jquery-tabs.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769
  1. /*! jQuery UI - v1.12.1 - 2021-06-03
  2. * http://jqueryui.com
  3. * Includes: widget.js, keycode.js, unique-id.js, widgets/tabs.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. // Internal use only
  670. var escapeSelector = $.ui.escapeSelector = ( function() {
  671. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  672. return function( selector ) {
  673. return selector.replace( selectorEscape, "\\$1" );
  674. };
  675. } )();
  676. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  677. var activeElement;
  678. // Support: IE 9 only
  679. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  680. try {
  681. activeElement = document.activeElement;
  682. } catch ( error ) {
  683. activeElement = document.body;
  684. }
  685. // Support: IE 9 - 11 only
  686. // IE may return null instead of an element
  687. // Interestingly, this only seems to occur when NOT in an iframe
  688. if ( !activeElement ) {
  689. activeElement = document.body;
  690. }
  691. // Support: IE 11 only
  692. // IE11 returns a seemingly empty object in some cases when accessing
  693. // document.activeElement from an <iframe>
  694. if ( !activeElement.nodeName ) {
  695. activeElement = document.body;
  696. }
  697. return activeElement;
  698. };
  699. /*!
  700. * jQuery UI Tabs 1.12.1
  701. * http://jqueryui.com
  702. *
  703. * Copyright jQuery Foundation and other contributors
  704. * Released under the MIT license.
  705. * http://jquery.org/license
  706. */
  707. //>>label: Tabs
  708. //>>group: Widgets
  709. //>>description: Transforms a set of container elements into a tab structure.
  710. //>>docs: http://api.jqueryui.com/tabs/
  711. //>>demos: http://jqueryui.com/tabs/
  712. //>>css.structure: ../../themes/base/core.css
  713. //>>css.structure: ../../themes/base/tabs.css
  714. //>>css.theme: ../../themes/base/theme.css
  715. $.widget( "ui.tabs", {
  716. version: "1.12.1",
  717. delay: 300,
  718. options: {
  719. active: null,
  720. classes: {
  721. "ui-tabs": "ui-corner-all",
  722. "ui-tabs-nav": "ui-corner-all",
  723. "ui-tabs-panel": "ui-corner-bottom",
  724. "ui-tabs-tab": "ui-corner-top"
  725. },
  726. collapsible: false,
  727. event: "click",
  728. heightStyle: "content",
  729. hide: null,
  730. show: null,
  731. // Callbacks
  732. activate: null,
  733. beforeActivate: null,
  734. beforeLoad: null,
  735. load: null
  736. },
  737. _isLocal: ( function() {
  738. var rhash = /#.*$/;
  739. return function( anchor ) {
  740. var anchorUrl, locationUrl;
  741. anchorUrl = anchor.href.replace( rhash, "" );
  742. locationUrl = location.href.replace( rhash, "" );
  743. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  744. try {
  745. anchorUrl = decodeURIComponent( anchorUrl );
  746. } catch ( error ) {}
  747. try {
  748. locationUrl = decodeURIComponent( locationUrl );
  749. } catch ( error ) {}
  750. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  751. };
  752. } )(),
  753. _create: function() {
  754. var that = this,
  755. options = this.options;
  756. this.running = false;
  757. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  758. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  759. this._processTabs();
  760. options.active = this._initialActive();
  761. // Take disabling tabs via class attribute from HTML
  762. // into account and update option properly.
  763. if ( $.isArray( options.disabled ) ) {
  764. options.disabled = $.unique( options.disabled.concat(
  765. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  766. return that.tabs.index( li );
  767. } )
  768. ) ).sort();
  769. }
  770. // Check for length avoids error when initializing empty list
  771. if ( this.options.active !== false && this.anchors.length ) {
  772. this.active = this._findActive( options.active );
  773. } else {
  774. this.active = $();
  775. }
  776. this._refresh();
  777. if ( this.active.length ) {
  778. this.load( options.active );
  779. }
  780. },
  781. _initialActive: function() {
  782. var active = this.options.active,
  783. collapsible = this.options.collapsible,
  784. locationHash = location.hash.substring( 1 );
  785. if ( active === null ) {
  786. // check the fragment identifier in the URL
  787. if ( locationHash ) {
  788. this.tabs.each( function( i, tab ) {
  789. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  790. active = i;
  791. return false;
  792. }
  793. } );
  794. }
  795. // Check for a tab marked active via a class
  796. if ( active === null ) {
  797. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  798. }
  799. // No active tab, set to false
  800. if ( active === null || active === -1 ) {
  801. active = this.tabs.length ? 0 : false;
  802. }
  803. }
  804. // Handle numbers: negative, out of range
  805. if ( active !== false ) {
  806. active = this.tabs.index( this.tabs.eq( active ) );
  807. if ( active === -1 ) {
  808. active = collapsible ? false : 0;
  809. }
  810. }
  811. // Don't allow collapsible: false and active: false
  812. if ( !collapsible && active === false && this.anchors.length ) {
  813. active = 0;
  814. }
  815. return active;
  816. },
  817. _getCreateEventData: function() {
  818. return {
  819. tab: this.active,
  820. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  821. };
  822. },
  823. _tabKeydown: function( event ) {
  824. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  825. selectedIndex = this.tabs.index( focusedTab ),
  826. goingForward = true;
  827. if ( this._handlePageNav( event ) ) {
  828. return;
  829. }
  830. switch ( event.keyCode ) {
  831. case $.ui.keyCode.RIGHT:
  832. case $.ui.keyCode.DOWN:
  833. selectedIndex++;
  834. break;
  835. case $.ui.keyCode.UP:
  836. case $.ui.keyCode.LEFT:
  837. goingForward = false;
  838. selectedIndex--;
  839. break;
  840. case $.ui.keyCode.END:
  841. selectedIndex = this.anchors.length - 1;
  842. break;
  843. case $.ui.keyCode.HOME:
  844. selectedIndex = 0;
  845. break;
  846. case $.ui.keyCode.SPACE:
  847. // Activate only, no collapsing
  848. event.preventDefault();
  849. clearTimeout( this.activating );
  850. this._activate( selectedIndex );
  851. return;
  852. case $.ui.keyCode.ENTER:
  853. // Toggle (cancel delayed activation, allow collapsing)
  854. event.preventDefault();
  855. clearTimeout( this.activating );
  856. // Determine if we should collapse or activate
  857. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  858. return;
  859. default:
  860. return;
  861. }
  862. // Focus the appropriate tab, based on which key was pressed
  863. event.preventDefault();
  864. clearTimeout( this.activating );
  865. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  866. // Navigating with control/command key will prevent automatic activation
  867. if ( !event.ctrlKey && !event.metaKey ) {
  868. // Update aria-selected immediately so that AT think the tab is already selected.
  869. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  870. // but the tab will already be activated by the time the announcement finishes.
  871. focusedTab.attr( "aria-selected", "false" );
  872. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  873. this.activating = this._delay( function() {
  874. this.option( "active", selectedIndex );
  875. }, this.delay );
  876. }
  877. },
  878. _panelKeydown: function( event ) {
  879. if ( this._handlePageNav( event ) ) {
  880. return;
  881. }
  882. // Ctrl+up moves focus to the current tab
  883. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  884. event.preventDefault();
  885. this.active.trigger( "focus" );
  886. }
  887. },
  888. // Alt+page up/down moves focus to the previous/next tab (and activates)
  889. _handlePageNav: function( event ) {
  890. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  891. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  892. return true;
  893. }
  894. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  895. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  896. return true;
  897. }
  898. },
  899. _findNextTab: function( index, goingForward ) {
  900. var lastTabIndex = this.tabs.length - 1;
  901. function constrain() {
  902. if ( index > lastTabIndex ) {
  903. index = 0;
  904. }
  905. if ( index < 0 ) {
  906. index = lastTabIndex;
  907. }
  908. return index;
  909. }
  910. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  911. index = goingForward ? index + 1 : index - 1;
  912. }
  913. return index;
  914. },
  915. _focusNextTab: function( index, goingForward ) {
  916. index = this._findNextTab( index, goingForward );
  917. this.tabs.eq( index ).trigger( "focus" );
  918. return index;
  919. },
  920. _setOption: function( key, value ) {
  921. if ( key === "active" ) {
  922. // _activate() will handle invalid values and update this.options
  923. this._activate( value );
  924. return;
  925. }
  926. this._super( key, value );
  927. if ( key === "collapsible" ) {
  928. this._toggleClass( "ui-tabs-collapsible", null, value );
  929. // Setting collapsible: false while collapsed; open first panel
  930. if ( !value && this.options.active === false ) {
  931. this._activate( 0 );
  932. }
  933. }
  934. if ( key === "event" ) {
  935. this._setupEvents( value );
  936. }
  937. if ( key === "heightStyle" ) {
  938. this._setupHeightStyle( value );
  939. }
  940. },
  941. _sanitizeSelector: function( hash ) {
  942. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  943. },
  944. refresh: function() {
  945. var options = this.options,
  946. lis = this.tablist.children( ":has(a[href])" );
  947. // Get disabled tabs from class attribute from HTML
  948. // this will get converted to a boolean if needed in _refresh()
  949. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  950. return lis.index( tab );
  951. } );
  952. this._processTabs();
  953. // Was collapsed or no tabs
  954. if ( options.active === false || !this.anchors.length ) {
  955. options.active = false;
  956. this.active = $();
  957. // was active, but active tab is gone
  958. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  959. // all remaining tabs are disabled
  960. if ( this.tabs.length === options.disabled.length ) {
  961. options.active = false;
  962. this.active = $();
  963. // activate previous tab
  964. } else {
  965. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  966. }
  967. // was active, active tab still exists
  968. } else {
  969. // make sure active index is correct
  970. options.active = this.tabs.index( this.active );
  971. }
  972. this._refresh();
  973. },
  974. _refresh: function() {
  975. this._setOptionDisabled( this.options.disabled );
  976. this._setupEvents( this.options.event );
  977. this._setupHeightStyle( this.options.heightStyle );
  978. this.tabs.not( this.active ).attr( {
  979. "aria-selected": "false",
  980. "aria-expanded": "false",
  981. tabIndex: -1
  982. } );
  983. this.panels.not( this._getPanelForTab( this.active ) )
  984. .hide()
  985. .attr( {
  986. "aria-hidden": "true"
  987. } );
  988. // Make sure one tab is in the tab order
  989. if ( !this.active.length ) {
  990. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  991. } else {
  992. this.active
  993. .attr( {
  994. "aria-selected": "true",
  995. "aria-expanded": "true",
  996. tabIndex: 0
  997. } );
  998. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  999. this._getPanelForTab( this.active )
  1000. .show()
  1001. .attr( {
  1002. "aria-hidden": "false"
  1003. } );
  1004. }
  1005. },
  1006. _processTabs: function() {
  1007. var that = this,
  1008. prevTabs = this.tabs,
  1009. prevAnchors = this.anchors,
  1010. prevPanels = this.panels;
  1011. this.tablist = this._getList().attr( "role", "tablist" );
  1012. this._addClass( this.tablist, "ui-tabs-nav",
  1013. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  1014. // Prevent users from focusing disabled tabs via click
  1015. this.tablist
  1016. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  1017. if ( $( this ).is( ".ui-state-disabled" ) ) {
  1018. event.preventDefault();
  1019. }
  1020. } )
  1021. // Support: IE <9
  1022. // Preventing the default action in mousedown doesn't prevent IE
  1023. // from focusing the element, so if the anchor gets focused, blur.
  1024. // We don't have to worry about focusing the previously focused
  1025. // element since clicking on a non-focusable element should focus
  1026. // the body anyway.
  1027. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  1028. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  1029. this.blur();
  1030. }
  1031. } );
  1032. this.tabs = this.tablist.find( "> li:has(a[href])" )
  1033. .attr( {
  1034. role: "tab",
  1035. tabIndex: -1
  1036. } );
  1037. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  1038. this.anchors = this.tabs.map( function() {
  1039. return $( "a", this )[ 0 ];
  1040. } )
  1041. .attr( {
  1042. role: "presentation",
  1043. tabIndex: -1
  1044. } );
  1045. this._addClass( this.anchors, "ui-tabs-anchor" );
  1046. this.panels = $();
  1047. this.anchors.each( function( i, anchor ) {
  1048. var selector, panel, panelId,
  1049. anchorId = $( anchor ).uniqueId().attr( "id" ),
  1050. tab = $( anchor ).closest( "li" ),
  1051. originalAriaControls = tab.attr( "aria-controls" );
  1052. // Inline tab
  1053. if ( that._isLocal( anchor ) ) {
  1054. selector = anchor.hash;
  1055. panelId = selector.substring( 1 );
  1056. panel = that.element.find( that._sanitizeSelector( selector ) );
  1057. // remote tab
  1058. } else {
  1059. // If the tab doesn't already have aria-controls,
  1060. // generate an id by using a throw-away element
  1061. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  1062. selector = "#" + panelId;
  1063. panel = that.element.find( selector );
  1064. if ( !panel.length ) {
  1065. panel = that._createPanel( panelId );
  1066. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  1067. }
  1068. panel.attr( "aria-live", "polite" );
  1069. }
  1070. if ( panel.length ) {
  1071. that.panels = that.panels.add( panel );
  1072. }
  1073. if ( originalAriaControls ) {
  1074. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  1075. }
  1076. tab.attr( {
  1077. "aria-controls": panelId,
  1078. "aria-labelledby": anchorId
  1079. } );
  1080. panel.attr( "aria-labelledby", anchorId );
  1081. } );
  1082. this.panels.attr( "role", "tabpanel" );
  1083. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  1084. // Avoid memory leaks (#10056)
  1085. if ( prevTabs ) {
  1086. this._off( prevTabs.not( this.tabs ) );
  1087. this._off( prevAnchors.not( this.anchors ) );
  1088. this._off( prevPanels.not( this.panels ) );
  1089. }
  1090. },
  1091. // Allow overriding how to find the list for rare usage scenarios (#7715)
  1092. _getList: function() {
  1093. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  1094. },
  1095. _createPanel: function( id ) {
  1096. return $( "<div>" )
  1097. .attr( "id", id )
  1098. .data( "ui-tabs-destroy", true );
  1099. },
  1100. _setOptionDisabled: function( disabled ) {
  1101. var currentItem, li, i;
  1102. if ( $.isArray( disabled ) ) {
  1103. if ( !disabled.length ) {
  1104. disabled = false;
  1105. } else if ( disabled.length === this.anchors.length ) {
  1106. disabled = true;
  1107. }
  1108. }
  1109. // Disable tabs
  1110. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  1111. currentItem = $( li );
  1112. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  1113. currentItem.attr( "aria-disabled", "true" );
  1114. this._addClass( currentItem, null, "ui-state-disabled" );
  1115. } else {
  1116. currentItem.removeAttr( "aria-disabled" );
  1117. this._removeClass( currentItem, null, "ui-state-disabled" );
  1118. }
  1119. }
  1120. this.options.disabled = disabled;
  1121. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  1122. disabled === true );
  1123. },
  1124. _setupEvents: function( event ) {
  1125. var events = {};
  1126. if ( event ) {
  1127. $.each( event.split( " " ), function( index, eventName ) {
  1128. events[ eventName ] = "_eventHandler";
  1129. } );
  1130. }
  1131. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  1132. // Always prevent the default action, even when disabled
  1133. this._on( true, this.anchors, {
  1134. click: function( event ) {
  1135. event.preventDefault();
  1136. }
  1137. } );
  1138. this._on( this.anchors, events );
  1139. this._on( this.tabs, { keydown: "_tabKeydown" } );
  1140. this._on( this.panels, { keydown: "_panelKeydown" } );
  1141. this._focusable( this.tabs );
  1142. this._hoverable( this.tabs );
  1143. },
  1144. _setupHeightStyle: function( heightStyle ) {
  1145. var maxHeight,
  1146. parent = this.element.parent();
  1147. if ( heightStyle === "fill" ) {
  1148. maxHeight = parent.height();
  1149. maxHeight -= this.element.outerHeight() - this.element.height();
  1150. this.element.siblings( ":visible" ).each( function() {
  1151. var elem = $( this ),
  1152. position = elem.css( "position" );
  1153. if ( position === "absolute" || position === "fixed" ) {
  1154. return;
  1155. }
  1156. maxHeight -= elem.outerHeight( true );
  1157. } );
  1158. this.element.children().not( this.panels ).each( function() {
  1159. maxHeight -= $( this ).outerHeight( true );
  1160. } );
  1161. this.panels.each( function() {
  1162. $( this ).height( Math.max( 0, maxHeight -
  1163. $( this ).innerHeight() + $( this ).height() ) );
  1164. } )
  1165. .css( "overflow", "auto" );
  1166. } else if ( heightStyle === "auto" ) {
  1167. maxHeight = 0;
  1168. this.panels.each( function() {
  1169. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  1170. } ).height( maxHeight );
  1171. }
  1172. },
  1173. _eventHandler: function( event ) {
  1174. var options = this.options,
  1175. active = this.active,
  1176. anchor = $( event.currentTarget ),
  1177. tab = anchor.closest( "li" ),
  1178. clickedIsActive = tab[ 0 ] === active[ 0 ],
  1179. collapsing = clickedIsActive && options.collapsible,
  1180. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  1181. toHide = !active.length ? $() : this._getPanelForTab( active ),
  1182. eventData = {
  1183. oldTab: active,
  1184. oldPanel: toHide,
  1185. newTab: collapsing ? $() : tab,
  1186. newPanel: toShow
  1187. };
  1188. event.preventDefault();
  1189. if ( tab.hasClass( "ui-state-disabled" ) ||
  1190. // tab is already loading
  1191. tab.hasClass( "ui-tabs-loading" ) ||
  1192. // can't switch durning an animation
  1193. this.running ||
  1194. // click on active header, but not collapsible
  1195. ( clickedIsActive && !options.collapsible ) ||
  1196. // allow canceling activation
  1197. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1198. return;
  1199. }
  1200. options.active = collapsing ? false : this.tabs.index( tab );
  1201. this.active = clickedIsActive ? $() : tab;
  1202. if ( this.xhr ) {
  1203. this.xhr.abort();
  1204. }
  1205. if ( !toHide.length && !toShow.length ) {
  1206. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  1207. }
  1208. if ( toShow.length ) {
  1209. this.load( this.tabs.index( tab ), event );
  1210. }
  1211. this._toggle( event, eventData );
  1212. },
  1213. // Handles show/hide for selecting tabs
  1214. _toggle: function( event, eventData ) {
  1215. var that = this,
  1216. toShow = eventData.newPanel,
  1217. toHide = eventData.oldPanel;
  1218. this.running = true;
  1219. function complete() {
  1220. that.running = false;
  1221. that._trigger( "activate", event, eventData );
  1222. }
  1223. function show() {
  1224. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  1225. if ( toShow.length && that.options.show ) {
  1226. that._show( toShow, that.options.show, complete );
  1227. } else {
  1228. toShow.show();
  1229. complete();
  1230. }
  1231. }
  1232. // Start out by hiding, then showing, then completing
  1233. if ( toHide.length && this.options.hide ) {
  1234. this._hide( toHide, this.options.hide, function() {
  1235. that._removeClass( eventData.oldTab.closest( "li" ),
  1236. "ui-tabs-active", "ui-state-active" );
  1237. show();
  1238. } );
  1239. } else {
  1240. this._removeClass( eventData.oldTab.closest( "li" ),
  1241. "ui-tabs-active", "ui-state-active" );
  1242. toHide.hide();
  1243. show();
  1244. }
  1245. toHide.attr( "aria-hidden", "true" );
  1246. eventData.oldTab.attr( {
  1247. "aria-selected": "false",
  1248. "aria-expanded": "false"
  1249. } );
  1250. // If we're switching tabs, remove the old tab from the tab order.
  1251. // If we're opening from collapsed state, remove the previous tab from the tab order.
  1252. // If we're collapsing, then keep the collapsing tab in the tab order.
  1253. if ( toShow.length && toHide.length ) {
  1254. eventData.oldTab.attr( "tabIndex", -1 );
  1255. } else if ( toShow.length ) {
  1256. this.tabs.filter( function() {
  1257. return $( this ).attr( "tabIndex" ) === 0;
  1258. } )
  1259. .attr( "tabIndex", -1 );
  1260. }
  1261. toShow.attr( "aria-hidden", "false" );
  1262. eventData.newTab.attr( {
  1263. "aria-selected": "true",
  1264. "aria-expanded": "true",
  1265. tabIndex: 0
  1266. } );
  1267. },
  1268. _activate: function( index ) {
  1269. var anchor,
  1270. active = this._findActive( index );
  1271. // Trying to activate the already active panel
  1272. if ( active[ 0 ] === this.active[ 0 ] ) {
  1273. return;
  1274. }
  1275. // Trying to collapse, simulate a click on the current active header
  1276. if ( !active.length ) {
  1277. active = this.active;
  1278. }
  1279. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  1280. this._eventHandler( {
  1281. target: anchor,
  1282. currentTarget: anchor,
  1283. preventDefault: $.noop
  1284. } );
  1285. },
  1286. _findActive: function( index ) {
  1287. return index === false ? $() : this.tabs.eq( index );
  1288. },
  1289. _getIndex: function( index ) {
  1290. // meta-function to give users option to provide a href string instead of a numerical index.
  1291. if ( typeof index === "string" ) {
  1292. index = this.anchors.index( this.anchors.filter( "[href$='" +
  1293. $.ui.escapeSelector( index ) + "']" ) );
  1294. }
  1295. return index;
  1296. },
  1297. _destroy: function() {
  1298. if ( this.xhr ) {
  1299. this.xhr.abort();
  1300. }
  1301. this.tablist
  1302. .removeAttr( "role" )
  1303. .off( this.eventNamespace );
  1304. this.anchors
  1305. .removeAttr( "role tabIndex" )
  1306. .removeUniqueId();
  1307. this.tabs.add( this.panels ).each( function() {
  1308. if ( $.data( this, "ui-tabs-destroy" ) ) {
  1309. $( this ).remove();
  1310. } else {
  1311. $( this ).removeAttr( "role tabIndex " +
  1312. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  1313. }
  1314. } );
  1315. this.tabs.each( function() {
  1316. var li = $( this ),
  1317. prev = li.data( "ui-tabs-aria-controls" );
  1318. if ( prev ) {
  1319. li
  1320. .attr( "aria-controls", prev )
  1321. .removeData( "ui-tabs-aria-controls" );
  1322. } else {
  1323. li.removeAttr( "aria-controls" );
  1324. }
  1325. } );
  1326. this.panels.show();
  1327. if ( this.options.heightStyle !== "content" ) {
  1328. this.panels.css( "height", "" );
  1329. }
  1330. },
  1331. enable: function( index ) {
  1332. var disabled = this.options.disabled;
  1333. if ( disabled === false ) {
  1334. return;
  1335. }
  1336. if ( index === undefined ) {
  1337. disabled = false;
  1338. } else {
  1339. index = this._getIndex( index );
  1340. if ( $.isArray( disabled ) ) {
  1341. disabled = $.map( disabled, function( num ) {
  1342. return num !== index ? num : null;
  1343. } );
  1344. } else {
  1345. disabled = $.map( this.tabs, function( li, num ) {
  1346. return num !== index ? num : null;
  1347. } );
  1348. }
  1349. }
  1350. this._setOptionDisabled( disabled );
  1351. },
  1352. disable: function( index ) {
  1353. var disabled = this.options.disabled;
  1354. if ( disabled === true ) {
  1355. return;
  1356. }
  1357. if ( index === undefined ) {
  1358. disabled = true;
  1359. } else {
  1360. index = this._getIndex( index );
  1361. if ( $.inArray( index, disabled ) !== -1 ) {
  1362. return;
  1363. }
  1364. if ( $.isArray( disabled ) ) {
  1365. disabled = $.merge( [ index ], disabled ).sort();
  1366. } else {
  1367. disabled = [ index ];
  1368. }
  1369. }
  1370. this._setOptionDisabled( disabled );
  1371. },
  1372. load: function( index, event ) {
  1373. index = this._getIndex( index );
  1374. var that = this,
  1375. tab = this.tabs.eq( index ),
  1376. anchor = tab.find( ".ui-tabs-anchor" ),
  1377. panel = this._getPanelForTab( tab ),
  1378. eventData = {
  1379. tab: tab,
  1380. panel: panel
  1381. },
  1382. complete = function( jqXHR, status ) {
  1383. if ( status === "abort" ) {
  1384. that.panels.stop( false, true );
  1385. }
  1386. that._removeClass( tab, "ui-tabs-loading" );
  1387. panel.removeAttr( "aria-busy" );
  1388. if ( jqXHR === that.xhr ) {
  1389. delete that.xhr;
  1390. }
  1391. };
  1392. // Not remote
  1393. if ( this._isLocal( anchor[ 0 ] ) ) {
  1394. return;
  1395. }
  1396. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  1397. // Support: jQuery <1.8
  1398. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  1399. // but as of 1.8, $.ajax() always returns a jqXHR object.
  1400. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  1401. this._addClass( tab, "ui-tabs-loading" );
  1402. panel.attr( "aria-busy", "true" );
  1403. this.xhr
  1404. .done( function( response, status, jqXHR ) {
  1405. // support: jQuery <1.8
  1406. // http://bugs.jquery.com/ticket/11778
  1407. setTimeout( function() {
  1408. panel.html( response );
  1409. that._trigger( "load", event, eventData );
  1410. complete( jqXHR, status );
  1411. }, 1 );
  1412. } )
  1413. .fail( function( jqXHR, status ) {
  1414. // support: jQuery <1.8
  1415. // http://bugs.jquery.com/ticket/11778
  1416. setTimeout( function() {
  1417. complete( jqXHR, status );
  1418. }, 1 );
  1419. } );
  1420. }
  1421. },
  1422. _ajaxSettings: function( anchor, event, eventData ) {
  1423. var that = this;
  1424. return {
  1425. // Support: IE <11 only
  1426. // Strip any hash that exists to prevent errors with the Ajax request
  1427. url: anchor.attr( "href" ).replace( /#.*$/, "" ),
  1428. beforeSend: function( jqXHR, settings ) {
  1429. return that._trigger( "beforeLoad", event,
  1430. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  1431. }
  1432. };
  1433. },
  1434. _getPanelForTab: function( tab ) {
  1435. var id = $( tab ).attr( "aria-controls" );
  1436. return this.element.find( this._sanitizeSelector( "#" + id ) );
  1437. }
  1438. } );
  1439. // DEPRECATED
  1440. // TODO: Switch return back to widget declaration at top of file when this is removed
  1441. if ( $.uiBackCompat !== false ) {
  1442. // Backcompat for ui-tab class (now ui-tabs-tab)
  1443. $.widget( "ui.tabs", $.ui.tabs, {
  1444. _processTabs: function() {
  1445. this._superApply( arguments );
  1446. this._addClass( this.tabs, "ui-tab" );
  1447. }
  1448. } );
  1449. }
  1450. var widgetsTabs = $.ui.tabs;
  1451. }));