Debian Codegraph @

dojox/grid/enhanced/_Events.js

raw symbols SCIP
1 define([
2 "dojo/_base/kernel",
3 "dojo/_base/declare",
4 "dojo/keys",
5 "dojo/_base/html",
6 "dojo/_base/event",
7 "dojox/grid/_Events"
8 ], function(dojo, declare, keys, html, event, _Events){
9
10 return declare("dojox.grid.enhanced._Events", null, {
11 // summary:
12 // Overwrite some default events of DataGrid
13 //
14 // description:
15 // Methods are copied or replaced for overwriting, this might be refined once
16 // an overall plugin architecture is set up for DataGrid.
17
18 // _events: Object
19 // Method map cached from dojox.grid._Events().
20 _events: null,
21
22 // headerCellActiveClass: String
23 // css class to apply to grid header cells when activated(mouse down)
24 headerCellActiveClass: 'dojoxGridHeaderActive',
25
26 // cellActiveClass: String
27 // css class to apply to grid content cells when activated(mouse down)
28 cellActiveClass: 'dojoxGridCellActive',
29
30 // rowActiveClass: String
31 // css class to apply to grid rows when activated(mouse down)
32 rowActiveClass: 'dojoxGridRowActive',
33
34 constructor: function(inGrid){
35 //TODO - extend dojox.grid._Events rather than mixin for 1.8
36 this._events = new _Events();
37 //mixin "this" to Grid
38 inGrid.mixin(inGrid, this);
39 },
40 dokeyup: function(e){
41 // summary:
42 // Grid key up event handler.
43 // e: Event
44 // Un-decorated event object
45 this.focus.currentArea().keyup(e);
46 },
47 onKeyDown: function(e){
48 // summary:
49 // Overwritten, see dojox.grid._Events.onKeyDown();
50 if(e.altKey || e.metaKey){ return; }
51 var focus = this.focus;
52 var editing = this.edit.isEditing();
53 switch(e.keyCode){
54 case keys.TAB:
55 if(e.ctrlKey){ return; }
56 focus.tab(e.shiftKey ? -1:1,e);
57 break;
58 case keys.UP_ARROW:
59 case keys.DOWN_ARROW:
60 if(editing){ return; }
61 focus.currentArea().move(e.keyCode == keys.UP_ARROW ? -1 : 1, 0, e);
62 break;
63 case keys.LEFT_ARROW:
64 case keys.RIGHT_ARROW:
65 if(editing){ return; }
66 var offset = (e.keyCode == keys.LEFT_ARROW) ? 1 : -1;
67 if(html._isBodyLtr()){ offset *= -1; }
68 focus.currentArea().move(0, offset, e);
69 break;
70 case keys.F10:
71 if(this.menus && e.shiftKey){
72 this.onRowContextMenu(e);
73 }
74 break;
75 default:
76 focus.currentArea().keydown(e);
77 break;
78 }
79 },
80 //TODO - make the following events more reasonalble - e.g. more accurate conditions
81 //events for row selectors
82 domouseup: function(e){
83 if(e.cellNode){
84 this.onMouseUp(e);
85 }else{
86 this.onRowSelectorMouseUp(e);
87 }
88 },
89 domousedown: function(e){
90 if(!e.cellNode){
91 this.onRowSelectorMouseDown(e);
92 }
93 },
94 onMouseUp: function(e){
95 // summary:
96 // New - Event fired when mouse is up inside grid.
97 // e: Event
98 // Decorated event object that contains reference to grid, cell, and rowIndex
99 this[e.rowIndex == -1 ? "onHeaderCellMouseUp" : "onCellMouseUp"](e);
100 },
101 onCellMouseDown: function(e){
102 // summary:
103 // Overwritten, see dojox.grid._Events.onCellMouseDown()
104 html.addClass(e.cellNode, this.cellActiveClass);
105 html.addClass(e.rowNode, this.rowActiveClass);
106 },
107 onCellMouseUp: function(e){
108 // summary:
109 // New - Event fired when mouse is up inside content cell.
110 // e: Event
111 // Decorated event object that contains reference to grid, cell, and rowIndex
112 html.removeClass(e.cellNode, this.cellActiveClass);
113 html.removeClass(e.rowNode, this.rowActiveClass);
114 },
115 onCellClick: function(e){
116 // summary:
117 // Overwritten, see dojox.grid._Events.onCellClick()
118
119 //invoke dojox.grid._Events.onCellClick()
120 this._events.onCellClick.call(this, e);
121 //move mouse events to the focus manager.
122 this.focus.contentMouseEvent(e);//TODO
123 },
124 onCellDblClick: function(e){
125 // summary:
126 // Overwritten, see dojox.grid._Events.onCellDblClick()
127 if(this.pluginMgr.isFixedCell(e.cell)){ return; }
128 if(this._click.length > 1 && (!this._click[0] || !this._click[1])){
129 this._click[0] = this._click[1] = e;
130 }
131 //invoke dojox.grid._Events.onCellDblClick()
132 this._events.onCellDblClick.call(this, e);
133 },
134 onRowClick: function(e){
135 // summary:
136 // Overwritten, see dojox.grid._Events.onRowClick()
137 this.edit.rowClick(e);
138 if(!e.cell || !this.plugin('indirectSelection')){
139 this.selection.clickSelectEvent(e);
140 }
141 },
142 onRowContextMenu: function(e){
143 // summary:
144 // Overwritten, see dojox.grid._Events.onRowContextMenu()
145 if(!this.edit.isEditing() && this.menus){
146 this.showMenu(e);
147 }
148 },
149 onSelectedRegionContextMenu: function(e){
150 // summary:
151 // New - Event fired when a selected region context menu is accessed via mouse right click.
152 // e: Event
153 // Decorated event object which contains reference to grid and info of selected
154 // regions(selection type - row|column, selected index - [...])
155 if(this.selectedRegionMenu){
156 this.selectedRegionMenu._openMyself({
157 target: e.target,
158 coords: e.keyCode !== keys.F10 && "pageX" in e ? {
159 x: e.pageX,
160 y: e.pageY
161 } : null
162 });
163 event.stop(e);
164 }
165 },
166 onHeaderCellMouseOut: function(e){
167 // summary:
168 // Overwritten, see dojox.grid._Events.onHeaderCellMouseOut()
169 if(e.cellNode){
170 html.removeClass(e.cellNode, this.cellOverClass);
171 html.removeClass(e.cellNode, this.headerCellActiveClass);
172 }
173 },
174 onHeaderCellMouseDown: function(e){
175 // summary:
176 // Overwritten, see dojox.grid._Events.onHeaderCellMouseDown()
177 if(e.cellNode){//TBD - apply to selection region for nested sorting?
178 html.addClass(e.cellNode, this.headerCellActiveClass);
179 }
180 },
181 onHeaderCellMouseUp: function(e){
182 // summary:
183 // New event
184 if(e.cellNode){
185 html.removeClass(e.cellNode, this.headerCellActiveClass);
186 }
187 },
188 onHeaderCellClick: function(e){
189 // summary:
190 // Overwritten, see dojox.grid._Events.onHeaderCellClick()
191
192 //move focus to header.
193 this.focus.currentArea("header");
194 //invoke dojox.grid._Events.onHeaderCellClick()
195 if(!e.cell.isRowSelector){
196 this._events.onHeaderCellClick.call(this, e);
197 }
198 //move mouse events to the focus manager.
199 this.focus.headerMouseEvent(e);
200 },
201 onRowSelectorMouseDown: function(e){
202 this.focus.focusArea("rowHeader", e);
203 },
204
205 onRowSelectorMouseUp: function(e){},
206
207 //triggered in _View, see Selector plugin
208 onMouseUpRow: function(e){
209 if(e.rowIndex != -1){
210 this.onRowMouseUp(e);
211 }
212 },
213 onRowMouseUp: function(e){}
214 });
215 });