Greasy Fork is available in English.

jQueryUI custom build

Custom jQueryUI v1.11.4 build only including core.js, widget.js, mouse.js, draggable.js

אין להתקין סקריפט זה ישירות. זוהי ספריה עבור סקריפטים אחרים // @require https://update.greatest.deepsurf.us/scripts/454988/1118197/jQueryUI%20custom%20build.js

  1. /*! jQuery UI - v1.11.4 - 2022-11-17
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, draggable.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5.  
  6. (function( factory ) {
  7. if ( typeof define === "function" && define.amd ) {
  8.  
  9. // AMD. Register as an anonymous module.
  10. define([ "jquery" ], factory );
  11. } else {
  12.  
  13. // Browser globals
  14. factory( jQuery );
  15. }
  16. }(function( $ ) {
  17. /*!
  18. * jQuery UI Core 1.11.4
  19. * http://jqueryui.com
  20. *
  21. * Copyright jQuery Foundation and other contributors
  22. * Released under the MIT license.
  23. * http://jquery.org/license
  24. *
  25. * http://api.jqueryui.com/category/ui-core/
  26. */
  27.  
  28.  
  29. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  30. $.ui = $.ui || {};
  31.  
  32. $.extend( $.ui, {
  33. version: "1.11.4",
  34.  
  35. keyCode: {
  36. BACKSPACE: 8,
  37. COMMA: 188,
  38. DELETE: 46,
  39. DOWN: 40,
  40. END: 35,
  41. ENTER: 13,
  42. ESCAPE: 27,
  43. HOME: 36,
  44. LEFT: 37,
  45. PAGE_DOWN: 34,
  46. PAGE_UP: 33,
  47. PERIOD: 190,
  48. RIGHT: 39,
  49. SPACE: 32,
  50. TAB: 9,
  51. UP: 38
  52. }
  53. });
  54.  
  55. // plugins
  56. $.fn.extend({
  57. scrollParent: function( includeHidden ) {
  58. var position = this.css( "position" ),
  59. excludeStaticParent = position === "absolute",
  60. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  61. scrollParent = this.parents().filter( function() {
  62. var parent = $( this );
  63. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  64. return false;
  65. }
  66. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  67. }).eq( 0 );
  68.  
  69. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  70. },
  71.  
  72. uniqueId: (function() {
  73. var uuid = 0;
  74.  
  75. return function() {
  76. return this.each(function() {
  77. if ( !this.id ) {
  78. this.id = "ui-id-" + ( ++uuid );
  79. }
  80. });
  81. };
  82. })(),
  83.  
  84. removeUniqueId: function() {
  85. return this.each(function() {
  86. if ( /^ui-id-\d+$/.test( this.id ) ) {
  87. $( this ).removeAttr( "id" );
  88. }
  89. });
  90. }
  91. });
  92.  
  93. // selectors
  94. function focusable( element, isTabIndexNotNaN ) {
  95. var map, mapName, img,
  96. nodeName = element.nodeName.toLowerCase();
  97. if ( "area" === nodeName ) {
  98. map = element.parentNode;
  99. mapName = map.name;
  100. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  101. return false;
  102. }
  103. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  104. return !!img && visible( img );
  105. }
  106. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  107. !element.disabled :
  108. "a" === nodeName ?
  109. element.href || isTabIndexNotNaN :
  110. isTabIndexNotNaN) &&
  111. // the element and all of its ancestors must be visible
  112. visible( element );
  113. }
  114.  
  115. function visible( element ) {
  116. return $.expr.filters.visible( element ) &&
  117. !$( element ).parents().addBack().filter(function() {
  118. return $.css( this, "visibility" ) === "hidden";
  119. }).length;
  120. }
  121.  
  122. $.extend( $.expr[ ":" ], {
  123. data: $.expr.createPseudo ?
  124. $.expr.createPseudo(function( dataName ) {
  125. return function( elem ) {
  126. return !!$.data( elem, dataName );
  127. };
  128. }) :
  129. // support: jQuery <1.8
  130. function( elem, i, match ) {
  131. return !!$.data( elem, match[ 3 ] );
  132. },
  133.  
  134. focusable: function( element ) {
  135. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  136. },
  137.  
  138. tabbable: function( element ) {
  139. var tabIndex = $.attr( element, "tabindex" ),
  140. isTabIndexNaN = isNaN( tabIndex );
  141. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  142. }
  143. });
  144.  
  145. // support: jQuery <1.8
  146. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  147. $.each( [ "Width", "Height" ], function( i, name ) {
  148. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  149. type = name.toLowerCase(),
  150. orig = {
  151. innerWidth: $.fn.innerWidth,
  152. innerHeight: $.fn.innerHeight,
  153. outerWidth: $.fn.outerWidth,
  154. outerHeight: $.fn.outerHeight
  155. };
  156.  
  157. function reduce( elem, size, border, margin ) {
  158. $.each( side, function() {
  159. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  160. if ( border ) {
  161. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  162. }
  163. if ( margin ) {
  164. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  165. }
  166. });
  167. return size;
  168. }
  169.  
  170. $.fn[ "inner" + name ] = function( size ) {
  171. if ( size === undefined ) {
  172. return orig[ "inner" + name ].call( this );
  173. }
  174.  
  175. return this.each(function() {
  176. $( this ).css( type, reduce( this, size ) + "px" );
  177. });
  178. };
  179.  
  180. $.fn[ "outer" + name] = function( size, margin ) {
  181. if ( typeof size !== "number" ) {
  182. return orig[ "outer" + name ].call( this, size );
  183. }
  184.  
  185. return this.each(function() {
  186. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  187. });
  188. };
  189. });
  190. }
  191.  
  192. // support: jQuery <1.8
  193. if ( !$.fn.addBack ) {
  194. $.fn.addBack = function( selector ) {
  195. return this.add( selector == null ?
  196. this.prevObject : this.prevObject.filter( selector )
  197. );
  198. };
  199. }
  200.  
  201. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  202. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  203. $.fn.removeData = (function( removeData ) {
  204. return function( key ) {
  205. if ( arguments.length ) {
  206. return removeData.call( this, $.camelCase( key ) );
  207. } else {
  208. return removeData.call( this );
  209. }
  210. };
  211. })( $.fn.removeData );
  212. }
  213.  
  214. // deprecated
  215. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  216.  
  217. $.fn.extend({
  218. focus: (function( orig ) {
  219. return function( delay, fn ) {
  220. return typeof delay === "number" ?
  221. this.each(function() {
  222. var elem = this;
  223. setTimeout(function() {
  224. $( elem ).focus();
  225. if ( fn ) {
  226. fn.call( elem );
  227. }
  228. }, delay );
  229. }) :
  230. orig.apply( this, arguments );
  231. };
  232. })( $.fn.focus ),
  233.  
  234. disableSelection: (function() {
  235. var eventType = "onselectstart" in document.createElement( "div" ) ?
  236. "selectstart" :
  237. "mousedown";
  238.  
  239. return function() {
  240. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  241. event.preventDefault();
  242. });
  243. };
  244. })(),
  245.  
  246. enableSelection: function() {
  247. return this.unbind( ".ui-disableSelection" );
  248. },
  249.  
  250. zIndex: function( zIndex ) {
  251. if ( zIndex !== undefined ) {
  252. return this.css( "zIndex", zIndex );
  253. }
  254.  
  255. if ( this.length ) {
  256. var elem = $( this[ 0 ] ), position, value;
  257. while ( elem.length && elem[ 0 ] !== document ) {
  258. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  259. // This makes behavior of this function consistent across browsers
  260. // WebKit always returns auto if the element is positioned
  261. position = elem.css( "position" );
  262. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  263. // IE returns 0 when zIndex is not specified
  264. // other browsers return a string
  265. // we ignore the case of nested elements with an explicit value of 0
  266. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  267. value = parseInt( elem.css( "zIndex" ), 10 );
  268. if ( !isNaN( value ) && value !== 0 ) {
  269. return value;
  270. }
  271. }
  272. elem = elem.parent();
  273. }
  274. }
  275.  
  276. return 0;
  277. }
  278. });
  279.  
  280. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  281. $.ui.plugin = {
  282. add: function( module, option, set ) {
  283. var i,
  284. proto = $.ui[ module ].prototype;
  285. for ( i in set ) {
  286. proto.plugins[ i ] = proto.plugins[ i ] || [];
  287. proto.plugins[ i ].push( [ option, set[ i ] ] );
  288. }
  289. },
  290. call: function( instance, name, args, allowDisconnected ) {
  291. var i,
  292. set = instance.plugins[ name ];
  293.  
  294. if ( !set ) {
  295. return;
  296. }
  297.  
  298. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  299. return;
  300. }
  301.  
  302. for ( i = 0; i < set.length; i++ ) {
  303. if ( instance.options[ set[ i ][ 0 ] ] ) {
  304. set[ i ][ 1 ].apply( instance.element, args );
  305. }
  306. }
  307. }
  308. };
  309.  
  310.  
  311. /*!
  312. * jQuery UI Widget 1.11.4
  313. * http://jqueryui.com
  314. *
  315. * Copyright jQuery Foundation and other contributors
  316. * Released under the MIT license.
  317. * http://jquery.org/license
  318. *
  319. * http://api.jqueryui.com/jQuery.widget/
  320. */
  321.  
  322.  
  323. var widget_uuid = 0,
  324. widget_slice = Array.prototype.slice;
  325.  
  326. $.cleanData = (function( orig ) {
  327. return function( elems ) {
  328. var events, elem, i;
  329. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  330. try {
  331.  
  332. // Only trigger remove when necessary to save time
  333. events = $._data( elem, "events" );
  334. if ( events && events.remove ) {
  335. $( elem ).triggerHandler( "remove" );
  336. }
  337.  
  338. // http://bugs.jquery.com/ticket/8235
  339. } catch ( e ) {}
  340. }
  341. orig( elems );
  342. };
  343. })( $.cleanData );
  344.  
  345. $.widget = function( name, base, prototype ) {
  346. var fullName, existingConstructor, constructor, basePrototype,
  347. // proxiedPrototype allows the provided prototype to remain unmodified
  348. // so that it can be used as a mixin for multiple widgets (#8876)
  349. proxiedPrototype = {},
  350. namespace = name.split( "." )[ 0 ];
  351.  
  352. name = name.split( "." )[ 1 ];
  353. fullName = namespace + "-" + name;
  354.  
  355. if ( !prototype ) {
  356. prototype = base;
  357. base = $.Widget;
  358. }
  359.  
  360. // create selector for plugin
  361. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  362. return !!$.data( elem, fullName );
  363. };
  364.  
  365. $[ namespace ] = $[ namespace ] || {};
  366. existingConstructor = $[ namespace ][ name ];
  367. constructor = $[ namespace ][ name ] = function( options, element ) {
  368. // allow instantiation without "new" keyword
  369. if ( !this._createWidget ) {
  370. return new constructor( options, element );
  371. }
  372.  
  373. // allow instantiation without initializing for simple inheritance
  374. // must use "new" keyword (the code above always passes args)
  375. if ( arguments.length ) {
  376. this._createWidget( options, element );
  377. }
  378. };
  379. // extend with the existing constructor to carry over any static properties
  380. $.extend( constructor, existingConstructor, {
  381. version: prototype.version,
  382. // copy the object used to create the prototype in case we need to
  383. // redefine the widget later
  384. _proto: $.extend( {}, prototype ),
  385. // track widgets that inherit from this widget in case this widget is
  386. // redefined after a widget inherits from it
  387. _childConstructors: []
  388. });
  389.  
  390. basePrototype = new base();
  391. // we need to make the options hash a property directly on the new instance
  392. // otherwise we'll modify the options hash on the prototype that we're
  393. // inheriting from
  394. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  395. $.each( prototype, function( prop, value ) {
  396. if ( !$.isFunction( value ) ) {
  397. proxiedPrototype[ prop ] = value;
  398. return;
  399. }
  400. proxiedPrototype[ prop ] = (function() {
  401. var _super = function() {
  402. return base.prototype[ prop ].apply( this, arguments );
  403. },
  404. _superApply = function( args ) {
  405. return base.prototype[ prop ].apply( this, args );
  406. };
  407. return function() {
  408. var __super = this._super,
  409. __superApply = this._superApply,
  410. returnValue;
  411.  
  412. this._super = _super;
  413. this._superApply = _superApply;
  414.  
  415. returnValue = value.apply( this, arguments );
  416.  
  417. this._super = __super;
  418. this._superApply = __superApply;
  419.  
  420. return returnValue;
  421. };
  422. })();
  423. });
  424. constructor.prototype = $.widget.extend( basePrototype, {
  425. // TODO: remove support for widgetEventPrefix
  426. // always use the name + a colon as the prefix, e.g., draggable:start
  427. // don't prefix for widgets that aren't DOM-based
  428. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  429. }, proxiedPrototype, {
  430. constructor: constructor,
  431. namespace: namespace,
  432. widgetName: name,
  433. widgetFullName: fullName
  434. });
  435.  
  436. // If this widget is being redefined then we need to find all widgets that
  437. // are inheriting from it and redefine all of them so that they inherit from
  438. // the new version of this widget. We're essentially trying to replace one
  439. // level in the prototype chain.
  440. if ( existingConstructor ) {
  441. $.each( existingConstructor._childConstructors, function( i, child ) {
  442. var childPrototype = child.prototype;
  443.  
  444. // redefine the child widget using the same prototype that was
  445. // originally used, but inherit from the new version of the base
  446. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  447. });
  448. // remove the list of existing child constructors from the old constructor
  449. // so the old child constructors can be garbage collected
  450. delete existingConstructor._childConstructors;
  451. } else {
  452. base._childConstructors.push( constructor );
  453. }
  454.  
  455. $.widget.bridge( name, constructor );
  456.  
  457. return constructor;
  458. };
  459.  
  460. $.widget.extend = function( target ) {
  461. var input = widget_slice.call( arguments, 1 ),
  462. inputIndex = 0,
  463. inputLength = input.length,
  464. key,
  465. value;
  466. for ( ; inputIndex < inputLength; inputIndex++ ) {
  467. for ( key in input[ inputIndex ] ) {
  468. value = input[ inputIndex ][ key ];
  469. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  470. // Clone objects
  471. if ( $.isPlainObject( value ) ) {
  472. target[ key ] = $.isPlainObject( target[ key ] ) ?
  473. $.widget.extend( {}, target[ key ], value ) :
  474. // Don't extend strings, arrays, etc. with objects
  475. $.widget.extend( {}, value );
  476. // Copy everything else by reference
  477. } else {
  478. target[ key ] = value;
  479. }
  480. }
  481. }
  482. }
  483. return target;
  484. };
  485.  
  486. $.widget.bridge = function( name, object ) {
  487. var fullName = object.prototype.widgetFullName || name;
  488. $.fn[ name ] = function( options ) {
  489. var isMethodCall = typeof options === "string",
  490. args = widget_slice.call( arguments, 1 ),
  491. returnValue = this;
  492.  
  493. if ( isMethodCall ) {
  494. this.each(function() {
  495. var methodValue,
  496. instance = $.data( this, fullName );
  497. if ( options === "instance" ) {
  498. returnValue = instance;
  499. return false;
  500. }
  501. if ( !instance ) {
  502. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  503. "attempted to call method '" + options + "'" );
  504. }
  505. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  506. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  507. }
  508. methodValue = instance[ options ].apply( instance, args );
  509. if ( methodValue !== instance && methodValue !== undefined ) {
  510. returnValue = methodValue && methodValue.jquery ?
  511. returnValue.pushStack( methodValue.get() ) :
  512. methodValue;
  513. return false;
  514. }
  515. });
  516. } else {
  517.  
  518. // Allow multiple hashes to be passed on init
  519. if ( args.length ) {
  520. options = $.widget.extend.apply( null, [ options ].concat(args) );
  521. }
  522.  
  523. this.each(function() {
  524. var instance = $.data( this, fullName );
  525. if ( instance ) {
  526. instance.option( options || {} );
  527. if ( instance._init ) {
  528. instance._init();
  529. }
  530. } else {
  531. $.data( this, fullName, new object( options, this ) );
  532. }
  533. });
  534. }
  535.  
  536. return returnValue;
  537. };
  538. };
  539.  
  540. $.Widget = function( /* options, element */ ) {};
  541. $.Widget._childConstructors = [];
  542.  
  543. $.Widget.prototype = {
  544. widgetName: "widget",
  545. widgetEventPrefix: "",
  546. defaultElement: "<div>",
  547. options: {
  548. disabled: false,
  549.  
  550. // callbacks
  551. create: null
  552. },
  553. _createWidget: function( options, element ) {
  554. element = $( element || this.defaultElement || this )[ 0 ];
  555. this.element = $( element );
  556. this.uuid = widget_uuid++;
  557. this.eventNamespace = "." + this.widgetName + this.uuid;
  558.  
  559. this.bindings = $();
  560. this.hoverable = $();
  561. this.focusable = $();
  562.  
  563. if ( element !== this ) {
  564. $.data( element, this.widgetFullName, this );
  565. this._on( true, this.element, {
  566. remove: function( event ) {
  567. if ( event.target === element ) {
  568. this.destroy();
  569. }
  570. }
  571. });
  572. this.document = $( element.style ?
  573. // element within the document
  574. element.ownerDocument :
  575. // element is window or document
  576. element.document || element );
  577. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  578. }
  579.  
  580. this.options = $.widget.extend( {},
  581. this.options,
  582. this._getCreateOptions(),
  583. options );
  584.  
  585. this._create();
  586. this._trigger( "create", null, this._getCreateEventData() );
  587. this._init();
  588. },
  589. _getCreateOptions: $.noop,
  590. _getCreateEventData: $.noop,
  591. _create: $.noop,
  592. _init: $.noop,
  593.  
  594. destroy: function() {
  595. this._destroy();
  596. // we can probably remove the unbind calls in 2.0
  597. // all event bindings should go through this._on()
  598. this.element
  599. .unbind( this.eventNamespace )
  600. .removeData( this.widgetFullName )
  601. // support: jquery <1.6.3
  602. // http://bugs.jquery.com/ticket/9413
  603. .removeData( $.camelCase( this.widgetFullName ) );
  604. this.widget()
  605. .unbind( this.eventNamespace )
  606. .removeAttr( "aria-disabled" )
  607. .removeClass(
  608. this.widgetFullName + "-disabled " +
  609. "ui-state-disabled" );
  610.  
  611. // clean up events and states
  612. this.bindings.unbind( this.eventNamespace );
  613. this.hoverable.removeClass( "ui-state-hover" );
  614. this.focusable.removeClass( "ui-state-focus" );
  615. },
  616. _destroy: $.noop,
  617.  
  618. widget: function() {
  619. return this.element;
  620. },
  621.  
  622. option: function( key, value ) {
  623. var options = key,
  624. parts,
  625. curOption,
  626. i;
  627.  
  628. if ( arguments.length === 0 ) {
  629. // don't return a reference to the internal hash
  630. return $.widget.extend( {}, this.options );
  631. }
  632.  
  633. if ( typeof key === "string" ) {
  634. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  635. options = {};
  636. parts = key.split( "." );
  637. key = parts.shift();
  638. if ( parts.length ) {
  639. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  640. for ( i = 0; i < parts.length - 1; i++ ) {
  641. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  642. curOption = curOption[ parts[ i ] ];
  643. }
  644. key = parts.pop();
  645. if ( arguments.length === 1 ) {
  646. return curOption[ key ] === undefined ? null : curOption[ key ];
  647. }
  648. curOption[ key ] = value;
  649. } else {
  650. if ( arguments.length === 1 ) {
  651. return this.options[ key ] === undefined ? null : this.options[ key ];
  652. }
  653. options[ key ] = value;
  654. }
  655. }
  656.  
  657. this._setOptions( options );
  658.  
  659. return this;
  660. },
  661. _setOptions: function( options ) {
  662. var key;
  663.  
  664. for ( key in options ) {
  665. this._setOption( key, options[ key ] );
  666. }
  667.  
  668. return this;
  669. },
  670. _setOption: function( key, value ) {
  671. this.options[ key ] = value;
  672.  
  673. if ( key === "disabled" ) {
  674. this.widget()
  675. .toggleClass( this.widgetFullName + "-disabled", !!value );
  676.  
  677. // If the widget is becoming disabled, then nothing is interactive
  678. if ( value ) {
  679. this.hoverable.removeClass( "ui-state-hover" );
  680. this.focusable.removeClass( "ui-state-focus" );
  681. }
  682. }
  683.  
  684. return this;
  685. },
  686.  
  687. enable: function() {
  688. return this._setOptions({ disabled: false });
  689. },
  690. disable: function() {
  691. return this._setOptions({ disabled: true });
  692. },
  693.  
  694. _on: function( suppressDisabledCheck, element, handlers ) {
  695. var delegateElement,
  696. instance = this;
  697.  
  698. // no suppressDisabledCheck flag, shuffle arguments
  699. if ( typeof suppressDisabledCheck !== "boolean" ) {
  700. handlers = element;
  701. element = suppressDisabledCheck;
  702. suppressDisabledCheck = false;
  703. }
  704.  
  705. // no element argument, shuffle and use this.element
  706. if ( !handlers ) {
  707. handlers = element;
  708. element = this.element;
  709. delegateElement = this.widget();
  710. } else {
  711. element = delegateElement = $( element );
  712. this.bindings = this.bindings.add( element );
  713. }
  714.  
  715. $.each( handlers, function( event, handler ) {
  716. function handlerProxy() {
  717. // allow widgets to customize the disabled handling
  718. // - disabled as an array instead of boolean
  719. // - disabled class as method for disabling individual parts
  720. if ( !suppressDisabledCheck &&
  721. ( instance.options.disabled === true ||
  722. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  723. return;
  724. }
  725. return ( typeof handler === "string" ? instance[ handler ] : handler )
  726. .apply( instance, arguments );
  727. }
  728.  
  729. // copy the guid so direct unbinding works
  730. if ( typeof handler !== "string" ) {
  731. handlerProxy.guid = handler.guid =
  732. handler.guid || handlerProxy.guid || $.guid++;
  733. }
  734.  
  735. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  736. eventName = match[1] + instance.eventNamespace,
  737. selector = match[2];
  738. if ( selector ) {
  739. delegateElement.delegate( selector, eventName, handlerProxy );
  740. } else {
  741. element.bind( eventName, handlerProxy );
  742. }
  743. });
  744. },
  745.  
  746. _off: function( element, eventName ) {
  747. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  748. this.eventNamespace;
  749. element.unbind( eventName ).undelegate( eventName );
  750.  
  751. // Clear the stack to avoid memory leaks (#10056)
  752. this.bindings = $( this.bindings.not( element ).get() );
  753. this.focusable = $( this.focusable.not( element ).get() );
  754. this.hoverable = $( this.hoverable.not( element ).get() );
  755. },
  756.  
  757. _delay: function( handler, delay ) {
  758. function handlerProxy() {
  759. return ( typeof handler === "string" ? instance[ handler ] : handler )
  760. .apply( instance, arguments );
  761. }
  762. var instance = this;
  763. return setTimeout( handlerProxy, delay || 0 );
  764. },
  765.  
  766. _hoverable: function( element ) {
  767. this.hoverable = this.hoverable.add( element );
  768. this._on( element, {
  769. mouseenter: function( event ) {
  770. $( event.currentTarget ).addClass( "ui-state-hover" );
  771. },
  772. mouseleave: function( event ) {
  773. $( event.currentTarget ).removeClass( "ui-state-hover" );
  774. }
  775. });
  776. },
  777.  
  778. _focusable: function( element ) {
  779. this.focusable = this.focusable.add( element );
  780. this._on( element, {
  781. focusin: function( event ) {
  782. $( event.currentTarget ).addClass( "ui-state-focus" );
  783. },
  784. focusout: function( event ) {
  785. $( event.currentTarget ).removeClass( "ui-state-focus" );
  786. }
  787. });
  788. },
  789.  
  790. _trigger: function( type, event, data ) {
  791. var prop, orig,
  792. callback = this.options[ type ];
  793.  
  794. data = data || {};
  795. event = $.Event( event );
  796. event.type = ( type === this.widgetEventPrefix ?
  797. type :
  798. this.widgetEventPrefix + type ).toLowerCase();
  799. // the original event may come from any element
  800. // so we need to reset the target on the new event
  801. event.target = this.element[ 0 ];
  802.  
  803. // copy original event properties over to the new event
  804. orig = event.originalEvent;
  805. if ( orig ) {
  806. for ( prop in orig ) {
  807. if ( !( prop in event ) ) {
  808. event[ prop ] = orig[ prop ];
  809. }
  810. }
  811. }
  812.  
  813. this.element.trigger( event, data );
  814. return !( $.isFunction( callback ) &&
  815. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  816. event.isDefaultPrevented() );
  817. }
  818. };
  819.  
  820. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  821. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  822. if ( typeof options === "string" ) {
  823. options = { effect: options };
  824. }
  825. var hasOptions,
  826. effectName = !options ?
  827. method :
  828. options === true || typeof options === "number" ?
  829. defaultEffect :
  830. options.effect || defaultEffect;
  831. options = options || {};
  832. if ( typeof options === "number" ) {
  833. options = { duration: options };
  834. }
  835. hasOptions = !$.isEmptyObject( options );
  836. options.complete = callback;
  837. if ( options.delay ) {
  838. element.delay( options.delay );
  839. }
  840. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  841. element[ method ]( options );
  842. } else if ( effectName !== method && element[ effectName ] ) {
  843. element[ effectName ]( options.duration, options.easing, callback );
  844. } else {
  845. element.queue(function( next ) {
  846. $( this )[ method ]();
  847. if ( callback ) {
  848. callback.call( element[ 0 ] );
  849. }
  850. next();
  851. });
  852. }
  853. };
  854. });
  855.  
  856. var widget = $.widget;
  857.  
  858.  
  859. /*!
  860. * jQuery UI Mouse 1.11.4
  861. * http://jqueryui.com
  862. *
  863. * Copyright jQuery Foundation and other contributors
  864. * Released under the MIT license.
  865. * http://jquery.org/license
  866. *
  867. * http://api.jqueryui.com/mouse/
  868. */
  869.  
  870.  
  871. var mouseHandled = false;
  872. $( document ).mouseup( function() {
  873. mouseHandled = false;
  874. });
  875.  
  876. var mouse = $.widget("ui.mouse", {
  877. version: "1.11.4",
  878. options: {
  879. cancel: "input,textarea,button,select,option",
  880. distance: 1,
  881. delay: 0
  882. },
  883. _mouseInit: function() {
  884. var that = this;
  885.  
  886. this.element
  887. .bind("mousedown." + this.widgetName, function(event) {
  888. return that._mouseDown(event);
  889. })
  890. .bind("click." + this.widgetName, function(event) {
  891. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  892. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  893. event.stopImmediatePropagation();
  894. return false;
  895. }
  896. });
  897.  
  898. this.started = false;
  899. },
  900.  
  901. // TODO: make sure destroying one instance of mouse doesn't mess with
  902. // other instances of mouse
  903. _mouseDestroy: function() {
  904. this.element.unbind("." + this.widgetName);
  905. if ( this._mouseMoveDelegate ) {
  906. this.document
  907. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  908. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  909. }
  910. },
  911.  
  912. _mouseDown: function(event) {
  913. // don't let more than one widget handle mouseStart
  914. if ( mouseHandled ) {
  915. return;
  916. }
  917.  
  918. this._mouseMoved = false;
  919.  
  920. // we may have missed mouseup (out of window)
  921. (this._mouseStarted && this._mouseUp(event));
  922.  
  923. this._mouseDownEvent = event;
  924.  
  925. var that = this,
  926. btnIsLeft = (event.which === 1),
  927. // event.target.nodeName works around a bug in IE 8 with
  928. // disabled inputs (#7620)
  929. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  930. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  931. return true;
  932. }
  933.  
  934. this.mouseDelayMet = !this.options.delay;
  935. if (!this.mouseDelayMet) {
  936. this._mouseDelayTimer = setTimeout(function() {
  937. that.mouseDelayMet = true;
  938. }, this.options.delay);
  939. }
  940.  
  941. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  942. this._mouseStarted = (this._mouseStart(event) !== false);
  943. if (!this._mouseStarted) {
  944. event.preventDefault();
  945. return true;
  946. }
  947. }
  948.  
  949. // Click event may never have fired (Gecko & Opera)
  950. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  951. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  952. }
  953.  
  954. // these delegates are required to keep context
  955. this._mouseMoveDelegate = function(event) {
  956. return that._mouseMove(event);
  957. };
  958. this._mouseUpDelegate = function(event) {
  959. return that._mouseUp(event);
  960. };
  961.  
  962. this.document
  963. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  964. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  965.  
  966. event.preventDefault();
  967.  
  968. mouseHandled = true;
  969. return true;
  970. },
  971.  
  972. _mouseMove: function(event) {
  973. // Only check for mouseups outside the document if you've moved inside the document
  974. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  975. // fire a mousemove event if content is placed under the cursor. See #7778
  976. // Support: IE <9
  977. if ( this._mouseMoved ) {
  978. // IE mouseup check - mouseup happened when mouse was out of window
  979. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  980. return this._mouseUp(event);
  981.  
  982. // Iframe mouseup check - mouseup occurred in another document
  983. } else if ( !event.which ) {
  984. return this._mouseUp( event );
  985. }
  986. }
  987.  
  988. if ( event.which || event.button ) {
  989. this._mouseMoved = true;
  990. }
  991.  
  992. if (this._mouseStarted) {
  993. this._mouseDrag(event);
  994. return event.preventDefault();
  995. }
  996.  
  997. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  998. this._mouseStarted =
  999. (this._mouseStart(this._mouseDownEvent, event) !== false);
  1000. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  1001. }
  1002.  
  1003. return !this._mouseStarted;
  1004. },
  1005.  
  1006. _mouseUp: function(event) {
  1007. this.document
  1008. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1009. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1010.  
  1011. if (this._mouseStarted) {
  1012. this._mouseStarted = false;
  1013.  
  1014. if (event.target === this._mouseDownEvent.target) {
  1015. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  1016. }
  1017.  
  1018. this._mouseStop(event);
  1019. }
  1020.  
  1021. mouseHandled = false;
  1022. return false;
  1023. },
  1024.  
  1025. _mouseDistanceMet: function(event) {
  1026. return (Math.max(
  1027. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  1028. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  1029. ) >= this.options.distance
  1030. );
  1031. },
  1032.  
  1033. _mouseDelayMet: function(/* event */) {
  1034. return this.mouseDelayMet;
  1035. },
  1036.  
  1037. // These are placeholder methods, to be overriden by extending plugin
  1038. _mouseStart: function(/* event */) {},
  1039. _mouseDrag: function(/* event */) {},
  1040. _mouseStop: function(/* event */) {},
  1041. _mouseCapture: function(/* event */) { return true; }
  1042. });
  1043.  
  1044.  
  1045. /*!
  1046. * jQuery UI Draggable 1.11.4
  1047. * http://jqueryui.com
  1048. *
  1049. * Copyright jQuery Foundation and other contributors
  1050. * Released under the MIT license.
  1051. * http://jquery.org/license
  1052. *
  1053. * http://api.jqueryui.com/draggable/
  1054. */
  1055.  
  1056.  
  1057. $.widget("ui.draggable", $.ui.mouse, {
  1058. version: "1.11.4",
  1059. widgetEventPrefix: "drag",
  1060. options: {
  1061. addClasses: true,
  1062. appendTo: "parent",
  1063. axis: false,
  1064. connectToSortable: false,
  1065. containment: false,
  1066. cursor: "auto",
  1067. cursorAt: false,
  1068. grid: false,
  1069. handle: false,
  1070. helper: "original",
  1071. iframeFix: false,
  1072. opacity: false,
  1073. refreshPositions: false,
  1074. revert: false,
  1075. revertDuration: 500,
  1076. scope: "default",
  1077. scroll: true,
  1078. scrollSensitivity: 20,
  1079. scrollSpeed: 20,
  1080. snap: false,
  1081. snapMode: "both",
  1082. snapTolerance: 20,
  1083. stack: false,
  1084. zIndex: false,
  1085.  
  1086. // callbacks
  1087. drag: null,
  1088. start: null,
  1089. stop: null
  1090. },
  1091. _create: function() {
  1092.  
  1093. if ( this.options.helper === "original" ) {
  1094. this._setPositionRelative();
  1095. }
  1096. if (this.options.addClasses){
  1097. this.element.addClass("ui-draggable");
  1098. }
  1099. if (this.options.disabled){
  1100. this.element.addClass("ui-draggable-disabled");
  1101. }
  1102. this._setHandleClassName();
  1103.  
  1104. this._mouseInit();
  1105. },
  1106.  
  1107. _setOption: function( key, value ) {
  1108. this._super( key, value );
  1109. if ( key === "handle" ) {
  1110. this._removeHandleClassName();
  1111. this._setHandleClassName();
  1112. }
  1113. },
  1114.  
  1115. _destroy: function() {
  1116. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1117. this.destroyOnClear = true;
  1118. return;
  1119. }
  1120. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1121. this._removeHandleClassName();
  1122. this._mouseDestroy();
  1123. },
  1124.  
  1125. _mouseCapture: function(event) {
  1126. var o = this.options;
  1127.  
  1128. this._blurActiveElement( event );
  1129.  
  1130. // among others, prevent a drag on a resizable-handle
  1131. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1132. return false;
  1133. }
  1134.  
  1135. //Quit if we're not on a valid handle
  1136. this.handle = this._getHandle(event);
  1137. if (!this.handle) {
  1138. return false;
  1139. }
  1140.  
  1141. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1142.  
  1143. return true;
  1144.  
  1145. },
  1146.  
  1147. _blockFrames: function( selector ) {
  1148. this.iframeBlocks = this.document.find( selector ).map(function() {
  1149. var iframe = $( this );
  1150.  
  1151. return $( "<div>" )
  1152. .css( "position", "absolute" )
  1153. .appendTo( iframe.parent() )
  1154. .outerWidth( iframe.outerWidth() )
  1155. .outerHeight( iframe.outerHeight() )
  1156. .offset( iframe.offset() )[ 0 ];
  1157. });
  1158. },
  1159.  
  1160. _unblockFrames: function() {
  1161. if ( this.iframeBlocks ) {
  1162. this.iframeBlocks.remove();
  1163. delete this.iframeBlocks;
  1164. }
  1165. },
  1166.  
  1167. _blurActiveElement: function( event ) {
  1168. var document = this.document[ 0 ];
  1169.  
  1170. // Only need to blur if the event occurred on the draggable itself, see #10527
  1171. if ( !this.handleElement.is( event.target ) ) {
  1172. return;
  1173. }
  1174.  
  1175. // support: IE9
  1176. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1177. try {
  1178.  
  1179. // Support: IE9, IE10
  1180. // If the <body> is blurred, IE will switch windows, see #9520
  1181. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  1182.  
  1183. // Blur any element that currently has focus, see #4261
  1184. $( document.activeElement ).blur();
  1185. }
  1186. } catch ( error ) {}
  1187. },
  1188.  
  1189. _mouseStart: function(event) {
  1190.  
  1191. var o = this.options;
  1192.  
  1193. //Create and append the visible helper
  1194. this.helper = this._createHelper(event);
  1195.  
  1196. this.helper.addClass("ui-draggable-dragging");
  1197.  
  1198. //Cache the helper size
  1199. this._cacheHelperProportions();
  1200.  
  1201. //If ddmanager is used for droppables, set the global draggable
  1202. if ($.ui.ddmanager) {
  1203. $.ui.ddmanager.current = this;
  1204. }
  1205.  
  1206. /*
  1207. * - Position generation -
  1208. * This block generates everything position related - it's the core of draggables.
  1209. */
  1210.  
  1211. //Cache the margins of the original element
  1212. this._cacheMargins();
  1213.  
  1214. //Store the helper's css position
  1215. this.cssPosition = this.helper.css( "position" );
  1216. this.scrollParent = this.helper.scrollParent( true );
  1217. this.offsetParent = this.helper.offsetParent();
  1218. this.hasFixedAncestor = this.helper.parents().filter(function() {
  1219. return $( this ).css( "position" ) === "fixed";
  1220. }).length > 0;
  1221.  
  1222. //The element's absolute position on the page minus margins
  1223. this.positionAbs = this.element.offset();
  1224. this._refreshOffsets( event );
  1225.  
  1226. //Generate the original position
  1227. this.originalPosition = this.position = this._generatePosition( event, false );
  1228. this.originalPageX = event.pageX;
  1229. this.originalPageY = event.pageY;
  1230.  
  1231. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1232. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1233.  
  1234. //Set a containment if given in the options
  1235. this._setContainment();
  1236.  
  1237. //Trigger event + callbacks
  1238. if (this._trigger("start", event) === false) {
  1239. this._clear();
  1240. return false;
  1241. }
  1242.  
  1243. //Recache the helper size
  1244. this._cacheHelperProportions();
  1245.  
  1246. //Prepare the droppable offsets
  1247. if ($.ui.ddmanager && !o.dropBehaviour) {
  1248. $.ui.ddmanager.prepareOffsets(this, event);
  1249. }
  1250.  
  1251. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  1252. // as this prevents resizing of elements with right/bottom set (see #7772)
  1253. this._normalizeRightBottom();
  1254.  
  1255. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1256.  
  1257. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1258. if ( $.ui.ddmanager ) {
  1259. $.ui.ddmanager.dragStart(this, event);
  1260. }
  1261.  
  1262. return true;
  1263. },
  1264.  
  1265. _refreshOffsets: function( event ) {
  1266. this.offset = {
  1267. top: this.positionAbs.top - this.margins.top,
  1268. left: this.positionAbs.left - this.margins.left,
  1269. scroll: false,
  1270. parent: this._getParentOffset(),
  1271. relative: this._getRelativeOffset()
  1272. };
  1273.  
  1274. this.offset.click = {
  1275. left: event.pageX - this.offset.left,
  1276. top: event.pageY - this.offset.top
  1277. };
  1278. },
  1279.  
  1280. _mouseDrag: function(event, noPropagation) {
  1281. // reset any necessary cached properties (see #5009)
  1282. if ( this.hasFixedAncestor ) {
  1283. this.offset.parent = this._getParentOffset();
  1284. }
  1285.  
  1286. //Compute the helpers position
  1287. this.position = this._generatePosition( event, true );
  1288. this.positionAbs = this._convertPositionTo("absolute");
  1289.  
  1290. //Call plugins and callbacks and use the resulting position if something is returned
  1291. if (!noPropagation) {
  1292. var ui = this._uiHash();
  1293. if (this._trigger("drag", event, ui) === false) {
  1294. this._mouseUp({});
  1295. return false;
  1296. }
  1297. this.position = ui.position;
  1298. }
  1299.  
  1300. this.helper[ 0 ].style.left = this.position.left + "px";
  1301. this.helper[ 0 ].style.top = this.position.top + "px";
  1302.  
  1303. if ($.ui.ddmanager) {
  1304. $.ui.ddmanager.drag(this, event);
  1305. }
  1306.  
  1307. return false;
  1308. },
  1309.  
  1310. _mouseStop: function(event) {
  1311.  
  1312. //If we are using droppables, inform the manager about the drop
  1313. var that = this,
  1314. dropped = false;
  1315. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1316. dropped = $.ui.ddmanager.drop(this, event);
  1317. }
  1318.  
  1319. //if a drop comes from outside (a sortable)
  1320. if (this.dropped) {
  1321. dropped = this.dropped;
  1322. this.dropped = false;
  1323. }
  1324.  
  1325. 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))) {
  1326. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1327. if (that._trigger("stop", event) !== false) {
  1328. that._clear();
  1329. }
  1330. });
  1331. } else {
  1332. if (this._trigger("stop", event) !== false) {
  1333. this._clear();
  1334. }
  1335. }
  1336.  
  1337. return false;
  1338. },
  1339.  
  1340. _mouseUp: function( event ) {
  1341. this._unblockFrames();
  1342.  
  1343. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1344. if ( $.ui.ddmanager ) {
  1345. $.ui.ddmanager.dragStop(this, event);
  1346. }
  1347.  
  1348. // Only need to focus if the event occurred on the draggable itself, see #10527
  1349. if ( this.handleElement.is( event.target ) ) {
  1350. // The interaction is over; whether or not the click resulted in a drag, focus the element
  1351. this.element.focus();
  1352. }
  1353.  
  1354. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1355. },
  1356.  
  1357. cancel: function() {
  1358.  
  1359. if (this.helper.is(".ui-draggable-dragging")) {
  1360. this._mouseUp({});
  1361. } else {
  1362. this._clear();
  1363. }
  1364.  
  1365. return this;
  1366.  
  1367. },
  1368.  
  1369. _getHandle: function(event) {
  1370. return this.options.handle ?
  1371. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1372. true;
  1373. },
  1374.  
  1375. _setHandleClassName: function() {
  1376. this.handleElement = this.options.handle ?
  1377. this.element.find( this.options.handle ) : this.element;
  1378. this.handleElement.addClass( "ui-draggable-handle" );
  1379. },
  1380.  
  1381. _removeHandleClassName: function() {
  1382. this.handleElement.removeClass( "ui-draggable-handle" );
  1383. },
  1384.  
  1385. _createHelper: function(event) {
  1386.  
  1387. var o = this.options,
  1388. helperIsFunction = $.isFunction( o.helper ),
  1389. helper = helperIsFunction ?
  1390. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1391. ( o.helper === "clone" ?
  1392. this.element.clone().removeAttr( "id" ) :
  1393. this.element );
  1394.  
  1395. if (!helper.parents("body").length) {
  1396. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1397. }
  1398.  
  1399. // http://bugs.jqueryui.com/ticket/9446
  1400. // a helper function can return the original element
  1401. // which wouldn't have been set to relative in _create
  1402. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1403. this._setPositionRelative();
  1404. }
  1405.  
  1406. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1407. helper.css("position", "absolute");
  1408. }
  1409.  
  1410. return helper;
  1411.  
  1412. },
  1413.  
  1414. _setPositionRelative: function() {
  1415. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1416. this.element[ 0 ].style.position = "relative";
  1417. }
  1418. },
  1419.  
  1420. _adjustOffsetFromHelper: function(obj) {
  1421. if (typeof obj === "string") {
  1422. obj = obj.split(" ");
  1423. }
  1424. if ($.isArray(obj)) {
  1425. obj = { left: +obj[0], top: +obj[1] || 0 };
  1426. }
  1427. if ("left" in obj) {
  1428. this.offset.click.left = obj.left + this.margins.left;
  1429. }
  1430. if ("right" in obj) {
  1431. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1432. }
  1433. if ("top" in obj) {
  1434. this.offset.click.top = obj.top + this.margins.top;
  1435. }
  1436. if ("bottom" in obj) {
  1437. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1438. }
  1439. },
  1440.  
  1441. _isRootNode: function( element ) {
  1442. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1443. },
  1444.  
  1445. _getParentOffset: function() {
  1446.  
  1447. //Get the offsetParent and cache its position
  1448. var po = this.offsetParent.offset(),
  1449. document = this.document[ 0 ];
  1450.  
  1451. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1452. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1453. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1454. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1455. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1456. po.left += this.scrollParent.scrollLeft();
  1457. po.top += this.scrollParent.scrollTop();
  1458. }
  1459.  
  1460. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  1461. po = { top: 0, left: 0 };
  1462. }
  1463.  
  1464. return {
  1465. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  1466. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  1467. };
  1468.  
  1469. },
  1470.  
  1471. _getRelativeOffset: function() {
  1472. if ( this.cssPosition !== "relative" ) {
  1473. return { top: 0, left: 0 };
  1474. }
  1475.  
  1476. var p = this.element.position(),
  1477. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1478.  
  1479. return {
  1480. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  1481. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  1482. };
  1483.  
  1484. },
  1485.  
  1486. _cacheMargins: function() {
  1487. this.margins = {
  1488. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  1489. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  1490. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  1491. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  1492. };
  1493. },
  1494.  
  1495. _cacheHelperProportions: function() {
  1496. this.helperProportions = {
  1497. width: this.helper.outerWidth(),
  1498. height: this.helper.outerHeight()
  1499. };
  1500. },
  1501.  
  1502. _setContainment: function() {
  1503.  
  1504. var isUserScrollable, c, ce,
  1505. o = this.options,
  1506. document = this.document[ 0 ];
  1507.  
  1508. this.relativeContainer = null;
  1509.  
  1510. if ( !o.containment ) {
  1511. this.containment = null;
  1512. return;
  1513. }
  1514.  
  1515. if ( o.containment === "window" ) {
  1516. this.containment = [
  1517. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1518. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1519. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1520. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1521. ];
  1522. return;
  1523. }
  1524.  
  1525. if ( o.containment === "document") {
  1526. this.containment = [
  1527. 0,
  1528. 0,
  1529. $( document ).width() - this.helperProportions.width - this.margins.left,
  1530. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1531. ];
  1532. return;
  1533. }
  1534.  
  1535. if ( o.containment.constructor === Array ) {
  1536. this.containment = o.containment;
  1537. return;
  1538. }
  1539.  
  1540. if ( o.containment === "parent" ) {
  1541. o.containment = this.helper[ 0 ].parentNode;
  1542. }
  1543.  
  1544. c = $( o.containment );
  1545. ce = c[ 0 ];
  1546.  
  1547. if ( !ce ) {
  1548. return;
  1549. }
  1550.  
  1551. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  1552.  
  1553. this.containment = [
  1554. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1555. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  1556. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1557. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  1558. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  1559. this.helperProportions.width -
  1560. this.margins.left -
  1561. this.margins.right,
  1562. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1563. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  1564. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  1565. this.helperProportions.height -
  1566. this.margins.top -
  1567. this.margins.bottom
  1568. ];
  1569. this.relativeContainer = c;
  1570. },
  1571.  
  1572. _convertPositionTo: function(d, pos) {
  1573.  
  1574. if (!pos) {
  1575. pos = this.position;
  1576. }
  1577.  
  1578. var mod = d === "absolute" ? 1 : -1,
  1579. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1580.  
  1581. return {
  1582. top: (
  1583. pos.top + // The absolute mouse position
  1584. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1585. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1586. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  1587. ),
  1588. left: (
  1589. pos.left + // The absolute mouse position
  1590. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1591. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1592. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  1593. )
  1594. };
  1595.  
  1596. },
  1597.  
  1598. _generatePosition: function( event, constrainPosition ) {
  1599.  
  1600. var containment, co, top, left,
  1601. o = this.options,
  1602. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  1603. pageX = event.pageX,
  1604. pageY = event.pageY;
  1605.  
  1606. // Cache the scroll
  1607. if ( !scrollIsRootNode || !this.offset.scroll ) {
  1608. this.offset.scroll = {
  1609. top: this.scrollParent.scrollTop(),
  1610. left: this.scrollParent.scrollLeft()
  1611. };
  1612. }
  1613.  
  1614. /*
  1615. * - Position constraining -
  1616. * Constrain the position to a mix of grid, containment.
  1617. */
  1618.  
  1619. // If we are not dragging yet, we won't check for options
  1620. if ( constrainPosition ) {
  1621. if ( this.containment ) {
  1622. if ( this.relativeContainer ){
  1623. co = this.relativeContainer.offset();
  1624. containment = [
  1625. this.containment[ 0 ] + co.left,
  1626. this.containment[ 1 ] + co.top,
  1627. this.containment[ 2 ] + co.left,
  1628. this.containment[ 3 ] + co.top
  1629. ];
  1630. } else {
  1631. containment = this.containment;
  1632. }
  1633.  
  1634. if (event.pageX - this.offset.click.left < containment[0]) {
  1635. pageX = containment[0] + this.offset.click.left;
  1636. }
  1637. if (event.pageY - this.offset.click.top < containment[1]) {
  1638. pageY = containment[1] + this.offset.click.top;
  1639. }
  1640. if (event.pageX - this.offset.click.left > containment[2]) {
  1641. pageX = containment[2] + this.offset.click.left;
  1642. }
  1643. if (event.pageY - this.offset.click.top > containment[3]) {
  1644. pageY = containment[3] + this.offset.click.top;
  1645. }
  1646. }
  1647.  
  1648. if (o.grid) {
  1649. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1650. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1651. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  1652.  
  1653. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1654. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  1655. }
  1656.  
  1657. if ( o.axis === "y" ) {
  1658. pageX = this.originalPageX;
  1659. }
  1660.  
  1661. if ( o.axis === "x" ) {
  1662. pageY = this.originalPageY;
  1663. }
  1664. }
  1665.  
  1666. return {
  1667. top: (
  1668. pageY - // The absolute mouse position
  1669. this.offset.click.top - // Click offset (relative to the element)
  1670. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1671. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1672. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  1673. ),
  1674. left: (
  1675. pageX - // The absolute mouse position
  1676. this.offset.click.left - // Click offset (relative to the element)
  1677. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1678. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1679. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  1680. )
  1681. };
  1682.  
  1683. },
  1684.  
  1685. _clear: function() {
  1686. this.helper.removeClass("ui-draggable-dragging");
  1687. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1688. this.helper.remove();
  1689. }
  1690. this.helper = null;
  1691. this.cancelHelperRemoval = false;
  1692. if ( this.destroyOnClear ) {
  1693. this.destroy();
  1694. }
  1695. },
  1696.  
  1697. _normalizeRightBottom: function() {
  1698. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  1699. this.helper.width( this.helper.width() );
  1700. this.helper.css( "right", "auto" );
  1701. }
  1702. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  1703. this.helper.height( this.helper.height() );
  1704. this.helper.css( "bottom", "auto" );
  1705. }
  1706. },
  1707.  
  1708. // From now on bulk stuff - mainly helpers
  1709.  
  1710. _trigger: function( type, event, ui ) {
  1711. ui = ui || this._uiHash();
  1712. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  1713.  
  1714. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  1715. if ( /^(drag|start|stop)/.test( type ) ) {
  1716. this.positionAbs = this._convertPositionTo( "absolute" );
  1717. ui.offset = this.positionAbs;
  1718. }
  1719. return $.Widget.prototype._trigger.call( this, type, event, ui );
  1720. },
  1721.  
  1722. plugins: {},
  1723.  
  1724. _uiHash: function() {
  1725. return {
  1726. helper: this.helper,
  1727. position: this.position,
  1728. originalPosition: this.originalPosition,
  1729. offset: this.positionAbs
  1730. };
  1731. }
  1732.  
  1733. });
  1734.  
  1735. $.ui.plugin.add( "draggable", "connectToSortable", {
  1736. start: function( event, ui, draggable ) {
  1737. var uiSortable = $.extend( {}, ui, {
  1738. item: draggable.element
  1739. });
  1740.  
  1741. draggable.sortables = [];
  1742. $( draggable.options.connectToSortable ).each(function() {
  1743. var sortable = $( this ).sortable( "instance" );
  1744.  
  1745. if ( sortable && !sortable.options.disabled ) {
  1746. draggable.sortables.push( sortable );
  1747.  
  1748. // refreshPositions is called at drag start to refresh the containerCache
  1749. // which is used in drag. This ensures it's initialized and synchronized
  1750. // with any changes that might have happened on the page since initialization.
  1751. sortable.refreshPositions();
  1752. sortable._trigger("activate", event, uiSortable);
  1753. }
  1754. });
  1755. },
  1756. stop: function( event, ui, draggable ) {
  1757. var uiSortable = $.extend( {}, ui, {
  1758. item: draggable.element
  1759. });
  1760.  
  1761. draggable.cancelHelperRemoval = false;
  1762.  
  1763. $.each( draggable.sortables, function() {
  1764. var sortable = this;
  1765.  
  1766. if ( sortable.isOver ) {
  1767. sortable.isOver = 0;
  1768.  
  1769. // Allow this sortable to handle removing the helper
  1770. draggable.cancelHelperRemoval = true;
  1771. sortable.cancelHelperRemoval = false;
  1772.  
  1773. // Use _storedCSS To restore properties in the sortable,
  1774. // as this also handles revert (#9675) since the draggable
  1775. // may have modified them in unexpected ways (#8809)
  1776. sortable._storedCSS = {
  1777. position: sortable.placeholder.css( "position" ),
  1778. top: sortable.placeholder.css( "top" ),
  1779. left: sortable.placeholder.css( "left" )
  1780. };
  1781.  
  1782. sortable._mouseStop(event);
  1783.  
  1784. // Once drag has ended, the sortable should return to using
  1785. // its original helper, not the shared helper from draggable
  1786. sortable.options.helper = sortable.options._helper;
  1787. } else {
  1788. // Prevent this Sortable from removing the helper.
  1789. // However, don't set the draggable to remove the helper
  1790. // either as another connected Sortable may yet handle the removal.
  1791. sortable.cancelHelperRemoval = true;
  1792.  
  1793. sortable._trigger( "deactivate", event, uiSortable );
  1794. }
  1795. });
  1796. },
  1797. drag: function( event, ui, draggable ) {
  1798. $.each( draggable.sortables, function() {
  1799. var innermostIntersecting = false,
  1800. sortable = this;
  1801.  
  1802. // Copy over variables that sortable's _intersectsWith uses
  1803. sortable.positionAbs = draggable.positionAbs;
  1804. sortable.helperProportions = draggable.helperProportions;
  1805. sortable.offset.click = draggable.offset.click;
  1806.  
  1807. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  1808. innermostIntersecting = true;
  1809.  
  1810. $.each( draggable.sortables, function() {
  1811. // Copy over variables that sortable's _intersectsWith uses
  1812. this.positionAbs = draggable.positionAbs;
  1813. this.helperProportions = draggable.helperProportions;
  1814. this.offset.click = draggable.offset.click;
  1815.  
  1816. if ( this !== sortable &&
  1817. this._intersectsWith( this.containerCache ) &&
  1818. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  1819. innermostIntersecting = false;
  1820. }
  1821.  
  1822. return innermostIntersecting;
  1823. });
  1824. }
  1825.  
  1826. if ( innermostIntersecting ) {
  1827. // If it intersects, we use a little isOver variable and set it once,
  1828. // so that the move-in stuff gets fired only once.
  1829. if ( !sortable.isOver ) {
  1830. sortable.isOver = 1;
  1831.  
  1832. // Store draggable's parent in case we need to reappend to it later.
  1833. draggable._parent = ui.helper.parent();
  1834.  
  1835. sortable.currentItem = ui.helper
  1836. .appendTo( sortable.element )
  1837. .data( "ui-sortable-item", true );
  1838.  
  1839. // Store helper option to later restore it
  1840. sortable.options._helper = sortable.options.helper;
  1841.  
  1842. sortable.options.helper = function() {
  1843. return ui.helper[ 0 ];
  1844. };
  1845.  
  1846. // Fire the start events of the sortable with our passed browser event,
  1847. // and our own helper (so it doesn't create a new one)
  1848. event.target = sortable.currentItem[ 0 ];
  1849. sortable._mouseCapture( event, true );
  1850. sortable._mouseStart( event, true, true );
  1851.  
  1852. // Because the browser event is way off the new appended portlet,
  1853. // modify necessary variables to reflect the changes
  1854. sortable.offset.click.top = draggable.offset.click.top;
  1855. sortable.offset.click.left = draggable.offset.click.left;
  1856. sortable.offset.parent.left -= draggable.offset.parent.left -
  1857. sortable.offset.parent.left;
  1858. sortable.offset.parent.top -= draggable.offset.parent.top -
  1859. sortable.offset.parent.top;
  1860.  
  1861. draggable._trigger( "toSortable", event );
  1862.  
  1863. // Inform draggable that the helper is in a valid drop zone,
  1864. // used solely in the revert option to handle "valid/invalid".
  1865. draggable.dropped = sortable.element;
  1866.  
  1867. // Need to refreshPositions of all sortables in the case that
  1868. // adding to one sortable changes the location of the other sortables (#9675)
  1869. $.each( draggable.sortables, function() {
  1870. this.refreshPositions();
  1871. });
  1872.  
  1873. // hack so receive/update callbacks work (mostly)
  1874. draggable.currentItem = draggable.element;
  1875. sortable.fromOutside = draggable;
  1876. }
  1877.  
  1878. if ( sortable.currentItem ) {
  1879. sortable._mouseDrag( event );
  1880. // Copy the sortable's position because the draggable's can potentially reflect
  1881. // a relative position, while sortable is always absolute, which the dragged
  1882. // element has now become. (#8809)
  1883. ui.position = sortable.position;
  1884. }
  1885. } else {
  1886. // If it doesn't intersect with the sortable, and it intersected before,
  1887. // we fake the drag stop of the sortable, but make sure it doesn't remove
  1888. // the helper by using cancelHelperRemoval.
  1889. if ( sortable.isOver ) {
  1890.  
  1891. sortable.isOver = 0;
  1892. sortable.cancelHelperRemoval = true;
  1893.  
  1894. // Calling sortable's mouseStop would trigger a revert,
  1895. // so revert must be temporarily false until after mouseStop is called.
  1896. sortable.options._revert = sortable.options.revert;
  1897. sortable.options.revert = false;
  1898.  
  1899. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  1900. sortable._mouseStop( event, true );
  1901.  
  1902. // restore sortable behaviors that were modfied
  1903. // when the draggable entered the sortable area (#9481)
  1904. sortable.options.revert = sortable.options._revert;
  1905. sortable.options.helper = sortable.options._helper;
  1906.  
  1907. if ( sortable.placeholder ) {
  1908. sortable.placeholder.remove();
  1909. }
  1910.  
  1911. // Restore and recalculate the draggable's offset considering the sortable
  1912. // may have modified them in unexpected ways. (#8809, #10669)
  1913. ui.helper.appendTo( draggable._parent );
  1914. draggable._refreshOffsets( event );
  1915. ui.position = draggable._generatePosition( event, true );
  1916.  
  1917. draggable._trigger( "fromSortable", event );
  1918.  
  1919. // Inform draggable that the helper is no longer in a valid drop zone
  1920. draggable.dropped = false;
  1921.  
  1922. // Need to refreshPositions of all sortables just in case removing
  1923. // from one sortable changes the location of other sortables (#9675)
  1924. $.each( draggable.sortables, function() {
  1925. this.refreshPositions();
  1926. });
  1927. }
  1928. }
  1929. });
  1930. }
  1931. });
  1932.  
  1933. $.ui.plugin.add("draggable", "cursor", {
  1934. start: function( event, ui, instance ) {
  1935. var t = $( "body" ),
  1936. o = instance.options;
  1937.  
  1938. if (t.css("cursor")) {
  1939. o._cursor = t.css("cursor");
  1940. }
  1941. t.css("cursor", o.cursor);
  1942. },
  1943. stop: function( event, ui, instance ) {
  1944. var o = instance.options;
  1945. if (o._cursor) {
  1946. $("body").css("cursor", o._cursor);
  1947. }
  1948. }
  1949. });
  1950.  
  1951. $.ui.plugin.add("draggable", "opacity", {
  1952. start: function( event, ui, instance ) {
  1953. var t = $( ui.helper ),
  1954. o = instance.options;
  1955. if (t.css("opacity")) {
  1956. o._opacity = t.css("opacity");
  1957. }
  1958. t.css("opacity", o.opacity);
  1959. },
  1960. stop: function( event, ui, instance ) {
  1961. var o = instance.options;
  1962. if (o._opacity) {
  1963. $(ui.helper).css("opacity", o._opacity);
  1964. }
  1965. }
  1966. });
  1967.  
  1968. $.ui.plugin.add("draggable", "scroll", {
  1969. start: function( event, ui, i ) {
  1970. if ( !i.scrollParentNotHidden ) {
  1971. i.scrollParentNotHidden = i.helper.scrollParent( false );
  1972. }
  1973.  
  1974. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  1975. i.overflowOffset = i.scrollParentNotHidden.offset();
  1976. }
  1977. },
  1978. drag: function( event, ui, i ) {
  1979.  
  1980. var o = i.options,
  1981. scrolled = false,
  1982. scrollParent = i.scrollParentNotHidden[ 0 ],
  1983. document = i.document[ 0 ];
  1984.  
  1985. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  1986. if ( !o.axis || o.axis !== "x" ) {
  1987. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  1988. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  1989. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  1990. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  1991. }
  1992. }
  1993.  
  1994. if ( !o.axis || o.axis !== "y" ) {
  1995. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  1996. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  1997. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  1998. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  1999. }
  2000. }
  2001.  
  2002. } else {
  2003.  
  2004. if (!o.axis || o.axis !== "x") {
  2005. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  2006. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2007. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  2008. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2009. }
  2010. }
  2011.  
  2012. if (!o.axis || o.axis !== "y") {
  2013. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  2014. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2015. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  2016. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2017. }
  2018. }
  2019.  
  2020. }
  2021.  
  2022. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  2023. $.ui.ddmanager.prepareOffsets(i, event);
  2024. }
  2025.  
  2026. }
  2027. });
  2028.  
  2029. $.ui.plugin.add("draggable", "snap", {
  2030. start: function( event, ui, i ) {
  2031.  
  2032. var o = i.options;
  2033.  
  2034. i.snapElements = [];
  2035.  
  2036. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  2037. var $t = $(this),
  2038. $o = $t.offset();
  2039. if (this !== i.element[0]) {
  2040. i.snapElements.push({
  2041. item: this,
  2042. width: $t.outerWidth(), height: $t.outerHeight(),
  2043. top: $o.top, left: $o.left
  2044. });
  2045. }
  2046. });
  2047.  
  2048. },
  2049. drag: function( event, ui, inst ) {
  2050.  
  2051. var ts, bs, ls, rs, l, r, t, b, i, first,
  2052. o = inst.options,
  2053. d = o.snapTolerance,
  2054. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2055. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2056.  
  2057. for (i = inst.snapElements.length - 1; i >= 0; i--){
  2058.  
  2059. l = inst.snapElements[i].left - inst.margins.left;
  2060. r = l + inst.snapElements[i].width;
  2061. t = inst.snapElements[i].top - inst.margins.top;
  2062. b = t + inst.snapElements[i].height;
  2063.  
  2064. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  2065. if (inst.snapElements[i].snapping) {
  2066. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2067. }
  2068. inst.snapElements[i].snapping = false;
  2069. continue;
  2070. }
  2071.  
  2072. if (o.snapMode !== "inner") {
  2073. ts = Math.abs(t - y2) <= d;
  2074. bs = Math.abs(b - y1) <= d;
  2075. ls = Math.abs(l - x2) <= d;
  2076. rs = Math.abs(r - x1) <= d;
  2077. if (ts) {
  2078. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  2079. }
  2080. if (bs) {
  2081. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  2082. }
  2083. if (ls) {
  2084. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  2085. }
  2086. if (rs) {
  2087. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  2088. }
  2089. }
  2090.  
  2091. first = (ts || bs || ls || rs);
  2092.  
  2093. if (o.snapMode !== "outer") {
  2094. ts = Math.abs(t - y1) <= d;
  2095. bs = Math.abs(b - y2) <= d;
  2096. ls = Math.abs(l - x1) <= d;
  2097. rs = Math.abs(r - x2) <= d;
  2098. if (ts) {
  2099. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  2100. }
  2101. if (bs) {
  2102. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  2103. }
  2104. if (ls) {
  2105. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  2106. }
  2107. if (rs) {
  2108. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  2109. }
  2110. }
  2111.  
  2112. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2113. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2114. }
  2115. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2116.  
  2117. }
  2118.  
  2119. }
  2120. });
  2121.  
  2122. $.ui.plugin.add("draggable", "stack", {
  2123. start: function( event, ui, instance ) {
  2124. var min,
  2125. o = instance.options,
  2126. group = $.makeArray($(o.stack)).sort(function(a, b) {
  2127. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  2128. });
  2129.  
  2130. if (!group.length) { return; }
  2131.  
  2132. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2133. $(group).each(function(i) {
  2134. $(this).css("zIndex", min + i);
  2135. });
  2136. this.css("zIndex", (min + group.length));
  2137. }
  2138. });
  2139.  
  2140. $.ui.plugin.add("draggable", "zIndex", {
  2141. start: function( event, ui, instance ) {
  2142. var t = $( ui.helper ),
  2143. o = instance.options;
  2144.  
  2145. if (t.css("zIndex")) {
  2146. o._zIndex = t.css("zIndex");
  2147. }
  2148. t.css("zIndex", o.zIndex);
  2149. },
  2150. stop: function( event, ui, instance ) {
  2151. var o = instance.options;
  2152.  
  2153. if (o._zIndex) {
  2154. $(ui.helper).css("zIndex", o._zIndex);
  2155. }
  2156. }
  2157. });
  2158.  
  2159. var draggable = $.ui.draggable;
  2160.  
  2161.  
  2162.  
  2163.  
  2164. }));