diff options
author | Danny Trunk <dtrunk90@googlemail.com> | 2012-05-28 15:11:20 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-05-28 15:11:20 -0400 |
commit | 6e2f95f59d73d86a2b84faecba3fca593534b8c9 (patch) | |
tree | 0027d165ef02ba1e67543afd7ac5769203480344 /ui | |
parent | 2662edf7393d2fbe594b22f6294e14725847a8e8 (diff) | |
download | jquery-ui-6e2f95f59d73d86a2b84faecba3fca593534b8c9.tar.gz jquery-ui-6e2f95f59d73d86a2b84faecba3fca593534b8c9.zip |
Tabs: Added heightStyle option. Fixed #8345 - Tabs: Add heightStyle option.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.tabs.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index a693899da..1224f47b9 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -34,6 +34,7 @@ $.widget( "ui.tabs", { active: null, collapsible: false, event: "click", + heightStyle: "content", hide: null, show: null, @@ -150,6 +151,10 @@ $.widget( "ui.tabs", { if ( key === "event" ) { this._setupEvents( value ); } + + if ( key === "heightStyle" ) { + this._setupHeightStyle( value ); + } }, _tabId: function( tab ) { @@ -202,6 +207,7 @@ $.widget( "ui.tabs", { this._setupDisabled( options.disabled ); this._setupEvents( options.event ); + this._setupHeightStyle( options.heightStyle ); // remove all handlers, may run on existing tabs this.lis.unbind( ".tabs" ); @@ -290,6 +296,50 @@ $.widget( "ui.tabs", { this._bind( this.anchors, events ); }, + _setupHeightStyle: function( heightStyle ) { + var maxHeight, overflow, + parent = this.element.parent(); + + if ( heightStyle === "fill" ) { + // IE 6 treats height like minHeight, so we need to turn off overflow + // in order to get a reliable height + // we use the minHeight support test because we assume that only + // browsers that don't support minHeight will treat height as minHeight + if ( !$.support.minHeight ) { + overflow = parent.css( "overflow" ); + parent.css( "overflow", "hidden"); + } + maxHeight = parent.height(); + this.element.siblings( ":visible" ).each(function() { + var elem = $( this ), + position = elem.css( "position" ); + + if ( position === "absolute" || position === "fixed" ) { + return; + } + maxHeight -= elem.outerHeight( true ); + }); + if ( overflow ) { + parent.css( "overflow", overflow ); + } + + this.element.children().not( this.panels ).each(function() { + maxHeight -= $( this ).outerHeight( true ); + }); + + this.panels.each(function() { + $( this ).height( Math.max( 0, maxHeight - + $( this ).innerHeight() + $( this ).height() ) ); + }) + .css( "overflow", "auto" ); + } else if ( heightStyle === "auto" ) { + maxHeight = 0; + this.panels.each(function() { + maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() ); + }).height( maxHeight ); + } + }, + _eventHandler: function( event ) { var options = this.options, active = this.active, @@ -448,6 +498,10 @@ $.widget( "ui.tabs", { } }); + if ( this.options.heightStyle !== "content" ) { + this.panels.css( "height", "" ); + } + return this; }, |