1
/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */
2
YUI.add('dd-proxy', function (Y, NAME) {
6
* Plugin for dd-drag for creating a proxy drag node, instead of dragging the original node.
11
* Plugin for dd-drag for creating a proxy drag node, instead of dragging the original node.
19
DRAG_NODE = 'dragNode',
23
P.superclass.constructor.apply(this, arguments);
28
* The Proxy instance will be placed on the Drag instance under the proxy namespace.
42
* Move the original node at the end of the drag. Default: true
43
* @attribute moveOnEnd
50
* Hide the drag node at the end of the drag. Default: true
51
* @attribute hideOnEnd
58
* Make the Proxy node assume the size of the original node. Default: true
59
* @attribute resizeFrame
66
* Make the Proxy node appear in the same place as the original node. Default: true
67
* @attribute positionProxy
74
* The default border style for the border of the proxy. Default: 1px solid #808080
75
* @attribute borderStyle
79
value: '1px solid #808080'
82
* Should the node be cloned into the proxy for you. Default: false
83
* @attribute cloneNode
93
* Holds the event handles for setting the proxy
99
* Handler for the proxy config attribute
106
Y.on('domready', Y.bind(this._init, this));
112
var h, h1, host = this.get(HOST), dnode = host.get(DRAG_NODE);
113
if (dnode.compareTo(host.get(NODE))) {
115
host.set(DRAG_NODE, DDM._proxy);
118
Y.Array.each(this._hands, function(v) {
121
h = DDM.on('ddm:start', Y.bind(function() {
122
if (DDM.activeDrag === host) {
126
h1 = DDM.on('ddm:end', Y.bind(function() {
127
if (host.get('dragging')) {
128
if (this.get('moveOnEnd')) {
129
host.get(NODE).setXY(host.lastXY);
131
if (this.get('hideOnEnd')) {
132
host.get(DRAG_NODE).setStyle('display', 'none');
134
if (this.get('cloneNode')) {
135
host.get(DRAG_NODE).remove();
136
host.set(DRAG_NODE, DDM._proxy);
140
this._hands = [h, h1];
142
initializer: function() {
145
destructor: function() {
146
var host = this.get(HOST);
147
Y.Array.each(this._hands, function(v) {
150
host.set(DRAG_NODE, host.get(NODE));
153
var host = this.get(HOST),
155
c = n.cloneNode(true);
158
c.setAttribute('id', Y.guid());
159
c.setStyle('position', 'absolute');
160
n.get('parentNode').appendChild(c);
161
host.set(DRAG_NODE, c);
166
Y.namespace('Plugin');
167
Y.extend(P, Y.Base, proto);
168
Y.Plugin.DDProxy = P;
170
//Add a couple of methods to the DDM
173
* Create the proxy element if it doesn't already exist and set the DD.DDM._proxy value
177
* @method _createFrame
179
_createFrame: function() {
183
var p = Y.Node.create('<div></div>'),
187
position: 'absolute',
195
p.set('id', Y.guid());
196
p.addClass(DDM.CSS_PREFIX + '-proxy');
201
* If resizeProxy is set to true (default) it will resize the proxy element to match the size of the Drag Element.
202
* If positionProxy is set to true (default) it will position the proxy element in the same location as the Drag Element.
208
_setFrame: function(drag) {
209
var n = drag.get(NODE), d = drag.get(DRAG_NODE), ah, cur = 'auto';
211
ah = DDM.activeDrag.get('activeHandle');
213
cur = ah.getStyle('cursor');
215
if (cur === 'auto') {
216
cur = DDM.get('dragCursor');
220
visibility: 'hidden',
223
border: drag.proxy.get('borderStyle')
226
if (drag.proxy.get('cloneNode')) {
227
d = drag.proxy.clone();
230
if (drag.proxy.get('resizeFrame')) {
232
height: n.get('offsetHeight') + 'px',
233
width: n.get('offsetWidth') + 'px'
237
if (drag.proxy.get('positionProxy')) {
238
d.setXY(drag.nodeXY);
240
d.setStyle('visibility', 'visible');
244
//Create the frame when DOM is ready
245
//Y.on('domready', Y.bind(DDM._createFrame, DDM));
250
}, '3.9.1', {"requires": ["dd-drag"]});