root / trunk / web / dojo / dojox / grid / enhanced / _Plugin.js
History | View | Annotate | Download (6.28 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._Plugin"]){ |
9 |
dojo._hasResource["dojox.grid.enhanced._Plugin"]=true; |
10 |
dojo.provide("dojox.grid.enhanced._Plugin");
|
11 |
dojo.require("dojox.grid.enhanced._Builder");
|
12 |
dojo.require("dojox.grid.enhanced._Events");
|
13 |
dojo.declare("dojox.grid.enhanced._Plugin",null,{fixedCellNum:-1,funcMap:{},constructor:function(_1){ |
14 |
this.grid=_1;
|
15 |
this._parseProps(this.grid); |
16 |
},_parseProps:function(_2){ |
17 |
_2.plugins&&dojo.mixin(_2,_2.plugins); |
18 |
_2.rowSelectCell=null;
|
19 |
_2.dnd&&(_2.nestedSorting=true);
|
20 |
(_2.dnd||_2.indirectSelection)&&(_2.columnReordering=false);
|
21 |
},preInit:function(){ |
22 |
var _3=this.grid; |
23 |
_3.indirectSelection&&(new (this.getPluginClazz("dojox.grid.enhanced.plugins.IndirectSelection"))(_3)); |
24 |
if(_3.dnd&&(!_3.rowSelector||_3.rowSelector=="false")){ |
25 |
_3.rowSelector="20px";
|
26 |
} |
27 |
if(_3.nestedSorting){
|
28 |
dojox.grid._View.prototype._headerBuilderClass=dojox.grid.enhanced._HeaderBuilder; |
29 |
} |
30 |
dojox.grid._View.prototype._contentBuilderClass=dojox.grid.enhanced._ContentBuilder; |
31 |
},postInit:function(){ |
32 |
var _4=this.grid; |
33 |
new dojox.grid.enhanced._Events(_4);
|
34 |
_4.menus&&(new (this.getPluginClazz("dojox.grid.enhanced.plugins.Menu"))(_4)); |
35 |
_4.nestedSorting&&(new (this.getPluginClazz("dojox.grid.enhanced.plugins.NestedSorting"))(_4)); |
36 |
if(_4.dnd){
|
37 |
_4.isDndSelectEnable=_4.dnd; |
38 |
_4.dndDisabledTypes=["cell"];
|
39 |
new (this.getPluginClazz("dojox.grid.enhanced.plugins.DnD"))(_4); |
40 |
} |
41 |
dojo.isChrome<3&&(_4.constructor.prototype.startup=_4.startup);
|
42 |
this.fixedCellNum=this.getFixedCellNumber(); |
43 |
this.grid.plugins&&this._bindFuncs(); |
44 |
},getPluginClazz:function(_5){ |
45 |
var _6=dojo.getObject(_5);
|
46 |
if(_6){
|
47 |
return _6;
|
48 |
} |
49 |
throw new Error("Please make sure class \""+_5+"\" is required."); |
50 |
},isFixedCell:function(_7){ |
51 |
return _7&&(_7.isRowSelector||_7.positionFixed);
|
52 |
},getFixedCellNumber:function(){ |
53 |
if(this.fixedCellNum>=0){ |
54 |
return this.fixedCellNum; |
55 |
} |
56 |
var i=0; |
57 |
dojo.forEach(this.grid.layout.cells,dojo.hitch(this,function(_8){ |
58 |
this.isFixedCell(_8)&&(i++);
|
59 |
})); |
60 |
return i;
|
61 |
},inSingleSelection:function(){ |
62 |
return this.grid.selectionMode&&this.grid.selectionMode=="single"; |
63 |
},needUpdateRow:function(){ |
64 |
return ((this.grid.indirectSelection||this.grid.isDndSelectEnable)?this.grid.edit.isEditing():true); |
65 |
},_bindFuncs:function(){ |
66 |
dojo.forEach(this.grid.views.views,dojo.hitch(this,function(_9){ |
67 |
dojox.grid.util.funnelEvents(_9.contentNode,_9,"doContentEvent",["mouseup","mousemove"]); |
68 |
dojox.grid.util.funnelEvents(_9.headerNode,_9,"doHeaderEvent",["mouseup"]); |
69 |
this.funcMap[_9.id+"-"+"setColumnsWidth"]=_9.setColumnsWidth; |
70 |
_9.setColumnsWidth=this.setColumnsWidth;
|
71 |
this.grid.nestedSorting&&(_9._getHeaderContent=this.grid._getNestedSortHeaderContent); |
72 |
this.grid.dnd&&(_9.setScrollTop=this.setScrollTop); |
73 |
})); |
74 |
this.funcMap["nextKey"]=this.grid.focus.nextKey; |
75 |
this.grid.focus.nextKey=this.nextKey; |
76 |
this.funcMap["previousKey"]=this.grid.focus.previousKey; |
77 |
this.grid.focus.previousKey=this.previousKey; |
78 |
if(this.grid.indirectSelection){ |
79 |
this.funcMap["renderPage"]=this.grid.scroller.renderPage; |
80 |
this.grid.scroller.renderPage=this.renderPage; |
81 |
this.funcMap["measurePage"]=this.grid.scroller.measurePage; |
82 |
this.grid.scroller.measurePage=this.measurePage; |
83 |
} |
84 |
this.funcMap["updateRow"]=this.grid.updateRow; |
85 |
this.grid.updateRow=this.updateRow; |
86 |
if(this.grid.nestedSorting&&dojox.grid.cells._Widget){ |
87 |
dojox.grid.cells._Widget.prototype.sizeWidget=this.sizeWidget;
|
88 |
} |
89 |
dojox.grid.cells._Base.prototype.getEditNode=this.getEditNode;
|
90 |
dojox.grid._EditManager.prototype.styleRow=function(_a){ |
91 |
}; |
92 |
},setColumnsWidth:function(_b){ |
93 |
if(dojo.isIE&&!dojo._isBodyLtr()){
|
94 |
this.headerContentNode.style.width=_b+"px"; |
95 |
this.headerContentNode.parentNode.style.width=_b+"px"; |
96 |
} |
97 |
dojo.hitch(this,this.grid.pluginMgr.funcMap[this.id+"-"+"setColumnsWidth"])(_b); |
98 |
},previousKey:function(e){ |
99 |
var _c=this.grid.edit.isEditing(); |
100 |
if(!_c&&!this.isNavHeader()&&!this._isHeaderHidden()){ |
101 |
if(!this.grid.isDndSelectEnable){ |
102 |
this.focusHeader();
|
103 |
}else{
|
104 |
if(!this.isRowBar()){ |
105 |
this.focusRowBar();
|
106 |
}else{
|
107 |
this._blurRowBar();
|
108 |
this.focusHeader();
|
109 |
} |
110 |
} |
111 |
dojo.stopEvent(e); |
112 |
return;
|
113 |
} |
114 |
dojo.hitch(this,this.grid.pluginMgr.funcMap["previousKey"])(e); |
115 |
},nextKey:function(e){ |
116 |
var _d=this.grid.rowCount==0; |
117 |
var _e=(e.target===this.grid.domNode); |
118 |
if(!_e&&this.grid.isDndSelectEnable&&this.isNavHeader()){ |
119 |
this._colHeadNode=this._colHeadFocusIdx=null; |
120 |
this.focusRowBar();
|
121 |
return;
|
122 |
}else{
|
123 |
if(!_e&&(!this.grid.isDndSelectEnable&&this.isNavHeader())||(this.grid.isDndSelectEnable&&this.isRowBar())){ |
124 |
this._colHeadNode=this._colHeadFocusIdx=null; |
125 |
if(this.grid.isDndSelectEnable){ |
126 |
this._blurRowBar();
|
127 |
} |
128 |
if(this.isNoFocusCell()&&!_d){ |
129 |
this.setFocusIndex(0,0); |
130 |
}else{
|
131 |
if(this.cell&&!_d){ |
132 |
if(this.focusView&&!this.focusView.rowNodes[this.rowIndex]){ |
133 |
this.grid.scrollToRow(this.rowIndex); |
134 |
} |
135 |
this.focusGrid();
|
136 |
}else{
|
137 |
if(!this.findAndFocusGridCell()){ |
138 |
this.tabOut(this.grid.lastFocusNode); |
139 |
} |
140 |
} |
141 |
} |
142 |
return;
|
143 |
} |
144 |
} |
145 |
dojo.hitch(this,this.grid.pluginMgr.funcMap["nextKey"])(e); |
146 |
},renderPage:function(_f){ |
147 |
for(var i=0,j=_f*this.rowsPerPage;(i<this.rowsPerPage)&&(j<this.rowCount);i++,j++){ |
148 |
} |
149 |
this.grid.lastRenderingRowIdx=--j;
|
150 |
dojo.addClass(this.grid.domNode,"dojoxGridSortInProgress"); |
151 |
dojo.hitch(this,this.grid.pluginMgr.funcMap["renderPage"])(_f); |
152 |
},measurePage:function(_10){ |
153 |
var _11=dojo.hitch(this,this.grid.pluginMgr.funcMap["measurePage"])(_10); |
154 |
return (!dojo.isIE||this.grid.rowHeight||_11>this.rowsPerPage*this.grid.minRowHeight)?_11:undefined; |
155 |
},updateRow:function(_12){ |
156 |
var _13=arguments.callee.caller; |
157 |
if(_13.nom=="move"&&!this.pluginMgr.needUpdateRow()){ |
158 |
return;
|
159 |
} |
160 |
dojo.hitch(this,this.pluginMgr.funcMap["updateRow"])(_12); |
161 |
},getEditNode:function(_14){ |
162 |
return ((this.getNode(_14)||0).firstChild||0).firstChild||0; |
163 |
},sizeWidget:function(_15,_16,_17){ |
164 |
var p=this.getNode(_17).firstChild,box=dojo.contentBox(p); |
165 |
dojo.marginBox(this.widget.domNode,{w:box.w}); |
166 |
},setScrollTop:function(_18){ |
167 |
this.lastTop=_18;
|
168 |
this.scrollboxNode.scrollTop=_18;
|
169 |
return this.scrollboxNode.scrollTop; |
170 |
},getViewByCellIdx:function(_19){ |
171 |
var _1a=function(_1b){ |
172 |
var j=0,_1c=false; |
173 |
for(;j<_1b.length;j++){
|
174 |
if(dojo.isArray(_1b[j])){
|
175 |
if(_1a(_1b[j])){
|
176 |
return true; |
177 |
} |
178 |
}else{
|
179 |
if(_1b[j].index==_19){
|
180 |
return true; |
181 |
} |
182 |
} |
183 |
} |
184 |
}; |
185 |
var i=0,_1d=this.grid.views.views; |
186 |
for(;i<_1d.length;i++){
|
187 |
cells=_1d[i].structure.cells; |
188 |
if(_1a(cells)){
|
189 |
return _1d[i];
|
190 |
} |
191 |
} |
192 |
return null; |
193 |
}}); |
194 |
} |