aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.accordion.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.ui.accordion.js')
-rw-r--r--ui/jquery.ui.accordion.js92
1 files changed, 42 insertions, 50 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 26a9ce94f..131d12c32 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -14,15 +14,6 @@
*/
(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", {
version: "@VERSION",
options: {
@@ -42,6 +33,22 @@ $.widget( "ui.accordion", {
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() {
var options = this.options;
this.prevShow = this.prevHide = $();
@@ -99,31 +106,27 @@ $.widget( "ui.accordion", {
// clean up 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( "aria-expanded" )
.removeAttr( "aria-selected" )
.removeAttr( "aria-controls" )
.removeAttr( "tabIndex" )
- .each(function() {
- if ( /^ui-accordion/.test( this.id ) ) {
- this.removeAttribute( "id" );
- }
- });
+ .removeUniqueId();
+
this._destroyIcons();
// clean up content panels
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", "" )
.removeAttr( "role" )
- .removeAttr( "aria-expanded" )
.removeAttr( "aria-hidden" )
.removeAttr( "aria-labelledby" )
- .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
- .each(function() {
- if ( /^ui-accordion/.test( this.id ) ) {
- this.removeAttribute( "id" );
- }
- });
+ .removeUniqueId();
+
if ( this.options.heightStyle !== "content" ) {
contents.css( "height", "" );
}
@@ -259,9 +262,7 @@ $.widget( "ui.accordion", {
var maxHeight,
options = this.options,
heightStyle = options.heightStyle,
- parent = this.element.parent(),
- accordionId = this.accordionId = "ui-accordion-" +
- (this.element.attr( "id" ) || ++uid);
+ parent = this.element.parent();
this.active = this._findActive( options.active )
.addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
@@ -272,19 +273,11 @@ $.widget( "ui.accordion", {
this.headers
.attr( "role", "tab" )
- .each(function( i ) {
+ .each(function() {
var header = $( this ),
- headerId = header.attr( "id" ),
+ headerId = header.uniqueId().attr( "id" ),
panel = header.next(),
- panelId = panel.attr( "id" );
- if ( !headerId ) {
- headerId = accordionId + "-header-" + i;
- header.attr( "id", headerId );
- }
- if ( !panelId ) {
- panelId = accordionId + "-panel-" + i;
- panel.attr( "id", panelId );
- }
+ panelId = panel.uniqueId().attr( "id" );
header.attr( "aria-controls", panelId );
panel.attr( "aria-labelledby", headerId );
})
@@ -295,11 +288,11 @@ $.widget( "ui.accordion", {
.not( this.active )
.attr({
"aria-selected": "false",
+ "aria-expanded": "false",
tabIndex: -1
})
.next()
.attr({
- "aria-expanded": "false",
"aria-hidden": "true"
})
.hide();
@@ -310,11 +303,11 @@ $.widget( "ui.accordion", {
} else {
this.active.attr({
"aria-selected": "true",
+ "aria-expanded": "true",
tabIndex: 0
})
.next()
.attr({
- "aria-expanded": "true",
"aria-hidden": "false"
});
}
@@ -469,7 +462,6 @@ $.widget( "ui.accordion", {
}
toHide.attr({
- "aria-expanded": "false",
"aria-hidden": "true"
});
toHide.prev().attr( "aria-selected", "false" );
@@ -477,7 +469,10 @@ $.widget( "ui.accordion", {
// if we're opening from collapsed state, remove the previous header from the tab order
// if we're collapsing, then keep the collapsing header in the tab order
if ( toShow.length && toHide.length ) {
- toHide.prev().attr( "tabIndex", -1 );
+ toHide.prev().attr({
+ "tabIndex": -1,
+ "aria-expanded": "false"
+ });
} else if ( toShow.length ) {
this.headers.filter(function() {
return $( this ).attr( "tabIndex" ) === 0;
@@ -486,14 +481,12 @@ $.widget( "ui.accordion", {
}
toShow
- .attr({
- "aria-expanded": "true",
- "aria-hidden": "false"
- })
+ .attr( "aria-hidden", "false" )
.prev()
.attr({
"aria-selected": "true",
- tabIndex: 0
+ tabIndex: 0,
+ "aria-expanded": "true"
});
},
@@ -520,14 +513,14 @@ $.widget( "ui.accordion", {
duration = duration || options.duration || animate.duration;
if ( !toHide.length ) {
- return toShow.animate( showProps, duration, easing, complete );
+ return toShow.animate( this.showProps, duration, easing, complete );
}
if ( !toShow.length ) {
- return toHide.animate( hideProps, duration, easing, complete );
+ return toHide.animate( this.hideProps, duration, easing, complete );
}
total = toShow.show().outerHeight();
- toHide.animate( hideProps, {
+ toHide.animate( this.hideProps, {
duration: duration,
easing: easing,
step: function( now, fx ) {
@@ -536,7 +529,7 @@ $.widget( "ui.accordion", {
});
toShow
.hide()
- .animate( showProps, {
+ .animate( this.showProps, {
duration: duration,
easing: easing,
complete: complete,
@@ -565,7 +558,6 @@ $.widget( "ui.accordion", {
if ( toHide.length ) {
toHide.parent()[0].className = toHide.parent()[0].className;
}
-
this._trigger( "activate", null, data );
}
});