@@ -34,6 +34,7 @@ $.widget( "ui.tabs", {
3434 active : null ,
3535 collapsible : false ,
3636 event : "click" ,
37+ heightStyle : "content" ,
3738 hide : null ,
3839 show : null ,
3940
@@ -150,6 +151,10 @@ $.widget( "ui.tabs", {
150151 if ( key === "event" ) {
151152 this . _setupEvents ( value ) ;
152153 }
154+
155+ if ( key === "heightStyle" ) {
156+ this . _setupHeightStyle ( value ) ;
157+ }
153158 } ,
154159
155160 _tabId : function ( tab ) {
@@ -202,6 +207,7 @@ $.widget( "ui.tabs", {
202207
203208 this . _setupDisabled ( options . disabled ) ;
204209 this . _setupEvents ( options . event ) ;
210+ this . _setupHeightStyle ( options . heightStyle ) ;
205211
206212 // remove all handlers, may run on existing tabs
207213 this . lis . unbind ( ".tabs" ) ;
@@ -290,6 +296,50 @@ $.widget( "ui.tabs", {
290296 this . _bind ( this . anchors , events ) ;
291297 } ,
292298
299+ _setupHeightStyle : function ( heightStyle ) {
300+ var maxHeight , overflow ,
301+ parent = this . element . parent ( ) ;
302+
303+ if ( heightStyle === "fill" ) {
304+ // IE 6 treats height like minHeight, so we need to turn off overflow
305+ // in order to get a reliable height
306+ // we use the minHeight support test because we assume that only
307+ // browsers that don't support minHeight will treat height as minHeight
308+ if ( ! $ . support . minHeight ) {
309+ overflow = parent . css ( "overflow" ) ;
310+ parent . css ( "overflow" , "hidden" ) ;
311+ }
312+ maxHeight = parent . height ( ) ;
313+ this . element . siblings ( ":visible" ) . each ( function ( ) {
314+ var elem = $ ( this ) ,
315+ position = elem . css ( "position" ) ;
316+
317+ if ( position === "absolute" || position === "fixed" ) {
318+ return ;
319+ }
320+ maxHeight -= elem . outerHeight ( true ) ;
321+ } ) ;
322+ if ( overflow ) {
323+ parent . css ( "overflow" , overflow ) ;
324+ }
325+
326+ this . element . children ( ) . not ( this . panels ) . each ( function ( ) {
327+ maxHeight -= $ ( this ) . outerHeight ( true ) ;
328+ } ) ;
329+
330+ this . panels . each ( function ( ) {
331+ $ ( this ) . height ( Math . max ( 0 , maxHeight -
332+ $ ( this ) . innerHeight ( ) + $ ( this ) . height ( ) ) ) ;
333+ } )
334+ . css ( "overflow" , "auto" ) ;
335+ } else if ( heightStyle === "auto" ) {
336+ maxHeight = 0 ;
337+ this . panels . each ( function ( ) {
338+ maxHeight = Math . max ( maxHeight , $ ( this ) . height ( "" ) . height ( ) ) ;
339+ } ) . height ( maxHeight ) ;
340+ }
341+ } ,
342+
293343 _eventHandler : function ( event ) {
294344 var options = this . options ,
295345 active = this . active ,
@@ -448,6 +498,10 @@ $.widget( "ui.tabs", {
448498 }
449499 } ) ;
450500
501+ if ( this . options . heightStyle !== "content" ) {
502+ this . panels . css ( "height" , "" ) ;
503+ }
504+
451505 return this ;
452506 } ,
453507
0 commit comments