]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/grid/_grid/publicEvents.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojox / grid / _grid / publicEvents.js
1 if(!dojo._hasResource["dojox.grid._grid.publicEvents"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.grid._grid.publicEvents"] = true;
3 dojo.provide("dojox.grid._grid.publicEvents");
4
5 dojox.grid.publicEvents = {
6         // summary:
7         //              VirtualGrid mixin that provides default implementations for grid events.
8         // description: 
9         //              Default ynthetic events dispatched for VirtualGrid. dojo.connect to events to
10         //              retain default implementation or override them for custom handling.
11         
12         // cellOverClass: String
13         //              css class to apply to grid cells over which the cursor is placed.
14         cellOverClass: "dojoxGrid-cell-over",
15         
16         onKeyEvent: function(e){
17                 // summary: top level handler for Key Events
18                 this.dispatchKeyEvent(e);
19         },
20
21         onContentEvent: function(e){
22                 // summary: Top level handler for Content events
23                 this.dispatchContentEvent(e);
24         },
25
26         onHeaderEvent: function(e){
27                 // summary: Top level handler for header events
28                 this.dispatchHeaderEvent(e);
29         },
30
31         onStyleRow: function(inRow){
32                 // summary:
33                 //              Perform row styling on a given row. Called whenever row styling is updated.
34                 //
35                 // inRow: Object
36                 //              Object containing row state information: selected, true if the row is selcted; over:
37                 //              true of the mouse is over the row; odd: true if the row is odd. Use customClasses and
38                 //              customStyles to control row css classes and styles; both properties are strings.
39                 //
40                 // example: onStyleRow({ selected: true, over:true, odd:false })
41                 with(inRow){
42                         customClasses += (odd?" dojoxGrid-row-odd":"") + (selected?" dojoxGrid-row-selected":"") + (over?" dojoxGrid-row-over":"");
43                 }
44                 this.focus.styleRow(inRow);
45                 this.edit.styleRow(inRow);
46         },
47         
48         onKeyDown: function(e){
49                 // summary:
50                 //              Grid key event handler. By default enter begins editing and applies edits, escape cancels and edit,
51                 //              tab, shift-tab, and arrow keys move grid cell focus.
52                 if(e.altKey || e.ctrlKey || e.metaKey){
53                         return;
54                 }
55                 var dk = dojo.keys;
56                 switch(e.keyCode){
57                         case dk.ESCAPE:
58                                 this.edit.cancel();
59                                 break;
60                         case dk.ENTER:
61                                 if(!e.shiftKey){
62                                         var isEditing = this.edit.isEditing();
63                                         this.edit.apply();
64                                         if(!isEditing){
65                                                 this.edit.setEditCell(this.focus.cell, this.focus.rowIndex);
66                                         }
67                                 }
68                                 break;
69                         case dk.TAB:
70                                 this.focus[e.shiftKey ? 'previousKey' : 'nextKey'](e);
71                                 break;
72                         case dk.LEFT_ARROW:
73                         case dk.RIGHT_ARROW:
74                                 if(!this.edit.isEditing()){
75                                         dojo.stopEvent(e);
76                                         var offset = (e.keyCode == dk.LEFT_ARROW) ? 1 : -1;
77                                         if(dojo._isBodyLtr()){ offset *= -1; }
78                                         this.focus.move(0, offset);
79                                 }
80                                 break;
81                         case dk.UP_ARROW:
82                                 if(!this.edit.isEditing() && this.focus.rowIndex != 0){
83                                         dojo.stopEvent(e);
84                                         this.focus.move(-1, 0);
85                                 }
86                                 break;
87                         case dk.DOWN_ARROW:
88                                 if(!this.edit.isEditing() && this.focus.rowIndex+1 != this.model.count){
89                                         dojo.stopEvent(e);
90                                         this.focus.move(1, 0);
91                                 }
92                                 break;
93                         case dk.PAGE_UP:
94                                 if(!this.edit.isEditing() && this.focus.rowIndex != 0){
95                                         dojo.stopEvent(e);
96                                         if(this.focus.rowIndex != this.scroller.firstVisibleRow+1){
97                                                 this.focus.move(this.scroller.firstVisibleRow-this.focus.rowIndex, 0);
98                                         }else{
99                                                 this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex-1));
100                                                 this.focus.move(this.scroller.firstVisibleRow-this.scroller.lastVisibleRow+1, 0);
101                                         }
102                                 }
103                                 break;
104                         case dk.PAGE_DOWN:
105                                 if(!this.edit.isEditing() && this.focus.rowIndex+1 != this.model.count){
106                                         dojo.stopEvent(e);
107                                         if(this.focus.rowIndex != this.scroller.lastVisibleRow-1){
108                                                 this.focus.move(this.scroller.lastVisibleRow-this.focus.rowIndex-1, 0);
109                                         }else{
110                                                 this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex+1));
111                                                 this.focus.move(this.scroller.lastVisibleRow-this.scroller.firstVisibleRow-1, 0);
112                                         }
113                                 }
114                                 break;
115                 }
116         },
117         
118         onMouseOver: function(e){
119                 // summary:
120                 //              Event fired when mouse is over the grid.
121                 // e: Event
122                 //              Decorated event object contains reference to grid, cell, and rowIndex
123                 e.rowIndex == -1 ? this.onHeaderCellMouseOver(e) : this.onCellMouseOver(e);
124         },
125         
126         onMouseOut: function(e){
127                 // summary:
128                 //              Event fired when mouse moves out of the grid.
129                 // e: Event
130                 //              Decorated event object that contains reference to grid, cell, and rowIndex
131                 e.rowIndex == -1 ? this.onHeaderCellMouseOut(e) : this.onCellMouseOut(e);
132         },
133         
134         onMouseDown: function(e){
135                 // summary:
136                 //              Event fired when mouse is down inside grid.
137                 // e: Event
138                 //              Decorated event object that contains reference to grid, cell, and rowIndex
139                 e.rowIndex == -1 ? this.onHeaderCellMouseDown(e) : this.onCellMouseDown(e);
140         },
141         
142         onMouseOverRow: function(e){
143                 // summary:
144                 //              Event fired when mouse is over any row (data or header).
145                 // e: Event
146                 //              Decorated event object contains reference to grid, cell, and rowIndex
147                 if(!this.rows.isOver(e.rowIndex)){
148                         this.rows.setOverRow(e.rowIndex);
149                         e.rowIndex == -1 ? this.onHeaderMouseOver(e) : this.onRowMouseOver(e);
150                 }
151         },
152         onMouseOutRow: function(e){
153                 // summary:
154                 //              Event fired when mouse moves out of any row (data or header).
155                 // e: Event
156                 //              Decorated event object contains reference to grid, cell, and rowIndex
157                 if(this.rows.isOver(-1)){
158                         this.onHeaderMouseOut(e);
159                 }else if(!this.rows.isOver(-2)){
160                         this.rows.setOverRow(-2);
161                         this.onRowMouseOut(e);
162                 }
163         },
164         
165         onMouseDownRow: function(e){
166                 // summary:
167                 //              Event fired when mouse is down inside grid row
168                 // e: Event
169                 //              Decorated event object that contains reference to grid, cell, and rowIndex
170                 if(e.rowIndex != -1)
171                         this.onRowMouseDown(e);
172         },
173
174         // cell events
175         onCellMouseOver: function(e){
176                 // summary:
177                 //              Event fired when mouse is over a cell.
178                 // e: Event
179                 //              Decorated event object contains reference to grid, cell, and rowIndex
180                 dojo.addClass(e.cellNode, this.cellOverClass);
181         },
182         
183         onCellMouseOut: function(e){
184                 // summary:
185                 //              Event fired when mouse moves out of a cell.
186                 // e: Event
187                 //              Decorated event object which contains reference to grid, cell, and rowIndex
188                 dojo.removeClass(e.cellNode, this.cellOverClass);
189         },
190         
191         onCellMouseDown: function(e){
192                 // summary:
193                 //              Event fired when mouse is down in a header cell.
194                 // e: Event
195                 //              Decorated event object which contains reference to grid, cell, and rowIndex
196         },
197
198         onCellClick: function(e){
199                 // summary:
200                 //              Event fired when a cell is clicked.
201                 // e: Event
202                 //              Decorated event object which contains reference to grid, cell, and rowIndex
203                 this._click[0] = this._click[1];
204                 this._click[1] = e;
205                 if(!this.edit.isEditCell(e.rowIndex, e.cellIndex)){
206                         this.focus.setFocusCell(e.cell, e.rowIndex);
207                 }
208                 this.onRowClick(e);
209         },
210
211         onCellDblClick: function(e){
212                 // summary:
213                 //              Event fired when a cell is double-clicked.
214                 // e: Event
215                 //              Decorated event object contains reference to grid, cell, and rowIndex
216                 if(dojo.isIE){
217                         this.edit.setEditCell(this._click[1].cell, this._click[1].rowIndex);
218                 }else if(this._click[0].rowIndex != this._click[1].rowIndex){
219                         this.edit.setEditCell(this._click[0].cell, this._click[0].rowIndex);
220                 }else{
221                         this.edit.setEditCell(e.cell, e.rowIndex);
222                 }
223                 this.onRowDblClick(e);
224         },
225
226         onCellContextMenu: function(e){
227                 // summary:
228                 //              Event fired when a cell context menu is accessed via mouse right click.
229                 // e: Event
230                 //              Decorated event object which contains reference to grid, cell, and rowIndex
231                 this.onRowContextMenu(e);
232         },
233
234         onCellFocus: function(inCell, inRowIndex){
235                 // summary:
236                 //              Event fired when a cell receives focus.
237                 // inCell: Object
238                 //              Cell object containing properties of the grid column.
239                 // inRowIndex: Integer
240                 //              Index of the grid row
241                 this.edit.cellFocus(inCell, inRowIndex);
242         },
243
244         // row events
245         onRowClick: function(e){
246                 // summary:
247                 //              Event fired when a row is clicked.
248                 // e: Event
249                 //              Decorated event object which contains reference to grid, cell, and rowIndex
250                 this.edit.rowClick(e);
251                 this.selection.clickSelectEvent(e);
252         },
253
254         onRowDblClick: function(e){
255                 // summary:
256                 //              Event fired when a row is double clicked.
257                 // e: Event
258                 //              decorated event object which contains reference to grid, cell, and rowIndex
259         },
260
261         onRowMouseOver: function(e){
262                 // summary:
263                 //              Event fired when mouse moves over a data row.
264                 // e: Event
265                 //              Decorated event object which contains reference to grid, cell, and rowIndex
266         },
267
268         onRowMouseOut: function(e){
269                 // summary:
270                 //              Event fired when mouse moves out of a data row.
271                 // e: Event
272                 //              Decorated event object contains reference to grid, cell, and rowIndex
273         },
274         
275         onRowMouseDown: function(e){
276                 // summary:
277                 //              Event fired when mouse is down in a row.
278                 // e: Event
279                 //              Decorated event object which contains reference to grid, cell, and rowIndex
280         },
281
282         onRowContextMenu: function(e){
283                 // summary:
284                 //              Event fired when a row context menu is accessed via mouse right click.
285                 // e: Event
286                 //              Decorated event object which contains reference to grid, cell, and rowIndex
287                 dojo.stopEvent(e);
288         },
289
290         // header events
291         onHeaderMouseOver: function(e){
292                 // summary:
293                 //              Event fired when mouse moves over the grid header.
294                 // e: Event
295                 //              Decorated event object contains reference to grid, cell, and rowIndex
296         },
297
298         onHeaderMouseOut: function(e){
299                 // summary:
300                 //              Event fired when mouse moves out of the grid header.
301                 // e: Event
302                 //              Decorated event object which contains reference to grid, cell, and rowIndex
303         },
304
305         onHeaderCellMouseOver: function(e){
306                 // summary:
307                 //              Event fired when mouse moves over a header cell.
308                 // e: Event
309                 //              Decorated event object which contains reference to grid, cell, and rowIndex
310                 dojo.addClass(e.cellNode, this.cellOverClass);
311         },
312
313         onHeaderCellMouseOut: function(e){
314                 // summary:
315                 //              Event fired when mouse moves out of a header cell.
316                 // e: Event
317                 //              Decorated event object which contains reference to grid, cell, and rowIndex
318                 dojo.removeClass(e.cellNode, this.cellOverClass);
319         },
320         
321         onHeaderCellMouseDown: function(e) {
322                 // summary:
323                 //              Event fired when mouse is down in a header cell.
324                 // e: Event
325                 //              Decorated event object which contains reference to grid, cell, and rowIndex
326         },
327
328         onHeaderClick: function(e){
329                 // summary:
330                 //              Event fired when the grid header is clicked.
331                 // e: Event
332                 // Decorated event object which contains reference to grid, cell, and rowIndex
333         },
334
335         onHeaderCellClick: function(e){
336                 // summary:
337                 //              Event fired when a header cell is clicked.
338                 // e: Event
339                 //              Decorated event object which contains reference to grid, cell, and rowIndex
340                 this.setSortIndex(e.cell.index);
341                 this.onHeaderClick(e);
342         },
343
344         onHeaderDblClick: function(e){
345                 // summary:
346                 //              Event fired when the grid header is double clicked.
347                 // e: Event
348                 //              Decorated event object which contains reference to grid, cell, and rowIndex
349         },
350
351         onHeaderCellDblClick: function(e){
352                 // summary:
353                 //              Event fired when a header cell is double clicked.
354                 // e: Event
355                 //              Decorated event object which contains reference to grid, cell, and rowIndex
356                 this.onHeaderDblClick(e);
357         },
358
359         onHeaderCellContextMenu: function(e){
360                 // summary:
361                 //              Event fired when a header cell context menu is accessed via mouse right click.
362                 // e: Event
363                 //              Decorated event object which contains reference to grid, cell, and rowIndex
364                 this.onHeaderContextMenu(e);
365         },
366
367         onHeaderContextMenu: function(e){
368                 // summary:
369                 //              Event fired when the grid header context menu is accessed via mouse right click.
370                 // e: Event
371                 //              Decorated event object which contains reference to grid, cell, and rowIndex
372                 dojo.stopEvent(e);
373         },
374
375         // editing
376         onStartEdit: function(inCell, inRowIndex){
377                 // summary:
378                 //              Event fired when editing is started for a given grid cell
379                 // inCell: Object
380                 //              Cell object containing properties of the grid column.
381                 // inRowIndex: Integer
382                 //              Index of the grid row
383         },
384
385         onApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){
386                 // summary:
387                 //              Event fired when editing is applied for a given grid cell
388                 // inValue: String
389                 //              Value from cell editor
390                 // inRowIndex: Integer
391                 //              Index of the grid row
392                 // inFieldIndex: Integer
393                 //              Index in the grid's data model
394         },
395
396         onCancelEdit: function(inRowIndex){
397                 // summary:
398                 //              Event fired when editing is cancelled for a given grid cell
399                 // inRowIndex: Integer
400                 //              Index of the grid row
401         },
402
403         onApplyEdit: function(inRowIndex){
404                 // summary:
405                 //              Event fired when editing is applied for a given grid row
406                 // inRowIndex: Integer
407                 //              Index of the grid row
408         },
409
410         onCanSelect: function(inRowIndex){
411                 // summary:
412                 //              Event to determine if a grid row may be selected
413                 // inRowIndex: Integer
414                 //              Index of the grid row
415                 // returns: Boolean
416                 //              true if the row can be selected
417                 return true;
418         },
419
420         onCanDeselect: function(inRowIndex){
421                 // summary:
422                 //              Event to determine if a grid row may be deselected
423                 // inRowIndex: Integer
424                 //              Index of the grid row
425                 // returns: Boolean
426                 //              true if the row can be deselected
427                 return true;
428         },
429
430         onSelected: function(inRowIndex){
431                 // summary:
432                 //              Event fired when a grid row is selected
433                 // inRowIndex: Integer
434                 //              Index of the grid row
435                 this.updateRowStyles(inRowIndex);
436         },
437
438         onDeselected: function(inRowIndex){
439                 // summary:
440                 //              Event fired when a grid row is deselected
441                 // inRowIndex: Integer
442                 //              Index of the grid row
443                 this.updateRowStyles(inRowIndex);
444         },
445
446         onSelectionChanged: function(){
447         }
448
449 }
450
451 }