Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. /**
  2. * Multiple accordion
  3. * It extends jQuery UI Accordion 1.11.x (Copyright 2015 jQuery Foundation and other contributors)
  4. * Shamely created by Comandeer, released under MIT license
  5. */
  6. (function($)
  7. {
  8. var _create = $.ui.accordion.prototype._create
  9. ,_toggle = $.ui.accordion.prototype._toggle;
  10.  
  11. $.extend($.ui.accordion.prototype, {
  12. _create: function()
  13. {
  14. var options = this.options;
  15.  
  16. if(options.multiple && !options.collapsible)
  17. options.collapsible = true;
  18.  
  19. _create.call(this);
  20.  
  21. var active = this.element.find('.ui-accordion-content').eq(options.active);
  22.  
  23. this.shown = [];
  24.  
  25. if(active.is(':visible'))
  26. this.shown.push(active[0]);
  27. }
  28. ,_toggle: function(obj)
  29. {
  30. if(!this.options.multiple)
  31. return _toggle.call(this, obj);
  32.  
  33. var active = this.element.find('.ui-accordion-content').eq(this.options.active)
  34. ,prev = this.prevShow
  35. ,toChange = obj.newPanel.length ? obj.newPanel : (prev.length ? prev : active)
  36. ,i = this.shown.indexOf(toChange[0]);
  37.  
  38. this.prevShow = this.prevHide = $([]);
  39.  
  40. if(i !== -1)
  41. {
  42. obj.oldHeader = obj.newHeader;
  43. obj.oldPanel = toChange;
  44.  
  45. obj.newPanel = obj.newHeader = $([]);
  46.  
  47. this.shown.splice(i, 1);
  48. }
  49. else
  50. {
  51. obj.oldHeader = obj.oldPanel = $([]);
  52.  
  53. this.shown.push(obj.newPanel[0]);
  54. }
  55.  
  56. _toggle.call(this, obj);
  57. }
  58. });
  59. }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement