Sha256: 1e0b2efef62d3f00bc2797d6d168089718155693ed7f8817b15a5bf30015299c

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

;(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

1 entries across 1 versions & 1 rubygems

Version Path
sports_db-0.2.3 app/assets/javascripts/plugins/collapsible.js