Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Multiple accordion
- * It extends jQuery UI Accordion 1.11.x (Copyright 2015 jQuery Foundation and other contributors)
- * Shamely created by Comandeer, released under MIT license
- */
- (function($)
- {
- var _create = $.ui.accordion.prototype._create
- ,_toggle = $.ui.accordion.prototype._toggle;
- $.extend($.ui.accordion.prototype, {
- _create: function()
- {
- var options = this.options;
- if(options.multiple && !options.collapsible)
- options.collapsible = true;
- _create.call(this);
- var active = this.element.find('.ui-accordion-content').eq(options.active);
- this.shown = [];
- if(active.is(':visible'))
- this.shown.push(active[0]);
- }
- ,_toggle: function(obj)
- {
- if(!this.options.multiple)
- return _toggle.call(this, obj);
- var active = this.element.find('.ui-accordion-content').eq(this.options.active)
- ,prev = this.prevShow
- ,toChange = obj.newPanel.length ? obj.newPanel : (prev.length ? prev : active)
- ,i = this.shown.indexOf(toChange[0]);
- this.prevShow = this.prevHide = $([]);
- if(i !== -1)
- {
- obj.oldHeader = obj.newHeader;
- obj.oldPanel = toChange;
- obj.newPanel = obj.newHeader = $([]);
- this.shown.splice(i, 1);
- }
- else
- {
- obj.oldHeader = obj.oldPanel = $([]);
- this.shown.push(obj.newPanel[0]);
- }
- _toggle.call(this, obj);
- }
- });
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement