mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Accordion: Move code for deprecated height options into an extension at the bottom of the plugin.
This commit is contained in:
parent
f908281bc3
commit
d6edba5a89
@ -12,6 +12,7 @@ var accordion_defaults = {
|
|||||||
event: "click",
|
event: "click",
|
||||||
fillSpace: false,
|
fillSpace: false,
|
||||||
header: "> li > :first-child,> :not(li):even",
|
header: "> li > :first-child,> :not(li):even",
|
||||||
|
heightStyle: null,
|
||||||
icons: { "header": "ui-icon-triangle-1-e", "headerSelected": "ui-icon-triangle-1-s" },
|
icons: { "header": "ui-icon-triangle-1-e", "headerSelected": "ui-icon-triangle-1-s" },
|
||||||
navigation: false,
|
navigation: false,
|
||||||
navigationFilter: function() {}
|
navigationFilter: function() {}
|
||||||
|
72
ui/jquery.ui.accordion.js
vendored
72
ui/jquery.ui.accordion.js
vendored
@ -17,13 +17,11 @@ $.widget( "ui.accordion", {
|
|||||||
options: {
|
options: {
|
||||||
active: 0,
|
active: 0,
|
||||||
animated: "slide",
|
animated: "slide",
|
||||||
autoHeight: true, //DEPRECATED - use heightStyle: "auto"
|
|
||||||
clearStyle: false, //DEPRECATED - use heightStyle: "content"
|
|
||||||
collapsible: false,
|
collapsible: false,
|
||||||
event: "click",
|
event: "click",
|
||||||
fillSpace: false, //DEPRECATED - use heightStyle: "fill"
|
|
||||||
//heightStyle: "auto",
|
|
||||||
header: "> li > :first-child,> :not(li):even",
|
header: "> li > :first-child,> :not(li):even",
|
||||||
|
// TODO: set to "auto" in 2.0 (#5868, #5872)
|
||||||
|
heightStyle: null, // "auto"
|
||||||
icons: {
|
icons: {
|
||||||
header: "ui-icon-triangle-1-e",
|
header: "ui-icon-triangle-1-e",
|
||||||
headerSelected: "ui-icon-triangle-1-s"
|
headerSelected: "ui-icon-triangle-1-s"
|
||||||
@ -34,9 +32,6 @@ $.widget( "ui.accordion", {
|
|||||||
var self = this,
|
var self = this,
|
||||||
options = self.options;
|
options = self.options;
|
||||||
|
|
||||||
//Merge autoheight, fillSpace and clearStyle
|
|
||||||
options.heightStyle = options.heightStyle || self._mergeHeightStyle();
|
|
||||||
|
|
||||||
self.running = 0;
|
self.running = 0;
|
||||||
|
|
||||||
self.element
|
self.element
|
||||||
@ -176,30 +171,9 @@ $.widget( "ui.accordion", {
|
|||||||
return $.Widget.prototype.destroy.call( this );
|
return $.Widget.prototype.destroy.call( this );
|
||||||
},
|
},
|
||||||
|
|
||||||
_mergeHeightStyle: function() {
|
|
||||||
var options = this.options;
|
|
||||||
|
|
||||||
if ( options.fillSpace ) {
|
|
||||||
return "fill";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( options.clearStyle ) {
|
|
||||||
return "content";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( options.autoHeight ) {
|
|
||||||
return "auto";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_setOption: function( key, value ) {
|
_setOption: function( key, value ) {
|
||||||
$.Widget.prototype._setOption.apply( this, arguments );
|
$.Widget.prototype._setOption.apply( this, arguments );
|
||||||
|
|
||||||
// handle deprecated options
|
|
||||||
// TODO: remove in 2.0
|
|
||||||
if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
|
|
||||||
this.options.heightStyle = this._mergeHeightStyle();
|
|
||||||
}
|
|
||||||
if ( key == "active" ) {
|
if ( key == "active" ) {
|
||||||
this.activate( value );
|
this.activate( value );
|
||||||
}
|
}
|
||||||
@ -650,4 +624,46 @@ $.extend( $.ui.accordion, {
|
|||||||
};
|
};
|
||||||
}( jQuery, jQuery.ui.accordion.prototype ) );
|
}( jQuery, jQuery.ui.accordion.prototype ) );
|
||||||
|
|
||||||
|
(function( $, prototype ) {
|
||||||
|
$.extend( prototype.options, {
|
||||||
|
autoHeight: true, // use heightStyle: "auto"
|
||||||
|
clearStyle: false, // use heightStyle: "content"
|
||||||
|
fillSpace: false // use heightStyle: "fill"
|
||||||
|
});
|
||||||
|
|
||||||
|
var _create = prototype._create,
|
||||||
|
_setOption = prototype._setOption;
|
||||||
|
|
||||||
|
$.extend( prototype, {
|
||||||
|
_create: function() {
|
||||||
|
this.options.heightStyle = this.options.heightStyle ||
|
||||||
|
this._mergeHeightStyle();
|
||||||
|
_create.call( this );
|
||||||
|
},
|
||||||
|
|
||||||
|
_setOption: function( key, value ) {
|
||||||
|
if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
|
||||||
|
this.options.heightStyle = this._mergeHeightStyle();
|
||||||
|
}
|
||||||
|
_setOption.apply( this, arguments );
|
||||||
|
},
|
||||||
|
|
||||||
|
_mergeHeightStyle: function() {
|
||||||
|
var options = this.options;
|
||||||
|
|
||||||
|
if ( options.fillSpace ) {
|
||||||
|
return "fill";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( options.clearStyle ) {
|
||||||
|
return "content";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( options.autoHeight ) {
|
||||||
|
return "auto";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}( jQuery, jQuery.ui.accordion.prototype ) );
|
||||||
|
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
Loading…
Reference in New Issue
Block a user