123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- if(!dojo._hasResource["dojox.grid._Events"]){
- dojo._hasResource["dojox.grid._Events"] = true;
- dojo.provide("dojox.grid._Events");
- dojo.declare("dojox.grid._Events", null, {
-
-
-
-
-
-
-
-
- cellOverClass: "dojoxGridCellOver",
-
- onKeyEvent: function(e){
-
- this.dispatchKeyEvent(e);
- },
- onContentEvent: function(e){
-
- this.dispatchContentEvent(e);
- },
- onHeaderEvent: function(e){
-
- this.dispatchHeaderEvent(e);
- },
- onStyleRow: function(inRow){
-
-
-
-
-
-
-
-
-
- var i = inRow;
- i.customClasses += (i.odd?" dojoxGridRowOdd":"") + (i.selected?" dojoxGridRowSelected":"") + (i.over?" dojoxGridRowOver":"");
- this.focus.styleRow(inRow);
- this.edit.styleRow(inRow);
- },
-
- onKeyDown: function(e){
-
-
-
- if(e.altKey || e.metaKey){
- return;
- }
- var dk = dojo.keys;
- var colIdx;
- switch(e.keyCode){
- case dk.ESCAPE:
- this.edit.cancel();
- break;
- case dk.ENTER:
- if(!this.edit.isEditing()){
- colIdx = this.focus.getHeaderIndex();
- if(colIdx >= 0) {
- this.setSortIndex(colIdx);
- break;
- }else {
- this.selection.clickSelect(this.focus.rowIndex, dojo.isCopyKey(e), e.shiftKey);
- }
- dojo.stopEvent(e);
- }
- if(!e.shiftKey){
- var isEditing = this.edit.isEditing();
- this.edit.apply();
- if(!isEditing){
- this.edit.setEditCell(this.focus.cell, this.focus.rowIndex);
- }
- }
- if (!this.edit.isEditing()){
- var curView = this.focus.focusView || this.views.views[0];
- curView.content.decorateEvent(e);
- this.onRowClick(e);
- dojo.stopEvent(e);
- }
- break;
- case dk.SPACE:
- if(!this.edit.isEditing()){
- colIdx = this.focus.getHeaderIndex();
- if(colIdx >= 0) {
- this.setSortIndex(colIdx);
- break;
- }else {
- this.selection.clickSelect(this.focus.rowIndex, dojo.isCopyKey(e), e.shiftKey);
- }
- dojo.stopEvent(e);
- }
- break;
- case dk.TAB:
- this.focus[e.shiftKey ? 'previousKey' : 'nextKey'](e);
- break;
- case dk.LEFT_ARROW:
- case dk.RIGHT_ARROW:
- if(!this.edit.isEditing()){
- var keyCode = e.keyCode;
- dojo.stopEvent(e);
- colIdx = this.focus.getHeaderIndex();
- if (colIdx >= 0 && (e.shiftKey && e.ctrlKey)){
- this.focus.colSizeAdjust(e, colIdx, (keyCode == dk.LEFT_ARROW ? -1 : 1)*5);
- }
- else{
- var offset = (keyCode == dk.LEFT_ARROW) ? 1 : -1;
- if(dojo._isBodyLtr()){ offset *= -1; }
- this.focus.move(0, offset);
- }
- }
- break;
- case dk.UP_ARROW:
- if(!this.edit.isEditing() && this.focus.rowIndex !== 0){
- dojo.stopEvent(e);
- this.focus.move(-1, 0);
- }
- break;
- case dk.DOWN_ARROW:
- if(!this.edit.isEditing() && this.focus.rowIndex+1 != this.rowCount){
- dojo.stopEvent(e);
- this.focus.move(1, 0);
- }
- break;
- case dk.PAGE_UP:
- if(!this.edit.isEditing() && this.focus.rowIndex !== 0){
- dojo.stopEvent(e);
- if(this.focus.rowIndex != this.scroller.firstVisibleRow+1){
- this.focus.move(this.scroller.firstVisibleRow-this.focus.rowIndex, 0);
- }else{
- this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex-1));
- this.focus.move(this.scroller.firstVisibleRow-this.scroller.lastVisibleRow+1, 0);
- }
- }
- break;
- case dk.PAGE_DOWN:
- if(!this.edit.isEditing() && this.focus.rowIndex+1 != this.rowCount){
- dojo.stopEvent(e);
- if(this.focus.rowIndex != this.scroller.lastVisibleRow-1){
- this.focus.move(this.scroller.lastVisibleRow-this.focus.rowIndex-1, 0);
- }else{
- this.setScrollTop(this.scroller.findScrollTop(this.focus.rowIndex+1));
- this.focus.move(this.scroller.lastVisibleRow-this.scroller.firstVisibleRow-1, 0);
- }
- }
- break;
- default:
- break;
- }
- },
-
- onMouseOver: function(e){
-
-
-
-
- e.rowIndex == -1 ? this.onHeaderCellMouseOver(e) : this.onCellMouseOver(e);
- },
-
- onMouseOut: function(e){
-
-
-
-
- e.rowIndex == -1 ? this.onHeaderCellMouseOut(e) : this.onCellMouseOut(e);
- },
-
- onMouseDown: function(e){
-
-
-
-
- e.rowIndex == -1 ? this.onHeaderCellMouseDown(e) : this.onCellMouseDown(e);
- },
-
- onMouseOverRow: function(e){
-
-
-
-
- if(!this.rows.isOver(e.rowIndex)){
- this.rows.setOverRow(e.rowIndex);
- e.rowIndex == -1 ? this.onHeaderMouseOver(e) : this.onRowMouseOver(e);
- }
- },
- onMouseOutRow: function(e){
-
-
-
-
- if(this.rows.isOver(-1)){
- this.onHeaderMouseOut(e);
- }else if(!this.rows.isOver(-2)){
- this.rows.setOverRow(-2);
- this.onRowMouseOut(e);
- }
- },
-
- onMouseDownRow: function(e){
-
-
-
-
- if(e.rowIndex != -1)
- this.onRowMouseDown(e);
- },
-
- onCellMouseOver: function(e){
-
-
-
-
- if(e.cellNode){
- dojo.addClass(e.cellNode, this.cellOverClass);
- }
- },
-
- onCellMouseOut: function(e){
-
-
-
-
- if(e.cellNode){
- dojo.removeClass(e.cellNode, this.cellOverClass);
- }
- },
-
- onCellMouseDown: function(e){
-
-
-
-
- },
- onCellClick: function(e){
-
-
-
-
- this._click[0] = this._click[1];
- this._click[1] = e;
- if(!this.edit.isEditCell(e.rowIndex, e.cellIndex)){
- this.focus.setFocusCell(e.cell, e.rowIndex);
- }
-
- if(this._click.length > 1 && this._click[0] == null){
- this._click.shift();
- }
- this.onRowClick(e);
- },
- onCellDblClick: function(e){
-
-
-
-
- var event;
- if(this._click.length > 1 && dojo.isIE){
- event = this._click[1];
- }else if(this._click.length > 1 && this._click[0].rowIndex != this._click[1].rowIndex){
- event = this._click[0];
- }else{
- event = e;
- }
- this.focus.setFocusCell(event.cell, event.rowIndex);
- this.edit.setEditCell(event.cell, event.rowIndex);
- this.onRowDblClick(e);
- },
- onCellContextMenu: function(e){
-
-
-
-
- this.onRowContextMenu(e);
- },
- onCellFocus: function(inCell, inRowIndex){
-
-
-
-
-
-
- this.edit.cellFocus(inCell, inRowIndex);
- },
-
- onRowClick: function(e){
-
-
-
-
- this.edit.rowClick(e);
- this.selection.clickSelectEvent(e);
- },
- onRowDblClick: function(e){
-
-
-
-
- },
- onRowMouseOver: function(e){
-
-
-
-
- },
- onRowMouseOut: function(e){
-
-
-
-
- },
-
- onRowMouseDown: function(e){
-
-
-
-
- },
- onRowContextMenu: function(e){
-
-
-
-
- dojo.stopEvent(e);
- },
-
- onHeaderMouseOver: function(e){
-
-
-
-
- },
- onHeaderMouseOut: function(e){
-
-
-
-
- },
- onHeaderCellMouseOver: function(e){
-
-
-
-
- if(e.cellNode){
- dojo.addClass(e.cellNode, this.cellOverClass);
- }
- },
- onHeaderCellMouseOut: function(e){
-
-
-
-
- if(e.cellNode){
- dojo.removeClass(e.cellNode, this.cellOverClass);
- }
- },
-
- onHeaderCellMouseDown: function(e) {
-
-
-
-
- },
- onHeaderClick: function(e){
-
-
-
-
- },
- onHeaderCellClick: function(e){
-
-
-
-
- this.setSortIndex(e.cell.index);
- this.onHeaderClick(e);
- },
- onHeaderDblClick: function(e){
-
-
-
-
- },
- onHeaderCellDblClick: function(e){
-
-
-
-
- this.onHeaderDblClick(e);
- },
- onHeaderCellContextMenu: function(e){
-
-
-
-
- this.onHeaderContextMenu(e);
- },
- onHeaderContextMenu: function(e){
-
-
-
-
- if(!this.headerMenu){
- dojo.stopEvent(e);
- }
- },
-
- onStartEdit: function(inCell, inRowIndex){
-
-
-
-
-
-
- },
- onApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){
-
-
-
-
-
-
-
-
- },
- onCancelEdit: function(inRowIndex){
-
-
-
-
- },
- onApplyEdit: function(inRowIndex){
-
-
-
-
- },
- onCanSelect: function(inRowIndex){
-
-
-
-
-
-
- return true;
- },
- onCanDeselect: function(inRowIndex){
-
-
-
-
-
-
- return true;
- },
- onSelected: function(inRowIndex){
-
-
-
-
- this.updateRowStyles(inRowIndex);
- },
- onDeselected: function(inRowIndex){
-
-
-
-
- this.updateRowStyles(inRowIndex);
- },
- onSelectionChanged: function(){
- }
- });
- }
|