Skip to content

Commit d6edba5

Browse files
committed
Accordion: Move code for deprecated height options into an extension at the bottom of the plugin.
1 parent f908281 commit d6edba5

File tree

2 files changed

+47
-30
lines changed

2 files changed

+47
-30
lines changed

tests/unit/accordion/accordion_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var accordion_defaults = {
1212
event: "click",
1313
fillSpace: false,
1414
header: "> li > :first-child,> :not(li):even",
15+
heightStyle: null,
1516
icons: { "header": "ui-icon-triangle-1-e", "headerSelected": "ui-icon-triangle-1-s" },
1617
navigation: false,
1718
navigationFilter: function() {}

ui/jquery.ui.accordion.js

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ $.widget( "ui.accordion", {
1717
options: {
1818
active: 0,
1919
animated: "slide",
20-
autoHeight: true, //DEPRECATED - use heightStyle: "auto"
21-
clearStyle: false, //DEPRECATED - use heightStyle: "content"
2220
collapsible: false,
2321
event: "click",
24-
fillSpace: false, //DEPRECATED - use heightStyle: "fill"
25-
//heightStyle: "auto",
2622
header: "> li > :first-child,> :not(li):even",
23+
// TODO: set to "auto" in 2.0 (#5868, #5872)
24+
heightStyle: null, // "auto"
2725
icons: {
2826
header: "ui-icon-triangle-1-e",
2927
headerSelected: "ui-icon-triangle-1-s"
@@ -34,9 +32,6 @@ $.widget( "ui.accordion", {
3432
var self = this,
3533
options = self.options;
3634

37-
//Merge autoheight, fillSpace and clearStyle
38-
options.heightStyle = options.heightStyle || self._mergeHeightStyle();
39-
4035
self.running = 0;
4136

4237
self.element
@@ -176,30 +171,9 @@ $.widget( "ui.accordion", {
176171
return $.Widget.prototype.destroy.call( this );
177172
},
178173

179-
_mergeHeightStyle: function() {
180-
var options = this.options;
181-
182-
if ( options.fillSpace ) {
183-
return "fill";
184-
}
185-
186-
if ( options.clearStyle ) {
187-
return "content";
188-
}
189-
190-
if ( options.autoHeight ) {
191-
return "auto";
192-
}
193-
},
194-
195174
_setOption: function( key, value ) {
196175
$.Widget.prototype._setOption.apply( this, arguments );
197176

198-
// handle deprecated options
199-
// TODO: remove in 2.0
200-
if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
201-
this.options.heightStyle = this._mergeHeightStyle();
202-
}
203177
if ( key == "active" ) {
204178
this.activate( value );
205179
}
@@ -626,7 +600,7 @@ $.extend( $.ui.accordion, {
626600
return this.href.toLowerCase() === location.href.toLowerCase();
627601
}
628602
});
629-
603+
630604
var _create = prototype._create;
631605
prototype._create = function() {
632606
if ( this.options.navigation ) {
@@ -648,6 +622,48 @@ $.extend( $.ui.accordion, {
648622
}
649623
_create.call( this );
650624
};
651-
}( jQuery, jQuery.ui.accordion.prototype ));
625+
}( jQuery, jQuery.ui.accordion.prototype ) );
626+
627+
(function( $, prototype ) {
628+
$.extend( prototype.options, {
629+
autoHeight: true, // use heightStyle: "auto"
630+
clearStyle: false, // use heightStyle: "content"
631+
fillSpace: false // use heightStyle: "fill"
632+
});
633+
634+
var _create = prototype._create,
635+
_setOption = prototype._setOption;
636+
637+
$.extend( prototype, {
638+
_create: function() {
639+
this.options.heightStyle = this.options.heightStyle ||
640+
this._mergeHeightStyle();
641+
_create.call( this );
642+
},
643+
644+
_setOption: function( key, value ) {
645+
if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
646+
this.options.heightStyle = this._mergeHeightStyle();
647+
}
648+
_setOption.apply( this, arguments );
649+
},
650+
651+
_mergeHeightStyle: function() {
652+
var options = this.options;
653+
654+
if ( options.fillSpace ) {
655+
return "fill";
656+
}
657+
658+
if ( options.clearStyle ) {
659+
return "content";
660+
}
661+
662+
if ( options.autoHeight ) {
663+
return "auto";
664+
}
665+
}
666+
});
667+
}( jQuery, jQuery.ui.accordion.prototype ) );
652668

653669
})( jQuery );

0 commit comments

Comments
 (0)