~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/yui/build/dd/dd-ddm.js

  • Committer: Paul Hummer
  • Date: 2008-10-20 07:34:21 UTC
  • mto: This revision was merged to the branch mainline in revision 230.
  • Revision ID: paul@ubuntu.com-20081020073421-23tcue15338zryqq
Added forgotten library

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
 
3
Code licensed under the BSD License:
 
4
http://developer.yahoo.net/yui/license.txt
 
5
version: 3.0.0pr1
 
6
*/
 
7
YUI.add('dd-ddm', function(Y) {
 
8
 
 
9
    /**
 
10
     * 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.
 
11
     * It is also required to have Drop Targets enabled, as the viewport shim will contain the shims for the Drop Targets.
 
12
     * @module dd
 
13
     * @submodule dd-ddm
 
14
     * @for DDM
 
15
     */
 
16
    Y.mix(Y.DD.DDM, {
 
17
        /**
 
18
        * @private
 
19
        * @property _pg
 
20
        * @description The shim placed over the screen to track the mousemove event.
 
21
        * @type {Node}
 
22
        */
 
23
        _pg: null,
 
24
        /**
 
25
        * @private
 
26
        * @property _debugShim
 
27
        * @description Set this to true to set the shims opacity to .5 for debugging it, default: false.
 
28
        * @type {Boolean}
 
29
        */
 
30
        _debugShim: false,
 
31
        _activateTargets: function() {},
 
32
        _deactivateTargets: function() {},
 
33
        _startDrag: function() {
 
34
            if (this.activeDrag.get('useShim')) {
 
35
                this._pg_activate();
 
36
                this._activateTargets();
 
37
            }
 
38
        },
 
39
        _endDrag: function() {
 
40
            this._pg_deactivate();
 
41
            this._deactivateTargets();
 
42
        },
 
43
        /**
 
44
        * @private
 
45
        * @method _pg_deactivate
 
46
        * @description Deactivates the shim
 
47
        */
 
48
        _pg_deactivate: function() {
 
49
            this._pg.setStyle('display', 'none');
 
50
        },
 
51
        /**
 
52
        * @private
 
53
        * @method _pg_activate
 
54
        * @description Activates the shim
 
55
        */
 
56
        _pg_activate: function() {
 
57
            this._pg_size();
 
58
            this._pg.setStyles({
 
59
                top: 0,
 
60
                left: 0,
 
61
                display: 'block',
 
62
                opacity: ((this._debugShim) ? '.5' : '0')
 
63
            });
 
64
        },
 
65
        /**
 
66
        * @private
 
67
        * @method _pg_size
 
68
        * @description Sizes the shim on: activatation, window:scroll, window:resize
 
69
        */
 
70
        _pg_size: function() {
 
71
            if (this.activeDrag) {
 
72
                var b = Y.Node.get('body'),
 
73
                h = b.get('docHeight'),
 
74
                w = b.get('docWidth');
 
75
                this._pg.setStyles({
 
76
                    height: h + 'px',
 
77
                    width: w + 'px'
 
78
                });
 
79
            }
 
80
        },
 
81
        /**
 
82
        * @private
 
83
        * @method _createPG
 
84
        * @description Creates the shim and adds it's listeners to it.
 
85
        */
 
86
        _createPG: function() {
 
87
            //var pg = Y.Node.create(['div']),
 
88
            var pg = Y.Node.create('<div></div>'),
 
89
            bd = Y.Node.get('body');
 
90
            pg.setStyles({
 
91
                top: '0',
 
92
                left: '0',
 
93
                position: 'absolute',
 
94
                zIndex: '9999',
 
95
                overflow: 'hidden',
 
96
                //opacity: '0',
 
97
                backgroundColor: 'red',
 
98
                display: 'none',
 
99
                height: '5px',
 
100
                width: '5px'
 
101
            });
 
102
            if (bd.get('firstChild')) {
 
103
                bd.insertBefore(pg, bd.get('firstChild'));
 
104
            } else {
 
105
                bd.appendChild(pg);
 
106
            }
 
107
            this._pg = pg;
 
108
            this._pg.on('mouseup', this._end, this, true);
 
109
            this._pg.on('mousemove', this._move, this, true);
 
110
            
 
111
            
 
112
            //TODO
 
113
            Y.Event.addListener(window, 'resize', this._pg_size, this, true);
 
114
            Y.Event.addListener(window, 'scroll', this._pg_size, this, true);
 
115
        }   
 
116
    }, true);
 
117
 
 
118
    Y.DD.DDM._createPG();    
 
119
 
 
120
 
 
121
 
 
122
}, '3.0.0pr1' ,{requires:['dd-ddm-base'], skinnable:false});