Sha256: 410130a70f50594d7e4773447d82655496fa98da0cfdcc649f4cb3d9a031e8b2

Contents?: true

Size: 1.45 KB

Versions: 16

Compression:

Stored size: 1.45 KB

Contents

/*global Application */
;(function($){
    $.fn.collapsible = function() {

        var storage = Application.storage();

        return this.each(function() {

            if (storage && storage.getItem(this.id) === 'collapsed') {
                $(this)
                    .data('is_collapsed', true)
                    .find('tbody').hide().end()
                    .find('.arrow')
                    .animate({ rotate: '90deg' }, 200, 'ease-out');
            }

            $(this)
                .off('click', 'th')
                .on('click', 'th', function() {
                    var $table = $(this).closest('table');

                    if ($table.data('is_collapsed')) {
                        if (storage) storage.setItem($table.attr('id'), 'expanded');

                        $table
                            .data('is_collapsed', false)
                            .find('tbody').show().end()
                            .find('.arrow')
                            .animate({ rotate: '0' }, 200, 'ease-out');
                    } else {
                        if (storage) storage.setItem($table.attr('id'), 'collapsed');

                        $table
                            .data('is_collapsed', true)
                            .find('tbody').hide().end()
                            .find('.arrow')
                            .animate({ rotate: '90deg' }, 200, 'ease-out');
                    }
                });

        });
    };
})(Zepto);

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sports_db-0.2.19 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.18 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.17 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.16 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.15 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.14 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.13 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.12 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.11 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.10 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.9 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.8 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.7 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.6 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.5 app/assets/javascripts/plugins/collapsible.js
sports_db-0.2.4 app/assets/javascripts/plugins/collapsible.js