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.

11395 lines
358 KiB

  1. /* NUGET: BEGIN LICENSE TEXT
  2. *
  3. * Microsoft grants you the right to use these script files for the sole
  4. * purpose of either: (i) interacting through your browser with the Microsoft
  5. * website or online service, subject to the applicable licensing or use
  6. * terms; or (ii) using the files as included with a Microsoft product subject
  7. * to that product's license terms. Microsoft reserves all other rights to the
  8. * files not expressly granted by Microsoft, whether by implication, estoppel
  9. * or otherwise. Insofar as a script file is dual licensed under GPL,
  10. * Microsoft neither took the code under GPL nor distributes it thereunder but
  11. * under the terms set out in this paragraph. All notices and licenses
  12. * below are for informational purposes only.
  13. *
  14. * jQuery UI; Copyright (c) 2012 Paul Bakaus; http://opensource.org/licenses/MIT
  15. *
  16. * Includes jQuery Easing v1.3; Copyright 2008 George McGinley Smith; http://opensource.org/licenses/BSD-3-Clause
  17. *
  18. * NUGET: END LICENSE TEXT */
  19. /*! jQuery UI - v1.8.24 - 2012-09-28
  20. * https://github.com/jquery/jquery-ui
  21. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js, jquery.effects.blind.js, jquery.effects.bounce.js, jquery.effects.clip.js, jquery.effects.drop.js, jquery.effects.explode.js, jquery.effects.fade.js, jquery.effects.fold.js, jquery.effects.highlight.js, jquery.effects.pulsate.js, jquery.effects.scale.js, jquery.effects.shake.js, jquery.effects.slide.js, jquery.effects.transfer.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.tabs.js
  22. * Copyright (c) 2012 AUTHORS.txt; Licensed MIT */
  23. (function( $, undefined ) {
  24. // prevent duplicate loading
  25. // this is only a problem because we proxy existing functions
  26. // and we don't want to double proxy them
  27. $.ui = $.ui || {};
  28. if ( $.ui.version ) {
  29. return;
  30. }
  31. $.extend( $.ui, {
  32. version: "1.8.24",
  33. keyCode: {
  34. ALT: 18,
  35. BACKSPACE: 8,
  36. CAPS_LOCK: 20,
  37. COMMA: 188,
  38. COMMAND: 91,
  39. COMMAND_LEFT: 91, // COMMAND
  40. COMMAND_RIGHT: 93,
  41. CONTROL: 17,
  42. DELETE: 46,
  43. DOWN: 40,
  44. END: 35,
  45. ENTER: 13,
  46. ESCAPE: 27,
  47. HOME: 36,
  48. INSERT: 45,
  49. LEFT: 37,
  50. MENU: 93, // COMMAND_RIGHT
  51. NUMPAD_ADD: 107,
  52. NUMPAD_DECIMAL: 110,
  53. NUMPAD_DIVIDE: 111,
  54. NUMPAD_ENTER: 108,
  55. NUMPAD_MULTIPLY: 106,
  56. NUMPAD_SUBTRACT: 109,
  57. PAGE_DOWN: 34,
  58. PAGE_UP: 33,
  59. PERIOD: 190,
  60. RIGHT: 39,
  61. SHIFT: 16,
  62. SPACE: 32,
  63. TAB: 9,
  64. UP: 38,
  65. WINDOWS: 91 // COMMAND
  66. }
  67. });
  68. // plugins
  69. $.fn.extend({
  70. propAttr: $.fn.prop || $.fn.attr,
  71. _focus: $.fn.focus,
  72. focus: function( delay, fn ) {
  73. return typeof delay === "number" ?
  74. this.each(function() {
  75. var elem = this;
  76. setTimeout(function() {
  77. $( elem ).focus();
  78. if ( fn ) {
  79. fn.call( elem );
  80. }
  81. }, delay );
  82. }) :
  83. this._focus.apply( this, arguments );
  84. },
  85. scrollParent: function() {
  86. var scrollParent;
  87. if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
  88. scrollParent = this.parents().filter(function() {
  89. return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
  90. }).eq(0);
  91. } else {
  92. scrollParent = this.parents().filter(function() {
  93. return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
  94. }).eq(0);
  95. }
  96. return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
  97. },
  98. zIndex: function( zIndex ) {
  99. if ( zIndex !== undefined ) {
  100. return this.css( "zIndex", zIndex );
  101. }
  102. if ( this.length ) {
  103. var elem = $( this[ 0 ] ), position, value;
  104. while ( elem.length && elem[ 0 ] !== document ) {
  105. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  106. // This makes behavior of this function consistent across browsers
  107. // WebKit always returns auto if the element is positioned
  108. position = elem.css( "position" );
  109. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  110. // IE returns 0 when zIndex is not specified
  111. // other browsers return a string
  112. // we ignore the case of nested elements with an explicit value of 0
  113. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  114. value = parseInt( elem.css( "zIndex" ), 10 );
  115. if ( !isNaN( value ) && value !== 0 ) {
  116. return value;
  117. }
  118. }
  119. elem = elem.parent();
  120. }
  121. }
  122. return 0;
  123. },
  124. disableSelection: function() {
  125. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  126. ".ui-disableSelection", function( event ) {
  127. event.preventDefault();
  128. });
  129. },
  130. enableSelection: function() {
  131. return this.unbind( ".ui-disableSelection" );
  132. }
  133. });
  134. // support: jQuery <1.8
  135. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  136. $.each( [ "Width", "Height" ], function( i, name ) {
  137. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  138. type = name.toLowerCase(),
  139. orig = {
  140. innerWidth: $.fn.innerWidth,
  141. innerHeight: $.fn.innerHeight,
  142. outerWidth: $.fn.outerWidth,
  143. outerHeight: $.fn.outerHeight
  144. };
  145. function reduce( elem, size, border, margin ) {
  146. $.each( side, function() {
  147. size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
  148. if ( border ) {
  149. size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
  150. }
  151. if ( margin ) {
  152. size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
  153. }
  154. });
  155. return size;
  156. }
  157. $.fn[ "inner" + name ] = function( size ) {
  158. if ( size === undefined ) {
  159. return orig[ "inner" + name ].call( this );
  160. }
  161. return this.each(function() {
  162. $( this ).css( type, reduce( this, size ) + "px" );
  163. });
  164. };
  165. $.fn[ "outer" + name] = function( size, margin ) {
  166. if ( typeof size !== "number" ) {
  167. return orig[ "outer" + name ].call( this, size );
  168. }
  169. return this.each(function() {
  170. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  171. });
  172. };
  173. });
  174. }
  175. // selectors
  176. function focusable( element, isTabIndexNotNaN ) {
  177. var nodeName = element.nodeName.toLowerCase();
  178. if ( "area" === nodeName ) {
  179. var map = element.parentNode,
  180. mapName = map.name,
  181. img;
  182. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  183. return false;
  184. }
  185. img = $( "img[usemap=#" + mapName + "]" )[0];
  186. return !!img && visible( img );
  187. }
  188. return ( /input|select|textarea|button|object/.test( nodeName )
  189. ? !element.disabled
  190. : "a" == nodeName
  191. ? element.href || isTabIndexNotNaN
  192. : isTabIndexNotNaN)
  193. // the element and all of its ancestors must be visible
  194. && visible( element );
  195. }
  196. function visible( element ) {
  197. return !$( element ).parents().andSelf().filter(function() {
  198. return $.curCSS( this, "visibility" ) === "hidden" ||
  199. $.expr.filters.hidden( this );
  200. }).length;
  201. }
  202. $.extend( $.expr[ ":" ], {
  203. data: $.expr.createPseudo ?
  204. $.expr.createPseudo(function( dataName ) {
  205. return function( elem ) {
  206. return !!$.data( elem, dataName );
  207. };
  208. }) :
  209. // support: jQuery <1.8
  210. function( elem, i, match ) {
  211. return !!$.data( elem, match[ 3 ] );
  212. },
  213. focusable: function( element ) {
  214. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  215. },
  216. tabbable: function( element ) {
  217. var tabIndex = $.attr( element, "tabindex" ),
  218. isTabIndexNaN = isNaN( tabIndex );
  219. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  220. }
  221. });
  222. // support
  223. $(function() {
  224. var body = document.body,
  225. div = body.appendChild( div = document.createElement( "div" ) );
  226. // access offsetHeight before setting the style to prevent a layout bug
  227. // in IE 9 which causes the elemnt to continue to take up space even
  228. // after it is removed from the DOM (#8026)
  229. div.offsetHeight;
  230. $.extend( div.style, {
  231. minHeight: "100px",
  232. height: "auto",
  233. padding: 0,
  234. borderWidth: 0
  235. });
  236. $.support.minHeight = div.offsetHeight === 100;
  237. $.support.selectstart = "onselectstart" in div;
  238. // set display to none to avoid a layout bug in IE
  239. // http://dev.jquery.com/ticket/4014
  240. body.removeChild( div ).style.display = "none";
  241. });
  242. // jQuery <1.4.3 uses curCSS, in 1.4.3 - 1.7.2 curCSS = css, 1.8+ only has css
  243. if ( !$.curCSS ) {
  244. $.curCSS = $.css;
  245. }
  246. // deprecated
  247. $.extend( $.ui, {
  248. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  249. plugin: {
  250. add: function( module, option, set ) {
  251. var proto = $.ui[ module ].prototype;
  252. for ( var i in set ) {
  253. proto.plugins[ i ] = proto.plugins[ i ] || [];
  254. proto.plugins[ i ].push( [ option, set[ i ] ] );
  255. }
  256. },
  257. call: function( instance, name, args ) {
  258. var set = instance.plugins[ name ];
  259. if ( !set || !instance.element[ 0 ].parentNode ) {
  260. return;
  261. }
  262. for ( var i = 0; i < set.length; i++ ) {
  263. if ( instance.options[ set[ i ][ 0 ] ] ) {
  264. set[ i ][ 1 ].apply( instance.element, args );
  265. }
  266. }
  267. }
  268. },
  269. // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
  270. contains: function( a, b ) {
  271. return document.compareDocumentPosition ?
  272. a.compareDocumentPosition( b ) & 16 :
  273. a !== b && a.contains( b );
  274. },
  275. // only used by resizable
  276. hasScroll: function( el, a ) {
  277. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  278. if ( $( el ).css( "overflow" ) === "hidden") {
  279. return false;
  280. }
  281. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  282. has = false;
  283. if ( el[ scroll ] > 0 ) {
  284. return true;
  285. }
  286. // TODO: determine which cases actually cause this to happen
  287. // if the element doesn't have the scroll set, see if it's possible to
  288. // set the scroll
  289. el[ scroll ] = 1;
  290. has = ( el[ scroll ] > 0 );
  291. el[ scroll ] = 0;
  292. return has;
  293. },
  294. // these are odd functions, fix the API or move into individual plugins
  295. isOverAxis: function( x, reference, size ) {
  296. //Determines when x coordinate is over "b" element axis
  297. return ( x > reference ) && ( x < ( reference + size ) );
  298. },
  299. isOver: function( y, x, top, left, height, width ) {
  300. //Determines when x, y coordinates is over "b" element
  301. return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
  302. }
  303. });
  304. })( jQuery );
  305. (function( $, undefined ) {
  306. // jQuery 1.4+
  307. if ( $.cleanData ) {
  308. var _cleanData = $.cleanData;
  309. $.cleanData = function( elems ) {
  310. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  311. try {
  312. $( elem ).triggerHandler( "remove" );
  313. // http://bugs.jquery.com/ticket/8235
  314. } catch( e ) {}
  315. }
  316. _cleanData( elems );
  317. };
  318. } else {
  319. var _remove = $.fn.remove;
  320. $.fn.remove = function( selector, keepData ) {
  321. return this.each(function() {
  322. if ( !keepData ) {
  323. if ( !selector || $.filter( selector, [ this ] ).length ) {
  324. $( "*", this ).add( [ this ] ).each(function() {
  325. try {
  326. $( this ).triggerHandler( "remove" );
  327. // http://bugs.jquery.com/ticket/8235
  328. } catch( e ) {}
  329. });
  330. }
  331. }
  332. return _remove.call( $(this), selector, keepData );
  333. });
  334. };
  335. }
  336. $.widget = function( name, base, prototype ) {
  337. var namespace = name.split( "." )[ 0 ],
  338. fullName;
  339. name = name.split( "." )[ 1 ];
  340. fullName = namespace + "-" + name;
  341. if ( !prototype ) {
  342. prototype = base;
  343. base = $.Widget;
  344. }
  345. // create selector for plugin
  346. $.expr[ ":" ][ fullName ] = function( elem ) {
  347. return !!$.data( elem, name );
  348. };
  349. $[ namespace ] = $[ namespace ] || {};
  350. $[ namespace ][ name ] = function( options, element ) {
  351. // allow instantiation without initializing for simple inheritance
  352. if ( arguments.length ) {
  353. this._createWidget( options, element );
  354. }
  355. };
  356. var basePrototype = new base();
  357. // we need to make the options hash a property directly on the new instance
  358. // otherwise we'll modify the options hash on the prototype that we're
  359. // inheriting from
  360. // $.each( basePrototype, function( key, val ) {
  361. // if ( $.isPlainObject(val) ) {
  362. // basePrototype[ key ] = $.extend( {}, val );
  363. // }
  364. // });
  365. basePrototype.options = $.extend( true, {}, basePrototype.options );
  366. $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
  367. namespace: namespace,
  368. widgetName: name,
  369. widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
  370. widgetBaseClass: fullName
  371. }, prototype );
  372. $.widget.bridge( name, $[ namespace ][ name ] );
  373. };
  374. $.widget.bridge = function( name, object ) {
  375. $.fn[ name ] = function( options ) {
  376. var isMethodCall = typeof options === "string",
  377. args = Array.prototype.slice.call( arguments, 1 ),
  378. returnValue = this;
  379. // allow multiple hashes to be passed on init
  380. options = !isMethodCall && args.length ?
  381. $.extend.apply( null, [ true, options ].concat(args) ) :
  382. options;
  383. // prevent calls to internal methods
  384. if ( isMethodCall && options.charAt( 0 ) === "_" ) {
  385. return returnValue;
  386. }
  387. if ( isMethodCall ) {
  388. this.each(function() {
  389. var instance = $.data( this, name ),
  390. methodValue = instance && $.isFunction( instance[options] ) ?
  391. instance[ options ].apply( instance, args ) :
  392. instance;
  393. // TODO: add this back in 1.9 and use $.error() (see #5972)
  394. // if ( !instance ) {
  395. // throw "cannot call methods on " + name + " prior to initialization; " +
  396. // "attempted to call method '" + options + "'";
  397. // }
  398. // if ( !$.isFunction( instance[options] ) ) {
  399. // throw "no such method '" + options + "' for " + name + " widget instance";
  400. // }
  401. // var methodValue = instance[ options ].apply( instance, args );
  402. if ( methodValue !== instance && methodValue !== undefined ) {
  403. returnValue = methodValue;
  404. return false;
  405. }
  406. });
  407. } else {
  408. this.each(function() {
  409. var instance = $.data( this, name );
  410. if ( instance ) {
  411. instance.option( options || {} )._init();
  412. } else {
  413. $.data( this, name, new object( options, this ) );
  414. }
  415. });
  416. }
  417. return returnValue;
  418. };
  419. };
  420. $.Widget = function( options, element ) {
  421. // allow instantiation without initializing for simple inheritance
  422. if ( arguments.length ) {
  423. this._createWidget( options, element );
  424. }
  425. };
  426. $.Widget.prototype = {
  427. widgetName: "widget",
  428. widgetEventPrefix: "",
  429. options: {
  430. disabled: false
  431. },
  432. _createWidget: function( options, element ) {
  433. // $.widget.bridge stores the plugin instance, but we do it anyway
  434. // so that it's stored even before the _create function runs
  435. $.data( element, this.widgetName, this );
  436. this.element = $( element );
  437. this.options = $.extend( true, {},
  438. this.options,
  439. this._getCreateOptions(),
  440. options );
  441. var self = this;
  442. this.element.bind( "remove." + this.widgetName, function() {
  443. self.destroy();
  444. });
  445. this._create();
  446. this._trigger( "create" );
  447. this._init();
  448. },
  449. _getCreateOptions: function() {
  450. return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
  451. },
  452. _create: function() {},
  453. _init: function() {},
  454. destroy: function() {
  455. this.element
  456. .unbind( "." + this.widgetName )
  457. .removeData( this.widgetName );
  458. this.widget()
  459. .unbind( "." + this.widgetName )
  460. .removeAttr( "aria-disabled" )
  461. .removeClass(
  462. this.widgetBaseClass + "-disabled " +
  463. "ui-state-disabled" );
  464. },
  465. widget: function() {
  466. return this.element;
  467. },
  468. option: function( key, value ) {
  469. var options = key;
  470. if ( arguments.length === 0 ) {
  471. // don't return a reference to the internal hash
  472. return $.extend( {}, this.options );
  473. }
  474. if (typeof key === "string" ) {
  475. if ( value === undefined ) {
  476. return this.options[ key ];
  477. }
  478. options = {};
  479. options[ key ] = value;
  480. }
  481. this._setOptions( options );
  482. return this;
  483. },
  484. _setOptions: function( options ) {
  485. var self = this;
  486. $.each( options, function( key, value ) {
  487. self._setOption( key, value );
  488. });
  489. return this;
  490. },
  491. _setOption: function( key, value ) {
  492. this.options[ key ] = value;
  493. if ( key === "disabled" ) {
  494. this.widget()
  495. [ value ? "addClass" : "removeClass"](
  496. this.widgetBaseClass + "-disabled" + " " +
  497. "ui-state-disabled" )
  498. .attr( "aria-disabled", value );
  499. }
  500. return this;
  501. },
  502. enable: function() {
  503. return this._setOption( "disabled", false );
  504. },
  505. disable: function() {
  506. return this._setOption( "disabled", true );
  507. },
  508. _trigger: function( type, event, data ) {
  509. var prop, orig,
  510. callback = this.options[ type ];
  511. data = data || {};
  512. event = $.Event( event );
  513. event.type = ( type === this.widgetEventPrefix ?
  514. type :
  515. this.widgetEventPrefix + type ).toLowerCase();
  516. // the original event may come from any element
  517. // so we need to reset the target on the new event
  518. event.target = this.element[ 0 ];
  519. // copy original event properties over to the new event
  520. orig = event.originalEvent;
  521. if ( orig ) {
  522. for ( prop in orig ) {
  523. if ( !( prop in event ) ) {
  524. event[ prop ] = orig[ prop ];
  525. }
  526. }
  527. }
  528. this.element.trigger( event, data );
  529. return !( $.isFunction(callback) &&
  530. callback.call( this.element[0], event, data ) === false ||
  531. event.isDefaultPrevented() );
  532. }
  533. };
  534. })( jQuery );
  535. (function( $, undefined ) {
  536. var mouseHandled = false;
  537. $( document ).mouseup( function( e ) {
  538. mouseHandled = false;
  539. });
  540. $.widget("ui.mouse", {
  541. options: {
  542. cancel: ':input,option',
  543. distance: 1,
  544. delay: 0
  545. },
  546. _mouseInit: function() {
  547. var self = this;
  548. this.element
  549. .bind('mousedown.'+this.widgetName, function(event) {
  550. return self._mouseDown(event);
  551. })
  552. .bind('click.'+this.widgetName, function(event) {
  553. if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
  554. $.removeData(event.target, self.widgetName + '.preventClickEvent');
  555. event.stopImmediatePropagation();
  556. return false;
  557. }
  558. });
  559. this.started = false;
  560. },
  561. // TODO: make sure destroying one instance of mouse doesn't mess with
  562. // other instances of mouse
  563. _mouseDestroy: function() {
  564. this.element.unbind('.'+this.widgetName);
  565. if ( this._mouseMoveDelegate ) {
  566. $(document)
  567. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  568. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  569. }
  570. },
  571. _mouseDown: function(event) {
  572. // don't let more than one widget handle mouseStart
  573. if( mouseHandled ) { return };
  574. // we may have missed mouseup (out of window)
  575. (this._mouseStarted && this._mouseUp(event));
  576. this._mouseDownEvent = event;
  577. var self = this,
  578. btnIsLeft = (event.which == 1),
  579. // event.target.nodeName works around a bug in IE 8 with
  580. // disabled inputs (#7620)
  581. elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  582. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  583. return true;
  584. }
  585. this.mouseDelayMet = !this.options.delay;
  586. if (!this.mouseDelayMet) {
  587. this._mouseDelayTimer = setTimeout(function() {
  588. self.mouseDelayMet = true;
  589. }, this.options.delay);
  590. }
  591. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  592. this._mouseStarted = (this._mouseStart(event) !== false);
  593. if (!this._mouseStarted) {
  594. event.preventDefault();
  595. return true;
  596. }
  597. }
  598. // Click event may never have fired (Gecko & Opera)
  599. if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
  600. $.removeData(event.target, this.widgetName + '.preventClickEvent');
  601. }
  602. // these delegates are required to keep context
  603. this._mouseMoveDelegate = function(event) {
  604. return self._mouseMove(event);
  605. };
  606. this._mouseUpDelegate = function(event) {
  607. return self._mouseUp(event);
  608. };
  609. $(document)
  610. .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  611. .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  612. event.preventDefault();
  613. mouseHandled = true;
  614. return true;
  615. },
  616. _mouseMove: function(event) {
  617. // IE mouseup check - mouseup happened when mouse was out of window
  618. if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
  619. return this._mouseUp(event);
  620. }
  621. if (this._mouseStarted) {
  622. this._mouseDrag(event);
  623. return event.preventDefault();
  624. }
  625. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  626. this._mouseStarted =
  627. (this._mouseStart(this._mouseDownEvent, event) !== false);
  628. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  629. }
  630. return !this._mouseStarted;
  631. },
  632. _mouseUp: function(event) {
  633. $(document)
  634. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  635. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  636. if (this._mouseStarted) {
  637. this._mouseStarted = false;
  638. if (event.target == this._mouseDownEvent.target) {
  639. $.data(event.target, this.widgetName + '.preventClickEvent', true);
  640. }
  641. this._mouseStop(event);
  642. }
  643. return false;
  644. },
  645. _mouseDistanceMet: function(event) {
  646. return (Math.max(
  647. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  648. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  649. ) >= this.options.distance
  650. );
  651. },
  652. _mouseDelayMet: function(event) {
  653. return this.mouseDelayMet;
  654. },
  655. // These are placeholder methods, to be overriden by extending plugin
  656. _mouseStart: function(event) {},
  657. _mouseDrag: function(event) {},
  658. _mouseStop: function(event) {},
  659. _mouseCapture: function(event) { return true; }
  660. });
  661. })(jQuery);
  662. (function( $, undefined ) {
  663. $.widget("ui.draggable", $.ui.mouse, {
  664. widgetEventPrefix: "drag",
  665. options: {
  666. addClasses: true,
  667. appendTo: "parent",
  668. axis: false,
  669. connectToSortable: false,
  670. containment: false,
  671. cursor: "auto",
  672. cursorAt: false,
  673. grid: false,
  674. handle: false,
  675. helper: "original",
  676. iframeFix: false,
  677. opacity: false,
  678. refreshPositions: false,
  679. revert: false,
  680. revertDuration: 500,
  681. scope: "default",
  682. scroll: true,
  683. scrollSensitivity: 20,
  684. scrollSpeed: 20,
  685. snap: false,
  686. snapMode: "both",
  687. snapTolerance: 20,
  688. stack: false,
  689. zIndex: false
  690. },
  691. _create: function() {
  692. if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
  693. this.element[0].style.position = 'relative';
  694. (this.options.addClasses && this.element.addClass("ui-draggable"));
  695. (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
  696. this._mouseInit();
  697. },
  698. destroy: function() {
  699. if(!this.element.data('draggable')) return;
  700. this.element
  701. .removeData("draggable")
  702. .unbind(".draggable")
  703. .removeClass("ui-draggable"
  704. + " ui-draggable-dragging"
  705. + " ui-draggable-disabled");
  706. this._mouseDestroy();
  707. return this;
  708. },
  709. _mouseCapture: function(event) {
  710. var o = this.options;
  711. // among others, prevent a drag on a resizable-handle
  712. if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
  713. return false;
  714. //Quit if we're not on a valid handle
  715. this.handle = this._getHandle(event);
  716. if (!this.handle)
  717. return false;
  718. if ( o.iframeFix ) {
  719. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  720. $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
  721. .css({
  722. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  723. position: "absolute", opacity: "0.001", zIndex: 1000
  724. })
  725. .css($(this).offset())
  726. .appendTo("body");
  727. });
  728. }
  729. return true;
  730. },
  731. _mouseStart: function(event) {
  732. var o = this.options;
  733. //Create and append the visible helper
  734. this.helper = this._createHelper(event);
  735. this.helper.addClass("ui-draggable-dragging");
  736. //Cache the helper size
  737. this._cacheHelperProportions();
  738. //If ddmanager is used for droppables, set the global draggable
  739. if($.ui.ddmanager)
  740. $.ui.ddmanager.current = this;
  741. /*
  742. * - Position generation -
  743. * This block generates everything position related - it's the core of draggables.
  744. */
  745. //Cache the margins of the original element
  746. this._cacheMargins();
  747. //Store the helper's css position
  748. this.cssPosition = this.helper.css("position");
  749. this.scrollParent = this.helper.scrollParent();
  750. //The element's absolute position on the page minus margins
  751. this.offset = this.positionAbs = this.element.offset();
  752. this.offset = {
  753. top: this.offset.top - this.margins.top,
  754. left: this.offset.left - this.margins.left
  755. };
  756. $.extend(this.offset, {
  757. click: { //Where the click happened, relative to the element
  758. left: event.pageX - this.offset.left,
  759. top: event.pageY - this.offset.top
  760. },
  761. parent: this._getParentOffset(),
  762. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  763. });
  764. //Generate the original position
  765. this.originalPosition = this.position = this._generatePosition(event);
  766. this.originalPageX = event.pageX;
  767. this.originalPageY = event.pageY;
  768. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  769. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  770. //Set a containment if given in the options
  771. if(o.containment)
  772. this._setContainment();
  773. //Trigger event + callbacks
  774. if(this._trigger("start", event) === false) {
  775. this._clear();
  776. return false;
  777. }
  778. //Recache the helper size
  779. this._cacheHelperProportions();
  780. //Prepare the droppable offsets
  781. if ($.ui.ddmanager && !o.dropBehaviour)
  782. $.ui.ddmanager.prepareOffsets(this, event);
  783. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  784. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  785. if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
  786. return true;
  787. },
  788. _mouseDrag: function(event, noPropagation) {
  789. //Compute the helpers position
  790. this.position = this._generatePosition(event);
  791. this.positionAbs = this._convertPositionTo("absolute");
  792. //Call plugins and callbacks and use the resulting position if something is returned
  793. if (!noPropagation) {
  794. var ui = this._uiHash();
  795. if(this._trigger('drag', event, ui) === false) {
  796. this._mouseUp({});
  797. return false;
  798. }
  799. this.position = ui.position;
  800. }
  801. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  802. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  803. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  804. return false;
  805. },
  806. _mouseStop: function(event) {
  807. //If we are using droppables, inform the manager about the drop
  808. var dropped = false;
  809. if ($.ui.ddmanager && !this.options.dropBehaviour)
  810. dropped = $.ui.ddmanager.drop(this, event);
  811. //if a drop comes from outside (a sortable)
  812. if(this.dropped) {
  813. dropped = this.dropped;
  814. this.dropped = false;
  815. }
  816. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  817. var element = this.element[0], elementInDom = false;
  818. while ( element && (element = element.parentNode) ) {
  819. if (element == document ) {
  820. elementInDom = true;
  821. }
  822. }
  823. if ( !elementInDom && this.options.helper === "original" )
  824. return false;
  825. 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))) {
  826. var self = this;
  827. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  828. if(self._trigger("stop", event) !== false) {
  829. self._clear();
  830. }
  831. });
  832. } else {
  833. if(this._trigger("stop", event) !== false) {
  834. this._clear();
  835. }
  836. }
  837. return false;
  838. },
  839. _mouseUp: function(event) {
  840. //Remove frame helpers
  841. $("div.ui-draggable-iframeFix").each(function() {
  842. this.parentNode.removeChild(this);
  843. });
  844. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  845. if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
  846. return $.ui.mouse.prototype._mouseUp.call(this, event);
  847. },
  848. cancel: function() {
  849. if(this.helper.is(".ui-draggable-dragging")) {
  850. this._mouseUp({});
  851. } else {
  852. this._clear();
  853. }
  854. return this;
  855. },
  856. _getHandle: function(event) {
  857. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  858. $(this.options.handle, this.element)
  859. .find("*")
  860. .andSelf()
  861. .each(function() {
  862. if(this == event.target) handle = true;
  863. });
  864. return handle;
  865. },
  866. _createHelper: function(event) {
  867. var o = this.options;
  868. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
  869. if(!helper.parents('body').length)
  870. helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
  871. if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
  872. helper.css("position", "absolute");
  873. return helper;
  874. },
  875. _adjustOffsetFromHelper: function(obj) {
  876. if (typeof obj == 'string') {
  877. obj = obj.split(' ');
  878. }
  879. if ($.isArray(obj)) {
  880. obj = {left: +obj[0], top: +obj[1] || 0};
  881. }
  882. if ('left' in obj) {
  883. this.offset.click.left = obj.left + this.margins.left;
  884. }
  885. if ('right' in obj) {
  886. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  887. }
  888. if ('top' in obj) {
  889. this.offset.click.top = obj.top + this.margins.top;
  890. }
  891. if ('bottom' in obj) {
  892. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  893. }
  894. },
  895. _getParentOffset: function() {
  896. //Get the offsetParent and cache its position
  897. this.offsetParent = this.helper.offsetParent();
  898. var po = this.offsetParent.offset();
  899. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  900. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  901. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  902. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  903. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  904. po.left += this.scrollParent.scrollLeft();
  905. po.top += this.scrollParent.scrollTop();
  906. }
  907. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  908. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  909. po = { top: 0, left: 0 };
  910. return {
  911. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  912. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  913. };
  914. },
  915. _getRelativeOffset: function() {
  916. if(this.cssPosition == "relative") {
  917. var p = this.element.position();
  918. return {
  919. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  920. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  921. };
  922. } else {
  923. return { top: 0, left: 0 };
  924. }
  925. },
  926. _cacheMargins: function() {
  927. this.margins = {
  928. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  929. top: (parseInt(this.element.css("marginTop"),10) || 0),
  930. right: (parseInt(this.element.css("marginRight"),10) || 0),
  931. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  932. };
  933. },
  934. _cacheHelperProportions: function() {
  935. this.helperProportions = {
  936. width: this.helper.outerWidth(),
  937. height: this.helper.outerHeight()
  938. };
  939. },
  940. _setContainment: function() {
  941. var o = this.options;
  942. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  943. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  944. o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  945. o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  946. (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  947. (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  948. ];
  949. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
  950. var c = $(o.containment);
  951. var ce = c[0]; if(!ce) return;
  952. var co = c.offset();
  953. var over = ($(ce).css("overflow") != 'hidden');
  954. this.containment = [
  955. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  956. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  957. (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 - this.margins.right,
  958. (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 - this.margins.bottom
  959. ];
  960. this.relative_container = c;
  961. } else if(o.containment.constructor == Array) {
  962. this.containment = o.containment;
  963. }
  964. },
  965. _convertPositionTo: function(d, pos) {
  966. if(!pos) pos = this.position;
  967. var mod = d == "absolute" ? 1 : -1;
  968. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  969. return {
  970. top: (
  971. pos.top // The absolute mouse position
  972. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  973. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  974. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  975. ),
  976. left: (
  977. pos.left // The absolute mouse position
  978. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  979. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  980. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  981. )
  982. };
  983. },
  984. _generatePosition: function(event) {
  985. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  986. var pageX = event.pageX;
  987. var pageY = event.pageY;
  988. /*
  989. * - Position constraining -
  990. * Constrain the position to a mix of grid, containment.
  991. */
  992. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  993. var containment;
  994. if(this.containment) {
  995. if (this.relative_container){
  996. var co = this.relative_container.offset();
  997. containment = [ this.containment[0] + co.left,
  998. this.containment[1] + co.top,
  999. this.containment[2] + co.left,
  1000. this.containment[3] + co.top ];
  1001. }
  1002. else {
  1003. containment = this.containment;
  1004. }
  1005. if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
  1006. if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
  1007. if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
  1008. if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
  1009. }
  1010. if(o.grid) {
  1011. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1012. var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1013. 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;
  1014. var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1015. 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;
  1016. }
  1017. }
  1018. return {
  1019. top: (
  1020. pageY // The absolute mouse position
  1021. - this.offset.click.top // Click offset (relative to the element)
  1022. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  1023. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  1024. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  1025. ),
  1026. left: (
  1027. pageX // The absolute mouse position
  1028. - this.offset.click.left // Click offset (relative to the element)
  1029. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  1030. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  1031. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  1032. )
  1033. };
  1034. },
  1035. _clear: function() {
  1036. this.helper.removeClass("ui-draggable-dragging");
  1037. if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
  1038. //if($.ui.ddmanager) $.ui.ddmanager.current = null;
  1039. this.helper = null;
  1040. this.cancelHelperRemoval = false;
  1041. },
  1042. // From now on bulk stuff - mainly helpers
  1043. _trigger: function(type, event, ui) {
  1044. ui = ui || this._uiHash();
  1045. $.ui.plugin.call(this, type, [event, ui]);
  1046. if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
  1047. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1048. },
  1049. plugins: {},
  1050. _uiHash: function(event) {
  1051. return {
  1052. helper: this.helper,
  1053. position: this.position,
  1054. originalPosition: this.originalPosition,
  1055. offset: this.positionAbs
  1056. };
  1057. }
  1058. });
  1059. $.extend($.ui.draggable, {
  1060. version: "1.8.24"
  1061. });
  1062. $.ui.plugin.add("draggable", "connectToSortable", {
  1063. start: function(event, ui) {
  1064. var inst = $(this).data("draggable"), o = inst.options,
  1065. uiSortable = $.extend({}, ui, { item: inst.element });
  1066. inst.sortables = [];
  1067. $(o.connectToSortable).each(function() {
  1068. var sortable = $.data(this, 'sortable');
  1069. if (sortable && !sortable.options.disabled) {
  1070. inst.sortables.push({
  1071. instance: sortable,
  1072. shouldRevert: sortable.options.revert
  1073. });
  1074. 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).
  1075. sortable._trigger("activate", event, uiSortable);
  1076. }
  1077. });
  1078. },
  1079. stop: function(event, ui) {
  1080. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1081. var inst = $(this).data("draggable"),
  1082. uiSortable = $.extend({}, ui, { item: inst.element });
  1083. $.each(inst.sortables, function() {
  1084. if(this.instance.isOver) {
  1085. this.instance.isOver = 0;
  1086. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1087. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1088. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
  1089. if(this.shouldRevert) this.instance.options.revert = true;
  1090. //Trigger the stop of the sortable
  1091. this.instance._mouseStop(event);
  1092. this.instance.options.helper = this.instance.options._helper;
  1093. //If the helper has been the original item, restore properties in the sortable
  1094. if(inst.options.helper == 'original')
  1095. this.instance.currentItem.css({ top: 'auto', left: 'auto' });
  1096. } else {
  1097. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1098. this.instance._trigger("deactivate", event, uiSortable);
  1099. }
  1100. });
  1101. },
  1102. drag: function(event, ui) {
  1103. var inst = $(this).data("draggable"), self = this;
  1104. var checkPos = function(o) {
  1105. var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
  1106. var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
  1107. var itemHeight = o.height, itemWidth = o.width;
  1108. var itemTop = o.top, itemLeft = o.left;
  1109. return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
  1110. };
  1111. $.each(inst.sortables, function(i) {
  1112. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1113. this.instance.positionAbs = inst.positionAbs;
  1114. this.instance.helperProportions = inst.helperProportions;
  1115. this.instance.offset.click = inst.offset.click;
  1116. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1117. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1118. if(!this.instance.isOver) {
  1119. this.instance.isOver = 1;
  1120. //Now we fake the start of dragging for the sortable instance,
  1121. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1122. //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)
  1123. this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
  1124. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1125. this.instance.options.helper = function() { return ui.helper[0]; };
  1126. event.target = this.instance.currentItem[0];
  1127. this.instance._mouseCapture(event, true);
  1128. this.instance._mouseStart(event, true, true);
  1129. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1130. this.instance.offset.click.top = inst.offset.click.top;
  1131. this.instance.offset.click.left = inst.offset.click.left;
  1132. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1133. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1134. inst._trigger("toSortable", event);
  1135. inst.dropped = this.instance.element; //draggable revert needs that
  1136. //hack so receive/update callbacks work (mostly)
  1137. inst.currentItem = inst.element;
  1138. this.instance.fromOutside = inst;
  1139. }
  1140. //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
  1141. if(this.instance.currentItem) this.instance._mouseDrag(event);
  1142. } else {
  1143. //If it doesn't intersect with the sortable, and it intersected before,
  1144. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1145. if(this.instance.isOver) {
  1146. this.instance.isOver = 0;
  1147. this.instance.cancelHelperRemoval = true;
  1148. //Prevent reverting on this forced stop
  1149. this.instance.options.revert = false;
  1150. // The out event needs to be triggered independently
  1151. this.instance._trigger('out', event, this.instance._uiHash(this.instance));
  1152. this.instance._mouseStop(event, true);
  1153. this.instance.options.helper = this.instance.options._helper;
  1154. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1155. this.instance.currentItem.remove();
  1156. if(this.instance.placeholder) this.instance.placeholder.remove();
  1157. inst._trigger("fromSortable", event);
  1158. inst.dropped = false; //draggable revert needs that
  1159. }
  1160. };
  1161. });
  1162. }
  1163. });
  1164. $.ui.plugin.add("draggable", "cursor", {
  1165. start: function(event, ui) {
  1166. var t = $('body'), o = $(this).data('draggable').options;
  1167. if (t.css("cursor")) o._cursor = t.css("cursor");
  1168. t.css("cursor", o.cursor);
  1169. },
  1170. stop: function(event, ui) {
  1171. var o = $(this).data('draggable').options;
  1172. if (o._cursor) $('body').css("cursor", o._cursor);
  1173. }
  1174. });
  1175. $.ui.plugin.add("draggable", "opacity", {
  1176. start: function(event, ui) {
  1177. var t = $(ui.helper), o = $(this).data('draggable').options;
  1178. if(t.css("opacity")) o._opacity = t.css("opacity");
  1179. t.css('opacity', o.opacity);
  1180. },
  1181. stop: function(event, ui) {
  1182. var o = $(this).data('draggable').options;
  1183. if(o._opacity) $(ui.helper).css('opacity', o._opacity);
  1184. }
  1185. });
  1186. $.ui.plugin.add("draggable", "scroll", {
  1187. start: function(event, ui) {
  1188. var i = $(this).data("draggable");
  1189. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
  1190. },
  1191. drag: function(event, ui) {
  1192. var i = $(this).data("draggable"), o = i.options, scrolled = false;
  1193. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
  1194. if(!o.axis || o.axis != 'x') {
  1195. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  1196. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1197. else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
  1198. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1199. }
  1200. if(!o.axis || o.axis != 'y') {
  1201. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  1202. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1203. else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
  1204. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1205. }
  1206. } else {
  1207. if(!o.axis || o.axis != 'x') {
  1208. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  1209. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1210. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  1211. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1212. }
  1213. if(!o.axis || o.axis != 'y') {
  1214. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  1215. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1216. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  1217. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1218. }
  1219. }
  1220. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  1221. $.ui.ddmanager.prepareOffsets(i, event);
  1222. }
  1223. });
  1224. $.ui.plugin.add("draggable", "snap", {
  1225. start: function(event, ui) {
  1226. var i = $(this).data("draggable"), o = i.options;
  1227. i.snapElements = [];
  1228. $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
  1229. var $t = $(this); var $o = $t.offset();
  1230. if(this != i.element[0]) i.snapElements.push({
  1231. item: this,
  1232. width: $t.outerWidth(), height: $t.outerHeight(),
  1233. top: $o.top, left: $o.left
  1234. });
  1235. });
  1236. },
  1237. drag: function(event, ui) {
  1238. var inst = $(this).data("draggable"), o = inst.options;
  1239. var d = o.snapTolerance;
  1240. var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1241. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1242. for (var i = inst.snapElements.length - 1; i >= 0; i--){
  1243. var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
  1244. t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
  1245. //Yes, I know, this is insane ;)
  1246. if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
  1247. if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1248. inst.snapElements[i].snapping = false;
  1249. continue;
  1250. }
  1251. if(o.snapMode != 'inner') {
  1252. var ts = Math.abs(t - y2) <= d;
  1253. var bs = Math.abs(b - y1) <= d;
  1254. var ls = Math.abs(l - x2) <= d;
  1255. var rs = Math.abs(r - x1) <= d;
  1256. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1257. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1258. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1259. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1260. }
  1261. var first = (ts || bs || ls || rs);
  1262. if(o.snapMode != 'outer') {
  1263. var ts = Math.abs(t - y1) <= d;
  1264. var bs = Math.abs(b - y2) <= d;
  1265. var ls = Math.abs(l - x1) <= d;
  1266. var rs = Math.abs(r - x2) <= d;
  1267. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1268. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1269. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1270. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1271. }
  1272. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
  1273. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1274. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1275. };
  1276. }
  1277. });
  1278. $.ui.plugin.add("draggable", "stack", {
  1279. start: function(event, ui) {
  1280. var o = $(this).data("draggable").options;
  1281. var group = $.makeArray($(o.stack)).sort(function(a,b) {
  1282. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1283. });
  1284. if (!group.length) { return; }
  1285. var min = parseInt(group[0].style.zIndex) || 0;
  1286. $(group).each(function(i) {
  1287. this.style.zIndex = min + i;
  1288. });
  1289. this[0].style.zIndex = min + group.length;
  1290. }
  1291. });
  1292. $.ui.plugin.add("draggable", "zIndex", {
  1293. start: function(event, ui) {
  1294. var t = $(ui.helper), o = $(this).data("draggable").options;
  1295. if(t.css("zIndex")) o._zIndex = t.css("zIndex");
  1296. t.css('zIndex', o.zIndex);
  1297. },
  1298. stop: function(event, ui) {
  1299. var o = $(this).data("draggable").options;
  1300. if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
  1301. }
  1302. });
  1303. })(jQuery);
  1304. (function( $, undefined ) {
  1305. $.widget("ui.droppable", {
  1306. widgetEventPrefix: "drop",
  1307. options: {
  1308. accept: '*',
  1309. activeClass: false,
  1310. addClasses: true,
  1311. greedy: false,
  1312. hoverClass: false,
  1313. scope: 'default',
  1314. tolerance: 'intersect'
  1315. },
  1316. _create: function() {
  1317. var o = this.options, accept = o.accept;
  1318. this.isover = 0; this.isout = 1;
  1319. this.accept = $.isFunction(accept) ? accept : function(d) {
  1320. return d.is(accept);
  1321. };
  1322. //Store the droppable's proportions
  1323. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1324. // Add the reference and positions to the manager
  1325. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1326. $.ui.ddmanager.droppables[o.scope].push(this);
  1327. (o.addClasses && this.element.addClass("ui-droppable"));
  1328. },
  1329. destroy: function() {
  1330. var drop = $.ui.ddmanager.droppables[this.options.scope];
  1331. for ( var i = 0; i < drop.length; i++ )
  1332. if ( drop[i] == this )
  1333. drop.splice(i, 1);
  1334. this.element
  1335. .removeClass("ui-droppable ui-droppable-disabled")
  1336. .removeData("droppable")
  1337. .unbind(".droppable");
  1338. return this;
  1339. },
  1340. _setOption: function(key, value) {
  1341. if(key == 'accept') {
  1342. this.accept = $.isFunction(value) ? value : function(d) {
  1343. return d.is(value);
  1344. };
  1345. }
  1346. $.Widget.prototype._setOption.apply(this, arguments);
  1347. },
  1348. _activate: function(event) {
  1349. var draggable = $.ui.ddmanager.current;
  1350. if(this.options.activeClass) this.element.addClass(this.options.activeClass);
  1351. (draggable && this._trigger('activate', event, this.ui(draggable)));
  1352. },
  1353. _deactivate: function(event) {
  1354. var draggable = $.ui.ddmanager.current;
  1355. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1356. (draggable && this._trigger('deactivate', event, this.ui(draggable)));
  1357. },
  1358. _over: function(event) {
  1359. var draggable = $.ui.ddmanager.current;
  1360. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1361. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1362. if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
  1363. this._trigger('over', event, this.ui(draggable));
  1364. }
  1365. },
  1366. _out: function(event) {
  1367. var draggable = $.ui.ddmanager.current;
  1368. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1369. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1370. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1371. this._trigger('out', event, this.ui(draggable));
  1372. }
  1373. },
  1374. _drop: function(event,custom) {
  1375. var draggable = custom || $.ui.ddmanager.current;
  1376. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
  1377. var childrenIntersection = false;
  1378. this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
  1379. var inst = $.data(this, 'droppable');
  1380. if(
  1381. inst.options.greedy
  1382. && !inst.options.disabled
  1383. && inst.options.scope == draggable.options.scope
  1384. && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
  1385. && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1386. ) { childrenIntersection = true; return false; }
  1387. });
  1388. if(childrenIntersection) return false;
  1389. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1390. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1391. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1392. this._trigger('drop', event, this.ui(draggable));
  1393. return this.element;
  1394. }
  1395. return false;
  1396. },
  1397. ui: function(c) {
  1398. return {
  1399. draggable: (c.currentItem || c.element),
  1400. helper: c.helper,
  1401. position: c.position,
  1402. offset: c.positionAbs
  1403. };
  1404. }
  1405. });
  1406. $.extend($.ui.droppable, {
  1407. version: "1.8.24"
  1408. });
  1409. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1410. if (!droppable.offset) return false;
  1411. var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1412. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
  1413. var l = droppable.offset.left, r = l + droppable.proportions.width,
  1414. t = droppable.offset.top, b = t + droppable.proportions.height;
  1415. switch (toleranceMode) {
  1416. case 'fit':
  1417. return (l <= x1 && x2 <= r
  1418. && t <= y1 && y2 <= b);
  1419. break;
  1420. case 'intersect':
  1421. return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
  1422. && x2 - (draggable.helperProportions.width / 2) < r // Left Half
  1423. && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
  1424. && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1425. break;
  1426. case 'pointer':
  1427. var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
  1428. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
  1429. isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
  1430. return isOver;
  1431. break;
  1432. case 'touch':
  1433. return (
  1434. (y1 >= t && y1 <= b) || // Top edge touching
  1435. (y2 >= t && y2 <= b) || // Bottom edge touching
  1436. (y1 < t && y2 > b) // Surrounded vertically
  1437. ) && (
  1438. (x1 >= l && x1 <= r) || // Left edge touching
  1439. (x2 >= l && x2 <= r) || // Right edge touching
  1440. (x1 < l && x2 > r) // Surrounded horizontally
  1441. );
  1442. break;
  1443. default:
  1444. return false;
  1445. break;
  1446. }
  1447. };
  1448. /*
  1449. This manager tracks offsets of draggables and droppables
  1450. */
  1451. $.ui.ddmanager = {
  1452. current: null,
  1453. droppables: { 'default': [] },
  1454. prepareOffsets: function(t, event) {
  1455. var m = $.ui.ddmanager.droppables[t.options.scope] || [];
  1456. var type = event ? event.type : null; // workaround for #2317
  1457. var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
  1458. droppablesLoop: for (var i = 0; i < m.length; i++) {
  1459. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
  1460. for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
  1461. m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
  1462. if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
  1463. m[i].offset = m[i].element.offset();
  1464. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1465. }
  1466. },
  1467. drop: function(draggable, event) {
  1468. var dropped = false;
  1469. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1470. if(!this.options) return;
  1471. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
  1472. dropped = this._drop.call(this, event) || dropped;
  1473. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1474. this.isout = 1; this.isover = 0;
  1475. this._deactivate.call(this, event);
  1476. }
  1477. });
  1478. return dropped;
  1479. },
  1480. dragStart: function( draggable, event ) {
  1481. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1482. draggable.element.parents( ":not(body,html)" ).bind( "scroll.droppable", function() {
  1483. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  1484. });
  1485. },
  1486. drag: function(draggable, event) {
  1487. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1488. if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
  1489. //Run through all droppables and check their positions based on specific tolerance options
  1490. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1491. if(this.options.disabled || this.greedyChild || !this.visible) return;
  1492. var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
  1493. var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
  1494. if(!c) return;
  1495. var parentInstance;
  1496. if (this.options.greedy) {
  1497. // find droppable parents with same scope
  1498. var scope = this.options.scope;
  1499. var parent = this.element.parents(':data(droppable)').filter(function () {
  1500. return $.data(this, 'droppable').options.scope === scope;
  1501. });
  1502. if (parent.length) {
  1503. parentInstance = $.data(parent[0], 'droppable');
  1504. parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
  1505. }
  1506. }
  1507. // we just moved into a greedy child
  1508. if (parentInstance && c == 'isover') {
  1509. parentInstance['isover'] = 0;
  1510. parentInstance['isout'] = 1;
  1511. parentInstance._out.call(parentInstance, event);
  1512. }
  1513. this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
  1514. this[c == "isover" ? "_over" : "_out"].call(this, event);
  1515. // we just moved out of a greedy child
  1516. if (parentInstance && c == 'isout') {
  1517. parentInstance['isout'] = 0;
  1518. parentInstance['isover'] = 1;
  1519. parentInstance._over.call(parentInstance, event);
  1520. }
  1521. });
  1522. },
  1523. dragStop: function( draggable, event ) {
  1524. draggable.element.parents( ":not(body,html)" ).unbind( "scroll.droppable" );
  1525. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1526. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  1527. }
  1528. };
  1529. })(jQuery);
  1530. (function( $, undefined ) {
  1531. $.widget("ui.resizable", $.ui.mouse, {
  1532. widgetEventPrefix: "resize",
  1533. options: {
  1534. alsoResize: false,
  1535. animate: false,
  1536. animateDuration: "slow",
  1537. animateEasing: "swing",
  1538. aspectRatio: false,
  1539. autoHide: false,
  1540. containment: false,
  1541. ghost: false,
  1542. grid: false,
  1543. handles: "e,s,se",
  1544. helper: false,
  1545. maxHeight: null,
  1546. maxWidth: null,
  1547. minHeight: 10,
  1548. minWidth: 10,
  1549. zIndex: 1000
  1550. },
  1551. _create: function() {
  1552. var self = this, o = this.options;
  1553. this.element.addClass("ui-resizable");
  1554. $.extend(this, {
  1555. _aspectRatio: !!(o.aspectRatio),
  1556. aspectRatio: o.aspectRatio,
  1557. originalElement: this.element,
  1558. _proportionallyResizeElements: [],
  1559. _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
  1560. });
  1561. //Wrap the element if it cannot hold child nodes
  1562. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1563. //Create a wrapper element and set the wrapper to the new current internal element
  1564. this.element.wrap(
  1565. $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
  1566. position: this.element.css('position'),
  1567. width: this.element.outerWidth(),
  1568. height: this.element.outerHeight(),
  1569. top: this.element.css('top'),
  1570. left: this.element.css('left')
  1571. })
  1572. );
  1573. //Overwrite the original this.element
  1574. this.element = this.element.parent().data(
  1575. "resizable", this.element.data('resizable')
  1576. );
  1577. this.elementIsWrapper = true;
  1578. //Move margins to the wrapper
  1579. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1580. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1581. //Prevent Safari textarea resize
  1582. this.originalResizeStyle = this.originalElement.css('resize');
  1583. this.originalElement.css('resize', 'none');
  1584. //Push the actual element to our proportionallyResize internal array
  1585. this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
  1586. // avoid IE jump (hard set the margin)
  1587. this.originalElement.css({ margin: this.originalElement.css('margin') });
  1588. // fix handlers offset
  1589. this._proportionallyResize();
  1590. }
  1591. 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' });
  1592. if(this.handles.constructor == String) {
  1593. if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
  1594. var n = this.handles.split(","); this.handles = {};
  1595. for(var i = 0; i < n.length; i++) {
  1596. var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
  1597. var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
  1598. // Apply zIndex to all handles - see #7960
  1599. axis.css({ zIndex: o.zIndex });
  1600. //TODO : What's going on here?
  1601. if ('se' == handle) {
  1602. axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
  1603. };
  1604. //Insert into internal handles object and append to element
  1605. this.handles[handle] = '.ui-resizable-'+handle;
  1606. this.element.append(axis);
  1607. }
  1608. }
  1609. this._renderAxis = function(target) {
  1610. target = target || this.element;
  1611. for(var i in this.handles) {
  1612. if(this.handles[i].constructor == String)
  1613. this.handles[i] = $(this.handles[i], this.element).show();
  1614. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  1615. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  1616. var axis = $(this.handles[i], this.element), padWrapper = 0;
  1617. //Checking the correct pad and border
  1618. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  1619. //The padding type i have to apply...
  1620. var padPos = [ 'padding',
  1621. /ne|nw|n/.test(i) ? 'Top' :
  1622. /se|sw|s/.test(i) ? 'Bottom' :
  1623. /^e$/.test(i) ? 'Right' : 'Left' ].join("");
  1624. target.css(padPos, padWrapper);
  1625. this._proportionallyResize();
  1626. }
  1627. //TODO: What's that good for? There's not anything to be executed left
  1628. if(!$(this.handles[i]).length)
  1629. continue;
  1630. }
  1631. };
  1632. //TODO: make renderAxis a prototype function
  1633. this._renderAxis(this.element);
  1634. this._handles = $('.ui-resizable-handle', this.element)
  1635. .disableSelection();
  1636. //Matching axis name
  1637. this._handles.mouseover(function() {
  1638. if (!self.resizing) {
  1639. if (this.className)
  1640. var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  1641. //Axis, default = se
  1642. self.axis = axis && axis[1] ? axis[1] : 'se';
  1643. }
  1644. });
  1645. //If we want to auto hide the elements
  1646. if (o.autoHide) {
  1647. this._handles.hide();
  1648. $(this.element)
  1649. .addClass("ui-resizable-autohide")
  1650. .hover(function() {
  1651. if (o.disabled) return;
  1652. $(this).removeClass("ui-resizable-autohide");
  1653. self._handles.show();
  1654. },
  1655. function(){
  1656. if (o.disabled) return;
  1657. if (!self.resizing) {
  1658. $(this).addClass("ui-resizable-autohide");
  1659. self._handles.hide();
  1660. }
  1661. });
  1662. }
  1663. //Initialize the mouse interaction
  1664. this._mouseInit();
  1665. },
  1666. destroy: function() {
  1667. this._mouseDestroy();
  1668. var _destroy = function(exp) {
  1669. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  1670. .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
  1671. };
  1672. //TODO: Unwrap at same DOM position
  1673. if (this.elementIsWrapper) {
  1674. _destroy(this.element);
  1675. var wrapper = this.element;
  1676. wrapper.after(
  1677. this.originalElement.css({
  1678. position: wrapper.css('position'),
  1679. width: wrapper.outerWidth(),
  1680. height: wrapper.outerHeight(),
  1681. top: wrapper.css('top'),
  1682. left: wrapper.css('left')
  1683. })
  1684. ).remove();
  1685. }
  1686. this.originalElement.css('resize', this.originalResizeStyle);
  1687. _destroy(this.originalElement);
  1688. return this;
  1689. },
  1690. _mouseCapture: function(event) {
  1691. var handle = false;
  1692. for (var i in this.handles) {
  1693. if ($(this.handles[i])[0] == event.target) {
  1694. handle = true;
  1695. }
  1696. }
  1697. return !this.options.disabled && handle;
  1698. },
  1699. _mouseStart: function(event) {
  1700. var o = this.options, iniPos = this.element.position(), el = this.element;
  1701. this.resizing = true;
  1702. this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
  1703. // bugfix for http://dev.jquery.com/ticket/1749
  1704. if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
  1705. el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
  1706. }
  1707. this._renderProxy();
  1708. var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
  1709. if (o.containment) {
  1710. curleft += $(o.containment).scrollLeft() || 0;
  1711. curtop += $(o.containment).scrollTop() || 0;
  1712. }
  1713. //Store needed variables
  1714. this.offset = this.helper.offset();
  1715. this.position = { left: curleft, top: curtop };
  1716. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  1717. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  1718. this.originalPosition = { left: curleft, top: curtop };
  1719. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  1720. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  1721. //Aspect Ratio
  1722. this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  1723. var cursor = $('.ui-resizable-' + this.axis).css('cursor');
  1724. $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
  1725. el.addClass("ui-resizable-resizing");
  1726. this._propagate("start", event);
  1727. return true;
  1728. },
  1729. _mouseDrag: function(event) {
  1730. //Increase performance, avoid regex
  1731. var el = this.helper, o = this.options, props = {},
  1732. self = this, smp = this.originalMousePosition, a = this.axis;
  1733. var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
  1734. var trigger = this._change[a];
  1735. if (!trigger) return false;
  1736. // Calculate the attrs that will be change
  1737. var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
  1738. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  1739. this._updateVirtualBoundaries(event.shiftKey);
  1740. if (this._aspectRatio || event.shiftKey)
  1741. data = this._updateRatio(data, event);
  1742. data = this._respectSize(data, event);
  1743. // plugins callbacks need to be called first
  1744. this._propagate("resize", event);
  1745. el.css({
  1746. top: this.position.top + "px", left: this.position.left + "px",
  1747. width: this.size.width + "px", height: this.size.height + "px"
  1748. });
  1749. if (!this._helper && this._proportionallyResizeElements.length)
  1750. this._proportionallyResize();
  1751. this._updateCache(data);
  1752. // calling the user callback at the end
  1753. this._trigger('resize', event, this.ui());
  1754. return false;
  1755. },
  1756. _mouseStop: function(event) {
  1757. this.resizing = false;
  1758. var o = this.options, self = this;
  1759. if(this._helper) {
  1760. var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  1761. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  1762. soffsetw = ista ? 0 : self.sizeDiff.width;
  1763. var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) },
  1764. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  1765. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  1766. if (!o.animate)
  1767. this.element.css($.extend(s, { top: top, left: left }));
  1768. self.helper.height(self.size.height);
  1769. self.helper.width(self.size.width);
  1770. if (this._helper && !o.animate) this._proportionallyResize();
  1771. }
  1772. $('body').css('cursor', 'auto');
  1773. this.element.removeClass("ui-resizable-resizing");
  1774. this._propagate("stop", event);
  1775. if (this._helper) this.helper.remove();
  1776. return false;
  1777. },
  1778. _updateVirtualBoundaries: function(forceAspectRatio) {
  1779. var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
  1780. b = {
  1781. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  1782. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  1783. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  1784. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  1785. };
  1786. if(this._aspectRatio || forceAspectRatio) {
  1787. // We want to create an enclosing box whose aspect ration is the requested one
  1788. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  1789. pMinWidth = b.minHeight * this.aspectRatio;
  1790. pMinHeight = b.minWidth / this.aspectRatio;
  1791. pMaxWidth = b.maxHeight * this.aspectRatio;
  1792. pMaxHeight = b.maxWidth / this.aspectRatio;
  1793. if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
  1794. if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
  1795. if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
  1796. if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
  1797. }
  1798. this._vBoundaries = b;
  1799. },
  1800. _updateCache: function(data) {
  1801. var o = this.options;
  1802. this.offset = this.helper.offset();
  1803. if (isNumber(data.left)) this.position.left = data.left;
  1804. if (isNumber(data.top)) this.position.top = data.top;
  1805. if (isNumber(data.height)) this.size.height = data.height;
  1806. if (isNumber(data.width)) this.size.width = data.width;
  1807. },
  1808. _updateRatio: function(data, event) {
  1809. var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
  1810. if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
  1811. else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
  1812. if (a == 'sw') {
  1813. data.left = cpos.left + (csize.width - data.width);
  1814. data.top = null;
  1815. }
  1816. if (a == 'nw') {
  1817. data.top = cpos.top + (csize.height - data.height);
  1818. data.left = cpos.left + (csize.width - data.width);
  1819. }
  1820. return data;
  1821. },
  1822. _respectSize: function(data, event) {
  1823. var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
  1824. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  1825. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
  1826. if (isminw) data.width = o.minWidth;
  1827. if (isminh) data.height = o.minHeight;
  1828. if (ismaxw) data.width = o.maxWidth;
  1829. if (ismaxh) data.height = o.maxHeight;
  1830. var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
  1831. var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  1832. if (isminw && cw) data.left = dw - o.minWidth;
  1833. if (ismaxw && cw) data.left = dw - o.maxWidth;
  1834. if (isminh && ch) data.top = dh - o.minHeight;
  1835. if (ismaxh && ch) data.top = dh - o.maxHeight;
  1836. // fixing jump error on top/left - bug #2330
  1837. var isNotwh = !data.width && !data.height;
  1838. if (isNotwh && !data.left && data.top) data.top = null;
  1839. else if (isNotwh && !data.top && data.left) data.left = null;
  1840. return data;
  1841. },
  1842. _proportionallyResize: function() {
  1843. var o = this.options;
  1844. if (!this._proportionallyResizeElements.length) return;
  1845. var element = this.helper || this.element;
  1846. for (var i=0; i < this._proportionallyResizeElements.length; i++) {
  1847. var prel = this._proportionallyResizeElements[i];
  1848. if (!this.borderDif) {
  1849. var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
  1850. p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
  1851. this.borderDif = $.map(b, function(v, i) {
  1852. var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
  1853. return border + padding;
  1854. });
  1855. }
  1856. if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length)))
  1857. continue;
  1858. prel.css({
  1859. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  1860. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  1861. });
  1862. };
  1863. },
  1864. _renderProxy: function() {
  1865. var el = this.element, o = this.options;
  1866. this.elementOffset = el.offset();
  1867. if(this._helper) {
  1868. this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
  1869. // fix ie6 offset TODO: This seems broken
  1870. var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
  1871. pxyoffset = ( ie6 ? 2 : -1 );
  1872. this.helper.addClass(this._helper).css({
  1873. width: this.element.outerWidth() + pxyoffset,
  1874. height: this.element.outerHeight() + pxyoffset,
  1875. position: 'absolute',
  1876. left: this.elementOffset.left - ie6offset +'px',
  1877. top: this.elementOffset.top - ie6offset +'px',
  1878. zIndex: ++o.zIndex //TODO: Don't modify option
  1879. });
  1880. this.helper
  1881. .appendTo("body")
  1882. .disableSelection();
  1883. } else {
  1884. this.helper = this.element;
  1885. }
  1886. },
  1887. _change: {
  1888. e: function(event, dx, dy) {
  1889. return { width: this.originalSize.width + dx };
  1890. },
  1891. w: function(event, dx, dy) {
  1892. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  1893. return { left: sp.left + dx, width: cs.width - dx };
  1894. },
  1895. n: function(event, dx, dy) {
  1896. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  1897. return { top: sp.top + dy, height: cs.height - dy };
  1898. },
  1899. s: function(event, dx, dy) {
  1900. return { height: this.originalSize.height + dy };
  1901. },
  1902. se: function(event, dx, dy) {
  1903. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  1904. },
  1905. sw: function(event, dx, dy) {
  1906. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  1907. },
  1908. ne: function(event, dx, dy) {
  1909. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  1910. },
  1911. nw: function(event, dx, dy) {
  1912. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  1913. }
  1914. },
  1915. _propagate: function(n, event) {
  1916. $.ui.plugin.call(this, n, [event, this.ui()]);
  1917. (n != "resize" && this._trigger(n, event, this.ui()));
  1918. },
  1919. plugins: {},
  1920. ui: function() {
  1921. return {
  1922. originalElement: this.originalElement,
  1923. element: this.element,
  1924. helper: this.helper,
  1925. position: this.position,
  1926. size: this.size,
  1927. originalSize: this.originalSize,
  1928. originalPosition: this.originalPosition
  1929. };
  1930. }
  1931. });
  1932. $.extend($.ui.resizable, {
  1933. version: "1.8.24"
  1934. });
  1935. /*
  1936. * Resizable Extensions
  1937. */
  1938. $.ui.plugin.add("resizable", "alsoResize", {
  1939. start: function (event, ui) {
  1940. var self = $(this).data("resizable"), o = self.options;
  1941. var _store = function (exp) {
  1942. $(exp).each(function() {
  1943. var el = $(this);
  1944. el.data("resizable-alsoresize", {
  1945. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  1946. left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
  1947. });
  1948. });
  1949. };
  1950. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
  1951. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  1952. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  1953. }else{
  1954. _store(o.alsoResize);
  1955. }
  1956. },
  1957. resize: function (event, ui) {
  1958. var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
  1959. var delta = {
  1960. height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
  1961. top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
  1962. },
  1963. _alsoResize = function (exp, c) {
  1964. $(exp).each(function() {
  1965. var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
  1966. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
  1967. $.each(css, function (i, prop) {
  1968. var sum = (start[prop]||0) + (delta[prop]||0);
  1969. if (sum && sum >= 0)
  1970. style[prop] = sum || null;
  1971. });
  1972. el.css(style);
  1973. });
  1974. };
  1975. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
  1976. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  1977. }else{
  1978. _alsoResize(o.alsoResize);
  1979. }
  1980. },
  1981. stop: function (event, ui) {
  1982. $(this).removeData("resizable-alsoresize");
  1983. }
  1984. });
  1985. $.ui.plugin.add("resizable", "animate", {
  1986. stop: function(event, ui) {
  1987. var self = $(this).data("resizable"), o = self.options;
  1988. var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  1989. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  1990. soffsetw = ista ? 0 : self.sizeDiff.width;
  1991. var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
  1992. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  1993. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  1994. self.element.animate(
  1995. $.extend(style, top && left ? { top: top, left: left } : {}), {
  1996. duration: o.animateDuration,
  1997. easing: o.animateEasing,
  1998. step: function() {
  1999. var data = {
  2000. width: parseInt(self.element.css('width'), 10),
  2001. height: parseInt(self.element.css('height'), 10),
  2002. top: parseInt(self.element.css('top'), 10),
  2003. left: parseInt(self.element.css('left'), 10)
  2004. };
  2005. if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
  2006. // propagating resize, and updating values for each animation step
  2007. self._updateCache(data);
  2008. self._propagate("resize", event);
  2009. }
  2010. }
  2011. );
  2012. }
  2013. });
  2014. $.ui.plugin.add("resizable", "containment", {
  2015. start: function(event, ui) {
  2016. var self = $(this).data("resizable"), o = self.options, el = self.element;
  2017. var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2018. if (!ce) return;
  2019. self.containerElement = $(ce);
  2020. if (/document/.test(oc) || oc == document) {
  2021. self.containerOffset = { left: 0, top: 0 };
  2022. self.containerPosition = { left: 0, top: 0 };
  2023. self.parentData = {
  2024. element: $(document), left: 0, top: 0,
  2025. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2026. };
  2027. }
  2028. // i'm a node, so compute top, left, right, bottom
  2029. else {
  2030. var element = $(ce), p = [];
  2031. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2032. self.containerOffset = element.offset();
  2033. self.containerPosition = element.position();
  2034. self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2035. var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
  2036. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2037. self.parentData = {
  2038. element: ce, left: co.left, top: co.top, width: width, height: height
  2039. };
  2040. }
  2041. },
  2042. resize: function(event, ui) {
  2043. var self = $(this).data("resizable"), o = self.options,
  2044. ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
  2045. pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
  2046. if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
  2047. if (cp.left < (self._helper ? co.left : 0)) {
  2048. self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
  2049. if (pRatio) self.size.height = self.size.width / self.aspectRatio;
  2050. self.position.left = o.helper ? co.left : 0;
  2051. }
  2052. if (cp.top < (self._helper ? co.top : 0)) {
  2053. self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
  2054. if (pRatio) self.size.width = self.size.height * self.aspectRatio;
  2055. self.position.top = self._helper ? co.top : 0;
  2056. }
  2057. self.offset.left = self.parentData.left+self.position.left;
  2058. self.offset.top = self.parentData.top+self.position.top;
  2059. var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
  2060. hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
  2061. var isParent = self.containerElement.get(0) == self.element.parent().get(0),
  2062. isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
  2063. if(isParent && isOffsetRelative) woset -= self.parentData.left;
  2064. if (woset + self.size.width >= self.parentData.width) {
  2065. self.size.width = self.parentData.width - woset;
  2066. if (pRatio) self.size.height = self.size.width / self.aspectRatio;
  2067. }
  2068. if (hoset + self.size.height >= self.parentData.height) {
  2069. self.size.height = self.parentData.height - hoset;
  2070. if (pRatio) self.size.width = self.size.height * self.aspectRatio;
  2071. }
  2072. },
  2073. stop: function(event, ui){
  2074. var self = $(this).data("resizable"), o = self.options, cp = self.position,
  2075. co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
  2076. var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
  2077. if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
  2078. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2079. if (self._helper && !o.animate && (/static/).test(ce.css('position')))
  2080. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2081. }
  2082. });
  2083. $.ui.plugin.add("resizable", "ghost", {
  2084. start: function(event, ui) {
  2085. var self = $(this).data("resizable"), o = self.options, cs = self.size;
  2086. self.ghost = self.originalElement.clone();
  2087. self.ghost
  2088. .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2089. .addClass('ui-resizable-ghost')
  2090. .addClass(typeof o.ghost == 'string' ? o.ghost : '');
  2091. self.ghost.appendTo(self.helper);
  2092. },
  2093. resize: function(event, ui){
  2094. var self = $(this).data("resizable"), o = self.options;
  2095. if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
  2096. },
  2097. stop: function(event, ui){
  2098. var self = $(this).data("resizable"), o = self.options;
  2099. if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
  2100. }
  2101. });
  2102. $.ui.plugin.add("resizable", "grid", {
  2103. resize: function(event, ui) {
  2104. var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
  2105. o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
  2106. var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
  2107. if (/^(se|s|e)$/.test(a)) {
  2108. self.size.width = os.width + ox;
  2109. self.size.height = os.height + oy;
  2110. }
  2111. else if (/^(ne)$/.test(a)) {
  2112. self.size.width = os.width + ox;
  2113. self.size.height = os.height + oy;
  2114. self.position.top = op.top - oy;
  2115. }
  2116. else if (/^(sw)$/.test(a)) {
  2117. self.size.width = os.width + ox;
  2118. self.size.height = os.height + oy;
  2119. self.position.left = op.left - ox;
  2120. }
  2121. else {
  2122. self.size.width = os.width + ox;
  2123. self.size.height = os.height + oy;
  2124. self.position.top = op.top - oy;
  2125. self.position.left = op.left - ox;
  2126. }
  2127. }
  2128. });
  2129. var num = function(v) {
  2130. return parseInt(v, 10) || 0;
  2131. };
  2132. var isNumber = function(value) {
  2133. return !isNaN(parseInt(value, 10));
  2134. };
  2135. })(jQuery);
  2136. (function( $, undefined ) {
  2137. $.widget("ui.selectable", $.ui.mouse, {
  2138. options: {
  2139. appendTo: 'body',
  2140. autoRefresh: true,
  2141. distance: 0,
  2142. filter: '*',
  2143. tolerance: 'touch'
  2144. },
  2145. _create: function() {
  2146. var self = this;
  2147. this.element.addClass("ui-selectable");
  2148. this.dragged = false;
  2149. // cache selectee children based on filter
  2150. var selectees;
  2151. this.refresh = function() {
  2152. selectees = $(self.options.filter, self.element[0]);
  2153. selectees.addClass("ui-selectee");
  2154. selectees.each(function() {
  2155. var $this = $(this);
  2156. var pos = $this.offset();
  2157. $.data(this, "selectable-item", {
  2158. element: this,
  2159. $element: $this,
  2160. left: pos.left,
  2161. top: pos.top,
  2162. right: pos.left + $this.outerWidth(),
  2163. bottom: pos.top + $this.outerHeight(),
  2164. startselected: false,
  2165. selected: $this.hasClass('ui-selected'),
  2166. selecting: $this.hasClass('ui-selecting'),
  2167. unselecting: $this.hasClass('ui-unselecting')
  2168. });
  2169. });
  2170. };
  2171. this.refresh();
  2172. this.selectees = selectees.addClass("ui-selectee");
  2173. this._mouseInit();
  2174. this.helper = $("<div class='ui-selectable-helper'></div>");
  2175. },
  2176. destroy: function() {
  2177. this.selectees
  2178. .removeClass("ui-selectee")
  2179. .removeData("selectable-item");
  2180. this.element
  2181. .removeClass("ui-selectable ui-selectable-disabled")
  2182. .removeData("selectable")
  2183. .unbind(".selectable");
  2184. this._mouseDestroy();
  2185. return this;
  2186. },
  2187. _mouseStart: function(event) {
  2188. var self = this;
  2189. this.opos = [event.pageX, event.pageY];
  2190. if (this.options.disabled)
  2191. return;
  2192. var options = this.options;
  2193. this.selectees = $(options.filter, this.element[0]);
  2194. this._trigger("start", event);
  2195. $(options.appendTo).append(this.helper);
  2196. // position helper (lasso)
  2197. this.helper.css({
  2198. "left": event.clientX,
  2199. "top": event.clientY,
  2200. "width": 0,
  2201. "height": 0
  2202. });
  2203. if (options.autoRefresh) {
  2204. this.refresh();
  2205. }
  2206. this.selectees.filter('.ui-selected').each(function() {
  2207. var selectee = $.data(this, "selectable-item");
  2208. selectee.startselected = true;
  2209. if (!event.metaKey && !event.ctrlKey) {
  2210. selectee.$element.removeClass('ui-selected');
  2211. selectee.selected = false;
  2212. selectee.$element.addClass('ui-unselecting');
  2213. selectee.unselecting = true;
  2214. // selectable UNSELECTING callback
  2215. self._trigger("unselecting", event, {
  2216. unselecting: selectee.element
  2217. });
  2218. }
  2219. });
  2220. $(event.target).parents().andSelf().each(function() {
  2221. var selectee = $.data(this, "selectable-item");
  2222. if (selectee) {
  2223. var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
  2224. selectee.$element
  2225. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2226. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2227. selectee.unselecting = !doSelect;
  2228. selectee.selecting = doSelect;
  2229. selectee.selected = doSelect;
  2230. // selectable (UN)SELECTING callback
  2231. if (doSelect) {
  2232. self._trigger("selecting", event, {
  2233. selecting: selectee.element
  2234. });
  2235. } else {
  2236. self._trigger("unselecting", event, {
  2237. unselecting: selectee.element
  2238. });
  2239. }
  2240. return false;
  2241. }
  2242. });
  2243. },
  2244. _mouseDrag: function(event) {
  2245. var self = this;
  2246. this.dragged = true;
  2247. if (this.options.disabled)
  2248. return;
  2249. var options = this.options;
  2250. var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
  2251. if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
  2252. if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
  2253. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2254. this.selectees.each(function() {
  2255. var selectee = $.data(this, "selectable-item");
  2256. //prevent helper from being selected if appendTo: selectable
  2257. if (!selectee || selectee.element == self.element[0])
  2258. return;
  2259. var hit = false;
  2260. if (options.tolerance == 'touch') {
  2261. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2262. } else if (options.tolerance == 'fit') {
  2263. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2264. }
  2265. if (hit) {
  2266. // SELECT
  2267. if (selectee.selected) {
  2268. selectee.$element.removeClass('ui-selected');
  2269. selectee.selected = false;
  2270. }
  2271. if (selectee.unselecting) {
  2272. selectee.$element.removeClass('ui-unselecting');
  2273. selectee.unselecting = false;
  2274. }
  2275. if (!selectee.selecting) {
  2276. selectee.$element.addClass('ui-selecting');
  2277. selectee.selecting = true;
  2278. // selectable SELECTING callback
  2279. self._trigger("selecting", event, {
  2280. selecting: selectee.element
  2281. });
  2282. }
  2283. } else {
  2284. // UNSELECT
  2285. if (selectee.selecting) {
  2286. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2287. selectee.$element.removeClass('ui-selecting');
  2288. selectee.selecting = false;
  2289. selectee.$element.addClass('ui-selected');
  2290. selectee.selected = true;
  2291. } else {
  2292. selectee.$element.removeClass('ui-selecting');
  2293. selectee.selecting = false;
  2294. if (selectee.startselected) {
  2295. selectee.$element.addClass('ui-unselecting');
  2296. selectee.unselecting = true;
  2297. }
  2298. // selectable UNSELECTING callback
  2299. self._trigger("unselecting", event, {
  2300. unselecting: selectee.element
  2301. });
  2302. }
  2303. }
  2304. if (selectee.selected) {
  2305. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2306. selectee.$element.removeClass('ui-selected');
  2307. selectee.selected = false;
  2308. selectee.$element.addClass('ui-unselecting');
  2309. selectee.unselecting = true;
  2310. // selectable UNSELECTING callback
  2311. self._trigger("unselecting", event, {
  2312. unselecting: selectee.element
  2313. });
  2314. }
  2315. }
  2316. }
  2317. });
  2318. return false;
  2319. },
  2320. _mouseStop: function(event) {
  2321. var self = this;
  2322. this.dragged = false;
  2323. var options = this.options;
  2324. $('.ui-unselecting', this.element[0]).each(function() {
  2325. var selectee = $.data(this, "selectable-item");
  2326. selectee.$element.removeClass('ui-unselecting');
  2327. selectee.unselecting = false;
  2328. selectee.startselected = false;
  2329. self._trigger("unselected", event, {
  2330. unselected: selectee.element
  2331. });
  2332. });
  2333. $('.ui-selecting', this.element[0]).each(function() {
  2334. var selectee = $.data(this, "selectable-item");
  2335. selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
  2336. selectee.selecting = false;
  2337. selectee.selected = true;
  2338. selectee.startselected = true;
  2339. self._trigger("selected", event, {
  2340. selected: selectee.element
  2341. });
  2342. });
  2343. this._trigger("stop", event);
  2344. this.helper.remove();
  2345. return false;
  2346. }
  2347. });
  2348. $.extend($.ui.selectable, {
  2349. version: "1.8.24"
  2350. });
  2351. })(jQuery);
  2352. (function( $, undefined ) {
  2353. $.widget("ui.sortable", $.ui.mouse, {
  2354. widgetEventPrefix: "sort",
  2355. ready: false,
  2356. options: {
  2357. appendTo: "parent",
  2358. axis: false,
  2359. connectWith: false,
  2360. containment: false,
  2361. cursor: 'auto',
  2362. cursorAt: false,
  2363. dropOnEmpty: true,
  2364. forcePlaceholderSize: false,
  2365. forceHelperSize: false,
  2366. grid: false,
  2367. handle: false,
  2368. helper: "original",
  2369. items: '> *',
  2370. opacity: false,
  2371. placeholder: false,
  2372. revert: false,
  2373. scroll: true,
  2374. scrollSensitivity: 20,
  2375. scrollSpeed: 20,
  2376. scope: "default",
  2377. tolerance: "intersect",
  2378. zIndex: 1000
  2379. },
  2380. _create: function() {
  2381. var o = this.options;
  2382. this.containerCache = {};
  2383. this.element.addClass("ui-sortable");
  2384. //Get the items
  2385. this.refresh();
  2386. //Let's determine if the items are being displayed horizontally
  2387. this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
  2388. //Let's determine the parent's offset
  2389. this.offset = this.element.offset();
  2390. //Initialize mouse events for interaction
  2391. this._mouseInit();
  2392. //We're ready to go
  2393. this.ready = true
  2394. },
  2395. destroy: function() {
  2396. $.Widget.prototype.destroy.call( this );
  2397. this.element
  2398. .removeClass("ui-sortable ui-sortable-disabled");
  2399. this._mouseDestroy();
  2400. for ( var i = this.items.length - 1; i >= 0; i-- )
  2401. this.items[i].item.removeData(this.widgetName + "-item");
  2402. return this;
  2403. },
  2404. _setOption: function(key, value){
  2405. if ( key === "disabled" ) {
  2406. this.options[ key ] = value;
  2407. this.widget()
  2408. [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
  2409. } else {
  2410. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2411. $.Widget.prototype._setOption.apply(this, arguments);
  2412. }
  2413. },
  2414. _mouseCapture: function(event, overrideHandle) {
  2415. var that = this;
  2416. if (this.reverting) {
  2417. return false;
  2418. }
  2419. if(this.options.disabled || this.options.type == 'static') return false;
  2420. //We have to refresh the items data once first
  2421. this._refreshItems(event);
  2422. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  2423. var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
  2424. if($.data(this, that.widgetName + '-item') == self) {
  2425. currentItem = $(this);
  2426. return false;
  2427. }
  2428. });
  2429. if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
  2430. if(!currentItem) return false;
  2431. if(this.options.handle && !overrideHandle) {
  2432. var validHandle = false;
  2433. $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
  2434. if(!validHandle) return false;
  2435. }
  2436. this.currentItem = currentItem;
  2437. this._removeCurrentsFromItems();
  2438. return true;
  2439. },
  2440. _mouseStart: function(event, overrideHandle, noActivation) {
  2441. var o = this.options, self = this;
  2442. this.currentContainer = this;
  2443. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  2444. this.refreshPositions();
  2445. //Create and append the visible helper
  2446. this.helper = this._createHelper(event);
  2447. //Cache the helper size
  2448. this._cacheHelperProportions();
  2449. /*
  2450. * - Position generation -
  2451. * This block generates everything position related - it's the core of draggables.
  2452. */
  2453. //Cache the margins of the original element
  2454. this._cacheMargins();
  2455. //Get the next scrolling parent
  2456. this.scrollParent = this.helper.scrollParent();
  2457. //The element's absolute position on the page minus margins
  2458. this.offset = this.currentItem.offset();
  2459. this.offset = {
  2460. top: this.offset.top - this.margins.top,
  2461. left: this.offset.left - this.margins.left
  2462. };
  2463. $.extend(this.offset, {
  2464. click: { //Where the click happened, relative to the element
  2465. left: event.pageX - this.offset.left,
  2466. top: event.pageY - this.offset.top
  2467. },
  2468. parent: this._getParentOffset(),
  2469. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  2470. });
  2471. // Only after we got the offset, we can change the helper's position to absolute
  2472. // TODO: Still need to figure out a way to make relative sorting possible
  2473. this.helper.css("position", "absolute");
  2474. this.cssPosition = this.helper.css("position");
  2475. //Generate the original position
  2476. this.originalPosition = this._generatePosition(event);
  2477. this.originalPageX = event.pageX;
  2478. this.originalPageY = event.pageY;
  2479. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  2480. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  2481. //Cache the former DOM position
  2482. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  2483. //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
  2484. if(this.helper[0] != this.currentItem[0]) {
  2485. this.currentItem.hide();
  2486. }
  2487. //Create the placeholder
  2488. this._createPlaceholder();
  2489. //Set a containment if given in the options
  2490. if(o.containment)
  2491. this._setContainment();
  2492. if(o.cursor) { // cursor option
  2493. if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
  2494. $('body').css("cursor", o.cursor);
  2495. }
  2496. if(o.opacity) { // opacity option
  2497. if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
  2498. this.helper.css("opacity", o.opacity);
  2499. }
  2500. if(o.zIndex) { // zIndex option
  2501. if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
  2502. this.helper.css("zIndex", o.zIndex);
  2503. }
  2504. //Prepare scrolling
  2505. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
  2506. this.overflowOffset = this.scrollParent.offset();
  2507. //Call callbacks
  2508. this._trigger("start", event, this._uiHash());
  2509. //Recache the helper size
  2510. if(!this._preserveHelperProportions)
  2511. this._cacheHelperProportions();
  2512. //Post 'activate' events to possible containers
  2513. if(!noActivation) {
  2514. for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
  2515. }
  2516. //Prepare possible droppables
  2517. if($.ui.ddmanager)
  2518. $.ui.ddmanager.current = this;
  2519. if ($.ui.ddmanager && !o.dropBehaviour)
  2520. $.ui.ddmanager.prepareOffsets(this, event);
  2521. this.dragging = true;
  2522. this.helper.addClass("ui-sortable-helper");
  2523. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  2524. return true;
  2525. },
  2526. _mouseDrag: function(event) {
  2527. //Compute the helpers position
  2528. this.position = this._generatePosition(event);
  2529. this.positionAbs = this._convertPositionTo("absolute");
  2530. if (!this.lastPositionAbs) {
  2531. this.lastPositionAbs = this.positionAbs;
  2532. }
  2533. //Do scrolling
  2534. if(this.options.scroll) {
  2535. var o = this.options, scrolled = false;
  2536. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
  2537. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  2538. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  2539. else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
  2540. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  2541. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  2542. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  2543. else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
  2544. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  2545. } else {
  2546. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  2547. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2548. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  2549. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2550. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  2551. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2552. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  2553. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2554. }
  2555. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  2556. $.ui.ddmanager.prepareOffsets(this, event);
  2557. }
  2558. //Regenerate the absolute position used for position checks
  2559. this.positionAbs = this._convertPositionTo("absolute");
  2560. //Set the helper position
  2561. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  2562. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  2563. //Rearrange
  2564. for (var i = this.items.length - 1; i >= 0; i--) {
  2565. //Cache variables and intersection, continue if no intersection
  2566. var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
  2567. if (!intersection) continue;
  2568. // Only put the placeholder inside the current Container, skip all
  2569. // items form other containers. This works because when moving
  2570. // an item from one container to another the
  2571. // currentContainer is switched before the placeholder is moved.
  2572. //
  2573. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  2574. // beetween the outer and inner container.
  2575. if (item.instance !== this.currentContainer) continue;
  2576. if (itemElement != this.currentItem[0] //cannot intersect with itself
  2577. && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
  2578. && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
  2579. && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
  2580. //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
  2581. ) {
  2582. this.direction = intersection == 1 ? "down" : "up";
  2583. if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
  2584. this._rearrange(event, item);
  2585. } else {
  2586. break;
  2587. }
  2588. this._trigger("change", event, this._uiHash());
  2589. break;
  2590. }
  2591. }
  2592. //Post events to containers
  2593. this._contactContainers(event);
  2594. //Interconnect with droppables
  2595. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  2596. //Call callbacks
  2597. this._trigger('sort', event, this._uiHash());
  2598. this.lastPositionAbs = this.positionAbs;
  2599. return false;
  2600. },
  2601. _mouseStop: function(event, noPropagation) {
  2602. if(!event) return;
  2603. //If we are using droppables, inform the manager about the drop
  2604. if ($.ui.ddmanager && !this.options.dropBehaviour)
  2605. $.ui.ddmanager.drop(this, event);
  2606. if(this.options.revert) {
  2607. var self = this;
  2608. var cur = self.placeholder.offset();
  2609. self.reverting = true;
  2610. $(this.helper).animate({
  2611. left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
  2612. top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
  2613. }, parseInt(this.options.revert, 10) || 500, function() {
  2614. self._clear(event);
  2615. });
  2616. } else {
  2617. this._clear(event, noPropagation);
  2618. }
  2619. return false;
  2620. },
  2621. cancel: function() {
  2622. var self = this;
  2623. if(this.dragging) {
  2624. this._mouseUp({ target: null });
  2625. if(this.options.helper == "original")
  2626. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  2627. else
  2628. this.currentItem.show();
  2629. //Post deactivating events to containers
  2630. for (var i = this.containers.length - 1; i >= 0; i--){
  2631. this.containers[i]._trigger("deactivate", null, self._uiHash(this));
  2632. if(this.containers[i].containerCache.over) {
  2633. this.containers[i]._trigger("out", null, self._uiHash(this));
  2634. this.containers[i].containerCache.over = 0;
  2635. }
  2636. }
  2637. }
  2638. if (this.placeholder) {
  2639. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  2640. if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  2641. if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
  2642. $.extend(this, {
  2643. helper: null,
  2644. dragging: false,
  2645. reverting: false,
  2646. _noFinalSort: null
  2647. });
  2648. if(this.domPosition.prev) {
  2649. $(this.domPosition.prev).after(this.currentItem);
  2650. } else {
  2651. $(this.domPosition.parent).prepend(this.currentItem);
  2652. }
  2653. }
  2654. return this;
  2655. },
  2656. serialize: function(o) {
  2657. var items = this._getItemsAsjQuery(o && o.connected);
  2658. var str = []; o = o || {};
  2659. $(items).each(function() {
  2660. var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
  2661. if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
  2662. });
  2663. if(!str.length && o.key) {
  2664. str.push(o.key + '=');
  2665. }
  2666. return str.join('&');
  2667. },
  2668. toArray: function(o) {
  2669. var items = this._getItemsAsjQuery(o && o.connected);
  2670. var ret = []; o = o || {};
  2671. items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
  2672. return ret;
  2673. },
  2674. /* Be careful with the following core functions */
  2675. _intersectsWith: function(item) {
  2676. var x1 = this.positionAbs.left,
  2677. x2 = x1 + this.helperProportions.width,
  2678. y1 = this.positionAbs.top,
  2679. y2 = y1 + this.helperProportions.height;
  2680. var l = item.left,
  2681. r = l + item.width,
  2682. t = item.top,
  2683. b = t + item.height;
  2684. var dyClick = this.offset.click.top,
  2685. dxClick = this.offset.click.left;
  2686. var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  2687. if( this.options.tolerance == "pointer"
  2688. || this.options.forcePointerForContainers
  2689. || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
  2690. ) {
  2691. return isOverElement;
  2692. } else {
  2693. return (l < x1 + (this.helperProportions.width / 2) // Right Half
  2694. && x2 - (this.helperProportions.width / 2) < r // Left Half
  2695. && t < y1 + (this.helperProportions.height / 2) // Bottom Half
  2696. && y2 - (this.helperProportions.height / 2) < b ); // Top Half
  2697. }
  2698. },
  2699. _intersectsWithPointer: function(item) {
  2700. var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  2701. isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  2702. isOverElement = isOverElementHeight && isOverElementWidth,
  2703. verticalDirection = this._getDragVerticalDirection(),
  2704. horizontalDirection = this._getDragHorizontalDirection();
  2705. if (!isOverElement)
  2706. return false;
  2707. return this.floating ?
  2708. ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
  2709. : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
  2710. },
  2711. _intersectsWithSides: function(item) {
  2712. var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  2713. isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  2714. verticalDirection = this._getDragVerticalDirection(),
  2715. horizontalDirection = this._getDragHorizontalDirection();
  2716. if (this.floating && horizontalDirection) {
  2717. return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
  2718. } else {
  2719. return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
  2720. }
  2721. },
  2722. _getDragVerticalDirection: function() {
  2723. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  2724. return delta != 0 && (delta > 0 ? "down" : "up");
  2725. },
  2726. _getDragHorizontalDirection: function() {
  2727. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  2728. return delta != 0 && (delta > 0 ? "right" : "left");
  2729. },
  2730. refresh: function(event) {
  2731. this._refreshItems(event);
  2732. this.refreshPositions();
  2733. return this;
  2734. },
  2735. _connectWith: function() {
  2736. var options = this.options;
  2737. return options.connectWith.constructor == String
  2738. ? [options.connectWith]
  2739. : options.connectWith;
  2740. },
  2741. _getItemsAsjQuery: function(connected) {
  2742. var self = this;
  2743. var items = [];
  2744. var queries = [];
  2745. var connectWith = this._connectWith();
  2746. if(connectWith && connected) {
  2747. for (var i = connectWith.length - 1; i >= 0; i--){
  2748. var cur = $(connectWith[i]);
  2749. for (var j = cur.length - 1; j >= 0; j--){
  2750. var inst = $.data(cur[j], this.widgetName);
  2751. if(inst && inst != this && !inst.options.disabled) {
  2752. 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]);
  2753. }
  2754. };
  2755. };
  2756. }
  2757. 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]);
  2758. for (var i = queries.length - 1; i >= 0; i--){
  2759. queries[i][0].each(function() {
  2760. items.push(this);
  2761. });
  2762. };
  2763. return $(items);
  2764. },
  2765. _removeCurrentsFromItems: function() {
  2766. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  2767. for (var i=0; i < this.items.length; i++) {
  2768. for (var j=0; j < list.length; j++) {
  2769. if(list[j] == this.items[i].item[0])
  2770. this.items.splice(i,1);
  2771. };
  2772. };
  2773. },
  2774. _refreshItems: function(event) {
  2775. this.items = [];
  2776. this.containers = [this];
  2777. var items = this.items;
  2778. var self = this;
  2779. var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
  2780. var connectWith = this._connectWith();
  2781. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  2782. for (var i = connectWith.length - 1; i >= 0; i--){
  2783. var cur = $(connectWith[i]);
  2784. for (var j = cur.length - 1; j >= 0; j--){
  2785. var inst = $.data(cur[j], this.widgetName);
  2786. if(inst && inst != this && !inst.options.disabled) {
  2787. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  2788. this.containers.push(inst);
  2789. }
  2790. };
  2791. };
  2792. }
  2793. for (var i = queries.length - 1; i >= 0; i--) {
  2794. var targetData = queries[i][1];
  2795. var _queries = queries[i][0];
  2796. for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  2797. var item = $(_queries[j]);
  2798. item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
  2799. items.push({
  2800. item: item,
  2801. instance: targetData,
  2802. width: 0, height: 0,
  2803. left: 0, top: 0
  2804. });
  2805. };
  2806. };
  2807. },
  2808. refreshPositions: function(fast) {
  2809. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  2810. if(this.offsetParent && this.helper) {
  2811. this.offset.parent = this._getParentOffset();
  2812. }
  2813. for (var i = this.items.length - 1; i >= 0; i--){
  2814. var item = this.items[i];
  2815. //We ignore calculating positions of all connected containers when we're not over them
  2816. if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
  2817. continue;
  2818. var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  2819. if (!fast) {
  2820. item.width = t.outerWidth();
  2821. item.height = t.outerHeight();
  2822. }
  2823. var p = t.offset();
  2824. item.left = p.left;
  2825. item.top = p.top;
  2826. };
  2827. if(this.options.custom && this.options.custom.refreshContainers) {
  2828. this.options.custom.refreshContainers.call(this);
  2829. } else {
  2830. for (var i = this.containers.length - 1; i >= 0; i--){
  2831. var p = this.containers[i].element.offset();
  2832. this.containers[i].containerCache.left = p.left;
  2833. this.containers[i].containerCache.top = p.top;
  2834. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  2835. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  2836. };
  2837. }
  2838. return this;
  2839. },
  2840. _createPlaceholder: function(that) {
  2841. var self = that || this, o = self.options;
  2842. if(!o.placeholder || o.placeholder.constructor == String) {
  2843. var className = o.placeholder;
  2844. o.placeholder = {
  2845. element: function() {
  2846. var el = $(document.createElement(self.currentItem[0].nodeName))
  2847. .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
  2848. .removeClass("ui-sortable-helper")[0];
  2849. if(!className)
  2850. el.style.visibility = "hidden";
  2851. return el;
  2852. },
  2853. update: function(container, p) {
  2854. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  2855. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  2856. if(className && !o.forcePlaceholderSize) return;
  2857. //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
  2858. if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
  2859. if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
  2860. }
  2861. };
  2862. }
  2863. //Create the placeholder
  2864. self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
  2865. //Append it after the actual current item
  2866. self.currentItem.after(self.placeholder);
  2867. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  2868. o.placeholder.update(self, self.placeholder);
  2869. },
  2870. _contactContainers: function(event) {
  2871. // get innermost container that intersects with item
  2872. var innermostContainer = null, innermostIndex = null;
  2873. for (var i = this.containers.length - 1; i >= 0; i--){
  2874. // never consider a container that's located within the item itself
  2875. if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
  2876. continue;
  2877. if(this._intersectsWith(this.containers[i].containerCache)) {
  2878. // if we've already found a container and it's more "inner" than this, then continue
  2879. if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
  2880. continue;
  2881. innermostContainer = this.containers[i];
  2882. innermostIndex = i;
  2883. } else {
  2884. // container doesn't intersect. trigger "out" event if necessary
  2885. if(this.containers[i].containerCache.over) {
  2886. this.containers[i]._trigger("out", event, this._uiHash(this));
  2887. this.containers[i].containerCache.over = 0;
  2888. }
  2889. }
  2890. }
  2891. // if no intersecting containers found, return
  2892. if(!innermostContainer) return;
  2893. // move the item into the container if it's not there already
  2894. if(this.containers.length === 1) {
  2895. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  2896. this.containers[innermostIndex].containerCache.over = 1;
  2897. } else if(this.currentContainer != this.containers[innermostIndex]) {
  2898. //When entering a new container, we will find the item with the least distance and append our item near it
  2899. var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
  2900. for (var j = this.items.length - 1; j >= 0; j--) {
  2901. if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
  2902. var cur = this.containers[innermostIndex].floating ? this.items[j].item.offset().left : this.items[j].item.offset().top;
  2903. if(Math.abs(cur - base) < dist) {
  2904. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  2905. this.direction = (cur - base > 0) ? 'down' : 'up';
  2906. }
  2907. }
  2908. if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
  2909. return;
  2910. this.currentContainer = this.containers[innermostIndex];
  2911. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  2912. this._trigger("change", event, this._uiHash());
  2913. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  2914. //Update the placeholder
  2915. this.options.placeholder.update(this.currentContainer, this.placeholder);
  2916. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  2917. this.containers[innermostIndex].containerCache.over = 1;
  2918. }
  2919. },
  2920. _createHelper: function(event) {
  2921. var o = this.options;
  2922. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
  2923. if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
  2924. $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  2925. if(helper[0] == this.currentItem[0])
  2926. 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") };
  2927. if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
  2928. if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
  2929. return helper;
  2930. },
  2931. _adjustOffsetFromHelper: function(obj) {
  2932. if (typeof obj == 'string') {
  2933. obj = obj.split(' ');
  2934. }
  2935. if ($.isArray(obj)) {
  2936. obj = {left: +obj[0], top: +obj[1] || 0};
  2937. }
  2938. if ('left' in obj) {
  2939. this.offset.click.left = obj.left + this.margins.left;
  2940. }
  2941. if ('right' in obj) {
  2942. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  2943. }
  2944. if ('top' in obj) {
  2945. this.offset.click.top = obj.top + this.margins.top;
  2946. }
  2947. if ('bottom' in obj) {
  2948. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  2949. }
  2950. },
  2951. _getParentOffset: function() {
  2952. //Get the offsetParent and cache its position
  2953. this.offsetParent = this.helper.offsetParent();
  2954. var po = this.offsetParent.offset();
  2955. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  2956. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  2957. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  2958. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  2959. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  2960. po.left += this.scrollParent.scrollLeft();
  2961. po.top += this.scrollParent.scrollTop();
  2962. }
  2963. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  2964. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  2965. po = { top: 0, left: 0 };
  2966. return {
  2967. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  2968. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  2969. };
  2970. },
  2971. _getRelativeOffset: function() {
  2972. if(this.cssPosition == "relative") {
  2973. var p = this.currentItem.position();
  2974. return {
  2975. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  2976. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  2977. };
  2978. } else {
  2979. return { top: 0, left: 0 };
  2980. }
  2981. },
  2982. _cacheMargins: function() {
  2983. this.margins = {
  2984. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  2985. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  2986. };
  2987. },
  2988. _cacheHelperProportions: function() {
  2989. this.helperProportions = {
  2990. width: this.helper.outerWidth(),
  2991. height: this.helper.outerHeight()
  2992. };
  2993. },
  2994. _setContainment: function() {
  2995. var o = this.options;
  2996. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  2997. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  2998. 0 - this.offset.relative.left - this.offset.parent.left,
  2999. 0 - this.offset.relative.top - this.offset.parent.top,
  3000. $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  3001. ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3002. ];
  3003. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3004. var ce = $(o.containment)[0];
  3005. var co = $(o.containment).offset();
  3006. var over = ($(ce).css("overflow") != 'hidden');
  3007. this.containment = [
  3008. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3009. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3010. 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,
  3011. 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
  3012. ];
  3013. }
  3014. },
  3015. _convertPositionTo: function(d, pos) {
  3016. if(!pos) pos = this.position;
  3017. var mod = d == "absolute" ? 1 : -1;
  3018. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3019. return {
  3020. top: (
  3021. pos.top // The absolute mouse position
  3022. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  3023. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  3024. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3025. ),
  3026. left: (
  3027. pos.left // The absolute mouse position
  3028. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  3029. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  3030. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3031. )
  3032. };
  3033. },
  3034. _generatePosition: function(event) {
  3035. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3036. // This is another very weird special case that only happens for relative elements:
  3037. // 1. If the css position is relative
  3038. // 2. and the scroll parent is the document or similar to the offset parent
  3039. // we have to refresh the relative offset during the scroll so there are no jumps
  3040. if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
  3041. this.offset.relative = this._getRelativeOffset();
  3042. }
  3043. var pageX = event.pageX;
  3044. var pageY = event.pageY;
  3045. /*
  3046. * - Position constraining -
  3047. * Constrain the position to a mix of grid, containment.
  3048. */
  3049. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3050. if(this.containment) {
  3051. if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
  3052. if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
  3053. if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
  3054. if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
  3055. }
  3056. if(o.grid) {
  3057. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3058. 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;
  3059. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3060. 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;
  3061. }
  3062. }
  3063. return {
  3064. top: (
  3065. pageY // The absolute mouse position
  3066. - this.offset.click.top // Click offset (relative to the element)
  3067. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  3068. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  3069. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3070. ),
  3071. left: (
  3072. pageX // The absolute mouse position
  3073. - this.offset.click.left // Click offset (relative to the element)
  3074. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  3075. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  3076. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3077. )
  3078. };
  3079. },
  3080. _rearrange: function(event, i, a, hardRefresh) {
  3081. 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));
  3082. //Various things done here to improve the performance:
  3083. // 1. we create a setTimeout, that calls refreshPositions
  3084. // 2. on the instance, we have a counter variable, that get's higher after every append
  3085. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3086. // 4. this lets only the last addition to the timeout stack through
  3087. this.counter = this.counter ? ++this.counter : 1;
  3088. var self = this, counter = this.counter;
  3089. window.setTimeout(function() {
  3090. if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3091. },0);
  3092. },
  3093. _clear: function(event, noPropagation) {
  3094. this.reverting = false;
  3095. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3096. // everything else normalized again
  3097. var delayedTriggers = [], self = this;
  3098. // We first have to update the dom position of the actual currentItem
  3099. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3100. if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
  3101. this._noFinalSort = null;
  3102. if(this.helper[0] == this.currentItem[0]) {
  3103. for(var i in this._storedCSS) {
  3104. if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
  3105. }
  3106. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3107. } else {
  3108. this.currentItem.show();
  3109. }
  3110. if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3111. if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3112. // Check if the items Container has Changed and trigger appropriate
  3113. // events.
  3114. if (this !== this.currentContainer) {
  3115. if(!noPropagation) {
  3116. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3117. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3118. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3119. }
  3120. }
  3121. //Post events to containers
  3122. for (var i = this.containers.length - 1; i >= 0; i--){
  3123. if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3124. if(this.containers[i].containerCache.over) {
  3125. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3126. this.containers[i].containerCache.over = 0;
  3127. }
  3128. }
  3129. //Do what was originally in plugins
  3130. if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
  3131. if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
  3132. if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
  3133. this.dragging = false;
  3134. if(this.cancelHelperRemoval) {
  3135. if(!noPropagation) {
  3136. this._trigger("beforeStop", event, this._uiHash());
  3137. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3138. this._trigger("stop", event, this._uiHash());
  3139. }
  3140. this.fromOutside = false;
  3141. return false;
  3142. }
  3143. if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
  3144. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3145. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3146. if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
  3147. if(!noPropagation) {
  3148. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3149. this._trigger("stop", event, this._uiHash());
  3150. }
  3151. this.fromOutside = false;
  3152. return true;
  3153. },
  3154. _trigger: function() {
  3155. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3156. this.cancel();
  3157. }
  3158. },
  3159. _uiHash: function(inst) {
  3160. var self = inst || this;
  3161. return {
  3162. helper: self.helper,
  3163. placeholder: self.placeholder || $([]),
  3164. position: self.position,
  3165. originalPosition: self.originalPosition,
  3166. offset: self.positionAbs,
  3167. item: self.currentItem,
  3168. sender: inst ? inst.element : null
  3169. };
  3170. }
  3171. });
  3172. $.extend($.ui.sortable, {
  3173. version: "1.8.24"
  3174. });
  3175. })(jQuery);
  3176. ;jQuery.effects || (function($, undefined) {
  3177. $.effects = {};
  3178. /******************************************************************************/
  3179. /****************************** COLOR ANIMATIONS ******************************/
  3180. /******************************************************************************/
  3181. // override the animation for color styles
  3182. $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
  3183. 'borderRightColor', 'borderTopColor', 'borderColor', 'color', 'outlineColor'],
  3184. function(i, attr) {
  3185. $.fx.step[attr] = function(fx) {
  3186. if (!fx.colorInit) {
  3187. fx.start = getColor(fx.elem, attr);
  3188. fx.end = getRGB(fx.end);
  3189. fx.colorInit = true;
  3190. }
  3191. fx.elem.style[attr] = 'rgb(' +
  3192. Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
  3193. Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
  3194. Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
  3195. };
  3196. });
  3197. // Color Conversion functions from highlightFade
  3198. // By Blair Mitchelmore
  3199. // http://jquery.offput.ca/highlightFade/
  3200. // Parse strings looking for color tuples [255,255,255]
  3201. function getRGB(color) {
  3202. var result;
  3203. // Check if we're already dealing with an array of colors
  3204. if ( color && color.constructor == Array && color.length == 3 )
  3205. return color;
  3206. // Look for rgb(num,num,num)
  3207. if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
  3208. return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
  3209. // Look for rgb(num%,num%,num%)
  3210. if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
  3211. return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
  3212. // Look for #a0b1c2
  3213. if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
  3214. return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
  3215. // Look for #fff
  3216. if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
  3217. return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
  3218. // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
  3219. if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
  3220. return colors['transparent'];
  3221. // Otherwise, we're most likely dealing with a named color
  3222. return colors[$.trim(color).toLowerCase()];
  3223. }
  3224. function getColor(elem, attr) {
  3225. var color;
  3226. do {
  3227. // jQuery <1.4.3 uses curCSS, in 1.4.3 - 1.7.2 curCSS = css, 1.8+ only has css
  3228. color = ($.curCSS || $.css)(elem, attr);
  3229. // Keep going until we find an element that has color, or we hit the body
  3230. if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
  3231. break;
  3232. attr = "backgroundColor";
  3233. } while ( elem = elem.parentNode );
  3234. return getRGB(color);
  3235. };
  3236. // Some named colors to work with
  3237. // From Interface by Stefan Petre
  3238. // http://interface.eyecon.ro/
  3239. var colors = {
  3240. aqua:[0,255,255],
  3241. azure:[240,255,255],
  3242. beige:[245,245,220],
  3243. black:[0,0,0],
  3244. blue:[0,0,255],
  3245. brown:[165,42,42],
  3246. cyan:[0,255,255],
  3247. darkblue:[0,0,139],
  3248. darkcyan:[0,139,139],
  3249. darkgrey:[169,169,169],
  3250. darkgreen:[0,100,0],
  3251. darkkhaki:[189,183,107],
  3252. darkmagenta:[139,0,139],
  3253. darkolivegreen:[85,107,47],
  3254. darkorange:[255,140,0],
  3255. darkorchid:[153,50,204],
  3256. darkred:[139,0,0],
  3257. darksalmon:[233,150,122],
  3258. darkviolet:[148,0,211],
  3259. fuchsia:[255,0,255],
  3260. gold:[255,215,0],
  3261. green:[0,128,0],
  3262. indigo:[75,0,130],
  3263. khaki:[240,230,140],
  3264. lightblue:[173,216,230],
  3265. lightcyan:[224,255,255],
  3266. lightgreen:[144,238,144],
  3267. lightgrey:[211,211,211],
  3268. lightpink:[255,182,193],
  3269. lightyellow:[255,255,224],
  3270. lime:[0,255,0],
  3271. magenta:[255,0,255],
  3272. maroon:[128,0,0],
  3273. navy:[0,0,128],
  3274. olive:[128,128,0],
  3275. orange:[255,165,0],
  3276. pink:[255,192,203],
  3277. purple:[128,0,128],
  3278. violet:[128,0,128],
  3279. red:[255,0,0],
  3280. silver:[192,192,192],
  3281. white:[255,255,255],
  3282. yellow:[255,255,0],
  3283. transparent: [255,255,255]
  3284. };
  3285. /******************************************************************************/
  3286. /****************************** CLASS ANIMATIONS ******************************/
  3287. /******************************************************************************/
  3288. var classAnimationActions = ['add', 'remove', 'toggle'],
  3289. shorthandStyles = {
  3290. border: 1,
  3291. borderBottom: 1,
  3292. borderColor: 1,
  3293. borderLeft: 1,
  3294. borderRight: 1,
  3295. borderTop: 1,
  3296. borderWidth: 1,
  3297. margin: 1,
  3298. padding: 1
  3299. };
  3300. function getElementStyles() {
  3301. var style = document.defaultView
  3302. ? document.defaultView.getComputedStyle(this, null)
  3303. : this.currentStyle,
  3304. newStyle = {},
  3305. key,
  3306. camelCase;
  3307. // webkit enumerates style porperties
  3308. if (style && style.length && style[0] && style[style[0]]) {
  3309. var len = style.length;
  3310. while (len--) {
  3311. key = style[len];
  3312. if (typeof style[key] == 'string') {
  3313. camelCase = key.replace(/\-(\w)/g, function(all, letter){
  3314. return letter.toUpperCase();
  3315. });
  3316. newStyle[camelCase] = style[key];
  3317. }
  3318. }
  3319. } else {
  3320. for (key in style) {
  3321. if (typeof style[key] === 'string') {
  3322. newStyle[key] = style[key];
  3323. }
  3324. }
  3325. }
  3326. return newStyle;
  3327. }
  3328. function filterStyles(styles) {
  3329. var name, value;
  3330. for (name in styles) {
  3331. value = styles[name];
  3332. if (
  3333. // ignore null and undefined values
  3334. value == null ||
  3335. // ignore functions (when does this occur?)
  3336. $.isFunction(value) ||
  3337. // shorthand styles that need to be expanded
  3338. name in shorthandStyles ||
  3339. // ignore scrollbars (break in IE)
  3340. (/scrollbar/).test(name) ||
  3341. // only colors or values that can be converted to numbers
  3342. (!(/color/i).test(name) && isNaN(parseFloat(value)))
  3343. ) {
  3344. delete styles[name];
  3345. }
  3346. }
  3347. return styles;
  3348. }
  3349. function styleDifference(oldStyle, newStyle) {
  3350. var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
  3351. name;
  3352. for (name in newStyle) {
  3353. if (oldStyle[name] != newStyle[name]) {
  3354. diff[name] = newStyle[name];
  3355. }
  3356. }
  3357. return diff;
  3358. }
  3359. $.effects.animateClass = function(value, duration, easing, callback) {
  3360. if ($.isFunction(easing)) {
  3361. callback = easing;
  3362. easing = null;
  3363. }
  3364. return this.queue(function() {
  3365. var that = $(this),
  3366. originalStyleAttr = that.attr('style') || ' ',
  3367. originalStyle = filterStyles(getElementStyles.call(this)),
  3368. newStyle,
  3369. className = that.attr('class') || "";
  3370. $.each(classAnimationActions, function(i, action) {
  3371. if (value[action]) {
  3372. that[action + 'Class'](value[action]);
  3373. }
  3374. });
  3375. newStyle = filterStyles(getElementStyles.call(this));
  3376. that.attr('class', className);
  3377. that.animate(styleDifference(originalStyle, newStyle), {
  3378. queue: false,
  3379. duration: duration,
  3380. easing: easing,
  3381. complete: function() {
  3382. $.each(classAnimationActions, function(i, action) {
  3383. if (value[action]) { that[action + 'Class'](value[action]); }
  3384. });
  3385. // work around bug in IE by clearing the cssText before setting it
  3386. if (typeof that.attr('style') == 'object') {
  3387. that.attr('style').cssText = '';
  3388. that.attr('style').cssText = originalStyleAttr;
  3389. } else {
  3390. that.attr('style', originalStyleAttr);
  3391. }
  3392. if (callback) { callback.apply(this, arguments); }
  3393. $.dequeue( this );
  3394. }
  3395. });
  3396. });
  3397. };
  3398. $.fn.extend({
  3399. _addClass: $.fn.addClass,
  3400. addClass: function(classNames, speed, easing, callback) {
  3401. return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
  3402. },
  3403. _removeClass: $.fn.removeClass,
  3404. removeClass: function(classNames,speed,easing,callback) {
  3405. return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
  3406. },
  3407. _toggleClass: $.fn.toggleClass,
  3408. toggleClass: function(classNames, force, speed, easing, callback) {
  3409. if ( typeof force == "boolean" || force === undefined ) {
  3410. if ( !speed ) {
  3411. // without speed parameter;
  3412. return this._toggleClass(classNames, force);
  3413. } else {
  3414. return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
  3415. }
  3416. } else {
  3417. // without switch parameter;
  3418. return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
  3419. }
  3420. },
  3421. switchClass: function(remove,add,speed,easing,callback) {
  3422. return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
  3423. }
  3424. });
  3425. /******************************************************************************/
  3426. /*********************************** EFFECTS **********************************/
  3427. /******************************************************************************/
  3428. $.extend($.effects, {
  3429. version: "1.8.24",
  3430. // Saves a set of properties in a data storage
  3431. save: function(element, set) {
  3432. for(var i=0; i < set.length; i++) {
  3433. if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
  3434. }
  3435. },
  3436. // Restores a set of previously saved properties from a data storage
  3437. restore: function(element, set) {
  3438. for(var i=0; i < set.length; i++) {
  3439. if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
  3440. }
  3441. },
  3442. setMode: function(el, mode) {
  3443. if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
  3444. return mode;
  3445. },
  3446. getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
  3447. // this should be a little more flexible in the future to handle a string & hash
  3448. var y, x;
  3449. switch (origin[0]) {
  3450. case 'top': y = 0; break;
  3451. case 'middle': y = 0.5; break;
  3452. case 'bottom': y = 1; break;
  3453. default: y = origin[0] / original.height;
  3454. };
  3455. switch (origin[1]) {
  3456. case 'left': x = 0; break;
  3457. case 'center': x = 0.5; break;
  3458. case 'right': x = 1; break;
  3459. default: x = origin[1] / original.width;
  3460. };
  3461. return {x: x, y: y};
  3462. },
  3463. // Wraps the element around a wrapper that copies position properties
  3464. createWrapper: function(element) {
  3465. // if the element is already wrapped, return it
  3466. if (element.parent().is('.ui-effects-wrapper')) {
  3467. return element.parent();
  3468. }
  3469. // wrap the element
  3470. var props = {
  3471. width: element.outerWidth(true),
  3472. height: element.outerHeight(true),
  3473. 'float': element.css('float')
  3474. },
  3475. wrapper = $('<div></div>')
  3476. .addClass('ui-effects-wrapper')
  3477. .css({
  3478. fontSize: '100%',
  3479. background: 'transparent',
  3480. border: 'none',
  3481. margin: 0,
  3482. padding: 0
  3483. }),
  3484. active = document.activeElement;
  3485. // support: Firefox
  3486. // Firefox incorrectly exposes anonymous content
  3487. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  3488. try {
  3489. active.id;
  3490. } catch( e ) {
  3491. active = document.body;
  3492. }
  3493. element.wrap( wrapper );
  3494. // Fixes #7595 - Elements lose focus when wrapped.
  3495. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  3496. $( active ).focus();
  3497. }
  3498. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
  3499. // transfer positioning properties to the wrapper
  3500. if (element.css('position') == 'static') {
  3501. wrapper.css({ position: 'relative' });
  3502. element.css({ position: 'relative' });
  3503. } else {
  3504. $.extend(props, {
  3505. position: element.css('position'),
  3506. zIndex: element.css('z-index')
  3507. });
  3508. $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
  3509. props[pos] = element.css(pos);
  3510. if (isNaN(parseInt(props[pos], 10))) {
  3511. props[pos] = 'auto';
  3512. }
  3513. });
  3514. element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' });
  3515. }
  3516. return wrapper.css(props).show();
  3517. },
  3518. removeWrapper: function(element) {
  3519. var parent,
  3520. active = document.activeElement;
  3521. if (element.parent().is('.ui-effects-wrapper')) {
  3522. parent = element.parent().replaceWith(element);
  3523. // Fixes #7595 - Elements lose focus when wrapped.
  3524. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  3525. $( active ).focus();
  3526. }
  3527. return parent;
  3528. }
  3529. return element;
  3530. },
  3531. setTransition: function(element, list, factor, value) {
  3532. value = value || {};
  3533. $.each(list, function(i, x){
  3534. var unit = element.cssUnit(x);
  3535. if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
  3536. });
  3537. return value;
  3538. }
  3539. });
  3540. function _normalizeArguments(effect, options, speed, callback) {
  3541. // shift params for method overloading
  3542. if (typeof effect == 'object') {
  3543. callback = options;
  3544. speed = null;
  3545. options = effect;
  3546. effect = options.effect;
  3547. }
  3548. if ($.isFunction(options)) {
  3549. callback = options;
  3550. speed = null;
  3551. options = {};
  3552. }
  3553. if (typeof options == 'number' || $.fx.speeds[options]) {
  3554. callback = speed;
  3555. speed = options;
  3556. options = {};
  3557. }
  3558. if ($.isFunction(speed)) {
  3559. callback = speed;
  3560. speed = null;
  3561. }
  3562. options = options || {};
  3563. speed = speed || options.duration;
  3564. speed = $.fx.off ? 0 : typeof speed == 'number'
  3565. ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
  3566. callback = callback || options.complete;
  3567. return [effect, options, speed, callback];
  3568. }
  3569. function standardSpeed( speed ) {
  3570. // valid standard speeds
  3571. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  3572. return true;
  3573. }
  3574. // invalid strings - treat as "normal" speed
  3575. if ( typeof speed === "string" && !$.effects[ speed ] ) {
  3576. return true;
  3577. }
  3578. return false;
  3579. }
  3580. $.fn.extend({
  3581. effect: function(effect, options, speed, callback) {
  3582. var args = _normalizeArguments.apply(this, arguments),
  3583. // TODO: make effects take actual parameters instead of a hash
  3584. args2 = {
  3585. options: args[1],
  3586. duration: args[2],
  3587. callback: args[3]
  3588. },
  3589. mode = args2.options.mode,
  3590. effectMethod = $.effects[effect];
  3591. if ( $.fx.off || !effectMethod ) {
  3592. // delegate to the original method (e.g., .show()) if possible
  3593. if ( mode ) {
  3594. return this[ mode ]( args2.duration, args2.callback );
  3595. } else {
  3596. return this.each(function() {
  3597. if ( args2.callback ) {
  3598. args2.callback.call( this );
  3599. }
  3600. });
  3601. }
  3602. }
  3603. return effectMethod.call(this, args2);
  3604. },
  3605. _show: $.fn.show,
  3606. show: function(speed) {
  3607. if ( standardSpeed( speed ) ) {
  3608. return this._show.apply(this, arguments);
  3609. } else {
  3610. var args = _normalizeArguments.apply(this, arguments);
  3611. args[1].mode = 'show';
  3612. return this.effect.apply(this, args);
  3613. }
  3614. },
  3615. _hide: $.fn.hide,
  3616. hide: function(speed) {
  3617. if ( standardSpeed( speed ) ) {
  3618. return this._hide.apply(this, arguments);
  3619. } else {
  3620. var args = _normalizeArguments.apply(this, arguments);
  3621. args[1].mode = 'hide';
  3622. return this.effect.apply(this, args);
  3623. }
  3624. },
  3625. // jQuery core overloads toggle and creates _toggle
  3626. __toggle: $.fn.toggle,
  3627. toggle: function(speed) {
  3628. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  3629. return this.__toggle.apply(this, arguments);
  3630. } else {
  3631. var args = _normalizeArguments.apply(this, arguments);
  3632. args[1].mode = 'toggle';
  3633. return this.effect.apply(this, args);
  3634. }
  3635. },
  3636. // helper functions
  3637. cssUnit: function(key) {
  3638. var style = this.css(key), val = [];
  3639. $.each( ['em','px','%','pt'], function(i, unit){
  3640. if(style.indexOf(unit) > 0)
  3641. val = [parseFloat(style), unit];
  3642. });
  3643. return val;
  3644. }
  3645. });
  3646. /******************************************************************************/
  3647. /*********************************** EASING ***********************************/
  3648. /******************************************************************************/
  3649. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  3650. var baseEasings = {};
  3651. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  3652. baseEasings[ name ] = function( p ) {
  3653. return Math.pow( p, i + 2 );
  3654. };
  3655. });
  3656. $.extend( baseEasings, {
  3657. Sine: function ( p ) {
  3658. return 1 - Math.cos( p * Math.PI / 2 );
  3659. },
  3660. Circ: function ( p ) {
  3661. return 1 - Math.sqrt( 1 - p * p );
  3662. },
  3663. Elastic: function( p ) {
  3664. return p === 0 || p === 1 ? p :
  3665. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  3666. },
  3667. Back: function( p ) {
  3668. return p * p * ( 3 * p - 2 );
  3669. },
  3670. Bounce: function ( p ) {
  3671. var pow2,
  3672. bounce = 4;
  3673. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  3674. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  3675. }
  3676. });
  3677. $.each( baseEasings, function( name, easeIn ) {
  3678. $.easing[ "easeIn" + name ] = easeIn;
  3679. $.easing[ "easeOut" + name ] = function( p ) {
  3680. return 1 - easeIn( 1 - p );
  3681. };
  3682. $.easing[ "easeInOut" + name ] = function( p ) {
  3683. return p < .5 ?
  3684. easeIn( p * 2 ) / 2 :
  3685. easeIn( p * -2 + 2 ) / -2 + 1;
  3686. };
  3687. });
  3688. })(jQuery);
  3689. (function( $, undefined ) {
  3690. $.effects.blind = function(o) {
  3691. return this.queue(function() {
  3692. // Create element
  3693. var el = $(this), props = ['position','top','bottom','left','right'];
  3694. // Set options
  3695. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  3696. var direction = o.options.direction || 'vertical'; // Default direction
  3697. // Adjust
  3698. $.effects.save(el, props); el.show(); // Save & Show
  3699. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  3700. var ref = (direction == 'vertical') ? 'height' : 'width';
  3701. var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
  3702. if(mode == 'show') wrapper.css(ref, 0); // Shift
  3703. // Animation
  3704. var animation = {};
  3705. animation[ref] = mode == 'show' ? distance : 0;
  3706. // Animate
  3707. wrapper.animate(animation, o.duration, o.options.easing, function() {
  3708. if(mode == 'hide') el.hide(); // Hide
  3709. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3710. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  3711. el.dequeue();
  3712. });
  3713. });
  3714. };
  3715. })(jQuery);
  3716. (function( $, undefined ) {
  3717. $.effects.bounce = function(o) {
  3718. return this.queue(function() {
  3719. // Create element
  3720. var el = $(this), props = ['position','top','bottom','left','right'];
  3721. // Set options
  3722. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  3723. var direction = o.options.direction || 'up'; // Default direction
  3724. var distance = o.options.distance || 20; // Default distance
  3725. var times = o.options.times || 5; // Default # of times
  3726. var speed = o.duration || 250; // Default speed per bounce
  3727. if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
  3728. // Adjust
  3729. $.effects.save(el, props); el.show(); // Save & Show
  3730. $.effects.createWrapper(el); // Create Wrapper
  3731. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  3732. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  3733. var distance = o.options.distance || (ref == 'top' ? el.outerHeight(true) / 3 : el.outerWidth(true) / 3);
  3734. if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
  3735. if (mode == 'hide') distance = distance / (times * 2);
  3736. if (mode != 'hide') times--;
  3737. // Animate
  3738. if (mode == 'show') { // Show Bounce
  3739. var animation = {opacity: 1};
  3740. animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  3741. el.animate(animation, speed / 2, o.options.easing);
  3742. distance = distance / 2;
  3743. times--;
  3744. };
  3745. for (var i = 0; i < times; i++) { // Bounces
  3746. var animation1 = {}, animation2 = {};
  3747. animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  3748. animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  3749. el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
  3750. distance = (mode == 'hide') ? distance * 2 : distance / 2;
  3751. };
  3752. if (mode == 'hide') { // Last Bounce
  3753. var animation = {opacity: 0};
  3754. animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  3755. el.animate(animation, speed / 2, o.options.easing, function(){
  3756. el.hide(); // Hide
  3757. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3758. if(o.callback) o.callback.apply(this, arguments); // Callback
  3759. });
  3760. } else {
  3761. var animation1 = {}, animation2 = {};
  3762. animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  3763. animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  3764. el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
  3765. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3766. if(o.callback) o.callback.apply(this, arguments); // Callback
  3767. });
  3768. };
  3769. el.queue('fx', function() { el.dequeue(); });
  3770. el.dequeue();
  3771. });
  3772. };
  3773. })(jQuery);
  3774. (function( $, undefined ) {
  3775. $.effects.clip = function(o) {
  3776. return this.queue(function() {
  3777. // Create element
  3778. var el = $(this), props = ['position','top','bottom','left','right','height','width'];
  3779. // Set options
  3780. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  3781. var direction = o.options.direction || 'vertical'; // Default direction
  3782. // Adjust
  3783. $.effects.save(el, props); el.show(); // Save & Show
  3784. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  3785. var animate = el[0].tagName == 'IMG' ? wrapper : el;
  3786. var ref = {
  3787. size: (direction == 'vertical') ? 'height' : 'width',
  3788. position: (direction == 'vertical') ? 'top' : 'left'
  3789. };
  3790. var distance = (direction == 'vertical') ? animate.height() : animate.width();
  3791. if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
  3792. // Animation
  3793. var animation = {};
  3794. animation[ref.size] = mode == 'show' ? distance : 0;
  3795. animation[ref.position] = mode == 'show' ? 0 : distance / 2;
  3796. // Animate
  3797. animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  3798. if(mode == 'hide') el.hide(); // Hide
  3799. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3800. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  3801. el.dequeue();
  3802. }});
  3803. });
  3804. };
  3805. })(jQuery);
  3806. (function( $, undefined ) {
  3807. $.effects.drop = function(o) {
  3808. return this.queue(function() {
  3809. // Create element
  3810. var el = $(this), props = ['position','top','bottom','left','right','opacity'];
  3811. // Set options
  3812. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  3813. var direction = o.options.direction || 'left'; // Default Direction
  3814. // Adjust
  3815. $.effects.save(el, props); el.show(); // Save & Show
  3816. $.effects.createWrapper(el); // Create Wrapper
  3817. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  3818. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  3819. var distance = o.options.distance || (ref == 'top' ? el.outerHeight( true ) / 2 : el.outerWidth( true ) / 2);
  3820. if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
  3821. // Animation
  3822. var animation = {opacity: mode == 'show' ? 1 : 0};
  3823. animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
  3824. // Animate
  3825. el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  3826. if(mode == 'hide') el.hide(); // Hide
  3827. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3828. if(o.callback) o.callback.apply(this, arguments); // Callback
  3829. el.dequeue();
  3830. }});
  3831. });
  3832. };
  3833. })(jQuery);
  3834. (function( $, undefined ) {
  3835. $.effects.explode = function(o) {
  3836. return this.queue(function() {
  3837. var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
  3838. var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
  3839. o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
  3840. var el = $(this).show().css('visibility', 'hidden');
  3841. var offset = el.offset();
  3842. //Substract the margins - not fixing the problem yet.
  3843. offset.top -= parseInt(el.css("marginTop"),10) || 0;
  3844. offset.left -= parseInt(el.css("marginLeft"),10) || 0;
  3845. var width = el.outerWidth(true);
  3846. var height = el.outerHeight(true);
  3847. for(var i=0;i<rows;i++) { // =
  3848. for(var j=0;j<cells;j++) { // ||
  3849. el
  3850. .clone()
  3851. .appendTo('body')
  3852. .wrap('<div></div>')
  3853. .css({
  3854. position: 'absolute',
  3855. visibility: 'visible',
  3856. left: -j*(width/cells),
  3857. top: -i*(height/rows)
  3858. })
  3859. .parent()
  3860. .addClass('ui-effects-explode')
  3861. .css({
  3862. position: 'absolute',
  3863. overflow: 'hidden',
  3864. width: width/cells,
  3865. height: height/rows,
  3866. left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
  3867. top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
  3868. opacity: o.options.mode == 'show' ? 0 : 1
  3869. }).animate({
  3870. left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
  3871. top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
  3872. opacity: o.options.mode == 'show' ? 1 : 0
  3873. }, o.duration || 500);
  3874. }
  3875. }
  3876. // Set a timeout, to call the callback approx. when the other animations have finished
  3877. setTimeout(function() {
  3878. o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
  3879. if(o.callback) o.callback.apply(el[0]); // Callback
  3880. el.dequeue();
  3881. $('div.ui-effects-explode').remove();
  3882. }, o.duration || 500);
  3883. });
  3884. };
  3885. })(jQuery);
  3886. (function( $, undefined ) {
  3887. $.effects.fade = function(o) {
  3888. return this.queue(function() {
  3889. var elem = $(this),
  3890. mode = $.effects.setMode(elem, o.options.mode || 'hide');
  3891. elem.animate({ opacity: mode }, {
  3892. queue: false,
  3893. duration: o.duration,
  3894. easing: o.options.easing,
  3895. complete: function() {
  3896. (o.callback && o.callback.apply(this, arguments));
  3897. elem.dequeue();
  3898. }
  3899. });
  3900. });
  3901. };
  3902. })(jQuery);
  3903. (function( $, undefined ) {
  3904. $.effects.fold = function(o) {
  3905. return this.queue(function() {
  3906. // Create element
  3907. var el = $(this), props = ['position','top','bottom','left','right'];
  3908. // Set options
  3909. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  3910. var size = o.options.size || 15; // Default fold size
  3911. var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
  3912. var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
  3913. // Adjust
  3914. $.effects.save(el, props); el.show(); // Save & Show
  3915. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  3916. var widthFirst = ((mode == 'show') != horizFirst);
  3917. var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
  3918. var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
  3919. var percent = /([0-9]+)%/.exec(size);
  3920. if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1];
  3921. if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
  3922. // Animation
  3923. var animation1 = {}, animation2 = {};
  3924. animation1[ref[0]] = mode == 'show' ? distance[0] : size;
  3925. animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
  3926. // Animate
  3927. wrapper.animate(animation1, duration, o.options.easing)
  3928. .animate(animation2, duration, o.options.easing, function() {
  3929. if(mode == 'hide') el.hide(); // Hide
  3930. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3931. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  3932. el.dequeue();
  3933. });
  3934. });
  3935. };
  3936. })(jQuery);
  3937. (function( $, undefined ) {
  3938. $.effects.highlight = function(o) {
  3939. return this.queue(function() {
  3940. var elem = $(this),
  3941. props = ['backgroundImage', 'backgroundColor', 'opacity'],
  3942. mode = $.effects.setMode(elem, o.options.mode || 'show'),
  3943. animation = {
  3944. backgroundColor: elem.css('backgroundColor')
  3945. };
  3946. if (mode == 'hide') {
  3947. animation.opacity = 0;
  3948. }
  3949. $.effects.save(elem, props);
  3950. elem
  3951. .show()
  3952. .css({
  3953. backgroundImage: 'none',
  3954. backgroundColor: o.options.color || '#ffff99'
  3955. })
  3956. .animate(animation, {
  3957. queue: false,
  3958. duration: o.duration,
  3959. easing: o.options.easing,
  3960. complete: function() {
  3961. (mode == 'hide' && elem.hide());
  3962. $.effects.restore(elem, props);
  3963. (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
  3964. (o.callback && o.callback.apply(this, arguments));
  3965. elem.dequeue();
  3966. }
  3967. });
  3968. });
  3969. };
  3970. })(jQuery);
  3971. (function( $, undefined ) {
  3972. $.effects.pulsate = function(o) {
  3973. return this.queue(function() {
  3974. var elem = $(this),
  3975. mode = $.effects.setMode(elem, o.options.mode || 'show'),
  3976. times = ((o.options.times || 5) * 2) - 1,
  3977. duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
  3978. isVisible = elem.is(':visible'),
  3979. animateTo = 0;
  3980. if (!isVisible) {
  3981. elem.css('opacity', 0).show();
  3982. animateTo = 1;
  3983. }
  3984. if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
  3985. times--;
  3986. }
  3987. for (var i = 0; i < times; i++) {
  3988. elem.animate({ opacity: animateTo }, duration, o.options.easing);
  3989. animateTo = (animateTo + 1) % 2;
  3990. }
  3991. elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
  3992. if (animateTo == 0) {
  3993. elem.hide();
  3994. }
  3995. (o.callback && o.callback.apply(this, arguments));
  3996. });
  3997. elem
  3998. .queue('fx', function() { elem.dequeue(); })
  3999. .dequeue();
  4000. });
  4001. };
  4002. })(jQuery);
  4003. (function( $, undefined ) {
  4004. $.effects.puff = function(o) {
  4005. return this.queue(function() {
  4006. var elem = $(this),
  4007. mode = $.effects.setMode(elem, o.options.mode || 'hide'),
  4008. percent = parseInt(o.options.percent, 10) || 150,
  4009. factor = percent / 100,
  4010. original = { height: elem.height(), width: elem.width() };
  4011. $.extend(o.options, {
  4012. fade: true,
  4013. mode: mode,
  4014. percent: mode == 'hide' ? percent : 100,
  4015. from: mode == 'hide'
  4016. ? original
  4017. : {
  4018. height: original.height * factor,
  4019. width: original.width * factor
  4020. }
  4021. });
  4022. elem.effect('scale', o.options, o.duration, o.callback);
  4023. elem.dequeue();
  4024. });
  4025. };
  4026. $.effects.scale = function(o) {
  4027. return this.queue(function() {
  4028. // Create element
  4029. var el = $(this);
  4030. // Set options
  4031. var options = $.extend(true, {}, o.options);
  4032. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  4033. var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
  4034. var direction = o.options.direction || 'both'; // Set default axis
  4035. var origin = o.options.origin; // The origin of the scaling
  4036. if (mode != 'effect') { // Set default origin and restore for show/hide
  4037. options.origin = origin || ['middle','center'];
  4038. options.restore = true;
  4039. }
  4040. var original = {height: el.height(), width: el.width()}; // Save original
  4041. el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
  4042. // Adjust
  4043. var factor = { // Set scaling factor
  4044. y: direction != 'horizontal' ? (percent / 100) : 1,
  4045. x: direction != 'vertical' ? (percent / 100) : 1
  4046. };
  4047. el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
  4048. if (o.options.fade) { // Fade option to support puff
  4049. if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
  4050. if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
  4051. };
  4052. // Animation
  4053. options.from = el.from; options.to = el.to; options.mode = mode;
  4054. // Animate
  4055. el.effect('size', options, o.duration, o.callback);
  4056. el.dequeue();
  4057. });
  4058. };
  4059. $.effects.size = function(o) {
  4060. return this.queue(function() {
  4061. // Create element
  4062. var el = $(this), props = ['position','top','bottom','left','right','width','height','overflow','opacity'];
  4063. var props1 = ['position','top','bottom','left','right','overflow','opacity']; // Always restore
  4064. var props2 = ['width','height','overflow']; // Copy for children
  4065. var cProps = ['fontSize'];
  4066. var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
  4067. var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
  4068. // Set options
  4069. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  4070. var restore = o.options.restore || false; // Default restore
  4071. var scale = o.options.scale || 'both'; // Default scale mode
  4072. var origin = o.options.origin; // The origin of the sizing
  4073. var original = {height: el.height(), width: el.width()}; // Save original
  4074. el.from = o.options.from || original; // Default from state
  4075. el.to = o.options.to || original; // Default to state
  4076. // Adjust
  4077. if (origin) { // Calculate baseline shifts
  4078. var baseline = $.effects.getBaseline(origin, original);
  4079. el.from.top = (original.height - el.from.height) * baseline.y;
  4080. el.from.left = (original.width - el.from.width) * baseline.x;
  4081. el.to.top = (original.height - el.to.height) * baseline.y;
  4082. el.to.left = (original.width - el.to.width) * baseline.x;
  4083. };
  4084. var factor = { // Set scaling factor
  4085. from: {y: el.from.height / original.height, x: el.from.width / original.width},
  4086. to: {y: el.to.height / original.height, x: el.to.width / original.width}
  4087. };
  4088. if (scale == 'box' || scale == 'both') { // Scale the css box
  4089. if (factor.from.y != factor.to.y) { // Vertical props scaling
  4090. props = props.concat(vProps);
  4091. el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
  4092. el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
  4093. };
  4094. if (factor.from.x != factor.to.x) { // Horizontal props scaling
  4095. props = props.concat(hProps);
  4096. el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
  4097. el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
  4098. };
  4099. };
  4100. if (scale == 'content' || scale == 'both') { // Scale the content
  4101. if (factor.from.y != factor.to.y) { // Vertical props scaling
  4102. props = props.concat(cProps);
  4103. el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
  4104. el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
  4105. };
  4106. };
  4107. $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
  4108. $.effects.createWrapper(el); // Create Wrapper
  4109. el.css('overflow','hidden').css(el.from); // Shift
  4110. // Animate
  4111. if (scale == 'content' || scale == 'both') { // Scale the children
  4112. vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
  4113. hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
  4114. props2 = props.concat(vProps).concat(hProps); // Concat
  4115. el.find("*[width]").each(function(){
  4116. var child = $(this);
  4117. if (restore) $.effects.save(child, props2);
  4118. var c_original = {height: child.height(), width: child.width()}; // Save original
  4119. child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
  4120. child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
  4121. if (factor.from.y != factor.to.y) { // Vertical props scaling
  4122. child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
  4123. child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
  4124. };
  4125. if (factor.from.x != factor.to.x) { // Horizontal props scaling
  4126. child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
  4127. child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
  4128. };
  4129. child.css(child.from); // Shift children
  4130. child.animate(child.to, o.duration, o.options.easing, function(){
  4131. if (restore) $.effects.restore(child, props2); // Restore children
  4132. }); // Animate children
  4133. });
  4134. };
  4135. // Animate
  4136. el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  4137. if (el.to.opacity === 0) {
  4138. el.css('opacity', el.from.opacity);
  4139. }
  4140. if(mode == 'hide') el.hide(); // Hide
  4141. $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
  4142. if(o.callback) o.callback.apply(this, arguments); // Callback
  4143. el.dequeue();
  4144. }});
  4145. });
  4146. };
  4147. })(jQuery);
  4148. (function( $, undefined ) {
  4149. $.effects.shake = function(o) {
  4150. return this.queue(function() {
  4151. // Create element
  4152. var el = $(this), props = ['position','top','bottom','left','right'];
  4153. // Set options
  4154. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  4155. var direction = o.options.direction || 'left'; // Default direction
  4156. var distance = o.options.distance || 20; // Default distance
  4157. var times = o.options.times || 3; // Default # of times
  4158. var speed = o.duration || o.options.duration || 140; // Default speed per shake
  4159. // Adjust
  4160. $.effects.save(el, props); el.show(); // Save & Show
  4161. $.effects.createWrapper(el); // Create Wrapper
  4162. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  4163. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  4164. // Animation
  4165. var animation = {}, animation1 = {}, animation2 = {};
  4166. animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  4167. animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2;
  4168. animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2;
  4169. // Animate
  4170. el.animate(animation, speed, o.options.easing);
  4171. for (var i = 1; i < times; i++) { // Shakes
  4172. el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
  4173. };
  4174. el.animate(animation1, speed, o.options.easing).
  4175. animate(animation, speed / 2, o.options.easing, function(){ // Last shake
  4176. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  4177. if(o.callback) o.callback.apply(this, arguments); // Callback
  4178. });
  4179. el.queue('fx', function() { el.dequeue(); });
  4180. el.dequeue();
  4181. });
  4182. };
  4183. })(jQuery);
  4184. (function( $, undefined ) {
  4185. $.effects.slide = function(o) {
  4186. return this.queue(function() {
  4187. // Create element
  4188. var el = $(this), props = ['position','top','bottom','left','right'];
  4189. // Set options
  4190. var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
  4191. var direction = o.options.direction || 'left'; // Default Direction
  4192. // Adjust
  4193. $.effects.save(el, props); el.show(); // Save & Show
  4194. $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  4195. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  4196. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  4197. var distance = o.options.distance || (ref == 'top' ? el.outerHeight( true ) : el.outerWidth( true ));
  4198. if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
  4199. // Animation
  4200. var animation = {};
  4201. animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
  4202. // Animate
  4203. el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  4204. if(mode == 'hide') el.hide(); // Hide
  4205. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  4206. if(o.callback) o.callback.apply(this, arguments); // Callback
  4207. el.dequeue();
  4208. }});
  4209. });
  4210. };
  4211. })(jQuery);
  4212. (function( $, undefined ) {
  4213. $.effects.transfer = function(o) {
  4214. return this.queue(function() {
  4215. var elem = $(this),
  4216. target = $(o.options.to),
  4217. endPosition = target.offset(),
  4218. animation = {
  4219. top: endPosition.top,
  4220. left: endPosition.left,
  4221. height: target.innerHeight(),
  4222. width: target.innerWidth()
  4223. },
  4224. startPosition = elem.offset(),
  4225. transfer = $('<div class="ui-effects-transfer"></div>')
  4226. .appendTo(document.body)
  4227. .addClass(o.options.className)
  4228. .css({
  4229. top: startPosition.top,
  4230. left: startPosition.left,
  4231. height: elem.innerHeight(),
  4232. width: elem.innerWidth(),
  4233. position: 'absolute'
  4234. })
  4235. .animate(animation, o.duration, o.options.easing, function() {
  4236. transfer.remove();
  4237. (o.callback && o.callback.apply(elem[0], arguments));
  4238. elem.dequeue();
  4239. });
  4240. });
  4241. };
  4242. })(jQuery);
  4243. (function( $, undefined ) {
  4244. $.widget( "ui.accordion", {
  4245. options: {
  4246. active: 0,
  4247. animated: "slide",
  4248. autoHeight: true,
  4249. clearStyle: false,
  4250. collapsible: false,
  4251. event: "click",
  4252. fillSpace: false,
  4253. header: "> li > :first-child,> :not(li):even",
  4254. icons: {
  4255. header: "ui-icon-triangle-1-e",
  4256. headerSelected: "ui-icon-triangle-1-s"
  4257. },
  4258. navigation: false,
  4259. navigationFilter: function() {
  4260. return this.href.toLowerCase() === location.href.toLowerCase();
  4261. }
  4262. },
  4263. _create: function() {
  4264. var self = this,
  4265. options = self.options;
  4266. self.running = 0;
  4267. self.element
  4268. .addClass( "ui-accordion ui-widget ui-helper-reset" )
  4269. // in lack of child-selectors in CSS
  4270. // we need to mark top-LIs in a UL-accordion for some IE-fix
  4271. .children( "li" )
  4272. .addClass( "ui-accordion-li-fix" );
  4273. self.headers = self.element.find( options.header )
  4274. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" )
  4275. .bind( "mouseenter.accordion", function() {
  4276. if ( options.disabled ) {
  4277. return;
  4278. }
  4279. $( this ).addClass( "ui-state-hover" );
  4280. })
  4281. .bind( "mouseleave.accordion", function() {
  4282. if ( options.disabled ) {
  4283. return;
  4284. }
  4285. $( this ).removeClass( "ui-state-hover" );
  4286. })
  4287. .bind( "focus.accordion", function() {
  4288. if ( options.disabled ) {
  4289. return;
  4290. }
  4291. $( this ).addClass( "ui-state-focus" );
  4292. })
  4293. .bind( "blur.accordion", function() {
  4294. if ( options.disabled ) {
  4295. return;
  4296. }
  4297. $( this ).removeClass( "ui-state-focus" );
  4298. });
  4299. self.headers.next()
  4300. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
  4301. if ( options.navigation ) {
  4302. var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 );
  4303. if ( current.length ) {
  4304. var header = current.closest( ".ui-accordion-header" );
  4305. if ( header.length ) {
  4306. // anchor within header
  4307. self.active = header;
  4308. } else {
  4309. // anchor within content
  4310. self.active = current.closest( ".ui-accordion-content" ).prev();
  4311. }
  4312. }
  4313. }
  4314. self.active = self._findActive( self.active || options.active )
  4315. .addClass( "ui-state-default ui-state-active" )
  4316. .toggleClass( "ui-corner-all" )
  4317. .toggleClass( "ui-corner-top" );
  4318. self.active.next().addClass( "ui-accordion-content-active" );
  4319. self._createIcons();
  4320. self.resize();
  4321. // ARIA
  4322. self.element.attr( "role", "tablist" );
  4323. self.headers
  4324. .attr( "role", "tab" )
  4325. .bind( "keydown.accordion", function( event ) {
  4326. return self._keydown( event );
  4327. })
  4328. .next()
  4329. .attr( "role", "tabpanel" );
  4330. self.headers
  4331. .not( self.active || "" )
  4332. .attr({
  4333. "aria-expanded": "false",
  4334. "aria-selected": "false",
  4335. tabIndex: -1
  4336. })
  4337. .next()
  4338. .hide();
  4339. // make sure at least one header is in the tab order
  4340. if ( !self.active.length ) {
  4341. self.headers.eq( 0 ).attr( "tabIndex", 0 );
  4342. } else {
  4343. self.active
  4344. .attr({
  4345. "aria-expanded": "true",
  4346. "aria-selected": "true",
  4347. tabIndex: 0
  4348. });
  4349. }
  4350. // only need links in tab order for Safari
  4351. if ( !$.browser.safari ) {
  4352. self.headers.find( "a" ).attr( "tabIndex", -1 );
  4353. }
  4354. if ( options.event ) {
  4355. self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion", function(event) {
  4356. self._clickHandler.call( self, event, this );
  4357. event.preventDefault();
  4358. });
  4359. }
  4360. },
  4361. _createIcons: function() {
  4362. var options = this.options;
  4363. if ( options.icons ) {
  4364. $( "<span></span>" )
  4365. .addClass( "ui-icon " + options.icons.header )
  4366. .prependTo( this.headers );
  4367. this.active.children( ".ui-icon" )
  4368. .toggleClass(options.icons.header)
  4369. .toggleClass(options.icons.headerSelected);
  4370. this.element.addClass( "ui-accordion-icons" );
  4371. }
  4372. },
  4373. _destroyIcons: function() {
  4374. this.headers.children( ".ui-icon" ).remove();
  4375. this.element.removeClass( "ui-accordion-icons" );
  4376. },
  4377. destroy: function() {
  4378. var options = this.options;
  4379. this.element
  4380. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4381. .removeAttr( "role" );
  4382. this.headers
  4383. .unbind( ".accordion" )
  4384. .removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  4385. .removeAttr( "role" )
  4386. .removeAttr( "aria-expanded" )
  4387. .removeAttr( "aria-selected" )
  4388. .removeAttr( "tabIndex" );
  4389. this.headers.find( "a" ).removeAttr( "tabIndex" );
  4390. this._destroyIcons();
  4391. var contents = this.headers.next()
  4392. .css( "display", "" )
  4393. .removeAttr( "role" )
  4394. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
  4395. if ( options.autoHeight || options.fillHeight ) {
  4396. contents.css( "height", "" );
  4397. }
  4398. return $.Widget.prototype.destroy.call( this );
  4399. },
  4400. _setOption: function( key, value ) {
  4401. $.Widget.prototype._setOption.apply( this, arguments );
  4402. if ( key == "active" ) {
  4403. this.activate( value );
  4404. }
  4405. if ( key == "icons" ) {
  4406. this._destroyIcons();
  4407. if ( value ) {
  4408. this._createIcons();
  4409. }
  4410. }
  4411. // #5332 - opacity doesn't cascade to positioned elements in IE
  4412. // so we need to add the disabled class to the headers and panels
  4413. if ( key == "disabled" ) {
  4414. this.headers.add(this.headers.next())
  4415. [ value ? "addClass" : "removeClass" ](
  4416. "ui-accordion-disabled ui-state-disabled" );
  4417. }
  4418. },
  4419. _keydown: function( event ) {
  4420. if ( this.options.disabled || event.altKey || event.ctrlKey ) {
  4421. return;
  4422. }
  4423. var keyCode = $.ui.keyCode,
  4424. length = this.headers.length,
  4425. currentIndex = this.headers.index( event.target ),
  4426. toFocus = false;
  4427. switch ( event.keyCode ) {
  4428. case keyCode.RIGHT:
  4429. case keyCode.DOWN:
  4430. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4431. break;
  4432. case keyCode.LEFT:
  4433. case keyCode.UP:
  4434. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4435. break;
  4436. case keyCode.SPACE:
  4437. case keyCode.ENTER:
  4438. this._clickHandler( { target: event.target }, event.target );
  4439. event.preventDefault();
  4440. }
  4441. if ( toFocus ) {
  4442. $( event.target ).attr( "tabIndex", -1 );
  4443. $( toFocus ).attr( "tabIndex", 0 );
  4444. toFocus.focus();
  4445. return false;
  4446. }
  4447. return true;
  4448. },
  4449. resize: function() {
  4450. var options = this.options,
  4451. maxHeight;
  4452. if ( options.fillSpace ) {
  4453. if ( $.browser.msie ) {
  4454. var defOverflow = this.element.parent().css( "overflow" );
  4455. this.element.parent().css( "overflow", "hidden");
  4456. }
  4457. maxHeight = this.element.parent().height();
  4458. if ($.browser.msie) {
  4459. this.element.parent().css( "overflow", defOverflow );
  4460. }
  4461. this.headers.each(function() {
  4462. maxHeight -= $( this ).outerHeight( true );
  4463. });
  4464. this.headers.next()
  4465. .each(function() {
  4466. $( this ).height( Math.max( 0, maxHeight -
  4467. $( this ).innerHeight() + $( this ).height() ) );
  4468. })
  4469. .css( "overflow", "auto" );
  4470. } else if ( options.autoHeight ) {
  4471. maxHeight = 0;
  4472. this.headers.next()
  4473. .each(function() {
  4474. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  4475. })
  4476. .height( maxHeight );
  4477. }
  4478. return this;
  4479. },
  4480. activate: function( index ) {
  4481. // TODO this gets called on init, changing the option without an explicit call for that
  4482. this.options.active = index;
  4483. // call clickHandler with custom event
  4484. var active = this._findActive( index )[ 0 ];
  4485. this._clickHandler( { target: active }, active );
  4486. return this;
  4487. },
  4488. _findActive: function( selector ) {
  4489. return selector
  4490. ? typeof selector === "number"
  4491. ? this.headers.filter( ":eq(" + selector + ")" )
  4492. : this.headers.not( this.headers.not( selector ) )
  4493. : selector === false
  4494. ? $( [] )
  4495. : this.headers.filter( ":eq(0)" );
  4496. },
  4497. // TODO isn't event.target enough? why the separate target argument?
  4498. _clickHandler: function( event, target ) {
  4499. var options = this.options;
  4500. if ( options.disabled ) {
  4501. return;
  4502. }
  4503. // called only when using activate(false) to close all parts programmatically
  4504. if ( !event.target ) {
  4505. if ( !options.collapsible ) {
  4506. return;
  4507. }
  4508. this.active
  4509. .removeClass( "ui-state-active ui-corner-top" )
  4510. .addClass( "ui-state-default ui-corner-all" )
  4511. .children( ".ui-icon" )
  4512. .removeClass( options.icons.headerSelected )
  4513. .addClass( options.icons.header );
  4514. this.active.next().addClass( "ui-accordion-content-active" );
  4515. var toHide = this.active.next(),
  4516. data = {
  4517. options: options,
  4518. newHeader: $( [] ),
  4519. oldHeader: options.active,
  4520. newContent: $( [] ),
  4521. oldContent: toHide
  4522. },
  4523. toShow = ( this.active = $( [] ) );
  4524. this._toggle( toShow, toHide, data );
  4525. return;
  4526. }
  4527. // get the click target
  4528. var clicked = $( event.currentTarget || target ),
  4529. clickedIsActive = clicked[0] === this.active[0];
  4530. // TODO the option is changed, is that correct?
  4531. // TODO if it is correct, shouldn't that happen after determining that the click is valid?
  4532. options.active = options.collapsible && clickedIsActive ?
  4533. false :
  4534. this.headers.index( clicked );
  4535. // if animations are still active, or the active header is the target, ignore click
  4536. if ( this.running || ( !options.collapsible && clickedIsActive ) ) {
  4537. return;
  4538. }
  4539. // find elements to show and hide
  4540. var active = this.active,
  4541. toShow = clicked.next(),
  4542. toHide = this.active.next(),
  4543. data = {
  4544. options: options,
  4545. newHeader: clickedIsActive && options.collapsible ? $([]) : clicked,
  4546. oldHeader: this.active,
  4547. newContent: clickedIsActive && options.collapsible ? $([]) : toShow,
  4548. oldContent: toHide
  4549. },
  4550. down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
  4551. // when the call to ._toggle() comes after the class changes
  4552. // it causes a very odd bug in IE 8 (see #6720)
  4553. this.active = clickedIsActive ? $([]) : clicked;
  4554. this._toggle( toShow, toHide, data, clickedIsActive, down );
  4555. // switch classes
  4556. active
  4557. .removeClass( "ui-state-active ui-corner-top" )
  4558. .addClass( "ui-state-default ui-corner-all" )
  4559. .children( ".ui-icon" )
  4560. .removeClass( options.icons.headerSelected )
  4561. .addClass( options.icons.header );
  4562. if ( !clickedIsActive ) {
  4563. clicked
  4564. .removeClass( "ui-state-default ui-corner-all" )
  4565. .addClass( "ui-state-active ui-corner-top" )
  4566. .children( ".ui-icon" )
  4567. .removeClass( options.icons.header )
  4568. .addClass( options.icons.headerSelected );
  4569. clicked
  4570. .next()
  4571. .addClass( "ui-accordion-content-active" );
  4572. }
  4573. return;
  4574. },
  4575. _toggle: function( toShow, toHide, data, clickedIsActive, down ) {
  4576. var self = this,
  4577. options = self.options;
  4578. self.toShow = toShow;
  4579. self.toHide = toHide;
  4580. self.data = data;
  4581. var complete = function() {
  4582. if ( !self ) {
  4583. return;
  4584. }
  4585. return self._completed.apply( self, arguments );
  4586. };
  4587. // trigger changestart event
  4588. self._trigger( "changestart", null, self.data );
  4589. // count elements to animate
  4590. self.running = toHide.size() === 0 ? toShow.size() : toHide.size();
  4591. if ( options.animated ) {
  4592. var animOptions = {};
  4593. if ( options.collapsible && clickedIsActive ) {
  4594. animOptions = {
  4595. toShow: $( [] ),
  4596. toHide: toHide,
  4597. complete: complete,
  4598. down: down,
  4599. autoHeight: options.autoHeight || options.fillSpace
  4600. };
  4601. } else {
  4602. animOptions = {
  4603. toShow: toShow,
  4604. toHide: toHide,
  4605. complete: complete,
  4606. down: down,
  4607. autoHeight: options.autoHeight || options.fillSpace
  4608. };
  4609. }
  4610. if ( !options.proxied ) {
  4611. options.proxied = options.animated;
  4612. }
  4613. if ( !options.proxiedDuration ) {
  4614. options.proxiedDuration = options.duration;
  4615. }
  4616. options.animated = $.isFunction( options.proxied ) ?
  4617. options.proxied( animOptions ) :
  4618. options.proxied;
  4619. options.duration = $.isFunction( options.proxiedDuration ) ?
  4620. options.proxiedDuration( animOptions ) :
  4621. options.proxiedDuration;
  4622. var animations = $.ui.accordion.animations,
  4623. duration = options.duration,
  4624. easing = options.animated;
  4625. if ( easing && !animations[ easing ] && !$.easing[ easing ] ) {
  4626. easing = "slide";
  4627. }
  4628. if ( !animations[ easing ] ) {
  4629. animations[ easing ] = function( options ) {
  4630. this.slide( options, {
  4631. easing: easing,
  4632. duration: duration || 700
  4633. });
  4634. };
  4635. }
  4636. animations[ easing ]( animOptions );
  4637. } else {
  4638. if ( options.collapsible && clickedIsActive ) {
  4639. toShow.toggle();
  4640. } else {
  4641. toHide.hide();
  4642. toShow.show();
  4643. }
  4644. complete( true );
  4645. }
  4646. // TODO assert that the blur and focus triggers are really necessary, remove otherwise
  4647. toHide.prev()
  4648. .attr({
  4649. "aria-expanded": "false",
  4650. "aria-selected": "false",
  4651. tabIndex: -1
  4652. })
  4653. .blur();
  4654. toShow.prev()
  4655. .attr({
  4656. "aria-expanded": "true",
  4657. "aria-selected": "true",
  4658. tabIndex: 0
  4659. })
  4660. .focus();
  4661. },
  4662. _completed: function( cancel ) {
  4663. this.running = cancel ? 0 : --this.running;
  4664. if ( this.running ) {
  4665. return;
  4666. }
  4667. if ( this.options.clearStyle ) {
  4668. this.toShow.add( this.toHide ).css({
  4669. height: "",
  4670. overflow: ""
  4671. });
  4672. }
  4673. // other classes are removed before the animation; this one needs to stay until completed
  4674. this.toHide.removeClass( "ui-accordion-content-active" );
  4675. // Work around for rendering bug in IE (#5421)
  4676. if ( this.toHide.length ) {
  4677. this.toHide.parent()[0].className = this.toHide.parent()[0].className;
  4678. }
  4679. this._trigger( "change", null, this.data );
  4680. }
  4681. });
  4682. $.extend( $.ui.accordion, {
  4683. version: "1.8.24",
  4684. animations: {
  4685. slide: function( options, additions ) {
  4686. options = $.extend({
  4687. easing: "swing",
  4688. duration: 300
  4689. }, options, additions );
  4690. if ( !options.toHide.size() ) {
  4691. options.toShow.animate({
  4692. height: "show",
  4693. paddingTop: "show",
  4694. paddingBottom: "show"
  4695. }, options );
  4696. return;
  4697. }
  4698. if ( !options.toShow.size() ) {
  4699. options.toHide.animate({
  4700. height: "hide",
  4701. paddingTop: "hide",
  4702. paddingBottom: "hide"
  4703. }, options );
  4704. return;
  4705. }
  4706. var overflow = options.toShow.css( "overflow" ),
  4707. percentDone = 0,
  4708. showProps = {},
  4709. hideProps = {},
  4710. fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
  4711. originalWidth;
  4712. // fix width before calculating height of hidden element
  4713. var s = options.toShow;
  4714. originalWidth = s[0].style.width;
  4715. s.width( s.parent().width()
  4716. - parseFloat( s.css( "paddingLeft" ) )
  4717. - parseFloat( s.css( "paddingRight" ) )
  4718. - ( parseFloat( s.css( "borderLeftWidth" ) ) || 0 )
  4719. - ( parseFloat( s.css( "borderRightWidth" ) ) || 0 ) );
  4720. $.each( fxAttrs, function( i, prop ) {
  4721. hideProps[ prop ] = "hide";
  4722. var parts = ( "" + $.css( options.toShow[0], prop ) ).match( /^([\d+-.]+)(.*)$/ );
  4723. showProps[ prop ] = {
  4724. value: parts[ 1 ],
  4725. unit: parts[ 2 ] || "px"
  4726. };
  4727. });
  4728. options.toShow.css({ height: 0, overflow: "hidden" }).show();
  4729. options.toHide
  4730. .filter( ":hidden" )
  4731. .each( options.complete )
  4732. .end()
  4733. .filter( ":visible" )
  4734. .animate( hideProps, {
  4735. step: function( now, settings ) {
  4736. // only calculate the percent when animating height
  4737. // IE gets very inconsistent results when animating elements
  4738. // with small values, which is common for padding
  4739. if ( settings.prop == "height" ) {
  4740. percentDone = ( settings.end - settings.start === 0 ) ? 0 :
  4741. ( settings.now - settings.start ) / ( settings.end - settings.start );
  4742. }
  4743. options.toShow[ 0 ].style[ settings.prop ] =
  4744. ( percentDone * showProps[ settings.prop ].value )
  4745. + showProps[ settings.prop ].unit;
  4746. },
  4747. duration: options.duration,
  4748. easing: options.easing,
  4749. complete: function() {
  4750. if ( !options.autoHeight ) {
  4751. options.toShow.css( "height", "" );
  4752. }
  4753. options.toShow.css({
  4754. width: originalWidth,
  4755. overflow: overflow
  4756. });
  4757. options.complete();
  4758. }
  4759. });
  4760. },
  4761. bounceslide: function( options ) {
  4762. this.slide( options, {
  4763. easing: options.down ? "easeOutBounce" : "swing",
  4764. duration: options.down ? 1000 : 200
  4765. });
  4766. }
  4767. }
  4768. });
  4769. })( jQuery );
  4770. (function( $, undefined ) {
  4771. // used to prevent race conditions with remote data sources
  4772. var requestIndex = 0;
  4773. $.widget( "ui.autocomplete", {
  4774. options: {
  4775. appendTo: "body",
  4776. autoFocus: false,
  4777. delay: 300,
  4778. minLength: 1,
  4779. position: {
  4780. my: "left top",
  4781. at: "left bottom",
  4782. collision: "none"
  4783. },
  4784. source: null
  4785. },
  4786. pending: 0,
  4787. _create: function() {
  4788. var self = this,
  4789. doc = this.element[ 0 ].ownerDocument,
  4790. suppressKeyPress;
  4791. this.isMultiLine = this.element.is( "textarea" );
  4792. this.element
  4793. .addClass( "ui-autocomplete-input" )
  4794. .attr( "autocomplete", "off" )
  4795. // TODO verify these actually work as intended
  4796. .attr({
  4797. role: "textbox",
  4798. "aria-autocomplete": "list",
  4799. "aria-haspopup": "true"
  4800. })
  4801. .bind( "keydown.autocomplete", function( event ) {
  4802. if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
  4803. return;
  4804. }
  4805. suppressKeyPress = false;
  4806. var keyCode = $.ui.keyCode;
  4807. switch( event.keyCode ) {
  4808. case keyCode.PAGE_UP:
  4809. self._move( "previousPage", event );
  4810. break;
  4811. case keyCode.PAGE_DOWN:
  4812. self._move( "nextPage", event );
  4813. break;
  4814. case keyCode.UP:
  4815. self._keyEvent( "previous", event );
  4816. break;
  4817. case keyCode.DOWN:
  4818. self._keyEvent( "next", event );
  4819. break;
  4820. case keyCode.ENTER:
  4821. case keyCode.NUMPAD_ENTER:
  4822. // when menu is open and has focus
  4823. if ( self.menu.active ) {
  4824. // #6055 - Opera still allows the keypress to occur
  4825. // which causes forms to submit
  4826. suppressKeyPress = true;
  4827. event.preventDefault();
  4828. }
  4829. //passthrough - ENTER and TAB both select the current element
  4830. case keyCode.TAB:
  4831. if ( !self.menu.active ) {
  4832. return;
  4833. }
  4834. self.menu.select( event );
  4835. break;
  4836. case keyCode.ESCAPE:
  4837. self.element.val( self.term );
  4838. self.close( event );
  4839. break;
  4840. default:
  4841. // keypress is triggered before the input value is changed
  4842. clearTimeout( self.searching );
  4843. self.searching = setTimeout(function() {
  4844. // only search if the value has changed
  4845. if ( self.term != self.element.val() ) {
  4846. self.selectedItem = null;
  4847. self.search( null, event );
  4848. }
  4849. }, self.options.delay );
  4850. break;
  4851. }
  4852. })
  4853. .bind( "keypress.autocomplete", function( event ) {
  4854. if ( suppressKeyPress ) {
  4855. suppressKeyPress = false;
  4856. event.preventDefault();
  4857. }
  4858. })
  4859. .bind( "focus.autocomplete", function() {
  4860. if ( self.options.disabled ) {
  4861. return;
  4862. }
  4863. self.selectedItem = null;
  4864. self.previous = self.element.val();
  4865. })
  4866. .bind( "blur.autocomplete", function( event ) {
  4867. if ( self.options.disabled ) {
  4868. return;
  4869. }
  4870. clearTimeout( self.searching );
  4871. // clicks on the menu (or a button to trigger a search) will cause a blur event
  4872. self.closing = setTimeout(function() {
  4873. self.close( event );
  4874. self._change( event );
  4875. }, 150 );
  4876. });
  4877. this._initSource();
  4878. this.menu = $( "<ul></ul>" )
  4879. .addClass( "ui-autocomplete" )
  4880. .appendTo( $( this.options.appendTo || "body", doc )[0] )
  4881. // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
  4882. .mousedown(function( event ) {
  4883. // clicking on the scrollbar causes focus to shift to the body
  4884. // but we can't detect a mouseup or a click immediately afterward
  4885. // so we have to track the next mousedown and close the menu if
  4886. // the user clicks somewhere outside of the autocomplete
  4887. var menuElement = self.menu.element[ 0 ];
  4888. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  4889. setTimeout(function() {
  4890. $( document ).one( 'mousedown', function( event ) {
  4891. if ( event.target !== self.element[ 0 ] &&
  4892. event.target !== menuElement &&
  4893. !$.ui.contains( menuElement, event.target ) ) {
  4894. self.close();
  4895. }
  4896. });
  4897. }, 1 );
  4898. }
  4899. // use another timeout to make sure the blur-event-handler on the input was already triggered
  4900. setTimeout(function() {
  4901. clearTimeout( self.closing );
  4902. }, 13);
  4903. })
  4904. .menu({
  4905. focus: function( event, ui ) {
  4906. var item = ui.item.data( "item.autocomplete" );
  4907. if ( false !== self._trigger( "focus", event, { item: item } ) ) {
  4908. // use value to match what will end up in the input, if it was a key event
  4909. if ( /^key/.test(event.originalEvent.type) ) {
  4910. self.element.val( item.value );
  4911. }
  4912. }
  4913. },
  4914. selected: function( event, ui ) {
  4915. var item = ui.item.data( "item.autocomplete" ),
  4916. previous = self.previous;
  4917. // only trigger when focus was lost (click on menu)
  4918. if ( self.element[0] !== doc.activeElement ) {
  4919. self.element.focus();
  4920. self.previous = previous;
  4921. // #6109 - IE triggers two focus events and the second
  4922. // is asynchronous, so we need to reset the previous
  4923. // term synchronously and asynchronously :-(
  4924. setTimeout(function() {
  4925. self.previous = previous;
  4926. self.selectedItem = item;
  4927. }, 1);
  4928. }
  4929. if ( false !== self._trigger( "select", event, { item: item } ) ) {
  4930. self.element.val( item.value );
  4931. }
  4932. // reset the term after the select event
  4933. // this allows custom select handling to work properly
  4934. self.term = self.element.val();
  4935. self.close( event );
  4936. self.selectedItem = item;
  4937. },
  4938. blur: function( event, ui ) {
  4939. // don't set the value of the text field if it's already correct
  4940. // this prevents moving the cursor unnecessarily
  4941. if ( self.menu.element.is(":visible") &&
  4942. ( self.element.val() !== self.term ) ) {
  4943. self.element.val( self.term );
  4944. }
  4945. }
  4946. })
  4947. .zIndex( this.element.zIndex() + 1 )
  4948. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  4949. .css({ top: 0, left: 0 })
  4950. .hide()
  4951. .data( "menu" );
  4952. if ( $.fn.bgiframe ) {
  4953. this.menu.element.bgiframe();
  4954. }
  4955. // turning off autocomplete prevents the browser from remembering the
  4956. // value when navigating through history, so we re-enable autocomplete
  4957. // if the page is unloaded before the widget is destroyed. #7790
  4958. self.beforeunloadHandler = function() {
  4959. self.element.removeAttr( "autocomplete" );
  4960. };
  4961. $( window ).bind( "beforeunload", self.beforeunloadHandler );
  4962. },
  4963. destroy: function() {
  4964. this.element
  4965. .removeClass( "ui-autocomplete-input" )
  4966. .removeAttr( "autocomplete" )
  4967. .removeAttr( "role" )
  4968. .removeAttr( "aria-autocomplete" )
  4969. .removeAttr( "aria-haspopup" );
  4970. this.menu.element.remove();
  4971. $( window ).unbind( "beforeunload", this.beforeunloadHandler );
  4972. $.Widget.prototype.destroy.call( this );
  4973. },
  4974. _setOption: function( key, value ) {
  4975. $.Widget.prototype._setOption.apply( this, arguments );
  4976. if ( key === "source" ) {
  4977. this._initSource();
  4978. }
  4979. if ( key === "appendTo" ) {
  4980. this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
  4981. }
  4982. if ( key === "disabled" && value && this.xhr ) {
  4983. this.xhr.abort();
  4984. }
  4985. },
  4986. _initSource: function() {
  4987. var self = this,
  4988. array,
  4989. url;
  4990. if ( $.isArray(this.options.source) ) {
  4991. array = this.options.source;
  4992. this.source = function( request, response ) {
  4993. response( $.ui.autocomplete.filter(array, request.term) );
  4994. };
  4995. } else if ( typeof this.options.source === "string" ) {
  4996. url = this.options.source;
  4997. this.source = function( request, response ) {
  4998. if ( self.xhr ) {
  4999. self.xhr.abort();
  5000. }
  5001. self.xhr = $.ajax({
  5002. url: url,
  5003. data: request,
  5004. dataType: "json",
  5005. success: function( data, status ) {
  5006. response( data );
  5007. },
  5008. error: function() {
  5009. response( [] );
  5010. }
  5011. });
  5012. };
  5013. } else {
  5014. this.source = this.options.source;
  5015. }
  5016. },
  5017. search: function( value, event ) {
  5018. value = value != null ? value : this.element.val();
  5019. // always save the actual value, not the one passed as an argument
  5020. this.term = this.element.val();
  5021. if ( value.length < this.options.minLength ) {
  5022. return this.close( event );
  5023. }
  5024. clearTimeout( this.closing );
  5025. if ( this._trigger( "search", event ) === false ) {
  5026. return;
  5027. }
  5028. return this._search( value );
  5029. },
  5030. _search: function( value ) {
  5031. this.pending++;
  5032. this.element.addClass( "ui-autocomplete-loading" );
  5033. this.source( { term: value }, this._response() );
  5034. },
  5035. _response: function() {
  5036. var that = this,
  5037. index = ++requestIndex;
  5038. return function( content ) {
  5039. if ( index === requestIndex ) {
  5040. that.__response( content );
  5041. }
  5042. that.pending--;
  5043. if ( !that.pending ) {
  5044. that.element.removeClass( "ui-autocomplete-loading" );
  5045. }
  5046. };
  5047. },
  5048. __response: function( content ) {
  5049. if ( !this.options.disabled && content && content.length ) {
  5050. content = this._normalize( content );
  5051. this._suggest( content );
  5052. this._trigger( "open" );
  5053. } else {
  5054. this.close();
  5055. }
  5056. },
  5057. close: function( event ) {
  5058. clearTimeout( this.closing );
  5059. if ( this.menu.element.is(":visible") ) {
  5060. this.menu.element.hide();
  5061. this.menu.deactivate();
  5062. this._trigger( "close", event );
  5063. }
  5064. },
  5065. _change: function( event ) {
  5066. if ( this.previous !== this.element.val() ) {
  5067. this._trigger( "change", event, { item: this.selectedItem } );
  5068. }
  5069. },
  5070. _normalize: function( items ) {
  5071. // assume all items have the right format when the first item is complete
  5072. if ( items.length && items[0].label && items[0].value ) {
  5073. return items;
  5074. }
  5075. return $.map( items, function(item) {
  5076. if ( typeof item === "string" ) {
  5077. return {
  5078. label: item,
  5079. value: item
  5080. };
  5081. }
  5082. return $.extend({
  5083. label: item.label || item.value,
  5084. value: item.value || item.label
  5085. }, item );
  5086. });
  5087. },
  5088. _suggest: function( items ) {
  5089. var ul = this.menu.element
  5090. .empty()
  5091. .zIndex( this.element.zIndex() + 1 );
  5092. this._renderMenu( ul, items );
  5093. // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
  5094. this.menu.deactivate();
  5095. this.menu.refresh();
  5096. // size and position menu
  5097. ul.show();
  5098. this._resizeMenu();
  5099. ul.position( $.extend({
  5100. of: this.element
  5101. }, this.options.position ));
  5102. if ( this.options.autoFocus ) {
  5103. this.menu.next( new $.Event("mouseover") );
  5104. }
  5105. },
  5106. _resizeMenu: function() {
  5107. var ul = this.menu.element;
  5108. ul.outerWidth( Math.max(
  5109. // Firefox wraps long text (possibly a rounding bug)
  5110. // so we add 1px to avoid the wrapping (#7513)
  5111. ul.width( "" ).outerWidth() + 1,
  5112. this.element.outerWidth()
  5113. ) );
  5114. },
  5115. _renderMenu: function( ul, items ) {
  5116. var self = this;
  5117. $.each( items, function( index, item ) {
  5118. self._renderItem( ul, item );
  5119. });
  5120. },
  5121. _renderItem: function( ul, item) {
  5122. return $( "<li></li>" )
  5123. .data( "item.autocomplete", item )
  5124. .append( $( "<a></a>" ).text( item.label ) )
  5125. .appendTo( ul );
  5126. },
  5127. _move: function( direction, event ) {
  5128. if ( !this.menu.element.is(":visible") ) {
  5129. this.search( null, event );
  5130. return;
  5131. }
  5132. if ( this.menu.first() && /^previous/.test(direction) ||
  5133. this.menu.last() && /^next/.test(direction) ) {
  5134. this.element.val( this.term );
  5135. this.menu.deactivate();
  5136. return;
  5137. }
  5138. this.menu[ direction ]( event );
  5139. },
  5140. widget: function() {
  5141. return this.menu.element;
  5142. },
  5143. _keyEvent: function( keyEvent, event ) {
  5144. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5145. this._move( keyEvent, event );
  5146. // prevents moving cursor to beginning/end of the text field in some browsers
  5147. event.preventDefault();
  5148. }
  5149. }
  5150. });
  5151. $.extend( $.ui.autocomplete, {
  5152. escapeRegex: function( value ) {
  5153. return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  5154. },
  5155. filter: function(array, term) {
  5156. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  5157. return $.grep( array, function(value) {
  5158. return matcher.test( value.label || value.value || value );
  5159. });
  5160. }
  5161. });
  5162. }( jQuery ));
  5163. /*
  5164. * jQuery UI Menu (not officially released)
  5165. *
  5166. * This widget isn't yet finished and the API is subject to change. We plan to finish
  5167. * it for the next release. You're welcome to give it a try anyway and give us feedback,
  5168. * as long as you're okay with migrating your code later on. We can help with that, too.
  5169. *
  5170. * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
  5171. * Licensed under the MIT license.
  5172. * http://jquery.org/license
  5173. *
  5174. * http://docs.jquery.com/UI/Menu
  5175. *
  5176. * Depends:
  5177. * jquery.ui.core.js
  5178. * jquery.ui.widget.js
  5179. */
  5180. (function($) {
  5181. $.widget("ui.menu", {
  5182. _create: function() {
  5183. var self = this;
  5184. this.element
  5185. .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
  5186. .attr({
  5187. role: "listbox",
  5188. "aria-activedescendant": "ui-active-menuitem"
  5189. })
  5190. .click(function( event ) {
  5191. if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
  5192. return;
  5193. }
  5194. // temporary
  5195. event.preventDefault();
  5196. self.select( event );
  5197. });
  5198. this.refresh();
  5199. },
  5200. refresh: function() {
  5201. var self = this;
  5202. // don't refresh list items that are already adapted
  5203. var items = this.element.children("li:not(.ui-menu-item):has(a)")
  5204. .addClass("ui-menu-item")
  5205. .attr("role", "menuitem");
  5206. items.children("a")
  5207. .addClass("ui-corner-all")
  5208. .attr("tabindex", -1)
  5209. // mouseenter doesn't work with event delegation
  5210. .mouseenter(function( event ) {
  5211. self.activate( event, $(this).parent() );
  5212. })
  5213. .mouseleave(function() {
  5214. self.deactivate();
  5215. });
  5216. },
  5217. activate: function( event, item ) {
  5218. this.deactivate();
  5219. if (this.hasScroll()) {
  5220. var offset = item.offset().top - this.element.offset().top,
  5221. scroll = this.element.scrollTop(),
  5222. elementHeight = this.element.height();
  5223. if (offset < 0) {
  5224. this.element.scrollTop( scroll + offset);
  5225. } else if (offset >= elementHeight) {
  5226. this.element.scrollTop( scroll + offset - elementHeight + item.height());
  5227. }
  5228. }
  5229. this.active = item.eq(0)
  5230. .children("a")
  5231. .addClass("ui-state-hover")
  5232. .attr("id", "ui-active-menuitem")
  5233. .end();
  5234. this._trigger("focus", event, { item: item });
  5235. },
  5236. deactivate: function() {
  5237. if (!this.active) { return; }
  5238. this.active.children("a")
  5239. .removeClass("ui-state-hover")
  5240. .removeAttr("id");
  5241. this._trigger("blur");
  5242. this.active = null;
  5243. },
  5244. next: function(event) {
  5245. this.move("next", ".ui-menu-item:first", event);
  5246. },
  5247. previous: function(event) {
  5248. this.move("prev", ".ui-menu-item:last", event);
  5249. },
  5250. first: function() {
  5251. return this.active && !this.active.prevAll(".ui-menu-item").length;
  5252. },
  5253. last: function() {
  5254. return this.active && !this.active.nextAll(".ui-menu-item").length;
  5255. },
  5256. move: function(direction, edge, event) {
  5257. if (!this.active) {
  5258. this.activate(event, this.element.children(edge));
  5259. return;
  5260. }
  5261. var next = this.active[direction + "All"](".ui-menu-item").eq(0);
  5262. if (next.length) {
  5263. this.activate(event, next);
  5264. } else {
  5265. this.activate(event, this.element.children(edge));
  5266. }
  5267. },
  5268. // TODO merge with previousPage
  5269. nextPage: function(event) {
  5270. if (this.hasScroll()) {
  5271. // TODO merge with no-scroll-else
  5272. if (!this.active || this.last()) {
  5273. this.activate(event, this.element.children(".ui-menu-item:first"));
  5274. return;
  5275. }
  5276. var base = this.active.offset().top,
  5277. height = this.element.height(),
  5278. result = this.element.children(".ui-menu-item").filter(function() {
  5279. var close = $(this).offset().top - base - height + $(this).height();
  5280. // TODO improve approximation
  5281. return close < 10 && close > -10;
  5282. });
  5283. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  5284. if (!result.length) {
  5285. result = this.element.children(".ui-menu-item:last");
  5286. }
  5287. this.activate(event, result);
  5288. } else {
  5289. this.activate(event, this.element.children(".ui-menu-item")
  5290. .filter(!this.active || this.last() ? ":first" : ":last"));
  5291. }
  5292. },
  5293. // TODO merge with nextPage
  5294. previousPage: function(event) {
  5295. if (this.hasScroll()) {
  5296. // TODO merge with no-scroll-else
  5297. if (!this.active || this.first()) {
  5298. this.activate(event, this.element.children(".ui-menu-item:last"));
  5299. return;
  5300. }
  5301. var base = this.active.offset().top,
  5302. height = this.element.height(),
  5303. result = this.element.children(".ui-menu-item").filter(function() {
  5304. var close = $(this).offset().top - base + height - $(this).height();
  5305. // TODO improve approximation
  5306. return close < 10 && close > -10;
  5307. });
  5308. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  5309. if (!result.length) {
  5310. result = this.element.children(".ui-menu-item:first");
  5311. }
  5312. this.activate(event, result);
  5313. } else {
  5314. this.activate(event, this.element.children(".ui-menu-item")
  5315. .filter(!this.active || this.first() ? ":last" : ":first"));
  5316. }
  5317. },
  5318. hasScroll: function() {
  5319. return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
  5320. },
  5321. select: function( event ) {
  5322. this._trigger("selected", event, { item: this.active });
  5323. }
  5324. });
  5325. }(jQuery));
  5326. (function( $, undefined ) {
  5327. var lastActive, startXPos, startYPos, clickDragged,
  5328. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  5329. stateClasses = "ui-state-hover ui-state-active ",
  5330. 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",
  5331. formResetHandler = function() {
  5332. var buttons = $( this ).find( ":ui-button" );
  5333. setTimeout(function() {
  5334. buttons.button( "refresh" );
  5335. }, 1 );
  5336. },
  5337. radioGroup = function( radio ) {
  5338. var name = radio.name,
  5339. form = radio.form,
  5340. radios = $( [] );
  5341. if ( name ) {
  5342. if ( form ) {
  5343. radios = $( form ).find( "[name='" + name + "']" );
  5344. } else {
  5345. radios = $( "[name='" + name + "']", radio.ownerDocument )
  5346. .filter(function() {
  5347. return !this.form;
  5348. });
  5349. }
  5350. }
  5351. return radios;
  5352. };
  5353. $.widget( "ui.button", {
  5354. options: {
  5355. disabled: null,
  5356. text: true,
  5357. label: null,
  5358. icons: {
  5359. primary: null,
  5360. secondary: null
  5361. }
  5362. },
  5363. _create: function() {
  5364. this.element.closest( "form" )
  5365. .unbind( "reset.button" )
  5366. .bind( "reset.button", formResetHandler );
  5367. if ( typeof this.options.disabled !== "boolean" ) {
  5368. this.options.disabled = !!this.element.propAttr( "disabled" );
  5369. } else {
  5370. this.element.propAttr( "disabled", this.options.disabled );
  5371. }
  5372. this._determineButtonType();
  5373. this.hasTitle = !!this.buttonElement.attr( "title" );
  5374. var self = this,
  5375. options = this.options,
  5376. toggleButton = this.type === "checkbox" || this.type === "radio",
  5377. hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
  5378. focusClass = "ui-state-focus";
  5379. if ( options.label === null ) {
  5380. options.label = this.buttonElement.html();
  5381. }
  5382. this.buttonElement
  5383. .addClass( baseClasses )
  5384. .attr( "role", "button" )
  5385. .bind( "mouseenter.button", function() {
  5386. if ( options.disabled ) {
  5387. return;
  5388. }
  5389. $( this ).addClass( "ui-state-hover" );
  5390. if ( this === lastActive ) {
  5391. $( this ).addClass( "ui-state-active" );
  5392. }
  5393. })
  5394. .bind( "mouseleave.button", function() {
  5395. if ( options.disabled ) {
  5396. return;
  5397. }
  5398. $( this ).removeClass( hoverClass );
  5399. })
  5400. .bind( "click.button", function( event ) {
  5401. if ( options.disabled ) {
  5402. event.preventDefault();
  5403. event.stopImmediatePropagation();
  5404. }
  5405. });
  5406. this.element
  5407. .bind( "focus.button", function() {
  5408. // no need to check disabled, focus won't be triggered anyway
  5409. self.buttonElement.addClass( focusClass );
  5410. })
  5411. .bind( "blur.button", function() {
  5412. self.buttonElement.removeClass( focusClass );
  5413. });
  5414. if ( toggleButton ) {
  5415. this.element.bind( "change.button", function() {
  5416. if ( clickDragged ) {
  5417. return;
  5418. }
  5419. self.refresh();
  5420. });
  5421. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  5422. // prevents issue where button state changes but checkbox/radio checked state
  5423. // does not in Firefox (see ticket #6970)
  5424. this.buttonElement
  5425. .bind( "mousedown.button", function( event ) {
  5426. if ( options.disabled ) {
  5427. return;
  5428. }
  5429. clickDragged = false;
  5430. startXPos = event.pageX;
  5431. startYPos = event.pageY;
  5432. })
  5433. .bind( "mouseup.button", function( event ) {
  5434. if ( options.disabled ) {
  5435. return;
  5436. }
  5437. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  5438. clickDragged = true;
  5439. }
  5440. });
  5441. }
  5442. if ( this.type === "checkbox" ) {
  5443. this.buttonElement.bind( "click.button", function() {
  5444. if ( options.disabled || clickDragged ) {
  5445. return false;
  5446. }
  5447. $( this ).toggleClass( "ui-state-active" );
  5448. self.buttonElement.attr( "aria-pressed", self.element[0].checked );
  5449. });
  5450. } else if ( this.type === "radio" ) {
  5451. this.buttonElement.bind( "click.button", function() {
  5452. if ( options.disabled || clickDragged ) {
  5453. return false;
  5454. }
  5455. $( this ).addClass( "ui-state-active" );
  5456. self.buttonElement.attr( "aria-pressed", "true" );
  5457. var radio = self.element[ 0 ];
  5458. radioGroup( radio )
  5459. .not( radio )
  5460. .map(function() {
  5461. return $( this ).button( "widget" )[ 0 ];
  5462. })
  5463. .removeClass( "ui-state-active" )
  5464. .attr( "aria-pressed", "false" );
  5465. });
  5466. } else {
  5467. this.buttonElement
  5468. .bind( "mousedown.button", function() {
  5469. if ( options.disabled ) {
  5470. return false;
  5471. }
  5472. $( this ).addClass( "ui-state-active" );
  5473. lastActive = this;
  5474. $( document ).one( "mouseup", function() {
  5475. lastActive = null;
  5476. });
  5477. })
  5478. .bind( "mouseup.button", function() {
  5479. if ( options.disabled ) {
  5480. return false;
  5481. }
  5482. $( this ).removeClass( "ui-state-active" );
  5483. })
  5484. .bind( "keydown.button", function(event) {
  5485. if ( options.disabled ) {
  5486. return false;
  5487. }
  5488. if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
  5489. $( this ).addClass( "ui-state-active" );
  5490. }
  5491. })
  5492. .bind( "keyup.button", function() {
  5493. $( this ).removeClass( "ui-state-active" );
  5494. });
  5495. if ( this.buttonElement.is("a") ) {
  5496. this.buttonElement.keyup(function(event) {
  5497. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5498. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  5499. $( this ).click();
  5500. }
  5501. });
  5502. }
  5503. }
  5504. // TODO: pull out $.Widget's handling for the disabled option into
  5505. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  5506. // be overridden by individual plugins
  5507. this._setOption( "disabled", options.disabled );
  5508. this._resetButton();
  5509. },
  5510. _determineButtonType: function() {
  5511. if ( this.element.is(":checkbox") ) {
  5512. this.type = "checkbox";
  5513. } else if ( this.element.is(":radio") ) {
  5514. this.type = "radio";
  5515. } else if ( this.element.is("input") ) {
  5516. this.type = "input";
  5517. } else {
  5518. this.type = "button";
  5519. }
  5520. if ( this.type === "checkbox" || this.type === "radio" ) {
  5521. // we don't search against the document in case the element
  5522. // is disconnected from the DOM
  5523. var ancestor = this.element.parents().filter(":last"),
  5524. labelSelector = "label[for='" + this.element.attr("id") + "']";
  5525. this.buttonElement = ancestor.find( labelSelector );
  5526. if ( !this.buttonElement.length ) {
  5527. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  5528. this.buttonElement = ancestor.filter( labelSelector );
  5529. if ( !this.buttonElement.length ) {
  5530. this.buttonElement = ancestor.find( labelSelector );
  5531. }
  5532. }
  5533. this.element.addClass( "ui-helper-hidden-accessible" );
  5534. var checked = this.element.is( ":checked" );
  5535. if ( checked ) {
  5536. this.buttonElement.addClass( "ui-state-active" );
  5537. }
  5538. this.buttonElement.attr( "aria-pressed", checked );
  5539. } else {
  5540. this.buttonElement = this.element;
  5541. }
  5542. },
  5543. widget: function() {
  5544. return this.buttonElement;
  5545. },
  5546. destroy: function() {
  5547. this.element
  5548. .removeClass( "ui-helper-hidden-accessible" );
  5549. this.buttonElement
  5550. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  5551. .removeAttr( "role" )
  5552. .removeAttr( "aria-pressed" )
  5553. .html( this.buttonElement.find(".ui-button-text").html() );
  5554. if ( !this.hasTitle ) {
  5555. this.buttonElement.removeAttr( "title" );
  5556. }
  5557. $.Widget.prototype.destroy.call( this );
  5558. },
  5559. _setOption: function( key, value ) {
  5560. $.Widget.prototype._setOption.apply( this, arguments );
  5561. if ( key === "disabled" ) {
  5562. if ( value ) {
  5563. this.element.propAttr( "disabled", true );
  5564. } else {
  5565. this.element.propAttr( "disabled", false );
  5566. }
  5567. return;
  5568. }
  5569. this._resetButton();
  5570. },
  5571. refresh: function() {
  5572. var isDisabled = this.element.is( ":disabled" );
  5573. if ( isDisabled !== this.options.disabled ) {
  5574. this._setOption( "disabled", isDisabled );
  5575. }
  5576. if ( this.type === "radio" ) {
  5577. radioGroup( this.element[0] ).each(function() {
  5578. if ( $( this ).is( ":checked" ) ) {
  5579. $( this ).button( "widget" )
  5580. .addClass( "ui-state-active" )
  5581. .attr( "aria-pressed", "true" );
  5582. } else {
  5583. $( this ).button( "widget" )
  5584. .removeClass( "ui-state-active" )
  5585. .attr( "aria-pressed", "false" );
  5586. }
  5587. });
  5588. } else if ( this.type === "checkbox" ) {
  5589. if ( this.element.is( ":checked" ) ) {
  5590. this.buttonElement
  5591. .addClass( "ui-state-active" )
  5592. .attr( "aria-pressed", "true" );
  5593. } else {
  5594. this.buttonElement
  5595. .removeClass( "ui-state-active" )
  5596. .attr( "aria-pressed", "false" );
  5597. }
  5598. }
  5599. },
  5600. _resetButton: function() {
  5601. if ( this.type === "input" ) {
  5602. if ( this.options.label ) {
  5603. this.element.val( this.options.label );
  5604. }
  5605. return;
  5606. }
  5607. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  5608. buttonText = $( "<span></span>", this.element[0].ownerDocument )
  5609. .addClass( "ui-button-text" )
  5610. .html( this.options.label )
  5611. .appendTo( buttonElement.empty() )
  5612. .text(),
  5613. icons = this.options.icons,
  5614. multipleIcons = icons.primary && icons.secondary,
  5615. buttonClasses = [];
  5616. if ( icons.primary || icons.secondary ) {
  5617. if ( this.options.text ) {
  5618. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  5619. }
  5620. if ( icons.primary ) {
  5621. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  5622. }
  5623. if ( icons.secondary ) {
  5624. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  5625. }
  5626. if ( !this.options.text ) {
  5627. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  5628. if ( !this.hasTitle ) {
  5629. buttonElement.attr( "title", buttonText );
  5630. }
  5631. }
  5632. } else {
  5633. buttonClasses.push( "ui-button-text-only" );
  5634. }
  5635. buttonElement.addClass( buttonClasses.join( " " ) );
  5636. }
  5637. });
  5638. $.widget( "ui.buttonset", {
  5639. options: {
  5640. items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
  5641. },
  5642. _create: function() {
  5643. this.element.addClass( "ui-buttonset" );
  5644. },
  5645. _init: function() {
  5646. this.refresh();
  5647. },
  5648. _setOption: function( key, value ) {
  5649. if ( key === "disabled" ) {
  5650. this.buttons.button( "option", key, value );
  5651. }
  5652. $.Widget.prototype._setOption.apply( this, arguments );
  5653. },
  5654. refresh: function() {
  5655. var rtl = this.element.css( "direction" ) === "rtl";
  5656. this.buttons = this.element.find( this.options.items )
  5657. .filter( ":ui-button" )
  5658. .button( "refresh" )
  5659. .end()
  5660. .not( ":ui-button" )
  5661. .button()
  5662. .end()
  5663. .map(function() {
  5664. return $( this ).button( "widget" )[ 0 ];
  5665. })
  5666. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  5667. .filter( ":first" )
  5668. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  5669. .end()
  5670. .filter( ":last" )
  5671. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  5672. .end()
  5673. .end();
  5674. },
  5675. destroy: function() {
  5676. this.element.removeClass( "ui-buttonset" );
  5677. this.buttons
  5678. .map(function() {
  5679. return $( this ).button( "widget" )[ 0 ];
  5680. })
  5681. .removeClass( "ui-corner-left ui-corner-right" )
  5682. .end()
  5683. .button( "destroy" );
  5684. $.Widget.prototype.destroy.call( this );
  5685. }
  5686. });
  5687. }( jQuery ) );
  5688. (function( $, undefined ) {
  5689. $.extend($.ui, { datepicker: { version: "1.8.24" } });
  5690. var PROP_NAME = 'datepicker';
  5691. var dpuuid = new Date().getTime();
  5692. var instActive;
  5693. /* Date picker manager.
  5694. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  5695. Settings for (groups of) date pickers are maintained in an instance object,
  5696. allowing multiple different settings on the same page. */
  5697. function Datepicker() {
  5698. this.debug = false; // Change this to true to start debugging
  5699. this._curInst = null; // The current instance in use
  5700. this._keyEvent = false; // If the last event was a key event
  5701. this._disabledInputs = []; // List of date picker inputs that have been disabled
  5702. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  5703. this._inDialog = false; // True if showing within a "dialog", false if not
  5704. this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
  5705. this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
  5706. this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
  5707. this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
  5708. this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
  5709. this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
  5710. this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
  5711. this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
  5712. this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
  5713. this.regional = []; // Available regional settings, indexed by language code
  5714. this.regional[''] = { // Default regional settings
  5715. closeText: 'Done', // Display text for close link
  5716. prevText: 'Prev', // Display text for previous month link
  5717. nextText: 'Next', // Display text for next month link
  5718. currentText: 'Today', // Display text for current month link
  5719. monthNames: ['January','February','March','April','May','June',
  5720. 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
  5721. monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
  5722. dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
  5723. dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
  5724. dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
  5725. weekHeader: 'Wk', // Column header for week of the year
  5726. dateFormat: 'mm/dd/yy', // See format options on parseDate
  5727. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  5728. isRTL: false, // True if right-to-left language, false if left-to-right
  5729. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  5730. yearSuffix: '' // Additional text to append to the year in the month headers
  5731. };
  5732. this._defaults = { // Global defaults for all the date picker instances
  5733. showOn: 'focus', // 'focus' for popup on focus,
  5734. // 'button' for trigger button, or 'both' for either
  5735. showAnim: 'fadeIn', // Name of jQuery animation for popup
  5736. showOptions: {}, // Options for enhanced animations
  5737. defaultDate: null, // Used when field is blank: actual date,
  5738. // +/-number for offset from today, null for today
  5739. appendText: '', // Display text following the input box, e.g. showing the format
  5740. buttonText: '...', // Text for trigger button
  5741. buttonImage: '', // URL for trigger button image
  5742. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  5743. hideIfNoPrevNext: false, // True to hide next/previous month links
  5744. // if not applicable, false to just disable them
  5745. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  5746. gotoCurrent: false, // True if today link goes back to current selection instead
  5747. changeMonth: false, // True if month can be selected directly, false if only prev/next
  5748. changeYear: false, // True if year can be selected directly, false if only prev/next
  5749. yearRange: 'c-10:c+10', // Range of years to display in drop-down,
  5750. // either relative to today's year (-nn:+nn), relative to currently displayed year
  5751. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  5752. showOtherMonths: false, // True to show dates in other months, false to leave blank
  5753. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  5754. showWeek: false, // True to show week of the year, false to not show it
  5755. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  5756. // takes a Date and returns the number of the week for it
  5757. shortYearCutoff: '+10', // Short year values < this are in the current century,
  5758. // > this are in the previous century,
  5759. // string value starting with '+' for current year + value
  5760. minDate: null, // The earliest selectable date, or null for no limit
  5761. maxDate: null, // The latest selectable date, or null for no limit
  5762. duration: 'fast', // Duration of display/closure
  5763. beforeShowDay: null, // Function that takes a date and returns an array with
  5764. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
  5765. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  5766. beforeShow: null, // Function that takes an input field and
  5767. // returns a set of custom settings for the date picker
  5768. onSelect: null, // Define a callback function when a date is selected
  5769. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  5770. onClose: null, // Define a callback function when the datepicker is closed
  5771. numberOfMonths: 1, // Number of months to show at a time
  5772. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  5773. stepMonths: 1, // Number of months to step back/forward
  5774. stepBigMonths: 12, // Number of months to step back/forward for the big links
  5775. altField: '', // Selector for an alternate field to store selected dates into
  5776. altFormat: '', // The date format to use for the alternate field
  5777. constrainInput: true, // The input is constrained by the current date format
  5778. showButtonPanel: false, // True to show button panel, false to not show it
  5779. autoSize: false, // True to size the input for the date format, false to leave as is
  5780. disabled: false // The initial disabled state
  5781. };
  5782. $.extend(this._defaults, this.regional['']);
  5783. this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
  5784. }
  5785. $.extend(Datepicker.prototype, {
  5786. /* Class name added to elements to indicate already configured with a date picker. */
  5787. markerClassName: 'hasDatepicker',
  5788. //Keep track of the maximum number of rows displayed (see #7043)
  5789. maxRows: 4,
  5790. /* Debug logging (if enabled). */
  5791. log: function () {
  5792. if (this.debug)
  5793. console.log.apply('', arguments);
  5794. },
  5795. // TODO rename to "widget" when switching to widget factory
  5796. _widgetDatepicker: function() {
  5797. return this.dpDiv;
  5798. },
  5799. /* Override the default settings for all instances of the date picker.
  5800. @param settings object - the new settings to use as defaults (anonymous object)
  5801. @return the manager object */
  5802. setDefaults: function(settings) {
  5803. extendRemove(this._defaults, settings || {});
  5804. return this;
  5805. },
  5806. /* Attach the date picker to a jQuery selection.
  5807. @param target element - the target input field or division or span
  5808. @param settings object - the new settings to use for this date picker instance (anonymous) */
  5809. _attachDatepicker: function(target, settings) {
  5810. // check for settings on the control itself - in namespace 'date:'
  5811. var inlineSettings = null;
  5812. for (var attrName in this._defaults) {
  5813. var attrValue = target.getAttribute('date:' + attrName);
  5814. if (attrValue) {
  5815. inlineSettings = inlineSettings || {};
  5816. try {
  5817. inlineSettings[attrName] = eval(attrValue);
  5818. } catch (err) {
  5819. inlineSettings[attrName] = attrValue;
  5820. }
  5821. }
  5822. }
  5823. var nodeName = target.nodeName.toLowerCase();
  5824. var inline = (nodeName == 'div' || nodeName == 'span');
  5825. if (!target.id) {
  5826. this.uuid += 1;
  5827. target.id = 'dp' + this.uuid;
  5828. }
  5829. var inst = this._newInst($(target), inline);
  5830. inst.settings = $.extend({}, settings || {}, inlineSettings || {});
  5831. if (nodeName == 'input') {
  5832. this._connectDatepicker(target, inst);
  5833. } else if (inline) {
  5834. this._inlineDatepicker(target, inst);
  5835. }
  5836. },
  5837. /* Create a new instance object. */
  5838. _newInst: function(target, inline) {
  5839. var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
  5840. return {id: id, input: target, // associated target
  5841. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  5842. drawMonth: 0, drawYear: 0, // month being drawn
  5843. inline: inline, // is datepicker inline or not
  5844. dpDiv: (!inline ? this.dpDiv : // presentation div
  5845. bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
  5846. },
  5847. /* Attach the date picker to an input field. */
  5848. _connectDatepicker: function(target, inst) {
  5849. var input = $(target);
  5850. inst.append = $([]);
  5851. inst.trigger = $([]);
  5852. if (input.hasClass(this.markerClassName))
  5853. return;
  5854. this._attachments(input, inst);
  5855. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  5856. keypress(this._doKeyPress).keyup(this._doKeyUp).
  5857. bind("setData.datepicker", function(event, key, value) {
  5858. inst.settings[key] = value;
  5859. }).bind("getData.datepicker", function(event, key) {
  5860. return this._get(inst, key);
  5861. });
  5862. this._autoSize(inst);
  5863. $.data(target, PROP_NAME, inst);
  5864. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  5865. if( inst.settings.disabled ) {
  5866. this._disableDatepicker( target );
  5867. }
  5868. },
  5869. /* Make attachments based on settings. */
  5870. _attachments: function(input, inst) {
  5871. var appendText = this._get(inst, 'appendText');
  5872. var isRTL = this._get(inst, 'isRTL');
  5873. if (inst.append)
  5874. inst.append.remove();
  5875. if (appendText) {
  5876. inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
  5877. input[isRTL ? 'before' : 'after'](inst.append);
  5878. }
  5879. input.unbind('focus', this._showDatepicker);
  5880. if (inst.trigger)
  5881. inst.trigger.remove();
  5882. var showOn = this._get(inst, 'showOn');
  5883. if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
  5884. input.focus(this._showDatepicker);
  5885. if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
  5886. var buttonText = this._get(inst, 'buttonText');
  5887. var buttonImage = this._get(inst, 'buttonImage');
  5888. inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
  5889. $('<img/>').addClass(this._triggerClass).
  5890. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  5891. $('<button type="button"></button>').addClass(this._triggerClass).
  5892. html(buttonImage == '' ? buttonText : $('<img/>').attr(
  5893. { src:buttonImage, alt:buttonText, title:buttonText })));
  5894. input[isRTL ? 'before' : 'after'](inst.trigger);
  5895. inst.trigger.click(function() {
  5896. if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
  5897. $.datepicker._hideDatepicker();
  5898. else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
  5899. $.datepicker._hideDatepicker();
  5900. $.datepicker._showDatepicker(input[0]);
  5901. } else
  5902. $.datepicker._showDatepicker(input[0]);
  5903. return false;
  5904. });
  5905. }
  5906. },
  5907. /* Apply the maximum length for the date format. */
  5908. _autoSize: function(inst) {
  5909. if (this._get(inst, 'autoSize') && !inst.inline) {
  5910. var date = new Date(2009, 12 - 1, 20); // Ensure double digits
  5911. var dateFormat = this._get(inst, 'dateFormat');
  5912. if (dateFormat.match(/[DM]/)) {
  5913. var findMax = function(names) {
  5914. var max = 0;
  5915. var maxI = 0;
  5916. for (var i = 0; i < names.length; i++) {
  5917. if (names[i].length > max) {
  5918. max = names[i].length;
  5919. maxI = i;
  5920. }
  5921. }
  5922. return maxI;
  5923. };
  5924. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  5925. 'monthNames' : 'monthNamesShort'))));
  5926. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  5927. 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
  5928. }
  5929. inst.input.attr('size', this._formatDate(inst, date).length);
  5930. }
  5931. },
  5932. /* Attach an inline date picker to a div. */
  5933. _inlineDatepicker: function(target, inst) {
  5934. var divSpan = $(target);
  5935. if (divSpan.hasClass(this.markerClassName))
  5936. return;
  5937. divSpan.addClass(this.markerClassName).append(inst.dpDiv).
  5938. bind("setData.datepicker", function(event, key, value){
  5939. inst.settings[key] = value;
  5940. }).bind("getData.datepicker", function(event, key){
  5941. return this._get(inst, key);
  5942. });
  5943. $.data(target, PROP_NAME, inst);
  5944. this._setDate(inst, this._getDefaultDate(inst), true);
  5945. this._updateDatepicker(inst);
  5946. this._updateAlternate(inst);
  5947. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  5948. if( inst.settings.disabled ) {
  5949. this._disableDatepicker( target );
  5950. }
  5951. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  5952. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  5953. inst.dpDiv.css( "display", "block" );
  5954. },
  5955. /* Pop-up the date picker in a "dialog" box.
  5956. @param input element - ignored
  5957. @param date string or Date - the initial date to display
  5958. @param onSelect function - the function to call when a date is selected
  5959. @param settings object - update the dialog date picker instance's settings (anonymous object)
  5960. @param pos int[2] - coordinates for the dialog's position within the screen or
  5961. event - with x/y coordinates or
  5962. leave empty for default (screen centre)
  5963. @return the manager object */
  5964. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  5965. var inst = this._dialogInst; // internal instance
  5966. if (!inst) {
  5967. this.uuid += 1;
  5968. var id = 'dp' + this.uuid;
  5969. this._dialogInput = $('<input type="text" id="' + id +
  5970. '" style="position: absolute; top: -100px; width: 0px;"/>');
  5971. this._dialogInput.keydown(this._doKeyDown);
  5972. $('body').append(this._dialogInput);
  5973. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  5974. inst.settings = {};
  5975. $.data(this._dialogInput[0], PROP_NAME, inst);
  5976. }
  5977. extendRemove(inst.settings, settings || {});
  5978. date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
  5979. this._dialogInput.val(date);
  5980. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  5981. if (!this._pos) {
  5982. var browserWidth = document.documentElement.clientWidth;
  5983. var browserHeight = document.documentElement.clientHeight;
  5984. var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  5985. var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  5986. this._pos = // should use actual width/height below
  5987. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  5988. }
  5989. // move input on screen for focus, but hidden behind dialog
  5990. this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
  5991. inst.settings.onSelect = onSelect;
  5992. this._inDialog = true;
  5993. this.dpDiv.addClass(this._dialogClass);
  5994. this._showDatepicker(this._dialogInput[0]);
  5995. if ($.blockUI)
  5996. $.blockUI(this.dpDiv);
  5997. $.data(this._dialogInput[0], PROP_NAME, inst);
  5998. return this;
  5999. },
  6000. /* Detach a datepicker from its control.
  6001. @param target element - the target input field or division or span */
  6002. _destroyDatepicker: function(target) {
  6003. var $target = $(target);
  6004. var inst = $.data(target, PROP_NAME);
  6005. if (!$target.hasClass(this.markerClassName)) {
  6006. return;
  6007. }
  6008. var nodeName = target.nodeName.toLowerCase();
  6009. $.removeData(target, PROP_NAME);
  6010. if (nodeName == 'input') {
  6011. inst.append.remove();
  6012. inst.trigger.remove();
  6013. $target.removeClass(this.markerClassName).
  6014. unbind('focus', this._showDatepicker).
  6015. unbind('keydown', this._doKeyDown).
  6016. unbind('keypress', this._doKeyPress).
  6017. unbind('keyup', this._doKeyUp);
  6018. } else if (nodeName == 'div' || nodeName == 'span')
  6019. $target.removeClass(this.markerClassName).empty();
  6020. },
  6021. /* Enable the date picker to a jQuery selection.
  6022. @param target element - the target input field or division or span */
  6023. _enableDatepicker: function(target) {
  6024. var $target = $(target);
  6025. var inst = $.data(target, PROP_NAME);
  6026. if (!$target.hasClass(this.markerClassName)) {
  6027. return;
  6028. }
  6029. var nodeName = target.nodeName.toLowerCase();
  6030. if (nodeName == 'input') {
  6031. target.disabled = false;
  6032. inst.trigger.filter('button').
  6033. each(function() { this.disabled = false; }).end().
  6034. filter('img').css({opacity: '1.0', cursor: ''});
  6035. }
  6036. else if (nodeName == 'div' || nodeName == 'span') {
  6037. var inline = $target.children('.' + this._inlineClass);
  6038. inline.children().removeClass('ui-state-disabled');
  6039. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6040. removeAttr("disabled");
  6041. }
  6042. this._disabledInputs = $.map(this._disabledInputs,
  6043. function(value) { return (value == target ? null : value); }); // delete entry
  6044. },
  6045. /* Disable the date picker to a jQuery selection.
  6046. @param target element - the target input field or division or span */
  6047. _disableDatepicker: function(target) {
  6048. var $target = $(target);
  6049. var inst = $.data(target, PROP_NAME);
  6050. if (!$target.hasClass(this.markerClassName)) {
  6051. return;
  6052. }
  6053. var nodeName = target.nodeName.toLowerCase();
  6054. if (nodeName == 'input') {
  6055. target.disabled = true;
  6056. inst.trigger.filter('button').
  6057. each(function() { this.disabled = true; }).end().
  6058. filter('img').css({opacity: '0.5', cursor: 'default'});
  6059. }
  6060. else if (nodeName == 'div' || nodeName == 'span') {
  6061. var inline = $target.children('.' + this._inlineClass);
  6062. inline.children().addClass('ui-state-disabled');
  6063. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6064. attr("disabled", "disabled");
  6065. }
  6066. this._disabledInputs = $.map(this._disabledInputs,
  6067. function(value) { return (value == target ? null : value); }); // delete entry
  6068. this._disabledInputs[this._disabledInputs.length] = target;
  6069. },
  6070. /* Is the first field in a jQuery collection disabled as a datepicker?
  6071. @param target element - the target input field or division or span
  6072. @return boolean - true if disabled, false if enabled */
  6073. _isDisabledDatepicker: function(target) {
  6074. if (!target) {
  6075. return false;
  6076. }
  6077. for (var i = 0; i < this._disabledInputs.length; i++) {
  6078. if (this._disabledInputs[i] == target)
  6079. return true;
  6080. }
  6081. return false;
  6082. },
  6083. /* Retrieve the instance data for the target control.
  6084. @param target element - the target input field or division or span
  6085. @return object - the associated instance data
  6086. @throws error if a jQuery problem getting data */
  6087. _getInst: function(target) {
  6088. try {
  6089. return $.data(target, PROP_NAME);
  6090. }
  6091. catch (err) {
  6092. throw 'Missing instance data for this datepicker';
  6093. }
  6094. },
  6095. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6096. @param target element - the target input field or division or span
  6097. @param name object - the new settings to update or
  6098. string - the name of the setting to change or retrieve,
  6099. when retrieving also 'all' for all instance settings or
  6100. 'defaults' for all global defaults
  6101. @param value any - the new value for the setting
  6102. (omit if above is an object or to retrieve a value) */
  6103. _optionDatepicker: function(target, name, value) {
  6104. var inst = this._getInst(target);
  6105. if (arguments.length == 2 && typeof name == 'string') {
  6106. return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
  6107. (inst ? (name == 'all' ? $.extend({}, inst.settings) :
  6108. this._get(inst, name)) : null));
  6109. }
  6110. var settings = name || {};
  6111. if (typeof name == 'string') {
  6112. settings = {};
  6113. settings[name] = value;
  6114. }
  6115. if (inst) {
  6116. if (this._curInst == inst) {
  6117. this._hideDatepicker();
  6118. }
  6119. var date = this._getDateDatepicker(target, true);
  6120. var minDate = this._getMinMaxDate(inst, 'min');
  6121. var maxDate = this._getMinMaxDate(inst, 'max');
  6122. extendRemove(inst.settings, settings);
  6123. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6124. if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
  6125. inst.settings.minDate = this._formatDate(inst, minDate);
  6126. if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
  6127. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6128. this._attachments($(target), inst);
  6129. this._autoSize(inst);
  6130. this._setDate(inst, date);
  6131. this._updateAlternate(inst);
  6132. this._updateDatepicker(inst);
  6133. }
  6134. },
  6135. // change method deprecated
  6136. _changeDatepicker: function(target, name, value) {
  6137. this._optionDatepicker(target, name, value);
  6138. },
  6139. /* Redraw the date picker attached to an input field or division.
  6140. @param target element - the target input field or division or span */
  6141. _refreshDatepicker: function(target) {
  6142. var inst = this._getInst(target);
  6143. if (inst) {
  6144. this._updateDatepicker(inst);
  6145. }
  6146. },
  6147. /* Set the dates for a jQuery selection.
  6148. @param target element - the target input field or division or span
  6149. @param date Date - the new date */
  6150. _setDateDatepicker: function(target, date) {
  6151. var inst = this._getInst(target);
  6152. if (inst) {
  6153. this._setDate(inst, date);
  6154. this._updateDatepicker(inst);
  6155. this._updateAlternate(inst);
  6156. }
  6157. },
  6158. /* Get the date(s) for the first entry in a jQuery selection.
  6159. @param target element - the target input field or division or span
  6160. @param noDefault boolean - true if no default date is to be used
  6161. @return Date - the current date */
  6162. _getDateDatepicker: function(target, noDefault) {
  6163. var inst = this._getInst(target);
  6164. if (inst && !inst.inline)
  6165. this._setDateFromField(inst, noDefault);
  6166. return (inst ? this._getDate(inst) : null);
  6167. },
  6168. /* Handle keystrokes. */
  6169. _doKeyDown: function(event) {
  6170. var inst = $.datepicker._getInst(event.target);
  6171. var handled = true;
  6172. var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
  6173. inst._keyEvent = true;
  6174. if ($.datepicker._datepickerShowing)
  6175. switch (event.keyCode) {
  6176. case 9: $.datepicker._hideDatepicker();
  6177. handled = false;
  6178. break; // hide on tab out
  6179. case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
  6180. $.datepicker._currentClass + ')', inst.dpDiv);
  6181. if (sel[0])
  6182. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6183. var onSelect = $.datepicker._get(inst, 'onSelect');
  6184. if (onSelect) {
  6185. var dateStr = $.datepicker._formatDate(inst);
  6186. // trigger custom callback
  6187. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6188. }
  6189. else
  6190. $.datepicker._hideDatepicker();
  6191. return false; // don't submit the form
  6192. break; // select the value on enter
  6193. case 27: $.datepicker._hideDatepicker();
  6194. break; // hide on escape
  6195. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6196. -$.datepicker._get(inst, 'stepBigMonths') :
  6197. -$.datepicker._get(inst, 'stepMonths')), 'M');
  6198. break; // previous month/year on page up/+ ctrl
  6199. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6200. +$.datepicker._get(inst, 'stepBigMonths') :
  6201. +$.datepicker._get(inst, 'stepMonths')), 'M');
  6202. break; // next month/year on page down/+ ctrl
  6203. case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
  6204. handled = event.ctrlKey || event.metaKey;
  6205. break; // clear on ctrl or command +end
  6206. case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
  6207. handled = event.ctrlKey || event.metaKey;
  6208. break; // current on ctrl or command +home
  6209. case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
  6210. handled = event.ctrlKey || event.metaKey;
  6211. // -1 day on ctrl or command +left
  6212. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6213. -$.datepicker._get(inst, 'stepBigMonths') :
  6214. -$.datepicker._get(inst, 'stepMonths')), 'M');
  6215. // next month/year on alt +left on Mac
  6216. break;
  6217. case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
  6218. handled = event.ctrlKey || event.metaKey;
  6219. break; // -1 week on ctrl or command +up
  6220. case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
  6221. handled = event.ctrlKey || event.metaKey;
  6222. // +1 day on ctrl or command +right
  6223. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6224. +$.datepicker._get(inst, 'stepBigMonths') :
  6225. +$.datepicker._get(inst, 'stepMonths')), 'M');
  6226. // next month/year on alt +right
  6227. break;
  6228. case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
  6229. handled = event.ctrlKey || event.metaKey;
  6230. break; // +1 week on ctrl or command +down
  6231. default: handled = false;
  6232. }
  6233. else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
  6234. $.datepicker._showDatepicker(this);
  6235. else {
  6236. handled = false;
  6237. }
  6238. if (handled) {
  6239. event.preventDefault();
  6240. event.stopPropagation();
  6241. }
  6242. },
  6243. /* Filter entered characters - based on date format. */
  6244. _doKeyPress: function(event) {
  6245. var inst = $.datepicker._getInst(event.target);
  6246. if ($.datepicker._get(inst, 'constrainInput')) {
  6247. var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
  6248. var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
  6249. return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
  6250. }
  6251. },
  6252. /* Synchronise manual entry and field/alternate field. */
  6253. _doKeyUp: function(event) {
  6254. var inst = $.datepicker._getInst(event.target);
  6255. if (inst.input.val() != inst.lastVal) {
  6256. try {
  6257. var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  6258. (inst.input ? inst.input.val() : null),
  6259. $.datepicker._getFormatConfig(inst));
  6260. if (date) { // only if valid
  6261. $.datepicker._setDateFromField(inst);
  6262. $.datepicker._updateAlternate(inst);
  6263. $.datepicker._updateDatepicker(inst);
  6264. }
  6265. }
  6266. catch (err) {
  6267. $.datepicker.log(err);
  6268. }
  6269. }
  6270. return true;
  6271. },
  6272. /* Pop-up the date picker for a given input field.
  6273. If false returned from beforeShow event handler do not show.
  6274. @param input element - the input field attached to the date picker or
  6275. event - if triggered by focus */
  6276. _showDatepicker: function(input) {
  6277. input = input.target || input;
  6278. if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
  6279. input = $('input', input.parentNode)[0];
  6280. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
  6281. return;
  6282. var inst = $.datepicker._getInst(input);
  6283. if ($.datepicker._curInst && $.datepicker._curInst != inst) {
  6284. $.datepicker._curInst.dpDiv.stop(true, true);
  6285. if ( inst && $.datepicker._datepickerShowing ) {
  6286. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  6287. }
  6288. }
  6289. var beforeShow = $.datepicker._get(inst, 'beforeShow');
  6290. var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  6291. if(beforeShowSettings === false){
  6292. //false
  6293. return;
  6294. }
  6295. extendRemove(inst.settings, beforeShowSettings);
  6296. inst.lastVal = null;
  6297. $.datepicker._lastInput = input;
  6298. $.datepicker._setDateFromField(inst);
  6299. if ($.datepicker._inDialog) // hide cursor
  6300. input.value = '';
  6301. if (!$.datepicker._pos) { // position below input
  6302. $.datepicker._pos = $.datepicker._findPos(input);
  6303. $.datepicker._pos[1] += input.offsetHeight; // add the height
  6304. }
  6305. var isFixed = false;
  6306. $(input).parents().each(function() {
  6307. isFixed |= $(this).css('position') == 'fixed';
  6308. return !isFixed;
  6309. });
  6310. if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
  6311. $.datepicker._pos[0] -= document.documentElement.scrollLeft;
  6312. $.datepicker._pos[1] -= document.documentElement.scrollTop;
  6313. }
  6314. var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  6315. $.datepicker._pos = null;
  6316. //to avoid flashes on Firefox
  6317. inst.dpDiv.empty();
  6318. // determine sizing offscreen
  6319. inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
  6320. $.datepicker._updateDatepicker(inst);
  6321. // fix width for dynamic number of date pickers
  6322. // and adjust position before showing
  6323. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  6324. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  6325. 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
  6326. left: offset.left + 'px', top: offset.top + 'px'});
  6327. if (!inst.inline) {
  6328. var showAnim = $.datepicker._get(inst, 'showAnim');
  6329. var duration = $.datepicker._get(inst, 'duration');
  6330. var postProcess = function() {
  6331. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  6332. if( !! cover.length ){
  6333. var borders = $.datepicker._getBorders(inst.dpDiv);
  6334. cover.css({left: -borders[0], top: -borders[1],
  6335. width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
  6336. }
  6337. };
  6338. inst.dpDiv.zIndex($(input).zIndex()+1);
  6339. $.datepicker._datepickerShowing = true;
  6340. if ($.effects && $.effects[showAnim])
  6341. inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  6342. else
  6343. inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
  6344. if (!showAnim || !duration)
  6345. postProcess();
  6346. if (inst.input.is(':visible') && !inst.input.is(':disabled'))
  6347. inst.input.focus();
  6348. $.datepicker._curInst = inst;
  6349. }
  6350. },
  6351. /* Generate the date picker content. */
  6352. _updateDatepicker: function(inst) {
  6353. var self = this;
  6354. self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6355. var borders = $.datepicker._getBorders(inst.dpDiv);
  6356. instActive = inst; // for delegate hover events
  6357. inst.dpDiv.empty().append(this._generateHTML(inst));
  6358. this._attachHandlers(inst);
  6359. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  6360. if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
  6361. cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
  6362. }
  6363. inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
  6364. var numMonths = this._getNumberOfMonths(inst);
  6365. var cols = numMonths[1];
  6366. var width = 17;
  6367. inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
  6368. if (cols > 1)
  6369. inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
  6370. inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
  6371. 'Class']('ui-datepicker-multi');
  6372. inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
  6373. 'Class']('ui-datepicker-rtl');
  6374. if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  6375. // #6694 - don't focus the input if it's already focused
  6376. // this breaks the change event in IE
  6377. inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
  6378. inst.input.focus();
  6379. // deffered render of the years select (to avoid flashes on Firefox)
  6380. if( inst.yearshtml ){
  6381. var origyearshtml = inst.yearshtml;
  6382. setTimeout(function(){
  6383. //assure that inst.yearshtml didn't change.
  6384. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  6385. inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
  6386. }
  6387. origyearshtml = inst.yearshtml = null;
  6388. }, 0);
  6389. }
  6390. },
  6391. /* Retrieve the size of left and top borders for an element.
  6392. @param elem (jQuery object) the element of interest
  6393. @return (number[2]) the left and top borders */
  6394. _getBorders: function(elem) {
  6395. var convert = function(value) {
  6396. return {thin: 1, medium: 2, thick: 3}[value] || value;
  6397. };
  6398. return [parseFloat(convert(elem.css('border-left-width'))),
  6399. parseFloat(convert(elem.css('border-top-width')))];
  6400. },
  6401. /* Check positioning to remain on screen. */
  6402. _checkOffset: function(inst, offset, isFixed) {
  6403. var dpWidth = inst.dpDiv.outerWidth();
  6404. var dpHeight = inst.dpDiv.outerHeight();
  6405. var inputWidth = inst.input ? inst.input.outerWidth() : 0;
  6406. var inputHeight = inst.input ? inst.input.outerHeight() : 0;
  6407. var viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft());
  6408. var viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  6409. offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
  6410. offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
  6411. offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  6412. // now check if datepicker is showing outside window viewport - move to a better place if so.
  6413. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  6414. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  6415. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  6416. Math.abs(dpHeight + inputHeight) : 0);
  6417. return offset;
  6418. },
  6419. /* Find an object's position on the screen. */
  6420. _findPos: function(obj) {
  6421. var inst = this._getInst(obj);
  6422. var isRTL = this._get(inst, 'isRTL');
  6423. while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
  6424. obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
  6425. }
  6426. var position = $(obj).offset();
  6427. return [position.left, position.top];
  6428. },
  6429. /* Hide the date picker from view.
  6430. @param input element - the input field attached to the date picker */
  6431. _hideDatepicker: function(input) {
  6432. var inst = this._curInst;
  6433. if (!inst || (input && inst != $.data(input, PROP_NAME)))
  6434. return;
  6435. if (this._datepickerShowing) {
  6436. var showAnim = this._get(inst, 'showAnim');
  6437. var duration = this._get(inst, 'duration');
  6438. var postProcess = function() {
  6439. $.datepicker._tidyDialog(inst);
  6440. };
  6441. if ($.effects && $.effects[showAnim])
  6442. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  6443. else
  6444. inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
  6445. (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
  6446. if (!showAnim)
  6447. postProcess();
  6448. this._datepickerShowing = false;
  6449. var onClose = this._get(inst, 'onClose');
  6450. if (onClose)
  6451. onClose.apply((inst.input ? inst.input[0] : null),
  6452. [(inst.input ? inst.input.val() : ''), inst]);
  6453. this._lastInput = null;
  6454. if (this._inDialog) {
  6455. this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
  6456. if ($.blockUI) {
  6457. $.unblockUI();
  6458. $('body').append(this.dpDiv);
  6459. }
  6460. }
  6461. this._inDialog = false;
  6462. }
  6463. },
  6464. /* Tidy up after a dialog display. */
  6465. _tidyDialog: function(inst) {
  6466. inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
  6467. },
  6468. /* Close date picker if clicked elsewhere. */
  6469. _checkExternalClick: function(event) {
  6470. if (!$.datepicker._curInst)
  6471. return;
  6472. var $target = $(event.target),
  6473. inst = $.datepicker._getInst($target[0]);
  6474. if ( ( ( $target[0].id != $.datepicker._mainDivId &&
  6475. $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
  6476. !$target.hasClass($.datepicker.markerClassName) &&
  6477. !$target.closest("." + $.datepicker._triggerClass).length &&
  6478. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  6479. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
  6480. $.datepicker._hideDatepicker();
  6481. },
  6482. /* Adjust one of the date sub-fields. */
  6483. _adjustDate: function(id, offset, period) {
  6484. var target = $(id);
  6485. var inst = this._getInst(target[0]);
  6486. if (this._isDisabledDatepicker(target[0])) {
  6487. return;
  6488. }
  6489. this._adjustInstDate(inst, offset +
  6490. (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
  6491. period);
  6492. this._updateDatepicker(inst);
  6493. },
  6494. /* Action for current link. */
  6495. _gotoToday: function(id) {
  6496. var target = $(id);
  6497. var inst = this._getInst(target[0]);
  6498. if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
  6499. inst.selectedDay = inst.currentDay;
  6500. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  6501. inst.drawYear = inst.selectedYear = inst.currentYear;
  6502. }
  6503. else {
  6504. var date = new Date();
  6505. inst.selectedDay = date.getDate();
  6506. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6507. inst.drawYear = inst.selectedYear = date.getFullYear();
  6508. }
  6509. this._notifyChange(inst);
  6510. this._adjustDate(target);
  6511. },
  6512. /* Action for selecting a new month/year. */
  6513. _selectMonthYear: function(id, select, period) {
  6514. var target = $(id);
  6515. var inst = this._getInst(target[0]);
  6516. inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
  6517. inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
  6518. parseInt(select.options[select.selectedIndex].value,10);
  6519. this._notifyChange(inst);
  6520. this._adjustDate(target);
  6521. },
  6522. /* Action for selecting a day. */
  6523. _selectDay: function(id, month, year, td) {
  6524. var target = $(id);
  6525. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  6526. return;
  6527. }
  6528. var inst = this._getInst(target[0]);
  6529. inst.selectedDay = inst.currentDay = $('a', td).html();
  6530. inst.selectedMonth = inst.currentMonth = month;
  6531. inst.selectedYear = inst.currentYear = year;
  6532. this._selectDate(id, this._formatDate(inst,
  6533. inst.currentDay, inst.currentMonth, inst.currentYear));
  6534. },
  6535. /* Erase the input field and hide the date picker. */
  6536. _clearDate: function(id) {
  6537. var target = $(id);
  6538. var inst = this._getInst(target[0]);
  6539. this._selectDate(target, '');
  6540. },
  6541. /* Update the input field with the selected date. */
  6542. _selectDate: function(id, dateStr) {
  6543. var target = $(id);
  6544. var inst = this._getInst(target[0]);
  6545. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  6546. if (inst.input)
  6547. inst.input.val(dateStr);
  6548. this._updateAlternate(inst);
  6549. var onSelect = this._get(inst, 'onSelect');
  6550. if (onSelect)
  6551. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  6552. else if (inst.input)
  6553. inst.input.trigger('change'); // fire the change event
  6554. if (inst.inline)
  6555. this._updateDatepicker(inst);
  6556. else {
  6557. this._hideDatepicker();
  6558. this._lastInput = inst.input[0];
  6559. if (typeof(inst.input[0]) != 'object')
  6560. inst.input.focus(); // restore focus
  6561. this._lastInput = null;
  6562. }
  6563. },
  6564. /* Update any alternate field to synchronise with the main field. */
  6565. _updateAlternate: function(inst) {
  6566. var altField = this._get(inst, 'altField');
  6567. if (altField) { // update alternate field too
  6568. var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
  6569. var date = this._getDate(inst);
  6570. var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  6571. $(altField).each(function() { $(this).val(dateStr); });
  6572. }
  6573. },
  6574. /* Set as beforeShowDay function to prevent selection of weekends.
  6575. @param date Date - the date to customise
  6576. @return [boolean, string] - is this date selectable?, what is its CSS class? */
  6577. noWeekends: function(date) {
  6578. var day = date.getDay();
  6579. return [(day > 0 && day < 6), ''];
  6580. },
  6581. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  6582. @param date Date - the date to get the week for
  6583. @return number - the number of the week within the year that contains this date */
  6584. iso8601Week: function(date) {
  6585. var checkDate = new Date(date.getTime());
  6586. // Find Thursday of this week starting on Monday
  6587. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  6588. var time = checkDate.getTime();
  6589. checkDate.setMonth(0); // Compare with Jan 1
  6590. checkDate.setDate(1);
  6591. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  6592. },
  6593. /* Parse a string value into a date object.
  6594. See formatDate below for the possible formats.
  6595. @param format string - the expected format of the date
  6596. @param value string - the date in the above format
  6597. @param settings Object - attributes include:
  6598. shortYearCutoff number - the cutoff year for determining the century (optional)
  6599. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6600. dayNames string[7] - names of the days from Sunday (optional)
  6601. monthNamesShort string[12] - abbreviated names of the months (optional)
  6602. monthNames string[12] - names of the months (optional)
  6603. @return Date - the extracted date value or null if value is blank */
  6604. parseDate: function (format, value, settings) {
  6605. if (format == null || value == null)
  6606. throw 'Invalid arguments';
  6607. value = (typeof value == 'object' ? value.toString() : value + '');
  6608. if (value == '')
  6609. return null;
  6610. var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
  6611. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  6612. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  6613. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  6614. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  6615. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  6616. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  6617. var year = -1;
  6618. var month = -1;
  6619. var day = -1;
  6620. var doy = -1;
  6621. var literal = false;
  6622. // Check whether a format character is doubled
  6623. var lookAhead = function(match) {
  6624. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  6625. if (matches)
  6626. iFormat++;
  6627. return matches;
  6628. };
  6629. // Extract a number from the string value
  6630. var getNumber = function(match) {
  6631. var isDoubled = lookAhead(match);
  6632. var size = (match == '@' ? 14 : (match == '!' ? 20 :
  6633. (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
  6634. var digits = new RegExp('^\\d{1,' + size + '}');
  6635. var num = value.substring(iValue).match(digits);
  6636. if (!num)
  6637. throw 'Missing number at position ' + iValue;
  6638. iValue += num[0].length;
  6639. return parseInt(num[0], 10);
  6640. };
  6641. // Extract a name from the string value and convert to an index
  6642. var getName = function(match, shortNames, longNames) {
  6643. var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  6644. return [ [k, v] ];
  6645. }).sort(function (a, b) {
  6646. return -(a[1].length - b[1].length);
  6647. });
  6648. var index = -1;
  6649. $.each(names, function (i, pair) {
  6650. var name = pair[1];
  6651. if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
  6652. index = pair[0];
  6653. iValue += name.length;
  6654. return false;
  6655. }
  6656. });
  6657. if (index != -1)
  6658. return index + 1;
  6659. else
  6660. throw 'Unknown name at position ' + iValue;
  6661. };
  6662. // Confirm that a literal character matches the string value
  6663. var checkLiteral = function() {
  6664. if (value.charAt(iValue) != format.charAt(iFormat))
  6665. throw 'Unexpected literal at position ' + iValue;
  6666. iValue++;
  6667. };
  6668. var iValue = 0;
  6669. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  6670. if (literal)
  6671. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  6672. literal = false;
  6673. else
  6674. checkLiteral();
  6675. else
  6676. switch (format.charAt(iFormat)) {
  6677. case 'd':
  6678. day = getNumber('d');
  6679. break;
  6680. case 'D':
  6681. getName('D', dayNamesShort, dayNames);
  6682. break;
  6683. case 'o':
  6684. doy = getNumber('o');
  6685. break;
  6686. case 'm':
  6687. month = getNumber('m');
  6688. break;
  6689. case 'M':
  6690. month = getName('M', monthNamesShort, monthNames);
  6691. break;
  6692. case 'y':
  6693. year = getNumber('y');
  6694. break;
  6695. case '@':
  6696. var date = new Date(getNumber('@'));
  6697. year = date.getFullYear();
  6698. month = date.getMonth() + 1;
  6699. day = date.getDate();
  6700. break;
  6701. case '!':
  6702. var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
  6703. year = date.getFullYear();
  6704. month = date.getMonth() + 1;
  6705. day = date.getDate();
  6706. break;
  6707. case "'":
  6708. if (lookAhead("'"))
  6709. checkLiteral();
  6710. else
  6711. literal = true;
  6712. break;
  6713. default:
  6714. checkLiteral();
  6715. }
  6716. }
  6717. if (iValue < value.length){
  6718. throw "Extra/unparsed characters found in date: " + value.substring(iValue);
  6719. }
  6720. if (year == -1)
  6721. year = new Date().getFullYear();
  6722. else if (year < 100)
  6723. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  6724. (year <= shortYearCutoff ? 0 : -100);
  6725. if (doy > -1) {
  6726. month = 1;
  6727. day = doy;
  6728. do {
  6729. var dim = this._getDaysInMonth(year, month - 1);
  6730. if (day <= dim)
  6731. break;
  6732. month++;
  6733. day -= dim;
  6734. } while (true);
  6735. }
  6736. var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  6737. if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
  6738. throw 'Invalid date'; // E.g. 31/02/00
  6739. return date;
  6740. },
  6741. /* Standard date formats. */
  6742. ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
  6743. COOKIE: 'D, dd M yy',
  6744. ISO_8601: 'yy-mm-dd',
  6745. RFC_822: 'D, d M y',
  6746. RFC_850: 'DD, dd-M-y',
  6747. RFC_1036: 'D, d M y',
  6748. RFC_1123: 'D, d M yy',
  6749. RFC_2822: 'D, d M yy',
  6750. RSS: 'D, d M y', // RFC 822
  6751. TICKS: '!',
  6752. TIMESTAMP: '@',
  6753. W3C: 'yy-mm-dd', // ISO 8601
  6754. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  6755. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  6756. /* Format a date object into a string value.
  6757. The format can be combinations of the following:
  6758. d - day of month (no leading zero)
  6759. dd - day of month (two digit)
  6760. o - day of year (no leading zeros)
  6761. oo - day of year (three digit)
  6762. D - day name short
  6763. DD - day name long
  6764. m - month of year (no leading zero)
  6765. mm - month of year (two digit)
  6766. M - month name short
  6767. MM - month name long
  6768. y - year (two digit)
  6769. yy - year (four digit)
  6770. @ - Unix timestamp (ms since 01/01/1970)
  6771. ! - Windows ticks (100ns since 01/01/0001)
  6772. '...' - literal text
  6773. '' - single quote
  6774. @param format string - the desired format of the date
  6775. @param date Date - the date value to format
  6776. @param settings Object - attributes include:
  6777. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6778. dayNames string[7] - names of the days from Sunday (optional)
  6779. monthNamesShort string[12] - abbreviated names of the months (optional)
  6780. monthNames string[12] - names of the months (optional)
  6781. @return string - the date in the above format */
  6782. formatDate: function (format, date, settings) {
  6783. if (!date)
  6784. return '';
  6785. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  6786. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  6787. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  6788. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  6789. // Check whether a format character is doubled
  6790. var lookAhead = function(match) {
  6791. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  6792. if (matches)
  6793. iFormat++;
  6794. return matches;
  6795. };
  6796. // Format a number, with leading zero if necessary
  6797. var formatNumber = function(match, value, len) {
  6798. var num = '' + value;
  6799. if (lookAhead(match))
  6800. while (num.length < len)
  6801. num = '0' + num;
  6802. return num;
  6803. };
  6804. // Format a name, short or long as requested
  6805. var formatName = function(match, value, shortNames, longNames) {
  6806. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  6807. };
  6808. var output = '';
  6809. var literal = false;
  6810. if (date)
  6811. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  6812. if (literal)
  6813. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  6814. literal = false;
  6815. else
  6816. output += format.charAt(iFormat);
  6817. else
  6818. switch (format.charAt(iFormat)) {
  6819. case 'd':
  6820. output += formatNumber('d', date.getDate(), 2);
  6821. break;
  6822. case 'D':
  6823. output += formatName('D', date.getDay(), dayNamesShort, dayNames);
  6824. break;
  6825. case 'o':
  6826. output += formatNumber('o',
  6827. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  6828. break;
  6829. case 'm':
  6830. output += formatNumber('m', date.getMonth() + 1, 2);
  6831. break;
  6832. case 'M':
  6833. output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
  6834. break;
  6835. case 'y':
  6836. output += (lookAhead('y') ? date.getFullYear() :
  6837. (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
  6838. break;
  6839. case '@':
  6840. output += date.getTime();
  6841. break;
  6842. case '!':
  6843. output += date.getTime() * 10000 + this._ticksTo1970;
  6844. break;
  6845. case "'":
  6846. if (lookAhead("'"))
  6847. output += "'";
  6848. else
  6849. literal = true;
  6850. break;
  6851. default:
  6852. output += format.charAt(iFormat);
  6853. }
  6854. }
  6855. return output;
  6856. },
  6857. /* Extract all possible characters from the date format. */
  6858. _possibleChars: function (format) {
  6859. var chars = '';
  6860. var literal = false;
  6861. // Check whether a format character is doubled
  6862. var lookAhead = function(match) {
  6863. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  6864. if (matches)
  6865. iFormat++;
  6866. return matches;
  6867. };
  6868. for (var iFormat = 0; iFormat < format.length; iFormat++)
  6869. if (literal)
  6870. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  6871. literal = false;
  6872. else
  6873. chars += format.charAt(iFormat);
  6874. else
  6875. switch (format.charAt(iFormat)) {
  6876. case 'd': case 'm': case 'y': case '@':
  6877. chars += '0123456789';
  6878. break;
  6879. case 'D': case 'M':
  6880. return null; // Accept anything
  6881. case "'":
  6882. if (lookAhead("'"))
  6883. chars += "'";
  6884. else
  6885. literal = true;
  6886. break;
  6887. default:
  6888. chars += format.charAt(iFormat);
  6889. }
  6890. return chars;
  6891. },
  6892. /* Get a setting value, defaulting if necessary. */
  6893. _get: function(inst, name) {
  6894. return inst.settings[name] !== undefined ?
  6895. inst.settings[name] : this._defaults[name];
  6896. },
  6897. /* Parse existing date and initialise date picker. */
  6898. _setDateFromField: function(inst, noDefault) {
  6899. if (inst.input.val() == inst.lastVal) {
  6900. return;
  6901. }
  6902. var dateFormat = this._get(inst, 'dateFormat');
  6903. var dates = inst.lastVal = inst.input ? inst.input.val() : null;
  6904. var date, defaultDate;
  6905. date = defaultDate = this._getDefaultDate(inst);
  6906. var settings = this._getFormatConfig(inst);
  6907. try {
  6908. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  6909. } catch (event) {
  6910. this.log(event);
  6911. dates = (noDefault ? '' : dates);
  6912. }
  6913. inst.selectedDay = date.getDate();
  6914. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6915. inst.drawYear = inst.selectedYear = date.getFullYear();
  6916. inst.currentDay = (dates ? date.getDate() : 0);
  6917. inst.currentMonth = (dates ? date.getMonth() : 0);
  6918. inst.currentYear = (dates ? date.getFullYear() : 0);
  6919. this._adjustInstDate(inst);
  6920. },
  6921. /* Retrieve the default date shown on opening. */
  6922. _getDefaultDate: function(inst) {
  6923. return this._restrictMinMax(inst,
  6924. this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
  6925. },
  6926. /* A date may be specified as an exact value or a relative one. */
  6927. _determineDate: function(inst, date, defaultDate) {
  6928. var offsetNumeric = function(offset) {
  6929. var date = new Date();
  6930. date.setDate(date.getDate() + offset);
  6931. return date;
  6932. };
  6933. var offsetString = function(offset) {
  6934. try {
  6935. return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  6936. offset, $.datepicker._getFormatConfig(inst));
  6937. }
  6938. catch (e) {
  6939. // Ignore
  6940. }
  6941. var date = (offset.toLowerCase().match(/^c/) ?
  6942. $.datepicker._getDate(inst) : null) || new Date();
  6943. var year = date.getFullYear();
  6944. var month = date.getMonth();
  6945. var day = date.getDate();
  6946. var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
  6947. var matches = pattern.exec(offset);
  6948. while (matches) {
  6949. switch (matches[2] || 'd') {
  6950. case 'd' : case 'D' :
  6951. day += parseInt(matches[1],10); break;
  6952. case 'w' : case 'W' :
  6953. day += parseInt(matches[1],10) * 7; break;
  6954. case 'm' : case 'M' :
  6955. month += parseInt(matches[1],10);
  6956. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  6957. break;
  6958. case 'y': case 'Y' :
  6959. year += parseInt(matches[1],10);
  6960. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  6961. break;
  6962. }
  6963. matches = pattern.exec(offset);
  6964. }
  6965. return new Date(year, month, day);
  6966. };
  6967. var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
  6968. (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  6969. newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
  6970. if (newDate) {
  6971. newDate.setHours(0);
  6972. newDate.setMinutes(0);
  6973. newDate.setSeconds(0);
  6974. newDate.setMilliseconds(0);
  6975. }
  6976. return this._daylightSavingAdjust(newDate);
  6977. },
  6978. /* Handle switch to/from daylight saving.
  6979. Hours may be non-zero on daylight saving cut-over:
  6980. > 12 when midnight changeover, but then cannot generate
  6981. midnight datetime, so jump to 1AM, otherwise reset.
  6982. @param date (Date) the date to check
  6983. @return (Date) the corrected date */
  6984. _daylightSavingAdjust: function(date) {
  6985. if (!date) return null;
  6986. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  6987. return date;
  6988. },
  6989. /* Set the date(s) directly. */
  6990. _setDate: function(inst, date, noChange) {
  6991. var clear = !date;
  6992. var origMonth = inst.selectedMonth;
  6993. var origYear = inst.selectedYear;
  6994. var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  6995. inst.selectedDay = inst.currentDay = newDate.getDate();
  6996. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  6997. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  6998. if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
  6999. this._notifyChange(inst);
  7000. this._adjustInstDate(inst);
  7001. if (inst.input) {
  7002. inst.input.val(clear ? '' : this._formatDate(inst));
  7003. }
  7004. },
  7005. /* Retrieve the date(s) directly. */
  7006. _getDate: function(inst) {
  7007. var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
  7008. this._daylightSavingAdjust(new Date(
  7009. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7010. return startDate;
  7011. },
  7012. /* Attach the onxxx handlers. These are declared statically so
  7013. * they work with static code transformers like Caja.
  7014. */
  7015. _attachHandlers: function(inst) {
  7016. var stepMonths = this._get(inst, 'stepMonths');
  7017. var id = '#' + inst.id.replace( /\\\\/g, "\\" );
  7018. inst.dpDiv.find('[data-handler]').map(function () {
  7019. var handler = {
  7020. prev: function () {
  7021. window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, -stepMonths, 'M');
  7022. },
  7023. next: function () {
  7024. window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, +stepMonths, 'M');
  7025. },
  7026. hide: function () {
  7027. window['DP_jQuery_' + dpuuid].datepicker._hideDatepicker();
  7028. },
  7029. today: function () {
  7030. window['DP_jQuery_' + dpuuid].datepicker._gotoToday(id);
  7031. },
  7032. selectDay: function () {
  7033. window['DP_jQuery_' + dpuuid].datepicker._selectDay(id, +this.getAttribute('data-month'), +this.getAttribute('data-year'), this);
  7034. return false;
  7035. },
  7036. selectMonth: function () {
  7037. window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'M');
  7038. return false;
  7039. },
  7040. selectYear: function () {
  7041. window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'Y');
  7042. return false;
  7043. }
  7044. };
  7045. $(this).bind(this.getAttribute('data-event'), handler[this.getAttribute('data-handler')]);
  7046. });
  7047. },
  7048. /* Generate the HTML for the current state of the date picker. */
  7049. _generateHTML: function(inst) {
  7050. var today = new Date();
  7051. today = this._daylightSavingAdjust(
  7052. new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
  7053. var isRTL = this._get(inst, 'isRTL');
  7054. var showButtonPanel = this._get(inst, 'showButtonPanel');
  7055. var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
  7056. var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
  7057. var numMonths = this._getNumberOfMonths(inst);
  7058. var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
  7059. var stepMonths = this._get(inst, 'stepMonths');
  7060. var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
  7061. var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7062. new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7063. var minDate = this._getMinMaxDate(inst, 'min');
  7064. var maxDate = this._getMinMaxDate(inst, 'max');
  7065. var drawMonth = inst.drawMonth - showCurrentAtPos;
  7066. var drawYear = inst.drawYear;
  7067. if (drawMonth < 0) {
  7068. drawMonth += 12;
  7069. drawYear--;
  7070. }
  7071. if (maxDate) {
  7072. var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7073. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7074. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7075. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7076. drawMonth--;
  7077. if (drawMonth < 0) {
  7078. drawMonth = 11;
  7079. drawYear--;
  7080. }
  7081. }
  7082. }
  7083. inst.drawMonth = drawMonth;
  7084. inst.drawYear = drawYear;
  7085. var prevText = this._get(inst, 'prevText');
  7086. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7087. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7088. this._getFormatConfig(inst)));
  7089. var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7090. '<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click"' +
  7091. ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
  7092. (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>'));
  7093. var nextText = this._get(inst, 'nextText');
  7094. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7095. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7096. this._getFormatConfig(inst)));
  7097. var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7098. '<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click"' +
  7099. ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
  7100. (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>'));
  7101. var currentText = this._get(inst, 'currentText');
  7102. var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
  7103. currentText = (!navigationAsDateFormat ? currentText :
  7104. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7105. var 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">' +
  7106. this._get(inst, 'closeText') + '</button>' : '');
  7107. var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
  7108. (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"' +
  7109. '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
  7110. var firstDay = parseInt(this._get(inst, 'firstDay'),10);
  7111. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7112. var showWeek = this._get(inst, 'showWeek');
  7113. var dayNames = this._get(inst, 'dayNames');
  7114. var dayNamesShort = this._get(inst, 'dayNamesShort');
  7115. var dayNamesMin = this._get(inst, 'dayNamesMin');
  7116. var monthNames = this._get(inst, 'monthNames');
  7117. var monthNamesShort = this._get(inst, 'monthNamesShort');
  7118. var beforeShowDay = this._get(inst, 'beforeShowDay');
  7119. var showOtherMonths = this._get(inst, 'showOtherMonths');
  7120. var selectOtherMonths = this._get(inst, 'selectOtherMonths');
  7121. var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
  7122. var defaultDate = this._getDefaultDate(inst);
  7123. var html = '';
  7124. for (var row = 0; row < numMonths[0]; row++) {
  7125. var group = '';
  7126. this.maxRows = 4;
  7127. for (var col = 0; col < numMonths[1]; col++) {
  7128. var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7129. var cornerClass = ' ui-corner-all';
  7130. var calender = '';
  7131. if (isMultiMonth) {
  7132. calender += '<div class="ui-datepicker-group';
  7133. if (numMonths[1] > 1)
  7134. switch (col) {
  7135. case 0: calender += ' ui-datepicker-group-first';
  7136. cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
  7137. case numMonths[1]-1: calender += ' ui-datepicker-group-last';
  7138. cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
  7139. default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
  7140. }
  7141. calender += '">';
  7142. }
  7143. calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
  7144. (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
  7145. (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
  7146. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7147. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7148. '</div><table class="ui-datepicker-calendar"><thead>' +
  7149. '<tr>';
  7150. var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
  7151. for (var dow = 0; dow < 7; dow++) { // days of the week
  7152. var day = (dow + firstDay) % 7;
  7153. thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
  7154. '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
  7155. }
  7156. calender += thead + '</tr></thead><tbody>';
  7157. var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7158. if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
  7159. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7160. var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7161. var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7162. var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7163. this.maxRows = numRows;
  7164. var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7165. for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7166. calender += '<tr>';
  7167. var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
  7168. this._get(inst, 'calculateWeek')(printDate) + '</td>');
  7169. for (var dow = 0; dow < 7; dow++) { // create date picker days
  7170. var daySettings = (beforeShowDay ?
  7171. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
  7172. var otherMonth = (printDate.getMonth() != drawMonth);
  7173. var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7174. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7175. tbody += '<td class="' +
  7176. ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
  7177. (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
  7178. ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
  7179. (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
  7180. // or defaultDate is current printedDate and defaultDate is selectedDate
  7181. ' ' + this._dayOverClass : '') + // highlight selected day
  7182. (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
  7183. (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
  7184. (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
  7185. (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
  7186. ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
  7187. (unselectable ? '' : ' data-handler="selectDay" data-event="click" data-month="' + printDate.getMonth() + '" data-year="' + printDate.getFullYear() + '"') + '>' + // actions
  7188. (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
  7189. (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
  7190. (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
  7191. (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
  7192. (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
  7193. '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
  7194. printDate.setDate(printDate.getDate() + 1);
  7195. printDate = this._daylightSavingAdjust(printDate);
  7196. }
  7197. calender += tbody + '</tr>';
  7198. }
  7199. drawMonth++;
  7200. if (drawMonth > 11) {
  7201. drawMonth = 0;
  7202. drawYear++;
  7203. }
  7204. calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
  7205. ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
  7206. group += calender;
  7207. }
  7208. html += group;
  7209. }
  7210. html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
  7211. '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
  7212. inst._keyEvent = false;
  7213. return html;
  7214. },
  7215. /* Generate the month and year header. */
  7216. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7217. secondary, monthNames, monthNamesShort) {
  7218. var changeMonth = this._get(inst, 'changeMonth');
  7219. var changeYear = this._get(inst, 'changeYear');
  7220. var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
  7221. var html = '<div class="ui-datepicker-title">';
  7222. var monthHtml = '';
  7223. // month selection
  7224. if (secondary || !changeMonth)
  7225. monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
  7226. else {
  7227. var inMinYear = (minDate && minDate.getFullYear() == drawYear);
  7228. var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
  7229. monthHtml += '<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';
  7230. for (var month = 0; month < 12; month++) {
  7231. if ((!inMinYear || month >= minDate.getMonth()) &&
  7232. (!inMaxYear || month <= maxDate.getMonth()))
  7233. monthHtml += '<option value="' + month + '"' +
  7234. (month == drawMonth ? ' selected="selected"' : '') +
  7235. '>' + monthNamesShort[month] + '</option>';
  7236. }
  7237. monthHtml += '</select>';
  7238. }
  7239. if (!showMonthAfterYear)
  7240. html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
  7241. // year selection
  7242. if ( !inst.yearshtml ) {
  7243. inst.yearshtml = '';
  7244. if (secondary || !changeYear)
  7245. html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
  7246. else {
  7247. // determine range of years to display
  7248. var years = this._get(inst, 'yearRange').split(':');
  7249. var thisYear = new Date().getFullYear();
  7250. var determineYear = function(value) {
  7251. var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  7252. (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
  7253. parseInt(value, 10)));
  7254. return (isNaN(year) ? thisYear : year);
  7255. };
  7256. var year = determineYear(years[0]);
  7257. var endYear = Math.max(year, determineYear(years[1] || ''));
  7258. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  7259. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  7260. inst.yearshtml += '<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';
  7261. for (; year <= endYear; year++) {
  7262. inst.yearshtml += '<option value="' + year + '"' +
  7263. (year == drawYear ? ' selected="selected"' : '') +
  7264. '>' + year + '</option>';
  7265. }
  7266. inst.yearshtml += '</select>';
  7267. html += inst.yearshtml;
  7268. inst.yearshtml = null;
  7269. }
  7270. }
  7271. html += this._get(inst, 'yearSuffix');
  7272. if (showMonthAfterYear)
  7273. html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
  7274. html += '</div>'; // Close datepicker_header
  7275. return html;
  7276. },
  7277. /* Adjust one of the date sub-fields. */
  7278. _adjustInstDate: function(inst, offset, period) {
  7279. var year = inst.drawYear + (period == 'Y' ? offset : 0);
  7280. var month = inst.drawMonth + (period == 'M' ? offset : 0);
  7281. var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
  7282. (period == 'D' ? offset : 0);
  7283. var date = this._restrictMinMax(inst,
  7284. this._daylightSavingAdjust(new Date(year, month, day)));
  7285. inst.selectedDay = date.getDate();
  7286. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7287. inst.drawYear = inst.selectedYear = date.getFullYear();
  7288. if (period == 'M' || period == 'Y')
  7289. this._notifyChange(inst);
  7290. },
  7291. /* Ensure a date is within any min/max bounds. */
  7292. _restrictMinMax: function(inst, date) {
  7293. var minDate = this._getMinMaxDate(inst, 'min');
  7294. var maxDate = this._getMinMaxDate(inst, 'max');
  7295. var newDate = (minDate && date < minDate ? minDate : date);
  7296. newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
  7297. return newDate;
  7298. },
  7299. /* Notify change of month/year. */
  7300. _notifyChange: function(inst) {
  7301. var onChange = this._get(inst, 'onChangeMonthYear');
  7302. if (onChange)
  7303. onChange.apply((inst.input ? inst.input[0] : null),
  7304. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  7305. },
  7306. /* Determine the number of months to show. */
  7307. _getNumberOfMonths: function(inst) {
  7308. var numMonths = this._get(inst, 'numberOfMonths');
  7309. return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
  7310. },
  7311. /* Determine the current maximum date - ensure no time components are set. */
  7312. _getMinMaxDate: function(inst, minMax) {
  7313. return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
  7314. },
  7315. /* Find the number of days in a given month. */
  7316. _getDaysInMonth: function(year, month) {
  7317. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  7318. },
  7319. /* Find the day of the week of the first of a month. */
  7320. _getFirstDayOfMonth: function(year, month) {
  7321. return new Date(year, month, 1).getDay();
  7322. },
  7323. /* Determines if we should allow a "next/prev" month display change. */
  7324. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  7325. var numMonths = this._getNumberOfMonths(inst);
  7326. var date = this._daylightSavingAdjust(new Date(curYear,
  7327. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  7328. if (offset < 0)
  7329. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  7330. return this._isInRange(inst, date);
  7331. },
  7332. /* Is the given date in the accepted range? */
  7333. _isInRange: function(inst, date) {
  7334. var minDate = this._getMinMaxDate(inst, 'min');
  7335. var maxDate = this._getMinMaxDate(inst, 'max');
  7336. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  7337. (!maxDate || date.getTime() <= maxDate.getTime()));
  7338. },
  7339. /* Provide the configuration settings for formatting/parsing. */
  7340. _getFormatConfig: function(inst) {
  7341. var shortYearCutoff = this._get(inst, 'shortYearCutoff');
  7342. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  7343. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  7344. return {shortYearCutoff: shortYearCutoff,
  7345. dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
  7346. monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
  7347. },
  7348. /* Format the given date for display. */
  7349. _formatDate: function(inst, day, month, year) {
  7350. if (!day) {
  7351. inst.currentDay = inst.selectedDay;
  7352. inst.currentMonth = inst.selectedMonth;
  7353. inst.currentYear = inst.selectedYear;
  7354. }
  7355. var date = (day ? (typeof day == 'object' ? day :
  7356. this._daylightSavingAdjust(new Date(year, month, day))) :
  7357. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7358. return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
  7359. }
  7360. });
  7361. /*
  7362. * Bind hover events for datepicker elements.
  7363. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  7364. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  7365. */
  7366. function bindHover(dpDiv) {
  7367. var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
  7368. return dpDiv.bind('mouseout', function(event) {
  7369. var elem = $( event.target ).closest( selector );
  7370. if ( !elem.length ) {
  7371. return;
  7372. }
  7373. elem.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" );
  7374. })
  7375. .bind('mouseover', function(event) {
  7376. var elem = $( event.target ).closest( selector );
  7377. if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) ||
  7378. !elem.length ) {
  7379. return;
  7380. }
  7381. elem.parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
  7382. elem.addClass('ui-state-hover');
  7383. if (elem.hasClass('ui-datepicker-prev')) elem.addClass('ui-datepicker-prev-hover');
  7384. if (elem.hasClass('ui-datepicker-next')) elem.addClass('ui-datepicker-next-hover');
  7385. });
  7386. }
  7387. /* jQuery extend now ignores nulls! */
  7388. function extendRemove(target, props) {
  7389. $.extend(target, props);
  7390. for (var name in props)
  7391. if (props[name] == null || props[name] == undefined)
  7392. target[name] = props[name];
  7393. return target;
  7394. };
  7395. /* Determine whether an object is an array. */
  7396. function isArray(a) {
  7397. return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
  7398. (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
  7399. };
  7400. /* Invoke the datepicker functionality.
  7401. @param options string - a command, optionally followed by additional parameters or
  7402. Object - settings for attaching new datepicker functionality
  7403. @return jQuery object */
  7404. $.fn.datepicker = function(options){
  7405. /* Verify an empty collection wasn't passed - Fixes #6976 */
  7406. if ( !this.length ) {
  7407. return this;
  7408. }
  7409. /* Initialise the date picker. */
  7410. if (!$.datepicker.initialized) {
  7411. $(document).mousedown($.datepicker._checkExternalClick).
  7412. find('body').append($.datepicker.dpDiv);
  7413. $.datepicker.initialized = true;
  7414. }
  7415. var otherArgs = Array.prototype.slice.call(arguments, 1);
  7416. if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
  7417. return $.datepicker['_' + options + 'Datepicker'].
  7418. apply($.datepicker, [this[0]].concat(otherArgs));
  7419. if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
  7420. return $.datepicker['_' + options + 'Datepicker'].
  7421. apply($.datepicker, [this[0]].concat(otherArgs));
  7422. return this.each(function() {
  7423. typeof options == 'string' ?
  7424. $.datepicker['_' + options + 'Datepicker'].
  7425. apply($.datepicker, [this].concat(otherArgs)) :
  7426. $.datepicker._attachDatepicker(this, options);
  7427. });
  7428. };
  7429. $.datepicker = new Datepicker(); // singleton instance
  7430. $.datepicker.initialized = false;
  7431. $.datepicker.uuid = new Date().getTime();
  7432. $.datepicker.version = "1.8.24";
  7433. // Workaround for #4055
  7434. // Add another global to avoid noConflict issues with inline event handlers
  7435. window['DP_jQuery_' + dpuuid] = $;
  7436. })(jQuery);
  7437. (function( $, undefined ) {
  7438. var uiDialogClasses =
  7439. 'ui-dialog ' +
  7440. 'ui-widget ' +
  7441. 'ui-widget-content ' +
  7442. 'ui-corner-all ',
  7443. sizeRelatedOptions = {
  7444. buttons: true,
  7445. height: true,
  7446. maxHeight: true,
  7447. maxWidth: true,
  7448. minHeight: true,
  7449. minWidth: true,
  7450. width: true
  7451. },
  7452. resizableRelatedOptions = {
  7453. maxHeight: true,
  7454. maxWidth: true,
  7455. minHeight: true,
  7456. minWidth: true
  7457. };
  7458. $.widget("ui.dialog", {
  7459. options: {
  7460. autoOpen: true,
  7461. buttons: {},
  7462. closeOnEscape: true,
  7463. closeText: 'close',
  7464. dialogClass: '',
  7465. draggable: true,
  7466. hide: null,
  7467. height: 'auto',
  7468. maxHeight: false,
  7469. maxWidth: false,
  7470. minHeight: 150,
  7471. minWidth: 150,
  7472. modal: false,
  7473. position: {
  7474. my: 'center',
  7475. at: 'center',
  7476. collision: 'fit',
  7477. // ensure that the titlebar is never outside the document
  7478. using: function(pos) {
  7479. var topOffset = $(this).css(pos).offset().top;
  7480. if (topOffset < 0) {
  7481. $(this).css('top', pos.top - topOffset);
  7482. }
  7483. }
  7484. },
  7485. resizable: true,
  7486. show: null,
  7487. stack: true,
  7488. title: '',
  7489. width: 300,
  7490. zIndex: 1000
  7491. },
  7492. _create: function() {
  7493. this.originalTitle = this.element.attr('title');
  7494. // #5742 - .attr() might return a DOMElement
  7495. if ( typeof this.originalTitle !== "string" ) {
  7496. this.originalTitle = "";
  7497. }
  7498. this.options.title = this.options.title || this.originalTitle;
  7499. var self = this,
  7500. options = self.options,
  7501. title = options.title || '&#160;',
  7502. titleId = $.ui.dialog.getTitleId(self.element),
  7503. uiDialog = (self.uiDialog = $('<div></div>'))
  7504. .appendTo(document.body)
  7505. .hide()
  7506. .addClass(uiDialogClasses + options.dialogClass)
  7507. .css({
  7508. zIndex: options.zIndex
  7509. })
  7510. // setting tabIndex makes the div focusable
  7511. // setting outline to 0 prevents a border on focus in Mozilla
  7512. .attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
  7513. if (options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7514. event.keyCode === $.ui.keyCode.ESCAPE) {
  7515. self.close(event);
  7516. event.preventDefault();
  7517. }
  7518. })
  7519. .attr({
  7520. role: 'dialog',
  7521. 'aria-labelledby': titleId
  7522. })
  7523. .mousedown(function(event) {
  7524. self.moveToTop(false, event);
  7525. }),
  7526. uiDialogContent = self.element
  7527. .show()
  7528. .removeAttr('title')
  7529. .addClass(
  7530. 'ui-dialog-content ' +
  7531. 'ui-widget-content')
  7532. .appendTo(uiDialog),
  7533. uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
  7534. .addClass(
  7535. 'ui-dialog-titlebar ' +
  7536. 'ui-widget-header ' +
  7537. 'ui-corner-all ' +
  7538. 'ui-helper-clearfix'
  7539. )
  7540. .prependTo(uiDialog),
  7541. uiDialogTitlebarClose = $('<a href="#"></a>')
  7542. .addClass(
  7543. 'ui-dialog-titlebar-close ' +
  7544. 'ui-corner-all'
  7545. )
  7546. .attr('role', 'button')
  7547. .hover(
  7548. function() {
  7549. uiDialogTitlebarClose.addClass('ui-state-hover');
  7550. },
  7551. function() {
  7552. uiDialogTitlebarClose.removeClass('ui-state-hover');
  7553. }
  7554. )
  7555. .focus(function() {
  7556. uiDialogTitlebarClose.addClass('ui-state-focus');
  7557. })
  7558. .blur(function() {
  7559. uiDialogTitlebarClose.removeClass('ui-state-focus');
  7560. })
  7561. .click(function(event) {
  7562. self.close(event);
  7563. return false;
  7564. })
  7565. .appendTo(uiDialogTitlebar),
  7566. uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
  7567. .addClass(
  7568. 'ui-icon ' +
  7569. 'ui-icon-closethick'
  7570. )
  7571. .text(options.closeText)
  7572. .appendTo(uiDialogTitlebarClose),
  7573. uiDialogTitle = $('<span></span>')
  7574. .addClass('ui-dialog-title')
  7575. .attr('id', titleId)
  7576. .html(title)
  7577. .prependTo(uiDialogTitlebar);
  7578. //handling of deprecated beforeclose (vs beforeClose) option
  7579. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  7580. //TODO: remove in 1.9pre
  7581. if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
  7582. options.beforeClose = options.beforeclose;
  7583. }
  7584. uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
  7585. if (options.draggable && $.fn.draggable) {
  7586. self._makeDraggable();
  7587. }
  7588. if (options.resizable && $.fn.resizable) {
  7589. self._makeResizable();
  7590. }
  7591. self._createButtons(options.buttons);
  7592. self._isOpen = false;
  7593. if ($.fn.bgiframe) {
  7594. uiDialog.bgiframe();
  7595. }
  7596. },
  7597. _init: function() {
  7598. if ( this.options.autoOpen ) {
  7599. this.open();
  7600. }
  7601. },
  7602. destroy: function() {
  7603. var self = this;
  7604. if (self.overlay) {
  7605. self.overlay.destroy();
  7606. }
  7607. self.uiDialog.hide();
  7608. self.element
  7609. .unbind('.dialog')
  7610. .removeData('dialog')
  7611. .removeClass('ui-dialog-content ui-widget-content')
  7612. .hide().appendTo('body');
  7613. self.uiDialog.remove();
  7614. if (self.originalTitle) {
  7615. self.element.attr('title', self.originalTitle);
  7616. }
  7617. return self;
  7618. },
  7619. widget: function() {
  7620. return this.uiDialog;
  7621. },
  7622. close: function(event) {
  7623. var self = this,
  7624. maxZ, thisZ;
  7625. if (false === self._trigger('beforeClose', event)) {
  7626. return;
  7627. }
  7628. if (self.overlay) {
  7629. self.overlay.destroy();
  7630. }
  7631. self.uiDialog.unbind('keypress.ui-dialog');
  7632. self._isOpen = false;
  7633. if (self.options.hide) {
  7634. self.uiDialog.hide(self.options.hide, function() {
  7635. self._trigger('close', event);
  7636. });
  7637. } else {
  7638. self.uiDialog.hide();
  7639. self._trigger('close', event);
  7640. }
  7641. $.ui.dialog.overlay.resize();
  7642. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  7643. if (self.options.modal) {
  7644. maxZ = 0;
  7645. $('.ui-dialog').each(function() {
  7646. if (this !== self.uiDialog[0]) {
  7647. thisZ = $(this).css('z-index');
  7648. if(!isNaN(thisZ)) {
  7649. maxZ = Math.max(maxZ, thisZ);
  7650. }
  7651. }
  7652. });
  7653. $.ui.dialog.maxZ = maxZ;
  7654. }
  7655. return self;
  7656. },
  7657. isOpen: function() {
  7658. return this._isOpen;
  7659. },
  7660. // the force parameter allows us to move modal dialogs to their correct
  7661. // position on open
  7662. moveToTop: function(force, event) {
  7663. var self = this,
  7664. options = self.options,
  7665. saveScroll;
  7666. if ((options.modal && !force) ||
  7667. (!options.stack && !options.modal)) {
  7668. return self._trigger('focus', event);
  7669. }
  7670. if (options.zIndex > $.ui.dialog.maxZ) {
  7671. $.ui.dialog.maxZ = options.zIndex;
  7672. }
  7673. if (self.overlay) {
  7674. $.ui.dialog.maxZ += 1;
  7675. self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
  7676. }
  7677. //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
  7678. // http://ui.jquery.com/bugs/ticket/3193
  7679. saveScroll = { scrollTop: self.element.scrollTop(), scrollLeft: self.element.scrollLeft() };
  7680. $.ui.dialog.maxZ += 1;
  7681. self.uiDialog.css('z-index', $.ui.dialog.maxZ);
  7682. self.element.attr(saveScroll);
  7683. self._trigger('focus', event);
  7684. return self;
  7685. },
  7686. open: function() {
  7687. if (this._isOpen) { return; }
  7688. var self = this,
  7689. options = self.options,
  7690. uiDialog = self.uiDialog;
  7691. self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
  7692. self._size();
  7693. self._position(options.position);
  7694. uiDialog.show(options.show);
  7695. self.moveToTop(true);
  7696. // prevent tabbing out of modal dialogs
  7697. if ( options.modal ) {
  7698. uiDialog.bind( "keydown.ui-dialog", function( event ) {
  7699. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  7700. return;
  7701. }
  7702. var tabbables = $(':tabbable', this),
  7703. first = tabbables.filter(':first'),
  7704. last = tabbables.filter(':last');
  7705. if (event.target === last[0] && !event.shiftKey) {
  7706. first.focus(1);
  7707. return false;
  7708. } else if (event.target === first[0] && event.shiftKey) {
  7709. last.focus(1);
  7710. return false;
  7711. }
  7712. });
  7713. }
  7714. // set focus to the first tabbable element in the content area or the first button
  7715. // if there are no tabbable elements, set focus on the dialog itself
  7716. $(self.element.find(':tabbable').get().concat(
  7717. uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat(
  7718. uiDialog.get()))).eq(0).focus();
  7719. self._isOpen = true;
  7720. self._trigger('open');
  7721. return self;
  7722. },
  7723. _createButtons: function(buttons) {
  7724. var self = this,
  7725. hasButtons = false,
  7726. uiDialogButtonPane = $('<div></div>')
  7727. .addClass(
  7728. 'ui-dialog-buttonpane ' +
  7729. 'ui-widget-content ' +
  7730. 'ui-helper-clearfix'
  7731. ),
  7732. uiButtonSet = $( "<div></div>" )
  7733. .addClass( "ui-dialog-buttonset" )
  7734. .appendTo( uiDialogButtonPane );
  7735. // if we already have a button pane, remove it
  7736. self.uiDialog.find('.ui-dialog-buttonpane').remove();
  7737. if (typeof buttons === 'object' && buttons !== null) {
  7738. $.each(buttons, function() {
  7739. return !(hasButtons = true);
  7740. });
  7741. }
  7742. if (hasButtons) {
  7743. $.each(buttons, function(name, props) {
  7744. props = $.isFunction( props ) ?
  7745. { click: props, text: name } :
  7746. props;
  7747. var button = $('<button type="button"></button>')
  7748. .click(function() {
  7749. props.click.apply(self.element[0], arguments);
  7750. })
  7751. .appendTo(uiButtonSet);
  7752. // can't use .attr( props, true ) with jQuery 1.3.2.
  7753. $.each( props, function( key, value ) {
  7754. if ( key === "click" ) {
  7755. return;
  7756. }
  7757. if ( key in button ) {
  7758. button[ key ]( value );
  7759. } else {
  7760. button.attr( key, value );
  7761. }
  7762. });
  7763. if ($.fn.button) {
  7764. button.button();
  7765. }
  7766. });
  7767. uiDialogButtonPane.appendTo(self.uiDialog);
  7768. }
  7769. },
  7770. _makeDraggable: function() {
  7771. var self = this,
  7772. options = self.options,
  7773. doc = $(document),
  7774. heightBeforeDrag;
  7775. function filteredUi(ui) {
  7776. return {
  7777. position: ui.position,
  7778. offset: ui.offset
  7779. };
  7780. }
  7781. self.uiDialog.draggable({
  7782. cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
  7783. handle: '.ui-dialog-titlebar',
  7784. containment: 'document',
  7785. start: function(event, ui) {
  7786. heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
  7787. $(this).height($(this).height()).addClass("ui-dialog-dragging");
  7788. self._trigger('dragStart', event, filteredUi(ui));
  7789. },
  7790. drag: function(event, ui) {
  7791. self._trigger('drag', event, filteredUi(ui));
  7792. },
  7793. stop: function(event, ui) {
  7794. options.position = [ui.position.left - doc.scrollLeft(),
  7795. ui.position.top - doc.scrollTop()];
  7796. $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
  7797. self._trigger('dragStop', event, filteredUi(ui));
  7798. $.ui.dialog.overlay.resize();
  7799. }
  7800. });
  7801. },
  7802. _makeResizable: function(handles) {
  7803. handles = (handles === undefined ? this.options.resizable : handles);
  7804. var self = this,
  7805. options = self.options,
  7806. // .ui-resizable has position: relative defined in the stylesheet
  7807. // but dialogs have to use absolute or fixed positioning
  7808. position = self.uiDialog.css('position'),
  7809. resizeHandles = (typeof handles === 'string' ?
  7810. handles :
  7811. 'n,e,s,w,se,sw,ne,nw'
  7812. );
  7813. function filteredUi(ui) {
  7814. return {
  7815. originalPosition: ui.originalPosition,
  7816. originalSize: ui.originalSize,
  7817. position: ui.position,
  7818. size: ui.size
  7819. };
  7820. }
  7821. self.uiDialog.resizable({
  7822. cancel: '.ui-dialog-content',
  7823. containment: 'document',
  7824. alsoResize: self.element,
  7825. maxWidth: options.maxWidth,
  7826. maxHeight: options.maxHeight,
  7827. minWidth: options.minWidth,
  7828. minHeight: self._minHeight(),
  7829. handles: resizeHandles,
  7830. start: function(event, ui) {
  7831. $(this).addClass("ui-dialog-resizing");
  7832. self._trigger('resizeStart', event, filteredUi(ui));
  7833. },
  7834. resize: function(event, ui) {
  7835. self._trigger('resize', event, filteredUi(ui));
  7836. },
  7837. stop: function(event, ui) {
  7838. $(this).removeClass("ui-dialog-resizing");
  7839. options.height = $(this).height();
  7840. options.width = $(this).width();
  7841. self._trigger('resizeStop', event, filteredUi(ui));
  7842. $.ui.dialog.overlay.resize();
  7843. }
  7844. })
  7845. .css('position', position)
  7846. .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
  7847. },
  7848. _minHeight: function() {
  7849. var options = this.options;
  7850. if (options.height === 'auto') {
  7851. return options.minHeight;
  7852. } else {
  7853. return Math.min(options.minHeight, options.height);
  7854. }
  7855. },
  7856. _position: function(position) {
  7857. var myAt = [],
  7858. offset = [0, 0],
  7859. isVisible;
  7860. if (position) {
  7861. // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
  7862. // if (typeof position == 'string' || $.isArray(position)) {
  7863. // myAt = $.isArray(position) ? position : position.split(' ');
  7864. if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
  7865. myAt = position.split ? position.split(' ') : [position[0], position[1]];
  7866. if (myAt.length === 1) {
  7867. myAt[1] = myAt[0];
  7868. }
  7869. $.each(['left', 'top'], function(i, offsetPosition) {
  7870. if (+myAt[i] === myAt[i]) {
  7871. offset[i] = myAt[i];
  7872. myAt[i] = offsetPosition;
  7873. }
  7874. });
  7875. position = {
  7876. my: myAt.join(" "),
  7877. at: myAt.join(" "),
  7878. offset: offset.join(" ")
  7879. };
  7880. }
  7881. position = $.extend({}, $.ui.dialog.prototype.options.position, position);
  7882. } else {
  7883. position = $.ui.dialog.prototype.options.position;
  7884. }
  7885. // need to show the dialog to get the actual offset in the position plugin
  7886. isVisible = this.uiDialog.is(':visible');
  7887. if (!isVisible) {
  7888. this.uiDialog.show();
  7889. }
  7890. this.uiDialog
  7891. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  7892. .css({ top: 0, left: 0 })
  7893. .position($.extend({ of: window }, position));
  7894. if (!isVisible) {
  7895. this.uiDialog.hide();
  7896. }
  7897. },
  7898. _setOptions: function( options ) {
  7899. var self = this,
  7900. resizableOptions = {},
  7901. resize = false;
  7902. $.each( options, function( key, value ) {
  7903. self._setOption( key, value );
  7904. if ( key in sizeRelatedOptions ) {
  7905. resize = true;
  7906. }
  7907. if ( key in resizableRelatedOptions ) {
  7908. resizableOptions[ key ] = value;
  7909. }
  7910. });
  7911. if ( resize ) {
  7912. this._size();
  7913. }
  7914. if ( this.uiDialog.is( ":data(resizable)" ) ) {
  7915. this.uiDialog.resizable( "option", resizableOptions );
  7916. }
  7917. },
  7918. _setOption: function(key, value){
  7919. var self = this,
  7920. uiDialog = self.uiDialog;
  7921. switch (key) {
  7922. //handling of deprecated beforeclose (vs beforeClose) option
  7923. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  7924. //TODO: remove in 1.9pre
  7925. case "beforeclose":
  7926. key = "beforeClose";
  7927. break;
  7928. case "buttons":
  7929. self._createButtons(value);
  7930. break;
  7931. case "closeText":
  7932. // ensure that we always pass a string
  7933. self.uiDialogTitlebarCloseText.text("" + value);
  7934. break;
  7935. case "dialogClass":
  7936. uiDialog
  7937. .removeClass(self.options.dialogClass)
  7938. .addClass(uiDialogClasses + value);
  7939. break;
  7940. case "disabled":
  7941. if (value) {
  7942. uiDialog.addClass('ui-dialog-disabled');
  7943. } else {
  7944. uiDialog.removeClass('ui-dialog-disabled');
  7945. }
  7946. break;
  7947. case "draggable":
  7948. var isDraggable = uiDialog.is( ":data(draggable)" );
  7949. if ( isDraggable && !value ) {
  7950. uiDialog.draggable( "destroy" );
  7951. }
  7952. if ( !isDraggable && value ) {
  7953. self._makeDraggable();
  7954. }
  7955. break;
  7956. case "position":
  7957. self._position(value);
  7958. break;
  7959. case "resizable":
  7960. // currently resizable, becoming non-resizable
  7961. var isResizable = uiDialog.is( ":data(resizable)" );
  7962. if (isResizable && !value) {
  7963. uiDialog.resizable('destroy');
  7964. }
  7965. // currently resizable, changing handles
  7966. if (isResizable && typeof value === 'string') {
  7967. uiDialog.resizable('option', 'handles', value);
  7968. }
  7969. // currently non-resizable, becoming resizable
  7970. if (!isResizable && value !== false) {
  7971. self._makeResizable(value);
  7972. }
  7973. break;
  7974. case "title":
  7975. // convert whatever was passed in o a string, for html() to not throw up
  7976. $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
  7977. break;
  7978. }
  7979. $.Widget.prototype._setOption.apply(self, arguments);
  7980. },
  7981. _size: function() {
  7982. /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  7983. * divs will both have width and height set, so we need to reset them
  7984. */
  7985. var options = this.options,
  7986. nonContentHeight,
  7987. minContentHeight,
  7988. isVisible = this.uiDialog.is( ":visible" );
  7989. // reset content sizing
  7990. this.element.show().css({
  7991. width: 'auto',
  7992. minHeight: 0,
  7993. height: 0
  7994. });
  7995. if (options.minWidth > options.width) {
  7996. options.width = options.minWidth;
  7997. }
  7998. // reset wrapper sizing
  7999. // determine the height of all the non-content elements
  8000. nonContentHeight = this.uiDialog.css({
  8001. height: 'auto',
  8002. width: options.width
  8003. })
  8004. .height();
  8005. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8006. if ( options.height === "auto" ) {
  8007. // only needed for IE6 support
  8008. if ( $.support.minHeight ) {
  8009. this.element.css({
  8010. minHeight: minContentHeight,
  8011. height: "auto"
  8012. });
  8013. } else {
  8014. this.uiDialog.show();
  8015. var autoHeight = this.element.css( "height", "auto" ).height();
  8016. if ( !isVisible ) {
  8017. this.uiDialog.hide();
  8018. }
  8019. this.element.height( Math.max( autoHeight, minContentHeight ) );
  8020. }
  8021. } else {
  8022. this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
  8023. }
  8024. if (this.uiDialog.is(':data(resizable)')) {
  8025. this.uiDialog.resizable('option', 'minHeight', this._minHeight());
  8026. }
  8027. }
  8028. });
  8029. $.extend($.ui.dialog, {
  8030. version: "1.8.24",
  8031. uuid: 0,
  8032. maxZ: 0,
  8033. getTitleId: function($el) {
  8034. var id = $el.attr('id');
  8035. if (!id) {
  8036. this.uuid += 1;
  8037. id = this.uuid;
  8038. }
  8039. return 'ui-dialog-title-' + id;
  8040. },
  8041. overlay: function(dialog) {
  8042. this.$el = $.ui.dialog.overlay.create(dialog);
  8043. }
  8044. });
  8045. $.extend($.ui.dialog.overlay, {
  8046. instances: [],
  8047. // reuse old instances due to IE memory leak with alpha transparency (see #5185)
  8048. oldInstances: [],
  8049. maxZ: 0,
  8050. events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
  8051. function(event) { return event + '.dialog-overlay'; }).join(' '),
  8052. create: function(dialog) {
  8053. if (this.instances.length === 0) {
  8054. // prevent use of anchors and inputs
  8055. // we use a setTimeout in case the overlay is created from an
  8056. // event that we're going to be cancelling (see #2804)
  8057. setTimeout(function() {
  8058. // handle $(el).dialog().dialog('close') (see #4065)
  8059. if ($.ui.dialog.overlay.instances.length) {
  8060. $(document).bind($.ui.dialog.overlay.events, function(event) {
  8061. // stop events if the z-index of the target is < the z-index of the overlay
  8062. // we cannot return true when we don't want to cancel the event (#3523)
  8063. if ($(event.target).zIndex() < $.ui.dialog.overlay.maxZ) {
  8064. return false;
  8065. }
  8066. });
  8067. }
  8068. }, 1);
  8069. // allow closing by pressing the escape key
  8070. $(document).bind('keydown.dialog-overlay', function(event) {
  8071. if (dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8072. event.keyCode === $.ui.keyCode.ESCAPE) {
  8073. dialog.close(event);
  8074. event.preventDefault();
  8075. }
  8076. });
  8077. // handle window resize
  8078. $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
  8079. }
  8080. var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
  8081. .appendTo(document.body)
  8082. .css({
  8083. width: this.width(),
  8084. height: this.height()
  8085. });
  8086. if ($.fn.bgiframe) {
  8087. $el.bgiframe();
  8088. }
  8089. this.instances.push($el);
  8090. return $el;
  8091. },
  8092. destroy: function($el) {
  8093. var indexOf = $.inArray($el, this.instances);
  8094. if (indexOf != -1){
  8095. this.oldInstances.push(this.instances.splice(indexOf, 1)[0]);
  8096. }
  8097. if (this.instances.length === 0) {
  8098. $([document, window]).unbind('.dialog-overlay');
  8099. }
  8100. $el.remove();
  8101. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  8102. var maxZ = 0;
  8103. $.each(this.instances, function() {
  8104. maxZ = Math.max(maxZ, this.css('z-index'));
  8105. });
  8106. this.maxZ = maxZ;
  8107. },
  8108. height: function() {
  8109. var scrollHeight,
  8110. offsetHeight;
  8111. // handle IE 6
  8112. if ($.browser.msie && $.browser.version < 7) {
  8113. scrollHeight = Math.max(
  8114. document.documentElement.scrollHeight,
  8115. document.body.scrollHeight
  8116. );
  8117. offsetHeight = Math.max(
  8118. document.documentElement.offsetHeight,
  8119. document.body.offsetHeight
  8120. );
  8121. if (scrollHeight < offsetHeight) {
  8122. return $(window).height() + 'px';
  8123. } else {
  8124. return scrollHeight + 'px';
  8125. }
  8126. // handle "good" browsers
  8127. } else {
  8128. return $(document).height() + 'px';
  8129. }
  8130. },
  8131. width: function() {
  8132. var scrollWidth,
  8133. offsetWidth;
  8134. // handle IE
  8135. if ( $.browser.msie ) {
  8136. scrollWidth = Math.max(
  8137. document.documentElement.scrollWidth,
  8138. document.body.scrollWidth
  8139. );
  8140. offsetWidth = Math.max(
  8141. document.documentElement.offsetWidth,
  8142. document.body.offsetWidth
  8143. );
  8144. if (scrollWidth < offsetWidth) {
  8145. return $(window).width() + 'px';
  8146. } else {
  8147. return scrollWidth + 'px';
  8148. }
  8149. // handle "good" browsers
  8150. } else {
  8151. return $(document).width() + 'px';
  8152. }
  8153. },
  8154. resize: function() {
  8155. /* If the dialog is draggable and the user drags it past the
  8156. * right edge of the window, the document becomes wider so we
  8157. * need to stretch the overlay. If the user then drags the
  8158. * dialog back to the left, the document will become narrower,
  8159. * so we need to shrink the overlay to the appropriate size.
  8160. * This is handled by shrinking the overlay before setting it
  8161. * to the full document size.
  8162. */
  8163. var $overlays = $([]);
  8164. $.each($.ui.dialog.overlay.instances, function() {
  8165. $overlays = $overlays.add(this);
  8166. });
  8167. $overlays.css({
  8168. width: 0,
  8169. height: 0
  8170. }).css({
  8171. width: $.ui.dialog.overlay.width(),
  8172. height: $.ui.dialog.overlay.height()
  8173. });
  8174. }
  8175. });
  8176. $.extend($.ui.dialog.overlay.prototype, {
  8177. destroy: function() {
  8178. $.ui.dialog.overlay.destroy(this.$el);
  8179. }
  8180. });
  8181. }(jQuery));
  8182. (function( $, undefined ) {
  8183. $.ui = $.ui || {};
  8184. var horizontalPositions = /left|center|right/,
  8185. verticalPositions = /top|center|bottom/,
  8186. center = "center",
  8187. support = {},
  8188. _position = $.fn.position,
  8189. _offset = $.fn.offset;
  8190. $.fn.position = function( options ) {
  8191. if ( !options || !options.of ) {
  8192. return _position.apply( this, arguments );
  8193. }
  8194. // make a copy, we don't want to modify arguments
  8195. options = $.extend( {}, options );
  8196. var target = $( options.of ),
  8197. targetElem = target[0],
  8198. collision = ( options.collision || "flip" ).split( " " ),
  8199. offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
  8200. targetWidth,
  8201. targetHeight,
  8202. basePosition;
  8203. if ( targetElem.nodeType === 9 ) {
  8204. targetWidth = target.width();
  8205. targetHeight = target.height();
  8206. basePosition = { top: 0, left: 0 };
  8207. // TODO: use $.isWindow() in 1.9
  8208. } else if ( targetElem.setTimeout ) {
  8209. targetWidth = target.width();
  8210. targetHeight = target.height();
  8211. basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
  8212. } else if ( targetElem.preventDefault ) {
  8213. // force left top to allow flipping
  8214. options.at = "left top";
  8215. targetWidth = targetHeight = 0;
  8216. basePosition = { top: options.of.pageY, left: options.of.pageX };
  8217. } else {
  8218. targetWidth = target.outerWidth();
  8219. targetHeight = target.outerHeight();
  8220. basePosition = target.offset();
  8221. }
  8222. // force my and at to have valid horizontal and veritcal positions
  8223. // if a value is missing or invalid, it will be converted to center
  8224. $.each( [ "my", "at" ], function() {
  8225. var pos = ( options[this] || "" ).split( " " );
  8226. if ( pos.length === 1) {
  8227. pos = horizontalPositions.test( pos[0] ) ?
  8228. pos.concat( [center] ) :
  8229. verticalPositions.test( pos[0] ) ?
  8230. [ center ].concat( pos ) :
  8231. [ center, center ];
  8232. }
  8233. pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
  8234. pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
  8235. options[ this ] = pos;
  8236. });
  8237. // normalize collision option
  8238. if ( collision.length === 1 ) {
  8239. collision[ 1 ] = collision[ 0 ];
  8240. }
  8241. // normalize offset option
  8242. offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
  8243. if ( offset.length === 1 ) {
  8244. offset[ 1 ] = offset[ 0 ];
  8245. }
  8246. offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
  8247. if ( options.at[0] === "right" ) {
  8248. basePosition.left += targetWidth;
  8249. } else if ( options.at[0] === center ) {
  8250. basePosition.left += targetWidth / 2;
  8251. }
  8252. if ( options.at[1] === "bottom" ) {
  8253. basePosition.top += targetHeight;
  8254. } else if ( options.at[1] === center ) {
  8255. basePosition.top += targetHeight / 2;
  8256. }
  8257. basePosition.left += offset[ 0 ];
  8258. basePosition.top += offset[ 1 ];
  8259. return this.each(function() {
  8260. var elem = $( this ),
  8261. elemWidth = elem.outerWidth(),
  8262. elemHeight = elem.outerHeight(),
  8263. marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
  8264. marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
  8265. collisionWidth = elemWidth + marginLeft +
  8266. ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
  8267. collisionHeight = elemHeight + marginTop +
  8268. ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
  8269. position = $.extend( {}, basePosition ),
  8270. collisionPosition;
  8271. if ( options.my[0] === "right" ) {
  8272. position.left -= elemWidth;
  8273. } else if ( options.my[0] === center ) {
  8274. position.left -= elemWidth / 2;
  8275. }
  8276. if ( options.my[1] === "bottom" ) {
  8277. position.top -= elemHeight;
  8278. } else if ( options.my[1] === center ) {
  8279. position.top -= elemHeight / 2;
  8280. }
  8281. // prevent fractions if jQuery version doesn't support them (see #5280)
  8282. if ( !support.fractions ) {
  8283. position.left = Math.round( position.left );
  8284. position.top = Math.round( position.top );
  8285. }
  8286. collisionPosition = {
  8287. left: position.left - marginLeft,
  8288. top: position.top - marginTop
  8289. };
  8290. $.each( [ "left", "top" ], function( i, dir ) {
  8291. if ( $.ui.position[ collision[i] ] ) {
  8292. $.ui.position[ collision[i] ][ dir ]( position, {
  8293. targetWidth: targetWidth,
  8294. targetHeight: targetHeight,
  8295. elemWidth: elemWidth,
  8296. elemHeight: elemHeight,
  8297. collisionPosition: collisionPosition,
  8298. collisionWidth: collisionWidth,
  8299. collisionHeight: collisionHeight,
  8300. offset: offset,
  8301. my: options.my,
  8302. at: options.at
  8303. });
  8304. }
  8305. });
  8306. if ( $.fn.bgiframe ) {
  8307. elem.bgiframe();
  8308. }
  8309. elem.offset( $.extend( position, { using: options.using } ) );
  8310. });
  8311. };
  8312. $.ui.position = {
  8313. fit: {
  8314. left: function( position, data ) {
  8315. var win = $( window ),
  8316. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
  8317. position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
  8318. },
  8319. top: function( position, data ) {
  8320. var win = $( window ),
  8321. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
  8322. position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
  8323. }
  8324. },
  8325. flip: {
  8326. left: function( position, data ) {
  8327. if ( data.at[0] === center ) {
  8328. return;
  8329. }
  8330. var win = $( window ),
  8331. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
  8332. myOffset = data.my[ 0 ] === "left" ?
  8333. -data.elemWidth :
  8334. data.my[ 0 ] === "right" ?
  8335. data.elemWidth :
  8336. 0,
  8337. atOffset = data.at[ 0 ] === "left" ?
  8338. data.targetWidth :
  8339. -data.targetWidth,
  8340. offset = -2 * data.offset[ 0 ];
  8341. position.left += data.collisionPosition.left < 0 ?
  8342. myOffset + atOffset + offset :
  8343. over > 0 ?
  8344. myOffset + atOffset + offset :
  8345. 0;
  8346. },
  8347. top: function( position, data ) {
  8348. if ( data.at[1] === center ) {
  8349. return;
  8350. }
  8351. var win = $( window ),
  8352. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
  8353. myOffset = data.my[ 1 ] === "top" ?
  8354. -data.elemHeight :
  8355. data.my[ 1 ] === "bottom" ?
  8356. data.elemHeight :
  8357. 0,
  8358. atOffset = data.at[ 1 ] === "top" ?
  8359. data.targetHeight :
  8360. -data.targetHeight,
  8361. offset = -2 * data.offset[ 1 ];
  8362. position.top += data.collisionPosition.top < 0 ?
  8363. myOffset + atOffset + offset :
  8364. over > 0 ?
  8365. myOffset + atOffset + offset :
  8366. 0;
  8367. }
  8368. }
  8369. };
  8370. // offset setter from jQuery 1.4
  8371. if ( !$.offset.setOffset ) {
  8372. $.offset.setOffset = function( elem, options ) {
  8373. // set position first, in-case top/left are set even on static elem
  8374. if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
  8375. elem.style.position = "relative";
  8376. }
  8377. var curElem = $( elem ),
  8378. curOffset = curElem.offset(),
  8379. curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
  8380. curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
  8381. props = {
  8382. top: (options.top - curOffset.top) + curTop,
  8383. left: (options.left - curOffset.left) + curLeft
  8384. };
  8385. if ( 'using' in options ) {
  8386. options.using.call( elem, props );
  8387. } else {
  8388. curElem.css( props );
  8389. }
  8390. };
  8391. $.fn.offset = function( options ) {
  8392. var elem = this[ 0 ];
  8393. if ( !elem || !elem.ownerDocument ) { return null; }
  8394. if ( options ) {
  8395. if ( $.isFunction( options ) ) {
  8396. return this.each(function( i ) {
  8397. $( this ).offset( options.call( this, i, $( this ).offset() ) );
  8398. });
  8399. }
  8400. return this.each(function() {
  8401. $.offset.setOffset( this, options );
  8402. });
  8403. }
  8404. return _offset.call( this );
  8405. };
  8406. }
  8407. // jQuery <1.4.3 uses curCSS, in 1.4.3 - 1.7.2 curCSS = css, 1.8+ only has css
  8408. if ( !$.curCSS ) {
  8409. $.curCSS = $.css;
  8410. }
  8411. // fraction support test (older versions of jQuery don't support fractions)
  8412. (function () {
  8413. var body = document.getElementsByTagName( "body" )[ 0 ],
  8414. div = document.createElement( "div" ),
  8415. testElement, testElementParent, testElementStyle, offset, offsetTotal;
  8416. //Create a "fake body" for testing based on method used in jQuery.support
  8417. testElement = document.createElement( body ? "div" : "body" );
  8418. testElementStyle = {
  8419. visibility: "hidden",
  8420. width: 0,
  8421. height: 0,
  8422. border: 0,
  8423. margin: 0,
  8424. background: "none"
  8425. };
  8426. if ( body ) {
  8427. $.extend( testElementStyle, {
  8428. position: "absolute",
  8429. left: "-1000px",
  8430. top: "-1000px"
  8431. });
  8432. }
  8433. for ( var i in testElementStyle ) {
  8434. testElement.style[ i ] = testElementStyle[ i ];
  8435. }
  8436. testElement.appendChild( div );
  8437. testElementParent = body || document.documentElement;
  8438. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  8439. div.style.cssText = "position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";
  8440. offset = $( div ).offset( function( _, offset ) {
  8441. return offset;
  8442. }).offset();
  8443. testElement.innerHTML = "";
  8444. testElementParent.removeChild( testElement );
  8445. offsetTotal = offset.top + offset.left + ( body ? 2000 : 0 );
  8446. support.fractions = offsetTotal > 21 && offsetTotal < 22;
  8447. })();
  8448. }( jQuery ));
  8449. (function( $, undefined ) {
  8450. $.widget( "ui.progressbar", {
  8451. options: {
  8452. value: 0,
  8453. max: 100
  8454. },
  8455. min: 0,
  8456. _create: function() {
  8457. this.element
  8458. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8459. .attr({
  8460. role: "progressbar",
  8461. "aria-valuemin": this.min,
  8462. "aria-valuemax": this.options.max,
  8463. "aria-valuenow": this._value()
  8464. });
  8465. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8466. .appendTo( this.element );
  8467. this.oldValue = this._value();
  8468. this._refreshValue();
  8469. },
  8470. destroy: function() {
  8471. this.element
  8472. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8473. .removeAttr( "role" )
  8474. .removeAttr( "aria-valuemin" )
  8475. .removeAttr( "aria-valuemax" )
  8476. .removeAttr( "aria-valuenow" );
  8477. this.valueDiv.remove();
  8478. $.Widget.prototype.destroy.apply( this, arguments );
  8479. },
  8480. value: function( newValue ) {
  8481. if ( newValue === undefined ) {
  8482. return this._value();
  8483. }
  8484. this._setOption( "value", newValue );
  8485. return this;
  8486. },
  8487. _setOption: function( key, value ) {
  8488. if ( key === "value" ) {
  8489. this.options.value = value;
  8490. this._refreshValue();
  8491. if ( this._value() === this.options.max ) {
  8492. this._trigger( "complete" );
  8493. }
  8494. }
  8495. $.Widget.prototype._setOption.apply( this, arguments );
  8496. },
  8497. _value: function() {
  8498. var val = this.options.value;
  8499. // normalize invalid value
  8500. if ( typeof val !== "number" ) {
  8501. val = 0;
  8502. }
  8503. return Math.min( this.options.max, Math.max( this.min, val ) );
  8504. },
  8505. _percentage: function() {
  8506. return 100 * this._value() / this.options.max;
  8507. },
  8508. _refreshValue: function() {
  8509. var value = this.value();
  8510. var percentage = this._percentage();
  8511. if ( this.oldValue !== value ) {
  8512. this.oldValue = value;
  8513. this._trigger( "change" );
  8514. }
  8515. this.valueDiv
  8516. .toggle( value > this.min )
  8517. .toggleClass( "ui-corner-right", value === this.options.max )
  8518. .width( percentage.toFixed(0) + "%" );
  8519. this.element.attr( "aria-valuenow", value );
  8520. }
  8521. });
  8522. $.extend( $.ui.progressbar, {
  8523. version: "1.8.24"
  8524. });
  8525. })( jQuery );
  8526. (function( $, undefined ) {
  8527. // number of pages in a slider
  8528. // (how many times can you page up/down to go through the whole range)
  8529. var numPages = 5;
  8530. $.widget( "ui.slider", $.ui.mouse, {
  8531. widgetEventPrefix: "slide",
  8532. options: {
  8533. animate: false,
  8534. distance: 0,
  8535. max: 100,
  8536. min: 0,
  8537. orientation: "horizontal",
  8538. range: false,
  8539. step: 1,
  8540. value: 0,
  8541. values: null
  8542. },
  8543. _create: function() {
  8544. var self = this,
  8545. o = this.options,
  8546. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  8547. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  8548. handleCount = ( o.values && o.values.length ) || 1,
  8549. handles = [];
  8550. this._keySliding = false;
  8551. this._mouseSliding = false;
  8552. this._animateOff = true;
  8553. this._handleIndex = null;
  8554. this._detectOrientation();
  8555. this._mouseInit();
  8556. this.element
  8557. .addClass( "ui-slider" +
  8558. " ui-slider-" + this.orientation +
  8559. " ui-widget" +
  8560. " ui-widget-content" +
  8561. " ui-corner-all" +
  8562. ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
  8563. this.range = $([]);
  8564. if ( o.range ) {
  8565. if ( o.range === true ) {
  8566. if ( !o.values ) {
  8567. o.values = [ this._valueMin(), this._valueMin() ];
  8568. }
  8569. if ( o.values.length && o.values.length !== 2 ) {
  8570. o.values = [ o.values[0], o.values[0] ];
  8571. }
  8572. }
  8573. this.range = $( "<div></div>" )
  8574. .appendTo( this.element )
  8575. .addClass( "ui-slider-range" +
  8576. // note: this isn't the most fittingly semantic framework class for this element,
  8577. // but worked best visually with a variety of themes
  8578. " ui-widget-header" +
  8579. ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
  8580. }
  8581. for ( var i = existingHandles.length; i < handleCount; i += 1 ) {
  8582. handles.push( handle );
  8583. }
  8584. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
  8585. this.handle = this.handles.eq( 0 );
  8586. this.handles.add( this.range ).filter( "a" )
  8587. .click(function( event ) {
  8588. event.preventDefault();
  8589. })
  8590. .hover(function() {
  8591. if ( !o.disabled ) {
  8592. $( this ).addClass( "ui-state-hover" );
  8593. }
  8594. }, function() {
  8595. $( this ).removeClass( "ui-state-hover" );
  8596. })
  8597. .focus(function() {
  8598. if ( !o.disabled ) {
  8599. $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
  8600. $( this ).addClass( "ui-state-focus" );
  8601. } else {
  8602. $( this ).blur();
  8603. }
  8604. })
  8605. .blur(function() {
  8606. $( this ).removeClass( "ui-state-focus" );
  8607. });
  8608. this.handles.each(function( i ) {
  8609. $( this ).data( "index.ui-slider-handle", i );
  8610. });
  8611. this.handles
  8612. .keydown(function( event ) {
  8613. var index = $( this ).data( "index.ui-slider-handle" ),
  8614. allowed,
  8615. curVal,
  8616. newVal,
  8617. step;
  8618. if ( self.options.disabled ) {
  8619. return;
  8620. }
  8621. switch ( event.keyCode ) {
  8622. case $.ui.keyCode.HOME:
  8623. case $.ui.keyCode.END:
  8624. case $.ui.keyCode.PAGE_UP:
  8625. case $.ui.keyCode.PAGE_DOWN:
  8626. case $.ui.keyCode.UP:
  8627. case $.ui.keyCode.RIGHT:
  8628. case $.ui.keyCode.DOWN:
  8629. case $.ui.keyCode.LEFT:
  8630. event.preventDefault();
  8631. if ( !self._keySliding ) {
  8632. self._keySliding = true;
  8633. $( this ).addClass( "ui-state-active" );
  8634. allowed = self._start( event, index );
  8635. if ( allowed === false ) {
  8636. return;
  8637. }
  8638. }
  8639. break;
  8640. }
  8641. step = self.options.step;
  8642. if ( self.options.values && self.options.values.length ) {
  8643. curVal = newVal = self.values( index );
  8644. } else {
  8645. curVal = newVal = self.value();
  8646. }
  8647. switch ( event.keyCode ) {
  8648. case $.ui.keyCode.HOME:
  8649. newVal = self._valueMin();
  8650. break;
  8651. case $.ui.keyCode.END:
  8652. newVal = self._valueMax();
  8653. break;
  8654. case $.ui.keyCode.PAGE_UP:
  8655. newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
  8656. break;
  8657. case $.ui.keyCode.PAGE_DOWN:
  8658. newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
  8659. break;
  8660. case $.ui.keyCode.UP:
  8661. case $.ui.keyCode.RIGHT:
  8662. if ( curVal === self._valueMax() ) {
  8663. return;
  8664. }
  8665. newVal = self._trimAlignValue( curVal + step );
  8666. break;
  8667. case $.ui.keyCode.DOWN:
  8668. case $.ui.keyCode.LEFT:
  8669. if ( curVal === self._valueMin() ) {
  8670. return;
  8671. }
  8672. newVal = self._trimAlignValue( curVal - step );
  8673. break;
  8674. }
  8675. self._slide( event, index, newVal );
  8676. })
  8677. .keyup(function( event ) {
  8678. var index = $( this ).data( "index.ui-slider-handle" );
  8679. if ( self._keySliding ) {
  8680. self._keySliding = false;
  8681. self._stop( event, index );
  8682. self._change( event, index );
  8683. $( this ).removeClass( "ui-state-active" );
  8684. }
  8685. });
  8686. this._refreshValue();
  8687. this._animateOff = false;
  8688. },
  8689. destroy: function() {
  8690. this.handles.remove();
  8691. this.range.remove();
  8692. this.element
  8693. .removeClass( "ui-slider" +
  8694. " ui-slider-horizontal" +
  8695. " ui-slider-vertical" +
  8696. " ui-slider-disabled" +
  8697. " ui-widget" +
  8698. " ui-widget-content" +
  8699. " ui-corner-all" )
  8700. .removeData( "slider" )
  8701. .unbind( ".slider" );
  8702. this._mouseDestroy();
  8703. return this;
  8704. },
  8705. _mouseCapture: function( event ) {
  8706. var o = this.options,
  8707. position,
  8708. normValue,
  8709. distance,
  8710. closestHandle,
  8711. self,
  8712. index,
  8713. allowed,
  8714. offset,
  8715. mouseOverHandle;
  8716. if ( o.disabled ) {
  8717. return false;
  8718. }
  8719. this.elementSize = {
  8720. width: this.element.outerWidth(),
  8721. height: this.element.outerHeight()
  8722. };
  8723. this.elementOffset = this.element.offset();
  8724. position = { x: event.pageX, y: event.pageY };
  8725. normValue = this._normValueFromMouse( position );
  8726. distance = this._valueMax() - this._valueMin() + 1;
  8727. self = this;
  8728. this.handles.each(function( i ) {
  8729. var thisDistance = Math.abs( normValue - self.values(i) );
  8730. if ( distance > thisDistance ) {
  8731. distance = thisDistance;
  8732. closestHandle = $( this );
  8733. index = i;
  8734. }
  8735. });
  8736. // workaround for bug #3736 (if both handles of a range are at 0,
  8737. // the first is always used as the one with least distance,
  8738. // and moving it is obviously prevented by preventing negative ranges)
  8739. if( o.range === true && this.values(1) === o.min ) {
  8740. index += 1;
  8741. closestHandle = $( this.handles[index] );
  8742. }
  8743. allowed = this._start( event, index );
  8744. if ( allowed === false ) {
  8745. return false;
  8746. }
  8747. this._mouseSliding = true;
  8748. self._handleIndex = index;
  8749. closestHandle
  8750. .addClass( "ui-state-active" )
  8751. .focus();
  8752. offset = closestHandle.offset();
  8753. mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
  8754. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  8755. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  8756. top: event.pageY - offset.top -
  8757. ( closestHandle.height() / 2 ) -
  8758. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  8759. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  8760. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  8761. };
  8762. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  8763. this._slide( event, index, normValue );
  8764. }
  8765. this._animateOff = true;
  8766. return true;
  8767. },
  8768. _mouseStart: function( event ) {
  8769. return true;
  8770. },
  8771. _mouseDrag: function( event ) {
  8772. var position = { x: event.pageX, y: event.pageY },
  8773. normValue = this._normValueFromMouse( position );
  8774. this._slide( event, this._handleIndex, normValue );
  8775. return false;
  8776. },
  8777. _mouseStop: function( event ) {
  8778. this.handles.removeClass( "ui-state-active" );
  8779. this._mouseSliding = false;
  8780. this._stop( event, this._handleIndex );
  8781. this._change( event, this._handleIndex );
  8782. this._handleIndex = null;
  8783. this._clickOffset = null;
  8784. this._animateOff = false;
  8785. return false;
  8786. },
  8787. _detectOrientation: function() {
  8788. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  8789. },
  8790. _normValueFromMouse: function( position ) {
  8791. var pixelTotal,
  8792. pixelMouse,
  8793. percentMouse,
  8794. valueTotal,
  8795. valueMouse;
  8796. if ( this.orientation === "horizontal" ) {
  8797. pixelTotal = this.elementSize.width;
  8798. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  8799. } else {
  8800. pixelTotal = this.elementSize.height;
  8801. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  8802. }
  8803. percentMouse = ( pixelMouse / pixelTotal );
  8804. if ( percentMouse > 1 ) {
  8805. percentMouse = 1;
  8806. }
  8807. if ( percentMouse < 0 ) {
  8808. percentMouse = 0;
  8809. }
  8810. if ( this.orientation === "vertical" ) {
  8811. percentMouse = 1 - percentMouse;
  8812. }
  8813. valueTotal = this._valueMax() - this._valueMin();
  8814. valueMouse = this._valueMin() + percentMouse * valueTotal;
  8815. return this._trimAlignValue( valueMouse );
  8816. },
  8817. _start: function( event, index ) {
  8818. var uiHash = {
  8819. handle: this.handles[ index ],
  8820. value: this.value()
  8821. };
  8822. if ( this.options.values && this.options.values.length ) {
  8823. uiHash.value = this.values( index );
  8824. uiHash.values = this.values();
  8825. }
  8826. return this._trigger( "start", event, uiHash );
  8827. },
  8828. _slide: function( event, index, newVal ) {
  8829. var otherVal,
  8830. newValues,
  8831. allowed;
  8832. if ( this.options.values && this.options.values.length ) {
  8833. otherVal = this.values( index ? 0 : 1 );
  8834. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  8835. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  8836. ) {
  8837. newVal = otherVal;
  8838. }
  8839. if ( newVal !== this.values( index ) ) {
  8840. newValues = this.values();
  8841. newValues[ index ] = newVal;
  8842. // A slide can be canceled by returning false from the slide callback
  8843. allowed = this._trigger( "slide", event, {
  8844. handle: this.handles[ index ],
  8845. value: newVal,
  8846. values: newValues
  8847. } );
  8848. otherVal = this.values( index ? 0 : 1 );
  8849. if ( allowed !== false ) {
  8850. this.values( index, newVal, true );
  8851. }
  8852. }
  8853. } else {
  8854. if ( newVal !== this.value() ) {
  8855. // A slide can be canceled by returning false from the slide callback
  8856. allowed = this._trigger( "slide", event, {
  8857. handle: this.handles[ index ],
  8858. value: newVal
  8859. } );
  8860. if ( allowed !== false ) {
  8861. this.value( newVal );
  8862. }
  8863. }
  8864. }
  8865. },
  8866. _stop: function( event, index ) {
  8867. var uiHash = {
  8868. handle: this.handles[ index ],
  8869. value: this.value()
  8870. };
  8871. if ( this.options.values && this.options.values.length ) {
  8872. uiHash.value = this.values( index );
  8873. uiHash.values = this.values();
  8874. }
  8875. this._trigger( "stop", event, uiHash );
  8876. },
  8877. _change: function( event, index ) {
  8878. if ( !this._keySliding && !this._mouseSliding ) {
  8879. var uiHash = {
  8880. handle: this.handles[ index ],
  8881. value: this.value()
  8882. };
  8883. if ( this.options.values && this.options.values.length ) {
  8884. uiHash.value = this.values( index );
  8885. uiHash.values = this.values();
  8886. }
  8887. this._trigger( "change", event, uiHash );
  8888. }
  8889. },
  8890. value: function( newValue ) {
  8891. if ( arguments.length ) {
  8892. this.options.value = this._trimAlignValue( newValue );
  8893. this._refreshValue();
  8894. this._change( null, 0 );
  8895. return;
  8896. }
  8897. return this._value();
  8898. },
  8899. values: function( index, newValue ) {
  8900. var vals,
  8901. newValues,
  8902. i;
  8903. if ( arguments.length > 1 ) {
  8904. this.options.values[ index ] = this._trimAlignValue( newValue );
  8905. this._refreshValue();
  8906. this._change( null, index );
  8907. return;
  8908. }
  8909. if ( arguments.length ) {
  8910. if ( $.isArray( arguments[ 0 ] ) ) {
  8911. vals = this.options.values;
  8912. newValues = arguments[ 0 ];
  8913. for ( i = 0; i < vals.length; i += 1 ) {
  8914. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  8915. this._change( null, i );
  8916. }
  8917. this._refreshValue();
  8918. } else {
  8919. if ( this.options.values && this.options.values.length ) {
  8920. return this._values( index );
  8921. } else {
  8922. return this.value();
  8923. }
  8924. }
  8925. } else {
  8926. return this._values();
  8927. }
  8928. },
  8929. _setOption: function( key, value ) {
  8930. var i,
  8931. valsLength = 0;
  8932. if ( $.isArray( this.options.values ) ) {
  8933. valsLength = this.options.values.length;
  8934. }
  8935. $.Widget.prototype._setOption.apply( this, arguments );
  8936. switch ( key ) {
  8937. case "disabled":
  8938. if ( value ) {
  8939. this.handles.filter( ".ui-state-focus" ).blur();
  8940. this.handles.removeClass( "ui-state-hover" );
  8941. this.handles.propAttr( "disabled", true );
  8942. this.element.addClass( "ui-disabled" );
  8943. } else {
  8944. this.handles.propAttr( "disabled", false );
  8945. this.element.removeClass( "ui-disabled" );
  8946. }
  8947. break;
  8948. case "orientation":
  8949. this._detectOrientation();
  8950. this.element
  8951. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  8952. .addClass( "ui-slider-" + this.orientation );
  8953. this._refreshValue();
  8954. break;
  8955. case "value":
  8956. this._animateOff = true;
  8957. this._refreshValue();
  8958. this._change( null, 0 );
  8959. this._animateOff = false;
  8960. break;
  8961. case "values":
  8962. this._animateOff = true;
  8963. this._refreshValue();
  8964. for ( i = 0; i < valsLength; i += 1 ) {
  8965. this._change( null, i );
  8966. }
  8967. this._animateOff = false;
  8968. break;
  8969. }
  8970. },
  8971. //internal value getter
  8972. // _value() returns value trimmed by min and max, aligned by step
  8973. _value: function() {
  8974. var val = this.options.value;
  8975. val = this._trimAlignValue( val );
  8976. return val;
  8977. },
  8978. //internal values getter
  8979. // _values() returns array of values trimmed by min and max, aligned by step
  8980. // _values( index ) returns single value trimmed by min and max, aligned by step
  8981. _values: function( index ) {
  8982. var val,
  8983. vals,
  8984. i;
  8985. if ( arguments.length ) {
  8986. val = this.options.values[ index ];
  8987. val = this._trimAlignValue( val );
  8988. return val;
  8989. } else {
  8990. // .slice() creates a copy of the array
  8991. // this copy gets trimmed by min and max and then returned
  8992. vals = this.options.values.slice();
  8993. for ( i = 0; i < vals.length; i+= 1) {
  8994. vals[ i ] = this._trimAlignValue( vals[ i ] );
  8995. }
  8996. return vals;
  8997. }
  8998. },
  8999. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  9000. _trimAlignValue: function( val ) {
  9001. if ( val <= this._valueMin() ) {
  9002. return this._valueMin();
  9003. }
  9004. if ( val >= this._valueMax() ) {
  9005. return this._valueMax();
  9006. }
  9007. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  9008. valModStep = (val - this._valueMin()) % step,
  9009. alignValue = val - valModStep;
  9010. if ( Math.abs(valModStep) * 2 >= step ) {
  9011. alignValue += ( valModStep > 0 ) ? step : ( -step );
  9012. }
  9013. // Since JavaScript has problems with large floats, round
  9014. // the final value to 5 digits after the decimal point (see #4124)
  9015. return parseFloat( alignValue.toFixed(5) );
  9016. },
  9017. _valueMin: function() {
  9018. return this.options.min;
  9019. },
  9020. _valueMax: function() {
  9021. return this.options.max;
  9022. },
  9023. _refreshValue: function() {
  9024. var oRange = this.options.range,
  9025. o = this.options,
  9026. self = this,
  9027. animate = ( !this._animateOff ) ? o.animate : false,
  9028. valPercent,
  9029. _set = {},
  9030. lastValPercent,
  9031. value,
  9032. valueMin,
  9033. valueMax;
  9034. if ( this.options.values && this.options.values.length ) {
  9035. this.handles.each(function( i, j ) {
  9036. valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
  9037. _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9038. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9039. if ( self.options.range === true ) {
  9040. if ( self.orientation === "horizontal" ) {
  9041. if ( i === 0 ) {
  9042. self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  9043. }
  9044. if ( i === 1 ) {
  9045. self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9046. }
  9047. } else {
  9048. if ( i === 0 ) {
  9049. self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  9050. }
  9051. if ( i === 1 ) {
  9052. self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9053. }
  9054. }
  9055. }
  9056. lastValPercent = valPercent;
  9057. });
  9058. } else {
  9059. value = this.value();
  9060. valueMin = this._valueMin();
  9061. valueMax = this._valueMax();
  9062. valPercent = ( valueMax !== valueMin ) ?
  9063. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  9064. 0;
  9065. _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9066. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9067. if ( oRange === "min" && this.orientation === "horizontal" ) {
  9068. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  9069. }
  9070. if ( oRange === "max" && this.orientation === "horizontal" ) {
  9071. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9072. }
  9073. if ( oRange === "min" && this.orientation === "vertical" ) {
  9074. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  9075. }
  9076. if ( oRange === "max" && this.orientation === "vertical" ) {
  9077. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9078. }
  9079. }
  9080. }
  9081. });
  9082. $.extend( $.ui.slider, {
  9083. version: "1.8.24"
  9084. });
  9085. }(jQuery));
  9086. (function( $, undefined ) {
  9087. var tabId = 0,
  9088. listId = 0;
  9089. function getNextTabId() {
  9090. return ++tabId;
  9091. }
  9092. function getNextListId() {
  9093. return ++listId;
  9094. }
  9095. $.widget( "ui.tabs", {
  9096. options: {
  9097. add: null,
  9098. ajaxOptions: null,
  9099. cache: false,
  9100. cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
  9101. collapsible: false,
  9102. disable: null,
  9103. disabled: [],
  9104. enable: null,
  9105. event: "click",
  9106. fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
  9107. idPrefix: "ui-tabs-",
  9108. load: null,
  9109. panelTemplate: "<div></div>",
  9110. remove: null,
  9111. select: null,
  9112. show: null,
  9113. spinner: "<em>Loading&#8230;</em>",
  9114. tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
  9115. },
  9116. _create: function() {
  9117. this._tabify( true );
  9118. },
  9119. _setOption: function( key, value ) {
  9120. if ( key == "selected" ) {
  9121. if (this.options.collapsible && value == this.options.selected ) {
  9122. return;
  9123. }
  9124. this.select( value );
  9125. } else {
  9126. this.options[ key ] = value;
  9127. this._tabify();
  9128. }
  9129. },
  9130. _tabId: function( a ) {
  9131. return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
  9132. this.options.idPrefix + getNextTabId();
  9133. },
  9134. _sanitizeSelector: function( hash ) {
  9135. // we need this because an id may contain a ":"
  9136. return hash.replace( /:/g, "\\:" );
  9137. },
  9138. _cookie: function() {
  9139. var cookie = this.cookie ||
  9140. ( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
  9141. return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
  9142. },
  9143. _ui: function( tab, panel ) {
  9144. return {
  9145. tab: tab,
  9146. panel: panel,
  9147. index: this.anchors.index( tab )
  9148. };
  9149. },
  9150. _cleanup: function() {
  9151. // restore all former loading tabs labels
  9152. this.lis.filter( ".ui-state-processing" )
  9153. .removeClass( "ui-state-processing" )
  9154. .find( "span:data(label.tabs)" )
  9155. .each(function() {
  9156. var el = $( this );
  9157. el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
  9158. });
  9159. },
  9160. _tabify: function( init ) {
  9161. var self = this,
  9162. o = this.options,
  9163. fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
  9164. this.list = this.element.find( "ol,ul" ).eq( 0 );
  9165. this.lis = $( " > li:has(a[href])", this.list );
  9166. this.anchors = this.lis.map(function() {
  9167. return $( "a", this )[ 0 ];
  9168. });
  9169. this.panels = $( [] );
  9170. this.anchors.each(function( i, a ) {
  9171. var href = $( a ).attr( "href" );
  9172. // For dynamically created HTML that contains a hash as href IE < 8 expands
  9173. // such href to the full page url with hash and then misinterprets tab as ajax.
  9174. // Same consideration applies for an added tab with a fragment identifier
  9175. // since a[href=#fragment-identifier] does unexpectedly not match.
  9176. // Thus normalize href attribute...
  9177. var hrefBase = href.split( "#" )[ 0 ],
  9178. baseEl;
  9179. if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
  9180. ( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
  9181. href = a.hash;
  9182. a.href = href;
  9183. }
  9184. // inline tab
  9185. if ( fragmentId.test( href ) ) {
  9186. self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
  9187. // remote tab
  9188. // prevent loading the page itself if href is just "#"
  9189. } else if ( href && href !== "#" ) {
  9190. // required for restore on destroy
  9191. $.data( a, "href.tabs", href );
  9192. // TODO until #3808 is fixed strip fragment identifier from url
  9193. // (IE fails to load from such url)
  9194. $.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
  9195. var id = self._tabId( a );
  9196. a.href = "#" + id;
  9197. var $panel = self.element.find( "#" + id );
  9198. if ( !$panel.length ) {
  9199. $panel = $( o.panelTemplate )
  9200. .attr( "id", id )
  9201. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  9202. .insertAfter( self.panels[ i - 1 ] || self.list );
  9203. $panel.data( "destroy.tabs", true );
  9204. }
  9205. self.panels = self.panels.add( $panel );
  9206. // invalid tab href
  9207. } else {
  9208. o.disabled.push( i );
  9209. }
  9210. });
  9211. // initialization from scratch
  9212. if ( init ) {
  9213. // attach necessary classes for styling
  9214. this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
  9215. this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
  9216. this.lis.addClass( "ui-state-default ui-corner-top" );
  9217. this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
  9218. // Selected tab
  9219. // use "selected" option or try to retrieve:
  9220. // 1. from fragment identifier in url
  9221. // 2. from cookie
  9222. // 3. from selected class attribute on <li>
  9223. if ( o.selected === undefined ) {
  9224. if ( location.hash ) {
  9225. this.anchors.each(function( i, a ) {
  9226. if ( a.hash == location.hash ) {
  9227. o.selected = i;
  9228. return false;
  9229. }
  9230. });
  9231. }
  9232. if ( typeof o.selected !== "number" && o.cookie ) {
  9233. o.selected = parseInt( self._cookie(), 10 );
  9234. }
  9235. if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
  9236. o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
  9237. }
  9238. o.selected = o.selected || ( this.lis.length ? 0 : -1 );
  9239. } else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
  9240. o.selected = -1;
  9241. }
  9242. // sanity check - default to first tab...
  9243. o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
  9244. ? o.selected
  9245. : 0;
  9246. // Take disabling tabs via class attribute from HTML
  9247. // into account and update option properly.
  9248. // A selected tab cannot become disabled.
  9249. o.disabled = $.unique( o.disabled.concat(
  9250. $.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
  9251. return self.lis.index( n );
  9252. })
  9253. ) ).sort();
  9254. if ( $.inArray( o.selected, o.disabled ) != -1 ) {
  9255. o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
  9256. }
  9257. // highlight selected tab
  9258. this.panels.addClass( "ui-tabs-hide" );
  9259. this.lis.removeClass( "ui-tabs-selected ui-state-active" );
  9260. // check for length avoids error when initializing empty list
  9261. if ( o.selected >= 0 && this.anchors.length ) {
  9262. self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
  9263. this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
  9264. // seems to be expected behavior that the show callback is fired
  9265. self.element.queue( "tabs", function() {
  9266. self._trigger( "show", null,
  9267. self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) )[ 0 ] ) );
  9268. });
  9269. this.load( o.selected );
  9270. }
  9271. // clean up to avoid memory leaks in certain versions of IE 6
  9272. // TODO: namespace this event
  9273. $( window ).bind( "unload", function() {
  9274. self.lis.add( self.anchors ).unbind( ".tabs" );
  9275. self.lis = self.anchors = self.panels = null;
  9276. });
  9277. // update selected after add/remove
  9278. } else {
  9279. o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
  9280. }
  9281. // update collapsible
  9282. // TODO: use .toggleClass()
  9283. this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
  9284. // set or update cookie after init and add/remove respectively
  9285. if ( o.cookie ) {
  9286. this._cookie( o.selected, o.cookie );
  9287. }
  9288. // disable tabs
  9289. for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
  9290. $( li )[ $.inArray( i, o.disabled ) != -1 &&
  9291. // TODO: use .toggleClass()
  9292. !$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
  9293. }
  9294. // reset cache if switching from cached to not cached
  9295. if ( o.cache === false ) {
  9296. this.anchors.removeData( "cache.tabs" );
  9297. }
  9298. // remove all handlers before, tabify may run on existing tabs after add or option change
  9299. this.lis.add( this.anchors ).unbind( ".tabs" );
  9300. if ( o.event !== "mouseover" ) {
  9301. var addState = function( state, el ) {
  9302. if ( el.is( ":not(.ui-state-disabled)" ) ) {
  9303. el.addClass( "ui-state-" + state );
  9304. }
  9305. };
  9306. var removeState = function( state, el ) {
  9307. el.removeClass( "ui-state-" + state );
  9308. };
  9309. this.lis.bind( "mouseover.tabs" , function() {
  9310. addState( "hover", $( this ) );
  9311. });
  9312. this.lis.bind( "mouseout.tabs", function() {
  9313. removeState( "hover", $( this ) );
  9314. });
  9315. this.anchors.bind( "focus.tabs", function() {
  9316. addState( "focus", $( this ).closest( "li" ) );
  9317. });
  9318. this.anchors.bind( "blur.tabs", function() {
  9319. removeState( "focus", $( this ).closest( "li" ) );
  9320. });
  9321. }
  9322. // set up animations
  9323. var hideFx, showFx;
  9324. if ( o.fx ) {
  9325. if ( $.isArray( o.fx ) ) {
  9326. hideFx = o.fx[ 0 ];
  9327. showFx = o.fx[ 1 ];
  9328. } else {
  9329. hideFx = showFx = o.fx;
  9330. }
  9331. }
  9332. // Reset certain styles left over from animation
  9333. // and prevent IE's ClearType bug...
  9334. function resetStyle( $el, fx ) {
  9335. $el.css( "display", "" );
  9336. if ( !$.support.opacity && fx.opacity ) {
  9337. $el[ 0 ].style.removeAttribute( "filter" );
  9338. }
  9339. }
  9340. // Show a tab...
  9341. var showTab = showFx
  9342. ? function( clicked, $show ) {
  9343. $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
  9344. $show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
  9345. .animate( showFx, showFx.duration || "normal", function() {
  9346. resetStyle( $show, showFx );
  9347. self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
  9348. });
  9349. }
  9350. : function( clicked, $show ) {
  9351. $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
  9352. $show.removeClass( "ui-tabs-hide" );
  9353. self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
  9354. };
  9355. // Hide a tab, $show is optional...
  9356. var hideTab = hideFx
  9357. ? function( clicked, $hide ) {
  9358. $hide.animate( hideFx, hideFx.duration || "normal", function() {
  9359. self.lis.removeClass( "ui-tabs-selected ui-state-active" );
  9360. $hide.addClass( "ui-tabs-hide" );
  9361. resetStyle( $hide, hideFx );
  9362. self.element.dequeue( "tabs" );
  9363. });
  9364. }
  9365. : function( clicked, $hide, $show ) {
  9366. self.lis.removeClass( "ui-tabs-selected ui-state-active" );
  9367. $hide.addClass( "ui-tabs-hide" );
  9368. self.element.dequeue( "tabs" );
  9369. };
  9370. // attach tab event handler, unbind to avoid duplicates from former tabifying...
  9371. this.anchors.bind( o.event + ".tabs", function() {
  9372. var el = this,
  9373. $li = $(el).closest( "li" ),
  9374. $hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
  9375. $show = self.element.find( self._sanitizeSelector( el.hash ) );
  9376. // If tab is already selected and not collapsible or tab disabled or
  9377. // or is already loading or click callback returns false stop here.
  9378. // Check if click handler returns false last so that it is not executed
  9379. // for a disabled or loading tab!
  9380. if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
  9381. $li.hasClass( "ui-state-disabled" ) ||
  9382. $li.hasClass( "ui-state-processing" ) ||
  9383. self.panels.filter( ":animated" ).length ||
  9384. self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
  9385. this.blur();
  9386. return false;
  9387. }
  9388. o.selected = self.anchors.index( this );
  9389. self.abort();
  9390. // if tab may be closed
  9391. if ( o.collapsible ) {
  9392. if ( $li.hasClass( "ui-tabs-selected" ) ) {
  9393. o.selected = -1;
  9394. if ( o.cookie ) {
  9395. self._cookie( o.selected, o.cookie );
  9396. }
  9397. self.element.queue( "tabs", function() {
  9398. hideTab( el, $hide );
  9399. }).dequeue( "tabs" );
  9400. this.blur();
  9401. return false;
  9402. } else if ( !$hide.length ) {
  9403. if ( o.cookie ) {
  9404. self._cookie( o.selected, o.cookie );
  9405. }
  9406. self.element.queue( "tabs", function() {
  9407. showTab( el, $show );
  9408. });
  9409. // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
  9410. self.load( self.anchors.index( this ) );
  9411. this.blur();
  9412. return false;
  9413. }
  9414. }
  9415. if ( o.cookie ) {
  9416. self._cookie( o.selected, o.cookie );
  9417. }
  9418. // show new tab
  9419. if ( $show.length ) {
  9420. if ( $hide.length ) {
  9421. self.element.queue( "tabs", function() {
  9422. hideTab( el, $hide );
  9423. });
  9424. }
  9425. self.element.queue( "tabs", function() {
  9426. showTab( el, $show );
  9427. });
  9428. self.load( self.anchors.index( this ) );
  9429. } else {
  9430. throw "jQuery UI Tabs: Mismatching fragment identifier.";
  9431. }
  9432. // Prevent IE from keeping other link focussed when using the back button
  9433. // and remove dotted border from clicked link. This is controlled via CSS
  9434. // in modern browsers; blur() removes focus from address bar in Firefox
  9435. // which can become a usability and annoying problem with tabs('rotate').
  9436. if ( $.browser.msie ) {
  9437. this.blur();
  9438. }
  9439. });
  9440. // disable click in any case
  9441. this.anchors.bind( "click.tabs", function(){
  9442. return false;
  9443. });
  9444. },
  9445. _getIndex: function( index ) {
  9446. // meta-function to give users option to provide a href string instead of a numerical index.
  9447. // also sanitizes numerical indexes to valid values.
  9448. if ( typeof index == "string" ) {
  9449. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  9450. }
  9451. return index;
  9452. },
  9453. destroy: function() {
  9454. var o = this.options;
  9455. this.abort();
  9456. this.element
  9457. .unbind( ".tabs" )
  9458. .removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
  9459. .removeData( "tabs" );
  9460. this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
  9461. this.anchors.each(function() {
  9462. var href = $.data( this, "href.tabs" );
  9463. if ( href ) {
  9464. this.href = href;
  9465. }
  9466. var $this = $( this ).unbind( ".tabs" );
  9467. $.each( [ "href", "load", "cache" ], function( i, prefix ) {
  9468. $this.removeData( prefix + ".tabs" );
  9469. });
  9470. });
  9471. this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
  9472. if ( $.data( this, "destroy.tabs" ) ) {
  9473. $( this ).remove();
  9474. } else {
  9475. $( this ).removeClass([
  9476. "ui-state-default",
  9477. "ui-corner-top",
  9478. "ui-tabs-selected",
  9479. "ui-state-active",
  9480. "ui-state-hover",
  9481. "ui-state-focus",
  9482. "ui-state-disabled",
  9483. "ui-tabs-panel",
  9484. "ui-widget-content",
  9485. "ui-corner-bottom",
  9486. "ui-tabs-hide"
  9487. ].join( " " ) );
  9488. }
  9489. });
  9490. if ( o.cookie ) {
  9491. this._cookie( null, o.cookie );
  9492. }
  9493. return this;
  9494. },
  9495. add: function( url, label, index ) {
  9496. if ( index === undefined ) {
  9497. index = this.anchors.length;
  9498. }
  9499. var self = this,
  9500. o = this.options,
  9501. $li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
  9502. id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
  9503. $li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
  9504. // try to find an existing element before creating a new one
  9505. var $panel = self.element.find( "#" + id );
  9506. if ( !$panel.length ) {
  9507. $panel = $( o.panelTemplate )
  9508. .attr( "id", id )
  9509. .data( "destroy.tabs", true );
  9510. }
  9511. $panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
  9512. if ( index >= this.lis.length ) {
  9513. $li.appendTo( this.list );
  9514. $panel.appendTo( this.list[ 0 ].parentNode );
  9515. } else {
  9516. $li.insertBefore( this.lis[ index ] );
  9517. $panel.insertBefore( this.panels[ index ] );
  9518. }
  9519. o.disabled = $.map( o.disabled, function( n, i ) {
  9520. return n >= index ? ++n : n;
  9521. });
  9522. this._tabify();
  9523. if ( this.anchors.length == 1 ) {
  9524. o.selected = 0;
  9525. $li.addClass( "ui-tabs-selected ui-state-active" );
  9526. $panel.removeClass( "ui-tabs-hide" );
  9527. this.element.queue( "tabs", function() {
  9528. self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
  9529. });
  9530. this.load( 0 );
  9531. }
  9532. this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  9533. return this;
  9534. },
  9535. remove: function( index ) {
  9536. index = this._getIndex( index );
  9537. var o = this.options,
  9538. $li = this.lis.eq( index ).remove(),
  9539. $panel = this.panels.eq( index ).remove();
  9540. // If selected tab was removed focus tab to the right or
  9541. // in case the last tab was removed the tab to the left.
  9542. if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
  9543. this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
  9544. }
  9545. o.disabled = $.map(
  9546. $.grep( o.disabled, function(n, i) {
  9547. return n != index;
  9548. }),
  9549. function( n, i ) {
  9550. return n >= index ? --n : n;
  9551. });
  9552. this._tabify();
  9553. this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
  9554. return this;
  9555. },
  9556. enable: function( index ) {
  9557. index = this._getIndex( index );
  9558. var o = this.options;
  9559. if ( $.inArray( index, o.disabled ) == -1 ) {
  9560. return;
  9561. }
  9562. this.lis.eq( index ).removeClass( "ui-state-disabled" );
  9563. o.disabled = $.grep( o.disabled, function( n, i ) {
  9564. return n != index;
  9565. });
  9566. this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  9567. return this;
  9568. },
  9569. disable: function( index ) {
  9570. index = this._getIndex( index );
  9571. var self = this, o = this.options;
  9572. // cannot disable already selected tab
  9573. if ( index != o.selected ) {
  9574. this.lis.eq( index ).addClass( "ui-state-disabled" );
  9575. o.disabled.push( index );
  9576. o.disabled.sort();
  9577. this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  9578. }
  9579. return this;
  9580. },
  9581. select: function( index ) {
  9582. index = this._getIndex( index );
  9583. if ( index == -1 ) {
  9584. if ( this.options.collapsible && this.options.selected != -1 ) {
  9585. index = this.options.selected;
  9586. } else {
  9587. return this;
  9588. }
  9589. }
  9590. this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
  9591. return this;
  9592. },
  9593. load: function( index ) {
  9594. index = this._getIndex( index );
  9595. var self = this,
  9596. o = this.options,
  9597. a = this.anchors.eq( index )[ 0 ],
  9598. url = $.data( a, "load.tabs" );
  9599. this.abort();
  9600. // not remote or from cache
  9601. if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
  9602. this.element.dequeue( "tabs" );
  9603. return;
  9604. }
  9605. // load remote from here on
  9606. this.lis.eq( index ).addClass( "ui-state-processing" );
  9607. if ( o.spinner ) {
  9608. var span = $( "span", a );
  9609. span.data( "label.tabs", span.html() ).html( o.spinner );
  9610. }
  9611. this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
  9612. url: url,
  9613. success: function( r, s ) {
  9614. self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
  9615. // take care of tab labels
  9616. self._cleanup();
  9617. if ( o.cache ) {
  9618. $.data( a, "cache.tabs", true );
  9619. }
  9620. self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
  9621. try {
  9622. o.ajaxOptions.success( r, s );
  9623. }
  9624. catch ( e ) {}
  9625. },
  9626. error: function( xhr, s, e ) {
  9627. // take care of tab labels
  9628. self._cleanup();
  9629. self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
  9630. try {
  9631. // Passing index avoid a race condition when this method is
  9632. // called after the user has selected another tab.
  9633. // Pass the anchor that initiated this request allows
  9634. // loadError to manipulate the tab content panel via $(a.hash)
  9635. o.ajaxOptions.error( xhr, s, index, a );
  9636. }
  9637. catch ( e ) {}
  9638. }
  9639. } ) );
  9640. // last, so that load event is fired before show...
  9641. self.element.dequeue( "tabs" );
  9642. return this;
  9643. },
  9644. abort: function() {
  9645. // stop possibly running animations
  9646. this.element.queue( [] );
  9647. this.panels.stop( false, true );
  9648. // "tabs" queue must not contain more than two elements,
  9649. // which are the callbacks for the latest clicked tab...
  9650. this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
  9651. // terminate pending requests from other tabs
  9652. if ( this.xhr ) {
  9653. this.xhr.abort();
  9654. delete this.xhr;
  9655. }
  9656. // take care of tab labels
  9657. this._cleanup();
  9658. return this;
  9659. },
  9660. url: function( index, url ) {
  9661. this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
  9662. return this;
  9663. },
  9664. length: function() {
  9665. return this.anchors.length;
  9666. }
  9667. });
  9668. $.extend( $.ui.tabs, {
  9669. version: "1.8.24"
  9670. });
  9671. /*
  9672. * Tabs Extensions
  9673. */
  9674. /*
  9675. * Rotate
  9676. */
  9677. $.extend( $.ui.tabs.prototype, {
  9678. rotation: null,
  9679. rotate: function( ms, continuing ) {
  9680. var self = this,
  9681. o = this.options;
  9682. var rotate = self._rotate || ( self._rotate = function( e ) {
  9683. clearTimeout( self.rotation );
  9684. self.rotation = setTimeout(function() {
  9685. var t = o.selected;
  9686. self.select( ++t < self.anchors.length ? t : 0 );
  9687. }, ms );
  9688. if ( e ) {
  9689. e.stopPropagation();
  9690. }
  9691. });
  9692. var stop = self._unrotate || ( self._unrotate = !continuing
  9693. ? function(e) {
  9694. if (e.clientX) { // in case of a true click
  9695. self.rotate(null);
  9696. }
  9697. }
  9698. : function( e ) {
  9699. rotate();
  9700. });
  9701. // start rotation
  9702. if ( ms ) {
  9703. this.element.bind( "tabsshow", rotate );
  9704. this.anchors.bind( o.event + ".tabs", stop );
  9705. rotate();
  9706. // stop rotation
  9707. } else {
  9708. clearTimeout( self.rotation );
  9709. this.element.unbind( "tabsshow", rotate );
  9710. this.anchors.unbind( o.event + ".tabs", stop );
  9711. delete this._rotate;
  9712. delete this._unrotate;
  9713. }
  9714. return this;
  9715. }
  9716. });
  9717. })( jQuery );