Sha256: e661cb5d223d1c5a5f479c6e6cf5263385021ed23927bd17dfad4c45051ba556

Contents?: true

Size: 1.74 KB

Versions: 62

Compression:

Stored size: 1.74 KB

Contents

/**
 * @namespace WORKAREA.expandables
 */
WORKAREA.registerModule('expandables', (function () {
    'use strict';

    var getThreshold = function ($element) {
            return _.min([
                WORKAREA.config.expandable.threshold,
                $element.data('expandable') || undefined
            ]);
        },

        expand = function (event) {
            var $ui = $(event.target).closest('.expandable');

            $ui.addClass('expandable--expanded');

            $ui.find('.expandable__element').css({
                maxHeight: 'none'
            });
        },

        addButton = function ($ui) {
            var button = JST['workarea/admin/templates/expandable_button']();

            $(button)
            .on('click', expand)
            .appendTo($ui);
        },

        setHeight = function ($element) {
            $element.css({
                maxHeight: getThreshold($element)
            });
        },

        addUI = function ($element) {
            $element.addClass('expandable__element');
            return $element.wrap('<div class="expandable" />').parent();
        },

        setup = function ($element) {
            var $ui = addUI($element);
            setHeight($element);
            addButton($ui);
        },

        testHeight = function (index, element) {
            var $element = $(element),
                threshold = getThreshold($element);

            if ($element.height() < threshold) { return; }

            setup($element);
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.expandables
         */
        init = function ($scope) {
            $('[data-expandable]', $scope).each(testHeight);
        };

    return {
        init: init
    };
}()));

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.26 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.45 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.25 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.23 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.44 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.22 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.43 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.21 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.42 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.20 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.41 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.19 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.40 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.18 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.39 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.17 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.38 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.5.16 app/assets/javascripts/workarea/admin/modules/expandables.js
workarea-admin-3.4.37 app/assets/javascripts/workarea/admin/modules/expandables.js