root / trunk / web / dojo / dojox / grid / enhanced / plugins / Menu.js
History | View | Annotate | Download (2.45 KB)
| 1 | /*
 | 
|---|---|
| 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.enhanced.plugins.Menu"]){ | 
| 9 | dojo._hasResource["dojox.grid.enhanced.plugins.Menu"]=true; | 
| 10 | dojo.provide("dojox.grid.enhanced.plugins.Menu");
 | 
| 11 | dojo.declare("dojox.grid.enhanced.plugins.Menu",null,{constructor:function(_1){ | 
| 12 | _1.mixin(_1,this);
 | 
| 13 | },_initMenus:function(){ | 
| 14 | var _2=this.menuContainer; | 
| 15 | !this.headerMenu&&(this.headerMenu=this._getMenuWidget(this.menus["headerMenu"])); | 
| 16 | !this.rowMenu&&(this.rowMenu=this._getMenuWidget(this.menus["rowMenu"])); | 
| 17 | !this.cellMenu&&(this.cellMenu=this._getMenuWidget(this.menus["cellMenu"])); | 
| 18 | !this.selectedRegionMenu&&(this.selectedRegionMenu=this._getMenuWidget(this.menus["selectedRegionMenu"])); | 
| 19 | this.headerMenu&&this.set("headerMenu",this.headerMenu)&&this.setupHeaderMenu(); | 
| 20 | this.rowMenu&&this.set("rowMenu",this.rowMenu); | 
| 21 | this.cellMenu&&this.set("cellMenu",this.cellMenu); | 
| 22 | this.isDndSelectEnable&&this.selectedRegionMenu&&dojo.connect(this.select,"setDrugCoverDivs",dojo.hitch(this,this._bindDnDSelectEvent)); | 
| 23 | },_getMenuWidget:function(_3){ | 
| 24 | if(!_3){
 | 
| 25 | return;
 | 
| 26 | } | 
| 27 | var _4=dijit.byId(_3);
 | 
| 28 | if(!_4){
 | 
| 29 | throw new Error("Menu '"+_3+"' not existed"); | 
| 30 | } | 
| 31 | return _4;
 | 
| 32 | },_bindDnDSelectEvent:function(){ | 
| 33 | dojo.forEach(this.select.coverDIVs,dojo.hitch(this,function(_5){ | 
| 34 | this.selectedRegionMenu.bindDomNode(_5);
 | 
| 35 | dojo.connect(_5,"contextmenu",dojo.hitch(this,function(e){ | 
| 36 | dojo.mixin(e,this.select.getSelectedRegionInfo());
 | 
| 37 | this.onSelectedRegionContextMenu(e);
 | 
| 38 | })); | 
| 39 | })); | 
| 40 | },_setRowMenuAttr:function(_6){ | 
| 41 | this._setRowCellMenuAttr(_6,"rowMenu"); | 
| 42 | },_setCellMenuAttr:function(_7){ | 
| 43 | this._setRowCellMenuAttr(_7,"cellMenu"); | 
| 44 | },_setRowCellMenuAttr:function(_8,_9){ | 
| 45 | if(!_8){
 | 
| 46 | return;
 | 
| 47 | } | 
| 48 | if(this[_9]){ | 
| 49 | this[_9].unBindDomNode(this.domNode); | 
| 50 | } | 
| 51 | this[_9]=_8;
 | 
| 52 | this[_9].bindDomNode(this.domNode); | 
| 53 | },showRowCellMenu:function(e){ | 
| 54 | var _a=e.sourceView.declaredClass=="dojox.grid._RowSelector"; | 
| 55 | if(this.rowMenu&&(!e.cell||this.selection.isSelected(e.rowIndex))){ | 
| 56 | this.rowMenu._openMyself({target:e.target,coords:"pageX" in e?{x:e.pageX,y:e.pageY}:null}); | 
| 57 | dojo.stopEvent(e); | 
| 58 | return;
 | 
| 59 | } | 
| 60 | if(_a||e.cell&&e.cell.isRowSelector){
 | 
| 61 | dojo.stopEvent(e); | 
| 62 | return;
 | 
| 63 | } | 
| 64 | if(this.isDndSelectEnable){ | 
| 65 | this.select.cellClick(e.cellIndex,e.rowIndex);
 | 
| 66 | this.focus.setFocusCell(e.cell,e.rowIndex);
 | 
| 67 | } | 
| 68 | if(this.cellMenu){ | 
| 69 | this.cellMenu._openMyself({target:e.target,coords:"pageX" in e?{x:e.pageX,y:e.pageY}:null}); | 
| 70 | } | 
| 71 | }}); | 
| 72 | } |