dd-ddm.js revision 0ce21a2762300a493f87331397ca2b814905718b
486N/AYUI.add('dd-ddm', function(Y) {
486N/A
486N/A
486N/A /**
486N/A * 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.
486N/A * It is also required to have Drop Targets enabled, as the viewport shim will contain the shims for the Drop Targets.
486N/A * @module dd
486N/A * @submodule dd-ddm
486N/A * @for DDM
486N/A * @namespace DD
486N/A */
486N/A Y.mix(Y.DD.DDM, {
486N/A /**
486N/A * @private
486N/A * @property _pg
486N/A * @description The shim placed over the screen to track the mousemove event.
486N/A * @type {Node}
486N/A */
486N/A _pg: null,
873N/A /**
486N/A * @private
486N/A * @property _debugShim
486N/A * @description Set this to true to set the shims opacity to .5 for debugging it, default: false.
486N/A * @type {Boolean}
486N/A */
4362N/A _debugShim: false,
6031N/A _activateTargets: function() { },
486N/A _deactivateTargets: function() {},
486N/A _startDrag: function() {
619N/A if (this.activeDrag.get('useShim')) {
619N/A this._pg_activate();
619N/A this._activateTargets();
619N/A }
619N/A },
3488N/A _endDrag: function() {
619N/A this._pg_deactivate();
619N/A this._deactivateTargets();
619N/A },
3824N/A /**
3824N/A * @private
3824N/A * @method _pg_deactivate
619N/A * @description Deactivates the shim
619N/A */
486N/A _pg_deactivate: function() {
536N/A this._pg.setStyle('display', 'none');
2976N/A },
2976N/A /**
536N/A * @private
5306N/A * @method _pg_activate
3972N/A * @description Activates the shim
5636N/A */
5306N/A _pg_activate: function() {
3972N/A var ah = this.activeDrag.get('activeHandle'), cur = 'auto';
5306N/A if (ah) {
3972N/A cur = ah.getStyle('cursor');
3978N/A }
3972N/A if (cur == 'auto') {
3972N/A cur = this.get('dragCursor');
3978N/A }
3978N/A
3978N/A this._pg_size();
3972N/A this._pg.setStyles({
3972N/A top: 0,
3972N/A left: 0,
5306N/A display: 'block',
3972N/A opacity: ((this._debugShim) ? '.5' : '0'),
3972N/A cursor: cur
3972N/A });
2976N/A },
2976N/A /**
2976N/A * @private
3860N/A * @method _pg_size
3860N/A * @description Sizes the shim on: activatation, window:scroll, window:resize
3824N/A */
2976N/A _pg_size: function() {
2976N/A if (this.activeDrag) {
1181N/A var b = Y.one('body'),
2976N/A h = b.get('docHeight'),
1181N/A w = b.get('docWidth');
536N/A this._pg.setStyles({
3860N/A height: h + 'px',
3860N/A width: w + 'px'
3860N/A });
3860N/A }
3860N/A },
3860N/A /**
3860N/A * @private
2976N/A * @method _createPG
830N/A * @description Creates the shim and adds it's listeners to it.
830N/A */
830N/A _createPG: function() {
830N/A var pg = Y.Node.create('<div></div>'),
830N/A bd = Y.one('body'), win;
830N/A pg.setStyles({
6031N/A top: '0',
830N/A left: '0',
830N/A position: 'absolute',
830N/A zIndex: '9999',
2296N/A overflow: 'hidden',
830N/A backgroundColor: 'red',
961N/A display: 'none',
961N/A height: '5px',
961N/A width: '5px'
486N/A });
5636N/A pg.set('id', Y.stamp(pg));
486N/A pg.addClass('yui3-dd-shim');
486N/A if (bd.get('firstChild')) {
486N/A bd.insertBefore(pg, bd.get('firstChild'));
486N/A } else {
2296N/A bd.appendChild(pg);
2296N/A }
5636N/A this._pg = pg;
4362N/A this._pg.on('mouseup', Y.bind(this._end, this));
2296N/A this._pg.on('mousemove', Y.throttle(Y.bind(this._move, this), this.get('throttleTime')));
5636N/A
4362N/A win = Y.one('win');
2296N/A Y.on('window:resize', Y.bind(this._pg_size, this));
2402N/A win.on('scroll', Y.bind(this._pg_size, this));
2402N/A }
2402N/A }, true);
2402N/A
6031N/A
2402N/A
2422N/A
2402N/A}, '@VERSION@' ,{requires:['dd-ddm-base', 'event-resize'], skinnable:false});
2402N/A