~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/dd-drop/dd-drop-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('dd-drop', function(Y) {
8
 
 
9
 
 
10
 
    /**
11
 
     * Provides the ability to create a Drop Target.
12
 
     * @module dd
13
 
     * @submodule dd-drop
14
 
     */     
15
 
    /**
16
 
     * Provides the ability to create a Drop Target.
17
 
     * @class Drop
18
 
     * @extends Base
19
 
     * @constructor
20
 
     * @namespace DD
21
 
     */
22
 
 
23
 
    var NODE = 'node',
24
 
        DDM = Y.DD.DDM,
25
 
        OFFSET_HEIGHT = 'offsetHeight',
26
 
        OFFSET_WIDTH = 'offsetWidth',
27
 
        /**
28
 
        * @event drop:over
29
 
        * @description Fires when a drag element is over this target.
30
 
        * @param {EventFacade} event An Event Facade object with the following specific property added:
31
 
        * <dl>
32
 
        * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
33
 
        * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
34
 
        * </dl>        
35
 
        * @bubbles DDM
36
 
        * @type {CustomEvent}
37
 
        */
38
 
        EV_DROP_OVER = 'drop:over',
39
 
        /**
40
 
        * @event drop:enter
41
 
        * @description Fires when a drag element enters this target.
42
 
        * @param {EventFacade} event An Event Facade object with the following specific property added:
43
 
        * <dl>
44
 
        * <dt>drop</dt><dd>The drop object at the time of the event.</dd>
45
 
        * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
46
 
        * </dl>        
47
 
        * @bubbles DDM
48
 
        * @type {CustomEvent}
49
 
        */
50
 
        EV_DROP_ENTER = 'drop:enter',
51
 
        /**
52
 
        * @event drop:exit
53
 
        * @description Fires when a drag element exits this target.
54
 
        * @param {EventFacade} event An Event Facade object
55
 
        * @bubbles DDM
56
 
        * @type {CustomEvent}
57
 
        */
58
 
        EV_DROP_EXIT = 'drop:exit',
59
 
 
60
 
        /**
61
 
        * @event drop:hit
62
 
        * @description Fires when a draggable node is dropped on this Drop Target. (Fired from dd-ddm-drop)
63
 
        * @param {EventFacade} event An Event Facade object with the following specific property added:
64
 
        * <dl>
65
 
        * <dt>drop</dt><dd>The best guess on what was dropped on.</dd>
66
 
        * <dt>drag</dt><dd>The drag object at the time of the event.</dd>
67
 
        * <dt>others</dt><dd>An array of all the other drop targets that was dropped on.</dd>
68
 
        * </dl>        
69
 
        * @bubbles DDM
70
 
        * @type {CustomEvent}
71
 
        */
72
 
        
73
 
 
74
 
    Drop = function() {
75
 
        this._lazyAddAttrs = false;
76
 
        Drop.superclass.constructor.apply(this, arguments);
77
 
 
78
 
 
79
 
        //DD init speed up.
80
 
        Y.on('domready', Y.bind(function() {
81
 
            Y.later(100, this, this._createShim);
82
 
        }, this));
83
 
        DDM._regTarget(this);
84
 
 
85
 
        /* TODO
86
 
        if (Dom.getStyle(this.el, 'position') == 'fixed') {
87
 
            Event.on(window, 'scroll', function() {
88
 
                this.activateShim();
89
 
            }, this, true);
90
 
        }
91
 
        */
92
 
    };
93
 
 
94
 
    Drop.NAME = 'drop';
95
 
 
96
 
    Drop.ATTRS = {
97
 
        /**
98
 
        * @attribute node
99
 
        * @description Y.Node instanace to use as the element to make a Drop Target
100
 
        * @type Node
101
 
        */        
102
 
        node: {
103
 
            setter: function(node) {
104
 
                var n = Y.one(node);
105
 
                if (!n) {
106
 
                    Y.error('DD.Drop: Invalid Node Given: ' + node);
107
 
                }
108
 
                return n;               
109
 
            }
110
 
        },
111
 
        /**
112
 
        * @attribute groups
113
 
        * @description Array of groups to add this drop into.
114
 
        * @type Array
115
 
        */        
116
 
        groups: {
117
 
            value: ['default'],
118
 
            setter: function(g) {
119
 
                this._groups = {};
120
 
                Y.each(g, function(v, k) {
121
 
                    this._groups[v] = true;
122
 
                }, this);
123
 
                return g;
124
 
            }
125
 
        },   
126
 
        /**
127
 
        * @attribute padding
128
 
        * @description CSS style padding to make the Drop Target bigger than the node.
129
 
        * @type String
130
 
        */
131
 
        padding: {
132
 
            value: '0',
133
 
            setter: function(p) {
134
 
                return DDM.cssSizestoObject(p);
135
 
            }
136
 
        },
137
 
        /**
138
 
        * @attribute lock
139
 
        * @description Set to lock this drop element.
140
 
        * @type Boolean
141
 
        */        
142
 
        lock: {
143
 
            value: false,
144
 
            setter: function(lock) {
145
 
                if (lock) {
146
 
                    this.get(NODE).addClass(DDM.CSS_PREFIX + '-drop-locked');
147
 
                } else {
148
 
                    this.get(NODE).removeClass(DDM.CSS_PREFIX + '-drop-locked');
149
 
                }
150
 
                return lock;
151
 
            }
152
 
        },
153
 
        /**
154
 
        * @deprecated
155
 
        * @attribute bubbles
156
 
        * @description Controls the default bubble parent for this Drop instance. Default: Y.DD.DDM. Set to false to disable bubbling. Use bubbleTargets in config.
157
 
        * @type Object
158
 
        */
159
 
        bubbles: {
160
 
            setter: function(t) {
161
 
                Y.log('bubbles is deprecated use bubbleTargets: HOST', 'warn', 'dd');
162
 
                this.addTarget(t);
163
 
                return t;
164
 
            }
165
 
        },
166
 
        /**
167
 
        * @deprecated
168
 
        * @attribute useShim
169
 
        * @description Use the Drop shim. Default: true
170
 
        * @type Boolean
171
 
        */
172
 
        useShim: {
173
 
            value: true,
174
 
            setter: function(v) {
175
 
                Y.DD.DDM._noShim = !v;
176
 
                return v;
177
 
            }
178
 
        }
179
 
    };
180
 
 
181
 
    Y.extend(Drop, Y.Base, {
182
 
        /**
183
 
        * @private
184
 
        * @property _bubbleTargets
185
 
        * @description The default bubbleTarget for this object. Default: Y.DD.DDM
186
 
        */
187
 
        _bubbleTargets: Y.DD.DDM,
188
 
        /**
189
 
        * @method addToGroup
190
 
        * @description Add this Drop instance to a group, this should be used for on-the-fly group additions.
191
 
        * @param {String} g The group to add this Drop Instance to.
192
 
        * @return {Self}
193
 
        * @chainable
194
 
        */
195
 
        addToGroup: function(g) {
196
 
            this._groups[g] = true;
197
 
            return this;
198
 
        },
199
 
        /**
200
 
        * @method removeFromGroup
201
 
        * @description Remove this Drop instance from a group, this should be used for on-the-fly group removals.
202
 
        * @param {String} g The group to remove this Drop Instance from.
203
 
        * @return {Self}
204
 
        * @chainable
205
 
        */
206
 
        removeFromGroup: function(g) {
207
 
            delete this._groups[g];
208
 
            return this;
209
 
        },
210
 
        /**
211
 
        * @private
212
 
        * @method _createEvents
213
 
        * @description This method creates all the events for this Event Target and publishes them so we get Event Bubbling.
214
 
        */
215
 
        _createEvents: function() {
216
 
            
217
 
            var ev = [
218
 
                EV_DROP_OVER,
219
 
                EV_DROP_ENTER,
220
 
                EV_DROP_EXIT,
221
 
                'drop:hit'
222
 
            ];
223
 
 
224
 
            Y.each(ev, function(v, k) {
225
 
                this.publish(v, {
226
 
                    type: v,
227
 
                    emitFacade: true,
228
 
                    preventable: false,
229
 
                    bubbles: true,
230
 
                    queuable: false,
231
 
                    prefix: 'drop'
232
 
                });
233
 
            }, this);
234
 
        },
235
 
        /**
236
 
        * @private
237
 
        * @property _valid
238
 
        * @description Flag for determining if the target is valid in this operation.
239
 
        * @type Boolean
240
 
        */
241
 
        _valid: null,
242
 
        /**
243
 
        * @private
244
 
        * @property _groups
245
 
        * @description The groups this target belongs to.
246
 
        * @type Array
247
 
        */
248
 
        _groups: null,
249
 
        /**
250
 
        * @property shim
251
 
        * @description Node reference to the targets shim
252
 
        * @type {Object}
253
 
        */
254
 
        shim: null,
255
 
        /**
256
 
        * @property region
257
 
        * @description A region object associated with this target, used for checking regions while dragging.
258
 
        * @type Object
259
 
        */
260
 
        region: null,
261
 
        /**
262
 
        * @property overTarget
263
 
        * @description This flag is tripped when a drag element is over this target.
264
 
        * @type Boolean
265
 
        */
266
 
        overTarget: null,
267
 
        /**
268
 
        * @method inGroup
269
 
        * @description Check if this target is in one of the supplied groups.
270
 
        * @param {Array} groups The groups to check against
271
 
        * @return Boolean
272
 
        */
273
 
        inGroup: function(groups) {
274
 
            this._valid = false;
275
 
            var ret = false;
276
 
            Y.each(groups, function(v, k) {
277
 
                if (this._groups[v]) {
278
 
                    ret = true;
279
 
                    this._valid = true;
280
 
                }
281
 
            }, this);
282
 
            return ret;
283
 
        },
284
 
        /**
285
 
        * @private
286
 
        * @method initializer
287
 
        * @description Private lifecycle method
288
 
        */
289
 
        initializer: function(cfg) {
290
 
            Y.later(100, this, this._createEvents);
291
 
 
292
 
            var node = this.get(NODE), id;
293
 
            if (!node.get('id')) {
294
 
                id = Y.stamp(node);
295
 
                node.set('id', id);
296
 
            }
297
 
            node.addClass(DDM.CSS_PREFIX + '-drop');
298
 
            //Shouldn't have to do this..
299
 
            this.set('groups', this.get('groups'));           
300
 
        },
301
 
        /**
302
 
        * @private
303
 
        * @method destructor
304
 
        * @description Lifecycle destructor, unreg the drag from the DDM and remove listeners
305
 
        */
306
 
        destructor: function() {
307
 
            DDM._unregTarget(this);
308
 
            if (this.shim && (this.shim !== this.get(NODE))) {
309
 
                this.shim.detachAll();
310
 
                this.shim.remove();
311
 
                this.shim = null;
312
 
            }
313
 
            this.get(NODE).removeClass(DDM.CSS_PREFIX + '-drop');
314
 
            this.detachAll();
315
 
        },
316
 
        /**
317
 
        * @private
318
 
        * @method _deactivateShim
319
 
        * @description Removes classes from the target, resets some flags and sets the shims deactive position [-999, -999]
320
 
        */
321
 
        _deactivateShim: function() {
322
 
            if (!this.shim) {
323
 
                return false;
324
 
            }
325
 
            this.get(NODE).removeClass(DDM.CSS_PREFIX + '-drop-active-valid');
326
 
            this.get(NODE).removeClass(DDM.CSS_PREFIX + '-drop-active-invalid');
327
 
            this.get(NODE).removeClass(DDM.CSS_PREFIX + '-drop-over');
328
 
 
329
 
            if (this.get('useShim')) {
330
 
                this.shim.setStyles({
331
 
                    top: '-999px',
332
 
                    left: '-999px',
333
 
                    zIndex: '1'
334
 
                });
335
 
            }
336
 
            this.overTarget = false;
337
 
        },
338
 
        /**
339
 
        * @private
340
 
        * @method _activateShim
341
 
        * @description Activates the shim and adds some interaction CSS classes
342
 
        */
343
 
        _activateShim: function() {
344
 
            if (!DDM.activeDrag) {
345
 
                return false; //Nothing is dragging, no reason to activate.
346
 
            }
347
 
            if (this.get(NODE) === DDM.activeDrag.get(NODE)) {
348
 
                return false;
349
 
            }
350
 
            if (this.get('lock')) {
351
 
                return false;
352
 
            }
353
 
            var node = this.get(NODE);
354
 
            //TODO Visibility Check..
355
 
            //if (this.inGroup(DDM.activeDrag.get('groups')) && this.get(NODE).isVisible()) {
356
 
            if (this.inGroup(DDM.activeDrag.get('groups'))) {
357
 
                node.removeClass(DDM.CSS_PREFIX + '-drop-active-invalid');
358
 
                node.addClass(DDM.CSS_PREFIX + '-drop-active-valid');
359
 
                DDM._addValid(this);
360
 
                this.overTarget = false;
361
 
                if (!this.get('useShim')) {
362
 
                    this.shim = this.get(NODE);
363
 
                }
364
 
                this.sizeShim();
365
 
            } else {
366
 
                DDM._removeValid(this);
367
 
                node.removeClass(DDM.CSS_PREFIX + '-drop-active-valid');
368
 
                node.addClass(DDM.CSS_PREFIX + '-drop-active-invalid');
369
 
            }
370
 
        },
371
 
        /**
372
 
        * @method sizeShim
373
 
        * @description Positions and sizes the shim with the raw data from the node, this can be used to programatically adjust the Targets shim for Animation..
374
 
        */
375
 
        sizeShim: function() {
376
 
            if (!DDM.activeDrag) {
377
 
                return false; //Nothing is dragging, no reason to activate.
378
 
            }
379
 
            if (this.get(NODE) === DDM.activeDrag.get(NODE)) {
380
 
                return false;
381
 
            }
382
 
            //if (this.get('lock') || !this.get('useShim')) {
383
 
            if (this.get('lock')) {
384
 
                return false;
385
 
            }
386
 
            if (!this.shim) {
387
 
                Y.later(100, this, this.sizeShim);
388
 
                return false;
389
 
            }
390
 
            var node = this.get(NODE),
391
 
                nh = node.get(OFFSET_HEIGHT),
392
 
                nw = node.get(OFFSET_WIDTH),
393
 
                xy = node.getXY(),
394
 
                p = this.get('padding'),
395
 
                dd, dH, dW;
396
 
 
397
 
 
398
 
            //Apply padding
399
 
            nw = nw + p.left + p.right;
400
 
            nh = nh + p.top + p.bottom;
401
 
            xy[0] = xy[0] - p.left;
402
 
            xy[1] = xy[1] - p.top;
403
 
            
404
 
 
405
 
            if (DDM.activeDrag.get('dragMode') === DDM.INTERSECT) {
406
 
                //Intersect Mode, make the shim bigger
407
 
                dd = DDM.activeDrag;
408
 
                dH = dd.get(NODE).get(OFFSET_HEIGHT);
409
 
                dW = dd.get(NODE).get(OFFSET_WIDTH);
410
 
                
411
 
                nh = (nh + dH);
412
 
                nw = (nw + dW);
413
 
                xy[0] = xy[0] - (dW - dd.deltaXY[0]);
414
 
                xy[1] = xy[1] - (dH - dd.deltaXY[1]);
415
 
 
416
 
            }
417
 
            
418
 
            if (this.get('useShim')) {
419
 
                //Set the style on the shim
420
 
                this.shim.setStyles({
421
 
                    height: nh + 'px',
422
 
                    width: nw + 'px',
423
 
                    top: xy[1] + 'px',
424
 
                    left: xy[0] + 'px'
425
 
                });
426
 
            }
427
 
 
428
 
            //Create the region to be used by intersect when a drag node is over us.
429
 
            this.region = {
430
 
                '0': xy[0], 
431
 
                '1': xy[1],
432
 
                area: 0,
433
 
                top: xy[1],
434
 
                right: xy[0] + nw,
435
 
                bottom: xy[1] + nh,
436
 
                left: xy[0]
437
 
            };
438
 
        },
439
 
        /**
440
 
        * @private
441
 
        * @method _createShim
442
 
        * @description Creates the Target shim and adds it to the DDM's playground..
443
 
        */
444
 
        _createShim: function() {
445
 
            //No playground, defer
446
 
            if (!DDM._pg) {
447
 
                Y.later(10, this, this._createShim);
448
 
                return;
449
 
            }
450
 
            //Shim already here, cancel
451
 
            if (this.shim) {
452
 
                return;
453
 
            }
454
 
            var s = this.get('node');
455
 
 
456
 
            if (this.get('useShim')) {
457
 
                s = Y.Node.create('<div id="' + this.get(NODE).get('id') + '_shim"></div>');
458
 
                s.setStyles({
459
 
                    height: this.get(NODE).get(OFFSET_HEIGHT) + 'px',
460
 
                    width: this.get(NODE).get(OFFSET_WIDTH) + 'px',
461
 
                    backgroundColor: 'yellow',
462
 
                    opacity: '.5',
463
 
                    zIndex: '1',
464
 
                    overflow: 'hidden',
465
 
                    top: '-900px',
466
 
                    left: '-900px',
467
 
                    position:  'absolute'
468
 
                });
469
 
 
470
 
                DDM._pg.appendChild(s);
471
 
 
472
 
                s.on('mouseover', Y.bind(this._handleOverEvent, this));
473
 
                s.on('mouseout', Y.bind(this._handleOutEvent, this));
474
 
            }
475
 
 
476
 
 
477
 
            this.shim = s;
478
 
        },
479
 
        /**
480
 
        * @private
481
 
        * @method _handleOverTarget
482
 
        * @description This handles the over target call made from this object or from the DDM
483
 
        */
484
 
        _handleTargetOver: function() {
485
 
            if (DDM.isOverTarget(this)) {
486
 
                this.get(NODE).addClass(DDM.CSS_PREFIX + '-drop-over');
487
 
                DDM.activeDrop = this;
488
 
                DDM.otherDrops[this] = this;
489
 
                if (this.overTarget) {
490
 
                    DDM.activeDrag.fire('drag:over', { drop: this, drag: DDM.activeDrag });
491
 
                    this.fire(EV_DROP_OVER, { drop: this, drag: DDM.activeDrag });
492
 
                } else {
493
 
                    //Prevent an enter before a start..
494
 
                    if (DDM.activeDrag.get('dragging')) {
495
 
                        this.overTarget = true;
496
 
                        this.fire(EV_DROP_ENTER, { drop: this, drag: DDM.activeDrag });
497
 
                        DDM.activeDrag.fire('drag:enter', { drop: this, drag: DDM.activeDrag });
498
 
                        DDM.activeDrag.get(NODE).addClass(DDM.CSS_PREFIX + '-drag-over');
499
 
                        //TODO - Is this needed??
500
 
                        //DDM._handleTargetOver();
501
 
                    }
502
 
                }
503
 
            } else {
504
 
                this._handleOut();
505
 
            }
506
 
        },
507
 
        /**
508
 
        * @private
509
 
        * @method _handleOverEvent
510
 
        * @description Handles the mouseover DOM event on the Target Shim
511
 
        */
512
 
        _handleOverEvent: function() {
513
 
            this.shim.setStyle('zIndex', '999');
514
 
            DDM._addActiveShim(this);
515
 
        },
516
 
        /**
517
 
        * @private
518
 
        * @method _handleOutEvent
519
 
        * @description Handles the mouseout DOM event on the Target Shim
520
 
        */
521
 
        _handleOutEvent: function() {
522
 
            this.shim.setStyle('zIndex', '1');
523
 
            DDM._removeActiveShim(this);
524
 
        },
525
 
        /**
526
 
        * @private
527
 
        * @method _handleOut
528
 
        * @description Handles out of target calls/checks
529
 
        */
530
 
        _handleOut: function(force) {
531
 
            if (!DDM.isOverTarget(this) || force) {
532
 
                if (this.overTarget) {
533
 
                    this.overTarget = false;
534
 
                    if (!force) {
535
 
                        DDM._removeActiveShim(this);
536
 
                    }
537
 
                    if (DDM.activeDrag) {
538
 
                        this.get(NODE).removeClass(DDM.CSS_PREFIX + '-drop-over');
539
 
                        DDM.activeDrag.get(NODE).removeClass(DDM.CSS_PREFIX + '-drag-over');
540
 
                        this.fire(EV_DROP_EXIT);
541
 
                        DDM.activeDrag.fire('drag:exit', { drop: this });
542
 
                        delete DDM.otherDrops[this];
543
 
                    }
544
 
                }
545
 
            }
546
 
        }
547
 
    });
548
 
 
549
 
    Y.DD.Drop = Drop;
550
 
 
551
 
 
552
 
 
553
 
 
554
 
}, '3.4.1' ,{skinnable:false, requires:['dd-ddm-drop', 'dd-drag']});