jquery-accordion.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. /*! jQuery UI - v1.12.1 - 2021-06-01
  2. * http://jqueryui.com
  3. * Includes: widget.js, keycode.js, unique-id.js, widgets/accordion.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. $.ui = $.ui || {};
  15. var version = $.ui.version = "1.12.1";
  16. /*!
  17. * jQuery UI Widget 1.12.1
  18. * http://jqueryui.com
  19. *
  20. * Copyright jQuery Foundation and other contributors
  21. * Released under the MIT license.
  22. * http://jquery.org/license
  23. */
  24. //>>label: Widget
  25. //>>group: Core
  26. //>>description: Provides a factory for creating stateful widgets with a common API.
  27. //>>docs: http://api.jqueryui.com/jQuery.widget/
  28. //>>demos: http://jqueryui.com/widget/
  29. var widgetUuid = 0;
  30. var widgetSlice = Array.prototype.slice;
  31. $.cleanData = ( function( orig ) {
  32. return function( elems ) {
  33. var events, elem, i;
  34. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  35. try {
  36. // Only trigger remove when necessary to save time
  37. events = $._data( elem, "events" );
  38. if ( events && events.remove ) {
  39. $( elem ).triggerHandler( "remove" );
  40. }
  41. // Http://bugs.jquery.com/ticket/8235
  42. } catch ( e ) {}
  43. }
  44. orig( elems );
  45. };
  46. } )( $.cleanData );
  47. $.widget = function( name, base, prototype ) {
  48. var existingConstructor, constructor, basePrototype;
  49. // ProxiedPrototype allows the provided prototype to remain unmodified
  50. // so that it can be used as a mixin for multiple widgets (#8876)
  51. var proxiedPrototype = {};
  52. var namespace = name.split( "." )[ 0 ];
  53. name = name.split( "." )[ 1 ];
  54. var fullName = namespace + "-" + name;
  55. if ( !prototype ) {
  56. prototype = base;
  57. base = $.Widget;
  58. }
  59. if ( $.isArray( prototype ) ) {
  60. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  61. }
  62. // Create selector for plugin
  63. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  64. return !!$.data( elem, fullName );
  65. };
  66. $[ namespace ] = $[ namespace ] || {};
  67. existingConstructor = $[ namespace ][ name ];
  68. constructor = $[ namespace ][ name ] = function( options, element ) {
  69. // Allow instantiation without "new" keyword
  70. if ( !this._createWidget ) {
  71. return new constructor( options, element );
  72. }
  73. // Allow instantiation without initializing for simple inheritance
  74. // must use "new" keyword (the code above always passes args)
  75. if ( arguments.length ) {
  76. this._createWidget( options, element );
  77. }
  78. };
  79. // Extend with the existing constructor to carry over any static properties
  80. $.extend( constructor, existingConstructor, {
  81. version: prototype.version,
  82. // Copy the object used to create the prototype in case we need to
  83. // redefine the widget later
  84. _proto: $.extend( {}, prototype ),
  85. // Track widgets that inherit from this widget in case this widget is
  86. // redefined after a widget inherits from it
  87. _childConstructors: []
  88. } );
  89. basePrototype = new base();
  90. // We need to make the options hash a property directly on the new instance
  91. // otherwise we'll modify the options hash on the prototype that we're
  92. // inheriting from
  93. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  94. $.each( prototype, function( prop, value ) {
  95. if ( !$.isFunction( value ) ) {
  96. proxiedPrototype[ prop ] = value;
  97. return;
  98. }
  99. proxiedPrototype[ prop ] = ( function() {
  100. function _super() {
  101. return base.prototype[ prop ].apply( this, arguments );
  102. }
  103. function _superApply( args ) {
  104. return base.prototype[ prop ].apply( this, args );
  105. }
  106. return function() {
  107. var __super = this._super;
  108. var __superApply = this._superApply;
  109. var returnValue;
  110. this._super = _super;
  111. this._superApply = _superApply;
  112. returnValue = value.apply( this, arguments );
  113. this._super = __super;
  114. this._superApply = __superApply;
  115. return returnValue;
  116. };
  117. } )();
  118. } );
  119. constructor.prototype = $.widget.extend( basePrototype, {
  120. // TODO: remove support for widgetEventPrefix
  121. // always use the name + a colon as the prefix, e.g., draggable:start
  122. // don't prefix for widgets that aren't DOM-based
  123. widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
  124. }, proxiedPrototype, {
  125. constructor: constructor,
  126. namespace: namespace,
  127. widgetName: name,
  128. widgetFullName: fullName
  129. } );
  130. // If this widget is being redefined then we need to find all widgets that
  131. // are inheriting from it and redefine all of them so that they inherit from
  132. // the new version of this widget. We're essentially trying to replace one
  133. // level in the prototype chain.
  134. if ( existingConstructor ) {
  135. $.each( existingConstructor._childConstructors, function( i, child ) {
  136. var childPrototype = child.prototype;
  137. // Redefine the child widget using the same prototype that was
  138. // originally used, but inherit from the new version of the base
  139. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
  140. child._proto );
  141. } );
  142. // Remove the list of existing child constructors from the old constructor
  143. // so the old child constructors can be garbage collected
  144. delete existingConstructor._childConstructors;
  145. } else {
  146. base._childConstructors.push( constructor );
  147. }
  148. $.widget.bridge( name, constructor );
  149. return constructor;
  150. };
  151. $.widget.extend = function( target ) {
  152. var input = widgetSlice.call( arguments, 1 );
  153. var inputIndex = 0;
  154. var inputLength = input.length;
  155. var key;
  156. var value;
  157. for ( ; inputIndex < inputLength; inputIndex++ ) {
  158. for ( key in input[ inputIndex ] ) {
  159. value = input[ inputIndex ][ key ];
  160. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  161. // Clone objects
  162. if ( $.isPlainObject( value ) ) {
  163. target[ key ] = $.isPlainObject( target[ key ] ) ?
  164. $.widget.extend( {}, target[ key ], value ) :
  165. // Don't extend strings, arrays, etc. with objects
  166. $.widget.extend( {}, value );
  167. // Copy everything else by reference
  168. } else {
  169. target[ key ] = value;
  170. }
  171. }
  172. }
  173. }
  174. return target;
  175. };
  176. $.widget.bridge = function( name, object ) {
  177. var fullName = object.prototype.widgetFullName || name;
  178. $.fn[ name ] = function( options ) {
  179. var isMethodCall = typeof options === "string";
  180. var args = widgetSlice.call( arguments, 1 );
  181. var returnValue = this;
  182. if ( isMethodCall ) {
  183. // If this is an empty collection, we need to have the instance method
  184. // return undefined instead of the jQuery instance
  185. if ( !this.length && options === "instance" ) {
  186. returnValue = undefined;
  187. } else {
  188. this.each( function() {
  189. var methodValue;
  190. var instance = $.data( this, fullName );
  191. if ( options === "instance" ) {
  192. returnValue = instance;
  193. return false;
  194. }
  195. if ( !instance ) {
  196. return $.error( "cannot call methods on " + name +
  197. " prior to initialization; " +
  198. "attempted to call method '" + options + "'" );
  199. }
  200. if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
  201. return $.error( "no such method '" + options + "' for " + name +
  202. " widget instance" );
  203. }
  204. methodValue = instance[ options ].apply( instance, args );
  205. if ( methodValue !== instance && methodValue !== undefined ) {
  206. returnValue = methodValue && methodValue.jquery ?
  207. returnValue.pushStack( methodValue.get() ) :
  208. methodValue;
  209. return false;
  210. }
  211. } );
  212. }
  213. } else {
  214. // Allow multiple hashes to be passed on init
  215. if ( args.length ) {
  216. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  217. }
  218. this.each( function() {
  219. var instance = $.data( this, fullName );
  220. if ( instance ) {
  221. instance.option( options || {} );
  222. if ( instance._init ) {
  223. instance._init();
  224. }
  225. } else {
  226. $.data( this, fullName, new object( options, this ) );
  227. }
  228. } );
  229. }
  230. return returnValue;
  231. };
  232. };
  233. $.Widget = function( /* options, element */ ) {};
  234. $.Widget._childConstructors = [];
  235. $.Widget.prototype = {
  236. widgetName: "widget",
  237. widgetEventPrefix: "",
  238. defaultElement: "<div>",
  239. options: {
  240. classes: {},
  241. disabled: false,
  242. // Callbacks
  243. create: null
  244. },
  245. _createWidget: function( options, element ) {
  246. element = $( element || this.defaultElement || this )[ 0 ];
  247. this.element = $( element );
  248. this.uuid = widgetUuid++;
  249. this.eventNamespace = "." + this.widgetName + this.uuid;
  250. this.bindings = $();
  251. this.hoverable = $();
  252. this.focusable = $();
  253. this.classesElementLookup = {};
  254. if ( element !== this ) {
  255. $.data( element, this.widgetFullName, this );
  256. this._on( true, this.element, {
  257. remove: function( event ) {
  258. if ( event.target === element ) {
  259. this.destroy();
  260. }
  261. }
  262. } );
  263. this.document = $( element.style ?
  264. // Element within the document
  265. element.ownerDocument :
  266. // Element is window or document
  267. element.document || element );
  268. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  269. }
  270. this.options = $.widget.extend( {},
  271. this.options,
  272. this._getCreateOptions(),
  273. options );
  274. this._create();
  275. if ( this.options.disabled ) {
  276. this._setOptionDisabled( this.options.disabled );
  277. }
  278. this._trigger( "create", null, this._getCreateEventData() );
  279. this._init();
  280. },
  281. _getCreateOptions: function() {
  282. return {};
  283. },
  284. _getCreateEventData: $.noop,
  285. _create: $.noop,
  286. _init: $.noop,
  287. destroy: function() {
  288. var that = this;
  289. this._destroy();
  290. $.each( this.classesElementLookup, function( key, value ) {
  291. that._removeClass( value, key );
  292. } );
  293. // We can probably remove the unbind calls in 2.0
  294. // all event bindings should go through this._on()
  295. this.element
  296. .off( this.eventNamespace )
  297. .removeData( this.widgetFullName );
  298. this.widget()
  299. .off( this.eventNamespace )
  300. .removeAttr( "aria-disabled" );
  301. // Clean up events and states
  302. this.bindings.off( this.eventNamespace );
  303. },
  304. _destroy: $.noop,
  305. widget: function() {
  306. return this.element;
  307. },
  308. option: function( key, value ) {
  309. var options = key;
  310. var parts;
  311. var curOption;
  312. var i;
  313. if ( arguments.length === 0 ) {
  314. // Don't return a reference to the internal hash
  315. return $.widget.extend( {}, this.options );
  316. }
  317. if ( typeof key === "string" ) {
  318. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  319. options = {};
  320. parts = key.split( "." );
  321. key = parts.shift();
  322. if ( parts.length ) {
  323. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  324. for ( i = 0; i < parts.length - 1; i++ ) {
  325. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  326. curOption = curOption[ parts[ i ] ];
  327. }
  328. key = parts.pop();
  329. if ( arguments.length === 1 ) {
  330. return curOption[ key ] === undefined ? null : curOption[ key ];
  331. }
  332. curOption[ key ] = value;
  333. } else {
  334. if ( arguments.length === 1 ) {
  335. return this.options[ key ] === undefined ? null : this.options[ key ];
  336. }
  337. options[ key ] = value;
  338. }
  339. }
  340. this._setOptions( options );
  341. return this;
  342. },
  343. _setOptions: function( options ) {
  344. var key;
  345. for ( key in options ) {
  346. this._setOption( key, options[ key ] );
  347. }
  348. return this;
  349. },
  350. _setOption: function( key, value ) {
  351. if ( key === "classes" ) {
  352. this._setOptionClasses( value );
  353. }
  354. this.options[ key ] = value;
  355. if ( key === "disabled" ) {
  356. this._setOptionDisabled( value );
  357. }
  358. return this;
  359. },
  360. _setOptionClasses: function( value ) {
  361. var classKey, elements, currentElements;
  362. for ( classKey in value ) {
  363. currentElements = this.classesElementLookup[ classKey ];
  364. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  365. !currentElements ||
  366. !currentElements.length ) {
  367. continue;
  368. }
  369. // We are doing this to create a new jQuery object because the _removeClass() call
  370. // on the next line is going to destroy the reference to the current elements being
  371. // tracked. We need to save a copy of this collection so that we can add the new classes
  372. // below.
  373. elements = $( currentElements.get() );
  374. this._removeClass( currentElements, classKey );
  375. // We don't use _addClass() here, because that uses this.options.classes
  376. // for generating the string of classes. We want to use the value passed in from
  377. // _setOption(), this is the new value of the classes option which was passed to
  378. // _setOption(). We pass this value directly to _classes().
  379. elements.addClass( this._classes( {
  380. element: elements,
  381. keys: classKey,
  382. classes: value,
  383. add: true
  384. } ) );
  385. }
  386. },
  387. _setOptionDisabled: function( value ) {
  388. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  389. // If the widget is becoming disabled, then nothing is interactive
  390. if ( value ) {
  391. this._removeClass( this.hoverable, null, "ui-state-hover" );
  392. this._removeClass( this.focusable, null, "ui-state-focus" );
  393. }
  394. },
  395. enable: function() {
  396. return this._setOptions( { disabled: false } );
  397. },
  398. disable: function() {
  399. return this._setOptions( { disabled: true } );
  400. },
  401. _classes: function( options ) {
  402. var full = [];
  403. var that = this;
  404. options = $.extend( {
  405. element: this.element,
  406. classes: this.options.classes || {}
  407. }, options );
  408. function processClassString( classes, checkOption ) {
  409. var current, i;
  410. for ( i = 0; i < classes.length; i++ ) {
  411. current = that.classesElementLookup[ classes[ i ] ] || $();
  412. if ( options.add ) {
  413. current = $( $.unique( current.get().concat( options.element.get() ) ) );
  414. } else {
  415. current = $( current.not( options.element ).get() );
  416. }
  417. that.classesElementLookup[ classes[ i ] ] = current;
  418. full.push( classes[ i ] );
  419. if ( checkOption && options.classes[ classes[ i ] ] ) {
  420. full.push( options.classes[ classes[ i ] ] );
  421. }
  422. }
  423. }
  424. this._on( options.element, {
  425. "remove": "_untrackClassesElement"
  426. } );
  427. if ( options.keys ) {
  428. processClassString( options.keys.match( /\S+/g ) || [], true );
  429. }
  430. if ( options.extra ) {
  431. processClassString( options.extra.match( /\S+/g ) || [] );
  432. }
  433. return full.join( " " );
  434. },
  435. _untrackClassesElement: function( event ) {
  436. var that = this;
  437. $.each( that.classesElementLookup, function( key, value ) {
  438. if ( $.inArray( event.target, value ) !== -1 ) {
  439. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  440. }
  441. } );
  442. },
  443. _removeClass: function( element, keys, extra ) {
  444. return this._toggleClass( element, keys, extra, false );
  445. },
  446. _addClass: function( element, keys, extra ) {
  447. return this._toggleClass( element, keys, extra, true );
  448. },
  449. _toggleClass: function( element, keys, extra, add ) {
  450. add = ( typeof add === "boolean" ) ? add : extra;
  451. var shift = ( typeof element === "string" || element === null ),
  452. options = {
  453. extra: shift ? keys : extra,
  454. keys: shift ? element : keys,
  455. element: shift ? this.element : element,
  456. add: add
  457. };
  458. options.element.toggleClass( this._classes( options ), add );
  459. return this;
  460. },
  461. _on: function( suppressDisabledCheck, element, handlers ) {
  462. var delegateElement;
  463. var instance = this;
  464. // No suppressDisabledCheck flag, shuffle arguments
  465. if ( typeof suppressDisabledCheck !== "boolean" ) {
  466. handlers = element;
  467. element = suppressDisabledCheck;
  468. suppressDisabledCheck = false;
  469. }
  470. // No element argument, shuffle and use this.element
  471. if ( !handlers ) {
  472. handlers = element;
  473. element = this.element;
  474. delegateElement = this.widget();
  475. } else {
  476. element = delegateElement = $( element );
  477. this.bindings = this.bindings.add( element );
  478. }
  479. $.each( handlers, function( event, handler ) {
  480. function handlerProxy() {
  481. // Allow widgets to customize the disabled handling
  482. // - disabled as an array instead of boolean
  483. // - disabled class as method for disabling individual parts
  484. if ( !suppressDisabledCheck &&
  485. ( instance.options.disabled === true ||
  486. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  487. return;
  488. }
  489. return ( typeof handler === "string" ? instance[ handler ] : handler )
  490. .apply( instance, arguments );
  491. }
  492. // Copy the guid so direct unbinding works
  493. if ( typeof handler !== "string" ) {
  494. handlerProxy.guid = handler.guid =
  495. handler.guid || handlerProxy.guid || $.guid++;
  496. }
  497. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  498. var eventName = match[ 1 ] + instance.eventNamespace;
  499. var selector = match[ 2 ];
  500. if ( selector ) {
  501. delegateElement.on( eventName, selector, handlerProxy );
  502. } else {
  503. element.on( eventName, handlerProxy );
  504. }
  505. } );
  506. },
  507. _off: function( element, eventName ) {
  508. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  509. this.eventNamespace;
  510. element.off( eventName ).off( eventName );
  511. // Clear the stack to avoid memory leaks (#10056)
  512. this.bindings = $( this.bindings.not( element ).get() );
  513. this.focusable = $( this.focusable.not( element ).get() );
  514. this.hoverable = $( this.hoverable.not( element ).get() );
  515. },
  516. _delay: function( handler, delay ) {
  517. function handlerProxy() {
  518. return ( typeof handler === "string" ? instance[ handler ] : handler )
  519. .apply( instance, arguments );
  520. }
  521. var instance = this;
  522. return setTimeout( handlerProxy, delay || 0 );
  523. },
  524. _hoverable: function( element ) {
  525. this.hoverable = this.hoverable.add( element );
  526. this._on( element, {
  527. mouseenter: function( event ) {
  528. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  529. },
  530. mouseleave: function( event ) {
  531. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  532. }
  533. } );
  534. },
  535. _focusable: function( element ) {
  536. this.focusable = this.focusable.add( element );
  537. this._on( element, {
  538. focusin: function( event ) {
  539. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  540. },
  541. focusout: function( event ) {
  542. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  543. }
  544. } );
  545. },
  546. _trigger: function( type, event, data ) {
  547. var prop, orig;
  548. var callback = this.options[ type ];
  549. data = data || {};
  550. event = $.Event( event );
  551. event.type = ( type === this.widgetEventPrefix ?
  552. type :
  553. this.widgetEventPrefix + type ).toLowerCase();
  554. // The original event may come from any element
  555. // so we need to reset the target on the new event
  556. event.target = this.element[ 0 ];
  557. // Copy original event properties over to the new event
  558. orig = event.originalEvent;
  559. if ( orig ) {
  560. for ( prop in orig ) {
  561. if ( !( prop in event ) ) {
  562. event[ prop ] = orig[ prop ];
  563. }
  564. }
  565. }
  566. this.element.trigger( event, data );
  567. return !( $.isFunction( callback ) &&
  568. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  569. event.isDefaultPrevented() );
  570. }
  571. };
  572. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  573. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  574. if ( typeof options === "string" ) {
  575. options = { effect: options };
  576. }
  577. var hasOptions;
  578. var effectName = !options ?
  579. method :
  580. options === true || typeof options === "number" ?
  581. defaultEffect :
  582. options.effect || defaultEffect;
  583. options = options || {};
  584. if ( typeof options === "number" ) {
  585. options = { duration: options };
  586. }
  587. hasOptions = !$.isEmptyObject( options );
  588. options.complete = callback;
  589. if ( options.delay ) {
  590. element.delay( options.delay );
  591. }
  592. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  593. element[ method ]( options );
  594. } else if ( effectName !== method && element[ effectName ] ) {
  595. element[ effectName ]( options.duration, options.easing, callback );
  596. } else {
  597. element.queue( function( next ) {
  598. $( this )[ method ]();
  599. if ( callback ) {
  600. callback.call( element[ 0 ] );
  601. }
  602. next();
  603. } );
  604. }
  605. };
  606. } );
  607. var widget = $.widget;
  608. /*!
  609. * jQuery UI Keycode 1.12.1
  610. * http://jqueryui.com
  611. *
  612. * Copyright jQuery Foundation and other contributors
  613. * Released under the MIT license.
  614. * http://jquery.org/license
  615. */
  616. //>>label: Keycode
  617. //>>group: Core
  618. //>>description: Provide keycodes as keynames
  619. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  620. var keycode = $.ui.keyCode = {
  621. BACKSPACE: 8,
  622. COMMA: 188,
  623. DELETE: 46,
  624. DOWN: 40,
  625. END: 35,
  626. ENTER: 13,
  627. ESCAPE: 27,
  628. HOME: 36,
  629. LEFT: 37,
  630. PAGE_DOWN: 34,
  631. PAGE_UP: 33,
  632. PERIOD: 190,
  633. RIGHT: 39,
  634. SPACE: 32,
  635. TAB: 9,
  636. UP: 38
  637. };
  638. /*!
  639. * jQuery UI Unique ID 1.12.1
  640. * http://jqueryui.com
  641. *
  642. * Copyright jQuery Foundation and other contributors
  643. * Released under the MIT license.
  644. * http://jquery.org/license
  645. */
  646. //>>label: uniqueId
  647. //>>group: Core
  648. //>>description: Functions to generate and remove uniqueId's
  649. //>>docs: http://api.jqueryui.com/uniqueId/
  650. var uniqueId = $.fn.extend( {
  651. uniqueId: ( function() {
  652. var uuid = 0;
  653. return function() {
  654. return this.each( function() {
  655. if ( !this.id ) {
  656. this.id = "ui-id-" + ( ++uuid );
  657. }
  658. } );
  659. };
  660. } )(),
  661. removeUniqueId: function() {
  662. return this.each( function() {
  663. if ( /^ui-id-\d+$/.test( this.id ) ) {
  664. $( this ).removeAttr( "id" );
  665. }
  666. } );
  667. }
  668. } );
  669. /*!
  670. * jQuery UI Accordion 1.12.1
  671. * http://jqueryui.com
  672. *
  673. * Copyright jQuery Foundation and other contributors
  674. * Released under the MIT license.
  675. * http://jquery.org/license
  676. */
  677. //>>label: Accordion
  678. //>>group: Widgets
  679. // jscs:disable maximumLineLength
  680. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  681. // jscs:enable maximumLineLength
  682. //>>docs: http://api.jqueryui.com/accordion/
  683. //>>demos: http://jqueryui.com/accordion/
  684. //>>css.structure: ../../themes/base/core.css
  685. //>>css.structure: ../../themes/base/accordion.css
  686. //>>css.theme: ../../themes/base/theme.css
  687. var widgetsAccordion = $.widget( "ui.accordion", {
  688. version: "1.12.1",
  689. options: {
  690. active: 0,
  691. animate: {},
  692. classes: {
  693. "ui-accordion-header": "ui-corner-top",
  694. "ui-accordion-header-collapsed": "ui-corner-all",
  695. "ui-accordion-content": "ui-corner-bottom"
  696. },
  697. collapsible: false,
  698. event: "click",
  699. header: "> li > :first-child, > :not(li):even",
  700. heightStyle: "auto",
  701. icons: {
  702. activeHeader: "ui-icon-triangle-1-s",
  703. header: "ui-icon-triangle-1-e"
  704. },
  705. // Callbacks
  706. activate: null,
  707. beforeActivate: null
  708. },
  709. hideProps: {
  710. borderTopWidth: "hide",
  711. borderBottomWidth: "hide",
  712. paddingTop: "hide",
  713. paddingBottom: "hide",
  714. height: "hide"
  715. },
  716. showProps: {
  717. borderTopWidth: "show",
  718. borderBottomWidth: "show",
  719. paddingTop: "show",
  720. paddingBottom: "show",
  721. height: "show"
  722. },
  723. _create: function() {
  724. var options = this.options;
  725. this.prevShow = this.prevHide = $();
  726. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  727. this.element.attr( "role", "tablist" );
  728. // Don't allow collapsible: false and active: false / null
  729. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  730. options.active = 0;
  731. }
  732. this._processPanels();
  733. // handle negative values
  734. if ( options.active < 0 ) {
  735. options.active += this.headers.length;
  736. }
  737. this._refresh();
  738. },
  739. _getCreateEventData: function() {
  740. return {
  741. header: this.active,
  742. panel: !this.active.length ? $() : this.active.next()
  743. };
  744. },
  745. _createIcons: function() {
  746. var icon, children,
  747. icons = this.options.icons;
  748. if ( icons ) {
  749. icon = $( "<span>" );
  750. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  751. icon.prependTo( this.headers );
  752. children = this.active.children( ".ui-accordion-header-icon" );
  753. this._removeClass( children, icons.header )
  754. ._addClass( children, null, icons.activeHeader )
  755. ._addClass( this.headers, "ui-accordion-icons" );
  756. }
  757. },
  758. _destroyIcons: function() {
  759. this._removeClass( this.headers, "ui-accordion-icons" );
  760. this.headers.children( ".ui-accordion-header-icon" ).remove();
  761. },
  762. _destroy: function() {
  763. var contents;
  764. // Clean up main element
  765. this.element.removeAttr( "role" );
  766. // Clean up headers
  767. this.headers
  768. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  769. .removeUniqueId();
  770. this._destroyIcons();
  771. // Clean up content panels
  772. contents = this.headers.next()
  773. .css( "display", "" )
  774. .removeAttr( "role aria-hidden aria-labelledby" )
  775. .removeUniqueId();
  776. if ( this.options.heightStyle !== "content" ) {
  777. contents.css( "height", "" );
  778. }
  779. },
  780. _setOption: function( key, value ) {
  781. if ( key === "active" ) {
  782. // _activate() will handle invalid values and update this.options
  783. this._activate( value );
  784. return;
  785. }
  786. if ( key === "event" ) {
  787. if ( this.options.event ) {
  788. this._off( this.headers, this.options.event );
  789. }
  790. this._setupEvents( value );
  791. }
  792. this._super( key, value );
  793. // Setting collapsible: false while collapsed; open first panel
  794. if ( key === "collapsible" && !value && this.options.active === false ) {
  795. this._activate( 0 );
  796. }
  797. if ( key === "icons" ) {
  798. this._destroyIcons();
  799. if ( value ) {
  800. this._createIcons();
  801. }
  802. }
  803. },
  804. _setOptionDisabled: function( value ) {
  805. this._super( value );
  806. this.element.attr( "aria-disabled", value );
  807. // Support: IE8 Only
  808. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  809. // so we need to add the disabled class to the headers and panels
  810. this._toggleClass( null, "ui-state-disabled", !!value );
  811. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  812. !!value );
  813. },
  814. _keydown: function( event ) {
  815. if ( event.altKey || event.ctrlKey ) {
  816. return;
  817. }
  818. var keyCode = $.ui.keyCode,
  819. length = this.headers.length,
  820. currentIndex = this.headers.index( event.target ),
  821. toFocus = false;
  822. switch ( event.keyCode ) {
  823. case keyCode.RIGHT:
  824. case keyCode.DOWN:
  825. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  826. break;
  827. case keyCode.LEFT:
  828. case keyCode.UP:
  829. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  830. break;
  831. case keyCode.SPACE:
  832. case keyCode.ENTER:
  833. this._eventHandler( event );
  834. break;
  835. case keyCode.HOME:
  836. toFocus = this.headers[ 0 ];
  837. break;
  838. case keyCode.END:
  839. toFocus = this.headers[ length - 1 ];
  840. break;
  841. }
  842. if ( toFocus ) {
  843. $( event.target ).attr( "tabIndex", -1 );
  844. $( toFocus ).attr( "tabIndex", 0 );
  845. $( toFocus ).trigger( "focus" );
  846. event.preventDefault();
  847. }
  848. },
  849. _panelKeyDown: function( event ) {
  850. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  851. $( event.currentTarget ).prev().trigger( "focus" );
  852. }
  853. },
  854. refresh: function() {
  855. var options = this.options;
  856. this._processPanels();
  857. // Was collapsed or no panel
  858. if ( ( options.active === false && options.collapsible === true ) ||
  859. !this.headers.length ) {
  860. options.active = false;
  861. this.active = $();
  862. // active false only when collapsible is true
  863. } else if ( options.active === false ) {
  864. this._activate( 0 );
  865. // was active, but active panel is gone
  866. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  867. // all remaining panel are disabled
  868. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  869. options.active = false;
  870. this.active = $();
  871. // activate previous panel
  872. } else {
  873. this._activate( Math.max( 0, options.active - 1 ) );
  874. }
  875. // was active, active panel still exists
  876. } else {
  877. // make sure active index is correct
  878. options.active = this.headers.index( this.active );
  879. }
  880. this._destroyIcons();
  881. this._refresh();
  882. },
  883. _processPanels: function() {
  884. var prevHeaders = this.headers,
  885. prevPanels = this.panels;
  886. this.headers = this.element.find( this.options.header );
  887. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  888. "ui-state-default" );
  889. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  890. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  891. // Avoid memory leaks (#10056)
  892. if ( prevPanels ) {
  893. this._off( prevHeaders.not( this.headers ) );
  894. this._off( prevPanels.not( this.panels ) );
  895. }
  896. },
  897. _refresh: function() {
  898. var maxHeight,
  899. options = this.options,
  900. heightStyle = options.heightStyle,
  901. parent = this.element.parent();
  902. this.active = this._findActive( options.active );
  903. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  904. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  905. this._addClass( this.active.next(), "ui-accordion-content-active" );
  906. this.active.next().show();
  907. this.headers
  908. .attr( "role", "tab" )
  909. .each( function() {
  910. var header = $( this ),
  911. headerId = header.uniqueId().attr( "id" ),
  912. panel = header.next(),
  913. panelId = panel.uniqueId().attr( "id" );
  914. header.attr( "aria-controls", panelId );
  915. panel.attr( "aria-labelledby", headerId );
  916. } )
  917. .next()
  918. .attr( "role", "tabpanel" );
  919. this.headers
  920. .not( this.active )
  921. .attr( {
  922. "aria-selected": "false",
  923. "aria-expanded": "false",
  924. tabIndex: -1
  925. } )
  926. .next()
  927. .attr( {
  928. "aria-hidden": "true"
  929. } )
  930. .hide();
  931. // Make sure at least one header is in the tab order
  932. if ( !this.active.length ) {
  933. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  934. } else {
  935. this.active.attr( {
  936. "aria-selected": "true",
  937. "aria-expanded": "true",
  938. tabIndex: 0
  939. } )
  940. .next()
  941. .attr( {
  942. "aria-hidden": "false"
  943. } );
  944. }
  945. this._createIcons();
  946. this._setupEvents( options.event );
  947. if ( heightStyle === "fill" ) {
  948. maxHeight = parent.height();
  949. this.element.siblings( ":visible" ).each( function() {
  950. var elem = $( this ),
  951. position = elem.css( "position" );
  952. if ( position === "absolute" || position === "fixed" ) {
  953. return;
  954. }
  955. maxHeight -= elem.outerHeight( true );
  956. } );
  957. this.headers.each( function() {
  958. maxHeight -= $( this ).outerHeight( true );
  959. } );
  960. this.headers.next()
  961. .each( function() {
  962. $( this ).height( Math.max( 0, maxHeight -
  963. $( this ).innerHeight() + $( this ).height() ) );
  964. } )
  965. .css( "overflow", "auto" );
  966. } else if ( heightStyle === "auto" ) {
  967. maxHeight = 0;
  968. this.headers.next()
  969. .each( function() {
  970. var isVisible = $( this ).is( ":visible" );
  971. if ( !isVisible ) {
  972. $( this ).show();
  973. }
  974. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  975. if ( !isVisible ) {
  976. $( this ).hide();
  977. }
  978. } )
  979. .height( maxHeight );
  980. }
  981. },
  982. _activate: function( index ) {
  983. var active = this._findActive( index )[ 0 ];
  984. // Trying to activate the already active panel
  985. if ( active === this.active[ 0 ] ) {
  986. return;
  987. }
  988. // Trying to collapse, simulate a click on the currently active header
  989. active = active || this.active[ 0 ];
  990. this._eventHandler( {
  991. target: active,
  992. currentTarget: active,
  993. preventDefault: $.noop
  994. } );
  995. },
  996. _findActive: function( selector ) {
  997. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  998. },
  999. _setupEvents: function( event ) {
  1000. var events = {
  1001. keydown: "_keydown"
  1002. };
  1003. if ( event ) {
  1004. $.each( event.split( " " ), function( index, eventName ) {
  1005. events[ eventName ] = "_eventHandler";
  1006. } );
  1007. }
  1008. this._off( this.headers.add( this.headers.next() ) );
  1009. this._on( this.headers, events );
  1010. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  1011. this._hoverable( this.headers );
  1012. this._focusable( this.headers );
  1013. },
  1014. _eventHandler: function( event ) {
  1015. var activeChildren, clickedChildren,
  1016. options = this.options,
  1017. active = this.active,
  1018. clicked = $( event.currentTarget ),
  1019. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1020. collapsing = clickedIsActive && options.collapsible,
  1021. toShow = collapsing ? $() : clicked.next(),
  1022. toHide = active.next(),
  1023. eventData = {
  1024. oldHeader: active,
  1025. oldPanel: toHide,
  1026. newHeader: collapsing ? $() : clicked,
  1027. newPanel: toShow
  1028. };
  1029. event.preventDefault();
  1030. if (
  1031. // click on active header, but not collapsible
  1032. ( clickedIsActive && !options.collapsible ) ||
  1033. // allow canceling activation
  1034. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1035. return;
  1036. }
  1037. options.active = collapsing ? false : this.headers.index( clicked );
  1038. // When the call to ._toggle() comes after the class changes
  1039. // it causes a very odd bug in IE 8 (see #6720)
  1040. this.active = clickedIsActive ? $() : clicked;
  1041. this._toggle( eventData );
  1042. // Switch classes
  1043. // corner classes on the previously active header stay after the animation
  1044. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  1045. if ( options.icons ) {
  1046. activeChildren = active.children( ".ui-accordion-header-icon" );
  1047. this._removeClass( activeChildren, null, options.icons.activeHeader )
  1048. ._addClass( activeChildren, null, options.icons.header );
  1049. }
  1050. if ( !clickedIsActive ) {
  1051. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  1052. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  1053. if ( options.icons ) {
  1054. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  1055. this._removeClass( clickedChildren, null, options.icons.header )
  1056. ._addClass( clickedChildren, null, options.icons.activeHeader );
  1057. }
  1058. this._addClass( clicked.next(), "ui-accordion-content-active" );
  1059. }
  1060. },
  1061. _toggle: function( data ) {
  1062. var toShow = data.newPanel,
  1063. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1064. // Handle activating a panel during the animation for another activation
  1065. this.prevShow.add( this.prevHide ).stop( true, true );
  1066. this.prevShow = toShow;
  1067. this.prevHide = toHide;
  1068. if ( this.options.animate ) {
  1069. this._animate( toShow, toHide, data );
  1070. } else {
  1071. toHide.hide();
  1072. toShow.show();
  1073. this._toggleComplete( data );
  1074. }
  1075. toHide.attr( {
  1076. "aria-hidden": "true"
  1077. } );
  1078. toHide.prev().attr( {
  1079. "aria-selected": "false",
  1080. "aria-expanded": "false"
  1081. } );
  1082. // if we're switching panels, remove the old header from the tab order
  1083. // if we're opening from collapsed state, remove the previous header from the tab order
  1084. // if we're collapsing, then keep the collapsing header in the tab order
  1085. if ( toShow.length && toHide.length ) {
  1086. toHide.prev().attr( {
  1087. "tabIndex": -1,
  1088. "aria-expanded": "false"
  1089. } );
  1090. } else if ( toShow.length ) {
  1091. this.headers.filter( function() {
  1092. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  1093. } )
  1094. .attr( "tabIndex", -1 );
  1095. }
  1096. toShow
  1097. .attr( "aria-hidden", "false" )
  1098. .prev()
  1099. .attr( {
  1100. "aria-selected": "true",
  1101. "aria-expanded": "true",
  1102. tabIndex: 0
  1103. } );
  1104. },
  1105. _animate: function( toShow, toHide, data ) {
  1106. var total, easing, duration,
  1107. that = this,
  1108. adjust = 0,
  1109. boxSizing = toShow.css( "box-sizing" ),
  1110. down = toShow.length &&
  1111. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1112. animate = this.options.animate || {},
  1113. options = down && animate.down || animate,
  1114. complete = function() {
  1115. that._toggleComplete( data );
  1116. };
  1117. if ( typeof options === "number" ) {
  1118. duration = options;
  1119. }
  1120. if ( typeof options === "string" ) {
  1121. easing = options;
  1122. }
  1123. // fall back from options to animation in case of partial down settings
  1124. easing = easing || options.easing || animate.easing;
  1125. duration = duration || options.duration || animate.duration;
  1126. if ( !toHide.length ) {
  1127. return toShow.animate( this.showProps, duration, easing, complete );
  1128. }
  1129. if ( !toShow.length ) {
  1130. return toHide.animate( this.hideProps, duration, easing, complete );
  1131. }
  1132. total = toShow.show().outerHeight();
  1133. toHide.animate( this.hideProps, {
  1134. duration: duration,
  1135. easing: easing,
  1136. step: function( now, fx ) {
  1137. fx.now = Math.round( now );
  1138. }
  1139. } );
  1140. toShow
  1141. .hide()
  1142. .animate( this.showProps, {
  1143. duration: duration,
  1144. easing: easing,
  1145. complete: complete,
  1146. step: function( now, fx ) {
  1147. fx.now = Math.round( now );
  1148. if ( fx.prop !== "height" ) {
  1149. if ( boxSizing === "content-box" ) {
  1150. adjust += fx.now;
  1151. }
  1152. } else if ( that.options.heightStyle !== "content" ) {
  1153. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1154. adjust = 0;
  1155. }
  1156. }
  1157. } );
  1158. },
  1159. _toggleComplete: function( data ) {
  1160. var toHide = data.oldPanel,
  1161. prev = toHide.prev();
  1162. this._removeClass( toHide, "ui-accordion-content-active" );
  1163. this._removeClass( prev, "ui-accordion-header-active" )
  1164. ._addClass( prev, "ui-accordion-header-collapsed" );
  1165. // Work around for rendering bug in IE (#5421)
  1166. if ( toHide.length ) {
  1167. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  1168. }
  1169. this._trigger( "activate", null, data );
  1170. }
  1171. } );
  1172. }));