/usr/share/javascript/yui3/dd-plugin/dd-plugin.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('dd-plugin', function(Y) {
/**
* Simple Drag plugin that can be attached to a Node or Widget via the plug method.
* @module dd
* @submodule dd-plugin
*/
/**
* Simple Drag plugin that can be attached to a Node or Widget via the plug method.
* @class Drag
* @extends DD.Drag
* @constructor
* @namespace Plugin
*/
var Drag = function(config) {
if (Y.Widget && config.host instanceof Y.Widget) {
config.node = config.host.get('boundingBox');
config.widget = config.host;
} else {
config.node = config.host;
config.widget = false;
}
Drag.superclass.constructor.call(this, config);
},
EV_START = 'drag:start',
EV_DRAG = 'drag:drag',
EV_DRAG_END = 'drag:end';
/**
* @property NAME
* @description dd-plugin
* @type {String}
*/
Drag.NAME = "dd-plugin";
/**
* @property NS
* @description The Drag instance will be placed on the Node instance under the dd namespace. It can be accessed via Node.dd;
* @type {String}
*/
Drag.NS = "dd";
Y.extend(Drag, Y.DD.Drag, {
_widgetHandles: null,
/**
* refers to a Y.Widget if its the host, otherwise = false.
*
* @attribute _widget
* @private
*/
_widget: undefined,
/**
* refers to the [x,y] coordinate where the drag was stopped last
*
* @attribute _stoppedPosition
* @private
*/
_stoppedPosition: undefined,
/**
* Returns true if widget uses widgetPosition, otherwise returns false
*
* @method _usesWidgetPosition
* @private
*/
_usesWidgetPosition: function(widget) {
var r = false;
if (widget) {
r = (widget.hasImpl && widget.hasImpl(Y.WidgetPosition)) ? true : false;
}
return r;
},
/**
* Attached to the `drag:start` event, it checks if this plugin needs
* to attach or detach listeners for widgets. If `dd-proxy` is plugged
* the default widget positioning should be ignored.
* @method _checkEvents
* @private
*/
_checkEvents: function() {
if (this._widget) {
//It's a widget
if (this.proxy) {
//It's a proxy
if (this._widgetHandles.length > 0) {
//Remove Listeners
this._removeWidgetListeners();
}
} else {
if (this._widgetHandles.length === 0) {
this._attachWidgetListeners();
}
}
}
},
/**
* Remove the attached widget listeners
* @method _removeWidgetListeners
* @private
*/
_removeWidgetListeners: function() {
Y.Array.each(this._widgetHandles, function(handle) {
handle.detach();
});
this._widgetHandles = [];
},
/**
* If this is a Widget, then attach the positioning listeners
* @method _attachWidgetListeners
* @private
*/
_attachWidgetListeners: function() {
//if this thing is a widget, and it uses widgetposition...
if (this._usesWidgetPosition(this._widget)) {
//set the x,y on the widget's ATTRS
this._widgetHandles.push(this.on(EV_DRAG, this._setWidgetCoords));
//store the new position that the widget ends up on
this._widgetHandles.push(this.on(EV_DRAG_END, this._updateStopPosition));
}
},
/**
* Sets up event listeners on drag events if interacting with a widget
*
* @method initializer
* @protected
*/
initializer: function(config) {
this._widgetHandles = [];
this._widget = config.widget;
this.on(EV_START, this._checkEvents); //Always run, don't check
this._attachWidgetListeners();
},
/**
* Updates x,y or xy attributes on widget based on where the widget is dragged
*
* @method initializer
* @param {EventFacade} e Event Facade
* @private
*/
_setWidgetCoords: function(e) {
//get the last position where the widget was, or get the starting point
var nodeXY = this._stoppedPosition || e.target.nodeXY,
realXY = e.target.realXY,
//amount moved = [(x2 - x1) , (y2 - y1)]
movedXY = [realXY[0] - nodeXY[0], realXY[1] - nodeXY[1]];
//if both have changed..
if (movedXY[0] !== 0 && movedXY[1] !== 0) {
this._widget.set('xy', realXY);
}
//if only x is 0, set the Y
else if (movedXY[0] === 0) {
this._widget.set('y',realXY[1]);
}
//otherwise, y is 0, so set X
else if (movedXY[1] === 0){
this._widget.set('x', realXY[0]);
}
},
/**
* Updates the last position where the widget was stopped.
*
* @method _updateStopPosition
* @param {EventFacade} e Event Facade
* @private
*/
_updateStopPosition: function(e) {
this._stoppedPosition = e.target.realXY;
}
});
Y.namespace('Plugin');
Y.Plugin.Drag = Drag;
}, '3.5.1' ,{skinnable:false, optional:['dd-constrain', 'dd-proxy'], requires:['dd-drag']});
|