Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

10890 lignes
340 KiB

  1. /*!
  2. * jQuery UI 1.8
  3. *
  4. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  5. * Dual licensed under the MIT (MIT-LICENSE.txt)
  6. * and GPL (GPL-LICENSE.txt) licenses.
  7. *
  8. * http://docs.jquery.com/UI
  9. */
  10. ;jQuery.ui || (function($) {
  11. //Helper functions and ui object
  12. $.ui = {
  13. version: "1.8",
  14. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  15. plugin: {
  16. add: function(module, option, set) {
  17. var proto = $.ui[module].prototype;
  18. for(var i in set) {
  19. proto.plugins[i] = proto.plugins[i] || [];
  20. proto.plugins[i].push([option, set[i]]);
  21. }
  22. },
  23. call: function(instance, name, args) {
  24. var set = instance.plugins[name];
  25. if(!set || !instance.element[0].parentNode) { return; }
  26. for (var i = 0; i < set.length; i++) {
  27. if (instance.options[set[i][0]]) {
  28. set[i][1].apply(instance.element, args);
  29. }
  30. }
  31. }
  32. },
  33. contains: function(a, b) {
  34. return document.compareDocumentPosition
  35. ? a.compareDocumentPosition(b) & 16
  36. : a !== b && a.contains(b);
  37. },
  38. hasScroll: function(el, a) {
  39. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  40. if ($(el).css('overflow') == 'hidden') { return false; }
  41. var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
  42. has = false;
  43. if (el[scroll] > 0) { return true; }
  44. // TODO: determine which cases actually cause this to happen
  45. // if the element doesn't have the scroll set, see if it's possible to
  46. // set the scroll
  47. el[scroll] = 1;
  48. has = (el[scroll] > 0);
  49. el[scroll] = 0;
  50. return has;
  51. },
  52. isOverAxis: function(x, reference, size) {
  53. //Determines when x coordinate is over "b" element axis
  54. return (x > reference) && (x < (reference + size));
  55. },
  56. isOver: function(y, x, top, left, height, width) {
  57. //Determines when x, y coordinates is over "b" element
  58. return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
  59. },
  60. keyCode: {
  61. BACKSPACE: 8,
  62. CAPS_LOCK: 20,
  63. COMMA: 188,
  64. CONTROL: 17,
  65. DELETE: 46,
  66. DOWN: 40,
  67. END: 35,
  68. ENTER: 13,
  69. ESCAPE: 27,
  70. HOME: 36,
  71. INSERT: 45,
  72. LEFT: 37,
  73. NUMPAD_ADD: 107,
  74. NUMPAD_DECIMAL: 110,
  75. NUMPAD_DIVIDE: 111,
  76. NUMPAD_ENTER: 108,
  77. NUMPAD_MULTIPLY: 106,
  78. NUMPAD_SUBTRACT: 109,
  79. PAGE_DOWN: 34,
  80. PAGE_UP: 33,
  81. PERIOD: 190,
  82. RIGHT: 39,
  83. SHIFT: 16,
  84. SPACE: 32,
  85. TAB: 9,
  86. UP: 38
  87. }
  88. };
  89. //jQuery plugins
  90. $.fn.extend({
  91. _focus: $.fn.focus,
  92. focus: function(delay, fn) {
  93. return typeof delay === 'number'
  94. ? this.each(function() {
  95. var elem = this;
  96. setTimeout(function() {
  97. $(elem).focus();
  98. (fn && fn.call(elem));
  99. }, delay);
  100. })
  101. : this._focus.apply(this, arguments);
  102. },
  103. enableSelection: function() {
  104. return this
  105. .attr('unselectable', 'off')
  106. .css('MozUserSelect', '')
  107. .unbind('selectstart.ui');
  108. },
  109. disableSelection: function() {
  110. return this
  111. .attr('unselectable', 'on')
  112. .css('MozUserSelect', 'none')
  113. .bind('selectstart.ui', function() { return false; });
  114. },
  115. scrollParent: function() {
  116. var scrollParent;
  117. if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
  118. scrollParent = this.parents().filter(function() {
  119. 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));
  120. }).eq(0);
  121. } else {
  122. scrollParent = this.parents().filter(function() {
  123. return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
  124. }).eq(0);
  125. }
  126. return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
  127. },
  128. zIndex: function(zIndex) {
  129. if (zIndex !== undefined) {
  130. return this.css('zIndex', zIndex);
  131. }
  132. if (this.length) {
  133. var elem = $(this[0]), position, value;
  134. while (elem.length && elem[0] !== document) {
  135. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  136. // This makes behavior of this function consistent across browsers
  137. // WebKit always returns auto if the element is positioned
  138. position = elem.css('position');
  139. if (position == 'absolute' || position == 'relative' || position == 'fixed')
  140. {
  141. // IE returns 0 when zIndex is not specified
  142. // other browsers return a string
  143. // we ignore the case of nested elements with an explicit value of 0
  144. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  145. value = parseInt(elem.css('zIndex'));
  146. if (!isNaN(value) && value != 0) {
  147. return value;
  148. }
  149. }
  150. elem = elem.parent();
  151. }
  152. }
  153. return 0;
  154. }
  155. });
  156. //Additional selectors
  157. $.extend($.expr[':'], {
  158. data: function(elem, i, match) {
  159. return !!$.data(elem, match[3]);
  160. },
  161. focusable: function(element) {
  162. var nodeName = element.nodeName.toLowerCase(),
  163. tabIndex = $.attr(element, 'tabindex');
  164. return (/input|select|textarea|button|object/.test(nodeName)
  165. ? !element.disabled
  166. : 'a' == nodeName || 'area' == nodeName
  167. ? element.href || !isNaN(tabIndex)
  168. : !isNaN(tabIndex))
  169. // the element and all of its ancestors must be visible
  170. // the browser may report that the area is hidden
  171. && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
  172. },
  173. tabbable: function(element) {
  174. var tabIndex = $.attr(element, 'tabindex');
  175. return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
  176. }
  177. });
  178. })(jQuery);
  179. /*!
  180. * jQuery UI Widget 1.8
  181. *
  182. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  183. * Dual licensed under the MIT (MIT-LICENSE.txt)
  184. * and GPL (GPL-LICENSE.txt) licenses.
  185. *
  186. * http://docs.jquery.com/UI/Widget
  187. */
  188. (function( $ ) {
  189. var _remove = $.fn.remove;
  190. $.fn.remove = function( selector, keepData ) {
  191. return this.each(function() {
  192. if ( !keepData ) {
  193. if ( !selector || $.filter( selector, [ this ] ).length ) {
  194. $( "*", this ).add( this ).each(function() {
  195. $( this ).triggerHandler( "remove" );
  196. });
  197. }
  198. }
  199. return _remove.call( $(this), selector, keepData );
  200. });
  201. };
  202. $.widget = function( name, base, prototype ) {
  203. var namespace = name.split( "." )[ 0 ],
  204. fullName;
  205. name = name.split( "." )[ 1 ];
  206. fullName = namespace + "-" + name;
  207. if ( !prototype ) {
  208. prototype = base;
  209. base = $.Widget;
  210. }
  211. // create selector for plugin
  212. $.expr[ ":" ][ fullName ] = function( elem ) {
  213. return !!$.data( elem, name );
  214. };
  215. $[ namespace ] = $[ namespace ] || {};
  216. $[ namespace ][ name ] = function( options, element ) {
  217. // allow instantiation without initializing for simple inheritance
  218. if ( arguments.length ) {
  219. this._createWidget( options, element );
  220. }
  221. };
  222. var basePrototype = new base();
  223. // we need to make the options hash a property directly on the new instance
  224. // otherwise we'll modify the options hash on the prototype that we're
  225. // inheriting from
  226. // $.each( basePrototype, function( key, val ) {
  227. // if ( $.isPlainObject(val) ) {
  228. // basePrototype[ key ] = $.extend( {}, val );
  229. // }
  230. // });
  231. basePrototype.options = $.extend( {}, basePrototype.options );
  232. $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
  233. namespace: namespace,
  234. widgetName: name,
  235. widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
  236. widgetBaseClass: fullName
  237. }, prototype );
  238. $.widget.bridge( name, $[ namespace ][ name ] );
  239. };
  240. $.widget.bridge = function( name, object ) {
  241. $.fn[ name ] = function( options ) {
  242. var isMethodCall = typeof options === "string",
  243. args = Array.prototype.slice.call( arguments, 1 ),
  244. returnValue = this;
  245. // allow multiple hashes to be passed on init
  246. options = !isMethodCall && args.length ?
  247. $.extend.apply( null, [ true, options ].concat(args) ) :
  248. options;
  249. // prevent calls to internal methods
  250. if ( isMethodCall && options.substring( 0, 1 ) === "_" ) {
  251. return returnValue;
  252. }
  253. if ( isMethodCall ) {
  254. this.each(function() {
  255. var instance = $.data( this, name ),
  256. methodValue = instance && $.isFunction( instance[options] ) ?
  257. instance[ options ].apply( instance, args ) :
  258. instance;
  259. if ( methodValue !== instance && methodValue !== undefined ) {
  260. returnValue = methodValue;
  261. return false;
  262. }
  263. });
  264. } else {
  265. this.each(function() {
  266. var instance = $.data( this, name );
  267. if ( instance ) {
  268. if ( options ) {
  269. instance.option( options );
  270. }
  271. instance._init();
  272. } else {
  273. $.data( this, name, new object( options, this ) );
  274. }
  275. });
  276. }
  277. return returnValue;
  278. };
  279. };
  280. $.Widget = function( options, element ) {
  281. // allow instantiation without initializing for simple inheritance
  282. if ( arguments.length ) {
  283. this._createWidget( options, element );
  284. }
  285. };
  286. $.Widget.prototype = {
  287. widgetName: "widget",
  288. widgetEventPrefix: "",
  289. options: {
  290. disabled: false
  291. },
  292. _createWidget: function( options, element ) {
  293. // $.widget.bridge stores the plugin instance, but we do it anyway
  294. // so that it's stored even before the _create function runs
  295. this.element = $( element ).data( this.widgetName, this );
  296. this.options = $.extend( true, {},
  297. this.options,
  298. $.metadata && $.metadata.get( element )[ this.widgetName ],
  299. options );
  300. var self = this;
  301. this.element.bind( "remove." + this.widgetName, function() {
  302. self.destroy();
  303. });
  304. this._create();
  305. this._init();
  306. },
  307. _create: function() {},
  308. _init: function() {},
  309. destroy: function() {
  310. this.element
  311. .unbind( "." + this.widgetName )
  312. .removeData( this.widgetName );
  313. this.widget()
  314. .unbind( "." + this.widgetName )
  315. .removeAttr( "aria-disabled" )
  316. .removeClass(
  317. this.widgetBaseClass + "-disabled " +
  318. this.namespace + "-state-disabled" );
  319. },
  320. widget: function() {
  321. return this.element;
  322. },
  323. option: function( key, value ) {
  324. var options = key,
  325. self = this;
  326. if ( arguments.length === 0 ) {
  327. // don't return a reference to the internal hash
  328. return $.extend( {}, self.options );
  329. }
  330. if (typeof key === "string" ) {
  331. if ( value === undefined ) {
  332. return this.options[ key ];
  333. }
  334. options = {};
  335. options[ key ] = value;
  336. }
  337. $.each( options, function( key, value ) {
  338. self._setOption( key, value );
  339. });
  340. return self;
  341. },
  342. _setOption: function( key, value ) {
  343. this.options[ key ] = value;
  344. if ( key === "disabled" ) {
  345. this.widget()
  346. [ value ? "addClass" : "removeClass"](
  347. this.widgetBaseClass + "-disabled" + " " +
  348. this.namespace + "-state-disabled" )
  349. .attr( "aria-disabled", value );
  350. }
  351. return this;
  352. },
  353. enable: function() {
  354. return this._setOption( "disabled", false );
  355. },
  356. disable: function() {
  357. return this._setOption( "disabled", true );
  358. },
  359. _trigger: function( type, event, data ) {
  360. var callback = this.options[ type ];
  361. event = $.Event( event );
  362. event.type = ( type === this.widgetEventPrefix ?
  363. type :
  364. this.widgetEventPrefix + type ).toLowerCase();
  365. data = data || {};
  366. // copy original event properties over to the new event
  367. // this would happen if we could call $.event.fix instead of $.Event
  368. // but we don't have a way to force an event to be fixed multiple times
  369. if ( event.originalEvent ) {
  370. for ( var i = $.event.props.length, prop; i; ) {
  371. prop = $.event.props[ --i ];
  372. event[ prop ] = event.originalEvent[ prop ];
  373. }
  374. }
  375. this.element.trigger( event, data );
  376. return !( $.isFunction(callback) &&
  377. callback.call( this.element[0], event, data ) === false ||
  378. event.isDefaultPrevented() );
  379. }
  380. };
  381. })( jQuery );
  382. /*!
  383. * jQuery UI Mouse 1.8
  384. *
  385. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  386. * Dual licensed under the MIT (MIT-LICENSE.txt)
  387. * and GPL (GPL-LICENSE.txt) licenses.
  388. *
  389. * http://docs.jquery.com/UI/Mouse
  390. *
  391. * Depends:
  392. * jquery.ui.widget.js
  393. */
  394. (function($) {
  395. $.widget("ui.mouse", {
  396. options: {
  397. cancel: ':input,option',
  398. distance: 1,
  399. delay: 0
  400. },
  401. _mouseInit: function() {
  402. var self = this;
  403. this.element
  404. .bind('mousedown.'+this.widgetName, function(event) {
  405. return self._mouseDown(event);
  406. })
  407. .bind('click.'+this.widgetName, function(event) {
  408. if(self._preventClickEvent) {
  409. self._preventClickEvent = false;
  410. event.stopImmediatePropagation();
  411. return false;
  412. }
  413. });
  414. this.started = false;
  415. },
  416. // TODO: make sure destroying one instance of mouse doesn't mess with
  417. // other instances of mouse
  418. _mouseDestroy: function() {
  419. this.element.unbind('.'+this.widgetName);
  420. },
  421. _mouseDown: function(event) {
  422. // don't let more than one widget handle mouseStart
  423. // TODO: figure out why we have to use originalEvent
  424. event.originalEvent = event.originalEvent || {};
  425. if (event.originalEvent.mouseHandled) { return; }
  426. // we may have missed mouseup (out of window)
  427. (this._mouseStarted && this._mouseUp(event));
  428. this._mouseDownEvent = event;
  429. var self = this,
  430. btnIsLeft = (event.which == 1),
  431. elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
  432. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  433. return true;
  434. }
  435. this.mouseDelayMet = !this.options.delay;
  436. if (!this.mouseDelayMet) {
  437. this._mouseDelayTimer = setTimeout(function() {
  438. self.mouseDelayMet = true;
  439. }, this.options.delay);
  440. }
  441. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  442. this._mouseStarted = (this._mouseStart(event) !== false);
  443. if (!this._mouseStarted) {
  444. event.preventDefault();
  445. return true;
  446. }
  447. }
  448. // these delegates are required to keep context
  449. this._mouseMoveDelegate = function(event) {
  450. return self._mouseMove(event);
  451. };
  452. this._mouseUpDelegate = function(event) {
  453. return self._mouseUp(event);
  454. };
  455. $(document)
  456. .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  457. .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  458. // preventDefault() is used to prevent the selection of text here -
  459. // however, in Safari, this causes select boxes not to be selectable
  460. // anymore, so this fix is needed
  461. ($.browser.safari || event.preventDefault());
  462. event.originalEvent.mouseHandled = true;
  463. return true;
  464. },
  465. _mouseMove: function(event) {
  466. // IE mouseup check - mouseup happened when mouse was out of window
  467. if ($.browser.msie && !event.button) {
  468. return this._mouseUp(event);
  469. }
  470. if (this._mouseStarted) {
  471. this._mouseDrag(event);
  472. return event.preventDefault();
  473. }
  474. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  475. this._mouseStarted =
  476. (this._mouseStart(this._mouseDownEvent, event) !== false);
  477. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  478. }
  479. return !this._mouseStarted;
  480. },
  481. _mouseUp: function(event) {
  482. $(document)
  483. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  484. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  485. if (this._mouseStarted) {
  486. this._mouseStarted = false;
  487. this._preventClickEvent = (event.target == this._mouseDownEvent.target);
  488. this._mouseStop(event);
  489. }
  490. return false;
  491. },
  492. _mouseDistanceMet: function(event) {
  493. return (Math.max(
  494. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  495. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  496. ) >= this.options.distance
  497. );
  498. },
  499. _mouseDelayMet: function(event) {
  500. return this.mouseDelayMet;
  501. },
  502. // These are placeholder methods, to be overriden by extending plugin
  503. _mouseStart: function(event) {},
  504. _mouseDrag: function(event) {},
  505. _mouseStop: function(event) {},
  506. _mouseCapture: function(event) { return true; }
  507. });
  508. })(jQuery);
  509. /*
  510. * jQuery UI Position 1.8
  511. *
  512. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  513. * Dual licensed under the MIT (MIT-LICENSE.txt)
  514. * and GPL (GPL-LICENSE.txt) licenses.
  515. *
  516. * http://docs.jquery.com/UI/Position
  517. */
  518. (function( $ ) {
  519. $.ui = $.ui || {};
  520. var horizontalPositions = /left|center|right/,
  521. horizontalDefault = "center",
  522. verticalPositions = /top|center|bottom/,
  523. verticalDefault = "center",
  524. _position = $.fn.position,
  525. _offset = $.fn.offset;
  526. $.fn.position = function( options ) {
  527. if ( !options || !options.of ) {
  528. return _position.apply( this, arguments );
  529. }
  530. // make a copy, we don't want to modify arguments
  531. options = $.extend( {}, options );
  532. var target = $( options.of ),
  533. collision = ( options.collision || "flip" ).split( " " ),
  534. offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
  535. targetWidth,
  536. targetHeight,
  537. basePosition;
  538. if ( options.of.nodeType === 9 ) {
  539. targetWidth = target.width();
  540. targetHeight = target.height();
  541. basePosition = { top: 0, left: 0 };
  542. } else if ( options.of.scrollTo && options.of.document ) {
  543. targetWidth = target.width();
  544. targetHeight = target.height();
  545. basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
  546. } else if ( options.of.preventDefault ) {
  547. // force left top to allow flipping
  548. options.at = "left top";
  549. targetWidth = targetHeight = 0;
  550. basePosition = { top: options.of.pageY, left: options.of.pageX };
  551. } else {
  552. targetWidth = target.outerWidth();
  553. targetHeight = target.outerHeight();
  554. basePosition = target.offset();
  555. }
  556. // force my and at to have valid horizontal and veritcal positions
  557. // if a value is missing or invalid, it will be converted to center
  558. $.each( [ "my", "at" ], function() {
  559. var pos = ( options[this] || "" ).split( " " );
  560. if ( pos.length === 1) {
  561. pos = horizontalPositions.test( pos[0] ) ?
  562. pos.concat( [verticalDefault] ) :
  563. verticalPositions.test( pos[0] ) ?
  564. [ horizontalDefault ].concat( pos ) :
  565. [ horizontalDefault, verticalDefault ];
  566. }
  567. pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : horizontalDefault;
  568. pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : verticalDefault;
  569. options[ this ] = pos;
  570. });
  571. // normalize collision option
  572. if ( collision.length === 1 ) {
  573. collision[ 1 ] = collision[ 0 ];
  574. }
  575. // normalize offset option
  576. offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
  577. if ( offset.length === 1 ) {
  578. offset[ 1 ] = offset[ 0 ];
  579. }
  580. offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
  581. if ( options.at[0] === "right" ) {
  582. basePosition.left += targetWidth;
  583. } else if (options.at[0] === horizontalDefault ) {
  584. basePosition.left += targetWidth / 2;
  585. }
  586. if ( options.at[1] === "bottom" ) {
  587. basePosition.top += targetHeight;
  588. } else if ( options.at[1] === verticalDefault ) {
  589. basePosition.top += targetHeight / 2;
  590. }
  591. basePosition.left += offset[ 0 ];
  592. basePosition.top += offset[ 1 ];
  593. return this.each(function() {
  594. var elem = $( this ),
  595. elemWidth = elem.outerWidth(),
  596. elemHeight = elem.outerHeight(),
  597. position = $.extend( {}, basePosition );
  598. if ( options.my[0] === "right" ) {
  599. position.left -= elemWidth;
  600. } else if ( options.my[0] === horizontalDefault ) {
  601. position.left -= elemWidth / 2;
  602. }
  603. if ( options.my[1] === "bottom" ) {
  604. position.top -= elemHeight;
  605. } else if ( options.my[1] === verticalDefault ) {
  606. position.top -= elemHeight / 2;
  607. }
  608. $.each( [ "left", "top" ], function( i, dir ) {
  609. if ( $.ui.position[ collision[i] ] ) {
  610. $.ui.position[ collision[i] ][ dir ]( position, {
  611. targetWidth: targetWidth,
  612. targetHeight: targetHeight,
  613. elemWidth: elemWidth,
  614. elemHeight: elemHeight,
  615. offset: offset,
  616. my: options.my,
  617. at: options.at
  618. });
  619. }
  620. });
  621. if ( $.fn.bgiframe ) {
  622. elem.bgiframe();
  623. }
  624. elem.offset( $.extend( position, { using: options.using } ) );
  625. });
  626. };
  627. $.ui.position = {
  628. fit: {
  629. left: function( position, data ) {
  630. var win = $( window ),
  631. over = position.left + data.elemWidth - win.width() - win.scrollLeft();
  632. position.left = over > 0 ? position.left - over : Math.max( 0, position.left );
  633. },
  634. top: function( position, data ) {
  635. var win = $( window ),
  636. over = position.top + data.elemHeight - win.height() - win.scrollTop();
  637. position.top = over > 0 ? position.top - over : Math.max( 0, position.top );
  638. }
  639. },
  640. flip: {
  641. left: function( position, data ) {
  642. if ( data.at[0] === "center" ) {
  643. return;
  644. }
  645. var win = $( window ),
  646. over = position.left + data.elemWidth - win.width() - win.scrollLeft(),
  647. myOffset = data.my[ 0 ] === "left" ?
  648. -data.elemWidth :
  649. data.my[ 0 ] === "right" ?
  650. data.elemWidth :
  651. 0,
  652. offset = -2 * data.offset[ 0 ];
  653. position.left += position.left < 0 ?
  654. myOffset + data.targetWidth + offset :
  655. over > 0 ?
  656. myOffset - data.targetWidth + offset :
  657. 0;
  658. },
  659. top: function( position, data ) {
  660. if ( data.at[1] === "center" ) {
  661. return;
  662. }
  663. var win = $( window ),
  664. over = position.top + data.elemHeight - win.height() - win.scrollTop(),
  665. myOffset = data.my[ 1 ] === "top" ?
  666. -data.elemHeight :
  667. data.my[ 1 ] === "bottom" ?
  668. data.elemHeight :
  669. 0,
  670. atOffset = data.at[ 1 ] === "top" ?
  671. data.targetHeight :
  672. -data.targetHeight,
  673. offset = -2 * data.offset[ 1 ];
  674. position.top += position.top < 0 ?
  675. myOffset + data.targetHeight + offset :
  676. over > 0 ?
  677. myOffset + atOffset + offset :
  678. 0;
  679. }
  680. }
  681. };
  682. // offset setter from jQuery 1.4
  683. if ( !$.offset.setOffset ) {
  684. $.offset.setOffset = function( elem, options ) {
  685. // set position first, in-case top/left are set even on static elem
  686. if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
  687. elem.style.position = "relative";
  688. }
  689. var curElem = $( elem ),
  690. curOffset = curElem.offset(),
  691. curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
  692. curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
  693. props = {
  694. top: (options.top - curOffset.top) + curTop,
  695. left: (options.left - curOffset.left) + curLeft
  696. };
  697. if ( 'using' in options ) {
  698. options.using.call( elem, props );
  699. } else {
  700. curElem.css( props );
  701. }
  702. };
  703. $.fn.offset = function( options ) {
  704. var elem = this[ 0 ];
  705. if ( !elem || !elem.ownerDocument ) { return null; }
  706. if ( options ) {
  707. return this.each(function() {
  708. $.offset.setOffset( this, options );
  709. });
  710. }
  711. return _offset.call( this );
  712. };
  713. }
  714. }( jQuery ));
  715. /*
  716. * jQuery UI Draggable 1.8
  717. *
  718. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  719. * Dual licensed under the MIT (MIT-LICENSE.txt)
  720. * and GPL (GPL-LICENSE.txt) licenses.
  721. *
  722. * http://docs.jquery.com/UI/Draggables
  723. *
  724. * Depends:
  725. * jquery.ui.core.js
  726. * jquery.ui.mouse.js
  727. * jquery.ui.widget.js
  728. */
  729. (function($) {
  730. $.widget("ui.draggable", $.ui.mouse, {
  731. widgetEventPrefix: "drag",
  732. options: {
  733. addClasses: true,
  734. appendTo: "parent",
  735. axis: false,
  736. connectToSortable: false,
  737. containment: false,
  738. cursor: "auto",
  739. cursorAt: false,
  740. grid: false,
  741. handle: false,
  742. helper: "original",
  743. iframeFix: false,
  744. opacity: false,
  745. refreshPositions: false,
  746. revert: false,
  747. revertDuration: 500,
  748. scope: "default",
  749. scroll: true,
  750. scrollSensitivity: 20,
  751. scrollSpeed: 20,
  752. snap: false,
  753. snapMode: "both",
  754. snapTolerance: 20,
  755. stack: false,
  756. zIndex: false
  757. },
  758. _create: function() {
  759. if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
  760. this.element[0].style.position = 'relative';
  761. (this.options.addClasses && this.element.addClass("ui-draggable"));
  762. (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
  763. this._mouseInit();
  764. },
  765. destroy: function() {
  766. if(!this.element.data('draggable')) return;
  767. this.element
  768. .removeData("draggable")
  769. .unbind(".draggable")
  770. .removeClass("ui-draggable"
  771. + " ui-draggable-dragging"
  772. + " ui-draggable-disabled");
  773. this._mouseDestroy();
  774. return this;
  775. },
  776. _mouseCapture: function(event) {
  777. var o = this.options;
  778. // among others, prevent a drag on a resizable-handle
  779. if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
  780. return false;
  781. //Quit if we're not on a valid handle
  782. this.handle = this._getHandle(event);
  783. if (!this.handle)
  784. return false;
  785. return true;
  786. },
  787. _mouseStart: function(event) {
  788. var o = this.options;
  789. //Create and append the visible helper
  790. this.helper = this._createHelper(event);
  791. //Cache the helper size
  792. this._cacheHelperProportions();
  793. //If ddmanager is used for droppables, set the global draggable
  794. if($.ui.ddmanager)
  795. $.ui.ddmanager.current = this;
  796. /*
  797. * - Position generation -
  798. * This block generates everything position related - it's the core of draggables.
  799. */
  800. //Cache the margins of the original element
  801. this._cacheMargins();
  802. //Store the helper's css position
  803. this.cssPosition = this.helper.css("position");
  804. this.scrollParent = this.helper.scrollParent();
  805. //The element's absolute position on the page minus margins
  806. this.offset = this.positionAbs = this.element.offset();
  807. this.offset = {
  808. top: this.offset.top - this.margins.top,
  809. left: this.offset.left - this.margins.left
  810. };
  811. $.extend(this.offset, {
  812. click: { //Where the click happened, relative to the element
  813. left: event.pageX - this.offset.left,
  814. top: event.pageY - this.offset.top
  815. },
  816. parent: this._getParentOffset(),
  817. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  818. });
  819. //Generate the original position
  820. this.originalPosition = this.position = this._generatePosition(event);
  821. this.originalPageX = event.pageX;
  822. this.originalPageY = event.pageY;
  823. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  824. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  825. //Set a containment if given in the options
  826. if(o.containment)
  827. this._setContainment();
  828. //Trigger event + callbacks
  829. if(this._trigger("start", event) === false) {
  830. this._clear();
  831. return false;
  832. }
  833. //Recache the helper size
  834. this._cacheHelperProportions();
  835. //Prepare the droppable offsets
  836. if ($.ui.ddmanager && !o.dropBehaviour)
  837. $.ui.ddmanager.prepareOffsets(this, event);
  838. this.helper.addClass("ui-draggable-dragging");
  839. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  840. return true;
  841. },
  842. _mouseDrag: function(event, noPropagation) {
  843. //Compute the helpers position
  844. this.position = this._generatePosition(event);
  845. this.positionAbs = this._convertPositionTo("absolute");
  846. //Call plugins and callbacks and use the resulting position if something is returned
  847. if (!noPropagation) {
  848. var ui = this._uiHash();
  849. if(this._trigger('drag', event, ui) === false) {
  850. this._mouseUp({});
  851. return false;
  852. }
  853. this.position = ui.position;
  854. }
  855. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  856. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  857. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  858. return false;
  859. },
  860. _mouseStop: function(event) {
  861. //If we are using droppables, inform the manager about the drop
  862. var dropped = false;
  863. if ($.ui.ddmanager && !this.options.dropBehaviour)
  864. dropped = $.ui.ddmanager.drop(this, event);
  865. //if a drop comes from outside (a sortable)
  866. if(this.dropped) {
  867. dropped = this.dropped;
  868. this.dropped = false;
  869. }
  870. //if the original element is removed, don't bother to continue
  871. if(!this.element[0] || !this.element[0].parentNode)
  872. return false;
  873. 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))) {
  874. var self = this;
  875. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  876. if(self._trigger("stop", event) !== false) {
  877. self._clear();
  878. }
  879. });
  880. } else {
  881. if(this._trigger("stop", event) !== false) {
  882. this._clear();
  883. }
  884. }
  885. return false;
  886. },
  887. cancel: function() {
  888. if(this.helper.is(".ui-draggable-dragging")) {
  889. this._mouseUp({});
  890. } else {
  891. this._clear();
  892. }
  893. return this;
  894. },
  895. _getHandle: function(event) {
  896. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  897. $(this.options.handle, this.element)
  898. .find("*")
  899. .andSelf()
  900. .each(function() {
  901. if(this == event.target) handle = true;
  902. });
  903. return handle;
  904. },
  905. _createHelper: function(event) {
  906. var o = this.options;
  907. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
  908. if(!helper.parents('body').length)
  909. helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
  910. if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
  911. helper.css("position", "absolute");
  912. return helper;
  913. },
  914. _adjustOffsetFromHelper: function(obj) {
  915. if (typeof obj == 'string') {
  916. obj = obj.split(' ');
  917. }
  918. if ($.isArray(obj)) {
  919. obj = {left: +obj[0], top: +obj[1] || 0};
  920. }
  921. if ('left' in obj) {
  922. this.offset.click.left = obj.left + this.margins.left;
  923. }
  924. if ('right' in obj) {
  925. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  926. }
  927. if ('top' in obj) {
  928. this.offset.click.top = obj.top + this.margins.top;
  929. }
  930. if ('bottom' in obj) {
  931. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  932. }
  933. },
  934. _getParentOffset: function() {
  935. //Get the offsetParent and cache its position
  936. this.offsetParent = this.helper.offsetParent();
  937. var po = this.offsetParent.offset();
  938. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  939. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  940. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  941. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  942. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  943. po.left += this.scrollParent.scrollLeft();
  944. po.top += this.scrollParent.scrollTop();
  945. }
  946. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  947. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  948. po = { top: 0, left: 0 };
  949. return {
  950. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  951. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  952. };
  953. },
  954. _getRelativeOffset: function() {
  955. if(this.cssPosition == "relative") {
  956. var p = this.element.position();
  957. return {
  958. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  959. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  960. };
  961. } else {
  962. return { top: 0, left: 0 };
  963. }
  964. },
  965. _cacheMargins: function() {
  966. this.margins = {
  967. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  968. top: (parseInt(this.element.css("marginTop"),10) || 0)
  969. };
  970. },
  971. _cacheHelperProportions: function() {
  972. this.helperProportions = {
  973. width: this.helper.outerWidth(),
  974. height: this.helper.outerHeight()
  975. };
  976. },
  977. _setContainment: function() {
  978. var o = this.options;
  979. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  980. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  981. 0 - this.offset.relative.left - this.offset.parent.left,
  982. 0 - this.offset.relative.top - this.offset.parent.top,
  983. $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  984. ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  985. ];
  986. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
  987. var ce = $(o.containment)[0]; if(!ce) return;
  988. var co = $(o.containment).offset();
  989. var over = ($(ce).css("overflow") != 'hidden');
  990. this.containment = [
  991. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  992. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  993. 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,
  994. 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
  995. ];
  996. } else if(o.containment.constructor == Array) {
  997. this.containment = o.containment;
  998. }
  999. },
  1000. _convertPositionTo: function(d, pos) {
  1001. if(!pos) pos = this.position;
  1002. var mod = d == "absolute" ? 1 : -1;
  1003. 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);
  1004. return {
  1005. top: (
  1006. pos.top // The absolute mouse position
  1007. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  1008. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  1009. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  1010. ),
  1011. left: (
  1012. pos.left // The absolute mouse position
  1013. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  1014. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  1015. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  1016. )
  1017. };
  1018. },
  1019. _generatePosition: function(event) {
  1020. 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);
  1021. var pageX = event.pageX;
  1022. var pageY = event.pageY;
  1023. /*
  1024. * - Position constraining -
  1025. * Constrain the position to a mix of grid, containment.
  1026. */
  1027. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  1028. if(this.containment) {
  1029. if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
  1030. if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
  1031. if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
  1032. if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
  1033. }
  1034. if(o.grid) {
  1035. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  1036. 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;
  1037. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  1038. 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;
  1039. }
  1040. }
  1041. return {
  1042. top: (
  1043. pageY // The absolute mouse position
  1044. - this.offset.click.top // Click offset (relative to the element)
  1045. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  1046. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  1047. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  1048. ),
  1049. left: (
  1050. pageX // The absolute mouse position
  1051. - this.offset.click.left // Click offset (relative to the element)
  1052. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  1053. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  1054. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  1055. )
  1056. };
  1057. },
  1058. _clear: function() {
  1059. this.helper.removeClass("ui-draggable-dragging");
  1060. if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
  1061. //if($.ui.ddmanager) $.ui.ddmanager.current = null;
  1062. this.helper = null;
  1063. this.cancelHelperRemoval = false;
  1064. },
  1065. // From now on bulk stuff - mainly helpers
  1066. _trigger: function(type, event, ui) {
  1067. ui = ui || this._uiHash();
  1068. $.ui.plugin.call(this, type, [event, ui]);
  1069. if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
  1070. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1071. },
  1072. plugins: {},
  1073. _uiHash: function(event) {
  1074. return {
  1075. helper: this.helper,
  1076. position: this.position,
  1077. originalPosition: this.originalPosition,
  1078. offset: this.positionAbs
  1079. };
  1080. }
  1081. });
  1082. $.extend($.ui.draggable, {
  1083. version: "1.8"
  1084. });
  1085. $.ui.plugin.add("draggable", "connectToSortable", {
  1086. start: function(event, ui) {
  1087. var inst = $(this).data("draggable"), o = inst.options,
  1088. uiSortable = $.extend({}, ui, { item: inst.element });
  1089. inst.sortables = [];
  1090. $(o.connectToSortable).each(function() {
  1091. var sortable = $.data(this, 'sortable');
  1092. if (sortable && !sortable.options.disabled) {
  1093. inst.sortables.push({
  1094. instance: sortable,
  1095. shouldRevert: sortable.options.revert
  1096. });
  1097. sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
  1098. sortable._trigger("activate", event, uiSortable);
  1099. }
  1100. });
  1101. },
  1102. stop: function(event, ui) {
  1103. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1104. var inst = $(this).data("draggable"),
  1105. uiSortable = $.extend({}, ui, { item: inst.element });
  1106. $.each(inst.sortables, function() {
  1107. if(this.instance.isOver) {
  1108. this.instance.isOver = 0;
  1109. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1110. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1111. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
  1112. if(this.shouldRevert) this.instance.options.revert = true;
  1113. //Trigger the stop of the sortable
  1114. this.instance._mouseStop(event);
  1115. this.instance.options.helper = this.instance.options._helper;
  1116. //If the helper has been the original item, restore properties in the sortable
  1117. if(inst.options.helper == 'original')
  1118. this.instance.currentItem.css({ top: 'auto', left: 'auto' });
  1119. } else {
  1120. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1121. this.instance._trigger("deactivate", event, uiSortable);
  1122. }
  1123. });
  1124. },
  1125. drag: function(event, ui) {
  1126. var inst = $(this).data("draggable"), self = this;
  1127. var checkPos = function(o) {
  1128. var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
  1129. var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
  1130. var itemHeight = o.height, itemWidth = o.width;
  1131. var itemTop = o.top, itemLeft = o.left;
  1132. return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
  1133. };
  1134. $.each(inst.sortables, function(i) {
  1135. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1136. this.instance.positionAbs = inst.positionAbs;
  1137. this.instance.helperProportions = inst.helperProportions;
  1138. this.instance.offset.click = inst.offset.click;
  1139. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1140. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1141. if(!this.instance.isOver) {
  1142. this.instance.isOver = 1;
  1143. //Now we fake the start of dragging for the sortable instance,
  1144. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1145. //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)
  1146. this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
  1147. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1148. this.instance.options.helper = function() { return ui.helper[0]; };
  1149. event.target = this.instance.currentItem[0];
  1150. this.instance._mouseCapture(event, true);
  1151. this.instance._mouseStart(event, true, true);
  1152. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1153. this.instance.offset.click.top = inst.offset.click.top;
  1154. this.instance.offset.click.left = inst.offset.click.left;
  1155. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1156. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1157. inst._trigger("toSortable", event);
  1158. inst.dropped = this.instance.element; //draggable revert needs that
  1159. //hack so receive/update callbacks work (mostly)
  1160. inst.currentItem = inst.element;
  1161. this.instance.fromOutside = inst;
  1162. }
  1163. //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
  1164. if(this.instance.currentItem) this.instance._mouseDrag(event);
  1165. } else {
  1166. //If it doesn't intersect with the sortable, and it intersected before,
  1167. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1168. if(this.instance.isOver) {
  1169. this.instance.isOver = 0;
  1170. this.instance.cancelHelperRemoval = true;
  1171. //Prevent reverting on this forced stop
  1172. this.instance.options.revert = false;
  1173. // The out event needs to be triggered independently
  1174. this.instance._trigger('out', event, this.instance._uiHash(this.instance));
  1175. this.instance._mouseStop(event, true);
  1176. this.instance.options.helper = this.instance.options._helper;
  1177. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1178. this.instance.currentItem.remove();
  1179. if(this.instance.placeholder) this.instance.placeholder.remove();
  1180. inst._trigger("fromSortable", event);
  1181. inst.dropped = false; //draggable revert needs that
  1182. }
  1183. };
  1184. });
  1185. }
  1186. });
  1187. $.ui.plugin.add("draggable", "cursor", {
  1188. start: function(event, ui) {
  1189. var t = $('body'), o = $(this).data('draggable').options;
  1190. if (t.css("cursor")) o._cursor = t.css("cursor");
  1191. t.css("cursor", o.cursor);
  1192. },
  1193. stop: function(event, ui) {
  1194. var o = $(this).data('draggable').options;
  1195. if (o._cursor) $('body').css("cursor", o._cursor);
  1196. }
  1197. });
  1198. $.ui.plugin.add("draggable", "iframeFix", {
  1199. start: function(event, ui) {
  1200. var o = $(this).data('draggable').options;
  1201. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  1202. $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
  1203. .css({
  1204. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  1205. position: "absolute", opacity: "0.001", zIndex: 1000
  1206. })
  1207. .css($(this).offset())
  1208. .appendTo("body");
  1209. });
  1210. },
  1211. stop: function(event, ui) {
  1212. $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
  1213. }
  1214. });
  1215. $.ui.plugin.add("draggable", "opacity", {
  1216. start: function(event, ui) {
  1217. var t = $(ui.helper), o = $(this).data('draggable').options;
  1218. if(t.css("opacity")) o._opacity = t.css("opacity");
  1219. t.css('opacity', o.opacity);
  1220. },
  1221. stop: function(event, ui) {
  1222. var o = $(this).data('draggable').options;
  1223. if(o._opacity) $(ui.helper).css('opacity', o._opacity);
  1224. }
  1225. });
  1226. $.ui.plugin.add("draggable", "scroll", {
  1227. start: function(event, ui) {
  1228. var i = $(this).data("draggable");
  1229. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
  1230. },
  1231. drag: function(event, ui) {
  1232. var i = $(this).data("draggable"), o = i.options, scrolled = false;
  1233. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
  1234. if(!o.axis || o.axis != 'x') {
  1235. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  1236. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1237. else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
  1238. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1239. }
  1240. if(!o.axis || o.axis != 'y') {
  1241. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  1242. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1243. else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
  1244. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1245. }
  1246. } else {
  1247. if(!o.axis || o.axis != 'x') {
  1248. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  1249. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1250. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  1251. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1252. }
  1253. if(!o.axis || o.axis != 'y') {
  1254. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  1255. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1256. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  1257. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1258. }
  1259. }
  1260. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  1261. $.ui.ddmanager.prepareOffsets(i, event);
  1262. }
  1263. });
  1264. $.ui.plugin.add("draggable", "snap", {
  1265. start: function(event, ui) {
  1266. var i = $(this).data("draggable"), o = i.options;
  1267. i.snapElements = [];
  1268. $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
  1269. var $t = $(this); var $o = $t.offset();
  1270. if(this != i.element[0]) i.snapElements.push({
  1271. item: this,
  1272. width: $t.outerWidth(), height: $t.outerHeight(),
  1273. top: $o.top, left: $o.left
  1274. });
  1275. });
  1276. },
  1277. drag: function(event, ui) {
  1278. var inst = $(this).data("draggable"), o = inst.options;
  1279. var d = o.snapTolerance;
  1280. var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1281. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1282. for (var i = inst.snapElements.length - 1; i >= 0; i--){
  1283. var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
  1284. t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
  1285. //Yes, I know, this is insane ;)
  1286. 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))) {
  1287. 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 })));
  1288. inst.snapElements[i].snapping = false;
  1289. continue;
  1290. }
  1291. if(o.snapMode != 'inner') {
  1292. var ts = Math.abs(t - y2) <= d;
  1293. var bs = Math.abs(b - y1) <= d;
  1294. var ls = Math.abs(l - x2) <= d;
  1295. var rs = Math.abs(r - x1) <= d;
  1296. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1297. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1298. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1299. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1300. }
  1301. var first = (ts || bs || ls || rs);
  1302. if(o.snapMode != 'outer') {
  1303. var ts = Math.abs(t - y1) <= d;
  1304. var bs = Math.abs(b - y2) <= d;
  1305. var ls = Math.abs(l - x1) <= d;
  1306. var rs = Math.abs(r - x2) <= d;
  1307. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1308. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1309. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1310. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1311. }
  1312. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
  1313. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1314. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1315. };
  1316. }
  1317. });
  1318. $.ui.plugin.add("draggable", "stack", {
  1319. start: function(event, ui) {
  1320. var o = $(this).data("draggable").options;
  1321. var group = $.makeArray($(o.stack)).sort(function(a,b) {
  1322. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1323. });
  1324. if (!group.length) { return; }
  1325. var min = parseInt(group[0].style.zIndex) || 0;
  1326. $(group).each(function(i) {
  1327. this.style.zIndex = min + i;
  1328. });
  1329. this[0].style.zIndex = min + group.length;
  1330. }
  1331. });
  1332. $.ui.plugin.add("draggable", "zIndex", {
  1333. start: function(event, ui) {
  1334. var t = $(ui.helper), o = $(this).data("draggable").options;
  1335. if(t.css("zIndex")) o._zIndex = t.css("zIndex");
  1336. t.css('zIndex', o.zIndex);
  1337. },
  1338. stop: function(event, ui) {
  1339. var o = $(this).data("draggable").options;
  1340. if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
  1341. }
  1342. });
  1343. })(jQuery);
  1344. /*
  1345. * jQuery UI Droppable 1.8
  1346. *
  1347. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  1348. * Dual licensed under the MIT (MIT-LICENSE.txt)
  1349. * and GPL (GPL-LICENSE.txt) licenses.
  1350. *
  1351. * http://docs.jquery.com/UI/Droppables
  1352. *
  1353. * Depends:
  1354. * jquery.ui.core.js
  1355. * jquery.ui.widget.js
  1356. * jquery.ui.mouse.js
  1357. * jquery.ui.draggable.js
  1358. */
  1359. (function($) {
  1360. $.widget("ui.droppable", {
  1361. widgetEventPrefix: "drop",
  1362. options: {
  1363. accept: '*',
  1364. activeClass: false,
  1365. addClasses: true,
  1366. greedy: false,
  1367. hoverClass: false,
  1368. scope: 'default',
  1369. tolerance: 'intersect'
  1370. },
  1371. _create: function() {
  1372. var o = this.options, accept = o.accept;
  1373. this.isover = 0; this.isout = 1;
  1374. this.accept = $.isFunction(accept) ? accept : function(d) {
  1375. return d.is(accept);
  1376. };
  1377. //Store the droppable's proportions
  1378. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1379. // Add the reference and positions to the manager
  1380. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1381. $.ui.ddmanager.droppables[o.scope].push(this);
  1382. (o.addClasses && this.element.addClass("ui-droppable"));
  1383. },
  1384. destroy: function() {
  1385. var drop = $.ui.ddmanager.droppables[this.options.scope];
  1386. for ( var i = 0; i < drop.length; i++ )
  1387. if ( drop[i] == this )
  1388. drop.splice(i, 1);
  1389. this.element
  1390. .removeClass("ui-droppable ui-droppable-disabled")
  1391. .removeData("droppable")
  1392. .unbind(".droppable");
  1393. return this;
  1394. },
  1395. _setOption: function(key, value) {
  1396. if(key == 'accept') {
  1397. this.accept = $.isFunction(value) ? value : function(d) {
  1398. return d.is(value);
  1399. };
  1400. }
  1401. $.Widget.prototype._setOption.apply(this, arguments);
  1402. },
  1403. _activate: function(event) {
  1404. var draggable = $.ui.ddmanager.current;
  1405. if(this.options.activeClass) this.element.addClass(this.options.activeClass);
  1406. (draggable && this._trigger('activate', event, this.ui(draggable)));
  1407. },
  1408. _deactivate: function(event) {
  1409. var draggable = $.ui.ddmanager.current;
  1410. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1411. (draggable && this._trigger('deactivate', event, this.ui(draggable)));
  1412. },
  1413. _over: function(event) {
  1414. var draggable = $.ui.ddmanager.current;
  1415. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1416. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1417. if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
  1418. this._trigger('over', event, this.ui(draggable));
  1419. }
  1420. },
  1421. _out: function(event) {
  1422. var draggable = $.ui.ddmanager.current;
  1423. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1424. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1425. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1426. this._trigger('out', event, this.ui(draggable));
  1427. }
  1428. },
  1429. _drop: function(event,custom) {
  1430. var draggable = custom || $.ui.ddmanager.current;
  1431. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
  1432. var childrenIntersection = false;
  1433. this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
  1434. var inst = $.data(this, 'droppable');
  1435. if(
  1436. inst.options.greedy
  1437. && !inst.options.disabled
  1438. && inst.options.scope == draggable.options.scope
  1439. && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
  1440. && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1441. ) { childrenIntersection = true; return false; }
  1442. });
  1443. if(childrenIntersection) return false;
  1444. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1445. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1446. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1447. this._trigger('drop', event, this.ui(draggable));
  1448. return this.element;
  1449. }
  1450. return false;
  1451. },
  1452. ui: function(c) {
  1453. return {
  1454. draggable: (c.currentItem || c.element),
  1455. helper: c.helper,
  1456. position: c.position,
  1457. offset: c.positionAbs
  1458. };
  1459. }
  1460. });
  1461. $.extend($.ui.droppable, {
  1462. version: "1.8"
  1463. });
  1464. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1465. if (!droppable.offset) return false;
  1466. var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1467. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
  1468. var l = droppable.offset.left, r = l + droppable.proportions.width,
  1469. t = droppable.offset.top, b = t + droppable.proportions.height;
  1470. switch (toleranceMode) {
  1471. case 'fit':
  1472. return (l < x1 && x2 < r
  1473. && t < y1 && y2 < b);
  1474. break;
  1475. case 'intersect':
  1476. return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
  1477. && x2 - (draggable.helperProportions.width / 2) < r // Left Half
  1478. && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
  1479. && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1480. break;
  1481. case 'pointer':
  1482. var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
  1483. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
  1484. isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
  1485. return isOver;
  1486. break;
  1487. case 'touch':
  1488. return (
  1489. (y1 >= t && y1 <= b) || // Top edge touching
  1490. (y2 >= t && y2 <= b) || // Bottom edge touching
  1491. (y1 < t && y2 > b) // Surrounded vertically
  1492. ) && (
  1493. (x1 >= l && x1 <= r) || // Left edge touching
  1494. (x2 >= l && x2 <= r) || // Right edge touching
  1495. (x1 < l && x2 > r) // Surrounded horizontally
  1496. );
  1497. break;
  1498. default:
  1499. return false;
  1500. break;
  1501. }
  1502. };
  1503. /*
  1504. This manager tracks offsets of draggables and droppables
  1505. */
  1506. $.ui.ddmanager = {
  1507. current: null,
  1508. droppables: { 'default': [] },
  1509. prepareOffsets: function(t, event) {
  1510. var m = $.ui.ddmanager.droppables[t.options.scope] || [];
  1511. var type = event ? event.type : null; // workaround for #2317
  1512. var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
  1513. droppablesLoop: for (var i = 0; i < m.length; i++) {
  1514. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
  1515. 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
  1516. m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
  1517. m[i].offset = m[i].element.offset();
  1518. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1519. if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
  1520. }
  1521. },
  1522. drop: function(draggable, event) {
  1523. var dropped = false;
  1524. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1525. if(!this.options) return;
  1526. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
  1527. dropped = dropped || this._drop.call(this, event);
  1528. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1529. this.isout = 1; this.isover = 0;
  1530. this._deactivate.call(this, event);
  1531. }
  1532. });
  1533. return dropped;
  1534. },
  1535. drag: function(draggable, event) {
  1536. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1537. if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
  1538. //Run through all droppables and check their positions based on specific tolerance options
  1539. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1540. if(this.options.disabled || this.greedyChild || !this.visible) return;
  1541. var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
  1542. var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
  1543. if(!c) return;
  1544. var parentInstance;
  1545. if (this.options.greedy) {
  1546. var parent = this.element.parents(':data(droppable):eq(0)');
  1547. if (parent.length) {
  1548. parentInstance = $.data(parent[0], 'droppable');
  1549. parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
  1550. }
  1551. }
  1552. // we just moved into a greedy child
  1553. if (parentInstance && c == 'isover') {
  1554. parentInstance['isover'] = 0;
  1555. parentInstance['isout'] = 1;
  1556. parentInstance._out.call(parentInstance, event);
  1557. }
  1558. this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
  1559. this[c == "isover" ? "_over" : "_out"].call(this, event);
  1560. // we just moved out of a greedy child
  1561. if (parentInstance && c == 'isout') {
  1562. parentInstance['isout'] = 0;
  1563. parentInstance['isover'] = 1;
  1564. parentInstance._over.call(parentInstance, event);
  1565. }
  1566. });
  1567. }
  1568. };
  1569. })(jQuery);
  1570. /*
  1571. * jQuery UI Resizable 1.8
  1572. *
  1573. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  1574. * Dual licensed under the MIT (MIT-LICENSE.txt)
  1575. * and GPL (GPL-LICENSE.txt) licenses.
  1576. *
  1577. * http://docs.jquery.com/UI/Resizables
  1578. *
  1579. * Depends:
  1580. * jquery.ui.core.js
  1581. * jquery.ui.mouse.js
  1582. * jquery.ui.widget.js
  1583. */
  1584. (function($) {
  1585. $.widget("ui.resizable", $.ui.mouse, {
  1586. widgetEventPrefix: "resize",
  1587. options: {
  1588. alsoResize: false,
  1589. animate: false,
  1590. animateDuration: "slow",
  1591. animateEasing: "swing",
  1592. aspectRatio: false,
  1593. autoHide: false,
  1594. containment: false,
  1595. ghost: false,
  1596. grid: false,
  1597. handles: "e,s,se",
  1598. helper: false,
  1599. maxHeight: null,
  1600. maxWidth: null,
  1601. minHeight: 10,
  1602. minWidth: 10,
  1603. zIndex: 1000
  1604. },
  1605. _create: function() {
  1606. var self = this, o = this.options;
  1607. this.element.addClass("ui-resizable");
  1608. $.extend(this, {
  1609. _aspectRatio: !!(o.aspectRatio),
  1610. aspectRatio: o.aspectRatio,
  1611. originalElement: this.element,
  1612. _proportionallyResizeElements: [],
  1613. _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
  1614. });
  1615. //Wrap the element if it cannot hold child nodes
  1616. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1617. //Opera fix for relative positioning
  1618. if (/relative/.test(this.element.css('position')) && $.browser.opera)
  1619. this.element.css({ position: 'relative', top: 'auto', left: 'auto' });
  1620. //Create a wrapper element and set the wrapper to the new current internal element
  1621. this.element.wrap(
  1622. $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
  1623. position: this.element.css('position'),
  1624. width: this.element.outerWidth(),
  1625. height: this.element.outerHeight(),
  1626. top: this.element.css('top'),
  1627. left: this.element.css('left')
  1628. })
  1629. );
  1630. //Overwrite the original this.element
  1631. this.element = this.element.parent().data(
  1632. "resizable", this.element.data('resizable')
  1633. );
  1634. this.elementIsWrapper = true;
  1635. //Move margins to the wrapper
  1636. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1637. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1638. //Prevent Safari textarea resize
  1639. this.originalResizeStyle = this.originalElement.css('resize');
  1640. this.originalElement.css('resize', 'none');
  1641. //Push the actual element to our proportionallyResize internal array
  1642. this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
  1643. // avoid IE jump (hard set the margin)
  1644. this.originalElement.css({ margin: this.originalElement.css('margin') });
  1645. // fix handlers offset
  1646. this._proportionallyResize();
  1647. }
  1648. 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' });
  1649. if(this.handles.constructor == String) {
  1650. if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
  1651. var n = this.handles.split(","); this.handles = {};
  1652. for(var i = 0; i < n.length; i++) {
  1653. var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
  1654. var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
  1655. // increase zIndex of sw, se, ne, nw axis
  1656. //TODO : this modifies original option
  1657. if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex });
  1658. //TODO : What's going on here?
  1659. if ('se' == handle) {
  1660. axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
  1661. };
  1662. //Insert into internal handles object and append to element
  1663. this.handles[handle] = '.ui-resizable-'+handle;
  1664. this.element.append(axis);
  1665. }
  1666. }
  1667. this._renderAxis = function(target) {
  1668. target = target || this.element;
  1669. for(var i in this.handles) {
  1670. if(this.handles[i].constructor == String)
  1671. this.handles[i] = $(this.handles[i], this.element).show();
  1672. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  1673. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  1674. var axis = $(this.handles[i], this.element), padWrapper = 0;
  1675. //Checking the correct pad and border
  1676. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  1677. //The padding type i have to apply...
  1678. var padPos = [ 'padding',
  1679. /ne|nw|n/.test(i) ? 'Top' :
  1680. /se|sw|s/.test(i) ? 'Bottom' :
  1681. /^e$/.test(i) ? 'Right' : 'Left' ].join("");
  1682. target.css(padPos, padWrapper);
  1683. this._proportionallyResize();
  1684. }
  1685. //TODO: What's that good for? There's not anything to be executed left
  1686. if(!$(this.handles[i]).length)
  1687. continue;
  1688. }
  1689. };
  1690. //TODO: make renderAxis a prototype function
  1691. this._renderAxis(this.element);
  1692. this._handles = $('.ui-resizable-handle', this.element)
  1693. .disableSelection();
  1694. //Matching axis name
  1695. this._handles.mouseover(function() {
  1696. if (!self.resizing) {
  1697. if (this.className)
  1698. var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  1699. //Axis, default = se
  1700. self.axis = axis && axis[1] ? axis[1] : 'se';
  1701. }
  1702. });
  1703. //If we want to auto hide the elements
  1704. if (o.autoHide) {
  1705. this._handles.hide();
  1706. $(this.element)
  1707. .addClass("ui-resizable-autohide")
  1708. .hover(function() {
  1709. $(this).removeClass("ui-resizable-autohide");
  1710. self._handles.show();
  1711. },
  1712. function(){
  1713. if (!self.resizing) {
  1714. $(this).addClass("ui-resizable-autohide");
  1715. self._handles.hide();
  1716. }
  1717. });
  1718. }
  1719. //Initialize the mouse interaction
  1720. this._mouseInit();
  1721. },
  1722. destroy: function() {
  1723. this._mouseDestroy();
  1724. var _destroy = function(exp) {
  1725. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  1726. .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
  1727. };
  1728. //TODO: Unwrap at same DOM position
  1729. if (this.elementIsWrapper) {
  1730. _destroy(this.element);
  1731. var wrapper = this.element;
  1732. wrapper.after(
  1733. this.originalElement.css({
  1734. position: wrapper.css('position'),
  1735. width: wrapper.outerWidth(),
  1736. height: wrapper.outerHeight(),
  1737. top: wrapper.css('top'),
  1738. left: wrapper.css('left')
  1739. })
  1740. ).remove();
  1741. }
  1742. this.originalElement.css('resize', this.originalResizeStyle);
  1743. _destroy(this.originalElement);
  1744. return this;
  1745. },
  1746. _mouseCapture: function(event) {
  1747. var handle = false;
  1748. for (var i in this.handles) {
  1749. if ($(this.handles[i])[0] == event.target) {
  1750. handle = true;
  1751. }
  1752. }
  1753. return !this.options.disabled && handle;
  1754. },
  1755. _mouseStart: function(event) {
  1756. var o = this.options, iniPos = this.element.position(), el = this.element;
  1757. this.resizing = true;
  1758. this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
  1759. // bugfix for http://dev.jquery.com/ticket/1749
  1760. if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
  1761. el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
  1762. }
  1763. //Opera fixing relative position
  1764. if ($.browser.opera && (/relative/).test(el.css('position')))
  1765. el.css({ position: 'relative', top: 'auto', left: 'auto' });
  1766. this._renderProxy();
  1767. var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
  1768. if (o.containment) {
  1769. curleft += $(o.containment).scrollLeft() || 0;
  1770. curtop += $(o.containment).scrollTop() || 0;
  1771. }
  1772. //Store needed variables
  1773. this.offset = this.helper.offset();
  1774. this.position = { left: curleft, top: curtop };
  1775. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  1776. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  1777. this.originalPosition = { left: curleft, top: curtop };
  1778. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  1779. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  1780. //Aspect Ratio
  1781. this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  1782. var cursor = $('.ui-resizable-' + this.axis).css('cursor');
  1783. $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
  1784. el.addClass("ui-resizable-resizing");
  1785. this._propagate("start", event);
  1786. return true;
  1787. },
  1788. _mouseDrag: function(event) {
  1789. //Increase performance, avoid regex
  1790. var el = this.helper, o = this.options, props = {},
  1791. self = this, smp = this.originalMousePosition, a = this.axis;
  1792. var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
  1793. var trigger = this._change[a];
  1794. if (!trigger) return false;
  1795. // Calculate the attrs that will be change
  1796. var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
  1797. if (this._aspectRatio || event.shiftKey)
  1798. data = this._updateRatio(data, event);
  1799. data = this._respectSize(data, event);
  1800. // plugins callbacks need to be called first
  1801. this._propagate("resize", event);
  1802. el.css({
  1803. top: this.position.top + "px", left: this.position.left + "px",
  1804. width: this.size.width + "px", height: this.size.height + "px"
  1805. });
  1806. if (!this._helper && this._proportionallyResizeElements.length)
  1807. this._proportionallyResize();
  1808. this._updateCache(data);
  1809. // calling the user callback at the end
  1810. this._trigger('resize', event, this.ui());
  1811. return false;
  1812. },
  1813. _mouseStop: function(event) {
  1814. this.resizing = false;
  1815. var o = this.options, self = this;
  1816. if(this._helper) {
  1817. var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  1818. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  1819. soffsetw = ista ? 0 : self.sizeDiff.width;
  1820. var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
  1821. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  1822. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  1823. if (!o.animate)
  1824. this.element.css($.extend(s, { top: top, left: left }));
  1825. self.helper.height(self.size.height);
  1826. self.helper.width(self.size.width);
  1827. if (this._helper && !o.animate) this._proportionallyResize();
  1828. }
  1829. $('body').css('cursor', 'auto');
  1830. this.element.removeClass("ui-resizable-resizing");
  1831. this._propagate("stop", event);
  1832. if (this._helper) this.helper.remove();
  1833. return false;
  1834. },
  1835. _updateCache: function(data) {
  1836. var o = this.options;
  1837. this.offset = this.helper.offset();
  1838. if (isNumber(data.left)) this.position.left = data.left;
  1839. if (isNumber(data.top)) this.position.top = data.top;
  1840. if (isNumber(data.height)) this.size.height = data.height;
  1841. if (isNumber(data.width)) this.size.width = data.width;
  1842. },
  1843. _updateRatio: function(data, event) {
  1844. var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
  1845. if (data.height) data.width = (csize.height * this.aspectRatio);
  1846. else if (data.width) data.height = (csize.width / this.aspectRatio);
  1847. if (a == 'sw') {
  1848. data.left = cpos.left + (csize.width - data.width);
  1849. data.top = null;
  1850. }
  1851. if (a == 'nw') {
  1852. data.top = cpos.top + (csize.height - data.height);
  1853. data.left = cpos.left + (csize.width - data.width);
  1854. }
  1855. return data;
  1856. },
  1857. _respectSize: function(data, event) {
  1858. var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
  1859. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  1860. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
  1861. if (isminw) data.width = o.minWidth;
  1862. if (isminh) data.height = o.minHeight;
  1863. if (ismaxw) data.width = o.maxWidth;
  1864. if (ismaxh) data.height = o.maxHeight;
  1865. var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
  1866. var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  1867. if (isminw && cw) data.left = dw - o.minWidth;
  1868. if (ismaxw && cw) data.left = dw - o.maxWidth;
  1869. if (isminh && ch) data.top = dh - o.minHeight;
  1870. if (ismaxh && ch) data.top = dh - o.maxHeight;
  1871. // fixing jump error on top/left - bug #2330
  1872. var isNotwh = !data.width && !data.height;
  1873. if (isNotwh && !data.left && data.top) data.top = null;
  1874. else if (isNotwh && !data.top && data.left) data.left = null;
  1875. return data;
  1876. },
  1877. _proportionallyResize: function() {
  1878. var o = this.options;
  1879. if (!this._proportionallyResizeElements.length) return;
  1880. var element = this.helper || this.element;
  1881. for (var i=0; i < this._proportionallyResizeElements.length; i++) {
  1882. var prel = this._proportionallyResizeElements[i];
  1883. if (!this.borderDif) {
  1884. var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
  1885. p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
  1886. this.borderDif = $.map(b, function(v, i) {
  1887. var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
  1888. return border + padding;
  1889. });
  1890. }
  1891. if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length)))
  1892. continue;
  1893. prel.css({
  1894. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  1895. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  1896. });
  1897. };
  1898. },
  1899. _renderProxy: function() {
  1900. var el = this.element, o = this.options;
  1901. this.elementOffset = el.offset();
  1902. if(this._helper) {
  1903. this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
  1904. // fix ie6 offset TODO: This seems broken
  1905. var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
  1906. pxyoffset = ( ie6 ? 2 : -1 );
  1907. this.helper.addClass(this._helper).css({
  1908. width: this.element.outerWidth() + pxyoffset,
  1909. height: this.element.outerHeight() + pxyoffset,
  1910. position: 'absolute',
  1911. left: this.elementOffset.left - ie6offset +'px',
  1912. top: this.elementOffset.top - ie6offset +'px',
  1913. zIndex: ++o.zIndex //TODO: Don't modify option
  1914. });
  1915. this.helper
  1916. .appendTo("body")
  1917. .disableSelection();
  1918. } else {
  1919. this.helper = this.element;
  1920. }
  1921. },
  1922. _change: {
  1923. e: function(event, dx, dy) {
  1924. return { width: this.originalSize.width + dx };
  1925. },
  1926. w: function(event, dx, dy) {
  1927. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  1928. return { left: sp.left + dx, width: cs.width - dx };
  1929. },
  1930. n: function(event, dx, dy) {
  1931. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  1932. return { top: sp.top + dy, height: cs.height - dy };
  1933. },
  1934. s: function(event, dx, dy) {
  1935. return { height: this.originalSize.height + dy };
  1936. },
  1937. se: function(event, dx, dy) {
  1938. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  1939. },
  1940. sw: function(event, dx, dy) {
  1941. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  1942. },
  1943. ne: function(event, dx, dy) {
  1944. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  1945. },
  1946. nw: function(event, dx, dy) {
  1947. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  1948. }
  1949. },
  1950. _propagate: function(n, event) {
  1951. $.ui.plugin.call(this, n, [event, this.ui()]);
  1952. (n != "resize" && this._trigger(n, event, this.ui()));
  1953. },
  1954. plugins: {},
  1955. ui: function() {
  1956. return {
  1957. originalElement: this.originalElement,
  1958. element: this.element,
  1959. helper: this.helper,
  1960. position: this.position,
  1961. size: this.size,
  1962. originalSize: this.originalSize,
  1963. originalPosition: this.originalPosition
  1964. };
  1965. }
  1966. });
  1967. $.extend($.ui.resizable, {
  1968. version: "1.8"
  1969. });
  1970. /*
  1971. * Resizable Extensions
  1972. */
  1973. $.ui.plugin.add("resizable", "alsoResize", {
  1974. start: function(event, ui) {
  1975. var self = $(this).data("resizable"), o = self.options;
  1976. var _store = function(exp) {
  1977. $(exp).each(function() {
  1978. $(this).data("resizable-alsoresize", {
  1979. width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10),
  1980. left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10)
  1981. });
  1982. });
  1983. };
  1984. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
  1985. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  1986. else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); }
  1987. }else{
  1988. _store(o.alsoResize);
  1989. }
  1990. },
  1991. resize: function(event, ui){
  1992. var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
  1993. var delta = {
  1994. height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
  1995. top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
  1996. },
  1997. _alsoResize = function(exp, c) {
  1998. $(exp).each(function() {
  1999. var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];
  2000. $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) {
  2001. var sum = (start[prop]||0) + (delta[prop]||0);
  2002. if (sum && sum >= 0)
  2003. style[prop] = sum || null;
  2004. });
  2005. //Opera fixing relative position
  2006. if (/relative/.test(el.css('position')) && $.browser.opera) {
  2007. self._revertToRelativePosition = true;
  2008. el.css({ position: 'absolute', top: 'auto', left: 'auto' });
  2009. }
  2010. el.css(style);
  2011. });
  2012. };
  2013. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
  2014. $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });
  2015. }else{
  2016. _alsoResize(o.alsoResize);
  2017. }
  2018. },
  2019. stop: function(event, ui){
  2020. var self = $(this).data("resizable");
  2021. //Opera fixing relative position
  2022. if (self._revertToRelativePosition && $.browser.opera) {
  2023. self._revertToRelativePosition = false;
  2024. el.css({ position: 'relative' });
  2025. }
  2026. $(this).removeData("resizable-alsoresize-start");
  2027. }
  2028. });
  2029. $.ui.plugin.add("resizable", "animate", {
  2030. stop: function(event, ui) {
  2031. var self = $(this).data("resizable"), o = self.options;
  2032. var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2033. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  2034. soffsetw = ista ? 0 : self.sizeDiff.width;
  2035. var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
  2036. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  2037. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  2038. self.element.animate(
  2039. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2040. duration: o.animateDuration,
  2041. easing: o.animateEasing,
  2042. step: function() {
  2043. var data = {
  2044. width: parseInt(self.element.css('width'), 10),
  2045. height: parseInt(self.element.css('height'), 10),
  2046. top: parseInt(self.element.css('top'), 10),
  2047. left: parseInt(self.element.css('left'), 10)
  2048. };
  2049. if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
  2050. // propagating resize, and updating values for each animation step
  2051. self._updateCache(data);
  2052. self._propagate("resize", event);
  2053. }
  2054. }
  2055. );
  2056. }
  2057. });
  2058. $.ui.plugin.add("resizable", "containment", {
  2059. start: function(event, ui) {
  2060. var self = $(this).data("resizable"), o = self.options, el = self.element;
  2061. var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2062. if (!ce) return;
  2063. self.containerElement = $(ce);
  2064. if (/document/.test(oc) || oc == document) {
  2065. self.containerOffset = { left: 0, top: 0 };
  2066. self.containerPosition = { left: 0, top: 0 };
  2067. self.parentData = {
  2068. element: $(document), left: 0, top: 0,
  2069. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2070. };
  2071. }
  2072. // i'm a node, so compute top, left, right, bottom
  2073. else {
  2074. var element = $(ce), p = [];
  2075. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2076. self.containerOffset = element.offset();
  2077. self.containerPosition = element.position();
  2078. self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2079. var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
  2080. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2081. self.parentData = {
  2082. element: ce, left: co.left, top: co.top, width: width, height: height
  2083. };
  2084. }
  2085. },
  2086. resize: function(event, ui) {
  2087. var self = $(this).data("resizable"), o = self.options,
  2088. ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
  2089. pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
  2090. if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
  2091. if (cp.left < (self._helper ? co.left : 0)) {
  2092. self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
  2093. if (pRatio) self.size.height = self.size.width / o.aspectRatio;
  2094. self.position.left = o.helper ? co.left : 0;
  2095. }
  2096. if (cp.top < (self._helper ? co.top : 0)) {
  2097. self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
  2098. if (pRatio) self.size.width = self.size.height * o.aspectRatio;
  2099. self.position.top = self._helper ? co.top : 0;
  2100. }
  2101. self.offset.left = self.parentData.left+self.position.left;
  2102. self.offset.top = self.parentData.top+self.position.top;
  2103. var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
  2104. hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
  2105. var isParent = self.containerElement.get(0) == self.element.parent().get(0),
  2106. isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
  2107. if(isParent && isOffsetRelative) woset -= self.parentData.left;
  2108. if (woset + self.size.width >= self.parentData.width) {
  2109. self.size.width = self.parentData.width - woset;
  2110. if (pRatio) self.size.height = self.size.width / self.aspectRatio;
  2111. }
  2112. if (hoset + self.size.height >= self.parentData.height) {
  2113. self.size.height = self.parentData.height - hoset;
  2114. if (pRatio) self.size.width = self.size.height * self.aspectRatio;
  2115. }
  2116. },
  2117. stop: function(event, ui){
  2118. var self = $(this).data("resizable"), o = self.options, cp = self.position,
  2119. co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
  2120. var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
  2121. if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
  2122. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2123. if (self._helper && !o.animate && (/static/).test(ce.css('position')))
  2124. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2125. }
  2126. });
  2127. $.ui.plugin.add("resizable", "ghost", {
  2128. start: function(event, ui) {
  2129. var self = $(this).data("resizable"), o = self.options, cs = self.size;
  2130. self.ghost = self.originalElement.clone();
  2131. self.ghost
  2132. .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2133. .addClass('ui-resizable-ghost')
  2134. .addClass(typeof o.ghost == 'string' ? o.ghost : '');
  2135. self.ghost.appendTo(self.helper);
  2136. },
  2137. resize: function(event, ui){
  2138. var self = $(this).data("resizable"), o = self.options;
  2139. if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
  2140. },
  2141. stop: function(event, ui){
  2142. var self = $(this).data("resizable"), o = self.options;
  2143. if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
  2144. }
  2145. });
  2146. $.ui.plugin.add("resizable", "grid", {
  2147. resize: function(event, ui) {
  2148. 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;
  2149. o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
  2150. 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);
  2151. if (/^(se|s|e)$/.test(a)) {
  2152. self.size.width = os.width + ox;
  2153. self.size.height = os.height + oy;
  2154. }
  2155. else if (/^(ne)$/.test(a)) {
  2156. self.size.width = os.width + ox;
  2157. self.size.height = os.height + oy;
  2158. self.position.top = op.top - oy;
  2159. }
  2160. else if (/^(sw)$/.test(a)) {
  2161. self.size.width = os.width + ox;
  2162. self.size.height = os.height + oy;
  2163. self.position.left = op.left - ox;
  2164. }
  2165. else {
  2166. self.size.width = os.width + ox;
  2167. self.size.height = os.height + oy;
  2168. self.position.top = op.top - oy;
  2169. self.position.left = op.left - ox;
  2170. }
  2171. }
  2172. });
  2173. var num = function(v) {
  2174. return parseInt(v, 10) || 0;
  2175. };
  2176. var isNumber = function(value) {
  2177. return !isNaN(parseInt(value, 10));
  2178. };
  2179. })(jQuery);
  2180. /*
  2181. * jQuery UI Selectable 1.8
  2182. *
  2183. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  2184. * Dual licensed under the MIT (MIT-LICENSE.txt)
  2185. * and GPL (GPL-LICENSE.txt) licenses.
  2186. *
  2187. * http://docs.jquery.com/UI/Selectables
  2188. *
  2189. * Depends:
  2190. * jquery.ui.core.js
  2191. * jquery.ui.mouse.js
  2192. * jquery.ui.widget.js
  2193. */
  2194. (function($) {
  2195. $.widget("ui.selectable", $.ui.mouse, {
  2196. options: {
  2197. appendTo: 'body',
  2198. autoRefresh: true,
  2199. distance: 0,
  2200. filter: '*',
  2201. tolerance: 'touch'
  2202. },
  2203. _create: function() {
  2204. var self = this;
  2205. this.element.addClass("ui-selectable");
  2206. this.dragged = false;
  2207. // cache selectee children based on filter
  2208. var selectees;
  2209. this.refresh = function() {
  2210. selectees = $(self.options.filter, self.element[0]);
  2211. selectees.each(function() {
  2212. var $this = $(this);
  2213. var pos = $this.offset();
  2214. $.data(this, "selectable-item", {
  2215. element: this,
  2216. $element: $this,
  2217. left: pos.left,
  2218. top: pos.top,
  2219. right: pos.left + $this.outerWidth(),
  2220. bottom: pos.top + $this.outerHeight(),
  2221. startselected: false,
  2222. selected: $this.hasClass('ui-selected'),
  2223. selecting: $this.hasClass('ui-selecting'),
  2224. unselecting: $this.hasClass('ui-unselecting')
  2225. });
  2226. });
  2227. };
  2228. this.refresh();
  2229. this.selectees = selectees.addClass("ui-selectee");
  2230. this._mouseInit();
  2231. this.helper = $(document.createElement('div'))
  2232. .css({border:'1px dotted black'})
  2233. .addClass("ui-selectable-helper");
  2234. },
  2235. destroy: function() {
  2236. this.selectees
  2237. .removeClass("ui-selectee")
  2238. .removeData("selectable-item");
  2239. this.element
  2240. .removeClass("ui-selectable ui-selectable-disabled")
  2241. .removeData("selectable")
  2242. .unbind(".selectable");
  2243. this._mouseDestroy();
  2244. return this;
  2245. },
  2246. _mouseStart: function(event) {
  2247. var self = this;
  2248. this.opos = [event.pageX, event.pageY];
  2249. if (this.options.disabled)
  2250. return;
  2251. var options = this.options;
  2252. this.selectees = $(options.filter, this.element[0]);
  2253. this._trigger("start", event);
  2254. $(options.appendTo).append(this.helper);
  2255. // position helper (lasso)
  2256. this.helper.css({
  2257. "z-index": 100,
  2258. "position": "absolute",
  2259. "left": event.clientX,
  2260. "top": event.clientY,
  2261. "width": 0,
  2262. "height": 0
  2263. });
  2264. if (options.autoRefresh) {
  2265. this.refresh();
  2266. }
  2267. this.selectees.filter('.ui-selected').each(function() {
  2268. var selectee = $.data(this, "selectable-item");
  2269. selectee.startselected = true;
  2270. if (!event.metaKey) {
  2271. selectee.$element.removeClass('ui-selected');
  2272. selectee.selected = false;
  2273. selectee.$element.addClass('ui-unselecting');
  2274. selectee.unselecting = true;
  2275. // selectable UNSELECTING callback
  2276. self._trigger("unselecting", event, {
  2277. unselecting: selectee.element
  2278. });
  2279. }
  2280. });
  2281. $(event.target).parents().andSelf().each(function() {
  2282. var selectee = $.data(this, "selectable-item");
  2283. if (selectee) {
  2284. selectee.$element.removeClass("ui-unselecting").addClass('ui-selecting');
  2285. selectee.unselecting = false;
  2286. selectee.selecting = true;
  2287. selectee.selected = true;
  2288. // selectable SELECTING callback
  2289. self._trigger("selecting", event, {
  2290. selecting: selectee.element
  2291. });
  2292. return false;
  2293. }
  2294. });
  2295. },
  2296. _mouseDrag: function(event) {
  2297. var self = this;
  2298. this.dragged = true;
  2299. if (this.options.disabled)
  2300. return;
  2301. var options = this.options;
  2302. var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
  2303. if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
  2304. if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
  2305. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2306. this.selectees.each(function() {
  2307. var selectee = $.data(this, "selectable-item");
  2308. //prevent helper from being selected if appendTo: selectable
  2309. if (!selectee || selectee.element == self.element[0])
  2310. return;
  2311. var hit = false;
  2312. if (options.tolerance == 'touch') {
  2313. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2314. } else if (options.tolerance == 'fit') {
  2315. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2316. }
  2317. if (hit) {
  2318. // SELECT
  2319. if (selectee.selected) {
  2320. selectee.$element.removeClass('ui-selected');
  2321. selectee.selected = false;
  2322. }
  2323. if (selectee.unselecting) {
  2324. selectee.$element.removeClass('ui-unselecting');
  2325. selectee.unselecting = false;
  2326. }
  2327. if (!selectee.selecting) {
  2328. selectee.$element.addClass('ui-selecting');
  2329. selectee.selecting = true;
  2330. // selectable SELECTING callback
  2331. self._trigger("selecting", event, {
  2332. selecting: selectee.element
  2333. });
  2334. }
  2335. } else {
  2336. // UNSELECT
  2337. if (selectee.selecting) {
  2338. if (event.metaKey && selectee.startselected) {
  2339. selectee.$element.removeClass('ui-selecting');
  2340. selectee.selecting = false;
  2341. selectee.$element.addClass('ui-selected');
  2342. selectee.selected = true;
  2343. } else {
  2344. selectee.$element.removeClass('ui-selecting');
  2345. selectee.selecting = false;
  2346. if (selectee.startselected) {
  2347. selectee.$element.addClass('ui-unselecting');
  2348. selectee.unselecting = true;
  2349. }
  2350. // selectable UNSELECTING callback
  2351. self._trigger("unselecting", event, {
  2352. unselecting: selectee.element
  2353. });
  2354. }
  2355. }
  2356. if (selectee.selected) {
  2357. if (!event.metaKey && !selectee.startselected) {
  2358. selectee.$element.removeClass('ui-selected');
  2359. selectee.selected = false;
  2360. selectee.$element.addClass('ui-unselecting');
  2361. selectee.unselecting = true;
  2362. // selectable UNSELECTING callback
  2363. self._trigger("unselecting", event, {
  2364. unselecting: selectee.element
  2365. });
  2366. }
  2367. }
  2368. }
  2369. });
  2370. return false;
  2371. },
  2372. _mouseStop: function(event) {
  2373. var self = this;
  2374. this.dragged = false;
  2375. var options = this.options;
  2376. $('.ui-unselecting', this.element[0]).each(function() {
  2377. var selectee = $.data(this, "selectable-item");
  2378. selectee.$element.removeClass('ui-unselecting');
  2379. selectee.unselecting = false;
  2380. selectee.startselected = false;
  2381. self._trigger("unselected", event, {
  2382. unselected: selectee.element
  2383. });
  2384. });
  2385. $('.ui-selecting', this.element[0]).each(function() {
  2386. var selectee = $.data(this, "selectable-item");
  2387. selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
  2388. selectee.selecting = false;
  2389. selectee.selected = true;
  2390. selectee.startselected = true;
  2391. self._trigger("selected", event, {
  2392. selected: selectee.element
  2393. });
  2394. });
  2395. this._trigger("stop", event);
  2396. this.helper.remove();
  2397. return false;
  2398. }
  2399. });
  2400. $.extend($.ui.selectable, {
  2401. version: "1.8"
  2402. });
  2403. })(jQuery);
  2404. /*
  2405. * jQuery UI Sortable 1.8
  2406. *
  2407. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  2408. * Dual licensed under the MIT (MIT-LICENSE.txt)
  2409. * and GPL (GPL-LICENSE.txt) licenses.
  2410. *
  2411. * http://docs.jquery.com/UI/Sortables
  2412. *
  2413. * Depends:
  2414. * jquery.ui.core.js
  2415. * jquery.ui.mouse.js
  2416. * jquery.ui.widget.js
  2417. */
  2418. (function($) {
  2419. $.widget("ui.sortable", $.ui.mouse, {
  2420. widgetEventPrefix: "sort",
  2421. options: {
  2422. appendTo: "parent",
  2423. axis: false,
  2424. connectWith: false,
  2425. containment: false,
  2426. cursor: 'auto',
  2427. cursorAt: false,
  2428. dropOnEmpty: true,
  2429. forcePlaceholderSize: false,
  2430. forceHelperSize: false,
  2431. grid: false,
  2432. handle: false,
  2433. helper: "original",
  2434. items: '> *',
  2435. opacity: false,
  2436. placeholder: false,
  2437. revert: false,
  2438. scroll: true,
  2439. scrollSensitivity: 20,
  2440. scrollSpeed: 20,
  2441. scope: "default",
  2442. tolerance: "intersect",
  2443. zIndex: 1000
  2444. },
  2445. _create: function() {
  2446. var o = this.options;
  2447. this.containerCache = {};
  2448. this.element.addClass("ui-sortable");
  2449. //Get the items
  2450. this.refresh();
  2451. //Let's determine if the items are floating
  2452. this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;
  2453. //Let's determine the parent's offset
  2454. this.offset = this.element.offset();
  2455. //Initialize mouse events for interaction
  2456. this._mouseInit();
  2457. },
  2458. destroy: function() {
  2459. this.element
  2460. .removeClass("ui-sortable ui-sortable-disabled")
  2461. .removeData("sortable")
  2462. .unbind(".sortable");
  2463. this._mouseDestroy();
  2464. for ( var i = this.items.length - 1; i >= 0; i-- )
  2465. this.items[i].item.removeData("sortable-item");
  2466. return this;
  2467. },
  2468. _mouseCapture: function(event, overrideHandle) {
  2469. if (this.reverting) {
  2470. return false;
  2471. }
  2472. if(this.options.disabled || this.options.type == 'static') return false;
  2473. //We have to refresh the items data once first
  2474. this._refreshItems(event);
  2475. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  2476. var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
  2477. if($.data(this, 'sortable-item') == self) {
  2478. currentItem = $(this);
  2479. return false;
  2480. }
  2481. });
  2482. if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
  2483. if(!currentItem) return false;
  2484. if(this.options.handle && !overrideHandle) {
  2485. var validHandle = false;
  2486. $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
  2487. if(!validHandle) return false;
  2488. }
  2489. this.currentItem = currentItem;
  2490. this._removeCurrentsFromItems();
  2491. return true;
  2492. },
  2493. _mouseStart: function(event, overrideHandle, noActivation) {
  2494. var o = this.options, self = this;
  2495. this.currentContainer = this;
  2496. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  2497. this.refreshPositions();
  2498. //Create and append the visible helper
  2499. this.helper = this._createHelper(event);
  2500. //Cache the helper size
  2501. this._cacheHelperProportions();
  2502. /*
  2503. * - Position generation -
  2504. * This block generates everything position related - it's the core of draggables.
  2505. */
  2506. //Cache the margins of the original element
  2507. this._cacheMargins();
  2508. //Get the next scrolling parent
  2509. this.scrollParent = this.helper.scrollParent();
  2510. //The element's absolute position on the page minus margins
  2511. this.offset = this.currentItem.offset();
  2512. this.offset = {
  2513. top: this.offset.top - this.margins.top,
  2514. left: this.offset.left - this.margins.left
  2515. };
  2516. // Only after we got the offset, we can change the helper's position to absolute
  2517. // TODO: Still need to figure out a way to make relative sorting possible
  2518. this.helper.css("position", "absolute");
  2519. this.cssPosition = this.helper.css("position");
  2520. $.extend(this.offset, {
  2521. click: { //Where the click happened, relative to the element
  2522. left: event.pageX - this.offset.left,
  2523. top: event.pageY - this.offset.top
  2524. },
  2525. parent: this._getParentOffset(),
  2526. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  2527. });
  2528. //Generate the original position
  2529. this.originalPosition = this._generatePosition(event);
  2530. this.originalPageX = event.pageX;
  2531. this.originalPageY = event.pageY;
  2532. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  2533. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  2534. //Cache the former DOM position
  2535. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  2536. //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
  2537. if(this.helper[0] != this.currentItem[0]) {
  2538. this.currentItem.hide();
  2539. }
  2540. //Create the placeholder
  2541. this._createPlaceholder();
  2542. //Set a containment if given in the options
  2543. if(o.containment)
  2544. this._setContainment();
  2545. if(o.cursor) { // cursor option
  2546. if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
  2547. $('body').css("cursor", o.cursor);
  2548. }
  2549. if(o.opacity) { // opacity option
  2550. if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
  2551. this.helper.css("opacity", o.opacity);
  2552. }
  2553. if(o.zIndex) { // zIndex option
  2554. if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
  2555. this.helper.css("zIndex", o.zIndex);
  2556. }
  2557. //Prepare scrolling
  2558. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
  2559. this.overflowOffset = this.scrollParent.offset();
  2560. //Call callbacks
  2561. this._trigger("start", event, this._uiHash());
  2562. //Recache the helper size
  2563. if(!this._preserveHelperProportions)
  2564. this._cacheHelperProportions();
  2565. //Post 'activate' events to possible containers
  2566. if(!noActivation) {
  2567. for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
  2568. }
  2569. //Prepare possible droppables
  2570. if($.ui.ddmanager)
  2571. $.ui.ddmanager.current = this;
  2572. if ($.ui.ddmanager && !o.dropBehaviour)
  2573. $.ui.ddmanager.prepareOffsets(this, event);
  2574. this.dragging = true;
  2575. this.helper.addClass("ui-sortable-helper");
  2576. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  2577. return true;
  2578. },
  2579. _mouseDrag: function(event) {
  2580. //Compute the helpers position
  2581. this.position = this._generatePosition(event);
  2582. this.positionAbs = this._convertPositionTo("absolute");
  2583. if (!this.lastPositionAbs) {
  2584. this.lastPositionAbs = this.positionAbs;
  2585. }
  2586. //Do scrolling
  2587. if(this.options.scroll) {
  2588. var o = this.options, scrolled = false;
  2589. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
  2590. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  2591. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  2592. else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
  2593. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  2594. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  2595. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  2596. else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
  2597. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  2598. } else {
  2599. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  2600. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2601. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  2602. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2603. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  2604. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2605. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  2606. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2607. }
  2608. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  2609. $.ui.ddmanager.prepareOffsets(this, event);
  2610. }
  2611. //Regenerate the absolute position used for position checks
  2612. this.positionAbs = this._convertPositionTo("absolute");
  2613. //Set the helper position
  2614. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  2615. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  2616. //Rearrange
  2617. for (var i = this.items.length - 1; i >= 0; i--) {
  2618. //Cache variables and intersection, continue if no intersection
  2619. var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
  2620. if (!intersection) continue;
  2621. if(itemElement != this.currentItem[0] //cannot intersect with itself
  2622. && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
  2623. && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
  2624. && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
  2625. //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
  2626. ) {
  2627. this.direction = intersection == 1 ? "down" : "up";
  2628. if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
  2629. this._rearrange(event, item);
  2630. } else {
  2631. break;
  2632. }
  2633. this._trigger("change", event, this._uiHash());
  2634. break;
  2635. }
  2636. }
  2637. //Post events to containers
  2638. this._contactContainers(event);
  2639. //Interconnect with droppables
  2640. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  2641. //Call callbacks
  2642. this._trigger('sort', event, this._uiHash());
  2643. this.lastPositionAbs = this.positionAbs;
  2644. return false;
  2645. },
  2646. _mouseStop: function(event, noPropagation) {
  2647. if(!event) return;
  2648. //If we are using droppables, inform the manager about the drop
  2649. if ($.ui.ddmanager && !this.options.dropBehaviour)
  2650. $.ui.ddmanager.drop(this, event);
  2651. if(this.options.revert) {
  2652. var self = this;
  2653. var cur = self.placeholder.offset();
  2654. self.reverting = true;
  2655. $(this.helper).animate({
  2656. left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
  2657. top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
  2658. }, parseInt(this.options.revert, 10) || 500, function() {
  2659. self._clear(event);
  2660. });
  2661. } else {
  2662. this._clear(event, noPropagation);
  2663. }
  2664. return false;
  2665. },
  2666. cancel: function() {
  2667. var self = this;
  2668. if(this.dragging) {
  2669. this._mouseUp();
  2670. if(this.options.helper == "original")
  2671. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  2672. else
  2673. this.currentItem.show();
  2674. //Post deactivating events to containers
  2675. for (var i = this.containers.length - 1; i >= 0; i--){
  2676. this.containers[i]._trigger("deactivate", null, self._uiHash(this));
  2677. if(this.containers[i].containerCache.over) {
  2678. this.containers[i]._trigger("out", null, self._uiHash(this));
  2679. this.containers[i].containerCache.over = 0;
  2680. }
  2681. }
  2682. }
  2683. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  2684. if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  2685. if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
  2686. $.extend(this, {
  2687. helper: null,
  2688. dragging: false,
  2689. reverting: false,
  2690. _noFinalSort: null
  2691. });
  2692. if(this.domPosition.prev) {
  2693. $(this.domPosition.prev).after(this.currentItem);
  2694. } else {
  2695. $(this.domPosition.parent).prepend(this.currentItem);
  2696. }
  2697. return this;
  2698. },
  2699. serialize: function(o) {
  2700. var items = this._getItemsAsjQuery(o && o.connected);
  2701. var str = []; o = o || {};
  2702. $(items).each(function() {
  2703. var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
  2704. if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
  2705. });
  2706. return str.join('&');
  2707. },
  2708. toArray: function(o) {
  2709. var items = this._getItemsAsjQuery(o && o.connected);
  2710. var ret = []; o = o || {};
  2711. items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
  2712. return ret;
  2713. },
  2714. /* Be careful with the following core functions */
  2715. _intersectsWith: function(item) {
  2716. var x1 = this.positionAbs.left,
  2717. x2 = x1 + this.helperProportions.width,
  2718. y1 = this.positionAbs.top,
  2719. y2 = y1 + this.helperProportions.height;
  2720. var l = item.left,
  2721. r = l + item.width,
  2722. t = item.top,
  2723. b = t + item.height;
  2724. var dyClick = this.offset.click.top,
  2725. dxClick = this.offset.click.left;
  2726. var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  2727. if( this.options.tolerance == "pointer"
  2728. || this.options.forcePointerForContainers
  2729. || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
  2730. ) {
  2731. return isOverElement;
  2732. } else {
  2733. return (l < x1 + (this.helperProportions.width / 2) // Right Half
  2734. && x2 - (this.helperProportions.width / 2) < r // Left Half
  2735. && t < y1 + (this.helperProportions.height / 2) // Bottom Half
  2736. && y2 - (this.helperProportions.height / 2) < b ); // Top Half
  2737. }
  2738. },
  2739. _intersectsWithPointer: function(item) {
  2740. var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  2741. isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  2742. isOverElement = isOverElementHeight && isOverElementWidth,
  2743. verticalDirection = this._getDragVerticalDirection(),
  2744. horizontalDirection = this._getDragHorizontalDirection();
  2745. if (!isOverElement)
  2746. return false;
  2747. return this.floating ?
  2748. ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
  2749. : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
  2750. },
  2751. _intersectsWithSides: function(item) {
  2752. var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  2753. isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  2754. verticalDirection = this._getDragVerticalDirection(),
  2755. horizontalDirection = this._getDragHorizontalDirection();
  2756. if (this.floating && horizontalDirection) {
  2757. return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
  2758. } else {
  2759. return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
  2760. }
  2761. },
  2762. _getDragVerticalDirection: function() {
  2763. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  2764. return delta != 0 && (delta > 0 ? "down" : "up");
  2765. },
  2766. _getDragHorizontalDirection: function() {
  2767. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  2768. return delta != 0 && (delta > 0 ? "right" : "left");
  2769. },
  2770. refresh: function(event) {
  2771. this._refreshItems(event);
  2772. this.refreshPositions();
  2773. return this;
  2774. },
  2775. _connectWith: function() {
  2776. var options = this.options;
  2777. return options.connectWith.constructor == String
  2778. ? [options.connectWith]
  2779. : options.connectWith;
  2780. },
  2781. _getItemsAsjQuery: function(connected) {
  2782. var self = this;
  2783. var items = [];
  2784. var queries = [];
  2785. var connectWith = this._connectWith();
  2786. if(connectWith && connected) {
  2787. for (var i = connectWith.length - 1; i >= 0; i--){
  2788. var cur = $(connectWith[i]);
  2789. for (var j = cur.length - 1; j >= 0; j--){
  2790. var inst = $.data(cur[j], 'sortable');
  2791. if(inst && inst != this && !inst.options.disabled) {
  2792. 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]);
  2793. }
  2794. };
  2795. };
  2796. }
  2797. 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]);
  2798. for (var i = queries.length - 1; i >= 0; i--){
  2799. queries[i][0].each(function() {
  2800. items.push(this);
  2801. });
  2802. };
  2803. return $(items);
  2804. },
  2805. _removeCurrentsFromItems: function() {
  2806. var list = this.currentItem.find(":data(sortable-item)");
  2807. for (var i=0; i < this.items.length; i++) {
  2808. for (var j=0; j < list.length; j++) {
  2809. if(list[j] == this.items[i].item[0])
  2810. this.items.splice(i,1);
  2811. };
  2812. };
  2813. },
  2814. _refreshItems: function(event) {
  2815. this.items = [];
  2816. this.containers = [this];
  2817. var items = this.items;
  2818. var self = this;
  2819. var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
  2820. var connectWith = this._connectWith();
  2821. if(connectWith) {
  2822. for (var i = connectWith.length - 1; i >= 0; i--){
  2823. var cur = $(connectWith[i]);
  2824. for (var j = cur.length - 1; j >= 0; j--){
  2825. var inst = $.data(cur[j], 'sortable');
  2826. if(inst && inst != this && !inst.options.disabled) {
  2827. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  2828. this.containers.push(inst);
  2829. }
  2830. };
  2831. };
  2832. }
  2833. for (var i = queries.length - 1; i >= 0; i--) {
  2834. var targetData = queries[i][1];
  2835. var _queries = queries[i][0];
  2836. for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  2837. var item = $(_queries[j]);
  2838. item.data('sortable-item', targetData); // Data for target checking (mouse manager)
  2839. items.push({
  2840. item: item,
  2841. instance: targetData,
  2842. width: 0, height: 0,
  2843. left: 0, top: 0
  2844. });
  2845. };
  2846. };
  2847. },
  2848. refreshPositions: function(fast) {
  2849. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  2850. if(this.offsetParent && this.helper) {
  2851. this.offset.parent = this._getParentOffset();
  2852. }
  2853. for (var i = this.items.length - 1; i >= 0; i--){
  2854. var item = this.items[i];
  2855. var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  2856. if (!fast) {
  2857. item.width = t.outerWidth();
  2858. item.height = t.outerHeight();
  2859. }
  2860. var p = t.offset();
  2861. item.left = p.left;
  2862. item.top = p.top;
  2863. };
  2864. if(this.options.custom && this.options.custom.refreshContainers) {
  2865. this.options.custom.refreshContainers.call(this);
  2866. } else {
  2867. for (var i = this.containers.length - 1; i >= 0; i--){
  2868. var p = this.containers[i].element.offset();
  2869. this.containers[i].containerCache.left = p.left;
  2870. this.containers[i].containerCache.top = p.top;
  2871. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  2872. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  2873. };
  2874. }
  2875. return this;
  2876. },
  2877. _createPlaceholder: function(that) {
  2878. var self = that || this, o = self.options;
  2879. if(!o.placeholder || o.placeholder.constructor == String) {
  2880. var className = o.placeholder;
  2881. o.placeholder = {
  2882. element: function() {
  2883. var el = $(document.createElement(self.currentItem[0].nodeName))
  2884. .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
  2885. .removeClass("ui-sortable-helper")[0];
  2886. if(!className)
  2887. el.style.visibility = "hidden";
  2888. return el;
  2889. },
  2890. update: function(container, p) {
  2891. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  2892. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  2893. if(className && !o.forcePlaceholderSize) return;
  2894. //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
  2895. if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
  2896. if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
  2897. }
  2898. };
  2899. }
  2900. //Create the placeholder
  2901. self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
  2902. //Append it after the actual current item
  2903. self.currentItem.after(self.placeholder);
  2904. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  2905. o.placeholder.update(self, self.placeholder);
  2906. },
  2907. _contactContainers: function(event) {
  2908. // get innermost container that intersects with item
  2909. var innermostContainer = null, innermostIndex = null;
  2910. for (var i = this.containers.length - 1; i >= 0; i--){
  2911. // never consider a container that's located within the item itself
  2912. if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
  2913. continue;
  2914. if(this._intersectsWith(this.containers[i].containerCache)) {
  2915. // if we've already found a container and it's more "inner" than this, then continue
  2916. if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
  2917. continue;
  2918. innermostContainer = this.containers[i];
  2919. innermostIndex = i;
  2920. } else {
  2921. // container doesn't intersect. trigger "out" event if necessary
  2922. if(this.containers[i].containerCache.over) {
  2923. this.containers[i]._trigger("out", event, this._uiHash(this));
  2924. this.containers[i].containerCache.over = 0;
  2925. }
  2926. }
  2927. }
  2928. // if no intersecting containers found, return
  2929. if(!innermostContainer) return;
  2930. // move the item into the container if it's not there already
  2931. if(this.containers.length === 1) {
  2932. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  2933. this.containers[innermostIndex].containerCache.over = 1;
  2934. } else if(this.currentContainer != this.containers[innermostIndex]) {
  2935. //When entering a new container, we will find the item with the least distance and append our item near it
  2936. var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
  2937. for (var j = this.items.length - 1; j >= 0; j--) {
  2938. if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
  2939. var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
  2940. if(Math.abs(cur - base) < dist) {
  2941. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  2942. }
  2943. }
  2944. if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
  2945. return;
  2946. this.currentContainer = this.containers[innermostIndex];
  2947. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  2948. this._trigger("change", event, this._uiHash());
  2949. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  2950. //Update the placeholder
  2951. this.options.placeholder.update(this.currentContainer, this.placeholder);
  2952. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  2953. this.containers[innermostIndex].containerCache.over = 1;
  2954. }
  2955. },
  2956. _createHelper: function(event) {
  2957. var o = this.options;
  2958. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
  2959. if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
  2960. $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  2961. if(helper[0] == this.currentItem[0])
  2962. 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") };
  2963. if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
  2964. if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
  2965. return helper;
  2966. },
  2967. _adjustOffsetFromHelper: function(obj) {
  2968. if (typeof obj == 'string') {
  2969. obj = obj.split(' ');
  2970. }
  2971. if ($.isArray(obj)) {
  2972. obj = {left: +obj[0], top: +obj[1] || 0};
  2973. }
  2974. if ('left' in obj) {
  2975. this.offset.click.left = obj.left + this.margins.left;
  2976. }
  2977. if ('right' in obj) {
  2978. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  2979. }
  2980. if ('top' in obj) {
  2981. this.offset.click.top = obj.top + this.margins.top;
  2982. }
  2983. if ('bottom' in obj) {
  2984. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  2985. }
  2986. },
  2987. _getParentOffset: function() {
  2988. //Get the offsetParent and cache its position
  2989. this.offsetParent = this.helper.offsetParent();
  2990. var po = this.offsetParent.offset();
  2991. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  2992. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  2993. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  2994. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  2995. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  2996. po.left += this.scrollParent.scrollLeft();
  2997. po.top += this.scrollParent.scrollTop();
  2998. }
  2999. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  3000. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  3001. po = { top: 0, left: 0 };
  3002. return {
  3003. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3004. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3005. };
  3006. },
  3007. _getRelativeOffset: function() {
  3008. if(this.cssPosition == "relative") {
  3009. var p = this.currentItem.position();
  3010. return {
  3011. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3012. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3013. };
  3014. } else {
  3015. return { top: 0, left: 0 };
  3016. }
  3017. },
  3018. _cacheMargins: function() {
  3019. this.margins = {
  3020. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3021. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3022. };
  3023. },
  3024. _cacheHelperProportions: function() {
  3025. this.helperProportions = {
  3026. width: this.helper.outerWidth(),
  3027. height: this.helper.outerHeight()
  3028. };
  3029. },
  3030. _setContainment: function() {
  3031. var o = this.options;
  3032. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  3033. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  3034. 0 - this.offset.relative.left - this.offset.parent.left,
  3035. 0 - this.offset.relative.top - this.offset.parent.top,
  3036. $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  3037. ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3038. ];
  3039. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3040. var ce = $(o.containment)[0];
  3041. var co = $(o.containment).offset();
  3042. var over = ($(ce).css("overflow") != 'hidden');
  3043. this.containment = [
  3044. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3045. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3046. 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,
  3047. 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
  3048. ];
  3049. }
  3050. },
  3051. _convertPositionTo: function(d, pos) {
  3052. if(!pos) pos = this.position;
  3053. var mod = d == "absolute" ? 1 : -1;
  3054. 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);
  3055. return {
  3056. top: (
  3057. pos.top // The absolute mouse position
  3058. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  3059. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  3060. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3061. ),
  3062. left: (
  3063. pos.left // The absolute mouse position
  3064. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  3065. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  3066. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3067. )
  3068. };
  3069. },
  3070. _generatePosition: function(event) {
  3071. 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);
  3072. // This is another very weird special case that only happens for relative elements:
  3073. // 1. If the css position is relative
  3074. // 2. and the scroll parent is the document or similar to the offset parent
  3075. // we have to refresh the relative offset during the scroll so there are no jumps
  3076. if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
  3077. this.offset.relative = this._getRelativeOffset();
  3078. }
  3079. var pageX = event.pageX;
  3080. var pageY = event.pageY;
  3081. /*
  3082. * - Position constraining -
  3083. * Constrain the position to a mix of grid, containment.
  3084. */
  3085. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3086. if(this.containment) {
  3087. if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
  3088. if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
  3089. if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
  3090. if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
  3091. }
  3092. if(o.grid) {
  3093. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3094. 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;
  3095. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3096. 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;
  3097. }
  3098. }
  3099. return {
  3100. top: (
  3101. pageY // The absolute mouse position
  3102. - this.offset.click.top // Click offset (relative to the element)
  3103. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  3104. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  3105. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3106. ),
  3107. left: (
  3108. pageX // The absolute mouse position
  3109. - this.offset.click.left // Click offset (relative to the element)
  3110. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  3111. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  3112. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3113. )
  3114. };
  3115. },
  3116. _rearrange: function(event, i, a, hardRefresh) {
  3117. 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));
  3118. //Various things done here to improve the performance:
  3119. // 1. we create a setTimeout, that calls refreshPositions
  3120. // 2. on the instance, we have a counter variable, that get's higher after every append
  3121. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3122. // 4. this lets only the last addition to the timeout stack through
  3123. this.counter = this.counter ? ++this.counter : 1;
  3124. var self = this, counter = this.counter;
  3125. window.setTimeout(function() {
  3126. if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3127. },0);
  3128. },
  3129. _clear: function(event, noPropagation) {
  3130. this.reverting = false;
  3131. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3132. // everything else normalized again
  3133. var delayedTriggers = [], self = this;
  3134. // We first have to update the dom position of the actual currentItem
  3135. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3136. if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem);
  3137. this._noFinalSort = null;
  3138. if(this.helper[0] == this.currentItem[0]) {
  3139. for(var i in this._storedCSS) {
  3140. if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
  3141. }
  3142. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3143. } else {
  3144. this.currentItem.show();
  3145. }
  3146. if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3147. 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
  3148. if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
  3149. if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3150. for (var i = this.containers.length - 1; i >= 0; i--){
  3151. if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
  3152. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3153. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3154. }
  3155. };
  3156. };
  3157. //Post events to containers
  3158. for (var i = this.containers.length - 1; i >= 0; i--){
  3159. if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3160. if(this.containers[i].containerCache.over) {
  3161. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3162. this.containers[i].containerCache.over = 0;
  3163. }
  3164. }
  3165. //Do what was originally in plugins
  3166. if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
  3167. if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
  3168. if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
  3169. this.dragging = false;
  3170. if(this.cancelHelperRemoval) {
  3171. if(!noPropagation) {
  3172. this._trigger("beforeStop", event, this._uiHash());
  3173. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3174. this._trigger("stop", event, this._uiHash());
  3175. }
  3176. return false;
  3177. }
  3178. if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
  3179. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3180. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3181. if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
  3182. if(!noPropagation) {
  3183. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3184. this._trigger("stop", event, this._uiHash());
  3185. }
  3186. this.fromOutside = false;
  3187. return true;
  3188. },
  3189. _trigger: function() {
  3190. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3191. this.cancel();
  3192. }
  3193. },
  3194. _uiHash: function(inst) {
  3195. var self = inst || this;
  3196. return {
  3197. helper: self.helper,
  3198. placeholder: self.placeholder || $([]),
  3199. position: self.position,
  3200. originalPosition: self.originalPosition,
  3201. offset: self.positionAbs,
  3202. item: self.currentItem,
  3203. sender: inst ? inst.element : null
  3204. };
  3205. }
  3206. });
  3207. $.extend($.ui.sortable, {
  3208. version: "1.8"
  3209. });
  3210. })(jQuery);
  3211. /*
  3212. * jQuery UI Accordion 1.8
  3213. *
  3214. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  3215. * Dual licensed under the MIT (MIT-LICENSE.txt)
  3216. * and GPL (GPL-LICENSE.txt) licenses.
  3217. *
  3218. * http://docs.jquery.com/UI/Accordion
  3219. *
  3220. * Depends:
  3221. * jquery.ui.core.js
  3222. * jquery.ui.widget.js
  3223. */
  3224. (function($) {
  3225. $.widget("ui.accordion", {
  3226. options: {
  3227. active: 0,
  3228. animated: 'slide',
  3229. autoHeight: true,
  3230. clearStyle: false,
  3231. collapsible: false,
  3232. event: "click",
  3233. fillSpace: false,
  3234. header: "> li > :first-child,> :not(li):even",
  3235. icons: {
  3236. header: "ui-icon-triangle-1-e",
  3237. headerSelected: "ui-icon-triangle-1-s"
  3238. },
  3239. navigation: false,
  3240. navigationFilter: function() {
  3241. return this.href.toLowerCase() == location.href.toLowerCase();
  3242. }
  3243. },
  3244. _create: function() {
  3245. var o = this.options, self = this;
  3246. this.running = 0;
  3247. this.element.addClass("ui-accordion ui-widget ui-helper-reset");
  3248. // in lack of child-selectors in CSS we need to mark top-LIs in a UL-accordion for some IE-fix
  3249. if (this.element[0].nodeName == "UL") {
  3250. this.element.children("li").addClass("ui-accordion-li-fix");
  3251. }
  3252. this.headers = this.element.find(o.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all")
  3253. .bind("mouseenter.accordion", function(){ $(this).addClass('ui-state-hover'); })
  3254. .bind("mouseleave.accordion", function(){ $(this).removeClass('ui-state-hover'); })
  3255. .bind("focus.accordion", function(){ $(this).addClass('ui-state-focus'); })
  3256. .bind("blur.accordion", function(){ $(this).removeClass('ui-state-focus'); });
  3257. this.headers
  3258. .next()
  3259. .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");
  3260. if ( o.navigation ) {
  3261. var current = this.element.find("a").filter(o.navigationFilter);
  3262. if ( current.length ) {
  3263. var header = current.closest(".ui-accordion-header");
  3264. if ( header.length ) {
  3265. // anchor within header
  3266. this.active = header;
  3267. } else {
  3268. // anchor within content
  3269. this.active = current.closest(".ui-accordion-content").prev();
  3270. }
  3271. }
  3272. }
  3273. this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");
  3274. this.active.next().addClass('ui-accordion-content-active');
  3275. //Append icon elements
  3276. this._createIcons();
  3277. // IE7-/Win - Extra vertical space in lists fixed
  3278. if ($.browser.msie) {
  3279. this.element.find('a').css('zoom', '1');
  3280. }
  3281. this.resize();
  3282. //ARIA
  3283. this.element.attr('role','tablist');
  3284. this.headers
  3285. .attr('role','tab')
  3286. .bind('keydown', function(event) { return self._keydown(event); })
  3287. .next()
  3288. .attr('role','tabpanel');
  3289. this.headers
  3290. .not(this.active || "")
  3291. .attr('aria-expanded','false')
  3292. .attr("tabIndex", "-1")
  3293. .next()
  3294. .hide();
  3295. // make sure at least one header is in the tab order
  3296. if (!this.active.length) {
  3297. this.headers.eq(0).attr('tabIndex','0');
  3298. } else {
  3299. this.active
  3300. .attr('aria-expanded','true')
  3301. .attr('tabIndex', '0');
  3302. }
  3303. // only need links in taborder for Safari
  3304. if (!$.browser.safari)
  3305. this.headers.find('a').attr('tabIndex','-1');
  3306. if (o.event) {
  3307. this.headers.bind((o.event) + ".accordion", function(event) {
  3308. self._clickHandler.call(self, event, this);
  3309. event.preventDefault();
  3310. });
  3311. }
  3312. },
  3313. _createIcons: function() {
  3314. var o = this.options;
  3315. if (o.icons) {
  3316. $("<span/>").addClass("ui-icon " + o.icons.header).prependTo(this.headers);
  3317. this.active.find(".ui-icon").toggleClass(o.icons.header).toggleClass(o.icons.headerSelected);
  3318. this.element.addClass("ui-accordion-icons");
  3319. }
  3320. },
  3321. _destroyIcons: function() {
  3322. this.headers.children(".ui-icon").remove();
  3323. this.element.removeClass("ui-accordion-icons");
  3324. },
  3325. destroy: function() {
  3326. var o = this.options;
  3327. this.element
  3328. .removeClass("ui-accordion ui-widget ui-helper-reset")
  3329. .removeAttr("role")
  3330. .unbind('.accordion')
  3331. .removeData('accordion');
  3332. this.headers
  3333. .unbind(".accordion")
  3334. .removeClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-corner-top")
  3335. .removeAttr("role").removeAttr("aria-expanded").removeAttr("tabindex");
  3336. this.headers.find("a").removeAttr("tabindex");
  3337. this._destroyIcons();
  3338. var contents = this.headers.next().css("display", "").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active");
  3339. if (o.autoHeight || o.fillHeight) {
  3340. contents.css("height", "");
  3341. }
  3342. return this;
  3343. },
  3344. _setOption: function(key, value) {
  3345. $.Widget.prototype._setOption.apply(this, arguments);
  3346. if (key == "active") {
  3347. this.activate(value);
  3348. }
  3349. if (key == "icons") {
  3350. this._destroyIcons();
  3351. if (value) {
  3352. this._createIcons();
  3353. }
  3354. }
  3355. },
  3356. _keydown: function(event) {
  3357. var o = this.options, keyCode = $.ui.keyCode;
  3358. if (o.disabled || event.altKey || event.ctrlKey)
  3359. return;
  3360. var length = this.headers.length;
  3361. var currentIndex = this.headers.index(event.target);
  3362. var toFocus = false;
  3363. switch(event.keyCode) {
  3364. case keyCode.RIGHT:
  3365. case keyCode.DOWN:
  3366. toFocus = this.headers[(currentIndex + 1) % length];
  3367. break;
  3368. case keyCode.LEFT:
  3369. case keyCode.UP:
  3370. toFocus = this.headers[(currentIndex - 1 + length) % length];
  3371. break;
  3372. case keyCode.SPACE:
  3373. case keyCode.ENTER:
  3374. this._clickHandler({ target: event.target }, event.target);
  3375. event.preventDefault();
  3376. }
  3377. if (toFocus) {
  3378. $(event.target).attr('tabIndex','-1');
  3379. $(toFocus).attr('tabIndex','0');
  3380. toFocus.focus();
  3381. return false;
  3382. }
  3383. return true;
  3384. },
  3385. resize: function() {
  3386. var o = this.options, maxHeight;
  3387. if (o.fillSpace) {
  3388. if($.browser.msie) { var defOverflow = this.element.parent().css('overflow'); this.element.parent().css('overflow', 'hidden'); }
  3389. maxHeight = this.element.parent().height();
  3390. if($.browser.msie) { this.element.parent().css('overflow', defOverflow); }
  3391. this.headers.each(function() {
  3392. maxHeight -= $(this).outerHeight(true);
  3393. });
  3394. this.headers.next().each(function() {
  3395. $(this).height(Math.max(0, maxHeight - $(this).innerHeight() + $(this).height()));
  3396. }).css('overflow', 'auto');
  3397. } else if ( o.autoHeight ) {
  3398. maxHeight = 0;
  3399. this.headers.next().each(function() {
  3400. maxHeight = Math.max(maxHeight, $(this).height());
  3401. }).height(maxHeight);
  3402. }
  3403. return this;
  3404. },
  3405. activate: function(index) {
  3406. // TODO this gets called on init, changing the option without an explicit call for that
  3407. this.options.active = index;
  3408. // call clickHandler with custom event
  3409. var active = this._findActive(index)[0];
  3410. this._clickHandler({ target: active }, active);
  3411. return this;
  3412. },
  3413. _findActive: function(selector) {
  3414. return selector
  3415. ? typeof selector == "number"
  3416. ? this.headers.filter(":eq(" + selector + ")")
  3417. : this.headers.not(this.headers.not(selector))
  3418. : selector === false
  3419. ? $([])
  3420. : this.headers.filter(":eq(0)");
  3421. },
  3422. // TODO isn't event.target enough? why the seperate target argument?
  3423. _clickHandler: function(event, target) {
  3424. var o = this.options;
  3425. if (o.disabled)
  3426. return;
  3427. // called only when using activate(false) to close all parts programmatically
  3428. if (!event.target) {
  3429. if (!o.collapsible)
  3430. return;
  3431. this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all")
  3432. .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header);
  3433. this.active.next().addClass('ui-accordion-content-active');
  3434. var toHide = this.active.next(),
  3435. data = {
  3436. options: o,
  3437. newHeader: $([]),
  3438. oldHeader: o.active,
  3439. newContent: $([]),
  3440. oldContent: toHide
  3441. },
  3442. toShow = (this.active = $([]));
  3443. this._toggle(toShow, toHide, data);
  3444. return;
  3445. }
  3446. // get the click target
  3447. var clicked = $(event.currentTarget || target);
  3448. var clickedIsActive = clicked[0] == this.active[0];
  3449. // TODO the option is changed, is that correct?
  3450. // TODO if it is correct, shouldn't that happen after determining that the click is valid?
  3451. o.active = o.collapsible && clickedIsActive ? false : $('.ui-accordion-header', this.element).index(clicked);
  3452. // if animations are still active, or the active header is the target, ignore click
  3453. if (this.running || (!o.collapsible && clickedIsActive)) {
  3454. return;
  3455. }
  3456. // switch classes
  3457. this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all")
  3458. .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header);
  3459. if (!clickedIsActive) {
  3460. clicked.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top")
  3461. .find(".ui-icon").removeClass(o.icons.header).addClass(o.icons.headerSelected);
  3462. clicked.next().addClass('ui-accordion-content-active');
  3463. }
  3464. // find elements to show and hide
  3465. var toShow = clicked.next(),
  3466. toHide = this.active.next(),
  3467. data = {
  3468. options: o,
  3469. newHeader: clickedIsActive && o.collapsible ? $([]) : clicked,
  3470. oldHeader: this.active,
  3471. newContent: clickedIsActive && o.collapsible ? $([]) : toShow,
  3472. oldContent: toHide
  3473. },
  3474. down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
  3475. this.active = clickedIsActive ? $([]) : clicked;
  3476. this._toggle(toShow, toHide, data, clickedIsActive, down);
  3477. return;
  3478. },
  3479. _toggle: function(toShow, toHide, data, clickedIsActive, down) {
  3480. var o = this.options, self = this;
  3481. this.toShow = toShow;
  3482. this.toHide = toHide;
  3483. this.data = data;
  3484. var complete = function() { if(!self) return; return self._completed.apply(self, arguments); };
  3485. // trigger changestart event
  3486. this._trigger("changestart", null, this.data);
  3487. // count elements to animate
  3488. this.running = toHide.size() === 0 ? toShow.size() : toHide.size();
  3489. if (o.animated) {
  3490. var animOptions = {};
  3491. if ( o.collapsible && clickedIsActive ) {
  3492. animOptions = {
  3493. toShow: $([]),
  3494. toHide: toHide,
  3495. complete: complete,
  3496. down: down,
  3497. autoHeight: o.autoHeight || o.fillSpace
  3498. };
  3499. } else {
  3500. animOptions = {
  3501. toShow: toShow,
  3502. toHide: toHide,
  3503. complete: complete,
  3504. down: down,
  3505. autoHeight: o.autoHeight || o.fillSpace
  3506. };
  3507. }
  3508. if (!o.proxied) {
  3509. o.proxied = o.animated;
  3510. }
  3511. if (!o.proxiedDuration) {
  3512. o.proxiedDuration = o.duration;
  3513. }
  3514. o.animated = $.isFunction(o.proxied) ?
  3515. o.proxied(animOptions) : o.proxied;
  3516. o.duration = $.isFunction(o.proxiedDuration) ?
  3517. o.proxiedDuration(animOptions) : o.proxiedDuration;
  3518. var animations = $.ui.accordion.animations,
  3519. duration = o.duration,
  3520. easing = o.animated;
  3521. if (easing && !animations[easing] && !$.easing[easing]) {
  3522. easing = 'slide';
  3523. }
  3524. if (!animations[easing]) {
  3525. animations[easing] = function(options) {
  3526. this.slide(options, {
  3527. easing: easing,
  3528. duration: duration || 700
  3529. });
  3530. };
  3531. }
  3532. animations[easing](animOptions);
  3533. } else {
  3534. if (o.collapsible && clickedIsActive) {
  3535. toShow.toggle();
  3536. } else {
  3537. toHide.hide();
  3538. toShow.show();
  3539. }
  3540. complete(true);
  3541. }
  3542. // TODO assert that the blur and focus triggers are really necessary, remove otherwise
  3543. toHide.prev().attr('aria-expanded','false').attr("tabIndex", "-1").blur();
  3544. toShow.prev().attr('aria-expanded','true').attr("tabIndex", "0").focus();
  3545. },
  3546. _completed: function(cancel) {
  3547. var o = this.options;
  3548. this.running = cancel ? 0 : --this.running;
  3549. if (this.running) return;
  3550. if (o.clearStyle) {
  3551. this.toShow.add(this.toHide).css({
  3552. height: "",
  3553. overflow: ""
  3554. });
  3555. }
  3556. // other classes are removed before the animation; this one needs to stay until completed
  3557. this.toHide.removeClass("ui-accordion-content-active");
  3558. this._trigger('change', null, this.data);
  3559. }
  3560. });
  3561. $.extend($.ui.accordion, {
  3562. version: "1.8",
  3563. animations: {
  3564. slide: function(options, additions) {
  3565. options = $.extend({
  3566. easing: "swing",
  3567. duration: 300
  3568. }, options, additions);
  3569. if ( !options.toHide.size() ) {
  3570. options.toShow.animate({height: "show"}, options);
  3571. return;
  3572. }
  3573. if ( !options.toShow.size() ) {
  3574. options.toHide.animate({height: "hide"}, options);
  3575. return;
  3576. }
  3577. var overflow = options.toShow.css('overflow'),
  3578. percentDone = 0,
  3579. showProps = {},
  3580. hideProps = {},
  3581. fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
  3582. originalWidth;
  3583. // fix width before calculating height of hidden element
  3584. var s = options.toShow;
  3585. originalWidth = s[0].style.width;
  3586. s.width( parseInt(s.parent().width(),10) - parseInt(s.css("paddingLeft"),10) - parseInt(s.css("paddingRight"),10) - (parseInt(s.css("borderLeftWidth"),10) || 0) - (parseInt(s.css("borderRightWidth"),10) || 0) );
  3587. $.each(fxAttrs, function(i, prop) {
  3588. hideProps[prop] = 'hide';
  3589. var parts = ('' + $.css(options.toShow[0], prop)).match(/^([\d+-.]+)(.*)$/);
  3590. showProps[prop] = {
  3591. value: parts[1],
  3592. unit: parts[2] || 'px'
  3593. };
  3594. });
  3595. options.toShow.css({ height: 0, overflow: 'hidden' }).show();
  3596. options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{
  3597. step: function(now, settings) {
  3598. // only calculate the percent when animating height
  3599. // IE gets very inconsistent results when animating elements
  3600. // with small values, which is common for padding
  3601. if (settings.prop == 'height') {
  3602. percentDone = ( settings.end - settings.start === 0 ) ? 0 :
  3603. (settings.now - settings.start) / (settings.end - settings.start);
  3604. }
  3605. options.toShow[0].style[settings.prop] =
  3606. (percentDone * showProps[settings.prop].value) + showProps[settings.prop].unit;
  3607. },
  3608. duration: options.duration,
  3609. easing: options.easing,
  3610. complete: function() {
  3611. if ( !options.autoHeight ) {
  3612. options.toShow.css("height", "");
  3613. }
  3614. options.toShow.css("width", originalWidth);
  3615. options.toShow.css({overflow: overflow});
  3616. options.complete();
  3617. }
  3618. });
  3619. },
  3620. bounceslide: function(options) {
  3621. this.slide(options, {
  3622. easing: options.down ? "easeOutBounce" : "swing",
  3623. duration: options.down ? 1000 : 200
  3624. });
  3625. }
  3626. }
  3627. });
  3628. })(jQuery);
  3629. /*
  3630. * jQuery UI Autocomplete 1.8
  3631. *
  3632. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  3633. * Dual licensed under the MIT (MIT-LICENSE.txt)
  3634. * and GPL (GPL-LICENSE.txt) licenses.
  3635. *
  3636. * http://docs.jquery.com/UI/Autocomplete
  3637. *
  3638. * Depends:
  3639. * jquery.ui.core.js
  3640. * jquery.ui.widget.js
  3641. * jquery.ui.position.js
  3642. */
  3643. (function( $ ) {
  3644. $.widget( "ui.autocomplete", {
  3645. options: {
  3646. minLength: 1,
  3647. delay: 300
  3648. },
  3649. _create: function() {
  3650. var self = this,
  3651. doc = this.element[ 0 ].ownerDocument;
  3652. this.element
  3653. .addClass( "ui-autocomplete-input" )
  3654. .attr( "autocomplete", "off" )
  3655. // TODO verify these actually work as intended
  3656. .attr({
  3657. role: "textbox",
  3658. "aria-autocomplete": "list",
  3659. "aria-haspopup": "true"
  3660. })
  3661. .bind( "keydown.autocomplete", function( event ) {
  3662. var keyCode = $.ui.keyCode;
  3663. switch( event.keyCode ) {
  3664. case keyCode.PAGE_UP:
  3665. self._move( "previousPage", event );
  3666. break;
  3667. case keyCode.PAGE_DOWN:
  3668. self._move( "nextPage", event );
  3669. break;
  3670. case keyCode.UP:
  3671. self._move( "previous", event );
  3672. // prevent moving cursor to beginning of text field in some browsers
  3673. event.preventDefault();
  3674. break;
  3675. case keyCode.DOWN:
  3676. self._move( "next", event );
  3677. // prevent moving cursor to end of text field in some browsers
  3678. event.preventDefault();
  3679. break;
  3680. case keyCode.ENTER:
  3681. // when menu is open or has focus
  3682. if ( self.menu.active ) {
  3683. event.preventDefault();
  3684. }
  3685. //passthrough - ENTER and TAB both select the current element
  3686. case keyCode.TAB:
  3687. if ( !self.menu.active ) {
  3688. return;
  3689. }
  3690. self.menu.select();
  3691. break;
  3692. case keyCode.ESCAPE:
  3693. self.element.val( self.term );
  3694. self.close( event );
  3695. break;
  3696. case keyCode.SHIFT:
  3697. case keyCode.CONTROL:
  3698. case 18:
  3699. // ignore metakeys (shift, ctrl, alt)
  3700. break;
  3701. default:
  3702. // keypress is triggered before the input value is changed
  3703. clearTimeout( self.searching );
  3704. self.searching = setTimeout(function() {
  3705. self.search( null, event );
  3706. }, self.options.delay );
  3707. break;
  3708. }
  3709. })
  3710. .bind( "focus.autocomplete", function() {
  3711. self.previous = self.element.val();
  3712. })
  3713. .bind( "blur.autocomplete", function( event ) {
  3714. clearTimeout( self.searching );
  3715. // clicks on the menu (or a button to trigger a search) will cause a blur event
  3716. // TODO try to implement this without a timeout, see clearTimeout in search()
  3717. self.closing = setTimeout(function() {
  3718. self.close( event );
  3719. }, 150 );
  3720. });
  3721. this._initSource();
  3722. this.response = function() {
  3723. return self._response.apply( self, arguments );
  3724. };
  3725. this.menu = $( "<ul></ul>" )
  3726. .addClass( "ui-autocomplete" )
  3727. .appendTo( "body", doc )
  3728. .menu({
  3729. focus: function( event, ui ) {
  3730. var item = ui.item.data( "item.autocomplete" );
  3731. if ( false !== self._trigger( "focus", null, { item: item } ) ) {
  3732. // use value to match what will end up in the input
  3733. self.element.val( item.value );
  3734. }
  3735. },
  3736. selected: function( event, ui ) {
  3737. var item = ui.item.data( "item.autocomplete" );
  3738. if ( false !== self._trigger( "select", event, { item: item } ) ) {
  3739. self.element.val( item.value );
  3740. }
  3741. self.close( event );
  3742. self.previous = self.element.val();
  3743. // only trigger when focus was lost (click on menu)
  3744. if ( self.element[0] !== doc.activeElement ) {
  3745. self.element.focus();
  3746. }
  3747. },
  3748. blur: function( event, ui ) {
  3749. if ( self.menu.element.is(":visible") ) {
  3750. self.element.val( self.term );
  3751. }
  3752. }
  3753. })
  3754. .zIndex( this.element.zIndex() + 1 )
  3755. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  3756. .css({ top: 0, left: 0 })
  3757. .hide()
  3758. .data( "menu" );
  3759. if ( $.fn.bgiframe ) {
  3760. this.menu.element.bgiframe();
  3761. }
  3762. },
  3763. destroy: function() {
  3764. this.element
  3765. .removeClass( "ui-autocomplete-input ui-widget ui-widget-content" )
  3766. .removeAttr( "autocomplete" )
  3767. .removeAttr( "role" )
  3768. .removeAttr( "aria-autocomplete" )
  3769. .removeAttr( "aria-haspopup" );
  3770. this.menu.element.remove();
  3771. $.Widget.prototype.destroy.call( this );
  3772. },
  3773. _setOption: function( key ) {
  3774. $.Widget.prototype._setOption.apply( this, arguments );
  3775. if ( key === "source" ) {
  3776. this._initSource();
  3777. }
  3778. },
  3779. _initSource: function() {
  3780. var array,
  3781. url;
  3782. if ( $.isArray(this.options.source) ) {
  3783. array = this.options.source;
  3784. this.source = function( request, response ) {
  3785. // escape regex characters
  3786. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
  3787. response( $.grep( array, function(value) {
  3788. return matcher.test( value.label || value.value || value );
  3789. }) );
  3790. };
  3791. } else if ( typeof this.options.source === "string" ) {
  3792. url = this.options.source;
  3793. this.source = function( request, response ) {
  3794. $.getJSON( url, request, response );
  3795. };
  3796. } else {
  3797. this.source = this.options.source;
  3798. }
  3799. },
  3800. search: function( value, event ) {
  3801. value = value != null ? value : this.element.val();
  3802. if ( value.length < this.options.minLength ) {
  3803. return this.close( event );
  3804. }
  3805. clearTimeout( this.closing );
  3806. if ( this._trigger("search") === false ) {
  3807. return;
  3808. }
  3809. return this._search( value );
  3810. },
  3811. _search: function( value ) {
  3812. this.term = this.element
  3813. .addClass( "ui-autocomplete-loading" )
  3814. // always save the actual value, not the one passed as an argument
  3815. .val();
  3816. this.source( { term: value }, this.response );
  3817. },
  3818. _response: function( content ) {
  3819. if ( content.length ) {
  3820. content = this._normalize( content );
  3821. this._suggest( content );
  3822. this._trigger( "open" );
  3823. } else {
  3824. this.close();
  3825. }
  3826. this.element.removeClass( "ui-autocomplete-loading" );
  3827. },
  3828. close: function( event ) {
  3829. clearTimeout( this.closing );
  3830. if ( this.menu.element.is(":visible") ) {
  3831. this._trigger( "close", event );
  3832. this.menu.element.hide();
  3833. this.menu.deactivate();
  3834. }
  3835. if ( this.previous !== this.element.val() ) {
  3836. this._trigger( "change", event );
  3837. }
  3838. },
  3839. _normalize: function( items ) {
  3840. // assume all items have the right format when the first item is complete
  3841. if ( items.length && items[0].label && items[0].value ) {
  3842. return items;
  3843. }
  3844. return $.map( items, function(item) {
  3845. if ( typeof item === "string" ) {
  3846. return {
  3847. label: item,
  3848. value: item
  3849. };
  3850. }
  3851. return $.extend({
  3852. label: item.label || item.value,
  3853. value: item.value || item.label
  3854. }, item );
  3855. });
  3856. },
  3857. _suggest: function( items ) {
  3858. var ul = this.menu.element
  3859. .empty()
  3860. .zIndex( this.element.zIndex() + 1 ),
  3861. menuWidth,
  3862. textWidth;
  3863. this._renderMenu( ul, items );
  3864. // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
  3865. this.menu.deactivate();
  3866. this.menu.refresh();
  3867. this.menu.element.show().position({
  3868. my: "left top",
  3869. at: "left bottom",
  3870. of: this.element,
  3871. collision: "none"
  3872. });
  3873. menuWidth = ul.width( "" ).width();
  3874. textWidth = this.element.width();
  3875. ul.width( Math.max( menuWidth, textWidth ) );
  3876. },
  3877. _renderMenu: function( ul, items ) {
  3878. var self = this;
  3879. $.each( items, function( index, item ) {
  3880. self._renderItem( ul, item );
  3881. });
  3882. },
  3883. _renderItem: function( ul, item) {
  3884. return $( "<li></li>" )
  3885. .data( "item.autocomplete", item )
  3886. .append( "<a>" + item.label + "</a>" )
  3887. .appendTo( ul );
  3888. },
  3889. _move: function( direction, event ) {
  3890. if ( !this.menu.element.is(":visible") ) {
  3891. this.search( null, event );
  3892. return;
  3893. }
  3894. if ( this.menu.first() && /^previous/.test(direction) ||
  3895. this.menu.last() && /^next/.test(direction) ) {
  3896. this.element.val( this.term );
  3897. this.menu.deactivate();
  3898. return;
  3899. }
  3900. this.menu[ direction ]();
  3901. },
  3902. widget: function() {
  3903. return this.menu.element;
  3904. }
  3905. });
  3906. $.extend( $.ui.autocomplete, {
  3907. escapeRegex: function( value ) {
  3908. return value.replace( /([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1" );
  3909. }
  3910. });
  3911. }( jQuery ));
  3912. /*
  3913. * jQuery UI Menu (not officially released)
  3914. *
  3915. * This widget isn't yet finished and the API is subject to change. We plan to finish
  3916. * it for the next release. You're welcome to give it a try anyway and give us feedback,
  3917. * as long as you're okay with migrating your code later on. We can help with that, too.
  3918. *
  3919. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  3920. * Dual licensed under the MIT (MIT-LICENSE.txt)
  3921. * and GPL (GPL-LICENSE.txt) licenses.
  3922. *
  3923. * http://docs.jquery.com/UI/Menu
  3924. *
  3925. * Depends:
  3926. * jquery.ui.core.js
  3927. * jquery.ui.widget.js
  3928. */
  3929. (function($) {
  3930. $.widget("ui.menu", {
  3931. _create: function() {
  3932. var self = this;
  3933. this.element
  3934. .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
  3935. .attr({
  3936. role: "listbox",
  3937. "aria-activedescendant": "ui-active-menuitem"
  3938. })
  3939. .click(function(e) {
  3940. // temporary
  3941. e.preventDefault();
  3942. self.select();
  3943. });
  3944. this.refresh();
  3945. },
  3946. refresh: function() {
  3947. var self = this;
  3948. // don't refresh list items that are already adapted
  3949. var items = this.element.children("li:not(.ui-menu-item):has(a)")
  3950. .addClass("ui-menu-item")
  3951. .attr("role", "menuitem");
  3952. items.children("a")
  3953. .addClass("ui-corner-all")
  3954. .attr("tabindex", -1)
  3955. // mouseenter doesn't work with event delegation
  3956. .mouseenter(function() {
  3957. self.activate($(this).parent());
  3958. })
  3959. .mouseleave(function() {
  3960. self.deactivate();
  3961. });
  3962. },
  3963. activate: function(item) {
  3964. this.deactivate();
  3965. if (this.hasScroll()) {
  3966. var offset = item.offset().top - this.element.offset().top,
  3967. scroll = this.element.attr("scrollTop"),
  3968. elementHeight = this.element.height();
  3969. if (offset < 0) {
  3970. this.element.attr("scrollTop", scroll + offset);
  3971. } else if (offset > elementHeight) {
  3972. this.element.attr("scrollTop", scroll + offset - elementHeight + item.height());
  3973. }
  3974. }
  3975. this.active = item.eq(0)
  3976. .children("a")
  3977. .addClass("ui-state-hover")
  3978. .attr("id", "ui-active-menuitem")
  3979. .end();
  3980. this._trigger("focus", null, { item: item });
  3981. },
  3982. deactivate: function() {
  3983. if (!this.active) { return; }
  3984. this.active.children("a")
  3985. .removeClass("ui-state-hover")
  3986. .removeAttr("id");
  3987. this._trigger("blur");
  3988. this.active = null;
  3989. },
  3990. next: function() {
  3991. this.move("next", "li:first");
  3992. },
  3993. previous: function() {
  3994. this.move("prev", "li:last");
  3995. },
  3996. first: function() {
  3997. return this.active && !this.active.prev().length;
  3998. },
  3999. last: function() {
  4000. return this.active && !this.active.next().length;
  4001. },
  4002. move: function(direction, edge) {
  4003. if (!this.active) {
  4004. this.activate(this.element.children(edge));
  4005. return;
  4006. }
  4007. var next = this.active[direction]();
  4008. if (next.length) {
  4009. this.activate(next);
  4010. } else {
  4011. this.activate(this.element.children(edge));
  4012. }
  4013. },
  4014. // TODO merge with previousPage
  4015. nextPage: function() {
  4016. if (this.hasScroll()) {
  4017. // TODO merge with no-scroll-else
  4018. if (!this.active || this.last()) {
  4019. this.activate(this.element.children(":first"));
  4020. return;
  4021. }
  4022. var base = this.active.offset().top,
  4023. height = this.element.height(),
  4024. result = this.element.children("li").filter(function() {
  4025. var close = $(this).offset().top - base - height + $(this).height();
  4026. // TODO improve approximation
  4027. return close < 10 && close > -10;
  4028. });
  4029. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  4030. if (!result.length) {
  4031. result = this.element.children(":last");
  4032. }
  4033. this.activate(result);
  4034. } else {
  4035. this.activate(this.element.children(!this.active || this.last() ? ":first" : ":last"));
  4036. }
  4037. },
  4038. // TODO merge with nextPage
  4039. previousPage: function() {
  4040. if (this.hasScroll()) {
  4041. // TODO merge with no-scroll-else
  4042. if (!this.active || this.first()) {
  4043. this.activate(this.element.children(":last"));
  4044. return;
  4045. }
  4046. var base = this.active.offset().top,
  4047. height = this.element.height();
  4048. result = this.element.children("li").filter(function() {
  4049. var close = $(this).offset().top - base + height - $(this).height();
  4050. // TODO improve approximation
  4051. return close < 10 && close > -10;
  4052. });
  4053. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  4054. if (!result.length) {
  4055. result = this.element.children(":first");
  4056. }
  4057. this.activate(result);
  4058. } else {
  4059. this.activate(this.element.children(!this.active || this.first() ? ":last" : ":first"));
  4060. }
  4061. },
  4062. hasScroll: function() {
  4063. return this.element.height() < this.element.attr("scrollHeight");
  4064. },
  4065. select: function() {
  4066. this._trigger("selected", null, { item: this.active });
  4067. }
  4068. });
  4069. }(jQuery));
  4070. /*
  4071. * jQuery UI Button 1.8
  4072. *
  4073. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  4074. * Dual licensed under the MIT (MIT-LICENSE.txt)
  4075. * and GPL (GPL-LICENSE.txt) licenses.
  4076. *
  4077. * http://docs.jquery.com/UI/Button
  4078. *
  4079. * Depends:
  4080. * jquery.ui.core.js
  4081. * jquery.ui.widget.js
  4082. */
  4083. (function( $ ) {
  4084. var lastActive,
  4085. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  4086. otherClasses = "ui-state-hover ui-state-active " +
  4087. "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon ui-button-text-only",
  4088. formResetHandler = function( event ) {
  4089. $( ":ui-button", event.target.form ).each(function() {
  4090. var inst = $( this ).data( "button" );
  4091. setTimeout(function() {
  4092. inst.refresh();
  4093. }, 1 );
  4094. });
  4095. },
  4096. radioGroup = function( radio ) {
  4097. var name = radio.name,
  4098. form = radio.form,
  4099. radios = $( [] );
  4100. if ( name ) {
  4101. if ( form ) {
  4102. radios = $( form ).find( "[name='" + name + "']" );
  4103. } else {
  4104. radios = $( "[name='" + name + "']", radio.ownerDocument )
  4105. .filter(function() {
  4106. return !this.form;
  4107. });
  4108. }
  4109. }
  4110. return radios;
  4111. };
  4112. $.widget( "ui.button", {
  4113. options: {
  4114. text: true,
  4115. label: null,
  4116. icons: {
  4117. primary: null,
  4118. secondary: null
  4119. }
  4120. },
  4121. _create: function() {
  4122. this.element.closest( "form" )
  4123. .unbind( "reset.button" )
  4124. .bind( "reset.button", formResetHandler );
  4125. this._determineButtonType();
  4126. this.hasTitle = !!this.buttonElement.attr( "title" );
  4127. var self = this,
  4128. options = this.options,
  4129. toggleButton = this.type === "checkbox" || this.type === "radio",
  4130. hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
  4131. focusClass = "ui-state-focus";
  4132. if ( options.label === null ) {
  4133. options.label = this.buttonElement.html();
  4134. }
  4135. if ( this.element.is( ":disabled" ) ) {
  4136. options.disabled = true;
  4137. }
  4138. this.buttonElement
  4139. .addClass( baseClasses )
  4140. .attr( "role", "button" )
  4141. .bind( "mouseenter.button", function() {
  4142. if ( options.disabled ) {
  4143. return;
  4144. }
  4145. $( this ).addClass( "ui-state-hover" );
  4146. if ( this === lastActive ) {
  4147. $( this ).addClass( "ui-state-active" );
  4148. }
  4149. })
  4150. .bind( "mouseleave.button", function() {
  4151. if ( options.disabled ) {
  4152. return;
  4153. }
  4154. $( this ).removeClass( hoverClass );
  4155. })
  4156. .bind( "focus.button", function() {
  4157. // no need to check disabled, focus won't be triggered anyway
  4158. $( this ).addClass( focusClass );
  4159. })
  4160. .bind( "blur.button", function() {
  4161. $( this ).removeClass( focusClass );
  4162. });
  4163. if ( toggleButton ) {
  4164. this.element.bind( "change.button", function() {
  4165. self.refresh();
  4166. });
  4167. }
  4168. if ( this.type === "checkbox" ) {
  4169. this.buttonElement.bind( "click.button", function() {
  4170. if ( options.disabled ) {
  4171. return false;
  4172. }
  4173. $( this ).toggleClass( "ui-state-active" );
  4174. self.buttonElement.attr( "aria-pressed", self.element[0].checked );
  4175. });
  4176. } else if ( this.type === "radio" ) {
  4177. this.buttonElement.bind( "click.button", function() {
  4178. if ( options.disabled ) {
  4179. return false;
  4180. }
  4181. $( this ).addClass( "ui-state-active" );
  4182. self.buttonElement.attr( "aria-pressed", true );
  4183. var radio = self.element[ 0 ];
  4184. radioGroup( radio )
  4185. .not( radio )
  4186. .map(function() {
  4187. return $( this ).button( "widget" )[ 0 ];
  4188. })
  4189. .removeClass( "ui-state-active" )
  4190. .attr( "aria-pressed", false );
  4191. });
  4192. } else {
  4193. this.buttonElement
  4194. .bind( "mousedown.button", function() {
  4195. if ( options.disabled ) {
  4196. return false;
  4197. }
  4198. $( this ).addClass( "ui-state-active" );
  4199. lastActive = this;
  4200. $( document ).one( "mouseup", function() {
  4201. lastActive = null;
  4202. });
  4203. })
  4204. .bind( "mouseup.button", function() {
  4205. if ( options.disabled ) {
  4206. return false;
  4207. }
  4208. $( this ).removeClass( "ui-state-active" );
  4209. })
  4210. .bind( "keydown.button", function(event) {
  4211. if ( options.disabled ) {
  4212. return false;
  4213. }
  4214. if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
  4215. $( this ).addClass( "ui-state-active" );
  4216. }
  4217. })
  4218. .bind( "keyup.button", function() {
  4219. $( this ).removeClass( "ui-state-active" );
  4220. });
  4221. if ( this.buttonElement.is("a") ) {
  4222. this.buttonElement.keyup(function(event) {
  4223. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  4224. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  4225. $( this ).click();
  4226. }
  4227. });
  4228. }
  4229. }
  4230. // TODO: pull out $.Widget's handling for the disabled option into
  4231. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  4232. // be overridden by individual plugins
  4233. this._setOption( "disabled", options.disabled );
  4234. },
  4235. _determineButtonType: function() {
  4236. if ( this.element.is(":checkbox") ) {
  4237. this.type = "checkbox";
  4238. } else {
  4239. if ( this.element.is(":radio") ) {
  4240. this.type = "radio";
  4241. } else {
  4242. if ( this.element.is("input") ) {
  4243. this.type = "input";
  4244. } else {
  4245. this.type = "button";
  4246. }
  4247. }
  4248. }
  4249. if ( this.type === "checkbox" || this.type === "radio" ) {
  4250. // we don't search against the document in case the element
  4251. // is disconnected from the DOM
  4252. this.buttonElement = this.element.parents().last()
  4253. .find( "[for=" + this.element.attr("id") + "]" );
  4254. this.element.addClass( "ui-helper-hidden-accessible" );
  4255. var checked = this.element.is( ":checked" );
  4256. if ( checked ) {
  4257. this.buttonElement.addClass( "ui-state-active" );
  4258. }
  4259. this.buttonElement.attr( "aria-pressed", checked );
  4260. } else {
  4261. this.buttonElement = this.element;
  4262. }
  4263. },
  4264. widget: function() {
  4265. return this.buttonElement;
  4266. },
  4267. destroy: function() {
  4268. this.element
  4269. .removeClass( "ui-helper-hidden-accessible" );
  4270. this.buttonElement
  4271. .removeClass( baseClasses + " " + otherClasses )
  4272. .removeAttr( "role" )
  4273. .removeAttr( "aria-pressed" )
  4274. .html( this.buttonElement.find(".ui-button-text").html() );
  4275. if ( !this.hasTitle ) {
  4276. this.buttonElement.removeAttr( "title" );
  4277. }
  4278. $.Widget.prototype.destroy.call( this );
  4279. },
  4280. _setOption: function( key, value ) {
  4281. $.Widget.prototype._setOption.apply( this, arguments );
  4282. if ( key === "disabled" ) {
  4283. if ( value ) {
  4284. this.element.attr( "disabled", true );
  4285. } else {
  4286. this.element.removeAttr( "disabled" );
  4287. }
  4288. }
  4289. this._resetButton();
  4290. },
  4291. refresh: function() {
  4292. var isDisabled = this.element.is( ":disabled" );
  4293. if ( isDisabled !== this.options.disabled ) {
  4294. this._setOption( "disabled", isDisabled );
  4295. }
  4296. if ( this.type === "radio" ) {
  4297. radioGroup( this.element[0] ).each(function() {
  4298. if ( $( this ).is( ":checked" ) ) {
  4299. $( this ).button( "widget" )
  4300. .addClass( "ui-state-active" )
  4301. .attr( "aria-pressed", true );
  4302. } else {
  4303. $( this ).button( "widget" )
  4304. .removeClass( "ui-state-active" )
  4305. .attr( "aria-pressed", false );
  4306. }
  4307. });
  4308. } else if ( this.type === "checkbox" ) {
  4309. if ( this.element.is( ":checked" ) ) {
  4310. this.buttonElement
  4311. .addClass( "ui-state-active" )
  4312. .attr( "aria-pressed", true );
  4313. } else {
  4314. this.buttonElement
  4315. .removeClass( "ui-state-active" )
  4316. .attr( "aria-pressed", false );
  4317. }
  4318. }
  4319. },
  4320. _resetButton: function() {
  4321. if ( this.type === "input" ) {
  4322. if ( this.options.label ) {
  4323. this.element.val( this.options.label );
  4324. }
  4325. return;
  4326. }
  4327. var buttonElement = this.buttonElement,
  4328. buttonText = $( "<span></span>" )
  4329. .addClass( "ui-button-text" )
  4330. .html( this.options.label )
  4331. .appendTo( buttonElement.empty() )
  4332. .text(),
  4333. icons = this.options.icons,
  4334. multipleIcons = icons.primary && icons.secondary;
  4335. if ( icons.primary || icons.secondary ) {
  4336. buttonElement.addClass( "ui-button-text-icon" +
  4337. ( multipleIcons ? "s" : "" ) );
  4338. if ( icons.primary ) {
  4339. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  4340. }
  4341. if ( icons.secondary ) {
  4342. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  4343. }
  4344. if ( !this.options.text ) {
  4345. buttonElement
  4346. .addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
  4347. .removeClass( "ui-button-text-icons ui-button-text-icon" );
  4348. if ( !this.hasTitle ) {
  4349. buttonElement.attr( "title", buttonText );
  4350. }
  4351. }
  4352. } else {
  4353. buttonElement.addClass( "ui-button-text-only" );
  4354. }
  4355. }
  4356. });
  4357. $.widget( "ui.buttonset", {
  4358. _create: function() {
  4359. this.element.addClass( "ui-buttonset" );
  4360. this._init();
  4361. },
  4362. _init: function() {
  4363. this.refresh();
  4364. },
  4365. _setOption: function( key, value ) {
  4366. if ( key === "disabled" ) {
  4367. this.buttons.button( "option", key, value );
  4368. }
  4369. $.Widget.prototype._setOption.apply( this, arguments );
  4370. },
  4371. refresh: function() {
  4372. this.buttons = this.element.find( ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" )
  4373. .filter( ":ui-button" )
  4374. .button( "refresh" )
  4375. .end()
  4376. .not( ":ui-button" )
  4377. .button()
  4378. .end()
  4379. .map(function() {
  4380. return $( this ).button( "widget" )[ 0 ];
  4381. })
  4382. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  4383. .filter( ":first" )
  4384. .addClass( "ui-corner-left" )
  4385. .end()
  4386. .filter( ":last" )
  4387. .addClass( "ui-corner-right" )
  4388. .end()
  4389. .end();
  4390. },
  4391. destroy: function() {
  4392. this.element.removeClass( "ui-buttonset" );
  4393. this.buttons
  4394. .map(function() {
  4395. return $( this ).button( "widget" )[ 0 ];
  4396. })
  4397. .removeClass( "ui-corner-left ui-corner-right" )
  4398. .end()
  4399. .button( "destroy" )
  4400. $.Widget.prototype.destroy.call( this );
  4401. }
  4402. });
  4403. }( jQuery ) );
  4404. /*
  4405. * jQuery UI Dialog 1.8
  4406. *
  4407. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  4408. * Dual licensed under the MIT (MIT-LICENSE.txt)
  4409. * and GPL (GPL-LICENSE.txt) licenses.
  4410. *
  4411. * http://docs.jquery.com/UI/Dialog
  4412. *
  4413. * Depends:
  4414. * jquery.ui.core.js
  4415. * jquery.ui.widget.js
  4416. * jquery.ui.button.js
  4417. * jquery.ui.draggable.js
  4418. * jquery.ui.mouse.js
  4419. * jquery.ui.position.js
  4420. * jquery.ui.resizable.js
  4421. */
  4422. (function($) {
  4423. var uiDialogClasses =
  4424. 'ui-dialog ' +
  4425. 'ui-widget ' +
  4426. 'ui-widget-content ' +
  4427. 'ui-corner-all ';
  4428. $.widget("ui.dialog", {
  4429. options: {
  4430. autoOpen: true,
  4431. buttons: {},
  4432. closeOnEscape: true,
  4433. closeText: 'close',
  4434. dialogClass: '',
  4435. draggable: true,
  4436. hide: null,
  4437. height: 'auto',
  4438. maxHeight: false,
  4439. maxWidth: false,
  4440. minHeight: 150,
  4441. minWidth: 150,
  4442. modal: false,
  4443. position: 'center',
  4444. resizable: true,
  4445. show: null,
  4446. stack: true,
  4447. title: '',
  4448. width: 300,
  4449. zIndex: 1000
  4450. },
  4451. _create: function() {
  4452. this.originalTitle = this.element.attr('title');
  4453. var self = this,
  4454. options = self.options,
  4455. title = options.title || self.originalTitle || '&#160;',
  4456. titleId = $.ui.dialog.getTitleId(self.element),
  4457. uiDialog = (self.uiDialog = $('<div></div>'))
  4458. .appendTo(document.body)
  4459. .hide()
  4460. .addClass(uiDialogClasses + options.dialogClass)
  4461. .css({
  4462. zIndex: options.zIndex
  4463. })
  4464. // setting tabIndex makes the div focusable
  4465. // setting outline to 0 prevents a border on focus in Mozilla
  4466. .attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
  4467. if (options.closeOnEscape && event.keyCode &&
  4468. event.keyCode === $.ui.keyCode.ESCAPE) {
  4469. self.close(event);
  4470. event.preventDefault();
  4471. }
  4472. })
  4473. .attr({
  4474. role: 'dialog',
  4475. 'aria-labelledby': titleId
  4476. })
  4477. .mousedown(function(event) {
  4478. self.moveToTop(false, event);
  4479. }),
  4480. uiDialogContent = self.element
  4481. .show()
  4482. .removeAttr('title')
  4483. .addClass(
  4484. 'ui-dialog-content ' +
  4485. 'ui-widget-content')
  4486. .appendTo(uiDialog),
  4487. uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
  4488. .addClass(
  4489. 'ui-dialog-titlebar ' +
  4490. 'ui-widget-header ' +
  4491. 'ui-corner-all ' +
  4492. 'ui-helper-clearfix'
  4493. )
  4494. .prependTo(uiDialog),
  4495. uiDialogTitlebarClose = $('<a href="#"></a>')
  4496. .addClass(
  4497. 'ui-dialog-titlebar-close ' +
  4498. 'ui-corner-all'
  4499. )
  4500. .attr('role', 'button')
  4501. .hover(
  4502. function() {
  4503. uiDialogTitlebarClose.addClass('ui-state-hover');
  4504. },
  4505. function() {
  4506. uiDialogTitlebarClose.removeClass('ui-state-hover');
  4507. }
  4508. )
  4509. .focus(function() {
  4510. uiDialogTitlebarClose.addClass('ui-state-focus');
  4511. })
  4512. .blur(function() {
  4513. uiDialogTitlebarClose.removeClass('ui-state-focus');
  4514. })
  4515. .click(function(event) {
  4516. self.close(event);
  4517. return false;
  4518. })
  4519. .appendTo(uiDialogTitlebar),
  4520. uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
  4521. .addClass(
  4522. 'ui-icon ' +
  4523. 'ui-icon-closethick'
  4524. )
  4525. .text(options.closeText)
  4526. .appendTo(uiDialogTitlebarClose),
  4527. uiDialogTitle = $('<span></span>')
  4528. .addClass('ui-dialog-title')
  4529. .attr('id', titleId)
  4530. .html(title)
  4531. .prependTo(uiDialogTitlebar);
  4532. //handling of deprecated beforeclose (vs beforeClose) option
  4533. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  4534. //TODO: remove in 1.9pre
  4535. if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
  4536. options.beforeClose = options.beforeclose;
  4537. }
  4538. uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
  4539. if (options.draggable && $.fn.draggable) {
  4540. self._makeDraggable();
  4541. }
  4542. if (options.resizable && $.fn.resizable) {
  4543. self._makeResizable();
  4544. }
  4545. self._createButtons(options.buttons);
  4546. self._isOpen = false;
  4547. if ($.fn.bgiframe) {
  4548. uiDialog.bgiframe();
  4549. }
  4550. },
  4551. _init: function() {
  4552. if ( this.options.autoOpen ) {
  4553. this.open();
  4554. }
  4555. },
  4556. destroy: function() {
  4557. var self = this;
  4558. if (self.overlay) {
  4559. self.overlay.destroy();
  4560. }
  4561. self.uiDialog.hide();
  4562. self.element
  4563. .unbind('.dialog')
  4564. .removeData('dialog')
  4565. .removeClass('ui-dialog-content ui-widget-content')
  4566. .hide().appendTo('body');
  4567. self.uiDialog.remove();
  4568. if (self.originalTitle) {
  4569. self.element.attr('title', self.originalTitle);
  4570. }
  4571. return self;
  4572. },
  4573. widget: function() {
  4574. return this.uiDialog;
  4575. },
  4576. close: function(event) {
  4577. var self = this,
  4578. maxZ;
  4579. if (false === self._trigger('beforeClose', event)) {
  4580. return;
  4581. }
  4582. if (self.overlay) {
  4583. self.overlay.destroy();
  4584. }
  4585. self.uiDialog.unbind('keypress.ui-dialog');
  4586. self._isOpen = false;
  4587. if (self.options.hide) {
  4588. self.uiDialog.hide(self.options.hide, function() {
  4589. self._trigger('close', event);
  4590. });
  4591. } else {
  4592. self.uiDialog.hide();
  4593. self._trigger('close', event);
  4594. }
  4595. $.ui.dialog.overlay.resize();
  4596. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  4597. if (self.options.modal) {
  4598. maxZ = 0;
  4599. $('.ui-dialog').each(function() {
  4600. if (this !== self.uiDialog[0]) {
  4601. maxZ = Math.max(maxZ, $(this).css('z-index'));
  4602. }
  4603. });
  4604. $.ui.dialog.maxZ = maxZ;
  4605. }
  4606. return self;
  4607. },
  4608. isOpen: function() {
  4609. return this._isOpen;
  4610. },
  4611. // the force parameter allows us to move modal dialogs to their correct
  4612. // position on open
  4613. moveToTop: function(force, event) {
  4614. var self = this,
  4615. options = self.options,
  4616. saveScroll;
  4617. if ((options.modal && !force) ||
  4618. (!options.stack && !options.modal)) {
  4619. return self._trigger('focus', event);
  4620. }
  4621. if (options.zIndex > $.ui.dialog.maxZ) {
  4622. $.ui.dialog.maxZ = options.zIndex;
  4623. }
  4624. if (self.overlay) {
  4625. $.ui.dialog.maxZ += 1;
  4626. self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
  4627. }
  4628. //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
  4629. // http://ui.jquery.com/bugs/ticket/3193
  4630. saveScroll = { scrollTop: self.element.attr('scrollTop'), scrollLeft: self.element.attr('scrollLeft') };
  4631. $.ui.dialog.maxZ += 1;
  4632. self.uiDialog.css('z-index', $.ui.dialog.maxZ);
  4633. self.element.attr(saveScroll);
  4634. self._trigger('focus', event);
  4635. return self;
  4636. },
  4637. open: function() {
  4638. if (this._isOpen) { return; }
  4639. var self = this,
  4640. options = self.options,
  4641. uiDialog = self.uiDialog;
  4642. self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
  4643. if (uiDialog.next().length) {
  4644. uiDialog.appendTo('body');
  4645. }
  4646. self._size();
  4647. self._position(options.position);
  4648. uiDialog.show(options.show);
  4649. self.moveToTop(true);
  4650. // prevent tabbing out of modal dialogs
  4651. if (options.modal) {
  4652. uiDialog.bind('keypress.ui-dialog', function(event) {
  4653. if (event.keyCode !== $.ui.keyCode.TAB) {
  4654. return;
  4655. }
  4656. var tabbables = $(':tabbable', this),
  4657. first = tabbables.filter(':first'),
  4658. last = tabbables.filter(':last');
  4659. if (event.target === last[0] && !event.shiftKey) {
  4660. first.focus(1);
  4661. return false;
  4662. } else if (event.target === first[0] && event.shiftKey) {
  4663. last.focus(1);
  4664. return false;
  4665. }
  4666. });
  4667. }
  4668. // set focus to the first tabbable element in the content area or the first button
  4669. // if there are no tabbable elements, set focus on the dialog itself
  4670. $([])
  4671. .add(uiDialog.find('.ui-dialog-content :tabbable:first'))
  4672. .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first'))
  4673. .add(uiDialog)
  4674. .filter(':first')
  4675. .focus();
  4676. self._trigger('open');
  4677. self._isOpen = true;
  4678. return self;
  4679. },
  4680. _createButtons: function(buttons) {
  4681. var self = this,
  4682. hasButtons = false,
  4683. uiDialogButtonPane = $('<div></div>')
  4684. .addClass(
  4685. 'ui-dialog-buttonpane ' +
  4686. 'ui-widget-content ' +
  4687. 'ui-helper-clearfix'
  4688. );
  4689. // if we already have a button pane, remove it
  4690. self.uiDialog.find('.ui-dialog-buttonpane').remove();
  4691. if (typeof buttons === 'object' && buttons !== null) {
  4692. $.each(buttons, function() {
  4693. return !(hasButtons = true);
  4694. });
  4695. }
  4696. if (hasButtons) {
  4697. $.each(buttons, function(name, fn) {
  4698. var button = $('<button type="button"></button>')
  4699. .text(name)
  4700. .click(function() { fn.apply(self.element[0], arguments); })
  4701. .appendTo(uiDialogButtonPane);
  4702. if ($.fn.button) {
  4703. button.button();
  4704. }
  4705. });
  4706. uiDialogButtonPane.appendTo(self.uiDialog);
  4707. }
  4708. },
  4709. _makeDraggable: function() {
  4710. var self = this,
  4711. options = self.options,
  4712. doc = $(document),
  4713. heightBeforeDrag;
  4714. function filteredUi(ui) {
  4715. return {
  4716. position: ui.position,
  4717. offset: ui.offset
  4718. };
  4719. }
  4720. self.uiDialog.draggable({
  4721. cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
  4722. handle: '.ui-dialog-titlebar',
  4723. containment: 'document',
  4724. start: function(event, ui) {
  4725. heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
  4726. $(this).height($(this).height()).addClass("ui-dialog-dragging");
  4727. self._trigger('dragStart', event, filteredUi(ui));
  4728. },
  4729. drag: function(event, ui) {
  4730. self._trigger('drag', event, filteredUi(ui));
  4731. },
  4732. stop: function(event, ui) {
  4733. options.position = [ui.position.left - doc.scrollLeft(),
  4734. ui.position.top - doc.scrollTop()];
  4735. $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
  4736. self._trigger('dragStop', event, filteredUi(ui));
  4737. $.ui.dialog.overlay.resize();
  4738. }
  4739. });
  4740. },
  4741. _makeResizable: function(handles) {
  4742. handles = (handles === undefined ? this.options.resizable : handles);
  4743. var self = this,
  4744. options = self.options,
  4745. // .ui-resizable has position: relative defined in the stylesheet
  4746. // but dialogs have to use absolute or fixed positioning
  4747. position = self.uiDialog.css('position'),
  4748. resizeHandles = (typeof handles === 'string' ?
  4749. handles :
  4750. 'n,e,s,w,se,sw,ne,nw'
  4751. );
  4752. function filteredUi(ui) {
  4753. return {
  4754. originalPosition: ui.originalPosition,
  4755. originalSize: ui.originalSize,
  4756. position: ui.position,
  4757. size: ui.size
  4758. };
  4759. }
  4760. self.uiDialog.resizable({
  4761. cancel: '.ui-dialog-content',
  4762. containment: 'document',
  4763. alsoResize: self.element,
  4764. maxWidth: options.maxWidth,
  4765. maxHeight: options.maxHeight,
  4766. minWidth: options.minWidth,
  4767. minHeight: self._minHeight(),
  4768. handles: resizeHandles,
  4769. start: function(event, ui) {
  4770. $(this).addClass("ui-dialog-resizing");
  4771. self._trigger('resizeStart', event, filteredUi(ui));
  4772. },
  4773. resize: function(event, ui) {
  4774. self._trigger('resize', event, filteredUi(ui));
  4775. },
  4776. stop: function(event, ui) {
  4777. $(this).removeClass("ui-dialog-resizing");
  4778. options.height = $(this).height();
  4779. options.width = $(this).width();
  4780. self._trigger('resizeStop', event, filteredUi(ui));
  4781. $.ui.dialog.overlay.resize();
  4782. }
  4783. })
  4784. .css('position', position)
  4785. .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
  4786. },
  4787. _minHeight: function() {
  4788. var options = this.options;
  4789. if (options.height === 'auto') {
  4790. return options.minHeight;
  4791. } else {
  4792. return Math.min(options.minHeight, options.height);
  4793. }
  4794. },
  4795. _position: function(position) {
  4796. var myAt = [],
  4797. offset = [0, 0],
  4798. isVisible;
  4799. position = position || $.ui.dialog.prototype.options.position;
  4800. // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
  4801. // if (typeof position == 'string' || $.isArray(position)) {
  4802. // myAt = $.isArray(position) ? position : position.split(' ');
  4803. if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
  4804. myAt = position.split ? position.split(' ') : [position[0], position[1]];
  4805. if (myAt.length === 1) {
  4806. myAt[1] = myAt[0];
  4807. }
  4808. $.each(['left', 'top'], function(i, offsetPosition) {
  4809. if (+myAt[i] === myAt[i]) {
  4810. offset[i] = myAt[i];
  4811. myAt[i] = offsetPosition;
  4812. }
  4813. });
  4814. } else if (typeof position === 'object') {
  4815. if ('left' in position) {
  4816. myAt[0] = 'left';
  4817. offset[0] = position.left;
  4818. } else if ('right' in position) {
  4819. myAt[0] = 'right';
  4820. offset[0] = -position.right;
  4821. }
  4822. if ('top' in position) {
  4823. myAt[1] = 'top';
  4824. offset[1] = position.top;
  4825. } else if ('bottom' in position) {
  4826. myAt[1] = 'bottom';
  4827. offset[1] = -position.bottom;
  4828. }
  4829. }
  4830. // need to show the dialog to get the actual offset in the position plugin
  4831. isVisible = this.uiDialog.is(':visible');
  4832. if (!isVisible) {
  4833. this.uiDialog.show();
  4834. }
  4835. this.uiDialog
  4836. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  4837. .css({ top: 0, left: 0 })
  4838. .position({
  4839. my: myAt.join(' '),
  4840. at: myAt.join(' '),
  4841. offset: offset.join(' '),
  4842. of: window,
  4843. collision: 'fit',
  4844. // ensure that the titlebar is never outside the document
  4845. using: function(pos) {
  4846. var topOffset = $(this).css(pos).offset().top;
  4847. if (topOffset < 0) {
  4848. $(this).css('top', pos.top - topOffset);
  4849. }
  4850. }
  4851. });
  4852. if (!isVisible) {
  4853. this.uiDialog.hide();
  4854. }
  4855. },
  4856. _setOption: function(key, value){
  4857. var self = this,
  4858. uiDialog = self.uiDialog,
  4859. isResizable = uiDialog.is(':data(resizable)'),
  4860. resize = false;
  4861. switch (key) {
  4862. //handling of deprecated beforeclose (vs beforeClose) option
  4863. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  4864. //TODO: remove in 1.9pre
  4865. case "beforeclose":
  4866. key = "beforeClose";
  4867. break;
  4868. case "buttons":
  4869. self._createButtons(value);
  4870. break;
  4871. case "closeText":
  4872. // convert whatever was passed in to a string, for text() to not throw up
  4873. self.uiDialogTitlebarCloseText.text("" + value);
  4874. break;
  4875. case "dialogClass":
  4876. uiDialog
  4877. .removeClass(self.options.dialogClass)
  4878. .addClass(uiDialogClasses + value);
  4879. break;
  4880. case "disabled":
  4881. if (value) {
  4882. uiDialog.addClass('ui-dialog-disabled');
  4883. } else {
  4884. uiDialog.removeClass('ui-dialog-disabled');
  4885. }
  4886. break;
  4887. case "draggable":
  4888. if (value) {
  4889. self._makeDraggable();
  4890. } else {
  4891. uiDialog.draggable('destroy');
  4892. }
  4893. break;
  4894. case "height":
  4895. resize = true;
  4896. break;
  4897. case "maxHeight":
  4898. if (isResizable) {
  4899. uiDialog.resizable('option', 'maxHeight', value);
  4900. }
  4901. resize = true;
  4902. break;
  4903. case "maxWidth":
  4904. if (isResizable) {
  4905. uiDialog.resizable('option', 'maxWidth', value);
  4906. }
  4907. resize = true;
  4908. break;
  4909. case "minHeight":
  4910. if (isResizable) {
  4911. uiDialog.resizable('option', 'minHeight', value);
  4912. }
  4913. resize = true;
  4914. break;
  4915. case "minWidth":
  4916. if (isResizable) {
  4917. uiDialog.resizable('option', 'minWidth', value);
  4918. }
  4919. resize = true;
  4920. break;
  4921. case "position":
  4922. self._position(value);
  4923. break;
  4924. case "resizable":
  4925. // currently resizable, becoming non-resizable
  4926. if (isResizable && !value) {
  4927. uiDialog.resizable('destroy');
  4928. }
  4929. // currently resizable, changing handles
  4930. if (isResizable && typeof value === 'string') {
  4931. uiDialog.resizable('option', 'handles', value);
  4932. }
  4933. // currently non-resizable, becoming resizable
  4934. if (!isResizable && value !== false) {
  4935. self._makeResizable(value);
  4936. }
  4937. break;
  4938. case "title":
  4939. // convert whatever was passed in o a string, for html() to not throw up
  4940. $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
  4941. break;
  4942. case "width":
  4943. resize = true;
  4944. break;
  4945. }
  4946. $.Widget.prototype._setOption.apply(self, arguments);
  4947. if (resize) {
  4948. self._size();
  4949. }
  4950. },
  4951. _size: function() {
  4952. /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  4953. * divs will both have width and height set, so we need to reset them
  4954. */
  4955. var options = this.options,
  4956. nonContentHeight;
  4957. // reset content sizing
  4958. // hide for non content measurement because height: 0 doesn't work in IE quirks mode (see #4350)
  4959. this.element.css('width', 'auto')
  4960. .hide();
  4961. // reset wrapper sizing
  4962. // determine the height of all the non-content elements
  4963. nonContentHeight = this.uiDialog.css({
  4964. height: 'auto',
  4965. width: options.width
  4966. })
  4967. .height();
  4968. this.element
  4969. .css(options.height === 'auto' ? {
  4970. minHeight: Math.max(options.minHeight - nonContentHeight, 0),
  4971. height: 'auto'
  4972. } : {
  4973. minHeight: 0,
  4974. height: Math.max(options.height - nonContentHeight, 0)
  4975. })
  4976. .show();
  4977. if (this.uiDialog.is(':data(resizable)')) {
  4978. this.uiDialog.resizable('option', 'minHeight', this._minHeight());
  4979. }
  4980. }
  4981. });
  4982. $.extend($.ui.dialog, {
  4983. version: "1.8",
  4984. uuid: 0,
  4985. maxZ: 0,
  4986. getTitleId: function($el) {
  4987. var id = $el.attr('id');
  4988. if (!id) {
  4989. this.uuid += 1;
  4990. id = this.uuid;
  4991. }
  4992. return 'ui-dialog-title-' + id;
  4993. },
  4994. overlay: function(dialog) {
  4995. this.$el = $.ui.dialog.overlay.create(dialog);
  4996. }
  4997. });
  4998. $.extend($.ui.dialog.overlay, {
  4999. instances: [],
  5000. // reuse old instances due to IE memory leak with alpha transparency (see #5185)
  5001. oldInstances: [],
  5002. maxZ: 0,
  5003. events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
  5004. function(event) { return event + '.dialog-overlay'; }).join(' '),
  5005. create: function(dialog) {
  5006. if (this.instances.length === 0) {
  5007. // prevent use of anchors and inputs
  5008. // we use a setTimeout in case the overlay is created from an
  5009. // event that we're going to be cancelling (see #2804)
  5010. setTimeout(function() {
  5011. // handle $(el).dialog().dialog('close') (see #4065)
  5012. if ($.ui.dialog.overlay.instances.length) {
  5013. $(document).bind($.ui.dialog.overlay.events, function(event) {
  5014. // stop events if the z-index of the target is < the z-index of the overlay
  5015. return ($(event.target).zIndex() >= $.ui.dialog.overlay.maxZ);
  5016. });
  5017. }
  5018. }, 1);
  5019. // allow closing by pressing the escape key
  5020. $(document).bind('keydown.dialog-overlay', function(event) {
  5021. if (dialog.options.closeOnEscape && event.keyCode &&
  5022. event.keyCode === $.ui.keyCode.ESCAPE) {
  5023. dialog.close(event);
  5024. event.preventDefault();
  5025. }
  5026. });
  5027. // handle window resize
  5028. $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
  5029. }
  5030. var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
  5031. .appendTo(document.body)
  5032. .css({
  5033. width: this.width(),
  5034. height: this.height()
  5035. });
  5036. if ($.fn.bgiframe) {
  5037. $el.bgiframe();
  5038. }
  5039. this.instances.push($el);
  5040. return $el;
  5041. },
  5042. destroy: function($el) {
  5043. this.oldInstances.push(this.instances.splice($.inArray($el, this.instances), 1)[0]);
  5044. if (this.instances.length === 0) {
  5045. $([document, window]).unbind('.dialog-overlay');
  5046. }
  5047. $el.remove();
  5048. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  5049. var maxZ = 0;
  5050. $.each(this.instances, function() {
  5051. maxZ = Math.max(maxZ, this.css('z-index'));
  5052. });
  5053. this.maxZ = maxZ;
  5054. },
  5055. height: function() {
  5056. var scrollHeight,
  5057. offsetHeight;
  5058. // handle IE 6
  5059. if ($.browser.msie && $.browser.version < 7) {
  5060. scrollHeight = Math.max(
  5061. document.documentElement.scrollHeight,
  5062. document.body.scrollHeight
  5063. );
  5064. offsetHeight = Math.max(
  5065. document.documentElement.offsetHeight,
  5066. document.body.offsetHeight
  5067. );
  5068. if (scrollHeight < offsetHeight) {
  5069. return $(window).height() + 'px';
  5070. } else {
  5071. return scrollHeight + 'px';
  5072. }
  5073. // handle "good" browsers
  5074. } else {
  5075. return $(document).height() + 'px';
  5076. }
  5077. },
  5078. width: function() {
  5079. var scrollWidth,
  5080. offsetWidth;
  5081. // handle IE 6
  5082. if ($.browser.msie && $.browser.version < 7) {
  5083. scrollWidth = Math.max(
  5084. document.documentElement.scrollWidth,
  5085. document.body.scrollWidth
  5086. );
  5087. offsetWidth = Math.max(
  5088. document.documentElement.offsetWidth,
  5089. document.body.offsetWidth
  5090. );
  5091. if (scrollWidth < offsetWidth) {
  5092. return $(window).width() + 'px';
  5093. } else {
  5094. return scrollWidth + 'px';
  5095. }
  5096. // handle "good" browsers
  5097. } else {
  5098. return $(document).width() + 'px';
  5099. }
  5100. },
  5101. resize: function() {
  5102. /* If the dialog is draggable and the user drags it past the
  5103. * right edge of the window, the document becomes wider so we
  5104. * need to stretch the overlay. If the user then drags the
  5105. * dialog back to the left, the document will become narrower,
  5106. * so we need to shrink the overlay to the appropriate size.
  5107. * This is handled by shrinking the overlay before setting it
  5108. * to the full document size.
  5109. */
  5110. var $overlays = $([]);
  5111. $.each($.ui.dialog.overlay.instances, function() {
  5112. $overlays = $overlays.add(this);
  5113. });
  5114. $overlays.css({
  5115. width: 0,
  5116. height: 0
  5117. }).css({
  5118. width: $.ui.dialog.overlay.width(),
  5119. height: $.ui.dialog.overlay.height()
  5120. });
  5121. }
  5122. });
  5123. $.extend($.ui.dialog.overlay.prototype, {
  5124. destroy: function() {
  5125. $.ui.dialog.overlay.destroy(this.$el);
  5126. }
  5127. });
  5128. }(jQuery));
  5129. /*
  5130. * jQuery UI Slider 1.8
  5131. *
  5132. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  5133. * Dual licensed under the MIT (MIT-LICENSE.txt)
  5134. * and GPL (GPL-LICENSE.txt) licenses.
  5135. *
  5136. * http://docs.jquery.com/UI/Slider
  5137. *
  5138. * Depends:
  5139. * jquery.ui.core.js
  5140. * jquery.ui.mouse.js
  5141. * jquery.ui.widget.js
  5142. */
  5143. (function($) {
  5144. // number of pages in a slider
  5145. // (how many times can you page up/down to go through the whole range)
  5146. var numPages = 5;
  5147. $.widget("ui.slider", $.ui.mouse, {
  5148. widgetEventPrefix: "slide",
  5149. options: {
  5150. animate: false,
  5151. distance: 0,
  5152. max: 100,
  5153. min: 0,
  5154. orientation: 'horizontal',
  5155. range: false,
  5156. step: 1,
  5157. value: 0,
  5158. values: null
  5159. },
  5160. _create: function() {
  5161. var self = this, o = this.options;
  5162. this._keySliding = false;
  5163. this._mouseSliding = false;
  5164. this._animateOff = true;
  5165. this._handleIndex = null;
  5166. this._detectOrientation();
  5167. this._mouseInit();
  5168. this.element
  5169. .addClass("ui-slider"
  5170. + " ui-slider-" + this.orientation
  5171. + " ui-widget"
  5172. + " ui-widget-content"
  5173. + " ui-corner-all");
  5174. if (o.disabled) {
  5175. this.element.addClass('ui-slider-disabled ui-disabled');
  5176. }
  5177. this.range = $([]);
  5178. if (o.range) {
  5179. if (o.range === true) {
  5180. this.range = $('<div></div>');
  5181. if (!o.values) o.values = [this._valueMin(), this._valueMin()];
  5182. if (o.values.length && o.values.length != 2) {
  5183. o.values = [o.values[0], o.values[0]];
  5184. }
  5185. } else {
  5186. this.range = $('<div></div>');
  5187. }
  5188. this.range
  5189. .appendTo(this.element)
  5190. .addClass("ui-slider-range");
  5191. if (o.range == "min" || o.range == "max") {
  5192. this.range.addClass("ui-slider-range-" + o.range);
  5193. }
  5194. // note: this isn't the most fittingly semantic framework class for this element,
  5195. // but worked best visually with a variety of themes
  5196. this.range.addClass("ui-widget-header");
  5197. }
  5198. if ($(".ui-slider-handle", this.element).length == 0)
  5199. $('<a href="#"></a>')
  5200. .appendTo(this.element)
  5201. .addClass("ui-slider-handle");
  5202. if (o.values && o.values.length) {
  5203. while ($(".ui-slider-handle", this.element).length < o.values.length)
  5204. $('<a href="#"></a>')
  5205. .appendTo(this.element)
  5206. .addClass("ui-slider-handle");
  5207. }
  5208. this.handles = $(".ui-slider-handle", this.element)
  5209. .addClass("ui-state-default"
  5210. + " ui-corner-all");
  5211. this.handle = this.handles.eq(0);
  5212. this.handles.add(this.range).filter("a")
  5213. .click(function(event) {
  5214. event.preventDefault();
  5215. })
  5216. .hover(function() {
  5217. if (!o.disabled) {
  5218. $(this).addClass('ui-state-hover');
  5219. }
  5220. }, function() {
  5221. $(this).removeClass('ui-state-hover');
  5222. })
  5223. .focus(function() {
  5224. if (!o.disabled) {
  5225. $(".ui-slider .ui-state-focus").removeClass('ui-state-focus'); $(this).addClass('ui-state-focus');
  5226. } else {
  5227. $(this).blur();
  5228. }
  5229. })
  5230. .blur(function() {
  5231. $(this).removeClass('ui-state-focus');
  5232. });
  5233. this.handles.each(function(i) {
  5234. $(this).data("index.ui-slider-handle", i);
  5235. });
  5236. this.handles.keydown(function(event) {
  5237. var ret = true;
  5238. var index = $(this).data("index.ui-slider-handle");
  5239. if (self.options.disabled)
  5240. return;
  5241. switch (event.keyCode) {
  5242. case $.ui.keyCode.HOME:
  5243. case $.ui.keyCode.END:
  5244. case $.ui.keyCode.PAGE_UP:
  5245. case $.ui.keyCode.PAGE_DOWN:
  5246. case $.ui.keyCode.UP:
  5247. case $.ui.keyCode.RIGHT:
  5248. case $.ui.keyCode.DOWN:
  5249. case $.ui.keyCode.LEFT:
  5250. ret = false;
  5251. if (!self._keySliding) {
  5252. self._keySliding = true;
  5253. $(this).addClass("ui-state-active");
  5254. self._start(event, index);
  5255. }
  5256. break;
  5257. }
  5258. var curVal, newVal, step = self._step();
  5259. if (self.options.values && self.options.values.length) {
  5260. curVal = newVal = self.values(index);
  5261. } else {
  5262. curVal = newVal = self.value();
  5263. }
  5264. switch (event.keyCode) {
  5265. case $.ui.keyCode.HOME:
  5266. newVal = self._valueMin();
  5267. break;
  5268. case $.ui.keyCode.END:
  5269. newVal = self._valueMax();
  5270. break;
  5271. case $.ui.keyCode.PAGE_UP:
  5272. newVal = curVal + ((self._valueMax() - self._valueMin()) / numPages);
  5273. break;
  5274. case $.ui.keyCode.PAGE_DOWN:
  5275. newVal = curVal - ((self._valueMax() - self._valueMin()) / numPages);
  5276. break;
  5277. case $.ui.keyCode.UP:
  5278. case $.ui.keyCode.RIGHT:
  5279. if(curVal == self._valueMax()) return;
  5280. newVal = curVal + step;
  5281. break;
  5282. case $.ui.keyCode.DOWN:
  5283. case $.ui.keyCode.LEFT:
  5284. if(curVal == self._valueMin()) return;
  5285. newVal = curVal - step;
  5286. break;
  5287. }
  5288. self._slide(event, index, newVal);
  5289. return ret;
  5290. }).keyup(function(event) {
  5291. var index = $(this).data("index.ui-slider-handle");
  5292. if (self._keySliding) {
  5293. self._keySliding = false;
  5294. self._stop(event, index);
  5295. self._change(event, index);
  5296. $(this).removeClass("ui-state-active");
  5297. }
  5298. });
  5299. this._refreshValue();
  5300. this._animateOff = false;
  5301. },
  5302. destroy: function() {
  5303. this.handles.remove();
  5304. this.range.remove();
  5305. this.element
  5306. .removeClass("ui-slider"
  5307. + " ui-slider-horizontal"
  5308. + " ui-slider-vertical"
  5309. + " ui-slider-disabled"
  5310. + " ui-widget"
  5311. + " ui-widget-content"
  5312. + " ui-corner-all")
  5313. .removeData("slider")
  5314. .unbind(".slider");
  5315. this._mouseDestroy();
  5316. return this;
  5317. },
  5318. _mouseCapture: function(event) {
  5319. var o = this.options;
  5320. if (o.disabled)
  5321. return false;
  5322. this.elementSize = {
  5323. width: this.element.outerWidth(),
  5324. height: this.element.outerHeight()
  5325. };
  5326. this.elementOffset = this.element.offset();
  5327. var position = { x: event.pageX, y: event.pageY };
  5328. var normValue = this._normValueFromMouse(position);
  5329. var distance = this._valueMax() - this._valueMin() + 1, closestHandle;
  5330. var self = this, index;
  5331. this.handles.each(function(i) {
  5332. var thisDistance = Math.abs(normValue - self.values(i));
  5333. if (distance > thisDistance) {
  5334. distance = thisDistance;
  5335. closestHandle = $(this);
  5336. index = i;
  5337. }
  5338. });
  5339. // workaround for bug #3736 (if both handles of a range are at 0,
  5340. // the first is always used as the one with least distance,
  5341. // and moving it is obviously prevented by preventing negative ranges)
  5342. if(o.range == true && this.values(1) == o.min) {
  5343. closestHandle = $(this.handles[++index]);
  5344. }
  5345. this._start(event, index);
  5346. this._mouseSliding = true;
  5347. self._handleIndex = index;
  5348. closestHandle
  5349. .addClass("ui-state-active")
  5350. .focus();
  5351. var offset = closestHandle.offset();
  5352. var mouseOverHandle = !$(event.target).parents().andSelf().is('.ui-slider-handle');
  5353. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  5354. left: event.pageX - offset.left - (closestHandle.width() / 2),
  5355. top: event.pageY - offset.top
  5356. - (closestHandle.height() / 2)
  5357. - (parseInt(closestHandle.css('borderTopWidth'),10) || 0)
  5358. - (parseInt(closestHandle.css('borderBottomWidth'),10) || 0)
  5359. + (parseInt(closestHandle.css('marginTop'),10) || 0)
  5360. };
  5361. normValue = this._normValueFromMouse(position);
  5362. this._slide(event, index, normValue);
  5363. this._animateOff = true;
  5364. return true;
  5365. },
  5366. _mouseStart: function(event) {
  5367. return true;
  5368. },
  5369. _mouseDrag: function(event) {
  5370. var position = { x: event.pageX, y: event.pageY };
  5371. var normValue = this._normValueFromMouse(position);
  5372. this._slide(event, this._handleIndex, normValue);
  5373. return false;
  5374. },
  5375. _mouseStop: function(event) {
  5376. this.handles.removeClass("ui-state-active");
  5377. this._mouseSliding = false;
  5378. this._stop(event, this._handleIndex);
  5379. this._change(event, this._handleIndex);
  5380. this._handleIndex = null;
  5381. this._clickOffset = null;
  5382. this._animateOff = false;
  5383. return false;
  5384. },
  5385. _detectOrientation: function() {
  5386. this.orientation = this.options.orientation == 'vertical' ? 'vertical' : 'horizontal';
  5387. },
  5388. _normValueFromMouse: function(position) {
  5389. var pixelTotal, pixelMouse;
  5390. if ('horizontal' == this.orientation) {
  5391. pixelTotal = this.elementSize.width;
  5392. pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0);
  5393. } else {
  5394. pixelTotal = this.elementSize.height;
  5395. pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0);
  5396. }
  5397. var percentMouse = (pixelMouse / pixelTotal);
  5398. if (percentMouse > 1) percentMouse = 1;
  5399. if (percentMouse < 0) percentMouse = 0;
  5400. if ('vertical' == this.orientation)
  5401. percentMouse = 1 - percentMouse;
  5402. var valueTotal = this._valueMax() - this._valueMin(),
  5403. valueMouse = percentMouse * valueTotal,
  5404. valueMouseModStep = valueMouse % this.options.step,
  5405. normValue = this._valueMin() + valueMouse - valueMouseModStep;
  5406. if (valueMouseModStep > (this.options.step / 2))
  5407. normValue += this.options.step;
  5408. // Since JavaScript has problems with large floats, round
  5409. // the final value to 5 digits after the decimal point (see #4124)
  5410. return parseFloat(normValue.toFixed(5));
  5411. },
  5412. _start: function(event, index) {
  5413. var uiHash = {
  5414. handle: this.handles[index],
  5415. value: this.value()
  5416. };
  5417. if (this.options.values && this.options.values.length) {
  5418. uiHash.value = this.values(index);
  5419. uiHash.values = this.values();
  5420. }
  5421. this._trigger("start", event, uiHash);
  5422. },
  5423. _slide: function(event, index, newVal) {
  5424. var handle = this.handles[index];
  5425. if (this.options.values && this.options.values.length) {
  5426. var otherVal = this.values(index ? 0 : 1);
  5427. if ((this.options.values.length == 2 && this.options.range === true) &&
  5428. ((index == 0 && newVal > otherVal) || (index == 1 && newVal < otherVal))){
  5429. newVal = otherVal;
  5430. }
  5431. if (newVal != this.values(index)) {
  5432. var newValues = this.values();
  5433. newValues[index] = newVal;
  5434. // A slide can be canceled by returning false from the slide callback
  5435. var allowed = this._trigger("slide", event, {
  5436. handle: this.handles[index],
  5437. value: newVal,
  5438. values: newValues
  5439. });
  5440. var otherVal = this.values(index ? 0 : 1);
  5441. if (allowed !== false) {
  5442. this.values(index, newVal, true);
  5443. }
  5444. }
  5445. } else {
  5446. if (newVal != this.value()) {
  5447. // A slide can be canceled by returning false from the slide callback
  5448. var allowed = this._trigger("slide", event, {
  5449. handle: this.handles[index],
  5450. value: newVal
  5451. });
  5452. if (allowed !== false) {
  5453. this.value(newVal);
  5454. }
  5455. }
  5456. }
  5457. },
  5458. _stop: function(event, index) {
  5459. var uiHash = {
  5460. handle: this.handles[index],
  5461. value: this.value()
  5462. };
  5463. if (this.options.values && this.options.values.length) {
  5464. uiHash.value = this.values(index);
  5465. uiHash.values = this.values();
  5466. }
  5467. this._trigger("stop", event, uiHash);
  5468. },
  5469. _change: function(event, index) {
  5470. if (!this._keySliding && !this._mouseSliding) {
  5471. var uiHash = {
  5472. handle: this.handles[index],
  5473. value: this.value()
  5474. };
  5475. if (this.options.values && this.options.values.length) {
  5476. uiHash.value = this.values(index);
  5477. uiHash.values = this.values();
  5478. }
  5479. this._trigger("change", event, uiHash);
  5480. }
  5481. },
  5482. value: function(newValue) {
  5483. if (arguments.length) {
  5484. this.options.value = this._trimValue(newValue);
  5485. this._refreshValue();
  5486. this._change(null, 0);
  5487. }
  5488. return this._value();
  5489. },
  5490. values: function(index, newValue) {
  5491. if (arguments.length > 1) {
  5492. this.options.values[index] = this._trimValue(newValue);
  5493. this._refreshValue();
  5494. this._change(null, index);
  5495. }
  5496. if (arguments.length) {
  5497. if ($.isArray(arguments[0])) {
  5498. var vals = this.options.values, newValues = arguments[0];
  5499. for (var i = 0, l = vals.length; i < l; i++) {
  5500. vals[i] = this._trimValue(newValues[i]);
  5501. this._change(null, i);
  5502. }
  5503. this._refreshValue();
  5504. } else {
  5505. if (this.options.values && this.options.values.length) {
  5506. return this._values(index);
  5507. } else {
  5508. return this.value();
  5509. }
  5510. }
  5511. } else {
  5512. return this._values();
  5513. }
  5514. },
  5515. _setOption: function(key, value) {
  5516. var i,
  5517. valsLength = 0;
  5518. if ( jQuery.isArray(this.options.values) ) {
  5519. valsLength = this.options.values.length;
  5520. };
  5521. $.Widget.prototype._setOption.apply(this, arguments);
  5522. switch (key) {
  5523. case 'disabled':
  5524. if (value) {
  5525. this.handles.filter(".ui-state-focus").blur();
  5526. this.handles.removeClass("ui-state-hover");
  5527. this.handles.attr("disabled", "disabled");
  5528. this.element.addClass("ui-disabled");
  5529. } else {
  5530. this.handles.removeAttr("disabled");
  5531. this.element.removeClass("ui-disabled");
  5532. }
  5533. case 'orientation':
  5534. this._detectOrientation();
  5535. this.element
  5536. .removeClass("ui-slider-horizontal ui-slider-vertical")
  5537. .addClass("ui-slider-" + this.orientation);
  5538. this._refreshValue();
  5539. break;
  5540. case 'value':
  5541. this._animateOff = true;
  5542. this._refreshValue();
  5543. this._change(null, 0);
  5544. this._animateOff = false;
  5545. break;
  5546. case 'values':
  5547. this._animateOff = true;
  5548. this._refreshValue();
  5549. for (i = 0; i < valsLength; i++) {
  5550. this._change(null, i);
  5551. }
  5552. this._animateOff = false;
  5553. break;
  5554. }
  5555. },
  5556. _step: function() {
  5557. var step = this.options.step;
  5558. return step;
  5559. },
  5560. _value: function() {
  5561. //internal value getter
  5562. // _value() returns value trimmed by min and max
  5563. var val = this.options.value;
  5564. val = this._trimValue(val);
  5565. return val;
  5566. },
  5567. _values: function(index) {
  5568. //internal values getter
  5569. // _values() returns array of values trimmed by min and max
  5570. // _values(index) returns single value trimmed by min and max
  5571. if (arguments.length) {
  5572. var val = this.options.values[index];
  5573. val = this._trimValue(val);
  5574. return val;
  5575. } else {
  5576. // .slice() creates a copy of the array
  5577. // this copy gets trimmed by min and max and then returned
  5578. var vals = this.options.values.slice();
  5579. for (var i = 0, l = vals.length; i < l; i++) {
  5580. vals[i] = this._trimValue(vals[i]);
  5581. }
  5582. return vals;
  5583. }
  5584. },
  5585. _trimValue: function(val) {
  5586. if (val < this._valueMin()) val = this._valueMin();
  5587. if (val > this._valueMax()) val = this._valueMax();
  5588. return val;
  5589. },
  5590. _valueMin: function() {
  5591. var valueMin = this.options.min;
  5592. return valueMin;
  5593. },
  5594. _valueMax: function() {
  5595. var valueMax = this.options.max;
  5596. return valueMax;
  5597. },
  5598. _refreshValue: function() {
  5599. var oRange = this.options.range, o = this.options, self = this;
  5600. var animate = (!this._animateOff) ? o.animate : false;
  5601. if (this.options.values && this.options.values.length) {
  5602. var vp0, vp1;
  5603. this.handles.each(function(i, j) {
  5604. var valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100;
  5605. var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';
  5606. $(this).stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);
  5607. if (self.options.range === true) {
  5608. if (self.orientation == 'horizontal') {
  5609. (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ left: valPercent + '%' }, o.animate);
  5610. (i == 1) && self.range[animate ? 'animate' : 'css']({ width: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate });
  5611. } else {
  5612. (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ bottom: (valPercent) + '%' }, o.animate);
  5613. (i == 1) && self.range[animate ? 'animate' : 'css']({ height: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate });
  5614. }
  5615. }
  5616. lastValPercent = valPercent;
  5617. });
  5618. } else {
  5619. var value = this.value(),
  5620. valueMin = this._valueMin(),
  5621. valueMax = this._valueMax(),
  5622. valPercent = valueMax != valueMin
  5623. ? (value - valueMin) / (valueMax - valueMin) * 100
  5624. : 0;
  5625. var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';
  5626. this.handle.stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);
  5627. (oRange == "min") && (this.orientation == "horizontal") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ width: valPercent + '%' }, o.animate);
  5628. (oRange == "max") && (this.orientation == "horizontal") && this.range[animate ? 'animate' : 'css']({ width: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });
  5629. (oRange == "min") && (this.orientation == "vertical") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ height: valPercent + '%' }, o.animate);
  5630. (oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });
  5631. }
  5632. }
  5633. });
  5634. $.extend($.ui.slider, {
  5635. version: "1.8"
  5636. });
  5637. })(jQuery);
  5638. /*
  5639. * jQuery UI Tabs 1.8
  5640. *
  5641. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  5642. * Dual licensed under the MIT (MIT-LICENSE.txt)
  5643. * and GPL (GPL-LICENSE.txt) licenses.
  5644. *
  5645. * http://docs.jquery.com/UI/Tabs
  5646. *
  5647. * Depends:
  5648. * jquery.ui.core.js
  5649. * jquery.ui.widget.js
  5650. */
  5651. (function($) {
  5652. var tabId = 0,
  5653. listId = 0;
  5654. $.widget("ui.tabs", {
  5655. options: {
  5656. add: null,
  5657. ajaxOptions: null,
  5658. cache: false,
  5659. cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
  5660. collapsible: false,
  5661. disable: null,
  5662. disabled: [],
  5663. enable: null,
  5664. event: 'click',
  5665. fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
  5666. idPrefix: 'ui-tabs-',
  5667. load: null,
  5668. panelTemplate: '<div></div>',
  5669. remove: null,
  5670. select: null,
  5671. show: null,
  5672. spinner: '<em>Loading&#8230;</em>',
  5673. tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>'
  5674. },
  5675. _create: function() {
  5676. this._tabify(true);
  5677. },
  5678. _setOption: function(key, value) {
  5679. if (key == 'selected') {
  5680. if (this.options.collapsible && value == this.options.selected) {
  5681. return;
  5682. }
  5683. this.select(value);
  5684. }
  5685. else {
  5686. this.options[key] = value;
  5687. this._tabify();
  5688. }
  5689. },
  5690. _tabId: function(a) {
  5691. return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '') ||
  5692. this.options.idPrefix + (++tabId);
  5693. },
  5694. _sanitizeSelector: function(hash) {
  5695. return hash.replace(/:/g, '\\:'); // we need this because an id may contain a ":"
  5696. },
  5697. _cookie: function() {
  5698. var cookie = this.cookie || (this.cookie = this.options.cookie.name || 'ui-tabs-' + (++listId));
  5699. return $.cookie.apply(null, [cookie].concat($.makeArray(arguments)));
  5700. },
  5701. _ui: function(tab, panel) {
  5702. return {
  5703. tab: tab,
  5704. panel: panel,
  5705. index: this.anchors.index(tab)
  5706. };
  5707. },
  5708. _cleanup: function() {
  5709. // restore all former loading tabs labels
  5710. this.lis.filter('.ui-state-processing').removeClass('ui-state-processing')
  5711. .find('span:data(label.tabs)')
  5712. .each(function() {
  5713. var el = $(this);
  5714. el.html(el.data('label.tabs')).removeData('label.tabs');
  5715. });
  5716. },
  5717. _tabify: function(init) {
  5718. this.list = this.element.find('ol,ul').eq(0);
  5719. this.lis = $('li:has(a[href])', this.list);
  5720. this.anchors = this.lis.map(function() { return $('a', this)[0]; });
  5721. this.panels = $([]);
  5722. var self = this, o = this.options;
  5723. var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
  5724. this.anchors.each(function(i, a) {
  5725. var href = $(a).attr('href');
  5726. // For dynamically created HTML that contains a hash as href IE < 8 expands
  5727. // such href to the full page url with hash and then misinterprets tab as ajax.
  5728. // Same consideration applies for an added tab with a fragment identifier
  5729. // since a[href=#fragment-identifier] does unexpectedly not match.
  5730. // Thus normalize href attribute...
  5731. var hrefBase = href.split('#')[0], baseEl;
  5732. if (hrefBase && (hrefBase === location.toString().split('#')[0] ||
  5733. (baseEl = $('base')[0]) && hrefBase === baseEl.href)) {
  5734. href = a.hash;
  5735. a.href = href;
  5736. }
  5737. // inline tab
  5738. if (fragmentId.test(href)) {
  5739. self.panels = self.panels.add(self._sanitizeSelector(href));
  5740. }
  5741. // remote tab
  5742. else if (href != '#') { // prevent loading the page itself if href is just "#"
  5743. $.data(a, 'href.tabs', href); // required for restore on destroy
  5744. // TODO until #3808 is fixed strip fragment identifier from url
  5745. // (IE fails to load from such url)
  5746. $.data(a, 'load.tabs', href.replace(/#.*$/, '')); // mutable data
  5747. var id = self._tabId(a);
  5748. a.href = '#' + id;
  5749. var $panel = $('#' + id);
  5750. if (!$panel.length) {
  5751. $panel = $(o.panelTemplate).attr('id', id).addClass('ui-tabs-panel ui-widget-content ui-corner-bottom')
  5752. .insertAfter(self.panels[i - 1] || self.list);
  5753. $panel.data('destroy.tabs', true);
  5754. }
  5755. self.panels = self.panels.add($panel);
  5756. }
  5757. // invalid tab href
  5758. else {
  5759. o.disabled.push(i);
  5760. }
  5761. });
  5762. // initialization from scratch
  5763. if (init) {
  5764. // attach necessary classes for styling
  5765. this.element.addClass('ui-tabs ui-widget ui-widget-content ui-corner-all');
  5766. this.list.addClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all');
  5767. this.lis.addClass('ui-state-default ui-corner-top');
  5768. this.panels.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom');
  5769. // Selected tab
  5770. // use "selected" option or try to retrieve:
  5771. // 1. from fragment identifier in url
  5772. // 2. from cookie
  5773. // 3. from selected class attribute on <li>
  5774. if (o.selected === undefined) {
  5775. if (location.hash) {
  5776. this.anchors.each(function(i, a) {
  5777. if (a.hash == location.hash) {
  5778. o.selected = i;
  5779. return false; // break
  5780. }
  5781. });
  5782. }
  5783. if (typeof o.selected != 'number' && o.cookie) {
  5784. o.selected = parseInt(self._cookie(), 10);
  5785. }
  5786. if (typeof o.selected != 'number' && this.lis.filter('.ui-tabs-selected').length) {
  5787. o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected'));
  5788. }
  5789. o.selected = o.selected || (this.lis.length ? 0 : -1);
  5790. }
  5791. else if (o.selected === null) { // usage of null is deprecated, TODO remove in next release
  5792. o.selected = -1;
  5793. }
  5794. // sanity check - default to first tab...
  5795. o.selected = ((o.selected >= 0 && this.anchors[o.selected]) || o.selected < 0) ? o.selected : 0;
  5796. // Take disabling tabs via class attribute from HTML
  5797. // into account and update option properly.
  5798. // A selected tab cannot become disabled.
  5799. o.disabled = $.unique(o.disabled.concat(
  5800. $.map(this.lis.filter('.ui-state-disabled'),
  5801. function(n, i) { return self.lis.index(n); } )
  5802. )).sort();
  5803. if ($.inArray(o.selected, o.disabled) != -1) {
  5804. o.disabled.splice($.inArray(o.selected, o.disabled), 1);
  5805. }
  5806. // highlight selected tab
  5807. this.panels.addClass('ui-tabs-hide');
  5808. this.lis.removeClass('ui-tabs-selected ui-state-active');
  5809. if (o.selected >= 0 && this.anchors.length) { // check for length avoids error when initializing empty list
  5810. this.panels.eq(o.selected).removeClass('ui-tabs-hide');
  5811. this.lis.eq(o.selected).addClass('ui-tabs-selected ui-state-active');
  5812. // seems to be expected behavior that the show callback is fired
  5813. self.element.queue("tabs", function() {
  5814. self._trigger('show', null, self._ui(self.anchors[o.selected], self.panels[o.selected]));
  5815. });
  5816. this.load(o.selected);
  5817. }
  5818. // clean up to avoid memory leaks in certain versions of IE 6
  5819. $(window).bind('unload', function() {
  5820. self.lis.add(self.anchors).unbind('.tabs');
  5821. self.lis = self.anchors = self.panels = null;
  5822. });
  5823. }
  5824. // update selected after add/remove
  5825. else {
  5826. o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected'));
  5827. }
  5828. // update collapsible
  5829. this.element[o.collapsible ? 'addClass' : 'removeClass']('ui-tabs-collapsible');
  5830. // set or update cookie after init and add/remove respectively
  5831. if (o.cookie) {
  5832. this._cookie(o.selected, o.cookie);
  5833. }
  5834. // disable tabs
  5835. for (var i = 0, li; (li = this.lis[i]); i++) {
  5836. $(li)[$.inArray(i, o.disabled) != -1 &&
  5837. !$(li).hasClass('ui-tabs-selected') ? 'addClass' : 'removeClass']('ui-state-disabled');
  5838. }
  5839. // reset cache if switching from cached to not cached
  5840. if (o.cache === false) {
  5841. this.anchors.removeData('cache.tabs');
  5842. }
  5843. // remove all handlers before, tabify may run on existing tabs after add or option change
  5844. this.lis.add(this.anchors).unbind('.tabs');
  5845. if (o.event != 'mouseover') {
  5846. var addState = function(state, el) {
  5847. if (el.is(':not(.ui-state-disabled)')) {
  5848. el.addClass('ui-state-' + state);
  5849. }
  5850. };
  5851. var removeState = function(state, el) {
  5852. el.removeClass('ui-state-' + state);
  5853. };
  5854. this.lis.bind('mouseover.tabs', function() {
  5855. addState('hover', $(this));
  5856. });
  5857. this.lis.bind('mouseout.tabs', function() {
  5858. removeState('hover', $(this));
  5859. });
  5860. this.anchors.bind('focus.tabs', function() {
  5861. addState('focus', $(this).closest('li'));
  5862. });
  5863. this.anchors.bind('blur.tabs', function() {
  5864. removeState('focus', $(this).closest('li'));
  5865. });
  5866. }
  5867. // set up animations
  5868. var hideFx, showFx;
  5869. if (o.fx) {
  5870. if ($.isArray(o.fx)) {
  5871. hideFx = o.fx[0];
  5872. showFx = o.fx[1];
  5873. }
  5874. else {
  5875. hideFx = showFx = o.fx;
  5876. }
  5877. }
  5878. // Reset certain styles left over from animation
  5879. // and prevent IE's ClearType bug...
  5880. function resetStyle($el, fx) {
  5881. $el.css({ display: '' });
  5882. if (!$.support.opacity && fx.opacity) {
  5883. $el[0].style.removeAttribute('filter');
  5884. }
  5885. }
  5886. // Show a tab...
  5887. var showTab = showFx ?
  5888. function(clicked, $show) {
  5889. $(clicked).closest('li').addClass('ui-tabs-selected ui-state-active');
  5890. $show.hide().removeClass('ui-tabs-hide') // avoid flicker that way
  5891. .animate(showFx, showFx.duration || 'normal', function() {
  5892. resetStyle($show, showFx);
  5893. self._trigger('show', null, self._ui(clicked, $show[0]));
  5894. });
  5895. } :
  5896. function(clicked, $show) {
  5897. $(clicked).closest('li').addClass('ui-tabs-selected ui-state-active');
  5898. $show.removeClass('ui-tabs-hide');
  5899. self._trigger('show', null, self._ui(clicked, $show[0]));
  5900. };
  5901. // Hide a tab, $show is optional...
  5902. var hideTab = hideFx ?
  5903. function(clicked, $hide) {
  5904. $hide.animate(hideFx, hideFx.duration || 'normal', function() {
  5905. self.lis.removeClass('ui-tabs-selected ui-state-active');
  5906. $hide.addClass('ui-tabs-hide');
  5907. resetStyle($hide, hideFx);
  5908. self.element.dequeue("tabs");
  5909. });
  5910. } :
  5911. function(clicked, $hide, $show) {
  5912. self.lis.removeClass('ui-tabs-selected ui-state-active');
  5913. $hide.addClass('ui-tabs-hide');
  5914. self.element.dequeue("tabs");
  5915. };
  5916. // attach tab event handler, unbind to avoid duplicates from former tabifying...
  5917. this.anchors.bind(o.event + '.tabs', function() {
  5918. var el = this, $li = $(this).closest('li'), $hide = self.panels.filter(':not(.ui-tabs-hide)'),
  5919. $show = $(self._sanitizeSelector(this.hash));
  5920. // If tab is already selected and not collapsible or tab disabled or
  5921. // or is already loading or click callback returns false stop here.
  5922. // Check if click handler returns false last so that it is not executed
  5923. // for a disabled or loading tab!
  5924. if (($li.hasClass('ui-tabs-selected') && !o.collapsible) ||
  5925. $li.hasClass('ui-state-disabled') ||
  5926. $li.hasClass('ui-state-processing') ||
  5927. self._trigger('select', null, self._ui(this, $show[0])) === false) {
  5928. this.blur();
  5929. return false;
  5930. }
  5931. o.selected = self.anchors.index(this);
  5932. self.abort();
  5933. // if tab may be closed
  5934. if (o.collapsible) {
  5935. if ($li.hasClass('ui-tabs-selected')) {
  5936. o.selected = -1;
  5937. if (o.cookie) {
  5938. self._cookie(o.selected, o.cookie);
  5939. }
  5940. self.element.queue("tabs", function() {
  5941. hideTab(el, $hide);
  5942. }).dequeue("tabs");
  5943. this.blur();
  5944. return false;
  5945. }
  5946. else if (!$hide.length) {
  5947. if (o.cookie) {
  5948. self._cookie(o.selected, o.cookie);
  5949. }
  5950. self.element.queue("tabs", function() {
  5951. showTab(el, $show);
  5952. });
  5953. self.load(self.anchors.index(this)); // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
  5954. this.blur();
  5955. return false;
  5956. }
  5957. }
  5958. if (o.cookie) {
  5959. self._cookie(o.selected, o.cookie);
  5960. }
  5961. // show new tab
  5962. if ($show.length) {
  5963. if ($hide.length) {
  5964. self.element.queue("tabs", function() {
  5965. hideTab(el, $hide);
  5966. });
  5967. }
  5968. self.element.queue("tabs", function() {
  5969. showTab(el, $show);
  5970. });
  5971. self.load(self.anchors.index(this));
  5972. }
  5973. else {
  5974. throw 'jQuery UI Tabs: Mismatching fragment identifier.';
  5975. }
  5976. // Prevent IE from keeping other link focussed when using the back button
  5977. // and remove dotted border from clicked link. This is controlled via CSS
  5978. // in modern browsers; blur() removes focus from address bar in Firefox
  5979. // which can become a usability and annoying problem with tabs('rotate').
  5980. if ($.browser.msie) {
  5981. this.blur();
  5982. }
  5983. });
  5984. // disable click in any case
  5985. this.anchors.bind('click.tabs', function(){return false;});
  5986. },
  5987. destroy: function() {
  5988. var o = this.options;
  5989. this.abort();
  5990. this.element.unbind('.tabs')
  5991. .removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible')
  5992. .removeData('tabs');
  5993. this.list.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all');
  5994. this.anchors.each(function() {
  5995. var href = $.data(this, 'href.tabs');
  5996. if (href) {
  5997. this.href = href;
  5998. }
  5999. var $this = $(this).unbind('.tabs');
  6000. $.each(['href', 'load', 'cache'], function(i, prefix) {
  6001. $this.removeData(prefix + '.tabs');
  6002. });
  6003. });
  6004. this.lis.unbind('.tabs').add(this.panels).each(function() {
  6005. if ($.data(this, 'destroy.tabs')) {
  6006. $(this).remove();
  6007. }
  6008. else {
  6009. $(this).removeClass([
  6010. 'ui-state-default',
  6011. 'ui-corner-top',
  6012. 'ui-tabs-selected',
  6013. 'ui-state-active',
  6014. 'ui-state-hover',
  6015. 'ui-state-focus',
  6016. 'ui-state-disabled',
  6017. 'ui-tabs-panel',
  6018. 'ui-widget-content',
  6019. 'ui-corner-bottom',
  6020. 'ui-tabs-hide'
  6021. ].join(' '));
  6022. }
  6023. });
  6024. if (o.cookie) {
  6025. this._cookie(null, o.cookie);
  6026. }
  6027. return this;
  6028. },
  6029. add: function(url, label, index) {
  6030. if (index === undefined) {
  6031. index = this.anchors.length; // append by default
  6032. }
  6033. var self = this, o = this.options,
  6034. $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label)),
  6035. id = !url.indexOf('#') ? url.replace('#', '') : this._tabId($('a', $li)[0]);
  6036. $li.addClass('ui-state-default ui-corner-top').data('destroy.tabs', true);
  6037. // try to find an existing element before creating a new one
  6038. var $panel = $('#' + id);
  6039. if (!$panel.length) {
  6040. $panel = $(o.panelTemplate).attr('id', id).data('destroy.tabs', true);
  6041. }
  6042. $panel.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide');
  6043. if (index >= this.lis.length) {
  6044. $li.appendTo(this.list);
  6045. $panel.appendTo(this.list[0].parentNode);
  6046. }
  6047. else {
  6048. $li.insertBefore(this.lis[index]);
  6049. $panel.insertBefore(this.panels[index]);
  6050. }
  6051. o.disabled = $.map(o.disabled,
  6052. function(n, i) { return n >= index ? ++n : n; });
  6053. this._tabify();
  6054. if (this.anchors.length == 1) { // after tabify
  6055. o.selected = 0;
  6056. $li.addClass('ui-tabs-selected ui-state-active');
  6057. $panel.removeClass('ui-tabs-hide');
  6058. this.element.queue("tabs", function() {
  6059. self._trigger('show', null, self._ui(self.anchors[0], self.panels[0]));
  6060. });
  6061. this.load(0);
  6062. }
  6063. // callback
  6064. this._trigger('add', null, this._ui(this.anchors[index], this.panels[index]));
  6065. return this;
  6066. },
  6067. remove: function(index) {
  6068. var o = this.options, $li = this.lis.eq(index).remove(),
  6069. $panel = this.panels.eq(index).remove();
  6070. // If selected tab was removed focus tab to the right or
  6071. // in case the last tab was removed the tab to the left.
  6072. if ($li.hasClass('ui-tabs-selected') && this.anchors.length > 1) {
  6073. this.select(index + (index + 1 < this.anchors.length ? 1 : -1));
  6074. }
  6075. o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }),
  6076. function(n, i) { return n >= index ? --n : n; });
  6077. this._tabify();
  6078. // callback
  6079. this._trigger('remove', null, this._ui($li.find('a')[0], $panel[0]));
  6080. return this;
  6081. },
  6082. enable: function(index) {
  6083. var o = this.options;
  6084. if ($.inArray(index, o.disabled) == -1) {
  6085. return;
  6086. }
  6087. this.lis.eq(index).removeClass('ui-state-disabled');
  6088. o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });
  6089. // callback
  6090. this._trigger('enable', null, this._ui(this.anchors[index], this.panels[index]));
  6091. return this;
  6092. },
  6093. disable: function(index) {
  6094. var self = this, o = this.options;
  6095. if (index != o.selected) { // cannot disable already selected tab
  6096. this.lis.eq(index).addClass('ui-state-disabled');
  6097. o.disabled.push(index);
  6098. o.disabled.sort();
  6099. // callback
  6100. this._trigger('disable', null, this._ui(this.anchors[index], this.panels[index]));
  6101. }
  6102. return this;
  6103. },
  6104. select: function(index) {
  6105. if (typeof index == 'string') {
  6106. index = this.anchors.index(this.anchors.filter('[href$=' + index + ']'));
  6107. }
  6108. else if (index === null) { // usage of null is deprecated, TODO remove in next release
  6109. index = -1;
  6110. }
  6111. if (index == -1 && this.options.collapsible) {
  6112. index = this.options.selected;
  6113. }
  6114. this.anchors.eq(index).trigger(this.options.event + '.tabs');
  6115. return this;
  6116. },
  6117. load: function(index) {
  6118. var self = this, o = this.options, a = this.anchors.eq(index)[0], url = $.data(a, 'load.tabs');
  6119. this.abort();
  6120. // not remote or from cache
  6121. if (!url || this.element.queue("tabs").length !== 0 && $.data(a, 'cache.tabs')) {
  6122. this.element.dequeue("tabs");
  6123. return;
  6124. }
  6125. // load remote from here on
  6126. this.lis.eq(index).addClass('ui-state-processing');
  6127. if (o.spinner) {
  6128. var span = $('span', a);
  6129. span.data('label.tabs', span.html()).html(o.spinner);
  6130. }
  6131. this.xhr = $.ajax($.extend({}, o.ajaxOptions, {
  6132. url: url,
  6133. success: function(r, s) {
  6134. $(self._sanitizeSelector(a.hash)).html(r);
  6135. // take care of tab labels
  6136. self._cleanup();
  6137. if (o.cache) {
  6138. $.data(a, 'cache.tabs', true); // if loaded once do not load them again
  6139. }
  6140. // callbacks
  6141. self._trigger('load', null, self._ui(self.anchors[index], self.panels[index]));
  6142. try {
  6143. o.ajaxOptions.success(r, s);
  6144. }
  6145. catch (e) {}
  6146. },
  6147. error: function(xhr, s, e) {
  6148. // take care of tab labels
  6149. self._cleanup();
  6150. // callbacks
  6151. self._trigger('load', null, self._ui(self.anchors[index], self.panels[index]));
  6152. try {
  6153. // Passing index avoid a race condition when this method is
  6154. // called after the user has selected another tab.
  6155. // Pass the anchor that initiated this request allows
  6156. // loadError to manipulate the tab content panel via $(a.hash)
  6157. o.ajaxOptions.error(xhr, s, index, a);
  6158. }
  6159. catch (e) {}
  6160. }
  6161. }));
  6162. // last, so that load event is fired before show...
  6163. self.element.dequeue("tabs");
  6164. return this;
  6165. },
  6166. abort: function() {
  6167. // stop possibly running animations
  6168. this.element.queue([]);
  6169. this.panels.stop(false, true);
  6170. // "tabs" queue must not contain more than two elements,
  6171. // which are the callbacks for the latest clicked tab...
  6172. this.element.queue("tabs", this.element.queue("tabs").splice(-2, 2));
  6173. // terminate pending requests from other tabs
  6174. if (this.xhr) {
  6175. this.xhr.abort();
  6176. delete this.xhr;
  6177. }
  6178. // take care of tab labels
  6179. this._cleanup();
  6180. return this;
  6181. },
  6182. url: function(index, url) {
  6183. this.anchors.eq(index).removeData('cache.tabs').data('load.tabs', url);
  6184. return this;
  6185. },
  6186. length: function() {
  6187. return this.anchors.length;
  6188. }
  6189. });
  6190. $.extend($.ui.tabs, {
  6191. version: '1.8'
  6192. });
  6193. /*
  6194. * Tabs Extensions
  6195. */
  6196. /*
  6197. * Rotate
  6198. */
  6199. $.extend($.ui.tabs.prototype, {
  6200. rotation: null,
  6201. rotate: function(ms, continuing) {
  6202. var self = this, o = this.options;
  6203. var rotate = self._rotate || (self._rotate = function(e) {
  6204. clearTimeout(self.rotation);
  6205. self.rotation = setTimeout(function() {
  6206. var t = o.selected;
  6207. self.select( ++t < self.anchors.length ? t : 0 );
  6208. }, ms);
  6209. if (e) {
  6210. e.stopPropagation();
  6211. }
  6212. });
  6213. var stop = self._unrotate || (self._unrotate = !continuing ?
  6214. function(e) {
  6215. if (e.clientX) { // in case of a true click
  6216. self.rotate(null);
  6217. }
  6218. } :
  6219. function(e) {
  6220. t = o.selected;
  6221. rotate();
  6222. });
  6223. // start rotation
  6224. if (ms) {
  6225. this.element.bind('tabsshow', rotate);
  6226. this.anchors.bind(o.event + '.tabs', stop);
  6227. rotate();
  6228. }
  6229. // stop rotation
  6230. else {
  6231. clearTimeout(self.rotation);
  6232. this.element.unbind('tabsshow', rotate);
  6233. this.anchors.unbind(o.event + '.tabs', stop);
  6234. delete this._rotate;
  6235. delete this._unrotate;
  6236. }
  6237. return this;
  6238. }
  6239. });
  6240. })(jQuery);
  6241. /*
  6242. * jQuery UI Datepicker 1.8
  6243. *
  6244. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  6245. * Dual licensed under the MIT (MIT-LICENSE.txt)
  6246. * and GPL (GPL-LICENSE.txt) licenses.
  6247. *
  6248. * http://docs.jquery.com/UI/Datepicker
  6249. *
  6250. * Depends:
  6251. * jquery.ui.core.js
  6252. */
  6253. (function($) { // hide the namespace
  6254. $.extend($.ui, { datepicker: { version: "1.8" } });
  6255. var PROP_NAME = 'datepicker';
  6256. var dpuuid = new Date().getTime();
  6257. /* Date picker manager.
  6258. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6259. Settings for (groups of) date pickers are maintained in an instance object,
  6260. allowing multiple different settings on the same page. */
  6261. function Datepicker() {
  6262. this.debug = false; // Change this to true to start debugging
  6263. this._curInst = null; // The current instance in use
  6264. this._keyEvent = false; // If the last event was a key event
  6265. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6266. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6267. this._inDialog = false; // True if showing within a "dialog", false if not
  6268. this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
  6269. this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
  6270. this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
  6271. this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
  6272. this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
  6273. this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
  6274. this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
  6275. this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
  6276. this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
  6277. this.regional = []; // Available regional settings, indexed by language code
  6278. this.regional[''] = { // Default regional settings
  6279. closeText: 'Done', // Display text for close link
  6280. prevText: 'Prev', // Display text for previous month link
  6281. nextText: 'Next', // Display text for next month link
  6282. currentText: 'Today', // Display text for current month link
  6283. monthNames: ['January','February','March','April','May','June',
  6284. 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
  6285. monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
  6286. dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
  6287. dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
  6288. dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
  6289. weekHeader: 'Wk', // Column header for week of the year
  6290. dateFormat: 'mm/dd/yy', // See format options on parseDate
  6291. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6292. isRTL: false, // True if right-to-left language, false if left-to-right
  6293. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6294. yearSuffix: '' // Additional text to append to the year in the month headers
  6295. };
  6296. this._defaults = { // Global defaults for all the date picker instances
  6297. showOn: 'focus', // 'focus' for popup on focus,
  6298. // 'button' for trigger button, or 'both' for either
  6299. showAnim: 'show', // Name of jQuery animation for popup
  6300. showOptions: {}, // Options for enhanced animations
  6301. defaultDate: null, // Used when field is blank: actual date,
  6302. // +/-number for offset from today, null for today
  6303. appendText: '', // Display text following the input box, e.g. showing the format
  6304. buttonText: '...', // Text for trigger button
  6305. buttonImage: '', // URL for trigger button image
  6306. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6307. hideIfNoPrevNext: false, // True to hide next/previous month links
  6308. // if not applicable, false to just disable them
  6309. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6310. gotoCurrent: false, // True if today link goes back to current selection instead
  6311. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6312. changeYear: false, // True if year can be selected directly, false if only prev/next
  6313. yearRange: 'c-10:c+10', // Range of years to display in drop-down,
  6314. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6315. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6316. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6317. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6318. showWeek: false, // True to show week of the year, false to not show it
  6319. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6320. // takes a Date and returns the number of the week for it
  6321. shortYearCutoff: '+10', // Short year values < this are in the current century,
  6322. // > this are in the previous century,
  6323. // string value starting with '+' for current year + value
  6324. minDate: null, // The earliest selectable date, or null for no limit
  6325. maxDate: null, // The latest selectable date, or null for no limit
  6326. duration: '_default', // Duration of display/closure
  6327. beforeShowDay: null, // Function that takes a date and returns an array with
  6328. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
  6329. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6330. beforeShow: null, // Function that takes an input field and
  6331. // returns a set of custom settings for the date picker
  6332. onSelect: null, // Define a callback function when a date is selected
  6333. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6334. onClose: null, // Define a callback function when the datepicker is closed
  6335. numberOfMonths: 1, // Number of months to show at a time
  6336. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6337. stepMonths: 1, // Number of months to step back/forward
  6338. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6339. altField: '', // Selector for an alternate field to store selected dates into
  6340. altFormat: '', // The date format to use for the alternate field
  6341. constrainInput: true, // The input is constrained by the current date format
  6342. showButtonPanel: false, // True to show button panel, false to not show it
  6343. autoSize: false // True to size the input for the date format, false to leave as is
  6344. };
  6345. $.extend(this._defaults, this.regional['']);
  6346. this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>');
  6347. }
  6348. $.extend(Datepicker.prototype, {
  6349. /* Class name added to elements to indicate already configured with a date picker. */
  6350. markerClassName: 'hasDatepicker',
  6351. /* Debug logging (if enabled). */
  6352. log: function () {
  6353. if (this.debug)
  6354. console.log.apply('', arguments);
  6355. },
  6356. // TODO rename to "widget" when switching to widget factory
  6357. _widgetDatepicker: function() {
  6358. return this.dpDiv;
  6359. },
  6360. /* Override the default settings for all instances of the date picker.
  6361. @param settings object - the new settings to use as defaults (anonymous object)
  6362. @return the manager object */
  6363. setDefaults: function(settings) {
  6364. extendRemove(this._defaults, settings || {});
  6365. return this;
  6366. },
  6367. /* Attach the date picker to a jQuery selection.
  6368. @param target element - the target input field or division or span
  6369. @param settings object - the new settings to use for this date picker instance (anonymous) */
  6370. _attachDatepicker: function(target, settings) {
  6371. // check for settings on the control itself - in namespace 'date:'
  6372. var inlineSettings = null;
  6373. for (var attrName in this._defaults) {
  6374. var attrValue = target.getAttribute('date:' + attrName);
  6375. if (attrValue) {
  6376. inlineSettings = inlineSettings || {};
  6377. try {
  6378. inlineSettings[attrName] = eval(attrValue);
  6379. } catch (err) {
  6380. inlineSettings[attrName] = attrValue;
  6381. }
  6382. }
  6383. }
  6384. var nodeName = target.nodeName.toLowerCase();
  6385. var inline = (nodeName == 'div' || nodeName == 'span');
  6386. if (!target.id)
  6387. target.id = 'dp' + (++this.uuid);
  6388. var inst = this._newInst($(target), inline);
  6389. inst.settings = $.extend({}, settings || {}, inlineSettings || {});
  6390. if (nodeName == 'input') {
  6391. this._connectDatepicker(target, inst);
  6392. } else if (inline) {
  6393. this._inlineDatepicker(target, inst);
  6394. }
  6395. },
  6396. /* Create a new instance object. */
  6397. _newInst: function(target, inline) {
  6398. var id = target[0].id.replace(/([^A-Za-z0-9_])/g, '\\\\$1'); // escape jQuery meta chars
  6399. return {id: id, input: target, // associated target
  6400. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6401. drawMonth: 0, drawYear: 0, // month being drawn
  6402. inline: inline, // is datepicker inline or not
  6403. dpDiv: (!inline ? this.dpDiv : // presentation div
  6404. $('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};
  6405. },
  6406. /* Attach the date picker to an input field. */
  6407. _connectDatepicker: function(target, inst) {
  6408. var input = $(target);
  6409. inst.append = $([]);
  6410. inst.trigger = $([]);
  6411. if (input.hasClass(this.markerClassName))
  6412. return;
  6413. this._attachments(input, inst);
  6414. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6415. keypress(this._doKeyPress).keyup(this._doKeyUp).
  6416. bind("setData.datepicker", function(event, key, value) {
  6417. inst.settings[key] = value;
  6418. }).bind("getData.datepicker", function(event, key) {
  6419. return this._get(inst, key);
  6420. });
  6421. this._autoSize(inst);
  6422. $.data(target, PROP_NAME, inst);
  6423. },
  6424. /* Make attachments based on settings. */
  6425. _attachments: function(input, inst) {
  6426. var appendText = this._get(inst, 'appendText');
  6427. var isRTL = this._get(inst, 'isRTL');
  6428. if (inst.append)
  6429. inst.append.remove();
  6430. if (appendText) {
  6431. inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
  6432. input[isRTL ? 'before' : 'after'](inst.append);
  6433. }
  6434. input.unbind('focus', this._showDatepicker);
  6435. if (inst.trigger)
  6436. inst.trigger.remove();
  6437. var showOn = this._get(inst, 'showOn');
  6438. if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
  6439. input.focus(this._showDatepicker);
  6440. if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
  6441. var buttonText = this._get(inst, 'buttonText');
  6442. var buttonImage = this._get(inst, 'buttonImage');
  6443. inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
  6444. $('<img/>').addClass(this._triggerClass).
  6445. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6446. $('<button type="button"></button>').addClass(this._triggerClass).
  6447. html(buttonImage == '' ? buttonText : $('<img/>').attr(
  6448. { src:buttonImage, alt:buttonText, title:buttonText })));
  6449. input[isRTL ? 'before' : 'after'](inst.trigger);
  6450. inst.trigger.click(function() {
  6451. if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
  6452. $.datepicker._hideDatepicker();
  6453. else
  6454. $.datepicker._showDatepicker(input[0]);
  6455. return false;
  6456. });
  6457. }
  6458. },
  6459. /* Apply the maximum length for the date format. */
  6460. _autoSize: function(inst) {
  6461. if (this._get(inst, 'autoSize') && !inst.inline) {
  6462. var date = new Date(2009, 12 - 1, 20); // Ensure double digits
  6463. var dateFormat = this._get(inst, 'dateFormat');
  6464. if (dateFormat.match(/[DM]/)) {
  6465. var findMax = function(names) {
  6466. var max = 0;
  6467. var maxI = 0;
  6468. for (var i = 0; i < names.length; i++) {
  6469. if (names[i].length > max) {
  6470. max = names[i].length;
  6471. maxI = i;
  6472. }
  6473. }
  6474. return maxI;
  6475. };
  6476. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6477. 'monthNames' : 'monthNamesShort'))));
  6478. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6479. 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
  6480. }
  6481. inst.input.attr('size', this._formatDate(inst, date).length);
  6482. }
  6483. },
  6484. /* Attach an inline date picker to a div. */
  6485. _inlineDatepicker: function(target, inst) {
  6486. var divSpan = $(target);
  6487. if (divSpan.hasClass(this.markerClassName))
  6488. return;
  6489. divSpan.addClass(this.markerClassName).append(inst.dpDiv).
  6490. bind("setData.datepicker", function(event, key, value){
  6491. inst.settings[key] = value;
  6492. }).bind("getData.datepicker", function(event, key){
  6493. return this._get(inst, key);
  6494. });
  6495. $.data(target, PROP_NAME, inst);
  6496. this._setDate(inst, this._getDefaultDate(inst), true);
  6497. this._updateDatepicker(inst);
  6498. this._updateAlternate(inst);
  6499. },
  6500. /* Pop-up the date picker in a "dialog" box.
  6501. @param input element - ignored
  6502. @param date string or Date - the initial date to display
  6503. @param onSelect function - the function to call when a date is selected
  6504. @param settings object - update the dialog date picker instance's settings (anonymous object)
  6505. @param pos int[2] - coordinates for the dialog's position within the screen or
  6506. event - with x/y coordinates or
  6507. leave empty for default (screen centre)
  6508. @return the manager object */
  6509. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6510. var inst = this._dialogInst; // internal instance
  6511. if (!inst) {
  6512. var id = 'dp' + (++this.uuid);
  6513. this._dialogInput = $('<input type="text" id="' + id +
  6514. '" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
  6515. this._dialogInput.keydown(this._doKeyDown);
  6516. $('body').append(this._dialogInput);
  6517. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6518. inst.settings = {};
  6519. $.data(this._dialogInput[0], PROP_NAME, inst);
  6520. }
  6521. extendRemove(inst.settings, settings || {});
  6522. date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
  6523. this._dialogInput.val(date);
  6524. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6525. if (!this._pos) {
  6526. var browserWidth = document.documentElement.clientWidth;
  6527. var browserHeight = document.documentElement.clientHeight;
  6528. var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6529. var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6530. this._pos = // should use actual width/height below
  6531. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6532. }
  6533. // move input on screen for focus, but hidden behind dialog
  6534. this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
  6535. inst.settings.onSelect = onSelect;
  6536. this._inDialog = true;
  6537. this.dpDiv.addClass(this._dialogClass);
  6538. this._showDatepicker(this._dialogInput[0]);
  6539. if ($.blockUI)
  6540. $.blockUI(this.dpDiv);
  6541. $.data(this._dialogInput[0], PROP_NAME, inst);
  6542. return this;
  6543. },
  6544. /* Detach a datepicker from its control.
  6545. @param target element - the target input field or division or span */
  6546. _destroyDatepicker: function(target) {
  6547. var $target = $(target);
  6548. var inst = $.data(target, PROP_NAME);
  6549. if (!$target.hasClass(this.markerClassName)) {
  6550. return;
  6551. }
  6552. var nodeName = target.nodeName.toLowerCase();
  6553. $.removeData(target, PROP_NAME);
  6554. if (nodeName == 'input') {
  6555. inst.append.remove();
  6556. inst.trigger.remove();
  6557. $target.removeClass(this.markerClassName).
  6558. unbind('focus', this._showDatepicker).
  6559. unbind('keydown', this._doKeyDown).
  6560. unbind('keypress', this._doKeyPress).
  6561. unbind('keyup', this._doKeyUp);
  6562. } else if (nodeName == 'div' || nodeName == 'span')
  6563. $target.removeClass(this.markerClassName).empty();
  6564. },
  6565. /* Enable the date picker to a jQuery selection.
  6566. @param target element - the target input field or division or span */
  6567. _enableDatepicker: function(target) {
  6568. var $target = $(target);
  6569. var inst = $.data(target, PROP_NAME);
  6570. if (!$target.hasClass(this.markerClassName)) {
  6571. return;
  6572. }
  6573. var nodeName = target.nodeName.toLowerCase();
  6574. if (nodeName == 'input') {
  6575. target.disabled = false;
  6576. inst.trigger.filter('button').
  6577. each(function() { this.disabled = false; }).end().
  6578. filter('img').css({opacity: '1.0', cursor: ''});
  6579. }
  6580. else if (nodeName == 'div' || nodeName == 'span') {
  6581. var inline = $target.children('.' + this._inlineClass);
  6582. inline.children().removeClass('ui-state-disabled');
  6583. }
  6584. this._disabledInputs = $.map(this._disabledInputs,
  6585. function(value) { return (value == target ? null : value); }); // delete entry
  6586. },
  6587. /* Disable the date picker to a jQuery selection.
  6588. @param target element - the target input field or division or span */
  6589. _disableDatepicker: function(target) {
  6590. var $target = $(target);
  6591. var inst = $.data(target, PROP_NAME);
  6592. if (!$target.hasClass(this.markerClassName)) {
  6593. return;
  6594. }
  6595. var nodeName = target.nodeName.toLowerCase();
  6596. if (nodeName == 'input') {
  6597. target.disabled = true;
  6598. inst.trigger.filter('button').
  6599. each(function() { this.disabled = true; }).end().
  6600. filter('img').css({opacity: '0.5', cursor: 'default'});
  6601. }
  6602. else if (nodeName == 'div' || nodeName == 'span') {
  6603. var inline = $target.children('.' + this._inlineClass);
  6604. inline.children().addClass('ui-state-disabled');
  6605. }
  6606. this._disabledInputs = $.map(this._disabledInputs,
  6607. function(value) { return (value == target ? null : value); }); // delete entry
  6608. this._disabledInputs[this._disabledInputs.length] = target;
  6609. },
  6610. /* Is the first field in a jQuery collection disabled as a datepicker?
  6611. @param target element - the target input field or division or span
  6612. @return boolean - true if disabled, false if enabled */
  6613. _isDisabledDatepicker: function(target) {
  6614. if (!target) {
  6615. return false;
  6616. }
  6617. for (var i = 0; i < this._disabledInputs.length; i++) {
  6618. if (this._disabledInputs[i] == target)
  6619. return true;
  6620. }
  6621. return false;
  6622. },
  6623. /* Retrieve the instance data for the target control.
  6624. @param target element - the target input field or division or span
  6625. @return object - the associated instance data
  6626. @throws error if a jQuery problem getting data */
  6627. _getInst: function(target) {
  6628. try {
  6629. return $.data(target, PROP_NAME);
  6630. }
  6631. catch (err) {
  6632. throw 'Missing instance data for this datepicker';
  6633. }
  6634. },
  6635. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6636. @param target element - the target input field or division or span
  6637. @param name object - the new settings to update or
  6638. string - the name of the setting to change or retrieve,
  6639. when retrieving also 'all' for all instance settings or
  6640. 'defaults' for all global defaults
  6641. @param value any - the new value for the setting
  6642. (omit if above is an object or to retrieve a value) */
  6643. _optionDatepicker: function(target, name, value) {
  6644. var inst = this._getInst(target);
  6645. if (arguments.length == 2 && typeof name == 'string') {
  6646. return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
  6647. (inst ? (name == 'all' ? $.extend({}, inst.settings) :
  6648. this._get(inst, name)) : null));
  6649. }
  6650. var settings = name || {};
  6651. if (typeof name == 'string') {
  6652. settings = {};
  6653. settings[name] = value;
  6654. }
  6655. if (inst) {
  6656. if (this._curInst == inst) {
  6657. this._hideDatepicker();
  6658. }
  6659. var date = this._getDateDatepicker(target, true);
  6660. extendRemove(inst.settings, settings);
  6661. this._attachments($(target), inst);
  6662. this._autoSize(inst);
  6663. this._setDateDatepicker(target, date);
  6664. this._updateDatepicker(inst);
  6665. }
  6666. },
  6667. // change method deprecated
  6668. _changeDatepicker: function(target, name, value) {
  6669. this._optionDatepicker(target, name, value);
  6670. },
  6671. /* Redraw the date picker attached to an input field or division.
  6672. @param target element - the target input field or division or span */
  6673. _refreshDatepicker: function(target) {
  6674. var inst = this._getInst(target);
  6675. if (inst) {
  6676. this._updateDatepicker(inst);
  6677. }
  6678. },
  6679. /* Set the dates for a jQuery selection.
  6680. @param target element - the target input field or division or span
  6681. @param date Date - the new date */
  6682. _setDateDatepicker: function(target, date) {
  6683. var inst = this._getInst(target);
  6684. if (inst) {
  6685. this._setDate(inst, date);
  6686. this._updateDatepicker(inst);
  6687. this._updateAlternate(inst);
  6688. }
  6689. },
  6690. /* Get the date(s) for the first entry in a jQuery selection.
  6691. @param target element - the target input field or division or span
  6692. @param noDefault boolean - true if no default date is to be used
  6693. @return Date - the current date */
  6694. _getDateDatepicker: function(target, noDefault) {
  6695. var inst = this._getInst(target);
  6696. if (inst && !inst.inline)
  6697. this._setDateFromField(inst, noDefault);
  6698. return (inst ? this._getDate(inst) : null);
  6699. },
  6700. /* Handle keystrokes. */
  6701. _doKeyDown: function(event) {
  6702. var inst = $.datepicker._getInst(event.target);
  6703. var handled = true;
  6704. var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
  6705. inst._keyEvent = true;
  6706. if ($.datepicker._datepickerShowing)
  6707. switch (event.keyCode) {
  6708. case 9: $.datepicker._hideDatepicker();
  6709. handled = false;
  6710. break; // hide on tab out
  6711. case 13: var sel = $('td.' + $.datepicker._dayOverClass, inst.dpDiv).
  6712. add($('td.' + $.datepicker._currentClass, inst.dpDiv));
  6713. if (sel[0])
  6714. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6715. else
  6716. $.datepicker._hideDatepicker();
  6717. return false; // don't submit the form
  6718. break; // select the value on enter
  6719. case 27: $.datepicker._hideDatepicker();
  6720. break; // hide on escape
  6721. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6722. -$.datepicker._get(inst, 'stepBigMonths') :
  6723. -$.datepicker._get(inst, 'stepMonths')), 'M');
  6724. break; // previous month/year on page up/+ ctrl
  6725. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6726. +$.datepicker._get(inst, 'stepBigMonths') :
  6727. +$.datepicker._get(inst, 'stepMonths')), 'M');
  6728. break; // next month/year on page down/+ ctrl
  6729. case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
  6730. handled = event.ctrlKey || event.metaKey;
  6731. break; // clear on ctrl or command +end
  6732. case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
  6733. handled = event.ctrlKey || event.metaKey;
  6734. break; // current on ctrl or command +home
  6735. case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
  6736. handled = event.ctrlKey || event.metaKey;
  6737. // -1 day on ctrl or command +left
  6738. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6739. -$.datepicker._get(inst, 'stepBigMonths') :
  6740. -$.datepicker._get(inst, 'stepMonths')), 'M');
  6741. // next month/year on alt +left on Mac
  6742. break;
  6743. case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
  6744. handled = event.ctrlKey || event.metaKey;
  6745. break; // -1 week on ctrl or command +up
  6746. case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
  6747. handled = event.ctrlKey || event.metaKey;
  6748. // +1 day on ctrl or command +right
  6749. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6750. +$.datepicker._get(inst, 'stepBigMonths') :
  6751. +$.datepicker._get(inst, 'stepMonths')), 'M');
  6752. // next month/year on alt +right
  6753. break;
  6754. case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
  6755. handled = event.ctrlKey || event.metaKey;
  6756. break; // +1 week on ctrl or command +down
  6757. default: handled = false;
  6758. }
  6759. else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
  6760. $.datepicker._showDatepicker(this);
  6761. else {
  6762. handled = false;
  6763. }
  6764. if (handled) {
  6765. event.preventDefault();
  6766. event.stopPropagation();
  6767. }
  6768. },
  6769. /* Filter entered characters - based on date format. */
  6770. _doKeyPress: function(event) {
  6771. var inst = $.datepicker._getInst(event.target);
  6772. if ($.datepicker._get(inst, 'constrainInput')) {
  6773. var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
  6774. var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
  6775. return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
  6776. }
  6777. },
  6778. /* Synchronise manual entry and field/alternate field. */
  6779. _doKeyUp: function(event) {
  6780. var inst = $.datepicker._getInst(event.target);
  6781. if (inst.input.val() != inst.lastVal) {
  6782. try {
  6783. var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  6784. (inst.input ? inst.input.val() : null),
  6785. $.datepicker._getFormatConfig(inst));
  6786. if (date) { // only if valid
  6787. $.datepicker._setDateFromField(inst);
  6788. $.datepicker._updateAlternate(inst);
  6789. $.datepicker._updateDatepicker(inst);
  6790. }
  6791. }
  6792. catch (event) {
  6793. $.datepicker.log(event);
  6794. }
  6795. }
  6796. return true;
  6797. },
  6798. /* Pop-up the date picker for a given input field.
  6799. @param input element - the input field attached to the date picker or
  6800. event - if triggered by focus */
  6801. _showDatepicker: function(input) {
  6802. input = input.target || input;
  6803. if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
  6804. input = $('input', input.parentNode)[0];
  6805. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
  6806. return;
  6807. var inst = $.datepicker._getInst(input);
  6808. if ($.datepicker._curInst && $.datepicker._curInst != inst) {
  6809. $.datepicker._curInst.dpDiv.stop(true, true);
  6810. }
  6811. var beforeShow = $.datepicker._get(inst, 'beforeShow');
  6812. extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
  6813. inst.lastVal = null;
  6814. $.datepicker._lastInput = input;
  6815. $.datepicker._setDateFromField(inst);
  6816. if ($.datepicker._inDialog) // hide cursor
  6817. input.value = '';
  6818. if (!$.datepicker._pos) { // position below input
  6819. $.datepicker._pos = $.datepicker._findPos(input);
  6820. $.datepicker._pos[1] += input.offsetHeight; // add the height
  6821. }
  6822. var isFixed = false;
  6823. $(input).parents().each(function() {
  6824. isFixed |= $(this).css('position') == 'fixed';
  6825. return !isFixed;
  6826. });
  6827. if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
  6828. $.datepicker._pos[0] -= document.documentElement.scrollLeft;
  6829. $.datepicker._pos[1] -= document.documentElement.scrollTop;
  6830. }
  6831. var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  6832. $.datepicker._pos = null;
  6833. // determine sizing offscreen
  6834. inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
  6835. $.datepicker._updateDatepicker(inst);
  6836. // fix width for dynamic number of date pickers
  6837. // and adjust position before showing
  6838. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  6839. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  6840. 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
  6841. left: offset.left + 'px', top: offset.top + 'px'});
  6842. if (!inst.inline) {
  6843. var showAnim = $.datepicker._get(inst, 'showAnim');
  6844. var duration = $.datepicker._get(inst, 'duration');
  6845. var postProcess = function() {
  6846. $.datepicker._datepickerShowing = true;
  6847. var borders = $.datepicker._getBorders(inst.dpDiv);
  6848. inst.dpDiv.find('iframe.ui-datepicker-cover'). // IE6- only
  6849. css({left: -borders[0], top: -borders[1],
  6850. width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
  6851. };
  6852. inst.dpDiv.zIndex($(input).zIndex()+1);
  6853. if ($.effects && $.effects[showAnim])
  6854. inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  6855. else
  6856. inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
  6857. if (!showAnim || !duration)
  6858. postProcess();
  6859. if (inst.input.is(':visible') && !inst.input.is(':disabled'))
  6860. inst.input.focus();
  6861. $.datepicker._curInst = inst;
  6862. }
  6863. },
  6864. /* Generate the date picker content. */
  6865. _updateDatepicker: function(inst) {
  6866. var self = this;
  6867. var borders = $.datepicker._getBorders(inst.dpDiv);
  6868. inst.dpDiv.empty().append(this._generateHTML(inst))
  6869. .find('iframe.ui-datepicker-cover') // IE6- only
  6870. .css({left: -borders[0], top: -borders[1],
  6871. width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
  6872. .end()
  6873. .find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a')
  6874. .bind('mouseout', function(){
  6875. $(this).removeClass('ui-state-hover');
  6876. if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
  6877. if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
  6878. })
  6879. .bind('mouseover', function(){
  6880. if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) {
  6881. $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
  6882. $(this).addClass('ui-state-hover');
  6883. if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
  6884. if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
  6885. }
  6886. })
  6887. .end()
  6888. .find('.' + this._dayOverClass + ' a')
  6889. .trigger('mouseover')
  6890. .end();
  6891. var numMonths = this._getNumberOfMonths(inst);
  6892. var cols = numMonths[1];
  6893. var width = 17;
  6894. if (cols > 1)
  6895. inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
  6896. else
  6897. inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
  6898. inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
  6899. 'Class']('ui-datepicker-multi');
  6900. inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
  6901. 'Class']('ui-datepicker-rtl');
  6902. if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  6903. inst.input.is(':visible') && !inst.input.is(':disabled'))
  6904. inst.input.focus();
  6905. },
  6906. /* Retrieve the size of left and top borders for an element.
  6907. @param elem (jQuery object) the element of interest
  6908. @return (number[2]) the left and top borders */
  6909. _getBorders: function(elem) {
  6910. var convert = function(value) {
  6911. return {thin: 1, medium: 2, thick: 3}[value] || value;
  6912. };
  6913. return [parseFloat(convert(elem.css('border-left-width'))),
  6914. parseFloat(convert(elem.css('border-top-width')))];
  6915. },
  6916. /* Check positioning to remain on screen. */
  6917. _checkOffset: function(inst, offset, isFixed) {
  6918. var dpWidth = inst.dpDiv.outerWidth();
  6919. var dpHeight = inst.dpDiv.outerHeight();
  6920. var inputWidth = inst.input ? inst.input.outerWidth() : 0;
  6921. var inputHeight = inst.input ? inst.input.outerHeight() : 0;
  6922. var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
  6923. var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
  6924. offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
  6925. offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
  6926. offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  6927. // now check if datepicker is showing outside window viewport - move to a better place if so.
  6928. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  6929. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  6930. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  6931. Math.abs(dpHeight + inputHeight) : 0);
  6932. return offset;
  6933. },
  6934. /* Find an object's position on the screen. */
  6935. _findPos: function(obj) {
  6936. var inst = this._getInst(obj);
  6937. var isRTL = this._get(inst, 'isRTL');
  6938. while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
  6939. obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
  6940. }
  6941. var position = $(obj).offset();
  6942. return [position.left, position.top];
  6943. },
  6944. /* Hide the date picker from view.
  6945. @param input element - the input field attached to the date picker */
  6946. _hideDatepicker: function(input) {
  6947. var inst = this._curInst;
  6948. if (!inst || (input && inst != $.data(input, PROP_NAME)))
  6949. return;
  6950. if (this._datepickerShowing) {
  6951. var showAnim = this._get(inst, 'showAnim');
  6952. var duration = this._get(inst, 'duration');
  6953. var postProcess = function() {
  6954. $.datepicker._tidyDialog(inst);
  6955. this._curInst = null;
  6956. };
  6957. if ($.effects && $.effects[showAnim])
  6958. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  6959. else
  6960. inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
  6961. (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
  6962. if (!showAnim)
  6963. postProcess();
  6964. var onClose = this._get(inst, 'onClose');
  6965. if (onClose)
  6966. onClose.apply((inst.input ? inst.input[0] : null),
  6967. [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
  6968. this._datepickerShowing = false;
  6969. this._lastInput = null;
  6970. if (this._inDialog) {
  6971. this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
  6972. if ($.blockUI) {
  6973. $.unblockUI();
  6974. $('body').append(this.dpDiv);
  6975. }
  6976. }
  6977. this._inDialog = false;
  6978. }
  6979. },
  6980. /* Tidy up after a dialog display. */
  6981. _tidyDialog: function(inst) {
  6982. inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
  6983. },
  6984. /* Close date picker if clicked elsewhere. */
  6985. _checkExternalClick: function(event) {
  6986. if (!$.datepicker._curInst)
  6987. return;
  6988. var $target = $(event.target);
  6989. if ($target[0].id != $.datepicker._mainDivId &&
  6990. $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
  6991. !$target.hasClass($.datepicker.markerClassName) &&
  6992. !$target.hasClass($.datepicker._triggerClass) &&
  6993. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
  6994. $.datepicker._hideDatepicker();
  6995. },
  6996. /* Adjust one of the date sub-fields. */
  6997. _adjustDate: function(id, offset, period) {
  6998. var target = $(id);
  6999. var inst = this._getInst(target[0]);
  7000. if (this._isDisabledDatepicker(target[0])) {
  7001. return;
  7002. }
  7003. this._adjustInstDate(inst, offset +
  7004. (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
  7005. period);
  7006. this._updateDatepicker(inst);
  7007. },
  7008. /* Action for current link. */
  7009. _gotoToday: function(id) {
  7010. var target = $(id);
  7011. var inst = this._getInst(target[0]);
  7012. if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
  7013. inst.selectedDay = inst.currentDay;
  7014. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7015. inst.drawYear = inst.selectedYear = inst.currentYear;
  7016. }
  7017. else {
  7018. var date = new Date();
  7019. inst.selectedDay = date.getDate();
  7020. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7021. inst.drawYear = inst.selectedYear = date.getFullYear();
  7022. }
  7023. this._notifyChange(inst);
  7024. this._adjustDate(target);
  7025. },
  7026. /* Action for selecting a new month/year. */
  7027. _selectMonthYear: function(id, select, period) {
  7028. var target = $(id);
  7029. var inst = this._getInst(target[0]);
  7030. inst._selectingMonthYear = false;
  7031. inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
  7032. inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
  7033. parseInt(select.options[select.selectedIndex].value,10);
  7034. this._notifyChange(inst);
  7035. this._adjustDate(target);
  7036. },
  7037. /* Restore input focus after not changing month/year. */
  7038. _clickMonthYear: function(id) {
  7039. var target = $(id);
  7040. var inst = this._getInst(target[0]);
  7041. if (inst.input && inst._selectingMonthYear && !$.browser.msie)
  7042. inst.input.focus();
  7043. inst._selectingMonthYear = !inst._selectingMonthYear;
  7044. },
  7045. /* Action for selecting a day. */
  7046. _selectDay: function(id, month, year, td) {
  7047. var target = $(id);
  7048. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7049. return;
  7050. }
  7051. var inst = this._getInst(target[0]);
  7052. inst.selectedDay = inst.currentDay = $('a', td).html();
  7053. inst.selectedMonth = inst.currentMonth = month;
  7054. inst.selectedYear = inst.currentYear = year;
  7055. this._selectDate(id, this._formatDate(inst,
  7056. inst.currentDay, inst.currentMonth, inst.currentYear));
  7057. },
  7058. /* Erase the input field and hide the date picker. */
  7059. _clearDate: function(id) {
  7060. var target = $(id);
  7061. var inst = this._getInst(target[0]);
  7062. this._selectDate(target, '');
  7063. },
  7064. /* Update the input field with the selected date. */
  7065. _selectDate: function(id, dateStr) {
  7066. var target = $(id);
  7067. var inst = this._getInst(target[0]);
  7068. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7069. if (inst.input)
  7070. inst.input.val(dateStr);
  7071. this._updateAlternate(inst);
  7072. var onSelect = this._get(inst, 'onSelect');
  7073. if (onSelect)
  7074. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7075. else if (inst.input)
  7076. inst.input.trigger('change'); // fire the change event
  7077. if (inst.inline)
  7078. this._updateDatepicker(inst);
  7079. else {
  7080. this._hideDatepicker();
  7081. this._lastInput = inst.input[0];
  7082. if (typeof(inst.input[0]) != 'object')
  7083. inst.input.focus(); // restore focus
  7084. this._lastInput = null;
  7085. }
  7086. },
  7087. /* Update any alternate field to synchronise with the main field. */
  7088. _updateAlternate: function(inst) {
  7089. var altField = this._get(inst, 'altField');
  7090. if (altField) { // update alternate field too
  7091. var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
  7092. var date = this._getDate(inst);
  7093. var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7094. $(altField).each(function() { $(this).val(dateStr); });
  7095. }
  7096. },
  7097. /* Set as beforeShowDay function to prevent selection of weekends.
  7098. @param date Date - the date to customise
  7099. @return [boolean, string] - is this date selectable?, what is its CSS class? */
  7100. noWeekends: function(date) {
  7101. var day = date.getDay();
  7102. return [(day > 0 && day < 6), ''];
  7103. },
  7104. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7105. @param date Date - the date to get the week for
  7106. @return number - the number of the week within the year that contains this date */
  7107. iso8601Week: function(date) {
  7108. var checkDate = new Date(date.getTime());
  7109. // Find Thursday of this week starting on Monday
  7110. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7111. var time = checkDate.getTime();
  7112. checkDate.setMonth(0); // Compare with Jan 1
  7113. checkDate.setDate(1);
  7114. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7115. },
  7116. /* Parse a string value into a date object.
  7117. See formatDate below for the possible formats.
  7118. @param format string - the expected format of the date
  7119. @param value string - the date in the above format
  7120. @param settings Object - attributes include:
  7121. shortYearCutoff number - the cutoff year for determining the century (optional)
  7122. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7123. dayNames string[7] - names of the days from Sunday (optional)
  7124. monthNamesShort string[12] - abbreviated names of the months (optional)
  7125. monthNames string[12] - names of the months (optional)
  7126. @return Date - the extracted date value or null if value is blank */
  7127. parseDate: function (format, value, settings) {
  7128. if (format == null || value == null)
  7129. throw 'Invalid arguments';
  7130. value = (typeof value == 'object' ? value.toString() : value + '');
  7131. if (value == '')
  7132. return null;
  7133. var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
  7134. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  7135. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  7136. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  7137. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  7138. var year = -1;
  7139. var month = -1;
  7140. var day = -1;
  7141. var doy = -1;
  7142. var literal = false;
  7143. // Check whether a format character is doubled
  7144. var lookAhead = function(match) {
  7145. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  7146. if (matches)
  7147. iFormat++;
  7148. return matches;
  7149. };
  7150. // Extract a number from the string value
  7151. var getNumber = function(match) {
  7152. lookAhead(match);
  7153. var size = (match == '@' ? 14 : (match == '!' ? 20 :
  7154. (match == 'y' ? 4 : (match == 'o' ? 3 : 2))));
  7155. var digits = new RegExp('^\\d{1,' + size + '}');
  7156. var num = value.substring(iValue).match(digits);
  7157. if (!num)
  7158. throw 'Missing number at position ' + iValue;
  7159. iValue += num[0].length;
  7160. return parseInt(num[0], 10);
  7161. };
  7162. // Extract a name from the string value and convert to an index
  7163. var getName = function(match, shortNames, longNames) {
  7164. var names = (lookAhead(match) ? longNames : shortNames);
  7165. for (var i = 0; i < names.length; i++) {
  7166. if (value.substr(iValue, names[i].length) == names[i]) {
  7167. iValue += names[i].length;
  7168. return i + 1;
  7169. }
  7170. }
  7171. throw 'Unknown name at position ' + iValue;
  7172. };
  7173. // Confirm that a literal character matches the string value
  7174. var checkLiteral = function() {
  7175. if (value.charAt(iValue) != format.charAt(iFormat))
  7176. throw 'Unexpected literal at position ' + iValue;
  7177. iValue++;
  7178. };
  7179. var iValue = 0;
  7180. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  7181. if (literal)
  7182. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  7183. literal = false;
  7184. else
  7185. checkLiteral();
  7186. else
  7187. switch (format.charAt(iFormat)) {
  7188. case 'd':
  7189. day = getNumber('d');
  7190. break;
  7191. case 'D':
  7192. getName('D', dayNamesShort, dayNames);
  7193. break;
  7194. case 'o':
  7195. doy = getNumber('o');
  7196. break;
  7197. case 'm':
  7198. month = getNumber('m');
  7199. break;
  7200. case 'M':
  7201. month = getName('M', monthNamesShort, monthNames);
  7202. break;
  7203. case 'y':
  7204. year = getNumber('y');
  7205. break;
  7206. case '@':
  7207. var date = new Date(getNumber('@'));
  7208. year = date.getFullYear();
  7209. month = date.getMonth() + 1;
  7210. day = date.getDate();
  7211. break;
  7212. case '!':
  7213. var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
  7214. year = date.getFullYear();
  7215. month = date.getMonth() + 1;
  7216. day = date.getDate();
  7217. break;
  7218. case "'":
  7219. if (lookAhead("'"))
  7220. checkLiteral();
  7221. else
  7222. literal = true;
  7223. break;
  7224. default:
  7225. checkLiteral();
  7226. }
  7227. }
  7228. if (year == -1)
  7229. year = new Date().getFullYear();
  7230. else if (year < 100)
  7231. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7232. (year <= shortYearCutoff ? 0 : -100);
  7233. if (doy > -1) {
  7234. month = 1;
  7235. day = doy;
  7236. do {
  7237. var dim = this._getDaysInMonth(year, month - 1);
  7238. if (day <= dim)
  7239. break;
  7240. month++;
  7241. day -= dim;
  7242. } while (true);
  7243. }
  7244. var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7245. if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
  7246. throw 'Invalid date'; // E.g. 31/02/*
  7247. return date;
  7248. },
  7249. /* Standard date formats. */
  7250. ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
  7251. COOKIE: 'D, dd M yy',
  7252. ISO_8601: 'yy-mm-dd',
  7253. RFC_822: 'D, d M y',
  7254. RFC_850: 'DD, dd-M-y',
  7255. RFC_1036: 'D, d M y',
  7256. RFC_1123: 'D, d M yy',
  7257. RFC_2822: 'D, d M yy',
  7258. RSS: 'D, d M y', // RFC 822
  7259. TICKS: '!',
  7260. TIMESTAMP: '@',
  7261. W3C: 'yy-mm-dd', // ISO 8601
  7262. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7263. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7264. /* Format a date object into a string value.
  7265. The format can be combinations of the following:
  7266. d - day of month (no leading zero)
  7267. dd - day of month (two digit)
  7268. o - day of year (no leading zeros)
  7269. oo - day of year (three digit)
  7270. D - day name short
  7271. DD - day name long
  7272. m - month of year (no leading zero)
  7273. mm - month of year (two digit)
  7274. M - month name short
  7275. MM - month name long
  7276. y - year (two digit)
  7277. yy - year (four digit)
  7278. @ - Unix timestamp (ms since 01/01/1970)
  7279. ! - Windows ticks (100ns since 01/01/0001)
  7280. '...' - literal text
  7281. '' - single quote
  7282. @param format string - the desired format of the date
  7283. @param date Date - the date value to format
  7284. @param settings Object - attributes include:
  7285. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7286. dayNames string[7] - names of the days from Sunday (optional)
  7287. monthNamesShort string[12] - abbreviated names of the months (optional)
  7288. monthNames string[12] - names of the months (optional)
  7289. @return string - the date in the above format */
  7290. formatDate: function (format, date, settings) {
  7291. if (!date)
  7292. return '';
  7293. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  7294. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  7295. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  7296. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  7297. // Check whether a format character is doubled
  7298. var lookAhead = function(match) {
  7299. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  7300. if (matches)
  7301. iFormat++;
  7302. return matches;
  7303. };
  7304. // Format a number, with leading zero if necessary
  7305. var formatNumber = function(match, value, len) {
  7306. var num = '' + value;
  7307. if (lookAhead(match))
  7308. while (num.length < len)
  7309. num = '0' + num;
  7310. return num;
  7311. };
  7312. // Format a name, short or long as requested
  7313. var formatName = function(match, value, shortNames, longNames) {
  7314. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7315. };
  7316. var output = '';
  7317. var literal = false;
  7318. if (date)
  7319. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  7320. if (literal)
  7321. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  7322. literal = false;
  7323. else
  7324. output += format.charAt(iFormat);
  7325. else
  7326. switch (format.charAt(iFormat)) {
  7327. case 'd':
  7328. output += formatNumber('d', date.getDate(), 2);
  7329. break;
  7330. case 'D':
  7331. output += formatName('D', date.getDay(), dayNamesShort, dayNames);
  7332. break;
  7333. case 'o':
  7334. output += formatNumber('o',
  7335. (date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
  7336. break;
  7337. case 'm':
  7338. output += formatNumber('m', date.getMonth() + 1, 2);
  7339. break;
  7340. case 'M':
  7341. output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
  7342. break;
  7343. case 'y':
  7344. output += (lookAhead('y') ? date.getFullYear() :
  7345. (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
  7346. break;
  7347. case '@':
  7348. output += date.getTime();
  7349. break;
  7350. case '!':
  7351. output += date.getTime() * 10000 + this._ticksTo1970;
  7352. break;
  7353. case "'":
  7354. if (lookAhead("'"))
  7355. output += "'";
  7356. else
  7357. literal = true;
  7358. break;
  7359. default:
  7360. output += format.charAt(iFormat);
  7361. }
  7362. }
  7363. return output;
  7364. },
  7365. /* Extract all possible characters from the date format. */
  7366. _possibleChars: function (format) {
  7367. var chars = '';
  7368. var literal = false;
  7369. // Check whether a format character is doubled
  7370. var lookAhead = function(match) {
  7371. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  7372. if (matches)
  7373. iFormat++;
  7374. return matches;
  7375. };
  7376. for (var iFormat = 0; iFormat < format.length; iFormat++)
  7377. if (literal)
  7378. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  7379. literal = false;
  7380. else
  7381. chars += format.charAt(iFormat);
  7382. else
  7383. switch (format.charAt(iFormat)) {
  7384. case 'd': case 'm': case 'y': case '@':
  7385. chars += '0123456789';
  7386. break;
  7387. case 'D': case 'M':
  7388. return null; // Accept anything
  7389. case "'":
  7390. if (lookAhead("'"))
  7391. chars += "'";
  7392. else
  7393. literal = true;
  7394. break;
  7395. default:
  7396. chars += format.charAt(iFormat);
  7397. }
  7398. return chars;
  7399. },
  7400. /* Get a setting value, defaulting if necessary. */
  7401. _get: function(inst, name) {
  7402. return inst.settings[name] !== undefined ?
  7403. inst.settings[name] : this._defaults[name];
  7404. },
  7405. /* Parse existing date and initialise date picker. */
  7406. _setDateFromField: function(inst, noDefault) {
  7407. if (inst.input.val() == inst.lastVal) {
  7408. return;
  7409. }
  7410. var dateFormat = this._get(inst, 'dateFormat');
  7411. var dates = inst.lastVal = inst.input ? inst.input.val() : null;
  7412. var date, defaultDate;
  7413. date = defaultDate = this._getDefaultDate(inst);
  7414. var settings = this._getFormatConfig(inst);
  7415. try {
  7416. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7417. } catch (event) {
  7418. this.log(event);
  7419. dates = (noDefault ? '' : dates);
  7420. }
  7421. inst.selectedDay = date.getDate();
  7422. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7423. inst.drawYear = inst.selectedYear = date.getFullYear();
  7424. inst.currentDay = (dates ? date.getDate() : 0);
  7425. inst.currentMonth = (dates ? date.getMonth() : 0);
  7426. inst.currentYear = (dates ? date.getFullYear() : 0);
  7427. this._adjustInstDate(inst);
  7428. },
  7429. /* Retrieve the default date shown on opening. */
  7430. _getDefaultDate: function(inst) {
  7431. return this._restrictMinMax(inst,
  7432. this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
  7433. },
  7434. /* A date may be specified as an exact value or a relative one. */
  7435. _determineDate: function(inst, date, defaultDate) {
  7436. var offsetNumeric = function(offset) {
  7437. var date = new Date();
  7438. date.setDate(date.getDate() + offset);
  7439. return date;
  7440. };
  7441. var offsetString = function(offset) {
  7442. try {
  7443. return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  7444. offset, $.datepicker._getFormatConfig(inst));
  7445. }
  7446. catch (e) {
  7447. // Ignore
  7448. }
  7449. var date = (offset.toLowerCase().match(/^c/) ?
  7450. $.datepicker._getDate(inst) : null) || new Date();
  7451. var year = date.getFullYear();
  7452. var month = date.getMonth();
  7453. var day = date.getDate();
  7454. var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
  7455. var matches = pattern.exec(offset);
  7456. while (matches) {
  7457. switch (matches[2] || 'd') {
  7458. case 'd' : case 'D' :
  7459. day += parseInt(matches[1],10); break;
  7460. case 'w' : case 'W' :
  7461. day += parseInt(matches[1],10) * 7; break;
  7462. case 'm' : case 'M' :
  7463. month += parseInt(matches[1],10);
  7464. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7465. break;
  7466. case 'y': case 'Y' :
  7467. year += parseInt(matches[1],10);
  7468. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7469. break;
  7470. }
  7471. matches = pattern.exec(offset);
  7472. }
  7473. return new Date(year, month, day);
  7474. };
  7475. date = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) :
  7476. (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
  7477. date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
  7478. if (date) {
  7479. date.setHours(0);
  7480. date.setMinutes(0);
  7481. date.setSeconds(0);
  7482. date.setMilliseconds(0);
  7483. }
  7484. return this._daylightSavingAdjust(date);
  7485. },
  7486. /* Handle switch to/from daylight saving.
  7487. Hours may be non-zero on daylight saving cut-over:
  7488. > 12 when midnight changeover, but then cannot generate
  7489. midnight datetime, so jump to 1AM, otherwise reset.
  7490. @param date (Date) the date to check
  7491. @return (Date) the corrected date */
  7492. _daylightSavingAdjust: function(date) {
  7493. if (!date) return null;
  7494. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7495. return date;
  7496. },
  7497. /* Set the date(s) directly. */
  7498. _setDate: function(inst, date, noChange) {
  7499. var clear = !(date);
  7500. var origMonth = inst.selectedMonth;
  7501. var origYear = inst.selectedYear;
  7502. date = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7503. inst.selectedDay = inst.currentDay = date.getDate();
  7504. inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
  7505. inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
  7506. if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
  7507. this._notifyChange(inst);
  7508. this._adjustInstDate(inst);
  7509. if (inst.input) {
  7510. inst.input.val(clear ? '' : this._formatDate(inst));
  7511. }
  7512. },
  7513. /* Retrieve the date(s) directly. */
  7514. _getDate: function(inst) {
  7515. var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
  7516. this._daylightSavingAdjust(new Date(
  7517. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7518. return startDate;
  7519. },
  7520. /* Generate the HTML for the current state of the date picker. */
  7521. _generateHTML: function(inst) {
  7522. var today = new Date();
  7523. today = this._daylightSavingAdjust(
  7524. new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
  7525. var isRTL = this._get(inst, 'isRTL');
  7526. var showButtonPanel = this._get(inst, 'showButtonPanel');
  7527. var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
  7528. var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
  7529. var numMonths = this._getNumberOfMonths(inst);
  7530. var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
  7531. var stepMonths = this._get(inst, 'stepMonths');
  7532. var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
  7533. var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7534. new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7535. var minDate = this._getMinMaxDate(inst, 'min');
  7536. var maxDate = this._getMinMaxDate(inst, 'max');
  7537. var drawMonth = inst.drawMonth - showCurrentAtPos;
  7538. var drawYear = inst.drawYear;
  7539. if (drawMonth < 0) {
  7540. drawMonth += 12;
  7541. drawYear--;
  7542. }
  7543. if (maxDate) {
  7544. var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7545. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7546. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7547. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7548. drawMonth--;
  7549. if (drawMonth < 0) {
  7550. drawMonth = 11;
  7551. drawYear--;
  7552. }
  7553. }
  7554. }
  7555. inst.drawMonth = drawMonth;
  7556. inst.drawYear = drawYear;
  7557. var prevText = this._get(inst, 'prevText');
  7558. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7559. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7560. this._getFormatConfig(inst)));
  7561. var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7562. '<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7563. '.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
  7564. ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
  7565. (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>'));
  7566. var nextText = this._get(inst, 'nextText');
  7567. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7568. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7569. this._getFormatConfig(inst)));
  7570. var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7571. '<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7572. '.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
  7573. ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
  7574. (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>'));
  7575. var currentText = this._get(inst, 'currentText');
  7576. var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
  7577. currentText = (!navigationAsDateFormat ? currentText :
  7578. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7579. var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7580. '.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
  7581. var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
  7582. (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7583. '.datepicker._gotoToday(\'#' + inst.id + '\');"' +
  7584. '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
  7585. var firstDay = parseInt(this._get(inst, 'firstDay'),10);
  7586. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7587. var showWeek = this._get(inst, 'showWeek');
  7588. var dayNames = this._get(inst, 'dayNames');
  7589. var dayNamesShort = this._get(inst, 'dayNamesShort');
  7590. var dayNamesMin = this._get(inst, 'dayNamesMin');
  7591. var monthNames = this._get(inst, 'monthNames');
  7592. var monthNamesShort = this._get(inst, 'monthNamesShort');
  7593. var beforeShowDay = this._get(inst, 'beforeShowDay');
  7594. var showOtherMonths = this._get(inst, 'showOtherMonths');
  7595. var selectOtherMonths = this._get(inst, 'selectOtherMonths');
  7596. var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
  7597. var defaultDate = this._getDefaultDate(inst);
  7598. var html = '';
  7599. for (var row = 0; row < numMonths[0]; row++) {
  7600. var group = '';
  7601. for (var col = 0; col < numMonths[1]; col++) {
  7602. var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7603. var cornerClass = ' ui-corner-all';
  7604. var calender = '';
  7605. if (isMultiMonth) {
  7606. calender += '<div class="ui-datepicker-group';
  7607. if (numMonths[1] > 1)
  7608. switch (col) {
  7609. case 0: calender += ' ui-datepicker-group-first';
  7610. cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
  7611. case numMonths[1]-1: calender += ' ui-datepicker-group-last';
  7612. cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
  7613. default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
  7614. }
  7615. calender += '">';
  7616. }
  7617. calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
  7618. (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
  7619. (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
  7620. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7621. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7622. '</div><table class="ui-datepicker-calendar"><thead>' +
  7623. '<tr>';
  7624. var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
  7625. for (var dow = 0; dow < 7; dow++) { // days of the week
  7626. var day = (dow + firstDay) % 7;
  7627. thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
  7628. '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
  7629. }
  7630. calender += thead + '</tr></thead><tbody>';
  7631. var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7632. if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
  7633. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7634. var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7635. var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
  7636. var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7637. for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7638. calender += '<tr>';
  7639. var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
  7640. this._get(inst, 'calculateWeek')(printDate) + '</td>');
  7641. for (var dow = 0; dow < 7; dow++) { // create date picker days
  7642. var daySettings = (beforeShowDay ?
  7643. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
  7644. var otherMonth = (printDate.getMonth() != drawMonth);
  7645. var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7646. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7647. tbody += '<td class="' +
  7648. ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
  7649. (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
  7650. ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
  7651. (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
  7652. // or defaultDate is current printedDate and defaultDate is selectedDate
  7653. ' ' + this._dayOverClass : '') + // highlight selected day
  7654. (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
  7655. (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
  7656. (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
  7657. (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
  7658. ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
  7659. (unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
  7660. inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
  7661. (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
  7662. (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
  7663. (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
  7664. (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
  7665. (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
  7666. '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
  7667. printDate.setDate(printDate.getDate() + 1);
  7668. printDate = this._daylightSavingAdjust(printDate);
  7669. }
  7670. calender += tbody + '</tr>';
  7671. }
  7672. drawMonth++;
  7673. if (drawMonth > 11) {
  7674. drawMonth = 0;
  7675. drawYear++;
  7676. }
  7677. calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
  7678. ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
  7679. group += calender;
  7680. }
  7681. html += group;
  7682. }
  7683. html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
  7684. '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
  7685. inst._keyEvent = false;
  7686. return html;
  7687. },
  7688. /* Generate the month and year header. */
  7689. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7690. secondary, monthNames, monthNamesShort) {
  7691. var changeMonth = this._get(inst, 'changeMonth');
  7692. var changeYear = this._get(inst, 'changeYear');
  7693. var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
  7694. var html = '<div class="ui-datepicker-title">';
  7695. var monthHtml = '';
  7696. // month selection
  7697. if (secondary || !changeMonth)
  7698. monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
  7699. else {
  7700. var inMinYear = (minDate && minDate.getFullYear() == drawYear);
  7701. var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
  7702. monthHtml += '<select class="ui-datepicker-month" ' +
  7703. 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
  7704. 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
  7705. '>';
  7706. for (var month = 0; month < 12; month++) {
  7707. if ((!inMinYear || month >= minDate.getMonth()) &&
  7708. (!inMaxYear || month <= maxDate.getMonth()))
  7709. monthHtml += '<option value="' + month + '"' +
  7710. (month == drawMonth ? ' selected="selected"' : '') +
  7711. '>' + monthNamesShort[month] + '</option>';
  7712. }
  7713. monthHtml += '</select>';
  7714. }
  7715. if (!showMonthAfterYear)
  7716. html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
  7717. // year selection
  7718. if (secondary || !changeYear)
  7719. html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
  7720. else {
  7721. // determine range of years to display
  7722. var years = this._get(inst, 'yearRange').split(':');
  7723. var thisYear = new Date().getFullYear();
  7724. var determineYear = function(value) {
  7725. var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  7726. (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
  7727. parseInt(value, 10)));
  7728. return (isNaN(year) ? thisYear : year);
  7729. };
  7730. var year = determineYear(years[0]);
  7731. var endYear = Math.max(year, determineYear(years[1] || ''));
  7732. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  7733. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  7734. html += '<select class="ui-datepicker-year" ' +
  7735. 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
  7736. 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
  7737. '>';
  7738. for (; year <= endYear; year++) {
  7739. html += '<option value="' + year + '"' +
  7740. (year == drawYear ? ' selected="selected"' : '') +
  7741. '>' + year + '</option>';
  7742. }
  7743. html += '</select>';
  7744. }
  7745. html += this._get(inst, 'yearSuffix');
  7746. if (showMonthAfterYear)
  7747. html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
  7748. html += '</div>'; // Close datepicker_header
  7749. return html;
  7750. },
  7751. /* Adjust one of the date sub-fields. */
  7752. _adjustInstDate: function(inst, offset, period) {
  7753. var year = inst.drawYear + (period == 'Y' ? offset : 0);
  7754. var month = inst.drawMonth + (period == 'M' ? offset : 0);
  7755. var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
  7756. (period == 'D' ? offset : 0);
  7757. var date = this._restrictMinMax(inst,
  7758. this._daylightSavingAdjust(new Date(year, month, day)));
  7759. inst.selectedDay = date.getDate();
  7760. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7761. inst.drawYear = inst.selectedYear = date.getFullYear();
  7762. if (period == 'M' || period == 'Y')
  7763. this._notifyChange(inst);
  7764. },
  7765. /* Ensure a date is within any min/max bounds. */
  7766. _restrictMinMax: function(inst, date) {
  7767. var minDate = this._getMinMaxDate(inst, 'min');
  7768. var maxDate = this._getMinMaxDate(inst, 'max');
  7769. date = (minDate && date < minDate ? minDate : date);
  7770. date = (maxDate && date > maxDate ? maxDate : date);
  7771. return date;
  7772. },
  7773. /* Notify change of month/year. */
  7774. _notifyChange: function(inst) {
  7775. var onChange = this._get(inst, 'onChangeMonthYear');
  7776. if (onChange)
  7777. onChange.apply((inst.input ? inst.input[0] : null),
  7778. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  7779. },
  7780. /* Determine the number of months to show. */
  7781. _getNumberOfMonths: function(inst) {
  7782. var numMonths = this._get(inst, 'numberOfMonths');
  7783. return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
  7784. },
  7785. /* Determine the current maximum date - ensure no time components are set. */
  7786. _getMinMaxDate: function(inst, minMax) {
  7787. return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
  7788. },
  7789. /* Find the number of days in a given month. */
  7790. _getDaysInMonth: function(year, month) {
  7791. return 32 - new Date(year, month, 32).getDate();
  7792. },
  7793. /* Find the day of the week of the first of a month. */
  7794. _getFirstDayOfMonth: function(year, month) {
  7795. return new Date(year, month, 1).getDay();
  7796. },
  7797. /* Determines if we should allow a "next/prev" month display change. */
  7798. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  7799. var numMonths = this._getNumberOfMonths(inst);
  7800. var date = this._daylightSavingAdjust(new Date(curYear,
  7801. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  7802. if (offset < 0)
  7803. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  7804. return this._isInRange(inst, date);
  7805. },
  7806. /* Is the given date in the accepted range? */
  7807. _isInRange: function(inst, date) {
  7808. var minDate = this._getMinMaxDate(inst, 'min');
  7809. var maxDate = this._getMinMaxDate(inst, 'max');
  7810. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  7811. (!maxDate || date.getTime() <= maxDate.getTime()));
  7812. },
  7813. /* Provide the configuration settings for formatting/parsing. */
  7814. _getFormatConfig: function(inst) {
  7815. var shortYearCutoff = this._get(inst, 'shortYearCutoff');
  7816. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  7817. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  7818. return {shortYearCutoff: shortYearCutoff,
  7819. dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
  7820. monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
  7821. },
  7822. /* Format the given date for display. */
  7823. _formatDate: function(inst, day, month, year) {
  7824. if (!day) {
  7825. inst.currentDay = inst.selectedDay;
  7826. inst.currentMonth = inst.selectedMonth;
  7827. inst.currentYear = inst.selectedYear;
  7828. }
  7829. var date = (day ? (typeof day == 'object' ? day :
  7830. this._daylightSavingAdjust(new Date(year, month, day))) :
  7831. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7832. return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
  7833. }
  7834. });
  7835. /* jQuery extend now ignores nulls! */
  7836. function extendRemove(target, props) {
  7837. $.extend(target, props);
  7838. for (var name in props)
  7839. if (props[name] == null || props[name] == undefined)
  7840. target[name] = props[name];
  7841. return target;
  7842. };
  7843. /* Determine whether an object is an array. */
  7844. function isArray(a) {
  7845. return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
  7846. (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
  7847. };
  7848. /* Invoke the datepicker functionality.
  7849. @param options string - a command, optionally followed by additional parameters or
  7850. Object - settings for attaching new datepicker functionality
  7851. @return jQuery object */
  7852. $.fn.datepicker = function(options){
  7853. /* Initialise the date picker. */
  7854. if (!$.datepicker.initialized) {
  7855. $(document).mousedown($.datepicker._checkExternalClick).
  7856. find('body').append($.datepicker.dpDiv);
  7857. $.datepicker.initialized = true;
  7858. }
  7859. var otherArgs = Array.prototype.slice.call(arguments, 1);
  7860. if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
  7861. return $.datepicker['_' + options + 'Datepicker'].
  7862. apply($.datepicker, [this[0]].concat(otherArgs));
  7863. if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
  7864. return $.datepicker['_' + options + 'Datepicker'].
  7865. apply($.datepicker, [this[0]].concat(otherArgs));
  7866. return this.each(function() {
  7867. typeof options == 'string' ?
  7868. $.datepicker['_' + options + 'Datepicker'].
  7869. apply($.datepicker, [this].concat(otherArgs)) :
  7870. $.datepicker._attachDatepicker(this, options);
  7871. });
  7872. };
  7873. $.datepicker = new Datepicker(); // singleton instance
  7874. $.datepicker.initialized = false;
  7875. $.datepicker.uuid = new Date().getTime();
  7876. $.datepicker.version = "1.8";
  7877. // Workaround for #4055
  7878. // Add another global to avoid noConflict issues with inline event handlers
  7879. window['DP_jQuery_' + dpuuid] = $;
  7880. })(jQuery);
  7881. /*
  7882. * jQuery UI Progressbar 1.8
  7883. *
  7884. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  7885. * Dual licensed under the MIT (MIT-LICENSE.txt)
  7886. * and GPL (GPL-LICENSE.txt) licenses.
  7887. *
  7888. * http://docs.jquery.com/UI/Progressbar
  7889. *
  7890. * Depends:
  7891. * jquery.ui.core.js
  7892. * jquery.ui.widget.js
  7893. */
  7894. (function( $ ) {
  7895. $.widget( "ui.progressbar", {
  7896. options: {
  7897. value: 0
  7898. },
  7899. _create: function() {
  7900. this.element
  7901. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  7902. .attr({
  7903. role: "progressbar",
  7904. "aria-valuemin": this._valueMin(),
  7905. "aria-valuemax": this._valueMax(),
  7906. "aria-valuenow": this._value()
  7907. });
  7908. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  7909. .appendTo( this.element );
  7910. this._refreshValue();
  7911. },
  7912. destroy: function() {
  7913. this.element
  7914. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  7915. .removeAttr( "role" )
  7916. .removeAttr( "aria-valuemin" )
  7917. .removeAttr( "aria-valuemax" )
  7918. .removeAttr( "aria-valuenow" );
  7919. this.valueDiv.remove();
  7920. $.Widget.prototype.destroy.apply( this, arguments );
  7921. },
  7922. value: function( newValue ) {
  7923. if ( newValue === undefined ) {
  7924. return this._value();
  7925. }
  7926. this._setOption( "value", newValue );
  7927. return this;
  7928. },
  7929. _setOption: function( key, value ) {
  7930. switch ( key ) {
  7931. case "value":
  7932. this.options.value = value;
  7933. this._refreshValue();
  7934. this._trigger( "change" );
  7935. break;
  7936. }
  7937. $.Widget.prototype._setOption.apply( this, arguments );
  7938. },
  7939. _value: function() {
  7940. var val = this.options.value;
  7941. // normalize invalid value
  7942. if ( typeof val !== "number" ) {
  7943. val = 0;
  7944. }
  7945. if ( val < this._valueMin() ) {
  7946. val = this._valueMin();
  7947. }
  7948. if ( val > this._valueMax() ) {
  7949. val = this._valueMax();
  7950. }
  7951. return val;
  7952. },
  7953. _valueMin: function() {
  7954. return 0;
  7955. },
  7956. _valueMax: function() {
  7957. return 100;
  7958. },
  7959. _refreshValue: function() {
  7960. var value = this.value();
  7961. this.valueDiv
  7962. [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" )
  7963. .width( value + "%" );
  7964. this.element.attr( "aria-valuenow", value );
  7965. }
  7966. });
  7967. $.extend( $.ui.progressbar, {
  7968. version: "1.8"
  7969. });
  7970. })( jQuery );
  7971. /*
  7972. * jQuery UI Effects 1.8
  7973. *
  7974. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  7975. * Dual licensed under the MIT (MIT-LICENSE.txt)
  7976. * and GPL (GPL-LICENSE.txt) licenses.
  7977. *
  7978. * http://docs.jquery.com/UI/Effects/
  7979. */
  7980. ;jQuery.effects || (function($) {
  7981. $.effects = {};
  7982. /******************************************************************************/
  7983. /****************************** COLOR ANIMATIONS ******************************/
  7984. /******************************************************************************/
  7985. // override the animation for color styles
  7986. $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
  7987. 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'],
  7988. function(i, attr) {
  7989. $.fx.step[attr] = function(fx) {
  7990. if (!fx.colorInit) {
  7991. fx.start = getColor(fx.elem, attr);
  7992. fx.end = getRGB(fx.end);
  7993. fx.colorInit = true;
  7994. }
  7995. fx.elem.style[attr] = 'rgb(' +
  7996. Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
  7997. Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
  7998. Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
  7999. };
  8000. });
  8001. // Color Conversion functions from highlightFade
  8002. // By Blair Mitchelmore
  8003. // http://jquery.offput.ca/highlightFade/
  8004. // Parse strings looking for color tuples [255,255,255]
  8005. function getRGB(color) {
  8006. var result;
  8007. // Check if we're already dealing with an array of colors
  8008. if ( color && color.constructor == Array && color.length == 3 )
  8009. return color;
  8010. // Look for rgb(num,num,num)
  8011. if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
  8012. return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
  8013. // Look for rgb(num%,num%,num%)
  8014. if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
  8015. return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
  8016. // Look for #a0b1c2
  8017. if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
  8018. return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
  8019. // Look for #fff
  8020. if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
  8021. return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
  8022. // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
  8023. if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
  8024. return colors['transparent'];
  8025. // Otherwise, we're most likely dealing with a named color
  8026. return colors[$.trim(color).toLowerCase()];
  8027. }
  8028. function getColor(elem, attr) {
  8029. var color;
  8030. do {
  8031. color = $.curCSS(elem, attr);
  8032. // Keep going until we find an element that has color, or we hit the body
  8033. if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
  8034. break;
  8035. attr = "backgroundColor";
  8036. } while ( elem = elem.parentNode );
  8037. return getRGB(color);
  8038. };
  8039. // Some named colors to work with
  8040. // From Interface by Stefan Petre
  8041. // http://interface.eyecon.ro/
  8042. var colors = {
  8043. aqua:[0,255,255],
  8044. azure:[240,255,255],
  8045. beige:[245,245,220],
  8046. black:[0,0,0],
  8047. blue:[0,0,255],
  8048. brown:[165,42,42],
  8049. cyan:[0,255,255],
  8050. darkblue:[0,0,139],
  8051. darkcyan:[0,139,139],
  8052. darkgrey:[169,169,169],
  8053. darkgreen:[0,100,0],
  8054. darkkhaki:[189,183,107],
  8055. darkmagenta:[139,0,139],
  8056. darkolivegreen:[85,107,47],
  8057. darkorange:[255,140,0],
  8058. darkorchid:[153,50,204],
  8059. darkred:[139,0,0],
  8060. darksalmon:[233,150,122],
  8061. darkviolet:[148,0,211],
  8062. fuchsia:[255,0,255],
  8063. gold:[255,215,0],
  8064. green:[0,128,0],
  8065. indigo:[75,0,130],
  8066. khaki:[240,230,140],
  8067. lightblue:[173,216,230],
  8068. lightcyan:[224,255,255],
  8069. lightgreen:[144,238,144],
  8070. lightgrey:[211,211,211],
  8071. lightpink:[255,182,193],
  8072. lightyellow:[255,255,224],
  8073. lime:[0,255,0],
  8074. magenta:[255,0,255],
  8075. maroon:[128,0,0],
  8076. navy:[0,0,128],
  8077. olive:[128,128,0],
  8078. orange:[255,165,0],
  8079. pink:[255,192,203],
  8080. purple:[128,0,128],
  8081. violet:[128,0,128],
  8082. red:[255,0,0],
  8083. silver:[192,192,192],
  8084. white:[255,255,255],
  8085. yellow:[255,255,0],
  8086. transparent: [255,255,255]
  8087. };
  8088. /******************************************************************************/
  8089. /****************************** CLASS ANIMATIONS ******************************/
  8090. /******************************************************************************/
  8091. var classAnimationActions = ['add', 'remove', 'toggle'],
  8092. shorthandStyles = {
  8093. border: 1,
  8094. borderBottom: 1,
  8095. borderColor: 1,
  8096. borderLeft: 1,
  8097. borderRight: 1,
  8098. borderTop: 1,
  8099. borderWidth: 1,
  8100. margin: 1,
  8101. padding: 1
  8102. };
  8103. function getElementStyles() {
  8104. var style = document.defaultView
  8105. ? document.defaultView.getComputedStyle(this, null)
  8106. : this.currentStyle,
  8107. newStyle = {},
  8108. key,
  8109. camelCase;
  8110. // webkit enumerates style porperties
  8111. if (style && style.length && style[0] && style[style[0]]) {
  8112. var len = style.length;
  8113. while (len--) {
  8114. key = style[len];
  8115. if (typeof style[key] == 'string') {
  8116. camelCase = key.replace(/\-(\w)/g, function(all, letter){
  8117. return letter.toUpperCase();
  8118. });
  8119. newStyle[camelCase] = style[key];
  8120. }
  8121. }
  8122. } else {
  8123. for (key in style) {
  8124. if (typeof style[key] === 'string') {
  8125. newStyle[key] = style[key];
  8126. }
  8127. }
  8128. }
  8129. return newStyle;
  8130. }
  8131. function filterStyles(styles) {
  8132. var name, value;
  8133. for (name in styles) {
  8134. value = styles[name];
  8135. if (
  8136. // ignore null and undefined values
  8137. value == null ||
  8138. // ignore functions (when does this occur?)
  8139. $.isFunction(value) ||
  8140. // shorthand styles that need to be expanded
  8141. name in shorthandStyles ||
  8142. // ignore scrollbars (break in IE)
  8143. (/scrollbar/).test(name) ||
  8144. // only colors or values that can be converted to numbers
  8145. (!(/color/i).test(name) && isNaN(parseFloat(value)))
  8146. ) {
  8147. delete styles[name];
  8148. }
  8149. }
  8150. return styles;
  8151. }
  8152. function styleDifference(oldStyle, newStyle) {
  8153. var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
  8154. name;
  8155. for (name in newStyle) {
  8156. if (oldStyle[name] != newStyle[name]) {
  8157. diff[name] = newStyle[name];
  8158. }
  8159. }
  8160. return diff;
  8161. }
  8162. $.effects.animateClass = function(value, duration, easing, callback) {
  8163. if ($.isFunction(easing)) {
  8164. callback = easing;
  8165. easing = null;
  8166. }
  8167. return this.each(function() {
  8168. var that = $(this),
  8169. originalStyleAttr = that.attr('style') || ' ',
  8170. originalStyle = filterStyles(getElementStyles.call(this)),
  8171. newStyle,
  8172. className = that.attr('className');
  8173. $.each(classAnimationActions, function(i, action) {
  8174. if (value[action]) {
  8175. that[action + 'Class'](value[action]);
  8176. }
  8177. });
  8178. newStyle = filterStyles(getElementStyles.call(this));
  8179. that.attr('className', className);
  8180. that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() {
  8181. $.each(classAnimationActions, function(i, action) {
  8182. if (value[action]) { that[action + 'Class'](value[action]); }
  8183. });
  8184. // work around bug in IE by clearing the cssText before setting it
  8185. if (typeof that.attr('style') == 'object') {
  8186. that.attr('style').cssText = '';
  8187. that.attr('style').cssText = originalStyleAttr;
  8188. } else {
  8189. that.attr('style', originalStyleAttr);
  8190. }
  8191. if (callback) { callback.apply(this, arguments); }
  8192. });
  8193. });
  8194. };
  8195. $.fn.extend({
  8196. _addClass: $.fn.addClass,
  8197. addClass: function(classNames, speed, easing, callback) {
  8198. return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
  8199. },
  8200. _removeClass: $.fn.removeClass,
  8201. removeClass: function(classNames,speed,easing,callback) {
  8202. return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
  8203. },
  8204. _toggleClass: $.fn.toggleClass,
  8205. toggleClass: function(classNames, force, speed, easing, callback) {
  8206. if ( typeof force == "boolean" || force === undefined ) {
  8207. if ( !speed ) {
  8208. // without speed parameter;
  8209. return this._toggleClass(classNames, force);
  8210. } else {
  8211. return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
  8212. }
  8213. } else {
  8214. // without switch parameter;
  8215. return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
  8216. }
  8217. },
  8218. switchClass: function(remove,add,speed,easing,callback) {
  8219. return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
  8220. }
  8221. });
  8222. /******************************************************************************/
  8223. /*********************************** EFFECTS **********************************/
  8224. /******************************************************************************/
  8225. $.extend($.effects, {
  8226. version: "1.8",
  8227. // Saves a set of properties in a data storage
  8228. save: function(element, set) {
  8229. for(var i=0; i < set.length; i++) {
  8230. if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
  8231. }
  8232. },
  8233. // Restores a set of previously saved properties from a data storage
  8234. restore: function(element, set) {
  8235. for(var i=0; i < set.length; i++) {
  8236. if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
  8237. }
  8238. },
  8239. setMode: function(el, mode) {
  8240. if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
  8241. return mode;
  8242. },
  8243. getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
  8244. // this should be a little more flexible in the future to handle a string & hash
  8245. var y, x;
  8246. switch (origin[0]) {
  8247. case 'top': y = 0; break;
  8248. case 'middle': y = 0.5; break;
  8249. case 'bottom': y = 1; break;
  8250. default: y = origin[0] / original.height;
  8251. };
  8252. switch (origin[1]) {
  8253. case 'left': x = 0; break;
  8254. case 'center': x = 0.5; break;
  8255. case 'right': x = 1; break;
  8256. default: x = origin[1] / original.width;
  8257. };
  8258. return {x: x, y: y};
  8259. },
  8260. // Wraps the element around a wrapper that copies position properties
  8261. createWrapper: function(element) {
  8262. // if the element is already wrapped, return it
  8263. if (element.parent().is('.ui-effects-wrapper')) {
  8264. return element.parent();
  8265. }
  8266. // wrap the element
  8267. var props = {
  8268. width: element.outerWidth(true),
  8269. height: element.outerHeight(true),
  8270. 'float': element.css('float')
  8271. },
  8272. wrapper = $('<div></div>')
  8273. .addClass('ui-effects-wrapper')
  8274. .css({
  8275. fontSize: '100%',
  8276. background: 'transparent',
  8277. border: 'none',
  8278. margin: 0,
  8279. padding: 0
  8280. });
  8281. element.wrap(wrapper);
  8282. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
  8283. // transfer positioning properties to the wrapper
  8284. if (element.css('position') == 'static') {
  8285. wrapper.css({ position: 'relative' });
  8286. element.css({ position: 'relative' });
  8287. } else {
  8288. $.extend(props, {
  8289. position: element.css('position'),
  8290. zIndex: element.css('z-index')
  8291. });
  8292. $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
  8293. props[pos] = element.css(pos);
  8294. if (isNaN(parseInt(props[pos], 10))) {
  8295. props[pos] = 'auto';
  8296. }
  8297. });
  8298. element.css({position: 'relative', top: 0, left: 0 });
  8299. }
  8300. return wrapper.css(props).show();
  8301. },
  8302. removeWrapper: function(element) {
  8303. if (element.parent().is('.ui-effects-wrapper'))
  8304. return element.parent().replaceWith(element);
  8305. return element;
  8306. },
  8307. setTransition: function(element, list, factor, value) {
  8308. value = value || {};
  8309. $.each(list, function(i, x){
  8310. unit = element.cssUnit(x);
  8311. if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
  8312. });
  8313. return value;
  8314. }
  8315. });
  8316. function _normalizeArguments(effect, options, speed, callback) {
  8317. // shift params for method overloading
  8318. if (typeof effect == 'object') {
  8319. callback = options;
  8320. speed = null;
  8321. options = effect;
  8322. effect = options.effect;
  8323. }
  8324. if ($.isFunction(options)) {
  8325. callback = options;
  8326. speed = null;
  8327. options = {};
  8328. }
  8329. if ($.isFunction(speed)) {
  8330. callback = speed;
  8331. speed = null;
  8332. }
  8333. if (typeof options == 'number' || $.fx.speeds[options]) {
  8334. callback = speed;
  8335. speed = options;
  8336. options = {};
  8337. }
  8338. options = options || {};
  8339. speed = speed || options.duration;
  8340. speed = $.fx.off ? 0 : typeof speed == 'number'
  8341. ? speed : $.fx.speeds[speed] || $.fx.speeds._default;
  8342. callback = callback || options.complete;
  8343. return [effect, options, speed, callback];
  8344. }
  8345. $.fn.extend({
  8346. effect: function(effect, options, speed, callback) {
  8347. var args = _normalizeArguments.apply(this, arguments),
  8348. // TODO: make effects takes actual parameters instead of a hash
  8349. args2 = {
  8350. options: args[1],
  8351. duration: args[2],
  8352. callback: args[3]
  8353. },
  8354. effectMethod = $.effects[effect];
  8355. return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this;
  8356. },
  8357. _show: $.fn.show,
  8358. show: function(speed) {
  8359. if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
  8360. return this._show.apply(this, arguments);
  8361. } else {
  8362. var args = _normalizeArguments.apply(this, arguments);
  8363. args[1].mode = 'show';
  8364. return this.effect.apply(this, args);
  8365. }
  8366. },
  8367. _hide: $.fn.hide,
  8368. hide: function(speed) {
  8369. if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
  8370. return this._hide.apply(this, arguments);
  8371. } else {
  8372. var args = _normalizeArguments.apply(this, arguments);
  8373. args[1].mode = 'hide';
  8374. return this.effect.apply(this, args);
  8375. }
  8376. },
  8377. // jQuery core overloads toggle and create _toggle
  8378. __toggle: $.fn.toggle,
  8379. toggle: function(speed) {
  8380. if (!speed || typeof speed == 'number' || $.fx.speeds[speed] ||
  8381. typeof speed == 'boolean' || $.isFunction(speed)) {
  8382. return this.__toggle.apply(this, arguments);
  8383. } else {
  8384. var args = _normalizeArguments.apply(this, arguments);
  8385. args[1].mode = 'toggle';
  8386. return this.effect.apply(this, args);
  8387. }
  8388. },
  8389. // helper functions
  8390. cssUnit: function(key) {
  8391. var style = this.css(key), val = [];
  8392. $.each( ['em','px','%','pt'], function(i, unit){
  8393. if(style.indexOf(unit) > 0)
  8394. val = [parseFloat(style), unit];
  8395. });
  8396. return val;
  8397. }
  8398. });
  8399. /******************************************************************************/
  8400. /*********************************** EASING ***********************************/
  8401. /******************************************************************************/
  8402. /*
  8403. * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
  8404. *
  8405. * Uses the built in easing capabilities added In jQuery 1.1
  8406. * to offer multiple easing options
  8407. *
  8408. * TERMS OF USE - jQuery Easing
  8409. *
  8410. * Open source under the BSD License.
  8411. *
  8412. * Copyright 2008 George McGinley Smith
  8413. * All rights reserved.
  8414. *
  8415. * Redistribution and use in source and binary forms, with or without modification,
  8416. * are permitted provided that the following conditions are met:
  8417. *
  8418. * Redistributions of source code must retain the above copyright notice, this list of
  8419. * conditions and the following disclaimer.
  8420. * Redistributions in binary form must reproduce the above copyright notice, this list
  8421. * of conditions and the following disclaimer in the documentation and/or other materials
  8422. * provided with the distribution.
  8423. *
  8424. * Neither the name of the author nor the names of contributors may be used to endorse
  8425. * or promote products derived from this software without specific prior written permission.
  8426. *
  8427. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  8428. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  8429. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  8430. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  8431. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  8432. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  8433. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8434. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  8435. * OF THE POSSIBILITY OF SUCH DAMAGE.
  8436. *
  8437. */
  8438. // t: current time, b: begInnIng value, c: change In value, d: duration
  8439. $.easing.jswing = $.easing.swing;
  8440. $.extend($.easing,
  8441. {
  8442. def: 'easeOutQuad',
  8443. swing: function (x, t, b, c, d) {
  8444. //alert($.easing.default);
  8445. return $.easing[$.easing.def](x, t, b, c, d);
  8446. },
  8447. easeInQuad: function (x, t, b, c, d) {
  8448. return c*(t/=d)*t + b;
  8449. },
  8450. easeOutQuad: function (x, t, b, c, d) {
  8451. return -c *(t/=d)*(t-2) + b;
  8452. },
  8453. easeInOutQuad: function (x, t, b, c, d) {
  8454. if ((t/=d/2) < 1) return c/2*t*t + b;
  8455. return -c/2 * ((--t)*(t-2) - 1) + b;
  8456. },
  8457. easeInCubic: function (x, t, b, c, d) {
  8458. return c*(t/=d)*t*t + b;
  8459. },
  8460. easeOutCubic: function (x, t, b, c, d) {
  8461. return c*((t=t/d-1)*t*t + 1) + b;
  8462. },
  8463. easeInOutCubic: function (x, t, b, c, d) {
  8464. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  8465. return c/2*((t-=2)*t*t + 2) + b;
  8466. },
  8467. easeInQuart: function (x, t, b, c, d) {
  8468. return c*(t/=d)*t*t*t + b;
  8469. },
  8470. easeOutQuart: function (x, t, b, c, d) {
  8471. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  8472. },
  8473. easeInOutQuart: function (x, t, b, c, d) {
  8474. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  8475. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  8476. },
  8477. easeInQuint: function (x, t, b, c, d) {
  8478. return c*(t/=d)*t*t*t*t + b;
  8479. },
  8480. easeOutQuint: function (x, t, b, c, d) {
  8481. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  8482. },
  8483. easeInOutQuint: function (x, t, b, c, d) {
  8484. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  8485. return c/2*((t-=2)*t*t*t*t + 2) + b;
  8486. },
  8487. easeInSine: function (x, t, b, c, d) {
  8488. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  8489. },
  8490. easeOutSine: function (x, t, b, c, d) {
  8491. return c * Math.sin(t/d * (Math.PI/2)) + b;
  8492. },
  8493. easeInOutSine: function (x, t, b, c, d) {
  8494. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  8495. },
  8496. easeInExpo: function (x, t, b, c, d) {
  8497. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  8498. },
  8499. easeOutExpo: function (x, t, b, c, d) {
  8500. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  8501. },
  8502. easeInOutExpo: function (x, t, b, c, d) {
  8503. if (t==0) return b;
  8504. if (t==d) return b+c;
  8505. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  8506. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  8507. },
  8508. easeInCirc: function (x, t, b, c, d) {
  8509. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  8510. },
  8511. easeOutCirc: function (x, t, b, c, d) {
  8512. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  8513. },
  8514. easeInOutCirc: function (x, t, b, c, d) {
  8515. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  8516. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  8517. },
  8518. easeInElastic: function (x, t, b, c, d) {
  8519. var s=1.70158;var p=0;var a=c;
  8520. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  8521. if (a < Math.abs(c)) { a=c; var s=p/4; }
  8522. else var s = p/(2*Math.PI) * Math.asin (c/a);
  8523. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  8524. },
  8525. easeOutElastic: function (x, t, b, c, d) {
  8526. var s=1.70158;var p=0;var a=c;
  8527. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  8528. if (a < Math.abs(c)) { a=c; var s=p/4; }
  8529. else var s = p/(2*Math.PI) * Math.asin (c/a);
  8530. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  8531. },
  8532. easeInOutElastic: function (x, t, b, c, d) {
  8533. var s=1.70158;var p=0;var a=c;
  8534. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  8535. if (a < Math.abs(c)) { a=c; var s=p/4; }
  8536. else var s = p/(2*Math.PI) * Math.asin (c/a);
  8537. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  8538. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  8539. },
  8540. easeInBack: function (x, t, b, c, d, s) {
  8541. if (s == undefined) s = 1.70158;
  8542. return c*(t/=d)*t*((s+1)*t - s) + b;
  8543. },
  8544. easeOutBack: function (x, t, b, c, d, s) {
  8545. if (s == undefined) s = 1.70158;
  8546. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  8547. },
  8548. easeInOutBack: function (x, t, b, c, d, s) {
  8549. if (s == undefined) s = 1.70158;
  8550. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  8551. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  8552. },
  8553. easeInBounce: function (x, t, b, c, d) {
  8554. return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  8555. },
  8556. easeOutBounce: function (x, t, b, c, d) {
  8557. if ((t/=d) < (1/2.75)) {
  8558. return c*(7.5625*t*t) + b;
  8559. } else if (t < (2/2.75)) {
  8560. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  8561. } else if (t < (2.5/2.75)) {
  8562. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  8563. } else {
  8564. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  8565. }
  8566. },
  8567. easeInOutBounce: function (x, t, b, c, d) {
  8568. if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  8569. return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  8570. }
  8571. });
  8572. /*
  8573. *
  8574. * TERMS OF USE - EASING EQUATIONS
  8575. *
  8576. * Open source under the BSD License.
  8577. *
  8578. * Copyright 2001 Robert Penner
  8579. * All rights reserved.
  8580. *
  8581. * Redistribution and use in source and binary forms, with or without modification,
  8582. * are permitted provided that the following conditions are met:
  8583. *
  8584. * Redistributions of source code must retain the above copyright notice, this list of
  8585. * conditions and the following disclaimer.
  8586. * Redistributions in binary form must reproduce the above copyright notice, this list
  8587. * of conditions and the following disclaimer in the documentation and/or other materials
  8588. * provided with the distribution.
  8589. *
  8590. * Neither the name of the author nor the names of contributors may be used to endorse
  8591. * or promote products derived from this software without specific prior written permission.
  8592. *
  8593. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  8594. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  8595. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  8596. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  8597. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  8598. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  8599. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8600. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  8601. * OF THE POSSIBILITY OF SUCH DAMAGE.
  8602. *
  8603. */
  8604. })(jQuery);
  8605. /*
  8606. * jQuery UI Effects Blind 1.8
  8607. *
  8608. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8609. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8610. * and GPL (GPL-LICENSE.txt) licenses.
  8611. *
  8612. * http://docs.jquery.com/UI/Effects/Blind
  8613. *
  8614. * Depends:
  8615. * jquery.effects.core.js
  8616. */
  8617. (function($) {
  8618. $.effects.blind = function(o) {
  8619. return this.queue(function() {
  8620. // Create element
  8621. var el = $(this), props = ['position','top','left'];
  8622. // Set options
  8623. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  8624. var direction = o.options.direction || 'vertical'; // Default direction
  8625. // Adjust
  8626. $.effects.save(el, props); el.show(); // Save & Show
  8627. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  8628. var ref = (direction == 'vertical') ? 'height' : 'width';
  8629. var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
  8630. if(mode == 'show') wrapper.css(ref, 0); // Shift
  8631. // Animation
  8632. var animation = {};
  8633. animation[ref] = mode == 'show' ? distance : 0;
  8634. // Animate
  8635. wrapper.animate(animation, o.duration, o.options.easing, function() {
  8636. if(mode == 'hide') el.hide(); // Hide
  8637. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  8638. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  8639. el.dequeue();
  8640. });
  8641. });
  8642. };
  8643. })(jQuery);
  8644. /*
  8645. * jQuery UI Effects Bounce 1.8
  8646. *
  8647. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8648. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8649. * and GPL (GPL-LICENSE.txt) licenses.
  8650. *
  8651. * http://docs.jquery.com/UI/Effects/Bounce
  8652. *
  8653. * Depends:
  8654. * jquery.effects.core.js
  8655. */
  8656. (function($) {
  8657. $.effects.bounce = function(o) {
  8658. return this.queue(function() {
  8659. // Create element
  8660. var el = $(this), props = ['position','top','left'];
  8661. // Set options
  8662. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  8663. var direction = o.options.direction || 'up'; // Default direction
  8664. var distance = o.options.distance || 20; // Default distance
  8665. var times = o.options.times || 5; // Default # of times
  8666. var speed = o.duration || 250; // Default speed per bounce
  8667. if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
  8668. // Adjust
  8669. $.effects.save(el, props); el.show(); // Save & Show
  8670. $.effects.createWrapper(el); // Create Wrapper
  8671. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  8672. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  8673. var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
  8674. if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
  8675. if (mode == 'hide') distance = distance / (times * 2);
  8676. if (mode != 'hide') times--;
  8677. // Animate
  8678. if (mode == 'show') { // Show Bounce
  8679. var animation = {opacity: 1};
  8680. animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  8681. el.animate(animation, speed / 2, o.options.easing);
  8682. distance = distance / 2;
  8683. times--;
  8684. };
  8685. for (var i = 0; i < times; i++) { // Bounces
  8686. var animation1 = {}, animation2 = {};
  8687. animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  8688. animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  8689. el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
  8690. distance = (mode == 'hide') ? distance * 2 : distance / 2;
  8691. };
  8692. if (mode == 'hide') { // Last Bounce
  8693. var animation = {opacity: 0};
  8694. animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  8695. el.animate(animation, speed / 2, o.options.easing, function(){
  8696. el.hide(); // Hide
  8697. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  8698. if(o.callback) o.callback.apply(this, arguments); // Callback
  8699. });
  8700. } else {
  8701. var animation1 = {}, animation2 = {};
  8702. animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  8703. animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  8704. el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
  8705. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  8706. if(o.callback) o.callback.apply(this, arguments); // Callback
  8707. });
  8708. };
  8709. el.queue('fx', function() { el.dequeue(); });
  8710. el.dequeue();
  8711. });
  8712. };
  8713. })(jQuery);
  8714. /*
  8715. * jQuery UI Effects Clip 1.8
  8716. *
  8717. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8718. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8719. * and GPL (GPL-LICENSE.txt) licenses.
  8720. *
  8721. * http://docs.jquery.com/UI/Effects/Clip
  8722. *
  8723. * Depends:
  8724. * jquery.effects.core.js
  8725. */
  8726. (function($) {
  8727. $.effects.clip = function(o) {
  8728. return this.queue(function() {
  8729. // Create element
  8730. var el = $(this), props = ['position','top','left','height','width'];
  8731. // Set options
  8732. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  8733. var direction = o.options.direction || 'vertical'; // Default direction
  8734. // Adjust
  8735. $.effects.save(el, props); el.show(); // Save & Show
  8736. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  8737. var animate = el[0].tagName == 'IMG' ? wrapper : el;
  8738. var ref = {
  8739. size: (direction == 'vertical') ? 'height' : 'width',
  8740. position: (direction == 'vertical') ? 'top' : 'left'
  8741. };
  8742. var distance = (direction == 'vertical') ? animate.height() : animate.width();
  8743. if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
  8744. // Animation
  8745. var animation = {};
  8746. animation[ref.size] = mode == 'show' ? distance : 0;
  8747. animation[ref.position] = mode == 'show' ? 0 : distance / 2;
  8748. // Animate
  8749. animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  8750. if(mode == 'hide') el.hide(); // Hide
  8751. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  8752. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  8753. el.dequeue();
  8754. }});
  8755. });
  8756. };
  8757. })(jQuery);
  8758. /*
  8759. * jQuery UI Effects Drop 1.8
  8760. *
  8761. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8762. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8763. * and GPL (GPL-LICENSE.txt) licenses.
  8764. *
  8765. * http://docs.jquery.com/UI/Effects/Drop
  8766. *
  8767. * Depends:
  8768. * jquery.effects.core.js
  8769. */
  8770. (function($) {
  8771. $.effects.drop = function(o) {
  8772. return this.queue(function() {
  8773. // Create element
  8774. var el = $(this), props = ['position','top','left','opacity'];
  8775. // Set options
  8776. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  8777. var direction = o.options.direction || 'left'; // Default Direction
  8778. // Adjust
  8779. $.effects.save(el, props); el.show(); // Save & Show
  8780. $.effects.createWrapper(el); // Create Wrapper
  8781. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  8782. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  8783. var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
  8784. if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
  8785. // Animation
  8786. var animation = {opacity: mode == 'show' ? 1 : 0};
  8787. animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
  8788. // Animate
  8789. el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  8790. if(mode == 'hide') el.hide(); // Hide
  8791. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  8792. if(o.callback) o.callback.apply(this, arguments); // Callback
  8793. el.dequeue();
  8794. }});
  8795. });
  8796. };
  8797. })(jQuery);
  8798. /*
  8799. * jQuery UI Effects Explode 1.8
  8800. *
  8801. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8802. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8803. * and GPL (GPL-LICENSE.txt) licenses.
  8804. *
  8805. * http://docs.jquery.com/UI/Effects/Explode
  8806. *
  8807. * Depends:
  8808. * jquery.effects.core.js
  8809. */
  8810. (function($) {
  8811. $.effects.explode = function(o) {
  8812. return this.queue(function() {
  8813. var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
  8814. var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
  8815. o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
  8816. var el = $(this).show().css('visibility', 'hidden');
  8817. var offset = el.offset();
  8818. //Substract the margins - not fixing the problem yet.
  8819. offset.top -= parseInt(el.css("marginTop"),10) || 0;
  8820. offset.left -= parseInt(el.css("marginLeft"),10) || 0;
  8821. var width = el.outerWidth(true);
  8822. var height = el.outerHeight(true);
  8823. for(var i=0;i<rows;i++) { // =
  8824. for(var j=0;j<cells;j++) { // ||
  8825. el
  8826. .clone()
  8827. .appendTo('body')
  8828. .wrap('<div></div>')
  8829. .css({
  8830. position: 'absolute',
  8831. visibility: 'visible',
  8832. left: -j*(width/cells),
  8833. top: -i*(height/rows)
  8834. })
  8835. .parent()
  8836. .addClass('ui-effects-explode')
  8837. .css({
  8838. position: 'absolute',
  8839. overflow: 'hidden',
  8840. width: width/cells,
  8841. height: height/rows,
  8842. left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
  8843. top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
  8844. opacity: o.options.mode == 'show' ? 0 : 1
  8845. }).animate({
  8846. left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
  8847. top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
  8848. opacity: o.options.mode == 'show' ? 1 : 0
  8849. }, o.duration || 500);
  8850. }
  8851. }
  8852. // Set a timeout, to call the callback approx. when the other animations have finished
  8853. setTimeout(function() {
  8854. o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
  8855. if(o.callback) o.callback.apply(el[0]); // Callback
  8856. el.dequeue();
  8857. $('div.ui-effects-explode').remove();
  8858. }, o.duration || 500);
  8859. });
  8860. };
  8861. })(jQuery);
  8862. /*
  8863. * jQuery UI Effects Fold 1.8
  8864. *
  8865. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8866. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8867. * and GPL (GPL-LICENSE.txt) licenses.
  8868. *
  8869. * http://docs.jquery.com/UI/Effects/Fold
  8870. *
  8871. * Depends:
  8872. * jquery.effects.core.js
  8873. */
  8874. (function($) {
  8875. $.effects.fold = function(o) {
  8876. return this.queue(function() {
  8877. // Create element
  8878. var el = $(this), props = ['position','top','left'];
  8879. // Set options
  8880. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  8881. var size = o.options.size || 15; // Default fold size
  8882. var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
  8883. var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
  8884. // Adjust
  8885. $.effects.save(el, props); el.show(); // Save & Show
  8886. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  8887. var widthFirst = ((mode == 'show') != horizFirst);
  8888. var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
  8889. var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
  8890. var percent = /([0-9]+)%/.exec(size);
  8891. if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1];
  8892. if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
  8893. // Animation
  8894. var animation1 = {}, animation2 = {};
  8895. animation1[ref[0]] = mode == 'show' ? distance[0] : size;
  8896. animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
  8897. // Animate
  8898. wrapper.animate(animation1, duration, o.options.easing)
  8899. .animate(animation2, duration, o.options.easing, function() {
  8900. if(mode == 'hide') el.hide(); // Hide
  8901. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  8902. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  8903. el.dequeue();
  8904. });
  8905. });
  8906. };
  8907. })(jQuery);
  8908. /*
  8909. * jQuery UI Effects Highlight 1.8
  8910. *
  8911. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8912. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8913. * and GPL (GPL-LICENSE.txt) licenses.
  8914. *
  8915. * http://docs.jquery.com/UI/Effects/Highlight
  8916. *
  8917. * Depends:
  8918. * jquery.effects.core.js
  8919. */
  8920. (function($) {
  8921. $.effects.highlight = function(o) {
  8922. return this.queue(function() {
  8923. var elem = $(this),
  8924. props = ['backgroundImage', 'backgroundColor', 'opacity'],
  8925. mode = $.effects.setMode(elem, o.options.mode || 'show'),
  8926. animation = {
  8927. backgroundColor: elem.css('backgroundColor')
  8928. };
  8929. if (mode == 'hide') {
  8930. animation.opacity = 0;
  8931. }
  8932. $.effects.save(elem, props);
  8933. elem
  8934. .show()
  8935. .css({
  8936. backgroundImage: 'none',
  8937. backgroundColor: o.options.color || '#ffff99'
  8938. })
  8939. .animate(animation, {
  8940. queue: false,
  8941. duration: o.duration,
  8942. easing: o.options.easing,
  8943. complete: function() {
  8944. (mode == 'hide' && elem.hide());
  8945. $.effects.restore(elem, props);
  8946. (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
  8947. (o.callback && o.callback.apply(this, arguments));
  8948. elem.dequeue();
  8949. }
  8950. });
  8951. });
  8952. };
  8953. })(jQuery);
  8954. /*
  8955. * jQuery UI Effects Pulsate 1.8
  8956. *
  8957. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  8958. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8959. * and GPL (GPL-LICENSE.txt) licenses.
  8960. *
  8961. * http://docs.jquery.com/UI/Effects/Pulsate
  8962. *
  8963. * Depends:
  8964. * jquery.effects.core.js
  8965. */
  8966. (function($) {
  8967. $.effects.pulsate = function(o) {
  8968. return this.queue(function() {
  8969. var elem = $(this),
  8970. mode = $.effects.setMode(elem, o.options.mode || 'show');
  8971. times = ((o.options.times || 5) * 2) - 1;
  8972. duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
  8973. isVisible = elem.is(':visible'),
  8974. animateTo = 0;
  8975. if (!isVisible) {
  8976. elem.css('opacity', 0).show();
  8977. animateTo = 1;
  8978. }
  8979. if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
  8980. times--;
  8981. }
  8982. for (var i = 0; i < times; i++) {
  8983. elem.animate({ opacity: animateTo }, duration, o.options.easing);
  8984. animateTo = (animateTo + 1) % 2;
  8985. }
  8986. elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
  8987. if (animateTo == 0) {
  8988. elem.hide();
  8989. }
  8990. (o.callback && o.callback.apply(this, arguments));
  8991. });
  8992. elem
  8993. .queue('fx', function() { elem.dequeue(); })
  8994. .dequeue();
  8995. });
  8996. };
  8997. })(jQuery);
  8998. /*
  8999. * jQuery UI Effects Scale 1.8
  9000. *
  9001. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  9002. * Dual licensed under the MIT (MIT-LICENSE.txt)
  9003. * and GPL (GPL-LICENSE.txt) licenses.
  9004. *
  9005. * http://docs.jquery.com/UI/Effects/Scale
  9006. *
  9007. * Depends:
  9008. * jquery.effects.core.js
  9009. */
  9010. (function($) {
  9011. $.effects.puff = function(o) {
  9012. return this.queue(function() {
  9013. var elem = $(this),
  9014. mode = $.effects.setMode(elem, o.options.mode || 'hide'),
  9015. percent = parseInt(o.options.percent, 10) || 150,
  9016. factor = percent / 100,
  9017. original = { height: elem.height(), width: elem.width() };
  9018. $.extend(o.options, {
  9019. fade: true,
  9020. mode: mode,
  9021. percent: mode == 'hide' ? percent : 100,
  9022. from: mode == 'hide'
  9023. ? original
  9024. : {
  9025. height: original.height * factor,
  9026. width: original.width * factor
  9027. }
  9028. });
  9029. elem.effect('scale', o.options, o.duration, o.callback);
  9030. elem.dequeue();
  9031. });
  9032. };
  9033. $.effects.scale = function(o) {
  9034. return this.queue(function() {
  9035. // Create element
  9036. var el = $(this);
  9037. // Set options
  9038. var options = $.extend(true, {}, o.options);
  9039. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  9040. var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
  9041. var direction = o.options.direction || 'both'; // Set default axis
  9042. var origin = o.options.origin; // The origin of the scaling
  9043. if (mode != 'effect') { // Set default origin and restore for show/hide
  9044. options.origin = origin || ['middle','center'];
  9045. options.restore = true;
  9046. }
  9047. var original = {height: el.height(), width: el.width()}; // Save original
  9048. el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
  9049. // Adjust
  9050. var factor = { // Set scaling factor
  9051. y: direction != 'horizontal' ? (percent / 100) : 1,
  9052. x: direction != 'vertical' ? (percent / 100) : 1
  9053. };
  9054. el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
  9055. if (o.options.fade) { // Fade option to support puff
  9056. if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
  9057. if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
  9058. };
  9059. // Animation
  9060. options.from = el.from; options.to = el.to; options.mode = mode;
  9061. // Animate
  9062. el.effect('size', options, o.duration, o.callback);
  9063. el.dequeue();
  9064. });
  9065. };
  9066. $.effects.size = function(o) {
  9067. return this.queue(function() {
  9068. // Create element
  9069. var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];
  9070. var props1 = ['position','top','left','overflow','opacity']; // Always restore
  9071. var props2 = ['width','height','overflow']; // Copy for children
  9072. var cProps = ['fontSize'];
  9073. var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
  9074. var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
  9075. // Set options
  9076. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  9077. var restore = o.options.restore || false; // Default restore
  9078. var scale = o.options.scale || 'both'; // Default scale mode
  9079. var origin = o.options.origin; // The origin of the sizing
  9080. var original = {height: el.height(), width: el.width()}; // Save original
  9081. el.from = o.options.from || original; // Default from state
  9082. el.to = o.options.to || original; // Default to state
  9083. // Adjust
  9084. if (origin) { // Calculate baseline shifts
  9085. var baseline = $.effects.getBaseline(origin, original);
  9086. el.from.top = (original.height - el.from.height) * baseline.y;
  9087. el.from.left = (original.width - el.from.width) * baseline.x;
  9088. el.to.top = (original.height - el.to.height) * baseline.y;
  9089. el.to.left = (original.width - el.to.width) * baseline.x;
  9090. };
  9091. var factor = { // Set scaling factor
  9092. from: {y: el.from.height / original.height, x: el.from.width / original.width},
  9093. to: {y: el.to.height / original.height, x: el.to.width / original.width}
  9094. };
  9095. if (scale == 'box' || scale == 'both') { // Scale the css box
  9096. if (factor.from.y != factor.to.y) { // Vertical props scaling
  9097. props = props.concat(vProps);
  9098. el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
  9099. el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
  9100. };
  9101. if (factor.from.x != factor.to.x) { // Horizontal props scaling
  9102. props = props.concat(hProps);
  9103. el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
  9104. el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
  9105. };
  9106. };
  9107. if (scale == 'content' || scale == 'both') { // Scale the content
  9108. if (factor.from.y != factor.to.y) { // Vertical props scaling
  9109. props = props.concat(cProps);
  9110. el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
  9111. el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
  9112. };
  9113. };
  9114. $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
  9115. $.effects.createWrapper(el); // Create Wrapper
  9116. el.css('overflow','hidden').css(el.from); // Shift
  9117. // Animate
  9118. if (scale == 'content' || scale == 'both') { // Scale the children
  9119. vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
  9120. hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
  9121. props2 = props.concat(vProps).concat(hProps); // Concat
  9122. el.find("*[width]").each(function(){
  9123. child = $(this);
  9124. if (restore) $.effects.save(child, props2);
  9125. var c_original = {height: child.height(), width: child.width()}; // Save original
  9126. child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
  9127. child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
  9128. if (factor.from.y != factor.to.y) { // Vertical props scaling
  9129. child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
  9130. child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
  9131. };
  9132. if (factor.from.x != factor.to.x) { // Horizontal props scaling
  9133. child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
  9134. child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
  9135. };
  9136. child.css(child.from); // Shift children
  9137. child.animate(child.to, o.duration, o.options.easing, function(){
  9138. if (restore) $.effects.restore(child, props2); // Restore children
  9139. }); // Animate children
  9140. });
  9141. };
  9142. // Animate
  9143. el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  9144. if (el.to.opacity === 0) {
  9145. el.css('opacity', el.from.opacity);
  9146. }
  9147. if(mode == 'hide') el.hide(); // Hide
  9148. $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
  9149. if(o.callback) o.callback.apply(this, arguments); // Callback
  9150. el.dequeue();
  9151. }});
  9152. });
  9153. };
  9154. })(jQuery);
  9155. /*
  9156. * jQuery UI Effects Shake 1.8
  9157. *
  9158. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  9159. * Dual licensed under the MIT (MIT-LICENSE.txt)
  9160. * and GPL (GPL-LICENSE.txt) licenses.
  9161. *
  9162. * http://docs.jquery.com/UI/Effects/Shake
  9163. *
  9164. * Depends:
  9165. * jquery.effects.core.js
  9166. */
  9167. (function($) {
  9168. $.effects.shake = function(o) {
  9169. return this.queue(function() {
  9170. // Create element
  9171. var el = $(this), props = ['position','top','left'];
  9172. // Set options
  9173. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  9174. var direction = o.options.direction || 'left'; // Default direction
  9175. var distance = o.options.distance || 20; // Default distance
  9176. var times = o.options.times || 3; // Default # of times
  9177. var speed = o.duration || o.options.duration || 140; // Default speed per shake
  9178. // Adjust
  9179. $.effects.save(el, props); el.show(); // Save & Show
  9180. $.effects.createWrapper(el); // Create Wrapper
  9181. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  9182. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  9183. // Animation
  9184. var animation = {}, animation1 = {}, animation2 = {};
  9185. animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  9186. animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2;
  9187. animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2;
  9188. // Animate
  9189. el.animate(animation, speed, o.options.easing);
  9190. for (var i = 1; i < times; i++) { // Shakes
  9191. el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
  9192. };
  9193. el.animate(animation1, speed, o.options.easing).
  9194. animate(animation, speed / 2, o.options.easing, function(){ // Last shake
  9195. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  9196. if(o.callback) o.callback.apply(this, arguments); // Callback
  9197. });
  9198. el.queue('fx', function() { el.dequeue(); });
  9199. el.dequeue();
  9200. });
  9201. };
  9202. })(jQuery);
  9203. /*
  9204. * jQuery UI Effects Slide 1.8
  9205. *
  9206. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  9207. * Dual licensed under the MIT (MIT-LICENSE.txt)
  9208. * and GPL (GPL-LICENSE.txt) licenses.
  9209. *
  9210. * http://docs.jquery.com/UI/Effects/Slide
  9211. *
  9212. * Depends:
  9213. * jquery.effects.core.js
  9214. */
  9215. (function($) {
  9216. $.effects.slide = function(o) {
  9217. return this.queue(function() {
  9218. // Create element
  9219. var el = $(this), props = ['position','top','left'];
  9220. // Set options
  9221. var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
  9222. var direction = o.options.direction || 'left'; // Default Direction
  9223. // Adjust
  9224. $.effects.save(el, props); el.show(); // Save & Show
  9225. $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  9226. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  9227. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  9228. var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
  9229. if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift
  9230. // Animation
  9231. var animation = {};
  9232. animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
  9233. // Animate
  9234. el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  9235. if(mode == 'hide') el.hide(); // Hide
  9236. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  9237. if(o.callback) o.callback.apply(this, arguments); // Callback
  9238. el.dequeue();
  9239. }});
  9240. });
  9241. };
  9242. })(jQuery);
  9243. /*
  9244. * jQuery UI Effects Transfer 1.8
  9245. *
  9246. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  9247. * Dual licensed under the MIT (MIT-LICENSE.txt)
  9248. * and GPL (GPL-LICENSE.txt) licenses.
  9249. *
  9250. * http://docs.jquery.com/UI/Effects/Transfer
  9251. *
  9252. * Depends:
  9253. * jquery.effects.core.js
  9254. */
  9255. (function($) {
  9256. $.effects.transfer = function(o) {
  9257. return this.queue(function() {
  9258. var elem = $(this),
  9259. target = $(o.options.to),
  9260. endPosition = target.offset(),
  9261. animation = {
  9262. top: endPosition.top,
  9263. left: endPosition.left,
  9264. height: target.innerHeight(),
  9265. width: target.innerWidth()
  9266. },
  9267. startPosition = elem.offset(),
  9268. transfer = $('<div class="ui-effects-transfer"></div>')
  9269. .appendTo(document.body)
  9270. .addClass(o.options.className)
  9271. .css({
  9272. top: startPosition.top,
  9273. left: startPosition.left,
  9274. height: elem.innerHeight(),
  9275. width: elem.innerWidth(),
  9276. position: 'absolute'
  9277. })
  9278. .animate(animation, o.duration, o.options.easing, function() {
  9279. transfer.remove();
  9280. (o.callback && o.callback.apply(elem[0], arguments));
  9281. elem.dequeue();
  9282. });
  9283. });
  9284. };
  9285. })(jQuery);