1. /*! jQuery UI - v1.11.4 - 2015-04-23
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, selectable.js, sortable.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, menu.js, progressbar.js, selectmenu.js, slider.js, spinner.js, tabs.js, tooltip.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
  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. getWithinInfo: function( element ) {
  985. var withinElement = $( element || window ),
  986. isWindow = $.isWindow( withinElement[0] ),
  987. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  988. return {
  989. element: withinElement,
  990. isWindow: isWindow,
  991. isDocument: isDocument,
  992. offset: withinElement.offset() || { left: 0, top: 0 },
  993. scrollLeft: withinElement.scrollLeft(),
  994. scrollTop: withinElement.scrollTop(),
  995. // support: jQuery 1.6.x
  996. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  997. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  998. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  999. };
  1000. }
  1001. };
  1002. $.fn.position = function( options ) {
  1003. if ( !options || !options.of ) {
  1004. return _position.apply( this, arguments );
  1005. }
  1006. // make a copy, we don't want to modify arguments
  1007. options = $.extend( {}, options );
  1008. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1009. target = $( options.of ),
  1010. within = $.position.getWithinInfo( options.within ),
  1011. scrollInfo = $.position.getScrollInfo( within ),
  1012. collision = ( options.collision || "flip" ).split( " " ),
  1013. offsets = {};
  1014. dimensions = getDimensions( target );
  1015. if ( target[0].preventDefault ) {
  1016. // force left top to allow flipping
  1017. options.at = "left top";
  1018. }
  1019. targetWidth = dimensions.width;
  1020. targetHeight = dimensions.height;
  1021. targetOffset = dimensions.offset;
  1022. // clone to reuse original targetOffset later
  1023. basePosition = $.extend( {}, targetOffset );
  1024. // force my and at to have valid horizontal and vertical positions
  1025. // if a value is missing or invalid, it will be converted to center
  1026. $.each( [ "my", "at" ], function() {
  1027. var pos = ( options[ this ] || "" ).split( " " ),
  1028. horizontalOffset,
  1029. verticalOffset;
  1030. if ( pos.length === 1) {
  1031. pos = rhorizontal.test( pos[ 0 ] ) ?
  1032. pos.concat( [ "center" ] ) :
  1033. rvertical.test( pos[ 0 ] ) ?
  1034. [ "center" ].concat( pos ) :
  1035. [ "center", "center" ];
  1036. }
  1037. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1038. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1039. // calculate offsets
  1040. horizontalOffset = roffset.exec( pos[ 0 ] );
  1041. verticalOffset = roffset.exec( pos[ 1 ] );
  1042. offsets[ this ] = [
  1043. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1044. verticalOffset ? verticalOffset[ 0 ] : 0
  1045. ];
  1046. // reduce to just the positions without the offsets
  1047. options[ this ] = [
  1048. rposition.exec( pos[ 0 ] )[ 0 ],
  1049. rposition.exec( pos[ 1 ] )[ 0 ]
  1050. ];
  1051. });
  1052. // normalize collision option
  1053. if ( collision.length === 1 ) {
  1054. collision[ 1 ] = collision[ 0 ];
  1055. }
  1056. if ( options.at[ 0 ] === "right" ) {
  1057. basePosition.left += targetWidth;
  1058. } else if ( options.at[ 0 ] === "center" ) {
  1059. basePosition.left += targetWidth / 2;
  1060. }
  1061. if ( options.at[ 1 ] === "bottom" ) {
  1062. basePosition.top += targetHeight;
  1063. } else if ( options.at[ 1 ] === "center" ) {
  1064. basePosition.top += targetHeight / 2;
  1065. }
  1066. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1067. basePosition.left += atOffset[ 0 ];
  1068. basePosition.top += atOffset[ 1 ];
  1069. return this.each(function() {
  1070. var collisionPosition, using,
  1071. elem = $( this ),
  1072. elemWidth = elem.outerWidth(),
  1073. elemHeight = elem.outerHeight(),
  1074. marginLeft = parseCss( this, "marginLeft" ),
  1075. marginTop = parseCss( this, "marginTop" ),
  1076. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1077. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1078. position = $.extend( {}, basePosition ),
  1079. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1080. if ( options.my[ 0 ] === "right" ) {
  1081. position.left -= elemWidth;
  1082. } else if ( options.my[ 0 ] === "center" ) {
  1083. position.left -= elemWidth / 2;
  1084. }
  1085. if ( options.my[ 1 ] === "bottom" ) {
  1086. position.top -= elemHeight;
  1087. } else if ( options.my[ 1 ] === "center" ) {
  1088. position.top -= elemHeight / 2;
  1089. }
  1090. position.left += myOffset[ 0 ];
  1091. position.top += myOffset[ 1 ];
  1092. // if the browser doesn't support fractions, then round for consistent results
  1093. if ( !supportsOffsetFractions ) {
  1094. position.left = round( position.left );
  1095. position.top = round( position.top );
  1096. }
  1097. collisionPosition = {
  1098. marginLeft: marginLeft,
  1099. marginTop: marginTop
  1100. };
  1101. $.each( [ "left", "top" ], function( i, dir ) {
  1102. if ( $.ui.position[ collision[ i ] ] ) {
  1103. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1104. targetWidth: targetWidth,
  1105. targetHeight: targetHeight,
  1106. elemWidth: elemWidth,
  1107. elemHeight: elemHeight,
  1108. collisionPosition: collisionPosition,
  1109. collisionWidth: collisionWidth,
  1110. collisionHeight: collisionHeight,
  1111. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1112. my: options.my,
  1113. at: options.at,
  1114. within: within,
  1115. elem: elem
  1116. });
  1117. }
  1118. });
  1119. if ( options.using ) {
  1120. // adds feedback as second argument to using callback, if present
  1121. using = function( props ) {
  1122. var left = targetOffset.left - position.left,
  1123. right = left + targetWidth - elemWidth,
  1124. top = targetOffset.top - position.top,
  1125. bottom = top + targetHeight - elemHeight,
  1126. feedback = {
  1127. target: {
  1128. element: target,
  1129. left: targetOffset.left,
  1130. top: targetOffset.top,
  1131. width: targetWidth,
  1132. height: targetHeight
  1133. },
  1134. element: {
  1135. element: elem,
  1136. left: position.left,
  1137. top: position.top,
  1138. width: elemWidth,
  1139. height: elemHeight
  1140. },
  1141. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1142. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1143. };
  1144. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1145. feedback.horizontal = "center";
  1146. }
  1147. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1148. feedback.vertical = "middle";
  1149. }
  1150. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1151. feedback.important = "horizontal";
  1152. } else {
  1153. feedback.important = "vertical";
  1154. }
  1155. options.using.call( this, props, feedback );
  1156. };
  1157. }
  1158. elem.offset( $.extend( position, { using: using } ) );
  1159. });
  1160. };
  1161. $.ui.position = {
  1162. fit: {
  1163. left: function( position, data ) {
  1164. var within = data.within,
  1165. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1166. outerWidth = within.width,
  1167. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1168. overLeft = withinOffset - collisionPosLeft,
  1169. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1170. newOverRight;
  1171. // element is wider than within
  1172. if ( data.collisionWidth > outerWidth ) {
  1173. // element is initially over the left side of within
  1174. if ( overLeft > 0 && overRight <= 0 ) {
  1175. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1176. position.left += overLeft - newOverRight;
  1177. // element is initially over right side of within
  1178. } else if ( overRight > 0 && overLeft <= 0 ) {
  1179. position.left = withinOffset;
  1180. // element is initially over both left and right sides of within
  1181. } else {
  1182. if ( overLeft > overRight ) {
  1183. position.left = withinOffset + outerWidth - data.collisionWidth;
  1184. } else {
  1185. position.left = withinOffset;
  1186. }
  1187. }
  1188. // too far left -> align with left edge
  1189. } else if ( overLeft > 0 ) {
  1190. position.left += overLeft;
  1191. // too far right -> align with right edge
  1192. } else if ( overRight > 0 ) {
  1193. position.left -= overRight;
  1194. // adjust based on position and margin
  1195. } else {
  1196. position.left = max( position.left - collisionPosLeft, position.left );
  1197. }
  1198. },
  1199. top: function( position, data ) {
  1200. var within = data.within,
  1201. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1202. outerHeight = data.within.height,
  1203. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1204. overTop = withinOffset - collisionPosTop,
  1205. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1206. newOverBottom;
  1207. // element is taller than within
  1208. if ( data.collisionHeight > outerHeight ) {
  1209. // element is initially over the top of within
  1210. if ( overTop > 0 && overBottom <= 0 ) {
  1211. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1212. position.top += overTop - newOverBottom;
  1213. // element is initially over bottom of within
  1214. } else if ( overBottom > 0 && overTop <= 0 ) {
  1215. position.top = withinOffset;
  1216. // element is initially over both top and bottom of within
  1217. } else {
  1218. if ( overTop > overBottom ) {
  1219. position.top = withinOffset + outerHeight - data.collisionHeight;
  1220. } else {
  1221. position.top = withinOffset;
  1222. }
  1223. }
  1224. // too far up -> align with top
  1225. } else if ( overTop > 0 ) {
  1226. position.top += overTop;
  1227. // too far down -> align with bottom edge
  1228. } else if ( overBottom > 0 ) {
  1229. position.top -= overBottom;
  1230. // adjust based on position and margin
  1231. } else {
  1232. position.top = max( position.top - collisionPosTop, position.top );
  1233. }
  1234. }
  1235. },
  1236. flip: {
  1237. left: function( position, data ) {
  1238. var within = data.within,
  1239. withinOffset = within.offset.left + within.scrollLeft,
  1240. outerWidth = within.width,
  1241. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1242. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1243. overLeft = collisionPosLeft - offsetLeft,
  1244. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1245. myOffset = data.my[ 0 ] === "left" ?
  1246. -data.elemWidth :
  1247. data.my[ 0 ] === "right" ?
  1248. data.elemWidth :
  1249. 0,
  1250. atOffset = data.at[ 0 ] === "left" ?
  1251. data.targetWidth :
  1252. data.at[ 0 ] === "right" ?
  1253. -data.targetWidth :
  1254. 0,
  1255. offset = -2 * data.offset[ 0 ],
  1256. newOverRight,
  1257. newOverLeft;
  1258. if ( overLeft < 0 ) {
  1259. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1260. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1261. position.left += myOffset + atOffset + offset;
  1262. }
  1263. } else if ( overRight > 0 ) {
  1264. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1265. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1266. position.left += myOffset + atOffset + offset;
  1267. }
  1268. }
  1269. },
  1270. top: function( position, data ) {
  1271. var within = data.within,
  1272. withinOffset = within.offset.top + within.scrollTop,
  1273. outerHeight = within.height,
  1274. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1275. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1276. overTop = collisionPosTop - offsetTop,
  1277. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1278. top = data.my[ 1 ] === "top",
  1279. myOffset = top ?
  1280. -data.elemHeight :
  1281. data.my[ 1 ] === "bottom" ?
  1282. data.elemHeight :
  1283. 0,
  1284. atOffset = data.at[ 1 ] === "top" ?
  1285. data.targetHeight :
  1286. data.at[ 1 ] === "bottom" ?
  1287. -data.targetHeight :
  1288. 0,
  1289. offset = -2 * data.offset[ 1 ],
  1290. newOverTop,
  1291. newOverBottom;
  1292. if ( overTop < 0 ) {
  1293. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1294. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1295. position.top += myOffset + atOffset + offset;
  1296. }
  1297. } else if ( overBottom > 0 ) {
  1298. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1299. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1300. position.top += myOffset + atOffset + offset;
  1301. }
  1302. }
  1303. }
  1304. },
  1305. flipfit: {
  1306. left: function() {
  1307. $.ui.position.flip.left.apply( this, arguments );
  1308. $.ui.position.fit.left.apply( this, arguments );
  1309. },
  1310. top: function() {
  1311. $.ui.position.flip.top.apply( this, arguments );
  1312. $.ui.position.fit.top.apply( this, arguments );
  1313. }
  1314. }
  1315. };
  1316. // fraction support test
  1317. (function() {
  1318. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1319. body = document.getElementsByTagName( "body" )[ 0 ],
  1320. div = document.createElement( "div" );
  1321. //Create a "fake body" for testing based on method used in jQuery.support
  1322. testElement = document.createElement( body ? "div" : "body" );
  1323. testElementStyle = {
  1324. visibility: "hidden",
  1325. width: 0,
  1326. height: 0,
  1327. border: 0,
  1328. margin: 0,
  1329. background: "none"
  1330. };
  1331. if ( body ) {
  1332. $.extend( testElementStyle, {
  1333. position: "absolute",
  1334. left: "-1000px",
  1335. top: "-1000px"
  1336. });
  1337. }
  1338. for ( i in testElementStyle ) {
  1339. testElement.style[ i ] = testElementStyle[ i ];
  1340. }
  1341. testElement.appendChild( div );
  1342. testElementParent = body || document.documentElement;
  1343. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1344. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1345. offsetLeft = $( div ).offset().left;
  1346. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1347. testElement.innerHTML = "";
  1348. testElementParent.removeChild( testElement );
  1349. })();
  1350. })();
  1351. var position = $.ui.position;
  1352. /*!
  1353. * jQuery UI Draggable 1.11.4
  1354. * http://jqueryui.com
  1355. *
  1356. * Copyright jQuery Foundation and other contributors
  1357. * Released under the MIT license.
  1358. * http://jquery.org/license
  1359. *
  1360. * http://api.jqueryui.com/draggable/
  1361. */
  1362. $.widget("ui.draggable", $.ui.mouse, {
  1363. version: "1.11.4",
  1364. widgetEventPrefix: "drag",
  1365. options: {
  1366. addClasses: true,
  1367. appendTo: "parent",
  1368. axis: false,
  1369. connectToSortable: false,
  1370. containment: false,
  1371. cursor: "auto",
  1372. cursorAt: false,
  1373. grid: false,
  1374. handle: false,
  1375. helper: "original",
  1376. iframeFix: false,
  1377. opacity: false,
  1378. refreshPositions: false,
  1379. revert: false,
  1380. revertDuration: 500,
  1381. scope: "default",
  1382. scroll: true,
  1383. scrollSensitivity: 20,
  1384. scrollSpeed: 20,
  1385. snap: false,
  1386. snapMode: "both",
  1387. snapTolerance: 20,
  1388. stack: false,
  1389. zIndex: false,
  1390. // callbacks
  1391. drag: null,
  1392. start: null,
  1393. stop: null
  1394. },
  1395. _create: function() {
  1396. if ( this.options.helper === "original" ) {
  1397. this._setPositionRelative();
  1398. }
  1399. if (this.options.addClasses){
  1400. this.element.addClass("ui-draggable");
  1401. }
  1402. if (this.options.disabled){
  1403. this.element.addClass("ui-draggable-disabled");
  1404. }
  1405. this._setHandleClassName();
  1406. this._mouseInit();
  1407. },
  1408. _setOption: function( key, value ) {
  1409. this._super( key, value );
  1410. if ( key === "handle" ) {
  1411. this._removeHandleClassName();
  1412. this._setHandleClassName();
  1413. }
  1414. },
  1415. _destroy: function() {
  1416. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1417. this.destroyOnClear = true;
  1418. return;
  1419. }
  1420. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1421. this._removeHandleClassName();
  1422. this._mouseDestroy();
  1423. },
  1424. _mouseCapture: function(event) {
  1425. var o = this.options;
  1426. this._blurActiveElement( event );
  1427. // among others, prevent a drag on a resizable-handle
  1428. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1429. return false;
  1430. }
  1431. //Quit if we're not on a valid handle
  1432. this.handle = this._getHandle(event);
  1433. if (!this.handle) {
  1434. return false;
  1435. }
  1436. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1437. return true;
  1438. },
  1439. _blockFrames: function( selector ) {
  1440. this.iframeBlocks = this.document.find( selector ).map(function() {
  1441. var iframe = $( this );
  1442. return $( "<div>" )
  1443. .css( "position", "absolute" )
  1444. .appendTo( iframe.parent() )
  1445. .outerWidth( iframe.outerWidth() )
  1446. .outerHeight( iframe.outerHeight() )
  1447. .offset( iframe.offset() )[ 0 ];
  1448. });
  1449. },
  1450. _unblockFrames: function() {
  1451. if ( this.iframeBlocks ) {
  1452. this.iframeBlocks.remove();
  1453. delete this.iframeBlocks;
  1454. }
  1455. },
  1456. _blurActiveElement: function( event ) {
  1457. var document = this.document[ 0 ];
  1458. // Only need to blur if the event occurred on the draggable itself, see #10527
  1459. if ( !this.handleElement.is( event.target ) ) {
  1460. return;
  1461. }
  1462. // support: IE9
  1463. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1464. try {
  1465. // Support: IE9, IE10
  1466. // If the <body> is blurred, IE will switch windows, see #9520
  1467. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  1468. // Blur any element that currently has focus, see #4261
  1469. $( document.activeElement ).blur();
  1470. }
  1471. } catch ( error ) {}
  1472. },
  1473. _mouseStart: function(event) {
  1474. var o = this.options;
  1475. //Create and append the visible helper
  1476. this.helper = this._createHelper(event);
  1477. this.helper.addClass("ui-draggable-dragging");
  1478. //Cache the helper size
  1479. this._cacheHelperProportions();
  1480. //If ddmanager is used for droppables, set the global draggable
  1481. if ($.ui.ddmanager) {
  1482. $.ui.ddmanager.current = this;
  1483. }
  1484. /*
  1485. * - Position generation -
  1486. * This block generates everything position related - it's the core of draggables.
  1487. */
  1488. //Cache the margins of the original element
  1489. this._cacheMargins();
  1490. //Store the helper's css position
  1491. this.cssPosition = this.helper.css( "position" );
  1492. this.scrollParent = this.helper.scrollParent( true );
  1493. this.offsetParent = this.helper.offsetParent();
  1494. this.hasFixedAncestor = this.helper.parents().filter(function() {
  1495. return $( this ).css( "position" ) === "fixed";
  1496. }).length > 0;
  1497. //The element's absolute position on the page minus margins
  1498. this.positionAbs = this.element.offset();
  1499. this._refreshOffsets( event );
  1500. //Generate the original position
  1501. this.originalPosition = this.position = this._generatePosition( event, false );
  1502. this.originalPageX = event.pageX;
  1503. this.originalPageY = event.pageY;
  1504. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1505. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1506. //Set a containment if given in the options
  1507. this._setContainment();
  1508. //Trigger event + callbacks
  1509. if (this._trigger("start", event) === false) {
  1510. this._clear();
  1511. return false;
  1512. }
  1513. //Recache the helper size
  1514. this._cacheHelperProportions();
  1515. //Prepare the droppable offsets
  1516. if ($.ui.ddmanager && !o.dropBehaviour) {
  1517. $.ui.ddmanager.prepareOffsets(this, event);
  1518. }
  1519. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  1520. // as this prevents resizing of elements with right/bottom set (see #7772)
  1521. this._normalizeRightBottom();
  1522. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1523. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1524. if ( $.ui.ddmanager ) {
  1525. $.ui.ddmanager.dragStart(this, event);
  1526. }
  1527. return true;
  1528. },
  1529. _refreshOffsets: function( event ) {
  1530. this.offset = {
  1531. top: this.positionAbs.top - this.margins.top,
  1532. left: this.positionAbs.left - this.margins.left,
  1533. scroll: false,
  1534. parent: this._getParentOffset(),
  1535. relative: this._getRelativeOffset()
  1536. };
  1537. this.offset.click = {
  1538. left: event.pageX - this.offset.left,
  1539. top: event.pageY - this.offset.top
  1540. };
  1541. },
  1542. _mouseDrag: function(event, noPropagation) {
  1543. // reset any necessary cached properties (see #5009)
  1544. if ( this.hasFixedAncestor ) {
  1545. this.offset.parent = this._getParentOffset();
  1546. }
  1547. //Compute the helpers position
  1548. this.position = this._generatePosition( event, true );
  1549. this.positionAbs = this._convertPositionTo("absolute");
  1550. //Call plugins and callbacks and use the resulting position if something is returned
  1551. if (!noPropagation) {
  1552. var ui = this._uiHash();
  1553. if (this._trigger("drag", event, ui) === false) {
  1554. this._mouseUp({});
  1555. return false;
  1556. }
  1557. this.position = ui.position;
  1558. }
  1559. this.helper[ 0 ].style.left = this.position.left + "px";
  1560. this.helper[ 0 ].style.top = this.position.top + "px";
  1561. if ($.ui.ddmanager) {
  1562. $.ui.ddmanager.drag(this, event);
  1563. }
  1564. return false;
  1565. },
  1566. _mouseStop: function(event) {
  1567. //If we are using droppables, inform the manager about the drop
  1568. var that = this,
  1569. dropped = false;
  1570. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1571. dropped = $.ui.ddmanager.drop(this, event);
  1572. }
  1573. //if a drop comes from outside (a sortable)
  1574. if (this.dropped) {
  1575. dropped = this.dropped;
  1576. this.dropped = false;
  1577. }
  1578. 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))) {
  1579. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1580. if (that._trigger("stop", event) !== false) {
  1581. that._clear();
  1582. }
  1583. });
  1584. } else {
  1585. if (this._trigger("stop", event) !== false) {
  1586. this._clear();
  1587. }
  1588. }
  1589. return false;
  1590. },
  1591. _mouseUp: function( event ) {
  1592. this._unblockFrames();
  1593. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1594. if ( $.ui.ddmanager ) {
  1595. $.ui.ddmanager.dragStop(this, event);
  1596. }
  1597. // Only need to focus if the event occurred on the draggable itself, see #10527
  1598. if ( this.handleElement.is( event.target ) ) {
  1599. // The interaction is over; whether or not the click resulted in a drag, focus the element
  1600. this.element.focus();
  1601. }
  1602. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1603. },
  1604. cancel: function() {
  1605. if (this.helper.is(".ui-draggable-dragging")) {
  1606. this._mouseUp({});
  1607. } else {
  1608. this._clear();
  1609. }
  1610. return this;
  1611. },
  1612. _getHandle: function(event) {
  1613. return this.options.handle ?
  1614. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1615. true;
  1616. },
  1617. _setHandleClassName: function() {
  1618. this.handleElement = this.options.handle ?
  1619. this.element.find( this.options.handle ) : this.element;
  1620. this.handleElement.addClass( "ui-draggable-handle" );
  1621. },
  1622. _removeHandleClassName: function() {
  1623. this.handleElement.removeClass( "ui-draggable-handle" );
  1624. },
  1625. _createHelper: function(event) {
  1626. var o = this.options,
  1627. helperIsFunction = $.isFunction( o.helper ),
  1628. helper = helperIsFunction ?
  1629. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1630. ( o.helper === "clone" ?
  1631. this.element.clone().removeAttr( "id" ) :
  1632. this.element );
  1633. if (!helper.parents("body").length) {
  1634. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1635. }
  1636. // http://bugs.jqueryui.com/ticket/9446
  1637. // a helper function can return the original element
  1638. // which wouldn't have been set to relative in _create
  1639. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1640. this._setPositionRelative();
  1641. }
  1642. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1643. helper.css("position", "absolute");
  1644. }
  1645. return helper;
  1646. },
  1647. _setPositionRelative: function() {
  1648. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1649. this.element[ 0 ].style.position = "relative";
  1650. }
  1651. },
  1652. _adjustOffsetFromHelper: function(obj) {
  1653. if (typeof obj === "string") {
  1654. obj = obj.split(" ");
  1655. }
  1656. if ($.isArray(obj)) {
  1657. obj = { left: +obj[0], top: +obj[1] || 0 };
  1658. }
  1659. if ("left" in obj) {
  1660. this.offset.click.left = obj.left + this.margins.left;
  1661. }
  1662. if ("right" in obj) {
  1663. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1664. }
  1665. if ("top" in obj) {
  1666. this.offset.click.top = obj.top + this.margins.top;
  1667. }
  1668. if ("bottom" in obj) {
  1669. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1670. }
  1671. },
  1672. _isRootNode: function( element ) {
  1673. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1674. },
  1675. _getParentOffset: function() {
  1676. //Get the offsetParent and cache its position
  1677. var po = this.offsetParent.offset(),
  1678. document = this.document[ 0 ];
  1679. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1680. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1681. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1682. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1683. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1684. po.left += this.scrollParent.scrollLeft();
  1685. po.top += this.scrollParent.scrollTop();
  1686. }
  1687. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  1688. po = { top: 0, left: 0 };
  1689. }
  1690. return {
  1691. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  1692. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  1693. };
  1694. },
  1695. _getRelativeOffset: function() {
  1696. if ( this.cssPosition !== "relative" ) {
  1697. return { top: 0, left: 0 };
  1698. }
  1699. var p = this.element.position(),
  1700. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1701. return {
  1702. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  1703. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  1704. };
  1705. },
  1706. _cacheMargins: function() {
  1707. this.margins = {
  1708. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  1709. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  1710. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  1711. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  1712. };
  1713. },
  1714. _cacheHelperProportions: function() {
  1715. this.helperProportions = {
  1716. width: this.helper.outerWidth(),
  1717. height: this.helper.outerHeight()
  1718. };
  1719. },
  1720. _setContainment: function() {
  1721. var isUserScrollable, c, ce,
  1722. o = this.options,
  1723. document = this.document[ 0 ];
  1724. this.relativeContainer = null;
  1725. if ( !o.containment ) {
  1726. this.containment = null;
  1727. return;
  1728. }
  1729. if ( o.containment === "window" ) {
  1730. this.containment = [
  1731. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1732. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1733. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1734. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1735. ];
  1736. return;
  1737. }
  1738. if ( o.containment === "document") {
  1739. this.containment = [
  1740. 0,
  1741. 0,
  1742. $( document ).width() - this.helperProportions.width - this.margins.left,
  1743. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1744. ];
  1745. return;
  1746. }
  1747. if ( o.containment.constructor === Array ) {
  1748. this.containment = o.containment;
  1749. return;
  1750. }
  1751. if ( o.containment === "parent" ) {
  1752. o.containment = this.helper[ 0 ].parentNode;
  1753. }
  1754. c = $( o.containment );
  1755. ce = c[ 0 ];
  1756. if ( !ce ) {
  1757. return;
  1758. }
  1759. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  1760. this.containment = [
  1761. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1762. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  1763. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1764. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  1765. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  1766. this.helperProportions.width -
  1767. this.margins.left -
  1768. this.margins.right,
  1769. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1770. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  1771. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  1772. this.helperProportions.height -
  1773. this.margins.top -
  1774. this.margins.bottom
  1775. ];
  1776. this.relativeContainer = c;
  1777. },
  1778. _convertPositionTo: function(d, pos) {
  1779. if (!pos) {
  1780. pos = this.position;
  1781. }
  1782. var mod = d === "absolute" ? 1 : -1,
  1783. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1784. return {
  1785. top: (
  1786. pos.top + // The absolute mouse position
  1787. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1788. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1789. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  1790. ),
  1791. left: (
  1792. pos.left + // The absolute mouse position
  1793. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1794. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1795. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  1796. )
  1797. };
  1798. },
  1799. _generatePosition: function( event, constrainPosition ) {
  1800. var containment, co, top, left,
  1801. o = this.options,
  1802. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  1803. pageX = event.pageX,
  1804. pageY = event.pageY;
  1805. // Cache the scroll
  1806. if ( !scrollIsRootNode || !this.offset.scroll ) {
  1807. this.offset.scroll = {
  1808. top: this.scrollParent.scrollTop(),
  1809. left: this.scrollParent.scrollLeft()
  1810. };
  1811. }
  1812. /*
  1813. * - Position constraining -
  1814. * Constrain the position to a mix of grid, containment.
  1815. */
  1816. // If we are not dragging yet, we won't check for options
  1817. if ( constrainPosition ) {
  1818. if ( this.containment ) {
  1819. if ( this.relativeContainer ){
  1820. co = this.relativeContainer.offset();
  1821. containment = [
  1822. this.containment[ 0 ] + co.left,
  1823. this.containment[ 1 ] + co.top,
  1824. this.containment[ 2 ] + co.left,
  1825. this.containment[ 3 ] + co.top
  1826. ];
  1827. } else {
  1828. containment = this.containment;
  1829. }
  1830. if (event.pageX - this.offset.click.left < containment[0]) {
  1831. pageX = containment[0] + this.offset.click.left;
  1832. }
  1833. if (event.pageY - this.offset.click.top < containment[1]) {
  1834. pageY = containment[1] + this.offset.click.top;
  1835. }
  1836. if (event.pageX - this.offset.click.left > containment[2]) {
  1837. pageX = containment[2] + this.offset.click.left;
  1838. }
  1839. if (event.pageY - this.offset.click.top > containment[3]) {
  1840. pageY = containment[3] + this.offset.click.top;
  1841. }
  1842. }
  1843. if (o.grid) {
  1844. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1845. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1846. 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;
  1847. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1848. 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;
  1849. }
  1850. if ( o.axis === "y" ) {
  1851. pageX = this.originalPageX;
  1852. }
  1853. if ( o.axis === "x" ) {
  1854. pageY = this.originalPageY;
  1855. }
  1856. }
  1857. return {
  1858. top: (
  1859. pageY - // The absolute mouse position
  1860. this.offset.click.top - // Click offset (relative to the element)
  1861. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1862. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1863. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  1864. ),
  1865. left: (
  1866. pageX - // The absolute mouse position
  1867. this.offset.click.left - // Click offset (relative to the element)
  1868. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1869. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1870. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  1871. )
  1872. };
  1873. },
  1874. _clear: function() {
  1875. this.helper.removeClass("ui-draggable-dragging");
  1876. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1877. this.helper.remove();
  1878. }
  1879. this.helper = null;
  1880. this.cancelHelperRemoval = false;
  1881. if ( this.destroyOnClear ) {
  1882. this.destroy();
  1883. }
  1884. },
  1885. _normalizeRightBottom: function() {
  1886. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  1887. this.helper.width( this.helper.width() );
  1888. this.helper.css( "right", "auto" );
  1889. }
  1890. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  1891. this.helper.height( this.helper.height() );
  1892. this.helper.css( "bottom", "auto" );
  1893. }
  1894. },
  1895. // From now on bulk stuff - mainly helpers
  1896. _trigger: function( type, event, ui ) {
  1897. ui = ui || this._uiHash();
  1898. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  1899. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  1900. if ( /^(drag|start|stop)/.test( type ) ) {
  1901. this.positionAbs = this._convertPositionTo( "absolute" );
  1902. ui.offset = this.positionAbs;
  1903. }
  1904. return $.Widget.prototype._trigger.call( this, type, event, ui );
  1905. },
  1906. plugins: {},
  1907. _uiHash: function() {
  1908. return {
  1909. helper: this.helper,
  1910. position: this.position,
  1911. originalPosition: this.originalPosition,
  1912. offset: this.positionAbs
  1913. };
  1914. }
  1915. });
  1916. $.ui.plugin.add( "draggable", "connectToSortable", {
  1917. start: function( event, ui, draggable ) {
  1918. var uiSortable = $.extend( {}, ui, {
  1919. item: draggable.element
  1920. });
  1921. draggable.sortables = [];
  1922. $( draggable.options.connectToSortable ).each(function() {
  1923. var sortable = $( this ).sortable( "instance" );
  1924. if ( sortable && !sortable.options.disabled ) {
  1925. draggable.sortables.push( sortable );
  1926. // refreshPositions is called at drag start to refresh the containerCache
  1927. // which is used in drag. This ensures it's initialized and synchronized
  1928. // with any changes that might have happened on the page since initialization.
  1929. sortable.refreshPositions();
  1930. sortable._trigger("activate", event, uiSortable);
  1931. }
  1932. });
  1933. },
  1934. stop: function( event, ui, draggable ) {
  1935. var uiSortable = $.extend( {}, ui, {
  1936. item: draggable.element
  1937. });
  1938. draggable.cancelHelperRemoval = false;
  1939. $.each( draggable.sortables, function() {
  1940. var sortable = this;
  1941. if ( sortable.isOver ) {
  1942. sortable.isOver = 0;
  1943. // Allow this sortable to handle removing the helper
  1944. draggable.cancelHelperRemoval = true;
  1945. sortable.cancelHelperRemoval = false;
  1946. // Use _storedCSS To restore properties in the sortable,
  1947. // as this also handles revert (#9675) since the draggable
  1948. // may have modified them in unexpected ways (#8809)
  1949. sortable._storedCSS = {
  1950. position: sortable.placeholder.css( "position" ),
  1951. top: sortable.placeholder.css( "top" ),
  1952. left: sortable.placeholder.css( "left" )
  1953. };
  1954. sortable._mouseStop(event);
  1955. // Once drag has ended, the sortable should return to using
  1956. // its original helper, not the shared helper from draggable
  1957. sortable.options.helper = sortable.options._helper;
  1958. } else {
  1959. // Prevent this Sortable from removing the helper.
  1960. // However, don't set the draggable to remove the helper
  1961. // either as another connected Sortable may yet handle the removal.
  1962. sortable.cancelHelperRemoval = true;
  1963. sortable._trigger( "deactivate", event, uiSortable );
  1964. }
  1965. });
  1966. },
  1967. drag: function( event, ui, draggable ) {
  1968. $.each( draggable.sortables, function() {
  1969. var innermostIntersecting = false,
  1970. sortable = this;
  1971. // Copy over variables that sortable's _intersectsWith uses
  1972. sortable.positionAbs = draggable.positionAbs;
  1973. sortable.helperProportions = draggable.helperProportions;
  1974. sortable.offset.click = draggable.offset.click;
  1975. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  1976. innermostIntersecting = true;
  1977. $.each( draggable.sortables, function() {
  1978. // Copy over variables that sortable's _intersectsWith uses
  1979. this.positionAbs = draggable.positionAbs;
  1980. this.helperProportions = draggable.helperProportions;
  1981. this.offset.click = draggable.offset.click;
  1982. if ( this !== sortable &&
  1983. this._intersectsWith( this.containerCache ) &&
  1984. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  1985. innermostIntersecting = false;
  1986. }
  1987. return innermostIntersecting;
  1988. });
  1989. }
  1990. if ( innermostIntersecting ) {
  1991. // If it intersects, we use a little isOver variable and set it once,
  1992. // so that the move-in stuff gets fired only once.
  1993. if ( !sortable.isOver ) {
  1994. sortable.isOver = 1;
  1995. // Store draggable's parent in case we need to reappend to it later.
  1996. draggable._parent = ui.helper.parent();
  1997. sortable.currentItem = ui.helper
  1998. .appendTo( sortable.element )
  1999. .data( "ui-sortable-item", true );
  2000. // Store helper option to later restore it
  2001. sortable.options._helper = sortable.options.helper;
  2002. sortable.options.helper = function() {
  2003. return ui.helper[ 0 ];
  2004. };
  2005. // Fire the start events of the sortable with our passed browser event,
  2006. // and our own helper (so it doesn't create a new one)
  2007. event.target = sortable.currentItem[ 0 ];
  2008. sortable._mouseCapture( event, true );
  2009. sortable._mouseStart( event, true, true );
  2010. // Because the browser event is way off the new appended portlet,
  2011. // modify necessary variables to reflect the changes
  2012. sortable.offset.click.top = draggable.offset.click.top;
  2013. sortable.offset.click.left = draggable.offset.click.left;
  2014. sortable.offset.parent.left -= draggable.offset.parent.left -
  2015. sortable.offset.parent.left;
  2016. sortable.offset.parent.top -= draggable.offset.parent.top -
  2017. sortable.offset.parent.top;
  2018. draggable._trigger( "toSortable", event );
  2019. // Inform draggable that the helper is in a valid drop zone,
  2020. // used solely in the revert option to handle "valid/invalid".
  2021. draggable.dropped = sortable.element;
  2022. // Need to refreshPositions of all sortables in the case that
  2023. // adding to one sortable changes the location of the other sortables (#9675)
  2024. $.each( draggable.sortables, function() {
  2025. this.refreshPositions();
  2026. });
  2027. // hack so receive/update callbacks work (mostly)
  2028. draggable.currentItem = draggable.element;
  2029. sortable.fromOutside = draggable;
  2030. }
  2031. if ( sortable.currentItem ) {
  2032. sortable._mouseDrag( event );
  2033. // Copy the sortable's position because the draggable's can potentially reflect
  2034. // a relative position, while sortable is always absolute, which the dragged
  2035. // element has now become. (#8809)
  2036. ui.position = sortable.position;
  2037. }
  2038. } else {
  2039. // If it doesn't intersect with the sortable, and it intersected before,
  2040. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2041. // the helper by using cancelHelperRemoval.
  2042. if ( sortable.isOver ) {
  2043. sortable.isOver = 0;
  2044. sortable.cancelHelperRemoval = true;
  2045. // Calling sortable's mouseStop would trigger a revert,
  2046. // so revert must be temporarily false until after mouseStop is called.
  2047. sortable.options._revert = sortable.options.revert;
  2048. sortable.options.revert = false;
  2049. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2050. sortable._mouseStop( event, true );
  2051. // restore sortable behaviors that were modfied
  2052. // when the draggable entered the sortable area (#9481)
  2053. sortable.options.revert = sortable.options._revert;
  2054. sortable.options.helper = sortable.options._helper;
  2055. if ( sortable.placeholder ) {
  2056. sortable.placeholder.remove();
  2057. }
  2058. // Restore and recalculate the draggable's offset considering the sortable
  2059. // may have modified them in unexpected ways. (#8809, #10669)
  2060. ui.helper.appendTo( draggable._parent );
  2061. draggable._refreshOffsets( event );
  2062. ui.position = draggable._generatePosition( event, true );
  2063. draggable._trigger( "fromSortable", event );
  2064. // Inform draggable that the helper is no longer in a valid drop zone
  2065. draggable.dropped = false;
  2066. // Need to refreshPositions of all sortables just in case removing
  2067. // from one sortable changes the location of other sortables (#9675)
  2068. $.each( draggable.sortables, function() {
  2069. this.refreshPositions();
  2070. });
  2071. }
  2072. }
  2073. });
  2074. }
  2075. });
  2076. $.ui.plugin.add("draggable", "cursor", {
  2077. start: function( event, ui, instance ) {
  2078. var t = $( "body" ),
  2079. o = instance.options;
  2080. if (t.css("cursor")) {
  2081. o._cursor = t.css("cursor");
  2082. }
  2083. t.css("cursor", o.cursor);
  2084. },
  2085. stop: function( event, ui, instance ) {
  2086. var o = instance.options;
  2087. if (o._cursor) {
  2088. $("body").css("cursor", o._cursor);
  2089. }
  2090. }
  2091. });
  2092. $.ui.plugin.add("draggable", "opacity", {
  2093. start: function( event, ui, instance ) {
  2094. var t = $( ui.helper ),
  2095. o = instance.options;
  2096. if (t.css("opacity")) {
  2097. o._opacity = t.css("opacity");
  2098. }
  2099. t.css("opacity", o.opacity);
  2100. },
  2101. stop: function( event, ui, instance ) {
  2102. var o = instance.options;
  2103. if (o._opacity) {
  2104. $(ui.helper).css("opacity", o._opacity);
  2105. }
  2106. }
  2107. });
  2108. $.ui.plugin.add("draggable", "scroll", {
  2109. start: function( event, ui, i ) {
  2110. if ( !i.scrollParentNotHidden ) {
  2111. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2112. }
  2113. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2114. i.overflowOffset = i.scrollParentNotHidden.offset();
  2115. }
  2116. },
  2117. drag: function( event, ui, i ) {
  2118. var o = i.options,
  2119. scrolled = false,
  2120. scrollParent = i.scrollParentNotHidden[ 0 ],
  2121. document = i.document[ 0 ];
  2122. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2123. if ( !o.axis || o.axis !== "x" ) {
  2124. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  2125. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2126. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2127. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2128. }
  2129. }
  2130. if ( !o.axis || o.axis !== "y" ) {
  2131. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  2132. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2133. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2134. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2135. }
  2136. }
  2137. } else {
  2138. if (!o.axis || o.axis !== "x") {
  2139. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  2140. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2141. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  2142. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2143. }
  2144. }
  2145. if (!o.axis || o.axis !== "y") {
  2146. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  2147. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2148. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  2149. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2150. }
  2151. }
  2152. }
  2153. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  2154. $.ui.ddmanager.prepareOffsets(i, event);
  2155. }
  2156. }
  2157. });
  2158. $.ui.plugin.add("draggable", "snap", {
  2159. start: function( event, ui, i ) {
  2160. var o = i.options;
  2161. i.snapElements = [];
  2162. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  2163. var $t = $(this),
  2164. $o = $t.offset();
  2165. if (this !== i.element[0]) {
  2166. i.snapElements.push({
  2167. item: this,
  2168. width: $t.outerWidth(), height: $t.outerHeight(),
  2169. top: $o.top, left: $o.left
  2170. });
  2171. }
  2172. });
  2173. },
  2174. drag: function( event, ui, inst ) {
  2175. var ts, bs, ls, rs, l, r, t, b, i, first,
  2176. o = inst.options,
  2177. d = o.snapTolerance,
  2178. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2179. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2180. for (i = inst.snapElements.length - 1; i >= 0; i--){
  2181. l = inst.snapElements[i].left - inst.margins.left;
  2182. r = l + inst.snapElements[i].width;
  2183. t = inst.snapElements[i].top - inst.margins.top;
  2184. b = t + inst.snapElements[i].height;
  2185. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  2186. if (inst.snapElements[i].snapping) {
  2187. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2188. }
  2189. inst.snapElements[i].snapping = false;
  2190. continue;
  2191. }
  2192. if (o.snapMode !== "inner") {
  2193. ts = Math.abs(t - y2) <= d;
  2194. bs = Math.abs(b - y1) <= d;
  2195. ls = Math.abs(l - x2) <= d;
  2196. rs = Math.abs(r - x1) <= d;
  2197. if (ts) {
  2198. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  2199. }
  2200. if (bs) {
  2201. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  2202. }
  2203. if (ls) {
  2204. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  2205. }
  2206. if (rs) {
  2207. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  2208. }
  2209. }
  2210. first = (ts || bs || ls || rs);
  2211. if (o.snapMode !== "outer") {
  2212. ts = Math.abs(t - y1) <= d;
  2213. bs = Math.abs(b - y2) <= d;
  2214. ls = Math.abs(l - x1) <= d;
  2215. rs = Math.abs(r - x2) <= d;
  2216. if (ts) {
  2217. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  2218. }
  2219. if (bs) {
  2220. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  2221. }
  2222. if (ls) {
  2223. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  2224. }
  2225. if (rs) {
  2226. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  2227. }
  2228. }
  2229. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2230. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2231. }
  2232. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2233. }
  2234. }
  2235. });
  2236. $.ui.plugin.add("draggable", "stack", {
  2237. start: function( event, ui, instance ) {
  2238. var min,
  2239. o = instance.options,
  2240. group = $.makeArray($(o.stack)).sort(function(a, b) {
  2241. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  2242. });
  2243. if (!group.length) { return; }
  2244. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2245. $(group).each(function(i) {
  2246. $(this).css("zIndex", min + i);
  2247. });
  2248. this.css("zIndex", (min + group.length));
  2249. }
  2250. });
  2251. $.ui.plugin.add("draggable", "zIndex", {
  2252. start: function( event, ui, instance ) {
  2253. var t = $( ui.helper ),
  2254. o = instance.options;
  2255. if (t.css("zIndex")) {
  2256. o._zIndex = t.css("zIndex");
  2257. }
  2258. t.css("zIndex", o.zIndex);
  2259. },
  2260. stop: function( event, ui, instance ) {
  2261. var o = instance.options;
  2262. if (o._zIndex) {
  2263. $(ui.helper).css("zIndex", o._zIndex);
  2264. }
  2265. }
  2266. });
  2267. var draggable = $.ui.draggable;
  2268. /*!
  2269. * jQuery UI Droppable 1.11.4
  2270. * http://jqueryui.com
  2271. *
  2272. * Copyright jQuery Foundation and other contributors
  2273. * Released under the MIT license.
  2274. * http://jquery.org/license
  2275. *
  2276. * http://api.jqueryui.com/droppable/
  2277. */
  2278. $.widget( "ui.droppable", {
  2279. version: "1.11.4",
  2280. widgetEventPrefix: "drop",
  2281. options: {
  2282. accept: "*",
  2283. activeClass: false,
  2284. addClasses: true,
  2285. greedy: false,
  2286. hoverClass: false,
  2287. scope: "default",
  2288. tolerance: "intersect",
  2289. // callbacks
  2290. activate: null,
  2291. deactivate: null,
  2292. drop: null,
  2293. out: null,
  2294. over: null
  2295. },
  2296. _create: function() {
  2297. var proportions,
  2298. o = this.options,
  2299. accept = o.accept;
  2300. this.isover = false;
  2301. this.isout = true;
  2302. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2303. return d.is( accept );
  2304. };
  2305. this.proportions = function( /* valueToWrite */ ) {
  2306. if ( arguments.length ) {
  2307. // Store the droppable's proportions
  2308. proportions = arguments[ 0 ];
  2309. } else {
  2310. // Retrieve or derive the droppable's proportions
  2311. return proportions ?
  2312. proportions :
  2313. proportions = {
  2314. width: this.element[ 0 ].offsetWidth,
  2315. height: this.element[ 0 ].offsetHeight
  2316. };
  2317. }
  2318. };
  2319. this._addToManager( o.scope );
  2320. o.addClasses && this.element.addClass( "ui-droppable" );
  2321. },
  2322. _addToManager: function( scope ) {
  2323. // Add the reference and positions to the manager
  2324. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2325. $.ui.ddmanager.droppables[ scope ].push( this );
  2326. },
  2327. _splice: function( drop ) {
  2328. var i = 0;
  2329. for ( ; i < drop.length; i++ ) {
  2330. if ( drop[ i ] === this ) {
  2331. drop.splice( i, 1 );
  2332. }
  2333. }
  2334. },
  2335. _destroy: function() {
  2336. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2337. this._splice( drop );
  2338. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  2339. },
  2340. _setOption: function( key, value ) {
  2341. if ( key === "accept" ) {
  2342. this.accept = $.isFunction( value ) ? value : function( d ) {
  2343. return d.is( value );
  2344. };
  2345. } else if ( key === "scope" ) {
  2346. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2347. this._splice( drop );
  2348. this._addToManager( value );
  2349. }
  2350. this._super( key, value );
  2351. },
  2352. _activate: function( event ) {
  2353. var draggable = $.ui.ddmanager.current;
  2354. if ( this.options.activeClass ) {
  2355. this.element.addClass( this.options.activeClass );
  2356. }
  2357. if ( draggable ){
  2358. this._trigger( "activate", event, this.ui( draggable ) );
  2359. }
  2360. },
  2361. _deactivate: function( event ) {
  2362. var draggable = $.ui.ddmanager.current;
  2363. if ( this.options.activeClass ) {
  2364. this.element.removeClass( this.options.activeClass );
  2365. }
  2366. if ( draggable ){
  2367. this._trigger( "deactivate", event, this.ui( draggable ) );
  2368. }
  2369. },
  2370. _over: function( event ) {
  2371. var draggable = $.ui.ddmanager.current;
  2372. // Bail if draggable and droppable are same element
  2373. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2374. return;
  2375. }
  2376. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2377. if ( this.options.hoverClass ) {
  2378. this.element.addClass( this.options.hoverClass );
  2379. }
  2380. this._trigger( "over", event, this.ui( draggable ) );
  2381. }
  2382. },
  2383. _out: function( event ) {
  2384. var draggable = $.ui.ddmanager.current;
  2385. // Bail if draggable and droppable are same element
  2386. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2387. return;
  2388. }
  2389. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2390. if ( this.options.hoverClass ) {
  2391. this.element.removeClass( this.options.hoverClass );
  2392. }
  2393. this._trigger( "out", event, this.ui( draggable ) );
  2394. }
  2395. },
  2396. _drop: function( event, custom ) {
  2397. var draggable = custom || $.ui.ddmanager.current,
  2398. childrenIntersection = false;
  2399. // Bail if draggable and droppable are same element
  2400. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2401. return false;
  2402. }
  2403. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  2404. var inst = $( this ).droppable( "instance" );
  2405. if (
  2406. inst.options.greedy &&
  2407. !inst.options.disabled &&
  2408. inst.options.scope === draggable.options.scope &&
  2409. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  2410. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  2411. ) { childrenIntersection = true; return false; }
  2412. });
  2413. if ( childrenIntersection ) {
  2414. return false;
  2415. }
  2416. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2417. if ( this.options.activeClass ) {
  2418. this.element.removeClass( this.options.activeClass );
  2419. }
  2420. if ( this.options.hoverClass ) {
  2421. this.element.removeClass( this.options.hoverClass );
  2422. }
  2423. this._trigger( "drop", event, this.ui( draggable ) );
  2424. return this.element;
  2425. }
  2426. return false;
  2427. },
  2428. ui: function( c ) {
  2429. return {
  2430. draggable: ( c.currentItem || c.element ),
  2431. helper: c.helper,
  2432. position: c.position,
  2433. offset: c.positionAbs
  2434. };
  2435. }
  2436. });
  2437. $.ui.intersect = (function() {
  2438. function isOverAxis( x, reference, size ) {
  2439. return ( x >= reference ) && ( x < ( reference + size ) );
  2440. }
  2441. return function( draggable, droppable, toleranceMode, event ) {
  2442. if ( !droppable.offset ) {
  2443. return false;
  2444. }
  2445. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  2446. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  2447. x2 = x1 + draggable.helperProportions.width,
  2448. y2 = y1 + draggable.helperProportions.height,
  2449. l = droppable.offset.left,
  2450. t = droppable.offset.top,
  2451. r = l + droppable.proportions().width,
  2452. b = t + droppable.proportions().height;
  2453. switch ( toleranceMode ) {
  2454. case "fit":
  2455. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2456. case "intersect":
  2457. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2458. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2459. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2460. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2461. case "pointer":
  2462. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2463. case "touch":
  2464. return (
  2465. ( y1 >= t && y1 <= b ) || // Top edge touching
  2466. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2467. ( y1 < t && y2 > b ) // Surrounded vertically
  2468. ) && (
  2469. ( x1 >= l && x1 <= r ) || // Left edge touching
  2470. ( x2 >= l && x2 <= r ) || // Right edge touching
  2471. ( x1 < l && x2 > r ) // Surrounded horizontally
  2472. );
  2473. default:
  2474. return false;
  2475. }
  2476. };
  2477. })();
  2478. /*
  2479. This manager tracks offsets of draggables and droppables
  2480. */
  2481. $.ui.ddmanager = {
  2482. current: null,
  2483. droppables: { "default": [] },
  2484. prepareOffsets: function( t, event ) {
  2485. var i, j,
  2486. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2487. type = event ? event.type : null, // workaround for #2317
  2488. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2489. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2490. // No disabled and non-accepted
  2491. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2492. continue;
  2493. }
  2494. // Filter out elements in the current dragged item
  2495. for ( j = 0; j < list.length; j++ ) {
  2496. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2497. m[ i ].proportions().height = 0;
  2498. continue droppablesLoop;
  2499. }
  2500. }
  2501. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2502. if ( !m[ i ].visible ) {
  2503. continue;
  2504. }
  2505. // Activate the droppable if used directly from draggables
  2506. if ( type === "mousedown" ) {
  2507. m[ i ]._activate.call( m[ i ], event );
  2508. }
  2509. m[ i ].offset = m[ i ].element.offset();
  2510. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2511. }
  2512. },
  2513. drop: function( draggable, event ) {
  2514. var dropped = false;
  2515. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2516. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2517. if ( !this.options ) {
  2518. return;
  2519. }
  2520. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2521. dropped = this._drop.call( this, event ) || dropped;
  2522. }
  2523. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2524. this.isout = true;
  2525. this.isover = false;
  2526. this._deactivate.call( this, event );
  2527. }
  2528. });
  2529. return dropped;
  2530. },
  2531. dragStart: function( draggable, event ) {
  2532. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2533. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2534. if ( !draggable.options.refreshPositions ) {
  2535. $.ui.ddmanager.prepareOffsets( draggable, event );
  2536. }
  2537. });
  2538. },
  2539. drag: function( draggable, event ) {
  2540. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2541. if ( draggable.options.refreshPositions ) {
  2542. $.ui.ddmanager.prepareOffsets( draggable, event );
  2543. }
  2544. // Run through all droppables and check their positions based on specific tolerance options
  2545. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2546. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2547. return;
  2548. }
  2549. var parentInstance, scope, parent,
  2550. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2551. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2552. if ( !c ) {
  2553. return;
  2554. }
  2555. if ( this.options.greedy ) {
  2556. // find droppable parents with same scope
  2557. scope = this.options.scope;
  2558. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  2559. return $( this ).droppable( "instance" ).options.scope === scope;
  2560. });
  2561. if ( parent.length ) {
  2562. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2563. parentInstance.greedyChild = ( c === "isover" );
  2564. }
  2565. }
  2566. // we just moved into a greedy child
  2567. if ( parentInstance && c === "isover" ) {
  2568. parentInstance.isover = false;
  2569. parentInstance.isout = true;
  2570. parentInstance._out.call( parentInstance, event );
  2571. }
  2572. this[ c ] = true;
  2573. this[c === "isout" ? "isover" : "isout"] = false;
  2574. this[c === "isover" ? "_over" : "_out"].call( this, event );
  2575. // we just moved out of a greedy child
  2576. if ( parentInstance && c === "isout" ) {
  2577. parentInstance.isout = false;
  2578. parentInstance.isover = true;
  2579. parentInstance._over.call( parentInstance, event );
  2580. }
  2581. });
  2582. },
  2583. dragStop: function( draggable, event ) {
  2584. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2585. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2586. if ( !draggable.options.refreshPositions ) {
  2587. $.ui.ddmanager.prepareOffsets( draggable, event );
  2588. }
  2589. }
  2590. };
  2591. var droppable = $.ui.droppable;
  2592. /*!
  2593. * jQuery UI Resizable 1.11.4
  2594. * http://jqueryui.com
  2595. *
  2596. * Copyright jQuery Foundation and other contributors
  2597. * Released under the MIT license.
  2598. * http://jquery.org/license
  2599. *
  2600. * http://api.jqueryui.com/resizable/
  2601. */
  2602. $.widget("ui.resizable", $.ui.mouse, {
  2603. version: "1.11.4",
  2604. widgetEventPrefix: "resize",
  2605. options: {
  2606. alsoResize: false,
  2607. animate: false,
  2608. animateDuration: "slow",
  2609. animateEasing: "swing",
  2610. aspectRatio: false,
  2611. autoHide: false,
  2612. containment: false,
  2613. ghost: false,
  2614. grid: false,
  2615. handles: "e,s,se",
  2616. helper: false,
  2617. maxHeight: null,
  2618. maxWidth: null,
  2619. minHeight: 10,
  2620. minWidth: 10,
  2621. // See #7960
  2622. zIndex: 90,
  2623. // callbacks
  2624. resize: null,
  2625. start: null,
  2626. stop: null
  2627. },
  2628. _num: function( value ) {
  2629. return parseInt( value, 10 ) || 0;
  2630. },
  2631. _isNumber: function( value ) {
  2632. return !isNaN( parseInt( value, 10 ) );
  2633. },
  2634. _hasScroll: function( el, a ) {
  2635. if ( $( el ).css( "overflow" ) === "hidden") {
  2636. return false;
  2637. }
  2638. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  2639. has = false;
  2640. if ( el[ scroll ] > 0 ) {
  2641. return true;
  2642. }
  2643. // TODO: determine which cases actually cause this to happen
  2644. // if the element doesn't have the scroll set, see if it's possible to
  2645. // set the scroll
  2646. el[ scroll ] = 1;
  2647. has = ( el[ scroll ] > 0 );
  2648. el[ scroll ] = 0;
  2649. return has;
  2650. },
  2651. _create: function() {
  2652. var n, i, handle, axis, hname,
  2653. that = this,
  2654. o = this.options;
  2655. this.element.addClass("ui-resizable");
  2656. $.extend(this, {
  2657. _aspectRatio: !!(o.aspectRatio),
  2658. aspectRatio: o.aspectRatio,
  2659. originalElement: this.element,
  2660. _proportionallyResizeElements: [],
  2661. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2662. });
  2663. // Wrap the element if it cannot hold child nodes
  2664. if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
  2665. this.element.wrap(
  2666. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2667. position: this.element.css("position"),
  2668. width: this.element.outerWidth(),
  2669. height: this.element.outerHeight(),
  2670. top: this.element.css("top"),
  2671. left: this.element.css("left")
  2672. })
  2673. );
  2674. this.element = this.element.parent().data(
  2675. "ui-resizable", this.element.resizable( "instance" )
  2676. );
  2677. this.elementIsWrapper = true;
  2678. this.element.css({
  2679. marginLeft: this.originalElement.css("marginLeft"),
  2680. marginTop: this.originalElement.css("marginTop"),
  2681. marginRight: this.originalElement.css("marginRight"),
  2682. marginBottom: this.originalElement.css("marginBottom")
  2683. });
  2684. this.originalElement.css({
  2685. marginLeft: 0,
  2686. marginTop: 0,
  2687. marginRight: 0,
  2688. marginBottom: 0
  2689. });
  2690. // support: Safari
  2691. // Prevent Safari textarea resize
  2692. this.originalResizeStyle = this.originalElement.css("resize");
  2693. this.originalElement.css("resize", "none");
  2694. this._proportionallyResizeElements.push( this.originalElement.css({
  2695. position: "static",
  2696. zoom: 1,
  2697. display: "block"
  2698. }) );
  2699. // support: IE9
  2700. // avoid IE jump (hard set the margin)
  2701. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2702. this._proportionallyResize();
  2703. }
  2704. this.handles = o.handles ||
  2705. ( !$(".ui-resizable-handle", this.element).length ?
  2706. "e,s,se" : {
  2707. n: ".ui-resizable-n",
  2708. e: ".ui-resizable-e",
  2709. s: ".ui-resizable-s",
  2710. w: ".ui-resizable-w",
  2711. se: ".ui-resizable-se",
  2712. sw: ".ui-resizable-sw",
  2713. ne: ".ui-resizable-ne",
  2714. nw: ".ui-resizable-nw"
  2715. } );
  2716. this._handles = $();
  2717. if ( this.handles.constructor === String ) {
  2718. if ( this.handles === "all") {
  2719. this.handles = "n,e,s,w,se,sw,ne,nw";
  2720. }
  2721. n = this.handles.split(",");
  2722. this.handles = {};
  2723. for (i = 0; i < n.length; i++) {
  2724. handle = $.trim(n[i]);
  2725. hname = "ui-resizable-" + handle;
  2726. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2727. axis.css({ zIndex: o.zIndex });
  2728. // TODO : What's going on here?
  2729. if ("se" === handle) {
  2730. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2731. }
  2732. this.handles[handle] = ".ui-resizable-" + handle;
  2733. this.element.append(axis);
  2734. }
  2735. }
  2736. this._renderAxis = function(target) {
  2737. var i, axis, padPos, padWrapper;
  2738. target = target || this.element;
  2739. for (i in this.handles) {
  2740. if (this.handles[i].constructor === String) {
  2741. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  2742. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  2743. this.handles[ i ] = $( this.handles[ i ] );
  2744. this._on( this.handles[ i ], { "mousedown": that._mouseDown });
  2745. }
  2746. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
  2747. axis = $(this.handles[i], this.element);
  2748. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2749. padPos = [ "padding",
  2750. /ne|nw|n/.test(i) ? "Top" :
  2751. /se|sw|s/.test(i) ? "Bottom" :
  2752. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2753. target.css(padPos, padWrapper);
  2754. this._proportionallyResize();
  2755. }
  2756. this._handles = this._handles.add( this.handles[ i ] );
  2757. }
  2758. };
  2759. // TODO: make renderAxis a prototype function
  2760. this._renderAxis(this.element);
  2761. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  2762. this._handles.disableSelection();
  2763. this._handles.mouseover(function() {
  2764. if (!that.resizing) {
  2765. if (this.className) {
  2766. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2767. }
  2768. that.axis = axis && axis[1] ? axis[1] : "se";
  2769. }
  2770. });
  2771. if (o.autoHide) {
  2772. this._handles.hide();
  2773. $(this.element)
  2774. .addClass("ui-resizable-autohide")
  2775. .mouseenter(function() {
  2776. if (o.disabled) {
  2777. return;
  2778. }
  2779. $(this).removeClass("ui-resizable-autohide");
  2780. that._handles.show();
  2781. })
  2782. .mouseleave(function() {
  2783. if (o.disabled) {
  2784. return;
  2785. }
  2786. if (!that.resizing) {
  2787. $(this).addClass("ui-resizable-autohide");
  2788. that._handles.hide();
  2789. }
  2790. });
  2791. }
  2792. this._mouseInit();
  2793. },
  2794. _destroy: function() {
  2795. this._mouseDestroy();
  2796. var wrapper,
  2797. _destroy = function(exp) {
  2798. $(exp)
  2799. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2800. .removeData("resizable")
  2801. .removeData("ui-resizable")
  2802. .unbind(".resizable")
  2803. .find(".ui-resizable-handle")
  2804. .remove();
  2805. };
  2806. // TODO: Unwrap at same DOM position
  2807. if (this.elementIsWrapper) {
  2808. _destroy(this.element);
  2809. wrapper = this.element;
  2810. this.originalElement.css({
  2811. position: wrapper.css("position"),
  2812. width: wrapper.outerWidth(),
  2813. height: wrapper.outerHeight(),
  2814. top: wrapper.css("top"),
  2815. left: wrapper.css("left")
  2816. }).insertAfter( wrapper );
  2817. wrapper.remove();
  2818. }
  2819. this.originalElement.css("resize", this.originalResizeStyle);
  2820. _destroy(this.originalElement);
  2821. return this;
  2822. },
  2823. _mouseCapture: function(event) {
  2824. var i, handle,
  2825. capture = false;
  2826. for (i in this.handles) {
  2827. handle = $(this.handles[i])[0];
  2828. if (handle === event.target || $.contains(handle, event.target)) {
  2829. capture = true;
  2830. }
  2831. }
  2832. return !this.options.disabled && capture;
  2833. },
  2834. _mouseStart: function(event) {
  2835. var curleft, curtop, cursor,
  2836. o = this.options,
  2837. el = this.element;
  2838. this.resizing = true;
  2839. this._renderProxy();
  2840. curleft = this._num(this.helper.css("left"));
  2841. curtop = this._num(this.helper.css("top"));
  2842. if (o.containment) {
  2843. curleft += $(o.containment).scrollLeft() || 0;
  2844. curtop += $(o.containment).scrollTop() || 0;
  2845. }
  2846. this.offset = this.helper.offset();
  2847. this.position = { left: curleft, top: curtop };
  2848. this.size = this._helper ? {
  2849. width: this.helper.width(),
  2850. height: this.helper.height()
  2851. } : {
  2852. width: el.width(),
  2853. height: el.height()
  2854. };
  2855. this.originalSize = this._helper ? {
  2856. width: el.outerWidth(),
  2857. height: el.outerHeight()
  2858. } : {
  2859. width: el.width(),
  2860. height: el.height()
  2861. };
  2862. this.sizeDiff = {
  2863. width: el.outerWidth() - el.width(),
  2864. height: el.outerHeight() - el.height()
  2865. };
  2866. this.originalPosition = { left: curleft, top: curtop };
  2867. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2868. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  2869. o.aspectRatio :
  2870. ((this.originalSize.width / this.originalSize.height) || 1);
  2871. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2872. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2873. el.addClass("ui-resizable-resizing");
  2874. this._propagate("start", event);
  2875. return true;
  2876. },
  2877. _mouseDrag: function(event) {
  2878. var data, props,
  2879. smp = this.originalMousePosition,
  2880. a = this.axis,
  2881. dx = (event.pageX - smp.left) || 0,
  2882. dy = (event.pageY - smp.top) || 0,
  2883. trigger = this._change[a];
  2884. this._updatePrevProperties();
  2885. if (!trigger) {
  2886. return false;
  2887. }
  2888. data = trigger.apply(this, [ event, dx, dy ]);
  2889. this._updateVirtualBoundaries(event.shiftKey);
  2890. if (this._aspectRatio || event.shiftKey) {
  2891. data = this._updateRatio(data, event);
  2892. }
  2893. data = this._respectSize(data, event);
  2894. this._updateCache(data);
  2895. this._propagate("resize", event);
  2896. props = this._applyChanges();
  2897. if ( !this._helper && this._proportionallyResizeElements.length ) {
  2898. this._proportionallyResize();
  2899. }
  2900. if ( !$.isEmptyObject( props ) ) {
  2901. this._updatePrevProperties();
  2902. this._trigger( "resize", event, this.ui() );
  2903. this._applyChanges();
  2904. }
  2905. return false;
  2906. },
  2907. _mouseStop: function(event) {
  2908. this.resizing = false;
  2909. var pr, ista, soffseth, soffsetw, s, left, top,
  2910. o = this.options, that = this;
  2911. if (this._helper) {
  2912. pr = this._proportionallyResizeElements;
  2913. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2914. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  2915. soffsetw = ista ? 0 : that.sizeDiff.width;
  2916. s = {
  2917. width: (that.helper.width() - soffsetw),
  2918. height: (that.helper.height() - soffseth)
  2919. };
  2920. left = (parseInt(that.element.css("left"), 10) +
  2921. (that.position.left - that.originalPosition.left)) || null;
  2922. top = (parseInt(that.element.css("top"), 10) +
  2923. (that.position.top - that.originalPosition.top)) || null;
  2924. if (!o.animate) {
  2925. this.element.css($.extend(s, { top: top, left: left }));
  2926. }
  2927. that.helper.height(that.size.height);
  2928. that.helper.width(that.size.width);
  2929. if (this._helper && !o.animate) {
  2930. this._proportionallyResize();
  2931. }
  2932. }
  2933. $("body").css("cursor", "auto");
  2934. this.element.removeClass("ui-resizable-resizing");
  2935. this._propagate("stop", event);
  2936. if (this._helper) {
  2937. this.helper.remove();
  2938. }
  2939. return false;
  2940. },
  2941. _updatePrevProperties: function() {
  2942. this.prevPosition = {
  2943. top: this.position.top,
  2944. left: this.position.left
  2945. };
  2946. this.prevSize = {
  2947. width: this.size.width,
  2948. height: this.size.height
  2949. };
  2950. },
  2951. _applyChanges: function() {
  2952. var props = {};
  2953. if ( this.position.top !== this.prevPosition.top ) {
  2954. props.top = this.position.top + "px";
  2955. }
  2956. if ( this.position.left !== this.prevPosition.left ) {
  2957. props.left = this.position.left + "px";
  2958. }
  2959. if ( this.size.width !== this.prevSize.width ) {
  2960. props.width = this.size.width + "px";
  2961. }
  2962. if ( this.size.height !== this.prevSize.height ) {
  2963. props.height = this.size.height + "px";
  2964. }
  2965. this.helper.css( props );
  2966. return props;
  2967. },
  2968. _updateVirtualBoundaries: function(forceAspectRatio) {
  2969. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2970. o = this.options;
  2971. b = {
  2972. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  2973. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2974. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  2975. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2976. };
  2977. if (this._aspectRatio || forceAspectRatio) {
  2978. pMinWidth = b.minHeight * this.aspectRatio;
  2979. pMinHeight = b.minWidth / this.aspectRatio;
  2980. pMaxWidth = b.maxHeight * this.aspectRatio;
  2981. pMaxHeight = b.maxWidth / this.aspectRatio;
  2982. if (pMinWidth > b.minWidth) {
  2983. b.minWidth = pMinWidth;
  2984. }
  2985. if (pMinHeight > b.minHeight) {
  2986. b.minHeight = pMinHeight;
  2987. }
  2988. if (pMaxWidth < b.maxWidth) {
  2989. b.maxWidth = pMaxWidth;
  2990. }
  2991. if (pMaxHeight < b.maxHeight) {
  2992. b.maxHeight = pMaxHeight;
  2993. }
  2994. }
  2995. this._vBoundaries = b;
  2996. },
  2997. _updateCache: function(data) {
  2998. this.offset = this.helper.offset();
  2999. if (this._isNumber(data.left)) {
  3000. this.position.left = data.left;
  3001. }
  3002. if (this._isNumber(data.top)) {
  3003. this.position.top = data.top;
  3004. }
  3005. if (this._isNumber(data.height)) {
  3006. this.size.height = data.height;
  3007. }
  3008. if (this._isNumber(data.width)) {
  3009. this.size.width = data.width;
  3010. }
  3011. },
  3012. _updateRatio: function( data ) {
  3013. var cpos = this.position,
  3014. csize = this.size,
  3015. a = this.axis;
  3016. if (this._isNumber(data.height)) {
  3017. data.width = (data.height * this.aspectRatio);
  3018. } else if (this._isNumber(data.width)) {
  3019. data.height = (data.width / this.aspectRatio);
  3020. }
  3021. if (a === "sw") {
  3022. data.left = cpos.left + (csize.width - data.width);
  3023. data.top = null;
  3024. }
  3025. if (a === "nw") {
  3026. data.top = cpos.top + (csize.height - data.height);
  3027. data.left = cpos.left + (csize.width - data.width);
  3028. }
  3029. return data;
  3030. },
  3031. _respectSize: function( data ) {
  3032. var o = this._vBoundaries,
  3033. a = this.axis,
  3034. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  3035. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  3036. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  3037. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  3038. dw = this.originalPosition.left + this.originalSize.width,
  3039. dh = this.position.top + this.size.height,
  3040. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  3041. if (isminw) {
  3042. data.width = o.minWidth;
  3043. }
  3044. if (isminh) {
  3045. data.height = o.minHeight;
  3046. }
  3047. if (ismaxw) {
  3048. data.width = o.maxWidth;
  3049. }
  3050. if (ismaxh) {
  3051. data.height = o.maxHeight;
  3052. }
  3053. if (isminw && cw) {
  3054. data.left = dw - o.minWidth;
  3055. }
  3056. if (ismaxw && cw) {
  3057. data.left = dw - o.maxWidth;
  3058. }
  3059. if (isminh && ch) {
  3060. data.top = dh - o.minHeight;
  3061. }
  3062. if (ismaxh && ch) {
  3063. data.top = dh - o.maxHeight;
  3064. }
  3065. // Fixing jump error on top/left - bug #2330
  3066. if (!data.width && !data.height && !data.left && data.top) {
  3067. data.top = null;
  3068. } else if (!data.width && !data.height && !data.top && data.left) {
  3069. data.left = null;
  3070. }
  3071. return data;
  3072. },
  3073. _getPaddingPlusBorderDimensions: function( element ) {
  3074. var i = 0,
  3075. widths = [],
  3076. borders = [
  3077. element.css( "borderTopWidth" ),
  3078. element.css( "borderRightWidth" ),
  3079. element.css( "borderBottomWidth" ),
  3080. element.css( "borderLeftWidth" )
  3081. ],
  3082. paddings = [
  3083. element.css( "paddingTop" ),
  3084. element.css( "paddingRight" ),
  3085. element.css( "paddingBottom" ),
  3086. element.css( "paddingLeft" )
  3087. ];
  3088. for ( ; i < 4; i++ ) {
  3089. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  3090. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  3091. }
  3092. return {
  3093. height: widths[ 0 ] + widths[ 2 ],
  3094. width: widths[ 1 ] + widths[ 3 ]
  3095. };
  3096. },
  3097. _proportionallyResize: function() {
  3098. if (!this._proportionallyResizeElements.length) {
  3099. return;
  3100. }
  3101. var prel,
  3102. i = 0,
  3103. element = this.helper || this.element;
  3104. for ( ; i < this._proportionallyResizeElements.length; i++) {
  3105. prel = this._proportionallyResizeElements[i];
  3106. // TODO: Seems like a bug to cache this.outerDimensions
  3107. // considering that we are in a loop.
  3108. if (!this.outerDimensions) {
  3109. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3110. }
  3111. prel.css({
  3112. height: (element.height() - this.outerDimensions.height) || 0,
  3113. width: (element.width() - this.outerDimensions.width) || 0
  3114. });
  3115. }
  3116. },
  3117. _renderProxy: function() {
  3118. var el = this.element, o = this.options;
  3119. this.elementOffset = el.offset();
  3120. if (this._helper) {
  3121. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  3122. this.helper.addClass(this._helper).css({
  3123. width: this.element.outerWidth() - 1,
  3124. height: this.element.outerHeight() - 1,
  3125. position: "absolute",
  3126. left: this.elementOffset.left + "px",
  3127. top: this.elementOffset.top + "px",
  3128. zIndex: ++o.zIndex //TODO: Don't modify option
  3129. });
  3130. this.helper
  3131. .appendTo("body")
  3132. .disableSelection();
  3133. } else {
  3134. this.helper = this.element;
  3135. }
  3136. },
  3137. _change: {
  3138. e: function(event, dx) {
  3139. return { width: this.originalSize.width + dx };
  3140. },
  3141. w: function(event, dx) {
  3142. var cs = this.originalSize, sp = this.originalPosition;
  3143. return { left: sp.left + dx, width: cs.width - dx };
  3144. },
  3145. n: function(event, dx, dy) {
  3146. var cs = this.originalSize, sp = this.originalPosition;
  3147. return { top: sp.top + dy, height: cs.height - dy };
  3148. },
  3149. s: function(event, dx, dy) {
  3150. return { height: this.originalSize.height + dy };
  3151. },
  3152. se: function(event, dx, dy) {
  3153. return $.extend(this._change.s.apply(this, arguments),
  3154. this._change.e.apply(this, [ event, dx, dy ]));
  3155. },
  3156. sw: function(event, dx, dy) {
  3157. return $.extend(this._change.s.apply(this, arguments),
  3158. this._change.w.apply(this, [ event, dx, dy ]));
  3159. },
  3160. ne: function(event, dx, dy) {
  3161. return $.extend(this._change.n.apply(this, arguments),
  3162. this._change.e.apply(this, [ event, dx, dy ]));
  3163. },
  3164. nw: function(event, dx, dy) {
  3165. return $.extend(this._change.n.apply(this, arguments),
  3166. this._change.w.apply(this, [ event, dx, dy ]));
  3167. }
  3168. },
  3169. _propagate: function(n, event) {
  3170. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  3171. (n !== "resize" && this._trigger(n, event, this.ui()));
  3172. },
  3173. plugins: {},
  3174. ui: function() {
  3175. return {
  3176. originalElement: this.originalElement,
  3177. element: this.element,
  3178. helper: this.helper,
  3179. position: this.position,
  3180. size: this.size,
  3181. originalSize: this.originalSize,
  3182. originalPosition: this.originalPosition
  3183. };
  3184. }
  3185. });
  3186. /*
  3187. * Resizable Extensions
  3188. */
  3189. $.ui.plugin.add("resizable", "animate", {
  3190. stop: function( event ) {
  3191. var that = $(this).resizable( "instance" ),
  3192. o = that.options,
  3193. pr = that._proportionallyResizeElements,
  3194. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  3195. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  3196. soffsetw = ista ? 0 : that.sizeDiff.width,
  3197. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  3198. left = (parseInt(that.element.css("left"), 10) +
  3199. (that.position.left - that.originalPosition.left)) || null,
  3200. top = (parseInt(that.element.css("top"), 10) +
  3201. (that.position.top - that.originalPosition.top)) || null;
  3202. that.element.animate(
  3203. $.extend(style, top && left ? { top: top, left: left } : {}), {
  3204. duration: o.animateDuration,
  3205. easing: o.animateEasing,
  3206. step: function() {
  3207. var data = {
  3208. width: parseInt(that.element.css("width"), 10),
  3209. height: parseInt(that.element.css("height"), 10),
  3210. top: parseInt(that.element.css("top"), 10),
  3211. left: parseInt(that.element.css("left"), 10)
  3212. };
  3213. if (pr && pr.length) {
  3214. $(pr[0]).css({ width: data.width, height: data.height });
  3215. }
  3216. // propagating resize, and updating values for each animation step
  3217. that._updateCache(data);
  3218. that._propagate("resize", event);
  3219. }
  3220. }
  3221. );
  3222. }
  3223. });
  3224. $.ui.plugin.add( "resizable", "containment", {
  3225. start: function() {
  3226. var element, p, co, ch, cw, width, height,
  3227. that = $( this ).resizable( "instance" ),
  3228. o = that.options,
  3229. el = that.element,
  3230. oc = o.containment,
  3231. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3232. if ( !ce ) {
  3233. return;
  3234. }
  3235. that.containerElement = $( ce );
  3236. if ( /document/.test( oc ) || oc === document ) {
  3237. that.containerOffset = {
  3238. left: 0,
  3239. top: 0
  3240. };
  3241. that.containerPosition = {
  3242. left: 0,
  3243. top: 0
  3244. };
  3245. that.parentData = {
  3246. element: $( document ),
  3247. left: 0,
  3248. top: 0,
  3249. width: $( document ).width(),
  3250. height: $( document ).height() || document.body.parentNode.scrollHeight
  3251. };
  3252. } else {
  3253. element = $( ce );
  3254. p = [];
  3255. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  3256. p[ i ] = that._num( element.css( "padding" + name ) );
  3257. });
  3258. that.containerOffset = element.offset();
  3259. that.containerPosition = element.position();
  3260. that.containerSize = {
  3261. height: ( element.innerHeight() - p[ 3 ] ),
  3262. width: ( element.innerWidth() - p[ 1 ] )
  3263. };
  3264. co = that.containerOffset;
  3265. ch = that.containerSize.height;
  3266. cw = that.containerSize.width;
  3267. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3268. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3269. that.parentData = {
  3270. element: ce,
  3271. left: co.left,
  3272. top: co.top,
  3273. width: width,
  3274. height: height
  3275. };
  3276. }
  3277. },
  3278. resize: function( event ) {
  3279. var woset, hoset, isParent, isOffsetRelative,
  3280. that = $( this ).resizable( "instance" ),
  3281. o = that.options,
  3282. co = that.containerOffset,
  3283. cp = that.position,
  3284. pRatio = that._aspectRatio || event.shiftKey,
  3285. cop = {
  3286. top: 0,
  3287. left: 0
  3288. },
  3289. ce = that.containerElement,
  3290. continueResize = true;
  3291. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3292. cop = co;
  3293. }
  3294. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3295. that.size.width = that.size.width +
  3296. ( that._helper ?
  3297. ( that.position.left - co.left ) :
  3298. ( that.position.left - cop.left ) );
  3299. if ( pRatio ) {
  3300. that.size.height = that.size.width / that.aspectRatio;
  3301. continueResize = false;
  3302. }
  3303. that.position.left = o.helper ? co.left : 0;
  3304. }
  3305. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3306. that.size.height = that.size.height +
  3307. ( that._helper ?
  3308. ( that.position.top - co.top ) :
  3309. that.position.top );
  3310. if ( pRatio ) {
  3311. that.size.width = that.size.height * that.aspectRatio;
  3312. continueResize = false;
  3313. }
  3314. that.position.top = that._helper ? co.top : 0;
  3315. }
  3316. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3317. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3318. if ( isParent && isOffsetRelative ) {
  3319. that.offset.left = that.parentData.left + that.position.left;
  3320. that.offset.top = that.parentData.top + that.position.top;
  3321. } else {
  3322. that.offset.left = that.element.offset().left;
  3323. that.offset.top = that.element.offset().top;
  3324. }
  3325. woset = Math.abs( that.sizeDiff.width +
  3326. (that._helper ?
  3327. that.offset.left - cop.left :
  3328. (that.offset.left - co.left)) );
  3329. hoset = Math.abs( that.sizeDiff.height +
  3330. (that._helper ?
  3331. that.offset.top - cop.top :
  3332. (that.offset.top - co.top)) );
  3333. if ( woset + that.size.width >= that.parentData.width ) {
  3334. that.size.width = that.parentData.width - woset;
  3335. if ( pRatio ) {
  3336. that.size.height = that.size.width / that.aspectRatio;
  3337. continueResize = false;
  3338. }
  3339. }
  3340. if ( hoset + that.size.height >= that.parentData.height ) {
  3341. that.size.height = that.parentData.height - hoset;
  3342. if ( pRatio ) {
  3343. that.size.width = that.size.height * that.aspectRatio;
  3344. continueResize = false;
  3345. }
  3346. }
  3347. if ( !continueResize ) {
  3348. that.position.left = that.prevPosition.left;
  3349. that.position.top = that.prevPosition.top;
  3350. that.size.width = that.prevSize.width;
  3351. that.size.height = that.prevSize.height;
  3352. }
  3353. },
  3354. stop: function() {
  3355. var that = $( this ).resizable( "instance" ),
  3356. o = that.options,
  3357. co = that.containerOffset,
  3358. cop = that.containerPosition,
  3359. ce = that.containerElement,
  3360. helper = $( that.helper ),
  3361. ho = helper.offset(),
  3362. w = helper.outerWidth() - that.sizeDiff.width,
  3363. h = helper.outerHeight() - that.sizeDiff.height;
  3364. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3365. $( this ).css({
  3366. left: ho.left - cop.left - co.left,
  3367. width: w,
  3368. height: h
  3369. });
  3370. }
  3371. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3372. $( this ).css({
  3373. left: ho.left - cop.left - co.left,
  3374. width: w,
  3375. height: h
  3376. });
  3377. }
  3378. }
  3379. });
  3380. $.ui.plugin.add("resizable", "alsoResize", {
  3381. start: function() {
  3382. var that = $(this).resizable( "instance" ),
  3383. o = that.options;
  3384. $(o.alsoResize).each(function() {
  3385. var el = $(this);
  3386. el.data("ui-resizable-alsoresize", {
  3387. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3388. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3389. });
  3390. });
  3391. },
  3392. resize: function(event, ui) {
  3393. var that = $(this).resizable( "instance" ),
  3394. o = that.options,
  3395. os = that.originalSize,
  3396. op = that.originalPosition,
  3397. delta = {
  3398. height: (that.size.height - os.height) || 0,
  3399. width: (that.size.width - os.width) || 0,
  3400. top: (that.position.top - op.top) || 0,
  3401. left: (that.position.left - op.left) || 0
  3402. };
  3403. $(o.alsoResize).each(function() {
  3404. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3405. css = el.parents(ui.originalElement[0]).length ?
  3406. [ "width", "height" ] :
  3407. [ "width", "height", "top", "left" ];
  3408. $.each(css, function(i, prop) {
  3409. var sum = (start[prop] || 0) + (delta[prop] || 0);
  3410. if (sum && sum >= 0) {
  3411. style[prop] = sum || null;
  3412. }
  3413. });
  3414. el.css(style);
  3415. });
  3416. },
  3417. stop: function() {
  3418. $(this).removeData("resizable-alsoresize");
  3419. }
  3420. });
  3421. $.ui.plugin.add("resizable", "ghost", {
  3422. start: function() {
  3423. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  3424. that.ghost = that.originalElement.clone();
  3425. that.ghost
  3426. .css({
  3427. opacity: 0.25,
  3428. display: "block",
  3429. position: "relative",
  3430. height: cs.height,
  3431. width: cs.width,
  3432. margin: 0,
  3433. left: 0,
  3434. top: 0
  3435. })
  3436. .addClass("ui-resizable-ghost")
  3437. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3438. that.ghost.appendTo(that.helper);
  3439. },
  3440. resize: function() {
  3441. var that = $(this).resizable( "instance" );
  3442. if (that.ghost) {
  3443. that.ghost.css({
  3444. position: "relative",
  3445. height: that.size.height,
  3446. width: that.size.width
  3447. });
  3448. }
  3449. },
  3450. stop: function() {
  3451. var that = $(this).resizable( "instance" );
  3452. if (that.ghost && that.helper) {
  3453. that.helper.get(0).removeChild(that.ghost.get(0));
  3454. }
  3455. }
  3456. });
  3457. $.ui.plugin.add("resizable", "grid", {
  3458. resize: function() {
  3459. var outerDimensions,
  3460. that = $(this).resizable( "instance" ),
  3461. o = that.options,
  3462. cs = that.size,
  3463. os = that.originalSize,
  3464. op = that.originalPosition,
  3465. a = that.axis,
  3466. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3467. gridX = (grid[0] || 1),
  3468. gridY = (grid[1] || 1),
  3469. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3470. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3471. newWidth = os.width + ox,
  3472. newHeight = os.height + oy,
  3473. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3474. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3475. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3476. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3477. o.grid = grid;
  3478. if (isMinWidth) {
  3479. newWidth += gridX;
  3480. }
  3481. if (isMinHeight) {
  3482. newHeight += gridY;
  3483. }
  3484. if (isMaxWidth) {
  3485. newWidth -= gridX;
  3486. }
  3487. if (isMaxHeight) {
  3488. newHeight -= gridY;
  3489. }
  3490. if (/^(se|s|e)$/.test(a)) {
  3491. that.size.width = newWidth;
  3492. that.size.height = newHeight;
  3493. } else if (/^(ne)$/.test(a)) {
  3494. that.size.width = newWidth;
  3495. that.size.height = newHeight;
  3496. that.position.top = op.top - oy;
  3497. } else if (/^(sw)$/.test(a)) {
  3498. that.size.width = newWidth;
  3499. that.size.height = newHeight;
  3500. that.position.left = op.left - ox;
  3501. } else {
  3502. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  3503. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  3504. }
  3505. if ( newHeight - gridY > 0 ) {
  3506. that.size.height = newHeight;
  3507. that.position.top = op.top - oy;
  3508. } else {
  3509. newHeight = gridY - outerDimensions.height;
  3510. that.size.height = newHeight;
  3511. that.position.top = op.top + os.height - newHeight;
  3512. }
  3513. if ( newWidth - gridX > 0 ) {
  3514. that.size.width = newWidth;
  3515. that.position.left = op.left - ox;
  3516. } else {
  3517. newWidth = gridX - outerDimensions.width;
  3518. that.size.width = newWidth;
  3519. that.position.left = op.left + os.width - newWidth;
  3520. }
  3521. }
  3522. }
  3523. });
  3524. var resizable = $.ui.resizable;
  3525. /*!
  3526. * jQuery UI Selectable 1.11.4
  3527. * http://jqueryui.com
  3528. *
  3529. * Copyright jQuery Foundation and other contributors
  3530. * Released under the MIT license.
  3531. * http://jquery.org/license
  3532. *
  3533. * http://api.jqueryui.com/selectable/
  3534. */
  3535. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  3536. version: "1.11.4",
  3537. options: {
  3538. appendTo: "body",
  3539. autoRefresh: true,
  3540. distance: 0,
  3541. filter: "*",
  3542. tolerance: "touch",
  3543. // callbacks
  3544. selected: null,
  3545. selecting: null,
  3546. start: null,
  3547. stop: null,
  3548. unselected: null,
  3549. unselecting: null
  3550. },
  3551. _create: function() {
  3552. var selectees,
  3553. that = this;
  3554. this.element.addClass("ui-selectable");
  3555. this.dragged = false;
  3556. // cache selectee children based on filter
  3557. this.refresh = function() {
  3558. selectees = $(that.options.filter, that.element[0]);
  3559. selectees.addClass("ui-selectee");
  3560. selectees.each(function() {
  3561. var $this = $(this),
  3562. pos = $this.offset();
  3563. $.data(this, "selectable-item", {
  3564. element: this,
  3565. $element: $this,
  3566. left: pos.left,
  3567. top: pos.top,
  3568. right: pos.left + $this.outerWidth(),
  3569. bottom: pos.top + $this.outerHeight(),
  3570. startselected: false,
  3571. selected: $this.hasClass("ui-selected"),
  3572. selecting: $this.hasClass("ui-selecting"),
  3573. unselecting: $this.hasClass("ui-unselecting")
  3574. });
  3575. });
  3576. };
  3577. this.refresh();
  3578. this.selectees = selectees.addClass("ui-selectee");
  3579. this._mouseInit();
  3580. this.helper = $("<div class='ui-selectable-helper'></div>");
  3581. },
  3582. _destroy: function() {
  3583. this.selectees
  3584. .removeClass("ui-selectee")
  3585. .removeData("selectable-item");
  3586. this.element
  3587. .removeClass("ui-selectable ui-selectable-disabled");
  3588. this._mouseDestroy();
  3589. },
  3590. _mouseStart: function(event) {
  3591. var that = this,
  3592. options = this.options;
  3593. this.opos = [ event.pageX, event.pageY ];
  3594. if (this.options.disabled) {
  3595. return;
  3596. }
  3597. this.selectees = $(options.filter, this.element[0]);
  3598. this._trigger("start", event);
  3599. $(options.appendTo).append(this.helper);
  3600. // position helper (lasso)
  3601. this.helper.css({
  3602. "left": event.pageX,
  3603. "top": event.pageY,
  3604. "width": 0,
  3605. "height": 0
  3606. });
  3607. if (options.autoRefresh) {
  3608. this.refresh();
  3609. }
  3610. this.selectees.filter(".ui-selected").each(function() {
  3611. var selectee = $.data(this, "selectable-item");
  3612. selectee.startselected = true;
  3613. if (!event.metaKey && !event.ctrlKey) {
  3614. selectee.$element.removeClass("ui-selected");
  3615. selectee.selected = false;
  3616. selectee.$element.addClass("ui-unselecting");
  3617. selectee.unselecting = true;
  3618. // selectable UNSELECTING callback
  3619. that._trigger("unselecting", event, {
  3620. unselecting: selectee.element
  3621. });
  3622. }
  3623. });
  3624. $(event.target).parents().addBack().each(function() {
  3625. var doSelect,
  3626. selectee = $.data(this, "selectable-item");
  3627. if (selectee) {
  3628. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3629. selectee.$element
  3630. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3631. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3632. selectee.unselecting = !doSelect;
  3633. selectee.selecting = doSelect;
  3634. selectee.selected = doSelect;
  3635. // selectable (UN)SELECTING callback
  3636. if (doSelect) {
  3637. that._trigger("selecting", event, {
  3638. selecting: selectee.element
  3639. });
  3640. } else {
  3641. that._trigger("unselecting", event, {
  3642. unselecting: selectee.element
  3643. });
  3644. }
  3645. return false;
  3646. }
  3647. });
  3648. },
  3649. _mouseDrag: function(event) {
  3650. this.dragged = true;
  3651. if (this.options.disabled) {
  3652. return;
  3653. }
  3654. var tmp,
  3655. that = this,
  3656. options = this.options,
  3657. x1 = this.opos[0],
  3658. y1 = this.opos[1],
  3659. x2 = event.pageX,
  3660. y2 = event.pageY;
  3661. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3662. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3663. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  3664. this.selectees.each(function() {
  3665. var selectee = $.data(this, "selectable-item"),
  3666. hit = false;
  3667. //prevent helper from being selected if appendTo: selectable
  3668. if (!selectee || selectee.element === that.element[0]) {
  3669. return;
  3670. }
  3671. if (options.tolerance === "touch") {
  3672. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3673. } else if (options.tolerance === "fit") {
  3674. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3675. }
  3676. if (hit) {
  3677. // SELECT
  3678. if (selectee.selected) {
  3679. selectee.$element.removeClass("ui-selected");
  3680. selectee.selected = false;
  3681. }
  3682. if (selectee.unselecting) {
  3683. selectee.$element.removeClass("ui-unselecting");
  3684. selectee.unselecting = false;
  3685. }
  3686. if (!selectee.selecting) {
  3687. selectee.$element.addClass("ui-selecting");
  3688. selectee.selecting = true;
  3689. // selectable SELECTING callback
  3690. that._trigger("selecting", event, {
  3691. selecting: selectee.element
  3692. });
  3693. }
  3694. } else {
  3695. // UNSELECT
  3696. if (selectee.selecting) {
  3697. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3698. selectee.$element.removeClass("ui-selecting");
  3699. selectee.selecting = false;
  3700. selectee.$element.addClass("ui-selected");
  3701. selectee.selected = true;
  3702. } else {
  3703. selectee.$element.removeClass("ui-selecting");
  3704. selectee.selecting = false;
  3705. if (selectee.startselected) {
  3706. selectee.$element.addClass("ui-unselecting");
  3707. selectee.unselecting = true;
  3708. }
  3709. // selectable UNSELECTING callback
  3710. that._trigger("unselecting", event, {
  3711. unselecting: selectee.element
  3712. });
  3713. }
  3714. }
  3715. if (selectee.selected) {
  3716. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3717. selectee.$element.removeClass("ui-selected");
  3718. selectee.selected = false;
  3719. selectee.$element.addClass("ui-unselecting");
  3720. selectee.unselecting = true;
  3721. // selectable UNSELECTING callback
  3722. that._trigger("unselecting", event, {
  3723. unselecting: selectee.element
  3724. });
  3725. }
  3726. }
  3727. }
  3728. });
  3729. return false;
  3730. },
  3731. _mouseStop: function(event) {
  3732. var that = this;
  3733. this.dragged = false;
  3734. $(".ui-unselecting", this.element[0]).each(function() {
  3735. var selectee = $.data(this, "selectable-item");
  3736. selectee.$element.removeClass("ui-unselecting");
  3737. selectee.unselecting = false;
  3738. selectee.startselected = false;
  3739. that._trigger("unselected", event, {
  3740. unselected: selectee.element
  3741. });
  3742. });
  3743. $(".ui-selecting", this.element[0]).each(function() {
  3744. var selectee = $.data(this, "selectable-item");
  3745. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3746. selectee.selecting = false;
  3747. selectee.selected = true;
  3748. selectee.startselected = true;
  3749. that._trigger("selected", event, {
  3750. selected: selectee.element
  3751. });
  3752. });
  3753. this._trigger("stop", event);
  3754. this.helper.remove();
  3755. return false;
  3756. }
  3757. });
  3758. /*!
  3759. * jQuery UI Sortable 1.11.4
  3760. * http://jqueryui.com
  3761. *
  3762. * Copyright jQuery Foundation and other contributors
  3763. * Released under the MIT license.
  3764. * http://jquery.org/license
  3765. *
  3766. * http://api.jqueryui.com/sortable/
  3767. */
  3768. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  3769. version: "1.11.4",
  3770. widgetEventPrefix: "sort",
  3771. ready: false,
  3772. options: {
  3773. appendTo: "parent",
  3774. axis: false,
  3775. connectWith: false,
  3776. containment: false,
  3777. cursor: "auto",
  3778. cursorAt: false,
  3779. dropOnEmpty: true,
  3780. forcePlaceholderSize: false,
  3781. forceHelperSize: false,
  3782. grid: false,
  3783. handle: false,
  3784. helper: "original",
  3785. items: "> *",
  3786. opacity: false,
  3787. placeholder: false,
  3788. revert: false,
  3789. scroll: true,
  3790. scrollSensitivity: 20,
  3791. scrollSpeed: 20,
  3792. scope: "default",
  3793. tolerance: "intersect",
  3794. zIndex: 1000,
  3795. // callbacks
  3796. activate: null,
  3797. beforeStop: null,
  3798. change: null,
  3799. deactivate: null,
  3800. out: null,
  3801. over: null,
  3802. receive: null,
  3803. remove: null,
  3804. sort: null,
  3805. start: null,
  3806. stop: null,
  3807. update: null
  3808. },
  3809. _isOverAxis: function( x, reference, size ) {
  3810. return ( x >= reference ) && ( x < ( reference + size ) );
  3811. },
  3812. _isFloating: function( item ) {
  3813. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3814. },
  3815. _create: function() {
  3816. this.containerCache = {};
  3817. this.element.addClass("ui-sortable");
  3818. //Get the items
  3819. this.refresh();
  3820. //Let's determine the parent's offset
  3821. this.offset = this.element.offset();
  3822. //Initialize mouse events for interaction
  3823. this._mouseInit();
  3824. this._setHandleClassName();
  3825. //We're ready to go
  3826. this.ready = true;
  3827. },
  3828. _setOption: function( key, value ) {
  3829. this._super( key, value );
  3830. if ( key === "handle" ) {
  3831. this._setHandleClassName();
  3832. }
  3833. },
  3834. _setHandleClassName: function() {
  3835. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  3836. $.each( this.items, function() {
  3837. ( this.instance.options.handle ?
  3838. this.item.find( this.instance.options.handle ) : this.item )
  3839. .addClass( "ui-sortable-handle" );
  3840. });
  3841. },
  3842. _destroy: function() {
  3843. this.element
  3844. .removeClass( "ui-sortable ui-sortable-disabled" )
  3845. .find( ".ui-sortable-handle" )
  3846. .removeClass( "ui-sortable-handle" );
  3847. this._mouseDestroy();
  3848. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3849. this.items[i].item.removeData(this.widgetName + "-item");
  3850. }
  3851. return this;
  3852. },
  3853. _mouseCapture: function(event, overrideHandle) {
  3854. var currentItem = null,
  3855. validHandle = false,
  3856. that = this;
  3857. if (this.reverting) {
  3858. return false;
  3859. }
  3860. if(this.options.disabled || this.options.type === "static") {
  3861. return false;
  3862. }
  3863. //We have to refresh the items data once first
  3864. this._refreshItems(event);
  3865. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3866. $(event.target).parents().each(function() {
  3867. if($.data(this, that.widgetName + "-item") === that) {
  3868. currentItem = $(this);
  3869. return false;
  3870. }
  3871. });
  3872. if($.data(event.target, that.widgetName + "-item") === that) {
  3873. currentItem = $(event.target);
  3874. }
  3875. if(!currentItem) {
  3876. return false;
  3877. }
  3878. if(this.options.handle && !overrideHandle) {
  3879. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3880. if(this === event.target) {
  3881. validHandle = true;
  3882. }
  3883. });
  3884. if(!validHandle) {
  3885. return false;
  3886. }
  3887. }
  3888. this.currentItem = currentItem;
  3889. this._removeCurrentsFromItems();
  3890. return true;
  3891. },
  3892. _mouseStart: function(event, overrideHandle, noActivation) {
  3893. var i, body,
  3894. o = this.options;
  3895. this.currentContainer = this;
  3896. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3897. this.refreshPositions();
  3898. //Create and append the visible helper
  3899. this.helper = this._createHelper(event);
  3900. //Cache the helper size
  3901. this._cacheHelperProportions();
  3902. /*
  3903. * - Position generation -
  3904. * This block generates everything position related - it's the core of draggables.
  3905. */
  3906. //Cache the margins of the original element
  3907. this._cacheMargins();
  3908. //Get the next scrolling parent
  3909. this.scrollParent = this.helper.scrollParent();
  3910. //The element's absolute position on the page minus margins
  3911. this.offset = this.currentItem.offset();
  3912. this.offset = {
  3913. top: this.offset.top - this.margins.top,
  3914. left: this.offset.left - this.margins.left
  3915. };
  3916. $.extend(this.offset, {
  3917. click: { //Where the click happened, relative to the element
  3918. left: event.pageX - this.offset.left,
  3919. top: event.pageY - this.offset.top
  3920. },
  3921. parent: this._getParentOffset(),
  3922. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3923. });
  3924. // Only after we got the offset, we can change the helper's position to absolute
  3925. // TODO: Still need to figure out a way to make relative sorting possible
  3926. this.helper.css("position", "absolute");
  3927. this.cssPosition = this.helper.css("position");
  3928. //Generate the original position
  3929. this.originalPosition = this._generatePosition(event);
  3930. this.originalPageX = event.pageX;
  3931. this.originalPageY = event.pageY;
  3932. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3933. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3934. //Cache the former DOM position
  3935. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3936. //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
  3937. if(this.helper[0] !== this.currentItem[0]) {
  3938. this.currentItem.hide();
  3939. }
  3940. //Create the placeholder
  3941. this._createPlaceholder();
  3942. //Set a containment if given in the options
  3943. if(o.containment) {
  3944. this._setContainment();
  3945. }
  3946. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3947. body = this.document.find( "body" );
  3948. // support: IE
  3949. this.storedCursor = body.css( "cursor" );
  3950. body.css( "cursor", o.cursor );
  3951. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3952. }
  3953. if(o.opacity) { // opacity option
  3954. if (this.helper.css("opacity")) {
  3955. this._storedOpacity = this.helper.css("opacity");
  3956. }
  3957. this.helper.css("opacity", o.opacity);
  3958. }
  3959. if(o.zIndex) { // zIndex option
  3960. if (this.helper.css("zIndex")) {
  3961. this._storedZIndex = this.helper.css("zIndex");
  3962. }
  3963. this.helper.css("zIndex", o.zIndex);
  3964. }
  3965. //Prepare scrolling
  3966. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  3967. this.overflowOffset = this.scrollParent.offset();
  3968. }
  3969. //Call callbacks
  3970. this._trigger("start", event, this._uiHash());
  3971. //Recache the helper size
  3972. if(!this._preserveHelperProportions) {
  3973. this._cacheHelperProportions();
  3974. }
  3975. //Post "activate" events to possible containers
  3976. if( !noActivation ) {
  3977. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3978. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3979. }
  3980. }
  3981. //Prepare possible droppables
  3982. if($.ui.ddmanager) {
  3983. $.ui.ddmanager.current = this;
  3984. }
  3985. if ($.ui.ddmanager && !o.dropBehaviour) {
  3986. $.ui.ddmanager.prepareOffsets(this, event);
  3987. }
  3988. this.dragging = true;
  3989. this.helper.addClass("ui-sortable-helper");
  3990. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3991. return true;
  3992. },
  3993. _mouseDrag: function(event) {
  3994. var i, item, itemElement, intersection,
  3995. o = this.options,
  3996. scrolled = false;
  3997. //Compute the helpers position
  3998. this.position = this._generatePosition(event);
  3999. this.positionAbs = this._convertPositionTo("absolute");
  4000. if (!this.lastPositionAbs) {
  4001. this.lastPositionAbs = this.positionAbs;
  4002. }
  4003. //Do scrolling
  4004. if(this.options.scroll) {
  4005. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  4006. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  4007. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  4008. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  4009. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  4010. }
  4011. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  4012. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  4013. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  4014. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  4015. }
  4016. } else {
  4017. if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
  4018. scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
  4019. } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
  4020. scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
  4021. }
  4022. if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
  4023. scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
  4024. } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
  4025. scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
  4026. }
  4027. }
  4028. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  4029. $.ui.ddmanager.prepareOffsets(this, event);
  4030. }
  4031. }
  4032. //Regenerate the absolute position used for position checks
  4033. this.positionAbs = this._convertPositionTo("absolute");
  4034. //Set the helper position
  4035. if(!this.options.axis || this.options.axis !== "y") {
  4036. this.helper[0].style.left = this.position.left+"px";
  4037. }
  4038. if(!this.options.axis || this.options.axis !== "x") {
  4039. this.helper[0].style.top = this.position.top+"px";
  4040. }
  4041. //Rearrange
  4042. for (i = this.items.length - 1; i >= 0; i--) {
  4043. //Cache variables and intersection, continue if no intersection
  4044. item = this.items[i];
  4045. itemElement = item.item[0];
  4046. intersection = this._intersectsWithPointer(item);
  4047. if (!intersection) {
  4048. continue;
  4049. }
  4050. // Only put the placeholder inside the current Container, skip all
  4051. // items from other containers. This works because when moving
  4052. // an item from one container to another the
  4053. // currentContainer is switched before the placeholder is moved.
  4054. //
  4055. // Without this, moving items in "sub-sortables" can cause
  4056. // the placeholder to jitter between the outer and inner container.
  4057. if (item.instance !== this.currentContainer) {
  4058. continue;
  4059. }
  4060. // cannot intersect with itself
  4061. // no useless actions that have been done before
  4062. // no action if the item moved is the parent of the item checked
  4063. if (itemElement !== this.currentItem[0] &&
  4064. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  4065. !$.contains(this.placeholder[0], itemElement) &&
  4066. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  4067. ) {
  4068. this.direction = intersection === 1 ? "down" : "up";
  4069. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  4070. this._rearrange(event, item);
  4071. } else {
  4072. break;
  4073. }
  4074. this._trigger("change", event, this._uiHash());
  4075. break;
  4076. }
  4077. }
  4078. //Post events to containers
  4079. this._contactContainers(event);
  4080. //Interconnect with droppables
  4081. if($.ui.ddmanager) {
  4082. $.ui.ddmanager.drag(this, event);
  4083. }
  4084. //Call callbacks
  4085. this._trigger("sort", event, this._uiHash());
  4086. this.lastPositionAbs = this.positionAbs;
  4087. return false;
  4088. },
  4089. _mouseStop: function(event, noPropagation) {
  4090. if(!event) {
  4091. return;
  4092. }
  4093. //If we are using droppables, inform the manager about the drop
  4094. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  4095. $.ui.ddmanager.drop(this, event);
  4096. }
  4097. if(this.options.revert) {
  4098. var that = this,
  4099. cur = this.placeholder.offset(),
  4100. axis = this.options.axis,
  4101. animation = {};
  4102. if ( !axis || axis === "x" ) {
  4103. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
  4104. }
  4105. if ( !axis || axis === "y" ) {
  4106. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
  4107. }
  4108. this.reverting = true;
  4109. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  4110. that._clear(event);
  4111. });
  4112. } else {
  4113. this._clear(event, noPropagation);
  4114. }
  4115. return false;
  4116. },
  4117. cancel: function() {
  4118. if(this.dragging) {
  4119. this._mouseUp({ target: null });
  4120. if(this.options.helper === "original") {
  4121. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4122. } else {
  4123. this.currentItem.show();
  4124. }
  4125. //Post deactivating events to containers
  4126. for (var i = this.containers.length - 1; i >= 0; i--){
  4127. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  4128. if(this.containers[i].containerCache.over) {
  4129. this.containers[i]._trigger("out", null, this._uiHash(this));
  4130. this.containers[i].containerCache.over = 0;
  4131. }
  4132. }
  4133. }
  4134. if (this.placeholder) {
  4135. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4136. if(this.placeholder[0].parentNode) {
  4137. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4138. }
  4139. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  4140. this.helper.remove();
  4141. }
  4142. $.extend(this, {
  4143. helper: null,
  4144. dragging: false,
  4145. reverting: false,
  4146. _noFinalSort: null
  4147. });
  4148. if(this.domPosition.prev) {
  4149. $(this.domPosition.prev).after(this.currentItem);
  4150. } else {
  4151. $(this.domPosition.parent).prepend(this.currentItem);
  4152. }
  4153. }
  4154. return this;
  4155. },
  4156. serialize: function(o) {
  4157. var items = this._getItemsAsjQuery(o && o.connected),
  4158. str = [];
  4159. o = o || {};
  4160. $(items).each(function() {
  4161. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  4162. if (res) {
  4163. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  4164. }
  4165. });
  4166. if(!str.length && o.key) {
  4167. str.push(o.key + "=");
  4168. }
  4169. return str.join("&");
  4170. },
  4171. toArray: function(o) {
  4172. var items = this._getItemsAsjQuery(o && o.connected),
  4173. ret = [];
  4174. o = o || {};
  4175. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  4176. return ret;
  4177. },
  4178. /* Be careful with the following core functions */
  4179. _intersectsWith: function(item) {
  4180. var x1 = this.positionAbs.left,
  4181. x2 = x1 + this.helperProportions.width,
  4182. y1 = this.positionAbs.top,
  4183. y2 = y1 + this.helperProportions.height,
  4184. l = item.left,
  4185. r = l + item.width,
  4186. t = item.top,
  4187. b = t + item.height,
  4188. dyClick = this.offset.click.top,
  4189. dxClick = this.offset.click.left,
  4190. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  4191. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  4192. isOverElement = isOverElementHeight && isOverElementWidth;
  4193. if ( this.options.tolerance === "pointer" ||
  4194. this.options.forcePointerForContainers ||
  4195. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  4196. ) {
  4197. return isOverElement;
  4198. } else {
  4199. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  4200. x2 - (this.helperProportions.width / 2) < r && // Left Half
  4201. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  4202. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  4203. }
  4204. },
  4205. _intersectsWithPointer: function(item) {
  4206. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  4207. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  4208. isOverElement = isOverElementHeight && isOverElementWidth,
  4209. verticalDirection = this._getDragVerticalDirection(),
  4210. horizontalDirection = this._getDragHorizontalDirection();
  4211. if (!isOverElement) {
  4212. return false;
  4213. }
  4214. return this.floating ?
  4215. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  4216. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  4217. },
  4218. _intersectsWithSides: function(item) {
  4219. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  4220. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  4221. verticalDirection = this._getDragVerticalDirection(),
  4222. horizontalDirection = this._getDragHorizontalDirection();
  4223. if (this.floating && horizontalDirection) {
  4224. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  4225. } else {
  4226. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  4227. }
  4228. },
  4229. _getDragVerticalDirection: function() {
  4230. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4231. return delta !== 0 && (delta > 0 ? "down" : "up");
  4232. },
  4233. _getDragHorizontalDirection: function() {
  4234. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4235. return delta !== 0 && (delta > 0 ? "right" : "left");
  4236. },
  4237. refresh: function(event) {
  4238. this._refreshItems(event);
  4239. this._setHandleClassName();
  4240. this.refreshPositions();
  4241. return this;
  4242. },
  4243. _connectWith: function() {
  4244. var options = this.options;
  4245. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  4246. },
  4247. _getItemsAsjQuery: function(connected) {
  4248. var i, j, cur, inst,
  4249. items = [],
  4250. queries = [],
  4251. connectWith = this._connectWith();
  4252. if(connectWith && connected) {
  4253. for (i = connectWith.length - 1; i >= 0; i--){
  4254. cur = $(connectWith[i], this.document[0]);
  4255. for ( j = cur.length - 1; j >= 0; j--){
  4256. inst = $.data(cur[j], this.widgetFullName);
  4257. if(inst && inst !== this && !inst.options.disabled) {
  4258. 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]);
  4259. }
  4260. }
  4261. }
  4262. }
  4263. 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]);
  4264. function addItems() {
  4265. items.push( this );
  4266. }
  4267. for (i = queries.length - 1; i >= 0; i--){
  4268. queries[i][0].each( addItems );
  4269. }
  4270. return $(items);
  4271. },
  4272. _removeCurrentsFromItems: function() {
  4273. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  4274. this.items = $.grep(this.items, function (item) {
  4275. for (var j=0; j < list.length; j++) {
  4276. if(list[j] === item.item[0]) {
  4277. return false;
  4278. }
  4279. }
  4280. return true;
  4281. });
  4282. },
  4283. _refreshItems: function(event) {
  4284. this.items = [];
  4285. this.containers = [this];
  4286. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4287. items = this.items,
  4288. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  4289. connectWith = this._connectWith();
  4290. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  4291. for (i = connectWith.length - 1; i >= 0; i--){
  4292. cur = $(connectWith[i], this.document[0]);
  4293. for (j = cur.length - 1; j >= 0; j--){
  4294. inst = $.data(cur[j], this.widgetFullName);
  4295. if(inst && inst !== this && !inst.options.disabled) {
  4296. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  4297. this.containers.push(inst);
  4298. }
  4299. }
  4300. }
  4301. }
  4302. for (i = queries.length - 1; i >= 0; i--) {
  4303. targetData = queries[i][1];
  4304. _queries = queries[i][0];
  4305. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  4306. item = $(_queries[j]);
  4307. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  4308. items.push({
  4309. item: item,
  4310. instance: targetData,
  4311. width: 0, height: 0,
  4312. left: 0, top: 0
  4313. });
  4314. }
  4315. }
  4316. },
  4317. refreshPositions: function(fast) {
  4318. // Determine whether items are being displayed horizontally
  4319. this.floating = this.items.length ?
  4320. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  4321. false;
  4322. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  4323. if(this.offsetParent && this.helper) {
  4324. this.offset.parent = this._getParentOffset();
  4325. }
  4326. var i, item, t, p;
  4327. for (i = this.items.length - 1; i >= 0; i--){
  4328. item = this.items[i];
  4329. //We ignore calculating positions of all connected containers when we're not over them
  4330. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  4331. continue;
  4332. }
  4333. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  4334. if (!fast) {
  4335. item.width = t.outerWidth();
  4336. item.height = t.outerHeight();
  4337. }
  4338. p = t.offset();
  4339. item.left = p.left;
  4340. item.top = p.top;
  4341. }
  4342. if(this.options.custom && this.options.custom.refreshContainers) {
  4343. this.options.custom.refreshContainers.call(this);
  4344. } else {
  4345. for (i = this.containers.length - 1; i >= 0; i--){
  4346. p = this.containers[i].element.offset();
  4347. this.containers[i].containerCache.left = p.left;
  4348. this.containers[i].containerCache.top = p.top;
  4349. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  4350. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  4351. }
  4352. }
  4353. return this;
  4354. },
  4355. _createPlaceholder: function(that) {
  4356. that = that || this;
  4357. var className,
  4358. o = that.options;
  4359. if(!o.placeholder || o.placeholder.constructor === String) {
  4360. className = o.placeholder;
  4361. o.placeholder = {
  4362. element: function() {
  4363. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  4364. element = $( "<" + nodeName + ">", that.document[0] )
  4365. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  4366. .removeClass("ui-sortable-helper");
  4367. if ( nodeName === "tbody" ) {
  4368. that._createTrPlaceholder(
  4369. that.currentItem.find( "tr" ).eq( 0 ),
  4370. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  4371. );
  4372. } else if ( nodeName === "tr" ) {
  4373. that._createTrPlaceholder( that.currentItem, element );
  4374. } else if ( nodeName === "img" ) {
  4375. element.attr( "src", that.currentItem.attr( "src" ) );
  4376. }
  4377. if ( !className ) {
  4378. element.css( "visibility", "hidden" );
  4379. }
  4380. return element;
  4381. },
  4382. update: function(container, p) {
  4383. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  4384. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  4385. if(className && !o.forcePlaceholderSize) {
  4386. return;
  4387. }
  4388. //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
  4389. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  4390. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  4391. }
  4392. };
  4393. }
  4394. //Create the placeholder
  4395. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  4396. //Append it after the actual current item
  4397. that.currentItem.after(that.placeholder);
  4398. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  4399. o.placeholder.update(that, that.placeholder);
  4400. },
  4401. _createTrPlaceholder: function( sourceTr, targetTr ) {
  4402. var that = this;
  4403. sourceTr.children().each(function() {
  4404. $( "<td>&#160;</td>", that.document[ 0 ] )
  4405. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  4406. .appendTo( targetTr );
  4407. });
  4408. },
  4409. _contactContainers: function(event) {
  4410. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  4411. innermostContainer = null,
  4412. innermostIndex = null;
  4413. // get innermost container that intersects with item
  4414. for (i = this.containers.length - 1; i >= 0; i--) {
  4415. // never consider a container that's located within the item itself
  4416. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  4417. continue;
  4418. }
  4419. if(this._intersectsWith(this.containers[i].containerCache)) {
  4420. // if we've already found a container and it's more "inner" than this, then continue
  4421. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  4422. continue;
  4423. }
  4424. innermostContainer = this.containers[i];
  4425. innermostIndex = i;
  4426. } else {
  4427. // container doesn't intersect. trigger "out" event if necessary
  4428. if(this.containers[i].containerCache.over) {
  4429. this.containers[i]._trigger("out", event, this._uiHash(this));
  4430. this.containers[i].containerCache.over = 0;
  4431. }
  4432. }
  4433. }
  4434. // if no intersecting containers found, return
  4435. if(!innermostContainer) {
  4436. return;
  4437. }
  4438. // move the item into the container if it's not there already
  4439. if(this.containers.length === 1) {
  4440. if (!this.containers[innermostIndex].containerCache.over) {
  4441. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4442. this.containers[innermostIndex].containerCache.over = 1;
  4443. }
  4444. } else {
  4445. //When entering a new container, we will find the item with the least distance and append our item near it
  4446. dist = 10000;
  4447. itemWithLeastDistance = null;
  4448. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  4449. posProperty = floating ? "left" : "top";
  4450. sizeProperty = floating ? "width" : "height";
  4451. axis = floating ? "clientX" : "clientY";
  4452. for (j = this.items.length - 1; j >= 0; j--) {
  4453. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4454. continue;
  4455. }
  4456. if(this.items[j].item[0] === this.currentItem[0]) {
  4457. continue;
  4458. }
  4459. cur = this.items[j].item.offset()[posProperty];
  4460. nearBottom = false;
  4461. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  4462. nearBottom = true;
  4463. }
  4464. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  4465. dist = Math.abs( event[ axis ] - cur );
  4466. itemWithLeastDistance = this.items[ j ];
  4467. this.direction = nearBottom ? "up": "down";
  4468. }
  4469. }
  4470. //Check if dropOnEmpty is enabled
  4471. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4472. return;
  4473. }
  4474. if(this.currentContainer === this.containers[innermostIndex]) {
  4475. if ( !this.currentContainer.containerCache.over ) {
  4476. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  4477. this.currentContainer.containerCache.over = 1;
  4478. }
  4479. return;
  4480. }
  4481. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4482. this._trigger("change", event, this._uiHash());
  4483. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4484. this.currentContainer = this.containers[innermostIndex];
  4485. //Update the placeholder
  4486. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4487. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4488. this.containers[innermostIndex].containerCache.over = 1;
  4489. }
  4490. },
  4491. _createHelper: function(event) {
  4492. var o = this.options,
  4493. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4494. //Add the helper to the DOM if that didn't happen already
  4495. if(!helper.parents("body").length) {
  4496. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4497. }
  4498. if(helper[0] === this.currentItem[0]) {
  4499. 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") };
  4500. }
  4501. if(!helper[0].style.width || o.forceHelperSize) {
  4502. helper.width(this.currentItem.width());
  4503. }
  4504. if(!helper[0].style.height || o.forceHelperSize) {
  4505. helper.height(this.currentItem.height());
  4506. }
  4507. return helper;
  4508. },
  4509. _adjustOffsetFromHelper: function(obj) {
  4510. if (typeof obj === "string") {
  4511. obj = obj.split(" ");
  4512. }
  4513. if ($.isArray(obj)) {
  4514. obj = {left: +obj[0], top: +obj[1] || 0};
  4515. }
  4516. if ("left" in obj) {
  4517. this.offset.click.left = obj.left + this.margins.left;
  4518. }
  4519. if ("right" in obj) {
  4520. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4521. }
  4522. if ("top" in obj) {
  4523. this.offset.click.top = obj.top + this.margins.top;
  4524. }
  4525. if ("bottom" in obj) {
  4526. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4527. }
  4528. },
  4529. _getParentOffset: function() {
  4530. //Get the offsetParent and cache its position
  4531. this.offsetParent = this.helper.offsetParent();
  4532. var po = this.offsetParent.offset();
  4533. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4534. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4535. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4536. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4537. if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4538. po.left += this.scrollParent.scrollLeft();
  4539. po.top += this.scrollParent.scrollTop();
  4540. }
  4541. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4542. // with an ugly IE fix
  4543. if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4544. po = { top: 0, left: 0 };
  4545. }
  4546. return {
  4547. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4548. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4549. };
  4550. },
  4551. _getRelativeOffset: function() {
  4552. if(this.cssPosition === "relative") {
  4553. var p = this.currentItem.position();
  4554. return {
  4555. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4556. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4557. };
  4558. } else {
  4559. return { top: 0, left: 0 };
  4560. }
  4561. },
  4562. _cacheMargins: function() {
  4563. this.margins = {
  4564. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4565. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4566. };
  4567. },
  4568. _cacheHelperProportions: function() {
  4569. this.helperProportions = {
  4570. width: this.helper.outerWidth(),
  4571. height: this.helper.outerHeight()
  4572. };
  4573. },
  4574. _setContainment: function() {
  4575. var ce, co, over,
  4576. o = this.options;
  4577. if(o.containment === "parent") {
  4578. o.containment = this.helper[0].parentNode;
  4579. }
  4580. if(o.containment === "document" || o.containment === "window") {
  4581. this.containment = [
  4582. 0 - this.offset.relative.left - this.offset.parent.left,
  4583. 0 - this.offset.relative.top - this.offset.parent.top,
  4584. o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
  4585. (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4586. ];
  4587. }
  4588. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4589. ce = $(o.containment)[0];
  4590. co = $(o.containment).offset();
  4591. over = ($(ce).css("overflow") !== "hidden");
  4592. this.containment = [
  4593. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4594. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4595. 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,
  4596. 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
  4597. ];
  4598. }
  4599. },
  4600. _convertPositionTo: function(d, pos) {
  4601. if(!pos) {
  4602. pos = this.position;
  4603. }
  4604. var mod = d === "absolute" ? 1 : -1,
  4605. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4606. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4607. return {
  4608. top: (
  4609. pos.top + // The absolute mouse position
  4610. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4611. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4612. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4613. ),
  4614. left: (
  4615. pos.left + // The absolute mouse position
  4616. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4617. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4618. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4619. )
  4620. };
  4621. },
  4622. _generatePosition: function(event) {
  4623. var top, left,
  4624. o = this.options,
  4625. pageX = event.pageX,
  4626. pageY = event.pageY,
  4627. 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);
  4628. // This is another very weird special case that only happens for relative elements:
  4629. // 1. If the css position is relative
  4630. // 2. and the scroll parent is the document or similar to the offset parent
  4631. // we have to refresh the relative offset during the scroll so there are no jumps
  4632. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
  4633. this.offset.relative = this._getRelativeOffset();
  4634. }
  4635. /*
  4636. * - Position constraining -
  4637. * Constrain the position to a mix of grid, containment.
  4638. */
  4639. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4640. if(this.containment) {
  4641. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4642. pageX = this.containment[0] + this.offset.click.left;
  4643. }
  4644. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4645. pageY = this.containment[1] + this.offset.click.top;
  4646. }
  4647. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4648. pageX = this.containment[2] + this.offset.click.left;
  4649. }
  4650. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4651. pageY = this.containment[3] + this.offset.click.top;
  4652. }
  4653. }
  4654. if(o.grid) {
  4655. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4656. 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;
  4657. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4658. 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;
  4659. }
  4660. }
  4661. return {
  4662. top: (
  4663. pageY - // The absolute mouse position
  4664. this.offset.click.top - // Click offset (relative to the element)
  4665. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4666. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4667. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4668. ),
  4669. left: (
  4670. pageX - // The absolute mouse position
  4671. this.offset.click.left - // Click offset (relative to the element)
  4672. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4673. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4674. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4675. )
  4676. };
  4677. },
  4678. _rearrange: function(event, i, a, hardRefresh) {
  4679. 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));
  4680. //Various things done here to improve the performance:
  4681. // 1. we create a setTimeout, that calls refreshPositions
  4682. // 2. on the instance, we have a counter variable, that get's higher after every append
  4683. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4684. // 4. this lets only the last addition to the timeout stack through
  4685. this.counter = this.counter ? ++this.counter : 1;
  4686. var counter = this.counter;
  4687. this._delay(function() {
  4688. if(counter === this.counter) {
  4689. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4690. }
  4691. });
  4692. },
  4693. _clear: function(event, noPropagation) {
  4694. this.reverting = false;
  4695. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4696. // everything else normalized again
  4697. var i,
  4698. delayedTriggers = [];
  4699. // We first have to update the dom position of the actual currentItem
  4700. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4701. if(!this._noFinalSort && this.currentItem.parent().length) {
  4702. this.placeholder.before(this.currentItem);
  4703. }
  4704. this._noFinalSort = null;
  4705. if(this.helper[0] === this.currentItem[0]) {
  4706. for(i in this._storedCSS) {
  4707. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4708. this._storedCSS[i] = "";
  4709. }
  4710. }
  4711. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4712. } else {
  4713. this.currentItem.show();
  4714. }
  4715. if(this.fromOutside && !noPropagation) {
  4716. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4717. }
  4718. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4719. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4720. }
  4721. // Check if the items Container has Changed and trigger appropriate
  4722. // events.
  4723. if (this !== this.currentContainer) {
  4724. if(!noPropagation) {
  4725. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4726. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4727. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4728. }
  4729. }
  4730. //Post events to containers
  4731. function delayEvent( type, instance, container ) {
  4732. return function( event ) {
  4733. container._trigger( type, event, instance._uiHash( instance ) );
  4734. };
  4735. }
  4736. for (i = this.containers.length - 1; i >= 0; i--){
  4737. if (!noPropagation) {
  4738. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  4739. }
  4740. if(this.containers[i].containerCache.over) {
  4741. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  4742. this.containers[i].containerCache.over = 0;
  4743. }
  4744. }
  4745. //Do what was originally in plugins
  4746. if ( this.storedCursor ) {
  4747. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4748. this.storedStylesheet.remove();
  4749. }
  4750. if(this._storedOpacity) {
  4751. this.helper.css("opacity", this._storedOpacity);
  4752. }
  4753. if(this._storedZIndex) {
  4754. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4755. }
  4756. this.dragging = false;
  4757. if(!noPropagation) {
  4758. this._trigger("beforeStop", event, this._uiHash());
  4759. }
  4760. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4761. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4762. if ( !this.cancelHelperRemoval ) {
  4763. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4764. this.helper.remove();
  4765. }
  4766. this.helper = null;
  4767. }
  4768. if(!noPropagation) {
  4769. for (i=0; i < delayedTriggers.length; i++) {
  4770. delayedTriggers[i].call(this, event);
  4771. } //Trigger all delayed events
  4772. this._trigger("stop", event, this._uiHash());
  4773. }
  4774. this.fromOutside = false;
  4775. return !this.cancelHelperRemoval;
  4776. },
  4777. _trigger: function() {
  4778. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4779. this.cancel();
  4780. }
  4781. },
  4782. _uiHash: function(_inst) {
  4783. var inst = _inst || this;
  4784. return {
  4785. helper: inst.helper,
  4786. placeholder: inst.placeholder || $([]),
  4787. position: inst.position,
  4788. originalPosition: inst.originalPosition,
  4789. offset: inst.positionAbs,
  4790. item: inst.currentItem,
  4791. sender: _inst ? _inst.element : null
  4792. };
  4793. }
  4794. });
  4795. /*!
  4796. * jQuery UI Accordion 1.11.4
  4797. * http://jqueryui.com
  4798. *
  4799. * Copyright jQuery Foundation and other contributors
  4800. * Released under the MIT license.
  4801. * http://jquery.org/license
  4802. *
  4803. * http://api.jqueryui.com/accordion/
  4804. */
  4805. var accordion = $.widget( "ui.accordion", {
  4806. version: "1.11.4",
  4807. options: {
  4808. active: 0,
  4809. animate: {},
  4810. collapsible: false,
  4811. event: "click",
  4812. header: "> li > :first-child,> :not(li):even",
  4813. heightStyle: "auto",
  4814. icons: {
  4815. activeHeader: "ui-icon-triangle-1-s",
  4816. header: "ui-icon-triangle-1-e"
  4817. },
  4818. // callbacks
  4819. activate: null,
  4820. beforeActivate: null
  4821. },
  4822. hideProps: {
  4823. borderTopWidth: "hide",
  4824. borderBottomWidth: "hide",
  4825. paddingTop: "hide",
  4826. paddingBottom: "hide",
  4827. height: "hide"
  4828. },
  4829. showProps: {
  4830. borderTopWidth: "show",
  4831. borderBottomWidth: "show",
  4832. paddingTop: "show",
  4833. paddingBottom: "show",
  4834. height: "show"
  4835. },
  4836. _create: function() {
  4837. var options = this.options;
  4838. this.prevShow = this.prevHide = $();
  4839. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  4840. // ARIA
  4841. .attr( "role", "tablist" );
  4842. // don't allow collapsible: false and active: false / null
  4843. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  4844. options.active = 0;
  4845. }
  4846. this._processPanels();
  4847. // handle negative values
  4848. if ( options.active < 0 ) {
  4849. options.active += this.headers.length;
  4850. }
  4851. this._refresh();
  4852. },
  4853. _getCreateEventData: function() {
  4854. return {
  4855. header: this.active,
  4856. panel: !this.active.length ? $() : this.active.next()
  4857. };
  4858. },
  4859. _createIcons: function() {
  4860. var icons = this.options.icons;
  4861. if ( icons ) {
  4862. $( "<span>" )
  4863. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  4864. .prependTo( this.headers );
  4865. this.active.children( ".ui-accordion-header-icon" )
  4866. .removeClass( icons.header )
  4867. .addClass( icons.activeHeader );
  4868. this.headers.addClass( "ui-accordion-icons" );
  4869. }
  4870. },
  4871. _destroyIcons: function() {
  4872. this.headers
  4873. .removeClass( "ui-accordion-icons" )
  4874. .children( ".ui-accordion-header-icon" )
  4875. .remove();
  4876. },
  4877. _destroy: function() {
  4878. var contents;
  4879. // clean up main element
  4880. this.element
  4881. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4882. .removeAttr( "role" );
  4883. // clean up headers
  4884. this.headers
  4885. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  4886. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  4887. .removeAttr( "role" )
  4888. .removeAttr( "aria-expanded" )
  4889. .removeAttr( "aria-selected" )
  4890. .removeAttr( "aria-controls" )
  4891. .removeAttr( "tabIndex" )
  4892. .removeUniqueId();
  4893. this._destroyIcons();
  4894. // clean up content panels
  4895. contents = this.headers.next()
  4896. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  4897. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  4898. .css( "display", "" )
  4899. .removeAttr( "role" )
  4900. .removeAttr( "aria-hidden" )
  4901. .removeAttr( "aria-labelledby" )
  4902. .removeUniqueId();
  4903. if ( this.options.heightStyle !== "content" ) {
  4904. contents.css( "height", "" );
  4905. }
  4906. },
  4907. _setOption: function( key, value ) {
  4908. if ( key === "active" ) {
  4909. // _activate() will handle invalid values and update this.options
  4910. this._activate( value );
  4911. return;
  4912. }
  4913. if ( key === "event" ) {
  4914. if ( this.options.event ) {
  4915. this._off( this.headers, this.options.event );
  4916. }
  4917. this._setupEvents( value );
  4918. }
  4919. this._super( key, value );
  4920. // setting collapsible: false while collapsed; open first panel
  4921. if ( key === "collapsible" && !value && this.options.active === false ) {
  4922. this._activate( 0 );
  4923. }
  4924. if ( key === "icons" ) {
  4925. this._destroyIcons();
  4926. if ( value ) {
  4927. this._createIcons();
  4928. }
  4929. }
  4930. // #5332 - opacity doesn't cascade to positioned elements in IE
  4931. // so we need to add the disabled class to the headers and panels
  4932. if ( key === "disabled" ) {
  4933. this.element
  4934. .toggleClass( "ui-state-disabled", !!value )
  4935. .attr( "aria-disabled", value );
  4936. this.headers.add( this.headers.next() )
  4937. .toggleClass( "ui-state-disabled", !!value );
  4938. }
  4939. },
  4940. _keydown: function( event ) {
  4941. if ( event.altKey || event.ctrlKey ) {
  4942. return;
  4943. }
  4944. var keyCode = $.ui.keyCode,
  4945. length = this.headers.length,
  4946. currentIndex = this.headers.index( event.target ),
  4947. toFocus = false;
  4948. switch ( event.keyCode ) {
  4949. case keyCode.RIGHT:
  4950. case keyCode.DOWN:
  4951. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4952. break;
  4953. case keyCode.LEFT:
  4954. case keyCode.UP:
  4955. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4956. break;
  4957. case keyCode.SPACE:
  4958. case keyCode.ENTER:
  4959. this._eventHandler( event );
  4960. break;
  4961. case keyCode.HOME:
  4962. toFocus = this.headers[ 0 ];
  4963. break;
  4964. case keyCode.END:
  4965. toFocus = this.headers[ length - 1 ];
  4966. break;
  4967. }
  4968. if ( toFocus ) {
  4969. $( event.target ).attr( "tabIndex", -1 );
  4970. $( toFocus ).attr( "tabIndex", 0 );
  4971. toFocus.focus();
  4972. event.preventDefault();
  4973. }
  4974. },
  4975. _panelKeyDown: function( event ) {
  4976. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  4977. $( event.currentTarget ).prev().focus();
  4978. }
  4979. },
  4980. refresh: function() {
  4981. var options = this.options;
  4982. this._processPanels();
  4983. // was collapsed or no panel
  4984. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  4985. options.active = false;
  4986. this.active = $();
  4987. // active false only when collapsible is true
  4988. } else if ( options.active === false ) {
  4989. this._activate( 0 );
  4990. // was active, but active panel is gone
  4991. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4992. // all remaining panel are disabled
  4993. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  4994. options.active = false;
  4995. this.active = $();
  4996. // activate previous panel
  4997. } else {
  4998. this._activate( Math.max( 0, options.active - 1 ) );
  4999. }
  5000. // was active, active panel still exists
  5001. } else {
  5002. // make sure active index is correct
  5003. options.active = this.headers.index( this.active );
  5004. }
  5005. this._destroyIcons();
  5006. this._refresh();
  5007. },
  5008. _processPanels: function() {
  5009. var prevHeaders = this.headers,
  5010. prevPanels = this.panels;
  5011. this.headers = this.element.find( this.options.header )
  5012. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  5013. this.panels = this.headers.next()
  5014. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5015. .filter( ":not(.ui-accordion-content-active)" )
  5016. .hide();
  5017. // Avoid memory leaks (#10056)
  5018. if ( prevPanels ) {
  5019. this._off( prevHeaders.not( this.headers ) );
  5020. this._off( prevPanels.not( this.panels ) );
  5021. }
  5022. },
  5023. _refresh: function() {
  5024. var maxHeight,
  5025. options = this.options,
  5026. heightStyle = options.heightStyle,
  5027. parent = this.element.parent();
  5028. this.active = this._findActive( options.active )
  5029. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5030. .removeClass( "ui-corner-all" );
  5031. this.active.next()
  5032. .addClass( "ui-accordion-content-active" )
  5033. .show();
  5034. this.headers
  5035. .attr( "role", "tab" )
  5036. .each(function() {
  5037. var header = $( this ),
  5038. headerId = header.uniqueId().attr( "id" ),
  5039. panel = header.next(),
  5040. panelId = panel.uniqueId().attr( "id" );
  5041. header.attr( "aria-controls", panelId );
  5042. panel.attr( "aria-labelledby", headerId );
  5043. })
  5044. .next()
  5045. .attr( "role", "tabpanel" );
  5046. this.headers
  5047. .not( this.active )
  5048. .attr({
  5049. "aria-selected": "false",
  5050. "aria-expanded": "false",
  5051. tabIndex: -1
  5052. })
  5053. .next()
  5054. .attr({
  5055. "aria-hidden": "true"
  5056. })
  5057. .hide();
  5058. // make sure at least one header is in the tab order
  5059. if ( !this.active.length ) {
  5060. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5061. } else {
  5062. this.active.attr({
  5063. "aria-selected": "true",
  5064. "aria-expanded": "true",
  5065. tabIndex: 0
  5066. })
  5067. .next()
  5068. .attr({
  5069. "aria-hidden": "false"
  5070. });
  5071. }
  5072. this._createIcons();
  5073. this._setupEvents( options.event );
  5074. if ( heightStyle === "fill" ) {
  5075. maxHeight = parent.height();
  5076. this.element.siblings( ":visible" ).each(function() {
  5077. var elem = $( this ),
  5078. position = elem.css( "position" );
  5079. if ( position === "absolute" || position === "fixed" ) {
  5080. return;
  5081. }
  5082. maxHeight -= elem.outerHeight( true );
  5083. });
  5084. this.headers.each(function() {
  5085. maxHeight -= $( this ).outerHeight( true );
  5086. });
  5087. this.headers.next()
  5088. .each(function() {
  5089. $( this ).height( Math.max( 0, maxHeight -
  5090. $( this ).innerHeight() + $( this ).height() ) );
  5091. })
  5092. .css( "overflow", "auto" );
  5093. } else if ( heightStyle === "none" ) {
  5094. maxHeight = 0;
  5095. this.headers.next()
  5096. .each(function() {
  5097. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5098. })
  5099. .height( maxHeight );
  5100. }
  5101. },
  5102. _activate: function( index ) {
  5103. var active = this._findActive( index )[ 0 ];
  5104. // trying to activate the already active panel
  5105. if ( active === this.active[ 0 ] ) {
  5106. return;
  5107. }
  5108. // trying to collapse, simulate a click on the currently active header
  5109. active = active || this.active[ 0 ];
  5110. this._eventHandler({
  5111. target: active,
  5112. currentTarget: active,
  5113. preventDefault: $.noop
  5114. });
  5115. },
  5116. _findActive: function( selector ) {
  5117. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5118. },
  5119. _setupEvents: function( event ) {
  5120. var events = {
  5121. keydown: "_keydown"
  5122. };
  5123. if ( event ) {
  5124. $.each( event.split( " " ), function( index, eventName ) {
  5125. events[ eventName ] = "_eventHandler";
  5126. });
  5127. }
  5128. this._off( this.headers.add( this.headers.next() ) );
  5129. this._on( this.headers, events );
  5130. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5131. this._hoverable( this.headers );
  5132. this._focusable( this.headers );
  5133. },
  5134. _eventHandler: function( event ) {
  5135. var options = this.options,
  5136. active = this.active,
  5137. clicked = $( event.currentTarget ),
  5138. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5139. collapsing = clickedIsActive && options.collapsible,
  5140. toShow = collapsing ? $() : clicked.next(),
  5141. toHide = active.next(),
  5142. eventData = {
  5143. oldHeader: active,
  5144. oldPanel: toHide,
  5145. newHeader: collapsing ? $() : clicked,
  5146. newPanel: toShow
  5147. };
  5148. event.preventDefault();
  5149. if (
  5150. // click on active header, but not collapsible
  5151. ( clickedIsActive && !options.collapsible ) ||
  5152. // allow canceling activation
  5153. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5154. return;
  5155. }
  5156. options.active = collapsing ? false : this.headers.index( clicked );
  5157. // when the call to ._toggle() comes after the class changes
  5158. // it causes a very odd bug in IE 8 (see #6720)
  5159. this.active = clickedIsActive ? $() : clicked;
  5160. this._toggle( eventData );
  5161. // switch classes
  5162. // corner classes on the previously active header stay after the animation
  5163. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5164. if ( options.icons ) {
  5165. active.children( ".ui-accordion-header-icon" )
  5166. .removeClass( options.icons.activeHeader )
  5167. .addClass( options.icons.header );
  5168. }
  5169. if ( !clickedIsActive ) {
  5170. clicked
  5171. .removeClass( "ui-corner-all" )
  5172. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5173. if ( options.icons ) {
  5174. clicked.children( ".ui-accordion-header-icon" )
  5175. .removeClass( options.icons.header )
  5176. .addClass( options.icons.activeHeader );
  5177. }
  5178. clicked
  5179. .next()
  5180. .addClass( "ui-accordion-content-active" );
  5181. }
  5182. },
  5183. _toggle: function( data ) {
  5184. var toShow = data.newPanel,
  5185. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5186. // handle activating a panel during the animation for another activation
  5187. this.prevShow.add( this.prevHide ).stop( true, true );
  5188. this.prevShow = toShow;
  5189. this.prevHide = toHide;
  5190. if ( this.options.animate ) {
  5191. this._animate( toShow, toHide, data );
  5192. } else {
  5193. toHide.hide();
  5194. toShow.show();
  5195. this._toggleComplete( data );
  5196. }
  5197. toHide.attr({
  5198. "aria-hidden": "true"
  5199. });
  5200. toHide.prev().attr({
  5201. "aria-selected": "false",
  5202. "aria-expanded": "false"
  5203. });
  5204. // if we're switching panels, remove the old header from the tab order
  5205. // if we're opening from collapsed state, remove the previous header from the tab order
  5206. // if we're collapsing, then keep the collapsing header in the tab order
  5207. if ( toShow.length && toHide.length ) {
  5208. toHide.prev().attr({
  5209. "tabIndex": -1,
  5210. "aria-expanded": "false"
  5211. });
  5212. } else if ( toShow.length ) {
  5213. this.headers.filter(function() {
  5214. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  5215. })
  5216. .attr( "tabIndex", -1 );
  5217. }
  5218. toShow
  5219. .attr( "aria-hidden", "false" )
  5220. .prev()
  5221. .attr({
  5222. "aria-selected": "true",
  5223. "aria-expanded": "true",
  5224. tabIndex: 0
  5225. });
  5226. },
  5227. _animate: function( toShow, toHide, data ) {
  5228. var total, easing, duration,
  5229. that = this,
  5230. adjust = 0,
  5231. boxSizing = toShow.css( "box-sizing" ),
  5232. down = toShow.length &&
  5233. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5234. animate = this.options.animate || {},
  5235. options = down && animate.down || animate,
  5236. complete = function() {
  5237. that._toggleComplete( data );
  5238. };
  5239. if ( typeof options === "number" ) {
  5240. duration = options;
  5241. }
  5242. if ( typeof options === "string" ) {
  5243. easing = options;
  5244. }
  5245. // fall back from options to animation in case of partial down settings
  5246. easing = easing || options.easing || animate.easing;
  5247. duration = duration || options.duration || animate.duration;
  5248. if ( !toHide.length ) {
  5249. return toShow.animate( this.showProps, duration, easing, complete );
  5250. }
  5251. if ( !toShow.length ) {
  5252. return toHide.animate( this.hideProps, duration, easing, complete );
  5253. }
  5254. total = toShow.show().outerHeight();
  5255. toHide.animate( this.hideProps, {
  5256. duration: duration,
  5257. easing: easing,
  5258. step: function( now, fx ) {
  5259. fx.now = Math.round( now );
  5260. }
  5261. });
  5262. toShow
  5263. .hide()
  5264. .animate( this.showProps, {
  5265. duration: duration,
  5266. easing: easing,
  5267. complete: complete,
  5268. step: function( now, fx ) {
  5269. fx.now = Math.round( now );
  5270. if ( fx.prop !== "height" ) {
  5271. if ( boxSizing === "content-box" ) {
  5272. adjust += fx.now;
  5273. }
  5274. } else if ( that.options.heightStyle !== "content" ) {
  5275. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5276. adjust = 0;
  5277. }
  5278. }
  5279. });
  5280. },
  5281. _toggleComplete: function( data ) {
  5282. var toHide = data.oldPanel;
  5283. toHide
  5284. .removeClass( "ui-accordion-content-active" )
  5285. .prev()
  5286. .removeClass( "ui-corner-top" )
  5287. .addClass( "ui-corner-all" );
  5288. // Work around for rendering bug in IE (#5421)
  5289. if ( toHide.length ) {
  5290. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  5291. }
  5292. this._trigger( "activate", null, data );
  5293. }
  5294. });
  5295. /*!
  5296. * jQuery UI Menu 1.11.4
  5297. * http://jqueryui.com
  5298. *
  5299. * Copyright jQuery Foundation and other contributors
  5300. * Released under the MIT license.
  5301. * http://jquery.org/license
  5302. *
  5303. * http://api.jqueryui.com/menu/
  5304. */
  5305. var menu = $.widget( "ui.menu", {
  5306. version: "1.11.4",
  5307. defaultElement: "<ul>",
  5308. delay: 300,
  5309. options: {
  5310. icons: {
  5311. submenu: "ui-icon-carat-1-e"
  5312. },
  5313. items: "> *",
  5314. menus: "ul",
  5315. position: {
  5316. my: "left-1 top",
  5317. at: "right top"
  5318. },
  5319. role: "menu",
  5320. // callbacks
  5321. blur: null,
  5322. focus: null,
  5323. select: null
  5324. },
  5325. _create: function() {
  5326. this.activeMenu = this.element;
  5327. // Flag used to prevent firing of the click handler
  5328. // as the event bubbles up through nested menus
  5329. this.mouseHandled = false;
  5330. this.element
  5331. .uniqueId()
  5332. .addClass( "ui-menu ui-widget ui-widget-content" )
  5333. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  5334. .attr({
  5335. role: this.options.role,
  5336. tabIndex: 0
  5337. });
  5338. if ( this.options.disabled ) {
  5339. this.element
  5340. .addClass( "ui-state-disabled" )
  5341. .attr( "aria-disabled", "true" );
  5342. }
  5343. this._on({
  5344. // Prevent focus from sticking to links inside menu after clicking
  5345. // them (focus should always stay on UL during navigation).
  5346. "mousedown .ui-menu-item": function( event ) {
  5347. event.preventDefault();
  5348. },
  5349. "click .ui-menu-item": function( event ) {
  5350. var target = $( event.target );
  5351. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  5352. this.select( event );
  5353. // Only set the mouseHandled flag if the event will bubble, see #9469.
  5354. if ( !event.isPropagationStopped() ) {
  5355. this.mouseHandled = true;
  5356. }
  5357. // Open submenu on click
  5358. if ( target.has( ".ui-menu" ).length ) {
  5359. this.expand( event );
  5360. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  5361. // Redirect focus to the menu
  5362. this.element.trigger( "focus", [ true ] );
  5363. // If the active item is on the top level, let it stay active.
  5364. // Otherwise, blur the active item since it is no longer visible.
  5365. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  5366. clearTimeout( this.timer );
  5367. }
  5368. }
  5369. }
  5370. },
  5371. "mouseenter .ui-menu-item": function( event ) {
  5372. // Ignore mouse events while typeahead is active, see #10458.
  5373. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  5374. // is over an item in the menu
  5375. if ( this.previousFilter ) {
  5376. return;
  5377. }
  5378. var target = $( event.currentTarget );
  5379. // Remove ui-state-active class from siblings of the newly focused menu item
  5380. // to avoid a jump caused by adjacent elements both having a class with a border
  5381. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  5382. this.focus( event, target );
  5383. },
  5384. mouseleave: "collapseAll",
  5385. "mouseleave .ui-menu": "collapseAll",
  5386. focus: function( event, keepActiveItem ) {
  5387. // If there's already an active item, keep it active
  5388. // If not, activate the first item
  5389. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  5390. if ( !keepActiveItem ) {
  5391. this.focus( event, item );
  5392. }
  5393. },
  5394. blur: function( event ) {
  5395. this._delay(function() {
  5396. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  5397. this.collapseAll( event );
  5398. }
  5399. });
  5400. },
  5401. keydown: "_keydown"
  5402. });
  5403. this.refresh();
  5404. // Clicks outside of a menu collapse any open menus
  5405. this._on( this.document, {
  5406. click: function( event ) {
  5407. if ( this._closeOnDocumentClick( event ) ) {
  5408. this.collapseAll( event );
  5409. }
  5410. // Reset the mouseHandled flag
  5411. this.mouseHandled = false;
  5412. }
  5413. });
  5414. },
  5415. _destroy: function() {
  5416. // Destroy (sub)menus
  5417. this.element
  5418. .removeAttr( "aria-activedescendant" )
  5419. .find( ".ui-menu" ).addBack()
  5420. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  5421. .removeAttr( "role" )
  5422. .removeAttr( "tabIndex" )
  5423. .removeAttr( "aria-labelledby" )
  5424. .removeAttr( "aria-expanded" )
  5425. .removeAttr( "aria-hidden" )
  5426. .removeAttr( "aria-disabled" )
  5427. .removeUniqueId()
  5428. .show();
  5429. // Destroy menu items
  5430. this.element.find( ".ui-menu-item" )
  5431. .removeClass( "ui-menu-item" )
  5432. .removeAttr( "role" )
  5433. .removeAttr( "aria-disabled" )
  5434. .removeUniqueId()
  5435. .removeClass( "ui-state-hover" )
  5436. .removeAttr( "tabIndex" )
  5437. .removeAttr( "role" )
  5438. .removeAttr( "aria-haspopup" )
  5439. .children().each( function() {
  5440. var elem = $( this );
  5441. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  5442. elem.remove();
  5443. }
  5444. });
  5445. // Destroy menu dividers
  5446. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  5447. },
  5448. _keydown: function( event ) {
  5449. var match, prev, character, skip,
  5450. preventDefault = true;
  5451. switch ( event.keyCode ) {
  5452. case $.ui.keyCode.PAGE_UP:
  5453. this.previousPage( event );
  5454. break;
  5455. case $.ui.keyCode.PAGE_DOWN:
  5456. this.nextPage( event );
  5457. break;
  5458. case $.ui.keyCode.HOME:
  5459. this._move( "first", "first", event );
  5460. break;
  5461. case $.ui.keyCode.END:
  5462. this._move( "last", "last", event );
  5463. break;
  5464. case $.ui.keyCode.UP:
  5465. this.previous( event );
  5466. break;
  5467. case $.ui.keyCode.DOWN:
  5468. this.next( event );
  5469. break;
  5470. case $.ui.keyCode.LEFT:
  5471. this.collapse( event );
  5472. break;
  5473. case $.ui.keyCode.RIGHT:
  5474. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  5475. this.expand( event );
  5476. }
  5477. break;
  5478. case $.ui.keyCode.ENTER:
  5479. case $.ui.keyCode.SPACE:
  5480. this._activate( event );
  5481. break;
  5482. case $.ui.keyCode.ESCAPE:
  5483. this.collapse( event );
  5484. break;
  5485. default:
  5486. preventDefault = false;
  5487. prev = this.previousFilter || "";
  5488. character = String.fromCharCode( event.keyCode );
  5489. skip = false;
  5490. clearTimeout( this.filterTimer );
  5491. if ( character === prev ) {
  5492. skip = true;
  5493. } else {
  5494. character = prev + character;
  5495. }
  5496. match = this._filterMenuItems( character );
  5497. match = skip && match.index( this.active.next() ) !== -1 ?
  5498. this.active.nextAll( ".ui-menu-item" ) :
  5499. match;
  5500. // If no matches on the current filter, reset to the last character pressed
  5501. // to move down the menu to the first item that starts with that character
  5502. if ( !match.length ) {
  5503. character = String.fromCharCode( event.keyCode );
  5504. match = this._filterMenuItems( character );
  5505. }
  5506. if ( match.length ) {
  5507. this.focus( event, match );
  5508. this.previousFilter = character;
  5509. this.filterTimer = this._delay(function() {
  5510. delete this.previousFilter;
  5511. }, 1000 );
  5512. } else {
  5513. delete this.previousFilter;
  5514. }
  5515. }
  5516. if ( preventDefault ) {
  5517. event.preventDefault();
  5518. }
  5519. },
  5520. _activate: function( event ) {
  5521. if ( !this.active.is( ".ui-state-disabled" ) ) {
  5522. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  5523. this.expand( event );
  5524. } else {
  5525. this.select( event );
  5526. }
  5527. }
  5528. },
  5529. refresh: function() {
  5530. var menus, items,
  5531. that = this,
  5532. icon = this.options.icons.submenu,
  5533. submenus = this.element.find( this.options.menus );
  5534. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  5535. // Initialize nested menus
  5536. submenus.filter( ":not(.ui-menu)" )
  5537. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  5538. .hide()
  5539. .attr({
  5540. role: this.options.role,
  5541. "aria-hidden": "true",
  5542. "aria-expanded": "false"
  5543. })
  5544. .each(function() {
  5545. var menu = $( this ),
  5546. item = menu.parent(),
  5547. submenuCarat = $( "<span>" )
  5548. .addClass( "ui-menu-icon ui-icon " + icon )
  5549. .data( "ui-menu-submenu-carat", true );
  5550. item
  5551. .attr( "aria-haspopup", "true" )
  5552. .prepend( submenuCarat );
  5553. menu.attr( "aria-labelledby", item.attr( "id" ) );
  5554. });
  5555. menus = submenus.add( this.element );
  5556. items = menus.find( this.options.items );
  5557. // Initialize menu-items containing spaces and/or dashes only as dividers
  5558. items.not( ".ui-menu-item" ).each(function() {
  5559. var item = $( this );
  5560. if ( that._isDivider( item ) ) {
  5561. item.addClass( "ui-widget-content ui-menu-divider" );
  5562. }
  5563. });
  5564. // Don't refresh list items that are already adapted
  5565. items.not( ".ui-menu-item, .ui-menu-divider" )
  5566. .addClass( "ui-menu-item" )
  5567. .uniqueId()
  5568. .attr({
  5569. tabIndex: -1,
  5570. role: this._itemRole()
  5571. });
  5572. // Add aria-disabled attribute to any disabled menu item
  5573. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  5574. // If the active item has been removed, blur the menu
  5575. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5576. this.blur();
  5577. }
  5578. },
  5579. _itemRole: function() {
  5580. return {
  5581. menu: "menuitem",
  5582. listbox: "option"
  5583. }[ this.options.role ];
  5584. },
  5585. _setOption: function( key, value ) {
  5586. if ( key === "icons" ) {
  5587. this.element.find( ".ui-menu-icon" )
  5588. .removeClass( this.options.icons.submenu )
  5589. .addClass( value.submenu );
  5590. }
  5591. if ( key === "disabled" ) {
  5592. this.element
  5593. .toggleClass( "ui-state-disabled", !!value )
  5594. .attr( "aria-disabled", value );
  5595. }
  5596. this._super( key, value );
  5597. },
  5598. focus: function( event, item ) {
  5599. var nested, focused;
  5600. this.blur( event, event && event.type === "focus" );
  5601. this._scrollIntoView( item );
  5602. this.active = item.first();
  5603. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  5604. // Only update aria-activedescendant if there's a role
  5605. // otherwise we assume focus is managed elsewhere
  5606. if ( this.options.role ) {
  5607. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  5608. }
  5609. // Highlight active parent menu item, if any
  5610. this.active
  5611. .parent()
  5612. .closest( ".ui-menu-item" )
  5613. .addClass( "ui-state-active" );
  5614. if ( event && event.type === "keydown" ) {
  5615. this._close();
  5616. } else {
  5617. this.timer = this._delay(function() {
  5618. this._close();
  5619. }, this.delay );
  5620. }
  5621. nested = item.children( ".ui-menu" );
  5622. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  5623. this._startOpening(nested);
  5624. }
  5625. this.activeMenu = item.parent();
  5626. this._trigger( "focus", event, { item: item } );
  5627. },
  5628. _scrollIntoView: function( item ) {
  5629. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  5630. if ( this._hasScroll() ) {
  5631. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  5632. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  5633. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  5634. scroll = this.activeMenu.scrollTop();
  5635. elementHeight = this.activeMenu.height();
  5636. itemHeight = item.outerHeight();
  5637. if ( offset < 0 ) {
  5638. this.activeMenu.scrollTop( scroll + offset );
  5639. } else if ( offset + itemHeight > elementHeight ) {
  5640. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  5641. }
  5642. }
  5643. },
  5644. blur: function( event, fromFocus ) {
  5645. if ( !fromFocus ) {
  5646. clearTimeout( this.timer );
  5647. }
  5648. if ( !this.active ) {
  5649. return;
  5650. }
  5651. this.active.removeClass( "ui-state-focus" );
  5652. this.active = null;
  5653. this._trigger( "blur", event, { item: this.active } );
  5654. },
  5655. _startOpening: function( submenu ) {
  5656. clearTimeout( this.timer );
  5657. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  5658. // shift in the submenu position when mousing over the carat icon
  5659. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  5660. return;
  5661. }
  5662. this.timer = this._delay(function() {
  5663. this._close();
  5664. this._open( submenu );
  5665. }, this.delay );
  5666. },
  5667. _open: function( submenu ) {
  5668. var position = $.extend({
  5669. of: this.active
  5670. }, this.options.position );
  5671. clearTimeout( this.timer );
  5672. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  5673. .hide()
  5674. .attr( "aria-hidden", "true" );
  5675. submenu
  5676. .show()
  5677. .removeAttr( "aria-hidden" )
  5678. .attr( "aria-expanded", "true" )
  5679. .position( position );
  5680. },
  5681. collapseAll: function( event, all ) {
  5682. clearTimeout( this.timer );
  5683. this.timer = this._delay(function() {
  5684. // If we were passed an event, look for the submenu that contains the event
  5685. var currentMenu = all ? this.element :
  5686. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  5687. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  5688. if ( !currentMenu.length ) {
  5689. currentMenu = this.element;
  5690. }
  5691. this._close( currentMenu );
  5692. this.blur( event );
  5693. this.activeMenu = currentMenu;
  5694. }, this.delay );
  5695. },
  5696. // With no arguments, closes the currently active menu - if nothing is active
  5697. // it closes all menus. If passed an argument, it will search for menus BELOW
  5698. _close: function( startMenu ) {
  5699. if ( !startMenu ) {
  5700. startMenu = this.active ? this.active.parent() : this.element;
  5701. }
  5702. startMenu
  5703. .find( ".ui-menu" )
  5704. .hide()
  5705. .attr( "aria-hidden", "true" )
  5706. .attr( "aria-expanded", "false" )
  5707. .end()
  5708. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  5709. .removeClass( "ui-state-active" );
  5710. },
  5711. _closeOnDocumentClick: function( event ) {
  5712. return !$( event.target ).closest( ".ui-menu" ).length;
  5713. },
  5714. _isDivider: function( item ) {
  5715. // Match hyphen, em dash, en dash
  5716. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  5717. },
  5718. collapse: function( event ) {
  5719. var newItem = this.active &&
  5720. this.active.parent().closest( ".ui-menu-item", this.element );
  5721. if ( newItem && newItem.length ) {
  5722. this._close();
  5723. this.focus( event, newItem );
  5724. }
  5725. },
  5726. expand: function( event ) {
  5727. var newItem = this.active &&
  5728. this.active
  5729. .children( ".ui-menu " )
  5730. .find( this.options.items )
  5731. .first();
  5732. if ( newItem && newItem.length ) {
  5733. this._open( newItem.parent() );
  5734. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  5735. this._delay(function() {
  5736. this.focus( event, newItem );
  5737. });
  5738. }
  5739. },
  5740. next: function( event ) {
  5741. this._move( "next", "first", event );
  5742. },
  5743. previous: function( event ) {
  5744. this._move( "prev", "last", event );
  5745. },
  5746. isFirstItem: function() {
  5747. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  5748. },
  5749. isLastItem: function() {
  5750. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  5751. },
  5752. _move: function( direction, filter, event ) {
  5753. var next;
  5754. if ( this.active ) {
  5755. if ( direction === "first" || direction === "last" ) {
  5756. next = this.active
  5757. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  5758. .eq( -1 );
  5759. } else {
  5760. next = this.active
  5761. [ direction + "All" ]( ".ui-menu-item" )
  5762. .eq( 0 );
  5763. }
  5764. }
  5765. if ( !next || !next.length || !this.active ) {
  5766. next = this.activeMenu.find( this.options.items )[ filter ]();
  5767. }
  5768. this.focus( event, next );
  5769. },
  5770. nextPage: function( event ) {
  5771. var item, base, height;
  5772. if ( !this.active ) {
  5773. this.next( event );
  5774. return;
  5775. }
  5776. if ( this.isLastItem() ) {
  5777. return;
  5778. }
  5779. if ( this._hasScroll() ) {
  5780. base = this.active.offset().top;
  5781. height = this.element.height();
  5782. this.active.nextAll( ".ui-menu-item" ).each(function() {
  5783. item = $( this );
  5784. return item.offset().top - base - height < 0;
  5785. });
  5786. this.focus( event, item );
  5787. } else {
  5788. this.focus( event, this.activeMenu.find( this.options.items )
  5789. [ !this.active ? "first" : "last" ]() );
  5790. }
  5791. },
  5792. previousPage: function( event ) {
  5793. var item, base, height;
  5794. if ( !this.active ) {
  5795. this.next( event );
  5796. return;
  5797. }
  5798. if ( this.isFirstItem() ) {
  5799. return;
  5800. }
  5801. if ( this._hasScroll() ) {
  5802. base = this.active.offset().top;
  5803. height = this.element.height();
  5804. this.active.prevAll( ".ui-menu-item" ).each(function() {
  5805. item = $( this );
  5806. return item.offset().top - base + height > 0;
  5807. });
  5808. this.focus( event, item );
  5809. } else {
  5810. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  5811. }
  5812. },
  5813. _hasScroll: function() {
  5814. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  5815. },
  5816. select: function( event ) {
  5817. // TODO: It should never be possible to not have an active item at this
  5818. // point, but the tests don't trigger mouseenter before click.
  5819. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  5820. var ui = { item: this.active };
  5821. if ( !this.active.has( ".ui-menu" ).length ) {
  5822. this.collapseAll( event, true );
  5823. }
  5824. this._trigger( "select", event, ui );
  5825. },
  5826. _filterMenuItems: function(character) {
  5827. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  5828. regex = new RegExp( "^" + escapedCharacter, "i" );
  5829. return this.activeMenu
  5830. .find( this.options.items )
  5831. // Only match on items, not dividers or other content (#10571)
  5832. .filter( ".ui-menu-item" )
  5833. .filter(function() {
  5834. return regex.test( $.trim( $( this ).text() ) );
  5835. });
  5836. }
  5837. });
  5838. /*!
  5839. * jQuery UI Autocomplete 1.11.4
  5840. * http://jqueryui.com
  5841. *
  5842. * Copyright jQuery Foundation and other contributors
  5843. * Released under the MIT license.
  5844. * http://jquery.org/license
  5845. *
  5846. * http://api.jqueryui.com/autocomplete/
  5847. */
  5848. $.widget( "ui.autocomplete", {
  5849. version: "1.11.4",
  5850. defaultElement: "<input>",
  5851. options: {
  5852. appendTo: null,
  5853. autoFocus: false,
  5854. delay: 300,
  5855. minLength: 1,
  5856. position: {
  5857. my: "left top",
  5858. at: "left bottom",
  5859. collision: "none"
  5860. },
  5861. source: null,
  5862. // callbacks
  5863. change: null,
  5864. close: null,
  5865. focus: null,
  5866. open: null,
  5867. response: null,
  5868. search: null,
  5869. select: null
  5870. },
  5871. requestIndex: 0,
  5872. pending: 0,
  5873. _create: function() {
  5874. // Some browsers only repeat keydown events, not keypress events,
  5875. // so we use the suppressKeyPress flag to determine if we've already
  5876. // handled the keydown event. #7269
  5877. // Unfortunately the code for & in keypress is the same as the up arrow,
  5878. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5879. // events when we know the keydown event was used to modify the
  5880. // search term. #7799
  5881. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5882. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  5883. isTextarea = nodeName === "textarea",
  5884. isInput = nodeName === "input";
  5885. this.isMultiLine =
  5886. // Textareas are always multi-line
  5887. isTextarea ? true :
  5888. // Inputs are always single-line, even if inside a contentEditable element
  5889. // IE also treats inputs as contentEditable
  5890. isInput ? false :
  5891. // All other element types are determined by whether or not they're contentEditable
  5892. this.element.prop( "isContentEditable" );
  5893. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5894. this.isNewMenu = true;
  5895. this.element
  5896. .addClass( "ui-autocomplete-input" )
  5897. .attr( "autocomplete", "off" );
  5898. this._on( this.element, {
  5899. keydown: function( event ) {
  5900. if ( this.element.prop( "readOnly" ) ) {
  5901. suppressKeyPress = true;
  5902. suppressInput = true;
  5903. suppressKeyPressRepeat = true;
  5904. return;
  5905. }
  5906. suppressKeyPress = false;
  5907. suppressInput = false;
  5908. suppressKeyPressRepeat = false;
  5909. var keyCode = $.ui.keyCode;
  5910. switch ( event.keyCode ) {
  5911. case keyCode.PAGE_UP:
  5912. suppressKeyPress = true;
  5913. this._move( "previousPage", event );
  5914. break;
  5915. case keyCode.PAGE_DOWN:
  5916. suppressKeyPress = true;
  5917. this._move( "nextPage", event );
  5918. break;
  5919. case keyCode.UP:
  5920. suppressKeyPress = true;
  5921. this._keyEvent( "previous", event );
  5922. break;
  5923. case keyCode.DOWN:
  5924. suppressKeyPress = true;
  5925. this._keyEvent( "next", event );
  5926. break;
  5927. case keyCode.ENTER:
  5928. // when menu is open and has focus
  5929. if ( this.menu.active ) {
  5930. // #6055 - Opera still allows the keypress to occur
  5931. // which causes forms to submit
  5932. suppressKeyPress = true;
  5933. event.preventDefault();
  5934. this.menu.select( event );
  5935. }
  5936. break;
  5937. case keyCode.TAB:
  5938. if ( this.menu.active ) {
  5939. this.menu.select( event );
  5940. }
  5941. break;
  5942. case keyCode.ESCAPE:
  5943. if ( this.menu.element.is( ":visible" ) ) {
  5944. if ( !this.isMultiLine ) {
  5945. this._value( this.term );
  5946. }
  5947. this.close( event );
  5948. // Different browsers have different default behavior for escape
  5949. // Single press can mean undo or clear
  5950. // Double press in IE means clear the whole form
  5951. event.preventDefault();
  5952. }
  5953. break;
  5954. default:
  5955. suppressKeyPressRepeat = true;
  5956. // search timeout should be triggered before the input value is changed
  5957. this._searchTimeout( event );
  5958. break;
  5959. }
  5960. },
  5961. keypress: function( event ) {
  5962. if ( suppressKeyPress ) {
  5963. suppressKeyPress = false;
  5964. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5965. event.preventDefault();
  5966. }
  5967. return;
  5968. }
  5969. if ( suppressKeyPressRepeat ) {
  5970. return;
  5971. }
  5972. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5973. var keyCode = $.ui.keyCode;
  5974. switch ( event.keyCode ) {
  5975. case keyCode.PAGE_UP:
  5976. this._move( "previousPage", event );
  5977. break;
  5978. case keyCode.PAGE_DOWN:
  5979. this._move( "nextPage", event );
  5980. break;
  5981. case keyCode.UP:
  5982. this._keyEvent( "previous", event );
  5983. break;
  5984. case keyCode.DOWN:
  5985. this._keyEvent( "next", event );
  5986. break;
  5987. }
  5988. },
  5989. input: function( event ) {
  5990. if ( suppressInput ) {
  5991. suppressInput = false;
  5992. event.preventDefault();
  5993. return;
  5994. }
  5995. this._searchTimeout( event );
  5996. },
  5997. focus: function() {
  5998. this.selectedItem = null;
  5999. this.previous = this._value();
  6000. },
  6001. blur: function( event ) {
  6002. if ( this.cancelBlur ) {
  6003. delete this.cancelBlur;
  6004. return;
  6005. }
  6006. clearTimeout( this.searching );
  6007. this.close( event );
  6008. this._change( event );
  6009. }
  6010. });
  6011. this._initSource();
  6012. this.menu = $( "<ul>" )
  6013. .addClass( "ui-autocomplete ui-front" )
  6014. .appendTo( this._appendTo() )
  6015. .menu({
  6016. // disable ARIA support, the live region takes care of that
  6017. role: null
  6018. })
  6019. .hide()
  6020. .menu( "instance" );
  6021. this._on( this.menu.element, {
  6022. mousedown: function( event ) {
  6023. // prevent moving focus out of the text field
  6024. event.preventDefault();
  6025. // IE doesn't prevent moving focus even with event.preventDefault()
  6026. // so we set a flag to know when we should ignore the blur event
  6027. this.cancelBlur = true;
  6028. this._delay(function() {
  6029. delete this.cancelBlur;
  6030. });
  6031. // clicking on the scrollbar causes focus to shift to the body
  6032. // but we can't detect a mouseup or a click immediately afterward
  6033. // so we have to track the next mousedown and close the menu if
  6034. // the user clicks somewhere outside of the autocomplete
  6035. var menuElement = this.menu.element[ 0 ];
  6036. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  6037. this._delay(function() {
  6038. var that = this;
  6039. this.document.one( "mousedown", function( event ) {
  6040. if ( event.target !== that.element[ 0 ] &&
  6041. event.target !== menuElement &&
  6042. !$.contains( menuElement, event.target ) ) {
  6043. that.close();
  6044. }
  6045. });
  6046. });
  6047. }
  6048. },
  6049. menufocus: function( event, ui ) {
  6050. var label, item;
  6051. // support: Firefox
  6052. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  6053. if ( this.isNewMenu ) {
  6054. this.isNewMenu = false;
  6055. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  6056. this.menu.blur();
  6057. this.document.one( "mousemove", function() {
  6058. $( event.target ).trigger( event.originalEvent );
  6059. });
  6060. return;
  6061. }
  6062. }
  6063. item = ui.item.data( "ui-autocomplete-item" );
  6064. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  6065. // use value to match what will end up in the input, if it was a key event
  6066. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  6067. this._value( item.value );
  6068. }
  6069. }
  6070. // Announce the value in the liveRegion
  6071. label = ui.item.attr( "aria-label" ) || item.value;
  6072. if ( label && $.trim( label ).length ) {
  6073. this.liveRegion.children().hide();
  6074. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  6075. }
  6076. },
  6077. menuselect: function( event, ui ) {
  6078. var item = ui.item.data( "ui-autocomplete-item" ),
  6079. previous = this.previous;
  6080. // only trigger when focus was lost (click on menu)
  6081. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  6082. this.element.focus();
  6083. this.previous = previous;
  6084. // #6109 - IE triggers two focus events and the second
  6085. // is asynchronous, so we need to reset the previous
  6086. // term synchronously and asynchronously :-(
  6087. this._delay(function() {
  6088. this.previous = previous;
  6089. this.selectedItem = item;
  6090. });
  6091. }
  6092. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  6093. this._value( item.value );
  6094. }
  6095. // reset the term after the select event
  6096. // this allows custom select handling to work properly
  6097. this.term = this._value();
  6098. this.close( event );
  6099. this.selectedItem = item;
  6100. }
  6101. });
  6102. this.liveRegion = $( "<span>", {
  6103. role: "status",
  6104. "aria-live": "assertive",
  6105. "aria-relevant": "additions"
  6106. })
  6107. .addClass( "ui-helper-hidden-accessible" )
  6108. .appendTo( this.document[ 0 ].body );
  6109. // turning off autocomplete prevents the browser from remembering the
  6110. // value when navigating through history, so we re-enable autocomplete
  6111. // if the page is unloaded before the widget is destroyed. #7790
  6112. this._on( this.window, {
  6113. beforeunload: function() {
  6114. this.element.removeAttr( "autocomplete" );
  6115. }
  6116. });
  6117. },
  6118. _destroy: function() {
  6119. clearTimeout( this.searching );
  6120. this.element
  6121. .removeClass( "ui-autocomplete-input" )
  6122. .removeAttr( "autocomplete" );
  6123. this.menu.element.remove();
  6124. this.liveRegion.remove();
  6125. },
  6126. _setOption: function( key, value ) {
  6127. this._super( key, value );
  6128. if ( key === "source" ) {
  6129. this._initSource();
  6130. }
  6131. if ( key === "appendTo" ) {
  6132. this.menu.element.appendTo( this._appendTo() );
  6133. }
  6134. if ( key === "disabled" && value && this.xhr ) {
  6135. this.xhr.abort();
  6136. }
  6137. },
  6138. _appendTo: function() {
  6139. var element = this.options.appendTo;
  6140. if ( element ) {
  6141. element = element.jquery || element.nodeType ?
  6142. $( element ) :
  6143. this.document.find( element ).eq( 0 );
  6144. }
  6145. if ( !element || !element[ 0 ] ) {
  6146. element = this.element.closest( ".ui-front" );
  6147. }
  6148. if ( !element.length ) {
  6149. element = this.document[ 0 ].body;
  6150. }
  6151. return element;
  6152. },
  6153. _initSource: function() {
  6154. var array, url,
  6155. that = this;
  6156. if ( $.isArray( this.options.source ) ) {
  6157. array = this.options.source;
  6158. this.source = function( request, response ) {
  6159. response( $.ui.autocomplete.filter( array, request.term ) );
  6160. };
  6161. } else if ( typeof this.options.source === "string" ) {
  6162. url = this.options.source;
  6163. this.source = function( request, response ) {
  6164. if ( that.xhr ) {
  6165. that.xhr.abort();
  6166. }
  6167. that.xhr = $.ajax({
  6168. url: url,
  6169. data: request,
  6170. dataType: "json",
  6171. success: function( data ) {
  6172. response( data );
  6173. },
  6174. error: function() {
  6175. response([]);
  6176. }
  6177. });
  6178. };
  6179. } else {
  6180. this.source = this.options.source;
  6181. }
  6182. },
  6183. _searchTimeout: function( event ) {
  6184. clearTimeout( this.searching );
  6185. this.searching = this._delay(function() {
  6186. // Search if the value has changed, or if the user retypes the same value (see #7434)
  6187. var equalValues = this.term === this._value(),
  6188. menuVisible = this.menu.element.is( ":visible" ),
  6189. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  6190. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  6191. this.selectedItem = null;
  6192. this.search( null, event );
  6193. }
  6194. }, this.options.delay );
  6195. },
  6196. search: function( value, event ) {
  6197. value = value != null ? value : this._value();
  6198. // always save the actual value, not the one passed as an argument
  6199. this.term = this._value();
  6200. if ( value.length < this.options.minLength ) {
  6201. return this.close( event );
  6202. }
  6203. if ( this._trigger( "search", event ) === false ) {
  6204. return;
  6205. }
  6206. return this._search( value );
  6207. },
  6208. _search: function( value ) {
  6209. this.pending++;
  6210. this.element.addClass( "ui-autocomplete-loading" );
  6211. this.cancelSearch = false;
  6212. this.source( { term: value }, this._response() );
  6213. },
  6214. _response: function() {
  6215. var index = ++this.requestIndex;
  6216. return $.proxy(function( content ) {
  6217. if ( index === this.requestIndex ) {
  6218. this.__response( content );
  6219. }
  6220. this.pending--;
  6221. if ( !this.pending ) {
  6222. this.element.removeClass( "ui-autocomplete-loading" );
  6223. }
  6224. }, this );
  6225. },
  6226. __response: function( content ) {
  6227. if ( content ) {
  6228. content = this._normalize( content );
  6229. }
  6230. this._trigger( "response", null, { content: content } );
  6231. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  6232. this._suggest( content );
  6233. this._trigger( "open" );
  6234. } else {
  6235. // use ._close() instead of .close() so we don't cancel future searches
  6236. this._close();
  6237. }
  6238. },
  6239. close: function( event ) {
  6240. this.cancelSearch = true;
  6241. this._close( event );
  6242. },
  6243. _close: function( event ) {
  6244. if ( this.menu.element.is( ":visible" ) ) {
  6245. this.menu.element.hide();
  6246. this.menu.blur();
  6247. this.isNewMenu = true;
  6248. this._trigger( "close", event );
  6249. }
  6250. },
  6251. _change: function( event ) {
  6252. if ( this.previous !== this._value() ) {
  6253. this._trigger( "change", event, { item: this.selectedItem } );
  6254. }
  6255. },
  6256. _normalize: function( items ) {
  6257. // assume all items have the right format when the first item is complete
  6258. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  6259. return items;
  6260. }
  6261. return $.map( items, function( item ) {
  6262. if ( typeof item === "string" ) {
  6263. return {
  6264. label: item,
  6265. value: item
  6266. };
  6267. }
  6268. return $.extend( {}, item, {
  6269. label: item.label || item.value,
  6270. value: item.value || item.label
  6271. });
  6272. });
  6273. },
  6274. _suggest: function( items ) {
  6275. var ul = this.menu.element.empty();
  6276. this._renderMenu( ul, items );
  6277. this.isNewMenu = true;
  6278. this.menu.refresh();
  6279. // size and position menu
  6280. ul.show();
  6281. this._resizeMenu();
  6282. ul.position( $.extend({
  6283. of: this.element
  6284. }, this.options.position ) );
  6285. if ( this.options.autoFocus ) {
  6286. this.menu.next();
  6287. }
  6288. },
  6289. _resizeMenu: function() {
  6290. var ul = this.menu.element;
  6291. ul.outerWidth( Math.max(
  6292. // Firefox wraps long text (possibly a rounding bug)
  6293. // so we add 1px to avoid the wrapping (#7513)
  6294. ul.width( "" ).outerWidth() + 1,
  6295. this.element.outerWidth()
  6296. ) );
  6297. },
  6298. _renderMenu: function( ul, items ) {
  6299. var that = this;
  6300. $.each( items, function( index, item ) {
  6301. that._renderItemData( ul, item );
  6302. });
  6303. },
  6304. _renderItemData: function( ul, item ) {
  6305. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  6306. },
  6307. _renderItem: function( ul, item ) {
  6308. return $( "<li>" ).text( item.label ).appendTo( ul );
  6309. },
  6310. _move: function( direction, event ) {
  6311. if ( !this.menu.element.is( ":visible" ) ) {
  6312. this.search( null, event );
  6313. return;
  6314. }
  6315. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  6316. this.menu.isLastItem() && /^next/.test( direction ) ) {
  6317. if ( !this.isMultiLine ) {
  6318. this._value( this.term );
  6319. }
  6320. this.menu.blur();
  6321. return;
  6322. }
  6323. this.menu[ direction ]( event );
  6324. },
  6325. widget: function() {
  6326. return this.menu.element;
  6327. },
  6328. _value: function() {
  6329. return this.valueMethod.apply( this.element, arguments );
  6330. },
  6331. _keyEvent: function( keyEvent, event ) {
  6332. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6333. this._move( keyEvent, event );
  6334. // prevents moving cursor to beginning/end of the text field in some browsers
  6335. event.preventDefault();
  6336. }
  6337. }
  6338. });
  6339. $.extend( $.ui.autocomplete, {
  6340. escapeRegex: function( value ) {
  6341. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  6342. },
  6343. filter: function( array, term ) {
  6344. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  6345. return $.grep( array, function( value ) {
  6346. return matcher.test( value.label || value.value || value );
  6347. });
  6348. }
  6349. });
  6350. // live region extension, adding a `messages` option
  6351. // NOTE: This is an experimental API. We are still investigating
  6352. // a full solution for string manipulation and internationalization.
  6353. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6354. options: {
  6355. messages: {
  6356. noResults: "No search results.",
  6357. results: function( amount ) {
  6358. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6359. " available, use up and down arrow keys to navigate.";
  6360. }
  6361. }
  6362. },
  6363. __response: function( content ) {
  6364. var message;
  6365. this._superApply( arguments );
  6366. if ( this.options.disabled || this.cancelSearch ) {
  6367. return;
  6368. }
  6369. if ( content && content.length ) {
  6370. message = this.options.messages.results( content.length );
  6371. } else {
  6372. message = this.options.messages.noResults;
  6373. }
  6374. this.liveRegion.children().hide();
  6375. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  6376. }
  6377. });
  6378. var autocomplete = $.ui.autocomplete;
  6379. /*!
  6380. * jQuery UI Button 1.11.4
  6381. * http://jqueryui.com
  6382. *
  6383. * Copyright jQuery Foundation and other contributors
  6384. * Released under the MIT license.
  6385. * http://jquery.org/license
  6386. *
  6387. * http://api.jqueryui.com/button/
  6388. */
  6389. var lastActive,
  6390. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6391. 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",
  6392. formResetHandler = function() {
  6393. var form = $( this );
  6394. setTimeout(function() {
  6395. form.find( ":ui-button" ).button( "refresh" );
  6396. }, 1 );
  6397. },
  6398. radioGroup = function( radio ) {
  6399. var name = radio.name,
  6400. form = radio.form,
  6401. radios = $( [] );
  6402. if ( name ) {
  6403. name = name.replace( /'/g, "\\'" );
  6404. if ( form ) {
  6405. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  6406. } else {
  6407. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  6408. .filter(function() {
  6409. return !this.form;
  6410. });
  6411. }
  6412. }
  6413. return radios;
  6414. };
  6415. $.widget( "ui.button", {
  6416. version: "1.11.4",
  6417. defaultElement: "<button>",
  6418. options: {
  6419. disabled: null,
  6420. text: true,
  6421. label: null,
  6422. icons: {
  6423. primary: null,
  6424. secondary: null
  6425. }
  6426. },
  6427. _create: function() {
  6428. this.element.closest( "form" )
  6429. .unbind( "reset" + this.eventNamespace )
  6430. .bind( "reset" + this.eventNamespace, formResetHandler );
  6431. if ( typeof this.options.disabled !== "boolean" ) {
  6432. this.options.disabled = !!this.element.prop( "disabled" );
  6433. } else {
  6434. this.element.prop( "disabled", this.options.disabled );
  6435. }
  6436. this._determineButtonType();
  6437. this.hasTitle = !!this.buttonElement.attr( "title" );
  6438. var that = this,
  6439. options = this.options,
  6440. toggleButton = this.type === "checkbox" || this.type === "radio",
  6441. activeClass = !toggleButton ? "ui-state-active" : "";
  6442. if ( options.label === null ) {
  6443. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6444. }
  6445. this._hoverable( this.buttonElement );
  6446. this.buttonElement
  6447. .addClass( baseClasses )
  6448. .attr( "role", "button" )
  6449. .bind( "mouseenter" + this.eventNamespace, function() {
  6450. if ( options.disabled ) {
  6451. return;
  6452. }
  6453. if ( this === lastActive ) {
  6454. $( this ).addClass( "ui-state-active" );
  6455. }
  6456. })
  6457. .bind( "mouseleave" + this.eventNamespace, function() {
  6458. if ( options.disabled ) {
  6459. return;
  6460. }
  6461. $( this ).removeClass( activeClass );
  6462. })
  6463. .bind( "click" + this.eventNamespace, function( event ) {
  6464. if ( options.disabled ) {
  6465. event.preventDefault();
  6466. event.stopImmediatePropagation();
  6467. }
  6468. });
  6469. // Can't use _focusable() because the element that receives focus
  6470. // and the element that gets the ui-state-focus class are different
  6471. this._on({
  6472. focus: function() {
  6473. this.buttonElement.addClass( "ui-state-focus" );
  6474. },
  6475. blur: function() {
  6476. this.buttonElement.removeClass( "ui-state-focus" );
  6477. }
  6478. });
  6479. if ( toggleButton ) {
  6480. this.element.bind( "change" + this.eventNamespace, function() {
  6481. that.refresh();
  6482. });
  6483. }
  6484. if ( this.type === "checkbox" ) {
  6485. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6486. if ( options.disabled ) {
  6487. return false;
  6488. }
  6489. });
  6490. } else if ( this.type === "radio" ) {
  6491. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6492. if ( options.disabled ) {
  6493. return false;
  6494. }
  6495. $( this ).addClass( "ui-state-active" );
  6496. that.buttonElement.attr( "aria-pressed", "true" );
  6497. var radio = that.element[ 0 ];
  6498. radioGroup( radio )
  6499. .not( radio )
  6500. .map(function() {
  6501. return $( this ).button( "widget" )[ 0 ];
  6502. })
  6503. .removeClass( "ui-state-active" )
  6504. .attr( "aria-pressed", "false" );
  6505. });
  6506. } else {
  6507. this.buttonElement
  6508. .bind( "mousedown" + this.eventNamespace, function() {
  6509. if ( options.disabled ) {
  6510. return false;
  6511. }
  6512. $( this ).addClass( "ui-state-active" );
  6513. lastActive = this;
  6514. that.document.one( "mouseup", function() {
  6515. lastActive = null;
  6516. });
  6517. })
  6518. .bind( "mouseup" + this.eventNamespace, function() {
  6519. if ( options.disabled ) {
  6520. return false;
  6521. }
  6522. $( this ).removeClass( "ui-state-active" );
  6523. })
  6524. .bind( "keydown" + this.eventNamespace, function(event) {
  6525. if ( options.disabled ) {
  6526. return false;
  6527. }
  6528. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6529. $( this ).addClass( "ui-state-active" );
  6530. }
  6531. })
  6532. // see #8559, we bind to blur here in case the button element loses
  6533. // focus between keydown and keyup, it would be left in an "active" state
  6534. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6535. $( this ).removeClass( "ui-state-active" );
  6536. });
  6537. if ( this.buttonElement.is("a") ) {
  6538. this.buttonElement.keyup(function(event) {
  6539. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6540. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6541. $( this ).click();
  6542. }
  6543. });
  6544. }
  6545. }
  6546. this._setOption( "disabled", options.disabled );
  6547. this._resetButton();
  6548. },
  6549. _determineButtonType: function() {
  6550. var ancestor, labelSelector, checked;
  6551. if ( this.element.is("[type=checkbox]") ) {
  6552. this.type = "checkbox";
  6553. } else if ( this.element.is("[type=radio]") ) {
  6554. this.type = "radio";
  6555. } else if ( this.element.is("input") ) {
  6556. this.type = "input";
  6557. } else {
  6558. this.type = "button";
  6559. }
  6560. if ( this.type === "checkbox" || this.type === "radio" ) {
  6561. // we don't search against the document in case the element
  6562. // is disconnected from the DOM
  6563. ancestor = this.element.parents().last();
  6564. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6565. this.buttonElement = ancestor.find( labelSelector );
  6566. if ( !this.buttonElement.length ) {
  6567. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6568. this.buttonElement = ancestor.filter( labelSelector );
  6569. if ( !this.buttonElement.length ) {
  6570. this.buttonElement = ancestor.find( labelSelector );
  6571. }
  6572. }
  6573. this.element.addClass( "ui-helper-hidden-accessible" );
  6574. checked = this.element.is( ":checked" );
  6575. if ( checked ) {
  6576. this.buttonElement.addClass( "ui-state-active" );
  6577. }
  6578. this.buttonElement.prop( "aria-pressed", checked );
  6579. } else {
  6580. this.buttonElement = this.element;
  6581. }
  6582. },
  6583. widget: function() {
  6584. return this.buttonElement;
  6585. },
  6586. _destroy: function() {
  6587. this.element
  6588. .removeClass( "ui-helper-hidden-accessible" );
  6589. this.buttonElement
  6590. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  6591. .removeAttr( "role" )
  6592. .removeAttr( "aria-pressed" )
  6593. .html( this.buttonElement.find(".ui-button-text").html() );
  6594. if ( !this.hasTitle ) {
  6595. this.buttonElement.removeAttr( "title" );
  6596. }
  6597. },
  6598. _setOption: function( key, value ) {
  6599. this._super( key, value );
  6600. if ( key === "disabled" ) {
  6601. this.widget().toggleClass( "ui-state-disabled", !!value );
  6602. this.element.prop( "disabled", !!value );
  6603. if ( value ) {
  6604. if ( this.type === "checkbox" || this.type === "radio" ) {
  6605. this.buttonElement.removeClass( "ui-state-focus" );
  6606. } else {
  6607. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  6608. }
  6609. }
  6610. return;
  6611. }
  6612. this._resetButton();
  6613. },
  6614. refresh: function() {
  6615. //See #8237 & #8828
  6616. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6617. if ( isDisabled !== this.options.disabled ) {
  6618. this._setOption( "disabled", isDisabled );
  6619. }
  6620. if ( this.type === "radio" ) {
  6621. radioGroup( this.element[0] ).each(function() {
  6622. if ( $( this ).is( ":checked" ) ) {
  6623. $( this ).button( "widget" )
  6624. .addClass( "ui-state-active" )
  6625. .attr( "aria-pressed", "true" );
  6626. } else {
  6627. $( this ).button( "widget" )
  6628. .removeClass( "ui-state-active" )
  6629. .attr( "aria-pressed", "false" );
  6630. }
  6631. });
  6632. } else if ( this.type === "checkbox" ) {
  6633. if ( this.element.is( ":checked" ) ) {
  6634. this.buttonElement
  6635. .addClass( "ui-state-active" )
  6636. .attr( "aria-pressed", "true" );
  6637. } else {
  6638. this.buttonElement
  6639. .removeClass( "ui-state-active" )
  6640. .attr( "aria-pressed", "false" );
  6641. }
  6642. }
  6643. },
  6644. _resetButton: function() {
  6645. if ( this.type === "input" ) {
  6646. if ( this.options.label ) {
  6647. this.element.val( this.options.label );
  6648. }
  6649. return;
  6650. }
  6651. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6652. buttonText = $( "<span></span>", this.document[0] )
  6653. .addClass( "ui-button-text" )
  6654. .html( this.options.label )
  6655. .appendTo( buttonElement.empty() )
  6656. .text(),
  6657. icons = this.options.icons,
  6658. multipleIcons = icons.primary && icons.secondary,
  6659. buttonClasses = [];
  6660. if ( icons.primary || icons.secondary ) {
  6661. if ( this.options.text ) {
  6662. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6663. }
  6664. if ( icons.primary ) {
  6665. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6666. }
  6667. if ( icons.secondary ) {
  6668. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6669. }
  6670. if ( !this.options.text ) {
  6671. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6672. if ( !this.hasTitle ) {
  6673. buttonElement.attr( "title", $.trim( buttonText ) );
  6674. }
  6675. }
  6676. } else {
  6677. buttonClasses.push( "ui-button-text-only" );
  6678. }
  6679. buttonElement.addClass( buttonClasses.join( " " ) );
  6680. }
  6681. });
  6682. $.widget( "ui.buttonset", {
  6683. version: "1.11.4",
  6684. options: {
  6685. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6686. },
  6687. _create: function() {
  6688. this.element.addClass( "ui-buttonset" );
  6689. },
  6690. _init: function() {
  6691. this.refresh();
  6692. },
  6693. _setOption: function( key, value ) {
  6694. if ( key === "disabled" ) {
  6695. this.buttons.button( "option", key, value );
  6696. }
  6697. this._super( key, value );
  6698. },
  6699. refresh: function() {
  6700. var rtl = this.element.css( "direction" ) === "rtl",
  6701. allButtons = this.element.find( this.options.items ),
  6702. existingButtons = allButtons.filter( ":ui-button" );
  6703. // Initialize new buttons
  6704. allButtons.not( ":ui-button" ).button();
  6705. // Refresh existing buttons
  6706. existingButtons.button( "refresh" );
  6707. this.buttons = allButtons
  6708. .map(function() {
  6709. return $( this ).button( "widget" )[ 0 ];
  6710. })
  6711. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6712. .filter( ":first" )
  6713. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6714. .end()
  6715. .filter( ":last" )
  6716. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6717. .end()
  6718. .end();
  6719. },
  6720. _destroy: function() {
  6721. this.element.removeClass( "ui-buttonset" );
  6722. this.buttons
  6723. .map(function() {
  6724. return $( this ).button( "widget" )[ 0 ];
  6725. })
  6726. .removeClass( "ui-corner-left ui-corner-right" )
  6727. .end()
  6728. .button( "destroy" );
  6729. }
  6730. });
  6731. var button = $.ui.button;
  6732. /*!
  6733. * jQuery UI Datepicker 1.11.4
  6734. * http://jqueryui.com
  6735. *
  6736. * Copyright jQuery Foundation and other contributors
  6737. * Released under the MIT license.
  6738. * http://jquery.org/license
  6739. *
  6740. * http://api.jqueryui.com/datepicker/
  6741. */
  6742. $.extend($.ui, { datepicker: { version: "1.11.4" } });
  6743. var datepicker_instActive;
  6744. function datepicker_getZindex( elem ) {
  6745. var position, value;
  6746. while ( elem.length && elem[ 0 ] !== document ) {
  6747. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  6748. // This makes behavior of this function consistent across browsers
  6749. // WebKit always returns auto if the element is positioned
  6750. position = elem.css( "position" );
  6751. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6752. // IE returns 0 when zIndex is not specified
  6753. // other browsers return a string
  6754. // we ignore the case of nested elements with an explicit value of 0
  6755. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6756. value = parseInt( elem.css( "zIndex" ), 10 );
  6757. if ( !isNaN( value ) && value !== 0 ) {
  6758. return value;
  6759. }
  6760. }
  6761. elem = elem.parent();
  6762. }
  6763. return 0;
  6764. }
  6765. /* Date picker manager.
  6766. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6767. Settings for (groups of) date pickers are maintained in an instance object,
  6768. allowing multiple different settings on the same page. */
  6769. function Datepicker() {
  6770. this._curInst = null; // The current instance in use
  6771. this._keyEvent = false; // If the last event was a key event
  6772. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6773. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6774. this._inDialog = false; // True if showing within a "dialog", false if not
  6775. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6776. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6777. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6778. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6779. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6780. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6781. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6782. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6783. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6784. this.regional = []; // Available regional settings, indexed by language code
  6785. this.regional[""] = { // Default regional settings
  6786. closeText: "Done", // Display text for close link
  6787. prevText: "Prev", // Display text for previous month link
  6788. nextText: "Next", // Display text for next month link
  6789. currentText: "Today", // Display text for current month link
  6790. monthNames: ["January","February","March","April","May","June",
  6791. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6792. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6793. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6794. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6795. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6796. weekHeader: "Wk", // Column header for week of the year
  6797. dateFormat: "mm/dd/yy", // See format options on parseDate
  6798. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6799. isRTL: false, // True if right-to-left language, false if left-to-right
  6800. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6801. yearSuffix: "" // Additional text to append to the year in the month headers
  6802. };
  6803. this._defaults = { // Global defaults for all the date picker instances
  6804. showOn: "focus", // "focus" for popup on focus,
  6805. // "button" for trigger button, or "both" for either
  6806. showAnim: "fadeIn", // Name of jQuery animation for popup
  6807. showOptions: {}, // Options for enhanced animations
  6808. defaultDate: null, // Used when field is blank: actual date,
  6809. // +/-number for offset from today, null for today
  6810. appendText: "", // Display text following the input box, e.g. showing the format
  6811. buttonText: "...", // Text for trigger button
  6812. buttonImage: "", // URL for trigger button image
  6813. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6814. hideIfNoPrevNext: false, // True to hide next/previous month links
  6815. // if not applicable, false to just disable them
  6816. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6817. gotoCurrent: false, // True if today link goes back to current selection instead
  6818. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6819. changeYear: false, // True if year can be selected directly, false if only prev/next
  6820. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6821. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6822. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6823. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6824. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6825. showWeek: false, // True to show week of the year, false to not show it
  6826. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6827. // takes a Date and returns the number of the week for it
  6828. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6829. // > this are in the previous century,
  6830. // string value starting with "+" for current year + value
  6831. minDate: null, // The earliest selectable date, or null for no limit
  6832. maxDate: null, // The latest selectable date, or null for no limit
  6833. duration: "fast", // Duration of display/closure
  6834. beforeShowDay: null, // Function that takes a date and returns an array with
  6835. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6836. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6837. beforeShow: null, // Function that takes an input field and
  6838. // returns a set of custom settings for the date picker
  6839. onSelect: null, // Define a callback function when a date is selected
  6840. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6841. onClose: null, // Define a callback function when the datepicker is closed
  6842. numberOfMonths: 1, // Number of months to show at a time
  6843. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6844. stepMonths: 1, // Number of months to step back/forward
  6845. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6846. altField: "", // Selector for an alternate field to store selected dates into
  6847. altFormat: "", // The date format to use for the alternate field
  6848. constrainInput: true, // The input is constrained by the current date format
  6849. showButtonPanel: false, // True to show button panel, false to not show it
  6850. autoSize: false, // True to size the input for the date format, false to leave as is
  6851. disabled: false // The initial disabled state
  6852. };
  6853. $.extend(this._defaults, this.regional[""]);
  6854. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  6855. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6856. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6857. }
  6858. $.extend(Datepicker.prototype, {
  6859. /* Class name added to elements to indicate already configured with a date picker. */
  6860. markerClassName: "hasDatepicker",
  6861. //Keep track of the maximum number of rows displayed (see #7043)
  6862. maxRows: 4,
  6863. // TODO rename to "widget" when switching to widget factory
  6864. _widgetDatepicker: function() {
  6865. return this.dpDiv;
  6866. },
  6867. /* Override the default settings for all instances of the date picker.
  6868. * @param settings object - the new settings to use as defaults (anonymous object)
  6869. * @return the manager object
  6870. */
  6871. setDefaults: function(settings) {
  6872. datepicker_extendRemove(this._defaults, settings || {});
  6873. return this;
  6874. },
  6875. /* Attach the date picker to a jQuery selection.
  6876. * @param target element - the target input field or division or span
  6877. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6878. */
  6879. _attachDatepicker: function(target, settings) {
  6880. var nodeName, inline, inst;
  6881. nodeName = target.nodeName.toLowerCase();
  6882. inline = (nodeName === "div" || nodeName === "span");
  6883. if (!target.id) {
  6884. this.uuid += 1;
  6885. target.id = "dp" + this.uuid;
  6886. }
  6887. inst = this._newInst($(target), inline);
  6888. inst.settings = $.extend({}, settings || {});
  6889. if (nodeName === "input") {
  6890. this._connectDatepicker(target, inst);
  6891. } else if (inline) {
  6892. this._inlineDatepicker(target, inst);
  6893. }
  6894. },
  6895. /* Create a new instance object. */
  6896. _newInst: function(target, inline) {
  6897. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6898. return {id: id, input: target, // associated target
  6899. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6900. drawMonth: 0, drawYear: 0, // month being drawn
  6901. inline: inline, // is datepicker inline or not
  6902. dpDiv: (!inline ? this.dpDiv : // presentation div
  6903. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6904. },
  6905. /* Attach the date picker to an input field. */
  6906. _connectDatepicker: function(target, inst) {
  6907. var input = $(target);
  6908. inst.append = $([]);
  6909. inst.trigger = $([]);
  6910. if (input.hasClass(this.markerClassName)) {
  6911. return;
  6912. }
  6913. this._attachments(input, inst);
  6914. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6915. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6916. this._autoSize(inst);
  6917. $.data(target, "datepicker", inst);
  6918. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6919. if( inst.settings.disabled ) {
  6920. this._disableDatepicker( target );
  6921. }
  6922. },
  6923. /* Make attachments based on settings. */
  6924. _attachments: function(input, inst) {
  6925. var showOn, buttonText, buttonImage,
  6926. appendText = this._get(inst, "appendText"),
  6927. isRTL = this._get(inst, "isRTL");
  6928. if (inst.append) {
  6929. inst.append.remove();
  6930. }
  6931. if (appendText) {
  6932. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6933. input[isRTL ? "before" : "after"](inst.append);
  6934. }
  6935. input.unbind("focus", this._showDatepicker);
  6936. if (inst.trigger) {
  6937. inst.trigger.remove();
  6938. }
  6939. showOn = this._get(inst, "showOn");
  6940. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6941. input.focus(this._showDatepicker);
  6942. }
  6943. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6944. buttonText = this._get(inst, "buttonText");
  6945. buttonImage = this._get(inst, "buttonImage");
  6946. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6947. $("<img/>").addClass(this._triggerClass).
  6948. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6949. $("<button type='button'></button>").addClass(this._triggerClass).
  6950. html(!buttonImage ? buttonText : $("<img/>").attr(
  6951. { src:buttonImage, alt:buttonText, title:buttonText })));
  6952. input[isRTL ? "before" : "after"](inst.trigger);
  6953. inst.trigger.click(function() {
  6954. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6955. $.datepicker._hideDatepicker();
  6956. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6957. $.datepicker._hideDatepicker();
  6958. $.datepicker._showDatepicker(input[0]);
  6959. } else {
  6960. $.datepicker._showDatepicker(input[0]);
  6961. }
  6962. return false;
  6963. });
  6964. }
  6965. },
  6966. /* Apply the maximum length for the date format. */
  6967. _autoSize: function(inst) {
  6968. if (this._get(inst, "autoSize") && !inst.inline) {
  6969. var findMax, max, maxI, i,
  6970. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6971. dateFormat = this._get(inst, "dateFormat");
  6972. if (dateFormat.match(/[DM]/)) {
  6973. findMax = function(names) {
  6974. max = 0;
  6975. maxI = 0;
  6976. for (i = 0; i < names.length; i++) {
  6977. if (names[i].length > max) {
  6978. max = names[i].length;
  6979. maxI = i;
  6980. }
  6981. }
  6982. return maxI;
  6983. };
  6984. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6985. "monthNames" : "monthNamesShort"))));
  6986. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6987. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  6988. }
  6989. inst.input.attr("size", this._formatDate(inst, date).length);
  6990. }
  6991. },
  6992. /* Attach an inline date picker to a div. */
  6993. _inlineDatepicker: function(target, inst) {
  6994. var divSpan = $(target);
  6995. if (divSpan.hasClass(this.markerClassName)) {
  6996. return;
  6997. }
  6998. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  6999. $.data(target, "datepicker", inst);
  7000. this._setDate(inst, this._getDefaultDate(inst), true);
  7001. this._updateDatepicker(inst);
  7002. this._updateAlternate(inst);
  7003. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  7004. if( inst.settings.disabled ) {
  7005. this._disableDatepicker( target );
  7006. }
  7007. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  7008. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  7009. inst.dpDiv.css( "display", "block" );
  7010. },
  7011. /* Pop-up the date picker in a "dialog" box.
  7012. * @param input element - ignored
  7013. * @param date string or Date - the initial date to display
  7014. * @param onSelect function - the function to call when a date is selected
  7015. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  7016. * @param pos int[2] - coordinates for the dialog's position within the screen or
  7017. * event - with x/y coordinates or
  7018. * leave empty for default (screen centre)
  7019. * @return the manager object
  7020. */
  7021. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  7022. var id, browserWidth, browserHeight, scrollX, scrollY,
  7023. inst = this._dialogInst; // internal instance
  7024. if (!inst) {
  7025. this.uuid += 1;
  7026. id = "dp" + this.uuid;
  7027. this._dialogInput = $("<input type='text' id='" + id +
  7028. "' style='position: absolute; top: -100px; width: 0px;'/>");
  7029. this._dialogInput.keydown(this._doKeyDown);
  7030. $("body").append(this._dialogInput);
  7031. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  7032. inst.settings = {};
  7033. $.data(this._dialogInput[0], "datepicker", inst);
  7034. }
  7035. datepicker_extendRemove(inst.settings, settings || {});
  7036. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  7037. this._dialogInput.val(date);
  7038. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  7039. if (!this._pos) {
  7040. browserWidth = document.documentElement.clientWidth;
  7041. browserHeight = document.documentElement.clientHeight;
  7042. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  7043. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  7044. this._pos = // should use actual width/height below
  7045. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  7046. }
  7047. // move input on screen for focus, but hidden behind dialog
  7048. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  7049. inst.settings.onSelect = onSelect;
  7050. this._inDialog = true;
  7051. this.dpDiv.addClass(this._dialogClass);
  7052. this._showDatepicker(this._dialogInput[0]);
  7053. if ($.blockUI) {
  7054. $.blockUI(this.dpDiv);
  7055. }
  7056. $.data(this._dialogInput[0], "datepicker", inst);
  7057. return this;
  7058. },
  7059. /* Detach a datepicker from its control.
  7060. * @param target element - the target input field or division or span
  7061. */
  7062. _destroyDatepicker: function(target) {
  7063. var nodeName,
  7064. $target = $(target),
  7065. inst = $.data(target, "datepicker");
  7066. if (!$target.hasClass(this.markerClassName)) {
  7067. return;
  7068. }
  7069. nodeName = target.nodeName.toLowerCase();
  7070. $.removeData(target, "datepicker");
  7071. if (nodeName === "input") {
  7072. inst.append.remove();
  7073. inst.trigger.remove();
  7074. $target.removeClass(this.markerClassName).
  7075. unbind("focus", this._showDatepicker).
  7076. unbind("keydown", this._doKeyDown).
  7077. unbind("keypress", this._doKeyPress).
  7078. unbind("keyup", this._doKeyUp);
  7079. } else if (nodeName === "div" || nodeName === "span") {
  7080. $target.removeClass(this.markerClassName).empty();
  7081. }
  7082. if ( datepicker_instActive === inst ) {
  7083. datepicker_instActive = null;
  7084. }
  7085. },
  7086. /* Enable the date picker to a jQuery selection.
  7087. * @param target element - the target input field or division or span
  7088. */
  7089. _enableDatepicker: function(target) {
  7090. var nodeName, inline,
  7091. $target = $(target),
  7092. inst = $.data(target, "datepicker");
  7093. if (!$target.hasClass(this.markerClassName)) {
  7094. return;
  7095. }
  7096. nodeName = target.nodeName.toLowerCase();
  7097. if (nodeName === "input") {
  7098. target.disabled = false;
  7099. inst.trigger.filter("button").
  7100. each(function() { this.disabled = false; }).end().
  7101. filter("img").css({opacity: "1.0", cursor: ""});
  7102. } else if (nodeName === "div" || nodeName === "span") {
  7103. inline = $target.children("." + this._inlineClass);
  7104. inline.children().removeClass("ui-state-disabled");
  7105. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7106. prop("disabled", false);
  7107. }
  7108. this._disabledInputs = $.map(this._disabledInputs,
  7109. function(value) { return (value === target ? null : value); }); // delete entry
  7110. },
  7111. /* Disable the date picker to a jQuery selection.
  7112. * @param target element - the target input field or division or span
  7113. */
  7114. _disableDatepicker: function(target) {
  7115. var nodeName, inline,
  7116. $target = $(target),
  7117. inst = $.data(target, "datepicker");
  7118. if (!$target.hasClass(this.markerClassName)) {
  7119. return;
  7120. }
  7121. nodeName = target.nodeName.toLowerCase();
  7122. if (nodeName === "input") {
  7123. target.disabled = true;
  7124. inst.trigger.filter("button").
  7125. each(function() { this.disabled = true; }).end().
  7126. filter("img").css({opacity: "0.5", cursor: "default"});
  7127. } else if (nodeName === "div" || nodeName === "span") {
  7128. inline = $target.children("." + this._inlineClass);
  7129. inline.children().addClass("ui-state-disabled");
  7130. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7131. prop("disabled", true);
  7132. }
  7133. this._disabledInputs = $.map(this._disabledInputs,
  7134. function(value) { return (value === target ? null : value); }); // delete entry
  7135. this._disabledInputs[this._disabledInputs.length] = target;
  7136. },
  7137. /* Is the first field in a jQuery collection disabled as a datepicker?
  7138. * @param target element - the target input field or division or span
  7139. * @return boolean - true if disabled, false if enabled
  7140. */
  7141. _isDisabledDatepicker: function(target) {
  7142. if (!target) {
  7143. return false;
  7144. }
  7145. for (var i = 0; i < this._disabledInputs.length; i++) {
  7146. if (this._disabledInputs[i] === target) {
  7147. return true;
  7148. }
  7149. }
  7150. return false;
  7151. },
  7152. /* Retrieve the instance data for the target control.
  7153. * @param target element - the target input field or division or span
  7154. * @return object - the associated instance data
  7155. * @throws error if a jQuery problem getting data
  7156. */
  7157. _getInst: function(target) {
  7158. try {
  7159. return $.data(target, "datepicker");
  7160. }
  7161. catch (err) {
  7162. throw "Missing instance data for this datepicker";
  7163. }
  7164. },
  7165. /* Update or retrieve the settings for a date picker attached to an input field or division.
  7166. * @param target element - the target input field or division or span
  7167. * @param name object - the new settings to update or
  7168. * string - the name of the setting to change or retrieve,
  7169. * when retrieving also "all" for all instance settings or
  7170. * "defaults" for all global defaults
  7171. * @param value any - the new value for the setting
  7172. * (omit if above is an object or to retrieve a value)
  7173. */
  7174. _optionDatepicker: function(target, name, value) {
  7175. var settings, date, minDate, maxDate,
  7176. inst = this._getInst(target);
  7177. if (arguments.length === 2 && typeof name === "string") {
  7178. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  7179. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  7180. this._get(inst, name)) : null));
  7181. }
  7182. settings = name || {};
  7183. if (typeof name === "string") {
  7184. settings = {};
  7185. settings[name] = value;
  7186. }
  7187. if (inst) {
  7188. if (this._curInst === inst) {
  7189. this._hideDatepicker();
  7190. }
  7191. date = this._getDateDatepicker(target, true);
  7192. minDate = this._getMinMaxDate(inst, "min");
  7193. maxDate = this._getMinMaxDate(inst, "max");
  7194. datepicker_extendRemove(inst.settings, settings);
  7195. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  7196. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  7197. inst.settings.minDate = this._formatDate(inst, minDate);
  7198. }
  7199. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  7200. inst.settings.maxDate = this._formatDate(inst, maxDate);
  7201. }
  7202. if ( "disabled" in settings ) {
  7203. if ( settings.disabled ) {
  7204. this._disableDatepicker(target);
  7205. } else {
  7206. this._enableDatepicker(target);
  7207. }
  7208. }
  7209. this._attachments($(target), inst);
  7210. this._autoSize(inst);
  7211. this._setDate(inst, date);
  7212. this._updateAlternate(inst);
  7213. this._updateDatepicker(inst);
  7214. }
  7215. },
  7216. // change method deprecated
  7217. _changeDatepicker: function(target, name, value) {
  7218. this._optionDatepicker(target, name, value);
  7219. },
  7220. /* Redraw the date picker attached to an input field or division.
  7221. * @param target element - the target input field or division or span
  7222. */
  7223. _refreshDatepicker: function(target) {
  7224. var inst = this._getInst(target);
  7225. if (inst) {
  7226. this._updateDatepicker(inst);
  7227. }
  7228. },
  7229. /* Set the dates for a jQuery selection.
  7230. * @param target element - the target input field or division or span
  7231. * @param date Date - the new date
  7232. */
  7233. _setDateDatepicker: function(target, date) {
  7234. var inst = this._getInst(target);
  7235. if (inst) {
  7236. this._setDate(inst, date);
  7237. this._updateDatepicker(inst);
  7238. this._updateAlternate(inst);
  7239. }
  7240. },
  7241. /* Get the date(s) for the first entry in a jQuery selection.
  7242. * @param target element - the target input field or division or span
  7243. * @param noDefault boolean - true if no default date is to be used
  7244. * @return Date - the current date
  7245. */
  7246. _getDateDatepicker: function(target, noDefault) {
  7247. var inst = this._getInst(target);
  7248. if (inst && !inst.inline) {
  7249. this._setDateFromField(inst, noDefault);
  7250. }
  7251. return (inst ? this._getDate(inst) : null);
  7252. },
  7253. /* Handle keystrokes. */
  7254. _doKeyDown: function(event) {
  7255. var onSelect, dateStr, sel,
  7256. inst = $.datepicker._getInst(event.target),
  7257. handled = true,
  7258. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  7259. inst._keyEvent = true;
  7260. if ($.datepicker._datepickerShowing) {
  7261. switch (event.keyCode) {
  7262. case 9: $.datepicker._hideDatepicker();
  7263. handled = false;
  7264. break; // hide on tab out
  7265. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  7266. $.datepicker._currentClass + ")", inst.dpDiv);
  7267. if (sel[0]) {
  7268. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  7269. }
  7270. onSelect = $.datepicker._get(inst, "onSelect");
  7271. if (onSelect) {
  7272. dateStr = $.datepicker._formatDate(inst);
  7273. // trigger custom callback
  7274. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  7275. } else {
  7276. $.datepicker._hideDatepicker();
  7277. }
  7278. return false; // don't submit the form
  7279. case 27: $.datepicker._hideDatepicker();
  7280. break; // hide on escape
  7281. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7282. -$.datepicker._get(inst, "stepBigMonths") :
  7283. -$.datepicker._get(inst, "stepMonths")), "M");
  7284. break; // previous month/year on page up/+ ctrl
  7285. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7286. +$.datepicker._get(inst, "stepBigMonths") :
  7287. +$.datepicker._get(inst, "stepMonths")), "M");
  7288. break; // next month/year on page down/+ ctrl
  7289. case 35: if (event.ctrlKey || event.metaKey) {
  7290. $.datepicker._clearDate(event.target);
  7291. }
  7292. handled = event.ctrlKey || event.metaKey;
  7293. break; // clear on ctrl or command +end
  7294. case 36: if (event.ctrlKey || event.metaKey) {
  7295. $.datepicker._gotoToday(event.target);
  7296. }
  7297. handled = event.ctrlKey || event.metaKey;
  7298. break; // current on ctrl or command +home
  7299. case 37: if (event.ctrlKey || event.metaKey) {
  7300. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  7301. }
  7302. handled = event.ctrlKey || event.metaKey;
  7303. // -1 day on ctrl or command +left
  7304. if (event.originalEvent.altKey) {
  7305. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7306. -$.datepicker._get(inst, "stepBigMonths") :
  7307. -$.datepicker._get(inst, "stepMonths")), "M");
  7308. }
  7309. // next month/year on alt +left on Mac
  7310. break;
  7311. case 38: if (event.ctrlKey || event.metaKey) {
  7312. $.datepicker._adjustDate(event.target, -7, "D");
  7313. }
  7314. handled = event.ctrlKey || event.metaKey;
  7315. break; // -1 week on ctrl or command +up
  7316. case 39: if (event.ctrlKey || event.metaKey) {
  7317. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  7318. }
  7319. handled = event.ctrlKey || event.metaKey;
  7320. // +1 day on ctrl or command +right
  7321. if (event.originalEvent.altKey) {
  7322. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7323. +$.datepicker._get(inst, "stepBigMonths") :
  7324. +$.datepicker._get(inst, "stepMonths")), "M");
  7325. }
  7326. // next month/year on alt +right
  7327. break;
  7328. case 40: if (event.ctrlKey || event.metaKey) {
  7329. $.datepicker._adjustDate(event.target, +7, "D");
  7330. }
  7331. handled = event.ctrlKey || event.metaKey;
  7332. break; // +1 week on ctrl or command +down
  7333. default: handled = false;
  7334. }
  7335. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  7336. $.datepicker._showDatepicker(this);
  7337. } else {
  7338. handled = false;
  7339. }
  7340. if (handled) {
  7341. event.preventDefault();
  7342. event.stopPropagation();
  7343. }
  7344. },
  7345. /* Filter entered characters - based on date format. */
  7346. _doKeyPress: function(event) {
  7347. var chars, chr,
  7348. inst = $.datepicker._getInst(event.target);
  7349. if ($.datepicker._get(inst, "constrainInput")) {
  7350. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  7351. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  7352. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7353. }
  7354. },
  7355. /* Synchronise manual entry and field/alternate field. */
  7356. _doKeyUp: function(event) {
  7357. var date,
  7358. inst = $.datepicker._getInst(event.target);
  7359. if (inst.input.val() !== inst.lastVal) {
  7360. try {
  7361. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7362. (inst.input ? inst.input.val() : null),
  7363. $.datepicker._getFormatConfig(inst));
  7364. if (date) { // only if valid
  7365. $.datepicker._setDateFromField(inst);
  7366. $.datepicker._updateAlternate(inst);
  7367. $.datepicker._updateDatepicker(inst);
  7368. }
  7369. }
  7370. catch (err) {
  7371. }
  7372. }
  7373. return true;
  7374. },
  7375. /* Pop-up the date picker for a given input field.
  7376. * If false returned from beforeShow event handler do not show.
  7377. * @param input element - the input field attached to the date picker or
  7378. * event - if triggered by focus
  7379. */
  7380. _showDatepicker: function(input) {
  7381. input = input.target || input;
  7382. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7383. input = $("input", input.parentNode)[0];
  7384. }
  7385. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7386. return;
  7387. }
  7388. var inst, beforeShow, beforeShowSettings, isFixed,
  7389. offset, showAnim, duration;
  7390. inst = $.datepicker._getInst(input);
  7391. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7392. $.datepicker._curInst.dpDiv.stop(true, true);
  7393. if ( inst && $.datepicker._datepickerShowing ) {
  7394. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7395. }
  7396. }
  7397. beforeShow = $.datepicker._get(inst, "beforeShow");
  7398. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7399. if(beforeShowSettings === false){
  7400. return;
  7401. }
  7402. datepicker_extendRemove(inst.settings, beforeShowSettings);
  7403. inst.lastVal = null;
  7404. $.datepicker._lastInput = input;
  7405. $.datepicker._setDateFromField(inst);
  7406. if ($.datepicker._inDialog) { // hide cursor
  7407. input.value = "";
  7408. }
  7409. if (!$.datepicker._pos) { // position below input
  7410. $.datepicker._pos = $.datepicker._findPos(input);
  7411. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7412. }
  7413. isFixed = false;
  7414. $(input).parents().each(function() {
  7415. isFixed |= $(this).css("position") === "fixed";
  7416. return !isFixed;
  7417. });
  7418. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7419. $.datepicker._pos = null;
  7420. //to avoid flashes on Firefox
  7421. inst.dpDiv.empty();
  7422. // determine sizing offscreen
  7423. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7424. $.datepicker._updateDatepicker(inst);
  7425. // fix width for dynamic number of date pickers
  7426. // and adjust position before showing
  7427. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7428. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7429. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7430. left: offset.left + "px", top: offset.top + "px"});
  7431. if (!inst.inline) {
  7432. showAnim = $.datepicker._get(inst, "showAnim");
  7433. duration = $.datepicker._get(inst, "duration");
  7434. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  7435. $.datepicker._datepickerShowing = true;
  7436. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7437. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7438. } else {
  7439. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7440. }
  7441. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7442. inst.input.focus();
  7443. }
  7444. $.datepicker._curInst = inst;
  7445. }
  7446. },
  7447. /* Generate the date picker content. */
  7448. _updateDatepicker: function(inst) {
  7449. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7450. datepicker_instActive = inst; // for delegate hover events
  7451. inst.dpDiv.empty().append(this._generateHTML(inst));
  7452. this._attachHandlers(inst);
  7453. var origyearshtml,
  7454. numMonths = this._getNumberOfMonths(inst),
  7455. cols = numMonths[1],
  7456. width = 17,
  7457. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  7458. if ( activeCell.length > 0 ) {
  7459. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  7460. }
  7461. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7462. if (cols > 1) {
  7463. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7464. }
  7465. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7466. "Class"]("ui-datepicker-multi");
  7467. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7468. "Class"]("ui-datepicker-rtl");
  7469. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7470. inst.input.focus();
  7471. }
  7472. // deffered render of the years select (to avoid flashes on Firefox)
  7473. if( inst.yearshtml ){
  7474. origyearshtml = inst.yearshtml;
  7475. setTimeout(function(){
  7476. //assure that inst.yearshtml didn't change.
  7477. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7478. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7479. }
  7480. origyearshtml = inst.yearshtml = null;
  7481. }, 0);
  7482. }
  7483. },
  7484. // #6694 - don't focus the input if it's already focused
  7485. // this breaks the change event in IE
  7486. // Support: IE and jQuery <1.9
  7487. _shouldFocusInput: function( inst ) {
  7488. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7489. },
  7490. /* Check positioning to remain on screen. */
  7491. _checkOffset: function(inst, offset, isFixed) {
  7492. var dpWidth = inst.dpDiv.outerWidth(),
  7493. dpHeight = inst.dpDiv.outerHeight(),
  7494. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7495. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7496. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7497. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7498. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7499. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7500. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7501. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7502. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7503. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7504. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7505. Math.abs(dpHeight + inputHeight) : 0);
  7506. return offset;
  7507. },
  7508. /* Find an object's position on the screen. */
  7509. _findPos: function(obj) {
  7510. var position,
  7511. inst = this._getInst(obj),
  7512. isRTL = this._get(inst, "isRTL");
  7513. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7514. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7515. }
  7516. position = $(obj).offset();
  7517. return [position.left, position.top];
  7518. },
  7519. /* Hide the date picker from view.
  7520. * @param input element - the input field attached to the date picker
  7521. */
  7522. _hideDatepicker: function(input) {
  7523. var showAnim, duration, postProcess, onClose,
  7524. inst = this._curInst;
  7525. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  7526. return;
  7527. }
  7528. if (this._datepickerShowing) {
  7529. showAnim = this._get(inst, "showAnim");
  7530. duration = this._get(inst, "duration");
  7531. postProcess = function() {
  7532. $.datepicker._tidyDialog(inst);
  7533. };
  7534. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7535. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7536. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7537. } else {
  7538. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7539. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7540. }
  7541. if (!showAnim) {
  7542. postProcess();
  7543. }
  7544. this._datepickerShowing = false;
  7545. onClose = this._get(inst, "onClose");
  7546. if (onClose) {
  7547. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7548. }
  7549. this._lastInput = null;
  7550. if (this._inDialog) {
  7551. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7552. if ($.blockUI) {
  7553. $.unblockUI();
  7554. $("body").append(this.dpDiv);
  7555. }
  7556. }
  7557. this._inDialog = false;
  7558. }
  7559. },
  7560. /* Tidy up after a dialog display. */
  7561. _tidyDialog: function(inst) {
  7562. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7563. },
  7564. /* Close date picker if clicked elsewhere. */
  7565. _checkExternalClick: function(event) {
  7566. if (!$.datepicker._curInst) {
  7567. return;
  7568. }
  7569. var $target = $(event.target),
  7570. inst = $.datepicker._getInst($target[0]);
  7571. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7572. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7573. !$target.hasClass($.datepicker.markerClassName) &&
  7574. !$target.closest("." + $.datepicker._triggerClass).length &&
  7575. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7576. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7577. $.datepicker._hideDatepicker();
  7578. }
  7579. },
  7580. /* Adjust one of the date sub-fields. */
  7581. _adjustDate: function(id, offset, period) {
  7582. var target = $(id),
  7583. inst = this._getInst(target[0]);
  7584. if (this._isDisabledDatepicker(target[0])) {
  7585. return;
  7586. }
  7587. this._adjustInstDate(inst, offset +
  7588. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7589. period);
  7590. this._updateDatepicker(inst);
  7591. },
  7592. /* Action for current link. */
  7593. _gotoToday: function(id) {
  7594. var date,
  7595. target = $(id),
  7596. inst = this._getInst(target[0]);
  7597. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7598. inst.selectedDay = inst.currentDay;
  7599. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7600. inst.drawYear = inst.selectedYear = inst.currentYear;
  7601. } else {
  7602. date = new Date();
  7603. inst.selectedDay = date.getDate();
  7604. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7605. inst.drawYear = inst.selectedYear = date.getFullYear();
  7606. }
  7607. this._notifyChange(inst);
  7608. this._adjustDate(target);
  7609. },
  7610. /* Action for selecting a new month/year. */
  7611. _selectMonthYear: function(id, select, period) {
  7612. var target = $(id),
  7613. inst = this._getInst(target[0]);
  7614. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7615. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7616. parseInt(select.options[select.selectedIndex].value,10);
  7617. this._notifyChange(inst);
  7618. this._adjustDate(target);
  7619. },
  7620. /* Action for selecting a day. */
  7621. _selectDay: function(id, month, year, td) {
  7622. var inst,
  7623. target = $(id);
  7624. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7625. return;
  7626. }
  7627. inst = this._getInst(target[0]);
  7628. inst.selectedDay = inst.currentDay = $("a", td).html();
  7629. inst.selectedMonth = inst.currentMonth = month;
  7630. inst.selectedYear = inst.currentYear = year;
  7631. this._selectDate(id, this._formatDate(inst,
  7632. inst.currentDay, inst.currentMonth, inst.currentYear));
  7633. },
  7634. /* Erase the input field and hide the date picker. */
  7635. _clearDate: function(id) {
  7636. var target = $(id);
  7637. this._selectDate(target, "");
  7638. },
  7639. /* Update the input field with the selected date. */
  7640. _selectDate: function(id, dateStr) {
  7641. var onSelect,
  7642. target = $(id),
  7643. inst = this._getInst(target[0]);
  7644. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7645. if (inst.input) {
  7646. inst.input.val(dateStr);
  7647. }
  7648. this._updateAlternate(inst);
  7649. onSelect = this._get(inst, "onSelect");
  7650. if (onSelect) {
  7651. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7652. } else if (inst.input) {
  7653. inst.input.trigger("change"); // fire the change event
  7654. }
  7655. if (inst.inline){
  7656. this._updateDatepicker(inst);
  7657. } else {
  7658. this._hideDatepicker();
  7659. this._lastInput = inst.input[0];
  7660. if (typeof(inst.input[0]) !== "object") {
  7661. inst.input.focus(); // restore focus
  7662. }
  7663. this._lastInput = null;
  7664. }
  7665. },
  7666. /* Update any alternate field to synchronise with the main field. */
  7667. _updateAlternate: function(inst) {
  7668. var altFormat, date, dateStr,
  7669. altField = this._get(inst, "altField");
  7670. if (altField) { // update alternate field too
  7671. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7672. date = this._getDate(inst);
  7673. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7674. $(altField).each(function() { $(this).val(dateStr); });
  7675. }
  7676. },
  7677. /* Set as beforeShowDay function to prevent selection of weekends.
  7678. * @param date Date - the date to customise
  7679. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7680. */
  7681. noWeekends: function(date) {
  7682. var day = date.getDay();
  7683. return [(day > 0 && day < 6), ""];
  7684. },
  7685. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7686. * @param date Date - the date to get the week for
  7687. * @return number - the number of the week within the year that contains this date
  7688. */
  7689. iso8601Week: function(date) {
  7690. var time,
  7691. checkDate = new Date(date.getTime());
  7692. // Find Thursday of this week starting on Monday
  7693. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7694. time = checkDate.getTime();
  7695. checkDate.setMonth(0); // Compare with Jan 1
  7696. checkDate.setDate(1);
  7697. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7698. },
  7699. /* Parse a string value into a date object.
  7700. * See formatDate below for the possible formats.
  7701. *
  7702. * @param format string - the expected format of the date
  7703. * @param value string - the date in the above format
  7704. * @param settings Object - attributes include:
  7705. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7706. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7707. * dayNames string[7] - names of the days from Sunday (optional)
  7708. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7709. * monthNames string[12] - names of the months (optional)
  7710. * @return Date - the extracted date value or null if value is blank
  7711. */
  7712. parseDate: function (format, value, settings) {
  7713. if (format == null || value == null) {
  7714. throw "Invalid arguments";
  7715. }
  7716. value = (typeof value === "object" ? value.toString() : value + "");
  7717. if (value === "") {
  7718. return null;
  7719. }
  7720. var iFormat, dim, extra,
  7721. iValue = 0,
  7722. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7723. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7724. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7725. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7726. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7727. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7728. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7729. year = -1,
  7730. month = -1,
  7731. day = -1,
  7732. doy = -1,
  7733. literal = false,
  7734. date,
  7735. // Check whether a format character is doubled
  7736. lookAhead = function(match) {
  7737. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7738. if (matches) {
  7739. iFormat++;
  7740. }
  7741. return matches;
  7742. },
  7743. // Extract a number from the string value
  7744. getNumber = function(match) {
  7745. var isDoubled = lookAhead(match),
  7746. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7747. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7748. minSize = (match === "y" ? size : 1),
  7749. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  7750. num = value.substring(iValue).match(digits);
  7751. if (!num) {
  7752. throw "Missing number at position " + iValue;
  7753. }
  7754. iValue += num[0].length;
  7755. return parseInt(num[0], 10);
  7756. },
  7757. // Extract a name from the string value and convert to an index
  7758. getName = function(match, shortNames, longNames) {
  7759. var index = -1,
  7760. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7761. return [ [k, v] ];
  7762. }).sort(function (a, b) {
  7763. return -(a[1].length - b[1].length);
  7764. });
  7765. $.each(names, function (i, pair) {
  7766. var name = pair[1];
  7767. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7768. index = pair[0];
  7769. iValue += name.length;
  7770. return false;
  7771. }
  7772. });
  7773. if (index !== -1) {
  7774. return index + 1;
  7775. } else {
  7776. throw "Unknown name at position " + iValue;
  7777. }
  7778. },
  7779. // Confirm that a literal character matches the string value
  7780. checkLiteral = function() {
  7781. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7782. throw "Unexpected literal at position " + iValue;
  7783. }
  7784. iValue++;
  7785. };
  7786. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7787. if (literal) {
  7788. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7789. literal = false;
  7790. } else {
  7791. checkLiteral();
  7792. }
  7793. } else {
  7794. switch (format.charAt(iFormat)) {
  7795. case "d":
  7796. day = getNumber("d");
  7797. break;
  7798. case "D":
  7799. getName("D", dayNamesShort, dayNames);
  7800. break;
  7801. case "o":
  7802. doy = getNumber("o");
  7803. break;
  7804. case "m":
  7805. month = getNumber("m");
  7806. break;
  7807. case "M":
  7808. month = getName("M", monthNamesShort, monthNames);
  7809. break;
  7810. case "y":
  7811. year = getNumber("y");
  7812. break;
  7813. case "@":
  7814. date = new Date(getNumber("@"));
  7815. year = date.getFullYear();
  7816. month = date.getMonth() + 1;
  7817. day = date.getDate();
  7818. break;
  7819. case "!":
  7820. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7821. year = date.getFullYear();
  7822. month = date.getMonth() + 1;
  7823. day = date.getDate();
  7824. break;
  7825. case "'":
  7826. if (lookAhead("'")){
  7827. checkLiteral();
  7828. } else {
  7829. literal = true;
  7830. }
  7831. break;
  7832. default:
  7833. checkLiteral();
  7834. }
  7835. }
  7836. }
  7837. if (iValue < value.length){
  7838. extra = value.substr(iValue);
  7839. if (!/^\s+/.test(extra)) {
  7840. throw "Extra/unparsed characters found in date: " + extra;
  7841. }
  7842. }
  7843. if (year === -1) {
  7844. year = new Date().getFullYear();
  7845. } else if (year < 100) {
  7846. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7847. (year <= shortYearCutoff ? 0 : -100);
  7848. }
  7849. if (doy > -1) {
  7850. month = 1;
  7851. day = doy;
  7852. do {
  7853. dim = this._getDaysInMonth(year, month - 1);
  7854. if (day <= dim) {
  7855. break;
  7856. }
  7857. month++;
  7858. day -= dim;
  7859. } while (true);
  7860. }
  7861. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7862. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7863. throw "Invalid date"; // E.g. 31/02/00
  7864. }
  7865. return date;
  7866. },
  7867. /* Standard date formats. */
  7868. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7869. COOKIE: "D, dd M yy",
  7870. ISO_8601: "yy-mm-dd",
  7871. RFC_822: "D, d M y",
  7872. RFC_850: "DD, dd-M-y",
  7873. RFC_1036: "D, d M y",
  7874. RFC_1123: "D, d M yy",
  7875. RFC_2822: "D, d M yy",
  7876. RSS: "D, d M y", // RFC 822
  7877. TICKS: "!",
  7878. TIMESTAMP: "@",
  7879. W3C: "yy-mm-dd", // ISO 8601
  7880. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7881. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7882. /* Format a date object into a string value.
  7883. * The format can be combinations of the following:
  7884. * d - day of month (no leading zero)
  7885. * dd - day of month (two digit)
  7886. * o - day of year (no leading zeros)
  7887. * oo - day of year (three digit)
  7888. * D - day name short
  7889. * DD - day name long
  7890. * m - month of year (no leading zero)
  7891. * mm - month of year (two digit)
  7892. * M - month name short
  7893. * MM - month name long
  7894. * y - year (two digit)
  7895. * yy - year (four digit)
  7896. * @ - Unix timestamp (ms since 01/01/1970)
  7897. * ! - Windows ticks (100ns since 01/01/0001)
  7898. * "..." - literal text
  7899. * '' - single quote
  7900. *
  7901. * @param format string - the desired format of the date
  7902. * @param date Date - the date value to format
  7903. * @param settings Object - attributes include:
  7904. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7905. * dayNames string[7] - names of the days from Sunday (optional)
  7906. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7907. * monthNames string[12] - names of the months (optional)
  7908. * @return string - the date in the above format
  7909. */
  7910. formatDate: function (format, date, settings) {
  7911. if (!date) {
  7912. return "";
  7913. }
  7914. var iFormat,
  7915. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7916. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7917. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7918. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7919. // Check whether a format character is doubled
  7920. lookAhead = function(match) {
  7921. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7922. if (matches) {
  7923. iFormat++;
  7924. }
  7925. return matches;
  7926. },
  7927. // Format a number, with leading zero if necessary
  7928. formatNumber = function(match, value, len) {
  7929. var num = "" + value;
  7930. if (lookAhead(match)) {
  7931. while (num.length < len) {
  7932. num = "0" + num;
  7933. }
  7934. }
  7935. return num;
  7936. },
  7937. // Format a name, short or long as requested
  7938. formatName = function(match, value, shortNames, longNames) {
  7939. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7940. },
  7941. output = "",
  7942. literal = false;
  7943. if (date) {
  7944. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7945. if (literal) {
  7946. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7947. literal = false;
  7948. } else {
  7949. output += format.charAt(iFormat);
  7950. }
  7951. } else {
  7952. switch (format.charAt(iFormat)) {
  7953. case "d":
  7954. output += formatNumber("d", date.getDate(), 2);
  7955. break;
  7956. case "D":
  7957. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7958. break;
  7959. case "o":
  7960. output += formatNumber("o",
  7961. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7962. break;
  7963. case "m":
  7964. output += formatNumber("m", date.getMonth() + 1, 2);
  7965. break;
  7966. case "M":
  7967. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7968. break;
  7969. case "y":
  7970. output += (lookAhead("y") ? date.getFullYear() :
  7971. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7972. break;
  7973. case "@":
  7974. output += date.getTime();
  7975. break;
  7976. case "!":
  7977. output += date.getTime() * 10000 + this._ticksTo1970;
  7978. break;
  7979. case "'":
  7980. if (lookAhead("'")) {
  7981. output += "'";
  7982. } else {
  7983. literal = true;
  7984. }
  7985. break;
  7986. default:
  7987. output += format.charAt(iFormat);
  7988. }
  7989. }
  7990. }
  7991. }
  7992. return output;
  7993. },
  7994. /* Extract all possible characters from the date format. */
  7995. _possibleChars: function (format) {
  7996. var iFormat,
  7997. chars = "",
  7998. literal = false,
  7999. // Check whether a format character is doubled
  8000. lookAhead = function(match) {
  8001. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  8002. if (matches) {
  8003. iFormat++;
  8004. }
  8005. return matches;
  8006. };
  8007. for (iFormat = 0; iFormat < format.length; iFormat++) {
  8008. if (literal) {
  8009. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  8010. literal = false;
  8011. } else {
  8012. chars += format.charAt(iFormat);
  8013. }
  8014. } else {
  8015. switch (format.charAt(iFormat)) {
  8016. case "d": case "m": case "y": case "@":
  8017. chars += "0123456789";
  8018. break;
  8019. case "D": case "M":
  8020. return null; // Accept anything
  8021. case "'":
  8022. if (lookAhead("'")) {
  8023. chars += "'";
  8024. } else {
  8025. literal = true;
  8026. }
  8027. break;
  8028. default:
  8029. chars += format.charAt(iFormat);
  8030. }
  8031. }
  8032. }
  8033. return chars;
  8034. },
  8035. /* Get a setting value, defaulting if necessary. */
  8036. _get: function(inst, name) {
  8037. return inst.settings[name] !== undefined ?
  8038. inst.settings[name] : this._defaults[name];
  8039. },
  8040. /* Parse existing date and initialise date picker. */
  8041. _setDateFromField: function(inst, noDefault) {
  8042. if (inst.input.val() === inst.lastVal) {
  8043. return;
  8044. }
  8045. var dateFormat = this._get(inst, "dateFormat"),
  8046. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  8047. defaultDate = this._getDefaultDate(inst),
  8048. date = defaultDate,
  8049. settings = this._getFormatConfig(inst);
  8050. try {
  8051. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  8052. } catch (event) {
  8053. dates = (noDefault ? "" : dates);
  8054. }
  8055. inst.selectedDay = date.getDate();
  8056. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8057. inst.drawYear = inst.selectedYear = date.getFullYear();
  8058. inst.currentDay = (dates ? date.getDate() : 0);
  8059. inst.currentMonth = (dates ? date.getMonth() : 0);
  8060. inst.currentYear = (dates ? date.getFullYear() : 0);
  8061. this._adjustInstDate(inst);
  8062. },
  8063. /* Retrieve the default date shown on opening. */
  8064. _getDefaultDate: function(inst) {
  8065. return this._restrictMinMax(inst,
  8066. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  8067. },
  8068. /* A date may be specified as an exact value or a relative one. */
  8069. _determineDate: function(inst, date, defaultDate) {
  8070. var offsetNumeric = function(offset) {
  8071. var date = new Date();
  8072. date.setDate(date.getDate() + offset);
  8073. return date;
  8074. },
  8075. offsetString = function(offset) {
  8076. try {
  8077. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  8078. offset, $.datepicker._getFormatConfig(inst));
  8079. }
  8080. catch (e) {
  8081. // Ignore
  8082. }
  8083. var date = (offset.toLowerCase().match(/^c/) ?
  8084. $.datepicker._getDate(inst) : null) || new Date(),
  8085. year = date.getFullYear(),
  8086. month = date.getMonth(),
  8087. day = date.getDate(),
  8088. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  8089. matches = pattern.exec(offset);
  8090. while (matches) {
  8091. switch (matches[2] || "d") {
  8092. case "d" : case "D" :
  8093. day += parseInt(matches[1],10); break;
  8094. case "w" : case "W" :
  8095. day += parseInt(matches[1],10) * 7; break;
  8096. case "m" : case "M" :
  8097. month += parseInt(matches[1],10);
  8098. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8099. break;
  8100. case "y": case "Y" :
  8101. year += parseInt(matches[1],10);
  8102. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8103. break;
  8104. }
  8105. matches = pattern.exec(offset);
  8106. }
  8107. return new Date(year, month, day);
  8108. },
  8109. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  8110. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  8111. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  8112. if (newDate) {
  8113. newDate.setHours(0);
  8114. newDate.setMinutes(0);
  8115. newDate.setSeconds(0);
  8116. newDate.setMilliseconds(0);
  8117. }
  8118. return this._daylightSavingAdjust(newDate);
  8119. },
  8120. /* Handle switch to/from daylight saving.
  8121. * Hours may be non-zero on daylight saving cut-over:
  8122. * > 12 when midnight changeover, but then cannot generate
  8123. * midnight datetime, so jump to 1AM, otherwise reset.
  8124. * @param date (Date) the date to check
  8125. * @return (Date) the corrected date
  8126. */
  8127. _daylightSavingAdjust: function(date) {
  8128. if (!date) {
  8129. return null;
  8130. }
  8131. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  8132. return date;
  8133. },
  8134. /* Set the date(s) directly. */
  8135. _setDate: function(inst, date, noChange) {
  8136. var clear = !date,
  8137. origMonth = inst.selectedMonth,
  8138. origYear = inst.selectedYear,
  8139. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  8140. inst.selectedDay = inst.currentDay = newDate.getDate();
  8141. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  8142. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  8143. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  8144. this._notifyChange(inst);
  8145. }
  8146. this._adjustInstDate(inst);
  8147. if (inst.input) {
  8148. inst.input.val(clear ? "" : this._formatDate(inst));
  8149. }
  8150. },
  8151. /* Retrieve the date(s) directly. */
  8152. _getDate: function(inst) {
  8153. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  8154. this._daylightSavingAdjust(new Date(
  8155. inst.currentYear, inst.currentMonth, inst.currentDay)));
  8156. return startDate;
  8157. },
  8158. /* Attach the onxxx handlers. These are declared statically so
  8159. * they work with static code transformers like Caja.
  8160. */
  8161. _attachHandlers: function(inst) {
  8162. var stepMonths = this._get(inst, "stepMonths"),
  8163. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  8164. inst.dpDiv.find("[data-handler]").map(function () {
  8165. var handler = {
  8166. prev: function () {
  8167. $.datepicker._adjustDate(id, -stepMonths, "M");
  8168. },
  8169. next: function () {
  8170. $.datepicker._adjustDate(id, +stepMonths, "M");
  8171. },
  8172. hide: function () {
  8173. $.datepicker._hideDatepicker();
  8174. },
  8175. today: function () {
  8176. $.datepicker._gotoToday(id);
  8177. },
  8178. selectDay: function () {
  8179. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  8180. return false;
  8181. },
  8182. selectMonth: function () {
  8183. $.datepicker._selectMonthYear(id, this, "M");
  8184. return false;
  8185. },
  8186. selectYear: function () {
  8187. $.datepicker._selectMonthYear(id, this, "Y");
  8188. return false;
  8189. }
  8190. };
  8191. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  8192. });
  8193. },
  8194. /* Generate the HTML for the current state of the date picker. */
  8195. _generateHTML: function(inst) {
  8196. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  8197. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  8198. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  8199. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  8200. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  8201. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  8202. tempDate = new Date(),
  8203. today = this._daylightSavingAdjust(
  8204. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  8205. isRTL = this._get(inst, "isRTL"),
  8206. showButtonPanel = this._get(inst, "showButtonPanel"),
  8207. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  8208. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  8209. numMonths = this._getNumberOfMonths(inst),
  8210. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  8211. stepMonths = this._get(inst, "stepMonths"),
  8212. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  8213. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  8214. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  8215. minDate = this._getMinMaxDate(inst, "min"),
  8216. maxDate = this._getMinMaxDate(inst, "max"),
  8217. drawMonth = inst.drawMonth - showCurrentAtPos,
  8218. drawYear = inst.drawYear;
  8219. if (drawMonth < 0) {
  8220. drawMonth += 12;
  8221. drawYear--;
  8222. }
  8223. if (maxDate) {
  8224. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  8225. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  8226. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  8227. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  8228. drawMonth--;
  8229. if (drawMonth < 0) {
  8230. drawMonth = 11;
  8231. drawYear--;
  8232. }
  8233. }
  8234. }
  8235. inst.drawMonth = drawMonth;
  8236. inst.drawYear = drawYear;
  8237. prevText = this._get(inst, "prevText");
  8238. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  8239. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  8240. this._getFormatConfig(inst)));
  8241. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  8242. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  8243. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  8244. (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>"));
  8245. nextText = this._get(inst, "nextText");
  8246. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  8247. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  8248. this._getFormatConfig(inst)));
  8249. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  8250. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  8251. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  8252. (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>"));
  8253. currentText = this._get(inst, "currentText");
  8254. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  8255. currentText = (!navigationAsDateFormat ? currentText :
  8256. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  8257. 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'>" +
  8258. this._get(inst, "closeText") + "</button>" : "");
  8259. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  8260. (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'" +
  8261. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  8262. firstDay = parseInt(this._get(inst, "firstDay"),10);
  8263. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  8264. showWeek = this._get(inst, "showWeek");
  8265. dayNames = this._get(inst, "dayNames");
  8266. dayNamesMin = this._get(inst, "dayNamesMin");
  8267. monthNames = this._get(inst, "monthNames");
  8268. monthNamesShort = this._get(inst, "monthNamesShort");
  8269. beforeShowDay = this._get(inst, "beforeShowDay");
  8270. showOtherMonths = this._get(inst, "showOtherMonths");
  8271. selectOtherMonths = this._get(inst, "selectOtherMonths");
  8272. defaultDate = this._getDefaultDate(inst);
  8273. html = "";
  8274. dow;
  8275. for (row = 0; row < numMonths[0]; row++) {
  8276. group = "";
  8277. this.maxRows = 4;
  8278. for (col = 0; col < numMonths[1]; col++) {
  8279. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  8280. cornerClass = " ui-corner-all";
  8281. calender = "";
  8282. if (isMultiMonth) {
  8283. calender += "<div class='ui-datepicker-group";
  8284. if (numMonths[1] > 1) {
  8285. switch (col) {
  8286. case 0: calender += " ui-datepicker-group-first";
  8287. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  8288. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  8289. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  8290. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  8291. }
  8292. }
  8293. calender += "'>";
  8294. }
  8295. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  8296. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  8297. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  8298. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  8299. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  8300. "</div><table class='ui-datepicker-calendar'><thead>" +
  8301. "<tr>";
  8302. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  8303. for (dow = 0; dow < 7; dow++) { // days of the week
  8304. day = (dow + firstDay) % 7;
  8305. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  8306. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  8307. }
  8308. calender += thead + "</tr></thead><tbody>";
  8309. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  8310. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  8311. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  8312. }
  8313. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  8314. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  8315. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  8316. this.maxRows = numRows;
  8317. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  8318. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  8319. calender += "<tr>";
  8320. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  8321. this._get(inst, "calculateWeek")(printDate) + "</td>");
  8322. for (dow = 0; dow < 7; dow++) { // create date picker days
  8323. daySettings = (beforeShowDay ?
  8324. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  8325. otherMonth = (printDate.getMonth() !== drawMonth);
  8326. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  8327. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  8328. tbody += "<td class='" +
  8329. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  8330. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  8331. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  8332. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  8333. // or defaultDate is current printedDate and defaultDate is selectedDate
  8334. " " + this._dayOverClass : "") + // highlight selected day
  8335. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  8336. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  8337. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  8338. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  8339. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  8340. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  8341. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  8342. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  8343. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  8344. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  8345. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  8346. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  8347. printDate.setDate(printDate.getDate() + 1);
  8348. printDate = this._daylightSavingAdjust(printDate);
  8349. }
  8350. calender += tbody + "</tr>";
  8351. }
  8352. drawMonth++;
  8353. if (drawMonth > 11) {
  8354. drawMonth = 0;
  8355. drawYear++;
  8356. }
  8357. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8358. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8359. group += calender;
  8360. }
  8361. html += group;
  8362. }
  8363. html += buttonPanel;
  8364. inst._keyEvent = false;
  8365. return html;
  8366. },
  8367. /* Generate the month and year header. */
  8368. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8369. secondary, monthNames, monthNamesShort) {
  8370. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8371. changeMonth = this._get(inst, "changeMonth"),
  8372. changeYear = this._get(inst, "changeYear"),
  8373. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8374. html = "<div class='ui-datepicker-title'>",
  8375. monthHtml = "";
  8376. // month selection
  8377. if (secondary || !changeMonth) {
  8378. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8379. } else {
  8380. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8381. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8382. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8383. for ( month = 0; month < 12; month++) {
  8384. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8385. monthHtml += "<option value='" + month + "'" +
  8386. (month === drawMonth ? " selected='selected'" : "") +
  8387. ">" + monthNamesShort[month] + "</option>";
  8388. }
  8389. }
  8390. monthHtml += "</select>";
  8391. }
  8392. if (!showMonthAfterYear) {
  8393. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8394. }
  8395. // year selection
  8396. if ( !inst.yearshtml ) {
  8397. inst.yearshtml = "";
  8398. if (secondary || !changeYear) {
  8399. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8400. } else {
  8401. // determine range of years to display
  8402. years = this._get(inst, "yearRange").split(":");
  8403. thisYear = new Date().getFullYear();
  8404. determineYear = function(value) {
  8405. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8406. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8407. parseInt(value, 10)));
  8408. return (isNaN(year) ? thisYear : year);
  8409. };
  8410. year = determineYear(years[0]);
  8411. endYear = Math.max(year, determineYear(years[1] || ""));
  8412. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8413. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8414. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8415. for (; year <= endYear; year++) {
  8416. inst.yearshtml += "<option value='" + year + "'" +
  8417. (year === drawYear ? " selected='selected'" : "") +
  8418. ">" + year + "</option>";
  8419. }
  8420. inst.yearshtml += "</select>";
  8421. html += inst.yearshtml;
  8422. inst.yearshtml = null;
  8423. }
  8424. }
  8425. html += this._get(inst, "yearSuffix");
  8426. if (showMonthAfterYear) {
  8427. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8428. }
  8429. html += "</div>"; // Close datepicker_header
  8430. return html;
  8431. },
  8432. /* Adjust one of the date sub-fields. */
  8433. _adjustInstDate: function(inst, offset, period) {
  8434. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8435. month = inst.drawMonth + (period === "M" ? offset : 0),
  8436. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8437. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8438. inst.selectedDay = date.getDate();
  8439. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8440. inst.drawYear = inst.selectedYear = date.getFullYear();
  8441. if (period === "M" || period === "Y") {
  8442. this._notifyChange(inst);
  8443. }
  8444. },
  8445. /* Ensure a date is within any min/max bounds. */
  8446. _restrictMinMax: function(inst, date) {
  8447. var minDate = this._getMinMaxDate(inst, "min"),
  8448. maxDate = this._getMinMaxDate(inst, "max"),
  8449. newDate = (minDate && date < minDate ? minDate : date);
  8450. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8451. },
  8452. /* Notify change of month/year. */
  8453. _notifyChange: function(inst) {
  8454. var onChange = this._get(inst, "onChangeMonthYear");
  8455. if (onChange) {
  8456. onChange.apply((inst.input ? inst.input[0] : null),
  8457. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8458. }
  8459. },
  8460. /* Determine the number of months to show. */
  8461. _getNumberOfMonths: function(inst) {
  8462. var numMonths = this._get(inst, "numberOfMonths");
  8463. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8464. },
  8465. /* Determine the current maximum date - ensure no time components are set. */
  8466. _getMinMaxDate: function(inst, minMax) {
  8467. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8468. },
  8469. /* Find the number of days in a given month. */
  8470. _getDaysInMonth: function(year, month) {
  8471. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8472. },
  8473. /* Find the day of the week of the first of a month. */
  8474. _getFirstDayOfMonth: function(year, month) {
  8475. return new Date(year, month, 1).getDay();
  8476. },
  8477. /* Determines if we should allow a "next/prev" month display change. */
  8478. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8479. var numMonths = this._getNumberOfMonths(inst),
  8480. date = this._daylightSavingAdjust(new Date(curYear,
  8481. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8482. if (offset < 0) {
  8483. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8484. }
  8485. return this._isInRange(inst, date);
  8486. },
  8487. /* Is the given date in the accepted range? */
  8488. _isInRange: function(inst, date) {
  8489. var yearSplit, currentYear,
  8490. minDate = this._getMinMaxDate(inst, "min"),
  8491. maxDate = this._getMinMaxDate(inst, "max"),
  8492. minYear = null,
  8493. maxYear = null,
  8494. years = this._get(inst, "yearRange");
  8495. if (years){
  8496. yearSplit = years.split(":");
  8497. currentYear = new Date().getFullYear();
  8498. minYear = parseInt(yearSplit[0], 10);
  8499. maxYear = parseInt(yearSplit[1], 10);
  8500. if ( yearSplit[0].match(/[+\-].*/) ) {
  8501. minYear += currentYear;
  8502. }
  8503. if ( yearSplit[1].match(/[+\-].*/) ) {
  8504. maxYear += currentYear;
  8505. }
  8506. }
  8507. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8508. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8509. (!minYear || date.getFullYear() >= minYear) &&
  8510. (!maxYear || date.getFullYear() <= maxYear));
  8511. },
  8512. /* Provide the configuration settings for formatting/parsing. */
  8513. _getFormatConfig: function(inst) {
  8514. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8515. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8516. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8517. return {shortYearCutoff: shortYearCutoff,
  8518. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8519. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8520. },
  8521. /* Format the given date for display. */
  8522. _formatDate: function(inst, day, month, year) {
  8523. if (!day) {
  8524. inst.currentDay = inst.selectedDay;
  8525. inst.currentMonth = inst.selectedMonth;
  8526. inst.currentYear = inst.selectedYear;
  8527. }
  8528. var date = (day ? (typeof day === "object" ? day :
  8529. this._daylightSavingAdjust(new Date(year, month, day))) :
  8530. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8531. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8532. }
  8533. });
  8534. /*
  8535. * Bind hover events for datepicker elements.
  8536. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8537. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8538. */
  8539. function datepicker_bindHover(dpDiv) {
  8540. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8541. return dpDiv.delegate(selector, "mouseout", function() {
  8542. $(this).removeClass("ui-state-hover");
  8543. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8544. $(this).removeClass("ui-datepicker-prev-hover");
  8545. }
  8546. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8547. $(this).removeClass("ui-datepicker-next-hover");
  8548. }
  8549. })
  8550. .delegate( selector, "mouseover", datepicker_handleMouseover );
  8551. }
  8552. function datepicker_handleMouseover() {
  8553. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  8554. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8555. $(this).addClass("ui-state-hover");
  8556. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8557. $(this).addClass("ui-datepicker-prev-hover");
  8558. }
  8559. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8560. $(this).addClass("ui-datepicker-next-hover");
  8561. }
  8562. }
  8563. }
  8564. /* jQuery extend now ignores nulls! */
  8565. function datepicker_extendRemove(target, props) {
  8566. $.extend(target, props);
  8567. for (var name in props) {
  8568. if (props[name] == null) {
  8569. target[name] = props[name];
  8570. }
  8571. }
  8572. return target;
  8573. }
  8574. /* Invoke the datepicker functionality.
  8575. @param options string - a command, optionally followed by additional parameters or
  8576. Object - settings for attaching new datepicker functionality
  8577. @return jQuery object */
  8578. $.fn.datepicker = function(options){
  8579. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8580. if ( !this.length ) {
  8581. return this;
  8582. }
  8583. /* Initialise the date picker. */
  8584. if (!$.datepicker.initialized) {
  8585. $(document).mousedown($.datepicker._checkExternalClick);
  8586. $.datepicker.initialized = true;
  8587. }
  8588. /* Append datepicker main container to body if not exist. */
  8589. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8590. $("body").append($.datepicker.dpDiv);
  8591. }
  8592. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8593. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8594. return $.datepicker["_" + options + "Datepicker"].
  8595. apply($.datepicker, [this[0]].concat(otherArgs));
  8596. }
  8597. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8598. return $.datepicker["_" + options + "Datepicker"].
  8599. apply($.datepicker, [this[0]].concat(otherArgs));
  8600. }
  8601. return this.each(function() {
  8602. typeof options === "string" ?
  8603. $.datepicker["_" + options + "Datepicker"].
  8604. apply($.datepicker, [this].concat(otherArgs)) :
  8605. $.datepicker._attachDatepicker(this, options);
  8606. });
  8607. };
  8608. $.datepicker = new Datepicker(); // singleton instance
  8609. $.datepicker.initialized = false;
  8610. $.datepicker.uuid = new Date().getTime();
  8611. $.datepicker.version = "1.11.4";
  8612. var datepicker = $.datepicker;
  8613. /*!
  8614. * jQuery UI Dialog 1.11.4
  8615. * http://jqueryui.com
  8616. *
  8617. * Copyright jQuery Foundation and other contributors
  8618. * Released under the MIT license.
  8619. * http://jquery.org/license
  8620. *
  8621. * http://api.jqueryui.com/dialog/
  8622. */
  8623. var dialog = $.widget( "ui.dialog", {
  8624. version: "1.11.4",
  8625. options: {
  8626. appendTo: "body",
  8627. autoOpen: true,
  8628. buttons: [],
  8629. closeOnEscape: true,
  8630. closeText: "Close",
  8631. dialogClass: "",
  8632. draggable: true,
  8633. hide: null,
  8634. height: "auto",
  8635. maxHeight: null,
  8636. maxWidth: null,
  8637. minHeight: 150,
  8638. minWidth: 150,
  8639. modal: false,
  8640. position: {
  8641. my: "center",
  8642. at: "center",
  8643. of: window,
  8644. collision: "fit",
  8645. // Ensure the titlebar is always visible
  8646. using: function( pos ) {
  8647. var topOffset = $( this ).css( pos ).offset().top;
  8648. if ( topOffset < 0 ) {
  8649. $( this ).css( "top", pos.top - topOffset );
  8650. }
  8651. }
  8652. },
  8653. resizable: true,
  8654. show: null,
  8655. title: null,
  8656. width: 300,
  8657. // callbacks
  8658. beforeClose: null,
  8659. close: null,
  8660. drag: null,
  8661. dragStart: null,
  8662. dragStop: null,
  8663. focus: null,
  8664. open: null,
  8665. resize: null,
  8666. resizeStart: null,
  8667. resizeStop: null
  8668. },
  8669. sizeRelatedOptions: {
  8670. buttons: true,
  8671. height: true,
  8672. maxHeight: true,
  8673. maxWidth: true,
  8674. minHeight: true,
  8675. minWidth: true,
  8676. width: true
  8677. },
  8678. resizableRelatedOptions: {
  8679. maxHeight: true,
  8680. maxWidth: true,
  8681. minHeight: true,
  8682. minWidth: true
  8683. },
  8684. _create: function() {
  8685. this.originalCss = {
  8686. display: this.element[ 0 ].style.display,
  8687. width: this.element[ 0 ].style.width,
  8688. minHeight: this.element[ 0 ].style.minHeight,
  8689. maxHeight: this.element[ 0 ].style.maxHeight,
  8690. height: this.element[ 0 ].style.height
  8691. };
  8692. this.originalPosition = {
  8693. parent: this.element.parent(),
  8694. index: this.element.parent().children().index( this.element )
  8695. };
  8696. this.originalTitle = this.element.attr( "title" );
  8697. this.options.title = this.options.title || this.originalTitle;
  8698. this._createWrapper();
  8699. this.element
  8700. .show()
  8701. .removeAttr( "title" )
  8702. .addClass( "ui-dialog-content ui-widget-content" )
  8703. .appendTo( this.uiDialog );
  8704. this._createTitlebar();
  8705. this._createButtonPane();
  8706. if ( this.options.draggable && $.fn.draggable ) {
  8707. this._makeDraggable();
  8708. }
  8709. if ( this.options.resizable && $.fn.resizable ) {
  8710. this._makeResizable();
  8711. }
  8712. this._isOpen = false;
  8713. this._trackFocus();
  8714. },
  8715. _init: function() {
  8716. if ( this.options.autoOpen ) {
  8717. this.open();
  8718. }
  8719. },
  8720. _appendTo: function() {
  8721. var element = this.options.appendTo;
  8722. if ( element && (element.jquery || element.nodeType) ) {
  8723. return $( element );
  8724. }
  8725. return this.document.find( element || "body" ).eq( 0 );
  8726. },
  8727. _destroy: function() {
  8728. var next,
  8729. originalPosition = this.originalPosition;
  8730. this._untrackInstance();
  8731. this._destroyOverlay();
  8732. this.element
  8733. .removeUniqueId()
  8734. .removeClass( "ui-dialog-content ui-widget-content" )
  8735. .css( this.originalCss )
  8736. // Without detaching first, the following becomes really slow
  8737. .detach();
  8738. this.uiDialog.stop( true, true ).remove();
  8739. if ( this.originalTitle ) {
  8740. this.element.attr( "title", this.originalTitle );
  8741. }
  8742. next = originalPosition.parent.children().eq( originalPosition.index );
  8743. // Don't try to place the dialog next to itself (#8613)
  8744. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  8745. next.before( this.element );
  8746. } else {
  8747. originalPosition.parent.append( this.element );
  8748. }
  8749. },
  8750. widget: function() {
  8751. return this.uiDialog;
  8752. },
  8753. disable: $.noop,
  8754. enable: $.noop,
  8755. close: function( event ) {
  8756. var activeElement,
  8757. that = this;
  8758. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8759. return;
  8760. }
  8761. this._isOpen = false;
  8762. this._focusedElement = null;
  8763. this._destroyOverlay();
  8764. this._untrackInstance();
  8765. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  8766. // support: IE9
  8767. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  8768. try {
  8769. activeElement = this.document[ 0 ].activeElement;
  8770. // Support: IE9, IE10
  8771. // If the <body> is blurred, IE will switch windows, see #4520
  8772. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  8773. // Hiding a focused element doesn't trigger blur in WebKit
  8774. // so in case we have nothing to focus on, explicitly blur the active element
  8775. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8776. $( activeElement ).blur();
  8777. }
  8778. } catch ( error ) {}
  8779. }
  8780. this._hide( this.uiDialog, this.options.hide, function() {
  8781. that._trigger( "close", event );
  8782. });
  8783. },
  8784. isOpen: function() {
  8785. return this._isOpen;
  8786. },
  8787. moveToTop: function() {
  8788. this._moveToTop();
  8789. },
  8790. _moveToTop: function( event, silent ) {
  8791. var moved = false,
  8792. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  8793. return +$( this ).css( "z-index" );
  8794. }).get(),
  8795. zIndexMax = Math.max.apply( null, zIndices );
  8796. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  8797. this.uiDialog.css( "z-index", zIndexMax + 1 );
  8798. moved = true;
  8799. }
  8800. if ( moved && !silent ) {
  8801. this._trigger( "focus", event );
  8802. }
  8803. return moved;
  8804. },
  8805. open: function() {
  8806. var that = this;
  8807. if ( this._isOpen ) {
  8808. if ( this._moveToTop() ) {
  8809. this._focusTabbable();
  8810. }
  8811. return;
  8812. }
  8813. this._isOpen = true;
  8814. this.opener = $( this.document[ 0 ].activeElement );
  8815. this._size();
  8816. this._position();
  8817. this._createOverlay();
  8818. this._moveToTop( null, true );
  8819. // Ensure the overlay is moved to the top with the dialog, but only when
  8820. // opening. The overlay shouldn't move after the dialog is open so that
  8821. // modeless dialogs opened after the modal dialog stack properly.
  8822. if ( this.overlay ) {
  8823. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  8824. }
  8825. this._show( this.uiDialog, this.options.show, function() {
  8826. that._focusTabbable();
  8827. that._trigger( "focus" );
  8828. });
  8829. // Track the dialog immediately upon openening in case a focus event
  8830. // somehow occurs outside of the dialog before an element inside the
  8831. // dialog is focused (#10152)
  8832. this._makeFocusTarget();
  8833. this._trigger( "open" );
  8834. },
  8835. _focusTabbable: function() {
  8836. // Set focus to the first match:
  8837. // 1. An element that was focused previously
  8838. // 2. First element inside the dialog matching [autofocus]
  8839. // 3. Tabbable element inside the content element
  8840. // 4. Tabbable element inside the buttonpane
  8841. // 5. The close button
  8842. // 6. The dialog itself
  8843. var hasFocus = this._focusedElement;
  8844. if ( !hasFocus ) {
  8845. hasFocus = this.element.find( "[autofocus]" );
  8846. }
  8847. if ( !hasFocus.length ) {
  8848. hasFocus = this.element.find( ":tabbable" );
  8849. }
  8850. if ( !hasFocus.length ) {
  8851. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  8852. }
  8853. if ( !hasFocus.length ) {
  8854. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  8855. }
  8856. if ( !hasFocus.length ) {
  8857. hasFocus = this.uiDialog;
  8858. }
  8859. hasFocus.eq( 0 ).focus();
  8860. },
  8861. _keepFocus: function( event ) {
  8862. function checkFocus() {
  8863. var activeElement = this.document[0].activeElement,
  8864. isActive = this.uiDialog[0] === activeElement ||
  8865. $.contains( this.uiDialog[0], activeElement );
  8866. if ( !isActive ) {
  8867. this._focusTabbable();
  8868. }
  8869. }
  8870. event.preventDefault();
  8871. checkFocus.call( this );
  8872. // support: IE
  8873. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8874. // so we check again later
  8875. this._delay( checkFocus );
  8876. },
  8877. _createWrapper: function() {
  8878. this.uiDialog = $("<div>")
  8879. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8880. this.options.dialogClass )
  8881. .hide()
  8882. .attr({
  8883. // Setting tabIndex makes the div focusable
  8884. tabIndex: -1,
  8885. role: "dialog"
  8886. })
  8887. .appendTo( this._appendTo() );
  8888. this._on( this.uiDialog, {
  8889. keydown: function( event ) {
  8890. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8891. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8892. event.preventDefault();
  8893. this.close( event );
  8894. return;
  8895. }
  8896. // prevent tabbing out of dialogs
  8897. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  8898. return;
  8899. }
  8900. var tabbables = this.uiDialog.find( ":tabbable" ),
  8901. first = tabbables.filter( ":first" ),
  8902. last = tabbables.filter( ":last" );
  8903. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8904. this._delay(function() {
  8905. first.focus();
  8906. });
  8907. event.preventDefault();
  8908. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8909. this._delay(function() {
  8910. last.focus();
  8911. });
  8912. event.preventDefault();
  8913. }
  8914. },
  8915. mousedown: function( event ) {
  8916. if ( this._moveToTop( event ) ) {
  8917. this._focusTabbable();
  8918. }
  8919. }
  8920. });
  8921. // We assume that any existing aria-describedby attribute means
  8922. // that the dialog content is marked up properly
  8923. // otherwise we brute force the content as the description
  8924. if ( !this.element.find( "[aria-describedby]" ).length ) {
  8925. this.uiDialog.attr({
  8926. "aria-describedby": this.element.uniqueId().attr( "id" )
  8927. });
  8928. }
  8929. },
  8930. _createTitlebar: function() {
  8931. var uiDialogTitle;
  8932. this.uiDialogTitlebar = $( "<div>" )
  8933. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  8934. .prependTo( this.uiDialog );
  8935. this._on( this.uiDialogTitlebar, {
  8936. mousedown: function( event ) {
  8937. // Don't prevent click on close button (#8838)
  8938. // Focusing a dialog that is partially scrolled out of view
  8939. // causes the browser to scroll it into view, preventing the click event
  8940. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  8941. // Dialog isn't getting focus when dragging (#8063)
  8942. this.uiDialog.focus();
  8943. }
  8944. }
  8945. });
  8946. // support: IE
  8947. // Use type="button" to prevent enter keypresses in textboxes from closing the
  8948. // dialog in IE (#9312)
  8949. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  8950. .button({
  8951. label: this.options.closeText,
  8952. icons: {
  8953. primary: "ui-icon-closethick"
  8954. },
  8955. text: false
  8956. })
  8957. .addClass( "ui-dialog-titlebar-close" )
  8958. .appendTo( this.uiDialogTitlebar );
  8959. this._on( this.uiDialogTitlebarClose, {
  8960. click: function( event ) {
  8961. event.preventDefault();
  8962. this.close( event );
  8963. }
  8964. });
  8965. uiDialogTitle = $( "<span>" )
  8966. .uniqueId()
  8967. .addClass( "ui-dialog-title" )
  8968. .prependTo( this.uiDialogTitlebar );
  8969. this._title( uiDialogTitle );
  8970. this.uiDialog.attr({
  8971. "aria-labelledby": uiDialogTitle.attr( "id" )
  8972. });
  8973. },
  8974. _title: function( title ) {
  8975. if ( !this.options.title ) {
  8976. title.html( "&#160;" );
  8977. }
  8978. title.text( this.options.title );
  8979. },
  8980. _createButtonPane: function() {
  8981. this.uiDialogButtonPane = $( "<div>" )
  8982. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  8983. this.uiButtonSet = $( "<div>" )
  8984. .addClass( "ui-dialog-buttonset" )
  8985. .appendTo( this.uiDialogButtonPane );
  8986. this._createButtons();
  8987. },
  8988. _createButtons: function() {
  8989. var that = this,
  8990. buttons = this.options.buttons;
  8991. // if we already have a button pane, remove it
  8992. this.uiDialogButtonPane.remove();
  8993. this.uiButtonSet.empty();
  8994. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  8995. this.uiDialog.removeClass( "ui-dialog-buttons" );
  8996. return;
  8997. }
  8998. $.each( buttons, function( name, props ) {
  8999. var click, buttonOptions;
  9000. props = $.isFunction( props ) ?
  9001. { click: props, text: name } :
  9002. props;
  9003. // Default to a non-submitting button
  9004. props = $.extend( { type: "button" }, props );
  9005. // Change the context for the click callback to be the main element
  9006. click = props.click;
  9007. props.click = function() {
  9008. click.apply( that.element[ 0 ], arguments );
  9009. };
  9010. buttonOptions = {
  9011. icons: props.icons,
  9012. text: props.showText
  9013. };
  9014. delete props.icons;
  9015. delete props.showText;
  9016. $( "<button></button>", props )
  9017. .button( buttonOptions )
  9018. .appendTo( that.uiButtonSet );
  9019. });
  9020. this.uiDialog.addClass( "ui-dialog-buttons" );
  9021. this.uiDialogButtonPane.appendTo( this.uiDialog );
  9022. },
  9023. _makeDraggable: function() {
  9024. var that = this,
  9025. options = this.options;
  9026. function filteredUi( ui ) {
  9027. return {
  9028. position: ui.position,
  9029. offset: ui.offset
  9030. };
  9031. }
  9032. this.uiDialog.draggable({
  9033. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  9034. handle: ".ui-dialog-titlebar",
  9035. containment: "document",
  9036. start: function( event, ui ) {
  9037. $( this ).addClass( "ui-dialog-dragging" );
  9038. that._blockFrames();
  9039. that._trigger( "dragStart", event, filteredUi( ui ) );
  9040. },
  9041. drag: function( event, ui ) {
  9042. that._trigger( "drag", event, filteredUi( ui ) );
  9043. },
  9044. stop: function( event, ui ) {
  9045. var left = ui.offset.left - that.document.scrollLeft(),
  9046. top = ui.offset.top - that.document.scrollTop();
  9047. options.position = {
  9048. my: "left top",
  9049. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9050. "top" + (top >= 0 ? "+" : "") + top,
  9051. of: that.window
  9052. };
  9053. $( this ).removeClass( "ui-dialog-dragging" );
  9054. that._unblockFrames();
  9055. that._trigger( "dragStop", event, filteredUi( ui ) );
  9056. }
  9057. });
  9058. },
  9059. _makeResizable: function() {
  9060. var that = this,
  9061. options = this.options,
  9062. handles = options.resizable,
  9063. // .ui-resizable has position: relative defined in the stylesheet
  9064. // but dialogs have to use absolute or fixed positioning
  9065. position = this.uiDialog.css("position"),
  9066. resizeHandles = typeof handles === "string" ?
  9067. handles :
  9068. "n,e,s,w,se,sw,ne,nw";
  9069. function filteredUi( ui ) {
  9070. return {
  9071. originalPosition: ui.originalPosition,
  9072. originalSize: ui.originalSize,
  9073. position: ui.position,
  9074. size: ui.size
  9075. };
  9076. }
  9077. this.uiDialog.resizable({
  9078. cancel: ".ui-dialog-content",
  9079. containment: "document",
  9080. alsoResize: this.element,
  9081. maxWidth: options.maxWidth,
  9082. maxHeight: options.maxHeight,
  9083. minWidth: options.minWidth,
  9084. minHeight: this._minHeight(),
  9085. handles: resizeHandles,
  9086. start: function( event, ui ) {
  9087. $( this ).addClass( "ui-dialog-resizing" );
  9088. that._blockFrames();
  9089. that._trigger( "resizeStart", event, filteredUi( ui ) );
  9090. },
  9091. resize: function( event, ui ) {
  9092. that._trigger( "resize", event, filteredUi( ui ) );
  9093. },
  9094. stop: function( event, ui ) {
  9095. var offset = that.uiDialog.offset(),
  9096. left = offset.left - that.document.scrollLeft(),
  9097. top = offset.top - that.document.scrollTop();
  9098. options.height = that.uiDialog.height();
  9099. options.width = that.uiDialog.width();
  9100. options.position = {
  9101. my: "left top",
  9102. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9103. "top" + (top >= 0 ? "+" : "") + top,
  9104. of: that.window
  9105. };
  9106. $( this ).removeClass( "ui-dialog-resizing" );
  9107. that._unblockFrames();
  9108. that._trigger( "resizeStop", event, filteredUi( ui ) );
  9109. }
  9110. })
  9111. .css( "position", position );
  9112. },
  9113. _trackFocus: function() {
  9114. this._on( this.widget(), {
  9115. focusin: function( event ) {
  9116. this._makeFocusTarget();
  9117. this._focusedElement = $( event.target );
  9118. }
  9119. });
  9120. },
  9121. _makeFocusTarget: function() {
  9122. this._untrackInstance();
  9123. this._trackingInstances().unshift( this );
  9124. },
  9125. _untrackInstance: function() {
  9126. var instances = this._trackingInstances(),
  9127. exists = $.inArray( this, instances );
  9128. if ( exists !== -1 ) {
  9129. instances.splice( exists, 1 );
  9130. }
  9131. },
  9132. _trackingInstances: function() {
  9133. var instances = this.document.data( "ui-dialog-instances" );
  9134. if ( !instances ) {
  9135. instances = [];
  9136. this.document.data( "ui-dialog-instances", instances );
  9137. }
  9138. return instances;
  9139. },
  9140. _minHeight: function() {
  9141. var options = this.options;
  9142. return options.height === "auto" ?
  9143. options.minHeight :
  9144. Math.min( options.minHeight, options.height );
  9145. },
  9146. _position: function() {
  9147. // Need to show the dialog to get the actual offset in the position plugin
  9148. var isVisible = this.uiDialog.is( ":visible" );
  9149. if ( !isVisible ) {
  9150. this.uiDialog.show();
  9151. }
  9152. this.uiDialog.position( this.options.position );
  9153. if ( !isVisible ) {
  9154. this.uiDialog.hide();
  9155. }
  9156. },
  9157. _setOptions: function( options ) {
  9158. var that = this,
  9159. resize = false,
  9160. resizableOptions = {};
  9161. $.each( options, function( key, value ) {
  9162. that._setOption( key, value );
  9163. if ( key in that.sizeRelatedOptions ) {
  9164. resize = true;
  9165. }
  9166. if ( key in that.resizableRelatedOptions ) {
  9167. resizableOptions[ key ] = value;
  9168. }
  9169. });
  9170. if ( resize ) {
  9171. this._size();
  9172. this._position();
  9173. }
  9174. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9175. this.uiDialog.resizable( "option", resizableOptions );
  9176. }
  9177. },
  9178. _setOption: function( key, value ) {
  9179. var isDraggable, isResizable,
  9180. uiDialog = this.uiDialog;
  9181. if ( key === "dialogClass" ) {
  9182. uiDialog
  9183. .removeClass( this.options.dialogClass )
  9184. .addClass( value );
  9185. }
  9186. if ( key === "disabled" ) {
  9187. return;
  9188. }
  9189. this._super( key, value );
  9190. if ( key === "appendTo" ) {
  9191. this.uiDialog.appendTo( this._appendTo() );
  9192. }
  9193. if ( key === "buttons" ) {
  9194. this._createButtons();
  9195. }
  9196. if ( key === "closeText" ) {
  9197. this.uiDialogTitlebarClose.button({
  9198. // Ensure that we always pass a string
  9199. label: "" + value
  9200. });
  9201. }
  9202. if ( key === "draggable" ) {
  9203. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  9204. if ( isDraggable && !value ) {
  9205. uiDialog.draggable( "destroy" );
  9206. }
  9207. if ( !isDraggable && value ) {
  9208. this._makeDraggable();
  9209. }
  9210. }
  9211. if ( key === "position" ) {
  9212. this._position();
  9213. }
  9214. if ( key === "resizable" ) {
  9215. // currently resizable, becoming non-resizable
  9216. isResizable = uiDialog.is( ":data(ui-resizable)" );
  9217. if ( isResizable && !value ) {
  9218. uiDialog.resizable( "destroy" );
  9219. }
  9220. // currently resizable, changing handles
  9221. if ( isResizable && typeof value === "string" ) {
  9222. uiDialog.resizable( "option", "handles", value );
  9223. }
  9224. // currently non-resizable, becoming resizable
  9225. if ( !isResizable && value !== false ) {
  9226. this._makeResizable();
  9227. }
  9228. }
  9229. if ( key === "title" ) {
  9230. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  9231. }
  9232. },
  9233. _size: function() {
  9234. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  9235. // divs will both have width and height set, so we need to reset them
  9236. var nonContentHeight, minContentHeight, maxContentHeight,
  9237. options = this.options;
  9238. // Reset content sizing
  9239. this.element.show().css({
  9240. width: "auto",
  9241. minHeight: 0,
  9242. maxHeight: "none",
  9243. height: 0
  9244. });
  9245. if ( options.minWidth > options.width ) {
  9246. options.width = options.minWidth;
  9247. }
  9248. // reset wrapper sizing
  9249. // determine the height of all the non-content elements
  9250. nonContentHeight = this.uiDialog.css({
  9251. height: "auto",
  9252. width: options.width
  9253. })
  9254. .outerHeight();
  9255. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  9256. maxContentHeight = typeof options.maxHeight === "number" ?
  9257. Math.max( 0, options.maxHeight - nonContentHeight ) :
  9258. "none";
  9259. if ( options.height === "auto" ) {
  9260. this.element.css({
  9261. minHeight: minContentHeight,
  9262. maxHeight: maxContentHeight,
  9263. height: "auto"
  9264. });
  9265. } else {
  9266. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  9267. }
  9268. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9269. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  9270. }
  9271. },
  9272. _blockFrames: function() {
  9273. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  9274. var iframe = $( this );
  9275. return $( "<div>" )
  9276. .css({
  9277. position: "absolute",
  9278. width: iframe.outerWidth(),
  9279. height: iframe.outerHeight()
  9280. })
  9281. .appendTo( iframe.parent() )
  9282. .offset( iframe.offset() )[0];
  9283. });
  9284. },
  9285. _unblockFrames: function() {
  9286. if ( this.iframeBlocks ) {
  9287. this.iframeBlocks.remove();
  9288. delete this.iframeBlocks;
  9289. }
  9290. },
  9291. _allowInteraction: function( event ) {
  9292. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  9293. return true;
  9294. }
  9295. // TODO: Remove hack when datepicker implements
  9296. // the .ui-front logic (#8989)
  9297. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  9298. },
  9299. _createOverlay: function() {
  9300. if ( !this.options.modal ) {
  9301. return;
  9302. }
  9303. // We use a delay in case the overlay is created from an
  9304. // event that we're going to be cancelling (#2804)
  9305. var isOpening = true;
  9306. this._delay(function() {
  9307. isOpening = false;
  9308. });
  9309. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  9310. // Prevent use of anchors and inputs
  9311. // Using _on() for an event handler shared across many instances is
  9312. // safe because the dialogs stack and must be closed in reverse order
  9313. this._on( this.document, {
  9314. focusin: function( event ) {
  9315. if ( isOpening ) {
  9316. return;
  9317. }
  9318. if ( !this._allowInteraction( event ) ) {
  9319. event.preventDefault();
  9320. this._trackingInstances()[ 0 ]._focusTabbable();
  9321. }
  9322. }
  9323. });
  9324. }
  9325. this.overlay = $( "<div>" )
  9326. .addClass( "ui-widget-overlay ui-front" )
  9327. .appendTo( this._appendTo() );
  9328. this._on( this.overlay, {
  9329. mousedown: "_keepFocus"
  9330. });
  9331. this.document.data( "ui-dialog-overlays",
  9332. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  9333. },
  9334. _destroyOverlay: function() {
  9335. if ( !this.options.modal ) {
  9336. return;
  9337. }
  9338. if ( this.overlay ) {
  9339. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  9340. if ( !overlays ) {
  9341. this.document
  9342. .unbind( "focusin" )
  9343. .removeData( "ui-dialog-overlays" );
  9344. } else {
  9345. this.document.data( "ui-dialog-overlays", overlays );
  9346. }
  9347. this.overlay.remove();
  9348. this.overlay = null;
  9349. }
  9350. }
  9351. });
  9352. /*!
  9353. * jQuery UI Progressbar 1.11.4
  9354. * http://jqueryui.com
  9355. *
  9356. * Copyright jQuery Foundation and other contributors
  9357. * Released under the MIT license.
  9358. * http://jquery.org/license
  9359. *
  9360. * http://api.jqueryui.com/progressbar/
  9361. */
  9362. var progressbar = $.widget( "ui.progressbar", {
  9363. version: "1.11.4",
  9364. options: {
  9365. max: 100,
  9366. value: 0,
  9367. change: null,
  9368. complete: null
  9369. },
  9370. min: 0,
  9371. _create: function() {
  9372. // Constrain initial value
  9373. this.oldValue = this.options.value = this._constrainedValue();
  9374. this.element
  9375. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9376. .attr({
  9377. // Only set static values, aria-valuenow and aria-valuemax are
  9378. // set inside _refreshValue()
  9379. role: "progressbar",
  9380. "aria-valuemin": this.min
  9381. });
  9382. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  9383. .appendTo( this.element );
  9384. this._refreshValue();
  9385. },
  9386. _destroy: function() {
  9387. this.element
  9388. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9389. .removeAttr( "role" )
  9390. .removeAttr( "aria-valuemin" )
  9391. .removeAttr( "aria-valuemax" )
  9392. .removeAttr( "aria-valuenow" );
  9393. this.valueDiv.remove();
  9394. },
  9395. value: function( newValue ) {
  9396. if ( newValue === undefined ) {
  9397. return this.options.value;
  9398. }
  9399. this.options.value = this._constrainedValue( newValue );
  9400. this._refreshValue();
  9401. },
  9402. _constrainedValue: function( newValue ) {
  9403. if ( newValue === undefined ) {
  9404. newValue = this.options.value;
  9405. }
  9406. this.indeterminate = newValue === false;
  9407. // sanitize value
  9408. if ( typeof newValue !== "number" ) {
  9409. newValue = 0;
  9410. }
  9411. return this.indeterminate ? false :
  9412. Math.min( this.options.max, Math.max( this.min, newValue ) );
  9413. },
  9414. _setOptions: function( options ) {
  9415. // Ensure "value" option is set after other values (like max)
  9416. var value = options.value;
  9417. delete options.value;
  9418. this._super( options );
  9419. this.options.value = this._constrainedValue( value );
  9420. this._refreshValue();
  9421. },
  9422. _setOption: function( key, value ) {
  9423. if ( key === "max" ) {
  9424. // Don't allow a max less than min
  9425. value = Math.max( this.min, value );
  9426. }
  9427. if ( key === "disabled" ) {
  9428. this.element
  9429. .toggleClass( "ui-state-disabled", !!value )
  9430. .attr( "aria-disabled", value );
  9431. }
  9432. this._super( key, value );
  9433. },
  9434. _percentage: function() {
  9435. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  9436. },
  9437. _refreshValue: function() {
  9438. var value = this.options.value,
  9439. percentage = this._percentage();
  9440. this.valueDiv
  9441. .toggle( this.indeterminate || value > this.min )
  9442. .toggleClass( "ui-corner-right", value === this.options.max )
  9443. .width( percentage.toFixed(0) + "%" );
  9444. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  9445. if ( this.indeterminate ) {
  9446. this.element.removeAttr( "aria-valuenow" );
  9447. if ( !this.overlayDiv ) {
  9448. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  9449. }
  9450. } else {
  9451. this.element.attr({
  9452. "aria-valuemax": this.options.max,
  9453. "aria-valuenow": value
  9454. });
  9455. if ( this.overlayDiv ) {
  9456. this.overlayDiv.remove();
  9457. this.overlayDiv = null;
  9458. }
  9459. }
  9460. if ( this.oldValue !== value ) {
  9461. this.oldValue = value;
  9462. this._trigger( "change" );
  9463. }
  9464. if ( value === this.options.max ) {
  9465. this._trigger( "complete" );
  9466. }
  9467. }
  9468. });
  9469. /*!
  9470. * jQuery UI Selectmenu 1.11.4
  9471. * http://jqueryui.com
  9472. *
  9473. * Copyright jQuery Foundation and other contributors
  9474. * Released under the MIT license.
  9475. * http://jquery.org/license
  9476. *
  9477. * http://api.jqueryui.com/selectmenu
  9478. */
  9479. var selectmenu = $.widget( "ui.selectmenu", {
  9480. version: "1.11.4",
  9481. defaultElement: "<select>",
  9482. options: {
  9483. appendTo: null,
  9484. disabled: null,
  9485. icons: {
  9486. button: "ui-icon-triangle-1-s"
  9487. },
  9488. position: {
  9489. my: "left top",
  9490. at: "left bottom",
  9491. collision: "none"
  9492. },
  9493. width: null,
  9494. // callbacks
  9495. change: null,
  9496. close: null,
  9497. focus: null,
  9498. open: null,
  9499. select: null
  9500. },
  9501. _create: function() {
  9502. var selectmenuId = this.element.uniqueId().attr( "id" );
  9503. this.ids = {
  9504. element: selectmenuId,
  9505. button: selectmenuId + "-button",
  9506. menu: selectmenuId + "-menu"
  9507. };
  9508. this._drawButton();
  9509. this._drawMenu();
  9510. if ( this.options.disabled ) {
  9511. this.disable();
  9512. }
  9513. },
  9514. _drawButton: function() {
  9515. var that = this;
  9516. // Associate existing label with the new button
  9517. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  9518. this._on( this.label, {
  9519. click: function( event ) {
  9520. this.button.focus();
  9521. event.preventDefault();
  9522. }
  9523. });
  9524. // Hide original select element
  9525. this.element.hide();
  9526. // Create button
  9527. this.button = $( "<span>", {
  9528. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  9529. tabindex: this.options.disabled ? -1 : 0,
  9530. id: this.ids.button,
  9531. role: "combobox",
  9532. "aria-expanded": "false",
  9533. "aria-autocomplete": "list",
  9534. "aria-owns": this.ids.menu,
  9535. "aria-haspopup": "true"
  9536. })
  9537. .insertAfter( this.element );
  9538. $( "<span>", {
  9539. "class": "ui-icon " + this.options.icons.button
  9540. })
  9541. .prependTo( this.button );
  9542. this.buttonText = $( "<span>", {
  9543. "class": "ui-selectmenu-text"
  9544. })
  9545. .appendTo( this.button );
  9546. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  9547. this._resizeButton();
  9548. this._on( this.button, this._buttonEvents );
  9549. this.button.one( "focusin", function() {
  9550. // Delay rendering the menu items until the button receives focus.
  9551. // The menu may have already been rendered via a programmatic open.
  9552. if ( !that.menuItems ) {
  9553. that._refreshMenu();
  9554. }
  9555. });
  9556. this._hoverable( this.button );
  9557. this._focusable( this.button );
  9558. },
  9559. _drawMenu: function() {
  9560. var that = this;
  9561. // Create menu
  9562. this.menu = $( "<ul>", {
  9563. "aria-hidden": "true",
  9564. "aria-labelledby": this.ids.button,
  9565. id: this.ids.menu
  9566. });
  9567. // Wrap menu
  9568. this.menuWrap = $( "<div>", {
  9569. "class": "ui-selectmenu-menu ui-front"
  9570. })
  9571. .append( this.menu )
  9572. .appendTo( this._appendTo() );
  9573. // Initialize menu widget
  9574. this.menuInstance = this.menu
  9575. .menu({
  9576. role: "listbox",
  9577. select: function( event, ui ) {
  9578. event.preventDefault();
  9579. // support: IE8
  9580. // If the item was selected via a click, the text selection
  9581. // will be destroyed in IE
  9582. that._setSelection();
  9583. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  9584. },
  9585. focus: function( event, ui ) {
  9586. var item = ui.item.data( "ui-selectmenu-item" );
  9587. // Prevent inital focus from firing and check if its a newly focused item
  9588. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  9589. that._trigger( "focus", event, { item: item } );
  9590. if ( !that.isOpen ) {
  9591. that._select( item, event );
  9592. }
  9593. }
  9594. that.focusIndex = item.index;
  9595. that.button.attr( "aria-activedescendant",
  9596. that.menuItems.eq( item.index ).attr( "id" ) );
  9597. }
  9598. })
  9599. .menu( "instance" );
  9600. // Adjust menu styles to dropdown
  9601. this.menu
  9602. .addClass( "ui-corner-bottom" )
  9603. .removeClass( "ui-corner-all" );
  9604. // Don't close the menu on mouseleave
  9605. this.menuInstance._off( this.menu, "mouseleave" );
  9606. // Cancel the menu's collapseAll on document click
  9607. this.menuInstance._closeOnDocumentClick = function() {
  9608. return false;
  9609. };
  9610. // Selects often contain empty items, but never contain dividers
  9611. this.menuInstance._isDivider = function() {
  9612. return false;
  9613. };
  9614. },
  9615. refresh: function() {
  9616. this._refreshMenu();
  9617. this._setText( this.buttonText, this._getSelectedItem().text() );
  9618. if ( !this.options.width ) {
  9619. this._resizeButton();
  9620. }
  9621. },
  9622. _refreshMenu: function() {
  9623. this.menu.empty();
  9624. var item,
  9625. options = this.element.find( "option" );
  9626. if ( !options.length ) {
  9627. return;
  9628. }
  9629. this._parseOptions( options );
  9630. this._renderMenu( this.menu, this.items );
  9631. this.menuInstance.refresh();
  9632. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  9633. item = this._getSelectedItem();
  9634. // Update the menu to have the correct item focused
  9635. this.menuInstance.focus( null, item );
  9636. this._setAria( item.data( "ui-selectmenu-item" ) );
  9637. // Set disabled state
  9638. this._setOption( "disabled", this.element.prop( "disabled" ) );
  9639. },
  9640. open: function( event ) {
  9641. if ( this.options.disabled ) {
  9642. return;
  9643. }
  9644. // If this is the first time the menu is being opened, render the items
  9645. if ( !this.menuItems ) {
  9646. this._refreshMenu();
  9647. } else {
  9648. // Menu clears focus on close, reset focus to selected item
  9649. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  9650. this.menuInstance.focus( null, this._getSelectedItem() );
  9651. }
  9652. this.isOpen = true;
  9653. this._toggleAttr();
  9654. this._resizeMenu();
  9655. this._position();
  9656. this._on( this.document, this._documentClick );
  9657. this._trigger( "open", event );
  9658. },
  9659. _position: function() {
  9660. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  9661. },
  9662. close: function( event ) {
  9663. if ( !this.isOpen ) {
  9664. return;
  9665. }
  9666. this.isOpen = false;
  9667. this._toggleAttr();
  9668. this.range = null;
  9669. this._off( this.document );
  9670. this._trigger( "close", event );
  9671. },
  9672. widget: function() {
  9673. return this.button;
  9674. },
  9675. menuWidget: function() {
  9676. return this.menu;
  9677. },
  9678. _renderMenu: function( ul, items ) {
  9679. var that = this,
  9680. currentOptgroup = "";
  9681. $.each( items, function( index, item ) {
  9682. if ( item.optgroup !== currentOptgroup ) {
  9683. $( "<li>", {
  9684. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  9685. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  9686. " ui-state-disabled" :
  9687. "" ),
  9688. text: item.optgroup
  9689. })
  9690. .appendTo( ul );
  9691. currentOptgroup = item.optgroup;
  9692. }
  9693. that._renderItemData( ul, item );
  9694. });
  9695. },
  9696. _renderItemData: function( ul, item ) {
  9697. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  9698. },
  9699. _renderItem: function( ul, item ) {
  9700. var li = $( "<li>" );
  9701. if ( item.disabled ) {
  9702. li.addClass( "ui-state-disabled" );
  9703. }
  9704. this._setText( li, item.label );
  9705. return li.appendTo( ul );
  9706. },
  9707. _setText: function( element, value ) {
  9708. if ( value ) {
  9709. element.text( value );
  9710. } else {
  9711. element.html( "&#160;" );
  9712. }
  9713. },
  9714. _move: function( direction, event ) {
  9715. var item, next,
  9716. filter = ".ui-menu-item";
  9717. if ( this.isOpen ) {
  9718. item = this.menuItems.eq( this.focusIndex );
  9719. } else {
  9720. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9721. filter += ":not(.ui-state-disabled)";
  9722. }
  9723. if ( direction === "first" || direction === "last" ) {
  9724. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  9725. } else {
  9726. next = item[ direction + "All" ]( filter ).eq( 0 );
  9727. }
  9728. if ( next.length ) {
  9729. this.menuInstance.focus( event, next );
  9730. }
  9731. },
  9732. _getSelectedItem: function() {
  9733. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9734. },
  9735. _toggle: function( event ) {
  9736. this[ this.isOpen ? "close" : "open" ]( event );
  9737. },
  9738. _setSelection: function() {
  9739. var selection;
  9740. if ( !this.range ) {
  9741. return;
  9742. }
  9743. if ( window.getSelection ) {
  9744. selection = window.getSelection();
  9745. selection.removeAllRanges();
  9746. selection.addRange( this.range );
  9747. // support: IE8
  9748. } else {
  9749. this.range.select();
  9750. }
  9751. // support: IE
  9752. // Setting the text selection kills the button focus in IE, but
  9753. // restoring the focus doesn't kill the selection.
  9754. this.button.focus();
  9755. },
  9756. _documentClick: {
  9757. mousedown: function( event ) {
  9758. if ( !this.isOpen ) {
  9759. return;
  9760. }
  9761. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  9762. this.close( event );
  9763. }
  9764. }
  9765. },
  9766. _buttonEvents: {
  9767. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  9768. mousedown: function() {
  9769. var selection;
  9770. if ( window.getSelection ) {
  9771. selection = window.getSelection();
  9772. if ( selection.rangeCount ) {
  9773. this.range = selection.getRangeAt( 0 );
  9774. }
  9775. // support: IE8
  9776. } else {
  9777. this.range = document.selection.createRange();
  9778. }
  9779. },
  9780. click: function( event ) {
  9781. this._setSelection();
  9782. this._toggle( event );
  9783. },
  9784. keydown: function( event ) {
  9785. var preventDefault = true;
  9786. switch ( event.keyCode ) {
  9787. case $.ui.keyCode.TAB:
  9788. case $.ui.keyCode.ESCAPE:
  9789. this.close( event );
  9790. preventDefault = false;
  9791. break;
  9792. case $.ui.keyCode.ENTER:
  9793. if ( this.isOpen ) {
  9794. this._selectFocusedItem( event );
  9795. }
  9796. break;
  9797. case $.ui.keyCode.UP:
  9798. if ( event.altKey ) {
  9799. this._toggle( event );
  9800. } else {
  9801. this._move( "prev", event );
  9802. }
  9803. break;
  9804. case $.ui.keyCode.DOWN:
  9805. if ( event.altKey ) {
  9806. this._toggle( event );
  9807. } else {
  9808. this._move( "next", event );
  9809. }
  9810. break;
  9811. case $.ui.keyCode.SPACE:
  9812. if ( this.isOpen ) {
  9813. this._selectFocusedItem( event );
  9814. } else {
  9815. this._toggle( event );
  9816. }
  9817. break;
  9818. case $.ui.keyCode.LEFT:
  9819. this._move( "prev", event );
  9820. break;
  9821. case $.ui.keyCode.RIGHT:
  9822. this._move( "next", event );
  9823. break;
  9824. case $.ui.keyCode.HOME:
  9825. case $.ui.keyCode.PAGE_UP:
  9826. this._move( "first", event );
  9827. break;
  9828. case $.ui.keyCode.END:
  9829. case $.ui.keyCode.PAGE_DOWN:
  9830. this._move( "last", event );
  9831. break;
  9832. default:
  9833. this.menu.trigger( event );
  9834. preventDefault = false;
  9835. }
  9836. if ( preventDefault ) {
  9837. event.preventDefault();
  9838. }
  9839. }
  9840. },
  9841. _selectFocusedItem: function( event ) {
  9842. var item = this.menuItems.eq( this.focusIndex );
  9843. if ( !item.hasClass( "ui-state-disabled" ) ) {
  9844. this._select( item.data( "ui-selectmenu-item" ), event );
  9845. }
  9846. },
  9847. _select: function( item, event ) {
  9848. var oldIndex = this.element[ 0 ].selectedIndex;
  9849. // Change native select element
  9850. this.element[ 0 ].selectedIndex = item.index;
  9851. this._setText( this.buttonText, item.label );
  9852. this._setAria( item );
  9853. this._trigger( "select", event, { item: item } );
  9854. if ( item.index !== oldIndex ) {
  9855. this._trigger( "change", event, { item: item } );
  9856. }
  9857. this.close( event );
  9858. },
  9859. _setAria: function( item ) {
  9860. var id = this.menuItems.eq( item.index ).attr( "id" );
  9861. this.button.attr({
  9862. "aria-labelledby": id,
  9863. "aria-activedescendant": id
  9864. });
  9865. this.menu.attr( "aria-activedescendant", id );
  9866. },
  9867. _setOption: function( key, value ) {
  9868. if ( key === "icons" ) {
  9869. this.button.find( "span.ui-icon" )
  9870. .removeClass( this.options.icons.button )
  9871. .addClass( value.button );
  9872. }
  9873. this._super( key, value );
  9874. if ( key === "appendTo" ) {
  9875. this.menuWrap.appendTo( this._appendTo() );
  9876. }
  9877. if ( key === "disabled" ) {
  9878. this.menuInstance.option( "disabled", value );
  9879. this.button
  9880. .toggleClass( "ui-state-disabled", value )
  9881. .attr( "aria-disabled", value );
  9882. this.element.prop( "disabled", value );
  9883. if ( value ) {
  9884. this.button.attr( "tabindex", -1 );
  9885. this.close();
  9886. } else {
  9887. this.button.attr( "tabindex", 0 );
  9888. }
  9889. }
  9890. if ( key === "width" ) {
  9891. this._resizeButton();
  9892. }
  9893. },
  9894. _appendTo: function() {
  9895. var element = this.options.appendTo;
  9896. if ( element ) {
  9897. element = element.jquery || element.nodeType ?
  9898. $( element ) :
  9899. this.document.find( element ).eq( 0 );
  9900. }
  9901. if ( !element || !element[ 0 ] ) {
  9902. element = this.element.closest( ".ui-front" );
  9903. }
  9904. if ( !element.length ) {
  9905. element = this.document[ 0 ].body;
  9906. }
  9907. return element;
  9908. },
  9909. _toggleAttr: function() {
  9910. this.button
  9911. .toggleClass( "ui-corner-top", this.isOpen )
  9912. .toggleClass( "ui-corner-all", !this.isOpen )
  9913. .attr( "aria-expanded", this.isOpen );
  9914. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  9915. this.menu.attr( "aria-hidden", !this.isOpen );
  9916. },
  9917. _resizeButton: function() {
  9918. var width = this.options.width;
  9919. if ( !width ) {
  9920. width = this.element.show().outerWidth();
  9921. this.element.hide();
  9922. }
  9923. this.button.outerWidth( width );
  9924. },
  9925. _resizeMenu: function() {
  9926. this.menu.outerWidth( Math.max(
  9927. this.button.outerWidth(),
  9928. // support: IE10
  9929. // IE10 wraps long text (possibly a rounding bug)
  9930. // so we add 1px to avoid the wrapping
  9931. this.menu.width( "" ).outerWidth() + 1
  9932. ) );
  9933. },
  9934. _getCreateOptions: function() {
  9935. return { disabled: this.element.prop( "disabled" ) };
  9936. },
  9937. _parseOptions: function( options ) {
  9938. var data = [];
  9939. options.each(function( index, item ) {
  9940. var option = $( item ),
  9941. optgroup = option.parent( "optgroup" );
  9942. data.push({
  9943. element: option,
  9944. index: index,
  9945. value: option.val(),
  9946. label: option.text(),
  9947. optgroup: optgroup.attr( "label" ) || "",
  9948. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  9949. });
  9950. });
  9951. this.items = data;
  9952. },
  9953. _destroy: function() {
  9954. this.menuWrap.remove();
  9955. this.button.remove();
  9956. this.element.show();
  9957. this.element.removeUniqueId();
  9958. this.label.attr( "for", this.ids.element );
  9959. }
  9960. });
  9961. /*!
  9962. * jQuery UI Slider 1.11.4
  9963. * http://jqueryui.com
  9964. *
  9965. * Copyright jQuery Foundation and other contributors
  9966. * Released under the MIT license.
  9967. * http://jquery.org/license
  9968. *
  9969. * http://api.jqueryui.com/slider/
  9970. */
  9971. var slider = $.widget( "ui.slider", $.ui.mouse, {
  9972. version: "1.11.4",
  9973. widgetEventPrefix: "slide",
  9974. options: {
  9975. animate: false,
  9976. distance: 0,
  9977. max: 100,
  9978. min: 0,
  9979. orientation: "horizontal",
  9980. range: false,
  9981. step: 1,
  9982. value: 0,
  9983. values: null,
  9984. // callbacks
  9985. change: null,
  9986. slide: null,
  9987. start: null,
  9988. stop: null
  9989. },
  9990. // number of pages in a slider
  9991. // (how many times can you page up/down to go through the whole range)
  9992. numPages: 5,
  9993. _create: function() {
  9994. this._keySliding = false;
  9995. this._mouseSliding = false;
  9996. this._animateOff = true;
  9997. this._handleIndex = null;
  9998. this._detectOrientation();
  9999. this._mouseInit();
  10000. this._calculateNewMax();
  10001. this.element
  10002. .addClass( "ui-slider" +
  10003. " ui-slider-" + this.orientation +
  10004. " ui-widget" +
  10005. " ui-widget-content" +
  10006. " ui-corner-all");
  10007. this._refresh();
  10008. this._setOption( "disabled", this.options.disabled );
  10009. this._animateOff = false;
  10010. },
  10011. _refresh: function() {
  10012. this._createRange();
  10013. this._createHandles();
  10014. this._setupEvents();
  10015. this._refreshValue();
  10016. },
  10017. _createHandles: function() {
  10018. var i, handleCount,
  10019. options = this.options,
  10020. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10021. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  10022. handles = [];
  10023. handleCount = ( options.values && options.values.length ) || 1;
  10024. if ( existingHandles.length > handleCount ) {
  10025. existingHandles.slice( handleCount ).remove();
  10026. existingHandles = existingHandles.slice( 0, handleCount );
  10027. }
  10028. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10029. handles.push( handle );
  10030. }
  10031. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10032. this.handle = this.handles.eq( 0 );
  10033. this.handles.each(function( i ) {
  10034. $( this ).data( "ui-slider-handle-index", i );
  10035. });
  10036. },
  10037. _createRange: function() {
  10038. var options = this.options,
  10039. classes = "";
  10040. if ( options.range ) {
  10041. if ( options.range === true ) {
  10042. if ( !options.values ) {
  10043. options.values = [ this._valueMin(), this._valueMin() ];
  10044. } else if ( options.values.length && options.values.length !== 2 ) {
  10045. options.values = [ options.values[0], options.values[0] ];
  10046. } else if ( $.isArray( options.values ) ) {
  10047. options.values = options.values.slice(0);
  10048. }
  10049. }
  10050. if ( !this.range || !this.range.length ) {
  10051. this.range = $( "<div></div>" )
  10052. .appendTo( this.element );
  10053. classes = "ui-slider-range" +
  10054. // note: this isn't the most fittingly semantic framework class for this element,
  10055. // but worked best visually with a variety of themes
  10056. " ui-widget-header ui-corner-all";
  10057. } else {
  10058. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10059. // Handle range switching from true to min/max
  10060. .css({
  10061. "left": "",
  10062. "bottom": ""
  10063. });
  10064. }
  10065. this.range.addClass( classes +
  10066. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10067. } else {
  10068. if ( this.range ) {
  10069. this.range.remove();
  10070. }
  10071. this.range = null;
  10072. }
  10073. },
  10074. _setupEvents: function() {
  10075. this._off( this.handles );
  10076. this._on( this.handles, this._handleEvents );
  10077. this._hoverable( this.handles );
  10078. this._focusable( this.handles );
  10079. },
  10080. _destroy: function() {
  10081. this.handles.remove();
  10082. if ( this.range ) {
  10083. this.range.remove();
  10084. }
  10085. this.element
  10086. .removeClass( "ui-slider" +
  10087. " ui-slider-horizontal" +
  10088. " ui-slider-vertical" +
  10089. " ui-widget" +
  10090. " ui-widget-content" +
  10091. " ui-corner-all" );
  10092. this._mouseDestroy();
  10093. },
  10094. _mouseCapture: function( event ) {
  10095. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10096. that = this,
  10097. o = this.options;
  10098. if ( o.disabled ) {
  10099. return false;
  10100. }
  10101. this.elementSize = {
  10102. width: this.element.outerWidth(),
  10103. height: this.element.outerHeight()
  10104. };
  10105. this.elementOffset = this.element.offset();
  10106. position = { x: event.pageX, y: event.pageY };
  10107. normValue = this._normValueFromMouse( position );
  10108. distance = this._valueMax() - this._valueMin() + 1;
  10109. this.handles.each(function( i ) {
  10110. var thisDistance = Math.abs( normValue - that.values(i) );
  10111. if (( distance > thisDistance ) ||
  10112. ( distance === thisDistance &&
  10113. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10114. distance = thisDistance;
  10115. closestHandle = $( this );
  10116. index = i;
  10117. }
  10118. });
  10119. allowed = this._start( event, index );
  10120. if ( allowed === false ) {
  10121. return false;
  10122. }
  10123. this._mouseSliding = true;
  10124. this._handleIndex = index;
  10125. closestHandle
  10126. .addClass( "ui-state-active" )
  10127. .focus();
  10128. offset = closestHandle.offset();
  10129. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10130. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10131. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10132. top: event.pageY - offset.top -
  10133. ( closestHandle.height() / 2 ) -
  10134. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  10135. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  10136. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  10137. };
  10138. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  10139. this._slide( event, index, normValue );
  10140. }
  10141. this._animateOff = true;
  10142. return true;
  10143. },
  10144. _mouseStart: function() {
  10145. return true;
  10146. },
  10147. _mouseDrag: function( event ) {
  10148. var position = { x: event.pageX, y: event.pageY },
  10149. normValue = this._normValueFromMouse( position );
  10150. this._slide( event, this._handleIndex, normValue );
  10151. return false;
  10152. },
  10153. _mouseStop: function( event ) {
  10154. this.handles.removeClass( "ui-state-active" );
  10155. this._mouseSliding = false;
  10156. this._stop( event, this._handleIndex );
  10157. this._change( event, this._handleIndex );
  10158. this._handleIndex = null;
  10159. this._clickOffset = null;
  10160. this._animateOff = false;
  10161. return false;
  10162. },
  10163. _detectOrientation: function() {
  10164. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  10165. },
  10166. _normValueFromMouse: function( position ) {
  10167. var pixelTotal,
  10168. pixelMouse,
  10169. percentMouse,
  10170. valueTotal,
  10171. valueMouse;
  10172. if ( this.orientation === "horizontal" ) {
  10173. pixelTotal = this.elementSize.width;
  10174. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  10175. } else {
  10176. pixelTotal = this.elementSize.height;
  10177. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  10178. }
  10179. percentMouse = ( pixelMouse / pixelTotal );
  10180. if ( percentMouse > 1 ) {
  10181. percentMouse = 1;
  10182. }
  10183. if ( percentMouse < 0 ) {
  10184. percentMouse = 0;
  10185. }
  10186. if ( this.orientation === "vertical" ) {
  10187. percentMouse = 1 - percentMouse;
  10188. }
  10189. valueTotal = this._valueMax() - this._valueMin();
  10190. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10191. return this._trimAlignValue( valueMouse );
  10192. },
  10193. _start: function( event, index ) {
  10194. var uiHash = {
  10195. handle: this.handles[ index ],
  10196. value: this.value()
  10197. };
  10198. if ( this.options.values && this.options.values.length ) {
  10199. uiHash.value = this.values( index );
  10200. uiHash.values = this.values();
  10201. }
  10202. return this._trigger( "start", event, uiHash );
  10203. },
  10204. _slide: function( event, index, newVal ) {
  10205. var otherVal,
  10206. newValues,
  10207. allowed;
  10208. if ( this.options.values && this.options.values.length ) {
  10209. otherVal = this.values( index ? 0 : 1 );
  10210. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  10211. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  10212. ) {
  10213. newVal = otherVal;
  10214. }
  10215. if ( newVal !== this.values( index ) ) {
  10216. newValues = this.values();
  10217. newValues[ index ] = newVal;
  10218. // A slide can be canceled by returning false from the slide callback
  10219. allowed = this._trigger( "slide", event, {
  10220. handle: this.handles[ index ],
  10221. value: newVal,
  10222. values: newValues
  10223. } );
  10224. otherVal = this.values( index ? 0 : 1 );
  10225. if ( allowed !== false ) {
  10226. this.values( index, newVal );
  10227. }
  10228. }
  10229. } else {
  10230. if ( newVal !== this.value() ) {
  10231. // A slide can be canceled by returning false from the slide callback
  10232. allowed = this._trigger( "slide", event, {
  10233. handle: this.handles[ index ],
  10234. value: newVal
  10235. } );
  10236. if ( allowed !== false ) {
  10237. this.value( newVal );
  10238. }
  10239. }
  10240. }
  10241. },
  10242. _stop: function( event, index ) {
  10243. var uiHash = {
  10244. handle: this.handles[ index ],
  10245. value: this.value()
  10246. };
  10247. if ( this.options.values && this.options.values.length ) {
  10248. uiHash.value = this.values( index );
  10249. uiHash.values = this.values();
  10250. }
  10251. this._trigger( "stop", event, uiHash );
  10252. },
  10253. _change: function( event, index ) {
  10254. if ( !this._keySliding && !this._mouseSliding ) {
  10255. var uiHash = {
  10256. handle: this.handles[ index ],
  10257. value: this.value()
  10258. };
  10259. if ( this.options.values && this.options.values.length ) {
  10260. uiHash.value = this.values( index );
  10261. uiHash.values = this.values();
  10262. }
  10263. //store the last changed value index for reference when handles overlap
  10264. this._lastChangedValue = index;
  10265. this._trigger( "change", event, uiHash );
  10266. }
  10267. },
  10268. value: function( newValue ) {
  10269. if ( arguments.length ) {
  10270. this.options.value = this._trimAlignValue( newValue );
  10271. this._refreshValue();
  10272. this._change( null, 0 );
  10273. return;
  10274. }
  10275. return this._value();
  10276. },
  10277. values: function( index, newValue ) {
  10278. var vals,
  10279. newValues,
  10280. i;
  10281. if ( arguments.length > 1 ) {
  10282. this.options.values[ index ] = this._trimAlignValue( newValue );
  10283. this._refreshValue();
  10284. this._change( null, index );
  10285. return;
  10286. }
  10287. if ( arguments.length ) {
  10288. if ( $.isArray( arguments[ 0 ] ) ) {
  10289. vals = this.options.values;
  10290. newValues = arguments[ 0 ];
  10291. for ( i = 0; i < vals.length; i += 1 ) {
  10292. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  10293. this._change( null, i );
  10294. }
  10295. this._refreshValue();
  10296. } else {
  10297. if ( this.options.values && this.options.values.length ) {
  10298. return this._values( index );
  10299. } else {
  10300. return this.value();
  10301. }
  10302. }
  10303. } else {
  10304. return this._values();
  10305. }
  10306. },
  10307. _setOption: function( key, value ) {
  10308. var i,
  10309. valsLength = 0;
  10310. if ( key === "range" && this.options.range === true ) {
  10311. if ( value === "min" ) {
  10312. this.options.value = this._values( 0 );
  10313. this.options.values = null;
  10314. } else if ( value === "max" ) {
  10315. this.options.value = this._values( this.options.values.length - 1 );
  10316. this.options.values = null;
  10317. }
  10318. }
  10319. if ( $.isArray( this.options.values ) ) {
  10320. valsLength = this.options.values.length;
  10321. }
  10322. if ( key === "disabled" ) {
  10323. this.element.toggleClass( "ui-state-disabled", !!value );
  10324. }
  10325. this._super( key, value );
  10326. switch ( key ) {
  10327. case "orientation":
  10328. this._detectOrientation();
  10329. this.element
  10330. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  10331. .addClass( "ui-slider-" + this.orientation );
  10332. this._refreshValue();
  10333. // Reset positioning from previous orientation
  10334. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  10335. break;
  10336. case "value":
  10337. this._animateOff = true;
  10338. this._refreshValue();
  10339. this._change( null, 0 );
  10340. this._animateOff = false;
  10341. break;
  10342. case "values":
  10343. this._animateOff = true;
  10344. this._refreshValue();
  10345. for ( i = 0; i < valsLength; i += 1 ) {
  10346. this._change( null, i );
  10347. }
  10348. this._animateOff = false;
  10349. break;
  10350. case "step":
  10351. case "min":
  10352. case "max":
  10353. this._animateOff = true;
  10354. this._calculateNewMax();
  10355. this._refreshValue();
  10356. this._animateOff = false;
  10357. break;
  10358. case "range":
  10359. this._animateOff = true;
  10360. this._refresh();
  10361. this._animateOff = false;
  10362. break;
  10363. }
  10364. },
  10365. //internal value getter
  10366. // _value() returns value trimmed by min and max, aligned by step
  10367. _value: function() {
  10368. var val = this.options.value;
  10369. val = this._trimAlignValue( val );
  10370. return val;
  10371. },
  10372. //internal values getter
  10373. // _values() returns array of values trimmed by min and max, aligned by step
  10374. // _values( index ) returns single value trimmed by min and max, aligned by step
  10375. _values: function( index ) {
  10376. var val,
  10377. vals,
  10378. i;
  10379. if ( arguments.length ) {
  10380. val = this.options.values[ index ];
  10381. val = this._trimAlignValue( val );
  10382. return val;
  10383. } else if ( this.options.values && this.options.values.length ) {
  10384. // .slice() creates a copy of the array
  10385. // this copy gets trimmed by min and max and then returned
  10386. vals = this.options.values.slice();
  10387. for ( i = 0; i < vals.length; i += 1) {
  10388. vals[ i ] = this._trimAlignValue( vals[ i ] );
  10389. }
  10390. return vals;
  10391. } else {
  10392. return [];
  10393. }
  10394. },
  10395. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  10396. _trimAlignValue: function( val ) {
  10397. if ( val <= this._valueMin() ) {
  10398. return this._valueMin();
  10399. }
  10400. if ( val >= this._valueMax() ) {
  10401. return this._valueMax();
  10402. }
  10403. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  10404. valModStep = (val - this._valueMin()) % step,
  10405. alignValue = val - valModStep;
  10406. if ( Math.abs(valModStep) * 2 >= step ) {
  10407. alignValue += ( valModStep > 0 ) ? step : ( -step );
  10408. }
  10409. // Since JavaScript has problems with large floats, round
  10410. // the final value to 5 digits after the decimal point (see #4124)
  10411. return parseFloat( alignValue.toFixed(5) );
  10412. },
  10413. _calculateNewMax: function() {
  10414. var max = this.options.max,
  10415. min = this._valueMin(),
  10416. step = this.options.step,
  10417. aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step;
  10418. max = aboveMin + min;
  10419. this.max = parseFloat( max.toFixed( this._precision() ) );
  10420. },
  10421. _precision: function() {
  10422. var precision = this._precisionOf( this.options.step );
  10423. if ( this.options.min !== null ) {
  10424. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  10425. }
  10426. return precision;
  10427. },
  10428. _precisionOf: function( num ) {
  10429. var str = num.toString(),
  10430. decimal = str.indexOf( "." );
  10431. return decimal === -1 ? 0 : str.length - decimal - 1;
  10432. },
  10433. _valueMin: function() {
  10434. return this.options.min;
  10435. },
  10436. _valueMax: function() {
  10437. return this.max;
  10438. },
  10439. _refreshValue: function() {
  10440. var lastValPercent, valPercent, value, valueMin, valueMax,
  10441. oRange = this.options.range,
  10442. o = this.options,
  10443. that = this,
  10444. animate = ( !this._animateOff ) ? o.animate : false,
  10445. _set = {};
  10446. if ( this.options.values && this.options.values.length ) {
  10447. this.handles.each(function( i ) {
  10448. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  10449. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10450. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10451. if ( that.options.range === true ) {
  10452. if ( that.orientation === "horizontal" ) {
  10453. if ( i === 0 ) {
  10454. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  10455. }
  10456. if ( i === 1 ) {
  10457. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10458. }
  10459. } else {
  10460. if ( i === 0 ) {
  10461. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  10462. }
  10463. if ( i === 1 ) {
  10464. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10465. }
  10466. }
  10467. }
  10468. lastValPercent = valPercent;
  10469. });
  10470. } else {
  10471. value = this.value();
  10472. valueMin = this._valueMin();
  10473. valueMax = this._valueMax();
  10474. valPercent = ( valueMax !== valueMin ) ?
  10475. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  10476. 0;
  10477. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10478. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10479. if ( oRange === "min" && this.orientation === "horizontal" ) {
  10480. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  10481. }
  10482. if ( oRange === "max" && this.orientation === "horizontal" ) {
  10483. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10484. }
  10485. if ( oRange === "min" && this.orientation === "vertical" ) {
  10486. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  10487. }
  10488. if ( oRange === "max" && this.orientation === "vertical" ) {
  10489. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10490. }
  10491. }
  10492. },
  10493. _handleEvents: {
  10494. keydown: function( event ) {
  10495. var allowed, curVal, newVal, step,
  10496. index = $( event.target ).data( "ui-slider-handle-index" );
  10497. switch ( event.keyCode ) {
  10498. case $.ui.keyCode.HOME:
  10499. case $.ui.keyCode.END:
  10500. case $.ui.keyCode.PAGE_UP:
  10501. case $.ui.keyCode.PAGE_DOWN:
  10502. case $.ui.keyCode.UP:
  10503. case $.ui.keyCode.RIGHT:
  10504. case $.ui.keyCode.DOWN:
  10505. case $.ui.keyCode.LEFT:
  10506. event.preventDefault();
  10507. if ( !this._keySliding ) {
  10508. this._keySliding = true;
  10509. $( event.target ).addClass( "ui-state-active" );
  10510. allowed = this._start( event, index );
  10511. if ( allowed === false ) {
  10512. return;
  10513. }
  10514. }
  10515. break;
  10516. }
  10517. step = this.options.step;
  10518. if ( this.options.values && this.options.values.length ) {
  10519. curVal = newVal = this.values( index );
  10520. } else {
  10521. curVal = newVal = this.value();
  10522. }
  10523. switch ( event.keyCode ) {
  10524. case $.ui.keyCode.HOME:
  10525. newVal = this._valueMin();
  10526. break;
  10527. case $.ui.keyCode.END:
  10528. newVal = this._valueMax();
  10529. break;
  10530. case $.ui.keyCode.PAGE_UP:
  10531. newVal = this._trimAlignValue(
  10532. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  10533. );
  10534. break;
  10535. case $.ui.keyCode.PAGE_DOWN:
  10536. newVal = this._trimAlignValue(
  10537. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  10538. break;
  10539. case $.ui.keyCode.UP:
  10540. case $.ui.keyCode.RIGHT:
  10541. if ( curVal === this._valueMax() ) {
  10542. return;
  10543. }
  10544. newVal = this._trimAlignValue( curVal + step );
  10545. break;
  10546. case $.ui.keyCode.DOWN:
  10547. case $.ui.keyCode.LEFT:
  10548. if ( curVal === this._valueMin() ) {
  10549. return;
  10550. }
  10551. newVal = this._trimAlignValue( curVal - step );
  10552. break;
  10553. }
  10554. this._slide( event, index, newVal );
  10555. },
  10556. keyup: function( event ) {
  10557. var index = $( event.target ).data( "ui-slider-handle-index" );
  10558. if ( this._keySliding ) {
  10559. this._keySliding = false;
  10560. this._stop( event, index );
  10561. this._change( event, index );
  10562. $( event.target ).removeClass( "ui-state-active" );
  10563. }
  10564. }
  10565. }
  10566. });
  10567. /*!
  10568. * jQuery UI Spinner 1.11.4
  10569. * http://jqueryui.com
  10570. *
  10571. * Copyright jQuery Foundation and other contributors
  10572. * Released under the MIT license.
  10573. * http://jquery.org/license
  10574. *
  10575. * http://api.jqueryui.com/spinner/
  10576. */
  10577. function spinner_modifier( fn ) {
  10578. return function() {
  10579. var previous = this.element.val();
  10580. fn.apply( this, arguments );
  10581. this._refresh();
  10582. if ( previous !== this.element.val() ) {
  10583. this._trigger( "change" );
  10584. }
  10585. };
  10586. }
  10587. var spinner = $.widget( "ui.spinner", {
  10588. version: "1.11.4",
  10589. defaultElement: "<input>",
  10590. widgetEventPrefix: "spin",
  10591. options: {
  10592. culture: null,
  10593. icons: {
  10594. down: "ui-icon-triangle-1-s",
  10595. up: "ui-icon-triangle-1-n"
  10596. },
  10597. incremental: true,
  10598. max: null,
  10599. min: null,
  10600. numberFormat: null,
  10601. page: 10,
  10602. step: 1,
  10603. change: null,
  10604. spin: null,
  10605. start: null,
  10606. stop: null
  10607. },
  10608. _create: function() {
  10609. // handle string values that need to be parsed
  10610. this._setOption( "max", this.options.max );
  10611. this._setOption( "min", this.options.min );
  10612. this._setOption( "step", this.options.step );
  10613. // Only format if there is a value, prevents the field from being marked
  10614. // as invalid in Firefox, see #9573.
  10615. if ( this.value() !== "" ) {
  10616. // Format the value, but don't constrain.
  10617. this._value( this.element.val(), true );
  10618. }
  10619. this._draw();
  10620. this._on( this._events );
  10621. this._refresh();
  10622. // turning off autocomplete prevents the browser from remembering the
  10623. // value when navigating through history, so we re-enable autocomplete
  10624. // if the page is unloaded before the widget is destroyed. #7790
  10625. this._on( this.window, {
  10626. beforeunload: function() {
  10627. this.element.removeAttr( "autocomplete" );
  10628. }
  10629. });
  10630. },
  10631. _getCreateOptions: function() {
  10632. var options = {},
  10633. element = this.element;
  10634. $.each( [ "min", "max", "step" ], function( i, option ) {
  10635. var value = element.attr( option );
  10636. if ( value !== undefined && value.length ) {
  10637. options[ option ] = value;
  10638. }
  10639. });
  10640. return options;
  10641. },
  10642. _events: {
  10643. keydown: function( event ) {
  10644. if ( this._start( event ) && this._keydown( event ) ) {
  10645. event.preventDefault();
  10646. }
  10647. },
  10648. keyup: "_stop",
  10649. focus: function() {
  10650. this.previous = this.element.val();
  10651. },
  10652. blur: function( event ) {
  10653. if ( this.cancelBlur ) {
  10654. delete this.cancelBlur;
  10655. return;
  10656. }
  10657. this._stop();
  10658. this._refresh();
  10659. if ( this.previous !== this.element.val() ) {
  10660. this._trigger( "change", event );
  10661. }
  10662. },
  10663. mousewheel: function( event, delta ) {
  10664. if ( !delta ) {
  10665. return;
  10666. }
  10667. if ( !this.spinning && !this._start( event ) ) {
  10668. return false;
  10669. }
  10670. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  10671. clearTimeout( this.mousewheelTimer );
  10672. this.mousewheelTimer = this._delay(function() {
  10673. if ( this.spinning ) {
  10674. this._stop( event );
  10675. }
  10676. }, 100 );
  10677. event.preventDefault();
  10678. },
  10679. "mousedown .ui-spinner-button": function( event ) {
  10680. var previous;
  10681. // We never want the buttons to have focus; whenever the user is
  10682. // interacting with the spinner, the focus should be on the input.
  10683. // If the input is focused then this.previous is properly set from
  10684. // when the input first received focus. If the input is not focused
  10685. // then we need to set this.previous based on the value before spinning.
  10686. previous = this.element[0] === this.document[0].activeElement ?
  10687. this.previous : this.element.val();
  10688. function checkFocus() {
  10689. var isActive = this.element[0] === this.document[0].activeElement;
  10690. if ( !isActive ) {
  10691. this.element.focus();
  10692. this.previous = previous;
  10693. // support: IE
  10694. // IE sets focus asynchronously, so we need to check if focus
  10695. // moved off of the input because the user clicked on the button.
  10696. this._delay(function() {
  10697. this.previous = previous;
  10698. });
  10699. }
  10700. }
  10701. // ensure focus is on (or stays on) the text field
  10702. event.preventDefault();
  10703. checkFocus.call( this );
  10704. // support: IE
  10705. // IE doesn't prevent moving focus even with event.preventDefault()
  10706. // so we set a flag to know when we should ignore the blur event
  10707. // and check (again) if focus moved off of the input.
  10708. this.cancelBlur = true;
  10709. this._delay(function() {
  10710. delete this.cancelBlur;
  10711. checkFocus.call( this );
  10712. });
  10713. if ( this._start( event ) === false ) {
  10714. return;
  10715. }
  10716. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10717. },
  10718. "mouseup .ui-spinner-button": "_stop",
  10719. "mouseenter .ui-spinner-button": function( event ) {
  10720. // button will add ui-state-active if mouse was down while mouseleave and kept down
  10721. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  10722. return;
  10723. }
  10724. if ( this._start( event ) === false ) {
  10725. return false;
  10726. }
  10727. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10728. },
  10729. // TODO: do we really want to consider this a stop?
  10730. // shouldn't we just stop the repeater and wait until mouseup before
  10731. // we trigger the stop event?
  10732. "mouseleave .ui-spinner-button": "_stop"
  10733. },
  10734. _draw: function() {
  10735. var uiSpinner = this.uiSpinner = this.element
  10736. .addClass( "ui-spinner-input" )
  10737. .attr( "autocomplete", "off" )
  10738. .wrap( this._uiSpinnerHtml() )
  10739. .parent()
  10740. // add buttons
  10741. .append( this._buttonHtml() );
  10742. this.element.attr( "role", "spinbutton" );
  10743. // button bindings
  10744. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  10745. .attr( "tabIndex", -1 )
  10746. .button()
  10747. .removeClass( "ui-corner-all" );
  10748. // IE 6 doesn't understand height: 50% for the buttons
  10749. // unless the wrapper has an explicit height
  10750. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  10751. uiSpinner.height() > 0 ) {
  10752. uiSpinner.height( uiSpinner.height() );
  10753. }
  10754. // disable spinner if element was already disabled
  10755. if ( this.options.disabled ) {
  10756. this.disable();
  10757. }
  10758. },
  10759. _keydown: function( event ) {
  10760. var options = this.options,
  10761. keyCode = $.ui.keyCode;
  10762. switch ( event.keyCode ) {
  10763. case keyCode.UP:
  10764. this._repeat( null, 1, event );
  10765. return true;
  10766. case keyCode.DOWN:
  10767. this._repeat( null, -1, event );
  10768. return true;
  10769. case keyCode.PAGE_UP:
  10770. this._repeat( null, options.page, event );
  10771. return true;
  10772. case keyCode.PAGE_DOWN:
  10773. this._repeat( null, -options.page, event );
  10774. return true;
  10775. }
  10776. return false;
  10777. },
  10778. _uiSpinnerHtml: function() {
  10779. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  10780. },
  10781. _buttonHtml: function() {
  10782. return "" +
  10783. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  10784. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  10785. "</a>" +
  10786. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  10787. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  10788. "</a>";
  10789. },
  10790. _start: function( event ) {
  10791. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  10792. return false;
  10793. }
  10794. if ( !this.counter ) {
  10795. this.counter = 1;
  10796. }
  10797. this.spinning = true;
  10798. return true;
  10799. },
  10800. _repeat: function( i, steps, event ) {
  10801. i = i || 500;
  10802. clearTimeout( this.timer );
  10803. this.timer = this._delay(function() {
  10804. this._repeat( 40, steps, event );
  10805. }, i );
  10806. this._spin( steps * this.options.step, event );
  10807. },
  10808. _spin: function( step, event ) {
  10809. var value = this.value() || 0;
  10810. if ( !this.counter ) {
  10811. this.counter = 1;
  10812. }
  10813. value = this._adjustValue( value + step * this._increment( this.counter ) );
  10814. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  10815. this._value( value );
  10816. this.counter++;
  10817. }
  10818. },
  10819. _increment: function( i ) {
  10820. var incremental = this.options.incremental;
  10821. if ( incremental ) {
  10822. return $.isFunction( incremental ) ?
  10823. incremental( i ) :
  10824. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  10825. }
  10826. return 1;
  10827. },
  10828. _precision: function() {
  10829. var precision = this._precisionOf( this.options.step );
  10830. if ( this.options.min !== null ) {
  10831. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  10832. }
  10833. return precision;
  10834. },
  10835. _precisionOf: function( num ) {
  10836. var str = num.toString(),
  10837. decimal = str.indexOf( "." );
  10838. return decimal === -1 ? 0 : str.length - decimal - 1;
  10839. },
  10840. _adjustValue: function( value ) {
  10841. var base, aboveMin,
  10842. options = this.options;
  10843. // make sure we're at a valid step
  10844. // - find out where we are relative to the base (min or 0)
  10845. base = options.min !== null ? options.min : 0;
  10846. aboveMin = value - base;
  10847. // - round to the nearest step
  10848. aboveMin = Math.round(aboveMin / options.step) * options.step;
  10849. // - rounding is based on 0, so adjust back to our base
  10850. value = base + aboveMin;
  10851. // fix precision from bad JS floating point math
  10852. value = parseFloat( value.toFixed( this._precision() ) );
  10853. // clamp the value
  10854. if ( options.max !== null && value > options.max) {
  10855. return options.max;
  10856. }
  10857. if ( options.min !== null && value < options.min ) {
  10858. return options.min;
  10859. }
  10860. return value;
  10861. },
  10862. _stop: function( event ) {
  10863. if ( !this.spinning ) {
  10864. return;
  10865. }
  10866. clearTimeout( this.timer );
  10867. clearTimeout( this.mousewheelTimer );
  10868. this.counter = 0;
  10869. this.spinning = false;
  10870. this._trigger( "stop", event );
  10871. },
  10872. _setOption: function( key, value ) {
  10873. if ( key === "culture" || key === "numberFormat" ) {
  10874. var prevValue = this._parse( this.element.val() );
  10875. this.options[ key ] = value;
  10876. this.element.val( this._format( prevValue ) );
  10877. return;
  10878. }
  10879. if ( key === "max" || key === "min" || key === "step" ) {
  10880. if ( typeof value === "string" ) {
  10881. value = this._parse( value );
  10882. }
  10883. }
  10884. if ( key === "icons" ) {
  10885. this.buttons.first().find( ".ui-icon" )
  10886. .removeClass( this.options.icons.up )
  10887. .addClass( value.up );
  10888. this.buttons.last().find( ".ui-icon" )
  10889. .removeClass( this.options.icons.down )
  10890. .addClass( value.down );
  10891. }
  10892. this._super( key, value );
  10893. if ( key === "disabled" ) {
  10894. this.widget().toggleClass( "ui-state-disabled", !!value );
  10895. this.element.prop( "disabled", !!value );
  10896. this.buttons.button( value ? "disable" : "enable" );
  10897. }
  10898. },
  10899. _setOptions: spinner_modifier(function( options ) {
  10900. this._super( options );
  10901. }),
  10902. _parse: function( val ) {
  10903. if ( typeof val === "string" && val !== "" ) {
  10904. val = window.Globalize && this.options.numberFormat ?
  10905. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  10906. }
  10907. return val === "" || isNaN( val ) ? null : val;
  10908. },
  10909. _format: function( value ) {
  10910. if ( value === "" ) {
  10911. return "";
  10912. }
  10913. return window.Globalize && this.options.numberFormat ?
  10914. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  10915. value;
  10916. },
  10917. _refresh: function() {
  10918. this.element.attr({
  10919. "aria-valuemin": this.options.min,
  10920. "aria-valuemax": this.options.max,
  10921. // TODO: what should we do with values that can't be parsed?
  10922. "aria-valuenow": this._parse( this.element.val() )
  10923. });
  10924. },
  10925. isValid: function() {
  10926. var value = this.value();
  10927. // null is invalid
  10928. if ( value === null ) {
  10929. return false;
  10930. }
  10931. // if value gets adjusted, it's invalid
  10932. return value === this._adjustValue( value );
  10933. },
  10934. // update the value without triggering change
  10935. _value: function( value, allowAny ) {
  10936. var parsed;
  10937. if ( value !== "" ) {
  10938. parsed = this._parse( value );
  10939. if ( parsed !== null ) {
  10940. if ( !allowAny ) {
  10941. parsed = this._adjustValue( parsed );
  10942. }
  10943. value = this._format( parsed );
  10944. }
  10945. }
  10946. this.element.val( value );
  10947. this._refresh();
  10948. },
  10949. _destroy: function() {
  10950. this.element
  10951. .removeClass( "ui-spinner-input" )
  10952. .prop( "disabled", false )
  10953. .removeAttr( "autocomplete" )
  10954. .removeAttr( "role" )
  10955. .removeAttr( "aria-valuemin" )
  10956. .removeAttr( "aria-valuemax" )
  10957. .removeAttr( "aria-valuenow" );
  10958. this.uiSpinner.replaceWith( this.element );
  10959. },
  10960. stepUp: spinner_modifier(function( steps ) {
  10961. this._stepUp( steps );
  10962. }),
  10963. _stepUp: function( steps ) {
  10964. if ( this._start() ) {
  10965. this._spin( (steps || 1) * this.options.step );
  10966. this._stop();
  10967. }
  10968. },
  10969. stepDown: spinner_modifier(function( steps ) {
  10970. this._stepDown( steps );
  10971. }),
  10972. _stepDown: function( steps ) {
  10973. if ( this._start() ) {
  10974. this._spin( (steps || 1) * -this.options.step );
  10975. this._stop();
  10976. }
  10977. },
  10978. pageUp: spinner_modifier(function( pages ) {
  10979. this._stepUp( (pages || 1) * this.options.page );
  10980. }),
  10981. pageDown: spinner_modifier(function( pages ) {
  10982. this._stepDown( (pages || 1) * this.options.page );
  10983. }),
  10984. value: function( newVal ) {
  10985. if ( !arguments.length ) {
  10986. return this._parse( this.element.val() );
  10987. }
  10988. spinner_modifier( this._value ).call( this, newVal );
  10989. },
  10990. widget: function() {
  10991. return this.uiSpinner;
  10992. }
  10993. });
  10994. /*!
  10995. * jQuery UI Tabs 1.11.4
  10996. * http://jqueryui.com
  10997. *
  10998. * Copyright jQuery Foundation and other contributors
  10999. * Released under the MIT license.
  11000. * http://jquery.org/license
  11001. *
  11002. * http://api.jqueryui.com/tabs/
  11003. */
  11004. var tabs = $.widget( "ui.tabs", {
  11005. version: "1.11.4",
  11006. delay: 300,
  11007. options: {
  11008. active: null,
  11009. collapsible: false,
  11010. event: "click",
  11011. heightStyle: "content",
  11012. hide: null,
  11013. show: null,
  11014. // callbacks
  11015. activate: null,
  11016. beforeActivate: null,
  11017. beforeLoad: null,
  11018. load: null
  11019. },
  11020. _isLocal: (function() {
  11021. var rhash = /#.*$/;
  11022. return function( anchor ) {
  11023. var anchorUrl, locationUrl;
  11024. // support: IE7
  11025. // IE7 doesn't normalize the href property when set via script (#9317)
  11026. anchor = anchor.cloneNode( false );
  11027. anchorUrl = anchor.href.replace( rhash, "" );
  11028. locationUrl = location.href.replace( rhash, "" );
  11029. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  11030. try {
  11031. anchorUrl = decodeURIComponent( anchorUrl );
  11032. } catch ( error ) {}
  11033. try {
  11034. locationUrl = decodeURIComponent( locationUrl );
  11035. } catch ( error ) {}
  11036. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  11037. };
  11038. })(),
  11039. _create: function() {
  11040. var that = this,
  11041. options = this.options;
  11042. this.running = false;
  11043. this.element
  11044. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11045. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  11046. this._processTabs();
  11047. options.active = this._initialActive();
  11048. // Take disabling tabs via class attribute from HTML
  11049. // into account and update option properly.
  11050. if ( $.isArray( options.disabled ) ) {
  11051. options.disabled = $.unique( options.disabled.concat(
  11052. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11053. return that.tabs.index( li );
  11054. })
  11055. ) ).sort();
  11056. }
  11057. // check for length avoids error when initializing empty list
  11058. if ( this.options.active !== false && this.anchors.length ) {
  11059. this.active = this._findActive( options.active );
  11060. } else {
  11061. this.active = $();
  11062. }
  11063. this._refresh();
  11064. if ( this.active.length ) {
  11065. this.load( options.active );
  11066. }
  11067. },
  11068. _initialActive: function() {
  11069. var active = this.options.active,
  11070. collapsible = this.options.collapsible,
  11071. locationHash = location.hash.substring( 1 );
  11072. if ( active === null ) {
  11073. // check the fragment identifier in the URL
  11074. if ( locationHash ) {
  11075. this.tabs.each(function( i, tab ) {
  11076. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11077. active = i;
  11078. return false;
  11079. }
  11080. });
  11081. }
  11082. // check for a tab marked active via a class
  11083. if ( active === null ) {
  11084. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11085. }
  11086. // no active tab, set to false
  11087. if ( active === null || active === -1 ) {
  11088. active = this.tabs.length ? 0 : false;
  11089. }
  11090. }
  11091. // handle numbers: negative, out of range
  11092. if ( active !== false ) {
  11093. active = this.tabs.index( this.tabs.eq( active ) );
  11094. if ( active === -1 ) {
  11095. active = collapsible ? false : 0;
  11096. }
  11097. }
  11098. // don't allow collapsible: false and active: false
  11099. if ( !collapsible && active === false && this.anchors.length ) {
  11100. active = 0;
  11101. }
  11102. return active;
  11103. },
  11104. _getCreateEventData: function() {
  11105. return {
  11106. tab: this.active,
  11107. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11108. };
  11109. },
  11110. _tabKeydown: function( event ) {
  11111. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11112. selectedIndex = this.tabs.index( focusedTab ),
  11113. goingForward = true;
  11114. if ( this._handlePageNav( event ) ) {
  11115. return;
  11116. }
  11117. switch ( event.keyCode ) {
  11118. case $.ui.keyCode.RIGHT:
  11119. case $.ui.keyCode.DOWN:
  11120. selectedIndex++;
  11121. break;
  11122. case $.ui.keyCode.UP:
  11123. case $.ui.keyCode.LEFT:
  11124. goingForward = false;
  11125. selectedIndex--;
  11126. break;
  11127. case $.ui.keyCode.END:
  11128. selectedIndex = this.anchors.length - 1;
  11129. break;
  11130. case $.ui.keyCode.HOME:
  11131. selectedIndex = 0;
  11132. break;
  11133. case $.ui.keyCode.SPACE:
  11134. // Activate only, no collapsing
  11135. event.preventDefault();
  11136. clearTimeout( this.activating );
  11137. this._activate( selectedIndex );
  11138. return;
  11139. case $.ui.keyCode.ENTER:
  11140. // Toggle (cancel delayed activation, allow collapsing)
  11141. event.preventDefault();
  11142. clearTimeout( this.activating );
  11143. // Determine if we should collapse or activate
  11144. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11145. return;
  11146. default:
  11147. return;
  11148. }
  11149. // Focus the appropriate tab, based on which key was pressed
  11150. event.preventDefault();
  11151. clearTimeout( this.activating );
  11152. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11153. // Navigating with control/command key will prevent automatic activation
  11154. if ( !event.ctrlKey && !event.metaKey ) {
  11155. // Update aria-selected immediately so that AT think the tab is already selected.
  11156. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11157. // but the tab will already be activated by the time the announcement finishes.
  11158. focusedTab.attr( "aria-selected", "false" );
  11159. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11160. this.activating = this._delay(function() {
  11161. this.option( "active", selectedIndex );
  11162. }, this.delay );
  11163. }
  11164. },
  11165. _panelKeydown: function( event ) {
  11166. if ( this._handlePageNav( event ) ) {
  11167. return;
  11168. }
  11169. // Ctrl+up moves focus to the current tab
  11170. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11171. event.preventDefault();
  11172. this.active.focus();
  11173. }
  11174. },
  11175. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11176. _handlePageNav: function( event ) {
  11177. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11178. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11179. return true;
  11180. }
  11181. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11182. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11183. return true;
  11184. }
  11185. },
  11186. _findNextTab: function( index, goingForward ) {
  11187. var lastTabIndex = this.tabs.length - 1;
  11188. function constrain() {
  11189. if ( index > lastTabIndex ) {
  11190. index = 0;
  11191. }
  11192. if ( index < 0 ) {
  11193. index = lastTabIndex;
  11194. }
  11195. return index;
  11196. }
  11197. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11198. index = goingForward ? index + 1 : index - 1;
  11199. }
  11200. return index;
  11201. },
  11202. _focusNextTab: function( index, goingForward ) {
  11203. index = this._findNextTab( index, goingForward );
  11204. this.tabs.eq( index ).focus();
  11205. return index;
  11206. },
  11207. _setOption: function( key, value ) {
  11208. if ( key === "active" ) {
  11209. // _activate() will handle invalid values and update this.options
  11210. this._activate( value );
  11211. return;
  11212. }
  11213. if ( key === "disabled" ) {
  11214. // don't use the widget factory's disabled handling
  11215. this._setupDisabled( value );
  11216. return;
  11217. }
  11218. this._super( key, value);
  11219. if ( key === "collapsible" ) {
  11220. this.element.toggleClass( "ui-tabs-collapsible", value );
  11221. // Setting collapsible: false while collapsed; open first panel
  11222. if ( !value && this.options.active === false ) {
  11223. this._activate( 0 );
  11224. }
  11225. }
  11226. if ( key === "event" ) {
  11227. this._setupEvents( value );
  11228. }
  11229. if ( key === "heightStyle" ) {
  11230. this._setupHeightStyle( value );
  11231. }
  11232. },
  11233. _sanitizeSelector: function( hash ) {
  11234. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  11235. },
  11236. refresh: function() {
  11237. var options = this.options,
  11238. lis = this.tablist.children( ":has(a[href])" );
  11239. // get disabled tabs from class attribute from HTML
  11240. // this will get converted to a boolean if needed in _refresh()
  11241. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  11242. return lis.index( tab );
  11243. });
  11244. this._processTabs();
  11245. // was collapsed or no tabs
  11246. if ( options.active === false || !this.anchors.length ) {
  11247. options.active = false;
  11248. this.active = $();
  11249. // was active, but active tab is gone
  11250. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  11251. // all remaining tabs are disabled
  11252. if ( this.tabs.length === options.disabled.length ) {
  11253. options.active = false;
  11254. this.active = $();
  11255. // activate previous tab
  11256. } else {
  11257. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  11258. }
  11259. // was active, active tab still exists
  11260. } else {
  11261. // make sure active index is correct
  11262. options.active = this.tabs.index( this.active );
  11263. }
  11264. this._refresh();
  11265. },
  11266. _refresh: function() {
  11267. this._setupDisabled( this.options.disabled );
  11268. this._setupEvents( this.options.event );
  11269. this._setupHeightStyle( this.options.heightStyle );
  11270. this.tabs.not( this.active ).attr({
  11271. "aria-selected": "false",
  11272. "aria-expanded": "false",
  11273. tabIndex: -1
  11274. });
  11275. this.panels.not( this._getPanelForTab( this.active ) )
  11276. .hide()
  11277. .attr({
  11278. "aria-hidden": "true"
  11279. });
  11280. // Make sure one tab is in the tab order
  11281. if ( !this.active.length ) {
  11282. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  11283. } else {
  11284. this.active
  11285. .addClass( "ui-tabs-active ui-state-active" )
  11286. .attr({
  11287. "aria-selected": "true",
  11288. "aria-expanded": "true",
  11289. tabIndex: 0
  11290. });
  11291. this._getPanelForTab( this.active )
  11292. .show()
  11293. .attr({
  11294. "aria-hidden": "false"
  11295. });
  11296. }
  11297. },
  11298. _processTabs: function() {
  11299. var that = this,
  11300. prevTabs = this.tabs,
  11301. prevAnchors = this.anchors,
  11302. prevPanels = this.panels;
  11303. this.tablist = this._getList()
  11304. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11305. .attr( "role", "tablist" )
  11306. // Prevent users from focusing disabled tabs via click
  11307. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  11308. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11309. event.preventDefault();
  11310. }
  11311. })
  11312. // support: IE <9
  11313. // Preventing the default action in mousedown doesn't prevent IE
  11314. // from focusing the element, so if the anchor gets focused, blur.
  11315. // We don't have to worry about focusing the previously focused
  11316. // element since clicking on a non-focusable element should focus
  11317. // the body anyway.
  11318. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11319. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11320. this.blur();
  11321. }
  11322. });
  11323. this.tabs = this.tablist.find( "> li:has(a[href])" )
  11324. .addClass( "ui-state-default ui-corner-top" )
  11325. .attr({
  11326. role: "tab",
  11327. tabIndex: -1
  11328. });
  11329. this.anchors = this.tabs.map(function() {
  11330. return $( "a", this )[ 0 ];
  11331. })
  11332. .addClass( "ui-tabs-anchor" )
  11333. .attr({
  11334. role: "presentation",
  11335. tabIndex: -1
  11336. });
  11337. this.panels = $();
  11338. this.anchors.each(function( i, anchor ) {
  11339. var selector, panel, panelId,
  11340. anchorId = $( anchor ).uniqueId().attr( "id" ),
  11341. tab = $( anchor ).closest( "li" ),
  11342. originalAriaControls = tab.attr( "aria-controls" );
  11343. // inline tab
  11344. if ( that._isLocal( anchor ) ) {
  11345. selector = anchor.hash;
  11346. panelId = selector.substring( 1 );
  11347. panel = that.element.find( that._sanitizeSelector( selector ) );
  11348. // remote tab
  11349. } else {
  11350. // If the tab doesn't already have aria-controls,
  11351. // generate an id by using a throw-away element
  11352. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  11353. selector = "#" + panelId;
  11354. panel = that.element.find( selector );
  11355. if ( !panel.length ) {
  11356. panel = that._createPanel( panelId );
  11357. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  11358. }
  11359. panel.attr( "aria-live", "polite" );
  11360. }
  11361. if ( panel.length) {
  11362. that.panels = that.panels.add( panel );
  11363. }
  11364. if ( originalAriaControls ) {
  11365. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  11366. }
  11367. tab.attr({
  11368. "aria-controls": panelId,
  11369. "aria-labelledby": anchorId
  11370. });
  11371. panel.attr( "aria-labelledby", anchorId );
  11372. });
  11373. this.panels
  11374. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11375. .attr( "role", "tabpanel" );
  11376. // Avoid memory leaks (#10056)
  11377. if ( prevTabs ) {
  11378. this._off( prevTabs.not( this.tabs ) );
  11379. this._off( prevAnchors.not( this.anchors ) );
  11380. this._off( prevPanels.not( this.panels ) );
  11381. }
  11382. },
  11383. // allow overriding how to find the list for rare usage scenarios (#7715)
  11384. _getList: function() {
  11385. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  11386. },
  11387. _createPanel: function( id ) {
  11388. return $( "<div>" )
  11389. .attr( "id", id )
  11390. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11391. .data( "ui-tabs-destroy", true );
  11392. },
  11393. _setupDisabled: function( disabled ) {
  11394. if ( $.isArray( disabled ) ) {
  11395. if ( !disabled.length ) {
  11396. disabled = false;
  11397. } else if ( disabled.length === this.anchors.length ) {
  11398. disabled = true;
  11399. }
  11400. }
  11401. // disable tabs
  11402. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  11403. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  11404. $( li )
  11405. .addClass( "ui-state-disabled" )
  11406. .attr( "aria-disabled", "true" );
  11407. } else {
  11408. $( li )
  11409. .removeClass( "ui-state-disabled" )
  11410. .removeAttr( "aria-disabled" );
  11411. }
  11412. }
  11413. this.options.disabled = disabled;
  11414. },
  11415. _setupEvents: function( event ) {
  11416. var events = {};
  11417. if ( event ) {
  11418. $.each( event.split(" "), function( index, eventName ) {
  11419. events[ eventName ] = "_eventHandler";
  11420. });
  11421. }
  11422. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  11423. // Always prevent the default action, even when disabled
  11424. this._on( true, this.anchors, {
  11425. click: function( event ) {
  11426. event.preventDefault();
  11427. }
  11428. });
  11429. this._on( this.anchors, events );
  11430. this._on( this.tabs, { keydown: "_tabKeydown" } );
  11431. this._on( this.panels, { keydown: "_panelKeydown" } );
  11432. this._focusable( this.tabs );
  11433. this._hoverable( this.tabs );
  11434. },
  11435. _setupHeightStyle: function( heightStyle ) {
  11436. var maxHeight,
  11437. parent = this.element.parent();
  11438. if ( heightStyle === "fill" ) {
  11439. maxHeight = parent.height();
  11440. maxHeight -= this.element.outerHeight() - this.element.height();
  11441. this.element.siblings( ":visible" ).each(function() {
  11442. var elem = $( this ),
  11443. position = elem.css( "position" );
  11444. if ( position === "absolute" || position === "fixed" ) {
  11445. return;
  11446. }
  11447. maxHeight -= elem.outerHeight( true );
  11448. });
  11449. this.element.children().not( this.panels ).each(function() {
  11450. maxHeight -= $( this ).outerHeight( true );
  11451. });
  11452. this.panels.each(function() {
  11453. $( this ).height( Math.max( 0, maxHeight -
  11454. $( this ).innerHeight() + $( this ).height() ) );
  11455. })
  11456. .css( "overflow", "auto" );
  11457. } else if ( heightStyle === "auto" ) {
  11458. maxHeight = 0;
  11459. this.panels.each(function() {
  11460. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  11461. }).height( maxHeight );
  11462. }
  11463. },
  11464. _eventHandler: function( event ) {
  11465. var options = this.options,
  11466. active = this.active,
  11467. anchor = $( event.currentTarget ),
  11468. tab = anchor.closest( "li" ),
  11469. clickedIsActive = tab[ 0 ] === active[ 0 ],
  11470. collapsing = clickedIsActive && options.collapsible,
  11471. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  11472. toHide = !active.length ? $() : this._getPanelForTab( active ),
  11473. eventData = {
  11474. oldTab: active,
  11475. oldPanel: toHide,
  11476. newTab: collapsing ? $() : tab,
  11477. newPanel: toShow
  11478. };
  11479. event.preventDefault();
  11480. if ( tab.hasClass( "ui-state-disabled" ) ||
  11481. // tab is already loading
  11482. tab.hasClass( "ui-tabs-loading" ) ||
  11483. // can't switch durning an animation
  11484. this.running ||
  11485. // click on active header, but not collapsible
  11486. ( clickedIsActive && !options.collapsible ) ||
  11487. // allow canceling activation
  11488. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  11489. return;
  11490. }
  11491. options.active = collapsing ? false : this.tabs.index( tab );
  11492. this.active = clickedIsActive ? $() : tab;
  11493. if ( this.xhr ) {
  11494. this.xhr.abort();
  11495. }
  11496. if ( !toHide.length && !toShow.length ) {
  11497. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  11498. }
  11499. if ( toShow.length ) {
  11500. this.load( this.tabs.index( tab ), event );
  11501. }
  11502. this._toggle( event, eventData );
  11503. },
  11504. // handles show/hide for selecting tabs
  11505. _toggle: function( event, eventData ) {
  11506. var that = this,
  11507. toShow = eventData.newPanel,
  11508. toHide = eventData.oldPanel;
  11509. this.running = true;
  11510. function complete() {
  11511. that.running = false;
  11512. that._trigger( "activate", event, eventData );
  11513. }
  11514. function show() {
  11515. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  11516. if ( toShow.length && that.options.show ) {
  11517. that._show( toShow, that.options.show, complete );
  11518. } else {
  11519. toShow.show();
  11520. complete();
  11521. }
  11522. }
  11523. // start out by hiding, then showing, then completing
  11524. if ( toHide.length && this.options.hide ) {
  11525. this._hide( toHide, this.options.hide, function() {
  11526. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11527. show();
  11528. });
  11529. } else {
  11530. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11531. toHide.hide();
  11532. show();
  11533. }
  11534. toHide.attr( "aria-hidden", "true" );
  11535. eventData.oldTab.attr({
  11536. "aria-selected": "false",
  11537. "aria-expanded": "false"
  11538. });
  11539. // If we're switching tabs, remove the old tab from the tab order.
  11540. // If we're opening from collapsed state, remove the previous tab from the tab order.
  11541. // If we're collapsing, then keep the collapsing tab in the tab order.
  11542. if ( toShow.length && toHide.length ) {
  11543. eventData.oldTab.attr( "tabIndex", -1 );
  11544. } else if ( toShow.length ) {
  11545. this.tabs.filter(function() {
  11546. return $( this ).attr( "tabIndex" ) === 0;
  11547. })
  11548. .attr( "tabIndex", -1 );
  11549. }
  11550. toShow.attr( "aria-hidden", "false" );
  11551. eventData.newTab.attr({
  11552. "aria-selected": "true",
  11553. "aria-expanded": "true",
  11554. tabIndex: 0
  11555. });
  11556. },
  11557. _activate: function( index ) {
  11558. var anchor,
  11559. active = this._findActive( index );
  11560. // trying to activate the already active panel
  11561. if ( active[ 0 ] === this.active[ 0 ] ) {
  11562. return;
  11563. }
  11564. // trying to collapse, simulate a click on the current active header
  11565. if ( !active.length ) {
  11566. active = this.active;
  11567. }
  11568. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  11569. this._eventHandler({
  11570. target: anchor,
  11571. currentTarget: anchor,
  11572. preventDefault: $.noop
  11573. });
  11574. },
  11575. _findActive: function( index ) {
  11576. return index === false ? $() : this.tabs.eq( index );
  11577. },
  11578. _getIndex: function( index ) {
  11579. // meta-function to give users option to provide a href string instead of a numerical index.
  11580. if ( typeof index === "string" ) {
  11581. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  11582. }
  11583. return index;
  11584. },
  11585. _destroy: function() {
  11586. if ( this.xhr ) {
  11587. this.xhr.abort();
  11588. }
  11589. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  11590. this.tablist
  11591. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11592. .removeAttr( "role" );
  11593. this.anchors
  11594. .removeClass( "ui-tabs-anchor" )
  11595. .removeAttr( "role" )
  11596. .removeAttr( "tabIndex" )
  11597. .removeUniqueId();
  11598. this.tablist.unbind( this.eventNamespace );
  11599. this.tabs.add( this.panels ).each(function() {
  11600. if ( $.data( this, "ui-tabs-destroy" ) ) {
  11601. $( this ).remove();
  11602. } else {
  11603. $( this )
  11604. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  11605. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  11606. .removeAttr( "tabIndex" )
  11607. .removeAttr( "aria-live" )
  11608. .removeAttr( "aria-busy" )
  11609. .removeAttr( "aria-selected" )
  11610. .removeAttr( "aria-labelledby" )
  11611. .removeAttr( "aria-hidden" )
  11612. .removeAttr( "aria-expanded" )
  11613. .removeAttr( "role" );
  11614. }
  11615. });
  11616. this.tabs.each(function() {
  11617. var li = $( this ),
  11618. prev = li.data( "ui-tabs-aria-controls" );
  11619. if ( prev ) {
  11620. li
  11621. .attr( "aria-controls", prev )
  11622. .removeData( "ui-tabs-aria-controls" );
  11623. } else {
  11624. li.removeAttr( "aria-controls" );
  11625. }
  11626. });
  11627. this.panels.show();
  11628. if ( this.options.heightStyle !== "content" ) {
  11629. this.panels.css( "height", "" );
  11630. }
  11631. },
  11632. enable: function( index ) {
  11633. var disabled = this.options.disabled;
  11634. if ( disabled === false ) {
  11635. return;
  11636. }
  11637. if ( index === undefined ) {
  11638. disabled = false;
  11639. } else {
  11640. index = this._getIndex( index );
  11641. if ( $.isArray( disabled ) ) {
  11642. disabled = $.map( disabled, function( num ) {
  11643. return num !== index ? num : null;
  11644. });
  11645. } else {
  11646. disabled = $.map( this.tabs, function( li, num ) {
  11647. return num !== index ? num : null;
  11648. });
  11649. }
  11650. }
  11651. this._setupDisabled( disabled );
  11652. },
  11653. disable: function( index ) {
  11654. var disabled = this.options.disabled;
  11655. if ( disabled === true ) {
  11656. return;
  11657. }
  11658. if ( index === undefined ) {
  11659. disabled = true;
  11660. } else {
  11661. index = this._getIndex( index );
  11662. if ( $.inArray( index, disabled ) !== -1 ) {
  11663. return;
  11664. }
  11665. if ( $.isArray( disabled ) ) {
  11666. disabled = $.merge( [ index ], disabled ).sort();
  11667. } else {
  11668. disabled = [ index ];
  11669. }
  11670. }
  11671. this._setupDisabled( disabled );
  11672. },
  11673. load: function( index, event ) {
  11674. index = this._getIndex( index );
  11675. var that = this,
  11676. tab = this.tabs.eq( index ),
  11677. anchor = tab.find( ".ui-tabs-anchor" ),
  11678. panel = this._getPanelForTab( tab ),
  11679. eventData = {
  11680. tab: tab,
  11681. panel: panel
  11682. },
  11683. complete = function( jqXHR, status ) {
  11684. if ( status === "abort" ) {
  11685. that.panels.stop( false, true );
  11686. }
  11687. tab.removeClass( "ui-tabs-loading" );
  11688. panel.removeAttr( "aria-busy" );
  11689. if ( jqXHR === that.xhr ) {
  11690. delete that.xhr;
  11691. }
  11692. };
  11693. // not remote
  11694. if ( this._isLocal( anchor[ 0 ] ) ) {
  11695. return;
  11696. }
  11697. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  11698. // support: jQuery <1.8
  11699. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  11700. // but as of 1.8, $.ajax() always returns a jqXHR object.
  11701. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  11702. tab.addClass( "ui-tabs-loading" );
  11703. panel.attr( "aria-busy", "true" );
  11704. this.xhr
  11705. .done(function( response, status, jqXHR ) {
  11706. // support: jQuery <1.8
  11707. // http://bugs.jquery.com/ticket/11778
  11708. setTimeout(function() {
  11709. panel.html( response );
  11710. that._trigger( "load", event, eventData );
  11711. complete( jqXHR, status );
  11712. }, 1 );
  11713. })
  11714. .fail(function( jqXHR, status ) {
  11715. // support: jQuery <1.8
  11716. // http://bugs.jquery.com/ticket/11778
  11717. setTimeout(function() {
  11718. complete( jqXHR, status );
  11719. }, 1 );
  11720. });
  11721. }
  11722. },
  11723. _ajaxSettings: function( anchor, event, eventData ) {
  11724. var that = this;
  11725. return {
  11726. url: anchor.attr( "href" ),
  11727. beforeSend: function( jqXHR, settings ) {
  11728. return that._trigger( "beforeLoad", event,
  11729. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  11730. }
  11731. };
  11732. },
  11733. _getPanelForTab: function( tab ) {
  11734. var id = $( tab ).attr( "aria-controls" );
  11735. return this.element.find( this._sanitizeSelector( "#" + id ) );
  11736. }
  11737. });
  11738. /*!
  11739. * jQuery UI Tooltip 1.11.4
  11740. * http://jqueryui.com
  11741. *
  11742. * Copyright jQuery Foundation and other contributors
  11743. * Released under the MIT license.
  11744. * http://jquery.org/license
  11745. *
  11746. * http://api.jqueryui.com/tooltip/
  11747. */
  11748. var tooltip = $.widget( "ui.tooltip", {
  11749. version: "1.11.4",
  11750. options: {
  11751. content: function() {
  11752. // support: IE<9, Opera in jQuery <1.7
  11753. // .text() can't accept undefined, so coerce to a string
  11754. var title = $( this ).attr( "title" ) || "";
  11755. // Escape title, since we're going from an attribute to raw HTML
  11756. return $( "<a>" ).text( title ).html();
  11757. },
  11758. hide: true,
  11759. // Disabled elements have inconsistent behavior across browsers (#8661)
  11760. items: "[title]:not([disabled])",
  11761. position: {
  11762. my: "left top+15",
  11763. at: "left bottom",
  11764. collision: "flipfit flip"
  11765. },
  11766. show: true,
  11767. tooltipClass: null,
  11768. track: false,
  11769. // callbacks
  11770. close: null,
  11771. open: null
  11772. },
  11773. _addDescribedBy: function( elem, id ) {
  11774. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  11775. describedby.push( id );
  11776. elem
  11777. .data( "ui-tooltip-id", id )
  11778. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  11779. },
  11780. _removeDescribedBy: function( elem ) {
  11781. var id = elem.data( "ui-tooltip-id" ),
  11782. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  11783. index = $.inArray( id, describedby );
  11784. if ( index !== -1 ) {
  11785. describedby.splice( index, 1 );
  11786. }
  11787. elem.removeData( "ui-tooltip-id" );
  11788. describedby = $.trim( describedby.join( " " ) );
  11789. if ( describedby ) {
  11790. elem.attr( "aria-describedby", describedby );
  11791. } else {
  11792. elem.removeAttr( "aria-describedby" );
  11793. }
  11794. },
  11795. _create: function() {
  11796. this._on({
  11797. mouseover: "open",
  11798. focusin: "open"
  11799. });
  11800. // IDs of generated tooltips, needed for destroy
  11801. this.tooltips = {};
  11802. // IDs of parent tooltips where we removed the title attribute
  11803. this.parents = {};
  11804. if ( this.options.disabled ) {
  11805. this._disable();
  11806. }
  11807. // Append the aria-live region so tooltips announce correctly
  11808. this.liveRegion = $( "<div>" )
  11809. .attr({
  11810. role: "log",
  11811. "aria-live": "assertive",
  11812. "aria-relevant": "additions"
  11813. })
  11814. .addClass( "ui-helper-hidden-accessible" )
  11815. .appendTo( this.document[ 0 ].body );
  11816. },
  11817. _setOption: function( key, value ) {
  11818. var that = this;
  11819. if ( key === "disabled" ) {
  11820. this[ value ? "_disable" : "_enable" ]();
  11821. this.options[ key ] = value;
  11822. // disable element style changes
  11823. return;
  11824. }
  11825. this._super( key, value );
  11826. if ( key === "content" ) {
  11827. $.each( this.tooltips, function( id, tooltipData ) {
  11828. that._updateContent( tooltipData.element );
  11829. });
  11830. }
  11831. },
  11832. _disable: function() {
  11833. var that = this;
  11834. // close open tooltips
  11835. $.each( this.tooltips, function( id, tooltipData ) {
  11836. var event = $.Event( "blur" );
  11837. event.target = event.currentTarget = tooltipData.element[ 0 ];
  11838. that.close( event, true );
  11839. });
  11840. // remove title attributes to prevent native tooltips
  11841. this.element.find( this.options.items ).addBack().each(function() {
  11842. var element = $( this );
  11843. if ( element.is( "[title]" ) ) {
  11844. element
  11845. .data( "ui-tooltip-title", element.attr( "title" ) )
  11846. .removeAttr( "title" );
  11847. }
  11848. });
  11849. },
  11850. _enable: function() {
  11851. // restore title attributes
  11852. this.element.find( this.options.items ).addBack().each(function() {
  11853. var element = $( this );
  11854. if ( element.data( "ui-tooltip-title" ) ) {
  11855. element.attr( "title", element.data( "ui-tooltip-title" ) );
  11856. }
  11857. });
  11858. },
  11859. open: function( event ) {
  11860. var that = this,
  11861. target = $( event ? event.target : this.element )
  11862. // we need closest here due to mouseover bubbling,
  11863. // but always pointing at the same event target
  11864. .closest( this.options.items );
  11865. // No element to show a tooltip for or the tooltip is already open
  11866. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  11867. return;
  11868. }
  11869. if ( target.attr( "title" ) ) {
  11870. target.data( "ui-tooltip-title", target.attr( "title" ) );
  11871. }
  11872. target.data( "ui-tooltip-open", true );
  11873. // kill parent tooltips, custom or native, for hover
  11874. if ( event && event.type === "mouseover" ) {
  11875. target.parents().each(function() {
  11876. var parent = $( this ),
  11877. blurEvent;
  11878. if ( parent.data( "ui-tooltip-open" ) ) {
  11879. blurEvent = $.Event( "blur" );
  11880. blurEvent.target = blurEvent.currentTarget = this;
  11881. that.close( blurEvent, true );
  11882. }
  11883. if ( parent.attr( "title" ) ) {
  11884. parent.uniqueId();
  11885. that.parents[ this.id ] = {
  11886. element: this,
  11887. title: parent.attr( "title" )
  11888. };
  11889. parent.attr( "title", "" );
  11890. }
  11891. });
  11892. }
  11893. this._registerCloseHandlers( event, target );
  11894. this._updateContent( target, event );
  11895. },
  11896. _updateContent: function( target, event ) {
  11897. var content,
  11898. contentOption = this.options.content,
  11899. that = this,
  11900. eventType = event ? event.type : null;
  11901. if ( typeof contentOption === "string" ) {
  11902. return this._open( event, target, contentOption );
  11903. }
  11904. content = contentOption.call( target[0], function( response ) {
  11905. // IE may instantly serve a cached response for ajax requests
  11906. // delay this call to _open so the other call to _open runs first
  11907. that._delay(function() {
  11908. // Ignore async response if tooltip was closed already
  11909. if ( !target.data( "ui-tooltip-open" ) ) {
  11910. return;
  11911. }
  11912. // jQuery creates a special event for focusin when it doesn't
  11913. // exist natively. To improve performance, the native event
  11914. // object is reused and the type is changed. Therefore, we can't
  11915. // rely on the type being correct after the event finished
  11916. // bubbling, so we set it back to the previous value. (#8740)
  11917. if ( event ) {
  11918. event.type = eventType;
  11919. }
  11920. this._open( event, target, response );
  11921. });
  11922. });
  11923. if ( content ) {
  11924. this._open( event, target, content );
  11925. }
  11926. },
  11927. _open: function( event, target, content ) {
  11928. var tooltipData, tooltip, delayedShow, a11yContent,
  11929. positionOption = $.extend( {}, this.options.position );
  11930. if ( !content ) {
  11931. return;
  11932. }
  11933. // Content can be updated multiple times. If the tooltip already
  11934. // exists, then just update the content and bail.
  11935. tooltipData = this._find( target );
  11936. if ( tooltipData ) {
  11937. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  11938. return;
  11939. }
  11940. // if we have a title, clear it to prevent the native tooltip
  11941. // we have to check first to avoid defining a title if none exists
  11942. // (we don't want to cause an element to start matching [title])
  11943. //
  11944. // We use removeAttr only for key events, to allow IE to export the correct
  11945. // accessible attributes. For mouse events, set to empty string to avoid
  11946. // native tooltip showing up (happens only when removing inside mouseover).
  11947. if ( target.is( "[title]" ) ) {
  11948. if ( event && event.type === "mouseover" ) {
  11949. target.attr( "title", "" );
  11950. } else {
  11951. target.removeAttr( "title" );
  11952. }
  11953. }
  11954. tooltipData = this._tooltip( target );
  11955. tooltip = tooltipData.tooltip;
  11956. this._addDescribedBy( target, tooltip.attr( "id" ) );
  11957. tooltip.find( ".ui-tooltip-content" ).html( content );
  11958. // Support: Voiceover on OS X, JAWS on IE <= 9
  11959. // JAWS announces deletions even when aria-relevant="additions"
  11960. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  11961. this.liveRegion.children().hide();
  11962. if ( content.clone ) {
  11963. a11yContent = content.clone();
  11964. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  11965. } else {
  11966. a11yContent = content;
  11967. }
  11968. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  11969. function position( event ) {
  11970. positionOption.of = event;
  11971. if ( tooltip.is( ":hidden" ) ) {
  11972. return;
  11973. }
  11974. tooltip.position( positionOption );
  11975. }
  11976. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  11977. this._on( this.document, {
  11978. mousemove: position
  11979. });
  11980. // trigger once to override element-relative positioning
  11981. position( event );
  11982. } else {
  11983. tooltip.position( $.extend({
  11984. of: target
  11985. }, this.options.position ) );
  11986. }
  11987. tooltip.hide();
  11988. this._show( tooltip, this.options.show );
  11989. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  11990. // as the tooltip is visible, position the tooltip using the most recent
  11991. // event.
  11992. if ( this.options.show && this.options.show.delay ) {
  11993. delayedShow = this.delayedShow = setInterval(function() {
  11994. if ( tooltip.is( ":visible" ) ) {
  11995. position( positionOption.of );
  11996. clearInterval( delayedShow );
  11997. }
  11998. }, $.fx.interval );
  11999. }
  12000. this._trigger( "open", event, { tooltip: tooltip } );
  12001. },
  12002. _registerCloseHandlers: function( event, target ) {
  12003. var events = {
  12004. keyup: function( event ) {
  12005. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12006. var fakeEvent = $.Event(event);
  12007. fakeEvent.currentTarget = target[0];
  12008. this.close( fakeEvent, true );
  12009. }
  12010. }
  12011. };
  12012. // Only bind remove handler for delegated targets. Non-delegated
  12013. // tooltips will handle this in destroy.
  12014. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12015. events.remove = function() {
  12016. this._removeTooltip( this._find( target ).tooltip );
  12017. };
  12018. }
  12019. if ( !event || event.type === "mouseover" ) {
  12020. events.mouseleave = "close";
  12021. }
  12022. if ( !event || event.type === "focusin" ) {
  12023. events.focusout = "close";
  12024. }
  12025. this._on( true, target, events );
  12026. },
  12027. close: function( event ) {
  12028. var tooltip,
  12029. that = this,
  12030. target = $( event ? event.currentTarget : this.element ),
  12031. tooltipData = this._find( target );
  12032. // The tooltip may already be closed
  12033. if ( !tooltipData ) {
  12034. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  12035. // additional data once there's actually content to show (in _open()). So even if the
  12036. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  12037. // the period between open() and _open().
  12038. target.removeData( "ui-tooltip-open" );
  12039. return;
  12040. }
  12041. tooltip = tooltipData.tooltip;
  12042. // disabling closes the tooltip, so we need to track when we're closing
  12043. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12044. if ( tooltipData.closing ) {
  12045. return;
  12046. }
  12047. // Clear the interval for delayed tracking tooltips
  12048. clearInterval( this.delayedShow );
  12049. // only set title if we had one before (see comment in _open())
  12050. // If the title attribute has changed since open(), don't restore
  12051. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  12052. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12053. }
  12054. this._removeDescribedBy( target );
  12055. tooltipData.hiding = true;
  12056. tooltip.stop( true );
  12057. this._hide( tooltip, this.options.hide, function() {
  12058. that._removeTooltip( $( this ) );
  12059. });
  12060. target.removeData( "ui-tooltip-open" );
  12061. this._off( target, "mouseleave focusout keyup" );
  12062. // Remove 'remove' binding only on delegated targets
  12063. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12064. this._off( target, "remove" );
  12065. }
  12066. this._off( this.document, "mousemove" );
  12067. if ( event && event.type === "mouseleave" ) {
  12068. $.each( this.parents, function( id, parent ) {
  12069. $( parent.element ).attr( "title", parent.title );
  12070. delete that.parents[ id ];
  12071. });
  12072. }
  12073. tooltipData.closing = true;
  12074. this._trigger( "close", event, { tooltip: tooltip } );
  12075. if ( !tooltipData.hiding ) {
  12076. tooltipData.closing = false;
  12077. }
  12078. },
  12079. _tooltip: function( element ) {
  12080. var tooltip = $( "<div>" )
  12081. .attr( "role", "tooltip" )
  12082. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12083. ( this.options.tooltipClass || "" ) ),
  12084. id = tooltip.uniqueId().attr( "id" );
  12085. $( "<div>" )
  12086. .addClass( "ui-tooltip-content" )
  12087. .appendTo( tooltip );
  12088. tooltip.appendTo( this.document[0].body );
  12089. return this.tooltips[ id ] = {
  12090. element: element,
  12091. tooltip: tooltip
  12092. };
  12093. },
  12094. _find: function( target ) {
  12095. var id = target.data( "ui-tooltip-id" );
  12096. return id ? this.tooltips[ id ] : null;
  12097. },
  12098. _removeTooltip: function( tooltip ) {
  12099. tooltip.remove();
  12100. delete this.tooltips[ tooltip.attr( "id" ) ];
  12101. },
  12102. _destroy: function() {
  12103. var that = this;
  12104. // close open tooltips
  12105. $.each( this.tooltips, function( id, tooltipData ) {
  12106. // Delegate to close method to handle common cleanup
  12107. var event = $.Event( "blur" ),
  12108. element = tooltipData.element;
  12109. event.target = event.currentTarget = element[ 0 ];
  12110. that.close( event, true );
  12111. // Remove immediately; destroying an open tooltip doesn't use the
  12112. // hide animation
  12113. $( "#" + id ).remove();
  12114. // Restore the title
  12115. if ( element.data( "ui-tooltip-title" ) ) {
  12116. // If the title attribute has changed since open(), don't restore
  12117. if ( !element.attr( "title" ) ) {
  12118. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12119. }
  12120. element.removeData( "ui-tooltip-title" );
  12121. }
  12122. });
  12123. this.liveRegion.remove();
  12124. }
  12125. });
  12126. /*!
  12127. * jQuery UI Effects 1.11.4
  12128. * http://jqueryui.com
  12129. *
  12130. * Copyright jQuery Foundation and other contributors
  12131. * Released under the MIT license.
  12132. * http://jquery.org/license
  12133. *
  12134. * http://api.jqueryui.com/category/effects-core/
  12135. */
  12136. var dataSpace = "ui-effects-",
  12137. // Create a local jQuery because jQuery Color relies on it and the
  12138. // global may not exist with AMD and a custom build (#10199)
  12139. jQuery = $;
  12140. $.effects = {
  12141. effect: {}
  12142. };
  12143. /*!
  12144. * jQuery Color Animations v2.1.2
  12145. * https://github.com/jquery/jquery-color
  12146. *
  12147. * Copyright 2014 jQuery Foundation and other contributors
  12148. * Released under the MIT license.
  12149. * http://jquery.org/license
  12150. *
  12151. * Date: Wed Jan 16 08:47:09 2013 -0600
  12152. */
  12153. (function( jQuery, undefined ) {
  12154. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  12155. // plusequals test for += 100 -= 100
  12156. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  12157. // a set of RE's that can match strings and generate color tuples.
  12158. stringParsers = [ {
  12159. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12160. parse: function( execResult ) {
  12161. return [
  12162. execResult[ 1 ],
  12163. execResult[ 2 ],
  12164. execResult[ 3 ],
  12165. execResult[ 4 ]
  12166. ];
  12167. }
  12168. }, {
  12169. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12170. parse: function( execResult ) {
  12171. return [
  12172. execResult[ 1 ] * 2.55,
  12173. execResult[ 2 ] * 2.55,
  12174. execResult[ 3 ] * 2.55,
  12175. execResult[ 4 ]
  12176. ];
  12177. }
  12178. }, {
  12179. // this regex ignores A-F because it's compared against an already lowercased string
  12180. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  12181. parse: function( execResult ) {
  12182. return [
  12183. parseInt( execResult[ 1 ], 16 ),
  12184. parseInt( execResult[ 2 ], 16 ),
  12185. parseInt( execResult[ 3 ], 16 )
  12186. ];
  12187. }
  12188. }, {
  12189. // this regex ignores A-F because it's compared against an already lowercased string
  12190. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  12191. parse: function( execResult ) {
  12192. return [
  12193. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  12194. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  12195. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  12196. ];
  12197. }
  12198. }, {
  12199. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12200. space: "hsla",
  12201. parse: function( execResult ) {
  12202. return [
  12203. execResult[ 1 ],
  12204. execResult[ 2 ] / 100,
  12205. execResult[ 3 ] / 100,
  12206. execResult[ 4 ]
  12207. ];
  12208. }
  12209. } ],
  12210. // jQuery.Color( )
  12211. color = jQuery.Color = function( color, green, blue, alpha ) {
  12212. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  12213. },
  12214. spaces = {
  12215. rgba: {
  12216. props: {
  12217. red: {
  12218. idx: 0,
  12219. type: "byte"
  12220. },
  12221. green: {
  12222. idx: 1,
  12223. type: "byte"
  12224. },
  12225. blue: {
  12226. idx: 2,
  12227. type: "byte"
  12228. }
  12229. }
  12230. },
  12231. hsla: {
  12232. props: {
  12233. hue: {
  12234. idx: 0,
  12235. type: "degrees"
  12236. },
  12237. saturation: {
  12238. idx: 1,
  12239. type: "percent"
  12240. },
  12241. lightness: {
  12242. idx: 2,
  12243. type: "percent"
  12244. }
  12245. }
  12246. }
  12247. },
  12248. propTypes = {
  12249. "byte": {
  12250. floor: true,
  12251. max: 255
  12252. },
  12253. "percent": {
  12254. max: 1
  12255. },
  12256. "degrees": {
  12257. mod: 360,
  12258. floor: true
  12259. }
  12260. },
  12261. support = color.support = {},
  12262. // element for support tests
  12263. supportElem = jQuery( "<p>" )[ 0 ],
  12264. // colors = jQuery.Color.names
  12265. colors,
  12266. // local aliases of functions called often
  12267. each = jQuery.each;
  12268. // determine rgba support immediately
  12269. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  12270. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  12271. // define cache name and alpha properties
  12272. // for rgba and hsla spaces
  12273. each( spaces, function( spaceName, space ) {
  12274. space.cache = "_" + spaceName;
  12275. space.props.alpha = {
  12276. idx: 3,
  12277. type: "percent",
  12278. def: 1
  12279. };
  12280. });
  12281. function clamp( value, prop, allowEmpty ) {
  12282. var type = propTypes[ prop.type ] || {};
  12283. if ( value == null ) {
  12284. return (allowEmpty || !prop.def) ? null : prop.def;
  12285. }
  12286. // ~~ is an short way of doing floor for positive numbers
  12287. value = type.floor ? ~~value : parseFloat( value );
  12288. // IE will pass in empty strings as value for alpha,
  12289. // which will hit this case
  12290. if ( isNaN( value ) ) {
  12291. return prop.def;
  12292. }
  12293. if ( type.mod ) {
  12294. // we add mod before modding to make sure that negatives values
  12295. // get converted properly: -10 -> 350
  12296. return (value + type.mod) % type.mod;
  12297. }
  12298. // for now all property types without mod have min and max
  12299. return 0 > value ? 0 : type.max < value ? type.max : value;
  12300. }
  12301. function stringParse( string ) {
  12302. var inst = color(),
  12303. rgba = inst._rgba = [];
  12304. string = string.toLowerCase();
  12305. each( stringParsers, function( i, parser ) {
  12306. var parsed,
  12307. match = parser.re.exec( string ),
  12308. values = match && parser.parse( match ),
  12309. spaceName = parser.space || "rgba";
  12310. if ( values ) {
  12311. parsed = inst[ spaceName ]( values );
  12312. // if this was an rgba parse the assignment might happen twice
  12313. // oh well....
  12314. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  12315. rgba = inst._rgba = parsed._rgba;
  12316. // exit each( stringParsers ) here because we matched
  12317. return false;
  12318. }
  12319. });
  12320. // Found a stringParser that handled it
  12321. if ( rgba.length ) {
  12322. // if this came from a parsed string, force "transparent" when alpha is 0
  12323. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  12324. if ( rgba.join() === "0,0,0,0" ) {
  12325. jQuery.extend( rgba, colors.transparent );
  12326. }
  12327. return inst;
  12328. }
  12329. // named colors
  12330. return colors[ string ];
  12331. }
  12332. color.fn = jQuery.extend( color.prototype, {
  12333. parse: function( red, green, blue, alpha ) {
  12334. if ( red === undefined ) {
  12335. this._rgba = [ null, null, null, null ];
  12336. return this;
  12337. }
  12338. if ( red.jquery || red.nodeType ) {
  12339. red = jQuery( red ).css( green );
  12340. green = undefined;
  12341. }
  12342. var inst = this,
  12343. type = jQuery.type( red ),
  12344. rgba = this._rgba = [];
  12345. // more than 1 argument specified - assume ( red, green, blue, alpha )
  12346. if ( green !== undefined ) {
  12347. red = [ red, green, blue, alpha ];
  12348. type = "array";
  12349. }
  12350. if ( type === "string" ) {
  12351. return this.parse( stringParse( red ) || colors._default );
  12352. }
  12353. if ( type === "array" ) {
  12354. each( spaces.rgba.props, function( key, prop ) {
  12355. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  12356. });
  12357. return this;
  12358. }
  12359. if ( type === "object" ) {
  12360. if ( red instanceof color ) {
  12361. each( spaces, function( spaceName, space ) {
  12362. if ( red[ space.cache ] ) {
  12363. inst[ space.cache ] = red[ space.cache ].slice();
  12364. }
  12365. });
  12366. } else {
  12367. each( spaces, function( spaceName, space ) {
  12368. var cache = space.cache;
  12369. each( space.props, function( key, prop ) {
  12370. // if the cache doesn't exist, and we know how to convert
  12371. if ( !inst[ cache ] && space.to ) {
  12372. // if the value was null, we don't need to copy it
  12373. // if the key was alpha, we don't need to copy it either
  12374. if ( key === "alpha" || red[ key ] == null ) {
  12375. return;
  12376. }
  12377. inst[ cache ] = space.to( inst._rgba );
  12378. }
  12379. // this is the only case where we allow nulls for ALL properties.
  12380. // call clamp with alwaysAllowEmpty
  12381. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  12382. });
  12383. // everything defined but alpha?
  12384. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  12385. // use the default of 1
  12386. inst[ cache ][ 3 ] = 1;
  12387. if ( space.from ) {
  12388. inst._rgba = space.from( inst[ cache ] );
  12389. }
  12390. }
  12391. });
  12392. }
  12393. return this;
  12394. }
  12395. },
  12396. is: function( compare ) {
  12397. var is = color( compare ),
  12398. same = true,
  12399. inst = this;
  12400. each( spaces, function( _, space ) {
  12401. var localCache,
  12402. isCache = is[ space.cache ];
  12403. if (isCache) {
  12404. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  12405. each( space.props, function( _, prop ) {
  12406. if ( isCache[ prop.idx ] != null ) {
  12407. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  12408. return same;
  12409. }
  12410. });
  12411. }
  12412. return same;
  12413. });
  12414. return same;
  12415. },
  12416. _space: function() {
  12417. var used = [],
  12418. inst = this;
  12419. each( spaces, function( spaceName, space ) {
  12420. if ( inst[ space.cache ] ) {
  12421. used.push( spaceName );
  12422. }
  12423. });
  12424. return used.pop();
  12425. },
  12426. transition: function( other, distance ) {
  12427. var end = color( other ),
  12428. spaceName = end._space(),
  12429. space = spaces[ spaceName ],
  12430. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  12431. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  12432. result = start.slice();
  12433. end = end[ space.cache ];
  12434. each( space.props, function( key, prop ) {
  12435. var index = prop.idx,
  12436. startValue = start[ index ],
  12437. endValue = end[ index ],
  12438. type = propTypes[ prop.type ] || {};
  12439. // if null, don't override start value
  12440. if ( endValue === null ) {
  12441. return;
  12442. }
  12443. // if null - use end
  12444. if ( startValue === null ) {
  12445. result[ index ] = endValue;
  12446. } else {
  12447. if ( type.mod ) {
  12448. if ( endValue - startValue > type.mod / 2 ) {
  12449. startValue += type.mod;
  12450. } else if ( startValue - endValue > type.mod / 2 ) {
  12451. startValue -= type.mod;
  12452. }
  12453. }
  12454. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  12455. }
  12456. });
  12457. return this[ spaceName ]( result );
  12458. },
  12459. blend: function( opaque ) {
  12460. // if we are already opaque - return ourself
  12461. if ( this._rgba[ 3 ] === 1 ) {
  12462. return this;
  12463. }
  12464. var rgb = this._rgba.slice(),
  12465. a = rgb.pop(),
  12466. blend = color( opaque )._rgba;
  12467. return color( jQuery.map( rgb, function( v, i ) {
  12468. return ( 1 - a ) * blend[ i ] + a * v;
  12469. }));
  12470. },
  12471. toRgbaString: function() {
  12472. var prefix = "rgba(",
  12473. rgba = jQuery.map( this._rgba, function( v, i ) {
  12474. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  12475. });
  12476. if ( rgba[ 3 ] === 1 ) {
  12477. rgba.pop();
  12478. prefix = "rgb(";
  12479. }
  12480. return prefix + rgba.join() + ")";
  12481. },
  12482. toHslaString: function() {
  12483. var prefix = "hsla(",
  12484. hsla = jQuery.map( this.hsla(), function( v, i ) {
  12485. if ( v == null ) {
  12486. v = i > 2 ? 1 : 0;
  12487. }
  12488. // catch 1 and 2
  12489. if ( i && i < 3 ) {
  12490. v = Math.round( v * 100 ) + "%";
  12491. }
  12492. return v;
  12493. });
  12494. if ( hsla[ 3 ] === 1 ) {
  12495. hsla.pop();
  12496. prefix = "hsl(";
  12497. }
  12498. return prefix + hsla.join() + ")";
  12499. },
  12500. toHexString: function( includeAlpha ) {
  12501. var rgba = this._rgba.slice(),
  12502. alpha = rgba.pop();
  12503. if ( includeAlpha ) {
  12504. rgba.push( ~~( alpha * 255 ) );
  12505. }
  12506. return "#" + jQuery.map( rgba, function( v ) {
  12507. // default to 0 when nulls exist
  12508. v = ( v || 0 ).toString( 16 );
  12509. return v.length === 1 ? "0" + v : v;
  12510. }).join("");
  12511. },
  12512. toString: function() {
  12513. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  12514. }
  12515. });
  12516. color.fn.parse.prototype = color.fn;
  12517. // hsla conversions adapted from:
  12518. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  12519. function hue2rgb( p, q, h ) {
  12520. h = ( h + 1 ) % 1;
  12521. if ( h * 6 < 1 ) {
  12522. return p + ( q - p ) * h * 6;
  12523. }
  12524. if ( h * 2 < 1) {
  12525. return q;
  12526. }
  12527. if ( h * 3 < 2 ) {
  12528. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  12529. }
  12530. return p;
  12531. }
  12532. spaces.hsla.to = function( rgba ) {
  12533. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  12534. return [ null, null, null, rgba[ 3 ] ];
  12535. }
  12536. var r = rgba[ 0 ] / 255,
  12537. g = rgba[ 1 ] / 255,
  12538. b = rgba[ 2 ] / 255,
  12539. a = rgba[ 3 ],
  12540. max = Math.max( r, g, b ),
  12541. min = Math.min( r, g, b ),
  12542. diff = max - min,
  12543. add = max + min,
  12544. l = add * 0.5,
  12545. h, s;
  12546. if ( min === max ) {
  12547. h = 0;
  12548. } else if ( r === max ) {
  12549. h = ( 60 * ( g - b ) / diff ) + 360;
  12550. } else if ( g === max ) {
  12551. h = ( 60 * ( b - r ) / diff ) + 120;
  12552. } else {
  12553. h = ( 60 * ( r - g ) / diff ) + 240;
  12554. }
  12555. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  12556. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  12557. if ( diff === 0 ) {
  12558. s = 0;
  12559. } else if ( l <= 0.5 ) {
  12560. s = diff / add;
  12561. } else {
  12562. s = diff / ( 2 - add );
  12563. }
  12564. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  12565. };
  12566. spaces.hsla.from = function( hsla ) {
  12567. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  12568. return [ null, null, null, hsla[ 3 ] ];
  12569. }
  12570. var h = hsla[ 0 ] / 360,
  12571. s = hsla[ 1 ],
  12572. l = hsla[ 2 ],
  12573. a = hsla[ 3 ],
  12574. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  12575. p = 2 * l - q;
  12576. return [
  12577. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  12578. Math.round( hue2rgb( p, q, h ) * 255 ),
  12579. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  12580. a
  12581. ];
  12582. };
  12583. each( spaces, function( spaceName, space ) {
  12584. var props = space.props,
  12585. cache = space.cache,
  12586. to = space.to,
  12587. from = space.from;
  12588. // makes rgba() and hsla()
  12589. color.fn[ spaceName ] = function( value ) {
  12590. // generate a cache for this space if it doesn't exist
  12591. if ( to && !this[ cache ] ) {
  12592. this[ cache ] = to( this._rgba );
  12593. }
  12594. if ( value === undefined ) {
  12595. return this[ cache ].slice();
  12596. }
  12597. var ret,
  12598. type = jQuery.type( value ),
  12599. arr = ( type === "array" || type === "object" ) ? value : arguments,
  12600. local = this[ cache ].slice();
  12601. each( props, function( key, prop ) {
  12602. var val = arr[ type === "object" ? key : prop.idx ];
  12603. if ( val == null ) {
  12604. val = local[ prop.idx ];
  12605. }
  12606. local[ prop.idx ] = clamp( val, prop );
  12607. });
  12608. if ( from ) {
  12609. ret = color( from( local ) );
  12610. ret[ cache ] = local;
  12611. return ret;
  12612. } else {
  12613. return color( local );
  12614. }
  12615. };
  12616. // makes red() green() blue() alpha() hue() saturation() lightness()
  12617. each( props, function( key, prop ) {
  12618. // alpha is included in more than one space
  12619. if ( color.fn[ key ] ) {
  12620. return;
  12621. }
  12622. color.fn[ key ] = function( value ) {
  12623. var vtype = jQuery.type( value ),
  12624. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  12625. local = this[ fn ](),
  12626. cur = local[ prop.idx ],
  12627. match;
  12628. if ( vtype === "undefined" ) {
  12629. return cur;
  12630. }
  12631. if ( vtype === "function" ) {
  12632. value = value.call( this, cur );
  12633. vtype = jQuery.type( value );
  12634. }
  12635. if ( value == null && prop.empty ) {
  12636. return this;
  12637. }
  12638. if ( vtype === "string" ) {
  12639. match = rplusequals.exec( value );
  12640. if ( match ) {
  12641. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  12642. }
  12643. }
  12644. local[ prop.idx ] = value;
  12645. return this[ fn ]( local );
  12646. };
  12647. });
  12648. });
  12649. // add cssHook and .fx.step function for each named hook.
  12650. // accept a space separated string of properties
  12651. color.hook = function( hook ) {
  12652. var hooks = hook.split( " " );
  12653. each( hooks, function( i, hook ) {
  12654. jQuery.cssHooks[ hook ] = {
  12655. set: function( elem, value ) {
  12656. var parsed, curElem,
  12657. backgroundColor = "";
  12658. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  12659. value = color( parsed || value );
  12660. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  12661. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  12662. while (
  12663. (backgroundColor === "" || backgroundColor === "transparent") &&
  12664. curElem && curElem.style
  12665. ) {
  12666. try {
  12667. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  12668. curElem = curElem.parentNode;
  12669. } catch ( e ) {
  12670. }
  12671. }
  12672. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  12673. backgroundColor :
  12674. "_default" );
  12675. }
  12676. value = value.toRgbaString();
  12677. }
  12678. try {
  12679. elem.style[ hook ] = value;
  12680. } catch ( e ) {
  12681. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  12682. }
  12683. }
  12684. };
  12685. jQuery.fx.step[ hook ] = function( fx ) {
  12686. if ( !fx.colorInit ) {
  12687. fx.start = color( fx.elem, hook );
  12688. fx.end = color( fx.end );
  12689. fx.colorInit = true;
  12690. }
  12691. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  12692. };
  12693. });
  12694. };
  12695. color.hook( stepHooks );
  12696. jQuery.cssHooks.borderColor = {
  12697. expand: function( value ) {
  12698. var expanded = {};
  12699. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  12700. expanded[ "border" + part + "Color" ] = value;
  12701. });
  12702. return expanded;
  12703. }
  12704. };
  12705. // Basic color names only.
  12706. // Usage of any of the other color names requires adding yourself or including
  12707. // jquery.color.svg-names.js.
  12708. colors = jQuery.Color.names = {
  12709. // 4.1. Basic color keywords
  12710. aqua: "#00ffff",
  12711. black: "#000000",
  12712. blue: "#0000ff",
  12713. fuchsia: "#ff00ff",
  12714. gray: "#808080",
  12715. green: "#008000",
  12716. lime: "#00ff00",
  12717. maroon: "#800000",
  12718. navy: "#000080",
  12719. olive: "#808000",
  12720. purple: "#800080",
  12721. red: "#ff0000",
  12722. silver: "#c0c0c0",
  12723. teal: "#008080",
  12724. white: "#ffffff",
  12725. yellow: "#ffff00",
  12726. // 4.2.3. "transparent" color keyword
  12727. transparent: [ null, null, null, 0 ],
  12728. _default: "#ffffff"
  12729. };
  12730. })( jQuery );
  12731. /******************************************************************************/
  12732. /****************************** CLASS ANIMATIONS ******************************/
  12733. /******************************************************************************/
  12734. (function() {
  12735. var classAnimationActions = [ "add", "remove", "toggle" ],
  12736. shorthandStyles = {
  12737. border: 1,
  12738. borderBottom: 1,
  12739. borderColor: 1,
  12740. borderLeft: 1,
  12741. borderRight: 1,
  12742. borderTop: 1,
  12743. borderWidth: 1,
  12744. margin: 1,
  12745. padding: 1
  12746. };
  12747. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  12748. $.fx.step[ prop ] = function( fx ) {
  12749. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  12750. jQuery.style( fx.elem, prop, fx.end );
  12751. fx.setAttr = true;
  12752. }
  12753. };
  12754. });
  12755. function getElementStyles( elem ) {
  12756. var key, len,
  12757. style = elem.ownerDocument.defaultView ?
  12758. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  12759. elem.currentStyle,
  12760. styles = {};
  12761. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  12762. len = style.length;
  12763. while ( len-- ) {
  12764. key = style[ len ];
  12765. if ( typeof style[ key ] === "string" ) {
  12766. styles[ $.camelCase( key ) ] = style[ key ];
  12767. }
  12768. }
  12769. // support: Opera, IE <9
  12770. } else {
  12771. for ( key in style ) {
  12772. if ( typeof style[ key ] === "string" ) {
  12773. styles[ key ] = style[ key ];
  12774. }
  12775. }
  12776. }
  12777. return styles;
  12778. }
  12779. function styleDifference( oldStyle, newStyle ) {
  12780. var diff = {},
  12781. name, value;
  12782. for ( name in newStyle ) {
  12783. value = newStyle[ name ];
  12784. if ( oldStyle[ name ] !== value ) {
  12785. if ( !shorthandStyles[ name ] ) {
  12786. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  12787. diff[ name ] = value;
  12788. }
  12789. }
  12790. }
  12791. }
  12792. return diff;
  12793. }
  12794. // support: jQuery <1.8
  12795. if ( !$.fn.addBack ) {
  12796. $.fn.addBack = function( selector ) {
  12797. return this.add( selector == null ?
  12798. this.prevObject : this.prevObject.filter( selector )
  12799. );
  12800. };
  12801. }
  12802. $.effects.animateClass = function( value, duration, easing, callback ) {
  12803. var o = $.speed( duration, easing, callback );
  12804. return this.queue( function() {
  12805. var animated = $( this ),
  12806. baseClass = animated.attr( "class" ) || "",
  12807. applyClassChange,
  12808. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  12809. // map the animated objects to store the original styles.
  12810. allAnimations = allAnimations.map(function() {
  12811. var el = $( this );
  12812. return {
  12813. el: el,
  12814. start: getElementStyles( this )
  12815. };
  12816. });
  12817. // apply class change
  12818. applyClassChange = function() {
  12819. $.each( classAnimationActions, function(i, action) {
  12820. if ( value[ action ] ) {
  12821. animated[ action + "Class" ]( value[ action ] );
  12822. }
  12823. });
  12824. };
  12825. applyClassChange();
  12826. // map all animated objects again - calculate new styles and diff
  12827. allAnimations = allAnimations.map(function() {
  12828. this.end = getElementStyles( this.el[ 0 ] );
  12829. this.diff = styleDifference( this.start, this.end );
  12830. return this;
  12831. });
  12832. // apply original class
  12833. animated.attr( "class", baseClass );
  12834. // map all animated objects again - this time collecting a promise
  12835. allAnimations = allAnimations.map(function() {
  12836. var styleInfo = this,
  12837. dfd = $.Deferred(),
  12838. opts = $.extend({}, o, {
  12839. queue: false,
  12840. complete: function() {
  12841. dfd.resolve( styleInfo );
  12842. }
  12843. });
  12844. this.el.animate( this.diff, opts );
  12845. return dfd.promise();
  12846. });
  12847. // once all animations have completed:
  12848. $.when.apply( $, allAnimations.get() ).done(function() {
  12849. // set the final class
  12850. applyClassChange();
  12851. // for each animated element,
  12852. // clear all css properties that were animated
  12853. $.each( arguments, function() {
  12854. var el = this.el;
  12855. $.each( this.diff, function(key) {
  12856. el.css( key, "" );
  12857. });
  12858. });
  12859. // this is guarnteed to be there if you use jQuery.speed()
  12860. // it also handles dequeuing the next anim...
  12861. o.complete.call( animated[ 0 ] );
  12862. });
  12863. });
  12864. };
  12865. $.fn.extend({
  12866. addClass: (function( orig ) {
  12867. return function( classNames, speed, easing, callback ) {
  12868. return speed ?
  12869. $.effects.animateClass.call( this,
  12870. { add: classNames }, speed, easing, callback ) :
  12871. orig.apply( this, arguments );
  12872. };
  12873. })( $.fn.addClass ),
  12874. removeClass: (function( orig ) {
  12875. return function( classNames, speed, easing, callback ) {
  12876. return arguments.length > 1 ?
  12877. $.effects.animateClass.call( this,
  12878. { remove: classNames }, speed, easing, callback ) :
  12879. orig.apply( this, arguments );
  12880. };
  12881. })( $.fn.removeClass ),
  12882. toggleClass: (function( orig ) {
  12883. return function( classNames, force, speed, easing, callback ) {
  12884. if ( typeof force === "boolean" || force === undefined ) {
  12885. if ( !speed ) {
  12886. // without speed parameter
  12887. return orig.apply( this, arguments );
  12888. } else {
  12889. return $.effects.animateClass.call( this,
  12890. (force ? { add: classNames } : { remove: classNames }),
  12891. speed, easing, callback );
  12892. }
  12893. } else {
  12894. // without force parameter
  12895. return $.effects.animateClass.call( this,
  12896. { toggle: classNames }, force, speed, easing );
  12897. }
  12898. };
  12899. })( $.fn.toggleClass ),
  12900. switchClass: function( remove, add, speed, easing, callback) {
  12901. return $.effects.animateClass.call( this, {
  12902. add: add,
  12903. remove: remove
  12904. }, speed, easing, callback );
  12905. }
  12906. });
  12907. })();
  12908. /******************************************************************************/
  12909. /*********************************** EFFECTS **********************************/
  12910. /******************************************************************************/
  12911. (function() {
  12912. $.extend( $.effects, {
  12913. version: "1.11.4",
  12914. // Saves a set of properties in a data storage
  12915. save: function( element, set ) {
  12916. for ( var i = 0; i < set.length; i++ ) {
  12917. if ( set[ i ] !== null ) {
  12918. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  12919. }
  12920. }
  12921. },
  12922. // Restores a set of previously saved properties from a data storage
  12923. restore: function( element, set ) {
  12924. var val, i;
  12925. for ( i = 0; i < set.length; i++ ) {
  12926. if ( set[ i ] !== null ) {
  12927. val = element.data( dataSpace + set[ i ] );
  12928. // support: jQuery 1.6.2
  12929. // http://bugs.jquery.com/ticket/9917
  12930. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  12931. // We can't differentiate between "" and 0 here, so we just assume
  12932. // empty string since it's likely to be a more common value...
  12933. if ( val === undefined ) {
  12934. val = "";
  12935. }
  12936. element.css( set[ i ], val );
  12937. }
  12938. }
  12939. },
  12940. setMode: function( el, mode ) {
  12941. if (mode === "toggle") {
  12942. mode = el.is( ":hidden" ) ? "show" : "hide";
  12943. }
  12944. return mode;
  12945. },
  12946. // Translates a [top,left] array into a baseline value
  12947. // this should be a little more flexible in the future to handle a string & hash
  12948. getBaseline: function( origin, original ) {
  12949. var y, x;
  12950. switch ( origin[ 0 ] ) {
  12951. case "top": y = 0; break;
  12952. case "middle": y = 0.5; break;
  12953. case "bottom": y = 1; break;
  12954. default: y = origin[ 0 ] / original.height;
  12955. }
  12956. switch ( origin[ 1 ] ) {
  12957. case "left": x = 0; break;
  12958. case "center": x = 0.5; break;
  12959. case "right": x = 1; break;
  12960. default: x = origin[ 1 ] / original.width;
  12961. }
  12962. return {
  12963. x: x,
  12964. y: y
  12965. };
  12966. },
  12967. // Wraps the element around a wrapper that copies position properties
  12968. createWrapper: function( element ) {
  12969. // if the element is already wrapped, return it
  12970. if ( element.parent().is( ".ui-effects-wrapper" )) {
  12971. return element.parent();
  12972. }
  12973. // wrap the element
  12974. var props = {
  12975. width: element.outerWidth(true),
  12976. height: element.outerHeight(true),
  12977. "float": element.css( "float" )
  12978. },
  12979. wrapper = $( "<div></div>" )
  12980. .addClass( "ui-effects-wrapper" )
  12981. .css({
  12982. fontSize: "100%",
  12983. background: "transparent",
  12984. border: "none",
  12985. margin: 0,
  12986. padding: 0
  12987. }),
  12988. // Store the size in case width/height are defined in % - Fixes #5245
  12989. size = {
  12990. width: element.width(),
  12991. height: element.height()
  12992. },
  12993. active = document.activeElement;
  12994. // support: Firefox
  12995. // Firefox incorrectly exposes anonymous content
  12996. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  12997. try {
  12998. active.id;
  12999. } catch ( e ) {
  13000. active = document.body;
  13001. }
  13002. element.wrap( wrapper );
  13003. // Fixes #7595 - Elements lose focus when wrapped.
  13004. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  13005. $( active ).focus();
  13006. }
  13007. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  13008. // transfer positioning properties to the wrapper
  13009. if ( element.css( "position" ) === "static" ) {
  13010. wrapper.css({ position: "relative" });
  13011. element.css({ position: "relative" });
  13012. } else {
  13013. $.extend( props, {
  13014. position: element.css( "position" ),
  13015. zIndex: element.css( "z-index" )
  13016. });
  13017. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  13018. props[ pos ] = element.css( pos );
  13019. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  13020. props[ pos ] = "auto";
  13021. }
  13022. });
  13023. element.css({
  13024. position: "relative",
  13025. top: 0,
  13026. left: 0,
  13027. right: "auto",
  13028. bottom: "auto"
  13029. });
  13030. }
  13031. element.css(size);
  13032. return wrapper.css( props ).show();
  13033. },
  13034. removeWrapper: function( element ) {
  13035. var active = document.activeElement;
  13036. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  13037. element.parent().replaceWith( element );
  13038. // Fixes #7595 - Elements lose focus when wrapped.
  13039. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  13040. $( active ).focus();
  13041. }
  13042. }
  13043. return element;
  13044. },
  13045. setTransition: function( element, list, factor, value ) {
  13046. value = value || {};
  13047. $.each( list, function( i, x ) {
  13048. var unit = element.cssUnit( x );
  13049. if ( unit[ 0 ] > 0 ) {
  13050. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  13051. }
  13052. });
  13053. return value;
  13054. }
  13055. });
  13056. // return an effect options object for the given parameters:
  13057. function _normalizeArguments( effect, options, speed, callback ) {
  13058. // allow passing all options as the first parameter
  13059. if ( $.isPlainObject( effect ) ) {
  13060. options = effect;
  13061. effect = effect.effect;
  13062. }
  13063. // convert to an object
  13064. effect = { effect: effect };
  13065. // catch (effect, null, ...)
  13066. if ( options == null ) {
  13067. options = {};
  13068. }
  13069. // catch (effect, callback)
  13070. if ( $.isFunction( options ) ) {
  13071. callback = options;
  13072. speed = null;
  13073. options = {};
  13074. }
  13075. // catch (effect, speed, ?)
  13076. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  13077. callback = speed;
  13078. speed = options;
  13079. options = {};
  13080. }
  13081. // catch (effect, options, callback)
  13082. if ( $.isFunction( speed ) ) {
  13083. callback = speed;
  13084. speed = null;
  13085. }
  13086. // add options to effect
  13087. if ( options ) {
  13088. $.extend( effect, options );
  13089. }
  13090. speed = speed || options.duration;
  13091. effect.duration = $.fx.off ? 0 :
  13092. typeof speed === "number" ? speed :
  13093. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  13094. $.fx.speeds._default;
  13095. effect.complete = callback || options.complete;
  13096. return effect;
  13097. }
  13098. function standardAnimationOption( option ) {
  13099. // Valid standard speeds (nothing, number, named speed)
  13100. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  13101. return true;
  13102. }
  13103. // Invalid strings - treat as "normal" speed
  13104. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  13105. return true;
  13106. }
  13107. // Complete callback
  13108. if ( $.isFunction( option ) ) {
  13109. return true;
  13110. }
  13111. // Options hash (but not naming an effect)
  13112. if ( typeof option === "object" && !option.effect ) {
  13113. return true;
  13114. }
  13115. // Didn't match any standard API
  13116. return false;
  13117. }
  13118. $.fn.extend({
  13119. effect: function( /* effect, options, speed, callback */ ) {
  13120. var args = _normalizeArguments.apply( this, arguments ),
  13121. mode = args.mode,
  13122. queue = args.queue,
  13123. effectMethod = $.effects.effect[ args.effect ];
  13124. if ( $.fx.off || !effectMethod ) {
  13125. // delegate to the original method (e.g., .show()) if possible
  13126. if ( mode ) {
  13127. return this[ mode ]( args.duration, args.complete );
  13128. } else {
  13129. return this.each( function() {
  13130. if ( args.complete ) {
  13131. args.complete.call( this );
  13132. }
  13133. });
  13134. }
  13135. }
  13136. function run( next ) {
  13137. var elem = $( this ),
  13138. complete = args.complete,
  13139. mode = args.mode;
  13140. function done() {
  13141. if ( $.isFunction( complete ) ) {
  13142. complete.call( elem[0] );
  13143. }
  13144. if ( $.isFunction( next ) ) {
  13145. next();
  13146. }
  13147. }
  13148. // If the element already has the correct final state, delegate to
  13149. // the core methods so the internal tracking of "olddisplay" works.
  13150. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  13151. elem[ mode ]();
  13152. done();
  13153. } else {
  13154. effectMethod.call( elem[0], args, done );
  13155. }
  13156. }
  13157. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  13158. },
  13159. show: (function( orig ) {
  13160. return function( option ) {
  13161. if ( standardAnimationOption( option ) ) {
  13162. return orig.apply( this, arguments );
  13163. } else {
  13164. var args = _normalizeArguments.apply( this, arguments );
  13165. args.mode = "show";
  13166. return this.effect.call( this, args );
  13167. }
  13168. };
  13169. })( $.fn.show ),
  13170. hide: (function( orig ) {
  13171. return function( option ) {
  13172. if ( standardAnimationOption( option ) ) {
  13173. return orig.apply( this, arguments );
  13174. } else {
  13175. var args = _normalizeArguments.apply( this, arguments );
  13176. args.mode = "hide";
  13177. return this.effect.call( this, args );
  13178. }
  13179. };
  13180. })( $.fn.hide ),
  13181. toggle: (function( orig ) {
  13182. return function( option ) {
  13183. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  13184. return orig.apply( this, arguments );
  13185. } else {
  13186. var args = _normalizeArguments.apply( this, arguments );
  13187. args.mode = "toggle";
  13188. return this.effect.call( this, args );
  13189. }
  13190. };
  13191. })( $.fn.toggle ),
  13192. // helper functions
  13193. cssUnit: function(key) {
  13194. var style = this.css( key ),
  13195. val = [];
  13196. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  13197. if ( style.indexOf( unit ) > 0 ) {
  13198. val = [ parseFloat( style ), unit ];
  13199. }
  13200. });
  13201. return val;
  13202. }
  13203. });
  13204. })();
  13205. /******************************************************************************/
  13206. /*********************************** EASING ***********************************/
  13207. /******************************************************************************/
  13208. (function() {
  13209. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  13210. var baseEasings = {};
  13211. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  13212. baseEasings[ name ] = function( p ) {
  13213. return Math.pow( p, i + 2 );
  13214. };
  13215. });
  13216. $.extend( baseEasings, {
  13217. Sine: function( p ) {
  13218. return 1 - Math.cos( p * Math.PI / 2 );
  13219. },
  13220. Circ: function( p ) {
  13221. return 1 - Math.sqrt( 1 - p * p );
  13222. },
  13223. Elastic: function( p ) {
  13224. return p === 0 || p === 1 ? p :
  13225. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  13226. },
  13227. Back: function( p ) {
  13228. return p * p * ( 3 * p - 2 );
  13229. },
  13230. Bounce: function( p ) {
  13231. var pow2,
  13232. bounce = 4;
  13233. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  13234. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  13235. }
  13236. });
  13237. $.each( baseEasings, function( name, easeIn ) {
  13238. $.easing[ "easeIn" + name ] = easeIn;
  13239. $.easing[ "easeOut" + name ] = function( p ) {
  13240. return 1 - easeIn( 1 - p );
  13241. };
  13242. $.easing[ "easeInOut" + name ] = function( p ) {
  13243. return p < 0.5 ?
  13244. easeIn( p * 2 ) / 2 :
  13245. 1 - easeIn( p * -2 + 2 ) / 2;
  13246. };
  13247. });
  13248. })();
  13249. var effect = $.effects;
  13250. /*!
  13251. * jQuery UI Effects Blind 1.11.4
  13252. * http://jqueryui.com
  13253. *
  13254. * Copyright jQuery Foundation and other contributors
  13255. * Released under the MIT license.
  13256. * http://jquery.org/license
  13257. *
  13258. * http://api.jqueryui.com/blind-effect/
  13259. */
  13260. var effectBlind = $.effects.effect.blind = function( o, done ) {
  13261. // Create element
  13262. var el = $( this ),
  13263. rvertical = /up|down|vertical/,
  13264. rpositivemotion = /up|left|vertical|horizontal/,
  13265. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13266. mode = $.effects.setMode( el, o.mode || "hide" ),
  13267. direction = o.direction || "up",
  13268. vertical = rvertical.test( direction ),
  13269. ref = vertical ? "height" : "width",
  13270. ref2 = vertical ? "top" : "left",
  13271. motion = rpositivemotion.test( direction ),
  13272. animation = {},
  13273. show = mode === "show",
  13274. wrapper, distance, margin;
  13275. // if already wrapped, the wrapper's properties are my property. #6245
  13276. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  13277. $.effects.save( el.parent(), props );
  13278. } else {
  13279. $.effects.save( el, props );
  13280. }
  13281. el.show();
  13282. wrapper = $.effects.createWrapper( el ).css({
  13283. overflow: "hidden"
  13284. });
  13285. distance = wrapper[ ref ]();
  13286. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  13287. animation[ ref ] = show ? distance : 0;
  13288. if ( !motion ) {
  13289. el
  13290. .css( vertical ? "bottom" : "right", 0 )
  13291. .css( vertical ? "top" : "left", "auto" )
  13292. .css({ position: "absolute" });
  13293. animation[ ref2 ] = show ? margin : distance + margin;
  13294. }
  13295. // start at 0 if we are showing
  13296. if ( show ) {
  13297. wrapper.css( ref, 0 );
  13298. if ( !motion ) {
  13299. wrapper.css( ref2, margin + distance );
  13300. }
  13301. }
  13302. // Animate
  13303. wrapper.animate( animation, {
  13304. duration: o.duration,
  13305. easing: o.easing,
  13306. queue: false,
  13307. complete: function() {
  13308. if ( mode === "hide" ) {
  13309. el.hide();
  13310. }
  13311. $.effects.restore( el, props );
  13312. $.effects.removeWrapper( el );
  13313. done();
  13314. }
  13315. });
  13316. };
  13317. /*!
  13318. * jQuery UI Effects Bounce 1.11.4
  13319. * http://jqueryui.com
  13320. *
  13321. * Copyright jQuery Foundation and other contributors
  13322. * Released under the MIT license.
  13323. * http://jquery.org/license
  13324. *
  13325. * http://api.jqueryui.com/bounce-effect/
  13326. */
  13327. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  13328. var el = $( this ),
  13329. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13330. // defaults:
  13331. mode = $.effects.setMode( el, o.mode || "effect" ),
  13332. hide = mode === "hide",
  13333. show = mode === "show",
  13334. direction = o.direction || "up",
  13335. distance = o.distance,
  13336. times = o.times || 5,
  13337. // number of internal animations
  13338. anims = times * 2 + ( show || hide ? 1 : 0 ),
  13339. speed = o.duration / anims,
  13340. easing = o.easing,
  13341. // utility:
  13342. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13343. motion = ( direction === "up" || direction === "left" ),
  13344. i,
  13345. upAnim,
  13346. downAnim,
  13347. // we will need to re-assemble the queue to stack our animations in place
  13348. queue = el.queue(),
  13349. queuelen = queue.length;
  13350. // Avoid touching opacity to prevent clearType and PNG issues in IE
  13351. if ( show || hide ) {
  13352. props.push( "opacity" );
  13353. }
  13354. $.effects.save( el, props );
  13355. el.show();
  13356. $.effects.createWrapper( el ); // Create Wrapper
  13357. // default distance for the BIGGEST bounce is the outer Distance / 3
  13358. if ( !distance ) {
  13359. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  13360. }
  13361. if ( show ) {
  13362. downAnim = { opacity: 1 };
  13363. downAnim[ ref ] = 0;
  13364. // if we are showing, force opacity 0 and set the initial position
  13365. // then do the "first" animation
  13366. el.css( "opacity", 0 )
  13367. .css( ref, motion ? -distance * 2 : distance * 2 )
  13368. .animate( downAnim, speed, easing );
  13369. }
  13370. // start at the smallest distance if we are hiding
  13371. if ( hide ) {
  13372. distance = distance / Math.pow( 2, times - 1 );
  13373. }
  13374. downAnim = {};
  13375. downAnim[ ref ] = 0;
  13376. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  13377. for ( i = 0; i < times; i++ ) {
  13378. upAnim = {};
  13379. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13380. el.animate( upAnim, speed, easing )
  13381. .animate( downAnim, speed, easing );
  13382. distance = hide ? distance * 2 : distance / 2;
  13383. }
  13384. // Last Bounce when Hiding
  13385. if ( hide ) {
  13386. upAnim = { opacity: 0 };
  13387. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13388. el.animate( upAnim, speed, easing );
  13389. }
  13390. el.queue(function() {
  13391. if ( hide ) {
  13392. el.hide();
  13393. }
  13394. $.effects.restore( el, props );
  13395. $.effects.removeWrapper( el );
  13396. done();
  13397. });
  13398. // inject all the animations we just queued to be first in line (after "inprogress")
  13399. if ( queuelen > 1) {
  13400. queue.splice.apply( queue,
  13401. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  13402. }
  13403. el.dequeue();
  13404. };
  13405. /*!
  13406. * jQuery UI Effects Clip 1.11.4
  13407. * http://jqueryui.com
  13408. *
  13409. * Copyright jQuery Foundation and other contributors
  13410. * Released under the MIT license.
  13411. * http://jquery.org/license
  13412. *
  13413. * http://api.jqueryui.com/clip-effect/
  13414. */
  13415. var effectClip = $.effects.effect.clip = function( o, done ) {
  13416. // Create element
  13417. var el = $( this ),
  13418. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13419. mode = $.effects.setMode( el, o.mode || "hide" ),
  13420. show = mode === "show",
  13421. direction = o.direction || "vertical",
  13422. vert = direction === "vertical",
  13423. size = vert ? "height" : "width",
  13424. position = vert ? "top" : "left",
  13425. animation = {},
  13426. wrapper, animate, distance;
  13427. // Save & Show
  13428. $.effects.save( el, props );
  13429. el.show();
  13430. // Create Wrapper
  13431. wrapper = $.effects.createWrapper( el ).css({
  13432. overflow: "hidden"
  13433. });
  13434. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  13435. distance = animate[ size ]();
  13436. // Shift
  13437. if ( show ) {
  13438. animate.css( size, 0 );
  13439. animate.css( position, distance / 2 );
  13440. }
  13441. // Create Animation Object:
  13442. animation[ size ] = show ? distance : 0;
  13443. animation[ position ] = show ? 0 : distance / 2;
  13444. // Animate
  13445. animate.animate( animation, {
  13446. queue: false,
  13447. duration: o.duration,
  13448. easing: o.easing,
  13449. complete: function() {
  13450. if ( !show ) {
  13451. el.hide();
  13452. }
  13453. $.effects.restore( el, props );
  13454. $.effects.removeWrapper( el );
  13455. done();
  13456. }
  13457. });
  13458. };
  13459. /*!
  13460. * jQuery UI Effects Drop 1.11.4
  13461. * http://jqueryui.com
  13462. *
  13463. * Copyright jQuery Foundation and other contributors
  13464. * Released under the MIT license.
  13465. * http://jquery.org/license
  13466. *
  13467. * http://api.jqueryui.com/drop-effect/
  13468. */
  13469. var effectDrop = $.effects.effect.drop = function( o, done ) {
  13470. var el = $( this ),
  13471. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  13472. mode = $.effects.setMode( el, o.mode || "hide" ),
  13473. show = mode === "show",
  13474. direction = o.direction || "left",
  13475. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13476. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  13477. animation = {
  13478. opacity: show ? 1 : 0
  13479. },
  13480. distance;
  13481. // Adjust
  13482. $.effects.save( el, props );
  13483. el.show();
  13484. $.effects.createWrapper( el );
  13485. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  13486. if ( show ) {
  13487. el
  13488. .css( "opacity", 0 )
  13489. .css( ref, motion === "pos" ? -distance : distance );
  13490. }
  13491. // Animation
  13492. animation[ ref ] = ( show ?
  13493. ( motion === "pos" ? "+=" : "-=" ) :
  13494. ( motion === "pos" ? "-=" : "+=" ) ) +
  13495. distance;
  13496. // Animate
  13497. el.animate( animation, {
  13498. queue: false,
  13499. duration: o.duration,
  13500. easing: o.easing,
  13501. complete: function() {
  13502. if ( mode === "hide" ) {
  13503. el.hide();
  13504. }
  13505. $.effects.restore( el, props );
  13506. $.effects.removeWrapper( el );
  13507. done();
  13508. }
  13509. });
  13510. };
  13511. /*!
  13512. * jQuery UI Effects Explode 1.11.4
  13513. * http://jqueryui.com
  13514. *
  13515. * Copyright jQuery Foundation and other contributors
  13516. * Released under the MIT license.
  13517. * http://jquery.org/license
  13518. *
  13519. * http://api.jqueryui.com/explode-effect/
  13520. */
  13521. var effectExplode = $.effects.effect.explode = function( o, done ) {
  13522. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  13523. cells = rows,
  13524. el = $( this ),
  13525. mode = $.effects.setMode( el, o.mode || "hide" ),
  13526. show = mode === "show",
  13527. // show and then visibility:hidden the element before calculating offset
  13528. offset = el.show().css( "visibility", "hidden" ).offset(),
  13529. // width and height of a piece
  13530. width = Math.ceil( el.outerWidth() / cells ),
  13531. height = Math.ceil( el.outerHeight() / rows ),
  13532. pieces = [],
  13533. // loop
  13534. i, j, left, top, mx, my;
  13535. // children animate complete:
  13536. function childComplete() {
  13537. pieces.push( this );
  13538. if ( pieces.length === rows * cells ) {
  13539. animComplete();
  13540. }
  13541. }
  13542. // clone the element for each row and cell.
  13543. for ( i = 0; i < rows ; i++ ) { // ===>
  13544. top = offset.top + i * height;
  13545. my = i - ( rows - 1 ) / 2 ;
  13546. for ( j = 0; j < cells ; j++ ) { // |||
  13547. left = offset.left + j * width;
  13548. mx = j - ( cells - 1 ) / 2 ;
  13549. // Create a clone of the now hidden main element that will be absolute positioned
  13550. // within a wrapper div off the -left and -top equal to size of our pieces
  13551. el
  13552. .clone()
  13553. .appendTo( "body" )
  13554. .wrap( "<div></div>" )
  13555. .css({
  13556. position: "absolute",
  13557. visibility: "visible",
  13558. left: -j * width,
  13559. top: -i * height
  13560. })
  13561. // select the wrapper - make it overflow: hidden and absolute positioned based on
  13562. // where the original was located +left and +top equal to the size of pieces
  13563. .parent()
  13564. .addClass( "ui-effects-explode" )
  13565. .css({
  13566. position: "absolute",
  13567. overflow: "hidden",
  13568. width: width,
  13569. height: height,
  13570. left: left + ( show ? mx * width : 0 ),
  13571. top: top + ( show ? my * height : 0 ),
  13572. opacity: show ? 0 : 1
  13573. }).animate({
  13574. left: left + ( show ? 0 : mx * width ),
  13575. top: top + ( show ? 0 : my * height ),
  13576. opacity: show ? 1 : 0
  13577. }, o.duration || 500, o.easing, childComplete );
  13578. }
  13579. }
  13580. function animComplete() {
  13581. el.css({
  13582. visibility: "visible"
  13583. });
  13584. $( pieces ).remove();
  13585. if ( !show ) {
  13586. el.hide();
  13587. }
  13588. done();
  13589. }
  13590. };
  13591. /*!
  13592. * jQuery UI Effects Fade 1.11.4
  13593. * http://jqueryui.com
  13594. *
  13595. * Copyright jQuery Foundation and other contributors
  13596. * Released under the MIT license.
  13597. * http://jquery.org/license
  13598. *
  13599. * http://api.jqueryui.com/fade-effect/
  13600. */
  13601. var effectFade = $.effects.effect.fade = function( o, done ) {
  13602. var el = $( this ),
  13603. mode = $.effects.setMode( el, o.mode || "toggle" );
  13604. el.animate({
  13605. opacity: mode
  13606. }, {
  13607. queue: false,
  13608. duration: o.duration,
  13609. easing: o.easing,
  13610. complete: done
  13611. });
  13612. };
  13613. /*!
  13614. * jQuery UI Effects Fold 1.11.4
  13615. * http://jqueryui.com
  13616. *
  13617. * Copyright jQuery Foundation and other contributors
  13618. * Released under the MIT license.
  13619. * http://jquery.org/license
  13620. *
  13621. * http://api.jqueryui.com/fold-effect/
  13622. */
  13623. var effectFold = $.effects.effect.fold = function( o, done ) {
  13624. // Create element
  13625. var el = $( this ),
  13626. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13627. mode = $.effects.setMode( el, o.mode || "hide" ),
  13628. show = mode === "show",
  13629. hide = mode === "hide",
  13630. size = o.size || 15,
  13631. percent = /([0-9]+)%/.exec( size ),
  13632. horizFirst = !!o.horizFirst,
  13633. widthFirst = show !== horizFirst,
  13634. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  13635. duration = o.duration / 2,
  13636. wrapper, distance,
  13637. animation1 = {},
  13638. animation2 = {};
  13639. $.effects.save( el, props );
  13640. el.show();
  13641. // Create Wrapper
  13642. wrapper = $.effects.createWrapper( el ).css({
  13643. overflow: "hidden"
  13644. });
  13645. distance = widthFirst ?
  13646. [ wrapper.width(), wrapper.height() ] :
  13647. [ wrapper.height(), wrapper.width() ];
  13648. if ( percent ) {
  13649. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  13650. }
  13651. if ( show ) {
  13652. wrapper.css( horizFirst ? {
  13653. height: 0,
  13654. width: size
  13655. } : {
  13656. height: size,
  13657. width: 0
  13658. });
  13659. }
  13660. // Animation
  13661. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  13662. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  13663. // Animate
  13664. wrapper
  13665. .animate( animation1, duration, o.easing )
  13666. .animate( animation2, duration, o.easing, function() {
  13667. if ( hide ) {
  13668. el.hide();
  13669. }
  13670. $.effects.restore( el, props );
  13671. $.effects.removeWrapper( el );
  13672. done();
  13673. });
  13674. };
  13675. /*!
  13676. * jQuery UI Effects Highlight 1.11.4
  13677. * http://jqueryui.com
  13678. *
  13679. * Copyright jQuery Foundation and other contributors
  13680. * Released under the MIT license.
  13681. * http://jquery.org/license
  13682. *
  13683. * http://api.jqueryui.com/highlight-effect/
  13684. */
  13685. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  13686. var elem = $( this ),
  13687. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  13688. mode = $.effects.setMode( elem, o.mode || "show" ),
  13689. animation = {
  13690. backgroundColor: elem.css( "backgroundColor" )
  13691. };
  13692. if (mode === "hide") {
  13693. animation.opacity = 0;
  13694. }
  13695. $.effects.save( elem, props );
  13696. elem
  13697. .show()
  13698. .css({
  13699. backgroundImage: "none",
  13700. backgroundColor: o.color || "#ffff99"
  13701. })
  13702. .animate( animation, {
  13703. queue: false,
  13704. duration: o.duration,
  13705. easing: o.easing,
  13706. complete: function() {
  13707. if ( mode === "hide" ) {
  13708. elem.hide();
  13709. }
  13710. $.effects.restore( elem, props );
  13711. done();
  13712. }
  13713. });
  13714. };
  13715. /*!
  13716. * jQuery UI Effects Size 1.11.4
  13717. * http://jqueryui.com
  13718. *
  13719. * Copyright jQuery Foundation and other contributors
  13720. * Released under the MIT license.
  13721. * http://jquery.org/license
  13722. *
  13723. * http://api.jqueryui.com/size-effect/
  13724. */
  13725. var effectSize = $.effects.effect.size = function( o, done ) {
  13726. // Create element
  13727. var original, baseline, factor,
  13728. el = $( this ),
  13729. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  13730. // Always restore
  13731. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  13732. // Copy for children
  13733. props2 = [ "width", "height", "overflow" ],
  13734. cProps = [ "fontSize" ],
  13735. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  13736. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  13737. // Set options
  13738. mode = $.effects.setMode( el, o.mode || "effect" ),
  13739. restore = o.restore || mode !== "effect",
  13740. scale = o.scale || "both",
  13741. origin = o.origin || [ "middle", "center" ],
  13742. position = el.css( "position" ),
  13743. props = restore ? props0 : props1,
  13744. zero = {
  13745. height: 0,
  13746. width: 0,
  13747. outerHeight: 0,
  13748. outerWidth: 0
  13749. };
  13750. if ( mode === "show" ) {
  13751. el.show();
  13752. }
  13753. original = {
  13754. height: el.height(),
  13755. width: el.width(),
  13756. outerHeight: el.outerHeight(),
  13757. outerWidth: el.outerWidth()
  13758. };
  13759. if ( o.mode === "toggle" && mode === "show" ) {
  13760. el.from = o.to || zero;
  13761. el.to = o.from || original;
  13762. } else {
  13763. el.from = o.from || ( mode === "show" ? zero : original );
  13764. el.to = o.to || ( mode === "hide" ? zero : original );
  13765. }
  13766. // Set scaling factor
  13767. factor = {
  13768. from: {
  13769. y: el.from.height / original.height,
  13770. x: el.from.width / original.width
  13771. },
  13772. to: {
  13773. y: el.to.height / original.height,
  13774. x: el.to.width / original.width
  13775. }
  13776. };
  13777. // Scale the css box
  13778. if ( scale === "box" || scale === "both" ) {
  13779. // Vertical props scaling
  13780. if ( factor.from.y !== factor.to.y ) {
  13781. props = props.concat( vProps );
  13782. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  13783. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  13784. }
  13785. // Horizontal props scaling
  13786. if ( factor.from.x !== factor.to.x ) {
  13787. props = props.concat( hProps );
  13788. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  13789. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  13790. }
  13791. }
  13792. // Scale the content
  13793. if ( scale === "content" || scale === "both" ) {
  13794. // Vertical props scaling
  13795. if ( factor.from.y !== factor.to.y ) {
  13796. props = props.concat( cProps ).concat( props2 );
  13797. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  13798. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  13799. }
  13800. }
  13801. $.effects.save( el, props );
  13802. el.show();
  13803. $.effects.createWrapper( el );
  13804. el.css( "overflow", "hidden" ).css( el.from );
  13805. // Adjust
  13806. if (origin) { // Calculate baseline shifts
  13807. baseline = $.effects.getBaseline( origin, original );
  13808. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  13809. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  13810. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  13811. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  13812. }
  13813. el.css( el.from ); // set top & left
  13814. // Animate
  13815. if ( scale === "content" || scale === "both" ) { // Scale the children
  13816. // Add margins/font-size
  13817. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  13818. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  13819. props2 = props0.concat(vProps).concat(hProps);
  13820. el.find( "*[width]" ).each( function() {
  13821. var child = $( this ),
  13822. c_original = {
  13823. height: child.height(),
  13824. width: child.width(),
  13825. outerHeight: child.outerHeight(),
  13826. outerWidth: child.outerWidth()
  13827. };
  13828. if (restore) {
  13829. $.effects.save(child, props2);
  13830. }
  13831. child.from = {
  13832. height: c_original.height * factor.from.y,
  13833. width: c_original.width * factor.from.x,
  13834. outerHeight: c_original.outerHeight * factor.from.y,
  13835. outerWidth: c_original.outerWidth * factor.from.x
  13836. };
  13837. child.to = {
  13838. height: c_original.height * factor.to.y,
  13839. width: c_original.width * factor.to.x,
  13840. outerHeight: c_original.height * factor.to.y,
  13841. outerWidth: c_original.width * factor.to.x
  13842. };
  13843. // Vertical props scaling
  13844. if ( factor.from.y !== factor.to.y ) {
  13845. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  13846. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  13847. }
  13848. // Horizontal props scaling
  13849. if ( factor.from.x !== factor.to.x ) {
  13850. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  13851. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  13852. }
  13853. // Animate children
  13854. child.css( child.from );
  13855. child.animate( child.to, o.duration, o.easing, function() {
  13856. // Restore children
  13857. if ( restore ) {
  13858. $.effects.restore( child, props2 );
  13859. }
  13860. });
  13861. });
  13862. }
  13863. // Animate
  13864. el.animate( el.to, {
  13865. queue: false,
  13866. duration: o.duration,
  13867. easing: o.easing,
  13868. complete: function() {
  13869. if ( el.to.opacity === 0 ) {
  13870. el.css( "opacity", el.from.opacity );
  13871. }
  13872. if ( mode === "hide" ) {
  13873. el.hide();
  13874. }
  13875. $.effects.restore( el, props );
  13876. if ( !restore ) {
  13877. // we need to calculate our new positioning based on the scaling
  13878. if ( position === "static" ) {
  13879. el.css({
  13880. position: "relative",
  13881. top: el.to.top,
  13882. left: el.to.left
  13883. });
  13884. } else {
  13885. $.each([ "top", "left" ], function( idx, pos ) {
  13886. el.css( pos, function( _, str ) {
  13887. var val = parseInt( str, 10 ),
  13888. toRef = idx ? el.to.left : el.to.top;
  13889. // if original was "auto", recalculate the new value from wrapper
  13890. if ( str === "auto" ) {
  13891. return toRef + "px";
  13892. }
  13893. return val + toRef + "px";
  13894. });
  13895. });
  13896. }
  13897. }
  13898. $.effects.removeWrapper( el );
  13899. done();
  13900. }
  13901. });
  13902. };
  13903. /*!
  13904. * jQuery UI Effects Scale 1.11.4
  13905. * http://jqueryui.com
  13906. *
  13907. * Copyright jQuery Foundation and other contributors
  13908. * Released under the MIT license.
  13909. * http://jquery.org/license
  13910. *
  13911. * http://api.jqueryui.com/scale-effect/
  13912. */
  13913. var effectScale = $.effects.effect.scale = function( o, done ) {
  13914. // Create element
  13915. var el = $( this ),
  13916. options = $.extend( true, {}, o ),
  13917. mode = $.effects.setMode( el, o.mode || "effect" ),
  13918. percent = parseInt( o.percent, 10 ) ||
  13919. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  13920. direction = o.direction || "both",
  13921. origin = o.origin,
  13922. original = {
  13923. height: el.height(),
  13924. width: el.width(),
  13925. outerHeight: el.outerHeight(),
  13926. outerWidth: el.outerWidth()
  13927. },
  13928. factor = {
  13929. y: direction !== "horizontal" ? (percent / 100) : 1,
  13930. x: direction !== "vertical" ? (percent / 100) : 1
  13931. };
  13932. // We are going to pass this effect to the size effect:
  13933. options.effect = "size";
  13934. options.queue = false;
  13935. options.complete = done;
  13936. // Set default origin and restore for show/hide
  13937. if ( mode !== "effect" ) {
  13938. options.origin = origin || [ "middle", "center" ];
  13939. options.restore = true;
  13940. }
  13941. options.from = o.from || ( mode === "show" ? {
  13942. height: 0,
  13943. width: 0,
  13944. outerHeight: 0,
  13945. outerWidth: 0
  13946. } : original );
  13947. options.to = {
  13948. height: original.height * factor.y,
  13949. width: original.width * factor.x,
  13950. outerHeight: original.outerHeight * factor.y,
  13951. outerWidth: original.outerWidth * factor.x
  13952. };
  13953. // Fade option to support puff
  13954. if ( options.fade ) {
  13955. if ( mode === "show" ) {
  13956. options.from.opacity = 0;
  13957. options.to.opacity = 1;
  13958. }
  13959. if ( mode === "hide" ) {
  13960. options.from.opacity = 1;
  13961. options.to.opacity = 0;
  13962. }
  13963. }
  13964. // Animate
  13965. el.effect( options );
  13966. };
  13967. /*!
  13968. * jQuery UI Effects Puff 1.11.4
  13969. * http://jqueryui.com
  13970. *
  13971. * Copyright jQuery Foundation and other contributors
  13972. * Released under the MIT license.
  13973. * http://jquery.org/license
  13974. *
  13975. * http://api.jqueryui.com/puff-effect/
  13976. */
  13977. var effectPuff = $.effects.effect.puff = function( o, done ) {
  13978. var elem = $( this ),
  13979. mode = $.effects.setMode( elem, o.mode || "hide" ),
  13980. hide = mode === "hide",
  13981. percent = parseInt( o.percent, 10 ) || 150,
  13982. factor = percent / 100,
  13983. original = {
  13984. height: elem.height(),
  13985. width: elem.width(),
  13986. outerHeight: elem.outerHeight(),
  13987. outerWidth: elem.outerWidth()
  13988. };
  13989. $.extend( o, {
  13990. effect: "scale",
  13991. queue: false,
  13992. fade: true,
  13993. mode: mode,
  13994. complete: done,
  13995. percent: hide ? percent : 100,
  13996. from: hide ?
  13997. original :
  13998. {
  13999. height: original.height * factor,
  14000. width: original.width * factor,
  14001. outerHeight: original.outerHeight * factor,
  14002. outerWidth: original.outerWidth * factor
  14003. }
  14004. });
  14005. elem.effect( o );
  14006. };
  14007. /*!
  14008. * jQuery UI Effects Pulsate 1.11.4
  14009. * http://jqueryui.com
  14010. *
  14011. * Copyright jQuery Foundation and other contributors
  14012. * Released under the MIT license.
  14013. * http://jquery.org/license
  14014. *
  14015. * http://api.jqueryui.com/pulsate-effect/
  14016. */
  14017. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  14018. var elem = $( this ),
  14019. mode = $.effects.setMode( elem, o.mode || "show" ),
  14020. show = mode === "show",
  14021. hide = mode === "hide",
  14022. showhide = ( show || mode === "hide" ),
  14023. // showing or hiding leaves of the "last" animation
  14024. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  14025. duration = o.duration / anims,
  14026. animateTo = 0,
  14027. queue = elem.queue(),
  14028. queuelen = queue.length,
  14029. i;
  14030. if ( show || !elem.is(":visible")) {
  14031. elem.css( "opacity", 0 ).show();
  14032. animateTo = 1;
  14033. }
  14034. // anims - 1 opacity "toggles"
  14035. for ( i = 1; i < anims; i++ ) {
  14036. elem.animate({
  14037. opacity: animateTo
  14038. }, duration, o.easing );
  14039. animateTo = 1 - animateTo;
  14040. }
  14041. elem.animate({
  14042. opacity: animateTo
  14043. }, duration, o.easing);
  14044. elem.queue(function() {
  14045. if ( hide ) {
  14046. elem.hide();
  14047. }
  14048. done();
  14049. });
  14050. // We just queued up "anims" animations, we need to put them next in the queue
  14051. if ( queuelen > 1 ) {
  14052. queue.splice.apply( queue,
  14053. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14054. }
  14055. elem.dequeue();
  14056. };
  14057. /*!
  14058. * jQuery UI Effects Shake 1.11.4
  14059. * http://jqueryui.com
  14060. *
  14061. * Copyright jQuery Foundation and other contributors
  14062. * Released under the MIT license.
  14063. * http://jquery.org/license
  14064. *
  14065. * http://api.jqueryui.com/shake-effect/
  14066. */
  14067. var effectShake = $.effects.effect.shake = function( o, done ) {
  14068. var el = $( this ),
  14069. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  14070. mode = $.effects.setMode( el, o.mode || "effect" ),
  14071. direction = o.direction || "left",
  14072. distance = o.distance || 20,
  14073. times = o.times || 3,
  14074. anims = times * 2 + 1,
  14075. speed = Math.round( o.duration / anims ),
  14076. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14077. positiveMotion = (direction === "up" || direction === "left"),
  14078. animation = {},
  14079. animation1 = {},
  14080. animation2 = {},
  14081. i,
  14082. // we will need to re-assemble the queue to stack our animations in place
  14083. queue = el.queue(),
  14084. queuelen = queue.length;
  14085. $.effects.save( el, props );
  14086. el.show();
  14087. $.effects.createWrapper( el );
  14088. // Animation
  14089. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  14090. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  14091. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  14092. // Animate
  14093. el.animate( animation, speed, o.easing );
  14094. // Shakes
  14095. for ( i = 1; i < times; i++ ) {
  14096. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  14097. }
  14098. el
  14099. .animate( animation1, speed, o.easing )
  14100. .animate( animation, speed / 2, o.easing )
  14101. .queue(function() {
  14102. if ( mode === "hide" ) {
  14103. el.hide();
  14104. }
  14105. $.effects.restore( el, props );
  14106. $.effects.removeWrapper( el );
  14107. done();
  14108. });
  14109. // inject all the animations we just queued to be first in line (after "inprogress")
  14110. if ( queuelen > 1) {
  14111. queue.splice.apply( queue,
  14112. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14113. }
  14114. el.dequeue();
  14115. };
  14116. /*!
  14117. * jQuery UI Effects Slide 1.11.4
  14118. * http://jqueryui.com
  14119. *
  14120. * Copyright jQuery Foundation and other contributors
  14121. * Released under the MIT license.
  14122. * http://jquery.org/license
  14123. *
  14124. * http://api.jqueryui.com/slide-effect/
  14125. */
  14126. var effectSlide = $.effects.effect.slide = function( o, done ) {
  14127. // Create element
  14128. var el = $( this ),
  14129. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  14130. mode = $.effects.setMode( el, o.mode || "show" ),
  14131. show = mode === "show",
  14132. direction = o.direction || "left",
  14133. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14134. positiveMotion = (direction === "up" || direction === "left"),
  14135. distance,
  14136. animation = {};
  14137. // Adjust
  14138. $.effects.save( el, props );
  14139. el.show();
  14140. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  14141. $.effects.createWrapper( el ).css({
  14142. overflow: "hidden"
  14143. });
  14144. if ( show ) {
  14145. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  14146. }
  14147. // Animation
  14148. animation[ ref ] = ( show ?
  14149. ( positiveMotion ? "+=" : "-=") :
  14150. ( positiveMotion ? "-=" : "+=")) +
  14151. distance;
  14152. // Animate
  14153. el.animate( animation, {
  14154. queue: false,
  14155. duration: o.duration,
  14156. easing: o.easing,
  14157. complete: function() {
  14158. if ( mode === "hide" ) {
  14159. el.hide();
  14160. }
  14161. $.effects.restore( el, props );
  14162. $.effects.removeWrapper( el );
  14163. done();
  14164. }
  14165. });
  14166. };
  14167. /*!
  14168. * jQuery UI Effects Transfer 1.11.4
  14169. * http://jqueryui.com
  14170. *
  14171. * Copyright jQuery Foundation and other contributors
  14172. * Released under the MIT license.
  14173. * http://jquery.org/license
  14174. *
  14175. * http://api.jqueryui.com/transfer-effect/
  14176. */
  14177. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  14178. var elem = $( this ),
  14179. target = $( o.to ),
  14180. targetFixed = target.css( "position" ) === "fixed",
  14181. body = $("body"),
  14182. fixTop = targetFixed ? body.scrollTop() : 0,
  14183. fixLeft = targetFixed ? body.scrollLeft() : 0,
  14184. endPosition = target.offset(),
  14185. animation = {
  14186. top: endPosition.top - fixTop,
  14187. left: endPosition.left - fixLeft,
  14188. height: target.innerHeight(),
  14189. width: target.innerWidth()
  14190. },
  14191. startPosition = elem.offset(),
  14192. transfer = $( "<div class='ui-effects-transfer'></div>" )
  14193. .appendTo( document.body )
  14194. .addClass( o.className )
  14195. .css({
  14196. top: startPosition.top - fixTop,
  14197. left: startPosition.left - fixLeft,
  14198. height: elem.innerHeight(),
  14199. width: elem.innerWidth(),
  14200. position: targetFixed ? "fixed" : "absolute"
  14201. })
  14202. .animate( animation, o.duration, o.easing, function() {
  14203. transfer.remove();
  14204. done();
  14205. });
  14206. };
  14207. }));