Skip to content
Snippets Groups Projects
Main.js 2.65 KiB
Newer Older

/* global $ */
/* @depend TablesorterController.js */

var QfqNS = QfqNS || {};

$(document).ready( function () {
    (function (n) {

        var tablesorterController = new n.TablesorterController();
        $('.tablesorter').each(function(i) {
            tablesorterController.setup($(this), i);
        }); // end .each()

        $('.tablesorter-filter').addClass('qfq-skip-dirty');

        $('.qfq-auto-grow').each(function() {
            var minHeight = $(this).attr("rows") * 14 + 18;
            var newHeight = $(this).prop('scrollHeight');
            var maxHeight = $(this).data('max-height') || 0;

            if ($(this).val === '' || newHeight < minHeight) {
                return;
            }

            if (newHeight < maxHeight || maxHeight === 0) {
                $(this).height(newHeight);
            } else {
                $(this).height(maxHeight);
        $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
            $('.qfq-auto-grow').each(function () {
                var minHeight = $(this).attr("rows") * 14 + 18;
                var newHeight = $(this).prop('scrollHeight');
                var maxHeight = $(this).data('max-height') || 0;

                if ($(this).val === '' || newHeight < minHeight) {
                    return;
                }

                if (newHeight < maxHeight || maxHeight === 0) {
                    $(this).height(newHeight);
                } else {
                    $(this).height(maxHeight);
                }
            });
        });

bbaer's avatar
bbaer committed
        $('.qfq-auto-grow').on('input paste', function() {
            var newHeight = $(this).prop('scrollHeight');
            var maxHeight = $(this).data('max-height') || 0;
            if ($(this).outerHeight() < newHeight) {
                if(newHeight < maxHeight || maxHeight === 0) {
                    $(this).height(newHeight);
                }
            }
        });
bbaer's avatar
bbaer committed
        $('.qfq-clear-me').each(function() {
            var myInput = $(this);
bbaer's avatar
bbaer committed
            if(!myInput.is("input,textarea")) {
bbaer's avatar
bbaer committed
                return;
bbaer's avatar
bbaer committed
            }
bbaer's avatar
bbaer committed
            var closeButton = $("<span>", {
                class: "qfq-clear-me-button hidden"
            });
            closeButton.on("click", function(e) {
                myInput.val('');
                closeButton.addClass("hidden");
            });
            $(this).after(closeButton);
            $(this).on("input", function() {
bbaer's avatar
bbaer committed
                if(myInput.val() != '') {
                    closeButton.removeClass("hidden");
                } else {
                    closeButton.addClass("hidden");
                }
bbaer's avatar
bbaer committed
        });

    })(QfqNS);
});