dd-drag-debug.js revision c03d3f1eafc55ad0233f238f9ba1583c1e47fa96
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsYUI.add('dd-drag', function(Y) {
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
4a14ce5ba00ab7bc55c99ffdcf59c7a4ab902721Automatic Updater * Provides the ability to drag a Node.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @module dd
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @submodule dd-drag
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * Provides the ability to drag a Node.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @class Drag
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @extends Base
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @constructor
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @namespace DD
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
ea94d370123a5892f6c47a97f21d1b28d44bb168Tinderbox User var DDM = Y.DD.DDM,
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews NODE = 'node',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews DRAGGING = 'dragging',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews DRAG_NODE = 'dragNode',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews OFFSET_HEIGHT = 'offsetHeight',
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews OFFSET_WIDTH = 'offsetWidth',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User * @event drag:mouseup
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater * @description Handles the mouseup DOM event, does nothing internally just fires.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:mouseDown
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Handles the mousedown DOM event, checks to see if you have a valid handle then starts the drag timers.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @preventable _defMouseDownFn
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater * <dl><dt>ev</dt><dd>The original mousedown event.</dd></dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_MOUSE_DOWN = 'drag:mouseDown',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:afterMouseDown
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Fires after the mousedown event has been cleared.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dl><dt>ev</dt><dd>The original mousedown event.</dd></dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_AFTER_MOUSE_DOWN = 'drag:afterMouseDown',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:removeHandle
0f52ea95d861c237da324aa0c009638298069ec0Tinderbox User * @description Fires after a handle is removed.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dl><dt>handle</dt><dd>The handle that was removed.</dd></dl>
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_REMOVE_HANDLE = 'drag:removeHandle',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:addHandle
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Fires after a handle is added.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dl><dt>handle</dt><dd>The handle that was added.</dd></dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User */
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User EV_ADD_HANDLE = 'drag:addHandle',
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User /**
c247e3f281613fabe1af362e9f3157e35ebbe52cMark Andrews * @event drag:removeInvalid
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User * @description Fires after an invalid selector is removed.
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User * @param {EventFacade} event An Event Facade object with the following specific property added:
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User * <dl><dt>handle</dt><dd>The handle that was removed.</dd></dl>
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_REMOVE_INVALID = 'drag:removeInvalid',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:addInvalid
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Fires after an invalid selector is added.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dl><dt>handle</dt><dd>The handle that was added.</dd></dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_ADD_INVALID = 'drag:addInvalid',
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:start
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Fires at the start of a drag operation.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>pageX</dt><dd>The original node position X.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>pageY</dt><dd>The original node position Y.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>startTime</dt><dd>The startTime of the event. getTime on the current Date object.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * </dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_START = 'drag:start',
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:end
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Fires at the end of a drag operation.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>pageX</dt><dd>The current node position X.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>pageY</dt><dd>The current node position Y.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>startTime</dt><dd>The startTime of the event, from the start event.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>endTime</dt><dd>The endTime of the event. getTime on the current Date object.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * </dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_END = 'drag:end',
1224c3b69b3d18f7127aa042644936af25a2d679Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:drag
1224c3b69b3d18f7127aa042644936af25a2d679Mark Andrews * @description Fires every mousemove during a drag operation.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
1224c3b69b3d18f7127aa042644936af25a2d679Mark Andrews * <dl>
b2f07642fd712c8fda81a116bcdde229ab291f33Tinderbox User * <dt>pageX</dt><dd>The current node position X.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>pageY</dt><dd>The current node position Y.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>scroll</dt><dd>Should a scroll action occur.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>info</dt><dd>Object hash containing calculated XY arrays: start, xy, delta, offset</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * </dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_DRAG = 'drag:drag',
d3ddafd7469d1f3430ccd1b0fe0d13ccbbaf5debTinderbox User /**
d3ddafd7469d1f3430ccd1b0fe0d13ccbbaf5debTinderbox User * @event drag:align
d3ddafd7469d1f3430ccd1b0fe0d13ccbbaf5debTinderbox User * @preventable _defAlignFn
d3ddafd7469d1f3430ccd1b0fe0d13ccbbaf5debTinderbox User * @description Fires when this node is aligned.
d3ddafd7469d1f3430ccd1b0fe0d13ccbbaf5debTinderbox User * @param {EventFacade} event An Event Facade object with the following specific property added:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>pageX</dt><dd>The current node position X.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>pageY</dt><dd>The current node position Y.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * </dl>
c247e3f281613fabe1af362e9f3157e35ebbe52cMark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
c247e3f281613fabe1af362e9f3157e35ebbe52cMark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EV_ALIGN = 'drag:align',
c247e3f281613fabe1af362e9f3157e35ebbe52cMark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:over
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Fires when this node is over a Drop Target. (Fired from dd-drop)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
c247e3f281613fabe1af362e9f3157e35ebbe52cMark Andrews * <dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * </dl>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @bubbles DDM
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @event drag:enter
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Fires when this node enters a Drop Target. (Fired from dd-drop)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * <dl>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * </dl>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @bubbles DDM
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type {CustomEvent}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @event drag:exit
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Fires when this node exits a Drop Target. (Fired from dd-drop)
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @param {EventFacade} event An Event Facade object with the following specific property added:
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * <dl>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * </dl>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @bubbles DDM
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type {CustomEvent}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @event drag:drophit
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Fires when this node is dropped on a valid Drop Target. (Fired from dd-ddm-drop)
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @param {EventFacade} event An Event Facade object with the following specific property added:
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * <dl>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * <dt>drop</dt><dd>The best guess on what was dropped on.</dd>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * <dt>others</dt><dd>An array of all the other drop targets that was dropped on.</dd>
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * </dl>
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * @bubbles DDM
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * @type {CustomEvent}
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User */
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User /**
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * @event drag:dropmiss
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * @description Fires when this node is dropped on an invalid Drop Target. (Fired from dd-ddm-drop)
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * @param {EventFacade} event An Event Facade object with the following specific property added:
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * <dl>
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * <dt>pageX</dt><dd>The current node position X.</dd>
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * <dt>pageY</dt><dd>The current node position Y.</dd>
4f9cb7bd58e2c0a7407fee3758ea265aee329ac6Tinderbox User * </dl>
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @bubbles DDM
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type {CustomEvent}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Drag = function(o) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this._lazyAddAttrs = false;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Drag.superclass.constructor.apply(this, arguments);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User var valid = DDM._regDrag(this);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (!valid) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Y.error('Failed to register node, already in use: ' + o.node);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User };
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Drag.NAME = 'drag';
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * This property defaults to "mousedown", but when drag-gestures is loaded, it is changed to "gesturemovestart"
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @static
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @property START_EVENT
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Drag.START_EVENT = 'mousedown';
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Drag.ATTRS = {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute node
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Y.Node instance to use as the element to initiate a drag operation
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Node
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User node: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User setter: function(node) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (this._canDrag(node)) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return node;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User var n = Y.one(node);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (!n) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Y.error('DD.Drag: Invalid Node Given: ' + node);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return n;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute dragNode
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Y.Node instance to use as the draggable element, defaults to node
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Node
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User dragNode: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User setter: function(node) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (this._canDrag(node)) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return node;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User var n = Y.one(node);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (!n) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Y.error('DD.Drag: Invalid dragNode Given: ' + node);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return n;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute offsetNode
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Offset the drag element by the difference in cursor position: default true
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Boolean
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User offsetNode: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: true
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute startCentered
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Center the dragNode to the mouse position on drag:start: default false
f2016fcecf098726740507a5522dca04c49aeb82Tinderbox User * @type Boolean
f2016fcecf098726740507a5522dca04c49aeb82Tinderbox User */
f2016fcecf098726740507a5522dca04c49aeb82Tinderbox User startCentered: {
f2016fcecf098726740507a5522dca04c49aeb82Tinderbox User value: false
f2016fcecf098726740507a5522dca04c49aeb82Tinderbox User },
f2016fcecf098726740507a5522dca04c49aeb82Tinderbox User /**
f2016fcecf098726740507a5522dca04c49aeb82Tinderbox User * @attribute clickPixelThresh
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description The number of pixels to move to start a drag operation, default is 3.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Number
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User clickPixelThresh: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: DDM.get('clickPixelThresh')
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute clickTimeThresh
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description The number of milliseconds a mousedown has to pass to start a drag operation, default is 1000.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Number
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User clickTimeThresh: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: DDM.get('clickTimeThresh')
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute lock
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Set to lock this drag element so that it can't be dragged: default false.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Boolean
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User lock: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: false,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User setter: function(lock) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (lock) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this.get(NODE).addClass(DDM.CSS_PREFIX + '-locked');
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User } else {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this.get(NODE).removeClass(DDM.CSS_PREFIX + '-locked');
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return lock;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute data
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description A payload holder to store arbitrary data about this drag object, can be used to store any value.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Mixed
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User data: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: false
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute move
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description If this is false, the drag element will not move with the cursor: default true. Can be used to "resize" the element.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Boolean
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User move: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: true
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute useShim
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Use the protective shim on all drag operations: default true. Only works with dd-ddm, not dd-ddm-base.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Boolean
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User useShim: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: true
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute activeHandle
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description This config option is set by Drag to inform you of which handle fired the drag event (in the case that there are several handles): default false.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Node
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User activeHandle: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: false
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute primaryButtonOnly
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description By default a drag operation will only begin if the mousedown occurred with the primary mouse button. Setting this to false will allow for all mousedown events to trigger a drag.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Boolean
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User */
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User primaryButtonOnly: {
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User value: true
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute dragging
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description This attribute is not meant to be used by the implementor, it is meant to be used as an Event tracker so you can listen for it to change.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Boolean
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User dragging: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: false
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User parent: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: false
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute target
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description This attribute only works if the dd-drop module has been loaded. It will make this node a drop target as well as draggable.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Boolean
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User target: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: false,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User setter: function(config) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this._handleTarget(config);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return config;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute dragMode
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description This attribute only works if the dd-drop module is active. It will set the dragMode (point, intersect, strict) of this Drag instance.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type String
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User dragMode: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User setter: function(mode) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return DDM._setDragMode(mode);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute groups
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Array of groups to add this drag into.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Array
5fa6a064b8301e4f274bd132fd577def59e4fb4cTinderbox User */
5fa6a064b8301e4f274bd132fd577def59e4fb4cTinderbox User groups: {
5fa6a064b8301e4f274bd132fd577def59e4fb4cTinderbox User value: ['default'],
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User getter: function() {
a24330c4805a224191ab687d0291963062fe3355Tinderbox User if (!this._groups) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this._groups = {};
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
5fa6a064b8301e4f274bd132fd577def59e4fb4cTinderbox User var ret = [];
5fa6a064b8301e4f274bd132fd577def59e4fb4cTinderbox User Y.each(this._groups, function(v, k) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User ret[ret.length] = k;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User });
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return ret;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User setter: function(g) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this._groups = {};
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Y.each(g, function(v, k) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this._groups[v] = true;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }, this);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return g;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @attribute handles
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Array of valid handles to add. Adding something here will set all handles, even if previously added with addHandle
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Array
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User handles: {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User value: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User setter: function(g) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (g) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this._handles = {};
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Y.each(g, function(v, k) {
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User var key = v;
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User if (v instanceof Y.Node || v instanceof Y.NodeList) {
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User key = v._yuid;
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User }
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User this._handles[key] = v;
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User }, this);
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User } else {
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User this._handles = null;
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User }
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User return g;
6478b87fd23bcd3ab74c25b261021fe19a239c4fTinderbox User }
6478b87fd23bcd3ab74c25b261021fe19a239c4fTinderbox User },
5fa6a064b8301e4f274bd132fd577def59e4fb4cTinderbox User /**
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User * @deprecated
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User * @attribute bubbles
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User * @description Controls the default bubble parent for this Drag instance. Default: Y.DD.DDM. Set to false to disable bubbling. Use bubbleTargets in config
6478b87fd23bcd3ab74c25b261021fe19a239c4fTinderbox User * @type Object
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User */
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User bubbles: {
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User setter: function(t) {
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User Y.log('bubbles is deprecated use bubbleTargets: HOST', 'warn', 'dd');
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User this.addTarget(t);
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User return t;
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User }
6478b87fd23bcd3ab74c25b261021fe19a239c4fTinderbox User },
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User /**
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User * @attribute haltDown
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @description Should the mousedown event be halted. Default: true
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @type Boolean
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User */
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User haltDown: {
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User value: true
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User }
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User };
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User Y.extend(Drag, Y.Base, {
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User _canDrag: function(n) {
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User if (n && n.setXY && n.getXY && n.test && n.contains) {
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User return true;
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User }
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User return false;
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User },
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User /**
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @private
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @property _bubbleTargets
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @description The default bubbleTarget for this object. Default: Y.DD.DDM
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User */
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User _bubbleTargets: Y.DD.DDM,
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User /**
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @method addToGroup
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @description Add this Drag instance to a group, this should be used for on-the-fly group additions.
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @param {String} g The group to add this Drag Instance to.
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @return {Self}
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User * @chainable
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User */
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User addToGroup: function(g) {
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User this._groups[g] = true;
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User DDM._activateTargets();
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User return this;
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User },
61ab11c0ec845606f85452b2c9f2e223772aae00Tinderbox User /**
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User * @method removeFromGroup
f5c27ecceb6dcba6ad8b75172fe5f9823d7a6d42Tinderbox User * @description Remove this Drag instance from a group, this should be used for on-the-fly group removals.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @param {String} g The group to remove this Drag Instance from.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @return {Self}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @chainable
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User removeFromGroup: function(g) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User delete this._groups[g];
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User DDM._activateTargets();
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return this;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @property target
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description This will be a reference to the Drop instance associated with this drag if the target: true config attribute is set..
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type {Object}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User target: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @method _handleTarget
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Attribute handler for the target config attribute.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @param {Boolean/Object}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @return {Boolean/Object}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User _handleTarget: function(config) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (Y.DD.Drop) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (config === false) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User if (this.target) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User DDM._unregTarget(this.target);
369963ad26cef09c3839d76c74c2d856f91be27aTinderbox User this.target = null;
369963ad26cef09c3839d76c74c2d856f91be27aTinderbox User }
369963ad26cef09c3839d76c74c2d856f91be27aTinderbox User return false;
369963ad26cef09c3839d76c74c2d856f91be27aTinderbox User } else {
369963ad26cef09c3839d76c74c2d856f91be27aTinderbox User if (!Y.Lang.isObject(config)) {
369963ad26cef09c3839d76c74c2d856f91be27aTinderbox User config = {};
369963ad26cef09c3839d76c74c2d856f91be27aTinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User config.bubbleTargets = ('bubbleTargets' in config) ? config.bubbleTargets : Y.Object.values(this._yuievt.targets);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User config.node = this.get(NODE);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User config.groups = config.groups || this.get('groups');
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this.target = new Y.DD.Drop(config);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User } else {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User return false;
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @property _groups
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description Storage Array for the groups this drag belongs to.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type {Array}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User _groups: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @method _createEvents
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description This method creates all the events for this Event Target and publishes them so we get Event Bubbling.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User _createEvents: function() {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this.publish(EV_MOUSE_DOWN, {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User defaultFn: this._defMouseDownFn,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User queuable: false,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User emitFacade: true,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User bubbles: true,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User prefix: 'drag'
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User });
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this.publish(EV_ALIGN, {
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User defaultFn: this._defAlignFn,
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User queuable: false,
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User emitFacade: true,
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User bubbles: true,
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User prefix: 'drag'
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User });
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User this.publish(EV_DRAG, {
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User defaultFn: this._defDragFn,
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User queuable: false,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User emitFacade: true,
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User bubbles: true,
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User prefix: 'drag'
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User });
11e9368a226272085c337e9e74b79808c16fbdbaTinderbox User
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User this.publish(EV_END, {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User defaultFn: this._defEndFn,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User preventedFn: this._prevEndFn,
74ae031d9d7780015c11242b71cecca905ada695Tinderbox User queuable: false,
74ae031d9d7780015c11242b71cecca905ada695Tinderbox User emitFacade: true,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User bubbles: true,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User prefix: 'drag'
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User });
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User var ev = [
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User EV_AFTER_MOUSE_DOWN,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User EV_REMOVE_HANDLE,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User EV_ADD_HANDLE,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User EV_REMOVE_INVALID,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User EV_ADD_INVALID,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User EV_START,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User 'drag:drophit',
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User 'drag:dropmiss',
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User 'drag:over',
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User 'drag:enter',
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User 'drag:exit'
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User ];
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User Y.each(ev, function(v, k) {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User this.publish(v, {
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User type: v,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User emitFacade: true,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User bubbles: true,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User preventable: false,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User queuable: false,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User prefix: 'drag'
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User });
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User }, this);
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User },
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @property _ev_md
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description A private reference to the mousedown DOM event
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type {EventFacade}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User _ev_md: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
3c7b4ac4517ac9d78c9bf3e0e790cedce10ddc18Tinderbox User * @property _startTime
3c7b4ac4517ac9d78c9bf3e0e790cedce10ddc18Tinderbox User * @description The getTime of the mousedown event. Not used, just here in case someone wants/needs to use it.
3c7b4ac4517ac9d78c9bf3e0e790cedce10ddc18Tinderbox User * @type Date
3c7b4ac4517ac9d78c9bf3e0e790cedce10ddc18Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User _startTime: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @property _endTime
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description The getTime of the mouseup event. Not used, just here in case someone wants/needs to use it.
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type Date
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User _endTime: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @property _handles
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @description A private hash of the valid drag handles
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @type {Object}
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User */
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User _handles: null,
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User /**
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User * @private
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User * @property _invalids
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User * @description A private hash of the invalid selector strings
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User * @type {Object}
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User */
eaaf00efc02fdd4965f747afb51f881ac5a389d2Tinderbox User _invalids: null,
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User /**
0ccb0e98c77a9b9636a036f8f64f5679a430aaf4Tinderbox User * @private
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @property _invalidsDefault
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description A private hash of the default invalid selector strings: {'textarea': true, 'input': true, 'a': true, 'button': true, 'select': true}
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User * @type {Object}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews _invalidsDefault: {'textarea': true, 'input': true, 'a': true, 'button': true, 'select': true },
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @private
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @property _dragThreshMet
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Private flag to see if the drag threshhold was met
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {Boolean}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews _dragThreshMet: null,
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @private
1d216bfaa764f2b40c57cf61987453c5a6fa9b0aMark Andrews * @property _fromTimeout
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description Flag to determine if the drag operation came from a timeout
d71e2e0c61df16ff37c9934c371a4a60c08974f7Mark Andrews * @type {Boolean}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews _fromTimeout: null,
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @private
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @property _clickTimeout
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User * @description Holder for the setTimeout call
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {Boolean}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews _clickTimeout: null,
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @property deltaXY
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description The offset of the mouse position to the element's position
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {Array}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews deltaXY: null,
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater /**
cd32f419a8a5432fbb139f56ee73cbf68b9350ccTinderbox User * @property startXY
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description The initial mouse position
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {Array}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews startXY: null,
4abdfc917e6635a7c81d1f931a0c79227e72d025Mark Andrews /**
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater * @property nodeXY
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @description The initial element position
4abdfc917e6635a7c81d1f931a0c79227e72d025Mark Andrews * @type {Array}
4abdfc917e6635a7c81d1f931a0c79227e72d025Mark Andrews */
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews nodeXY: null,
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews /**
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @property lastXY
30c0c7470d5bfabd8f43c563f4eca636d06cc484Tinderbox User * @description The position of the element as it's moving (for offset calculations)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * @type {Array}
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews */
lastXY: null,
/**
* @property actXY
* @description The xy that the node will be set to. Changing this will alter the position as it's dragged.
* @type {Array}
*/
actXY: null,
/**
* @property realXY
* @description The real xy position of the node.
* @type {Array}
*/
realXY: null,
/**
* @property mouseXY
* @description The XY coords of the mousemove
* @type {Array}
*/
mouseXY: null,
/**
* @property region
* @description A region object associated with this drag, used for checking regions while dragging.
* @type Object
*/
region: null,
/**
* @private
* @method _handleMouseUp
* @description Handler for the mouseup DOM event
* @param {EventFacade}
*/
_handleMouseUp: function(ev) {
this.fire('drag:mouseup');
this._fixIEMouseUp();
if (DDM.activeDrag) {
DDM._end();
}
},
/**
* @private
* @method _fixDragStart
* @description The function we use as the ondragstart handler when we start a drag in Internet Explorer. This keeps IE from blowing up on images as drag handles.
*/
_fixDragStart: function(e) {
e.preventDefault();
},
/**
* @private
* @method _ieSelectFix
* @description The function we use as the onselectstart handler when we start a drag in Internet Explorer
*/
_ieSelectFix: function() {
return false;
},
/**
* @private
* @property _ieSelectBack
* @description We will hold a copy of the current "onselectstart" method on this property, and reset it after we are done using it.
*/
_ieSelectBack: null,
/**
* @private
* @method _fixIEMouseDown
* @description This method copies the onselectstart listner on the document to the _ieSelectFix property
*/
_fixIEMouseDown: function(e) {
if (Y.UA.ie) {
this._ieSelectBack = Y.config.doc.body.onselectstart;
Y.config.doc.body.onselectstart = this._ieSelectFix;
}
},
/**
* @private
* @method _fixIEMouseUp
* @description This method copies the _ieSelectFix property back to the onselectstart listner on the document.
*/
_fixIEMouseUp: function() {
if (Y.UA.ie) {
Y.config.doc.body.onselectstart = this._ieSelectBack;
}
},
/**
* @private
* @method _handleMouseDownEvent
* @description Handler for the mousedown DOM event
* @param {EventFacade}
*/
_handleMouseDownEvent: function(ev) {
this.fire(EV_MOUSE_DOWN, { ev: ev });
},
/**
* @private
* @method _defMouseDownFn
* @description Handler for the mousedown DOM event
* @param {EventFacade}
*/
_defMouseDownFn: function(e) {
var ev = e.ev;
this._dragThreshMet = false;
this._ev_md = ev;
if (this.get('primaryButtonOnly') && ev.button > 1) {
return false;
}
if (this.validClick(ev)) {
this._fixIEMouseDown(ev);
if (this.get('haltDown')) {
Y.log('Halting MouseDown', 'info', 'drag');
ev.halt();
} else {
Y.log('Preventing Default on MouseDown', 'info', 'drag');
ev.preventDefault();
}
this._setStartPosition([ev.pageX, ev.pageY]);
DDM.activeDrag = this;
this._clickTimeout = Y.later(this.get('clickTimeThresh'), this, this._timeoutCheck);
}
this.fire(EV_AFTER_MOUSE_DOWN, { ev: ev });
},
/**
* @method validClick
* @description Method first checks to see if we have handles, if so it validates the click against the handle. Then if it finds a valid handle, it checks it against the invalid handles list. Returns true if a good handle was used, false otherwise.
* @param {EventFacade}
* @return {Boolean}
*/
validClick: function(ev) {
var r = false, n = false,
tar = ev.target,
hTest = null,
els = null,
nlist = null,
set = false;
if (this._handles) {
Y.each(this._handles, function(i, n) {
if (i instanceof Y.Node || i instanceof Y.NodeList) {
if (!r) {
nlist = i;
if (nlist instanceof Y.Node) {
nlist = new Y.NodeList(i._node);
}
nlist.each(function(nl) {
if (nl.contains(tar)) {
r = true;
}
});
}
} else if (Y.Lang.isString(n)) {
//Am I this or am I inside this
if (tar.test(n + ', ' + n + ' *') && !hTest) {
hTest = n;
r = true;
}
}
});
} else {
n = this.get(NODE);
if (n.contains(tar) || n.compareTo(tar)) {
r = true;
}
}
if (r) {
if (this._invalids) {
Y.each(this._invalids, function(i, n) {
if (Y.Lang.isString(n)) {
//Am I this or am I inside this
if (tar.test(n + ', ' + n + ' *')) {
r = false;
}
}
});
}
}
if (r) {
if (hTest) {
els = ev.currentTarget.all(hTest);
set = false;
els.each(function(n, i) {
if ((n.contains(tar) || n.compareTo(tar)) && !set) {
set = true;
this.set('activeHandle', n);
}
}, this);
} else {
this.set('activeHandle', this.get(NODE));
}
}
return r;
},
/**
* @private
* @method _setStartPosition
* @description Sets the current position of the Element and calculates the offset
* @param {Array} xy The XY coords to set the position to.
*/
_setStartPosition: function(xy) {
this.startXY = xy;
this.nodeXY = this.lastXY = this.realXY = this.get(NODE).getXY();
if (this.get('offsetNode')) {
this.deltaXY = [(this.startXY[0] - this.nodeXY[0]), (this.startXY[1] - this.nodeXY[1])];
} else {
this.deltaXY = [0, 0];
}
},
/**
* @private
* @method _timeoutCheck
* @description The method passed to setTimeout to determine if the clickTimeThreshold was met.
*/
_timeoutCheck: function() {
if (!this.get('lock') && !this._dragThreshMet && this._ev_md) {
this._fromTimeout = this._dragThreshMet = true;
this.start();
this._alignNode([this._ev_md.pageX, this._ev_md.pageY], true);
}
},
/**
* @method removeHandle
* @description Remove a Selector added by addHandle
* @param {String} str The selector for the handle to be removed.
* @return {Self}
* @chainable
*/
removeHandle: function(str) {
var key = str;
if (str instanceof Y.Node || str instanceof Y.NodeList) {
key = str._yuid;
}
if (this._handles[key]) {
delete this._handles[key];
this.fire(EV_REMOVE_HANDLE, { handle: str });
}
return this;
},
/**
* @method addHandle
* @description Add a handle to a drag element. Drag only initiates when a mousedown happens on this element.
* @param {String} str The selector to test for a valid handle. Must be a child of the element.
* @return {Self}
* @chainable
*/
addHandle: function(str) {
if (!this._handles) {
this._handles = {};
}
var key = str;
if (str instanceof Y.Node || str instanceof Y.NodeList) {
key = str._yuid;
}
this._handles[key] = str;
this.fire(EV_ADD_HANDLE, { handle: str });
return this;
},
/**
* @method removeInvalid
* @description Remove an invalid handle added by addInvalid
* @param {String} str The invalid handle to remove from the internal list.
* @return {Self}
* @chainable
*/
removeInvalid: function(str) {
if (this._invalids[str]) {
this._invalids[str] = null;
delete this._invalids[str];
this.fire(EV_REMOVE_INVALID, { handle: str });
}
return this;
},
/**
* @method addInvalid
* @description Add a selector string to test the handle against. If the test passes the drag operation will not continue.
* @param {String} str The selector to test against to determine if this is an invalid drag handle.
* @return {Self}
* @chainable
*/
addInvalid: function(str) {
if (Y.Lang.isString(str)) {
this._invalids[str] = true;
this.fire(EV_ADD_INVALID, { handle: str });
}
return this;
},
/**
* @private
* @method initializer
* @description Internal init handler
*/
initializer: function(cfg) {
this.get(NODE).dd = this;
if (!this.get(NODE).get('id')) {
var id = Y.stamp(this.get(NODE));
this.get(NODE).set('id', id);
}
this.actXY = [];
this._invalids = Y.clone(this._invalidsDefault, true);
this._createEvents();
if (!this.get(DRAG_NODE)) {
this.set(DRAG_NODE, this.get(NODE));
}
//Fix for #2528096
//Don't prep the DD instance until all plugins are loaded.
this.on('initializedChange', Y.bind(this._prep, this));
//Shouldn't have to do this..
this.set('groups', this.get('groups'));
},
/**
* @private
* @method _prep
* @description Attach event listners and add classname
*/
_prep: function() {
this._dragThreshMet = false;
var node = this.get(NODE);
node.addClass(DDM.CSS_PREFIX + '-draggable');
node.on(Drag.START_EVENT, Y.bind(this._handleMouseDownEvent, this));
node.on('mouseup', Y.bind(this._handleMouseUp, this));
node.on('dragstart', Y.bind(this._fixDragStart, this));
},
/**
* @private
* @method _unprep
* @description Detach event listeners and remove classname
*/
_unprep: function() {
var node = this.get(NODE);
node.removeClass(DDM.CSS_PREFIX + '-draggable');
node.detachAll();
},
/**
* @method start
* @description Starts the drag operation
* @return {Self}
* @chainable
*/
start: function() {
if (!this.get('lock') && !this.get(DRAGGING)) {
var node = this.get(NODE), ow, oh, xy;
this._startTime = (new Date()).getTime();
DDM._start();
node.addClass(DDM.CSS_PREFIX + '-dragging');
this.fire(EV_START, {
pageX: this.nodeXY[0],
pageY: this.nodeXY[1],
startTime: this._startTime
});
node = this.get(DRAG_NODE);
xy = this.nodeXY;
ow = node.get(OFFSET_WIDTH);
oh = node.get(OFFSET_HEIGHT);
if (this.get('startCentered')) {
this._setStartPosition([xy[0] + (ow / 2), xy[1] + (oh / 2)]);
}
this.region = {
'0': xy[0],
'1': xy[1],
area: 0,
top: xy[1],
right: xy[0] + ow,
bottom: xy[1] + oh,
left: xy[0]
};
this.set(DRAGGING, true);
}
return this;
},
/**
* @method end
* @description Ends the drag operation
* @return {Self}
* @chainable
*/
end: function() {
this._endTime = (new Date()).getTime();
if (this._clickTimeout) {
this._clickTimeout.cancel();
}
this._dragThreshMet = this._fromTimeout = false;
if (!this.get('lock') && this.get(DRAGGING)) {
this.fire(EV_END, {
pageX: this.lastXY[0],
pageY: this.lastXY[1],
startTime: this._startTime,
endTime: this._endTime
});
}
this.get(NODE).removeClass(DDM.CSS_PREFIX + '-dragging');
this.set(DRAGGING, false);
this.deltaXY = [0, 0];
return this;
},
/**
* @private
* @method _defEndFn
* @description Handler for fixing the selection in IE
*/
_defEndFn: function(e) {
this._fixIEMouseUp();
this._ev_md = null;
},
/**
* @private
* @method _prevEndFn
* @description Handler for preventing the drag:end event. It will reset the node back to it's start position
*/
_prevEndFn: function(e) {
this._fixIEMouseUp();
//Bug #1852577
this.get(DRAG_NODE).setXY(this.nodeXY);
this._ev_md = null;
this.region = null;
},
/**
* @private
* @method _align
* @description Calculates the offsets and set's the XY that the element will move to.
* @param {Array} xy The xy coords to align with.
*/
_align: function(xy) {
this.fire(EV_ALIGN, {pageX: xy[0], pageY: xy[1] });
},
/**
* @private
* @method _defAlignFn
* @description Calculates the offsets and set's the XY that the element will move to.
* @param {EventFacade} e The drag:align event.
*/
_defAlignFn: function(e) {
this.actXY = [e.pageX - this.deltaXY[0], e.pageY - this.deltaXY[1]];
},
/**
* @private
* @method _alignNode
* @description This method performs the alignment before the element move.
* @param {Array} eXY The XY to move the element to, usually comes from the mousemove DOM event.
*/
_alignNode: function(eXY) {
this._align(eXY);
this._moveNode();
},
/**
* @private
* @method _moveNode
* @description This method performs the actual element move.
*/
_moveNode: function(scroll) {
//if (!this.get(DRAGGING)) {
// return;
//}
var diffXY = [], diffXY2 = [], startXY = this.nodeXY, xy = this.actXY;
diffXY[0] = (xy[0] - this.lastXY[0]);
diffXY[1] = (xy[1] - this.lastXY[1]);
diffXY2[0] = (xy[0] - this.nodeXY[0]);
diffXY2[1] = (xy[1] - this.nodeXY[1]);
this.region = {
'0': xy[0],
'1': xy[1],
area: 0,
top: xy[1],
right: xy[0] + this.get(DRAG_NODE).get(OFFSET_WIDTH),
bottom: xy[1] + this.get(DRAG_NODE).get(OFFSET_HEIGHT),
left: xy[0]
};
this.fire(EV_DRAG, {
pageX: xy[0],
pageY: xy[1],
scroll: scroll,
info: {
start: startXY,
xy: xy,
delta: diffXY,
offset: diffXY2
}
});
this.lastXY = xy;
},
/**
* @private
* @method _defDragFn
* @description Default function for drag:drag. Fired from _moveNode.
* @param {EventFacade} ev The drag:drag event
*/
_defDragFn: function(e) {
if (this.get('move')) {
if (e.scroll) {
e.scroll.node.set('scrollTop', e.scroll.top);
e.scroll.node.set('scrollLeft', e.scroll.left);
}
this.get(DRAG_NODE).setXY([e.pageX, e.pageY]);
this.realXY = [e.pageX, e.pageY];
}
},
/**
* @private
* @method _move
* @description Fired from DragDropMgr (DDM) on mousemove.
* @param {EventFacade} ev The mousemove DOM event
*/
_move: function(ev) {
if (this.get('lock')) {
return false;
} else {
this.mouseXY = [ev.pageX, ev.pageY];
if (!this._dragThreshMet) {
var diffX = Math.abs(this.startXY[0] - ev.pageX),
diffY = Math.abs(this.startXY[1] - ev.pageY);
if (diffX > this.get('clickPixelThresh') || diffY > this.get('clickPixelThresh')) {
this._dragThreshMet = true;
this.start();
this._alignNode([ev.pageX, ev.pageY]);
}
} else {
if (this._clickTimeout) {
this._clickTimeout.cancel();
}
this._alignNode([ev.pageX, ev.pageY]);
}
}
},
/**
* @method stopDrag
* @description Method will forcefully stop a drag operation. For example calling this from inside an ESC keypress handler will stop this drag.
* @return {Self}
* @chainable
*/
stopDrag: function() {
if (this.get(DRAGGING)) {
DDM._end();
}
return this;
},
/**
* @private
* @method destructor
* @description Lifecycle destructor, unreg the drag from the DDM and remove listeners
*/
destructor: function() {
this._unprep();
this.detachAll();
if (this.target) {
this.target.destroy();
}
DDM._unregDrag(this);
}
});
Y.namespace('DD');
Y.DD.Drag = Drag;
}, '@VERSION@' ,{skinnable:false, requires:['dd-ddm-base']});