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

15008 lines
426 KiB

  1. /*! jQuery UI - v1.10.4 - 2014-01-17
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.slider.js, jquery.ui.sortable.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  9. $.ui = $.ui || {};
  10. $.extend( $.ui, {
  11. version: "1.10.4",
  12. keyCode: {
  13. BACKSPACE: 8,
  14. COMMA: 188,
  15. DELETE: 46,
  16. DOWN: 40,
  17. END: 35,
  18. ENTER: 13,
  19. ESCAPE: 27,
  20. HOME: 36,
  21. LEFT: 37,
  22. NUMPAD_ADD: 107,
  23. NUMPAD_DECIMAL: 110,
  24. NUMPAD_DIVIDE: 111,
  25. NUMPAD_ENTER: 108,
  26. NUMPAD_MULTIPLY: 106,
  27. NUMPAD_SUBTRACT: 109,
  28. PAGE_DOWN: 34,
  29. PAGE_UP: 33,
  30. PERIOD: 190,
  31. RIGHT: 39,
  32. SPACE: 32,
  33. TAB: 9,
  34. UP: 38
  35. }
  36. });
  37. // plugins
  38. $.fn.extend({
  39. focus: (function( orig ) {
  40. return function( delay, fn ) {
  41. return typeof delay === "number" ?
  42. this.each(function() {
  43. var elem = this;
  44. setTimeout(function() {
  45. $( elem ).focus();
  46. if ( fn ) {
  47. fn.call( elem );
  48. }
  49. }, delay );
  50. }) :
  51. orig.apply( this, arguments );
  52. };
  53. })( $.fn.focus ),
  54. scrollParent: function() {
  55. var scrollParent;
  56. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  57. scrollParent = this.parents().filter(function() {
  58. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  59. }).eq(0);
  60. } else {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  63. }).eq(0);
  64. }
  65. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
  66. },
  67. zIndex: function( zIndex ) {
  68. if ( zIndex !== undefined ) {
  69. return this.css( "zIndex", zIndex );
  70. }
  71. if ( this.length ) {
  72. var elem = $( this[ 0 ] ), position, value;
  73. while ( elem.length && elem[ 0 ] !== document ) {
  74. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  75. // This makes behavior of this function consistent across browsers
  76. // WebKit always returns auto if the element is positioned
  77. position = elem.css( "position" );
  78. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  79. // IE returns 0 when zIndex is not specified
  80. // other browsers return a string
  81. // we ignore the case of nested elements with an explicit value of 0
  82. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  83. value = parseInt( elem.css( "zIndex" ), 10 );
  84. if ( !isNaN( value ) && value !== 0 ) {
  85. return value;
  86. }
  87. }
  88. elem = elem.parent();
  89. }
  90. }
  91. return 0;
  92. },
  93. uniqueId: function() {
  94. return this.each(function() {
  95. if ( !this.id ) {
  96. this.id = "ui-id-" + (++uuid);
  97. }
  98. });
  99. },
  100. removeUniqueId: function() {
  101. return this.each(function() {
  102. if ( runiqueId.test( this.id ) ) {
  103. $( this ).removeAttr( "id" );
  104. }
  105. });
  106. }
  107. });
  108. // selectors
  109. function focusable( element, isTabIndexNotNaN ) {
  110. var map, mapName, img,
  111. nodeName = element.nodeName.toLowerCase();
  112. if ( "area" === nodeName ) {
  113. map = element.parentNode;
  114. mapName = map.name;
  115. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  116. return false;
  117. }
  118. img = $( "img[usemap=#" + mapName + "]" )[0];
  119. return !!img && visible( img );
  120. }
  121. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  122. !element.disabled :
  123. "a" === nodeName ?
  124. element.href || isTabIndexNotNaN :
  125. isTabIndexNotNaN) &&
  126. // the element and all of its ancestors must be visible
  127. visible( element );
  128. }
  129. function visible( element ) {
  130. return $.expr.filters.visible( element ) &&
  131. !$( element ).parents().addBack().filter(function() {
  132. return $.css( this, "visibility" ) === "hidden";
  133. }).length;
  134. }
  135. $.extend( $.expr[ ":" ], {
  136. data: $.expr.createPseudo ?
  137. $.expr.createPseudo(function( dataName ) {
  138. return function( elem ) {
  139. return !!$.data( elem, dataName );
  140. };
  141. }) :
  142. // support: jQuery <1.8
  143. function( elem, i, match ) {
  144. return !!$.data( elem, match[ 3 ] );
  145. },
  146. focusable: function( element ) {
  147. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  148. },
  149. tabbable: function( element ) {
  150. var tabIndex = $.attr( element, "tabindex" ),
  151. isTabIndexNaN = isNaN( tabIndex );
  152. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  153. }
  154. });
  155. // support: jQuery <1.8
  156. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  157. $.each( [ "Width", "Height" ], function( i, name ) {
  158. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  159. type = name.toLowerCase(),
  160. orig = {
  161. innerWidth: $.fn.innerWidth,
  162. innerHeight: $.fn.innerHeight,
  163. outerWidth: $.fn.outerWidth,
  164. outerHeight: $.fn.outerHeight
  165. };
  166. function reduce( elem, size, border, margin ) {
  167. $.each( side, function() {
  168. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  169. if ( border ) {
  170. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  171. }
  172. if ( margin ) {
  173. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  174. }
  175. });
  176. return size;
  177. }
  178. $.fn[ "inner" + name ] = function( size ) {
  179. if ( size === undefined ) {
  180. return orig[ "inner" + name ].call( this );
  181. }
  182. return this.each(function() {
  183. $( this ).css( type, reduce( this, size ) + "px" );
  184. });
  185. };
  186. $.fn[ "outer" + name] = function( size, margin ) {
  187. if ( typeof size !== "number" ) {
  188. return orig[ "outer" + name ].call( this, size );
  189. }
  190. return this.each(function() {
  191. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  192. });
  193. };
  194. });
  195. }
  196. // support: jQuery <1.8
  197. if ( !$.fn.addBack ) {
  198. $.fn.addBack = function( selector ) {
  199. return this.add( selector == null ?
  200. this.prevObject : this.prevObject.filter( selector )
  201. );
  202. };
  203. }
  204. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  205. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  206. $.fn.removeData = (function( removeData ) {
  207. return function( key ) {
  208. if ( arguments.length ) {
  209. return removeData.call( this, $.camelCase( key ) );
  210. } else {
  211. return removeData.call( this );
  212. }
  213. };
  214. })( $.fn.removeData );
  215. }
  216. // deprecated
  217. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  218. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  219. $.fn.extend({
  220. disableSelection: function() {
  221. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  222. ".ui-disableSelection", function( event ) {
  223. event.preventDefault();
  224. });
  225. },
  226. enableSelection: function() {
  227. return this.unbind( ".ui-disableSelection" );
  228. }
  229. });
  230. $.extend( $.ui, {
  231. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  232. plugin: {
  233. add: function( module, option, set ) {
  234. var i,
  235. proto = $.ui[ module ].prototype;
  236. for ( i in set ) {
  237. proto.plugins[ i ] = proto.plugins[ i ] || [];
  238. proto.plugins[ i ].push( [ option, set[ i ] ] );
  239. }
  240. },
  241. call: function( instance, name, args ) {
  242. var i,
  243. set = instance.plugins[ name ];
  244. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  245. return;
  246. }
  247. for ( i = 0; i < set.length; i++ ) {
  248. if ( instance.options[ set[ i ][ 0 ] ] ) {
  249. set[ i ][ 1 ].apply( instance.element, args );
  250. }
  251. }
  252. }
  253. },
  254. // only used by resizable
  255. hasScroll: function( el, a ) {
  256. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  257. if ( $( el ).css( "overflow" ) === "hidden") {
  258. return false;
  259. }
  260. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  261. has = false;
  262. if ( el[ scroll ] > 0 ) {
  263. return true;
  264. }
  265. // TODO: determine which cases actually cause this to happen
  266. // if the element doesn't have the scroll set, see if it's possible to
  267. // set the scroll
  268. el[ scroll ] = 1;
  269. has = ( el[ scroll ] > 0 );
  270. el[ scroll ] = 0;
  271. return has;
  272. }
  273. });
  274. })( jQuery );
  275. (function( $, undefined ) {
  276. var uuid = 0,
  277. slice = Array.prototype.slice,
  278. _cleanData = $.cleanData;
  279. $.cleanData = function( elems ) {
  280. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  281. try {
  282. $( elem ).triggerHandler( "remove" );
  283. // http://bugs.jquery.com/ticket/8235
  284. } catch( e ) {}
  285. }
  286. _cleanData( elems );
  287. };
  288. $.widget = function( name, base, prototype ) {
  289. var fullName, existingConstructor, constructor, basePrototype,
  290. // proxiedPrototype allows the provided prototype to remain unmodified
  291. // so that it can be used as a mixin for multiple widgets (#8876)
  292. proxiedPrototype = {},
  293. namespace = name.split( "." )[ 0 ];
  294. name = name.split( "." )[ 1 ];
  295. fullName = namespace + "-" + name;
  296. if ( !prototype ) {
  297. prototype = base;
  298. base = $.Widget;
  299. }
  300. // create selector for plugin
  301. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  302. return !!$.data( elem, fullName );
  303. };
  304. $[ namespace ] = $[ namespace ] || {};
  305. existingConstructor = $[ namespace ][ name ];
  306. constructor = $[ namespace ][ name ] = function( options, element ) {
  307. // allow instantiation without "new" keyword
  308. if ( !this._createWidget ) {
  309. return new constructor( options, element );
  310. }
  311. // allow instantiation without initializing for simple inheritance
  312. // must use "new" keyword (the code above always passes args)
  313. if ( arguments.length ) {
  314. this._createWidget( options, element );
  315. }
  316. };
  317. // extend with the existing constructor to carry over any static properties
  318. $.extend( constructor, existingConstructor, {
  319. version: prototype.version,
  320. // copy the object used to create the prototype in case we need to
  321. // redefine the widget later
  322. _proto: $.extend( {}, prototype ),
  323. // track widgets that inherit from this widget in case this widget is
  324. // redefined after a widget inherits from it
  325. _childConstructors: []
  326. });
  327. basePrototype = new base();
  328. // we need to make the options hash a property directly on the new instance
  329. // otherwise we'll modify the options hash on the prototype that we're
  330. // inheriting from
  331. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  332. $.each( prototype, function( prop, value ) {
  333. if ( !$.isFunction( value ) ) {
  334. proxiedPrototype[ prop ] = value;
  335. return;
  336. }
  337. proxiedPrototype[ prop ] = (function() {
  338. var _super = function() {
  339. return base.prototype[ prop ].apply( this, arguments );
  340. },
  341. _superApply = function( args ) {
  342. return base.prototype[ prop ].apply( this, args );
  343. };
  344. return function() {
  345. var __super = this._super,
  346. __superApply = this._superApply,
  347. returnValue;
  348. this._super = _super;
  349. this._superApply = _superApply;
  350. returnValue = value.apply( this, arguments );
  351. this._super = __super;
  352. this._superApply = __superApply;
  353. return returnValue;
  354. };
  355. })();
  356. });
  357. constructor.prototype = $.widget.extend( basePrototype, {
  358. // TODO: remove support for widgetEventPrefix
  359. // always use the name + a colon as the prefix, e.g., draggable:start
  360. // don't prefix for widgets that aren't DOM-based
  361. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  362. }, proxiedPrototype, {
  363. constructor: constructor,
  364. namespace: namespace,
  365. widgetName: name,
  366. widgetFullName: fullName
  367. });
  368. // If this widget is being redefined then we need to find all widgets that
  369. // are inheriting from it and redefine all of them so that they inherit from
  370. // the new version of this widget. We're essentially trying to replace one
  371. // level in the prototype chain.
  372. if ( existingConstructor ) {
  373. $.each( existingConstructor._childConstructors, function( i, child ) {
  374. var childPrototype = child.prototype;
  375. // redefine the child widget using the same prototype that was
  376. // originally used, but inherit from the new version of the base
  377. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  378. });
  379. // remove the list of existing child constructors from the old constructor
  380. // so the old child constructors can be garbage collected
  381. delete existingConstructor._childConstructors;
  382. } else {
  383. base._childConstructors.push( constructor );
  384. }
  385. $.widget.bridge( name, constructor );
  386. };
  387. $.widget.extend = function( target ) {
  388. var input = slice.call( arguments, 1 ),
  389. inputIndex = 0,
  390. inputLength = input.length,
  391. key,
  392. value;
  393. for ( ; inputIndex < inputLength; inputIndex++ ) {
  394. for ( key in input[ inputIndex ] ) {
  395. value = input[ inputIndex ][ key ];
  396. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  397. // Clone objects
  398. if ( $.isPlainObject( value ) ) {
  399. target[ key ] = $.isPlainObject( target[ key ] ) ?
  400. $.widget.extend( {}, target[ key ], value ) :
  401. // Don't extend strings, arrays, etc. with objects
  402. $.widget.extend( {}, value );
  403. // Copy everything else by reference
  404. } else {
  405. target[ key ] = value;
  406. }
  407. }
  408. }
  409. }
  410. return target;
  411. };
  412. $.widget.bridge = function( name, object ) {
  413. var fullName = object.prototype.widgetFullName || name;
  414. $.fn[ name ] = function( options ) {
  415. var isMethodCall = typeof options === "string",
  416. args = slice.call( arguments, 1 ),
  417. returnValue = this;
  418. // allow multiple hashes to be passed on init
  419. options = !isMethodCall && args.length ?
  420. $.widget.extend.apply( null, [ options ].concat(args) ) :
  421. options;
  422. if ( isMethodCall ) {
  423. this.each(function() {
  424. var methodValue,
  425. instance = $.data( this, fullName );
  426. if ( !instance ) {
  427. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  428. "attempted to call method '" + options + "'" );
  429. }
  430. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  431. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  432. }
  433. methodValue = instance[ options ].apply( instance, args );
  434. if ( methodValue !== instance && methodValue !== undefined ) {
  435. returnValue = methodValue && methodValue.jquery ?
  436. returnValue.pushStack( methodValue.get() ) :
  437. methodValue;
  438. return false;
  439. }
  440. });
  441. } else {
  442. this.each(function() {
  443. var instance = $.data( this, fullName );
  444. if ( instance ) {
  445. instance.option( options || {} )._init();
  446. } else {
  447. $.data( this, fullName, new object( options, this ) );
  448. }
  449. });
  450. }
  451. return returnValue;
  452. };
  453. };
  454. $.Widget = function( /* options, element */ ) {};
  455. $.Widget._childConstructors = [];
  456. $.Widget.prototype = {
  457. widgetName: "widget",
  458. widgetEventPrefix: "",
  459. defaultElement: "<div>",
  460. options: {
  461. disabled: false,
  462. // callbacks
  463. create: null
  464. },
  465. _createWidget: function( options, element ) {
  466. element = $( element || this.defaultElement || this )[ 0 ];
  467. this.element = $( element );
  468. this.uuid = uuid++;
  469. this.eventNamespace = "." + this.widgetName + this.uuid;
  470. this.options = $.widget.extend( {},
  471. this.options,
  472. this._getCreateOptions(),
  473. options );
  474. this.bindings = $();
  475. this.hoverable = $();
  476. this.focusable = $();
  477. if ( element !== this ) {
  478. $.data( element, this.widgetFullName, this );
  479. this._on( true, this.element, {
  480. remove: function( event ) {
  481. if ( event.target === element ) {
  482. this.destroy();
  483. }
  484. }
  485. });
  486. this.document = $( element.style ?
  487. // element within the document
  488. element.ownerDocument :
  489. // element is window or document
  490. element.document || element );
  491. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  492. }
  493. this._create();
  494. this._trigger( "create", null, this._getCreateEventData() );
  495. this._init();
  496. },
  497. _getCreateOptions: $.noop,
  498. _getCreateEventData: $.noop,
  499. _create: $.noop,
  500. _init: $.noop,
  501. destroy: function() {
  502. this._destroy();
  503. // we can probably remove the unbind calls in 2.0
  504. // all event bindings should go through this._on()
  505. this.element
  506. .unbind( this.eventNamespace )
  507. // 1.9 BC for #7810
  508. // TODO remove dual storage
  509. .removeData( this.widgetName )
  510. .removeData( this.widgetFullName )
  511. // support: jquery <1.6.3
  512. // http://bugs.jquery.com/ticket/9413
  513. .removeData( $.camelCase( this.widgetFullName ) );
  514. this.widget()
  515. .unbind( this.eventNamespace )
  516. .removeAttr( "aria-disabled" )
  517. .removeClass(
  518. this.widgetFullName + "-disabled " +
  519. "ui-state-disabled" );
  520. // clean up events and states
  521. this.bindings.unbind( this.eventNamespace );
  522. this.hoverable.removeClass( "ui-state-hover" );
  523. this.focusable.removeClass( "ui-state-focus" );
  524. },
  525. _destroy: $.noop,
  526. widget: function() {
  527. return this.element;
  528. },
  529. option: function( key, value ) {
  530. var options = key,
  531. parts,
  532. curOption,
  533. i;
  534. if ( arguments.length === 0 ) {
  535. // don't return a reference to the internal hash
  536. return $.widget.extend( {}, this.options );
  537. }
  538. if ( typeof key === "string" ) {
  539. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  540. options = {};
  541. parts = key.split( "." );
  542. key = parts.shift();
  543. if ( parts.length ) {
  544. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  545. for ( i = 0; i < parts.length - 1; i++ ) {
  546. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  547. curOption = curOption[ parts[ i ] ];
  548. }
  549. key = parts.pop();
  550. if ( arguments.length === 1 ) {
  551. return curOption[ key ] === undefined ? null : curOption[ key ];
  552. }
  553. curOption[ key ] = value;
  554. } else {
  555. if ( arguments.length === 1 ) {
  556. return this.options[ key ] === undefined ? null : this.options[ key ];
  557. }
  558. options[ key ] = value;
  559. }
  560. }
  561. this._setOptions( options );
  562. return this;
  563. },
  564. _setOptions: function( options ) {
  565. var key;
  566. for ( key in options ) {
  567. this._setOption( key, options[ key ] );
  568. }
  569. return this;
  570. },
  571. _setOption: function( key, value ) {
  572. this.options[ key ] = value;
  573. if ( key === "disabled" ) {
  574. this.widget()
  575. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  576. .attr( "aria-disabled", value );
  577. this.hoverable.removeClass( "ui-state-hover" );
  578. this.focusable.removeClass( "ui-state-focus" );
  579. }
  580. return this;
  581. },
  582. enable: function() {
  583. return this._setOption( "disabled", false );
  584. },
  585. disable: function() {
  586. return this._setOption( "disabled", true );
  587. },
  588. _on: function( suppressDisabledCheck, element, handlers ) {
  589. var delegateElement,
  590. instance = this;
  591. // no suppressDisabledCheck flag, shuffle arguments
  592. if ( typeof suppressDisabledCheck !== "boolean" ) {
  593. handlers = element;
  594. element = suppressDisabledCheck;
  595. suppressDisabledCheck = false;
  596. }
  597. // no element argument, shuffle and use this.element
  598. if ( !handlers ) {
  599. handlers = element;
  600. element = this.element;
  601. delegateElement = this.widget();
  602. } else {
  603. // accept selectors, DOM elements
  604. element = delegateElement = $( element );
  605. this.bindings = this.bindings.add( element );
  606. }
  607. $.each( handlers, function( event, handler ) {
  608. function handlerProxy() {
  609. // allow widgets to customize the disabled handling
  610. // - disabled as an array instead of boolean
  611. // - disabled class as method for disabling individual parts
  612. if ( !suppressDisabledCheck &&
  613. ( instance.options.disabled === true ||
  614. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  615. return;
  616. }
  617. return ( typeof handler === "string" ? instance[ handler ] : handler )
  618. .apply( instance, arguments );
  619. }
  620. // copy the guid so direct unbinding works
  621. if ( typeof handler !== "string" ) {
  622. handlerProxy.guid = handler.guid =
  623. handler.guid || handlerProxy.guid || $.guid++;
  624. }
  625. var match = event.match( /^(\w+)\s*(.*)$/ ),
  626. eventName = match[1] + instance.eventNamespace,
  627. selector = match[2];
  628. if ( selector ) {
  629. delegateElement.delegate( selector, eventName, handlerProxy );
  630. } else {
  631. element.bind( eventName, handlerProxy );
  632. }
  633. });
  634. },
  635. _off: function( element, eventName ) {
  636. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  637. element.unbind( eventName ).undelegate( eventName );
  638. },
  639. _delay: function( handler, delay ) {
  640. function handlerProxy() {
  641. return ( typeof handler === "string" ? instance[ handler ] : handler )
  642. .apply( instance, arguments );
  643. }
  644. var instance = this;
  645. return setTimeout( handlerProxy, delay || 0 );
  646. },
  647. _hoverable: function( element ) {
  648. this.hoverable = this.hoverable.add( element );
  649. this._on( element, {
  650. mouseenter: function( event ) {
  651. $( event.currentTarget ).addClass( "ui-state-hover" );
  652. },
  653. mouseleave: function( event ) {
  654. $( event.currentTarget ).removeClass( "ui-state-hover" );
  655. }
  656. });
  657. },
  658. _focusable: function( element ) {
  659. this.focusable = this.focusable.add( element );
  660. this._on( element, {
  661. focusin: function( event ) {
  662. $( event.currentTarget ).addClass( "ui-state-focus" );
  663. },
  664. focusout: function( event ) {
  665. $( event.currentTarget ).removeClass( "ui-state-focus" );
  666. }
  667. });
  668. },
  669. _trigger: function( type, event, data ) {
  670. var prop, orig,
  671. callback = this.options[ type ];
  672. data = data || {};
  673. event = $.Event( event );
  674. event.type = ( type === this.widgetEventPrefix ?
  675. type :
  676. this.widgetEventPrefix + type ).toLowerCase();
  677. // the original event may come from any element
  678. // so we need to reset the target on the new event
  679. event.target = this.element[ 0 ];
  680. // copy original event properties over to the new event
  681. orig = event.originalEvent;
  682. if ( orig ) {
  683. for ( prop in orig ) {
  684. if ( !( prop in event ) ) {
  685. event[ prop ] = orig[ prop ];
  686. }
  687. }
  688. }
  689. this.element.trigger( event, data );
  690. return !( $.isFunction( callback ) &&
  691. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  692. event.isDefaultPrevented() );
  693. }
  694. };
  695. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  696. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  697. if ( typeof options === "string" ) {
  698. options = { effect: options };
  699. }
  700. var hasOptions,
  701. effectName = !options ?
  702. method :
  703. options === true || typeof options === "number" ?
  704. defaultEffect :
  705. options.effect || defaultEffect;
  706. options = options || {};
  707. if ( typeof options === "number" ) {
  708. options = { duration: options };
  709. }
  710. hasOptions = !$.isEmptyObject( options );
  711. options.complete = callback;
  712. if ( options.delay ) {
  713. element.delay( options.delay );
  714. }
  715. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  716. element[ method ]( options );
  717. } else if ( effectName !== method && element[ effectName ] ) {
  718. element[ effectName ]( options.duration, options.easing, callback );
  719. } else {
  720. element.queue(function( next ) {
  721. $( this )[ method ]();
  722. if ( callback ) {
  723. callback.call( element[ 0 ] );
  724. }
  725. next();
  726. });
  727. }
  728. };
  729. });
  730. })( jQuery );
  731. (function( $, undefined ) {
  732. var mouseHandled = false;
  733. $( document ).mouseup( function() {
  734. mouseHandled = false;
  735. });
  736. $.widget("ui.mouse", {
  737. version: "1.10.4",
  738. options: {
  739. cancel: "input,textarea,button,select,option",
  740. distance: 1,
  741. delay: 0
  742. },
  743. _mouseInit: function() {
  744. var that = this;
  745. this.element
  746. .bind("mousedown."+this.widgetName, function(event) {
  747. return that._mouseDown(event);
  748. })
  749. .bind("click."+this.widgetName, function(event) {
  750. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  751. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  752. event.stopImmediatePropagation();
  753. return false;
  754. }
  755. });
  756. this.started = false;
  757. },
  758. // TODO: make sure destroying one instance of mouse doesn't mess with
  759. // other instances of mouse
  760. _mouseDestroy: function() {
  761. this.element.unbind("."+this.widgetName);
  762. if ( this._mouseMoveDelegate ) {
  763. $(document)
  764. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  765. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  766. }
  767. },
  768. _mouseDown: function(event) {
  769. // don't let more than one widget handle mouseStart
  770. if( mouseHandled ) { return; }
  771. // we may have missed mouseup (out of window)
  772. (this._mouseStarted && this._mouseUp(event));
  773. this._mouseDownEvent = event;
  774. var that = this,
  775. btnIsLeft = (event.which === 1),
  776. // event.target.nodeName works around a bug in IE 8 with
  777. // disabled inputs (#7620)
  778. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  779. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  780. return true;
  781. }
  782. this.mouseDelayMet = !this.options.delay;
  783. if (!this.mouseDelayMet) {
  784. this._mouseDelayTimer = setTimeout(function() {
  785. that.mouseDelayMet = true;
  786. }, this.options.delay);
  787. }
  788. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  789. this._mouseStarted = (this._mouseStart(event) !== false);
  790. if (!this._mouseStarted) {
  791. event.preventDefault();
  792. return true;
  793. }
  794. }
  795. // Click event may never have fired (Gecko & Opera)
  796. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  797. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  798. }
  799. // these delegates are required to keep context
  800. this._mouseMoveDelegate = function(event) {
  801. return that._mouseMove(event);
  802. };
  803. this._mouseUpDelegate = function(event) {
  804. return that._mouseUp(event);
  805. };
  806. $(document)
  807. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  808. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  809. event.preventDefault();
  810. mouseHandled = true;
  811. return true;
  812. },
  813. _mouseMove: function(event) {
  814. // IE mouseup check - mouseup happened when mouse was out of window
  815. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  816. return this._mouseUp(event);
  817. }
  818. if (this._mouseStarted) {
  819. this._mouseDrag(event);
  820. return event.preventDefault();
  821. }
  822. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  823. this._mouseStarted =
  824. (this._mouseStart(this._mouseDownEvent, event) !== false);
  825. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  826. }
  827. return !this._mouseStarted;
  828. },
  829. _mouseUp: function(event) {
  830. $(document)
  831. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  832. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  833. if (this._mouseStarted) {
  834. this._mouseStarted = false;
  835. if (event.target === this._mouseDownEvent.target) {
  836. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  837. }
  838. this._mouseStop(event);
  839. }
  840. return false;
  841. },
  842. _mouseDistanceMet: function(event) {
  843. return (Math.max(
  844. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  845. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  846. ) >= this.options.distance
  847. );
  848. },
  849. _mouseDelayMet: function(/* event */) {
  850. return this.mouseDelayMet;
  851. },
  852. // These are placeholder methods, to be overriden by extending plugin
  853. _mouseStart: function(/* event */) {},
  854. _mouseDrag: function(/* event */) {},
  855. _mouseStop: function(/* event */) {},
  856. _mouseCapture: function(/* event */) { return true; }
  857. });
  858. })(jQuery);
  859. (function( $, undefined ) {
  860. $.ui = $.ui || {};
  861. var cachedScrollbarWidth,
  862. max = Math.max,
  863. abs = Math.abs,
  864. round = Math.round,
  865. rhorizontal = /left|center|right/,
  866. rvertical = /top|center|bottom/,
  867. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  868. rposition = /^\w+/,
  869. rpercent = /%$/,
  870. _position = $.fn.position;
  871. function getOffsets( offsets, width, height ) {
  872. return [
  873. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  874. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  875. ];
  876. }
  877. function parseCss( element, property ) {
  878. return parseInt( $.css( element, property ), 10 ) || 0;
  879. }
  880. function getDimensions( elem ) {
  881. var raw = elem[0];
  882. if ( raw.nodeType === 9 ) {
  883. return {
  884. width: elem.width(),
  885. height: elem.height(),
  886. offset: { top: 0, left: 0 }
  887. };
  888. }
  889. if ( $.isWindow( raw ) ) {
  890. return {
  891. width: elem.width(),
  892. height: elem.height(),
  893. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  894. };
  895. }
  896. if ( raw.preventDefault ) {
  897. return {
  898. width: 0,
  899. height: 0,
  900. offset: { top: raw.pageY, left: raw.pageX }
  901. };
  902. }
  903. return {
  904. width: elem.outerWidth(),
  905. height: elem.outerHeight(),
  906. offset: elem.offset()
  907. };
  908. }
  909. $.position = {
  910. scrollbarWidth: function() {
  911. if ( cachedScrollbarWidth !== undefined ) {
  912. return cachedScrollbarWidth;
  913. }
  914. var w1, w2,
  915. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  916. innerDiv = div.children()[0];
  917. $( "body" ).append( div );
  918. w1 = innerDiv.offsetWidth;
  919. div.css( "overflow", "scroll" );
  920. w2 = innerDiv.offsetWidth;
  921. if ( w1 === w2 ) {
  922. w2 = div[0].clientWidth;
  923. }
  924. div.remove();
  925. return (cachedScrollbarWidth = w1 - w2);
  926. },
  927. getScrollInfo: function( within ) {
  928. var overflowX = within.isWindow || within.isDocument ? "" :
  929. within.element.css( "overflow-x" ),
  930. overflowY = within.isWindow || within.isDocument ? "" :
  931. within.element.css( "overflow-y" ),
  932. hasOverflowX = overflowX === "scroll" ||
  933. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  934. hasOverflowY = overflowY === "scroll" ||
  935. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  936. return {
  937. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  938. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  939. };
  940. },
  941. getWithinInfo: function( element ) {
  942. var withinElement = $( element || window ),
  943. isWindow = $.isWindow( withinElement[0] ),
  944. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  945. return {
  946. element: withinElement,
  947. isWindow: isWindow,
  948. isDocument: isDocument,
  949. offset: withinElement.offset() || { left: 0, top: 0 },
  950. scrollLeft: withinElement.scrollLeft(),
  951. scrollTop: withinElement.scrollTop(),
  952. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  953. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  954. };
  955. }
  956. };
  957. $.fn.position = function( options ) {
  958. if ( !options || !options.of ) {
  959. return _position.apply( this, arguments );
  960. }
  961. // make a copy, we don't want to modify arguments
  962. options = $.extend( {}, options );
  963. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  964. target = $( options.of ),
  965. within = $.position.getWithinInfo( options.within ),
  966. scrollInfo = $.position.getScrollInfo( within ),
  967. collision = ( options.collision || "flip" ).split( " " ),
  968. offsets = {};
  969. dimensions = getDimensions( target );
  970. if ( target[0].preventDefault ) {
  971. // force left top to allow flipping
  972. options.at = "left top";
  973. }
  974. targetWidth = dimensions.width;
  975. targetHeight = dimensions.height;
  976. targetOffset = dimensions.offset;
  977. // clone to reuse original targetOffset later
  978. basePosition = $.extend( {}, targetOffset );
  979. // force my and at to have valid horizontal and vertical positions
  980. // if a value is missing or invalid, it will be converted to center
  981. $.each( [ "my", "at" ], function() {
  982. var pos = ( options[ this ] || "" ).split( " " ),
  983. horizontalOffset,
  984. verticalOffset;
  985. if ( pos.length === 1) {
  986. pos = rhorizontal.test( pos[ 0 ] ) ?
  987. pos.concat( [ "center" ] ) :
  988. rvertical.test( pos[ 0 ] ) ?
  989. [ "center" ].concat( pos ) :
  990. [ "center", "center" ];
  991. }
  992. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  993. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  994. // calculate offsets
  995. horizontalOffset = roffset.exec( pos[ 0 ] );
  996. verticalOffset = roffset.exec( pos[ 1 ] );
  997. offsets[ this ] = [
  998. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  999. verticalOffset ? verticalOffset[ 0 ] : 0
  1000. ];
  1001. // reduce to just the positions without the offsets
  1002. options[ this ] = [
  1003. rposition.exec( pos[ 0 ] )[ 0 ],
  1004. rposition.exec( pos[ 1 ] )[ 0 ]
  1005. ];
  1006. });
  1007. // normalize collision option
  1008. if ( collision.length === 1 ) {
  1009. collision[ 1 ] = collision[ 0 ];
  1010. }
  1011. if ( options.at[ 0 ] === "right" ) {
  1012. basePosition.left += targetWidth;
  1013. } else if ( options.at[ 0 ] === "center" ) {
  1014. basePosition.left += targetWidth / 2;
  1015. }
  1016. if ( options.at[ 1 ] === "bottom" ) {
  1017. basePosition.top += targetHeight;
  1018. } else if ( options.at[ 1 ] === "center" ) {
  1019. basePosition.top += targetHeight / 2;
  1020. }
  1021. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1022. basePosition.left += atOffset[ 0 ];
  1023. basePosition.top += atOffset[ 1 ];
  1024. return this.each(function() {
  1025. var collisionPosition, using,
  1026. elem = $( this ),
  1027. elemWidth = elem.outerWidth(),
  1028. elemHeight = elem.outerHeight(),
  1029. marginLeft = parseCss( this, "marginLeft" ),
  1030. marginTop = parseCss( this, "marginTop" ),
  1031. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1032. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1033. position = $.extend( {}, basePosition ),
  1034. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1035. if ( options.my[ 0 ] === "right" ) {
  1036. position.left -= elemWidth;
  1037. } else if ( options.my[ 0 ] === "center" ) {
  1038. position.left -= elemWidth / 2;
  1039. }
  1040. if ( options.my[ 1 ] === "bottom" ) {
  1041. position.top -= elemHeight;
  1042. } else if ( options.my[ 1 ] === "center" ) {
  1043. position.top -= elemHeight / 2;
  1044. }
  1045. position.left += myOffset[ 0 ];
  1046. position.top += myOffset[ 1 ];
  1047. // if the browser doesn't support fractions, then round for consistent results
  1048. if ( !$.support.offsetFractions ) {
  1049. position.left = round( position.left );
  1050. position.top = round( position.top );
  1051. }
  1052. collisionPosition = {
  1053. marginLeft: marginLeft,
  1054. marginTop: marginTop
  1055. };
  1056. $.each( [ "left", "top" ], function( i, dir ) {
  1057. if ( $.ui.position[ collision[ i ] ] ) {
  1058. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1059. targetWidth: targetWidth,
  1060. targetHeight: targetHeight,
  1061. elemWidth: elemWidth,
  1062. elemHeight: elemHeight,
  1063. collisionPosition: collisionPosition,
  1064. collisionWidth: collisionWidth,
  1065. collisionHeight: collisionHeight,
  1066. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1067. my: options.my,
  1068. at: options.at,
  1069. within: within,
  1070. elem : elem
  1071. });
  1072. }
  1073. });
  1074. if ( options.using ) {
  1075. // adds feedback as second argument to using callback, if present
  1076. using = function( props ) {
  1077. var left = targetOffset.left - position.left,
  1078. right = left + targetWidth - elemWidth,
  1079. top = targetOffset.top - position.top,
  1080. bottom = top + targetHeight - elemHeight,
  1081. feedback = {
  1082. target: {
  1083. element: target,
  1084. left: targetOffset.left,
  1085. top: targetOffset.top,
  1086. width: targetWidth,
  1087. height: targetHeight
  1088. },
  1089. element: {
  1090. element: elem,
  1091. left: position.left,
  1092. top: position.top,
  1093. width: elemWidth,
  1094. height: elemHeight
  1095. },
  1096. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1097. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1098. };
  1099. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1100. feedback.horizontal = "center";
  1101. }
  1102. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1103. feedback.vertical = "middle";
  1104. }
  1105. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1106. feedback.important = "horizontal";
  1107. } else {
  1108. feedback.important = "vertical";
  1109. }
  1110. options.using.call( this, props, feedback );
  1111. };
  1112. }
  1113. elem.offset( $.extend( position, { using: using } ) );
  1114. });
  1115. };
  1116. $.ui.position = {
  1117. fit: {
  1118. left: function( position, data ) {
  1119. var within = data.within,
  1120. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1121. outerWidth = within.width,
  1122. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1123. overLeft = withinOffset - collisionPosLeft,
  1124. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1125. newOverRight;
  1126. // element is wider than within
  1127. if ( data.collisionWidth > outerWidth ) {
  1128. // element is initially over the left side of within
  1129. if ( overLeft > 0 && overRight <= 0 ) {
  1130. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1131. position.left += overLeft - newOverRight;
  1132. // element is initially over right side of within
  1133. } else if ( overRight > 0 && overLeft <= 0 ) {
  1134. position.left = withinOffset;
  1135. // element is initially over both left and right sides of within
  1136. } else {
  1137. if ( overLeft > overRight ) {
  1138. position.left = withinOffset + outerWidth - data.collisionWidth;
  1139. } else {
  1140. position.left = withinOffset;
  1141. }
  1142. }
  1143. // too far left -> align with left edge
  1144. } else if ( overLeft > 0 ) {
  1145. position.left += overLeft;
  1146. // too far right -> align with right edge
  1147. } else if ( overRight > 0 ) {
  1148. position.left -= overRight;
  1149. // adjust based on position and margin
  1150. } else {
  1151. position.left = max( position.left - collisionPosLeft, position.left );
  1152. }
  1153. },
  1154. top: function( position, data ) {
  1155. var within = data.within,
  1156. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1157. outerHeight = data.within.height,
  1158. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1159. overTop = withinOffset - collisionPosTop,
  1160. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1161. newOverBottom;
  1162. // element is taller than within
  1163. if ( data.collisionHeight > outerHeight ) {
  1164. // element is initially over the top of within
  1165. if ( overTop > 0 && overBottom <= 0 ) {
  1166. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1167. position.top += overTop - newOverBottom;
  1168. // element is initially over bottom of within
  1169. } else if ( overBottom > 0 && overTop <= 0 ) {
  1170. position.top = withinOffset;
  1171. // element is initially over both top and bottom of within
  1172. } else {
  1173. if ( overTop > overBottom ) {
  1174. position.top = withinOffset + outerHeight - data.collisionHeight;
  1175. } else {
  1176. position.top = withinOffset;
  1177. }
  1178. }
  1179. // too far up -> align with top
  1180. } else if ( overTop > 0 ) {
  1181. position.top += overTop;
  1182. // too far down -> align with bottom edge
  1183. } else if ( overBottom > 0 ) {
  1184. position.top -= overBottom;
  1185. // adjust based on position and margin
  1186. } else {
  1187. position.top = max( position.top - collisionPosTop, position.top );
  1188. }
  1189. }
  1190. },
  1191. flip: {
  1192. left: function( position, data ) {
  1193. var within = data.within,
  1194. withinOffset = within.offset.left + within.scrollLeft,
  1195. outerWidth = within.width,
  1196. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1197. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1198. overLeft = collisionPosLeft - offsetLeft,
  1199. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1200. myOffset = data.my[ 0 ] === "left" ?
  1201. -data.elemWidth :
  1202. data.my[ 0 ] === "right" ?
  1203. data.elemWidth :
  1204. 0,
  1205. atOffset = data.at[ 0 ] === "left" ?
  1206. data.targetWidth :
  1207. data.at[ 0 ] === "right" ?
  1208. -data.targetWidth :
  1209. 0,
  1210. offset = -2 * data.offset[ 0 ],
  1211. newOverRight,
  1212. newOverLeft;
  1213. if ( overLeft < 0 ) {
  1214. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1215. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1216. position.left += myOffset + atOffset + offset;
  1217. }
  1218. }
  1219. else if ( overRight > 0 ) {
  1220. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1221. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1222. position.left += myOffset + atOffset + offset;
  1223. }
  1224. }
  1225. },
  1226. top: function( position, data ) {
  1227. var within = data.within,
  1228. withinOffset = within.offset.top + within.scrollTop,
  1229. outerHeight = within.height,
  1230. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1231. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1232. overTop = collisionPosTop - offsetTop,
  1233. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1234. top = data.my[ 1 ] === "top",
  1235. myOffset = top ?
  1236. -data.elemHeight :
  1237. data.my[ 1 ] === "bottom" ?
  1238. data.elemHeight :
  1239. 0,
  1240. atOffset = data.at[ 1 ] === "top" ?
  1241. data.targetHeight :
  1242. data.at[ 1 ] === "bottom" ?
  1243. -data.targetHeight :
  1244. 0,
  1245. offset = -2 * data.offset[ 1 ],
  1246. newOverTop,
  1247. newOverBottom;
  1248. if ( overTop < 0 ) {
  1249. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1250. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1251. position.top += myOffset + atOffset + offset;
  1252. }
  1253. }
  1254. else if ( overBottom > 0 ) {
  1255. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1256. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1257. position.top += myOffset + atOffset + offset;
  1258. }
  1259. }
  1260. }
  1261. },
  1262. flipfit: {
  1263. left: function() {
  1264. $.ui.position.flip.left.apply( this, arguments );
  1265. $.ui.position.fit.left.apply( this, arguments );
  1266. },
  1267. top: function() {
  1268. $.ui.position.flip.top.apply( this, arguments );
  1269. $.ui.position.fit.top.apply( this, arguments );
  1270. }
  1271. }
  1272. };
  1273. // fraction support test
  1274. (function () {
  1275. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1276. body = document.getElementsByTagName( "body" )[ 0 ],
  1277. div = document.createElement( "div" );
  1278. //Create a "fake body" for testing based on method used in jQuery.support
  1279. testElement = document.createElement( body ? "div" : "body" );
  1280. testElementStyle = {
  1281. visibility: "hidden",
  1282. width: 0,
  1283. height: 0,
  1284. border: 0,
  1285. margin: 0,
  1286. background: "none"
  1287. };
  1288. if ( body ) {
  1289. $.extend( testElementStyle, {
  1290. position: "absolute",
  1291. left: "-1000px",
  1292. top: "-1000px"
  1293. });
  1294. }
  1295. for ( i in testElementStyle ) {
  1296. testElement.style[ i ] = testElementStyle[ i ];
  1297. }
  1298. testElement.appendChild( div );
  1299. testElementParent = body || document.documentElement;
  1300. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1301. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1302. offsetLeft = $( div ).offset().left;
  1303. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1304. testElement.innerHTML = "";
  1305. testElementParent.removeChild( testElement );
  1306. })();
  1307. }( jQuery ) );
  1308. (function( $, undefined ) {
  1309. var uid = 0,
  1310. hideProps = {},
  1311. showProps = {};
  1312. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  1313. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  1314. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  1315. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  1316. $.widget( "ui.accordion", {
  1317. version: "1.10.4",
  1318. options: {
  1319. active: 0,
  1320. animate: {},
  1321. collapsible: false,
  1322. event: "click",
  1323. header: "> li > :first-child,> :not(li):even",
  1324. heightStyle: "auto",
  1325. icons: {
  1326. activeHeader: "ui-icon-triangle-1-s",
  1327. header: "ui-icon-triangle-1-e"
  1328. },
  1329. // callbacks
  1330. activate: null,
  1331. beforeActivate: null
  1332. },
  1333. _create: function() {
  1334. var options = this.options;
  1335. this.prevShow = this.prevHide = $();
  1336. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  1337. // ARIA
  1338. .attr( "role", "tablist" );
  1339. // don't allow collapsible: false and active: false / null
  1340. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  1341. options.active = 0;
  1342. }
  1343. this._processPanels();
  1344. // handle negative values
  1345. if ( options.active < 0 ) {
  1346. options.active += this.headers.length;
  1347. }
  1348. this._refresh();
  1349. },
  1350. _getCreateEventData: function() {
  1351. return {
  1352. header: this.active,
  1353. panel: !this.active.length ? $() : this.active.next(),
  1354. content: !this.active.length ? $() : this.active.next()
  1355. };
  1356. },
  1357. _createIcons: function() {
  1358. var icons = this.options.icons;
  1359. if ( icons ) {
  1360. $( "<span>" )
  1361. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  1362. .prependTo( this.headers );
  1363. this.active.children( ".ui-accordion-header-icon" )
  1364. .removeClass( icons.header )
  1365. .addClass( icons.activeHeader );
  1366. this.headers.addClass( "ui-accordion-icons" );
  1367. }
  1368. },
  1369. _destroyIcons: function() {
  1370. this.headers
  1371. .removeClass( "ui-accordion-icons" )
  1372. .children( ".ui-accordion-header-icon" )
  1373. .remove();
  1374. },
  1375. _destroy: function() {
  1376. var contents;
  1377. // clean up main element
  1378. this.element
  1379. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  1380. .removeAttr( "role" );
  1381. // clean up headers
  1382. this.headers
  1383. .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  1384. .removeAttr( "role" )
  1385. .removeAttr( "aria-expanded" )
  1386. .removeAttr( "aria-selected" )
  1387. .removeAttr( "aria-controls" )
  1388. .removeAttr( "tabIndex" )
  1389. .each(function() {
  1390. if ( /^ui-accordion/.test( this.id ) ) {
  1391. this.removeAttribute( "id" );
  1392. }
  1393. });
  1394. this._destroyIcons();
  1395. // clean up content panels
  1396. contents = this.headers.next()
  1397. .css( "display", "" )
  1398. .removeAttr( "role" )
  1399. .removeAttr( "aria-hidden" )
  1400. .removeAttr( "aria-labelledby" )
  1401. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  1402. .each(function() {
  1403. if ( /^ui-accordion/.test( this.id ) ) {
  1404. this.removeAttribute( "id" );
  1405. }
  1406. });
  1407. if ( this.options.heightStyle !== "content" ) {
  1408. contents.css( "height", "" );
  1409. }
  1410. },
  1411. _setOption: function( key, value ) {
  1412. if ( key === "active" ) {
  1413. // _activate() will handle invalid values and update this.options
  1414. this._activate( value );
  1415. return;
  1416. }
  1417. if ( key === "event" ) {
  1418. if ( this.options.event ) {
  1419. this._off( this.headers, this.options.event );
  1420. }
  1421. this._setupEvents( value );
  1422. }
  1423. this._super( key, value );
  1424. // setting collapsible: false while collapsed; open first panel
  1425. if ( key === "collapsible" && !value && this.options.active === false ) {
  1426. this._activate( 0 );
  1427. }
  1428. if ( key === "icons" ) {
  1429. this._destroyIcons();
  1430. if ( value ) {
  1431. this._createIcons();
  1432. }
  1433. }
  1434. // #5332 - opacity doesn't cascade to positioned elements in IE
  1435. // so we need to add the disabled class to the headers and panels
  1436. if ( key === "disabled" ) {
  1437. this.headers.add( this.headers.next() )
  1438. .toggleClass( "ui-state-disabled", !!value );
  1439. }
  1440. },
  1441. _keydown: function( event ) {
  1442. if ( event.altKey || event.ctrlKey ) {
  1443. return;
  1444. }
  1445. var keyCode = $.ui.keyCode,
  1446. length = this.headers.length,
  1447. currentIndex = this.headers.index( event.target ),
  1448. toFocus = false;
  1449. switch ( event.keyCode ) {
  1450. case keyCode.RIGHT:
  1451. case keyCode.DOWN:
  1452. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  1453. break;
  1454. case keyCode.LEFT:
  1455. case keyCode.UP:
  1456. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  1457. break;
  1458. case keyCode.SPACE:
  1459. case keyCode.ENTER:
  1460. this._eventHandler( event );
  1461. break;
  1462. case keyCode.HOME:
  1463. toFocus = this.headers[ 0 ];
  1464. break;
  1465. case keyCode.END:
  1466. toFocus = this.headers[ length - 1 ];
  1467. break;
  1468. }
  1469. if ( toFocus ) {
  1470. $( event.target ).attr( "tabIndex", -1 );
  1471. $( toFocus ).attr( "tabIndex", 0 );
  1472. toFocus.focus();
  1473. event.preventDefault();
  1474. }
  1475. },
  1476. _panelKeyDown : function( event ) {
  1477. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  1478. $( event.currentTarget ).prev().focus();
  1479. }
  1480. },
  1481. refresh: function() {
  1482. var options = this.options;
  1483. this._processPanels();
  1484. // was collapsed or no panel
  1485. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  1486. options.active = false;
  1487. this.active = $();
  1488. // active false only when collapsible is true
  1489. } else if ( options.active === false ) {
  1490. this._activate( 0 );
  1491. // was active, but active panel is gone
  1492. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1493. // all remaining panel are disabled
  1494. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  1495. options.active = false;
  1496. this.active = $();
  1497. // activate previous panel
  1498. } else {
  1499. this._activate( Math.max( 0, options.active - 1 ) );
  1500. }
  1501. // was active, active panel still exists
  1502. } else {
  1503. // make sure active index is correct
  1504. options.active = this.headers.index( this.active );
  1505. }
  1506. this._destroyIcons();
  1507. this._refresh();
  1508. },
  1509. _processPanels: function() {
  1510. this.headers = this.element.find( this.options.header )
  1511. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  1512. this.headers.next()
  1513. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  1514. .filter(":not(.ui-accordion-content-active)")
  1515. .hide();
  1516. },
  1517. _refresh: function() {
  1518. var maxHeight,
  1519. options = this.options,
  1520. heightStyle = options.heightStyle,
  1521. parent = this.element.parent(),
  1522. accordionId = this.accordionId = "ui-accordion-" +
  1523. (this.element.attr( "id" ) || ++uid);
  1524. this.active = this._findActive( options.active )
  1525. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  1526. .removeClass( "ui-corner-all" );
  1527. this.active.next()
  1528. .addClass( "ui-accordion-content-active" )
  1529. .show();
  1530. this.headers
  1531. .attr( "role", "tab" )
  1532. .each(function( i ) {
  1533. var header = $( this ),
  1534. headerId = header.attr( "id" ),
  1535. panel = header.next(),
  1536. panelId = panel.attr( "id" );
  1537. if ( !headerId ) {
  1538. headerId = accordionId + "-header-" + i;
  1539. header.attr( "id", headerId );
  1540. }
  1541. if ( !panelId ) {
  1542. panelId = accordionId + "-panel-" + i;
  1543. panel.attr( "id", panelId );
  1544. }
  1545. header.attr( "aria-controls", panelId );
  1546. panel.attr( "aria-labelledby", headerId );
  1547. })
  1548. .next()
  1549. .attr( "role", "tabpanel" );
  1550. this.headers
  1551. .not( this.active )
  1552. .attr({
  1553. "aria-selected": "false",
  1554. "aria-expanded": "false",
  1555. tabIndex: -1
  1556. })
  1557. .next()
  1558. .attr({
  1559. "aria-hidden": "true"
  1560. })
  1561. .hide();
  1562. // make sure at least one header is in the tab order
  1563. if ( !this.active.length ) {
  1564. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  1565. } else {
  1566. this.active.attr({
  1567. "aria-selected": "true",
  1568. "aria-expanded": "true",
  1569. tabIndex: 0
  1570. })
  1571. .next()
  1572. .attr({
  1573. "aria-hidden": "false"
  1574. });
  1575. }
  1576. this._createIcons();
  1577. this._setupEvents( options.event );
  1578. if ( heightStyle === "fill" ) {
  1579. maxHeight = parent.height();
  1580. this.element.siblings( ":visible" ).each(function() {
  1581. var elem = $( this ),
  1582. position = elem.css( "position" );
  1583. if ( position === "absolute" || position === "fixed" ) {
  1584. return;
  1585. }
  1586. maxHeight -= elem.outerHeight( true );
  1587. });
  1588. this.headers.each(function() {
  1589. maxHeight -= $( this ).outerHeight( true );
  1590. });
  1591. this.headers.next()
  1592. .each(function() {
  1593. $( this ).height( Math.max( 0, maxHeight -
  1594. $( this ).innerHeight() + $( this ).height() ) );
  1595. })
  1596. .css( "overflow", "auto" );
  1597. } else if ( heightStyle === "auto" ) {
  1598. maxHeight = 0;
  1599. this.headers.next()
  1600. .each(function() {
  1601. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  1602. })
  1603. .height( maxHeight );
  1604. }
  1605. },
  1606. _activate: function( index ) {
  1607. var active = this._findActive( index )[ 0 ];
  1608. // trying to activate the already active panel
  1609. if ( active === this.active[ 0 ] ) {
  1610. return;
  1611. }
  1612. // trying to collapse, simulate a click on the currently active header
  1613. active = active || this.active[ 0 ];
  1614. this._eventHandler({
  1615. target: active,
  1616. currentTarget: active,
  1617. preventDefault: $.noop
  1618. });
  1619. },
  1620. _findActive: function( selector ) {
  1621. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  1622. },
  1623. _setupEvents: function( event ) {
  1624. var events = {
  1625. keydown: "_keydown"
  1626. };
  1627. if ( event ) {
  1628. $.each( event.split(" "), function( index, eventName ) {
  1629. events[ eventName ] = "_eventHandler";
  1630. });
  1631. }
  1632. this._off( this.headers.add( this.headers.next() ) );
  1633. this._on( this.headers, events );
  1634. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  1635. this._hoverable( this.headers );
  1636. this._focusable( this.headers );
  1637. },
  1638. _eventHandler: function( event ) {
  1639. var options = this.options,
  1640. active = this.active,
  1641. clicked = $( event.currentTarget ),
  1642. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1643. collapsing = clickedIsActive && options.collapsible,
  1644. toShow = collapsing ? $() : clicked.next(),
  1645. toHide = active.next(),
  1646. eventData = {
  1647. oldHeader: active,
  1648. oldPanel: toHide,
  1649. newHeader: collapsing ? $() : clicked,
  1650. newPanel: toShow
  1651. };
  1652. event.preventDefault();
  1653. if (
  1654. // click on active header, but not collapsible
  1655. ( clickedIsActive && !options.collapsible ) ||
  1656. // allow canceling activation
  1657. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1658. return;
  1659. }
  1660. options.active = collapsing ? false : this.headers.index( clicked );
  1661. // when the call to ._toggle() comes after the class changes
  1662. // it causes a very odd bug in IE 8 (see #6720)
  1663. this.active = clickedIsActive ? $() : clicked;
  1664. this._toggle( eventData );
  1665. // switch classes
  1666. // corner classes on the previously active header stay after the animation
  1667. active.removeClass( "ui-accordion-header-active ui-state-active" );
  1668. if ( options.icons ) {
  1669. active.children( ".ui-accordion-header-icon" )
  1670. .removeClass( options.icons.activeHeader )
  1671. .addClass( options.icons.header );
  1672. }
  1673. if ( !clickedIsActive ) {
  1674. clicked
  1675. .removeClass( "ui-corner-all" )
  1676. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  1677. if ( options.icons ) {
  1678. clicked.children( ".ui-accordion-header-icon" )
  1679. .removeClass( options.icons.header )
  1680. .addClass( options.icons.activeHeader );
  1681. }
  1682. clicked
  1683. .next()
  1684. .addClass( "ui-accordion-content-active" );
  1685. }
  1686. },
  1687. _toggle: function( data ) {
  1688. var toShow = data.newPanel,
  1689. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1690. // handle activating a panel during the animation for another activation
  1691. this.prevShow.add( this.prevHide ).stop( true, true );
  1692. this.prevShow = toShow;
  1693. this.prevHide = toHide;
  1694. if ( this.options.animate ) {
  1695. this._animate( toShow, toHide, data );
  1696. } else {
  1697. toHide.hide();
  1698. toShow.show();
  1699. this._toggleComplete( data );
  1700. }
  1701. toHide.attr({
  1702. "aria-hidden": "true"
  1703. });
  1704. toHide.prev().attr( "aria-selected", "false" );
  1705. // if we're switching panels, remove the old header from the tab order
  1706. // if we're opening from collapsed state, remove the previous header from the tab order
  1707. // if we're collapsing, then keep the collapsing header in the tab order
  1708. if ( toShow.length && toHide.length ) {
  1709. toHide.prev().attr({
  1710. "tabIndex": -1,
  1711. "aria-expanded": "false"
  1712. });
  1713. } else if ( toShow.length ) {
  1714. this.headers.filter(function() {
  1715. return $( this ).attr( "tabIndex" ) === 0;
  1716. })
  1717. .attr( "tabIndex", -1 );
  1718. }
  1719. toShow
  1720. .attr( "aria-hidden", "false" )
  1721. .prev()
  1722. .attr({
  1723. "aria-selected": "true",
  1724. tabIndex: 0,
  1725. "aria-expanded": "true"
  1726. });
  1727. },
  1728. _animate: function( toShow, toHide, data ) {
  1729. var total, easing, duration,
  1730. that = this,
  1731. adjust = 0,
  1732. down = toShow.length &&
  1733. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1734. animate = this.options.animate || {},
  1735. options = down && animate.down || animate,
  1736. complete = function() {
  1737. that._toggleComplete( data );
  1738. };
  1739. if ( typeof options === "number" ) {
  1740. duration = options;
  1741. }
  1742. if ( typeof options === "string" ) {
  1743. easing = options;
  1744. }
  1745. // fall back from options to animation in case of partial down settings
  1746. easing = easing || options.easing || animate.easing;
  1747. duration = duration || options.duration || animate.duration;
  1748. if ( !toHide.length ) {
  1749. return toShow.animate( showProps, duration, easing, complete );
  1750. }
  1751. if ( !toShow.length ) {
  1752. return toHide.animate( hideProps, duration, easing, complete );
  1753. }
  1754. total = toShow.show().outerHeight();
  1755. toHide.animate( hideProps, {
  1756. duration: duration,
  1757. easing: easing,
  1758. step: function( now, fx ) {
  1759. fx.now = Math.round( now );
  1760. }
  1761. });
  1762. toShow
  1763. .hide()
  1764. .animate( showProps, {
  1765. duration: duration,
  1766. easing: easing,
  1767. complete: complete,
  1768. step: function( now, fx ) {
  1769. fx.now = Math.round( now );
  1770. if ( fx.prop !== "height" ) {
  1771. adjust += fx.now;
  1772. } else if ( that.options.heightStyle !== "content" ) {
  1773. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1774. adjust = 0;
  1775. }
  1776. }
  1777. });
  1778. },
  1779. _toggleComplete: function( data ) {
  1780. var toHide = data.oldPanel;
  1781. toHide
  1782. .removeClass( "ui-accordion-content-active" )
  1783. .prev()
  1784. .removeClass( "ui-corner-top" )
  1785. .addClass( "ui-corner-all" );
  1786. // Work around for rendering bug in IE (#5421)
  1787. if ( toHide.length ) {
  1788. toHide.parent()[0].className = toHide.parent()[0].className;
  1789. }
  1790. this._trigger( "activate", null, data );
  1791. }
  1792. });
  1793. })( jQuery );
  1794. (function( $, undefined ) {
  1795. $.widget( "ui.autocomplete", {
  1796. version: "1.10.4",
  1797. defaultElement: "<input>",
  1798. options: {
  1799. appendTo: null,
  1800. autoFocus: false,
  1801. delay: 300,
  1802. minLength: 1,
  1803. position: {
  1804. my: "left top",
  1805. at: "left bottom",
  1806. collision: "none"
  1807. },
  1808. source: null,
  1809. // callbacks
  1810. change: null,
  1811. close: null,
  1812. focus: null,
  1813. open: null,
  1814. response: null,
  1815. search: null,
  1816. select: null
  1817. },
  1818. requestIndex: 0,
  1819. pending: 0,
  1820. _create: function() {
  1821. // Some browsers only repeat keydown events, not keypress events,
  1822. // so we use the suppressKeyPress flag to determine if we've already
  1823. // handled the keydown event. #7269
  1824. // Unfortunately the code for & in keypress is the same as the up arrow,
  1825. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  1826. // events when we know the keydown event was used to modify the
  1827. // search term. #7799
  1828. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  1829. nodeName = this.element[0].nodeName.toLowerCase(),
  1830. isTextarea = nodeName === "textarea",
  1831. isInput = nodeName === "input";
  1832. this.isMultiLine =
  1833. // Textareas are always multi-line
  1834. isTextarea ? true :
  1835. // Inputs are always single-line, even if inside a contentEditable element
  1836. // IE also treats inputs as contentEditable
  1837. isInput ? false :
  1838. // All other element types are determined by whether or not they're contentEditable
  1839. this.element.prop( "isContentEditable" );
  1840. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  1841. this.isNewMenu = true;
  1842. this.element
  1843. .addClass( "ui-autocomplete-input" )
  1844. .attr( "autocomplete", "off" );
  1845. this._on( this.element, {
  1846. keydown: function( event ) {
  1847. if ( this.element.prop( "readOnly" ) ) {
  1848. suppressKeyPress = true;
  1849. suppressInput = true;
  1850. suppressKeyPressRepeat = true;
  1851. return;
  1852. }
  1853. suppressKeyPress = false;
  1854. suppressInput = false;
  1855. suppressKeyPressRepeat = false;
  1856. var keyCode = $.ui.keyCode;
  1857. switch( event.keyCode ) {
  1858. case keyCode.PAGE_UP:
  1859. suppressKeyPress = true;
  1860. this._move( "previousPage", event );
  1861. break;
  1862. case keyCode.PAGE_DOWN:
  1863. suppressKeyPress = true;
  1864. this._move( "nextPage", event );
  1865. break;
  1866. case keyCode.UP:
  1867. suppressKeyPress = true;
  1868. this._keyEvent( "previous", event );
  1869. break;
  1870. case keyCode.DOWN:
  1871. suppressKeyPress = true;
  1872. this._keyEvent( "next", event );
  1873. break;
  1874. case keyCode.ENTER:
  1875. case keyCode.NUMPAD_ENTER:
  1876. // when menu is open and has focus
  1877. if ( this.menu.active ) {
  1878. // #6055 - Opera still allows the keypress to occur
  1879. // which causes forms to submit
  1880. suppressKeyPress = true;
  1881. event.preventDefault();
  1882. this.menu.select( event );
  1883. }
  1884. break;
  1885. case keyCode.TAB:
  1886. if ( this.menu.active ) {
  1887. this.menu.select( event );
  1888. }
  1889. break;
  1890. case keyCode.ESCAPE:
  1891. if ( this.menu.element.is( ":visible" ) ) {
  1892. this._value( this.term );
  1893. this.close( event );
  1894. // Different browsers have different default behavior for escape
  1895. // Single press can mean undo or clear
  1896. // Double press in IE means clear the whole form
  1897. event.preventDefault();
  1898. }
  1899. break;
  1900. default:
  1901. suppressKeyPressRepeat = true;
  1902. // search timeout should be triggered before the input value is changed
  1903. this._searchTimeout( event );
  1904. break;
  1905. }
  1906. },
  1907. keypress: function( event ) {
  1908. if ( suppressKeyPress ) {
  1909. suppressKeyPress = false;
  1910. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  1911. event.preventDefault();
  1912. }
  1913. return;
  1914. }
  1915. if ( suppressKeyPressRepeat ) {
  1916. return;
  1917. }
  1918. // replicate some key handlers to allow them to repeat in Firefox and Opera
  1919. var keyCode = $.ui.keyCode;
  1920. switch( event.keyCode ) {
  1921. case keyCode.PAGE_UP:
  1922. this._move( "previousPage", event );
  1923. break;
  1924. case keyCode.PAGE_DOWN:
  1925. this._move( "nextPage", event );
  1926. break;
  1927. case keyCode.UP:
  1928. this._keyEvent( "previous", event );
  1929. break;
  1930. case keyCode.DOWN:
  1931. this._keyEvent( "next", event );
  1932. break;
  1933. }
  1934. },
  1935. input: function( event ) {
  1936. if ( suppressInput ) {
  1937. suppressInput = false;
  1938. event.preventDefault();
  1939. return;
  1940. }
  1941. this._searchTimeout( event );
  1942. },
  1943. focus: function() {
  1944. this.selectedItem = null;
  1945. this.previous = this._value();
  1946. },
  1947. blur: function( event ) {
  1948. if ( this.cancelBlur ) {
  1949. delete this.cancelBlur;
  1950. return;
  1951. }
  1952. clearTimeout( this.searching );
  1953. this.close( event );
  1954. this._change( event );
  1955. }
  1956. });
  1957. this._initSource();
  1958. this.menu = $( "<ul>" )
  1959. .addClass( "ui-autocomplete ui-front" )
  1960. .appendTo( this._appendTo() )
  1961. .menu({
  1962. // disable ARIA support, the live region takes care of that
  1963. role: null
  1964. })
  1965. .hide()
  1966. .data( "ui-menu" );
  1967. this._on( this.menu.element, {
  1968. mousedown: function( event ) {
  1969. // prevent moving focus out of the text field
  1970. event.preventDefault();
  1971. // IE doesn't prevent moving focus even with event.preventDefault()
  1972. // so we set a flag to know when we should ignore the blur event
  1973. this.cancelBlur = true;
  1974. this._delay(function() {
  1975. delete this.cancelBlur;
  1976. });
  1977. // clicking on the scrollbar causes focus to shift to the body
  1978. // but we can't detect a mouseup or a click immediately afterward
  1979. // so we have to track the next mousedown and close the menu if
  1980. // the user clicks somewhere outside of the autocomplete
  1981. var menuElement = this.menu.element[ 0 ];
  1982. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  1983. this._delay(function() {
  1984. var that = this;
  1985. this.document.one( "mousedown", function( event ) {
  1986. if ( event.target !== that.element[ 0 ] &&
  1987. event.target !== menuElement &&
  1988. !$.contains( menuElement, event.target ) ) {
  1989. that.close();
  1990. }
  1991. });
  1992. });
  1993. }
  1994. },
  1995. menufocus: function( event, ui ) {
  1996. // support: Firefox
  1997. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  1998. if ( this.isNewMenu ) {
  1999. this.isNewMenu = false;
  2000. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2001. this.menu.blur();
  2002. this.document.one( "mousemove", function() {
  2003. $( event.target ).trigger( event.originalEvent );
  2004. });
  2005. return;
  2006. }
  2007. }
  2008. var item = ui.item.data( "ui-autocomplete-item" );
  2009. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2010. // use value to match what will end up in the input, if it was a key event
  2011. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2012. this._value( item.value );
  2013. }
  2014. } else {
  2015. // Normally the input is populated with the item's value as the
  2016. // menu is navigated, causing screen readers to notice a change and
  2017. // announce the item. Since the focus event was canceled, this doesn't
  2018. // happen, so we update the live region so that screen readers can
  2019. // still notice the change and announce it.
  2020. this.liveRegion.text( item.value );
  2021. }
  2022. },
  2023. menuselect: function( event, ui ) {
  2024. var item = ui.item.data( "ui-autocomplete-item" ),
  2025. previous = this.previous;
  2026. // only trigger when focus was lost (click on menu)
  2027. if ( this.element[0] !== this.document[0].activeElement ) {
  2028. this.element.focus();
  2029. this.previous = previous;
  2030. // #6109 - IE triggers two focus events and the second
  2031. // is asynchronous, so we need to reset the previous
  2032. // term synchronously and asynchronously :-(
  2033. this._delay(function() {
  2034. this.previous = previous;
  2035. this.selectedItem = item;
  2036. });
  2037. }
  2038. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2039. this._value( item.value );
  2040. }
  2041. // reset the term after the select event
  2042. // this allows custom select handling to work properly
  2043. this.term = this._value();
  2044. this.close( event );
  2045. this.selectedItem = item;
  2046. }
  2047. });
  2048. this.liveRegion = $( "<span>", {
  2049. role: "status",
  2050. "aria-live": "polite"
  2051. })
  2052. .addClass( "ui-helper-hidden-accessible" )
  2053. .insertBefore( this.element );
  2054. // turning off autocomplete prevents the browser from remembering the
  2055. // value when navigating through history, so we re-enable autocomplete
  2056. // if the page is unloaded before the widget is destroyed. #7790
  2057. this._on( this.window, {
  2058. beforeunload: function() {
  2059. this.element.removeAttr( "autocomplete" );
  2060. }
  2061. });
  2062. },
  2063. _destroy: function() {
  2064. clearTimeout( this.searching );
  2065. this.element
  2066. .removeClass( "ui-autocomplete-input" )
  2067. .removeAttr( "autocomplete" );
  2068. this.menu.element.remove();
  2069. this.liveRegion.remove();
  2070. },
  2071. _setOption: function( key, value ) {
  2072. this._super( key, value );
  2073. if ( key === "source" ) {
  2074. this._initSource();
  2075. }
  2076. if ( key === "appendTo" ) {
  2077. this.menu.element.appendTo( this._appendTo() );
  2078. }
  2079. if ( key === "disabled" && value && this.xhr ) {
  2080. this.xhr.abort();
  2081. }
  2082. },
  2083. _appendTo: function() {
  2084. var element = this.options.appendTo;
  2085. if ( element ) {
  2086. element = element.jquery || element.nodeType ?
  2087. $( element ) :
  2088. this.document.find( element ).eq( 0 );
  2089. }
  2090. if ( !element ) {
  2091. element = this.element.closest( ".ui-front" );
  2092. }
  2093. if ( !element.length ) {
  2094. element = this.document[0].body;
  2095. }
  2096. return element;
  2097. },
  2098. _initSource: function() {
  2099. var array, url,
  2100. that = this;
  2101. if ( $.isArray(this.options.source) ) {
  2102. array = this.options.source;
  2103. this.source = function( request, response ) {
  2104. response( $.ui.autocomplete.filter( array, request.term ) );
  2105. };
  2106. } else if ( typeof this.options.source === "string" ) {
  2107. url = this.options.source;
  2108. this.source = function( request, response ) {
  2109. if ( that.xhr ) {
  2110. that.xhr.abort();
  2111. }
  2112. that.xhr = $.ajax({
  2113. url: url,
  2114. data: request,
  2115. dataType: "json",
  2116. success: function( data ) {
  2117. response( data );
  2118. },
  2119. error: function() {
  2120. response( [] );
  2121. }
  2122. });
  2123. };
  2124. } else {
  2125. this.source = this.options.source;
  2126. }
  2127. },
  2128. _searchTimeout: function( event ) {
  2129. clearTimeout( this.searching );
  2130. this.searching = this._delay(function() {
  2131. // only search if the value has changed
  2132. if ( this.term !== this._value() ) {
  2133. this.selectedItem = null;
  2134. this.search( null, event );
  2135. }
  2136. }, this.options.delay );
  2137. },
  2138. search: function( value, event ) {
  2139. value = value != null ? value : this._value();
  2140. // always save the actual value, not the one passed as an argument
  2141. this.term = this._value();
  2142. if ( value.length < this.options.minLength ) {
  2143. return this.close( event );
  2144. }
  2145. if ( this._trigger( "search", event ) === false ) {
  2146. return;
  2147. }
  2148. return this._search( value );
  2149. },
  2150. _search: function( value ) {
  2151. this.pending++;
  2152. this.element.addClass( "ui-autocomplete-loading" );
  2153. this.cancelSearch = false;
  2154. this.source( { term: value }, this._response() );
  2155. },
  2156. _response: function() {
  2157. var index = ++this.requestIndex;
  2158. return $.proxy(function( content ) {
  2159. if ( index === this.requestIndex ) {
  2160. this.__response( content );
  2161. }
  2162. this.pending--;
  2163. if ( !this.pending ) {
  2164. this.element.removeClass( "ui-autocomplete-loading" );
  2165. }
  2166. }, this );
  2167. },
  2168. __response: function( content ) {
  2169. if ( content ) {
  2170. content = this._normalize( content );
  2171. }
  2172. this._trigger( "response", null, { content: content } );
  2173. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2174. this._suggest( content );
  2175. this._trigger( "open" );
  2176. } else {
  2177. // use ._close() instead of .close() so we don't cancel future searches
  2178. this._close();
  2179. }
  2180. },
  2181. close: function( event ) {
  2182. this.cancelSearch = true;
  2183. this._close( event );
  2184. },
  2185. _close: function( event ) {
  2186. if ( this.menu.element.is( ":visible" ) ) {
  2187. this.menu.element.hide();
  2188. this.menu.blur();
  2189. this.isNewMenu = true;
  2190. this._trigger( "close", event );
  2191. }
  2192. },
  2193. _change: function( event ) {
  2194. if ( this.previous !== this._value() ) {
  2195. this._trigger( "change", event, { item: this.selectedItem } );
  2196. }
  2197. },
  2198. _normalize: function( items ) {
  2199. // assume all items have the right format when the first item is complete
  2200. if ( items.length && items[0].label && items[0].value ) {
  2201. return items;
  2202. }
  2203. return $.map( items, function( item ) {
  2204. if ( typeof item === "string" ) {
  2205. return {
  2206. label: item,
  2207. value: item
  2208. };
  2209. }
  2210. return $.extend({
  2211. label: item.label || item.value,
  2212. value: item.value || item.label
  2213. }, item );
  2214. });
  2215. },
  2216. _suggest: function( items ) {
  2217. var ul = this.menu.element.empty();
  2218. this._renderMenu( ul, items );
  2219. this.isNewMenu = true;
  2220. this.menu.refresh();
  2221. // size and position menu
  2222. ul.show();
  2223. this._resizeMenu();
  2224. ul.position( $.extend({
  2225. of: this.element
  2226. }, this.options.position ));
  2227. if ( this.options.autoFocus ) {
  2228. this.menu.next();
  2229. }
  2230. },
  2231. _resizeMenu: function() {
  2232. var ul = this.menu.element;
  2233. ul.outerWidth( Math.max(
  2234. // Firefox wraps long text (possibly a rounding bug)
  2235. // so we add 1px to avoid the wrapping (#7513)
  2236. ul.width( "" ).outerWidth() + 1,
  2237. this.element.outerWidth()
  2238. ) );
  2239. },
  2240. _renderMenu: function( ul, items ) {
  2241. var that = this;
  2242. $.each( items, function( index, item ) {
  2243. that._renderItemData( ul, item );
  2244. });
  2245. },
  2246. _renderItemData: function( ul, item ) {
  2247. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2248. },
  2249. _renderItem: function( ul, item ) {
  2250. return $( "<li>" )
  2251. .append( $( "<a>" ).text( item.label ) )
  2252. .appendTo( ul );
  2253. },
  2254. _move: function( direction, event ) {
  2255. if ( !this.menu.element.is( ":visible" ) ) {
  2256. this.search( null, event );
  2257. return;
  2258. }
  2259. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2260. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2261. this._value( this.term );
  2262. this.menu.blur();
  2263. return;
  2264. }
  2265. this.menu[ direction ]( event );
  2266. },
  2267. widget: function() {
  2268. return this.menu.element;
  2269. },
  2270. _value: function() {
  2271. return this.valueMethod.apply( this.element, arguments );
  2272. },
  2273. _keyEvent: function( keyEvent, event ) {
  2274. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2275. this._move( keyEvent, event );
  2276. // prevents moving cursor to beginning/end of the text field in some browsers
  2277. event.preventDefault();
  2278. }
  2279. }
  2280. });
  2281. $.extend( $.ui.autocomplete, {
  2282. escapeRegex: function( value ) {
  2283. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  2284. },
  2285. filter: function(array, term) {
  2286. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  2287. return $.grep( array, function(value) {
  2288. return matcher.test( value.label || value.value || value );
  2289. });
  2290. }
  2291. });
  2292. // live region extension, adding a `messages` option
  2293. // NOTE: This is an experimental API. We are still investigating
  2294. // a full solution for string manipulation and internationalization.
  2295. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2296. options: {
  2297. messages: {
  2298. noResults: "No search results.",
  2299. results: function( amount ) {
  2300. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2301. " available, use up and down arrow keys to navigate.";
  2302. }
  2303. }
  2304. },
  2305. __response: function( content ) {
  2306. var message;
  2307. this._superApply( arguments );
  2308. if ( this.options.disabled || this.cancelSearch ) {
  2309. return;
  2310. }
  2311. if ( content && content.length ) {
  2312. message = this.options.messages.results( content.length );
  2313. } else {
  2314. message = this.options.messages.noResults;
  2315. }
  2316. this.liveRegion.text( message );
  2317. }
  2318. });
  2319. }( jQuery ));
  2320. (function( $, undefined ) {
  2321. var lastActive,
  2322. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2323. 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",
  2324. formResetHandler = function() {
  2325. var form = $( this );
  2326. setTimeout(function() {
  2327. form.find( ":ui-button" ).button( "refresh" );
  2328. }, 1 );
  2329. },
  2330. radioGroup = function( radio ) {
  2331. var name = radio.name,
  2332. form = radio.form,
  2333. radios = $( [] );
  2334. if ( name ) {
  2335. name = name.replace( /'/g, "\\'" );
  2336. if ( form ) {
  2337. radios = $( form ).find( "[name='" + name + "']" );
  2338. } else {
  2339. radios = $( "[name='" + name + "']", radio.ownerDocument )
  2340. .filter(function() {
  2341. return !this.form;
  2342. });
  2343. }
  2344. }
  2345. return radios;
  2346. };
  2347. $.widget( "ui.button", {
  2348. version: "1.10.4",
  2349. defaultElement: "<button>",
  2350. options: {
  2351. disabled: null,
  2352. text: true,
  2353. label: null,
  2354. icons: {
  2355. primary: null,
  2356. secondary: null
  2357. }
  2358. },
  2359. _create: function() {
  2360. this.element.closest( "form" )
  2361. .unbind( "reset" + this.eventNamespace )
  2362. .bind( "reset" + this.eventNamespace, formResetHandler );
  2363. if ( typeof this.options.disabled !== "boolean" ) {
  2364. this.options.disabled = !!this.element.prop( "disabled" );
  2365. } else {
  2366. this.element.prop( "disabled", this.options.disabled );
  2367. }
  2368. this._determineButtonType();
  2369. this.hasTitle = !!this.buttonElement.attr( "title" );
  2370. var that = this,
  2371. options = this.options,
  2372. toggleButton = this.type === "checkbox" || this.type === "radio",
  2373. activeClass = !toggleButton ? "ui-state-active" : "";
  2374. if ( options.label === null ) {
  2375. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  2376. }
  2377. this._hoverable( this.buttonElement );
  2378. this.buttonElement
  2379. .addClass( baseClasses )
  2380. .attr( "role", "button" )
  2381. .bind( "mouseenter" + this.eventNamespace, function() {
  2382. if ( options.disabled ) {
  2383. return;
  2384. }
  2385. if ( this === lastActive ) {
  2386. $( this ).addClass( "ui-state-active" );
  2387. }
  2388. })
  2389. .bind( "mouseleave" + this.eventNamespace, function() {
  2390. if ( options.disabled ) {
  2391. return;
  2392. }
  2393. $( this ).removeClass( activeClass );
  2394. })
  2395. .bind( "click" + this.eventNamespace, function( event ) {
  2396. if ( options.disabled ) {
  2397. event.preventDefault();
  2398. event.stopImmediatePropagation();
  2399. }
  2400. });
  2401. // Can't use _focusable() because the element that receives focus
  2402. // and the element that gets the ui-state-focus class are different
  2403. this._on({
  2404. focus: function() {
  2405. this.buttonElement.addClass( "ui-state-focus" );
  2406. },
  2407. blur: function() {
  2408. this.buttonElement.removeClass( "ui-state-focus" );
  2409. }
  2410. });
  2411. if ( toggleButton ) {
  2412. this.element.bind( "change" + this.eventNamespace, function() {
  2413. that.refresh();
  2414. });
  2415. }
  2416. if ( this.type === "checkbox" ) {
  2417. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  2418. if ( options.disabled ) {
  2419. return false;
  2420. }
  2421. });
  2422. } else if ( this.type === "radio" ) {
  2423. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  2424. if ( options.disabled ) {
  2425. return false;
  2426. }
  2427. $( this ).addClass( "ui-state-active" );
  2428. that.buttonElement.attr( "aria-pressed", "true" );
  2429. var radio = that.element[ 0 ];
  2430. radioGroup( radio )
  2431. .not( radio )
  2432. .map(function() {
  2433. return $( this ).button( "widget" )[ 0 ];
  2434. })
  2435. .removeClass( "ui-state-active" )
  2436. .attr( "aria-pressed", "false" );
  2437. });
  2438. } else {
  2439. this.buttonElement
  2440. .bind( "mousedown" + this.eventNamespace, function() {
  2441. if ( options.disabled ) {
  2442. return false;
  2443. }
  2444. $( this ).addClass( "ui-state-active" );
  2445. lastActive = this;
  2446. that.document.one( "mouseup", function() {
  2447. lastActive = null;
  2448. });
  2449. })
  2450. .bind( "mouseup" + this.eventNamespace, function() {
  2451. if ( options.disabled ) {
  2452. return false;
  2453. }
  2454. $( this ).removeClass( "ui-state-active" );
  2455. })
  2456. .bind( "keydown" + this.eventNamespace, function(event) {
  2457. if ( options.disabled ) {
  2458. return false;
  2459. }
  2460. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  2461. $( this ).addClass( "ui-state-active" );
  2462. }
  2463. })
  2464. // see #8559, we bind to blur here in case the button element loses
  2465. // focus between keydown and keyup, it would be left in an "active" state
  2466. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  2467. $( this ).removeClass( "ui-state-active" );
  2468. });
  2469. if ( this.buttonElement.is("a") ) {
  2470. this.buttonElement.keyup(function(event) {
  2471. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  2472. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  2473. $( this ).click();
  2474. }
  2475. });
  2476. }
  2477. }
  2478. // TODO: pull out $.Widget's handling for the disabled option into
  2479. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  2480. // be overridden by individual plugins
  2481. this._setOption( "disabled", options.disabled );
  2482. this._resetButton();
  2483. },
  2484. _determineButtonType: function() {
  2485. var ancestor, labelSelector, checked;
  2486. if ( this.element.is("[type=checkbox]") ) {
  2487. this.type = "checkbox";
  2488. } else if ( this.element.is("[type=radio]") ) {
  2489. this.type = "radio";
  2490. } else if ( this.element.is("input") ) {
  2491. this.type = "input";
  2492. } else {
  2493. this.type = "button";
  2494. }
  2495. if ( this.type === "checkbox" || this.type === "radio" ) {
  2496. // we don't search against the document in case the element
  2497. // is disconnected from the DOM
  2498. ancestor = this.element.parents().last();
  2499. labelSelector = "label[for='" + this.element.attr("id") + "']";
  2500. this.buttonElement = ancestor.find( labelSelector );
  2501. if ( !this.buttonElement.length ) {
  2502. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  2503. this.buttonElement = ancestor.filter( labelSelector );
  2504. if ( !this.buttonElement.length ) {
  2505. this.buttonElement = ancestor.find( labelSelector );
  2506. }
  2507. }
  2508. this.element.addClass( "ui-helper-hidden-accessible" );
  2509. checked = this.element.is( ":checked" );
  2510. if ( checked ) {
  2511. this.buttonElement.addClass( "ui-state-active" );
  2512. }
  2513. this.buttonElement.prop( "aria-pressed", checked );
  2514. } else {
  2515. this.buttonElement = this.element;
  2516. }
  2517. },
  2518. widget: function() {
  2519. return this.buttonElement;
  2520. },
  2521. _destroy: function() {
  2522. this.element
  2523. .removeClass( "ui-helper-hidden-accessible" );
  2524. this.buttonElement
  2525. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  2526. .removeAttr( "role" )
  2527. .removeAttr( "aria-pressed" )
  2528. .html( this.buttonElement.find(".ui-button-text").html() );
  2529. if ( !this.hasTitle ) {
  2530. this.buttonElement.removeAttr( "title" );
  2531. }
  2532. },
  2533. _setOption: function( key, value ) {
  2534. this._super( key, value );
  2535. if ( key === "disabled" ) {
  2536. this.element.prop( "disabled", !!value );
  2537. if ( value ) {
  2538. this.buttonElement.removeClass( "ui-state-focus" );
  2539. }
  2540. return;
  2541. }
  2542. this._resetButton();
  2543. },
  2544. refresh: function() {
  2545. //See #8237 & #8828
  2546. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  2547. if ( isDisabled !== this.options.disabled ) {
  2548. this._setOption( "disabled", isDisabled );
  2549. }
  2550. if ( this.type === "radio" ) {
  2551. radioGroup( this.element[0] ).each(function() {
  2552. if ( $( this ).is( ":checked" ) ) {
  2553. $( this ).button( "widget" )
  2554. .addClass( "ui-state-active" )
  2555. .attr( "aria-pressed", "true" );
  2556. } else {
  2557. $( this ).button( "widget" )
  2558. .removeClass( "ui-state-active" )
  2559. .attr( "aria-pressed", "false" );
  2560. }
  2561. });
  2562. } else if ( this.type === "checkbox" ) {
  2563. if ( this.element.is( ":checked" ) ) {
  2564. this.buttonElement
  2565. .addClass( "ui-state-active" )
  2566. .attr( "aria-pressed", "true" );
  2567. } else {
  2568. this.buttonElement
  2569. .removeClass( "ui-state-active" )
  2570. .attr( "aria-pressed", "false" );
  2571. }
  2572. }
  2573. },
  2574. _resetButton: function() {
  2575. if ( this.type === "input" ) {
  2576. if ( this.options.label ) {
  2577. this.element.val( this.options.label );
  2578. }
  2579. return;
  2580. }
  2581. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  2582. buttonText = $( "<span></span>", this.document[0] )
  2583. .addClass( "ui-button-text" )
  2584. .html( this.options.label )
  2585. .appendTo( buttonElement.empty() )
  2586. .text(),
  2587. icons = this.options.icons,
  2588. multipleIcons = icons.primary && icons.secondary,
  2589. buttonClasses = [];
  2590. if ( icons.primary || icons.secondary ) {
  2591. if ( this.options.text ) {
  2592. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  2593. }
  2594. if ( icons.primary ) {
  2595. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  2596. }
  2597. if ( icons.secondary ) {
  2598. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  2599. }
  2600. if ( !this.options.text ) {
  2601. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  2602. if ( !this.hasTitle ) {
  2603. buttonElement.attr( "title", $.trim( buttonText ) );
  2604. }
  2605. }
  2606. } else {
  2607. buttonClasses.push( "ui-button-text-only" );
  2608. }
  2609. buttonElement.addClass( buttonClasses.join( " " ) );
  2610. }
  2611. });
  2612. $.widget( "ui.buttonset", {
  2613. version: "1.10.4",
  2614. options: {
  2615. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  2616. },
  2617. _create: function() {
  2618. this.element.addClass( "ui-buttonset" );
  2619. },
  2620. _init: function() {
  2621. this.refresh();
  2622. },
  2623. _setOption: function( key, value ) {
  2624. if ( key === "disabled" ) {
  2625. this.buttons.button( "option", key, value );
  2626. }
  2627. this._super( key, value );
  2628. },
  2629. refresh: function() {
  2630. var rtl = this.element.css( "direction" ) === "rtl";
  2631. this.buttons = this.element.find( this.options.items )
  2632. .filter( ":ui-button" )
  2633. .button( "refresh" )
  2634. .end()
  2635. .not( ":ui-button" )
  2636. .button()
  2637. .end()
  2638. .map(function() {
  2639. return $( this ).button( "widget" )[ 0 ];
  2640. })
  2641. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  2642. .filter( ":first" )
  2643. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  2644. .end()
  2645. .filter( ":last" )
  2646. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  2647. .end()
  2648. .end();
  2649. },
  2650. _destroy: function() {
  2651. this.element.removeClass( "ui-buttonset" );
  2652. this.buttons
  2653. .map(function() {
  2654. return $( this ).button( "widget" )[ 0 ];
  2655. })
  2656. .removeClass( "ui-corner-left ui-corner-right" )
  2657. .end()
  2658. .button( "destroy" );
  2659. }
  2660. });
  2661. }( jQuery ) );
  2662. (function( $, undefined ) {
  2663. $.extend($.ui, { datepicker: { version: "1.10.4" } });
  2664. var PROP_NAME = "datepicker",
  2665. instActive;
  2666. /* Date picker manager.
  2667. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  2668. Settings for (groups of) date pickers are maintained in an instance object,
  2669. allowing multiple different settings on the same page. */
  2670. function Datepicker() {
  2671. this._curInst = null; // The current instance in use
  2672. this._keyEvent = false; // If the last event was a key event
  2673. this._disabledInputs = []; // List of date picker inputs that have been disabled
  2674. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  2675. this._inDialog = false; // True if showing within a "dialog", false if not
  2676. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  2677. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  2678. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  2679. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  2680. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  2681. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  2682. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  2683. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  2684. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  2685. this.regional = []; // Available regional settings, indexed by language code
  2686. this.regional[""] = { // Default regional settings
  2687. closeText: "Done", // Display text for close link
  2688. prevText: "Prev", // Display text for previous month link
  2689. nextText: "Next", // Display text for next month link
  2690. currentText: "Today", // Display text for current month link
  2691. monthNames: ["January","February","March","April","May","June",
  2692. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  2693. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  2694. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  2695. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  2696. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  2697. weekHeader: "Wk", // Column header for week of the year
  2698. dateFormat: "mm/dd/yy", // See format options on parseDate
  2699. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  2700. isRTL: false, // True if right-to-left language, false if left-to-right
  2701. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  2702. yearSuffix: "" // Additional text to append to the year in the month headers
  2703. };
  2704. this._defaults = { // Global defaults for all the date picker instances
  2705. showOn: "focus", // "focus" for popup on focus,
  2706. // "button" for trigger button, or "both" for either
  2707. showAnim: "fadeIn", // Name of jQuery animation for popup
  2708. showOptions: {}, // Options for enhanced animations
  2709. defaultDate: null, // Used when field is blank: actual date,
  2710. // +/-number for offset from today, null for today
  2711. appendText: "", // Display text following the input box, e.g. showing the format
  2712. buttonText: "...", // Text for trigger button
  2713. buttonImage: "", // URL for trigger button image
  2714. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  2715. hideIfNoPrevNext: false, // True to hide next/previous month links
  2716. // if not applicable, false to just disable them
  2717. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  2718. gotoCurrent: false, // True if today link goes back to current selection instead
  2719. changeMonth: false, // True if month can be selected directly, false if only prev/next
  2720. changeYear: false, // True if year can be selected directly, false if only prev/next
  2721. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  2722. // either relative to today's year (-nn:+nn), relative to currently displayed year
  2723. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  2724. showOtherMonths: false, // True to show dates in other months, false to leave blank
  2725. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  2726. showWeek: false, // True to show week of the year, false to not show it
  2727. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  2728. // takes a Date and returns the number of the week for it
  2729. shortYearCutoff: "+10", // Short year values < this are in the current century,
  2730. // > this are in the previous century,
  2731. // string value starting with "+" for current year + value
  2732. minDate: null, // The earliest selectable date, or null for no limit
  2733. maxDate: null, // The latest selectable date, or null for no limit
  2734. duration: "fast", // Duration of display/closure
  2735. beforeShowDay: null, // Function that takes a date and returns an array with
  2736. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  2737. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  2738. beforeShow: null, // Function that takes an input field and
  2739. // returns a set of custom settings for the date picker
  2740. onSelect: null, // Define a callback function when a date is selected
  2741. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  2742. onClose: null, // Define a callback function when the datepicker is closed
  2743. numberOfMonths: 1, // Number of months to show at a time
  2744. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  2745. stepMonths: 1, // Number of months to step back/forward
  2746. stepBigMonths: 12, // Number of months to step back/forward for the big links
  2747. altField: "", // Selector for an alternate field to store selected dates into
  2748. altFormat: "", // The date format to use for the alternate field
  2749. constrainInput: true, // The input is constrained by the current date format
  2750. showButtonPanel: false, // True to show button panel, false to not show it
  2751. autoSize: false, // True to size the input for the date format, false to leave as is
  2752. disabled: false // The initial disabled state
  2753. };
  2754. $.extend(this._defaults, this.regional[""]);
  2755. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  2756. }
  2757. $.extend(Datepicker.prototype, {
  2758. /* Class name added to elements to indicate already configured with a date picker. */
  2759. markerClassName: "hasDatepicker",
  2760. //Keep track of the maximum number of rows displayed (see #7043)
  2761. maxRows: 4,
  2762. // TODO rename to "widget" when switching to widget factory
  2763. _widgetDatepicker: function() {
  2764. return this.dpDiv;
  2765. },
  2766. /* Override the default settings for all instances of the date picker.
  2767. * @param settings object - the new settings to use as defaults (anonymous object)
  2768. * @return the manager object
  2769. */
  2770. setDefaults: function(settings) {
  2771. extendRemove(this._defaults, settings || {});
  2772. return this;
  2773. },
  2774. /* Attach the date picker to a jQuery selection.
  2775. * @param target element - the target input field or division or span
  2776. * @param settings object - the new settings to use for this date picker instance (anonymous)
  2777. */
  2778. _attachDatepicker: function(target, settings) {
  2779. var nodeName, inline, inst;
  2780. nodeName = target.nodeName.toLowerCase();
  2781. inline = (nodeName === "div" || nodeName === "span");
  2782. if (!target.id) {
  2783. this.uuid += 1;
  2784. target.id = "dp" + this.uuid;
  2785. }
  2786. inst = this._newInst($(target), inline);
  2787. inst.settings = $.extend({}, settings || {});
  2788. if (nodeName === "input") {
  2789. this._connectDatepicker(target, inst);
  2790. } else if (inline) {
  2791. this._inlineDatepicker(target, inst);
  2792. }
  2793. },
  2794. /* Create a new instance object. */
  2795. _newInst: function(target, inline) {
  2796. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  2797. return {id: id, input: target, // associated target
  2798. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  2799. drawMonth: 0, drawYear: 0, // month being drawn
  2800. inline: inline, // is datepicker inline or not
  2801. dpDiv: (!inline ? this.dpDiv : // presentation div
  2802. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  2803. },
  2804. /* Attach the date picker to an input field. */
  2805. _connectDatepicker: function(target, inst) {
  2806. var input = $(target);
  2807. inst.append = $([]);
  2808. inst.trigger = $([]);
  2809. if (input.hasClass(this.markerClassName)) {
  2810. return;
  2811. }
  2812. this._attachments(input, inst);
  2813. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  2814. keypress(this._doKeyPress).keyup(this._doKeyUp);
  2815. this._autoSize(inst);
  2816. $.data(target, PROP_NAME, inst);
  2817. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  2818. if( inst.settings.disabled ) {
  2819. this._disableDatepicker( target );
  2820. }
  2821. },
  2822. /* Make attachments based on settings. */
  2823. _attachments: function(input, inst) {
  2824. var showOn, buttonText, buttonImage,
  2825. appendText = this._get(inst, "appendText"),
  2826. isRTL = this._get(inst, "isRTL");
  2827. if (inst.append) {
  2828. inst.append.remove();
  2829. }
  2830. if (appendText) {
  2831. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  2832. input[isRTL ? "before" : "after"](inst.append);
  2833. }
  2834. input.unbind("focus", this._showDatepicker);
  2835. if (inst.trigger) {
  2836. inst.trigger.remove();
  2837. }
  2838. showOn = this._get(inst, "showOn");
  2839. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  2840. input.focus(this._showDatepicker);
  2841. }
  2842. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  2843. buttonText = this._get(inst, "buttonText");
  2844. buttonImage = this._get(inst, "buttonImage");
  2845. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  2846. $("<img/>").addClass(this._triggerClass).
  2847. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  2848. $("<button type='button'></button>").addClass(this._triggerClass).
  2849. html(!buttonImage ? buttonText : $("<img/>").attr(
  2850. { src:buttonImage, alt:buttonText, title:buttonText })));
  2851. input[isRTL ? "before" : "after"](inst.trigger);
  2852. inst.trigger.click(function() {
  2853. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  2854. $.datepicker._hideDatepicker();
  2855. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  2856. $.datepicker._hideDatepicker();
  2857. $.datepicker._showDatepicker(input[0]);
  2858. } else {
  2859. $.datepicker._showDatepicker(input[0]);
  2860. }
  2861. return false;
  2862. });
  2863. }
  2864. },
  2865. /* Apply the maximum length for the date format. */
  2866. _autoSize: function(inst) {
  2867. if (this._get(inst, "autoSize") && !inst.inline) {
  2868. var findMax, max, maxI, i,
  2869. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  2870. dateFormat = this._get(inst, "dateFormat");
  2871. if (dateFormat.match(/[DM]/)) {
  2872. findMax = function(names) {
  2873. max = 0;
  2874. maxI = 0;
  2875. for (i = 0; i < names.length; i++) {
  2876. if (names[i].length > max) {
  2877. max = names[i].length;
  2878. maxI = i;
  2879. }
  2880. }
  2881. return maxI;
  2882. };
  2883. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  2884. "monthNames" : "monthNamesShort"))));
  2885. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  2886. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  2887. }
  2888. inst.input.attr("size", this._formatDate(inst, date).length);
  2889. }
  2890. },
  2891. /* Attach an inline date picker to a div. */
  2892. _inlineDatepicker: function(target, inst) {
  2893. var divSpan = $(target);
  2894. if (divSpan.hasClass(this.markerClassName)) {
  2895. return;
  2896. }
  2897. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  2898. $.data(target, PROP_NAME, inst);
  2899. this._setDate(inst, this._getDefaultDate(inst), true);
  2900. this._updateDatepicker(inst);
  2901. this._updateAlternate(inst);
  2902. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  2903. if( inst.settings.disabled ) {
  2904. this._disableDatepicker( target );
  2905. }
  2906. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  2907. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  2908. inst.dpDiv.css( "display", "block" );
  2909. },
  2910. /* Pop-up the date picker in a "dialog" box.
  2911. * @param input element - ignored
  2912. * @param date string or Date - the initial date to display
  2913. * @param onSelect function - the function to call when a date is selected
  2914. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  2915. * @param pos int[2] - coordinates for the dialog's position within the screen or
  2916. * event - with x/y coordinates or
  2917. * leave empty for default (screen centre)
  2918. * @return the manager object
  2919. */
  2920. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  2921. var id, browserWidth, browserHeight, scrollX, scrollY,
  2922. inst = this._dialogInst; // internal instance
  2923. if (!inst) {
  2924. this.uuid += 1;
  2925. id = "dp" + this.uuid;
  2926. this._dialogInput = $("<input type='text' id='" + id +
  2927. "' style='position: absolute; top: -100px; width: 0px;'/>");
  2928. this._dialogInput.keydown(this._doKeyDown);
  2929. $("body").append(this._dialogInput);
  2930. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  2931. inst.settings = {};
  2932. $.data(this._dialogInput[0], PROP_NAME, inst);
  2933. }
  2934. extendRemove(inst.settings, settings || {});
  2935. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  2936. this._dialogInput.val(date);
  2937. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  2938. if (!this._pos) {
  2939. browserWidth = document.documentElement.clientWidth;
  2940. browserHeight = document.documentElement.clientHeight;
  2941. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  2942. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  2943. this._pos = // should use actual width/height below
  2944. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  2945. }
  2946. // move input on screen for focus, but hidden behind dialog
  2947. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  2948. inst.settings.onSelect = onSelect;
  2949. this._inDialog = true;
  2950. this.dpDiv.addClass(this._dialogClass);
  2951. this._showDatepicker(this._dialogInput[0]);
  2952. if ($.blockUI) {
  2953. $.blockUI(this.dpDiv);
  2954. }
  2955. $.data(this._dialogInput[0], PROP_NAME, inst);
  2956. return this;
  2957. },
  2958. /* Detach a datepicker from its control.
  2959. * @param target element - the target input field or division or span
  2960. */
  2961. _destroyDatepicker: function(target) {
  2962. var nodeName,
  2963. $target = $(target),
  2964. inst = $.data(target, PROP_NAME);
  2965. if (!$target.hasClass(this.markerClassName)) {
  2966. return;
  2967. }
  2968. nodeName = target.nodeName.toLowerCase();
  2969. $.removeData(target, PROP_NAME);
  2970. if (nodeName === "input") {
  2971. inst.append.remove();
  2972. inst.trigger.remove();
  2973. $target.removeClass(this.markerClassName).
  2974. unbind("focus", this._showDatepicker).
  2975. unbind("keydown", this._doKeyDown).
  2976. unbind("keypress", this._doKeyPress).
  2977. unbind("keyup", this._doKeyUp);
  2978. } else if (nodeName === "div" || nodeName === "span") {
  2979. $target.removeClass(this.markerClassName).empty();
  2980. }
  2981. },
  2982. /* Enable the date picker to a jQuery selection.
  2983. * @param target element - the target input field or division or span
  2984. */
  2985. _enableDatepicker: function(target) {
  2986. var nodeName, inline,
  2987. $target = $(target),
  2988. inst = $.data(target, PROP_NAME);
  2989. if (!$target.hasClass(this.markerClassName)) {
  2990. return;
  2991. }
  2992. nodeName = target.nodeName.toLowerCase();
  2993. if (nodeName === "input") {
  2994. target.disabled = false;
  2995. inst.trigger.filter("button").
  2996. each(function() { this.disabled = false; }).end().
  2997. filter("img").css({opacity: "1.0", cursor: ""});
  2998. } else if (nodeName === "div" || nodeName === "span") {
  2999. inline = $target.children("." + this._inlineClass);
  3000. inline.children().removeClass("ui-state-disabled");
  3001. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3002. prop("disabled", false);
  3003. }
  3004. this._disabledInputs = $.map(this._disabledInputs,
  3005. function(value) { return (value === target ? null : value); }); // delete entry
  3006. },
  3007. /* Disable the date picker to a jQuery selection.
  3008. * @param target element - the target input field or division or span
  3009. */
  3010. _disableDatepicker: function(target) {
  3011. var nodeName, inline,
  3012. $target = $(target),
  3013. inst = $.data(target, PROP_NAME);
  3014. if (!$target.hasClass(this.markerClassName)) {
  3015. return;
  3016. }
  3017. nodeName = target.nodeName.toLowerCase();
  3018. if (nodeName === "input") {
  3019. target.disabled = true;
  3020. inst.trigger.filter("button").
  3021. each(function() { this.disabled = true; }).end().
  3022. filter("img").css({opacity: "0.5", cursor: "default"});
  3023. } else if (nodeName === "div" || nodeName === "span") {
  3024. inline = $target.children("." + this._inlineClass);
  3025. inline.children().addClass("ui-state-disabled");
  3026. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3027. prop("disabled", true);
  3028. }
  3029. this._disabledInputs = $.map(this._disabledInputs,
  3030. function(value) { return (value === target ? null : value); }); // delete entry
  3031. this._disabledInputs[this._disabledInputs.length] = target;
  3032. },
  3033. /* Is the first field in a jQuery collection disabled as a datepicker?
  3034. * @param target element - the target input field or division or span
  3035. * @return boolean - true if disabled, false if enabled
  3036. */
  3037. _isDisabledDatepicker: function(target) {
  3038. if (!target) {
  3039. return false;
  3040. }
  3041. for (var i = 0; i < this._disabledInputs.length; i++) {
  3042. if (this._disabledInputs[i] === target) {
  3043. return true;
  3044. }
  3045. }
  3046. return false;
  3047. },
  3048. /* Retrieve the instance data for the target control.
  3049. * @param target element - the target input field or division or span
  3050. * @return object - the associated instance data
  3051. * @throws error if a jQuery problem getting data
  3052. */
  3053. _getInst: function(target) {
  3054. try {
  3055. return $.data(target, PROP_NAME);
  3056. }
  3057. catch (err) {
  3058. throw "Missing instance data for this datepicker";
  3059. }
  3060. },
  3061. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3062. * @param target element - the target input field or division or span
  3063. * @param name object - the new settings to update or
  3064. * string - the name of the setting to change or retrieve,
  3065. * when retrieving also "all" for all instance settings or
  3066. * "defaults" for all global defaults
  3067. * @param value any - the new value for the setting
  3068. * (omit if above is an object or to retrieve a value)
  3069. */
  3070. _optionDatepicker: function(target, name, value) {
  3071. var settings, date, minDate, maxDate,
  3072. inst = this._getInst(target);
  3073. if (arguments.length === 2 && typeof name === "string") {
  3074. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  3075. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  3076. this._get(inst, name)) : null));
  3077. }
  3078. settings = name || {};
  3079. if (typeof name === "string") {
  3080. settings = {};
  3081. settings[name] = value;
  3082. }
  3083. if (inst) {
  3084. if (this._curInst === inst) {
  3085. this._hideDatepicker();
  3086. }
  3087. date = this._getDateDatepicker(target, true);
  3088. minDate = this._getMinMaxDate(inst, "min");
  3089. maxDate = this._getMinMaxDate(inst, "max");
  3090. extendRemove(inst.settings, settings);
  3091. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3092. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  3093. inst.settings.minDate = this._formatDate(inst, minDate);
  3094. }
  3095. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  3096. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3097. }
  3098. if ( "disabled" in settings ) {
  3099. if ( settings.disabled ) {
  3100. this._disableDatepicker(target);
  3101. } else {
  3102. this._enableDatepicker(target);
  3103. }
  3104. }
  3105. this._attachments($(target), inst);
  3106. this._autoSize(inst);
  3107. this._setDate(inst, date);
  3108. this._updateAlternate(inst);
  3109. this._updateDatepicker(inst);
  3110. }
  3111. },
  3112. // change method deprecated
  3113. _changeDatepicker: function(target, name, value) {
  3114. this._optionDatepicker(target, name, value);
  3115. },
  3116. /* Redraw the date picker attached to an input field or division.
  3117. * @param target element - the target input field or division or span
  3118. */
  3119. _refreshDatepicker: function(target) {
  3120. var inst = this._getInst(target);
  3121. if (inst) {
  3122. this._updateDatepicker(inst);
  3123. }
  3124. },
  3125. /* Set the dates for a jQuery selection.
  3126. * @param target element - the target input field or division or span
  3127. * @param date Date - the new date
  3128. */
  3129. _setDateDatepicker: function(target, date) {
  3130. var inst = this._getInst(target);
  3131. if (inst) {
  3132. this._setDate(inst, date);
  3133. this._updateDatepicker(inst);
  3134. this._updateAlternate(inst);
  3135. }
  3136. },
  3137. /* Get the date(s) for the first entry in a jQuery selection.
  3138. * @param target element - the target input field or division or span
  3139. * @param noDefault boolean - true if no default date is to be used
  3140. * @return Date - the current date
  3141. */
  3142. _getDateDatepicker: function(target, noDefault) {
  3143. var inst = this._getInst(target);
  3144. if (inst && !inst.inline) {
  3145. this._setDateFromField(inst, noDefault);
  3146. }
  3147. return (inst ? this._getDate(inst) : null);
  3148. },
  3149. /* Handle keystrokes. */
  3150. _doKeyDown: function(event) {
  3151. var onSelect, dateStr, sel,
  3152. inst = $.datepicker._getInst(event.target),
  3153. handled = true,
  3154. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  3155. inst._keyEvent = true;
  3156. if ($.datepicker._datepickerShowing) {
  3157. switch (event.keyCode) {
  3158. case 9: $.datepicker._hideDatepicker();
  3159. handled = false;
  3160. break; // hide on tab out
  3161. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  3162. $.datepicker._currentClass + ")", inst.dpDiv);
  3163. if (sel[0]) {
  3164. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3165. }
  3166. onSelect = $.datepicker._get(inst, "onSelect");
  3167. if (onSelect) {
  3168. dateStr = $.datepicker._formatDate(inst);
  3169. // trigger custom callback
  3170. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3171. } else {
  3172. $.datepicker._hideDatepicker();
  3173. }
  3174. return false; // don't submit the form
  3175. case 27: $.datepicker._hideDatepicker();
  3176. break; // hide on escape
  3177. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3178. -$.datepicker._get(inst, "stepBigMonths") :
  3179. -$.datepicker._get(inst, "stepMonths")), "M");
  3180. break; // previous month/year on page up/+ ctrl
  3181. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3182. +$.datepicker._get(inst, "stepBigMonths") :
  3183. +$.datepicker._get(inst, "stepMonths")), "M");
  3184. break; // next month/year on page down/+ ctrl
  3185. case 35: if (event.ctrlKey || event.metaKey) {
  3186. $.datepicker._clearDate(event.target);
  3187. }
  3188. handled = event.ctrlKey || event.metaKey;
  3189. break; // clear on ctrl or command +end
  3190. case 36: if (event.ctrlKey || event.metaKey) {
  3191. $.datepicker._gotoToday(event.target);
  3192. }
  3193. handled = event.ctrlKey || event.metaKey;
  3194. break; // current on ctrl or command +home
  3195. case 37: if (event.ctrlKey || event.metaKey) {
  3196. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3197. }
  3198. handled = event.ctrlKey || event.metaKey;
  3199. // -1 day on ctrl or command +left
  3200. if (event.originalEvent.altKey) {
  3201. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3202. -$.datepicker._get(inst, "stepBigMonths") :
  3203. -$.datepicker._get(inst, "stepMonths")), "M");
  3204. }
  3205. // next month/year on alt +left on Mac
  3206. break;
  3207. case 38: if (event.ctrlKey || event.metaKey) {
  3208. $.datepicker._adjustDate(event.target, -7, "D");
  3209. }
  3210. handled = event.ctrlKey || event.metaKey;
  3211. break; // -1 week on ctrl or command +up
  3212. case 39: if (event.ctrlKey || event.metaKey) {
  3213. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3214. }
  3215. handled = event.ctrlKey || event.metaKey;
  3216. // +1 day on ctrl or command +right
  3217. if (event.originalEvent.altKey) {
  3218. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3219. +$.datepicker._get(inst, "stepBigMonths") :
  3220. +$.datepicker._get(inst, "stepMonths")), "M");
  3221. }
  3222. // next month/year on alt +right
  3223. break;
  3224. case 40: if (event.ctrlKey || event.metaKey) {
  3225. $.datepicker._adjustDate(event.target, +7, "D");
  3226. }
  3227. handled = event.ctrlKey || event.metaKey;
  3228. break; // +1 week on ctrl or command +down
  3229. default: handled = false;
  3230. }
  3231. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3232. $.datepicker._showDatepicker(this);
  3233. } else {
  3234. handled = false;
  3235. }
  3236. if (handled) {
  3237. event.preventDefault();
  3238. event.stopPropagation();
  3239. }
  3240. },
  3241. /* Filter entered characters - based on date format. */
  3242. _doKeyPress: function(event) {
  3243. var chars, chr,
  3244. inst = $.datepicker._getInst(event.target);
  3245. if ($.datepicker._get(inst, "constrainInput")) {
  3246. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3247. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3248. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3249. }
  3250. },
  3251. /* Synchronise manual entry and field/alternate field. */
  3252. _doKeyUp: function(event) {
  3253. var date,
  3254. inst = $.datepicker._getInst(event.target);
  3255. if (inst.input.val() !== inst.lastVal) {
  3256. try {
  3257. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3258. (inst.input ? inst.input.val() : null),
  3259. $.datepicker._getFormatConfig(inst));
  3260. if (date) { // only if valid
  3261. $.datepicker._setDateFromField(inst);
  3262. $.datepicker._updateAlternate(inst);
  3263. $.datepicker._updateDatepicker(inst);
  3264. }
  3265. }
  3266. catch (err) {
  3267. }
  3268. }
  3269. return true;
  3270. },
  3271. /* Pop-up the date picker for a given input field.
  3272. * If false returned from beforeShow event handler do not show.
  3273. * @param input element - the input field attached to the date picker or
  3274. * event - if triggered by focus
  3275. */
  3276. _showDatepicker: function(input) {
  3277. input = input.target || input;
  3278. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3279. input = $("input", input.parentNode)[0];
  3280. }
  3281. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3282. return;
  3283. }
  3284. var inst, beforeShow, beforeShowSettings, isFixed,
  3285. offset, showAnim, duration;
  3286. inst = $.datepicker._getInst(input);
  3287. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3288. $.datepicker._curInst.dpDiv.stop(true, true);
  3289. if ( inst && $.datepicker._datepickerShowing ) {
  3290. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3291. }
  3292. }
  3293. beforeShow = $.datepicker._get(inst, "beforeShow");
  3294. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3295. if(beforeShowSettings === false){
  3296. return;
  3297. }
  3298. extendRemove(inst.settings, beforeShowSettings);
  3299. inst.lastVal = null;
  3300. $.datepicker._lastInput = input;
  3301. $.datepicker._setDateFromField(inst);
  3302. if ($.datepicker._inDialog) { // hide cursor
  3303. input.value = "";
  3304. }
  3305. if (!$.datepicker._pos) { // position below input
  3306. $.datepicker._pos = $.datepicker._findPos(input);
  3307. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3308. }
  3309. isFixed = false;
  3310. $(input).parents().each(function() {
  3311. isFixed |= $(this).css("position") === "fixed";
  3312. return !isFixed;
  3313. });
  3314. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3315. $.datepicker._pos = null;
  3316. //to avoid flashes on Firefox
  3317. inst.dpDiv.empty();
  3318. // determine sizing offscreen
  3319. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  3320. $.datepicker._updateDatepicker(inst);
  3321. // fix width for dynamic number of date pickers
  3322. // and adjust position before showing
  3323. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3324. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3325. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  3326. left: offset.left + "px", top: offset.top + "px"});
  3327. if (!inst.inline) {
  3328. showAnim = $.datepicker._get(inst, "showAnim");
  3329. duration = $.datepicker._get(inst, "duration");
  3330. inst.dpDiv.zIndex($(input).zIndex()+1);
  3331. $.datepicker._datepickerShowing = true;
  3332. if ( $.effects && $.effects.effect[ showAnim ] ) {
  3333. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  3334. } else {
  3335. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  3336. }
  3337. if ( $.datepicker._shouldFocusInput( inst ) ) {
  3338. inst.input.focus();
  3339. }
  3340. $.datepicker._curInst = inst;
  3341. }
  3342. },
  3343. /* Generate the date picker content. */
  3344. _updateDatepicker: function(inst) {
  3345. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  3346. instActive = inst; // for delegate hover events
  3347. inst.dpDiv.empty().append(this._generateHTML(inst));
  3348. this._attachHandlers(inst);
  3349. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  3350. var origyearshtml,
  3351. numMonths = this._getNumberOfMonths(inst),
  3352. cols = numMonths[1],
  3353. width = 17;
  3354. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  3355. if (cols > 1) {
  3356. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  3357. }
  3358. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  3359. "Class"]("ui-datepicker-multi");
  3360. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  3361. "Class"]("ui-datepicker-rtl");
  3362. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  3363. inst.input.focus();
  3364. }
  3365. // deffered render of the years select (to avoid flashes on Firefox)
  3366. if( inst.yearshtml ){
  3367. origyearshtml = inst.yearshtml;
  3368. setTimeout(function(){
  3369. //assure that inst.yearshtml didn't change.
  3370. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  3371. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  3372. }
  3373. origyearshtml = inst.yearshtml = null;
  3374. }, 0);
  3375. }
  3376. },
  3377. // #6694 - don't focus the input if it's already focused
  3378. // this breaks the change event in IE
  3379. // Support: IE and jQuery <1.9
  3380. _shouldFocusInput: function( inst ) {
  3381. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  3382. },
  3383. /* Check positioning to remain on screen. */
  3384. _checkOffset: function(inst, offset, isFixed) {
  3385. var dpWidth = inst.dpDiv.outerWidth(),
  3386. dpHeight = inst.dpDiv.outerHeight(),
  3387. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  3388. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  3389. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  3390. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  3391. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  3392. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  3393. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  3394. // now check if datepicker is showing outside window viewport - move to a better place if so.
  3395. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  3396. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  3397. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  3398. Math.abs(dpHeight + inputHeight) : 0);
  3399. return offset;
  3400. },
  3401. /* Find an object's position on the screen. */
  3402. _findPos: function(obj) {
  3403. var position,
  3404. inst = this._getInst(obj),
  3405. isRTL = this._get(inst, "isRTL");
  3406. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  3407. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  3408. }
  3409. position = $(obj).offset();
  3410. return [position.left, position.top];
  3411. },
  3412. /* Hide the date picker from view.
  3413. * @param input element - the input field attached to the date picker
  3414. */
  3415. _hideDatepicker: function(input) {
  3416. var showAnim, duration, postProcess, onClose,
  3417. inst = this._curInst;
  3418. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  3419. return;
  3420. }
  3421. if (this._datepickerShowing) {
  3422. showAnim = this._get(inst, "showAnim");
  3423. duration = this._get(inst, "duration");
  3424. postProcess = function() {
  3425. $.datepicker._tidyDialog(inst);
  3426. };
  3427. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  3428. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  3429. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  3430. } else {
  3431. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  3432. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  3433. }
  3434. if (!showAnim) {
  3435. postProcess();
  3436. }
  3437. this._datepickerShowing = false;
  3438. onClose = this._get(inst, "onClose");
  3439. if (onClose) {
  3440. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  3441. }
  3442. this._lastInput = null;
  3443. if (this._inDialog) {
  3444. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  3445. if ($.blockUI) {
  3446. $.unblockUI();
  3447. $("body").append(this.dpDiv);
  3448. }
  3449. }
  3450. this._inDialog = false;
  3451. }
  3452. },
  3453. /* Tidy up after a dialog display. */
  3454. _tidyDialog: function(inst) {
  3455. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  3456. },
  3457. /* Close date picker if clicked elsewhere. */
  3458. _checkExternalClick: function(event) {
  3459. if (!$.datepicker._curInst) {
  3460. return;
  3461. }
  3462. var $target = $(event.target),
  3463. inst = $.datepicker._getInst($target[0]);
  3464. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  3465. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  3466. !$target.hasClass($.datepicker.markerClassName) &&
  3467. !$target.closest("." + $.datepicker._triggerClass).length &&
  3468. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  3469. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  3470. $.datepicker._hideDatepicker();
  3471. }
  3472. },
  3473. /* Adjust one of the date sub-fields. */
  3474. _adjustDate: function(id, offset, period) {
  3475. var target = $(id),
  3476. inst = this._getInst(target[0]);
  3477. if (this._isDisabledDatepicker(target[0])) {
  3478. return;
  3479. }
  3480. this._adjustInstDate(inst, offset +
  3481. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  3482. period);
  3483. this._updateDatepicker(inst);
  3484. },
  3485. /* Action for current link. */
  3486. _gotoToday: function(id) {
  3487. var date,
  3488. target = $(id),
  3489. inst = this._getInst(target[0]);
  3490. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  3491. inst.selectedDay = inst.currentDay;
  3492. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  3493. inst.drawYear = inst.selectedYear = inst.currentYear;
  3494. } else {
  3495. date = new Date();
  3496. inst.selectedDay = date.getDate();
  3497. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3498. inst.drawYear = inst.selectedYear = date.getFullYear();
  3499. }
  3500. this._notifyChange(inst);
  3501. this._adjustDate(target);
  3502. },
  3503. /* Action for selecting a new month/year. */
  3504. _selectMonthYear: function(id, select, period) {
  3505. var target = $(id),
  3506. inst = this._getInst(target[0]);
  3507. inst["selected" + (period === "M" ? "Month" : "Year")] =
  3508. inst["draw" + (period === "M" ? "Month" : "Year")] =
  3509. parseInt(select.options[select.selectedIndex].value,10);
  3510. this._notifyChange(inst);
  3511. this._adjustDate(target);
  3512. },
  3513. /* Action for selecting a day. */
  3514. _selectDay: function(id, month, year, td) {
  3515. var inst,
  3516. target = $(id);
  3517. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  3518. return;
  3519. }
  3520. inst = this._getInst(target[0]);
  3521. inst.selectedDay = inst.currentDay = $("a", td).html();
  3522. inst.selectedMonth = inst.currentMonth = month;
  3523. inst.selectedYear = inst.currentYear = year;
  3524. this._selectDate(id, this._formatDate(inst,
  3525. inst.currentDay, inst.currentMonth, inst.currentYear));
  3526. },
  3527. /* Erase the input field and hide the date picker. */
  3528. _clearDate: function(id) {
  3529. var target = $(id);
  3530. this._selectDate(target, "");
  3531. },
  3532. /* Update the input field with the selected date. */
  3533. _selectDate: function(id, dateStr) {
  3534. var onSelect,
  3535. target = $(id),
  3536. inst = this._getInst(target[0]);
  3537. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  3538. if (inst.input) {
  3539. inst.input.val(dateStr);
  3540. }
  3541. this._updateAlternate(inst);
  3542. onSelect = this._get(inst, "onSelect");
  3543. if (onSelect) {
  3544. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  3545. } else if (inst.input) {
  3546. inst.input.trigger("change"); // fire the change event
  3547. }
  3548. if (inst.inline){
  3549. this._updateDatepicker(inst);
  3550. } else {
  3551. this._hideDatepicker();
  3552. this._lastInput = inst.input[0];
  3553. if (typeof(inst.input[0]) !== "object") {
  3554. inst.input.focus(); // restore focus
  3555. }
  3556. this._lastInput = null;
  3557. }
  3558. },
  3559. /* Update any alternate field to synchronise with the main field. */
  3560. _updateAlternate: function(inst) {
  3561. var altFormat, date, dateStr,
  3562. altField = this._get(inst, "altField");
  3563. if (altField) { // update alternate field too
  3564. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  3565. date = this._getDate(inst);
  3566. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  3567. $(altField).each(function() { $(this).val(dateStr); });
  3568. }
  3569. },
  3570. /* Set as beforeShowDay function to prevent selection of weekends.
  3571. * @param date Date - the date to customise
  3572. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  3573. */
  3574. noWeekends: function(date) {
  3575. var day = date.getDay();
  3576. return [(day > 0 && day < 6), ""];
  3577. },
  3578. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  3579. * @param date Date - the date to get the week for
  3580. * @return number - the number of the week within the year that contains this date
  3581. */
  3582. iso8601Week: function(date) {
  3583. var time,
  3584. checkDate = new Date(date.getTime());
  3585. // Find Thursday of this week starting on Monday
  3586. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  3587. time = checkDate.getTime();
  3588. checkDate.setMonth(0); // Compare with Jan 1
  3589. checkDate.setDate(1);
  3590. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  3591. },
  3592. /* Parse a string value into a date object.
  3593. * See formatDate below for the possible formats.
  3594. *
  3595. * @param format string - the expected format of the date
  3596. * @param value string - the date in the above format
  3597. * @param settings Object - attributes include:
  3598. * shortYearCutoff number - the cutoff year for determining the century (optional)
  3599. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3600. * dayNames string[7] - names of the days from Sunday (optional)
  3601. * monthNamesShort string[12] - abbreviated names of the months (optional)
  3602. * monthNames string[12] - names of the months (optional)
  3603. * @return Date - the extracted date value or null if value is blank
  3604. */
  3605. parseDate: function (format, value, settings) {
  3606. if (format == null || value == null) {
  3607. throw "Invalid arguments";
  3608. }
  3609. value = (typeof value === "object" ? value.toString() : value + "");
  3610. if (value === "") {
  3611. return null;
  3612. }
  3613. var iFormat, dim, extra,
  3614. iValue = 0,
  3615. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  3616. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  3617. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  3618. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  3619. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  3620. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  3621. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  3622. year = -1,
  3623. month = -1,
  3624. day = -1,
  3625. doy = -1,
  3626. literal = false,
  3627. date,
  3628. // Check whether a format character is doubled
  3629. lookAhead = function(match) {
  3630. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3631. if (matches) {
  3632. iFormat++;
  3633. }
  3634. return matches;
  3635. },
  3636. // Extract a number from the string value
  3637. getNumber = function(match) {
  3638. var isDoubled = lookAhead(match),
  3639. size = (match === "@" ? 14 : (match === "!" ? 20 :
  3640. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  3641. digits = new RegExp("^\\d{1," + size + "}"),
  3642. num = value.substring(iValue).match(digits);
  3643. if (!num) {
  3644. throw "Missing number at position " + iValue;
  3645. }
  3646. iValue += num[0].length;
  3647. return parseInt(num[0], 10);
  3648. },
  3649. // Extract a name from the string value and convert to an index
  3650. getName = function(match, shortNames, longNames) {
  3651. var index = -1,
  3652. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  3653. return [ [k, v] ];
  3654. }).sort(function (a, b) {
  3655. return -(a[1].length - b[1].length);
  3656. });
  3657. $.each(names, function (i, pair) {
  3658. var name = pair[1];
  3659. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  3660. index = pair[0];
  3661. iValue += name.length;
  3662. return false;
  3663. }
  3664. });
  3665. if (index !== -1) {
  3666. return index + 1;
  3667. } else {
  3668. throw "Unknown name at position " + iValue;
  3669. }
  3670. },
  3671. // Confirm that a literal character matches the string value
  3672. checkLiteral = function() {
  3673. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  3674. throw "Unexpected literal at position " + iValue;
  3675. }
  3676. iValue++;
  3677. };
  3678. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3679. if (literal) {
  3680. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3681. literal = false;
  3682. } else {
  3683. checkLiteral();
  3684. }
  3685. } else {
  3686. switch (format.charAt(iFormat)) {
  3687. case "d":
  3688. day = getNumber("d");
  3689. break;
  3690. case "D":
  3691. getName("D", dayNamesShort, dayNames);
  3692. break;
  3693. case "o":
  3694. doy = getNumber("o");
  3695. break;
  3696. case "m":
  3697. month = getNumber("m");
  3698. break;
  3699. case "M":
  3700. month = getName("M", monthNamesShort, monthNames);
  3701. break;
  3702. case "y":
  3703. year = getNumber("y");
  3704. break;
  3705. case "@":
  3706. date = new Date(getNumber("@"));
  3707. year = date.getFullYear();
  3708. month = date.getMonth() + 1;
  3709. day = date.getDate();
  3710. break;
  3711. case "!":
  3712. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  3713. year = date.getFullYear();
  3714. month = date.getMonth() + 1;
  3715. day = date.getDate();
  3716. break;
  3717. case "'":
  3718. if (lookAhead("'")){
  3719. checkLiteral();
  3720. } else {
  3721. literal = true;
  3722. }
  3723. break;
  3724. default:
  3725. checkLiteral();
  3726. }
  3727. }
  3728. }
  3729. if (iValue < value.length){
  3730. extra = value.substr(iValue);
  3731. if (!/^\s+/.test(extra)) {
  3732. throw "Extra/unparsed characters found in date: " + extra;
  3733. }
  3734. }
  3735. if (year === -1) {
  3736. year = new Date().getFullYear();
  3737. } else if (year < 100) {
  3738. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  3739. (year <= shortYearCutoff ? 0 : -100);
  3740. }
  3741. if (doy > -1) {
  3742. month = 1;
  3743. day = doy;
  3744. do {
  3745. dim = this._getDaysInMonth(year, month - 1);
  3746. if (day <= dim) {
  3747. break;
  3748. }
  3749. month++;
  3750. day -= dim;
  3751. } while (true);
  3752. }
  3753. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  3754. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  3755. throw "Invalid date"; // E.g. 31/02/00
  3756. }
  3757. return date;
  3758. },
  3759. /* Standard date formats. */
  3760. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  3761. COOKIE: "D, dd M yy",
  3762. ISO_8601: "yy-mm-dd",
  3763. RFC_822: "D, d M y",
  3764. RFC_850: "DD, dd-M-y",
  3765. RFC_1036: "D, d M y",
  3766. RFC_1123: "D, d M yy",
  3767. RFC_2822: "D, d M yy",
  3768. RSS: "D, d M y", // RFC 822
  3769. TICKS: "!",
  3770. TIMESTAMP: "@",
  3771. W3C: "yy-mm-dd", // ISO 8601
  3772. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  3773. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  3774. /* Format a date object into a string value.
  3775. * The format can be combinations of the following:
  3776. * d - day of month (no leading zero)
  3777. * dd - day of month (two digit)
  3778. * o - day of year (no leading zeros)
  3779. * oo - day of year (three digit)
  3780. * D - day name short
  3781. * DD - day name long
  3782. * m - month of year (no leading zero)
  3783. * mm - month of year (two digit)
  3784. * M - month name short
  3785. * MM - month name long
  3786. * y - year (two digit)
  3787. * yy - year (four digit)
  3788. * @ - Unix timestamp (ms since 01/01/1970)
  3789. * ! - Windows ticks (100ns since 01/01/0001)
  3790. * "..." - literal text
  3791. * '' - single quote
  3792. *
  3793. * @param format string - the desired format of the date
  3794. * @param date Date - the date value to format
  3795. * @param settings Object - attributes include:
  3796. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3797. * dayNames string[7] - names of the days from Sunday (optional)
  3798. * monthNamesShort string[12] - abbreviated names of the months (optional)
  3799. * monthNames string[12] - names of the months (optional)
  3800. * @return string - the date in the above format
  3801. */
  3802. formatDate: function (format, date, settings) {
  3803. if (!date) {
  3804. return "";
  3805. }
  3806. var iFormat,
  3807. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  3808. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  3809. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  3810. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  3811. // Check whether a format character is doubled
  3812. lookAhead = function(match) {
  3813. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3814. if (matches) {
  3815. iFormat++;
  3816. }
  3817. return matches;
  3818. },
  3819. // Format a number, with leading zero if necessary
  3820. formatNumber = function(match, value, len) {
  3821. var num = "" + value;
  3822. if (lookAhead(match)) {
  3823. while (num.length < len) {
  3824. num = "0" + num;
  3825. }
  3826. }
  3827. return num;
  3828. },
  3829. // Format a name, short or long as requested
  3830. formatName = function(match, value, shortNames, longNames) {
  3831. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  3832. },
  3833. output = "",
  3834. literal = false;
  3835. if (date) {
  3836. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3837. if (literal) {
  3838. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3839. literal = false;
  3840. } else {
  3841. output += format.charAt(iFormat);
  3842. }
  3843. } else {
  3844. switch (format.charAt(iFormat)) {
  3845. case "d":
  3846. output += formatNumber("d", date.getDate(), 2);
  3847. break;
  3848. case "D":
  3849. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  3850. break;
  3851. case "o":
  3852. output += formatNumber("o",
  3853. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  3854. break;
  3855. case "m":
  3856. output += formatNumber("m", date.getMonth() + 1, 2);
  3857. break;
  3858. case "M":
  3859. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  3860. break;
  3861. case "y":
  3862. output += (lookAhead("y") ? date.getFullYear() :
  3863. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  3864. break;
  3865. case "@":
  3866. output += date.getTime();
  3867. break;
  3868. case "!":
  3869. output += date.getTime() * 10000 + this._ticksTo1970;
  3870. break;
  3871. case "'":
  3872. if (lookAhead("'")) {
  3873. output += "'";
  3874. } else {
  3875. literal = true;
  3876. }
  3877. break;
  3878. default:
  3879. output += format.charAt(iFormat);
  3880. }
  3881. }
  3882. }
  3883. }
  3884. return output;
  3885. },
  3886. /* Extract all possible characters from the date format. */
  3887. _possibleChars: function (format) {
  3888. var iFormat,
  3889. chars = "",
  3890. literal = false,
  3891. // Check whether a format character is doubled
  3892. lookAhead = function(match) {
  3893. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3894. if (matches) {
  3895. iFormat++;
  3896. }
  3897. return matches;
  3898. };
  3899. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3900. if (literal) {
  3901. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3902. literal = false;
  3903. } else {
  3904. chars += format.charAt(iFormat);
  3905. }
  3906. } else {
  3907. switch (format.charAt(iFormat)) {
  3908. case "d": case "m": case "y": case "@":
  3909. chars += "0123456789";
  3910. break;
  3911. case "D": case "M":
  3912. return null; // Accept anything
  3913. case "'":
  3914. if (lookAhead("'")) {
  3915. chars += "'";
  3916. } else {
  3917. literal = true;
  3918. }
  3919. break;
  3920. default:
  3921. chars += format.charAt(iFormat);
  3922. }
  3923. }
  3924. }
  3925. return chars;
  3926. },
  3927. /* Get a setting value, defaulting if necessary. */
  3928. _get: function(inst, name) {
  3929. return inst.settings[name] !== undefined ?
  3930. inst.settings[name] : this._defaults[name];
  3931. },
  3932. /* Parse existing date and initialise date picker. */
  3933. _setDateFromField: function(inst, noDefault) {
  3934. if (inst.input.val() === inst.lastVal) {
  3935. return;
  3936. }
  3937. var dateFormat = this._get(inst, "dateFormat"),
  3938. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  3939. defaultDate = this._getDefaultDate(inst),
  3940. date = defaultDate,
  3941. settings = this._getFormatConfig(inst);
  3942. try {
  3943. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  3944. } catch (event) {
  3945. dates = (noDefault ? "" : dates);
  3946. }
  3947. inst.selectedDay = date.getDate();
  3948. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3949. inst.drawYear = inst.selectedYear = date.getFullYear();
  3950. inst.currentDay = (dates ? date.getDate() : 0);
  3951. inst.currentMonth = (dates ? date.getMonth() : 0);
  3952. inst.currentYear = (dates ? date.getFullYear() : 0);
  3953. this._adjustInstDate(inst);
  3954. },
  3955. /* Retrieve the default date shown on opening. */
  3956. _getDefaultDate: function(inst) {
  3957. return this._restrictMinMax(inst,
  3958. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  3959. },
  3960. /* A date may be specified as an exact value or a relative one. */
  3961. _determineDate: function(inst, date, defaultDate) {
  3962. var offsetNumeric = function(offset) {
  3963. var date = new Date();
  3964. date.setDate(date.getDate() + offset);
  3965. return date;
  3966. },
  3967. offsetString = function(offset) {
  3968. try {
  3969. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3970. offset, $.datepicker._getFormatConfig(inst));
  3971. }
  3972. catch (e) {
  3973. // Ignore
  3974. }
  3975. var date = (offset.toLowerCase().match(/^c/) ?
  3976. $.datepicker._getDate(inst) : null) || new Date(),
  3977. year = date.getFullYear(),
  3978. month = date.getMonth(),
  3979. day = date.getDate(),
  3980. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  3981. matches = pattern.exec(offset);
  3982. while (matches) {
  3983. switch (matches[2] || "d") {
  3984. case "d" : case "D" :
  3985. day += parseInt(matches[1],10); break;
  3986. case "w" : case "W" :
  3987. day += parseInt(matches[1],10) * 7; break;
  3988. case "m" : case "M" :
  3989. month += parseInt(matches[1],10);
  3990. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  3991. break;
  3992. case "y": case "Y" :
  3993. year += parseInt(matches[1],10);
  3994. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  3995. break;
  3996. }
  3997. matches = pattern.exec(offset);
  3998. }
  3999. return new Date(year, month, day);
  4000. },
  4001. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  4002. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4003. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  4004. if (newDate) {
  4005. newDate.setHours(0);
  4006. newDate.setMinutes(0);
  4007. newDate.setSeconds(0);
  4008. newDate.setMilliseconds(0);
  4009. }
  4010. return this._daylightSavingAdjust(newDate);
  4011. },
  4012. /* Handle switch to/from daylight saving.
  4013. * Hours may be non-zero on daylight saving cut-over:
  4014. * > 12 when midnight changeover, but then cannot generate
  4015. * midnight datetime, so jump to 1AM, otherwise reset.
  4016. * @param date (Date) the date to check
  4017. * @return (Date) the corrected date
  4018. */
  4019. _daylightSavingAdjust: function(date) {
  4020. if (!date) {
  4021. return null;
  4022. }
  4023. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4024. return date;
  4025. },
  4026. /* Set the date(s) directly. */
  4027. _setDate: function(inst, date, noChange) {
  4028. var clear = !date,
  4029. origMonth = inst.selectedMonth,
  4030. origYear = inst.selectedYear,
  4031. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4032. inst.selectedDay = inst.currentDay = newDate.getDate();
  4033. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4034. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4035. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  4036. this._notifyChange(inst);
  4037. }
  4038. this._adjustInstDate(inst);
  4039. if (inst.input) {
  4040. inst.input.val(clear ? "" : this._formatDate(inst));
  4041. }
  4042. },
  4043. /* Retrieve the date(s) directly. */
  4044. _getDate: function(inst) {
  4045. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  4046. this._daylightSavingAdjust(new Date(
  4047. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4048. return startDate;
  4049. },
  4050. /* Attach the onxxx handlers. These are declared statically so
  4051. * they work with static code transformers like Caja.
  4052. */
  4053. _attachHandlers: function(inst) {
  4054. var stepMonths = this._get(inst, "stepMonths"),
  4055. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  4056. inst.dpDiv.find("[data-handler]").map(function () {
  4057. var handler = {
  4058. prev: function () {
  4059. $.datepicker._adjustDate(id, -stepMonths, "M");
  4060. },
  4061. next: function () {
  4062. $.datepicker._adjustDate(id, +stepMonths, "M");
  4063. },
  4064. hide: function () {
  4065. $.datepicker._hideDatepicker();
  4066. },
  4067. today: function () {
  4068. $.datepicker._gotoToday(id);
  4069. },
  4070. selectDay: function () {
  4071. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  4072. return false;
  4073. },
  4074. selectMonth: function () {
  4075. $.datepicker._selectMonthYear(id, this, "M");
  4076. return false;
  4077. },
  4078. selectYear: function () {
  4079. $.datepicker._selectMonthYear(id, this, "Y");
  4080. return false;
  4081. }
  4082. };
  4083. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  4084. });
  4085. },
  4086. /* Generate the HTML for the current state of the date picker. */
  4087. _generateHTML: function(inst) {
  4088. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  4089. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  4090. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  4091. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  4092. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  4093. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  4094. tempDate = new Date(),
  4095. today = this._daylightSavingAdjust(
  4096. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  4097. isRTL = this._get(inst, "isRTL"),
  4098. showButtonPanel = this._get(inst, "showButtonPanel"),
  4099. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  4100. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  4101. numMonths = this._getNumberOfMonths(inst),
  4102. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  4103. stepMonths = this._get(inst, "stepMonths"),
  4104. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  4105. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4106. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  4107. minDate = this._getMinMaxDate(inst, "min"),
  4108. maxDate = this._getMinMaxDate(inst, "max"),
  4109. drawMonth = inst.drawMonth - showCurrentAtPos,
  4110. drawYear = inst.drawYear;
  4111. if (drawMonth < 0) {
  4112. drawMonth += 12;
  4113. drawYear--;
  4114. }
  4115. if (maxDate) {
  4116. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4117. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4118. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4119. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4120. drawMonth--;
  4121. if (drawMonth < 0) {
  4122. drawMonth = 11;
  4123. drawYear--;
  4124. }
  4125. }
  4126. }
  4127. inst.drawMonth = drawMonth;
  4128. inst.drawYear = drawYear;
  4129. prevText = this._get(inst, "prevText");
  4130. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4131. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4132. this._getFormatConfig(inst)));
  4133. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4134. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  4135. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  4136. (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>"));
  4137. nextText = this._get(inst, "nextText");
  4138. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4139. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4140. this._getFormatConfig(inst)));
  4141. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4142. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  4143. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  4144. (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>"));
  4145. currentText = this._get(inst, "currentText");
  4146. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  4147. currentText = (!navigationAsDateFormat ? currentText :
  4148. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4149. 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'>" +
  4150. this._get(inst, "closeText") + "</button>" : "");
  4151. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  4152. (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'" +
  4153. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  4154. firstDay = parseInt(this._get(inst, "firstDay"),10);
  4155. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4156. showWeek = this._get(inst, "showWeek");
  4157. dayNames = this._get(inst, "dayNames");
  4158. dayNamesMin = this._get(inst, "dayNamesMin");
  4159. monthNames = this._get(inst, "monthNames");
  4160. monthNamesShort = this._get(inst, "monthNamesShort");
  4161. beforeShowDay = this._get(inst, "beforeShowDay");
  4162. showOtherMonths = this._get(inst, "showOtherMonths");
  4163. selectOtherMonths = this._get(inst, "selectOtherMonths");
  4164. defaultDate = this._getDefaultDate(inst);
  4165. html = "";
  4166. dow;
  4167. for (row = 0; row < numMonths[0]; row++) {
  4168. group = "";
  4169. this.maxRows = 4;
  4170. for (col = 0; col < numMonths[1]; col++) {
  4171. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4172. cornerClass = " ui-corner-all";
  4173. calender = "";
  4174. if (isMultiMonth) {
  4175. calender += "<div class='ui-datepicker-group";
  4176. if (numMonths[1] > 1) {
  4177. switch (col) {
  4178. case 0: calender += " ui-datepicker-group-first";
  4179. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4180. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  4181. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4182. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4183. }
  4184. }
  4185. calender += "'>";
  4186. }
  4187. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4188. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4189. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4190. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4191. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4192. "</div><table class='ui-datepicker-calendar'><thead>" +
  4193. "<tr>";
  4194. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4195. for (dow = 0; dow < 7; dow++) { // days of the week
  4196. day = (dow + firstDay) % 7;
  4197. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4198. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4199. }
  4200. calender += thead + "</tr></thead><tbody>";
  4201. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4202. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4203. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4204. }
  4205. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4206. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4207. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4208. this.maxRows = numRows;
  4209. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4210. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4211. calender += "<tr>";
  4212. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4213. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4214. for (dow = 0; dow < 7; dow++) { // create date picker days
  4215. daySettings = (beforeShowDay ?
  4216. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4217. otherMonth = (printDate.getMonth() !== drawMonth);
  4218. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4219. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4220. tbody += "<td class='" +
  4221. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4222. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4223. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4224. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4225. // or defaultDate is current printedDate and defaultDate is selectedDate
  4226. " " + this._dayOverClass : "") + // highlight selected day
  4227. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  4228. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4229. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4230. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4231. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4232. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4233. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4234. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4235. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4236. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4237. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4238. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4239. printDate.setDate(printDate.getDate() + 1);
  4240. printDate = this._daylightSavingAdjust(printDate);
  4241. }
  4242. calender += tbody + "</tr>";
  4243. }
  4244. drawMonth++;
  4245. if (drawMonth > 11) {
  4246. drawMonth = 0;
  4247. drawYear++;
  4248. }
  4249. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4250. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4251. group += calender;
  4252. }
  4253. html += group;
  4254. }
  4255. html += buttonPanel;
  4256. inst._keyEvent = false;
  4257. return html;
  4258. },
  4259. /* Generate the month and year header. */
  4260. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4261. secondary, monthNames, monthNamesShort) {
  4262. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4263. changeMonth = this._get(inst, "changeMonth"),
  4264. changeYear = this._get(inst, "changeYear"),
  4265. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4266. html = "<div class='ui-datepicker-title'>",
  4267. monthHtml = "";
  4268. // month selection
  4269. if (secondary || !changeMonth) {
  4270. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4271. } else {
  4272. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4273. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4274. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4275. for ( month = 0; month < 12; month++) {
  4276. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4277. monthHtml += "<option value='" + month + "'" +
  4278. (month === drawMonth ? " selected='selected'" : "") +
  4279. ">" + monthNamesShort[month] + "</option>";
  4280. }
  4281. }
  4282. monthHtml += "</select>";
  4283. }
  4284. if (!showMonthAfterYear) {
  4285. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4286. }
  4287. // year selection
  4288. if ( !inst.yearshtml ) {
  4289. inst.yearshtml = "";
  4290. if (secondary || !changeYear) {
  4291. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4292. } else {
  4293. // determine range of years to display
  4294. years = this._get(inst, "yearRange").split(":");
  4295. thisYear = new Date().getFullYear();
  4296. determineYear = function(value) {
  4297. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4298. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4299. parseInt(value, 10)));
  4300. return (isNaN(year) ? thisYear : year);
  4301. };
  4302. year = determineYear(years[0]);
  4303. endYear = Math.max(year, determineYear(years[1] || ""));
  4304. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4305. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4306. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4307. for (; year <= endYear; year++) {
  4308. inst.yearshtml += "<option value='" + year + "'" +
  4309. (year === drawYear ? " selected='selected'" : "") +
  4310. ">" + year + "</option>";
  4311. }
  4312. inst.yearshtml += "</select>";
  4313. html += inst.yearshtml;
  4314. inst.yearshtml = null;
  4315. }
  4316. }
  4317. html += this._get(inst, "yearSuffix");
  4318. if (showMonthAfterYear) {
  4319. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4320. }
  4321. html += "</div>"; // Close datepicker_header
  4322. return html;
  4323. },
  4324. /* Adjust one of the date sub-fields. */
  4325. _adjustInstDate: function(inst, offset, period) {
  4326. var year = inst.drawYear + (period === "Y" ? offset : 0),
  4327. month = inst.drawMonth + (period === "M" ? offset : 0),
  4328. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  4329. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  4330. inst.selectedDay = date.getDate();
  4331. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4332. inst.drawYear = inst.selectedYear = date.getFullYear();
  4333. if (period === "M" || period === "Y") {
  4334. this._notifyChange(inst);
  4335. }
  4336. },
  4337. /* Ensure a date is within any min/max bounds. */
  4338. _restrictMinMax: function(inst, date) {
  4339. var minDate = this._getMinMaxDate(inst, "min"),
  4340. maxDate = this._getMinMaxDate(inst, "max"),
  4341. newDate = (minDate && date < minDate ? minDate : date);
  4342. return (maxDate && newDate > maxDate ? maxDate : newDate);
  4343. },
  4344. /* Notify change of month/year. */
  4345. _notifyChange: function(inst) {
  4346. var onChange = this._get(inst, "onChangeMonthYear");
  4347. if (onChange) {
  4348. onChange.apply((inst.input ? inst.input[0] : null),
  4349. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  4350. }
  4351. },
  4352. /* Determine the number of months to show. */
  4353. _getNumberOfMonths: function(inst) {
  4354. var numMonths = this._get(inst, "numberOfMonths");
  4355. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  4356. },
  4357. /* Determine the current maximum date - ensure no time components are set. */
  4358. _getMinMaxDate: function(inst, minMax) {
  4359. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  4360. },
  4361. /* Find the number of days in a given month. */
  4362. _getDaysInMonth: function(year, month) {
  4363. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  4364. },
  4365. /* Find the day of the week of the first of a month. */
  4366. _getFirstDayOfMonth: function(year, month) {
  4367. return new Date(year, month, 1).getDay();
  4368. },
  4369. /* Determines if we should allow a "next/prev" month display change. */
  4370. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  4371. var numMonths = this._getNumberOfMonths(inst),
  4372. date = this._daylightSavingAdjust(new Date(curYear,
  4373. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  4374. if (offset < 0) {
  4375. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  4376. }
  4377. return this._isInRange(inst, date);
  4378. },
  4379. /* Is the given date in the accepted range? */
  4380. _isInRange: function(inst, date) {
  4381. var yearSplit, currentYear,
  4382. minDate = this._getMinMaxDate(inst, "min"),
  4383. maxDate = this._getMinMaxDate(inst, "max"),
  4384. minYear = null,
  4385. maxYear = null,
  4386. years = this._get(inst, "yearRange");
  4387. if (years){
  4388. yearSplit = years.split(":");
  4389. currentYear = new Date().getFullYear();
  4390. minYear = parseInt(yearSplit[0], 10);
  4391. maxYear = parseInt(yearSplit[1], 10);
  4392. if ( yearSplit[0].match(/[+\-].*/) ) {
  4393. minYear += currentYear;
  4394. }
  4395. if ( yearSplit[1].match(/[+\-].*/) ) {
  4396. maxYear += currentYear;
  4397. }
  4398. }
  4399. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  4400. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  4401. (!minYear || date.getFullYear() >= minYear) &&
  4402. (!maxYear || date.getFullYear() <= maxYear));
  4403. },
  4404. /* Provide the configuration settings for formatting/parsing. */
  4405. _getFormatConfig: function(inst) {
  4406. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  4407. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  4408. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  4409. return {shortYearCutoff: shortYearCutoff,
  4410. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  4411. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  4412. },
  4413. /* Format the given date for display. */
  4414. _formatDate: function(inst, day, month, year) {
  4415. if (!day) {
  4416. inst.currentDay = inst.selectedDay;
  4417. inst.currentMonth = inst.selectedMonth;
  4418. inst.currentYear = inst.selectedYear;
  4419. }
  4420. var date = (day ? (typeof day === "object" ? day :
  4421. this._daylightSavingAdjust(new Date(year, month, day))) :
  4422. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  4423. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  4424. }
  4425. });
  4426. /*
  4427. * Bind hover events for datepicker elements.
  4428. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  4429. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  4430. */
  4431. function bindHover(dpDiv) {
  4432. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  4433. return dpDiv.delegate(selector, "mouseout", function() {
  4434. $(this).removeClass("ui-state-hover");
  4435. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  4436. $(this).removeClass("ui-datepicker-prev-hover");
  4437. }
  4438. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  4439. $(this).removeClass("ui-datepicker-next-hover");
  4440. }
  4441. })
  4442. .delegate(selector, "mouseover", function(){
  4443. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  4444. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  4445. $(this).addClass("ui-state-hover");
  4446. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  4447. $(this).addClass("ui-datepicker-prev-hover");
  4448. }
  4449. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  4450. $(this).addClass("ui-datepicker-next-hover");
  4451. }
  4452. }
  4453. });
  4454. }
  4455. /* jQuery extend now ignores nulls! */
  4456. function extendRemove(target, props) {
  4457. $.extend(target, props);
  4458. for (var name in props) {
  4459. if (props[name] == null) {
  4460. target[name] = props[name];
  4461. }
  4462. }
  4463. return target;
  4464. }
  4465. /* Invoke the datepicker functionality.
  4466. @param options string - a command, optionally followed by additional parameters or
  4467. Object - settings for attaching new datepicker functionality
  4468. @return jQuery object */
  4469. $.fn.datepicker = function(options){
  4470. /* Verify an empty collection wasn't passed - Fixes #6976 */
  4471. if ( !this.length ) {
  4472. return this;
  4473. }
  4474. /* Initialise the date picker. */
  4475. if (!$.datepicker.initialized) {
  4476. $(document).mousedown($.datepicker._checkExternalClick);
  4477. $.datepicker.initialized = true;
  4478. }
  4479. /* Append datepicker main container to body if not exist. */
  4480. if ($("#"+$.datepicker._mainDivId).length === 0) {
  4481. $("body").append($.datepicker.dpDiv);
  4482. }
  4483. var otherArgs = Array.prototype.slice.call(arguments, 1);
  4484. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  4485. return $.datepicker["_" + options + "Datepicker"].
  4486. apply($.datepicker, [this[0]].concat(otherArgs));
  4487. }
  4488. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  4489. return $.datepicker["_" + options + "Datepicker"].
  4490. apply($.datepicker, [this[0]].concat(otherArgs));
  4491. }
  4492. return this.each(function() {
  4493. typeof options === "string" ?
  4494. $.datepicker["_" + options + "Datepicker"].
  4495. apply($.datepicker, [this].concat(otherArgs)) :
  4496. $.datepicker._attachDatepicker(this, options);
  4497. });
  4498. };
  4499. $.datepicker = new Datepicker(); // singleton instance
  4500. $.datepicker.initialized = false;
  4501. $.datepicker.uuid = new Date().getTime();
  4502. $.datepicker.version = "1.10.4";
  4503. })(jQuery);
  4504. (function( $, undefined ) {
  4505. var sizeRelatedOptions = {
  4506. buttons: true,
  4507. height: true,
  4508. maxHeight: true,
  4509. maxWidth: true,
  4510. minHeight: true,
  4511. minWidth: true,
  4512. width: true
  4513. },
  4514. resizableRelatedOptions = {
  4515. maxHeight: true,
  4516. maxWidth: true,
  4517. minHeight: true,
  4518. minWidth: true
  4519. };
  4520. $.widget( "ui.dialog", {
  4521. version: "1.10.4",
  4522. options: {
  4523. appendTo: "body",
  4524. autoOpen: true,
  4525. buttons: [],
  4526. closeOnEscape: true,
  4527. closeText: "close",
  4528. dialogClass: "",
  4529. draggable: true,
  4530. hide: null,
  4531. height: "auto",
  4532. maxHeight: null,
  4533. maxWidth: null,
  4534. minHeight: 150,
  4535. minWidth: 150,
  4536. modal: false,
  4537. position: {
  4538. my: "center",
  4539. at: "center",
  4540. of: window,
  4541. collision: "fit",
  4542. // Ensure the titlebar is always visible
  4543. using: function( pos ) {
  4544. var topOffset = $( this ).css( pos ).offset().top;
  4545. if ( topOffset < 0 ) {
  4546. $( this ).css( "top", pos.top - topOffset );
  4547. }
  4548. }
  4549. },
  4550. resizable: true,
  4551. show: null,
  4552. title: null,
  4553. width: 300,
  4554. // callbacks
  4555. beforeClose: null,
  4556. close: null,
  4557. drag: null,
  4558. dragStart: null,
  4559. dragStop: null,
  4560. focus: null,
  4561. open: null,
  4562. resize: null,
  4563. resizeStart: null,
  4564. resizeStop: null
  4565. },
  4566. _create: function() {
  4567. this.originalCss = {
  4568. display: this.element[0].style.display,
  4569. width: this.element[0].style.width,
  4570. minHeight: this.element[0].style.minHeight,
  4571. maxHeight: this.element[0].style.maxHeight,
  4572. height: this.element[0].style.height
  4573. };
  4574. this.originalPosition = {
  4575. parent: this.element.parent(),
  4576. index: this.element.parent().children().index( this.element )
  4577. };
  4578. this.originalTitle = this.element.attr("title");
  4579. this.options.title = this.options.title || this.originalTitle;
  4580. this._createWrapper();
  4581. this.element
  4582. .show()
  4583. .removeAttr("title")
  4584. .addClass("ui-dialog-content ui-widget-content")
  4585. .appendTo( this.uiDialog );
  4586. this._createTitlebar();
  4587. this._createButtonPane();
  4588. if ( this.options.draggable && $.fn.draggable ) {
  4589. this._makeDraggable();
  4590. }
  4591. if ( this.options.resizable && $.fn.resizable ) {
  4592. this._makeResizable();
  4593. }
  4594. this._isOpen = false;
  4595. },
  4596. _init: function() {
  4597. if ( this.options.autoOpen ) {
  4598. this.open();
  4599. }
  4600. },
  4601. _appendTo: function() {
  4602. var element = this.options.appendTo;
  4603. if ( element && (element.jquery || element.nodeType) ) {
  4604. return $( element );
  4605. }
  4606. return this.document.find( element || "body" ).eq( 0 );
  4607. },
  4608. _destroy: function() {
  4609. var next,
  4610. originalPosition = this.originalPosition;
  4611. this._destroyOverlay();
  4612. this.element
  4613. .removeUniqueId()
  4614. .removeClass("ui-dialog-content ui-widget-content")
  4615. .css( this.originalCss )
  4616. // Without detaching first, the following becomes really slow
  4617. .detach();
  4618. this.uiDialog.stop( true, true ).remove();
  4619. if ( this.originalTitle ) {
  4620. this.element.attr( "title", this.originalTitle );
  4621. }
  4622. next = originalPosition.parent.children().eq( originalPosition.index );
  4623. // Don't try to place the dialog next to itself (#8613)
  4624. if ( next.length && next[0] !== this.element[0] ) {
  4625. next.before( this.element );
  4626. } else {
  4627. originalPosition.parent.append( this.element );
  4628. }
  4629. },
  4630. widget: function() {
  4631. return this.uiDialog;
  4632. },
  4633. disable: $.noop,
  4634. enable: $.noop,
  4635. close: function( event ) {
  4636. var activeElement,
  4637. that = this;
  4638. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  4639. return;
  4640. }
  4641. this._isOpen = false;
  4642. this._destroyOverlay();
  4643. if ( !this.opener.filter(":focusable").focus().length ) {
  4644. // support: IE9
  4645. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  4646. try {
  4647. activeElement = this.document[ 0 ].activeElement;
  4648. // Support: IE9, IE10
  4649. // If the <body> is blurred, IE will switch windows, see #4520
  4650. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  4651. // Hiding a focused element doesn't trigger blur in WebKit
  4652. // so in case we have nothing to focus on, explicitly blur the active element
  4653. // https://bugs.webkit.org/show_bug.cgi?id=47182
  4654. $( activeElement ).blur();
  4655. }
  4656. } catch ( error ) {}
  4657. }
  4658. this._hide( this.uiDialog, this.options.hide, function() {
  4659. that._trigger( "close", event );
  4660. });
  4661. },
  4662. isOpen: function() {
  4663. return this._isOpen;
  4664. },
  4665. moveToTop: function() {
  4666. this._moveToTop();
  4667. },
  4668. _moveToTop: function( event, silent ) {
  4669. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  4670. if ( moved && !silent ) {
  4671. this._trigger( "focus", event );
  4672. }
  4673. return moved;
  4674. },
  4675. open: function() {
  4676. var that = this;
  4677. if ( this._isOpen ) {
  4678. if ( this._moveToTop() ) {
  4679. this._focusTabbable();
  4680. }
  4681. return;
  4682. }
  4683. this._isOpen = true;
  4684. this.opener = $( this.document[0].activeElement );
  4685. this._size();
  4686. this._position();
  4687. this._createOverlay();
  4688. this._moveToTop( null, true );
  4689. this._show( this.uiDialog, this.options.show, function() {
  4690. that._focusTabbable();
  4691. that._trigger("focus");
  4692. });
  4693. this._trigger("open");
  4694. },
  4695. _focusTabbable: function() {
  4696. // Set focus to the first match:
  4697. // 1. First element inside the dialog matching [autofocus]
  4698. // 2. Tabbable element inside the content element
  4699. // 3. Tabbable element inside the buttonpane
  4700. // 4. The close button
  4701. // 5. The dialog itself
  4702. var hasFocus = this.element.find("[autofocus]");
  4703. if ( !hasFocus.length ) {
  4704. hasFocus = this.element.find(":tabbable");
  4705. }
  4706. if ( !hasFocus.length ) {
  4707. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  4708. }
  4709. if ( !hasFocus.length ) {
  4710. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  4711. }
  4712. if ( !hasFocus.length ) {
  4713. hasFocus = this.uiDialog;
  4714. }
  4715. hasFocus.eq( 0 ).focus();
  4716. },
  4717. _keepFocus: function( event ) {
  4718. function checkFocus() {
  4719. var activeElement = this.document[0].activeElement,
  4720. isActive = this.uiDialog[0] === activeElement ||
  4721. $.contains( this.uiDialog[0], activeElement );
  4722. if ( !isActive ) {
  4723. this._focusTabbable();
  4724. }
  4725. }
  4726. event.preventDefault();
  4727. checkFocus.call( this );
  4728. // support: IE
  4729. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  4730. // so we check again later
  4731. this._delay( checkFocus );
  4732. },
  4733. _createWrapper: function() {
  4734. this.uiDialog = $("<div>")
  4735. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  4736. this.options.dialogClass )
  4737. .hide()
  4738. .attr({
  4739. // Setting tabIndex makes the div focusable
  4740. tabIndex: -1,
  4741. role: "dialog"
  4742. })
  4743. .appendTo( this._appendTo() );
  4744. this._on( this.uiDialog, {
  4745. keydown: function( event ) {
  4746. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  4747. event.keyCode === $.ui.keyCode.ESCAPE ) {
  4748. event.preventDefault();
  4749. this.close( event );
  4750. return;
  4751. }
  4752. // prevent tabbing out of dialogs
  4753. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  4754. return;
  4755. }
  4756. var tabbables = this.uiDialog.find(":tabbable"),
  4757. first = tabbables.filter(":first"),
  4758. last = tabbables.filter(":last");
  4759. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  4760. first.focus( 1 );
  4761. event.preventDefault();
  4762. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  4763. last.focus( 1 );
  4764. event.preventDefault();
  4765. }
  4766. },
  4767. mousedown: function( event ) {
  4768. if ( this._moveToTop( event ) ) {
  4769. this._focusTabbable();
  4770. }
  4771. }
  4772. });
  4773. // We assume that any existing aria-describedby attribute means
  4774. // that the dialog content is marked up properly
  4775. // otherwise we brute force the content as the description
  4776. if ( !this.element.find("[aria-describedby]").length ) {
  4777. this.uiDialog.attr({
  4778. "aria-describedby": this.element.uniqueId().attr("id")
  4779. });
  4780. }
  4781. },
  4782. _createTitlebar: function() {
  4783. var uiDialogTitle;
  4784. this.uiDialogTitlebar = $("<div>")
  4785. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  4786. .prependTo( this.uiDialog );
  4787. this._on( this.uiDialogTitlebar, {
  4788. mousedown: function( event ) {
  4789. // Don't prevent click on close button (#8838)
  4790. // Focusing a dialog that is partially scrolled out of view
  4791. // causes the browser to scroll it into view, preventing the click event
  4792. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  4793. // Dialog isn't getting focus when dragging (#8063)
  4794. this.uiDialog.focus();
  4795. }
  4796. }
  4797. });
  4798. // support: IE
  4799. // Use type="button" to prevent enter keypresses in textboxes from closing the
  4800. // dialog in IE (#9312)
  4801. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  4802. .button({
  4803. label: this.options.closeText,
  4804. icons: {
  4805. primary: "ui-icon-closethick"
  4806. },
  4807. text: false
  4808. })
  4809. .addClass("ui-dialog-titlebar-close")
  4810. .appendTo( this.uiDialogTitlebar );
  4811. this._on( this.uiDialogTitlebarClose, {
  4812. click: function( event ) {
  4813. event.preventDefault();
  4814. this.close( event );
  4815. }
  4816. });
  4817. uiDialogTitle = $("<span>")
  4818. .uniqueId()
  4819. .addClass("ui-dialog-title")
  4820. .prependTo( this.uiDialogTitlebar );
  4821. this._title( uiDialogTitle );
  4822. this.uiDialog.attr({
  4823. "aria-labelledby": uiDialogTitle.attr("id")
  4824. });
  4825. },
  4826. _title: function( title ) {
  4827. if ( !this.options.title ) {
  4828. title.html("&#160;");
  4829. }
  4830. title.text( this.options.title );
  4831. },
  4832. _createButtonPane: function() {
  4833. this.uiDialogButtonPane = $("<div>")
  4834. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  4835. this.uiButtonSet = $("<div>")
  4836. .addClass("ui-dialog-buttonset")
  4837. .appendTo( this.uiDialogButtonPane );
  4838. this._createButtons();
  4839. },
  4840. _createButtons: function() {
  4841. var that = this,
  4842. buttons = this.options.buttons;
  4843. // if we already have a button pane, remove it
  4844. this.uiDialogButtonPane.remove();
  4845. this.uiButtonSet.empty();
  4846. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  4847. this.uiDialog.removeClass("ui-dialog-buttons");
  4848. return;
  4849. }
  4850. $.each( buttons, function( name, props ) {
  4851. var click, buttonOptions;
  4852. props = $.isFunction( props ) ?
  4853. { click: props, text: name } :
  4854. props;
  4855. // Default to a non-submitting button
  4856. props = $.extend( { type: "button" }, props );
  4857. // Change the context for the click callback to be the main element
  4858. click = props.click;
  4859. props.click = function() {
  4860. click.apply( that.element[0], arguments );
  4861. };
  4862. buttonOptions = {
  4863. icons: props.icons,
  4864. text: props.showText
  4865. };
  4866. delete props.icons;
  4867. delete props.showText;
  4868. $( "<button></button>", props )
  4869. .button( buttonOptions )
  4870. .appendTo( that.uiButtonSet );
  4871. });
  4872. this.uiDialog.addClass("ui-dialog-buttons");
  4873. this.uiDialogButtonPane.appendTo( this.uiDialog );
  4874. },
  4875. _makeDraggable: function() {
  4876. var that = this,
  4877. options = this.options;
  4878. function filteredUi( ui ) {
  4879. return {
  4880. position: ui.position,
  4881. offset: ui.offset
  4882. };
  4883. }
  4884. this.uiDialog.draggable({
  4885. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  4886. handle: ".ui-dialog-titlebar",
  4887. containment: "document",
  4888. start: function( event, ui ) {
  4889. $( this ).addClass("ui-dialog-dragging");
  4890. that._blockFrames();
  4891. that._trigger( "dragStart", event, filteredUi( ui ) );
  4892. },
  4893. drag: function( event, ui ) {
  4894. that._trigger( "drag", event, filteredUi( ui ) );
  4895. },
  4896. stop: function( event, ui ) {
  4897. options.position = [
  4898. ui.position.left - that.document.scrollLeft(),
  4899. ui.position.top - that.document.scrollTop()
  4900. ];
  4901. $( this ).removeClass("ui-dialog-dragging");
  4902. that._unblockFrames();
  4903. that._trigger( "dragStop", event, filteredUi( ui ) );
  4904. }
  4905. });
  4906. },
  4907. _makeResizable: function() {
  4908. var that = this,
  4909. options = this.options,
  4910. handles = options.resizable,
  4911. // .ui-resizable has position: relative defined in the stylesheet
  4912. // but dialogs have to use absolute or fixed positioning
  4913. position = this.uiDialog.css("position"),
  4914. resizeHandles = typeof handles === "string" ?
  4915. handles :
  4916. "n,e,s,w,se,sw,ne,nw";
  4917. function filteredUi( ui ) {
  4918. return {
  4919. originalPosition: ui.originalPosition,
  4920. originalSize: ui.originalSize,
  4921. position: ui.position,
  4922. size: ui.size
  4923. };
  4924. }
  4925. this.uiDialog.resizable({
  4926. cancel: ".ui-dialog-content",
  4927. containment: "document",
  4928. alsoResize: this.element,
  4929. maxWidth: options.maxWidth,
  4930. maxHeight: options.maxHeight,
  4931. minWidth: options.minWidth,
  4932. minHeight: this._minHeight(),
  4933. handles: resizeHandles,
  4934. start: function( event, ui ) {
  4935. $( this ).addClass("ui-dialog-resizing");
  4936. that._blockFrames();
  4937. that._trigger( "resizeStart", event, filteredUi( ui ) );
  4938. },
  4939. resize: function( event, ui ) {
  4940. that._trigger( "resize", event, filteredUi( ui ) );
  4941. },
  4942. stop: function( event, ui ) {
  4943. options.height = $( this ).height();
  4944. options.width = $( this ).width();
  4945. $( this ).removeClass("ui-dialog-resizing");
  4946. that._unblockFrames();
  4947. that._trigger( "resizeStop", event, filteredUi( ui ) );
  4948. }
  4949. })
  4950. .css( "position", position );
  4951. },
  4952. _minHeight: function() {
  4953. var options = this.options;
  4954. return options.height === "auto" ?
  4955. options.minHeight :
  4956. Math.min( options.minHeight, options.height );
  4957. },
  4958. _position: function() {
  4959. // Need to show the dialog to get the actual offset in the position plugin
  4960. var isVisible = this.uiDialog.is(":visible");
  4961. if ( !isVisible ) {
  4962. this.uiDialog.show();
  4963. }
  4964. this.uiDialog.position( this.options.position );
  4965. if ( !isVisible ) {
  4966. this.uiDialog.hide();
  4967. }
  4968. },
  4969. _setOptions: function( options ) {
  4970. var that = this,
  4971. resize = false,
  4972. resizableOptions = {};
  4973. $.each( options, function( key, value ) {
  4974. that._setOption( key, value );
  4975. if ( key in sizeRelatedOptions ) {
  4976. resize = true;
  4977. }
  4978. if ( key in resizableRelatedOptions ) {
  4979. resizableOptions[ key ] = value;
  4980. }
  4981. });
  4982. if ( resize ) {
  4983. this._size();
  4984. this._position();
  4985. }
  4986. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  4987. this.uiDialog.resizable( "option", resizableOptions );
  4988. }
  4989. },
  4990. _setOption: function( key, value ) {
  4991. var isDraggable, isResizable,
  4992. uiDialog = this.uiDialog;
  4993. if ( key === "dialogClass" ) {
  4994. uiDialog
  4995. .removeClass( this.options.dialogClass )
  4996. .addClass( value );
  4997. }
  4998. if ( key === "disabled" ) {
  4999. return;
  5000. }
  5001. this._super( key, value );
  5002. if ( key === "appendTo" ) {
  5003. this.uiDialog.appendTo( this._appendTo() );
  5004. }
  5005. if ( key === "buttons" ) {
  5006. this._createButtons();
  5007. }
  5008. if ( key === "closeText" ) {
  5009. this.uiDialogTitlebarClose.button({
  5010. // Ensure that we always pass a string
  5011. label: "" + value
  5012. });
  5013. }
  5014. if ( key === "draggable" ) {
  5015. isDraggable = uiDialog.is(":data(ui-draggable)");
  5016. if ( isDraggable && !value ) {
  5017. uiDialog.draggable("destroy");
  5018. }
  5019. if ( !isDraggable && value ) {
  5020. this._makeDraggable();
  5021. }
  5022. }
  5023. if ( key === "position" ) {
  5024. this._position();
  5025. }
  5026. if ( key === "resizable" ) {
  5027. // currently resizable, becoming non-resizable
  5028. isResizable = uiDialog.is(":data(ui-resizable)");
  5029. if ( isResizable && !value ) {
  5030. uiDialog.resizable("destroy");
  5031. }
  5032. // currently resizable, changing handles
  5033. if ( isResizable && typeof value === "string" ) {
  5034. uiDialog.resizable( "option", "handles", value );
  5035. }
  5036. // currently non-resizable, becoming resizable
  5037. if ( !isResizable && value !== false ) {
  5038. this._makeResizable();
  5039. }
  5040. }
  5041. if ( key === "title" ) {
  5042. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  5043. }
  5044. },
  5045. _size: function() {
  5046. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  5047. // divs will both have width and height set, so we need to reset them
  5048. var nonContentHeight, minContentHeight, maxContentHeight,
  5049. options = this.options;
  5050. // Reset content sizing
  5051. this.element.show().css({
  5052. width: "auto",
  5053. minHeight: 0,
  5054. maxHeight: "none",
  5055. height: 0
  5056. });
  5057. if ( options.minWidth > options.width ) {
  5058. options.width = options.minWidth;
  5059. }
  5060. // reset wrapper sizing
  5061. // determine the height of all the non-content elements
  5062. nonContentHeight = this.uiDialog.css({
  5063. height: "auto",
  5064. width: options.width
  5065. })
  5066. .outerHeight();
  5067. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  5068. maxContentHeight = typeof options.maxHeight === "number" ?
  5069. Math.max( 0, options.maxHeight - nonContentHeight ) :
  5070. "none";
  5071. if ( options.height === "auto" ) {
  5072. this.element.css({
  5073. minHeight: minContentHeight,
  5074. maxHeight: maxContentHeight,
  5075. height: "auto"
  5076. });
  5077. } else {
  5078. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  5079. }
  5080. if (this.uiDialog.is(":data(ui-resizable)") ) {
  5081. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  5082. }
  5083. },
  5084. _blockFrames: function() {
  5085. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  5086. var iframe = $( this );
  5087. return $( "<div>" )
  5088. .css({
  5089. position: "absolute",
  5090. width: iframe.outerWidth(),
  5091. height: iframe.outerHeight()
  5092. })
  5093. .appendTo( iframe.parent() )
  5094. .offset( iframe.offset() )[0];
  5095. });
  5096. },
  5097. _unblockFrames: function() {
  5098. if ( this.iframeBlocks ) {
  5099. this.iframeBlocks.remove();
  5100. delete this.iframeBlocks;
  5101. }
  5102. },
  5103. _allowInteraction: function( event ) {
  5104. if ( $( event.target ).closest(".ui-dialog").length ) {
  5105. return true;
  5106. }
  5107. // TODO: Remove hack when datepicker implements
  5108. // the .ui-front logic (#8989)
  5109. return !!$( event.target ).closest(".ui-datepicker").length;
  5110. },
  5111. _createOverlay: function() {
  5112. if ( !this.options.modal ) {
  5113. return;
  5114. }
  5115. var that = this,
  5116. widgetFullName = this.widgetFullName;
  5117. if ( !$.ui.dialog.overlayInstances ) {
  5118. // Prevent use of anchors and inputs.
  5119. // We use a delay in case the overlay is created from an
  5120. // event that we're going to be cancelling. (#2804)
  5121. this._delay(function() {
  5122. // Handle .dialog().dialog("close") (#4065)
  5123. if ( $.ui.dialog.overlayInstances ) {
  5124. this.document.bind( "focusin.dialog", function( event ) {
  5125. if ( !that._allowInteraction( event ) ) {
  5126. event.preventDefault();
  5127. $(".ui-dialog:visible:last .ui-dialog-content")
  5128. .data( widgetFullName )._focusTabbable();
  5129. }
  5130. });
  5131. }
  5132. });
  5133. }
  5134. this.overlay = $("<div>")
  5135. .addClass("ui-widget-overlay ui-front")
  5136. .appendTo( this._appendTo() );
  5137. this._on( this.overlay, {
  5138. mousedown: "_keepFocus"
  5139. });
  5140. $.ui.dialog.overlayInstances++;
  5141. },
  5142. _destroyOverlay: function() {
  5143. if ( !this.options.modal ) {
  5144. return;
  5145. }
  5146. if ( this.overlay ) {
  5147. $.ui.dialog.overlayInstances--;
  5148. if ( !$.ui.dialog.overlayInstances ) {
  5149. this.document.unbind( "focusin.dialog" );
  5150. }
  5151. this.overlay.remove();
  5152. this.overlay = null;
  5153. }
  5154. }
  5155. });
  5156. $.ui.dialog.overlayInstances = 0;
  5157. // DEPRECATED
  5158. if ( $.uiBackCompat !== false ) {
  5159. // position option with array notation
  5160. // just override with old implementation
  5161. $.widget( "ui.dialog", $.ui.dialog, {
  5162. _position: function() {
  5163. var position = this.options.position,
  5164. myAt = [],
  5165. offset = [ 0, 0 ],
  5166. isVisible;
  5167. if ( position ) {
  5168. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  5169. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  5170. if ( myAt.length === 1 ) {
  5171. myAt[1] = myAt[0];
  5172. }
  5173. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  5174. if ( +myAt[ i ] === myAt[ i ] ) {
  5175. offset[ i ] = myAt[ i ];
  5176. myAt[ i ] = offsetPosition;
  5177. }
  5178. });
  5179. position = {
  5180. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  5181. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  5182. at: myAt.join(" ")
  5183. };
  5184. }
  5185. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  5186. } else {
  5187. position = $.ui.dialog.prototype.options.position;
  5188. }
  5189. // need to show the dialog to get the actual offset in the position plugin
  5190. isVisible = this.uiDialog.is(":visible");
  5191. if ( !isVisible ) {
  5192. this.uiDialog.show();
  5193. }
  5194. this.uiDialog.position( position );
  5195. if ( !isVisible ) {
  5196. this.uiDialog.hide();
  5197. }
  5198. }
  5199. });
  5200. }
  5201. }( jQuery ) );
  5202. (function( $, undefined ) {
  5203. $.widget("ui.draggable", $.ui.mouse, {
  5204. version: "1.10.4",
  5205. widgetEventPrefix: "drag",
  5206. options: {
  5207. addClasses: true,
  5208. appendTo: "parent",
  5209. axis: false,
  5210. connectToSortable: false,
  5211. containment: false,
  5212. cursor: "auto",
  5213. cursorAt: false,
  5214. grid: false,
  5215. handle: false,
  5216. helper: "original",
  5217. iframeFix: false,
  5218. opacity: false,
  5219. refreshPositions: false,
  5220. revert: false,
  5221. revertDuration: 500,
  5222. scope: "default",
  5223. scroll: true,
  5224. scrollSensitivity: 20,
  5225. scrollSpeed: 20,
  5226. snap: false,
  5227. snapMode: "both",
  5228. snapTolerance: 20,
  5229. stack: false,
  5230. zIndex: false,
  5231. // callbacks
  5232. drag: null,
  5233. start: null,
  5234. stop: null
  5235. },
  5236. _create: function() {
  5237. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  5238. this.element[0].style.position = "relative";
  5239. }
  5240. if (this.options.addClasses){
  5241. this.element.addClass("ui-draggable");
  5242. }
  5243. if (this.options.disabled){
  5244. this.element.addClass("ui-draggable-disabled");
  5245. }
  5246. this._mouseInit();
  5247. },
  5248. _destroy: function() {
  5249. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5250. this._mouseDestroy();
  5251. },
  5252. _mouseCapture: function(event) {
  5253. var o = this.options;
  5254. // among others, prevent a drag on a resizable-handle
  5255. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  5256. return false;
  5257. }
  5258. //Quit if we're not on a valid handle
  5259. this.handle = this._getHandle(event);
  5260. if (!this.handle) {
  5261. return false;
  5262. }
  5263. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  5264. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  5265. .css({
  5266. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  5267. position: "absolute", opacity: "0.001", zIndex: 1000
  5268. })
  5269. .css($(this).offset())
  5270. .appendTo("body");
  5271. });
  5272. return true;
  5273. },
  5274. _mouseStart: function(event) {
  5275. var o = this.options;
  5276. //Create and append the visible helper
  5277. this.helper = this._createHelper(event);
  5278. this.helper.addClass("ui-draggable-dragging");
  5279. //Cache the helper size
  5280. this._cacheHelperProportions();
  5281. //If ddmanager is used for droppables, set the global draggable
  5282. if($.ui.ddmanager) {
  5283. $.ui.ddmanager.current = this;
  5284. }
  5285. /*
  5286. * - Position generation -
  5287. * This block generates everything position related - it's the core of draggables.
  5288. */
  5289. //Cache the margins of the original element
  5290. this._cacheMargins();
  5291. //Store the helper's css position
  5292. this.cssPosition = this.helper.css( "position" );
  5293. this.scrollParent = this.helper.scrollParent();
  5294. this.offsetParent = this.helper.offsetParent();
  5295. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  5296. //The element's absolute position on the page minus margins
  5297. this.offset = this.positionAbs = this.element.offset();
  5298. this.offset = {
  5299. top: this.offset.top - this.margins.top,
  5300. left: this.offset.left - this.margins.left
  5301. };
  5302. //Reset scroll cache
  5303. this.offset.scroll = false;
  5304. $.extend(this.offset, {
  5305. click: { //Where the click happened, relative to the element
  5306. left: event.pageX - this.offset.left,
  5307. top: event.pageY - this.offset.top
  5308. },
  5309. parent: this._getParentOffset(),
  5310. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  5311. });
  5312. //Generate the original position
  5313. this.originalPosition = this.position = this._generatePosition(event);
  5314. this.originalPageX = event.pageX;
  5315. this.originalPageY = event.pageY;
  5316. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  5317. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5318. //Set a containment if given in the options
  5319. this._setContainment();
  5320. //Trigger event + callbacks
  5321. if(this._trigger("start", event) === false) {
  5322. this._clear();
  5323. return false;
  5324. }
  5325. //Recache the helper size
  5326. this._cacheHelperProportions();
  5327. //Prepare the droppable offsets
  5328. if ($.ui.ddmanager && !o.dropBehaviour) {
  5329. $.ui.ddmanager.prepareOffsets(this, event);
  5330. }
  5331. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5332. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5333. if ( $.ui.ddmanager ) {
  5334. $.ui.ddmanager.dragStart(this, event);
  5335. }
  5336. return true;
  5337. },
  5338. _mouseDrag: function(event, noPropagation) {
  5339. // reset any necessary cached properties (see #5009)
  5340. if ( this.offsetParentCssPosition === "fixed" ) {
  5341. this.offset.parent = this._getParentOffset();
  5342. }
  5343. //Compute the helpers position
  5344. this.position = this._generatePosition(event);
  5345. this.positionAbs = this._convertPositionTo("absolute");
  5346. //Call plugins and callbacks and use the resulting position if something is returned
  5347. if (!noPropagation) {
  5348. var ui = this._uiHash();
  5349. if(this._trigger("drag", event, ui) === false) {
  5350. this._mouseUp({});
  5351. return false;
  5352. }
  5353. this.position = ui.position;
  5354. }
  5355. if(!this.options.axis || this.options.axis !== "y") {
  5356. this.helper[0].style.left = this.position.left+"px";
  5357. }
  5358. if(!this.options.axis || this.options.axis !== "x") {
  5359. this.helper[0].style.top = this.position.top+"px";
  5360. }
  5361. if($.ui.ddmanager) {
  5362. $.ui.ddmanager.drag(this, event);
  5363. }
  5364. return false;
  5365. },
  5366. _mouseStop: function(event) {
  5367. //If we are using droppables, inform the manager about the drop
  5368. var that = this,
  5369. dropped = false;
  5370. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  5371. dropped = $.ui.ddmanager.drop(this, event);
  5372. }
  5373. //if a drop comes from outside (a sortable)
  5374. if(this.dropped) {
  5375. dropped = this.dropped;
  5376. this.dropped = false;
  5377. }
  5378. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  5379. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  5380. return false;
  5381. }
  5382. 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))) {
  5383. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5384. if(that._trigger("stop", event) !== false) {
  5385. that._clear();
  5386. }
  5387. });
  5388. } else {
  5389. if(this._trigger("stop", event) !== false) {
  5390. this._clear();
  5391. }
  5392. }
  5393. return false;
  5394. },
  5395. _mouseUp: function(event) {
  5396. //Remove frame helpers
  5397. $("div.ui-draggable-iframeFix").each(function() {
  5398. this.parentNode.removeChild(this);
  5399. });
  5400. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5401. if( $.ui.ddmanager ) {
  5402. $.ui.ddmanager.dragStop(this, event);
  5403. }
  5404. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5405. },
  5406. cancel: function() {
  5407. if(this.helper.is(".ui-draggable-dragging")) {
  5408. this._mouseUp({});
  5409. } else {
  5410. this._clear();
  5411. }
  5412. return this;
  5413. },
  5414. _getHandle: function(event) {
  5415. return this.options.handle ?
  5416. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  5417. true;
  5418. },
  5419. _createHelper: function(event) {
  5420. var o = this.options,
  5421. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  5422. if(!helper.parents("body").length) {
  5423. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  5424. }
  5425. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  5426. helper.css("position", "absolute");
  5427. }
  5428. return helper;
  5429. },
  5430. _adjustOffsetFromHelper: function(obj) {
  5431. if (typeof obj === "string") {
  5432. obj = obj.split(" ");
  5433. }
  5434. if ($.isArray(obj)) {
  5435. obj = {left: +obj[0], top: +obj[1] || 0};
  5436. }
  5437. if ("left" in obj) {
  5438. this.offset.click.left = obj.left + this.margins.left;
  5439. }
  5440. if ("right" in obj) {
  5441. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5442. }
  5443. if ("top" in obj) {
  5444. this.offset.click.top = obj.top + this.margins.top;
  5445. }
  5446. if ("bottom" in obj) {
  5447. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5448. }
  5449. },
  5450. _getParentOffset: function() {
  5451. //Get the offsetParent and cache its position
  5452. var po = this.offsetParent.offset();
  5453. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5454. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5455. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5456. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5457. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5458. po.left += this.scrollParent.scrollLeft();
  5459. po.top += this.scrollParent.scrollTop();
  5460. }
  5461. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  5462. //Ugly IE fix
  5463. if((this.offsetParent[0] === document.body) ||
  5464. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  5465. po = { top: 0, left: 0 };
  5466. }
  5467. return {
  5468. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  5469. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  5470. };
  5471. },
  5472. _getRelativeOffset: function() {
  5473. if(this.cssPosition === "relative") {
  5474. var p = this.element.position();
  5475. return {
  5476. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  5477. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  5478. };
  5479. } else {
  5480. return { top: 0, left: 0 };
  5481. }
  5482. },
  5483. _cacheMargins: function() {
  5484. this.margins = {
  5485. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  5486. top: (parseInt(this.element.css("marginTop"),10) || 0),
  5487. right: (parseInt(this.element.css("marginRight"),10) || 0),
  5488. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  5489. };
  5490. },
  5491. _cacheHelperProportions: function() {
  5492. this.helperProportions = {
  5493. width: this.helper.outerWidth(),
  5494. height: this.helper.outerHeight()
  5495. };
  5496. },
  5497. _setContainment: function() {
  5498. var over, c, ce,
  5499. o = this.options;
  5500. if ( !o.containment ) {
  5501. this.containment = null;
  5502. return;
  5503. }
  5504. if ( o.containment === "window" ) {
  5505. this.containment = [
  5506. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5507. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5508. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  5509. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5510. ];
  5511. return;
  5512. }
  5513. if ( o.containment === "document") {
  5514. this.containment = [
  5515. 0,
  5516. 0,
  5517. $( document ).width() - this.helperProportions.width - this.margins.left,
  5518. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5519. ];
  5520. return;
  5521. }
  5522. if ( o.containment.constructor === Array ) {
  5523. this.containment = o.containment;
  5524. return;
  5525. }
  5526. if ( o.containment === "parent" ) {
  5527. o.containment = this.helper[ 0 ].parentNode;
  5528. }
  5529. c = $( o.containment );
  5530. ce = c[ 0 ];
  5531. if( !ce ) {
  5532. return;
  5533. }
  5534. over = c.css( "overflow" ) !== "hidden";
  5535. this.containment = [
  5536. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  5537. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  5538. ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
  5539. ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
  5540. ];
  5541. this.relative_container = c;
  5542. },
  5543. _convertPositionTo: function(d, pos) {
  5544. if(!pos) {
  5545. pos = this.position;
  5546. }
  5547. var mod = d === "absolute" ? 1 : -1,
  5548. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  5549. //Cache the scroll
  5550. if (!this.offset.scroll) {
  5551. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  5552. }
  5553. return {
  5554. top: (
  5555. pos.top + // The absolute mouse position
  5556. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5557. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  5558. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  5559. ),
  5560. left: (
  5561. pos.left + // The absolute mouse position
  5562. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5563. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  5564. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  5565. )
  5566. };
  5567. },
  5568. _generatePosition: function(event) {
  5569. var containment, co, top, left,
  5570. o = this.options,
  5571. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  5572. pageX = event.pageX,
  5573. pageY = event.pageY;
  5574. //Cache the scroll
  5575. if (!this.offset.scroll) {
  5576. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  5577. }
  5578. /*
  5579. * - Position constraining -
  5580. * Constrain the position to a mix of grid, containment.
  5581. */
  5582. // If we are not dragging yet, we won't check for options
  5583. if ( this.originalPosition ) {
  5584. if ( this.containment ) {
  5585. if ( this.relative_container ){
  5586. co = this.relative_container.offset();
  5587. containment = [
  5588. this.containment[ 0 ] + co.left,
  5589. this.containment[ 1 ] + co.top,
  5590. this.containment[ 2 ] + co.left,
  5591. this.containment[ 3 ] + co.top
  5592. ];
  5593. }
  5594. else {
  5595. containment = this.containment;
  5596. }
  5597. if(event.pageX - this.offset.click.left < containment[0]) {
  5598. pageX = containment[0] + this.offset.click.left;
  5599. }
  5600. if(event.pageY - this.offset.click.top < containment[1]) {
  5601. pageY = containment[1] + this.offset.click.top;
  5602. }
  5603. if(event.pageX - this.offset.click.left > containment[2]) {
  5604. pageX = containment[2] + this.offset.click.left;
  5605. }
  5606. if(event.pageY - this.offset.click.top > containment[3]) {
  5607. pageY = containment[3] + this.offset.click.top;
  5608. }
  5609. }
  5610. if(o.grid) {
  5611. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5612. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5613. 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;
  5614. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5615. 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;
  5616. }
  5617. }
  5618. return {
  5619. top: (
  5620. pageY - // The absolute mouse position
  5621. this.offset.click.top - // Click offset (relative to the element)
  5622. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  5623. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  5624. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  5625. ),
  5626. left: (
  5627. pageX - // The absolute mouse position
  5628. this.offset.click.left - // Click offset (relative to the element)
  5629. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  5630. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  5631. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  5632. )
  5633. };
  5634. },
  5635. _clear: function() {
  5636. this.helper.removeClass("ui-draggable-dragging");
  5637. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  5638. this.helper.remove();
  5639. }
  5640. this.helper = null;
  5641. this.cancelHelperRemoval = false;
  5642. },
  5643. // From now on bulk stuff - mainly helpers
  5644. _trigger: function(type, event, ui) {
  5645. ui = ui || this._uiHash();
  5646. $.ui.plugin.call(this, type, [event, ui]);
  5647. //The absolute position has to be recalculated after plugins
  5648. if(type === "drag") {
  5649. this.positionAbs = this._convertPositionTo("absolute");
  5650. }
  5651. return $.Widget.prototype._trigger.call(this, type, event, ui);
  5652. },
  5653. plugins: {},
  5654. _uiHash: function() {
  5655. return {
  5656. helper: this.helper,
  5657. position: this.position,
  5658. originalPosition: this.originalPosition,
  5659. offset: this.positionAbs
  5660. };
  5661. }
  5662. });
  5663. $.ui.plugin.add("draggable", "connectToSortable", {
  5664. start: function(event, ui) {
  5665. var inst = $(this).data("ui-draggable"), o = inst.options,
  5666. uiSortable = $.extend({}, ui, { item: inst.element });
  5667. inst.sortables = [];
  5668. $(o.connectToSortable).each(function() {
  5669. var sortable = $.data(this, "ui-sortable");
  5670. if (sortable && !sortable.options.disabled) {
  5671. inst.sortables.push({
  5672. instance: sortable,
  5673. shouldRevert: sortable.options.revert
  5674. });
  5675. sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
  5676. sortable._trigger("activate", event, uiSortable);
  5677. }
  5678. });
  5679. },
  5680. stop: function(event, ui) {
  5681. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  5682. var inst = $(this).data("ui-draggable"),
  5683. uiSortable = $.extend({}, ui, { item: inst.element });
  5684. $.each(inst.sortables, function() {
  5685. if(this.instance.isOver) {
  5686. this.instance.isOver = 0;
  5687. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  5688. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  5689. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  5690. if(this.shouldRevert) {
  5691. this.instance.options.revert = this.shouldRevert;
  5692. }
  5693. //Trigger the stop of the sortable
  5694. this.instance._mouseStop(event);
  5695. this.instance.options.helper = this.instance.options._helper;
  5696. //If the helper has been the original item, restore properties in the sortable
  5697. if(inst.options.helper === "original") {
  5698. this.instance.currentItem.css({ top: "auto", left: "auto" });
  5699. }
  5700. } else {
  5701. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  5702. this.instance._trigger("deactivate", event, uiSortable);
  5703. }
  5704. });
  5705. },
  5706. drag: function(event, ui) {
  5707. var inst = $(this).data("ui-draggable"), that = this;
  5708. $.each(inst.sortables, function() {
  5709. var innermostIntersecting = false,
  5710. thisSortable = this;
  5711. //Copy over some variables to allow calling the sortable's native _intersectsWith
  5712. this.instance.positionAbs = inst.positionAbs;
  5713. this.instance.helperProportions = inst.helperProportions;
  5714. this.instance.offset.click = inst.offset.click;
  5715. if(this.instance._intersectsWith(this.instance.containerCache)) {
  5716. innermostIntersecting = true;
  5717. $.each(inst.sortables, function () {
  5718. this.instance.positionAbs = inst.positionAbs;
  5719. this.instance.helperProportions = inst.helperProportions;
  5720. this.instance.offset.click = inst.offset.click;
  5721. if (this !== thisSortable &&
  5722. this.instance._intersectsWith(this.instance.containerCache) &&
  5723. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  5724. ) {
  5725. innermostIntersecting = false;
  5726. }
  5727. return innermostIntersecting;
  5728. });
  5729. }
  5730. if(innermostIntersecting) {
  5731. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  5732. if(!this.instance.isOver) {
  5733. this.instance.isOver = 1;
  5734. //Now we fake the start of dragging for the sortable instance,
  5735. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  5736. //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
  5737. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  5738. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  5739. this.instance.options.helper = function() { return ui.helper[0]; };
  5740. event.target = this.instance.currentItem[0];
  5741. this.instance._mouseCapture(event, true);
  5742. this.instance._mouseStart(event, true, true);
  5743. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  5744. this.instance.offset.click.top = inst.offset.click.top;
  5745. this.instance.offset.click.left = inst.offset.click.left;
  5746. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  5747. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  5748. inst._trigger("toSortable", event);
  5749. inst.dropped = this.instance.element; //draggable revert needs that
  5750. //hack so receive/update callbacks work (mostly)
  5751. inst.currentItem = inst.element;
  5752. this.instance.fromOutside = inst;
  5753. }
  5754. //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
  5755. if(this.instance.currentItem) {
  5756. this.instance._mouseDrag(event);
  5757. }
  5758. } else {
  5759. //If it doesn't intersect with the sortable, and it intersected before,
  5760. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  5761. if(this.instance.isOver) {
  5762. this.instance.isOver = 0;
  5763. this.instance.cancelHelperRemoval = true;
  5764. //Prevent reverting on this forced stop
  5765. this.instance.options.revert = false;
  5766. // The out event needs to be triggered independently
  5767. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  5768. this.instance._mouseStop(event, true);
  5769. this.instance.options.helper = this.instance.options._helper;
  5770. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  5771. this.instance.currentItem.remove();
  5772. if(this.instance.placeholder) {
  5773. this.instance.placeholder.remove();
  5774. }
  5775. inst._trigger("fromSortable", event);
  5776. inst.dropped = false; //draggable revert needs that
  5777. }
  5778. }
  5779. });
  5780. }
  5781. });
  5782. $.ui.plugin.add("draggable", "cursor", {
  5783. start: function() {
  5784. var t = $("body"), o = $(this).data("ui-draggable").options;
  5785. if (t.css("cursor")) {
  5786. o._cursor = t.css("cursor");
  5787. }
  5788. t.css("cursor", o.cursor);
  5789. },
  5790. stop: function() {
  5791. var o = $(this).data("ui-draggable").options;
  5792. if (o._cursor) {
  5793. $("body").css("cursor", o._cursor);
  5794. }
  5795. }
  5796. });
  5797. $.ui.plugin.add("draggable", "opacity", {
  5798. start: function(event, ui) {
  5799. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  5800. if(t.css("opacity")) {
  5801. o._opacity = t.css("opacity");
  5802. }
  5803. t.css("opacity", o.opacity);
  5804. },
  5805. stop: function(event, ui) {
  5806. var o = $(this).data("ui-draggable").options;
  5807. if(o._opacity) {
  5808. $(ui.helper).css("opacity", o._opacity);
  5809. }
  5810. }
  5811. });
  5812. $.ui.plugin.add("draggable", "scroll", {
  5813. start: function() {
  5814. var i = $(this).data("ui-draggable");
  5815. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  5816. i.overflowOffset = i.scrollParent.offset();
  5817. }
  5818. },
  5819. drag: function( event ) {
  5820. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  5821. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  5822. if(!o.axis || o.axis !== "x") {
  5823. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  5824. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  5825. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  5826. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  5827. }
  5828. }
  5829. if(!o.axis || o.axis !== "y") {
  5830. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  5831. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  5832. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  5833. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  5834. }
  5835. }
  5836. } else {
  5837. if(!o.axis || o.axis !== "x") {
  5838. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  5839. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5840. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  5841. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5842. }
  5843. }
  5844. if(!o.axis || o.axis !== "y") {
  5845. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  5846. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5847. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  5848. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5849. }
  5850. }
  5851. }
  5852. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  5853. $.ui.ddmanager.prepareOffsets(i, event);
  5854. }
  5855. }
  5856. });
  5857. $.ui.plugin.add("draggable", "snap", {
  5858. start: function() {
  5859. var i = $(this).data("ui-draggable"),
  5860. o = i.options;
  5861. i.snapElements = [];
  5862. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  5863. var $t = $(this),
  5864. $o = $t.offset();
  5865. if(this !== i.element[0]) {
  5866. i.snapElements.push({
  5867. item: this,
  5868. width: $t.outerWidth(), height: $t.outerHeight(),
  5869. top: $o.top, left: $o.left
  5870. });
  5871. }
  5872. });
  5873. },
  5874. drag: function(event, ui) {
  5875. var ts, bs, ls, rs, l, r, t, b, i, first,
  5876. inst = $(this).data("ui-draggable"),
  5877. o = inst.options,
  5878. d = o.snapTolerance,
  5879. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  5880. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  5881. for (i = inst.snapElements.length - 1; i >= 0; i--){
  5882. l = inst.snapElements[i].left;
  5883. r = l + inst.snapElements[i].width;
  5884. t = inst.snapElements[i].top;
  5885. b = t + inst.snapElements[i].height;
  5886. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  5887. if(inst.snapElements[i].snapping) {
  5888. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5889. }
  5890. inst.snapElements[i].snapping = false;
  5891. continue;
  5892. }
  5893. if(o.snapMode !== "inner") {
  5894. ts = Math.abs(t - y2) <= d;
  5895. bs = Math.abs(b - y1) <= d;
  5896. ls = Math.abs(l - x2) <= d;
  5897. rs = Math.abs(r - x1) <= d;
  5898. if(ts) {
  5899. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5900. }
  5901. if(bs) {
  5902. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  5903. }
  5904. if(ls) {
  5905. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  5906. }
  5907. if(rs) {
  5908. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  5909. }
  5910. }
  5911. first = (ts || bs || ls || rs);
  5912. if(o.snapMode !== "outer") {
  5913. ts = Math.abs(t - y1) <= d;
  5914. bs = Math.abs(b - y2) <= d;
  5915. ls = Math.abs(l - x1) <= d;
  5916. rs = Math.abs(r - x2) <= d;
  5917. if(ts) {
  5918. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  5919. }
  5920. if(bs) {
  5921. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5922. }
  5923. if(ls) {
  5924. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  5925. }
  5926. if(rs) {
  5927. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  5928. }
  5929. }
  5930. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  5931. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5932. }
  5933. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  5934. }
  5935. }
  5936. });
  5937. $.ui.plugin.add("draggable", "stack", {
  5938. start: function() {
  5939. var min,
  5940. o = this.data("ui-draggable").options,
  5941. group = $.makeArray($(o.stack)).sort(function(a,b) {
  5942. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  5943. });
  5944. if (!group.length) { return; }
  5945. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  5946. $(group).each(function(i) {
  5947. $(this).css("zIndex", min + i);
  5948. });
  5949. this.css("zIndex", (min + group.length));
  5950. }
  5951. });
  5952. $.ui.plugin.add("draggable", "zIndex", {
  5953. start: function(event, ui) {
  5954. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  5955. if(t.css("zIndex")) {
  5956. o._zIndex = t.css("zIndex");
  5957. }
  5958. t.css("zIndex", o.zIndex);
  5959. },
  5960. stop: function(event, ui) {
  5961. var o = $(this).data("ui-draggable").options;
  5962. if(o._zIndex) {
  5963. $(ui.helper).css("zIndex", o._zIndex);
  5964. }
  5965. }
  5966. });
  5967. })(jQuery);
  5968. (function( $, undefined ) {
  5969. function isOverAxis( x, reference, size ) {
  5970. return ( x > reference ) && ( x < ( reference + size ) );
  5971. }
  5972. $.widget("ui.droppable", {
  5973. version: "1.10.4",
  5974. widgetEventPrefix: "drop",
  5975. options: {
  5976. accept: "*",
  5977. activeClass: false,
  5978. addClasses: true,
  5979. greedy: false,
  5980. hoverClass: false,
  5981. scope: "default",
  5982. tolerance: "intersect",
  5983. // callbacks
  5984. activate: null,
  5985. deactivate: null,
  5986. drop: null,
  5987. out: null,
  5988. over: null
  5989. },
  5990. _create: function() {
  5991. var proportions,
  5992. o = this.options,
  5993. accept = o.accept;
  5994. this.isover = false;
  5995. this.isout = true;
  5996. this.accept = $.isFunction(accept) ? accept : function(d) {
  5997. return d.is(accept);
  5998. };
  5999. this.proportions = function( /* valueToWrite */ ) {
  6000. if ( arguments.length ) {
  6001. // Store the droppable's proportions
  6002. proportions = arguments[ 0 ];
  6003. } else {
  6004. // Retrieve or derive the droppable's proportions
  6005. return proportions ?
  6006. proportions :
  6007. proportions = {
  6008. width: this.element[ 0 ].offsetWidth,
  6009. height: this.element[ 0 ].offsetHeight
  6010. };
  6011. }
  6012. };
  6013. // Add the reference and positions to the manager
  6014. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  6015. $.ui.ddmanager.droppables[o.scope].push(this);
  6016. (o.addClasses && this.element.addClass("ui-droppable"));
  6017. },
  6018. _destroy: function() {
  6019. var i = 0,
  6020. drop = $.ui.ddmanager.droppables[this.options.scope];
  6021. for ( ; i < drop.length; i++ ) {
  6022. if ( drop[i] === this ) {
  6023. drop.splice(i, 1);
  6024. }
  6025. }
  6026. this.element.removeClass("ui-droppable ui-droppable-disabled");
  6027. },
  6028. _setOption: function(key, value) {
  6029. if(key === "accept") {
  6030. this.accept = $.isFunction(value) ? value : function(d) {
  6031. return d.is(value);
  6032. };
  6033. }
  6034. $.Widget.prototype._setOption.apply(this, arguments);
  6035. },
  6036. _activate: function(event) {
  6037. var draggable = $.ui.ddmanager.current;
  6038. if(this.options.activeClass) {
  6039. this.element.addClass(this.options.activeClass);
  6040. }
  6041. if(draggable){
  6042. this._trigger("activate", event, this.ui(draggable));
  6043. }
  6044. },
  6045. _deactivate: function(event) {
  6046. var draggable = $.ui.ddmanager.current;
  6047. if(this.options.activeClass) {
  6048. this.element.removeClass(this.options.activeClass);
  6049. }
  6050. if(draggable){
  6051. this._trigger("deactivate", event, this.ui(draggable));
  6052. }
  6053. },
  6054. _over: function(event) {
  6055. var draggable = $.ui.ddmanager.current;
  6056. // Bail if draggable and droppable are same element
  6057. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  6058. return;
  6059. }
  6060. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6061. if(this.options.hoverClass) {
  6062. this.element.addClass(this.options.hoverClass);
  6063. }
  6064. this._trigger("over", event, this.ui(draggable));
  6065. }
  6066. },
  6067. _out: function(event) {
  6068. var draggable = $.ui.ddmanager.current;
  6069. // Bail if draggable and droppable are same element
  6070. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  6071. return;
  6072. }
  6073. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6074. if(this.options.hoverClass) {
  6075. this.element.removeClass(this.options.hoverClass);
  6076. }
  6077. this._trigger("out", event, this.ui(draggable));
  6078. }
  6079. },
  6080. _drop: function(event,custom) {
  6081. var draggable = custom || $.ui.ddmanager.current,
  6082. childrenIntersection = false;
  6083. // Bail if draggable and droppable are same element
  6084. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  6085. return false;
  6086. }
  6087. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  6088. var inst = $.data(this, "ui-droppable");
  6089. if(
  6090. inst.options.greedy &&
  6091. !inst.options.disabled &&
  6092. inst.options.scope === draggable.options.scope &&
  6093. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  6094. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  6095. ) { childrenIntersection = true; return false; }
  6096. });
  6097. if(childrenIntersection) {
  6098. return false;
  6099. }
  6100. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6101. if(this.options.activeClass) {
  6102. this.element.removeClass(this.options.activeClass);
  6103. }
  6104. if(this.options.hoverClass) {
  6105. this.element.removeClass(this.options.hoverClass);
  6106. }
  6107. this._trigger("drop", event, this.ui(draggable));
  6108. return this.element;
  6109. }
  6110. return false;
  6111. },
  6112. ui: function(c) {
  6113. return {
  6114. draggable: (c.currentItem || c.element),
  6115. helper: c.helper,
  6116. position: c.position,
  6117. offset: c.positionAbs
  6118. };
  6119. }
  6120. });
  6121. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  6122. if (!droppable.offset) {
  6123. return false;
  6124. }
  6125. var draggableLeft, draggableTop,
  6126. x1 = (draggable.positionAbs || draggable.position.absolute).left,
  6127. y1 = (draggable.positionAbs || draggable.position.absolute).top,
  6128. x2 = x1 + draggable.helperProportions.width,
  6129. y2 = y1 + draggable.helperProportions.height,
  6130. l = droppable.offset.left,
  6131. t = droppable.offset.top,
  6132. r = l + droppable.proportions().width,
  6133. b = t + droppable.proportions().height;
  6134. switch (toleranceMode) {
  6135. case "fit":
  6136. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  6137. case "intersect":
  6138. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  6139. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  6140. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  6141. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  6142. case "pointer":
  6143. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  6144. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  6145. return isOverAxis( draggableTop, t, droppable.proportions().height ) && isOverAxis( draggableLeft, l, droppable.proportions().width );
  6146. case "touch":
  6147. return (
  6148. (y1 >= t && y1 <= b) || // Top edge touching
  6149. (y2 >= t && y2 <= b) || // Bottom edge touching
  6150. (y1 < t && y2 > b) // Surrounded vertically
  6151. ) && (
  6152. (x1 >= l && x1 <= r) || // Left edge touching
  6153. (x2 >= l && x2 <= r) || // Right edge touching
  6154. (x1 < l && x2 > r) // Surrounded horizontally
  6155. );
  6156. default:
  6157. return false;
  6158. }
  6159. };
  6160. /*
  6161. This manager tracks offsets of draggables and droppables
  6162. */
  6163. $.ui.ddmanager = {
  6164. current: null,
  6165. droppables: { "default": [] },
  6166. prepareOffsets: function(t, event) {
  6167. var i, j,
  6168. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  6169. type = event ? event.type : null, // workaround for #2317
  6170. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  6171. droppablesLoop: for (i = 0; i < m.length; i++) {
  6172. //No disabled and non-accepted
  6173. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  6174. continue;
  6175. }
  6176. // Filter out elements in the current dragged item
  6177. for (j=0; j < list.length; j++) {
  6178. if(list[j] === m[i].element[0]) {
  6179. m[i].proportions().height = 0;
  6180. continue droppablesLoop;
  6181. }
  6182. }
  6183. m[i].visible = m[i].element.css("display") !== "none";
  6184. if(!m[i].visible) {
  6185. continue;
  6186. }
  6187. //Activate the droppable if used directly from draggables
  6188. if(type === "mousedown") {
  6189. m[i]._activate.call(m[i], event);
  6190. }
  6191. m[ i ].offset = m[ i ].element.offset();
  6192. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  6193. }
  6194. },
  6195. drop: function(draggable, event) {
  6196. var dropped = false;
  6197. // Create a copy of the droppables in case the list changes during the drop (#9116)
  6198. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  6199. if(!this.options) {
  6200. return;
  6201. }
  6202. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  6203. dropped = this._drop.call(this, event) || dropped;
  6204. }
  6205. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6206. this.isout = true;
  6207. this.isover = false;
  6208. this._deactivate.call(this, event);
  6209. }
  6210. });
  6211. return dropped;
  6212. },
  6213. dragStart: function( draggable, event ) {
  6214. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  6215. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  6216. if( !draggable.options.refreshPositions ) {
  6217. $.ui.ddmanager.prepareOffsets( draggable, event );
  6218. }
  6219. });
  6220. },
  6221. drag: function(draggable, event) {
  6222. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  6223. if(draggable.options.refreshPositions) {
  6224. $.ui.ddmanager.prepareOffsets(draggable, event);
  6225. }
  6226. //Run through all droppables and check their positions based on specific tolerance options
  6227. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  6228. if(this.options.disabled || this.greedyChild || !this.visible) {
  6229. return;
  6230. }
  6231. var parentInstance, scope, parent,
  6232. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  6233. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  6234. if(!c) {
  6235. return;
  6236. }
  6237. if (this.options.greedy) {
  6238. // find droppable parents with same scope
  6239. scope = this.options.scope;
  6240. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  6241. return $.data(this, "ui-droppable").options.scope === scope;
  6242. });
  6243. if (parent.length) {
  6244. parentInstance = $.data(parent[0], "ui-droppable");
  6245. parentInstance.greedyChild = (c === "isover");
  6246. }
  6247. }
  6248. // we just moved into a greedy child
  6249. if (parentInstance && c === "isover") {
  6250. parentInstance.isover = false;
  6251. parentInstance.isout = true;
  6252. parentInstance._out.call(parentInstance, event);
  6253. }
  6254. this[c] = true;
  6255. this[c === "isout" ? "isover" : "isout"] = false;
  6256. this[c === "isover" ? "_over" : "_out"].call(this, event);
  6257. // we just moved out of a greedy child
  6258. if (parentInstance && c === "isout") {
  6259. parentInstance.isout = false;
  6260. parentInstance.isover = true;
  6261. parentInstance._over.call(parentInstance, event);
  6262. }
  6263. });
  6264. },
  6265. dragStop: function( draggable, event ) {
  6266. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  6267. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  6268. if( !draggable.options.refreshPositions ) {
  6269. $.ui.ddmanager.prepareOffsets( draggable, event );
  6270. }
  6271. }
  6272. };
  6273. })(jQuery);
  6274. (function($, undefined) {
  6275. var dataSpace = "ui-effects-";
  6276. $.effects = {
  6277. effect: {}
  6278. };
  6279. /*!
  6280. * jQuery Color Animations v2.1.2
  6281. * https://github.com/jquery/jquery-color
  6282. *
  6283. * Copyright 2013 jQuery Foundation and other contributors
  6284. * Released under the MIT license.
  6285. * http://jquery.org/license
  6286. *
  6287. * Date: Wed Jan 16 08:47:09 2013 -0600
  6288. */
  6289. (function( jQuery, undefined ) {
  6290. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  6291. // plusequals test for += 100 -= 100
  6292. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  6293. // a set of RE's that can match strings and generate color tuples.
  6294. stringParsers = [{
  6295. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  6296. parse: function( execResult ) {
  6297. return [
  6298. execResult[ 1 ],
  6299. execResult[ 2 ],
  6300. execResult[ 3 ],
  6301. execResult[ 4 ]
  6302. ];
  6303. }
  6304. }, {
  6305. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  6306. parse: function( execResult ) {
  6307. return [
  6308. execResult[ 1 ] * 2.55,
  6309. execResult[ 2 ] * 2.55,
  6310. execResult[ 3 ] * 2.55,
  6311. execResult[ 4 ]
  6312. ];
  6313. }
  6314. }, {
  6315. // this regex ignores A-F because it's compared against an already lowercased string
  6316. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  6317. parse: function( execResult ) {
  6318. return [
  6319. parseInt( execResult[ 1 ], 16 ),
  6320. parseInt( execResult[ 2 ], 16 ),
  6321. parseInt( execResult[ 3 ], 16 )
  6322. ];
  6323. }
  6324. }, {
  6325. // this regex ignores A-F because it's compared against an already lowercased string
  6326. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  6327. parse: function( execResult ) {
  6328. return [
  6329. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  6330. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  6331. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  6332. ];
  6333. }
  6334. }, {
  6335. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  6336. space: "hsla",
  6337. parse: function( execResult ) {
  6338. return [
  6339. execResult[ 1 ],
  6340. execResult[ 2 ] / 100,
  6341. execResult[ 3 ] / 100,
  6342. execResult[ 4 ]
  6343. ];
  6344. }
  6345. }],
  6346. // jQuery.Color( )
  6347. color = jQuery.Color = function( color, green, blue, alpha ) {
  6348. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  6349. },
  6350. spaces = {
  6351. rgba: {
  6352. props: {
  6353. red: {
  6354. idx: 0,
  6355. type: "byte"
  6356. },
  6357. green: {
  6358. idx: 1,
  6359. type: "byte"
  6360. },
  6361. blue: {
  6362. idx: 2,
  6363. type: "byte"
  6364. }
  6365. }
  6366. },
  6367. hsla: {
  6368. props: {
  6369. hue: {
  6370. idx: 0,
  6371. type: "degrees"
  6372. },
  6373. saturation: {
  6374. idx: 1,
  6375. type: "percent"
  6376. },
  6377. lightness: {
  6378. idx: 2,
  6379. type: "percent"
  6380. }
  6381. }
  6382. }
  6383. },
  6384. propTypes = {
  6385. "byte": {
  6386. floor: true,
  6387. max: 255
  6388. },
  6389. "percent": {
  6390. max: 1
  6391. },
  6392. "degrees": {
  6393. mod: 360,
  6394. floor: true
  6395. }
  6396. },
  6397. support = color.support = {},
  6398. // element for support tests
  6399. supportElem = jQuery( "<p>" )[ 0 ],
  6400. // colors = jQuery.Color.names
  6401. colors,
  6402. // local aliases of functions called often
  6403. each = jQuery.each;
  6404. // determine rgba support immediately
  6405. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  6406. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  6407. // define cache name and alpha properties
  6408. // for rgba and hsla spaces
  6409. each( spaces, function( spaceName, space ) {
  6410. space.cache = "_" + spaceName;
  6411. space.props.alpha = {
  6412. idx: 3,
  6413. type: "percent",
  6414. def: 1
  6415. };
  6416. });
  6417. function clamp( value, prop, allowEmpty ) {
  6418. var type = propTypes[ prop.type ] || {};
  6419. if ( value == null ) {
  6420. return (allowEmpty || !prop.def) ? null : prop.def;
  6421. }
  6422. // ~~ is an short way of doing floor for positive numbers
  6423. value = type.floor ? ~~value : parseFloat( value );
  6424. // IE will pass in empty strings as value for alpha,
  6425. // which will hit this case
  6426. if ( isNaN( value ) ) {
  6427. return prop.def;
  6428. }
  6429. if ( type.mod ) {
  6430. // we add mod before modding to make sure that negatives values
  6431. // get converted properly: -10 -> 350
  6432. return (value + type.mod) % type.mod;
  6433. }
  6434. // for now all property types without mod have min and max
  6435. return 0 > value ? 0 : type.max < value ? type.max : value;
  6436. }
  6437. function stringParse( string ) {
  6438. var inst = color(),
  6439. rgba = inst._rgba = [];
  6440. string = string.toLowerCase();
  6441. each( stringParsers, function( i, parser ) {
  6442. var parsed,
  6443. match = parser.re.exec( string ),
  6444. values = match && parser.parse( match ),
  6445. spaceName = parser.space || "rgba";
  6446. if ( values ) {
  6447. parsed = inst[ spaceName ]( values );
  6448. // if this was an rgba parse the assignment might happen twice
  6449. // oh well....
  6450. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  6451. rgba = inst._rgba = parsed._rgba;
  6452. // exit each( stringParsers ) here because we matched
  6453. return false;
  6454. }
  6455. });
  6456. // Found a stringParser that handled it
  6457. if ( rgba.length ) {
  6458. // if this came from a parsed string, force "transparent" when alpha is 0
  6459. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  6460. if ( rgba.join() === "0,0,0,0" ) {
  6461. jQuery.extend( rgba, colors.transparent );
  6462. }
  6463. return inst;
  6464. }
  6465. // named colors
  6466. return colors[ string ];
  6467. }
  6468. color.fn = jQuery.extend( color.prototype, {
  6469. parse: function( red, green, blue, alpha ) {
  6470. if ( red === undefined ) {
  6471. this._rgba = [ null, null, null, null ];
  6472. return this;
  6473. }
  6474. if ( red.jquery || red.nodeType ) {
  6475. red = jQuery( red ).css( green );
  6476. green = undefined;
  6477. }
  6478. var inst = this,
  6479. type = jQuery.type( red ),
  6480. rgba = this._rgba = [];
  6481. // more than 1 argument specified - assume ( red, green, blue, alpha )
  6482. if ( green !== undefined ) {
  6483. red = [ red, green, blue, alpha ];
  6484. type = "array";
  6485. }
  6486. if ( type === "string" ) {
  6487. return this.parse( stringParse( red ) || colors._default );
  6488. }
  6489. if ( type === "array" ) {
  6490. each( spaces.rgba.props, function( key, prop ) {
  6491. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  6492. });
  6493. return this;
  6494. }
  6495. if ( type === "object" ) {
  6496. if ( red instanceof color ) {
  6497. each( spaces, function( spaceName, space ) {
  6498. if ( red[ space.cache ] ) {
  6499. inst[ space.cache ] = red[ space.cache ].slice();
  6500. }
  6501. });
  6502. } else {
  6503. each( spaces, function( spaceName, space ) {
  6504. var cache = space.cache;
  6505. each( space.props, function( key, prop ) {
  6506. // if the cache doesn't exist, and we know how to convert
  6507. if ( !inst[ cache ] && space.to ) {
  6508. // if the value was null, we don't need to copy it
  6509. // if the key was alpha, we don't need to copy it either
  6510. if ( key === "alpha" || red[ key ] == null ) {
  6511. return;
  6512. }
  6513. inst[ cache ] = space.to( inst._rgba );
  6514. }
  6515. // this is the only case where we allow nulls for ALL properties.
  6516. // call clamp with alwaysAllowEmpty
  6517. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  6518. });
  6519. // everything defined but alpha?
  6520. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  6521. // use the default of 1
  6522. inst[ cache ][ 3 ] = 1;
  6523. if ( space.from ) {
  6524. inst._rgba = space.from( inst[ cache ] );
  6525. }
  6526. }
  6527. });
  6528. }
  6529. return this;
  6530. }
  6531. },
  6532. is: function( compare ) {
  6533. var is = color( compare ),
  6534. same = true,
  6535. inst = this;
  6536. each( spaces, function( _, space ) {
  6537. var localCache,
  6538. isCache = is[ space.cache ];
  6539. if (isCache) {
  6540. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  6541. each( space.props, function( _, prop ) {
  6542. if ( isCache[ prop.idx ] != null ) {
  6543. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  6544. return same;
  6545. }
  6546. });
  6547. }
  6548. return same;
  6549. });
  6550. return same;
  6551. },
  6552. _space: function() {
  6553. var used = [],
  6554. inst = this;
  6555. each( spaces, function( spaceName, space ) {
  6556. if ( inst[ space.cache ] ) {
  6557. used.push( spaceName );
  6558. }
  6559. });
  6560. return used.pop();
  6561. },
  6562. transition: function( other, distance ) {
  6563. var end = color( other ),
  6564. spaceName = end._space(),
  6565. space = spaces[ spaceName ],
  6566. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  6567. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  6568. result = start.slice();
  6569. end = end[ space.cache ];
  6570. each( space.props, function( key, prop ) {
  6571. var index = prop.idx,
  6572. startValue = start[ index ],
  6573. endValue = end[ index ],
  6574. type = propTypes[ prop.type ] || {};
  6575. // if null, don't override start value
  6576. if ( endValue === null ) {
  6577. return;
  6578. }
  6579. // if null - use end
  6580. if ( startValue === null ) {
  6581. result[ index ] = endValue;
  6582. } else {
  6583. if ( type.mod ) {
  6584. if ( endValue - startValue > type.mod / 2 ) {
  6585. startValue += type.mod;
  6586. } else if ( startValue - endValue > type.mod / 2 ) {
  6587. startValue -= type.mod;
  6588. }
  6589. }
  6590. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  6591. }
  6592. });
  6593. return this[ spaceName ]( result );
  6594. },
  6595. blend: function( opaque ) {
  6596. // if we are already opaque - return ourself
  6597. if ( this._rgba[ 3 ] === 1 ) {
  6598. return this;
  6599. }
  6600. var rgb = this._rgba.slice(),
  6601. a = rgb.pop(),
  6602. blend = color( opaque )._rgba;
  6603. return color( jQuery.map( rgb, function( v, i ) {
  6604. return ( 1 - a ) * blend[ i ] + a * v;
  6605. }));
  6606. },
  6607. toRgbaString: function() {
  6608. var prefix = "rgba(",
  6609. rgba = jQuery.map( this._rgba, function( v, i ) {
  6610. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  6611. });
  6612. if ( rgba[ 3 ] === 1 ) {
  6613. rgba.pop();
  6614. prefix = "rgb(";
  6615. }
  6616. return prefix + rgba.join() + ")";
  6617. },
  6618. toHslaString: function() {
  6619. var prefix = "hsla(",
  6620. hsla = jQuery.map( this.hsla(), function( v, i ) {
  6621. if ( v == null ) {
  6622. v = i > 2 ? 1 : 0;
  6623. }
  6624. // catch 1 and 2
  6625. if ( i && i < 3 ) {
  6626. v = Math.round( v * 100 ) + "%";
  6627. }
  6628. return v;
  6629. });
  6630. if ( hsla[ 3 ] === 1 ) {
  6631. hsla.pop();
  6632. prefix = "hsl(";
  6633. }
  6634. return prefix + hsla.join() + ")";
  6635. },
  6636. toHexString: function( includeAlpha ) {
  6637. var rgba = this._rgba.slice(),
  6638. alpha = rgba.pop();
  6639. if ( includeAlpha ) {
  6640. rgba.push( ~~( alpha * 255 ) );
  6641. }
  6642. return "#" + jQuery.map( rgba, function( v ) {
  6643. // default to 0 when nulls exist
  6644. v = ( v || 0 ).toString( 16 );
  6645. return v.length === 1 ? "0" + v : v;
  6646. }).join("");
  6647. },
  6648. toString: function() {
  6649. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  6650. }
  6651. });
  6652. color.fn.parse.prototype = color.fn;
  6653. // hsla conversions adapted from:
  6654. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  6655. function hue2rgb( p, q, h ) {
  6656. h = ( h + 1 ) % 1;
  6657. if ( h * 6 < 1 ) {
  6658. return p + (q - p) * h * 6;
  6659. }
  6660. if ( h * 2 < 1) {
  6661. return q;
  6662. }
  6663. if ( h * 3 < 2 ) {
  6664. return p + (q - p) * ((2/3) - h) * 6;
  6665. }
  6666. return p;
  6667. }
  6668. spaces.hsla.to = function ( rgba ) {
  6669. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  6670. return [ null, null, null, rgba[ 3 ] ];
  6671. }
  6672. var r = rgba[ 0 ] / 255,
  6673. g = rgba[ 1 ] / 255,
  6674. b = rgba[ 2 ] / 255,
  6675. a = rgba[ 3 ],
  6676. max = Math.max( r, g, b ),
  6677. min = Math.min( r, g, b ),
  6678. diff = max - min,
  6679. add = max + min,
  6680. l = add * 0.5,
  6681. h, s;
  6682. if ( min === max ) {
  6683. h = 0;
  6684. } else if ( r === max ) {
  6685. h = ( 60 * ( g - b ) / diff ) + 360;
  6686. } else if ( g === max ) {
  6687. h = ( 60 * ( b - r ) / diff ) + 120;
  6688. } else {
  6689. h = ( 60 * ( r - g ) / diff ) + 240;
  6690. }
  6691. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  6692. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  6693. if ( diff === 0 ) {
  6694. s = 0;
  6695. } else if ( l <= 0.5 ) {
  6696. s = diff / add;
  6697. } else {
  6698. s = diff / ( 2 - add );
  6699. }
  6700. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  6701. };
  6702. spaces.hsla.from = function ( hsla ) {
  6703. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  6704. return [ null, null, null, hsla[ 3 ] ];
  6705. }
  6706. var h = hsla[ 0 ] / 360,
  6707. s = hsla[ 1 ],
  6708. l = hsla[ 2 ],
  6709. a = hsla[ 3 ],
  6710. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  6711. p = 2 * l - q;
  6712. return [
  6713. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  6714. Math.round( hue2rgb( p, q, h ) * 255 ),
  6715. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  6716. a
  6717. ];
  6718. };
  6719. each( spaces, function( spaceName, space ) {
  6720. var props = space.props,
  6721. cache = space.cache,
  6722. to = space.to,
  6723. from = space.from;
  6724. // makes rgba() and hsla()
  6725. color.fn[ spaceName ] = function( value ) {
  6726. // generate a cache for this space if it doesn't exist
  6727. if ( to && !this[ cache ] ) {
  6728. this[ cache ] = to( this._rgba );
  6729. }
  6730. if ( value === undefined ) {
  6731. return this[ cache ].slice();
  6732. }
  6733. var ret,
  6734. type = jQuery.type( value ),
  6735. arr = ( type === "array" || type === "object" ) ? value : arguments,
  6736. local = this[ cache ].slice();
  6737. each( props, function( key, prop ) {
  6738. var val = arr[ type === "object" ? key : prop.idx ];
  6739. if ( val == null ) {
  6740. val = local[ prop.idx ];
  6741. }
  6742. local[ prop.idx ] = clamp( val, prop );
  6743. });
  6744. if ( from ) {
  6745. ret = color( from( local ) );
  6746. ret[ cache ] = local;
  6747. return ret;
  6748. } else {
  6749. return color( local );
  6750. }
  6751. };
  6752. // makes red() green() blue() alpha() hue() saturation() lightness()
  6753. each( props, function( key, prop ) {
  6754. // alpha is included in more than one space
  6755. if ( color.fn[ key ] ) {
  6756. return;
  6757. }
  6758. color.fn[ key ] = function( value ) {
  6759. var vtype = jQuery.type( value ),
  6760. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  6761. local = this[ fn ](),
  6762. cur = local[ prop.idx ],
  6763. match;
  6764. if ( vtype === "undefined" ) {
  6765. return cur;
  6766. }
  6767. if ( vtype === "function" ) {
  6768. value = value.call( this, cur );
  6769. vtype = jQuery.type( value );
  6770. }
  6771. if ( value == null && prop.empty ) {
  6772. return this;
  6773. }
  6774. if ( vtype === "string" ) {
  6775. match = rplusequals.exec( value );
  6776. if ( match ) {
  6777. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  6778. }
  6779. }
  6780. local[ prop.idx ] = value;
  6781. return this[ fn ]( local );
  6782. };
  6783. });
  6784. });
  6785. // add cssHook and .fx.step function for each named hook.
  6786. // accept a space separated string of properties
  6787. color.hook = function( hook ) {
  6788. var hooks = hook.split( " " );
  6789. each( hooks, function( i, hook ) {
  6790. jQuery.cssHooks[ hook ] = {
  6791. set: function( elem, value ) {
  6792. var parsed, curElem,
  6793. backgroundColor = "";
  6794. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  6795. value = color( parsed || value );
  6796. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  6797. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  6798. while (
  6799. (backgroundColor === "" || backgroundColor === "transparent") &&
  6800. curElem && curElem.style
  6801. ) {
  6802. try {
  6803. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  6804. curElem = curElem.parentNode;
  6805. } catch ( e ) {
  6806. }
  6807. }
  6808. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  6809. backgroundColor :
  6810. "_default" );
  6811. }
  6812. value = value.toRgbaString();
  6813. }
  6814. try {
  6815. elem.style[ hook ] = value;
  6816. } catch( e ) {
  6817. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  6818. }
  6819. }
  6820. };
  6821. jQuery.fx.step[ hook ] = function( fx ) {
  6822. if ( !fx.colorInit ) {
  6823. fx.start = color( fx.elem, hook );
  6824. fx.end = color( fx.end );
  6825. fx.colorInit = true;
  6826. }
  6827. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  6828. };
  6829. });
  6830. };
  6831. color.hook( stepHooks );
  6832. jQuery.cssHooks.borderColor = {
  6833. expand: function( value ) {
  6834. var expanded = {};
  6835. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  6836. expanded[ "border" + part + "Color" ] = value;
  6837. });
  6838. return expanded;
  6839. }
  6840. };
  6841. // Basic color names only.
  6842. // Usage of any of the other color names requires adding yourself or including
  6843. // jquery.color.svg-names.js.
  6844. colors = jQuery.Color.names = {
  6845. // 4.1. Basic color keywords
  6846. aqua: "#00ffff",
  6847. black: "#000000",
  6848. blue: "#0000ff",
  6849. fuchsia: "#ff00ff",
  6850. gray: "#808080",
  6851. green: "#008000",
  6852. lime: "#00ff00",
  6853. maroon: "#800000",
  6854. navy: "#000080",
  6855. olive: "#808000",
  6856. purple: "#800080",
  6857. red: "#ff0000",
  6858. silver: "#c0c0c0",
  6859. teal: "#008080",
  6860. white: "#ffffff",
  6861. yellow: "#ffff00",
  6862. // 4.2.3. "transparent" color keyword
  6863. transparent: [ null, null, null, 0 ],
  6864. _default: "#ffffff"
  6865. };
  6866. })( jQuery );
  6867. /******************************************************************************/
  6868. /****************************** CLASS ANIMATIONS ******************************/
  6869. /******************************************************************************/
  6870. (function() {
  6871. var classAnimationActions = [ "add", "remove", "toggle" ],
  6872. shorthandStyles = {
  6873. border: 1,
  6874. borderBottom: 1,
  6875. borderColor: 1,
  6876. borderLeft: 1,
  6877. borderRight: 1,
  6878. borderTop: 1,
  6879. borderWidth: 1,
  6880. margin: 1,
  6881. padding: 1
  6882. };
  6883. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  6884. $.fx.step[ prop ] = function( fx ) {
  6885. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  6886. jQuery.style( fx.elem, prop, fx.end );
  6887. fx.setAttr = true;
  6888. }
  6889. };
  6890. });
  6891. function getElementStyles( elem ) {
  6892. var key, len,
  6893. style = elem.ownerDocument.defaultView ?
  6894. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  6895. elem.currentStyle,
  6896. styles = {};
  6897. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  6898. len = style.length;
  6899. while ( len-- ) {
  6900. key = style[ len ];
  6901. if ( typeof style[ key ] === "string" ) {
  6902. styles[ $.camelCase( key ) ] = style[ key ];
  6903. }
  6904. }
  6905. // support: Opera, IE <9
  6906. } else {
  6907. for ( key in style ) {
  6908. if ( typeof style[ key ] === "string" ) {
  6909. styles[ key ] = style[ key ];
  6910. }
  6911. }
  6912. }
  6913. return styles;
  6914. }
  6915. function styleDifference( oldStyle, newStyle ) {
  6916. var diff = {},
  6917. name, value;
  6918. for ( name in newStyle ) {
  6919. value = newStyle[ name ];
  6920. if ( oldStyle[ name ] !== value ) {
  6921. if ( !shorthandStyles[ name ] ) {
  6922. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  6923. diff[ name ] = value;
  6924. }
  6925. }
  6926. }
  6927. }
  6928. return diff;
  6929. }
  6930. // support: jQuery <1.8
  6931. if ( !$.fn.addBack ) {
  6932. $.fn.addBack = function( selector ) {
  6933. return this.add( selector == null ?
  6934. this.prevObject : this.prevObject.filter( selector )
  6935. );
  6936. };
  6937. }
  6938. $.effects.animateClass = function( value, duration, easing, callback ) {
  6939. var o = $.speed( duration, easing, callback );
  6940. return this.queue( function() {
  6941. var animated = $( this ),
  6942. baseClass = animated.attr( "class" ) || "",
  6943. applyClassChange,
  6944. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  6945. // map the animated objects to store the original styles.
  6946. allAnimations = allAnimations.map(function() {
  6947. var el = $( this );
  6948. return {
  6949. el: el,
  6950. start: getElementStyles( this )
  6951. };
  6952. });
  6953. // apply class change
  6954. applyClassChange = function() {
  6955. $.each( classAnimationActions, function(i, action) {
  6956. if ( value[ action ] ) {
  6957. animated[ action + "Class" ]( value[ action ] );
  6958. }
  6959. });
  6960. };
  6961. applyClassChange();
  6962. // map all animated objects again - calculate new styles and diff
  6963. allAnimations = allAnimations.map(function() {
  6964. this.end = getElementStyles( this.el[ 0 ] );
  6965. this.diff = styleDifference( this.start, this.end );
  6966. return this;
  6967. });
  6968. // apply original class
  6969. animated.attr( "class", baseClass );
  6970. // map all animated objects again - this time collecting a promise
  6971. allAnimations = allAnimations.map(function() {
  6972. var styleInfo = this,
  6973. dfd = $.Deferred(),
  6974. opts = $.extend({}, o, {
  6975. queue: false,
  6976. complete: function() {
  6977. dfd.resolve( styleInfo );
  6978. }
  6979. });
  6980. this.el.animate( this.diff, opts );
  6981. return dfd.promise();
  6982. });
  6983. // once all animations have completed:
  6984. $.when.apply( $, allAnimations.get() ).done(function() {
  6985. // set the final class
  6986. applyClassChange();
  6987. // for each animated element,
  6988. // clear all css properties that were animated
  6989. $.each( arguments, function() {
  6990. var el = this.el;
  6991. $.each( this.diff, function(key) {
  6992. el.css( key, "" );
  6993. });
  6994. });
  6995. // this is guarnteed to be there if you use jQuery.speed()
  6996. // it also handles dequeuing the next anim...
  6997. o.complete.call( animated[ 0 ] );
  6998. });
  6999. });
  7000. };
  7001. $.fn.extend({
  7002. addClass: (function( orig ) {
  7003. return function( classNames, speed, easing, callback ) {
  7004. return speed ?
  7005. $.effects.animateClass.call( this,
  7006. { add: classNames }, speed, easing, callback ) :
  7007. orig.apply( this, arguments );
  7008. };
  7009. })( $.fn.addClass ),
  7010. removeClass: (function( orig ) {
  7011. return function( classNames, speed, easing, callback ) {
  7012. return arguments.length > 1 ?
  7013. $.effects.animateClass.call( this,
  7014. { remove: classNames }, speed, easing, callback ) :
  7015. orig.apply( this, arguments );
  7016. };
  7017. })( $.fn.removeClass ),
  7018. toggleClass: (function( orig ) {
  7019. return function( classNames, force, speed, easing, callback ) {
  7020. if ( typeof force === "boolean" || force === undefined ) {
  7021. if ( !speed ) {
  7022. // without speed parameter
  7023. return orig.apply( this, arguments );
  7024. } else {
  7025. return $.effects.animateClass.call( this,
  7026. (force ? { add: classNames } : { remove: classNames }),
  7027. speed, easing, callback );
  7028. }
  7029. } else {
  7030. // without force parameter
  7031. return $.effects.animateClass.call( this,
  7032. { toggle: classNames }, force, speed, easing );
  7033. }
  7034. };
  7035. })( $.fn.toggleClass ),
  7036. switchClass: function( remove, add, speed, easing, callback) {
  7037. return $.effects.animateClass.call( this, {
  7038. add: add,
  7039. remove: remove
  7040. }, speed, easing, callback );
  7041. }
  7042. });
  7043. })();
  7044. /******************************************************************************/
  7045. /*********************************** EFFECTS **********************************/
  7046. /******************************************************************************/
  7047. (function() {
  7048. $.extend( $.effects, {
  7049. version: "1.10.4",
  7050. // Saves a set of properties in a data storage
  7051. save: function( element, set ) {
  7052. for( var i=0; i < set.length; i++ ) {
  7053. if ( set[ i ] !== null ) {
  7054. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  7055. }
  7056. }
  7057. },
  7058. // Restores a set of previously saved properties from a data storage
  7059. restore: function( element, set ) {
  7060. var val, i;
  7061. for( i=0; i < set.length; i++ ) {
  7062. if ( set[ i ] !== null ) {
  7063. val = element.data( dataSpace + set[ i ] );
  7064. // support: jQuery 1.6.2
  7065. // http://bugs.jquery.com/ticket/9917
  7066. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  7067. // We can't differentiate between "" and 0 here, so we just assume
  7068. // empty string since it's likely to be a more common value...
  7069. if ( val === undefined ) {
  7070. val = "";
  7071. }
  7072. element.css( set[ i ], val );
  7073. }
  7074. }
  7075. },
  7076. setMode: function( el, mode ) {
  7077. if (mode === "toggle") {
  7078. mode = el.is( ":hidden" ) ? "show" : "hide";
  7079. }
  7080. return mode;
  7081. },
  7082. // Translates a [top,left] array into a baseline value
  7083. // this should be a little more flexible in the future to handle a string & hash
  7084. getBaseline: function( origin, original ) {
  7085. var y, x;
  7086. switch ( origin[ 0 ] ) {
  7087. case "top": y = 0; break;
  7088. case "middle": y = 0.5; break;
  7089. case "bottom": y = 1; break;
  7090. default: y = origin[ 0 ] / original.height;
  7091. }
  7092. switch ( origin[ 1 ] ) {
  7093. case "left": x = 0; break;
  7094. case "center": x = 0.5; break;
  7095. case "right": x = 1; break;
  7096. default: x = origin[ 1 ] / original.width;
  7097. }
  7098. return {
  7099. x: x,
  7100. y: y
  7101. };
  7102. },
  7103. // Wraps the element around a wrapper that copies position properties
  7104. createWrapper: function( element ) {
  7105. // if the element is already wrapped, return it
  7106. if ( element.parent().is( ".ui-effects-wrapper" )) {
  7107. return element.parent();
  7108. }
  7109. // wrap the element
  7110. var props = {
  7111. width: element.outerWidth(true),
  7112. height: element.outerHeight(true),
  7113. "float": element.css( "float" )
  7114. },
  7115. wrapper = $( "<div></div>" )
  7116. .addClass( "ui-effects-wrapper" )
  7117. .css({
  7118. fontSize: "100%",
  7119. background: "transparent",
  7120. border: "none",
  7121. margin: 0,
  7122. padding: 0
  7123. }),
  7124. // Store the size in case width/height are defined in % - Fixes #5245
  7125. size = {
  7126. width: element.width(),
  7127. height: element.height()
  7128. },
  7129. active = document.activeElement;
  7130. // support: Firefox
  7131. // Firefox incorrectly exposes anonymous content
  7132. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  7133. try {
  7134. active.id;
  7135. } catch( e ) {
  7136. active = document.body;
  7137. }
  7138. element.wrap( wrapper );
  7139. // Fixes #7595 - Elements lose focus when wrapped.
  7140. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  7141. $( active ).focus();
  7142. }
  7143. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  7144. // transfer positioning properties to the wrapper
  7145. if ( element.css( "position" ) === "static" ) {
  7146. wrapper.css({ position: "relative" });
  7147. element.css({ position: "relative" });
  7148. } else {
  7149. $.extend( props, {
  7150. position: element.css( "position" ),
  7151. zIndex: element.css( "z-index" )
  7152. });
  7153. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  7154. props[ pos ] = element.css( pos );
  7155. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  7156. props[ pos ] = "auto";
  7157. }
  7158. });
  7159. element.css({
  7160. position: "relative",
  7161. top: 0,
  7162. left: 0,
  7163. right: "auto",
  7164. bottom: "auto"
  7165. });
  7166. }
  7167. element.css(size);
  7168. return wrapper.css( props ).show();
  7169. },
  7170. removeWrapper: function( element ) {
  7171. var active = document.activeElement;
  7172. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  7173. element.parent().replaceWith( element );
  7174. // Fixes #7595 - Elements lose focus when wrapped.
  7175. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  7176. $( active ).focus();
  7177. }
  7178. }
  7179. return element;
  7180. },
  7181. setTransition: function( element, list, factor, value ) {
  7182. value = value || {};
  7183. $.each( list, function( i, x ) {
  7184. var unit = element.cssUnit( x );
  7185. if ( unit[ 0 ] > 0 ) {
  7186. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  7187. }
  7188. });
  7189. return value;
  7190. }
  7191. });
  7192. // return an effect options object for the given parameters:
  7193. function _normalizeArguments( effect, options, speed, callback ) {
  7194. // allow passing all options as the first parameter
  7195. if ( $.isPlainObject( effect ) ) {
  7196. options = effect;
  7197. effect = effect.effect;
  7198. }
  7199. // convert to an object
  7200. effect = { effect: effect };
  7201. // catch (effect, null, ...)
  7202. if ( options == null ) {
  7203. options = {};
  7204. }
  7205. // catch (effect, callback)
  7206. if ( $.isFunction( options ) ) {
  7207. callback = options;
  7208. speed = null;
  7209. options = {};
  7210. }
  7211. // catch (effect, speed, ?)
  7212. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  7213. callback = speed;
  7214. speed = options;
  7215. options = {};
  7216. }
  7217. // catch (effect, options, callback)
  7218. if ( $.isFunction( speed ) ) {
  7219. callback = speed;
  7220. speed = null;
  7221. }
  7222. // add options to effect
  7223. if ( options ) {
  7224. $.extend( effect, options );
  7225. }
  7226. speed = speed || options.duration;
  7227. effect.duration = $.fx.off ? 0 :
  7228. typeof speed === "number" ? speed :
  7229. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  7230. $.fx.speeds._default;
  7231. effect.complete = callback || options.complete;
  7232. return effect;
  7233. }
  7234. function standardAnimationOption( option ) {
  7235. // Valid standard speeds (nothing, number, named speed)
  7236. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  7237. return true;
  7238. }
  7239. // Invalid strings - treat as "normal" speed
  7240. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  7241. return true;
  7242. }
  7243. // Complete callback
  7244. if ( $.isFunction( option ) ) {
  7245. return true;
  7246. }
  7247. // Options hash (but not naming an effect)
  7248. if ( typeof option === "object" && !option.effect ) {
  7249. return true;
  7250. }
  7251. // Didn't match any standard API
  7252. return false;
  7253. }
  7254. $.fn.extend({
  7255. effect: function( /* effect, options, speed, callback */ ) {
  7256. var args = _normalizeArguments.apply( this, arguments ),
  7257. mode = args.mode,
  7258. queue = args.queue,
  7259. effectMethod = $.effects.effect[ args.effect ];
  7260. if ( $.fx.off || !effectMethod ) {
  7261. // delegate to the original method (e.g., .show()) if possible
  7262. if ( mode ) {
  7263. return this[ mode ]( args.duration, args.complete );
  7264. } else {
  7265. return this.each( function() {
  7266. if ( args.complete ) {
  7267. args.complete.call( this );
  7268. }
  7269. });
  7270. }
  7271. }
  7272. function run( next ) {
  7273. var elem = $( this ),
  7274. complete = args.complete,
  7275. mode = args.mode;
  7276. function done() {
  7277. if ( $.isFunction( complete ) ) {
  7278. complete.call( elem[0] );
  7279. }
  7280. if ( $.isFunction( next ) ) {
  7281. next();
  7282. }
  7283. }
  7284. // If the element already has the correct final state, delegate to
  7285. // the core methods so the internal tracking of "olddisplay" works.
  7286. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  7287. elem[ mode ]();
  7288. done();
  7289. } else {
  7290. effectMethod.call( elem[0], args, done );
  7291. }
  7292. }
  7293. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  7294. },
  7295. show: (function( orig ) {
  7296. return function( option ) {
  7297. if ( standardAnimationOption( option ) ) {
  7298. return orig.apply( this, arguments );
  7299. } else {
  7300. var args = _normalizeArguments.apply( this, arguments );
  7301. args.mode = "show";
  7302. return this.effect.call( this, args );
  7303. }
  7304. };
  7305. })( $.fn.show ),
  7306. hide: (function( orig ) {
  7307. return function( option ) {
  7308. if ( standardAnimationOption( option ) ) {
  7309. return orig.apply( this, arguments );
  7310. } else {
  7311. var args = _normalizeArguments.apply( this, arguments );
  7312. args.mode = "hide";
  7313. return this.effect.call( this, args );
  7314. }
  7315. };
  7316. })( $.fn.hide ),
  7317. toggle: (function( orig ) {
  7318. return function( option ) {
  7319. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  7320. return orig.apply( this, arguments );
  7321. } else {
  7322. var args = _normalizeArguments.apply( this, arguments );
  7323. args.mode = "toggle";
  7324. return this.effect.call( this, args );
  7325. }
  7326. };
  7327. })( $.fn.toggle ),
  7328. // helper functions
  7329. cssUnit: function(key) {
  7330. var style = this.css( key ),
  7331. val = [];
  7332. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  7333. if ( style.indexOf( unit ) > 0 ) {
  7334. val = [ parseFloat( style ), unit ];
  7335. }
  7336. });
  7337. return val;
  7338. }
  7339. });
  7340. })();
  7341. /******************************************************************************/
  7342. /*********************************** EASING ***********************************/
  7343. /******************************************************************************/
  7344. (function() {
  7345. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  7346. var baseEasings = {};
  7347. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  7348. baseEasings[ name ] = function( p ) {
  7349. return Math.pow( p, i + 2 );
  7350. };
  7351. });
  7352. $.extend( baseEasings, {
  7353. Sine: function ( p ) {
  7354. return 1 - Math.cos( p * Math.PI / 2 );
  7355. },
  7356. Circ: function ( p ) {
  7357. return 1 - Math.sqrt( 1 - p * p );
  7358. },
  7359. Elastic: function( p ) {
  7360. return p === 0 || p === 1 ? p :
  7361. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  7362. },
  7363. Back: function( p ) {
  7364. return p * p * ( 3 * p - 2 );
  7365. },
  7366. Bounce: function ( p ) {
  7367. var pow2,
  7368. bounce = 4;
  7369. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  7370. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  7371. }
  7372. });
  7373. $.each( baseEasings, function( name, easeIn ) {
  7374. $.easing[ "easeIn" + name ] = easeIn;
  7375. $.easing[ "easeOut" + name ] = function( p ) {
  7376. return 1 - easeIn( 1 - p );
  7377. };
  7378. $.easing[ "easeInOut" + name ] = function( p ) {
  7379. return p < 0.5 ?
  7380. easeIn( p * 2 ) / 2 :
  7381. 1 - easeIn( p * -2 + 2 ) / 2;
  7382. };
  7383. });
  7384. })();
  7385. })(jQuery);
  7386. (function( $, undefined ) {
  7387. var rvertical = /up|down|vertical/,
  7388. rpositivemotion = /up|left|vertical|horizontal/;
  7389. $.effects.effect.blind = function( o, done ) {
  7390. // Create element
  7391. var el = $( this ),
  7392. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7393. mode = $.effects.setMode( el, o.mode || "hide" ),
  7394. direction = o.direction || "up",
  7395. vertical = rvertical.test( direction ),
  7396. ref = vertical ? "height" : "width",
  7397. ref2 = vertical ? "top" : "left",
  7398. motion = rpositivemotion.test( direction ),
  7399. animation = {},
  7400. show = mode === "show",
  7401. wrapper, distance, margin;
  7402. // if already wrapped, the wrapper's properties are my property. #6245
  7403. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  7404. $.effects.save( el.parent(), props );
  7405. } else {
  7406. $.effects.save( el, props );
  7407. }
  7408. el.show();
  7409. wrapper = $.effects.createWrapper( el ).css({
  7410. overflow: "hidden"
  7411. });
  7412. distance = wrapper[ ref ]();
  7413. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  7414. animation[ ref ] = show ? distance : 0;
  7415. if ( !motion ) {
  7416. el
  7417. .css( vertical ? "bottom" : "right", 0 )
  7418. .css( vertical ? "top" : "left", "auto" )
  7419. .css({ position: "absolute" });
  7420. animation[ ref2 ] = show ? margin : distance + margin;
  7421. }
  7422. // start at 0 if we are showing
  7423. if ( show ) {
  7424. wrapper.css( ref, 0 );
  7425. if ( ! motion ) {
  7426. wrapper.css( ref2, margin + distance );
  7427. }
  7428. }
  7429. // Animate
  7430. wrapper.animate( animation, {
  7431. duration: o.duration,
  7432. easing: o.easing,
  7433. queue: false,
  7434. complete: function() {
  7435. if ( mode === "hide" ) {
  7436. el.hide();
  7437. }
  7438. $.effects.restore( el, props );
  7439. $.effects.removeWrapper( el );
  7440. done();
  7441. }
  7442. });
  7443. };
  7444. })(jQuery);
  7445. (function( $, undefined ) {
  7446. $.effects.effect.bounce = function( o, done ) {
  7447. var el = $( this ),
  7448. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7449. // defaults:
  7450. mode = $.effects.setMode( el, o.mode || "effect" ),
  7451. hide = mode === "hide",
  7452. show = mode === "show",
  7453. direction = o.direction || "up",
  7454. distance = o.distance,
  7455. times = o.times || 5,
  7456. // number of internal animations
  7457. anims = times * 2 + ( show || hide ? 1 : 0 ),
  7458. speed = o.duration / anims,
  7459. easing = o.easing,
  7460. // utility:
  7461. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  7462. motion = ( direction === "up" || direction === "left" ),
  7463. i,
  7464. upAnim,
  7465. downAnim,
  7466. // we will need to re-assemble the queue to stack our animations in place
  7467. queue = el.queue(),
  7468. queuelen = queue.length;
  7469. // Avoid touching opacity to prevent clearType and PNG issues in IE
  7470. if ( show || hide ) {
  7471. props.push( "opacity" );
  7472. }
  7473. $.effects.save( el, props );
  7474. el.show();
  7475. $.effects.createWrapper( el ); // Create Wrapper
  7476. // default distance for the BIGGEST bounce is the outer Distance / 3
  7477. if ( !distance ) {
  7478. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  7479. }
  7480. if ( show ) {
  7481. downAnim = { opacity: 1 };
  7482. downAnim[ ref ] = 0;
  7483. // if we are showing, force opacity 0 and set the initial position
  7484. // then do the "first" animation
  7485. el.css( "opacity", 0 )
  7486. .css( ref, motion ? -distance * 2 : distance * 2 )
  7487. .animate( downAnim, speed, easing );
  7488. }
  7489. // start at the smallest distance if we are hiding
  7490. if ( hide ) {
  7491. distance = distance / Math.pow( 2, times - 1 );
  7492. }
  7493. downAnim = {};
  7494. downAnim[ ref ] = 0;
  7495. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  7496. for ( i = 0; i < times; i++ ) {
  7497. upAnim = {};
  7498. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  7499. el.animate( upAnim, speed, easing )
  7500. .animate( downAnim, speed, easing );
  7501. distance = hide ? distance * 2 : distance / 2;
  7502. }
  7503. // Last Bounce when Hiding
  7504. if ( hide ) {
  7505. upAnim = { opacity: 0 };
  7506. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  7507. el.animate( upAnim, speed, easing );
  7508. }
  7509. el.queue(function() {
  7510. if ( hide ) {
  7511. el.hide();
  7512. }
  7513. $.effects.restore( el, props );
  7514. $.effects.removeWrapper( el );
  7515. done();
  7516. });
  7517. // inject all the animations we just queued to be first in line (after "inprogress")
  7518. if ( queuelen > 1) {
  7519. queue.splice.apply( queue,
  7520. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7521. }
  7522. el.dequeue();
  7523. };
  7524. })(jQuery);
  7525. (function( $, undefined ) {
  7526. $.effects.effect.clip = function( o, done ) {
  7527. // Create element
  7528. var el = $( this ),
  7529. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7530. mode = $.effects.setMode( el, o.mode || "hide" ),
  7531. show = mode === "show",
  7532. direction = o.direction || "vertical",
  7533. vert = direction === "vertical",
  7534. size = vert ? "height" : "width",
  7535. position = vert ? "top" : "left",
  7536. animation = {},
  7537. wrapper, animate, distance;
  7538. // Save & Show
  7539. $.effects.save( el, props );
  7540. el.show();
  7541. // Create Wrapper
  7542. wrapper = $.effects.createWrapper( el ).css({
  7543. overflow: "hidden"
  7544. });
  7545. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  7546. distance = animate[ size ]();
  7547. // Shift
  7548. if ( show ) {
  7549. animate.css( size, 0 );
  7550. animate.css( position, distance / 2 );
  7551. }
  7552. // Create Animation Object:
  7553. animation[ size ] = show ? distance : 0;
  7554. animation[ position ] = show ? 0 : distance / 2;
  7555. // Animate
  7556. animate.animate( animation, {
  7557. queue: false,
  7558. duration: o.duration,
  7559. easing: o.easing,
  7560. complete: function() {
  7561. if ( !show ) {
  7562. el.hide();
  7563. }
  7564. $.effects.restore( el, props );
  7565. $.effects.removeWrapper( el );
  7566. done();
  7567. }
  7568. });
  7569. };
  7570. })(jQuery);
  7571. (function( $, undefined ) {
  7572. $.effects.effect.drop = function( o, done ) {
  7573. var el = $( this ),
  7574. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  7575. mode = $.effects.setMode( el, o.mode || "hide" ),
  7576. show = mode === "show",
  7577. direction = o.direction || "left",
  7578. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  7579. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  7580. animation = {
  7581. opacity: show ? 1 : 0
  7582. },
  7583. distance;
  7584. // Adjust
  7585. $.effects.save( el, props );
  7586. el.show();
  7587. $.effects.createWrapper( el );
  7588. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  7589. if ( show ) {
  7590. el
  7591. .css( "opacity", 0 )
  7592. .css( ref, motion === "pos" ? -distance : distance );
  7593. }
  7594. // Animation
  7595. animation[ ref ] = ( show ?
  7596. ( motion === "pos" ? "+=" : "-=" ) :
  7597. ( motion === "pos" ? "-=" : "+=" ) ) +
  7598. distance;
  7599. // Animate
  7600. el.animate( animation, {
  7601. queue: false,
  7602. duration: o.duration,
  7603. easing: o.easing,
  7604. complete: function() {
  7605. if ( mode === "hide" ) {
  7606. el.hide();
  7607. }
  7608. $.effects.restore( el, props );
  7609. $.effects.removeWrapper( el );
  7610. done();
  7611. }
  7612. });
  7613. };
  7614. })(jQuery);
  7615. (function( $, undefined ) {
  7616. $.effects.effect.explode = function( o, done ) {
  7617. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  7618. cells = rows,
  7619. el = $( this ),
  7620. mode = $.effects.setMode( el, o.mode || "hide" ),
  7621. show = mode === "show",
  7622. // show and then visibility:hidden the element before calculating offset
  7623. offset = el.show().css( "visibility", "hidden" ).offset(),
  7624. // width and height of a piece
  7625. width = Math.ceil( el.outerWidth() / cells ),
  7626. height = Math.ceil( el.outerHeight() / rows ),
  7627. pieces = [],
  7628. // loop
  7629. i, j, left, top, mx, my;
  7630. // children animate complete:
  7631. function childComplete() {
  7632. pieces.push( this );
  7633. if ( pieces.length === rows * cells ) {
  7634. animComplete();
  7635. }
  7636. }
  7637. // clone the element for each row and cell.
  7638. for( i = 0; i < rows ; i++ ) { // ===>
  7639. top = offset.top + i * height;
  7640. my = i - ( rows - 1 ) / 2 ;
  7641. for( j = 0; j < cells ; j++ ) { // |||
  7642. left = offset.left + j * width;
  7643. mx = j - ( cells - 1 ) / 2 ;
  7644. // Create a clone of the now hidden main element that will be absolute positioned
  7645. // within a wrapper div off the -left and -top equal to size of our pieces
  7646. el
  7647. .clone()
  7648. .appendTo( "body" )
  7649. .wrap( "<div></div>" )
  7650. .css({
  7651. position: "absolute",
  7652. visibility: "visible",
  7653. left: -j * width,
  7654. top: -i * height
  7655. })
  7656. // select the wrapper - make it overflow: hidden and absolute positioned based on
  7657. // where the original was located +left and +top equal to the size of pieces
  7658. .parent()
  7659. .addClass( "ui-effects-explode" )
  7660. .css({
  7661. position: "absolute",
  7662. overflow: "hidden",
  7663. width: width,
  7664. height: height,
  7665. left: left + ( show ? mx * width : 0 ),
  7666. top: top + ( show ? my * height : 0 ),
  7667. opacity: show ? 0 : 1
  7668. }).animate({
  7669. left: left + ( show ? 0 : mx * width ),
  7670. top: top + ( show ? 0 : my * height ),
  7671. opacity: show ? 1 : 0
  7672. }, o.duration || 500, o.easing, childComplete );
  7673. }
  7674. }
  7675. function animComplete() {
  7676. el.css({
  7677. visibility: "visible"
  7678. });
  7679. $( pieces ).remove();
  7680. if ( !show ) {
  7681. el.hide();
  7682. }
  7683. done();
  7684. }
  7685. };
  7686. })(jQuery);
  7687. (function( $, undefined ) {
  7688. $.effects.effect.fade = function( o, done ) {
  7689. var el = $( this ),
  7690. mode = $.effects.setMode( el, o.mode || "toggle" );
  7691. el.animate({
  7692. opacity: mode
  7693. }, {
  7694. queue: false,
  7695. duration: o.duration,
  7696. easing: o.easing,
  7697. complete: done
  7698. });
  7699. };
  7700. })( jQuery );
  7701. (function( $, undefined ) {
  7702. $.effects.effect.fold = function( o, done ) {
  7703. // Create element
  7704. var el = $( this ),
  7705. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7706. mode = $.effects.setMode( el, o.mode || "hide" ),
  7707. show = mode === "show",
  7708. hide = mode === "hide",
  7709. size = o.size || 15,
  7710. percent = /([0-9]+)%/.exec( size ),
  7711. horizFirst = !!o.horizFirst,
  7712. widthFirst = show !== horizFirst,
  7713. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  7714. duration = o.duration / 2,
  7715. wrapper, distance,
  7716. animation1 = {},
  7717. animation2 = {};
  7718. $.effects.save( el, props );
  7719. el.show();
  7720. // Create Wrapper
  7721. wrapper = $.effects.createWrapper( el ).css({
  7722. overflow: "hidden"
  7723. });
  7724. distance = widthFirst ?
  7725. [ wrapper.width(), wrapper.height() ] :
  7726. [ wrapper.height(), wrapper.width() ];
  7727. if ( percent ) {
  7728. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  7729. }
  7730. if ( show ) {
  7731. wrapper.css( horizFirst ? {
  7732. height: 0,
  7733. width: size
  7734. } : {
  7735. height: size,
  7736. width: 0
  7737. });
  7738. }
  7739. // Animation
  7740. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  7741. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  7742. // Animate
  7743. wrapper
  7744. .animate( animation1, duration, o.easing )
  7745. .animate( animation2, duration, o.easing, function() {
  7746. if ( hide ) {
  7747. el.hide();
  7748. }
  7749. $.effects.restore( el, props );
  7750. $.effects.removeWrapper( el );
  7751. done();
  7752. });
  7753. };
  7754. })(jQuery);
  7755. (function( $, undefined ) {
  7756. $.effects.effect.highlight = function( o, done ) {
  7757. var elem = $( this ),
  7758. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  7759. mode = $.effects.setMode( elem, o.mode || "show" ),
  7760. animation = {
  7761. backgroundColor: elem.css( "backgroundColor" )
  7762. };
  7763. if (mode === "hide") {
  7764. animation.opacity = 0;
  7765. }
  7766. $.effects.save( elem, props );
  7767. elem
  7768. .show()
  7769. .css({
  7770. backgroundImage: "none",
  7771. backgroundColor: o.color || "#ffff99"
  7772. })
  7773. .animate( animation, {
  7774. queue: false,
  7775. duration: o.duration,
  7776. easing: o.easing,
  7777. complete: function() {
  7778. if ( mode === "hide" ) {
  7779. elem.hide();
  7780. }
  7781. $.effects.restore( elem, props );
  7782. done();
  7783. }
  7784. });
  7785. };
  7786. })(jQuery);
  7787. (function( $, undefined ) {
  7788. $.effects.effect.pulsate = function( o, done ) {
  7789. var elem = $( this ),
  7790. mode = $.effects.setMode( elem, o.mode || "show" ),
  7791. show = mode === "show",
  7792. hide = mode === "hide",
  7793. showhide = ( show || mode === "hide" ),
  7794. // showing or hiding leaves of the "last" animation
  7795. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  7796. duration = o.duration / anims,
  7797. animateTo = 0,
  7798. queue = elem.queue(),
  7799. queuelen = queue.length,
  7800. i;
  7801. if ( show || !elem.is(":visible")) {
  7802. elem.css( "opacity", 0 ).show();
  7803. animateTo = 1;
  7804. }
  7805. // anims - 1 opacity "toggles"
  7806. for ( i = 1; i < anims; i++ ) {
  7807. elem.animate({
  7808. opacity: animateTo
  7809. }, duration, o.easing );
  7810. animateTo = 1 - animateTo;
  7811. }
  7812. elem.animate({
  7813. opacity: animateTo
  7814. }, duration, o.easing);
  7815. elem.queue(function() {
  7816. if ( hide ) {
  7817. elem.hide();
  7818. }
  7819. done();
  7820. });
  7821. // We just queued up "anims" animations, we need to put them next in the queue
  7822. if ( queuelen > 1 ) {
  7823. queue.splice.apply( queue,
  7824. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7825. }
  7826. elem.dequeue();
  7827. };
  7828. })(jQuery);
  7829. (function( $, undefined ) {
  7830. $.effects.effect.puff = function( o, done ) {
  7831. var elem = $( this ),
  7832. mode = $.effects.setMode( elem, o.mode || "hide" ),
  7833. hide = mode === "hide",
  7834. percent = parseInt( o.percent, 10 ) || 150,
  7835. factor = percent / 100,
  7836. original = {
  7837. height: elem.height(),
  7838. width: elem.width(),
  7839. outerHeight: elem.outerHeight(),
  7840. outerWidth: elem.outerWidth()
  7841. };
  7842. $.extend( o, {
  7843. effect: "scale",
  7844. queue: false,
  7845. fade: true,
  7846. mode: mode,
  7847. complete: done,
  7848. percent: hide ? percent : 100,
  7849. from: hide ?
  7850. original :
  7851. {
  7852. height: original.height * factor,
  7853. width: original.width * factor,
  7854. outerHeight: original.outerHeight * factor,
  7855. outerWidth: original.outerWidth * factor
  7856. }
  7857. });
  7858. elem.effect( o );
  7859. };
  7860. $.effects.effect.scale = function( o, done ) {
  7861. // Create element
  7862. var el = $( this ),
  7863. options = $.extend( true, {}, o ),
  7864. mode = $.effects.setMode( el, o.mode || "effect" ),
  7865. percent = parseInt( o.percent, 10 ) ||
  7866. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  7867. direction = o.direction || "both",
  7868. origin = o.origin,
  7869. original = {
  7870. height: el.height(),
  7871. width: el.width(),
  7872. outerHeight: el.outerHeight(),
  7873. outerWidth: el.outerWidth()
  7874. },
  7875. factor = {
  7876. y: direction !== "horizontal" ? (percent / 100) : 1,
  7877. x: direction !== "vertical" ? (percent / 100) : 1
  7878. };
  7879. // We are going to pass this effect to the size effect:
  7880. options.effect = "size";
  7881. options.queue = false;
  7882. options.complete = done;
  7883. // Set default origin and restore for show/hide
  7884. if ( mode !== "effect" ) {
  7885. options.origin = origin || ["middle","center"];
  7886. options.restore = true;
  7887. }
  7888. options.from = o.from || ( mode === "show" ? {
  7889. height: 0,
  7890. width: 0,
  7891. outerHeight: 0,
  7892. outerWidth: 0
  7893. } : original );
  7894. options.to = {
  7895. height: original.height * factor.y,
  7896. width: original.width * factor.x,
  7897. outerHeight: original.outerHeight * factor.y,
  7898. outerWidth: original.outerWidth * factor.x
  7899. };
  7900. // Fade option to support puff
  7901. if ( options.fade ) {
  7902. if ( mode === "show" ) {
  7903. options.from.opacity = 0;
  7904. options.to.opacity = 1;
  7905. }
  7906. if ( mode === "hide" ) {
  7907. options.from.opacity = 1;
  7908. options.to.opacity = 0;
  7909. }
  7910. }
  7911. // Animate
  7912. el.effect( options );
  7913. };
  7914. $.effects.effect.size = function( o, done ) {
  7915. // Create element
  7916. var original, baseline, factor,
  7917. el = $( this ),
  7918. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  7919. // Always restore
  7920. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  7921. // Copy for children
  7922. props2 = [ "width", "height", "overflow" ],
  7923. cProps = [ "fontSize" ],
  7924. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  7925. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  7926. // Set options
  7927. mode = $.effects.setMode( el, o.mode || "effect" ),
  7928. restore = o.restore || mode !== "effect",
  7929. scale = o.scale || "both",
  7930. origin = o.origin || [ "middle", "center" ],
  7931. position = el.css( "position" ),
  7932. props = restore ? props0 : props1,
  7933. zero = {
  7934. height: 0,
  7935. width: 0,
  7936. outerHeight: 0,
  7937. outerWidth: 0
  7938. };
  7939. if ( mode === "show" ) {
  7940. el.show();
  7941. }
  7942. original = {
  7943. height: el.height(),
  7944. width: el.width(),
  7945. outerHeight: el.outerHeight(),
  7946. outerWidth: el.outerWidth()
  7947. };
  7948. if ( o.mode === "toggle" && mode === "show" ) {
  7949. el.from = o.to || zero;
  7950. el.to = o.from || original;
  7951. } else {
  7952. el.from = o.from || ( mode === "show" ? zero : original );
  7953. el.to = o.to || ( mode === "hide" ? zero : original );
  7954. }
  7955. // Set scaling factor
  7956. factor = {
  7957. from: {
  7958. y: el.from.height / original.height,
  7959. x: el.from.width / original.width
  7960. },
  7961. to: {
  7962. y: el.to.height / original.height,
  7963. x: el.to.width / original.width
  7964. }
  7965. };
  7966. // Scale the css box
  7967. if ( scale === "box" || scale === "both" ) {
  7968. // Vertical props scaling
  7969. if ( factor.from.y !== factor.to.y ) {
  7970. props = props.concat( vProps );
  7971. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  7972. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  7973. }
  7974. // Horizontal props scaling
  7975. if ( factor.from.x !== factor.to.x ) {
  7976. props = props.concat( hProps );
  7977. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  7978. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  7979. }
  7980. }
  7981. // Scale the content
  7982. if ( scale === "content" || scale === "both" ) {
  7983. // Vertical props scaling
  7984. if ( factor.from.y !== factor.to.y ) {
  7985. props = props.concat( cProps ).concat( props2 );
  7986. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  7987. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  7988. }
  7989. }
  7990. $.effects.save( el, props );
  7991. el.show();
  7992. $.effects.createWrapper( el );
  7993. el.css( "overflow", "hidden" ).css( el.from );
  7994. // Adjust
  7995. if (origin) { // Calculate baseline shifts
  7996. baseline = $.effects.getBaseline( origin, original );
  7997. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  7998. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  7999. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  8000. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  8001. }
  8002. el.css( el.from ); // set top & left
  8003. // Animate
  8004. if ( scale === "content" || scale === "both" ) { // Scale the children
  8005. // Add margins/font-size
  8006. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  8007. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  8008. props2 = props0.concat(vProps).concat(hProps);
  8009. el.find( "*[width]" ).each( function(){
  8010. var child = $( this ),
  8011. c_original = {
  8012. height: child.height(),
  8013. width: child.width(),
  8014. outerHeight: child.outerHeight(),
  8015. outerWidth: child.outerWidth()
  8016. };
  8017. if (restore) {
  8018. $.effects.save(child, props2);
  8019. }
  8020. child.from = {
  8021. height: c_original.height * factor.from.y,
  8022. width: c_original.width * factor.from.x,
  8023. outerHeight: c_original.outerHeight * factor.from.y,
  8024. outerWidth: c_original.outerWidth * factor.from.x
  8025. };
  8026. child.to = {
  8027. height: c_original.height * factor.to.y,
  8028. width: c_original.width * factor.to.x,
  8029. outerHeight: c_original.height * factor.to.y,
  8030. outerWidth: c_original.width * factor.to.x
  8031. };
  8032. // Vertical props scaling
  8033. if ( factor.from.y !== factor.to.y ) {
  8034. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  8035. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  8036. }
  8037. // Horizontal props scaling
  8038. if ( factor.from.x !== factor.to.x ) {
  8039. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  8040. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  8041. }
  8042. // Animate children
  8043. child.css( child.from );
  8044. child.animate( child.to, o.duration, o.easing, function() {
  8045. // Restore children
  8046. if ( restore ) {
  8047. $.effects.restore( child, props2 );
  8048. }
  8049. });
  8050. });
  8051. }
  8052. // Animate
  8053. el.animate( el.to, {
  8054. queue: false,
  8055. duration: o.duration,
  8056. easing: o.easing,
  8057. complete: function() {
  8058. if ( el.to.opacity === 0 ) {
  8059. el.css( "opacity", el.from.opacity );
  8060. }
  8061. if( mode === "hide" ) {
  8062. el.hide();
  8063. }
  8064. $.effects.restore( el, props );
  8065. if ( !restore ) {
  8066. // we need to calculate our new positioning based on the scaling
  8067. if ( position === "static" ) {
  8068. el.css({
  8069. position: "relative",
  8070. top: el.to.top,
  8071. left: el.to.left
  8072. });
  8073. } else {
  8074. $.each([ "top", "left" ], function( idx, pos ) {
  8075. el.css( pos, function( _, str ) {
  8076. var val = parseInt( str, 10 ),
  8077. toRef = idx ? el.to.left : el.to.top;
  8078. // if original was "auto", recalculate the new value from wrapper
  8079. if ( str === "auto" ) {
  8080. return toRef + "px";
  8081. }
  8082. return val + toRef + "px";
  8083. });
  8084. });
  8085. }
  8086. }
  8087. $.effects.removeWrapper( el );
  8088. done();
  8089. }
  8090. });
  8091. };
  8092. })(jQuery);
  8093. (function( $, undefined ) {
  8094. $.effects.effect.shake = function( o, done ) {
  8095. var el = $( this ),
  8096. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8097. mode = $.effects.setMode( el, o.mode || "effect" ),
  8098. direction = o.direction || "left",
  8099. distance = o.distance || 20,
  8100. times = o.times || 3,
  8101. anims = times * 2 + 1,
  8102. speed = Math.round(o.duration/anims),
  8103. ref = (direction === "up" || direction === "down") ? "top" : "left",
  8104. positiveMotion = (direction === "up" || direction === "left"),
  8105. animation = {},
  8106. animation1 = {},
  8107. animation2 = {},
  8108. i,
  8109. // we will need to re-assemble the queue to stack our animations in place
  8110. queue = el.queue(),
  8111. queuelen = queue.length;
  8112. $.effects.save( el, props );
  8113. el.show();
  8114. $.effects.createWrapper( el );
  8115. // Animation
  8116. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  8117. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  8118. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  8119. // Animate
  8120. el.animate( animation, speed, o.easing );
  8121. // Shakes
  8122. for ( i = 1; i < times; i++ ) {
  8123. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  8124. }
  8125. el
  8126. .animate( animation1, speed, o.easing )
  8127. .animate( animation, speed / 2, o.easing )
  8128. .queue(function() {
  8129. if ( mode === "hide" ) {
  8130. el.hide();
  8131. }
  8132. $.effects.restore( el, props );
  8133. $.effects.removeWrapper( el );
  8134. done();
  8135. });
  8136. // inject all the animations we just queued to be first in line (after "inprogress")
  8137. if ( queuelen > 1) {
  8138. queue.splice.apply( queue,
  8139. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  8140. }
  8141. el.dequeue();
  8142. };
  8143. })(jQuery);
  8144. (function( $, undefined ) {
  8145. $.effects.effect.slide = function( o, done ) {
  8146. // Create element
  8147. var el = $( this ),
  8148. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  8149. mode = $.effects.setMode( el, o.mode || "show" ),
  8150. show = mode === "show",
  8151. direction = o.direction || "left",
  8152. ref = (direction === "up" || direction === "down") ? "top" : "left",
  8153. positiveMotion = (direction === "up" || direction === "left"),
  8154. distance,
  8155. animation = {};
  8156. // Adjust
  8157. $.effects.save( el, props );
  8158. el.show();
  8159. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  8160. $.effects.createWrapper( el ).css({
  8161. overflow: "hidden"
  8162. });
  8163. if ( show ) {
  8164. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  8165. }
  8166. // Animation
  8167. animation[ ref ] = ( show ?
  8168. ( positiveMotion ? "+=" : "-=") :
  8169. ( positiveMotion ? "-=" : "+=")) +
  8170. distance;
  8171. // Animate
  8172. el.animate( animation, {
  8173. queue: false,
  8174. duration: o.duration,
  8175. easing: o.easing,
  8176. complete: function() {
  8177. if ( mode === "hide" ) {
  8178. el.hide();
  8179. }
  8180. $.effects.restore( el, props );
  8181. $.effects.removeWrapper( el );
  8182. done();
  8183. }
  8184. });
  8185. };
  8186. })(jQuery);
  8187. (function( $, undefined ) {
  8188. $.effects.effect.transfer = function( o, done ) {
  8189. var elem = $( this ),
  8190. target = $( o.to ),
  8191. targetFixed = target.css( "position" ) === "fixed",
  8192. body = $("body"),
  8193. fixTop = targetFixed ? body.scrollTop() : 0,
  8194. fixLeft = targetFixed ? body.scrollLeft() : 0,
  8195. endPosition = target.offset(),
  8196. animation = {
  8197. top: endPosition.top - fixTop ,
  8198. left: endPosition.left - fixLeft ,
  8199. height: target.innerHeight(),
  8200. width: target.innerWidth()
  8201. },
  8202. startPosition = elem.offset(),
  8203. transfer = $( "<div class='ui-effects-transfer'></div>" )
  8204. .appendTo( document.body )
  8205. .addClass( o.className )
  8206. .css({
  8207. top: startPosition.top - fixTop ,
  8208. left: startPosition.left - fixLeft ,
  8209. height: elem.innerHeight(),
  8210. width: elem.innerWidth(),
  8211. position: targetFixed ? "fixed" : "absolute"
  8212. })
  8213. .animate( animation, o.duration, o.easing, function() {
  8214. transfer.remove();
  8215. done();
  8216. });
  8217. };
  8218. })(jQuery);
  8219. (function( $, undefined ) {
  8220. $.widget( "ui.menu", {
  8221. version: "1.10.4",
  8222. defaultElement: "<ul>",
  8223. delay: 300,
  8224. options: {
  8225. icons: {
  8226. submenu: "ui-icon-carat-1-e"
  8227. },
  8228. menus: "ul",
  8229. position: {
  8230. my: "left top",
  8231. at: "right top"
  8232. },
  8233. role: "menu",
  8234. // callbacks
  8235. blur: null,
  8236. focus: null,
  8237. select: null
  8238. },
  8239. _create: function() {
  8240. this.activeMenu = this.element;
  8241. // flag used to prevent firing of the click handler
  8242. // as the event bubbles up through nested menus
  8243. this.mouseHandled = false;
  8244. this.element
  8245. .uniqueId()
  8246. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8247. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  8248. .attr({
  8249. role: this.options.role,
  8250. tabIndex: 0
  8251. })
  8252. // need to catch all clicks on disabled menu
  8253. // not possible through _on
  8254. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  8255. if ( this.options.disabled ) {
  8256. event.preventDefault();
  8257. }
  8258. }, this ));
  8259. if ( this.options.disabled ) {
  8260. this.element
  8261. .addClass( "ui-state-disabled" )
  8262. .attr( "aria-disabled", "true" );
  8263. }
  8264. this._on({
  8265. // Prevent focus from sticking to links inside menu after clicking
  8266. // them (focus should always stay on UL during navigation).
  8267. "mousedown .ui-menu-item > a": function( event ) {
  8268. event.preventDefault();
  8269. },
  8270. "click .ui-state-disabled > a": function( event ) {
  8271. event.preventDefault();
  8272. },
  8273. "click .ui-menu-item:has(a)": function( event ) {
  8274. var target = $( event.target ).closest( ".ui-menu-item" );
  8275. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  8276. this.select( event );
  8277. // Only set the mouseHandled flag if the event will bubble, see #9469.
  8278. if ( !event.isPropagationStopped() ) {
  8279. this.mouseHandled = true;
  8280. }
  8281. // Open submenu on click
  8282. if ( target.has( ".ui-menu" ).length ) {
  8283. this.expand( event );
  8284. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  8285. // Redirect focus to the menu
  8286. this.element.trigger( "focus", [ true ] );
  8287. // If the active item is on the top level, let it stay active.
  8288. // Otherwise, blur the active item since it is no longer visible.
  8289. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  8290. clearTimeout( this.timer );
  8291. }
  8292. }
  8293. }
  8294. },
  8295. "mouseenter .ui-menu-item": function( event ) {
  8296. var target = $( event.currentTarget );
  8297. // Remove ui-state-active class from siblings of the newly focused menu item
  8298. // to avoid a jump caused by adjacent elements both having a class with a border
  8299. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  8300. this.focus( event, target );
  8301. },
  8302. mouseleave: "collapseAll",
  8303. "mouseleave .ui-menu": "collapseAll",
  8304. focus: function( event, keepActiveItem ) {
  8305. // If there's already an active item, keep it active
  8306. // If not, activate the first item
  8307. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  8308. if ( !keepActiveItem ) {
  8309. this.focus( event, item );
  8310. }
  8311. },
  8312. blur: function( event ) {
  8313. this._delay(function() {
  8314. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  8315. this.collapseAll( event );
  8316. }
  8317. });
  8318. },
  8319. keydown: "_keydown"
  8320. });
  8321. this.refresh();
  8322. // Clicks outside of a menu collapse any open menus
  8323. this._on( this.document, {
  8324. click: function( event ) {
  8325. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  8326. this.collapseAll( event );
  8327. }
  8328. // Reset the mouseHandled flag
  8329. this.mouseHandled = false;
  8330. }
  8331. });
  8332. },
  8333. _destroy: function() {
  8334. // Destroy (sub)menus
  8335. this.element
  8336. .removeAttr( "aria-activedescendant" )
  8337. .find( ".ui-menu" ).addBack()
  8338. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  8339. .removeAttr( "role" )
  8340. .removeAttr( "tabIndex" )
  8341. .removeAttr( "aria-labelledby" )
  8342. .removeAttr( "aria-expanded" )
  8343. .removeAttr( "aria-hidden" )
  8344. .removeAttr( "aria-disabled" )
  8345. .removeUniqueId()
  8346. .show();
  8347. // Destroy menu items
  8348. this.element.find( ".ui-menu-item" )
  8349. .removeClass( "ui-menu-item" )
  8350. .removeAttr( "role" )
  8351. .removeAttr( "aria-disabled" )
  8352. .children( "a" )
  8353. .removeUniqueId()
  8354. .removeClass( "ui-corner-all ui-state-hover" )
  8355. .removeAttr( "tabIndex" )
  8356. .removeAttr( "role" )
  8357. .removeAttr( "aria-haspopup" )
  8358. .children().each( function() {
  8359. var elem = $( this );
  8360. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  8361. elem.remove();
  8362. }
  8363. });
  8364. // Destroy menu dividers
  8365. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  8366. },
  8367. _keydown: function( event ) {
  8368. var match, prev, character, skip, regex,
  8369. preventDefault = true;
  8370. function escape( value ) {
  8371. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  8372. }
  8373. switch ( event.keyCode ) {
  8374. case $.ui.keyCode.PAGE_UP:
  8375. this.previousPage( event );
  8376. break;
  8377. case $.ui.keyCode.PAGE_DOWN:
  8378. this.nextPage( event );
  8379. break;
  8380. case $.ui.keyCode.HOME:
  8381. this._move( "first", "first", event );
  8382. break;
  8383. case $.ui.keyCode.END:
  8384. this._move( "last", "last", event );
  8385. break;
  8386. case $.ui.keyCode.UP:
  8387. this.previous( event );
  8388. break;
  8389. case $.ui.keyCode.DOWN:
  8390. this.next( event );
  8391. break;
  8392. case $.ui.keyCode.LEFT:
  8393. this.collapse( event );
  8394. break;
  8395. case $.ui.keyCode.RIGHT:
  8396. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  8397. this.expand( event );
  8398. }
  8399. break;
  8400. case $.ui.keyCode.ENTER:
  8401. case $.ui.keyCode.SPACE:
  8402. this._activate( event );
  8403. break;
  8404. case $.ui.keyCode.ESCAPE:
  8405. this.collapse( event );
  8406. break;
  8407. default:
  8408. preventDefault = false;
  8409. prev = this.previousFilter || "";
  8410. character = String.fromCharCode( event.keyCode );
  8411. skip = false;
  8412. clearTimeout( this.filterTimer );
  8413. if ( character === prev ) {
  8414. skip = true;
  8415. } else {
  8416. character = prev + character;
  8417. }
  8418. regex = new RegExp( "^" + escape( character ), "i" );
  8419. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8420. return regex.test( $( this ).children( "a" ).text() );
  8421. });
  8422. match = skip && match.index( this.active.next() ) !== -1 ?
  8423. this.active.nextAll( ".ui-menu-item" ) :
  8424. match;
  8425. // If no matches on the current filter, reset to the last character pressed
  8426. // to move down the menu to the first item that starts with that character
  8427. if ( !match.length ) {
  8428. character = String.fromCharCode( event.keyCode );
  8429. regex = new RegExp( "^" + escape( character ), "i" );
  8430. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8431. return regex.test( $( this ).children( "a" ).text() );
  8432. });
  8433. }
  8434. if ( match.length ) {
  8435. this.focus( event, match );
  8436. if ( match.length > 1 ) {
  8437. this.previousFilter = character;
  8438. this.filterTimer = this._delay(function() {
  8439. delete this.previousFilter;
  8440. }, 1000 );
  8441. } else {
  8442. delete this.previousFilter;
  8443. }
  8444. } else {
  8445. delete this.previousFilter;
  8446. }
  8447. }
  8448. if ( preventDefault ) {
  8449. event.preventDefault();
  8450. }
  8451. },
  8452. _activate: function( event ) {
  8453. if ( !this.active.is( ".ui-state-disabled" ) ) {
  8454. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  8455. this.expand( event );
  8456. } else {
  8457. this.select( event );
  8458. }
  8459. }
  8460. },
  8461. refresh: function() {
  8462. var menus,
  8463. icon = this.options.icons.submenu,
  8464. submenus = this.element.find( this.options.menus );
  8465. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  8466. // Initialize nested menus
  8467. submenus.filter( ":not(.ui-menu)" )
  8468. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8469. .hide()
  8470. .attr({
  8471. role: this.options.role,
  8472. "aria-hidden": "true",
  8473. "aria-expanded": "false"
  8474. })
  8475. .each(function() {
  8476. var menu = $( this ),
  8477. item = menu.prev( "a" ),
  8478. submenuCarat = $( "<span>" )
  8479. .addClass( "ui-menu-icon ui-icon " + icon )
  8480. .data( "ui-menu-submenu-carat", true );
  8481. item
  8482. .attr( "aria-haspopup", "true" )
  8483. .prepend( submenuCarat );
  8484. menu.attr( "aria-labelledby", item.attr( "id" ) );
  8485. });
  8486. menus = submenus.add( this.element );
  8487. // Don't refresh list items that are already adapted
  8488. menus.children( ":not(.ui-menu-item):has(a)" )
  8489. .addClass( "ui-menu-item" )
  8490. .attr( "role", "presentation" )
  8491. .children( "a" )
  8492. .uniqueId()
  8493. .addClass( "ui-corner-all" )
  8494. .attr({
  8495. tabIndex: -1,
  8496. role: this._itemRole()
  8497. });
  8498. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  8499. menus.children( ":not(.ui-menu-item)" ).each(function() {
  8500. var item = $( this );
  8501. // hyphen, em dash, en dash
  8502. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  8503. item.addClass( "ui-widget-content ui-menu-divider" );
  8504. }
  8505. });
  8506. // Add aria-disabled attribute to any disabled menu item
  8507. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  8508. // If the active item has been removed, blur the menu
  8509. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  8510. this.blur();
  8511. }
  8512. },
  8513. _itemRole: function() {
  8514. return {
  8515. menu: "menuitem",
  8516. listbox: "option"
  8517. }[ this.options.role ];
  8518. },
  8519. _setOption: function( key, value ) {
  8520. if ( key === "icons" ) {
  8521. this.element.find( ".ui-menu-icon" )
  8522. .removeClass( this.options.icons.submenu )
  8523. .addClass( value.submenu );
  8524. }
  8525. this._super( key, value );
  8526. },
  8527. focus: function( event, item ) {
  8528. var nested, focused;
  8529. this.blur( event, event && event.type === "focus" );
  8530. this._scrollIntoView( item );
  8531. this.active = item.first();
  8532. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  8533. // Only update aria-activedescendant if there's a role
  8534. // otherwise we assume focus is managed elsewhere
  8535. if ( this.options.role ) {
  8536. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  8537. }
  8538. // Highlight active parent menu item, if any
  8539. this.active
  8540. .parent()
  8541. .closest( ".ui-menu-item" )
  8542. .children( "a:first" )
  8543. .addClass( "ui-state-active" );
  8544. if ( event && event.type === "keydown" ) {
  8545. this._close();
  8546. } else {
  8547. this.timer = this._delay(function() {
  8548. this._close();
  8549. }, this.delay );
  8550. }
  8551. nested = item.children( ".ui-menu" );
  8552. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  8553. this._startOpening(nested);
  8554. }
  8555. this.activeMenu = item.parent();
  8556. this._trigger( "focus", event, { item: item } );
  8557. },
  8558. _scrollIntoView: function( item ) {
  8559. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  8560. if ( this._hasScroll() ) {
  8561. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  8562. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  8563. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  8564. scroll = this.activeMenu.scrollTop();
  8565. elementHeight = this.activeMenu.height();
  8566. itemHeight = item.height();
  8567. if ( offset < 0 ) {
  8568. this.activeMenu.scrollTop( scroll + offset );
  8569. } else if ( offset + itemHeight > elementHeight ) {
  8570. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  8571. }
  8572. }
  8573. },
  8574. blur: function( event, fromFocus ) {
  8575. if ( !fromFocus ) {
  8576. clearTimeout( this.timer );
  8577. }
  8578. if ( !this.active ) {
  8579. return;
  8580. }
  8581. this.active.children( "a" ).removeClass( "ui-state-focus" );
  8582. this.active = null;
  8583. this._trigger( "blur", event, { item: this.active } );
  8584. },
  8585. _startOpening: function( submenu ) {
  8586. clearTimeout( this.timer );
  8587. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  8588. // shift in the submenu position when mousing over the carat icon
  8589. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  8590. return;
  8591. }
  8592. this.timer = this._delay(function() {
  8593. this._close();
  8594. this._open( submenu );
  8595. }, this.delay );
  8596. },
  8597. _open: function( submenu ) {
  8598. var position = $.extend({
  8599. of: this.active
  8600. }, this.options.position );
  8601. clearTimeout( this.timer );
  8602. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  8603. .hide()
  8604. .attr( "aria-hidden", "true" );
  8605. submenu
  8606. .show()
  8607. .removeAttr( "aria-hidden" )
  8608. .attr( "aria-expanded", "true" )
  8609. .position( position );
  8610. },
  8611. collapseAll: function( event, all ) {
  8612. clearTimeout( this.timer );
  8613. this.timer = this._delay(function() {
  8614. // If we were passed an event, look for the submenu that contains the event
  8615. var currentMenu = all ? this.element :
  8616. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  8617. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  8618. if ( !currentMenu.length ) {
  8619. currentMenu = this.element;
  8620. }
  8621. this._close( currentMenu );
  8622. this.blur( event );
  8623. this.activeMenu = currentMenu;
  8624. }, this.delay );
  8625. },
  8626. // With no arguments, closes the currently active menu - if nothing is active
  8627. // it closes all menus. If passed an argument, it will search for menus BELOW
  8628. _close: function( startMenu ) {
  8629. if ( !startMenu ) {
  8630. startMenu = this.active ? this.active.parent() : this.element;
  8631. }
  8632. startMenu
  8633. .find( ".ui-menu" )
  8634. .hide()
  8635. .attr( "aria-hidden", "true" )
  8636. .attr( "aria-expanded", "false" )
  8637. .end()
  8638. .find( "a.ui-state-active" )
  8639. .removeClass( "ui-state-active" );
  8640. },
  8641. collapse: function( event ) {
  8642. var newItem = this.active &&
  8643. this.active.parent().closest( ".ui-menu-item", this.element );
  8644. if ( newItem && newItem.length ) {
  8645. this._close();
  8646. this.focus( event, newItem );
  8647. }
  8648. },
  8649. expand: function( event ) {
  8650. var newItem = this.active &&
  8651. this.active
  8652. .children( ".ui-menu " )
  8653. .children( ".ui-menu-item" )
  8654. .first();
  8655. if ( newItem && newItem.length ) {
  8656. this._open( newItem.parent() );
  8657. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  8658. this._delay(function() {
  8659. this.focus( event, newItem );
  8660. });
  8661. }
  8662. },
  8663. next: function( event ) {
  8664. this._move( "next", "first", event );
  8665. },
  8666. previous: function( event ) {
  8667. this._move( "prev", "last", event );
  8668. },
  8669. isFirstItem: function() {
  8670. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  8671. },
  8672. isLastItem: function() {
  8673. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  8674. },
  8675. _move: function( direction, filter, event ) {
  8676. var next;
  8677. if ( this.active ) {
  8678. if ( direction === "first" || direction === "last" ) {
  8679. next = this.active
  8680. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  8681. .eq( -1 );
  8682. } else {
  8683. next = this.active
  8684. [ direction + "All" ]( ".ui-menu-item" )
  8685. .eq( 0 );
  8686. }
  8687. }
  8688. if ( !next || !next.length || !this.active ) {
  8689. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  8690. }
  8691. this.focus( event, next );
  8692. },
  8693. nextPage: function( event ) {
  8694. var item, base, height;
  8695. if ( !this.active ) {
  8696. this.next( event );
  8697. return;
  8698. }
  8699. if ( this.isLastItem() ) {
  8700. return;
  8701. }
  8702. if ( this._hasScroll() ) {
  8703. base = this.active.offset().top;
  8704. height = this.element.height();
  8705. this.active.nextAll( ".ui-menu-item" ).each(function() {
  8706. item = $( this );
  8707. return item.offset().top - base - height < 0;
  8708. });
  8709. this.focus( event, item );
  8710. } else {
  8711. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  8712. [ !this.active ? "first" : "last" ]() );
  8713. }
  8714. },
  8715. previousPage: function( event ) {
  8716. var item, base, height;
  8717. if ( !this.active ) {
  8718. this.next( event );
  8719. return;
  8720. }
  8721. if ( this.isFirstItem() ) {
  8722. return;
  8723. }
  8724. if ( this._hasScroll() ) {
  8725. base = this.active.offset().top;
  8726. height = this.element.height();
  8727. this.active.prevAll( ".ui-menu-item" ).each(function() {
  8728. item = $( this );
  8729. return item.offset().top - base + height > 0;
  8730. });
  8731. this.focus( event, item );
  8732. } else {
  8733. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  8734. }
  8735. },
  8736. _hasScroll: function() {
  8737. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  8738. },
  8739. select: function( event ) {
  8740. // TODO: It should never be possible to not have an active item at this
  8741. // point, but the tests don't trigger mouseenter before click.
  8742. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  8743. var ui = { item: this.active };
  8744. if ( !this.active.has( ".ui-menu" ).length ) {
  8745. this.collapseAll( event, true );
  8746. }
  8747. this._trigger( "select", event, ui );
  8748. }
  8749. });
  8750. }( jQuery ));
  8751. (function( $, undefined ) {
  8752. $.widget( "ui.progressbar", {
  8753. version: "1.10.4",
  8754. options: {
  8755. max: 100,
  8756. value: 0,
  8757. change: null,
  8758. complete: null
  8759. },
  8760. min: 0,
  8761. _create: function() {
  8762. // Constrain initial value
  8763. this.oldValue = this.options.value = this._constrainedValue();
  8764. this.element
  8765. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8766. .attr({
  8767. // Only set static values, aria-valuenow and aria-valuemax are
  8768. // set inside _refreshValue()
  8769. role: "progressbar",
  8770. "aria-valuemin": this.min
  8771. });
  8772. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8773. .appendTo( this.element );
  8774. this._refreshValue();
  8775. },
  8776. _destroy: function() {
  8777. this.element
  8778. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8779. .removeAttr( "role" )
  8780. .removeAttr( "aria-valuemin" )
  8781. .removeAttr( "aria-valuemax" )
  8782. .removeAttr( "aria-valuenow" );
  8783. this.valueDiv.remove();
  8784. },
  8785. value: function( newValue ) {
  8786. if ( newValue === undefined ) {
  8787. return this.options.value;
  8788. }
  8789. this.options.value = this._constrainedValue( newValue );
  8790. this._refreshValue();
  8791. },
  8792. _constrainedValue: function( newValue ) {
  8793. if ( newValue === undefined ) {
  8794. newValue = this.options.value;
  8795. }
  8796. this.indeterminate = newValue === false;
  8797. // sanitize value
  8798. if ( typeof newValue !== "number" ) {
  8799. newValue = 0;
  8800. }
  8801. return this.indeterminate ? false :
  8802. Math.min( this.options.max, Math.max( this.min, newValue ) );
  8803. },
  8804. _setOptions: function( options ) {
  8805. // Ensure "value" option is set after other values (like max)
  8806. var value = options.value;
  8807. delete options.value;
  8808. this._super( options );
  8809. this.options.value = this._constrainedValue( value );
  8810. this._refreshValue();
  8811. },
  8812. _setOption: function( key, value ) {
  8813. if ( key === "max" ) {
  8814. // Don't allow a max less than min
  8815. value = Math.max( this.min, value );
  8816. }
  8817. this._super( key, value );
  8818. },
  8819. _percentage: function() {
  8820. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  8821. },
  8822. _refreshValue: function() {
  8823. var value = this.options.value,
  8824. percentage = this._percentage();
  8825. this.valueDiv
  8826. .toggle( this.indeterminate || value > this.min )
  8827. .toggleClass( "ui-corner-right", value === this.options.max )
  8828. .width( percentage.toFixed(0) + "%" );
  8829. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  8830. if ( this.indeterminate ) {
  8831. this.element.removeAttr( "aria-valuenow" );
  8832. if ( !this.overlayDiv ) {
  8833. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  8834. }
  8835. } else {
  8836. this.element.attr({
  8837. "aria-valuemax": this.options.max,
  8838. "aria-valuenow": value
  8839. });
  8840. if ( this.overlayDiv ) {
  8841. this.overlayDiv.remove();
  8842. this.overlayDiv = null;
  8843. }
  8844. }
  8845. if ( this.oldValue !== value ) {
  8846. this.oldValue = value;
  8847. this._trigger( "change" );
  8848. }
  8849. if ( value === this.options.max ) {
  8850. this._trigger( "complete" );
  8851. }
  8852. }
  8853. });
  8854. })( jQuery );
  8855. (function( $, undefined ) {
  8856. function num(v) {
  8857. return parseInt(v, 10) || 0;
  8858. }
  8859. function isNumber(value) {
  8860. return !isNaN(parseInt(value, 10));
  8861. }
  8862. $.widget("ui.resizable", $.ui.mouse, {
  8863. version: "1.10.4",
  8864. widgetEventPrefix: "resize",
  8865. options: {
  8866. alsoResize: false,
  8867. animate: false,
  8868. animateDuration: "slow",
  8869. animateEasing: "swing",
  8870. aspectRatio: false,
  8871. autoHide: false,
  8872. containment: false,
  8873. ghost: false,
  8874. grid: false,
  8875. handles: "e,s,se",
  8876. helper: false,
  8877. maxHeight: null,
  8878. maxWidth: null,
  8879. minHeight: 10,
  8880. minWidth: 10,
  8881. // See #7960
  8882. zIndex: 90,
  8883. // callbacks
  8884. resize: null,
  8885. start: null,
  8886. stop: null
  8887. },
  8888. _create: function() {
  8889. var n, i, handle, axis, hname,
  8890. that = this,
  8891. o = this.options;
  8892. this.element.addClass("ui-resizable");
  8893. $.extend(this, {
  8894. _aspectRatio: !!(o.aspectRatio),
  8895. aspectRatio: o.aspectRatio,
  8896. originalElement: this.element,
  8897. _proportionallyResizeElements: [],
  8898. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  8899. });
  8900. //Wrap the element if it cannot hold child nodes
  8901. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  8902. //Create a wrapper element and set the wrapper to the new current internal element
  8903. this.element.wrap(
  8904. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  8905. position: this.element.css("position"),
  8906. width: this.element.outerWidth(),
  8907. height: this.element.outerHeight(),
  8908. top: this.element.css("top"),
  8909. left: this.element.css("left")
  8910. })
  8911. );
  8912. //Overwrite the original this.element
  8913. this.element = this.element.parent().data(
  8914. "ui-resizable", this.element.data("ui-resizable")
  8915. );
  8916. this.elementIsWrapper = true;
  8917. //Move margins to the wrapper
  8918. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  8919. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  8920. //Prevent Safari textarea resize
  8921. this.originalResizeStyle = this.originalElement.css("resize");
  8922. this.originalElement.css("resize", "none");
  8923. //Push the actual element to our proportionallyResize internal array
  8924. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  8925. // avoid IE jump (hard set the margin)
  8926. this.originalElement.css({ margin: this.originalElement.css("margin") });
  8927. // fix handlers offset
  8928. this._proportionallyResize();
  8929. }
  8930. this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" });
  8931. if(this.handles.constructor === String) {
  8932. if ( this.handles === "all") {
  8933. this.handles = "n,e,s,w,se,sw,ne,nw";
  8934. }
  8935. n = this.handles.split(",");
  8936. this.handles = {};
  8937. for(i = 0; i < n.length; i++) {
  8938. handle = $.trim(n[i]);
  8939. hname = "ui-resizable-"+handle;
  8940. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  8941. // Apply zIndex to all handles - see #7960
  8942. axis.css({ zIndex: o.zIndex });
  8943. //TODO : What's going on here?
  8944. if ("se" === handle) {
  8945. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  8946. }
  8947. //Insert into internal handles object and append to element
  8948. this.handles[handle] = ".ui-resizable-"+handle;
  8949. this.element.append(axis);
  8950. }
  8951. }
  8952. this._renderAxis = function(target) {
  8953. var i, axis, padPos, padWrapper;
  8954. target = target || this.element;
  8955. for(i in this.handles) {
  8956. if(this.handles[i].constructor === String) {
  8957. this.handles[i] = $(this.handles[i], this.element).show();
  8958. }
  8959. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  8960. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  8961. axis = $(this.handles[i], this.element);
  8962. //Checking the correct pad and border
  8963. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  8964. //The padding type i have to apply...
  8965. padPos = [ "padding",
  8966. /ne|nw|n/.test(i) ? "Top" :
  8967. /se|sw|s/.test(i) ? "Bottom" :
  8968. /^e$/.test(i) ? "Right" : "Left" ].join("");
  8969. target.css(padPos, padWrapper);
  8970. this._proportionallyResize();
  8971. }
  8972. //TODO: What's that good for? There's not anything to be executed left
  8973. if(!$(this.handles[i]).length) {
  8974. continue;
  8975. }
  8976. }
  8977. };
  8978. //TODO: make renderAxis a prototype function
  8979. this._renderAxis(this.element);
  8980. this._handles = $(".ui-resizable-handle", this.element)
  8981. .disableSelection();
  8982. //Matching axis name
  8983. this._handles.mouseover(function() {
  8984. if (!that.resizing) {
  8985. if (this.className) {
  8986. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  8987. }
  8988. //Axis, default = se
  8989. that.axis = axis && axis[1] ? axis[1] : "se";
  8990. }
  8991. });
  8992. //If we want to auto hide the elements
  8993. if (o.autoHide) {
  8994. this._handles.hide();
  8995. $(this.element)
  8996. .addClass("ui-resizable-autohide")
  8997. .mouseenter(function() {
  8998. if (o.disabled) {
  8999. return;
  9000. }
  9001. $(this).removeClass("ui-resizable-autohide");
  9002. that._handles.show();
  9003. })
  9004. .mouseleave(function(){
  9005. if (o.disabled) {
  9006. return;
  9007. }
  9008. if (!that.resizing) {
  9009. $(this).addClass("ui-resizable-autohide");
  9010. that._handles.hide();
  9011. }
  9012. });
  9013. }
  9014. //Initialize the mouse interaction
  9015. this._mouseInit();
  9016. },
  9017. _destroy: function() {
  9018. this._mouseDestroy();
  9019. var wrapper,
  9020. _destroy = function(exp) {
  9021. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  9022. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  9023. };
  9024. //TODO: Unwrap at same DOM position
  9025. if (this.elementIsWrapper) {
  9026. _destroy(this.element);
  9027. wrapper = this.element;
  9028. this.originalElement.css({
  9029. position: wrapper.css("position"),
  9030. width: wrapper.outerWidth(),
  9031. height: wrapper.outerHeight(),
  9032. top: wrapper.css("top"),
  9033. left: wrapper.css("left")
  9034. }).insertAfter( wrapper );
  9035. wrapper.remove();
  9036. }
  9037. this.originalElement.css("resize", this.originalResizeStyle);
  9038. _destroy(this.originalElement);
  9039. return this;
  9040. },
  9041. _mouseCapture: function(event) {
  9042. var i, handle,
  9043. capture = false;
  9044. for (i in this.handles) {
  9045. handle = $(this.handles[i])[0];
  9046. if (handle === event.target || $.contains(handle, event.target)) {
  9047. capture = true;
  9048. }
  9049. }
  9050. return !this.options.disabled && capture;
  9051. },
  9052. _mouseStart: function(event) {
  9053. var curleft, curtop, cursor,
  9054. o = this.options,
  9055. iniPos = this.element.position(),
  9056. el = this.element;
  9057. this.resizing = true;
  9058. // bugfix for http://dev.jquery.com/ticket/1749
  9059. if ( (/absolute/).test( el.css("position") ) ) {
  9060. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  9061. } else if (el.is(".ui-draggable")) {
  9062. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  9063. }
  9064. this._renderProxy();
  9065. curleft = num(this.helper.css("left"));
  9066. curtop = num(this.helper.css("top"));
  9067. if (o.containment) {
  9068. curleft += $(o.containment).scrollLeft() || 0;
  9069. curtop += $(o.containment).scrollTop() || 0;
  9070. }
  9071. //Store needed variables
  9072. this.offset = this.helper.offset();
  9073. this.position = { left: curleft, top: curtop };
  9074. this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
  9075. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  9076. this.originalPosition = { left: curleft, top: curtop };
  9077. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  9078. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  9079. //Aspect Ratio
  9080. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  9081. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  9082. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  9083. el.addClass("ui-resizable-resizing");
  9084. this._propagate("start", event);
  9085. return true;
  9086. },
  9087. _mouseDrag: function(event) {
  9088. //Increase performance, avoid regex
  9089. var data,
  9090. el = this.helper, props = {},
  9091. smp = this.originalMousePosition,
  9092. a = this.axis,
  9093. prevTop = this.position.top,
  9094. prevLeft = this.position.left,
  9095. prevWidth = this.size.width,
  9096. prevHeight = this.size.height,
  9097. dx = (event.pageX-smp.left)||0,
  9098. dy = (event.pageY-smp.top)||0,
  9099. trigger = this._change[a];
  9100. if (!trigger) {
  9101. return false;
  9102. }
  9103. // Calculate the attrs that will be change
  9104. data = trigger.apply(this, [event, dx, dy]);
  9105. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  9106. this._updateVirtualBoundaries(event.shiftKey);
  9107. if (this._aspectRatio || event.shiftKey) {
  9108. data = this._updateRatio(data, event);
  9109. }
  9110. data = this._respectSize(data, event);
  9111. this._updateCache(data);
  9112. // plugins callbacks need to be called first
  9113. this._propagate("resize", event);
  9114. if (this.position.top !== prevTop) {
  9115. props.top = this.position.top + "px";
  9116. }
  9117. if (this.position.left !== prevLeft) {
  9118. props.left = this.position.left + "px";
  9119. }
  9120. if (this.size.width !== prevWidth) {
  9121. props.width = this.size.width + "px";
  9122. }
  9123. if (this.size.height !== prevHeight) {
  9124. props.height = this.size.height + "px";
  9125. }
  9126. el.css(props);
  9127. if (!this._helper && this._proportionallyResizeElements.length) {
  9128. this._proportionallyResize();
  9129. }
  9130. // Call the user callback if the element was resized
  9131. if ( ! $.isEmptyObject(props) ) {
  9132. this._trigger("resize", event, this.ui());
  9133. }
  9134. return false;
  9135. },
  9136. _mouseStop: function(event) {
  9137. this.resizing = false;
  9138. var pr, ista, soffseth, soffsetw, s, left, top,
  9139. o = this.options, that = this;
  9140. if(this._helper) {
  9141. pr = this._proportionallyResizeElements;
  9142. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  9143. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  9144. soffsetw = ista ? 0 : that.sizeDiff.width;
  9145. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  9146. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  9147. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  9148. if (!o.animate) {
  9149. this.element.css($.extend(s, { top: top, left: left }));
  9150. }
  9151. that.helper.height(that.size.height);
  9152. that.helper.width(that.size.width);
  9153. if (this._helper && !o.animate) {
  9154. this._proportionallyResize();
  9155. }
  9156. }
  9157. $("body").css("cursor", "auto");
  9158. this.element.removeClass("ui-resizable-resizing");
  9159. this._propagate("stop", event);
  9160. if (this._helper) {
  9161. this.helper.remove();
  9162. }
  9163. return false;
  9164. },
  9165. _updateVirtualBoundaries: function(forceAspectRatio) {
  9166. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  9167. o = this.options;
  9168. b = {
  9169. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  9170. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  9171. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  9172. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  9173. };
  9174. if(this._aspectRatio || forceAspectRatio) {
  9175. // We want to create an enclosing box whose aspect ration is the requested one
  9176. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  9177. pMinWidth = b.minHeight * this.aspectRatio;
  9178. pMinHeight = b.minWidth / this.aspectRatio;
  9179. pMaxWidth = b.maxHeight * this.aspectRatio;
  9180. pMaxHeight = b.maxWidth / this.aspectRatio;
  9181. if(pMinWidth > b.minWidth) {
  9182. b.minWidth = pMinWidth;
  9183. }
  9184. if(pMinHeight > b.minHeight) {
  9185. b.minHeight = pMinHeight;
  9186. }
  9187. if(pMaxWidth < b.maxWidth) {
  9188. b.maxWidth = pMaxWidth;
  9189. }
  9190. if(pMaxHeight < b.maxHeight) {
  9191. b.maxHeight = pMaxHeight;
  9192. }
  9193. }
  9194. this._vBoundaries = b;
  9195. },
  9196. _updateCache: function(data) {
  9197. this.offset = this.helper.offset();
  9198. if (isNumber(data.left)) {
  9199. this.position.left = data.left;
  9200. }
  9201. if (isNumber(data.top)) {
  9202. this.position.top = data.top;
  9203. }
  9204. if (isNumber(data.height)) {
  9205. this.size.height = data.height;
  9206. }
  9207. if (isNumber(data.width)) {
  9208. this.size.width = data.width;
  9209. }
  9210. },
  9211. _updateRatio: function( data ) {
  9212. var cpos = this.position,
  9213. csize = this.size,
  9214. a = this.axis;
  9215. if (isNumber(data.height)) {
  9216. data.width = (data.height * this.aspectRatio);
  9217. } else if (isNumber(data.width)) {
  9218. data.height = (data.width / this.aspectRatio);
  9219. }
  9220. if (a === "sw") {
  9221. data.left = cpos.left + (csize.width - data.width);
  9222. data.top = null;
  9223. }
  9224. if (a === "nw") {
  9225. data.top = cpos.top + (csize.height - data.height);
  9226. data.left = cpos.left + (csize.width - data.width);
  9227. }
  9228. return data;
  9229. },
  9230. _respectSize: function( data ) {
  9231. var o = this._vBoundaries,
  9232. a = this.axis,
  9233. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  9234. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  9235. dw = this.originalPosition.left + this.originalSize.width,
  9236. dh = this.position.top + this.size.height,
  9237. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  9238. if (isminw) {
  9239. data.width = o.minWidth;
  9240. }
  9241. if (isminh) {
  9242. data.height = o.minHeight;
  9243. }
  9244. if (ismaxw) {
  9245. data.width = o.maxWidth;
  9246. }
  9247. if (ismaxh) {
  9248. data.height = o.maxHeight;
  9249. }
  9250. if (isminw && cw) {
  9251. data.left = dw - o.minWidth;
  9252. }
  9253. if (ismaxw && cw) {
  9254. data.left = dw - o.maxWidth;
  9255. }
  9256. if (isminh && ch) {
  9257. data.top = dh - o.minHeight;
  9258. }
  9259. if (ismaxh && ch) {
  9260. data.top = dh - o.maxHeight;
  9261. }
  9262. // fixing jump error on top/left - bug #2330
  9263. if (!data.width && !data.height && !data.left && data.top) {
  9264. data.top = null;
  9265. } else if (!data.width && !data.height && !data.top && data.left) {
  9266. data.left = null;
  9267. }
  9268. return data;
  9269. },
  9270. _proportionallyResize: function() {
  9271. if (!this._proportionallyResizeElements.length) {
  9272. return;
  9273. }
  9274. var i, j, borders, paddings, prel,
  9275. element = this.helper || this.element;
  9276. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  9277. prel = this._proportionallyResizeElements[i];
  9278. if (!this.borderDif) {
  9279. this.borderDif = [];
  9280. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  9281. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  9282. for ( j = 0; j < borders.length; j++ ) {
  9283. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  9284. }
  9285. }
  9286. prel.css({
  9287. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  9288. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  9289. });
  9290. }
  9291. },
  9292. _renderProxy: function() {
  9293. var el = this.element, o = this.options;
  9294. this.elementOffset = el.offset();
  9295. if(this._helper) {
  9296. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  9297. this.helper.addClass(this._helper).css({
  9298. width: this.element.outerWidth() - 1,
  9299. height: this.element.outerHeight() - 1,
  9300. position: "absolute",
  9301. left: this.elementOffset.left +"px",
  9302. top: this.elementOffset.top +"px",
  9303. zIndex: ++o.zIndex //TODO: Don't modify option
  9304. });
  9305. this.helper
  9306. .appendTo("body")
  9307. .disableSelection();
  9308. } else {
  9309. this.helper = this.element;
  9310. }
  9311. },
  9312. _change: {
  9313. e: function(event, dx) {
  9314. return { width: this.originalSize.width + dx };
  9315. },
  9316. w: function(event, dx) {
  9317. var cs = this.originalSize, sp = this.originalPosition;
  9318. return { left: sp.left + dx, width: cs.width - dx };
  9319. },
  9320. n: function(event, dx, dy) {
  9321. var cs = this.originalSize, sp = this.originalPosition;
  9322. return { top: sp.top + dy, height: cs.height - dy };
  9323. },
  9324. s: function(event, dx, dy) {
  9325. return { height: this.originalSize.height + dy };
  9326. },
  9327. se: function(event, dx, dy) {
  9328. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9329. },
  9330. sw: function(event, dx, dy) {
  9331. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9332. },
  9333. ne: function(event, dx, dy) {
  9334. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9335. },
  9336. nw: function(event, dx, dy) {
  9337. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9338. }
  9339. },
  9340. _propagate: function(n, event) {
  9341. $.ui.plugin.call(this, n, [event, this.ui()]);
  9342. (n !== "resize" && this._trigger(n, event, this.ui()));
  9343. },
  9344. plugins: {},
  9345. ui: function() {
  9346. return {
  9347. originalElement: this.originalElement,
  9348. element: this.element,
  9349. helper: this.helper,
  9350. position: this.position,
  9351. size: this.size,
  9352. originalSize: this.originalSize,
  9353. originalPosition: this.originalPosition
  9354. };
  9355. }
  9356. });
  9357. /*
  9358. * Resizable Extensions
  9359. */
  9360. $.ui.plugin.add("resizable", "animate", {
  9361. stop: function( event ) {
  9362. var that = $(this).data("ui-resizable"),
  9363. o = that.options,
  9364. pr = that._proportionallyResizeElements,
  9365. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  9366. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  9367. soffsetw = ista ? 0 : that.sizeDiff.width,
  9368. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  9369. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  9370. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  9371. that.element.animate(
  9372. $.extend(style, top && left ? { top: top, left: left } : {}), {
  9373. duration: o.animateDuration,
  9374. easing: o.animateEasing,
  9375. step: function() {
  9376. var data = {
  9377. width: parseInt(that.element.css("width"), 10),
  9378. height: parseInt(that.element.css("height"), 10),
  9379. top: parseInt(that.element.css("top"), 10),
  9380. left: parseInt(that.element.css("left"), 10)
  9381. };
  9382. if (pr && pr.length) {
  9383. $(pr[0]).css({ width: data.width, height: data.height });
  9384. }
  9385. // propagating resize, and updating values for each animation step
  9386. that._updateCache(data);
  9387. that._propagate("resize", event);
  9388. }
  9389. }
  9390. );
  9391. }
  9392. });
  9393. $.ui.plugin.add("resizable", "containment", {
  9394. start: function() {
  9395. var element, p, co, ch, cw, width, height,
  9396. that = $(this).data("ui-resizable"),
  9397. o = that.options,
  9398. el = that.element,
  9399. oc = o.containment,
  9400. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  9401. if (!ce) {
  9402. return;
  9403. }
  9404. that.containerElement = $(ce);
  9405. if (/document/.test(oc) || oc === document) {
  9406. that.containerOffset = { left: 0, top: 0 };
  9407. that.containerPosition = { left: 0, top: 0 };
  9408. that.parentData = {
  9409. element: $(document), left: 0, top: 0,
  9410. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  9411. };
  9412. }
  9413. // i'm a node, so compute top, left, right, bottom
  9414. else {
  9415. element = $(ce);
  9416. p = [];
  9417. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  9418. that.containerOffset = element.offset();
  9419. that.containerPosition = element.position();
  9420. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  9421. co = that.containerOffset;
  9422. ch = that.containerSize.height;
  9423. cw = that.containerSize.width;
  9424. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  9425. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  9426. that.parentData = {
  9427. element: ce, left: co.left, top: co.top, width: width, height: height
  9428. };
  9429. }
  9430. },
  9431. resize: function( event ) {
  9432. var woset, hoset, isParent, isOffsetRelative,
  9433. that = $(this).data("ui-resizable"),
  9434. o = that.options,
  9435. co = that.containerOffset, cp = that.position,
  9436. pRatio = that._aspectRatio || event.shiftKey,
  9437. cop = { top:0, left:0 }, ce = that.containerElement;
  9438. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  9439. cop = co;
  9440. }
  9441. if (cp.left < (that._helper ? co.left : 0)) {
  9442. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  9443. if (pRatio) {
  9444. that.size.height = that.size.width / that.aspectRatio;
  9445. }
  9446. that.position.left = o.helper ? co.left : 0;
  9447. }
  9448. if (cp.top < (that._helper ? co.top : 0)) {
  9449. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  9450. if (pRatio) {
  9451. that.size.width = that.size.height * that.aspectRatio;
  9452. }
  9453. that.position.top = that._helper ? co.top : 0;
  9454. }
  9455. that.offset.left = that.parentData.left+that.position.left;
  9456. that.offset.top = that.parentData.top+that.position.top;
  9457. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  9458. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  9459. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  9460. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  9461. if ( isParent && isOffsetRelative ) {
  9462. woset -= Math.abs( that.parentData.left );
  9463. }
  9464. if (woset + that.size.width >= that.parentData.width) {
  9465. that.size.width = that.parentData.width - woset;
  9466. if (pRatio) {
  9467. that.size.height = that.size.width / that.aspectRatio;
  9468. }
  9469. }
  9470. if (hoset + that.size.height >= that.parentData.height) {
  9471. that.size.height = that.parentData.height - hoset;
  9472. if (pRatio) {
  9473. that.size.width = that.size.height * that.aspectRatio;
  9474. }
  9475. }
  9476. },
  9477. stop: function(){
  9478. var that = $(this).data("ui-resizable"),
  9479. o = that.options,
  9480. co = that.containerOffset,
  9481. cop = that.containerPosition,
  9482. ce = that.containerElement,
  9483. helper = $(that.helper),
  9484. ho = helper.offset(),
  9485. w = helper.outerWidth() - that.sizeDiff.width,
  9486. h = helper.outerHeight() - that.sizeDiff.height;
  9487. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  9488. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9489. }
  9490. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  9491. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9492. }
  9493. }
  9494. });
  9495. $.ui.plugin.add("resizable", "alsoResize", {
  9496. start: function () {
  9497. var that = $(this).data("ui-resizable"),
  9498. o = that.options,
  9499. _store = function (exp) {
  9500. $(exp).each(function() {
  9501. var el = $(this);
  9502. el.data("ui-resizable-alsoresize", {
  9503. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  9504. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  9505. });
  9506. });
  9507. };
  9508. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  9509. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  9510. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  9511. }else{
  9512. _store(o.alsoResize);
  9513. }
  9514. },
  9515. resize: function (event, ui) {
  9516. var that = $(this).data("ui-resizable"),
  9517. o = that.options,
  9518. os = that.originalSize,
  9519. op = that.originalPosition,
  9520. delta = {
  9521. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  9522. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  9523. },
  9524. _alsoResize = function (exp, c) {
  9525. $(exp).each(function() {
  9526. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  9527. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  9528. $.each(css, function (i, prop) {
  9529. var sum = (start[prop]||0) + (delta[prop]||0);
  9530. if (sum && sum >= 0) {
  9531. style[prop] = sum || null;
  9532. }
  9533. });
  9534. el.css(style);
  9535. });
  9536. };
  9537. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  9538. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  9539. }else{
  9540. _alsoResize(o.alsoResize);
  9541. }
  9542. },
  9543. stop: function () {
  9544. $(this).removeData("resizable-alsoresize");
  9545. }
  9546. });
  9547. $.ui.plugin.add("resizable", "ghost", {
  9548. start: function() {
  9549. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  9550. that.ghost = that.originalElement.clone();
  9551. that.ghost
  9552. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  9553. .addClass("ui-resizable-ghost")
  9554. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  9555. that.ghost.appendTo(that.helper);
  9556. },
  9557. resize: function(){
  9558. var that = $(this).data("ui-resizable");
  9559. if (that.ghost) {
  9560. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  9561. }
  9562. },
  9563. stop: function() {
  9564. var that = $(this).data("ui-resizable");
  9565. if (that.ghost && that.helper) {
  9566. that.helper.get(0).removeChild(that.ghost.get(0));
  9567. }
  9568. }
  9569. });
  9570. $.ui.plugin.add("resizable", "grid", {
  9571. resize: function() {
  9572. var that = $(this).data("ui-resizable"),
  9573. o = that.options,
  9574. cs = that.size,
  9575. os = that.originalSize,
  9576. op = that.originalPosition,
  9577. a = that.axis,
  9578. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  9579. gridX = (grid[0]||1),
  9580. gridY = (grid[1]||1),
  9581. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  9582. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  9583. newWidth = os.width + ox,
  9584. newHeight = os.height + oy,
  9585. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  9586. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  9587. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  9588. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  9589. o.grid = grid;
  9590. if (isMinWidth) {
  9591. newWidth = newWidth + gridX;
  9592. }
  9593. if (isMinHeight) {
  9594. newHeight = newHeight + gridY;
  9595. }
  9596. if (isMaxWidth) {
  9597. newWidth = newWidth - gridX;
  9598. }
  9599. if (isMaxHeight) {
  9600. newHeight = newHeight - gridY;
  9601. }
  9602. if (/^(se|s|e)$/.test(a)) {
  9603. that.size.width = newWidth;
  9604. that.size.height = newHeight;
  9605. } else if (/^(ne)$/.test(a)) {
  9606. that.size.width = newWidth;
  9607. that.size.height = newHeight;
  9608. that.position.top = op.top - oy;
  9609. } else if (/^(sw)$/.test(a)) {
  9610. that.size.width = newWidth;
  9611. that.size.height = newHeight;
  9612. that.position.left = op.left - ox;
  9613. } else {
  9614. if ( newHeight - gridY > 0 ) {
  9615. that.size.height = newHeight;
  9616. that.position.top = op.top - oy;
  9617. } else {
  9618. that.size.height = gridY;
  9619. that.position.top = op.top + os.height - gridY;
  9620. }
  9621. if ( newWidth - gridX > 0 ) {
  9622. that.size.width = newWidth;
  9623. that.position.left = op.left - ox;
  9624. } else {
  9625. that.size.width = gridX;
  9626. that.position.left = op.left + os.width - gridX;
  9627. }
  9628. }
  9629. }
  9630. });
  9631. })(jQuery);
  9632. (function( $, undefined ) {
  9633. $.widget("ui.selectable", $.ui.mouse, {
  9634. version: "1.10.4",
  9635. options: {
  9636. appendTo: "body",
  9637. autoRefresh: true,
  9638. distance: 0,
  9639. filter: "*",
  9640. tolerance: "touch",
  9641. // callbacks
  9642. selected: null,
  9643. selecting: null,
  9644. start: null,
  9645. stop: null,
  9646. unselected: null,
  9647. unselecting: null
  9648. },
  9649. _create: function() {
  9650. var selectees,
  9651. that = this;
  9652. this.element.addClass("ui-selectable");
  9653. this.dragged = false;
  9654. // cache selectee children based on filter
  9655. this.refresh = function() {
  9656. selectees = $(that.options.filter, that.element[0]);
  9657. selectees.addClass("ui-selectee");
  9658. selectees.each(function() {
  9659. var $this = $(this),
  9660. pos = $this.offset();
  9661. $.data(this, "selectable-item", {
  9662. element: this,
  9663. $element: $this,
  9664. left: pos.left,
  9665. top: pos.top,
  9666. right: pos.left + $this.outerWidth(),
  9667. bottom: pos.top + $this.outerHeight(),
  9668. startselected: false,
  9669. selected: $this.hasClass("ui-selected"),
  9670. selecting: $this.hasClass("ui-selecting"),
  9671. unselecting: $this.hasClass("ui-unselecting")
  9672. });
  9673. });
  9674. };
  9675. this.refresh();
  9676. this.selectees = selectees.addClass("ui-selectee");
  9677. this._mouseInit();
  9678. this.helper = $("<div class='ui-selectable-helper'></div>");
  9679. },
  9680. _destroy: function() {
  9681. this.selectees
  9682. .removeClass("ui-selectee")
  9683. .removeData("selectable-item");
  9684. this.element
  9685. .removeClass("ui-selectable ui-selectable-disabled");
  9686. this._mouseDestroy();
  9687. },
  9688. _mouseStart: function(event) {
  9689. var that = this,
  9690. options = this.options;
  9691. this.opos = [event.pageX, event.pageY];
  9692. if (this.options.disabled) {
  9693. return;
  9694. }
  9695. this.selectees = $(options.filter, this.element[0]);
  9696. this._trigger("start", event);
  9697. $(options.appendTo).append(this.helper);
  9698. // position helper (lasso)
  9699. this.helper.css({
  9700. "left": event.pageX,
  9701. "top": event.pageY,
  9702. "width": 0,
  9703. "height": 0
  9704. });
  9705. if (options.autoRefresh) {
  9706. this.refresh();
  9707. }
  9708. this.selectees.filter(".ui-selected").each(function() {
  9709. var selectee = $.data(this, "selectable-item");
  9710. selectee.startselected = true;
  9711. if (!event.metaKey && !event.ctrlKey) {
  9712. selectee.$element.removeClass("ui-selected");
  9713. selectee.selected = false;
  9714. selectee.$element.addClass("ui-unselecting");
  9715. selectee.unselecting = true;
  9716. // selectable UNSELECTING callback
  9717. that._trigger("unselecting", event, {
  9718. unselecting: selectee.element
  9719. });
  9720. }
  9721. });
  9722. $(event.target).parents().addBack().each(function() {
  9723. var doSelect,
  9724. selectee = $.data(this, "selectable-item");
  9725. if (selectee) {
  9726. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  9727. selectee.$element
  9728. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  9729. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  9730. selectee.unselecting = !doSelect;
  9731. selectee.selecting = doSelect;
  9732. selectee.selected = doSelect;
  9733. // selectable (UN)SELECTING callback
  9734. if (doSelect) {
  9735. that._trigger("selecting", event, {
  9736. selecting: selectee.element
  9737. });
  9738. } else {
  9739. that._trigger("unselecting", event, {
  9740. unselecting: selectee.element
  9741. });
  9742. }
  9743. return false;
  9744. }
  9745. });
  9746. },
  9747. _mouseDrag: function(event) {
  9748. this.dragged = true;
  9749. if (this.options.disabled) {
  9750. return;
  9751. }
  9752. var tmp,
  9753. that = this,
  9754. options = this.options,
  9755. x1 = this.opos[0],
  9756. y1 = this.opos[1],
  9757. x2 = event.pageX,
  9758. y2 = event.pageY;
  9759. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  9760. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  9761. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  9762. this.selectees.each(function() {
  9763. var selectee = $.data(this, "selectable-item"),
  9764. hit = false;
  9765. //prevent helper from being selected if appendTo: selectable
  9766. if (!selectee || selectee.element === that.element[0]) {
  9767. return;
  9768. }
  9769. if (options.tolerance === "touch") {
  9770. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  9771. } else if (options.tolerance === "fit") {
  9772. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  9773. }
  9774. if (hit) {
  9775. // SELECT
  9776. if (selectee.selected) {
  9777. selectee.$element.removeClass("ui-selected");
  9778. selectee.selected = false;
  9779. }
  9780. if (selectee.unselecting) {
  9781. selectee.$element.removeClass("ui-unselecting");
  9782. selectee.unselecting = false;
  9783. }
  9784. if (!selectee.selecting) {
  9785. selectee.$element.addClass("ui-selecting");
  9786. selectee.selecting = true;
  9787. // selectable SELECTING callback
  9788. that._trigger("selecting", event, {
  9789. selecting: selectee.element
  9790. });
  9791. }
  9792. } else {
  9793. // UNSELECT
  9794. if (selectee.selecting) {
  9795. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  9796. selectee.$element.removeClass("ui-selecting");
  9797. selectee.selecting = false;
  9798. selectee.$element.addClass("ui-selected");
  9799. selectee.selected = true;
  9800. } else {
  9801. selectee.$element.removeClass("ui-selecting");
  9802. selectee.selecting = false;
  9803. if (selectee.startselected) {
  9804. selectee.$element.addClass("ui-unselecting");
  9805. selectee.unselecting = true;
  9806. }
  9807. // selectable UNSELECTING callback
  9808. that._trigger("unselecting", event, {
  9809. unselecting: selectee.element
  9810. });
  9811. }
  9812. }
  9813. if (selectee.selected) {
  9814. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  9815. selectee.$element.removeClass("ui-selected");
  9816. selectee.selected = false;
  9817. selectee.$element.addClass("ui-unselecting");
  9818. selectee.unselecting = true;
  9819. // selectable UNSELECTING callback
  9820. that._trigger("unselecting", event, {
  9821. unselecting: selectee.element
  9822. });
  9823. }
  9824. }
  9825. }
  9826. });
  9827. return false;
  9828. },
  9829. _mouseStop: function(event) {
  9830. var that = this;
  9831. this.dragged = false;
  9832. $(".ui-unselecting", this.element[0]).each(function() {
  9833. var selectee = $.data(this, "selectable-item");
  9834. selectee.$element.removeClass("ui-unselecting");
  9835. selectee.unselecting = false;
  9836. selectee.startselected = false;
  9837. that._trigger("unselected", event, {
  9838. unselected: selectee.element
  9839. });
  9840. });
  9841. $(".ui-selecting", this.element[0]).each(function() {
  9842. var selectee = $.data(this, "selectable-item");
  9843. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  9844. selectee.selecting = false;
  9845. selectee.selected = true;
  9846. selectee.startselected = true;
  9847. that._trigger("selected", event, {
  9848. selected: selectee.element
  9849. });
  9850. });
  9851. this._trigger("stop", event);
  9852. this.helper.remove();
  9853. return false;
  9854. }
  9855. });
  9856. })(jQuery);
  9857. (function( $, undefined ) {
  9858. // number of pages in a slider
  9859. // (how many times can you page up/down to go through the whole range)
  9860. var numPages = 5;
  9861. $.widget( "ui.slider", $.ui.mouse, {
  9862. version: "1.10.4",
  9863. widgetEventPrefix: "slide",
  9864. options: {
  9865. animate: false,
  9866. distance: 0,
  9867. max: 100,
  9868. min: 0,
  9869. orientation: "horizontal",
  9870. range: false,
  9871. step: 1,
  9872. value: 0,
  9873. values: null,
  9874. // callbacks
  9875. change: null,
  9876. slide: null,
  9877. start: null,
  9878. stop: null
  9879. },
  9880. _create: function() {
  9881. this._keySliding = false;
  9882. this._mouseSliding = false;
  9883. this._animateOff = true;
  9884. this._handleIndex = null;
  9885. this._detectOrientation();
  9886. this._mouseInit();
  9887. this.element
  9888. .addClass( "ui-slider" +
  9889. " ui-slider-" + this.orientation +
  9890. " ui-widget" +
  9891. " ui-widget-content" +
  9892. " ui-corner-all");
  9893. this._refresh();
  9894. this._setOption( "disabled", this.options.disabled );
  9895. this._animateOff = false;
  9896. },
  9897. _refresh: function() {
  9898. this._createRange();
  9899. this._createHandles();
  9900. this._setupEvents();
  9901. this._refreshValue();
  9902. },
  9903. _createHandles: function() {
  9904. var i, handleCount,
  9905. options = this.options,
  9906. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  9907. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  9908. handles = [];
  9909. handleCount = ( options.values && options.values.length ) || 1;
  9910. if ( existingHandles.length > handleCount ) {
  9911. existingHandles.slice( handleCount ).remove();
  9912. existingHandles = existingHandles.slice( 0, handleCount );
  9913. }
  9914. for ( i = existingHandles.length; i < handleCount; i++ ) {
  9915. handles.push( handle );
  9916. }
  9917. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  9918. this.handle = this.handles.eq( 0 );
  9919. this.handles.each(function( i ) {
  9920. $( this ).data( "ui-slider-handle-index", i );
  9921. });
  9922. },
  9923. _createRange: function() {
  9924. var options = this.options,
  9925. classes = "";
  9926. if ( options.range ) {
  9927. if ( options.range === true ) {
  9928. if ( !options.values ) {
  9929. options.values = [ this._valueMin(), this._valueMin() ];
  9930. } else if ( options.values.length && options.values.length !== 2 ) {
  9931. options.values = [ options.values[0], options.values[0] ];
  9932. } else if ( $.isArray( options.values ) ) {
  9933. options.values = options.values.slice(0);
  9934. }
  9935. }
  9936. if ( !this.range || !this.range.length ) {
  9937. this.range = $( "<div></div>" )
  9938. .appendTo( this.element );
  9939. classes = "ui-slider-range" +
  9940. // note: this isn't the most fittingly semantic framework class for this element,
  9941. // but worked best visually with a variety of themes
  9942. " ui-widget-header ui-corner-all";
  9943. } else {
  9944. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  9945. // Handle range switching from true to min/max
  9946. .css({
  9947. "left": "",
  9948. "bottom": ""
  9949. });
  9950. }
  9951. this.range.addClass( classes +
  9952. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  9953. } else {
  9954. if ( this.range ) {
  9955. this.range.remove();
  9956. }
  9957. this.range = null;
  9958. }
  9959. },
  9960. _setupEvents: function() {
  9961. var elements = this.handles.add( this.range ).filter( "a" );
  9962. this._off( elements );
  9963. this._on( elements, this._handleEvents );
  9964. this._hoverable( elements );
  9965. this._focusable( elements );
  9966. },
  9967. _destroy: function() {
  9968. this.handles.remove();
  9969. if ( this.range ) {
  9970. this.range.remove();
  9971. }
  9972. this.element
  9973. .removeClass( "ui-slider" +
  9974. " ui-slider-horizontal" +
  9975. " ui-slider-vertical" +
  9976. " ui-widget" +
  9977. " ui-widget-content" +
  9978. " ui-corner-all" );
  9979. this._mouseDestroy();
  9980. },
  9981. _mouseCapture: function( event ) {
  9982. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  9983. that = this,
  9984. o = this.options;
  9985. if ( o.disabled ) {
  9986. return false;
  9987. }
  9988. this.elementSize = {
  9989. width: this.element.outerWidth(),
  9990. height: this.element.outerHeight()
  9991. };
  9992. this.elementOffset = this.element.offset();
  9993. position = { x: event.pageX, y: event.pageY };
  9994. normValue = this._normValueFromMouse( position );
  9995. distance = this._valueMax() - this._valueMin() + 1;
  9996. this.handles.each(function( i ) {
  9997. var thisDistance = Math.abs( normValue - that.values(i) );
  9998. if (( distance > thisDistance ) ||
  9999. ( distance === thisDistance &&
  10000. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10001. distance = thisDistance;
  10002. closestHandle = $( this );
  10003. index = i;
  10004. }
  10005. });
  10006. allowed = this._start( event, index );
  10007. if ( allowed === false ) {
  10008. return false;
  10009. }
  10010. this._mouseSliding = true;
  10011. this._handleIndex = index;
  10012. closestHandle
  10013. .addClass( "ui-state-active" )
  10014. .focus();
  10015. offset = closestHandle.offset();
  10016. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10017. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10018. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10019. top: event.pageY - offset.top -
  10020. ( closestHandle.height() / 2 ) -
  10021. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  10022. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  10023. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  10024. };
  10025. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  10026. this._slide( event, index, normValue );
  10027. }
  10028. this._animateOff = true;
  10029. return true;
  10030. },
  10031. _mouseStart: function() {
  10032. return true;
  10033. },
  10034. _mouseDrag: function( event ) {
  10035. var position = { x: event.pageX, y: event.pageY },
  10036. normValue = this._normValueFromMouse( position );
  10037. this._slide( event, this._handleIndex, normValue );
  10038. return false;
  10039. },
  10040. _mouseStop: function( event ) {
  10041. this.handles.removeClass( "ui-state-active" );
  10042. this._mouseSliding = false;
  10043. this._stop( event, this._handleIndex );
  10044. this._change( event, this._handleIndex );
  10045. this._handleIndex = null;
  10046. this._clickOffset = null;
  10047. this._animateOff = false;
  10048. return false;
  10049. },
  10050. _detectOrientation: function() {
  10051. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  10052. },
  10053. _normValueFromMouse: function( position ) {
  10054. var pixelTotal,
  10055. pixelMouse,
  10056. percentMouse,
  10057. valueTotal,
  10058. valueMouse;
  10059. if ( this.orientation === "horizontal" ) {
  10060. pixelTotal = this.elementSize.width;
  10061. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  10062. } else {
  10063. pixelTotal = this.elementSize.height;
  10064. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  10065. }
  10066. percentMouse = ( pixelMouse / pixelTotal );
  10067. if ( percentMouse > 1 ) {
  10068. percentMouse = 1;
  10069. }
  10070. if ( percentMouse < 0 ) {
  10071. percentMouse = 0;
  10072. }
  10073. if ( this.orientation === "vertical" ) {
  10074. percentMouse = 1 - percentMouse;
  10075. }
  10076. valueTotal = this._valueMax() - this._valueMin();
  10077. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10078. return this._trimAlignValue( valueMouse );
  10079. },
  10080. _start: function( event, index ) {
  10081. var uiHash = {
  10082. handle: this.handles[ index ],
  10083. value: this.value()
  10084. };
  10085. if ( this.options.values && this.options.values.length ) {
  10086. uiHash.value = this.values( index );
  10087. uiHash.values = this.values();
  10088. }
  10089. return this._trigger( "start", event, uiHash );
  10090. },
  10091. _slide: function( event, index, newVal ) {
  10092. var otherVal,
  10093. newValues,
  10094. allowed;
  10095. if ( this.options.values && this.options.values.length ) {
  10096. otherVal = this.values( index ? 0 : 1 );
  10097. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  10098. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  10099. ) {
  10100. newVal = otherVal;
  10101. }
  10102. if ( newVal !== this.values( index ) ) {
  10103. newValues = this.values();
  10104. newValues[ index ] = newVal;
  10105. // A slide can be canceled by returning false from the slide callback
  10106. allowed = this._trigger( "slide", event, {
  10107. handle: this.handles[ index ],
  10108. value: newVal,
  10109. values: newValues
  10110. } );
  10111. otherVal = this.values( index ? 0 : 1 );
  10112. if ( allowed !== false ) {
  10113. this.values( index, newVal );
  10114. }
  10115. }
  10116. } else {
  10117. if ( newVal !== this.value() ) {
  10118. // A slide can be canceled by returning false from the slide callback
  10119. allowed = this._trigger( "slide", event, {
  10120. handle: this.handles[ index ],
  10121. value: newVal
  10122. } );
  10123. if ( allowed !== false ) {
  10124. this.value( newVal );
  10125. }
  10126. }
  10127. }
  10128. },
  10129. _stop: function( event, index ) {
  10130. var uiHash = {
  10131. handle: this.handles[ index ],
  10132. value: this.value()
  10133. };
  10134. if ( this.options.values && this.options.values.length ) {
  10135. uiHash.value = this.values( index );
  10136. uiHash.values = this.values();
  10137. }
  10138. this._trigger( "stop", event, uiHash );
  10139. },
  10140. _change: function( event, index ) {
  10141. if ( !this._keySliding && !this._mouseSliding ) {
  10142. var uiHash = {
  10143. handle: this.handles[ index ],
  10144. value: this.value()
  10145. };
  10146. if ( this.options.values && this.options.values.length ) {
  10147. uiHash.value = this.values( index );
  10148. uiHash.values = this.values();
  10149. }
  10150. //store the last changed value index for reference when handles overlap
  10151. this._lastChangedValue = index;
  10152. this._trigger( "change", event, uiHash );
  10153. }
  10154. },
  10155. value: function( newValue ) {
  10156. if ( arguments.length ) {
  10157. this.options.value = this._trimAlignValue( newValue );
  10158. this._refreshValue();
  10159. this._change( null, 0 );
  10160. return;
  10161. }
  10162. return this._value();
  10163. },
  10164. values: function( index, newValue ) {
  10165. var vals,
  10166. newValues,
  10167. i;
  10168. if ( arguments.length > 1 ) {
  10169. this.options.values[ index ] = this._trimAlignValue( newValue );
  10170. this._refreshValue();
  10171. this._change( null, index );
  10172. return;
  10173. }
  10174. if ( arguments.length ) {
  10175. if ( $.isArray( arguments[ 0 ] ) ) {
  10176. vals = this.options.values;
  10177. newValues = arguments[ 0 ];
  10178. for ( i = 0; i < vals.length; i += 1 ) {
  10179. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  10180. this._change( null, i );
  10181. }
  10182. this._refreshValue();
  10183. } else {
  10184. if ( this.options.values && this.options.values.length ) {
  10185. return this._values( index );
  10186. } else {
  10187. return this.value();
  10188. }
  10189. }
  10190. } else {
  10191. return this._values();
  10192. }
  10193. },
  10194. _setOption: function( key, value ) {
  10195. var i,
  10196. valsLength = 0;
  10197. if ( key === "range" && this.options.range === true ) {
  10198. if ( value === "min" ) {
  10199. this.options.value = this._values( 0 );
  10200. this.options.values = null;
  10201. } else if ( value === "max" ) {
  10202. this.options.value = this._values( this.options.values.length-1 );
  10203. this.options.values = null;
  10204. }
  10205. }
  10206. if ( $.isArray( this.options.values ) ) {
  10207. valsLength = this.options.values.length;
  10208. }
  10209. $.Widget.prototype._setOption.apply( this, arguments );
  10210. switch ( key ) {
  10211. case "orientation":
  10212. this._detectOrientation();
  10213. this.element
  10214. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  10215. .addClass( "ui-slider-" + this.orientation );
  10216. this._refreshValue();
  10217. break;
  10218. case "value":
  10219. this._animateOff = true;
  10220. this._refreshValue();
  10221. this._change( null, 0 );
  10222. this._animateOff = false;
  10223. break;
  10224. case "values":
  10225. this._animateOff = true;
  10226. this._refreshValue();
  10227. for ( i = 0; i < valsLength; i += 1 ) {
  10228. this._change( null, i );
  10229. }
  10230. this._animateOff = false;
  10231. break;
  10232. case "min":
  10233. case "max":
  10234. this._animateOff = true;
  10235. this._refreshValue();
  10236. this._animateOff = false;
  10237. break;
  10238. case "range":
  10239. this._animateOff = true;
  10240. this._refresh();
  10241. this._animateOff = false;
  10242. break;
  10243. }
  10244. },
  10245. //internal value getter
  10246. // _value() returns value trimmed by min and max, aligned by step
  10247. _value: function() {
  10248. var val = this.options.value;
  10249. val = this._trimAlignValue( val );
  10250. return val;
  10251. },
  10252. //internal values getter
  10253. // _values() returns array of values trimmed by min and max, aligned by step
  10254. // _values( index ) returns single value trimmed by min and max, aligned by step
  10255. _values: function( index ) {
  10256. var val,
  10257. vals,
  10258. i;
  10259. if ( arguments.length ) {
  10260. val = this.options.values[ index ];
  10261. val = this._trimAlignValue( val );
  10262. return val;
  10263. } else if ( this.options.values && this.options.values.length ) {
  10264. // .slice() creates a copy of the array
  10265. // this copy gets trimmed by min and max and then returned
  10266. vals = this.options.values.slice();
  10267. for ( i = 0; i < vals.length; i+= 1) {
  10268. vals[ i ] = this._trimAlignValue( vals[ i ] );
  10269. }
  10270. return vals;
  10271. } else {
  10272. return [];
  10273. }
  10274. },
  10275. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  10276. _trimAlignValue: function( val ) {
  10277. if ( val <= this._valueMin() ) {
  10278. return this._valueMin();
  10279. }
  10280. if ( val >= this._valueMax() ) {
  10281. return this._valueMax();
  10282. }
  10283. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  10284. valModStep = (val - this._valueMin()) % step,
  10285. alignValue = val - valModStep;
  10286. if ( Math.abs(valModStep) * 2 >= step ) {
  10287. alignValue += ( valModStep > 0 ) ? step : ( -step );
  10288. }
  10289. // Since JavaScript has problems with large floats, round
  10290. // the final value to 5 digits after the decimal point (see #4124)
  10291. return parseFloat( alignValue.toFixed(5) );
  10292. },
  10293. _valueMin: function() {
  10294. return this.options.min;
  10295. },
  10296. _valueMax: function() {
  10297. return this.options.max;
  10298. },
  10299. _refreshValue: function() {
  10300. var lastValPercent, valPercent, value, valueMin, valueMax,
  10301. oRange = this.options.range,
  10302. o = this.options,
  10303. that = this,
  10304. animate = ( !this._animateOff ) ? o.animate : false,
  10305. _set = {};
  10306. if ( this.options.values && this.options.values.length ) {
  10307. this.handles.each(function( i ) {
  10308. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  10309. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10310. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10311. if ( that.options.range === true ) {
  10312. if ( that.orientation === "horizontal" ) {
  10313. if ( i === 0 ) {
  10314. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  10315. }
  10316. if ( i === 1 ) {
  10317. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10318. }
  10319. } else {
  10320. if ( i === 0 ) {
  10321. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  10322. }
  10323. if ( i === 1 ) {
  10324. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10325. }
  10326. }
  10327. }
  10328. lastValPercent = valPercent;
  10329. });
  10330. } else {
  10331. value = this.value();
  10332. valueMin = this._valueMin();
  10333. valueMax = this._valueMax();
  10334. valPercent = ( valueMax !== valueMin ) ?
  10335. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  10336. 0;
  10337. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10338. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10339. if ( oRange === "min" && this.orientation === "horizontal" ) {
  10340. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  10341. }
  10342. if ( oRange === "max" && this.orientation === "horizontal" ) {
  10343. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10344. }
  10345. if ( oRange === "min" && this.orientation === "vertical" ) {
  10346. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  10347. }
  10348. if ( oRange === "max" && this.orientation === "vertical" ) {
  10349. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10350. }
  10351. }
  10352. },
  10353. _handleEvents: {
  10354. keydown: function( event ) {
  10355. var allowed, curVal, newVal, step,
  10356. index = $( event.target ).data( "ui-slider-handle-index" );
  10357. switch ( event.keyCode ) {
  10358. case $.ui.keyCode.HOME:
  10359. case $.ui.keyCode.END:
  10360. case $.ui.keyCode.PAGE_UP:
  10361. case $.ui.keyCode.PAGE_DOWN:
  10362. case $.ui.keyCode.UP:
  10363. case $.ui.keyCode.RIGHT:
  10364. case $.ui.keyCode.DOWN:
  10365. case $.ui.keyCode.LEFT:
  10366. event.preventDefault();
  10367. if ( !this._keySliding ) {
  10368. this._keySliding = true;
  10369. $( event.target ).addClass( "ui-state-active" );
  10370. allowed = this._start( event, index );
  10371. if ( allowed === false ) {
  10372. return;
  10373. }
  10374. }
  10375. break;
  10376. }
  10377. step = this.options.step;
  10378. if ( this.options.values && this.options.values.length ) {
  10379. curVal = newVal = this.values( index );
  10380. } else {
  10381. curVal = newVal = this.value();
  10382. }
  10383. switch ( event.keyCode ) {
  10384. case $.ui.keyCode.HOME:
  10385. newVal = this._valueMin();
  10386. break;
  10387. case $.ui.keyCode.END:
  10388. newVal = this._valueMax();
  10389. break;
  10390. case $.ui.keyCode.PAGE_UP:
  10391. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  10392. break;
  10393. case $.ui.keyCode.PAGE_DOWN:
  10394. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  10395. break;
  10396. case $.ui.keyCode.UP:
  10397. case $.ui.keyCode.RIGHT:
  10398. if ( curVal === this._valueMax() ) {
  10399. return;
  10400. }
  10401. newVal = this._trimAlignValue( curVal + step );
  10402. break;
  10403. case $.ui.keyCode.DOWN:
  10404. case $.ui.keyCode.LEFT:
  10405. if ( curVal === this._valueMin() ) {
  10406. return;
  10407. }
  10408. newVal = this._trimAlignValue( curVal - step );
  10409. break;
  10410. }
  10411. this._slide( event, index, newVal );
  10412. },
  10413. click: function( event ) {
  10414. event.preventDefault();
  10415. },
  10416. keyup: function( event ) {
  10417. var index = $( event.target ).data( "ui-slider-handle-index" );
  10418. if ( this._keySliding ) {
  10419. this._keySliding = false;
  10420. this._stop( event, index );
  10421. this._change( event, index );
  10422. $( event.target ).removeClass( "ui-state-active" );
  10423. }
  10424. }
  10425. }
  10426. });
  10427. }(jQuery));
  10428. (function( $, undefined ) {
  10429. function isOverAxis( x, reference, size ) {
  10430. return ( x > reference ) && ( x < ( reference + size ) );
  10431. }
  10432. function isFloating(item) {
  10433. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  10434. }
  10435. $.widget("ui.sortable", $.ui.mouse, {
  10436. version: "1.10.4",
  10437. widgetEventPrefix: "sort",
  10438. ready: false,
  10439. options: {
  10440. appendTo: "parent",
  10441. axis: false,
  10442. connectWith: false,
  10443. containment: false,
  10444. cursor: "auto",
  10445. cursorAt: false,
  10446. dropOnEmpty: true,
  10447. forcePlaceholderSize: false,
  10448. forceHelperSize: false,
  10449. grid: false,
  10450. handle: false,
  10451. helper: "original",
  10452. items: "> *",
  10453. opacity: false,
  10454. placeholder: false,
  10455. revert: false,
  10456. scroll: true,
  10457. scrollSensitivity: 20,
  10458. scrollSpeed: 20,
  10459. scope: "default",
  10460. tolerance: "intersect",
  10461. zIndex: 1000,
  10462. // callbacks
  10463. activate: null,
  10464. beforeStop: null,
  10465. change: null,
  10466. deactivate: null,
  10467. out: null,
  10468. over: null,
  10469. receive: null,
  10470. remove: null,
  10471. sort: null,
  10472. start: null,
  10473. stop: null,
  10474. update: null
  10475. },
  10476. _create: function() {
  10477. var o = this.options;
  10478. this.containerCache = {};
  10479. this.element.addClass("ui-sortable");
  10480. //Get the items
  10481. this.refresh();
  10482. //Let's determine if the items are being displayed horizontally
  10483. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  10484. //Let's determine the parent's offset
  10485. this.offset = this.element.offset();
  10486. //Initialize mouse events for interaction
  10487. this._mouseInit();
  10488. //We're ready to go
  10489. this.ready = true;
  10490. },
  10491. _destroy: function() {
  10492. this.element
  10493. .removeClass("ui-sortable ui-sortable-disabled");
  10494. this._mouseDestroy();
  10495. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  10496. this.items[i].item.removeData(this.widgetName + "-item");
  10497. }
  10498. return this;
  10499. },
  10500. _setOption: function(key, value){
  10501. if ( key === "disabled" ) {
  10502. this.options[ key ] = value;
  10503. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  10504. } else {
  10505. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  10506. $.Widget.prototype._setOption.apply(this, arguments);
  10507. }
  10508. },
  10509. _mouseCapture: function(event, overrideHandle) {
  10510. var currentItem = null,
  10511. validHandle = false,
  10512. that = this;
  10513. if (this.reverting) {
  10514. return false;
  10515. }
  10516. if(this.options.disabled || this.options.type === "static") {
  10517. return false;
  10518. }
  10519. //We have to refresh the items data once first
  10520. this._refreshItems(event);
  10521. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  10522. $(event.target).parents().each(function() {
  10523. if($.data(this, that.widgetName + "-item") === that) {
  10524. currentItem = $(this);
  10525. return false;
  10526. }
  10527. });
  10528. if($.data(event.target, that.widgetName + "-item") === that) {
  10529. currentItem = $(event.target);
  10530. }
  10531. if(!currentItem) {
  10532. return false;
  10533. }
  10534. if(this.options.handle && !overrideHandle) {
  10535. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  10536. if(this === event.target) {
  10537. validHandle = true;
  10538. }
  10539. });
  10540. if(!validHandle) {
  10541. return false;
  10542. }
  10543. }
  10544. this.currentItem = currentItem;
  10545. this._removeCurrentsFromItems();
  10546. return true;
  10547. },
  10548. _mouseStart: function(event, overrideHandle, noActivation) {
  10549. var i, body,
  10550. o = this.options;
  10551. this.currentContainer = this;
  10552. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  10553. this.refreshPositions();
  10554. //Create and append the visible helper
  10555. this.helper = this._createHelper(event);
  10556. //Cache the helper size
  10557. this._cacheHelperProportions();
  10558. /*
  10559. * - Position generation -
  10560. * This block generates everything position related - it's the core of draggables.
  10561. */
  10562. //Cache the margins of the original element
  10563. this._cacheMargins();
  10564. //Get the next scrolling parent
  10565. this.scrollParent = this.helper.scrollParent();
  10566. //The element's absolute position on the page minus margins
  10567. this.offset = this.currentItem.offset();
  10568. this.offset = {
  10569. top: this.offset.top - this.margins.top,
  10570. left: this.offset.left - this.margins.left
  10571. };
  10572. $.extend(this.offset, {
  10573. click: { //Where the click happened, relative to the element
  10574. left: event.pageX - this.offset.left,
  10575. top: event.pageY - this.offset.top
  10576. },
  10577. parent: this._getParentOffset(),
  10578. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  10579. });
  10580. // Only after we got the offset, we can change the helper's position to absolute
  10581. // TODO: Still need to figure out a way to make relative sorting possible
  10582. this.helper.css("position", "absolute");
  10583. this.cssPosition = this.helper.css("position");
  10584. //Generate the original position
  10585. this.originalPosition = this._generatePosition(event);
  10586. this.originalPageX = event.pageX;
  10587. this.originalPageY = event.pageY;
  10588. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  10589. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  10590. //Cache the former DOM position
  10591. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  10592. //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
  10593. if(this.helper[0] !== this.currentItem[0]) {
  10594. this.currentItem.hide();
  10595. }
  10596. //Create the placeholder
  10597. this._createPlaceholder();
  10598. //Set a containment if given in the options
  10599. if(o.containment) {
  10600. this._setContainment();
  10601. }
  10602. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  10603. body = this.document.find( "body" );
  10604. // support: IE
  10605. this.storedCursor = body.css( "cursor" );
  10606. body.css( "cursor", o.cursor );
  10607. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  10608. }
  10609. if(o.opacity) { // opacity option
  10610. if (this.helper.css("opacity")) {
  10611. this._storedOpacity = this.helper.css("opacity");
  10612. }
  10613. this.helper.css("opacity", o.opacity);
  10614. }
  10615. if(o.zIndex) { // zIndex option
  10616. if (this.helper.css("zIndex")) {
  10617. this._storedZIndex = this.helper.css("zIndex");
  10618. }
  10619. this.helper.css("zIndex", o.zIndex);
  10620. }
  10621. //Prepare scrolling
  10622. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  10623. this.overflowOffset = this.scrollParent.offset();
  10624. }
  10625. //Call callbacks
  10626. this._trigger("start", event, this._uiHash());
  10627. //Recache the helper size
  10628. if(!this._preserveHelperProportions) {
  10629. this._cacheHelperProportions();
  10630. }
  10631. //Post "activate" events to possible containers
  10632. if( !noActivation ) {
  10633. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  10634. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  10635. }
  10636. }
  10637. //Prepare possible droppables
  10638. if($.ui.ddmanager) {
  10639. $.ui.ddmanager.current = this;
  10640. }
  10641. if ($.ui.ddmanager && !o.dropBehaviour) {
  10642. $.ui.ddmanager.prepareOffsets(this, event);
  10643. }
  10644. this.dragging = true;
  10645. this.helper.addClass("ui-sortable-helper");
  10646. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  10647. return true;
  10648. },
  10649. _mouseDrag: function(event) {
  10650. var i, item, itemElement, intersection,
  10651. o = this.options,
  10652. scrolled = false;
  10653. //Compute the helpers position
  10654. this.position = this._generatePosition(event);
  10655. this.positionAbs = this._convertPositionTo("absolute");
  10656. if (!this.lastPositionAbs) {
  10657. this.lastPositionAbs = this.positionAbs;
  10658. }
  10659. //Do scrolling
  10660. if(this.options.scroll) {
  10661. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  10662. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  10663. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  10664. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  10665. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  10666. }
  10667. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  10668. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  10669. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  10670. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  10671. }
  10672. } else {
  10673. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  10674. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  10675. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  10676. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  10677. }
  10678. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  10679. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  10680. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  10681. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  10682. }
  10683. }
  10684. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  10685. $.ui.ddmanager.prepareOffsets(this, event);
  10686. }
  10687. }
  10688. //Regenerate the absolute position used for position checks
  10689. this.positionAbs = this._convertPositionTo("absolute");
  10690. //Set the helper position
  10691. if(!this.options.axis || this.options.axis !== "y") {
  10692. this.helper[0].style.left = this.position.left+"px";
  10693. }
  10694. if(!this.options.axis || this.options.axis !== "x") {
  10695. this.helper[0].style.top = this.position.top+"px";
  10696. }
  10697. //Rearrange
  10698. for (i = this.items.length - 1; i >= 0; i--) {
  10699. //Cache variables and intersection, continue if no intersection
  10700. item = this.items[i];
  10701. itemElement = item.item[0];
  10702. intersection = this._intersectsWithPointer(item);
  10703. if (!intersection) {
  10704. continue;
  10705. }
  10706. // Only put the placeholder inside the current Container, skip all
  10707. // items from other containers. This works because when moving
  10708. // an item from one container to another the
  10709. // currentContainer is switched before the placeholder is moved.
  10710. //
  10711. // Without this, moving items in "sub-sortables" can cause
  10712. // the placeholder to jitter beetween the outer and inner container.
  10713. if (item.instance !== this.currentContainer) {
  10714. continue;
  10715. }
  10716. // cannot intersect with itself
  10717. // no useless actions that have been done before
  10718. // no action if the item moved is the parent of the item checked
  10719. if (itemElement !== this.currentItem[0] &&
  10720. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  10721. !$.contains(this.placeholder[0], itemElement) &&
  10722. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  10723. ) {
  10724. this.direction = intersection === 1 ? "down" : "up";
  10725. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  10726. this._rearrange(event, item);
  10727. } else {
  10728. break;
  10729. }
  10730. this._trigger("change", event, this._uiHash());
  10731. break;
  10732. }
  10733. }
  10734. //Post events to containers
  10735. this._contactContainers(event);
  10736. //Interconnect with droppables
  10737. if($.ui.ddmanager) {
  10738. $.ui.ddmanager.drag(this, event);
  10739. }
  10740. //Call callbacks
  10741. this._trigger("sort", event, this._uiHash());
  10742. this.lastPositionAbs = this.positionAbs;
  10743. return false;
  10744. },
  10745. _mouseStop: function(event, noPropagation) {
  10746. if(!event) {
  10747. return;
  10748. }
  10749. //If we are using droppables, inform the manager about the drop
  10750. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  10751. $.ui.ddmanager.drop(this, event);
  10752. }
  10753. if(this.options.revert) {
  10754. var that = this,
  10755. cur = this.placeholder.offset(),
  10756. axis = this.options.axis,
  10757. animation = {};
  10758. if ( !axis || axis === "x" ) {
  10759. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  10760. }
  10761. if ( !axis || axis === "y" ) {
  10762. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  10763. }
  10764. this.reverting = true;
  10765. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  10766. that._clear(event);
  10767. });
  10768. } else {
  10769. this._clear(event, noPropagation);
  10770. }
  10771. return false;
  10772. },
  10773. cancel: function() {
  10774. if(this.dragging) {
  10775. this._mouseUp({ target: null });
  10776. if(this.options.helper === "original") {
  10777. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  10778. } else {
  10779. this.currentItem.show();
  10780. }
  10781. //Post deactivating events to containers
  10782. for (var i = this.containers.length - 1; i >= 0; i--){
  10783. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  10784. if(this.containers[i].containerCache.over) {
  10785. this.containers[i]._trigger("out", null, this._uiHash(this));
  10786. this.containers[i].containerCache.over = 0;
  10787. }
  10788. }
  10789. }
  10790. if (this.placeholder) {
  10791. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  10792. if(this.placeholder[0].parentNode) {
  10793. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  10794. }
  10795. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  10796. this.helper.remove();
  10797. }
  10798. $.extend(this, {
  10799. helper: null,
  10800. dragging: false,
  10801. reverting: false,
  10802. _noFinalSort: null
  10803. });
  10804. if(this.domPosition.prev) {
  10805. $(this.domPosition.prev).after(this.currentItem);
  10806. } else {
  10807. $(this.domPosition.parent).prepend(this.currentItem);
  10808. }
  10809. }
  10810. return this;
  10811. },
  10812. serialize: function(o) {
  10813. var items = this._getItemsAsjQuery(o && o.connected),
  10814. str = [];
  10815. o = o || {};
  10816. $(items).each(function() {
  10817. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  10818. if (res) {
  10819. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  10820. }
  10821. });
  10822. if(!str.length && o.key) {
  10823. str.push(o.key + "=");
  10824. }
  10825. return str.join("&");
  10826. },
  10827. toArray: function(o) {
  10828. var items = this._getItemsAsjQuery(o && o.connected),
  10829. ret = [];
  10830. o = o || {};
  10831. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  10832. return ret;
  10833. },
  10834. /* Be careful with the following core functions */
  10835. _intersectsWith: function(item) {
  10836. var x1 = this.positionAbs.left,
  10837. x2 = x1 + this.helperProportions.width,
  10838. y1 = this.positionAbs.top,
  10839. y2 = y1 + this.helperProportions.height,
  10840. l = item.left,
  10841. r = l + item.width,
  10842. t = item.top,
  10843. b = t + item.height,
  10844. dyClick = this.offset.click.top,
  10845. dxClick = this.offset.click.left,
  10846. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  10847. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  10848. isOverElement = isOverElementHeight && isOverElementWidth;
  10849. if ( this.options.tolerance === "pointer" ||
  10850. this.options.forcePointerForContainers ||
  10851. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  10852. ) {
  10853. return isOverElement;
  10854. } else {
  10855. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  10856. x2 - (this.helperProportions.width / 2) < r && // Left Half
  10857. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  10858. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  10859. }
  10860. },
  10861. _intersectsWithPointer: function(item) {
  10862. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  10863. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  10864. isOverElement = isOverElementHeight && isOverElementWidth,
  10865. verticalDirection = this._getDragVerticalDirection(),
  10866. horizontalDirection = this._getDragHorizontalDirection();
  10867. if (!isOverElement) {
  10868. return false;
  10869. }
  10870. return this.floating ?
  10871. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  10872. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  10873. },
  10874. _intersectsWithSides: function(item) {
  10875. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  10876. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  10877. verticalDirection = this._getDragVerticalDirection(),
  10878. horizontalDirection = this._getDragHorizontalDirection();
  10879. if (this.floating && horizontalDirection) {
  10880. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  10881. } else {
  10882. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  10883. }
  10884. },
  10885. _getDragVerticalDirection: function() {
  10886. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  10887. return delta !== 0 && (delta > 0 ? "down" : "up");
  10888. },
  10889. _getDragHorizontalDirection: function() {
  10890. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  10891. return delta !== 0 && (delta > 0 ? "right" : "left");
  10892. },
  10893. refresh: function(event) {
  10894. this._refreshItems(event);
  10895. this.refreshPositions();
  10896. return this;
  10897. },
  10898. _connectWith: function() {
  10899. var options = this.options;
  10900. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  10901. },
  10902. _getItemsAsjQuery: function(connected) {
  10903. var i, j, cur, inst,
  10904. items = [],
  10905. queries = [],
  10906. connectWith = this._connectWith();
  10907. if(connectWith && connected) {
  10908. for (i = connectWith.length - 1; i >= 0; i--){
  10909. cur = $(connectWith[i]);
  10910. for ( j = cur.length - 1; j >= 0; j--){
  10911. inst = $.data(cur[j], this.widgetFullName);
  10912. if(inst && inst !== this && !inst.options.disabled) {
  10913. 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]);
  10914. }
  10915. }
  10916. }
  10917. }
  10918. 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]);
  10919. function addItems() {
  10920. items.push( this );
  10921. }
  10922. for (i = queries.length - 1; i >= 0; i--){
  10923. queries[i][0].each( addItems );
  10924. }
  10925. return $(items);
  10926. },
  10927. _removeCurrentsFromItems: function() {
  10928. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  10929. this.items = $.grep(this.items, function (item) {
  10930. for (var j=0; j < list.length; j++) {
  10931. if(list[j] === item.item[0]) {
  10932. return false;
  10933. }
  10934. }
  10935. return true;
  10936. });
  10937. },
  10938. _refreshItems: function(event) {
  10939. this.items = [];
  10940. this.containers = [this];
  10941. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  10942. items = this.items,
  10943. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  10944. connectWith = this._connectWith();
  10945. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  10946. for (i = connectWith.length - 1; i >= 0; i--){
  10947. cur = $(connectWith[i]);
  10948. for (j = cur.length - 1; j >= 0; j--){
  10949. inst = $.data(cur[j], this.widgetFullName);
  10950. if(inst && inst !== this && !inst.options.disabled) {
  10951. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  10952. this.containers.push(inst);
  10953. }
  10954. }
  10955. }
  10956. }
  10957. for (i = queries.length - 1; i >= 0; i--) {
  10958. targetData = queries[i][1];
  10959. _queries = queries[i][0];
  10960. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  10961. item = $(_queries[j]);
  10962. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  10963. items.push({
  10964. item: item,
  10965. instance: targetData,
  10966. width: 0, height: 0,
  10967. left: 0, top: 0
  10968. });
  10969. }
  10970. }
  10971. },
  10972. refreshPositions: function(fast) {
  10973. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  10974. if(this.offsetParent && this.helper) {
  10975. this.offset.parent = this._getParentOffset();
  10976. }
  10977. var i, item, t, p;
  10978. for (i = this.items.length - 1; i >= 0; i--){
  10979. item = this.items[i];
  10980. //We ignore calculating positions of all connected containers when we're not over them
  10981. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  10982. continue;
  10983. }
  10984. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  10985. if (!fast) {
  10986. item.width = t.outerWidth();
  10987. item.height = t.outerHeight();
  10988. }
  10989. p = t.offset();
  10990. item.left = p.left;
  10991. item.top = p.top;
  10992. }
  10993. if(this.options.custom && this.options.custom.refreshContainers) {
  10994. this.options.custom.refreshContainers.call(this);
  10995. } else {
  10996. for (i = this.containers.length - 1; i >= 0; i--){
  10997. p = this.containers[i].element.offset();
  10998. this.containers[i].containerCache.left = p.left;
  10999. this.containers[i].containerCache.top = p.top;
  11000. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  11001. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  11002. }
  11003. }
  11004. return this;
  11005. },
  11006. _createPlaceholder: function(that) {
  11007. that = that || this;
  11008. var className,
  11009. o = that.options;
  11010. if(!o.placeholder || o.placeholder.constructor === String) {
  11011. className = o.placeholder;
  11012. o.placeholder = {
  11013. element: function() {
  11014. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  11015. element = $( "<" + nodeName + ">", that.document[0] )
  11016. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  11017. .removeClass("ui-sortable-helper");
  11018. if ( nodeName === "tr" ) {
  11019. that.currentItem.children().each(function() {
  11020. $( "<td>&#160;</td>", that.document[0] )
  11021. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  11022. .appendTo( element );
  11023. });
  11024. } else if ( nodeName === "img" ) {
  11025. element.attr( "src", that.currentItem.attr( "src" ) );
  11026. }
  11027. if ( !className ) {
  11028. element.css( "visibility", "hidden" );
  11029. }
  11030. return element;
  11031. },
  11032. update: function(container, p) {
  11033. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  11034. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  11035. if(className && !o.forcePlaceholderSize) {
  11036. return;
  11037. }
  11038. //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
  11039. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  11040. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  11041. }
  11042. };
  11043. }
  11044. //Create the placeholder
  11045. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  11046. //Append it after the actual current item
  11047. that.currentItem.after(that.placeholder);
  11048. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  11049. o.placeholder.update(that, that.placeholder);
  11050. },
  11051. _contactContainers: function(event) {
  11052. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  11053. innermostContainer = null,
  11054. innermostIndex = null;
  11055. // get innermost container that intersects with item
  11056. for (i = this.containers.length - 1; i >= 0; i--) {
  11057. // never consider a container that's located within the item itself
  11058. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  11059. continue;
  11060. }
  11061. if(this._intersectsWith(this.containers[i].containerCache)) {
  11062. // if we've already found a container and it's more "inner" than this, then continue
  11063. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  11064. continue;
  11065. }
  11066. innermostContainer = this.containers[i];
  11067. innermostIndex = i;
  11068. } else {
  11069. // container doesn't intersect. trigger "out" event if necessary
  11070. if(this.containers[i].containerCache.over) {
  11071. this.containers[i]._trigger("out", event, this._uiHash(this));
  11072. this.containers[i].containerCache.over = 0;
  11073. }
  11074. }
  11075. }
  11076. // if no intersecting containers found, return
  11077. if(!innermostContainer) {
  11078. return;
  11079. }
  11080. // move the item into the container if it's not there already
  11081. if(this.containers.length === 1) {
  11082. if (!this.containers[innermostIndex].containerCache.over) {
  11083. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11084. this.containers[innermostIndex].containerCache.over = 1;
  11085. }
  11086. } else {
  11087. //When entering a new container, we will find the item with the least distance and append our item near it
  11088. dist = 10000;
  11089. itemWithLeastDistance = null;
  11090. floating = innermostContainer.floating || isFloating(this.currentItem);
  11091. posProperty = floating ? "left" : "top";
  11092. sizeProperty = floating ? "width" : "height";
  11093. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  11094. for (j = this.items.length - 1; j >= 0; j--) {
  11095. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  11096. continue;
  11097. }
  11098. if(this.items[j].item[0] === this.currentItem[0]) {
  11099. continue;
  11100. }
  11101. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  11102. continue;
  11103. }
  11104. cur = this.items[j].item.offset()[posProperty];
  11105. nearBottom = false;
  11106. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  11107. nearBottom = true;
  11108. cur += this.items[j][sizeProperty];
  11109. }
  11110. if(Math.abs(cur - base) < dist) {
  11111. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  11112. this.direction = nearBottom ? "up": "down";
  11113. }
  11114. }
  11115. //Check if dropOnEmpty is enabled
  11116. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  11117. return;
  11118. }
  11119. if(this.currentContainer === this.containers[innermostIndex]) {
  11120. return;
  11121. }
  11122. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  11123. this._trigger("change", event, this._uiHash());
  11124. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  11125. this.currentContainer = this.containers[innermostIndex];
  11126. //Update the placeholder
  11127. this.options.placeholder.update(this.currentContainer, this.placeholder);
  11128. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11129. this.containers[innermostIndex].containerCache.over = 1;
  11130. }
  11131. },
  11132. _createHelper: function(event) {
  11133. var o = this.options,
  11134. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  11135. //Add the helper to the DOM if that didn't happen already
  11136. if(!helper.parents("body").length) {
  11137. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  11138. }
  11139. if(helper[0] === this.currentItem[0]) {
  11140. 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") };
  11141. }
  11142. if(!helper[0].style.width || o.forceHelperSize) {
  11143. helper.width(this.currentItem.width());
  11144. }
  11145. if(!helper[0].style.height || o.forceHelperSize) {
  11146. helper.height(this.currentItem.height());
  11147. }
  11148. return helper;
  11149. },
  11150. _adjustOffsetFromHelper: function(obj) {
  11151. if (typeof obj === "string") {
  11152. obj = obj.split(" ");
  11153. }
  11154. if ($.isArray(obj)) {
  11155. obj = {left: +obj[0], top: +obj[1] || 0};
  11156. }
  11157. if ("left" in obj) {
  11158. this.offset.click.left = obj.left + this.margins.left;
  11159. }
  11160. if ("right" in obj) {
  11161. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  11162. }
  11163. if ("top" in obj) {
  11164. this.offset.click.top = obj.top + this.margins.top;
  11165. }
  11166. if ("bottom" in obj) {
  11167. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  11168. }
  11169. },
  11170. _getParentOffset: function() {
  11171. //Get the offsetParent and cache its position
  11172. this.offsetParent = this.helper.offsetParent();
  11173. var po = this.offsetParent.offset();
  11174. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  11175. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  11176. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  11177. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  11178. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  11179. po.left += this.scrollParent.scrollLeft();
  11180. po.top += this.scrollParent.scrollTop();
  11181. }
  11182. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  11183. // with an ugly IE fix
  11184. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  11185. po = { top: 0, left: 0 };
  11186. }
  11187. return {
  11188. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  11189. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  11190. };
  11191. },
  11192. _getRelativeOffset: function() {
  11193. if(this.cssPosition === "relative") {
  11194. var p = this.currentItem.position();
  11195. return {
  11196. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  11197. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  11198. };
  11199. } else {
  11200. return { top: 0, left: 0 };
  11201. }
  11202. },
  11203. _cacheMargins: function() {
  11204. this.margins = {
  11205. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  11206. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  11207. };
  11208. },
  11209. _cacheHelperProportions: function() {
  11210. this.helperProportions = {
  11211. width: this.helper.outerWidth(),
  11212. height: this.helper.outerHeight()
  11213. };
  11214. },
  11215. _setContainment: function() {
  11216. var ce, co, over,
  11217. o = this.options;
  11218. if(o.containment === "parent") {
  11219. o.containment = this.helper[0].parentNode;
  11220. }
  11221. if(o.containment === "document" || o.containment === "window") {
  11222. this.containment = [
  11223. 0 - this.offset.relative.left - this.offset.parent.left,
  11224. 0 - this.offset.relative.top - this.offset.parent.top,
  11225. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  11226. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  11227. ];
  11228. }
  11229. if(!(/^(document|window|parent)$/).test(o.containment)) {
  11230. ce = $(o.containment)[0];
  11231. co = $(o.containment).offset();
  11232. over = ($(ce).css("overflow") !== "hidden");
  11233. this.containment = [
  11234. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  11235. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  11236. 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,
  11237. 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
  11238. ];
  11239. }
  11240. },
  11241. _convertPositionTo: function(d, pos) {
  11242. if(!pos) {
  11243. pos = this.position;
  11244. }
  11245. var mod = d === "absolute" ? 1 : -1,
  11246. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  11247. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  11248. return {
  11249. top: (
  11250. pos.top + // The absolute mouse position
  11251. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  11252. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  11253. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  11254. ),
  11255. left: (
  11256. pos.left + // The absolute mouse position
  11257. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  11258. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  11259. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  11260. )
  11261. };
  11262. },
  11263. _generatePosition: function(event) {
  11264. var top, left,
  11265. o = this.options,
  11266. pageX = event.pageX,
  11267. pageY = event.pageY,
  11268. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  11269. // This is another very weird special case that only happens for relative elements:
  11270. // 1. If the css position is relative
  11271. // 2. and the scroll parent is the document or similar to the offset parent
  11272. // we have to refresh the relative offset during the scroll so there are no jumps
  11273. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  11274. this.offset.relative = this._getRelativeOffset();
  11275. }
  11276. /*
  11277. * - Position constraining -
  11278. * Constrain the position to a mix of grid, containment.
  11279. */
  11280. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  11281. if(this.containment) {
  11282. if(event.pageX - this.offset.click.left < this.containment[0]) {
  11283. pageX = this.containment[0] + this.offset.click.left;
  11284. }
  11285. if(event.pageY - this.offset.click.top < this.containment[1]) {
  11286. pageY = this.containment[1] + this.offset.click.top;
  11287. }
  11288. if(event.pageX - this.offset.click.left > this.containment[2]) {
  11289. pageX = this.containment[2] + this.offset.click.left;
  11290. }
  11291. if(event.pageY - this.offset.click.top > this.containment[3]) {
  11292. pageY = this.containment[3] + this.offset.click.top;
  11293. }
  11294. }
  11295. if(o.grid) {
  11296. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  11297. 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;
  11298. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  11299. 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;
  11300. }
  11301. }
  11302. return {
  11303. top: (
  11304. pageY - // The absolute mouse position
  11305. this.offset.click.top - // Click offset (relative to the element)
  11306. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  11307. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  11308. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  11309. ),
  11310. left: (
  11311. pageX - // The absolute mouse position
  11312. this.offset.click.left - // Click offset (relative to the element)
  11313. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  11314. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  11315. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  11316. )
  11317. };
  11318. },
  11319. _rearrange: function(event, i, a, hardRefresh) {
  11320. 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));
  11321. //Various things done here to improve the performance:
  11322. // 1. we create a setTimeout, that calls refreshPositions
  11323. // 2. on the instance, we have a counter variable, that get's higher after every append
  11324. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  11325. // 4. this lets only the last addition to the timeout stack through
  11326. this.counter = this.counter ? ++this.counter : 1;
  11327. var counter = this.counter;
  11328. this._delay(function() {
  11329. if(counter === this.counter) {
  11330. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  11331. }
  11332. });
  11333. },
  11334. _clear: function(event, noPropagation) {
  11335. this.reverting = false;
  11336. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  11337. // everything else normalized again
  11338. var i,
  11339. delayedTriggers = [];
  11340. // We first have to update the dom position of the actual currentItem
  11341. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  11342. if(!this._noFinalSort && this.currentItem.parent().length) {
  11343. this.placeholder.before(this.currentItem);
  11344. }
  11345. this._noFinalSort = null;
  11346. if(this.helper[0] === this.currentItem[0]) {
  11347. for(i in this._storedCSS) {
  11348. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  11349. this._storedCSS[i] = "";
  11350. }
  11351. }
  11352. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  11353. } else {
  11354. this.currentItem.show();
  11355. }
  11356. if(this.fromOutside && !noPropagation) {
  11357. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  11358. }
  11359. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  11360. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  11361. }
  11362. // Check if the items Container has Changed and trigger appropriate
  11363. // events.
  11364. if (this !== this.currentContainer) {
  11365. if(!noPropagation) {
  11366. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  11367. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  11368. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  11369. }
  11370. }
  11371. //Post events to containers
  11372. function delayEvent( type, instance, container ) {
  11373. return function( event ) {
  11374. container._trigger( type, event, instance._uiHash( instance ) );
  11375. };
  11376. }
  11377. for (i = this.containers.length - 1; i >= 0; i--){
  11378. if (!noPropagation) {
  11379. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  11380. }
  11381. if(this.containers[i].containerCache.over) {
  11382. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  11383. this.containers[i].containerCache.over = 0;
  11384. }
  11385. }
  11386. //Do what was originally in plugins
  11387. if ( this.storedCursor ) {
  11388. this.document.find( "body" ).css( "cursor", this.storedCursor );
  11389. this.storedStylesheet.remove();
  11390. }
  11391. if(this._storedOpacity) {
  11392. this.helper.css("opacity", this._storedOpacity);
  11393. }
  11394. if(this._storedZIndex) {
  11395. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  11396. }
  11397. this.dragging = false;
  11398. if(this.cancelHelperRemoval) {
  11399. if(!noPropagation) {
  11400. this._trigger("beforeStop", event, this._uiHash());
  11401. for (i=0; i < delayedTriggers.length; i++) {
  11402. delayedTriggers[i].call(this, event);
  11403. } //Trigger all delayed events
  11404. this._trigger("stop", event, this._uiHash());
  11405. }
  11406. this.fromOutside = false;
  11407. return false;
  11408. }
  11409. if(!noPropagation) {
  11410. this._trigger("beforeStop", event, this._uiHash());
  11411. }
  11412. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  11413. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  11414. if(this.helper[0] !== this.currentItem[0]) {
  11415. this.helper.remove();
  11416. }
  11417. this.helper = null;
  11418. if(!noPropagation) {
  11419. for (i=0; i < delayedTriggers.length; i++) {
  11420. delayedTriggers[i].call(this, event);
  11421. } //Trigger all delayed events
  11422. this._trigger("stop", event, this._uiHash());
  11423. }
  11424. this.fromOutside = false;
  11425. return true;
  11426. },
  11427. _trigger: function() {
  11428. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  11429. this.cancel();
  11430. }
  11431. },
  11432. _uiHash: function(_inst) {
  11433. var inst = _inst || this;
  11434. return {
  11435. helper: inst.helper,
  11436. placeholder: inst.placeholder || $([]),
  11437. position: inst.position,
  11438. originalPosition: inst.originalPosition,
  11439. offset: inst.positionAbs,
  11440. item: inst.currentItem,
  11441. sender: _inst ? _inst.element : null
  11442. };
  11443. }
  11444. });
  11445. })(jQuery);
  11446. (function( $ ) {
  11447. function modifier( fn ) {
  11448. return function() {
  11449. var previous = this.element.val();
  11450. fn.apply( this, arguments );
  11451. this._refresh();
  11452. if ( previous !== this.element.val() ) {
  11453. this._trigger( "change" );
  11454. }
  11455. };
  11456. }
  11457. $.widget( "ui.spinner", {
  11458. version: "1.10.4",
  11459. defaultElement: "<input>",
  11460. widgetEventPrefix: "spin",
  11461. options: {
  11462. culture: null,
  11463. icons: {
  11464. down: "ui-icon-triangle-1-s",
  11465. up: "ui-icon-triangle-1-n"
  11466. },
  11467. incremental: true,
  11468. max: null,
  11469. min: null,
  11470. numberFormat: null,
  11471. page: 10,
  11472. step: 1,
  11473. change: null,
  11474. spin: null,
  11475. start: null,
  11476. stop: null
  11477. },
  11478. _create: function() {
  11479. // handle string values that need to be parsed
  11480. this._setOption( "max", this.options.max );
  11481. this._setOption( "min", this.options.min );
  11482. this._setOption( "step", this.options.step );
  11483. // Only format if there is a value, prevents the field from being marked
  11484. // as invalid in Firefox, see #9573.
  11485. if ( this.value() !== "" ) {
  11486. // Format the value, but don't constrain.
  11487. this._value( this.element.val(), true );
  11488. }
  11489. this._draw();
  11490. this._on( this._events );
  11491. this._refresh();
  11492. // turning off autocomplete prevents the browser from remembering the
  11493. // value when navigating through history, so we re-enable autocomplete
  11494. // if the page is unloaded before the widget is destroyed. #7790
  11495. this._on( this.window, {
  11496. beforeunload: function() {
  11497. this.element.removeAttr( "autocomplete" );
  11498. }
  11499. });
  11500. },
  11501. _getCreateOptions: function() {
  11502. var options = {},
  11503. element = this.element;
  11504. $.each( [ "min", "max", "step" ], function( i, option ) {
  11505. var value = element.attr( option );
  11506. if ( value !== undefined && value.length ) {
  11507. options[ option ] = value;
  11508. }
  11509. });
  11510. return options;
  11511. },
  11512. _events: {
  11513. keydown: function( event ) {
  11514. if ( this._start( event ) && this._keydown( event ) ) {
  11515. event.preventDefault();
  11516. }
  11517. },
  11518. keyup: "_stop",
  11519. focus: function() {
  11520. this.previous = this.element.val();
  11521. },
  11522. blur: function( event ) {
  11523. if ( this.cancelBlur ) {
  11524. delete this.cancelBlur;
  11525. return;
  11526. }
  11527. this._stop();
  11528. this._refresh();
  11529. if ( this.previous !== this.element.val() ) {
  11530. this._trigger( "change", event );
  11531. }
  11532. },
  11533. mousewheel: function( event, delta ) {
  11534. if ( !delta ) {
  11535. return;
  11536. }
  11537. if ( !this.spinning && !this._start( event ) ) {
  11538. return false;
  11539. }
  11540. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11541. clearTimeout( this.mousewheelTimer );
  11542. this.mousewheelTimer = this._delay(function() {
  11543. if ( this.spinning ) {
  11544. this._stop( event );
  11545. }
  11546. }, 100 );
  11547. event.preventDefault();
  11548. },
  11549. "mousedown .ui-spinner-button": function( event ) {
  11550. var previous;
  11551. // We never want the buttons to have focus; whenever the user is
  11552. // interacting with the spinner, the focus should be on the input.
  11553. // If the input is focused then this.previous is properly set from
  11554. // when the input first received focus. If the input is not focused
  11555. // then we need to set this.previous based on the value before spinning.
  11556. previous = this.element[0] === this.document[0].activeElement ?
  11557. this.previous : this.element.val();
  11558. function checkFocus() {
  11559. var isActive = this.element[0] === this.document[0].activeElement;
  11560. if ( !isActive ) {
  11561. this.element.focus();
  11562. this.previous = previous;
  11563. // support: IE
  11564. // IE sets focus asynchronously, so we need to check if focus
  11565. // moved off of the input because the user clicked on the button.
  11566. this._delay(function() {
  11567. this.previous = previous;
  11568. });
  11569. }
  11570. }
  11571. // ensure focus is on (or stays on) the text field
  11572. event.preventDefault();
  11573. checkFocus.call( this );
  11574. // support: IE
  11575. // IE doesn't prevent moving focus even with event.preventDefault()
  11576. // so we set a flag to know when we should ignore the blur event
  11577. // and check (again) if focus moved off of the input.
  11578. this.cancelBlur = true;
  11579. this._delay(function() {
  11580. delete this.cancelBlur;
  11581. checkFocus.call( this );
  11582. });
  11583. if ( this._start( event ) === false ) {
  11584. return;
  11585. }
  11586. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11587. },
  11588. "mouseup .ui-spinner-button": "_stop",
  11589. "mouseenter .ui-spinner-button": function( event ) {
  11590. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11591. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11592. return;
  11593. }
  11594. if ( this._start( event ) === false ) {
  11595. return false;
  11596. }
  11597. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11598. },
  11599. // TODO: do we really want to consider this a stop?
  11600. // shouldn't we just stop the repeater and wait until mouseup before
  11601. // we trigger the stop event?
  11602. "mouseleave .ui-spinner-button": "_stop"
  11603. },
  11604. _draw: function() {
  11605. var uiSpinner = this.uiSpinner = this.element
  11606. .addClass( "ui-spinner-input" )
  11607. .attr( "autocomplete", "off" )
  11608. .wrap( this._uiSpinnerHtml() )
  11609. .parent()
  11610. // add buttons
  11611. .append( this._buttonHtml() );
  11612. this.element.attr( "role", "spinbutton" );
  11613. // button bindings
  11614. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11615. .attr( "tabIndex", -1 )
  11616. .button()
  11617. .removeClass( "ui-corner-all" );
  11618. // IE 6 doesn't understand height: 50% for the buttons
  11619. // unless the wrapper has an explicit height
  11620. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11621. uiSpinner.height() > 0 ) {
  11622. uiSpinner.height( uiSpinner.height() );
  11623. }
  11624. // disable spinner if element was already disabled
  11625. if ( this.options.disabled ) {
  11626. this.disable();
  11627. }
  11628. },
  11629. _keydown: function( event ) {
  11630. var options = this.options,
  11631. keyCode = $.ui.keyCode;
  11632. switch ( event.keyCode ) {
  11633. case keyCode.UP:
  11634. this._repeat( null, 1, event );
  11635. return true;
  11636. case keyCode.DOWN:
  11637. this._repeat( null, -1, event );
  11638. return true;
  11639. case keyCode.PAGE_UP:
  11640. this._repeat( null, options.page, event );
  11641. return true;
  11642. case keyCode.PAGE_DOWN:
  11643. this._repeat( null, -options.page, event );
  11644. return true;
  11645. }
  11646. return false;
  11647. },
  11648. _uiSpinnerHtml: function() {
  11649. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11650. },
  11651. _buttonHtml: function() {
  11652. return "" +
  11653. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11654. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11655. "</a>" +
  11656. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11657. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11658. "</a>";
  11659. },
  11660. _start: function( event ) {
  11661. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11662. return false;
  11663. }
  11664. if ( !this.counter ) {
  11665. this.counter = 1;
  11666. }
  11667. this.spinning = true;
  11668. return true;
  11669. },
  11670. _repeat: function( i, steps, event ) {
  11671. i = i || 500;
  11672. clearTimeout( this.timer );
  11673. this.timer = this._delay(function() {
  11674. this._repeat( 40, steps, event );
  11675. }, i );
  11676. this._spin( steps * this.options.step, event );
  11677. },
  11678. _spin: function( step, event ) {
  11679. var value = this.value() || 0;
  11680. if ( !this.counter ) {
  11681. this.counter = 1;
  11682. }
  11683. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11684. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11685. this._value( value );
  11686. this.counter++;
  11687. }
  11688. },
  11689. _increment: function( i ) {
  11690. var incremental = this.options.incremental;
  11691. if ( incremental ) {
  11692. return $.isFunction( incremental ) ?
  11693. incremental( i ) :
  11694. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11695. }
  11696. return 1;
  11697. },
  11698. _precision: function() {
  11699. var precision = this._precisionOf( this.options.step );
  11700. if ( this.options.min !== null ) {
  11701. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11702. }
  11703. return precision;
  11704. },
  11705. _precisionOf: function( num ) {
  11706. var str = num.toString(),
  11707. decimal = str.indexOf( "." );
  11708. return decimal === -1 ? 0 : str.length - decimal - 1;
  11709. },
  11710. _adjustValue: function( value ) {
  11711. var base, aboveMin,
  11712. options = this.options;
  11713. // make sure we're at a valid step
  11714. // - find out where we are relative to the base (min or 0)
  11715. base = options.min !== null ? options.min : 0;
  11716. aboveMin = value - base;
  11717. // - round to the nearest step
  11718. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11719. // - rounding is based on 0, so adjust back to our base
  11720. value = base + aboveMin;
  11721. // fix precision from bad JS floating point math
  11722. value = parseFloat( value.toFixed( this._precision() ) );
  11723. // clamp the value
  11724. if ( options.max !== null && value > options.max) {
  11725. return options.max;
  11726. }
  11727. if ( options.min !== null && value < options.min ) {
  11728. return options.min;
  11729. }
  11730. return value;
  11731. },
  11732. _stop: function( event ) {
  11733. if ( !this.spinning ) {
  11734. return;
  11735. }
  11736. clearTimeout( this.timer );
  11737. clearTimeout( this.mousewheelTimer );
  11738. this.counter = 0;
  11739. this.spinning = false;
  11740. this._trigger( "stop", event );
  11741. },
  11742. _setOption: function( key, value ) {
  11743. if ( key === "culture" || key === "numberFormat" ) {
  11744. var prevValue = this._parse( this.element.val() );
  11745. this.options[ key ] = value;
  11746. this.element.val( this._format( prevValue ) );
  11747. return;
  11748. }
  11749. if ( key === "max" || key === "min" || key === "step" ) {
  11750. if ( typeof value === "string" ) {
  11751. value = this._parse( value );
  11752. }
  11753. }
  11754. if ( key === "icons" ) {
  11755. this.buttons.first().find( ".ui-icon" )
  11756. .removeClass( this.options.icons.up )
  11757. .addClass( value.up );
  11758. this.buttons.last().find( ".ui-icon" )
  11759. .removeClass( this.options.icons.down )
  11760. .addClass( value.down );
  11761. }
  11762. this._super( key, value );
  11763. if ( key === "disabled" ) {
  11764. if ( value ) {
  11765. this.element.prop( "disabled", true );
  11766. this.buttons.button( "disable" );
  11767. } else {
  11768. this.element.prop( "disabled", false );
  11769. this.buttons.button( "enable" );
  11770. }
  11771. }
  11772. },
  11773. _setOptions: modifier(function( options ) {
  11774. this._super( options );
  11775. this._value( this.element.val() );
  11776. }),
  11777. _parse: function( val ) {
  11778. if ( typeof val === "string" && val !== "" ) {
  11779. val = window.Globalize && this.options.numberFormat ?
  11780. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11781. }
  11782. return val === "" || isNaN( val ) ? null : val;
  11783. },
  11784. _format: function( value ) {
  11785. if ( value === "" ) {
  11786. return "";
  11787. }
  11788. return window.Globalize && this.options.numberFormat ?
  11789. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11790. value;
  11791. },
  11792. _refresh: function() {
  11793. this.element.attr({
  11794. "aria-valuemin": this.options.min,
  11795. "aria-valuemax": this.options.max,
  11796. // TODO: what should we do with values that can't be parsed?
  11797. "aria-valuenow": this._parse( this.element.val() )
  11798. });
  11799. },
  11800. // update the value without triggering change
  11801. _value: function( value, allowAny ) {
  11802. var parsed;
  11803. if ( value !== "" ) {
  11804. parsed = this._parse( value );
  11805. if ( parsed !== null ) {
  11806. if ( !allowAny ) {
  11807. parsed = this._adjustValue( parsed );
  11808. }
  11809. value = this._format( parsed );
  11810. }
  11811. }
  11812. this.element.val( value );
  11813. this._refresh();
  11814. },
  11815. _destroy: function() {
  11816. this.element
  11817. .removeClass( "ui-spinner-input" )
  11818. .prop( "disabled", false )
  11819. .removeAttr( "autocomplete" )
  11820. .removeAttr( "role" )
  11821. .removeAttr( "aria-valuemin" )
  11822. .removeAttr( "aria-valuemax" )
  11823. .removeAttr( "aria-valuenow" );
  11824. this.uiSpinner.replaceWith( this.element );
  11825. },
  11826. stepUp: modifier(function( steps ) {
  11827. this._stepUp( steps );
  11828. }),
  11829. _stepUp: function( steps ) {
  11830. if ( this._start() ) {
  11831. this._spin( (steps || 1) * this.options.step );
  11832. this._stop();
  11833. }
  11834. },
  11835. stepDown: modifier(function( steps ) {
  11836. this._stepDown( steps );
  11837. }),
  11838. _stepDown: function( steps ) {
  11839. if ( this._start() ) {
  11840. this._spin( (steps || 1) * -this.options.step );
  11841. this._stop();
  11842. }
  11843. },
  11844. pageUp: modifier(function( pages ) {
  11845. this._stepUp( (pages || 1) * this.options.page );
  11846. }),
  11847. pageDown: modifier(function( pages ) {
  11848. this._stepDown( (pages || 1) * this.options.page );
  11849. }),
  11850. value: function( newVal ) {
  11851. if ( !arguments.length ) {
  11852. return this._parse( this.element.val() );
  11853. }
  11854. modifier( this._value ).call( this, newVal );
  11855. },
  11856. widget: function() {
  11857. return this.uiSpinner;
  11858. }
  11859. });
  11860. }( jQuery ) );
  11861. (function( $, undefined ) {
  11862. var tabId = 0,
  11863. rhash = /#.*$/;
  11864. function getNextTabId() {
  11865. return ++tabId;
  11866. }
  11867. function isLocal( anchor ) {
  11868. // support: IE7
  11869. // IE7 doesn't normalize the href property when set via script (#9317)
  11870. anchor = anchor.cloneNode( false );
  11871. return anchor.hash.length > 1 &&
  11872. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11873. decodeURIComponent( location.href.replace( rhash, "" ) );
  11874. }
  11875. $.widget( "ui.tabs", {
  11876. version: "1.10.4",
  11877. delay: 300,
  11878. options: {
  11879. active: null,
  11880. collapsible: false,
  11881. event: "click",
  11882. heightStyle: "content",
  11883. hide: null,
  11884. show: null,
  11885. // callbacks
  11886. activate: null,
  11887. beforeActivate: null,
  11888. beforeLoad: null,
  11889. load: null
  11890. },
  11891. _create: function() {
  11892. var that = this,
  11893. options = this.options;
  11894. this.running = false;
  11895. this.element
  11896. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11897. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11898. // Prevent users from focusing disabled tabs via click
  11899. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11900. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11901. event.preventDefault();
  11902. }
  11903. })
  11904. // support: IE <9
  11905. // Preventing the default action in mousedown doesn't prevent IE
  11906. // from focusing the element, so if the anchor gets focused, blur.
  11907. // We don't have to worry about focusing the previously focused
  11908. // element since clicking on a non-focusable element should focus
  11909. // the body anyway.
  11910. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11911. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11912. this.blur();
  11913. }
  11914. });
  11915. this._processTabs();
  11916. options.active = this._initialActive();
  11917. // Take disabling tabs via class attribute from HTML
  11918. // into account and update option properly.
  11919. if ( $.isArray( options.disabled ) ) {
  11920. options.disabled = $.unique( options.disabled.concat(
  11921. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11922. return that.tabs.index( li );
  11923. })
  11924. ) ).sort();
  11925. }
  11926. // check for length avoids error when initializing empty list
  11927. if ( this.options.active !== false && this.anchors.length ) {
  11928. this.active = this._findActive( options.active );
  11929. } else {
  11930. this.active = $();
  11931. }
  11932. this._refresh();
  11933. if ( this.active.length ) {
  11934. this.load( options.active );
  11935. }
  11936. },
  11937. _initialActive: function() {
  11938. var active = this.options.active,
  11939. collapsible = this.options.collapsible,
  11940. locationHash = location.hash.substring( 1 );
  11941. if ( active === null ) {
  11942. // check the fragment identifier in the URL
  11943. if ( locationHash ) {
  11944. this.tabs.each(function( i, tab ) {
  11945. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11946. active = i;
  11947. return false;
  11948. }
  11949. });
  11950. }
  11951. // check for a tab marked active via a class
  11952. if ( active === null ) {
  11953. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11954. }
  11955. // no active tab, set to false
  11956. if ( active === null || active === -1 ) {
  11957. active = this.tabs.length ? 0 : false;
  11958. }
  11959. }
  11960. // handle numbers: negative, out of range
  11961. if ( active !== false ) {
  11962. active = this.tabs.index( this.tabs.eq( active ) );
  11963. if ( active === -1 ) {
  11964. active = collapsible ? false : 0;
  11965. }
  11966. }
  11967. // don't allow collapsible: false and active: false
  11968. if ( !collapsible && active === false && this.anchors.length ) {
  11969. active = 0;
  11970. }
  11971. return active;
  11972. },
  11973. _getCreateEventData: function() {
  11974. return {
  11975. tab: this.active,
  11976. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11977. };
  11978. },
  11979. _tabKeydown: function( event ) {
  11980. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11981. selectedIndex = this.tabs.index( focusedTab ),
  11982. goingForward = true;
  11983. if ( this._handlePageNav( event ) ) {
  11984. return;
  11985. }
  11986. switch ( event.keyCode ) {
  11987. case $.ui.keyCode.RIGHT:
  11988. case $.ui.keyCode.DOWN:
  11989. selectedIndex++;
  11990. break;
  11991. case $.ui.keyCode.UP:
  11992. case $.ui.keyCode.LEFT:
  11993. goingForward = false;
  11994. selectedIndex--;
  11995. break;
  11996. case $.ui.keyCode.END:
  11997. selectedIndex = this.anchors.length - 1;
  11998. break;
  11999. case $.ui.keyCode.HOME:
  12000. selectedIndex = 0;
  12001. break;
  12002. case $.ui.keyCode.SPACE:
  12003. // Activate only, no collapsing
  12004. event.preventDefault();
  12005. clearTimeout( this.activating );
  12006. this._activate( selectedIndex );
  12007. return;
  12008. case $.ui.keyCode.ENTER:
  12009. // Toggle (cancel delayed activation, allow collapsing)
  12010. event.preventDefault();
  12011. clearTimeout( this.activating );
  12012. // Determine if we should collapse or activate
  12013. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  12014. return;
  12015. default:
  12016. return;
  12017. }
  12018. // Focus the appropriate tab, based on which key was pressed
  12019. event.preventDefault();
  12020. clearTimeout( this.activating );
  12021. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  12022. // Navigating with control key will prevent automatic activation
  12023. if ( !event.ctrlKey ) {
  12024. // Update aria-selected immediately so that AT think the tab is already selected.
  12025. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  12026. // but the tab will already be activated by the time the announcement finishes.
  12027. focusedTab.attr( "aria-selected", "false" );
  12028. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  12029. this.activating = this._delay(function() {
  12030. this.option( "active", selectedIndex );
  12031. }, this.delay );
  12032. }
  12033. },
  12034. _panelKeydown: function( event ) {
  12035. if ( this._handlePageNav( event ) ) {
  12036. return;
  12037. }
  12038. // Ctrl+up moves focus to the current tab
  12039. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12040. event.preventDefault();
  12041. this.active.focus();
  12042. }
  12043. },
  12044. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12045. _handlePageNav: function( event ) {
  12046. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12047. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12048. return true;
  12049. }
  12050. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12051. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12052. return true;
  12053. }
  12054. },
  12055. _findNextTab: function( index, goingForward ) {
  12056. var lastTabIndex = this.tabs.length - 1;
  12057. function constrain() {
  12058. if ( index > lastTabIndex ) {
  12059. index = 0;
  12060. }
  12061. if ( index < 0 ) {
  12062. index = lastTabIndex;
  12063. }
  12064. return index;
  12065. }
  12066. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12067. index = goingForward ? index + 1 : index - 1;
  12068. }
  12069. return index;
  12070. },
  12071. _focusNextTab: function( index, goingForward ) {
  12072. index = this._findNextTab( index, goingForward );
  12073. this.tabs.eq( index ).focus();
  12074. return index;
  12075. },
  12076. _setOption: function( key, value ) {
  12077. if ( key === "active" ) {
  12078. // _activate() will handle invalid values and update this.options
  12079. this._activate( value );
  12080. return;
  12081. }
  12082. if ( key === "disabled" ) {
  12083. // don't use the widget factory's disabled handling
  12084. this._setupDisabled( value );
  12085. return;
  12086. }
  12087. this._super( key, value);
  12088. if ( key === "collapsible" ) {
  12089. this.element.toggleClass( "ui-tabs-collapsible", value );
  12090. // Setting collapsible: false while collapsed; open first panel
  12091. if ( !value && this.options.active === false ) {
  12092. this._activate( 0 );
  12093. }
  12094. }
  12095. if ( key === "event" ) {
  12096. this._setupEvents( value );
  12097. }
  12098. if ( key === "heightStyle" ) {
  12099. this._setupHeightStyle( value );
  12100. }
  12101. },
  12102. _tabId: function( tab ) {
  12103. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12104. },
  12105. _sanitizeSelector: function( hash ) {
  12106. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12107. },
  12108. refresh: function() {
  12109. var options = this.options,
  12110. lis = this.tablist.children( ":has(a[href])" );
  12111. // get disabled tabs from class attribute from HTML
  12112. // this will get converted to a boolean if needed in _refresh()
  12113. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12114. return lis.index( tab );
  12115. });
  12116. this._processTabs();
  12117. // was collapsed or no tabs
  12118. if ( options.active === false || !this.anchors.length ) {
  12119. options.active = false;
  12120. this.active = $();
  12121. // was active, but active tab is gone
  12122. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12123. // all remaining tabs are disabled
  12124. if ( this.tabs.length === options.disabled.length ) {
  12125. options.active = false;
  12126. this.active = $();
  12127. // activate previous tab
  12128. } else {
  12129. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12130. }
  12131. // was active, active tab still exists
  12132. } else {
  12133. // make sure active index is correct
  12134. options.active = this.tabs.index( this.active );
  12135. }
  12136. this._refresh();
  12137. },
  12138. _refresh: function() {
  12139. this._setupDisabled( this.options.disabled );
  12140. this._setupEvents( this.options.event );
  12141. this._setupHeightStyle( this.options.heightStyle );
  12142. this.tabs.not( this.active ).attr({
  12143. "aria-selected": "false",
  12144. tabIndex: -1
  12145. });
  12146. this.panels.not( this._getPanelForTab( this.active ) )
  12147. .hide()
  12148. .attr({
  12149. "aria-expanded": "false",
  12150. "aria-hidden": "true"
  12151. });
  12152. // Make sure one tab is in the tab order
  12153. if ( !this.active.length ) {
  12154. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12155. } else {
  12156. this.active
  12157. .addClass( "ui-tabs-active ui-state-active" )
  12158. .attr({
  12159. "aria-selected": "true",
  12160. tabIndex: 0
  12161. });
  12162. this._getPanelForTab( this.active )
  12163. .show()
  12164. .attr({
  12165. "aria-expanded": "true",
  12166. "aria-hidden": "false"
  12167. });
  12168. }
  12169. },
  12170. _processTabs: function() {
  12171. var that = this;
  12172. this.tablist = this._getList()
  12173. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12174. .attr( "role", "tablist" );
  12175. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12176. .addClass( "ui-state-default ui-corner-top" )
  12177. .attr({
  12178. role: "tab",
  12179. tabIndex: -1
  12180. });
  12181. this.anchors = this.tabs.map(function() {
  12182. return $( "a", this )[ 0 ];
  12183. })
  12184. .addClass( "ui-tabs-anchor" )
  12185. .attr({
  12186. role: "presentation",
  12187. tabIndex: -1
  12188. });
  12189. this.panels = $();
  12190. this.anchors.each(function( i, anchor ) {
  12191. var selector, panel, panelId,
  12192. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12193. tab = $( anchor ).closest( "li" ),
  12194. originalAriaControls = tab.attr( "aria-controls" );
  12195. // inline tab
  12196. if ( isLocal( anchor ) ) {
  12197. selector = anchor.hash;
  12198. panel = that.element.find( that._sanitizeSelector( selector ) );
  12199. // remote tab
  12200. } else {
  12201. panelId = that._tabId( tab );
  12202. selector = "#" + panelId;
  12203. panel = that.element.find( selector );
  12204. if ( !panel.length ) {
  12205. panel = that._createPanel( panelId );
  12206. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12207. }
  12208. panel.attr( "aria-live", "polite" );
  12209. }
  12210. if ( panel.length) {
  12211. that.panels = that.panels.add( panel );
  12212. }
  12213. if ( originalAriaControls ) {
  12214. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12215. }
  12216. tab.attr({
  12217. "aria-controls": selector.substring( 1 ),
  12218. "aria-labelledby": anchorId
  12219. });
  12220. panel.attr( "aria-labelledby", anchorId );
  12221. });
  12222. this.panels
  12223. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12224. .attr( "role", "tabpanel" );
  12225. },
  12226. // allow overriding how to find the list for rare usage scenarios (#7715)
  12227. _getList: function() {
  12228. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  12229. },
  12230. _createPanel: function( id ) {
  12231. return $( "<div>" )
  12232. .attr( "id", id )
  12233. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12234. .data( "ui-tabs-destroy", true );
  12235. },
  12236. _setupDisabled: function( disabled ) {
  12237. if ( $.isArray( disabled ) ) {
  12238. if ( !disabled.length ) {
  12239. disabled = false;
  12240. } else if ( disabled.length === this.anchors.length ) {
  12241. disabled = true;
  12242. }
  12243. }
  12244. // disable tabs
  12245. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12246. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12247. $( li )
  12248. .addClass( "ui-state-disabled" )
  12249. .attr( "aria-disabled", "true" );
  12250. } else {
  12251. $( li )
  12252. .removeClass( "ui-state-disabled" )
  12253. .removeAttr( "aria-disabled" );
  12254. }
  12255. }
  12256. this.options.disabled = disabled;
  12257. },
  12258. _setupEvents: function( event ) {
  12259. var events = {
  12260. click: function( event ) {
  12261. event.preventDefault();
  12262. }
  12263. };
  12264. if ( event ) {
  12265. $.each( event.split(" "), function( index, eventName ) {
  12266. events[ eventName ] = "_eventHandler";
  12267. });
  12268. }
  12269. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12270. this._on( this.anchors, events );
  12271. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12272. this._on( this.panels, { keydown: "_panelKeydown" } );
  12273. this._focusable( this.tabs );
  12274. this._hoverable( this.tabs );
  12275. },
  12276. _setupHeightStyle: function( heightStyle ) {
  12277. var maxHeight,
  12278. parent = this.element.parent();
  12279. if ( heightStyle === "fill" ) {
  12280. maxHeight = parent.height();
  12281. maxHeight -= this.element.outerHeight() - this.element.height();
  12282. this.element.siblings( ":visible" ).each(function() {
  12283. var elem = $( this ),
  12284. position = elem.css( "position" );
  12285. if ( position === "absolute" || position === "fixed" ) {
  12286. return;
  12287. }
  12288. maxHeight -= elem.outerHeight( true );
  12289. });
  12290. this.element.children().not( this.panels ).each(function() {
  12291. maxHeight -= $( this ).outerHeight( true );
  12292. });
  12293. this.panels.each(function() {
  12294. $( this ).height( Math.max( 0, maxHeight -
  12295. $( this ).innerHeight() + $( this ).height() ) );
  12296. })
  12297. .css( "overflow", "auto" );
  12298. } else if ( heightStyle === "auto" ) {
  12299. maxHeight = 0;
  12300. this.panels.each(function() {
  12301. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12302. }).height( maxHeight );
  12303. }
  12304. },
  12305. _eventHandler: function( event ) {
  12306. var options = this.options,
  12307. active = this.active,
  12308. anchor = $( event.currentTarget ),
  12309. tab = anchor.closest( "li" ),
  12310. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12311. collapsing = clickedIsActive && options.collapsible,
  12312. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12313. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12314. eventData = {
  12315. oldTab: active,
  12316. oldPanel: toHide,
  12317. newTab: collapsing ? $() : tab,
  12318. newPanel: toShow
  12319. };
  12320. event.preventDefault();
  12321. if ( tab.hasClass( "ui-state-disabled" ) ||
  12322. // tab is already loading
  12323. tab.hasClass( "ui-tabs-loading" ) ||
  12324. // can't switch durning an animation
  12325. this.running ||
  12326. // click on active header, but not collapsible
  12327. ( clickedIsActive && !options.collapsible ) ||
  12328. // allow canceling activation
  12329. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12330. return;
  12331. }
  12332. options.active = collapsing ? false : this.tabs.index( tab );
  12333. this.active = clickedIsActive ? $() : tab;
  12334. if ( this.xhr ) {
  12335. this.xhr.abort();
  12336. }
  12337. if ( !toHide.length && !toShow.length ) {
  12338. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12339. }
  12340. if ( toShow.length ) {
  12341. this.load( this.tabs.index( tab ), event );
  12342. }
  12343. this._toggle( event, eventData );
  12344. },
  12345. // handles show/hide for selecting tabs
  12346. _toggle: function( event, eventData ) {
  12347. var that = this,
  12348. toShow = eventData.newPanel,
  12349. toHide = eventData.oldPanel;
  12350. this.running = true;
  12351. function complete() {
  12352. that.running = false;
  12353. that._trigger( "activate", event, eventData );
  12354. }
  12355. function show() {
  12356. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12357. if ( toShow.length && that.options.show ) {
  12358. that._show( toShow, that.options.show, complete );
  12359. } else {
  12360. toShow.show();
  12361. complete();
  12362. }
  12363. }
  12364. // start out by hiding, then showing, then completing
  12365. if ( toHide.length && this.options.hide ) {
  12366. this._hide( toHide, this.options.hide, function() {
  12367. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12368. show();
  12369. });
  12370. } else {
  12371. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12372. toHide.hide();
  12373. show();
  12374. }
  12375. toHide.attr({
  12376. "aria-expanded": "false",
  12377. "aria-hidden": "true"
  12378. });
  12379. eventData.oldTab.attr( "aria-selected", "false" );
  12380. // If we're switching tabs, remove the old tab from the tab order.
  12381. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12382. // If we're collapsing, then keep the collapsing tab in the tab order.
  12383. if ( toShow.length && toHide.length ) {
  12384. eventData.oldTab.attr( "tabIndex", -1 );
  12385. } else if ( toShow.length ) {
  12386. this.tabs.filter(function() {
  12387. return $( this ).attr( "tabIndex" ) === 0;
  12388. })
  12389. .attr( "tabIndex", -1 );
  12390. }
  12391. toShow.attr({
  12392. "aria-expanded": "true",
  12393. "aria-hidden": "false"
  12394. });
  12395. eventData.newTab.attr({
  12396. "aria-selected": "true",
  12397. tabIndex: 0
  12398. });
  12399. },
  12400. _activate: function( index ) {
  12401. var anchor,
  12402. active = this._findActive( index );
  12403. // trying to activate the already active panel
  12404. if ( active[ 0 ] === this.active[ 0 ] ) {
  12405. return;
  12406. }
  12407. // trying to collapse, simulate a click on the current active header
  12408. if ( !active.length ) {
  12409. active = this.active;
  12410. }
  12411. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12412. this._eventHandler({
  12413. target: anchor,
  12414. currentTarget: anchor,
  12415. preventDefault: $.noop
  12416. });
  12417. },
  12418. _findActive: function( index ) {
  12419. return index === false ? $() : this.tabs.eq( index );
  12420. },
  12421. _getIndex: function( index ) {
  12422. // meta-function to give users option to provide a href string instead of a numerical index.
  12423. if ( typeof index === "string" ) {
  12424. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12425. }
  12426. return index;
  12427. },
  12428. _destroy: function() {
  12429. if ( this.xhr ) {
  12430. this.xhr.abort();
  12431. }
  12432. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12433. this.tablist
  12434. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12435. .removeAttr( "role" );
  12436. this.anchors
  12437. .removeClass( "ui-tabs-anchor" )
  12438. .removeAttr( "role" )
  12439. .removeAttr( "tabIndex" )
  12440. .removeUniqueId();
  12441. this.tabs.add( this.panels ).each(function() {
  12442. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12443. $( this ).remove();
  12444. } else {
  12445. $( this )
  12446. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12447. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12448. .removeAttr( "tabIndex" )
  12449. .removeAttr( "aria-live" )
  12450. .removeAttr( "aria-busy" )
  12451. .removeAttr( "aria-selected" )
  12452. .removeAttr( "aria-labelledby" )
  12453. .removeAttr( "aria-hidden" )
  12454. .removeAttr( "aria-expanded" )
  12455. .removeAttr( "role" );
  12456. }
  12457. });
  12458. this.tabs.each(function() {
  12459. var li = $( this ),
  12460. prev = li.data( "ui-tabs-aria-controls" );
  12461. if ( prev ) {
  12462. li
  12463. .attr( "aria-controls", prev )
  12464. .removeData( "ui-tabs-aria-controls" );
  12465. } else {
  12466. li.removeAttr( "aria-controls" );
  12467. }
  12468. });
  12469. this.panels.show();
  12470. if ( this.options.heightStyle !== "content" ) {
  12471. this.panels.css( "height", "" );
  12472. }
  12473. },
  12474. enable: function( index ) {
  12475. var disabled = this.options.disabled;
  12476. if ( disabled === false ) {
  12477. return;
  12478. }
  12479. if ( index === undefined ) {
  12480. disabled = false;
  12481. } else {
  12482. index = this._getIndex( index );
  12483. if ( $.isArray( disabled ) ) {
  12484. disabled = $.map( disabled, function( num ) {
  12485. return num !== index ? num : null;
  12486. });
  12487. } else {
  12488. disabled = $.map( this.tabs, function( li, num ) {
  12489. return num !== index ? num : null;
  12490. });
  12491. }
  12492. }
  12493. this._setupDisabled( disabled );
  12494. },
  12495. disable: function( index ) {
  12496. var disabled = this.options.disabled;
  12497. if ( disabled === true ) {
  12498. return;
  12499. }
  12500. if ( index === undefined ) {
  12501. disabled = true;
  12502. } else {
  12503. index = this._getIndex( index );
  12504. if ( $.inArray( index, disabled ) !== -1 ) {
  12505. return;
  12506. }
  12507. if ( $.isArray( disabled ) ) {
  12508. disabled = $.merge( [ index ], disabled ).sort();
  12509. } else {
  12510. disabled = [ index ];
  12511. }
  12512. }
  12513. this._setupDisabled( disabled );
  12514. },
  12515. load: function( index, event ) {
  12516. index = this._getIndex( index );
  12517. var that = this,
  12518. tab = this.tabs.eq( index ),
  12519. anchor = tab.find( ".ui-tabs-anchor" ),
  12520. panel = this._getPanelForTab( tab ),
  12521. eventData = {
  12522. tab: tab,
  12523. panel: panel
  12524. };
  12525. // not remote
  12526. if ( isLocal( anchor[ 0 ] ) ) {
  12527. return;
  12528. }
  12529. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12530. // support: jQuery <1.8
  12531. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12532. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12533. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12534. tab.addClass( "ui-tabs-loading" );
  12535. panel.attr( "aria-busy", "true" );
  12536. this.xhr
  12537. .success(function( response ) {
  12538. // support: jQuery <1.8
  12539. // http://bugs.jquery.com/ticket/11778
  12540. setTimeout(function() {
  12541. panel.html( response );
  12542. that._trigger( "load", event, eventData );
  12543. }, 1 );
  12544. })
  12545. .complete(function( jqXHR, status ) {
  12546. // support: jQuery <1.8
  12547. // http://bugs.jquery.com/ticket/11778
  12548. setTimeout(function() {
  12549. if ( status === "abort" ) {
  12550. that.panels.stop( false, true );
  12551. }
  12552. tab.removeClass( "ui-tabs-loading" );
  12553. panel.removeAttr( "aria-busy" );
  12554. if ( jqXHR === that.xhr ) {
  12555. delete that.xhr;
  12556. }
  12557. }, 1 );
  12558. });
  12559. }
  12560. },
  12561. _ajaxSettings: function( anchor, event, eventData ) {
  12562. var that = this;
  12563. return {
  12564. url: anchor.attr( "href" ),
  12565. beforeSend: function( jqXHR, settings ) {
  12566. return that._trigger( "beforeLoad", event,
  12567. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12568. }
  12569. };
  12570. },
  12571. _getPanelForTab: function( tab ) {
  12572. var id = $( tab ).attr( "aria-controls" );
  12573. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12574. }
  12575. });
  12576. })( jQuery );
  12577. (function( $ ) {
  12578. var increments = 0;
  12579. function addDescribedBy( elem, id ) {
  12580. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12581. describedby.push( id );
  12582. elem
  12583. .data( "ui-tooltip-id", id )
  12584. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12585. }
  12586. function removeDescribedBy( elem ) {
  12587. var id = elem.data( "ui-tooltip-id" ),
  12588. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12589. index = $.inArray( id, describedby );
  12590. if ( index !== -1 ) {
  12591. describedby.splice( index, 1 );
  12592. }
  12593. elem.removeData( "ui-tooltip-id" );
  12594. describedby = $.trim( describedby.join( " " ) );
  12595. if ( describedby ) {
  12596. elem.attr( "aria-describedby", describedby );
  12597. } else {
  12598. elem.removeAttr( "aria-describedby" );
  12599. }
  12600. }
  12601. $.widget( "ui.tooltip", {
  12602. version: "1.10.4",
  12603. options: {
  12604. content: function() {
  12605. // support: IE<9, Opera in jQuery <1.7
  12606. // .text() can't accept undefined, so coerce to a string
  12607. var title = $( this ).attr( "title" ) || "";
  12608. // Escape title, since we're going from an attribute to raw HTML
  12609. return $( "<a>" ).text( title ).html();
  12610. },
  12611. hide: true,
  12612. // Disabled elements have inconsistent behavior across browsers (#8661)
  12613. items: "[title]:not([disabled])",
  12614. position: {
  12615. my: "left top+15",
  12616. at: "left bottom",
  12617. collision: "flipfit flip"
  12618. },
  12619. show: true,
  12620. tooltipClass: null,
  12621. track: false,
  12622. // callbacks
  12623. close: null,
  12624. open: null
  12625. },
  12626. _create: function() {
  12627. this._on({
  12628. mouseover: "open",
  12629. focusin: "open"
  12630. });
  12631. // IDs of generated tooltips, needed for destroy
  12632. this.tooltips = {};
  12633. // IDs of parent tooltips where we removed the title attribute
  12634. this.parents = {};
  12635. if ( this.options.disabled ) {
  12636. this._disable();
  12637. }
  12638. },
  12639. _setOption: function( key, value ) {
  12640. var that = this;
  12641. if ( key === "disabled" ) {
  12642. this[ value ? "_disable" : "_enable" ]();
  12643. this.options[ key ] = value;
  12644. // disable element style changes
  12645. return;
  12646. }
  12647. this._super( key, value );
  12648. if ( key === "content" ) {
  12649. $.each( this.tooltips, function( id, element ) {
  12650. that._updateContent( element );
  12651. });
  12652. }
  12653. },
  12654. _disable: function() {
  12655. var that = this;
  12656. // close open tooltips
  12657. $.each( this.tooltips, function( id, element ) {
  12658. var event = $.Event( "blur" );
  12659. event.target = event.currentTarget = element[0];
  12660. that.close( event, true );
  12661. });
  12662. // remove title attributes to prevent native tooltips
  12663. this.element.find( this.options.items ).addBack().each(function() {
  12664. var element = $( this );
  12665. if ( element.is( "[title]" ) ) {
  12666. element
  12667. .data( "ui-tooltip-title", element.attr( "title" ) )
  12668. .attr( "title", "" );
  12669. }
  12670. });
  12671. },
  12672. _enable: function() {
  12673. // restore title attributes
  12674. this.element.find( this.options.items ).addBack().each(function() {
  12675. var element = $( this );
  12676. if ( element.data( "ui-tooltip-title" ) ) {
  12677. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12678. }
  12679. });
  12680. },
  12681. open: function( event ) {
  12682. var that = this,
  12683. target = $( event ? event.target : this.element )
  12684. // we need closest here due to mouseover bubbling,
  12685. // but always pointing at the same event target
  12686. .closest( this.options.items );
  12687. // No element to show a tooltip for or the tooltip is already open
  12688. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12689. return;
  12690. }
  12691. if ( target.attr( "title" ) ) {
  12692. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12693. }
  12694. target.data( "ui-tooltip-open", true );
  12695. // kill parent tooltips, custom or native, for hover
  12696. if ( event && event.type === "mouseover" ) {
  12697. target.parents().each(function() {
  12698. var parent = $( this ),
  12699. blurEvent;
  12700. if ( parent.data( "ui-tooltip-open" ) ) {
  12701. blurEvent = $.Event( "blur" );
  12702. blurEvent.target = blurEvent.currentTarget = this;
  12703. that.close( blurEvent, true );
  12704. }
  12705. if ( parent.attr( "title" ) ) {
  12706. parent.uniqueId();
  12707. that.parents[ this.id ] = {
  12708. element: this,
  12709. title: parent.attr( "title" )
  12710. };
  12711. parent.attr( "title", "" );
  12712. }
  12713. });
  12714. }
  12715. this._updateContent( target, event );
  12716. },
  12717. _updateContent: function( target, event ) {
  12718. var content,
  12719. contentOption = this.options.content,
  12720. that = this,
  12721. eventType = event ? event.type : null;
  12722. if ( typeof contentOption === "string" ) {
  12723. return this._open( event, target, contentOption );
  12724. }
  12725. content = contentOption.call( target[0], function( response ) {
  12726. // ignore async response if tooltip was closed already
  12727. if ( !target.data( "ui-tooltip-open" ) ) {
  12728. return;
  12729. }
  12730. // IE may instantly serve a cached response for ajax requests
  12731. // delay this call to _open so the other call to _open runs first
  12732. that._delay(function() {
  12733. // jQuery creates a special event for focusin when it doesn't
  12734. // exist natively. To improve performance, the native event
  12735. // object is reused and the type is changed. Therefore, we can't
  12736. // rely on the type being correct after the event finished
  12737. // bubbling, so we set it back to the previous value. (#8740)
  12738. if ( event ) {
  12739. event.type = eventType;
  12740. }
  12741. this._open( event, target, response );
  12742. });
  12743. });
  12744. if ( content ) {
  12745. this._open( event, target, content );
  12746. }
  12747. },
  12748. _open: function( event, target, content ) {
  12749. var tooltip, events, delayedShow,
  12750. positionOption = $.extend( {}, this.options.position );
  12751. if ( !content ) {
  12752. return;
  12753. }
  12754. // Content can be updated multiple times. If the tooltip already
  12755. // exists, then just update the content and bail.
  12756. tooltip = this._find( target );
  12757. if ( tooltip.length ) {
  12758. tooltip.find( ".ui-tooltip-content" ).html( content );
  12759. return;
  12760. }
  12761. // if we have a title, clear it to prevent the native tooltip
  12762. // we have to check first to avoid defining a title if none exists
  12763. // (we don't want to cause an element to start matching [title])
  12764. //
  12765. // We use removeAttr only for key events, to allow IE to export the correct
  12766. // accessible attributes. For mouse events, set to empty string to avoid
  12767. // native tooltip showing up (happens only when removing inside mouseover).
  12768. if ( target.is( "[title]" ) ) {
  12769. if ( event && event.type === "mouseover" ) {
  12770. target.attr( "title", "" );
  12771. } else {
  12772. target.removeAttr( "title" );
  12773. }
  12774. }
  12775. tooltip = this._tooltip( target );
  12776. addDescribedBy( target, tooltip.attr( "id" ) );
  12777. tooltip.find( ".ui-tooltip-content" ).html( content );
  12778. function position( event ) {
  12779. positionOption.of = event;
  12780. if ( tooltip.is( ":hidden" ) ) {
  12781. return;
  12782. }
  12783. tooltip.position( positionOption );
  12784. }
  12785. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12786. this._on( this.document, {
  12787. mousemove: position
  12788. });
  12789. // trigger once to override element-relative positioning
  12790. position( event );
  12791. } else {
  12792. tooltip.position( $.extend({
  12793. of: target
  12794. }, this.options.position ) );
  12795. }
  12796. tooltip.hide();
  12797. this._show( tooltip, this.options.show );
  12798. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12799. // as the tooltip is visible, position the tooltip using the most recent
  12800. // event.
  12801. if ( this.options.show && this.options.show.delay ) {
  12802. delayedShow = this.delayedShow = setInterval(function() {
  12803. if ( tooltip.is( ":visible" ) ) {
  12804. position( positionOption.of );
  12805. clearInterval( delayedShow );
  12806. }
  12807. }, $.fx.interval );
  12808. }
  12809. this._trigger( "open", event, { tooltip: tooltip } );
  12810. events = {
  12811. keyup: function( event ) {
  12812. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12813. var fakeEvent = $.Event(event);
  12814. fakeEvent.currentTarget = target[0];
  12815. this.close( fakeEvent, true );
  12816. }
  12817. },
  12818. remove: function() {
  12819. this._removeTooltip( tooltip );
  12820. }
  12821. };
  12822. if ( !event || event.type === "mouseover" ) {
  12823. events.mouseleave = "close";
  12824. }
  12825. if ( !event || event.type === "focusin" ) {
  12826. events.focusout = "close";
  12827. }
  12828. this._on( true, target, events );
  12829. },
  12830. close: function( event ) {
  12831. var that = this,
  12832. target = $( event ? event.currentTarget : this.element ),
  12833. tooltip = this._find( target );
  12834. // disabling closes the tooltip, so we need to track when we're closing
  12835. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12836. if ( this.closing ) {
  12837. return;
  12838. }
  12839. // Clear the interval for delayed tracking tooltips
  12840. clearInterval( this.delayedShow );
  12841. // only set title if we had one before (see comment in _open())
  12842. if ( target.data( "ui-tooltip-title" ) ) {
  12843. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12844. }
  12845. removeDescribedBy( target );
  12846. tooltip.stop( true );
  12847. this._hide( tooltip, this.options.hide, function() {
  12848. that._removeTooltip( $( this ) );
  12849. });
  12850. target.removeData( "ui-tooltip-open" );
  12851. this._off( target, "mouseleave focusout keyup" );
  12852. // Remove 'remove' binding only on delegated targets
  12853. if ( target[0] !== this.element[0] ) {
  12854. this._off( target, "remove" );
  12855. }
  12856. this._off( this.document, "mousemove" );
  12857. if ( event && event.type === "mouseleave" ) {
  12858. $.each( this.parents, function( id, parent ) {
  12859. $( parent.element ).attr( "title", parent.title );
  12860. delete that.parents[ id ];
  12861. });
  12862. }
  12863. this.closing = true;
  12864. this._trigger( "close", event, { tooltip: tooltip } );
  12865. this.closing = false;
  12866. },
  12867. _tooltip: function( element ) {
  12868. var id = "ui-tooltip-" + increments++,
  12869. tooltip = $( "<div>" )
  12870. .attr({
  12871. id: id,
  12872. role: "tooltip"
  12873. })
  12874. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12875. ( this.options.tooltipClass || "" ) );
  12876. $( "<div>" )
  12877. .addClass( "ui-tooltip-content" )
  12878. .appendTo( tooltip );
  12879. tooltip.appendTo( this.document[0].body );
  12880. this.tooltips[ id ] = element;
  12881. return tooltip;
  12882. },
  12883. _find: function( target ) {
  12884. var id = target.data( "ui-tooltip-id" );
  12885. return id ? $( "#" + id ) : $();
  12886. },
  12887. _removeTooltip: function( tooltip ) {
  12888. tooltip.remove();
  12889. delete this.tooltips[ tooltip.attr( "id" ) ];
  12890. },
  12891. _destroy: function() {
  12892. var that = this;
  12893. // close open tooltips
  12894. $.each( this.tooltips, function( id, element ) {
  12895. // Delegate to close method to handle common cleanup
  12896. var event = $.Event( "blur" );
  12897. event.target = event.currentTarget = element[0];
  12898. that.close( event, true );
  12899. // Remove immediately; destroying an open tooltip doesn't use the
  12900. // hide animation
  12901. $( "#" + id ).remove();
  12902. // Restore the title
  12903. if ( element.data( "ui-tooltip-title" ) ) {
  12904. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12905. element.removeData( "ui-tooltip-title" );
  12906. }
  12907. });
  12908. }
  12909. });
  12910. }( jQuery ) );