2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('dd-ddm', function(Y) {
12 * 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.
13 * It is also required to have Drop Targets enabled, as the viewport shim will contain the shims for the Drop Targets.
23 * @description The shim placed over the screen to track the mousemove event.
29 * @property _debugShim
30 * @description Set this to true to set the shims opacity to .5 for debugging it, default: false.
34 _activateTargets: function() { },
35 _deactivateTargets: function() {},
36 _startDrag: function() {
37 if (this.activeDrag && this.activeDrag.get('useShim')) {
39 this._activateTargets();
42 _endDrag: function() {
43 this._pg_deactivate();
44 this._deactivateTargets();
48 * @method _pg_deactivate
49 * @description Deactivates the shim
51 _pg_deactivate: function() {
52 this._pg.setStyle('display', 'none');
56 * @method _pg_activate
57 * @description Activates the shim
59 _pg_activate: function() {
60 var ah = this.activeDrag.get('activeHandle'), cur = 'auto';
62 cur = ah.getStyle('cursor');
65 cur = this.get('dragCursor');
73 opacity: ((this._debugShim) ? '.5' : '0'),
80 * @description Sizes the shim on: activatation, window:scroll, window:resize
82 _pg_size: function() {
83 if (this.activeDrag) {
84 var b = Y.one('body'),
85 h = b.get('docHeight'),
86 w = b.get('docWidth');
96 * @description Creates the shim and adds it's listeners to it.
98 _createPG: function() {
99 var pg = Y.Node.create('<div></div>'),
100 bd = Y.one('body'), win;
104 position: 'absolute',
107 backgroundColor: 'red',
112 pg.set('id', Y.stamp(pg));
113 pg.addClass(Y.DD.DDM.CSS_PREFIX + '-shim');
116 this._pg.on('mousemove', Y.throttle(Y.bind(this._move, this), this.get('throttleTime')));
117 this._pg.on('mouseup', Y.bind(this._end, this));
120 Y.on('window:resize', Y.bind(this._pg_size, this));
121 win.on('scroll', Y.bind(this._pg_size, this));
128 }, '3.3.0' ,{requires:['dd-ddm-base', 'event-resize'], skinnable:false});