jQuery-ui-autocomplete

jQuery-ui with the autocomplete widget

Este script não deve ser instalado diretamente. Este script é uma biblioteca de outros scripts para incluir com o diretório meta // @require https://update.greatest.deepsurf.us/scripts/8072/36815/jQuery-ui-autocomplete.js

  1. // ==UserScript==
  2. // @name jQuery-ui-autocomplete
  3. // @namespace jQuery
  4. // @description jQuery-ui with the autocomplete widget
  5. // @source http://jqueryui.com/
  6. // @copyright The jQuery Foundation
  7. // @version 1.11.3
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. /*! jQuery UI - v1.11.3 - 2015-02-13
  12. * http://jqueryui.com
  13. * Includes: core.js, widget.js, position.js, autocomplete.js, menu.js
  14. * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
  15. function loadjQueryUIFullscreen(){
  16. (function( factory ) {
  17. if ( typeof define === "function" && define.amd ) {
  18.  
  19. // AMD. Register as an anonymous module.
  20. define([ "jquery" ], factory );
  21. } else {
  22.  
  23. // Browser globals
  24. factory( jQuery );
  25. }
  26. }(function( $ ) {
  27. /*!
  28. * jQuery UI Core 1.11.3
  29. * http://jqueryui.com
  30. *
  31. * Copyright jQuery Foundation and other contributors
  32. * Released under the MIT license.
  33. * http://jquery.org/license
  34. *
  35. * http://api.jqueryui.com/category/ui-core/
  36. */
  37.  
  38.  
  39. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  40. $.ui = $.ui || {};
  41.  
  42. $.extend( $.ui, {
  43. version: "1.11.3",
  44.  
  45. keyCode: {
  46. BACKSPACE: 8,
  47. COMMA: 188,
  48. DELETE: 46,
  49. DOWN: 40,
  50. END: 35,
  51. ENTER: 13,
  52. ESCAPE: 27,
  53. HOME: 36,
  54. LEFT: 37,
  55. PAGE_DOWN: 34,
  56. PAGE_UP: 33,
  57. PERIOD: 190,
  58. RIGHT: 39,
  59. SPACE: 32,
  60. TAB: 9,
  61. UP: 38
  62. }
  63. });
  64.  
  65. // plugins
  66. $.fn.extend({
  67. scrollParent: function( includeHidden ) {
  68. var position = this.css( "position" ),
  69. excludeStaticParent = position === "absolute",
  70. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  71. scrollParent = this.parents().filter( function() {
  72. var parent = $( this );
  73. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  74. return false;
  75. }
  76. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  77. }).eq( 0 );
  78.  
  79. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  80. },
  81.  
  82. uniqueId: (function() {
  83. var uuid = 0;
  84.  
  85. return function() {
  86. return this.each(function() {
  87. if ( !this.id ) {
  88. this.id = "ui-id-" + ( ++uuid );
  89. }
  90. });
  91. };
  92. })(),
  93.  
  94. removeUniqueId: function() {
  95. return this.each(function() {
  96. if ( /^ui-id-\d+$/.test( this.id ) ) {
  97. $( this ).removeAttr( "id" );
  98. }
  99. });
  100. }
  101. });
  102.  
  103. // selectors
  104. function focusable( element, isTabIndexNotNaN ) {
  105. var map, mapName, img,
  106. nodeName = element.nodeName.toLowerCase();
  107. if ( "area" === nodeName ) {
  108. map = element.parentNode;
  109. mapName = map.name;
  110. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  111. return false;
  112. }
  113. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  114. return !!img && visible( img );
  115. }
  116. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  117. !element.disabled :
  118. "a" === nodeName ?
  119. element.href || isTabIndexNotNaN :
  120. isTabIndexNotNaN) &&
  121. // the element and all of its ancestors must be visible
  122. visible( element );
  123. }
  124.  
  125. function visible( element ) {
  126. return $.expr.filters.visible( element ) &&
  127. !$( element ).parents().addBack().filter(function() {
  128. return $.css( this, "visibility" ) === "hidden";
  129. }).length;
  130. }
  131.  
  132. $.extend( $.expr[ ":" ], {
  133. data: $.expr.createPseudo ?
  134. $.expr.createPseudo(function( dataName ) {
  135. return function( elem ) {
  136. return !!$.data( elem, dataName );
  137. };
  138. }) :
  139. // support: jQuery <1.8
  140. function( elem, i, match ) {
  141. return !!$.data( elem, match[ 3 ] );
  142. },
  143.  
  144. focusable: function( element ) {
  145. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  146. },
  147.  
  148. tabbable: function( element ) {
  149. var tabIndex = $.attr( element, "tabindex" ),
  150. isTabIndexNaN = isNaN( tabIndex );
  151. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  152. }
  153. });
  154.  
  155. // support: jQuery <1.8
  156. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  157. $.each( [ "Width", "Height" ], function( i, name ) {
  158. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  159. type = name.toLowerCase(),
  160. orig = {
  161. innerWidth: $.fn.innerWidth,
  162. innerHeight: $.fn.innerHeight,
  163. outerWidth: $.fn.outerWidth,
  164. outerHeight: $.fn.outerHeight
  165. };
  166.  
  167. function reduce( elem, size, border, margin ) {
  168. $.each( side, function() {
  169. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  170. if ( border ) {
  171. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  172. }
  173. if ( margin ) {
  174. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  175. }
  176. });
  177. return size;
  178. }
  179.  
  180. $.fn[ "inner" + name ] = function( size ) {
  181. if ( size === undefined ) {
  182. return orig[ "inner" + name ].call( this );
  183. }
  184.  
  185. return this.each(function() {
  186. $( this ).css( type, reduce( this, size ) + "px" );
  187. });
  188. };
  189.  
  190. $.fn[ "outer" + name] = function( size, margin ) {
  191. if ( typeof size !== "number" ) {
  192. return orig[ "outer" + name ].call( this, size );
  193. }
  194.  
  195. return this.each(function() {
  196. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  197. });
  198. };
  199. });
  200. }
  201.  
  202. // support: jQuery <1.8
  203. if ( !$.fn.addBack ) {
  204. $.fn.addBack = function( selector ) {
  205. return this.add( selector == null ?
  206. this.prevObject : this.prevObject.filter( selector )
  207. );
  208. };
  209. }
  210.  
  211. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  212. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  213. $.fn.removeData = (function( removeData ) {
  214. return function( key ) {
  215. if ( arguments.length ) {
  216. return removeData.call( this, $.camelCase( key ) );
  217. } else {
  218. return removeData.call( this );
  219. }
  220. };
  221. })( $.fn.removeData );
  222. }
  223.  
  224. // deprecated
  225. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  226.  
  227. $.fn.extend({
  228. focus: (function( orig ) {
  229. return function( delay, fn ) {
  230. return typeof delay === "number" ?
  231. this.each(function() {
  232. var elem = this;
  233. setTimeout(function() {
  234. $( elem ).focus();
  235. if ( fn ) {
  236. fn.call( elem );
  237. }
  238. }, delay );
  239. }) :
  240. orig.apply( this, arguments );
  241. };
  242. })( $.fn.focus ),
  243.  
  244. disableSelection: (function() {
  245. var eventType = "onselectstart" in document.createElement( "div" ) ?
  246. "selectstart" :
  247. "mousedown";
  248.  
  249. return function() {
  250. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  251. event.preventDefault();
  252. });
  253. };
  254. })(),
  255.  
  256. enableSelection: function() {
  257. return this.unbind( ".ui-disableSelection" );
  258. },
  259.  
  260. zIndex: function( zIndex ) {
  261. if ( zIndex !== undefined ) {
  262. return this.css( "zIndex", zIndex );
  263. }
  264.  
  265. if ( this.length ) {
  266. var elem = $( this[ 0 ] ), position, value;
  267. while ( elem.length && elem[ 0 ] !== document ) {
  268. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  269. // This makes behavior of this function consistent across browsers
  270. // WebKit always returns auto if the element is positioned
  271. position = elem.css( "position" );
  272. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  273. // IE returns 0 when zIndex is not specified
  274. // other browsers return a string
  275. // we ignore the case of nested elements with an explicit value of 0
  276. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  277. value = parseInt( elem.css( "zIndex" ), 10 );
  278. if ( !isNaN( value ) && value !== 0 ) {
  279. return value;
  280. }
  281. }
  282. elem = elem.parent();
  283. }
  284. }
  285.  
  286. return 0;
  287. }
  288. });
  289.  
  290. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  291. $.ui.plugin = {
  292. add: function( module, option, set ) {
  293. var i,
  294. proto = $.ui[ module ].prototype;
  295. for ( i in set ) {
  296. proto.plugins[ i ] = proto.plugins[ i ] || [];
  297. proto.plugins[ i ].push( [ option, set[ i ] ] );
  298. }
  299. },
  300. call: function( instance, name, args, allowDisconnected ) {
  301. var i,
  302. set = instance.plugins[ name ];
  303.  
  304. if ( !set ) {
  305. return;
  306. }
  307.  
  308. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  309. return;
  310. }
  311.  
  312. for ( i = 0; i < set.length; i++ ) {
  313. if ( instance.options[ set[ i ][ 0 ] ] ) {
  314. set[ i ][ 1 ].apply( instance.element, args );
  315. }
  316. }
  317. }
  318. };
  319.  
  320.  
  321. /*!
  322. * jQuery UI Widget 1.11.3
  323. * http://jqueryui.com
  324. *
  325. * Copyright jQuery Foundation and other contributors
  326. * Released under the MIT license.
  327. * http://jquery.org/license
  328. *
  329. * http://api.jqueryui.com/jQuery.widget/
  330. */
  331.  
  332.  
  333. var widget_uuid = 0,
  334. widget_slice = Array.prototype.slice;
  335.  
  336. $.cleanData = (function( orig ) {
  337. return function( elems ) {
  338. var events, elem, i;
  339. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  340. try {
  341.  
  342. // Only trigger remove when necessary to save time
  343. events = $._data( elem, "events" );
  344. if ( events && events.remove ) {
  345. $( elem ).triggerHandler( "remove" );
  346. }
  347.  
  348. // http://bugs.jquery.com/ticket/8235
  349. } catch ( e ) {}
  350. }
  351. orig( elems );
  352. };
  353. })( $.cleanData );
  354.  
  355. $.widget = function( name, base, prototype ) {
  356. var fullName, existingConstructor, constructor, basePrototype,
  357. // proxiedPrototype allows the provided prototype to remain unmodified
  358. // so that it can be used as a mixin for multiple widgets (#8876)
  359. proxiedPrototype = {},
  360. namespace = name.split( "." )[ 0 ];
  361.  
  362. name = name.split( "." )[ 1 ];
  363. fullName = namespace + "-" + name;
  364.  
  365. if ( !prototype ) {
  366. prototype = base;
  367. base = $.Widget;
  368. }
  369.  
  370. // create selector for plugin
  371. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  372. return !!$.data( elem, fullName );
  373. };
  374.  
  375. $[ namespace ] = $[ namespace ] || {};
  376. existingConstructor = $[ namespace ][ name ];
  377. constructor = $[ namespace ][ name ] = function( options, element ) {
  378. // allow instantiation without "new" keyword
  379. if ( !this._createWidget ) {
  380. return new constructor( options, element );
  381. }
  382.  
  383. // allow instantiation without initializing for simple inheritance
  384. // must use "new" keyword (the code above always passes args)
  385. if ( arguments.length ) {
  386. this._createWidget( options, element );
  387. }
  388. };
  389. // extend with the existing constructor to carry over any static properties
  390. $.extend( constructor, existingConstructor, {
  391. version: prototype.version,
  392. // copy the object used to create the prototype in case we need to
  393. // redefine the widget later
  394. _proto: $.extend( {}, prototype ),
  395. // track widgets that inherit from this widget in case this widget is
  396. // redefined after a widget inherits from it
  397. _childConstructors: []
  398. });
  399.  
  400. basePrototype = new base();
  401. // we need to make the options hash a property directly on the new instance
  402. // otherwise we'll modify the options hash on the prototype that we're
  403. // inheriting from
  404. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  405. $.each( prototype, function( prop, value ) {
  406. if ( !$.isFunction( value ) ) {
  407. proxiedPrototype[ prop ] = value;
  408. return;
  409. }
  410. proxiedPrototype[ prop ] = (function() {
  411. var _super = function() {
  412. return base.prototype[ prop ].apply( this, arguments );
  413. },
  414. _superApply = function( args ) {
  415. return base.prototype[ prop ].apply( this, args );
  416. };
  417. return function() {
  418. var __super = this._super,
  419. __superApply = this._superApply,
  420. returnValue;
  421.  
  422. this._super = _super;
  423. this._superApply = _superApply;
  424.  
  425. returnValue = value.apply( this, arguments );
  426.  
  427. this._super = __super;
  428. this._superApply = __superApply;
  429.  
  430. return returnValue;
  431. };
  432. })();
  433. });
  434. constructor.prototype = $.widget.extend( basePrototype, {
  435. // TODO: remove support for widgetEventPrefix
  436. // always use the name + a colon as the prefix, e.g., draggable:start
  437. // don't prefix for widgets that aren't DOM-based
  438. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  439. }, proxiedPrototype, {
  440. constructor: constructor,
  441. namespace: namespace,
  442. widgetName: name,
  443. widgetFullName: fullName
  444. });
  445.  
  446. // If this widget is being redefined then we need to find all widgets that
  447. // are inheriting from it and redefine all of them so that they inherit from
  448. // the new version of this widget. We're essentially trying to replace one
  449. // level in the prototype chain.
  450. if ( existingConstructor ) {
  451. $.each( existingConstructor._childConstructors, function( i, child ) {
  452. var childPrototype = child.prototype;
  453.  
  454. // redefine the child widget using the same prototype that was
  455. // originally used, but inherit from the new version of the base
  456. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  457. });
  458. // remove the list of existing child constructors from the old constructor
  459. // so the old child constructors can be garbage collected
  460. delete existingConstructor._childConstructors;
  461. } else {
  462. base._childConstructors.push( constructor );
  463. }
  464.  
  465. $.widget.bridge( name, constructor );
  466.  
  467. return constructor;
  468. };
  469.  
  470. $.widget.extend = function( target ) {
  471. var input = widget_slice.call( arguments, 1 ),
  472. inputIndex = 0,
  473. inputLength = input.length,
  474. key,
  475. value;
  476. for ( ; inputIndex < inputLength; inputIndex++ ) {
  477. for ( key in input[ inputIndex ] ) {
  478. value = input[ inputIndex ][ key ];
  479. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  480. // Clone objects
  481. if ( $.isPlainObject( value ) ) {
  482. target[ key ] = $.isPlainObject( target[ key ] ) ?
  483. $.widget.extend( {}, target[ key ], value ) :
  484. // Don't extend strings, arrays, etc. with objects
  485. $.widget.extend( {}, value );
  486. // Copy everything else by reference
  487. } else {
  488. target[ key ] = value;
  489. }
  490. }
  491. }
  492. }
  493. return target;
  494. };
  495.  
  496. $.widget.bridge = function( name, object ) {
  497. var fullName = object.prototype.widgetFullName || name;
  498. $.fn[ name ] = function( options ) {
  499. var isMethodCall = typeof options === "string",
  500. args = widget_slice.call( arguments, 1 ),
  501. returnValue = this;
  502.  
  503. if ( isMethodCall ) {
  504. this.each(function() {
  505. var methodValue,
  506. instance = $.data( this, fullName );
  507. if ( options === "instance" ) {
  508. returnValue = instance;
  509. return false;
  510. }
  511. if ( !instance ) {
  512. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  513. "attempted to call method '" + options + "'" );
  514. }
  515. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  516. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  517. }
  518. methodValue = instance[ options ].apply( instance, args );
  519. if ( methodValue !== instance && methodValue !== undefined ) {
  520. returnValue = methodValue && methodValue.jquery ?
  521. returnValue.pushStack( methodValue.get() ) :
  522. methodValue;
  523. return false;
  524. }
  525. });
  526. } else {
  527.  
  528. // Allow multiple hashes to be passed on init
  529. if ( args.length ) {
  530. options = $.widget.extend.apply( null, [ options ].concat(args) );
  531. }
  532.  
  533. this.each(function() {
  534. var instance = $.data( this, fullName );
  535. if ( instance ) {
  536. instance.option( options || {} );
  537. if ( instance._init ) {
  538. instance._init();
  539. }
  540. } else {
  541. $.data( this, fullName, new object( options, this ) );
  542. }
  543. });
  544. }
  545.  
  546. return returnValue;
  547. };
  548. };
  549.  
  550. $.Widget = function( /* options, element */ ) {};
  551. $.Widget._childConstructors = [];
  552.  
  553. $.Widget.prototype = {
  554. widgetName: "widget",
  555. widgetEventPrefix: "",
  556. defaultElement: "<div>",
  557. options: {
  558. disabled: false,
  559.  
  560. // callbacks
  561. create: null
  562. },
  563. _createWidget: function( options, element ) {
  564. element = $( element || this.defaultElement || this )[ 0 ];
  565. this.element = $( element );
  566. this.uuid = widget_uuid++;
  567. this.eventNamespace = "." + this.widgetName + this.uuid;
  568.  
  569. this.bindings = $();
  570. this.hoverable = $();
  571. this.focusable = $();
  572.  
  573. if ( element !== this ) {
  574. $.data( element, this.widgetFullName, this );
  575. this._on( true, this.element, {
  576. remove: function( event ) {
  577. if ( event.target === element ) {
  578. this.destroy();
  579. }
  580. }
  581. });
  582. this.document = $( element.style ?
  583. // element within the document
  584. element.ownerDocument :
  585. // element is window or document
  586. element.document || element );
  587. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  588. }
  589.  
  590. this.options = $.widget.extend( {},
  591. this.options,
  592. this._getCreateOptions(),
  593. options );
  594.  
  595. this._create();
  596. this._trigger( "create", null, this._getCreateEventData() );
  597. this._init();
  598. },
  599. _getCreateOptions: $.noop,
  600. _getCreateEventData: $.noop,
  601. _create: $.noop,
  602. _init: $.noop,
  603.  
  604. destroy: function() {
  605. this._destroy();
  606. // we can probably remove the unbind calls in 2.0
  607. // all event bindings should go through this._on()
  608. this.element
  609. .unbind( this.eventNamespace )
  610. .removeData( this.widgetFullName )
  611. // support: jquery <1.6.3
  612. // http://bugs.jquery.com/ticket/9413
  613. .removeData( $.camelCase( this.widgetFullName ) );
  614. this.widget()
  615. .unbind( this.eventNamespace )
  616. .removeAttr( "aria-disabled" )
  617. .removeClass(
  618. this.widgetFullName + "-disabled " +
  619. "ui-state-disabled" );
  620.  
  621. // clean up events and states
  622. this.bindings.unbind( this.eventNamespace );
  623. this.hoverable.removeClass( "ui-state-hover" );
  624. this.focusable.removeClass( "ui-state-focus" );
  625. },
  626. _destroy: $.noop,
  627.  
  628. widget: function() {
  629. return this.element;
  630. },
  631.  
  632. option: function( key, value ) {
  633. var options = key,
  634. parts,
  635. curOption,
  636. i;
  637.  
  638. if ( arguments.length === 0 ) {
  639. // don't return a reference to the internal hash
  640. return $.widget.extend( {}, this.options );
  641. }
  642.  
  643. if ( typeof key === "string" ) {
  644. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  645. options = {};
  646. parts = key.split( "." );
  647. key = parts.shift();
  648. if ( parts.length ) {
  649. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  650. for ( i = 0; i < parts.length - 1; i++ ) {
  651. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  652. curOption = curOption[ parts[ i ] ];
  653. }
  654. key = parts.pop();
  655. if ( arguments.length === 1 ) {
  656. return curOption[ key ] === undefined ? null : curOption[ key ];
  657. }
  658. curOption[ key ] = value;
  659. } else {
  660. if ( arguments.length === 1 ) {
  661. return this.options[ key ] === undefined ? null : this.options[ key ];
  662. }
  663. options[ key ] = value;
  664. }
  665. }
  666.  
  667. this._setOptions( options );
  668.  
  669. return this;
  670. },
  671. _setOptions: function( options ) {
  672. var key;
  673.  
  674. for ( key in options ) {
  675. this._setOption( key, options[ key ] );
  676. }
  677.  
  678. return this;
  679. },
  680. _setOption: function( key, value ) {
  681. this.options[ key ] = value;
  682.  
  683. if ( key === "disabled" ) {
  684. this.widget()
  685. .toggleClass( this.widgetFullName + "-disabled", !!value );
  686.  
  687. // If the widget is becoming disabled, then nothing is interactive
  688. if ( value ) {
  689. this.hoverable.removeClass( "ui-state-hover" );
  690. this.focusable.removeClass( "ui-state-focus" );
  691. }
  692. }
  693.  
  694. return this;
  695. },
  696.  
  697. enable: function() {
  698. return this._setOptions({ disabled: false });
  699. },
  700. disable: function() {
  701. return this._setOptions({ disabled: true });
  702. },
  703.  
  704. _on: function( suppressDisabledCheck, element, handlers ) {
  705. var delegateElement,
  706. instance = this;
  707.  
  708. // no suppressDisabledCheck flag, shuffle arguments
  709. if ( typeof suppressDisabledCheck !== "boolean" ) {
  710. handlers = element;
  711. element = suppressDisabledCheck;
  712. suppressDisabledCheck = false;
  713. }
  714.  
  715. // no element argument, shuffle and use this.element
  716. if ( !handlers ) {
  717. handlers = element;
  718. element = this.element;
  719. delegateElement = this.widget();
  720. } else {
  721. element = delegateElement = $( element );
  722. this.bindings = this.bindings.add( element );
  723. }
  724.  
  725. $.each( handlers, function( event, handler ) {
  726. function handlerProxy() {
  727. // allow widgets to customize the disabled handling
  728. // - disabled as an array instead of boolean
  729. // - disabled class as method for disabling individual parts
  730. if ( !suppressDisabledCheck &&
  731. ( instance.options.disabled === true ||
  732. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  733. return;
  734. }
  735. return ( typeof handler === "string" ? instance[ handler ] : handler )
  736. .apply( instance, arguments );
  737. }
  738.  
  739. // copy the guid so direct unbinding works
  740. if ( typeof handler !== "string" ) {
  741. handlerProxy.guid = handler.guid =
  742. handler.guid || handlerProxy.guid || $.guid++;
  743. }
  744.  
  745. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  746. eventName = match[1] + instance.eventNamespace,
  747. selector = match[2];
  748. if ( selector ) {
  749. delegateElement.delegate( selector, eventName, handlerProxy );
  750. } else {
  751. element.bind( eventName, handlerProxy );
  752. }
  753. });
  754. },
  755.  
  756. _off: function( element, eventName ) {
  757. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  758. this.eventNamespace;
  759. element.unbind( eventName ).undelegate( eventName );
  760.  
  761. // Clear the stack to avoid memory leaks (#10056)
  762. this.bindings = $( this.bindings.not( element ).get() );
  763. this.focusable = $( this.focusable.not( element ).get() );
  764. this.hoverable = $( this.hoverable.not( element ).get() );
  765. },
  766.  
  767. _delay: function( handler, delay ) {
  768. function handlerProxy() {
  769. return ( typeof handler === "string" ? instance[ handler ] : handler )
  770. .apply( instance, arguments );
  771. }
  772. var instance = this;
  773. return setTimeout( handlerProxy, delay || 0 );
  774. },
  775.  
  776. _hoverable: function( element ) {
  777. this.hoverable = this.hoverable.add( element );
  778. this._on( element, {
  779. mouseenter: function( event ) {
  780. $( event.currentTarget ).addClass( "ui-state-hover" );
  781. },
  782. mouseleave: function( event ) {
  783. $( event.currentTarget ).removeClass( "ui-state-hover" );
  784. }
  785. });
  786. },
  787.  
  788. _focusable: function( element ) {
  789. this.focusable = this.focusable.add( element );
  790. this._on( element, {
  791. focusin: function( event ) {
  792. $( event.currentTarget ).addClass( "ui-state-focus" );
  793. },
  794. focusout: function( event ) {
  795. $( event.currentTarget ).removeClass( "ui-state-focus" );
  796. }
  797. });
  798. },
  799.  
  800. _trigger: function( type, event, data ) {
  801. var prop, orig,
  802. callback = this.options[ type ];
  803.  
  804. data = data || {};
  805. event = $.Event( event );
  806. event.type = ( type === this.widgetEventPrefix ?
  807. type :
  808. this.widgetEventPrefix + type ).toLowerCase();
  809. // the original event may come from any element
  810. // so we need to reset the target on the new event
  811. event.target = this.element[ 0 ];
  812.  
  813. // copy original event properties over to the new event
  814. orig = event.originalEvent;
  815. if ( orig ) {
  816. for ( prop in orig ) {
  817. if ( !( prop in event ) ) {
  818. event[ prop ] = orig[ prop ];
  819. }
  820. }
  821. }
  822.  
  823. this.element.trigger( event, data );
  824. return !( $.isFunction( callback ) &&
  825. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  826. event.isDefaultPrevented() );
  827. }
  828. };
  829.  
  830. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  831. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  832. if ( typeof options === "string" ) {
  833. options = { effect: options };
  834. }
  835. var hasOptions,
  836. effectName = !options ?
  837. method :
  838. options === true || typeof options === "number" ?
  839. defaultEffect :
  840. options.effect || defaultEffect;
  841. options = options || {};
  842. if ( typeof options === "number" ) {
  843. options = { duration: options };
  844. }
  845. hasOptions = !$.isEmptyObject( options );
  846. options.complete = callback;
  847. if ( options.delay ) {
  848. element.delay( options.delay );
  849. }
  850. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  851. element[ method ]( options );
  852. } else if ( effectName !== method && element[ effectName ] ) {
  853. element[ effectName ]( options.duration, options.easing, callback );
  854. } else {
  855. element.queue(function( next ) {
  856. $( this )[ method ]();
  857. if ( callback ) {
  858. callback.call( element[ 0 ] );
  859. }
  860. next();
  861. });
  862. }
  863. };
  864. });
  865.  
  866. var widget = $.widget;
  867.  
  868.  
  869. /*!
  870. * jQuery UI Position 1.11.3
  871. * http://jqueryui.com
  872. *
  873. * Copyright jQuery Foundation and other contributors
  874. * Released under the MIT license.
  875. * http://jquery.org/license
  876. *
  877. * http://api.jqueryui.com/position/
  878. */
  879.  
  880. (function() {
  881.  
  882. $.ui = $.ui || {};
  883.  
  884. var cachedScrollbarWidth, supportsOffsetFractions,
  885. max = Math.max,
  886. abs = Math.abs,
  887. round = Math.round,
  888. rhorizontal = /left|center|right/,
  889. rvertical = /top|center|bottom/,
  890. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  891. rposition = /^\w+/,
  892. rpercent = /%$/,
  893. _position = $.fn.position;
  894.  
  895. function getOffsets( offsets, width, height ) {
  896. return [
  897. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  898. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  899. ];
  900. }
  901.  
  902. function parseCss( element, property ) {
  903. return parseInt( $.css( element, property ), 10 ) || 0;
  904. }
  905.  
  906. function getDimensions( elem ) {
  907. var raw = elem[0];
  908. if ( raw.nodeType === 9 ) {
  909. return {
  910. width: elem.width(),
  911. height: elem.height(),
  912. offset: { top: 0, left: 0 }
  913. };
  914. }
  915. if ( $.isWindow( raw ) ) {
  916. return {
  917. width: elem.width(),
  918. height: elem.height(),
  919. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  920. };
  921. }
  922. if ( raw.preventDefault ) {
  923. return {
  924. width: 0,
  925. height: 0,
  926. offset: { top: raw.pageY, left: raw.pageX }
  927. };
  928. }
  929. return {
  930. width: elem.outerWidth(),
  931. height: elem.outerHeight(),
  932. offset: elem.offset()
  933. };
  934. }
  935.  
  936. $.position = {
  937. scrollbarWidth: function() {
  938. if ( cachedScrollbarWidth !== undefined ) {
  939. return cachedScrollbarWidth;
  940. }
  941. var w1, w2,
  942. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  943. innerDiv = div.children()[0];
  944.  
  945. $( "body" ).append( div );
  946. w1 = innerDiv.offsetWidth;
  947. div.css( "overflow", "scroll" );
  948.  
  949. w2 = innerDiv.offsetWidth;
  950.  
  951. if ( w1 === w2 ) {
  952. w2 = div[0].clientWidth;
  953. }
  954.  
  955. div.remove();
  956.  
  957. return (cachedScrollbarWidth = w1 - w2);
  958. },
  959. getScrollInfo: function( within ) {
  960. var overflowX = within.isWindow || within.isDocument ? "" :
  961. within.element.css( "overflow-x" ),
  962. overflowY = within.isWindow || within.isDocument ? "" :
  963. within.element.css( "overflow-y" ),
  964. hasOverflowX = overflowX === "scroll" ||
  965. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  966. hasOverflowY = overflowY === "scroll" ||
  967. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  968. return {
  969. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  970. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  971. };
  972. },
  973. getWithinInfo: function( element ) {
  974. var withinElement = $( element || window ),
  975. isWindow = $.isWindow( withinElement[0] ),
  976. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  977. return {
  978. element: withinElement,
  979. isWindow: isWindow,
  980. isDocument: isDocument,
  981. offset: withinElement.offset() || { left: 0, top: 0 },
  982. scrollLeft: withinElement.scrollLeft(),
  983. scrollTop: withinElement.scrollTop(),
  984.  
  985. // support: jQuery 1.6.x
  986. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  987. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  988. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  989. };
  990. }
  991. };
  992.  
  993. $.fn.position = function( options ) {
  994. if ( !options || !options.of ) {
  995. return _position.apply( this, arguments );
  996. }
  997.  
  998. // make a copy, we don't want to modify arguments
  999. options = $.extend( {}, options );
  1000.  
  1001. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1002. target = $( options.of ),
  1003. within = $.position.getWithinInfo( options.within ),
  1004. scrollInfo = $.position.getScrollInfo( within ),
  1005. collision = ( options.collision || "flip" ).split( " " ),
  1006. offsets = {};
  1007.  
  1008. dimensions = getDimensions( target );
  1009. if ( target[0].preventDefault ) {
  1010. // force left top to allow flipping
  1011. options.at = "left top";
  1012. }
  1013. targetWidth = dimensions.width;
  1014. targetHeight = dimensions.height;
  1015. targetOffset = dimensions.offset;
  1016. // clone to reuse original targetOffset later
  1017. basePosition = $.extend( {}, targetOffset );
  1018.  
  1019. // force my and at to have valid horizontal and vertical positions
  1020. // if a value is missing or invalid, it will be converted to center
  1021. $.each( [ "my", "at" ], function() {
  1022. var pos = ( options[ this ] || "" ).split( " " ),
  1023. horizontalOffset,
  1024. verticalOffset;
  1025.  
  1026. if ( pos.length === 1) {
  1027. pos = rhorizontal.test( pos[ 0 ] ) ?
  1028. pos.concat( [ "center" ] ) :
  1029. rvertical.test( pos[ 0 ] ) ?
  1030. [ "center" ].concat( pos ) :
  1031. [ "center", "center" ];
  1032. }
  1033. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1034. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1035.  
  1036. // calculate offsets
  1037. horizontalOffset = roffset.exec( pos[ 0 ] );
  1038. verticalOffset = roffset.exec( pos[ 1 ] );
  1039. offsets[ this ] = [
  1040. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1041. verticalOffset ? verticalOffset[ 0 ] : 0
  1042. ];
  1043.  
  1044. // reduce to just the positions without the offsets
  1045. options[ this ] = [
  1046. rposition.exec( pos[ 0 ] )[ 0 ],
  1047. rposition.exec( pos[ 1 ] )[ 0 ]
  1048. ];
  1049. });
  1050.  
  1051. // normalize collision option
  1052. if ( collision.length === 1 ) {
  1053. collision[ 1 ] = collision[ 0 ];
  1054. }
  1055.  
  1056. if ( options.at[ 0 ] === "right" ) {
  1057. basePosition.left += targetWidth;
  1058. } else if ( options.at[ 0 ] === "center" ) {
  1059. basePosition.left += targetWidth / 2;
  1060. }
  1061.  
  1062. if ( options.at[ 1 ] === "bottom" ) {
  1063. basePosition.top += targetHeight;
  1064. } else if ( options.at[ 1 ] === "center" ) {
  1065. basePosition.top += targetHeight / 2;
  1066. }
  1067.  
  1068. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1069. basePosition.left += atOffset[ 0 ];
  1070. basePosition.top += atOffset[ 1 ];
  1071.  
  1072. return this.each(function() {
  1073. var collisionPosition, using,
  1074. elem = $( this ),
  1075. elemWidth = elem.outerWidth(),
  1076. elemHeight = elem.outerHeight(),
  1077. marginLeft = parseCss( this, "marginLeft" ),
  1078. marginTop = parseCss( this, "marginTop" ),
  1079. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1080. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1081. position = $.extend( {}, basePosition ),
  1082. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1083.  
  1084. if ( options.my[ 0 ] === "right" ) {
  1085. position.left -= elemWidth;
  1086. } else if ( options.my[ 0 ] === "center" ) {
  1087. position.left -= elemWidth / 2;
  1088. }
  1089.  
  1090. if ( options.my[ 1 ] === "bottom" ) {
  1091. position.top -= elemHeight;
  1092. } else if ( options.my[ 1 ] === "center" ) {
  1093. position.top -= elemHeight / 2;
  1094. }
  1095.  
  1096. position.left += myOffset[ 0 ];
  1097. position.top += myOffset[ 1 ];
  1098.  
  1099. // if the browser doesn't support fractions, then round for consistent results
  1100. if ( !supportsOffsetFractions ) {
  1101. position.left = round( position.left );
  1102. position.top = round( position.top );
  1103. }
  1104.  
  1105. collisionPosition = {
  1106. marginLeft: marginLeft,
  1107. marginTop: marginTop
  1108. };
  1109.  
  1110. $.each( [ "left", "top" ], function( i, dir ) {
  1111. if ( $.ui.position[ collision[ i ] ] ) {
  1112. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1113. targetWidth: targetWidth,
  1114. targetHeight: targetHeight,
  1115. elemWidth: elemWidth,
  1116. elemHeight: elemHeight,
  1117. collisionPosition: collisionPosition,
  1118. collisionWidth: collisionWidth,
  1119. collisionHeight: collisionHeight,
  1120. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1121. my: options.my,
  1122. at: options.at,
  1123. within: within,
  1124. elem: elem
  1125. });
  1126. }
  1127. });
  1128.  
  1129. if ( options.using ) {
  1130. // adds feedback as second argument to using callback, if present
  1131. using = function( props ) {
  1132. var left = targetOffset.left - position.left,
  1133. right = left + targetWidth - elemWidth,
  1134. top = targetOffset.top - position.top,
  1135. bottom = top + targetHeight - elemHeight,
  1136. feedback = {
  1137. target: {
  1138. element: target,
  1139. left: targetOffset.left,
  1140. top: targetOffset.top,
  1141. width: targetWidth,
  1142. height: targetHeight
  1143. },
  1144. element: {
  1145. element: elem,
  1146. left: position.left,
  1147. top: position.top,
  1148. width: elemWidth,
  1149. height: elemHeight
  1150. },
  1151. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1152. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1153. };
  1154. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1155. feedback.horizontal = "center";
  1156. }
  1157. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1158. feedback.vertical = "middle";
  1159. }
  1160. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1161. feedback.important = "horizontal";
  1162. } else {
  1163. feedback.important = "vertical";
  1164. }
  1165. options.using.call( this, props, feedback );
  1166. };
  1167. }
  1168.  
  1169. elem.offset( $.extend( position, { using: using } ) );
  1170. });
  1171. };
  1172.  
  1173. $.ui.position = {
  1174. fit: {
  1175. left: function( position, data ) {
  1176. var within = data.within,
  1177. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1178. outerWidth = within.width,
  1179. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1180. overLeft = withinOffset - collisionPosLeft,
  1181. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1182. newOverRight;
  1183.  
  1184. // element is wider than within
  1185. if ( data.collisionWidth > outerWidth ) {
  1186. // element is initially over the left side of within
  1187. if ( overLeft > 0 && overRight <= 0 ) {
  1188. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1189. position.left += overLeft - newOverRight;
  1190. // element is initially over right side of within
  1191. } else if ( overRight > 0 && overLeft <= 0 ) {
  1192. position.left = withinOffset;
  1193. // element is initially over both left and right sides of within
  1194. } else {
  1195. if ( overLeft > overRight ) {
  1196. position.left = withinOffset + outerWidth - data.collisionWidth;
  1197. } else {
  1198. position.left = withinOffset;
  1199. }
  1200. }
  1201. // too far left -> align with left edge
  1202. } else if ( overLeft > 0 ) {
  1203. position.left += overLeft;
  1204. // too far right -> align with right edge
  1205. } else if ( overRight > 0 ) {
  1206. position.left -= overRight;
  1207. // adjust based on position and margin
  1208. } else {
  1209. position.left = max( position.left - collisionPosLeft, position.left );
  1210. }
  1211. },
  1212. top: function( position, data ) {
  1213. var within = data.within,
  1214. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1215. outerHeight = data.within.height,
  1216. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1217. overTop = withinOffset - collisionPosTop,
  1218. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1219. newOverBottom;
  1220.  
  1221. // element is taller than within
  1222. if ( data.collisionHeight > outerHeight ) {
  1223. // element is initially over the top of within
  1224. if ( overTop > 0 && overBottom <= 0 ) {
  1225. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1226. position.top += overTop - newOverBottom;
  1227. // element is initially over bottom of within
  1228. } else if ( overBottom > 0 && overTop <= 0 ) {
  1229. position.top = withinOffset;
  1230. // element is initially over both top and bottom of within
  1231. } else {
  1232. if ( overTop > overBottom ) {
  1233. position.top = withinOffset + outerHeight - data.collisionHeight;
  1234. } else {
  1235. position.top = withinOffset;
  1236. }
  1237. }
  1238. // too far up -> align with top
  1239. } else if ( overTop > 0 ) {
  1240. position.top += overTop;
  1241. // too far down -> align with bottom edge
  1242. } else if ( overBottom > 0 ) {
  1243. position.top -= overBottom;
  1244. // adjust based on position and margin
  1245. } else {
  1246. position.top = max( position.top - collisionPosTop, position.top );
  1247. }
  1248. }
  1249. },
  1250. flip: {
  1251. left: function( position, data ) {
  1252. var within = data.within,
  1253. withinOffset = within.offset.left + within.scrollLeft,
  1254. outerWidth = within.width,
  1255. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1256. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1257. overLeft = collisionPosLeft - offsetLeft,
  1258. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1259. myOffset = data.my[ 0 ] === "left" ?
  1260. -data.elemWidth :
  1261. data.my[ 0 ] === "right" ?
  1262. data.elemWidth :
  1263. 0,
  1264. atOffset = data.at[ 0 ] === "left" ?
  1265. data.targetWidth :
  1266. data.at[ 0 ] === "right" ?
  1267. -data.targetWidth :
  1268. 0,
  1269. offset = -2 * data.offset[ 0 ],
  1270. newOverRight,
  1271. newOverLeft;
  1272.  
  1273. if ( overLeft < 0 ) {
  1274. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1275. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1276. position.left += myOffset + atOffset + offset;
  1277. }
  1278. } else if ( overRight > 0 ) {
  1279. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1280. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1281. position.left += myOffset + atOffset + offset;
  1282. }
  1283. }
  1284. },
  1285. top: function( position, data ) {
  1286. var within = data.within,
  1287. withinOffset = within.offset.top + within.scrollTop,
  1288. outerHeight = within.height,
  1289. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1290. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1291. overTop = collisionPosTop - offsetTop,
  1292. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1293. top = data.my[ 1 ] === "top",
  1294. myOffset = top ?
  1295. -data.elemHeight :
  1296. data.my[ 1 ] === "bottom" ?
  1297. data.elemHeight :
  1298. 0,
  1299. atOffset = data.at[ 1 ] === "top" ?
  1300. data.targetHeight :
  1301. data.at[ 1 ] === "bottom" ?
  1302. -data.targetHeight :
  1303. 0,
  1304. offset = -2 * data.offset[ 1 ],
  1305. newOverTop,
  1306. newOverBottom;
  1307. if ( overTop < 0 ) {
  1308. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1309. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1310. position.top += myOffset + atOffset + offset;
  1311. }
  1312. } else if ( overBottom > 0 ) {
  1313. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1314. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1315. position.top += myOffset + atOffset + offset;
  1316. }
  1317. }
  1318. }
  1319. },
  1320. flipfit: {
  1321. left: function() {
  1322. $.ui.position.flip.left.apply( this, arguments );
  1323. $.ui.position.fit.left.apply( this, arguments );
  1324. },
  1325. top: function() {
  1326. $.ui.position.flip.top.apply( this, arguments );
  1327. $.ui.position.fit.top.apply( this, arguments );
  1328. }
  1329. }
  1330. };
  1331.  
  1332. // fraction support test
  1333. (function() {
  1334. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1335. body = document.getElementsByTagName( "body" )[ 0 ],
  1336. div = document.createElement( "div" );
  1337.  
  1338. //Create a "fake body" for testing based on method used in jQuery.support
  1339. testElement = document.createElement( body ? "div" : "body" );
  1340. testElementStyle = {
  1341. visibility: "hidden",
  1342. width: 0,
  1343. height: 0,
  1344. border: 0,
  1345. margin: 0,
  1346. background: "none"
  1347. };
  1348. if ( body ) {
  1349. $.extend( testElementStyle, {
  1350. position: "absolute",
  1351. left: "-1000px",
  1352. top: "-1000px"
  1353. });
  1354. }
  1355. for ( i in testElementStyle ) {
  1356. testElement.style[ i ] = testElementStyle[ i ];
  1357. }
  1358. testElement.appendChild( div );
  1359. testElementParent = body || document.documentElement;
  1360. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1361.  
  1362. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1363.  
  1364. offsetLeft = $( div ).offset().left;
  1365. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1366.  
  1367. testElement.innerHTML = "";
  1368. testElementParent.removeChild( testElement );
  1369. })();
  1370.  
  1371. })();
  1372.  
  1373. var position = $.ui.position;
  1374.  
  1375.  
  1376. /*!
  1377. * jQuery UI Menu 1.11.3
  1378. * http://jqueryui.com
  1379. *
  1380. * Copyright jQuery Foundation and other contributors
  1381. * Released under the MIT license.
  1382. * http://jquery.org/license
  1383. *
  1384. * http://api.jqueryui.com/menu/
  1385. */
  1386.  
  1387.  
  1388. var menu = $.widget( "ui.menu", {
  1389. version: "1.11.3",
  1390. defaultElement: "<ul>",
  1391. delay: 300,
  1392. options: {
  1393. icons: {
  1394. submenu: "ui-icon-carat-1-e"
  1395. },
  1396. items: "> *",
  1397. menus: "ul",
  1398. position: {
  1399. my: "left-1 top",
  1400. at: "right top"
  1401. },
  1402. role: "menu",
  1403.  
  1404. // callbacks
  1405. blur: null,
  1406. focus: null,
  1407. select: null
  1408. },
  1409.  
  1410. _create: function() {
  1411. this.activeMenu = this.element;
  1412.  
  1413. // Flag used to prevent firing of the click handler
  1414. // as the event bubbles up through nested menus
  1415. this.mouseHandled = false;
  1416. this.element
  1417. .uniqueId()
  1418. .addClass( "ui-menu ui-widget ui-widget-content" )
  1419. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1420. .attr({
  1421. role: this.options.role,
  1422. tabIndex: 0
  1423. });
  1424.  
  1425. if ( this.options.disabled ) {
  1426. this.element
  1427. .addClass( "ui-state-disabled" )
  1428. .attr( "aria-disabled", "true" );
  1429. }
  1430.  
  1431. this._on({
  1432. // Prevent focus from sticking to links inside menu after clicking
  1433. // them (focus should always stay on UL during navigation).
  1434. "mousedown .ui-menu-item": function( event ) {
  1435. event.preventDefault();
  1436. },
  1437. "click .ui-menu-item": function( event ) {
  1438. var target = $( event.target );
  1439. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1440. this.select( event );
  1441.  
  1442. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1443. if ( !event.isPropagationStopped() ) {
  1444. this.mouseHandled = true;
  1445. }
  1446.  
  1447. // Open submenu on click
  1448. if ( target.has( ".ui-menu" ).length ) {
  1449. this.expand( event );
  1450. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1451.  
  1452. // Redirect focus to the menu
  1453. this.element.trigger( "focus", [ true ] );
  1454.  
  1455. // If the active item is on the top level, let it stay active.
  1456. // Otherwise, blur the active item since it is no longer visible.
  1457. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1458. clearTimeout( this.timer );
  1459. }
  1460. }
  1461. }
  1462. },
  1463. "mouseenter .ui-menu-item": function( event ) {
  1464. // Ignore mouse events while typeahead is active, see #10458.
  1465. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  1466. // is over an item in the menu
  1467. if ( this.previousFilter ) {
  1468. return;
  1469. }
  1470. var target = $( event.currentTarget );
  1471. // Remove ui-state-active class from siblings of the newly focused menu item
  1472. // to avoid a jump caused by adjacent elements both having a class with a border
  1473. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1474. this.focus( event, target );
  1475. },
  1476. mouseleave: "collapseAll",
  1477. "mouseleave .ui-menu": "collapseAll",
  1478. focus: function( event, keepActiveItem ) {
  1479. // If there's already an active item, keep it active
  1480. // If not, activate the first item
  1481. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1482.  
  1483. if ( !keepActiveItem ) {
  1484. this.focus( event, item );
  1485. }
  1486. },
  1487. blur: function( event ) {
  1488. this._delay(function() {
  1489. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1490. this.collapseAll( event );
  1491. }
  1492. });
  1493. },
  1494. keydown: "_keydown"
  1495. });
  1496.  
  1497. this.refresh();
  1498.  
  1499. // Clicks outside of a menu collapse any open menus
  1500. this._on( this.document, {
  1501. click: function( event ) {
  1502. if ( this._closeOnDocumentClick( event ) ) {
  1503. this.collapseAll( event );
  1504. }
  1505.  
  1506. // Reset the mouseHandled flag
  1507. this.mouseHandled = false;
  1508. }
  1509. });
  1510. },
  1511.  
  1512. _destroy: function() {
  1513. // Destroy (sub)menus
  1514. this.element
  1515. .removeAttr( "aria-activedescendant" )
  1516. .find( ".ui-menu" ).addBack()
  1517. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1518. .removeAttr( "role" )
  1519. .removeAttr( "tabIndex" )
  1520. .removeAttr( "aria-labelledby" )
  1521. .removeAttr( "aria-expanded" )
  1522. .removeAttr( "aria-hidden" )
  1523. .removeAttr( "aria-disabled" )
  1524. .removeUniqueId()
  1525. .show();
  1526.  
  1527. // Destroy menu items
  1528. this.element.find( ".ui-menu-item" )
  1529. .removeClass( "ui-menu-item" )
  1530. .removeAttr( "role" )
  1531. .removeAttr( "aria-disabled" )
  1532. .removeUniqueId()
  1533. .removeClass( "ui-state-hover" )
  1534. .removeAttr( "tabIndex" )
  1535. .removeAttr( "role" )
  1536. .removeAttr( "aria-haspopup" )
  1537. .children().each( function() {
  1538. var elem = $( this );
  1539. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  1540. elem.remove();
  1541. }
  1542. });
  1543.  
  1544. // Destroy menu dividers
  1545. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  1546. },
  1547.  
  1548. _keydown: function( event ) {
  1549. var match, prev, character, skip,
  1550. preventDefault = true;
  1551.  
  1552. switch ( event.keyCode ) {
  1553. case $.ui.keyCode.PAGE_UP:
  1554. this.previousPage( event );
  1555. break;
  1556. case $.ui.keyCode.PAGE_DOWN:
  1557. this.nextPage( event );
  1558. break;
  1559. case $.ui.keyCode.HOME:
  1560. this._move( "first", "first", event );
  1561. break;
  1562. case $.ui.keyCode.END:
  1563. this._move( "last", "last", event );
  1564. break;
  1565. case $.ui.keyCode.UP:
  1566. this.previous( event );
  1567. break;
  1568. case $.ui.keyCode.DOWN:
  1569. this.next( event );
  1570. break;
  1571. case $.ui.keyCode.LEFT:
  1572. this.collapse( event );
  1573. break;
  1574. case $.ui.keyCode.RIGHT:
  1575. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  1576. this.expand( event );
  1577. }
  1578. break;
  1579. case $.ui.keyCode.ENTER:
  1580. case $.ui.keyCode.SPACE:
  1581. this._activate( event );
  1582. break;
  1583. case $.ui.keyCode.ESCAPE:
  1584. this.collapse( event );
  1585. break;
  1586. default:
  1587. preventDefault = false;
  1588. prev = this.previousFilter || "";
  1589. character = String.fromCharCode( event.keyCode );
  1590. skip = false;
  1591.  
  1592. clearTimeout( this.filterTimer );
  1593.  
  1594. if ( character === prev ) {
  1595. skip = true;
  1596. } else {
  1597. character = prev + character;
  1598. }
  1599.  
  1600. match = this._filterMenuItems( character );
  1601. match = skip && match.index( this.active.next() ) !== -1 ?
  1602. this.active.nextAll( ".ui-menu-item" ) :
  1603. match;
  1604.  
  1605. // If no matches on the current filter, reset to the last character pressed
  1606. // to move down the menu to the first item that starts with that character
  1607. if ( !match.length ) {
  1608. character = String.fromCharCode( event.keyCode );
  1609. match = this._filterMenuItems( character );
  1610. }
  1611.  
  1612. if ( match.length ) {
  1613. this.focus( event, match );
  1614. this.previousFilter = character;
  1615. this.filterTimer = this._delay(function() {
  1616. delete this.previousFilter;
  1617. }, 1000 );
  1618. } else {
  1619. delete this.previousFilter;
  1620. }
  1621. }
  1622.  
  1623. if ( preventDefault ) {
  1624. event.preventDefault();
  1625. }
  1626. },
  1627.  
  1628. _activate: function( event ) {
  1629. if ( !this.active.is( ".ui-state-disabled" ) ) {
  1630. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  1631. this.expand( event );
  1632. } else {
  1633. this.select( event );
  1634. }
  1635. }
  1636. },
  1637.  
  1638. refresh: function() {
  1639. var menus, items,
  1640. that = this,
  1641. icon = this.options.icons.submenu,
  1642. submenus = this.element.find( this.options.menus );
  1643.  
  1644. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  1645.  
  1646. // Initialize nested menus
  1647. submenus.filter( ":not(.ui-menu)" )
  1648. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  1649. .hide()
  1650. .attr({
  1651. role: this.options.role,
  1652. "aria-hidden": "true",
  1653. "aria-expanded": "false"
  1654. })
  1655. .each(function() {
  1656. var menu = $( this ),
  1657. item = menu.parent(),
  1658. submenuCarat = $( "<span>" )
  1659. .addClass( "ui-menu-icon ui-icon " + icon )
  1660. .data( "ui-menu-submenu-carat", true );
  1661.  
  1662. item
  1663. .attr( "aria-haspopup", "true" )
  1664. .prepend( submenuCarat );
  1665. menu.attr( "aria-labelledby", item.attr( "id" ) );
  1666. });
  1667.  
  1668. menus = submenus.add( this.element );
  1669. items = menus.find( this.options.items );
  1670.  
  1671. // Initialize menu-items containing spaces and/or dashes only as dividers
  1672. items.not( ".ui-menu-item" ).each(function() {
  1673. var item = $( this );
  1674. if ( that._isDivider( item ) ) {
  1675. item.addClass( "ui-widget-content ui-menu-divider" );
  1676. }
  1677. });
  1678.  
  1679. // Don't refresh list items that are already adapted
  1680. items.not( ".ui-menu-item, .ui-menu-divider" )
  1681. .addClass( "ui-menu-item" )
  1682. .uniqueId()
  1683. .attr({
  1684. tabIndex: -1,
  1685. role: this._itemRole()
  1686. });
  1687.  
  1688. // Add aria-disabled attribute to any disabled menu item
  1689. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  1690.  
  1691. // If the active item has been removed, blur the menu
  1692. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1693. this.blur();
  1694. }
  1695. },
  1696.  
  1697. _itemRole: function() {
  1698. return {
  1699. menu: "menuitem",
  1700. listbox: "option"
  1701. }[ this.options.role ];
  1702. },
  1703.  
  1704. _setOption: function( key, value ) {
  1705. if ( key === "icons" ) {
  1706. this.element.find( ".ui-menu-icon" )
  1707. .removeClass( this.options.icons.submenu )
  1708. .addClass( value.submenu );
  1709. }
  1710. if ( key === "disabled" ) {
  1711. this.element
  1712. .toggleClass( "ui-state-disabled", !!value )
  1713. .attr( "aria-disabled", value );
  1714. }
  1715. this._super( key, value );
  1716. },
  1717.  
  1718. focus: function( event, item ) {
  1719. var nested, focused;
  1720. this.blur( event, event && event.type === "focus" );
  1721.  
  1722. this._scrollIntoView( item );
  1723.  
  1724. this.active = item.first();
  1725. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  1726. // Only update aria-activedescendant if there's a role
  1727. // otherwise we assume focus is managed elsewhere
  1728. if ( this.options.role ) {
  1729. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  1730. }
  1731.  
  1732. // Highlight active parent menu item, if any
  1733. this.active
  1734. .parent()
  1735. .closest( ".ui-menu-item" )
  1736. .addClass( "ui-state-active" );
  1737.  
  1738. if ( event && event.type === "keydown" ) {
  1739. this._close();
  1740. } else {
  1741. this.timer = this._delay(function() {
  1742. this._close();
  1743. }, this.delay );
  1744. }
  1745.  
  1746. nested = item.children( ".ui-menu" );
  1747. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  1748. this._startOpening(nested);
  1749. }
  1750. this.activeMenu = item.parent();
  1751.  
  1752. this._trigger( "focus", event, { item: item } );
  1753. },
  1754.  
  1755. _scrollIntoView: function( item ) {
  1756. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  1757. if ( this._hasScroll() ) {
  1758. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  1759. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  1760. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  1761. scroll = this.activeMenu.scrollTop();
  1762. elementHeight = this.activeMenu.height();
  1763. itemHeight = item.outerHeight();
  1764.  
  1765. if ( offset < 0 ) {
  1766. this.activeMenu.scrollTop( scroll + offset );
  1767. } else if ( offset + itemHeight > elementHeight ) {
  1768. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  1769. }
  1770. }
  1771. },
  1772.  
  1773. blur: function( event, fromFocus ) {
  1774. if ( !fromFocus ) {
  1775. clearTimeout( this.timer );
  1776. }
  1777.  
  1778. if ( !this.active ) {
  1779. return;
  1780. }
  1781.  
  1782. this.active.removeClass( "ui-state-focus" );
  1783. this.active = null;
  1784.  
  1785. this._trigger( "blur", event, { item: this.active } );
  1786. },
  1787.  
  1788. _startOpening: function( submenu ) {
  1789. clearTimeout( this.timer );
  1790.  
  1791. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  1792. // shift in the submenu position when mousing over the carat icon
  1793. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  1794. return;
  1795. }
  1796.  
  1797. this.timer = this._delay(function() {
  1798. this._close();
  1799. this._open( submenu );
  1800. }, this.delay );
  1801. },
  1802.  
  1803. _open: function( submenu ) {
  1804. var position = $.extend({
  1805. of: this.active
  1806. }, this.options.position );
  1807.  
  1808. clearTimeout( this.timer );
  1809. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  1810. .hide()
  1811. .attr( "aria-hidden", "true" );
  1812.  
  1813. submenu
  1814. .show()
  1815. .removeAttr( "aria-hidden" )
  1816. .attr( "aria-expanded", "true" )
  1817. .position( position );
  1818. },
  1819.  
  1820. collapseAll: function( event, all ) {
  1821. clearTimeout( this.timer );
  1822. this.timer = this._delay(function() {
  1823. // If we were passed an event, look for the submenu that contains the event
  1824. var currentMenu = all ? this.element :
  1825. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  1826.  
  1827. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  1828. if ( !currentMenu.length ) {
  1829. currentMenu = this.element;
  1830. }
  1831.  
  1832. this._close( currentMenu );
  1833.  
  1834. this.blur( event );
  1835. this.activeMenu = currentMenu;
  1836. }, this.delay );
  1837. },
  1838.  
  1839. // With no arguments, closes the currently active menu - if nothing is active
  1840. // it closes all menus. If passed an argument, it will search for menus BELOW
  1841. _close: function( startMenu ) {
  1842. if ( !startMenu ) {
  1843. startMenu = this.active ? this.active.parent() : this.element;
  1844. }
  1845.  
  1846. startMenu
  1847. .find( ".ui-menu" )
  1848. .hide()
  1849. .attr( "aria-hidden", "true" )
  1850. .attr( "aria-expanded", "false" )
  1851. .end()
  1852. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  1853. .removeClass( "ui-state-active" );
  1854. },
  1855.  
  1856. _closeOnDocumentClick: function( event ) {
  1857. return !$( event.target ).closest( ".ui-menu" ).length;
  1858. },
  1859.  
  1860. _isDivider: function( item ) {
  1861.  
  1862. // Match hyphen, em dash, en dash
  1863. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  1864. },
  1865.  
  1866. collapse: function( event ) {
  1867. var newItem = this.active &&
  1868. this.active.parent().closest( ".ui-menu-item", this.element );
  1869. if ( newItem && newItem.length ) {
  1870. this._close();
  1871. this.focus( event, newItem );
  1872. }
  1873. },
  1874.  
  1875. expand: function( event ) {
  1876. var newItem = this.active &&
  1877. this.active
  1878. .children( ".ui-menu " )
  1879. .find( this.options.items )
  1880. .first();
  1881.  
  1882. if ( newItem && newItem.length ) {
  1883. this._open( newItem.parent() );
  1884.  
  1885. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  1886. this._delay(function() {
  1887. this.focus( event, newItem );
  1888. });
  1889. }
  1890. },
  1891.  
  1892. next: function( event ) {
  1893. this._move( "next", "first", event );
  1894. },
  1895.  
  1896. previous: function( event ) {
  1897. this._move( "prev", "last", event );
  1898. },
  1899.  
  1900. isFirstItem: function() {
  1901. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  1902. },
  1903.  
  1904. isLastItem: function() {
  1905. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  1906. },
  1907.  
  1908. _move: function( direction, filter, event ) {
  1909. var next;
  1910. if ( this.active ) {
  1911. if ( direction === "first" || direction === "last" ) {
  1912. next = this.active
  1913. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  1914. .eq( -1 );
  1915. } else {
  1916. next = this.active
  1917. [ direction + "All" ]( ".ui-menu-item" )
  1918. .eq( 0 );
  1919. }
  1920. }
  1921. if ( !next || !next.length || !this.active ) {
  1922. next = this.activeMenu.find( this.options.items )[ filter ]();
  1923. }
  1924.  
  1925. this.focus( event, next );
  1926. },
  1927.  
  1928. nextPage: function( event ) {
  1929. var item, base, height;
  1930.  
  1931. if ( !this.active ) {
  1932. this.next( event );
  1933. return;
  1934. }
  1935. if ( this.isLastItem() ) {
  1936. return;
  1937. }
  1938. if ( this._hasScroll() ) {
  1939. base = this.active.offset().top;
  1940. height = this.element.height();
  1941. this.active.nextAll( ".ui-menu-item" ).each(function() {
  1942. item = $( this );
  1943. return item.offset().top - base - height < 0;
  1944. });
  1945.  
  1946. this.focus( event, item );
  1947. } else {
  1948. this.focus( event, this.activeMenu.find( this.options.items )
  1949. [ !this.active ? "first" : "last" ]() );
  1950. }
  1951. },
  1952.  
  1953. previousPage: function( event ) {
  1954. var item, base, height;
  1955. if ( !this.active ) {
  1956. this.next( event );
  1957. return;
  1958. }
  1959. if ( this.isFirstItem() ) {
  1960. return;
  1961. }
  1962. if ( this._hasScroll() ) {
  1963. base = this.active.offset().top;
  1964. height = this.element.height();
  1965. this.active.prevAll( ".ui-menu-item" ).each(function() {
  1966. item = $( this );
  1967. return item.offset().top - base + height > 0;
  1968. });
  1969.  
  1970. this.focus( event, item );
  1971. } else {
  1972. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  1973. }
  1974. },
  1975.  
  1976. _hasScroll: function() {
  1977. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  1978. },
  1979.  
  1980. select: function( event ) {
  1981. // TODO: It should never be possible to not have an active item at this
  1982. // point, but the tests don't trigger mouseenter before click.
  1983. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  1984. var ui = { item: this.active };
  1985. if ( !this.active.has( ".ui-menu" ).length ) {
  1986. this.collapseAll( event, true );
  1987. }
  1988. this._trigger( "select", event, ui );
  1989. },
  1990.  
  1991. _filterMenuItems: function(character) {
  1992. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  1993. regex = new RegExp( "^" + escapedCharacter, "i" );
  1994.  
  1995. return this.activeMenu
  1996. .find( this.options.items )
  1997.  
  1998. // Only match on items, not dividers or other content (#10571)
  1999. .filter( ".ui-menu-item" )
  2000. .filter(function() {
  2001. return regex.test( $.trim( $( this ).text() ) );
  2002. });
  2003. }
  2004. });
  2005.  
  2006.  
  2007. /*!
  2008. * jQuery UI Autocomplete 1.11.3
  2009. * http://jqueryui.com
  2010. *
  2011. * Copyright jQuery Foundation and other contributors
  2012. * Released under the MIT license.
  2013. * http://jquery.org/license
  2014. *
  2015. * http://api.jqueryui.com/autocomplete/
  2016. */
  2017.  
  2018.  
  2019. $.widget( "ui.autocomplete", {
  2020. version: "1.11.3",
  2021. defaultElement: "<input>",
  2022. options: {
  2023. appendTo: null,
  2024. autoFocus: false,
  2025. delay: 300,
  2026. minLength: 1,
  2027. position: {
  2028. my: "left top",
  2029. at: "left bottom",
  2030. collision: "none"
  2031. },
  2032. source: null,
  2033.  
  2034. // callbacks
  2035. change: null,
  2036. close: null,
  2037. focus: null,
  2038. open: null,
  2039. response: null,
  2040. search: null,
  2041. select: null
  2042. },
  2043.  
  2044. requestIndex: 0,
  2045. pending: 0,
  2046.  
  2047. _create: function() {
  2048. // Some browsers only repeat keydown events, not keypress events,
  2049. // so we use the suppressKeyPress flag to determine if we've already
  2050. // handled the keydown event. #7269
  2051. // Unfortunately the code for & in keypress is the same as the up arrow,
  2052. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  2053. // events when we know the keydown event was used to modify the
  2054. // search term. #7799
  2055. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  2056. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  2057. isTextarea = nodeName === "textarea",
  2058. isInput = nodeName === "input";
  2059.  
  2060. this.isMultiLine =
  2061. // Textareas are always multi-line
  2062. isTextarea ? true :
  2063. // Inputs are always single-line, even if inside a contentEditable element
  2064. // IE also treats inputs as contentEditable
  2065. isInput ? false :
  2066. // All other element types are determined by whether or not they're contentEditable
  2067. this.element.prop( "isContentEditable" );
  2068.  
  2069. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  2070. this.isNewMenu = true;
  2071.  
  2072. this.element
  2073. .addClass( "ui-autocomplete-input" )
  2074. .attr( "autocomplete", "off" );
  2075.  
  2076. this._on( this.element, {
  2077. keydown: function( event ) {
  2078. if ( this.element.prop( "readOnly" ) ) {
  2079. suppressKeyPress = true;
  2080. suppressInput = true;
  2081. suppressKeyPressRepeat = true;
  2082. return;
  2083. }
  2084.  
  2085. suppressKeyPress = false;
  2086. suppressInput = false;
  2087. suppressKeyPressRepeat = false;
  2088. var keyCode = $.ui.keyCode;
  2089. switch ( event.keyCode ) {
  2090. case keyCode.PAGE_UP:
  2091. suppressKeyPress = true;
  2092. this._move( "previousPage", event );
  2093. break;
  2094. case keyCode.PAGE_DOWN:
  2095. suppressKeyPress = true;
  2096. this._move( "nextPage", event );
  2097. break;
  2098. case keyCode.UP:
  2099. suppressKeyPress = true;
  2100. this._keyEvent( "previous", event );
  2101. break;
  2102. case keyCode.DOWN:
  2103. suppressKeyPress = true;
  2104. this._keyEvent( "next", event );
  2105. break;
  2106. case keyCode.ENTER:
  2107. // when menu is open and has focus
  2108. if ( this.menu.active ) {
  2109. // #6055 - Opera still allows the keypress to occur
  2110. // which causes forms to submit
  2111. suppressKeyPress = true;
  2112. event.preventDefault();
  2113. this.menu.select( event );
  2114. }
  2115. break;
  2116. case keyCode.TAB:
  2117. if ( this.menu.active ) {
  2118. this.menu.select( event );
  2119. }
  2120. break;
  2121. case keyCode.ESCAPE:
  2122. if ( this.menu.element.is( ":visible" ) ) {
  2123. if ( !this.isMultiLine ) {
  2124. this._value( this.term );
  2125. }
  2126. this.close( event );
  2127. // Different browsers have different default behavior for escape
  2128. // Single press can mean undo or clear
  2129. // Double press in IE means clear the whole form
  2130. event.preventDefault();
  2131. }
  2132. break;
  2133. default:
  2134. suppressKeyPressRepeat = true;
  2135. // search timeout should be triggered before the input value is changed
  2136. this._searchTimeout( event );
  2137. break;
  2138. }
  2139. },
  2140. keypress: function( event ) {
  2141. if ( suppressKeyPress ) {
  2142. suppressKeyPress = false;
  2143. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2144. event.preventDefault();
  2145. }
  2146. return;
  2147. }
  2148. if ( suppressKeyPressRepeat ) {
  2149. return;
  2150. }
  2151.  
  2152. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2153. var keyCode = $.ui.keyCode;
  2154. switch ( event.keyCode ) {
  2155. case keyCode.PAGE_UP:
  2156. this._move( "previousPage", event );
  2157. break;
  2158. case keyCode.PAGE_DOWN:
  2159. this._move( "nextPage", event );
  2160. break;
  2161. case keyCode.UP:
  2162. this._keyEvent( "previous", event );
  2163. break;
  2164. case keyCode.DOWN:
  2165. this._keyEvent( "next", event );
  2166. break;
  2167. }
  2168. },
  2169. input: function( event ) {
  2170. if ( suppressInput ) {
  2171. suppressInput = false;
  2172. event.preventDefault();
  2173. return;
  2174. }
  2175. this._searchTimeout( event );
  2176. },
  2177. focus: function() {
  2178. this.selectedItem = null;
  2179. this.previous = this._value();
  2180. },
  2181. blur: function( event ) {
  2182. if ( this.cancelBlur ) {
  2183. delete this.cancelBlur;
  2184. return;
  2185. }
  2186.  
  2187. clearTimeout( this.searching );
  2188. this.close( event );
  2189. this._change( event );
  2190. }
  2191. });
  2192.  
  2193. this._initSource();
  2194. this.menu = $( "<ul>" )
  2195. .addClass( "ui-autocomplete ui-front" )
  2196. .appendTo( this._appendTo() )
  2197. .menu({
  2198. // disable ARIA support, the live region takes care of that
  2199. role: null
  2200. })
  2201. .hide()
  2202. .menu( "instance" );
  2203.  
  2204. this._on( this.menu.element, {
  2205. mousedown: function( event ) {
  2206. // prevent moving focus out of the text field
  2207. event.preventDefault();
  2208.  
  2209. // IE doesn't prevent moving focus even with event.preventDefault()
  2210. // so we set a flag to know when we should ignore the blur event
  2211. this.cancelBlur = true;
  2212. this._delay(function() {
  2213. delete this.cancelBlur;
  2214. });
  2215.  
  2216. // clicking on the scrollbar causes focus to shift to the body
  2217. // but we can't detect a mouseup or a click immediately afterward
  2218. // so we have to track the next mousedown and close the menu if
  2219. // the user clicks somewhere outside of the autocomplete
  2220. var menuElement = this.menu.element[ 0 ];
  2221. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2222. this._delay(function() {
  2223. var that = this;
  2224. this.document.one( "mousedown", function( event ) {
  2225. if ( event.target !== that.element[ 0 ] &&
  2226. event.target !== menuElement &&
  2227. !$.contains( menuElement, event.target ) ) {
  2228. that.close();
  2229. }
  2230. });
  2231. });
  2232. }
  2233. },
  2234. menufocus: function( event, ui ) {
  2235. var label, item;
  2236. // support: Firefox
  2237. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  2238. if ( this.isNewMenu ) {
  2239. this.isNewMenu = false;
  2240. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2241. this.menu.blur();
  2242.  
  2243. this.document.one( "mousemove", function() {
  2244. $( event.target ).trigger( event.originalEvent );
  2245. });
  2246.  
  2247. return;
  2248. }
  2249. }
  2250.  
  2251. item = ui.item.data( "ui-autocomplete-item" );
  2252. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2253. // use value to match what will end up in the input, if it was a key event
  2254. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2255. this._value( item.value );
  2256. }
  2257. }
  2258.  
  2259. // Announce the value in the liveRegion
  2260. label = ui.item.attr( "aria-label" ) || item.value;
  2261. if ( label && $.trim( label ).length ) {
  2262. this.liveRegion.children().hide();
  2263. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  2264. }
  2265. },
  2266. menuselect: function( event, ui ) {
  2267. var item = ui.item.data( "ui-autocomplete-item" ),
  2268. previous = this.previous;
  2269.  
  2270. // only trigger when focus was lost (click on menu)
  2271. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2272. this.element.focus();
  2273. this.previous = previous;
  2274. // #6109 - IE triggers two focus events and the second
  2275. // is asynchronous, so we need to reset the previous
  2276. // term synchronously and asynchronously :-(
  2277. this._delay(function() {
  2278. this.previous = previous;
  2279. this.selectedItem = item;
  2280. });
  2281. }
  2282.  
  2283. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2284. this._value( item.value );
  2285. }
  2286. // reset the term after the select event
  2287. // this allows custom select handling to work properly
  2288. this.term = this._value();
  2289.  
  2290. this.close( event );
  2291. this.selectedItem = item;
  2292. }
  2293. });
  2294.  
  2295. this.liveRegion = $( "<span>", {
  2296. role: "status",
  2297. "aria-live": "assertive",
  2298. "aria-relevant": "additions"
  2299. })
  2300. .addClass( "ui-helper-hidden-accessible" )
  2301. .appendTo( this.document[ 0 ].body );
  2302.  
  2303. // turning off autocomplete prevents the browser from remembering the
  2304. // value when navigating through history, so we re-enable autocomplete
  2305. // if the page is unloaded before the widget is destroyed. #7790
  2306. this._on( this.window, {
  2307. beforeunload: function() {
  2308. this.element.removeAttr( "autocomplete" );
  2309. }
  2310. });
  2311. },
  2312.  
  2313. _destroy: function() {
  2314. clearTimeout( this.searching );
  2315. this.element
  2316. .removeClass( "ui-autocomplete-input" )
  2317. .removeAttr( "autocomplete" );
  2318. this.menu.element.remove();
  2319. this.liveRegion.remove();
  2320. },
  2321.  
  2322. _setOption: function( key, value ) {
  2323. this._super( key, value );
  2324. if ( key === "source" ) {
  2325. this._initSource();
  2326. }
  2327. if ( key === "appendTo" ) {
  2328. this.menu.element.appendTo( this._appendTo() );
  2329. }
  2330. if ( key === "disabled" && value && this.xhr ) {
  2331. this.xhr.abort();
  2332. }
  2333. },
  2334.  
  2335. _appendTo: function() {
  2336. var element = this.options.appendTo;
  2337.  
  2338. if ( element ) {
  2339. element = element.jquery || element.nodeType ?
  2340. $( element ) :
  2341. this.document.find( element ).eq( 0 );
  2342. }
  2343.  
  2344. if ( !element || !element[ 0 ] ) {
  2345. element = this.element.closest( ".ui-front" );
  2346. }
  2347.  
  2348. if ( !element.length ) {
  2349. element = this.document[ 0 ].body;
  2350. }
  2351.  
  2352. return element;
  2353. },
  2354.  
  2355. _initSource: function() {
  2356. var array, url,
  2357. that = this;
  2358. if ( $.isArray( this.options.source ) ) {
  2359. array = this.options.source;
  2360. this.source = function( request, response ) {
  2361. response( $.ui.autocomplete.filter( array, request.term ) );
  2362. };
  2363. } else if ( typeof this.options.source === "string" ) {
  2364. url = this.options.source;
  2365. this.source = function( request, response ) {
  2366. if ( that.xhr ) {
  2367. that.xhr.abort();
  2368. }
  2369. that.xhr = $.ajax({
  2370. url: url,
  2371. data: request,
  2372. dataType: "json",
  2373. success: function( data ) {
  2374. response( data );
  2375. },
  2376. error: function() {
  2377. response([]);
  2378. }
  2379. });
  2380. };
  2381. } else {
  2382. this.source = this.options.source;
  2383. }
  2384. },
  2385.  
  2386. _searchTimeout: function( event ) {
  2387. clearTimeout( this.searching );
  2388. this.searching = this._delay(function() {
  2389.  
  2390. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2391. var equalValues = this.term === this._value(),
  2392. menuVisible = this.menu.element.is( ":visible" ),
  2393. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2394.  
  2395. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2396. this.selectedItem = null;
  2397. this.search( null, event );
  2398. }
  2399. }, this.options.delay );
  2400. },
  2401.  
  2402. search: function( value, event ) {
  2403. value = value != null ? value : this._value();
  2404.  
  2405. // always save the actual value, not the one passed as an argument
  2406. this.term = this._value();
  2407.  
  2408. if ( value.length < this.options.minLength ) {
  2409. return this.close( event );
  2410. }
  2411.  
  2412. if ( this._trigger( "search", event ) === false ) {
  2413. return;
  2414. }
  2415.  
  2416. return this._search( value );
  2417. },
  2418.  
  2419. _search: function( value ) {
  2420. this.pending++;
  2421. this.element.addClass( "ui-autocomplete-loading" );
  2422. this.cancelSearch = false;
  2423.  
  2424. this.source( { term: value }, this._response() );
  2425. },
  2426.  
  2427. _response: function() {
  2428. var index = ++this.requestIndex;
  2429.  
  2430. return $.proxy(function( content ) {
  2431. if ( index === this.requestIndex ) {
  2432. this.__response( content );
  2433. }
  2434.  
  2435. this.pending--;
  2436. if ( !this.pending ) {
  2437. this.element.removeClass( "ui-autocomplete-loading" );
  2438. }
  2439. }, this );
  2440. },
  2441.  
  2442. __response: function( content ) {
  2443. if ( content ) {
  2444. content = this._normalize( content );
  2445. }
  2446. this._trigger( "response", null, { content: content } );
  2447. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2448. this._suggest( content );
  2449. this._trigger( "open" );
  2450. } else {
  2451. // use ._close() instead of .close() so we don't cancel future searches
  2452. this._close();
  2453. }
  2454. },
  2455.  
  2456. close: function( event ) {
  2457. this.cancelSearch = true;
  2458. this._close( event );
  2459. },
  2460.  
  2461. _close: function( event ) {
  2462. if ( this.menu.element.is( ":visible" ) ) {
  2463. this.menu.element.hide();
  2464. this.menu.blur();
  2465. this.isNewMenu = true;
  2466. this._trigger( "close", event );
  2467. }
  2468. },
  2469.  
  2470. _change: function( event ) {
  2471. if ( this.previous !== this._value() ) {
  2472. this._trigger( "change", event, { item: this.selectedItem } );
  2473. }
  2474. },
  2475.  
  2476. _normalize: function( items ) {
  2477. // assume all items have the right format when the first item is complete
  2478. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2479. return items;
  2480. }
  2481. return $.map( items, function( item ) {
  2482. if ( typeof item === "string" ) {
  2483. return {
  2484. label: item,
  2485. value: item
  2486. };
  2487. }
  2488. return $.extend( {}, item, {
  2489. label: item.label || item.value,
  2490. value: item.value || item.label
  2491. });
  2492. });
  2493. },
  2494.  
  2495. _suggest: function( items ) {
  2496. var ul = this.menu.element.empty();
  2497. this._renderMenu( ul, items );
  2498. this.isNewMenu = true;
  2499. this.menu.refresh();
  2500.  
  2501. // size and position menu
  2502. ul.show();
  2503. this._resizeMenu();
  2504. ul.position( $.extend({
  2505. of: this.element
  2506. }, this.options.position ) );
  2507.  
  2508. if ( this.options.autoFocus ) {
  2509. this.menu.next();
  2510. }
  2511. },
  2512.  
  2513. _resizeMenu: function() {
  2514. var ul = this.menu.element;
  2515. ul.outerWidth( Math.max(
  2516. // Firefox wraps long text (possibly a rounding bug)
  2517. // so we add 1px to avoid the wrapping (#7513)
  2518. ul.width( "" ).outerWidth() + 1,
  2519. this.element.outerWidth()
  2520. ) );
  2521. },
  2522.  
  2523. _renderMenu: function( ul, items ) {
  2524. var that = this;
  2525. $.each( items, function( index, item ) {
  2526. that._renderItemData( ul, item );
  2527. });
  2528. },
  2529.  
  2530. _renderItemData: function( ul, item ) {
  2531. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2532. },
  2533.  
  2534. _renderItem: function( ul, item ) {
  2535. return $( "<li>" ).text( item.label ).appendTo( ul );
  2536. },
  2537.  
  2538. _move: function( direction, event ) {
  2539. if ( !this.menu.element.is( ":visible" ) ) {
  2540. this.search( null, event );
  2541. return;
  2542. }
  2543. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2544. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2545.  
  2546. if ( !this.isMultiLine ) {
  2547. this._value( this.term );
  2548. }
  2549.  
  2550. this.menu.blur();
  2551. return;
  2552. }
  2553. this.menu[ direction ]( event );
  2554. },
  2555.  
  2556. widget: function() {
  2557. return this.menu.element;
  2558. },
  2559.  
  2560. _value: function() {
  2561. return this.valueMethod.apply( this.element, arguments );
  2562. },
  2563.  
  2564. _keyEvent: function( keyEvent, event ) {
  2565. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2566. this._move( keyEvent, event );
  2567.  
  2568. // prevents moving cursor to beginning/end of the text field in some browsers
  2569. event.preventDefault();
  2570. }
  2571. }
  2572. });
  2573.  
  2574. $.extend( $.ui.autocomplete, {
  2575. escapeRegex: function( value ) {
  2576. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2577. },
  2578. filter: function( array, term ) {
  2579. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2580. return $.grep( array, function( value ) {
  2581. return matcher.test( value.label || value.value || value );
  2582. });
  2583. }
  2584. });
  2585.  
  2586. // live region extension, adding a `messages` option
  2587. // NOTE: This is an experimental API. We are still investigating
  2588. // a full solution for string manipulation and internationalization.
  2589. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2590. options: {
  2591. messages: {
  2592. noResults: "No search results.",
  2593. results: function( amount ) {
  2594. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2595. " available, use up and down arrow keys to navigate.";
  2596. }
  2597. }
  2598. },
  2599.  
  2600. __response: function( content ) {
  2601. var message;
  2602. this._superApply( arguments );
  2603. if ( this.options.disabled || this.cancelSearch ) {
  2604. return;
  2605. }
  2606. if ( content && content.length ) {
  2607. message = this.options.messages.results( content.length );
  2608. } else {
  2609. message = this.options.messages.noResults;
  2610. }
  2611. this.liveRegion.children().hide();
  2612. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2613. }
  2614. });
  2615.  
  2616. var autocomplete = $.ui.autocomplete;
  2617.  
  2618.  
  2619.  
  2620. }));
  2621.  
  2622. }
  2623. if (window.document.readyState === 'complete') {
  2624. loadjQueryUIFullscreen();
  2625. } else {
  2626. window.addEventListener('load',loadjQueryUIFullscreen, false);
  2627. }