not really known
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.

16616 lines
460 KiB

  1. /*! jQuery UI - v1.11.4 - 2015-03-11
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js
  4. * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. /*!
  15. * jQuery UI Core 1.11.4
  16. * http://jqueryui.com
  17. *
  18. * Copyright jQuery Foundation and other contributors
  19. * Released under the MIT license.
  20. * http://jquery.org/license
  21. *
  22. * http://api.jqueryui.com/category/ui-core/
  23. */
  24. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  25. $.ui = $.ui || {};
  26. $.extend( $.ui, {
  27. version: "1.11.4",
  28. keyCode: {
  29. BACKSPACE: 8,
  30. COMMA: 188,
  31. DELETE: 46,
  32. DOWN: 40,
  33. END: 35,
  34. ENTER: 13,
  35. ESCAPE: 27,
  36. HOME: 36,
  37. LEFT: 37,
  38. PAGE_DOWN: 34,
  39. PAGE_UP: 33,
  40. PERIOD: 190,
  41. RIGHT: 39,
  42. SPACE: 32,
  43. TAB: 9,
  44. UP: 38
  45. }
  46. });
  47. // plugins
  48. $.fn.extend({
  49. scrollParent: function( includeHidden ) {
  50. var position = this.css( "position" ),
  51. excludeStaticParent = position === "absolute",
  52. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  53. scrollParent = this.parents().filter( function() {
  54. var parent = $( this );
  55. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  56. return false;
  57. }
  58. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  59. }).eq( 0 );
  60. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  61. },
  62. uniqueId: (function() {
  63. var uuid = 0;
  64. return function() {
  65. return this.each(function() {
  66. if ( !this.id ) {
  67. this.id = "ui-id-" + ( ++uuid );
  68. }
  69. });
  70. };
  71. })(),
  72. removeUniqueId: function() {
  73. return this.each(function() {
  74. if ( /^ui-id-\d+$/.test( this.id ) ) {
  75. $( this ).removeAttr( "id" );
  76. }
  77. });
  78. }
  79. });
  80. // selectors
  81. function focusable( element, isTabIndexNotNaN ) {
  82. var map, mapName, img,
  83. nodeName = element.nodeName.toLowerCase();
  84. if ( "area" === nodeName ) {
  85. map = element.parentNode;
  86. mapName = map.name;
  87. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  88. return false;
  89. }
  90. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  91. return !!img && visible( img );
  92. }
  93. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  94. !element.disabled :
  95. "a" === nodeName ?
  96. element.href || isTabIndexNotNaN :
  97. isTabIndexNotNaN) &&
  98. // the element and all of its ancestors must be visible
  99. visible( element );
  100. }
  101. function visible( element ) {
  102. return $.expr.filters.visible( element ) &&
  103. !$( element ).parents().addBack().filter(function() {
  104. return $.css( this, "visibility" ) === "hidden";
  105. }).length;
  106. }
  107. $.extend( $.expr[ ":" ], {
  108. data: $.expr.createPseudo ?
  109. $.expr.createPseudo(function( dataName ) {
  110. return function( elem ) {
  111. return !!$.data( elem, dataName );
  112. };
  113. }) :
  114. // support: jQuery <1.8
  115. function( elem, i, match ) {
  116. return !!$.data( elem, match[ 3 ] );
  117. },
  118. focusable: function( element ) {
  119. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  120. },
  121. tabbable: function( element ) {
  122. var tabIndex = $.attr( element, "tabindex" ),
  123. isTabIndexNaN = isNaN( tabIndex );
  124. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  125. }
  126. });
  127. // support: jQuery <1.8
  128. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  129. $.each( [ "Width", "Height" ], function( i, name ) {
  130. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  131. type = name.toLowerCase(),
  132. orig = {
  133. innerWidth: $.fn.innerWidth,
  134. innerHeight: $.fn.innerHeight,
  135. outerWidth: $.fn.outerWidth,
  136. outerHeight: $.fn.outerHeight
  137. };
  138. function reduce( elem, size, border, margin ) {
  139. $.each( side, function() {
  140. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  141. if ( border ) {
  142. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  143. }
  144. if ( margin ) {
  145. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  146. }
  147. });
  148. return size;
  149. }
  150. $.fn[ "inner" + name ] = function( size ) {
  151. if ( size === undefined ) {
  152. return orig[ "inner" + name ].call( this );
  153. }
  154. return this.each(function() {
  155. $( this ).css( type, reduce( this, size ) + "px" );
  156. });
  157. };
  158. $.fn[ "outer" + name] = function( size, margin ) {
  159. if ( typeof size !== "number" ) {
  160. return orig[ "outer" + name ].call( this, size );
  161. }
  162. return this.each(function() {
  163. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  164. });
  165. };
  166. });
  167. }
  168. // support: jQuery <1.8
  169. if ( !$.fn.addBack ) {
  170. $.fn.addBack = function( selector ) {
  171. return this.add( selector == null ?
  172. this.prevObject : this.prevObject.filter( selector )
  173. );
  174. };
  175. }
  176. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  177. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  178. $.fn.removeData = (function( removeData ) {
  179. return function( key ) {
  180. if ( arguments.length ) {
  181. return removeData.call( this, $.camelCase( key ) );
  182. } else {
  183. return removeData.call( this );
  184. }
  185. };
  186. })( $.fn.removeData );
  187. }
  188. // deprecated
  189. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  190. $.fn.extend({
  191. focus: (function( orig ) {
  192. return function( delay, fn ) {
  193. return typeof delay === "number" ?
  194. this.each(function() {
  195. var elem = this;
  196. setTimeout(function() {
  197. $( elem ).focus();
  198. if ( fn ) {
  199. fn.call( elem );
  200. }
  201. }, delay );
  202. }) :
  203. orig.apply( this, arguments );
  204. };
  205. })( $.fn.focus ),
  206. disableSelection: (function() {
  207. var eventType = "onselectstart" in document.createElement( "div" ) ?
  208. "selectstart" :
  209. "mousedown";
  210. return function() {
  211. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  212. event.preventDefault();
  213. });
  214. };
  215. })(),
  216. enableSelection: function() {
  217. return this.unbind( ".ui-disableSelection" );
  218. },
  219. zIndex: function( zIndex ) {
  220. if ( zIndex !== undefined ) {
  221. return this.css( "zIndex", zIndex );
  222. }
  223. if ( this.length ) {
  224. var elem = $( this[ 0 ] ), position, value;
  225. while ( elem.length && elem[ 0 ] !== document ) {
  226. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  227. // This makes behavior of this function consistent across browsers
  228. // WebKit always returns auto if the element is positioned
  229. position = elem.css( "position" );
  230. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  231. // IE returns 0 when zIndex is not specified
  232. // other browsers return a string
  233. // we ignore the case of nested elements with an explicit value of 0
  234. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  235. value = parseInt( elem.css( "zIndex" ), 10 );
  236. if ( !isNaN( value ) && value !== 0 ) {
  237. return value;
  238. }
  239. }
  240. elem = elem.parent();
  241. }
  242. }
  243. return 0;
  244. }
  245. });
  246. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  247. $.ui.plugin = {
  248. add: function( module, option, set ) {
  249. var i,
  250. proto = $.ui[ module ].prototype;
  251. for ( i in set ) {
  252. proto.plugins[ i ] = proto.plugins[ i ] || [];
  253. proto.plugins[ i ].push( [ option, set[ i ] ] );
  254. }
  255. },
  256. call: function( instance, name, args, allowDisconnected ) {
  257. var i,
  258. set = instance.plugins[ name ];
  259. if ( !set ) {
  260. return;
  261. }
  262. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  263. return;
  264. }
  265. for ( i = 0; i < set.length; i++ ) {
  266. if ( instance.options[ set[ i ][ 0 ] ] ) {
  267. set[ i ][ 1 ].apply( instance.element, args );
  268. }
  269. }
  270. }
  271. };
  272. /*!
  273. * jQuery UI Widget 1.11.4
  274. * http://jqueryui.com
  275. *
  276. * Copyright jQuery Foundation and other contributors
  277. * Released under the MIT license.
  278. * http://jquery.org/license
  279. *
  280. * http://api.jqueryui.com/jQuery.widget/
  281. */
  282. var widget_uuid = 0,
  283. widget_slice = Array.prototype.slice;
  284. $.cleanData = (function( orig ) {
  285. return function( elems ) {
  286. var events, elem, i;
  287. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  288. try {
  289. // Only trigger remove when necessary to save time
  290. events = $._data( elem, "events" );
  291. if ( events && events.remove ) {
  292. $( elem ).triggerHandler( "remove" );
  293. }
  294. // http://bugs.jquery.com/ticket/8235
  295. } catch ( e ) {}
  296. }
  297. orig( elems );
  298. };
  299. })( $.cleanData );
  300. $.widget = function( name, base, prototype ) {
  301. var fullName, existingConstructor, constructor, basePrototype,
  302. // proxiedPrototype allows the provided prototype to remain unmodified
  303. // so that it can be used as a mixin for multiple widgets (#8876)
  304. proxiedPrototype = {},
  305. namespace = name.split( "." )[ 0 ];
  306. name = name.split( "." )[ 1 ];
  307. fullName = namespace + "-" + name;
  308. if ( !prototype ) {
  309. prototype = base;
  310. base = $.Widget;
  311. }
  312. // create selector for plugin
  313. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  314. return !!$.data( elem, fullName );
  315. };
  316. $[ namespace ] = $[ namespace ] || {};
  317. existingConstructor = $[ namespace ][ name ];
  318. constructor = $[ namespace ][ name ] = function( options, element ) {
  319. // allow instantiation without "new" keyword
  320. if ( !this._createWidget ) {
  321. return new constructor( options, element );
  322. }
  323. // allow instantiation without initializing for simple inheritance
  324. // must use "new" keyword (the code above always passes args)
  325. if ( arguments.length ) {
  326. this._createWidget( options, element );
  327. }
  328. };
  329. // extend with the existing constructor to carry over any static properties
  330. $.extend( constructor, existingConstructor, {
  331. version: prototype.version,
  332. // copy the object used to create the prototype in case we need to
  333. // redefine the widget later
  334. _proto: $.extend( {}, prototype ),
  335. // track widgets that inherit from this widget in case this widget is
  336. // redefined after a widget inherits from it
  337. _childConstructors: []
  338. });
  339. basePrototype = new base();
  340. // we need to make the options hash a property directly on the new instance
  341. // otherwise we'll modify the options hash on the prototype that we're
  342. // inheriting from
  343. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  344. $.each( prototype, function( prop, value ) {
  345. if ( !$.isFunction( value ) ) {
  346. proxiedPrototype[ prop ] = value;
  347. return;
  348. }
  349. proxiedPrototype[ prop ] = (function() {
  350. var _super = function() {
  351. return base.prototype[ prop ].apply( this, arguments );
  352. },
  353. _superApply = function( args ) {
  354. return base.prototype[ prop ].apply( this, args );
  355. };
  356. return function() {
  357. var __super = this._super,
  358. __superApply = this._superApply,
  359. returnValue;
  360. this._super = _super;
  361. this._superApply = _superApply;
  362. returnValue = value.apply( this, arguments );
  363. this._super = __super;
  364. this._superApply = __superApply;
  365. return returnValue;
  366. };
  367. })();
  368. });
  369. constructor.prototype = $.widget.extend( basePrototype, {
  370. // TODO: remove support for widgetEventPrefix
  371. // always use the name + a colon as the prefix, e.g., draggable:start
  372. // don't prefix for widgets that aren't DOM-based
  373. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  374. }, proxiedPrototype, {
  375. constructor: constructor,
  376. namespace: namespace,
  377. widgetName: name,
  378. widgetFullName: fullName
  379. });
  380. // If this widget is being redefined then we need to find all widgets that
  381. // are inheriting from it and redefine all of them so that they inherit from
  382. // the new version of this widget. We're essentially trying to replace one
  383. // level in the prototype chain.
  384. if ( existingConstructor ) {
  385. $.each( existingConstructor._childConstructors, function( i, child ) {
  386. var childPrototype = child.prototype;
  387. // redefine the child widget using the same prototype that was
  388. // originally used, but inherit from the new version of the base
  389. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  390. });
  391. // remove the list of existing child constructors from the old constructor
  392. // so the old child constructors can be garbage collected
  393. delete existingConstructor._childConstructors;
  394. } else {
  395. base._childConstructors.push( constructor );
  396. }
  397. $.widget.bridge( name, constructor );
  398. return constructor;
  399. };
  400. $.widget.extend = function( target ) {
  401. var input = widget_slice.call( arguments, 1 ),
  402. inputIndex = 0,
  403. inputLength = input.length,
  404. key,
  405. value;
  406. for ( ; inputIndex < inputLength; inputIndex++ ) {
  407. for ( key in input[ inputIndex ] ) {
  408. value = input[ inputIndex ][ key ];
  409. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  410. // Clone objects
  411. if ( $.isPlainObject( value ) ) {
  412. target[ key ] = $.isPlainObject( target[ key ] ) ?
  413. $.widget.extend( {}, target[ key ], value ) :
  414. // Don't extend strings, arrays, etc. with objects
  415. $.widget.extend( {}, value );
  416. // Copy everything else by reference
  417. } else {
  418. target[ key ] = value;
  419. }
  420. }
  421. }
  422. }
  423. return target;
  424. };
  425. $.widget.bridge = function( name, object ) {
  426. var fullName = object.prototype.widgetFullName || name;
  427. $.fn[ name ] = function( options ) {
  428. var isMethodCall = typeof options === "string",
  429. args = widget_slice.call( arguments, 1 ),
  430. returnValue = this;
  431. if ( isMethodCall ) {
  432. this.each(function() {
  433. var methodValue,
  434. instance = $.data( this, fullName );
  435. if ( options === "instance" ) {
  436. returnValue = instance;
  437. return false;
  438. }
  439. if ( !instance ) {
  440. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  441. "attempted to call method '" + options + "'" );
  442. }
  443. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  444. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  445. }
  446. methodValue = instance[ options ].apply( instance, args );
  447. if ( methodValue !== instance && methodValue !== undefined ) {
  448. returnValue = methodValue && methodValue.jquery ?
  449. returnValue.pushStack( methodValue.get() ) :
  450. methodValue;
  451. return false;
  452. }
  453. });
  454. } else {
  455. // Allow multiple hashes to be passed on init
  456. if ( args.length ) {
  457. options = $.widget.extend.apply( null, [ options ].concat(args) );
  458. }
  459. this.each(function() {
  460. var instance = $.data( this, fullName );
  461. if ( instance ) {
  462. instance.option( options || {} );
  463. if ( instance._init ) {
  464. instance._init();
  465. }
  466. } else {
  467. $.data( this, fullName, new object( options, this ) );
  468. }
  469. });
  470. }
  471. return returnValue;
  472. };
  473. };
  474. $.Widget = function( /* options, element */ ) {};
  475. $.Widget._childConstructors = [];
  476. $.Widget.prototype = {
  477. widgetName: "widget",
  478. widgetEventPrefix: "",
  479. defaultElement: "<div>",
  480. options: {
  481. disabled: false,
  482. // callbacks
  483. create: null
  484. },
  485. _createWidget: function( options, element ) {
  486. element = $( element || this.defaultElement || this )[ 0 ];
  487. this.element = $( element );
  488. this.uuid = widget_uuid++;
  489. this.eventNamespace = "." + this.widgetName + this.uuid;
  490. this.bindings = $();
  491. this.hoverable = $();
  492. this.focusable = $();
  493. if ( element !== this ) {
  494. $.data( element, this.widgetFullName, this );
  495. this._on( true, this.element, {
  496. remove: function( event ) {
  497. if ( event.target === element ) {
  498. this.destroy();
  499. }
  500. }
  501. });
  502. this.document = $( element.style ?
  503. // element within the document
  504. element.ownerDocument :
  505. // element is window or document
  506. element.document || element );
  507. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  508. }
  509. this.options = $.widget.extend( {},
  510. this.options,
  511. this._getCreateOptions(),
  512. options );
  513. this._create();
  514. this._trigger( "create", null, this._getCreateEventData() );
  515. this._init();
  516. },
  517. _getCreateOptions: $.noop,
  518. _getCreateEventData: $.noop,
  519. _create: $.noop,
  520. _init: $.noop,
  521. destroy: function() {
  522. this._destroy();
  523. // we can probably remove the unbind calls in 2.0
  524. // all event bindings should go through this._on()
  525. this.element
  526. .unbind( this.eventNamespace )
  527. .removeData( this.widgetFullName )
  528. // support: jquery <1.6.3
  529. // http://bugs.jquery.com/ticket/9413
  530. .removeData( $.camelCase( this.widgetFullName ) );
  531. this.widget()
  532. .unbind( this.eventNamespace )
  533. .removeAttr( "aria-disabled" )
  534. .removeClass(
  535. this.widgetFullName + "-disabled " +
  536. "ui-state-disabled" );
  537. // clean up events and states
  538. this.bindings.unbind( this.eventNamespace );
  539. this.hoverable.removeClass( "ui-state-hover" );
  540. this.focusable.removeClass( "ui-state-focus" );
  541. },
  542. _destroy: $.noop,
  543. widget: function() {
  544. return this.element;
  545. },
  546. option: function( key, value ) {
  547. var options = key,
  548. parts,
  549. curOption,
  550. i;
  551. if ( arguments.length === 0 ) {
  552. // don't return a reference to the internal hash
  553. return $.widget.extend( {}, this.options );
  554. }
  555. if ( typeof key === "string" ) {
  556. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  557. options = {};
  558. parts = key.split( "." );
  559. key = parts.shift();
  560. if ( parts.length ) {
  561. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  562. for ( i = 0; i < parts.length - 1; i++ ) {
  563. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  564. curOption = curOption[ parts[ i ] ];
  565. }
  566. key = parts.pop();
  567. if ( arguments.length === 1 ) {
  568. return curOption[ key ] === undefined ? null : curOption[ key ];
  569. }
  570. curOption[ key ] = value;
  571. } else {
  572. if ( arguments.length === 1 ) {
  573. return this.options[ key ] === undefined ? null : this.options[ key ];
  574. }
  575. options[ key ] = value;
  576. }
  577. }
  578. this._setOptions( options );
  579. return this;
  580. },
  581. _setOptions: function( options ) {
  582. var key;
  583. for ( key in options ) {
  584. this._setOption( key, options[ key ] );
  585. }
  586. return this;
  587. },
  588. _setOption: function( key, value ) {
  589. this.options[ key ] = value;
  590. if ( key === "disabled" ) {
  591. this.widget()
  592. .toggleClass( this.widgetFullName + "-disabled", !!value );
  593. // If the widget is becoming disabled, then nothing is interactive
  594. if ( value ) {
  595. this.hoverable.removeClass( "ui-state-hover" );
  596. this.focusable.removeClass( "ui-state-focus" );
  597. }
  598. }
  599. return this;
  600. },
  601. enable: function() {
  602. return this._setOptions({ disabled: false });
  603. },
  604. disable: function() {
  605. return this._setOptions({ disabled: true });
  606. },
  607. _on: function( suppressDisabledCheck, element, handlers ) {
  608. var delegateElement,
  609. instance = this;
  610. // no suppressDisabledCheck flag, shuffle arguments
  611. if ( typeof suppressDisabledCheck !== "boolean" ) {
  612. handlers = element;
  613. element = suppressDisabledCheck;
  614. suppressDisabledCheck = false;
  615. }
  616. // no element argument, shuffle and use this.element
  617. if ( !handlers ) {
  618. handlers = element;
  619. element = this.element;
  620. delegateElement = this.widget();
  621. } else {
  622. element = delegateElement = $( element );
  623. this.bindings = this.bindings.add( element );
  624. }
  625. $.each( handlers, function( event, handler ) {
  626. function handlerProxy() {
  627. // allow widgets to customize the disabled handling
  628. // - disabled as an array instead of boolean
  629. // - disabled class as method for disabling individual parts
  630. if ( !suppressDisabledCheck &&
  631. ( instance.options.disabled === true ||
  632. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  633. return;
  634. }
  635. return ( typeof handler === "string" ? instance[ handler ] : handler )
  636. .apply( instance, arguments );
  637. }
  638. // copy the guid so direct unbinding works
  639. if ( typeof handler !== "string" ) {
  640. handlerProxy.guid = handler.guid =
  641. handler.guid || handlerProxy.guid || $.guid++;
  642. }
  643. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  644. eventName = match[1] + instance.eventNamespace,
  645. selector = match[2];
  646. if ( selector ) {
  647. delegateElement.delegate( selector, eventName, handlerProxy );
  648. } else {
  649. element.bind( eventName, handlerProxy );
  650. }
  651. });
  652. },
  653. _off: function( element, eventName ) {
  654. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  655. this.eventNamespace;
  656. element.unbind( eventName ).undelegate( eventName );
  657. // Clear the stack to avoid memory leaks (#10056)
  658. this.bindings = $( this.bindings.not( element ).get() );
  659. this.focusable = $( this.focusable.not( element ).get() );
  660. this.hoverable = $( this.hoverable.not( element ).get() );
  661. },
  662. _delay: function( handler, delay ) {
  663. function handlerProxy() {
  664. return ( typeof handler === "string" ? instance[ handler ] : handler )
  665. .apply( instance, arguments );
  666. }
  667. var instance = this;
  668. return setTimeout( handlerProxy, delay || 0 );
  669. },
  670. _hoverable: function( element ) {
  671. this.hoverable = this.hoverable.add( element );
  672. this._on( element, {
  673. mouseenter: function( event ) {
  674. $( event.currentTarget ).addClass( "ui-state-hover" );
  675. },
  676. mouseleave: function( event ) {
  677. $( event.currentTarget ).removeClass( "ui-state-hover" );
  678. }
  679. });
  680. },
  681. _focusable: function( element ) {
  682. this.focusable = this.focusable.add( element );
  683. this._on( element, {
  684. focusin: function( event ) {
  685. $( event.currentTarget ).addClass( "ui-state-focus" );
  686. },
  687. focusout: function( event ) {
  688. $( event.currentTarget ).removeClass( "ui-state-focus" );
  689. }
  690. });
  691. },
  692. _trigger: function( type, event, data ) {
  693. var prop, orig,
  694. callback = this.options[ type ];
  695. data = data || {};
  696. event = $.Event( event );
  697. event.type = ( type === this.widgetEventPrefix ?
  698. type :
  699. this.widgetEventPrefix + type ).toLowerCase();
  700. // the original event may come from any element
  701. // so we need to reset the target on the new event
  702. event.target = this.element[ 0 ];
  703. // copy original event properties over to the new event
  704. orig = event.originalEvent;
  705. if ( orig ) {
  706. for ( prop in orig ) {
  707. if ( !( prop in event ) ) {
  708. event[ prop ] = orig[ prop ];
  709. }
  710. }
  711. }
  712. this.element.trigger( event, data );
  713. return !( $.isFunction( callback ) &&
  714. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  715. event.isDefaultPrevented() );
  716. }
  717. };
  718. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  719. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  720. if ( typeof options === "string" ) {
  721. options = { effect: options };
  722. }
  723. var hasOptions,
  724. effectName = !options ?
  725. method :
  726. options === true || typeof options === "number" ?
  727. defaultEffect :
  728. options.effect || defaultEffect;
  729. options = options || {};
  730. if ( typeof options === "number" ) {
  731. options = { duration: options };
  732. }
  733. hasOptions = !$.isEmptyObject( options );
  734. options.complete = callback;
  735. if ( options.delay ) {
  736. element.delay( options.delay );
  737. }
  738. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  739. element[ method ]( options );
  740. } else if ( effectName !== method && element[ effectName ] ) {
  741. element[ effectName ]( options.duration, options.easing, callback );
  742. } else {
  743. element.queue(function( next ) {
  744. $( this )[ method ]();
  745. if ( callback ) {
  746. callback.call( element[ 0 ] );
  747. }
  748. next();
  749. });
  750. }
  751. };
  752. });
  753. var widget = $.widget;
  754. /*!
  755. * jQuery UI Mouse 1.11.4
  756. * http://jqueryui.com
  757. *
  758. * Copyright jQuery Foundation and other contributors
  759. * Released under the MIT license.
  760. * http://jquery.org/license
  761. *
  762. * http://api.jqueryui.com/mouse/
  763. */
  764. var mouseHandled = false;
  765. $( document ).mouseup( function() {
  766. mouseHandled = false;
  767. });
  768. var mouse = $.widget("ui.mouse", {
  769. version: "1.11.4",
  770. options: {
  771. cancel: "input,textarea,button,select,option",
  772. distance: 1,
  773. delay: 0
  774. },
  775. _mouseInit: function() {
  776. var that = this;
  777. this.element
  778. .bind("mousedown." + this.widgetName, function(event) {
  779. return that._mouseDown(event);
  780. })
  781. .bind("click." + this.widgetName, function(event) {
  782. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  783. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  784. event.stopImmediatePropagation();
  785. return false;
  786. }
  787. });
  788. this.started = false;
  789. },
  790. // TODO: make sure destroying one instance of mouse doesn't mess with
  791. // other instances of mouse
  792. _mouseDestroy: function() {
  793. this.element.unbind("." + this.widgetName);
  794. if ( this._mouseMoveDelegate ) {
  795. this.document
  796. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  797. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  798. }
  799. },
  800. _mouseDown: function(event) {
  801. // don't let more than one widget handle mouseStart
  802. if ( mouseHandled ) {
  803. return;
  804. }
  805. this._mouseMoved = false;
  806. // we may have missed mouseup (out of window)
  807. (this._mouseStarted && this._mouseUp(event));
  808. this._mouseDownEvent = event;
  809. var that = this,
  810. btnIsLeft = (event.which === 1),
  811. // event.target.nodeName works around a bug in IE 8 with
  812. // disabled inputs (#7620)
  813. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  814. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  815. return true;
  816. }
  817. this.mouseDelayMet = !this.options.delay;
  818. if (!this.mouseDelayMet) {
  819. this._mouseDelayTimer = setTimeout(function() {
  820. that.mouseDelayMet = true;
  821. }, this.options.delay);
  822. }
  823. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  824. this._mouseStarted = (this._mouseStart(event) !== false);
  825. if (!this._mouseStarted) {
  826. event.preventDefault();
  827. return true;
  828. }
  829. }
  830. // Click event may never have fired (Gecko & Opera)
  831. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  832. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  833. }
  834. // these delegates are required to keep context
  835. this._mouseMoveDelegate = function(event) {
  836. return that._mouseMove(event);
  837. };
  838. this._mouseUpDelegate = function(event) {
  839. return that._mouseUp(event);
  840. };
  841. this.document
  842. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  843. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  844. event.preventDefault();
  845. mouseHandled = true;
  846. return true;
  847. },
  848. _mouseMove: function(event) {
  849. // Only check for mouseups outside the document if you've moved inside the document
  850. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  851. // fire a mousemove event if content is placed under the cursor. See #7778
  852. // Support: IE <9
  853. if ( this._mouseMoved ) {
  854. // IE mouseup check - mouseup happened when mouse was out of window
  855. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  856. return this._mouseUp(event);
  857. // Iframe mouseup check - mouseup occurred in another document
  858. } else if ( !event.which ) {
  859. return this._mouseUp( event );
  860. }
  861. }
  862. if ( event.which || event.button ) {
  863. this._mouseMoved = true;
  864. }
  865. if (this._mouseStarted) {
  866. this._mouseDrag(event);
  867. return event.preventDefault();
  868. }
  869. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  870. this._mouseStarted =
  871. (this._mouseStart(this._mouseDownEvent, event) !== false);
  872. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  873. }
  874. return !this._mouseStarted;
  875. },
  876. _mouseUp: function(event) {
  877. this.document
  878. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  879. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  880. if (this._mouseStarted) {
  881. this._mouseStarted = false;
  882. if (event.target === this._mouseDownEvent.target) {
  883. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  884. }
  885. this._mouseStop(event);
  886. }
  887. mouseHandled = false;
  888. return false;
  889. },
  890. _mouseDistanceMet: function(event) {
  891. return (Math.max(
  892. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  893. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  894. ) >= this.options.distance
  895. );
  896. },
  897. _mouseDelayMet: function(/* event */) {
  898. return this.mouseDelayMet;
  899. },
  900. // These are placeholder methods, to be overriden by extending plugin
  901. _mouseStart: function(/* event */) {},
  902. _mouseDrag: function(/* event */) {},
  903. _mouseStop: function(/* event */) {},
  904. _mouseCapture: function(/* event */) { return true; }
  905. });
  906. /*!
  907. * jQuery UI Position 1.11.4
  908. * http://jqueryui.com
  909. *
  910. * Copyright jQuery Foundation and other contributors
  911. * Released under the MIT license.
  912. * http://jquery.org/license
  913. *
  914. * http://api.jqueryui.com/position/
  915. */
  916. (function() {
  917. $.ui = $.ui || {};
  918. var cachedScrollbarWidth, supportsOffsetFractions,
  919. max = Math.max,
  920. abs = Math.abs,
  921. round = Math.round,
  922. rhorizontal = /left|center|right/,
  923. rvertical = /top|center|bottom/,
  924. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  925. rposition = /^\w+/,
  926. rpercent = /%$/,
  927. _position = $.fn.position;
  928. function getOffsets( offsets, width, height ) {
  929. return [
  930. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  931. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  932. ];
  933. }
  934. function parseCss( element, property ) {
  935. return parseInt( $.css( element, property ), 10 ) || 0;
  936. }
  937. function getDimensions( elem ) {
  938. var raw = elem[0];
  939. if ( raw.nodeType === 9 ) {
  940. return {
  941. width: elem.width(),
  942. height: elem.height(),
  943. offset: { top: 0, left: 0 }
  944. };
  945. }
  946. if ( $.isWindow( raw ) ) {
  947. return {
  948. width: elem.width(),
  949. height: elem.height(),
  950. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  951. };
  952. }
  953. if ( raw.preventDefault ) {
  954. return {
  955. width: 0,
  956. height: 0,
  957. offset: { top: raw.pageY, left: raw.pageX }
  958. };
  959. }
  960. return {
  961. width: elem.outerWidth(),
  962. height: elem.outerHeight(),
  963. offset: elem.offset()
  964. };
  965. }
  966. $.position = {
  967. scrollbarWidth: function() {
  968. if ( cachedScrollbarWidth !== undefined ) {
  969. return cachedScrollbarWidth;
  970. }
  971. var w1, w2,
  972. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  973. innerDiv = div.children()[0];
  974. $( "body" ).append( div );
  975. w1 = innerDiv.offsetWidth;
  976. div.css( "overflow", "scroll" );
  977. w2 = innerDiv.offsetWidth;
  978. if ( w1 === w2 ) {
  979. w2 = div[0].clientWidth;
  980. }
  981. div.remove();
  982. return (cachedScrollbarWidth = w1 - w2);
  983. },
  984. getScrollInfo: function( within ) {
  985. var overflowX = within.isWindow || within.isDocument ? "" :
  986. within.element.css( "overflow-x" ),
  987. overflowY = within.isWindow || within.isDocument ? "" :
  988. within.element.css( "overflow-y" ),
  989. hasOverflowX = overflowX === "scroll" ||
  990. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  991. hasOverflowY = overflowY === "scroll" ||
  992. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  993. return {
  994. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  995. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  996. };
  997. },
  998. getWithinInfo: function( element ) {
  999. var withinElement = $( element || window ),
  1000. isWindow = $.isWindow( withinElement[0] ),
  1001. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  1002. return {
  1003. element: withinElement,
  1004. isWindow: isWindow,
  1005. isDocument: isDocument,
  1006. offset: withinElement.offset() || { left: 0, top: 0 },
  1007. scrollLeft: withinElement.scrollLeft(),
  1008. scrollTop: withinElement.scrollTop(),
  1009. // support: jQuery 1.6.x
  1010. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  1011. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  1012. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  1013. };
  1014. }
  1015. };
  1016. $.fn.position = function( options ) {
  1017. if ( !options || !options.of ) {
  1018. return _position.apply( this, arguments );
  1019. }
  1020. // make a copy, we don't want to modify arguments
  1021. options = $.extend( {}, options );
  1022. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1023. target = $( options.of ),
  1024. within = $.position.getWithinInfo( options.within ),
  1025. scrollInfo = $.position.getScrollInfo( within ),
  1026. collision = ( options.collision || "flip" ).split( " " ),
  1027. offsets = {};
  1028. dimensions = getDimensions( target );
  1029. if ( target[0].preventDefault ) {
  1030. // force left top to allow flipping
  1031. options.at = "left top";
  1032. }
  1033. targetWidth = dimensions.width;
  1034. targetHeight = dimensions.height;
  1035. targetOffset = dimensions.offset;
  1036. // clone to reuse original targetOffset later
  1037. basePosition = $.extend( {}, targetOffset );
  1038. // force my and at to have valid horizontal and vertical positions
  1039. // if a value is missing or invalid, it will be converted to center
  1040. $.each( [ "my", "at" ], function() {
  1041. var pos = ( options[ this ] || "" ).split( " " ),
  1042. horizontalOffset,
  1043. verticalOffset;
  1044. if ( pos.length === 1) {
  1045. pos = rhorizontal.test( pos[ 0 ] ) ?
  1046. pos.concat( [ "center" ] ) :
  1047. rvertical.test( pos[ 0 ] ) ?
  1048. [ "center" ].concat( pos ) :
  1049. [ "center", "center" ];
  1050. }
  1051. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1052. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1053. // calculate offsets
  1054. horizontalOffset = roffset.exec( pos[ 0 ] );
  1055. verticalOffset = roffset.exec( pos[ 1 ] );
  1056. offsets[ this ] = [
  1057. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1058. verticalOffset ? verticalOffset[ 0 ] : 0
  1059. ];
  1060. // reduce to just the positions without the offsets
  1061. options[ this ] = [
  1062. rposition.exec( pos[ 0 ] )[ 0 ],
  1063. rposition.exec( pos[ 1 ] )[ 0 ]
  1064. ];
  1065. });
  1066. // normalize collision option
  1067. if ( collision.length === 1 ) {
  1068. collision[ 1 ] = collision[ 0 ];
  1069. }
  1070. if ( options.at[ 0 ] === "right" ) {
  1071. basePosition.left += targetWidth;
  1072. } else if ( options.at[ 0 ] === "center" ) {
  1073. basePosition.left += targetWidth / 2;
  1074. }
  1075. if ( options.at[ 1 ] === "bottom" ) {
  1076. basePosition.top += targetHeight;
  1077. } else if ( options.at[ 1 ] === "center" ) {
  1078. basePosition.top += targetHeight / 2;
  1079. }
  1080. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1081. basePosition.left += atOffset[ 0 ];
  1082. basePosition.top += atOffset[ 1 ];
  1083. return this.each(function() {
  1084. var collisionPosition, using,
  1085. elem = $( this ),
  1086. elemWidth = elem.outerWidth(),
  1087. elemHeight = elem.outerHeight(),
  1088. marginLeft = parseCss( this, "marginLeft" ),
  1089. marginTop = parseCss( this, "marginTop" ),
  1090. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1091. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1092. position = $.extend( {}, basePosition ),
  1093. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1094. if ( options.my[ 0 ] === "right" ) {
  1095. position.left -= elemWidth;
  1096. } else if ( options.my[ 0 ] === "center" ) {
  1097. position.left -= elemWidth / 2;
  1098. }
  1099. if ( options.my[ 1 ] === "bottom" ) {
  1100. position.top -= elemHeight;
  1101. } else if ( options.my[ 1 ] === "center" ) {
  1102. position.top -= elemHeight / 2;
  1103. }
  1104. position.left += myOffset[ 0 ];
  1105. position.top += myOffset[ 1 ];
  1106. // if the browser doesn't support fractions, then round for consistent results
  1107. if ( !supportsOffsetFractions ) {
  1108. position.left = round( position.left );
  1109. position.top = round( position.top );
  1110. }
  1111. collisionPosition = {
  1112. marginLeft: marginLeft,
  1113. marginTop: marginTop
  1114. };
  1115. $.each( [ "left", "top" ], function( i, dir ) {
  1116. if ( $.ui.position[ collision[ i ] ] ) {
  1117. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1118. targetWidth: targetWidth,
  1119. targetHeight: targetHeight,
  1120. elemWidth: elemWidth,
  1121. elemHeight: elemHeight,
  1122. collisionPosition: collisionPosition,
  1123. collisionWidth: collisionWidth,
  1124. collisionHeight: collisionHeight,
  1125. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1126. my: options.my,
  1127. at: options.at,
  1128. within: within,
  1129. elem: elem
  1130. });
  1131. }
  1132. });
  1133. if ( options.using ) {
  1134. // adds feedback as second argument to using callback, if present
  1135. using = function( props ) {
  1136. var left = targetOffset.left - position.left,
  1137. right = left + targetWidth - elemWidth,
  1138. top = targetOffset.top - position.top,
  1139. bottom = top + targetHeight - elemHeight,
  1140. feedback = {
  1141. target: {
  1142. element: target,
  1143. left: targetOffset.left,
  1144. top: targetOffset.top,
  1145. width: targetWidth,
  1146. height: targetHeight
  1147. },
  1148. element: {
  1149. element: elem,
  1150. left: position.left,
  1151. top: position.top,
  1152. width: elemWidth,
  1153. height: elemHeight
  1154. },
  1155. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1156. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1157. };
  1158. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1159. feedback.horizontal = "center";
  1160. }
  1161. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1162. feedback.vertical = "middle";
  1163. }
  1164. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1165. feedback.important = "horizontal";
  1166. } else {
  1167. feedback.important = "vertical";
  1168. }
  1169. options.using.call( this, props, feedback );
  1170. };
  1171. }
  1172. elem.offset( $.extend( position, { using: using } ) );
  1173. });
  1174. };
  1175. $.ui.position = {
  1176. fit: {
  1177. left: function( position, data ) {
  1178. var within = data.within,
  1179. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1180. outerWidth = within.width,
  1181. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1182. overLeft = withinOffset - collisionPosLeft,
  1183. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1184. newOverRight;
  1185. // element is wider than within
  1186. if ( data.collisionWidth > outerWidth ) {
  1187. // element is initially over the left side of within
  1188. if ( overLeft > 0 && overRight <= 0 ) {
  1189. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1190. position.left += overLeft - newOverRight;
  1191. // element is initially over right side of within
  1192. } else if ( overRight > 0 && overLeft <= 0 ) {
  1193. position.left = withinOffset;
  1194. // element is initially over both left and right sides of within
  1195. } else {
  1196. if ( overLeft > overRight ) {
  1197. position.left = withinOffset + outerWidth - data.collisionWidth;
  1198. } else {
  1199. position.left = withinOffset;
  1200. }
  1201. }
  1202. // too far left -> align with left edge
  1203. } else if ( overLeft > 0 ) {
  1204. position.left += overLeft;
  1205. // too far right -> align with right edge
  1206. } else if ( overRight > 0 ) {
  1207. position.left -= overRight;
  1208. // adjust based on position and margin
  1209. } else {
  1210. position.left = max( position.left - collisionPosLeft, position.left );
  1211. }
  1212. },
  1213. top: function( position, data ) {
  1214. var within = data.within,
  1215. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1216. outerHeight = data.within.height,
  1217. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1218. overTop = withinOffset - collisionPosTop,
  1219. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1220. newOverBottom;
  1221. // element is taller than within
  1222. if ( data.collisionHeight > outerHeight ) {
  1223. // element is initially over the top of within
  1224. if ( overTop > 0 && overBottom <= 0 ) {
  1225. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1226. position.top += overTop - newOverBottom;
  1227. // element is initially over bottom of within
  1228. } else if ( overBottom > 0 && overTop <= 0 ) {
  1229. position.top = withinOffset;
  1230. // element is initially over both top and bottom of within
  1231. } else {
  1232. if ( overTop > overBottom ) {
  1233. position.top = withinOffset + outerHeight - data.collisionHeight;
  1234. } else {
  1235. position.top = withinOffset;
  1236. }
  1237. }
  1238. // too far up -> align with top
  1239. } else if ( overTop > 0 ) {
  1240. position.top += overTop;
  1241. // too far down -> align with bottom edge
  1242. } else if ( overBottom > 0 ) {
  1243. position.top -= overBottom;
  1244. // adjust based on position and margin
  1245. } else {
  1246. position.top = max( position.top - collisionPosTop, position.top );
  1247. }
  1248. }
  1249. },
  1250. flip: {
  1251. left: function( position, data ) {
  1252. var within = data.within,
  1253. withinOffset = within.offset.left + within.scrollLeft,
  1254. outerWidth = within.width,
  1255. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1256. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1257. overLeft = collisionPosLeft - offsetLeft,
  1258. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1259. myOffset = data.my[ 0 ] === "left" ?
  1260. -data.elemWidth :
  1261. data.my[ 0 ] === "right" ?
  1262. data.elemWidth :
  1263. 0,
  1264. atOffset = data.at[ 0 ] === "left" ?
  1265. data.targetWidth :
  1266. data.at[ 0 ] === "right" ?
  1267. -data.targetWidth :
  1268. 0,
  1269. offset = -2 * data.offset[ 0 ],
  1270. newOverRight,
  1271. newOverLeft;
  1272. if ( overLeft < 0 ) {
  1273. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1274. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1275. position.left += myOffset + atOffset + offset;
  1276. }
  1277. } else if ( overRight > 0 ) {
  1278. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1279. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1280. position.left += myOffset + atOffset + offset;
  1281. }
  1282. }
  1283. },
  1284. top: function( position, data ) {
  1285. var within = data.within,
  1286. withinOffset = within.offset.top + within.scrollTop,
  1287. outerHeight = within.height,
  1288. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1289. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1290. overTop = collisionPosTop - offsetTop,
  1291. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1292. top = data.my[ 1 ] === "top",
  1293. myOffset = top ?
  1294. -data.elemHeight :
  1295. data.my[ 1 ] === "bottom" ?
  1296. data.elemHeight :
  1297. 0,
  1298. atOffset = data.at[ 1 ] === "top" ?
  1299. data.targetHeight :
  1300. data.at[ 1 ] === "bottom" ?
  1301. -data.targetHeight :
  1302. 0,
  1303. offset = -2 * data.offset[ 1 ],
  1304. newOverTop,
  1305. newOverBottom;
  1306. if ( overTop < 0 ) {
  1307. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1308. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1309. position.top += myOffset + atOffset + offset;
  1310. }
  1311. } else if ( overBottom > 0 ) {
  1312. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1313. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1314. position.top += myOffset + atOffset + offset;
  1315. }
  1316. }
  1317. }
  1318. },
  1319. flipfit: {
  1320. left: function() {
  1321. $.ui.position.flip.left.apply( this, arguments );
  1322. $.ui.position.fit.left.apply( this, arguments );
  1323. },
  1324. top: function() {
  1325. $.ui.position.flip.top.apply( this, arguments );
  1326. $.ui.position.fit.top.apply( this, arguments );
  1327. }
  1328. }
  1329. };
  1330. // fraction support test
  1331. (function() {
  1332. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1333. body = document.getElementsByTagName( "body" )[ 0 ],
  1334. div = document.createElement( "div" );
  1335. //Create a "fake body" for testing based on method used in jQuery.support
  1336. testElement = document.createElement( body ? "div" : "body" );
  1337. testElementStyle = {
  1338. visibility: "hidden",
  1339. width: 0,
  1340. height: 0,
  1341. border: 0,
  1342. margin: 0,
  1343. background: "none"
  1344. };
  1345. if ( body ) {
  1346. $.extend( testElementStyle, {
  1347. position: "absolute",
  1348. left: "-1000px",
  1349. top: "-1000px"
  1350. });
  1351. }
  1352. for ( i in testElementStyle ) {
  1353. testElement.style[ i ] = testElementStyle[ i ];
  1354. }
  1355. testElement.appendChild( div );
  1356. testElementParent = body || document.documentElement;
  1357. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1358. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1359. offsetLeft = $( div ).offset().left;
  1360. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1361. testElement.innerHTML = "";
  1362. testElementParent.removeChild( testElement );
  1363. })();
  1364. })();
  1365. var position = $.ui.position;
  1366. /*!
  1367. * jQuery UI Accordion 1.11.4
  1368. * http://jqueryui.com
  1369. *
  1370. * Copyright jQuery Foundation and other contributors
  1371. * Released under the MIT license.
  1372. * http://jquery.org/license
  1373. *
  1374. * http://api.jqueryui.com/accordion/
  1375. */
  1376. var accordion = $.widget( "ui.accordion", {
  1377. version: "1.11.4",
  1378. options: {
  1379. active: 0,
  1380. animate: {},
  1381. collapsible: false,
  1382. event: "click",
  1383. header: "> li > :first-child,> :not(li):even",
  1384. heightStyle: "auto",
  1385. icons: {
  1386. activeHeader: "ui-icon-triangle-1-s",
  1387. header: "ui-icon-triangle-1-e"
  1388. },
  1389. // callbacks
  1390. activate: null,
  1391. beforeActivate: null
  1392. },
  1393. hideProps: {
  1394. borderTopWidth: "hide",
  1395. borderBottomWidth: "hide",
  1396. paddingTop: "hide",
  1397. paddingBottom: "hide",
  1398. height: "hide"
  1399. },
  1400. showProps: {
  1401. borderTopWidth: "show",
  1402. borderBottomWidth: "show",
  1403. paddingTop: "show",
  1404. paddingBottom: "show",
  1405. height: "show"
  1406. },
  1407. _create: function() {
  1408. var options = this.options;
  1409. this.prevShow = this.prevHide = $();
  1410. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  1411. // ARIA
  1412. .attr( "role", "tablist" );
  1413. // don't allow collapsible: false and active: false / null
  1414. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  1415. options.active = 0;
  1416. }
  1417. this._processPanels();
  1418. // handle negative values
  1419. if ( options.active < 0 ) {
  1420. options.active += this.headers.length;
  1421. }
  1422. this._refresh();
  1423. },
  1424. _getCreateEventData: function() {
  1425. return {
  1426. header: this.active,
  1427. panel: !this.active.length ? $() : this.active.next()
  1428. };
  1429. },
  1430. _createIcons: function() {
  1431. var icons = this.options.icons;
  1432. if ( icons ) {
  1433. $( "<span>" )
  1434. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  1435. .prependTo( this.headers );
  1436. this.active.children( ".ui-accordion-header-icon" )
  1437. .removeClass( icons.header )
  1438. .addClass( icons.activeHeader );
  1439. this.headers.addClass( "ui-accordion-icons" );
  1440. }
  1441. },
  1442. _destroyIcons: function() {
  1443. this.headers
  1444. .removeClass( "ui-accordion-icons" )
  1445. .children( ".ui-accordion-header-icon" )
  1446. .remove();
  1447. },
  1448. _destroy: function() {
  1449. var contents;
  1450. // clean up main element
  1451. this.element
  1452. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  1453. .removeAttr( "role" );
  1454. // clean up headers
  1455. this.headers
  1456. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  1457. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  1458. .removeAttr( "role" )
  1459. .removeAttr( "aria-expanded" )
  1460. .removeAttr( "aria-selected" )
  1461. .removeAttr( "aria-controls" )
  1462. .removeAttr( "tabIndex" )
  1463. .removeUniqueId();
  1464. this._destroyIcons();
  1465. // clean up content panels
  1466. contents = this.headers.next()
  1467. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  1468. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  1469. .css( "display", "" )
  1470. .removeAttr( "role" )
  1471. .removeAttr( "aria-hidden" )
  1472. .removeAttr( "aria-labelledby" )
  1473. .removeUniqueId();
  1474. if ( this.options.heightStyle !== "content" ) {
  1475. contents.css( "height", "" );
  1476. }
  1477. },
  1478. _setOption: function( key, value ) {
  1479. if ( key === "active" ) {
  1480. // _activate() will handle invalid values and update this.options
  1481. this._activate( value );
  1482. return;
  1483. }
  1484. if ( key === "event" ) {
  1485. if ( this.options.event ) {
  1486. this._off( this.headers, this.options.event );
  1487. }
  1488. this._setupEvents( value );
  1489. }
  1490. this._super( key, value );
  1491. // setting collapsible: false while collapsed; open first panel
  1492. if ( key === "collapsible" && !value && this.options.active === false ) {
  1493. this._activate( 0 );
  1494. }
  1495. if ( key === "icons" ) {
  1496. this._destroyIcons();
  1497. if ( value ) {
  1498. this._createIcons();
  1499. }
  1500. }
  1501. // #5332 - opacity doesn't cascade to positioned elements in IE
  1502. // so we need to add the disabled class to the headers and panels
  1503. if ( key === "disabled" ) {
  1504. this.element
  1505. .toggleClass( "ui-state-disabled", !!value )
  1506. .attr( "aria-disabled", value );
  1507. this.headers.add( this.headers.next() )
  1508. .toggleClass( "ui-state-disabled", !!value );
  1509. }
  1510. },
  1511. _keydown: function( event ) {
  1512. if ( event.altKey || event.ctrlKey ) {
  1513. return;
  1514. }
  1515. var keyCode = $.ui.keyCode,
  1516. length = this.headers.length,
  1517. currentIndex = this.headers.index( event.target ),
  1518. toFocus = false;
  1519. switch ( event.keyCode ) {
  1520. case keyCode.RIGHT:
  1521. case keyCode.DOWN:
  1522. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  1523. break;
  1524. case keyCode.LEFT:
  1525. case keyCode.UP:
  1526. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  1527. break;
  1528. case keyCode.SPACE:
  1529. case keyCode.ENTER:
  1530. this._eventHandler( event );
  1531. break;
  1532. case keyCode.HOME:
  1533. toFocus = this.headers[ 0 ];
  1534. break;
  1535. case keyCode.END:
  1536. toFocus = this.headers[ length - 1 ];
  1537. break;
  1538. }
  1539. if ( toFocus ) {
  1540. $( event.target ).attr( "tabIndex", -1 );
  1541. $( toFocus ).attr( "tabIndex", 0 );
  1542. toFocus.focus();
  1543. event.preventDefault();
  1544. }
  1545. },
  1546. _panelKeyDown: function( event ) {
  1547. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  1548. $( event.currentTarget ).prev().focus();
  1549. }
  1550. },
  1551. refresh: function() {
  1552. var options = this.options;
  1553. this._processPanels();
  1554. // was collapsed or no panel
  1555. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  1556. options.active = false;
  1557. this.active = $();
  1558. // active false only when collapsible is true
  1559. } else if ( options.active === false ) {
  1560. this._activate( 0 );
  1561. // was active, but active panel is gone
  1562. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1563. // all remaining panel are disabled
  1564. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  1565. options.active = false;
  1566. this.active = $();
  1567. // activate previous panel
  1568. } else {
  1569. this._activate( Math.max( 0, options.active - 1 ) );
  1570. }
  1571. // was active, active panel still exists
  1572. } else {
  1573. // make sure active index is correct
  1574. options.active = this.headers.index( this.active );
  1575. }
  1576. this._destroyIcons();
  1577. this._refresh();
  1578. },
  1579. _processPanels: function() {
  1580. var prevHeaders = this.headers,
  1581. prevPanels = this.panels;
  1582. this.headers = this.element.find( this.options.header )
  1583. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  1584. this.panels = this.headers.next()
  1585. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  1586. .filter( ":not(.ui-accordion-content-active)" )
  1587. .hide();
  1588. // Avoid memory leaks (#10056)
  1589. if ( prevPanels ) {
  1590. this._off( prevHeaders.not( this.headers ) );
  1591. this._off( prevPanels.not( this.panels ) );
  1592. }
  1593. },
  1594. _refresh: function() {
  1595. var maxHeight,
  1596. options = this.options,
  1597. heightStyle = options.heightStyle,
  1598. parent = this.element.parent();
  1599. this.active = this._findActive( options.active )
  1600. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  1601. .removeClass( "ui-corner-all" );
  1602. this.active.next()
  1603. .addClass( "ui-accordion-content-active" )
  1604. .show();
  1605. this.headers
  1606. .attr( "role", "tab" )
  1607. .each(function() {
  1608. var header = $( this ),
  1609. headerId = header.uniqueId().attr( "id" ),
  1610. panel = header.next(),
  1611. panelId = panel.uniqueId().attr( "id" );
  1612. header.attr( "aria-controls", panelId );
  1613. panel.attr( "aria-labelledby", headerId );
  1614. })
  1615. .next()
  1616. .attr( "role", "tabpanel" );
  1617. this.headers
  1618. .not( this.active )
  1619. .attr({
  1620. "aria-selected": "false",
  1621. "aria-expanded": "false",
  1622. tabIndex: -1
  1623. })
  1624. .next()
  1625. .attr({
  1626. "aria-hidden": "true"
  1627. })
  1628. .hide();
  1629. // make sure at least one header is in the tab order
  1630. if ( !this.active.length ) {
  1631. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  1632. } else {
  1633. this.active.attr({
  1634. "aria-selected": "true",
  1635. "aria-expanded": "true",
  1636. tabIndex: 0
  1637. })
  1638. .next()
  1639. .attr({
  1640. "aria-hidden": "false"
  1641. });
  1642. }
  1643. this._createIcons();
  1644. this._setupEvents( options.event );
  1645. if ( heightStyle === "fill" ) {
  1646. maxHeight = parent.height();
  1647. this.element.siblings( ":visible" ).each(function() {
  1648. var elem = $( this ),
  1649. position = elem.css( "position" );
  1650. if ( position === "absolute" || position === "fixed" ) {
  1651. return;
  1652. }
  1653. maxHeight -= elem.outerHeight( true );
  1654. });
  1655. this.headers.each(function() {
  1656. maxHeight -= $( this ).outerHeight( true );
  1657. });
  1658. this.headers.next()
  1659. .each(function() {
  1660. $( this ).height( Math.max( 0, maxHeight -
  1661. $( this ).innerHeight() + $( this ).height() ) );
  1662. })
  1663. .css( "overflow", "auto" );
  1664. } else if ( heightStyle === "auto" ) {
  1665. maxHeight = 0;
  1666. this.headers.next()
  1667. .each(function() {
  1668. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  1669. })
  1670. .height( maxHeight );
  1671. }
  1672. },
  1673. _activate: function( index ) {
  1674. var active = this._findActive( index )[ 0 ];
  1675. // trying to activate the already active panel
  1676. if ( active === this.active[ 0 ] ) {
  1677. return;
  1678. }
  1679. // trying to collapse, simulate a click on the currently active header
  1680. active = active || this.active[ 0 ];
  1681. this._eventHandler({
  1682. target: active,
  1683. currentTarget: active,
  1684. preventDefault: $.noop
  1685. });
  1686. },
  1687. _findActive: function( selector ) {
  1688. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  1689. },
  1690. _setupEvents: function( event ) {
  1691. var events = {
  1692. keydown: "_keydown"
  1693. };
  1694. if ( event ) {
  1695. $.each( event.split( " " ), function( index, eventName ) {
  1696. events[ eventName ] = "_eventHandler";
  1697. });
  1698. }
  1699. this._off( this.headers.add( this.headers.next() ) );
  1700. this._on( this.headers, events );
  1701. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  1702. this._hoverable( this.headers );
  1703. this._focusable( this.headers );
  1704. },
  1705. _eventHandler: function( event ) {
  1706. var options = this.options,
  1707. active = this.active,
  1708. clicked = $( event.currentTarget ),
  1709. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1710. collapsing = clickedIsActive && options.collapsible,
  1711. toShow = collapsing ? $() : clicked.next(),
  1712. toHide = active.next(),
  1713. eventData = {
  1714. oldHeader: active,
  1715. oldPanel: toHide,
  1716. newHeader: collapsing ? $() : clicked,
  1717. newPanel: toShow
  1718. };
  1719. event.preventDefault();
  1720. if (
  1721. // click on active header, but not collapsible
  1722. ( clickedIsActive && !options.collapsible ) ||
  1723. // allow canceling activation
  1724. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1725. return;
  1726. }
  1727. options.active = collapsing ? false : this.headers.index( clicked );
  1728. // when the call to ._toggle() comes after the class changes
  1729. // it causes a very odd bug in IE 8 (see #6720)
  1730. this.active = clickedIsActive ? $() : clicked;
  1731. this._toggle( eventData );
  1732. // switch classes
  1733. // corner classes on the previously active header stay after the animation
  1734. active.removeClass( "ui-accordion-header-active ui-state-active" );
  1735. if ( options.icons ) {
  1736. active.children( ".ui-accordion-header-icon" )
  1737. .removeClass( options.icons.activeHeader )
  1738. .addClass( options.icons.header );
  1739. }
  1740. if ( !clickedIsActive ) {
  1741. clicked
  1742. .removeClass( "ui-corner-all" )
  1743. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  1744. if ( options.icons ) {
  1745. clicked.children( ".ui-accordion-header-icon" )
  1746. .removeClass( options.icons.header )
  1747. .addClass( options.icons.activeHeader );
  1748. }
  1749. clicked
  1750. .next()
  1751. .addClass( "ui-accordion-content-active" );
  1752. }
  1753. },
  1754. _toggle: function( data ) {
  1755. var toShow = data.newPanel,
  1756. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1757. // handle activating a panel during the animation for another activation
  1758. this.prevShow.add( this.prevHide ).stop( true, true );
  1759. this.prevShow = toShow;
  1760. this.prevHide = toHide;
  1761. if ( this.options.animate ) {
  1762. this._animate( toShow, toHide, data );
  1763. } else {
  1764. toHide.hide();
  1765. toShow.show();
  1766. this._toggleComplete( data );
  1767. }
  1768. toHide.attr({
  1769. "aria-hidden": "true"
  1770. });
  1771. toHide.prev().attr({
  1772. "aria-selected": "false",
  1773. "aria-expanded": "false"
  1774. });
  1775. // if we're switching panels, remove the old header from the tab order
  1776. // if we're opening from collapsed state, remove the previous header from the tab order
  1777. // if we're collapsing, then keep the collapsing header in the tab order
  1778. if ( toShow.length && toHide.length ) {
  1779. toHide.prev().attr({
  1780. "tabIndex": -1,
  1781. "aria-expanded": "false"
  1782. });
  1783. } else if ( toShow.length ) {
  1784. this.headers.filter(function() {
  1785. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  1786. })
  1787. .attr( "tabIndex", -1 );
  1788. }
  1789. toShow
  1790. .attr( "aria-hidden", "false" )
  1791. .prev()
  1792. .attr({
  1793. "aria-selected": "true",
  1794. "aria-expanded": "true",
  1795. tabIndex: 0
  1796. });
  1797. },
  1798. _animate: function( toShow, toHide, data ) {
  1799. var total, easing, duration,
  1800. that = this,
  1801. adjust = 0,
  1802. boxSizing = toShow.css( "box-sizing" ),
  1803. down = toShow.length &&
  1804. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1805. animate = this.options.animate || {},
  1806. options = down && animate.down || animate,
  1807. complete = function() {
  1808. that._toggleComplete( data );
  1809. };
  1810. if ( typeof options === "number" ) {
  1811. duration = options;
  1812. }
  1813. if ( typeof options === "string" ) {
  1814. easing = options;
  1815. }
  1816. // fall back from options to animation in case of partial down settings
  1817. easing = easing || options.easing || animate.easing;
  1818. duration = duration || options.duration || animate.duration;
  1819. if ( !toHide.length ) {
  1820. return toShow.animate( this.showProps, duration, easing, complete );
  1821. }
  1822. if ( !toShow.length ) {
  1823. return toHide.animate( this.hideProps, duration, easing, complete );
  1824. }
  1825. total = toShow.show().outerHeight();
  1826. toHide.animate( this.hideProps, {
  1827. duration: duration,
  1828. easing: easing,
  1829. step: function( now, fx ) {
  1830. fx.now = Math.round( now );
  1831. }
  1832. });
  1833. toShow
  1834. .hide()
  1835. .animate( this.showProps, {
  1836. duration: duration,
  1837. easing: easing,
  1838. complete: complete,
  1839. step: function( now, fx ) {
  1840. fx.now = Math.round( now );
  1841. if ( fx.prop !== "height" ) {
  1842. if ( boxSizing === "content-box" ) {
  1843. adjust += fx.now;
  1844. }
  1845. } else if ( that.options.heightStyle !== "content" ) {
  1846. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1847. adjust = 0;
  1848. }
  1849. }
  1850. });
  1851. },
  1852. _toggleComplete: function( data ) {
  1853. var toHide = data.oldPanel;
  1854. toHide
  1855. .removeClass( "ui-accordion-content-active" )
  1856. .prev()
  1857. .removeClass( "ui-corner-top" )
  1858. .addClass( "ui-corner-all" );
  1859. // Work around for rendering bug in IE (#5421)
  1860. if ( toHide.length ) {
  1861. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  1862. }
  1863. this._trigger( "activate", null, data );
  1864. }
  1865. });
  1866. /*!
  1867. * jQuery UI Menu 1.11.4
  1868. * http://jqueryui.com
  1869. *
  1870. * Copyright jQuery Foundation and other contributors
  1871. * Released under the MIT license.
  1872. * http://jquery.org/license
  1873. *
  1874. * http://api.jqueryui.com/menu/
  1875. */
  1876. var menu = $.widget( "ui.menu", {
  1877. version: "1.11.4",
  1878. defaultElement: "<ul>",
  1879. delay: 300,
  1880. options: {
  1881. icons: {
  1882. submenu: "ui-icon-carat-1-e"
  1883. },
  1884. items: "> *",
  1885. menus: "ul",
  1886. position: {
  1887. my: "left-1 top",
  1888. at: "right top"
  1889. },
  1890. role: "menu",
  1891. // callbacks
  1892. blur: null,
  1893. focus: null,
  1894. select: null
  1895. },
  1896. _create: function() {
  1897. this.activeMenu = this.element;
  1898. // Flag used to prevent firing of the click handler
  1899. // as the event bubbles up through nested menus
  1900. this.mouseHandled = false;
  1901. this.element
  1902. .uniqueId()
  1903. .addClass( "ui-menu ui-widget ui-widget-content" )
  1904. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1905. .attr({
  1906. role: this.options.role,
  1907. tabIndex: 0
  1908. });
  1909. if ( this.options.disabled ) {
  1910. this.element
  1911. .addClass( "ui-state-disabled" )
  1912. .attr( "aria-disabled", "true" );
  1913. }
  1914. this._on({
  1915. // Prevent focus from sticking to links inside menu after clicking
  1916. // them (focus should always stay on UL during navigation).
  1917. "mousedown .ui-menu-item": function( event ) {
  1918. event.preventDefault();
  1919. },
  1920. "click .ui-menu-item": function( event ) {
  1921. var target = $( event.target );
  1922. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1923. this.select( event );
  1924. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1925. if ( !event.isPropagationStopped() ) {
  1926. this.mouseHandled = true;
  1927. }
  1928. // Open submenu on click
  1929. if ( target.has( ".ui-menu" ).length ) {
  1930. this.expand( event );
  1931. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1932. // Redirect focus to the menu
  1933. this.element.trigger( "focus", [ true ] );
  1934. // If the active item is on the top level, let it stay active.
  1935. // Otherwise, blur the active item since it is no longer visible.
  1936. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1937. clearTimeout( this.timer );
  1938. }
  1939. }
  1940. }
  1941. },
  1942. "mouseenter .ui-menu-item": function( event ) {
  1943. // Ignore mouse events while typeahead is active, see #10458.
  1944. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  1945. // is over an item in the menu
  1946. if ( this.previousFilter ) {
  1947. return;
  1948. }
  1949. var target = $( event.currentTarget );
  1950. // Remove ui-state-active class from siblings of the newly focused menu item
  1951. // to avoid a jump caused by adjacent elements both having a class with a border
  1952. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1953. this.focus( event, target );
  1954. },
  1955. mouseleave: "collapseAll",
  1956. "mouseleave .ui-menu": "collapseAll",
  1957. focus: function( event, keepActiveItem ) {
  1958. // If there's already an active item, keep it active
  1959. // If not, activate the first item
  1960. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1961. if ( !keepActiveItem ) {
  1962. this.focus( event, item );
  1963. }
  1964. },
  1965. blur: function( event ) {
  1966. this._delay(function() {
  1967. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1968. this.collapseAll( event );
  1969. }
  1970. });
  1971. },
  1972. keydown: "_keydown"
  1973. });
  1974. this.refresh();
  1975. // Clicks outside of a menu collapse any open menus
  1976. this._on( this.document, {
  1977. click: function( event ) {
  1978. if ( this._closeOnDocumentClick( event ) ) {
  1979. this.collapseAll( event );
  1980. }
  1981. // Reset the mouseHandled flag
  1982. this.mouseHandled = false;
  1983. }
  1984. });
  1985. },
  1986. _destroy: function() {
  1987. // Destroy (sub)menus
  1988. this.element
  1989. .removeAttr( "aria-activedescendant" )
  1990. .find( ".ui-menu" ).addBack()
  1991. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1992. .removeAttr( "role" )
  1993. .removeAttr( "tabIndex" )
  1994. .removeAttr( "aria-labelledby" )
  1995. .removeAttr( "aria-expanded" )
  1996. .removeAttr( "aria-hidden" )
  1997. .removeAttr( "aria-disabled" )
  1998. .removeUniqueId()
  1999. .show();
  2000. // Destroy menu items
  2001. this.element.find( ".ui-menu-item" )
  2002. .removeClass( "ui-menu-item" )
  2003. .removeAttr( "role" )
  2004. .removeAttr( "aria-disabled" )
  2005. .removeUniqueId()
  2006. .removeClass( "ui-state-hover" )
  2007. .removeAttr( "tabIndex" )
  2008. .removeAttr( "role" )
  2009. .removeAttr( "aria-haspopup" )
  2010. .children().each( function() {
  2011. var elem = $( this );
  2012. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  2013. elem.remove();
  2014. }
  2015. });
  2016. // Destroy menu dividers
  2017. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  2018. },
  2019. _keydown: function( event ) {
  2020. var match, prev, character, skip,
  2021. preventDefault = true;
  2022. switch ( event.keyCode ) {
  2023. case $.ui.keyCode.PAGE_UP:
  2024. this.previousPage( event );
  2025. break;
  2026. case $.ui.keyCode.PAGE_DOWN:
  2027. this.nextPage( event );
  2028. break;
  2029. case $.ui.keyCode.HOME:
  2030. this._move( "first", "first", event );
  2031. break;
  2032. case $.ui.keyCode.END:
  2033. this._move( "last", "last", event );
  2034. break;
  2035. case $.ui.keyCode.UP:
  2036. this.previous( event );
  2037. break;
  2038. case $.ui.keyCode.DOWN:
  2039. this.next( event );
  2040. break;
  2041. case $.ui.keyCode.LEFT:
  2042. this.collapse( event );
  2043. break;
  2044. case $.ui.keyCode.RIGHT:
  2045. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  2046. this.expand( event );
  2047. }
  2048. break;
  2049. case $.ui.keyCode.ENTER:
  2050. case $.ui.keyCode.SPACE:
  2051. this._activate( event );
  2052. break;
  2053. case $.ui.keyCode.ESCAPE:
  2054. this.collapse( event );
  2055. break;
  2056. default:
  2057. preventDefault = false;
  2058. prev = this.previousFilter || "";
  2059. character = String.fromCharCode( event.keyCode );
  2060. skip = false;
  2061. clearTimeout( this.filterTimer );
  2062. if ( character === prev ) {
  2063. skip = true;
  2064. } else {
  2065. character = prev + character;
  2066. }
  2067. match = this._filterMenuItems( character );
  2068. match = skip && match.index( this.active.next() ) !== -1 ?
  2069. this.active.nextAll( ".ui-menu-item" ) :
  2070. match;
  2071. // If no matches on the current filter, reset to the last character pressed
  2072. // to move down the menu to the first item that starts with that character
  2073. if ( !match.length ) {
  2074. character = String.fromCharCode( event.keyCode );
  2075. match = this._filterMenuItems( character );
  2076. }
  2077. if ( match.length ) {
  2078. this.focus( event, match );
  2079. this.previousFilter = character;
  2080. this.filterTimer = this._delay(function() {
  2081. delete this.previousFilter;
  2082. }, 1000 );
  2083. } else {
  2084. delete this.previousFilter;
  2085. }
  2086. }
  2087. if ( preventDefault ) {
  2088. event.preventDefault();
  2089. }
  2090. },
  2091. _activate: function( event ) {
  2092. if ( !this.active.is( ".ui-state-disabled" ) ) {
  2093. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  2094. this.expand( event );
  2095. } else {
  2096. this.select( event );
  2097. }
  2098. }
  2099. },
  2100. refresh: function() {
  2101. var menus, items,
  2102. that = this,
  2103. icon = this.options.icons.submenu,
  2104. submenus = this.element.find( this.options.menus );
  2105. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  2106. // Initialize nested menus
  2107. submenus.filter( ":not(.ui-menu)" )
  2108. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  2109. .hide()
  2110. .attr({
  2111. role: this.options.role,
  2112. "aria-hidden": "true",
  2113. "aria-expanded": "false"
  2114. })
  2115. .each(function() {
  2116. var menu = $( this ),
  2117. item = menu.parent(),
  2118. submenuCarat = $( "<span>" )
  2119. .addClass( "ui-menu-icon ui-icon " + icon )
  2120. .data( "ui-menu-submenu-carat", true );
  2121. item
  2122. .attr( "aria-haspopup", "true" )
  2123. .prepend( submenuCarat );
  2124. menu.attr( "aria-labelledby", item.attr( "id" ) );
  2125. });
  2126. menus = submenus.add( this.element );
  2127. items = menus.find( this.options.items );
  2128. // Initialize menu-items containing spaces and/or dashes only as dividers
  2129. items.not( ".ui-menu-item" ).each(function() {
  2130. var item = $( this );
  2131. if ( that._isDivider( item ) ) {
  2132. item.addClass( "ui-widget-content ui-menu-divider" );
  2133. }
  2134. });
  2135. // Don't refresh list items that are already adapted
  2136. items.not( ".ui-menu-item, .ui-menu-divider" )
  2137. .addClass( "ui-menu-item" )
  2138. .uniqueId()
  2139. .attr({
  2140. tabIndex: -1,
  2141. role: this._itemRole()
  2142. });
  2143. // Add aria-disabled attribute to any disabled menu item
  2144. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  2145. // If the active item has been removed, blur the menu
  2146. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  2147. this.blur();
  2148. }
  2149. },
  2150. _itemRole: function() {
  2151. return {
  2152. menu: "menuitem",
  2153. listbox: "option"
  2154. }[ this.options.role ];
  2155. },
  2156. _setOption: function( key, value ) {
  2157. if ( key === "icons" ) {
  2158. this.element.find( ".ui-menu-icon" )
  2159. .removeClass( this.options.icons.submenu )
  2160. .addClass( value.submenu );
  2161. }
  2162. if ( key === "disabled" ) {
  2163. this.element
  2164. .toggleClass( "ui-state-disabled", !!value )
  2165. .attr( "aria-disabled", value );
  2166. }
  2167. this._super( key, value );
  2168. },
  2169. focus: function( event, item ) {
  2170. var nested, focused;
  2171. this.blur( event, event && event.type === "focus" );
  2172. this._scrollIntoView( item );
  2173. this.active = item.first();
  2174. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  2175. // Only update aria-activedescendant if there's a role
  2176. // otherwise we assume focus is managed elsewhere
  2177. if ( this.options.role ) {
  2178. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  2179. }
  2180. // Highlight active parent menu item, if any
  2181. this.active
  2182. .parent()
  2183. .closest( ".ui-menu-item" )
  2184. .addClass( "ui-state-active" );
  2185. if ( event && event.type === "keydown" ) {
  2186. this._close();
  2187. } else {
  2188. this.timer = this._delay(function() {
  2189. this._close();
  2190. }, this.delay );
  2191. }
  2192. nested = item.children( ".ui-menu" );
  2193. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  2194. this._startOpening(nested);
  2195. }
  2196. this.activeMenu = item.parent();
  2197. this._trigger( "focus", event, { item: item } );
  2198. },
  2199. _scrollIntoView: function( item ) {
  2200. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  2201. if ( this._hasScroll() ) {
  2202. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  2203. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  2204. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  2205. scroll = this.activeMenu.scrollTop();
  2206. elementHeight = this.activeMenu.height();
  2207. itemHeight = item.outerHeight();
  2208. if ( offset < 0 ) {
  2209. this.activeMenu.scrollTop( scroll + offset );
  2210. } else if ( offset + itemHeight > elementHeight ) {
  2211. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  2212. }
  2213. }
  2214. },
  2215. blur: function( event, fromFocus ) {
  2216. if ( !fromFocus ) {
  2217. clearTimeout( this.timer );
  2218. }
  2219. if ( !this.active ) {
  2220. return;
  2221. }
  2222. this.active.removeClass( "ui-state-focus" );
  2223. this.active = null;
  2224. this._trigger( "blur", event, { item: this.active } );
  2225. },
  2226. _startOpening: function( submenu ) {
  2227. clearTimeout( this.timer );
  2228. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  2229. // shift in the submenu position when mousing over the carat icon
  2230. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  2231. return;
  2232. }
  2233. this.timer = this._delay(function() {
  2234. this._close();
  2235. this._open( submenu );
  2236. }, this.delay );
  2237. },
  2238. _open: function( submenu ) {
  2239. var position = $.extend({
  2240. of: this.active
  2241. }, this.options.position );
  2242. clearTimeout( this.timer );
  2243. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  2244. .hide()
  2245. .attr( "aria-hidden", "true" );
  2246. submenu
  2247. .show()
  2248. .removeAttr( "aria-hidden" )
  2249. .attr( "aria-expanded", "true" )
  2250. .position( position );
  2251. },
  2252. collapseAll: function( event, all ) {
  2253. clearTimeout( this.timer );
  2254. this.timer = this._delay(function() {
  2255. // If we were passed an event, look for the submenu that contains the event
  2256. var currentMenu = all ? this.element :
  2257. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  2258. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  2259. if ( !currentMenu.length ) {
  2260. currentMenu = this.element;
  2261. }
  2262. this._close( currentMenu );
  2263. this.blur( event );
  2264. this.activeMenu = currentMenu;
  2265. }, this.delay );
  2266. },
  2267. // With no arguments, closes the currently active menu - if nothing is active
  2268. // it closes all menus. If passed an argument, it will search for menus BELOW
  2269. _close: function( startMenu ) {
  2270. if ( !startMenu ) {
  2271. startMenu = this.active ? this.active.parent() : this.element;
  2272. }
  2273. startMenu
  2274. .find( ".ui-menu" )
  2275. .hide()
  2276. .attr( "aria-hidden", "true" )
  2277. .attr( "aria-expanded", "false" )
  2278. .end()
  2279. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  2280. .removeClass( "ui-state-active" );
  2281. },
  2282. _closeOnDocumentClick: function( event ) {
  2283. return !$( event.target ).closest( ".ui-menu" ).length;
  2284. },
  2285. _isDivider: function( item ) {
  2286. // Match hyphen, em dash, en dash
  2287. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  2288. },
  2289. collapse: function( event ) {
  2290. var newItem = this.active &&
  2291. this.active.parent().closest( ".ui-menu-item", this.element );
  2292. if ( newItem && newItem.length ) {
  2293. this._close();
  2294. this.focus( event, newItem );
  2295. }
  2296. },
  2297. expand: function( event ) {
  2298. var newItem = this.active &&
  2299. this.active
  2300. .children( ".ui-menu " )
  2301. .find( this.options.items )
  2302. .first();
  2303. if ( newItem && newItem.length ) {
  2304. this._open( newItem.parent() );
  2305. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  2306. this._delay(function() {
  2307. this.focus( event, newItem );
  2308. });
  2309. }
  2310. },
  2311. next: function( event ) {
  2312. this._move( "next", "first", event );
  2313. },
  2314. previous: function( event ) {
  2315. this._move( "prev", "last", event );
  2316. },
  2317. isFirstItem: function() {
  2318. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  2319. },
  2320. isLastItem: function() {
  2321. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  2322. },
  2323. _move: function( direction, filter, event ) {
  2324. var next;
  2325. if ( this.active ) {
  2326. if ( direction === "first" || direction === "last" ) {
  2327. next = this.active
  2328. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  2329. .eq( -1 );
  2330. } else {
  2331. next = this.active
  2332. [ direction + "All" ]( ".ui-menu-item" )
  2333. .eq( 0 );
  2334. }
  2335. }
  2336. if ( !next || !next.length || !this.active ) {
  2337. next = this.activeMenu.find( this.options.items )[ filter ]();
  2338. }
  2339. this.focus( event, next );
  2340. },
  2341. nextPage: function( event ) {
  2342. var item, base, height;
  2343. if ( !this.active ) {
  2344. this.next( event );
  2345. return;
  2346. }
  2347. if ( this.isLastItem() ) {
  2348. return;
  2349. }
  2350. if ( this._hasScroll() ) {
  2351. base = this.active.offset().top;
  2352. height = this.element.height();
  2353. this.active.nextAll( ".ui-menu-item" ).each(function() {
  2354. item = $( this );
  2355. return item.offset().top - base - height < 0;
  2356. });
  2357. this.focus( event, item );
  2358. } else {
  2359. this.focus( event, this.activeMenu.find( this.options.items )
  2360. [ !this.active ? "first" : "last" ]() );
  2361. }
  2362. },
  2363. previousPage: function( event ) {
  2364. var item, base, height;
  2365. if ( !this.active ) {
  2366. this.next( event );
  2367. return;
  2368. }
  2369. if ( this.isFirstItem() ) {
  2370. return;
  2371. }
  2372. if ( this._hasScroll() ) {
  2373. base = this.active.offset().top;
  2374. height = this.element.height();
  2375. this.active.prevAll( ".ui-menu-item" ).each(function() {
  2376. item = $( this );
  2377. return item.offset().top - base + height > 0;
  2378. });
  2379. this.focus( event, item );
  2380. } else {
  2381. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  2382. }
  2383. },
  2384. _hasScroll: function() {
  2385. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  2386. },
  2387. select: function( event ) {
  2388. // TODO: It should never be possible to not have an active item at this
  2389. // point, but the tests don't trigger mouseenter before click.
  2390. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  2391. var ui = { item: this.active };
  2392. if ( !this.active.has( ".ui-menu" ).length ) {
  2393. this.collapseAll( event, true );
  2394. }
  2395. this._trigger( "select", event, ui );
  2396. },
  2397. _filterMenuItems: function(character) {
  2398. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  2399. regex = new RegExp( "^" + escapedCharacter, "i" );
  2400. return this.activeMenu
  2401. .find( this.options.items )
  2402. // Only match on items, not dividers or other content (#10571)
  2403. .filter( ".ui-menu-item" )
  2404. .filter(function() {
  2405. return regex.test( $.trim( $( this ).text() ) );
  2406. });
  2407. }
  2408. });
  2409. /*!
  2410. * jQuery UI Autocomplete 1.11.4
  2411. * http://jqueryui.com
  2412. *
  2413. * Copyright jQuery Foundation and other contributors
  2414. * Released under the MIT license.
  2415. * http://jquery.org/license
  2416. *
  2417. * http://api.jqueryui.com/autocomplete/
  2418. */
  2419. $.widget( "ui.autocomplete", {
  2420. version: "1.11.4",
  2421. defaultElement: "<input>",
  2422. options: {
  2423. appendTo: null,
  2424. autoFocus: false,
  2425. delay: 300,
  2426. minLength: 1,
  2427. position: {
  2428. my: "left top",
  2429. at: "left bottom",
  2430. collision: "none"
  2431. },
  2432. source: null,
  2433. // callbacks
  2434. change: null,
  2435. close: null,
  2436. focus: null,
  2437. open: null,
  2438. response: null,
  2439. search: null,
  2440. select: null
  2441. },
  2442. requestIndex: 0,
  2443. pending: 0,
  2444. _create: function() {
  2445. // Some browsers only repeat keydown events, not keypress events,
  2446. // so we use the suppressKeyPress flag to determine if we've already
  2447. // handled the keydown event. #7269
  2448. // Unfortunately the code for & in keypress is the same as the up arrow,
  2449. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  2450. // events when we know the keydown event was used to modify the
  2451. // search term. #7799
  2452. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  2453. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  2454. isTextarea = nodeName === "textarea",
  2455. isInput = nodeName === "input";
  2456. this.isMultiLine =
  2457. // Textareas are always multi-line
  2458. isTextarea ? true :
  2459. // Inputs are always single-line, even if inside a contentEditable element
  2460. // IE also treats inputs as contentEditable
  2461. isInput ? false :
  2462. // All other element types are determined by whether or not they're contentEditable
  2463. this.element.prop( "isContentEditable" );
  2464. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  2465. this.isNewMenu = true;
  2466. this.element
  2467. .addClass( "ui-autocomplete-input" )
  2468. .attr( "autocomplete", "off" );
  2469. this._on( this.element, {
  2470. keydown: function( event ) {
  2471. if ( this.element.prop( "readOnly" ) ) {
  2472. suppressKeyPress = true;
  2473. suppressInput = true;
  2474. suppressKeyPressRepeat = true;
  2475. return;
  2476. }
  2477. suppressKeyPress = false;
  2478. suppressInput = false;
  2479. suppressKeyPressRepeat = false;
  2480. var keyCode = $.ui.keyCode;
  2481. switch ( event.keyCode ) {
  2482. case keyCode.PAGE_UP:
  2483. suppressKeyPress = true;
  2484. this._move( "previousPage", event );
  2485. break;
  2486. case keyCode.PAGE_DOWN:
  2487. suppressKeyPress = true;
  2488. this._move( "nextPage", event );
  2489. break;
  2490. case keyCode.UP:
  2491. suppressKeyPress = true;
  2492. this._keyEvent( "previous", event );
  2493. break;
  2494. case keyCode.DOWN:
  2495. suppressKeyPress = true;
  2496. this._keyEvent( "next", event );
  2497. break;
  2498. case keyCode.ENTER:
  2499. // when menu is open and has focus
  2500. if ( this.menu.active ) {
  2501. // #6055 - Opera still allows the keypress to occur
  2502. // which causes forms to submit
  2503. suppressKeyPress = true;
  2504. event.preventDefault();
  2505. this.menu.select( event );
  2506. }
  2507. break;
  2508. case keyCode.TAB:
  2509. if ( this.menu.active ) {
  2510. this.menu.select( event );
  2511. }
  2512. break;
  2513. case keyCode.ESCAPE:
  2514. if ( this.menu.element.is( ":visible" ) ) {
  2515. if ( !this.isMultiLine ) {
  2516. this._value( this.term );
  2517. }
  2518. this.close( event );
  2519. // Different browsers have different default behavior for escape
  2520. // Single press can mean undo or clear
  2521. // Double press in IE means clear the whole form
  2522. event.preventDefault();
  2523. }
  2524. break;
  2525. default:
  2526. suppressKeyPressRepeat = true;
  2527. // search timeout should be triggered before the input value is changed
  2528. this._searchTimeout( event );
  2529. break;
  2530. }
  2531. },
  2532. keypress: function( event ) {
  2533. if ( suppressKeyPress ) {
  2534. suppressKeyPress = false;
  2535. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2536. event.preventDefault();
  2537. }
  2538. return;
  2539. }
  2540. if ( suppressKeyPressRepeat ) {
  2541. return;
  2542. }
  2543. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2544. var keyCode = $.ui.keyCode;
  2545. switch ( event.keyCode ) {
  2546. case keyCode.PAGE_UP:
  2547. this._move( "previousPage", event );
  2548. break;
  2549. case keyCode.PAGE_DOWN:
  2550. this._move( "nextPage", event );
  2551. break;
  2552. case keyCode.UP:
  2553. this._keyEvent( "previous", event );
  2554. break;
  2555. case keyCode.DOWN:
  2556. this._keyEvent( "next", event );
  2557. break;
  2558. }
  2559. },
  2560. input: function( event ) {
  2561. if ( suppressInput ) {
  2562. suppressInput = false;
  2563. event.preventDefault();
  2564. return;
  2565. }
  2566. this._searchTimeout( event );
  2567. },
  2568. focus: function() {
  2569. this.selectedItem = null;
  2570. this.previous = this._value();
  2571. },
  2572. blur: function( event ) {
  2573. if ( this.cancelBlur ) {
  2574. delete this.cancelBlur;
  2575. return;
  2576. }
  2577. clearTimeout( this.searching );
  2578. this.close( event );
  2579. this._change( event );
  2580. }
  2581. });
  2582. this._initSource();
  2583. this.menu = $( "<ul>" )
  2584. .addClass( "ui-autocomplete ui-front" )
  2585. .appendTo( this._appendTo() )
  2586. .menu({
  2587. // disable ARIA support, the live region takes care of that
  2588. role: null
  2589. })
  2590. .hide()
  2591. .menu( "instance" );
  2592. this._on( this.menu.element, {
  2593. mousedown: function( event ) {
  2594. // prevent moving focus out of the text field
  2595. event.preventDefault();
  2596. // IE doesn't prevent moving focus even with event.preventDefault()
  2597. // so we set a flag to know when we should ignore the blur event
  2598. this.cancelBlur = true;
  2599. this._delay(function() {
  2600. delete this.cancelBlur;
  2601. });
  2602. // clicking on the scrollbar causes focus to shift to the body
  2603. // but we can't detect a mouseup or a click immediately afterward
  2604. // so we have to track the next mousedown and close the menu if
  2605. // the user clicks somewhere outside of the autocomplete
  2606. var menuElement = this.menu.element[ 0 ];
  2607. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2608. this._delay(function() {
  2609. var that = this;
  2610. this.document.one( "mousedown", function( event ) {
  2611. if ( event.target !== that.element[ 0 ] &&
  2612. event.target !== menuElement &&
  2613. !$.contains( menuElement, event.target ) ) {
  2614. that.close();
  2615. }
  2616. });
  2617. });
  2618. }
  2619. },
  2620. menufocus: function( event, ui ) {
  2621. var label, item;
  2622. // support: Firefox
  2623. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  2624. if ( this.isNewMenu ) {
  2625. this.isNewMenu = false;
  2626. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2627. this.menu.blur();
  2628. this.document.one( "mousemove", function() {
  2629. $( event.target ).trigger( event.originalEvent );
  2630. });
  2631. return;
  2632. }
  2633. }
  2634. item = ui.item.data( "ui-autocomplete-item" );
  2635. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2636. // use value to match what will end up in the input, if it was a key event
  2637. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2638. this._value( item.value );
  2639. }
  2640. }
  2641. // Announce the value in the liveRegion
  2642. label = ui.item.attr( "aria-label" ) || item.value;
  2643. if ( label && $.trim( label ).length ) {
  2644. this.liveRegion.children().hide();
  2645. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  2646. }
  2647. },
  2648. menuselect: function( event, ui ) {
  2649. var item = ui.item.data( "ui-autocomplete-item" ),
  2650. previous = this.previous;
  2651. // only trigger when focus was lost (click on menu)
  2652. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2653. this.element.focus();
  2654. this.previous = previous;
  2655. // #6109 - IE triggers two focus events and the second
  2656. // is asynchronous, so we need to reset the previous
  2657. // term synchronously and asynchronously :-(
  2658. this._delay(function() {
  2659. this.previous = previous;
  2660. this.selectedItem = item;
  2661. });
  2662. }
  2663. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2664. this._value( item.value );
  2665. }
  2666. // reset the term after the select event
  2667. // this allows custom select handling to work properly
  2668. this.term = this._value();
  2669. this.close( event );
  2670. this.selectedItem = item;
  2671. }
  2672. });
  2673. this.liveRegion = $( "<span>", {
  2674. role: "status",
  2675. "aria-live": "assertive",
  2676. "aria-relevant": "additions"
  2677. })
  2678. .addClass( "ui-helper-hidden-accessible" )
  2679. .appendTo( this.document[ 0 ].body );
  2680. // turning off autocomplete prevents the browser from remembering the
  2681. // value when navigating through history, so we re-enable autocomplete
  2682. // if the page is unloaded before the widget is destroyed. #7790
  2683. this._on( this.window, {
  2684. beforeunload: function() {
  2685. this.element.removeAttr( "autocomplete" );
  2686. }
  2687. });
  2688. },
  2689. _destroy: function() {
  2690. clearTimeout( this.searching );
  2691. this.element
  2692. .removeClass( "ui-autocomplete-input" )
  2693. .removeAttr( "autocomplete" );
  2694. this.menu.element.remove();
  2695. this.liveRegion.remove();
  2696. },
  2697. _setOption: function( key, value ) {
  2698. this._super( key, value );
  2699. if ( key === "source" ) {
  2700. this._initSource();
  2701. }
  2702. if ( key === "appendTo" ) {
  2703. this.menu.element.appendTo( this._appendTo() );
  2704. }
  2705. if ( key === "disabled" && value && this.xhr ) {
  2706. this.xhr.abort();
  2707. }
  2708. },
  2709. _appendTo: function() {
  2710. var element = this.options.appendTo;
  2711. if ( element ) {
  2712. element = element.jquery || element.nodeType ?
  2713. $( element ) :
  2714. this.document.find( element ).eq( 0 );
  2715. }
  2716. if ( !element || !element[ 0 ] ) {
  2717. element = this.element.closest( ".ui-front" );
  2718. }
  2719. if ( !element.length ) {
  2720. element = this.document[ 0 ].body;
  2721. }
  2722. return element;
  2723. },
  2724. _initSource: function() {
  2725. var array, url,
  2726. that = this;
  2727. if ( $.isArray( this.options.source ) ) {
  2728. array = this.options.source;
  2729. this.source = function( request, response ) {
  2730. response( $.ui.autocomplete.filter( array, request.term ) );
  2731. };
  2732. } else if ( typeof this.options.source === "string" ) {
  2733. url = this.options.source;
  2734. this.source = function( request, response ) {
  2735. if ( that.xhr ) {
  2736. that.xhr.abort();
  2737. }
  2738. that.xhr = $.ajax({
  2739. url: url,
  2740. data: request,
  2741. dataType: "json",
  2742. success: function( data ) {
  2743. response( data );
  2744. },
  2745. error: function() {
  2746. response([]);
  2747. }
  2748. });
  2749. };
  2750. } else {
  2751. this.source = this.options.source;
  2752. }
  2753. },
  2754. _searchTimeout: function( event ) {
  2755. clearTimeout( this.searching );
  2756. this.searching = this._delay(function() {
  2757. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2758. var equalValues = this.term === this._value(),
  2759. menuVisible = this.menu.element.is( ":visible" ),
  2760. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2761. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2762. this.selectedItem = null;
  2763. this.search( null, event );
  2764. }
  2765. }, this.options.delay );
  2766. },
  2767. search: function( value, event ) {
  2768. value = value != null ? value : this._value();
  2769. // always save the actual value, not the one passed as an argument
  2770. this.term = this._value();
  2771. if ( value.length < this.options.minLength ) {
  2772. return this.close( event );
  2773. }
  2774. if ( this._trigger( "search", event ) === false ) {
  2775. return;
  2776. }
  2777. return this._search( value );
  2778. },
  2779. _search: function( value ) {
  2780. this.pending++;
  2781. this.element.addClass( "ui-autocomplete-loading" );
  2782. this.cancelSearch = false;
  2783. this.source( { term: value }, this._response() );
  2784. },
  2785. _response: function() {
  2786. var index = ++this.requestIndex;
  2787. return $.proxy(function( content ) {
  2788. if ( index === this.requestIndex ) {
  2789. this.__response( content );
  2790. }
  2791. this.pending--;
  2792. if ( !this.pending ) {
  2793. this.element.removeClass( "ui-autocomplete-loading" );
  2794. }
  2795. }, this );
  2796. },
  2797. __response: function( content ) {
  2798. if ( content ) {
  2799. content = this._normalize( content );
  2800. }
  2801. this._trigger( "response", null, { content: content } );
  2802. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2803. this._suggest( content );
  2804. this._trigger( "open" );
  2805. } else {
  2806. // use ._close() instead of .close() so we don't cancel future searches
  2807. this._close();
  2808. }
  2809. },
  2810. close: function( event ) {
  2811. this.cancelSearch = true;
  2812. this._close( event );
  2813. },
  2814. _close: function( event ) {
  2815. if ( this.menu.element.is( ":visible" ) ) {
  2816. this.menu.element.hide();
  2817. this.menu.blur();
  2818. this.isNewMenu = true;
  2819. this._trigger( "close", event );
  2820. }
  2821. },
  2822. _change: function( event ) {
  2823. if ( this.previous !== this._value() ) {
  2824. this._trigger( "change", event, { item: this.selectedItem } );
  2825. }
  2826. },
  2827. _normalize: function( items ) {
  2828. // assume all items have the right format when the first item is complete
  2829. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2830. return items;
  2831. }
  2832. return $.map( items, function( item ) {
  2833. if ( typeof item === "string" ) {
  2834. return {
  2835. label: item,
  2836. value: item
  2837. };
  2838. }
  2839. return $.extend( {}, item, {
  2840. label: item.label || item.value,
  2841. value: item.value || item.label
  2842. });
  2843. });
  2844. },
  2845. _suggest: function( items ) {
  2846. var ul = this.menu.element.empty();
  2847. this._renderMenu( ul, items );
  2848. this.isNewMenu = true;
  2849. this.menu.refresh();
  2850. // size and position menu
  2851. ul.show();
  2852. this._resizeMenu();
  2853. ul.position( $.extend({
  2854. of: this.element
  2855. }, this.options.position ) );
  2856. if ( this.options.autoFocus ) {
  2857. this.menu.next();
  2858. }
  2859. },
  2860. _resizeMenu: function() {
  2861. var ul = this.menu.element;
  2862. ul.outerWidth( Math.max(
  2863. // Firefox wraps long text (possibly a rounding bug)
  2864. // so we add 1px to avoid the wrapping (#7513)
  2865. ul.width( "" ).outerWidth() + 1,
  2866. this.element.outerWidth()
  2867. ) );
  2868. },
  2869. _renderMenu: function( ul, items ) {
  2870. var that = this;
  2871. $.each( items, function( index, item ) {
  2872. that._renderItemData( ul, item );
  2873. });
  2874. },
  2875. _renderItemData: function( ul, item ) {
  2876. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2877. },
  2878. _renderItem: function( ul, item ) {
  2879. return $( "<li>" ).text( item.label ).appendTo( ul );
  2880. },
  2881. _move: function( direction, event ) {
  2882. if ( !this.menu.element.is( ":visible" ) ) {
  2883. this.search( null, event );
  2884. return;
  2885. }
  2886. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2887. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2888. if ( !this.isMultiLine ) {
  2889. this._value( this.term );
  2890. }
  2891. this.menu.blur();
  2892. return;
  2893. }
  2894. this.menu[ direction ]( event );
  2895. },
  2896. widget: function() {
  2897. return this.menu.element;
  2898. },
  2899. _value: function() {
  2900. return this.valueMethod.apply( this.element, arguments );
  2901. },
  2902. _keyEvent: function( keyEvent, event ) {
  2903. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2904. this._move( keyEvent, event );
  2905. // prevents moving cursor to beginning/end of the text field in some browsers
  2906. event.preventDefault();
  2907. }
  2908. }
  2909. });
  2910. $.extend( $.ui.autocomplete, {
  2911. escapeRegex: function( value ) {
  2912. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2913. },
  2914. filter: function( array, term ) {
  2915. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2916. return $.grep( array, function( value ) {
  2917. return matcher.test( value.label || value.value || value );
  2918. });
  2919. }
  2920. });
  2921. // live region extension, adding a `messages` option
  2922. // NOTE: This is an experimental API. We are still investigating
  2923. // a full solution for string manipulation and internationalization.
  2924. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2925. options: {
  2926. messages: {
  2927. noResults: "No search results.",
  2928. results: function( amount ) {
  2929. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2930. " available, use up and down arrow keys to navigate.";
  2931. }
  2932. }
  2933. },
  2934. __response: function( content ) {
  2935. var message;
  2936. this._superApply( arguments );
  2937. if ( this.options.disabled || this.cancelSearch ) {
  2938. return;
  2939. }
  2940. if ( content && content.length ) {
  2941. message = this.options.messages.results( content.length );
  2942. } else {
  2943. message = this.options.messages.noResults;
  2944. }
  2945. this.liveRegion.children().hide();
  2946. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2947. }
  2948. });
  2949. var autocomplete = $.ui.autocomplete;
  2950. /*!
  2951. * jQuery UI Button 1.11.4
  2952. * http://jqueryui.com
  2953. *
  2954. * Copyright jQuery Foundation and other contributors
  2955. * Released under the MIT license.
  2956. * http://jquery.org/license
  2957. *
  2958. * http://api.jqueryui.com/button/
  2959. */
  2960. var lastActive,
  2961. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2962. typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
  2963. formResetHandler = function() {
  2964. var form = $( this );
  2965. setTimeout(function() {
  2966. form.find( ":ui-button" ).button( "refresh" );
  2967. }, 1 );
  2968. },
  2969. radioGroup = function( radio ) {
  2970. var name = radio.name,
  2971. form = radio.form,
  2972. radios = $( [] );
  2973. if ( name ) {
  2974. name = name.replace( /'/g, "\\'" );
  2975. if ( form ) {
  2976. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  2977. } else {
  2978. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  2979. .filter(function() {
  2980. return !this.form;
  2981. });
  2982. }
  2983. }
  2984. return radios;
  2985. };
  2986. $.widget( "ui.button", {
  2987. version: "1.11.4",
  2988. defaultElement: "<button>",
  2989. options: {
  2990. disabled: null,
  2991. text: true,
  2992. label: null,
  2993. icons: {
  2994. primary: null,
  2995. secondary: null
  2996. }
  2997. },
  2998. _create: function() {
  2999. this.element.closest( "form" )
  3000. .unbind( "reset" + this.eventNamespace )
  3001. .bind( "reset" + this.eventNamespace, formResetHandler );
  3002. if ( typeof this.options.disabled !== "boolean" ) {
  3003. this.options.disabled = !!this.element.prop( "disabled" );
  3004. } else {
  3005. this.element.prop( "disabled", this.options.disabled );
  3006. }
  3007. this._determineButtonType();
  3008. this.hasTitle = !!this.buttonElement.attr( "title" );
  3009. var that = this,
  3010. options = this.options,
  3011. toggleButton = this.type === "checkbox" || this.type === "radio",
  3012. activeClass = !toggleButton ? "ui-state-active" : "";
  3013. if ( options.label === null ) {
  3014. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  3015. }
  3016. this._hoverable( this.buttonElement );
  3017. this.buttonElement
  3018. .addClass( baseClasses )
  3019. .attr( "role", "button" )
  3020. .bind( "mouseenter" + this.eventNamespace, function() {
  3021. if ( options.disabled ) {
  3022. return;
  3023. }
  3024. if ( this === lastActive ) {
  3025. $( this ).addClass( "ui-state-active" );
  3026. }
  3027. })
  3028. .bind( "mouseleave" + this.eventNamespace, function() {
  3029. if ( options.disabled ) {
  3030. return;
  3031. }
  3032. $( this ).removeClass( activeClass );
  3033. })
  3034. .bind( "click" + this.eventNamespace, function( event ) {
  3035. if ( options.disabled ) {
  3036. event.preventDefault();
  3037. event.stopImmediatePropagation();
  3038. }
  3039. });
  3040. // Can't use _focusable() because the element that receives focus
  3041. // and the element that gets the ui-state-focus class are different
  3042. this._on({
  3043. focus: function() {
  3044. this.buttonElement.addClass( "ui-state-focus" );
  3045. },
  3046. blur: function() {
  3047. this.buttonElement.removeClass( "ui-state-focus" );
  3048. }
  3049. });
  3050. if ( toggleButton ) {
  3051. this.element.bind( "change" + this.eventNamespace, function() {
  3052. that.refresh();
  3053. });
  3054. }
  3055. if ( this.type === "checkbox" ) {
  3056. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3057. if ( options.disabled ) {
  3058. return false;
  3059. }
  3060. });
  3061. } else if ( this.type === "radio" ) {
  3062. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3063. if ( options.disabled ) {
  3064. return false;
  3065. }
  3066. $( this ).addClass( "ui-state-active" );
  3067. that.buttonElement.attr( "aria-pressed", "true" );
  3068. var radio = that.element[ 0 ];
  3069. radioGroup( radio )
  3070. .not( radio )
  3071. .map(function() {
  3072. return $( this ).button( "widget" )[ 0 ];
  3073. })
  3074. .removeClass( "ui-state-active" )
  3075. .attr( "aria-pressed", "false" );
  3076. });
  3077. } else {
  3078. this.buttonElement
  3079. .bind( "mousedown" + this.eventNamespace, function() {
  3080. if ( options.disabled ) {
  3081. return false;
  3082. }
  3083. $( this ).addClass( "ui-state-active" );
  3084. lastActive = this;
  3085. that.document.one( "mouseup", function() {
  3086. lastActive = null;
  3087. });
  3088. })
  3089. .bind( "mouseup" + this.eventNamespace, function() {
  3090. if ( options.disabled ) {
  3091. return false;
  3092. }
  3093. $( this ).removeClass( "ui-state-active" );
  3094. })
  3095. .bind( "keydown" + this.eventNamespace, function(event) {
  3096. if ( options.disabled ) {
  3097. return false;
  3098. }
  3099. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  3100. $( this ).addClass( "ui-state-active" );
  3101. }
  3102. })
  3103. // see #8559, we bind to blur here in case the button element loses
  3104. // focus between keydown and keyup, it would be left in an "active" state
  3105. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  3106. $( this ).removeClass( "ui-state-active" );
  3107. });
  3108. if ( this.buttonElement.is("a") ) {
  3109. this.buttonElement.keyup(function(event) {
  3110. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  3111. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  3112. $( this ).click();
  3113. }
  3114. });
  3115. }
  3116. }
  3117. this._setOption( "disabled", options.disabled );
  3118. this._resetButton();
  3119. },
  3120. _determineButtonType: function() {
  3121. var ancestor, labelSelector, checked;
  3122. if ( this.element.is("[type=checkbox]") ) {
  3123. this.type = "checkbox";
  3124. } else if ( this.element.is("[type=radio]") ) {
  3125. this.type = "radio";
  3126. } else if ( this.element.is("input") ) {
  3127. this.type = "input";
  3128. } else {
  3129. this.type = "button";
  3130. }
  3131. if ( this.type === "checkbox" || this.type === "radio" ) {
  3132. // we don't search against the document in case the element
  3133. // is disconnected from the DOM
  3134. ancestor = this.element.parents().last();
  3135. labelSelector = "label[for='" + this.element.attr("id") + "']";
  3136. this.buttonElement = ancestor.find( labelSelector );
  3137. if ( !this.buttonElement.length ) {
  3138. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  3139. this.buttonElement = ancestor.filter( labelSelector );
  3140. if ( !this.buttonElement.length ) {
  3141. this.buttonElement = ancestor.find( labelSelector );
  3142. }
  3143. }
  3144. this.element.addClass( "ui-helper-hidden-accessible" );
  3145. checked = this.element.is( ":checked" );
  3146. if ( checked ) {
  3147. this.buttonElement.addClass( "ui-state-active" );
  3148. }
  3149. this.buttonElement.prop( "aria-pressed", checked );
  3150. } else {
  3151. this.buttonElement = this.element;
  3152. }
  3153. },
  3154. widget: function() {
  3155. return this.buttonElement;
  3156. },
  3157. _destroy: function() {
  3158. this.element
  3159. .removeClass( "ui-helper-hidden-accessible" );
  3160. this.buttonElement
  3161. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  3162. .removeAttr( "role" )
  3163. .removeAttr( "aria-pressed" )
  3164. .html( this.buttonElement.find(".ui-button-text").html() );
  3165. if ( !this.hasTitle ) {
  3166. this.buttonElement.removeAttr( "title" );
  3167. }
  3168. },
  3169. _setOption: function( key, value ) {
  3170. this._super( key, value );
  3171. if ( key === "disabled" ) {
  3172. this.widget().toggleClass( "ui-state-disabled", !!value );
  3173. this.element.prop( "disabled", !!value );
  3174. if ( value ) {
  3175. if ( this.type === "checkbox" || this.type === "radio" ) {
  3176. this.buttonElement.removeClass( "ui-state-focus" );
  3177. } else {
  3178. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  3179. }
  3180. }
  3181. return;
  3182. }
  3183. this._resetButton();
  3184. },
  3185. refresh: function() {
  3186. //See #8237 & #8828
  3187. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  3188. if ( isDisabled !== this.options.disabled ) {
  3189. this._setOption( "disabled", isDisabled );
  3190. }
  3191. if ( this.type === "radio" ) {
  3192. radioGroup( this.element[0] ).each(function() {
  3193. if ( $( this ).is( ":checked" ) ) {
  3194. $( this ).button( "widget" )
  3195. .addClass( "ui-state-active" )
  3196. .attr( "aria-pressed", "true" );
  3197. } else {
  3198. $( this ).button( "widget" )
  3199. .removeClass( "ui-state-active" )
  3200. .attr( "aria-pressed", "false" );
  3201. }
  3202. });
  3203. } else if ( this.type === "checkbox" ) {
  3204. if ( this.element.is( ":checked" ) ) {
  3205. this.buttonElement
  3206. .addClass( "ui-state-active" )
  3207. .attr( "aria-pressed", "true" );
  3208. } else {
  3209. this.buttonElement
  3210. .removeClass( "ui-state-active" )
  3211. .attr( "aria-pressed", "false" );
  3212. }
  3213. }
  3214. },
  3215. _resetButton: function() {
  3216. if ( this.type === "input" ) {
  3217. if ( this.options.label ) {
  3218. this.element.val( this.options.label );
  3219. }
  3220. return;
  3221. }
  3222. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  3223. buttonText = $( "<span></span>", this.document[0] )
  3224. .addClass( "ui-button-text" )
  3225. .html( this.options.label )
  3226. .appendTo( buttonElement.empty() )
  3227. .text(),
  3228. icons = this.options.icons,
  3229. multipleIcons = icons.primary && icons.secondary,
  3230. buttonClasses = [];
  3231. if ( icons.primary || icons.secondary ) {
  3232. if ( this.options.text ) {
  3233. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  3234. }
  3235. if ( icons.primary ) {
  3236. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  3237. }
  3238. if ( icons.secondary ) {
  3239. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  3240. }
  3241. if ( !this.options.text ) {
  3242. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  3243. if ( !this.hasTitle ) {
  3244. buttonElement.attr( "title", $.trim( buttonText ) );
  3245. }
  3246. }
  3247. } else {
  3248. buttonClasses.push( "ui-button-text-only" );
  3249. }
  3250. buttonElement.addClass( buttonClasses.join( " " ) );
  3251. }
  3252. });
  3253. $.widget( "ui.buttonset", {
  3254. version: "1.11.4",
  3255. options: {
  3256. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  3257. },
  3258. _create: function() {
  3259. this.element.addClass( "ui-buttonset" );
  3260. },
  3261. _init: function() {
  3262. this.refresh();
  3263. },
  3264. _setOption: function( key, value ) {
  3265. if ( key === "disabled" ) {
  3266. this.buttons.button( "option", key, value );
  3267. }
  3268. this._super( key, value );
  3269. },
  3270. refresh: function() {
  3271. var rtl = this.element.css( "direction" ) === "rtl",
  3272. allButtons = this.element.find( this.options.items ),
  3273. existingButtons = allButtons.filter( ":ui-button" );
  3274. // Initialize new buttons
  3275. allButtons.not( ":ui-button" ).button();
  3276. // Refresh existing buttons
  3277. existingButtons.button( "refresh" );
  3278. this.buttons = allButtons
  3279. .map(function() {
  3280. return $( this ).button( "widget" )[ 0 ];
  3281. })
  3282. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  3283. .filter( ":first" )
  3284. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  3285. .end()
  3286. .filter( ":last" )
  3287. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  3288. .end()
  3289. .end();
  3290. },
  3291. _destroy: function() {
  3292. this.element.removeClass( "ui-buttonset" );
  3293. this.buttons
  3294. .map(function() {
  3295. return $( this ).button( "widget" )[ 0 ];
  3296. })
  3297. .removeClass( "ui-corner-left ui-corner-right" )
  3298. .end()
  3299. .button( "destroy" );
  3300. }
  3301. });
  3302. var button = $.ui.button;
  3303. /*!
  3304. * jQuery UI Datepicker 1.11.4
  3305. * http://jqueryui.com
  3306. *
  3307. * Copyright jQuery Foundation and other contributors
  3308. * Released under the MIT license.
  3309. * http://jquery.org/license
  3310. *
  3311. * http://api.jqueryui.com/datepicker/
  3312. */
  3313. $.extend($.ui, { datepicker: { version: "1.11.4" } });
  3314. var datepicker_instActive;
  3315. function datepicker_getZindex( elem ) {
  3316. var position, value;
  3317. while ( elem.length && elem[ 0 ] !== document ) {
  3318. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  3319. // This makes behavior of this function consistent across browsers
  3320. // WebKit always returns auto if the element is positioned
  3321. position = elem.css( "position" );
  3322. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  3323. // IE returns 0 when zIndex is not specified
  3324. // other browsers return a string
  3325. // we ignore the case of nested elements with an explicit value of 0
  3326. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  3327. value = parseInt( elem.css( "zIndex" ), 10 );
  3328. if ( !isNaN( value ) && value !== 0 ) {
  3329. return value;
  3330. }
  3331. }
  3332. elem = elem.parent();
  3333. }
  3334. return 0;
  3335. }
  3336. /* Date picker manager.
  3337. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  3338. Settings for (groups of) date pickers are maintained in an instance object,
  3339. allowing multiple different settings on the same page. */
  3340. function Datepicker() {
  3341. this._curInst = null; // The current instance in use
  3342. this._keyEvent = false; // If the last event was a key event
  3343. this._disabledInputs = []; // List of date picker inputs that have been disabled
  3344. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  3345. this._inDialog = false; // True if showing within a "dialog", false if not
  3346. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  3347. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  3348. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  3349. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  3350. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  3351. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  3352. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  3353. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  3354. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  3355. this.regional = []; // Available regional settings, indexed by language code
  3356. this.regional[""] = { // Default regional settings
  3357. closeText: "Done", // Display text for close link
  3358. prevText: "Prev", // Display text for previous month link
  3359. nextText: "Next", // Display text for next month link
  3360. currentText: "Today", // Display text for current month link
  3361. monthNames: ["January","February","March","April","May","June",
  3362. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  3363. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  3364. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  3365. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  3366. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  3367. weekHeader: "Wk", // Column header for week of the year
  3368. dateFormat: "mm/dd/yy", // See format options on parseDate
  3369. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  3370. isRTL: false, // True if right-to-left language, false if left-to-right
  3371. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  3372. yearSuffix: "" // Additional text to append to the year in the month headers
  3373. };
  3374. this._defaults = { // Global defaults for all the date picker instances
  3375. showOn: "focus", // "focus" for popup on focus,
  3376. // "button" for trigger button, or "both" for either
  3377. showAnim: "fadeIn", // Name of jQuery animation for popup
  3378. showOptions: {}, // Options for enhanced animations
  3379. defaultDate: null, // Used when field is blank: actual date,
  3380. // +/-number for offset from today, null for today
  3381. appendText: "", // Display text following the input box, e.g. showing the format
  3382. buttonText: "...", // Text for trigger button
  3383. buttonImage: "", // URL for trigger button image
  3384. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  3385. hideIfNoPrevNext: false, // True to hide next/previous month links
  3386. // if not applicable, false to just disable them
  3387. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  3388. gotoCurrent: false, // True if today link goes back to current selection instead
  3389. changeMonth: false, // True if month can be selected directly, false if only prev/next
  3390. changeYear: false, // True if year can be selected directly, false if only prev/next
  3391. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  3392. // either relative to today's year (-nn:+nn), relative to currently displayed year
  3393. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  3394. showOtherMonths: false, // True to show dates in other months, false to leave blank
  3395. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  3396. showWeek: false, // True to show week of the year, false to not show it
  3397. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  3398. // takes a Date and returns the number of the week for it
  3399. shortYearCutoff: "+10", // Short year values < this are in the current century,
  3400. // > this are in the previous century,
  3401. // string value starting with "+" for current year + value
  3402. minDate: null, // The earliest selectable date, or null for no limit
  3403. maxDate: null, // The latest selectable date, or null for no limit
  3404. duration: "fast", // Duration of display/closure
  3405. beforeShowDay: null, // Function that takes a date and returns an array with
  3406. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  3407. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  3408. beforeShow: null, // Function that takes an input field and
  3409. // returns a set of custom settings for the date picker
  3410. onSelect: null, // Define a callback function when a date is selected
  3411. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  3412. onClose: null, // Define a callback function when the datepicker is closed
  3413. numberOfMonths: 1, // Number of months to show at a time
  3414. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  3415. stepMonths: 1, // Number of months to step back/forward
  3416. stepBigMonths: 12, // Number of months to step back/forward for the big links
  3417. altField: "", // Selector for an alternate field to store selected dates into
  3418. altFormat: "", // The date format to use for the alternate field
  3419. constrainInput: true, // The input is constrained by the current date format
  3420. showButtonPanel: false, // True to show button panel, false to not show it
  3421. autoSize: false, // True to size the input for the date format, false to leave as is
  3422. disabled: false // The initial disabled state
  3423. };
  3424. $.extend(this._defaults, this.regional[""]);
  3425. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  3426. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  3427. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  3428. }
  3429. $.extend(Datepicker.prototype, {
  3430. /* Class name added to elements to indicate already configured with a date picker. */
  3431. markerClassName: "hasDatepicker",
  3432. //Keep track of the maximum number of rows displayed (see #7043)
  3433. maxRows: 4,
  3434. // TODO rename to "widget" when switching to widget factory
  3435. _widgetDatepicker: function() {
  3436. return this.dpDiv;
  3437. },
  3438. /* Override the default settings for all instances of the date picker.
  3439. * @param settings object - the new settings to use as defaults (anonymous object)
  3440. * @return the manager object
  3441. */
  3442. setDefaults: function(settings) {
  3443. datepicker_extendRemove(this._defaults, settings || {});
  3444. return this;
  3445. },
  3446. /* Attach the date picker to a jQuery selection.
  3447. * @param target element - the target input field or division or span
  3448. * @param settings object - the new settings to use for this date picker instance (anonymous)
  3449. */
  3450. _attachDatepicker: function(target, settings) {
  3451. var nodeName, inline, inst;
  3452. nodeName = target.nodeName.toLowerCase();
  3453. inline = (nodeName === "div" || nodeName === "span");
  3454. if (!target.id) {
  3455. this.uuid += 1;
  3456. target.id = "dp" + this.uuid;
  3457. }
  3458. inst = this._newInst($(target), inline);
  3459. inst.settings = $.extend({}, settings || {});
  3460. if (nodeName === "input") {
  3461. this._connectDatepicker(target, inst);
  3462. } else if (inline) {
  3463. this._inlineDatepicker(target, inst);
  3464. }
  3465. },
  3466. /* Create a new instance object. */
  3467. _newInst: function(target, inline) {
  3468. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  3469. return {id: id, input: target, // associated target
  3470. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  3471. drawMonth: 0, drawYear: 0, // month being drawn
  3472. inline: inline, // is datepicker inline or not
  3473. dpDiv: (!inline ? this.dpDiv : // presentation div
  3474. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  3475. },
  3476. /* Attach the date picker to an input field. */
  3477. _connectDatepicker: function(target, inst) {
  3478. var input = $(target);
  3479. inst.append = $([]);
  3480. inst.trigger = $([]);
  3481. if (input.hasClass(this.markerClassName)) {
  3482. return;
  3483. }
  3484. this._attachments(input, inst);
  3485. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  3486. keypress(this._doKeyPress).keyup(this._doKeyUp);
  3487. this._autoSize(inst);
  3488. $.data(target, "datepicker", inst);
  3489. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  3490. if( inst.settings.disabled ) {
  3491. this._disableDatepicker( target );
  3492. }
  3493. },
  3494. /* Make attachments based on settings. */
  3495. _attachments: function(input, inst) {
  3496. var showOn, buttonText, buttonImage,
  3497. appendText = this._get(inst, "appendText"),
  3498. isRTL = this._get(inst, "isRTL");
  3499. if (inst.append) {
  3500. inst.append.remove();
  3501. }
  3502. if (appendText) {
  3503. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  3504. input[isRTL ? "before" : "after"](inst.append);
  3505. }
  3506. input.unbind("focus", this._showDatepicker);
  3507. if (inst.trigger) {
  3508. inst.trigger.remove();
  3509. }
  3510. showOn = this._get(inst, "showOn");
  3511. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  3512. input.focus(this._showDatepicker);
  3513. }
  3514. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  3515. buttonText = this._get(inst, "buttonText");
  3516. buttonImage = this._get(inst, "buttonImage");
  3517. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  3518. $("<img/>").addClass(this._triggerClass).
  3519. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  3520. $("<button type='button'></button>").addClass(this._triggerClass).
  3521. html(!buttonImage ? buttonText : $("<img/>").attr(
  3522. { src:buttonImage, alt:buttonText, title:buttonText })));
  3523. input[isRTL ? "before" : "after"](inst.trigger);
  3524. inst.trigger.click(function() {
  3525. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  3526. $.datepicker._hideDatepicker();
  3527. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  3528. $.datepicker._hideDatepicker();
  3529. $.datepicker._showDatepicker(input[0]);
  3530. } else {
  3531. $.datepicker._showDatepicker(input[0]);
  3532. }
  3533. return false;
  3534. });
  3535. }
  3536. },
  3537. /* Apply the maximum length for the date format. */
  3538. _autoSize: function(inst) {
  3539. if (this._get(inst, "autoSize") && !inst.inline) {
  3540. var findMax, max, maxI, i,
  3541. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  3542. dateFormat = this._get(inst, "dateFormat");
  3543. if (dateFormat.match(/[DM]/)) {
  3544. findMax = function(names) {
  3545. max = 0;
  3546. maxI = 0;
  3547. for (i = 0; i < names.length; i++) {
  3548. if (names[i].length > max) {
  3549. max = names[i].length;
  3550. maxI = i;
  3551. }
  3552. }
  3553. return maxI;
  3554. };
  3555. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  3556. "monthNames" : "monthNamesShort"))));
  3557. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  3558. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  3559. }
  3560. inst.input.attr("size", this._formatDate(inst, date).length);
  3561. }
  3562. },
  3563. /* Attach an inline date picker to a div. */
  3564. _inlineDatepicker: function(target, inst) {
  3565. var divSpan = $(target);
  3566. if (divSpan.hasClass(this.markerClassName)) {
  3567. return;
  3568. }
  3569. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  3570. $.data(target, "datepicker", inst);
  3571. this._setDate(inst, this._getDefaultDate(inst), true);
  3572. this._updateDatepicker(inst);
  3573. this._updateAlternate(inst);
  3574. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  3575. if( inst.settings.disabled ) {
  3576. this._disableDatepicker( target );
  3577. }
  3578. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  3579. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  3580. inst.dpDiv.css( "display", "block" );
  3581. },
  3582. /* Pop-up the date picker in a "dialog" box.
  3583. * @param input element - ignored
  3584. * @param date string or Date - the initial date to display
  3585. * @param onSelect function - the function to call when a date is selected
  3586. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  3587. * @param pos int[2] - coordinates for the dialog's position within the screen or
  3588. * event - with x/y coordinates or
  3589. * leave empty for default (screen centre)
  3590. * @return the manager object
  3591. */
  3592. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  3593. var id, browserWidth, browserHeight, scrollX, scrollY,
  3594. inst = this._dialogInst; // internal instance
  3595. if (!inst) {
  3596. this.uuid += 1;
  3597. id = "dp" + this.uuid;
  3598. this._dialogInput = $("<input type='text' id='" + id +
  3599. "' style='position: absolute; top: -100px; width: 0px;'/>");
  3600. this._dialogInput.keydown(this._doKeyDown);
  3601. $("body").append(this._dialogInput);
  3602. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  3603. inst.settings = {};
  3604. $.data(this._dialogInput[0], "datepicker", inst);
  3605. }
  3606. datepicker_extendRemove(inst.settings, settings || {});
  3607. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  3608. this._dialogInput.val(date);
  3609. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  3610. if (!this._pos) {
  3611. browserWidth = document.documentElement.clientWidth;
  3612. browserHeight = document.documentElement.clientHeight;
  3613. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  3614. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  3615. this._pos = // should use actual width/height below
  3616. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  3617. }
  3618. // move input on screen for focus, but hidden behind dialog
  3619. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  3620. inst.settings.onSelect = onSelect;
  3621. this._inDialog = true;
  3622. this.dpDiv.addClass(this._dialogClass);
  3623. this._showDatepicker(this._dialogInput[0]);
  3624. if ($.blockUI) {
  3625. $.blockUI(this.dpDiv);
  3626. }
  3627. $.data(this._dialogInput[0], "datepicker", inst);
  3628. return this;
  3629. },
  3630. /* Detach a datepicker from its control.
  3631. * @param target element - the target input field or division or span
  3632. */
  3633. _destroyDatepicker: function(target) {
  3634. var nodeName,
  3635. $target = $(target),
  3636. inst = $.data(target, "datepicker");
  3637. if (!$target.hasClass(this.markerClassName)) {
  3638. return;
  3639. }
  3640. nodeName = target.nodeName.toLowerCase();
  3641. $.removeData(target, "datepicker");
  3642. if (nodeName === "input") {
  3643. inst.append.remove();
  3644. inst.trigger.remove();
  3645. $target.removeClass(this.markerClassName).
  3646. unbind("focus", this._showDatepicker).
  3647. unbind("keydown", this._doKeyDown).
  3648. unbind("keypress", this._doKeyPress).
  3649. unbind("keyup", this._doKeyUp);
  3650. } else if (nodeName === "div" || nodeName === "span") {
  3651. $target.removeClass(this.markerClassName).empty();
  3652. }
  3653. if ( datepicker_instActive === inst ) {
  3654. datepicker_instActive = null;
  3655. }
  3656. },
  3657. /* Enable the date picker to a jQuery selection.
  3658. * @param target element - the target input field or division or span
  3659. */
  3660. _enableDatepicker: function(target) {
  3661. var nodeName, inline,
  3662. $target = $(target),
  3663. inst = $.data(target, "datepicker");
  3664. if (!$target.hasClass(this.markerClassName)) {
  3665. return;
  3666. }
  3667. nodeName = target.nodeName.toLowerCase();
  3668. if (nodeName === "input") {
  3669. target.disabled = false;
  3670. inst.trigger.filter("button").
  3671. each(function() { this.disabled = false; }).end().
  3672. filter("img").css({opacity: "1.0", cursor: ""});
  3673. } else if (nodeName === "div" || nodeName === "span") {
  3674. inline = $target.children("." + this._inlineClass);
  3675. inline.children().removeClass("ui-state-disabled");
  3676. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3677. prop("disabled", false);
  3678. }
  3679. this._disabledInputs = $.map(this._disabledInputs,
  3680. function(value) { return (value === target ? null : value); }); // delete entry
  3681. },
  3682. /* Disable the date picker to a jQuery selection.
  3683. * @param target element - the target input field or division or span
  3684. */
  3685. _disableDatepicker: function(target) {
  3686. var nodeName, inline,
  3687. $target = $(target),
  3688. inst = $.data(target, "datepicker");
  3689. if (!$target.hasClass(this.markerClassName)) {
  3690. return;
  3691. }
  3692. nodeName = target.nodeName.toLowerCase();
  3693. if (nodeName === "input") {
  3694. target.disabled = true;
  3695. inst.trigger.filter("button").
  3696. each(function() { this.disabled = true; }).end().
  3697. filter("img").css({opacity: "0.5", cursor: "default"});
  3698. } else if (nodeName === "div" || nodeName === "span") {
  3699. inline = $target.children("." + this._inlineClass);
  3700. inline.children().addClass("ui-state-disabled");
  3701. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3702. prop("disabled", true);
  3703. }
  3704. this._disabledInputs = $.map(this._disabledInputs,
  3705. function(value) { return (value === target ? null : value); }); // delete entry
  3706. this._disabledInputs[this._disabledInputs.length] = target;
  3707. },
  3708. /* Is the first field in a jQuery collection disabled as a datepicker?
  3709. * @param target element - the target input field or division or span
  3710. * @return boolean - true if disabled, false if enabled
  3711. */
  3712. _isDisabledDatepicker: function(target) {
  3713. if (!target) {
  3714. return false;
  3715. }
  3716. for (var i = 0; i < this._disabledInputs.length; i++) {
  3717. if (this._disabledInputs[i] === target) {
  3718. return true;
  3719. }
  3720. }
  3721. return false;
  3722. },
  3723. /* Retrieve the instance data for the target control.
  3724. * @param target element - the target input field or division or span
  3725. * @return object - the associated instance data
  3726. * @throws error if a jQuery problem getting data
  3727. */
  3728. _getInst: function(target) {
  3729. try {
  3730. return $.data(target, "datepicker");
  3731. }
  3732. catch (err) {
  3733. throw "Missing instance data for this datepicker";
  3734. }
  3735. },
  3736. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3737. * @param target element - the target input field or division or span
  3738. * @param name object - the new settings to update or
  3739. * string - the name of the setting to change or retrieve,
  3740. * when retrieving also "all" for all instance settings or
  3741. * "defaults" for all global defaults
  3742. * @param value any - the new value for the setting
  3743. * (omit if above is an object or to retrieve a value)
  3744. */
  3745. _optionDatepicker: function(target, name, value) {
  3746. var settings, date, minDate, maxDate,
  3747. inst = this._getInst(target);
  3748. if (arguments.length === 2 && typeof name === "string") {
  3749. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  3750. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  3751. this._get(inst, name)) : null));
  3752. }
  3753. settings = name || {};
  3754. if (typeof name === "string") {
  3755. settings = {};
  3756. settings[name] = value;
  3757. }
  3758. if (inst) {
  3759. if (this._curInst === inst) {
  3760. this._hideDatepicker();
  3761. }
  3762. date = this._getDateDatepicker(target, true);
  3763. minDate = this._getMinMaxDate(inst, "min");
  3764. maxDate = this._getMinMaxDate(inst, "max");
  3765. datepicker_extendRemove(inst.settings, settings);
  3766. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3767. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  3768. inst.settings.minDate = this._formatDate(inst, minDate);
  3769. }
  3770. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  3771. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3772. }
  3773. if ( "disabled" in settings ) {
  3774. if ( settings.disabled ) {
  3775. this._disableDatepicker(target);
  3776. } else {
  3777. this._enableDatepicker(target);
  3778. }
  3779. }
  3780. this._attachments($(target), inst);
  3781. this._autoSize(inst);
  3782. this._setDate(inst, date);
  3783. this._updateAlternate(inst);
  3784. this._updateDatepicker(inst);
  3785. }
  3786. },
  3787. // change method deprecated
  3788. _changeDatepicker: function(target, name, value) {
  3789. this._optionDatepicker(target, name, value);
  3790. },
  3791. /* Redraw the date picker attached to an input field or division.
  3792. * @param target element - the target input field or division or span
  3793. */
  3794. _refreshDatepicker: function(target) {
  3795. var inst = this._getInst(target);
  3796. if (inst) {
  3797. this._updateDatepicker(inst);
  3798. }
  3799. },
  3800. /* Set the dates for a jQuery selection.
  3801. * @param target element - the target input field or division or span
  3802. * @param date Date - the new date
  3803. */
  3804. _setDateDatepicker: function(target, date) {
  3805. var inst = this._getInst(target);
  3806. if (inst) {
  3807. this._setDate(inst, date);
  3808. this._updateDatepicker(inst);
  3809. this._updateAlternate(inst);
  3810. }
  3811. },
  3812. /* Get the date(s) for the first entry in a jQuery selection.
  3813. * @param target element - the target input field or division or span
  3814. * @param noDefault boolean - true if no default date is to be used
  3815. * @return Date - the current date
  3816. */
  3817. _getDateDatepicker: function(target, noDefault) {
  3818. var inst = this._getInst(target);
  3819. if (inst && !inst.inline) {
  3820. this._setDateFromField(inst, noDefault);
  3821. }
  3822. return (inst ? this._getDate(inst) : null);
  3823. },
  3824. /* Handle keystrokes. */
  3825. _doKeyDown: function(event) {
  3826. var onSelect, dateStr, sel,
  3827. inst = $.datepicker._getInst(event.target),
  3828. handled = true,
  3829. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  3830. inst._keyEvent = true;
  3831. if ($.datepicker._datepickerShowing) {
  3832. switch (event.keyCode) {
  3833. case 9: $.datepicker._hideDatepicker();
  3834. handled = false;
  3835. break; // hide on tab out
  3836. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  3837. $.datepicker._currentClass + ")", inst.dpDiv);
  3838. if (sel[0]) {
  3839. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3840. }
  3841. onSelect = $.datepicker._get(inst, "onSelect");
  3842. if (onSelect) {
  3843. dateStr = $.datepicker._formatDate(inst);
  3844. // trigger custom callback
  3845. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3846. } else {
  3847. $.datepicker._hideDatepicker();
  3848. }
  3849. return false; // don't submit the form
  3850. case 27: $.datepicker._hideDatepicker();
  3851. break; // hide on escape
  3852. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3853. -$.datepicker._get(inst, "stepBigMonths") :
  3854. -$.datepicker._get(inst, "stepMonths")), "M");
  3855. break; // previous month/year on page up/+ ctrl
  3856. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3857. +$.datepicker._get(inst, "stepBigMonths") :
  3858. +$.datepicker._get(inst, "stepMonths")), "M");
  3859. break; // next month/year on page down/+ ctrl
  3860. case 35: if (event.ctrlKey || event.metaKey) {
  3861. $.datepicker._clearDate(event.target);
  3862. }
  3863. handled = event.ctrlKey || event.metaKey;
  3864. break; // clear on ctrl or command +end
  3865. case 36: if (event.ctrlKey || event.metaKey) {
  3866. $.datepicker._gotoToday(event.target);
  3867. }
  3868. handled = event.ctrlKey || event.metaKey;
  3869. break; // current on ctrl or command +home
  3870. case 37: if (event.ctrlKey || event.metaKey) {
  3871. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3872. }
  3873. handled = event.ctrlKey || event.metaKey;
  3874. // -1 day on ctrl or command +left
  3875. if (event.originalEvent.altKey) {
  3876. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3877. -$.datepicker._get(inst, "stepBigMonths") :
  3878. -$.datepicker._get(inst, "stepMonths")), "M");
  3879. }
  3880. // next month/year on alt +left on Mac
  3881. break;
  3882. case 38: if (event.ctrlKey || event.metaKey) {
  3883. $.datepicker._adjustDate(event.target, -7, "D");
  3884. }
  3885. handled = event.ctrlKey || event.metaKey;
  3886. break; // -1 week on ctrl or command +up
  3887. case 39: if (event.ctrlKey || event.metaKey) {
  3888. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3889. }
  3890. handled = event.ctrlKey || event.metaKey;
  3891. // +1 day on ctrl or command +right
  3892. if (event.originalEvent.altKey) {
  3893. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3894. +$.datepicker._get(inst, "stepBigMonths") :
  3895. +$.datepicker._get(inst, "stepMonths")), "M");
  3896. }
  3897. // next month/year on alt +right
  3898. break;
  3899. case 40: if (event.ctrlKey || event.metaKey) {
  3900. $.datepicker._adjustDate(event.target, +7, "D");
  3901. }
  3902. handled = event.ctrlKey || event.metaKey;
  3903. break; // +1 week on ctrl or command +down
  3904. default: handled = false;
  3905. }
  3906. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3907. $.datepicker._showDatepicker(this);
  3908. } else {
  3909. handled = false;
  3910. }
  3911. if (handled) {
  3912. event.preventDefault();
  3913. event.stopPropagation();
  3914. }
  3915. },
  3916. /* Filter entered characters - based on date format. */
  3917. _doKeyPress: function(event) {
  3918. var chars, chr,
  3919. inst = $.datepicker._getInst(event.target);
  3920. if ($.datepicker._get(inst, "constrainInput")) {
  3921. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3922. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3923. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3924. }
  3925. },
  3926. /* Synchronise manual entry and field/alternate field. */
  3927. _doKeyUp: function(event) {
  3928. var date,
  3929. inst = $.datepicker._getInst(event.target);
  3930. if (inst.input.val() !== inst.lastVal) {
  3931. try {
  3932. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3933. (inst.input ? inst.input.val() : null),
  3934. $.datepicker._getFormatConfig(inst));
  3935. if (date) { // only if valid
  3936. $.datepicker._setDateFromField(inst);
  3937. $.datepicker._updateAlternate(inst);
  3938. $.datepicker._updateDatepicker(inst);
  3939. }
  3940. }
  3941. catch (err) {
  3942. }
  3943. }
  3944. return true;
  3945. },
  3946. /* Pop-up the date picker for a given input field.
  3947. * If false returned from beforeShow event handler do not show.
  3948. * @param input element - the input field attached to the date picker or
  3949. * event - if triggered by focus
  3950. */
  3951. _showDatepicker: function(input) {
  3952. input = input.target || input;
  3953. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3954. input = $("input", input.parentNode)[0];
  3955. }
  3956. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3957. return;
  3958. }
  3959. var inst, beforeShow, beforeShowSettings, isFixed,
  3960. offset, showAnim, duration;
  3961. inst = $.datepicker._getInst(input);
  3962. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3963. $.datepicker._curInst.dpDiv.stop(true, true);
  3964. if ( inst && $.datepicker._datepickerShowing ) {
  3965. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3966. }
  3967. }
  3968. beforeShow = $.datepicker._get(inst, "beforeShow");
  3969. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3970. if(beforeShowSettings === false){
  3971. return;
  3972. }
  3973. datepicker_extendRemove(inst.settings, beforeShowSettings);
  3974. inst.lastVal = null;
  3975. $.datepicker._lastInput = input;
  3976. $.datepicker._setDateFromField(inst);
  3977. if ($.datepicker._inDialog) { // hide cursor
  3978. input.value = "";
  3979. }
  3980. if (!$.datepicker._pos) { // position below input
  3981. $.datepicker._pos = $.datepicker._findPos(input);
  3982. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3983. }
  3984. isFixed = false;
  3985. $(input).parents().each(function() {
  3986. isFixed |= $(this).css("position") === "fixed";
  3987. return !isFixed;
  3988. });
  3989. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3990. $.datepicker._pos = null;
  3991. //to avoid flashes on Firefox
  3992. inst.dpDiv.empty();
  3993. // determine sizing offscreen
  3994. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  3995. $.datepicker._updateDatepicker(inst);
  3996. // fix width for dynamic number of date pickers
  3997. // and adjust position before showing
  3998. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3999. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  4000. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  4001. left: offset.left + "px", top: offset.top + "px"});
  4002. if (!inst.inline) {
  4003. showAnim = $.datepicker._get(inst, "showAnim");
  4004. duration = $.datepicker._get(inst, "duration");
  4005. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  4006. $.datepicker._datepickerShowing = true;
  4007. if ( $.effects && $.effects.effect[ showAnim ] ) {
  4008. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  4009. } else {
  4010. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  4011. }
  4012. if ( $.datepicker._shouldFocusInput( inst ) ) {
  4013. inst.input.focus();
  4014. }
  4015. $.datepicker._curInst = inst;
  4016. }
  4017. },
  4018. /* Generate the date picker content. */
  4019. _updateDatepicker: function(inst) {
  4020. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  4021. datepicker_instActive = inst; // for delegate hover events
  4022. inst.dpDiv.empty().append(this._generateHTML(inst));
  4023. this._attachHandlers(inst);
  4024. var origyearshtml,
  4025. numMonths = this._getNumberOfMonths(inst),
  4026. cols = numMonths[1],
  4027. width = 17,
  4028. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  4029. if ( activeCell.length > 0 ) {
  4030. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  4031. }
  4032. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  4033. if (cols > 1) {
  4034. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  4035. }
  4036. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  4037. "Class"]("ui-datepicker-multi");
  4038. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  4039. "Class"]("ui-datepicker-rtl");
  4040. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  4041. inst.input.focus();
  4042. }
  4043. // deffered render of the years select (to avoid flashes on Firefox)
  4044. if( inst.yearshtml ){
  4045. origyearshtml = inst.yearshtml;
  4046. setTimeout(function(){
  4047. //assure that inst.yearshtml didn't change.
  4048. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  4049. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  4050. }
  4051. origyearshtml = inst.yearshtml = null;
  4052. }, 0);
  4053. }
  4054. },
  4055. // #6694 - don't focus the input if it's already focused
  4056. // this breaks the change event in IE
  4057. // Support: IE and jQuery <1.9
  4058. _shouldFocusInput: function( inst ) {
  4059. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  4060. },
  4061. /* Check positioning to remain on screen. */
  4062. _checkOffset: function(inst, offset, isFixed) {
  4063. var dpWidth = inst.dpDiv.outerWidth(),
  4064. dpHeight = inst.dpDiv.outerHeight(),
  4065. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  4066. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  4067. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  4068. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  4069. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  4070. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  4071. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  4072. // now check if datepicker is showing outside window viewport - move to a better place if so.
  4073. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  4074. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  4075. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  4076. Math.abs(dpHeight + inputHeight) : 0);
  4077. return offset;
  4078. },
  4079. /* Find an object's position on the screen. */
  4080. _findPos: function(obj) {
  4081. var position,
  4082. inst = this._getInst(obj),
  4083. isRTL = this._get(inst, "isRTL");
  4084. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  4085. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  4086. }
  4087. position = $(obj).offset();
  4088. return [position.left, position.top];
  4089. },
  4090. /* Hide the date picker from view.
  4091. * @param input element - the input field attached to the date picker
  4092. */
  4093. _hideDatepicker: function(input) {
  4094. var showAnim, duration, postProcess, onClose,
  4095. inst = this._curInst;
  4096. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  4097. return;
  4098. }
  4099. if (this._datepickerShowing) {
  4100. showAnim = this._get(inst, "showAnim");
  4101. duration = this._get(inst, "duration");
  4102. postProcess = function() {
  4103. $.datepicker._tidyDialog(inst);
  4104. };
  4105. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  4106. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  4107. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  4108. } else {
  4109. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  4110. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  4111. }
  4112. if (!showAnim) {
  4113. postProcess();
  4114. }
  4115. this._datepickerShowing = false;
  4116. onClose = this._get(inst, "onClose");
  4117. if (onClose) {
  4118. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  4119. }
  4120. this._lastInput = null;
  4121. if (this._inDialog) {
  4122. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  4123. if ($.blockUI) {
  4124. $.unblockUI();
  4125. $("body").append(this.dpDiv);
  4126. }
  4127. }
  4128. this._inDialog = false;
  4129. }
  4130. },
  4131. /* Tidy up after a dialog display. */
  4132. _tidyDialog: function(inst) {
  4133. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  4134. },
  4135. /* Close date picker if clicked elsewhere. */
  4136. _checkExternalClick: function(event) {
  4137. if (!$.datepicker._curInst) {
  4138. return;
  4139. }
  4140. var $target = $(event.target),
  4141. inst = $.datepicker._getInst($target[0]);
  4142. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  4143. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  4144. !$target.hasClass($.datepicker.markerClassName) &&
  4145. !$target.closest("." + $.datepicker._triggerClass).length &&
  4146. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  4147. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  4148. $.datepicker._hideDatepicker();
  4149. }
  4150. },
  4151. /* Adjust one of the date sub-fields. */
  4152. _adjustDate: function(id, offset, period) {
  4153. var target = $(id),
  4154. inst = this._getInst(target[0]);
  4155. if (this._isDisabledDatepicker(target[0])) {
  4156. return;
  4157. }
  4158. this._adjustInstDate(inst, offset +
  4159. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  4160. period);
  4161. this._updateDatepicker(inst);
  4162. },
  4163. /* Action for current link. */
  4164. _gotoToday: function(id) {
  4165. var date,
  4166. target = $(id),
  4167. inst = this._getInst(target[0]);
  4168. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  4169. inst.selectedDay = inst.currentDay;
  4170. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  4171. inst.drawYear = inst.selectedYear = inst.currentYear;
  4172. } else {
  4173. date = new Date();
  4174. inst.selectedDay = date.getDate();
  4175. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4176. inst.drawYear = inst.selectedYear = date.getFullYear();
  4177. }
  4178. this._notifyChange(inst);
  4179. this._adjustDate(target);
  4180. },
  4181. /* Action for selecting a new month/year. */
  4182. _selectMonthYear: function(id, select, period) {
  4183. var target = $(id),
  4184. inst = this._getInst(target[0]);
  4185. inst["selected" + (period === "M" ? "Month" : "Year")] =
  4186. inst["draw" + (period === "M" ? "Month" : "Year")] =
  4187. parseInt(select.options[select.selectedIndex].value,10);
  4188. this._notifyChange(inst);
  4189. this._adjustDate(target);
  4190. },
  4191. /* Action for selecting a day. */
  4192. _selectDay: function(id, month, year, td) {
  4193. var inst,
  4194. target = $(id);
  4195. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  4196. return;
  4197. }
  4198. inst = this._getInst(target[0]);
  4199. inst.selectedDay = inst.currentDay = $("a", td).html();
  4200. inst.selectedMonth = inst.currentMonth = month;
  4201. inst.selectedYear = inst.currentYear = year;
  4202. this._selectDate(id, this._formatDate(inst,
  4203. inst.currentDay, inst.currentMonth, inst.currentYear));
  4204. },
  4205. /* Erase the input field and hide the date picker. */
  4206. _clearDate: function(id) {
  4207. var target = $(id);
  4208. this._selectDate(target, "");
  4209. },
  4210. /* Update the input field with the selected date. */
  4211. _selectDate: function(id, dateStr) {
  4212. var onSelect,
  4213. target = $(id),
  4214. inst = this._getInst(target[0]);
  4215. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  4216. if (inst.input) {
  4217. inst.input.val(dateStr);
  4218. }
  4219. this._updateAlternate(inst);
  4220. onSelect = this._get(inst, "onSelect");
  4221. if (onSelect) {
  4222. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  4223. } else if (inst.input) {
  4224. inst.input.trigger("change"); // fire the change event
  4225. }
  4226. if (inst.inline){
  4227. this._updateDatepicker(inst);
  4228. } else {
  4229. this._hideDatepicker();
  4230. this._lastInput = inst.input[0];
  4231. if (typeof(inst.input[0]) !== "object") {
  4232. inst.input.focus(); // restore focus
  4233. }
  4234. this._lastInput = null;
  4235. }
  4236. },
  4237. /* Update any alternate field to synchronise with the main field. */
  4238. _updateAlternate: function(inst) {
  4239. var altFormat, date, dateStr,
  4240. altField = this._get(inst, "altField");
  4241. if (altField) { // update alternate field too
  4242. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  4243. date = this._getDate(inst);
  4244. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  4245. $(altField).each(function() { $(this).val(dateStr); });
  4246. }
  4247. },
  4248. /* Set as beforeShowDay function to prevent selection of weekends.
  4249. * @param date Date - the date to customise
  4250. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  4251. */
  4252. noWeekends: function(date) {
  4253. var day = date.getDay();
  4254. return [(day > 0 && day < 6), ""];
  4255. },
  4256. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  4257. * @param date Date - the date to get the week for
  4258. * @return number - the number of the week within the year that contains this date
  4259. */
  4260. iso8601Week: function(date) {
  4261. var time,
  4262. checkDate = new Date(date.getTime());
  4263. // Find Thursday of this week starting on Monday
  4264. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  4265. time = checkDate.getTime();
  4266. checkDate.setMonth(0); // Compare with Jan 1
  4267. checkDate.setDate(1);
  4268. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  4269. },
  4270. /* Parse a string value into a date object.
  4271. * See formatDate below for the possible formats.
  4272. *
  4273. * @param format string - the expected format of the date
  4274. * @param value string - the date in the above format
  4275. * @param settings Object - attributes include:
  4276. * shortYearCutoff number - the cutoff year for determining the century (optional)
  4277. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4278. * dayNames string[7] - names of the days from Sunday (optional)
  4279. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4280. * monthNames string[12] - names of the months (optional)
  4281. * @return Date - the extracted date value or null if value is blank
  4282. */
  4283. parseDate: function (format, value, settings) {
  4284. if (format == null || value == null) {
  4285. throw "Invalid arguments";
  4286. }
  4287. value = (typeof value === "object" ? value.toString() : value + "");
  4288. if (value === "") {
  4289. return null;
  4290. }
  4291. var iFormat, dim, extra,
  4292. iValue = 0,
  4293. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  4294. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  4295. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  4296. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4297. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4298. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4299. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4300. year = -1,
  4301. month = -1,
  4302. day = -1,
  4303. doy = -1,
  4304. literal = false,
  4305. date,
  4306. // Check whether a format character is doubled
  4307. lookAhead = function(match) {
  4308. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4309. if (matches) {
  4310. iFormat++;
  4311. }
  4312. return matches;
  4313. },
  4314. // Extract a number from the string value
  4315. getNumber = function(match) {
  4316. var isDoubled = lookAhead(match),
  4317. size = (match === "@" ? 14 : (match === "!" ? 20 :
  4318. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  4319. minSize = (match === "y" ? size : 1),
  4320. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  4321. num = value.substring(iValue).match(digits);
  4322. if (!num) {
  4323. throw "Missing number at position " + iValue;
  4324. }
  4325. iValue += num[0].length;
  4326. return parseInt(num[0], 10);
  4327. },
  4328. // Extract a name from the string value and convert to an index
  4329. getName = function(match, shortNames, longNames) {
  4330. var index = -1,
  4331. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  4332. return [ [k, v] ];
  4333. }).sort(function (a, b) {
  4334. return -(a[1].length - b[1].length);
  4335. });
  4336. $.each(names, function (i, pair) {
  4337. var name = pair[1];
  4338. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  4339. index = pair[0];
  4340. iValue += name.length;
  4341. return false;
  4342. }
  4343. });
  4344. if (index !== -1) {
  4345. return index + 1;
  4346. } else {
  4347. throw "Unknown name at position " + iValue;
  4348. }
  4349. },
  4350. // Confirm that a literal character matches the string value
  4351. checkLiteral = function() {
  4352. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  4353. throw "Unexpected literal at position " + iValue;
  4354. }
  4355. iValue++;
  4356. };
  4357. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4358. if (literal) {
  4359. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4360. literal = false;
  4361. } else {
  4362. checkLiteral();
  4363. }
  4364. } else {
  4365. switch (format.charAt(iFormat)) {
  4366. case "d":
  4367. day = getNumber("d");
  4368. break;
  4369. case "D":
  4370. getName("D", dayNamesShort, dayNames);
  4371. break;
  4372. case "o":
  4373. doy = getNumber("o");
  4374. break;
  4375. case "m":
  4376. month = getNumber("m");
  4377. break;
  4378. case "M":
  4379. month = getName("M", monthNamesShort, monthNames);
  4380. break;
  4381. case "y":
  4382. year = getNumber("y");
  4383. break;
  4384. case "@":
  4385. date = new Date(getNumber("@"));
  4386. year = date.getFullYear();
  4387. month = date.getMonth() + 1;
  4388. day = date.getDate();
  4389. break;
  4390. case "!":
  4391. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  4392. year = date.getFullYear();
  4393. month = date.getMonth() + 1;
  4394. day = date.getDate();
  4395. break;
  4396. case "'":
  4397. if (lookAhead("'")){
  4398. checkLiteral();
  4399. } else {
  4400. literal = true;
  4401. }
  4402. break;
  4403. default:
  4404. checkLiteral();
  4405. }
  4406. }
  4407. }
  4408. if (iValue < value.length){
  4409. extra = value.substr(iValue);
  4410. if (!/^\s+/.test(extra)) {
  4411. throw "Extra/unparsed characters found in date: " + extra;
  4412. }
  4413. }
  4414. if (year === -1) {
  4415. year = new Date().getFullYear();
  4416. } else if (year < 100) {
  4417. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  4418. (year <= shortYearCutoff ? 0 : -100);
  4419. }
  4420. if (doy > -1) {
  4421. month = 1;
  4422. day = doy;
  4423. do {
  4424. dim = this._getDaysInMonth(year, month - 1);
  4425. if (day <= dim) {
  4426. break;
  4427. }
  4428. month++;
  4429. day -= dim;
  4430. } while (true);
  4431. }
  4432. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  4433. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  4434. throw "Invalid date"; // E.g. 31/02/00
  4435. }
  4436. return date;
  4437. },
  4438. /* Standard date formats. */
  4439. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  4440. COOKIE: "D, dd M yy",
  4441. ISO_8601: "yy-mm-dd",
  4442. RFC_822: "D, d M y",
  4443. RFC_850: "DD, dd-M-y",
  4444. RFC_1036: "D, d M y",
  4445. RFC_1123: "D, d M yy",
  4446. RFC_2822: "D, d M yy",
  4447. RSS: "D, d M y", // RFC 822
  4448. TICKS: "!",
  4449. TIMESTAMP: "@",
  4450. W3C: "yy-mm-dd", // ISO 8601
  4451. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  4452. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  4453. /* Format a date object into a string value.
  4454. * The format can be combinations of the following:
  4455. * d - day of month (no leading zero)
  4456. * dd - day of month (two digit)
  4457. * o - day of year (no leading zeros)
  4458. * oo - day of year (three digit)
  4459. * D - day name short
  4460. * DD - day name long
  4461. * m - month of year (no leading zero)
  4462. * mm - month of year (two digit)
  4463. * M - month name short
  4464. * MM - month name long
  4465. * y - year (two digit)
  4466. * yy - year (four digit)
  4467. * @ - Unix timestamp (ms since 01/01/1970)
  4468. * ! - Windows ticks (100ns since 01/01/0001)
  4469. * "..." - literal text
  4470. * '' - single quote
  4471. *
  4472. * @param format string - the desired format of the date
  4473. * @param date Date - the date value to format
  4474. * @param settings Object - attributes include:
  4475. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4476. * dayNames string[7] - names of the days from Sunday (optional)
  4477. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4478. * monthNames string[12] - names of the months (optional)
  4479. * @return string - the date in the above format
  4480. */
  4481. formatDate: function (format, date, settings) {
  4482. if (!date) {
  4483. return "";
  4484. }
  4485. var iFormat,
  4486. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4487. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4488. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4489. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4490. // Check whether a format character is doubled
  4491. lookAhead = function(match) {
  4492. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4493. if (matches) {
  4494. iFormat++;
  4495. }
  4496. return matches;
  4497. },
  4498. // Format a number, with leading zero if necessary
  4499. formatNumber = function(match, value, len) {
  4500. var num = "" + value;
  4501. if (lookAhead(match)) {
  4502. while (num.length < len) {
  4503. num = "0" + num;
  4504. }
  4505. }
  4506. return num;
  4507. },
  4508. // Format a name, short or long as requested
  4509. formatName = function(match, value, shortNames, longNames) {
  4510. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  4511. },
  4512. output = "",
  4513. literal = false;
  4514. if (date) {
  4515. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4516. if (literal) {
  4517. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4518. literal = false;
  4519. } else {
  4520. output += format.charAt(iFormat);
  4521. }
  4522. } else {
  4523. switch (format.charAt(iFormat)) {
  4524. case "d":
  4525. output += formatNumber("d", date.getDate(), 2);
  4526. break;
  4527. case "D":
  4528. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  4529. break;
  4530. case "o":
  4531. output += formatNumber("o",
  4532. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  4533. break;
  4534. case "m":
  4535. output += formatNumber("m", date.getMonth() + 1, 2);
  4536. break;
  4537. case "M":
  4538. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  4539. break;
  4540. case "y":
  4541. output += (lookAhead("y") ? date.getFullYear() :
  4542. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  4543. break;
  4544. case "@":
  4545. output += date.getTime();
  4546. break;
  4547. case "!":
  4548. output += date.getTime() * 10000 + this._ticksTo1970;
  4549. break;
  4550. case "'":
  4551. if (lookAhead("'")) {
  4552. output += "'";
  4553. } else {
  4554. literal = true;
  4555. }
  4556. break;
  4557. default:
  4558. output += format.charAt(iFormat);
  4559. }
  4560. }
  4561. }
  4562. }
  4563. return output;
  4564. },
  4565. /* Extract all possible characters from the date format. */
  4566. _possibleChars: function (format) {
  4567. var iFormat,
  4568. chars = "",
  4569. literal = false,
  4570. // Check whether a format character is doubled
  4571. lookAhead = function(match) {
  4572. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4573. if (matches) {
  4574. iFormat++;
  4575. }
  4576. return matches;
  4577. };
  4578. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4579. if (literal) {
  4580. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4581. literal = false;
  4582. } else {
  4583. chars += format.charAt(iFormat);
  4584. }
  4585. } else {
  4586. switch (format.charAt(iFormat)) {
  4587. case "d": case "m": case "y": case "@":
  4588. chars += "0123456789";
  4589. break;
  4590. case "D": case "M":
  4591. return null; // Accept anything
  4592. case "'":
  4593. if (lookAhead("'")) {
  4594. chars += "'";
  4595. } else {
  4596. literal = true;
  4597. }
  4598. break;
  4599. default:
  4600. chars += format.charAt(iFormat);
  4601. }
  4602. }
  4603. }
  4604. return chars;
  4605. },
  4606. /* Get a setting value, defaulting if necessary. */
  4607. _get: function(inst, name) {
  4608. return inst.settings[name] !== undefined ?
  4609. inst.settings[name] : this._defaults[name];
  4610. },
  4611. /* Parse existing date and initialise date picker. */
  4612. _setDateFromField: function(inst, noDefault) {
  4613. if (inst.input.val() === inst.lastVal) {
  4614. return;
  4615. }
  4616. var dateFormat = this._get(inst, "dateFormat"),
  4617. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  4618. defaultDate = this._getDefaultDate(inst),
  4619. date = defaultDate,
  4620. settings = this._getFormatConfig(inst);
  4621. try {
  4622. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  4623. } catch (event) {
  4624. dates = (noDefault ? "" : dates);
  4625. }
  4626. inst.selectedDay = date.getDate();
  4627. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4628. inst.drawYear = inst.selectedYear = date.getFullYear();
  4629. inst.currentDay = (dates ? date.getDate() : 0);
  4630. inst.currentMonth = (dates ? date.getMonth() : 0);
  4631. inst.currentYear = (dates ? date.getFullYear() : 0);
  4632. this._adjustInstDate(inst);
  4633. },
  4634. /* Retrieve the default date shown on opening. */
  4635. _getDefaultDate: function(inst) {
  4636. return this._restrictMinMax(inst,
  4637. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  4638. },
  4639. /* A date may be specified as an exact value or a relative one. */
  4640. _determineDate: function(inst, date, defaultDate) {
  4641. var offsetNumeric = function(offset) {
  4642. var date = new Date();
  4643. date.setDate(date.getDate() + offset);
  4644. return date;
  4645. },
  4646. offsetString = function(offset) {
  4647. try {
  4648. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  4649. offset, $.datepicker._getFormatConfig(inst));
  4650. }
  4651. catch (e) {
  4652. // Ignore
  4653. }
  4654. var date = (offset.toLowerCase().match(/^c/) ?
  4655. $.datepicker._getDate(inst) : null) || new Date(),
  4656. year = date.getFullYear(),
  4657. month = date.getMonth(),
  4658. day = date.getDate(),
  4659. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  4660. matches = pattern.exec(offset);
  4661. while (matches) {
  4662. switch (matches[2] || "d") {
  4663. case "d" : case "D" :
  4664. day += parseInt(matches[1],10); break;
  4665. case "w" : case "W" :
  4666. day += parseInt(matches[1],10) * 7; break;
  4667. case "m" : case "M" :
  4668. month += parseInt(matches[1],10);
  4669. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4670. break;
  4671. case "y": case "Y" :
  4672. year += parseInt(matches[1],10);
  4673. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4674. break;
  4675. }
  4676. matches = pattern.exec(offset);
  4677. }
  4678. return new Date(year, month, day);
  4679. },
  4680. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  4681. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4682. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  4683. if (newDate) {
  4684. newDate.setHours(0);
  4685. newDate.setMinutes(0);
  4686. newDate.setSeconds(0);
  4687. newDate.setMilliseconds(0);
  4688. }
  4689. return this._daylightSavingAdjust(newDate);
  4690. },
  4691. /* Handle switch to/from daylight saving.
  4692. * Hours may be non-zero on daylight saving cut-over:
  4693. * > 12 when midnight changeover, but then cannot generate
  4694. * midnight datetime, so jump to 1AM, otherwise reset.
  4695. * @param date (Date) the date to check
  4696. * @return (Date) the corrected date
  4697. */
  4698. _daylightSavingAdjust: function(date) {
  4699. if (!date) {
  4700. return null;
  4701. }
  4702. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4703. return date;
  4704. },
  4705. /* Set the date(s) directly. */
  4706. _setDate: function(inst, date, noChange) {
  4707. var clear = !date,
  4708. origMonth = inst.selectedMonth,
  4709. origYear = inst.selectedYear,
  4710. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4711. inst.selectedDay = inst.currentDay = newDate.getDate();
  4712. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4713. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4714. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  4715. this._notifyChange(inst);
  4716. }
  4717. this._adjustInstDate(inst);
  4718. if (inst.input) {
  4719. inst.input.val(clear ? "" : this._formatDate(inst));
  4720. }
  4721. },
  4722. /* Retrieve the date(s) directly. */
  4723. _getDate: function(inst) {
  4724. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  4725. this._daylightSavingAdjust(new Date(
  4726. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4727. return startDate;
  4728. },
  4729. /* Attach the onxxx handlers. These are declared statically so
  4730. * they work with static code transformers like Caja.
  4731. */
  4732. _attachHandlers: function(inst) {
  4733. var stepMonths = this._get(inst, "stepMonths"),
  4734. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  4735. inst.dpDiv.find("[data-handler]").map(function () {
  4736. var handler = {
  4737. prev: function () {
  4738. $.datepicker._adjustDate(id, -stepMonths, "M");
  4739. },
  4740. next: function () {
  4741. $.datepicker._adjustDate(id, +stepMonths, "M");
  4742. },
  4743. hide: function () {
  4744. $.datepicker._hideDatepicker();
  4745. },
  4746. today: function () {
  4747. $.datepicker._gotoToday(id);
  4748. },
  4749. selectDay: function () {
  4750. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  4751. return false;
  4752. },
  4753. selectMonth: function () {
  4754. $.datepicker._selectMonthYear(id, this, "M");
  4755. return false;
  4756. },
  4757. selectYear: function () {
  4758. $.datepicker._selectMonthYear(id, this, "Y");
  4759. return false;
  4760. }
  4761. };
  4762. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  4763. });
  4764. },
  4765. /* Generate the HTML for the current state of the date picker. */
  4766. _generateHTML: function(inst) {
  4767. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  4768. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  4769. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  4770. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  4771. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  4772. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  4773. tempDate = new Date(),
  4774. today = this._daylightSavingAdjust(
  4775. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  4776. isRTL = this._get(inst, "isRTL"),
  4777. showButtonPanel = this._get(inst, "showButtonPanel"),
  4778. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  4779. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  4780. numMonths = this._getNumberOfMonths(inst),
  4781. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  4782. stepMonths = this._get(inst, "stepMonths"),
  4783. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  4784. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4785. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  4786. minDate = this._getMinMaxDate(inst, "min"),
  4787. maxDate = this._getMinMaxDate(inst, "max"),
  4788. drawMonth = inst.drawMonth - showCurrentAtPos,
  4789. drawYear = inst.drawYear;
  4790. if (drawMonth < 0) {
  4791. drawMonth += 12;
  4792. drawYear--;
  4793. }
  4794. if (maxDate) {
  4795. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4796. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4797. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4798. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4799. drawMonth--;
  4800. if (drawMonth < 0) {
  4801. drawMonth = 11;
  4802. drawYear--;
  4803. }
  4804. }
  4805. }
  4806. inst.drawMonth = drawMonth;
  4807. inst.drawYear = drawYear;
  4808. prevText = this._get(inst, "prevText");
  4809. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4810. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4811. this._getFormatConfig(inst)));
  4812. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4813. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  4814. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  4815. (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
  4816. nextText = this._get(inst, "nextText");
  4817. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4818. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4819. this._getFormatConfig(inst)));
  4820. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4821. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  4822. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  4823. (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
  4824. currentText = this._get(inst, "currentText");
  4825. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  4826. currentText = (!navigationAsDateFormat ? currentText :
  4827. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4828. controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
  4829. this._get(inst, "closeText") + "</button>" : "");
  4830. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  4831. (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
  4832. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  4833. firstDay = parseInt(this._get(inst, "firstDay"),10);
  4834. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4835. showWeek = this._get(inst, "showWeek");
  4836. dayNames = this._get(inst, "dayNames");
  4837. dayNamesMin = this._get(inst, "dayNamesMin");
  4838. monthNames = this._get(inst, "monthNames");
  4839. monthNamesShort = this._get(inst, "monthNamesShort");
  4840. beforeShowDay = this._get(inst, "beforeShowDay");
  4841. showOtherMonths = this._get(inst, "showOtherMonths");
  4842. selectOtherMonths = this._get(inst, "selectOtherMonths");
  4843. defaultDate = this._getDefaultDate(inst);
  4844. html = "";
  4845. dow;
  4846. for (row = 0; row < numMonths[0]; row++) {
  4847. group = "";
  4848. this.maxRows = 4;
  4849. for (col = 0; col < numMonths[1]; col++) {
  4850. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4851. cornerClass = " ui-corner-all";
  4852. calender = "";
  4853. if (isMultiMonth) {
  4854. calender += "<div class='ui-datepicker-group";
  4855. if (numMonths[1] > 1) {
  4856. switch (col) {
  4857. case 0: calender += " ui-datepicker-group-first";
  4858. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4859. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  4860. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4861. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4862. }
  4863. }
  4864. calender += "'>";
  4865. }
  4866. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4867. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4868. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4869. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4870. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4871. "</div><table class='ui-datepicker-calendar'><thead>" +
  4872. "<tr>";
  4873. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4874. for (dow = 0; dow < 7; dow++) { // days of the week
  4875. day = (dow + firstDay) % 7;
  4876. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4877. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4878. }
  4879. calender += thead + "</tr></thead><tbody>";
  4880. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4881. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4882. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4883. }
  4884. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4885. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4886. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4887. this.maxRows = numRows;
  4888. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4889. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4890. calender += "<tr>";
  4891. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4892. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4893. for (dow = 0; dow < 7; dow++) { // create date picker days
  4894. daySettings = (beforeShowDay ?
  4895. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4896. otherMonth = (printDate.getMonth() !== drawMonth);
  4897. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4898. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4899. tbody += "<td class='" +
  4900. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4901. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4902. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4903. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4904. // or defaultDate is current printedDate and defaultDate is selectedDate
  4905. " " + this._dayOverClass : "") + // highlight selected day
  4906. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  4907. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4908. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4909. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4910. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4911. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4912. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4913. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4914. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4915. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4916. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4917. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4918. printDate.setDate(printDate.getDate() + 1);
  4919. printDate = this._daylightSavingAdjust(printDate);
  4920. }
  4921. calender += tbody + "</tr>";
  4922. }
  4923. drawMonth++;
  4924. if (drawMonth > 11) {
  4925. drawMonth = 0;
  4926. drawYear++;
  4927. }
  4928. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4929. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4930. group += calender;
  4931. }
  4932. html += group;
  4933. }
  4934. html += buttonPanel;
  4935. inst._keyEvent = false;
  4936. return html;
  4937. },
  4938. /* Generate the month and year header. */
  4939. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4940. secondary, monthNames, monthNamesShort) {
  4941. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4942. changeMonth = this._get(inst, "changeMonth"),
  4943. changeYear = this._get(inst, "changeYear"),
  4944. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4945. html = "<div class='ui-datepicker-title'>",
  4946. monthHtml = "";
  4947. // month selection
  4948. if (secondary || !changeMonth) {
  4949. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4950. } else {
  4951. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4952. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4953. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4954. for ( month = 0; month < 12; month++) {
  4955. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4956. monthHtml += "<option value='" + month + "'" +
  4957. (month === drawMonth ? " selected='selected'" : "") +
  4958. ">" + monthNamesShort[month] + "</option>";
  4959. }
  4960. }
  4961. monthHtml += "</select>";
  4962. }
  4963. if (!showMonthAfterYear) {
  4964. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4965. }
  4966. // year selection
  4967. if ( !inst.yearshtml ) {
  4968. inst.yearshtml = "";
  4969. if (secondary || !changeYear) {
  4970. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4971. } else {
  4972. // determine range of years to display
  4973. years = this._get(inst, "yearRange").split(":");
  4974. thisYear = new Date().getFullYear();
  4975. determineYear = function(value) {
  4976. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4977. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4978. parseInt(value, 10)));
  4979. return (isNaN(year) ? thisYear : year);
  4980. };
  4981. year = determineYear(years[0]);
  4982. endYear = Math.max(year, determineYear(years[1] || ""));
  4983. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4984. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4985. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4986. for (; year <= endYear; year++) {
  4987. inst.yearshtml += "<option value='" + year + "'" +
  4988. (year === drawYear ? " selected='selected'" : "") +
  4989. ">" + year + "</option>";
  4990. }
  4991. inst.yearshtml += "</select>";
  4992. html += inst.yearshtml;
  4993. inst.yearshtml = null;
  4994. }
  4995. }
  4996. html += this._get(inst, "yearSuffix");
  4997. if (showMonthAfterYear) {
  4998. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4999. }
  5000. html += "</div>"; // Close datepicker_header
  5001. return html;
  5002. },
  5003. /* Adjust one of the date sub-fields. */
  5004. _adjustInstDate: function(inst, offset, period) {
  5005. var year = inst.drawYear + (period === "Y" ? offset : 0),
  5006. month = inst.drawMonth + (period === "M" ? offset : 0),
  5007. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  5008. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  5009. inst.selectedDay = date.getDate();
  5010. inst.drawMonth = inst.selectedMonth = date.getMonth();
  5011. inst.drawYear = inst.selectedYear = date.getFullYear();
  5012. if (period === "M" || period === "Y") {
  5013. this._notifyChange(inst);
  5014. }
  5015. },
  5016. /* Ensure a date is within any min/max bounds. */
  5017. _restrictMinMax: function(inst, date) {
  5018. var minDate = this._getMinMaxDate(inst, "min"),
  5019. maxDate = this._getMinMaxDate(inst, "max"),
  5020. newDate = (minDate && date < minDate ? minDate : date);
  5021. return (maxDate && newDate > maxDate ? maxDate : newDate);
  5022. },
  5023. /* Notify change of month/year. */
  5024. _notifyChange: function(inst) {
  5025. var onChange = this._get(inst, "onChangeMonthYear");
  5026. if (onChange) {
  5027. onChange.apply((inst.input ? inst.input[0] : null),
  5028. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  5029. }
  5030. },
  5031. /* Determine the number of months to show. */
  5032. _getNumberOfMonths: function(inst) {
  5033. var numMonths = this._get(inst, "numberOfMonths");
  5034. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  5035. },
  5036. /* Determine the current maximum date - ensure no time components are set. */
  5037. _getMinMaxDate: function(inst, minMax) {
  5038. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  5039. },
  5040. /* Find the number of days in a given month. */
  5041. _getDaysInMonth: function(year, month) {
  5042. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  5043. },
  5044. /* Find the day of the week of the first of a month. */
  5045. _getFirstDayOfMonth: function(year, month) {
  5046. return new Date(year, month, 1).getDay();
  5047. },
  5048. /* Determines if we should allow a "next/prev" month display change. */
  5049. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  5050. var numMonths = this._getNumberOfMonths(inst),
  5051. date = this._daylightSavingAdjust(new Date(curYear,
  5052. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  5053. if (offset < 0) {
  5054. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  5055. }
  5056. return this._isInRange(inst, date);
  5057. },
  5058. /* Is the given date in the accepted range? */
  5059. _isInRange: function(inst, date) {
  5060. var yearSplit, currentYear,
  5061. minDate = this._getMinMaxDate(inst, "min"),
  5062. maxDate = this._getMinMaxDate(inst, "max"),
  5063. minYear = null,
  5064. maxYear = null,
  5065. years = this._get(inst, "yearRange");
  5066. if (years){
  5067. yearSplit = years.split(":");
  5068. currentYear = new Date().getFullYear();
  5069. minYear = parseInt(yearSplit[0], 10);
  5070. maxYear = parseInt(yearSplit[1], 10);
  5071. if ( yearSplit[0].match(/[+\-].*/) ) {
  5072. minYear += currentYear;
  5073. }
  5074. if ( yearSplit[1].match(/[+\-].*/) ) {
  5075. maxYear += currentYear;
  5076. }
  5077. }
  5078. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  5079. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  5080. (!minYear || date.getFullYear() >= minYear) &&
  5081. (!maxYear || date.getFullYear() <= maxYear));
  5082. },
  5083. /* Provide the configuration settings for formatting/parsing. */
  5084. _getFormatConfig: function(inst) {
  5085. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  5086. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  5087. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  5088. return {shortYearCutoff: shortYearCutoff,
  5089. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  5090. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  5091. },
  5092. /* Format the given date for display. */
  5093. _formatDate: function(inst, day, month, year) {
  5094. if (!day) {
  5095. inst.currentDay = inst.selectedDay;
  5096. inst.currentMonth = inst.selectedMonth;
  5097. inst.currentYear = inst.selectedYear;
  5098. }
  5099. var date = (day ? (typeof day === "object" ? day :
  5100. this._daylightSavingAdjust(new Date(year, month, day))) :
  5101. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  5102. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  5103. }
  5104. });
  5105. /*
  5106. * Bind hover events for datepicker elements.
  5107. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  5108. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  5109. */
  5110. function datepicker_bindHover(dpDiv) {
  5111. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  5112. return dpDiv.delegate(selector, "mouseout", function() {
  5113. $(this).removeClass("ui-state-hover");
  5114. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5115. $(this).removeClass("ui-datepicker-prev-hover");
  5116. }
  5117. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5118. $(this).removeClass("ui-datepicker-next-hover");
  5119. }
  5120. })
  5121. .delegate( selector, "mouseover", datepicker_handleMouseover );
  5122. }
  5123. function datepicker_handleMouseover() {
  5124. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  5125. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  5126. $(this).addClass("ui-state-hover");
  5127. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5128. $(this).addClass("ui-datepicker-prev-hover");
  5129. }
  5130. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5131. $(this).addClass("ui-datepicker-next-hover");
  5132. }
  5133. }
  5134. }
  5135. /* jQuery extend now ignores nulls! */
  5136. function datepicker_extendRemove(target, props) {
  5137. $.extend(target, props);
  5138. for (var name in props) {
  5139. if (props[name] == null) {
  5140. target[name] = props[name];
  5141. }
  5142. }
  5143. return target;
  5144. }
  5145. /* Invoke the datepicker functionality.
  5146. @param options string - a command, optionally followed by additional parameters or
  5147. Object - settings for attaching new datepicker functionality
  5148. @return jQuery object */
  5149. $.fn.datepicker = function(options){
  5150. /* Verify an empty collection wasn't passed - Fixes #6976 */
  5151. if ( !this.length ) {
  5152. return this;
  5153. }
  5154. /* Initialise the date picker. */
  5155. if (!$.datepicker.initialized) {
  5156. $(document).mousedown($.datepicker._checkExternalClick);
  5157. $.datepicker.initialized = true;
  5158. }
  5159. /* Append datepicker main container to body if not exist. */
  5160. if ($("#"+$.datepicker._mainDivId).length === 0) {
  5161. $("body").append($.datepicker.dpDiv);
  5162. }
  5163. var otherArgs = Array.prototype.slice.call(arguments, 1);
  5164. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  5165. return $.datepicker["_" + options + "Datepicker"].
  5166. apply($.datepicker, [this[0]].concat(otherArgs));
  5167. }
  5168. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  5169. return $.datepicker["_" + options + "Datepicker"].
  5170. apply($.datepicker, [this[0]].concat(otherArgs));
  5171. }
  5172. return this.each(function() {
  5173. typeof options === "string" ?
  5174. $.datepicker["_" + options + "Datepicker"].
  5175. apply($.datepicker, [this].concat(otherArgs)) :
  5176. $.datepicker._attachDatepicker(this, options);
  5177. });
  5178. };
  5179. $.datepicker = new Datepicker(); // singleton instance
  5180. $.datepicker.initialized = false;
  5181. $.datepicker.uuid = new Date().getTime();
  5182. $.datepicker.version = "1.11.4";
  5183. var datepicker = $.datepicker;
  5184. /*!
  5185. * jQuery UI Draggable 1.11.4
  5186. * http://jqueryui.com
  5187. *
  5188. * Copyright jQuery Foundation and other contributors
  5189. * Released under the MIT license.
  5190. * http://jquery.org/license
  5191. *
  5192. * http://api.jqueryui.com/draggable/
  5193. */
  5194. $.widget("ui.draggable", $.ui.mouse, {
  5195. version: "1.11.4",
  5196. widgetEventPrefix: "drag",
  5197. options: {
  5198. addClasses: true,
  5199. appendTo: "parent",
  5200. axis: false,
  5201. connectToSortable: false,
  5202. containment: false,
  5203. cursor: "auto",
  5204. cursorAt: false,
  5205. grid: false,
  5206. handle: false,
  5207. helper: "original",
  5208. iframeFix: false,
  5209. opacity: false,
  5210. refreshPositions: false,
  5211. revert: false,
  5212. revertDuration: 500,
  5213. scope: "default",
  5214. scroll: true,
  5215. scrollSensitivity: 20,
  5216. scrollSpeed: 20,
  5217. snap: false,
  5218. snapMode: "both",
  5219. snapTolerance: 20,
  5220. stack: false,
  5221. zIndex: false,
  5222. // callbacks
  5223. drag: null,
  5224. start: null,
  5225. stop: null
  5226. },
  5227. _create: function() {
  5228. if ( this.options.helper === "original" ) {
  5229. this._setPositionRelative();
  5230. }
  5231. if (this.options.addClasses){
  5232. this.element.addClass("ui-draggable");
  5233. }
  5234. if (this.options.disabled){
  5235. this.element.addClass("ui-draggable-disabled");
  5236. }
  5237. this._setHandleClassName();
  5238. this._mouseInit();
  5239. },
  5240. _setOption: function( key, value ) {
  5241. this._super( key, value );
  5242. if ( key === "handle" ) {
  5243. this._removeHandleClassName();
  5244. this._setHandleClassName();
  5245. }
  5246. },
  5247. _destroy: function() {
  5248. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  5249. this.destroyOnClear = true;
  5250. return;
  5251. }
  5252. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5253. this._removeHandleClassName();
  5254. this._mouseDestroy();
  5255. },
  5256. _mouseCapture: function(event) {
  5257. var o = this.options;
  5258. this._blurActiveElement( event );
  5259. // among others, prevent a drag on a resizable-handle
  5260. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  5261. return false;
  5262. }
  5263. //Quit if we're not on a valid handle
  5264. this.handle = this._getHandle(event);
  5265. if (!this.handle) {
  5266. return false;
  5267. }
  5268. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  5269. return true;
  5270. },
  5271. _blockFrames: function( selector ) {
  5272. this.iframeBlocks = this.document.find( selector ).map(function() {
  5273. var iframe = $( this );
  5274. return $( "<div>" )
  5275. .css( "position", "absolute" )
  5276. .appendTo( iframe.parent() )
  5277. .outerWidth( iframe.outerWidth() )
  5278. .outerHeight( iframe.outerHeight() )
  5279. .offset( iframe.offset() )[ 0 ];
  5280. });
  5281. },
  5282. _unblockFrames: function() {
  5283. if ( this.iframeBlocks ) {
  5284. this.iframeBlocks.remove();
  5285. delete this.iframeBlocks;
  5286. }
  5287. },
  5288. _blurActiveElement: function( event ) {
  5289. var document = this.document[ 0 ];
  5290. // Only need to blur if the event occurred on the draggable itself, see #10527
  5291. if ( !this.handleElement.is( event.target ) ) {
  5292. return;
  5293. }
  5294. // support: IE9
  5295. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  5296. try {
  5297. // Support: IE9, IE10
  5298. // If the <body> is blurred, IE will switch windows, see #9520
  5299. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  5300. // Blur any element that currently has focus, see #4261
  5301. $( document.activeElement ).blur();
  5302. }
  5303. } catch ( error ) {}
  5304. },
  5305. _mouseStart: function(event) {
  5306. var o = this.options;
  5307. //Create and append the visible helper
  5308. this.helper = this._createHelper(event);
  5309. this.helper.addClass("ui-draggable-dragging");
  5310. //Cache the helper size
  5311. this._cacheHelperProportions();
  5312. //If ddmanager is used for droppables, set the global draggable
  5313. if ($.ui.ddmanager) {
  5314. $.ui.ddmanager.current = this;
  5315. }
  5316. /*
  5317. * - Position generation -
  5318. * This block generates everything position related - it's the core of draggables.
  5319. */
  5320. //Cache the margins of the original element
  5321. this._cacheMargins();
  5322. //Store the helper's css position
  5323. this.cssPosition = this.helper.css( "position" );
  5324. this.scrollParent = this.helper.scrollParent( true );
  5325. this.offsetParent = this.helper.offsetParent();
  5326. this.hasFixedAncestor = this.helper.parents().filter(function() {
  5327. return $( this ).css( "position" ) === "fixed";
  5328. }).length > 0;
  5329. //The element's absolute position on the page minus margins
  5330. this.positionAbs = this.element.offset();
  5331. this._refreshOffsets( event );
  5332. //Generate the original position
  5333. this.originalPosition = this.position = this._generatePosition( event, false );
  5334. this.originalPageX = event.pageX;
  5335. this.originalPageY = event.pageY;
  5336. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  5337. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5338. //Set a containment if given in the options
  5339. this._setContainment();
  5340. //Trigger event + callbacks
  5341. if (this._trigger("start", event) === false) {
  5342. this._clear();
  5343. return false;
  5344. }
  5345. //Recache the helper size
  5346. this._cacheHelperProportions();
  5347. //Prepare the droppable offsets
  5348. if ($.ui.ddmanager && !o.dropBehaviour) {
  5349. $.ui.ddmanager.prepareOffsets(this, event);
  5350. }
  5351. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  5352. // as this prevents resizing of elements with right/bottom set (see #7772)
  5353. this._normalizeRightBottom();
  5354. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5355. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5356. if ( $.ui.ddmanager ) {
  5357. $.ui.ddmanager.dragStart(this, event);
  5358. }
  5359. return true;
  5360. },
  5361. _refreshOffsets: function( event ) {
  5362. this.offset = {
  5363. top: this.positionAbs.top - this.margins.top,
  5364. left: this.positionAbs.left - this.margins.left,
  5365. scroll: false,
  5366. parent: this._getParentOffset(),
  5367. relative: this._getRelativeOffset()
  5368. };
  5369. this.offset.click = {
  5370. left: event.pageX - this.offset.left,
  5371. top: event.pageY - this.offset.top
  5372. };
  5373. },
  5374. _mouseDrag: function(event, noPropagation) {
  5375. // reset any necessary cached properties (see #5009)
  5376. if ( this.hasFixedAncestor ) {
  5377. this.offset.parent = this._getParentOffset();
  5378. }
  5379. //Compute the helpers position
  5380. this.position = this._generatePosition( event, true );
  5381. this.positionAbs = this._convertPositionTo("absolute");
  5382. //Call plugins and callbacks and use the resulting position if something is returned
  5383. if (!noPropagation) {
  5384. var ui = this._uiHash();
  5385. if (this._trigger("drag", event, ui) === false) {
  5386. this._mouseUp({});
  5387. return false;
  5388. }
  5389. this.position = ui.position;
  5390. }
  5391. this.helper[ 0 ].style.left = this.position.left + "px";
  5392. this.helper[ 0 ].style.top = this.position.top + "px";
  5393. if ($.ui.ddmanager) {
  5394. $.ui.ddmanager.drag(this, event);
  5395. }
  5396. return false;
  5397. },
  5398. _mouseStop: function(event) {
  5399. //If we are using droppables, inform the manager about the drop
  5400. var that = this,
  5401. dropped = false;
  5402. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  5403. dropped = $.ui.ddmanager.drop(this, event);
  5404. }
  5405. //if a drop comes from outside (a sortable)
  5406. if (this.dropped) {
  5407. dropped = this.dropped;
  5408. this.dropped = false;
  5409. }
  5410. if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  5411. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5412. if (that._trigger("stop", event) !== false) {
  5413. that._clear();
  5414. }
  5415. });
  5416. } else {
  5417. if (this._trigger("stop", event) !== false) {
  5418. this._clear();
  5419. }
  5420. }
  5421. return false;
  5422. },
  5423. _mouseUp: function( event ) {
  5424. this._unblockFrames();
  5425. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5426. if ( $.ui.ddmanager ) {
  5427. $.ui.ddmanager.dragStop(this, event);
  5428. }
  5429. // Only need to focus if the event occurred on the draggable itself, see #10527
  5430. if ( this.handleElement.is( event.target ) ) {
  5431. // The interaction is over; whether or not the click resulted in a drag, focus the element
  5432. this.element.focus();
  5433. }
  5434. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5435. },
  5436. cancel: function() {
  5437. if (this.helper.is(".ui-draggable-dragging")) {
  5438. this._mouseUp({});
  5439. } else {
  5440. this._clear();
  5441. }
  5442. return this;
  5443. },
  5444. _getHandle: function(event) {
  5445. return this.options.handle ?
  5446. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  5447. true;
  5448. },
  5449. _setHandleClassName: function() {
  5450. this.handleElement = this.options.handle ?
  5451. this.element.find( this.options.handle ) : this.element;
  5452. this.handleElement.addClass( "ui-draggable-handle" );
  5453. },
  5454. _removeHandleClassName: function() {
  5455. this.handleElement.removeClass( "ui-draggable-handle" );
  5456. },
  5457. _createHelper: function(event) {
  5458. var o = this.options,
  5459. helperIsFunction = $.isFunction( o.helper ),
  5460. helper = helperIsFunction ?
  5461. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  5462. ( o.helper === "clone" ?
  5463. this.element.clone().removeAttr( "id" ) :
  5464. this.element );
  5465. if (!helper.parents("body").length) {
  5466. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  5467. }
  5468. // http://bugs.jqueryui.com/ticket/9446
  5469. // a helper function can return the original element
  5470. // which wouldn't have been set to relative in _create
  5471. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  5472. this._setPositionRelative();
  5473. }
  5474. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  5475. helper.css("position", "absolute");
  5476. }
  5477. return helper;
  5478. },
  5479. _setPositionRelative: function() {
  5480. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  5481. this.element[ 0 ].style.position = "relative";
  5482. }
  5483. },
  5484. _adjustOffsetFromHelper: function(obj) {
  5485. if (typeof obj === "string") {
  5486. obj = obj.split(" ");
  5487. }
  5488. if ($.isArray(obj)) {
  5489. obj = { left: +obj[0], top: +obj[1] || 0 };
  5490. }
  5491. if ("left" in obj) {
  5492. this.offset.click.left = obj.left + this.margins.left;
  5493. }
  5494. if ("right" in obj) {
  5495. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5496. }
  5497. if ("top" in obj) {
  5498. this.offset.click.top = obj.top + this.margins.top;
  5499. }
  5500. if ("bottom" in obj) {
  5501. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5502. }
  5503. },
  5504. _isRootNode: function( element ) {
  5505. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  5506. },
  5507. _getParentOffset: function() {
  5508. //Get the offsetParent and cache its position
  5509. var po = this.offsetParent.offset(),
  5510. document = this.document[ 0 ];
  5511. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5512. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5513. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5514. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5515. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5516. po.left += this.scrollParent.scrollLeft();
  5517. po.top += this.scrollParent.scrollTop();
  5518. }
  5519. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  5520. po = { top: 0, left: 0 };
  5521. }
  5522. return {
  5523. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  5524. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  5525. };
  5526. },
  5527. _getRelativeOffset: function() {
  5528. if ( this.cssPosition !== "relative" ) {
  5529. return { top: 0, left: 0 };
  5530. }
  5531. var p = this.element.position(),
  5532. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5533. return {
  5534. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  5535. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  5536. };
  5537. },
  5538. _cacheMargins: function() {
  5539. this.margins = {
  5540. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  5541. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  5542. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  5543. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  5544. };
  5545. },
  5546. _cacheHelperProportions: function() {
  5547. this.helperProportions = {
  5548. width: this.helper.outerWidth(),
  5549. height: this.helper.outerHeight()
  5550. };
  5551. },
  5552. _setContainment: function() {
  5553. var isUserScrollable, c, ce,
  5554. o = this.options,
  5555. document = this.document[ 0 ];
  5556. this.relativeContainer = null;
  5557. if ( !o.containment ) {
  5558. this.containment = null;
  5559. return;
  5560. }
  5561. if ( o.containment === "window" ) {
  5562. this.containment = [
  5563. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5564. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5565. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  5566. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5567. ];
  5568. return;
  5569. }
  5570. if ( o.containment === "document") {
  5571. this.containment = [
  5572. 0,
  5573. 0,
  5574. $( document ).width() - this.helperProportions.width - this.margins.left,
  5575. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5576. ];
  5577. return;
  5578. }
  5579. if ( o.containment.constructor === Array ) {
  5580. this.containment = o.containment;
  5581. return;
  5582. }
  5583. if ( o.containment === "parent" ) {
  5584. o.containment = this.helper[ 0 ].parentNode;
  5585. }
  5586. c = $( o.containment );
  5587. ce = c[ 0 ];
  5588. if ( !ce ) {
  5589. return;
  5590. }
  5591. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  5592. this.containment = [
  5593. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  5594. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  5595. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  5596. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  5597. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  5598. this.helperProportions.width -
  5599. this.margins.left -
  5600. this.margins.right,
  5601. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  5602. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  5603. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  5604. this.helperProportions.height -
  5605. this.margins.top -
  5606. this.margins.bottom
  5607. ];
  5608. this.relativeContainer = c;
  5609. },
  5610. _convertPositionTo: function(d, pos) {
  5611. if (!pos) {
  5612. pos = this.position;
  5613. }
  5614. var mod = d === "absolute" ? 1 : -1,
  5615. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5616. return {
  5617. top: (
  5618. pos.top + // The absolute mouse position
  5619. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5620. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  5621. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  5622. ),
  5623. left: (
  5624. pos.left + // The absolute mouse position
  5625. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5626. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  5627. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  5628. )
  5629. };
  5630. },
  5631. _generatePosition: function( event, constrainPosition ) {
  5632. var containment, co, top, left,
  5633. o = this.options,
  5634. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  5635. pageX = event.pageX,
  5636. pageY = event.pageY;
  5637. // Cache the scroll
  5638. if ( !scrollIsRootNode || !this.offset.scroll ) {
  5639. this.offset.scroll = {
  5640. top: this.scrollParent.scrollTop(),
  5641. left: this.scrollParent.scrollLeft()
  5642. };
  5643. }
  5644. /*
  5645. * - Position constraining -
  5646. * Constrain the position to a mix of grid, containment.
  5647. */
  5648. // If we are not dragging yet, we won't check for options
  5649. if ( constrainPosition ) {
  5650. if ( this.containment ) {
  5651. if ( this.relativeContainer ){
  5652. co = this.relativeContainer.offset();
  5653. containment = [
  5654. this.containment[ 0 ] + co.left,
  5655. this.containment[ 1 ] + co.top,
  5656. this.containment[ 2 ] + co.left,
  5657. this.containment[ 3 ] + co.top
  5658. ];
  5659. } else {
  5660. containment = this.containment;
  5661. }
  5662. if (event.pageX - this.offset.click.left < containment[0]) {
  5663. pageX = containment[0] + this.offset.click.left;
  5664. }
  5665. if (event.pageY - this.offset.click.top < containment[1]) {
  5666. pageY = containment[1] + this.offset.click.top;
  5667. }
  5668. if (event.pageX - this.offset.click.left > containment[2]) {
  5669. pageX = containment[2] + this.offset.click.left;
  5670. }
  5671. if (event.pageY - this.offset.click.top > containment[3]) {
  5672. pageY = containment[3] + this.offset.click.top;
  5673. }
  5674. }
  5675. if (o.grid) {
  5676. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5677. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5678. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  5679. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5680. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  5681. }
  5682. if ( o.axis === "y" ) {
  5683. pageX = this.originalPageX;
  5684. }
  5685. if ( o.axis === "x" ) {
  5686. pageY = this.originalPageY;
  5687. }
  5688. }
  5689. return {
  5690. top: (
  5691. pageY - // The absolute mouse position
  5692. this.offset.click.top - // Click offset (relative to the element)
  5693. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  5694. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  5695. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  5696. ),
  5697. left: (
  5698. pageX - // The absolute mouse position
  5699. this.offset.click.left - // Click offset (relative to the element)
  5700. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  5701. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  5702. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  5703. )
  5704. };
  5705. },
  5706. _clear: function() {
  5707. this.helper.removeClass("ui-draggable-dragging");
  5708. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  5709. this.helper.remove();
  5710. }
  5711. this.helper = null;
  5712. this.cancelHelperRemoval = false;
  5713. if ( this.destroyOnClear ) {
  5714. this.destroy();
  5715. }
  5716. },
  5717. _normalizeRightBottom: function() {
  5718. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  5719. this.helper.width( this.helper.width() );
  5720. this.helper.css( "right", "auto" );
  5721. }
  5722. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  5723. this.helper.height( this.helper.height() );
  5724. this.helper.css( "bottom", "auto" );
  5725. }
  5726. },
  5727. // From now on bulk stuff - mainly helpers
  5728. _trigger: function( type, event, ui ) {
  5729. ui = ui || this._uiHash();
  5730. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  5731. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  5732. if ( /^(drag|start|stop)/.test( type ) ) {
  5733. this.positionAbs = this._convertPositionTo( "absolute" );
  5734. ui.offset = this.positionAbs;
  5735. }
  5736. return $.Widget.prototype._trigger.call( this, type, event, ui );
  5737. },
  5738. plugins: {},
  5739. _uiHash: function() {
  5740. return {
  5741. helper: this.helper,
  5742. position: this.position,
  5743. originalPosition: this.originalPosition,
  5744. offset: this.positionAbs
  5745. };
  5746. }
  5747. });
  5748. $.ui.plugin.add( "draggable", "connectToSortable", {
  5749. start: function( event, ui, draggable ) {
  5750. var uiSortable = $.extend( {}, ui, {
  5751. item: draggable.element
  5752. });
  5753. draggable.sortables = [];
  5754. $( draggable.options.connectToSortable ).each(function() {
  5755. var sortable = $( this ).sortable( "instance" );
  5756. if ( sortable && !sortable.options.disabled ) {
  5757. draggable.sortables.push( sortable );
  5758. // refreshPositions is called at drag start to refresh the containerCache
  5759. // which is used in drag. This ensures it's initialized and synchronized
  5760. // with any changes that might have happened on the page since initialization.
  5761. sortable.refreshPositions();
  5762. sortable._trigger("activate", event, uiSortable);
  5763. }
  5764. });
  5765. },
  5766. stop: function( event, ui, draggable ) {
  5767. var uiSortable = $.extend( {}, ui, {
  5768. item: draggable.element
  5769. });
  5770. draggable.cancelHelperRemoval = false;
  5771. $.each( draggable.sortables, function() {
  5772. var sortable = this;
  5773. if ( sortable.isOver ) {
  5774. sortable.isOver = 0;
  5775. // Allow this sortable to handle removing the helper
  5776. draggable.cancelHelperRemoval = true;
  5777. sortable.cancelHelperRemoval = false;
  5778. // Use _storedCSS To restore properties in the sortable,
  5779. // as this also handles revert (#9675) since the draggable
  5780. // may have modified them in unexpected ways (#8809)
  5781. sortable._storedCSS = {
  5782. position: sortable.placeholder.css( "position" ),
  5783. top: sortable.placeholder.css( "top" ),
  5784. left: sortable.placeholder.css( "left" )
  5785. };
  5786. sortable._mouseStop(event);
  5787. // Once drag has ended, the sortable should return to using
  5788. // its original helper, not the shared helper from draggable
  5789. sortable.options.helper = sortable.options._helper;
  5790. } else {
  5791. // Prevent this Sortable from removing the helper.
  5792. // However, don't set the draggable to remove the helper
  5793. // either as another connected Sortable may yet handle the removal.
  5794. sortable.cancelHelperRemoval = true;
  5795. sortable._trigger( "deactivate", event, uiSortable );
  5796. }
  5797. });
  5798. },
  5799. drag: function( event, ui, draggable ) {
  5800. $.each( draggable.sortables, function() {
  5801. var innermostIntersecting = false,
  5802. sortable = this;
  5803. // Copy over variables that sortable's _intersectsWith uses
  5804. sortable.positionAbs = draggable.positionAbs;
  5805. sortable.helperProportions = draggable.helperProportions;
  5806. sortable.offset.click = draggable.offset.click;
  5807. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  5808. innermostIntersecting = true;
  5809. $.each( draggable.sortables, function() {
  5810. // Copy over variables that sortable's _intersectsWith uses
  5811. this.positionAbs = draggable.positionAbs;
  5812. this.helperProportions = draggable.helperProportions;
  5813. this.offset.click = draggable.offset.click;
  5814. if ( this !== sortable &&
  5815. this._intersectsWith( this.containerCache ) &&
  5816. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  5817. innermostIntersecting = false;
  5818. }
  5819. return innermostIntersecting;
  5820. });
  5821. }
  5822. if ( innermostIntersecting ) {
  5823. // If it intersects, we use a little isOver variable and set it once,
  5824. // so that the move-in stuff gets fired only once.
  5825. if ( !sortable.isOver ) {
  5826. sortable.isOver = 1;
  5827. // Store draggable's parent in case we need to reappend to it later.
  5828. draggable._parent = ui.helper.parent();
  5829. sortable.currentItem = ui.helper
  5830. .appendTo( sortable.element )
  5831. .data( "ui-sortable-item", true );
  5832. // Store helper option to later restore it
  5833. sortable.options._helper = sortable.options.helper;
  5834. sortable.options.helper = function() {
  5835. return ui.helper[ 0 ];
  5836. };
  5837. // Fire the start events of the sortable with our passed browser event,
  5838. // and our own helper (so it doesn't create a new one)
  5839. event.target = sortable.currentItem[ 0 ];
  5840. sortable._mouseCapture( event, true );
  5841. sortable._mouseStart( event, true, true );
  5842. // Because the browser event is way off the new appended portlet,
  5843. // modify necessary variables to reflect the changes
  5844. sortable.offset.click.top = draggable.offset.click.top;
  5845. sortable.offset.click.left = draggable.offset.click.left;
  5846. sortable.offset.parent.left -= draggable.offset.parent.left -
  5847. sortable.offset.parent.left;
  5848. sortable.offset.parent.top -= draggable.offset.parent.top -
  5849. sortable.offset.parent.top;
  5850. draggable._trigger( "toSortable", event );
  5851. // Inform draggable that the helper is in a valid drop zone,
  5852. // used solely in the revert option to handle "valid/invalid".
  5853. draggable.dropped = sortable.element;
  5854. // Need to refreshPositions of all sortables in the case that
  5855. // adding to one sortable changes the location of the other sortables (#9675)
  5856. $.each( draggable.sortables, function() {
  5857. this.refreshPositions();
  5858. });
  5859. // hack so receive/update callbacks work (mostly)
  5860. draggable.currentItem = draggable.element;
  5861. sortable.fromOutside = draggable;
  5862. }
  5863. if ( sortable.currentItem ) {
  5864. sortable._mouseDrag( event );
  5865. // Copy the sortable's position because the draggable's can potentially reflect
  5866. // a relative position, while sortable is always absolute, which the dragged
  5867. // element has now become. (#8809)
  5868. ui.position = sortable.position;
  5869. }
  5870. } else {
  5871. // If it doesn't intersect with the sortable, and it intersected before,
  5872. // we fake the drag stop of the sortable, but make sure it doesn't remove
  5873. // the helper by using cancelHelperRemoval.
  5874. if ( sortable.isOver ) {
  5875. sortable.isOver = 0;
  5876. sortable.cancelHelperRemoval = true;
  5877. // Calling sortable's mouseStop would trigger a revert,
  5878. // so revert must be temporarily false until after mouseStop is called.
  5879. sortable.options._revert = sortable.options.revert;
  5880. sortable.options.revert = false;
  5881. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  5882. sortable._mouseStop( event, true );
  5883. // restore sortable behaviors that were modfied
  5884. // when the draggable entered the sortable area (#9481)
  5885. sortable.options.revert = sortable.options._revert;
  5886. sortable.options.helper = sortable.options._helper;
  5887. if ( sortable.placeholder ) {
  5888. sortable.placeholder.remove();
  5889. }
  5890. // Restore and recalculate the draggable's offset considering the sortable
  5891. // may have modified them in unexpected ways. (#8809, #10669)
  5892. ui.helper.appendTo( draggable._parent );
  5893. draggable._refreshOffsets( event );
  5894. ui.position = draggable._generatePosition( event, true );
  5895. draggable._trigger( "fromSortable", event );
  5896. // Inform draggable that the helper is no longer in a valid drop zone
  5897. draggable.dropped = false;
  5898. // Need to refreshPositions of all sortables just in case removing
  5899. // from one sortable changes the location of other sortables (#9675)
  5900. $.each( draggable.sortables, function() {
  5901. this.refreshPositions();
  5902. });
  5903. }
  5904. }
  5905. });
  5906. }
  5907. });
  5908. $.ui.plugin.add("draggable", "cursor", {
  5909. start: function( event, ui, instance ) {
  5910. var t = $( "body" ),
  5911. o = instance.options;
  5912. if (t.css("cursor")) {
  5913. o._cursor = t.css("cursor");
  5914. }
  5915. t.css("cursor", o.cursor);
  5916. },
  5917. stop: function( event, ui, instance ) {
  5918. var o = instance.options;
  5919. if (o._cursor) {
  5920. $("body").css("cursor", o._cursor);
  5921. }
  5922. }
  5923. });
  5924. $.ui.plugin.add("draggable", "opacity", {
  5925. start: function( event, ui, instance ) {
  5926. var t = $( ui.helper ),
  5927. o = instance.options;
  5928. if (t.css("opacity")) {
  5929. o._opacity = t.css("opacity");
  5930. }
  5931. t.css("opacity", o.opacity);
  5932. },
  5933. stop: function( event, ui, instance ) {
  5934. var o = instance.options;
  5935. if (o._opacity) {
  5936. $(ui.helper).css("opacity", o._opacity);
  5937. }
  5938. }
  5939. });
  5940. $.ui.plugin.add("draggable", "scroll", {
  5941. start: function( event, ui, i ) {
  5942. if ( !i.scrollParentNotHidden ) {
  5943. i.scrollParentNotHidden = i.helper.scrollParent( false );
  5944. }
  5945. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  5946. i.overflowOffset = i.scrollParentNotHidden.offset();
  5947. }
  5948. },
  5949. drag: function( event, ui, i ) {
  5950. var o = i.options,
  5951. scrolled = false,
  5952. scrollParent = i.scrollParentNotHidden[ 0 ],
  5953. document = i.document[ 0 ];
  5954. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  5955. if ( !o.axis || o.axis !== "x" ) {
  5956. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  5957. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  5958. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  5959. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  5960. }
  5961. }
  5962. if ( !o.axis || o.axis !== "y" ) {
  5963. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  5964. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  5965. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  5966. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  5967. }
  5968. }
  5969. } else {
  5970. if (!o.axis || o.axis !== "x") {
  5971. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  5972. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5973. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  5974. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5975. }
  5976. }
  5977. if (!o.axis || o.axis !== "y") {
  5978. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  5979. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5980. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  5981. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5982. }
  5983. }
  5984. }
  5985. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  5986. $.ui.ddmanager.prepareOffsets(i, event);
  5987. }
  5988. }
  5989. });
  5990. $.ui.plugin.add("draggable", "snap", {
  5991. start: function( event, ui, i ) {
  5992. var o = i.options;
  5993. i.snapElements = [];
  5994. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  5995. var $t = $(this),
  5996. $o = $t.offset();
  5997. if (this !== i.element[0]) {
  5998. i.snapElements.push({
  5999. item: this,
  6000. width: $t.outerWidth(), height: $t.outerHeight(),
  6001. top: $o.top, left: $o.left
  6002. });
  6003. }
  6004. });
  6005. },
  6006. drag: function( event, ui, inst ) {
  6007. var ts, bs, ls, rs, l, r, t, b, i, first,
  6008. o = inst.options,
  6009. d = o.snapTolerance,
  6010. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  6011. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  6012. for (i = inst.snapElements.length - 1; i >= 0; i--){
  6013. l = inst.snapElements[i].left - inst.margins.left;
  6014. r = l + inst.snapElements[i].width;
  6015. t = inst.snapElements[i].top - inst.margins.top;
  6016. b = t + inst.snapElements[i].height;
  6017. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  6018. if (inst.snapElements[i].snapping) {
  6019. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  6020. }
  6021. inst.snapElements[i].snapping = false;
  6022. continue;
  6023. }
  6024. if (o.snapMode !== "inner") {
  6025. ts = Math.abs(t - y2) <= d;
  6026. bs = Math.abs(b - y1) <= d;
  6027. ls = Math.abs(l - x2) <= d;
  6028. rs = Math.abs(r - x1) <= d;
  6029. if (ts) {
  6030. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  6031. }
  6032. if (bs) {
  6033. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  6034. }
  6035. if (ls) {
  6036. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  6037. }
  6038. if (rs) {
  6039. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  6040. }
  6041. }
  6042. first = (ts || bs || ls || rs);
  6043. if (o.snapMode !== "outer") {
  6044. ts = Math.abs(t - y1) <= d;
  6045. bs = Math.abs(b - y2) <= d;
  6046. ls = Math.abs(l - x1) <= d;
  6047. rs = Math.abs(r - x2) <= d;
  6048. if (ts) {
  6049. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  6050. }
  6051. if (bs) {
  6052. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  6053. }
  6054. if (ls) {
  6055. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  6056. }
  6057. if (rs) {
  6058. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  6059. }
  6060. }
  6061. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  6062. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  6063. }
  6064. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  6065. }
  6066. }
  6067. });
  6068. $.ui.plugin.add("draggable", "stack", {
  6069. start: function( event, ui, instance ) {
  6070. var min,
  6071. o = instance.options,
  6072. group = $.makeArray($(o.stack)).sort(function(a, b) {
  6073. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  6074. });
  6075. if (!group.length) { return; }
  6076. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  6077. $(group).each(function(i) {
  6078. $(this).css("zIndex", min + i);
  6079. });
  6080. this.css("zIndex", (min + group.length));
  6081. }
  6082. });
  6083. $.ui.plugin.add("draggable", "zIndex", {
  6084. start: function( event, ui, instance ) {
  6085. var t = $( ui.helper ),
  6086. o = instance.options;
  6087. if (t.css("zIndex")) {
  6088. o._zIndex = t.css("zIndex");
  6089. }
  6090. t.css("zIndex", o.zIndex);
  6091. },
  6092. stop: function( event, ui, instance ) {
  6093. var o = instance.options;
  6094. if (o._zIndex) {
  6095. $(ui.helper).css("zIndex", o._zIndex);
  6096. }
  6097. }
  6098. });
  6099. var draggable = $.ui.draggable;
  6100. /*!
  6101. * jQuery UI Resizable 1.11.4
  6102. * http://jqueryui.com
  6103. *
  6104. * Copyright jQuery Foundation and other contributors
  6105. * Released under the MIT license.
  6106. * http://jquery.org/license
  6107. *
  6108. * http://api.jqueryui.com/resizable/
  6109. */
  6110. $.widget("ui.resizable", $.ui.mouse, {
  6111. version: "1.11.4",
  6112. widgetEventPrefix: "resize",
  6113. options: {
  6114. alsoResize: false,
  6115. animate: false,
  6116. animateDuration: "slow",
  6117. animateEasing: "swing",
  6118. aspectRatio: false,
  6119. autoHide: false,
  6120. containment: false,
  6121. ghost: false,
  6122. grid: false,
  6123. handles: "e,s,se",
  6124. helper: false,
  6125. maxHeight: null,
  6126. maxWidth: null,
  6127. minHeight: 10,
  6128. minWidth: 10,
  6129. // See #7960
  6130. zIndex: 90,
  6131. // callbacks
  6132. resize: null,
  6133. start: null,
  6134. stop: null
  6135. },
  6136. _num: function( value ) {
  6137. return parseInt( value, 10 ) || 0;
  6138. },
  6139. _isNumber: function( value ) {
  6140. return !isNaN( parseInt( value, 10 ) );
  6141. },
  6142. _hasScroll: function( el, a ) {
  6143. if ( $( el ).css( "overflow" ) === "hidden") {
  6144. return false;
  6145. }
  6146. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  6147. has = false;
  6148. if ( el[ scroll ] > 0 ) {
  6149. return true;
  6150. }
  6151. // TODO: determine which cases actually cause this to happen
  6152. // if the element doesn't have the scroll set, see if it's possible to
  6153. // set the scroll
  6154. el[ scroll ] = 1;
  6155. has = ( el[ scroll ] > 0 );
  6156. el[ scroll ] = 0;
  6157. return has;
  6158. },
  6159. _create: function() {
  6160. var n, i, handle, axis, hname,
  6161. that = this,
  6162. o = this.options;
  6163. this.element.addClass("ui-resizable");
  6164. $.extend(this, {
  6165. _aspectRatio: !!(o.aspectRatio),
  6166. aspectRatio: o.aspectRatio,
  6167. originalElement: this.element,
  6168. _proportionallyResizeElements: [],
  6169. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  6170. });
  6171. // Wrap the element if it cannot hold child nodes
  6172. if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
  6173. this.element.wrap(
  6174. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  6175. position: this.element.css("position"),
  6176. width: this.element.outerWidth(),
  6177. height: this.element.outerHeight(),
  6178. top: this.element.css("top"),
  6179. left: this.element.css("left")
  6180. })
  6181. );
  6182. this.element = this.element.parent().data(
  6183. "ui-resizable", this.element.resizable( "instance" )
  6184. );
  6185. this.elementIsWrapper = true;
  6186. this.element.css({
  6187. marginLeft: this.originalElement.css("marginLeft"),
  6188. marginTop: this.originalElement.css("marginTop"),
  6189. marginRight: this.originalElement.css("marginRight"),
  6190. marginBottom: this.originalElement.css("marginBottom")
  6191. });
  6192. this.originalElement.css({
  6193. marginLeft: 0,
  6194. marginTop: 0,
  6195. marginRight: 0,
  6196. marginBottom: 0
  6197. });
  6198. // support: Safari
  6199. // Prevent Safari textarea resize
  6200. this.originalResizeStyle = this.originalElement.css("resize");
  6201. this.originalElement.css("resize", "none");
  6202. this._proportionallyResizeElements.push( this.originalElement.css({
  6203. position: "static",
  6204. zoom: 1,
  6205. display: "block"
  6206. }) );
  6207. // support: IE9
  6208. // avoid IE jump (hard set the margin)
  6209. this.originalElement.css({ margin: this.originalElement.css("margin") });
  6210. this._proportionallyResize();
  6211. }
  6212. this.handles = o.handles ||
  6213. ( !$(".ui-resizable-handle", this.element).length ?
  6214. "e,s,se" : {
  6215. n: ".ui-resizable-n",
  6216. e: ".ui-resizable-e",
  6217. s: ".ui-resizable-s",
  6218. w: ".ui-resizable-w",
  6219. se: ".ui-resizable-se",
  6220. sw: ".ui-resizable-sw",
  6221. ne: ".ui-resizable-ne",
  6222. nw: ".ui-resizable-nw"
  6223. } );
  6224. this._handles = $();
  6225. if ( this.handles.constructor === String ) {
  6226. if ( this.handles === "all") {
  6227. this.handles = "n,e,s,w,se,sw,ne,nw";
  6228. }
  6229. n = this.handles.split(",");
  6230. this.handles = {};
  6231. for (i = 0; i < n.length; i++) {
  6232. handle = $.trim(n[i]);
  6233. hname = "ui-resizable-" + handle;
  6234. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  6235. axis.css({ zIndex: o.zIndex });
  6236. // TODO : What's going on here?
  6237. if ("se" === handle) {
  6238. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  6239. }
  6240. this.handles[handle] = ".ui-resizable-" + handle;
  6241. this.element.append(axis);
  6242. }
  6243. }
  6244. this._renderAxis = function(target) {
  6245. var i, axis, padPos, padWrapper;
  6246. target = target || this.element;
  6247. for (i in this.handles) {
  6248. if (this.handles[i].constructor === String) {
  6249. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  6250. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  6251. this.handles[ i ] = $( this.handles[ i ] );
  6252. this._on( this.handles[ i ], { "mousedown": that._mouseDown });
  6253. }
  6254. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
  6255. axis = $(this.handles[i], this.element);
  6256. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  6257. padPos = [ "padding",
  6258. /ne|nw|n/.test(i) ? "Top" :
  6259. /se|sw|s/.test(i) ? "Bottom" :
  6260. /^e$/.test(i) ? "Right" : "Left" ].join("");
  6261. target.css(padPos, padWrapper);
  6262. this._proportionallyResize();
  6263. }
  6264. this._handles = this._handles.add( this.handles[ i ] );
  6265. }
  6266. };
  6267. // TODO: make renderAxis a prototype function
  6268. this._renderAxis(this.element);
  6269. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  6270. this._handles.disableSelection();
  6271. this._handles.mouseover(function() {
  6272. if (!that.resizing) {
  6273. if (this.className) {
  6274. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  6275. }
  6276. that.axis = axis && axis[1] ? axis[1] : "se";
  6277. }
  6278. });
  6279. if (o.autoHide) {
  6280. this._handles.hide();
  6281. $(this.element)
  6282. .addClass("ui-resizable-autohide")
  6283. .mouseenter(function() {
  6284. if (o.disabled) {
  6285. return;
  6286. }
  6287. $(this).removeClass("ui-resizable-autohide");
  6288. that._handles.show();
  6289. })
  6290. .mouseleave(function() {
  6291. if (o.disabled) {
  6292. return;
  6293. }
  6294. if (!that.resizing) {
  6295. $(this).addClass("ui-resizable-autohide");
  6296. that._handles.hide();
  6297. }
  6298. });
  6299. }
  6300. this._mouseInit();
  6301. },
  6302. _destroy: function() {
  6303. this._mouseDestroy();
  6304. var wrapper,
  6305. _destroy = function(exp) {
  6306. $(exp)
  6307. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  6308. .removeData("resizable")
  6309. .removeData("ui-resizable")
  6310. .unbind(".resizable")
  6311. .find(".ui-resizable-handle")
  6312. .remove();
  6313. };
  6314. // TODO: Unwrap at same DOM position
  6315. if (this.elementIsWrapper) {
  6316. _destroy(this.element);
  6317. wrapper = this.element;
  6318. this.originalElement.css({
  6319. position: wrapper.css("position"),
  6320. width: wrapper.outerWidth(),
  6321. height: wrapper.outerHeight(),
  6322. top: wrapper.css("top"),
  6323. left: wrapper.css("left")
  6324. }).insertAfter( wrapper );
  6325. wrapper.remove();
  6326. }
  6327. this.originalElement.css("resize", this.originalResizeStyle);
  6328. _destroy(this.originalElement);
  6329. return this;
  6330. },
  6331. _mouseCapture: function(event) {
  6332. var i, handle,
  6333. capture = false;
  6334. for (i in this.handles) {
  6335. handle = $(this.handles[i])[0];
  6336. if (handle === event.target || $.contains(handle, event.target)) {
  6337. capture = true;
  6338. }
  6339. }
  6340. return !this.options.disabled && capture;
  6341. },
  6342. _mouseStart: function(event) {
  6343. var curleft, curtop, cursor,
  6344. o = this.options,
  6345. el = this.element;
  6346. this.resizing = true;
  6347. this._renderProxy();
  6348. curleft = this._num(this.helper.css("left"));
  6349. curtop = this._num(this.helper.css("top"));
  6350. if (o.containment) {
  6351. curleft += $(o.containment).scrollLeft() || 0;
  6352. curtop += $(o.containment).scrollTop() || 0;
  6353. }
  6354. this.offset = this.helper.offset();
  6355. this.position = { left: curleft, top: curtop };
  6356. this.size = this._helper ? {
  6357. width: this.helper.width(),
  6358. height: this.helper.height()
  6359. } : {
  6360. width: el.width(),
  6361. height: el.height()
  6362. };
  6363. this.originalSize = this._helper ? {
  6364. width: el.outerWidth(),
  6365. height: el.outerHeight()
  6366. } : {
  6367. width: el.width(),
  6368. height: el.height()
  6369. };
  6370. this.sizeDiff = {
  6371. width: el.outerWidth() - el.width(),
  6372. height: el.outerHeight() - el.height()
  6373. };
  6374. this.originalPosition = { left: curleft, top: curtop };
  6375. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  6376. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  6377. o.aspectRatio :
  6378. ((this.originalSize.width / this.originalSize.height) || 1);
  6379. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  6380. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  6381. el.addClass("ui-resizable-resizing");
  6382. this._propagate("start", event);
  6383. return true;
  6384. },
  6385. _mouseDrag: function(event) {
  6386. var data, props,
  6387. smp = this.originalMousePosition,
  6388. a = this.axis,
  6389. dx = (event.pageX - smp.left) || 0,
  6390. dy = (event.pageY - smp.top) || 0,
  6391. trigger = this._change[a];
  6392. this._updatePrevProperties();
  6393. if (!trigger) {
  6394. return false;
  6395. }
  6396. data = trigger.apply(this, [ event, dx, dy ]);
  6397. this._updateVirtualBoundaries(event.shiftKey);
  6398. if (this._aspectRatio || event.shiftKey) {
  6399. data = this._updateRatio(data, event);
  6400. }
  6401. data = this._respectSize(data, event);
  6402. this._updateCache(data);
  6403. this._propagate("resize", event);
  6404. props = this._applyChanges();
  6405. if ( !this._helper && this._proportionallyResizeElements.length ) {
  6406. this._proportionallyResize();
  6407. }
  6408. if ( !$.isEmptyObject( props ) ) {
  6409. this._updatePrevProperties();
  6410. this._trigger( "resize", event, this.ui() );
  6411. this._applyChanges();
  6412. }
  6413. return false;
  6414. },
  6415. _mouseStop: function(event) {
  6416. this.resizing = false;
  6417. var pr, ista, soffseth, soffsetw, s, left, top,
  6418. o = this.options, that = this;
  6419. if (this._helper) {
  6420. pr = this._proportionallyResizeElements;
  6421. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  6422. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  6423. soffsetw = ista ? 0 : that.sizeDiff.width;
  6424. s = {
  6425. width: (that.helper.width() - soffsetw),
  6426. height: (that.helper.height() - soffseth)
  6427. };
  6428. left = (parseInt(that.element.css("left"), 10) +
  6429. (that.position.left - that.originalPosition.left)) || null;
  6430. top = (parseInt(that.element.css("top"), 10) +
  6431. (that.position.top - that.originalPosition.top)) || null;
  6432. if (!o.animate) {
  6433. this.element.css($.extend(s, { top: top, left: left }));
  6434. }
  6435. that.helper.height(that.size.height);
  6436. that.helper.width(that.size.width);
  6437. if (this._helper && !o.animate) {
  6438. this._proportionallyResize();
  6439. }
  6440. }
  6441. $("body").css("cursor", "auto");
  6442. this.element.removeClass("ui-resizable-resizing");
  6443. this._propagate("stop", event);
  6444. if (this._helper) {
  6445. this.helper.remove();
  6446. }
  6447. return false;
  6448. },
  6449. _updatePrevProperties: function() {
  6450. this.prevPosition = {
  6451. top: this.position.top,
  6452. left: this.position.left
  6453. };
  6454. this.prevSize = {
  6455. width: this.size.width,
  6456. height: this.size.height
  6457. };
  6458. },
  6459. _applyChanges: function() {
  6460. var props = {};
  6461. if ( this.position.top !== this.prevPosition.top ) {
  6462. props.top = this.position.top + "px";
  6463. }
  6464. if ( this.position.left !== this.prevPosition.left ) {
  6465. props.left = this.position.left + "px";
  6466. }
  6467. if ( this.size.width !== this.prevSize.width ) {
  6468. props.width = this.size.width + "px";
  6469. }
  6470. if ( this.size.height !== this.prevSize.height ) {
  6471. props.height = this.size.height + "px";
  6472. }
  6473. this.helper.css( props );
  6474. return props;
  6475. },
  6476. _updateVirtualBoundaries: function(forceAspectRatio) {
  6477. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  6478. o = this.options;
  6479. b = {
  6480. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  6481. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  6482. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  6483. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  6484. };
  6485. if (this._aspectRatio || forceAspectRatio) {
  6486. pMinWidth = b.minHeight * this.aspectRatio;
  6487. pMinHeight = b.minWidth / this.aspectRatio;
  6488. pMaxWidth = b.maxHeight * this.aspectRatio;
  6489. pMaxHeight = b.maxWidth / this.aspectRatio;
  6490. if (pMinWidth > b.minWidth) {
  6491. b.minWidth = pMinWidth;
  6492. }
  6493. if (pMinHeight > b.minHeight) {
  6494. b.minHeight = pMinHeight;
  6495. }
  6496. if (pMaxWidth < b.maxWidth) {
  6497. b.maxWidth = pMaxWidth;
  6498. }
  6499. if (pMaxHeight < b.maxHeight) {
  6500. b.maxHeight = pMaxHeight;
  6501. }
  6502. }
  6503. this._vBoundaries = b;
  6504. },
  6505. _updateCache: function(data) {
  6506. this.offset = this.helper.offset();
  6507. if (this._isNumber(data.left)) {
  6508. this.position.left = data.left;
  6509. }
  6510. if (this._isNumber(data.top)) {
  6511. this.position.top = data.top;
  6512. }
  6513. if (this._isNumber(data.height)) {
  6514. this.size.height = data.height;
  6515. }
  6516. if (this._isNumber(data.width)) {
  6517. this.size.width = data.width;
  6518. }
  6519. },
  6520. _updateRatio: function( data ) {
  6521. var cpos = this.position,
  6522. csize = this.size,
  6523. a = this.axis;
  6524. if (this._isNumber(data.height)) {
  6525. data.width = (data.height * this.aspectRatio);
  6526. } else if (this._isNumber(data.width)) {
  6527. data.height = (data.width / this.aspectRatio);
  6528. }
  6529. if (a === "sw") {
  6530. data.left = cpos.left + (csize.width - data.width);
  6531. data.top = null;
  6532. }
  6533. if (a === "nw") {
  6534. data.top = cpos.top + (csize.height - data.height);
  6535. data.left = cpos.left + (csize.width - data.width);
  6536. }
  6537. return data;
  6538. },
  6539. _respectSize: function( data ) {
  6540. var o = this._vBoundaries,
  6541. a = this.axis,
  6542. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  6543. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  6544. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  6545. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  6546. dw = this.originalPosition.left + this.originalSize.width,
  6547. dh = this.position.top + this.size.height,
  6548. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  6549. if (isminw) {
  6550. data.width = o.minWidth;
  6551. }
  6552. if (isminh) {
  6553. data.height = o.minHeight;
  6554. }
  6555. if (ismaxw) {
  6556. data.width = o.maxWidth;
  6557. }
  6558. if (ismaxh) {
  6559. data.height = o.maxHeight;
  6560. }
  6561. if (isminw && cw) {
  6562. data.left = dw - o.minWidth;
  6563. }
  6564. if (ismaxw && cw) {
  6565. data.left = dw - o.maxWidth;
  6566. }
  6567. if (isminh && ch) {
  6568. data.top = dh - o.minHeight;
  6569. }
  6570. if (ismaxh && ch) {
  6571. data.top = dh - o.maxHeight;
  6572. }
  6573. // Fixing jump error on top/left - bug #2330
  6574. if (!data.width && !data.height && !data.left && data.top) {
  6575. data.top = null;
  6576. } else if (!data.width && !data.height && !data.top && data.left) {
  6577. data.left = null;
  6578. }
  6579. return data;
  6580. },
  6581. _getPaddingPlusBorderDimensions: function( element ) {
  6582. var i = 0,
  6583. widths = [],
  6584. borders = [
  6585. element.css( "borderTopWidth" ),
  6586. element.css( "borderRightWidth" ),
  6587. element.css( "borderBottomWidth" ),
  6588. element.css( "borderLeftWidth" )
  6589. ],
  6590. paddings = [
  6591. element.css( "paddingTop" ),
  6592. element.css( "paddingRight" ),
  6593. element.css( "paddingBottom" ),
  6594. element.css( "paddingLeft" )
  6595. ];
  6596. for ( ; i < 4; i++ ) {
  6597. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  6598. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  6599. }
  6600. return {
  6601. height: widths[ 0 ] + widths[ 2 ],
  6602. width: widths[ 1 ] + widths[ 3 ]
  6603. };
  6604. },
  6605. _proportionallyResize: function() {
  6606. if (!this._proportionallyResizeElements.length) {
  6607. return;
  6608. }
  6609. var prel,
  6610. i = 0,
  6611. element = this.helper || this.element;
  6612. for ( ; i < this._proportionallyResizeElements.length; i++) {
  6613. prel = this._proportionallyResizeElements[i];
  6614. // TODO: Seems like a bug to cache this.outerDimensions
  6615. // considering that we are in a loop.
  6616. if (!this.outerDimensions) {
  6617. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  6618. }
  6619. prel.css({
  6620. height: (element.height() - this.outerDimensions.height) || 0,
  6621. width: (element.width() - this.outerDimensions.width) || 0
  6622. });
  6623. }
  6624. },
  6625. _renderProxy: function() {
  6626. var el = this.element, o = this.options;
  6627. this.elementOffset = el.offset();
  6628. if (this._helper) {
  6629. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  6630. this.helper.addClass(this._helper).css({
  6631. width: this.element.outerWidth() - 1,
  6632. height: this.element.outerHeight() - 1,
  6633. position: "absolute",
  6634. left: this.elementOffset.left + "px",
  6635. top: this.elementOffset.top + "px",
  6636. zIndex: ++o.zIndex //TODO: Don't modify option
  6637. });
  6638. this.helper
  6639. .appendTo("body")
  6640. .disableSelection();
  6641. } else {
  6642. this.helper = this.element;
  6643. }
  6644. },
  6645. _change: {
  6646. e: function(event, dx) {
  6647. return { width: this.originalSize.width + dx };
  6648. },
  6649. w: function(event, dx) {
  6650. var cs = this.originalSize, sp = this.originalPosition;
  6651. return { left: sp.left + dx, width: cs.width - dx };
  6652. },
  6653. n: function(event, dx, dy) {
  6654. var cs = this.originalSize, sp = this.originalPosition;
  6655. return { top: sp.top + dy, height: cs.height - dy };
  6656. },
  6657. s: function(event, dx, dy) {
  6658. return { height: this.originalSize.height + dy };
  6659. },
  6660. se: function(event, dx, dy) {
  6661. return $.extend(this._change.s.apply(this, arguments),
  6662. this._change.e.apply(this, [ event, dx, dy ]));
  6663. },
  6664. sw: function(event, dx, dy) {
  6665. return $.extend(this._change.s.apply(this, arguments),
  6666. this._change.w.apply(this, [ event, dx, dy ]));
  6667. },
  6668. ne: function(event, dx, dy) {
  6669. return $.extend(this._change.n.apply(this, arguments),
  6670. this._change.e.apply(this, [ event, dx, dy ]));
  6671. },
  6672. nw: function(event, dx, dy) {
  6673. return $.extend(this._change.n.apply(this, arguments),
  6674. this._change.w.apply(this, [ event, dx, dy ]));
  6675. }
  6676. },
  6677. _propagate: function(n, event) {
  6678. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  6679. (n !== "resize" && this._trigger(n, event, this.ui()));
  6680. },
  6681. plugins: {},
  6682. ui: function() {
  6683. return {
  6684. originalElement: this.originalElement,
  6685. element: this.element,
  6686. helper: this.helper,
  6687. position: this.position,
  6688. size: this.size,
  6689. originalSize: this.originalSize,
  6690. originalPosition: this.originalPosition
  6691. };
  6692. }
  6693. });
  6694. /*
  6695. * Resizable Extensions
  6696. */
  6697. $.ui.plugin.add("resizable", "animate", {
  6698. stop: function( event ) {
  6699. var that = $(this).resizable( "instance" ),
  6700. o = that.options,
  6701. pr = that._proportionallyResizeElements,
  6702. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  6703. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  6704. soffsetw = ista ? 0 : that.sizeDiff.width,
  6705. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  6706. left = (parseInt(that.element.css("left"), 10) +
  6707. (that.position.left - that.originalPosition.left)) || null,
  6708. top = (parseInt(that.element.css("top"), 10) +
  6709. (that.position.top - that.originalPosition.top)) || null;
  6710. that.element.animate(
  6711. $.extend(style, top && left ? { top: top, left: left } : {}), {
  6712. duration: o.animateDuration,
  6713. easing: o.animateEasing,
  6714. step: function() {
  6715. var data = {
  6716. width: parseInt(that.element.css("width"), 10),
  6717. height: parseInt(that.element.css("height"), 10),
  6718. top: parseInt(that.element.css("top"), 10),
  6719. left: parseInt(that.element.css("left"), 10)
  6720. };
  6721. if (pr && pr.length) {
  6722. $(pr[0]).css({ width: data.width, height: data.height });
  6723. }
  6724. // propagating resize, and updating values for each animation step
  6725. that._updateCache(data);
  6726. that._propagate("resize", event);
  6727. }
  6728. }
  6729. );
  6730. }
  6731. });
  6732. $.ui.plugin.add( "resizable", "containment", {
  6733. start: function() {
  6734. var element, p, co, ch, cw, width, height,
  6735. that = $( this ).resizable( "instance" ),
  6736. o = that.options,
  6737. el = that.element,
  6738. oc = o.containment,
  6739. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  6740. if ( !ce ) {
  6741. return;
  6742. }
  6743. that.containerElement = $( ce );
  6744. if ( /document/.test( oc ) || oc === document ) {
  6745. that.containerOffset = {
  6746. left: 0,
  6747. top: 0
  6748. };
  6749. that.containerPosition = {
  6750. left: 0,
  6751. top: 0
  6752. };
  6753. that.parentData = {
  6754. element: $( document ),
  6755. left: 0,
  6756. top: 0,
  6757. width: $( document ).width(),
  6758. height: $( document ).height() || document.body.parentNode.scrollHeight
  6759. };
  6760. } else {
  6761. element = $( ce );
  6762. p = [];
  6763. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  6764. p[ i ] = that._num( element.css( "padding" + name ) );
  6765. });
  6766. that.containerOffset = element.offset();
  6767. that.containerPosition = element.position();
  6768. that.containerSize = {
  6769. height: ( element.innerHeight() - p[ 3 ] ),
  6770. width: ( element.innerWidth() - p[ 1 ] )
  6771. };
  6772. co = that.containerOffset;
  6773. ch = that.containerSize.height;
  6774. cw = that.containerSize.width;
  6775. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  6776. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  6777. that.parentData = {
  6778. element: ce,
  6779. left: co.left,
  6780. top: co.top,
  6781. width: width,
  6782. height: height
  6783. };
  6784. }
  6785. },
  6786. resize: function( event ) {
  6787. var woset, hoset, isParent, isOffsetRelative,
  6788. that = $( this ).resizable( "instance" ),
  6789. o = that.options,
  6790. co = that.containerOffset,
  6791. cp = that.position,
  6792. pRatio = that._aspectRatio || event.shiftKey,
  6793. cop = {
  6794. top: 0,
  6795. left: 0
  6796. },
  6797. ce = that.containerElement,
  6798. continueResize = true;
  6799. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  6800. cop = co;
  6801. }
  6802. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  6803. that.size.width = that.size.width +
  6804. ( that._helper ?
  6805. ( that.position.left - co.left ) :
  6806. ( that.position.left - cop.left ) );
  6807. if ( pRatio ) {
  6808. that.size.height = that.size.width / that.aspectRatio;
  6809. continueResize = false;
  6810. }
  6811. that.position.left = o.helper ? co.left : 0;
  6812. }
  6813. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  6814. that.size.height = that.size.height +
  6815. ( that._helper ?
  6816. ( that.position.top - co.top ) :
  6817. that.position.top );
  6818. if ( pRatio ) {
  6819. that.size.width = that.size.height * that.aspectRatio;
  6820. continueResize = false;
  6821. }
  6822. that.position.top = that._helper ? co.top : 0;
  6823. }
  6824. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  6825. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  6826. if ( isParent && isOffsetRelative ) {
  6827. that.offset.left = that.parentData.left + that.position.left;
  6828. that.offset.top = that.parentData.top + that.position.top;
  6829. } else {
  6830. that.offset.left = that.element.offset().left;
  6831. that.offset.top = that.element.offset().top;
  6832. }
  6833. woset = Math.abs( that.sizeDiff.width +
  6834. (that._helper ?
  6835. that.offset.left - cop.left :
  6836. (that.offset.left - co.left)) );
  6837. hoset = Math.abs( that.sizeDiff.height +
  6838. (that._helper ?
  6839. that.offset.top - cop.top :
  6840. (that.offset.top - co.top)) );
  6841. if ( woset + that.size.width >= that.parentData.width ) {
  6842. that.size.width = that.parentData.width - woset;
  6843. if ( pRatio ) {
  6844. that.size.height = that.size.width / that.aspectRatio;
  6845. continueResize = false;
  6846. }
  6847. }
  6848. if ( hoset + that.size.height >= that.parentData.height ) {
  6849. that.size.height = that.parentData.height - hoset;
  6850. if ( pRatio ) {
  6851. that.size.width = that.size.height * that.aspectRatio;
  6852. continueResize = false;
  6853. }
  6854. }
  6855. if ( !continueResize ) {
  6856. that.position.left = that.prevPosition.left;
  6857. that.position.top = that.prevPosition.top;
  6858. that.size.width = that.prevSize.width;
  6859. that.size.height = that.prevSize.height;
  6860. }
  6861. },
  6862. stop: function() {
  6863. var that = $( this ).resizable( "instance" ),
  6864. o = that.options,
  6865. co = that.containerOffset,
  6866. cop = that.containerPosition,
  6867. ce = that.containerElement,
  6868. helper = $( that.helper ),
  6869. ho = helper.offset(),
  6870. w = helper.outerWidth() - that.sizeDiff.width,
  6871. h = helper.outerHeight() - that.sizeDiff.height;
  6872. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  6873. $( this ).css({
  6874. left: ho.left - cop.left - co.left,
  6875. width: w,
  6876. height: h
  6877. });
  6878. }
  6879. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  6880. $( this ).css({
  6881. left: ho.left - cop.left - co.left,
  6882. width: w,
  6883. height: h
  6884. });
  6885. }
  6886. }
  6887. });
  6888. $.ui.plugin.add("resizable", "alsoResize", {
  6889. start: function() {
  6890. var that = $(this).resizable( "instance" ),
  6891. o = that.options;
  6892. $(o.alsoResize).each(function() {
  6893. var el = $(this);
  6894. el.data("ui-resizable-alsoresize", {
  6895. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  6896. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  6897. });
  6898. });
  6899. },
  6900. resize: function(event, ui) {
  6901. var that = $(this).resizable( "instance" ),
  6902. o = that.options,
  6903. os = that.originalSize,
  6904. op = that.originalPosition,
  6905. delta = {
  6906. height: (that.size.height - os.height) || 0,
  6907. width: (that.size.width - os.width) || 0,
  6908. top: (that.position.top - op.top) || 0,
  6909. left: (that.position.left - op.left) || 0
  6910. };
  6911. $(o.alsoResize).each(function() {
  6912. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  6913. css = el.parents(ui.originalElement[0]).length ?
  6914. [ "width", "height" ] :
  6915. [ "width", "height", "top", "left" ];
  6916. $.each(css, function(i, prop) {
  6917. var sum = (start[prop] || 0) + (delta[prop] || 0);
  6918. if (sum && sum >= 0) {
  6919. style[prop] = sum || null;
  6920. }
  6921. });
  6922. el.css(style);
  6923. });
  6924. },
  6925. stop: function() {
  6926. $(this).removeData("resizable-alsoresize");
  6927. }
  6928. });
  6929. $.ui.plugin.add("resizable", "ghost", {
  6930. start: function() {
  6931. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  6932. that.ghost = that.originalElement.clone();
  6933. that.ghost
  6934. .css({
  6935. opacity: 0.25,
  6936. display: "block",
  6937. position: "relative",
  6938. height: cs.height,
  6939. width: cs.width,
  6940. margin: 0,
  6941. left: 0,
  6942. top: 0
  6943. })
  6944. .addClass("ui-resizable-ghost")
  6945. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  6946. that.ghost.appendTo(that.helper);
  6947. },
  6948. resize: function() {
  6949. var that = $(this).resizable( "instance" );
  6950. if (that.ghost) {
  6951. that.ghost.css({
  6952. position: "relative",
  6953. height: that.size.height,
  6954. width: that.size.width
  6955. });
  6956. }
  6957. },
  6958. stop: function() {
  6959. var that = $(this).resizable( "instance" );
  6960. if (that.ghost && that.helper) {
  6961. that.helper.get(0).removeChild(that.ghost.get(0));
  6962. }
  6963. }
  6964. });
  6965. $.ui.plugin.add("resizable", "grid", {
  6966. resize: function() {
  6967. var outerDimensions,
  6968. that = $(this).resizable( "instance" ),
  6969. o = that.options,
  6970. cs = that.size,
  6971. os = that.originalSize,
  6972. op = that.originalPosition,
  6973. a = that.axis,
  6974. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  6975. gridX = (grid[0] || 1),
  6976. gridY = (grid[1] || 1),
  6977. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  6978. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  6979. newWidth = os.width + ox,
  6980. newHeight = os.height + oy,
  6981. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  6982. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  6983. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  6984. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  6985. o.grid = grid;
  6986. if (isMinWidth) {
  6987. newWidth += gridX;
  6988. }
  6989. if (isMinHeight) {
  6990. newHeight += gridY;
  6991. }
  6992. if (isMaxWidth) {
  6993. newWidth -= gridX;
  6994. }
  6995. if (isMaxHeight) {
  6996. newHeight -= gridY;
  6997. }
  6998. if (/^(se|s|e)$/.test(a)) {
  6999. that.size.width = newWidth;
  7000. that.size.height = newHeight;
  7001. } else if (/^(ne)$/.test(a)) {
  7002. that.size.width = newWidth;
  7003. that.size.height = newHeight;
  7004. that.position.top = op.top - oy;
  7005. } else if (/^(sw)$/.test(a)) {
  7006. that.size.width = newWidth;
  7007. that.size.height = newHeight;
  7008. that.position.left = op.left - ox;
  7009. } else {
  7010. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  7011. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  7012. }
  7013. if ( newHeight - gridY > 0 ) {
  7014. that.size.height = newHeight;
  7015. that.position.top = op.top - oy;
  7016. } else {
  7017. newHeight = gridY - outerDimensions.height;
  7018. that.size.height = newHeight;
  7019. that.position.top = op.top + os.height - newHeight;
  7020. }
  7021. if ( newWidth - gridX > 0 ) {
  7022. that.size.width = newWidth;
  7023. that.position.left = op.left - ox;
  7024. } else {
  7025. newWidth = gridX - outerDimensions.width;
  7026. that.size.width = newWidth;
  7027. that.position.left = op.left + os.width - newWidth;
  7028. }
  7029. }
  7030. }
  7031. });
  7032. var resizable = $.ui.resizable;
  7033. /*!
  7034. * jQuery UI Dialog 1.11.4
  7035. * http://jqueryui.com
  7036. *
  7037. * Copyright jQuery Foundation and other contributors
  7038. * Released under the MIT license.
  7039. * http://jquery.org/license
  7040. *
  7041. * http://api.jqueryui.com/dialog/
  7042. */
  7043. var dialog = $.widget( "ui.dialog", {
  7044. version: "1.11.4",
  7045. options: {
  7046. appendTo: "body",
  7047. autoOpen: true,
  7048. buttons: [],
  7049. closeOnEscape: true,
  7050. closeText: "Close",
  7051. dialogClass: "",
  7052. draggable: true,
  7053. hide: null,
  7054. height: "auto",
  7055. maxHeight: null,
  7056. maxWidth: null,
  7057. minHeight: 150,
  7058. minWidth: 150,
  7059. modal: false,
  7060. position: {
  7061. my: "center",
  7062. at: "center",
  7063. of: window,
  7064. collision: "fit",
  7065. // Ensure the titlebar is always visible
  7066. using: function( pos ) {
  7067. var topOffset = $( this ).css( pos ).offset().top;
  7068. if ( topOffset < 0 ) {
  7069. $( this ).css( "top", pos.top - topOffset );
  7070. }
  7071. }
  7072. },
  7073. resizable: true,
  7074. show: null,
  7075. title: null,
  7076. width: 300,
  7077. // callbacks
  7078. beforeClose: null,
  7079. close: null,
  7080. drag: null,
  7081. dragStart: null,
  7082. dragStop: null,
  7083. focus: null,
  7084. open: null,
  7085. resize: null,
  7086. resizeStart: null,
  7087. resizeStop: null
  7088. },
  7089. sizeRelatedOptions: {
  7090. buttons: true,
  7091. height: true,
  7092. maxHeight: true,
  7093. maxWidth: true,
  7094. minHeight: true,
  7095. minWidth: true,
  7096. width: true
  7097. },
  7098. resizableRelatedOptions: {
  7099. maxHeight: true,
  7100. maxWidth: true,
  7101. minHeight: true,
  7102. minWidth: true
  7103. },
  7104. _create: function() {
  7105. this.originalCss = {
  7106. display: this.element[ 0 ].style.display,
  7107. width: this.element[ 0 ].style.width,
  7108. minHeight: this.element[ 0 ].style.minHeight,
  7109. maxHeight: this.element[ 0 ].style.maxHeight,
  7110. height: this.element[ 0 ].style.height
  7111. };
  7112. this.originalPosition = {
  7113. parent: this.element.parent(),
  7114. index: this.element.parent().children().index( this.element )
  7115. };
  7116. this.originalTitle = this.element.attr( "title" );
  7117. this.options.title = this.options.title || this.originalTitle;
  7118. this._createWrapper();
  7119. this.element
  7120. .show()
  7121. .removeAttr( "title" )
  7122. .addClass( "ui-dialog-content ui-widget-content" )
  7123. .appendTo( this.uiDialog );
  7124. this._createTitlebar();
  7125. this._createButtonPane();
  7126. if ( this.options.draggable && $.fn.draggable ) {
  7127. this._makeDraggable();
  7128. }
  7129. if ( this.options.resizable && $.fn.resizable ) {
  7130. this._makeResizable();
  7131. }
  7132. this._isOpen = false;
  7133. this._trackFocus();
  7134. },
  7135. _init: function() {
  7136. if ( this.options.autoOpen ) {
  7137. this.open();
  7138. }
  7139. },
  7140. _appendTo: function() {
  7141. var element = this.options.appendTo;
  7142. if ( element && (element.jquery || element.nodeType) ) {
  7143. return $( element );
  7144. }
  7145. return this.document.find( element || "body" ).eq( 0 );
  7146. },
  7147. _destroy: function() {
  7148. var next,
  7149. originalPosition = this.originalPosition;
  7150. this._untrackInstance();
  7151. this._destroyOverlay();
  7152. this.element
  7153. .removeUniqueId()
  7154. .removeClass( "ui-dialog-content ui-widget-content" )
  7155. .css( this.originalCss )
  7156. // Without detaching first, the following becomes really slow
  7157. .detach();
  7158. this.uiDialog.stop( true, true ).remove();
  7159. if ( this.originalTitle ) {
  7160. this.element.attr( "title", this.originalTitle );
  7161. }
  7162. next = originalPosition.parent.children().eq( originalPosition.index );
  7163. // Don't try to place the dialog next to itself (#8613)
  7164. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  7165. next.before( this.element );
  7166. } else {
  7167. originalPosition.parent.append( this.element );
  7168. }
  7169. },
  7170. widget: function() {
  7171. return this.uiDialog;
  7172. },
  7173. disable: $.noop,
  7174. enable: $.noop,
  7175. close: function( event ) {
  7176. var activeElement,
  7177. that = this;
  7178. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  7179. return;
  7180. }
  7181. this._isOpen = false;
  7182. this._focusedElement = null;
  7183. this._destroyOverlay();
  7184. this._untrackInstance();
  7185. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  7186. // support: IE9
  7187. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  7188. try {
  7189. activeElement = this.document[ 0 ].activeElement;
  7190. // Support: IE9, IE10
  7191. // If the <body> is blurred, IE will switch windows, see #4520
  7192. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  7193. // Hiding a focused element doesn't trigger blur in WebKit
  7194. // so in case we have nothing to focus on, explicitly blur the active element
  7195. // https://bugs.webkit.org/show_bug.cgi?id=47182
  7196. $( activeElement ).blur();
  7197. }
  7198. } catch ( error ) {}
  7199. }
  7200. this._hide( this.uiDialog, this.options.hide, function() {
  7201. that._trigger( "close", event );
  7202. });
  7203. },
  7204. isOpen: function() {
  7205. return this._isOpen;
  7206. },
  7207. moveToTop: function() {
  7208. this._moveToTop();
  7209. },
  7210. _moveToTop: function( event, silent ) {
  7211. var moved = false,
  7212. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  7213. return +$( this ).css( "z-index" );
  7214. }).get(),
  7215. zIndexMax = Math.max.apply( null, zIndices );
  7216. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  7217. this.uiDialog.css( "z-index", zIndexMax + 1 );
  7218. moved = true;
  7219. }
  7220. if ( moved && !silent ) {
  7221. this._trigger( "focus", event );
  7222. }
  7223. return moved;
  7224. },
  7225. open: function() {
  7226. var that = this;
  7227. if ( this._isOpen ) {
  7228. if ( this._moveToTop() ) {
  7229. this._focusTabbable();
  7230. }
  7231. return;
  7232. }
  7233. this._isOpen = true;
  7234. this.opener = $( this.document[ 0 ].activeElement );
  7235. this._size();
  7236. this._position();
  7237. this._createOverlay();
  7238. this._moveToTop( null, true );
  7239. // Ensure the overlay is moved to the top with the dialog, but only when
  7240. // opening. The overlay shouldn't move after the dialog is open so that
  7241. // modeless dialogs opened after the modal dialog stack properly.
  7242. if ( this.overlay ) {
  7243. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  7244. }
  7245. this._show( this.uiDialog, this.options.show, function() {
  7246. that._focusTabbable();
  7247. that._trigger( "focus" );
  7248. });
  7249. // Track the dialog immediately upon openening in case a focus event
  7250. // somehow occurs outside of the dialog before an element inside the
  7251. // dialog is focused (#10152)
  7252. this._makeFocusTarget();
  7253. this._trigger( "open" );
  7254. },
  7255. _focusTabbable: function() {
  7256. // Set focus to the first match:
  7257. // 1. An element that was focused previously
  7258. // 2. First element inside the dialog matching [autofocus]
  7259. // 3. Tabbable element inside the content element
  7260. // 4. Tabbable element inside the buttonpane
  7261. // 5. The close button
  7262. // 6. The dialog itself
  7263. var hasFocus = this._focusedElement;
  7264. if ( !hasFocus ) {
  7265. hasFocus = this.element.find( "[autofocus]" );
  7266. }
  7267. if ( !hasFocus.length ) {
  7268. hasFocus = this.element.find( ":tabbable" );
  7269. }
  7270. if ( !hasFocus.length ) {
  7271. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  7272. }
  7273. if ( !hasFocus.length ) {
  7274. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  7275. }
  7276. if ( !hasFocus.length ) {
  7277. hasFocus = this.uiDialog;
  7278. }
  7279. hasFocus.eq( 0 ).focus();
  7280. },
  7281. _keepFocus: function( event ) {
  7282. function checkFocus() {
  7283. var activeElement = this.document[0].activeElement,
  7284. isActive = this.uiDialog[0] === activeElement ||
  7285. $.contains( this.uiDialog[0], activeElement );
  7286. if ( !isActive ) {
  7287. this._focusTabbable();
  7288. }
  7289. }
  7290. event.preventDefault();
  7291. checkFocus.call( this );
  7292. // support: IE
  7293. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7294. // so we check again later
  7295. this._delay( checkFocus );
  7296. },
  7297. _createWrapper: function() {
  7298. this.uiDialog = $("<div>")
  7299. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7300. this.options.dialogClass )
  7301. .hide()
  7302. .attr({
  7303. // Setting tabIndex makes the div focusable
  7304. tabIndex: -1,
  7305. role: "dialog"
  7306. })
  7307. .appendTo( this._appendTo() );
  7308. this._on( this.uiDialog, {
  7309. keydown: function( event ) {
  7310. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7311. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7312. event.preventDefault();
  7313. this.close( event );
  7314. return;
  7315. }
  7316. // prevent tabbing out of dialogs
  7317. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  7318. return;
  7319. }
  7320. var tabbables = this.uiDialog.find( ":tabbable" ),
  7321. first = tabbables.filter( ":first" ),
  7322. last = tabbables.filter( ":last" );
  7323. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7324. this._delay(function() {
  7325. first.focus();
  7326. });
  7327. event.preventDefault();
  7328. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7329. this._delay(function() {
  7330. last.focus();
  7331. });
  7332. event.preventDefault();
  7333. }
  7334. },
  7335. mousedown: function( event ) {
  7336. if ( this._moveToTop( event ) ) {
  7337. this._focusTabbable();
  7338. }
  7339. }
  7340. });
  7341. // We assume that any existing aria-describedby attribute means
  7342. // that the dialog content is marked up properly
  7343. // otherwise we brute force the content as the description
  7344. if ( !this.element.find( "[aria-describedby]" ).length ) {
  7345. this.uiDialog.attr({
  7346. "aria-describedby": this.element.uniqueId().attr( "id" )
  7347. });
  7348. }
  7349. },
  7350. _createTitlebar: function() {
  7351. var uiDialogTitle;
  7352. this.uiDialogTitlebar = $( "<div>" )
  7353. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  7354. .prependTo( this.uiDialog );
  7355. this._on( this.uiDialogTitlebar, {
  7356. mousedown: function( event ) {
  7357. // Don't prevent click on close button (#8838)
  7358. // Focusing a dialog that is partially scrolled out of view
  7359. // causes the browser to scroll it into view, preventing the click event
  7360. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  7361. // Dialog isn't getting focus when dragging (#8063)
  7362. this.uiDialog.focus();
  7363. }
  7364. }
  7365. });
  7366. // support: IE
  7367. // Use type="button" to prevent enter keypresses in textboxes from closing the
  7368. // dialog in IE (#9312)
  7369. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  7370. .button({
  7371. label: this.options.closeText,
  7372. icons: {
  7373. primary: "ui-icon-closethick"
  7374. },
  7375. text: false
  7376. })
  7377. .addClass( "ui-dialog-titlebar-close" )
  7378. .appendTo( this.uiDialogTitlebar );
  7379. this._on( this.uiDialogTitlebarClose, {
  7380. click: function( event ) {
  7381. event.preventDefault();
  7382. this.close( event );
  7383. }
  7384. });
  7385. uiDialogTitle = $( "<span>" )
  7386. .uniqueId()
  7387. .addClass( "ui-dialog-title" )
  7388. .prependTo( this.uiDialogTitlebar );
  7389. this._title( uiDialogTitle );
  7390. this.uiDialog.attr({
  7391. "aria-labelledby": uiDialogTitle.attr( "id" )
  7392. });
  7393. },
  7394. _title: function( title ) {
  7395. if ( !this.options.title ) {
  7396. title.html( "&#160;" );
  7397. }
  7398. title.text( this.options.title );
  7399. },
  7400. _createButtonPane: function() {
  7401. this.uiDialogButtonPane = $( "<div>" )
  7402. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  7403. this.uiButtonSet = $( "<div>" )
  7404. .addClass( "ui-dialog-buttonset" )
  7405. .appendTo( this.uiDialogButtonPane );
  7406. this._createButtons();
  7407. },
  7408. _createButtons: function() {
  7409. var that = this,
  7410. buttons = this.options.buttons;
  7411. // if we already have a button pane, remove it
  7412. this.uiDialogButtonPane.remove();
  7413. this.uiButtonSet.empty();
  7414. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  7415. this.uiDialog.removeClass( "ui-dialog-buttons" );
  7416. return;
  7417. }
  7418. $.each( buttons, function( name, props ) {
  7419. var click, buttonOptions;
  7420. props = $.isFunction( props ) ?
  7421. { click: props, text: name } :
  7422. props;
  7423. // Default to a non-submitting button
  7424. props = $.extend( { type: "button" }, props );
  7425. // Change the context for the click callback to be the main element
  7426. click = props.click;
  7427. props.click = function() {
  7428. click.apply( that.element[ 0 ], arguments );
  7429. };
  7430. buttonOptions = {
  7431. icons: props.icons,
  7432. text: props.showText
  7433. };
  7434. delete props.icons;
  7435. delete props.showText;
  7436. $( "<button></button>", props )
  7437. .button( buttonOptions )
  7438. .appendTo( that.uiButtonSet );
  7439. });
  7440. this.uiDialog.addClass( "ui-dialog-buttons" );
  7441. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7442. },
  7443. _makeDraggable: function() {
  7444. var that = this,
  7445. options = this.options;
  7446. function filteredUi( ui ) {
  7447. return {
  7448. position: ui.position,
  7449. offset: ui.offset
  7450. };
  7451. }
  7452. this.uiDialog.draggable({
  7453. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7454. handle: ".ui-dialog-titlebar",
  7455. containment: "document",
  7456. start: function( event, ui ) {
  7457. $( this ).addClass( "ui-dialog-dragging" );
  7458. that._blockFrames();
  7459. that._trigger( "dragStart", event, filteredUi( ui ) );
  7460. },
  7461. drag: function( event, ui ) {
  7462. that._trigger( "drag", event, filteredUi( ui ) );
  7463. },
  7464. stop: function( event, ui ) {
  7465. var left = ui.offset.left - that.document.scrollLeft(),
  7466. top = ui.offset.top - that.document.scrollTop();
  7467. options.position = {
  7468. my: "left top",
  7469. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7470. "top" + (top >= 0 ? "+" : "") + top,
  7471. of: that.window
  7472. };
  7473. $( this ).removeClass( "ui-dialog-dragging" );
  7474. that._unblockFrames();
  7475. that._trigger( "dragStop", event, filteredUi( ui ) );
  7476. }
  7477. });
  7478. },
  7479. _makeResizable: function() {
  7480. var that = this,
  7481. options = this.options,
  7482. handles = options.resizable,
  7483. // .ui-resizable has position: relative defined in the stylesheet
  7484. // but dialogs have to use absolute or fixed positioning
  7485. position = this.uiDialog.css("position"),
  7486. resizeHandles = typeof handles === "string" ?
  7487. handles :
  7488. "n,e,s,w,se,sw,ne,nw";
  7489. function filteredUi( ui ) {
  7490. return {
  7491. originalPosition: ui.originalPosition,
  7492. originalSize: ui.originalSize,
  7493. position: ui.position,
  7494. size: ui.size
  7495. };
  7496. }
  7497. this.uiDialog.resizable({
  7498. cancel: ".ui-dialog-content",
  7499. containment: "document",
  7500. alsoResize: this.element,
  7501. maxWidth: options.maxWidth,
  7502. maxHeight: options.maxHeight,
  7503. minWidth: options.minWidth,
  7504. minHeight: this._minHeight(),
  7505. handles: resizeHandles,
  7506. start: function( event, ui ) {
  7507. $( this ).addClass( "ui-dialog-resizing" );
  7508. that._blockFrames();
  7509. that._trigger( "resizeStart", event, filteredUi( ui ) );
  7510. },
  7511. resize: function( event, ui ) {
  7512. that._trigger( "resize", event, filteredUi( ui ) );
  7513. },
  7514. stop: function( event, ui ) {
  7515. var offset = that.uiDialog.offset(),
  7516. left = offset.left - that.document.scrollLeft(),
  7517. top = offset.top - that.document.scrollTop();
  7518. options.height = that.uiDialog.height();
  7519. options.width = that.uiDialog.width();
  7520. options.position = {
  7521. my: "left top",
  7522. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7523. "top" + (top >= 0 ? "+" : "") + top,
  7524. of: that.window
  7525. };
  7526. $( this ).removeClass( "ui-dialog-resizing" );
  7527. that._unblockFrames();
  7528. that._trigger( "resizeStop", event, filteredUi( ui ) );
  7529. }
  7530. })
  7531. .css( "position", position );
  7532. },
  7533. _trackFocus: function() {
  7534. this._on( this.widget(), {
  7535. focusin: function( event ) {
  7536. this._makeFocusTarget();
  7537. this._focusedElement = $( event.target );
  7538. }
  7539. });
  7540. },
  7541. _makeFocusTarget: function() {
  7542. this._untrackInstance();
  7543. this._trackingInstances().unshift( this );
  7544. },
  7545. _untrackInstance: function() {
  7546. var instances = this._trackingInstances(),
  7547. exists = $.inArray( this, instances );
  7548. if ( exists !== -1 ) {
  7549. instances.splice( exists, 1 );
  7550. }
  7551. },
  7552. _trackingInstances: function() {
  7553. var instances = this.document.data( "ui-dialog-instances" );
  7554. if ( !instances ) {
  7555. instances = [];
  7556. this.document.data( "ui-dialog-instances", instances );
  7557. }
  7558. return instances;
  7559. },
  7560. _minHeight: function() {
  7561. var options = this.options;
  7562. return options.height === "auto" ?
  7563. options.minHeight :
  7564. Math.min( options.minHeight, options.height );
  7565. },
  7566. _position: function() {
  7567. // Need to show the dialog to get the actual offset in the position plugin
  7568. var isVisible = this.uiDialog.is( ":visible" );
  7569. if ( !isVisible ) {
  7570. this.uiDialog.show();
  7571. }
  7572. this.uiDialog.position( this.options.position );
  7573. if ( !isVisible ) {
  7574. this.uiDialog.hide();
  7575. }
  7576. },
  7577. _setOptions: function( options ) {
  7578. var that = this,
  7579. resize = false,
  7580. resizableOptions = {};
  7581. $.each( options, function( key, value ) {
  7582. that._setOption( key, value );
  7583. if ( key in that.sizeRelatedOptions ) {
  7584. resize = true;
  7585. }
  7586. if ( key in that.resizableRelatedOptions ) {
  7587. resizableOptions[ key ] = value;
  7588. }
  7589. });
  7590. if ( resize ) {
  7591. this._size();
  7592. this._position();
  7593. }
  7594. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7595. this.uiDialog.resizable( "option", resizableOptions );
  7596. }
  7597. },
  7598. _setOption: function( key, value ) {
  7599. var isDraggable, isResizable,
  7600. uiDialog = this.uiDialog;
  7601. if ( key === "dialogClass" ) {
  7602. uiDialog
  7603. .removeClass( this.options.dialogClass )
  7604. .addClass( value );
  7605. }
  7606. if ( key === "disabled" ) {
  7607. return;
  7608. }
  7609. this._super( key, value );
  7610. if ( key === "appendTo" ) {
  7611. this.uiDialog.appendTo( this._appendTo() );
  7612. }
  7613. if ( key === "buttons" ) {
  7614. this._createButtons();
  7615. }
  7616. if ( key === "closeText" ) {
  7617. this.uiDialogTitlebarClose.button({
  7618. // Ensure that we always pass a string
  7619. label: "" + value
  7620. });
  7621. }
  7622. if ( key === "draggable" ) {
  7623. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  7624. if ( isDraggable && !value ) {
  7625. uiDialog.draggable( "destroy" );
  7626. }
  7627. if ( !isDraggable && value ) {
  7628. this._makeDraggable();
  7629. }
  7630. }
  7631. if ( key === "position" ) {
  7632. this._position();
  7633. }
  7634. if ( key === "resizable" ) {
  7635. // currently resizable, becoming non-resizable
  7636. isResizable = uiDialog.is( ":data(ui-resizable)" );
  7637. if ( isResizable && !value ) {
  7638. uiDialog.resizable( "destroy" );
  7639. }
  7640. // currently resizable, changing handles
  7641. if ( isResizable && typeof value === "string" ) {
  7642. uiDialog.resizable( "option", "handles", value );
  7643. }
  7644. // currently non-resizable, becoming resizable
  7645. if ( !isResizable && value !== false ) {
  7646. this._makeResizable();
  7647. }
  7648. }
  7649. if ( key === "title" ) {
  7650. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  7651. }
  7652. },
  7653. _size: function() {
  7654. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  7655. // divs will both have width and height set, so we need to reset them
  7656. var nonContentHeight, minContentHeight, maxContentHeight,
  7657. options = this.options;
  7658. // Reset content sizing
  7659. this.element.show().css({
  7660. width: "auto",
  7661. minHeight: 0,
  7662. maxHeight: "none",
  7663. height: 0
  7664. });
  7665. if ( options.minWidth > options.width ) {
  7666. options.width = options.minWidth;
  7667. }
  7668. // reset wrapper sizing
  7669. // determine the height of all the non-content elements
  7670. nonContentHeight = this.uiDialog.css({
  7671. height: "auto",
  7672. width: options.width
  7673. })
  7674. .outerHeight();
  7675. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  7676. maxContentHeight = typeof options.maxHeight === "number" ?
  7677. Math.max( 0, options.maxHeight - nonContentHeight ) :
  7678. "none";
  7679. if ( options.height === "auto" ) {
  7680. this.element.css({
  7681. minHeight: minContentHeight,
  7682. maxHeight: maxContentHeight,
  7683. height: "auto"
  7684. });
  7685. } else {
  7686. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  7687. }
  7688. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7689. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  7690. }
  7691. },
  7692. _blockFrames: function() {
  7693. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  7694. var iframe = $( this );
  7695. return $( "<div>" )
  7696. .css({
  7697. position: "absolute",
  7698. width: iframe.outerWidth(),
  7699. height: iframe.outerHeight()
  7700. })
  7701. .appendTo( iframe.parent() )
  7702. .offset( iframe.offset() )[0];
  7703. });
  7704. },
  7705. _unblockFrames: function() {
  7706. if ( this.iframeBlocks ) {
  7707. this.iframeBlocks.remove();
  7708. delete this.iframeBlocks;
  7709. }
  7710. },
  7711. _allowInteraction: function( event ) {
  7712. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  7713. return true;
  7714. }
  7715. // TODO: Remove hack when datepicker implements
  7716. // the .ui-front logic (#8989)
  7717. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  7718. },
  7719. _createOverlay: function() {
  7720. if ( !this.options.modal ) {
  7721. return;
  7722. }
  7723. // We use a delay in case the overlay is created from an
  7724. // event that we're going to be cancelling (#2804)
  7725. var isOpening = true;
  7726. this._delay(function() {
  7727. isOpening = false;
  7728. });
  7729. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  7730. // Prevent use of anchors and inputs
  7731. // Using _on() for an event handler shared across many instances is
  7732. // safe because the dialogs stack and must be closed in reverse order
  7733. this._on( this.document, {
  7734. focusin: function( event ) {
  7735. if ( isOpening ) {
  7736. return;
  7737. }
  7738. if ( !this._allowInteraction( event ) ) {
  7739. event.preventDefault();
  7740. this._trackingInstances()[ 0 ]._focusTabbable();
  7741. }
  7742. }
  7743. });
  7744. }
  7745. this.overlay = $( "<div>" )
  7746. .addClass( "ui-widget-overlay ui-front" )
  7747. .appendTo( this._appendTo() );
  7748. this._on( this.overlay, {
  7749. mousedown: "_keepFocus"
  7750. });
  7751. this.document.data( "ui-dialog-overlays",
  7752. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  7753. },
  7754. _destroyOverlay: function() {
  7755. if ( !this.options.modal ) {
  7756. return;
  7757. }
  7758. if ( this.overlay ) {
  7759. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  7760. if ( !overlays ) {
  7761. this.document
  7762. .unbind( "focusin" )
  7763. .removeData( "ui-dialog-overlays" );
  7764. } else {
  7765. this.document.data( "ui-dialog-overlays", overlays );
  7766. }
  7767. this.overlay.remove();
  7768. this.overlay = null;
  7769. }
  7770. }
  7771. });
  7772. /*!
  7773. * jQuery UI Droppable 1.11.4
  7774. * http://jqueryui.com
  7775. *
  7776. * Copyright jQuery Foundation and other contributors
  7777. * Released under the MIT license.
  7778. * http://jquery.org/license
  7779. *
  7780. * http://api.jqueryui.com/droppable/
  7781. */
  7782. $.widget( "ui.droppable", {
  7783. version: "1.11.4",
  7784. widgetEventPrefix: "drop",
  7785. options: {
  7786. accept: "*",
  7787. activeClass: false,
  7788. addClasses: true,
  7789. greedy: false,
  7790. hoverClass: false,
  7791. scope: "default",
  7792. tolerance: "intersect",
  7793. // callbacks
  7794. activate: null,
  7795. deactivate: null,
  7796. drop: null,
  7797. out: null,
  7798. over: null
  7799. },
  7800. _create: function() {
  7801. var proportions,
  7802. o = this.options,
  7803. accept = o.accept;
  7804. this.isover = false;
  7805. this.isout = true;
  7806. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  7807. return d.is( accept );
  7808. };
  7809. this.proportions = function( /* valueToWrite */ ) {
  7810. if ( arguments.length ) {
  7811. // Store the droppable's proportions
  7812. proportions = arguments[ 0 ];
  7813. } else {
  7814. // Retrieve or derive the droppable's proportions
  7815. return proportions ?
  7816. proportions :
  7817. proportions = {
  7818. width: this.element[ 0 ].offsetWidth,
  7819. height: this.element[ 0 ].offsetHeight
  7820. };
  7821. }
  7822. };
  7823. this._addToManager( o.scope );
  7824. o.addClasses && this.element.addClass( "ui-droppable" );
  7825. },
  7826. _addToManager: function( scope ) {
  7827. // Add the reference and positions to the manager
  7828. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  7829. $.ui.ddmanager.droppables[ scope ].push( this );
  7830. },
  7831. _splice: function( drop ) {
  7832. var i = 0;
  7833. for ( ; i < drop.length; i++ ) {
  7834. if ( drop[ i ] === this ) {
  7835. drop.splice( i, 1 );
  7836. }
  7837. }
  7838. },
  7839. _destroy: function() {
  7840. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7841. this._splice( drop );
  7842. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  7843. },
  7844. _setOption: function( key, value ) {
  7845. if ( key === "accept" ) {
  7846. this.accept = $.isFunction( value ) ? value : function( d ) {
  7847. return d.is( value );
  7848. };
  7849. } else if ( key === "scope" ) {
  7850. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7851. this._splice( drop );
  7852. this._addToManager( value );
  7853. }
  7854. this._super( key, value );
  7855. },
  7856. _activate: function( event ) {
  7857. var draggable = $.ui.ddmanager.current;
  7858. if ( this.options.activeClass ) {
  7859. this.element.addClass( this.options.activeClass );
  7860. }
  7861. if ( draggable ){
  7862. this._trigger( "activate", event, this.ui( draggable ) );
  7863. }
  7864. },
  7865. _deactivate: function( event ) {
  7866. var draggable = $.ui.ddmanager.current;
  7867. if ( this.options.activeClass ) {
  7868. this.element.removeClass( this.options.activeClass );
  7869. }
  7870. if ( draggable ){
  7871. this._trigger( "deactivate", event, this.ui( draggable ) );
  7872. }
  7873. },
  7874. _over: function( event ) {
  7875. var draggable = $.ui.ddmanager.current;
  7876. // Bail if draggable and droppable are same element
  7877. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7878. return;
  7879. }
  7880. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7881. if ( this.options.hoverClass ) {
  7882. this.element.addClass( this.options.hoverClass );
  7883. }
  7884. this._trigger( "over", event, this.ui( draggable ) );
  7885. }
  7886. },
  7887. _out: function( event ) {
  7888. var draggable = $.ui.ddmanager.current;
  7889. // Bail if draggable and droppable are same element
  7890. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7891. return;
  7892. }
  7893. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7894. if ( this.options.hoverClass ) {
  7895. this.element.removeClass( this.options.hoverClass );
  7896. }
  7897. this._trigger( "out", event, this.ui( draggable ) );
  7898. }
  7899. },
  7900. _drop: function( event, custom ) {
  7901. var draggable = custom || $.ui.ddmanager.current,
  7902. childrenIntersection = false;
  7903. // Bail if draggable and droppable are same element
  7904. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7905. return false;
  7906. }
  7907. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  7908. var inst = $( this ).droppable( "instance" );
  7909. if (
  7910. inst.options.greedy &&
  7911. !inst.options.disabled &&
  7912. inst.options.scope === draggable.options.scope &&
  7913. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  7914. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  7915. ) { childrenIntersection = true; return false; }
  7916. });
  7917. if ( childrenIntersection ) {
  7918. return false;
  7919. }
  7920. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7921. if ( this.options.activeClass ) {
  7922. this.element.removeClass( this.options.activeClass );
  7923. }
  7924. if ( this.options.hoverClass ) {
  7925. this.element.removeClass( this.options.hoverClass );
  7926. }
  7927. this._trigger( "drop", event, this.ui( draggable ) );
  7928. return this.element;
  7929. }
  7930. return false;
  7931. },
  7932. ui: function( c ) {
  7933. return {
  7934. draggable: ( c.currentItem || c.element ),
  7935. helper: c.helper,
  7936. position: c.position,
  7937. offset: c.positionAbs
  7938. };
  7939. }
  7940. });
  7941. $.ui.intersect = (function() {
  7942. function isOverAxis( x, reference, size ) {
  7943. return ( x >= reference ) && ( x < ( reference + size ) );
  7944. }
  7945. return function( draggable, droppable, toleranceMode, event ) {
  7946. if ( !droppable.offset ) {
  7947. return false;
  7948. }
  7949. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  7950. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  7951. x2 = x1 + draggable.helperProportions.width,
  7952. y2 = y1 + draggable.helperProportions.height,
  7953. l = droppable.offset.left,
  7954. t = droppable.offset.top,
  7955. r = l + droppable.proportions().width,
  7956. b = t + droppable.proportions().height;
  7957. switch ( toleranceMode ) {
  7958. case "fit":
  7959. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  7960. case "intersect":
  7961. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  7962. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  7963. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  7964. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  7965. case "pointer":
  7966. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  7967. case "touch":
  7968. return (
  7969. ( y1 >= t && y1 <= b ) || // Top edge touching
  7970. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  7971. ( y1 < t && y2 > b ) // Surrounded vertically
  7972. ) && (
  7973. ( x1 >= l && x1 <= r ) || // Left edge touching
  7974. ( x2 >= l && x2 <= r ) || // Right edge touching
  7975. ( x1 < l && x2 > r ) // Surrounded horizontally
  7976. );
  7977. default:
  7978. return false;
  7979. }
  7980. };
  7981. })();
  7982. /*
  7983. This manager tracks offsets of draggables and droppables
  7984. */
  7985. $.ui.ddmanager = {
  7986. current: null,
  7987. droppables: { "default": [] },
  7988. prepareOffsets: function( t, event ) {
  7989. var i, j,
  7990. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  7991. type = event ? event.type : null, // workaround for #2317
  7992. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  7993. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  7994. // No disabled and non-accepted
  7995. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  7996. continue;
  7997. }
  7998. // Filter out elements in the current dragged item
  7999. for ( j = 0; j < list.length; j++ ) {
  8000. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  8001. m[ i ].proportions().height = 0;
  8002. continue droppablesLoop;
  8003. }
  8004. }
  8005. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  8006. if ( !m[ i ].visible ) {
  8007. continue;
  8008. }
  8009. // Activate the droppable if used directly from draggables
  8010. if ( type === "mousedown" ) {
  8011. m[ i ]._activate.call( m[ i ], event );
  8012. }
  8013. m[ i ].offset = m[ i ].element.offset();
  8014. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  8015. }
  8016. },
  8017. drop: function( draggable, event ) {
  8018. var dropped = false;
  8019. // Create a copy of the droppables in case the list changes during the drop (#9116)
  8020. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  8021. if ( !this.options ) {
  8022. return;
  8023. }
  8024. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  8025. dropped = this._drop.call( this, event ) || dropped;
  8026. }
  8027. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  8028. this.isout = true;
  8029. this.isover = false;
  8030. this._deactivate.call( this, event );
  8031. }
  8032. });
  8033. return dropped;
  8034. },
  8035. dragStart: function( draggable, event ) {
  8036. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  8037. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  8038. if ( !draggable.options.refreshPositions ) {
  8039. $.ui.ddmanager.prepareOffsets( draggable, event );
  8040. }
  8041. });
  8042. },
  8043. drag: function( draggable, event ) {
  8044. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  8045. if ( draggable.options.refreshPositions ) {
  8046. $.ui.ddmanager.prepareOffsets( draggable, event );
  8047. }
  8048. // Run through all droppables and check their positions based on specific tolerance options
  8049. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  8050. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  8051. return;
  8052. }
  8053. var parentInstance, scope, parent,
  8054. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  8055. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  8056. if ( !c ) {
  8057. return;
  8058. }
  8059. if ( this.options.greedy ) {
  8060. // find droppable parents with same scope
  8061. scope = this.options.scope;
  8062. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  8063. return $( this ).droppable( "instance" ).options.scope === scope;
  8064. });
  8065. if ( parent.length ) {
  8066. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  8067. parentInstance.greedyChild = ( c === "isover" );
  8068. }
  8069. }
  8070. // we just moved into a greedy child
  8071. if ( parentInstance && c === "isover" ) {
  8072. parentInstance.isover = false;
  8073. parentInstance.isout = true;
  8074. parentInstance._out.call( parentInstance, event );
  8075. }
  8076. this[ c ] = true;
  8077. this[c === "isout" ? "isover" : "isout"] = false;
  8078. this[c === "isover" ? "_over" : "_out"].call( this, event );
  8079. // we just moved out of a greedy child
  8080. if ( parentInstance && c === "isout" ) {
  8081. parentInstance.isout = false;
  8082. parentInstance.isover = true;
  8083. parentInstance._over.call( parentInstance, event );
  8084. }
  8085. });
  8086. },
  8087. dragStop: function( draggable, event ) {
  8088. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  8089. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  8090. if ( !draggable.options.refreshPositions ) {
  8091. $.ui.ddmanager.prepareOffsets( draggable, event );
  8092. }
  8093. }
  8094. };
  8095. var droppable = $.ui.droppable;
  8096. /*!
  8097. * jQuery UI Effects 1.11.4
  8098. * http://jqueryui.com
  8099. *
  8100. * Copyright jQuery Foundation and other contributors
  8101. * Released under the MIT license.
  8102. * http://jquery.org/license
  8103. *
  8104. * http://api.jqueryui.com/category/effects-core/
  8105. */
  8106. var dataSpace = "ui-effects-",
  8107. // Create a local jQuery because jQuery Color relies on it and the
  8108. // global may not exist with AMD and a custom build (#10199)
  8109. jQuery = $;
  8110. $.effects = {
  8111. effect: {}
  8112. };
  8113. /*!
  8114. * jQuery Color Animations v2.1.2
  8115. * https://github.com/jquery/jquery-color
  8116. *
  8117. * Copyright 2014 jQuery Foundation and other contributors
  8118. * Released under the MIT license.
  8119. * http://jquery.org/license
  8120. *
  8121. * Date: Wed Jan 16 08:47:09 2013 -0600
  8122. */
  8123. (function( jQuery, undefined ) {
  8124. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  8125. // plusequals test for += 100 -= 100
  8126. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  8127. // a set of RE's that can match strings and generate color tuples.
  8128. stringParsers = [ {
  8129. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8130. parse: function( execResult ) {
  8131. return [
  8132. execResult[ 1 ],
  8133. execResult[ 2 ],
  8134. execResult[ 3 ],
  8135. execResult[ 4 ]
  8136. ];
  8137. }
  8138. }, {
  8139. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8140. parse: function( execResult ) {
  8141. return [
  8142. execResult[ 1 ] * 2.55,
  8143. execResult[ 2 ] * 2.55,
  8144. execResult[ 3 ] * 2.55,
  8145. execResult[ 4 ]
  8146. ];
  8147. }
  8148. }, {
  8149. // this regex ignores A-F because it's compared against an already lowercased string
  8150. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  8151. parse: function( execResult ) {
  8152. return [
  8153. parseInt( execResult[ 1 ], 16 ),
  8154. parseInt( execResult[ 2 ], 16 ),
  8155. parseInt( execResult[ 3 ], 16 )
  8156. ];
  8157. }
  8158. }, {
  8159. // this regex ignores A-F because it's compared against an already lowercased string
  8160. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  8161. parse: function( execResult ) {
  8162. return [
  8163. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  8164. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  8165. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  8166. ];
  8167. }
  8168. }, {
  8169. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8170. space: "hsla",
  8171. parse: function( execResult ) {
  8172. return [
  8173. execResult[ 1 ],
  8174. execResult[ 2 ] / 100,
  8175. execResult[ 3 ] / 100,
  8176. execResult[ 4 ]
  8177. ];
  8178. }
  8179. } ],
  8180. // jQuery.Color( )
  8181. color = jQuery.Color = function( color, green, blue, alpha ) {
  8182. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  8183. },
  8184. spaces = {
  8185. rgba: {
  8186. props: {
  8187. red: {
  8188. idx: 0,
  8189. type: "byte"
  8190. },
  8191. green: {
  8192. idx: 1,
  8193. type: "byte"
  8194. },
  8195. blue: {
  8196. idx: 2,
  8197. type: "byte"
  8198. }
  8199. }
  8200. },
  8201. hsla: {
  8202. props: {
  8203. hue: {
  8204. idx: 0,
  8205. type: "degrees"
  8206. },
  8207. saturation: {
  8208. idx: 1,
  8209. type: "percent"
  8210. },
  8211. lightness: {
  8212. idx: 2,
  8213. type: "percent"
  8214. }
  8215. }
  8216. }
  8217. },
  8218. propTypes = {
  8219. "byte": {
  8220. floor: true,
  8221. max: 255
  8222. },
  8223. "percent": {
  8224. max: 1
  8225. },
  8226. "degrees": {
  8227. mod: 360,
  8228. floor: true
  8229. }
  8230. },
  8231. support = color.support = {},
  8232. // element for support tests
  8233. supportElem = jQuery( "<p>" )[ 0 ],
  8234. // colors = jQuery.Color.names
  8235. colors,
  8236. // local aliases of functions called often
  8237. each = jQuery.each;
  8238. // determine rgba support immediately
  8239. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  8240. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  8241. // define cache name and alpha properties
  8242. // for rgba and hsla spaces
  8243. each( spaces, function( spaceName, space ) {
  8244. space.cache = "_" + spaceName;
  8245. space.props.alpha = {
  8246. idx: 3,
  8247. type: "percent",
  8248. def: 1
  8249. };
  8250. });
  8251. function clamp( value, prop, allowEmpty ) {
  8252. var type = propTypes[ prop.type ] || {};
  8253. if ( value == null ) {
  8254. return (allowEmpty || !prop.def) ? null : prop.def;
  8255. }
  8256. // ~~ is an short way of doing floor for positive numbers
  8257. value = type.floor ? ~~value : parseFloat( value );
  8258. // IE will pass in empty strings as value for alpha,
  8259. // which will hit this case
  8260. if ( isNaN( value ) ) {
  8261. return prop.def;
  8262. }
  8263. if ( type.mod ) {
  8264. // we add mod before modding to make sure that negatives values
  8265. // get converted properly: -10 -> 350
  8266. return (value + type.mod) % type.mod;
  8267. }
  8268. // for now all property types without mod have min and max
  8269. return 0 > value ? 0 : type.max < value ? type.max : value;
  8270. }
  8271. function stringParse( string ) {
  8272. var inst = color(),
  8273. rgba = inst._rgba = [];
  8274. string = string.toLowerCase();
  8275. each( stringParsers, function( i, parser ) {
  8276. var parsed,
  8277. match = parser.re.exec( string ),
  8278. values = match && parser.parse( match ),
  8279. spaceName = parser.space || "rgba";
  8280. if ( values ) {
  8281. parsed = inst[ spaceName ]( values );
  8282. // if this was an rgba parse the assignment might happen twice
  8283. // oh well....
  8284. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  8285. rgba = inst._rgba = parsed._rgba;
  8286. // exit each( stringParsers ) here because we matched
  8287. return false;
  8288. }
  8289. });
  8290. // Found a stringParser that handled it
  8291. if ( rgba.length ) {
  8292. // if this came from a parsed string, force "transparent" when alpha is 0
  8293. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  8294. if ( rgba.join() === "0,0,0,0" ) {
  8295. jQuery.extend( rgba, colors.transparent );
  8296. }
  8297. return inst;
  8298. }
  8299. // named colors
  8300. return colors[ string ];
  8301. }
  8302. color.fn = jQuery.extend( color.prototype, {
  8303. parse: function( red, green, blue, alpha ) {
  8304. if ( red === undefined ) {
  8305. this._rgba = [ null, null, null, null ];
  8306. return this;
  8307. }
  8308. if ( red.jquery || red.nodeType ) {
  8309. red = jQuery( red ).css( green );
  8310. green = undefined;
  8311. }
  8312. var inst = this,
  8313. type = jQuery.type( red ),
  8314. rgba = this._rgba = [];
  8315. // more than 1 argument specified - assume ( red, green, blue, alpha )
  8316. if ( green !== undefined ) {
  8317. red = [ red, green, blue, alpha ];
  8318. type = "array";
  8319. }
  8320. if ( type === "string" ) {
  8321. return this.parse( stringParse( red ) || colors._default );
  8322. }
  8323. if ( type === "array" ) {
  8324. each( spaces.rgba.props, function( key, prop ) {
  8325. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  8326. });
  8327. return this;
  8328. }
  8329. if ( type === "object" ) {
  8330. if ( red instanceof color ) {
  8331. each( spaces, function( spaceName, space ) {
  8332. if ( red[ space.cache ] ) {
  8333. inst[ space.cache ] = red[ space.cache ].slice();
  8334. }
  8335. });
  8336. } else {
  8337. each( spaces, function( spaceName, space ) {
  8338. var cache = space.cache;
  8339. each( space.props, function( key, prop ) {
  8340. // if the cache doesn't exist, and we know how to convert
  8341. if ( !inst[ cache ] && space.to ) {
  8342. // if the value was null, we don't need to copy it
  8343. // if the key was alpha, we don't need to copy it either
  8344. if ( key === "alpha" || red[ key ] == null ) {
  8345. return;
  8346. }
  8347. inst[ cache ] = space.to( inst._rgba );
  8348. }
  8349. // this is the only case where we allow nulls for ALL properties.
  8350. // call clamp with alwaysAllowEmpty
  8351. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  8352. });
  8353. // everything defined but alpha?
  8354. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  8355. // use the default of 1
  8356. inst[ cache ][ 3 ] = 1;
  8357. if ( space.from ) {
  8358. inst._rgba = space.from( inst[ cache ] );
  8359. }
  8360. }
  8361. });
  8362. }
  8363. return this;
  8364. }
  8365. },
  8366. is: function( compare ) {
  8367. var is = color( compare ),
  8368. same = true,
  8369. inst = this;
  8370. each( spaces, function( _, space ) {
  8371. var localCache,
  8372. isCache = is[ space.cache ];
  8373. if (isCache) {
  8374. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  8375. each( space.props, function( _, prop ) {
  8376. if ( isCache[ prop.idx ] != null ) {
  8377. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  8378. return same;
  8379. }
  8380. });
  8381. }
  8382. return same;
  8383. });
  8384. return same;
  8385. },
  8386. _space: function() {
  8387. var used = [],
  8388. inst = this;
  8389. each( spaces, function( spaceName, space ) {
  8390. if ( inst[ space.cache ] ) {
  8391. used.push( spaceName );
  8392. }
  8393. });
  8394. return used.pop();
  8395. },
  8396. transition: function( other, distance ) {
  8397. var end = color( other ),
  8398. spaceName = end._space(),
  8399. space = spaces[ spaceName ],
  8400. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  8401. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  8402. result = start.slice();
  8403. end = end[ space.cache ];
  8404. each( space.props, function( key, prop ) {
  8405. var index = prop.idx,
  8406. startValue = start[ index ],
  8407. endValue = end[ index ],
  8408. type = propTypes[ prop.type ] || {};
  8409. // if null, don't override start value
  8410. if ( endValue === null ) {
  8411. return;
  8412. }
  8413. // if null - use end
  8414. if ( startValue === null ) {
  8415. result[ index ] = endValue;
  8416. } else {
  8417. if ( type.mod ) {
  8418. if ( endValue - startValue > type.mod / 2 ) {
  8419. startValue += type.mod;
  8420. } else if ( startValue - endValue > type.mod / 2 ) {
  8421. startValue -= type.mod;
  8422. }
  8423. }
  8424. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  8425. }
  8426. });
  8427. return this[ spaceName ]( result );
  8428. },
  8429. blend: function( opaque ) {
  8430. // if we are already opaque - return ourself
  8431. if ( this._rgba[ 3 ] === 1 ) {
  8432. return this;
  8433. }
  8434. var rgb = this._rgba.slice(),
  8435. a = rgb.pop(),
  8436. blend = color( opaque )._rgba;
  8437. return color( jQuery.map( rgb, function( v, i ) {
  8438. return ( 1 - a ) * blend[ i ] + a * v;
  8439. }));
  8440. },
  8441. toRgbaString: function() {
  8442. var prefix = "rgba(",
  8443. rgba = jQuery.map( this._rgba, function( v, i ) {
  8444. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  8445. });
  8446. if ( rgba[ 3 ] === 1 ) {
  8447. rgba.pop();
  8448. prefix = "rgb(";
  8449. }
  8450. return prefix + rgba.join() + ")";
  8451. },
  8452. toHslaString: function() {
  8453. var prefix = "hsla(",
  8454. hsla = jQuery.map( this.hsla(), function( v, i ) {
  8455. if ( v == null ) {
  8456. v = i > 2 ? 1 : 0;
  8457. }
  8458. // catch 1 and 2
  8459. if ( i && i < 3 ) {
  8460. v = Math.round( v * 100 ) + "%";
  8461. }
  8462. return v;
  8463. });
  8464. if ( hsla[ 3 ] === 1 ) {
  8465. hsla.pop();
  8466. prefix = "hsl(";
  8467. }
  8468. return prefix + hsla.join() + ")";
  8469. },
  8470. toHexString: function( includeAlpha ) {
  8471. var rgba = this._rgba.slice(),
  8472. alpha = rgba.pop();
  8473. if ( includeAlpha ) {
  8474. rgba.push( ~~( alpha * 255 ) );
  8475. }
  8476. return "#" + jQuery.map( rgba, function( v ) {
  8477. // default to 0 when nulls exist
  8478. v = ( v || 0 ).toString( 16 );
  8479. return v.length === 1 ? "0" + v : v;
  8480. }).join("");
  8481. },
  8482. toString: function() {
  8483. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  8484. }
  8485. });
  8486. color.fn.parse.prototype = color.fn;
  8487. // hsla conversions adapted from:
  8488. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  8489. function hue2rgb( p, q, h ) {
  8490. h = ( h + 1 ) % 1;
  8491. if ( h * 6 < 1 ) {
  8492. return p + ( q - p ) * h * 6;
  8493. }
  8494. if ( h * 2 < 1) {
  8495. return q;
  8496. }
  8497. if ( h * 3 < 2 ) {
  8498. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  8499. }
  8500. return p;
  8501. }
  8502. spaces.hsla.to = function( rgba ) {
  8503. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  8504. return [ null, null, null, rgba[ 3 ] ];
  8505. }
  8506. var r = rgba[ 0 ] / 255,
  8507. g = rgba[ 1 ] / 255,
  8508. b = rgba[ 2 ] / 255,
  8509. a = rgba[ 3 ],
  8510. max = Math.max( r, g, b ),
  8511. min = Math.min( r, g, b ),
  8512. diff = max - min,
  8513. add = max + min,
  8514. l = add * 0.5,
  8515. h, s;
  8516. if ( min === max ) {
  8517. h = 0;
  8518. } else if ( r === max ) {
  8519. h = ( 60 * ( g - b ) / diff ) + 360;
  8520. } else if ( g === max ) {
  8521. h = ( 60 * ( b - r ) / diff ) + 120;
  8522. } else {
  8523. h = ( 60 * ( r - g ) / diff ) + 240;
  8524. }
  8525. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  8526. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  8527. if ( diff === 0 ) {
  8528. s = 0;
  8529. } else if ( l <= 0.5 ) {
  8530. s = diff / add;
  8531. } else {
  8532. s = diff / ( 2 - add );
  8533. }
  8534. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  8535. };
  8536. spaces.hsla.from = function( hsla ) {
  8537. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  8538. return [ null, null, null, hsla[ 3 ] ];
  8539. }
  8540. var h = hsla[ 0 ] / 360,
  8541. s = hsla[ 1 ],
  8542. l = hsla[ 2 ],
  8543. a = hsla[ 3 ],
  8544. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  8545. p = 2 * l - q;
  8546. return [
  8547. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  8548. Math.round( hue2rgb( p, q, h ) * 255 ),
  8549. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  8550. a
  8551. ];
  8552. };
  8553. each( spaces, function( spaceName, space ) {
  8554. var props = space.props,
  8555. cache = space.cache,
  8556. to = space.to,
  8557. from = space.from;
  8558. // makes rgba() and hsla()
  8559. color.fn[ spaceName ] = function( value ) {
  8560. // generate a cache for this space if it doesn't exist
  8561. if ( to && !this[ cache ] ) {
  8562. this[ cache ] = to( this._rgba );
  8563. }
  8564. if ( value === undefined ) {
  8565. return this[ cache ].slice();
  8566. }
  8567. var ret,
  8568. type = jQuery.type( value ),
  8569. arr = ( type === "array" || type === "object" ) ? value : arguments,
  8570. local = this[ cache ].slice();
  8571. each( props, function( key, prop ) {
  8572. var val = arr[ type === "object" ? key : prop.idx ];
  8573. if ( val == null ) {
  8574. val = local[ prop.idx ];
  8575. }
  8576. local[ prop.idx ] = clamp( val, prop );
  8577. });
  8578. if ( from ) {
  8579. ret = color( from( local ) );
  8580. ret[ cache ] = local;
  8581. return ret;
  8582. } else {
  8583. return color( local );
  8584. }
  8585. };
  8586. // makes red() green() blue() alpha() hue() saturation() lightness()
  8587. each( props, function( key, prop ) {
  8588. // alpha is included in more than one space
  8589. if ( color.fn[ key ] ) {
  8590. return;
  8591. }
  8592. color.fn[ key ] = function( value ) {
  8593. var vtype = jQuery.type( value ),
  8594. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  8595. local = this[ fn ](),
  8596. cur = local[ prop.idx ],
  8597. match;
  8598. if ( vtype === "undefined" ) {
  8599. return cur;
  8600. }
  8601. if ( vtype === "function" ) {
  8602. value = value.call( this, cur );
  8603. vtype = jQuery.type( value );
  8604. }
  8605. if ( value == null && prop.empty ) {
  8606. return this;
  8607. }
  8608. if ( vtype === "string" ) {
  8609. match = rplusequals.exec( value );
  8610. if ( match ) {
  8611. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  8612. }
  8613. }
  8614. local[ prop.idx ] = value;
  8615. return this[ fn ]( local );
  8616. };
  8617. });
  8618. });
  8619. // add cssHook and .fx.step function for each named hook.
  8620. // accept a space separated string of properties
  8621. color.hook = function( hook ) {
  8622. var hooks = hook.split( " " );
  8623. each( hooks, function( i, hook ) {
  8624. jQuery.cssHooks[ hook ] = {
  8625. set: function( elem, value ) {
  8626. var parsed, curElem,
  8627. backgroundColor = "";
  8628. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  8629. value = color( parsed || value );
  8630. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  8631. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  8632. while (
  8633. (backgroundColor === "" || backgroundColor === "transparent") &&
  8634. curElem && curElem.style
  8635. ) {
  8636. try {
  8637. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  8638. curElem = curElem.parentNode;
  8639. } catch ( e ) {
  8640. }
  8641. }
  8642. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  8643. backgroundColor :
  8644. "_default" );
  8645. }
  8646. value = value.toRgbaString();
  8647. }
  8648. try {
  8649. elem.style[ hook ] = value;
  8650. } catch ( e ) {
  8651. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  8652. }
  8653. }
  8654. };
  8655. jQuery.fx.step[ hook ] = function( fx ) {
  8656. if ( !fx.colorInit ) {
  8657. fx.start = color( fx.elem, hook );
  8658. fx.end = color( fx.end );
  8659. fx.colorInit = true;
  8660. }
  8661. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  8662. };
  8663. });
  8664. };
  8665. color.hook( stepHooks );
  8666. jQuery.cssHooks.borderColor = {
  8667. expand: function( value ) {
  8668. var expanded = {};
  8669. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  8670. expanded[ "border" + part + "Color" ] = value;
  8671. });
  8672. return expanded;
  8673. }
  8674. };
  8675. // Basic color names only.
  8676. // Usage of any of the other color names requires adding yourself or including
  8677. // jquery.color.svg-names.js.
  8678. colors = jQuery.Color.names = {
  8679. // 4.1. Basic color keywords
  8680. aqua: "#00ffff",
  8681. black: "#000000",
  8682. blue: "#0000ff",
  8683. fuchsia: "#ff00ff",
  8684. gray: "#808080",
  8685. green: "#008000",
  8686. lime: "#00ff00",
  8687. maroon: "#800000",
  8688. navy: "#000080",
  8689. olive: "#808000",
  8690. purple: "#800080",
  8691. red: "#ff0000",
  8692. silver: "#c0c0c0",
  8693. teal: "#008080",
  8694. white: "#ffffff",
  8695. yellow: "#ffff00",
  8696. // 4.2.3. "transparent" color keyword
  8697. transparent: [ null, null, null, 0 ],
  8698. _default: "#ffffff"
  8699. };
  8700. })( jQuery );
  8701. /******************************************************************************/
  8702. /****************************** CLASS ANIMATIONS ******************************/
  8703. /******************************************************************************/
  8704. (function() {
  8705. var classAnimationActions = [ "add", "remove", "toggle" ],
  8706. shorthandStyles = {
  8707. border: 1,
  8708. borderBottom: 1,
  8709. borderColor: 1,
  8710. borderLeft: 1,
  8711. borderRight: 1,
  8712. borderTop: 1,
  8713. borderWidth: 1,
  8714. margin: 1,
  8715. padding: 1
  8716. };
  8717. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  8718. $.fx.step[ prop ] = function( fx ) {
  8719. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  8720. jQuery.style( fx.elem, prop, fx.end );
  8721. fx.setAttr = true;
  8722. }
  8723. };
  8724. });
  8725. function getElementStyles( elem ) {
  8726. var key, len,
  8727. style = elem.ownerDocument.defaultView ?
  8728. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  8729. elem.currentStyle,
  8730. styles = {};
  8731. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  8732. len = style.length;
  8733. while ( len-- ) {
  8734. key = style[ len ];
  8735. if ( typeof style[ key ] === "string" ) {
  8736. styles[ $.camelCase( key ) ] = style[ key ];
  8737. }
  8738. }
  8739. // support: Opera, IE <9
  8740. } else {
  8741. for ( key in style ) {
  8742. if ( typeof style[ key ] === "string" ) {
  8743. styles[ key ] = style[ key ];
  8744. }
  8745. }
  8746. }
  8747. return styles;
  8748. }
  8749. function styleDifference( oldStyle, newStyle ) {
  8750. var diff = {},
  8751. name, value;
  8752. for ( name in newStyle ) {
  8753. value = newStyle[ name ];
  8754. if ( oldStyle[ name ] !== value ) {
  8755. if ( !shorthandStyles[ name ] ) {
  8756. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  8757. diff[ name ] = value;
  8758. }
  8759. }
  8760. }
  8761. }
  8762. return diff;
  8763. }
  8764. // support: jQuery <1.8
  8765. if ( !$.fn.addBack ) {
  8766. $.fn.addBack = function( selector ) {
  8767. return this.add( selector == null ?
  8768. this.prevObject : this.prevObject.filter( selector )
  8769. );
  8770. };
  8771. }
  8772. $.effects.animateClass = function( value, duration, easing, callback ) {
  8773. var o = $.speed( duration, easing, callback );
  8774. return this.queue( function() {
  8775. var animated = $( this ),
  8776. baseClass = animated.attr( "class" ) || "",
  8777. applyClassChange,
  8778. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  8779. // map the animated objects to store the original styles.
  8780. allAnimations = allAnimations.map(function() {
  8781. var el = $( this );
  8782. return {
  8783. el: el,
  8784. start: getElementStyles( this )
  8785. };
  8786. });
  8787. // apply class change
  8788. applyClassChange = function() {
  8789. $.each( classAnimationActions, function(i, action) {
  8790. if ( value[ action ] ) {
  8791. animated[ action + "Class" ]( value[ action ] );
  8792. }
  8793. });
  8794. };
  8795. applyClassChange();
  8796. // map all animated objects again - calculate new styles and diff
  8797. allAnimations = allAnimations.map(function() {
  8798. this.end = getElementStyles( this.el[ 0 ] );
  8799. this.diff = styleDifference( this.start, this.end );
  8800. return this;
  8801. });
  8802. // apply original class
  8803. animated.attr( "class", baseClass );
  8804. // map all animated objects again - this time collecting a promise
  8805. allAnimations = allAnimations.map(function() {
  8806. var styleInfo = this,
  8807. dfd = $.Deferred(),
  8808. opts = $.extend({}, o, {
  8809. queue: false,
  8810. complete: function() {
  8811. dfd.resolve( styleInfo );
  8812. }
  8813. });
  8814. this.el.animate( this.diff, opts );
  8815. return dfd.promise();
  8816. });
  8817. // once all animations have completed:
  8818. $.when.apply( $, allAnimations.get() ).done(function() {
  8819. // set the final class
  8820. applyClassChange();
  8821. // for each animated element,
  8822. // clear all css properties that were animated
  8823. $.each( arguments, function() {
  8824. var el = this.el;
  8825. $.each( this.diff, function(key) {
  8826. el.css( key, "" );
  8827. });
  8828. });
  8829. // this is guarnteed to be there if you use jQuery.speed()
  8830. // it also handles dequeuing the next anim...
  8831. o.complete.call( animated[ 0 ] );
  8832. });
  8833. });
  8834. };
  8835. $.fn.extend({
  8836. addClass: (function( orig ) {
  8837. return function( classNames, speed, easing, callback ) {
  8838. return speed ?
  8839. $.effects.animateClass.call( this,
  8840. { add: classNames }, speed, easing, callback ) :
  8841. orig.apply( this, arguments );
  8842. };
  8843. })( $.fn.addClass ),
  8844. removeClass: (function( orig ) {
  8845. return function( classNames, speed, easing, callback ) {
  8846. return arguments.length > 1 ?
  8847. $.effects.animateClass.call( this,
  8848. { remove: classNames }, speed, easing, callback ) :
  8849. orig.apply( this, arguments );
  8850. };
  8851. })( $.fn.removeClass ),
  8852. toggleClass: (function( orig ) {
  8853. return function( classNames, force, speed, easing, callback ) {
  8854. if ( typeof force === "boolean" || force === undefined ) {
  8855. if ( !speed ) {
  8856. // without speed parameter
  8857. return orig.apply( this, arguments );
  8858. } else {
  8859. return $.effects.animateClass.call( this,
  8860. (force ? { add: classNames } : { remove: classNames }),
  8861. speed, easing, callback );
  8862. }
  8863. } else {
  8864. // without force parameter
  8865. return $.effects.animateClass.call( this,
  8866. { toggle: classNames }, force, speed, easing );
  8867. }
  8868. };
  8869. })( $.fn.toggleClass ),
  8870. switchClass: function( remove, add, speed, easing, callback) {
  8871. return $.effects.animateClass.call( this, {
  8872. add: add,
  8873. remove: remove
  8874. }, speed, easing, callback );
  8875. }
  8876. });
  8877. })();
  8878. /******************************************************************************/
  8879. /*********************************** EFFECTS **********************************/
  8880. /******************************************************************************/
  8881. (function() {
  8882. $.extend( $.effects, {
  8883. version: "1.11.4",
  8884. // Saves a set of properties in a data storage
  8885. save: function( element, set ) {
  8886. for ( var i = 0; i < set.length; i++ ) {
  8887. if ( set[ i ] !== null ) {
  8888. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  8889. }
  8890. }
  8891. },
  8892. // Restores a set of previously saved properties from a data storage
  8893. restore: function( element, set ) {
  8894. var val, i;
  8895. for ( i = 0; i < set.length; i++ ) {
  8896. if ( set[ i ] !== null ) {
  8897. val = element.data( dataSpace + set[ i ] );
  8898. // support: jQuery 1.6.2
  8899. // http://bugs.jquery.com/ticket/9917
  8900. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  8901. // We can't differentiate between "" and 0 here, so we just assume
  8902. // empty string since it's likely to be a more common value...
  8903. if ( val === undefined ) {
  8904. val = "";
  8905. }
  8906. element.css( set[ i ], val );
  8907. }
  8908. }
  8909. },
  8910. setMode: function( el, mode ) {
  8911. if (mode === "toggle") {
  8912. mode = el.is( ":hidden" ) ? "show" : "hide";
  8913. }
  8914. return mode;
  8915. },
  8916. // Translates a [top,left] array into a baseline value
  8917. // this should be a little more flexible in the future to handle a string & hash
  8918. getBaseline: function( origin, original ) {
  8919. var y, x;
  8920. switch ( origin[ 0 ] ) {
  8921. case "top": y = 0; break;
  8922. case "middle": y = 0.5; break;
  8923. case "bottom": y = 1; break;
  8924. default: y = origin[ 0 ] / original.height;
  8925. }
  8926. switch ( origin[ 1 ] ) {
  8927. case "left": x = 0; break;
  8928. case "center": x = 0.5; break;
  8929. case "right": x = 1; break;
  8930. default: x = origin[ 1 ] / original.width;
  8931. }
  8932. return {
  8933. x: x,
  8934. y: y
  8935. };
  8936. },
  8937. // Wraps the element around a wrapper that copies position properties
  8938. createWrapper: function( element ) {
  8939. // if the element is already wrapped, return it
  8940. if ( element.parent().is( ".ui-effects-wrapper" )) {
  8941. return element.parent();
  8942. }
  8943. // wrap the element
  8944. var props = {
  8945. width: element.outerWidth(true),
  8946. height: element.outerHeight(true),
  8947. "float": element.css( "float" )
  8948. },
  8949. wrapper = $( "<div></div>" )
  8950. .addClass( "ui-effects-wrapper" )
  8951. .css({
  8952. fontSize: "100%",
  8953. background: "transparent",
  8954. border: "none",
  8955. margin: 0,
  8956. padding: 0
  8957. }),
  8958. // Store the size in case width/height are defined in % - Fixes #5245
  8959. size = {
  8960. width: element.width(),
  8961. height: element.height()
  8962. },
  8963. active = document.activeElement;
  8964. // support: Firefox
  8965. // Firefox incorrectly exposes anonymous content
  8966. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  8967. try {
  8968. active.id;
  8969. } catch ( e ) {
  8970. active = document.body;
  8971. }
  8972. element.wrap( wrapper );
  8973. // Fixes #7595 - Elements lose focus when wrapped.
  8974. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  8975. $( active ).focus();
  8976. }
  8977. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  8978. // transfer positioning properties to the wrapper
  8979. if ( element.css( "position" ) === "static" ) {
  8980. wrapper.css({ position: "relative" });
  8981. element.css({ position: "relative" });
  8982. } else {
  8983. $.extend( props, {
  8984. position: element.css( "position" ),
  8985. zIndex: element.css( "z-index" )
  8986. });
  8987. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  8988. props[ pos ] = element.css( pos );
  8989. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  8990. props[ pos ] = "auto";
  8991. }
  8992. });
  8993. element.css({
  8994. position: "relative",
  8995. top: 0,
  8996. left: 0,
  8997. right: "auto",
  8998. bottom: "auto"
  8999. });
  9000. }
  9001. element.css(size);
  9002. return wrapper.css( props ).show();
  9003. },
  9004. removeWrapper: function( element ) {
  9005. var active = document.activeElement;
  9006. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  9007. element.parent().replaceWith( element );
  9008. // Fixes #7595 - Elements lose focus when wrapped.
  9009. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  9010. $( active ).focus();
  9011. }
  9012. }
  9013. return element;
  9014. },
  9015. setTransition: function( element, list, factor, value ) {
  9016. value = value || {};
  9017. $.each( list, function( i, x ) {
  9018. var unit = element.cssUnit( x );
  9019. if ( unit[ 0 ] > 0 ) {
  9020. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  9021. }
  9022. });
  9023. return value;
  9024. }
  9025. });
  9026. // return an effect options object for the given parameters:
  9027. function _normalizeArguments( effect, options, speed, callback ) {
  9028. // allow passing all options as the first parameter
  9029. if ( $.isPlainObject( effect ) ) {
  9030. options = effect;
  9031. effect = effect.effect;
  9032. }
  9033. // convert to an object
  9034. effect = { effect: effect };
  9035. // catch (effect, null, ...)
  9036. if ( options == null ) {
  9037. options = {};
  9038. }
  9039. // catch (effect, callback)
  9040. if ( $.isFunction( options ) ) {
  9041. callback = options;
  9042. speed = null;
  9043. options = {};
  9044. }
  9045. // catch (effect, speed, ?)
  9046. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  9047. callback = speed;
  9048. speed = options;
  9049. options = {};
  9050. }
  9051. // catch (effect, options, callback)
  9052. if ( $.isFunction( speed ) ) {
  9053. callback = speed;
  9054. speed = null;
  9055. }
  9056. // add options to effect
  9057. if ( options ) {
  9058. $.extend( effect, options );
  9059. }
  9060. speed = speed || options.duration;
  9061. effect.duration = $.fx.off ? 0 :
  9062. typeof speed === "number" ? speed :
  9063. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  9064. $.fx.speeds._default;
  9065. effect.complete = callback || options.complete;
  9066. return effect;
  9067. }
  9068. function standardAnimationOption( option ) {
  9069. // Valid standard speeds (nothing, number, named speed)
  9070. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  9071. return true;
  9072. }
  9073. // Invalid strings - treat as "normal" speed
  9074. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  9075. return true;
  9076. }
  9077. // Complete callback
  9078. if ( $.isFunction( option ) ) {
  9079. return true;
  9080. }
  9081. // Options hash (but not naming an effect)
  9082. if ( typeof option === "object" && !option.effect ) {
  9083. return true;
  9084. }
  9085. // Didn't match any standard API
  9086. return false;
  9087. }
  9088. $.fn.extend({
  9089. effect: function( /* effect, options, speed, callback */ ) {
  9090. var args = _normalizeArguments.apply( this, arguments ),
  9091. mode = args.mode,
  9092. queue = args.queue,
  9093. effectMethod = $.effects.effect[ args.effect ];
  9094. if ( $.fx.off || !effectMethod ) {
  9095. // delegate to the original method (e.g., .show()) if possible
  9096. if ( mode ) {
  9097. return this[ mode ]( args.duration, args.complete );
  9098. } else {
  9099. return this.each( function() {
  9100. if ( args.complete ) {
  9101. args.complete.call( this );
  9102. }
  9103. });
  9104. }
  9105. }
  9106. function run( next ) {
  9107. var elem = $( this ),
  9108. complete = args.complete,
  9109. mode = args.mode;
  9110. function done() {
  9111. if ( $.isFunction( complete ) ) {
  9112. complete.call( elem[0] );
  9113. }
  9114. if ( $.isFunction( next ) ) {
  9115. next();
  9116. }
  9117. }
  9118. // If the element already has the correct final state, delegate to
  9119. // the core methods so the internal tracking of "olddisplay" works.
  9120. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  9121. elem[ mode ]();
  9122. done();
  9123. } else {
  9124. effectMethod.call( elem[0], args, done );
  9125. }
  9126. }
  9127. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  9128. },
  9129. show: (function( orig ) {
  9130. return function( option ) {
  9131. if ( standardAnimationOption( option ) ) {
  9132. return orig.apply( this, arguments );
  9133. } else {
  9134. var args = _normalizeArguments.apply( this, arguments );
  9135. args.mode = "show";
  9136. return this.effect.call( this, args );
  9137. }
  9138. };
  9139. })( $.fn.show ),
  9140. hide: (function( orig ) {
  9141. return function( option ) {
  9142. if ( standardAnimationOption( option ) ) {
  9143. return orig.apply( this, arguments );
  9144. } else {
  9145. var args = _normalizeArguments.apply( this, arguments );
  9146. args.mode = "hide";
  9147. return this.effect.call( this, args );
  9148. }
  9149. };
  9150. })( $.fn.hide ),
  9151. toggle: (function( orig ) {
  9152. return function( option ) {
  9153. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  9154. return orig.apply( this, arguments );
  9155. } else {
  9156. var args = _normalizeArguments.apply( this, arguments );
  9157. args.mode = "toggle";
  9158. return this.effect.call( this, args );
  9159. }
  9160. };
  9161. })( $.fn.toggle ),
  9162. // helper functions
  9163. cssUnit: function(key) {
  9164. var style = this.css( key ),
  9165. val = [];
  9166. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  9167. if ( style.indexOf( unit ) > 0 ) {
  9168. val = [ parseFloat( style ), unit ];
  9169. }
  9170. });
  9171. return val;
  9172. }
  9173. });
  9174. })();
  9175. /******************************************************************************/
  9176. /*********************************** EASING ***********************************/
  9177. /******************************************************************************/
  9178. (function() {
  9179. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  9180. var baseEasings = {};
  9181. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  9182. baseEasings[ name ] = function( p ) {
  9183. return Math.pow( p, i + 2 );
  9184. };
  9185. });
  9186. $.extend( baseEasings, {
  9187. Sine: function( p ) {
  9188. return 1 - Math.cos( p * Math.PI / 2 );
  9189. },
  9190. Circ: function( p ) {
  9191. return 1 - Math.sqrt( 1 - p * p );
  9192. },
  9193. Elastic: function( p ) {
  9194. return p === 0 || p === 1 ? p :
  9195. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  9196. },
  9197. Back: function( p ) {
  9198. return p * p * ( 3 * p - 2 );
  9199. },
  9200. Bounce: function( p ) {
  9201. var pow2,
  9202. bounce = 4;
  9203. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  9204. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  9205. }
  9206. });
  9207. $.each( baseEasings, function( name, easeIn ) {
  9208. $.easing[ "easeIn" + name ] = easeIn;
  9209. $.easing[ "easeOut" + name ] = function( p ) {
  9210. return 1 - easeIn( 1 - p );
  9211. };
  9212. $.easing[ "easeInOut" + name ] = function( p ) {
  9213. return p < 0.5 ?
  9214. easeIn( p * 2 ) / 2 :
  9215. 1 - easeIn( p * -2 + 2 ) / 2;
  9216. };
  9217. });
  9218. })();
  9219. var effect = $.effects;
  9220. /*!
  9221. * jQuery UI Effects Blind 1.11.4
  9222. * http://jqueryui.com
  9223. *
  9224. * Copyright jQuery Foundation and other contributors
  9225. * Released under the MIT license.
  9226. * http://jquery.org/license
  9227. *
  9228. * http://api.jqueryui.com/blind-effect/
  9229. */
  9230. var effectBlind = $.effects.effect.blind = function( o, done ) {
  9231. // Create element
  9232. var el = $( this ),
  9233. rvertical = /up|down|vertical/,
  9234. rpositivemotion = /up|left|vertical|horizontal/,
  9235. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9236. mode = $.effects.setMode( el, o.mode || "hide" ),
  9237. direction = o.direction || "up",
  9238. vertical = rvertical.test( direction ),
  9239. ref = vertical ? "height" : "width",
  9240. ref2 = vertical ? "top" : "left",
  9241. motion = rpositivemotion.test( direction ),
  9242. animation = {},
  9243. show = mode === "show",
  9244. wrapper, distance, margin;
  9245. // if already wrapped, the wrapper's properties are my property. #6245
  9246. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  9247. $.effects.save( el.parent(), props );
  9248. } else {
  9249. $.effects.save( el, props );
  9250. }
  9251. el.show();
  9252. wrapper = $.effects.createWrapper( el ).css({
  9253. overflow: "hidden"
  9254. });
  9255. distance = wrapper[ ref ]();
  9256. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  9257. animation[ ref ] = show ? distance : 0;
  9258. if ( !motion ) {
  9259. el
  9260. .css( vertical ? "bottom" : "right", 0 )
  9261. .css( vertical ? "top" : "left", "auto" )
  9262. .css({ position: "absolute" });
  9263. animation[ ref2 ] = show ? margin : distance + margin;
  9264. }
  9265. // start at 0 if we are showing
  9266. if ( show ) {
  9267. wrapper.css( ref, 0 );
  9268. if ( !motion ) {
  9269. wrapper.css( ref2, margin + distance );
  9270. }
  9271. }
  9272. // Animate
  9273. wrapper.animate( animation, {
  9274. duration: o.duration,
  9275. easing: o.easing,
  9276. queue: false,
  9277. complete: function() {
  9278. if ( mode === "hide" ) {
  9279. el.hide();
  9280. }
  9281. $.effects.restore( el, props );
  9282. $.effects.removeWrapper( el );
  9283. done();
  9284. }
  9285. });
  9286. };
  9287. /*!
  9288. * jQuery UI Effects Bounce 1.11.4
  9289. * http://jqueryui.com
  9290. *
  9291. * Copyright jQuery Foundation and other contributors
  9292. * Released under the MIT license.
  9293. * http://jquery.org/license
  9294. *
  9295. * http://api.jqueryui.com/bounce-effect/
  9296. */
  9297. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  9298. var el = $( this ),
  9299. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9300. // defaults:
  9301. mode = $.effects.setMode( el, o.mode || "effect" ),
  9302. hide = mode === "hide",
  9303. show = mode === "show",
  9304. direction = o.direction || "up",
  9305. distance = o.distance,
  9306. times = o.times || 5,
  9307. // number of internal animations
  9308. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9309. speed = o.duration / anims,
  9310. easing = o.easing,
  9311. // utility:
  9312. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9313. motion = ( direction === "up" || direction === "left" ),
  9314. i,
  9315. upAnim,
  9316. downAnim,
  9317. // we will need to re-assemble the queue to stack our animations in place
  9318. queue = el.queue(),
  9319. queuelen = queue.length;
  9320. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9321. if ( show || hide ) {
  9322. props.push( "opacity" );
  9323. }
  9324. $.effects.save( el, props );
  9325. el.show();
  9326. $.effects.createWrapper( el ); // Create Wrapper
  9327. // default distance for the BIGGEST bounce is the outer Distance / 3
  9328. if ( !distance ) {
  9329. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9330. }
  9331. if ( show ) {
  9332. downAnim = { opacity: 1 };
  9333. downAnim[ ref ] = 0;
  9334. // if we are showing, force opacity 0 and set the initial position
  9335. // then do the "first" animation
  9336. el.css( "opacity", 0 )
  9337. .css( ref, motion ? -distance * 2 : distance * 2 )
  9338. .animate( downAnim, speed, easing );
  9339. }
  9340. // start at the smallest distance if we are hiding
  9341. if ( hide ) {
  9342. distance = distance / Math.pow( 2, times - 1 );
  9343. }
  9344. downAnim = {};
  9345. downAnim[ ref ] = 0;
  9346. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9347. for ( i = 0; i < times; i++ ) {
  9348. upAnim = {};
  9349. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9350. el.animate( upAnim, speed, easing )
  9351. .animate( downAnim, speed, easing );
  9352. distance = hide ? distance * 2 : distance / 2;
  9353. }
  9354. // Last Bounce when Hiding
  9355. if ( hide ) {
  9356. upAnim = { opacity: 0 };
  9357. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9358. el.animate( upAnim, speed, easing );
  9359. }
  9360. el.queue(function() {
  9361. if ( hide ) {
  9362. el.hide();
  9363. }
  9364. $.effects.restore( el, props );
  9365. $.effects.removeWrapper( el );
  9366. done();
  9367. });
  9368. // inject all the animations we just queued to be first in line (after "inprogress")
  9369. if ( queuelen > 1) {
  9370. queue.splice.apply( queue,
  9371. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9372. }
  9373. el.dequeue();
  9374. };
  9375. /*!
  9376. * jQuery UI Effects Clip 1.11.4
  9377. * http://jqueryui.com
  9378. *
  9379. * Copyright jQuery Foundation and other contributors
  9380. * Released under the MIT license.
  9381. * http://jquery.org/license
  9382. *
  9383. * http://api.jqueryui.com/clip-effect/
  9384. */
  9385. var effectClip = $.effects.effect.clip = function( o, done ) {
  9386. // Create element
  9387. var el = $( this ),
  9388. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9389. mode = $.effects.setMode( el, o.mode || "hide" ),
  9390. show = mode === "show",
  9391. direction = o.direction || "vertical",
  9392. vert = direction === "vertical",
  9393. size = vert ? "height" : "width",
  9394. position = vert ? "top" : "left",
  9395. animation = {},
  9396. wrapper, animate, distance;
  9397. // Save & Show
  9398. $.effects.save( el, props );
  9399. el.show();
  9400. // Create Wrapper
  9401. wrapper = $.effects.createWrapper( el ).css({
  9402. overflow: "hidden"
  9403. });
  9404. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9405. distance = animate[ size ]();
  9406. // Shift
  9407. if ( show ) {
  9408. animate.css( size, 0 );
  9409. animate.css( position, distance / 2 );
  9410. }
  9411. // Create Animation Object:
  9412. animation[ size ] = show ? distance : 0;
  9413. animation[ position ] = show ? 0 : distance / 2;
  9414. // Animate
  9415. animate.animate( animation, {
  9416. queue: false,
  9417. duration: o.duration,
  9418. easing: o.easing,
  9419. complete: function() {
  9420. if ( !show ) {
  9421. el.hide();
  9422. }
  9423. $.effects.restore( el, props );
  9424. $.effects.removeWrapper( el );
  9425. done();
  9426. }
  9427. });
  9428. };
  9429. /*!
  9430. * jQuery UI Effects Drop 1.11.4
  9431. * http://jqueryui.com
  9432. *
  9433. * Copyright jQuery Foundation and other contributors
  9434. * Released under the MIT license.
  9435. * http://jquery.org/license
  9436. *
  9437. * http://api.jqueryui.com/drop-effect/
  9438. */
  9439. var effectDrop = $.effects.effect.drop = function( o, done ) {
  9440. var el = $( this ),
  9441. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9442. mode = $.effects.setMode( el, o.mode || "hide" ),
  9443. show = mode === "show",
  9444. direction = o.direction || "left",
  9445. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9446. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9447. animation = {
  9448. opacity: show ? 1 : 0
  9449. },
  9450. distance;
  9451. // Adjust
  9452. $.effects.save( el, props );
  9453. el.show();
  9454. $.effects.createWrapper( el );
  9455. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  9456. if ( show ) {
  9457. el
  9458. .css( "opacity", 0 )
  9459. .css( ref, motion === "pos" ? -distance : distance );
  9460. }
  9461. // Animation
  9462. animation[ ref ] = ( show ?
  9463. ( motion === "pos" ? "+=" : "-=" ) :
  9464. ( motion === "pos" ? "-=" : "+=" ) ) +
  9465. distance;
  9466. // Animate
  9467. el.animate( animation, {
  9468. queue: false,
  9469. duration: o.duration,
  9470. easing: o.easing,
  9471. complete: function() {
  9472. if ( mode === "hide" ) {
  9473. el.hide();
  9474. }
  9475. $.effects.restore( el, props );
  9476. $.effects.removeWrapper( el );
  9477. done();
  9478. }
  9479. });
  9480. };
  9481. /*!
  9482. * jQuery UI Effects Explode 1.11.4
  9483. * http://jqueryui.com
  9484. *
  9485. * Copyright jQuery Foundation and other contributors
  9486. * Released under the MIT license.
  9487. * http://jquery.org/license
  9488. *
  9489. * http://api.jqueryui.com/explode-effect/
  9490. */
  9491. var effectExplode = $.effects.effect.explode = function( o, done ) {
  9492. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9493. cells = rows,
  9494. el = $( this ),
  9495. mode = $.effects.setMode( el, o.mode || "hide" ),
  9496. show = mode === "show",
  9497. // show and then visibility:hidden the element before calculating offset
  9498. offset = el.show().css( "visibility", "hidden" ).offset(),
  9499. // width and height of a piece
  9500. width = Math.ceil( el.outerWidth() / cells ),
  9501. height = Math.ceil( el.outerHeight() / rows ),
  9502. pieces = [],
  9503. // loop
  9504. i, j, left, top, mx, my;
  9505. // children animate complete:
  9506. function childComplete() {
  9507. pieces.push( this );
  9508. if ( pieces.length === rows * cells ) {
  9509. animComplete();
  9510. }
  9511. }
  9512. // clone the element for each row and cell.
  9513. for ( i = 0; i < rows ; i++ ) { // ===>
  9514. top = offset.top + i * height;
  9515. my = i - ( rows - 1 ) / 2 ;
  9516. for ( j = 0; j < cells ; j++ ) { // |||
  9517. left = offset.left + j * width;
  9518. mx = j - ( cells - 1 ) / 2 ;
  9519. // Create a clone of the now hidden main element that will be absolute positioned
  9520. // within a wrapper div off the -left and -top equal to size of our pieces
  9521. el
  9522. .clone()
  9523. .appendTo( "body" )
  9524. .wrap( "<div></div>" )
  9525. .css({
  9526. position: "absolute",
  9527. visibility: "visible",
  9528. left: -j * width,
  9529. top: -i * height
  9530. })
  9531. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9532. // where the original was located +left and +top equal to the size of pieces
  9533. .parent()
  9534. .addClass( "ui-effects-explode" )
  9535. .css({
  9536. position: "absolute",
  9537. overflow: "hidden",
  9538. width: width,
  9539. height: height,
  9540. left: left + ( show ? mx * width : 0 ),
  9541. top: top + ( show ? my * height : 0 ),
  9542. opacity: show ? 0 : 1
  9543. }).animate({
  9544. left: left + ( show ? 0 : mx * width ),
  9545. top: top + ( show ? 0 : my * height ),
  9546. opacity: show ? 1 : 0
  9547. }, o.duration || 500, o.easing, childComplete );
  9548. }
  9549. }
  9550. function animComplete() {
  9551. el.css({
  9552. visibility: "visible"
  9553. });
  9554. $( pieces ).remove();
  9555. if ( !show ) {
  9556. el.hide();
  9557. }
  9558. done();
  9559. }
  9560. };
  9561. /*!
  9562. * jQuery UI Effects Fade 1.11.4
  9563. * http://jqueryui.com
  9564. *
  9565. * Copyright jQuery Foundation and other contributors
  9566. * Released under the MIT license.
  9567. * http://jquery.org/license
  9568. *
  9569. * http://api.jqueryui.com/fade-effect/
  9570. */
  9571. var effectFade = $.effects.effect.fade = function( o, done ) {
  9572. var el = $( this ),
  9573. mode = $.effects.setMode( el, o.mode || "toggle" );
  9574. el.animate({
  9575. opacity: mode
  9576. }, {
  9577. queue: false,
  9578. duration: o.duration,
  9579. easing: o.easing,
  9580. complete: done
  9581. });
  9582. };
  9583. /*!
  9584. * jQuery UI Effects Fold 1.11.4
  9585. * http://jqueryui.com
  9586. *
  9587. * Copyright jQuery Foundation and other contributors
  9588. * Released under the MIT license.
  9589. * http://jquery.org/license
  9590. *
  9591. * http://api.jqueryui.com/fold-effect/
  9592. */
  9593. var effectFold = $.effects.effect.fold = function( o, done ) {
  9594. // Create element
  9595. var el = $( this ),
  9596. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9597. mode = $.effects.setMode( el, o.mode || "hide" ),
  9598. show = mode === "show",
  9599. hide = mode === "hide",
  9600. size = o.size || 15,
  9601. percent = /([0-9]+)%/.exec( size ),
  9602. horizFirst = !!o.horizFirst,
  9603. widthFirst = show !== horizFirst,
  9604. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9605. duration = o.duration / 2,
  9606. wrapper, distance,
  9607. animation1 = {},
  9608. animation2 = {};
  9609. $.effects.save( el, props );
  9610. el.show();
  9611. // Create Wrapper
  9612. wrapper = $.effects.createWrapper( el ).css({
  9613. overflow: "hidden"
  9614. });
  9615. distance = widthFirst ?
  9616. [ wrapper.width(), wrapper.height() ] :
  9617. [ wrapper.height(), wrapper.width() ];
  9618. if ( percent ) {
  9619. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9620. }
  9621. if ( show ) {
  9622. wrapper.css( horizFirst ? {
  9623. height: 0,
  9624. width: size
  9625. } : {
  9626. height: size,
  9627. width: 0
  9628. });
  9629. }
  9630. // Animation
  9631. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9632. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9633. // Animate
  9634. wrapper
  9635. .animate( animation1, duration, o.easing )
  9636. .animate( animation2, duration, o.easing, function() {
  9637. if ( hide ) {
  9638. el.hide();
  9639. }
  9640. $.effects.restore( el, props );
  9641. $.effects.removeWrapper( el );
  9642. done();
  9643. });
  9644. };
  9645. /*!
  9646. * jQuery UI Effects Highlight 1.11.4
  9647. * http://jqueryui.com
  9648. *
  9649. * Copyright jQuery Foundation and other contributors
  9650. * Released under the MIT license.
  9651. * http://jquery.org/license
  9652. *
  9653. * http://api.jqueryui.com/highlight-effect/
  9654. */
  9655. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  9656. var elem = $( this ),
  9657. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9658. mode = $.effects.setMode( elem, o.mode || "show" ),
  9659. animation = {
  9660. backgroundColor: elem.css( "backgroundColor" )
  9661. };
  9662. if (mode === "hide") {
  9663. animation.opacity = 0;
  9664. }
  9665. $.effects.save( elem, props );
  9666. elem
  9667. .show()
  9668. .css({
  9669. backgroundImage: "none",
  9670. backgroundColor: o.color || "#ffff99"
  9671. })
  9672. .animate( animation, {
  9673. queue: false,
  9674. duration: o.duration,
  9675. easing: o.easing,
  9676. complete: function() {
  9677. if ( mode === "hide" ) {
  9678. elem.hide();
  9679. }
  9680. $.effects.restore( elem, props );
  9681. done();
  9682. }
  9683. });
  9684. };
  9685. /*!
  9686. * jQuery UI Effects Size 1.11.4
  9687. * http://jqueryui.com
  9688. *
  9689. * Copyright jQuery Foundation and other contributors
  9690. * Released under the MIT license.
  9691. * http://jquery.org/license
  9692. *
  9693. * http://api.jqueryui.com/size-effect/
  9694. */
  9695. var effectSize = $.effects.effect.size = function( o, done ) {
  9696. // Create element
  9697. var original, baseline, factor,
  9698. el = $( this ),
  9699. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9700. // Always restore
  9701. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9702. // Copy for children
  9703. props2 = [ "width", "height", "overflow" ],
  9704. cProps = [ "fontSize" ],
  9705. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9706. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9707. // Set options
  9708. mode = $.effects.setMode( el, o.mode || "effect" ),
  9709. restore = o.restore || mode !== "effect",
  9710. scale = o.scale || "both",
  9711. origin = o.origin || [ "middle", "center" ],
  9712. position = el.css( "position" ),
  9713. props = restore ? props0 : props1,
  9714. zero = {
  9715. height: 0,
  9716. width: 0,
  9717. outerHeight: 0,
  9718. outerWidth: 0
  9719. };
  9720. if ( mode === "show" ) {
  9721. el.show();
  9722. }
  9723. original = {
  9724. height: el.height(),
  9725. width: el.width(),
  9726. outerHeight: el.outerHeight(),
  9727. outerWidth: el.outerWidth()
  9728. };
  9729. if ( o.mode === "toggle" && mode === "show" ) {
  9730. el.from = o.to || zero;
  9731. el.to = o.from || original;
  9732. } else {
  9733. el.from = o.from || ( mode === "show" ? zero : original );
  9734. el.to = o.to || ( mode === "hide" ? zero : original );
  9735. }
  9736. // Set scaling factor
  9737. factor = {
  9738. from: {
  9739. y: el.from.height / original.height,
  9740. x: el.from.width / original.width
  9741. },
  9742. to: {
  9743. y: el.to.height / original.height,
  9744. x: el.to.width / original.width
  9745. }
  9746. };
  9747. // Scale the css box
  9748. if ( scale === "box" || scale === "both" ) {
  9749. // Vertical props scaling
  9750. if ( factor.from.y !== factor.to.y ) {
  9751. props = props.concat( vProps );
  9752. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9753. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9754. }
  9755. // Horizontal props scaling
  9756. if ( factor.from.x !== factor.to.x ) {
  9757. props = props.concat( hProps );
  9758. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9759. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9760. }
  9761. }
  9762. // Scale the content
  9763. if ( scale === "content" || scale === "both" ) {
  9764. // Vertical props scaling
  9765. if ( factor.from.y !== factor.to.y ) {
  9766. props = props.concat( cProps ).concat( props2 );
  9767. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9768. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9769. }
  9770. }
  9771. $.effects.save( el, props );
  9772. el.show();
  9773. $.effects.createWrapper( el );
  9774. el.css( "overflow", "hidden" ).css( el.from );
  9775. // Adjust
  9776. if (origin) { // Calculate baseline shifts
  9777. baseline = $.effects.getBaseline( origin, original );
  9778. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9779. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9780. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9781. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9782. }
  9783. el.css( el.from ); // set top & left
  9784. // Animate
  9785. if ( scale === "content" || scale === "both" ) { // Scale the children
  9786. // Add margins/font-size
  9787. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9788. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9789. props2 = props0.concat(vProps).concat(hProps);
  9790. el.find( "*[width]" ).each( function() {
  9791. var child = $( this ),
  9792. c_original = {
  9793. height: child.height(),
  9794. width: child.width(),
  9795. outerHeight: child.outerHeight(),
  9796. outerWidth: child.outerWidth()
  9797. };
  9798. if (restore) {
  9799. $.effects.save(child, props2);
  9800. }
  9801. child.from = {
  9802. height: c_original.height * factor.from.y,
  9803. width: c_original.width * factor.from.x,
  9804. outerHeight: c_original.outerHeight * factor.from.y,
  9805. outerWidth: c_original.outerWidth * factor.from.x
  9806. };
  9807. child.to = {
  9808. height: c_original.height * factor.to.y,
  9809. width: c_original.width * factor.to.x,
  9810. outerHeight: c_original.height * factor.to.y,
  9811. outerWidth: c_original.width * factor.to.x
  9812. };
  9813. // Vertical props scaling
  9814. if ( factor.from.y !== factor.to.y ) {
  9815. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9816. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9817. }
  9818. // Horizontal props scaling
  9819. if ( factor.from.x !== factor.to.x ) {
  9820. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9821. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9822. }
  9823. // Animate children
  9824. child.css( child.from );
  9825. child.animate( child.to, o.duration, o.easing, function() {
  9826. // Restore children
  9827. if ( restore ) {
  9828. $.effects.restore( child, props2 );
  9829. }
  9830. });
  9831. });
  9832. }
  9833. // Animate
  9834. el.animate( el.to, {
  9835. queue: false,
  9836. duration: o.duration,
  9837. easing: o.easing,
  9838. complete: function() {
  9839. if ( el.to.opacity === 0 ) {
  9840. el.css( "opacity", el.from.opacity );
  9841. }
  9842. if ( mode === "hide" ) {
  9843. el.hide();
  9844. }
  9845. $.effects.restore( el, props );
  9846. if ( !restore ) {
  9847. // we need to calculate our new positioning based on the scaling
  9848. if ( position === "static" ) {
  9849. el.css({
  9850. position: "relative",
  9851. top: el.to.top,
  9852. left: el.to.left
  9853. });
  9854. } else {
  9855. $.each([ "top", "left" ], function( idx, pos ) {
  9856. el.css( pos, function( _, str ) {
  9857. var val = parseInt( str, 10 ),
  9858. toRef = idx ? el.to.left : el.to.top;
  9859. // if original was "auto", recalculate the new value from wrapper
  9860. if ( str === "auto" ) {
  9861. return toRef + "px";
  9862. }
  9863. return val + toRef + "px";
  9864. });
  9865. });
  9866. }
  9867. }
  9868. $.effects.removeWrapper( el );
  9869. done();
  9870. }
  9871. });
  9872. };
  9873. /*!
  9874. * jQuery UI Effects Scale 1.11.4
  9875. * http://jqueryui.com
  9876. *
  9877. * Copyright jQuery Foundation and other contributors
  9878. * Released under the MIT license.
  9879. * http://jquery.org/license
  9880. *
  9881. * http://api.jqueryui.com/scale-effect/
  9882. */
  9883. var effectScale = $.effects.effect.scale = function( o, done ) {
  9884. // Create element
  9885. var el = $( this ),
  9886. options = $.extend( true, {}, o ),
  9887. mode = $.effects.setMode( el, o.mode || "effect" ),
  9888. percent = parseInt( o.percent, 10 ) ||
  9889. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9890. direction = o.direction || "both",
  9891. origin = o.origin,
  9892. original = {
  9893. height: el.height(),
  9894. width: el.width(),
  9895. outerHeight: el.outerHeight(),
  9896. outerWidth: el.outerWidth()
  9897. },
  9898. factor = {
  9899. y: direction !== "horizontal" ? (percent / 100) : 1,
  9900. x: direction !== "vertical" ? (percent / 100) : 1
  9901. };
  9902. // We are going to pass this effect to the size effect:
  9903. options.effect = "size";
  9904. options.queue = false;
  9905. options.complete = done;
  9906. // Set default origin and restore for show/hide
  9907. if ( mode !== "effect" ) {
  9908. options.origin = origin || [ "middle", "center" ];
  9909. options.restore = true;
  9910. }
  9911. options.from = o.from || ( mode === "show" ? {
  9912. height: 0,
  9913. width: 0,
  9914. outerHeight: 0,
  9915. outerWidth: 0
  9916. } : original );
  9917. options.to = {
  9918. height: original.height * factor.y,
  9919. width: original.width * factor.x,
  9920. outerHeight: original.outerHeight * factor.y,
  9921. outerWidth: original.outerWidth * factor.x
  9922. };
  9923. // Fade option to support puff
  9924. if ( options.fade ) {
  9925. if ( mode === "show" ) {
  9926. options.from.opacity = 0;
  9927. options.to.opacity = 1;
  9928. }
  9929. if ( mode === "hide" ) {
  9930. options.from.opacity = 1;
  9931. options.to.opacity = 0;
  9932. }
  9933. }
  9934. // Animate
  9935. el.effect( options );
  9936. };
  9937. /*!
  9938. * jQuery UI Effects Puff 1.11.4
  9939. * http://jqueryui.com
  9940. *
  9941. * Copyright jQuery Foundation and other contributors
  9942. * Released under the MIT license.
  9943. * http://jquery.org/license
  9944. *
  9945. * http://api.jqueryui.com/puff-effect/
  9946. */
  9947. var effectPuff = $.effects.effect.puff = function( o, done ) {
  9948. var elem = $( this ),
  9949. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9950. hide = mode === "hide",
  9951. percent = parseInt( o.percent, 10 ) || 150,
  9952. factor = percent / 100,
  9953. original = {
  9954. height: elem.height(),
  9955. width: elem.width(),
  9956. outerHeight: elem.outerHeight(),
  9957. outerWidth: elem.outerWidth()
  9958. };
  9959. $.extend( o, {
  9960. effect: "scale",
  9961. queue: false,
  9962. fade: true,
  9963. mode: mode,
  9964. complete: done,
  9965. percent: hide ? percent : 100,
  9966. from: hide ?
  9967. original :
  9968. {
  9969. height: original.height * factor,
  9970. width: original.width * factor,
  9971. outerHeight: original.outerHeight * factor,
  9972. outerWidth: original.outerWidth * factor
  9973. }
  9974. });
  9975. elem.effect( o );
  9976. };
  9977. /*!
  9978. * jQuery UI Effects Pulsate 1.11.4
  9979. * http://jqueryui.com
  9980. *
  9981. * Copyright jQuery Foundation and other contributors
  9982. * Released under the MIT license.
  9983. * http://jquery.org/license
  9984. *
  9985. * http://api.jqueryui.com/pulsate-effect/
  9986. */
  9987. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  9988. var elem = $( this ),
  9989. mode = $.effects.setMode( elem, o.mode || "show" ),
  9990. show = mode === "show",
  9991. hide = mode === "hide",
  9992. showhide = ( show || mode === "hide" ),
  9993. // showing or hiding leaves of the "last" animation
  9994. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9995. duration = o.duration / anims,
  9996. animateTo = 0,
  9997. queue = elem.queue(),
  9998. queuelen = queue.length,
  9999. i;
  10000. if ( show || !elem.is(":visible")) {
  10001. elem.css( "opacity", 0 ).show();
  10002. animateTo = 1;
  10003. }
  10004. // anims - 1 opacity "toggles"
  10005. for ( i = 1; i < anims; i++ ) {
  10006. elem.animate({
  10007. opacity: animateTo
  10008. }, duration, o.easing );
  10009. animateTo = 1 - animateTo;
  10010. }
  10011. elem.animate({
  10012. opacity: animateTo
  10013. }, duration, o.easing);
  10014. elem.queue(function() {
  10015. if ( hide ) {
  10016. elem.hide();
  10017. }
  10018. done();
  10019. });
  10020. // We just queued up "anims" animations, we need to put them next in the queue
  10021. if ( queuelen > 1 ) {
  10022. queue.splice.apply( queue,
  10023. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  10024. }
  10025. elem.dequeue();
  10026. };
  10027. /*!
  10028. * jQuery UI Effects Shake 1.11.4
  10029. * http://jqueryui.com
  10030. *
  10031. * Copyright jQuery Foundation and other contributors
  10032. * Released under the MIT license.
  10033. * http://jquery.org/license
  10034. *
  10035. * http://api.jqueryui.com/shake-effect/
  10036. */
  10037. var effectShake = $.effects.effect.shake = function( o, done ) {
  10038. var el = $( this ),
  10039. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  10040. mode = $.effects.setMode( el, o.mode || "effect" ),
  10041. direction = o.direction || "left",
  10042. distance = o.distance || 20,
  10043. times = o.times || 3,
  10044. anims = times * 2 + 1,
  10045. speed = Math.round( o.duration / anims ),
  10046. ref = (direction === "up" || direction === "down") ? "top" : "left",
  10047. positiveMotion = (direction === "up" || direction === "left"),
  10048. animation = {},
  10049. animation1 = {},
  10050. animation2 = {},
  10051. i,
  10052. // we will need to re-assemble the queue to stack our animations in place
  10053. queue = el.queue(),
  10054. queuelen = queue.length;
  10055. $.effects.save( el, props );
  10056. el.show();
  10057. $.effects.createWrapper( el );
  10058. // Animation
  10059. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  10060. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  10061. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  10062. // Animate
  10063. el.animate( animation, speed, o.easing );
  10064. // Shakes
  10065. for ( i = 1; i < times; i++ ) {
  10066. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  10067. }
  10068. el
  10069. .animate( animation1, speed, o.easing )
  10070. .animate( animation, speed / 2, o.easing )
  10071. .queue(function() {
  10072. if ( mode === "hide" ) {
  10073. el.hide();
  10074. }
  10075. $.effects.restore( el, props );
  10076. $.effects.removeWrapper( el );
  10077. done();
  10078. });
  10079. // inject all the animations we just queued to be first in line (after "inprogress")
  10080. if ( queuelen > 1) {
  10081. queue.splice.apply( queue,
  10082. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  10083. }
  10084. el.dequeue();
  10085. };
  10086. /*!
  10087. * jQuery UI Effects Slide 1.11.4
  10088. * http://jqueryui.com
  10089. *
  10090. * Copyright jQuery Foundation and other contributors
  10091. * Released under the MIT license.
  10092. * http://jquery.org/license
  10093. *
  10094. * http://api.jqueryui.com/slide-effect/
  10095. */
  10096. var effectSlide = $.effects.effect.slide = function( o, done ) {
  10097. // Create element
  10098. var el = $( this ),
  10099. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  10100. mode = $.effects.setMode( el, o.mode || "show" ),
  10101. show = mode === "show",
  10102. direction = o.direction || "left",
  10103. ref = (direction === "up" || direction === "down") ? "top" : "left",
  10104. positiveMotion = (direction === "up" || direction === "left"),
  10105. distance,
  10106. animation = {};
  10107. // Adjust
  10108. $.effects.save( el, props );
  10109. el.show();
  10110. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  10111. $.effects.createWrapper( el ).css({
  10112. overflow: "hidden"
  10113. });
  10114. if ( show ) {
  10115. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  10116. }
  10117. // Animation
  10118. animation[ ref ] = ( show ?
  10119. ( positiveMotion ? "+=" : "-=") :
  10120. ( positiveMotion ? "-=" : "+=")) +
  10121. distance;
  10122. // Animate
  10123. el.animate( animation, {
  10124. queue: false,
  10125. duration: o.duration,
  10126. easing: o.easing,
  10127. complete: function() {
  10128. if ( mode === "hide" ) {
  10129. el.hide();
  10130. }
  10131. $.effects.restore( el, props );
  10132. $.effects.removeWrapper( el );
  10133. done();
  10134. }
  10135. });
  10136. };
  10137. /*!
  10138. * jQuery UI Effects Transfer 1.11.4
  10139. * http://jqueryui.com
  10140. *
  10141. * Copyright jQuery Foundation and other contributors
  10142. * Released under the MIT license.
  10143. * http://jquery.org/license
  10144. *
  10145. * http://api.jqueryui.com/transfer-effect/
  10146. */
  10147. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  10148. var elem = $( this ),
  10149. target = $( o.to ),
  10150. targetFixed = target.css( "position" ) === "fixed",
  10151. body = $("body"),
  10152. fixTop = targetFixed ? body.scrollTop() : 0,
  10153. fixLeft = targetFixed ? body.scrollLeft() : 0,
  10154. endPosition = target.offset(),
  10155. animation = {
  10156. top: endPosition.top - fixTop,
  10157. left: endPosition.left - fixLeft,
  10158. height: target.innerHeight(),
  10159. width: target.innerWidth()
  10160. },
  10161. startPosition = elem.offset(),
  10162. transfer = $( "<div class='ui-effects-transfer'></div>" )
  10163. .appendTo( document.body )
  10164. .addClass( o.className )
  10165. .css({
  10166. top: startPosition.top - fixTop,
  10167. left: startPosition.left - fixLeft,
  10168. height: elem.innerHeight(),
  10169. width: elem.innerWidth(),
  10170. position: targetFixed ? "fixed" : "absolute"
  10171. })
  10172. .animate( animation, o.duration, o.easing, function() {
  10173. transfer.remove();
  10174. done();
  10175. });
  10176. };
  10177. /*!
  10178. * jQuery UI Progressbar 1.11.4
  10179. * http://jqueryui.com
  10180. *
  10181. * Copyright jQuery Foundation and other contributors
  10182. * Released under the MIT license.
  10183. * http://jquery.org/license
  10184. *
  10185. * http://api.jqueryui.com/progressbar/
  10186. */
  10187. var progressbar = $.widget( "ui.progressbar", {
  10188. version: "1.11.4",
  10189. options: {
  10190. max: 100,
  10191. value: 0,
  10192. change: null,
  10193. complete: null
  10194. },
  10195. min: 0,
  10196. _create: function() {
  10197. // Constrain initial value
  10198. this.oldValue = this.options.value = this._constrainedValue();
  10199. this.element
  10200. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10201. .attr({
  10202. // Only set static values, aria-valuenow and aria-valuemax are
  10203. // set inside _refreshValue()
  10204. role: "progressbar",
  10205. "aria-valuemin": this.min
  10206. });
  10207. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10208. .appendTo( this.element );
  10209. this._refreshValue();
  10210. },
  10211. _destroy: function() {
  10212. this.element
  10213. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10214. .removeAttr( "role" )
  10215. .removeAttr( "aria-valuemin" )
  10216. .removeAttr( "aria-valuemax" )
  10217. .removeAttr( "aria-valuenow" );
  10218. this.valueDiv.remove();
  10219. },
  10220. value: function( newValue ) {
  10221. if ( newValue === undefined ) {
  10222. return this.options.value;
  10223. }
  10224. this.options.value = this._constrainedValue( newValue );
  10225. this._refreshValue();
  10226. },
  10227. _constrainedValue: function( newValue ) {
  10228. if ( newValue === undefined ) {
  10229. newValue = this.options.value;
  10230. }
  10231. this.indeterminate = newValue === false;
  10232. // sanitize value
  10233. if ( typeof newValue !== "number" ) {
  10234. newValue = 0;
  10235. }
  10236. return this.indeterminate ? false :
  10237. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10238. },
  10239. _setOptions: function( options ) {
  10240. // Ensure "value" option is set after other values (like max)
  10241. var value = options.value;
  10242. delete options.value;
  10243. this._super( options );
  10244. this.options.value = this._constrainedValue( value );
  10245. this._refreshValue();
  10246. },
  10247. _setOption: function( key, value ) {
  10248. if ( key === "max" ) {
  10249. // Don't allow a max less than min
  10250. value = Math.max( this.min, value );
  10251. }
  10252. if ( key === "disabled" ) {
  10253. this.element
  10254. .toggleClass( "ui-state-disabled", !!value )
  10255. .attr( "aria-disabled", value );
  10256. }
  10257. this._super( key, value );
  10258. },
  10259. _percentage: function() {
  10260. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10261. },
  10262. _refreshValue: function() {
  10263. var value = this.options.value,
  10264. percentage = this._percentage();
  10265. this.valueDiv
  10266. .toggle( this.indeterminate || value > this.min )
  10267. .toggleClass( "ui-corner-right", value === this.options.max )
  10268. .width( percentage.toFixed(0) + "%" );
  10269. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10270. if ( this.indeterminate ) {
  10271. this.element.removeAttr( "aria-valuenow" );
  10272. if ( !this.overlayDiv ) {
  10273. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10274. }
  10275. } else {
  10276. this.element.attr({
  10277. "aria-valuemax": this.options.max,
  10278. "aria-valuenow": value
  10279. });
  10280. if ( this.overlayDiv ) {
  10281. this.overlayDiv.remove();
  10282. this.overlayDiv = null;
  10283. }
  10284. }
  10285. if ( this.oldValue !== value ) {
  10286. this.oldValue = value;
  10287. this._trigger( "change" );
  10288. }
  10289. if ( value === this.options.max ) {
  10290. this._trigger( "complete" );
  10291. }
  10292. }
  10293. });
  10294. /*!
  10295. * jQuery UI Selectable 1.11.4
  10296. * http://jqueryui.com
  10297. *
  10298. * Copyright jQuery Foundation and other contributors
  10299. * Released under the MIT license.
  10300. * http://jquery.org/license
  10301. *
  10302. * http://api.jqueryui.com/selectable/
  10303. */
  10304. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  10305. version: "1.11.4",
  10306. options: {
  10307. appendTo: "body",
  10308. autoRefresh: true,
  10309. distance: 0,
  10310. filter: "*",
  10311. tolerance: "touch",
  10312. // callbacks
  10313. selected: null,
  10314. selecting: null,
  10315. start: null,
  10316. stop: null,
  10317. unselected: null,
  10318. unselecting: null
  10319. },
  10320. _create: function() {
  10321. var selectees,
  10322. that = this;
  10323. this.element.addClass("ui-selectable");
  10324. this.dragged = false;
  10325. // cache selectee children based on filter
  10326. this.refresh = function() {
  10327. selectees = $(that.options.filter, that.element[0]);
  10328. selectees.addClass("ui-selectee");
  10329. selectees.each(function() {
  10330. var $this = $(this),
  10331. pos = $this.offset();
  10332. $.data(this, "selectable-item", {
  10333. element: this,
  10334. $element: $this,
  10335. left: pos.left,
  10336. top: pos.top,
  10337. right: pos.left + $this.outerWidth(),
  10338. bottom: pos.top + $this.outerHeight(),
  10339. startselected: false,
  10340. selected: $this.hasClass("ui-selected"),
  10341. selecting: $this.hasClass("ui-selecting"),
  10342. unselecting: $this.hasClass("ui-unselecting")
  10343. });
  10344. });
  10345. };
  10346. this.refresh();
  10347. this.selectees = selectees.addClass("ui-selectee");
  10348. this._mouseInit();
  10349. this.helper = $("<div class='ui-selectable-helper'></div>");
  10350. },
  10351. _destroy: function() {
  10352. this.selectees
  10353. .removeClass("ui-selectee")
  10354. .removeData("selectable-item");
  10355. this.element
  10356. .removeClass("ui-selectable ui-selectable-disabled");
  10357. this._mouseDestroy();
  10358. },
  10359. _mouseStart: function(event) {
  10360. var that = this,
  10361. options = this.options;
  10362. this.opos = [ event.pageX, event.pageY ];
  10363. if (this.options.disabled) {
  10364. return;
  10365. }
  10366. this.selectees = $(options.filter, this.element[0]);
  10367. this._trigger("start", event);
  10368. $(options.appendTo).append(this.helper);
  10369. // position helper (lasso)
  10370. this.helper.css({
  10371. "left": event.pageX,
  10372. "top": event.pageY,
  10373. "width": 0,
  10374. "height": 0
  10375. });
  10376. if (options.autoRefresh) {
  10377. this.refresh();
  10378. }
  10379. this.selectees.filter(".ui-selected").each(function() {
  10380. var selectee = $.data(this, "selectable-item");
  10381. selectee.startselected = true;
  10382. if (!event.metaKey && !event.ctrlKey) {
  10383. selectee.$element.removeClass("ui-selected");
  10384. selectee.selected = false;
  10385. selectee.$element.addClass("ui-unselecting");
  10386. selectee.unselecting = true;
  10387. // selectable UNSELECTING callback
  10388. that._trigger("unselecting", event, {
  10389. unselecting: selectee.element
  10390. });
  10391. }
  10392. });
  10393. $(event.target).parents().addBack().each(function() {
  10394. var doSelect,
  10395. selectee = $.data(this, "selectable-item");
  10396. if (selectee) {
  10397. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  10398. selectee.$element
  10399. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  10400. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  10401. selectee.unselecting = !doSelect;
  10402. selectee.selecting = doSelect;
  10403. selectee.selected = doSelect;
  10404. // selectable (UN)SELECTING callback
  10405. if (doSelect) {
  10406. that._trigger("selecting", event, {
  10407. selecting: selectee.element
  10408. });
  10409. } else {
  10410. that._trigger("unselecting", event, {
  10411. unselecting: selectee.element
  10412. });
  10413. }
  10414. return false;
  10415. }
  10416. });
  10417. },
  10418. _mouseDrag: function(event) {
  10419. this.dragged = true;
  10420. if (this.options.disabled) {
  10421. return;
  10422. }
  10423. var tmp,
  10424. that = this,
  10425. options = this.options,
  10426. x1 = this.opos[0],
  10427. y1 = this.opos[1],
  10428. x2 = event.pageX,
  10429. y2 = event.pageY;
  10430. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  10431. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  10432. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  10433. this.selectees.each(function() {
  10434. var selectee = $.data(this, "selectable-item"),
  10435. hit = false;
  10436. //prevent helper from being selected if appendTo: selectable
  10437. if (!selectee || selectee.element === that.element[0]) {
  10438. return;
  10439. }
  10440. if (options.tolerance === "touch") {
  10441. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  10442. } else if (options.tolerance === "fit") {
  10443. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  10444. }
  10445. if (hit) {
  10446. // SELECT
  10447. if (selectee.selected) {
  10448. selectee.$element.removeClass("ui-selected");
  10449. selectee.selected = false;
  10450. }
  10451. if (selectee.unselecting) {
  10452. selectee.$element.removeClass("ui-unselecting");
  10453. selectee.unselecting = false;
  10454. }
  10455. if (!selectee.selecting) {
  10456. selectee.$element.addClass("ui-selecting");
  10457. selectee.selecting = true;
  10458. // selectable SELECTING callback
  10459. that._trigger("selecting", event, {
  10460. selecting: selectee.element
  10461. });
  10462. }
  10463. } else {
  10464. // UNSELECT
  10465. if (selectee.selecting) {
  10466. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  10467. selectee.$element.removeClass("ui-selecting");
  10468. selectee.selecting = false;
  10469. selectee.$element.addClass("ui-selected");
  10470. selectee.selected = true;
  10471. } else {
  10472. selectee.$element.removeClass("ui-selecting");
  10473. selectee.selecting = false;
  10474. if (selectee.startselected) {
  10475. selectee.$element.addClass("ui-unselecting");
  10476. selectee.unselecting = true;
  10477. }
  10478. // selectable UNSELECTING callback
  10479. that._trigger("unselecting", event, {
  10480. unselecting: selectee.element
  10481. });
  10482. }
  10483. }
  10484. if (selectee.selected) {
  10485. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  10486. selectee.$element.removeClass("ui-selected");
  10487. selectee.selected = false;
  10488. selectee.$element.addClass("ui-unselecting");
  10489. selectee.unselecting = true;
  10490. // selectable UNSELECTING callback
  10491. that._trigger("unselecting", event, {
  10492. unselecting: selectee.element
  10493. });
  10494. }
  10495. }
  10496. }
  10497. });
  10498. return false;
  10499. },
  10500. _mouseStop: function(event) {
  10501. var that = this;
  10502. this.dragged = false;
  10503. $(".ui-unselecting", this.element[0]).each(function() {
  10504. var selectee = $.data(this, "selectable-item");
  10505. selectee.$element.removeClass("ui-unselecting");
  10506. selectee.unselecting = false;
  10507. selectee.startselected = false;
  10508. that._trigger("unselected", event, {
  10509. unselected: selectee.element
  10510. });
  10511. });
  10512. $(".ui-selecting", this.element[0]).each(function() {
  10513. var selectee = $.data(this, "selectable-item");
  10514. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  10515. selectee.selecting = false;
  10516. selectee.selected = true;
  10517. selectee.startselected = true;
  10518. that._trigger("selected", event, {
  10519. selected: selectee.element
  10520. });
  10521. });
  10522. this._trigger("stop", event);
  10523. this.helper.remove();
  10524. return false;
  10525. }
  10526. });
  10527. /*!
  10528. * jQuery UI Selectmenu 1.11.4
  10529. * http://jqueryui.com
  10530. *
  10531. * Copyright jQuery Foundation and other contributors
  10532. * Released under the MIT license.
  10533. * http://jquery.org/license
  10534. *
  10535. * http://api.jqueryui.com/selectmenu
  10536. */
  10537. var selectmenu = $.widget( "ui.selectmenu", {
  10538. version: "1.11.4",
  10539. defaultElement: "<select>",
  10540. options: {
  10541. appendTo: null,
  10542. disabled: null,
  10543. icons: {
  10544. button: "ui-icon-triangle-1-s"
  10545. },
  10546. position: {
  10547. my: "left top",
  10548. at: "left bottom",
  10549. collision: "none"
  10550. },
  10551. width: null,
  10552. // callbacks
  10553. change: null,
  10554. close: null,
  10555. focus: null,
  10556. open: null,
  10557. select: null
  10558. },
  10559. _create: function() {
  10560. var selectmenuId = this.element.uniqueId().attr( "id" );
  10561. this.ids = {
  10562. element: selectmenuId,
  10563. button: selectmenuId + "-button",
  10564. menu: selectmenuId + "-menu"
  10565. };
  10566. this._drawButton();
  10567. this._drawMenu();
  10568. if ( this.options.disabled ) {
  10569. this.disable();
  10570. }
  10571. },
  10572. _drawButton: function() {
  10573. var that = this;
  10574. // Associate existing label with the new button
  10575. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  10576. this._on( this.label, {
  10577. click: function( event ) {
  10578. this.button.focus();
  10579. event.preventDefault();
  10580. }
  10581. });
  10582. // Hide original select element
  10583. this.element.hide();
  10584. // Create button
  10585. this.button = $( "<span>", {
  10586. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  10587. tabindex: this.options.disabled ? -1 : 0,
  10588. id: this.ids.button,
  10589. role: "combobox",
  10590. "aria-expanded": "false",
  10591. "aria-autocomplete": "list",
  10592. "aria-owns": this.ids.menu,
  10593. "aria-haspopup": "true"
  10594. })
  10595. .insertAfter( this.element );
  10596. $( "<span>", {
  10597. "class": "ui-icon " + this.options.icons.button
  10598. })
  10599. .prependTo( this.button );
  10600. this.buttonText = $( "<span>", {
  10601. "class": "ui-selectmenu-text"
  10602. })
  10603. .appendTo( this.button );
  10604. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  10605. this._resizeButton();
  10606. this._on( this.button, this._buttonEvents );
  10607. this.button.one( "focusin", function() {
  10608. // Delay rendering the menu items until the button receives focus.
  10609. // The menu may have already been rendered via a programmatic open.
  10610. if ( !that.menuItems ) {
  10611. that._refreshMenu();
  10612. }
  10613. });
  10614. this._hoverable( this.button );
  10615. this._focusable( this.button );
  10616. },
  10617. _drawMenu: function() {
  10618. var that = this;
  10619. // Create menu
  10620. this.menu = $( "<ul>", {
  10621. "aria-hidden": "true",
  10622. "aria-labelledby": this.ids.button,
  10623. id: this.ids.menu
  10624. });
  10625. // Wrap menu
  10626. this.menuWrap = $( "<div>", {
  10627. "class": "ui-selectmenu-menu ui-front"
  10628. })
  10629. .append( this.menu )
  10630. .appendTo( this._appendTo() );
  10631. // Initialize menu widget
  10632. this.menuInstance = this.menu
  10633. .menu({
  10634. role: "listbox",
  10635. select: function( event, ui ) {
  10636. event.preventDefault();
  10637. // support: IE8
  10638. // If the item was selected via a click, the text selection
  10639. // will be destroyed in IE
  10640. that._setSelection();
  10641. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  10642. },
  10643. focus: function( event, ui ) {
  10644. var item = ui.item.data( "ui-selectmenu-item" );
  10645. // Prevent inital focus from firing and check if its a newly focused item
  10646. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  10647. that._trigger( "focus", event, { item: item } );
  10648. if ( !that.isOpen ) {
  10649. that._select( item, event );
  10650. }
  10651. }
  10652. that.focusIndex = item.index;
  10653. that.button.attr( "aria-activedescendant",
  10654. that.menuItems.eq( item.index ).attr( "id" ) );
  10655. }
  10656. })
  10657. .menu( "instance" );
  10658. // Adjust menu styles to dropdown
  10659. this.menu
  10660. .addClass( "ui-corner-bottom" )
  10661. .removeClass( "ui-corner-all" );
  10662. // Don't close the menu on mouseleave
  10663. this.menuInstance._off( this.menu, "mouseleave" );
  10664. // Cancel the menu's collapseAll on document click
  10665. this.menuInstance._closeOnDocumentClick = function() {
  10666. return false;
  10667. };
  10668. // Selects often contain empty items, but never contain dividers
  10669. this.menuInstance._isDivider = function() {
  10670. return false;
  10671. };
  10672. },
  10673. refresh: function() {
  10674. this._refreshMenu();
  10675. this._setText( this.buttonText, this._getSelectedItem().text() );
  10676. if ( !this.options.width ) {
  10677. this._resizeButton();
  10678. }
  10679. },
  10680. _refreshMenu: function() {
  10681. this.menu.empty();
  10682. var item,
  10683. options = this.element.find( "option" );
  10684. if ( !options.length ) {
  10685. return;
  10686. }
  10687. this._parseOptions( options );
  10688. this._renderMenu( this.menu, this.items );
  10689. this.menuInstance.refresh();
  10690. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  10691. item = this._getSelectedItem();
  10692. // Update the menu to have the correct item focused
  10693. this.menuInstance.focus( null, item );
  10694. this._setAria( item.data( "ui-selectmenu-item" ) );
  10695. // Set disabled state
  10696. this._setOption( "disabled", this.element.prop( "disabled" ) );
  10697. },
  10698. open: function( event ) {
  10699. if ( this.options.disabled ) {
  10700. return;
  10701. }
  10702. // If this is the first time the menu is being opened, render the items
  10703. if ( !this.menuItems ) {
  10704. this._refreshMenu();
  10705. } else {
  10706. // Menu clears focus on close, reset focus to selected item
  10707. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  10708. this.menuInstance.focus( null, this._getSelectedItem() );
  10709. }
  10710. this.isOpen = true;
  10711. this._toggleAttr();
  10712. this._resizeMenu();
  10713. this._position();
  10714. this._on( this.document, this._documentClick );
  10715. this._trigger( "open", event );
  10716. },
  10717. _position: function() {
  10718. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  10719. },
  10720. close: function( event ) {
  10721. if ( !this.isOpen ) {
  10722. return;
  10723. }
  10724. this.isOpen = false;
  10725. this._toggleAttr();
  10726. this.range = null;
  10727. this._off( this.document );
  10728. this._trigger( "close", event );
  10729. },
  10730. widget: function() {
  10731. return this.button;
  10732. },
  10733. menuWidget: function() {
  10734. return this.menu;
  10735. },
  10736. _renderMenu: function( ul, items ) {
  10737. var that = this,
  10738. currentOptgroup = "";
  10739. $.each( items, function( index, item ) {
  10740. if ( item.optgroup !== currentOptgroup ) {
  10741. $( "<li>", {
  10742. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  10743. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  10744. " ui-state-disabled" :
  10745. "" ),
  10746. text: item.optgroup
  10747. })
  10748. .appendTo( ul );
  10749. currentOptgroup = item.optgroup;
  10750. }
  10751. that._renderItemData( ul, item );
  10752. });
  10753. },
  10754. _renderItemData: function( ul, item ) {
  10755. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  10756. },
  10757. _renderItem: function( ul, item ) {
  10758. var li = $( "<li>" );
  10759. if ( item.disabled ) {
  10760. li.addClass( "ui-state-disabled" );
  10761. }
  10762. this._setText( li, item.label );
  10763. return li.appendTo( ul );
  10764. },
  10765. _setText: function( element, value ) {
  10766. if ( value ) {
  10767. element.text( value );
  10768. } else {
  10769. element.html( "&#160;" );
  10770. }
  10771. },
  10772. _move: function( direction, event ) {
  10773. var item, next,
  10774. filter = ".ui-menu-item";
  10775. if ( this.isOpen ) {
  10776. item = this.menuItems.eq( this.focusIndex );
  10777. } else {
  10778. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10779. filter += ":not(.ui-state-disabled)";
  10780. }
  10781. if ( direction === "first" || direction === "last" ) {
  10782. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  10783. } else {
  10784. next = item[ direction + "All" ]( filter ).eq( 0 );
  10785. }
  10786. if ( next.length ) {
  10787. this.menuInstance.focus( event, next );
  10788. }
  10789. },
  10790. _getSelectedItem: function() {
  10791. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10792. },
  10793. _toggle: function( event ) {
  10794. this[ this.isOpen ? "close" : "open" ]( event );
  10795. },
  10796. _setSelection: function() {
  10797. var selection;
  10798. if ( !this.range ) {
  10799. return;
  10800. }
  10801. if ( window.getSelection ) {
  10802. selection = window.getSelection();
  10803. selection.removeAllRanges();
  10804. selection.addRange( this.range );
  10805. // support: IE8
  10806. } else {
  10807. this.range.select();
  10808. }
  10809. // support: IE
  10810. // Setting the text selection kills the button focus in IE, but
  10811. // restoring the focus doesn't kill the selection.
  10812. this.button.focus();
  10813. },
  10814. _documentClick: {
  10815. mousedown: function( event ) {
  10816. if ( !this.isOpen ) {
  10817. return;
  10818. }
  10819. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  10820. this.close( event );
  10821. }
  10822. }
  10823. },
  10824. _buttonEvents: {
  10825. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  10826. mousedown: function() {
  10827. var selection;
  10828. if ( window.getSelection ) {
  10829. selection = window.getSelection();
  10830. if ( selection.rangeCount ) {
  10831. this.range = selection.getRangeAt( 0 );
  10832. }
  10833. // support: IE8
  10834. } else {
  10835. this.range = document.selection.createRange();
  10836. }
  10837. },
  10838. click: function( event ) {
  10839. this._setSelection();
  10840. this._toggle( event );
  10841. },
  10842. keydown: function( event ) {
  10843. var preventDefault = true;
  10844. switch ( event.keyCode ) {
  10845. case $.ui.keyCode.TAB:
  10846. case $.ui.keyCode.ESCAPE:
  10847. this.close( event );
  10848. preventDefault = false;
  10849. break;
  10850. case $.ui.keyCode.ENTER:
  10851. if ( this.isOpen ) {
  10852. this._selectFocusedItem( event );
  10853. }
  10854. break;
  10855. case $.ui.keyCode.UP:
  10856. if ( event.altKey ) {
  10857. this._toggle( event );
  10858. } else {
  10859. this._move( "prev", event );
  10860. }
  10861. break;
  10862. case $.ui.keyCode.DOWN:
  10863. if ( event.altKey ) {
  10864. this._toggle( event );
  10865. } else {
  10866. this._move( "next", event );
  10867. }
  10868. break;
  10869. case $.ui.keyCode.SPACE:
  10870. if ( this.isOpen ) {
  10871. this._selectFocusedItem( event );
  10872. } else {
  10873. this._toggle( event );
  10874. }
  10875. break;
  10876. case $.ui.keyCode.LEFT:
  10877. this._move( "prev", event );
  10878. break;
  10879. case $.ui.keyCode.RIGHT:
  10880. this._move( "next", event );
  10881. break;
  10882. case $.ui.keyCode.HOME:
  10883. case $.ui.keyCode.PAGE_UP:
  10884. this._move( "first", event );
  10885. break;
  10886. case $.ui.keyCode.END:
  10887. case $.ui.keyCode.PAGE_DOWN:
  10888. this._move( "last", event );
  10889. break;
  10890. default:
  10891. this.menu.trigger( event );
  10892. preventDefault = false;
  10893. }
  10894. if ( preventDefault ) {
  10895. event.preventDefault();
  10896. }
  10897. }
  10898. },
  10899. _selectFocusedItem: function( event ) {
  10900. var item = this.menuItems.eq( this.focusIndex );
  10901. if ( !item.hasClass( "ui-state-disabled" ) ) {
  10902. this._select( item.data( "ui-selectmenu-item" ), event );
  10903. }
  10904. },
  10905. _select: function( item, event ) {
  10906. var oldIndex = this.element[ 0 ].selectedIndex;
  10907. // Change native select element
  10908. this.element[ 0 ].selectedIndex = item.index;
  10909. this._setText( this.buttonText, item.label );
  10910. this._setAria( item );
  10911. this._trigger( "select", event, { item: item } );
  10912. if ( item.index !== oldIndex ) {
  10913. this._trigger( "change", event, { item: item } );
  10914. }
  10915. this.close( event );
  10916. },
  10917. _setAria: function( item ) {
  10918. var id = this.menuItems.eq( item.index ).attr( "id" );
  10919. this.button.attr({
  10920. "aria-labelledby": id,
  10921. "aria-activedescendant": id
  10922. });
  10923. this.menu.attr( "aria-activedescendant", id );
  10924. },
  10925. _setOption: function( key, value ) {
  10926. if ( key === "icons" ) {
  10927. this.button.find( "span.ui-icon" )
  10928. .removeClass( this.options.icons.button )
  10929. .addClass( value.button );
  10930. }
  10931. this._super( key, value );
  10932. if ( key === "appendTo" ) {
  10933. this.menuWrap.appendTo( this._appendTo() );
  10934. }
  10935. if ( key === "disabled" ) {
  10936. this.menuInstance.option( "disabled", value );
  10937. this.button
  10938. .toggleClass( "ui-state-disabled", value )
  10939. .attr( "aria-disabled", value );
  10940. this.element.prop( "disabled", value );
  10941. if ( value ) {
  10942. this.button.attr( "tabindex", -1 );
  10943. this.close();
  10944. } else {
  10945. this.button.attr( "tabindex", 0 );
  10946. }
  10947. }
  10948. if ( key === "width" ) {
  10949. this._resizeButton();
  10950. }
  10951. },
  10952. _appendTo: function() {
  10953. var element = this.options.appendTo;
  10954. if ( element ) {
  10955. element = element.jquery || element.nodeType ?
  10956. $( element ) :
  10957. this.document.find( element ).eq( 0 );
  10958. }
  10959. if ( !element || !element[ 0 ] ) {
  10960. element = this.element.closest( ".ui-front" );
  10961. }
  10962. if ( !element.length ) {
  10963. element = this.document[ 0 ].body;
  10964. }
  10965. return element;
  10966. },
  10967. _toggleAttr: function() {
  10968. this.button
  10969. .toggleClass( "ui-corner-top", this.isOpen )
  10970. .toggleClass( "ui-corner-all", !this.isOpen )
  10971. .attr( "aria-expanded", this.isOpen );
  10972. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  10973. this.menu.attr( "aria-hidden", !this.isOpen );
  10974. },
  10975. _resizeButton: function() {
  10976. var width = this.options.width;
  10977. if ( !width ) {
  10978. width = this.element.show().outerWidth();
  10979. this.element.hide();
  10980. }
  10981. this.button.outerWidth( width );
  10982. },
  10983. _resizeMenu: function() {
  10984. this.menu.outerWidth( Math.max(
  10985. this.button.outerWidth(),
  10986. // support: IE10
  10987. // IE10 wraps long text (possibly a rounding bug)
  10988. // so we add 1px to avoid the wrapping
  10989. this.menu.width( "" ).outerWidth() + 1
  10990. ) );
  10991. },
  10992. _getCreateOptions: function() {
  10993. return { disabled: this.element.prop( "disabled" ) };
  10994. },
  10995. _parseOptions: function( options ) {
  10996. var data = [];
  10997. options.each(function( index, item ) {
  10998. var option = $( item ),
  10999. optgroup = option.parent( "optgroup" );
  11000. data.push({
  11001. element: option,
  11002. index: index,
  11003. value: option.val(),
  11004. label: option.text(),
  11005. optgroup: optgroup.attr( "label" ) || "",
  11006. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  11007. });
  11008. });
  11009. this.items = data;
  11010. },
  11011. _destroy: function() {
  11012. this.menuWrap.remove();
  11013. this.button.remove();
  11014. this.element.show();
  11015. this.element.removeUniqueId();
  11016. this.label.attr( "for", this.ids.element );
  11017. }
  11018. });
  11019. /*!
  11020. * jQuery UI Slider 1.11.4
  11021. * http://jqueryui.com
  11022. *
  11023. * Copyright jQuery Foundation and other contributors
  11024. * Released under the MIT license.
  11025. * http://jquery.org/license
  11026. *
  11027. * http://api.jqueryui.com/slider/
  11028. */
  11029. var slider = $.widget( "ui.slider", $.ui.mouse, {
  11030. version: "1.11.4",
  11031. widgetEventPrefix: "slide",
  11032. options: {
  11033. animate: false,
  11034. distance: 0,
  11035. max: 100,
  11036. min: 0,
  11037. orientation: "horizontal",
  11038. range: false,
  11039. step: 1,
  11040. value: 0,
  11041. values: null,
  11042. // callbacks
  11043. change: null,
  11044. slide: null,
  11045. start: null,
  11046. stop: null
  11047. },
  11048. // number of pages in a slider
  11049. // (how many times can you page up/down to go through the whole range)
  11050. numPages: 5,
  11051. _create: function() {
  11052. this._keySliding = false;
  11053. this._mouseSliding = false;
  11054. this._animateOff = true;
  11055. this._handleIndex = null;
  11056. this._detectOrientation();
  11057. this._mouseInit();
  11058. this._calculateNewMax();
  11059. this.element
  11060. .addClass( "ui-slider" +
  11061. " ui-slider-" + this.orientation +
  11062. " ui-widget" +
  11063. " ui-widget-content" +
  11064. " ui-corner-all");
  11065. this._refresh();
  11066. this._setOption( "disabled", this.options.disabled );
  11067. this._animateOff = false;
  11068. },
  11069. _refresh: function() {
  11070. this._createRange();
  11071. this._createHandles();
  11072. this._setupEvents();
  11073. this._refreshValue();
  11074. },
  11075. _createHandles: function() {
  11076. var i, handleCount,
  11077. options = this.options,
  11078. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  11079. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  11080. handles = [];
  11081. handleCount = ( options.values && options.values.length ) || 1;
  11082. if ( existingHandles.length > handleCount ) {
  11083. existingHandles.slice( handleCount ).remove();
  11084. existingHandles = existingHandles.slice( 0, handleCount );
  11085. }
  11086. for ( i = existingHandles.length; i < handleCount; i++ ) {
  11087. handles.push( handle );
  11088. }
  11089. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  11090. this.handle = this.handles.eq( 0 );
  11091. this.handles.each(function( i ) {
  11092. $( this ).data( "ui-slider-handle-index", i );
  11093. });
  11094. },
  11095. _createRange: function() {
  11096. var options = this.options,
  11097. classes = "";
  11098. if ( options.range ) {
  11099. if ( options.range === true ) {
  11100. if ( !options.values ) {
  11101. options.values = [ this._valueMin(), this._valueMin() ];
  11102. } else if ( options.values.length && options.values.length !== 2 ) {
  11103. options.values = [ options.values[0], options.values[0] ];
  11104. } else if ( $.isArray( options.values ) ) {
  11105. options.values = options.values.slice(0);
  11106. }
  11107. }
  11108. if ( !this.range || !this.range.length ) {
  11109. this.range = $( "<div></div>" )
  11110. .appendTo( this.element );
  11111. classes = "ui-slider-range" +
  11112. // note: this isn't the most fittingly semantic framework class for this element,
  11113. // but worked best visually with a variety of themes
  11114. " ui-widget-header ui-corner-all";
  11115. } else {
  11116. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  11117. // Handle range switching from true to min/max
  11118. .css({
  11119. "left": "",
  11120. "bottom": ""
  11121. });
  11122. }
  11123. this.range.addClass( classes +
  11124. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  11125. } else {
  11126. if ( this.range ) {
  11127. this.range.remove();
  11128. }
  11129. this.range = null;
  11130. }
  11131. },
  11132. _setupEvents: function() {
  11133. this._off( this.handles );
  11134. this._on( this.handles, this._handleEvents );
  11135. this._hoverable( this.handles );
  11136. this._focusable( this.handles );
  11137. },
  11138. _destroy: function() {
  11139. this.handles.remove();
  11140. if ( this.range ) {
  11141. this.range.remove();
  11142. }
  11143. this.element
  11144. .removeClass( "ui-slider" +
  11145. " ui-slider-horizontal" +
  11146. " ui-slider-vertical" +
  11147. " ui-widget" +
  11148. " ui-widget-content" +
  11149. " ui-corner-all" );
  11150. this._mouseDestroy();
  11151. },
  11152. _mouseCapture: function( event ) {
  11153. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  11154. that = this,
  11155. o = this.options;
  11156. if ( o.disabled ) {
  11157. return false;
  11158. }
  11159. this.elementSize = {
  11160. width: this.element.outerWidth(),
  11161. height: this.element.outerHeight()
  11162. };
  11163. this.elementOffset = this.element.offset();
  11164. position = { x: event.pageX, y: event.pageY };
  11165. normValue = this._normValueFromMouse( position );
  11166. distance = this._valueMax() - this._valueMin() + 1;
  11167. this.handles.each(function( i ) {
  11168. var thisDistance = Math.abs( normValue - that.values(i) );
  11169. if (( distance > thisDistance ) ||
  11170. ( distance === thisDistance &&
  11171. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  11172. distance = thisDistance;
  11173. closestHandle = $( this );
  11174. index = i;
  11175. }
  11176. });
  11177. allowed = this._start( event, index );
  11178. if ( allowed === false ) {
  11179. return false;
  11180. }
  11181. this._mouseSliding = true;
  11182. this._handleIndex = index;
  11183. closestHandle
  11184. .addClass( "ui-state-active" )
  11185. .focus();
  11186. offset = closestHandle.offset();
  11187. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11188. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11189. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11190. top: event.pageY - offset.top -
  11191. ( closestHandle.height() / 2 ) -
  11192. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11193. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11194. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11195. };
  11196. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11197. this._slide( event, index, normValue );
  11198. }
  11199. this._animateOff = true;
  11200. return true;
  11201. },
  11202. _mouseStart: function() {
  11203. return true;
  11204. },
  11205. _mouseDrag: function( event ) {
  11206. var position = { x: event.pageX, y: event.pageY },
  11207. normValue = this._normValueFromMouse( position );
  11208. this._slide( event, this._handleIndex, normValue );
  11209. return false;
  11210. },
  11211. _mouseStop: function( event ) {
  11212. this.handles.removeClass( "ui-state-active" );
  11213. this._mouseSliding = false;
  11214. this._stop( event, this._handleIndex );
  11215. this._change( event, this._handleIndex );
  11216. this._handleIndex = null;
  11217. this._clickOffset = null;
  11218. this._animateOff = false;
  11219. return false;
  11220. },
  11221. _detectOrientation: function() {
  11222. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11223. },
  11224. _normValueFromMouse: function( position ) {
  11225. var pixelTotal,
  11226. pixelMouse,
  11227. percentMouse,
  11228. valueTotal,
  11229. valueMouse;
  11230. if ( this.orientation === "horizontal" ) {
  11231. pixelTotal = this.elementSize.width;
  11232. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11233. } else {
  11234. pixelTotal = this.elementSize.height;
  11235. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11236. }
  11237. percentMouse = ( pixelMouse / pixelTotal );
  11238. if ( percentMouse > 1 ) {
  11239. percentMouse = 1;
  11240. }
  11241. if ( percentMouse < 0 ) {
  11242. percentMouse = 0;
  11243. }
  11244. if ( this.orientation === "vertical" ) {
  11245. percentMouse = 1 - percentMouse;
  11246. }
  11247. valueTotal = this._valueMax() - this._valueMin();
  11248. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11249. return this._trimAlignValue( valueMouse );
  11250. },
  11251. _start: function( event, index ) {
  11252. var uiHash = {
  11253. handle: this.handles[ index ],
  11254. value: this.value()
  11255. };
  11256. if ( this.options.values && this.options.values.length ) {
  11257. uiHash.value = this.values( index );
  11258. uiHash.values = this.values();
  11259. }
  11260. return this._trigger( "start", event, uiHash );
  11261. },
  11262. _slide: function( event, index, newVal ) {
  11263. var otherVal,
  11264. newValues,
  11265. allowed;
  11266. if ( this.options.values && this.options.values.length ) {
  11267. otherVal = this.values( index ? 0 : 1 );
  11268. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11269. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11270. ) {
  11271. newVal = otherVal;
  11272. }
  11273. if ( newVal !== this.values( index ) ) {
  11274. newValues = this.values();
  11275. newValues[ index ] = newVal;
  11276. // A slide can be canceled by returning false from the slide callback
  11277. allowed = this._trigger( "slide", event, {
  11278. handle: this.handles[ index ],
  11279. value: newVal,
  11280. values: newValues
  11281. } );
  11282. otherVal = this.values( index ? 0 : 1 );
  11283. if ( allowed !== false ) {
  11284. this.values( index, newVal );
  11285. }
  11286. }
  11287. } else {
  11288. if ( newVal !== this.value() ) {
  11289. // A slide can be canceled by returning false from the slide callback
  11290. allowed = this._trigger( "slide", event, {
  11291. handle: this.handles[ index ],
  11292. value: newVal
  11293. } );
  11294. if ( allowed !== false ) {
  11295. this.value( newVal );
  11296. }
  11297. }
  11298. }
  11299. },
  11300. _stop: function( event, index ) {
  11301. var uiHash = {
  11302. handle: this.handles[ index ],
  11303. value: this.value()
  11304. };
  11305. if ( this.options.values && this.options.values.length ) {
  11306. uiHash.value = this.values( index );
  11307. uiHash.values = this.values();
  11308. }
  11309. this._trigger( "stop", event, uiHash );
  11310. },
  11311. _change: function( event, index ) {
  11312. if ( !this._keySliding && !this._mouseSliding ) {
  11313. var uiHash = {
  11314. handle: this.handles[ index ],
  11315. value: this.value()
  11316. };
  11317. if ( this.options.values && this.options.values.length ) {
  11318. uiHash.value = this.values( index );
  11319. uiHash.values = this.values();
  11320. }
  11321. //store the last changed value index for reference when handles overlap
  11322. this._lastChangedValue = index;
  11323. this._trigger( "change", event, uiHash );
  11324. }
  11325. },
  11326. value: function( newValue ) {
  11327. if ( arguments.length ) {
  11328. this.options.value = this._trimAlignValue( newValue );
  11329. this._refreshValue();
  11330. this._change( null, 0 );
  11331. return;
  11332. }
  11333. return this._value();
  11334. },
  11335. values: function( index, newValue ) {
  11336. var vals,
  11337. newValues,
  11338. i;
  11339. if ( arguments.length > 1 ) {
  11340. this.options.values[ index ] = this._trimAlignValue( newValue );
  11341. this._refreshValue();
  11342. this._change( null, index );
  11343. return;
  11344. }
  11345. if ( arguments.length ) {
  11346. if ( $.isArray( arguments[ 0 ] ) ) {
  11347. vals = this.options.values;
  11348. newValues = arguments[ 0 ];
  11349. for ( i = 0; i < vals.length; i += 1 ) {
  11350. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11351. this._change( null, i );
  11352. }
  11353. this._refreshValue();
  11354. } else {
  11355. if ( this.options.values && this.options.values.length ) {
  11356. return this._values( index );
  11357. } else {
  11358. return this.value();
  11359. }
  11360. }
  11361. } else {
  11362. return this._values();
  11363. }
  11364. },
  11365. _setOption: function( key, value ) {
  11366. var i,
  11367. valsLength = 0;
  11368. if ( key === "range" && this.options.range === true ) {
  11369. if ( value === "min" ) {
  11370. this.options.value = this._values( 0 );
  11371. this.options.values = null;
  11372. } else if ( value === "max" ) {
  11373. this.options.value = this._values( this.options.values.length - 1 );
  11374. this.options.values = null;
  11375. }
  11376. }
  11377. if ( $.isArray( this.options.values ) ) {
  11378. valsLength = this.options.values.length;
  11379. }
  11380. if ( key === "disabled" ) {
  11381. this.element.toggleClass( "ui-state-disabled", !!value );
  11382. }
  11383. this._super( key, value );
  11384. switch ( key ) {
  11385. case "orientation":
  11386. this._detectOrientation();
  11387. this.element
  11388. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11389. .addClass( "ui-slider-" + this.orientation );
  11390. this._refreshValue();
  11391. // Reset positioning from previous orientation
  11392. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  11393. break;
  11394. case "value":
  11395. this._animateOff = true;
  11396. this._refreshValue();
  11397. this._change( null, 0 );
  11398. this._animateOff = false;
  11399. break;
  11400. case "values":
  11401. this._animateOff = true;
  11402. this._refreshValue();
  11403. for ( i = 0; i < valsLength; i += 1 ) {
  11404. this._change( null, i );
  11405. }
  11406. this._animateOff = false;
  11407. break;
  11408. case "step":
  11409. case "min":
  11410. case "max":
  11411. this._animateOff = true;
  11412. this._calculateNewMax();
  11413. this._refreshValue();
  11414. this._animateOff = false;
  11415. break;
  11416. case "range":
  11417. this._animateOff = true;
  11418. this._refresh();
  11419. this._animateOff = false;
  11420. break;
  11421. }
  11422. },
  11423. //internal value getter
  11424. // _value() returns value trimmed by min and max, aligned by step
  11425. _value: function() {
  11426. var val = this.options.value;
  11427. val = this._trimAlignValue( val );
  11428. return val;
  11429. },
  11430. //internal values getter
  11431. // _values() returns array of values trimmed by min and max, aligned by step
  11432. // _values( index ) returns single value trimmed by min and max, aligned by step
  11433. _values: function( index ) {
  11434. var val,
  11435. vals,
  11436. i;
  11437. if ( arguments.length ) {
  11438. val = this.options.values[ index ];
  11439. val = this._trimAlignValue( val );
  11440. return val;
  11441. } else if ( this.options.values && this.options.values.length ) {
  11442. // .slice() creates a copy of the array
  11443. // this copy gets trimmed by min and max and then returned
  11444. vals = this.options.values.slice();
  11445. for ( i = 0; i < vals.length; i += 1) {
  11446. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11447. }
  11448. return vals;
  11449. } else {
  11450. return [];
  11451. }
  11452. },
  11453. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11454. _trimAlignValue: function( val ) {
  11455. if ( val <= this._valueMin() ) {
  11456. return this._valueMin();
  11457. }
  11458. if ( val >= this._valueMax() ) {
  11459. return this._valueMax();
  11460. }
  11461. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11462. valModStep = (val - this._valueMin()) % step,
  11463. alignValue = val - valModStep;
  11464. if ( Math.abs(valModStep) * 2 >= step ) {
  11465. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11466. }
  11467. // Since JavaScript has problems with large floats, round
  11468. // the final value to 5 digits after the decimal point (see #4124)
  11469. return parseFloat( alignValue.toFixed(5) );
  11470. },
  11471. _calculateNewMax: function() {
  11472. var max = this.options.max,
  11473. min = this._valueMin(),
  11474. step = this.options.step,
  11475. aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step;
  11476. max = aboveMin + min;
  11477. this.max = parseFloat( max.toFixed( this._precision() ) );
  11478. },
  11479. _precision: function() {
  11480. var precision = this._precisionOf( this.options.step );
  11481. if ( this.options.min !== null ) {
  11482. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11483. }
  11484. return precision;
  11485. },
  11486. _precisionOf: function( num ) {
  11487. var str = num.toString(),
  11488. decimal = str.indexOf( "." );
  11489. return decimal === -1 ? 0 : str.length - decimal - 1;
  11490. },
  11491. _valueMin: function() {
  11492. return this.options.min;
  11493. },
  11494. _valueMax: function() {
  11495. return this.max;
  11496. },
  11497. _refreshValue: function() {
  11498. var lastValPercent, valPercent, value, valueMin, valueMax,
  11499. oRange = this.options.range,
  11500. o = this.options,
  11501. that = this,
  11502. animate = ( !this._animateOff ) ? o.animate : false,
  11503. _set = {};
  11504. if ( this.options.values && this.options.values.length ) {
  11505. this.handles.each(function( i ) {
  11506. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11507. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11508. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11509. if ( that.options.range === true ) {
  11510. if ( that.orientation === "horizontal" ) {
  11511. if ( i === 0 ) {
  11512. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11513. }
  11514. if ( i === 1 ) {
  11515. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11516. }
  11517. } else {
  11518. if ( i === 0 ) {
  11519. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11520. }
  11521. if ( i === 1 ) {
  11522. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11523. }
  11524. }
  11525. }
  11526. lastValPercent = valPercent;
  11527. });
  11528. } else {
  11529. value = this.value();
  11530. valueMin = this._valueMin();
  11531. valueMax = this._valueMax();
  11532. valPercent = ( valueMax !== valueMin ) ?
  11533. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11534. 0;
  11535. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11536. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11537. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11538. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11539. }
  11540. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11541. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11542. }
  11543. if ( oRange === "min" && this.orientation === "vertical" ) {
  11544. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11545. }
  11546. if ( oRange === "max" && this.orientation === "vertical" ) {
  11547. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11548. }
  11549. }
  11550. },
  11551. _handleEvents: {
  11552. keydown: function( event ) {
  11553. var allowed, curVal, newVal, step,
  11554. index = $( event.target ).data( "ui-slider-handle-index" );
  11555. switch ( event.keyCode ) {
  11556. case $.ui.keyCode.HOME:
  11557. case $.ui.keyCode.END:
  11558. case $.ui.keyCode.PAGE_UP:
  11559. case $.ui.keyCode.PAGE_DOWN:
  11560. case $.ui.keyCode.UP:
  11561. case $.ui.keyCode.RIGHT:
  11562. case $.ui.keyCode.DOWN:
  11563. case $.ui.keyCode.LEFT:
  11564. event.preventDefault();
  11565. if ( !this._keySliding ) {
  11566. this._keySliding = true;
  11567. $( event.target ).addClass( "ui-state-active" );
  11568. allowed = this._start( event, index );
  11569. if ( allowed === false ) {
  11570. return;
  11571. }
  11572. }
  11573. break;
  11574. }
  11575. step = this.options.step;
  11576. if ( this.options.values && this.options.values.length ) {
  11577. curVal = newVal = this.values( index );
  11578. } else {
  11579. curVal = newVal = this.value();
  11580. }
  11581. switch ( event.keyCode ) {
  11582. case $.ui.keyCode.HOME:
  11583. newVal = this._valueMin();
  11584. break;
  11585. case $.ui.keyCode.END:
  11586. newVal = this._valueMax();
  11587. break;
  11588. case $.ui.keyCode.PAGE_UP:
  11589. newVal = this._trimAlignValue(
  11590. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  11591. );
  11592. break;
  11593. case $.ui.keyCode.PAGE_DOWN:
  11594. newVal = this._trimAlignValue(
  11595. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  11596. break;
  11597. case $.ui.keyCode.UP:
  11598. case $.ui.keyCode.RIGHT:
  11599. if ( curVal === this._valueMax() ) {
  11600. return;
  11601. }
  11602. newVal = this._trimAlignValue( curVal + step );
  11603. break;
  11604. case $.ui.keyCode.DOWN:
  11605. case $.ui.keyCode.LEFT:
  11606. if ( curVal === this._valueMin() ) {
  11607. return;
  11608. }
  11609. newVal = this._trimAlignValue( curVal - step );
  11610. break;
  11611. }
  11612. this._slide( event, index, newVal );
  11613. },
  11614. keyup: function( event ) {
  11615. var index = $( event.target ).data( "ui-slider-handle-index" );
  11616. if ( this._keySliding ) {
  11617. this._keySliding = false;
  11618. this._stop( event, index );
  11619. this._change( event, index );
  11620. $( event.target ).removeClass( "ui-state-active" );
  11621. }
  11622. }
  11623. }
  11624. });
  11625. /*!
  11626. * jQuery UI Sortable 1.11.4
  11627. * http://jqueryui.com
  11628. *
  11629. * Copyright jQuery Foundation and other contributors
  11630. * Released under the MIT license.
  11631. * http://jquery.org/license
  11632. *
  11633. * http://api.jqueryui.com/sortable/
  11634. */
  11635. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  11636. version: "1.11.4",
  11637. widgetEventPrefix: "sort",
  11638. ready: false,
  11639. options: {
  11640. appendTo: "parent",
  11641. axis: false,
  11642. connectWith: false,
  11643. containment: false,
  11644. cursor: "auto",
  11645. cursorAt: false,
  11646. dropOnEmpty: true,
  11647. forcePlaceholderSize: false,
  11648. forceHelperSize: false,
  11649. grid: false,
  11650. handle: false,
  11651. helper: "original",
  11652. items: "> *",
  11653. opacity: false,
  11654. placeholder: false,
  11655. revert: false,
  11656. scroll: true,
  11657. scrollSensitivity: 20,
  11658. scrollSpeed: 20,
  11659. scope: "default",
  11660. tolerance: "intersect",
  11661. zIndex: 1000,
  11662. // callbacks
  11663. activate: null,
  11664. beforeStop: null,
  11665. change: null,
  11666. deactivate: null,
  11667. out: null,
  11668. over: null,
  11669. receive: null,
  11670. remove: null,
  11671. sort: null,
  11672. start: null,
  11673. stop: null,
  11674. update: null
  11675. },
  11676. _isOverAxis: function( x, reference, size ) {
  11677. return ( x >= reference ) && ( x < ( reference + size ) );
  11678. },
  11679. _isFloating: function( item ) {
  11680. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  11681. },
  11682. _create: function() {
  11683. this.containerCache = {};
  11684. this.element.addClass("ui-sortable");
  11685. //Get the items
  11686. this.refresh();
  11687. //Let's determine the parent's offset
  11688. this.offset = this.element.offset();
  11689. //Initialize mouse events for interaction
  11690. this._mouseInit();
  11691. this._setHandleClassName();
  11692. //We're ready to go
  11693. this.ready = true;
  11694. },
  11695. _setOption: function( key, value ) {
  11696. this._super( key, value );
  11697. if ( key === "handle" ) {
  11698. this._setHandleClassName();
  11699. }
  11700. },
  11701. _setHandleClassName: function() {
  11702. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  11703. $.each( this.items, function() {
  11704. ( this.instance.options.handle ?
  11705. this.item.find( this.instance.options.handle ) : this.item )
  11706. .addClass( "ui-sortable-handle" );
  11707. });
  11708. },
  11709. _destroy: function() {
  11710. this.element
  11711. .removeClass( "ui-sortable ui-sortable-disabled" )
  11712. .find( ".ui-sortable-handle" )
  11713. .removeClass( "ui-sortable-handle" );
  11714. this._mouseDestroy();
  11715. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  11716. this.items[i].item.removeData(this.widgetName + "-item");
  11717. }
  11718. return this;
  11719. },
  11720. _mouseCapture: function(event, overrideHandle) {
  11721. var currentItem = null,
  11722. validHandle = false,
  11723. that = this;
  11724. if (this.reverting) {
  11725. return false;
  11726. }
  11727. if(this.options.disabled || this.options.type === "static") {
  11728. return false;
  11729. }
  11730. //We have to refresh the items data once first
  11731. this._refreshItems(event);
  11732. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  11733. $(event.target).parents().each(function() {
  11734. if($.data(this, that.widgetName + "-item") === that) {
  11735. currentItem = $(this);
  11736. return false;
  11737. }
  11738. });
  11739. if($.data(event.target, that.widgetName + "-item") === that) {
  11740. currentItem = $(event.target);
  11741. }
  11742. if(!currentItem) {
  11743. return false;
  11744. }
  11745. if(this.options.handle && !overrideHandle) {
  11746. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  11747. if(this === event.target) {
  11748. validHandle = true;
  11749. }
  11750. });
  11751. if(!validHandle) {
  11752. return false;
  11753. }
  11754. }
  11755. this.currentItem = currentItem;
  11756. this._removeCurrentsFromItems();
  11757. return true;
  11758. },
  11759. _mouseStart: function(event, overrideHandle, noActivation) {
  11760. var i, body,
  11761. o = this.options;
  11762. this.currentContainer = this;
  11763. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  11764. this.refreshPositions();
  11765. //Create and append the visible helper
  11766. this.helper = this._createHelper(event);
  11767. //Cache the helper size
  11768. this._cacheHelperProportions();
  11769. /*
  11770. * - Position generation -
  11771. * This block generates everything position related - it's the core of draggables.
  11772. */
  11773. //Cache the margins of the original element
  11774. this._cacheMargins();
  11775. //Get the next scrolling parent
  11776. this.scrollParent = this.helper.scrollParent();
  11777. //The element's absolute position on the page minus margins
  11778. this.offset = this.currentItem.offset();
  11779. this.offset = {
  11780. top: this.offset.top - this.margins.top,
  11781. left: this.offset.left - this.margins.left
  11782. };
  11783. $.extend(this.offset, {
  11784. click: { //Where the click happened, relative to the element
  11785. left: event.pageX - this.offset.left,
  11786. top: event.pageY - this.offset.top
  11787. },
  11788. parent: this._getParentOffset(),
  11789. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  11790. });
  11791. // Only after we got the offset, we can change the helper's position to absolute
  11792. // TODO: Still need to figure out a way to make relative sorting possible
  11793. this.helper.css("position", "absolute");
  11794. this.cssPosition = this.helper.css("position");
  11795. //Generate the original position
  11796. this.originalPosition = this._generatePosition(event);
  11797. this.originalPageX = event.pageX;
  11798. this.originalPageY = event.pageY;
  11799. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  11800. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  11801. //Cache the former DOM position
  11802. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  11803. //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
  11804. if(this.helper[0] !== this.currentItem[0]) {
  11805. this.currentItem.hide();
  11806. }
  11807. //Create the placeholder
  11808. this._createPlaceholder();
  11809. //Set a containment if given in the options
  11810. if(o.containment) {
  11811. this._setContainment();
  11812. }
  11813. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  11814. body = this.document.find( "body" );
  11815. // support: IE
  11816. this.storedCursor = body.css( "cursor" );
  11817. body.css( "cursor", o.cursor );
  11818. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  11819. }
  11820. if(o.opacity) { // opacity option
  11821. if (this.helper.css("opacity")) {
  11822. this._storedOpacity = this.helper.css("opacity");
  11823. }
  11824. this.helper.css("opacity", o.opacity);
  11825. }
  11826. if(o.zIndex) { // zIndex option
  11827. if (this.helper.css("zIndex")) {
  11828. this._storedZIndex = this.helper.css("zIndex");
  11829. }
  11830. this.helper.css("zIndex", o.zIndex);
  11831. }
  11832. //Prepare scrolling
  11833. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  11834. this.overflowOffset = this.scrollParent.offset();
  11835. }
  11836. //Call callbacks
  11837. this._trigger("start", event, this._uiHash());
  11838. //Recache the helper size
  11839. if(!this._preserveHelperProportions) {
  11840. this._cacheHelperProportions();
  11841. }
  11842. //Post "activate" events to possible containers
  11843. if( !noActivation ) {
  11844. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  11845. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  11846. }
  11847. }
  11848. //Prepare possible droppables
  11849. if($.ui.ddmanager) {
  11850. $.ui.ddmanager.current = this;
  11851. }
  11852. if ($.ui.ddmanager && !o.dropBehaviour) {
  11853. $.ui.ddmanager.prepareOffsets(this, event);
  11854. }
  11855. this.dragging = true;
  11856. this.helper.addClass("ui-sortable-helper");
  11857. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  11858. return true;
  11859. },
  11860. _mouseDrag: function(event) {
  11861. var i, item, itemElement, intersection,
  11862. o = this.options,
  11863. scrolled = false;
  11864. //Compute the helpers position
  11865. this.position = this._generatePosition(event);
  11866. this.positionAbs = this._convertPositionTo("absolute");
  11867. if (!this.lastPositionAbs) {
  11868. this.lastPositionAbs = this.positionAbs;
  11869. }
  11870. //Do scrolling
  11871. if(this.options.scroll) {
  11872. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  11873. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  11874. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  11875. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  11876. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  11877. }
  11878. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  11879. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  11880. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  11881. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  11882. }
  11883. } else {
  11884. if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
  11885. scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
  11886. } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
  11887. scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
  11888. }
  11889. if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
  11890. scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
  11891. } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
  11892. scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
  11893. }
  11894. }
  11895. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  11896. $.ui.ddmanager.prepareOffsets(this, event);
  11897. }
  11898. }
  11899. //Regenerate the absolute position used for position checks
  11900. this.positionAbs = this._convertPositionTo("absolute");
  11901. //Set the helper position
  11902. if(!this.options.axis || this.options.axis !== "y") {
  11903. this.helper[0].style.left = this.position.left+"px";
  11904. }
  11905. if(!this.options.axis || this.options.axis !== "x") {
  11906. this.helper[0].style.top = this.position.top+"px";
  11907. }
  11908. //Rearrange
  11909. for (i = this.items.length - 1; i >= 0; i--) {
  11910. //Cache variables and intersection, continue if no intersection
  11911. item = this.items[i];
  11912. itemElement = item.item[0];
  11913. intersection = this._intersectsWithPointer(item);
  11914. if (!intersection) {
  11915. continue;
  11916. }
  11917. // Only put the placeholder inside the current Container, skip all
  11918. // items from other containers. This works because when moving
  11919. // an item from one container to another the
  11920. // currentContainer is switched before the placeholder is moved.
  11921. //
  11922. // Without this, moving items in "sub-sortables" can cause
  11923. // the placeholder to jitter between the outer and inner container.
  11924. if (item.instance !== this.currentContainer) {
  11925. continue;
  11926. }
  11927. // cannot intersect with itself
  11928. // no useless actions that have been done before
  11929. // no action if the item moved is the parent of the item checked
  11930. if (itemElement !== this.currentItem[0] &&
  11931. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  11932. !$.contains(this.placeholder[0], itemElement) &&
  11933. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  11934. ) {
  11935. this.direction = intersection === 1 ? "down" : "up";
  11936. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  11937. this._rearrange(event, item);
  11938. } else {
  11939. break;
  11940. }
  11941. this._trigger("change", event, this._uiHash());
  11942. break;
  11943. }
  11944. }
  11945. //Post events to containers
  11946. this._contactContainers(event);
  11947. //Interconnect with droppables
  11948. if($.ui.ddmanager) {
  11949. $.ui.ddmanager.drag(this, event);
  11950. }
  11951. //Call callbacks
  11952. this._trigger("sort", event, this._uiHash());
  11953. this.lastPositionAbs = this.positionAbs;
  11954. return false;
  11955. },
  11956. _mouseStop: function(event, noPropagation) {
  11957. if(!event) {
  11958. return;
  11959. }
  11960. //If we are using droppables, inform the manager about the drop
  11961. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  11962. $.ui.ddmanager.drop(this, event);
  11963. }
  11964. if(this.options.revert) {
  11965. var that = this,
  11966. cur = this.placeholder.offset(),
  11967. axis = this.options.axis,
  11968. animation = {};
  11969. if ( !axis || axis === "x" ) {
  11970. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
  11971. }
  11972. if ( !axis || axis === "y" ) {
  11973. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
  11974. }
  11975. this.reverting = true;
  11976. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  11977. that._clear(event);
  11978. });
  11979. } else {
  11980. this._clear(event, noPropagation);
  11981. }
  11982. return false;
  11983. },
  11984. cancel: function() {
  11985. if(this.dragging) {
  11986. this._mouseUp({ target: null });
  11987. if(this.options.helper === "original") {
  11988. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  11989. } else {
  11990. this.currentItem.show();
  11991. }
  11992. //Post deactivating events to containers
  11993. for (var i = this.containers.length - 1; i >= 0; i--){
  11994. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  11995. if(this.containers[i].containerCache.over) {
  11996. this.containers[i]._trigger("out", null, this._uiHash(this));
  11997. this.containers[i].containerCache.over = 0;
  11998. }
  11999. }
  12000. }
  12001. if (this.placeholder) {
  12002. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12003. if(this.placeholder[0].parentNode) {
  12004. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12005. }
  12006. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  12007. this.helper.remove();
  12008. }
  12009. $.extend(this, {
  12010. helper: null,
  12011. dragging: false,
  12012. reverting: false,
  12013. _noFinalSort: null
  12014. });
  12015. if(this.domPosition.prev) {
  12016. $(this.domPosition.prev).after(this.currentItem);
  12017. } else {
  12018. $(this.domPosition.parent).prepend(this.currentItem);
  12019. }
  12020. }
  12021. return this;
  12022. },
  12023. serialize: function(o) {
  12024. var items = this._getItemsAsjQuery(o && o.connected),
  12025. str = [];
  12026. o = o || {};
  12027. $(items).each(function() {
  12028. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  12029. if (res) {
  12030. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  12031. }
  12032. });
  12033. if(!str.length && o.key) {
  12034. str.push(o.key + "=");
  12035. }
  12036. return str.join("&");
  12037. },
  12038. toArray: function(o) {
  12039. var items = this._getItemsAsjQuery(o && o.connected),
  12040. ret = [];
  12041. o = o || {};
  12042. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  12043. return ret;
  12044. },
  12045. /* Be careful with the following core functions */
  12046. _intersectsWith: function(item) {
  12047. var x1 = this.positionAbs.left,
  12048. x2 = x1 + this.helperProportions.width,
  12049. y1 = this.positionAbs.top,
  12050. y2 = y1 + this.helperProportions.height,
  12051. l = item.left,
  12052. r = l + item.width,
  12053. t = item.top,
  12054. b = t + item.height,
  12055. dyClick = this.offset.click.top,
  12056. dxClick = this.offset.click.left,
  12057. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  12058. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  12059. isOverElement = isOverElementHeight && isOverElementWidth;
  12060. if ( this.options.tolerance === "pointer" ||
  12061. this.options.forcePointerForContainers ||
  12062. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  12063. ) {
  12064. return isOverElement;
  12065. } else {
  12066. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  12067. x2 - (this.helperProportions.width / 2) < r && // Left Half
  12068. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  12069. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  12070. }
  12071. },
  12072. _intersectsWithPointer: function(item) {
  12073. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  12074. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  12075. isOverElement = isOverElementHeight && isOverElementWidth,
  12076. verticalDirection = this._getDragVerticalDirection(),
  12077. horizontalDirection = this._getDragHorizontalDirection();
  12078. if (!isOverElement) {
  12079. return false;
  12080. }
  12081. return this.floating ?
  12082. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  12083. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  12084. },
  12085. _intersectsWithSides: function(item) {
  12086. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  12087. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  12088. verticalDirection = this._getDragVerticalDirection(),
  12089. horizontalDirection = this._getDragHorizontalDirection();
  12090. if (this.floating && horizontalDirection) {
  12091. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  12092. } else {
  12093. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  12094. }
  12095. },
  12096. _getDragVerticalDirection: function() {
  12097. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  12098. return delta !== 0 && (delta > 0 ? "down" : "up");
  12099. },
  12100. _getDragHorizontalDirection: function() {
  12101. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  12102. return delta !== 0 && (delta > 0 ? "right" : "left");
  12103. },
  12104. refresh: function(event) {
  12105. this._refreshItems(event);
  12106. this._setHandleClassName();
  12107. this.refreshPositions();
  12108. return this;
  12109. },
  12110. _connectWith: function() {
  12111. var options = this.options;
  12112. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  12113. },
  12114. _getItemsAsjQuery: function(connected) {
  12115. var i, j, cur, inst,
  12116. items = [],
  12117. queries = [],
  12118. connectWith = this._connectWith();
  12119. if(connectWith && connected) {
  12120. for (i = connectWith.length - 1; i >= 0; i--){
  12121. cur = $(connectWith[i], this.document[0]);
  12122. for ( j = cur.length - 1; j >= 0; j--){
  12123. inst = $.data(cur[j], this.widgetFullName);
  12124. if(inst && inst !== this && !inst.options.disabled) {
  12125. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
  12126. }
  12127. }
  12128. }
  12129. }
  12130. queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
  12131. function addItems() {
  12132. items.push( this );
  12133. }
  12134. for (i = queries.length - 1; i >= 0; i--){
  12135. queries[i][0].each( addItems );
  12136. }
  12137. return $(items);
  12138. },
  12139. _removeCurrentsFromItems: function() {
  12140. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  12141. this.items = $.grep(this.items, function (item) {
  12142. for (var j=0; j < list.length; j++) {
  12143. if(list[j] === item.item[0]) {
  12144. return false;
  12145. }
  12146. }
  12147. return true;
  12148. });
  12149. },
  12150. _refreshItems: function(event) {
  12151. this.items = [];
  12152. this.containers = [this];
  12153. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  12154. items = this.items,
  12155. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  12156. connectWith = this._connectWith();
  12157. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  12158. for (i = connectWith.length - 1; i >= 0; i--){
  12159. cur = $(connectWith[i], this.document[0]);
  12160. for (j = cur.length - 1; j >= 0; j--){
  12161. inst = $.data(cur[j], this.widgetFullName);
  12162. if(inst && inst !== this && !inst.options.disabled) {
  12163. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  12164. this.containers.push(inst);
  12165. }
  12166. }
  12167. }
  12168. }
  12169. for (i = queries.length - 1; i >= 0; i--) {
  12170. targetData = queries[i][1];
  12171. _queries = queries[i][0];
  12172. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  12173. item = $(_queries[j]);
  12174. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  12175. items.push({
  12176. item: item,
  12177. instance: targetData,
  12178. width: 0, height: 0,
  12179. left: 0, top: 0
  12180. });
  12181. }
  12182. }
  12183. },
  12184. refreshPositions: function(fast) {
  12185. // Determine whether items are being displayed horizontally
  12186. this.floating = this.items.length ?
  12187. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  12188. false;
  12189. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  12190. if(this.offsetParent && this.helper) {
  12191. this.offset.parent = this._getParentOffset();
  12192. }
  12193. var i, item, t, p;
  12194. for (i = this.items.length - 1; i >= 0; i--){
  12195. item = this.items[i];
  12196. //We ignore calculating positions of all connected containers when we're not over them
  12197. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  12198. continue;
  12199. }
  12200. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  12201. if (!fast) {
  12202. item.width = t.outerWidth();
  12203. item.height = t.outerHeight();
  12204. }
  12205. p = t.offset();
  12206. item.left = p.left;
  12207. item.top = p.top;
  12208. }
  12209. if(this.options.custom && this.options.custom.refreshContainers) {
  12210. this.options.custom.refreshContainers.call(this);
  12211. } else {
  12212. for (i = this.containers.length - 1; i >= 0; i--){
  12213. p = this.containers[i].element.offset();
  12214. this.containers[i].containerCache.left = p.left;
  12215. this.containers[i].containerCache.top = p.top;
  12216. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  12217. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  12218. }
  12219. }
  12220. return this;
  12221. },
  12222. _createPlaceholder: function(that) {
  12223. that = that || this;
  12224. var className,
  12225. o = that.options;
  12226. if(!o.placeholder || o.placeholder.constructor === String) {
  12227. className = o.placeholder;
  12228. o.placeholder = {
  12229. element: function() {
  12230. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  12231. element = $( "<" + nodeName + ">", that.document[0] )
  12232. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  12233. .removeClass("ui-sortable-helper");
  12234. if ( nodeName === "tbody" ) {
  12235. that._createTrPlaceholder(
  12236. that.currentItem.find( "tr" ).eq( 0 ),
  12237. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  12238. );
  12239. } else if ( nodeName === "tr" ) {
  12240. that._createTrPlaceholder( that.currentItem, element );
  12241. } else if ( nodeName === "img" ) {
  12242. element.attr( "src", that.currentItem.attr( "src" ) );
  12243. }
  12244. if ( !className ) {
  12245. element.css( "visibility", "hidden" );
  12246. }
  12247. return element;
  12248. },
  12249. update: function(container, p) {
  12250. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  12251. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  12252. if(className && !o.forcePlaceholderSize) {
  12253. return;
  12254. }
  12255. //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
  12256. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  12257. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  12258. }
  12259. };
  12260. }
  12261. //Create the placeholder
  12262. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  12263. //Append it after the actual current item
  12264. that.currentItem.after(that.placeholder);
  12265. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  12266. o.placeholder.update(that, that.placeholder);
  12267. },
  12268. _createTrPlaceholder: function( sourceTr, targetTr ) {
  12269. var that = this;
  12270. sourceTr.children().each(function() {
  12271. $( "<td>&#160;</td>", that.document[ 0 ] )
  12272. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  12273. .appendTo( targetTr );
  12274. });
  12275. },
  12276. _contactContainers: function(event) {
  12277. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  12278. innermostContainer = null,
  12279. innermostIndex = null;
  12280. // get innermost container that intersects with item
  12281. for (i = this.containers.length - 1; i >= 0; i--) {
  12282. // never consider a container that's located within the item itself
  12283. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  12284. continue;
  12285. }
  12286. if(this._intersectsWith(this.containers[i].containerCache)) {
  12287. // if we've already found a container and it's more "inner" than this, then continue
  12288. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  12289. continue;
  12290. }
  12291. innermostContainer = this.containers[i];
  12292. innermostIndex = i;
  12293. } else {
  12294. // container doesn't intersect. trigger "out" event if necessary
  12295. if(this.containers[i].containerCache.over) {
  12296. this.containers[i]._trigger("out", event, this._uiHash(this));
  12297. this.containers[i].containerCache.over = 0;
  12298. }
  12299. }
  12300. }
  12301. // if no intersecting containers found, return
  12302. if(!innermostContainer) {
  12303. return;
  12304. }
  12305. // move the item into the container if it's not there already
  12306. if(this.containers.length === 1) {
  12307. if (!this.containers[innermostIndex].containerCache.over) {
  12308. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12309. this.containers[innermostIndex].containerCache.over = 1;
  12310. }
  12311. } else {
  12312. //When entering a new container, we will find the item with the least distance and append our item near it
  12313. dist = 10000;
  12314. itemWithLeastDistance = null;
  12315. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  12316. posProperty = floating ? "left" : "top";
  12317. sizeProperty = floating ? "width" : "height";
  12318. axis = floating ? "clientX" : "clientY";
  12319. for (j = this.items.length - 1; j >= 0; j--) {
  12320. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  12321. continue;
  12322. }
  12323. if(this.items[j].item[0] === this.currentItem[0]) {
  12324. continue;
  12325. }
  12326. cur = this.items[j].item.offset()[posProperty];
  12327. nearBottom = false;
  12328. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  12329. nearBottom = true;
  12330. }
  12331. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  12332. dist = Math.abs( event[ axis ] - cur );
  12333. itemWithLeastDistance = this.items[ j ];
  12334. this.direction = nearBottom ? "up": "down";
  12335. }
  12336. }
  12337. //Check if dropOnEmpty is enabled
  12338. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  12339. return;
  12340. }
  12341. if(this.currentContainer === this.containers[innermostIndex]) {
  12342. if ( !this.currentContainer.containerCache.over ) {
  12343. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  12344. this.currentContainer.containerCache.over = 1;
  12345. }
  12346. return;
  12347. }
  12348. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  12349. this._trigger("change", event, this._uiHash());
  12350. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  12351. this.currentContainer = this.containers[innermostIndex];
  12352. //Update the placeholder
  12353. this.options.placeholder.update(this.currentContainer, this.placeholder);
  12354. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12355. this.containers[innermostIndex].containerCache.over = 1;
  12356. }
  12357. },
  12358. _createHelper: function(event) {
  12359. var o = this.options,
  12360. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  12361. //Add the helper to the DOM if that didn't happen already
  12362. if(!helper.parents("body").length) {
  12363. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  12364. }
  12365. if(helper[0] === this.currentItem[0]) {
  12366. this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
  12367. }
  12368. if(!helper[0].style.width || o.forceHelperSize) {
  12369. helper.width(this.currentItem.width());
  12370. }
  12371. if(!helper[0].style.height || o.forceHelperSize) {
  12372. helper.height(this.currentItem.height());
  12373. }
  12374. return helper;
  12375. },
  12376. _adjustOffsetFromHelper: function(obj) {
  12377. if (typeof obj === "string") {
  12378. obj = obj.split(" ");
  12379. }
  12380. if ($.isArray(obj)) {
  12381. obj = {left: +obj[0], top: +obj[1] || 0};
  12382. }
  12383. if ("left" in obj) {
  12384. this.offset.click.left = obj.left + this.margins.left;
  12385. }
  12386. if ("right" in obj) {
  12387. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  12388. }
  12389. if ("top" in obj) {
  12390. this.offset.click.top = obj.top + this.margins.top;
  12391. }
  12392. if ("bottom" in obj) {
  12393. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  12394. }
  12395. },
  12396. _getParentOffset: function() {
  12397. //Get the offsetParent and cache its position
  12398. this.offsetParent = this.helper.offsetParent();
  12399. var po = this.offsetParent.offset();
  12400. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  12401. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  12402. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  12403. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  12404. if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  12405. po.left += this.scrollParent.scrollLeft();
  12406. po.top += this.scrollParent.scrollTop();
  12407. }
  12408. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  12409. // with an ugly IE fix
  12410. if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  12411. po = { top: 0, left: 0 };
  12412. }
  12413. return {
  12414. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  12415. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  12416. };
  12417. },
  12418. _getRelativeOffset: function() {
  12419. if(this.cssPosition === "relative") {
  12420. var p = this.currentItem.position();
  12421. return {
  12422. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  12423. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  12424. };
  12425. } else {
  12426. return { top: 0, left: 0 };
  12427. }
  12428. },
  12429. _cacheMargins: function() {
  12430. this.margins = {
  12431. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  12432. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  12433. };
  12434. },
  12435. _cacheHelperProportions: function() {
  12436. this.helperProportions = {
  12437. width: this.helper.outerWidth(),
  12438. height: this.helper.outerHeight()
  12439. };
  12440. },
  12441. _setContainment: function() {
  12442. var ce, co, over,
  12443. o = this.options;
  12444. if(o.containment === "parent") {
  12445. o.containment = this.helper[0].parentNode;
  12446. }
  12447. if(o.containment === "document" || o.containment === "window") {
  12448. this.containment = [
  12449. 0 - this.offset.relative.left - this.offset.parent.left,
  12450. 0 - this.offset.relative.top - this.offset.parent.top,
  12451. o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
  12452. (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  12453. ];
  12454. }
  12455. if(!(/^(document|window|parent)$/).test(o.containment)) {
  12456. ce = $(o.containment)[0];
  12457. co = $(o.containment).offset();
  12458. over = ($(ce).css("overflow") !== "hidden");
  12459. this.containment = [
  12460. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  12461. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  12462. co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
  12463. co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
  12464. ];
  12465. }
  12466. },
  12467. _convertPositionTo: function(d, pos) {
  12468. if(!pos) {
  12469. pos = this.position;
  12470. }
  12471. var mod = d === "absolute" ? 1 : -1,
  12472. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  12473. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12474. return {
  12475. top: (
  12476. pos.top + // The absolute mouse position
  12477. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12478. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  12479. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  12480. ),
  12481. left: (
  12482. pos.left + // The absolute mouse position
  12483. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12484. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  12485. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  12486. )
  12487. };
  12488. },
  12489. _generatePosition: function(event) {
  12490. var top, left,
  12491. o = this.options,
  12492. pageX = event.pageX,
  12493. pageY = event.pageY,
  12494. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12495. // This is another very weird special case that only happens for relative elements:
  12496. // 1. If the css position is relative
  12497. // 2. and the scroll parent is the document or similar to the offset parent
  12498. // we have to refresh the relative offset during the scroll so there are no jumps
  12499. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
  12500. this.offset.relative = this._getRelativeOffset();
  12501. }
  12502. /*
  12503. * - Position constraining -
  12504. * Constrain the position to a mix of grid, containment.
  12505. */
  12506. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  12507. if(this.containment) {
  12508. if(event.pageX - this.offset.click.left < this.containment[0]) {
  12509. pageX = this.containment[0] + this.offset.click.left;
  12510. }
  12511. if(event.pageY - this.offset.click.top < this.containment[1]) {
  12512. pageY = this.containment[1] + this.offset.click.top;
  12513. }
  12514. if(event.pageX - this.offset.click.left > this.containment[2]) {
  12515. pageX = this.containment[2] + this.offset.click.left;
  12516. }
  12517. if(event.pageY - this.offset.click.top > this.containment[3]) {
  12518. pageY = this.containment[3] + this.offset.click.top;
  12519. }
  12520. }
  12521. if(o.grid) {
  12522. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  12523. pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  12524. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  12525. pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  12526. }
  12527. }
  12528. return {
  12529. top: (
  12530. pageY - // The absolute mouse position
  12531. this.offset.click.top - // Click offset (relative to the element)
  12532. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  12533. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  12534. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  12535. ),
  12536. left: (
  12537. pageX - // The absolute mouse position
  12538. this.offset.click.left - // Click offset (relative to the element)
  12539. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  12540. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  12541. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  12542. )
  12543. };
  12544. },
  12545. _rearrange: function(event, i, a, hardRefresh) {
  12546. a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
  12547. //Various things done here to improve the performance:
  12548. // 1. we create a setTimeout, that calls refreshPositions
  12549. // 2. on the instance, we have a counter variable, that get's higher after every append
  12550. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  12551. // 4. this lets only the last addition to the timeout stack through
  12552. this.counter = this.counter ? ++this.counter : 1;
  12553. var counter = this.counter;
  12554. this._delay(function() {
  12555. if(counter === this.counter) {
  12556. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  12557. }
  12558. });
  12559. },
  12560. _clear: function(event, noPropagation) {
  12561. this.reverting = false;
  12562. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  12563. // everything else normalized again
  12564. var i,
  12565. delayedTriggers = [];
  12566. // We first have to update the dom position of the actual currentItem
  12567. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  12568. if(!this._noFinalSort && this.currentItem.parent().length) {
  12569. this.placeholder.before(this.currentItem);
  12570. }
  12571. this._noFinalSort = null;
  12572. if(this.helper[0] === this.currentItem[0]) {
  12573. for(i in this._storedCSS) {
  12574. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  12575. this._storedCSS[i] = "";
  12576. }
  12577. }
  12578. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  12579. } else {
  12580. this.currentItem.show();
  12581. }
  12582. if(this.fromOutside && !noPropagation) {
  12583. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  12584. }
  12585. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  12586. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  12587. }
  12588. // Check if the items Container has Changed and trigger appropriate
  12589. // events.
  12590. if (this !== this.currentContainer) {
  12591. if(!noPropagation) {
  12592. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  12593. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12594. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12595. }
  12596. }
  12597. //Post events to containers
  12598. function delayEvent( type, instance, container ) {
  12599. return function( event ) {
  12600. container._trigger( type, event, instance._uiHash( instance ) );
  12601. };
  12602. }
  12603. for (i = this.containers.length - 1; i >= 0; i--){
  12604. if (!noPropagation) {
  12605. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  12606. }
  12607. if(this.containers[i].containerCache.over) {
  12608. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  12609. this.containers[i].containerCache.over = 0;
  12610. }
  12611. }
  12612. //Do what was originally in plugins
  12613. if ( this.storedCursor ) {
  12614. this.document.find( "body" ).css( "cursor", this.storedCursor );
  12615. this.storedStylesheet.remove();
  12616. }
  12617. if(this._storedOpacity) {
  12618. this.helper.css("opacity", this._storedOpacity);
  12619. }
  12620. if(this._storedZIndex) {
  12621. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  12622. }
  12623. this.dragging = false;
  12624. if(!noPropagation) {
  12625. this._trigger("beforeStop", event, this._uiHash());
  12626. }
  12627. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12628. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12629. if ( !this.cancelHelperRemoval ) {
  12630. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  12631. this.helper.remove();
  12632. }
  12633. this.helper = null;
  12634. }
  12635. if(!noPropagation) {
  12636. for (i=0; i < delayedTriggers.length; i++) {
  12637. delayedTriggers[i].call(this, event);
  12638. } //Trigger all delayed events
  12639. this._trigger("stop", event, this._uiHash());
  12640. }
  12641. this.fromOutside = false;
  12642. return !this.cancelHelperRemoval;
  12643. },
  12644. _trigger: function() {
  12645. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  12646. this.cancel();
  12647. }
  12648. },
  12649. _uiHash: function(_inst) {
  12650. var inst = _inst || this;
  12651. return {
  12652. helper: inst.helper,
  12653. placeholder: inst.placeholder || $([]),
  12654. position: inst.position,
  12655. originalPosition: inst.originalPosition,
  12656. offset: inst.positionAbs,
  12657. item: inst.currentItem,
  12658. sender: _inst ? _inst.element : null
  12659. };
  12660. }
  12661. });
  12662. /*!
  12663. * jQuery UI Spinner 1.11.4
  12664. * http://jqueryui.com
  12665. *
  12666. * Copyright jQuery Foundation and other contributors
  12667. * Released under the MIT license.
  12668. * http://jquery.org/license
  12669. *
  12670. * http://api.jqueryui.com/spinner/
  12671. */
  12672. function spinner_modifier( fn ) {
  12673. return function() {
  12674. var previous = this.element.val();
  12675. fn.apply( this, arguments );
  12676. this._refresh();
  12677. if ( previous !== this.element.val() ) {
  12678. this._trigger( "change" );
  12679. }
  12680. };
  12681. }
  12682. var spinner = $.widget( "ui.spinner", {
  12683. version: "1.11.4",
  12684. defaultElement: "<input>",
  12685. widgetEventPrefix: "spin",
  12686. options: {
  12687. culture: null,
  12688. icons: {
  12689. down: "ui-icon-triangle-1-s",
  12690. up: "ui-icon-triangle-1-n"
  12691. },
  12692. incremental: true,
  12693. max: null,
  12694. min: null,
  12695. numberFormat: null,
  12696. page: 10,
  12697. step: 1,
  12698. change: null,
  12699. spin: null,
  12700. start: null,
  12701. stop: null
  12702. },
  12703. _create: function() {
  12704. // handle string values that need to be parsed
  12705. this._setOption( "max", this.options.max );
  12706. this._setOption( "min", this.options.min );
  12707. this._setOption( "step", this.options.step );
  12708. // Only format if there is a value, prevents the field from being marked
  12709. // as invalid in Firefox, see #9573.
  12710. if ( this.value() !== "" ) {
  12711. // Format the value, but don't constrain.
  12712. this._value( this.element.val(), true );
  12713. }
  12714. this._draw();
  12715. this._on( this._events );
  12716. this._refresh();
  12717. // turning off autocomplete prevents the browser from remembering the
  12718. // value when navigating through history, so we re-enable autocomplete
  12719. // if the page is unloaded before the widget is destroyed. #7790
  12720. this._on( this.window, {
  12721. beforeunload: function() {
  12722. this.element.removeAttr( "autocomplete" );
  12723. }
  12724. });
  12725. },
  12726. _getCreateOptions: function() {
  12727. var options = {},
  12728. element = this.element;
  12729. $.each( [ "min", "max", "step" ], function( i, option ) {
  12730. var value = element.attr( option );
  12731. if ( value !== undefined && value.length ) {
  12732. options[ option ] = value;
  12733. }
  12734. });
  12735. return options;
  12736. },
  12737. _events: {
  12738. keydown: function( event ) {
  12739. if ( this._start( event ) && this._keydown( event ) ) {
  12740. event.preventDefault();
  12741. }
  12742. },
  12743. keyup: "_stop",
  12744. focus: function() {
  12745. this.previous = this.element.val();
  12746. },
  12747. blur: function( event ) {
  12748. if ( this.cancelBlur ) {
  12749. delete this.cancelBlur;
  12750. return;
  12751. }
  12752. this._stop();
  12753. this._refresh();
  12754. if ( this.previous !== this.element.val() ) {
  12755. this._trigger( "change", event );
  12756. }
  12757. },
  12758. mousewheel: function( event, delta ) {
  12759. if ( !delta ) {
  12760. return;
  12761. }
  12762. if ( !this.spinning && !this._start( event ) ) {
  12763. return false;
  12764. }
  12765. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  12766. clearTimeout( this.mousewheelTimer );
  12767. this.mousewheelTimer = this._delay(function() {
  12768. if ( this.spinning ) {
  12769. this._stop( event );
  12770. }
  12771. }, 100 );
  12772. event.preventDefault();
  12773. },
  12774. "mousedown .ui-spinner-button": function( event ) {
  12775. var previous;
  12776. // We never want the buttons to have focus; whenever the user is
  12777. // interacting with the spinner, the focus should be on the input.
  12778. // If the input is focused then this.previous is properly set from
  12779. // when the input first received focus. If the input is not focused
  12780. // then we need to set this.previous based on the value before spinning.
  12781. previous = this.element[0] === this.document[0].activeElement ?
  12782. this.previous : this.element.val();
  12783. function checkFocus() {
  12784. var isActive = this.element[0] === this.document[0].activeElement;
  12785. if ( !isActive ) {
  12786. this.element.focus();
  12787. this.previous = previous;
  12788. // support: IE
  12789. // IE sets focus asynchronously, so we need to check if focus
  12790. // moved off of the input because the user clicked on the button.
  12791. this._delay(function() {
  12792. this.previous = previous;
  12793. });
  12794. }
  12795. }
  12796. // ensure focus is on (or stays on) the text field
  12797. event.preventDefault();
  12798. checkFocus.call( this );
  12799. // support: IE
  12800. // IE doesn't prevent moving focus even with event.preventDefault()
  12801. // so we set a flag to know when we should ignore the blur event
  12802. // and check (again) if focus moved off of the input.
  12803. this.cancelBlur = true;
  12804. this._delay(function() {
  12805. delete this.cancelBlur;
  12806. checkFocus.call( this );
  12807. });
  12808. if ( this._start( event ) === false ) {
  12809. return;
  12810. }
  12811. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12812. },
  12813. "mouseup .ui-spinner-button": "_stop",
  12814. "mouseenter .ui-spinner-button": function( event ) {
  12815. // button will add ui-state-active if mouse was down while mouseleave and kept down
  12816. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  12817. return;
  12818. }
  12819. if ( this._start( event ) === false ) {
  12820. return false;
  12821. }
  12822. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12823. },
  12824. // TODO: do we really want to consider this a stop?
  12825. // shouldn't we just stop the repeater and wait until mouseup before
  12826. // we trigger the stop event?
  12827. "mouseleave .ui-spinner-button": "_stop"
  12828. },
  12829. _draw: function() {
  12830. var uiSpinner = this.uiSpinner = this.element
  12831. .addClass( "ui-spinner-input" )
  12832. .attr( "autocomplete", "off" )
  12833. .wrap( this._uiSpinnerHtml() )
  12834. .parent()
  12835. // add buttons
  12836. .append( this._buttonHtml() );
  12837. this.element.attr( "role", "spinbutton" );
  12838. // button bindings
  12839. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  12840. .attr( "tabIndex", -1 )
  12841. .button()
  12842. .removeClass( "ui-corner-all" );
  12843. // IE 6 doesn't understand height: 50% for the buttons
  12844. // unless the wrapper has an explicit height
  12845. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  12846. uiSpinner.height() > 0 ) {
  12847. uiSpinner.height( uiSpinner.height() );
  12848. }
  12849. // disable spinner if element was already disabled
  12850. if ( this.options.disabled ) {
  12851. this.disable();
  12852. }
  12853. },
  12854. _keydown: function( event ) {
  12855. var options = this.options,
  12856. keyCode = $.ui.keyCode;
  12857. switch ( event.keyCode ) {
  12858. case keyCode.UP:
  12859. this._repeat( null, 1, event );
  12860. return true;
  12861. case keyCode.DOWN:
  12862. this._repeat( null, -1, event );
  12863. return true;
  12864. case keyCode.PAGE_UP:
  12865. this._repeat( null, options.page, event );
  12866. return true;
  12867. case keyCode.PAGE_DOWN:
  12868. this._repeat( null, -options.page, event );
  12869. return true;
  12870. }
  12871. return false;
  12872. },
  12873. _uiSpinnerHtml: function() {
  12874. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  12875. },
  12876. _buttonHtml: function() {
  12877. return "" +
  12878. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  12879. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  12880. "</a>" +
  12881. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  12882. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  12883. "</a>";
  12884. },
  12885. _start: function( event ) {
  12886. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  12887. return false;
  12888. }
  12889. if ( !this.counter ) {
  12890. this.counter = 1;
  12891. }
  12892. this.spinning = true;
  12893. return true;
  12894. },
  12895. _repeat: function( i, steps, event ) {
  12896. i = i || 500;
  12897. clearTimeout( this.timer );
  12898. this.timer = this._delay(function() {
  12899. this._repeat( 40, steps, event );
  12900. }, i );
  12901. this._spin( steps * this.options.step, event );
  12902. },
  12903. _spin: function( step, event ) {
  12904. var value = this.value() || 0;
  12905. if ( !this.counter ) {
  12906. this.counter = 1;
  12907. }
  12908. value = this._adjustValue( value + step * this._increment( this.counter ) );
  12909. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  12910. this._value( value );
  12911. this.counter++;
  12912. }
  12913. },
  12914. _increment: function( i ) {
  12915. var incremental = this.options.incremental;
  12916. if ( incremental ) {
  12917. return $.isFunction( incremental ) ?
  12918. incremental( i ) :
  12919. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  12920. }
  12921. return 1;
  12922. },
  12923. _precision: function() {
  12924. var precision = this._precisionOf( this.options.step );
  12925. if ( this.options.min !== null ) {
  12926. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12927. }
  12928. return precision;
  12929. },
  12930. _precisionOf: function( num ) {
  12931. var str = num.toString(),
  12932. decimal = str.indexOf( "." );
  12933. return decimal === -1 ? 0 : str.length - decimal - 1;
  12934. },
  12935. _adjustValue: function( value ) {
  12936. var base, aboveMin,
  12937. options = this.options;
  12938. // make sure we're at a valid step
  12939. // - find out where we are relative to the base (min or 0)
  12940. base = options.min !== null ? options.min : 0;
  12941. aboveMin = value - base;
  12942. // - round to the nearest step
  12943. aboveMin = Math.round(aboveMin / options.step) * options.step;
  12944. // - rounding is based on 0, so adjust back to our base
  12945. value = base + aboveMin;
  12946. // fix precision from bad JS floating point math
  12947. value = parseFloat( value.toFixed( this._precision() ) );
  12948. // clamp the value
  12949. if ( options.max !== null && value > options.max) {
  12950. return options.max;
  12951. }
  12952. if ( options.min !== null && value < options.min ) {
  12953. return options.min;
  12954. }
  12955. return value;
  12956. },
  12957. _stop: function( event ) {
  12958. if ( !this.spinning ) {
  12959. return;
  12960. }
  12961. clearTimeout( this.timer );
  12962. clearTimeout( this.mousewheelTimer );
  12963. this.counter = 0;
  12964. this.spinning = false;
  12965. this._trigger( "stop", event );
  12966. },
  12967. _setOption: function( key, value ) {
  12968. if ( key === "culture" || key === "numberFormat" ) {
  12969. var prevValue = this._parse( this.element.val() );
  12970. this.options[ key ] = value;
  12971. this.element.val( this._format( prevValue ) );
  12972. return;
  12973. }
  12974. if ( key === "max" || key === "min" || key === "step" ) {
  12975. if ( typeof value === "string" ) {
  12976. value = this._parse( value );
  12977. }
  12978. }
  12979. if ( key === "icons" ) {
  12980. this.buttons.first().find( ".ui-icon" )
  12981. .removeClass( this.options.icons.up )
  12982. .addClass( value.up );
  12983. this.buttons.last().find( ".ui-icon" )
  12984. .removeClass( this.options.icons.down )
  12985. .addClass( value.down );
  12986. }
  12987. this._super( key, value );
  12988. if ( key === "disabled" ) {
  12989. this.widget().toggleClass( "ui-state-disabled", !!value );
  12990. this.element.prop( "disabled", !!value );
  12991. this.buttons.button( value ? "disable" : "enable" );
  12992. }
  12993. },
  12994. _setOptions: spinner_modifier(function( options ) {
  12995. this._super( options );
  12996. }),
  12997. _parse: function( val ) {
  12998. if ( typeof val === "string" && val !== "" ) {
  12999. val = window.Globalize && this.options.numberFormat ?
  13000. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  13001. }
  13002. return val === "" || isNaN( val ) ? null : val;
  13003. },
  13004. _format: function( value ) {
  13005. if ( value === "" ) {
  13006. return "";
  13007. }
  13008. return window.Globalize && this.options.numberFormat ?
  13009. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  13010. value;
  13011. },
  13012. _refresh: function() {
  13013. this.element.attr({
  13014. "aria-valuemin": this.options.min,
  13015. "aria-valuemax": this.options.max,
  13016. // TODO: what should we do with values that can't be parsed?
  13017. "aria-valuenow": this._parse( this.element.val() )
  13018. });
  13019. },
  13020. isValid: function() {
  13021. var value = this.value();
  13022. // null is invalid
  13023. if ( value === null ) {
  13024. return false;
  13025. }
  13026. // if value gets adjusted, it's invalid
  13027. return value === this._adjustValue( value );
  13028. },
  13029. // update the value without triggering change
  13030. _value: function( value, allowAny ) {
  13031. var parsed;
  13032. if ( value !== "" ) {
  13033. parsed = this._parse( value );
  13034. if ( parsed !== null ) {
  13035. if ( !allowAny ) {
  13036. parsed = this._adjustValue( parsed );
  13037. }
  13038. value = this._format( parsed );
  13039. }
  13040. }
  13041. this.element.val( value );
  13042. this._refresh();
  13043. },
  13044. _destroy: function() {
  13045. this.element
  13046. .removeClass( "ui-spinner-input" )
  13047. .prop( "disabled", false )
  13048. .removeAttr( "autocomplete" )
  13049. .removeAttr( "role" )
  13050. .removeAttr( "aria-valuemin" )
  13051. .removeAttr( "aria-valuemax" )
  13052. .removeAttr( "aria-valuenow" );
  13053. this.uiSpinner.replaceWith( this.element );
  13054. },
  13055. stepUp: spinner_modifier(function( steps ) {
  13056. this._stepUp( steps );
  13057. }),
  13058. _stepUp: function( steps ) {
  13059. if ( this._start() ) {
  13060. this._spin( (steps || 1) * this.options.step );
  13061. this._stop();
  13062. }
  13063. },
  13064. stepDown: spinner_modifier(function( steps ) {
  13065. this._stepDown( steps );
  13066. }),
  13067. _stepDown: function( steps ) {
  13068. if ( this._start() ) {
  13069. this._spin( (steps || 1) * -this.options.step );
  13070. this._stop();
  13071. }
  13072. },
  13073. pageUp: spinner_modifier(function( pages ) {
  13074. this._stepUp( (pages || 1) * this.options.page );
  13075. }),
  13076. pageDown: spinner_modifier(function( pages ) {
  13077. this._stepDown( (pages || 1) * this.options.page );
  13078. }),
  13079. value: function( newVal ) {
  13080. if ( !arguments.length ) {
  13081. return this._parse( this.element.val() );
  13082. }
  13083. spinner_modifier( this._value ).call( this, newVal );
  13084. },
  13085. widget: function() {
  13086. return this.uiSpinner;
  13087. }
  13088. });
  13089. /*!
  13090. * jQuery UI Tabs 1.11.4
  13091. * http://jqueryui.com
  13092. *
  13093. * Copyright jQuery Foundation and other contributors
  13094. * Released under the MIT license.
  13095. * http://jquery.org/license
  13096. *
  13097. * http://api.jqueryui.com/tabs/
  13098. */
  13099. var tabs = $.widget( "ui.tabs", {
  13100. version: "1.11.4",
  13101. delay: 300,
  13102. options: {
  13103. active: null,
  13104. collapsible: false,
  13105. event: "click",
  13106. heightStyle: "content",
  13107. hide: null,
  13108. show: null,
  13109. // callbacks
  13110. activate: null,
  13111. beforeActivate: null,
  13112. beforeLoad: null,
  13113. load: null
  13114. },
  13115. _isLocal: (function() {
  13116. var rhash = /#.*$/;
  13117. return function( anchor ) {
  13118. var anchorUrl, locationUrl;
  13119. // support: IE7
  13120. // IE7 doesn't normalize the href property when set via script (#9317)
  13121. anchor = anchor.cloneNode( false );
  13122. anchorUrl = anchor.href.replace( rhash, "" );
  13123. locationUrl = location.href.replace( rhash, "" );
  13124. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  13125. try {
  13126. anchorUrl = decodeURIComponent( anchorUrl );
  13127. } catch ( error ) {}
  13128. try {
  13129. locationUrl = decodeURIComponent( locationUrl );
  13130. } catch ( error ) {}
  13131. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  13132. };
  13133. })(),
  13134. _create: function() {
  13135. var that = this,
  13136. options = this.options;
  13137. this.running = false;
  13138. this.element
  13139. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  13140. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  13141. this._processTabs();
  13142. options.active = this._initialActive();
  13143. // Take disabling tabs via class attribute from HTML
  13144. // into account and update option properly.
  13145. if ( $.isArray( options.disabled ) ) {
  13146. options.disabled = $.unique( options.disabled.concat(
  13147. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  13148. return that.tabs.index( li );
  13149. })
  13150. ) ).sort();
  13151. }
  13152. // check for length avoids error when initializing empty list
  13153. if ( this.options.active !== false && this.anchors.length ) {
  13154. this.active = this._findActive( options.active );
  13155. } else {
  13156. this.active = $();
  13157. }
  13158. this._refresh();
  13159. if ( this.active.length ) {
  13160. this.load( options.active );
  13161. }
  13162. },
  13163. _initialActive: function() {
  13164. var active = this.options.active,
  13165. collapsible = this.options.collapsible,
  13166. locationHash = location.hash.substring( 1 );
  13167. if ( active === null ) {
  13168. // check the fragment identifier in the URL
  13169. if ( locationHash ) {
  13170. this.tabs.each(function( i, tab ) {
  13171. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  13172. active = i;
  13173. return false;
  13174. }
  13175. });
  13176. }
  13177. // check for a tab marked active via a class
  13178. if ( active === null ) {
  13179. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  13180. }
  13181. // no active tab, set to false
  13182. if ( active === null || active === -1 ) {
  13183. active = this.tabs.length ? 0 : false;
  13184. }
  13185. }
  13186. // handle numbers: negative, out of range
  13187. if ( active !== false ) {
  13188. active = this.tabs.index( this.tabs.eq( active ) );
  13189. if ( active === -1 ) {
  13190. active = collapsible ? false : 0;
  13191. }
  13192. }
  13193. // don't allow collapsible: false and active: false
  13194. if ( !collapsible && active === false && this.anchors.length ) {
  13195. active = 0;
  13196. }
  13197. return active;
  13198. },
  13199. _getCreateEventData: function() {
  13200. return {
  13201. tab: this.active,
  13202. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  13203. };
  13204. },
  13205. _tabKeydown: function( event ) {
  13206. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  13207. selectedIndex = this.tabs.index( focusedTab ),
  13208. goingForward = true;
  13209. if ( this._handlePageNav( event ) ) {
  13210. return;
  13211. }
  13212. switch ( event.keyCode ) {
  13213. case $.ui.keyCode.RIGHT:
  13214. case $.ui.keyCode.DOWN:
  13215. selectedIndex++;
  13216. break;
  13217. case $.ui.keyCode.UP:
  13218. case $.ui.keyCode.LEFT:
  13219. goingForward = false;
  13220. selectedIndex--;
  13221. break;
  13222. case $.ui.keyCode.END:
  13223. selectedIndex = this.anchors.length - 1;
  13224. break;
  13225. case $.ui.keyCode.HOME:
  13226. selectedIndex = 0;
  13227. break;
  13228. case $.ui.keyCode.SPACE:
  13229. // Activate only, no collapsing
  13230. event.preventDefault();
  13231. clearTimeout( this.activating );
  13232. this._activate( selectedIndex );
  13233. return;
  13234. case $.ui.keyCode.ENTER:
  13235. // Toggle (cancel delayed activation, allow collapsing)
  13236. event.preventDefault();
  13237. clearTimeout( this.activating );
  13238. // Determine if we should collapse or activate
  13239. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  13240. return;
  13241. default:
  13242. return;
  13243. }
  13244. // Focus the appropriate tab, based on which key was pressed
  13245. event.preventDefault();
  13246. clearTimeout( this.activating );
  13247. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  13248. // Navigating with control/command key will prevent automatic activation
  13249. if ( !event.ctrlKey && !event.metaKey ) {
  13250. // Update aria-selected immediately so that AT think the tab is already selected.
  13251. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  13252. // but the tab will already be activated by the time the announcement finishes.
  13253. focusedTab.attr( "aria-selected", "false" );
  13254. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  13255. this.activating = this._delay(function() {
  13256. this.option( "active", selectedIndex );
  13257. }, this.delay );
  13258. }
  13259. },
  13260. _panelKeydown: function( event ) {
  13261. if ( this._handlePageNav( event ) ) {
  13262. return;
  13263. }
  13264. // Ctrl+up moves focus to the current tab
  13265. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  13266. event.preventDefault();
  13267. this.active.focus();
  13268. }
  13269. },
  13270. // Alt+page up/down moves focus to the previous/next tab (and activates)
  13271. _handlePageNav: function( event ) {
  13272. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  13273. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  13274. return true;
  13275. }
  13276. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  13277. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  13278. return true;
  13279. }
  13280. },
  13281. _findNextTab: function( index, goingForward ) {
  13282. var lastTabIndex = this.tabs.length - 1;
  13283. function constrain() {
  13284. if ( index > lastTabIndex ) {
  13285. index = 0;
  13286. }
  13287. if ( index < 0 ) {
  13288. index = lastTabIndex;
  13289. }
  13290. return index;
  13291. }
  13292. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  13293. index = goingForward ? index + 1 : index - 1;
  13294. }
  13295. return index;
  13296. },
  13297. _focusNextTab: function( index, goingForward ) {
  13298. index = this._findNextTab( index, goingForward );
  13299. this.tabs.eq( index ).focus();
  13300. return index;
  13301. },
  13302. _setOption: function( key, value ) {
  13303. if ( key === "active" ) {
  13304. // _activate() will handle invalid values and update this.options
  13305. this._activate( value );
  13306. return;
  13307. }
  13308. if ( key === "disabled" ) {
  13309. // don't use the widget factory's disabled handling
  13310. this._setupDisabled( value );
  13311. return;
  13312. }
  13313. this._super( key, value);
  13314. if ( key === "collapsible" ) {
  13315. this.element.toggleClass( "ui-tabs-collapsible", value );
  13316. // Setting collapsible: false while collapsed; open first panel
  13317. if ( !value && this.options.active === false ) {
  13318. this._activate( 0 );
  13319. }
  13320. }
  13321. if ( key === "event" ) {
  13322. this._setupEvents( value );
  13323. }
  13324. if ( key === "heightStyle" ) {
  13325. this._setupHeightStyle( value );
  13326. }
  13327. },
  13328. _sanitizeSelector: function( hash ) {
  13329. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  13330. },
  13331. refresh: function() {
  13332. var options = this.options,
  13333. lis = this.tablist.children( ":has(a[href])" );
  13334. // get disabled tabs from class attribute from HTML
  13335. // this will get converted to a boolean if needed in _refresh()
  13336. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  13337. return lis.index( tab );
  13338. });
  13339. this._processTabs();
  13340. // was collapsed or no tabs
  13341. if ( options.active === false || !this.anchors.length ) {
  13342. options.active = false;
  13343. this.active = $();
  13344. // was active, but active tab is gone
  13345. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  13346. // all remaining tabs are disabled
  13347. if ( this.tabs.length === options.disabled.length ) {
  13348. options.active = false;
  13349. this.active = $();
  13350. // activate previous tab
  13351. } else {
  13352. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  13353. }
  13354. // was active, active tab still exists
  13355. } else {
  13356. // make sure active index is correct
  13357. options.active = this.tabs.index( this.active );
  13358. }
  13359. this._refresh();
  13360. },
  13361. _refresh: function() {
  13362. this._setupDisabled( this.options.disabled );
  13363. this._setupEvents( this.options.event );
  13364. this._setupHeightStyle( this.options.heightStyle );
  13365. this.tabs.not( this.active ).attr({
  13366. "aria-selected": "false",
  13367. "aria-expanded": "false",
  13368. tabIndex: -1
  13369. });
  13370. this.panels.not( this._getPanelForTab( this.active ) )
  13371. .hide()
  13372. .attr({
  13373. "aria-hidden": "true"
  13374. });
  13375. // Make sure one tab is in the tab order
  13376. if ( !this.active.length ) {
  13377. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  13378. } else {
  13379. this.active
  13380. .addClass( "ui-tabs-active ui-state-active" )
  13381. .attr({
  13382. "aria-selected": "true",
  13383. "aria-expanded": "true",
  13384. tabIndex: 0
  13385. });
  13386. this._getPanelForTab( this.active )
  13387. .show()
  13388. .attr({
  13389. "aria-hidden": "false"
  13390. });
  13391. }
  13392. },
  13393. _processTabs: function() {
  13394. var that = this,
  13395. prevTabs = this.tabs,
  13396. prevAnchors = this.anchors,
  13397. prevPanels = this.panels;
  13398. this.tablist = this._getList()
  13399. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13400. .attr( "role", "tablist" )
  13401. // Prevent users from focusing disabled tabs via click
  13402. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  13403. if ( $( this ).is( ".ui-state-disabled" ) ) {
  13404. event.preventDefault();
  13405. }
  13406. })
  13407. // support: IE <9
  13408. // Preventing the default action in mousedown doesn't prevent IE
  13409. // from focusing the element, so if the anchor gets focused, blur.
  13410. // We don't have to worry about focusing the previously focused
  13411. // element since clicking on a non-focusable element should focus
  13412. // the body anyway.
  13413. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  13414. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  13415. this.blur();
  13416. }
  13417. });
  13418. this.tabs = this.tablist.find( "> li:has(a[href])" )
  13419. .addClass( "ui-state-default ui-corner-top" )
  13420. .attr({
  13421. role: "tab",
  13422. tabIndex: -1
  13423. });
  13424. this.anchors = this.tabs.map(function() {
  13425. return $( "a", this )[ 0 ];
  13426. })
  13427. .addClass( "ui-tabs-anchor" )
  13428. .attr({
  13429. role: "presentation",
  13430. tabIndex: -1
  13431. });
  13432. this.panels = $();
  13433. this.anchors.each(function( i, anchor ) {
  13434. var selector, panel, panelId,
  13435. anchorId = $( anchor ).uniqueId().attr( "id" ),
  13436. tab = $( anchor ).closest( "li" ),
  13437. originalAriaControls = tab.attr( "aria-controls" );
  13438. // inline tab
  13439. if ( that._isLocal( anchor ) ) {
  13440. selector = anchor.hash;
  13441. panelId = selector.substring( 1 );
  13442. panel = that.element.find( that._sanitizeSelector( selector ) );
  13443. // remote tab
  13444. } else {
  13445. // If the tab doesn't already have aria-controls,
  13446. // generate an id by using a throw-away element
  13447. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  13448. selector = "#" + panelId;
  13449. panel = that.element.find( selector );
  13450. if ( !panel.length ) {
  13451. panel = that._createPanel( panelId );
  13452. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  13453. }
  13454. panel.attr( "aria-live", "polite" );
  13455. }
  13456. if ( panel.length) {
  13457. that.panels = that.panels.add( panel );
  13458. }
  13459. if ( originalAriaControls ) {
  13460. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  13461. }
  13462. tab.attr({
  13463. "aria-controls": panelId,
  13464. "aria-labelledby": anchorId
  13465. });
  13466. panel.attr( "aria-labelledby", anchorId );
  13467. });
  13468. this.panels
  13469. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13470. .attr( "role", "tabpanel" );
  13471. // Avoid memory leaks (#10056)
  13472. if ( prevTabs ) {
  13473. this._off( prevTabs.not( this.tabs ) );
  13474. this._off( prevAnchors.not( this.anchors ) );
  13475. this._off( prevPanels.not( this.panels ) );
  13476. }
  13477. },
  13478. // allow overriding how to find the list for rare usage scenarios (#7715)
  13479. _getList: function() {
  13480. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  13481. },
  13482. _createPanel: function( id ) {
  13483. return $( "<div>" )
  13484. .attr( "id", id )
  13485. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13486. .data( "ui-tabs-destroy", true );
  13487. },
  13488. _setupDisabled: function( disabled ) {
  13489. if ( $.isArray( disabled ) ) {
  13490. if ( !disabled.length ) {
  13491. disabled = false;
  13492. } else if ( disabled.length === this.anchors.length ) {
  13493. disabled = true;
  13494. }
  13495. }
  13496. // disable tabs
  13497. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  13498. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  13499. $( li )
  13500. .addClass( "ui-state-disabled" )
  13501. .attr( "aria-disabled", "true" );
  13502. } else {
  13503. $( li )
  13504. .removeClass( "ui-state-disabled" )
  13505. .removeAttr( "aria-disabled" );
  13506. }
  13507. }
  13508. this.options.disabled = disabled;
  13509. },
  13510. _setupEvents: function( event ) {
  13511. var events = {};
  13512. if ( event ) {
  13513. $.each( event.split(" "), function( index, eventName ) {
  13514. events[ eventName ] = "_eventHandler";
  13515. });
  13516. }
  13517. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  13518. // Always prevent the default action, even when disabled
  13519. this._on( true, this.anchors, {
  13520. click: function( event ) {
  13521. event.preventDefault();
  13522. }
  13523. });
  13524. this._on( this.anchors, events );
  13525. this._on( this.tabs, { keydown: "_tabKeydown" } );
  13526. this._on( this.panels, { keydown: "_panelKeydown" } );
  13527. this._focusable( this.tabs );
  13528. this._hoverable( this.tabs );
  13529. },
  13530. _setupHeightStyle: function( heightStyle ) {
  13531. var maxHeight,
  13532. parent = this.element.parent();
  13533. if ( heightStyle === "fill" ) {
  13534. maxHeight = parent.height();
  13535. maxHeight -= this.element.outerHeight() - this.element.height();
  13536. this.element.siblings( ":visible" ).each(function() {
  13537. var elem = $( this ),
  13538. position = elem.css( "position" );
  13539. if ( position === "absolute" || position === "fixed" ) {
  13540. return;
  13541. }
  13542. maxHeight -= elem.outerHeight( true );
  13543. });
  13544. this.element.children().not( this.panels ).each(function() {
  13545. maxHeight -= $( this ).outerHeight( true );
  13546. });
  13547. this.panels.each(function() {
  13548. $( this ).height( Math.max( 0, maxHeight -
  13549. $( this ).innerHeight() + $( this ).height() ) );
  13550. })
  13551. .css( "overflow", "auto" );
  13552. } else if ( heightStyle === "auto" ) {
  13553. maxHeight = 0;
  13554. this.panels.each(function() {
  13555. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  13556. }).height( maxHeight );
  13557. }
  13558. },
  13559. _eventHandler: function( event ) {
  13560. var options = this.options,
  13561. active = this.active,
  13562. anchor = $( event.currentTarget ),
  13563. tab = anchor.closest( "li" ),
  13564. clickedIsActive = tab[ 0 ] === active[ 0 ],
  13565. collapsing = clickedIsActive && options.collapsible,
  13566. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  13567. toHide = !active.length ? $() : this._getPanelForTab( active ),
  13568. eventData = {
  13569. oldTab: active,
  13570. oldPanel: toHide,
  13571. newTab: collapsing ? $() : tab,
  13572. newPanel: toShow
  13573. };
  13574. event.preventDefault();
  13575. if ( tab.hasClass( "ui-state-disabled" ) ||
  13576. // tab is already loading
  13577. tab.hasClass( "ui-tabs-loading" ) ||
  13578. // can't switch durning an animation
  13579. this.running ||
  13580. // click on active header, but not collapsible
  13581. ( clickedIsActive && !options.collapsible ) ||
  13582. // allow canceling activation
  13583. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  13584. return;
  13585. }
  13586. options.active = collapsing ? false : this.tabs.index( tab );
  13587. this.active = clickedIsActive ? $() : tab;
  13588. if ( this.xhr ) {
  13589. this.xhr.abort();
  13590. }
  13591. if ( !toHide.length && !toShow.length ) {
  13592. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  13593. }
  13594. if ( toShow.length ) {
  13595. this.load( this.tabs.index( tab ), event );
  13596. }
  13597. this._toggle( event, eventData );
  13598. },
  13599. // handles show/hide for selecting tabs
  13600. _toggle: function( event, eventData ) {
  13601. var that = this,
  13602. toShow = eventData.newPanel,
  13603. toHide = eventData.oldPanel;
  13604. this.running = true;
  13605. function complete() {
  13606. that.running = false;
  13607. that._trigger( "activate", event, eventData );
  13608. }
  13609. function show() {
  13610. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  13611. if ( toShow.length && that.options.show ) {
  13612. that._show( toShow, that.options.show, complete );
  13613. } else {
  13614. toShow.show();
  13615. complete();
  13616. }
  13617. }
  13618. // start out by hiding, then showing, then completing
  13619. if ( toHide.length && this.options.hide ) {
  13620. this._hide( toHide, this.options.hide, function() {
  13621. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13622. show();
  13623. });
  13624. } else {
  13625. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13626. toHide.hide();
  13627. show();
  13628. }
  13629. toHide.attr( "aria-hidden", "true" );
  13630. eventData.oldTab.attr({
  13631. "aria-selected": "false",
  13632. "aria-expanded": "false"
  13633. });
  13634. // If we're switching tabs, remove the old tab from the tab order.
  13635. // If we're opening from collapsed state, remove the previous tab from the tab order.
  13636. // If we're collapsing, then keep the collapsing tab in the tab order.
  13637. if ( toShow.length && toHide.length ) {
  13638. eventData.oldTab.attr( "tabIndex", -1 );
  13639. } else if ( toShow.length ) {
  13640. this.tabs.filter(function() {
  13641. return $( this ).attr( "tabIndex" ) === 0;
  13642. })
  13643. .attr( "tabIndex", -1 );
  13644. }
  13645. toShow.attr( "aria-hidden", "false" );
  13646. eventData.newTab.attr({
  13647. "aria-selected": "true",
  13648. "aria-expanded": "true",
  13649. tabIndex: 0
  13650. });
  13651. },
  13652. _activate: function( index ) {
  13653. var anchor,
  13654. active = this._findActive( index );
  13655. // trying to activate the already active panel
  13656. if ( active[ 0 ] === this.active[ 0 ] ) {
  13657. return;
  13658. }
  13659. // trying to collapse, simulate a click on the current active header
  13660. if ( !active.length ) {
  13661. active = this.active;
  13662. }
  13663. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  13664. this._eventHandler({
  13665. target: anchor,
  13666. currentTarget: anchor,
  13667. preventDefault: $.noop
  13668. });
  13669. },
  13670. _findActive: function( index ) {
  13671. return index === false ? $() : this.tabs.eq( index );
  13672. },
  13673. _getIndex: function( index ) {
  13674. // meta-function to give users option to provide a href string instead of a numerical index.
  13675. if ( typeof index === "string" ) {
  13676. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  13677. }
  13678. return index;
  13679. },
  13680. _destroy: function() {
  13681. if ( this.xhr ) {
  13682. this.xhr.abort();
  13683. }
  13684. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  13685. this.tablist
  13686. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13687. .removeAttr( "role" );
  13688. this.anchors
  13689. .removeClass( "ui-tabs-anchor" )
  13690. .removeAttr( "role" )
  13691. .removeAttr( "tabIndex" )
  13692. .removeUniqueId();
  13693. this.tablist.unbind( this.eventNamespace );
  13694. this.tabs.add( this.panels ).each(function() {
  13695. if ( $.data( this, "ui-tabs-destroy" ) ) {
  13696. $( this ).remove();
  13697. } else {
  13698. $( this )
  13699. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  13700. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  13701. .removeAttr( "tabIndex" )
  13702. .removeAttr( "aria-live" )
  13703. .removeAttr( "aria-busy" )
  13704. .removeAttr( "aria-selected" )
  13705. .removeAttr( "aria-labelledby" )
  13706. .removeAttr( "aria-hidden" )
  13707. .removeAttr( "aria-expanded" )
  13708. .removeAttr( "role" );
  13709. }
  13710. });
  13711. this.tabs.each(function() {
  13712. var li = $( this ),
  13713. prev = li.data( "ui-tabs-aria-controls" );
  13714. if ( prev ) {
  13715. li
  13716. .attr( "aria-controls", prev )
  13717. .removeData( "ui-tabs-aria-controls" );
  13718. } else {
  13719. li.removeAttr( "aria-controls" );
  13720. }
  13721. });
  13722. this.panels.show();
  13723. if ( this.options.heightStyle !== "content" ) {
  13724. this.panels.css( "height", "" );
  13725. }
  13726. },
  13727. enable: function( index ) {
  13728. var disabled = this.options.disabled;
  13729. if ( disabled === false ) {
  13730. return;
  13731. }
  13732. if ( index === undefined ) {
  13733. disabled = false;
  13734. } else {
  13735. index = this._getIndex( index );
  13736. if ( $.isArray( disabled ) ) {
  13737. disabled = $.map( disabled, function( num ) {
  13738. return num !== index ? num : null;
  13739. });
  13740. } else {
  13741. disabled = $.map( this.tabs, function( li, num ) {
  13742. return num !== index ? num : null;
  13743. });
  13744. }
  13745. }
  13746. this._setupDisabled( disabled );
  13747. },
  13748. disable: function( index ) {
  13749. var disabled = this.options.disabled;
  13750. if ( disabled === true ) {
  13751. return;
  13752. }
  13753. if ( index === undefined ) {
  13754. disabled = true;
  13755. } else {
  13756. index = this._getIndex( index );
  13757. if ( $.inArray( index, disabled ) !== -1 ) {
  13758. return;
  13759. }
  13760. if ( $.isArray( disabled ) ) {
  13761. disabled = $.merge( [ index ], disabled ).sort();
  13762. } else {
  13763. disabled = [ index ];
  13764. }
  13765. }
  13766. this._setupDisabled( disabled );
  13767. },
  13768. load: function( index, event ) {
  13769. index = this._getIndex( index );
  13770. var that = this,
  13771. tab = this.tabs.eq( index ),
  13772. anchor = tab.find( ".ui-tabs-anchor" ),
  13773. panel = this._getPanelForTab( tab ),
  13774. eventData = {
  13775. tab: tab,
  13776. panel: panel
  13777. },
  13778. complete = function( jqXHR, status ) {
  13779. if ( status === "abort" ) {
  13780. that.panels.stop( false, true );
  13781. }
  13782. tab.removeClass( "ui-tabs-loading" );
  13783. panel.removeAttr( "aria-busy" );
  13784. if ( jqXHR === that.xhr ) {
  13785. delete that.xhr;
  13786. }
  13787. };
  13788. // not remote
  13789. if ( this._isLocal( anchor[ 0 ] ) ) {
  13790. return;
  13791. }
  13792. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  13793. // support: jQuery <1.8
  13794. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  13795. // but as of 1.8, $.ajax() always returns a jqXHR object.
  13796. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  13797. tab.addClass( "ui-tabs-loading" );
  13798. panel.attr( "aria-busy", "true" );
  13799. this.xhr
  13800. .done(function( response, status, jqXHR ) {
  13801. // support: jQuery <1.8
  13802. // http://bugs.jquery.com/ticket/11778
  13803. setTimeout(function() {
  13804. panel.html( response );
  13805. that._trigger( "load", event, eventData );
  13806. complete( jqXHR, status );
  13807. }, 1 );
  13808. })
  13809. .fail(function( jqXHR, status ) {
  13810. // support: jQuery <1.8
  13811. // http://bugs.jquery.com/ticket/11778
  13812. setTimeout(function() {
  13813. complete( jqXHR, status );
  13814. }, 1 );
  13815. });
  13816. }
  13817. },
  13818. _ajaxSettings: function( anchor, event, eventData ) {
  13819. var that = this;
  13820. return {
  13821. url: anchor.attr( "href" ),
  13822. beforeSend: function( jqXHR, settings ) {
  13823. return that._trigger( "beforeLoad", event,
  13824. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  13825. }
  13826. };
  13827. },
  13828. _getPanelForTab: function( tab ) {
  13829. var id = $( tab ).attr( "aria-controls" );
  13830. return this.element.find( this._sanitizeSelector( "#" + id ) );
  13831. }
  13832. });
  13833. /*!
  13834. * jQuery UI Tooltip 1.11.4
  13835. * http://jqueryui.com
  13836. *
  13837. * Copyright jQuery Foundation and other contributors
  13838. * Released under the MIT license.
  13839. * http://jquery.org/license
  13840. *
  13841. * http://api.jqueryui.com/tooltip/
  13842. */
  13843. var tooltip = $.widget( "ui.tooltip", {
  13844. version: "1.11.4",
  13845. options: {
  13846. content: function() {
  13847. // support: IE<9, Opera in jQuery <1.7
  13848. // .text() can't accept undefined, so coerce to a string
  13849. var title = $( this ).attr( "title" ) || "";
  13850. // Escape title, since we're going from an attribute to raw HTML
  13851. return $( "<a>" ).text( title ).html();
  13852. },
  13853. hide: true,
  13854. // Disabled elements have inconsistent behavior across browsers (#8661)
  13855. items: "[title]:not([disabled])",
  13856. position: {
  13857. my: "left top+15",
  13858. at: "left bottom",
  13859. collision: "flipfit flip"
  13860. },
  13861. show: true,
  13862. tooltipClass: null,
  13863. track: false,
  13864. // callbacks
  13865. close: null,
  13866. open: null
  13867. },
  13868. _addDescribedBy: function( elem, id ) {
  13869. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  13870. describedby.push( id );
  13871. elem
  13872. .data( "ui-tooltip-id", id )
  13873. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  13874. },
  13875. _removeDescribedBy: function( elem ) {
  13876. var id = elem.data( "ui-tooltip-id" ),
  13877. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  13878. index = $.inArray( id, describedby );
  13879. if ( index !== -1 ) {
  13880. describedby.splice( index, 1 );
  13881. }
  13882. elem.removeData( "ui-tooltip-id" );
  13883. describedby = $.trim( describedby.join( " " ) );
  13884. if ( describedby ) {
  13885. elem.attr( "aria-describedby", describedby );
  13886. } else {
  13887. elem.removeAttr( "aria-describedby" );
  13888. }
  13889. },
  13890. _create: function() {
  13891. this._on({
  13892. mouseover: "open",
  13893. focusin: "open"
  13894. });
  13895. // IDs of generated tooltips, needed for destroy
  13896. this.tooltips = {};
  13897. // IDs of parent tooltips where we removed the title attribute
  13898. this.parents = {};
  13899. if ( this.options.disabled ) {
  13900. this._disable();
  13901. }
  13902. // Append the aria-live region so tooltips announce correctly
  13903. this.liveRegion = $( "<div>" )
  13904. .attr({
  13905. role: "log",
  13906. "aria-live": "assertive",
  13907. "aria-relevant": "additions"
  13908. })
  13909. .addClass( "ui-helper-hidden-accessible" )
  13910. .appendTo( this.document[ 0 ].body );
  13911. },
  13912. _setOption: function( key, value ) {
  13913. var that = this;
  13914. if ( key === "disabled" ) {
  13915. this[ value ? "_disable" : "_enable" ]();
  13916. this.options[ key ] = value;
  13917. // disable element style changes
  13918. return;
  13919. }
  13920. this._super( key, value );
  13921. if ( key === "content" ) {
  13922. $.each( this.tooltips, function( id, tooltipData ) {
  13923. that._updateContent( tooltipData.element );
  13924. });
  13925. }
  13926. },
  13927. _disable: function() {
  13928. var that = this;
  13929. // close open tooltips
  13930. $.each( this.tooltips, function( id, tooltipData ) {
  13931. var event = $.Event( "blur" );
  13932. event.target = event.currentTarget = tooltipData.element[ 0 ];
  13933. that.close( event, true );
  13934. });
  13935. // remove title attributes to prevent native tooltips
  13936. this.element.find( this.options.items ).addBack().each(function() {
  13937. var element = $( this );
  13938. if ( element.is( "[title]" ) ) {
  13939. element
  13940. .data( "ui-tooltip-title", element.attr( "title" ) )
  13941. .removeAttr( "title" );
  13942. }
  13943. });
  13944. },
  13945. _enable: function() {
  13946. // restore title attributes
  13947. this.element.find( this.options.items ).addBack().each(function() {
  13948. var element = $( this );
  13949. if ( element.data( "ui-tooltip-title" ) ) {
  13950. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13951. }
  13952. });
  13953. },
  13954. open: function( event ) {
  13955. var that = this,
  13956. target = $( event ? event.target : this.element )
  13957. // we need closest here due to mouseover bubbling,
  13958. // but always pointing at the same event target
  13959. .closest( this.options.items );
  13960. // No element to show a tooltip for or the tooltip is already open
  13961. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  13962. return;
  13963. }
  13964. if ( target.attr( "title" ) ) {
  13965. target.data( "ui-tooltip-title", target.attr( "title" ) );
  13966. }
  13967. target.data( "ui-tooltip-open", true );
  13968. // kill parent tooltips, custom or native, for hover
  13969. if ( event && event.type === "mouseover" ) {
  13970. target.parents().each(function() {
  13971. var parent = $( this ),
  13972. blurEvent;
  13973. if ( parent.data( "ui-tooltip-open" ) ) {
  13974. blurEvent = $.Event( "blur" );
  13975. blurEvent.target = blurEvent.currentTarget = this;
  13976. that.close( blurEvent, true );
  13977. }
  13978. if ( parent.attr( "title" ) ) {
  13979. parent.uniqueId();
  13980. that.parents[ this.id ] = {
  13981. element: this,
  13982. title: parent.attr( "title" )
  13983. };
  13984. parent.attr( "title", "" );
  13985. }
  13986. });
  13987. }
  13988. this._registerCloseHandlers( event, target );
  13989. this._updateContent( target, event );
  13990. },
  13991. _updateContent: function( target, event ) {
  13992. var content,
  13993. contentOption = this.options.content,
  13994. that = this,
  13995. eventType = event ? event.type : null;
  13996. if ( typeof contentOption === "string" ) {
  13997. return this._open( event, target, contentOption );
  13998. }
  13999. content = contentOption.call( target[0], function( response ) {
  14000. // IE may instantly serve a cached response for ajax requests
  14001. // delay this call to _open so the other call to _open runs first
  14002. that._delay(function() {
  14003. // Ignore async response if tooltip was closed already
  14004. if ( !target.data( "ui-tooltip-open" ) ) {
  14005. return;
  14006. }
  14007. // jQuery creates a special event for focusin when it doesn't
  14008. // exist natively. To improve performance, the native event
  14009. // object is reused and the type is changed. Therefore, we can't
  14010. // rely on the type being correct after the event finished
  14011. // bubbling, so we set it back to the previous value. (#8740)
  14012. if ( event ) {
  14013. event.type = eventType;
  14014. }
  14015. this._open( event, target, response );
  14016. });
  14017. });
  14018. if ( content ) {
  14019. this._open( event, target, content );
  14020. }
  14021. },
  14022. _open: function( event, target, content ) {
  14023. var tooltipData, tooltip, delayedShow, a11yContent,
  14024. positionOption = $.extend( {}, this.options.position );
  14025. if ( !content ) {
  14026. return;
  14027. }
  14028. // Content can be updated multiple times. If the tooltip already
  14029. // exists, then just update the content and bail.
  14030. tooltipData = this._find( target );
  14031. if ( tooltipData ) {
  14032. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  14033. return;
  14034. }
  14035. // if we have a title, clear it to prevent the native tooltip
  14036. // we have to check first to avoid defining a title if none exists
  14037. // (we don't want to cause an element to start matching [title])
  14038. //
  14039. // We use removeAttr only for key events, to allow IE to export the correct
  14040. // accessible attributes. For mouse events, set to empty string to avoid
  14041. // native tooltip showing up (happens only when removing inside mouseover).
  14042. if ( target.is( "[title]" ) ) {
  14043. if ( event && event.type === "mouseover" ) {
  14044. target.attr( "title", "" );
  14045. } else {
  14046. target.removeAttr( "title" );
  14047. }
  14048. }
  14049. tooltipData = this._tooltip( target );
  14050. tooltip = tooltipData.tooltip;
  14051. this._addDescribedBy( target, tooltip.attr( "id" ) );
  14052. tooltip.find( ".ui-tooltip-content" ).html( content );
  14053. // Support: Voiceover on OS X, JAWS on IE <= 9
  14054. // JAWS announces deletions even when aria-relevant="additions"
  14055. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  14056. this.liveRegion.children().hide();
  14057. if ( content.clone ) {
  14058. a11yContent = content.clone();
  14059. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  14060. } else {
  14061. a11yContent = content;
  14062. }
  14063. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  14064. function position( event ) {
  14065. positionOption.of = event;
  14066. if ( tooltip.is( ":hidden" ) ) {
  14067. return;
  14068. }
  14069. tooltip.position( positionOption );
  14070. }
  14071. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  14072. this._on( this.document, {
  14073. mousemove: position
  14074. });
  14075. // trigger once to override element-relative positioning
  14076. position( event );
  14077. } else {
  14078. tooltip.position( $.extend({
  14079. of: target
  14080. }, this.options.position ) );
  14081. }
  14082. tooltip.hide();
  14083. this._show( tooltip, this.options.show );
  14084. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  14085. // as the tooltip is visible, position the tooltip using the most recent
  14086. // event.
  14087. if ( this.options.show && this.options.show.delay ) {
  14088. delayedShow = this.delayedShow = setInterval(function() {
  14089. if ( tooltip.is( ":visible" ) ) {
  14090. position( positionOption.of );
  14091. clearInterval( delayedShow );
  14092. }
  14093. }, $.fx.interval );
  14094. }
  14095. this._trigger( "open", event, { tooltip: tooltip } );
  14096. },
  14097. _registerCloseHandlers: function( event, target ) {
  14098. var events = {
  14099. keyup: function( event ) {
  14100. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  14101. var fakeEvent = $.Event(event);
  14102. fakeEvent.currentTarget = target[0];
  14103. this.close( fakeEvent, true );
  14104. }
  14105. }
  14106. };
  14107. // Only bind remove handler for delegated targets. Non-delegated
  14108. // tooltips will handle this in destroy.
  14109. if ( target[ 0 ] !== this.element[ 0 ] ) {
  14110. events.remove = function() {
  14111. this._removeTooltip( this._find( target ).tooltip );
  14112. };
  14113. }
  14114. if ( !event || event.type === "mouseover" ) {
  14115. events.mouseleave = "close";
  14116. }
  14117. if ( !event || event.type === "focusin" ) {
  14118. events.focusout = "close";
  14119. }
  14120. this._on( true, target, events );
  14121. },
  14122. close: function( event ) {
  14123. var tooltip,
  14124. that = this,
  14125. target = $( event ? event.currentTarget : this.element ),
  14126. tooltipData = this._find( target );
  14127. // The tooltip may already be closed
  14128. if ( !tooltipData ) {
  14129. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  14130. // additional data once there's actually content to show (in _open()). So even if the
  14131. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  14132. // the period between open() and _open().
  14133. target.removeData( "ui-tooltip-open" );
  14134. return;
  14135. }
  14136. tooltip = tooltipData.tooltip;
  14137. // disabling closes the tooltip, so we need to track when we're closing
  14138. // to avoid an infinite loop in case the tooltip becomes disabled on close
  14139. if ( tooltipData.closing ) {
  14140. return;
  14141. }
  14142. // Clear the interval for delayed tracking tooltips
  14143. clearInterval( this.delayedShow );
  14144. // only set title if we had one before (see comment in _open())
  14145. // If the title attribute has changed since open(), don't restore
  14146. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  14147. target.attr( "title", target.data( "ui-tooltip-title" ) );
  14148. }
  14149. this._removeDescribedBy( target );
  14150. tooltipData.hiding = true;
  14151. tooltip.stop( true );
  14152. this._hide( tooltip, this.options.hide, function() {
  14153. that._removeTooltip( $( this ) );
  14154. });
  14155. target.removeData( "ui-tooltip-open" );
  14156. this._off( target, "mouseleave focusout keyup" );
  14157. // Remove 'remove' binding only on delegated targets
  14158. if ( target[ 0 ] !== this.element[ 0 ] ) {
  14159. this._off( target, "remove" );
  14160. }
  14161. this._off( this.document, "mousemove" );
  14162. if ( event && event.type === "mouseleave" ) {
  14163. $.each( this.parents, function( id, parent ) {
  14164. $( parent.element ).attr( "title", parent.title );
  14165. delete that.parents[ id ];
  14166. });
  14167. }
  14168. tooltipData.closing = true;
  14169. this._trigger( "close", event, { tooltip: tooltip } );
  14170. if ( !tooltipData.hiding ) {
  14171. tooltipData.closing = false;
  14172. }
  14173. },
  14174. _tooltip: function( element ) {
  14175. var tooltip = $( "<div>" )
  14176. .attr( "role", "tooltip" )
  14177. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  14178. ( this.options.tooltipClass || "" ) ),
  14179. id = tooltip.uniqueId().attr( "id" );
  14180. $( "<div>" )
  14181. .addClass( "ui-tooltip-content" )
  14182. .appendTo( tooltip );
  14183. tooltip.appendTo( this.document[0].body );
  14184. return this.tooltips[ id ] = {
  14185. element: element,
  14186. tooltip: tooltip
  14187. };
  14188. },
  14189. _find: function( target ) {
  14190. var id = target.data( "ui-tooltip-id" );
  14191. return id ? this.tooltips[ id ] : null;
  14192. },
  14193. _removeTooltip: function( tooltip ) {
  14194. tooltip.remove();
  14195. delete this.tooltips[ tooltip.attr( "id" ) ];
  14196. },
  14197. _destroy: function() {
  14198. var that = this;
  14199. // close open tooltips
  14200. $.each( this.tooltips, function( id, tooltipData ) {
  14201. // Delegate to close method to handle common cleanup
  14202. var event = $.Event( "blur" ),
  14203. element = tooltipData.element;
  14204. event.target = event.currentTarget = element[ 0 ];
  14205. that.close( event, true );
  14206. // Remove immediately; destroying an open tooltip doesn't use the
  14207. // hide animation
  14208. $( "#" + id ).remove();
  14209. // Restore the title
  14210. if ( element.data( "ui-tooltip-title" ) ) {
  14211. // If the title attribute has changed since open(), don't restore
  14212. if ( !element.attr( "title" ) ) {
  14213. element.attr( "title", element.data( "ui-tooltip-title" ) );
  14214. }
  14215. element.removeData( "ui-tooltip-title" );
  14216. }
  14217. });
  14218. this.liveRegion.remove();
  14219. }
  14220. });
  14221. }));