dd-plugin.js revision 9ae4c004f09f87f8c346acbff826bada486622a5
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * Simple Drag plugin that can be attached to a Node or Widget via the plug method.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @module dd
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @submodule dd-plugin
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * Simple Drag plugin that can be attached to a Node or Widget via the plug method.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @class Drag
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @extends DD.Drag
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @constructor
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @namespace Plugin
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major if (Y.Widget && config.host instanceof Y.Widget) {
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @property NAME
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @description dd-plugin
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @type {String}
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @property NS
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @description The Drag instance will be placed on the Node instance under the dd namespace. It can be accessed via Node.dd;
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @type {String}
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * refers to a Y.Widget if its the host, otherwise = false.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @attribute _widget
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * refers to the [x,y] coordinate where the drag was stopped last
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @attribute _stoppedPosition
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * Returns true if widget uses widgetPosition, otherwise returns false
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @method _usesWidgetPosition
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major var r = false;
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major r = (widget.hasImpl && widget.hasImpl(Y.WidgetPosition)) ? true : false;
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * Sets up event listeners on drag events if interacting with a widget
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @method initializer
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @protected
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //if this thing is a widget, and it uses widgetposition...
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //set the x,y on the widget's ATTRS
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //store the new position that the widget ends up on
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * Updates x,y or xy attributes on widget based on where the widget is dragged
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @method initializer
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @param {EventFacade} e Event Facade
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //get the last position where the widget was, or get the starting point
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major var nodeXY = this._stoppedPosition || e.target.nodeXY,
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //amount moved = [(x2 - x1) , (y2 - y1)]
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major movedXY = [realXY[0] - nodeXY[0], realXY[1] - nodeXY[0]];
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //if both have changed..
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //if only x is 0, set the Y
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //otherwise, y is 0, so set X
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * Updates the last position where the widget was stopped.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @method updateStopPosition
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major * @param {EventFacade} e Event Facade
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major}, '@VERSION@' ,{optional:['dd-constrain', 'dd-proxy'], requires:['dd-drag'], skinnable:false});