root / trunk / web / dojo / dojox / grid / _View.js
History | View | Annotate | Download (18.4 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._View"]){ |
||
9 | dojo._hasResource["dojox.grid._View"]=true; |
||
10 | dojo.provide("dojox.grid._View");
|
||
11 | dojo.require("dijit._Widget");
|
||
12 | dojo.require("dijit._Templated");
|
||
13 | dojo.require("dojox.grid._Builder");
|
||
14 | dojo.require("dojox.html.metrics");
|
||
15 | dojo.require("dojox.grid.util");
|
||
16 | dojo.require("dojo.dnd.Source");
|
||
17 | dojo.require("dojo.dnd.Manager");
|
||
18 | (function(){
|
||
19 | var _1=function(_2,_3){ |
||
20 | return _2.style.cssText==undefined?_2.getAttribute("style"):_2.style.cssText; |
||
21 | }; |
||
22 | dojo.declare("dojox.grid._View",[dijit._Widget,dijit._Templated],{defaultWidth:"18em",viewWidth:"",templateString:"<div class=\"dojoxGridView\" wairole=\"presentation\">\n\t<div class=\"dojoxGridHeader\" dojoAttachPoint=\"headerNode\" wairole=\"presentation\">\n\t\t<div dojoAttachPoint=\"headerNodeContainer\" style=\"width:9000em\" wairole=\"presentation\">\n\t\t\t<div dojoAttachPoint=\"headerContentNode\" wairole=\"row\"></div>\n\t\t</div>\n\t</div>\n\t<input type=\"checkbox\" class=\"dojoxGridHiddenFocus\" dojoAttachPoint=\"hiddenFocusNode\" wairole=\"presentation\" />\n\t<input type=\"checkbox\" class=\"dojoxGridHiddenFocus\" wairole=\"presentation\" />\n\t<div class=\"dojoxGridScrollbox\" dojoAttachPoint=\"scrollboxNode\" wairole=\"presentation\">\n\t\t<div class=\"dojoxGridContent\" dojoAttachPoint=\"contentNode\" hidefocus=\"hidefocus\" wairole=\"presentation\"></div>\n\t</div>\n</div>\n",themeable:false,classTag:"dojoxGrid",marginBottom:0,rowPad:2,_togglingColumn:-1,_headerBuilderClass:dojox.grid._HeaderBuilder,_contentBuilderClass:dojox.grid._ContentBuilder,postMixInProperties:function(){ |
||
23 | this.rowNodes={};
|
||
24 | },postCreate:function(){ |
||
25 | this.connect(this.scrollboxNode,"onscroll","doscroll"); |
||
26 | dojox.grid.util.funnelEvents(this.contentNode,this,"doContentEvent",["mouseover","mouseout","click","dblclick","contextmenu","mousedown"]); |
||
27 | dojox.grid.util.funnelEvents(this.headerNode,this,"doHeaderEvent",["dblclick","mouseover","mouseout","mousemove","mousedown","click","contextmenu"]); |
||
28 | this.content=new this._contentBuilderClass(this); |
||
29 | this.header=new this._headerBuilderClass(this); |
||
30 | if(!dojo._isBodyLtr()){
|
||
31 | this.headerNodeContainer.style.width=""; |
||
32 | } |
||
33 | },destroy:function(){ |
||
34 | dojo.destroy(this.headerNode);
|
||
35 | delete this.headerNode; |
||
36 | for(var i in this.rowNodes){ |
||
37 | dojo.destroy(this.rowNodes[i]);
|
||
38 | } |
||
39 | this.rowNodes={};
|
||
40 | if(this.source){ |
||
41 | this.source.destroy();
|
||
42 | } |
||
43 | this.inherited(arguments); |
||
44 | },focus:function(){ |
||
45 | if(dojo.isIE||dojo.isWebKit||dojo.isOpera){
|
||
46 | this.hiddenFocusNode.focus();
|
||
47 | }else{
|
||
48 | this.scrollboxNode.focus();
|
||
49 | } |
||
50 | },setStructure:function(_4){ |
||
51 | var vs=(this.structure=_4); |
||
52 | if(vs.width&&!isNaN(vs.width)){
|
||
53 | this.viewWidth=vs.width+"em"; |
||
54 | }else{
|
||
55 | this.viewWidth=vs.width||(vs.noscroll?"auto":this.viewWidth); |
||
56 | } |
||
57 | this._onBeforeRow=vs.onBeforeRow||function(){ |
||
58 | }; |
||
59 | this._onAfterRow=vs.onAfterRow||function(){ |
||
60 | }; |
||
61 | this.noscroll=vs.noscroll;
|
||
62 | if(this.noscroll){ |
||
63 | this.scrollboxNode.style.overflow="hidden"; |
||
64 | } |
||
65 | this.simpleStructure=Boolean(vs.cells.length==1); |
||
66 | this.testFlexCells();
|
||
67 | this.updateStructure();
|
||
68 | },_cleanupRowWidgets:function(_5){ |
||
69 | if(_5){
|
||
70 | dojo.forEach(dojo.query("[widgetId]",_5).map(dijit.byNode),function(w){ |
||
71 | if(w._destroyOnRemove){
|
||
72 | w.destroy(); |
||
73 | delete w;
|
||
74 | }else{
|
||
75 | if(w.domNode&&w.domNode.parentNode){
|
||
76 | w.domNode.parentNode.removeChild(w.domNode); |
||
77 | } |
||
78 | } |
||
79 | }); |
||
80 | } |
||
81 | },onBeforeRow:function(_6,_7){ |
||
82 | this._onBeforeRow(_6,_7);
|
||
83 | if(_6>=0){ |
||
84 | this._cleanupRowWidgets(this.getRowNode(_6)); |
||
85 | } |
||
86 | },onAfterRow:function(_8,_9,_a){ |
||
87 | this._onAfterRow(_8,_9,_a);
|
||
88 | var g=this.grid; |
||
89 | dojo.forEach(dojo.query(".dojoxGridStubNode",_a),function(n){ |
||
90 | if(n&&n.parentNode){
|
||
91 | var lw=n.getAttribute("linkWidget"); |
||
92 | var _b=window.parseInt(dojo.attr(n,"cellIdx"),10); |
||
93 | var _c=g.getCell(_b);
|
||
94 | var w=dijit.byId(lw);
|
||
95 | if(w){
|
||
96 | n.parentNode.replaceChild(w.domNode,n); |
||
97 | if(!w._started){
|
||
98 | w.startup(); |
||
99 | } |
||
100 | }else{
|
||
101 | n.innerHTML="";
|
||
102 | } |
||
103 | } |
||
104 | },this);
|
||
105 | },testFlexCells:function(){ |
||
106 | this.flexCells=false; |
||
107 | for(var j=0,_d;(_d=this.structure.cells[j]);j++){ |
||
108 | for(var i=0,_e;(_e=_d[i]);i++){ |
||
109 | _e.view=this;
|
||
110 | this.flexCells=this.flexCells||_e.isFlex(); |
||
111 | } |
||
112 | } |
||
113 | return this.flexCells; |
||
114 | },updateStructure:function(){ |
||
115 | this.header.update();
|
||
116 | this.content.update();
|
||
117 | },getScrollbarWidth:function(){ |
||
118 | var _f=this.hasVScrollbar(); |
||
119 | var _10=dojo.style(this.scrollboxNode,"overflow"); |
||
120 | if(this.noscroll||!_10||_10=="hidden"){ |
||
121 | _f=false;
|
||
122 | }else{
|
||
123 | if(_10=="scroll"){ |
||
124 | _f=true;
|
||
125 | } |
||
126 | } |
||
127 | return (_f?dojox.html.metrics.getScrollbar().w:0); |
||
128 | },getColumnsWidth:function(){ |
||
129 | var h=this.headerContentNode; |
||
130 | return h&&h.firstChild?h.firstChild.offsetWidth:0; |
||
131 | },setColumnsWidth:function(_11){ |
||
132 | this.headerContentNode.firstChild.style.width=_11+"px"; |
||
133 | if(this.viewWidth){ |
||
134 | this.viewWidth=_11+"px"; |
||
135 | } |
||
136 | },getWidth:function(){ |
||
137 | return this.viewWidth||(this.getColumnsWidth()+this.getScrollbarWidth())+"px"; |
||
138 | },getContentWidth:function(){ |
||
139 | return Math.max(0,dojo._getContentBox(this.domNode).w-this.getScrollbarWidth())+"px"; |
||
140 | },render:function(){ |
||
141 | this.scrollboxNode.style.height=""; |
||
142 | this.renderHeader();
|
||
143 | if(this._togglingColumn>=0){ |
||
144 | this.setColumnsWidth(this.getColumnsWidth()-this._togglingColumn); |
||
145 | this._togglingColumn=-1; |
||
146 | } |
||
147 | var _12=this.grid.layout.cells; |
||
148 | var _13=dojo.hitch(this,function(_14,_15){ |
||
149 | !dojo._isBodyLtr()&&(_15=!_15); |
||
150 | var inc=_15?-1:1; |
||
151 | var idx=this.header.getCellNodeIndex(_14)+inc; |
||
152 | var _16=_12[idx];
|
||
153 | while(_16&&_16.getHeaderNode()&&_16.getHeaderNode().style.display=="none"){ |
||
154 | idx+=inc; |
||
155 | _16=_12[idx]; |
||
156 | } |
||
157 | if(_16){
|
||
158 | return _16.getHeaderNode();
|
||
159 | } |
||
160 | return null; |
||
161 | }); |
||
162 | if(this.grid.columnReordering&&this.simpleStructure){ |
||
163 | if(this.source){ |
||
164 | this.source.destroy();
|
||
165 | } |
||
166 | var _17="dojoxGrid_bottomMarker"; |
||
167 | var _18="dojoxGrid_topMarker"; |
||
168 | if(this.bottomMarker){ |
||
169 | dojo.destroy(this.bottomMarker);
|
||
170 | } |
||
171 | this.bottomMarker=dojo.byId(_17);
|
||
172 | if(this.topMarker){ |
||
173 | dojo.destroy(this.topMarker);
|
||
174 | } |
||
175 | this.topMarker=dojo.byId(_18);
|
||
176 | if(!this.bottomMarker){ |
||
177 | this.bottomMarker=dojo.create("div",{"id":_17,"class":"dojoxGridColPlaceBottom"},dojo.body()); |
||
178 | this._hide(this.bottomMarker); |
||
179 | this.topMarker=dojo.create("div",{"id":_18,"class":"dojoxGridColPlaceTop"},dojo.body()); |
||
180 | this._hide(this.topMarker); |
||
181 | } |
||
182 | this.arrowDim=dojo.contentBox(this.bottomMarker); |
||
183 | var _19=dojo.contentBox(this.headerContentNode.firstChild.rows[0]).h; |
||
184 | this.source=new dojo.dnd.Source(this.headerContentNode.firstChild.rows[0],{horizontal:true,accept:["gridColumn_"+this.grid.id],viewIndex:this.index,generateText:false,onMouseDown:dojo.hitch(this,function(e){ |
||
185 | this.header.decorateEvent(e);
|
||
186 | if((this.header.overRightResizeArea(e)||this.header.overLeftResizeArea(e))&&this.header.canResize(e)&&!this.header.moveable){ |
||
187 | this.header.beginColumnResize(e);
|
||
188 | }else{
|
||
189 | if(this.grid.headerMenu){ |
||
190 | this.grid.headerMenu.onCancel(true); |
||
191 | } |
||
192 | if(e.button===(dojo.isIE?1:0)){ |
||
193 | dojo.dnd.Source.prototype.onMouseDown.call(this.source,e);
|
||
194 | } |
||
195 | } |
||
196 | }),onMouseOver:dojo.hitch(this,function(e){ |
||
197 | var src=this.source; |
||
198 | if(src._getChildByEvent(e)){
|
||
199 | dojo.dnd.Source.prototype.onMouseOver.apply(src,arguments);
|
||
200 | } |
||
201 | }),_markTargetAnchor:dojo.hitch(this,function(_1a){ |
||
202 | var src=this.source; |
||
203 | if(src.current==src.targetAnchor&&src.before==_1a){
|
||
204 | return;
|
||
205 | } |
||
206 | if(src.targetAnchor&&_13(src.targetAnchor,src.before)){
|
||
207 | src._removeItemClass(_13(src.targetAnchor,src.before),src.before?"After":"Before"); |
||
208 | } |
||
209 | dojo.dnd.Source.prototype._markTargetAnchor.call(src,_1a); |
||
210 | var _1b=_1a?src.targetAnchor:_13(src.targetAnchor,src.before);
|
||
211 | var _1c=0; |
||
212 | if(!_1b){
|
||
213 | _1b=src.targetAnchor; |
||
214 | _1c=dojo.contentBox(_1b).w+this.arrowDim.w/2+2; |
||
215 | } |
||
216 | var pos=(dojo.position||dojo._abs)(_1b,true); |
||
217 | var _1d=Math.floor(pos.x-this.arrowDim.w/2+_1c); |
||
218 | dojo.style(this.bottomMarker,"visibility","visible"); |
||
219 | dojo.style(this.topMarker,"visibility","visible"); |
||
220 | dojo.style(this.bottomMarker,{"left":_1d+"px","top":(_19+pos.y)+"px"}); |
||
221 | dojo.style(this.topMarker,{"left":_1d+"px","top":(pos.y-this.arrowDim.h)+"px"}); |
||
222 | if(src.targetAnchor&&_13(src.targetAnchor,src.before)){
|
||
223 | src._addItemClass(_13(src.targetAnchor,src.before),src.before?"After":"Before"); |
||
224 | } |
||
225 | }),_unmarkTargetAnchor:dojo.hitch(this,function(){ |
||
226 | var src=this.source; |
||
227 | if(!src.targetAnchor){
|
||
228 | return;
|
||
229 | } |
||
230 | if(src.targetAnchor&&_13(src.targetAnchor,src.before)){
|
||
231 | src._removeItemClass(_13(src.targetAnchor,src.before),src.before?"After":"Before"); |
||
232 | } |
||
233 | this._hide(this.bottomMarker); |
||
234 | this._hide(this.topMarker); |
||
235 | dojo.dnd.Source.prototype._unmarkTargetAnchor.call(src); |
||
236 | }),destroy:dojo.hitch(this,function(){ |
||
237 | dojo.disconnect(this._source_conn);
|
||
238 | dojo.unsubscribe(this._source_sub);
|
||
239 | dojo.dnd.Source.prototype.destroy.call(this.source);
|
||
240 | if(this.bottomMarker){ |
||
241 | dojo.destroy(this.bottomMarker);
|
||
242 | delete this.bottomMarker; |
||
243 | } |
||
244 | if(this.topMarker){ |
||
245 | dojo.destroy(this.topMarker);
|
||
246 | delete this.topMarker; |
||
247 | } |
||
248 | }),onDndCancel:dojo.hitch(this,function(){ |
||
249 | dojo.dnd.Source.prototype.onDndCancel.call(this.source);
|
||
250 | this._hide(this.bottomMarker); |
||
251 | this._hide(this.topMarker); |
||
252 | })}); |
||
253 | this._source_conn=dojo.connect(this.source,"onDndDrop",this,"_onDndDrop"); |
||
254 | this._source_sub=dojo.subscribe("/dnd/drop/before",this,"_onDndDropBefore"); |
||
255 | this.source.startup();
|
||
256 | } |
||
257 | },_hide:function(_1e){ |
||
258 | dojo.style(_1e,{left:"-10000px",top:"-10000px","visibility":"hidden"}); |
||
259 | },_onDndDropBefore:function(_1f,_20,_21){ |
||
260 | if(dojo.dnd.manager().target!==this.source){ |
||
261 | return;
|
||
262 | } |
||
263 | this.source._targetNode=this.source.targetAnchor; |
||
264 | this.source._beforeTarget=this.source.before; |
||
265 | var _22=this.grid.views.views; |
||
266 | var _23=_22[_1f.viewIndex];
|
||
267 | var _24=_22[this.index]; |
||
268 | if(_24!=_23){
|
||
269 | _23.convertColPctToFixed(); |
||
270 | _24.convertColPctToFixed(); |
||
271 | } |
||
272 | },_onDndDrop:function(_25,_26,_27){ |
||
273 | if(dojo.dnd.manager().target!==this.source){ |
||
274 | if(dojo.dnd.manager().source===this.source){ |
||
275 | this._removingColumn=true; |
||
276 | } |
||
277 | return;
|
||
278 | } |
||
279 | this._hide(this.bottomMarker); |
||
280 | this._hide(this.topMarker); |
||
281 | var _28=function(n){ |
||
282 | return n?dojo.attr(n,"idx"):null; |
||
283 | }; |
||
284 | var w=dojo.marginBox(_26[0]).w; |
||
285 | if(_25.viewIndex!==this.index){ |
||
286 | var _29=this.grid.views.views; |
||
287 | var _2a=_29[_25.viewIndex];
|
||
288 | var _2b=_29[this.index]; |
||
289 | if(_2a.viewWidth&&_2a.viewWidth!="auto"){ |
||
290 | _2a.setColumnsWidth(_2a.getColumnsWidth()-w); |
||
291 | } |
||
292 | if(_2b.viewWidth&&_2b.viewWidth!="auto"){ |
||
293 | _2b.setColumnsWidth(_2b.getColumnsWidth()); |
||
294 | } |
||
295 | } |
||
296 | var stn=this.source._targetNode; |
||
297 | var stb=this.source._beforeTarget; |
||
298 | !dojo._isBodyLtr()&&(stb=!stb); |
||
299 | var _2c=this.grid.layout; |
||
300 | var idx=this.index; |
||
301 | delete this.source._targetNode; |
||
302 | delete this.source._beforeTarget; |
||
303 | _2c.moveColumn(_25.viewIndex,idx,_28(_26[0]),_28(stn),stb);
|
||
304 | },renderHeader:function(){ |
||
305 | this.headerContentNode.innerHTML=this.header.generateHtml(this._getHeaderContent); |
||
306 | if(this.flexCells){ |
||
307 | this.contentWidth=this.getContentWidth(); |
||
308 | this.headerContentNode.firstChild.style.width=this.contentWidth; |
||
309 | } |
||
310 | dojox.grid.util.fire(this,"onAfterRow",[-1,this.structure.cells,this.headerContentNode]); |
||
311 | },_getHeaderContent:function(_2d){ |
||
312 | var n=_2d.name||_2d.grid.getCellName(_2d);
|
||
313 | var ret=["<div class=\"dojoxGridSortNode"]; |
||
314 | if(_2d.index!=_2d.grid.getSortIndex()){
|
||
315 | ret.push("\">");
|
||
316 | }else{
|
||
317 | ret=ret.concat([" ",_2d.grid.sortInfo>0?"dojoxGridSortUp":"dojoxGridSortDown","\"><div class=\"dojoxGridArrowButtonChar\">",_2d.grid.sortInfo>0?"▲":"▼","</div><div class=\"dojoxGridArrowButtonNode\" role=\"presentation\"></div>","<div class=\"dojoxGridColCaption\">"]); |
||
318 | } |
||
319 | ret=ret.concat([n,"</div></div>"]);
|
||
320 | return ret.join(""); |
||
321 | },resize:function(){ |
||
322 | this.adaptHeight();
|
||
323 | this.adaptWidth();
|
||
324 | },hasHScrollbar:function(_2e){ |
||
325 | var _2f=this._hasHScroll||false; |
||
326 | if(this._hasHScroll==undefined||_2e){ |
||
327 | if(this.noscroll){ |
||
328 | this._hasHScroll=false; |
||
329 | }else{
|
||
330 | var _30=dojo.style(this.scrollboxNode,"overflow"); |
||
331 | if(_30=="hidden"){ |
||
332 | this._hasHScroll=false; |
||
333 | }else{
|
||
334 | if(_30=="scroll"){ |
||
335 | this._hasHScroll=true; |
||
336 | }else{
|
||
337 | this._hasHScroll=(this.scrollboxNode.offsetWidth-this.getScrollbarWidth()<this.contentNode.offsetWidth); |
||
338 | } |
||
339 | } |
||
340 | } |
||
341 | } |
||
342 | if(_2f!==this._hasHScroll){ |
||
343 | this.grid.update();
|
||
344 | } |
||
345 | return this._hasHScroll; |
||
346 | },hasVScrollbar:function(_31){ |
||
347 | var _32=this._hasVScroll||false; |
||
348 | if(this._hasVScroll==undefined||_31){ |
||
349 | if(this.noscroll){ |
||
350 | this._hasVScroll=false; |
||
351 | }else{
|
||
352 | var _33=dojo.style(this.scrollboxNode,"overflow"); |
||
353 | if(_33=="hidden"){ |
||
354 | this._hasVScroll=false; |
||
355 | }else{
|
||
356 | if(_33=="scroll"){ |
||
357 | this._hasVScroll=true; |
||
358 | }else{
|
||
359 | this._hasVScroll=(this.scrollboxNode.scrollHeight>this.scrollboxNode.clientHeight); |
||
360 | } |
||
361 | } |
||
362 | } |
||
363 | } |
||
364 | if(_32!==this._hasVScroll){ |
||
365 | this.grid.update();
|
||
366 | } |
||
367 | return this._hasVScroll; |
||
368 | },convertColPctToFixed:function(){ |
||
369 | var _34=false; |
||
370 | this.grid.initialWidth=""; |
||
371 | var _35=dojo.query("th",this.headerContentNode); |
||
372 | var _36=dojo.map(_35,function(c,_37){ |
||
373 | var w=c.style.width;
|
||
374 | dojo.attr(c,"vIdx",_37);
|
||
375 | if(w&&w.slice(-1)=="%"){ |
||
376 | _34=true;
|
||
377 | }else{
|
||
378 | if(w&&w.slice(-2)=="px"){ |
||
379 | return window.parseInt(w,10); |
||
380 | } |
||
381 | } |
||
382 | return dojo.contentBox(c).w;
|
||
383 | }); |
||
384 | if(_34){
|
||
385 | dojo.forEach(this.grid.layout.cells,function(_38,idx){ |
||
386 | if(_38.view==this){ |
||
387 | var _39=_38.view.getHeaderCellNode(_38.index);
|
||
388 | if(_39&&dojo.hasAttr(_39,"vIdx")){ |
||
389 | var _3a=window.parseInt(dojo.attr(_39,"vIdx")); |
||
390 | this.setColWidth(idx,_36[_3a]);
|
||
391 | dojo.removeAttr(_39,"vIdx");
|
||
392 | } |
||
393 | } |
||
394 | },this);
|
||
395 | return true; |
||
396 | } |
||
397 | return false; |
||
398 | },adaptHeight:function(_3b){ |
||
399 | if(!this.grid._autoHeight){ |
||
400 | var h=(this.domNode.style.height&&parseInt(this.domNode.style.height.replace(/px/,""),10))||this.domNode.clientHeight; |
||
401 | var _3c=this; |
||
402 | var _3d=function(){ |
||
403 | var v;
|
||
404 | for(var i in _3c.grid.views.views){ |
||
405 | v=_3c.grid.views.views[i]; |
||
406 | if(v!==_3c&&v.hasHScrollbar()){
|
||
407 | return true; |
||
408 | } |
||
409 | } |
||
410 | return false; |
||
411 | }; |
||
412 | if(_3b||(this.noscroll&&_3d())){ |
||
413 | h-=dojox.html.metrics.getScrollbar().h; |
||
414 | } |
||
415 | dojox.grid.util.setStyleHeightPx(this.scrollboxNode,h);
|
||
416 | } |
||
417 | this.hasVScrollbar(true); |
||
418 | },adaptWidth:function(){ |
||
419 | if(this.flexCells){ |
||
420 | this.contentWidth=this.getContentWidth(); |
||
421 | this.headerContentNode.firstChild.style.width=this.contentWidth; |
||
422 | } |
||
423 | var w=this.scrollboxNode.offsetWidth-this.getScrollbarWidth(); |
||
424 | if(!this._removingColumn){ |
||
425 | w=Math.max(w,this.getColumnsWidth())+"px"; |
||
426 | }else{
|
||
427 | w=Math.min(w,this.getColumnsWidth())+"px"; |
||
428 | this._removingColumn=false; |
||
429 | } |
||
430 | var cn=this.contentNode; |
||
431 | cn.style.width=w; |
||
432 | this.hasHScrollbar(true); |
||
433 | },setSize:function(w,h){ |
||
434 | var ds=this.domNode.style; |
||
435 | var hs=this.headerNode.style; |
||
436 | if(w){
|
||
437 | ds.width=w; |
||
438 | hs.width=w; |
||
439 | } |
||
440 | ds.height=(h>=0?h+"px":""); |
||
441 | },renderRow:function(_3e){ |
||
442 | var _3f=this.createRowNode(_3e); |
||
443 | this.buildRow(_3e,_3f);
|
||
444 | this.grid.edit.restore(this,_3e); |
||
445 | return _3f;
|
||
446 | },createRowNode:function(_40){ |
||
447 | var _41=document.createElement("div"); |
||
448 | _41.className=this.classTag+"Row"; |
||
449 | if(this instanceof dojox.grid._RowSelector){ |
||
450 | dojo.attr(_41,"role","presentation"); |
||
451 | }else{
|
||
452 | dojo.attr(_41,"role","row"); |
||
453 | if(this.grid.selectionMode!="none"){ |
||
454 | dojo.attr(_41,"aria-selected","false"); |
||
455 | } |
||
456 | } |
||
457 | _41[dojox.grid.util.gridViewTag]=this.id;
|
||
458 | _41[dojox.grid.util.rowIndexTag]=_40; |
||
459 | this.rowNodes[_40]=_41;
|
||
460 | return _41;
|
||
461 | },buildRow:function(_42,_43){ |
||
462 | this.buildRowContent(_42,_43);
|
||
463 | this.styleRow(_42,_43);
|
||
464 | },buildRowContent:function(_44,_45){ |
||
465 | _45.innerHTML=this.content.generateHtml(_44,_44);
|
||
466 | if(this.flexCells&&this.contentWidth){ |
||
467 | _45.firstChild.style.width=this.contentWidth;
|
||
468 | } |
||
469 | dojox.grid.util.fire(this,"onAfterRow",[_44,this.structure.cells,_45]); |
||
470 | },rowRemoved:function(_46){ |
||
471 | if(_46>=0){ |
||
472 | this._cleanupRowWidgets(this.getRowNode(_46)); |
||
473 | } |
||
474 | this.grid.edit.save(this,_46); |
||
475 | delete this.rowNodes[_46]; |
||
476 | },getRowNode:function(_47){ |
||
477 | return this.rowNodes[_47]; |
||
478 | },getCellNode:function(_48,_49){ |
||
479 | var row=this.getRowNode(_48); |
||
480 | if(row){
|
||
481 | return this.content.getCellNode(row,_49); |
||
482 | } |
||
483 | },getHeaderCellNode:function(_4a){ |
||
484 | if(this.headerContentNode){ |
||
485 | return this.header.getCellNode(this.headerContentNode,_4a); |
||
486 | } |
||
487 | },styleRow:function(_4b,_4c){ |
||
488 | _4c._style=_1(_4c); |
||
489 | this.styleRowNode(_4b,_4c);
|
||
490 | },styleRowNode:function(_4d,_4e){ |
||
491 | if(_4e){
|
||
492 | this.doStyleRowNode(_4d,_4e);
|
||
493 | } |
||
494 | },doStyleRowNode:function(_4f,_50){ |
||
495 | this.grid.styleRowNode(_4f,_50);
|
||
496 | },updateRow:function(_51){ |
||
497 | var _52=this.getRowNode(_51); |
||
498 | if(_52){
|
||
499 | _52.style.height="";
|
||
500 | this.buildRow(_51,_52);
|
||
501 | } |
||
502 | return _52;
|
||
503 | },updateRowStyles:function(_53){ |
||
504 | this.styleRowNode(_53,this.getRowNode(_53)); |
||
505 | },lastTop:0,firstScroll:0,doscroll:function(_54){ |
||
506 | var _55=dojo._isBodyLtr();
|
||
507 | if(this.firstScroll<2){ |
||
508 | if((!_55&&this.firstScroll==1)||(_55&&this.firstScroll===0)){ |
||
509 | var s=dojo.marginBox(this.headerNodeContainer); |
||
510 | if(dojo.isIE){
|
||
511 | this.headerNodeContainer.style.width=s.w+this.getScrollbarWidth()+"px"; |
||
512 | }else{
|
||
513 | if(dojo.isMoz){
|
||
514 | this.headerNodeContainer.style.width=s.w-this.getScrollbarWidth()+"px"; |
||
515 | this.scrollboxNode.scrollLeft=_55?this.scrollboxNode.clientWidth-this.scrollboxNode.scrollWidth:this.scrollboxNode.scrollWidth-this.scrollboxNode.clientWidth; |
||
516 | } |
||
517 | } |
||
518 | } |
||
519 | this.firstScroll++;
|
||
520 | } |
||
521 | this.headerNode.scrollLeft=this.scrollboxNode.scrollLeft; |
||
522 | var top=this.scrollboxNode.scrollTop; |
||
523 | if(top!==this.lastTop){ |
||
524 | this.grid.scrollTo(top);
|
||
525 | } |
||
526 | },setScrollTop:function(_56){ |
||
527 | this.lastTop=_56;
|
||
528 | this.scrollboxNode.scrollTop=_56;
|
||
529 | return this.scrollboxNode.scrollTop; |
||
530 | },doContentEvent:function(e){ |
||
531 | if(this.content.decorateEvent(e)){ |
||
532 | this.grid.onContentEvent(e);
|
||
533 | } |
||
534 | },doHeaderEvent:function(e){ |
||
535 | if(this.header.decorateEvent(e)){ |
||
536 | this.grid.onHeaderEvent(e);
|
||
537 | } |
||
538 | },dispatchContentEvent:function(e){ |
||
539 | return this.content.dispatchEvent(e); |
||
540 | },dispatchHeaderEvent:function(e){ |
||
541 | return this.header.dispatchEvent(e); |
||
542 | },setColWidth:function(_57,_58){ |
||
543 | this.grid.setCellWidth(_57,_58+"px"); |
||
544 | },update:function(){ |
||
545 | if(!this.domNode){ |
||
546 | return;
|
||
547 | } |
||
548 | this.content.update();
|
||
549 | this.grid.update();
|
||
550 | var _59=this.scrollboxNode.scrollLeft; |
||
551 | this.scrollboxNode.scrollLeft=_59;
|
||
552 | this.headerNode.scrollLeft=_59;
|
||
553 | }}); |
||
554 | dojo.declare("dojox.grid._GridAvatar",dojo.dnd.Avatar,{construct:function(){ |
||
555 | var dd=dojo.doc;
|
||
556 | var a=dd.createElement("table"); |
||
557 | a.cellPadding=a.cellSpacing="0";
|
||
558 | a.className="dojoxGridDndAvatar";
|
||
559 | a.style.position="absolute";
|
||
560 | a.style.zIndex=1999;
|
||
561 | a.style.margin="0px";
|
||
562 | var b=dd.createElement("tbody"); |
||
563 | var tr=dd.createElement("tr"); |
||
564 | var td=dd.createElement("td"); |
||
565 | var img=dd.createElement("td"); |
||
566 | tr.className="dojoxGridDndAvatarItem";
|
||
567 | img.className="dojoxGridDndAvatarItemImage";
|
||
568 | img.style.width="16px";
|
||
569 | var _5a=this.manager.source,_5b; |
||
570 | if(_5a.creator){
|
||
571 | _5b=_5a._normalizedCreator(_5a.getItem(this.manager.nodes[0].id).data,"avatar").node; |
||
572 | }else{
|
||
573 | _5b=this.manager.nodes[0].cloneNode(true); |
||
574 | var _5c,_5d;
|
||
575 | if(_5b.tagName.toLowerCase()=="tr"){ |
||
576 | _5c=dd.createElement("table");
|
||
577 | _5d=dd.createElement("tbody");
|
||
578 | _5d.appendChild(_5b); |
||
579 | _5c.appendChild(_5d); |
||
580 | _5b=_5c; |
||
581 | }else{
|
||
582 | if(_5b.tagName.toLowerCase()=="th"){ |
||
583 | _5c=dd.createElement("table");
|
||
584 | _5d=dd.createElement("tbody");
|
||
585 | var r=dd.createElement("tr"); |
||
586 | _5c.cellPadding=_5c.cellSpacing="0";
|
||
587 | r.appendChild(_5b); |
||
588 | _5d.appendChild(r); |
||
589 | _5c.appendChild(_5d); |
||
590 | _5b=_5c; |
||
591 | } |
||
592 | } |
||
593 | } |
||
594 | _5b.id="";
|
||
595 | td.appendChild(_5b); |
||
596 | tr.appendChild(img); |
||
597 | tr.appendChild(td); |
||
598 | dojo.style(tr,"opacity",0.9); |
||
599 | b.appendChild(tr); |
||
600 | a.appendChild(b); |
||
601 | this.node=a;
|
||
602 | var m=dojo.dnd.manager();
|
||
603 | this.oldOffsetY=m.OFFSET_Y;
|
||
604 | m.OFFSET_Y=1;
|
||
605 | },destroy:function(){ |
||
606 | dojo.dnd.manager().OFFSET_Y=this.oldOffsetY;
|
||
607 | this.inherited(arguments); |
||
608 | }}); |
||
609 | var _5e=dojo.dnd.manager().makeAvatar;
|
||
610 | dojo.dnd.manager().makeAvatar=function(){ |
||
611 | var src=this.source; |
||
612 | if(src.viewIndex!==undefined&&!dojo.hasClass(dojo.body(),"dijit_a11y")){ |
||
613 | return new dojox.grid._GridAvatar(this); |
||
614 | } |
||
615 | return _5e.call(dojo.dnd.manager());
|
||
616 | }; |
||
617 | })(); |
||
618 | } |