Skip to content

Commit 352ef4c

Browse files
committed
Accordion: Cleaned up destroy and refresh methods.
1 parent a4da197 commit 352ef4c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

ui/jquery.ui.accordion.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ $.widget( "ui.accordion", {
120120
},
121121

122122
_destroy: function() {
123-
var options = this.options;
124-
123+
// clean up main element
125124
this.element
126125
.removeClass( "ui-accordion ui-widget ui-helper-reset" )
127126
.removeAttr( "role" );
128127

128+
// clean up headers
129129
this.headers
130130
.unbind( ".accordion" )
131131
.removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
@@ -139,11 +139,12 @@ $.widget( "ui.accordion", {
139139
.removeClass( "ui-accordion-heading" );
140140
this._destroyIcons();
141141

142+
// clean up content panels
142143
var contents = this.headers.next()
143144
.css( "display", "" )
144145
.removeAttr( "role" )
145146
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
146-
if ( options.heightStyle !== "content" ) {
147+
if ( this.options.heightStyle !== "content" ) {
147148
contents.css( "height", "" );
148149
}
149150
},
@@ -211,14 +212,20 @@ $.widget( "ui.accordion", {
211212

212213
refresh: function() {
213214
var options = this.options,
214-
maxHeight;
215+
parent = this.element.parent(),
216+
maxHeight,
217+
overflow;
215218

216219
if ( options.heightStyle === "fill" ) {
217-
if ( $.browser.msie ) {
218-
var defOverflow = this.element.parent().css( "overflow" );
219-
this.element.parent().css( "overflow", "hidden");
220+
// IE 6 treats height like minHeight, so we need to turn off overflow
221+
// in ordder to get a reliable height
222+
// we use the minHeight support test because we assume that only
223+
// browsers that don't support minHeight will treat height as minHeight
224+
if ( !$.support.minHeight ) {
225+
overflow = parent.css( "overflow" );
226+
parent.css( "overflow", "hidden");
220227
}
221-
maxHeight = this.element.parent().height();
228+
maxHeight = parent.height();
222229
this.element.siblings( ":visible" ).each(function() {
223230
var elem = $( this ),
224231
position = elem.css( "position" );
@@ -228,8 +235,8 @@ $.widget( "ui.accordion", {
228235
}
229236
maxHeight -= elem.outerHeight( true );
230237
});
231-
if ($.browser.msie) {
232-
this.element.parent().css( "overflow", defOverflow );
238+
if ( overflow ) {
239+
parent.css( "overflow", overflow );
233240
}
234241

235242
this.headers.each(function() {
@@ -305,7 +312,6 @@ $.widget( "ui.accordion", {
305312
this._toggle( toShow, toHide, data );
306313
},
307314

308-
// TODO: add tests/docs for negative values in 2.0 (#6854)
309315
_findActive: function( selector ) {
310316
return typeof selector === "number" ? this.headers.eq( selector ) : $();
311317
},

0 commit comments

Comments
 (0)