Subversion Repositories oidplus

Rev

View as "text/javascript" | Blame | Last modification | View Log | RSS feed

  1. /**
  2.  *      UI Layout Callback: resizeTabLayout
  3.  *
  4.  *      Requires Layout 1.3.0.rc29.15 or later
  5.  *
  6.  *      This callback is used when a tab-panel is the container for a layout
  7.  *      The tab-layout can be initialized either before or after the tabs are created
  8.  *      Assign this callback to the tabs.show event:
  9.  *      - if the layout HAS been fully initialized already, it will be resized
  10.  *      - if the layout has NOT fully initialized, it will attempt to do so
  11.  *              - if it cannot initialize, it will try again next time the tab is accessed
  12.  *              - it also looks for ANY visible layout *inside* teh tab and resize/init it
  13.  *
  14.  *      SAMPLE:
  15.  *      < jQuery UI 1.9: $("#elem").tabs({ show: $.layout.callbacks.resizeTabLayout });
  16.  *      > jQuery UI 1.9: $("#elem").tabs({ activate: $.layout.callbacks.resizeTabLayout });
  17.  *      $("body").layout({ center__onresize: $.layout.callbacks.resizeTabLayout });
  18.  *
  19.  *      Version:        1.3 - 2013-01-12
  20.  *      Author:         Kevin Dalman (kevin@jquery-dev.com)
  21.  */
  22. ;(function ($) {
  23. var _ = $.layout;
  24.  
  25. // make sure the callbacks branch exists
  26. if (!_.callbacks) _.callbacks = {};
  27.  
  28. // this callback is bound to the tabs.show event OR to layout-pane.onresize event
  29. _.callbacks.resizeTabLayout = function (x, ui) {
  30.         // may be called EITHER from layout-pane.onresize OR tabs.show/activate
  31.         var $P = ui.jquery ? ui : $(ui.newPanel || ui.panel);
  32.         // find all VISIBLE layouts inside this pane/panel and resize them
  33.         $P.filter(":visible").find(".ui-layout-container:visible").andSelf().each(function(){
  34.                 var layout = $(this).data("layout");
  35.                 if (layout) {
  36.                         layout.options.resizeWithWindow = false; // set option just in case not already set
  37.                         layout.resizeAll();
  38.                 }
  39.         });
  40. };
  41. })( jQuery );