~bcsaller/juju-gui/charmFind

« back to all changes in this revision

Viewing changes to lib/yui/build/dd-ddm/dd-ddm-debug.js

  • Committer: kapil.foss at gmail
  • Date: 2012-07-13 18:45:59 UTC
  • Revision ID: kapil.foss@gmail.com-20120713184559-2xl7be17egsrz0c9
reshape

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.5.1 (build 22)
3
 
Copyright 2012 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('dd-ddm', function(Y) {
8
 
 
9
 
 
10
 
    /**
11
 
     * Extends the dd-ddm-base Class to add support for the viewport shim to allow a draggable node to drag to be dragged over an iframe or any other node that traps mousemove events.
12
 
     * It is also required to have Drop Targets enabled, as the viewport shim will contain the shims for the Drop Targets.
13
 
     * @module dd
14
 
     * @submodule dd-ddm
15
 
     * @for DDM
16
 
     * @namespace DD
17
 
     */
18
 
    Y.mix(Y.DD.DDM, {
19
 
        /**
20
 
        * @private
21
 
        * @property _pg
22
 
        * @description The shim placed over the screen to track the mousemove event.
23
 
        * @type {Node}
24
 
        */
25
 
        _pg: null,
26
 
        /**
27
 
        * @private
28
 
        * @property _debugShim
29
 
        * @description Set this to true to set the shims opacity to .5 for debugging it, default: false.
30
 
        * @type {Boolean}
31
 
        */
32
 
        _debugShim: false,
33
 
        _activateTargets: function() { },
34
 
        _deactivateTargets: function() {},
35
 
        _startDrag: function() {
36
 
            if (this.activeDrag && this.activeDrag.get('useShim')) {
37
 
                this._pg_activate();
38
 
                this._activateTargets();
39
 
            }
40
 
        },
41
 
        _endDrag: function() {
42
 
            this._pg_deactivate();
43
 
            this._deactivateTargets();
44
 
        },
45
 
        /**
46
 
        * @private
47
 
        * @method _pg_deactivate
48
 
        * @description Deactivates the shim
49
 
        */
50
 
        _pg_deactivate: function() {
51
 
            this._pg.setStyle('display', 'none');
52
 
        },
53
 
        /**
54
 
        * @private
55
 
        * @method _pg_activate
56
 
        * @description Activates the shim
57
 
        */
58
 
        _pg_activate: function() {
59
 
            if (!this._pg) {
60
 
                this._createPG();
61
 
            }
62
 
            var ah = this.activeDrag.get('activeHandle'), cur = 'auto';
63
 
            if (ah) {
64
 
                cur = ah.getStyle('cursor');
65
 
            }
66
 
            if (cur == 'auto') {
67
 
                cur = this.get('dragCursor');
68
 
            }
69
 
            
70
 
            this._pg_size();
71
 
            this._pg.setStyles({
72
 
                top: 0,
73
 
                left: 0,
74
 
                display: 'block',
75
 
                opacity: ((this._debugShim) ? '.5' : '0'),
76
 
                cursor: cur
77
 
            });
78
 
        },
79
 
        /**
80
 
        * @private
81
 
        * @method _pg_size
82
 
        * @description Sizes the shim on: activatation, window:scroll, window:resize
83
 
        */
84
 
        _pg_size: function() {
85
 
            if (this.activeDrag) {
86
 
                var b = Y.one('body'),
87
 
                h = b.get('docHeight'),
88
 
                w = b.get('docWidth');
89
 
                this._pg.setStyles({
90
 
                    height: h + 'px',
91
 
                    width: w + 'px'
92
 
                });
93
 
            }
94
 
        },
95
 
        /**
96
 
        * @private
97
 
        * @method _createPG
98
 
        * @description Creates the shim and adds it's listeners to it.
99
 
        */
100
 
        _createPG: function() {
101
 
            var pg = Y.Node.create('<div></div>'),
102
 
            bd = Y.one('body'), win;
103
 
            pg.setStyles({
104
 
                top: '0',
105
 
                left: '0',
106
 
                position: 'absolute',
107
 
                zIndex: '9999',
108
 
                overflow: 'hidden',
109
 
                backgroundColor: 'red',
110
 
                display: 'none',
111
 
                height: '5px',
112
 
                width: '5px'
113
 
            });
114
 
            pg.set('id', Y.stamp(pg));
115
 
            pg.addClass(Y.DD.DDM.CSS_PREFIX + '-shim');
116
 
            bd.prepend(pg);
117
 
            this._pg = pg;
118
 
            this._pg.on('mousemove', Y.throttle(Y.bind(this._move, this), this.get('throttleTime')));
119
 
            this._pg.on('mouseup', Y.bind(this._end, this));
120
 
            
121
 
            win = Y.one('win');
122
 
            Y.on('window:resize', Y.bind(this._pg_size, this));
123
 
            win.on('scroll', Y.bind(this._pg_size, this));
124
 
        }   
125
 
    }, true);
126
 
 
127
 
 
128
 
 
129
 
 
130
 
}, '3.5.1' ,{skinnable:false, requires:['dd-ddm-base', 'event-resize']});