jquery.layout.resizePaneAccordions.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * UI Layout Callback: resizePaneAccordions
  3. *
  4. * This callback is used when a layout-pane contains 1 or more accordions
  5. * - whether the accordion a child of the pane or is nested within other elements
  6. * Assign this callback to the pane.onresize event:
  7. *
  8. * SAMPLE:
  9. * < jQuery UI 1.9: $("#elem").tabs({ show: $.layout.callbacks.resizePaneAccordions });
  10. * > jQuery UI 1.9: $("#elem").tabs({ activate: $.layout.callbacks.resizePaneAccordions });
  11. * $("body").layout({ center__onresize: $.layout.callbacks.resizePaneAccordions });
  12. *
  13. * Version: 1.2 - 2013-01-12
  14. * Author: Kevin Dalman (kevin@jquery-dev.com)
  15. */
  16. ;(function ($) {
  17. var _ = $.layout;
  18. // make sure the callbacks branch exists
  19. if (!_.callbacks) _.callbacks = {};
  20. _.callbacks.resizePaneAccordions = function (x, ui) {
  21. // may be called EITHER from layout-pane.onresize OR tabs.show
  22. var $P = ui.jquery ? ui : $(ui.newPanel || ui.panel);
  23. // find all VISIBLE accordions inside this pane and resize them
  24. $P.find(".ui-accordion:visible").each(function(){
  25. var $E = $(this);
  26. if ($E.data("accordion")) // jQuery < 1.9
  27. $E.accordion("resize");
  28. if ($E.data("ui-accordion")) // jQuery >= 1.9
  29. $E.accordion("refresh");
  30. });
  31. };
  32. })( jQuery );