mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Accordion: Use .uniqueId() and move animation properties into the widget prototype.
This commit is contained in:
parent
dbbf3a9611
commit
da185a6c15
71
ui/jquery.ui.accordion.js
vendored
71
ui/jquery.ui.accordion.js
vendored
@ -14,15 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
(function( $, undefined ) {
|
(function( $, undefined ) {
|
||||||
|
|
||||||
var uid = 0,
|
|
||||||
hideProps = {},
|
|
||||||
showProps = {};
|
|
||||||
|
|
||||||
hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
|
|
||||||
hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
|
|
||||||
showProps.height = showProps.paddingTop = showProps.paddingBottom =
|
|
||||||
showProps.borderTopWidth = showProps.borderBottomWidth = "show";
|
|
||||||
|
|
||||||
$.widget( "ui.accordion", {
|
$.widget( "ui.accordion", {
|
||||||
version: "@VERSION",
|
version: "@VERSION",
|
||||||
options: {
|
options: {
|
||||||
@ -42,6 +33,22 @@ $.widget( "ui.accordion", {
|
|||||||
beforeActivate: null
|
beforeActivate: null
|
||||||
},
|
},
|
||||||
|
|
||||||
|
hideProps: {
|
||||||
|
borderTopWidth: "hide",
|
||||||
|
borderBottomWidth: "hide",
|
||||||
|
paddingTop: "hide",
|
||||||
|
paddingBottom: "hide",
|
||||||
|
height: "hide"
|
||||||
|
},
|
||||||
|
|
||||||
|
showProps: {
|
||||||
|
borderTopWidth: "show",
|
||||||
|
borderBottomWidth: "show",
|
||||||
|
paddingTop: "show",
|
||||||
|
paddingBottom: "show",
|
||||||
|
height: "show"
|
||||||
|
},
|
||||||
|
|
||||||
_create: function() {
|
_create: function() {
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
this.prevShow = this.prevHide = $();
|
this.prevShow = this.prevHide = $();
|
||||||
@ -99,31 +106,27 @@ $.widget( "ui.accordion", {
|
|||||||
|
|
||||||
// clean up headers
|
// clean up headers
|
||||||
this.headers
|
this.headers
|
||||||
.removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
|
.removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
|
||||||
|
"ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
|
||||||
.removeAttr( "role" )
|
.removeAttr( "role" )
|
||||||
.removeAttr( "aria-selected" )
|
.removeAttr( "aria-selected" )
|
||||||
.removeAttr( "aria-controls" )
|
.removeAttr( "aria-controls" )
|
||||||
.removeAttr( "tabIndex" )
|
.removeAttr( "tabIndex" )
|
||||||
.each(function() {
|
.removeUniqueId();
|
||||||
if ( /^ui-accordion/.test( this.id ) ) {
|
|
||||||
this.removeAttribute( "id" );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this._destroyIcons();
|
this._destroyIcons();
|
||||||
|
|
||||||
// clean up content panels
|
// clean up content panels
|
||||||
contents = this.headers.next()
|
contents = this.headers.next()
|
||||||
|
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
|
||||||
|
"ui-accordion-content ui-accordion-content-active ui-state-disabled" )
|
||||||
.css( "display", "" )
|
.css( "display", "" )
|
||||||
.removeAttr( "role" )
|
.removeAttr( "role" )
|
||||||
.removeAttr( "aria-expanded" )
|
.removeAttr( "aria-expanded" )
|
||||||
.removeAttr( "aria-hidden" )
|
.removeAttr( "aria-hidden" )
|
||||||
.removeAttr( "aria-labelledby" )
|
.removeAttr( "aria-labelledby" )
|
||||||
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
|
.removeUniqueId();
|
||||||
.each(function() {
|
|
||||||
if ( /^ui-accordion/.test( this.id ) ) {
|
|
||||||
this.removeAttribute( "id" );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if ( this.options.heightStyle !== "content" ) {
|
if ( this.options.heightStyle !== "content" ) {
|
||||||
contents.css( "height", "" );
|
contents.css( "height", "" );
|
||||||
}
|
}
|
||||||
@ -259,9 +262,7 @@ $.widget( "ui.accordion", {
|
|||||||
var maxHeight,
|
var maxHeight,
|
||||||
options = this.options,
|
options = this.options,
|
||||||
heightStyle = options.heightStyle,
|
heightStyle = options.heightStyle,
|
||||||
parent = this.element.parent(),
|
parent = this.element.parent();
|
||||||
accordionId = this.accordionId = "ui-accordion-" +
|
|
||||||
(this.element.attr( "id" ) || ++uid);
|
|
||||||
|
|
||||||
this.active = this._findActive( options.active )
|
this.active = this._findActive( options.active )
|
||||||
.addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
|
.addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
|
||||||
@ -272,19 +273,11 @@ $.widget( "ui.accordion", {
|
|||||||
|
|
||||||
this.headers
|
this.headers
|
||||||
.attr( "role", "tab" )
|
.attr( "role", "tab" )
|
||||||
.each(function( i ) {
|
.each(function() {
|
||||||
var header = $( this ),
|
var header = $( this ),
|
||||||
headerId = header.attr( "id" ),
|
headerId = header.uniqueId().attr( "id" ),
|
||||||
panel = header.next(),
|
panel = header.next(),
|
||||||
panelId = panel.attr( "id" );
|
panelId = panel.uniqueId().attr( "id" );
|
||||||
if ( !headerId ) {
|
|
||||||
headerId = accordionId + "-header-" + i;
|
|
||||||
header.attr( "id", headerId );
|
|
||||||
}
|
|
||||||
if ( !panelId ) {
|
|
||||||
panelId = accordionId + "-panel-" + i;
|
|
||||||
panel.attr( "id", panelId );
|
|
||||||
}
|
|
||||||
header.attr( "aria-controls", panelId );
|
header.attr( "aria-controls", panelId );
|
||||||
panel.attr( "aria-labelledby", headerId );
|
panel.attr( "aria-labelledby", headerId );
|
||||||
})
|
})
|
||||||
@ -520,14 +513,14 @@ $.widget( "ui.accordion", {
|
|||||||
duration = duration || options.duration || animate.duration;
|
duration = duration || options.duration || animate.duration;
|
||||||
|
|
||||||
if ( !toHide.length ) {
|
if ( !toHide.length ) {
|
||||||
return toShow.animate( showProps, duration, easing, complete );
|
return toShow.animate( this.showProps, duration, easing, complete );
|
||||||
}
|
}
|
||||||
if ( !toShow.length ) {
|
if ( !toShow.length ) {
|
||||||
return toHide.animate( hideProps, duration, easing, complete );
|
return toHide.animate( this.hideProps, duration, easing, complete );
|
||||||
}
|
}
|
||||||
|
|
||||||
total = toShow.show().outerHeight();
|
total = toShow.show().outerHeight();
|
||||||
toHide.animate( hideProps, {
|
toHide.animate( this.hideProps, {
|
||||||
duration: duration,
|
duration: duration,
|
||||||
easing: easing,
|
easing: easing,
|
||||||
step: function( now, fx ) {
|
step: function( now, fx ) {
|
||||||
@ -536,7 +529,7 @@ $.widget( "ui.accordion", {
|
|||||||
});
|
});
|
||||||
toShow
|
toShow
|
||||||
.hide()
|
.hide()
|
||||||
.animate( showProps, {
|
.animate( this.showProps, {
|
||||||
duration: duration,
|
duration: duration,
|
||||||
easing: easing,
|
easing: easing,
|
||||||
complete: complete,
|
complete: complete,
|
||||||
|
Loading…
Reference in New Issue
Block a user