You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19046 lines
516KB

  1. /*! jQuery UI - v1.13.0 - 2021-10-07
  2. * http://jqueryui.com
  3. * Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. ( function( factory ) {
  6. "use strict";
  7. if ( typeof define === "function" && define.amd ) {
  8. // AMD. Register as an anonymous module.
  9. define( [ "jquery" ], factory );
  10. } else {
  11. // Browser globals
  12. factory( jQuery );
  13. }
  14. } )( function( $ ) {
  15. "use strict";
  16. $.ui = $.ui || {};
  17. var version = $.ui.version = "1.13.0";
  18. /*!
  19. * jQuery UI Widget 1.13.0
  20. * http://jqueryui.com
  21. *
  22. * Copyright jQuery Foundation and other contributors
  23. * Released under the MIT license.
  24. * http://jquery.org/license
  25. */
  26. //>>label: Widget
  27. //>>group: Core
  28. //>>description: Provides a factory for creating stateful widgets with a common API.
  29. //>>docs: http://api.jqueryui.com/jQuery.widget/
  30. //>>demos: http://jqueryui.com/widget/
  31. var widgetUuid = 0;
  32. var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
  33. var widgetSlice = Array.prototype.slice;
  34. $.cleanData = ( function( orig ) {
  35. return function( elems ) {
  36. var events, elem, i;
  37. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  38. // Only trigger remove when necessary to save time
  39. events = $._data( elem, "events" );
  40. if ( events && events.remove ) {
  41. $( elem ).triggerHandler( "remove" );
  42. }
  43. }
  44. orig( elems );
  45. };
  46. } )( $.cleanData );
  47. $.widget = function( name, base, prototype ) {
  48. var existingConstructor, constructor, basePrototype;
  49. // ProxiedPrototype allows the provided prototype to remain unmodified
  50. // so that it can be used as a mixin for multiple widgets (#8876)
  51. var proxiedPrototype = {};
  52. var namespace = name.split( "." )[ 0 ];
  53. name = name.split( "." )[ 1 ];
  54. var fullName = namespace + "-" + name;
  55. if ( !prototype ) {
  56. prototype = base;
  57. base = $.Widget;
  58. }
  59. if ( Array.isArray( prototype ) ) {
  60. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  61. }
  62. // Create selector for plugin
  63. $.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) {
  64. return !!$.data( elem, fullName );
  65. };
  66. $[ namespace ] = $[ namespace ] || {};
  67. existingConstructor = $[ namespace ][ name ];
  68. constructor = $[ namespace ][ name ] = function( options, element ) {
  69. // Allow instantiation without "new" keyword
  70. if ( !this._createWidget ) {
  71. return new constructor( options, element );
  72. }
  73. // Allow instantiation without initializing for simple inheritance
  74. // must use "new" keyword (the code above always passes args)
  75. if ( arguments.length ) {
  76. this._createWidget( options, element );
  77. }
  78. };
  79. // Extend with the existing constructor to carry over any static properties
  80. $.extend( constructor, existingConstructor, {
  81. version: prototype.version,
  82. // Copy the object used to create the prototype in case we need to
  83. // redefine the widget later
  84. _proto: $.extend( {}, prototype ),
  85. // Track widgets that inherit from this widget in case this widget is
  86. // redefined after a widget inherits from it
  87. _childConstructors: []
  88. } );
  89. basePrototype = new base();
  90. // We need to make the options hash a property directly on the new instance
  91. // otherwise we'll modify the options hash on the prototype that we're
  92. // inheriting from
  93. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  94. $.each( prototype, function( prop, value ) {
  95. if ( typeof value !== "function" ) {
  96. proxiedPrototype[ prop ] = value;
  97. return;
  98. }
  99. proxiedPrototype[ prop ] = ( function() {
  100. function _super() {
  101. return base.prototype[ prop ].apply( this, arguments );
  102. }
  103. function _superApply( args ) {
  104. return base.prototype[ prop ].apply( this, args );
  105. }
  106. return function() {
  107. var __super = this._super;
  108. var __superApply = this._superApply;
  109. var returnValue;
  110. this._super = _super;
  111. this._superApply = _superApply;
  112. returnValue = value.apply( this, arguments );
  113. this._super = __super;
  114. this._superApply = __superApply;
  115. return returnValue;
  116. };
  117. } )();
  118. } );
  119. constructor.prototype = $.widget.extend( basePrototype, {
  120. // TODO: remove support for widgetEventPrefix
  121. // always use the name + a colon as the prefix, e.g., draggable:start
  122. // don't prefix for widgets that aren't DOM-based
  123. widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
  124. }, proxiedPrototype, {
  125. constructor: constructor,
  126. namespace: namespace,
  127. widgetName: name,
  128. widgetFullName: fullName
  129. } );
  130. // If this widget is being redefined then we need to find all widgets that
  131. // are inheriting from it and redefine all of them so that they inherit from
  132. // the new version of this widget. We're essentially trying to replace one
  133. // level in the prototype chain.
  134. if ( existingConstructor ) {
  135. $.each( existingConstructor._childConstructors, function( i, child ) {
  136. var childPrototype = child.prototype;
  137. // Redefine the child widget using the same prototype that was
  138. // originally used, but inherit from the new version of the base
  139. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
  140. child._proto );
  141. } );
  142. // Remove the list of existing child constructors from the old constructor
  143. // so the old child constructors can be garbage collected
  144. delete existingConstructor._childConstructors;
  145. } else {
  146. base._childConstructors.push( constructor );
  147. }
  148. $.widget.bridge( name, constructor );
  149. return constructor;
  150. };
  151. $.widget.extend = function( target ) {
  152. var input = widgetSlice.call( arguments, 1 );
  153. var inputIndex = 0;
  154. var inputLength = input.length;
  155. var key;
  156. var value;
  157. for ( ; inputIndex < inputLength; inputIndex++ ) {
  158. for ( key in input[ inputIndex ] ) {
  159. value = input[ inputIndex ][ key ];
  160. if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) {
  161. // Clone objects
  162. if ( $.isPlainObject( value ) ) {
  163. target[ key ] = $.isPlainObject( target[ key ] ) ?
  164. $.widget.extend( {}, target[ key ], value ) :
  165. // Don't extend strings, arrays, etc. with objects
  166. $.widget.extend( {}, value );
  167. // Copy everything else by reference
  168. } else {
  169. target[ key ] = value;
  170. }
  171. }
  172. }
  173. }
  174. return target;
  175. };
  176. $.widget.bridge = function( name, object ) {
  177. var fullName = object.prototype.widgetFullName || name;
  178. $.fn[ name ] = function( options ) {
  179. var isMethodCall = typeof options === "string";
  180. var args = widgetSlice.call( arguments, 1 );
  181. var returnValue = this;
  182. if ( isMethodCall ) {
  183. // If this is an empty collection, we need to have the instance method
  184. // return undefined instead of the jQuery instance
  185. if ( !this.length && options === "instance" ) {
  186. returnValue = undefined;
  187. } else {
  188. this.each( function() {
  189. var methodValue;
  190. var instance = $.data( this, fullName );
  191. if ( options === "instance" ) {
  192. returnValue = instance;
  193. return false;
  194. }
  195. if ( !instance ) {
  196. return $.error( "cannot call methods on " + name +
  197. " prior to initialization; " +
  198. "attempted to call method '" + options + "'" );
  199. }
  200. if ( typeof instance[ options ] !== "function" ||
  201. options.charAt( 0 ) === "_" ) {
  202. return $.error( "no such method '" + options + "' for " + name +
  203. " widget instance" );
  204. }
  205. methodValue = instance[ options ].apply( instance, args );
  206. if ( methodValue !== instance && methodValue !== undefined ) {
  207. returnValue = methodValue && methodValue.jquery ?
  208. returnValue.pushStack( methodValue.get() ) :
  209. methodValue;
  210. return false;
  211. }
  212. } );
  213. }
  214. } else {
  215. // Allow multiple hashes to be passed on init
  216. if ( args.length ) {
  217. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  218. }
  219. this.each( function() {
  220. var instance = $.data( this, fullName );
  221. if ( instance ) {
  222. instance.option( options || {} );
  223. if ( instance._init ) {
  224. instance._init();
  225. }
  226. } else {
  227. $.data( this, fullName, new object( options, this ) );
  228. }
  229. } );
  230. }
  231. return returnValue;
  232. };
  233. };
  234. $.Widget = function( /* options, element */ ) {};
  235. $.Widget._childConstructors = [];
  236. $.Widget.prototype = {
  237. widgetName: "widget",
  238. widgetEventPrefix: "",
  239. defaultElement: "<div>",
  240. options: {
  241. classes: {},
  242. disabled: false,
  243. // Callbacks
  244. create: null
  245. },
  246. _createWidget: function( options, element ) {
  247. element = $( element || this.defaultElement || this )[ 0 ];
  248. this.element = $( element );
  249. this.uuid = widgetUuid++;
  250. this.eventNamespace = "." + this.widgetName + this.uuid;
  251. this.bindings = $();
  252. this.hoverable = $();
  253. this.focusable = $();
  254. this.classesElementLookup = {};
  255. if ( element !== this ) {
  256. $.data( element, this.widgetFullName, this );
  257. this._on( true, this.element, {
  258. remove: function( event ) {
  259. if ( event.target === element ) {
  260. this.destroy();
  261. }
  262. }
  263. } );
  264. this.document = $( element.style ?
  265. // Element within the document
  266. element.ownerDocument :
  267. // Element is window or document
  268. element.document || element );
  269. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  270. }
  271. this.options = $.widget.extend( {},
  272. this.options,
  273. this._getCreateOptions(),
  274. options );
  275. this._create();
  276. if ( this.options.disabled ) {
  277. this._setOptionDisabled( this.options.disabled );
  278. }
  279. this._trigger( "create", null, this._getCreateEventData() );
  280. this._init();
  281. },
  282. _getCreateOptions: function() {
  283. return {};
  284. },
  285. _getCreateEventData: $.noop,
  286. _create: $.noop,
  287. _init: $.noop,
  288. destroy: function() {
  289. var that = this;
  290. this._destroy();
  291. $.each( this.classesElementLookup, function( key, value ) {
  292. that._removeClass( value, key );
  293. } );
  294. // We can probably remove the unbind calls in 2.0
  295. // all event bindings should go through this._on()
  296. this.element
  297. .off( this.eventNamespace )
  298. .removeData( this.widgetFullName );
  299. this.widget()
  300. .off( this.eventNamespace )
  301. .removeAttr( "aria-disabled" );
  302. // Clean up events and states
  303. this.bindings.off( this.eventNamespace );
  304. },
  305. _destroy: $.noop,
  306. widget: function() {
  307. return this.element;
  308. },
  309. option: function( key, value ) {
  310. var options = key;
  311. var parts;
  312. var curOption;
  313. var i;
  314. if ( arguments.length === 0 ) {
  315. // Don't return a reference to the internal hash
  316. return $.widget.extend( {}, this.options );
  317. }
  318. if ( typeof key === "string" ) {
  319. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  320. options = {};
  321. parts = key.split( "." );
  322. key = parts.shift();
  323. if ( parts.length ) {
  324. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  325. for ( i = 0; i < parts.length - 1; i++ ) {
  326. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  327. curOption = curOption[ parts[ i ] ];
  328. }
  329. key = parts.pop();
  330. if ( arguments.length === 1 ) {
  331. return curOption[ key ] === undefined ? null : curOption[ key ];
  332. }
  333. curOption[ key ] = value;
  334. } else {
  335. if ( arguments.length === 1 ) {
  336. return this.options[ key ] === undefined ? null : this.options[ key ];
  337. }
  338. options[ key ] = value;
  339. }
  340. }
  341. this._setOptions( options );
  342. return this;
  343. },
  344. _setOptions: function( options ) {
  345. var key;
  346. for ( key in options ) {
  347. this._setOption( key, options[ key ] );
  348. }
  349. return this;
  350. },
  351. _setOption: function( key, value ) {
  352. if ( key === "classes" ) {
  353. this._setOptionClasses( value );
  354. }
  355. this.options[ key ] = value;
  356. if ( key === "disabled" ) {
  357. this._setOptionDisabled( value );
  358. }
  359. return this;
  360. },
  361. _setOptionClasses: function( value ) {
  362. var classKey, elements, currentElements;
  363. for ( classKey in value ) {
  364. currentElements = this.classesElementLookup[ classKey ];
  365. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  366. !currentElements ||
  367. !currentElements.length ) {
  368. continue;
  369. }
  370. // We are doing this to create a new jQuery object because the _removeClass() call
  371. // on the next line is going to destroy the reference to the current elements being
  372. // tracked. We need to save a copy of this collection so that we can add the new classes
  373. // below.
  374. elements = $( currentElements.get() );
  375. this._removeClass( currentElements, classKey );
  376. // We don't use _addClass() here, because that uses this.options.classes
  377. // for generating the string of classes. We want to use the value passed in from
  378. // _setOption(), this is the new value of the classes option which was passed to
  379. // _setOption(). We pass this value directly to _classes().
  380. elements.addClass( this._classes( {
  381. element: elements,
  382. keys: classKey,
  383. classes: value,
  384. add: true
  385. } ) );
  386. }
  387. },
  388. _setOptionDisabled: function( value ) {
  389. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  390. // If the widget is becoming disabled, then nothing is interactive
  391. if ( value ) {
  392. this._removeClass( this.hoverable, null, "ui-state-hover" );
  393. this._removeClass( this.focusable, null, "ui-state-focus" );
  394. }
  395. },
  396. enable: function() {
  397. return this._setOptions( { disabled: false } );
  398. },
  399. disable: function() {
  400. return this._setOptions( { disabled: true } );
  401. },
  402. _classes: function( options ) {
  403. var full = [];
  404. var that = this;
  405. options = $.extend( {
  406. element: this.element,
  407. classes: this.options.classes || {}
  408. }, options );
  409. function bindRemoveEvent() {
  410. options.element.each( function( _, element ) {
  411. var isTracked = $.map( that.classesElementLookup, function( elements ) {
  412. return elements;
  413. } )
  414. .some( function( elements ) {
  415. return elements.is( element );
  416. } );
  417. if ( !isTracked ) {
  418. that._on( $( element ), {
  419. remove: "_untrackClassesElement"
  420. } );
  421. }
  422. } );
  423. }
  424. function processClassString( classes, checkOption ) {
  425. var current, i;
  426. for ( i = 0; i < classes.length; i++ ) {
  427. current = that.classesElementLookup[ classes[ i ] ] || $();
  428. if ( options.add ) {
  429. bindRemoveEvent();
  430. current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) );
  431. } else {
  432. current = $( current.not( options.element ).get() );
  433. }
  434. that.classesElementLookup[ classes[ i ] ] = current;
  435. full.push( classes[ i ] );
  436. if ( checkOption && options.classes[ classes[ i ] ] ) {
  437. full.push( options.classes[ classes[ i ] ] );
  438. }
  439. }
  440. }
  441. if ( options.keys ) {
  442. processClassString( options.keys.match( /\S+/g ) || [], true );
  443. }
  444. if ( options.extra ) {
  445. processClassString( options.extra.match( /\S+/g ) || [] );
  446. }
  447. return full.join( " " );
  448. },
  449. _untrackClassesElement: function( event ) {
  450. var that = this;
  451. $.each( that.classesElementLookup, function( key, value ) {
  452. if ( $.inArray( event.target, value ) !== -1 ) {
  453. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  454. }
  455. } );
  456. this._off( $( event.target ) );
  457. },
  458. _removeClass: function( element, keys, extra ) {
  459. return this._toggleClass( element, keys, extra, false );
  460. },
  461. _addClass: function( element, keys, extra ) {
  462. return this._toggleClass( element, keys, extra, true );
  463. },
  464. _toggleClass: function( element, keys, extra, add ) {
  465. add = ( typeof add === "boolean" ) ? add : extra;
  466. var shift = ( typeof element === "string" || element === null ),
  467. options = {
  468. extra: shift ? keys : extra,
  469. keys: shift ? element : keys,
  470. element: shift ? this.element : element,
  471. add: add
  472. };
  473. options.element.toggleClass( this._classes( options ), add );
  474. return this;
  475. },
  476. _on: function( suppressDisabledCheck, element, handlers ) {
  477. var delegateElement;
  478. var instance = this;
  479. // No suppressDisabledCheck flag, shuffle arguments
  480. if ( typeof suppressDisabledCheck !== "boolean" ) {
  481. handlers = element;
  482. element = suppressDisabledCheck;
  483. suppressDisabledCheck = false;
  484. }
  485. // No element argument, shuffle and use this.element
  486. if ( !handlers ) {
  487. handlers = element;
  488. element = this.element;
  489. delegateElement = this.widget();
  490. } else {
  491. element = delegateElement = $( element );
  492. this.bindings = this.bindings.add( element );
  493. }
  494. $.each( handlers, function( event, handler ) {
  495. function handlerProxy() {
  496. // Allow widgets to customize the disabled handling
  497. // - disabled as an array instead of boolean
  498. // - disabled class as method for disabling individual parts
  499. if ( !suppressDisabledCheck &&
  500. ( instance.options.disabled === true ||
  501. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  502. return;
  503. }
  504. return ( typeof handler === "string" ? instance[ handler ] : handler )
  505. .apply( instance, arguments );
  506. }
  507. // Copy the guid so direct unbinding works
  508. if ( typeof handler !== "string" ) {
  509. handlerProxy.guid = handler.guid =
  510. handler.guid || handlerProxy.guid || $.guid++;
  511. }
  512. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  513. var eventName = match[ 1 ] + instance.eventNamespace;
  514. var selector = match[ 2 ];
  515. if ( selector ) {
  516. delegateElement.on( eventName, selector, handlerProxy );
  517. } else {
  518. element.on( eventName, handlerProxy );
  519. }
  520. } );
  521. },
  522. _off: function( element, eventName ) {
  523. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  524. this.eventNamespace;
  525. element.off( eventName );
  526. // Clear the stack to avoid memory leaks (#10056)
  527. this.bindings = $( this.bindings.not( element ).get() );
  528. this.focusable = $( this.focusable.not( element ).get() );
  529. this.hoverable = $( this.hoverable.not( element ).get() );
  530. },
  531. _delay: function( handler, delay ) {
  532. function handlerProxy() {
  533. return ( typeof handler === "string" ? instance[ handler ] : handler )
  534. .apply( instance, arguments );
  535. }
  536. var instance = this;
  537. return setTimeout( handlerProxy, delay || 0 );
  538. },
  539. _hoverable: function( element ) {
  540. this.hoverable = this.hoverable.add( element );
  541. this._on( element, {
  542. mouseenter: function( event ) {
  543. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  544. },
  545. mouseleave: function( event ) {
  546. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  547. }
  548. } );
  549. },
  550. _focusable: function( element ) {
  551. this.focusable = this.focusable.add( element );
  552. this._on( element, {
  553. focusin: function( event ) {
  554. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  555. },
  556. focusout: function( event ) {
  557. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  558. }
  559. } );
  560. },
  561. _trigger: function( type, event, data ) {
  562. var prop, orig;
  563. var callback = this.options[ type ];
  564. data = data || {};
  565. event = $.Event( event );
  566. event.type = ( type === this.widgetEventPrefix ?
  567. type :
  568. this.widgetEventPrefix + type ).toLowerCase();
  569. // The original event may come from any element
  570. // so we need to reset the target on the new event
  571. event.target = this.element[ 0 ];
  572. // Copy original event properties over to the new event
  573. orig = event.originalEvent;
  574. if ( orig ) {
  575. for ( prop in orig ) {
  576. if ( !( prop in event ) ) {
  577. event[ prop ] = orig[ prop ];
  578. }
  579. }
  580. }
  581. this.element.trigger( event, data );
  582. return !( typeof callback === "function" &&
  583. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  584. event.isDefaultPrevented() );
  585. }
  586. };
  587. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  588. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  589. if ( typeof options === "string" ) {
  590. options = { effect: options };
  591. }
  592. var hasOptions;
  593. var effectName = !options ?
  594. method :
  595. options === true || typeof options === "number" ?
  596. defaultEffect :
  597. options.effect || defaultEffect;
  598. options = options || {};
  599. if ( typeof options === "number" ) {
  600. options = { duration: options };
  601. } else if ( options === true ) {
  602. options = {};
  603. }
  604. hasOptions = !$.isEmptyObject( options );
  605. options.complete = callback;
  606. if ( options.delay ) {
  607. element.delay( options.delay );
  608. }
  609. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  610. element[ method ]( options );
  611. } else if ( effectName !== method && element[ effectName ] ) {
  612. element[ effectName ]( options.duration, options.easing, callback );
  613. } else {
  614. element.queue( function( next ) {
  615. $( this )[ method ]();
  616. if ( callback ) {
  617. callback.call( element[ 0 ] );
  618. }
  619. next();
  620. } );
  621. }
  622. };
  623. } );
  624. var widget = $.widget;
  625. /*!
  626. * jQuery UI Position 1.13.0
  627. * http://jqueryui.com
  628. *
  629. * Copyright jQuery Foundation and other contributors
  630. * Released under the MIT license.
  631. * http://jquery.org/license
  632. *
  633. * http://api.jqueryui.com/position/
  634. */
  635. //>>label: Position
  636. //>>group: Core
  637. //>>description: Positions elements relative to other elements.
  638. //>>docs: http://api.jqueryui.com/position/
  639. //>>demos: http://jqueryui.com/position/
  640. ( function() {
  641. var cachedScrollbarWidth,
  642. max = Math.max,
  643. abs = Math.abs,
  644. rhorizontal = /left|center|right/,
  645. rvertical = /top|center|bottom/,
  646. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  647. rposition = /^\w+/,
  648. rpercent = /%$/,
  649. _position = $.fn.position;
  650. function getOffsets( offsets, width, height ) {
  651. return [
  652. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  653. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  654. ];
  655. }
  656. function parseCss( element, property ) {
  657. return parseInt( $.css( element, property ), 10 ) || 0;
  658. }
  659. function isWindow( obj ) {
  660. return obj != null && obj === obj.window;
  661. }
  662. function getDimensions( elem ) {
  663. var raw = elem[ 0 ];
  664. if ( raw.nodeType === 9 ) {
  665. return {
  666. width: elem.width(),
  667. height: elem.height(),
  668. offset: { top: 0, left: 0 }
  669. };
  670. }
  671. if ( isWindow( raw ) ) {
  672. return {
  673. width: elem.width(),
  674. height: elem.height(),
  675. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  676. };
  677. }
  678. if ( raw.preventDefault ) {
  679. return {
  680. width: 0,
  681. height: 0,
  682. offset: { top: raw.pageY, left: raw.pageX }
  683. };
  684. }
  685. return {
  686. width: elem.outerWidth(),
  687. height: elem.outerHeight(),
  688. offset: elem.offset()
  689. };
  690. }
  691. $.position = {
  692. scrollbarWidth: function() {
  693. if ( cachedScrollbarWidth !== undefined ) {
  694. return cachedScrollbarWidth;
  695. }
  696. var w1, w2,
  697. div = $( "<div style=" +
  698. "'display:block;position:absolute;width:200px;height:200px;overflow:hidden;'>" +
  699. "<div style='height:300px;width:auto;'></div></div>" ),
  700. innerDiv = div.children()[ 0 ];
  701. $( "body" ).append( div );
  702. w1 = innerDiv.offsetWidth;
  703. div.css( "overflow", "scroll" );
  704. w2 = innerDiv.offsetWidth;
  705. if ( w1 === w2 ) {
  706. w2 = div[ 0 ].clientWidth;
  707. }
  708. div.remove();
  709. return ( cachedScrollbarWidth = w1 - w2 );
  710. },
  711. getScrollInfo: function( within ) {
  712. var overflowX = within.isWindow || within.isDocument ? "" :
  713. within.element.css( "overflow-x" ),
  714. overflowY = within.isWindow || within.isDocument ? "" :
  715. within.element.css( "overflow-y" ),
  716. hasOverflowX = overflowX === "scroll" ||
  717. ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
  718. hasOverflowY = overflowY === "scroll" ||
  719. ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
  720. return {
  721. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  722. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  723. };
  724. },
  725. getWithinInfo: function( element ) {
  726. var withinElement = $( element || window ),
  727. isElemWindow = isWindow( withinElement[ 0 ] ),
  728. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
  729. hasOffset = !isElemWindow && !isDocument;
  730. return {
  731. element: withinElement,
  732. isWindow: isElemWindow,
  733. isDocument: isDocument,
  734. offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
  735. scrollLeft: withinElement.scrollLeft(),
  736. scrollTop: withinElement.scrollTop(),
  737. width: withinElement.outerWidth(),
  738. height: withinElement.outerHeight()
  739. };
  740. }
  741. };
  742. $.fn.position = function( options ) {
  743. if ( !options || !options.of ) {
  744. return _position.apply( this, arguments );
  745. }
  746. // Make a copy, we don't want to modify arguments
  747. options = $.extend( {}, options );
  748. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  749. // Make sure string options are treated as CSS selectors
  750. target = typeof options.of === "string" ?
  751. $( document ).find( options.of ) :
  752. $( options.of ),
  753. within = $.position.getWithinInfo( options.within ),
  754. scrollInfo = $.position.getScrollInfo( within ),
  755. collision = ( options.collision || "flip" ).split( " " ),
  756. offsets = {};
  757. dimensions = getDimensions( target );
  758. if ( target[ 0 ].preventDefault ) {
  759. // Force left top to allow flipping
  760. options.at = "left top";
  761. }
  762. targetWidth = dimensions.width;
  763. targetHeight = dimensions.height;
  764. targetOffset = dimensions.offset;
  765. // Clone to reuse original targetOffset later
  766. basePosition = $.extend( {}, targetOffset );
  767. // Force my and at to have valid horizontal and vertical positions
  768. // if a value is missing or invalid, it will be converted to center
  769. $.each( [ "my", "at" ], function() {
  770. var pos = ( options[ this ] || "" ).split( " " ),
  771. horizontalOffset,
  772. verticalOffset;
  773. if ( pos.length === 1 ) {
  774. pos = rhorizontal.test( pos[ 0 ] ) ?
  775. pos.concat( [ "center" ] ) :
  776. rvertical.test( pos[ 0 ] ) ?
  777. [ "center" ].concat( pos ) :
  778. [ "center", "center" ];
  779. }
  780. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  781. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  782. // Calculate offsets
  783. horizontalOffset = roffset.exec( pos[ 0 ] );
  784. verticalOffset = roffset.exec( pos[ 1 ] );
  785. offsets[ this ] = [
  786. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  787. verticalOffset ? verticalOffset[ 0 ] : 0
  788. ];
  789. // Reduce to just the positions without the offsets
  790. options[ this ] = [
  791. rposition.exec( pos[ 0 ] )[ 0 ],
  792. rposition.exec( pos[ 1 ] )[ 0 ]
  793. ];
  794. } );
  795. // Normalize collision option
  796. if ( collision.length === 1 ) {
  797. collision[ 1 ] = collision[ 0 ];
  798. }
  799. if ( options.at[ 0 ] === "right" ) {
  800. basePosition.left += targetWidth;
  801. } else if ( options.at[ 0 ] === "center" ) {
  802. basePosition.left += targetWidth / 2;
  803. }
  804. if ( options.at[ 1 ] === "bottom" ) {
  805. basePosition.top += targetHeight;
  806. } else if ( options.at[ 1 ] === "center" ) {
  807. basePosition.top += targetHeight / 2;
  808. }
  809. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  810. basePosition.left += atOffset[ 0 ];
  811. basePosition.top += atOffset[ 1 ];
  812. return this.each( function() {
  813. var collisionPosition, using,
  814. elem = $( this ),
  815. elemWidth = elem.outerWidth(),
  816. elemHeight = elem.outerHeight(),
  817. marginLeft = parseCss( this, "marginLeft" ),
  818. marginTop = parseCss( this, "marginTop" ),
  819. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
  820. scrollInfo.width,
  821. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
  822. scrollInfo.height,
  823. position = $.extend( {}, basePosition ),
  824. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  825. if ( options.my[ 0 ] === "right" ) {
  826. position.left -= elemWidth;
  827. } else if ( options.my[ 0 ] === "center" ) {
  828. position.left -= elemWidth / 2;
  829. }
  830. if ( options.my[ 1 ] === "bottom" ) {
  831. position.top -= elemHeight;
  832. } else if ( options.my[ 1 ] === "center" ) {
  833. position.top -= elemHeight / 2;
  834. }
  835. position.left += myOffset[ 0 ];
  836. position.top += myOffset[ 1 ];
  837. collisionPosition = {
  838. marginLeft: marginLeft,
  839. marginTop: marginTop
  840. };
  841. $.each( [ "left", "top" ], function( i, dir ) {
  842. if ( $.ui.position[ collision[ i ] ] ) {
  843. $.ui.position[ collision[ i ] ][ dir ]( position, {
  844. targetWidth: targetWidth,
  845. targetHeight: targetHeight,
  846. elemWidth: elemWidth,
  847. elemHeight: elemHeight,
  848. collisionPosition: collisionPosition,
  849. collisionWidth: collisionWidth,
  850. collisionHeight: collisionHeight,
  851. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  852. my: options.my,
  853. at: options.at,
  854. within: within,
  855. elem: elem
  856. } );
  857. }
  858. } );
  859. if ( options.using ) {
  860. // Adds feedback as second argument to using callback, if present
  861. using = function( props ) {
  862. var left = targetOffset.left - position.left,
  863. right = left + targetWidth - elemWidth,
  864. top = targetOffset.top - position.top,
  865. bottom = top + targetHeight - elemHeight,
  866. feedback = {
  867. target: {
  868. element: target,
  869. left: targetOffset.left,
  870. top: targetOffset.top,
  871. width: targetWidth,
  872. height: targetHeight
  873. },
  874. element: {
  875. element: elem,
  876. left: position.left,
  877. top: position.top,
  878. width: elemWidth,
  879. height: elemHeight
  880. },
  881. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  882. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  883. };
  884. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  885. feedback.horizontal = "center";
  886. }
  887. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  888. feedback.vertical = "middle";
  889. }
  890. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  891. feedback.important = "horizontal";
  892. } else {
  893. feedback.important = "vertical";
  894. }
  895. options.using.call( this, props, feedback );
  896. };
  897. }
  898. elem.offset( $.extend( position, { using: using } ) );
  899. } );
  900. };
  901. $.ui.position = {
  902. fit: {
  903. left: function( position, data ) {
  904. var within = data.within,
  905. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  906. outerWidth = within.width,
  907. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  908. overLeft = withinOffset - collisionPosLeft,
  909. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  910. newOverRight;
  911. // Element is wider than within
  912. if ( data.collisionWidth > outerWidth ) {
  913. // Element is initially over the left side of within
  914. if ( overLeft > 0 && overRight <= 0 ) {
  915. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  916. withinOffset;
  917. position.left += overLeft - newOverRight;
  918. // Element is initially over right side of within
  919. } else if ( overRight > 0 && overLeft <= 0 ) {
  920. position.left = withinOffset;
  921. // Element is initially over both left and right sides of within
  922. } else {
  923. if ( overLeft > overRight ) {
  924. position.left = withinOffset + outerWidth - data.collisionWidth;
  925. } else {
  926. position.left = withinOffset;
  927. }
  928. }
  929. // Too far left -> align with left edge
  930. } else if ( overLeft > 0 ) {
  931. position.left += overLeft;
  932. // Too far right -> align with right edge
  933. } else if ( overRight > 0 ) {
  934. position.left -= overRight;
  935. // Adjust based on position and margin
  936. } else {
  937. position.left = max( position.left - collisionPosLeft, position.left );
  938. }
  939. },
  940. top: function( position, data ) {
  941. var within = data.within,
  942. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  943. outerHeight = data.within.height,
  944. collisionPosTop = position.top - data.collisionPosition.marginTop,
  945. overTop = withinOffset - collisionPosTop,
  946. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  947. newOverBottom;
  948. // Element is taller than within
  949. if ( data.collisionHeight > outerHeight ) {
  950. // Element is initially over the top of within
  951. if ( overTop > 0 && overBottom <= 0 ) {
  952. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  953. withinOffset;
  954. position.top += overTop - newOverBottom;
  955. // Element is initially over bottom of within
  956. } else if ( overBottom > 0 && overTop <= 0 ) {
  957. position.top = withinOffset;
  958. // Element is initially over both top and bottom of within
  959. } else {
  960. if ( overTop > overBottom ) {
  961. position.top = withinOffset + outerHeight - data.collisionHeight;
  962. } else {
  963. position.top = withinOffset;
  964. }
  965. }
  966. // Too far up -> align with top
  967. } else if ( overTop > 0 ) {
  968. position.top += overTop;
  969. // Too far down -> align with bottom edge
  970. } else if ( overBottom > 0 ) {
  971. position.top -= overBottom;
  972. // Adjust based on position and margin
  973. } else {
  974. position.top = max( position.top - collisionPosTop, position.top );
  975. }
  976. }
  977. },
  978. flip: {
  979. left: function( position, data ) {
  980. var within = data.within,
  981. withinOffset = within.offset.left + within.scrollLeft,
  982. outerWidth = within.width,
  983. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  984. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  985. overLeft = collisionPosLeft - offsetLeft,
  986. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  987. myOffset = data.my[ 0 ] === "left" ?
  988. -data.elemWidth :
  989. data.my[ 0 ] === "right" ?
  990. data.elemWidth :
  991. 0,
  992. atOffset = data.at[ 0 ] === "left" ?
  993. data.targetWidth :
  994. data.at[ 0 ] === "right" ?
  995. -data.targetWidth :
  996. 0,
  997. offset = -2 * data.offset[ 0 ],
  998. newOverRight,
  999. newOverLeft;
  1000. if ( overLeft < 0 ) {
  1001. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  1002. outerWidth - withinOffset;
  1003. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1004. position.left += myOffset + atOffset + offset;
  1005. }
  1006. } else if ( overRight > 0 ) {
  1007. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  1008. atOffset + offset - offsetLeft;
  1009. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1010. position.left += myOffset + atOffset + offset;
  1011. }
  1012. }
  1013. },
  1014. top: function( position, data ) {
  1015. var within = data.within,
  1016. withinOffset = within.offset.top + within.scrollTop,
  1017. outerHeight = within.height,
  1018. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1019. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1020. overTop = collisionPosTop - offsetTop,
  1021. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1022. top = data.my[ 1 ] === "top",
  1023. myOffset = top ?
  1024. -data.elemHeight :
  1025. data.my[ 1 ] === "bottom" ?
  1026. data.elemHeight :
  1027. 0,
  1028. atOffset = data.at[ 1 ] === "top" ?
  1029. data.targetHeight :
  1030. data.at[ 1 ] === "bottom" ?
  1031. -data.targetHeight :
  1032. 0,
  1033. offset = -2 * data.offset[ 1 ],
  1034. newOverTop,
  1035. newOverBottom;
  1036. if ( overTop < 0 ) {
  1037. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  1038. outerHeight - withinOffset;
  1039. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1040. position.top += myOffset + atOffset + offset;
  1041. }
  1042. } else if ( overBottom > 0 ) {
  1043. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  1044. offset - offsetTop;
  1045. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1046. position.top += myOffset + atOffset + offset;
  1047. }
  1048. }
  1049. }
  1050. },
  1051. flipfit: {
  1052. left: function() {
  1053. $.ui.position.flip.left.apply( this, arguments );
  1054. $.ui.position.fit.left.apply( this, arguments );
  1055. },
  1056. top: function() {
  1057. $.ui.position.flip.top.apply( this, arguments );
  1058. $.ui.position.fit.top.apply( this, arguments );
  1059. }
  1060. }
  1061. };
  1062. } )();
  1063. var position = $.ui.position;
  1064. /*!
  1065. * jQuery UI :data 1.13.0
  1066. * http://jqueryui.com
  1067. *
  1068. * Copyright jQuery Foundation and other contributors
  1069. * Released under the MIT license.
  1070. * http://jquery.org/license
  1071. */
  1072. //>>label: :data Selector
  1073. //>>group: Core
  1074. //>>description: Selects elements which have data stored under the specified key.
  1075. //>>docs: http://api.jqueryui.com/data-selector/
  1076. var data = $.extend( $.expr.pseudos, {
  1077. data: $.expr.createPseudo ?
  1078. $.expr.createPseudo( function( dataName ) {
  1079. return function( elem ) {
  1080. return !!$.data( elem, dataName );
  1081. };
  1082. } ) :
  1083. // Support: jQuery <1.8
  1084. function( elem, i, match ) {
  1085. return !!$.data( elem, match[ 3 ] );
  1086. }
  1087. } );
  1088. /*!
  1089. * jQuery UI Disable Selection 1.13.0
  1090. * http://jqueryui.com
  1091. *
  1092. * Copyright jQuery Foundation and other contributors
  1093. * Released under the MIT license.
  1094. * http://jquery.org/license
  1095. */
  1096. //>>label: disableSelection
  1097. //>>group: Core
  1098. //>>description: Disable selection of text content within the set of matched elements.
  1099. //>>docs: http://api.jqueryui.com/disableSelection/
  1100. // This file is deprecated
  1101. var disableSelection = $.fn.extend( {
  1102. disableSelection: ( function() {
  1103. var eventType = "onselectstart" in document.createElement( "div" ) ?
  1104. "selectstart" :
  1105. "mousedown";
  1106. return function() {
  1107. return this.on( eventType + ".ui-disableSelection", function( event ) {
  1108. event.preventDefault();
  1109. } );
  1110. };
  1111. } )(),
  1112. enableSelection: function() {
  1113. return this.off( ".ui-disableSelection" );
  1114. }
  1115. } );
  1116. // Create a local jQuery because jQuery Color relies on it and the
  1117. // global may not exist with AMD and a custom build (#10199).
  1118. // This module is a noop if used as a regular AMD module.
  1119. // eslint-disable-next-line no-unused-vars
  1120. var jQuery = $;
  1121. /*!
  1122. * jQuery Color Animations v2.2.0
  1123. * https://github.com/jquery/jquery-color
  1124. *
  1125. * Copyright OpenJS Foundation and other contributors
  1126. * Released under the MIT license.
  1127. * http://jquery.org/license
  1128. *
  1129. * Date: Sun May 10 09:02:36 2020 +0200
  1130. */
  1131. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  1132. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  1133. class2type = {},
  1134. toString = class2type.toString,
  1135. // plusequals test for += 100 -= 100
  1136. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  1137. // a set of RE's that can match strings and generate color tuples.
  1138. stringParsers = [ {
  1139. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1140. parse: function( execResult ) {
  1141. return [
  1142. execResult[ 1 ],
  1143. execResult[ 2 ],
  1144. execResult[ 3 ],
  1145. execResult[ 4 ]
  1146. ];
  1147. }
  1148. }, {
  1149. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1150. parse: function( execResult ) {
  1151. return [
  1152. execResult[ 1 ] * 2.55,
  1153. execResult[ 2 ] * 2.55,
  1154. execResult[ 3 ] * 2.55,
  1155. execResult[ 4 ]
  1156. ];
  1157. }
  1158. }, {
  1159. // this regex ignores A-F because it's compared against an already lowercased string
  1160. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/,
  1161. parse: function( execResult ) {
  1162. return [
  1163. parseInt( execResult[ 1 ], 16 ),
  1164. parseInt( execResult[ 2 ], 16 ),
  1165. parseInt( execResult[ 3 ], 16 ),
  1166. execResult[ 4 ] ?
  1167. ( parseInt( execResult[ 4 ], 16 ) / 255 ).toFixed( 2 ) :
  1168. 1
  1169. ];
  1170. }
  1171. }, {
  1172. // this regex ignores A-F because it's compared against an already lowercased string
  1173. re: /#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/,
  1174. parse: function( execResult ) {
  1175. return [
  1176. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  1177. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  1178. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ),
  1179. execResult[ 4 ] ?
  1180. ( parseInt( execResult[ 4 ] + execResult[ 4 ], 16 ) / 255 )
  1181. .toFixed( 2 ) :
  1182. 1
  1183. ];
  1184. }
  1185. }, {
  1186. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1187. space: "hsla",
  1188. parse: function( execResult ) {
  1189. return [
  1190. execResult[ 1 ],
  1191. execResult[ 2 ] / 100,
  1192. execResult[ 3 ] / 100,
  1193. execResult[ 4 ]
  1194. ];
  1195. }
  1196. } ],
  1197. // jQuery.Color( )
  1198. color = jQuery.Color = function( color, green, blue, alpha ) {
  1199. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  1200. },
  1201. spaces = {
  1202. rgba: {
  1203. props: {
  1204. red: {
  1205. idx: 0,
  1206. type: "byte"
  1207. },
  1208. green: {
  1209. idx: 1,
  1210. type: "byte"
  1211. },
  1212. blue: {
  1213. idx: 2,
  1214. type: "byte"
  1215. }
  1216. }
  1217. },
  1218. hsla: {
  1219. props: {
  1220. hue: {
  1221. idx: 0,
  1222. type: "degrees"
  1223. },
  1224. saturation: {
  1225. idx: 1,
  1226. type: "percent"
  1227. },
  1228. lightness: {
  1229. idx: 2,
  1230. type: "percent"
  1231. }
  1232. }
  1233. }
  1234. },
  1235. propTypes = {
  1236. "byte": {
  1237. floor: true,
  1238. max: 255
  1239. },
  1240. "percent": {
  1241. max: 1
  1242. },
  1243. "degrees": {
  1244. mod: 360,
  1245. floor: true
  1246. }
  1247. },
  1248. support = color.support = {},
  1249. // element for support tests
  1250. supportElem = jQuery( "<p>" )[ 0 ],
  1251. // colors = jQuery.Color.names
  1252. colors,
  1253. // local aliases of functions called often
  1254. each = jQuery.each;
  1255. // determine rgba support immediately
  1256. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  1257. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  1258. // define cache name and alpha properties
  1259. // for rgba and hsla spaces
  1260. each( spaces, function( spaceName, space ) {
  1261. space.cache = "_" + spaceName;
  1262. space.props.alpha = {
  1263. idx: 3,
  1264. type: "percent",
  1265. def: 1
  1266. };
  1267. } );
  1268. // Populate the class2type map
  1269. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  1270. function( _i, name ) {
  1271. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  1272. } );
  1273. function getType( obj ) {
  1274. if ( obj == null ) {
  1275. return obj + "";
  1276. }
  1277. return typeof obj === "object" ?
  1278. class2type[ toString.call( obj ) ] || "object" :
  1279. typeof obj;
  1280. }
  1281. function clamp( value, prop, allowEmpty ) {
  1282. var type = propTypes[ prop.type ] || {};
  1283. if ( value == null ) {
  1284. return ( allowEmpty || !prop.def ) ? null : prop.def;
  1285. }
  1286. // ~~ is an short way of doing floor for positive numbers
  1287. value = type.floor ? ~~value : parseFloat( value );
  1288. // IE will pass in empty strings as value for alpha,
  1289. // which will hit this case
  1290. if ( isNaN( value ) ) {
  1291. return prop.def;
  1292. }
  1293. if ( type.mod ) {
  1294. // we add mod before modding to make sure that negatives values
  1295. // get converted properly: -10 -> 350
  1296. return ( value + type.mod ) % type.mod;
  1297. }
  1298. // for now all property types without mod have min and max
  1299. return Math.min( type.max, Math.max( 0, value ) );
  1300. }
  1301. function stringParse( string ) {
  1302. var inst = color(),
  1303. rgba = inst._rgba = [];
  1304. string = string.toLowerCase();
  1305. each( stringParsers, function( _i, parser ) {
  1306. var parsed,
  1307. match = parser.re.exec( string ),
  1308. values = match && parser.parse( match ),
  1309. spaceName = parser.space || "rgba";
  1310. if ( values ) {
  1311. parsed = inst[ spaceName ]( values );
  1312. // if this was an rgba parse the assignment might happen twice
  1313. // oh well....
  1314. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  1315. rgba = inst._rgba = parsed._rgba;
  1316. // exit each( stringParsers ) here because we matched
  1317. return false;
  1318. }
  1319. } );
  1320. // Found a stringParser that handled it
  1321. if ( rgba.length ) {
  1322. // if this came from a parsed string, force "transparent" when alpha is 0
  1323. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  1324. if ( rgba.join() === "0,0,0,0" ) {
  1325. jQuery.extend( rgba, colors.transparent );
  1326. }
  1327. return inst;
  1328. }
  1329. // named colors
  1330. return colors[ string ];
  1331. }
  1332. color.fn = jQuery.extend( color.prototype, {
  1333. parse: function( red, green, blue, alpha ) {
  1334. if ( red === undefined ) {
  1335. this._rgba = [ null, null, null, null ];
  1336. return this;
  1337. }
  1338. if ( red.jquery || red.nodeType ) {
  1339. red = jQuery( red ).css( green );
  1340. green = undefined;
  1341. }
  1342. var inst = this,
  1343. type = getType( red ),
  1344. rgba = this._rgba = [];
  1345. // more than 1 argument specified - assume ( red, green, blue, alpha )
  1346. if ( green !== undefined ) {
  1347. red = [ red, green, blue, alpha ];
  1348. type = "array";
  1349. }
  1350. if ( type === "string" ) {
  1351. return this.parse( stringParse( red ) || colors._default );
  1352. }
  1353. if ( type === "array" ) {
  1354. each( spaces.rgba.props, function( _key, prop ) {
  1355. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  1356. } );
  1357. return this;
  1358. }
  1359. if ( type === "object" ) {
  1360. if ( red instanceof color ) {
  1361. each( spaces, function( _spaceName, space ) {
  1362. if ( red[ space.cache ] ) {
  1363. inst[ space.cache ] = red[ space.cache ].slice();
  1364. }
  1365. } );
  1366. } else {
  1367. each( spaces, function( _spaceName, space ) {
  1368. var cache = space.cache;
  1369. each( space.props, function( key, prop ) {
  1370. // if the cache doesn't exist, and we know how to convert
  1371. if ( !inst[ cache ] && space.to ) {
  1372. // if the value was null, we don't need to copy it
  1373. // if the key was alpha, we don't need to copy it either
  1374. if ( key === "alpha" || red[ key ] == null ) {
  1375. return;
  1376. }
  1377. inst[ cache ] = space.to( inst._rgba );
  1378. }
  1379. // this is the only case where we allow nulls for ALL properties.
  1380. // call clamp with alwaysAllowEmpty
  1381. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  1382. } );
  1383. // everything defined but alpha?
  1384. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  1385. // use the default of 1
  1386. if ( inst[ cache ][ 3 ] == null ) {
  1387. inst[ cache ][ 3 ] = 1;
  1388. }
  1389. if ( space.from ) {
  1390. inst._rgba = space.from( inst[ cache ] );
  1391. }
  1392. }
  1393. } );
  1394. }
  1395. return this;
  1396. }
  1397. },
  1398. is: function( compare ) {
  1399. var is = color( compare ),
  1400. same = true,
  1401. inst = this;
  1402. each( spaces, function( _, space ) {
  1403. var localCache,
  1404. isCache = is[ space.cache ];
  1405. if ( isCache ) {
  1406. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  1407. each( space.props, function( _, prop ) {
  1408. if ( isCache[ prop.idx ] != null ) {
  1409. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  1410. return same;
  1411. }
  1412. } );
  1413. }
  1414. return same;
  1415. } );
  1416. return same;
  1417. },
  1418. _space: function() {
  1419. var used = [],
  1420. inst = this;
  1421. each( spaces, function( spaceName, space ) {
  1422. if ( inst[ space.cache ] ) {
  1423. used.push( spaceName );
  1424. }
  1425. } );
  1426. return used.pop();
  1427. },
  1428. transition: function( other, distance ) {
  1429. var end = color( other ),
  1430. spaceName = end._space(),
  1431. space = spaces[ spaceName ],
  1432. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  1433. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  1434. result = start.slice();
  1435. end = end[ space.cache ];
  1436. each( space.props, function( _key, prop ) {
  1437. var index = prop.idx,
  1438. startValue = start[ index ],
  1439. endValue = end[ index ],
  1440. type = propTypes[ prop.type ] || {};
  1441. // if null, don't override start value
  1442. if ( endValue === null ) {
  1443. return;
  1444. }
  1445. // if null - use end
  1446. if ( startValue === null ) {
  1447. result[ index ] = endValue;
  1448. } else {
  1449. if ( type.mod ) {
  1450. if ( endValue - startValue > type.mod / 2 ) {
  1451. startValue += type.mod;
  1452. } else if ( startValue - endValue > type.mod / 2 ) {
  1453. startValue -= type.mod;
  1454. }
  1455. }
  1456. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  1457. }
  1458. } );
  1459. return this[ spaceName ]( result );
  1460. },
  1461. blend: function( opaque ) {
  1462. // if we are already opaque - return ourself
  1463. if ( this._rgba[ 3 ] === 1 ) {
  1464. return this;
  1465. }
  1466. var rgb = this._rgba.slice(),
  1467. a = rgb.pop(),
  1468. blend = color( opaque )._rgba;
  1469. return color( jQuery.map( rgb, function( v, i ) {
  1470. return ( 1 - a ) * blend[ i ] + a * v;
  1471. } ) );
  1472. },
  1473. toRgbaString: function() {
  1474. var prefix = "rgba(",
  1475. rgba = jQuery.map( this._rgba, function( v, i ) {
  1476. if ( v != null ) {
  1477. return v;
  1478. }
  1479. return i > 2 ? 1 : 0;
  1480. } );
  1481. if ( rgba[ 3 ] === 1 ) {
  1482. rgba.pop();
  1483. prefix = "rgb(";
  1484. }
  1485. return prefix + rgba.join() + ")";
  1486. },
  1487. toHslaString: function() {
  1488. var prefix = "hsla(",
  1489. hsla = jQuery.map( this.hsla(), function( v, i ) {
  1490. if ( v == null ) {
  1491. v = i > 2 ? 1 : 0;
  1492. }
  1493. // catch 1 and 2
  1494. if ( i && i < 3 ) {
  1495. v = Math.round( v * 100 ) + "%";
  1496. }
  1497. return v;
  1498. } );
  1499. if ( hsla[ 3 ] === 1 ) {
  1500. hsla.pop();
  1501. prefix = "hsl(";
  1502. }
  1503. return prefix + hsla.join() + ")";
  1504. },
  1505. toHexString: function( includeAlpha ) {
  1506. var rgba = this._rgba.slice(),
  1507. alpha = rgba.pop();
  1508. if ( includeAlpha ) {
  1509. rgba.push( ~~( alpha * 255 ) );
  1510. }
  1511. return "#" + jQuery.map( rgba, function( v ) {
  1512. // default to 0 when nulls exist
  1513. v = ( v || 0 ).toString( 16 );
  1514. return v.length === 1 ? "0" + v : v;
  1515. } ).join( "" );
  1516. },
  1517. toString: function() {
  1518. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  1519. }
  1520. } );
  1521. color.fn.parse.prototype = color.fn;
  1522. // hsla conversions adapted from:
  1523. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  1524. function hue2rgb( p, q, h ) {
  1525. h = ( h + 1 ) % 1;
  1526. if ( h * 6 < 1 ) {
  1527. return p + ( q - p ) * h * 6;
  1528. }
  1529. if ( h * 2 < 1 ) {
  1530. return q;
  1531. }
  1532. if ( h * 3 < 2 ) {
  1533. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  1534. }
  1535. return p;
  1536. }
  1537. spaces.hsla.to = function( rgba ) {
  1538. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  1539. return [ null, null, null, rgba[ 3 ] ];
  1540. }
  1541. var r = rgba[ 0 ] / 255,
  1542. g = rgba[ 1 ] / 255,
  1543. b = rgba[ 2 ] / 255,
  1544. a = rgba[ 3 ],
  1545. max = Math.max( r, g, b ),
  1546. min = Math.min( r, g, b ),
  1547. diff = max - min,
  1548. add = max + min,
  1549. l = add * 0.5,
  1550. h, s;
  1551. if ( min === max ) {
  1552. h = 0;
  1553. } else if ( r === max ) {
  1554. h = ( 60 * ( g - b ) / diff ) + 360;
  1555. } else if ( g === max ) {
  1556. h = ( 60 * ( b - r ) / diff ) + 120;
  1557. } else {
  1558. h = ( 60 * ( r - g ) / diff ) + 240;
  1559. }
  1560. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  1561. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  1562. if ( diff === 0 ) {
  1563. s = 0;
  1564. } else if ( l <= 0.5 ) {
  1565. s = diff / add;
  1566. } else {
  1567. s = diff / ( 2 - add );
  1568. }
  1569. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  1570. };
  1571. spaces.hsla.from = function( hsla ) {
  1572. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  1573. return [ null, null, null, hsla[ 3 ] ];
  1574. }
  1575. var h = hsla[ 0 ] / 360,
  1576. s = hsla[ 1 ],
  1577. l = hsla[ 2 ],
  1578. a = hsla[ 3 ],
  1579. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  1580. p = 2 * l - q;
  1581. return [
  1582. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  1583. Math.round( hue2rgb( p, q, h ) * 255 ),
  1584. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  1585. a
  1586. ];
  1587. };
  1588. each( spaces, function( spaceName, space ) {
  1589. var props = space.props,
  1590. cache = space.cache,
  1591. to = space.to,
  1592. from = space.from;
  1593. // makes rgba() and hsla()
  1594. color.fn[ spaceName ] = function( value ) {
  1595. // generate a cache for this space if it doesn't exist
  1596. if ( to && !this[ cache ] ) {
  1597. this[ cache ] = to( this._rgba );
  1598. }
  1599. if ( value === undefined ) {
  1600. return this[ cache ].slice();
  1601. }
  1602. var ret,
  1603. type = getType( value ),
  1604. arr = ( type === "array" || type === "object" ) ? value : arguments,
  1605. local = this[ cache ].slice();
  1606. each( props, function( key, prop ) {
  1607. var val = arr[ type === "object" ? key : prop.idx ];
  1608. if ( val == null ) {
  1609. val = local[ prop.idx ];
  1610. }
  1611. local[ prop.idx ] = clamp( val, prop );
  1612. } );
  1613. if ( from ) {
  1614. ret = color( from( local ) );
  1615. ret[ cache ] = local;
  1616. return ret;
  1617. } else {
  1618. return color( local );
  1619. }
  1620. };
  1621. // makes red() green() blue() alpha() hue() saturation() lightness()
  1622. each( props, function( key, prop ) {
  1623. // alpha is included in more than one space
  1624. if ( color.fn[ key ] ) {
  1625. return;
  1626. }
  1627. color.fn[ key ] = function( value ) {
  1628. var local, cur, match, fn,
  1629. vtype = getType( value );
  1630. if ( key === "alpha" ) {
  1631. fn = this._hsla ? "hsla" : "rgba";
  1632. } else {
  1633. fn = spaceName;
  1634. }
  1635. local = this[ fn ]();
  1636. cur = local[ prop.idx ];
  1637. if ( vtype === "undefined" ) {
  1638. return cur;
  1639. }
  1640. if ( vtype === "function" ) {
  1641. value = value.call( this, cur );
  1642. vtype = getType( value );
  1643. }
  1644. if ( value == null && prop.empty ) {
  1645. return this;
  1646. }
  1647. if ( vtype === "string" ) {
  1648. match = rplusequals.exec( value );
  1649. if ( match ) {
  1650. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  1651. }
  1652. }
  1653. local[ prop.idx ] = value;
  1654. return this[ fn ]( local );
  1655. };
  1656. } );
  1657. } );
  1658. // add cssHook and .fx.step function for each named hook.
  1659. // accept a space separated string of properties
  1660. color.hook = function( hook ) {
  1661. var hooks = hook.split( " " );
  1662. each( hooks, function( _i, hook ) {
  1663. jQuery.cssHooks[ hook ] = {
  1664. set: function( elem, value ) {
  1665. var parsed, curElem,
  1666. backgroundColor = "";
  1667. if ( value !== "transparent" && ( getType( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  1668. value = color( parsed || value );
  1669. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  1670. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  1671. while (
  1672. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  1673. curElem && curElem.style
  1674. ) {
  1675. try {
  1676. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  1677. curElem = curElem.parentNode;
  1678. } catch ( e ) {
  1679. }
  1680. }
  1681. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  1682. backgroundColor :
  1683. "_default" );
  1684. }
  1685. value = value.toRgbaString();
  1686. }
  1687. try {
  1688. elem.style[ hook ] = value;
  1689. } catch ( e ) {
  1690. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  1691. }
  1692. }
  1693. };
  1694. jQuery.fx.step[ hook ] = function( fx ) {
  1695. if ( !fx.colorInit ) {
  1696. fx.start = color( fx.elem, hook );
  1697. fx.end = color( fx.end );
  1698. fx.colorInit = true;
  1699. }
  1700. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  1701. };
  1702. } );
  1703. };
  1704. color.hook( stepHooks );
  1705. jQuery.cssHooks.borderColor = {
  1706. expand: function( value ) {
  1707. var expanded = {};
  1708. each( [ "Top", "Right", "Bottom", "Left" ], function( _i, part ) {
  1709. expanded[ "border" + part + "Color" ] = value;
  1710. } );
  1711. return expanded;
  1712. }
  1713. };
  1714. // Basic color names only.
  1715. // Usage of any of the other color names requires adding yourself or including
  1716. // jquery.color.svg-names.js.
  1717. colors = jQuery.Color.names = {
  1718. // 4.1. Basic color keywords
  1719. aqua: "#00ffff",
  1720. black: "#000000",
  1721. blue: "#0000ff",
  1722. fuchsia: "#ff00ff",
  1723. gray: "#808080",
  1724. green: "#008000",
  1725. lime: "#00ff00",
  1726. maroon: "#800000",
  1727. navy: "#000080",
  1728. olive: "#808000",
  1729. purple: "#800080",
  1730. red: "#ff0000",
  1731. silver: "#c0c0c0",
  1732. teal: "#008080",
  1733. white: "#ffffff",
  1734. yellow: "#ffff00",
  1735. // 4.2.3. "transparent" color keyword
  1736. transparent: [ null, null, null, 0 ],
  1737. _default: "#ffffff"
  1738. };
  1739. /*!
  1740. * jQuery UI Effects 1.13.0
  1741. * http://jqueryui.com
  1742. *
  1743. * Copyright jQuery Foundation and other contributors
  1744. * Released under the MIT license.
  1745. * http://jquery.org/license
  1746. */
  1747. //>>label: Effects Core
  1748. //>>group: Effects
  1749. /* eslint-disable max-len */
  1750. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  1751. /* eslint-enable max-len */
  1752. //>>docs: http://api.jqueryui.com/category/effects-core/
  1753. //>>demos: http://jqueryui.com/effect/
  1754. var dataSpace = "ui-effects-",
  1755. dataSpaceStyle = "ui-effects-style",
  1756. dataSpaceAnimated = "ui-effects-animated";
  1757. $.effects = {
  1758. effect: {}
  1759. };
  1760. /******************************************************************************/
  1761. /****************************** CLASS ANIMATIONS ******************************/
  1762. /******************************************************************************/
  1763. ( function() {
  1764. var classAnimationActions = [ "add", "remove", "toggle" ],
  1765. shorthandStyles = {
  1766. border: 1,
  1767. borderBottom: 1,
  1768. borderColor: 1,
  1769. borderLeft: 1,
  1770. borderRight: 1,
  1771. borderTop: 1,
  1772. borderWidth: 1,
  1773. margin: 1,
  1774. padding: 1
  1775. };
  1776. $.each(
  1777. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  1778. function( _, prop ) {
  1779. $.fx.step[ prop ] = function( fx ) {
  1780. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  1781. jQuery.style( fx.elem, prop, fx.end );
  1782. fx.setAttr = true;
  1783. }
  1784. };
  1785. }
  1786. );
  1787. function camelCase( string ) {
  1788. return string.replace( /-([\da-z])/gi, function( all, letter ) {
  1789. return letter.toUpperCase();
  1790. } );
  1791. }
  1792. function getElementStyles( elem ) {
  1793. var key, len,
  1794. style = elem.ownerDocument.defaultView ?
  1795. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  1796. elem.currentStyle,
  1797. styles = {};
  1798. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  1799. len = style.length;
  1800. while ( len-- ) {
  1801. key = style[ len ];
  1802. if ( typeof style[ key ] === "string" ) {
  1803. styles[ camelCase( key ) ] = style[ key ];
  1804. }
  1805. }
  1806. // Support: Opera, IE <9
  1807. } else {
  1808. for ( key in style ) {
  1809. if ( typeof style[ key ] === "string" ) {
  1810. styles[ key ] = style[ key ];
  1811. }
  1812. }
  1813. }
  1814. return styles;
  1815. }
  1816. function styleDifference( oldStyle, newStyle ) {
  1817. var diff = {},
  1818. name, value;
  1819. for ( name in newStyle ) {
  1820. value = newStyle[ name ];
  1821. if ( oldStyle[ name ] !== value ) {
  1822. if ( !shorthandStyles[ name ] ) {
  1823. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  1824. diff[ name ] = value;
  1825. }
  1826. }
  1827. }
  1828. }
  1829. return diff;
  1830. }
  1831. // Support: jQuery <1.8
  1832. if ( !$.fn.addBack ) {
  1833. $.fn.addBack = function( selector ) {
  1834. return this.add( selector == null ?
  1835. this.prevObject : this.prevObject.filter( selector )
  1836. );
  1837. };
  1838. }
  1839. $.effects.animateClass = function( value, duration, easing, callback ) {
  1840. var o = $.speed( duration, easing, callback );
  1841. return this.queue( function() {
  1842. var animated = $( this ),
  1843. baseClass = animated.attr( "class" ) || "",
  1844. applyClassChange,
  1845. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  1846. // Map the animated objects to store the original styles.
  1847. allAnimations = allAnimations.map( function() {
  1848. var el = $( this );
  1849. return {
  1850. el: el,
  1851. start: getElementStyles( this )
  1852. };
  1853. } );
  1854. // Apply class change
  1855. applyClassChange = function() {
  1856. $.each( classAnimationActions, function( i, action ) {
  1857. if ( value[ action ] ) {
  1858. animated[ action + "Class" ]( value[ action ] );
  1859. }
  1860. } );
  1861. };
  1862. applyClassChange();
  1863. // Map all animated objects again - calculate new styles and diff
  1864. allAnimations = allAnimations.map( function() {
  1865. this.end = getElementStyles( this.el[ 0 ] );
  1866. this.diff = styleDifference( this.start, this.end );
  1867. return this;
  1868. } );
  1869. // Apply original class
  1870. animated.attr( "class", baseClass );
  1871. // Map all animated objects again - this time collecting a promise
  1872. allAnimations = allAnimations.map( function() {
  1873. var styleInfo = this,
  1874. dfd = $.Deferred(),
  1875. opts = $.extend( {}, o, {
  1876. queue: false,
  1877. complete: function() {
  1878. dfd.resolve( styleInfo );
  1879. }
  1880. } );
  1881. this.el.animate( this.diff, opts );
  1882. return dfd.promise();
  1883. } );
  1884. // Once all animations have completed:
  1885. $.when.apply( $, allAnimations.get() ).done( function() {
  1886. // Set the final class
  1887. applyClassChange();
  1888. // For each animated element,
  1889. // clear all css properties that were animated
  1890. $.each( arguments, function() {
  1891. var el = this.el;
  1892. $.each( this.diff, function( key ) {
  1893. el.css( key, "" );
  1894. } );
  1895. } );
  1896. // This is guarnteed to be there if you use jQuery.speed()
  1897. // it also handles dequeuing the next anim...
  1898. o.complete.call( animated[ 0 ] );
  1899. } );
  1900. } );
  1901. };
  1902. $.fn.extend( {
  1903. addClass: ( function( orig ) {
  1904. return function( classNames, speed, easing, callback ) {
  1905. return speed ?
  1906. $.effects.animateClass.call( this,
  1907. { add: classNames }, speed, easing, callback ) :
  1908. orig.apply( this, arguments );
  1909. };
  1910. } )( $.fn.addClass ),
  1911. removeClass: ( function( orig ) {
  1912. return function( classNames, speed, easing, callback ) {
  1913. return arguments.length > 1 ?
  1914. $.effects.animateClass.call( this,
  1915. { remove: classNames }, speed, easing, callback ) :
  1916. orig.apply( this, arguments );
  1917. };
  1918. } )( $.fn.removeClass ),
  1919. toggleClass: ( function( orig ) {
  1920. return function( classNames, force, speed, easing, callback ) {
  1921. if ( typeof force === "boolean" || force === undefined ) {
  1922. if ( !speed ) {
  1923. // Without speed parameter
  1924. return orig.apply( this, arguments );
  1925. } else {
  1926. return $.effects.animateClass.call( this,
  1927. ( force ? { add: classNames } : { remove: classNames } ),
  1928. speed, easing, callback );
  1929. }
  1930. } else {
  1931. // Without force parameter
  1932. return $.effects.animateClass.call( this,
  1933. { toggle: classNames }, force, speed, easing );
  1934. }
  1935. };
  1936. } )( $.fn.toggleClass ),
  1937. switchClass: function( remove, add, speed, easing, callback ) {
  1938. return $.effects.animateClass.call( this, {
  1939. add: add,
  1940. remove: remove
  1941. }, speed, easing, callback );
  1942. }
  1943. } );
  1944. } )();
  1945. /******************************************************************************/
  1946. /*********************************** EFFECTS **********************************/
  1947. /******************************************************************************/
  1948. ( function() {
  1949. if ( $.expr && $.expr.pseudos && $.expr.pseudos.animated ) {
  1950. $.expr.pseudos.animated = ( function( orig ) {
  1951. return function( elem ) {
  1952. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  1953. };
  1954. } )( $.expr.pseudos.animated );
  1955. }
  1956. if ( $.uiBackCompat !== false ) {
  1957. $.extend( $.effects, {
  1958. // Saves a set of properties in a data storage
  1959. save: function( element, set ) {
  1960. var i = 0, length = set.length;
  1961. for ( ; i < length; i++ ) {
  1962. if ( set[ i ] !== null ) {
  1963. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  1964. }
  1965. }
  1966. },
  1967. // Restores a set of previously saved properties from a data storage
  1968. restore: function( element, set ) {
  1969. var val, i = 0, length = set.length;
  1970. for ( ; i < length; i++ ) {
  1971. if ( set[ i ] !== null ) {
  1972. val = element.data( dataSpace + set[ i ] );
  1973. element.css( set[ i ], val );
  1974. }
  1975. }
  1976. },
  1977. setMode: function( el, mode ) {
  1978. if ( mode === "toggle" ) {
  1979. mode = el.is( ":hidden" ) ? "show" : "hide";
  1980. }
  1981. return mode;
  1982. },
  1983. // Wraps the element around a wrapper that copies position properties
  1984. createWrapper: function( element ) {
  1985. // If the element is already wrapped, return it
  1986. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  1987. return element.parent();
  1988. }
  1989. // Wrap the element
  1990. var props = {
  1991. width: element.outerWidth( true ),
  1992. height: element.outerHeight( true ),
  1993. "float": element.css( "float" )
  1994. },
  1995. wrapper = $( "<div></div>" )
  1996. .addClass( "ui-effects-wrapper" )
  1997. .css( {
  1998. fontSize: "100%",
  1999. background: "transparent",
  2000. border: "none",
  2001. margin: 0,
  2002. padding: 0
  2003. } ),
  2004. // Store the size in case width/height are defined in % - Fixes #5245
  2005. size = {
  2006. width: element.width(),
  2007. height: element.height()
  2008. },
  2009. active = document.activeElement;
  2010. // Support: Firefox
  2011. // Firefox incorrectly exposes anonymous content
  2012. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  2013. try {
  2014. // eslint-disable-next-line no-unused-expressions
  2015. active.id;
  2016. } catch ( e ) {
  2017. active = document.body;
  2018. }
  2019. element.wrap( wrapper );
  2020. // Fixes #7595 - Elements lose focus when wrapped.
  2021. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  2022. $( active ).trigger( "focus" );
  2023. }
  2024. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  2025. // lose the reference to the wrapped element
  2026. wrapper = element.parent();
  2027. // Transfer positioning properties to the wrapper
  2028. if ( element.css( "position" ) === "static" ) {
  2029. wrapper.css( { position: "relative" } );
  2030. element.css( { position: "relative" } );
  2031. } else {
  2032. $.extend( props, {
  2033. position: element.css( "position" ),
  2034. zIndex: element.css( "z-index" )
  2035. } );
  2036. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  2037. props[ pos ] = element.css( pos );
  2038. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  2039. props[ pos ] = "auto";
  2040. }
  2041. } );
  2042. element.css( {
  2043. position: "relative",
  2044. top: 0,
  2045. left: 0,
  2046. right: "auto",
  2047. bottom: "auto"
  2048. } );
  2049. }
  2050. element.css( size );
  2051. return wrapper.css( props ).show();
  2052. },
  2053. removeWrapper: function( element ) {
  2054. var active = document.activeElement;
  2055. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  2056. element.parent().replaceWith( element );
  2057. // Fixes #7595 - Elements lose focus when wrapped.
  2058. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  2059. $( active ).trigger( "focus" );
  2060. }
  2061. }
  2062. return element;
  2063. }
  2064. } );
  2065. }
  2066. $.extend( $.effects, {
  2067. version: "1.13.0",
  2068. define: function( name, mode, effect ) {
  2069. if ( !effect ) {
  2070. effect = mode;
  2071. mode = "effect";
  2072. }
  2073. $.effects.effect[ name ] = effect;
  2074. $.effects.effect[ name ].mode = mode;
  2075. return effect;
  2076. },
  2077. scaledDimensions: function( element, percent, direction ) {
  2078. if ( percent === 0 ) {
  2079. return {
  2080. height: 0,
  2081. width: 0,
  2082. outerHeight: 0,
  2083. outerWidth: 0
  2084. };
  2085. }
  2086. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  2087. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  2088. return {
  2089. height: element.height() * y,
  2090. width: element.width() * x,
  2091. outerHeight: element.outerHeight() * y,
  2092. outerWidth: element.outerWidth() * x
  2093. };
  2094. },
  2095. clipToBox: function( animation ) {
  2096. return {
  2097. width: animation.clip.right - animation.clip.left,
  2098. height: animation.clip.bottom - animation.clip.top,
  2099. left: animation.clip.left,
  2100. top: animation.clip.top
  2101. };
  2102. },
  2103. // Injects recently queued functions to be first in line (after "inprogress")
  2104. unshift: function( element, queueLength, count ) {
  2105. var queue = element.queue();
  2106. if ( queueLength > 1 ) {
  2107. queue.splice.apply( queue,
  2108. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  2109. }
  2110. element.dequeue();
  2111. },
  2112. saveStyle: function( element ) {
  2113. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  2114. },
  2115. restoreStyle: function( element ) {
  2116. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  2117. element.removeData( dataSpaceStyle );
  2118. },
  2119. mode: function( element, mode ) {
  2120. var hidden = element.is( ":hidden" );
  2121. if ( mode === "toggle" ) {
  2122. mode = hidden ? "show" : "hide";
  2123. }
  2124. if ( hidden ? mode === "hide" : mode === "show" ) {
  2125. mode = "none";
  2126. }
  2127. return mode;
  2128. },
  2129. // Translates a [top,left] array into a baseline value
  2130. getBaseline: function( origin, original ) {
  2131. var y, x;
  2132. switch ( origin[ 0 ] ) {
  2133. case "top":
  2134. y = 0;
  2135. break;
  2136. case "middle":
  2137. y = 0.5;
  2138. break;
  2139. case "bottom":
  2140. y = 1;
  2141. break;
  2142. default:
  2143. y = origin[ 0 ] / original.height;
  2144. }
  2145. switch ( origin[ 1 ] ) {
  2146. case "left":
  2147. x = 0;
  2148. break;
  2149. case "center":
  2150. x = 0.5;
  2151. break;
  2152. case "right":
  2153. x = 1;
  2154. break;
  2155. default:
  2156. x = origin[ 1 ] / original.width;
  2157. }
  2158. return {
  2159. x: x,
  2160. y: y
  2161. };
  2162. },
  2163. // Creates a placeholder element so that the original element can be made absolute
  2164. createPlaceholder: function( element ) {
  2165. var placeholder,
  2166. cssPosition = element.css( "position" ),
  2167. position = element.position();
  2168. // Lock in margins first to account for form elements, which
  2169. // will change margin if you explicitly set height
  2170. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  2171. // Support: Safari
  2172. element.css( {
  2173. marginTop: element.css( "marginTop" ),
  2174. marginBottom: element.css( "marginBottom" ),
  2175. marginLeft: element.css( "marginLeft" ),
  2176. marginRight: element.css( "marginRight" )
  2177. } )
  2178. .outerWidth( element.outerWidth() )
  2179. .outerHeight( element.outerHeight() );
  2180. if ( /^(static|relative)/.test( cssPosition ) ) {
  2181. cssPosition = "absolute";
  2182. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  2183. // Convert inline to inline block to account for inline elements
  2184. // that turn to inline block based on content (like img)
  2185. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  2186. "inline-block" :
  2187. "block",
  2188. visibility: "hidden",
  2189. // Margins need to be set to account for margin collapse
  2190. marginTop: element.css( "marginTop" ),
  2191. marginBottom: element.css( "marginBottom" ),
  2192. marginLeft: element.css( "marginLeft" ),
  2193. marginRight: element.css( "marginRight" ),
  2194. "float": element.css( "float" )
  2195. } )
  2196. .outerWidth( element.outerWidth() )
  2197. .outerHeight( element.outerHeight() )
  2198. .addClass( "ui-effects-placeholder" );
  2199. element.data( dataSpace + "placeholder", placeholder );
  2200. }
  2201. element.css( {
  2202. position: cssPosition,
  2203. left: position.left,
  2204. top: position.top
  2205. } );
  2206. return placeholder;
  2207. },
  2208. removePlaceholder: function( element ) {
  2209. var dataKey = dataSpace + "placeholder",
  2210. placeholder = element.data( dataKey );
  2211. if ( placeholder ) {
  2212. placeholder.remove();
  2213. element.removeData( dataKey );
  2214. }
  2215. },
  2216. // Removes a placeholder if it exists and restores
  2217. // properties that were modified during placeholder creation
  2218. cleanUp: function( element ) {
  2219. $.effects.restoreStyle( element );
  2220. $.effects.removePlaceholder( element );
  2221. },
  2222. setTransition: function( element, list, factor, value ) {
  2223. value = value || {};
  2224. $.each( list, function( i, x ) {
  2225. var unit = element.cssUnit( x );
  2226. if ( unit[ 0 ] > 0 ) {
  2227. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  2228. }
  2229. } );
  2230. return value;
  2231. }
  2232. } );
  2233. // Return an effect options object for the given parameters:
  2234. function _normalizeArguments( effect, options, speed, callback ) {
  2235. // Allow passing all options as the first parameter
  2236. if ( $.isPlainObject( effect ) ) {
  2237. options = effect;
  2238. effect = effect.effect;
  2239. }
  2240. // Convert to an object
  2241. effect = { effect: effect };
  2242. // Catch (effect, null, ...)
  2243. if ( options == null ) {
  2244. options = {};
  2245. }
  2246. // Catch (effect, callback)
  2247. if ( typeof options === "function" ) {
  2248. callback = options;
  2249. speed = null;
  2250. options = {};
  2251. }
  2252. // Catch (effect, speed, ?)
  2253. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  2254. callback = speed;
  2255. speed = options;
  2256. options = {};
  2257. }
  2258. // Catch (effect, options, callback)
  2259. if ( typeof speed === "function" ) {
  2260. callback = speed;
  2261. speed = null;
  2262. }
  2263. // Add options to effect
  2264. if ( options ) {
  2265. $.extend( effect, options );
  2266. }
  2267. speed = speed || options.duration;
  2268. effect.duration = $.fx.off ? 0 :
  2269. typeof speed === "number" ? speed :
  2270. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  2271. $.fx.speeds._default;
  2272. effect.complete = callback || options.complete;
  2273. return effect;
  2274. }
  2275. function standardAnimationOption( option ) {
  2276. // Valid standard speeds (nothing, number, named speed)
  2277. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  2278. return true;
  2279. }
  2280. // Invalid strings - treat as "normal" speed
  2281. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  2282. return true;
  2283. }
  2284. // Complete callback
  2285. if ( typeof option === "function" ) {
  2286. return true;
  2287. }
  2288. // Options hash (but not naming an effect)
  2289. if ( typeof option === "object" && !option.effect ) {
  2290. return true;
  2291. }
  2292. // Didn't match any standard API
  2293. return false;
  2294. }
  2295. $.fn.extend( {
  2296. effect: function( /* effect, options, speed, callback */ ) {
  2297. var args = _normalizeArguments.apply( this, arguments ),
  2298. effectMethod = $.effects.effect[ args.effect ],
  2299. defaultMode = effectMethod.mode,
  2300. queue = args.queue,
  2301. queueName = queue || "fx",
  2302. complete = args.complete,
  2303. mode = args.mode,
  2304. modes = [],
  2305. prefilter = function( next ) {
  2306. var el = $( this ),
  2307. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  2308. // Sentinel for duck-punching the :animated pseudo-selector
  2309. el.data( dataSpaceAnimated, true );
  2310. // Save effect mode for later use,
  2311. // we can't just call $.effects.mode again later,
  2312. // as the .show() below destroys the initial state
  2313. modes.push( normalizedMode );
  2314. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.14
  2315. if ( defaultMode && ( normalizedMode === "show" ||
  2316. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  2317. el.show();
  2318. }
  2319. if ( !defaultMode || normalizedMode !== "none" ) {
  2320. $.effects.saveStyle( el );
  2321. }
  2322. if ( typeof next === "function" ) {
  2323. next();
  2324. }
  2325. };
  2326. if ( $.fx.off || !effectMethod ) {
  2327. // Delegate to the original method (e.g., .show()) if possible
  2328. if ( mode ) {
  2329. return this[ mode ]( args.duration, complete );
  2330. } else {
  2331. return this.each( function() {
  2332. if ( complete ) {
  2333. complete.call( this );
  2334. }
  2335. } );
  2336. }
  2337. }
  2338. function run( next ) {
  2339. var elem = $( this );
  2340. function cleanup() {
  2341. elem.removeData( dataSpaceAnimated );
  2342. $.effects.cleanUp( elem );
  2343. if ( args.mode === "hide" ) {
  2344. elem.hide();
  2345. }
  2346. done();
  2347. }
  2348. function done() {
  2349. if ( typeof complete === "function" ) {
  2350. complete.call( elem[ 0 ] );
  2351. }
  2352. if ( typeof next === "function" ) {
  2353. next();
  2354. }
  2355. }
  2356. // Override mode option on a per element basis,
  2357. // as toggle can be either show or hide depending on element state
  2358. args.mode = modes.shift();
  2359. if ( $.uiBackCompat !== false && !defaultMode ) {
  2360. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  2361. // Call the core method to track "olddisplay" properly
  2362. elem[ mode ]();
  2363. done();
  2364. } else {
  2365. effectMethod.call( elem[ 0 ], args, done );
  2366. }
  2367. } else {
  2368. if ( args.mode === "none" ) {
  2369. // Call the core method to track "olddisplay" properly
  2370. elem[ mode ]();
  2371. done();
  2372. } else {
  2373. effectMethod.call( elem[ 0 ], args, cleanup );
  2374. }
  2375. }
  2376. }
  2377. // Run prefilter on all elements first to ensure that
  2378. // any showing or hiding happens before placeholder creation,
  2379. // which ensures that any layout changes are correctly captured.
  2380. return queue === false ?
  2381. this.each( prefilter ).each( run ) :
  2382. this.queue( queueName, prefilter ).queue( queueName, run );
  2383. },
  2384. show: ( function( orig ) {
  2385. return function( option ) {
  2386. if ( standardAnimationOption( option ) ) {
  2387. return orig.apply( this, arguments );
  2388. } else {
  2389. var args = _normalizeArguments.apply( this, arguments );
  2390. args.mode = "show";
  2391. return this.effect.call( this, args );
  2392. }
  2393. };
  2394. } )( $.fn.show ),
  2395. hide: ( function( orig ) {
  2396. return function( option ) {
  2397. if ( standardAnimationOption( option ) ) {
  2398. return orig.apply( this, arguments );
  2399. } else {
  2400. var args = _normalizeArguments.apply( this, arguments );
  2401. args.mode = "hide";
  2402. return this.effect.call( this, args );
  2403. }
  2404. };
  2405. } )( $.fn.hide ),
  2406. toggle: ( function( orig ) {
  2407. return function( option ) {
  2408. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  2409. return orig.apply( this, arguments );
  2410. } else {
  2411. var args = _normalizeArguments.apply( this, arguments );
  2412. args.mode = "toggle";
  2413. return this.effect.call( this, args );
  2414. }
  2415. };
  2416. } )( $.fn.toggle ),
  2417. cssUnit: function( key ) {
  2418. var style = this.css( key ),
  2419. val = [];
  2420. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  2421. if ( style.indexOf( unit ) > 0 ) {
  2422. val = [ parseFloat( style ), unit ];
  2423. }
  2424. } );
  2425. return val;
  2426. },
  2427. cssClip: function( clipObj ) {
  2428. if ( clipObj ) {
  2429. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  2430. clipObj.bottom + "px " + clipObj.left + "px)" );
  2431. }
  2432. return parseClip( this.css( "clip" ), this );
  2433. },
  2434. transfer: function( options, done ) {
  2435. var element = $( this ),
  2436. target = $( options.to ),
  2437. targetFixed = target.css( "position" ) === "fixed",
  2438. body = $( "body" ),
  2439. fixTop = targetFixed ? body.scrollTop() : 0,
  2440. fixLeft = targetFixed ? body.scrollLeft() : 0,
  2441. endPosition = target.offset(),
  2442. animation = {
  2443. top: endPosition.top - fixTop,
  2444. left: endPosition.left - fixLeft,
  2445. height: target.innerHeight(),
  2446. width: target.innerWidth()
  2447. },
  2448. startPosition = element.offset(),
  2449. transfer = $( "<div class='ui-effects-transfer'></div>" );
  2450. transfer
  2451. .appendTo( "body" )
  2452. .addClass( options.className )
  2453. .css( {
  2454. top: startPosition.top - fixTop,
  2455. left: startPosition.left - fixLeft,
  2456. height: element.innerHeight(),
  2457. width: element.innerWidth(),
  2458. position: targetFixed ? "fixed" : "absolute"
  2459. } )
  2460. .animate( animation, options.duration, options.easing, function() {
  2461. transfer.remove();
  2462. if ( typeof done === "function" ) {
  2463. done();
  2464. }
  2465. } );
  2466. }
  2467. } );
  2468. function parseClip( str, element ) {
  2469. var outerWidth = element.outerWidth(),
  2470. outerHeight = element.outerHeight(),
  2471. clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,
  2472. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  2473. return {
  2474. top: parseFloat( values[ 1 ] ) || 0,
  2475. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  2476. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  2477. left: parseFloat( values[ 4 ] ) || 0
  2478. };
  2479. }
  2480. $.fx.step.clip = function( fx ) {
  2481. if ( !fx.clipInit ) {
  2482. fx.start = $( fx.elem ).cssClip();
  2483. if ( typeof fx.end === "string" ) {
  2484. fx.end = parseClip( fx.end, fx.elem );
  2485. }
  2486. fx.clipInit = true;
  2487. }
  2488. $( fx.elem ).cssClip( {
  2489. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  2490. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  2491. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  2492. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  2493. } );
  2494. };
  2495. } )();
  2496. /******************************************************************************/
  2497. /*********************************** EASING ***********************************/
  2498. /******************************************************************************/
  2499. ( function() {
  2500. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  2501. var baseEasings = {};
  2502. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  2503. baseEasings[ name ] = function( p ) {
  2504. return Math.pow( p, i + 2 );
  2505. };
  2506. } );
  2507. $.extend( baseEasings, {
  2508. Sine: function( p ) {
  2509. return 1 - Math.cos( p * Math.PI / 2 );
  2510. },
  2511. Circ: function( p ) {
  2512. return 1 - Math.sqrt( 1 - p * p );
  2513. },
  2514. Elastic: function( p ) {
  2515. return p === 0 || p === 1 ? p :
  2516. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  2517. },
  2518. Back: function( p ) {
  2519. return p * p * ( 3 * p - 2 );
  2520. },
  2521. Bounce: function( p ) {
  2522. var pow2,
  2523. bounce = 4;
  2524. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  2525. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  2526. }
  2527. } );
  2528. $.each( baseEasings, function( name, easeIn ) {
  2529. $.easing[ "easeIn" + name ] = easeIn;
  2530. $.easing[ "easeOut" + name ] = function( p ) {
  2531. return 1 - easeIn( 1 - p );
  2532. };
  2533. $.easing[ "easeInOut" + name ] = function( p ) {
  2534. return p < 0.5 ?
  2535. easeIn( p * 2 ) / 2 :
  2536. 1 - easeIn( p * -2 + 2 ) / 2;
  2537. };
  2538. } );
  2539. } )();
  2540. var effect = $.effects;
  2541. /*!
  2542. * jQuery UI Effects Blind 1.13.0
  2543. * http://jqueryui.com
  2544. *
  2545. * Copyright jQuery Foundation and other contributors
  2546. * Released under the MIT license.
  2547. * http://jquery.org/license
  2548. */
  2549. //>>label: Blind Effect
  2550. //>>group: Effects
  2551. //>>description: Blinds the element.
  2552. //>>docs: http://api.jqueryui.com/blind-effect/
  2553. //>>demos: http://jqueryui.com/effect/
  2554. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  2555. var map = {
  2556. up: [ "bottom", "top" ],
  2557. vertical: [ "bottom", "top" ],
  2558. down: [ "top", "bottom" ],
  2559. left: [ "right", "left" ],
  2560. horizontal: [ "right", "left" ],
  2561. right: [ "left", "right" ]
  2562. },
  2563. element = $( this ),
  2564. direction = options.direction || "up",
  2565. start = element.cssClip(),
  2566. animate = { clip: $.extend( {}, start ) },
  2567. placeholder = $.effects.createPlaceholder( element );
  2568. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  2569. if ( options.mode === "show" ) {
  2570. element.cssClip( animate.clip );
  2571. if ( placeholder ) {
  2572. placeholder.css( $.effects.clipToBox( animate ) );
  2573. }
  2574. animate.clip = start;
  2575. }
  2576. if ( placeholder ) {
  2577. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  2578. }
  2579. element.animate( animate, {
  2580. queue: false,
  2581. duration: options.duration,
  2582. easing: options.easing,
  2583. complete: done
  2584. } );
  2585. } );
  2586. /*!
  2587. * jQuery UI Effects Bounce 1.13.0
  2588. * http://jqueryui.com
  2589. *
  2590. * Copyright jQuery Foundation and other contributors
  2591. * Released under the MIT license.
  2592. * http://jquery.org/license
  2593. */
  2594. //>>label: Bounce Effect
  2595. //>>group: Effects
  2596. //>>description: Bounces an element horizontally or vertically n times.
  2597. //>>docs: http://api.jqueryui.com/bounce-effect/
  2598. //>>demos: http://jqueryui.com/effect/
  2599. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  2600. var upAnim, downAnim, refValue,
  2601. element = $( this ),
  2602. // Defaults:
  2603. mode = options.mode,
  2604. hide = mode === "hide",
  2605. show = mode === "show",
  2606. direction = options.direction || "up",
  2607. distance = options.distance,
  2608. times = options.times || 5,
  2609. // Number of internal animations
  2610. anims = times * 2 + ( show || hide ? 1 : 0 ),
  2611. speed = options.duration / anims,
  2612. easing = options.easing,
  2613. // Utility:
  2614. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2615. motion = ( direction === "up" || direction === "left" ),
  2616. i = 0,
  2617. queuelen = element.queue().length;
  2618. $.effects.createPlaceholder( element );
  2619. refValue = element.css( ref );
  2620. // Default distance for the BIGGEST bounce is the outer Distance / 3
  2621. if ( !distance ) {
  2622. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  2623. }
  2624. if ( show ) {
  2625. downAnim = { opacity: 1 };
  2626. downAnim[ ref ] = refValue;
  2627. // If we are showing, force opacity 0 and set the initial position
  2628. // then do the "first" animation
  2629. element
  2630. .css( "opacity", 0 )
  2631. .css( ref, motion ? -distance * 2 : distance * 2 )
  2632. .animate( downAnim, speed, easing );
  2633. }
  2634. // Start at the smallest distance if we are hiding
  2635. if ( hide ) {
  2636. distance = distance / Math.pow( 2, times - 1 );
  2637. }
  2638. downAnim = {};
  2639. downAnim[ ref ] = refValue;
  2640. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  2641. for ( ; i < times; i++ ) {
  2642. upAnim = {};
  2643. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2644. element
  2645. .animate( upAnim, speed, easing )
  2646. .animate( downAnim, speed, easing );
  2647. distance = hide ? distance * 2 : distance / 2;
  2648. }
  2649. // Last Bounce when Hiding
  2650. if ( hide ) {
  2651. upAnim = { opacity: 0 };
  2652. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2653. element.animate( upAnim, speed, easing );
  2654. }
  2655. element.queue( done );
  2656. $.effects.unshift( element, queuelen, anims + 1 );
  2657. } );
  2658. /*!
  2659. * jQuery UI Effects Clip 1.13.0
  2660. * http://jqueryui.com
  2661. *
  2662. * Copyright jQuery Foundation and other contributors
  2663. * Released under the MIT license.
  2664. * http://jquery.org/license
  2665. */
  2666. //>>label: Clip Effect
  2667. //>>group: Effects
  2668. //>>description: Clips the element on and off like an old TV.
  2669. //>>docs: http://api.jqueryui.com/clip-effect/
  2670. //>>demos: http://jqueryui.com/effect/
  2671. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  2672. var start,
  2673. animate = {},
  2674. element = $( this ),
  2675. direction = options.direction || "vertical",
  2676. both = direction === "both",
  2677. horizontal = both || direction === "horizontal",
  2678. vertical = both || direction === "vertical";
  2679. start = element.cssClip();
  2680. animate.clip = {
  2681. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  2682. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  2683. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  2684. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  2685. };
  2686. $.effects.createPlaceholder( element );
  2687. if ( options.mode === "show" ) {
  2688. element.cssClip( animate.clip );
  2689. animate.clip = start;
  2690. }
  2691. element.animate( animate, {
  2692. queue: false,
  2693. duration: options.duration,
  2694. easing: options.easing,
  2695. complete: done
  2696. } );
  2697. } );
  2698. /*!
  2699. * jQuery UI Effects Drop 1.13.0
  2700. * http://jqueryui.com
  2701. *
  2702. * Copyright jQuery Foundation and other contributors
  2703. * Released under the MIT license.
  2704. * http://jquery.org/license
  2705. */
  2706. //>>label: Drop Effect
  2707. //>>group: Effects
  2708. //>>description: Moves an element in one direction and hides it at the same time.
  2709. //>>docs: http://api.jqueryui.com/drop-effect/
  2710. //>>demos: http://jqueryui.com/effect/
  2711. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  2712. var distance,
  2713. element = $( this ),
  2714. mode = options.mode,
  2715. show = mode === "show",
  2716. direction = options.direction || "left",
  2717. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2718. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  2719. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  2720. animation = {
  2721. opacity: 0
  2722. };
  2723. $.effects.createPlaceholder( element );
  2724. distance = options.distance ||
  2725. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  2726. animation[ ref ] = motion + distance;
  2727. if ( show ) {
  2728. element.css( animation );
  2729. animation[ ref ] = oppositeMotion + distance;
  2730. animation.opacity = 1;
  2731. }
  2732. // Animate
  2733. element.animate( animation, {
  2734. queue: false,
  2735. duration: options.duration,
  2736. easing: options.easing,
  2737. complete: done
  2738. } );
  2739. } );
  2740. /*!
  2741. * jQuery UI Effects Explode 1.13.0
  2742. * http://jqueryui.com
  2743. *
  2744. * Copyright jQuery Foundation and other contributors
  2745. * Released under the MIT license.
  2746. * http://jquery.org/license
  2747. */
  2748. //>>label: Explode Effect
  2749. //>>group: Effects
  2750. /* eslint-disable max-len */
  2751. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  2752. /* eslint-enable max-len */
  2753. //>>docs: http://api.jqueryui.com/explode-effect/
  2754. //>>demos: http://jqueryui.com/effect/
  2755. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  2756. var i, j, left, top, mx, my,
  2757. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  2758. cells = rows,
  2759. element = $( this ),
  2760. mode = options.mode,
  2761. show = mode === "show",
  2762. // Show and then visibility:hidden the element before calculating offset
  2763. offset = element.show().css( "visibility", "hidden" ).offset(),
  2764. // Width and height of a piece
  2765. width = Math.ceil( element.outerWidth() / cells ),
  2766. height = Math.ceil( element.outerHeight() / rows ),
  2767. pieces = [];
  2768. // Children animate complete:
  2769. function childComplete() {
  2770. pieces.push( this );
  2771. if ( pieces.length === rows * cells ) {
  2772. animComplete();
  2773. }
  2774. }
  2775. // Clone the element for each row and cell.
  2776. for ( i = 0; i < rows; i++ ) { // ===>
  2777. top = offset.top + i * height;
  2778. my = i - ( rows - 1 ) / 2;
  2779. for ( j = 0; j < cells; j++ ) { // |||
  2780. left = offset.left + j * width;
  2781. mx = j - ( cells - 1 ) / 2;
  2782. // Create a clone of the now hidden main element that will be absolute positioned
  2783. // within a wrapper div off the -left and -top equal to size of our pieces
  2784. element
  2785. .clone()
  2786. .appendTo( "body" )
  2787. .wrap( "<div></div>" )
  2788. .css( {
  2789. position: "absolute",
  2790. visibility: "visible",
  2791. left: -j * width,
  2792. top: -i * height
  2793. } )
  2794. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  2795. // where the original was located +left and +top equal to the size of pieces
  2796. .parent()
  2797. .addClass( "ui-effects-explode" )
  2798. .css( {
  2799. position: "absolute",
  2800. overflow: "hidden",
  2801. width: width,
  2802. height: height,
  2803. left: left + ( show ? mx * width : 0 ),
  2804. top: top + ( show ? my * height : 0 ),
  2805. opacity: show ? 0 : 1
  2806. } )
  2807. .animate( {
  2808. left: left + ( show ? 0 : mx * width ),
  2809. top: top + ( show ? 0 : my * height ),
  2810. opacity: show ? 1 : 0
  2811. }, options.duration || 500, options.easing, childComplete );
  2812. }
  2813. }
  2814. function animComplete() {
  2815. element.css( {
  2816. visibility: "visible"
  2817. } );
  2818. $( pieces ).remove();
  2819. done();
  2820. }
  2821. } );
  2822. /*!
  2823. * jQuery UI Effects Fade 1.13.0
  2824. * http://jqueryui.com
  2825. *
  2826. * Copyright jQuery Foundation and other contributors
  2827. * Released under the MIT license.
  2828. * http://jquery.org/license
  2829. */
  2830. //>>label: Fade Effect
  2831. //>>group: Effects
  2832. //>>description: Fades the element.
  2833. //>>docs: http://api.jqueryui.com/fade-effect/
  2834. //>>demos: http://jqueryui.com/effect/
  2835. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  2836. var show = options.mode === "show";
  2837. $( this )
  2838. .css( "opacity", show ? 0 : 1 )
  2839. .animate( {
  2840. opacity: show ? 1 : 0
  2841. }, {
  2842. queue: false,
  2843. duration: options.duration,
  2844. easing: options.easing,
  2845. complete: done
  2846. } );
  2847. } );
  2848. /*!
  2849. * jQuery UI Effects Fold 1.13.0
  2850. * http://jqueryui.com
  2851. *
  2852. * Copyright jQuery Foundation and other contributors
  2853. * Released under the MIT license.
  2854. * http://jquery.org/license
  2855. */
  2856. //>>label: Fold Effect
  2857. //>>group: Effects
  2858. //>>description: Folds an element first horizontally and then vertically.
  2859. //>>docs: http://api.jqueryui.com/fold-effect/
  2860. //>>demos: http://jqueryui.com/effect/
  2861. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  2862. // Create element
  2863. var element = $( this ),
  2864. mode = options.mode,
  2865. show = mode === "show",
  2866. hide = mode === "hide",
  2867. size = options.size || 15,
  2868. percent = /([0-9]+)%/.exec( size ),
  2869. horizFirst = !!options.horizFirst,
  2870. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  2871. duration = options.duration / 2,
  2872. placeholder = $.effects.createPlaceholder( element ),
  2873. start = element.cssClip(),
  2874. animation1 = { clip: $.extend( {}, start ) },
  2875. animation2 = { clip: $.extend( {}, start ) },
  2876. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  2877. queuelen = element.queue().length;
  2878. if ( percent ) {
  2879. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  2880. }
  2881. animation1.clip[ ref[ 0 ] ] = size;
  2882. animation2.clip[ ref[ 0 ] ] = size;
  2883. animation2.clip[ ref[ 1 ] ] = 0;
  2884. if ( show ) {
  2885. element.cssClip( animation2.clip );
  2886. if ( placeholder ) {
  2887. placeholder.css( $.effects.clipToBox( animation2 ) );
  2888. }
  2889. animation2.clip = start;
  2890. }
  2891. // Animate
  2892. element
  2893. .queue( function( next ) {
  2894. if ( placeholder ) {
  2895. placeholder
  2896. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  2897. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  2898. }
  2899. next();
  2900. } )
  2901. .animate( animation1, duration, options.easing )
  2902. .animate( animation2, duration, options.easing )
  2903. .queue( done );
  2904. $.effects.unshift( element, queuelen, 4 );
  2905. } );
  2906. /*!
  2907. * jQuery UI Effects Highlight 1.13.0
  2908. * http://jqueryui.com
  2909. *
  2910. * Copyright jQuery Foundation and other contributors
  2911. * Released under the MIT license.
  2912. * http://jquery.org/license
  2913. */
  2914. //>>label: Highlight Effect
  2915. //>>group: Effects
  2916. //>>description: Highlights the background of an element in a defined color for a custom duration.
  2917. //>>docs: http://api.jqueryui.com/highlight-effect/
  2918. //>>demos: http://jqueryui.com/effect/
  2919. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  2920. var element = $( this ),
  2921. animation = {
  2922. backgroundColor: element.css( "backgroundColor" )
  2923. };
  2924. if ( options.mode === "hide" ) {
  2925. animation.opacity = 0;
  2926. }
  2927. $.effects.saveStyle( element );
  2928. element
  2929. .css( {
  2930. backgroundImage: "none",
  2931. backgroundColor: options.color || "#ffff99"
  2932. } )
  2933. .animate( animation, {
  2934. queue: false,
  2935. duration: options.duration,
  2936. easing: options.easing,
  2937. complete: done
  2938. } );
  2939. } );
  2940. /*!
  2941. * jQuery UI Effects Size 1.13.0
  2942. * http://jqueryui.com
  2943. *
  2944. * Copyright jQuery Foundation and other contributors
  2945. * Released under the MIT license.
  2946. * http://jquery.org/license
  2947. */
  2948. //>>label: Size Effect
  2949. //>>group: Effects
  2950. //>>description: Resize an element to a specified width and height.
  2951. //>>docs: http://api.jqueryui.com/size-effect/
  2952. //>>demos: http://jqueryui.com/effect/
  2953. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  2954. // Create element
  2955. var baseline, factor, temp,
  2956. element = $( this ),
  2957. // Copy for children
  2958. cProps = [ "fontSize" ],
  2959. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  2960. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  2961. // Set options
  2962. mode = options.mode,
  2963. restore = mode !== "effect",
  2964. scale = options.scale || "both",
  2965. origin = options.origin || [ "middle", "center" ],
  2966. position = element.css( "position" ),
  2967. pos = element.position(),
  2968. original = $.effects.scaledDimensions( element ),
  2969. from = options.from || original,
  2970. to = options.to || $.effects.scaledDimensions( element, 0 );
  2971. $.effects.createPlaceholder( element );
  2972. if ( mode === "show" ) {
  2973. temp = from;
  2974. from = to;
  2975. to = temp;
  2976. }
  2977. // Set scaling factor
  2978. factor = {
  2979. from: {
  2980. y: from.height / original.height,
  2981. x: from.width / original.width
  2982. },
  2983. to: {
  2984. y: to.height / original.height,
  2985. x: to.width / original.width
  2986. }
  2987. };
  2988. // Scale the css box
  2989. if ( scale === "box" || scale === "both" ) {
  2990. // Vertical props scaling
  2991. if ( factor.from.y !== factor.to.y ) {
  2992. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  2993. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  2994. }
  2995. // Horizontal props scaling
  2996. if ( factor.from.x !== factor.to.x ) {
  2997. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  2998. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  2999. }
  3000. }
  3001. // Scale the content
  3002. if ( scale === "content" || scale === "both" ) {
  3003. // Vertical props scaling
  3004. if ( factor.from.y !== factor.to.y ) {
  3005. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  3006. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  3007. }
  3008. }
  3009. // Adjust the position properties based on the provided origin points
  3010. if ( origin ) {
  3011. baseline = $.effects.getBaseline( origin, original );
  3012. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  3013. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  3014. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  3015. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  3016. }
  3017. delete from.outerHeight;
  3018. delete from.outerWidth;
  3019. element.css( from );
  3020. // Animate the children if desired
  3021. if ( scale === "content" || scale === "both" ) {
  3022. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  3023. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  3024. // Only animate children with width attributes specified
  3025. // TODO: is this right? should we include anything with css width specified as well
  3026. element.find( "*[width]" ).each( function() {
  3027. var child = $( this ),
  3028. childOriginal = $.effects.scaledDimensions( child ),
  3029. childFrom = {
  3030. height: childOriginal.height * factor.from.y,
  3031. width: childOriginal.width * factor.from.x,
  3032. outerHeight: childOriginal.outerHeight * factor.from.y,
  3033. outerWidth: childOriginal.outerWidth * factor.from.x
  3034. },
  3035. childTo = {
  3036. height: childOriginal.height * factor.to.y,
  3037. width: childOriginal.width * factor.to.x,
  3038. outerHeight: childOriginal.height * factor.to.y,
  3039. outerWidth: childOriginal.width * factor.to.x
  3040. };
  3041. // Vertical props scaling
  3042. if ( factor.from.y !== factor.to.y ) {
  3043. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  3044. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  3045. }
  3046. // Horizontal props scaling
  3047. if ( factor.from.x !== factor.to.x ) {
  3048. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  3049. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  3050. }
  3051. if ( restore ) {
  3052. $.effects.saveStyle( child );
  3053. }
  3054. // Animate children
  3055. child.css( childFrom );
  3056. child.animate( childTo, options.duration, options.easing, function() {
  3057. // Restore children
  3058. if ( restore ) {
  3059. $.effects.restoreStyle( child );
  3060. }
  3061. } );
  3062. } );
  3063. }
  3064. // Animate
  3065. element.animate( to, {
  3066. queue: false,
  3067. duration: options.duration,
  3068. easing: options.easing,
  3069. complete: function() {
  3070. var offset = element.offset();
  3071. if ( to.opacity === 0 ) {
  3072. element.css( "opacity", from.opacity );
  3073. }
  3074. if ( !restore ) {
  3075. element
  3076. .css( "position", position === "static" ? "relative" : position )
  3077. .offset( offset );
  3078. // Need to save style here so that automatic style restoration
  3079. // doesn't restore to the original styles from before the animation.
  3080. $.effects.saveStyle( element );
  3081. }
  3082. done();
  3083. }
  3084. } );
  3085. } );
  3086. /*!
  3087. * jQuery UI Effects Scale 1.13.0
  3088. * http://jqueryui.com
  3089. *
  3090. * Copyright jQuery Foundation and other contributors
  3091. * Released under the MIT license.
  3092. * http://jquery.org/license
  3093. */
  3094. //>>label: Scale Effect
  3095. //>>group: Effects
  3096. //>>description: Grows or shrinks an element and its content.
  3097. //>>docs: http://api.jqueryui.com/scale-effect/
  3098. //>>demos: http://jqueryui.com/effect/
  3099. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  3100. // Create element
  3101. var el = $( this ),
  3102. mode = options.mode,
  3103. percent = parseInt( options.percent, 10 ) ||
  3104. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  3105. newOptions = $.extend( true, {
  3106. from: $.effects.scaledDimensions( el ),
  3107. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  3108. origin: options.origin || [ "middle", "center" ]
  3109. }, options );
  3110. // Fade option to support puff
  3111. if ( options.fade ) {
  3112. newOptions.from.opacity = 1;
  3113. newOptions.to.opacity = 0;
  3114. }
  3115. $.effects.effect.size.call( this, newOptions, done );
  3116. } );
  3117. /*!
  3118. * jQuery UI Effects Puff 1.13.0
  3119. * http://jqueryui.com
  3120. *
  3121. * Copyright jQuery Foundation and other contributors
  3122. * Released under the MIT license.
  3123. * http://jquery.org/license
  3124. */
  3125. //>>label: Puff Effect
  3126. //>>group: Effects
  3127. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  3128. //>>docs: http://api.jqueryui.com/puff-effect/
  3129. //>>demos: http://jqueryui.com/effect/
  3130. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  3131. var newOptions = $.extend( true, {}, options, {
  3132. fade: true,
  3133. percent: parseInt( options.percent, 10 ) || 150
  3134. } );
  3135. $.effects.effect.scale.call( this, newOptions, done );
  3136. } );
  3137. /*!
  3138. * jQuery UI Effects Pulsate 1.13.0
  3139. * http://jqueryui.com
  3140. *
  3141. * Copyright jQuery Foundation and other contributors
  3142. * Released under the MIT license.
  3143. * http://jquery.org/license
  3144. */
  3145. //>>label: Pulsate Effect
  3146. //>>group: Effects
  3147. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  3148. //>>docs: http://api.jqueryui.com/pulsate-effect/
  3149. //>>demos: http://jqueryui.com/effect/
  3150. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  3151. var element = $( this ),
  3152. mode = options.mode,
  3153. show = mode === "show",
  3154. hide = mode === "hide",
  3155. showhide = show || hide,
  3156. // Showing or hiding leaves off the "last" animation
  3157. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  3158. duration = options.duration / anims,
  3159. animateTo = 0,
  3160. i = 1,
  3161. queuelen = element.queue().length;
  3162. if ( show || !element.is( ":visible" ) ) {
  3163. element.css( "opacity", 0 ).show();
  3164. animateTo = 1;
  3165. }
  3166. // Anims - 1 opacity "toggles"
  3167. for ( ; i < anims; i++ ) {
  3168. element.animate( { opacity: animateTo }, duration, options.easing );
  3169. animateTo = 1 - animateTo;
  3170. }
  3171. element.animate( { opacity: animateTo }, duration, options.easing );
  3172. element.queue( done );
  3173. $.effects.unshift( element, queuelen, anims + 1 );
  3174. } );
  3175. /*!
  3176. * jQuery UI Effects Shake 1.13.0
  3177. * http://jqueryui.com
  3178. *
  3179. * Copyright jQuery Foundation and other contributors
  3180. * Released under the MIT license.
  3181. * http://jquery.org/license
  3182. */
  3183. //>>label: Shake Effect
  3184. //>>group: Effects
  3185. //>>description: Shakes an element horizontally or vertically n times.
  3186. //>>docs: http://api.jqueryui.com/shake-effect/
  3187. //>>demos: http://jqueryui.com/effect/
  3188. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  3189. var i = 1,
  3190. element = $( this ),
  3191. direction = options.direction || "left",
  3192. distance = options.distance || 20,
  3193. times = options.times || 3,
  3194. anims = times * 2 + 1,
  3195. speed = Math.round( options.duration / anims ),
  3196. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3197. positiveMotion = ( direction === "up" || direction === "left" ),
  3198. animation = {},
  3199. animation1 = {},
  3200. animation2 = {},
  3201. queuelen = element.queue().length;
  3202. $.effects.createPlaceholder( element );
  3203. // Animation
  3204. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  3205. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  3206. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  3207. // Animate
  3208. element.animate( animation, speed, options.easing );
  3209. // Shakes
  3210. for ( ; i < times; i++ ) {
  3211. element
  3212. .animate( animation1, speed, options.easing )
  3213. .animate( animation2, speed, options.easing );
  3214. }
  3215. element
  3216. .animate( animation1, speed, options.easing )
  3217. .animate( animation, speed / 2, options.easing )
  3218. .queue( done );
  3219. $.effects.unshift( element, queuelen, anims + 1 );
  3220. } );
  3221. /*!
  3222. * jQuery UI Effects Slide 1.13.0
  3223. * http://jqueryui.com
  3224. *
  3225. * Copyright jQuery Foundation and other contributors
  3226. * Released under the MIT license.
  3227. * http://jquery.org/license
  3228. */
  3229. //>>label: Slide Effect
  3230. //>>group: Effects
  3231. //>>description: Slides an element in and out of the viewport.
  3232. //>>docs: http://api.jqueryui.com/slide-effect/
  3233. //>>demos: http://jqueryui.com/effect/
  3234. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  3235. var startClip, startRef,
  3236. element = $( this ),
  3237. map = {
  3238. up: [ "bottom", "top" ],
  3239. down: [ "top", "bottom" ],
  3240. left: [ "right", "left" ],
  3241. right: [ "left", "right" ]
  3242. },
  3243. mode = options.mode,
  3244. direction = options.direction || "left",
  3245. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3246. positiveMotion = ( direction === "up" || direction === "left" ),
  3247. distance = options.distance ||
  3248. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  3249. animation = {};
  3250. $.effects.createPlaceholder( element );
  3251. startClip = element.cssClip();
  3252. startRef = element.position()[ ref ];
  3253. // Define hide animation
  3254. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  3255. animation.clip = element.cssClip();
  3256. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  3257. // Reverse the animation if we're showing
  3258. if ( mode === "show" ) {
  3259. element.cssClip( animation.clip );
  3260. element.css( ref, animation[ ref ] );
  3261. animation.clip = startClip;
  3262. animation[ ref ] = startRef;
  3263. }
  3264. // Actually animate
  3265. element.animate( animation, {
  3266. queue: false,
  3267. duration: options.duration,
  3268. easing: options.easing,
  3269. complete: done
  3270. } );
  3271. } );
  3272. /*!
  3273. * jQuery UI Effects Transfer 1.13.0
  3274. * http://jqueryui.com
  3275. *
  3276. * Copyright jQuery Foundation and other contributors
  3277. * Released under the MIT license.
  3278. * http://jquery.org/license
  3279. */
  3280. //>>label: Transfer Effect
  3281. //>>group: Effects
  3282. //>>description: Displays a transfer effect from one element to another.
  3283. //>>docs: http://api.jqueryui.com/transfer-effect/
  3284. //>>demos: http://jqueryui.com/effect/
  3285. var effect;
  3286. if ( $.uiBackCompat !== false ) {
  3287. effect = $.effects.define( "transfer", function( options, done ) {
  3288. $( this ).transfer( options, done );
  3289. } );
  3290. }
  3291. var effectsEffectTransfer = effect;
  3292. /*!
  3293. * jQuery UI Focusable 1.13.0
  3294. * http://jqueryui.com
  3295. *
  3296. * Copyright jQuery Foundation and other contributors
  3297. * Released under the MIT license.
  3298. * http://jquery.org/license
  3299. */
  3300. //>>label: :focusable Selector
  3301. //>>group: Core
  3302. //>>description: Selects elements which can be focused.
  3303. //>>docs: http://api.jqueryui.com/focusable-selector/
  3304. // Selectors
  3305. $.ui.focusable = function( element, hasTabindex ) {
  3306. var map, mapName, img, focusableIfVisible, fieldset,
  3307. nodeName = element.nodeName.toLowerCase();
  3308. if ( "area" === nodeName ) {
  3309. map = element.parentNode;
  3310. mapName = map.name;
  3311. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  3312. return false;
  3313. }
  3314. img = $( "img[usemap='#" + mapName + "']" );
  3315. return img.length > 0 && img.is( ":visible" );
  3316. }
  3317. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  3318. focusableIfVisible = !element.disabled;
  3319. if ( focusableIfVisible ) {
  3320. // Form controls within a disabled fieldset are disabled.
  3321. // However, controls within the fieldset's legend do not get disabled.
  3322. // Since controls generally aren't placed inside legends, we skip
  3323. // this portion of the check.
  3324. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  3325. if ( fieldset ) {
  3326. focusableIfVisible = !fieldset.disabled;
  3327. }
  3328. }
  3329. } else if ( "a" === nodeName ) {
  3330. focusableIfVisible = element.href || hasTabindex;
  3331. } else {
  3332. focusableIfVisible = hasTabindex;
  3333. }
  3334. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  3335. };
  3336. // Support: IE 8 only
  3337. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  3338. function visible( element ) {
  3339. var visibility = element.css( "visibility" );
  3340. while ( visibility === "inherit" ) {
  3341. element = element.parent();
  3342. visibility = element.css( "visibility" );
  3343. }
  3344. return visibility === "visible";
  3345. }
  3346. $.extend( $.expr.pseudos, {
  3347. focusable: function( element ) {
  3348. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  3349. }
  3350. } );
  3351. var focusable = $.ui.focusable;
  3352. // Support: IE8 Only
  3353. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  3354. // with a string, so we need to find the proper form.
  3355. var form = $.fn._form = function() {
  3356. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  3357. };
  3358. /*!
  3359. * jQuery UI Form Reset Mixin 1.13.0
  3360. * http://jqueryui.com
  3361. *
  3362. * Copyright jQuery Foundation and other contributors
  3363. * Released under the MIT license.
  3364. * http://jquery.org/license
  3365. */
  3366. //>>label: Form Reset Mixin
  3367. //>>group: Core
  3368. //>>description: Refresh input widgets when their form is reset
  3369. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  3370. var formResetMixin = $.ui.formResetMixin = {
  3371. _formResetHandler: function() {
  3372. var form = $( this );
  3373. // Wait for the form reset to actually happen before refreshing
  3374. setTimeout( function() {
  3375. var instances = form.data( "ui-form-reset-instances" );
  3376. $.each( instances, function() {
  3377. this.refresh();
  3378. } );
  3379. } );
  3380. },
  3381. _bindFormResetHandler: function() {
  3382. this.form = this.element._form();
  3383. if ( !this.form.length ) {
  3384. return;
  3385. }
  3386. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  3387. if ( !instances.length ) {
  3388. // We don't use _on() here because we use a single event handler per form
  3389. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  3390. }
  3391. instances.push( this );
  3392. this.form.data( "ui-form-reset-instances", instances );
  3393. },
  3394. _unbindFormResetHandler: function() {
  3395. if ( !this.form.length ) {
  3396. return;
  3397. }
  3398. var instances = this.form.data( "ui-form-reset-instances" );
  3399. instances.splice( $.inArray( this, instances ), 1 );
  3400. if ( instances.length ) {
  3401. this.form.data( "ui-form-reset-instances", instances );
  3402. } else {
  3403. this.form
  3404. .removeData( "ui-form-reset-instances" )
  3405. .off( "reset.ui-form-reset" );
  3406. }
  3407. }
  3408. };
  3409. /*!
  3410. * jQuery UI Support for jQuery core 1.8.x and newer 1.13.0
  3411. * http://jqueryui.com
  3412. *
  3413. * Copyright jQuery Foundation and other contributors
  3414. * Released under the MIT license.
  3415. * http://jquery.org/license
  3416. *
  3417. */
  3418. //>>label: jQuery 1.8+ Support
  3419. //>>group: Core
  3420. //>>description: Support version 1.8.x and newer of jQuery core
  3421. // Support: jQuery 1.9.x or older
  3422. // $.expr[ ":" ] is deprecated.
  3423. if ( !$.expr.pseudos ) {
  3424. $.expr.pseudos = $.expr[ ":" ];
  3425. }
  3426. // Support: jQuery 1.11.x or older
  3427. // $.unique has been renamed to $.uniqueSort
  3428. if ( !$.uniqueSort ) {
  3429. $.uniqueSort = $.unique;
  3430. }
  3431. // Support: jQuery 2.2.x or older.
  3432. // This method has been defined in jQuery 3.0.0.
  3433. // Code from https://github.com/jquery/jquery/blob/e539bac79e666bba95bba86d690b4e609dca2286/src/selector/escapeSelector.js
  3434. if ( !$.escapeSelector ) {
  3435. // CSS string/identifier serialization
  3436. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  3437. var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
  3438. var fcssescape = function( ch, asCodePoint ) {
  3439. if ( asCodePoint ) {
  3440. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  3441. if ( ch === "\0" ) {
  3442. return "\uFFFD";
  3443. }
  3444. // Control characters and (dependent upon position) numbers get escaped as code points
  3445. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  3446. }
  3447. // Other potentially-special ASCII characters get backslash-escaped
  3448. return "\\" + ch;
  3449. };
  3450. $.escapeSelector = function( sel ) {
  3451. return ( sel + "" ).replace( rcssescape, fcssescape );
  3452. };
  3453. }
  3454. // Support: jQuery 3.4.x or older
  3455. // These methods have been defined in jQuery 3.5.0.
  3456. if ( !$.fn.even || !$.fn.odd ) {
  3457. $.fn.extend( {
  3458. even: function() {
  3459. return this.filter( function( i ) {
  3460. return i % 2 === 0;
  3461. } );
  3462. },
  3463. odd: function() {
  3464. return this.filter( function( i ) {
  3465. return i % 2 === 1;
  3466. } );
  3467. }
  3468. } );
  3469. }
  3470. ;
  3471. /*!
  3472. * jQuery UI Keycode 1.13.0
  3473. * http://jqueryui.com
  3474. *
  3475. * Copyright jQuery Foundation and other contributors
  3476. * Released under the MIT license.
  3477. * http://jquery.org/license
  3478. */
  3479. //>>label: Keycode
  3480. //>>group: Core
  3481. //>>description: Provide keycodes as keynames
  3482. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  3483. var keycode = $.ui.keyCode = {
  3484. BACKSPACE: 8,
  3485. COMMA: 188,
  3486. DELETE: 46,
  3487. DOWN: 40,
  3488. END: 35,
  3489. ENTER: 13,
  3490. ESCAPE: 27,
  3491. HOME: 36,
  3492. LEFT: 37,
  3493. PAGE_DOWN: 34,
  3494. PAGE_UP: 33,
  3495. PERIOD: 190,
  3496. RIGHT: 39,
  3497. SPACE: 32,
  3498. TAB: 9,
  3499. UP: 38
  3500. };
  3501. /*!
  3502. * jQuery UI Labels 1.13.0
  3503. * http://jqueryui.com
  3504. *
  3505. * Copyright jQuery Foundation and other contributors
  3506. * Released under the MIT license.
  3507. * http://jquery.org/license
  3508. */
  3509. //>>label: labels
  3510. //>>group: Core
  3511. //>>description: Find all the labels associated with a given input
  3512. //>>docs: http://api.jqueryui.com/labels/
  3513. var labels = $.fn.labels = function() {
  3514. var ancestor, selector, id, labels, ancestors;
  3515. if ( !this.length ) {
  3516. return this.pushStack( [] );
  3517. }
  3518. // Check control.labels first
  3519. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  3520. return this.pushStack( this[ 0 ].labels );
  3521. }
  3522. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  3523. // Above browsers do not support control.labels. Everything below is to support them
  3524. // as well as document fragments. control.labels does not work on document fragments
  3525. labels = this.eq( 0 ).parents( "label" );
  3526. // Look for the label based on the id
  3527. id = this.attr( "id" );
  3528. if ( id ) {
  3529. // We don't search against the document in case the element
  3530. // is disconnected from the DOM
  3531. ancestor = this.eq( 0 ).parents().last();
  3532. // Get a full set of top level ancestors
  3533. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  3534. // Create a selector for the label based on the id
  3535. selector = "label[for='" + $.escapeSelector( id ) + "']";
  3536. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  3537. }
  3538. // Return whatever we have found for labels
  3539. return this.pushStack( labels );
  3540. };
  3541. /*!
  3542. * jQuery UI Scroll Parent 1.13.0
  3543. * http://jqueryui.com
  3544. *
  3545. * Copyright jQuery Foundation and other contributors
  3546. * Released under the MIT license.
  3547. * http://jquery.org/license
  3548. */
  3549. //>>label: scrollParent
  3550. //>>group: Core
  3551. //>>description: Get the closest ancestor element that is scrollable.
  3552. //>>docs: http://api.jqueryui.com/scrollParent/
  3553. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  3554. var position = this.css( "position" ),
  3555. excludeStaticParent = position === "absolute",
  3556. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  3557. scrollParent = this.parents().filter( function() {
  3558. var parent = $( this );
  3559. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  3560. return false;
  3561. }
  3562. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  3563. parent.css( "overflow-x" ) );
  3564. } ).eq( 0 );
  3565. return position === "fixed" || !scrollParent.length ?
  3566. $( this[ 0 ].ownerDocument || document ) :
  3567. scrollParent;
  3568. };
  3569. /*!
  3570. * jQuery UI Tabbable 1.13.0
  3571. * http://jqueryui.com
  3572. *
  3573. * Copyright jQuery Foundation and other contributors
  3574. * Released under the MIT license.
  3575. * http://jquery.org/license
  3576. */
  3577. //>>label: :tabbable Selector
  3578. //>>group: Core
  3579. //>>description: Selects elements which can be tabbed to.
  3580. //>>docs: http://api.jqueryui.com/tabbable-selector/
  3581. var tabbable = $.extend( $.expr.pseudos, {
  3582. tabbable: function( element ) {
  3583. var tabIndex = $.attr( element, "tabindex" ),
  3584. hasTabindex = tabIndex != null;
  3585. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  3586. }
  3587. } );
  3588. /*!
  3589. * jQuery UI Unique ID 1.13.0
  3590. * http://jqueryui.com
  3591. *
  3592. * Copyright jQuery Foundation and other contributors
  3593. * Released under the MIT license.
  3594. * http://jquery.org/license
  3595. */
  3596. //>>label: uniqueId
  3597. //>>group: Core
  3598. //>>description: Functions to generate and remove uniqueId's
  3599. //>>docs: http://api.jqueryui.com/uniqueId/
  3600. var uniqueId = $.fn.extend( {
  3601. uniqueId: ( function() {
  3602. var uuid = 0;
  3603. return function() {
  3604. return this.each( function() {
  3605. if ( !this.id ) {
  3606. this.id = "ui-id-" + ( ++uuid );
  3607. }
  3608. } );
  3609. };
  3610. } )(),
  3611. removeUniqueId: function() {
  3612. return this.each( function() {
  3613. if ( /^ui-id-\d+$/.test( this.id ) ) {
  3614. $( this ).removeAttr( "id" );
  3615. }
  3616. } );
  3617. }
  3618. } );
  3619. /*!
  3620. * jQuery UI Accordion 1.13.0
  3621. * http://jqueryui.com
  3622. *
  3623. * Copyright jQuery Foundation and other contributors
  3624. * Released under the MIT license.
  3625. * http://jquery.org/license
  3626. */
  3627. //>>label: Accordion
  3628. //>>group: Widgets
  3629. /* eslint-disable max-len */
  3630. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  3631. /* eslint-enable max-len */
  3632. //>>docs: http://api.jqueryui.com/accordion/
  3633. //>>demos: http://jqueryui.com/accordion/
  3634. //>>css.structure: ../../themes/base/core.css
  3635. //>>css.structure: ../../themes/base/accordion.css
  3636. //>>css.theme: ../../themes/base/theme.css
  3637. var widgetsAccordion = $.widget( "ui.accordion", {
  3638. version: "1.13.0",
  3639. options: {
  3640. active: 0,
  3641. animate: {},
  3642. classes: {
  3643. "ui-accordion-header": "ui-corner-top",
  3644. "ui-accordion-header-collapsed": "ui-corner-all",
  3645. "ui-accordion-content": "ui-corner-bottom"
  3646. },
  3647. collapsible: false,
  3648. event: "click",
  3649. header: function( elem ) {
  3650. return elem.find( "> li > :first-child" ).add( elem.find( "> :not(li)" ).even() );
  3651. },
  3652. heightStyle: "auto",
  3653. icons: {
  3654. activeHeader: "ui-icon-triangle-1-s",
  3655. header: "ui-icon-triangle-1-e"
  3656. },
  3657. // Callbacks
  3658. activate: null,
  3659. beforeActivate: null
  3660. },
  3661. hideProps: {
  3662. borderTopWidth: "hide",
  3663. borderBottomWidth: "hide",
  3664. paddingTop: "hide",
  3665. paddingBottom: "hide",
  3666. height: "hide"
  3667. },
  3668. showProps: {
  3669. borderTopWidth: "show",
  3670. borderBottomWidth: "show",
  3671. paddingTop: "show",
  3672. paddingBottom: "show",
  3673. height: "show"
  3674. },
  3675. _create: function() {
  3676. var options = this.options;
  3677. this.prevShow = this.prevHide = $();
  3678. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  3679. this.element.attr( "role", "tablist" );
  3680. // Don't allow collapsible: false and active: false / null
  3681. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  3682. options.active = 0;
  3683. }
  3684. this._processPanels();
  3685. // handle negative values
  3686. if ( options.active < 0 ) {
  3687. options.active += this.headers.length;
  3688. }
  3689. this._refresh();
  3690. },
  3691. _getCreateEventData: function() {
  3692. return {
  3693. header: this.active,
  3694. panel: !this.active.length ? $() : this.active.next()
  3695. };
  3696. },
  3697. _createIcons: function() {
  3698. var icon, children,
  3699. icons = this.options.icons;
  3700. if ( icons ) {
  3701. icon = $( "<span>" );
  3702. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  3703. icon.prependTo( this.headers );
  3704. children = this.active.children( ".ui-accordion-header-icon" );
  3705. this._removeClass( children, icons.header )
  3706. ._addClass( children, null, icons.activeHeader )
  3707. ._addClass( this.headers, "ui-accordion-icons" );
  3708. }
  3709. },
  3710. _destroyIcons: function() {
  3711. this._removeClass( this.headers, "ui-accordion-icons" );
  3712. this.headers.children( ".ui-accordion-header-icon" ).remove();
  3713. },
  3714. _destroy: function() {
  3715. var contents;
  3716. // Clean up main element
  3717. this.element.removeAttr( "role" );
  3718. // Clean up headers
  3719. this.headers
  3720. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  3721. .removeUniqueId();
  3722. this._destroyIcons();
  3723. // Clean up content panels
  3724. contents = this.headers.next()
  3725. .css( "display", "" )
  3726. .removeAttr( "role aria-hidden aria-labelledby" )
  3727. .removeUniqueId();
  3728. if ( this.options.heightStyle !== "content" ) {
  3729. contents.css( "height", "" );
  3730. }
  3731. },
  3732. _setOption: function( key, value ) {
  3733. if ( key === "active" ) {
  3734. // _activate() will handle invalid values and update this.options
  3735. this._activate( value );
  3736. return;
  3737. }
  3738. if ( key === "event" ) {
  3739. if ( this.options.event ) {
  3740. this._off( this.headers, this.options.event );
  3741. }
  3742. this._setupEvents( value );
  3743. }
  3744. this._super( key, value );
  3745. // Setting collapsible: false while collapsed; open first panel
  3746. if ( key === "collapsible" && !value && this.options.active === false ) {
  3747. this._activate( 0 );
  3748. }
  3749. if ( key === "icons" ) {
  3750. this._destroyIcons();
  3751. if ( value ) {
  3752. this._createIcons();
  3753. }
  3754. }
  3755. },
  3756. _setOptionDisabled: function( value ) {
  3757. this._super( value );
  3758. this.element.attr( "aria-disabled", value );
  3759. // Support: IE8 Only
  3760. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  3761. // so we need to add the disabled class to the headers and panels
  3762. this._toggleClass( null, "ui-state-disabled", !!value );
  3763. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  3764. !!value );
  3765. },
  3766. _keydown: function( event ) {
  3767. if ( event.altKey || event.ctrlKey ) {
  3768. return;
  3769. }
  3770. var keyCode = $.ui.keyCode,
  3771. length = this.headers.length,
  3772. currentIndex = this.headers.index( event.target ),
  3773. toFocus = false;
  3774. switch ( event.keyCode ) {
  3775. case keyCode.RIGHT:
  3776. case keyCode.DOWN:
  3777. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  3778. break;
  3779. case keyCode.LEFT:
  3780. case keyCode.UP:
  3781. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  3782. break;
  3783. case keyCode.SPACE:
  3784. case keyCode.ENTER:
  3785. this._eventHandler( event );
  3786. break;
  3787. case keyCode.HOME:
  3788. toFocus = this.headers[ 0 ];
  3789. break;
  3790. case keyCode.END:
  3791. toFocus = this.headers[ length - 1 ];
  3792. break;
  3793. }
  3794. if ( toFocus ) {
  3795. $( event.target ).attr( "tabIndex", -1 );
  3796. $( toFocus ).attr( "tabIndex", 0 );
  3797. $( toFocus ).trigger( "focus" );
  3798. event.preventDefault();
  3799. }
  3800. },
  3801. _panelKeyDown: function( event ) {
  3802. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  3803. $( event.currentTarget ).prev().trigger( "focus" );
  3804. }
  3805. },
  3806. refresh: function() {
  3807. var options = this.options;
  3808. this._processPanels();
  3809. // Was collapsed or no panel
  3810. if ( ( options.active === false && options.collapsible === true ) ||
  3811. !this.headers.length ) {
  3812. options.active = false;
  3813. this.active = $();
  3814. // active false only when collapsible is true
  3815. } else if ( options.active === false ) {
  3816. this._activate( 0 );
  3817. // was active, but active panel is gone
  3818. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  3819. // all remaining panel are disabled
  3820. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  3821. options.active = false;
  3822. this.active = $();
  3823. // activate previous panel
  3824. } else {
  3825. this._activate( Math.max( 0, options.active - 1 ) );
  3826. }
  3827. // was active, active panel still exists
  3828. } else {
  3829. // make sure active index is correct
  3830. options.active = this.headers.index( this.active );
  3831. }
  3832. this._destroyIcons();
  3833. this._refresh();
  3834. },
  3835. _processPanels: function() {
  3836. var prevHeaders = this.headers,
  3837. prevPanels = this.panels;
  3838. if ( typeof this.options.header === "function" ) {
  3839. this.headers = this.options.header( this.element );
  3840. } else {
  3841. this.headers = this.element.find( this.options.header );
  3842. }
  3843. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  3844. "ui-state-default" );
  3845. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  3846. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  3847. // Avoid memory leaks (#10056)
  3848. if ( prevPanels ) {
  3849. this._off( prevHeaders.not( this.headers ) );
  3850. this._off( prevPanels.not( this.panels ) );
  3851. }
  3852. },
  3853. _refresh: function() {
  3854. var maxHeight,
  3855. options = this.options,
  3856. heightStyle = options.heightStyle,
  3857. parent = this.element.parent();
  3858. this.active = this._findActive( options.active );
  3859. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  3860. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  3861. this._addClass( this.active.next(), "ui-accordion-content-active" );
  3862. this.active.next().show();
  3863. this.headers
  3864. .attr( "role", "tab" )
  3865. .each( function() {
  3866. var header = $( this ),
  3867. headerId = header.uniqueId().attr( "id" ),
  3868. panel = header.next(),
  3869. panelId = panel.uniqueId().attr( "id" );
  3870. header.attr( "aria-controls", panelId );
  3871. panel.attr( "aria-labelledby", headerId );
  3872. } )
  3873. .next()
  3874. .attr( "role", "tabpanel" );
  3875. this.headers
  3876. .not( this.active )
  3877. .attr( {
  3878. "aria-selected": "false",
  3879. "aria-expanded": "false",
  3880. tabIndex: -1
  3881. } )
  3882. .next()
  3883. .attr( {
  3884. "aria-hidden": "true"
  3885. } )
  3886. .hide();
  3887. // Make sure at least one header is in the tab order
  3888. if ( !this.active.length ) {
  3889. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  3890. } else {
  3891. this.active.attr( {
  3892. "aria-selected": "true",
  3893. "aria-expanded": "true",
  3894. tabIndex: 0
  3895. } )
  3896. .next()
  3897. .attr( {
  3898. "aria-hidden": "false"
  3899. } );
  3900. }
  3901. this._createIcons();
  3902. this._setupEvents( options.event );
  3903. if ( heightStyle === "fill" ) {
  3904. maxHeight = parent.height();
  3905. this.element.siblings( ":visible" ).each( function() {
  3906. var elem = $( this ),
  3907. position = elem.css( "position" );
  3908. if ( position === "absolute" || position === "fixed" ) {
  3909. return;
  3910. }
  3911. maxHeight -= elem.outerHeight( true );
  3912. } );
  3913. this.headers.each( function() {
  3914. maxHeight -= $( this ).outerHeight( true );
  3915. } );
  3916. this.headers.next()
  3917. .each( function() {
  3918. $( this ).height( Math.max( 0, maxHeight -
  3919. $( this ).innerHeight() + $( this ).height() ) );
  3920. } )
  3921. .css( "overflow", "auto" );
  3922. } else if ( heightStyle === "auto" ) {
  3923. maxHeight = 0;
  3924. this.headers.next()
  3925. .each( function() {
  3926. var isVisible = $( this ).is( ":visible" );
  3927. if ( !isVisible ) {
  3928. $( this ).show();
  3929. }
  3930. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  3931. if ( !isVisible ) {
  3932. $( this ).hide();
  3933. }
  3934. } )
  3935. .height( maxHeight );
  3936. }
  3937. },
  3938. _activate: function( index ) {
  3939. var active = this._findActive( index )[ 0 ];
  3940. // Trying to activate the already active panel
  3941. if ( active === this.active[ 0 ] ) {
  3942. return;
  3943. }
  3944. // Trying to collapse, simulate a click on the currently active header
  3945. active = active || this.active[ 0 ];
  3946. this._eventHandler( {
  3947. target: active,
  3948. currentTarget: active,
  3949. preventDefault: $.noop
  3950. } );
  3951. },
  3952. _findActive: function( selector ) {
  3953. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  3954. },
  3955. _setupEvents: function( event ) {
  3956. var events = {
  3957. keydown: "_keydown"
  3958. };
  3959. if ( event ) {
  3960. $.each( event.split( " " ), function( index, eventName ) {
  3961. events[ eventName ] = "_eventHandler";
  3962. } );
  3963. }
  3964. this._off( this.headers.add( this.headers.next() ) );
  3965. this._on( this.headers, events );
  3966. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  3967. this._hoverable( this.headers );
  3968. this._focusable( this.headers );
  3969. },
  3970. _eventHandler: function( event ) {
  3971. var activeChildren, clickedChildren,
  3972. options = this.options,
  3973. active = this.active,
  3974. clicked = $( event.currentTarget ),
  3975. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  3976. collapsing = clickedIsActive && options.collapsible,
  3977. toShow = collapsing ? $() : clicked.next(),
  3978. toHide = active.next(),
  3979. eventData = {
  3980. oldHeader: active,
  3981. oldPanel: toHide,
  3982. newHeader: collapsing ? $() : clicked,
  3983. newPanel: toShow
  3984. };
  3985. event.preventDefault();
  3986. if (
  3987. // click on active header, but not collapsible
  3988. ( clickedIsActive && !options.collapsible ) ||
  3989. // allow canceling activation
  3990. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  3991. return;
  3992. }
  3993. options.active = collapsing ? false : this.headers.index( clicked );
  3994. // When the call to ._toggle() comes after the class changes
  3995. // it causes a very odd bug in IE 8 (see #6720)
  3996. this.active = clickedIsActive ? $() : clicked;
  3997. this._toggle( eventData );
  3998. // Switch classes
  3999. // corner classes on the previously active header stay after the animation
  4000. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  4001. if ( options.icons ) {
  4002. activeChildren = active.children( ".ui-accordion-header-icon" );
  4003. this._removeClass( activeChildren, null, options.icons.activeHeader )
  4004. ._addClass( activeChildren, null, options.icons.header );
  4005. }
  4006. if ( !clickedIsActive ) {
  4007. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  4008. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  4009. if ( options.icons ) {
  4010. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  4011. this._removeClass( clickedChildren, null, options.icons.header )
  4012. ._addClass( clickedChildren, null, options.icons.activeHeader );
  4013. }
  4014. this._addClass( clicked.next(), "ui-accordion-content-active" );
  4015. }
  4016. },
  4017. _toggle: function( data ) {
  4018. var toShow = data.newPanel,
  4019. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  4020. // Handle activating a panel during the animation for another activation
  4021. this.prevShow.add( this.prevHide ).stop( true, true );
  4022. this.prevShow = toShow;
  4023. this.prevHide = toHide;
  4024. if ( this.options.animate ) {
  4025. this._animate( toShow, toHide, data );
  4026. } else {
  4027. toHide.hide();
  4028. toShow.show();
  4029. this._toggleComplete( data );
  4030. }
  4031. toHide.attr( {
  4032. "aria-hidden": "true"
  4033. } );
  4034. toHide.prev().attr( {
  4035. "aria-selected": "false",
  4036. "aria-expanded": "false"
  4037. } );
  4038. // if we're switching panels, remove the old header from the tab order
  4039. // if we're opening from collapsed state, remove the previous header from the tab order
  4040. // if we're collapsing, then keep the collapsing header in the tab order
  4041. if ( toShow.length && toHide.length ) {
  4042. toHide.prev().attr( {
  4043. "tabIndex": -1,
  4044. "aria-expanded": "false"
  4045. } );
  4046. } else if ( toShow.length ) {
  4047. this.headers.filter( function() {
  4048. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  4049. } )
  4050. .attr( "tabIndex", -1 );
  4051. }
  4052. toShow
  4053. .attr( "aria-hidden", "false" )
  4054. .prev()
  4055. .attr( {
  4056. "aria-selected": "true",
  4057. "aria-expanded": "true",
  4058. tabIndex: 0
  4059. } );
  4060. },
  4061. _animate: function( toShow, toHide, data ) {
  4062. var total, easing, duration,
  4063. that = this,
  4064. adjust = 0,
  4065. boxSizing = toShow.css( "box-sizing" ),
  4066. down = toShow.length &&
  4067. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  4068. animate = this.options.animate || {},
  4069. options = down && animate.down || animate,
  4070. complete = function() {
  4071. that._toggleComplete( data );
  4072. };
  4073. if ( typeof options === "number" ) {
  4074. duration = options;
  4075. }
  4076. if ( typeof options === "string" ) {
  4077. easing = options;
  4078. }
  4079. // fall back from options to animation in case of partial down settings
  4080. easing = easing || options.easing || animate.easing;
  4081. duration = duration || options.duration || animate.duration;
  4082. if ( !toHide.length ) {
  4083. return toShow.animate( this.showProps, duration, easing, complete );
  4084. }
  4085. if ( !toShow.length ) {
  4086. return toHide.animate( this.hideProps, duration, easing, complete );
  4087. }
  4088. total = toShow.show().outerHeight();
  4089. toHide.animate( this.hideProps, {
  4090. duration: duration,
  4091. easing: easing,
  4092. step: function( now, fx ) {
  4093. fx.now = Math.round( now );
  4094. }
  4095. } );
  4096. toShow
  4097. .hide()
  4098. .animate( this.showProps, {
  4099. duration: duration,
  4100. easing: easing,
  4101. complete: complete,
  4102. step: function( now, fx ) {
  4103. fx.now = Math.round( now );
  4104. if ( fx.prop !== "height" ) {
  4105. if ( boxSizing === "content-box" ) {
  4106. adjust += fx.now;
  4107. }
  4108. } else if ( that.options.heightStyle !== "content" ) {
  4109. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  4110. adjust = 0;
  4111. }
  4112. }
  4113. } );
  4114. },
  4115. _toggleComplete: function( data ) {
  4116. var toHide = data.oldPanel,
  4117. prev = toHide.prev();
  4118. this._removeClass( toHide, "ui-accordion-content-active" );
  4119. this._removeClass( prev, "ui-accordion-header-active" )
  4120. ._addClass( prev, "ui-accordion-header-collapsed" );
  4121. // Work around for rendering bug in IE (#5421)
  4122. if ( toHide.length ) {
  4123. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  4124. }
  4125. this._trigger( "activate", null, data );
  4126. }
  4127. } );
  4128. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  4129. var activeElement;
  4130. // Support: IE 9 only
  4131. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  4132. try {
  4133. activeElement = document.activeElement;
  4134. } catch ( error ) {
  4135. activeElement = document.body;
  4136. }
  4137. // Support: IE 9 - 11 only
  4138. // IE may return null instead of an element
  4139. // Interestingly, this only seems to occur when NOT in an iframe
  4140. if ( !activeElement ) {
  4141. activeElement = document.body;
  4142. }
  4143. // Support: IE 11 only
  4144. // IE11 returns a seemingly empty object in some cases when accessing
  4145. // document.activeElement from an <iframe>
  4146. if ( !activeElement.nodeName ) {
  4147. activeElement = document.body;
  4148. }
  4149. return activeElement;
  4150. };
  4151. /*!
  4152. * jQuery UI Menu 1.13.0
  4153. * http://jqueryui.com
  4154. *
  4155. * Copyright jQuery Foundation and other contributors
  4156. * Released under the MIT license.
  4157. * http://jquery.org/license
  4158. */
  4159. //>>label: Menu
  4160. //>>group: Widgets
  4161. //>>description: Creates nestable menus.
  4162. //>>docs: http://api.jqueryui.com/menu/
  4163. //>>demos: http://jqueryui.com/menu/
  4164. //>>css.structure: ../../themes/base/core.css
  4165. //>>css.structure: ../../themes/base/menu.css
  4166. //>>css.theme: ../../themes/base/theme.css
  4167. var widgetsMenu = $.widget( "ui.menu", {
  4168. version: "1.13.0",
  4169. defaultElement: "<ul>",
  4170. delay: 300,
  4171. options: {
  4172. icons: {
  4173. submenu: "ui-icon-caret-1-e"
  4174. },
  4175. items: "> *",
  4176. menus: "ul",
  4177. position: {
  4178. my: "left top",
  4179. at: "right top"
  4180. },
  4181. role: "menu",
  4182. // Callbacks
  4183. blur: null,
  4184. focus: null,
  4185. select: null
  4186. },
  4187. _create: function() {
  4188. this.activeMenu = this.element;
  4189. // Flag used to prevent firing of the click handler
  4190. // as the event bubbles up through nested menus
  4191. this.mouseHandled = false;
  4192. this.lastMousePosition = { x: null, y: null };
  4193. this.element
  4194. .uniqueId()
  4195. .attr( {
  4196. role: this.options.role,
  4197. tabIndex: 0
  4198. } );
  4199. this._addClass( "ui-menu", "ui-widget ui-widget-content" );
  4200. this._on( {
  4201. // Prevent focus from sticking to links inside menu after clicking
  4202. // them (focus should always stay on UL during navigation).
  4203. "mousedown .ui-menu-item": function( event ) {
  4204. event.preventDefault();
  4205. this._activateItem( event );
  4206. },
  4207. "click .ui-menu-item": function( event ) {
  4208. var target = $( event.target );
  4209. var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  4210. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  4211. this.select( event );
  4212. // Only set the mouseHandled flag if the event will bubble, see #9469.
  4213. if ( !event.isPropagationStopped() ) {
  4214. this.mouseHandled = true;
  4215. }
  4216. // Open submenu on click
  4217. if ( target.has( ".ui-menu" ).length ) {
  4218. this.expand( event );
  4219. } else if ( !this.element.is( ":focus" ) &&
  4220. active.closest( ".ui-menu" ).length ) {
  4221. // Redirect focus to the menu
  4222. this.element.trigger( "focus", [ true ] );
  4223. // If the active item is on the top level, let it stay active.
  4224. // Otherwise, blur the active item since it is no longer visible.
  4225. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  4226. clearTimeout( this.timer );
  4227. }
  4228. }
  4229. }
  4230. },
  4231. "mouseenter .ui-menu-item": "_activateItem",
  4232. "mousemove .ui-menu-item": "_activateItem",
  4233. mouseleave: "collapseAll",
  4234. "mouseleave .ui-menu": "collapseAll",
  4235. focus: function( event, keepActiveItem ) {
  4236. // If there's already an active item, keep it active
  4237. // If not, activate the first item
  4238. var item = this.active || this._menuItems().first();
  4239. if ( !keepActiveItem ) {
  4240. this.focus( event, item );
  4241. }
  4242. },
  4243. blur: function( event ) {
  4244. this._delay( function() {
  4245. var notContained = !$.contains(
  4246. this.element[ 0 ],
  4247. $.ui.safeActiveElement( this.document[ 0 ] )
  4248. );
  4249. if ( notContained ) {
  4250. this.collapseAll( event );
  4251. }
  4252. } );
  4253. },
  4254. keydown: "_keydown"
  4255. } );
  4256. this.refresh();
  4257. // Clicks outside of a menu collapse any open menus
  4258. this._on( this.document, {
  4259. click: function( event ) {
  4260. if ( this._closeOnDocumentClick( event ) ) {
  4261. this.collapseAll( event, true );
  4262. }
  4263. // Reset the mouseHandled flag
  4264. this.mouseHandled = false;
  4265. }
  4266. } );
  4267. },
  4268. _activateItem: function( event ) {
  4269. // Ignore mouse events while typeahead is active, see #10458.
  4270. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  4271. // is over an item in the menu
  4272. if ( this.previousFilter ) {
  4273. return;
  4274. }
  4275. // If the mouse didn't actually move, but the page was scrolled, ignore the event (#9356)
  4276. if ( event.clientX === this.lastMousePosition.x &&
  4277. event.clientY === this.lastMousePosition.y ) {
  4278. return;
  4279. }
  4280. this.lastMousePosition = {
  4281. x: event.clientX,
  4282. y: event.clientY
  4283. };
  4284. var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
  4285. target = $( event.currentTarget );
  4286. // Ignore bubbled events on parent items, see #11641
  4287. if ( actualTarget[ 0 ] !== target[ 0 ] ) {
  4288. return;
  4289. }
  4290. // If the item is already active, there's nothing to do
  4291. if ( target.is( ".ui-state-active" ) ) {
  4292. return;
  4293. }
  4294. // Remove ui-state-active class from siblings of the newly focused menu item
  4295. // to avoid a jump caused by adjacent elements both having a class with a border
  4296. this._removeClass( target.siblings().children( ".ui-state-active" ),
  4297. null, "ui-state-active" );
  4298. this.focus( event, target );
  4299. },
  4300. _destroy: function() {
  4301. var items = this.element.find( ".ui-menu-item" )
  4302. .removeAttr( "role aria-disabled" ),
  4303. submenus = items.children( ".ui-menu-item-wrapper" )
  4304. .removeUniqueId()
  4305. .removeAttr( "tabIndex role aria-haspopup" );
  4306. // Destroy (sub)menus
  4307. this.element
  4308. .removeAttr( "aria-activedescendant" )
  4309. .find( ".ui-menu" ).addBack()
  4310. .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
  4311. "tabIndex" )
  4312. .removeUniqueId()
  4313. .show();
  4314. submenus.children().each( function() {
  4315. var elem = $( this );
  4316. if ( elem.data( "ui-menu-submenu-caret" ) ) {
  4317. elem.remove();
  4318. }
  4319. } );
  4320. },
  4321. _keydown: function( event ) {
  4322. var match, prev, character, skip,
  4323. preventDefault = true;
  4324. switch ( event.keyCode ) {
  4325. case $.ui.keyCode.PAGE_UP:
  4326. this.previousPage( event );
  4327. break;
  4328. case $.ui.keyCode.PAGE_DOWN:
  4329. this.nextPage( event );
  4330. break;
  4331. case $.ui.keyCode.HOME:
  4332. this._move( "first", "first", event );
  4333. break;
  4334. case $.ui.keyCode.END:
  4335. this._move( "last", "last", event );
  4336. break;
  4337. case $.ui.keyCode.UP:
  4338. this.previous( event );
  4339. break;
  4340. case $.ui.keyCode.DOWN:
  4341. this.next( event );
  4342. break;
  4343. case $.ui.keyCode.LEFT:
  4344. this.collapse( event );
  4345. break;
  4346. case $.ui.keyCode.RIGHT:
  4347. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4348. this.expand( event );
  4349. }
  4350. break;
  4351. case $.ui.keyCode.ENTER:
  4352. case $.ui.keyCode.SPACE:
  4353. this._activate( event );
  4354. break;
  4355. case $.ui.keyCode.ESCAPE:
  4356. this.collapse( event );
  4357. break;
  4358. default:
  4359. preventDefault = false;
  4360. prev = this.previousFilter || "";
  4361. skip = false;
  4362. // Support number pad values
  4363. character = event.keyCode >= 96 && event.keyCode <= 105 ?
  4364. ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode );
  4365. clearTimeout( this.filterTimer );
  4366. if ( character === prev ) {
  4367. skip = true;
  4368. } else {
  4369. character = prev + character;
  4370. }
  4371. match = this._filterMenuItems( character );
  4372. match = skip && match.index( this.active.next() ) !== -1 ?
  4373. this.active.nextAll( ".ui-menu-item" ) :
  4374. match;
  4375. // If no matches on the current filter, reset to the last character pressed
  4376. // to move down the menu to the first item that starts with that character
  4377. if ( !match.length ) {
  4378. character = String.fromCharCode( event.keyCode );
  4379. match = this._filterMenuItems( character );
  4380. }
  4381. if ( match.length ) {
  4382. this.focus( event, match );
  4383. this.previousFilter = character;
  4384. this.filterTimer = this._delay( function() {
  4385. delete this.previousFilter;
  4386. }, 1000 );
  4387. } else {
  4388. delete this.previousFilter;
  4389. }
  4390. }
  4391. if ( preventDefault ) {
  4392. event.preventDefault();
  4393. }
  4394. },
  4395. _activate: function( event ) {
  4396. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4397. if ( this.active.children( "[aria-haspopup='true']" ).length ) {
  4398. this.expand( event );
  4399. } else {
  4400. this.select( event );
  4401. }
  4402. }
  4403. },
  4404. refresh: function() {
  4405. var menus, items, newSubmenus, newItems, newWrappers,
  4406. that = this,
  4407. icon = this.options.icons.submenu,
  4408. submenus = this.element.find( this.options.menus );
  4409. this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
  4410. // Initialize nested menus
  4411. newSubmenus = submenus.filter( ":not(.ui-menu)" )
  4412. .hide()
  4413. .attr( {
  4414. role: this.options.role,
  4415. "aria-hidden": "true",
  4416. "aria-expanded": "false"
  4417. } )
  4418. .each( function() {
  4419. var menu = $( this ),
  4420. item = menu.prev(),
  4421. submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
  4422. that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
  4423. item
  4424. .attr( "aria-haspopup", "true" )
  4425. .prepend( submenuCaret );
  4426. menu.attr( "aria-labelledby", item.attr( "id" ) );
  4427. } );
  4428. this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
  4429. menus = submenus.add( this.element );
  4430. items = menus.find( this.options.items );
  4431. // Initialize menu-items containing spaces and/or dashes only as dividers
  4432. items.not( ".ui-menu-item" ).each( function() {
  4433. var item = $( this );
  4434. if ( that._isDivider( item ) ) {
  4435. that._addClass( item, "ui-menu-divider", "ui-widget-content" );
  4436. }
  4437. } );
  4438. // Don't refresh list items that are already adapted
  4439. newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
  4440. newWrappers = newItems.children()
  4441. .not( ".ui-menu" )
  4442. .uniqueId()
  4443. .attr( {
  4444. tabIndex: -1,
  4445. role: this._itemRole()
  4446. } );
  4447. this._addClass( newItems, "ui-menu-item" )
  4448. ._addClass( newWrappers, "ui-menu-item-wrapper" );
  4449. // Add aria-disabled attribute to any disabled menu item
  4450. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  4451. // If the active item has been removed, blur the menu
  4452. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4453. this.blur();
  4454. }
  4455. },
  4456. _itemRole: function() {
  4457. return {
  4458. menu: "menuitem",
  4459. listbox: "option"
  4460. }[ this.options.role ];
  4461. },
  4462. _setOption: function( key, value ) {
  4463. if ( key === "icons" ) {
  4464. var icons = this.element.find( ".ui-menu-icon" );
  4465. this._removeClass( icons, null, this.options.icons.submenu )
  4466. ._addClass( icons, null, value.submenu );
  4467. }
  4468. this._super( key, value );
  4469. },
  4470. _setOptionDisabled: function( value ) {
  4471. this._super( value );
  4472. this.element.attr( "aria-disabled", String( value ) );
  4473. this._toggleClass( null, "ui-state-disabled", !!value );
  4474. },
  4475. focus: function( event, item ) {
  4476. var nested, focused, activeParent;
  4477. this.blur( event, event && event.type === "focus" );
  4478. this._scrollIntoView( item );
  4479. this.active = item.first();
  4480. focused = this.active.children( ".ui-menu-item-wrapper" );
  4481. this._addClass( focused, null, "ui-state-active" );
  4482. // Only update aria-activedescendant if there's a role
  4483. // otherwise we assume focus is managed elsewhere
  4484. if ( this.options.role ) {
  4485. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  4486. }
  4487. // Highlight active parent menu item, if any
  4488. activeParent = this.active
  4489. .parent()
  4490. .closest( ".ui-menu-item" )
  4491. .children( ".ui-menu-item-wrapper" );
  4492. this._addClass( activeParent, null, "ui-state-active" );
  4493. if ( event && event.type === "keydown" ) {
  4494. this._close();
  4495. } else {
  4496. this.timer = this._delay( function() {
  4497. this._close();
  4498. }, this.delay );
  4499. }
  4500. nested = item.children( ".ui-menu" );
  4501. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  4502. this._startOpening( nested );
  4503. }
  4504. this.activeMenu = item.parent();
  4505. this._trigger( "focus", event, { item: item } );
  4506. },
  4507. _scrollIntoView: function( item ) {
  4508. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  4509. if ( this._hasScroll() ) {
  4510. borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
  4511. paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
  4512. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  4513. scroll = this.activeMenu.scrollTop();
  4514. elementHeight = this.activeMenu.height();
  4515. itemHeight = item.outerHeight();
  4516. if ( offset < 0 ) {
  4517. this.activeMenu.scrollTop( scroll + offset );
  4518. } else if ( offset + itemHeight > elementHeight ) {
  4519. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  4520. }
  4521. }
  4522. },
  4523. blur: function( event, fromFocus ) {
  4524. if ( !fromFocus ) {
  4525. clearTimeout( this.timer );
  4526. }
  4527. if ( !this.active ) {
  4528. return;
  4529. }
  4530. this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
  4531. null, "ui-state-active" );
  4532. this._trigger( "blur", event, { item: this.active } );
  4533. this.active = null;
  4534. },
  4535. _startOpening: function( submenu ) {
  4536. clearTimeout( this.timer );
  4537. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  4538. // shift in the submenu position when mousing over the caret icon
  4539. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  4540. return;
  4541. }
  4542. this.timer = this._delay( function() {
  4543. this._close();
  4544. this._open( submenu );
  4545. }, this.delay );
  4546. },
  4547. _open: function( submenu ) {
  4548. var position = $.extend( {
  4549. of: this.active
  4550. }, this.options.position );
  4551. clearTimeout( this.timer );
  4552. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  4553. .hide()
  4554. .attr( "aria-hidden", "true" );
  4555. submenu
  4556. .show()
  4557. .removeAttr( "aria-hidden" )
  4558. .attr( "aria-expanded", "true" )
  4559. .position( position );
  4560. },
  4561. collapseAll: function( event, all ) {
  4562. clearTimeout( this.timer );
  4563. this.timer = this._delay( function() {
  4564. // If we were passed an event, look for the submenu that contains the event
  4565. var currentMenu = all ? this.element :
  4566. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  4567. // If we found no valid submenu ancestor, use the main menu to close all
  4568. // sub menus anyway
  4569. if ( !currentMenu.length ) {
  4570. currentMenu = this.element;
  4571. }
  4572. this._close( currentMenu );
  4573. this.blur( event );
  4574. // Work around active item staying active after menu is blurred
  4575. this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
  4576. this.activeMenu = currentMenu;
  4577. }, all ? 0 : this.delay );
  4578. },
  4579. // With no arguments, closes the currently active menu - if nothing is active
  4580. // it closes all menus. If passed an argument, it will search for menus BELOW
  4581. _close: function( startMenu ) {
  4582. if ( !startMenu ) {
  4583. startMenu = this.active ? this.active.parent() : this.element;
  4584. }
  4585. startMenu.find( ".ui-menu" )
  4586. .hide()
  4587. .attr( "aria-hidden", "true" )
  4588. .attr( "aria-expanded", "false" );
  4589. },
  4590. _closeOnDocumentClick: function( event ) {
  4591. return !$( event.target ).closest( ".ui-menu" ).length;
  4592. },
  4593. _isDivider: function( item ) {
  4594. // Match hyphen, em dash, en dash
  4595. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  4596. },
  4597. collapse: function( event ) {
  4598. var newItem = this.active &&
  4599. this.active.parent().closest( ".ui-menu-item", this.element );
  4600. if ( newItem && newItem.length ) {
  4601. this._close();
  4602. this.focus( event, newItem );
  4603. }
  4604. },
  4605. expand: function( event ) {
  4606. var newItem = this.active && this._menuItems( this.active.children( ".ui-menu" ) ).first();
  4607. if ( newItem && newItem.length ) {
  4608. this._open( newItem.parent() );
  4609. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  4610. this._delay( function() {
  4611. this.focus( event, newItem );
  4612. } );
  4613. }
  4614. },
  4615. next: function( event ) {
  4616. this._move( "next", "first", event );
  4617. },
  4618. previous: function( event ) {
  4619. this._move( "prev", "last", event );
  4620. },
  4621. isFirstItem: function() {
  4622. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  4623. },
  4624. isLastItem: function() {
  4625. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  4626. },
  4627. _menuItems: function( menu ) {
  4628. return ( menu || this.element )
  4629. .find( this.options.items )
  4630. .filter( ".ui-menu-item" );
  4631. },
  4632. _move: function( direction, filter, event ) {
  4633. var next;
  4634. if ( this.active ) {
  4635. if ( direction === "first" || direction === "last" ) {
  4636. next = this.active
  4637. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  4638. .last();
  4639. } else {
  4640. next = this.active
  4641. [ direction + "All" ]( ".ui-menu-item" )
  4642. .first();
  4643. }
  4644. }
  4645. if ( !next || !next.length || !this.active ) {
  4646. next = this._menuItems( this.activeMenu )[ filter ]();
  4647. }
  4648. this.focus( event, next );
  4649. },
  4650. nextPage: function( event ) {
  4651. var item, base, height;
  4652. if ( !this.active ) {
  4653. this.next( event );
  4654. return;
  4655. }
  4656. if ( this.isLastItem() ) {
  4657. return;
  4658. }
  4659. if ( this._hasScroll() ) {
  4660. base = this.active.offset().top;
  4661. height = this.element.innerHeight();
  4662. // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back.
  4663. if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) {
  4664. height += this.element[ 0 ].offsetHeight - this.element.outerHeight();
  4665. }
  4666. this.active.nextAll( ".ui-menu-item" ).each( function() {
  4667. item = $( this );
  4668. return item.offset().top - base - height < 0;
  4669. } );
  4670. this.focus( event, item );
  4671. } else {
  4672. this.focus( event, this._menuItems( this.activeMenu )
  4673. [ !this.active ? "first" : "last" ]() );
  4674. }
  4675. },
  4676. previousPage: function( event ) {
  4677. var item, base, height;
  4678. if ( !this.active ) {
  4679. this.next( event );
  4680. return;
  4681. }
  4682. if ( this.isFirstItem() ) {
  4683. return;
  4684. }
  4685. if ( this._hasScroll() ) {
  4686. base = this.active.offset().top;
  4687. height = this.element.innerHeight();
  4688. // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back.
  4689. if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) {
  4690. height += this.element[ 0 ].offsetHeight - this.element.outerHeight();
  4691. }
  4692. this.active.prevAll( ".ui-menu-item" ).each( function() {
  4693. item = $( this );
  4694. return item.offset().top - base + height > 0;
  4695. } );
  4696. this.focus( event, item );
  4697. } else {
  4698. this.focus( event, this._menuItems( this.activeMenu ).first() );
  4699. }
  4700. },
  4701. _hasScroll: function() {
  4702. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  4703. },
  4704. select: function( event ) {
  4705. // TODO: It should never be possible to not have an active item at this
  4706. // point, but the tests don't trigger mouseenter before click.
  4707. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  4708. var ui = { item: this.active };
  4709. if ( !this.active.has( ".ui-menu" ).length ) {
  4710. this.collapseAll( event, true );
  4711. }
  4712. this._trigger( "select", event, ui );
  4713. },
  4714. _filterMenuItems: function( character ) {
  4715. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  4716. regex = new RegExp( "^" + escapedCharacter, "i" );
  4717. return this.activeMenu
  4718. .find( this.options.items )
  4719. // Only match on items, not dividers or other content (#10571)
  4720. .filter( ".ui-menu-item" )
  4721. .filter( function() {
  4722. return regex.test(
  4723. String.prototype.trim.call(
  4724. $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
  4725. } );
  4726. }
  4727. } );
  4728. /*!
  4729. * jQuery UI Autocomplete 1.13.0
  4730. * http://jqueryui.com
  4731. *
  4732. * Copyright jQuery Foundation and other contributors
  4733. * Released under the MIT license.
  4734. * http://jquery.org/license
  4735. */
  4736. //>>label: Autocomplete
  4737. //>>group: Widgets
  4738. //>>description: Lists suggested words as the user is typing.
  4739. //>>docs: http://api.jqueryui.com/autocomplete/
  4740. //>>demos: http://jqueryui.com/autocomplete/
  4741. //>>css.structure: ../../themes/base/core.css
  4742. //>>css.structure: ../../themes/base/autocomplete.css
  4743. //>>css.theme: ../../themes/base/theme.css
  4744. $.widget( "ui.autocomplete", {
  4745. version: "1.13.0",
  4746. defaultElement: "<input>",
  4747. options: {
  4748. appendTo: null,
  4749. autoFocus: false,
  4750. delay: 300,
  4751. minLength: 1,
  4752. position: {
  4753. my: "left top",
  4754. at: "left bottom",
  4755. collision: "none"
  4756. },
  4757. source: null,
  4758. // Callbacks
  4759. change: null,
  4760. close: null,
  4761. focus: null,
  4762. open: null,
  4763. response: null,
  4764. search: null,
  4765. select: null
  4766. },
  4767. requestIndex: 0,
  4768. pending: 0,
  4769. _create: function() {
  4770. // Some browsers only repeat keydown events, not keypress events,
  4771. // so we use the suppressKeyPress flag to determine if we've already
  4772. // handled the keydown event. #7269
  4773. // Unfortunately the code for & in keypress is the same as the up arrow,
  4774. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4775. // events when we know the keydown event was used to modify the
  4776. // search term. #7799
  4777. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4778. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  4779. isTextarea = nodeName === "textarea",
  4780. isInput = nodeName === "input";
  4781. // Textareas are always multi-line
  4782. // Inputs are always single-line, even if inside a contentEditable element
  4783. // IE also treats inputs as contentEditable
  4784. // All other element types are determined by whether or not they're contentEditable
  4785. this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
  4786. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4787. this.isNewMenu = true;
  4788. this._addClass( "ui-autocomplete-input" );
  4789. this.element.attr( "autocomplete", "off" );
  4790. this._on( this.element, {
  4791. keydown: function( event ) {
  4792. if ( this.element.prop( "readOnly" ) ) {
  4793. suppressKeyPress = true;
  4794. suppressInput = true;
  4795. suppressKeyPressRepeat = true;
  4796. return;
  4797. }
  4798. suppressKeyPress = false;
  4799. suppressInput = false;
  4800. suppressKeyPressRepeat = false;
  4801. var keyCode = $.ui.keyCode;
  4802. switch ( event.keyCode ) {
  4803. case keyCode.PAGE_UP:
  4804. suppressKeyPress = true;
  4805. this._move( "previousPage", event );
  4806. break;
  4807. case keyCode.PAGE_DOWN:
  4808. suppressKeyPress = true;
  4809. this._move( "nextPage", event );
  4810. break;
  4811. case keyCode.UP:
  4812. suppressKeyPress = true;
  4813. this._keyEvent( "previous", event );
  4814. break;
  4815. case keyCode.DOWN:
  4816. suppressKeyPress = true;
  4817. this._keyEvent( "next", event );
  4818. break;
  4819. case keyCode.ENTER:
  4820. // when menu is open and has focus
  4821. if ( this.menu.active ) {
  4822. // #6055 - Opera still allows the keypress to occur
  4823. // which causes forms to submit
  4824. suppressKeyPress = true;
  4825. event.preventDefault();
  4826. this.menu.select( event );
  4827. }
  4828. break;
  4829. case keyCode.TAB:
  4830. if ( this.menu.active ) {
  4831. this.menu.select( event );
  4832. }
  4833. break;
  4834. case keyCode.ESCAPE:
  4835. if ( this.menu.element.is( ":visible" ) ) {
  4836. if ( !this.isMultiLine ) {
  4837. this._value( this.term );
  4838. }
  4839. this.close( event );
  4840. // Different browsers have different default behavior for escape
  4841. // Single press can mean undo or clear
  4842. // Double press in IE means clear the whole form
  4843. event.preventDefault();
  4844. }
  4845. break;
  4846. default:
  4847. suppressKeyPressRepeat = true;
  4848. // search timeout should be triggered before the input value is changed
  4849. this._searchTimeout( event );
  4850. break;
  4851. }
  4852. },
  4853. keypress: function( event ) {
  4854. if ( suppressKeyPress ) {
  4855. suppressKeyPress = false;
  4856. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4857. event.preventDefault();
  4858. }
  4859. return;
  4860. }
  4861. if ( suppressKeyPressRepeat ) {
  4862. return;
  4863. }
  4864. // Replicate some key handlers to allow them to repeat in Firefox and Opera
  4865. var keyCode = $.ui.keyCode;
  4866. switch ( event.keyCode ) {
  4867. case keyCode.PAGE_UP:
  4868. this._move( "previousPage", event );
  4869. break;
  4870. case keyCode.PAGE_DOWN:
  4871. this._move( "nextPage", event );
  4872. break;
  4873. case keyCode.UP:
  4874. this._keyEvent( "previous", event );
  4875. break;
  4876. case keyCode.DOWN:
  4877. this._keyEvent( "next", event );
  4878. break;
  4879. }
  4880. },
  4881. input: function( event ) {
  4882. if ( suppressInput ) {
  4883. suppressInput = false;
  4884. event.preventDefault();
  4885. return;
  4886. }
  4887. this._searchTimeout( event );
  4888. },
  4889. focus: function() {
  4890. this.selectedItem = null;
  4891. this.previous = this._value();
  4892. },
  4893. blur: function( event ) {
  4894. clearTimeout( this.searching );
  4895. this.close( event );
  4896. this._change( event );
  4897. }
  4898. } );
  4899. this._initSource();
  4900. this.menu = $( "<ul>" )
  4901. .appendTo( this._appendTo() )
  4902. .menu( {
  4903. // disable ARIA support, the live region takes care of that
  4904. role: null
  4905. } )
  4906. .hide()
  4907. // Support: IE 11 only, Edge <= 14
  4908. // For other browsers, we preventDefault() on the mousedown event
  4909. // to keep the dropdown from taking focus from the input. This doesn't
  4910. // work for IE/Edge, causing problems with selection and scrolling (#9638)
  4911. // Happily, IE and Edge support an "unselectable" attribute that
  4912. // prevents an element from receiving focus, exactly what we want here.
  4913. .attr( {
  4914. "unselectable": "on"
  4915. } )
  4916. .menu( "instance" );
  4917. this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
  4918. this._on( this.menu.element, {
  4919. mousedown: function( event ) {
  4920. // Prevent moving focus out of the text field
  4921. event.preventDefault();
  4922. },
  4923. menufocus: function( event, ui ) {
  4924. var label, item;
  4925. // support: Firefox
  4926. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  4927. if ( this.isNewMenu ) {
  4928. this.isNewMenu = false;
  4929. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  4930. this.menu.blur();
  4931. this.document.one( "mousemove", function() {
  4932. $( event.target ).trigger( event.originalEvent );
  4933. } );
  4934. return;
  4935. }
  4936. }
  4937. item = ui.item.data( "ui-autocomplete-item" );
  4938. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  4939. // use value to match what will end up in the input, if it was a key event
  4940. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  4941. this._value( item.value );
  4942. }
  4943. }
  4944. // Announce the value in the liveRegion
  4945. label = ui.item.attr( "aria-label" ) || item.value;
  4946. if ( label && String.prototype.trim.call( label ).length ) {
  4947. this.liveRegion.children().hide();
  4948. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  4949. }
  4950. },
  4951. menuselect: function( event, ui ) {
  4952. var item = ui.item.data( "ui-autocomplete-item" ),
  4953. previous = this.previous;
  4954. // Only trigger when focus was lost (click on menu)
  4955. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  4956. this.element.trigger( "focus" );
  4957. this.previous = previous;
  4958. // #6109 - IE triggers two focus events and the second
  4959. // is asynchronous, so we need to reset the previous
  4960. // term synchronously and asynchronously :-(
  4961. this._delay( function() {
  4962. this.previous = previous;
  4963. this.selectedItem = item;
  4964. } );
  4965. }
  4966. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  4967. this._value( item.value );
  4968. }
  4969. // reset the term after the select event
  4970. // this allows custom select handling to work properly
  4971. this.term = this._value();
  4972. this.close( event );
  4973. this.selectedItem = item;
  4974. }
  4975. } );
  4976. this.liveRegion = $( "<div>", {
  4977. role: "status",
  4978. "aria-live": "assertive",
  4979. "aria-relevant": "additions"
  4980. } )
  4981. .appendTo( this.document[ 0 ].body );
  4982. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  4983. // Turning off autocomplete prevents the browser from remembering the
  4984. // value when navigating through history, so we re-enable autocomplete
  4985. // if the page is unloaded before the widget is destroyed. #7790
  4986. this._on( this.window, {
  4987. beforeunload: function() {
  4988. this.element.removeAttr( "autocomplete" );
  4989. }
  4990. } );
  4991. },
  4992. _destroy: function() {
  4993. clearTimeout( this.searching );
  4994. this.element.removeAttr( "autocomplete" );
  4995. this.menu.element.remove();
  4996. this.liveRegion.remove();
  4997. },
  4998. _setOption: function( key, value ) {
  4999. this._super( key, value );
  5000. if ( key === "source" ) {
  5001. this._initSource();
  5002. }
  5003. if ( key === "appendTo" ) {
  5004. this.menu.element.appendTo( this._appendTo() );
  5005. }
  5006. if ( key === "disabled" && value && this.xhr ) {
  5007. this.xhr.abort();
  5008. }
  5009. },
  5010. _isEventTargetInWidget: function( event ) {
  5011. var menuElement = this.menu.element[ 0 ];
  5012. return event.target === this.element[ 0 ] ||
  5013. event.target === menuElement ||
  5014. $.contains( menuElement, event.target );
  5015. },
  5016. _closeOnClickOutside: function( event ) {
  5017. if ( !this._isEventTargetInWidget( event ) ) {
  5018. this.close();
  5019. }
  5020. },
  5021. _appendTo: function() {
  5022. var element = this.options.appendTo;
  5023. if ( element ) {
  5024. element = element.jquery || element.nodeType ?
  5025. $( element ) :
  5026. this.document.find( element ).eq( 0 );
  5027. }
  5028. if ( !element || !element[ 0 ] ) {
  5029. element = this.element.closest( ".ui-front, dialog" );
  5030. }
  5031. if ( !element.length ) {
  5032. element = this.document[ 0 ].body;
  5033. }
  5034. return element;
  5035. },
  5036. _initSource: function() {
  5037. var array, url,
  5038. that = this;
  5039. if ( Array.isArray( this.options.source ) ) {
  5040. array = this.options.source;
  5041. this.source = function( request, response ) {
  5042. response( $.ui.autocomplete.filter( array, request.term ) );
  5043. };
  5044. } else if ( typeof this.options.source === "string" ) {
  5045. url = this.options.source;
  5046. this.source = function( request, response ) {
  5047. if ( that.xhr ) {
  5048. that.xhr.abort();
  5049. }
  5050. that.xhr = $.ajax( {
  5051. url: url,
  5052. data: request,
  5053. dataType: "json",
  5054. success: function( data ) {
  5055. response( data );
  5056. },
  5057. error: function() {
  5058. response( [] );
  5059. }
  5060. } );
  5061. };
  5062. } else {
  5063. this.source = this.options.source;
  5064. }
  5065. },
  5066. _searchTimeout: function( event ) {
  5067. clearTimeout( this.searching );
  5068. this.searching = this._delay( function() {
  5069. // Search if the value has changed, or if the user retypes the same value (see #7434)
  5070. var equalValues = this.term === this._value(),
  5071. menuVisible = this.menu.element.is( ":visible" ),
  5072. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  5073. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  5074. this.selectedItem = null;
  5075. this.search( null, event );
  5076. }
  5077. }, this.options.delay );
  5078. },
  5079. search: function( value, event ) {
  5080. value = value != null ? value : this._value();
  5081. // Always save the actual value, not the one passed as an argument
  5082. this.term = this._value();
  5083. if ( value.length < this.options.minLength ) {
  5084. return this.close( event );
  5085. }
  5086. if ( this._trigger( "search", event ) === false ) {
  5087. return;
  5088. }
  5089. return this._search( value );
  5090. },
  5091. _search: function( value ) {
  5092. this.pending++;
  5093. this._addClass( "ui-autocomplete-loading" );
  5094. this.cancelSearch = false;
  5095. this.source( { term: value }, this._response() );
  5096. },
  5097. _response: function() {
  5098. var index = ++this.requestIndex;
  5099. return function( content ) {
  5100. if ( index === this.requestIndex ) {
  5101. this.__response( content );
  5102. }
  5103. this.pending--;
  5104. if ( !this.pending ) {
  5105. this._removeClass( "ui-autocomplete-loading" );
  5106. }
  5107. }.bind( this );
  5108. },
  5109. __response: function( content ) {
  5110. if ( content ) {
  5111. content = this._normalize( content );
  5112. }
  5113. this._trigger( "response", null, { content: content } );
  5114. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5115. this._suggest( content );
  5116. this._trigger( "open" );
  5117. } else {
  5118. // use ._close() instead of .close() so we don't cancel future searches
  5119. this._close();
  5120. }
  5121. },
  5122. close: function( event ) {
  5123. this.cancelSearch = true;
  5124. this._close( event );
  5125. },
  5126. _close: function( event ) {
  5127. // Remove the handler that closes the menu on outside clicks
  5128. this._off( this.document, "mousedown" );
  5129. if ( this.menu.element.is( ":visible" ) ) {
  5130. this.menu.element.hide();
  5131. this.menu.blur();
  5132. this.isNewMenu = true;
  5133. this._trigger( "close", event );
  5134. }
  5135. },
  5136. _change: function( event ) {
  5137. if ( this.previous !== this._value() ) {
  5138. this._trigger( "change", event, { item: this.selectedItem } );
  5139. }
  5140. },
  5141. _normalize: function( items ) {
  5142. // assume all items have the right format when the first item is complete
  5143. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  5144. return items;
  5145. }
  5146. return $.map( items, function( item ) {
  5147. if ( typeof item === "string" ) {
  5148. return {
  5149. label: item,
  5150. value: item
  5151. };
  5152. }
  5153. return $.extend( {}, item, {
  5154. label: item.label || item.value,
  5155. value: item.value || item.label
  5156. } );
  5157. } );
  5158. },
  5159. _suggest: function( items ) {
  5160. var ul = this.menu.element.empty();
  5161. this._renderMenu( ul, items );
  5162. this.isNewMenu = true;
  5163. this.menu.refresh();
  5164. // Size and position menu
  5165. ul.show();
  5166. this._resizeMenu();
  5167. ul.position( $.extend( {
  5168. of: this.element
  5169. }, this.options.position ) );
  5170. if ( this.options.autoFocus ) {
  5171. this.menu.next();
  5172. }
  5173. // Listen for interactions outside of the widget (#6642)
  5174. this._on( this.document, {
  5175. mousedown: "_closeOnClickOutside"
  5176. } );
  5177. },
  5178. _resizeMenu: function() {
  5179. var ul = this.menu.element;
  5180. ul.outerWidth( Math.max(
  5181. // Firefox wraps long text (possibly a rounding bug)
  5182. // so we add 1px to avoid the wrapping (#7513)
  5183. ul.width( "" ).outerWidth() + 1,
  5184. this.element.outerWidth()
  5185. ) );
  5186. },
  5187. _renderMenu: function( ul, items ) {
  5188. var that = this;
  5189. $.each( items, function( index, item ) {
  5190. that._renderItemData( ul, item );
  5191. } );
  5192. },
  5193. _renderItemData: function( ul, item ) {
  5194. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5195. },
  5196. _renderItem: function( ul, item ) {
  5197. return $( "<li>" )
  5198. .append( $( "<div>" ).text( item.label ) )
  5199. .appendTo( ul );
  5200. },
  5201. _move: function( direction, event ) {
  5202. if ( !this.menu.element.is( ":visible" ) ) {
  5203. this.search( null, event );
  5204. return;
  5205. }
  5206. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5207. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5208. if ( !this.isMultiLine ) {
  5209. this._value( this.term );
  5210. }
  5211. this.menu.blur();
  5212. return;
  5213. }
  5214. this.menu[ direction ]( event );
  5215. },
  5216. widget: function() {
  5217. return this.menu.element;
  5218. },
  5219. _value: function() {
  5220. return this.valueMethod.apply( this.element, arguments );
  5221. },
  5222. _keyEvent: function( keyEvent, event ) {
  5223. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5224. this._move( keyEvent, event );
  5225. // Prevents moving cursor to beginning/end of the text field in some browsers
  5226. event.preventDefault();
  5227. }
  5228. },
  5229. // Support: Chrome <=50
  5230. // We should be able to just use this.element.prop( "isContentEditable" )
  5231. // but hidden elements always report false in Chrome.
  5232. // https://code.google.com/p/chromium/issues/detail?id=313082
  5233. _isContentEditable: function( element ) {
  5234. if ( !element.length ) {
  5235. return false;
  5236. }
  5237. var editable = element.prop( "contentEditable" );
  5238. if ( editable === "inherit" ) {
  5239. return this._isContentEditable( element.parent() );
  5240. }
  5241. return editable === "true";
  5242. }
  5243. } );
  5244. $.extend( $.ui.autocomplete, {
  5245. escapeRegex: function( value ) {
  5246. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  5247. },
  5248. filter: function( array, term ) {
  5249. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  5250. return $.grep( array, function( value ) {
  5251. return matcher.test( value.label || value.value || value );
  5252. } );
  5253. }
  5254. } );
  5255. // Live region extension, adding a `messages` option
  5256. // NOTE: This is an experimental API. We are still investigating
  5257. // a full solution for string manipulation and internationalization.
  5258. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5259. options: {
  5260. messages: {
  5261. noResults: "No search results.",
  5262. results: function( amount ) {
  5263. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5264. " available, use up and down arrow keys to navigate.";
  5265. }
  5266. }
  5267. },
  5268. __response: function( content ) {
  5269. var message;
  5270. this._superApply( arguments );
  5271. if ( this.options.disabled || this.cancelSearch ) {
  5272. return;
  5273. }
  5274. if ( content && content.length ) {
  5275. message = this.options.messages.results( content.length );
  5276. } else {
  5277. message = this.options.messages.noResults;
  5278. }
  5279. this.liveRegion.children().hide();
  5280. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  5281. }
  5282. } );
  5283. var widgetsAutocomplete = $.ui.autocomplete;
  5284. /*!
  5285. * jQuery UI Controlgroup 1.13.0
  5286. * http://jqueryui.com
  5287. *
  5288. * Copyright jQuery Foundation and other contributors
  5289. * Released under the MIT license.
  5290. * http://jquery.org/license
  5291. */
  5292. //>>label: Controlgroup
  5293. //>>group: Widgets
  5294. //>>description: Visually groups form control widgets
  5295. //>>docs: http://api.jqueryui.com/controlgroup/
  5296. //>>demos: http://jqueryui.com/controlgroup/
  5297. //>>css.structure: ../../themes/base/core.css
  5298. //>>css.structure: ../../themes/base/controlgroup.css
  5299. //>>css.theme: ../../themes/base/theme.css
  5300. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  5301. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  5302. version: "1.13.0",
  5303. defaultElement: "<div>",
  5304. options: {
  5305. direction: "horizontal",
  5306. disabled: null,
  5307. onlyVisible: true,
  5308. items: {
  5309. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  5310. "controlgroupLabel": ".ui-controlgroup-label",
  5311. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  5312. "selectmenu": "select",
  5313. "spinner": ".ui-spinner-input"
  5314. }
  5315. },
  5316. _create: function() {
  5317. this._enhance();
  5318. },
  5319. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  5320. _enhance: function() {
  5321. this.element.attr( "role", "toolbar" );
  5322. this.refresh();
  5323. },
  5324. _destroy: function() {
  5325. this._callChildMethod( "destroy" );
  5326. this.childWidgets.removeData( "ui-controlgroup-data" );
  5327. this.element.removeAttr( "role" );
  5328. if ( this.options.items.controlgroupLabel ) {
  5329. this.element
  5330. .find( this.options.items.controlgroupLabel )
  5331. .find( ".ui-controlgroup-label-contents" )
  5332. .contents().unwrap();
  5333. }
  5334. },
  5335. _initWidgets: function() {
  5336. var that = this,
  5337. childWidgets = [];
  5338. // First we iterate over each of the items options
  5339. $.each( this.options.items, function( widget, selector ) {
  5340. var labels;
  5341. var options = {};
  5342. // Make sure the widget has a selector set
  5343. if ( !selector ) {
  5344. return;
  5345. }
  5346. if ( widget === "controlgroupLabel" ) {
  5347. labels = that.element.find( selector );
  5348. labels.each( function() {
  5349. var element = $( this );
  5350. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  5351. return;
  5352. }
  5353. element.contents()
  5354. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  5355. } );
  5356. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  5357. childWidgets = childWidgets.concat( labels.get() );
  5358. return;
  5359. }
  5360. // Make sure the widget actually exists
  5361. if ( !$.fn[ widget ] ) {
  5362. return;
  5363. }
  5364. // We assume everything is in the middle to start because we can't determine
  5365. // first / last elements until all enhancments are done.
  5366. if ( that[ "_" + widget + "Options" ] ) {
  5367. options = that[ "_" + widget + "Options" ]( "middle" );
  5368. } else {
  5369. options = { classes: {} };
  5370. }
  5371. // Find instances of this widget inside controlgroup and init them
  5372. that.element
  5373. .find( selector )
  5374. .each( function() {
  5375. var element = $( this );
  5376. var instance = element[ widget ]( "instance" );
  5377. // We need to clone the default options for this type of widget to avoid
  5378. // polluting the variable options which has a wider scope than a single widget.
  5379. var instanceOptions = $.widget.extend( {}, options );
  5380. // If the button is the child of a spinner ignore it
  5381. // TODO: Find a more generic solution
  5382. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  5383. return;
  5384. }
  5385. // Create the widget if it doesn't exist
  5386. if ( !instance ) {
  5387. instance = element[ widget ]()[ widget ]( "instance" );
  5388. }
  5389. if ( instance ) {
  5390. instanceOptions.classes =
  5391. that._resolveClassesValues( instanceOptions.classes, instance );
  5392. }
  5393. element[ widget ]( instanceOptions );
  5394. // Store an instance of the controlgroup to be able to reference
  5395. // from the outermost element for changing options and refresh
  5396. var widgetElement = element[ widget ]( "widget" );
  5397. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  5398. instance ? instance : element[ widget ]( "instance" ) );
  5399. childWidgets.push( widgetElement[ 0 ] );
  5400. } );
  5401. } );
  5402. this.childWidgets = $( $.uniqueSort( childWidgets ) );
  5403. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  5404. },
  5405. _callChildMethod: function( method ) {
  5406. this.childWidgets.each( function() {
  5407. var element = $( this ),
  5408. data = element.data( "ui-controlgroup-data" );
  5409. if ( data && data[ method ] ) {
  5410. data[ method ]();
  5411. }
  5412. } );
  5413. },
  5414. _updateCornerClass: function( element, position ) {
  5415. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  5416. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  5417. this._removeClass( element, null, remove );
  5418. this._addClass( element, null, add );
  5419. },
  5420. _buildSimpleOptions: function( position, key ) {
  5421. var direction = this.options.direction === "vertical";
  5422. var result = {
  5423. classes: {}
  5424. };
  5425. result.classes[ key ] = {
  5426. "middle": "",
  5427. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  5428. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  5429. "only": "ui-corner-all"
  5430. }[ position ];
  5431. return result;
  5432. },
  5433. _spinnerOptions: function( position ) {
  5434. var options = this._buildSimpleOptions( position, "ui-spinner" );
  5435. options.classes[ "ui-spinner-up" ] = "";
  5436. options.classes[ "ui-spinner-down" ] = "";
  5437. return options;
  5438. },
  5439. _buttonOptions: function( position ) {
  5440. return this._buildSimpleOptions( position, "ui-button" );
  5441. },
  5442. _checkboxradioOptions: function( position ) {
  5443. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  5444. },
  5445. _selectmenuOptions: function( position ) {
  5446. var direction = this.options.direction === "vertical";
  5447. return {
  5448. width: direction ? "auto" : false,
  5449. classes: {
  5450. middle: {
  5451. "ui-selectmenu-button-open": "",
  5452. "ui-selectmenu-button-closed": ""
  5453. },
  5454. first: {
  5455. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  5456. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  5457. },
  5458. last: {
  5459. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  5460. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  5461. },
  5462. only: {
  5463. "ui-selectmenu-button-open": "ui-corner-top",
  5464. "ui-selectmenu-button-closed": "ui-corner-all"
  5465. }
  5466. }[ position ]
  5467. };
  5468. },
  5469. _resolveClassesValues: function( classes, instance ) {
  5470. var result = {};
  5471. $.each( classes, function( key ) {
  5472. var current = instance.options.classes[ key ] || "";
  5473. current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) );
  5474. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  5475. } );
  5476. return result;
  5477. },
  5478. _setOption: function( key, value ) {
  5479. if ( key === "direction" ) {
  5480. this._removeClass( "ui-controlgroup-" + this.options.direction );
  5481. }
  5482. this._super( key, value );
  5483. if ( key === "disabled" ) {
  5484. this._callChildMethod( value ? "disable" : "enable" );
  5485. return;
  5486. }
  5487. this.refresh();
  5488. },
  5489. refresh: function() {
  5490. var children,
  5491. that = this;
  5492. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  5493. if ( this.options.direction === "horizontal" ) {
  5494. this._addClass( null, "ui-helper-clearfix" );
  5495. }
  5496. this._initWidgets();
  5497. children = this.childWidgets;
  5498. // We filter here because we need to track all childWidgets not just the visible ones
  5499. if ( this.options.onlyVisible ) {
  5500. children = children.filter( ":visible" );
  5501. }
  5502. if ( children.length ) {
  5503. // We do this last because we need to make sure all enhancment is done
  5504. // before determining first and last
  5505. $.each( [ "first", "last" ], function( index, value ) {
  5506. var instance = children[ value ]().data( "ui-controlgroup-data" );
  5507. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  5508. var options = that[ "_" + instance.widgetName + "Options" ](
  5509. children.length === 1 ? "only" : value
  5510. );
  5511. options.classes = that._resolveClassesValues( options.classes, instance );
  5512. instance.element[ instance.widgetName ]( options );
  5513. } else {
  5514. that._updateCornerClass( children[ value ](), value );
  5515. }
  5516. } );
  5517. // Finally call the refresh method on each of the child widgets.
  5518. this._callChildMethod( "refresh" );
  5519. }
  5520. }
  5521. } );
  5522. /*!
  5523. * jQuery UI Checkboxradio 1.13.0
  5524. * http://jqueryui.com
  5525. *
  5526. * Copyright jQuery Foundation and other contributors
  5527. * Released under the MIT license.
  5528. * http://jquery.org/license
  5529. */
  5530. //>>label: Checkboxradio
  5531. //>>group: Widgets
  5532. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  5533. //>>docs: http://api.jqueryui.com/checkboxradio/
  5534. //>>demos: http://jqueryui.com/checkboxradio/
  5535. //>>css.structure: ../../themes/base/core.css
  5536. //>>css.structure: ../../themes/base/button.css
  5537. //>>css.structure: ../../themes/base/checkboxradio.css
  5538. //>>css.theme: ../../themes/base/theme.css
  5539. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  5540. version: "1.13.0",
  5541. options: {
  5542. disabled: null,
  5543. label: null,
  5544. icon: true,
  5545. classes: {
  5546. "ui-checkboxradio-label": "ui-corner-all",
  5547. "ui-checkboxradio-icon": "ui-corner-all"
  5548. }
  5549. },
  5550. _getCreateOptions: function() {
  5551. var disabled, labels;
  5552. var that = this;
  5553. var options = this._super() || {};
  5554. // We read the type here, because it makes more sense to throw a element type error first,
  5555. // rather then the error for lack of a label. Often if its the wrong type, it
  5556. // won't have a label (e.g. calling on a div, btn, etc)
  5557. this._readType();
  5558. labels = this.element.labels();
  5559. // If there are multiple labels, use the last one
  5560. this.label = $( labels[ labels.length - 1 ] );
  5561. if ( !this.label.length ) {
  5562. $.error( "No label found for checkboxradio widget" );
  5563. }
  5564. this.originalLabel = "";
  5565. // We need to get the label text but this may also need to make sure it does not contain the
  5566. // input itself.
  5567. this.label.contents().not( this.element[ 0 ] ).each( function() {
  5568. // The label contents could be text, html, or a mix. We concat each element to get a
  5569. // string representation of the label, without the input as part of it.
  5570. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
  5571. } );
  5572. // Set the label option if we found label text
  5573. if ( this.originalLabel ) {
  5574. options.label = this.originalLabel;
  5575. }
  5576. disabled = this.element[ 0 ].disabled;
  5577. if ( disabled != null ) {
  5578. options.disabled = disabled;
  5579. }
  5580. return options;
  5581. },
  5582. _create: function() {
  5583. var checked = this.element[ 0 ].checked;
  5584. this._bindFormResetHandler();
  5585. if ( this.options.disabled == null ) {
  5586. this.options.disabled = this.element[ 0 ].disabled;
  5587. }
  5588. this._setOption( "disabled", this.options.disabled );
  5589. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  5590. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  5591. if ( this.type === "radio" ) {
  5592. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  5593. }
  5594. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5595. this._updateLabel();
  5596. } else if ( this.originalLabel ) {
  5597. this.options.label = this.originalLabel;
  5598. }
  5599. this._enhance();
  5600. if ( checked ) {
  5601. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  5602. }
  5603. this._on( {
  5604. change: "_toggleClasses",
  5605. focus: function() {
  5606. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5607. },
  5608. blur: function() {
  5609. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5610. }
  5611. } );
  5612. },
  5613. _readType: function() {
  5614. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  5615. this.type = this.element[ 0 ].type;
  5616. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  5617. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  5618. " and element.type=" + this.type );
  5619. }
  5620. },
  5621. // Support jQuery Mobile enhanced option
  5622. _enhance: function() {
  5623. this._updateIcon( this.element[ 0 ].checked );
  5624. },
  5625. widget: function() {
  5626. return this.label;
  5627. },
  5628. _getRadioGroup: function() {
  5629. var group;
  5630. var name = this.element[ 0 ].name;
  5631. var nameSelector = "input[name='" + $.escapeSelector( name ) + "']";
  5632. if ( !name ) {
  5633. return $( [] );
  5634. }
  5635. if ( this.form.length ) {
  5636. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  5637. } else {
  5638. // Not inside a form, check all inputs that also are not inside a form
  5639. group = $( nameSelector ).filter( function() {
  5640. return $( this )._form().length === 0;
  5641. } );
  5642. }
  5643. return group.not( this.element );
  5644. },
  5645. _toggleClasses: function() {
  5646. var checked = this.element[ 0 ].checked;
  5647. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5648. if ( this.options.icon && this.type === "checkbox" ) {
  5649. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  5650. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  5651. }
  5652. if ( this.type === "radio" ) {
  5653. this._getRadioGroup()
  5654. .each( function() {
  5655. var instance = $( this ).checkboxradio( "instance" );
  5656. if ( instance ) {
  5657. instance._removeClass( instance.label,
  5658. "ui-checkboxradio-checked", "ui-state-active" );
  5659. }
  5660. } );
  5661. }
  5662. },
  5663. _destroy: function() {
  5664. this._unbindFormResetHandler();
  5665. if ( this.icon ) {
  5666. this.icon.remove();
  5667. this.iconSpace.remove();
  5668. }
  5669. },
  5670. _setOption: function( key, value ) {
  5671. // We don't allow the value to be set to nothing
  5672. if ( key === "label" && !value ) {
  5673. return;
  5674. }
  5675. this._super( key, value );
  5676. if ( key === "disabled" ) {
  5677. this._toggleClass( this.label, null, "ui-state-disabled", value );
  5678. this.element[ 0 ].disabled = value;
  5679. // Don't refresh when setting disabled
  5680. return;
  5681. }
  5682. this.refresh();
  5683. },
  5684. _updateIcon: function( checked ) {
  5685. var toAdd = "ui-icon ui-icon-background ";
  5686. if ( this.options.icon ) {
  5687. if ( !this.icon ) {
  5688. this.icon = $( "<span>" );
  5689. this.iconSpace = $( "<span> </span>" );
  5690. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  5691. }
  5692. if ( this.type === "checkbox" ) {
  5693. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  5694. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  5695. } else {
  5696. toAdd += "ui-icon-blank";
  5697. }
  5698. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  5699. if ( !checked ) {
  5700. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  5701. }
  5702. this.icon.prependTo( this.label ).after( this.iconSpace );
  5703. } else if ( this.icon !== undefined ) {
  5704. this.icon.remove();
  5705. this.iconSpace.remove();
  5706. delete this.icon;
  5707. }
  5708. },
  5709. _updateLabel: function() {
  5710. // Remove the contents of the label ( minus the icon, icon space, and input )
  5711. var contents = this.label.contents().not( this.element[ 0 ] );
  5712. if ( this.icon ) {
  5713. contents = contents.not( this.icon[ 0 ] );
  5714. }
  5715. if ( this.iconSpace ) {
  5716. contents = contents.not( this.iconSpace[ 0 ] );
  5717. }
  5718. contents.remove();
  5719. this.label.append( this.options.label );
  5720. },
  5721. refresh: function() {
  5722. var checked = this.element[ 0 ].checked,
  5723. isDisabled = this.element[ 0 ].disabled;
  5724. this._updateIcon( checked );
  5725. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5726. if ( this.options.label !== null ) {
  5727. this._updateLabel();
  5728. }
  5729. if ( isDisabled !== this.options.disabled ) {
  5730. this._setOptions( { "disabled": isDisabled } );
  5731. }
  5732. }
  5733. } ] );
  5734. var widgetsCheckboxradio = $.ui.checkboxradio;
  5735. /*!
  5736. * jQuery UI Button 1.13.0
  5737. * http://jqueryui.com
  5738. *
  5739. * Copyright jQuery Foundation and other contributors
  5740. * Released under the MIT license.
  5741. * http://jquery.org/license
  5742. */
  5743. //>>label: Button
  5744. //>>group: Widgets
  5745. //>>description: Enhances a form with themeable buttons.
  5746. //>>docs: http://api.jqueryui.com/button/
  5747. //>>demos: http://jqueryui.com/button/
  5748. //>>css.structure: ../../themes/base/core.css
  5749. //>>css.structure: ../../themes/base/button.css
  5750. //>>css.theme: ../../themes/base/theme.css
  5751. $.widget( "ui.button", {
  5752. version: "1.13.0",
  5753. defaultElement: "<button>",
  5754. options: {
  5755. classes: {
  5756. "ui-button": "ui-corner-all"
  5757. },
  5758. disabled: null,
  5759. icon: null,
  5760. iconPosition: "beginning",
  5761. label: null,
  5762. showLabel: true
  5763. },
  5764. _getCreateOptions: function() {
  5765. var disabled,
  5766. // This is to support cases like in jQuery Mobile where the base widget does have
  5767. // an implementation of _getCreateOptions
  5768. options = this._super() || {};
  5769. this.isInput = this.element.is( "input" );
  5770. disabled = this.element[ 0 ].disabled;
  5771. if ( disabled != null ) {
  5772. options.disabled = disabled;
  5773. }
  5774. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  5775. if ( this.originalLabel ) {
  5776. options.label = this.originalLabel;
  5777. }
  5778. return options;
  5779. },
  5780. _create: function() {
  5781. if ( !this.option.showLabel & !this.options.icon ) {
  5782. this.options.showLabel = true;
  5783. }
  5784. // We have to check the option again here even though we did in _getCreateOptions,
  5785. // because null may have been passed on init which would override what was set in
  5786. // _getCreateOptions
  5787. if ( this.options.disabled == null ) {
  5788. this.options.disabled = this.element[ 0 ].disabled || false;
  5789. }
  5790. this.hasTitle = !!this.element.attr( "title" );
  5791. // Check to see if the label needs to be set or if its already correct
  5792. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5793. if ( this.isInput ) {
  5794. this.element.val( this.options.label );
  5795. } else {
  5796. this.element.html( this.options.label );
  5797. }
  5798. }
  5799. this._addClass( "ui-button", "ui-widget" );
  5800. this._setOption( "disabled", this.options.disabled );
  5801. this._enhance();
  5802. if ( this.element.is( "a" ) ) {
  5803. this._on( {
  5804. "keyup": function( event ) {
  5805. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5806. event.preventDefault();
  5807. // Support: PhantomJS <= 1.9, IE 8 Only
  5808. // If a native click is available use it so we actually cause navigation
  5809. // otherwise just trigger a click event
  5810. if ( this.element[ 0 ].click ) {
  5811. this.element[ 0 ].click();
  5812. } else {
  5813. this.element.trigger( "click" );
  5814. }
  5815. }
  5816. }
  5817. } );
  5818. }
  5819. },
  5820. _enhance: function() {
  5821. if ( !this.element.is( "button" ) ) {
  5822. this.element.attr( "role", "button" );
  5823. }
  5824. if ( this.options.icon ) {
  5825. this._updateIcon( "icon", this.options.icon );
  5826. this._updateTooltip();
  5827. }
  5828. },
  5829. _updateTooltip: function() {
  5830. this.title = this.element.attr( "title" );
  5831. if ( !this.options.showLabel && !this.title ) {
  5832. this.element.attr( "title", this.options.label );
  5833. }
  5834. },
  5835. _updateIcon: function( option, value ) {
  5836. var icon = option !== "iconPosition",
  5837. position = icon ? this.options.iconPosition : value,
  5838. displayBlock = position === "top" || position === "bottom";
  5839. // Create icon
  5840. if ( !this.icon ) {
  5841. this.icon = $( "<span>" );
  5842. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  5843. if ( !this.options.showLabel ) {
  5844. this._addClass( "ui-button-icon-only" );
  5845. }
  5846. } else if ( icon ) {
  5847. // If we are updating the icon remove the old icon class
  5848. this._removeClass( this.icon, null, this.options.icon );
  5849. }
  5850. // If we are updating the icon add the new icon class
  5851. if ( icon ) {
  5852. this._addClass( this.icon, null, value );
  5853. }
  5854. this._attachIcon( position );
  5855. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  5856. // the iconSpace if there is one.
  5857. if ( displayBlock ) {
  5858. this._addClass( this.icon, null, "ui-widget-icon-block" );
  5859. if ( this.iconSpace ) {
  5860. this.iconSpace.remove();
  5861. }
  5862. } else {
  5863. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  5864. // space if it does not exist
  5865. if ( !this.iconSpace ) {
  5866. this.iconSpace = $( "<span> </span>" );
  5867. this._addClass( this.iconSpace, "ui-button-icon-space" );
  5868. }
  5869. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  5870. this._attachIconSpace( position );
  5871. }
  5872. },
  5873. _destroy: function() {
  5874. this.element.removeAttr( "role" );
  5875. if ( this.icon ) {
  5876. this.icon.remove();
  5877. }
  5878. if ( this.iconSpace ) {
  5879. this.iconSpace.remove();
  5880. }
  5881. if ( !this.hasTitle ) {
  5882. this.element.removeAttr( "title" );
  5883. }
  5884. },
  5885. _attachIconSpace: function( iconPosition ) {
  5886. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  5887. },
  5888. _attachIcon: function( iconPosition ) {
  5889. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  5890. },
  5891. _setOptions: function( options ) {
  5892. var newShowLabel = options.showLabel === undefined ?
  5893. this.options.showLabel :
  5894. options.showLabel,
  5895. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  5896. if ( !newShowLabel && !newIcon ) {
  5897. options.showLabel = true;
  5898. }
  5899. this._super( options );
  5900. },
  5901. _setOption: function( key, value ) {
  5902. if ( key === "icon" ) {
  5903. if ( value ) {
  5904. this._updateIcon( key, value );
  5905. } else if ( this.icon ) {
  5906. this.icon.remove();
  5907. if ( this.iconSpace ) {
  5908. this.iconSpace.remove();
  5909. }
  5910. }
  5911. }
  5912. if ( key === "iconPosition" ) {
  5913. this._updateIcon( key, value );
  5914. }
  5915. // Make sure we can't end up with a button that has neither text nor icon
  5916. if ( key === "showLabel" ) {
  5917. this._toggleClass( "ui-button-icon-only", null, !value );
  5918. this._updateTooltip();
  5919. }
  5920. if ( key === "label" ) {
  5921. if ( this.isInput ) {
  5922. this.element.val( value );
  5923. } else {
  5924. // If there is an icon, append it, else nothing then append the value
  5925. // this avoids removal of the icon when setting label text
  5926. this.element.html( value );
  5927. if ( this.icon ) {
  5928. this._attachIcon( this.options.iconPosition );
  5929. this._attachIconSpace( this.options.iconPosition );
  5930. }
  5931. }
  5932. }
  5933. this._super( key, value );
  5934. if ( key === "disabled" ) {
  5935. this._toggleClass( null, "ui-state-disabled", value );
  5936. this.element[ 0 ].disabled = value;
  5937. if ( value ) {
  5938. this.element.trigger( "blur" );
  5939. }
  5940. }
  5941. },
  5942. refresh: function() {
  5943. // Make sure to only check disabled if its an element that supports this otherwise
  5944. // check for the disabled class to determine state
  5945. var isDisabled = this.element.is( "input, button" ) ?
  5946. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  5947. if ( isDisabled !== this.options.disabled ) {
  5948. this._setOptions( { disabled: isDisabled } );
  5949. }
  5950. this._updateTooltip();
  5951. }
  5952. } );
  5953. // DEPRECATED
  5954. if ( $.uiBackCompat !== false ) {
  5955. // Text and Icons options
  5956. $.widget( "ui.button", $.ui.button, {
  5957. options: {
  5958. text: true,
  5959. icons: {
  5960. primary: null,
  5961. secondary: null
  5962. }
  5963. },
  5964. _create: function() {
  5965. if ( this.options.showLabel && !this.options.text ) {
  5966. this.options.showLabel = this.options.text;
  5967. }
  5968. if ( !this.options.showLabel && this.options.text ) {
  5969. this.options.text = this.options.showLabel;
  5970. }
  5971. if ( !this.options.icon && ( this.options.icons.primary ||
  5972. this.options.icons.secondary ) ) {
  5973. if ( this.options.icons.primary ) {
  5974. this.options.icon = this.options.icons.primary;
  5975. } else {
  5976. this.options.icon = this.options.icons.secondary;
  5977. this.options.iconPosition = "end";
  5978. }
  5979. } else if ( this.options.icon ) {
  5980. this.options.icons.primary = this.options.icon;
  5981. }
  5982. this._super();
  5983. },
  5984. _setOption: function( key, value ) {
  5985. if ( key === "text" ) {
  5986. this._super( "showLabel", value );
  5987. return;
  5988. }
  5989. if ( key === "showLabel" ) {
  5990. this.options.text = value;
  5991. }
  5992. if ( key === "icon" ) {
  5993. this.options.icons.primary = value;
  5994. }
  5995. if ( key === "icons" ) {
  5996. if ( value.primary ) {
  5997. this._super( "icon", value.primary );
  5998. this._super( "iconPosition", "beginning" );
  5999. } else if ( value.secondary ) {
  6000. this._super( "icon", value.secondary );
  6001. this._super( "iconPosition", "end" );
  6002. }
  6003. }
  6004. this._superApply( arguments );
  6005. }
  6006. } );
  6007. $.fn.button = ( function( orig ) {
  6008. return function( options ) {
  6009. var isMethodCall = typeof options === "string";
  6010. var args = Array.prototype.slice.call( arguments, 1 );
  6011. var returnValue = this;
  6012. if ( isMethodCall ) {
  6013. // If this is an empty collection, we need to have the instance method
  6014. // return undefined instead of the jQuery instance
  6015. if ( !this.length && options === "instance" ) {
  6016. returnValue = undefined;
  6017. } else {
  6018. this.each( function() {
  6019. var methodValue;
  6020. var type = $( this ).attr( "type" );
  6021. var name = type !== "checkbox" && type !== "radio" ?
  6022. "button" :
  6023. "checkboxradio";
  6024. var instance = $.data( this, "ui-" + name );
  6025. if ( options === "instance" ) {
  6026. returnValue = instance;
  6027. return false;
  6028. }
  6029. if ( !instance ) {
  6030. return $.error( "cannot call methods on button" +
  6031. " prior to initialization; " +
  6032. "attempted to call method '" + options + "'" );
  6033. }
  6034. if ( typeof instance[ options ] !== "function" ||
  6035. options.charAt( 0 ) === "_" ) {
  6036. return $.error( "no such method '" + options + "' for button" +
  6037. " widget instance" );
  6038. }
  6039. methodValue = instance[ options ].apply( instance, args );
  6040. if ( methodValue !== instance && methodValue !== undefined ) {
  6041. returnValue = methodValue && methodValue.jquery ?
  6042. returnValue.pushStack( methodValue.get() ) :
  6043. methodValue;
  6044. return false;
  6045. }
  6046. } );
  6047. }
  6048. } else {
  6049. // Allow multiple hashes to be passed on init
  6050. if ( args.length ) {
  6051. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  6052. }
  6053. this.each( function() {
  6054. var type = $( this ).attr( "type" );
  6055. var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
  6056. var instance = $.data( this, "ui-" + name );
  6057. if ( instance ) {
  6058. instance.option( options || {} );
  6059. if ( instance._init ) {
  6060. instance._init();
  6061. }
  6062. } else {
  6063. if ( name === "button" ) {
  6064. orig.call( $( this ), options );
  6065. return;
  6066. }
  6067. $( this ).checkboxradio( $.extend( { icon: false }, options ) );
  6068. }
  6069. } );
  6070. }
  6071. return returnValue;
  6072. };
  6073. } )( $.fn.button );
  6074. $.fn.buttonset = function() {
  6075. if ( !$.ui.controlgroup ) {
  6076. $.error( "Controlgroup widget missing" );
  6077. }
  6078. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  6079. return this.controlgroup.apply( this,
  6080. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  6081. }
  6082. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  6083. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  6084. }
  6085. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  6086. arguments[ 0 ].items = {
  6087. button: arguments[ 0 ].items
  6088. };
  6089. }
  6090. return this.controlgroup.apply( this, arguments );
  6091. };
  6092. }
  6093. var widgetsButton = $.ui.button;
  6094. /* eslint-disable max-len, camelcase */
  6095. /*!
  6096. * jQuery UI Datepicker 1.13.0
  6097. * http://jqueryui.com
  6098. *
  6099. * Copyright jQuery Foundation and other contributors
  6100. * Released under the MIT license.
  6101. * http://jquery.org/license
  6102. */
  6103. //>>label: Datepicker
  6104. //>>group: Widgets
  6105. //>>description: Displays a calendar from an input or inline for selecting dates.
  6106. //>>docs: http://api.jqueryui.com/datepicker/
  6107. //>>demos: http://jqueryui.com/datepicker/
  6108. //>>css.structure: ../../themes/base/core.css
  6109. //>>css.structure: ../../themes/base/datepicker.css
  6110. //>>css.theme: ../../themes/base/theme.css
  6111. $.extend( $.ui, { datepicker: { version: "1.13.0" } } );
  6112. var datepicker_instActive;
  6113. function datepicker_getZindex( elem ) {
  6114. var position, value;
  6115. while ( elem.length && elem[ 0 ] !== document ) {
  6116. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  6117. // This makes behavior of this function consistent across browsers
  6118. // WebKit always returns auto if the element is positioned
  6119. position = elem.css( "position" );
  6120. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6121. // IE returns 0 when zIndex is not specified
  6122. // other browsers return a string
  6123. // we ignore the case of nested elements with an explicit value of 0
  6124. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6125. value = parseInt( elem.css( "zIndex" ), 10 );
  6126. if ( !isNaN( value ) && value !== 0 ) {
  6127. return value;
  6128. }
  6129. }
  6130. elem = elem.parent();
  6131. }
  6132. return 0;
  6133. }
  6134. /* Date picker manager.
  6135. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6136. Settings for (groups of) date pickers are maintained in an instance object,
  6137. allowing multiple different settings on the same page. */
  6138. function Datepicker() {
  6139. this._curInst = null; // The current instance in use
  6140. this._keyEvent = false; // If the last event was a key event
  6141. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6142. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6143. this._inDialog = false; // True if showing within a "dialog", false if not
  6144. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6145. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6146. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6147. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6148. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6149. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6150. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6151. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6152. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6153. this.regional = []; // Available regional settings, indexed by language code
  6154. this.regional[ "" ] = { // Default regional settings
  6155. closeText: "Done", // Display text for close link
  6156. prevText: "Prev", // Display text for previous month link
  6157. nextText: "Next", // Display text for next month link
  6158. currentText: "Today", // Display text for current month link
  6159. monthNames: [ "January", "February", "March", "April", "May", "June",
  6160. "July", "August", "September", "October", "November", "December" ], // Names of months for drop-down and formatting
  6161. monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
  6162. dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
  6163. dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
  6164. dayNamesMin: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ], // Column headings for days starting at Sunday
  6165. weekHeader: "Wk", // Column header for week of the year
  6166. dateFormat: "mm/dd/yy", // See format options on parseDate
  6167. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6168. isRTL: false, // True if right-to-left language, false if left-to-right
  6169. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6170. yearSuffix: "", // Additional text to append to the year in the month headers,
  6171. selectMonthLabel: "Select month", // Invisible label for month selector
  6172. selectYearLabel: "Select year" // Invisible label for year selector
  6173. };
  6174. this._defaults = { // Global defaults for all the date picker instances
  6175. showOn: "focus", // "focus" for popup on focus,
  6176. // "button" for trigger button, or "both" for either
  6177. showAnim: "fadeIn", // Name of jQuery animation for popup
  6178. showOptions: {}, // Options for enhanced animations
  6179. defaultDate: null, // Used when field is blank: actual date,
  6180. // +/-number for offset from today, null for today
  6181. appendText: "", // Display text following the input box, e.g. showing the format
  6182. buttonText: "...", // Text for trigger button
  6183. buttonImage: "", // URL for trigger button image
  6184. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6185. hideIfNoPrevNext: false, // True to hide next/previous month links
  6186. // if not applicable, false to just disable them
  6187. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6188. gotoCurrent: false, // True if today link goes back to current selection instead
  6189. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6190. changeYear: false, // True if year can be selected directly, false if only prev/next
  6191. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6192. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6193. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6194. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6195. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6196. showWeek: false, // True to show week of the year, false to not show it
  6197. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6198. // takes a Date and returns the number of the week for it
  6199. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6200. // > this are in the previous century,
  6201. // string value starting with "+" for current year + value
  6202. minDate: null, // The earliest selectable date, or null for no limit
  6203. maxDate: null, // The latest selectable date, or null for no limit
  6204. duration: "fast", // Duration of display/closure
  6205. beforeShowDay: null, // Function that takes a date and returns an array with
  6206. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6207. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6208. beforeShow: null, // Function that takes an input field and
  6209. // returns a set of custom settings for the date picker
  6210. onSelect: null, // Define a callback function when a date is selected
  6211. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6212. onClose: null, // Define a callback function when the datepicker is closed
  6213. onUpdateDatepicker: null, // Define a callback function when the datepicker is updated
  6214. numberOfMonths: 1, // Number of months to show at a time
  6215. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6216. stepMonths: 1, // Number of months to step back/forward
  6217. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6218. altField: "", // Selector for an alternate field to store selected dates into
  6219. altFormat: "", // The date format to use for the alternate field
  6220. constrainInput: true, // The input is constrained by the current date format
  6221. showButtonPanel: false, // True to show button panel, false to not show it
  6222. autoSize: false, // True to size the input for the date format, false to leave as is
  6223. disabled: false // The initial disabled state
  6224. };
  6225. $.extend( this._defaults, this.regional[ "" ] );
  6226. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  6227. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6228. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  6229. }
  6230. $.extend( Datepicker.prototype, {
  6231. /* Class name added to elements to indicate already configured with a date picker. */
  6232. markerClassName: "hasDatepicker",
  6233. //Keep track of the maximum number of rows displayed (see #7043)
  6234. maxRows: 4,
  6235. // TODO rename to "widget" when switching to widget factory
  6236. _widgetDatepicker: function() {
  6237. return this.dpDiv;
  6238. },
  6239. /* Override the default settings for all instances of the date picker.
  6240. * @param settings object - the new settings to use as defaults (anonymous object)
  6241. * @return the manager object
  6242. */
  6243. setDefaults: function( settings ) {
  6244. datepicker_extendRemove( this._defaults, settings || {} );
  6245. return this;
  6246. },
  6247. /* Attach the date picker to a jQuery selection.
  6248. * @param target element - the target input field or division or span
  6249. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6250. */
  6251. _attachDatepicker: function( target, settings ) {
  6252. var nodeName, inline, inst;
  6253. nodeName = target.nodeName.toLowerCase();
  6254. inline = ( nodeName === "div" || nodeName === "span" );
  6255. if ( !target.id ) {
  6256. this.uuid += 1;
  6257. target.id = "dp" + this.uuid;
  6258. }
  6259. inst = this._newInst( $( target ), inline );
  6260. inst.settings = $.extend( {}, settings || {} );
  6261. if ( nodeName === "input" ) {
  6262. this._connectDatepicker( target, inst );
  6263. } else if ( inline ) {
  6264. this._inlineDatepicker( target, inst );
  6265. }
  6266. },
  6267. /* Create a new instance object. */
  6268. _newInst: function( target, inline ) {
  6269. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  6270. return { id: id, input: target, // associated target
  6271. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6272. drawMonth: 0, drawYear: 0, // month being drawn
  6273. inline: inline, // is datepicker inline or not
  6274. dpDiv: ( !inline ? this.dpDiv : // presentation div
  6275. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  6276. },
  6277. /* Attach the date picker to an input field. */
  6278. _connectDatepicker: function( target, inst ) {
  6279. var input = $( target );
  6280. inst.append = $( [] );
  6281. inst.trigger = $( [] );
  6282. if ( input.hasClass( this.markerClassName ) ) {
  6283. return;
  6284. }
  6285. this._attachments( input, inst );
  6286. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  6287. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  6288. this._autoSize( inst );
  6289. $.data( target, "datepicker", inst );
  6290. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6291. if ( inst.settings.disabled ) {
  6292. this._disableDatepicker( target );
  6293. }
  6294. },
  6295. /* Make attachments based on settings. */
  6296. _attachments: function( input, inst ) {
  6297. var showOn, buttonText, buttonImage,
  6298. appendText = this._get( inst, "appendText" ),
  6299. isRTL = this._get( inst, "isRTL" );
  6300. if ( inst.append ) {
  6301. inst.append.remove();
  6302. }
  6303. if ( appendText ) {
  6304. inst.append = $( "<span>" )
  6305. .addClass( this._appendClass )
  6306. .text( appendText );
  6307. input[ isRTL ? "before" : "after" ]( inst.append );
  6308. }
  6309. input.off( "focus", this._showDatepicker );
  6310. if ( inst.trigger ) {
  6311. inst.trigger.remove();
  6312. }
  6313. showOn = this._get( inst, "showOn" );
  6314. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  6315. input.on( "focus", this._showDatepicker );
  6316. }
  6317. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  6318. buttonText = this._get( inst, "buttonText" );
  6319. buttonImage = this._get( inst, "buttonImage" );
  6320. if ( this._get( inst, "buttonImageOnly" ) ) {
  6321. inst.trigger = $( "<img>" )
  6322. .addClass( this._triggerClass )
  6323. .attr( {
  6324. src: buttonImage,
  6325. alt: buttonText,
  6326. title: buttonText
  6327. } );
  6328. } else {
  6329. inst.trigger = $( "<button type='button'>" )
  6330. .addClass( this._triggerClass );
  6331. if ( buttonImage ) {
  6332. inst.trigger.html(
  6333. $( "<img>" )
  6334. .attr( {
  6335. src: buttonImage,
  6336. alt: buttonText,
  6337. title: buttonText
  6338. } )
  6339. );
  6340. } else {
  6341. inst.trigger.text( buttonText );
  6342. }
  6343. }
  6344. input[ isRTL ? "before" : "after" ]( inst.trigger );
  6345. inst.trigger.on( "click", function() {
  6346. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  6347. $.datepicker._hideDatepicker();
  6348. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  6349. $.datepicker._hideDatepicker();
  6350. $.datepicker._showDatepicker( input[ 0 ] );
  6351. } else {
  6352. $.datepicker._showDatepicker( input[ 0 ] );
  6353. }
  6354. return false;
  6355. } );
  6356. }
  6357. },
  6358. /* Apply the maximum length for the date format. */
  6359. _autoSize: function( inst ) {
  6360. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  6361. var findMax, max, maxI, i,
  6362. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  6363. dateFormat = this._get( inst, "dateFormat" );
  6364. if ( dateFormat.match( /[DM]/ ) ) {
  6365. findMax = function( names ) {
  6366. max = 0;
  6367. maxI = 0;
  6368. for ( i = 0; i < names.length; i++ ) {
  6369. if ( names[ i ].length > max ) {
  6370. max = names[ i ].length;
  6371. maxI = i;
  6372. }
  6373. }
  6374. return maxI;
  6375. };
  6376. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  6377. "monthNames" : "monthNamesShort" ) ) ) );
  6378. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  6379. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  6380. }
  6381. inst.input.attr( "size", this._formatDate( inst, date ).length );
  6382. }
  6383. },
  6384. /* Attach an inline date picker to a div. */
  6385. _inlineDatepicker: function( target, inst ) {
  6386. var divSpan = $( target );
  6387. if ( divSpan.hasClass( this.markerClassName ) ) {
  6388. return;
  6389. }
  6390. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  6391. $.data( target, "datepicker", inst );
  6392. this._setDate( inst, this._getDefaultDate( inst ), true );
  6393. this._updateDatepicker( inst );
  6394. this._updateAlternate( inst );
  6395. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6396. if ( inst.settings.disabled ) {
  6397. this._disableDatepicker( target );
  6398. }
  6399. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6400. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6401. inst.dpDiv.css( "display", "block" );
  6402. },
  6403. /* Pop-up the date picker in a "dialog" box.
  6404. * @param input element - ignored
  6405. * @param date string or Date - the initial date to display
  6406. * @param onSelect function - the function to call when a date is selected
  6407. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6408. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6409. * event - with x/y coordinates or
  6410. * leave empty for default (screen centre)
  6411. * @return the manager object
  6412. */
  6413. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  6414. var id, browserWidth, browserHeight, scrollX, scrollY,
  6415. inst = this._dialogInst; // internal instance
  6416. if ( !inst ) {
  6417. this.uuid += 1;
  6418. id = "dp" + this.uuid;
  6419. this._dialogInput = $( "<input type='text' id='" + id +
  6420. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  6421. this._dialogInput.on( "keydown", this._doKeyDown );
  6422. $( "body" ).append( this._dialogInput );
  6423. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  6424. inst.settings = {};
  6425. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6426. }
  6427. datepicker_extendRemove( inst.settings, settings || {} );
  6428. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  6429. this._dialogInput.val( date );
  6430. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  6431. if ( !this._pos ) {
  6432. browserWidth = document.documentElement.clientWidth;
  6433. browserHeight = document.documentElement.clientHeight;
  6434. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6435. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6436. this._pos = // should use actual width/height below
  6437. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  6438. }
  6439. // Move input on screen for focus, but hidden behind dialog
  6440. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  6441. inst.settings.onSelect = onSelect;
  6442. this._inDialog = true;
  6443. this.dpDiv.addClass( this._dialogClass );
  6444. this._showDatepicker( this._dialogInput[ 0 ] );
  6445. if ( $.blockUI ) {
  6446. $.blockUI( this.dpDiv );
  6447. }
  6448. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6449. return this;
  6450. },
  6451. /* Detach a datepicker from its control.
  6452. * @param target element - the target input field or division or span
  6453. */
  6454. _destroyDatepicker: function( target ) {
  6455. var nodeName,
  6456. $target = $( target ),
  6457. inst = $.data( target, "datepicker" );
  6458. if ( !$target.hasClass( this.markerClassName ) ) {
  6459. return;
  6460. }
  6461. nodeName = target.nodeName.toLowerCase();
  6462. $.removeData( target, "datepicker" );
  6463. if ( nodeName === "input" ) {
  6464. inst.append.remove();
  6465. inst.trigger.remove();
  6466. $target.removeClass( this.markerClassName ).
  6467. off( "focus", this._showDatepicker ).
  6468. off( "keydown", this._doKeyDown ).
  6469. off( "keypress", this._doKeyPress ).
  6470. off( "keyup", this._doKeyUp );
  6471. } else if ( nodeName === "div" || nodeName === "span" ) {
  6472. $target.removeClass( this.markerClassName ).empty();
  6473. }
  6474. if ( datepicker_instActive === inst ) {
  6475. datepicker_instActive = null;
  6476. this._curInst = null;
  6477. }
  6478. },
  6479. /* Enable the date picker to a jQuery selection.
  6480. * @param target element - the target input field or division or span
  6481. */
  6482. _enableDatepicker: function( target ) {
  6483. var nodeName, inline,
  6484. $target = $( target ),
  6485. inst = $.data( target, "datepicker" );
  6486. if ( !$target.hasClass( this.markerClassName ) ) {
  6487. return;
  6488. }
  6489. nodeName = target.nodeName.toLowerCase();
  6490. if ( nodeName === "input" ) {
  6491. target.disabled = false;
  6492. inst.trigger.filter( "button" ).
  6493. each( function() {
  6494. this.disabled = false;
  6495. } ).end().
  6496. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  6497. } else if ( nodeName === "div" || nodeName === "span" ) {
  6498. inline = $target.children( "." + this._inlineClass );
  6499. inline.children().removeClass( "ui-state-disabled" );
  6500. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6501. prop( "disabled", false );
  6502. }
  6503. this._disabledInputs = $.map( this._disabledInputs,
  6504. // Delete entry
  6505. function( value ) {
  6506. return ( value === target ? null : value );
  6507. } );
  6508. },
  6509. /* Disable the date picker to a jQuery selection.
  6510. * @param target element - the target input field or division or span
  6511. */
  6512. _disableDatepicker: function( target ) {
  6513. var nodeName, inline,
  6514. $target = $( target ),
  6515. inst = $.data( target, "datepicker" );
  6516. if ( !$target.hasClass( this.markerClassName ) ) {
  6517. return;
  6518. }
  6519. nodeName = target.nodeName.toLowerCase();
  6520. if ( nodeName === "input" ) {
  6521. target.disabled = true;
  6522. inst.trigger.filter( "button" ).
  6523. each( function() {
  6524. this.disabled = true;
  6525. } ).end().
  6526. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  6527. } else if ( nodeName === "div" || nodeName === "span" ) {
  6528. inline = $target.children( "." + this._inlineClass );
  6529. inline.children().addClass( "ui-state-disabled" );
  6530. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6531. prop( "disabled", true );
  6532. }
  6533. this._disabledInputs = $.map( this._disabledInputs,
  6534. // Delete entry
  6535. function( value ) {
  6536. return ( value === target ? null : value );
  6537. } );
  6538. this._disabledInputs[ this._disabledInputs.length ] = target;
  6539. },
  6540. /* Is the first field in a jQuery collection disabled as a datepicker?
  6541. * @param target element - the target input field or division or span
  6542. * @return boolean - true if disabled, false if enabled
  6543. */
  6544. _isDisabledDatepicker: function( target ) {
  6545. if ( !target ) {
  6546. return false;
  6547. }
  6548. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  6549. if ( this._disabledInputs[ i ] === target ) {
  6550. return true;
  6551. }
  6552. }
  6553. return false;
  6554. },
  6555. /* Retrieve the instance data for the target control.
  6556. * @param target element - the target input field or division or span
  6557. * @return object - the associated instance data
  6558. * @throws error if a jQuery problem getting data
  6559. */
  6560. _getInst: function( target ) {
  6561. try {
  6562. return $.data( target, "datepicker" );
  6563. } catch ( err ) {
  6564. throw "Missing instance data for this datepicker";
  6565. }
  6566. },
  6567. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6568. * @param target element - the target input field or division or span
  6569. * @param name object - the new settings to update or
  6570. * string - the name of the setting to change or retrieve,
  6571. * when retrieving also "all" for all instance settings or
  6572. * "defaults" for all global defaults
  6573. * @param value any - the new value for the setting
  6574. * (omit if above is an object or to retrieve a value)
  6575. */
  6576. _optionDatepicker: function( target, name, value ) {
  6577. var settings, date, minDate, maxDate,
  6578. inst = this._getInst( target );
  6579. if ( arguments.length === 2 && typeof name === "string" ) {
  6580. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  6581. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  6582. this._get( inst, name ) ) : null ) );
  6583. }
  6584. settings = name || {};
  6585. if ( typeof name === "string" ) {
  6586. settings = {};
  6587. settings[ name ] = value;
  6588. }
  6589. if ( inst ) {
  6590. if ( this._curInst === inst ) {
  6591. this._hideDatepicker();
  6592. }
  6593. date = this._getDateDatepicker( target, true );
  6594. minDate = this._getMinMaxDate( inst, "min" );
  6595. maxDate = this._getMinMaxDate( inst, "max" );
  6596. datepicker_extendRemove( inst.settings, settings );
  6597. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6598. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  6599. inst.settings.minDate = this._formatDate( inst, minDate );
  6600. }
  6601. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  6602. inst.settings.maxDate = this._formatDate( inst, maxDate );
  6603. }
  6604. if ( "disabled" in settings ) {
  6605. if ( settings.disabled ) {
  6606. this._disableDatepicker( target );
  6607. } else {
  6608. this._enableDatepicker( target );
  6609. }
  6610. }
  6611. this._attachments( $( target ), inst );
  6612. this._autoSize( inst );
  6613. this._setDate( inst, date );
  6614. this._updateAlternate( inst );
  6615. this._updateDatepicker( inst );
  6616. }
  6617. },
  6618. // Change method deprecated
  6619. _changeDatepicker: function( target, name, value ) {
  6620. this._optionDatepicker( target, name, value );
  6621. },
  6622. /* Redraw the date picker attached to an input field or division.
  6623. * @param target element - the target input field or division or span
  6624. */
  6625. _refreshDatepicker: function( target ) {
  6626. var inst = this._getInst( target );
  6627. if ( inst ) {
  6628. this._updateDatepicker( inst );
  6629. }
  6630. },
  6631. /* Set the dates for a jQuery selection.
  6632. * @param target element - the target input field or division or span
  6633. * @param date Date - the new date
  6634. */
  6635. _setDateDatepicker: function( target, date ) {
  6636. var inst = this._getInst( target );
  6637. if ( inst ) {
  6638. this._setDate( inst, date );
  6639. this._updateDatepicker( inst );
  6640. this._updateAlternate( inst );
  6641. }
  6642. },
  6643. /* Get the date(s) for the first entry in a jQuery selection.
  6644. * @param target element - the target input field or division or span
  6645. * @param noDefault boolean - true if no default date is to be used
  6646. * @return Date - the current date
  6647. */
  6648. _getDateDatepicker: function( target, noDefault ) {
  6649. var inst = this._getInst( target );
  6650. if ( inst && !inst.inline ) {
  6651. this._setDateFromField( inst, noDefault );
  6652. }
  6653. return ( inst ? this._getDate( inst ) : null );
  6654. },
  6655. /* Handle keystrokes. */
  6656. _doKeyDown: function( event ) {
  6657. var onSelect, dateStr, sel,
  6658. inst = $.datepicker._getInst( event.target ),
  6659. handled = true,
  6660. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  6661. inst._keyEvent = true;
  6662. if ( $.datepicker._datepickerShowing ) {
  6663. switch ( event.keyCode ) {
  6664. case 9: $.datepicker._hideDatepicker();
  6665. handled = false;
  6666. break; // hide on tab out
  6667. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  6668. $.datepicker._currentClass + ")", inst.dpDiv );
  6669. if ( sel[ 0 ] ) {
  6670. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  6671. }
  6672. onSelect = $.datepicker._get( inst, "onSelect" );
  6673. if ( onSelect ) {
  6674. dateStr = $.datepicker._formatDate( inst );
  6675. // Trigger custom callback
  6676. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  6677. } else {
  6678. $.datepicker._hideDatepicker();
  6679. }
  6680. return false; // don't submit the form
  6681. case 27: $.datepicker._hideDatepicker();
  6682. break; // hide on escape
  6683. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6684. -$.datepicker._get( inst, "stepBigMonths" ) :
  6685. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6686. break; // previous month/year on page up/+ ctrl
  6687. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6688. +$.datepicker._get( inst, "stepBigMonths" ) :
  6689. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6690. break; // next month/year on page down/+ ctrl
  6691. case 35: if ( event.ctrlKey || event.metaKey ) {
  6692. $.datepicker._clearDate( event.target );
  6693. }
  6694. handled = event.ctrlKey || event.metaKey;
  6695. break; // clear on ctrl or command +end
  6696. case 36: if ( event.ctrlKey || event.metaKey ) {
  6697. $.datepicker._gotoToday( event.target );
  6698. }
  6699. handled = event.ctrlKey || event.metaKey;
  6700. break; // current on ctrl or command +home
  6701. case 37: if ( event.ctrlKey || event.metaKey ) {
  6702. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  6703. }
  6704. handled = event.ctrlKey || event.metaKey;
  6705. // -1 day on ctrl or command +left
  6706. if ( event.originalEvent.altKey ) {
  6707. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6708. -$.datepicker._get( inst, "stepBigMonths" ) :
  6709. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6710. }
  6711. // next month/year on alt +left on Mac
  6712. break;
  6713. case 38: if ( event.ctrlKey || event.metaKey ) {
  6714. $.datepicker._adjustDate( event.target, -7, "D" );
  6715. }
  6716. handled = event.ctrlKey || event.metaKey;
  6717. break; // -1 week on ctrl or command +up
  6718. case 39: if ( event.ctrlKey || event.metaKey ) {
  6719. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  6720. }
  6721. handled = event.ctrlKey || event.metaKey;
  6722. // +1 day on ctrl or command +right
  6723. if ( event.originalEvent.altKey ) {
  6724. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6725. +$.datepicker._get( inst, "stepBigMonths" ) :
  6726. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6727. }
  6728. // next month/year on alt +right
  6729. break;
  6730. case 40: if ( event.ctrlKey || event.metaKey ) {
  6731. $.datepicker._adjustDate( event.target, +7, "D" );
  6732. }
  6733. handled = event.ctrlKey || event.metaKey;
  6734. break; // +1 week on ctrl or command +down
  6735. default: handled = false;
  6736. }
  6737. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  6738. $.datepicker._showDatepicker( this );
  6739. } else {
  6740. handled = false;
  6741. }
  6742. if ( handled ) {
  6743. event.preventDefault();
  6744. event.stopPropagation();
  6745. }
  6746. },
  6747. /* Filter entered characters - based on date format. */
  6748. _doKeyPress: function( event ) {
  6749. var chars, chr,
  6750. inst = $.datepicker._getInst( event.target );
  6751. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  6752. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  6753. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  6754. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  6755. }
  6756. },
  6757. /* Synchronise manual entry and field/alternate field. */
  6758. _doKeyUp: function( event ) {
  6759. var date,
  6760. inst = $.datepicker._getInst( event.target );
  6761. if ( inst.input.val() !== inst.lastVal ) {
  6762. try {
  6763. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  6764. ( inst.input ? inst.input.val() : null ),
  6765. $.datepicker._getFormatConfig( inst ) );
  6766. if ( date ) { // only if valid
  6767. $.datepicker._setDateFromField( inst );
  6768. $.datepicker._updateAlternate( inst );
  6769. $.datepicker._updateDatepicker( inst );
  6770. }
  6771. } catch ( err ) {
  6772. }
  6773. }
  6774. return true;
  6775. },
  6776. /* Pop-up the date picker for a given input field.
  6777. * If false returned from beforeShow event handler do not show.
  6778. * @param input element - the input field attached to the date picker or
  6779. * event - if triggered by focus
  6780. */
  6781. _showDatepicker: function( input ) {
  6782. input = input.target || input;
  6783. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  6784. input = $( "input", input.parentNode )[ 0 ];
  6785. }
  6786. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  6787. return;
  6788. }
  6789. var inst, beforeShow, beforeShowSettings, isFixed,
  6790. offset, showAnim, duration;
  6791. inst = $.datepicker._getInst( input );
  6792. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  6793. $.datepicker._curInst.dpDiv.stop( true, true );
  6794. if ( inst && $.datepicker._datepickerShowing ) {
  6795. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  6796. }
  6797. }
  6798. beforeShow = $.datepicker._get( inst, "beforeShow" );
  6799. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  6800. if ( beforeShowSettings === false ) {
  6801. return;
  6802. }
  6803. datepicker_extendRemove( inst.settings, beforeShowSettings );
  6804. inst.lastVal = null;
  6805. $.datepicker._lastInput = input;
  6806. $.datepicker._setDateFromField( inst );
  6807. if ( $.datepicker._inDialog ) { // hide cursor
  6808. input.value = "";
  6809. }
  6810. if ( !$.datepicker._pos ) { // position below input
  6811. $.datepicker._pos = $.datepicker._findPos( input );
  6812. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  6813. }
  6814. isFixed = false;
  6815. $( input ).parents().each( function() {
  6816. isFixed |= $( this ).css( "position" ) === "fixed";
  6817. return !isFixed;
  6818. } );
  6819. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  6820. $.datepicker._pos = null;
  6821. //to avoid flashes on Firefox
  6822. inst.dpDiv.empty();
  6823. // determine sizing offscreen
  6824. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  6825. $.datepicker._updateDatepicker( inst );
  6826. // fix width for dynamic number of date pickers
  6827. // and adjust position before showing
  6828. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  6829. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  6830. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  6831. left: offset.left + "px", top: offset.top + "px" } );
  6832. if ( !inst.inline ) {
  6833. showAnim = $.datepicker._get( inst, "showAnim" );
  6834. duration = $.datepicker._get( inst, "duration" );
  6835. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  6836. $.datepicker._datepickerShowing = true;
  6837. if ( $.effects && $.effects.effect[ showAnim ] ) {
  6838. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  6839. } else {
  6840. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  6841. }
  6842. if ( $.datepicker._shouldFocusInput( inst ) ) {
  6843. inst.input.trigger( "focus" );
  6844. }
  6845. $.datepicker._curInst = inst;
  6846. }
  6847. },
  6848. /* Generate the date picker content. */
  6849. _updateDatepicker: function( inst ) {
  6850. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6851. datepicker_instActive = inst; // for delegate hover events
  6852. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  6853. this._attachHandlers( inst );
  6854. var origyearshtml,
  6855. numMonths = this._getNumberOfMonths( inst ),
  6856. cols = numMonths[ 1 ],
  6857. width = 17,
  6858. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ),
  6859. onUpdateDatepicker = $.datepicker._get( inst, "onUpdateDatepicker" );
  6860. if ( activeCell.length > 0 ) {
  6861. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  6862. }
  6863. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  6864. if ( cols > 1 ) {
  6865. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  6866. }
  6867. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  6868. "Class" ]( "ui-datepicker-multi" );
  6869. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  6870. "Class" ]( "ui-datepicker-rtl" );
  6871. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  6872. inst.input.trigger( "focus" );
  6873. }
  6874. // Deffered render of the years select (to avoid flashes on Firefox)
  6875. if ( inst.yearshtml ) {
  6876. origyearshtml = inst.yearshtml;
  6877. setTimeout( function() {
  6878. //assure that inst.yearshtml didn't change.
  6879. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  6880. inst.dpDiv.find( "select.ui-datepicker-year" ).first().replaceWith( inst.yearshtml );
  6881. }
  6882. origyearshtml = inst.yearshtml = null;
  6883. }, 0 );
  6884. }
  6885. if ( onUpdateDatepicker ) {
  6886. onUpdateDatepicker.apply( ( inst.input ? inst.input[ 0 ] : null ), [ inst ] );
  6887. }
  6888. },
  6889. // #6694 - don't focus the input if it's already focused
  6890. // this breaks the change event in IE
  6891. // Support: IE and jQuery <1.9
  6892. _shouldFocusInput: function( inst ) {
  6893. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  6894. },
  6895. /* Check positioning to remain on screen. */
  6896. _checkOffset: function( inst, offset, isFixed ) {
  6897. var dpWidth = inst.dpDiv.outerWidth(),
  6898. dpHeight = inst.dpDiv.outerHeight(),
  6899. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  6900. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  6901. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  6902. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  6903. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  6904. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  6905. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  6906. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  6907. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  6908. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  6909. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  6910. Math.abs( dpHeight + inputHeight ) : 0 );
  6911. return offset;
  6912. },
  6913. /* Find an object's position on the screen. */
  6914. _findPos: function( obj ) {
  6915. var position,
  6916. inst = this._getInst( obj ),
  6917. isRTL = this._get( inst, "isRTL" );
  6918. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.pseudos.hidden( obj ) ) ) {
  6919. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  6920. }
  6921. position = $( obj ).offset();
  6922. return [ position.left, position.top ];
  6923. },
  6924. /* Hide the date picker from view.
  6925. * @param input element - the input field attached to the date picker
  6926. */
  6927. _hideDatepicker: function( input ) {
  6928. var showAnim, duration, postProcess, onClose,
  6929. inst = this._curInst;
  6930. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  6931. return;
  6932. }
  6933. if ( this._datepickerShowing ) {
  6934. showAnim = this._get( inst, "showAnim" );
  6935. duration = this._get( inst, "duration" );
  6936. postProcess = function() {
  6937. $.datepicker._tidyDialog( inst );
  6938. };
  6939. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  6940. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  6941. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  6942. } else {
  6943. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  6944. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  6945. }
  6946. if ( !showAnim ) {
  6947. postProcess();
  6948. }
  6949. this._datepickerShowing = false;
  6950. onClose = this._get( inst, "onClose" );
  6951. if ( onClose ) {
  6952. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  6953. }
  6954. this._lastInput = null;
  6955. if ( this._inDialog ) {
  6956. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  6957. if ( $.blockUI ) {
  6958. $.unblockUI();
  6959. $( "body" ).append( this.dpDiv );
  6960. }
  6961. }
  6962. this._inDialog = false;
  6963. }
  6964. },
  6965. /* Tidy up after a dialog display. */
  6966. _tidyDialog: function( inst ) {
  6967. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  6968. },
  6969. /* Close date picker if clicked elsewhere. */
  6970. _checkExternalClick: function( event ) {
  6971. if ( !$.datepicker._curInst ) {
  6972. return;
  6973. }
  6974. var $target = $( event.target ),
  6975. inst = $.datepicker._getInst( $target[ 0 ] );
  6976. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  6977. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  6978. !$target.hasClass( $.datepicker.markerClassName ) &&
  6979. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  6980. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  6981. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  6982. $.datepicker._hideDatepicker();
  6983. }
  6984. },
  6985. /* Adjust one of the date sub-fields. */
  6986. _adjustDate: function( id, offset, period ) {
  6987. var target = $( id ),
  6988. inst = this._getInst( target[ 0 ] );
  6989. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  6990. return;
  6991. }
  6992. this._adjustInstDate( inst, offset, period );
  6993. this._updateDatepicker( inst );
  6994. },
  6995. /* Action for current link. */
  6996. _gotoToday: function( id ) {
  6997. var date,
  6998. target = $( id ),
  6999. inst = this._getInst( target[ 0 ] );
  7000. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  7001. inst.selectedDay = inst.currentDay;
  7002. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7003. inst.drawYear = inst.selectedYear = inst.currentYear;
  7004. } else {
  7005. date = new Date();
  7006. inst.selectedDay = date.getDate();
  7007. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7008. inst.drawYear = inst.selectedYear = date.getFullYear();
  7009. }
  7010. this._notifyChange( inst );
  7011. this._adjustDate( target );
  7012. },
  7013. /* Action for selecting a new month/year. */
  7014. _selectMonthYear: function( id, select, period ) {
  7015. var target = $( id ),
  7016. inst = this._getInst( target[ 0 ] );
  7017. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  7018. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  7019. parseInt( select.options[ select.selectedIndex ].value, 10 );
  7020. this._notifyChange( inst );
  7021. this._adjustDate( target );
  7022. },
  7023. /* Action for selecting a day. */
  7024. _selectDay: function( id, month, year, td ) {
  7025. var inst,
  7026. target = $( id );
  7027. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  7028. return;
  7029. }
  7030. inst = this._getInst( target[ 0 ] );
  7031. inst.selectedDay = inst.currentDay = parseInt( $( "a", td ).attr( "data-date" ) );
  7032. inst.selectedMonth = inst.currentMonth = month;
  7033. inst.selectedYear = inst.currentYear = year;
  7034. this._selectDate( id, this._formatDate( inst,
  7035. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  7036. },
  7037. /* Erase the input field and hide the date picker. */
  7038. _clearDate: function( id ) {
  7039. var target = $( id );
  7040. this._selectDate( target, "" );
  7041. },
  7042. /* Update the input field with the selected date. */
  7043. _selectDate: function( id, dateStr ) {
  7044. var onSelect,
  7045. target = $( id ),
  7046. inst = this._getInst( target[ 0 ] );
  7047. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  7048. if ( inst.input ) {
  7049. inst.input.val( dateStr );
  7050. }
  7051. this._updateAlternate( inst );
  7052. onSelect = this._get( inst, "onSelect" );
  7053. if ( onSelect ) {
  7054. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  7055. } else if ( inst.input ) {
  7056. inst.input.trigger( "change" ); // fire the change event
  7057. }
  7058. if ( inst.inline ) {
  7059. this._updateDatepicker( inst );
  7060. } else {
  7061. this._hideDatepicker();
  7062. this._lastInput = inst.input[ 0 ];
  7063. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  7064. inst.input.trigger( "focus" ); // restore focus
  7065. }
  7066. this._lastInput = null;
  7067. }
  7068. },
  7069. /* Update any alternate field to synchronise with the main field. */
  7070. _updateAlternate: function( inst ) {
  7071. var altFormat, date, dateStr,
  7072. altField = this._get( inst, "altField" );
  7073. if ( altField ) { // update alternate field too
  7074. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  7075. date = this._getDate( inst );
  7076. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  7077. $( document ).find( altField ).val( dateStr );
  7078. }
  7079. },
  7080. /* Set as beforeShowDay function to prevent selection of weekends.
  7081. * @param date Date - the date to customise
  7082. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7083. */
  7084. noWeekends: function( date ) {
  7085. var day = date.getDay();
  7086. return [ ( day > 0 && day < 6 ), "" ];
  7087. },
  7088. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7089. * @param date Date - the date to get the week for
  7090. * @return number - the number of the week within the year that contains this date
  7091. */
  7092. iso8601Week: function( date ) {
  7093. var time,
  7094. checkDate = new Date( date.getTime() );
  7095. // Find Thursday of this week starting on Monday
  7096. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  7097. time = checkDate.getTime();
  7098. checkDate.setMonth( 0 ); // Compare with Jan 1
  7099. checkDate.setDate( 1 );
  7100. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  7101. },
  7102. /* Parse a string value into a date object.
  7103. * See formatDate below for the possible formats.
  7104. *
  7105. * @param format string - the expected format of the date
  7106. * @param value string - the date in the above format
  7107. * @param settings Object - attributes include:
  7108. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7109. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7110. * dayNames string[7] - names of the days from Sunday (optional)
  7111. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7112. * monthNames string[12] - names of the months (optional)
  7113. * @return Date - the extracted date value or null if value is blank
  7114. */
  7115. parseDate: function( format, value, settings ) {
  7116. if ( format == null || value == null ) {
  7117. throw "Invalid arguments";
  7118. }
  7119. value = ( typeof value === "object" ? value.toString() : value + "" );
  7120. if ( value === "" ) {
  7121. return null;
  7122. }
  7123. var iFormat, dim, extra,
  7124. iValue = 0,
  7125. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  7126. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7127. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  7128. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7129. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7130. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7131. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7132. year = -1,
  7133. month = -1,
  7134. day = -1,
  7135. doy = -1,
  7136. literal = false,
  7137. date,
  7138. // Check whether a format character is doubled
  7139. lookAhead = function( match ) {
  7140. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7141. if ( matches ) {
  7142. iFormat++;
  7143. }
  7144. return matches;
  7145. },
  7146. // Extract a number from the string value
  7147. getNumber = function( match ) {
  7148. var isDoubled = lookAhead( match ),
  7149. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  7150. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  7151. minSize = ( match === "y" ? size : 1 ),
  7152. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  7153. num = value.substring( iValue ).match( digits );
  7154. if ( !num ) {
  7155. throw "Missing number at position " + iValue;
  7156. }
  7157. iValue += num[ 0 ].length;
  7158. return parseInt( num[ 0 ], 10 );
  7159. },
  7160. // Extract a name from the string value and convert to an index
  7161. getName = function( match, shortNames, longNames ) {
  7162. var index = -1,
  7163. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  7164. return [ [ k, v ] ];
  7165. } ).sort( function( a, b ) {
  7166. return -( a[ 1 ].length - b[ 1 ].length );
  7167. } );
  7168. $.each( names, function( i, pair ) {
  7169. var name = pair[ 1 ];
  7170. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  7171. index = pair[ 0 ];
  7172. iValue += name.length;
  7173. return false;
  7174. }
  7175. } );
  7176. if ( index !== -1 ) {
  7177. return index + 1;
  7178. } else {
  7179. throw "Unknown name at position " + iValue;
  7180. }
  7181. },
  7182. // Confirm that a literal character matches the string value
  7183. checkLiteral = function() {
  7184. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  7185. throw "Unexpected literal at position " + iValue;
  7186. }
  7187. iValue++;
  7188. };
  7189. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7190. if ( literal ) {
  7191. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7192. literal = false;
  7193. } else {
  7194. checkLiteral();
  7195. }
  7196. } else {
  7197. switch ( format.charAt( iFormat ) ) {
  7198. case "d":
  7199. day = getNumber( "d" );
  7200. break;
  7201. case "D":
  7202. getName( "D", dayNamesShort, dayNames );
  7203. break;
  7204. case "o":
  7205. doy = getNumber( "o" );
  7206. break;
  7207. case "m":
  7208. month = getNumber( "m" );
  7209. break;
  7210. case "M":
  7211. month = getName( "M", monthNamesShort, monthNames );
  7212. break;
  7213. case "y":
  7214. year = getNumber( "y" );
  7215. break;
  7216. case "@":
  7217. date = new Date( getNumber( "@" ) );
  7218. year = date.getFullYear();
  7219. month = date.getMonth() + 1;
  7220. day = date.getDate();
  7221. break;
  7222. case "!":
  7223. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  7224. year = date.getFullYear();
  7225. month = date.getMonth() + 1;
  7226. day = date.getDate();
  7227. break;
  7228. case "'":
  7229. if ( lookAhead( "'" ) ) {
  7230. checkLiteral();
  7231. } else {
  7232. literal = true;
  7233. }
  7234. break;
  7235. default:
  7236. checkLiteral();
  7237. }
  7238. }
  7239. }
  7240. if ( iValue < value.length ) {
  7241. extra = value.substr( iValue );
  7242. if ( !/^\s+/.test( extra ) ) {
  7243. throw "Extra/unparsed characters found in date: " + extra;
  7244. }
  7245. }
  7246. if ( year === -1 ) {
  7247. year = new Date().getFullYear();
  7248. } else if ( year < 100 ) {
  7249. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7250. ( year <= shortYearCutoff ? 0 : -100 );
  7251. }
  7252. if ( doy > -1 ) {
  7253. month = 1;
  7254. day = doy;
  7255. do {
  7256. dim = this._getDaysInMonth( year, month - 1 );
  7257. if ( day <= dim ) {
  7258. break;
  7259. }
  7260. month++;
  7261. day -= dim;
  7262. } while ( true );
  7263. }
  7264. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  7265. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  7266. throw "Invalid date"; // E.g. 31/02/00
  7267. }
  7268. return date;
  7269. },
  7270. /* Standard date formats. */
  7271. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7272. COOKIE: "D, dd M yy",
  7273. ISO_8601: "yy-mm-dd",
  7274. RFC_822: "D, d M y",
  7275. RFC_850: "DD, dd-M-y",
  7276. RFC_1036: "D, d M y",
  7277. RFC_1123: "D, d M yy",
  7278. RFC_2822: "D, d M yy",
  7279. RSS: "D, d M y", // RFC 822
  7280. TICKS: "!",
  7281. TIMESTAMP: "@",
  7282. W3C: "yy-mm-dd", // ISO 8601
  7283. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  7284. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  7285. /* Format a date object into a string value.
  7286. * The format can be combinations of the following:
  7287. * d - day of month (no leading zero)
  7288. * dd - day of month (two digit)
  7289. * o - day of year (no leading zeros)
  7290. * oo - day of year (three digit)
  7291. * D - day name short
  7292. * DD - day name long
  7293. * m - month of year (no leading zero)
  7294. * mm - month of year (two digit)
  7295. * M - month name short
  7296. * MM - month name long
  7297. * y - year (two digit)
  7298. * yy - year (four digit)
  7299. * @ - Unix timestamp (ms since 01/01/1970)
  7300. * ! - Windows ticks (100ns since 01/01/0001)
  7301. * "..." - literal text
  7302. * '' - single quote
  7303. *
  7304. * @param format string - the desired format of the date
  7305. * @param date Date - the date value to format
  7306. * @param settings Object - attributes include:
  7307. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7308. * dayNames string[7] - names of the days from Sunday (optional)
  7309. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7310. * monthNames string[12] - names of the months (optional)
  7311. * @return string - the date in the above format
  7312. */
  7313. formatDate: function( format, date, settings ) {
  7314. if ( !date ) {
  7315. return "";
  7316. }
  7317. var iFormat,
  7318. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7319. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7320. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7321. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7322. // Check whether a format character is doubled
  7323. lookAhead = function( match ) {
  7324. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7325. if ( matches ) {
  7326. iFormat++;
  7327. }
  7328. return matches;
  7329. },
  7330. // Format a number, with leading zero if necessary
  7331. formatNumber = function( match, value, len ) {
  7332. var num = "" + value;
  7333. if ( lookAhead( match ) ) {
  7334. while ( num.length < len ) {
  7335. num = "0" + num;
  7336. }
  7337. }
  7338. return num;
  7339. },
  7340. // Format a name, short or long as requested
  7341. formatName = function( match, value, shortNames, longNames ) {
  7342. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  7343. },
  7344. output = "",
  7345. literal = false;
  7346. if ( date ) {
  7347. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7348. if ( literal ) {
  7349. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7350. literal = false;
  7351. } else {
  7352. output += format.charAt( iFormat );
  7353. }
  7354. } else {
  7355. switch ( format.charAt( iFormat ) ) {
  7356. case "d":
  7357. output += formatNumber( "d", date.getDate(), 2 );
  7358. break;
  7359. case "D":
  7360. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  7361. break;
  7362. case "o":
  7363. output += formatNumber( "o",
  7364. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  7365. break;
  7366. case "m":
  7367. output += formatNumber( "m", date.getMonth() + 1, 2 );
  7368. break;
  7369. case "M":
  7370. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  7371. break;
  7372. case "y":
  7373. output += ( lookAhead( "y" ) ? date.getFullYear() :
  7374. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  7375. break;
  7376. case "@":
  7377. output += date.getTime();
  7378. break;
  7379. case "!":
  7380. output += date.getTime() * 10000 + this._ticksTo1970;
  7381. break;
  7382. case "'":
  7383. if ( lookAhead( "'" ) ) {
  7384. output += "'";
  7385. } else {
  7386. literal = true;
  7387. }
  7388. break;
  7389. default:
  7390. output += format.charAt( iFormat );
  7391. }
  7392. }
  7393. }
  7394. }
  7395. return output;
  7396. },
  7397. /* Extract all possible characters from the date format. */
  7398. _possibleChars: function( format ) {
  7399. var iFormat,
  7400. chars = "",
  7401. literal = false,
  7402. // Check whether a format character is doubled
  7403. lookAhead = function( match ) {
  7404. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7405. if ( matches ) {
  7406. iFormat++;
  7407. }
  7408. return matches;
  7409. };
  7410. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7411. if ( literal ) {
  7412. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7413. literal = false;
  7414. } else {
  7415. chars += format.charAt( iFormat );
  7416. }
  7417. } else {
  7418. switch ( format.charAt( iFormat ) ) {
  7419. case "d": case "m": case "y": case "@":
  7420. chars += "0123456789";
  7421. break;
  7422. case "D": case "M":
  7423. return null; // Accept anything
  7424. case "'":
  7425. if ( lookAhead( "'" ) ) {
  7426. chars += "'";
  7427. } else {
  7428. literal = true;
  7429. }
  7430. break;
  7431. default:
  7432. chars += format.charAt( iFormat );
  7433. }
  7434. }
  7435. }
  7436. return chars;
  7437. },
  7438. /* Get a setting value, defaulting if necessary. */
  7439. _get: function( inst, name ) {
  7440. return inst.settings[ name ] !== undefined ?
  7441. inst.settings[ name ] : this._defaults[ name ];
  7442. },
  7443. /* Parse existing date and initialise date picker. */
  7444. _setDateFromField: function( inst, noDefault ) {
  7445. if ( inst.input.val() === inst.lastVal ) {
  7446. return;
  7447. }
  7448. var dateFormat = this._get( inst, "dateFormat" ),
  7449. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7450. defaultDate = this._getDefaultDate( inst ),
  7451. date = defaultDate,
  7452. settings = this._getFormatConfig( inst );
  7453. try {
  7454. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  7455. } catch ( event ) {
  7456. dates = ( noDefault ? "" : dates );
  7457. }
  7458. inst.selectedDay = date.getDate();
  7459. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7460. inst.drawYear = inst.selectedYear = date.getFullYear();
  7461. inst.currentDay = ( dates ? date.getDate() : 0 );
  7462. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  7463. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  7464. this._adjustInstDate( inst );
  7465. },
  7466. /* Retrieve the default date shown on opening. */
  7467. _getDefaultDate: function( inst ) {
  7468. return this._restrictMinMax( inst,
  7469. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  7470. },
  7471. /* A date may be specified as an exact value or a relative one. */
  7472. _determineDate: function( inst, date, defaultDate ) {
  7473. var offsetNumeric = function( offset ) {
  7474. var date = new Date();
  7475. date.setDate( date.getDate() + offset );
  7476. return date;
  7477. },
  7478. offsetString = function( offset ) {
  7479. try {
  7480. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  7481. offset, $.datepicker._getFormatConfig( inst ) );
  7482. } catch ( e ) {
  7483. // Ignore
  7484. }
  7485. var date = ( offset.toLowerCase().match( /^c/ ) ?
  7486. $.datepicker._getDate( inst ) : null ) || new Date(),
  7487. year = date.getFullYear(),
  7488. month = date.getMonth(),
  7489. day = date.getDate(),
  7490. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7491. matches = pattern.exec( offset );
  7492. while ( matches ) {
  7493. switch ( matches[ 2 ] || "d" ) {
  7494. case "d" : case "D" :
  7495. day += parseInt( matches[ 1 ], 10 ); break;
  7496. case "w" : case "W" :
  7497. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  7498. case "m" : case "M" :
  7499. month += parseInt( matches[ 1 ], 10 );
  7500. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7501. break;
  7502. case "y": case "Y" :
  7503. year += parseInt( matches[ 1 ], 10 );
  7504. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7505. break;
  7506. }
  7507. matches = pattern.exec( offset );
  7508. }
  7509. return new Date( year, month, day );
  7510. },
  7511. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  7512. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  7513. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  7514. if ( newDate ) {
  7515. newDate.setHours( 0 );
  7516. newDate.setMinutes( 0 );
  7517. newDate.setSeconds( 0 );
  7518. newDate.setMilliseconds( 0 );
  7519. }
  7520. return this._daylightSavingAdjust( newDate );
  7521. },
  7522. /* Handle switch to/from daylight saving.
  7523. * Hours may be non-zero on daylight saving cut-over:
  7524. * > 12 when midnight changeover, but then cannot generate
  7525. * midnight datetime, so jump to 1AM, otherwise reset.
  7526. * @param date (Date) the date to check
  7527. * @return (Date) the corrected date
  7528. */
  7529. _daylightSavingAdjust: function( date ) {
  7530. if ( !date ) {
  7531. return null;
  7532. }
  7533. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  7534. return date;
  7535. },
  7536. /* Set the date(s) directly. */
  7537. _setDate: function( inst, date, noChange ) {
  7538. var clear = !date,
  7539. origMonth = inst.selectedMonth,
  7540. origYear = inst.selectedYear,
  7541. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  7542. inst.selectedDay = inst.currentDay = newDate.getDate();
  7543. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7544. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7545. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  7546. this._notifyChange( inst );
  7547. }
  7548. this._adjustInstDate( inst );
  7549. if ( inst.input ) {
  7550. inst.input.val( clear ? "" : this._formatDate( inst ) );
  7551. }
  7552. },
  7553. /* Retrieve the date(s) directly. */
  7554. _getDate: function( inst ) {
  7555. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  7556. this._daylightSavingAdjust( new Date(
  7557. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  7558. return startDate;
  7559. },
  7560. /* Attach the onxxx handlers. These are declared statically so
  7561. * they work with static code transformers like Caja.
  7562. */
  7563. _attachHandlers: function( inst ) {
  7564. var stepMonths = this._get( inst, "stepMonths" ),
  7565. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7566. inst.dpDiv.find( "[data-handler]" ).map( function() {
  7567. var handler = {
  7568. prev: function() {
  7569. $.datepicker._adjustDate( id, -stepMonths, "M" );
  7570. },
  7571. next: function() {
  7572. $.datepicker._adjustDate( id, +stepMonths, "M" );
  7573. },
  7574. hide: function() {
  7575. $.datepicker._hideDatepicker();
  7576. },
  7577. today: function() {
  7578. $.datepicker._gotoToday( id );
  7579. },
  7580. selectDay: function() {
  7581. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  7582. return false;
  7583. },
  7584. selectMonth: function() {
  7585. $.datepicker._selectMonthYear( id, this, "M" );
  7586. return false;
  7587. },
  7588. selectYear: function() {
  7589. $.datepicker._selectMonthYear( id, this, "Y" );
  7590. return false;
  7591. }
  7592. };
  7593. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  7594. } );
  7595. },
  7596. /* Generate the HTML for the current state of the date picker. */
  7597. _generateHTML: function( inst ) {
  7598. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7599. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7600. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7601. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7602. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7603. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7604. tempDate = new Date(),
  7605. today = this._daylightSavingAdjust(
  7606. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  7607. isRTL = this._get( inst, "isRTL" ),
  7608. showButtonPanel = this._get( inst, "showButtonPanel" ),
  7609. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  7610. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  7611. numMonths = this._getNumberOfMonths( inst ),
  7612. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  7613. stepMonths = this._get( inst, "stepMonths" ),
  7614. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  7615. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  7616. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  7617. minDate = this._getMinMaxDate( inst, "min" ),
  7618. maxDate = this._getMinMaxDate( inst, "max" ),
  7619. drawMonth = inst.drawMonth - showCurrentAtPos,
  7620. drawYear = inst.drawYear;
  7621. if ( drawMonth < 0 ) {
  7622. drawMonth += 12;
  7623. drawYear--;
  7624. }
  7625. if ( maxDate ) {
  7626. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  7627. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  7628. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  7629. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  7630. drawMonth--;
  7631. if ( drawMonth < 0 ) {
  7632. drawMonth = 11;
  7633. drawYear--;
  7634. }
  7635. }
  7636. }
  7637. inst.drawMonth = drawMonth;
  7638. inst.drawYear = drawYear;
  7639. prevText = this._get( inst, "prevText" );
  7640. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  7641. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  7642. this._getFormatConfig( inst ) ) );
  7643. if ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ) {
  7644. prev = $( "<a>" )
  7645. .attr( {
  7646. "class": "ui-datepicker-prev ui-corner-all",
  7647. "data-handler": "prev",
  7648. "data-event": "click",
  7649. title: prevText
  7650. } )
  7651. .append(
  7652. $( "<span>" )
  7653. .addClass( "ui-icon ui-icon-circle-triangle-" +
  7654. ( isRTL ? "e" : "w" ) )
  7655. .text( prevText )
  7656. )[ 0 ].outerHTML;
  7657. } else if ( hideIfNoPrevNext ) {
  7658. prev = "";
  7659. } else {
  7660. prev = $( "<a>" )
  7661. .attr( {
  7662. "class": "ui-datepicker-prev ui-corner-all ui-state-disabled",
  7663. title: prevText
  7664. } )
  7665. .append(
  7666. $( "<span>" )
  7667. .addClass( "ui-icon ui-icon-circle-triangle-" +
  7668. ( isRTL ? "e" : "w" ) )
  7669. .text( prevText )
  7670. )[ 0 ].outerHTML;
  7671. }
  7672. nextText = this._get( inst, "nextText" );
  7673. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  7674. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  7675. this._getFormatConfig( inst ) ) );
  7676. if ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ) {
  7677. next = $( "<a>" )
  7678. .attr( {
  7679. "class": "ui-datepicker-next ui-corner-all",
  7680. "data-handler": "next",
  7681. "data-event": "click",
  7682. title: nextText
  7683. } )
  7684. .append(
  7685. $( "<span>" )
  7686. .addClass( "ui-icon ui-icon-circle-triangle-" +
  7687. ( isRTL ? "w" : "e" ) )
  7688. .text( nextText )
  7689. )[ 0 ].outerHTML;
  7690. } else if ( hideIfNoPrevNext ) {
  7691. next = "";
  7692. } else {
  7693. next = $( "<a>" )
  7694. .attr( {
  7695. "class": "ui-datepicker-next ui-corner-all ui-state-disabled",
  7696. title: nextText
  7697. } )
  7698. .append(
  7699. $( "<span>" )
  7700. .attr( "class", "ui-icon ui-icon-circle-triangle-" +
  7701. ( isRTL ? "w" : "e" ) )
  7702. .text( nextText )
  7703. )[ 0 ].outerHTML;
  7704. }
  7705. currentText = this._get( inst, "currentText" );
  7706. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  7707. currentText = ( !navigationAsDateFormat ? currentText :
  7708. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  7709. controls = "";
  7710. if ( !inst.inline ) {
  7711. controls = $( "<button>" )
  7712. .attr( {
  7713. type: "button",
  7714. "class": "ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all",
  7715. "data-handler": "hide",
  7716. "data-event": "click"
  7717. } )
  7718. .text( this._get( inst, "closeText" ) )[ 0 ].outerHTML;
  7719. }
  7720. buttonPanel = "";
  7721. if ( showButtonPanel ) {
  7722. buttonPanel = $( "<div class='ui-datepicker-buttonpane ui-widget-content'>" )
  7723. .append( isRTL ? controls : "" )
  7724. .append( this._isInRange( inst, gotoDate ) ?
  7725. $( "<button>" )
  7726. .attr( {
  7727. type: "button",
  7728. "class": "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all",
  7729. "data-handler": "today",
  7730. "data-event": "click"
  7731. } )
  7732. .text( currentText ) :
  7733. "" )
  7734. .append( isRTL ? "" : controls )[ 0 ].outerHTML;
  7735. }
  7736. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  7737. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  7738. showWeek = this._get( inst, "showWeek" );
  7739. dayNames = this._get( inst, "dayNames" );
  7740. dayNamesMin = this._get( inst, "dayNamesMin" );
  7741. monthNames = this._get( inst, "monthNames" );
  7742. monthNamesShort = this._get( inst, "monthNamesShort" );
  7743. beforeShowDay = this._get( inst, "beforeShowDay" );
  7744. showOtherMonths = this._get( inst, "showOtherMonths" );
  7745. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  7746. defaultDate = this._getDefaultDate( inst );
  7747. html = "";
  7748. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  7749. group = "";
  7750. this.maxRows = 4;
  7751. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  7752. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  7753. cornerClass = " ui-corner-all";
  7754. calender = "";
  7755. if ( isMultiMonth ) {
  7756. calender += "<div class='ui-datepicker-group";
  7757. if ( numMonths[ 1 ] > 1 ) {
  7758. switch ( col ) {
  7759. case 0: calender += " ui-datepicker-group-first";
  7760. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  7761. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  7762. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  7763. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7764. }
  7765. }
  7766. calender += "'>";
  7767. }
  7768. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7769. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  7770. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  7771. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  7772. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  7773. "</div><table class='ui-datepicker-calendar'><thead>" +
  7774. "<tr>";
  7775. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  7776. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  7777. day = ( dow + firstDay ) % 7;
  7778. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  7779. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  7780. }
  7781. calender += thead + "</tr></thead><tbody>";
  7782. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  7783. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  7784. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  7785. }
  7786. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  7787. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  7788. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  7789. this.maxRows = numRows;
  7790. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  7791. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  7792. calender += "<tr>";
  7793. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7794. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  7795. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  7796. daySettings = ( beforeShowDay ?
  7797. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  7798. otherMonth = ( printDate.getMonth() !== drawMonth );
  7799. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  7800. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  7801. tbody += "<td class='" +
  7802. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  7803. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  7804. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  7805. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  7806. // or defaultDate is current printedDate and defaultDate is selectedDate
  7807. " " + this._dayOverClass : "" ) + // highlight selected day
  7808. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  7809. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  7810. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  7811. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  7812. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  7813. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  7814. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7815. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7816. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  7817. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  7818. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  7819. "' href='#' aria-current='" + ( printDate.getTime() === currentDate.getTime() ? "true" : "false" ) + // mark date as selected for screen reader
  7820. "' data-date='" + printDate.getDate() + // store date as data
  7821. "'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  7822. printDate.setDate( printDate.getDate() + 1 );
  7823. printDate = this._daylightSavingAdjust( printDate );
  7824. }
  7825. calender += tbody + "</tr>";
  7826. }
  7827. drawMonth++;
  7828. if ( drawMonth > 11 ) {
  7829. drawMonth = 0;
  7830. drawYear++;
  7831. }
  7832. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  7833. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  7834. group += calender;
  7835. }
  7836. html += group;
  7837. }
  7838. html += buttonPanel;
  7839. inst._keyEvent = false;
  7840. return html;
  7841. },
  7842. /* Generate the month and year header. */
  7843. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  7844. secondary, monthNames, monthNamesShort ) {
  7845. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7846. changeMonth = this._get( inst, "changeMonth" ),
  7847. changeYear = this._get( inst, "changeYear" ),
  7848. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  7849. selectMonthLabel = this._get( inst, "selectMonthLabel" ),
  7850. selectYearLabel = this._get( inst, "selectYearLabel" ),
  7851. html = "<div class='ui-datepicker-title'>",
  7852. monthHtml = "";
  7853. // Month selection
  7854. if ( secondary || !changeMonth ) {
  7855. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  7856. } else {
  7857. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  7858. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  7859. monthHtml += "<select class='ui-datepicker-month' aria-label='" + selectMonthLabel + "' data-handler='selectMonth' data-event='change'>";
  7860. for ( month = 0; month < 12; month++ ) {
  7861. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  7862. monthHtml += "<option value='" + month + "'" +
  7863. ( month === drawMonth ? " selected='selected'" : "" ) +
  7864. ">" + monthNamesShort[ month ] + "</option>";
  7865. }
  7866. }
  7867. monthHtml += "</select>";
  7868. }
  7869. if ( !showMonthAfterYear ) {
  7870. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  7871. }
  7872. // Year selection
  7873. if ( !inst.yearshtml ) {
  7874. inst.yearshtml = "";
  7875. if ( secondary || !changeYear ) {
  7876. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7877. } else {
  7878. // determine range of years to display
  7879. years = this._get( inst, "yearRange" ).split( ":" );
  7880. thisYear = new Date().getFullYear();
  7881. determineYear = function( value ) {
  7882. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  7883. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  7884. parseInt( value, 10 ) ) );
  7885. return ( isNaN( year ) ? thisYear : year );
  7886. };
  7887. year = determineYear( years[ 0 ] );
  7888. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  7889. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  7890. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  7891. inst.yearshtml += "<select class='ui-datepicker-year' aria-label='" + selectYearLabel + "' data-handler='selectYear' data-event='change'>";
  7892. for ( ; year <= endYear; year++ ) {
  7893. inst.yearshtml += "<option value='" + year + "'" +
  7894. ( year === drawYear ? " selected='selected'" : "" ) +
  7895. ">" + year + "</option>";
  7896. }
  7897. inst.yearshtml += "</select>";
  7898. html += inst.yearshtml;
  7899. inst.yearshtml = null;
  7900. }
  7901. }
  7902. html += this._get( inst, "yearSuffix" );
  7903. if ( showMonthAfterYear ) {
  7904. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  7905. }
  7906. html += "</div>"; // Close datepicker_header
  7907. return html;
  7908. },
  7909. /* Adjust one of the date sub-fields. */
  7910. _adjustInstDate: function( inst, offset, period ) {
  7911. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  7912. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  7913. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  7914. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  7915. inst.selectedDay = date.getDate();
  7916. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7917. inst.drawYear = inst.selectedYear = date.getFullYear();
  7918. if ( period === "M" || period === "Y" ) {
  7919. this._notifyChange( inst );
  7920. }
  7921. },
  7922. /* Ensure a date is within any min/max bounds. */
  7923. _restrictMinMax: function( inst, date ) {
  7924. var minDate = this._getMinMaxDate( inst, "min" ),
  7925. maxDate = this._getMinMaxDate( inst, "max" ),
  7926. newDate = ( minDate && date < minDate ? minDate : date );
  7927. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  7928. },
  7929. /* Notify change of month/year. */
  7930. _notifyChange: function( inst ) {
  7931. var onChange = this._get( inst, "onChangeMonthYear" );
  7932. if ( onChange ) {
  7933. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  7934. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  7935. }
  7936. },
  7937. /* Determine the number of months to show. */
  7938. _getNumberOfMonths: function( inst ) {
  7939. var numMonths = this._get( inst, "numberOfMonths" );
  7940. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  7941. },
  7942. /* Determine the current maximum date - ensure no time components are set. */
  7943. _getMinMaxDate: function( inst, minMax ) {
  7944. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  7945. },
  7946. /* Find the number of days in a given month. */
  7947. _getDaysInMonth: function( year, month ) {
  7948. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  7949. },
  7950. /* Find the day of the week of the first of a month. */
  7951. _getFirstDayOfMonth: function( year, month ) {
  7952. return new Date( year, month, 1 ).getDay();
  7953. },
  7954. /* Determines if we should allow a "next/prev" month display change. */
  7955. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  7956. var numMonths = this._getNumberOfMonths( inst ),
  7957. date = this._daylightSavingAdjust( new Date( curYear,
  7958. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  7959. if ( offset < 0 ) {
  7960. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  7961. }
  7962. return this._isInRange( inst, date );
  7963. },
  7964. /* Is the given date in the accepted range? */
  7965. _isInRange: function( inst, date ) {
  7966. var yearSplit, currentYear,
  7967. minDate = this._getMinMaxDate( inst, "min" ),
  7968. maxDate = this._getMinMaxDate( inst, "max" ),
  7969. minYear = null,
  7970. maxYear = null,
  7971. years = this._get( inst, "yearRange" );
  7972. if ( years ) {
  7973. yearSplit = years.split( ":" );
  7974. currentYear = new Date().getFullYear();
  7975. minYear = parseInt( yearSplit[ 0 ], 10 );
  7976. maxYear = parseInt( yearSplit[ 1 ], 10 );
  7977. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  7978. minYear += currentYear;
  7979. }
  7980. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  7981. maxYear += currentYear;
  7982. }
  7983. }
  7984. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  7985. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  7986. ( !minYear || date.getFullYear() >= minYear ) &&
  7987. ( !maxYear || date.getFullYear() <= maxYear ) );
  7988. },
  7989. /* Provide the configuration settings for formatting/parsing. */
  7990. _getFormatConfig: function( inst ) {
  7991. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  7992. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  7993. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  7994. return { shortYearCutoff: shortYearCutoff,
  7995. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  7996. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  7997. },
  7998. /* Format the given date for display. */
  7999. _formatDate: function( inst, day, month, year ) {
  8000. if ( !day ) {
  8001. inst.currentDay = inst.selectedDay;
  8002. inst.currentMonth = inst.selectedMonth;
  8003. inst.currentYear = inst.selectedYear;
  8004. }
  8005. var date = ( day ? ( typeof day === "object" ? day :
  8006. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  8007. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  8008. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  8009. }
  8010. } );
  8011. /*
  8012. * Bind hover events for datepicker elements.
  8013. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8014. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8015. */
  8016. function datepicker_bindHover( dpDiv ) {
  8017. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8018. return dpDiv.on( "mouseout", selector, function() {
  8019. $( this ).removeClass( "ui-state-hover" );
  8020. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  8021. $( this ).removeClass( "ui-datepicker-prev-hover" );
  8022. }
  8023. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  8024. $( this ).removeClass( "ui-datepicker-next-hover" );
  8025. }
  8026. } )
  8027. .on( "mouseover", selector, datepicker_handleMouseover );
  8028. }
  8029. function datepicker_handleMouseover() {
  8030. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  8031. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  8032. $( this ).addClass( "ui-state-hover" );
  8033. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  8034. $( this ).addClass( "ui-datepicker-prev-hover" );
  8035. }
  8036. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  8037. $( this ).addClass( "ui-datepicker-next-hover" );
  8038. }
  8039. }
  8040. }
  8041. /* jQuery extend now ignores nulls! */
  8042. function datepicker_extendRemove( target, props ) {
  8043. $.extend( target, props );
  8044. for ( var name in props ) {
  8045. if ( props[ name ] == null ) {
  8046. target[ name ] = props[ name ];
  8047. }
  8048. }
  8049. return target;
  8050. }
  8051. /* Invoke the datepicker functionality.
  8052. @param options string - a command, optionally followed by additional parameters or
  8053. Object - settings for attaching new datepicker functionality
  8054. @return jQuery object */
  8055. $.fn.datepicker = function( options ) {
  8056. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8057. if ( !this.length ) {
  8058. return this;
  8059. }
  8060. /* Initialise the date picker. */
  8061. if ( !$.datepicker.initialized ) {
  8062. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  8063. $.datepicker.initialized = true;
  8064. }
  8065. /* Append datepicker main container to body if not exist. */
  8066. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  8067. $( "body" ).append( $.datepicker.dpDiv );
  8068. }
  8069. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  8070. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  8071. return $.datepicker[ "_" + options + "Datepicker" ].
  8072. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  8073. }
  8074. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  8075. return $.datepicker[ "_" + options + "Datepicker" ].
  8076. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  8077. }
  8078. return this.each( function() {
  8079. if ( typeof options === "string" ) {
  8080. $.datepicker[ "_" + options + "Datepicker" ]
  8081. .apply( $.datepicker, [ this ].concat( otherArgs ) );
  8082. } else {
  8083. $.datepicker._attachDatepicker( this, options );
  8084. }
  8085. } );
  8086. };
  8087. $.datepicker = new Datepicker(); // singleton instance
  8088. $.datepicker.initialized = false;
  8089. $.datepicker.uuid = new Date().getTime();
  8090. $.datepicker.version = "1.13.0";
  8091. var widgetsDatepicker = $.datepicker;
  8092. // This file is deprecated
  8093. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  8094. /*!
  8095. * jQuery UI Mouse 1.13.0
  8096. * http://jqueryui.com
  8097. *
  8098. * Copyright jQuery Foundation and other contributors
  8099. * Released under the MIT license.
  8100. * http://jquery.org/license
  8101. */
  8102. //>>label: Mouse
  8103. //>>group: Widgets
  8104. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  8105. //>>docs: http://api.jqueryui.com/mouse/
  8106. var mouseHandled = false;
  8107. $( document ).on( "mouseup", function() {
  8108. mouseHandled = false;
  8109. } );
  8110. var widgetsMouse = $.widget( "ui.mouse", {
  8111. version: "1.13.0",
  8112. options: {
  8113. cancel: "input, textarea, button, select, option",
  8114. distance: 1,
  8115. delay: 0
  8116. },
  8117. _mouseInit: function() {
  8118. var that = this;
  8119. this.element
  8120. .on( "mousedown." + this.widgetName, function( event ) {
  8121. return that._mouseDown( event );
  8122. } )
  8123. .on( "click." + this.widgetName, function( event ) {
  8124. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  8125. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  8126. event.stopImmediatePropagation();
  8127. return false;
  8128. }
  8129. } );
  8130. this.started = false;
  8131. },
  8132. // TODO: make sure destroying one instance of mouse doesn't mess with
  8133. // other instances of mouse
  8134. _mouseDestroy: function() {
  8135. this.element.off( "." + this.widgetName );
  8136. if ( this._mouseMoveDelegate ) {
  8137. this.document
  8138. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  8139. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  8140. }
  8141. },
  8142. _mouseDown: function( event ) {
  8143. // don't let more than one widget handle mouseStart
  8144. if ( mouseHandled ) {
  8145. return;
  8146. }
  8147. this._mouseMoved = false;
  8148. // We may have missed mouseup (out of window)
  8149. if ( this._mouseStarted ) {
  8150. this._mouseUp( event );
  8151. }
  8152. this._mouseDownEvent = event;
  8153. var that = this,
  8154. btnIsLeft = ( event.which === 1 ),
  8155. // event.target.nodeName works around a bug in IE 8 with
  8156. // disabled inputs (#7620)
  8157. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  8158. $( event.target ).closest( this.options.cancel ).length : false );
  8159. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  8160. return true;
  8161. }
  8162. this.mouseDelayMet = !this.options.delay;
  8163. if ( !this.mouseDelayMet ) {
  8164. this._mouseDelayTimer = setTimeout( function() {
  8165. that.mouseDelayMet = true;
  8166. }, this.options.delay );
  8167. }
  8168. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  8169. this._mouseStarted = ( this._mouseStart( event ) !== false );
  8170. if ( !this._mouseStarted ) {
  8171. event.preventDefault();
  8172. return true;
  8173. }
  8174. }
  8175. // Click event may never have fired (Gecko & Opera)
  8176. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  8177. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  8178. }
  8179. // These delegates are required to keep context
  8180. this._mouseMoveDelegate = function( event ) {
  8181. return that._mouseMove( event );
  8182. };
  8183. this._mouseUpDelegate = function( event ) {
  8184. return that._mouseUp( event );
  8185. };
  8186. this.document
  8187. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  8188. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  8189. event.preventDefault();
  8190. mouseHandled = true;
  8191. return true;
  8192. },
  8193. _mouseMove: function( event ) {
  8194. // Only check for mouseups outside the document if you've moved inside the document
  8195. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  8196. // fire a mousemove event if content is placed under the cursor. See #7778
  8197. // Support: IE <9
  8198. if ( this._mouseMoved ) {
  8199. // IE mouseup check - mouseup happened when mouse was out of window
  8200. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  8201. !event.button ) {
  8202. return this._mouseUp( event );
  8203. // Iframe mouseup check - mouseup occurred in another document
  8204. } else if ( !event.which ) {
  8205. // Support: Safari <=8 - 9
  8206. // Safari sets which to 0 if you press any of the following keys
  8207. // during a drag (#14461)
  8208. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  8209. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  8210. this.ignoreMissingWhich = true;
  8211. } else if ( !this.ignoreMissingWhich ) {
  8212. return this._mouseUp( event );
  8213. }
  8214. }
  8215. }
  8216. if ( event.which || event.button ) {
  8217. this._mouseMoved = true;
  8218. }
  8219. if ( this._mouseStarted ) {
  8220. this._mouseDrag( event );
  8221. return event.preventDefault();
  8222. }
  8223. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  8224. this._mouseStarted =
  8225. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  8226. if ( this._mouseStarted ) {
  8227. this._mouseDrag( event );
  8228. } else {
  8229. this._mouseUp( event );
  8230. }
  8231. }
  8232. return !this._mouseStarted;
  8233. },
  8234. _mouseUp: function( event ) {
  8235. this.document
  8236. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  8237. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  8238. if ( this._mouseStarted ) {
  8239. this._mouseStarted = false;
  8240. if ( event.target === this._mouseDownEvent.target ) {
  8241. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  8242. }
  8243. this._mouseStop( event );
  8244. }
  8245. if ( this._mouseDelayTimer ) {
  8246. clearTimeout( this._mouseDelayTimer );
  8247. delete this._mouseDelayTimer;
  8248. }
  8249. this.ignoreMissingWhich = false;
  8250. mouseHandled = false;
  8251. event.preventDefault();
  8252. },
  8253. _mouseDistanceMet: function( event ) {
  8254. return ( Math.max(
  8255. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  8256. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  8257. ) >= this.options.distance
  8258. );
  8259. },
  8260. _mouseDelayMet: function( /* event */ ) {
  8261. return this.mouseDelayMet;
  8262. },
  8263. // These are placeholder methods, to be overriden by extending plugin
  8264. _mouseStart: function( /* event */ ) {},
  8265. _mouseDrag: function( /* event */ ) {},
  8266. _mouseStop: function( /* event */ ) {},
  8267. _mouseCapture: function( /* event */ ) {
  8268. return true;
  8269. }
  8270. } );
  8271. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  8272. var plugin = $.ui.plugin = {
  8273. add: function( module, option, set ) {
  8274. var i,
  8275. proto = $.ui[ module ].prototype;
  8276. for ( i in set ) {
  8277. proto.plugins[ i ] = proto.plugins[ i ] || [];
  8278. proto.plugins[ i ].push( [ option, set[ i ] ] );
  8279. }
  8280. },
  8281. call: function( instance, name, args, allowDisconnected ) {
  8282. var i,
  8283. set = instance.plugins[ name ];
  8284. if ( !set ) {
  8285. return;
  8286. }
  8287. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  8288. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  8289. return;
  8290. }
  8291. for ( i = 0; i < set.length; i++ ) {
  8292. if ( instance.options[ set[ i ][ 0 ] ] ) {
  8293. set[ i ][ 1 ].apply( instance.element, args );
  8294. }
  8295. }
  8296. }
  8297. };
  8298. var safeBlur = $.ui.safeBlur = function( element ) {
  8299. // Support: IE9 - 10 only
  8300. // If the <body> is blurred, IE will switch windows, see #9420
  8301. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  8302. $( element ).trigger( "blur" );
  8303. }
  8304. };
  8305. /*!
  8306. * jQuery UI Draggable 1.13.0
  8307. * http://jqueryui.com
  8308. *
  8309. * Copyright jQuery Foundation and other contributors
  8310. * Released under the MIT license.
  8311. * http://jquery.org/license
  8312. */
  8313. //>>label: Draggable
  8314. //>>group: Interactions
  8315. //>>description: Enables dragging functionality for any element.
  8316. //>>docs: http://api.jqueryui.com/draggable/
  8317. //>>demos: http://jqueryui.com/draggable/
  8318. //>>css.structure: ../../themes/base/draggable.css
  8319. $.widget( "ui.draggable", $.ui.mouse, {
  8320. version: "1.13.0",
  8321. widgetEventPrefix: "drag",
  8322. options: {
  8323. addClasses: true,
  8324. appendTo: "parent",
  8325. axis: false,
  8326. connectToSortable: false,
  8327. containment: false,
  8328. cursor: "auto",
  8329. cursorAt: false,
  8330. grid: false,
  8331. handle: false,
  8332. helper: "original",
  8333. iframeFix: false,
  8334. opacity: false,
  8335. refreshPositions: false,
  8336. revert: false,
  8337. revertDuration: 500,
  8338. scope: "default",
  8339. scroll: true,
  8340. scrollSensitivity: 20,
  8341. scrollSpeed: 20,
  8342. snap: false,
  8343. snapMode: "both",
  8344. snapTolerance: 20,
  8345. stack: false,
  8346. zIndex: false,
  8347. // Callbacks
  8348. drag: null,
  8349. start: null,
  8350. stop: null
  8351. },
  8352. _create: function() {
  8353. if ( this.options.helper === "original" ) {
  8354. this._setPositionRelative();
  8355. }
  8356. if ( this.options.addClasses ) {
  8357. this._addClass( "ui-draggable" );
  8358. }
  8359. this._setHandleClassName();
  8360. this._mouseInit();
  8361. },
  8362. _setOption: function( key, value ) {
  8363. this._super( key, value );
  8364. if ( key === "handle" ) {
  8365. this._removeHandleClassName();
  8366. this._setHandleClassName();
  8367. }
  8368. },
  8369. _destroy: function() {
  8370. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  8371. this.destroyOnClear = true;
  8372. return;
  8373. }
  8374. this._removeHandleClassName();
  8375. this._mouseDestroy();
  8376. },
  8377. _mouseCapture: function( event ) {
  8378. var o = this.options;
  8379. // Among others, prevent a drag on a resizable-handle
  8380. if ( this.helper || o.disabled ||
  8381. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  8382. return false;
  8383. }
  8384. //Quit if we're not on a valid handle
  8385. this.handle = this._getHandle( event );
  8386. if ( !this.handle ) {
  8387. return false;
  8388. }
  8389. this._blurActiveElement( event );
  8390. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  8391. return true;
  8392. },
  8393. _blockFrames: function( selector ) {
  8394. this.iframeBlocks = this.document.find( selector ).map( function() {
  8395. var iframe = $( this );
  8396. return $( "<div>" )
  8397. .css( "position", "absolute" )
  8398. .appendTo( iframe.parent() )
  8399. .outerWidth( iframe.outerWidth() )
  8400. .outerHeight( iframe.outerHeight() )
  8401. .offset( iframe.offset() )[ 0 ];
  8402. } );
  8403. },
  8404. _unblockFrames: function() {
  8405. if ( this.iframeBlocks ) {
  8406. this.iframeBlocks.remove();
  8407. delete this.iframeBlocks;
  8408. }
  8409. },
  8410. _blurActiveElement: function( event ) {
  8411. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  8412. target = $( event.target );
  8413. // Don't blur if the event occurred on an element that is within
  8414. // the currently focused element
  8415. // See #10527, #12472
  8416. if ( target.closest( activeElement ).length ) {
  8417. return;
  8418. }
  8419. // Blur any element that currently has focus, see #4261
  8420. $.ui.safeBlur( activeElement );
  8421. },
  8422. _mouseStart: function( event ) {
  8423. var o = this.options;
  8424. //Create and append the visible helper
  8425. this.helper = this._createHelper( event );
  8426. this._addClass( this.helper, "ui-draggable-dragging" );
  8427. //Cache the helper size
  8428. this._cacheHelperProportions();
  8429. //If ddmanager is used for droppables, set the global draggable
  8430. if ( $.ui.ddmanager ) {
  8431. $.ui.ddmanager.current = this;
  8432. }
  8433. /*
  8434. * - Position generation -
  8435. * This block generates everything position related - it's the core of draggables.
  8436. */
  8437. //Cache the margins of the original element
  8438. this._cacheMargins();
  8439. //Store the helper's css position
  8440. this.cssPosition = this.helper.css( "position" );
  8441. this.scrollParent = this.helper.scrollParent( true );
  8442. this.offsetParent = this.helper.offsetParent();
  8443. this.hasFixedAncestor = this.helper.parents().filter( function() {
  8444. return $( this ).css( "position" ) === "fixed";
  8445. } ).length > 0;
  8446. //The element's absolute position on the page minus margins
  8447. this.positionAbs = this.element.offset();
  8448. this._refreshOffsets( event );
  8449. //Generate the original position
  8450. this.originalPosition = this.position = this._generatePosition( event, false );
  8451. this.originalPageX = event.pageX;
  8452. this.originalPageY = event.pageY;
  8453. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  8454. if ( o.cursorAt ) {
  8455. this._adjustOffsetFromHelper( o.cursorAt );
  8456. }
  8457. //Set a containment if given in the options
  8458. this._setContainment();
  8459. //Trigger event + callbacks
  8460. if ( this._trigger( "start", event ) === false ) {
  8461. this._clear();
  8462. return false;
  8463. }
  8464. //Recache the helper size
  8465. this._cacheHelperProportions();
  8466. //Prepare the droppable offsets
  8467. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  8468. $.ui.ddmanager.prepareOffsets( this, event );
  8469. }
  8470. // Execute the drag once - this causes the helper not to be visible before getting its
  8471. // correct position
  8472. this._mouseDrag( event, true );
  8473. // If the ddmanager is used for droppables, inform the manager that dragging has started
  8474. // (see #5003)
  8475. if ( $.ui.ddmanager ) {
  8476. $.ui.ddmanager.dragStart( this, event );
  8477. }
  8478. return true;
  8479. },
  8480. _refreshOffsets: function( event ) {
  8481. this.offset = {
  8482. top: this.positionAbs.top - this.margins.top,
  8483. left: this.positionAbs.left - this.margins.left,
  8484. scroll: false,
  8485. parent: this._getParentOffset(),
  8486. relative: this._getRelativeOffset()
  8487. };
  8488. this.offset.click = {
  8489. left: event.pageX - this.offset.left,
  8490. top: event.pageY - this.offset.top
  8491. };
  8492. },
  8493. _mouseDrag: function( event, noPropagation ) {
  8494. // reset any necessary cached properties (see #5009)
  8495. if ( this.hasFixedAncestor ) {
  8496. this.offset.parent = this._getParentOffset();
  8497. }
  8498. //Compute the helpers position
  8499. this.position = this._generatePosition( event, true );
  8500. this.positionAbs = this._convertPositionTo( "absolute" );
  8501. //Call plugins and callbacks and use the resulting position if something is returned
  8502. if ( !noPropagation ) {
  8503. var ui = this._uiHash();
  8504. if ( this._trigger( "drag", event, ui ) === false ) {
  8505. this._mouseUp( new $.Event( "mouseup", event ) );
  8506. return false;
  8507. }
  8508. this.position = ui.position;
  8509. }
  8510. this.helper[ 0 ].style.left = this.position.left + "px";
  8511. this.helper[ 0 ].style.top = this.position.top + "px";
  8512. if ( $.ui.ddmanager ) {
  8513. $.ui.ddmanager.drag( this, event );
  8514. }
  8515. return false;
  8516. },
  8517. _mouseStop: function( event ) {
  8518. //If we are using droppables, inform the manager about the drop
  8519. var that = this,
  8520. dropped = false;
  8521. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  8522. dropped = $.ui.ddmanager.drop( this, event );
  8523. }
  8524. //if a drop comes from outside (a sortable)
  8525. if ( this.dropped ) {
  8526. dropped = this.dropped;
  8527. this.dropped = false;
  8528. }
  8529. if ( ( this.options.revert === "invalid" && !dropped ) ||
  8530. ( this.options.revert === "valid" && dropped ) ||
  8531. this.options.revert === true || ( typeof this.options.revert === "function" &&
  8532. this.options.revert.call( this.element, dropped ) )
  8533. ) {
  8534. $( this.helper ).animate(
  8535. this.originalPosition,
  8536. parseInt( this.options.revertDuration, 10 ),
  8537. function() {
  8538. if ( that._trigger( "stop", event ) !== false ) {
  8539. that._clear();
  8540. }
  8541. }
  8542. );
  8543. } else {
  8544. if ( this._trigger( "stop", event ) !== false ) {
  8545. this._clear();
  8546. }
  8547. }
  8548. return false;
  8549. },
  8550. _mouseUp: function( event ) {
  8551. this._unblockFrames();
  8552. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  8553. // (see #5003)
  8554. if ( $.ui.ddmanager ) {
  8555. $.ui.ddmanager.dragStop( this, event );
  8556. }
  8557. // Only need to focus if the event occurred on the draggable itself, see #10527
  8558. if ( this.handleElement.is( event.target ) ) {
  8559. // The interaction is over; whether or not the click resulted in a drag,
  8560. // focus the element
  8561. this.element.trigger( "focus" );
  8562. }
  8563. return $.ui.mouse.prototype._mouseUp.call( this, event );
  8564. },
  8565. cancel: function() {
  8566. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  8567. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  8568. } else {
  8569. this._clear();
  8570. }
  8571. return this;
  8572. },
  8573. _getHandle: function( event ) {
  8574. return this.options.handle ?
  8575. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  8576. true;
  8577. },
  8578. _setHandleClassName: function() {
  8579. this.handleElement = this.options.handle ?
  8580. this.element.find( this.options.handle ) : this.element;
  8581. this._addClass( this.handleElement, "ui-draggable-handle" );
  8582. },
  8583. _removeHandleClassName: function() {
  8584. this._removeClass( this.handleElement, "ui-draggable-handle" );
  8585. },
  8586. _createHelper: function( event ) {
  8587. var o = this.options,
  8588. helperIsFunction = typeof o.helper === "function",
  8589. helper = helperIsFunction ?
  8590. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  8591. ( o.helper === "clone" ?
  8592. this.element.clone().removeAttr( "id" ) :
  8593. this.element );
  8594. if ( !helper.parents( "body" ).length ) {
  8595. helper.appendTo( ( o.appendTo === "parent" ?
  8596. this.element[ 0 ].parentNode :
  8597. o.appendTo ) );
  8598. }
  8599. // Http://bugs.jqueryui.com/ticket/9446
  8600. // a helper function can return the original element
  8601. // which wouldn't have been set to relative in _create
  8602. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  8603. this._setPositionRelative();
  8604. }
  8605. if ( helper[ 0 ] !== this.element[ 0 ] &&
  8606. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  8607. helper.css( "position", "absolute" );
  8608. }
  8609. return helper;
  8610. },
  8611. _setPositionRelative: function() {
  8612. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  8613. this.element[ 0 ].style.position = "relative";
  8614. }
  8615. },
  8616. _adjustOffsetFromHelper: function( obj ) {
  8617. if ( typeof obj === "string" ) {
  8618. obj = obj.split( " " );
  8619. }
  8620. if ( Array.isArray( obj ) ) {
  8621. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  8622. }
  8623. if ( "left" in obj ) {
  8624. this.offset.click.left = obj.left + this.margins.left;
  8625. }
  8626. if ( "right" in obj ) {
  8627. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  8628. }
  8629. if ( "top" in obj ) {
  8630. this.offset.click.top = obj.top + this.margins.top;
  8631. }
  8632. if ( "bottom" in obj ) {
  8633. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  8634. }
  8635. },
  8636. _isRootNode: function( element ) {
  8637. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  8638. },
  8639. _getParentOffset: function() {
  8640. //Get the offsetParent and cache its position
  8641. var po = this.offsetParent.offset(),
  8642. document = this.document[ 0 ];
  8643. // This is a special case where we need to modify a offset calculated on start, since the
  8644. // following happened:
  8645. // 1. The position of the helper is absolute, so it's position is calculated based on the
  8646. // next positioned parent
  8647. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  8648. // the document, which means that the scroll is included in the initial calculation of the
  8649. // offset of the parent, and never recalculated upon drag
  8650. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  8651. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  8652. po.left += this.scrollParent.scrollLeft();
  8653. po.top += this.scrollParent.scrollTop();
  8654. }
  8655. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  8656. po = { top: 0, left: 0 };
  8657. }
  8658. return {
  8659. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  8660. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  8661. };
  8662. },
  8663. _getRelativeOffset: function() {
  8664. if ( this.cssPosition !== "relative" ) {
  8665. return { top: 0, left: 0 };
  8666. }
  8667. var p = this.element.position(),
  8668. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8669. return {
  8670. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  8671. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  8672. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  8673. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  8674. };
  8675. },
  8676. _cacheMargins: function() {
  8677. this.margins = {
  8678. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  8679. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  8680. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  8681. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  8682. };
  8683. },
  8684. _cacheHelperProportions: function() {
  8685. this.helperProportions = {
  8686. width: this.helper.outerWidth(),
  8687. height: this.helper.outerHeight()
  8688. };
  8689. },
  8690. _setContainment: function() {
  8691. var isUserScrollable, c, ce,
  8692. o = this.options,
  8693. document = this.document[ 0 ];
  8694. this.relativeContainer = null;
  8695. if ( !o.containment ) {
  8696. this.containment = null;
  8697. return;
  8698. }
  8699. if ( o.containment === "window" ) {
  8700. this.containment = [
  8701. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  8702. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  8703. $( window ).scrollLeft() + $( window ).width() -
  8704. this.helperProportions.width - this.margins.left,
  8705. $( window ).scrollTop() +
  8706. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  8707. this.helperProportions.height - this.margins.top
  8708. ];
  8709. return;
  8710. }
  8711. if ( o.containment === "document" ) {
  8712. this.containment = [
  8713. 0,
  8714. 0,
  8715. $( document ).width() - this.helperProportions.width - this.margins.left,
  8716. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  8717. this.helperProportions.height - this.margins.top
  8718. ];
  8719. return;
  8720. }
  8721. if ( o.containment.constructor === Array ) {
  8722. this.containment = o.containment;
  8723. return;
  8724. }
  8725. if ( o.containment === "parent" ) {
  8726. o.containment = this.helper[ 0 ].parentNode;
  8727. }
  8728. c = $( o.containment );
  8729. ce = c[ 0 ];
  8730. if ( !ce ) {
  8731. return;
  8732. }
  8733. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  8734. this.containment = [
  8735. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  8736. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  8737. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  8738. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  8739. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  8740. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  8741. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  8742. this.helperProportions.width -
  8743. this.margins.left -
  8744. this.margins.right,
  8745. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  8746. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  8747. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  8748. this.helperProportions.height -
  8749. this.margins.top -
  8750. this.margins.bottom
  8751. ];
  8752. this.relativeContainer = c;
  8753. },
  8754. _convertPositionTo: function( d, pos ) {
  8755. if ( !pos ) {
  8756. pos = this.position;
  8757. }
  8758. var mod = d === "absolute" ? 1 : -1,
  8759. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8760. return {
  8761. top: (
  8762. // The absolute mouse position
  8763. pos.top +
  8764. // Only for relative positioned nodes: Relative offset from element to offset parent
  8765. this.offset.relative.top * mod +
  8766. // The offsetParent's offset without borders (offset + border)
  8767. this.offset.parent.top * mod -
  8768. ( ( this.cssPosition === "fixed" ?
  8769. -this.offset.scroll.top :
  8770. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  8771. ),
  8772. left: (
  8773. // The absolute mouse position
  8774. pos.left +
  8775. // Only for relative positioned nodes: Relative offset from element to offset parent
  8776. this.offset.relative.left * mod +
  8777. // The offsetParent's offset without borders (offset + border)
  8778. this.offset.parent.left * mod -
  8779. ( ( this.cssPosition === "fixed" ?
  8780. -this.offset.scroll.left :
  8781. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  8782. )
  8783. };
  8784. },
  8785. _generatePosition: function( event, constrainPosition ) {
  8786. var containment, co, top, left,
  8787. o = this.options,
  8788. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  8789. pageX = event.pageX,
  8790. pageY = event.pageY;
  8791. // Cache the scroll
  8792. if ( !scrollIsRootNode || !this.offset.scroll ) {
  8793. this.offset.scroll = {
  8794. top: this.scrollParent.scrollTop(),
  8795. left: this.scrollParent.scrollLeft()
  8796. };
  8797. }
  8798. /*
  8799. * - Position constraining -
  8800. * Constrain the position to a mix of grid, containment.
  8801. */
  8802. // If we are not dragging yet, we won't check for options
  8803. if ( constrainPosition ) {
  8804. if ( this.containment ) {
  8805. if ( this.relativeContainer ) {
  8806. co = this.relativeContainer.offset();
  8807. containment = [
  8808. this.containment[ 0 ] + co.left,
  8809. this.containment[ 1 ] + co.top,
  8810. this.containment[ 2 ] + co.left,
  8811. this.containment[ 3 ] + co.top
  8812. ];
  8813. } else {
  8814. containment = this.containment;
  8815. }
  8816. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  8817. pageX = containment[ 0 ] + this.offset.click.left;
  8818. }
  8819. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  8820. pageY = containment[ 1 ] + this.offset.click.top;
  8821. }
  8822. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  8823. pageX = containment[ 2 ] + this.offset.click.left;
  8824. }
  8825. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  8826. pageY = containment[ 3 ] + this.offset.click.top;
  8827. }
  8828. }
  8829. if ( o.grid ) {
  8830. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  8831. // argument errors in IE (see ticket #6950)
  8832. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  8833. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  8834. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  8835. top - this.offset.click.top > containment[ 3 ] ) ?
  8836. top :
  8837. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  8838. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  8839. left = o.grid[ 0 ] ? this.originalPageX +
  8840. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  8841. this.originalPageX;
  8842. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  8843. left - this.offset.click.left > containment[ 2 ] ) ?
  8844. left :
  8845. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  8846. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  8847. }
  8848. if ( o.axis === "y" ) {
  8849. pageX = this.originalPageX;
  8850. }
  8851. if ( o.axis === "x" ) {
  8852. pageY = this.originalPageY;
  8853. }
  8854. }
  8855. return {
  8856. top: (
  8857. // The absolute mouse position
  8858. pageY -
  8859. // Click offset (relative to the element)
  8860. this.offset.click.top -
  8861. // Only for relative positioned nodes: Relative offset from element to offset parent
  8862. this.offset.relative.top -
  8863. // The offsetParent's offset without borders (offset + border)
  8864. this.offset.parent.top +
  8865. ( this.cssPosition === "fixed" ?
  8866. -this.offset.scroll.top :
  8867. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  8868. ),
  8869. left: (
  8870. // The absolute mouse position
  8871. pageX -
  8872. // Click offset (relative to the element)
  8873. this.offset.click.left -
  8874. // Only for relative positioned nodes: Relative offset from element to offset parent
  8875. this.offset.relative.left -
  8876. // The offsetParent's offset without borders (offset + border)
  8877. this.offset.parent.left +
  8878. ( this.cssPosition === "fixed" ?
  8879. -this.offset.scroll.left :
  8880. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  8881. )
  8882. };
  8883. },
  8884. _clear: function() {
  8885. this._removeClass( this.helper, "ui-draggable-dragging" );
  8886. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  8887. this.helper.remove();
  8888. }
  8889. this.helper = null;
  8890. this.cancelHelperRemoval = false;
  8891. if ( this.destroyOnClear ) {
  8892. this.destroy();
  8893. }
  8894. },
  8895. // From now on bulk stuff - mainly helpers
  8896. _trigger: function( type, event, ui ) {
  8897. ui = ui || this._uiHash();
  8898. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  8899. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  8900. if ( /^(drag|start|stop)/.test( type ) ) {
  8901. this.positionAbs = this._convertPositionTo( "absolute" );
  8902. ui.offset = this.positionAbs;
  8903. }
  8904. return $.Widget.prototype._trigger.call( this, type, event, ui );
  8905. },
  8906. plugins: {},
  8907. _uiHash: function() {
  8908. return {
  8909. helper: this.helper,
  8910. position: this.position,
  8911. originalPosition: this.originalPosition,
  8912. offset: this.positionAbs
  8913. };
  8914. }
  8915. } );
  8916. $.ui.plugin.add( "draggable", "connectToSortable", {
  8917. start: function( event, ui, draggable ) {
  8918. var uiSortable = $.extend( {}, ui, {
  8919. item: draggable.element
  8920. } );
  8921. draggable.sortables = [];
  8922. $( draggable.options.connectToSortable ).each( function() {
  8923. var sortable = $( this ).sortable( "instance" );
  8924. if ( sortable && !sortable.options.disabled ) {
  8925. draggable.sortables.push( sortable );
  8926. // RefreshPositions is called at drag start to refresh the containerCache
  8927. // which is used in drag. This ensures it's initialized and synchronized
  8928. // with any changes that might have happened on the page since initialization.
  8929. sortable.refreshPositions();
  8930. sortable._trigger( "activate", event, uiSortable );
  8931. }
  8932. } );
  8933. },
  8934. stop: function( event, ui, draggable ) {
  8935. var uiSortable = $.extend( {}, ui, {
  8936. item: draggable.element
  8937. } );
  8938. draggable.cancelHelperRemoval = false;
  8939. $.each( draggable.sortables, function() {
  8940. var sortable = this;
  8941. if ( sortable.isOver ) {
  8942. sortable.isOver = 0;
  8943. // Allow this sortable to handle removing the helper
  8944. draggable.cancelHelperRemoval = true;
  8945. sortable.cancelHelperRemoval = false;
  8946. // Use _storedCSS To restore properties in the sortable,
  8947. // as this also handles revert (#9675) since the draggable
  8948. // may have modified them in unexpected ways (#8809)
  8949. sortable._storedCSS = {
  8950. position: sortable.placeholder.css( "position" ),
  8951. top: sortable.placeholder.css( "top" ),
  8952. left: sortable.placeholder.css( "left" )
  8953. };
  8954. sortable._mouseStop( event );
  8955. // Once drag has ended, the sortable should return to using
  8956. // its original helper, not the shared helper from draggable
  8957. sortable.options.helper = sortable.options._helper;
  8958. } else {
  8959. // Prevent this Sortable from removing the helper.
  8960. // However, don't set the draggable to remove the helper
  8961. // either as another connected Sortable may yet handle the removal.
  8962. sortable.cancelHelperRemoval = true;
  8963. sortable._trigger( "deactivate", event, uiSortable );
  8964. }
  8965. } );
  8966. },
  8967. drag: function( event, ui, draggable ) {
  8968. $.each( draggable.sortables, function() {
  8969. var innermostIntersecting = false,
  8970. sortable = this;
  8971. // Copy over variables that sortable's _intersectsWith uses
  8972. sortable.positionAbs = draggable.positionAbs;
  8973. sortable.helperProportions = draggable.helperProportions;
  8974. sortable.offset.click = draggable.offset.click;
  8975. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  8976. innermostIntersecting = true;
  8977. $.each( draggable.sortables, function() {
  8978. // Copy over variables that sortable's _intersectsWith uses
  8979. this.positionAbs = draggable.positionAbs;
  8980. this.helperProportions = draggable.helperProportions;
  8981. this.offset.click = draggable.offset.click;
  8982. if ( this !== sortable &&
  8983. this._intersectsWith( this.containerCache ) &&
  8984. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  8985. innermostIntersecting = false;
  8986. }
  8987. return innermostIntersecting;
  8988. } );
  8989. }
  8990. if ( innermostIntersecting ) {
  8991. // If it intersects, we use a little isOver variable and set it once,
  8992. // so that the move-in stuff gets fired only once.
  8993. if ( !sortable.isOver ) {
  8994. sortable.isOver = 1;
  8995. // Store draggable's parent in case we need to reappend to it later.
  8996. draggable._parent = ui.helper.parent();
  8997. sortable.currentItem = ui.helper
  8998. .appendTo( sortable.element )
  8999. .data( "ui-sortable-item", true );
  9000. // Store helper option to later restore it
  9001. sortable.options._helper = sortable.options.helper;
  9002. sortable.options.helper = function() {
  9003. return ui.helper[ 0 ];
  9004. };
  9005. // Fire the start events of the sortable with our passed browser event,
  9006. // and our own helper (so it doesn't create a new one)
  9007. event.target = sortable.currentItem[ 0 ];
  9008. sortable._mouseCapture( event, true );
  9009. sortable._mouseStart( event, true, true );
  9010. // Because the browser event is way off the new appended portlet,
  9011. // modify necessary variables to reflect the changes
  9012. sortable.offset.click.top = draggable.offset.click.top;
  9013. sortable.offset.click.left = draggable.offset.click.left;
  9014. sortable.offset.parent.left -= draggable.offset.parent.left -
  9015. sortable.offset.parent.left;
  9016. sortable.offset.parent.top -= draggable.offset.parent.top -
  9017. sortable.offset.parent.top;
  9018. draggable._trigger( "toSortable", event );
  9019. // Inform draggable that the helper is in a valid drop zone,
  9020. // used solely in the revert option to handle "valid/invalid".
  9021. draggable.dropped = sortable.element;
  9022. // Need to refreshPositions of all sortables in the case that
  9023. // adding to one sortable changes the location of the other sortables (#9675)
  9024. $.each( draggable.sortables, function() {
  9025. this.refreshPositions();
  9026. } );
  9027. // Hack so receive/update callbacks work (mostly)
  9028. draggable.currentItem = draggable.element;
  9029. sortable.fromOutside = draggable;
  9030. }
  9031. if ( sortable.currentItem ) {
  9032. sortable._mouseDrag( event );
  9033. // Copy the sortable's position because the draggable's can potentially reflect
  9034. // a relative position, while sortable is always absolute, which the dragged
  9035. // element has now become. (#8809)
  9036. ui.position = sortable.position;
  9037. }
  9038. } else {
  9039. // If it doesn't intersect with the sortable, and it intersected before,
  9040. // we fake the drag stop of the sortable, but make sure it doesn't remove
  9041. // the helper by using cancelHelperRemoval.
  9042. if ( sortable.isOver ) {
  9043. sortable.isOver = 0;
  9044. sortable.cancelHelperRemoval = true;
  9045. // Calling sortable's mouseStop would trigger a revert,
  9046. // so revert must be temporarily false until after mouseStop is called.
  9047. sortable.options._revert = sortable.options.revert;
  9048. sortable.options.revert = false;
  9049. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  9050. sortable._mouseStop( event, true );
  9051. // Restore sortable behaviors that were modfied
  9052. // when the draggable entered the sortable area (#9481)
  9053. sortable.options.revert = sortable.options._revert;
  9054. sortable.options.helper = sortable.options._helper;
  9055. if ( sortable.placeholder ) {
  9056. sortable.placeholder.remove();
  9057. }
  9058. // Restore and recalculate the draggable's offset considering the sortable
  9059. // may have modified them in unexpected ways. (#8809, #10669)
  9060. ui.helper.appendTo( draggable._parent );
  9061. draggable._refreshOffsets( event );
  9062. ui.position = draggable._generatePosition( event, true );
  9063. draggable._trigger( "fromSortable", event );
  9064. // Inform draggable that the helper is no longer in a valid drop zone
  9065. draggable.dropped = false;
  9066. // Need to refreshPositions of all sortables just in case removing
  9067. // from one sortable changes the location of other sortables (#9675)
  9068. $.each( draggable.sortables, function() {
  9069. this.refreshPositions();
  9070. } );
  9071. }
  9072. }
  9073. } );
  9074. }
  9075. } );
  9076. $.ui.plugin.add( "draggable", "cursor", {
  9077. start: function( event, ui, instance ) {
  9078. var t = $( "body" ),
  9079. o = instance.options;
  9080. if ( t.css( "cursor" ) ) {
  9081. o._cursor = t.css( "cursor" );
  9082. }
  9083. t.css( "cursor", o.cursor );
  9084. },
  9085. stop: function( event, ui, instance ) {
  9086. var o = instance.options;
  9087. if ( o._cursor ) {
  9088. $( "body" ).css( "cursor", o._cursor );
  9089. }
  9090. }
  9091. } );
  9092. $.ui.plugin.add( "draggable", "opacity", {
  9093. start: function( event, ui, instance ) {
  9094. var t = $( ui.helper ),
  9095. o = instance.options;
  9096. if ( t.css( "opacity" ) ) {
  9097. o._opacity = t.css( "opacity" );
  9098. }
  9099. t.css( "opacity", o.opacity );
  9100. },
  9101. stop: function( event, ui, instance ) {
  9102. var o = instance.options;
  9103. if ( o._opacity ) {
  9104. $( ui.helper ).css( "opacity", o._opacity );
  9105. }
  9106. }
  9107. } );
  9108. $.ui.plugin.add( "draggable", "scroll", {
  9109. start: function( event, ui, i ) {
  9110. if ( !i.scrollParentNotHidden ) {
  9111. i.scrollParentNotHidden = i.helper.scrollParent( false );
  9112. }
  9113. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  9114. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  9115. i.overflowOffset = i.scrollParentNotHidden.offset();
  9116. }
  9117. },
  9118. drag: function( event, ui, i ) {
  9119. var o = i.options,
  9120. scrolled = false,
  9121. scrollParent = i.scrollParentNotHidden[ 0 ],
  9122. document = i.document[ 0 ];
  9123. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  9124. if ( !o.axis || o.axis !== "x" ) {
  9125. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  9126. o.scrollSensitivity ) {
  9127. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  9128. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  9129. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  9130. }
  9131. }
  9132. if ( !o.axis || o.axis !== "y" ) {
  9133. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  9134. o.scrollSensitivity ) {
  9135. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  9136. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  9137. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  9138. }
  9139. }
  9140. } else {
  9141. if ( !o.axis || o.axis !== "x" ) {
  9142. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  9143. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  9144. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  9145. o.scrollSensitivity ) {
  9146. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  9147. }
  9148. }
  9149. if ( !o.axis || o.axis !== "y" ) {
  9150. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  9151. scrolled = $( document ).scrollLeft(
  9152. $( document ).scrollLeft() - o.scrollSpeed
  9153. );
  9154. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  9155. o.scrollSensitivity ) {
  9156. scrolled = $( document ).scrollLeft(
  9157. $( document ).scrollLeft() + o.scrollSpeed
  9158. );
  9159. }
  9160. }
  9161. }
  9162. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  9163. $.ui.ddmanager.prepareOffsets( i, event );
  9164. }
  9165. }
  9166. } );
  9167. $.ui.plugin.add( "draggable", "snap", {
  9168. start: function( event, ui, i ) {
  9169. var o = i.options;
  9170. i.snapElements = [];
  9171. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  9172. .each( function() {
  9173. var $t = $( this ),
  9174. $o = $t.offset();
  9175. if ( this !== i.element[ 0 ] ) {
  9176. i.snapElements.push( {
  9177. item: this,
  9178. width: $t.outerWidth(), height: $t.outerHeight(),
  9179. top: $o.top, left: $o.left
  9180. } );
  9181. }
  9182. } );
  9183. },
  9184. drag: function( event, ui, inst ) {
  9185. var ts, bs, ls, rs, l, r, t, b, i, first,
  9186. o = inst.options,
  9187. d = o.snapTolerance,
  9188. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  9189. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  9190. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  9191. l = inst.snapElements[ i ].left - inst.margins.left;
  9192. r = l + inst.snapElements[ i ].width;
  9193. t = inst.snapElements[ i ].top - inst.margins.top;
  9194. b = t + inst.snapElements[ i ].height;
  9195. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  9196. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  9197. inst.snapElements[ i ].item ) ) {
  9198. if ( inst.snapElements[ i ].snapping ) {
  9199. if ( inst.options.snap.release ) {
  9200. inst.options.snap.release.call(
  9201. inst.element,
  9202. event,
  9203. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  9204. );
  9205. }
  9206. }
  9207. inst.snapElements[ i ].snapping = false;
  9208. continue;
  9209. }
  9210. if ( o.snapMode !== "inner" ) {
  9211. ts = Math.abs( t - y2 ) <= d;
  9212. bs = Math.abs( b - y1 ) <= d;
  9213. ls = Math.abs( l - x2 ) <= d;
  9214. rs = Math.abs( r - x1 ) <= d;
  9215. if ( ts ) {
  9216. ui.position.top = inst._convertPositionTo( "relative", {
  9217. top: t - inst.helperProportions.height,
  9218. left: 0
  9219. } ).top;
  9220. }
  9221. if ( bs ) {
  9222. ui.position.top = inst._convertPositionTo( "relative", {
  9223. top: b,
  9224. left: 0
  9225. } ).top;
  9226. }
  9227. if ( ls ) {
  9228. ui.position.left = inst._convertPositionTo( "relative", {
  9229. top: 0,
  9230. left: l - inst.helperProportions.width
  9231. } ).left;
  9232. }
  9233. if ( rs ) {
  9234. ui.position.left = inst._convertPositionTo( "relative", {
  9235. top: 0,
  9236. left: r
  9237. } ).left;
  9238. }
  9239. }
  9240. first = ( ts || bs || ls || rs );
  9241. if ( o.snapMode !== "outer" ) {
  9242. ts = Math.abs( t - y1 ) <= d;
  9243. bs = Math.abs( b - y2 ) <= d;
  9244. ls = Math.abs( l - x1 ) <= d;
  9245. rs = Math.abs( r - x2 ) <= d;
  9246. if ( ts ) {
  9247. ui.position.top = inst._convertPositionTo( "relative", {
  9248. top: t,
  9249. left: 0
  9250. } ).top;
  9251. }
  9252. if ( bs ) {
  9253. ui.position.top = inst._convertPositionTo( "relative", {
  9254. top: b - inst.helperProportions.height,
  9255. left: 0
  9256. } ).top;
  9257. }
  9258. if ( ls ) {
  9259. ui.position.left = inst._convertPositionTo( "relative", {
  9260. top: 0,
  9261. left: l
  9262. } ).left;
  9263. }
  9264. if ( rs ) {
  9265. ui.position.left = inst._convertPositionTo( "relative", {
  9266. top: 0,
  9267. left: r - inst.helperProportions.width
  9268. } ).left;
  9269. }
  9270. }
  9271. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  9272. if ( inst.options.snap.snap ) {
  9273. inst.options.snap.snap.call(
  9274. inst.element,
  9275. event,
  9276. $.extend( inst._uiHash(), {
  9277. snapItem: inst.snapElements[ i ].item
  9278. } ) );
  9279. }
  9280. }
  9281. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  9282. }
  9283. }
  9284. } );
  9285. $.ui.plugin.add( "draggable", "stack", {
  9286. start: function( event, ui, instance ) {
  9287. var min,
  9288. o = instance.options,
  9289. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  9290. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  9291. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  9292. } );
  9293. if ( !group.length ) {
  9294. return;
  9295. }
  9296. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  9297. $( group ).each( function( i ) {
  9298. $( this ).css( "zIndex", min + i );
  9299. } );
  9300. this.css( "zIndex", ( min + group.length ) );
  9301. }
  9302. } );
  9303. $.ui.plugin.add( "draggable", "zIndex", {
  9304. start: function( event, ui, instance ) {
  9305. var t = $( ui.helper ),
  9306. o = instance.options;
  9307. if ( t.css( "zIndex" ) ) {
  9308. o._zIndex = t.css( "zIndex" );
  9309. }
  9310. t.css( "zIndex", o.zIndex );
  9311. },
  9312. stop: function( event, ui, instance ) {
  9313. var o = instance.options;
  9314. if ( o._zIndex ) {
  9315. $( ui.helper ).css( "zIndex", o._zIndex );
  9316. }
  9317. }
  9318. } );
  9319. var widgetsDraggable = $.ui.draggable;
  9320. /*!
  9321. * jQuery UI Resizable 1.13.0
  9322. * http://jqueryui.com
  9323. *
  9324. * Copyright jQuery Foundation and other contributors
  9325. * Released under the MIT license.
  9326. * http://jquery.org/license
  9327. */
  9328. //>>label: Resizable
  9329. //>>group: Interactions
  9330. //>>description: Enables resize functionality for any element.
  9331. //>>docs: http://api.jqueryui.com/resizable/
  9332. //>>demos: http://jqueryui.com/resizable/
  9333. //>>css.structure: ../../themes/base/core.css
  9334. //>>css.structure: ../../themes/base/resizable.css
  9335. //>>css.theme: ../../themes/base/theme.css
  9336. $.widget( "ui.resizable", $.ui.mouse, {
  9337. version: "1.13.0",
  9338. widgetEventPrefix: "resize",
  9339. options: {
  9340. alsoResize: false,
  9341. animate: false,
  9342. animateDuration: "slow",
  9343. animateEasing: "swing",
  9344. aspectRatio: false,
  9345. autoHide: false,
  9346. classes: {
  9347. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  9348. },
  9349. containment: false,
  9350. ghost: false,
  9351. grid: false,
  9352. handles: "e,s,se",
  9353. helper: false,
  9354. maxHeight: null,
  9355. maxWidth: null,
  9356. minHeight: 10,
  9357. minWidth: 10,
  9358. // See #7960
  9359. zIndex: 90,
  9360. // Callbacks
  9361. resize: null,
  9362. start: null,
  9363. stop: null
  9364. },
  9365. _num: function( value ) {
  9366. return parseFloat( value ) || 0;
  9367. },
  9368. _isNumber: function( value ) {
  9369. return !isNaN( parseFloat( value ) );
  9370. },
  9371. _hasScroll: function( el, a ) {
  9372. if ( $( el ).css( "overflow" ) === "hidden" ) {
  9373. return false;
  9374. }
  9375. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  9376. has = false;
  9377. if ( el[ scroll ] > 0 ) {
  9378. return true;
  9379. }
  9380. // TODO: determine which cases actually cause this to happen
  9381. // if the element doesn't have the scroll set, see if it's possible to
  9382. // set the scroll
  9383. try {
  9384. el[ scroll ] = 1;
  9385. has = ( el[ scroll ] > 0 );
  9386. el[ scroll ] = 0;
  9387. } catch ( e ) {
  9388. // `el` might be a string, then setting `scroll` will throw
  9389. // an error in strict mode; ignore it.
  9390. }
  9391. return has;
  9392. },
  9393. _create: function() {
  9394. var margins,
  9395. o = this.options,
  9396. that = this;
  9397. this._addClass( "ui-resizable" );
  9398. $.extend( this, {
  9399. _aspectRatio: !!( o.aspectRatio ),
  9400. aspectRatio: o.aspectRatio,
  9401. originalElement: this.element,
  9402. _proportionallyResizeElements: [],
  9403. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  9404. } );
  9405. // Wrap the element if it cannot hold child nodes
  9406. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  9407. this.element.wrap(
  9408. $( "<div class='ui-wrapper'></div>" ).css( {
  9409. overflow: "hidden",
  9410. position: this.element.css( "position" ),
  9411. width: this.element.outerWidth(),
  9412. height: this.element.outerHeight(),
  9413. top: this.element.css( "top" ),
  9414. left: this.element.css( "left" )
  9415. } )
  9416. );
  9417. this.element = this.element.parent().data(
  9418. "ui-resizable", this.element.resizable( "instance" )
  9419. );
  9420. this.elementIsWrapper = true;
  9421. margins = {
  9422. marginTop: this.originalElement.css( "marginTop" ),
  9423. marginRight: this.originalElement.css( "marginRight" ),
  9424. marginBottom: this.originalElement.css( "marginBottom" ),
  9425. marginLeft: this.originalElement.css( "marginLeft" )
  9426. };
  9427. this.element.css( margins );
  9428. this.originalElement.css( "margin", 0 );
  9429. // support: Safari
  9430. // Prevent Safari textarea resize
  9431. this.originalResizeStyle = this.originalElement.css( "resize" );
  9432. this.originalElement.css( "resize", "none" );
  9433. this._proportionallyResizeElements.push( this.originalElement.css( {
  9434. position: "static",
  9435. zoom: 1,
  9436. display: "block"
  9437. } ) );
  9438. // Support: IE9
  9439. // avoid IE jump (hard set the margin)
  9440. this.originalElement.css( margins );
  9441. this._proportionallyResize();
  9442. }
  9443. this._setupHandles();
  9444. if ( o.autoHide ) {
  9445. $( this.element )
  9446. .on( "mouseenter", function() {
  9447. if ( o.disabled ) {
  9448. return;
  9449. }
  9450. that._removeClass( "ui-resizable-autohide" );
  9451. that._handles.show();
  9452. } )
  9453. .on( "mouseleave", function() {
  9454. if ( o.disabled ) {
  9455. return;
  9456. }
  9457. if ( !that.resizing ) {
  9458. that._addClass( "ui-resizable-autohide" );
  9459. that._handles.hide();
  9460. }
  9461. } );
  9462. }
  9463. this._mouseInit();
  9464. },
  9465. _destroy: function() {
  9466. this._mouseDestroy();
  9467. this._addedHandles.remove();
  9468. var wrapper,
  9469. _destroy = function( exp ) {
  9470. $( exp )
  9471. .removeData( "resizable" )
  9472. .removeData( "ui-resizable" )
  9473. .off( ".resizable" );
  9474. };
  9475. // TODO: Unwrap at same DOM position
  9476. if ( this.elementIsWrapper ) {
  9477. _destroy( this.element );
  9478. wrapper = this.element;
  9479. this.originalElement.css( {
  9480. position: wrapper.css( "position" ),
  9481. width: wrapper.outerWidth(),
  9482. height: wrapper.outerHeight(),
  9483. top: wrapper.css( "top" ),
  9484. left: wrapper.css( "left" )
  9485. } ).insertAfter( wrapper );
  9486. wrapper.remove();
  9487. }
  9488. this.originalElement.css( "resize", this.originalResizeStyle );
  9489. _destroy( this.originalElement );
  9490. return this;
  9491. },
  9492. _setOption: function( key, value ) {
  9493. this._super( key, value );
  9494. switch ( key ) {
  9495. case "handles":
  9496. this._removeHandles();
  9497. this._setupHandles();
  9498. break;
  9499. case "aspectRatio":
  9500. this._aspectRatio = !!value;
  9501. break;
  9502. default:
  9503. break;
  9504. }
  9505. },
  9506. _setupHandles: function() {
  9507. var o = this.options, handle, i, n, hname, axis, that = this;
  9508. this.handles = o.handles ||
  9509. ( !$( ".ui-resizable-handle", this.element ).length ?
  9510. "e,s,se" : {
  9511. n: ".ui-resizable-n",
  9512. e: ".ui-resizable-e",
  9513. s: ".ui-resizable-s",
  9514. w: ".ui-resizable-w",
  9515. se: ".ui-resizable-se",
  9516. sw: ".ui-resizable-sw",
  9517. ne: ".ui-resizable-ne",
  9518. nw: ".ui-resizable-nw"
  9519. } );
  9520. this._handles = $();
  9521. this._addedHandles = $();
  9522. if ( this.handles.constructor === String ) {
  9523. if ( this.handles === "all" ) {
  9524. this.handles = "n,e,s,w,se,sw,ne,nw";
  9525. }
  9526. n = this.handles.split( "," );
  9527. this.handles = {};
  9528. for ( i = 0; i < n.length; i++ ) {
  9529. handle = String.prototype.trim.call( n[ i ] );
  9530. hname = "ui-resizable-" + handle;
  9531. axis = $( "<div>" );
  9532. this._addClass( axis, "ui-resizable-handle " + hname );
  9533. axis.css( { zIndex: o.zIndex } );
  9534. this.handles[ handle ] = ".ui-resizable-" + handle;
  9535. if ( !this.element.children( this.handles[ handle ] ).length ) {
  9536. this.element.append( axis );
  9537. this._addedHandles = this._addedHandles.add( axis );
  9538. }
  9539. }
  9540. }
  9541. this._renderAxis = function( target ) {
  9542. var i, axis, padPos, padWrapper;
  9543. target = target || this.element;
  9544. for ( i in this.handles ) {
  9545. if ( this.handles[ i ].constructor === String ) {
  9546. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  9547. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  9548. this.handles[ i ] = $( this.handles[ i ] );
  9549. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  9550. }
  9551. if ( this.elementIsWrapper &&
  9552. this.originalElement[ 0 ]
  9553. .nodeName
  9554. .match( /^(textarea|input|select|button)$/i ) ) {
  9555. axis = $( this.handles[ i ], this.element );
  9556. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  9557. axis.outerHeight() :
  9558. axis.outerWidth();
  9559. padPos = [ "padding",
  9560. /ne|nw|n/.test( i ) ? "Top" :
  9561. /se|sw|s/.test( i ) ? "Bottom" :
  9562. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  9563. target.css( padPos, padWrapper );
  9564. this._proportionallyResize();
  9565. }
  9566. this._handles = this._handles.add( this.handles[ i ] );
  9567. }
  9568. };
  9569. // TODO: make renderAxis a prototype function
  9570. this._renderAxis( this.element );
  9571. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  9572. this._handles.disableSelection();
  9573. this._handles.on( "mouseover", function() {
  9574. if ( !that.resizing ) {
  9575. if ( this.className ) {
  9576. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  9577. }
  9578. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  9579. }
  9580. } );
  9581. if ( o.autoHide ) {
  9582. this._handles.hide();
  9583. this._addClass( "ui-resizable-autohide" );
  9584. }
  9585. },
  9586. _removeHandles: function() {
  9587. this._addedHandles.remove();
  9588. },
  9589. _mouseCapture: function( event ) {
  9590. var i, handle,
  9591. capture = false;
  9592. for ( i in this.handles ) {
  9593. handle = $( this.handles[ i ] )[ 0 ];
  9594. if ( handle === event.target || $.contains( handle, event.target ) ) {
  9595. capture = true;
  9596. }
  9597. }
  9598. return !this.options.disabled && capture;
  9599. },
  9600. _mouseStart: function( event ) {
  9601. var curleft, curtop, cursor,
  9602. o = this.options,
  9603. el = this.element;
  9604. this.resizing = true;
  9605. this._renderProxy();
  9606. curleft = this._num( this.helper.css( "left" ) );
  9607. curtop = this._num( this.helper.css( "top" ) );
  9608. if ( o.containment ) {
  9609. curleft += $( o.containment ).scrollLeft() || 0;
  9610. curtop += $( o.containment ).scrollTop() || 0;
  9611. }
  9612. this.offset = this.helper.offset();
  9613. this.position = { left: curleft, top: curtop };
  9614. this.size = this._helper ? {
  9615. width: this.helper.width(),
  9616. height: this.helper.height()
  9617. } : {
  9618. width: el.width(),
  9619. height: el.height()
  9620. };
  9621. this.originalSize = this._helper ? {
  9622. width: el.outerWidth(),
  9623. height: el.outerHeight()
  9624. } : {
  9625. width: el.width(),
  9626. height: el.height()
  9627. };
  9628. this.sizeDiff = {
  9629. width: el.outerWidth() - el.width(),
  9630. height: el.outerHeight() - el.height()
  9631. };
  9632. this.originalPosition = { left: curleft, top: curtop };
  9633. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  9634. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  9635. o.aspectRatio :
  9636. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  9637. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  9638. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  9639. this._addClass( "ui-resizable-resizing" );
  9640. this._propagate( "start", event );
  9641. return true;
  9642. },
  9643. _mouseDrag: function( event ) {
  9644. var data, props,
  9645. smp = this.originalMousePosition,
  9646. a = this.axis,
  9647. dx = ( event.pageX - smp.left ) || 0,
  9648. dy = ( event.pageY - smp.top ) || 0,
  9649. trigger = this._change[ a ];
  9650. this._updatePrevProperties();
  9651. if ( !trigger ) {
  9652. return false;
  9653. }
  9654. data = trigger.apply( this, [ event, dx, dy ] );
  9655. this._updateVirtualBoundaries( event.shiftKey );
  9656. if ( this._aspectRatio || event.shiftKey ) {
  9657. data = this._updateRatio( data, event );
  9658. }
  9659. data = this._respectSize( data, event );
  9660. this._updateCache( data );
  9661. this._propagate( "resize", event );
  9662. props = this._applyChanges();
  9663. if ( !this._helper && this._proportionallyResizeElements.length ) {
  9664. this._proportionallyResize();
  9665. }
  9666. if ( !$.isEmptyObject( props ) ) {
  9667. this._updatePrevProperties();
  9668. this._trigger( "resize", event, this.ui() );
  9669. this._applyChanges();
  9670. }
  9671. return false;
  9672. },
  9673. _mouseStop: function( event ) {
  9674. this.resizing = false;
  9675. var pr, ista, soffseth, soffsetw, s, left, top,
  9676. o = this.options, that = this;
  9677. if ( this._helper ) {
  9678. pr = this._proportionallyResizeElements;
  9679. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  9680. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  9681. soffsetw = ista ? 0 : that.sizeDiff.width;
  9682. s = {
  9683. width: ( that.helper.width() - soffsetw ),
  9684. height: ( that.helper.height() - soffseth )
  9685. };
  9686. left = ( parseFloat( that.element.css( "left" ) ) +
  9687. ( that.position.left - that.originalPosition.left ) ) || null;
  9688. top = ( parseFloat( that.element.css( "top" ) ) +
  9689. ( that.position.top - that.originalPosition.top ) ) || null;
  9690. if ( !o.animate ) {
  9691. this.element.css( $.extend( s, { top: top, left: left } ) );
  9692. }
  9693. that.helper.height( that.size.height );
  9694. that.helper.width( that.size.width );
  9695. if ( this._helper && !o.animate ) {
  9696. this._proportionallyResize();
  9697. }
  9698. }
  9699. $( "body" ).css( "cursor", "auto" );
  9700. this._removeClass( "ui-resizable-resizing" );
  9701. this._propagate( "stop", event );
  9702. if ( this._helper ) {
  9703. this.helper.remove();
  9704. }
  9705. return false;
  9706. },
  9707. _updatePrevProperties: function() {
  9708. this.prevPosition = {
  9709. top: this.position.top,
  9710. left: this.position.left
  9711. };
  9712. this.prevSize = {
  9713. width: this.size.width,
  9714. height: this.size.height
  9715. };
  9716. },
  9717. _applyChanges: function() {
  9718. var props = {};
  9719. if ( this.position.top !== this.prevPosition.top ) {
  9720. props.top = this.position.top + "px";
  9721. }
  9722. if ( this.position.left !== this.prevPosition.left ) {
  9723. props.left = this.position.left + "px";
  9724. }
  9725. if ( this.size.width !== this.prevSize.width ) {
  9726. props.width = this.size.width + "px";
  9727. }
  9728. if ( this.size.height !== this.prevSize.height ) {
  9729. props.height = this.size.height + "px";
  9730. }
  9731. this.helper.css( props );
  9732. return props;
  9733. },
  9734. _updateVirtualBoundaries: function( forceAspectRatio ) {
  9735. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  9736. o = this.options;
  9737. b = {
  9738. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  9739. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  9740. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  9741. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  9742. };
  9743. if ( this._aspectRatio || forceAspectRatio ) {
  9744. pMinWidth = b.minHeight * this.aspectRatio;
  9745. pMinHeight = b.minWidth / this.aspectRatio;
  9746. pMaxWidth = b.maxHeight * this.aspectRatio;
  9747. pMaxHeight = b.maxWidth / this.aspectRatio;
  9748. if ( pMinWidth > b.minWidth ) {
  9749. b.minWidth = pMinWidth;
  9750. }
  9751. if ( pMinHeight > b.minHeight ) {
  9752. b.minHeight = pMinHeight;
  9753. }
  9754. if ( pMaxWidth < b.maxWidth ) {
  9755. b.maxWidth = pMaxWidth;
  9756. }
  9757. if ( pMaxHeight < b.maxHeight ) {
  9758. b.maxHeight = pMaxHeight;
  9759. }
  9760. }
  9761. this._vBoundaries = b;
  9762. },
  9763. _updateCache: function( data ) {
  9764. this.offset = this.helper.offset();
  9765. if ( this._isNumber( data.left ) ) {
  9766. this.position.left = data.left;
  9767. }
  9768. if ( this._isNumber( data.top ) ) {
  9769. this.position.top = data.top;
  9770. }
  9771. if ( this._isNumber( data.height ) ) {
  9772. this.size.height = data.height;
  9773. }
  9774. if ( this._isNumber( data.width ) ) {
  9775. this.size.width = data.width;
  9776. }
  9777. },
  9778. _updateRatio: function( data ) {
  9779. var cpos = this.position,
  9780. csize = this.size,
  9781. a = this.axis;
  9782. if ( this._isNumber( data.height ) ) {
  9783. data.width = ( data.height * this.aspectRatio );
  9784. } else if ( this._isNumber( data.width ) ) {
  9785. data.height = ( data.width / this.aspectRatio );
  9786. }
  9787. if ( a === "sw" ) {
  9788. data.left = cpos.left + ( csize.width - data.width );
  9789. data.top = null;
  9790. }
  9791. if ( a === "nw" ) {
  9792. data.top = cpos.top + ( csize.height - data.height );
  9793. data.left = cpos.left + ( csize.width - data.width );
  9794. }
  9795. return data;
  9796. },
  9797. _respectSize: function( data ) {
  9798. var o = this._vBoundaries,
  9799. a = this.axis,
  9800. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  9801. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  9802. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  9803. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  9804. dw = this.originalPosition.left + this.originalSize.width,
  9805. dh = this.originalPosition.top + this.originalSize.height,
  9806. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  9807. if ( isminw ) {
  9808. data.width = o.minWidth;
  9809. }
  9810. if ( isminh ) {
  9811. data.height = o.minHeight;
  9812. }
  9813. if ( ismaxw ) {
  9814. data.width = o.maxWidth;
  9815. }
  9816. if ( ismaxh ) {
  9817. data.height = o.maxHeight;
  9818. }
  9819. if ( isminw && cw ) {
  9820. data.left = dw - o.minWidth;
  9821. }
  9822. if ( ismaxw && cw ) {
  9823. data.left = dw - o.maxWidth;
  9824. }
  9825. if ( isminh && ch ) {
  9826. data.top = dh - o.minHeight;
  9827. }
  9828. if ( ismaxh && ch ) {
  9829. data.top = dh - o.maxHeight;
  9830. }
  9831. // Fixing jump error on top/left - bug #2330
  9832. if ( !data.width && !data.height && !data.left && data.top ) {
  9833. data.top = null;
  9834. } else if ( !data.width && !data.height && !data.top && data.left ) {
  9835. data.left = null;
  9836. }
  9837. return data;
  9838. },
  9839. _getPaddingPlusBorderDimensions: function( element ) {
  9840. var i = 0,
  9841. widths = [],
  9842. borders = [
  9843. element.css( "borderTopWidth" ),
  9844. element.css( "borderRightWidth" ),
  9845. element.css( "borderBottomWidth" ),
  9846. element.css( "borderLeftWidth" )
  9847. ],
  9848. paddings = [
  9849. element.css( "paddingTop" ),
  9850. element.css( "paddingRight" ),
  9851. element.css( "paddingBottom" ),
  9852. element.css( "paddingLeft" )
  9853. ];
  9854. for ( ; i < 4; i++ ) {
  9855. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  9856. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  9857. }
  9858. return {
  9859. height: widths[ 0 ] + widths[ 2 ],
  9860. width: widths[ 1 ] + widths[ 3 ]
  9861. };
  9862. },
  9863. _proportionallyResize: function() {
  9864. if ( !this._proportionallyResizeElements.length ) {
  9865. return;
  9866. }
  9867. var prel,
  9868. i = 0,
  9869. element = this.helper || this.element;
  9870. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  9871. prel = this._proportionallyResizeElements[ i ];
  9872. // TODO: Seems like a bug to cache this.outerDimensions
  9873. // considering that we are in a loop.
  9874. if ( !this.outerDimensions ) {
  9875. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  9876. }
  9877. prel.css( {
  9878. height: ( element.height() - this.outerDimensions.height ) || 0,
  9879. width: ( element.width() - this.outerDimensions.width ) || 0
  9880. } );
  9881. }
  9882. },
  9883. _renderProxy: function() {
  9884. var el = this.element, o = this.options;
  9885. this.elementOffset = el.offset();
  9886. if ( this._helper ) {
  9887. this.helper = this.helper || $( "<div></div>" ).css( { overflow: "hidden" } );
  9888. this._addClass( this.helper, this._helper );
  9889. this.helper.css( {
  9890. width: this.element.outerWidth(),
  9891. height: this.element.outerHeight(),
  9892. position: "absolute",
  9893. left: this.elementOffset.left + "px",
  9894. top: this.elementOffset.top + "px",
  9895. zIndex: ++o.zIndex //TODO: Don't modify option
  9896. } );
  9897. this.helper
  9898. .appendTo( "body" )
  9899. .disableSelection();
  9900. } else {
  9901. this.helper = this.element;
  9902. }
  9903. },
  9904. _change: {
  9905. e: function( event, dx ) {
  9906. return { width: this.originalSize.width + dx };
  9907. },
  9908. w: function( event, dx ) {
  9909. var cs = this.originalSize, sp = this.originalPosition;
  9910. return { left: sp.left + dx, width: cs.width - dx };
  9911. },
  9912. n: function( event, dx, dy ) {
  9913. var cs = this.originalSize, sp = this.originalPosition;
  9914. return { top: sp.top + dy, height: cs.height - dy };
  9915. },
  9916. s: function( event, dx, dy ) {
  9917. return { height: this.originalSize.height + dy };
  9918. },
  9919. se: function( event, dx, dy ) {
  9920. return $.extend( this._change.s.apply( this, arguments ),
  9921. this._change.e.apply( this, [ event, dx, dy ] ) );
  9922. },
  9923. sw: function( event, dx, dy ) {
  9924. return $.extend( this._change.s.apply( this, arguments ),
  9925. this._change.w.apply( this, [ event, dx, dy ] ) );
  9926. },
  9927. ne: function( event, dx, dy ) {
  9928. return $.extend( this._change.n.apply( this, arguments ),
  9929. this._change.e.apply( this, [ event, dx, dy ] ) );
  9930. },
  9931. nw: function( event, dx, dy ) {
  9932. return $.extend( this._change.n.apply( this, arguments ),
  9933. this._change.w.apply( this, [ event, dx, dy ] ) );
  9934. }
  9935. },
  9936. _propagate: function( n, event ) {
  9937. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  9938. if ( n !== "resize" ) {
  9939. this._trigger( n, event, this.ui() );
  9940. }
  9941. },
  9942. plugins: {},
  9943. ui: function() {
  9944. return {
  9945. originalElement: this.originalElement,
  9946. element: this.element,
  9947. helper: this.helper,
  9948. position: this.position,
  9949. size: this.size,
  9950. originalSize: this.originalSize,
  9951. originalPosition: this.originalPosition
  9952. };
  9953. }
  9954. } );
  9955. /*
  9956. * Resizable Extensions
  9957. */
  9958. $.ui.plugin.add( "resizable", "animate", {
  9959. stop: function( event ) {
  9960. var that = $( this ).resizable( "instance" ),
  9961. o = that.options,
  9962. pr = that._proportionallyResizeElements,
  9963. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  9964. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  9965. soffsetw = ista ? 0 : that.sizeDiff.width,
  9966. style = {
  9967. width: ( that.size.width - soffsetw ),
  9968. height: ( that.size.height - soffseth )
  9969. },
  9970. left = ( parseFloat( that.element.css( "left" ) ) +
  9971. ( that.position.left - that.originalPosition.left ) ) || null,
  9972. top = ( parseFloat( that.element.css( "top" ) ) +
  9973. ( that.position.top - that.originalPosition.top ) ) || null;
  9974. that.element.animate(
  9975. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  9976. duration: o.animateDuration,
  9977. easing: o.animateEasing,
  9978. step: function() {
  9979. var data = {
  9980. width: parseFloat( that.element.css( "width" ) ),
  9981. height: parseFloat( that.element.css( "height" ) ),
  9982. top: parseFloat( that.element.css( "top" ) ),
  9983. left: parseFloat( that.element.css( "left" ) )
  9984. };
  9985. if ( pr && pr.length ) {
  9986. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  9987. }
  9988. // Propagating resize, and updating values for each animation step
  9989. that._updateCache( data );
  9990. that._propagate( "resize", event );
  9991. }
  9992. }
  9993. );
  9994. }
  9995. } );
  9996. $.ui.plugin.add( "resizable", "containment", {
  9997. start: function() {
  9998. var element, p, co, ch, cw, width, height,
  9999. that = $( this ).resizable( "instance" ),
  10000. o = that.options,
  10001. el = that.element,
  10002. oc = o.containment,
  10003. ce = ( oc instanceof $ ) ?
  10004. oc.get( 0 ) :
  10005. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  10006. if ( !ce ) {
  10007. return;
  10008. }
  10009. that.containerElement = $( ce );
  10010. if ( /document/.test( oc ) || oc === document ) {
  10011. that.containerOffset = {
  10012. left: 0,
  10013. top: 0
  10014. };
  10015. that.containerPosition = {
  10016. left: 0,
  10017. top: 0
  10018. };
  10019. that.parentData = {
  10020. element: $( document ),
  10021. left: 0,
  10022. top: 0,
  10023. width: $( document ).width(),
  10024. height: $( document ).height() || document.body.parentNode.scrollHeight
  10025. };
  10026. } else {
  10027. element = $( ce );
  10028. p = [];
  10029. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  10030. p[ i ] = that._num( element.css( "padding" + name ) );
  10031. } );
  10032. that.containerOffset = element.offset();
  10033. that.containerPosition = element.position();
  10034. that.containerSize = {
  10035. height: ( element.innerHeight() - p[ 3 ] ),
  10036. width: ( element.innerWidth() - p[ 1 ] )
  10037. };
  10038. co = that.containerOffset;
  10039. ch = that.containerSize.height;
  10040. cw = that.containerSize.width;
  10041. width = ( that._hasScroll( ce, "left" ) ? ce.scrollWidth : cw );
  10042. height = ( that._hasScroll( ce ) ? ce.scrollHeight : ch );
  10043. that.parentData = {
  10044. element: ce,
  10045. left: co.left,
  10046. top: co.top,
  10047. width: width,
  10048. height: height
  10049. };
  10050. }
  10051. },
  10052. resize: function( event ) {
  10053. var woset, hoset, isParent, isOffsetRelative,
  10054. that = $( this ).resizable( "instance" ),
  10055. o = that.options,
  10056. co = that.containerOffset,
  10057. cp = that.position,
  10058. pRatio = that._aspectRatio || event.shiftKey,
  10059. cop = {
  10060. top: 0,
  10061. left: 0
  10062. },
  10063. ce = that.containerElement,
  10064. continueResize = true;
  10065. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  10066. cop = co;
  10067. }
  10068. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  10069. that.size.width = that.size.width +
  10070. ( that._helper ?
  10071. ( that.position.left - co.left ) :
  10072. ( that.position.left - cop.left ) );
  10073. if ( pRatio ) {
  10074. that.size.height = that.size.width / that.aspectRatio;
  10075. continueResize = false;
  10076. }
  10077. that.position.left = o.helper ? co.left : 0;
  10078. }
  10079. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  10080. that.size.height = that.size.height +
  10081. ( that._helper ?
  10082. ( that.position.top - co.top ) :
  10083. that.position.top );
  10084. if ( pRatio ) {
  10085. that.size.width = that.size.height * that.aspectRatio;
  10086. continueResize = false;
  10087. }
  10088. that.position.top = that._helper ? co.top : 0;
  10089. }
  10090. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  10091. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  10092. if ( isParent && isOffsetRelative ) {
  10093. that.offset.left = that.parentData.left + that.position.left;
  10094. that.offset.top = that.parentData.top + that.position.top;
  10095. } else {
  10096. that.offset.left = that.element.offset().left;
  10097. that.offset.top = that.element.offset().top;
  10098. }
  10099. woset = Math.abs( that.sizeDiff.width +
  10100. ( that._helper ?
  10101. that.offset.left - cop.left :
  10102. ( that.offset.left - co.left ) ) );
  10103. hoset = Math.abs( that.sizeDiff.height +
  10104. ( that._helper ?
  10105. that.offset.top - cop.top :
  10106. ( that.offset.top - co.top ) ) );
  10107. if ( woset + that.size.width >= that.parentData.width ) {
  10108. that.size.width = that.parentData.width - woset;
  10109. if ( pRatio ) {
  10110. that.size.height = that.size.width / that.aspectRatio;
  10111. continueResize = false;
  10112. }
  10113. }
  10114. if ( hoset + that.size.height >= that.parentData.height ) {
  10115. that.size.height = that.parentData.height - hoset;
  10116. if ( pRatio ) {
  10117. that.size.width = that.size.height * that.aspectRatio;
  10118. continueResize = false;
  10119. }
  10120. }
  10121. if ( !continueResize ) {
  10122. that.position.left = that.prevPosition.left;
  10123. that.position.top = that.prevPosition.top;
  10124. that.size.width = that.prevSize.width;
  10125. that.size.height = that.prevSize.height;
  10126. }
  10127. },
  10128. stop: function() {
  10129. var that = $( this ).resizable( "instance" ),
  10130. o = that.options,
  10131. co = that.containerOffset,
  10132. cop = that.containerPosition,
  10133. ce = that.containerElement,
  10134. helper = $( that.helper ),
  10135. ho = helper.offset(),
  10136. w = helper.outerWidth() - that.sizeDiff.width,
  10137. h = helper.outerHeight() - that.sizeDiff.height;
  10138. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  10139. $( this ).css( {
  10140. left: ho.left - cop.left - co.left,
  10141. width: w,
  10142. height: h
  10143. } );
  10144. }
  10145. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  10146. $( this ).css( {
  10147. left: ho.left - cop.left - co.left,
  10148. width: w,
  10149. height: h
  10150. } );
  10151. }
  10152. }
  10153. } );
  10154. $.ui.plugin.add( "resizable", "alsoResize", {
  10155. start: function() {
  10156. var that = $( this ).resizable( "instance" ),
  10157. o = that.options;
  10158. $( o.alsoResize ).each( function() {
  10159. var el = $( this );
  10160. el.data( "ui-resizable-alsoresize", {
  10161. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  10162. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  10163. } );
  10164. } );
  10165. },
  10166. resize: function( event, ui ) {
  10167. var that = $( this ).resizable( "instance" ),
  10168. o = that.options,
  10169. os = that.originalSize,
  10170. op = that.originalPosition,
  10171. delta = {
  10172. height: ( that.size.height - os.height ) || 0,
  10173. width: ( that.size.width - os.width ) || 0,
  10174. top: ( that.position.top - op.top ) || 0,
  10175. left: ( that.position.left - op.left ) || 0
  10176. };
  10177. $( o.alsoResize ).each( function() {
  10178. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  10179. css = el.parents( ui.originalElement[ 0 ] ).length ?
  10180. [ "width", "height" ] :
  10181. [ "width", "height", "top", "left" ];
  10182. $.each( css, function( i, prop ) {
  10183. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  10184. if ( sum && sum >= 0 ) {
  10185. style[ prop ] = sum || null;
  10186. }
  10187. } );
  10188. el.css( style );
  10189. } );
  10190. },
  10191. stop: function() {
  10192. $( this ).removeData( "ui-resizable-alsoresize" );
  10193. }
  10194. } );
  10195. $.ui.plugin.add( "resizable", "ghost", {
  10196. start: function() {
  10197. var that = $( this ).resizable( "instance" ), cs = that.size;
  10198. that.ghost = that.originalElement.clone();
  10199. that.ghost.css( {
  10200. opacity: 0.25,
  10201. display: "block",
  10202. position: "relative",
  10203. height: cs.height,
  10204. width: cs.width,
  10205. margin: 0,
  10206. left: 0,
  10207. top: 0
  10208. } );
  10209. that._addClass( that.ghost, "ui-resizable-ghost" );
  10210. // DEPRECATED
  10211. // TODO: remove after 1.12
  10212. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  10213. // Ghost option
  10214. that.ghost.addClass( this.options.ghost );
  10215. }
  10216. that.ghost.appendTo( that.helper );
  10217. },
  10218. resize: function() {
  10219. var that = $( this ).resizable( "instance" );
  10220. if ( that.ghost ) {
  10221. that.ghost.css( {
  10222. position: "relative",
  10223. height: that.size.height,
  10224. width: that.size.width
  10225. } );
  10226. }
  10227. },
  10228. stop: function() {
  10229. var that = $( this ).resizable( "instance" );
  10230. if ( that.ghost && that.helper ) {
  10231. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  10232. }
  10233. }
  10234. } );
  10235. $.ui.plugin.add( "resizable", "grid", {
  10236. resize: function() {
  10237. var outerDimensions,
  10238. that = $( this ).resizable( "instance" ),
  10239. o = that.options,
  10240. cs = that.size,
  10241. os = that.originalSize,
  10242. op = that.originalPosition,
  10243. a = that.axis,
  10244. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  10245. gridX = ( grid[ 0 ] || 1 ),
  10246. gridY = ( grid[ 1 ] || 1 ),
  10247. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  10248. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  10249. newWidth = os.width + ox,
  10250. newHeight = os.height + oy,
  10251. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  10252. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  10253. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  10254. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  10255. o.grid = grid;
  10256. if ( isMinWidth ) {
  10257. newWidth += gridX;
  10258. }
  10259. if ( isMinHeight ) {
  10260. newHeight += gridY;
  10261. }
  10262. if ( isMaxWidth ) {
  10263. newWidth -= gridX;
  10264. }
  10265. if ( isMaxHeight ) {
  10266. newHeight -= gridY;
  10267. }
  10268. if ( /^(se|s|e)$/.test( a ) ) {
  10269. that.size.width = newWidth;
  10270. that.size.height = newHeight;
  10271. } else if ( /^(ne)$/.test( a ) ) {
  10272. that.size.width = newWidth;
  10273. that.size.height = newHeight;
  10274. that.position.top = op.top - oy;
  10275. } else if ( /^(sw)$/.test( a ) ) {
  10276. that.size.width = newWidth;
  10277. that.size.height = newHeight;
  10278. that.position.left = op.left - ox;
  10279. } else {
  10280. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  10281. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  10282. }
  10283. if ( newHeight - gridY > 0 ) {
  10284. that.size.height = newHeight;
  10285. that.position.top = op.top - oy;
  10286. } else {
  10287. newHeight = gridY - outerDimensions.height;
  10288. that.size.height = newHeight;
  10289. that.position.top = op.top + os.height - newHeight;
  10290. }
  10291. if ( newWidth - gridX > 0 ) {
  10292. that.size.width = newWidth;
  10293. that.position.left = op.left - ox;
  10294. } else {
  10295. newWidth = gridX - outerDimensions.width;
  10296. that.size.width = newWidth;
  10297. that.position.left = op.left + os.width - newWidth;
  10298. }
  10299. }
  10300. }
  10301. } );
  10302. var widgetsResizable = $.ui.resizable;
  10303. /*!
  10304. * jQuery UI Dialog 1.13.0
  10305. * http://jqueryui.com
  10306. *
  10307. * Copyright jQuery Foundation and other contributors
  10308. * Released under the MIT license.
  10309. * http://jquery.org/license
  10310. */
  10311. //>>label: Dialog
  10312. //>>group: Widgets
  10313. //>>description: Displays customizable dialog windows.
  10314. //>>docs: http://api.jqueryui.com/dialog/
  10315. //>>demos: http://jqueryui.com/dialog/
  10316. //>>css.structure: ../../themes/base/core.css
  10317. //>>css.structure: ../../themes/base/dialog.css
  10318. //>>css.theme: ../../themes/base/theme.css
  10319. $.widget( "ui.dialog", {
  10320. version: "1.13.0",
  10321. options: {
  10322. appendTo: "body",
  10323. autoOpen: true,
  10324. buttons: [],
  10325. classes: {
  10326. "ui-dialog": "ui-corner-all",
  10327. "ui-dialog-titlebar": "ui-corner-all"
  10328. },
  10329. closeOnEscape: true,
  10330. closeText: "Close",
  10331. draggable: true,
  10332. hide: null,
  10333. height: "auto",
  10334. maxHeight: null,
  10335. maxWidth: null,
  10336. minHeight: 150,
  10337. minWidth: 150,
  10338. modal: false,
  10339. position: {
  10340. my: "center",
  10341. at: "center",
  10342. of: window,
  10343. collision: "fit",
  10344. // Ensure the titlebar is always visible
  10345. using: function( pos ) {
  10346. var topOffset = $( this ).css( pos ).offset().top;
  10347. if ( topOffset < 0 ) {
  10348. $( this ).css( "top", pos.top - topOffset );
  10349. }
  10350. }
  10351. },
  10352. resizable: true,
  10353. show: null,
  10354. title: null,
  10355. width: 300,
  10356. // Callbacks
  10357. beforeClose: null,
  10358. close: null,
  10359. drag: null,
  10360. dragStart: null,
  10361. dragStop: null,
  10362. focus: null,
  10363. open: null,
  10364. resize: null,
  10365. resizeStart: null,
  10366. resizeStop: null
  10367. },
  10368. sizeRelatedOptions: {
  10369. buttons: true,
  10370. height: true,
  10371. maxHeight: true,
  10372. maxWidth: true,
  10373. minHeight: true,
  10374. minWidth: true,
  10375. width: true
  10376. },
  10377. resizableRelatedOptions: {
  10378. maxHeight: true,
  10379. maxWidth: true,
  10380. minHeight: true,
  10381. minWidth: true
  10382. },
  10383. _create: function() {
  10384. this.originalCss = {
  10385. display: this.element[ 0 ].style.display,
  10386. width: this.element[ 0 ].style.width,
  10387. minHeight: this.element[ 0 ].style.minHeight,
  10388. maxHeight: this.element[ 0 ].style.maxHeight,
  10389. height: this.element[ 0 ].style.height
  10390. };
  10391. this.originalPosition = {
  10392. parent: this.element.parent(),
  10393. index: this.element.parent().children().index( this.element )
  10394. };
  10395. this.originalTitle = this.element.attr( "title" );
  10396. if ( this.options.title == null && this.originalTitle != null ) {
  10397. this.options.title = this.originalTitle;
  10398. }
  10399. // Dialogs can't be disabled
  10400. if ( this.options.disabled ) {
  10401. this.options.disabled = false;
  10402. }
  10403. this._createWrapper();
  10404. this.element
  10405. .show()
  10406. .removeAttr( "title" )
  10407. .appendTo( this.uiDialog );
  10408. this._addClass( "ui-dialog-content", "ui-widget-content" );
  10409. this._createTitlebar();
  10410. this._createButtonPane();
  10411. if ( this.options.draggable && $.fn.draggable ) {
  10412. this._makeDraggable();
  10413. }
  10414. if ( this.options.resizable && $.fn.resizable ) {
  10415. this._makeResizable();
  10416. }
  10417. this._isOpen = false;
  10418. this._trackFocus();
  10419. },
  10420. _init: function() {
  10421. if ( this.options.autoOpen ) {
  10422. this.open();
  10423. }
  10424. },
  10425. _appendTo: function() {
  10426. var element = this.options.appendTo;
  10427. if ( element && ( element.jquery || element.nodeType ) ) {
  10428. return $( element );
  10429. }
  10430. return this.document.find( element || "body" ).eq( 0 );
  10431. },
  10432. _destroy: function() {
  10433. var next,
  10434. originalPosition = this.originalPosition;
  10435. this._untrackInstance();
  10436. this._destroyOverlay();
  10437. this.element
  10438. .removeUniqueId()
  10439. .css( this.originalCss )
  10440. // Without detaching first, the following becomes really slow
  10441. .detach();
  10442. this.uiDialog.remove();
  10443. if ( this.originalTitle ) {
  10444. this.element.attr( "title", this.originalTitle );
  10445. }
  10446. next = originalPosition.parent.children().eq( originalPosition.index );
  10447. // Don't try to place the dialog next to itself (#8613)
  10448. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  10449. next.before( this.element );
  10450. } else {
  10451. originalPosition.parent.append( this.element );
  10452. }
  10453. },
  10454. widget: function() {
  10455. return this.uiDialog;
  10456. },
  10457. disable: $.noop,
  10458. enable: $.noop,
  10459. close: function( event ) {
  10460. var that = this;
  10461. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  10462. return;
  10463. }
  10464. this._isOpen = false;
  10465. this._focusedElement = null;
  10466. this._destroyOverlay();
  10467. this._untrackInstance();
  10468. if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
  10469. // Hiding a focused element doesn't trigger blur in WebKit
  10470. // so in case we have nothing to focus on, explicitly blur the active element
  10471. // https://bugs.webkit.org/show_bug.cgi?id=47182
  10472. $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10473. }
  10474. this._hide( this.uiDialog, this.options.hide, function() {
  10475. that._trigger( "close", event );
  10476. } );
  10477. },
  10478. isOpen: function() {
  10479. return this._isOpen;
  10480. },
  10481. moveToTop: function() {
  10482. this._moveToTop();
  10483. },
  10484. _moveToTop: function( event, silent ) {
  10485. var moved = false,
  10486. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
  10487. return +$( this ).css( "z-index" );
  10488. } ).get(),
  10489. zIndexMax = Math.max.apply( null, zIndices );
  10490. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  10491. this.uiDialog.css( "z-index", zIndexMax + 1 );
  10492. moved = true;
  10493. }
  10494. if ( moved && !silent ) {
  10495. this._trigger( "focus", event );
  10496. }
  10497. return moved;
  10498. },
  10499. open: function() {
  10500. var that = this;
  10501. if ( this._isOpen ) {
  10502. if ( this._moveToTop() ) {
  10503. this._focusTabbable();
  10504. }
  10505. return;
  10506. }
  10507. this._isOpen = true;
  10508. this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10509. this._size();
  10510. this._position();
  10511. this._createOverlay();
  10512. this._moveToTop( null, true );
  10513. // Ensure the overlay is moved to the top with the dialog, but only when
  10514. // opening. The overlay shouldn't move after the dialog is open so that
  10515. // modeless dialogs opened after the modal dialog stack properly.
  10516. if ( this.overlay ) {
  10517. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  10518. }
  10519. this._show( this.uiDialog, this.options.show, function() {
  10520. that._focusTabbable();
  10521. that._trigger( "focus" );
  10522. } );
  10523. // Track the dialog immediately upon opening in case a focus event
  10524. // somehow occurs outside of the dialog before an element inside the
  10525. // dialog is focused (#10152)
  10526. this._makeFocusTarget();
  10527. this._trigger( "open" );
  10528. },
  10529. _focusTabbable: function() {
  10530. // Set focus to the first match:
  10531. // 1. An element that was focused previously
  10532. // 2. First element inside the dialog matching [autofocus]
  10533. // 3. Tabbable element inside the content element
  10534. // 4. Tabbable element inside the buttonpane
  10535. // 5. The close button
  10536. // 6. The dialog itself
  10537. var hasFocus = this._focusedElement;
  10538. if ( !hasFocus ) {
  10539. hasFocus = this.element.find( "[autofocus]" );
  10540. }
  10541. if ( !hasFocus.length ) {
  10542. hasFocus = this.element.find( ":tabbable" );
  10543. }
  10544. if ( !hasFocus.length ) {
  10545. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  10546. }
  10547. if ( !hasFocus.length ) {
  10548. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  10549. }
  10550. if ( !hasFocus.length ) {
  10551. hasFocus = this.uiDialog;
  10552. }
  10553. hasFocus.eq( 0 ).trigger( "focus" );
  10554. },
  10555. _restoreTabbableFocus: function() {
  10556. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  10557. isActive = this.uiDialog[ 0 ] === activeElement ||
  10558. $.contains( this.uiDialog[ 0 ], activeElement );
  10559. if ( !isActive ) {
  10560. this._focusTabbable();
  10561. }
  10562. },
  10563. _keepFocus: function( event ) {
  10564. event.preventDefault();
  10565. this._restoreTabbableFocus();
  10566. // support: IE
  10567. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  10568. // so we check again later
  10569. this._delay( this._restoreTabbableFocus );
  10570. },
  10571. _createWrapper: function() {
  10572. this.uiDialog = $( "<div>" )
  10573. .hide()
  10574. .attr( {
  10575. // Setting tabIndex makes the div focusable
  10576. tabIndex: -1,
  10577. role: "dialog"
  10578. } )
  10579. .appendTo( this._appendTo() );
  10580. this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
  10581. this._on( this.uiDialog, {
  10582. keydown: function( event ) {
  10583. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  10584. event.keyCode === $.ui.keyCode.ESCAPE ) {
  10585. event.preventDefault();
  10586. this.close( event );
  10587. return;
  10588. }
  10589. // Prevent tabbing out of dialogs
  10590. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  10591. return;
  10592. }
  10593. var tabbables = this.uiDialog.find( ":tabbable" ),
  10594. first = tabbables.first(),
  10595. last = tabbables.last();
  10596. if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
  10597. !event.shiftKey ) {
  10598. this._delay( function() {
  10599. first.trigger( "focus" );
  10600. } );
  10601. event.preventDefault();
  10602. } else if ( ( event.target === first[ 0 ] ||
  10603. event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
  10604. this._delay( function() {
  10605. last.trigger( "focus" );
  10606. } );
  10607. event.preventDefault();
  10608. }
  10609. },
  10610. mousedown: function( event ) {
  10611. if ( this._moveToTop( event ) ) {
  10612. this._focusTabbable();
  10613. }
  10614. }
  10615. } );
  10616. // We assume that any existing aria-describedby attribute means
  10617. // that the dialog content is marked up properly
  10618. // otherwise we brute force the content as the description
  10619. if ( !this.element.find( "[aria-describedby]" ).length ) {
  10620. this.uiDialog.attr( {
  10621. "aria-describedby": this.element.uniqueId().attr( "id" )
  10622. } );
  10623. }
  10624. },
  10625. _createTitlebar: function() {
  10626. var uiDialogTitle;
  10627. this.uiDialogTitlebar = $( "<div>" );
  10628. this._addClass( this.uiDialogTitlebar,
  10629. "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
  10630. this._on( this.uiDialogTitlebar, {
  10631. mousedown: function( event ) {
  10632. // Don't prevent click on close button (#8838)
  10633. // Focusing a dialog that is partially scrolled out of view
  10634. // causes the browser to scroll it into view, preventing the click event
  10635. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  10636. // Dialog isn't getting focus when dragging (#8063)
  10637. this.uiDialog.trigger( "focus" );
  10638. }
  10639. }
  10640. } );
  10641. // Support: IE
  10642. // Use type="button" to prevent enter keypresses in textboxes from closing the
  10643. // dialog in IE (#9312)
  10644. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  10645. .button( {
  10646. label: $( "<a>" ).text( this.options.closeText ).html(),
  10647. icon: "ui-icon-closethick",
  10648. showLabel: false
  10649. } )
  10650. .appendTo( this.uiDialogTitlebar );
  10651. this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
  10652. this._on( this.uiDialogTitlebarClose, {
  10653. click: function( event ) {
  10654. event.preventDefault();
  10655. this.close( event );
  10656. }
  10657. } );
  10658. uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
  10659. this._addClass( uiDialogTitle, "ui-dialog-title" );
  10660. this._title( uiDialogTitle );
  10661. this.uiDialogTitlebar.prependTo( this.uiDialog );
  10662. this.uiDialog.attr( {
  10663. "aria-labelledby": uiDialogTitle.attr( "id" )
  10664. } );
  10665. },
  10666. _title: function( title ) {
  10667. if ( this.options.title ) {
  10668. title.text( this.options.title );
  10669. } else {
  10670. title.html( "&#160;" );
  10671. }
  10672. },
  10673. _createButtonPane: function() {
  10674. this.uiDialogButtonPane = $( "<div>" );
  10675. this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
  10676. "ui-widget-content ui-helper-clearfix" );
  10677. this.uiButtonSet = $( "<div>" )
  10678. .appendTo( this.uiDialogButtonPane );
  10679. this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
  10680. this._createButtons();
  10681. },
  10682. _createButtons: function() {
  10683. var that = this,
  10684. buttons = this.options.buttons;
  10685. // If we already have a button pane, remove it
  10686. this.uiDialogButtonPane.remove();
  10687. this.uiButtonSet.empty();
  10688. if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) {
  10689. this._removeClass( this.uiDialog, "ui-dialog-buttons" );
  10690. return;
  10691. }
  10692. $.each( buttons, function( name, props ) {
  10693. var click, buttonOptions;
  10694. props = typeof props === "function" ?
  10695. { click: props, text: name } :
  10696. props;
  10697. // Default to a non-submitting button
  10698. props = $.extend( { type: "button" }, props );
  10699. // Change the context for the click callback to be the main element
  10700. click = props.click;
  10701. buttonOptions = {
  10702. icon: props.icon,
  10703. iconPosition: props.iconPosition,
  10704. showLabel: props.showLabel,
  10705. // Deprecated options
  10706. icons: props.icons,
  10707. text: props.text
  10708. };
  10709. delete props.click;
  10710. delete props.icon;
  10711. delete props.iconPosition;
  10712. delete props.showLabel;
  10713. // Deprecated options
  10714. delete props.icons;
  10715. if ( typeof props.text === "boolean" ) {
  10716. delete props.text;
  10717. }
  10718. $( "<button></button>", props )
  10719. .button( buttonOptions )
  10720. .appendTo( that.uiButtonSet )
  10721. .on( "click", function() {
  10722. click.apply( that.element[ 0 ], arguments );
  10723. } );
  10724. } );
  10725. this._addClass( this.uiDialog, "ui-dialog-buttons" );
  10726. this.uiDialogButtonPane.appendTo( this.uiDialog );
  10727. },
  10728. _makeDraggable: function() {
  10729. var that = this,
  10730. options = this.options;
  10731. function filteredUi( ui ) {
  10732. return {
  10733. position: ui.position,
  10734. offset: ui.offset
  10735. };
  10736. }
  10737. this.uiDialog.draggable( {
  10738. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  10739. handle: ".ui-dialog-titlebar",
  10740. containment: "document",
  10741. start: function( event, ui ) {
  10742. that._addClass( $( this ), "ui-dialog-dragging" );
  10743. that._blockFrames();
  10744. that._trigger( "dragStart", event, filteredUi( ui ) );
  10745. },
  10746. drag: function( event, ui ) {
  10747. that._trigger( "drag", event, filteredUi( ui ) );
  10748. },
  10749. stop: function( event, ui ) {
  10750. var left = ui.offset.left - that.document.scrollLeft(),
  10751. top = ui.offset.top - that.document.scrollTop();
  10752. options.position = {
  10753. my: "left top",
  10754. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10755. "top" + ( top >= 0 ? "+" : "" ) + top,
  10756. of: that.window
  10757. };
  10758. that._removeClass( $( this ), "ui-dialog-dragging" );
  10759. that._unblockFrames();
  10760. that._trigger( "dragStop", event, filteredUi( ui ) );
  10761. }
  10762. } );
  10763. },
  10764. _makeResizable: function() {
  10765. var that = this,
  10766. options = this.options,
  10767. handles = options.resizable,
  10768. // .ui-resizable has position: relative defined in the stylesheet
  10769. // but dialogs have to use absolute or fixed positioning
  10770. position = this.uiDialog.css( "position" ),
  10771. resizeHandles = typeof handles === "string" ?
  10772. handles :
  10773. "n,e,s,w,se,sw,ne,nw";
  10774. function filteredUi( ui ) {
  10775. return {
  10776. originalPosition: ui.originalPosition,
  10777. originalSize: ui.originalSize,
  10778. position: ui.position,
  10779. size: ui.size
  10780. };
  10781. }
  10782. this.uiDialog.resizable( {
  10783. cancel: ".ui-dialog-content",
  10784. containment: "document",
  10785. alsoResize: this.element,
  10786. maxWidth: options.maxWidth,
  10787. maxHeight: options.maxHeight,
  10788. minWidth: options.minWidth,
  10789. minHeight: this._minHeight(),
  10790. handles: resizeHandles,
  10791. start: function( event, ui ) {
  10792. that._addClass( $( this ), "ui-dialog-resizing" );
  10793. that._blockFrames();
  10794. that._trigger( "resizeStart", event, filteredUi( ui ) );
  10795. },
  10796. resize: function( event, ui ) {
  10797. that._trigger( "resize", event, filteredUi( ui ) );
  10798. },
  10799. stop: function( event, ui ) {
  10800. var offset = that.uiDialog.offset(),
  10801. left = offset.left - that.document.scrollLeft(),
  10802. top = offset.top - that.document.scrollTop();
  10803. options.height = that.uiDialog.height();
  10804. options.width = that.uiDialog.width();
  10805. options.position = {
  10806. my: "left top",
  10807. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10808. "top" + ( top >= 0 ? "+" : "" ) + top,
  10809. of: that.window
  10810. };
  10811. that._removeClass( $( this ), "ui-dialog-resizing" );
  10812. that._unblockFrames();
  10813. that._trigger( "resizeStop", event, filteredUi( ui ) );
  10814. }
  10815. } )
  10816. .css( "position", position );
  10817. },
  10818. _trackFocus: function() {
  10819. this._on( this.widget(), {
  10820. focusin: function( event ) {
  10821. this._makeFocusTarget();
  10822. this._focusedElement = $( event.target );
  10823. }
  10824. } );
  10825. },
  10826. _makeFocusTarget: function() {
  10827. this._untrackInstance();
  10828. this._trackingInstances().unshift( this );
  10829. },
  10830. _untrackInstance: function() {
  10831. var instances = this._trackingInstances(),
  10832. exists = $.inArray( this, instances );
  10833. if ( exists !== -1 ) {
  10834. instances.splice( exists, 1 );
  10835. }
  10836. },
  10837. _trackingInstances: function() {
  10838. var instances = this.document.data( "ui-dialog-instances" );
  10839. if ( !instances ) {
  10840. instances = [];
  10841. this.document.data( "ui-dialog-instances", instances );
  10842. }
  10843. return instances;
  10844. },
  10845. _minHeight: function() {
  10846. var options = this.options;
  10847. return options.height === "auto" ?
  10848. options.minHeight :
  10849. Math.min( options.minHeight, options.height );
  10850. },
  10851. _position: function() {
  10852. // Need to show the dialog to get the actual offset in the position plugin
  10853. var isVisible = this.uiDialog.is( ":visible" );
  10854. if ( !isVisible ) {
  10855. this.uiDialog.show();
  10856. }
  10857. this.uiDialog.position( this.options.position );
  10858. if ( !isVisible ) {
  10859. this.uiDialog.hide();
  10860. }
  10861. },
  10862. _setOptions: function( options ) {
  10863. var that = this,
  10864. resize = false,
  10865. resizableOptions = {};
  10866. $.each( options, function( key, value ) {
  10867. that._setOption( key, value );
  10868. if ( key in that.sizeRelatedOptions ) {
  10869. resize = true;
  10870. }
  10871. if ( key in that.resizableRelatedOptions ) {
  10872. resizableOptions[ key ] = value;
  10873. }
  10874. } );
  10875. if ( resize ) {
  10876. this._size();
  10877. this._position();
  10878. }
  10879. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10880. this.uiDialog.resizable( "option", resizableOptions );
  10881. }
  10882. },
  10883. _setOption: function( key, value ) {
  10884. var isDraggable, isResizable,
  10885. uiDialog = this.uiDialog;
  10886. if ( key === "disabled" ) {
  10887. return;
  10888. }
  10889. this._super( key, value );
  10890. if ( key === "appendTo" ) {
  10891. this.uiDialog.appendTo( this._appendTo() );
  10892. }
  10893. if ( key === "buttons" ) {
  10894. this._createButtons();
  10895. }
  10896. if ( key === "closeText" ) {
  10897. this.uiDialogTitlebarClose.button( {
  10898. // Ensure that we always pass a string
  10899. label: $( "<a>" ).text( "" + this.options.closeText ).html()
  10900. } );
  10901. }
  10902. if ( key === "draggable" ) {
  10903. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  10904. if ( isDraggable && !value ) {
  10905. uiDialog.draggable( "destroy" );
  10906. }
  10907. if ( !isDraggable && value ) {
  10908. this._makeDraggable();
  10909. }
  10910. }
  10911. if ( key === "position" ) {
  10912. this._position();
  10913. }
  10914. if ( key === "resizable" ) {
  10915. // currently resizable, becoming non-resizable
  10916. isResizable = uiDialog.is( ":data(ui-resizable)" );
  10917. if ( isResizable && !value ) {
  10918. uiDialog.resizable( "destroy" );
  10919. }
  10920. // Currently resizable, changing handles
  10921. if ( isResizable && typeof value === "string" ) {
  10922. uiDialog.resizable( "option", "handles", value );
  10923. }
  10924. // Currently non-resizable, becoming resizable
  10925. if ( !isResizable && value !== false ) {
  10926. this._makeResizable();
  10927. }
  10928. }
  10929. if ( key === "title" ) {
  10930. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  10931. }
  10932. },
  10933. _size: function() {
  10934. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  10935. // divs will both have width and height set, so we need to reset them
  10936. var nonContentHeight, minContentHeight, maxContentHeight,
  10937. options = this.options;
  10938. // Reset content sizing
  10939. this.element.show().css( {
  10940. width: "auto",
  10941. minHeight: 0,
  10942. maxHeight: "none",
  10943. height: 0
  10944. } );
  10945. if ( options.minWidth > options.width ) {
  10946. options.width = options.minWidth;
  10947. }
  10948. // Reset wrapper sizing
  10949. // determine the height of all the non-content elements
  10950. nonContentHeight = this.uiDialog.css( {
  10951. height: "auto",
  10952. width: options.width
  10953. } )
  10954. .outerHeight();
  10955. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  10956. maxContentHeight = typeof options.maxHeight === "number" ?
  10957. Math.max( 0, options.maxHeight - nonContentHeight ) :
  10958. "none";
  10959. if ( options.height === "auto" ) {
  10960. this.element.css( {
  10961. minHeight: minContentHeight,
  10962. maxHeight: maxContentHeight,
  10963. height: "auto"
  10964. } );
  10965. } else {
  10966. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  10967. }
  10968. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10969. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  10970. }
  10971. },
  10972. _blockFrames: function() {
  10973. this.iframeBlocks = this.document.find( "iframe" ).map( function() {
  10974. var iframe = $( this );
  10975. return $( "<div>" )
  10976. .css( {
  10977. position: "absolute",
  10978. width: iframe.outerWidth(),
  10979. height: iframe.outerHeight()
  10980. } )
  10981. .appendTo( iframe.parent() )
  10982. .offset( iframe.offset() )[ 0 ];
  10983. } );
  10984. },
  10985. _unblockFrames: function() {
  10986. if ( this.iframeBlocks ) {
  10987. this.iframeBlocks.remove();
  10988. delete this.iframeBlocks;
  10989. }
  10990. },
  10991. _allowInteraction: function( event ) {
  10992. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  10993. return true;
  10994. }
  10995. // TODO: Remove hack when datepicker implements
  10996. // the .ui-front logic (#8989)
  10997. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  10998. },
  10999. _createOverlay: function() {
  11000. if ( !this.options.modal ) {
  11001. return;
  11002. }
  11003. var jqMinor = $.fn.jquery.substring( 0, 4 );
  11004. // We use a delay in case the overlay is created from an
  11005. // event that we're going to be cancelling (#2804)
  11006. var isOpening = true;
  11007. this._delay( function() {
  11008. isOpening = false;
  11009. } );
  11010. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  11011. // Prevent use of anchors and inputs
  11012. // This doesn't use `_on()` because it is a shared event handler
  11013. // across all open modal dialogs.
  11014. this.document.on( "focusin.ui-dialog", function( event ) {
  11015. if ( isOpening ) {
  11016. return;
  11017. }
  11018. var instance = this._trackingInstances()[ 0 ];
  11019. if ( !instance._allowInteraction( event ) ) {
  11020. event.preventDefault();
  11021. instance._focusTabbable();
  11022. // Support: jQuery >=3.4 <3.6 only
  11023. // Focus re-triggering in jQuery 3.4/3.5 makes the original element
  11024. // have its focus event propagated last, breaking the re-targeting.
  11025. // Trigger focus in a delay in addition if needed to avoid the issue
  11026. // See https://github.com/jquery/jquery/issues/4382
  11027. if ( jqMinor === "3.4." || jqMinor === "3.5." ) {
  11028. instance._delay( instance._restoreTabbableFocus );
  11029. }
  11030. }
  11031. }.bind( this ) );
  11032. }
  11033. this.overlay = $( "<div>" )
  11034. .appendTo( this._appendTo() );
  11035. this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
  11036. this._on( this.overlay, {
  11037. mousedown: "_keepFocus"
  11038. } );
  11039. this.document.data( "ui-dialog-overlays",
  11040. ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
  11041. },
  11042. _destroyOverlay: function() {
  11043. if ( !this.options.modal ) {
  11044. return;
  11045. }
  11046. if ( this.overlay ) {
  11047. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  11048. if ( !overlays ) {
  11049. this.document.off( "focusin.ui-dialog" );
  11050. this.document.removeData( "ui-dialog-overlays" );
  11051. } else {
  11052. this.document.data( "ui-dialog-overlays", overlays );
  11053. }
  11054. this.overlay.remove();
  11055. this.overlay = null;
  11056. }
  11057. }
  11058. } );
  11059. // DEPRECATED
  11060. // TODO: switch return back to widget declaration at top of file when this is removed
  11061. if ( $.uiBackCompat !== false ) {
  11062. // Backcompat for dialogClass option
  11063. $.widget( "ui.dialog", $.ui.dialog, {
  11064. options: {
  11065. dialogClass: ""
  11066. },
  11067. _createWrapper: function() {
  11068. this._super();
  11069. this.uiDialog.addClass( this.options.dialogClass );
  11070. },
  11071. _setOption: function( key, value ) {
  11072. if ( key === "dialogClass" ) {
  11073. this.uiDialog
  11074. .removeClass( this.options.dialogClass )
  11075. .addClass( value );
  11076. }
  11077. this._superApply( arguments );
  11078. }
  11079. } );
  11080. }
  11081. var widgetsDialog = $.ui.dialog;
  11082. /*!
  11083. * jQuery UI Droppable 1.13.0
  11084. * http://jqueryui.com
  11085. *
  11086. * Copyright jQuery Foundation and other contributors
  11087. * Released under the MIT license.
  11088. * http://jquery.org/license
  11089. */
  11090. //>>label: Droppable
  11091. //>>group: Interactions
  11092. //>>description: Enables drop targets for draggable elements.
  11093. //>>docs: http://api.jqueryui.com/droppable/
  11094. //>>demos: http://jqueryui.com/droppable/
  11095. $.widget( "ui.droppable", {
  11096. version: "1.13.0",
  11097. widgetEventPrefix: "drop",
  11098. options: {
  11099. accept: "*",
  11100. addClasses: true,
  11101. greedy: false,
  11102. scope: "default",
  11103. tolerance: "intersect",
  11104. // Callbacks
  11105. activate: null,
  11106. deactivate: null,
  11107. drop: null,
  11108. out: null,
  11109. over: null
  11110. },
  11111. _create: function() {
  11112. var proportions,
  11113. o = this.options,
  11114. accept = o.accept;
  11115. this.isover = false;
  11116. this.isout = true;
  11117. this.accept = typeof accept === "function" ? accept : function( d ) {
  11118. return d.is( accept );
  11119. };
  11120. this.proportions = function( /* valueToWrite */ ) {
  11121. if ( arguments.length ) {
  11122. // Store the droppable's proportions
  11123. proportions = arguments[ 0 ];
  11124. } else {
  11125. // Retrieve or derive the droppable's proportions
  11126. return proportions ?
  11127. proportions :
  11128. proportions = {
  11129. width: this.element[ 0 ].offsetWidth,
  11130. height: this.element[ 0 ].offsetHeight
  11131. };
  11132. }
  11133. };
  11134. this._addToManager( o.scope );
  11135. if ( o.addClasses ) {
  11136. this._addClass( "ui-droppable" );
  11137. }
  11138. },
  11139. _addToManager: function( scope ) {
  11140. // Add the reference and positions to the manager
  11141. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  11142. $.ui.ddmanager.droppables[ scope ].push( this );
  11143. },
  11144. _splice: function( drop ) {
  11145. var i = 0;
  11146. for ( ; i < drop.length; i++ ) {
  11147. if ( drop[ i ] === this ) {
  11148. drop.splice( i, 1 );
  11149. }
  11150. }
  11151. },
  11152. _destroy: function() {
  11153. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  11154. this._splice( drop );
  11155. },
  11156. _setOption: function( key, value ) {
  11157. if ( key === "accept" ) {
  11158. this.accept = typeof value === "function" ? value : function( d ) {
  11159. return d.is( value );
  11160. };
  11161. } else if ( key === "scope" ) {
  11162. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  11163. this._splice( drop );
  11164. this._addToManager( value );
  11165. }
  11166. this._super( key, value );
  11167. },
  11168. _activate: function( event ) {
  11169. var draggable = $.ui.ddmanager.current;
  11170. this._addActiveClass();
  11171. if ( draggable ) {
  11172. this._trigger( "activate", event, this.ui( draggable ) );
  11173. }
  11174. },
  11175. _deactivate: function( event ) {
  11176. var draggable = $.ui.ddmanager.current;
  11177. this._removeActiveClass();
  11178. if ( draggable ) {
  11179. this._trigger( "deactivate", event, this.ui( draggable ) );
  11180. }
  11181. },
  11182. _over: function( event ) {
  11183. var draggable = $.ui.ddmanager.current;
  11184. // Bail if draggable and droppable are same element
  11185. if ( !draggable || ( draggable.currentItem ||
  11186. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  11187. return;
  11188. }
  11189. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  11190. draggable.element ) ) ) {
  11191. this._addHoverClass();
  11192. this._trigger( "over", event, this.ui( draggable ) );
  11193. }
  11194. },
  11195. _out: function( event ) {
  11196. var draggable = $.ui.ddmanager.current;
  11197. // Bail if draggable and droppable are same element
  11198. if ( !draggable || ( draggable.currentItem ||
  11199. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  11200. return;
  11201. }
  11202. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  11203. draggable.element ) ) ) {
  11204. this._removeHoverClass();
  11205. this._trigger( "out", event, this.ui( draggable ) );
  11206. }
  11207. },
  11208. _drop: function( event, custom ) {
  11209. var draggable = custom || $.ui.ddmanager.current,
  11210. childrenIntersection = false;
  11211. // Bail if draggable and droppable are same element
  11212. if ( !draggable || ( draggable.currentItem ||
  11213. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  11214. return false;
  11215. }
  11216. this.element
  11217. .find( ":data(ui-droppable)" )
  11218. .not( ".ui-draggable-dragging" )
  11219. .each( function() {
  11220. var inst = $( this ).droppable( "instance" );
  11221. if (
  11222. inst.options.greedy &&
  11223. !inst.options.disabled &&
  11224. inst.options.scope === draggable.options.scope &&
  11225. inst.accept.call(
  11226. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  11227. ) &&
  11228. $.ui.intersect(
  11229. draggable,
  11230. $.extend( inst, { offset: inst.element.offset() } ),
  11231. inst.options.tolerance, event
  11232. )
  11233. ) {
  11234. childrenIntersection = true;
  11235. return false;
  11236. }
  11237. } );
  11238. if ( childrenIntersection ) {
  11239. return false;
  11240. }
  11241. if ( this.accept.call( this.element[ 0 ],
  11242. ( draggable.currentItem || draggable.element ) ) ) {
  11243. this._removeActiveClass();
  11244. this._removeHoverClass();
  11245. this._trigger( "drop", event, this.ui( draggable ) );
  11246. return this.element;
  11247. }
  11248. return false;
  11249. },
  11250. ui: function( c ) {
  11251. return {
  11252. draggable: ( c.currentItem || c.element ),
  11253. helper: c.helper,
  11254. position: c.position,
  11255. offset: c.positionAbs
  11256. };
  11257. },
  11258. // Extension points just to make backcompat sane and avoid duplicating logic
  11259. // TODO: Remove in 1.14 along with call to it below
  11260. _addHoverClass: function() {
  11261. this._addClass( "ui-droppable-hover" );
  11262. },
  11263. _removeHoverClass: function() {
  11264. this._removeClass( "ui-droppable-hover" );
  11265. },
  11266. _addActiveClass: function() {
  11267. this._addClass( "ui-droppable-active" );
  11268. },
  11269. _removeActiveClass: function() {
  11270. this._removeClass( "ui-droppable-active" );
  11271. }
  11272. } );
  11273. $.ui.intersect = ( function() {
  11274. function isOverAxis( x, reference, size ) {
  11275. return ( x >= reference ) && ( x < ( reference + size ) );
  11276. }
  11277. return function( draggable, droppable, toleranceMode, event ) {
  11278. if ( !droppable.offset ) {
  11279. return false;
  11280. }
  11281. var x1 = ( draggable.positionAbs ||
  11282. draggable.position.absolute ).left + draggable.margins.left,
  11283. y1 = ( draggable.positionAbs ||
  11284. draggable.position.absolute ).top + draggable.margins.top,
  11285. x2 = x1 + draggable.helperProportions.width,
  11286. y2 = y1 + draggable.helperProportions.height,
  11287. l = droppable.offset.left,
  11288. t = droppable.offset.top,
  11289. r = l + droppable.proportions().width,
  11290. b = t + droppable.proportions().height;
  11291. switch ( toleranceMode ) {
  11292. case "fit":
  11293. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  11294. case "intersect":
  11295. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  11296. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  11297. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  11298. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  11299. case "pointer":
  11300. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  11301. isOverAxis( event.pageX, l, droppable.proportions().width );
  11302. case "touch":
  11303. return (
  11304. ( y1 >= t && y1 <= b ) || // Top edge touching
  11305. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  11306. ( y1 < t && y2 > b ) // Surrounded vertically
  11307. ) && (
  11308. ( x1 >= l && x1 <= r ) || // Left edge touching
  11309. ( x2 >= l && x2 <= r ) || // Right edge touching
  11310. ( x1 < l && x2 > r ) // Surrounded horizontally
  11311. );
  11312. default:
  11313. return false;
  11314. }
  11315. };
  11316. } )();
  11317. /*
  11318. This manager tracks offsets of draggables and droppables
  11319. */
  11320. $.ui.ddmanager = {
  11321. current: null,
  11322. droppables: { "default": [] },
  11323. prepareOffsets: function( t, event ) {
  11324. var i, j,
  11325. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  11326. type = event ? event.type : null, // workaround for #2317
  11327. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  11328. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  11329. // No disabled and non-accepted
  11330. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  11331. ( t.currentItem || t.element ) ) ) ) {
  11332. continue;
  11333. }
  11334. // Filter out elements in the current dragged item
  11335. for ( j = 0; j < list.length; j++ ) {
  11336. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  11337. m[ i ].proportions().height = 0;
  11338. continue droppablesLoop;
  11339. }
  11340. }
  11341. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  11342. if ( !m[ i ].visible ) {
  11343. continue;
  11344. }
  11345. // Activate the droppable if used directly from draggables
  11346. if ( type === "mousedown" ) {
  11347. m[ i ]._activate.call( m[ i ], event );
  11348. }
  11349. m[ i ].offset = m[ i ].element.offset();
  11350. m[ i ].proportions( {
  11351. width: m[ i ].element[ 0 ].offsetWidth,
  11352. height: m[ i ].element[ 0 ].offsetHeight
  11353. } );
  11354. }
  11355. },
  11356. drop: function( draggable, event ) {
  11357. var dropped = false;
  11358. // Create a copy of the droppables in case the list changes during the drop (#9116)
  11359. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  11360. if ( !this.options ) {
  11361. return;
  11362. }
  11363. if ( !this.options.disabled && this.visible &&
  11364. $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  11365. dropped = this._drop.call( this, event ) || dropped;
  11366. }
  11367. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  11368. ( draggable.currentItem || draggable.element ) ) ) {
  11369. this.isout = true;
  11370. this.isover = false;
  11371. this._deactivate.call( this, event );
  11372. }
  11373. } );
  11374. return dropped;
  11375. },
  11376. dragStart: function( draggable, event ) {
  11377. // Listen for scrolling so that if the dragging causes scrolling the position of the
  11378. // droppables can be recalculated (see #5003)
  11379. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  11380. if ( !draggable.options.refreshPositions ) {
  11381. $.ui.ddmanager.prepareOffsets( draggable, event );
  11382. }
  11383. } );
  11384. },
  11385. drag: function( draggable, event ) {
  11386. // If you have a highly dynamic page, you might try this option. It renders positions
  11387. // every time you move the mouse.
  11388. if ( draggable.options.refreshPositions ) {
  11389. $.ui.ddmanager.prepareOffsets( draggable, event );
  11390. }
  11391. // Run through all droppables and check their positions based on specific tolerance options
  11392. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  11393. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  11394. return;
  11395. }
  11396. var parentInstance, scope, parent,
  11397. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  11398. c = !intersects && this.isover ?
  11399. "isout" :
  11400. ( intersects && !this.isover ? "isover" : null );
  11401. if ( !c ) {
  11402. return;
  11403. }
  11404. if ( this.options.greedy ) {
  11405. // find droppable parents with same scope
  11406. scope = this.options.scope;
  11407. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  11408. return $( this ).droppable( "instance" ).options.scope === scope;
  11409. } );
  11410. if ( parent.length ) {
  11411. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  11412. parentInstance.greedyChild = ( c === "isover" );
  11413. }
  11414. }
  11415. // We just moved into a greedy child
  11416. if ( parentInstance && c === "isover" ) {
  11417. parentInstance.isover = false;
  11418. parentInstance.isout = true;
  11419. parentInstance._out.call( parentInstance, event );
  11420. }
  11421. this[ c ] = true;
  11422. this[ c === "isout" ? "isover" : "isout" ] = false;
  11423. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  11424. // We just moved out of a greedy child
  11425. if ( parentInstance && c === "isout" ) {
  11426. parentInstance.isout = false;
  11427. parentInstance.isover = true;
  11428. parentInstance._over.call( parentInstance, event );
  11429. }
  11430. } );
  11431. },
  11432. dragStop: function( draggable, event ) {
  11433. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  11434. // Call prepareOffsets one final time since IE does not fire return scroll events when
  11435. // overflow was caused by drag (see #5003)
  11436. if ( !draggable.options.refreshPositions ) {
  11437. $.ui.ddmanager.prepareOffsets( draggable, event );
  11438. }
  11439. }
  11440. };
  11441. // DEPRECATED
  11442. // TODO: switch return back to widget declaration at top of file when this is removed
  11443. if ( $.uiBackCompat !== false ) {
  11444. // Backcompat for activeClass and hoverClass options
  11445. $.widget( "ui.droppable", $.ui.droppable, {
  11446. options: {
  11447. hoverClass: false,
  11448. activeClass: false
  11449. },
  11450. _addActiveClass: function() {
  11451. this._super();
  11452. if ( this.options.activeClass ) {
  11453. this.element.addClass( this.options.activeClass );
  11454. }
  11455. },
  11456. _removeActiveClass: function() {
  11457. this._super();
  11458. if ( this.options.activeClass ) {
  11459. this.element.removeClass( this.options.activeClass );
  11460. }
  11461. },
  11462. _addHoverClass: function() {
  11463. this._super();
  11464. if ( this.options.hoverClass ) {
  11465. this.element.addClass( this.options.hoverClass );
  11466. }
  11467. },
  11468. _removeHoverClass: function() {
  11469. this._super();
  11470. if ( this.options.hoverClass ) {
  11471. this.element.removeClass( this.options.hoverClass );
  11472. }
  11473. }
  11474. } );
  11475. }
  11476. var widgetsDroppable = $.ui.droppable;
  11477. /*!
  11478. * jQuery UI Progressbar 1.13.0
  11479. * http://jqueryui.com
  11480. *
  11481. * Copyright jQuery Foundation and other contributors
  11482. * Released under the MIT license.
  11483. * http://jquery.org/license
  11484. */
  11485. //>>label: Progressbar
  11486. //>>group: Widgets
  11487. /* eslint-disable max-len */
  11488. //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
  11489. /* eslint-enable max-len */
  11490. //>>docs: http://api.jqueryui.com/progressbar/
  11491. //>>demos: http://jqueryui.com/progressbar/
  11492. //>>css.structure: ../../themes/base/core.css
  11493. //>>css.structure: ../../themes/base/progressbar.css
  11494. //>>css.theme: ../../themes/base/theme.css
  11495. var widgetsProgressbar = $.widget( "ui.progressbar", {
  11496. version: "1.13.0",
  11497. options: {
  11498. classes: {
  11499. "ui-progressbar": "ui-corner-all",
  11500. "ui-progressbar-value": "ui-corner-left",
  11501. "ui-progressbar-complete": "ui-corner-right"
  11502. },
  11503. max: 100,
  11504. value: 0,
  11505. change: null,
  11506. complete: null
  11507. },
  11508. min: 0,
  11509. _create: function() {
  11510. // Constrain initial value
  11511. this.oldValue = this.options.value = this._constrainedValue();
  11512. this.element.attr( {
  11513. // Only set static values; aria-valuenow and aria-valuemax are
  11514. // set inside _refreshValue()
  11515. role: "progressbar",
  11516. "aria-valuemin": this.min
  11517. } );
  11518. this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
  11519. this.valueDiv = $( "<div>" ).appendTo( this.element );
  11520. this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
  11521. this._refreshValue();
  11522. },
  11523. _destroy: function() {
  11524. this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
  11525. this.valueDiv.remove();
  11526. },
  11527. value: function( newValue ) {
  11528. if ( newValue === undefined ) {
  11529. return this.options.value;
  11530. }
  11531. this.options.value = this._constrainedValue( newValue );
  11532. this._refreshValue();
  11533. },
  11534. _constrainedValue: function( newValue ) {
  11535. if ( newValue === undefined ) {
  11536. newValue = this.options.value;
  11537. }
  11538. this.indeterminate = newValue === false;
  11539. // Sanitize value
  11540. if ( typeof newValue !== "number" ) {
  11541. newValue = 0;
  11542. }
  11543. return this.indeterminate ? false :
  11544. Math.min( this.options.max, Math.max( this.min, newValue ) );
  11545. },
  11546. _setOptions: function( options ) {
  11547. // Ensure "value" option is set after other values (like max)
  11548. var value = options.value;
  11549. delete options.value;
  11550. this._super( options );
  11551. this.options.value = this._constrainedValue( value );
  11552. this._refreshValue();
  11553. },
  11554. _setOption: function( key, value ) {
  11555. if ( key === "max" ) {
  11556. // Don't allow a max less than min
  11557. value = Math.max( this.min, value );
  11558. }
  11559. this._super( key, value );
  11560. },
  11561. _setOptionDisabled: function( value ) {
  11562. this._super( value );
  11563. this.element.attr( "aria-disabled", value );
  11564. this._toggleClass( null, "ui-state-disabled", !!value );
  11565. },
  11566. _percentage: function() {
  11567. return this.indeterminate ?
  11568. 100 :
  11569. 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  11570. },
  11571. _refreshValue: function() {
  11572. var value = this.options.value,
  11573. percentage = this._percentage();
  11574. this.valueDiv
  11575. .toggle( this.indeterminate || value > this.min )
  11576. .width( percentage.toFixed( 0 ) + "%" );
  11577. this
  11578. ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
  11579. value === this.options.max )
  11580. ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
  11581. if ( this.indeterminate ) {
  11582. this.element.removeAttr( "aria-valuenow" );
  11583. if ( !this.overlayDiv ) {
  11584. this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
  11585. this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
  11586. }
  11587. } else {
  11588. this.element.attr( {
  11589. "aria-valuemax": this.options.max,
  11590. "aria-valuenow": value
  11591. } );
  11592. if ( this.overlayDiv ) {
  11593. this.overlayDiv.remove();
  11594. this.overlayDiv = null;
  11595. }
  11596. }
  11597. if ( this.oldValue !== value ) {
  11598. this.oldValue = value;
  11599. this._trigger( "change" );
  11600. }
  11601. if ( value === this.options.max ) {
  11602. this._trigger( "complete" );
  11603. }
  11604. }
  11605. } );
  11606. /*!
  11607. * jQuery UI Selectable 1.13.0
  11608. * http://jqueryui.com
  11609. *
  11610. * Copyright jQuery Foundation and other contributors
  11611. * Released under the MIT license.
  11612. * http://jquery.org/license
  11613. */
  11614. //>>label: Selectable
  11615. //>>group: Interactions
  11616. //>>description: Allows groups of elements to be selected with the mouse.
  11617. //>>docs: http://api.jqueryui.com/selectable/
  11618. //>>demos: http://jqueryui.com/selectable/
  11619. //>>css.structure: ../../themes/base/selectable.css
  11620. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  11621. version: "1.13.0",
  11622. options: {
  11623. appendTo: "body",
  11624. autoRefresh: true,
  11625. distance: 0,
  11626. filter: "*",
  11627. tolerance: "touch",
  11628. // Callbacks
  11629. selected: null,
  11630. selecting: null,
  11631. start: null,
  11632. stop: null,
  11633. unselected: null,
  11634. unselecting: null
  11635. },
  11636. _create: function() {
  11637. var that = this;
  11638. this._addClass( "ui-selectable" );
  11639. this.dragged = false;
  11640. // Cache selectee children based on filter
  11641. this.refresh = function() {
  11642. that.elementPos = $( that.element[ 0 ] ).offset();
  11643. that.selectees = $( that.options.filter, that.element[ 0 ] );
  11644. that._addClass( that.selectees, "ui-selectee" );
  11645. that.selectees.each( function() {
  11646. var $this = $( this ),
  11647. selecteeOffset = $this.offset(),
  11648. pos = {
  11649. left: selecteeOffset.left - that.elementPos.left,
  11650. top: selecteeOffset.top - that.elementPos.top
  11651. };
  11652. $.data( this, "selectable-item", {
  11653. element: this,
  11654. $element: $this,
  11655. left: pos.left,
  11656. top: pos.top,
  11657. right: pos.left + $this.outerWidth(),
  11658. bottom: pos.top + $this.outerHeight(),
  11659. startselected: false,
  11660. selected: $this.hasClass( "ui-selected" ),
  11661. selecting: $this.hasClass( "ui-selecting" ),
  11662. unselecting: $this.hasClass( "ui-unselecting" )
  11663. } );
  11664. } );
  11665. };
  11666. this.refresh();
  11667. this._mouseInit();
  11668. this.helper = $( "<div>" );
  11669. this._addClass( this.helper, "ui-selectable-helper" );
  11670. },
  11671. _destroy: function() {
  11672. this.selectees.removeData( "selectable-item" );
  11673. this._mouseDestroy();
  11674. },
  11675. _mouseStart: function( event ) {
  11676. var that = this,
  11677. options = this.options;
  11678. this.opos = [ event.pageX, event.pageY ];
  11679. this.elementPos = $( this.element[ 0 ] ).offset();
  11680. if ( this.options.disabled ) {
  11681. return;
  11682. }
  11683. this.selectees = $( options.filter, this.element[ 0 ] );
  11684. this._trigger( "start", event );
  11685. $( options.appendTo ).append( this.helper );
  11686. // position helper (lasso)
  11687. this.helper.css( {
  11688. "left": event.pageX,
  11689. "top": event.pageY,
  11690. "width": 0,
  11691. "height": 0
  11692. } );
  11693. if ( options.autoRefresh ) {
  11694. this.refresh();
  11695. }
  11696. this.selectees.filter( ".ui-selected" ).each( function() {
  11697. var selectee = $.data( this, "selectable-item" );
  11698. selectee.startselected = true;
  11699. if ( !event.metaKey && !event.ctrlKey ) {
  11700. that._removeClass( selectee.$element, "ui-selected" );
  11701. selectee.selected = false;
  11702. that._addClass( selectee.$element, "ui-unselecting" );
  11703. selectee.unselecting = true;
  11704. // selectable UNSELECTING callback
  11705. that._trigger( "unselecting", event, {
  11706. unselecting: selectee.element
  11707. } );
  11708. }
  11709. } );
  11710. $( event.target ).parents().addBack().each( function() {
  11711. var doSelect,
  11712. selectee = $.data( this, "selectable-item" );
  11713. if ( selectee ) {
  11714. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  11715. !selectee.$element.hasClass( "ui-selected" );
  11716. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  11717. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  11718. selectee.unselecting = !doSelect;
  11719. selectee.selecting = doSelect;
  11720. selectee.selected = doSelect;
  11721. // selectable (UN)SELECTING callback
  11722. if ( doSelect ) {
  11723. that._trigger( "selecting", event, {
  11724. selecting: selectee.element
  11725. } );
  11726. } else {
  11727. that._trigger( "unselecting", event, {
  11728. unselecting: selectee.element
  11729. } );
  11730. }
  11731. return false;
  11732. }
  11733. } );
  11734. },
  11735. _mouseDrag: function( event ) {
  11736. this.dragged = true;
  11737. if ( this.options.disabled ) {
  11738. return;
  11739. }
  11740. var tmp,
  11741. that = this,
  11742. options = this.options,
  11743. x1 = this.opos[ 0 ],
  11744. y1 = this.opos[ 1 ],
  11745. x2 = event.pageX,
  11746. y2 = event.pageY;
  11747. if ( x1 > x2 ) {
  11748. tmp = x2; x2 = x1; x1 = tmp;
  11749. }
  11750. if ( y1 > y2 ) {
  11751. tmp = y2; y2 = y1; y1 = tmp;
  11752. }
  11753. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  11754. this.selectees.each( function() {
  11755. var selectee = $.data( this, "selectable-item" ),
  11756. hit = false,
  11757. offset = {};
  11758. //prevent helper from being selected if appendTo: selectable
  11759. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  11760. return;
  11761. }
  11762. offset.left = selectee.left + that.elementPos.left;
  11763. offset.right = selectee.right + that.elementPos.left;
  11764. offset.top = selectee.top + that.elementPos.top;
  11765. offset.bottom = selectee.bottom + that.elementPos.top;
  11766. if ( options.tolerance === "touch" ) {
  11767. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  11768. offset.bottom < y1 ) );
  11769. } else if ( options.tolerance === "fit" ) {
  11770. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  11771. offset.bottom < y2 );
  11772. }
  11773. if ( hit ) {
  11774. // SELECT
  11775. if ( selectee.selected ) {
  11776. that._removeClass( selectee.$element, "ui-selected" );
  11777. selectee.selected = false;
  11778. }
  11779. if ( selectee.unselecting ) {
  11780. that._removeClass( selectee.$element, "ui-unselecting" );
  11781. selectee.unselecting = false;
  11782. }
  11783. if ( !selectee.selecting ) {
  11784. that._addClass( selectee.$element, "ui-selecting" );
  11785. selectee.selecting = true;
  11786. // selectable SELECTING callback
  11787. that._trigger( "selecting", event, {
  11788. selecting: selectee.element
  11789. } );
  11790. }
  11791. } else {
  11792. // UNSELECT
  11793. if ( selectee.selecting ) {
  11794. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  11795. that._removeClass( selectee.$element, "ui-selecting" );
  11796. selectee.selecting = false;
  11797. that._addClass( selectee.$element, "ui-selected" );
  11798. selectee.selected = true;
  11799. } else {
  11800. that._removeClass( selectee.$element, "ui-selecting" );
  11801. selectee.selecting = false;
  11802. if ( selectee.startselected ) {
  11803. that._addClass( selectee.$element, "ui-unselecting" );
  11804. selectee.unselecting = true;
  11805. }
  11806. // selectable UNSELECTING callback
  11807. that._trigger( "unselecting", event, {
  11808. unselecting: selectee.element
  11809. } );
  11810. }
  11811. }
  11812. if ( selectee.selected ) {
  11813. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  11814. that._removeClass( selectee.$element, "ui-selected" );
  11815. selectee.selected = false;
  11816. that._addClass( selectee.$element, "ui-unselecting" );
  11817. selectee.unselecting = true;
  11818. // selectable UNSELECTING callback
  11819. that._trigger( "unselecting", event, {
  11820. unselecting: selectee.element
  11821. } );
  11822. }
  11823. }
  11824. }
  11825. } );
  11826. return false;
  11827. },
  11828. _mouseStop: function( event ) {
  11829. var that = this;
  11830. this.dragged = false;
  11831. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  11832. var selectee = $.data( this, "selectable-item" );
  11833. that._removeClass( selectee.$element, "ui-unselecting" );
  11834. selectee.unselecting = false;
  11835. selectee.startselected = false;
  11836. that._trigger( "unselected", event, {
  11837. unselected: selectee.element
  11838. } );
  11839. } );
  11840. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  11841. var selectee = $.data( this, "selectable-item" );
  11842. that._removeClass( selectee.$element, "ui-selecting" )
  11843. ._addClass( selectee.$element, "ui-selected" );
  11844. selectee.selecting = false;
  11845. selectee.selected = true;
  11846. selectee.startselected = true;
  11847. that._trigger( "selected", event, {
  11848. selected: selectee.element
  11849. } );
  11850. } );
  11851. this._trigger( "stop", event );
  11852. this.helper.remove();
  11853. return false;
  11854. }
  11855. } );
  11856. /*!
  11857. * jQuery UI Selectmenu 1.13.0
  11858. * http://jqueryui.com
  11859. *
  11860. * Copyright jQuery Foundation and other contributors
  11861. * Released under the MIT license.
  11862. * http://jquery.org/license
  11863. */
  11864. //>>label: Selectmenu
  11865. //>>group: Widgets
  11866. /* eslint-disable max-len */
  11867. //>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
  11868. /* eslint-enable max-len */
  11869. //>>docs: http://api.jqueryui.com/selectmenu/
  11870. //>>demos: http://jqueryui.com/selectmenu/
  11871. //>>css.structure: ../../themes/base/core.css
  11872. //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
  11873. //>>css.theme: ../../themes/base/theme.css
  11874. var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
  11875. version: "1.13.0",
  11876. defaultElement: "<select>",
  11877. options: {
  11878. appendTo: null,
  11879. classes: {
  11880. "ui-selectmenu-button-open": "ui-corner-top",
  11881. "ui-selectmenu-button-closed": "ui-corner-all"
  11882. },
  11883. disabled: null,
  11884. icons: {
  11885. button: "ui-icon-triangle-1-s"
  11886. },
  11887. position: {
  11888. my: "left top",
  11889. at: "left bottom",
  11890. collision: "none"
  11891. },
  11892. width: false,
  11893. // Callbacks
  11894. change: null,
  11895. close: null,
  11896. focus: null,
  11897. open: null,
  11898. select: null
  11899. },
  11900. _create: function() {
  11901. var selectmenuId = this.element.uniqueId().attr( "id" );
  11902. this.ids = {
  11903. element: selectmenuId,
  11904. button: selectmenuId + "-button",
  11905. menu: selectmenuId + "-menu"
  11906. };
  11907. this._drawButton();
  11908. this._drawMenu();
  11909. this._bindFormResetHandler();
  11910. this._rendered = false;
  11911. this.menuItems = $();
  11912. },
  11913. _drawButton: function() {
  11914. var icon,
  11915. that = this,
  11916. item = this._parseOption(
  11917. this.element.find( "option:selected" ),
  11918. this.element[ 0 ].selectedIndex
  11919. );
  11920. // Associate existing label with the new button
  11921. this.labels = this.element.labels().attr( "for", this.ids.button );
  11922. this._on( this.labels, {
  11923. click: function( event ) {
  11924. this.button.trigger( "focus" );
  11925. event.preventDefault();
  11926. }
  11927. } );
  11928. // Hide original select element
  11929. this.element.hide();
  11930. // Create button
  11931. this.button = $( "<span>", {
  11932. tabindex: this.options.disabled ? -1 : 0,
  11933. id: this.ids.button,
  11934. role: "combobox",
  11935. "aria-expanded": "false",
  11936. "aria-autocomplete": "list",
  11937. "aria-owns": this.ids.menu,
  11938. "aria-haspopup": "true",
  11939. title: this.element.attr( "title" )
  11940. } )
  11941. .insertAfter( this.element );
  11942. this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
  11943. "ui-button ui-widget" );
  11944. icon = $( "<span>" ).appendTo( this.button );
  11945. this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
  11946. this.buttonItem = this._renderButtonItem( item )
  11947. .appendTo( this.button );
  11948. if ( this.options.width !== false ) {
  11949. this._resizeButton();
  11950. }
  11951. this._on( this.button, this._buttonEvents );
  11952. this.button.one( "focusin", function() {
  11953. // Delay rendering the menu items until the button receives focus.
  11954. // The menu may have already been rendered via a programmatic open.
  11955. if ( !that._rendered ) {
  11956. that._refreshMenu();
  11957. }
  11958. } );
  11959. },
  11960. _drawMenu: function() {
  11961. var that = this;
  11962. // Create menu
  11963. this.menu = $( "<ul>", {
  11964. "aria-hidden": "true",
  11965. "aria-labelledby": this.ids.button,
  11966. id: this.ids.menu
  11967. } );
  11968. // Wrap menu
  11969. this.menuWrap = $( "<div>" ).append( this.menu );
  11970. this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
  11971. this.menuWrap.appendTo( this._appendTo() );
  11972. // Initialize menu widget
  11973. this.menuInstance = this.menu
  11974. .menu( {
  11975. classes: {
  11976. "ui-menu": "ui-corner-bottom"
  11977. },
  11978. role: "listbox",
  11979. select: function( event, ui ) {
  11980. event.preventDefault();
  11981. // Support: IE8
  11982. // If the item was selected via a click, the text selection
  11983. // will be destroyed in IE
  11984. that._setSelection();
  11985. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  11986. },
  11987. focus: function( event, ui ) {
  11988. var item = ui.item.data( "ui-selectmenu-item" );
  11989. // Prevent inital focus from firing and check if its a newly focused item
  11990. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  11991. that._trigger( "focus", event, { item: item } );
  11992. if ( !that.isOpen ) {
  11993. that._select( item, event );
  11994. }
  11995. }
  11996. that.focusIndex = item.index;
  11997. that.button.attr( "aria-activedescendant",
  11998. that.menuItems.eq( item.index ).attr( "id" ) );
  11999. }
  12000. } )
  12001. .menu( "instance" );
  12002. // Don't close the menu on mouseleave
  12003. this.menuInstance._off( this.menu, "mouseleave" );
  12004. // Cancel the menu's collapseAll on document click
  12005. this.menuInstance._closeOnDocumentClick = function() {
  12006. return false;
  12007. };
  12008. // Selects often contain empty items, but never contain dividers
  12009. this.menuInstance._isDivider = function() {
  12010. return false;
  12011. };
  12012. },
  12013. refresh: function() {
  12014. this._refreshMenu();
  12015. this.buttonItem.replaceWith(
  12016. this.buttonItem = this._renderButtonItem(
  12017. // Fall back to an empty object in case there are no options
  12018. this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
  12019. )
  12020. );
  12021. if ( this.options.width === null ) {
  12022. this._resizeButton();
  12023. }
  12024. },
  12025. _refreshMenu: function() {
  12026. var item,
  12027. options = this.element.find( "option" );
  12028. this.menu.empty();
  12029. this._parseOptions( options );
  12030. this._renderMenu( this.menu, this.items );
  12031. this.menuInstance.refresh();
  12032. this.menuItems = this.menu.find( "li" )
  12033. .not( ".ui-selectmenu-optgroup" )
  12034. .find( ".ui-menu-item-wrapper" );
  12035. this._rendered = true;
  12036. if ( !options.length ) {
  12037. return;
  12038. }
  12039. item = this._getSelectedItem();
  12040. // Update the menu to have the correct item focused
  12041. this.menuInstance.focus( null, item );
  12042. this._setAria( item.data( "ui-selectmenu-item" ) );
  12043. // Set disabled state
  12044. this._setOption( "disabled", this.element.prop( "disabled" ) );
  12045. },
  12046. open: function( event ) {
  12047. if ( this.options.disabled ) {
  12048. return;
  12049. }
  12050. // If this is the first time the menu is being opened, render the items
  12051. if ( !this._rendered ) {
  12052. this._refreshMenu();
  12053. } else {
  12054. // Menu clears focus on close, reset focus to selected item
  12055. this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
  12056. this.menuInstance.focus( null, this._getSelectedItem() );
  12057. }
  12058. // If there are no options, don't open the menu
  12059. if ( !this.menuItems.length ) {
  12060. return;
  12061. }
  12062. this.isOpen = true;
  12063. this._toggleAttr();
  12064. this._resizeMenu();
  12065. this._position();
  12066. this._on( this.document, this._documentClick );
  12067. this._trigger( "open", event );
  12068. },
  12069. _position: function() {
  12070. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  12071. },
  12072. close: function( event ) {
  12073. if ( !this.isOpen ) {
  12074. return;
  12075. }
  12076. this.isOpen = false;
  12077. this._toggleAttr();
  12078. this.range = null;
  12079. this._off( this.document );
  12080. this._trigger( "close", event );
  12081. },
  12082. widget: function() {
  12083. return this.button;
  12084. },
  12085. menuWidget: function() {
  12086. return this.menu;
  12087. },
  12088. _renderButtonItem: function( item ) {
  12089. var buttonItem = $( "<span>" );
  12090. this._setText( buttonItem, item.label );
  12091. this._addClass( buttonItem, "ui-selectmenu-text" );
  12092. return buttonItem;
  12093. },
  12094. _renderMenu: function( ul, items ) {
  12095. var that = this,
  12096. currentOptgroup = "";
  12097. $.each( items, function( index, item ) {
  12098. var li;
  12099. if ( item.optgroup !== currentOptgroup ) {
  12100. li = $( "<li>", {
  12101. text: item.optgroup
  12102. } );
  12103. that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
  12104. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  12105. " ui-state-disabled" :
  12106. "" ) );
  12107. li.appendTo( ul );
  12108. currentOptgroup = item.optgroup;
  12109. }
  12110. that._renderItemData( ul, item );
  12111. } );
  12112. },
  12113. _renderItemData: function( ul, item ) {
  12114. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  12115. },
  12116. _renderItem: function( ul, item ) {
  12117. var li = $( "<li>" ),
  12118. wrapper = $( "<div>", {
  12119. title: item.element.attr( "title" )
  12120. } );
  12121. if ( item.disabled ) {
  12122. this._addClass( li, null, "ui-state-disabled" );
  12123. }
  12124. this._setText( wrapper, item.label );
  12125. return li.append( wrapper ).appendTo( ul );
  12126. },
  12127. _setText: function( element, value ) {
  12128. if ( value ) {
  12129. element.text( value );
  12130. } else {
  12131. element.html( "&#160;" );
  12132. }
  12133. },
  12134. _move: function( direction, event ) {
  12135. var item, next,
  12136. filter = ".ui-menu-item";
  12137. if ( this.isOpen ) {
  12138. item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  12139. } else {
  12140. item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  12141. filter += ":not(.ui-state-disabled)";
  12142. }
  12143. if ( direction === "first" || direction === "last" ) {
  12144. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  12145. } else {
  12146. next = item[ direction + "All" ]( filter ).eq( 0 );
  12147. }
  12148. if ( next.length ) {
  12149. this.menuInstance.focus( event, next );
  12150. }
  12151. },
  12152. _getSelectedItem: function() {
  12153. return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  12154. },
  12155. _toggle: function( event ) {
  12156. this[ this.isOpen ? "close" : "open" ]( event );
  12157. },
  12158. _setSelection: function() {
  12159. var selection;
  12160. if ( !this.range ) {
  12161. return;
  12162. }
  12163. if ( window.getSelection ) {
  12164. selection = window.getSelection();
  12165. selection.removeAllRanges();
  12166. selection.addRange( this.range );
  12167. // Support: IE8
  12168. } else {
  12169. this.range.select();
  12170. }
  12171. // Support: IE
  12172. // Setting the text selection kills the button focus in IE, but
  12173. // restoring the focus doesn't kill the selection.
  12174. this.button.focus();
  12175. },
  12176. _documentClick: {
  12177. mousedown: function( event ) {
  12178. if ( !this.isOpen ) {
  12179. return;
  12180. }
  12181. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
  12182. $.escapeSelector( this.ids.button ) ).length ) {
  12183. this.close( event );
  12184. }
  12185. }
  12186. },
  12187. _buttonEvents: {
  12188. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  12189. mousedown: function() {
  12190. var selection;
  12191. if ( window.getSelection ) {
  12192. selection = window.getSelection();
  12193. if ( selection.rangeCount ) {
  12194. this.range = selection.getRangeAt( 0 );
  12195. }
  12196. // Support: IE8
  12197. } else {
  12198. this.range = document.selection.createRange();
  12199. }
  12200. },
  12201. click: function( event ) {
  12202. this._setSelection();
  12203. this._toggle( event );
  12204. },
  12205. keydown: function( event ) {
  12206. var preventDefault = true;
  12207. switch ( event.keyCode ) {
  12208. case $.ui.keyCode.TAB:
  12209. case $.ui.keyCode.ESCAPE:
  12210. this.close( event );
  12211. preventDefault = false;
  12212. break;
  12213. case $.ui.keyCode.ENTER:
  12214. if ( this.isOpen ) {
  12215. this._selectFocusedItem( event );
  12216. }
  12217. break;
  12218. case $.ui.keyCode.UP:
  12219. if ( event.altKey ) {
  12220. this._toggle( event );
  12221. } else {
  12222. this._move( "prev", event );
  12223. }
  12224. break;
  12225. case $.ui.keyCode.DOWN:
  12226. if ( event.altKey ) {
  12227. this._toggle( event );
  12228. } else {
  12229. this._move( "next", event );
  12230. }
  12231. break;
  12232. case $.ui.keyCode.SPACE:
  12233. if ( this.isOpen ) {
  12234. this._selectFocusedItem( event );
  12235. } else {
  12236. this._toggle( event );
  12237. }
  12238. break;
  12239. case $.ui.keyCode.LEFT:
  12240. this._move( "prev", event );
  12241. break;
  12242. case $.ui.keyCode.RIGHT:
  12243. this._move( "next", event );
  12244. break;
  12245. case $.ui.keyCode.HOME:
  12246. case $.ui.keyCode.PAGE_UP:
  12247. this._move( "first", event );
  12248. break;
  12249. case $.ui.keyCode.END:
  12250. case $.ui.keyCode.PAGE_DOWN:
  12251. this._move( "last", event );
  12252. break;
  12253. default:
  12254. this.menu.trigger( event );
  12255. preventDefault = false;
  12256. }
  12257. if ( preventDefault ) {
  12258. event.preventDefault();
  12259. }
  12260. }
  12261. },
  12262. _selectFocusedItem: function( event ) {
  12263. var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  12264. if ( !item.hasClass( "ui-state-disabled" ) ) {
  12265. this._select( item.data( "ui-selectmenu-item" ), event );
  12266. }
  12267. },
  12268. _select: function( item, event ) {
  12269. var oldIndex = this.element[ 0 ].selectedIndex;
  12270. // Change native select element
  12271. this.element[ 0 ].selectedIndex = item.index;
  12272. this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
  12273. this._setAria( item );
  12274. this._trigger( "select", event, { item: item } );
  12275. if ( item.index !== oldIndex ) {
  12276. this._trigger( "change", event, { item: item } );
  12277. }
  12278. this.close( event );
  12279. },
  12280. _setAria: function( item ) {
  12281. var id = this.menuItems.eq( item.index ).attr( "id" );
  12282. this.button.attr( {
  12283. "aria-labelledby": id,
  12284. "aria-activedescendant": id
  12285. } );
  12286. this.menu.attr( "aria-activedescendant", id );
  12287. },
  12288. _setOption: function( key, value ) {
  12289. if ( key === "icons" ) {
  12290. var icon = this.button.find( "span.ui-icon" );
  12291. this._removeClass( icon, null, this.options.icons.button )
  12292. ._addClass( icon, null, value.button );
  12293. }
  12294. this._super( key, value );
  12295. if ( key === "appendTo" ) {
  12296. this.menuWrap.appendTo( this._appendTo() );
  12297. }
  12298. if ( key === "width" ) {
  12299. this._resizeButton();
  12300. }
  12301. },
  12302. _setOptionDisabled: function( value ) {
  12303. this._super( value );
  12304. this.menuInstance.option( "disabled", value );
  12305. this.button.attr( "aria-disabled", value );
  12306. this._toggleClass( this.button, null, "ui-state-disabled", value );
  12307. this.element.prop( "disabled", value );
  12308. if ( value ) {
  12309. this.button.attr( "tabindex", -1 );
  12310. this.close();
  12311. } else {
  12312. this.button.attr( "tabindex", 0 );
  12313. }
  12314. },
  12315. _appendTo: function() {
  12316. var element = this.options.appendTo;
  12317. if ( element ) {
  12318. element = element.jquery || element.nodeType ?
  12319. $( element ) :
  12320. this.document.find( element ).eq( 0 );
  12321. }
  12322. if ( !element || !element[ 0 ] ) {
  12323. element = this.element.closest( ".ui-front, dialog" );
  12324. }
  12325. if ( !element.length ) {
  12326. element = this.document[ 0 ].body;
  12327. }
  12328. return element;
  12329. },
  12330. _toggleAttr: function() {
  12331. this.button.attr( "aria-expanded", this.isOpen );
  12332. // We can't use two _toggleClass() calls here, because we need to make sure
  12333. // we always remove classes first and add them second, otherwise if both classes have the
  12334. // same theme class, it will be removed after we add it.
  12335. this._removeClass( this.button, "ui-selectmenu-button-" +
  12336. ( this.isOpen ? "closed" : "open" ) )
  12337. ._addClass( this.button, "ui-selectmenu-button-" +
  12338. ( this.isOpen ? "open" : "closed" ) )
  12339. ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
  12340. this.menu.attr( "aria-hidden", !this.isOpen );
  12341. },
  12342. _resizeButton: function() {
  12343. var width = this.options.width;
  12344. // For `width: false`, just remove inline style and stop
  12345. if ( width === false ) {
  12346. this.button.css( "width", "" );
  12347. return;
  12348. }
  12349. // For `width: null`, match the width of the original element
  12350. if ( width === null ) {
  12351. width = this.element.show().outerWidth();
  12352. this.element.hide();
  12353. }
  12354. this.button.outerWidth( width );
  12355. },
  12356. _resizeMenu: function() {
  12357. this.menu.outerWidth( Math.max(
  12358. this.button.outerWidth(),
  12359. // Support: IE10
  12360. // IE10 wraps long text (possibly a rounding bug)
  12361. // so we add 1px to avoid the wrapping
  12362. this.menu.width( "" ).outerWidth() + 1
  12363. ) );
  12364. },
  12365. _getCreateOptions: function() {
  12366. var options = this._super();
  12367. options.disabled = this.element.prop( "disabled" );
  12368. return options;
  12369. },
  12370. _parseOptions: function( options ) {
  12371. var that = this,
  12372. data = [];
  12373. options.each( function( index, item ) {
  12374. if ( item.hidden ) {
  12375. return;
  12376. }
  12377. data.push( that._parseOption( $( item ), index ) );
  12378. } );
  12379. this.items = data;
  12380. },
  12381. _parseOption: function( option, index ) {
  12382. var optgroup = option.parent( "optgroup" );
  12383. return {
  12384. element: option,
  12385. index: index,
  12386. value: option.val(),
  12387. label: option.text(),
  12388. optgroup: optgroup.attr( "label" ) || "",
  12389. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  12390. };
  12391. },
  12392. _destroy: function() {
  12393. this._unbindFormResetHandler();
  12394. this.menuWrap.remove();
  12395. this.button.remove();
  12396. this.element.show();
  12397. this.element.removeUniqueId();
  12398. this.labels.attr( "for", this.ids.element );
  12399. }
  12400. } ] );
  12401. /*!
  12402. * jQuery UI Slider 1.13.0
  12403. * http://jqueryui.com
  12404. *
  12405. * Copyright jQuery Foundation and other contributors
  12406. * Released under the MIT license.
  12407. * http://jquery.org/license
  12408. */
  12409. //>>label: Slider
  12410. //>>group: Widgets
  12411. //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
  12412. //>>docs: http://api.jqueryui.com/slider/
  12413. //>>demos: http://jqueryui.com/slider/
  12414. //>>css.structure: ../../themes/base/core.css
  12415. //>>css.structure: ../../themes/base/slider.css
  12416. //>>css.theme: ../../themes/base/theme.css
  12417. var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
  12418. version: "1.13.0",
  12419. widgetEventPrefix: "slide",
  12420. options: {
  12421. animate: false,
  12422. classes: {
  12423. "ui-slider": "ui-corner-all",
  12424. "ui-slider-handle": "ui-corner-all",
  12425. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  12426. // element, but worked best visually with a variety of themes
  12427. "ui-slider-range": "ui-corner-all ui-widget-header"
  12428. },
  12429. distance: 0,
  12430. max: 100,
  12431. min: 0,
  12432. orientation: "horizontal",
  12433. range: false,
  12434. step: 1,
  12435. value: 0,
  12436. values: null,
  12437. // Callbacks
  12438. change: null,
  12439. slide: null,
  12440. start: null,
  12441. stop: null
  12442. },
  12443. // Number of pages in a slider
  12444. // (how many times can you page up/down to go through the whole range)
  12445. numPages: 5,
  12446. _create: function() {
  12447. this._keySliding = false;
  12448. this._mouseSliding = false;
  12449. this._animateOff = true;
  12450. this._handleIndex = null;
  12451. this._detectOrientation();
  12452. this._mouseInit();
  12453. this._calculateNewMax();
  12454. this._addClass( "ui-slider ui-slider-" + this.orientation,
  12455. "ui-widget ui-widget-content" );
  12456. this._refresh();
  12457. this._animateOff = false;
  12458. },
  12459. _refresh: function() {
  12460. this._createRange();
  12461. this._createHandles();
  12462. this._setupEvents();
  12463. this._refreshValue();
  12464. },
  12465. _createHandles: function() {
  12466. var i, handleCount,
  12467. options = this.options,
  12468. existingHandles = this.element.find( ".ui-slider-handle" ),
  12469. handle = "<span tabindex='0'></span>",
  12470. handles = [];
  12471. handleCount = ( options.values && options.values.length ) || 1;
  12472. if ( existingHandles.length > handleCount ) {
  12473. existingHandles.slice( handleCount ).remove();
  12474. existingHandles = existingHandles.slice( 0, handleCount );
  12475. }
  12476. for ( i = existingHandles.length; i < handleCount; i++ ) {
  12477. handles.push( handle );
  12478. }
  12479. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  12480. this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
  12481. this.handle = this.handles.eq( 0 );
  12482. this.handles.each( function( i ) {
  12483. $( this )
  12484. .data( "ui-slider-handle-index", i )
  12485. .attr( "tabIndex", 0 );
  12486. } );
  12487. },
  12488. _createRange: function() {
  12489. var options = this.options;
  12490. if ( options.range ) {
  12491. if ( options.range === true ) {
  12492. if ( !options.values ) {
  12493. options.values = [ this._valueMin(), this._valueMin() ];
  12494. } else if ( options.values.length && options.values.length !== 2 ) {
  12495. options.values = [ options.values[ 0 ], options.values[ 0 ] ];
  12496. } else if ( Array.isArray( options.values ) ) {
  12497. options.values = options.values.slice( 0 );
  12498. }
  12499. }
  12500. if ( !this.range || !this.range.length ) {
  12501. this.range = $( "<div>" )
  12502. .appendTo( this.element );
  12503. this._addClass( this.range, "ui-slider-range" );
  12504. } else {
  12505. this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
  12506. // Handle range switching from true to min/max
  12507. this.range.css( {
  12508. "left": "",
  12509. "bottom": ""
  12510. } );
  12511. }
  12512. if ( options.range === "min" || options.range === "max" ) {
  12513. this._addClass( this.range, "ui-slider-range-" + options.range );
  12514. }
  12515. } else {
  12516. if ( this.range ) {
  12517. this.range.remove();
  12518. }
  12519. this.range = null;
  12520. }
  12521. },
  12522. _setupEvents: function() {
  12523. this._off( this.handles );
  12524. this._on( this.handles, this._handleEvents );
  12525. this._hoverable( this.handles );
  12526. this._focusable( this.handles );
  12527. },
  12528. _destroy: function() {
  12529. this.handles.remove();
  12530. if ( this.range ) {
  12531. this.range.remove();
  12532. }
  12533. this._mouseDestroy();
  12534. },
  12535. _mouseCapture: function( event ) {
  12536. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  12537. that = this,
  12538. o = this.options;
  12539. if ( o.disabled ) {
  12540. return false;
  12541. }
  12542. this.elementSize = {
  12543. width: this.element.outerWidth(),
  12544. height: this.element.outerHeight()
  12545. };
  12546. this.elementOffset = this.element.offset();
  12547. position = { x: event.pageX, y: event.pageY };
  12548. normValue = this._normValueFromMouse( position );
  12549. distance = this._valueMax() - this._valueMin() + 1;
  12550. this.handles.each( function( i ) {
  12551. var thisDistance = Math.abs( normValue - that.values( i ) );
  12552. if ( ( distance > thisDistance ) ||
  12553. ( distance === thisDistance &&
  12554. ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
  12555. distance = thisDistance;
  12556. closestHandle = $( this );
  12557. index = i;
  12558. }
  12559. } );
  12560. allowed = this._start( event, index );
  12561. if ( allowed === false ) {
  12562. return false;
  12563. }
  12564. this._mouseSliding = true;
  12565. this._handleIndex = index;
  12566. this._addClass( closestHandle, null, "ui-state-active" );
  12567. closestHandle.trigger( "focus" );
  12568. offset = closestHandle.offset();
  12569. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  12570. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  12571. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  12572. top: event.pageY - offset.top -
  12573. ( closestHandle.height() / 2 ) -
  12574. ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
  12575. ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
  12576. ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
  12577. };
  12578. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  12579. this._slide( event, index, normValue );
  12580. }
  12581. this._animateOff = true;
  12582. return true;
  12583. },
  12584. _mouseStart: function() {
  12585. return true;
  12586. },
  12587. _mouseDrag: function( event ) {
  12588. var position = { x: event.pageX, y: event.pageY },
  12589. normValue = this._normValueFromMouse( position );
  12590. this._slide( event, this._handleIndex, normValue );
  12591. return false;
  12592. },
  12593. _mouseStop: function( event ) {
  12594. this._removeClass( this.handles, null, "ui-state-active" );
  12595. this._mouseSliding = false;
  12596. this._stop( event, this._handleIndex );
  12597. this._change( event, this._handleIndex );
  12598. this._handleIndex = null;
  12599. this._clickOffset = null;
  12600. this._animateOff = false;
  12601. return false;
  12602. },
  12603. _detectOrientation: function() {
  12604. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  12605. },
  12606. _normValueFromMouse: function( position ) {
  12607. var pixelTotal,
  12608. pixelMouse,
  12609. percentMouse,
  12610. valueTotal,
  12611. valueMouse;
  12612. if ( this.orientation === "horizontal" ) {
  12613. pixelTotal = this.elementSize.width;
  12614. pixelMouse = position.x - this.elementOffset.left -
  12615. ( this._clickOffset ? this._clickOffset.left : 0 );
  12616. } else {
  12617. pixelTotal = this.elementSize.height;
  12618. pixelMouse = position.y - this.elementOffset.top -
  12619. ( this._clickOffset ? this._clickOffset.top : 0 );
  12620. }
  12621. percentMouse = ( pixelMouse / pixelTotal );
  12622. if ( percentMouse > 1 ) {
  12623. percentMouse = 1;
  12624. }
  12625. if ( percentMouse < 0 ) {
  12626. percentMouse = 0;
  12627. }
  12628. if ( this.orientation === "vertical" ) {
  12629. percentMouse = 1 - percentMouse;
  12630. }
  12631. valueTotal = this._valueMax() - this._valueMin();
  12632. valueMouse = this._valueMin() + percentMouse * valueTotal;
  12633. return this._trimAlignValue( valueMouse );
  12634. },
  12635. _uiHash: function( index, value, values ) {
  12636. var uiHash = {
  12637. handle: this.handles[ index ],
  12638. handleIndex: index,
  12639. value: value !== undefined ? value : this.value()
  12640. };
  12641. if ( this._hasMultipleValues() ) {
  12642. uiHash.value = value !== undefined ? value : this.values( index );
  12643. uiHash.values = values || this.values();
  12644. }
  12645. return uiHash;
  12646. },
  12647. _hasMultipleValues: function() {
  12648. return this.options.values && this.options.values.length;
  12649. },
  12650. _start: function( event, index ) {
  12651. return this._trigger( "start", event, this._uiHash( index ) );
  12652. },
  12653. _slide: function( event, index, newVal ) {
  12654. var allowed, otherVal,
  12655. currentValue = this.value(),
  12656. newValues = this.values();
  12657. if ( this._hasMultipleValues() ) {
  12658. otherVal = this.values( index ? 0 : 1 );
  12659. currentValue = this.values( index );
  12660. if ( this.options.values.length === 2 && this.options.range === true ) {
  12661. newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
  12662. }
  12663. newValues[ index ] = newVal;
  12664. }
  12665. if ( newVal === currentValue ) {
  12666. return;
  12667. }
  12668. allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
  12669. // A slide can be canceled by returning false from the slide callback
  12670. if ( allowed === false ) {
  12671. return;
  12672. }
  12673. if ( this._hasMultipleValues() ) {
  12674. this.values( index, newVal );
  12675. } else {
  12676. this.value( newVal );
  12677. }
  12678. },
  12679. _stop: function( event, index ) {
  12680. this._trigger( "stop", event, this._uiHash( index ) );
  12681. },
  12682. _change: function( event, index ) {
  12683. if ( !this._keySliding && !this._mouseSliding ) {
  12684. //store the last changed value index for reference when handles overlap
  12685. this._lastChangedValue = index;
  12686. this._trigger( "change", event, this._uiHash( index ) );
  12687. }
  12688. },
  12689. value: function( newValue ) {
  12690. if ( arguments.length ) {
  12691. this.options.value = this._trimAlignValue( newValue );
  12692. this._refreshValue();
  12693. this._change( null, 0 );
  12694. return;
  12695. }
  12696. return this._value();
  12697. },
  12698. values: function( index, newValue ) {
  12699. var vals,
  12700. newValues,
  12701. i;
  12702. if ( arguments.length > 1 ) {
  12703. this.options.values[ index ] = this._trimAlignValue( newValue );
  12704. this._refreshValue();
  12705. this._change( null, index );
  12706. return;
  12707. }
  12708. if ( arguments.length ) {
  12709. if ( Array.isArray( arguments[ 0 ] ) ) {
  12710. vals = this.options.values;
  12711. newValues = arguments[ 0 ];
  12712. for ( i = 0; i < vals.length; i += 1 ) {
  12713. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  12714. this._change( null, i );
  12715. }
  12716. this._refreshValue();
  12717. } else {
  12718. if ( this._hasMultipleValues() ) {
  12719. return this._values( index );
  12720. } else {
  12721. return this.value();
  12722. }
  12723. }
  12724. } else {
  12725. return this._values();
  12726. }
  12727. },
  12728. _setOption: function( key, value ) {
  12729. var i,
  12730. valsLength = 0;
  12731. if ( key === "range" && this.options.range === true ) {
  12732. if ( value === "min" ) {
  12733. this.options.value = this._values( 0 );
  12734. this.options.values = null;
  12735. } else if ( value === "max" ) {
  12736. this.options.value = this._values( this.options.values.length - 1 );
  12737. this.options.values = null;
  12738. }
  12739. }
  12740. if ( Array.isArray( this.options.values ) ) {
  12741. valsLength = this.options.values.length;
  12742. }
  12743. this._super( key, value );
  12744. switch ( key ) {
  12745. case "orientation":
  12746. this._detectOrientation();
  12747. this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
  12748. ._addClass( "ui-slider-" + this.orientation );
  12749. this._refreshValue();
  12750. if ( this.options.range ) {
  12751. this._refreshRange( value );
  12752. }
  12753. // Reset positioning from previous orientation
  12754. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  12755. break;
  12756. case "value":
  12757. this._animateOff = true;
  12758. this._refreshValue();
  12759. this._change( null, 0 );
  12760. this._animateOff = false;
  12761. break;
  12762. case "values":
  12763. this._animateOff = true;
  12764. this._refreshValue();
  12765. // Start from the last handle to prevent unreachable handles (#9046)
  12766. for ( i = valsLength - 1; i >= 0; i-- ) {
  12767. this._change( null, i );
  12768. }
  12769. this._animateOff = false;
  12770. break;
  12771. case "step":
  12772. case "min":
  12773. case "max":
  12774. this._animateOff = true;
  12775. this._calculateNewMax();
  12776. this._refreshValue();
  12777. this._animateOff = false;
  12778. break;
  12779. case "range":
  12780. this._animateOff = true;
  12781. this._refresh();
  12782. this._animateOff = false;
  12783. break;
  12784. }
  12785. },
  12786. _setOptionDisabled: function( value ) {
  12787. this._super( value );
  12788. this._toggleClass( null, "ui-state-disabled", !!value );
  12789. },
  12790. //internal value getter
  12791. // _value() returns value trimmed by min and max, aligned by step
  12792. _value: function() {
  12793. var val = this.options.value;
  12794. val = this._trimAlignValue( val );
  12795. return val;
  12796. },
  12797. //internal values getter
  12798. // _values() returns array of values trimmed by min and max, aligned by step
  12799. // _values( index ) returns single value trimmed by min and max, aligned by step
  12800. _values: function( index ) {
  12801. var val,
  12802. vals,
  12803. i;
  12804. if ( arguments.length ) {
  12805. val = this.options.values[ index ];
  12806. val = this._trimAlignValue( val );
  12807. return val;
  12808. } else if ( this._hasMultipleValues() ) {
  12809. // .slice() creates a copy of the array
  12810. // this copy gets trimmed by min and max and then returned
  12811. vals = this.options.values.slice();
  12812. for ( i = 0; i < vals.length; i += 1 ) {
  12813. vals[ i ] = this._trimAlignValue( vals[ i ] );
  12814. }
  12815. return vals;
  12816. } else {
  12817. return [];
  12818. }
  12819. },
  12820. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  12821. _trimAlignValue: function( val ) {
  12822. if ( val <= this._valueMin() ) {
  12823. return this._valueMin();
  12824. }
  12825. if ( val >= this._valueMax() ) {
  12826. return this._valueMax();
  12827. }
  12828. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  12829. valModStep = ( val - this._valueMin() ) % step,
  12830. alignValue = val - valModStep;
  12831. if ( Math.abs( valModStep ) * 2 >= step ) {
  12832. alignValue += ( valModStep > 0 ) ? step : ( -step );
  12833. }
  12834. // Since JavaScript has problems with large floats, round
  12835. // the final value to 5 digits after the decimal point (see #4124)
  12836. return parseFloat( alignValue.toFixed( 5 ) );
  12837. },
  12838. _calculateNewMax: function() {
  12839. var max = this.options.max,
  12840. min = this._valueMin(),
  12841. step = this.options.step,
  12842. aboveMin = Math.round( ( max - min ) / step ) * step;
  12843. max = aboveMin + min;
  12844. if ( max > this.options.max ) {
  12845. //If max is not divisible by step, rounding off may increase its value
  12846. max -= step;
  12847. }
  12848. this.max = parseFloat( max.toFixed( this._precision() ) );
  12849. },
  12850. _precision: function() {
  12851. var precision = this._precisionOf( this.options.step );
  12852. if ( this.options.min !== null ) {
  12853. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12854. }
  12855. return precision;
  12856. },
  12857. _precisionOf: function( num ) {
  12858. var str = num.toString(),
  12859. decimal = str.indexOf( "." );
  12860. return decimal === -1 ? 0 : str.length - decimal - 1;
  12861. },
  12862. _valueMin: function() {
  12863. return this.options.min;
  12864. },
  12865. _valueMax: function() {
  12866. return this.max;
  12867. },
  12868. _refreshRange: function( orientation ) {
  12869. if ( orientation === "vertical" ) {
  12870. this.range.css( { "width": "", "left": "" } );
  12871. }
  12872. if ( orientation === "horizontal" ) {
  12873. this.range.css( { "height": "", "bottom": "" } );
  12874. }
  12875. },
  12876. _refreshValue: function() {
  12877. var lastValPercent, valPercent, value, valueMin, valueMax,
  12878. oRange = this.options.range,
  12879. o = this.options,
  12880. that = this,
  12881. animate = ( !this._animateOff ) ? o.animate : false,
  12882. _set = {};
  12883. if ( this._hasMultipleValues() ) {
  12884. this.handles.each( function( i ) {
  12885. valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
  12886. that._valueMin() ) * 100;
  12887. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12888. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12889. if ( that.options.range === true ) {
  12890. if ( that.orientation === "horizontal" ) {
  12891. if ( i === 0 ) {
  12892. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12893. left: valPercent + "%"
  12894. }, o.animate );
  12895. }
  12896. if ( i === 1 ) {
  12897. that.range[ animate ? "animate" : "css" ]( {
  12898. width: ( valPercent - lastValPercent ) + "%"
  12899. }, {
  12900. queue: false,
  12901. duration: o.animate
  12902. } );
  12903. }
  12904. } else {
  12905. if ( i === 0 ) {
  12906. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12907. bottom: ( valPercent ) + "%"
  12908. }, o.animate );
  12909. }
  12910. if ( i === 1 ) {
  12911. that.range[ animate ? "animate" : "css" ]( {
  12912. height: ( valPercent - lastValPercent ) + "%"
  12913. }, {
  12914. queue: false,
  12915. duration: o.animate
  12916. } );
  12917. }
  12918. }
  12919. }
  12920. lastValPercent = valPercent;
  12921. } );
  12922. } else {
  12923. value = this.value();
  12924. valueMin = this._valueMin();
  12925. valueMax = this._valueMax();
  12926. valPercent = ( valueMax !== valueMin ) ?
  12927. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  12928. 0;
  12929. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12930. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12931. if ( oRange === "min" && this.orientation === "horizontal" ) {
  12932. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12933. width: valPercent + "%"
  12934. }, o.animate );
  12935. }
  12936. if ( oRange === "max" && this.orientation === "horizontal" ) {
  12937. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12938. width: ( 100 - valPercent ) + "%"
  12939. }, o.animate );
  12940. }
  12941. if ( oRange === "min" && this.orientation === "vertical" ) {
  12942. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12943. height: valPercent + "%"
  12944. }, o.animate );
  12945. }
  12946. if ( oRange === "max" && this.orientation === "vertical" ) {
  12947. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12948. height: ( 100 - valPercent ) + "%"
  12949. }, o.animate );
  12950. }
  12951. }
  12952. },
  12953. _handleEvents: {
  12954. keydown: function( event ) {
  12955. var allowed, curVal, newVal, step,
  12956. index = $( event.target ).data( "ui-slider-handle-index" );
  12957. switch ( event.keyCode ) {
  12958. case $.ui.keyCode.HOME:
  12959. case $.ui.keyCode.END:
  12960. case $.ui.keyCode.PAGE_UP:
  12961. case $.ui.keyCode.PAGE_DOWN:
  12962. case $.ui.keyCode.UP:
  12963. case $.ui.keyCode.RIGHT:
  12964. case $.ui.keyCode.DOWN:
  12965. case $.ui.keyCode.LEFT:
  12966. event.preventDefault();
  12967. if ( !this._keySliding ) {
  12968. this._keySliding = true;
  12969. this._addClass( $( event.target ), null, "ui-state-active" );
  12970. allowed = this._start( event, index );
  12971. if ( allowed === false ) {
  12972. return;
  12973. }
  12974. }
  12975. break;
  12976. }
  12977. step = this.options.step;
  12978. if ( this._hasMultipleValues() ) {
  12979. curVal = newVal = this.values( index );
  12980. } else {
  12981. curVal = newVal = this.value();
  12982. }
  12983. switch ( event.keyCode ) {
  12984. case $.ui.keyCode.HOME:
  12985. newVal = this._valueMin();
  12986. break;
  12987. case $.ui.keyCode.END:
  12988. newVal = this._valueMax();
  12989. break;
  12990. case $.ui.keyCode.PAGE_UP:
  12991. newVal = this._trimAlignValue(
  12992. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  12993. );
  12994. break;
  12995. case $.ui.keyCode.PAGE_DOWN:
  12996. newVal = this._trimAlignValue(
  12997. curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
  12998. break;
  12999. case $.ui.keyCode.UP:
  13000. case $.ui.keyCode.RIGHT:
  13001. if ( curVal === this._valueMax() ) {
  13002. return;
  13003. }
  13004. newVal = this._trimAlignValue( curVal + step );
  13005. break;
  13006. case $.ui.keyCode.DOWN:
  13007. case $.ui.keyCode.LEFT:
  13008. if ( curVal === this._valueMin() ) {
  13009. return;
  13010. }
  13011. newVal = this._trimAlignValue( curVal - step );
  13012. break;
  13013. }
  13014. this._slide( event, index, newVal );
  13015. },
  13016. keyup: function( event ) {
  13017. var index = $( event.target ).data( "ui-slider-handle-index" );
  13018. if ( this._keySliding ) {
  13019. this._keySliding = false;
  13020. this._stop( event, index );
  13021. this._change( event, index );
  13022. this._removeClass( $( event.target ), null, "ui-state-active" );
  13023. }
  13024. }
  13025. }
  13026. } );
  13027. /*!
  13028. * jQuery UI Sortable 1.13.0
  13029. * http://jqueryui.com
  13030. *
  13031. * Copyright jQuery Foundation and other contributors
  13032. * Released under the MIT license.
  13033. * http://jquery.org/license
  13034. */
  13035. //>>label: Sortable
  13036. //>>group: Interactions
  13037. //>>description: Enables items in a list to be sorted using the mouse.
  13038. //>>docs: http://api.jqueryui.com/sortable/
  13039. //>>demos: http://jqueryui.com/sortable/
  13040. //>>css.structure: ../../themes/base/sortable.css
  13041. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  13042. version: "1.13.0",
  13043. widgetEventPrefix: "sort",
  13044. ready: false,
  13045. options: {
  13046. appendTo: "parent",
  13047. axis: false,
  13048. connectWith: false,
  13049. containment: false,
  13050. cursor: "auto",
  13051. cursorAt: false,
  13052. dropOnEmpty: true,
  13053. forcePlaceholderSize: false,
  13054. forceHelperSize: false,
  13055. grid: false,
  13056. handle: false,
  13057. helper: "original",
  13058. items: "> *",
  13059. opacity: false,
  13060. placeholder: false,
  13061. revert: false,
  13062. scroll: true,
  13063. scrollSensitivity: 20,
  13064. scrollSpeed: 20,
  13065. scope: "default",
  13066. tolerance: "intersect",
  13067. zIndex: 1000,
  13068. // Callbacks
  13069. activate: null,
  13070. beforeStop: null,
  13071. change: null,
  13072. deactivate: null,
  13073. out: null,
  13074. over: null,
  13075. receive: null,
  13076. remove: null,
  13077. sort: null,
  13078. start: null,
  13079. stop: null,
  13080. update: null
  13081. },
  13082. _isOverAxis: function( x, reference, size ) {
  13083. return ( x >= reference ) && ( x < ( reference + size ) );
  13084. },
  13085. _isFloating: function( item ) {
  13086. return ( /left|right/ ).test( item.css( "float" ) ) ||
  13087. ( /inline|table-cell/ ).test( item.css( "display" ) );
  13088. },
  13089. _create: function() {
  13090. this.containerCache = {};
  13091. this._addClass( "ui-sortable" );
  13092. //Get the items
  13093. this.refresh();
  13094. //Let's determine the parent's offset
  13095. this.offset = this.element.offset();
  13096. //Initialize mouse events for interaction
  13097. this._mouseInit();
  13098. this._setHandleClassName();
  13099. //We're ready to go
  13100. this.ready = true;
  13101. },
  13102. _setOption: function( key, value ) {
  13103. this._super( key, value );
  13104. if ( key === "handle" ) {
  13105. this._setHandleClassName();
  13106. }
  13107. },
  13108. _setHandleClassName: function() {
  13109. var that = this;
  13110. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  13111. $.each( this.items, function() {
  13112. that._addClass(
  13113. this.instance.options.handle ?
  13114. this.item.find( this.instance.options.handle ) :
  13115. this.item,
  13116. "ui-sortable-handle"
  13117. );
  13118. } );
  13119. },
  13120. _destroy: function() {
  13121. this._mouseDestroy();
  13122. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  13123. this.items[ i ].item.removeData( this.widgetName + "-item" );
  13124. }
  13125. return this;
  13126. },
  13127. _mouseCapture: function( event, overrideHandle ) {
  13128. var currentItem = null,
  13129. validHandle = false,
  13130. that = this;
  13131. if ( this.reverting ) {
  13132. return false;
  13133. }
  13134. if ( this.options.disabled || this.options.type === "static" ) {
  13135. return false;
  13136. }
  13137. //We have to refresh the items data once first
  13138. this._refreshItems( event );
  13139. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  13140. $( event.target ).parents().each( function() {
  13141. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  13142. currentItem = $( this );
  13143. return false;
  13144. }
  13145. } );
  13146. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  13147. currentItem = $( event.target );
  13148. }
  13149. if ( !currentItem ) {
  13150. return false;
  13151. }
  13152. if ( this.options.handle && !overrideHandle ) {
  13153. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  13154. if ( this === event.target ) {
  13155. validHandle = true;
  13156. }
  13157. } );
  13158. if ( !validHandle ) {
  13159. return false;
  13160. }
  13161. }
  13162. this.currentItem = currentItem;
  13163. this._removeCurrentsFromItems();
  13164. return true;
  13165. },
  13166. _mouseStart: function( event, overrideHandle, noActivation ) {
  13167. var i, body,
  13168. o = this.options;
  13169. this.currentContainer = this;
  13170. //We only need to call refreshPositions, because the refreshItems call has been moved to
  13171. // mouseCapture
  13172. this.refreshPositions();
  13173. //Prepare the dragged items parent
  13174. this.appendTo = $( o.appendTo !== "parent" ?
  13175. o.appendTo :
  13176. this.currentItem.parent() );
  13177. //Create and append the visible helper
  13178. this.helper = this._createHelper( event );
  13179. //Cache the helper size
  13180. this._cacheHelperProportions();
  13181. /*
  13182. * - Position generation -
  13183. * This block generates everything position related - it's the core of draggables.
  13184. */
  13185. //Cache the margins of the original element
  13186. this._cacheMargins();
  13187. //The element's absolute position on the page minus margins
  13188. this.offset = this.currentItem.offset();
  13189. this.offset = {
  13190. top: this.offset.top - this.margins.top,
  13191. left: this.offset.left - this.margins.left
  13192. };
  13193. $.extend( this.offset, {
  13194. click: { //Where the click happened, relative to the element
  13195. left: event.pageX - this.offset.left,
  13196. top: event.pageY - this.offset.top
  13197. },
  13198. // This is a relative to absolute position minus the actual position calculation -
  13199. // only used for relative positioned helper
  13200. relative: this._getRelativeOffset()
  13201. } );
  13202. // After we get the helper offset, but before we get the parent offset we can
  13203. // change the helper's position to absolute
  13204. // TODO: Still need to figure out a way to make relative sorting possible
  13205. this.helper.css( "position", "absolute" );
  13206. this.cssPosition = this.helper.css( "position" );
  13207. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  13208. if ( o.cursorAt ) {
  13209. this._adjustOffsetFromHelper( o.cursorAt );
  13210. }
  13211. //Cache the former DOM position
  13212. this.domPosition = {
  13213. prev: this.currentItem.prev()[ 0 ],
  13214. parent: this.currentItem.parent()[ 0 ]
  13215. };
  13216. // If the helper is not the original, hide the original so it's not playing any role during
  13217. // the drag, won't cause anything bad this way
  13218. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  13219. this.currentItem.hide();
  13220. }
  13221. //Create the placeholder
  13222. this._createPlaceholder();
  13223. //Get the next scrolling parent
  13224. this.scrollParent = this.placeholder.scrollParent();
  13225. $.extend( this.offset, {
  13226. parent: this._getParentOffset()
  13227. } );
  13228. //Set a containment if given in the options
  13229. if ( o.containment ) {
  13230. this._setContainment();
  13231. }
  13232. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  13233. body = this.document.find( "body" );
  13234. // Support: IE
  13235. this.storedCursor = body.css( "cursor" );
  13236. body.css( "cursor", o.cursor );
  13237. this.storedStylesheet =
  13238. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  13239. }
  13240. // We need to make sure to grab the zIndex before setting the
  13241. // opacity, because setting the opacity to anything lower than 1
  13242. // causes the zIndex to change from "auto" to 0.
  13243. if ( o.zIndex ) { // zIndex option
  13244. if ( this.helper.css( "zIndex" ) ) {
  13245. this._storedZIndex = this.helper.css( "zIndex" );
  13246. }
  13247. this.helper.css( "zIndex", o.zIndex );
  13248. }
  13249. if ( o.opacity ) { // opacity option
  13250. if ( this.helper.css( "opacity" ) ) {
  13251. this._storedOpacity = this.helper.css( "opacity" );
  13252. }
  13253. this.helper.css( "opacity", o.opacity );
  13254. }
  13255. //Prepare scrolling
  13256. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13257. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13258. this.overflowOffset = this.scrollParent.offset();
  13259. }
  13260. //Call callbacks
  13261. this._trigger( "start", event, this._uiHash() );
  13262. //Recache the helper size
  13263. if ( !this._preserveHelperProportions ) {
  13264. this._cacheHelperProportions();
  13265. }
  13266. //Post "activate" events to possible containers
  13267. if ( !noActivation ) {
  13268. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13269. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  13270. }
  13271. }
  13272. //Prepare possible droppables
  13273. if ( $.ui.ddmanager ) {
  13274. $.ui.ddmanager.current = this;
  13275. }
  13276. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  13277. $.ui.ddmanager.prepareOffsets( this, event );
  13278. }
  13279. this.dragging = true;
  13280. this._addClass( this.helper, "ui-sortable-helper" );
  13281. //Move the helper, if needed
  13282. if ( !this.helper.parent().is( this.appendTo ) ) {
  13283. this.helper.detach().appendTo( this.appendTo );
  13284. //Update position
  13285. this.offset.parent = this._getParentOffset();
  13286. }
  13287. //Generate the original position
  13288. this.position = this.originalPosition = this._generatePosition( event );
  13289. this.originalPageX = event.pageX;
  13290. this.originalPageY = event.pageY;
  13291. this.lastPositionAbs = this.positionAbs = this._convertPositionTo( "absolute" );
  13292. this._mouseDrag( event );
  13293. return true;
  13294. },
  13295. _scroll: function( event ) {
  13296. var o = this.options,
  13297. scrolled = false;
  13298. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13299. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13300. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  13301. event.pageY < o.scrollSensitivity ) {
  13302. this.scrollParent[ 0 ].scrollTop =
  13303. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  13304. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  13305. this.scrollParent[ 0 ].scrollTop =
  13306. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  13307. }
  13308. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  13309. event.pageX < o.scrollSensitivity ) {
  13310. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13311. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  13312. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  13313. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13314. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  13315. }
  13316. } else {
  13317. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  13318. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  13319. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  13320. o.scrollSensitivity ) {
  13321. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  13322. }
  13323. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  13324. scrolled = this.document.scrollLeft(
  13325. this.document.scrollLeft() - o.scrollSpeed
  13326. );
  13327. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  13328. o.scrollSensitivity ) {
  13329. scrolled = this.document.scrollLeft(
  13330. this.document.scrollLeft() + o.scrollSpeed
  13331. );
  13332. }
  13333. }
  13334. return scrolled;
  13335. },
  13336. _mouseDrag: function( event ) {
  13337. var i, item, itemElement, intersection,
  13338. o = this.options;
  13339. //Compute the helpers position
  13340. this.position = this._generatePosition( event );
  13341. this.positionAbs = this._convertPositionTo( "absolute" );
  13342. //Set the helper position
  13343. if ( !this.options.axis || this.options.axis !== "y" ) {
  13344. this.helper[ 0 ].style.left = this.position.left + "px";
  13345. }
  13346. if ( !this.options.axis || this.options.axis !== "x" ) {
  13347. this.helper[ 0 ].style.top = this.position.top + "px";
  13348. }
  13349. //Post events to containers
  13350. this._contactContainers( event );
  13351. if ( this.innermostContainer !== null ) {
  13352. //Do scrolling
  13353. if ( o.scroll ) {
  13354. if ( this._scroll( event ) !== false ) {
  13355. //Update item positions used in position checks
  13356. this._refreshItemPositions( true );
  13357. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  13358. $.ui.ddmanager.prepareOffsets( this, event );
  13359. }
  13360. }
  13361. }
  13362. this.dragDirection = {
  13363. vertical: this._getDragVerticalDirection(),
  13364. horizontal: this._getDragHorizontalDirection()
  13365. };
  13366. //Rearrange
  13367. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13368. //Cache variables and intersection, continue if no intersection
  13369. item = this.items[ i ];
  13370. itemElement = item.item[ 0 ];
  13371. intersection = this._intersectsWithPointer( item );
  13372. if ( !intersection ) {
  13373. continue;
  13374. }
  13375. // Only put the placeholder inside the current Container, skip all
  13376. // items from other containers. This works because when moving
  13377. // an item from one container to another the
  13378. // currentContainer is switched before the placeholder is moved.
  13379. //
  13380. // Without this, moving items in "sub-sortables" can cause
  13381. // the placeholder to jitter between the outer and inner container.
  13382. if ( item.instance !== this.currentContainer ) {
  13383. continue;
  13384. }
  13385. // Cannot intersect with itself
  13386. // no useless actions that have been done before
  13387. // no action if the item moved is the parent of the item checked
  13388. if ( itemElement !== this.currentItem[ 0 ] &&
  13389. this.placeholder[ intersection === 1 ?
  13390. "next" : "prev" ]()[ 0 ] !== itemElement &&
  13391. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  13392. ( this.options.type === "semi-dynamic" ?
  13393. !$.contains( this.element[ 0 ], itemElement ) :
  13394. true
  13395. )
  13396. ) {
  13397. this.direction = intersection === 1 ? "down" : "up";
  13398. if ( this.options.tolerance === "pointer" ||
  13399. this._intersectsWithSides( item ) ) {
  13400. this._rearrange( event, item );
  13401. } else {
  13402. break;
  13403. }
  13404. this._trigger( "change", event, this._uiHash() );
  13405. break;
  13406. }
  13407. }
  13408. }
  13409. //Interconnect with droppables
  13410. if ( $.ui.ddmanager ) {
  13411. $.ui.ddmanager.drag( this, event );
  13412. }
  13413. //Call callbacks
  13414. this._trigger( "sort", event, this._uiHash() );
  13415. this.lastPositionAbs = this.positionAbs;
  13416. return false;
  13417. },
  13418. _mouseStop: function( event, noPropagation ) {
  13419. if ( !event ) {
  13420. return;
  13421. }
  13422. //If we are using droppables, inform the manager about the drop
  13423. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  13424. $.ui.ddmanager.drop( this, event );
  13425. }
  13426. if ( this.options.revert ) {
  13427. var that = this,
  13428. cur = this.placeholder.offset(),
  13429. axis = this.options.axis,
  13430. animation = {};
  13431. if ( !axis || axis === "x" ) {
  13432. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  13433. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13434. 0 :
  13435. this.offsetParent[ 0 ].scrollLeft
  13436. );
  13437. }
  13438. if ( !axis || axis === "y" ) {
  13439. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  13440. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13441. 0 :
  13442. this.offsetParent[ 0 ].scrollTop
  13443. );
  13444. }
  13445. this.reverting = true;
  13446. $( this.helper ).animate(
  13447. animation,
  13448. parseInt( this.options.revert, 10 ) || 500,
  13449. function() {
  13450. that._clear( event );
  13451. }
  13452. );
  13453. } else {
  13454. this._clear( event, noPropagation );
  13455. }
  13456. return false;
  13457. },
  13458. cancel: function() {
  13459. if ( this.dragging ) {
  13460. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  13461. if ( this.options.helper === "original" ) {
  13462. this.currentItem.css( this._storedCSS );
  13463. this._removeClass( this.currentItem, "ui-sortable-helper" );
  13464. } else {
  13465. this.currentItem.show();
  13466. }
  13467. //Post deactivating events to containers
  13468. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  13469. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  13470. if ( this.containers[ i ].containerCache.over ) {
  13471. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  13472. this.containers[ i ].containerCache.over = 0;
  13473. }
  13474. }
  13475. }
  13476. if ( this.placeholder ) {
  13477. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  13478. // it unbinds ALL events from the original node!
  13479. if ( this.placeholder[ 0 ].parentNode ) {
  13480. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  13481. }
  13482. if ( this.options.helper !== "original" && this.helper &&
  13483. this.helper[ 0 ].parentNode ) {
  13484. this.helper.remove();
  13485. }
  13486. $.extend( this, {
  13487. helper: null,
  13488. dragging: false,
  13489. reverting: false,
  13490. _noFinalSort: null
  13491. } );
  13492. if ( this.domPosition.prev ) {
  13493. $( this.domPosition.prev ).after( this.currentItem );
  13494. } else {
  13495. $( this.domPosition.parent ).prepend( this.currentItem );
  13496. }
  13497. }
  13498. return this;
  13499. },
  13500. serialize: function( o ) {
  13501. var items = this._getItemsAsjQuery( o && o.connected ),
  13502. str = [];
  13503. o = o || {};
  13504. $( items ).each( function() {
  13505. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  13506. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  13507. if ( res ) {
  13508. str.push(
  13509. ( o.key || res[ 1 ] + "[]" ) +
  13510. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  13511. }
  13512. } );
  13513. if ( !str.length && o.key ) {
  13514. str.push( o.key + "=" );
  13515. }
  13516. return str.join( "&" );
  13517. },
  13518. toArray: function( o ) {
  13519. var items = this._getItemsAsjQuery( o && o.connected ),
  13520. ret = [];
  13521. o = o || {};
  13522. items.each( function() {
  13523. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  13524. } );
  13525. return ret;
  13526. },
  13527. /* Be careful with the following core functions */
  13528. _intersectsWith: function( item ) {
  13529. var x1 = this.positionAbs.left,
  13530. x2 = x1 + this.helperProportions.width,
  13531. y1 = this.positionAbs.top,
  13532. y2 = y1 + this.helperProportions.height,
  13533. l = item.left,
  13534. r = l + item.width,
  13535. t = item.top,
  13536. b = t + item.height,
  13537. dyClick = this.offset.click.top,
  13538. dxClick = this.offset.click.left,
  13539. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  13540. ( y1 + dyClick ) < b ),
  13541. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  13542. ( x1 + dxClick ) < r ),
  13543. isOverElement = isOverElementHeight && isOverElementWidth;
  13544. if ( this.options.tolerance === "pointer" ||
  13545. this.options.forcePointerForContainers ||
  13546. ( this.options.tolerance !== "pointer" &&
  13547. this.helperProportions[ this.floating ? "width" : "height" ] >
  13548. item[ this.floating ? "width" : "height" ] )
  13549. ) {
  13550. return isOverElement;
  13551. } else {
  13552. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  13553. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  13554. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  13555. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  13556. }
  13557. },
  13558. _intersectsWithPointer: function( item ) {
  13559. var verticalDirection, horizontalDirection,
  13560. isOverElementHeight = ( this.options.axis === "x" ) ||
  13561. this._isOverAxis(
  13562. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  13563. isOverElementWidth = ( this.options.axis === "y" ) ||
  13564. this._isOverAxis(
  13565. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  13566. isOverElement = isOverElementHeight && isOverElementWidth;
  13567. if ( !isOverElement ) {
  13568. return false;
  13569. }
  13570. verticalDirection = this.dragDirection.vertical;
  13571. horizontalDirection = this.dragDirection.horizontal;
  13572. return this.floating ?
  13573. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) :
  13574. ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  13575. },
  13576. _intersectsWithSides: function( item ) {
  13577. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  13578. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  13579. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  13580. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  13581. verticalDirection = this.dragDirection.vertical,
  13582. horizontalDirection = this.dragDirection.horizontal;
  13583. if ( this.floating && horizontalDirection ) {
  13584. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  13585. ( horizontalDirection === "left" && !isOverRightHalf ) );
  13586. } else {
  13587. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  13588. ( verticalDirection === "up" && !isOverBottomHalf ) );
  13589. }
  13590. },
  13591. _getDragVerticalDirection: function() {
  13592. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  13593. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  13594. },
  13595. _getDragHorizontalDirection: function() {
  13596. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  13597. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  13598. },
  13599. refresh: function( event ) {
  13600. this._refreshItems( event );
  13601. this._setHandleClassName();
  13602. this.refreshPositions();
  13603. return this;
  13604. },
  13605. _connectWith: function() {
  13606. var options = this.options;
  13607. return options.connectWith.constructor === String ?
  13608. [ options.connectWith ] :
  13609. options.connectWith;
  13610. },
  13611. _getItemsAsjQuery: function( connected ) {
  13612. var i, j, cur, inst,
  13613. items = [],
  13614. queries = [],
  13615. connectWith = this._connectWith();
  13616. if ( connectWith && connected ) {
  13617. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13618. cur = $( connectWith[ i ], this.document[ 0 ] );
  13619. for ( j = cur.length - 1; j >= 0; j-- ) {
  13620. inst = $.data( cur[ j ], this.widgetFullName );
  13621. if ( inst && inst !== this && !inst.options.disabled ) {
  13622. queries.push( [ typeof inst.options.items === "function" ?
  13623. inst.options.items.call( inst.element ) :
  13624. $( inst.options.items, inst.element )
  13625. .not( ".ui-sortable-helper" )
  13626. .not( ".ui-sortable-placeholder" ), inst ] );
  13627. }
  13628. }
  13629. }
  13630. }
  13631. queries.push( [ typeof this.options.items === "function" ?
  13632. this.options.items
  13633. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  13634. $( this.options.items, this.element )
  13635. .not( ".ui-sortable-helper" )
  13636. .not( ".ui-sortable-placeholder" ), this ] );
  13637. function addItems() {
  13638. items.push( this );
  13639. }
  13640. for ( i = queries.length - 1; i >= 0; i-- ) {
  13641. queries[ i ][ 0 ].each( addItems );
  13642. }
  13643. return $( items );
  13644. },
  13645. _removeCurrentsFromItems: function() {
  13646. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  13647. this.items = $.grep( this.items, function( item ) {
  13648. for ( var j = 0; j < list.length; j++ ) {
  13649. if ( list[ j ] === item.item[ 0 ] ) {
  13650. return false;
  13651. }
  13652. }
  13653. return true;
  13654. } );
  13655. },
  13656. _refreshItems: function( event ) {
  13657. this.items = [];
  13658. this.containers = [ this ];
  13659. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  13660. items = this.items,
  13661. queries = [ [ typeof this.options.items === "function" ?
  13662. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  13663. $( this.options.items, this.element ), this ] ],
  13664. connectWith = this._connectWith();
  13665. //Shouldn't be run the first time through due to massive slow-down
  13666. if ( connectWith && this.ready ) {
  13667. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13668. cur = $( connectWith[ i ], this.document[ 0 ] );
  13669. for ( j = cur.length - 1; j >= 0; j-- ) {
  13670. inst = $.data( cur[ j ], this.widgetFullName );
  13671. if ( inst && inst !== this && !inst.options.disabled ) {
  13672. queries.push( [ typeof inst.options.items === "function" ?
  13673. inst.options.items
  13674. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  13675. $( inst.options.items, inst.element ), inst ] );
  13676. this.containers.push( inst );
  13677. }
  13678. }
  13679. }
  13680. }
  13681. for ( i = queries.length - 1; i >= 0; i-- ) {
  13682. targetData = queries[ i ][ 1 ];
  13683. _queries = queries[ i ][ 0 ];
  13684. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  13685. item = $( _queries[ j ] );
  13686. // Data for target checking (mouse manager)
  13687. item.data( this.widgetName + "-item", targetData );
  13688. items.push( {
  13689. item: item,
  13690. instance: targetData,
  13691. width: 0, height: 0,
  13692. left: 0, top: 0
  13693. } );
  13694. }
  13695. }
  13696. },
  13697. _refreshItemPositions: function( fast ) {
  13698. var i, item, t, p;
  13699. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13700. item = this.items[ i ];
  13701. //We ignore calculating positions of all connected containers when we're not over them
  13702. if ( this.currentContainer && item.instance !== this.currentContainer &&
  13703. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  13704. continue;
  13705. }
  13706. t = this.options.toleranceElement ?
  13707. $( this.options.toleranceElement, item.item ) :
  13708. item.item;
  13709. if ( !fast ) {
  13710. item.width = t.outerWidth();
  13711. item.height = t.outerHeight();
  13712. }
  13713. p = t.offset();
  13714. item.left = p.left;
  13715. item.top = p.top;
  13716. }
  13717. },
  13718. refreshPositions: function( fast ) {
  13719. // Determine whether items are being displayed horizontally
  13720. this.floating = this.items.length ?
  13721. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  13722. false;
  13723. if ( this.innermostContainer !== null ) {
  13724. this._refreshItemPositions( fast );
  13725. }
  13726. var i, p;
  13727. if ( this.options.custom && this.options.custom.refreshContainers ) {
  13728. this.options.custom.refreshContainers.call( this );
  13729. } else {
  13730. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13731. p = this.containers[ i ].element.offset();
  13732. this.containers[ i ].containerCache.left = p.left;
  13733. this.containers[ i ].containerCache.top = p.top;
  13734. this.containers[ i ].containerCache.width =
  13735. this.containers[ i ].element.outerWidth();
  13736. this.containers[ i ].containerCache.height =
  13737. this.containers[ i ].element.outerHeight();
  13738. }
  13739. }
  13740. return this;
  13741. },
  13742. _createPlaceholder: function( that ) {
  13743. that = that || this;
  13744. var className, nodeName,
  13745. o = that.options;
  13746. if ( !o.placeholder || o.placeholder.constructor === String ) {
  13747. className = o.placeholder;
  13748. nodeName = that.currentItem[ 0 ].nodeName.toLowerCase();
  13749. o.placeholder = {
  13750. element: function() {
  13751. var element = $( "<" + nodeName + ">", that.document[ 0 ] );
  13752. that._addClass( element, "ui-sortable-placeholder",
  13753. className || that.currentItem[ 0 ].className )
  13754. ._removeClass( element, "ui-sortable-helper" );
  13755. if ( nodeName === "tbody" ) {
  13756. that._createTrPlaceholder(
  13757. that.currentItem.find( "tr" ).eq( 0 ),
  13758. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  13759. );
  13760. } else if ( nodeName === "tr" ) {
  13761. that._createTrPlaceholder( that.currentItem, element );
  13762. } else if ( nodeName === "img" ) {
  13763. element.attr( "src", that.currentItem.attr( "src" ) );
  13764. }
  13765. if ( !className ) {
  13766. element.css( "visibility", "hidden" );
  13767. }
  13768. return element;
  13769. },
  13770. update: function( container, p ) {
  13771. // 1. If a className is set as 'placeholder option, we don't force sizes -
  13772. // the class is responsible for that
  13773. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  13774. // class name is specified
  13775. if ( className && !o.forcePlaceholderSize ) {
  13776. return;
  13777. }
  13778. // If the element doesn't have a actual height or width by itself (without
  13779. // styles coming from a stylesheet), it receives the inline height and width
  13780. // from the dragged item. Or, if it's a tbody or tr, it's going to have a height
  13781. // anyway since we're populating them with <td>s above, but they're unlikely to
  13782. // be the correct height on their own if the row heights are dynamic, so we'll
  13783. // always assign the height of the dragged item given forcePlaceholderSize
  13784. // is true.
  13785. if ( !p.height() || ( o.forcePlaceholderSize &&
  13786. ( nodeName === "tbody" || nodeName === "tr" ) ) ) {
  13787. p.height(
  13788. that.currentItem.innerHeight() -
  13789. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  13790. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  13791. }
  13792. if ( !p.width() ) {
  13793. p.width(
  13794. that.currentItem.innerWidth() -
  13795. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  13796. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  13797. }
  13798. }
  13799. };
  13800. }
  13801. //Create the placeholder
  13802. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  13803. //Append it after the actual current item
  13804. that.currentItem.after( that.placeholder );
  13805. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  13806. o.placeholder.update( that, that.placeholder );
  13807. },
  13808. _createTrPlaceholder: function( sourceTr, targetTr ) {
  13809. var that = this;
  13810. sourceTr.children().each( function() {
  13811. $( "<td>&#160;</td>", that.document[ 0 ] )
  13812. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  13813. .appendTo( targetTr );
  13814. } );
  13815. },
  13816. _contactContainers: function( event ) {
  13817. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  13818. floating, axis,
  13819. innermostContainer = null,
  13820. innermostIndex = null;
  13821. // Get innermost container that intersects with item
  13822. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13823. // Never consider a container that's located within the item itself
  13824. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  13825. continue;
  13826. }
  13827. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  13828. // If we've already found a container and it's more "inner" than this, then continue
  13829. if ( innermostContainer &&
  13830. $.contains(
  13831. this.containers[ i ].element[ 0 ],
  13832. innermostContainer.element[ 0 ] ) ) {
  13833. continue;
  13834. }
  13835. innermostContainer = this.containers[ i ];
  13836. innermostIndex = i;
  13837. } else {
  13838. // container doesn't intersect. trigger "out" event if necessary
  13839. if ( this.containers[ i ].containerCache.over ) {
  13840. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  13841. this.containers[ i ].containerCache.over = 0;
  13842. }
  13843. }
  13844. }
  13845. this.innermostContainer = innermostContainer;
  13846. // If no intersecting containers found, return
  13847. if ( !innermostContainer ) {
  13848. return;
  13849. }
  13850. // Move the item into the container if it's not there already
  13851. if ( this.containers.length === 1 ) {
  13852. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  13853. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13854. this.containers[ innermostIndex ].containerCache.over = 1;
  13855. }
  13856. } else {
  13857. // When entering a new container, we will find the item with the least distance and
  13858. // append our item near it
  13859. dist = 10000;
  13860. itemWithLeastDistance = null;
  13861. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  13862. posProperty = floating ? "left" : "top";
  13863. sizeProperty = floating ? "width" : "height";
  13864. axis = floating ? "pageX" : "pageY";
  13865. for ( j = this.items.length - 1; j >= 0; j-- ) {
  13866. if ( !$.contains(
  13867. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  13868. ) {
  13869. continue;
  13870. }
  13871. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  13872. continue;
  13873. }
  13874. cur = this.items[ j ].item.offset()[ posProperty ];
  13875. nearBottom = false;
  13876. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  13877. nearBottom = true;
  13878. }
  13879. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  13880. dist = Math.abs( event[ axis ] - cur );
  13881. itemWithLeastDistance = this.items[ j ];
  13882. this.direction = nearBottom ? "up" : "down";
  13883. }
  13884. }
  13885. //Check if dropOnEmpty is enabled
  13886. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  13887. return;
  13888. }
  13889. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  13890. if ( !this.currentContainer.containerCache.over ) {
  13891. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  13892. this.currentContainer.containerCache.over = 1;
  13893. }
  13894. return;
  13895. }
  13896. if ( itemWithLeastDistance ) {
  13897. this._rearrange( event, itemWithLeastDistance, null, true );
  13898. } else {
  13899. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  13900. }
  13901. this._trigger( "change", event, this._uiHash() );
  13902. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  13903. this.currentContainer = this.containers[ innermostIndex ];
  13904. //Update the placeholder
  13905. this.options.placeholder.update( this.currentContainer, this.placeholder );
  13906. //Update scrollParent
  13907. this.scrollParent = this.placeholder.scrollParent();
  13908. //Update overflowOffset
  13909. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13910. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13911. this.overflowOffset = this.scrollParent.offset();
  13912. }
  13913. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13914. this.containers[ innermostIndex ].containerCache.over = 1;
  13915. }
  13916. },
  13917. _createHelper: function( event ) {
  13918. var o = this.options,
  13919. helper = typeof o.helper === "function" ?
  13920. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  13921. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  13922. //Add the helper to the DOM if that didn't happen already
  13923. if ( !helper.parents( "body" ).length ) {
  13924. this.appendTo[ 0 ].appendChild( helper[ 0 ] );
  13925. }
  13926. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  13927. this._storedCSS = {
  13928. width: this.currentItem[ 0 ].style.width,
  13929. height: this.currentItem[ 0 ].style.height,
  13930. position: this.currentItem.css( "position" ),
  13931. top: this.currentItem.css( "top" ),
  13932. left: this.currentItem.css( "left" )
  13933. };
  13934. }
  13935. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  13936. helper.width( this.currentItem.width() );
  13937. }
  13938. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  13939. helper.height( this.currentItem.height() );
  13940. }
  13941. return helper;
  13942. },
  13943. _adjustOffsetFromHelper: function( obj ) {
  13944. if ( typeof obj === "string" ) {
  13945. obj = obj.split( " " );
  13946. }
  13947. if ( Array.isArray( obj ) ) {
  13948. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  13949. }
  13950. if ( "left" in obj ) {
  13951. this.offset.click.left = obj.left + this.margins.left;
  13952. }
  13953. if ( "right" in obj ) {
  13954. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  13955. }
  13956. if ( "top" in obj ) {
  13957. this.offset.click.top = obj.top + this.margins.top;
  13958. }
  13959. if ( "bottom" in obj ) {
  13960. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  13961. }
  13962. },
  13963. _getParentOffset: function() {
  13964. //Get the offsetParent and cache its position
  13965. this.offsetParent = this.helper.offsetParent();
  13966. var po = this.offsetParent.offset();
  13967. // This is a special case where we need to modify a offset calculated on start, since the
  13968. // following happened:
  13969. // 1. The position of the helper is absolute, so it's position is calculated based on the
  13970. // next positioned parent
  13971. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  13972. // the document, which means that the scroll is included in the initial calculation of the
  13973. // offset of the parent, and never recalculated upon drag
  13974. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13975. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  13976. po.left += this.scrollParent.scrollLeft();
  13977. po.top += this.scrollParent.scrollTop();
  13978. }
  13979. // This needs to be actually done for all browsers, since pageX/pageY includes this
  13980. // information with an ugly IE fix
  13981. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  13982. ( this.offsetParent[ 0 ].tagName &&
  13983. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  13984. po = { top: 0, left: 0 };
  13985. }
  13986. return {
  13987. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  13988. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  13989. };
  13990. },
  13991. _getRelativeOffset: function() {
  13992. if ( this.cssPosition === "relative" ) {
  13993. var p = this.currentItem.position();
  13994. return {
  13995. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  13996. this.scrollParent.scrollTop(),
  13997. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  13998. this.scrollParent.scrollLeft()
  13999. };
  14000. } else {
  14001. return { top: 0, left: 0 };
  14002. }
  14003. },
  14004. _cacheMargins: function() {
  14005. this.margins = {
  14006. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  14007. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  14008. };
  14009. },
  14010. _cacheHelperProportions: function() {
  14011. this.helperProportions = {
  14012. width: this.helper.outerWidth(),
  14013. height: this.helper.outerHeight()
  14014. };
  14015. },
  14016. _setContainment: function() {
  14017. var ce, co, over,
  14018. o = this.options;
  14019. if ( o.containment === "parent" ) {
  14020. o.containment = this.helper[ 0 ].parentNode;
  14021. }
  14022. if ( o.containment === "document" || o.containment === "window" ) {
  14023. this.containment = [
  14024. 0 - this.offset.relative.left - this.offset.parent.left,
  14025. 0 - this.offset.relative.top - this.offset.parent.top,
  14026. o.containment === "document" ?
  14027. this.document.width() :
  14028. this.window.width() - this.helperProportions.width - this.margins.left,
  14029. ( o.containment === "document" ?
  14030. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  14031. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  14032. ) - this.helperProportions.height - this.margins.top
  14033. ];
  14034. }
  14035. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  14036. ce = $( o.containment )[ 0 ];
  14037. co = $( o.containment ).offset();
  14038. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  14039. this.containment = [
  14040. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  14041. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  14042. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  14043. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  14044. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  14045. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  14046. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  14047. this.helperProportions.width - this.margins.left,
  14048. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  14049. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  14050. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  14051. this.helperProportions.height - this.margins.top
  14052. ];
  14053. }
  14054. },
  14055. _convertPositionTo: function( d, pos ) {
  14056. if ( !pos ) {
  14057. pos = this.position;
  14058. }
  14059. var mod = d === "absolute" ? 1 : -1,
  14060. scroll = this.cssPosition === "absolute" &&
  14061. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  14062. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  14063. this.offsetParent :
  14064. this.scrollParent,
  14065. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  14066. return {
  14067. top: (
  14068. // The absolute mouse position
  14069. pos.top +
  14070. // Only for relative positioned nodes: Relative offset from element to offset parent
  14071. this.offset.relative.top * mod +
  14072. // The offsetParent's offset without borders (offset + border)
  14073. this.offset.parent.top * mod -
  14074. ( ( this.cssPosition === "fixed" ?
  14075. -this.scrollParent.scrollTop() :
  14076. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  14077. ),
  14078. left: (
  14079. // The absolute mouse position
  14080. pos.left +
  14081. // Only for relative positioned nodes: Relative offset from element to offset parent
  14082. this.offset.relative.left * mod +
  14083. // The offsetParent's offset without borders (offset + border)
  14084. this.offset.parent.left * mod -
  14085. ( ( this.cssPosition === "fixed" ?
  14086. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  14087. scroll.scrollLeft() ) * mod )
  14088. )
  14089. };
  14090. },
  14091. _generatePosition: function( event ) {
  14092. var top, left,
  14093. o = this.options,
  14094. pageX = event.pageX,
  14095. pageY = event.pageY,
  14096. scroll = this.cssPosition === "absolute" &&
  14097. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  14098. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  14099. this.offsetParent :
  14100. this.scrollParent,
  14101. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  14102. // This is another very weird special case that only happens for relative elements:
  14103. // 1. If the css position is relative
  14104. // 2. and the scroll parent is the document or similar to the offset parent
  14105. // we have to refresh the relative offset during the scroll so there are no jumps
  14106. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  14107. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  14108. this.offset.relative = this._getRelativeOffset();
  14109. }
  14110. /*
  14111. * - Position constraining -
  14112. * Constrain the position to a mix of grid, containment.
  14113. */
  14114. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  14115. if ( this.containment ) {
  14116. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  14117. pageX = this.containment[ 0 ] + this.offset.click.left;
  14118. }
  14119. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  14120. pageY = this.containment[ 1 ] + this.offset.click.top;
  14121. }
  14122. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  14123. pageX = this.containment[ 2 ] + this.offset.click.left;
  14124. }
  14125. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  14126. pageY = this.containment[ 3 ] + this.offset.click.top;
  14127. }
  14128. }
  14129. if ( o.grid ) {
  14130. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  14131. o.grid[ 1 ] ) * o.grid[ 1 ];
  14132. pageY = this.containment ?
  14133. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  14134. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  14135. top :
  14136. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  14137. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  14138. top;
  14139. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  14140. o.grid[ 0 ] ) * o.grid[ 0 ];
  14141. pageX = this.containment ?
  14142. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  14143. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  14144. left :
  14145. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  14146. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  14147. left;
  14148. }
  14149. }
  14150. return {
  14151. top: (
  14152. // The absolute mouse position
  14153. pageY -
  14154. // Click offset (relative to the element)
  14155. this.offset.click.top -
  14156. // Only for relative positioned nodes: Relative offset from element to offset parent
  14157. this.offset.relative.top -
  14158. // The offsetParent's offset without borders (offset + border)
  14159. this.offset.parent.top +
  14160. ( ( this.cssPosition === "fixed" ?
  14161. -this.scrollParent.scrollTop() :
  14162. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  14163. ),
  14164. left: (
  14165. // The absolute mouse position
  14166. pageX -
  14167. // Click offset (relative to the element)
  14168. this.offset.click.left -
  14169. // Only for relative positioned nodes: Relative offset from element to offset parent
  14170. this.offset.relative.left -
  14171. // The offsetParent's offset without borders (offset + border)
  14172. this.offset.parent.left +
  14173. ( ( this.cssPosition === "fixed" ?
  14174. -this.scrollParent.scrollLeft() :
  14175. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  14176. )
  14177. };
  14178. },
  14179. _rearrange: function( event, i, a, hardRefresh ) {
  14180. if ( a ) {
  14181. a[ 0 ].appendChild( this.placeholder[ 0 ] );
  14182. } else {
  14183. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  14184. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  14185. }
  14186. //Various things done here to improve the performance:
  14187. // 1. we create a setTimeout, that calls refreshPositions
  14188. // 2. on the instance, we have a counter variable, that get's higher after every append
  14189. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  14190. // if it's still the same
  14191. // 4. this lets only the last addition to the timeout stack through
  14192. this.counter = this.counter ? ++this.counter : 1;
  14193. var counter = this.counter;
  14194. this._delay( function() {
  14195. if ( counter === this.counter ) {
  14196. //Precompute after each DOM insertion, NOT on mousemove
  14197. this.refreshPositions( !hardRefresh );
  14198. }
  14199. } );
  14200. },
  14201. _clear: function( event, noPropagation ) {
  14202. this.reverting = false;
  14203. // We delay all events that have to be triggered to after the point where the placeholder
  14204. // has been removed and everything else normalized again
  14205. var i,
  14206. delayedTriggers = [];
  14207. // We first have to update the dom position of the actual currentItem
  14208. // Note: don't do it if the current item is already removed (by a user), or it gets
  14209. // reappended (see #4088)
  14210. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  14211. this.placeholder.before( this.currentItem );
  14212. }
  14213. this._noFinalSort = null;
  14214. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  14215. for ( i in this._storedCSS ) {
  14216. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  14217. this._storedCSS[ i ] = "";
  14218. }
  14219. }
  14220. this.currentItem.css( this._storedCSS );
  14221. this._removeClass( this.currentItem, "ui-sortable-helper" );
  14222. } else {
  14223. this.currentItem.show();
  14224. }
  14225. if ( this.fromOutside && !noPropagation ) {
  14226. delayedTriggers.push( function( event ) {
  14227. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  14228. } );
  14229. }
  14230. if ( ( this.fromOutside ||
  14231. this.domPosition.prev !==
  14232. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  14233. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  14234. // Trigger update callback if the DOM position has changed
  14235. delayedTriggers.push( function( event ) {
  14236. this._trigger( "update", event, this._uiHash() );
  14237. } );
  14238. }
  14239. // Check if the items Container has Changed and trigger appropriate
  14240. // events.
  14241. if ( this !== this.currentContainer ) {
  14242. if ( !noPropagation ) {
  14243. delayedTriggers.push( function( event ) {
  14244. this._trigger( "remove", event, this._uiHash() );
  14245. } );
  14246. delayedTriggers.push( ( function( c ) {
  14247. return function( event ) {
  14248. c._trigger( "receive", event, this._uiHash( this ) );
  14249. };
  14250. } ).call( this, this.currentContainer ) );
  14251. delayedTriggers.push( ( function( c ) {
  14252. return function( event ) {
  14253. c._trigger( "update", event, this._uiHash( this ) );
  14254. };
  14255. } ).call( this, this.currentContainer ) );
  14256. }
  14257. }
  14258. //Post events to containers
  14259. function delayEvent( type, instance, container ) {
  14260. return function( event ) {
  14261. container._trigger( type, event, instance._uiHash( instance ) );
  14262. };
  14263. }
  14264. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  14265. if ( !noPropagation ) {
  14266. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  14267. }
  14268. if ( this.containers[ i ].containerCache.over ) {
  14269. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  14270. this.containers[ i ].containerCache.over = 0;
  14271. }
  14272. }
  14273. //Do what was originally in plugins
  14274. if ( this.storedCursor ) {
  14275. this.document.find( "body" ).css( "cursor", this.storedCursor );
  14276. this.storedStylesheet.remove();
  14277. }
  14278. if ( this._storedOpacity ) {
  14279. this.helper.css( "opacity", this._storedOpacity );
  14280. }
  14281. if ( this._storedZIndex ) {
  14282. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  14283. }
  14284. this.dragging = false;
  14285. if ( !noPropagation ) {
  14286. this._trigger( "beforeStop", event, this._uiHash() );
  14287. }
  14288. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  14289. // it unbinds ALL events from the original node!
  14290. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  14291. if ( !this.cancelHelperRemoval ) {
  14292. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  14293. this.helper.remove();
  14294. }
  14295. this.helper = null;
  14296. }
  14297. if ( !noPropagation ) {
  14298. for ( i = 0; i < delayedTriggers.length; i++ ) {
  14299. // Trigger all delayed events
  14300. delayedTriggers[ i ].call( this, event );
  14301. }
  14302. this._trigger( "stop", event, this._uiHash() );
  14303. }
  14304. this.fromOutside = false;
  14305. return !this.cancelHelperRemoval;
  14306. },
  14307. _trigger: function() {
  14308. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  14309. this.cancel();
  14310. }
  14311. },
  14312. _uiHash: function( _inst ) {
  14313. var inst = _inst || this;
  14314. return {
  14315. helper: inst.helper,
  14316. placeholder: inst.placeholder || $( [] ),
  14317. position: inst.position,
  14318. originalPosition: inst.originalPosition,
  14319. offset: inst.positionAbs,
  14320. item: inst.currentItem,
  14321. sender: _inst ? _inst.element : null
  14322. };
  14323. }
  14324. } );
  14325. /*!
  14326. * jQuery UI Spinner 1.13.0
  14327. * http://jqueryui.com
  14328. *
  14329. * Copyright jQuery Foundation and other contributors
  14330. * Released under the MIT license.
  14331. * http://jquery.org/license
  14332. */
  14333. //>>label: Spinner
  14334. //>>group: Widgets
  14335. //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
  14336. //>>docs: http://api.jqueryui.com/spinner/
  14337. //>>demos: http://jqueryui.com/spinner/
  14338. //>>css.structure: ../../themes/base/core.css
  14339. //>>css.structure: ../../themes/base/spinner.css
  14340. //>>css.theme: ../../themes/base/theme.css
  14341. function spinnerModifier( fn ) {
  14342. return function() {
  14343. var previous = this.element.val();
  14344. fn.apply( this, arguments );
  14345. this._refresh();
  14346. if ( previous !== this.element.val() ) {
  14347. this._trigger( "change" );
  14348. }
  14349. };
  14350. }
  14351. $.widget( "ui.spinner", {
  14352. version: "1.13.0",
  14353. defaultElement: "<input>",
  14354. widgetEventPrefix: "spin",
  14355. options: {
  14356. classes: {
  14357. "ui-spinner": "ui-corner-all",
  14358. "ui-spinner-down": "ui-corner-br",
  14359. "ui-spinner-up": "ui-corner-tr"
  14360. },
  14361. culture: null,
  14362. icons: {
  14363. down: "ui-icon-triangle-1-s",
  14364. up: "ui-icon-triangle-1-n"
  14365. },
  14366. incremental: true,
  14367. max: null,
  14368. min: null,
  14369. numberFormat: null,
  14370. page: 10,
  14371. step: 1,
  14372. change: null,
  14373. spin: null,
  14374. start: null,
  14375. stop: null
  14376. },
  14377. _create: function() {
  14378. // handle string values that need to be parsed
  14379. this._setOption( "max", this.options.max );
  14380. this._setOption( "min", this.options.min );
  14381. this._setOption( "step", this.options.step );
  14382. // Only format if there is a value, prevents the field from being marked
  14383. // as invalid in Firefox, see #9573.
  14384. if ( this.value() !== "" ) {
  14385. // Format the value, but don't constrain.
  14386. this._value( this.element.val(), true );
  14387. }
  14388. this._draw();
  14389. this._on( this._events );
  14390. this._refresh();
  14391. // Turning off autocomplete prevents the browser from remembering the
  14392. // value when navigating through history, so we re-enable autocomplete
  14393. // if the page is unloaded before the widget is destroyed. #7790
  14394. this._on( this.window, {
  14395. beforeunload: function() {
  14396. this.element.removeAttr( "autocomplete" );
  14397. }
  14398. } );
  14399. },
  14400. _getCreateOptions: function() {
  14401. var options = this._super();
  14402. var element = this.element;
  14403. $.each( [ "min", "max", "step" ], function( i, option ) {
  14404. var value = element.attr( option );
  14405. if ( value != null && value.length ) {
  14406. options[ option ] = value;
  14407. }
  14408. } );
  14409. return options;
  14410. },
  14411. _events: {
  14412. keydown: function( event ) {
  14413. if ( this._start( event ) && this._keydown( event ) ) {
  14414. event.preventDefault();
  14415. }
  14416. },
  14417. keyup: "_stop",
  14418. focus: function() {
  14419. this.previous = this.element.val();
  14420. },
  14421. blur: function( event ) {
  14422. if ( this.cancelBlur ) {
  14423. delete this.cancelBlur;
  14424. return;
  14425. }
  14426. this._stop();
  14427. this._refresh();
  14428. if ( this.previous !== this.element.val() ) {
  14429. this._trigger( "change", event );
  14430. }
  14431. },
  14432. mousewheel: function( event, delta ) {
  14433. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] );
  14434. var isActive = this.element[ 0 ] === activeElement;
  14435. if ( !isActive || !delta ) {
  14436. return;
  14437. }
  14438. if ( !this.spinning && !this._start( event ) ) {
  14439. return false;
  14440. }
  14441. this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
  14442. clearTimeout( this.mousewheelTimer );
  14443. this.mousewheelTimer = this._delay( function() {
  14444. if ( this.spinning ) {
  14445. this._stop( event );
  14446. }
  14447. }, 100 );
  14448. event.preventDefault();
  14449. },
  14450. "mousedown .ui-spinner-button": function( event ) {
  14451. var previous;
  14452. // We never want the buttons to have focus; whenever the user is
  14453. // interacting with the spinner, the focus should be on the input.
  14454. // If the input is focused then this.previous is properly set from
  14455. // when the input first received focus. If the input is not focused
  14456. // then we need to set this.previous based on the value before spinning.
  14457. previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
  14458. this.previous : this.element.val();
  14459. function checkFocus() {
  14460. var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
  14461. if ( !isActive ) {
  14462. this.element.trigger( "focus" );
  14463. this.previous = previous;
  14464. // support: IE
  14465. // IE sets focus asynchronously, so we need to check if focus
  14466. // moved off of the input because the user clicked on the button.
  14467. this._delay( function() {
  14468. this.previous = previous;
  14469. } );
  14470. }
  14471. }
  14472. // Ensure focus is on (or stays on) the text field
  14473. event.preventDefault();
  14474. checkFocus.call( this );
  14475. // Support: IE
  14476. // IE doesn't prevent moving focus even with event.preventDefault()
  14477. // so we set a flag to know when we should ignore the blur event
  14478. // and check (again) if focus moved off of the input.
  14479. this.cancelBlur = true;
  14480. this._delay( function() {
  14481. delete this.cancelBlur;
  14482. checkFocus.call( this );
  14483. } );
  14484. if ( this._start( event ) === false ) {
  14485. return;
  14486. }
  14487. this._repeat( null, $( event.currentTarget )
  14488. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14489. },
  14490. "mouseup .ui-spinner-button": "_stop",
  14491. "mouseenter .ui-spinner-button": function( event ) {
  14492. // button will add ui-state-active if mouse was down while mouseleave and kept down
  14493. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  14494. return;
  14495. }
  14496. if ( this._start( event ) === false ) {
  14497. return false;
  14498. }
  14499. this._repeat( null, $( event.currentTarget )
  14500. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14501. },
  14502. // TODO: do we really want to consider this a stop?
  14503. // shouldn't we just stop the repeater and wait until mouseup before
  14504. // we trigger the stop event?
  14505. "mouseleave .ui-spinner-button": "_stop"
  14506. },
  14507. // Support mobile enhanced option and make backcompat more sane
  14508. _enhance: function() {
  14509. this.uiSpinner = this.element
  14510. .attr( "autocomplete", "off" )
  14511. .wrap( "<span>" )
  14512. .parent()
  14513. // Add buttons
  14514. .append(
  14515. "<a></a><a></a>"
  14516. );
  14517. },
  14518. _draw: function() {
  14519. this._enhance();
  14520. this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
  14521. this._addClass( "ui-spinner-input" );
  14522. this.element.attr( "role", "spinbutton" );
  14523. // Button bindings
  14524. this.buttons = this.uiSpinner.children( "a" )
  14525. .attr( "tabIndex", -1 )
  14526. .attr( "aria-hidden", true )
  14527. .button( {
  14528. classes: {
  14529. "ui-button": ""
  14530. }
  14531. } );
  14532. // TODO: Right now button does not support classes this is already updated in button PR
  14533. this._removeClass( this.buttons, "ui-corner-all" );
  14534. this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
  14535. this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
  14536. this.buttons.first().button( {
  14537. "icon": this.options.icons.up,
  14538. "showLabel": false
  14539. } );
  14540. this.buttons.last().button( {
  14541. "icon": this.options.icons.down,
  14542. "showLabel": false
  14543. } );
  14544. // IE 6 doesn't understand height: 50% for the buttons
  14545. // unless the wrapper has an explicit height
  14546. if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
  14547. this.uiSpinner.height() > 0 ) {
  14548. this.uiSpinner.height( this.uiSpinner.height() );
  14549. }
  14550. },
  14551. _keydown: function( event ) {
  14552. var options = this.options,
  14553. keyCode = $.ui.keyCode;
  14554. switch ( event.keyCode ) {
  14555. case keyCode.UP:
  14556. this._repeat( null, 1, event );
  14557. return true;
  14558. case keyCode.DOWN:
  14559. this._repeat( null, -1, event );
  14560. return true;
  14561. case keyCode.PAGE_UP:
  14562. this._repeat( null, options.page, event );
  14563. return true;
  14564. case keyCode.PAGE_DOWN:
  14565. this._repeat( null, -options.page, event );
  14566. return true;
  14567. }
  14568. return false;
  14569. },
  14570. _start: function( event ) {
  14571. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  14572. return false;
  14573. }
  14574. if ( !this.counter ) {
  14575. this.counter = 1;
  14576. }
  14577. this.spinning = true;
  14578. return true;
  14579. },
  14580. _repeat: function( i, steps, event ) {
  14581. i = i || 500;
  14582. clearTimeout( this.timer );
  14583. this.timer = this._delay( function() {
  14584. this._repeat( 40, steps, event );
  14585. }, i );
  14586. this._spin( steps * this.options.step, event );
  14587. },
  14588. _spin: function( step, event ) {
  14589. var value = this.value() || 0;
  14590. if ( !this.counter ) {
  14591. this.counter = 1;
  14592. }
  14593. value = this._adjustValue( value + step * this._increment( this.counter ) );
  14594. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
  14595. this._value( value );
  14596. this.counter++;
  14597. }
  14598. },
  14599. _increment: function( i ) {
  14600. var incremental = this.options.incremental;
  14601. if ( incremental ) {
  14602. return typeof incremental === "function" ?
  14603. incremental( i ) :
  14604. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  14605. }
  14606. return 1;
  14607. },
  14608. _precision: function() {
  14609. var precision = this._precisionOf( this.options.step );
  14610. if ( this.options.min !== null ) {
  14611. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  14612. }
  14613. return precision;
  14614. },
  14615. _precisionOf: function( num ) {
  14616. var str = num.toString(),
  14617. decimal = str.indexOf( "." );
  14618. return decimal === -1 ? 0 : str.length - decimal - 1;
  14619. },
  14620. _adjustValue: function( value ) {
  14621. var base, aboveMin,
  14622. options = this.options;
  14623. // Make sure we're at a valid step
  14624. // - find out where we are relative to the base (min or 0)
  14625. base = options.min !== null ? options.min : 0;
  14626. aboveMin = value - base;
  14627. // - round to the nearest step
  14628. aboveMin = Math.round( aboveMin / options.step ) * options.step;
  14629. // - rounding is based on 0, so adjust back to our base
  14630. value = base + aboveMin;
  14631. // Fix precision from bad JS floating point math
  14632. value = parseFloat( value.toFixed( this._precision() ) );
  14633. // Clamp the value
  14634. if ( options.max !== null && value > options.max ) {
  14635. return options.max;
  14636. }
  14637. if ( options.min !== null && value < options.min ) {
  14638. return options.min;
  14639. }
  14640. return value;
  14641. },
  14642. _stop: function( event ) {
  14643. if ( !this.spinning ) {
  14644. return;
  14645. }
  14646. clearTimeout( this.timer );
  14647. clearTimeout( this.mousewheelTimer );
  14648. this.counter = 0;
  14649. this.spinning = false;
  14650. this._trigger( "stop", event );
  14651. },
  14652. _setOption: function( key, value ) {
  14653. var prevValue, first, last;
  14654. if ( key === "culture" || key === "numberFormat" ) {
  14655. prevValue = this._parse( this.element.val() );
  14656. this.options[ key ] = value;
  14657. this.element.val( this._format( prevValue ) );
  14658. return;
  14659. }
  14660. if ( key === "max" || key === "min" || key === "step" ) {
  14661. if ( typeof value === "string" ) {
  14662. value = this._parse( value );
  14663. }
  14664. }
  14665. if ( key === "icons" ) {
  14666. first = this.buttons.first().find( ".ui-icon" );
  14667. this._removeClass( first, null, this.options.icons.up );
  14668. this._addClass( first, null, value.up );
  14669. last = this.buttons.last().find( ".ui-icon" );
  14670. this._removeClass( last, null, this.options.icons.down );
  14671. this._addClass( last, null, value.down );
  14672. }
  14673. this._super( key, value );
  14674. },
  14675. _setOptionDisabled: function( value ) {
  14676. this._super( value );
  14677. this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
  14678. this.element.prop( "disabled", !!value );
  14679. this.buttons.button( value ? "disable" : "enable" );
  14680. },
  14681. _setOptions: spinnerModifier( function( options ) {
  14682. this._super( options );
  14683. } ),
  14684. _parse: function( val ) {
  14685. if ( typeof val === "string" && val !== "" ) {
  14686. val = window.Globalize && this.options.numberFormat ?
  14687. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  14688. }
  14689. return val === "" || isNaN( val ) ? null : val;
  14690. },
  14691. _format: function( value ) {
  14692. if ( value === "" ) {
  14693. return "";
  14694. }
  14695. return window.Globalize && this.options.numberFormat ?
  14696. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  14697. value;
  14698. },
  14699. _refresh: function() {
  14700. this.element.attr( {
  14701. "aria-valuemin": this.options.min,
  14702. "aria-valuemax": this.options.max,
  14703. // TODO: what should we do with values that can't be parsed?
  14704. "aria-valuenow": this._parse( this.element.val() )
  14705. } );
  14706. },
  14707. isValid: function() {
  14708. var value = this.value();
  14709. // Null is invalid
  14710. if ( value === null ) {
  14711. return false;
  14712. }
  14713. // If value gets adjusted, it's invalid
  14714. return value === this._adjustValue( value );
  14715. },
  14716. // Update the value without triggering change
  14717. _value: function( value, allowAny ) {
  14718. var parsed;
  14719. if ( value !== "" ) {
  14720. parsed = this._parse( value );
  14721. if ( parsed !== null ) {
  14722. if ( !allowAny ) {
  14723. parsed = this._adjustValue( parsed );
  14724. }
  14725. value = this._format( parsed );
  14726. }
  14727. }
  14728. this.element.val( value );
  14729. this._refresh();
  14730. },
  14731. _destroy: function() {
  14732. this.element
  14733. .prop( "disabled", false )
  14734. .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
  14735. this.uiSpinner.replaceWith( this.element );
  14736. },
  14737. stepUp: spinnerModifier( function( steps ) {
  14738. this._stepUp( steps );
  14739. } ),
  14740. _stepUp: function( steps ) {
  14741. if ( this._start() ) {
  14742. this._spin( ( steps || 1 ) * this.options.step );
  14743. this._stop();
  14744. }
  14745. },
  14746. stepDown: spinnerModifier( function( steps ) {
  14747. this._stepDown( steps );
  14748. } ),
  14749. _stepDown: function( steps ) {
  14750. if ( this._start() ) {
  14751. this._spin( ( steps || 1 ) * -this.options.step );
  14752. this._stop();
  14753. }
  14754. },
  14755. pageUp: spinnerModifier( function( pages ) {
  14756. this._stepUp( ( pages || 1 ) * this.options.page );
  14757. } ),
  14758. pageDown: spinnerModifier( function( pages ) {
  14759. this._stepDown( ( pages || 1 ) * this.options.page );
  14760. } ),
  14761. value: function( newVal ) {
  14762. if ( !arguments.length ) {
  14763. return this._parse( this.element.val() );
  14764. }
  14765. spinnerModifier( this._value ).call( this, newVal );
  14766. },
  14767. widget: function() {
  14768. return this.uiSpinner;
  14769. }
  14770. } );
  14771. // DEPRECATED
  14772. // TODO: switch return back to widget declaration at top of file when this is removed
  14773. if ( $.uiBackCompat !== false ) {
  14774. // Backcompat for spinner html extension points
  14775. $.widget( "ui.spinner", $.ui.spinner, {
  14776. _enhance: function() {
  14777. this.uiSpinner = this.element
  14778. .attr( "autocomplete", "off" )
  14779. .wrap( this._uiSpinnerHtml() )
  14780. .parent()
  14781. // Add buttons
  14782. .append( this._buttonHtml() );
  14783. },
  14784. _uiSpinnerHtml: function() {
  14785. return "<span>";
  14786. },
  14787. _buttonHtml: function() {
  14788. return "<a></a><a></a>";
  14789. }
  14790. } );
  14791. }
  14792. var widgetsSpinner = $.ui.spinner;
  14793. /*!
  14794. * jQuery UI Tabs 1.13.0
  14795. * http://jqueryui.com
  14796. *
  14797. * Copyright jQuery Foundation and other contributors
  14798. * Released under the MIT license.
  14799. * http://jquery.org/license
  14800. */
  14801. //>>label: Tabs
  14802. //>>group: Widgets
  14803. //>>description: Transforms a set of container elements into a tab structure.
  14804. //>>docs: http://api.jqueryui.com/tabs/
  14805. //>>demos: http://jqueryui.com/tabs/
  14806. //>>css.structure: ../../themes/base/core.css
  14807. //>>css.structure: ../../themes/base/tabs.css
  14808. //>>css.theme: ../../themes/base/theme.css
  14809. $.widget( "ui.tabs", {
  14810. version: "1.13.0",
  14811. delay: 300,
  14812. options: {
  14813. active: null,
  14814. classes: {
  14815. "ui-tabs": "ui-corner-all",
  14816. "ui-tabs-nav": "ui-corner-all",
  14817. "ui-tabs-panel": "ui-corner-bottom",
  14818. "ui-tabs-tab": "ui-corner-top"
  14819. },
  14820. collapsible: false,
  14821. event: "click",
  14822. heightStyle: "content",
  14823. hide: null,
  14824. show: null,
  14825. // Callbacks
  14826. activate: null,
  14827. beforeActivate: null,
  14828. beforeLoad: null,
  14829. load: null
  14830. },
  14831. _isLocal: ( function() {
  14832. var rhash = /#.*$/;
  14833. return function( anchor ) {
  14834. var anchorUrl, locationUrl;
  14835. anchorUrl = anchor.href.replace( rhash, "" );
  14836. locationUrl = location.href.replace( rhash, "" );
  14837. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  14838. try {
  14839. anchorUrl = decodeURIComponent( anchorUrl );
  14840. } catch ( error ) {}
  14841. try {
  14842. locationUrl = decodeURIComponent( locationUrl );
  14843. } catch ( error ) {}
  14844. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  14845. };
  14846. } )(),
  14847. _create: function() {
  14848. var that = this,
  14849. options = this.options;
  14850. this.running = false;
  14851. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  14852. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  14853. this._processTabs();
  14854. options.active = this._initialActive();
  14855. // Take disabling tabs via class attribute from HTML
  14856. // into account and update option properly.
  14857. if ( Array.isArray( options.disabled ) ) {
  14858. options.disabled = $.uniqueSort( options.disabled.concat(
  14859. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  14860. return that.tabs.index( li );
  14861. } )
  14862. ) ).sort();
  14863. }
  14864. // Check for length avoids error when initializing empty list
  14865. if ( this.options.active !== false && this.anchors.length ) {
  14866. this.active = this._findActive( options.active );
  14867. } else {
  14868. this.active = $();
  14869. }
  14870. this._refresh();
  14871. if ( this.active.length ) {
  14872. this.load( options.active );
  14873. }
  14874. },
  14875. _initialActive: function() {
  14876. var active = this.options.active,
  14877. collapsible = this.options.collapsible,
  14878. locationHash = location.hash.substring( 1 );
  14879. if ( active === null ) {
  14880. // check the fragment identifier in the URL
  14881. if ( locationHash ) {
  14882. this.tabs.each( function( i, tab ) {
  14883. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  14884. active = i;
  14885. return false;
  14886. }
  14887. } );
  14888. }
  14889. // Check for a tab marked active via a class
  14890. if ( active === null ) {
  14891. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  14892. }
  14893. // No active tab, set to false
  14894. if ( active === null || active === -1 ) {
  14895. active = this.tabs.length ? 0 : false;
  14896. }
  14897. }
  14898. // Handle numbers: negative, out of range
  14899. if ( active !== false ) {
  14900. active = this.tabs.index( this.tabs.eq( active ) );
  14901. if ( active === -1 ) {
  14902. active = collapsible ? false : 0;
  14903. }
  14904. }
  14905. // Don't allow collapsible: false and active: false
  14906. if ( !collapsible && active === false && this.anchors.length ) {
  14907. active = 0;
  14908. }
  14909. return active;
  14910. },
  14911. _getCreateEventData: function() {
  14912. return {
  14913. tab: this.active,
  14914. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  14915. };
  14916. },
  14917. _tabKeydown: function( event ) {
  14918. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  14919. selectedIndex = this.tabs.index( focusedTab ),
  14920. goingForward = true;
  14921. if ( this._handlePageNav( event ) ) {
  14922. return;
  14923. }
  14924. switch ( event.keyCode ) {
  14925. case $.ui.keyCode.RIGHT:
  14926. case $.ui.keyCode.DOWN:
  14927. selectedIndex++;
  14928. break;
  14929. case $.ui.keyCode.UP:
  14930. case $.ui.keyCode.LEFT:
  14931. goingForward = false;
  14932. selectedIndex--;
  14933. break;
  14934. case $.ui.keyCode.END:
  14935. selectedIndex = this.anchors.length - 1;
  14936. break;
  14937. case $.ui.keyCode.HOME:
  14938. selectedIndex = 0;
  14939. break;
  14940. case $.ui.keyCode.SPACE:
  14941. // Activate only, no collapsing
  14942. event.preventDefault();
  14943. clearTimeout( this.activating );
  14944. this._activate( selectedIndex );
  14945. return;
  14946. case $.ui.keyCode.ENTER:
  14947. // Toggle (cancel delayed activation, allow collapsing)
  14948. event.preventDefault();
  14949. clearTimeout( this.activating );
  14950. // Determine if we should collapse or activate
  14951. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  14952. return;
  14953. default:
  14954. return;
  14955. }
  14956. // Focus the appropriate tab, based on which key was pressed
  14957. event.preventDefault();
  14958. clearTimeout( this.activating );
  14959. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  14960. // Navigating with control/command key will prevent automatic activation
  14961. if ( !event.ctrlKey && !event.metaKey ) {
  14962. // Update aria-selected immediately so that AT think the tab is already selected.
  14963. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  14964. // but the tab will already be activated by the time the announcement finishes.
  14965. focusedTab.attr( "aria-selected", "false" );
  14966. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  14967. this.activating = this._delay( function() {
  14968. this.option( "active", selectedIndex );
  14969. }, this.delay );
  14970. }
  14971. },
  14972. _panelKeydown: function( event ) {
  14973. if ( this._handlePageNav( event ) ) {
  14974. return;
  14975. }
  14976. // Ctrl+up moves focus to the current tab
  14977. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  14978. event.preventDefault();
  14979. this.active.trigger( "focus" );
  14980. }
  14981. },
  14982. // Alt+page up/down moves focus to the previous/next tab (and activates)
  14983. _handlePageNav: function( event ) {
  14984. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  14985. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  14986. return true;
  14987. }
  14988. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  14989. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  14990. return true;
  14991. }
  14992. },
  14993. _findNextTab: function( index, goingForward ) {
  14994. var lastTabIndex = this.tabs.length - 1;
  14995. function constrain() {
  14996. if ( index > lastTabIndex ) {
  14997. index = 0;
  14998. }
  14999. if ( index < 0 ) {
  15000. index = lastTabIndex;
  15001. }
  15002. return index;
  15003. }
  15004. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  15005. index = goingForward ? index + 1 : index - 1;
  15006. }
  15007. return index;
  15008. },
  15009. _focusNextTab: function( index, goingForward ) {
  15010. index = this._findNextTab( index, goingForward );
  15011. this.tabs.eq( index ).trigger( "focus" );
  15012. return index;
  15013. },
  15014. _setOption: function( key, value ) {
  15015. if ( key === "active" ) {
  15016. // _activate() will handle invalid values and update this.options
  15017. this._activate( value );
  15018. return;
  15019. }
  15020. this._super( key, value );
  15021. if ( key === "collapsible" ) {
  15022. this._toggleClass( "ui-tabs-collapsible", null, value );
  15023. // Setting collapsible: false while collapsed; open first panel
  15024. if ( !value && this.options.active === false ) {
  15025. this._activate( 0 );
  15026. }
  15027. }
  15028. if ( key === "event" ) {
  15029. this._setupEvents( value );
  15030. }
  15031. if ( key === "heightStyle" ) {
  15032. this._setupHeightStyle( value );
  15033. }
  15034. },
  15035. _sanitizeSelector: function( hash ) {
  15036. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  15037. },
  15038. refresh: function() {
  15039. var options = this.options,
  15040. lis = this.tablist.children( ":has(a[href])" );
  15041. // Get disabled tabs from class attribute from HTML
  15042. // this will get converted to a boolean if needed in _refresh()
  15043. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  15044. return lis.index( tab );
  15045. } );
  15046. this._processTabs();
  15047. // Was collapsed or no tabs
  15048. if ( options.active === false || !this.anchors.length ) {
  15049. options.active = false;
  15050. this.active = $();
  15051. // was active, but active tab is gone
  15052. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  15053. // all remaining tabs are disabled
  15054. if ( this.tabs.length === options.disabled.length ) {
  15055. options.active = false;
  15056. this.active = $();
  15057. // activate previous tab
  15058. } else {
  15059. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  15060. }
  15061. // was active, active tab still exists
  15062. } else {
  15063. // make sure active index is correct
  15064. options.active = this.tabs.index( this.active );
  15065. }
  15066. this._refresh();
  15067. },
  15068. _refresh: function() {
  15069. this._setOptionDisabled( this.options.disabled );
  15070. this._setupEvents( this.options.event );
  15071. this._setupHeightStyle( this.options.heightStyle );
  15072. this.tabs.not( this.active ).attr( {
  15073. "aria-selected": "false",
  15074. "aria-expanded": "false",
  15075. tabIndex: -1
  15076. } );
  15077. this.panels.not( this._getPanelForTab( this.active ) )
  15078. .hide()
  15079. .attr( {
  15080. "aria-hidden": "true"
  15081. } );
  15082. // Make sure one tab is in the tab order
  15083. if ( !this.active.length ) {
  15084. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  15085. } else {
  15086. this.active
  15087. .attr( {
  15088. "aria-selected": "true",
  15089. "aria-expanded": "true",
  15090. tabIndex: 0
  15091. } );
  15092. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  15093. this._getPanelForTab( this.active )
  15094. .show()
  15095. .attr( {
  15096. "aria-hidden": "false"
  15097. } );
  15098. }
  15099. },
  15100. _processTabs: function() {
  15101. var that = this,
  15102. prevTabs = this.tabs,
  15103. prevAnchors = this.anchors,
  15104. prevPanels = this.panels;
  15105. this.tablist = this._getList().attr( "role", "tablist" );
  15106. this._addClass( this.tablist, "ui-tabs-nav",
  15107. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  15108. // Prevent users from focusing disabled tabs via click
  15109. this.tablist
  15110. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  15111. if ( $( this ).is( ".ui-state-disabled" ) ) {
  15112. event.preventDefault();
  15113. }
  15114. } )
  15115. // Support: IE <9
  15116. // Preventing the default action in mousedown doesn't prevent IE
  15117. // from focusing the element, so if the anchor gets focused, blur.
  15118. // We don't have to worry about focusing the previously focused
  15119. // element since clicking on a non-focusable element should focus
  15120. // the body anyway.
  15121. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  15122. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  15123. this.blur();
  15124. }
  15125. } );
  15126. this.tabs = this.tablist.find( "> li:has(a[href])" )
  15127. .attr( {
  15128. role: "tab",
  15129. tabIndex: -1
  15130. } );
  15131. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  15132. this.anchors = this.tabs.map( function() {
  15133. return $( "a", this )[ 0 ];
  15134. } )
  15135. .attr( {
  15136. tabIndex: -1
  15137. } );
  15138. this._addClass( this.anchors, "ui-tabs-anchor" );
  15139. this.panels = $();
  15140. this.anchors.each( function( i, anchor ) {
  15141. var selector, panel, panelId,
  15142. anchorId = $( anchor ).uniqueId().attr( "id" ),
  15143. tab = $( anchor ).closest( "li" ),
  15144. originalAriaControls = tab.attr( "aria-controls" );
  15145. // Inline tab
  15146. if ( that._isLocal( anchor ) ) {
  15147. selector = anchor.hash;
  15148. panelId = selector.substring( 1 );
  15149. panel = that.element.find( that._sanitizeSelector( selector ) );
  15150. // remote tab
  15151. } else {
  15152. // If the tab doesn't already have aria-controls,
  15153. // generate an id by using a throw-away element
  15154. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  15155. selector = "#" + panelId;
  15156. panel = that.element.find( selector );
  15157. if ( !panel.length ) {
  15158. panel = that._createPanel( panelId );
  15159. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  15160. }
  15161. panel.attr( "aria-live", "polite" );
  15162. }
  15163. if ( panel.length ) {
  15164. that.panels = that.panels.add( panel );
  15165. }
  15166. if ( originalAriaControls ) {
  15167. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  15168. }
  15169. tab.attr( {
  15170. "aria-controls": panelId,
  15171. "aria-labelledby": anchorId
  15172. } );
  15173. panel.attr( "aria-labelledby", anchorId );
  15174. } );
  15175. this.panels.attr( "role", "tabpanel" );
  15176. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  15177. // Avoid memory leaks (#10056)
  15178. if ( prevTabs ) {
  15179. this._off( prevTabs.not( this.tabs ) );
  15180. this._off( prevAnchors.not( this.anchors ) );
  15181. this._off( prevPanels.not( this.panels ) );
  15182. }
  15183. },
  15184. // Allow overriding how to find the list for rare usage scenarios (#7715)
  15185. _getList: function() {
  15186. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  15187. },
  15188. _createPanel: function( id ) {
  15189. return $( "<div>" )
  15190. .attr( "id", id )
  15191. .data( "ui-tabs-destroy", true );
  15192. },
  15193. _setOptionDisabled: function( disabled ) {
  15194. var currentItem, li, i;
  15195. if ( Array.isArray( disabled ) ) {
  15196. if ( !disabled.length ) {
  15197. disabled = false;
  15198. } else if ( disabled.length === this.anchors.length ) {
  15199. disabled = true;
  15200. }
  15201. }
  15202. // Disable tabs
  15203. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  15204. currentItem = $( li );
  15205. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  15206. currentItem.attr( "aria-disabled", "true" );
  15207. this._addClass( currentItem, null, "ui-state-disabled" );
  15208. } else {
  15209. currentItem.removeAttr( "aria-disabled" );
  15210. this._removeClass( currentItem, null, "ui-state-disabled" );
  15211. }
  15212. }
  15213. this.options.disabled = disabled;
  15214. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  15215. disabled === true );
  15216. },
  15217. _setupEvents: function( event ) {
  15218. var events = {};
  15219. if ( event ) {
  15220. $.each( event.split( " " ), function( index, eventName ) {
  15221. events[ eventName ] = "_eventHandler";
  15222. } );
  15223. }
  15224. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  15225. // Always prevent the default action, even when disabled
  15226. this._on( true, this.anchors, {
  15227. click: function( event ) {
  15228. event.preventDefault();
  15229. }
  15230. } );
  15231. this._on( this.anchors, events );
  15232. this._on( this.tabs, { keydown: "_tabKeydown" } );
  15233. this._on( this.panels, { keydown: "_panelKeydown" } );
  15234. this._focusable( this.tabs );
  15235. this._hoverable( this.tabs );
  15236. },
  15237. _setupHeightStyle: function( heightStyle ) {
  15238. var maxHeight,
  15239. parent = this.element.parent();
  15240. if ( heightStyle === "fill" ) {
  15241. maxHeight = parent.height();
  15242. maxHeight -= this.element.outerHeight() - this.element.height();
  15243. this.element.siblings( ":visible" ).each( function() {
  15244. var elem = $( this ),
  15245. position = elem.css( "position" );
  15246. if ( position === "absolute" || position === "fixed" ) {
  15247. return;
  15248. }
  15249. maxHeight -= elem.outerHeight( true );
  15250. } );
  15251. this.element.children().not( this.panels ).each( function() {
  15252. maxHeight -= $( this ).outerHeight( true );
  15253. } );
  15254. this.panels.each( function() {
  15255. $( this ).height( Math.max( 0, maxHeight -
  15256. $( this ).innerHeight() + $( this ).height() ) );
  15257. } )
  15258. .css( "overflow", "auto" );
  15259. } else if ( heightStyle === "auto" ) {
  15260. maxHeight = 0;
  15261. this.panels.each( function() {
  15262. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  15263. } ).height( maxHeight );
  15264. }
  15265. },
  15266. _eventHandler: function( event ) {
  15267. var options = this.options,
  15268. active = this.active,
  15269. anchor = $( event.currentTarget ),
  15270. tab = anchor.closest( "li" ),
  15271. clickedIsActive = tab[ 0 ] === active[ 0 ],
  15272. collapsing = clickedIsActive && options.collapsible,
  15273. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  15274. toHide = !active.length ? $() : this._getPanelForTab( active ),
  15275. eventData = {
  15276. oldTab: active,
  15277. oldPanel: toHide,
  15278. newTab: collapsing ? $() : tab,
  15279. newPanel: toShow
  15280. };
  15281. event.preventDefault();
  15282. if ( tab.hasClass( "ui-state-disabled" ) ||
  15283. // tab is already loading
  15284. tab.hasClass( "ui-tabs-loading" ) ||
  15285. // can't switch durning an animation
  15286. this.running ||
  15287. // click on active header, but not collapsible
  15288. ( clickedIsActive && !options.collapsible ) ||
  15289. // allow canceling activation
  15290. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  15291. return;
  15292. }
  15293. options.active = collapsing ? false : this.tabs.index( tab );
  15294. this.active = clickedIsActive ? $() : tab;
  15295. if ( this.xhr ) {
  15296. this.xhr.abort();
  15297. }
  15298. if ( !toHide.length && !toShow.length ) {
  15299. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  15300. }
  15301. if ( toShow.length ) {
  15302. this.load( this.tabs.index( tab ), event );
  15303. }
  15304. this._toggle( event, eventData );
  15305. },
  15306. // Handles show/hide for selecting tabs
  15307. _toggle: function( event, eventData ) {
  15308. var that = this,
  15309. toShow = eventData.newPanel,
  15310. toHide = eventData.oldPanel;
  15311. this.running = true;
  15312. function complete() {
  15313. that.running = false;
  15314. that._trigger( "activate", event, eventData );
  15315. }
  15316. function show() {
  15317. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  15318. if ( toShow.length && that.options.show ) {
  15319. that._show( toShow, that.options.show, complete );
  15320. } else {
  15321. toShow.show();
  15322. complete();
  15323. }
  15324. }
  15325. // Start out by hiding, then showing, then completing
  15326. if ( toHide.length && this.options.hide ) {
  15327. this._hide( toHide, this.options.hide, function() {
  15328. that._removeClass( eventData.oldTab.closest( "li" ),
  15329. "ui-tabs-active", "ui-state-active" );
  15330. show();
  15331. } );
  15332. } else {
  15333. this._removeClass( eventData.oldTab.closest( "li" ),
  15334. "ui-tabs-active", "ui-state-active" );
  15335. toHide.hide();
  15336. show();
  15337. }
  15338. toHide.attr( "aria-hidden", "true" );
  15339. eventData.oldTab.attr( {
  15340. "aria-selected": "false",
  15341. "aria-expanded": "false"
  15342. } );
  15343. // If we're switching tabs, remove the old tab from the tab order.
  15344. // If we're opening from collapsed state, remove the previous tab from the tab order.
  15345. // If we're collapsing, then keep the collapsing tab in the tab order.
  15346. if ( toShow.length && toHide.length ) {
  15347. eventData.oldTab.attr( "tabIndex", -1 );
  15348. } else if ( toShow.length ) {
  15349. this.tabs.filter( function() {
  15350. return $( this ).attr( "tabIndex" ) === 0;
  15351. } )
  15352. .attr( "tabIndex", -1 );
  15353. }
  15354. toShow.attr( "aria-hidden", "false" );
  15355. eventData.newTab.attr( {
  15356. "aria-selected": "true",
  15357. "aria-expanded": "true",
  15358. tabIndex: 0
  15359. } );
  15360. },
  15361. _activate: function( index ) {
  15362. var anchor,
  15363. active = this._findActive( index );
  15364. // Trying to activate the already active panel
  15365. if ( active[ 0 ] === this.active[ 0 ] ) {
  15366. return;
  15367. }
  15368. // Trying to collapse, simulate a click on the current active header
  15369. if ( !active.length ) {
  15370. active = this.active;
  15371. }
  15372. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  15373. this._eventHandler( {
  15374. target: anchor,
  15375. currentTarget: anchor,
  15376. preventDefault: $.noop
  15377. } );
  15378. },
  15379. _findActive: function( index ) {
  15380. return index === false ? $() : this.tabs.eq( index );
  15381. },
  15382. _getIndex: function( index ) {
  15383. // meta-function to give users option to provide a href string instead of a numerical index.
  15384. if ( typeof index === "string" ) {
  15385. index = this.anchors.index( this.anchors.filter( "[href$='" +
  15386. $.escapeSelector( index ) + "']" ) );
  15387. }
  15388. return index;
  15389. },
  15390. _destroy: function() {
  15391. if ( this.xhr ) {
  15392. this.xhr.abort();
  15393. }
  15394. this.tablist
  15395. .removeAttr( "role" )
  15396. .off( this.eventNamespace );
  15397. this.anchors
  15398. .removeAttr( "role tabIndex" )
  15399. .removeUniqueId();
  15400. this.tabs.add( this.panels ).each( function() {
  15401. if ( $.data( this, "ui-tabs-destroy" ) ) {
  15402. $( this ).remove();
  15403. } else {
  15404. $( this ).removeAttr( "role tabIndex " +
  15405. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  15406. }
  15407. } );
  15408. this.tabs.each( function() {
  15409. var li = $( this ),
  15410. prev = li.data( "ui-tabs-aria-controls" );
  15411. if ( prev ) {
  15412. li
  15413. .attr( "aria-controls", prev )
  15414. .removeData( "ui-tabs-aria-controls" );
  15415. } else {
  15416. li.removeAttr( "aria-controls" );
  15417. }
  15418. } );
  15419. this.panels.show();
  15420. if ( this.options.heightStyle !== "content" ) {
  15421. this.panels.css( "height", "" );
  15422. }
  15423. },
  15424. enable: function( index ) {
  15425. var disabled = this.options.disabled;
  15426. if ( disabled === false ) {
  15427. return;
  15428. }
  15429. if ( index === undefined ) {
  15430. disabled = false;
  15431. } else {
  15432. index = this._getIndex( index );
  15433. if ( Array.isArray( disabled ) ) {
  15434. disabled = $.map( disabled, function( num ) {
  15435. return num !== index ? num : null;
  15436. } );
  15437. } else {
  15438. disabled = $.map( this.tabs, function( li, num ) {
  15439. return num !== index ? num : null;
  15440. } );
  15441. }
  15442. }
  15443. this._setOptionDisabled( disabled );
  15444. },
  15445. disable: function( index ) {
  15446. var disabled = this.options.disabled;
  15447. if ( disabled === true ) {
  15448. return;
  15449. }
  15450. if ( index === undefined ) {
  15451. disabled = true;
  15452. } else {
  15453. index = this._getIndex( index );
  15454. if ( $.inArray( index, disabled ) !== -1 ) {
  15455. return;
  15456. }
  15457. if ( Array.isArray( disabled ) ) {
  15458. disabled = $.merge( [ index ], disabled ).sort();
  15459. } else {
  15460. disabled = [ index ];
  15461. }
  15462. }
  15463. this._setOptionDisabled( disabled );
  15464. },
  15465. load: function( index, event ) {
  15466. index = this._getIndex( index );
  15467. var that = this,
  15468. tab = this.tabs.eq( index ),
  15469. anchor = tab.find( ".ui-tabs-anchor" ),
  15470. panel = this._getPanelForTab( tab ),
  15471. eventData = {
  15472. tab: tab,
  15473. panel: panel
  15474. },
  15475. complete = function( jqXHR, status ) {
  15476. if ( status === "abort" ) {
  15477. that.panels.stop( false, true );
  15478. }
  15479. that._removeClass( tab, "ui-tabs-loading" );
  15480. panel.removeAttr( "aria-busy" );
  15481. if ( jqXHR === that.xhr ) {
  15482. delete that.xhr;
  15483. }
  15484. };
  15485. // Not remote
  15486. if ( this._isLocal( anchor[ 0 ] ) ) {
  15487. return;
  15488. }
  15489. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  15490. // Support: jQuery <1.8
  15491. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  15492. // but as of 1.8, $.ajax() always returns a jqXHR object.
  15493. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  15494. this._addClass( tab, "ui-tabs-loading" );
  15495. panel.attr( "aria-busy", "true" );
  15496. this.xhr
  15497. .done( function( response, status, jqXHR ) {
  15498. // support: jQuery <1.8
  15499. // http://bugs.jquery.com/ticket/11778
  15500. setTimeout( function() {
  15501. panel.html( response );
  15502. that._trigger( "load", event, eventData );
  15503. complete( jqXHR, status );
  15504. }, 1 );
  15505. } )
  15506. .fail( function( jqXHR, status ) {
  15507. // support: jQuery <1.8
  15508. // http://bugs.jquery.com/ticket/11778
  15509. setTimeout( function() {
  15510. complete( jqXHR, status );
  15511. }, 1 );
  15512. } );
  15513. }
  15514. },
  15515. _ajaxSettings: function( anchor, event, eventData ) {
  15516. var that = this;
  15517. return {
  15518. // Support: IE <11 only
  15519. // Strip any hash that exists to prevent errors with the Ajax request
  15520. url: anchor.attr( "href" ).replace( /#.*$/, "" ),
  15521. beforeSend: function( jqXHR, settings ) {
  15522. return that._trigger( "beforeLoad", event,
  15523. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  15524. }
  15525. };
  15526. },
  15527. _getPanelForTab: function( tab ) {
  15528. var id = $( tab ).attr( "aria-controls" );
  15529. return this.element.find( this._sanitizeSelector( "#" + id ) );
  15530. }
  15531. } );
  15532. // DEPRECATED
  15533. // TODO: Switch return back to widget declaration at top of file when this is removed
  15534. if ( $.uiBackCompat !== false ) {
  15535. // Backcompat for ui-tab class (now ui-tabs-tab)
  15536. $.widget( "ui.tabs", $.ui.tabs, {
  15537. _processTabs: function() {
  15538. this._superApply( arguments );
  15539. this._addClass( this.tabs, "ui-tab" );
  15540. }
  15541. } );
  15542. }
  15543. var widgetsTabs = $.ui.tabs;
  15544. /*!
  15545. * jQuery UI Tooltip 1.13.0
  15546. * http://jqueryui.com
  15547. *
  15548. * Copyright jQuery Foundation and other contributors
  15549. * Released under the MIT license.
  15550. * http://jquery.org/license
  15551. */
  15552. //>>label: Tooltip
  15553. //>>group: Widgets
  15554. //>>description: Shows additional information for any element on hover or focus.
  15555. //>>docs: http://api.jqueryui.com/tooltip/
  15556. //>>demos: http://jqueryui.com/tooltip/
  15557. //>>css.structure: ../../themes/base/core.css
  15558. //>>css.structure: ../../themes/base/tooltip.css
  15559. //>>css.theme: ../../themes/base/theme.css
  15560. $.widget( "ui.tooltip", {
  15561. version: "1.13.0",
  15562. options: {
  15563. classes: {
  15564. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  15565. },
  15566. content: function() {
  15567. var title = $( this ).attr( "title" );
  15568. // Escape title, since we're going from an attribute to raw HTML
  15569. return $( "<a>" ).text( title ).html();
  15570. },
  15571. hide: true,
  15572. // Disabled elements have inconsistent behavior across browsers (#8661)
  15573. items: "[title]:not([disabled])",
  15574. position: {
  15575. my: "left top+15",
  15576. at: "left bottom",
  15577. collision: "flipfit flip"
  15578. },
  15579. show: true,
  15580. track: false,
  15581. // Callbacks
  15582. close: null,
  15583. open: null
  15584. },
  15585. _addDescribedBy: function( elem, id ) {
  15586. var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
  15587. describedby.push( id );
  15588. elem
  15589. .data( "ui-tooltip-id", id )
  15590. .attr( "aria-describedby", String.prototype.trim.call( describedby.join( " " ) ) );
  15591. },
  15592. _removeDescribedBy: function( elem ) {
  15593. var id = elem.data( "ui-tooltip-id" ),
  15594. describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
  15595. index = $.inArray( id, describedby );
  15596. if ( index !== -1 ) {
  15597. describedby.splice( index, 1 );
  15598. }
  15599. elem.removeData( "ui-tooltip-id" );
  15600. describedby = String.prototype.trim.call( describedby.join( " " ) );
  15601. if ( describedby ) {
  15602. elem.attr( "aria-describedby", describedby );
  15603. } else {
  15604. elem.removeAttr( "aria-describedby" );
  15605. }
  15606. },
  15607. _create: function() {
  15608. this._on( {
  15609. mouseover: "open",
  15610. focusin: "open"
  15611. } );
  15612. // IDs of generated tooltips, needed for destroy
  15613. this.tooltips = {};
  15614. // IDs of parent tooltips where we removed the title attribute
  15615. this.parents = {};
  15616. // Append the aria-live region so tooltips announce correctly
  15617. this.liveRegion = $( "<div>" )
  15618. .attr( {
  15619. role: "log",
  15620. "aria-live": "assertive",
  15621. "aria-relevant": "additions"
  15622. } )
  15623. .appendTo( this.document[ 0 ].body );
  15624. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  15625. this.disabledTitles = $( [] );
  15626. },
  15627. _setOption: function( key, value ) {
  15628. var that = this;
  15629. this._super( key, value );
  15630. if ( key === "content" ) {
  15631. $.each( this.tooltips, function( id, tooltipData ) {
  15632. that._updateContent( tooltipData.element );
  15633. } );
  15634. }
  15635. },
  15636. _setOptionDisabled: function( value ) {
  15637. this[ value ? "_disable" : "_enable" ]();
  15638. },
  15639. _disable: function() {
  15640. var that = this;
  15641. // Close open tooltips
  15642. $.each( this.tooltips, function( id, tooltipData ) {
  15643. var event = $.Event( "blur" );
  15644. event.target = event.currentTarget = tooltipData.element[ 0 ];
  15645. that.close( event, true );
  15646. } );
  15647. // Remove title attributes to prevent native tooltips
  15648. this.disabledTitles = this.disabledTitles.add(
  15649. this.element.find( this.options.items ).addBack()
  15650. .filter( function() {
  15651. var element = $( this );
  15652. if ( element.is( "[title]" ) ) {
  15653. return element
  15654. .data( "ui-tooltip-title", element.attr( "title" ) )
  15655. .removeAttr( "title" );
  15656. }
  15657. } )
  15658. );
  15659. },
  15660. _enable: function() {
  15661. // restore title attributes
  15662. this.disabledTitles.each( function() {
  15663. var element = $( this );
  15664. if ( element.data( "ui-tooltip-title" ) ) {
  15665. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15666. }
  15667. } );
  15668. this.disabledTitles = $( [] );
  15669. },
  15670. open: function( event ) {
  15671. var that = this,
  15672. target = $( event ? event.target : this.element )
  15673. // we need closest here due to mouseover bubbling,
  15674. // but always pointing at the same event target
  15675. .closest( this.options.items );
  15676. // No element to show a tooltip for or the tooltip is already open
  15677. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  15678. return;
  15679. }
  15680. if ( target.attr( "title" ) ) {
  15681. target.data( "ui-tooltip-title", target.attr( "title" ) );
  15682. }
  15683. target.data( "ui-tooltip-open", true );
  15684. // Kill parent tooltips, custom or native, for hover
  15685. if ( event && event.type === "mouseover" ) {
  15686. target.parents().each( function() {
  15687. var parent = $( this ),
  15688. blurEvent;
  15689. if ( parent.data( "ui-tooltip-open" ) ) {
  15690. blurEvent = $.Event( "blur" );
  15691. blurEvent.target = blurEvent.currentTarget = this;
  15692. that.close( blurEvent, true );
  15693. }
  15694. if ( parent.attr( "title" ) ) {
  15695. parent.uniqueId();
  15696. that.parents[ this.id ] = {
  15697. element: this,
  15698. title: parent.attr( "title" )
  15699. };
  15700. parent.attr( "title", "" );
  15701. }
  15702. } );
  15703. }
  15704. this._registerCloseHandlers( event, target );
  15705. this._updateContent( target, event );
  15706. },
  15707. _updateContent: function( target, event ) {
  15708. var content,
  15709. contentOption = this.options.content,
  15710. that = this,
  15711. eventType = event ? event.type : null;
  15712. if ( typeof contentOption === "string" || contentOption.nodeType ||
  15713. contentOption.jquery ) {
  15714. return this._open( event, target, contentOption );
  15715. }
  15716. content = contentOption.call( target[ 0 ], function( response ) {
  15717. // IE may instantly serve a cached response for ajax requests
  15718. // delay this call to _open so the other call to _open runs first
  15719. that._delay( function() {
  15720. // Ignore async response if tooltip was closed already
  15721. if ( !target.data( "ui-tooltip-open" ) ) {
  15722. return;
  15723. }
  15724. // JQuery creates a special event for focusin when it doesn't
  15725. // exist natively. To improve performance, the native event
  15726. // object is reused and the type is changed. Therefore, we can't
  15727. // rely on the type being correct after the event finished
  15728. // bubbling, so we set it back to the previous value. (#8740)
  15729. if ( event ) {
  15730. event.type = eventType;
  15731. }
  15732. this._open( event, target, response );
  15733. } );
  15734. } );
  15735. if ( content ) {
  15736. this._open( event, target, content );
  15737. }
  15738. },
  15739. _open: function( event, target, content ) {
  15740. var tooltipData, tooltip, delayedShow, a11yContent,
  15741. positionOption = $.extend( {}, this.options.position );
  15742. if ( !content ) {
  15743. return;
  15744. }
  15745. // Content can be updated multiple times. If the tooltip already
  15746. // exists, then just update the content and bail.
  15747. tooltipData = this._find( target );
  15748. if ( tooltipData ) {
  15749. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  15750. return;
  15751. }
  15752. // If we have a title, clear it to prevent the native tooltip
  15753. // we have to check first to avoid defining a title if none exists
  15754. // (we don't want to cause an element to start matching [title])
  15755. //
  15756. // We use removeAttr only for key events, to allow IE to export the correct
  15757. // accessible attributes. For mouse events, set to empty string to avoid
  15758. // native tooltip showing up (happens only when removing inside mouseover).
  15759. if ( target.is( "[title]" ) ) {
  15760. if ( event && event.type === "mouseover" ) {
  15761. target.attr( "title", "" );
  15762. } else {
  15763. target.removeAttr( "title" );
  15764. }
  15765. }
  15766. tooltipData = this._tooltip( target );
  15767. tooltip = tooltipData.tooltip;
  15768. this._addDescribedBy( target, tooltip.attr( "id" ) );
  15769. tooltip.find( ".ui-tooltip-content" ).html( content );
  15770. // Support: Voiceover on OS X, JAWS on IE <= 9
  15771. // JAWS announces deletions even when aria-relevant="additions"
  15772. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  15773. this.liveRegion.children().hide();
  15774. a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
  15775. a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
  15776. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  15777. a11yContent.appendTo( this.liveRegion );
  15778. function position( event ) {
  15779. positionOption.of = event;
  15780. if ( tooltip.is( ":hidden" ) ) {
  15781. return;
  15782. }
  15783. tooltip.position( positionOption );
  15784. }
  15785. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  15786. this._on( this.document, {
  15787. mousemove: position
  15788. } );
  15789. // trigger once to override element-relative positioning
  15790. position( event );
  15791. } else {
  15792. tooltip.position( $.extend( {
  15793. of: target
  15794. }, this.options.position ) );
  15795. }
  15796. tooltip.hide();
  15797. this._show( tooltip, this.options.show );
  15798. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  15799. // as the tooltip is visible, position the tooltip using the most recent
  15800. // event.
  15801. // Adds the check to add the timers only when both delay and track options are set (#14682)
  15802. if ( this.options.track && this.options.show && this.options.show.delay ) {
  15803. delayedShow = this.delayedShow = setInterval( function() {
  15804. if ( tooltip.is( ":visible" ) ) {
  15805. position( positionOption.of );
  15806. clearInterval( delayedShow );
  15807. }
  15808. }, 13 );
  15809. }
  15810. this._trigger( "open", event, { tooltip: tooltip } );
  15811. },
  15812. _registerCloseHandlers: function( event, target ) {
  15813. var events = {
  15814. keyup: function( event ) {
  15815. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  15816. var fakeEvent = $.Event( event );
  15817. fakeEvent.currentTarget = target[ 0 ];
  15818. this.close( fakeEvent, true );
  15819. }
  15820. }
  15821. };
  15822. // Only bind remove handler for delegated targets. Non-delegated
  15823. // tooltips will handle this in destroy.
  15824. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15825. events.remove = function() {
  15826. this._removeTooltip( this._find( target ).tooltip );
  15827. };
  15828. }
  15829. if ( !event || event.type === "mouseover" ) {
  15830. events.mouseleave = "close";
  15831. }
  15832. if ( !event || event.type === "focusin" ) {
  15833. events.focusout = "close";
  15834. }
  15835. this._on( true, target, events );
  15836. },
  15837. close: function( event ) {
  15838. var tooltip,
  15839. that = this,
  15840. target = $( event ? event.currentTarget : this.element ),
  15841. tooltipData = this._find( target );
  15842. // The tooltip may already be closed
  15843. if ( !tooltipData ) {
  15844. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  15845. // additional data once there's actually content to show (in _open()). So even if the
  15846. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  15847. // the period between open() and _open().
  15848. target.removeData( "ui-tooltip-open" );
  15849. return;
  15850. }
  15851. tooltip = tooltipData.tooltip;
  15852. // Disabling closes the tooltip, so we need to track when we're closing
  15853. // to avoid an infinite loop in case the tooltip becomes disabled on close
  15854. if ( tooltipData.closing ) {
  15855. return;
  15856. }
  15857. // Clear the interval for delayed tracking tooltips
  15858. clearInterval( this.delayedShow );
  15859. // Only set title if we had one before (see comment in _open())
  15860. // If the title attribute has changed since open(), don't restore
  15861. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  15862. target.attr( "title", target.data( "ui-tooltip-title" ) );
  15863. }
  15864. this._removeDescribedBy( target );
  15865. tooltipData.hiding = true;
  15866. tooltip.stop( true );
  15867. this._hide( tooltip, this.options.hide, function() {
  15868. that._removeTooltip( $( this ) );
  15869. } );
  15870. target.removeData( "ui-tooltip-open" );
  15871. this._off( target, "mouseleave focusout keyup" );
  15872. // Remove 'remove' binding only on delegated targets
  15873. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15874. this._off( target, "remove" );
  15875. }
  15876. this._off( this.document, "mousemove" );
  15877. if ( event && event.type === "mouseleave" ) {
  15878. $.each( this.parents, function( id, parent ) {
  15879. $( parent.element ).attr( "title", parent.title );
  15880. delete that.parents[ id ];
  15881. } );
  15882. }
  15883. tooltipData.closing = true;
  15884. this._trigger( "close", event, { tooltip: tooltip } );
  15885. if ( !tooltipData.hiding ) {
  15886. tooltipData.closing = false;
  15887. }
  15888. },
  15889. _tooltip: function( element ) {
  15890. var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
  15891. content = $( "<div>" ).appendTo( tooltip ),
  15892. id = tooltip.uniqueId().attr( "id" );
  15893. this._addClass( content, "ui-tooltip-content" );
  15894. this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
  15895. tooltip.appendTo( this._appendTo( element ) );
  15896. return this.tooltips[ id ] = {
  15897. element: element,
  15898. tooltip: tooltip
  15899. };
  15900. },
  15901. _find: function( target ) {
  15902. var id = target.data( "ui-tooltip-id" );
  15903. return id ? this.tooltips[ id ] : null;
  15904. },
  15905. _removeTooltip: function( tooltip ) {
  15906. // Clear the interval for delayed tracking tooltips
  15907. clearInterval( this.delayedShow );
  15908. tooltip.remove();
  15909. delete this.tooltips[ tooltip.attr( "id" ) ];
  15910. },
  15911. _appendTo: function( target ) {
  15912. var element = target.closest( ".ui-front, dialog" );
  15913. if ( !element.length ) {
  15914. element = this.document[ 0 ].body;
  15915. }
  15916. return element;
  15917. },
  15918. _destroy: function() {
  15919. var that = this;
  15920. // Close open tooltips
  15921. $.each( this.tooltips, function( id, tooltipData ) {
  15922. // Delegate to close method to handle common cleanup
  15923. var event = $.Event( "blur" ),
  15924. element = tooltipData.element;
  15925. event.target = event.currentTarget = element[ 0 ];
  15926. that.close( event, true );
  15927. // Remove immediately; destroying an open tooltip doesn't use the
  15928. // hide animation
  15929. $( "#" + id ).remove();
  15930. // Restore the title
  15931. if ( element.data( "ui-tooltip-title" ) ) {
  15932. // If the title attribute has changed since open(), don't restore
  15933. if ( !element.attr( "title" ) ) {
  15934. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15935. }
  15936. element.removeData( "ui-tooltip-title" );
  15937. }
  15938. } );
  15939. this.liveRegion.remove();
  15940. }
  15941. } );
  15942. // DEPRECATED
  15943. // TODO: Switch return back to widget declaration at top of file when this is removed
  15944. if ( $.uiBackCompat !== false ) {
  15945. // Backcompat for tooltipClass option
  15946. $.widget( "ui.tooltip", $.ui.tooltip, {
  15947. options: {
  15948. tooltipClass: null
  15949. },
  15950. _tooltip: function() {
  15951. var tooltipData = this._superApply( arguments );
  15952. if ( this.options.tooltipClass ) {
  15953. tooltipData.tooltip.addClass( this.options.tooltipClass );
  15954. }
  15955. return tooltipData;
  15956. }
  15957. } );
  15958. }
  15959. var widgetsTooltip = $.ui.tooltip;
  15960. } );