dd-drag-debug.js revision 9eb94626cedb24875edf2f541cdceb32c6a96046
c1a883f2e04d94e99c433b1f6cfd0c0338f4ed85Mark Andrews * Provides the ability to drag a Node.
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @module dd
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @submodule dd-drag
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * Provides the ability to drag a Node.
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @class Drag
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @extends Base
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @constructor
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @namespace DD
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:mouseup
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @description Handles the mouseup DOM event, does nothing internally just fires.
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @bubbles DDM
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @type {CustomEvent}
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @event drag:mouseDown
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @description Handles the mousedown DOM event, checks to see if you have a valid handle then starts the drag timers.
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @preventable _defMouseDownFn
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * <dl><dt>ev</dt><dd>The original mousedown event.</dd></dl>
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @bubbles DDM
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:afterMouseDown
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @description Fires after the mousedown event has been cleared.
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * <dl><dt>ev</dt><dd>The original mousedown event.</dd></dl>
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @bubbles DDM
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @type {CustomEvent}
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @event drag:removeHandle
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @description Fires after a handle is removed.
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * @param {EventFacade} event An Event Facade object with the following specific property added:
33d96fbbc8aa221508f3c780539bf44810fd2c9cMark Andrews * <dl><dt>handle</dt><dd>The handle that was removed.</dd></dl>
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @bubbles DDM
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:addHandle
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires after a handle is added.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dl><dt>handle</dt><dd>The handle that was added.</dd></dl>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:removeInvalid
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires after an invalid selector is removed.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dl><dt>handle</dt><dd>The handle that was removed.</dd></dl>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:addInvalid
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires after an invalid selector is added.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dl><dt>handle</dt><dd>The handle that was added.</dd></dl>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:start
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires at the start of a drag operation.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageX</dt><dd>The original node position X.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageY</dt><dd>The original node position Y.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>startTime</dt><dd>The startTime of the event. getTime on the current Date object.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:end
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires at the end of a drag operation.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageX</dt><dd>The current node position X.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageY</dt><dd>The current node position Y.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>startTime</dt><dd>The startTime of the event, from the start event.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>endTime</dt><dd>The endTime of the event. getTime on the current Date object.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:drag
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires every mousemove during a drag operation.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageX</dt><dd>The current node position X.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageY</dt><dd>The current node position Y.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>scroll</dt><dd>Should a scroll action occur.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>info</dt><dd>Object hash containing calculated XY arrays: start, xy, delta, offset</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:align
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @preventable _defAlignFn
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires when this node is aligned.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageX</dt><dd>The current node position X.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageY</dt><dd>The current node position Y.</dd>
819fe493f97078521bb6b9a7b97583bef89f5abcMark Andrews * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:over
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires when this node is over a Drop Target. (Fired from dd-drop)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:enter
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires when this node enters a Drop Target. (Fired from dd-drop)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:exit
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires when this node exits a Drop Target. (Fired from dd-drop)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:drophit
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires when this node is dropped on a valid Drop Target. (Fired from dd-ddm-drop)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>drop</dt><dd>The best guess on what was dropped on.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>others</dt><dd>An array of all the other drop targets that was dropped on.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @event drag:dropmiss
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Fires when this node is dropped on an invalid Drop Target. (Fired from dd-ddm-drop)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {EventFacade} event An Event Facade object with the following specific property added:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageX</dt><dd>The current node position X.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * <dt>pageY</dt><dd>The current node position Y.</dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @bubbles DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {CustomEvent}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Drag = function(o) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Drag.superclass.constructor.apply(this, arguments);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Y.error('Failed to register node, already in use: ' + o.node);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * This property defaults to "mousedown", but when drag-gestures is loaded, it is changed to "gesturemovestart"
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @property START_EVENT
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute node
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Y.Node instance to use as the element to initiate a drag operation
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Node
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Y.error('DD.Drag: Invalid Node Given: ' + node);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute dragNode
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Y.Node instance to use as the draggable element, defaults to node
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Node
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Y.error('DD.Drag: Invalid dragNode Given: ' + node);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute offsetNode
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Offset the drag element by the difference in cursor position: default true
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute startCentered
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Center the dragNode to the mouse position on drag:start: default false
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute clickPixelThresh
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description The number of pixels to move to start a drag operation, default is 3.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Number
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute clickTimeThresh
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description The number of milliseconds a mousedown has to pass to start a drag operation, default is 1000.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Number
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute lock
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Set to lock this drag element so that it can't be dragged: default false.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein this.get(NODE).addClass(DDM.CSS_PREFIX + '-locked');
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein this.get(NODE).removeClass(DDM.CSS_PREFIX + '-locked');
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute data
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description A payload holder to store arbitrary data about this drag object, can be used to store any value.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Mixed
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute move
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description If this is false, the drag element will not move with the cursor: default true. Can be used to "resize" the element.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute useShim
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Use the protective shim on all drag operations: default true. Only works with dd-ddm, not dd-ddm-base.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute activeHandle
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @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.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Node
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute primaryButtonOnly
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @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.
561a29af8c54a216e7d30b5b4f6e0d21661654ecMark Andrews * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute dragging
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @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.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute target
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @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.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute dragMode
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description This attribute only works if the dd-drop module is active. It will set the dragMode (point, intersect, strict) of this Drag instance.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type String
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute groups
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Array of groups to add this drag into.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Array
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein getter: function() {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein setter: function(g) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Y.each(g, function(v, k) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein this._groups[v] = true;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute handles
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Array of valid handles to add. Adding something here will set all handles, even if previously added with addHandle
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Array
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein setter: function(g) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Y.each(g, function(v, k) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein if (v instanceof Y.Node || v instanceof Y.NodeList) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @deprecated
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute bubbles
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Controls the default bubble parent for this Drag instance. Default: Y.DD.DDM. Set to false to disable bubbling. Use bubbleTargets in config
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Object
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein setter: function(t) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein Y.log('bubbles is deprecated use bubbleTargets: HOST', 'warn', 'dd');
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @attribute haltDown
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Should the mousedown event be halted. Default: true
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type Boolean
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Checks the object for the methods needed to drag the object around.
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews * Normally this would be a node instance, but in the case of Graphics, it
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews * may be an SVG node or something similar.
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews * @method _canDrag
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews * @param {Object} n The object to check
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews * @return {Boolean} True or false if the Object contains the methods needed to Drag
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews _canDrag: function(n) {
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews if (n && n.setXY && n.getXY && n.test && n.contains) {
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews return true;
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews return false;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @property _bubbleTargets
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description The default bubbleTarget for this object. Default: Y.DD.DDM
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @method addToGroup
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Add this Drag instance to a group, this should be used for on-the-fly group additions.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {String} g The group to add this Drag Instance to.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @return {Self}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @chainable
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein addToGroup: function(g) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein this._groups[g] = true;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein return this;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @method removeFromGroup
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Remove this Drag instance from a group, this should be used for on-the-fly group removals.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @param {String} g The group to remove this Drag Instance from.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @return {Self}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @chainable
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein delete this._groups[g];
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein return this;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @property target
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description This will be a reference to the Drop instance associated with this drag if the target: true config attribute is set..
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @type {Object}
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @method _handleTarget
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * @description Attribute handler for the target config attribute.
if (config === false) {
if (this.target) {
this.target = null;
config = {};
config.bubbleTargets = ('bubbleTargets' in config) ? config.bubbleTargets : Y.Object.values(this._yuievt.targets);
_groups: null,
* @description This method creates all the events for this Event Target and publishes them so we get Event Bubbling.
_createEvents: function() {
queuable: false,
emitFacade: true,
bubbles: true,
queuable: false,
emitFacade: true,
bubbles: true,
queuable: false,
emitFacade: true,
bubbles: true,
queuable: false,
emitFacade: true,
bubbles: true,
var ev = [
this.publish(v, {
type: v,
emitFacade: true,
bubbles: true,
preventable: false,
queuable: false,
_ev_md: null,
* @description The getTime of the mousedown event. Not used, just here in case someone wants/needs to use it.
_startTime: null,
* @description The getTime of the mouseup event. Not used, just here in case someone wants/needs to use it.
_endTime: null,
_handles: null,
_invalids: null,
* @description A private hash of the default invalid selector strings: {'textarea': true, 'input': true, 'a': true, 'button': true, 'select': true}
_dragThreshMet: null,
_fromTimeout: null,
_clickTimeout: null,
deltaXY: null,
startXY: null,
nodeXY: null,
lastXY: null,
* @description The xy that the node will be set to. Changing this will alter the position as it's dragged.
actXY: null,
realXY: null,
mouseXY: null,
region: null,
this._fixIEMouseUp();
* @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();
* @description The function we use as the onselectstart handler when we start a drag in Internet Explorer
_ieSelectFix: function() {
* @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,
* @description This method copies the onselectstart listner on the document to the _ieSelectFix property
_fixIEMouseDown: function(e) {
* @description This method copies the _ieSelectFix property back to the onselectstart listner on the document.
_fixIEMouseUp: function() {
_defMouseDownFn: function(e) {
this._dragThreshMet = false;
* @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.
hTest = null,
els = null,
nlist = null,
set = false;
if (this._handles) {
nlist = i;
hTest = n;
if (this._invalids) {
if (hTest) {
set = false;
set = true;
_timeoutCheck: function() {
this.start();
* @description Add a handle to a drag element. Drag only initiates when a mousedown happens on this element.
if (!this._handles) {
this._handles = {};
* @description Add a selector string to test the handle against. If the test passes the drag operation will not continue.
this.actXY = [];
this._createEvents();
_prep: function() {
this._dragThreshMet = false;
_unprep: function() {
start: function() {
this.region = {
end: function() {
if (this._clickTimeout) {
_defEndFn: function(e) {
this._fixIEMouseUp();
this._ev_md = null;
* @description Handler for preventing the drag:end event. It will reset the node back to it's start position
_prevEndFn: function(e) {
this._fixIEMouseUp();
this._ev_md = null;
this.region = null;
_defAlignFn: function(e) {
this._moveNode();
this.region = {
info: {
_defDragFn: function(e) {
if (e.scroll) {
if (!this._dragThreshMet) {
this._dragThreshMet = true;
this.start();
if (this._clickTimeout) {
* @description Method will forcefully stop a drag operation. For example calling this from inside an ESC keypress handler will stop this drag.
stopDrag: function() {
destructor: function() {
this._unprep();
if (this.target) {