Diffstat (limited to 'frontend/beta/js/YUI-extensions/grid/GridDD.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/YUI-extensions/grid/GridDD.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/grid/GridDD.js b/frontend/beta/js/YUI-extensions/grid/GridDD.js new file mode 100644 index 0000000..cdcaf39 --- a/dev/null +++ b/frontend/beta/js/YUI-extensions/grid/GridDD.js | |||
@@ -0,0 +1,101 @@ | |||
1 | |||
2 | // kill dependency issue | ||
3 | if(YAHOO.util.DDProxy){ | ||
4 | /** | ||
5 | * @class YAHOO.ext.grid.GridDD | ||
6 | * Custom implementation of YAHOO.util.DDProxy used internally by the grid | ||
7 | * @extends YAHOO.util.DDProxy | ||
8 | */ | ||
9 | YAHOO.ext.grid.GridDD = function(grid, bwrap){ | ||
10 | this.grid = grid; | ||
11 | var ddproxy = document.createElement('div'); | ||
12 | ddproxy.id = grid.container.id + '-ddproxy'; | ||
13 | ddproxy.className = 'ygrid-drag-proxy'; | ||
14 | document.body.insertBefore(ddproxy, document.body.firstChild); | ||
15 | YAHOO.util.Dom.setStyle(ddproxy, 'opacity', .80); | ||
16 | var ddicon = document.createElement('span'); | ||
17 | ddicon.className = 'ygrid-drop-icon ygrid-drop-nodrop'; | ||
18 | ddproxy.appendChild(ddicon); | ||
19 | var ddtext = document.createElement('span'); | ||
20 | ddtext.className = 'ygrid-drag-text'; | ||
21 | ddtext.innerHTML = " "; | ||
22 | ddproxy.appendChild(ddtext); | ||
23 | |||
24 | this.ddproxy = ddproxy; | ||
25 | this.ddtext = ddtext; | ||
26 | this.ddicon = ddicon; | ||
27 | YAHOO.util.Event.on(bwrap, 'click', this.handleClick, this, true); | ||
28 | YAHOO.ext.grid.GridDD.superclass.constructor.call(this, bwrap.id, 'GridDD', | ||
29 | {dragElId : ddproxy.id, resizeFrame: false}); | ||
30 | |||
31 | this.unlockDelegate = grid.selModel.unlock.createDelegate(grid.selModel); | ||
32 | }; | ||
33 | YAHOO.extendX(YAHOO.ext.grid.GridDD, YAHOO.util.DDProxy); | ||
34 | |||
35 | YAHOO.ext.grid.GridDD.prototype.handleMouseDown = function(e){ | ||
36 | var row = this.grid.getRowFromChild(YAHOO.util.Event.getTarget(e)); | ||
37 | if(!row) return; | ||
38 | if(this.grid.selModel.isSelected(row)){ | ||
39 | YAHOO.ext.grid.GridDD.superclass.handleMouseDown.call(this, e); | ||
40 | }else { | ||
41 | this.grid.selModel.unlock(); | ||
42 | YAHOO.ext.EventObject.setEvent(e); | ||
43 | this.grid.selModel.rowClick(this.grid, row.rowIndex, YAHOO.ext.EventObject); | ||
44 | YAHOO.ext.grid.GridDD.superclass.handleMouseDown.call(this, e); | ||
45 | this.grid.selModel.lock(); | ||
46 | } | ||
47 | }; | ||
48 | |||
49 | YAHOO.ext.grid.GridDD.prototype.handleClick = function(e){ | ||
50 | if(this.grid.selModel.isLocked()){ | ||
51 | setTimeout(this.unlockDelegate, 1); | ||
52 | YAHOO.util.Event.stopEvent(e); | ||
53 | } | ||
54 | }; | ||
55 | |||
56 | /** | ||
57 | * Updates the DD visual element to allow/not allow a drop | ||
58 | * @param {Boolean} dropStatus True if drop is allowed on the target | ||
59 | */ | ||
60 | YAHOO.ext.grid.GridDD.prototype.setDropStatus = function(dropStatus){ | ||
61 | if(dropStatus === true){ | ||
62 | YAHOO.util.Dom.replaceClass(this.ddicon, 'ygrid-drop-nodrop', 'ygrid-drop-ok'); | ||
63 | }else{ | ||
64 | YAHOO.util.Dom.replaceClass(this.ddicon, 'ygrid-drop-ok', 'ygrid-drop-nodrop'); | ||
65 | } | ||
66 | }; | ||
67 | |||
68 | YAHOO.ext.grid.GridDD.prototype.startDrag = function(e){ | ||
69 | this.ddtext.innerHTML = this.grid.getDragDropText(); | ||
70 | this.setDropStatus(false); | ||
71 | this.grid.selModel.lock(); | ||
72 | this.grid.fireEvent('startdrag', this.grid, this, e); | ||
73 | }; | ||
74 | |||
75 | YAHOO.ext.grid.GridDD.prototype.endDrag = function(e){ | ||
76 | YAHOO.util.Dom.setStyle(this.ddproxy, 'visibility', 'hidden'); | ||
77 | this.grid.fireEvent('enddrag', this.grid, this, e); | ||
78 | }; | ||
79 | |||
80 | YAHOO.ext.grid.GridDD.prototype.autoOffset = function(iPageX, iPageY) { | ||
81 | this.setDelta(-12, -20); | ||
82 | }; | ||
83 | |||
84 | YAHOO.ext.grid.GridDD.prototype.onDragEnter = function(e, id) { | ||
85 | this.setDropStatus(true); | ||
86 | this.grid.fireEvent('dragenter', this.grid, this, id, e); | ||
87 | }; | ||
88 | |||
89 | YAHOO.ext.grid.GridDD.prototype.onDragDrop = function(e, id) { | ||
90 | this.grid.fireEvent('dragdrop', this.grid, this, id, e); | ||
91 | }; | ||
92 | |||
93 | YAHOO.ext.grid.GridDD.prototype.onDragOver = function(e, id) { | ||
94 | this.grid.fireEvent('dragover', this.grid, this, id, e); | ||
95 | }; | ||
96 | |||
97 | YAHOO.ext.grid.GridDD.prototype.onDragOut = function(e, id) { | ||
98 | this.setDropStatus(false); | ||
99 | this.grid.fireEvent('dragout', this.grid, this, id, e); | ||
100 | }; | ||
101 | }; | ||