root / trunk / web / dojo / dojox / grid / _Events.js @ 9
History | View | Annotate | Download (5.86 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.grid._Events"]){ |
||
9 | dojo._hasResource["dojox.grid._Events"]=true; |
||
10 | dojo.provide("dojox.grid._Events");
|
||
11 | dojo.declare("dojox.grid._Events",null,{cellOverClass:"dojoxGridCellOver",onKeyEvent:function(e){ |
||
12 | this.dispatchKeyEvent(e);
|
||
13 | },onContentEvent:function(e){ |
||
14 | this.dispatchContentEvent(e);
|
||
15 | },onHeaderEvent:function(e){ |
||
16 | this.dispatchHeaderEvent(e);
|
||
17 | },onStyleRow:function(_1){ |
||
18 | var i=_1;
|
||
19 | i.customClasses+=(i.odd?" dojoxGridRowOdd":"")+(i.selected?" dojoxGridRowSelected":"")+(i.over?" dojoxGridRowOver":""); |
||
20 | this.focus.styleRow(_1);
|
||
21 | this.edit.styleRow(_1);
|
||
22 | },onKeyDown:function(e){ |
||
23 | if(e.altKey||e.metaKey){
|
||
24 | return;
|
||
25 | } |
||
26 | var dk=dojo.keys;
|
||
27 | var _2;
|
||
28 | switch(e.keyCode){
|
||
29 | case dk.ESCAPE:
|
||
30 | this.edit.cancel();
|
||
31 | break;
|
||
32 | case dk.ENTER:
|
||
33 | if(!this.edit.isEditing()){ |
||
34 | _2=this.focus.getHeaderIndex();
|
||
35 | if(_2>=0){ |
||
36 | this.setSortIndex(_2);
|
||
37 | break;
|
||
38 | }else{
|
||
39 | this.selection.clickSelect(this.focus.rowIndex,dojo.isCopyKey(e),e.shiftKey); |
||
40 | } |
||
41 | dojo.stopEvent(e); |
||
42 | } |
||
43 | if(!e.shiftKey){
|
||
44 | var _3=this.edit.isEditing(); |
||
45 | this.edit.apply();
|
||
46 | if(!_3){
|
||
47 | this.edit.setEditCell(this.focus.cell,this.focus.rowIndex); |
||
48 | } |
||
49 | } |
||
50 | if(!this.edit.isEditing()){ |
||
51 | var _4=this.focus.focusView||this.views.views[0]; |
||
52 | _4.content.decorateEvent(e); |
||
53 | this.onRowClick(e);
|
||
54 | } |
||
55 | break;
|
||
56 | case dk.SPACE:
|
||
57 | if(!this.edit.isEditing()){ |
||
58 | _2=this.focus.getHeaderIndex();
|
||
59 | if(_2>=0){ |
||
60 | this.setSortIndex(_2);
|
||
61 | break;
|
||
62 | }else{
|
||
63 | this.selection.clickSelect(this.focus.rowIndex,dojo.isCopyKey(e),e.shiftKey); |
||
64 | } |
||
65 | dojo.stopEvent(e); |
||
66 | } |
||
67 | break;
|
||
68 | case dk.TAB:
|
||
69 | this.focus[e.shiftKey?"previousKey":"nextKey"](e); |
||
70 | break;
|
||
71 | case dk.LEFT_ARROW:
|
||
72 | case dk.RIGHT_ARROW:
|
||
73 | if(!this.edit.isEditing()){ |
||
74 | var _5=e.keyCode;
|
||
75 | dojo.stopEvent(e); |
||
76 | _2=this.focus.getHeaderIndex();
|
||
77 | if(_2>=0&&(e.shiftKey&&e.ctrlKey)){ |
||
78 | this.focus.colSizeAdjust(e,_2,(_5==dk.LEFT_ARROW?-1:1)*5); |
||
79 | }else{
|
||
80 | var _6=(_5==dk.LEFT_ARROW)?1:-1; |
||
81 | if(dojo._isBodyLtr()){
|
||
82 | _6*=-1;
|
||
83 | } |
||
84 | this.focus.move(0,_6); |
||
85 | } |
||
86 | } |
||
87 | break;
|
||
88 | case dk.UP_ARROW:
|
||
89 | if(!this.edit.isEditing()&&this.focus.rowIndex!==0){ |
||
90 | dojo.stopEvent(e); |
||
91 | this.focus.move(-1,0); |
||
92 | } |
||
93 | break;
|
||
94 | case dk.DOWN_ARROW:
|
||
95 | if(!this.edit.isEditing()&&this.focus.rowIndex+1!=this.rowCount){ |
||
96 | dojo.stopEvent(e); |
||
97 | this.focus.move(1,0); |
||
98 | } |
||
99 | break;
|
||
100 | case dk.PAGE_UP:
|
||
101 | if(!this.edit.isEditing()&&this.focus.rowIndex!==0){ |
||
102 | dojo.stopEvent(e); |
||
103 | if(this.focus.rowIndex!=this.scroller.firstVisibleRow+1){ |
||
104 | this.focus.move(this.scroller.firstVisibleRow-this.focus.rowIndex,0); |
||
105 | }else{
|
||
106 | this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex-1)); |
||
107 | this.focus.move(this.scroller.firstVisibleRow-this.scroller.lastVisibleRow+1,0); |
||
108 | } |
||
109 | } |
||
110 | break;
|
||
111 | case dk.PAGE_DOWN:
|
||
112 | if(!this.edit.isEditing()&&this.focus.rowIndex+1!=this.rowCount){ |
||
113 | dojo.stopEvent(e); |
||
114 | if(this.focus.rowIndex!=this.scroller.lastVisibleRow-1){ |
||
115 | this.focus.move(this.scroller.lastVisibleRow-this.focus.rowIndex-1,0); |
||
116 | }else{
|
||
117 | this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex+1)); |
||
118 | this.focus.move(this.scroller.lastVisibleRow-this.scroller.firstVisibleRow-1,0); |
||
119 | } |
||
120 | } |
||
121 | break;
|
||
122 | default:
|
||
123 | break;
|
||
124 | } |
||
125 | },onMouseOver:function(e){ |
||
126 | e.rowIndex==-1?this.onHeaderCellMouseOver(e):this.onCellMouseOver(e); |
||
127 | },onMouseOut:function(e){ |
||
128 | e.rowIndex==-1?this.onHeaderCellMouseOut(e):this.onCellMouseOut(e); |
||
129 | },onMouseDown:function(e){ |
||
130 | e.rowIndex==-1?this.onHeaderCellMouseDown(e):this.onCellMouseDown(e); |
||
131 | },onMouseOverRow:function(e){ |
||
132 | if(!this.rows.isOver(e.rowIndex)){ |
||
133 | this.rows.setOverRow(e.rowIndex);
|
||
134 | e.rowIndex==-1?this.onHeaderMouseOver(e):this.onRowMouseOver(e); |
||
135 | } |
||
136 | },onMouseOutRow:function(e){ |
||
137 | if(this.rows.isOver(-1)){ |
||
138 | this.onHeaderMouseOut(e);
|
||
139 | }else{
|
||
140 | if(!this.rows.isOver(-2)){ |
||
141 | this.rows.setOverRow(-2); |
||
142 | this.onRowMouseOut(e);
|
||
143 | } |
||
144 | } |
||
145 | },onMouseDownRow:function(e){ |
||
146 | if(e.rowIndex!=-1){ |
||
147 | this.onRowMouseDown(e);
|
||
148 | } |
||
149 | },onCellMouseOver:function(e){ |
||
150 | if(e.cellNode){
|
||
151 | dojo.addClass(e.cellNode,this.cellOverClass);
|
||
152 | } |
||
153 | },onCellMouseOut:function(e){ |
||
154 | if(e.cellNode){
|
||
155 | dojo.removeClass(e.cellNode,this.cellOverClass);
|
||
156 | } |
||
157 | },onCellMouseDown:function(e){ |
||
158 | },onCellClick:function(e){ |
||
159 | this._click[0]=this._click[1]; |
||
160 | this._click[1]=e; |
||
161 | if(!this.edit.isEditCell(e.rowIndex,e.cellIndex)){ |
||
162 | this.focus.setFocusCell(e.cell,e.rowIndex);
|
||
163 | } |
||
164 | this.onRowClick(e);
|
||
165 | },onCellDblClick:function(e){ |
||
166 | if(this._click.length>1&&dojo.isIE){ |
||
167 | this.edit.setEditCell(this._click[1].cell,this._click[1].rowIndex); |
||
168 | }else{
|
||
169 | if(this._click.length>1&&this._click[0].rowIndex!=this._click[1].rowIndex){ |
||
170 | this.edit.setEditCell(this._click[0].cell,this._click[0].rowIndex); |
||
171 | }else{
|
||
172 | this.edit.setEditCell(e.cell,e.rowIndex);
|
||
173 | } |
||
174 | } |
||
175 | this.onRowDblClick(e);
|
||
176 | },onCellContextMenu:function(e){ |
||
177 | this.onRowContextMenu(e);
|
||
178 | },onCellFocus:function(_7,_8){ |
||
179 | this.edit.cellFocus(_7,_8);
|
||
180 | },onRowClick:function(e){ |
||
181 | this.edit.rowClick(e);
|
||
182 | this.selection.clickSelectEvent(e);
|
||
183 | },onRowDblClick:function(e){ |
||
184 | },onRowMouseOver:function(e){ |
||
185 | },onRowMouseOut:function(e){ |
||
186 | },onRowMouseDown:function(e){ |
||
187 | },onRowContextMenu:function(e){ |
||
188 | dojo.stopEvent(e); |
||
189 | },onHeaderMouseOver:function(e){ |
||
190 | },onHeaderMouseOut:function(e){ |
||
191 | },onHeaderCellMouseOver:function(e){ |
||
192 | if(e.cellNode){
|
||
193 | dojo.addClass(e.cellNode,this.cellOverClass);
|
||
194 | } |
||
195 | },onHeaderCellMouseOut:function(e){ |
||
196 | if(e.cellNode){
|
||
197 | dojo.removeClass(e.cellNode,this.cellOverClass);
|
||
198 | } |
||
199 | },onHeaderCellMouseDown:function(e){ |
||
200 | },onHeaderClick:function(e){ |
||
201 | },onHeaderCellClick:function(e){ |
||
202 | this.setSortIndex(e.cell.index);
|
||
203 | this.onHeaderClick(e);
|
||
204 | },onHeaderDblClick:function(e){ |
||
205 | },onHeaderCellDblClick:function(e){ |
||
206 | this.onHeaderDblClick(e);
|
||
207 | },onHeaderCellContextMenu:function(e){ |
||
208 | this.onHeaderContextMenu(e);
|
||
209 | },onHeaderContextMenu:function(e){ |
||
210 | if(!this.headerMenu){ |
||
211 | dojo.stopEvent(e); |
||
212 | } |
||
213 | },onStartEdit:function(_9,_a){ |
||
214 | },onApplyCellEdit:function(_b,_c,_d){ |
||
215 | },onCancelEdit:function(_e){ |
||
216 | },onApplyEdit:function(_f){ |
||
217 | },onCanSelect:function(_10){ |
||
218 | return true; |
||
219 | },onCanDeselect:function(_11){ |
||
220 | return true; |
||
221 | },onSelected:function(_12){ |
||
222 | this.updateRowStyles(_12);
|
||
223 | },onDeselected:function(_13){ |
||
224 | this.updateRowStyles(_13);
|
||
225 | },onSelectionChanged:function(){ |
||
226 | }}); |
||
227 | } |