Debian Codegraph @

src/lib/vendor/jquery-ui.custom/jquery-ui.js

raw
1 /*! jQuery UI - v1.13.2 - 2022-09-23
2 * http://jqueryui.com
3 * Includes: widget.js, form-reset-mixin.js, keycode.js, labels.js, unique-id.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/tabs.js
4 * Copyright jQuery Foundation and other contributors; Licensed MIT */
5
6 ( function( factory ) {
7 "use strict";
8
9 if ( typeof define === "function" && define.amd ) {
10
11 // AMD. Register as an anonymous module.
12 define( [ "jquery" ], factory );
13 } else {
14
15 // Browser globals
16 factory( jQuery );
17 }
18 } )( function( $ ) {
19 "use strict";
20
21 $.ui = $.ui || {};
22
23 var version = $.ui.version = "1.13.2";
24
25
26 /*!
27 * jQuery UI Widget 1.13.2
28 * http://jqueryui.com
29 *
30 * Copyright jQuery Foundation and other contributors
31 * Released under the MIT license.
32 * http://jquery.org/license
33 */
34
35 //>>label: Widget
36 //>>group: Core
37 //>>description: Provides a factory for creating stateful widgets with a common API.
38 //>>docs: http://api.jqueryui.com/jQuery.widget/
39 //>>demos: http://jqueryui.com/widget/
40
41
42 var widgetUuid = 0;
43 var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
44 var widgetSlice = Array.prototype.slice;
45
46 $.cleanData = ( function( orig ) {
47 return function( elems ) {
48 var events, elem, i;
49 for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
50
51 // Only trigger remove when necessary to save time
52 events = $._data( elem, "events" );
53 if ( events && events.remove ) {
54 $( elem ).triggerHandler( "remove" );
55 }
56 }
57 orig( elems );
58 };
59 } )( $.cleanData );
60
61 $.widget = function( name, base, prototype ) {
62 var existingConstructor, constructor, basePrototype;
63
64 // ProxiedPrototype allows the provided prototype to remain unmodified
65 // so that it can be used as a mixin for multiple widgets (#8876)
66 var proxiedPrototype = {};
67
68 var namespace = name.split( "." )[ 0 ];
69 name = name.split( "." )[ 1 ];
70 var fullName = namespace + "-" + name;
71
72 if ( !prototype ) {
73 prototype = base;
74 base = $.Widget;
75 }
76
77 if ( Array.isArray( prototype ) ) {
78 prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
79 }
80
81 // Create selector for plugin
82 $.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) {
83 return !!$.data( elem, fullName );
84 };
85
86 $[ namespace ] = $[ namespace ] || {};
87 existingConstructor = $[ namespace ][ name ];
88 constructor = $[ namespace ][ name ] = function( options, element ) {
89
90 // Allow instantiation without "new" keyword
91 if ( !this || !this._createWidget ) {
92 return new constructor( options, element );
93 }
94
95 // Allow instantiation without initializing for simple inheritance
96 // must use "new" keyword (the code above always passes args)
97 if ( arguments.length ) {
98 this._createWidget( options, element );
99 }
100 };
101
102 // Extend with the existing constructor to carry over any static properties
103 $.extend( constructor, existingConstructor, {
104 version: prototype.version,
105
106 // Copy the object used to create the prototype in case we need to
107 // redefine the widget later
108 _proto: $.extend( {}, prototype ),
109
110 // Track widgets that inherit from this widget in case this widget is
111 // redefined after a widget inherits from it
112 _childConstructors: []
113 } );
114
115 basePrototype = new base();
116
117 // We need to make the options hash a property directly on the new instance
118 // otherwise we'll modify the options hash on the prototype that we're
119 // inheriting from
120 basePrototype.options = $.widget.extend( {}, basePrototype.options );
121 $.each( prototype, function( prop, value ) {
122 if ( typeof value !== "function" ) {
123 proxiedPrototype[ prop ] = value;
124 return;
125 }
126 proxiedPrototype[ prop ] = ( function() {
127 function _super() {
128 return base.prototype[ prop ].apply( this, arguments );
129 }
130
131 function _superApply( args ) {
132 return base.prototype[ prop ].apply( this, args );
133 }
134
135 return function() {
136 var __super = this._super;
137 var __superApply = this._superApply;
138 var returnValue;
139
140 this._super = _super;
141 this._superApply = _superApply;
142
143 returnValue = value.apply( this, arguments );
144
145 this._super = __super;
146 this._superApply = __superApply;
147
148 return returnValue;
149 };
150 } )();
151 } );
152 constructor.prototype = $.widget.extend( basePrototype, {
153
154 // TODO: remove support for widgetEventPrefix
155 // always use the name + a colon as the prefix, e.g., draggable:start
156 // don't prefix for widgets that aren't DOM-based
157 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
158 }, proxiedPrototype, {
159 constructor: constructor,
160 namespace: namespace,
161 widgetName: name,
162 widgetFullName: fullName
163 } );
164
165 // If this widget is being redefined then we need to find all widgets that
166 // are inheriting from it and redefine all of them so that they inherit from
167 // the new version of this widget. We're essentially trying to replace one
168 // level in the prototype chain.
169 if ( existingConstructor ) {
170 $.each( existingConstructor._childConstructors, function( i, child ) {
171 var childPrototype = child.prototype;
172
173 // Redefine the child widget using the same prototype that was
174 // originally used, but inherit from the new version of the base
175 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
176 child._proto );
177 } );
178
179 // Remove the list of existing child constructors from the old constructor
180 // so the old child constructors can be garbage collected
181 delete existingConstructor._childConstructors;
182 } else {
183 base._childConstructors.push( constructor );
184 }
185
186 $.widget.bridge( name, constructor );
187
188 return constructor;
189 };
190
191 $.widget.extend = function( target ) {
192 var input = widgetSlice.call( arguments, 1 );
193 var inputIndex = 0;
194 var inputLength = input.length;
195 var key;
196 var value;
197
198 for ( ; inputIndex < inputLength; inputIndex++ ) {
199 for ( key in input[ inputIndex ] ) {
200 value = input[ inputIndex ][ key ];
201 if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) {
202
203 // Clone objects
204 if ( $.isPlainObject( value ) ) {
205 target[ key ] = $.isPlainObject( target[ key ] ) ?
206 $.widget.extend( {}, target[ key ], value ) :
207
208 // Don't extend strings, arrays, etc. with objects
209 $.widget.extend( {}, value );
210
211 // Copy everything else by reference
212 } else {
213 target[ key ] = value;
214 }
215 }
216 }
217 }
218 return target;
219 };
220
221 $.widget.bridge = function( name, object ) {
222 var fullName = object.prototype.widgetFullName || name;
223 $.fn[ name ] = function( options ) {
224 var isMethodCall = typeof options === "string";
225 var args = widgetSlice.call( arguments, 1 );
226 var returnValue = this;
227
228 if ( isMethodCall ) {
229
230 // If this is an empty collection, we need to have the instance method
231 // return undefined instead of the jQuery instance
232 if ( !this.length && options === "instance" ) {
233 returnValue = undefined;
234 } else {
235 this.each( function() {
236 var methodValue;
237 var instance = $.data( this, fullName );
238
239 if ( options === "instance" ) {
240 returnValue = instance;
241 return false;
242 }
243
244 if ( !instance ) {
245 return $.error( "cannot call methods on " + name +
246 " prior to initialization; " +
247 "attempted to call method '" + options + "'" );
248 }
249
250 if ( typeof instance[ options ] !== "function" ||
251 options.charAt( 0 ) === "_" ) {
252 return $.error( "no such method '" + options + "' for " + name +
253 " widget instance" );
254 }
255
256 methodValue = instance[ options ].apply( instance, args );
257
258 if ( methodValue !== instance && methodValue !== undefined ) {
259 returnValue = methodValue && methodValue.jquery ?
260 returnValue.pushStack( methodValue.get() ) :
261 methodValue;
262 return false;
263 }
264 } );
265 }
266 } else {
267
268 // Allow multiple hashes to be passed on init
269 if ( args.length ) {
270 options = $.widget.extend.apply( null, [ options ].concat( args ) );
271 }
272
273 this.each( function() {
274 var instance = $.data( this, fullName );
275 if ( instance ) {
276 instance.option( options || {} );
277 if ( instance._init ) {
278 instance._init();
279 }
280 } else {
281 $.data( this, fullName, new object( options, this ) );
282 }
283 } );
284 }
285
286 return returnValue;
287 };
288 };
289
290 $.Widget = function( /* options, element */ ) {};
291 $.Widget._childConstructors = [];
292
293 $.Widget.prototype = {
294 widgetName: "widget",
295 widgetEventPrefix: "",
296 defaultElement: "<div>",
297
298 options: {
299 classes: {},
300 disabled: false,
301
302 // Callbacks
303 create: null
304 },
305
306 _createWidget: function( options, element ) {
307 element = $( element || this.defaultElement || this )[ 0 ];
308 this.element = $( element );
309 this.uuid = widgetUuid++;
310 this.eventNamespace = "." + this.widgetName + this.uuid;
311
312 this.bindings = $();
313 this.hoverable = $();
314 this.focusable = $();
315 this.classesElementLookup = {};
316
317 if ( element !== this ) {
318 $.data( element, this.widgetFullName, this );
319 this._on( true, this.element, {
320 remove: function( event ) {
321 if ( event.target === element ) {
322 this.destroy();
323 }
324 }
325 } );
326 this.document = $( element.style ?
327
328 // Element within the document
329 element.ownerDocument :
330
331 // Element is window or document
332 element.document || element );
333 this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
334 }
335
336 this.options = $.widget.extend( {},
337 this.options,
338 this._getCreateOptions(),
339 options );
340
341 this._create();
342
343 if ( this.options.disabled ) {
344 this._setOptionDisabled( this.options.disabled );
345 }
346
347 this._trigger( "create", null, this._getCreateEventData() );
348 this._init();
349 },
350
351 _getCreateOptions: function() {
352 return {};
353 },
354
355 _getCreateEventData: $.noop,
356
357 _create: $.noop,
358
359 _init: $.noop,
360
361 destroy: function() {
362 var that = this;
363
364 this._destroy();
365 $.each( this.classesElementLookup, function( key, value ) {
366 that._removeClass( value, key );
367 } );
368
369 // We can probably remove the unbind calls in 2.0
370 // all event bindings should go through this._on()
371 this.element
372 .off( this.eventNamespace )
373 .removeData( this.widgetFullName );
374 this.widget()
375 .off( this.eventNamespace )
376 .removeAttr( "aria-disabled" );
377
378 // Clean up events and states
379 this.bindings.off( this.eventNamespace );
380 },
381
382 _destroy: $.noop,
383
384 widget: function() {
385 return this.element;
386 },
387
388 option: function( key, value ) {
389 var options = key;
390 var parts;
391 var curOption;
392 var i;
393
394 if ( arguments.length === 0 ) {
395
396 // Don't return a reference to the internal hash
397 return $.widget.extend( {}, this.options );
398 }
399
400 if ( typeof key === "string" ) {
401
402 // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
403 options = {};
404 parts = key.split( "." );
405 key = parts.shift();
406 if ( parts.length ) {
407 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
408 for ( i = 0; i < parts.length - 1; i++ ) {
409 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
410 curOption = curOption[ parts[ i ] ];
411 }
412 key = parts.pop();
413 if ( arguments.length === 1 ) {
414 return curOption[ key ] === undefined ? null : curOption[ key ];
415 }
416 curOption[ key ] = value;
417 } else {
418 if ( arguments.length === 1 ) {
419 return this.options[ key ] === undefined ? null : this.options[ key ];
420 }
421 options[ key ] = value;
422 }
423 }
424
425 this._setOptions( options );
426
427 return this;
428 },
429
430 _setOptions: function( options ) {
431 var key;
432
433 for ( key in options ) {
434 this._setOption( key, options[ key ] );
435 }
436
437 return this;
438 },
439
440 _setOption: function( key, value ) {
441 if ( key === "classes" ) {
442 this._setOptionClasses( value );
443 }
444
445 this.options[ key ] = value;
446
447 if ( key === "disabled" ) {
448 this._setOptionDisabled( value );
449 }
450
451 return this;
452 },
453
454 _setOptionClasses: function( value ) {
455 var classKey, elements, currentElements;
456
457 for ( classKey in value ) {
458 currentElements = this.classesElementLookup[ classKey ];
459 if ( value[ classKey ] === this.options.classes[ classKey ] ||
460 !currentElements ||
461 !currentElements.length ) {
462 continue;
463 }
464
465 // We are doing this to create a new jQuery object because the _removeClass() call
466 // on the next line is going to destroy the reference to the current elements being
467 // tracked. We need to save a copy of this collection so that we can add the new classes
468 // below.
469 elements = $( currentElements.get() );
470 this._removeClass( currentElements, classKey );
471
472 // We don't use _addClass() here, because that uses this.options.classes
473 // for generating the string of classes. We want to use the value passed in from
474 // _setOption(), this is the new value of the classes option which was passed to
475 // _setOption(). We pass this value directly to _classes().
476 elements.addClass( this._classes( {
477 element: elements,
478 keys: classKey,
479 classes: value,
480 add: true
481 } ) );
482 }
483 },
484
485 _setOptionDisabled: function( value ) {
486 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
487
488 // If the widget is becoming disabled, then nothing is interactive
489 if ( value ) {
490 this._removeClass( this.hoverable, null, "ui-state-hover" );
491 this._removeClass( this.focusable, null, "ui-state-focus" );
492 }
493 },
494
495 enable: function() {
496 return this._setOptions( { disabled: false } );
497 },
498
499 disable: function() {
500 return this._setOptions( { disabled: true } );
501 },
502
503 _classes: function( options ) {
504 var full = [];
505 var that = this;
506
507 options = $.extend( {
508 element: this.element,
509 classes: this.options.classes || {}
510 }, options );
511
512 function bindRemoveEvent() {
513 var nodesToBind = [];
514
515 options.element.each( function( _, element ) {
516 var isTracked = $.map( that.classesElementLookup, function( elements ) {
517 return elements;
518 } )
519 .some( function( elements ) {
520 return elements.is( element );
521 } );
522
523 if ( !isTracked ) {
524 nodesToBind.push( element );
525 }
526 } );
527
528 that._on( $( nodesToBind ), {
529 remove: "_untrackClassesElement"
530 } );
531 }
532
533 function processClassString( classes, checkOption ) {
534 var current, i;
535 for ( i = 0; i < classes.length; i++ ) {
536 current = that.classesElementLookup[ classes[ i ] ] || $();
537 if ( options.add ) {
538 bindRemoveEvent();
539 current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) );
540 } else {
541 current = $( current.not( options.element ).get() );
542 }
543 that.classesElementLookup[ classes[ i ] ] = current;
544 full.push( classes[ i ] );
545 if ( checkOption && options.classes[ classes[ i ] ] ) {
546 full.push( options.classes[ classes[ i ] ] );
547 }
548 }
549 }
550
551 if ( options.keys ) {
552 processClassString( options.keys.match( /\S+/g ) || [], true );
553 }
554 if ( options.extra ) {
555 processClassString( options.extra.match( /\S+/g ) || [] );
556 }
557
558 return full.join( " " );
559 },
560
561 _untrackClassesElement: function( event ) {
562 var that = this;
563 $.each( that.classesElementLookup, function( key, value ) {
564 if ( $.inArray( event.target, value ) !== -1 ) {
565 that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
566 }
567 } );
568
569 this._off( $( event.target ) );
570 },
571
572 _removeClass: function( element, keys, extra ) {
573 return this._toggleClass( element, keys, extra, false );
574 },
575
576 _addClass: function( element, keys, extra ) {
577 return this._toggleClass( element, keys, extra, true );
578 },
579
580 _toggleClass: function( element, keys, extra, add ) {
581 add = ( typeof add === "boolean" ) ? add : extra;
582 var shift = ( typeof element === "string" || element === null ),
583 options = {
584 extra: shift ? keys : extra,
585 keys: shift ? element : keys,
586 element: shift ? this.element : element,
587 add: add
588 };
589 options.element.toggleClass( this._classes( options ), add );
590 return this;
591 },
592
593 _on: function( suppressDisabledCheck, element, handlers ) {
594 var delegateElement;
595 var instance = this;
596
597 // No suppressDisabledCheck flag, shuffle arguments
598 if ( typeof suppressDisabledCheck !== "boolean" ) {
599 handlers = element;
600 element = suppressDisabledCheck;
601 suppressDisabledCheck = false;
602 }
603
604 // No element argument, shuffle and use this.element
605 if ( !handlers ) {
606 handlers = element;
607 element = this.element;
608 delegateElement = this.widget();
609 } else {
610 element = delegateElement = $( element );
611 this.bindings = this.bindings.add( element );
612 }
613
614 $.each( handlers, function( event, handler ) {
615 function handlerProxy() {
616
617 // Allow widgets to customize the disabled handling
618 // - disabled as an array instead of boolean
619 // - disabled class as method for disabling individual parts
620 if ( !suppressDisabledCheck &&
621 ( instance.options.disabled === true ||
622 $( this ).hasClass( "ui-state-disabled" ) ) ) {
623 return;
624 }
625 return ( typeof handler === "string" ? instance[ handler ] : handler )
626 .apply( instance, arguments );
627 }
628
629 // Copy the guid so direct unbinding works
630 if ( typeof handler !== "string" ) {
631 handlerProxy.guid = handler.guid =
632 handler.guid || handlerProxy.guid || $.guid++;
633 }
634
635 var match = event.match( /^([\w:-]*)\s*(.*)$/ );
636 var eventName = match[ 1 ] + instance.eventNamespace;
637 var selector = match[ 2 ];
638
639 if ( selector ) {
640 delegateElement.on( eventName, selector, handlerProxy );
641 } else {
642 element.on( eventName, handlerProxy );
643 }
644 } );
645 },
646
647 _off: function( element, eventName ) {
648 eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
649 this.eventNamespace;
650 element.off( eventName );
651
652 // Clear the stack to avoid memory leaks (#10056)
653 this.bindings = $( this.bindings.not( element ).get() );
654 this.focusable = $( this.focusable.not( element ).get() );
655 this.hoverable = $( this.hoverable.not( element ).get() );
656 },
657
658 _delay: function( handler, delay ) {
659 function handlerProxy() {
660 return ( typeof handler === "string" ? instance[ handler ] : handler )
661 .apply( instance, arguments );
662 }
663 var instance = this;
664 return setTimeout( handlerProxy, delay || 0 );
665 },
666
667 _hoverable: function( element ) {
668 this.hoverable = this.hoverable.add( element );
669 this._on( element, {
670 mouseenter: function( event ) {
671 this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
672 },
673 mouseleave: function( event ) {
674 this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
675 }
676 } );
677 },
678
679 _focusable: function( element ) {
680 this.focusable = this.focusable.add( element );
681 this._on( element, {
682 focusin: function( event ) {
683 this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
684 },
685 focusout: function( event ) {
686 this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
687 }
688 } );
689 },
690
691 _trigger: function( type, event, data ) {
692 var prop, orig;
693 var callback = this.options[ type ];
694
695 data = data || {};
696 event = $.Event( event );
697 event.type = ( type === this.widgetEventPrefix ?
698 type :
699 this.widgetEventPrefix + type ).toLowerCase();
700
701 // The original event may come from any element
702 // so we need to reset the target on the new event
703 event.target = this.element[ 0 ];
704
705 // Copy original event properties over to the new event
706 orig = event.originalEvent;
707 if ( orig ) {
708 for ( prop in orig ) {
709 if ( !( prop in event ) ) {
710 event[ prop ] = orig[ prop ];
711 }
712 }
713 }
714
715 this.element.trigger( event, data );
716 return !( typeof callback === "function" &&
717 callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
718 event.isDefaultPrevented() );
719 }
720 };
721
722 $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
723 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
724 if ( typeof options === "string" ) {
725 options = { effect: options };
726 }
727
728 var hasOptions;
729 var effectName = !options ?
730 method :
731 options === true || typeof options === "number" ?
732 defaultEffect :
733 options.effect || defaultEffect;
734
735 options = options || {};
736 if ( typeof options === "number" ) {
737 options = { duration: options };
738 } else if ( options === true ) {
739 options = {};
740 }
741
742 hasOptions = !$.isEmptyObject( options );
743 options.complete = callback;
744
745 if ( options.delay ) {
746 element.delay( options.delay );
747 }
748
749 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
750 element[ method ]( options );
751 } else if ( effectName !== method && element[ effectName ] ) {
752 element[ effectName ]( options.duration, options.easing, callback );
753 } else {
754 element.queue( function( next ) {
755 $( this )[ method ]();
756 if ( callback ) {
757 callback.call( element[ 0 ] );
758 }
759 next();
760 } );
761 }
762 };
763 } );
764
765 var widget = $.widget;
766
767
768
769 // Support: IE8 Only
770 // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
771 // with a string, so we need to find the proper form.
772 var form = $.fn._form = function() {
773 return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
774 };
775
776
777 /*!
778 * jQuery UI Form Reset Mixin 1.13.2
779 * http://jqueryui.com
780 *
781 * Copyright jQuery Foundation and other contributors
782 * Released under the MIT license.
783 * http://jquery.org/license
784 */
785
786 //>>label: Form Reset Mixin
787 //>>group: Core
788 //>>description: Refresh input widgets when their form is reset
789 //>>docs: http://api.jqueryui.com/form-reset-mixin/
790
791
792 var formResetMixin = $.ui.formResetMixin = {
793 _formResetHandler: function() {
794 var form = $( this );
795
796 // Wait for the form reset to actually happen before refreshing
797 setTimeout( function() {
798 var instances = form.data( "ui-form-reset-instances" );
799 $.each( instances, function() {
800 this.refresh();
801 } );
802 } );
803 },
804
805 _bindFormResetHandler: function() {
806 this.form = this.element._form();
807 if ( !this.form.length ) {
808 return;
809 }
810
811 var instances = this.form.data( "ui-form-reset-instances" ) || [];
812 if ( !instances.length ) {
813
814 // We don't use _on() here because we use a single event handler per form
815 this.form.on( "reset.ui-form-reset", this._formResetHandler );
816 }
817 instances.push( this );
818 this.form.data( "ui-form-reset-instances", instances );
819 },
820
821 _unbindFormResetHandler: function() {
822 if ( !this.form.length ) {
823 return;
824 }
825
826 var instances = this.form.data( "ui-form-reset-instances" );
827 instances.splice( $.inArray( this, instances ), 1 );
828 if ( instances.length ) {
829 this.form.data( "ui-form-reset-instances", instances );
830 } else {
831 this.form
832 .removeData( "ui-form-reset-instances" )
833 .off( "reset.ui-form-reset" );
834 }
835 }
836 };
837
838
839 /*!
840 * jQuery UI Keycode 1.13.2
841 * http://jqueryui.com
842 *
843 * Copyright jQuery Foundation and other contributors
844 * Released under the MIT license.
845 * http://jquery.org/license
846 */
847
848 //>>label: Keycode
849 //>>group: Core
850 //>>description: Provide keycodes as keynames
851 //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
852
853
854 var keycode = $.ui.keyCode = {
855 BACKSPACE: 8,
856 COMMA: 188,
857 DELETE: 46,
858 DOWN: 40,
859 END: 35,
860 ENTER: 13,
861 ESCAPE: 27,
862 HOME: 36,
863 LEFT: 37,
864 PAGE_DOWN: 34,
865 PAGE_UP: 33,
866 PERIOD: 190,
867 RIGHT: 39,
868 SPACE: 32,
869 TAB: 9,
870 UP: 38
871 };
872
873
874 /*!
875 * jQuery UI Labels 1.13.2
876 * http://jqueryui.com
877 *
878 * Copyright jQuery Foundation and other contributors
879 * Released under the MIT license.
880 * http://jquery.org/license
881 */
882
883 //>>label: labels
884 //>>group: Core
885 //>>description: Find all the labels associated with a given input
886 //>>docs: http://api.jqueryui.com/labels/
887
888
889 var labels = $.fn.labels = function() {
890 var ancestor, selector, id, labels, ancestors;
891
892 if ( !this.length ) {
893 return this.pushStack( [] );
894 }
895
896 // Check control.labels first
897 if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
898 return this.pushStack( this[ 0 ].labels );
899 }
900
901 // Support: IE <= 11, FF <= 37, Android <= 2.3 only
902 // Above browsers do not support control.labels. Everything below is to support them
903 // as well as document fragments. control.labels does not work on document fragments
904 labels = this.eq( 0 ).parents( "label" );
905
906 // Look for the label based on the id
907 id = this.attr( "id" );
908 if ( id ) {
909
910 // We don't search against the document in case the element
911 // is disconnected from the DOM
912 ancestor = this.eq( 0 ).parents().last();
913
914 // Get a full set of top level ancestors
915 ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
916
917 // Create a selector for the label based on the id
918 selector = "label[for='" + $.escapeSelector( id ) + "']";
919
920 labels = labels.add( ancestors.find( selector ).addBack( selector ) );
921
922 }
923
924 // Return whatever we have found for labels
925 return this.pushStack( labels );
926 };
927
928
929 /*!
930 * jQuery UI Unique ID 1.13.2
931 * http://jqueryui.com
932 *
933 * Copyright jQuery Foundation and other contributors
934 * Released under the MIT license.
935 * http://jquery.org/license
936 */
937
938 //>>label: uniqueId
939 //>>group: Core
940 //>>description: Functions to generate and remove uniqueId's
941 //>>docs: http://api.jqueryui.com/uniqueId/
942
943
944 var uniqueId = $.fn.extend( {
945 uniqueId: ( function() {
946 var uuid = 0;
947
948 return function() {
949 return this.each( function() {
950 if ( !this.id ) {
951 this.id = "ui-id-" + ( ++uuid );
952 }
953 } );
954 };
955 } )(),
956
957 removeUniqueId: function() {
958 return this.each( function() {
959 if ( /^ui-id-\d+$/.test( this.id ) ) {
960 $( this ).removeAttr( "id" );
961 }
962 } );
963 }
964 } );
965
966
967 /*!
968 * jQuery UI Controlgroup 1.13.2
969 * http://jqueryui.com
970 *
971 * Copyright jQuery Foundation and other contributors
972 * Released under the MIT license.
973 * http://jquery.org/license
974 */
975
976 //>>label: Controlgroup
977 //>>group: Widgets
978 //>>description: Visually groups form control widgets
979 //>>docs: http://api.jqueryui.com/controlgroup/
980 //>>demos: http://jqueryui.com/controlgroup/
981 //>>css.structure: ../../themes/base/core.css
982 //>>css.structure: ../../themes/base/controlgroup.css
983 //>>css.theme: ../../themes/base/theme.css
984
985
986 var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
987
988 var widgetsControlgroup = $.widget( "ui.controlgroup", {
989 version: "1.13.2",
990 defaultElement: "<div>",
991 options: {
992 direction: "horizontal",
993 disabled: null,
994 onlyVisible: true,
995 items: {
996 "button": "input[type=button], input[type=submit], input[type=reset], button, a",
997 "controlgroupLabel": ".ui-controlgroup-label",
998 "checkboxradio": "input[type='checkbox'], input[type='radio']",
999 "selectmenu": "select",
1000 "spinner": ".ui-spinner-input"
1001 }
1002 },
1003
1004 _create: function() {
1005 this._enhance();
1006 },
1007
1008 // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
1009 _enhance: function() {
1010 this.element.attr( "role", "toolbar" );
1011 this.refresh();
1012 },
1013
1014 _destroy: function() {
1015 this._callChildMethod( "destroy" );
1016 this.childWidgets.removeData( "ui-controlgroup-data" );
1017 this.element.removeAttr( "role" );
1018 if ( this.options.items.controlgroupLabel ) {
1019 this.element
1020 .find( this.options.items.controlgroupLabel )
1021 .find( ".ui-controlgroup-label-contents" )
1022 .contents().unwrap();
1023 }
1024 },
1025
1026 _initWidgets: function() {
1027 var that = this,
1028 childWidgets = [];
1029
1030 // First we iterate over each of the items options
1031 $.each( this.options.items, function( widget, selector ) {
1032 var labels;
1033 var options = {};
1034
1035 // Make sure the widget has a selector set
1036 if ( !selector ) {
1037 return;
1038 }
1039
1040 if ( widget === "controlgroupLabel" ) {
1041 labels = that.element.find( selector );
1042 labels.each( function() {
1043 var element = $( this );
1044
1045 if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
1046 return;
1047 }
1048 element.contents()
1049 .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
1050 } );
1051 that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
1052 childWidgets = childWidgets.concat( labels.get() );
1053 return;
1054 }
1055
1056 // Make sure the widget actually exists
1057 if ( !$.fn[ widget ] ) {
1058 return;
1059 }
1060
1061 // We assume everything is in the middle to start because we can't determine
1062 // first / last elements until all enhancments are done.
1063 if ( that[ "_" + widget + "Options" ] ) {
1064 options = that[ "_" + widget + "Options" ]( "middle" );
1065 } else {
1066 options = { classes: {} };
1067 }
1068
1069 // Find instances of this widget inside controlgroup and init them
1070 that.element
1071 .find( selector )
1072 .each( function() {
1073 var element = $( this );
1074 var instance = element[ widget ]( "instance" );
1075
1076 // We need to clone the default options for this type of widget to avoid
1077 // polluting the variable options which has a wider scope than a single widget.
1078 var instanceOptions = $.widget.extend( {}, options );
1079
1080 // If the button is the child of a spinner ignore it
1081 // TODO: Find a more generic solution
1082 if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
1083 return;
1084 }
1085
1086 // Create the widget if it doesn't exist
1087 if ( !instance ) {
1088 instance = element[ widget ]()[ widget ]( "instance" );
1089 }
1090 if ( instance ) {
1091 instanceOptions.classes =
1092 that._resolveClassesValues( instanceOptions.classes, instance );
1093 }
1094 element[ widget ]( instanceOptions );
1095
1096 // Store an instance of the controlgroup to be able to reference
1097 // from the outermost element for changing options and refresh
1098 var widgetElement = element[ widget ]( "widget" );
1099 $.data( widgetElement[ 0 ], "ui-controlgroup-data",
1100 instance ? instance : element[ widget ]( "instance" ) );
1101
1102 childWidgets.push( widgetElement[ 0 ] );
1103 } );
1104 } );
1105
1106 this.childWidgets = $( $.uniqueSort( childWidgets ) );
1107 this._addClass( this.childWidgets, "ui-controlgroup-item" );
1108 },
1109
1110 _callChildMethod: function( method ) {
1111 this.childWidgets.each( function() {
1112 var element = $( this ),
1113 data = element.data( "ui-controlgroup-data" );
1114 if ( data && data[ method ] ) {
1115 data[ method ]();
1116 }
1117 } );
1118 },
1119
1120 _updateCornerClass: function( element, position ) {
1121 var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
1122 var add = this._buildSimpleOptions( position, "label" ).classes.label;
1123
1124 this._removeClass( element, null, remove );
1125 this._addClass( element, null, add );
1126 },
1127
1128 _buildSimpleOptions: function( position, key ) {
1129 var direction = this.options.direction === "vertical";
1130 var result = {
1131 classes: {}
1132 };
1133 result.classes[ key ] = {
1134 "middle": "",
1135 "first": "ui-corner-" + ( direction ? "top" : "left" ),
1136 "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
1137 "only": "ui-corner-all"
1138 }[ position ];
1139
1140 return result;
1141 },
1142
1143 _spinnerOptions: function( position ) {
1144 var options = this._buildSimpleOptions( position, "ui-spinner" );
1145
1146 options.classes[ "ui-spinner-up" ] = "";
1147 options.classes[ "ui-spinner-down" ] = "";
1148
1149 return options;
1150 },
1151
1152 _buttonOptions: function( position ) {
1153 return this._buildSimpleOptions( position, "ui-button" );
1154 },
1155
1156 _checkboxradioOptions: function( position ) {
1157 return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
1158 },
1159
1160 _selectmenuOptions: function( position ) {
1161 var direction = this.options.direction === "vertical";
1162 return {
1163 width: direction ? "auto" : false,
1164 classes: {
1165 middle: {
1166 "ui-selectmenu-button-open": "",
1167 "ui-selectmenu-button-closed": ""
1168 },
1169 first: {
1170 "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
1171 "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
1172 },
1173 last: {
1174 "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
1175 "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
1176 },
1177 only: {
1178 "ui-selectmenu-button-open": "ui-corner-top",
1179 "ui-selectmenu-button-closed": "ui-corner-all"
1180 }
1181
1182 }[ position ]
1183 };
1184 },
1185
1186 _resolveClassesValues: function( classes, instance ) {
1187 var result = {};
1188 $.each( classes, function( key ) {
1189 var current = instance.options.classes[ key ] || "";
1190 current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) );
1191 result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
1192 } );
1193 return result;
1194 },
1195
1196 _setOption: function( key, value ) {
1197 if ( key === "direction" ) {
1198 this._removeClass( "ui-controlgroup-" + this.options.direction );
1199 }
1200
1201 this._super( key, value );
1202 if ( key === "disabled" ) {
1203 this._callChildMethod( value ? "disable" : "enable" );
1204 return;
1205 }
1206
1207 this.refresh();
1208 },
1209
1210 refresh: function() {
1211 var children,
1212 that = this;
1213
1214 this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
1215
1216 if ( this.options.direction === "horizontal" ) {
1217 this._addClass( null, "ui-helper-clearfix" );
1218 }
1219 this._initWidgets();
1220
1221 children = this.childWidgets;
1222
1223 // We filter here because we need to track all childWidgets not just the visible ones
1224 if ( this.options.onlyVisible ) {
1225 children = children.filter( ":visible" );
1226 }
1227
1228 if ( children.length ) {
1229
1230 // We do this last because we need to make sure all enhancment is done
1231 // before determining first and last
1232 $.each( [ "first", "last" ], function( index, value ) {
1233 var instance = children[ value ]().data( "ui-controlgroup-data" );
1234
1235 if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
1236 var options = that[ "_" + instance.widgetName + "Options" ](
1237 children.length === 1 ? "only" : value
1238 );
1239 options.classes = that._resolveClassesValues( options.classes, instance );
1240 instance.element[ instance.widgetName ]( options );
1241 } else {
1242 that._updateCornerClass( children[ value ](), value );
1243 }
1244 } );
1245
1246 // Finally call the refresh method on each of the child widgets.
1247 this._callChildMethod( "refresh" );
1248 }
1249 }
1250 } );
1251
1252 /*!
1253 * jQuery UI Checkboxradio 1.13.2
1254 * http://jqueryui.com
1255 *
1256 * Copyright jQuery Foundation and other contributors
1257 * Released under the MIT license.
1258 * http://jquery.org/license
1259 */
1260
1261 //>>label: Checkboxradio
1262 //>>group: Widgets
1263 //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
1264 //>>docs: http://api.jqueryui.com/checkboxradio/
1265 //>>demos: http://jqueryui.com/checkboxradio/
1266 //>>css.structure: ../../themes/base/core.css
1267 //>>css.structure: ../../themes/base/button.css
1268 //>>css.structure: ../../themes/base/checkboxradio.css
1269 //>>css.theme: ../../themes/base/theme.css
1270
1271
1272 $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
1273 version: "1.13.2",
1274 options: {
1275 disabled: null,
1276 label: null,
1277 icon: true,
1278 classes: {
1279 "ui-checkboxradio-label": "ui-corner-all",
1280 "ui-checkboxradio-icon": "ui-corner-all"
1281 }
1282 },
1283
1284 _getCreateOptions: function() {
1285 var disabled, labels, labelContents;
1286 var options = this._super() || {};
1287
1288 // We read the type here, because it makes more sense to throw a element type error first,
1289 // rather then the error for lack of a label. Often if its the wrong type, it
1290 // won't have a label (e.g. calling on a div, btn, etc)
1291 this._readType();
1292
1293 labels = this.element.labels();
1294
1295 // If there are multiple labels, use the last one
1296 this.label = $( labels[ labels.length - 1 ] );
1297 if ( !this.label.length ) {
1298 $.error( "No label found for checkboxradio widget" );
1299 }
1300
1301 this.originalLabel = "";
1302
1303 // We need to get the label text but this may also need to make sure it does not contain the
1304 // input itself.
1305 // The label contents could be text, html, or a mix. We wrap all elements
1306 // and read the wrapper's `innerHTML` to get a string representation of
1307 // the label, without the input as part of it.
1308 labelContents = this.label.contents().not( this.element[ 0 ] );
1309
1310 if ( labelContents.length ) {
1311 this.originalLabel += labelContents
1312 .clone()
1313 .wrapAll( "<div></div>" )
1314 .parent()
1315 .html();
1316 }
1317
1318 // Set the label option if we found label text
1319 if ( this.originalLabel ) {
1320 options.label = this.originalLabel;
1321 }
1322
1323 disabled = this.element[ 0 ].disabled;
1324 if ( disabled != null ) {
1325 options.disabled = disabled;
1326 }
1327 return options;
1328 },
1329
1330 _create: function() {
1331 var checked = this.element[ 0 ].checked;
1332
1333 this._bindFormResetHandler();
1334
1335 if ( this.options.disabled == null ) {
1336 this.options.disabled = this.element[ 0 ].disabled;
1337 }
1338
1339 this._setOption( "disabled", this.options.disabled );
1340 this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
1341 this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
1342
1343 if ( this.type === "radio" ) {
1344 this._addClass( this.label, "ui-checkboxradio-radio-label" );
1345 }
1346
1347 if ( this.options.label && this.options.label !== this.originalLabel ) {
1348 this._updateLabel();
1349 } else if ( this.originalLabel ) {
1350 this.options.label = this.originalLabel;
1351 }
1352
1353 this._enhance();
1354
1355 if ( checked ) {
1356 this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
1357 }
1358
1359 this._on( {
1360 change: "_toggleClasses",
1361 focus: function() {
1362 this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
1363 },
1364 blur: function() {
1365 this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
1366 }
1367 } );
1368 },
1369
1370 _readType: function() {
1371 var nodeName = this.element[ 0 ].nodeName.toLowerCase();
1372 this.type = this.element[ 0 ].type;
1373 if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
1374 $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
1375 " and element.type=" + this.type );
1376 }
1377 },
1378
1379 // Support jQuery Mobile enhanced option
1380 _enhance: function() {
1381 this._updateIcon( this.element[ 0 ].checked );
1382 },
1383
1384 widget: function() {
1385 return this.label;
1386 },
1387
1388 _getRadioGroup: function() {
1389 var group;
1390 var name = this.element[ 0 ].name;
1391 var nameSelector = "input[name='" + $.escapeSelector( name ) + "']";
1392
1393 if ( !name ) {
1394 return $( [] );
1395 }
1396
1397 if ( this.form.length ) {
1398 group = $( this.form[ 0 ].elements ).filter( nameSelector );
1399 } else {
1400
1401 // Not inside a form, check all inputs that also are not inside a form
1402 group = $( nameSelector ).filter( function() {
1403 return $( this )._form().length === 0;
1404 } );
1405 }
1406
1407 return group.not( this.element );
1408 },
1409
1410 _toggleClasses: function() {
1411 var checked = this.element[ 0 ].checked;
1412 this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
1413
1414 if ( this.options.icon && this.type === "checkbox" ) {
1415 this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
1416 ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
1417 }
1418
1419 if ( this.type === "radio" ) {
1420 this._getRadioGroup()
1421 .each( function() {
1422 var instance = $( this ).checkboxradio( "instance" );
1423
1424 if ( instance ) {
1425 instance._removeClass( instance.label,
1426 "ui-checkboxradio-checked", "ui-state-active" );
1427 }
1428 } );
1429 }
1430 },
1431
1432 _destroy: function() {
1433 this._unbindFormResetHandler();
1434
1435 if ( this.icon ) {
1436 this.icon.remove();
1437 this.iconSpace.remove();
1438 }
1439 },
1440
1441 _setOption: function( key, value ) {
1442
1443 // We don't allow the value to be set to nothing
1444 if ( key === "label" && !value ) {
1445 return;
1446 }
1447
1448 this._super( key, value );
1449
1450 if ( key === "disabled" ) {
1451 this._toggleClass( this.label, null, "ui-state-disabled", value );
1452 this.element[ 0 ].disabled = value;
1453
1454 // Don't refresh when setting disabled
1455 return;
1456 }
1457 this.refresh();
1458 },
1459
1460 _updateIcon: function( checked ) {
1461 var toAdd = "ui-icon ui-icon-background ";
1462
1463 if ( this.options.icon ) {
1464 if ( !this.icon ) {
1465 this.icon = $( "<span>" );
1466 this.iconSpace = $( "<span> </span>" );
1467 this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
1468 }
1469
1470 if ( this.type === "checkbox" ) {
1471 toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
1472 this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
1473 } else {
1474 toAdd += "ui-icon-blank";
1475 }
1476 this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
1477 if ( !checked ) {
1478 this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
1479 }
1480 this.icon.prependTo( this.label ).after( this.iconSpace );
1481 } else if ( this.icon !== undefined ) {
1482 this.icon.remove();
1483 this.iconSpace.remove();
1484 delete this.icon;
1485 }
1486 },
1487
1488 _updateLabel: function() {
1489
1490 // Remove the contents of the label ( minus the icon, icon space, and input )
1491 var contents = this.label.contents().not( this.element[ 0 ] );
1492 if ( this.icon ) {
1493 contents = contents.not( this.icon[ 0 ] );
1494 }
1495 if ( this.iconSpace ) {
1496 contents = contents.not( this.iconSpace[ 0 ] );
1497 }
1498 contents.remove();
1499
1500 this.label.append( this.options.label );
1501 },
1502
1503 refresh: function() {
1504 var checked = this.element[ 0 ].checked,
1505 isDisabled = this.element[ 0 ].disabled;
1506
1507 this._updateIcon( checked );
1508 this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
1509 if ( this.options.label !== null ) {
1510 this._updateLabel();
1511 }
1512
1513 if ( isDisabled !== this.options.disabled ) {
1514 this._setOptions( { "disabled": isDisabled } );
1515 }
1516 }
1517
1518 } ] );
1519
1520 var widgetsCheckboxradio = $.ui.checkboxradio;
1521
1522
1523 /*!
1524 * jQuery UI Button 1.13.2
1525 * http://jqueryui.com
1526 *
1527 * Copyright jQuery Foundation and other contributors
1528 * Released under the MIT license.
1529 * http://jquery.org/license
1530 */
1531
1532 //>>label: Button
1533 //>>group: Widgets
1534 //>>description: Enhances a form with themeable buttons.
1535 //>>docs: http://api.jqueryui.com/button/
1536 //>>demos: http://jqueryui.com/button/
1537 //>>css.structure: ../../themes/base/core.css
1538 //>>css.structure: ../../themes/base/button.css
1539 //>>css.theme: ../../themes/base/theme.css
1540
1541
1542 $.widget( "ui.button", {
1543 version: "1.13.2",
1544 defaultElement: "<button>",
1545 options: {
1546 classes: {
1547 "ui-button": "ui-corner-all"
1548 },
1549 disabled: null,
1550 icon: null,
1551 iconPosition: "beginning",
1552 label: null,
1553 showLabel: true
1554 },
1555
1556 _getCreateOptions: function() {
1557 var disabled,
1558
1559 // This is to support cases like in jQuery Mobile where the base widget does have
1560 // an implementation of _getCreateOptions
1561 options = this._super() || {};
1562
1563 this.isInput = this.element.is( "input" );
1564
1565 disabled = this.element[ 0 ].disabled;
1566 if ( disabled != null ) {
1567 options.disabled = disabled;
1568 }
1569
1570 this.originalLabel = this.isInput ? this.element.val() : this.element.html();
1571 if ( this.originalLabel ) {
1572 options.label = this.originalLabel;
1573 }
1574
1575 return options;
1576 },
1577
1578 _create: function() {
1579 if ( !this.option.showLabel & !this.options.icon ) {
1580 this.options.showLabel = true;
1581 }
1582
1583 // We have to check the option again here even though we did in _getCreateOptions,
1584 // because null may have been passed on init which would override what was set in
1585 // _getCreateOptions
1586 if ( this.options.disabled == null ) {
1587 this.options.disabled = this.element[ 0 ].disabled || false;
1588 }
1589
1590 this.hasTitle = !!this.element.attr( "title" );
1591
1592 // Check to see if the label needs to be set or if its already correct
1593 if ( this.options.label && this.options.label !== this.originalLabel ) {
1594 if ( this.isInput ) {
1595 this.element.val( this.options.label );
1596 } else {
1597 this.element.html( this.options.label );
1598 }
1599 }
1600 this._addClass( "ui-button", "ui-widget" );
1601 this._setOption( "disabled", this.options.disabled );
1602 this._enhance();
1603
1604 if ( this.element.is( "a" ) ) {
1605 this._on( {
1606 "keyup": function( event ) {
1607 if ( event.keyCode === $.ui.keyCode.SPACE ) {
1608 event.preventDefault();
1609
1610 // Support: PhantomJS <= 1.9, IE 8 Only
1611 // If a native click is available use it so we actually cause navigation
1612 // otherwise just trigger a click event
1613 if ( this.element[ 0 ].click ) {
1614 this.element[ 0 ].click();
1615 } else {
1616 this.element.trigger( "click" );
1617 }
1618 }
1619 }
1620 } );
1621 }
1622 },
1623
1624 _enhance: function() {
1625 if ( !this.element.is( "button" ) ) {
1626 this.element.attr( "role", "button" );
1627 }
1628
1629 if ( this.options.icon ) {
1630 this._updateIcon( "icon", this.options.icon );
1631 this._updateTooltip();
1632 }
1633 },
1634
1635 _updateTooltip: function() {
1636 this.title = this.element.attr( "title" );
1637
1638 if ( !this.options.showLabel && !this.title ) {
1639 this.element.attr( "title", this.options.label );
1640 }
1641 },
1642
1643 _updateIcon: function( option, value ) {
1644 var icon = option !== "iconPosition",
1645 position = icon ? this.options.iconPosition : value,
1646 displayBlock = position === "top" || position === "bottom";
1647
1648 // Create icon
1649 if ( !this.icon ) {
1650 this.icon = $( "<span>" );
1651
1652 this._addClass( this.icon, "ui-button-icon", "ui-icon" );
1653
1654 if ( !this.options.showLabel ) {
1655 this._addClass( "ui-button-icon-only" );
1656 }
1657 } else if ( icon ) {
1658
1659 // If we are updating the icon remove the old icon class
1660 this._removeClass( this.icon, null, this.options.icon );
1661 }
1662
1663 // If we are updating the icon add the new icon class
1664 if ( icon ) {
1665 this._addClass( this.icon, null, value );
1666 }
1667
1668 this._attachIcon( position );
1669
1670 // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
1671 // the iconSpace if there is one.
1672 if ( displayBlock ) {
1673 this._addClass( this.icon, null, "ui-widget-icon-block" );
1674 if ( this.iconSpace ) {
1675 this.iconSpace.remove();
1676 }
1677 } else {
1678
1679 // Position is beginning or end so remove the ui-widget-icon-block class and add the
1680 // space if it does not exist
1681 if ( !this.iconSpace ) {
1682 this.iconSpace = $( "<span> </span>" );
1683 this._addClass( this.iconSpace, "ui-button-icon-space" );
1684 }
1685 this._removeClass( this.icon, null, "ui-wiget-icon-block" );
1686 this._attachIconSpace( position );
1687 }
1688 },
1689
1690 _destroy: function() {
1691 this.element.removeAttr( "role" );
1692
1693 if ( this.icon ) {
1694 this.icon.remove();
1695 }
1696 if ( this.iconSpace ) {
1697 this.iconSpace.remove();
1698 }
1699 if ( !this.hasTitle ) {
1700 this.element.removeAttr( "title" );
1701 }
1702 },
1703
1704 _attachIconSpace: function( iconPosition ) {
1705 this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
1706 },
1707
1708 _attachIcon: function( iconPosition ) {
1709 this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
1710 },
1711
1712 _setOptions: function( options ) {
1713 var newShowLabel = options.showLabel === undefined ?
1714 this.options.showLabel :
1715 options.showLabel,
1716 newIcon = options.icon === undefined ? this.options.icon : options.icon;
1717
1718 if ( !newShowLabel && !newIcon ) {
1719 options.showLabel = true;
1720 }
1721 this._super( options );
1722 },
1723
1724 _setOption: function( key, value ) {
1725 if ( key === "icon" ) {
1726 if ( value ) {
1727 this._updateIcon( key, value );
1728 } else if ( this.icon ) {
1729 this.icon.remove();
1730 if ( this.iconSpace ) {
1731 this.iconSpace.remove();
1732 }
1733 }
1734 }
1735
1736 if ( key === "iconPosition" ) {
1737 this._updateIcon( key, value );
1738 }
1739
1740 // Make sure we can't end up with a button that has neither text nor icon
1741 if ( key === "showLabel" ) {
1742 this._toggleClass( "ui-button-icon-only", null, !value );
1743 this._updateTooltip();
1744 }
1745
1746 if ( key === "label" ) {
1747 if ( this.isInput ) {
1748 this.element.val( value );
1749 } else {
1750
1751 // If there is an icon, append it, else nothing then append the value
1752 // this avoids removal of the icon when setting label text
1753 this.element.html( value );
1754 if ( this.icon ) {
1755 this._attachIcon( this.options.iconPosition );
1756 this._attachIconSpace( this.options.iconPosition );
1757 }
1758 }
1759 }
1760
1761 this._super( key, value );
1762
1763 if ( key === "disabled" ) {
1764 this._toggleClass( null, "ui-state-disabled", value );
1765 this.element[ 0 ].disabled = value;
1766 if ( value ) {
1767 this.element.trigger( "blur" );
1768 }
1769 }
1770 },
1771
1772 refresh: function() {
1773
1774 // Make sure to only check disabled if its an element that supports this otherwise
1775 // check for the disabled class to determine state
1776 var isDisabled = this.element.is( "input, button" ) ?
1777 this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
1778
1779 if ( isDisabled !== this.options.disabled ) {
1780 this._setOptions( { disabled: isDisabled } );
1781 }
1782
1783 this._updateTooltip();
1784 }
1785 } );
1786
1787 // DEPRECATED
1788 if ( $.uiBackCompat !== false ) {
1789
1790 // Text and Icons options
1791 $.widget( "ui.button", $.ui.button, {
1792 options: {
1793 text: true,
1794 icons: {
1795 primary: null,
1796 secondary: null
1797 }
1798 },
1799
1800 _create: function() {
1801 if ( this.options.showLabel && !this.options.text ) {
1802 this.options.showLabel = this.options.text;
1803 }
1804 if ( !this.options.showLabel && this.options.text ) {
1805 this.options.text = this.options.showLabel;
1806 }
1807 if ( !this.options.icon && ( this.options.icons.primary ||
1808 this.options.icons.secondary ) ) {
1809 if ( this.options.icons.primary ) {
1810 this.options.icon = this.options.icons.primary;
1811 } else {
1812 this.options.icon = this.options.icons.secondary;
1813 this.options.iconPosition = "end";
1814 }
1815 } else if ( this.options.icon ) {
1816 this.options.icons.primary = this.options.icon;
1817 }
1818 this._super();
1819 },
1820
1821 _setOption: function( key, value ) {
1822 if ( key === "text" ) {
1823 this._super( "showLabel", value );
1824 return;
1825 }
1826 if ( key === "showLabel" ) {
1827 this.options.text = value;
1828 }
1829 if ( key === "icon" ) {
1830 this.options.icons.primary = value;
1831 }
1832 if ( key === "icons" ) {
1833 if ( value.primary ) {
1834 this._super( "icon", value.primary );
1835 this._super( "iconPosition", "beginning" );
1836 } else if ( value.secondary ) {
1837 this._super( "icon", value.secondary );
1838 this._super( "iconPosition", "end" );
1839 }
1840 }
1841 this._superApply( arguments );
1842 }
1843 } );
1844
1845 $.fn.button = ( function( orig ) {
1846 return function( options ) {
1847 var isMethodCall = typeof options === "string";
1848 var args = Array.prototype.slice.call( arguments, 1 );
1849 var returnValue = this;
1850
1851 if ( isMethodCall ) {
1852
1853 // If this is an empty collection, we need to have the instance method
1854 // return undefined instead of the jQuery instance
1855 if ( !this.length && options === "instance" ) {
1856 returnValue = undefined;
1857 } else {
1858 this.each( function() {
1859 var methodValue;
1860 var type = $( this ).attr( "type" );
1861 var name = type !== "checkbox" && type !== "radio" ?
1862 "button" :
1863 "checkboxradio";
1864 var instance = $.data( this, "ui-" + name );
1865
1866 if ( options === "instance" ) {
1867 returnValue = instance;
1868 return false;
1869 }
1870
1871 if ( !instance ) {
1872 return $.error( "cannot call methods on button" +
1873 " prior to initialization; " +
1874 "attempted to call method '" + options + "'" );
1875 }
1876
1877 if ( typeof instance[ options ] !== "function" ||
1878 options.charAt( 0 ) === "_" ) {
1879 return $.error( "no such method '" + options + "' for button" +
1880 " widget instance" );
1881 }
1882
1883 methodValue = instance[ options ].apply( instance, args );
1884
1885 if ( methodValue !== instance && methodValue !== undefined ) {
1886 returnValue = methodValue && methodValue.jquery ?
1887 returnValue.pushStack( methodValue.get() ) :
1888 methodValue;
1889 return false;
1890 }
1891 } );
1892 }
1893 } else {
1894
1895 // Allow multiple hashes to be passed on init
1896 if ( args.length ) {
1897 options = $.widget.extend.apply( null, [ options ].concat( args ) );
1898 }
1899
1900 this.each( function() {
1901 var type = $( this ).attr( "type" );
1902 var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
1903 var instance = $.data( this, "ui-" + name );
1904
1905 if ( instance ) {
1906 instance.option( options || {} );
1907 if ( instance._init ) {
1908 instance._init();
1909 }
1910 } else {
1911 if ( name === "button" ) {
1912 orig.call( $( this ), options );
1913 return;
1914 }
1915
1916 $( this ).checkboxradio( $.extend( { icon: false }, options ) );
1917 }
1918 } );
1919 }
1920
1921 return returnValue;
1922 };
1923 } )( $.fn.button );
1924
1925 $.fn.buttonset = function() {
1926 if ( !$.ui.controlgroup ) {
1927 $.error( "Controlgroup widget missing" );
1928 }
1929 if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
1930 return this.controlgroup.apply( this,
1931 [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
1932 }
1933 if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
1934 return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
1935 }
1936 if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
1937 arguments[ 0 ].items = {
1938 button: arguments[ 0 ].items
1939 };
1940 }
1941 return this.controlgroup.apply( this, arguments );
1942 };
1943 }
1944
1945 var widgetsButton = $.ui.button;
1946
1947
1948
1949 var safeActiveElement = $.ui.safeActiveElement = function( document ) {
1950 var activeElement;
1951
1952 // Support: IE 9 only
1953 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
1954 try {
1955 activeElement = document.activeElement;
1956 } catch ( error ) {
1957 activeElement = document.body;
1958 }
1959
1960 // Support: IE 9 - 11 only
1961 // IE may return null instead of an element
1962 // Interestingly, this only seems to occur when NOT in an iframe
1963 if ( !activeElement ) {
1964 activeElement = document.body;
1965 }
1966
1967 // Support: IE 11 only
1968 // IE11 returns a seemingly empty object in some cases when accessing
1969 // document.activeElement from an <iframe>
1970 if ( !activeElement.nodeName ) {
1971 activeElement = document.body;
1972 }
1973
1974 return activeElement;
1975 };
1976
1977
1978 /*!
1979 * jQuery UI Tabs 1.13.2
1980 * http://jqueryui.com
1981 *
1982 * Copyright jQuery Foundation and other contributors
1983 * Released under the MIT license.
1984 * http://jquery.org/license
1985 */
1986
1987 //>>label: Tabs
1988 //>>group: Widgets
1989 //>>description: Transforms a set of container elements into a tab structure.
1990 //>>docs: http://api.jqueryui.com/tabs/
1991 //>>demos: http://jqueryui.com/tabs/
1992 //>>css.structure: ../../themes/base/core.css
1993 //>>css.structure: ../../themes/base/tabs.css
1994 //>>css.theme: ../../themes/base/theme.css
1995
1996
1997 $.widget( "ui.tabs", {
1998 version: "1.13.2",
1999 delay: 300,
2000 options: {
2001 active: null,
2002 classes: {
2003 "ui-tabs": "ui-corner-all",
2004 "ui-tabs-nav": "ui-corner-all",
2005 "ui-tabs-panel": "ui-corner-bottom",
2006 "ui-tabs-tab": "ui-corner-top"
2007 },
2008 collapsible: false,
2009 event: "click",
2010 heightStyle: "content",
2011 hide: null,
2012 show: null,
2013
2014 // Callbacks
2015 activate: null,
2016 beforeActivate: null,
2017 beforeLoad: null,
2018 load: null
2019 },
2020
2021 _isLocal: ( function() {
2022 var rhash = /#.*$/;
2023
2024 return function( anchor ) {
2025 var anchorUrl, locationUrl;
2026
2027 anchorUrl = anchor.href.replace( rhash, "" );
2028 locationUrl = location.href.replace( rhash, "" );
2029
2030 // Decoding may throw an error if the URL isn't UTF-8 (#9518)
2031 try {
2032 anchorUrl = decodeURIComponent( anchorUrl );
2033 } catch ( error ) {}
2034 try {
2035 locationUrl = decodeURIComponent( locationUrl );
2036 } catch ( error ) {}
2037
2038 return anchor.hash.length > 1 && anchorUrl === locationUrl;
2039 };
2040 } )(),
2041
2042 _create: function() {
2043 var that = this,
2044 options = this.options;
2045
2046 this.running = false;
2047
2048 this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
2049 this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
2050
2051 this._processTabs();
2052 options.active = this._initialActive();
2053
2054 // Take disabling tabs via class attribute from HTML
2055 // into account and update option properly.
2056 if ( Array.isArray( options.disabled ) ) {
2057 options.disabled = $.uniqueSort( options.disabled.concat(
2058 $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
2059 return that.tabs.index( li );
2060 } )
2061 ) ).sort();
2062 }
2063
2064 // Check for length avoids error when initializing empty list
2065 if ( this.options.active !== false && this.anchors.length ) {
2066 this.active = this._findActive( options.active );
2067 } else {
2068 this.active = $();
2069 }
2070
2071 this._refresh();
2072
2073 if ( this.active.length ) {
2074 this.load( options.active );
2075 }
2076 },
2077
2078 _initialActive: function() {
2079 var active = this.options.active,
2080 collapsible = this.options.collapsible,
2081 locationHash = location.hash.substring( 1 );
2082
2083 if ( active === null ) {
2084
2085 // check the fragment identifier in the URL
2086 if ( locationHash ) {
2087 this.tabs.each( function( i, tab ) {
2088 if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
2089 active = i;
2090 return false;
2091 }
2092 } );
2093 }
2094
2095 // Check for a tab marked active via a class
2096 if ( active === null ) {
2097 active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
2098 }
2099
2100 // No active tab, set to false
2101 if ( active === null || active === -1 ) {
2102 active = this.tabs.length ? 0 : false;
2103 }
2104 }
2105
2106 // Handle numbers: negative, out of range
2107 if ( active !== false ) {
2108 active = this.tabs.index( this.tabs.eq( active ) );
2109 if ( active === -1 ) {
2110 active = collapsible ? false : 0;
2111 }
2112 }
2113
2114 // Don't allow collapsible: false and active: false
2115 if ( !collapsible && active === false && this.anchors.length ) {
2116 active = 0;
2117 }
2118
2119 return active;
2120 },
2121
2122 _getCreateEventData: function() {
2123 return {
2124 tab: this.active,
2125 panel: !this.active.length ? $() : this._getPanelForTab( this.active )
2126 };
2127 },
2128
2129 _tabKeydown: function( event ) {
2130 var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
2131 selectedIndex = this.tabs.index( focusedTab ),
2132 goingForward = true;
2133
2134 if ( this._handlePageNav( event ) ) {
2135 return;
2136 }
2137
2138 switch ( event.keyCode ) {
2139 case $.ui.keyCode.RIGHT:
2140 case $.ui.keyCode.DOWN:
2141 selectedIndex++;
2142 break;
2143 case $.ui.keyCode.UP:
2144 case $.ui.keyCode.LEFT:
2145 goingForward = false;
2146 selectedIndex--;
2147 break;
2148 case $.ui.keyCode.END:
2149 selectedIndex = this.anchors.length - 1;
2150 break;
2151 case $.ui.keyCode.HOME:
2152 selectedIndex = 0;
2153 break;
2154 case $.ui.keyCode.SPACE:
2155
2156 // Activate only, no collapsing
2157 event.preventDefault();
2158 clearTimeout( this.activating );
2159 this._activate( selectedIndex );
2160 return;
2161 case $.ui.keyCode.ENTER:
2162
2163 // Toggle (cancel delayed activation, allow collapsing)
2164 event.preventDefault();
2165 clearTimeout( this.activating );
2166
2167 // Determine if we should collapse or activate
2168 this._activate( selectedIndex === this.options.active ? false : selectedIndex );
2169 return;
2170 default:
2171 return;
2172 }
2173
2174 // Focus the appropriate tab, based on which key was pressed
2175 event.preventDefault();
2176 clearTimeout( this.activating );
2177 selectedIndex = this._focusNextTab( selectedIndex, goingForward );
2178
2179 // Navigating with control/command key will prevent automatic activation
2180 if ( !event.ctrlKey && !event.metaKey ) {
2181
2182 // Update aria-selected immediately so that AT think the tab is already selected.
2183 // Otherwise AT may confuse the user by stating that they need to activate the tab,
2184 // but the tab will already be activated by the time the announcement finishes.
2185 focusedTab.attr( "aria-selected", "false" );
2186 this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
2187
2188 this.activating = this._delay( function() {
2189 this.option( "active", selectedIndex );
2190 }, this.delay );
2191 }
2192 },
2193
2194 _panelKeydown: function( event ) {
2195 if ( this._handlePageNav( event ) ) {
2196 return;
2197 }
2198
2199 // Ctrl+up moves focus to the current tab
2200 if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
2201 event.preventDefault();
2202 this.active.trigger( "focus" );
2203 }
2204 },
2205
2206 // Alt+page up/down moves focus to the previous/next tab (and activates)
2207 _handlePageNav: function( event ) {
2208 if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
2209 this._activate( this._focusNextTab( this.options.active - 1, false ) );
2210 return true;
2211 }
2212 if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
2213 this._activate( this._focusNextTab( this.options.active + 1, true ) );
2214 return true;
2215 }
2216 },
2217
2218 _findNextTab: function( index, goingForward ) {
2219 var lastTabIndex = this.tabs.length - 1;
2220
2221 function constrain() {
2222 if ( index > lastTabIndex ) {
2223 index = 0;
2224 }
2225 if ( index < 0 ) {
2226 index = lastTabIndex;
2227 }
2228 return index;
2229 }
2230
2231 while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
2232 index = goingForward ? index + 1 : index - 1;
2233 }
2234
2235 return index;
2236 },
2237
2238 _focusNextTab: function( index, goingForward ) {
2239 index = this._findNextTab( index, goingForward );
2240 this.tabs.eq( index ).trigger( "focus" );
2241 return index;
2242 },
2243
2244 _setOption: function( key, value ) {
2245 if ( key === "active" ) {
2246
2247 // _activate() will handle invalid values and update this.options
2248 this._activate( value );
2249 return;
2250 }
2251
2252 this._super( key, value );
2253
2254 if ( key === "collapsible" ) {
2255 this._toggleClass( "ui-tabs-collapsible", null, value );
2256
2257 // Setting collapsible: false while collapsed; open first panel
2258 if ( !value && this.options.active === false ) {
2259 this._activate( 0 );
2260 }
2261 }
2262
2263 if ( key === "event" ) {
2264 this._setupEvents( value );
2265 }
2266
2267 if ( key === "heightStyle" ) {
2268 this._setupHeightStyle( value );
2269 }
2270 },
2271
2272 _sanitizeSelector: function( hash ) {
2273 return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
2274 },
2275
2276 refresh: function() {
2277 var options = this.options,
2278 lis = this.tablist.children( ":has(a[href])" );
2279
2280 // Get disabled tabs from class attribute from HTML
2281 // this will get converted to a boolean if needed in _refresh()
2282 options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
2283 return lis.index( tab );
2284 } );
2285
2286 this._processTabs();
2287
2288 // Was collapsed or no tabs
2289 if ( options.active === false || !this.anchors.length ) {
2290 options.active = false;
2291 this.active = $();
2292
2293 // was active, but active tab is gone
2294 } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
2295
2296 // all remaining tabs are disabled
2297 if ( this.tabs.length === options.disabled.length ) {
2298 options.active = false;
2299 this.active = $();
2300
2301 // activate previous tab
2302 } else {
2303 this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
2304 }
2305
2306 // was active, active tab still exists
2307 } else {
2308
2309 // make sure active index is correct
2310 options.active = this.tabs.index( this.active );
2311 }
2312
2313 this._refresh();
2314 },
2315
2316 _refresh: function() {
2317 this._setOptionDisabled( this.options.disabled );
2318 this._setupEvents( this.options.event );
2319 this._setupHeightStyle( this.options.heightStyle );
2320
2321 this.tabs.not( this.active ).attr( {
2322 "aria-selected": "false",
2323 "aria-expanded": "false",
2324 tabIndex: -1
2325 } );
2326 this.panels.not( this._getPanelForTab( this.active ) )
2327 .hide()
2328 .attr( {
2329 "aria-hidden": "true"
2330 } );
2331
2332 // Make sure one tab is in the tab order
2333 if ( !this.active.length ) {
2334 this.tabs.eq( 0 ).attr( "tabIndex", 0 );
2335 } else {
2336 this.active
2337 .attr( {
2338 "aria-selected": "true",
2339 "aria-expanded": "true",
2340 tabIndex: 0
2341 } );
2342 this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
2343 this._getPanelForTab( this.active )
2344 .show()
2345 .attr( {
2346 "aria-hidden": "false"
2347 } );
2348 }
2349 },
2350
2351 _processTabs: function() {
2352 var that = this,
2353 prevTabs = this.tabs,
2354 prevAnchors = this.anchors,
2355 prevPanels = this.panels;
2356
2357 this.tablist = this._getList().attr( "role", "tablist" );
2358 this._addClass( this.tablist, "ui-tabs-nav",
2359 "ui-helper-reset ui-helper-clearfix ui-widget-header" );
2360
2361 // Prevent users from focusing disabled tabs via click
2362 this.tablist
2363 .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
2364 if ( $( this ).is( ".ui-state-disabled" ) ) {
2365 event.preventDefault();
2366 }
2367 } )
2368
2369 // Support: IE <9
2370 // Preventing the default action in mousedown doesn't prevent IE
2371 // from focusing the element, so if the anchor gets focused, blur.
2372 // We don't have to worry about focusing the previously focused
2373 // element since clicking on a non-focusable element should focus
2374 // the body anyway.
2375 .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
2376 if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
2377 this.blur();
2378 }
2379 } );
2380
2381 this.tabs = this.tablist.find( "> li:has(a[href])" )
2382 .attr( {
2383 role: "tab",
2384 tabIndex: -1
2385 } );
2386 this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
2387
2388 this.anchors = this.tabs.map( function() {
2389 return $( "a", this )[ 0 ];
2390 } )
2391 .attr( {
2392 tabIndex: -1
2393 } );
2394 this._addClass( this.anchors, "ui-tabs-anchor" );
2395
2396 this.panels = $();
2397
2398 this.anchors.each( function( i, anchor ) {
2399 var selector, panel, panelId,
2400 anchorId = $( anchor ).uniqueId().attr( "id" ),
2401 tab = $( anchor ).closest( "li" ),
2402 originalAriaControls = tab.attr( "aria-controls" );
2403
2404 // Inline tab
2405 if ( that._isLocal( anchor ) ) {
2406 selector = anchor.hash;
2407 panelId = selector.substring( 1 );
2408 panel = that.element.find( that._sanitizeSelector( selector ) );
2409
2410 // remote tab
2411 } else {
2412
2413 // If the tab doesn't already have aria-controls,
2414 // generate an id by using a throw-away element
2415 panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
2416 selector = "#" + panelId;
2417 panel = that.element.find( selector );
2418 if ( !panel.length ) {
2419 panel = that._createPanel( panelId );
2420 panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
2421 }
2422 panel.attr( "aria-live", "polite" );
2423 }
2424
2425 if ( panel.length ) {
2426 that.panels = that.panels.add( panel );
2427 }
2428 if ( originalAriaControls ) {
2429 tab.data( "ui-tabs-aria-controls", originalAriaControls );
2430 }
2431 tab.attr( {
2432 "aria-controls": panelId,
2433 "aria-labelledby": anchorId
2434 } );
2435 panel.attr( "aria-labelledby", anchorId );
2436 } );
2437
2438 this.panels.attr( "role", "tabpanel" );
2439 this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
2440
2441 // Avoid memory leaks (#10056)
2442 if ( prevTabs ) {
2443 this._off( prevTabs.not( this.tabs ) );
2444 this._off( prevAnchors.not( this.anchors ) );
2445 this._off( prevPanels.not( this.panels ) );
2446 }
2447 },
2448
2449 // Allow overriding how to find the list for rare usage scenarios (#7715)
2450 _getList: function() {
2451 return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
2452 },
2453
2454 _createPanel: function( id ) {
2455 return $( "<div>" )
2456 .attr( "id", id )
2457 .data( "ui-tabs-destroy", true );
2458 },
2459
2460 _setOptionDisabled: function( disabled ) {
2461 var currentItem, li, i;
2462
2463 if ( Array.isArray( disabled ) ) {
2464 if ( !disabled.length ) {
2465 disabled = false;
2466 } else if ( disabled.length === this.anchors.length ) {
2467 disabled = true;
2468 }
2469 }
2470
2471 // Disable tabs
2472 for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
2473 currentItem = $( li );
2474 if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
2475 currentItem.attr( "aria-disabled", "true" );
2476 this._addClass( currentItem, null, "ui-state-disabled" );
2477 } else {
2478 currentItem.removeAttr( "aria-disabled" );
2479 this._removeClass( currentItem, null, "ui-state-disabled" );
2480 }
2481 }
2482
2483 this.options.disabled = disabled;
2484
2485 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
2486 disabled === true );
2487 },
2488
2489 _setupEvents: function( event ) {
2490 var events = {};
2491 if ( event ) {
2492 $.each( event.split( " " ), function( index, eventName ) {
2493 events[ eventName ] = "_eventHandler";
2494 } );
2495 }
2496
2497 this._off( this.anchors.add( this.tabs ).add( this.panels ) );
2498
2499 // Always prevent the default action, even when disabled
2500 this._on( true, this.anchors, {
2501 click: function( event ) {
2502 event.preventDefault();
2503 }
2504 } );
2505 this._on( this.anchors, events );
2506 this._on( this.tabs, { keydown: "_tabKeydown" } );
2507 this._on( this.panels, { keydown: "_panelKeydown" } );
2508
2509 this._focusable( this.tabs );
2510 this._hoverable( this.tabs );
2511 },
2512
2513 _setupHeightStyle: function( heightStyle ) {
2514 var maxHeight,
2515 parent = this.element.parent();
2516
2517 if ( heightStyle === "fill" ) {
2518 maxHeight = parent.height();
2519 maxHeight -= this.element.outerHeight() - this.element.height();
2520
2521 this.element.siblings( ":visible" ).each( function() {
2522 var elem = $( this ),
2523 position = elem.css( "position" );
2524
2525 if ( position === "absolute" || position === "fixed" ) {
2526 return;
2527 }
2528 maxHeight -= elem.outerHeight( true );
2529 } );
2530
2531 this.element.children().not( this.panels ).each( function() {
2532 maxHeight -= $( this ).outerHeight( true );
2533 } );
2534
2535 this.panels.each( function() {
2536 $( this ).height( Math.max( 0, maxHeight -
2537 $( this ).innerHeight() + $( this ).height() ) );
2538 } )
2539 .css( "overflow", "auto" );
2540 } else if ( heightStyle === "auto" ) {
2541 maxHeight = 0;
2542 this.panels.each( function() {
2543 maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
2544 } ).height( maxHeight );
2545 }
2546 },
2547
2548 _eventHandler: function( event ) {
2549 var options = this.options,
2550 active = this.active,
2551 anchor = $( event.currentTarget ),
2552 tab = anchor.closest( "li" ),
2553 clickedIsActive = tab[ 0 ] === active[ 0 ],
2554 collapsing = clickedIsActive && options.collapsible,
2555 toShow = collapsing ? $() : this._getPanelForTab( tab ),
2556 toHide = !active.length ? $() : this._getPanelForTab( active ),
2557 eventData = {
2558 oldTab: active,
2559 oldPanel: toHide,
2560 newTab: collapsing ? $() : tab,
2561 newPanel: toShow
2562 };
2563
2564 event.preventDefault();
2565
2566 if ( tab.hasClass( "ui-state-disabled" ) ||
2567
2568 // tab is already loading
2569 tab.hasClass( "ui-tabs-loading" ) ||
2570
2571 // can't switch durning an animation
2572 this.running ||
2573
2574 // click on active header, but not collapsible
2575 ( clickedIsActive && !options.collapsible ) ||
2576
2577 // allow canceling activation
2578 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
2579 return;
2580 }
2581
2582 options.active = collapsing ? false : this.tabs.index( tab );
2583
2584 this.active = clickedIsActive ? $() : tab;
2585 if ( this.xhr ) {
2586 this.xhr.abort();
2587 }
2588
2589 if ( !toHide.length && !toShow.length ) {
2590 $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
2591 }
2592
2593 if ( toShow.length ) {
2594 this.load( this.tabs.index( tab ), event );
2595 }
2596 this._toggle( event, eventData );
2597 },
2598
2599 // Handles show/hide for selecting tabs
2600 _toggle: function( event, eventData ) {
2601 var that = this,
2602 toShow = eventData.newPanel,
2603 toHide = eventData.oldPanel;
2604
2605 this.running = true;
2606
2607 function complete() {
2608 that.running = false;
2609 that._trigger( "activate", event, eventData );
2610 }
2611
2612 function show() {
2613 that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
2614
2615 if ( toShow.length && that.options.show ) {
2616 that._show( toShow, that.options.show, complete );
2617 } else {
2618 toShow.show();
2619 complete();
2620 }
2621 }
2622
2623 // Start out by hiding, then showing, then completing
2624 if ( toHide.length && this.options.hide ) {
2625 this._hide( toHide, this.options.hide, function() {
2626 that._removeClass( eventData.oldTab.closest( "li" ),
2627 "ui-tabs-active", "ui-state-active" );
2628 show();
2629 } );
2630 } else {
2631 this._removeClass( eventData.oldTab.closest( "li" ),
2632 "ui-tabs-active", "ui-state-active" );
2633 toHide.hide();
2634 show();
2635 }
2636
2637 toHide.attr( "aria-hidden", "true" );
2638 eventData.oldTab.attr( {
2639 "aria-selected": "false",
2640 "aria-expanded": "false"
2641 } );
2642
2643 // If we're switching tabs, remove the old tab from the tab order.
2644 // If we're opening from collapsed state, remove the previous tab from the tab order.
2645 // If we're collapsing, then keep the collapsing tab in the tab order.
2646 if ( toShow.length && toHide.length ) {
2647 eventData.oldTab.attr( "tabIndex", -1 );
2648 } else if ( toShow.length ) {
2649 this.tabs.filter( function() {
2650 return $( this ).attr( "tabIndex" ) === 0;
2651 } )
2652 .attr( "tabIndex", -1 );
2653 }
2654
2655 toShow.attr( "aria-hidden", "false" );
2656 eventData.newTab.attr( {
2657 "aria-selected": "true",
2658 "aria-expanded": "true",
2659 tabIndex: 0
2660 } );
2661 },
2662
2663 _activate: function( index ) {
2664 var anchor,
2665 active = this._findActive( index );
2666
2667 // Trying to activate the already active panel
2668 if ( active[ 0 ] === this.active[ 0 ] ) {
2669 return;
2670 }
2671
2672 // Trying to collapse, simulate a click on the current active header
2673 if ( !active.length ) {
2674 active = this.active;
2675 }
2676
2677 anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
2678 this._eventHandler( {
2679 target: anchor,
2680 currentTarget: anchor,
2681 preventDefault: $.noop
2682 } );
2683 },
2684
2685 _findActive: function( index ) {
2686 return index === false ? $() : this.tabs.eq( index );
2687 },
2688
2689 _getIndex: function( index ) {
2690
2691 // meta-function to give users option to provide a href string instead of a numerical index.
2692 if ( typeof index === "string" ) {
2693 index = this.anchors.index( this.anchors.filter( "[href$='" +
2694 $.escapeSelector( index ) + "']" ) );
2695 }
2696
2697 return index;
2698 },
2699
2700 _destroy: function() {
2701 if ( this.xhr ) {
2702 this.xhr.abort();
2703 }
2704
2705 this.tablist
2706 .removeAttr( "role" )
2707 .off( this.eventNamespace );
2708
2709 this.anchors
2710 .removeAttr( "role tabIndex" )
2711 .removeUniqueId();
2712
2713 this.tabs.add( this.panels ).each( function() {
2714 if ( $.data( this, "ui-tabs-destroy" ) ) {
2715 $( this ).remove();
2716 } else {
2717 $( this ).removeAttr( "role tabIndex " +
2718 "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
2719 }
2720 } );
2721
2722 this.tabs.each( function() {
2723 var li = $( this ),
2724 prev = li.data( "ui-tabs-aria-controls" );
2725 if ( prev ) {
2726 li
2727 .attr( "aria-controls", prev )
2728 .removeData( "ui-tabs-aria-controls" );
2729 } else {
2730 li.removeAttr( "aria-controls" );
2731 }
2732 } );
2733
2734 this.panels.show();
2735
2736 if ( this.options.heightStyle !== "content" ) {
2737 this.panels.css( "height", "" );
2738 }
2739 },
2740
2741 enable: function( index ) {
2742 var disabled = this.options.disabled;
2743 if ( disabled === false ) {
2744 return;
2745 }
2746
2747 if ( index === undefined ) {
2748 disabled = false;
2749 } else {
2750 index = this._getIndex( index );
2751 if ( Array.isArray( disabled ) ) {
2752 disabled = $.map( disabled, function( num ) {
2753 return num !== index ? num : null;
2754 } );
2755 } else {
2756 disabled = $.map( this.tabs, function( li, num ) {
2757 return num !== index ? num : null;
2758 } );
2759 }
2760 }
2761 this._setOptionDisabled( disabled );
2762 },
2763
2764 disable: function( index ) {
2765 var disabled = this.options.disabled;
2766 if ( disabled === true ) {
2767 return;
2768 }
2769
2770 if ( index === undefined ) {
2771 disabled = true;
2772 } else {
2773 index = this._getIndex( index );
2774 if ( $.inArray( index, disabled ) !== -1 ) {
2775 return;
2776 }
2777 if ( Array.isArray( disabled ) ) {
2778 disabled = $.merge( [ index ], disabled ).sort();
2779 } else {
2780 disabled = [ index ];
2781 }
2782 }
2783 this._setOptionDisabled( disabled );
2784 },
2785
2786 load: function( index, event ) {
2787 index = this._getIndex( index );
2788 var that = this,
2789 tab = this.tabs.eq( index ),
2790 anchor = tab.find( ".ui-tabs-anchor" ),
2791 panel = this._getPanelForTab( tab ),
2792 eventData = {
2793 tab: tab,
2794 panel: panel
2795 },
2796 complete = function( jqXHR, status ) {
2797 if ( status === "abort" ) {
2798 that.panels.stop( false, true );
2799 }
2800
2801 that._removeClass( tab, "ui-tabs-loading" );
2802 panel.removeAttr( "aria-busy" );
2803
2804 if ( jqXHR === that.xhr ) {
2805 delete that.xhr;
2806 }
2807 };
2808
2809 // Not remote
2810 if ( this._isLocal( anchor[ 0 ] ) ) {
2811 return;
2812 }
2813
2814 this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
2815
2816 // Support: jQuery <1.8
2817 // jQuery <1.8 returns false if the request is canceled in beforeSend,
2818 // but as of 1.8, $.ajax() always returns a jqXHR object.
2819 if ( this.xhr && this.xhr.statusText !== "canceled" ) {
2820 this._addClass( tab, "ui-tabs-loading" );
2821 panel.attr( "aria-busy", "true" );
2822
2823 this.xhr
2824 .done( function( response, status, jqXHR ) {
2825
2826 // support: jQuery <1.8
2827 // http://bugs.jquery.com/ticket/11778
2828 setTimeout( function() {
2829 panel.html( response );
2830 that._trigger( "load", event, eventData );
2831
2832 complete( jqXHR, status );
2833 }, 1 );
2834 } )
2835 .fail( function( jqXHR, status ) {
2836
2837 // support: jQuery <1.8
2838 // http://bugs.jquery.com/ticket/11778
2839 setTimeout( function() {
2840 complete( jqXHR, status );
2841 }, 1 );
2842 } );
2843 }
2844 },
2845
2846 _ajaxSettings: function( anchor, event, eventData ) {
2847 var that = this;
2848 return {
2849
2850 // Support: IE <11 only
2851 // Strip any hash that exists to prevent errors with the Ajax request
2852 url: anchor.attr( "href" ).replace( /#.*$/, "" ),
2853 beforeSend: function( jqXHR, settings ) {
2854 return that._trigger( "beforeLoad", event,
2855 $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
2856 }
2857 };
2858 },
2859
2860 _getPanelForTab: function( tab ) {
2861 var id = $( tab ).attr( "aria-controls" );
2862 return this.element.find( this._sanitizeSelector( "#" + id ) );
2863 }
2864 } );
2865
2866 // DEPRECATED
2867 // TODO: Switch return back to widget declaration at top of file when this is removed
2868 if ( $.uiBackCompat !== false ) {
2869
2870 // Backcompat for ui-tab class (now ui-tabs-tab)
2871 $.widget( "ui.tabs", $.ui.tabs, {
2872 _processTabs: function() {
2873 this._superApply( arguments );
2874 this._addClass( this.tabs, "ui-tab" );
2875 }
2876 } );
2877 }
2878
2879 var widgetsTabs = $.ui.tabs;
2880
2881
2882
2883
2884 } );