summaryrefslogtreecommitdiff
path: root/xstatic/pkg/jquery_ui/data/ui/jquery.ui.accordion.js
diff options
context:
space:
mode:
Diffstat (limited to 'xstatic/pkg/jquery_ui/data/ui/jquery.ui.accordion.js')
-rw-r--r--xstatic/pkg/jquery_ui/data/ui/jquery.ui.accordion.js437
1 files changed, 138 insertions, 299 deletions
diff --git a/xstatic/pkg/jquery_ui/data/ui/jquery.ui.accordion.js b/xstatic/pkg/jquery_ui/data/ui/jquery.ui.accordion.js
index 55bbecb..ac2fcd5 100644
--- a/xstatic/pkg/jquery_ui/data/ui/jquery.ui.accordion.js
+++ b/xstatic/pkg/jquery_ui/data/ui/jquery.ui.accordion.js
@@ -1,8 +1,8 @@
/*!
- * jQuery UI Accordion 1.9.2
+ * jQuery UI Accordion 1.10.4
* http://jqueryui.com
*
- * Copyright 2012 jQuery Foundation and other contributors
+ * Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
@@ -24,7 +24,7 @@ showProps.height = showProps.paddingTop = showProps.paddingBottom =
showProps.borderTopWidth = showProps.borderBottomWidth = "show";
$.widget( "ui.accordion", {
- version: "1.9.2",
+ version: "1.10.4",
options: {
active: 0,
animate: {},
@@ -43,100 +43,29 @@ $.widget( "ui.accordion", {
},
_create: function() {
- var accordionId = this.accordionId = "ui-accordion-" +
- (this.element.attr( "id" ) || ++uid),
- options = this.options;
-
+ var options = this.options;
this.prevShow = this.prevHide = $();
- this.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
-
- this.headers = this.element.find( options.header )
- .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
- this._hoverable( this.headers );
- this._focusable( this.headers );
-
- this.headers.next()
- .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
- .hide();
+ this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
+ // ARIA
+ .attr( "role", "tablist" );
// don't allow collapsible: false and active: false / null
if ( !options.collapsible && (options.active === false || options.active == null) ) {
options.active = 0;
}
+
+ this._processPanels();
// handle negative values
if ( options.active < 0 ) {
options.active += this.headers.length;
}
- this.active = this._findActive( options.active )
- .addClass( "ui-accordion-header-active ui-state-active" )
- .toggleClass( "ui-corner-all ui-corner-top" );
- this.active.next()
- .addClass( "ui-accordion-content-active" )
- .show();
-
- this._createIcons();
- this.refresh();
-
- // ARIA
- this.element.attr( "role", "tablist" );
-
- this.headers
- .attr( "role", "tab" )
- .each(function( i ) {
- var header = $( this ),
- headerId = header.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 );
- }
- header.attr( "aria-controls", panelId );
- panel.attr( "aria-labelledby", headerId );
- })
- .next()
- .attr( "role", "tabpanel" );
-
- this.headers
- .not( this.active )
- .attr({
- "aria-selected": "false",
- tabIndex: -1
- })
- .next()
- .attr({
- "aria-expanded": "false",
- "aria-hidden": "true"
- })
- .hide();
-
- // make sure at least one header is in the tab order
- if ( !this.active.length ) {
- this.headers.eq( 0 ).attr( "tabIndex", 0 );
- } else {
- this.active.attr({
- "aria-selected": "true",
- tabIndex: 0
- })
- .next()
- .attr({
- "aria-expanded": "true",
- "aria-hidden": "false"
- });
- }
-
- this._on( this.headers, { keydown: "_keydown" });
- this._on( this.headers.next(), { keydown: "_panelKeyDown" });
- this._setupEvents( options.event );
+ this._refresh();
},
_getCreateEventData: function() {
return {
header: this.active,
+ panel: !this.active.length ? $() : this.active.next(),
content: !this.active.length ? $() : this.active.next()
};
},
@@ -173,6 +102,7 @@ $.widget( "ui.accordion", {
this.headers
.removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset 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" )
@@ -187,7 +117,6 @@ $.widget( "ui.accordion", {
contents = this.headers.next()
.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" )
@@ -283,20 +212,116 @@ $.widget( "ui.accordion", {
},
refresh: function() {
- var maxHeight, overflow,
- heightStyle = this.options.heightStyle,
- parent = this.element.parent();
+ var options = this.options;
+ this._processPanels();
+
+ // was collapsed or no panel
+ if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
+ options.active = false;
+ this.active = $();
+ // active false only when collapsible is true
+ } else if ( options.active === false ) {
+ this._activate( 0 );
+ // was active, but active panel is gone
+ } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
+ // all remaining panel are disabled
+ if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
+ options.active = false;
+ this.active = $();
+ // activate previous panel
+ } else {
+ this._activate( Math.max( 0, options.active - 1 ) );
+ }
+ // was active, active panel still exists
+ } else {
+ // make sure active index is correct
+ options.active = this.headers.index( this.active );
+ }
+
+ this._destroyIcons();
+
+ this._refresh();
+ },
+
+ _processPanels: function() {
+ this.headers = this.element.find( this.options.header )
+ .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
+ this.headers.next()
+ .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
+ .filter(":not(.ui-accordion-content-active)")
+ .hide();
+ },
+
+ _refresh: function() {
+ var maxHeight,
+ options = this.options,
+ heightStyle = options.heightStyle,
+ parent = this.element.parent(),
+ accordionId = this.accordionId = "ui-accordion-" +
+ (this.element.attr( "id" ) || ++uid);
+
+ this.active = this._findActive( options.active )
+ .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
+ .removeClass( "ui-corner-all" );
+ this.active.next()
+ .addClass( "ui-accordion-content-active" )
+ .show();
+
+ this.headers
+ .attr( "role", "tab" )
+ .each(function( i ) {
+ var header = $( this ),
+ headerId = header.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 );
+ }
+ header.attr( "aria-controls", panelId );
+ panel.attr( "aria-labelledby", headerId );
+ })
+ .next()
+ .attr( "role", "tabpanel" );
+
+ this.headers
+ .not( this.active )
+ .attr({
+ "aria-selected": "false",
+ "aria-expanded": "false",
+ tabIndex: -1
+ })
+ .next()
+ .attr({
+ "aria-hidden": "true"
+ })
+ .hide();
+
+ // make sure at least one header is in the tab order
+ if ( !this.active.length ) {
+ this.headers.eq( 0 ).attr( "tabIndex", 0 );
+ } else {
+ this.active.attr({
+ "aria-selected": "true",
+ "aria-expanded": "true",
+ tabIndex: 0
+ })
+ .next()
+ .attr({
+ "aria-hidden": "false"
+ });
+ }
+
+ this._createIcons();
+
+ this._setupEvents( options.event );
if ( heightStyle === "fill" ) {
- // IE 6 treats height like minHeight, so we need to turn off overflow
- // in order to get a reliable height
- // we use the minHeight support test because we assume that only
- // browsers that don't support minHeight will treat height as minHeight
- if ( !$.support.minHeight ) {
- overflow = parent.css( "overflow" );
- parent.css( "overflow", "hidden");
- }
maxHeight = parent.height();
this.element.siblings( ":visible" ).each(function() {
var elem = $( this ),
@@ -307,9 +332,6 @@ $.widget( "ui.accordion", {
}
maxHeight -= elem.outerHeight( true );
});
- if ( overflow ) {
- parent.css( "overflow", overflow );
- }
this.headers.each(function() {
maxHeight -= $( this ).outerHeight( true );
@@ -354,14 +376,20 @@ $.widget( "ui.accordion", {
},
_setupEvents: function( event ) {
- var events = {};
- if ( !event ) {
- return;
+ var events = {
+ keydown: "_keydown"
+ };
+ if ( event ) {
+ $.each( event.split(" "), function( index, eventName ) {
+ events[ eventName ] = "_eventHandler";
+ });
}
- $.each( event.split(" "), function( index, eventName ) {
- events[ eventName ] = "_eventHandler";
- });
+
+ this._off( this.headers.add( this.headers.next() ) );
this._on( this.headers, events );
+ this._on( this.headers.next(), { keydown: "_panelKeyDown" });
+ this._hoverable( this.headers );
+ this._focusable( this.headers );
},
_eventHandler: function( event ) {
@@ -439,7 +467,6 @@ $.widget( "ui.accordion", {
}
toHide.attr({
- "aria-expanded": "false",
"aria-hidden": "true"
});
toHide.prev().attr( "aria-selected", "false" );
@@ -447,7 +474,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;
@@ -456,14 +486,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"
});
},
@@ -535,197 +563,8 @@ $.widget( "ui.accordion", {
if ( toHide.length ) {
toHide.parent()[0].className = toHide.parent()[0].className;
}
-
this._trigger( "activate", null, data );
}
});
-
-
-// DEPRECATED
-if ( $.uiBackCompat !== false ) {
- // navigation options
- (function( $, prototype ) {
- $.extend( prototype.options, {
- navigation: false,
- navigationFilter: function() {
- return this.href.toLowerCase() === location.href.toLowerCase();
- }
- });
-
- var _create = prototype._create;
- prototype._create = function() {
- if ( this.options.navigation ) {
- var that = this,
- headers = this.element.find( this.options.header ),
- content = headers.next(),
- current = headers.add( content )
- .find( "a" )
- .filter( this.options.navigationFilter )
- [ 0 ];
- if ( current ) {
- headers.add( content ).each( function( index ) {
- if ( $.contains( this, current ) ) {
- that.options.active = Math.floor( index / 2 );
- return false;
- }
- });
- }
- }
- _create.call( this );
- };
- }( jQuery, jQuery.ui.accordion.prototype ) );
-
- // height options
- (function( $, prototype ) {
- $.extend( prototype.options, {
- heightStyle: null, // remove default so we fall back to old values
- 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 ) {
- 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 ) );
-
- // icon options
- (function( $, prototype ) {
- $.extend( prototype.options.icons, {
- activeHeader: null, // remove default so we fall back to old values
- headerSelected: "ui-icon-triangle-1-s"
- });
-
- var _createIcons = prototype._createIcons;
- prototype._createIcons = function() {
- if ( this.options.icons ) {
- this.options.icons.activeHeader = this.options.icons.activeHeader ||
- this.options.icons.headerSelected;
- }
- _createIcons.call( this );
- };
- }( jQuery, jQuery.ui.accordion.prototype ) );
-
- // expanded active option, activate method
- (function( $, prototype ) {
- prototype.activate = prototype._activate;
-
- var _findActive = prototype._findActive;
- prototype._findActive = function( index ) {
- if ( index === -1 ) {
- index = false;
- }
- if ( index && typeof index !== "number" ) {
- index = this.headers.index( this.headers.filter( index ) );
- if ( index === -1 ) {
- index = false;
- }
- }
- return _findActive.call( this, index );
- };
- }( jQuery, jQuery.ui.accordion.prototype ) );
-
- // resize method
- jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;
-
- // change events
- (function( $, prototype ) {
- $.extend( prototype.options, {
- change: null,
- changestart: null
- });
-
- var _trigger = prototype._trigger;
- prototype._trigger = function( type, event, data ) {
- var ret = _trigger.apply( this, arguments );
- if ( !ret ) {
- return false;
- }
-
- if ( type === "beforeActivate" ) {
- ret = _trigger.call( this, "changestart", event, {
- oldHeader: data.oldHeader,
- oldContent: data.oldPanel,
- newHeader: data.newHeader,
- newContent: data.newPanel
- });
- } else if ( type === "activate" ) {
- ret = _trigger.call( this, "change", event, {
- oldHeader: data.oldHeader,
- oldContent: data.oldPanel,
- newHeader: data.newHeader,
- newContent: data.newPanel
- });
- }
- return ret;
- };
- }( jQuery, jQuery.ui.accordion.prototype ) );
-
- // animated option
- // NOTE: this only provides support for "slide", "bounceslide", and easings
- // not the full $.ui.accordion.animations API
- (function( $, prototype ) {
- $.extend( prototype.options, {
- animate: null,
- animated: "slide"
- });
-
- var _create = prototype._create;
- prototype._create = function() {
- var options = this.options;
- if ( options.animate === null ) {
- if ( !options.animated ) {
- options.animate = false;
- } else if ( options.animated === "slide" ) {
- options.animate = 300;
- } else if ( options.animated === "bounceslide" ) {
- options.animate = {
- duration: 200,
- down: {
- easing: "easeOutBounce",
- duration: 1000
- }
- };
- } else {
- options.animate = options.animated;
- }
- }
-
- _create.call( this );
- };
- }( jQuery, jQuery.ui.accordion.prototype ) );
-}
-
})( jQuery );