Merge branch 'wip_MDL-47303_m28_jquery' of https://github.com/skodak/moodle
[moodle.git] / lib / jquery / ui-1.11.1 / jquery-ui.js
1 /*! jQuery UI - v1.11.1 - 2014-08-13
2 * http://jqueryui.com
3 * Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js
4 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
6 (function( factory ) {
7         if ( typeof define === "function" && define.amd ) {
9                 // AMD. Register as an anonymous module.
10                 define([ "jquery" ], factory );
11         } else {
13                 // Browser globals
14                 factory( jQuery );
15         }
16 }(function( $ ) {
17 /*!
18  * jQuery UI Core 1.11.1
19  * http://jqueryui.com
20  *
21  * Copyright 2014 jQuery Foundation and other contributors
22  * Released under the MIT license.
23  * http://jquery.org/license
24  *
25  * http://api.jqueryui.com/category/ui-core/
26  */
29 // $.ui might exist from components with no dependencies, e.g., $.ui.position
30 $.ui = $.ui || {};
32 $.extend( $.ui, {
33         version: "1.11.1",
35         keyCode: {
36                 BACKSPACE: 8,
37                 COMMA: 188,
38                 DELETE: 46,
39                 DOWN: 40,
40                 END: 35,
41                 ENTER: 13,
42                 ESCAPE: 27,
43                 HOME: 36,
44                 LEFT: 37,
45                 PAGE_DOWN: 34,
46                 PAGE_UP: 33,
47                 PERIOD: 190,
48                 RIGHT: 39,
49                 SPACE: 32,
50                 TAB: 9,
51                 UP: 38
52         }
53 });
55 // plugins
56 $.fn.extend({
57         scrollParent: function( includeHidden ) {
58                 var position = this.css( "position" ),
59                         excludeStaticParent = position === "absolute",
60                         overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
61                         scrollParent = this.parents().filter( function() {
62                                 var parent = $( this );
63                                 if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
64                                         return false;
65                                 }
66                                 return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
67                         }).eq( 0 );
69                 return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
70         },
72         uniqueId: (function() {
73                 var uuid = 0;
75                 return function() {
76                         return this.each(function() {
77                                 if ( !this.id ) {
78                                         this.id = "ui-id-" + ( ++uuid );
79                                 }
80                         });
81                 };
82         })(),
84         removeUniqueId: function() {
85                 return this.each(function() {
86                         if ( /^ui-id-\d+$/.test( this.id ) ) {
87                                 $( this ).removeAttr( "id" );
88                         }
89                 });
90         }
91 });
93 // selectors
94 function focusable( element, isTabIndexNotNaN ) {
95         var map, mapName, img,
96                 nodeName = element.nodeName.toLowerCase();
97         if ( "area" === nodeName ) {
98                 map = element.parentNode;
99                 mapName = map.name;
100                 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
101                         return false;
102                 }
103                 img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
104                 return !!img && visible( img );
105         }
106         return ( /input|select|textarea|button|object/.test( nodeName ) ?
107                 !element.disabled :
108                 "a" === nodeName ?
109                         element.href || isTabIndexNotNaN :
110                         isTabIndexNotNaN) &&
111                 // the element and all of its ancestors must be visible
112                 visible( element );
115 function visible( element ) {
116         return $.expr.filters.visible( element ) &&
117                 !$( element ).parents().addBack().filter(function() {
118                         return $.css( this, "visibility" ) === "hidden";
119                 }).length;
122 $.extend( $.expr[ ":" ], {
123         data: $.expr.createPseudo ?
124                 $.expr.createPseudo(function( dataName ) {
125                         return function( elem ) {
126                                 return !!$.data( elem, dataName );
127                         };
128                 }) :
129                 // support: jQuery <1.8
130                 function( elem, i, match ) {
131                         return !!$.data( elem, match[ 3 ] );
132                 },
134         focusable: function( element ) {
135                 return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
136         },
138         tabbable: function( element ) {
139                 var tabIndex = $.attr( element, "tabindex" ),
140                         isTabIndexNaN = isNaN( tabIndex );
141                 return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
142         }
143 });
145 // support: jQuery <1.8
146 if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
147         $.each( [ "Width", "Height" ], function( i, name ) {
148                 var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
149                         type = name.toLowerCase(),
150                         orig = {
151                                 innerWidth: $.fn.innerWidth,
152                                 innerHeight: $.fn.innerHeight,
153                                 outerWidth: $.fn.outerWidth,
154                                 outerHeight: $.fn.outerHeight
155                         };
157                 function reduce( elem, size, border, margin ) {
158                         $.each( side, function() {
159                                 size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
160                                 if ( border ) {
161                                         size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
162                                 }
163                                 if ( margin ) {
164                                         size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
165                                 }
166                         });
167                         return size;
168                 }
170                 $.fn[ "inner" + name ] = function( size ) {
171                         if ( size === undefined ) {
172                                 return orig[ "inner" + name ].call( this );
173                         }
175                         return this.each(function() {
176                                 $( this ).css( type, reduce( this, size ) + "px" );
177                         });
178                 };
180                 $.fn[ "outer" + name] = function( size, margin ) {
181                         if ( typeof size !== "number" ) {
182                                 return orig[ "outer" + name ].call( this, size );
183                         }
185                         return this.each(function() {
186                                 $( this).css( type, reduce( this, size, true, margin ) + "px" );
187                         });
188                 };
189         });
192 // support: jQuery <1.8
193 if ( !$.fn.addBack ) {
194         $.fn.addBack = function( selector ) {
195                 return this.add( selector == null ?
196                         this.prevObject : this.prevObject.filter( selector )
197                 );
198         };
201 // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
202 if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
203         $.fn.removeData = (function( removeData ) {
204                 return function( key ) {
205                         if ( arguments.length ) {
206                                 return removeData.call( this, $.camelCase( key ) );
207                         } else {
208                                 return removeData.call( this );
209                         }
210                 };
211         })( $.fn.removeData );
214 // deprecated
215 $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
217 $.fn.extend({
218         focus: (function( orig ) {
219                 return function( delay, fn ) {
220                         return typeof delay === "number" ?
221                                 this.each(function() {
222                                         var elem = this;
223                                         setTimeout(function() {
224                                                 $( elem ).focus();
225                                                 if ( fn ) {
226                                                         fn.call( elem );
227                                                 }
228                                         }, delay );
229                                 }) :
230                                 orig.apply( this, arguments );
231                 };
232         })( $.fn.focus ),
234         disableSelection: (function() {
235                 var eventType = "onselectstart" in document.createElement( "div" ) ?
236                         "selectstart" :
237                         "mousedown";
239                 return function() {
240                         return this.bind( eventType + ".ui-disableSelection", function( event ) {
241                                 event.preventDefault();
242                         });
243                 };
244         })(),
246         enableSelection: function() {
247                 return this.unbind( ".ui-disableSelection" );
248         },
250         zIndex: function( zIndex ) {
251                 if ( zIndex !== undefined ) {
252                         return this.css( "zIndex", zIndex );
253                 }
255                 if ( this.length ) {
256                         var elem = $( this[ 0 ] ), position, value;
257                         while ( elem.length && elem[ 0 ] !== document ) {
258                                 // Ignore z-index if position is set to a value where z-index is ignored by the browser
259                                 // This makes behavior of this function consistent across browsers
260                                 // WebKit always returns auto if the element is positioned
261                                 position = elem.css( "position" );
262                                 if ( position === "absolute" || position === "relative" || position === "fixed" ) {
263                                         // IE returns 0 when zIndex is not specified
264                                         // other browsers return a string
265                                         // we ignore the case of nested elements with an explicit value of 0
266                                         // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
267                                         value = parseInt( elem.css( "zIndex" ), 10 );
268                                         if ( !isNaN( value ) && value !== 0 ) {
269                                                 return value;
270                                         }
271                                 }
272                                 elem = elem.parent();
273                         }
274                 }
276                 return 0;
277         }
278 });
280 // $.ui.plugin is deprecated. Use $.widget() extensions instead.
281 $.ui.plugin = {
282         add: function( module, option, set ) {
283                 var i,
284                         proto = $.ui[ module ].prototype;
285                 for ( i in set ) {
286                         proto.plugins[ i ] = proto.plugins[ i ] || [];
287                         proto.plugins[ i ].push( [ option, set[ i ] ] );
288                 }
289         },
290         call: function( instance, name, args, allowDisconnected ) {
291                 var i,
292                         set = instance.plugins[ name ];
294                 if ( !set ) {
295                         return;
296                 }
298                 if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
299                         return;
300                 }
302                 for ( i = 0; i < set.length; i++ ) {
303                         if ( instance.options[ set[ i ][ 0 ] ] ) {
304                                 set[ i ][ 1 ].apply( instance.element, args );
305                         }
306                 }
307         }
308 };
311 /*!
312  * jQuery UI Widget 1.11.1
313  * http://jqueryui.com
314  *
315  * Copyright 2014 jQuery Foundation and other contributors
316  * Released under the MIT license.
317  * http://jquery.org/license
318  *
319  * http://api.jqueryui.com/jQuery.widget/
320  */
323 var widget_uuid = 0,
324         widget_slice = Array.prototype.slice;
326 $.cleanData = (function( orig ) {
327         return function( elems ) {
328                 var events, elem, i;
329                 for ( i = 0; (elem = elems[i]) != null; i++ ) {
330                         try {
332                                 // Only trigger remove when necessary to save time
333                                 events = $._data( elem, "events" );
334                                 if ( events && events.remove ) {
335                                         $( elem ).triggerHandler( "remove" );
336                                 }
338                         // http://bugs.jquery.com/ticket/8235
339                         } catch( e ) {}
340                 }
341                 orig( elems );
342         };
343 })( $.cleanData );
345 $.widget = function( name, base, prototype ) {
346         var fullName, existingConstructor, constructor, basePrototype,
347                 // proxiedPrototype allows the provided prototype to remain unmodified
348                 // so that it can be used as a mixin for multiple widgets (#8876)
349                 proxiedPrototype = {},
350                 namespace = name.split( "." )[ 0 ];
352         name = name.split( "." )[ 1 ];
353         fullName = namespace + "-" + name;
355         if ( !prototype ) {
356                 prototype = base;
357                 base = $.Widget;
358         }
360         // create selector for plugin
361         $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
362                 return !!$.data( elem, fullName );
363         };
365         $[ namespace ] = $[ namespace ] || {};
366         existingConstructor = $[ namespace ][ name ];
367         constructor = $[ namespace ][ name ] = function( options, element ) {
368                 // allow instantiation without "new" keyword
369                 if ( !this._createWidget ) {
370                         return new constructor( options, element );
371                 }
373                 // allow instantiation without initializing for simple inheritance
374                 // must use "new" keyword (the code above always passes args)
375                 if ( arguments.length ) {
376                         this._createWidget( options, element );
377                 }
378         };
379         // extend with the existing constructor to carry over any static properties
380         $.extend( constructor, existingConstructor, {
381                 version: prototype.version,
382                 // copy the object used to create the prototype in case we need to
383                 // redefine the widget later
384                 _proto: $.extend( {}, prototype ),
385                 // track widgets that inherit from this widget in case this widget is
386                 // redefined after a widget inherits from it
387                 _childConstructors: []
388         });
390         basePrototype = new base();
391         // we need to make the options hash a property directly on the new instance
392         // otherwise we'll modify the options hash on the prototype that we're
393         // inheriting from
394         basePrototype.options = $.widget.extend( {}, basePrototype.options );
395         $.each( prototype, function( prop, value ) {
396                 if ( !$.isFunction( value ) ) {
397                         proxiedPrototype[ prop ] = value;
398                         return;
399                 }
400                 proxiedPrototype[ prop ] = (function() {
401                         var _super = function() {
402                                         return base.prototype[ prop ].apply( this, arguments );
403                                 },
404                                 _superApply = function( args ) {
405                                         return base.prototype[ prop ].apply( this, args );
406                                 };
407                         return function() {
408                                 var __super = this._super,
409                                         __superApply = this._superApply,
410                                         returnValue;
412                                 this._super = _super;
413                                 this._superApply = _superApply;
415                                 returnValue = value.apply( this, arguments );
417                                 this._super = __super;
418                                 this._superApply = __superApply;
420                                 return returnValue;
421                         };
422                 })();
423         });
424         constructor.prototype = $.widget.extend( basePrototype, {
425                 // TODO: remove support for widgetEventPrefix
426                 // always use the name + a colon as the prefix, e.g., draggable:start
427                 // don't prefix for widgets that aren't DOM-based
428                 widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
429         }, proxiedPrototype, {
430                 constructor: constructor,
431                 namespace: namespace,
432                 widgetName: name,
433                 widgetFullName: fullName
434         });
436         // If this widget is being redefined then we need to find all widgets that
437         // are inheriting from it and redefine all of them so that they inherit from
438         // the new version of this widget. We're essentially trying to replace one
439         // level in the prototype chain.
440         if ( existingConstructor ) {
441                 $.each( existingConstructor._childConstructors, function( i, child ) {
442                         var childPrototype = child.prototype;
444                         // redefine the child widget using the same prototype that was
445                         // originally used, but inherit from the new version of the base
446                         $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
447                 });
448                 // remove the list of existing child constructors from the old constructor
449                 // so the old child constructors can be garbage collected
450                 delete existingConstructor._childConstructors;
451         } else {
452                 base._childConstructors.push( constructor );
453         }
455         $.widget.bridge( name, constructor );
457         return constructor;
458 };
460 $.widget.extend = function( target ) {
461         var input = widget_slice.call( arguments, 1 ),
462                 inputIndex = 0,
463                 inputLength = input.length,
464                 key,
465                 value;
466         for ( ; inputIndex < inputLength; inputIndex++ ) {
467                 for ( key in input[ inputIndex ] ) {
468                         value = input[ inputIndex ][ key ];
469                         if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
470                                 // Clone objects
471                                 if ( $.isPlainObject( value ) ) {
472                                         target[ key ] = $.isPlainObject( target[ key ] ) ?
473                                                 $.widget.extend( {}, target[ key ], value ) :
474                                                 // Don't extend strings, arrays, etc. with objects
475                                                 $.widget.extend( {}, value );
476                                 // Copy everything else by reference
477                                 } else {
478                                         target[ key ] = value;
479                                 }
480                         }
481                 }
482         }
483         return target;
484 };
486 $.widget.bridge = function( name, object ) {
487         var fullName = object.prototype.widgetFullName || name;
488         $.fn[ name ] = function( options ) {
489                 var isMethodCall = typeof options === "string",
490                         args = widget_slice.call( arguments, 1 ),
491                         returnValue = this;
493                 // allow multiple hashes to be passed on init
494                 options = !isMethodCall && args.length ?
495                         $.widget.extend.apply( null, [ options ].concat(args) ) :
496                         options;
498                 if ( isMethodCall ) {
499                         this.each(function() {
500                                 var methodValue,
501                                         instance = $.data( this, fullName );
502                                 if ( options === "instance" ) {
503                                         returnValue = instance;
504                                         return false;
505                                 }
506                                 if ( !instance ) {
507                                         return $.error( "cannot call methods on " + name + " prior to initialization; " +
508                                                 "attempted to call method '" + options + "'" );
509                                 }
510                                 if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
511                                         return $.error( "no such method '" + options + "' for " + name + " widget instance" );
512                                 }
513                                 methodValue = instance[ options ].apply( instance, args );
514                                 if ( methodValue !== instance && methodValue !== undefined ) {
515                                         returnValue = methodValue && methodValue.jquery ?
516                                                 returnValue.pushStack( methodValue.get() ) :
517                                                 methodValue;
518                                         return false;
519                                 }
520                         });
521                 } else {
522                         this.each(function() {
523                                 var instance = $.data( this, fullName );
524                                 if ( instance ) {
525                                         instance.option( options || {} );
526                                         if ( instance._init ) {
527                                                 instance._init();
528                                         }
529                                 } else {
530                                         $.data( this, fullName, new object( options, this ) );
531                                 }
532                         });
533                 }
535                 return returnValue;
536         };
537 };
539 $.Widget = function( /* options, element */ ) {};
540 $.Widget._childConstructors = [];
542 $.Widget.prototype = {
543         widgetName: "widget",
544         widgetEventPrefix: "",
545         defaultElement: "<div>",
546         options: {
547                 disabled: false,
549                 // callbacks
550                 create: null
551         },
552         _createWidget: function( options, element ) {
553                 element = $( element || this.defaultElement || this )[ 0 ];
554                 this.element = $( element );
555                 this.uuid = widget_uuid++;
556                 this.eventNamespace = "." + this.widgetName + this.uuid;
557                 this.options = $.widget.extend( {},
558                         this.options,
559                         this._getCreateOptions(),
560                         options );
562                 this.bindings = $();
563                 this.hoverable = $();
564                 this.focusable = $();
566                 if ( element !== this ) {
567                         $.data( element, this.widgetFullName, this );
568                         this._on( true, this.element, {
569                                 remove: function( event ) {
570                                         if ( event.target === element ) {
571                                                 this.destroy();
572                                         }
573                                 }
574                         });
575                         this.document = $( element.style ?
576                                 // element within the document
577                                 element.ownerDocument :
578                                 // element is window or document
579                                 element.document || element );
580                         this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
581                 }
583                 this._create();
584                 this._trigger( "create", null, this._getCreateEventData() );
585                 this._init();
586         },
587         _getCreateOptions: $.noop,
588         _getCreateEventData: $.noop,
589         _create: $.noop,
590         _init: $.noop,
592         destroy: function() {
593                 this._destroy();
594                 // we can probably remove the unbind calls in 2.0
595                 // all event bindings should go through this._on()
596                 this.element
597                         .unbind( this.eventNamespace )
598                         .removeData( this.widgetFullName )
599                         // support: jquery <1.6.3
600                         // http://bugs.jquery.com/ticket/9413
601                         .removeData( $.camelCase( this.widgetFullName ) );
602                 this.widget()
603                         .unbind( this.eventNamespace )
604                         .removeAttr( "aria-disabled" )
605                         .removeClass(
606                                 this.widgetFullName + "-disabled " +
607                                 "ui-state-disabled" );
609                 // clean up events and states
610                 this.bindings.unbind( this.eventNamespace );
611                 this.hoverable.removeClass( "ui-state-hover" );
612                 this.focusable.removeClass( "ui-state-focus" );
613         },
614         _destroy: $.noop,
616         widget: function() {
617                 return this.element;
618         },
620         option: function( key, value ) {
621                 var options = key,
622                         parts,
623                         curOption,
624                         i;
626                 if ( arguments.length === 0 ) {
627                         // don't return a reference to the internal hash
628                         return $.widget.extend( {}, this.options );
629                 }
631                 if ( typeof key === "string" ) {
632                         // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
633                         options = {};
634                         parts = key.split( "." );
635                         key = parts.shift();
636                         if ( parts.length ) {
637                                 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
638                                 for ( i = 0; i < parts.length - 1; i++ ) {
639                                         curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
640                                         curOption = curOption[ parts[ i ] ];
641                                 }
642                                 key = parts.pop();
643                                 if ( arguments.length === 1 ) {
644                                         return curOption[ key ] === undefined ? null : curOption[ key ];
645                                 }
646                                 curOption[ key ] = value;
647                         } else {
648                                 if ( arguments.length === 1 ) {
649                                         return this.options[ key ] === undefined ? null : this.options[ key ];
650                                 }
651                                 options[ key ] = value;
652                         }
653                 }
655                 this._setOptions( options );
657                 return this;
658         },
659         _setOptions: function( options ) {
660                 var key;
662                 for ( key in options ) {
663                         this._setOption( key, options[ key ] );
664                 }
666                 return this;
667         },
668         _setOption: function( key, value ) {
669                 this.options[ key ] = value;
671                 if ( key === "disabled" ) {
672                         this.widget()
673                                 .toggleClass( this.widgetFullName + "-disabled", !!value );
675                         // If the widget is becoming disabled, then nothing is interactive
676                         if ( value ) {
677                                 this.hoverable.removeClass( "ui-state-hover" );
678                                 this.focusable.removeClass( "ui-state-focus" );
679                         }
680                 }
682                 return this;
683         },
685         enable: function() {
686                 return this._setOptions({ disabled: false });
687         },
688         disable: function() {
689                 return this._setOptions({ disabled: true });
690         },
692         _on: function( suppressDisabledCheck, element, handlers ) {
693                 var delegateElement,
694                         instance = this;
696                 // no suppressDisabledCheck flag, shuffle arguments
697                 if ( typeof suppressDisabledCheck !== "boolean" ) {
698                         handlers = element;
699                         element = suppressDisabledCheck;
700                         suppressDisabledCheck = false;
701                 }
703                 // no element argument, shuffle and use this.element
704                 if ( !handlers ) {
705                         handlers = element;
706                         element = this.element;
707                         delegateElement = this.widget();
708                 } else {
709                         element = delegateElement = $( element );
710                         this.bindings = this.bindings.add( element );
711                 }
713                 $.each( handlers, function( event, handler ) {
714                         function handlerProxy() {
715                                 // allow widgets to customize the disabled handling
716                                 // - disabled as an array instead of boolean
717                                 // - disabled class as method for disabling individual parts
718                                 if ( !suppressDisabledCheck &&
719                                                 ( instance.options.disabled === true ||
720                                                         $( this ).hasClass( "ui-state-disabled" ) ) ) {
721                                         return;
722                                 }
723                                 return ( typeof handler === "string" ? instance[ handler ] : handler )
724                                         .apply( instance, arguments );
725                         }
727                         // copy the guid so direct unbinding works
728                         if ( typeof handler !== "string" ) {
729                                 handlerProxy.guid = handler.guid =
730                                         handler.guid || handlerProxy.guid || $.guid++;
731                         }
733                         var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
734                                 eventName = match[1] + instance.eventNamespace,
735                                 selector = match[2];
736                         if ( selector ) {
737                                 delegateElement.delegate( selector, eventName, handlerProxy );
738                         } else {
739                                 element.bind( eventName, handlerProxy );
740                         }
741                 });
742         },
744         _off: function( element, eventName ) {
745                 eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
746                 element.unbind( eventName ).undelegate( eventName );
747         },
749         _delay: function( handler, delay ) {
750                 function handlerProxy() {
751                         return ( typeof handler === "string" ? instance[ handler ] : handler )
752                                 .apply( instance, arguments );
753                 }
754                 var instance = this;
755                 return setTimeout( handlerProxy, delay || 0 );
756         },
758         _hoverable: function( element ) {
759                 this.hoverable = this.hoverable.add( element );
760                 this._on( element, {
761                         mouseenter: function( event ) {
762                                 $( event.currentTarget ).addClass( "ui-state-hover" );
763                         },
764                         mouseleave: function( event ) {
765                                 $( event.currentTarget ).removeClass( "ui-state-hover" );
766                         }
767                 });
768         },
770         _focusable: function( element ) {
771                 this.focusable = this.focusable.add( element );
772                 this._on( element, {
773                         focusin: function( event ) {
774                                 $( event.currentTarget ).addClass( "ui-state-focus" );
775                         },
776                         focusout: function( event ) {
777                                 $( event.currentTarget ).removeClass( "ui-state-focus" );
778                         }
779                 });
780         },
782         _trigger: function( type, event, data ) {
783                 var prop, orig,
784                         callback = this.options[ type ];
786                 data = data || {};
787                 event = $.Event( event );
788                 event.type = ( type === this.widgetEventPrefix ?
789                         type :
790                         this.widgetEventPrefix + type ).toLowerCase();
791                 // the original event may come from any element
792                 // so we need to reset the target on the new event
793                 event.target = this.element[ 0 ];
795                 // copy original event properties over to the new event
796                 orig = event.originalEvent;
797                 if ( orig ) {
798                         for ( prop in orig ) {
799                                 if ( !( prop in event ) ) {
800                                         event[ prop ] = orig[ prop ];
801                                 }
802                         }
803                 }
805                 this.element.trigger( event, data );
806                 return !( $.isFunction( callback ) &&
807                         callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
808                         event.isDefaultPrevented() );
809         }
810 };
812 $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
813         $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
814                 if ( typeof options === "string" ) {
815                         options = { effect: options };
816                 }
817                 var hasOptions,
818                         effectName = !options ?
819                                 method :
820                                 options === true || typeof options === "number" ?
821                                         defaultEffect :
822                                         options.effect || defaultEffect;
823                 options = options || {};
824                 if ( typeof options === "number" ) {
825                         options = { duration: options };
826                 }
827                 hasOptions = !$.isEmptyObject( options );
828                 options.complete = callback;
829                 if ( options.delay ) {
830                         element.delay( options.delay );
831                 }
832                 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
833                         element[ method ]( options );
834                 } else if ( effectName !== method && element[ effectName ] ) {
835                         element[ effectName ]( options.duration, options.easing, callback );
836                 } else {
837                         element.queue(function( next ) {
838                                 $( this )[ method ]();
839                                 if ( callback ) {
840                                         callback.call( element[ 0 ] );
841                                 }
842                                 next();
843                         });
844                 }
845         };
846 });
848 var widget = $.widget;
851 /*!
852  * jQuery UI Mouse 1.11.1
853  * http://jqueryui.com
854  *
855  * Copyright 2014 jQuery Foundation and other contributors
856  * Released under the MIT license.
857  * http://jquery.org/license
858  *
859  * http://api.jqueryui.com/mouse/
860  */
863 var mouseHandled = false;
864 $( document ).mouseup( function() {
865         mouseHandled = false;
866 });
868 var mouse = $.widget("ui.mouse", {
869         version: "1.11.1",
870         options: {
871                 cancel: "input,textarea,button,select,option",
872                 distance: 1,
873                 delay: 0
874         },
875         _mouseInit: function() {
876                 var that = this;
878                 this.element
879                         .bind("mousedown." + this.widgetName, function(event) {
880                                 return that._mouseDown(event);
881                         })
882                         .bind("click." + this.widgetName, function(event) {
883                                 if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
884                                         $.removeData(event.target, that.widgetName + ".preventClickEvent");
885                                         event.stopImmediatePropagation();
886                                         return false;
887                                 }
888                         });
890                 this.started = false;
891         },
893         // TODO: make sure destroying one instance of mouse doesn't mess with
894         // other instances of mouse
895         _mouseDestroy: function() {
896                 this.element.unbind("." + this.widgetName);
897                 if ( this._mouseMoveDelegate ) {
898                         this.document
899                                 .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
900                                 .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
901                 }
902         },
904         _mouseDown: function(event) {
905                 // don't let more than one widget handle mouseStart
906                 if ( mouseHandled ) {
907                         return;
908                 }
910                 // we may have missed mouseup (out of window)
911                 (this._mouseStarted && this._mouseUp(event));
913                 this._mouseDownEvent = event;
915                 var that = this,
916                         btnIsLeft = (event.which === 1),
917                         // event.target.nodeName works around a bug in IE 8 with
918                         // disabled inputs (#7620)
919                         elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
920                 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
921                         return true;
922                 }
924                 this.mouseDelayMet = !this.options.delay;
925                 if (!this.mouseDelayMet) {
926                         this._mouseDelayTimer = setTimeout(function() {
927                                 that.mouseDelayMet = true;
928                         }, this.options.delay);
929                 }
931                 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
932                         this._mouseStarted = (this._mouseStart(event) !== false);
933                         if (!this._mouseStarted) {
934                                 event.preventDefault();
935                                 return true;
936                         }
937                 }
939                 // Click event may never have fired (Gecko & Opera)
940                 if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
941                         $.removeData(event.target, this.widgetName + ".preventClickEvent");
942                 }
944                 // these delegates are required to keep context
945                 this._mouseMoveDelegate = function(event) {
946                         return that._mouseMove(event);
947                 };
948                 this._mouseUpDelegate = function(event) {
949                         return that._mouseUp(event);
950                 };
952                 this.document
953                         .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
954                         .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
956                 event.preventDefault();
958                 mouseHandled = true;
959                 return true;
960         },
962         _mouseMove: function(event) {
963                 // IE mouseup check - mouseup happened when mouse was out of window
964                 if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
965                         return this._mouseUp(event);
967                 // Iframe mouseup check - mouseup occurred in another document
968                 } else if ( !event.which ) {
969                         return this._mouseUp( event );
970                 }
972                 if (this._mouseStarted) {
973                         this._mouseDrag(event);
974                         return event.preventDefault();
975                 }
977                 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
978                         this._mouseStarted =
979                                 (this._mouseStart(this._mouseDownEvent, event) !== false);
980                         (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
981                 }
983                 return !this._mouseStarted;
984         },
986         _mouseUp: function(event) {
987                 this.document
988                         .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
989                         .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
991                 if (this._mouseStarted) {
992                         this._mouseStarted = false;
994                         if (event.target === this._mouseDownEvent.target) {
995                                 $.data(event.target, this.widgetName + ".preventClickEvent", true);
996                         }
998                         this._mouseStop(event);
999                 }
1001                 mouseHandled = false;
1002                 return false;
1003         },
1005         _mouseDistanceMet: function(event) {
1006                 return (Math.max(
1007                                 Math.abs(this._mouseDownEvent.pageX - event.pageX),
1008                                 Math.abs(this._mouseDownEvent.pageY - event.pageY)
1009                         ) >= this.options.distance
1010                 );
1011         },
1013         _mouseDelayMet: function(/* event */) {
1014                 return this.mouseDelayMet;
1015         },
1017         // These are placeholder methods, to be overriden by extending plugin
1018         _mouseStart: function(/* event */) {},
1019         _mouseDrag: function(/* event */) {},
1020         _mouseStop: function(/* event */) {},
1021         _mouseCapture: function(/* event */) { return true; }
1022 });
1025 /*!
1026  * jQuery UI Position 1.11.1
1027  * http://jqueryui.com
1028  *
1029  * Copyright 2014 jQuery Foundation and other contributors
1030  * Released under the MIT license.
1031  * http://jquery.org/license
1032  *
1033  * http://api.jqueryui.com/position/
1034  */
1036 (function() {
1038 $.ui = $.ui || {};
1040 var cachedScrollbarWidth, supportsOffsetFractions,
1041         max = Math.max,
1042         abs = Math.abs,
1043         round = Math.round,
1044         rhorizontal = /left|center|right/,
1045         rvertical = /top|center|bottom/,
1046         roffset = /[\+\-]\d+(\.[\d]+)?%?/,
1047         rposition = /^\w+/,
1048         rpercent = /%$/,
1049         _position = $.fn.position;
1051 function getOffsets( offsets, width, height ) {
1052         return [
1053                 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
1054                 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
1055         ];
1058 function parseCss( element, property ) {
1059         return parseInt( $.css( element, property ), 10 ) || 0;
1062 function getDimensions( elem ) {
1063         var raw = elem[0];
1064         if ( raw.nodeType === 9 ) {
1065                 return {
1066                         width: elem.width(),
1067                         height: elem.height(),
1068                         offset: { top: 0, left: 0 }
1069                 };
1070         }
1071         if ( $.isWindow( raw ) ) {
1072                 return {
1073                         width: elem.width(),
1074                         height: elem.height(),
1075                         offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
1076                 };
1077         }
1078         if ( raw.preventDefault ) {
1079                 return {
1080                         width: 0,
1081                         height: 0,
1082                         offset: { top: raw.pageY, left: raw.pageX }
1083                 };
1084         }
1085         return {
1086                 width: elem.outerWidth(),
1087                 height: elem.outerHeight(),
1088                 offset: elem.offset()
1089         };
1092 $.position = {
1093         scrollbarWidth: function() {
1094                 if ( cachedScrollbarWidth !== undefined ) {
1095                         return cachedScrollbarWidth;
1096                 }
1097                 var w1, w2,
1098                         div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
1099                         innerDiv = div.children()[0];
1101                 $( "body" ).append( div );
1102                 w1 = innerDiv.offsetWidth;
1103                 div.css( "overflow", "scroll" );
1105                 w2 = innerDiv.offsetWidth;
1107                 if ( w1 === w2 ) {
1108                         w2 = div[0].clientWidth;
1109                 }
1111                 div.remove();
1113                 return (cachedScrollbarWidth = w1 - w2);
1114         },
1115         getScrollInfo: function( within ) {
1116                 var overflowX = within.isWindow || within.isDocument ? "" :
1117                                 within.element.css( "overflow-x" ),
1118                         overflowY = within.isWindow || within.isDocument ? "" :
1119                                 within.element.css( "overflow-y" ),
1120                         hasOverflowX = overflowX === "scroll" ||
1121                                 ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
1122                         hasOverflowY = overflowY === "scroll" ||
1123                                 ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
1124                 return {
1125                         width: hasOverflowY ? $.position.scrollbarWidth() : 0,
1126                         height: hasOverflowX ? $.position.scrollbarWidth() : 0
1127                 };
1128         },
1129         getWithinInfo: function( element ) {
1130                 var withinElement = $( element || window ),
1131                         isWindow = $.isWindow( withinElement[0] ),
1132                         isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
1133                 return {
1134                         element: withinElement,
1135                         isWindow: isWindow,
1136                         isDocument: isDocument,
1137                         offset: withinElement.offset() || { left: 0, top: 0 },
1138                         scrollLeft: withinElement.scrollLeft(),
1139                         scrollTop: withinElement.scrollTop(),
1141                         // support: jQuery 1.6.x
1142                         // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
1143                         width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
1144                         height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
1145                 };
1146         }
1147 };
1149 $.fn.position = function( options ) {
1150         if ( !options || !options.of ) {
1151                 return _position.apply( this, arguments );
1152         }
1154         // make a copy, we don't want to modify arguments
1155         options = $.extend( {}, options );
1157         var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
1158                 target = $( options.of ),
1159                 within = $.position.getWithinInfo( options.within ),
1160                 scrollInfo = $.position.getScrollInfo( within ),
1161                 collision = ( options.collision || "flip" ).split( " " ),
1162                 offsets = {};
1164         dimensions = getDimensions( target );
1165         if ( target[0].preventDefault ) {
1166                 // force left top to allow flipping
1167                 options.at = "left top";
1168         }
1169         targetWidth = dimensions.width;
1170         targetHeight = dimensions.height;
1171         targetOffset = dimensions.offset;
1172         // clone to reuse original targetOffset later
1173         basePosition = $.extend( {}, targetOffset );
1175         // force my and at to have valid horizontal and vertical positions
1176         // if a value is missing or invalid, it will be converted to center
1177         $.each( [ "my", "at" ], function() {
1178                 var pos = ( options[ this ] || "" ).split( " " ),
1179                         horizontalOffset,
1180                         verticalOffset;
1182                 if ( pos.length === 1) {
1183                         pos = rhorizontal.test( pos[ 0 ] ) ?
1184                                 pos.concat( [ "center" ] ) :
1185                                 rvertical.test( pos[ 0 ] ) ?
1186                                         [ "center" ].concat( pos ) :
1187                                         [ "center", "center" ];
1188                 }
1189                 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
1190                 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
1192                 // calculate offsets
1193                 horizontalOffset = roffset.exec( pos[ 0 ] );
1194                 verticalOffset = roffset.exec( pos[ 1 ] );
1195                 offsets[ this ] = [
1196                         horizontalOffset ? horizontalOffset[ 0 ] : 0,
1197                         verticalOffset ? verticalOffset[ 0 ] : 0
1198                 ];
1200                 // reduce to just the positions without the offsets
1201                 options[ this ] = [
1202                         rposition.exec( pos[ 0 ] )[ 0 ],
1203                         rposition.exec( pos[ 1 ] )[ 0 ]
1204                 ];
1205         });
1207         // normalize collision option
1208         if ( collision.length === 1 ) {
1209                 collision[ 1 ] = collision[ 0 ];
1210         }
1212         if ( options.at[ 0 ] === "right" ) {
1213                 basePosition.left += targetWidth;
1214         } else if ( options.at[ 0 ] === "center" ) {
1215                 basePosition.left += targetWidth / 2;
1216         }
1218         if ( options.at[ 1 ] === "bottom" ) {
1219                 basePosition.top += targetHeight;
1220         } else if ( options.at[ 1 ] === "center" ) {
1221                 basePosition.top += targetHeight / 2;
1222         }
1224         atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
1225         basePosition.left += atOffset[ 0 ];
1226         basePosition.top += atOffset[ 1 ];
1228         return this.each(function() {
1229                 var collisionPosition, using,
1230                         elem = $( this ),
1231                         elemWidth = elem.outerWidth(),
1232                         elemHeight = elem.outerHeight(),
1233                         marginLeft = parseCss( this, "marginLeft" ),
1234                         marginTop = parseCss( this, "marginTop" ),
1235                         collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
1236                         collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
1237                         position = $.extend( {}, basePosition ),
1238                         myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
1240                 if ( options.my[ 0 ] === "right" ) {
1241                         position.left -= elemWidth;
1242                 } else if ( options.my[ 0 ] === "center" ) {
1243                         position.left -= elemWidth / 2;
1244                 }
1246                 if ( options.my[ 1 ] === "bottom" ) {
1247                         position.top -= elemHeight;
1248                 } else if ( options.my[ 1 ] === "center" ) {
1249                         position.top -= elemHeight / 2;
1250                 }
1252                 position.left += myOffset[ 0 ];
1253                 position.top += myOffset[ 1 ];
1255                 // if the browser doesn't support fractions, then round for consistent results
1256                 if ( !supportsOffsetFractions ) {
1257                         position.left = round( position.left );
1258                         position.top = round( position.top );
1259                 }
1261                 collisionPosition = {
1262                         marginLeft: marginLeft,
1263                         marginTop: marginTop
1264                 };
1266                 $.each( [ "left", "top" ], function( i, dir ) {
1267                         if ( $.ui.position[ collision[ i ] ] ) {
1268                                 $.ui.position[ collision[ i ] ][ dir ]( position, {
1269                                         targetWidth: targetWidth,
1270                                         targetHeight: targetHeight,
1271                                         elemWidth: elemWidth,
1272                                         elemHeight: elemHeight,
1273                                         collisionPosition: collisionPosition,
1274                                         collisionWidth: collisionWidth,
1275                                         collisionHeight: collisionHeight,
1276                                         offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
1277                                         my: options.my,
1278                                         at: options.at,
1279                                         within: within,
1280                                         elem: elem
1281                                 });
1282                         }
1283                 });
1285                 if ( options.using ) {
1286                         // adds feedback as second argument to using callback, if present
1287                         using = function( props ) {
1288                                 var left = targetOffset.left - position.left,
1289                                         right = left + targetWidth - elemWidth,
1290                                         top = targetOffset.top - position.top,
1291                                         bottom = top + targetHeight - elemHeight,
1292                                         feedback = {
1293                                                 target: {
1294                                                         element: target,
1295                                                         left: targetOffset.left,
1296                                                         top: targetOffset.top,
1297                                                         width: targetWidth,
1298                                                         height: targetHeight
1299                                                 },
1300                                                 element: {
1301                                                         element: elem,
1302                                                         left: position.left,
1303                                                         top: position.top,
1304                                                         width: elemWidth,
1305                                                         height: elemHeight
1306                                                 },
1307                                                 horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
1308                                                 vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
1309                                         };
1310                                 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
1311                                         feedback.horizontal = "center";
1312                                 }
1313                                 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
1314                                         feedback.vertical = "middle";
1315                                 }
1316                                 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
1317                                         feedback.important = "horizontal";
1318                                 } else {
1319                                         feedback.important = "vertical";
1320                                 }
1321                                 options.using.call( this, props, feedback );
1322                         };
1323                 }
1325                 elem.offset( $.extend( position, { using: using } ) );
1326         });
1327 };
1329 $.ui.position = {
1330         fit: {
1331                 left: function( position, data ) {
1332                         var within = data.within,
1333                                 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
1334                                 outerWidth = within.width,
1335                                 collisionPosLeft = position.left - data.collisionPosition.marginLeft,
1336                                 overLeft = withinOffset - collisionPosLeft,
1337                                 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
1338                                 newOverRight;
1340                         // element is wider than within
1341                         if ( data.collisionWidth > outerWidth ) {
1342                                 // element is initially over the left side of within
1343                                 if ( overLeft > 0 && overRight <= 0 ) {
1344                                         newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
1345                                         position.left += overLeft - newOverRight;
1346                                 // element is initially over right side of within
1347                                 } else if ( overRight > 0 && overLeft <= 0 ) {
1348                                         position.left = withinOffset;
1349                                 // element is initially over both left and right sides of within
1350                                 } else {
1351                                         if ( overLeft > overRight ) {
1352                                                 position.left = withinOffset + outerWidth - data.collisionWidth;
1353                                         } else {
1354                                                 position.left = withinOffset;
1355                                         }
1356                                 }
1357                         // too far left -> align with left edge
1358                         } else if ( overLeft > 0 ) {
1359                                 position.left += overLeft;
1360                         // too far right -> align with right edge
1361                         } else if ( overRight > 0 ) {
1362                                 position.left -= overRight;
1363                         // adjust based on position and margin
1364                         } else {
1365                                 position.left = max( position.left - collisionPosLeft, position.left );
1366                         }
1367                 },
1368                 top: function( position, data ) {
1369                         var within = data.within,
1370                                 withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
1371                                 outerHeight = data.within.height,
1372                                 collisionPosTop = position.top - data.collisionPosition.marginTop,
1373                                 overTop = withinOffset - collisionPosTop,
1374                                 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
1375                                 newOverBottom;
1377                         // element is taller than within
1378                         if ( data.collisionHeight > outerHeight ) {
1379                                 // element is initially over the top of within
1380                                 if ( overTop > 0 && overBottom <= 0 ) {
1381                                         newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
1382                                         position.top += overTop - newOverBottom;
1383                                 // element is initially over bottom of within
1384                                 } else if ( overBottom > 0 && overTop <= 0 ) {
1385                                         position.top = withinOffset;
1386                                 // element is initially over both top and bottom of within
1387                                 } else {
1388                                         if ( overTop > overBottom ) {
1389                                                 position.top = withinOffset + outerHeight - data.collisionHeight;
1390                                         } else {
1391                                                 position.top = withinOffset;
1392                                         }
1393                                 }
1394                         // too far up -> align with top
1395                         } else if ( overTop > 0 ) {
1396                                 position.top += overTop;
1397                         // too far down -> align with bottom edge
1398                         } else if ( overBottom > 0 ) {
1399                                 position.top -= overBottom;
1400                         // adjust based on position and margin
1401                         } else {
1402                                 position.top = max( position.top - collisionPosTop, position.top );
1403                         }
1404                 }
1405         },
1406         flip: {
1407                 left: function( position, data ) {
1408                         var within = data.within,
1409                                 withinOffset = within.offset.left + within.scrollLeft,
1410                                 outerWidth = within.width,
1411                                 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
1412                                 collisionPosLeft = position.left - data.collisionPosition.marginLeft,
1413                                 overLeft = collisionPosLeft - offsetLeft,
1414                                 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
1415                                 myOffset = data.my[ 0 ] === "left" ?
1416                                         -data.elemWidth :
1417                                         data.my[ 0 ] === "right" ?
1418                                                 data.elemWidth :
1419                                                 0,
1420                                 atOffset = data.at[ 0 ] === "left" ?
1421                                         data.targetWidth :
1422                                         data.at[ 0 ] === "right" ?
1423                                                 -data.targetWidth :
1424                                                 0,
1425                                 offset = -2 * data.offset[ 0 ],
1426                                 newOverRight,
1427                                 newOverLeft;
1429                         if ( overLeft < 0 ) {
1430                                 newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
1431                                 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
1432                                         position.left += myOffset + atOffset + offset;
1433                                 }
1434                         } else if ( overRight > 0 ) {
1435                                 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
1436                                 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
1437                                         position.left += myOffset + atOffset + offset;
1438                                 }
1439                         }
1440                 },
1441                 top: function( position, data ) {
1442                         var within = data.within,
1443                                 withinOffset = within.offset.top + within.scrollTop,
1444                                 outerHeight = within.height,
1445                                 offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
1446                                 collisionPosTop = position.top - data.collisionPosition.marginTop,
1447                                 overTop = collisionPosTop - offsetTop,
1448                                 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
1449                                 top = data.my[ 1 ] === "top",
1450                                 myOffset = top ?
1451                                         -data.elemHeight :
1452                                         data.my[ 1 ] === "bottom" ?
1453                                                 data.elemHeight :
1454                                                 0,
1455                                 atOffset = data.at[ 1 ] === "top" ?
1456                                         data.targetHeight :
1457                                         data.at[ 1 ] === "bottom" ?
1458                                                 -data.targetHeight :
1459                                                 0,
1460                                 offset = -2 * data.offset[ 1 ],
1461                                 newOverTop,
1462                                 newOverBottom;
1463                         if ( overTop < 0 ) {
1464                                 newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
1465                                 if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
1466                                         position.top += myOffset + atOffset + offset;
1467                                 }
1468                         } else if ( overBottom > 0 ) {
1469                                 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
1470                                 if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
1471                                         position.top += myOffset + atOffset + offset;
1472                                 }
1473                         }
1474                 }
1475         },
1476         flipfit: {
1477                 left: function() {
1478                         $.ui.position.flip.left.apply( this, arguments );
1479                         $.ui.position.fit.left.apply( this, arguments );
1480                 },
1481                 top: function() {
1482                         $.ui.position.flip.top.apply( this, arguments );
1483                         $.ui.position.fit.top.apply( this, arguments );
1484                 }
1485         }
1486 };
1488 // fraction support test
1489 (function() {
1490         var testElement, testElementParent, testElementStyle, offsetLeft, i,
1491                 body = document.getElementsByTagName( "body" )[ 0 ],
1492                 div = document.createElement( "div" );
1494         //Create a "fake body" for testing based on method used in jQuery.support
1495         testElement = document.createElement( body ? "div" : "body" );
1496         testElementStyle = {
1497                 visibility: "hidden",
1498                 width: 0,
1499                 height: 0,
1500                 border: 0,
1501                 margin: 0,
1502                 background: "none"
1503         };
1504         if ( body ) {
1505                 $.extend( testElementStyle, {
1506                         position: "absolute",
1507                         left: "-1000px",
1508                         top: "-1000px"
1509                 });
1510         }
1511         for ( i in testElementStyle ) {
1512                 testElement.style[ i ] = testElementStyle[ i ];
1513         }
1514         testElement.appendChild( div );
1515         testElementParent = body || document.documentElement;
1516         testElementParent.insertBefore( testElement, testElementParent.firstChild );
1518         div.style.cssText = "position: absolute; left: 10.7432222px;";
1520         offsetLeft = $( div ).offset().left;
1521         supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
1523         testElement.innerHTML = "";
1524         testElementParent.removeChild( testElement );
1525 })();
1527 })();
1529 var position = $.ui.position;
1532 /*!
1533  * jQuery UI Accordion 1.11.1
1534  * http://jqueryui.com
1535  *
1536  * Copyright 2014 jQuery Foundation and other contributors
1537  * Released under the MIT license.
1538  * http://jquery.org/license
1539  *
1540  * http://api.jqueryui.com/accordion/
1541  */
1544 var accordion = $.widget( "ui.accordion", {
1545         version: "1.11.1",
1546         options: {
1547                 active: 0,
1548                 animate: {},
1549                 collapsible: false,
1550                 event: "click",
1551                 header: "> li > :first-child,> :not(li):even",
1552                 heightStyle: "auto",
1553                 icons: {
1554                         activeHeader: "ui-icon-triangle-1-s",
1555                         header: "ui-icon-triangle-1-e"
1556                 },
1558                 // callbacks
1559                 activate: null,
1560                 beforeActivate: null
1561         },
1563         hideProps: {
1564                 borderTopWidth: "hide",
1565                 borderBottomWidth: "hide",
1566                 paddingTop: "hide",
1567                 paddingBottom: "hide",
1568                 height: "hide"
1569         },
1571         showProps: {
1572                 borderTopWidth: "show",
1573                 borderBottomWidth: "show",
1574                 paddingTop: "show",
1575                 paddingBottom: "show",
1576                 height: "show"
1577         },
1579         _create: function() {
1580                 var options = this.options;
1581                 this.prevShow = this.prevHide = $();
1582                 this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
1583                         // ARIA
1584                         .attr( "role", "tablist" );
1586                 // don't allow collapsible: false and active: false / null
1587                 if ( !options.collapsible && (options.active === false || options.active == null) ) {
1588                         options.active = 0;
1589                 }
1591                 this._processPanels();
1592                 // handle negative values
1593                 if ( options.active < 0 ) {
1594                         options.active += this.headers.length;
1595                 }
1596                 this._refresh();
1597         },
1599         _getCreateEventData: function() {
1600                 return {
1601                         header: this.active,
1602                         panel: !this.active.length ? $() : this.active.next()
1603                 };
1604         },
1606         _createIcons: function() {
1607                 var icons = this.options.icons;
1608                 if ( icons ) {
1609                         $( "<span>" )
1610                                 .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
1611                                 .prependTo( this.headers );
1612                         this.active.children( ".ui-accordion-header-icon" )
1613                                 .removeClass( icons.header )
1614                                 .addClass( icons.activeHeader );
1615                         this.headers.addClass( "ui-accordion-icons" );
1616                 }
1617         },
1619         _destroyIcons: function() {
1620                 this.headers
1621                         .removeClass( "ui-accordion-icons" )
1622                         .children( ".ui-accordion-header-icon" )
1623                                 .remove();
1624         },
1626         _destroy: function() {
1627                 var contents;
1629                 // clean up main element
1630                 this.element
1631                         .removeClass( "ui-accordion ui-widget ui-helper-reset" )
1632                         .removeAttr( "role" );
1634                 // clean up headers
1635                 this.headers
1636                         .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
1637                                 "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
1638                         .removeAttr( "role" )
1639                         .removeAttr( "aria-expanded" )
1640                         .removeAttr( "aria-selected" )
1641                         .removeAttr( "aria-controls" )
1642                         .removeAttr( "tabIndex" )
1643                         .removeUniqueId();
1645                 this._destroyIcons();
1647                 // clean up content panels
1648                 contents = this.headers.next()
1649                         .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
1650                                 "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
1651                         .css( "display", "" )
1652                         .removeAttr( "role" )
1653                         .removeAttr( "aria-hidden" )
1654                         .removeAttr( "aria-labelledby" )
1655                         .removeUniqueId();
1657                 if ( this.options.heightStyle !== "content" ) {
1658                         contents.css( "height", "" );
1659                 }
1660         },
1662         _setOption: function( key, value ) {
1663                 if ( key === "active" ) {
1664                         // _activate() will handle invalid values and update this.options
1665                         this._activate( value );
1666                         return;
1667                 }
1669                 if ( key === "event" ) {
1670                         if ( this.options.event ) {
1671                                 this._off( this.headers, this.options.event );
1672                         }
1673                         this._setupEvents( value );
1674                 }
1676                 this._super( key, value );
1678                 // setting collapsible: false while collapsed; open first panel
1679                 if ( key === "collapsible" && !value && this.options.active === false ) {
1680                         this._activate( 0 );
1681                 }
1683                 if ( key === "icons" ) {
1684                         this._destroyIcons();
1685                         if ( value ) {
1686                                 this._createIcons();
1687                         }
1688                 }
1690                 // #5332 - opacity doesn't cascade to positioned elements in IE
1691                 // so we need to add the disabled class to the headers and panels
1692                 if ( key === "disabled" ) {
1693                         this.element
1694                                 .toggleClass( "ui-state-disabled", !!value )
1695                                 .attr( "aria-disabled", value );
1696                         this.headers.add( this.headers.next() )
1697                                 .toggleClass( "ui-state-disabled", !!value );
1698                 }
1699         },
1701         _keydown: function( event ) {
1702                 if ( event.altKey || event.ctrlKey ) {
1703                         return;
1704                 }
1706                 var keyCode = $.ui.keyCode,
1707                         length = this.headers.length,
1708                         currentIndex = this.headers.index( event.target ),
1709                         toFocus = false;
1711                 switch ( event.keyCode ) {
1712                         case keyCode.RIGHT:
1713                         case keyCode.DOWN:
1714                                 toFocus = this.headers[ ( currentIndex + 1 ) % length ];
1715                                 break;
1716                         case keyCode.LEFT:
1717                         case keyCode.UP:
1718                                 toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
1719                                 break;
1720                         case keyCode.SPACE:
1721                         case keyCode.ENTER:
1722                                 this._eventHandler( event );
1723                                 break;
1724                         case keyCode.HOME:
1725                                 toFocus = this.headers[ 0 ];
1726                                 break;
1727                         case keyCode.END:
1728                                 toFocus = this.headers[ length - 1 ];
1729                                 break;
1730                 }
1732                 if ( toFocus ) {
1733                         $( event.target ).attr( "tabIndex", -1 );
1734                         $( toFocus ).attr( "tabIndex", 0 );
1735                         toFocus.focus();
1736                         event.preventDefault();
1737                 }
1738         },
1740         _panelKeyDown: function( event ) {
1741                 if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
1742                         $( event.currentTarget ).prev().focus();
1743                 }
1744         },
1746         refresh: function() {
1747                 var options = this.options;
1748                 this._processPanels();
1750                 // was collapsed or no panel
1751                 if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
1752                         options.active = false;
1753                         this.active = $();
1754                 // active false only when collapsible is true
1755                 } else if ( options.active === false ) {
1756                         this._activate( 0 );
1757                 // was active, but active panel is gone
1758                 } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
1759                         // all remaining panel are disabled
1760                         if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
1761                                 options.active = false;
1762                                 this.active = $();
1763                         // activate previous panel
1764                         } else {
1765                                 this._activate( Math.max( 0, options.active - 1 ) );
1766                         }
1767                 // was active, active panel still exists
1768                 } else {
1769                         // make sure active index is correct
1770                         options.active = this.headers.index( this.active );
1771                 }
1773                 this._destroyIcons();
1775                 this._refresh();
1776         },
1778         _processPanels: function() {
1779                 this.headers = this.element.find( this.options.header )
1780                         .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
1782                 this.headers.next()
1783                         .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
1784                         .filter( ":not(.ui-accordion-content-active)" )
1785                         .hide();
1786         },
1788         _refresh: function() {
1789                 var maxHeight,
1790                         options = this.options,
1791                         heightStyle = options.heightStyle,
1792                         parent = this.element.parent();
1794                 this.active = this._findActive( options.active )
1795                         .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
1796                         .removeClass( "ui-corner-all" );
1797                 this.active.next()
1798                         .addClass( "ui-accordion-content-active" )
1799                         .show();
1801                 this.headers
1802                         .attr( "role", "tab" )
1803                         .each(function() {
1804                                 var header = $( this ),
1805                                         headerId = header.uniqueId().attr( "id" ),
1806                                         panel = header.next(),
1807                                         panelId = panel.uniqueId().attr( "id" );
1808                                 header.attr( "aria-controls", panelId );
1809                                 panel.attr( "aria-labelledby", headerId );
1810                         })
1811                         .next()
1812                                 .attr( "role", "tabpanel" );
1814                 this.headers
1815                         .not( this.active )
1816                         .attr({
1817                                 "aria-selected": "false",
1818                                 "aria-expanded": "false",
1819                                 tabIndex: -1
1820                         })
1821                         .next()
1822                                 .attr({
1823                                         "aria-hidden": "true"
1824                                 })
1825                                 .hide();
1827                 // make sure at least one header is in the tab order
1828                 if ( !this.active.length ) {
1829                         this.headers.eq( 0 ).attr( "tabIndex", 0 );
1830                 } else {
1831                         this.active.attr({
1832                                 "aria-selected": "true",
1833                                 "aria-expanded": "true",
1834                                 tabIndex: 0
1835                         })
1836                         .next()
1837                                 .attr({
1838                                         "aria-hidden": "false"
1839                                 });
1840                 }
1842                 this._createIcons();
1844                 this._setupEvents( options.event );
1846                 if ( heightStyle === "fill" ) {
1847                         maxHeight = parent.height();
1848                         this.element.siblings( ":visible" ).each(function() {
1849                                 var elem = $( this ),
1850                                         position = elem.css( "position" );
1852                                 if ( position === "absolute" || position === "fixed" ) {
1853                                         return;
1854                                 }
1855                                 maxHeight -= elem.outerHeight( true );
1856                         });
1858                         this.headers.each(function() {
1859                                 maxHeight -= $( this ).outerHeight( true );
1860                         });
1862                         this.headers.next()
1863                                 .each(function() {
1864                                         $( this ).height( Math.max( 0, maxHeight -
1865                                                 $( this ).innerHeight() + $( this ).height() ) );
1866                                 })
1867                                 .css( "overflow", "auto" );
1868                 } else if ( heightStyle === "auto" ) {
1869                         maxHeight = 0;
1870                         this.headers.next()
1871                                 .each(function() {
1872                                         maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
1873                                 })
1874                                 .height( maxHeight );
1875                 }
1876         },
1878         _activate: function( index ) {
1879                 var active = this._findActive( index )[ 0 ];
1881                 // trying to activate the already active panel
1882                 if ( active === this.active[ 0 ] ) {
1883                         return;
1884                 }
1886                 // trying to collapse, simulate a click on the currently active header
1887                 active = active || this.active[ 0 ];
1889                 this._eventHandler({
1890                         target: active,
1891                         currentTarget: active,
1892                         preventDefault: $.noop
1893                 });
1894         },
1896         _findActive: function( selector ) {
1897                 return typeof selector === "number" ? this.headers.eq( selector ) : $();
1898         },
1900         _setupEvents: function( event ) {
1901                 var events = {
1902                         keydown: "_keydown"
1903                 };
1904                 if ( event ) {
1905                         $.each( event.split( " " ), function( index, eventName ) {
1906                                 events[ eventName ] = "_eventHandler";
1907                         });
1908                 }
1910                 this._off( this.headers.add( this.headers.next() ) );
1911                 this._on( this.headers, events );
1912                 this._on( this.headers.next(), { keydown: "_panelKeyDown" });
1913                 this._hoverable( this.headers );
1914                 this._focusable( this.headers );
1915         },
1917         _eventHandler: function( event ) {
1918                 var options = this.options,
1919                         active = this.active,
1920                         clicked = $( event.currentTarget ),
1921                         clickedIsActive = clicked[ 0 ] === active[ 0 ],
1922                         collapsing = clickedIsActive && options.collapsible,
1923                         toShow = collapsing ? $() : clicked.next(),
1924                         toHide = active.next(),
1925                         eventData = {
1926                                 oldHeader: active,
1927                                 oldPanel: toHide,
1928                                 newHeader: collapsing ? $() : clicked,
1929                                 newPanel: toShow
1930                         };
1932                 event.preventDefault();
1934                 if (
1935                                 // click on active header, but not collapsible
1936                                 ( clickedIsActive && !options.collapsible ) ||
1937                                 // allow canceling activation
1938                                 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
1939                         return;
1940                 }
1942                 options.active = collapsing ? false : this.headers.index( clicked );
1944                 // when the call to ._toggle() comes after the class changes
1945                 // it causes a very odd bug in IE 8 (see #6720)
1946                 this.active = clickedIsActive ? $() : clicked;
1947                 this._toggle( eventData );
1949                 // switch classes
1950                 // corner classes on the previously active header stay after the animation
1951                 active.removeClass( "ui-accordion-header-active ui-state-active" );
1952                 if ( options.icons ) {
1953                         active.children( ".ui-accordion-header-icon" )
1954                                 .removeClass( options.icons.activeHeader )
1955                                 .addClass( options.icons.header );
1956                 }
1958                 if ( !clickedIsActive ) {
1959                         clicked
1960                                 .removeClass( "ui-corner-all" )
1961                                 .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
1962                         if ( options.icons ) {
1963                                 clicked.children( ".ui-accordion-header-icon" )
1964                                         .removeClass( options.icons.header )
1965                                         .addClass( options.icons.activeHeader );
1966                         }
1968                         clicked
1969                                 .next()
1970                                 .addClass( "ui-accordion-content-active" );
1971                 }
1972         },
1974         _toggle: function( data ) {
1975                 var toShow = data.newPanel,
1976                         toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
1978                 // handle activating a panel during the animation for another activation
1979                 this.prevShow.add( this.prevHide ).stop( true, true );
1980                 this.prevShow = toShow;
1981                 this.prevHide = toHide;
1983                 if ( this.options.animate ) {
1984                         this._animate( toShow, toHide, data );
1985                 } else {
1986                         toHide.hide();
1987                         toShow.show();
1988                         this._toggleComplete( data );
1989                 }
1991                 toHide.attr({
1992                         "aria-hidden": "true"
1993                 });
1994                 toHide.prev().attr( "aria-selected", "false" );
1995                 // if we're switching panels, remove the old header from the tab order
1996                 // if we're opening from collapsed state, remove the previous header from the tab order
1997                 // if we're collapsing, then keep the collapsing header in the tab order
1998                 if ( toShow.length && toHide.length ) {
1999                         toHide.prev().attr({
2000                                 "tabIndex": -1,
2001                                 "aria-expanded": "false"
2002                         });
2003                 } else if ( toShow.length ) {
2004                         this.headers.filter(function() {
2005                                 return $( this ).attr( "tabIndex" ) === 0;
2006                         })
2007                         .attr( "tabIndex", -1 );
2008                 }
2010                 toShow
2011                         .attr( "aria-hidden", "false" )
2012                         .prev()
2013                                 .attr({
2014                                         "aria-selected": "true",
2015                                         tabIndex: 0,
2016                                         "aria-expanded": "true"
2017                                 });
2018         },
2020         _animate: function( toShow, toHide, data ) {
2021                 var total, easing, duration,
2022                         that = this,
2023                         adjust = 0,
2024                         down = toShow.length &&
2025                                 ( !toHide.length || ( toShow.index() < toHide.index() ) ),
2026                         animate = this.options.animate || {},
2027                         options = down && animate.down || animate,
2028                         complete = function() {
2029                                 that._toggleComplete( data );
2030                         };
2032                 if ( typeof options === "number" ) {
2033                         duration = options;
2034                 }
2035                 if ( typeof options === "string" ) {
2036                         easing = options;
2037                 }
2038                 // fall back from options to animation in case of partial down settings
2039                 easing = easing || options.easing || animate.easing;
2040                 duration = duration || options.duration || animate.duration;
2042                 if ( !toHide.length ) {
2043                         return toShow.animate( this.showProps, duration, easing, complete );
2044                 }
2045                 if ( !toShow.length ) {
2046                         return toHide.animate( this.hideProps, duration, easing, complete );
2047                 }
2049                 total = toShow.show().outerHeight();
2050                 toHide.animate( this.hideProps, {
2051                         duration: duration,
2052                         easing: easing,
2053                         step: function( now, fx ) {
2054                                 fx.now = Math.round( now );
2055                         }
2056                 });
2057                 toShow
2058                         .hide()
2059                         .animate( this.showProps, {
2060                                 duration: duration,
2061                                 easing: easing,
2062                                 complete: complete,
2063                                 step: function( now, fx ) {
2064                                         fx.now = Math.round( now );
2065                                         if ( fx.prop !== "height" ) {
2066                                                 adjust += fx.now;
2067                                         } else if ( that.options.heightStyle !== "content" ) {
2068                                                 fx.now = Math.round( total - toHide.outerHeight() - adjust );
2069                                                 adjust = 0;
2070                                         }
2071                                 }
2072                         });
2073         },
2075         _toggleComplete: function( data ) {
2076                 var toHide = data.oldPanel;
2078                 toHide
2079                         .removeClass( "ui-accordion-content-active" )
2080                         .prev()
2081                                 .removeClass( "ui-corner-top" )
2082                                 .addClass( "ui-corner-all" );
2084                 // Work around for rendering bug in IE (#5421)
2085                 if ( toHide.length ) {
2086                         toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
2087                 }
2088                 this._trigger( "activate", null, data );
2089         }
2090 });
2093 /*!
2094  * jQuery UI Menu 1.11.1
2095  * http://jqueryui.com
2096  *
2097  * Copyright 2014 jQuery Foundation and other contributors
2098  * Released under the MIT license.
2099  * http://jquery.org/license
2100  *
2101  * http://api.jqueryui.com/menu/
2102  */
2105 var menu = $.widget( "ui.menu", {
2106         version: "1.11.1",
2107         defaultElement: "<ul>",
2108         delay: 300,
2109         options: {
2110                 icons: {
2111                         submenu: "ui-icon-carat-1-e"
2112                 },
2113                 items: "> *",
2114                 menus: "ul",
2115                 position: {
2116                         my: "left-1 top",
2117                         at: "right top"
2118                 },
2119                 role: "menu",
2121                 // callbacks
2122                 blur: null,
2123                 focus: null,
2124                 select: null
2125         },
2127         _create: function() {
2128                 this.activeMenu = this.element;
2130                 // Flag used to prevent firing of the click handler
2131                 // as the event bubbles up through nested menus
2132                 this.mouseHandled = false;
2133                 this.element
2134                         .uniqueId()
2135                         .addClass( "ui-menu ui-widget ui-widget-content" )
2136                         .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
2137                         .attr({
2138                                 role: this.options.role,
2139                                 tabIndex: 0
2140                         });
2142                 if ( this.options.disabled ) {
2143                         this.element
2144                                 .addClass( "ui-state-disabled" )
2145                                 .attr( "aria-disabled", "true" );
2146                 }
2148                 this._on({
2149                         // Prevent focus from sticking to links inside menu after clicking
2150                         // them (focus should always stay on UL during navigation).
2151                         "mousedown .ui-menu-item": function( event ) {
2152                                 event.preventDefault();
2153                         },
2154                         "click .ui-menu-item": function( event ) {
2155                                 var target = $( event.target );
2156                                 if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
2157                                         this.select( event );
2159                                         // Only set the mouseHandled flag if the event will bubble, see #9469.
2160                                         if ( !event.isPropagationStopped() ) {
2161                                                 this.mouseHandled = true;
2162                                         }
2164                                         // Open submenu on click
2165                                         if ( target.has( ".ui-menu" ).length ) {
2166                                                 this.expand( event );
2167                                         } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
2169                                                 // Redirect focus to the menu
2170                                                 this.element.trigger( "focus", [ true ] );
2172                                                 // If the active item is on the top level, let it stay active.
2173                                                 // Otherwise, blur the active item since it is no longer visible.
2174                                                 if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
2175                                                         clearTimeout( this.timer );
2176                                                 }
2177                                         }
2178                                 }
2179                         },
2180                         "mouseenter .ui-menu-item": function( event ) {
2181                                 var target = $( event.currentTarget );
2182                                 // Remove ui-state-active class from siblings of the newly focused menu item
2183                                 // to avoid a jump caused by adjacent elements both having a class with a border
2184                                 target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
2185                                 this.focus( event, target );
2186                         },
2187                         mouseleave: "collapseAll",
2188                         "mouseleave .ui-menu": "collapseAll",
2189                         focus: function( event, keepActiveItem ) {
2190                                 // If there's already an active item, keep it active
2191                                 // If not, activate the first item
2192                                 var item = this.active || this.element.find( this.options.items ).eq( 0 );
2194                                 if ( !keepActiveItem ) {
2195                                         this.focus( event, item );
2196                                 }
2197                         },
2198                         blur: function( event ) {
2199                                 this._delay(function() {
2200                                         if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
2201                                                 this.collapseAll( event );
2202                                         }
2203                                 });
2204                         },
2205                         keydown: "_keydown"
2206                 });
2208                 this.refresh();
2210                 // Clicks outside of a menu collapse any open menus
2211                 this._on( this.document, {
2212                         click: function( event ) {
2213                                 if ( this._closeOnDocumentClick( event ) ) {
2214                                         this.collapseAll( event );
2215                                 }
2217                                 // Reset the mouseHandled flag
2218                                 this.mouseHandled = false;
2219                         }
2220                 });
2221         },
2223         _destroy: function() {
2224                 // Destroy (sub)menus
2225                 this.element
2226                         .removeAttr( "aria-activedescendant" )
2227                         .find( ".ui-menu" ).addBack()
2228                                 .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
2229                                 .removeAttr( "role" )
2230                                 .removeAttr( "tabIndex" )
2231                                 .removeAttr( "aria-labelledby" )
2232                                 .removeAttr( "aria-expanded" )
2233                                 .removeAttr( "aria-hidden" )
2234                                 .removeAttr( "aria-disabled" )
2235                                 .removeUniqueId()
2236                                 .show();
2238                 // Destroy menu items
2239                 this.element.find( ".ui-menu-item" )
2240                         .removeClass( "ui-menu-item" )
2241                         .removeAttr( "role" )
2242                         .removeAttr( "aria-disabled" )
2243                         .removeUniqueId()
2244                         .removeClass( "ui-state-hover" )
2245                         .removeAttr( "tabIndex" )
2246                         .removeAttr( "role" )
2247                         .removeAttr( "aria-haspopup" )
2248                         .children().each( function() {
2249                                 var elem = $( this );
2250                                 if ( elem.data( "ui-menu-submenu-carat" ) ) {
2251                                         elem.remove();
2252                                 }
2253                         });
2255                 // Destroy menu dividers
2256                 this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
2257         },
2259         _keydown: function( event ) {
2260                 var match, prev, character, skip, regex,
2261                         preventDefault = true;
2263                 function escape( value ) {
2264                         return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
2265                 }
2267                 switch ( event.keyCode ) {
2268                 case $.ui.keyCode.PAGE_UP:
2269                         this.previousPage( event );
2270                         break;
2271                 case $.ui.keyCode.PAGE_DOWN:
2272                         this.nextPage( event );
2273                         break;
2274                 case $.ui.keyCode.HOME:
2275                         this._move( "first", "first", event );
2276                         break;
2277                 case $.ui.keyCode.END:
2278                         this._move( "last", "last", event );
2279                         break;
2280                 case $.ui.keyCode.UP:
2281                         this.previous( event );
2282                         break;
2283                 case $.ui.keyCode.DOWN:
2284                         this.next( event );
2285                         break;
2286                 case $.ui.keyCode.LEFT:
2287                         this.collapse( event );
2288                         break;
2289                 case $.ui.keyCode.RIGHT:
2290                         if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
2291                                 this.expand( event );
2292                         }
2293                         break;
2294                 case $.ui.keyCode.ENTER:
2295                 case $.ui.keyCode.SPACE:
2296                         this._activate( event );
2297                         break;
2298                 case $.ui.keyCode.ESCAPE:
2299                         this.collapse( event );
2300                         break;
2301                 default:
2302                         preventDefault = false;
2303                         prev = this.previousFilter || "";
2304                         character = String.fromCharCode( event.keyCode );
2305                         skip = false;
2307                         clearTimeout( this.filterTimer );
2309                         if ( character === prev ) {
2310                                 skip = true;
2311                         } else {
2312                                 character = prev + character;
2313                         }
2315                         regex = new RegExp( "^" + escape( character ), "i" );
2316                         match = this.activeMenu.find( this.options.items ).filter(function() {
2317                                 return regex.test( $( this ).text() );
2318                         });
2319                         match = skip && match.index( this.active.next() ) !== -1 ?
2320                                 this.active.nextAll( ".ui-menu-item" ) :
2321                                 match;
2323                         // If no matches on the current filter, reset to the last character pressed
2324                         // to move down the menu to the first item that starts with that character
2325                         if ( !match.length ) {
2326                                 character = String.fromCharCode( event.keyCode );
2327                                 regex = new RegExp( "^" + escape( character ), "i" );
2328                                 match = this.activeMenu.find( this.options.items ).filter(function() {
2329                                         return regex.test( $( this ).text() );
2330                                 });
2331                         }
2333                         if ( match.length ) {
2334                                 this.focus( event, match );
2335                                 if ( match.length > 1 ) {
2336                                         this.previousFilter = character;
2337                                         this.filterTimer = this._delay(function() {
2338                                                 delete this.previousFilter;
2339                                         }, 1000 );
2340                                 } else {
2341                                         delete this.previousFilter;
2342                                 }
2343                         } else {
2344                                 delete this.previousFilter;
2345                         }
2346                 }
2348                 if ( preventDefault ) {
2349                         event.preventDefault();
2350                 }
2351         },
2353         _activate: function( event ) {
2354                 if ( !this.active.is( ".ui-state-disabled" ) ) {
2355                         if ( this.active.is( "[aria-haspopup='true']" ) ) {
2356                                 this.expand( event );
2357                         } else {
2358                                 this.select( event );
2359                         }
2360                 }
2361         },
2363         refresh: function() {
2364                 var menus, items,
2365                         that = this,
2366                         icon = this.options.icons.submenu,
2367                         submenus = this.element.find( this.options.menus );
2369                 this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
2371                 // Initialize nested menus
2372                 submenus.filter( ":not(.ui-menu)" )
2373                         .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
2374                         .hide()
2375                         .attr({
2376                                 role: this.options.role,
2377                                 "aria-hidden": "true",
2378                                 "aria-expanded": "false"
2379                         })
2380                         .each(function() {
2381                                 var menu = $( this ),
2382                                         item = menu.parent(),
2383                                         submenuCarat = $( "<span>" )
2384                                                 .addClass( "ui-menu-icon ui-icon " + icon )
2385                                                 .data( "ui-menu-submenu-carat", true );
2387                                 item
2388                                         .attr( "aria-haspopup", "true" )
2389                                         .prepend( submenuCarat );
2390                                 menu.attr( "aria-labelledby", item.attr( "id" ) );
2391                         });
2393                 menus = submenus.add( this.element );
2394                 items = menus.find( this.options.items );
2396                 // Initialize menu-items containing spaces and/or dashes only as dividers
2397                 items.not( ".ui-menu-item" ).each(function() {
2398                         var item = $( this );
2399                         if ( that._isDivider( item ) ) {
2400                                 item.addClass( "ui-widget-content ui-menu-divider" );
2401                         }
2402                 });
2404                 // Don't refresh list items that are already adapted
2405                 items.not( ".ui-menu-item, .ui-menu-divider" )
2406                         .addClass( "ui-menu-item" )
2407                         .uniqueId()
2408                         .attr({
2409                                 tabIndex: -1,
2410                                 role: this._itemRole()
2411                         });
2413                 // Add aria-disabled attribute to any disabled menu item
2414                 items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
2416                 // If the active item has been removed, blur the menu
2417                 if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
2418                         this.blur();
2419                 }
2420         },
2422         _itemRole: function() {
2423                 return {
2424                         menu: "menuitem",
2425                         listbox: "option"
2426                 }[ this.options.role ];
2427         },
2429         _setOption: function( key, value ) {
2430                 if ( key === "icons" ) {
2431                         this.element.find( ".ui-menu-icon" )
2432                                 .removeClass( this.options.icons.submenu )
2433                                 .addClass( value.submenu );
2434                 }
2435                 if ( key === "disabled" ) {
2436                         this.element
2437                                 .toggleClass( "ui-state-disabled", !!value )
2438                                 .attr( "aria-disabled", value );
2439                 }
2440                 this._super( key, value );
2441         },
2443         focus: function( event, item ) {
2444                 var nested, focused;
2445                 this.blur( event, event && event.type === "focus" );
2447                 this._scrollIntoView( item );
2449                 this.active = item.first();
2450                 focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
2451                 // Only update aria-activedescendant if there's a role
2452                 // otherwise we assume focus is managed elsewhere
2453                 if ( this.options.role ) {
2454                         this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
2455                 }
2457                 // Highlight active parent menu item, if any
2458                 this.active
2459                         .parent()
2460                         .closest( ".ui-menu-item" )
2461                         .addClass( "ui-state-active" );
2463                 if ( event && event.type === "keydown" ) {
2464                         this._close();
2465                 } else {
2466                         this.timer = this._delay(function() {
2467                                 this._close();
2468                         }, this.delay );
2469                 }
2471                 nested = item.children( ".ui-menu" );
2472                 if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
2473                         this._startOpening(nested);
2474                 }
2475                 this.activeMenu = item.parent();
2477                 this._trigger( "focus", event, { item: item } );
2478         },
2480         _scrollIntoView: function( item ) {
2481                 var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
2482                 if ( this._hasScroll() ) {
2483                         borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
2484                         paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
2485                         offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
2486                         scroll = this.activeMenu.scrollTop();
2487                         elementHeight = this.activeMenu.height();
2488                         itemHeight = item.outerHeight();
2490                         if ( offset < 0 ) {
2491                                 this.activeMenu.scrollTop( scroll + offset );
2492                         } else if ( offset + itemHeight > elementHeight ) {
2493                                 this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
2494                         }
2495                 }
2496         },
2498         blur: function( event, fromFocus ) {
2499                 if ( !fromFocus ) {
2500                         clearTimeout( this.timer );
2501                 }
2503                 if ( !this.active ) {
2504                         return;
2505                 }
2507                 this.active.removeClass( "ui-state-focus" );
2508                 this.active = null;
2510                 this._trigger( "blur", event, { item: this.active } );
2511         },
2513         _startOpening: function( submenu ) {
2514                 clearTimeout( this.timer );
2516                 // Don't open if already open fixes a Firefox bug that caused a .5 pixel
2517                 // shift in the submenu position when mousing over the carat icon
2518                 if ( submenu.attr( "aria-hidden" ) !== "true" ) {
2519                         return;
2520                 }
2522                 this.timer = this._delay(function() {
2523                         this._close();
2524                         this._open( submenu );
2525                 }, this.delay );
2526         },
2528         _open: function( submenu ) {
2529                 var position = $.extend({
2530                         of: this.active
2531                 }, this.options.position );
2533                 clearTimeout( this.timer );
2534                 this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
2535                         .hide()
2536                         .attr( "aria-hidden", "true" );
2538                 submenu
2539                         .show()
2540                         .removeAttr( "aria-hidden" )
2541                         .attr( "aria-expanded", "true" )
2542                         .position( position );
2543         },
2545         collapseAll: function( event, all ) {
2546                 clearTimeout( this.timer );
2547                 this.timer = this._delay(function() {
2548                         // If we were passed an event, look for the submenu that contains the event
2549                         var currentMenu = all ? this.element :
2550                                 $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
2552                         // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
2553                         if ( !currentMenu.length ) {
2554                                 currentMenu = this.element;
2555                         }
2557                         this._close( currentMenu );
2559                         this.blur( event );
2560                         this.activeMenu = currentMenu;
2561                 }, this.delay );
2562         },
2564         // With no arguments, closes the currently active menu - if nothing is active
2565         // it closes all menus.  If passed an argument, it will search for menus BELOW
2566         _close: function( startMenu ) {
2567                 if ( !startMenu ) {
2568                         startMenu = this.active ? this.active.parent() : this.element;
2569                 }
2571                 startMenu
2572                         .find( ".ui-menu" )
2573                                 .hide()
2574                                 .attr( "aria-hidden", "true" )
2575                                 .attr( "aria-expanded", "false" )
2576                         .end()
2577                         .find( ".ui-state-active" ).not( ".ui-state-focus" )
2578                                 .removeClass( "ui-state-active" );
2579         },
2581         _closeOnDocumentClick: function( event ) {
2582                 return !$( event.target ).closest( ".ui-menu" ).length;
2583         },
2585         _isDivider: function( item ) {
2587                 // Match hyphen, em dash, en dash
2588                 return !/[^\-\u2014\u2013\s]/.test( item.text() );
2589         },
2591         collapse: function( event ) {
2592                 var newItem = this.active &&
2593                         this.active.parent().closest( ".ui-menu-item", this.element );
2594                 if ( newItem && newItem.length ) {
2595                         this._close();
2596                         this.focus( event, newItem );
2597                 }
2598         },
2600         expand: function( event ) {
2601                 var newItem = this.active &&
2602                         this.active
2603                                 .children( ".ui-menu " )
2604                                 .find( this.options.items )
2605                                 .first();
2607                 if ( newItem && newItem.length ) {
2608                         this._open( newItem.parent() );
2610                         // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
2611                         this._delay(function() {
2612                                 this.focus( event, newItem );
2613                         });
2614                 }
2615         },
2617         next: function( event ) {
2618                 this._move( "next", "first", event );
2619         },
2621         previous: function( event ) {
2622                 this._move( "prev", "last", event );
2623         },
2625         isFirstItem: function() {
2626                 return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
2627         },
2629         isLastItem: function() {
2630                 return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
2631         },
2633         _move: function( direction, filter, event ) {
2634                 var next;
2635                 if ( this.active ) {
2636                         if ( direction === "first" || direction === "last" ) {
2637                                 next = this.active
2638                                         [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
2639                                         .eq( -1 );
2640                         } else {
2641                                 next = this.active
2642                                         [ direction + "All" ]( ".ui-menu-item" )
2643                                         .eq( 0 );
2644                         }
2645                 }
2646                 if ( !next || !next.length || !this.active ) {
2647                         next = this.activeMenu.find( this.options.items )[ filter ]();
2648                 }
2650                 this.focus( event, next );
2651         },
2653         nextPage: function( event ) {
2654                 var item, base, height;
2656                 if ( !this.active ) {
2657                         this.next( event );
2658                         return;
2659                 }
2660                 if ( this.isLastItem() ) {
2661                         return;
2662                 }
2663                 if ( this._hasScroll() ) {
2664                         base = this.active.offset().top;
2665                         height = this.element.height();
2666                         this.active.nextAll( ".ui-menu-item" ).each(function() {
2667                                 item = $( this );
2668                                 return item.offset().top - base - height < 0;
2669                         });
2671                         this.focus( event, item );
2672                 } else {
2673                         this.focus( event, this.activeMenu.find( this.options.items )
2674                                 [ !this.active ? "first" : "last" ]() );
2675                 }
2676         },
2678         previousPage: function( event ) {
2679                 var item, base, height;
2680                 if ( !this.active ) {
2681                         this.next( event );
2682                         return;
2683                 }
2684                 if ( this.isFirstItem() ) {
2685                         return;
2686                 }
2687                 if ( this._hasScroll() ) {
2688                         base = this.active.offset().top;
2689                         height = this.element.height();
2690                         this.active.prevAll( ".ui-menu-item" ).each(function() {
2691                                 item = $( this );
2692                                 return item.offset().top - base + height > 0;
2693                         });
2695                         this.focus( event, item );
2696                 } else {
2697                         this.focus( event, this.activeMenu.find( this.options.items ).first() );
2698                 }
2699         },
2701         _hasScroll: function() {
2702                 return this.element.outerHeight() < this.element.prop( "scrollHeight" );
2703         },
2705         select: function( event ) {
2706                 // TODO: It should never be possible to not have an active item at this
2707                 // point, but the tests don't trigger mouseenter before click.
2708                 this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
2709                 var ui = { item: this.active };
2710                 if ( !this.active.has( ".ui-menu" ).length ) {
2711                         this.collapseAll( event, true );
2712                 }
2713                 this._trigger( "select", event, ui );
2714         }
2715 });
2718 /*!
2719  * jQuery UI Autocomplete 1.11.1
2720  * http://jqueryui.com
2721  *
2722  * Copyright 2014 jQuery Foundation and other contributors
2723  * Released under the MIT license.
2724  * http://jquery.org/license
2725  *
2726  * http://api.jqueryui.com/autocomplete/
2727  */
2730 $.widget( "ui.autocomplete", {
2731         version: "1.11.1",
2732         defaultElement: "<input>",
2733         options: {
2734                 appendTo: null,
2735                 autoFocus: false,
2736                 delay: 300,
2737                 minLength: 1,
2738                 position: {
2739                         my: "left top",
2740                         at: "left bottom",
2741                         collision: "none"
2742                 },
2743                 source: null,
2745                 // callbacks
2746                 change: null,
2747                 close: null,
2748                 focus: null,
2749                 open: null,
2750                 response: null,
2751                 search: null,
2752                 select: null
2753         },
2755         requestIndex: 0,
2756         pending: 0,
2758         _create: function() {
2759                 // Some browsers only repeat keydown events, not keypress events,
2760                 // so we use the suppressKeyPress flag to determine if we've already
2761                 // handled the keydown event. #7269
2762                 // Unfortunately the code for & in keypress is the same as the up arrow,
2763                 // so we use the suppressKeyPressRepeat flag to avoid handling keypress
2764                 // events when we know the keydown event was used to modify the
2765                 // search term. #7799
2766                 var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
2767                         nodeName = this.element[ 0 ].nodeName.toLowerCase(),
2768                         isTextarea = nodeName === "textarea",
2769                         isInput = nodeName === "input";
2771                 this.isMultiLine =
2772                         // Textareas are always multi-line
2773                         isTextarea ? true :
2774                         // Inputs are always single-line, even if inside a contentEditable element
2775                         // IE also treats inputs as contentEditable
2776                         isInput ? false :
2777                         // All other element types are determined by whether or not they're contentEditable
2778                         this.element.prop( "isContentEditable" );
2780                 this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
2781                 this.isNewMenu = true;
2783                 this.element
2784                         .addClass( "ui-autocomplete-input" )
2785                         .attr( "autocomplete", "off" );
2787                 this._on( this.element, {
2788                         keydown: function( event ) {
2789                                 if ( this.element.prop( "readOnly" ) ) {
2790                                         suppressKeyPress = true;
2791                                         suppressInput = true;
2792                                         suppressKeyPressRepeat = true;
2793                                         return;
2794                                 }
2796                                 suppressKeyPress = false;
2797                                 suppressInput = false;
2798                                 suppressKeyPressRepeat = false;
2799                                 var keyCode = $.ui.keyCode;
2800                                 switch ( event.keyCode ) {
2801                                 case keyCode.PAGE_UP:
2802                                         suppressKeyPress = true;
2803                                         this._move( "previousPage", event );
2804                                         break;
2805                                 case keyCode.PAGE_DOWN:
2806                                         suppressKeyPress = true;
2807                                         this._move( "nextPage", event );
2808                                         break;
2809                                 case keyCode.UP:
2810                                         suppressKeyPress = true;
2811                &