root / trunk / web / dojo / dojox / widget / RollingList.js
History | View | Annotate | Download (21.6 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.widget.RollingList"]){ |
9 |
dojo._hasResource["dojox.widget.RollingList"]=true; |
10 |
dojo.provide("dojox.widget.RollingList");
|
11 |
dojo.experimental("dojox.widget.RollingList");
|
12 |
dojo.require("dojo.window");
|
13 |
dojo.require("dijit.layout.ContentPane");
|
14 |
dojo.require("dijit._Templated");
|
15 |
dojo.require("dijit._Contained");
|
16 |
dojo.require("dijit.layout._LayoutWidget");
|
17 |
dojo.require("dijit.Menu");
|
18 |
dojo.require("dijit.form.Button");
|
19 |
dojo.require("dojox.html.metrics");
|
20 |
dojo.require("dojo.i18n");
|
21 |
dojo.requireLocalization("dijit","common",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); |
22 |
dojo.declare("dojox.widget._RollingListPane",[dijit.layout.ContentPane,dijit._Templated,dijit._Contained],{templateString:"<div class=\"dojoxRollingListPane\"><table><tbody><tr><td dojoAttachPoint=\"containerNode\"></td></tr></tbody></div>",parentWidget:null,parentPane:null,store:null,items:null,query:null,queryOptions:null,_focusByNode:true,minWidth:0,_setContentAndScroll:function(_1,_2){ |
23 |
this._setContent(_1,_2);
|
24 |
this.parentWidget.scrollIntoView(this); |
25 |
},_updateNodeWidth:function(n,_3){ |
26 |
n.style.width="";
|
27 |
var _4=dojo.marginBox(n).w;
|
28 |
if(_4<_3){
|
29 |
dojo.marginBox(n,{w:_3});
|
30 |
} |
31 |
},_onMinWidthChange:function(v){ |
32 |
this._updateNodeWidth(this.domNode,v); |
33 |
},_setMinWidthAttr:function(v){ |
34 |
if(v!==this.minWidth){ |
35 |
this.minWidth=v;
|
36 |
this._onMinWidthChange(v);
|
37 |
} |
38 |
},startup:function(){ |
39 |
if(this._started){ |
40 |
return;
|
41 |
} |
42 |
if(this.store&&this.store.getFeatures()["dojo.data.api.Notification"]){ |
43 |
window.setTimeout(dojo.hitch(this,function(){ |
44 |
this.connect(this.store,"onSet","_onSetItem"); |
45 |
this.connect(this.store,"onNew","_onNewItem"); |
46 |
this.connect(this.store,"onDelete","_onDeleteItem"); |
47 |
}),1);
|
48 |
} |
49 |
this.connect(this.focusNode||this.domNode,"onkeypress","_focusKey"); |
50 |
this.parentWidget._updateClass(this.domNode,"Pane"); |
51 |
this.inherited(arguments); |
52 |
this._onMinWidthChange(this.minWidth); |
53 |
},_focusKey:function(e){ |
54 |
if(e.charOrCode==dojo.keys.BACKSPACE){
|
55 |
dojo.stopEvent(e); |
56 |
return;
|
57 |
}else{
|
58 |
if(e.charOrCode==dojo.keys.LEFT_ARROW&&this.parentPane){ |
59 |
this.parentPane.focus();
|
60 |
this.parentWidget.scrollIntoView(this.parentPane); |
61 |
}else{
|
62 |
if(e.charOrCode==dojo.keys.ENTER){
|
63 |
this.parentWidget._onExecute();
|
64 |
} |
65 |
} |
66 |
} |
67 |
},focus:function(_5){ |
68 |
if(this.parentWidget._focusedPane!=this){ |
69 |
this.parentWidget._focusedPane=this; |
70 |
this.parentWidget.scrollIntoView(this); |
71 |
if(this._focusByNode&&(!this.parentWidget._savedFocus||_5)){ |
72 |
try{
|
73 |
(this.focusNode||this.domNode).focus(); |
74 |
} |
75 |
catch(e){
|
76 |
} |
77 |
} |
78 |
} |
79 |
},_onShow:function(){ |
80 |
if((this.store||this.items)&&((this.refreshOnShow&&this.domNode)||(!this.isLoaded&&this.domNode))){ |
81 |
this.refresh();
|
82 |
} |
83 |
},_load:function(){ |
84 |
this.isLoaded=false; |
85 |
if(this.items){ |
86 |
this._setContentAndScroll(this.onLoadStart(),true); |
87 |
window.setTimeout(dojo.hitch(this,"_doQuery"),1); |
88 |
}else{
|
89 |
this._doQuery();
|
90 |
} |
91 |
},_doLoadItems:function(_6,_7){ |
92 |
var _8=0,_9=this.store; |
93 |
dojo.forEach(_6,function(_a){
|
94 |
if(!_9.isItemLoaded(_a)){
|
95 |
_8++; |
96 |
} |
97 |
}); |
98 |
if(_8===0){ |
99 |
_7(); |
100 |
}else{
|
101 |
var _b=function(_c){ |
102 |
_8--; |
103 |
if((_8)===0){ |
104 |
_7(); |
105 |
} |
106 |
}; |
107 |
dojo.forEach(_6,function(_d){
|
108 |
if(!_9.isItemLoaded(_d)){
|
109 |
_9.loadItem({item:_d,onItem:_b}); |
110 |
} |
111 |
}); |
112 |
} |
113 |
},_doQuery:function(){ |
114 |
if(!this.domNode){ |
115 |
return;
|
116 |
} |
117 |
var _e=this.parentWidget.preloadItems; |
118 |
_e=(_e===true||(this.items&&this.items.length<=Number(_e))); |
119 |
if(this.items&&_e){ |
120 |
this._doLoadItems(this.items,dojo.hitch(this,"onItems")); |
121 |
}else{
|
122 |
if(this.items){ |
123 |
this.onItems();
|
124 |
}else{
|
125 |
this._setContentAndScroll(this.onFetchStart(),true); |
126 |
this.store.fetch({query:this.query,onComplete:function(_f){ |
127 |
this.items=_f;
|
128 |
this.onItems();
|
129 |
},onError:function(e){ |
130 |
this._onError("Fetch",e); |
131 |
},scope:this}); |
132 |
} |
133 |
} |
134 |
},_hasItem:function(_10){ |
135 |
var _11=this.items||[]; |
136 |
for(var i=0,_12;(_12=_11[i]);i++){ |
137 |
if(this.parentWidget._itemsMatch(_12,_10)){ |
138 |
return true; |
139 |
} |
140 |
} |
141 |
return false; |
142 |
},_onSetItem:function(_13,_14,_15,_16){ |
143 |
if(this._hasItem(_13)){ |
144 |
this.refresh();
|
145 |
} |
146 |
},_onNewItem:function(_17,_18){ |
147 |
var sel;
|
148 |
if((!_18&&!this.parentPane)||(_18&&this.parentPane&&this.parentPane._hasItem(_18.item)&&(sel=this.parentPane._getSelected())&&this.parentWidget._itemsMatch(sel.item,_18.item))){ |
149 |
this.items.push(_17);
|
150 |
this.refresh();
|
151 |
}else{
|
152 |
if(_18&&this.parentPane&&this._hasItem(_18.item)){ |
153 |
this.refresh();
|
154 |
} |
155 |
} |
156 |
},_onDeleteItem:function(_19){ |
157 |
if(this._hasItem(_19)){ |
158 |
this.items=dojo.filter(this.items,function(i){ |
159 |
return (i!=_19);
|
160 |
}); |
161 |
this.refresh();
|
162 |
} |
163 |
},onFetchStart:function(){ |
164 |
return this.loadingMessage; |
165 |
},onFetchError:function(_1a){ |
166 |
return this.errorMessage; |
167 |
},onLoadStart:function(){ |
168 |
return this.loadingMessage; |
169 |
},onLoadError:function(_1b){ |
170 |
return this.errorMessage; |
171 |
},onItems:function(){ |
172 |
if(!this.onLoadDeferred){ |
173 |
this.cancel();
|
174 |
this.onLoadDeferred=new dojo.Deferred(dojo.hitch(this,"cancel")); |
175 |
} |
176 |
this._onLoadHandler();
|
177 |
}}); |
178 |
dojo.declare("dojox.widget._RollingListGroupPane",[dojox.widget._RollingListPane],{templateString:"<div><div dojoAttachPoint=\"containerNode\"></div>"+"<div dojoAttachPoint=\"menuContainer\">"+"<div dojoAttachPoint=\"menuNode\"></div>"+"</div></div>",_menu:null,_setContent:function(_1c){ |
179 |
if(!this._menu){ |
180 |
this.inherited(arguments); |
181 |
} |
182 |
},_onMinWidthChange:function(v){ |
183 |
if(!this._menu){ |
184 |
return;
|
185 |
} |
186 |
var _1d=dojo.marginBox(this.domNode).w; |
187 |
var _1e=dojo.marginBox(this._menu.domNode).w; |
188 |
this._updateNodeWidth(this._menu.domNode,v-(_1d-_1e)); |
189 |
},onItems:function(){ |
190 |
var _1f,_20=false; |
191 |
if(this._menu){ |
192 |
_1f=this._getSelected();
|
193 |
this._menu.destroyRecursive();
|
194 |
} |
195 |
this._menu=this._getMenu(); |
196 |
var _21,_22;
|
197 |
if(this.items.length){ |
198 |
dojo.forEach(this.items,function(_23){ |
199 |
_21=this.parentWidget._getMenuItemForItem(_23,this); |
200 |
if(_21){
|
201 |
if(_1f&&this.parentWidget._itemsMatch(_21.item,_1f.item)){ |
202 |
_22=_21; |
203 |
} |
204 |
this._menu.addChild(_21);
|
205 |
} |
206 |
},this);
|
207 |
}else{
|
208 |
_21=this.parentWidget._getMenuItemForItem(null,this); |
209 |
if(_21){
|
210 |
this._menu.addChild(_21);
|
211 |
} |
212 |
} |
213 |
if(_22){
|
214 |
this._setSelected(_22);
|
215 |
if((_1f&&!_1f.children&&_22.children)||(_1f&&_1f.children&&!_22.children)){
|
216 |
var _24=this.parentWidget._getPaneForItem(_22.item,this,_22.children); |
217 |
if(_24){
|
218 |
this.parentWidget.addChild(_24,this.getIndexInParent()+1); |
219 |
}else{
|
220 |
this.parentWidget._removeAfter(this); |
221 |
this.parentWidget._onItemClick(null,this,_22.item,_22.children); |
222 |
} |
223 |
} |
224 |
}else{
|
225 |
if(_1f){
|
226 |
this.parentWidget._removeAfter(this); |
227 |
} |
228 |
} |
229 |
this.containerNode.innerHTML=""; |
230 |
this.containerNode.appendChild(this._menu.domNode); |
231 |
this.parentWidget.scrollIntoView(this); |
232 |
this._checkScrollConnection(true); |
233 |
this.inherited(arguments); |
234 |
this._onMinWidthChange(this.minWidth); |
235 |
},_checkScrollConnection:function(_25){ |
236 |
var _26=this.store; |
237 |
if(this._scrollConn){ |
238 |
this.disconnect(this._scrollConn); |
239 |
} |
240 |
delete this._scrollConn; |
241 |
if(!dojo.every(this.items,function(i){ |
242 |
return _26.isItemLoaded(i);
|
243 |
})){ |
244 |
if(_25){
|
245 |
this._loadVisibleItems();
|
246 |
} |
247 |
this._scrollConn=this.connect(this.domNode,"onscroll","_onScrollPane"); |
248 |
} |
249 |
},startup:function(){ |
250 |
this.inherited(arguments); |
251 |
this.parentWidget._updateClass(this.domNode,"GroupPane"); |
252 |
},focus:function(_27){ |
253 |
if(this._menu){ |
254 |
if(this._pendingFocus){ |
255 |
this.disconnect(this._pendingFocus); |
256 |
} |
257 |
delete this._pendingFocus; |
258 |
var _28=this._menu.focusedChild; |
259 |
if(!_28){
|
260 |
var _29=dojo.query(".dojoxRollingListItemSelected",this.domNode)[0]; |
261 |
if(_29){
|
262 |
_28=dijit.byNode(_29); |
263 |
} |
264 |
} |
265 |
if(!_28){
|
266 |
_28=this._menu.getChildren()[0]||this._menu; |
267 |
} |
268 |
this._focusByNode=false; |
269 |
if(_28.focusNode){
|
270 |
if(!this.parentWidget._savedFocus||_27){ |
271 |
try{
|
272 |
_28.focusNode.focus(); |
273 |
} |
274 |
catch(e){
|
275 |
} |
276 |
} |
277 |
window.setTimeout(function(){
|
278 |
try{
|
279 |
dojo.window.scrollIntoView(_28.focusNode); |
280 |
} |
281 |
catch(e){
|
282 |
} |
283 |
},1);
|
284 |
}else{
|
285 |
if(_28.focus){
|
286 |
if(!this.parentWidget._savedFocus||_27){ |
287 |
_28.focus(); |
288 |
} |
289 |
}else{
|
290 |
this._focusByNode=true; |
291 |
} |
292 |
} |
293 |
this.inherited(arguments); |
294 |
}else{
|
295 |
if(!this._pendingFocus){ |
296 |
this._pendingFocus=this.connect(this,"onItems","focus"); |
297 |
} |
298 |
} |
299 |
},_getMenu:function(){ |
300 |
var _2a=this; |
301 |
var _2b=new dijit.Menu({parentMenu:this.parentPane?this.parentPane._menu:null,onCancel:function(_2c){ |
302 |
if(_2a.parentPane){
|
303 |
_2a.parentPane.focus(true);
|
304 |
} |
305 |
},_moveToPopup:function(evt){ |
306 |
if(this.focusedChild&&!this.focusedChild.disabled){ |
307 |
this.focusedChild._onClick(evt);
|
308 |
} |
309 |
}},this.menuNode);
|
310 |
this.connect(_2b,"onItemClick",function(_2d,evt){ |
311 |
if(_2d.disabled){
|
312 |
return;
|
313 |
} |
314 |
evt.alreadySelected=dojo.hasClass(_2d.domNode,"dojoxRollingListItemSelected");
|
315 |
if(evt.alreadySelected&&((evt.type=="keypress"&&evt.charOrCode!=dojo.keys.ENTER)||(evt.type=="internal"))){ |
316 |
var p=this.parentWidget.getChildren()[this.getIndexInParent()+1]; |
317 |
if(p){
|
318 |
p.focus(true);
|
319 |
this.parentWidget.scrollIntoView(p);
|
320 |
} |
321 |
}else{
|
322 |
this._setSelected(_2d,_2b);
|
323 |
this.parentWidget._onItemClick(evt,this,_2d.item,_2d.children); |
324 |
if(evt.type=="keypress"&&evt.charOrCode==dojo.keys.ENTER){ |
325 |
this.parentWidget._onExecute();
|
326 |
} |
327 |
} |
328 |
}); |
329 |
if(!_2b._started){
|
330 |
_2b.startup(); |
331 |
} |
332 |
return _2b;
|
333 |
},_onScrollPane:function(){ |
334 |
if(this._visibleLoadPending){ |
335 |
window.clearTimeout(this._visibleLoadPending);
|
336 |
} |
337 |
this._visibleLoadPending=window.setTimeout(dojo.hitch(this,"_loadVisibleItems"),500); |
338 |
},_loadVisibleItems:function(){ |
339 |
delete this._visibleLoadPending; |
340 |
var _2e=this._menu; |
341 |
if(!_2e){
|
342 |
return;
|
343 |
} |
344 |
var _2f=_2e.getChildren();
|
345 |
if(!_2f||!_2f.length){
|
346 |
return;
|
347 |
} |
348 |
var _30=function(n,m,pb){ |
349 |
var s=dojo.getComputedStyle(n);
|
350 |
var r=0; |
351 |
if(m){
|
352 |
r+=dojo._getMarginExtents(n,s).t; |
353 |
} |
354 |
if(pb){
|
355 |
r+=dojo._getPadBorderExtents(n,s).t; |
356 |
} |
357 |
return r;
|
358 |
}; |
359 |
var _31=_30(this.domNode,false,true)+_30(this.containerNode,true,true)+_30(_2e.domNode,true,true)+_30(_2f[0].domNode,true,false); |
360 |
var h=dojo.contentBox(this.domNode).h; |
361 |
var _32=this.domNode.scrollTop-_31-(h/2); |
362 |
var _33=_32+(3*h/2); |
363 |
var _34=dojo.filter(_2f,function(c){ |
364 |
var cnt=c.domNode.offsetTop;
|
365 |
var s=c.store;
|
366 |
var i=c.item;
|
367 |
return (cnt>=_32&&cnt<=_33&&!s.isItemLoaded(i));
|
368 |
}); |
369 |
var _35=dojo.map(_34,function(c){ |
370 |
return c.item;
|
371 |
}); |
372 |
var _36=dojo.hitch(this,function(){ |
373 |
var _37=this._getSelected(); |
374 |
var _38;
|
375 |
dojo.forEach(_35,function(_39,idx){
|
376 |
var _3a=this.parentWidget._getMenuItemForItem(_39,this); |
377 |
var _3b=_34[idx];
|
378 |
var _3c=_3b.getIndexInParent();
|
379 |
_2e.removeChild(_3b); |
380 |
if(_3a){
|
381 |
if(_37&&this.parentWidget._itemsMatch(_3a.item,_37.item)){ |
382 |
_38=_3a; |
383 |
} |
384 |
_2e.addChild(_3a,_3c); |
385 |
if(_2e.focusedChild==_3b){
|
386 |
_2e.focusChild(_3a); |
387 |
} |
388 |
} |
389 |
_3b.destroy(); |
390 |
},this);
|
391 |
this._checkScrollConnection(false); |
392 |
}); |
393 |
this._doLoadItems(_35,_36);
|
394 |
},_getSelected:function(_3d){ |
395 |
if(!_3d){
|
396 |
_3d=this._menu;
|
397 |
} |
398 |
if(_3d){
|
399 |
var _3e=this._menu.getChildren(); |
400 |
for(var i=0,_3f;(_3f=_3e[i]);i++){ |
401 |
if(dojo.hasClass(_3f.domNode,"dojoxRollingListItemSelected")){ |
402 |
return _3f;
|
403 |
} |
404 |
} |
405 |
} |
406 |
return null; |
407 |
},_setSelected:function(_40,_41){ |
408 |
if(!_41){
|
409 |
_41=this._menu;
|
410 |
} |
411 |
if(_41){
|
412 |
dojo.forEach(_41.getChildren(),function(i){
|
413 |
this.parentWidget._updateClass(i.domNode,"Item",{"Selected":(_40&&(i==_40&&!i.disabled))}); |
414 |
},this);
|
415 |
} |
416 |
}}); |
417 |
dojo.declare("dojox.widget.RollingList",[dijit._Widget,dijit._Templated,dijit._Container],{templateString:dojo.cache("dojox.widget","RollingList/RollingList.html","<div class=\"dojoxRollingList ${className}\"\n\t><div class=\"dojoxRollingListContainer\" dojoAttachPoint=\"containerNode\" dojoAttachEvent=\"onkeypress:_onKey\"\n\t></div\n\t><div class=\"dojoxRollingListButtons\" dojoAttachPoint=\"buttonsNode\"\n ><button dojoType=\"dijit.form.Button\" dojoAttachPoint=\"okButton\"\n\t\t\t\tdojoAttachEvent=\"onClick:_onExecute\">${okButtonLabel}</button\n ><button dojoType=\"dijit.form.Button\" dojoAttachPoint=\"cancelButton\"\n\t\t\t\tdojoAttachEvent=\"onClick:_onCancel\">${cancelButtonLabel}</button\n\t></div\n></div>\n"),widgetsInTemplate:true,className:"",store:null,query:null,queryOptions:null,childrenAttrs:["children"],parentAttr:"",value:null,executeOnDblClick:true,preloadItems:false,showButtons:false,okButtonLabel:"",cancelButtonLabel:"",minPaneWidth:0,postMixInProperties:function(){ |
418 |
this.inherited(arguments); |
419 |
var loc=dojo.i18n.getLocalization("dijit","common"); |
420 |
this.okButtonLabel=this.okButtonLabel||loc.buttonOk; |
421 |
this.cancelButtonLabel=this.cancelButtonLabel||loc.buttonCancel; |
422 |
},_setShowButtonsAttr:function(_42){ |
423 |
var _43=false; |
424 |
if((this.showButtons!=_42&&this._started)||(this.showButtons==_42&&!this.started)){ |
425 |
_43=true;
|
426 |
} |
427 |
dojo.toggleClass(this.domNode,"dojoxRollingListButtonsHidden",!_42); |
428 |
this.showButtons=_42;
|
429 |
if(_43){
|
430 |
if(this._started){ |
431 |
this.layout();
|
432 |
}else{
|
433 |
window.setTimeout(dojo.hitch(this,"layout"),0); |
434 |
} |
435 |
} |
436 |
},_itemsMatch:function(_44,_45){ |
437 |
if(!_44&&!_45){
|
438 |
return true; |
439 |
}else{
|
440 |
if(!_44||!_45){
|
441 |
return false; |
442 |
} |
443 |
} |
444 |
return (_44==_45||(this._isIdentity&&this.store.getIdentity(_44)==this.store.getIdentity(_45))); |
445 |
},_removeAfter:function(idx){ |
446 |
if(typeof idx!="number"){ |
447 |
idx=this.getIndexOfChild(idx);
|
448 |
} |
449 |
if(idx>=0){ |
450 |
dojo.forEach(this.getChildren(),function(c,i){ |
451 |
if(i>idx){
|
452 |
this.removeChild(c);
|
453 |
c.destroyRecursive(); |
454 |
} |
455 |
},this);
|
456 |
} |
457 |
var _46=this.getChildren(),_47=_46[_46.length-1]; |
458 |
var _48=null; |
459 |
while(_47&&!_48){
|
460 |
var val=_47._getSelected?_47._getSelected():null; |
461 |
if(val){
|
462 |
_48=val.item; |
463 |
} |
464 |
_47=_47.parentPane; |
465 |
} |
466 |
if(!this._setInProgress){ |
467 |
this._setValue(_48);
|
468 |
} |
469 |
},addChild:function(_49,_4a){ |
470 |
if(_4a>0){ |
471 |
this._removeAfter(_4a-1); |
472 |
} |
473 |
this.inherited(arguments); |
474 |
if(!_49._started){
|
475 |
_49.startup(); |
476 |
} |
477 |
_49.attr("minWidth",this.minPaneWidth); |
478 |
this.layout();
|
479 |
if(!this._savedFocus){ |
480 |
_49.focus(); |
481 |
} |
482 |
},_setMinPaneWidthAttr:function(_4b){ |
483 |
if(_4b!==this.minPaneWidth){ |
484 |
this.minPaneWidth=_4b;
|
485 |
dojo.forEach(this.getChildren(),function(c){ |
486 |
c.attr("minWidth",_4b);
|
487 |
}); |
488 |
} |
489 |
},_updateClass:function(_4c,_4d,_4e){ |
490 |
if(!this._declaredClasses){ |
491 |
this._declaredClasses=("dojoxRollingList "+this.className).split(" "); |
492 |
} |
493 |
dojo.forEach(this._declaredClasses,function(c){ |
494 |
if(c){
|
495 |
dojo.addClass(_4c,c+_4d); |
496 |
for(var k in _4e||{}){ |
497 |
dojo.toggleClass(_4c,c+_4d+k,_4e[k]); |
498 |
} |
499 |
dojo.toggleClass(_4c,c+_4d+"FocusSelected",(dojo.hasClass(_4c,c+_4d+"Focus")&&dojo.hasClass(_4c,c+_4d+"Selected"))); |
500 |
dojo.toggleClass(_4c,c+_4d+"HoverSelected",(dojo.hasClass(_4c,c+_4d+"Hover")&&dojo.hasClass(_4c,c+_4d+"Selected"))); |
501 |
} |
502 |
}); |
503 |
},scrollIntoView:function(_4f){ |
504 |
if(this._scrollingTimeout){ |
505 |
window.clearTimeout(this._scrollingTimeout);
|
506 |
} |
507 |
delete this._scrollingTimeout; |
508 |
this._scrollingTimeout=window.setTimeout(dojo.hitch(this,function(){ |
509 |
if(_4f.domNode){
|
510 |
dojo.window.scrollIntoView(_4f.domNode); |
511 |
} |
512 |
delete this._scrollingTimeout; |
513 |
return;
|
514 |
}),1);
|
515 |
},resize:function(_50){ |
516 |
dijit.layout._LayoutWidget.prototype.resize.call(this,_50);
|
517 |
},layout:function(){ |
518 |
var _51=this.getChildren(); |
519 |
if(this._contentBox){ |
520 |
var bn=this.buttonsNode; |
521 |
var _52=this._contentBox.h-dojo.marginBox(bn).h-dojox.html.metrics.getScrollbar().h; |
522 |
dojo.forEach(_51,function(c){
|
523 |
dojo.marginBox(c.domNode,{h:_52});
|
524 |
}); |
525 |
} |
526 |
if(this._focusedPane){ |
527 |
var foc=this._focusedPane; |
528 |
delete this._focusedPane; |
529 |
if(!this._savedFocus){ |
530 |
foc.focus(); |
531 |
} |
532 |
}else{
|
533 |
if(_51&&_51.length){
|
534 |
if(!this._savedFocus){ |
535 |
_51[0].focus();
|
536 |
} |
537 |
} |
538 |
} |
539 |
},_onChange:function(_53){ |
540 |
this.onChange(_53);
|
541 |
},_setValue:function(_54){ |
542 |
delete this._setInProgress; |
543 |
if(!this._itemsMatch(this.value,_54)){ |
544 |
this.value=_54;
|
545 |
this._onChange(_54);
|
546 |
} |
547 |
},_setValueAttr:function(_55){ |
548 |
if(this._itemsMatch(this.value,_55)&&!_55){ |
549 |
return;
|
550 |
} |
551 |
if(this._setInProgress&&this._setInProgress===_55){ |
552 |
return;
|
553 |
} |
554 |
this._setInProgress=_55;
|
555 |
if(!_55||!this.store.isItem(_55)){ |
556 |
var _56=this.getChildren()[0]; |
557 |
_56._setSelected(null);
|
558 |
this._onItemClick(null,_56,null,null); |
559 |
return;
|
560 |
} |
561 |
var _57=dojo.hitch(this,function(_58,_59){ |
562 |
var _5a=this.store,id; |
563 |
if(this.parentAttr&&_5a.getFeatures()["dojo.data.api.Identity"]&&((id=this.store.getValue(_58,this.parentAttr))||id==="")){ |
564 |
var cb=function(i){ |
565 |
if(_5a.getIdentity(i)==_5a.getIdentity(_58)){
|
566 |
_59(null);
|
567 |
}else{
|
568 |
_59([i]); |
569 |
} |
570 |
}; |
571 |
if(id===""){ |
572 |
_59(null);
|
573 |
}else{
|
574 |
if(typeof id=="string"){ |
575 |
_5a.fetchItemByIdentity({identity:id,onItem:cb}); |
576 |
}else{
|
577 |
if(_5a.isItem(id)){
|
578 |
cb(id); |
579 |
} |
580 |
} |
581 |
} |
582 |
}else{
|
583 |
var _5b=this.childrenAttrs.length; |
584 |
var _5c=[];
|
585 |
dojo.forEach(this.childrenAttrs,function(_5d){ |
586 |
var q={};
|
587 |
q[_5d]=_58; |
588 |
_5a.fetch({query:q,scope:this,onComplete:function(_5e){ |
589 |
if(this._setInProgress!==_55){ |
590 |
return;
|
591 |
} |
592 |
_5c=_5c.concat(_5e); |
593 |
_5b--; |
594 |
if(_5b===0){ |
595 |
_59(_5c); |
596 |
} |
597 |
}}); |
598 |
},this);
|
599 |
} |
600 |
}); |
601 |
var _5f=dojo.hitch(this,function(_60,idx){ |
602 |
var set=_60[idx];
|
603 |
var _61=this.getChildren()[idx]; |
604 |
var _62;
|
605 |
if(set&&_61){
|
606 |
var fx=dojo.hitch(this,function(){ |
607 |
if(_62){
|
608 |
this.disconnect(_62);
|
609 |
} |
610 |
delete _62;
|
611 |
if(this._setInProgress!==_55){ |
612 |
return;
|
613 |
} |
614 |
var _63=dojo.filter(_61._menu.getChildren(),function(i){ |
615 |
return this._itemsMatch(i.item,set); |
616 |
},this)[0]; |
617 |
if(_63){
|
618 |
idx++; |
619 |
_61._menu.onItemClick(_63,{type:"internal",stopPropagation:function(){ |
620 |
},preventDefault:function(){ |
621 |
}}); |
622 |
if(_60[idx]){
|
623 |
_5f(_60,idx); |
624 |
}else{
|
625 |
this._setValue(set);
|
626 |
this.onItemClick(set,_61,this.getChildItems(set)); |
627 |
} |
628 |
} |
629 |
}); |
630 |
if(!_61.isLoaded){
|
631 |
_62=this.connect(_61,"onLoad",fx); |
632 |
}else{
|
633 |
fx(); |
634 |
} |
635 |
}else{
|
636 |
if(idx===0){ |
637 |
this.set("value",null); |
638 |
} |
639 |
} |
640 |
}); |
641 |
var _64=[];
|
642 |
var _65=dojo.hitch(this,function(_66){ |
643 |
if(_66&&_66.length){
|
644 |
_64.push(_66[0]);
|
645 |
_57(_66[0],_65);
|
646 |
}else{
|
647 |
if(!_66){
|
648 |
_64.pop(); |
649 |
} |
650 |
_64.reverse(); |
651 |
_5f(_64,0);
|
652 |
} |
653 |
}); |
654 |
var ns=this.domNode.style; |
655 |
if(ns.display=="none"||ns.visibility=="hidden"){ |
656 |
this._setValue(_55);
|
657 |
}else{
|
658 |
if(!this._itemsMatch(_55,this._visibleItem)){ |
659 |
_65([_55]); |
660 |
} |
661 |
} |
662 |
},_onItemClick:function(evt,_67,_68,_69){ |
663 |
if(evt){
|
664 |
var _6a=this._getPaneForItem(_68,_67,_69); |
665 |
var _6b=(evt.type=="click"&&evt.alreadySelected); |
666 |
if(_6b&&_6a){
|
667 |
this._removeAfter(_67.getIndexInParent()+1); |
668 |
var _6c=_67.getNextSibling();
|
669 |
if(_6c&&_6c._setSelected){
|
670 |
_6c._setSelected(null);
|
671 |
} |
672 |
this.scrollIntoView(_6c);
|
673 |
}else{
|
674 |
if(_6a){
|
675 |
this.addChild(_6a,_67.getIndexInParent()+1); |
676 |
if(this._savedFocus){ |
677 |
_6a.focus(true);
|
678 |
} |
679 |
}else{
|
680 |
this._removeAfter(_67);
|
681 |
this.scrollIntoView(_67);
|
682 |
} |
683 |
} |
684 |
}else{
|
685 |
if(_67){
|
686 |
this._removeAfter(_67);
|
687 |
this.scrollIntoView(_67);
|
688 |
} |
689 |
} |
690 |
if(!evt||evt.type!="internal"){ |
691 |
this._setValue(_68);
|
692 |
this.onItemClick(_68,_67,_69);
|
693 |
} |
694 |
this._visibleItem=_68;
|
695 |
},_getPaneForItem:function(_6d,_6e,_6f){ |
696 |
var ret=this.getPaneForItem(_6d,_6e,_6f); |
697 |
ret.store=this.store;
|
698 |
ret.parentWidget=this;
|
699 |
ret.parentPane=_6e||null;
|
700 |
if(!_6d){
|
701 |
ret.query=this.query;
|
702 |
ret.queryOptions=this.queryOptions;
|
703 |
}else{
|
704 |
if(_6f){
|
705 |
ret.items=_6f; |
706 |
}else{
|
707 |
ret.items=[_6d]; |
708 |
} |
709 |
} |
710 |
return ret;
|
711 |
},_getMenuItemForItem:function(_70,_71){ |
712 |
var _72=this.store; |
713 |
if(!_70||!_72||!_72.isItem(_70)){
|
714 |
var i=new dijit.MenuItem({label:"---",disabled:true,iconClass:"dojoxEmpty",focus:function(){ |
715 |
}}); |
716 |
this._updateClass(i.domNode,"Item"); |
717 |
return i;
|
718 |
}else{
|
719 |
var _73=_72.isItemLoaded(_70);
|
720 |
var _74=_73?this.getChildItems(_70):undefined; |
721 |
var _75;
|
722 |
if(_74){
|
723 |
_75=this.getMenuItemForItem(_70,_71,_74);
|
724 |
_75.children=_74; |
725 |
this._updateClass(_75.domNode,"Item",{"Expanding":true}); |
726 |
if(!_75._started){
|
727 |
var c=_75.connect(_75,"startup",function(){ |
728 |
this.disconnect(c);
|
729 |
dojo.style(this.arrowWrapper,"display",""); |
730 |
}); |
731 |
}else{
|
732 |
dojo.style(_75.arrowWrapper,"display",""); |
733 |
} |
734 |
}else{
|
735 |
_75=this.getMenuItemForItem(_70,_71,null); |
736 |
if(_73){
|
737 |
this._updateClass(_75.domNode,"Item",{"Single":true}); |
738 |
}else{
|
739 |
this._updateClass(_75.domNode,"Item",{"Unloaded":true}); |
740 |
_75.attr("disabled",true); |
741 |
} |
742 |
} |
743 |
_75.store=this.store;
|
744 |
_75.item=_70; |
745 |
if(!_75.label){
|
746 |
_75.attr("label",this.store.getLabel(_70).replace(/</,"<")); |
747 |
} |
748 |
if(_75.focusNode){
|
749 |
var _76=this; |
750 |
_75.focus=function(){ |
751 |
if(!this.disabled){ |
752 |
try{
|
753 |
this.focusNode.focus();
|
754 |
} |
755 |
catch(e){
|
756 |
} |
757 |
} |
758 |
}; |
759 |
_75.connect(_75.focusNode,"onmouseenter",function(){ |
760 |
if(!this.disabled){ |
761 |
_76._updateClass(this.domNode,"Item",{"Hover":true}); |
762 |
} |
763 |
}); |
764 |
_75.connect(_75.focusNode,"onmouseleave",function(){ |
765 |
if(!this.disabled){ |
766 |
_76._updateClass(this.domNode,"Item",{"Hover":false}); |
767 |
} |
768 |
}); |
769 |
_75.connect(_75.focusNode,"blur",function(){ |
770 |
_76._updateClass(this.domNode,"Item",{"Focus":false,"Hover":false}); |
771 |
}); |
772 |
_75.connect(_75.focusNode,"focus",function(){ |
773 |
_76._updateClass(this.domNode,"Item",{"Focus":true}); |
774 |
_76._focusedPane=_71; |
775 |
}); |
776 |
if(this.executeOnDblClick){ |
777 |
_75.connect(_75.focusNode,"ondblclick",function(){ |
778 |
_76._onExecute(); |
779 |
}); |
780 |
} |
781 |
} |
782 |
return _75;
|
783 |
} |
784 |
},_setStore:function(_77){ |
785 |
if(_77===this.store&&this._started){ |
786 |
return;
|
787 |
} |
788 |
this.store=_77;
|
789 |
this._isIdentity=_77.getFeatures()["dojo.data.api.Identity"]; |
790 |
var _78=this._getPaneForItem(); |
791 |
this.addChild(_78,0); |
792 |
},_onKey:function(e){ |
793 |
if(e.charOrCode==dojo.keys.BACKSPACE){
|
794 |
dojo.stopEvent(e); |
795 |
return;
|
796 |
}else{
|
797 |
if(e.charOrCode==dojo.keys.ESCAPE&&this._savedFocus){ |
798 |
try{
|
799 |
dijit.focus(this._savedFocus);
|
800 |
} |
801 |
catch(e){
|
802 |
} |
803 |
dojo.stopEvent(e); |
804 |
return;
|
805 |
}else{
|
806 |
if(e.charOrCode==dojo.keys.LEFT_ARROW||e.charOrCode==dojo.keys.RIGHT_ARROW){
|
807 |
dojo.stopEvent(e); |
808 |
return;
|
809 |
} |
810 |
} |
811 |
} |
812 |
},_resetValue:function(){ |
813 |
this.set("value",this._lastExecutedValue); |
814 |
},_onCancel:function(){ |
815 |
this._resetValue();
|
816 |
this.onCancel();
|
817 |
},_onExecute:function(){ |
818 |
this._lastExecutedValue=this.get("value"); |
819 |
this.onExecute();
|
820 |
},focus:function(){ |
821 |
var _79=this._savedFocus; |
822 |
this._savedFocus=dijit.getFocus(this); |
823 |
if(!this._savedFocus.node){ |
824 |
delete this._savedFocus; |
825 |
} |
826 |
if(!this._focusedPane){ |
827 |
var _7a=this.getChildren()[0]; |
828 |
if(_7a&&!_79){
|
829 |
_7a.focus(true);
|
830 |
} |
831 |
}else{
|
832 |
this._savedFocus=dijit.getFocus(this); |
833 |
var foc=this._focusedPane; |
834 |
delete this._focusedPane; |
835 |
if(!_79){
|
836 |
foc.focus(true);
|
837 |
} |
838 |
} |
839 |
},handleKey:function(e){ |
840 |
if(e.charOrCode==dojo.keys.DOWN_ARROW){
|
841 |
delete this._savedFocus; |
842 |
this.focus();
|
843 |
return false; |
844 |
}else{
|
845 |
if(e.charOrCode==dojo.keys.ESCAPE){
|
846 |
this._onCancel();
|
847 |
return false; |
848 |
} |
849 |
} |
850 |
return true; |
851 |
},_updateChildClasses:function(){ |
852 |
var _7b=this.getChildren(); |
853 |
var _7c=_7b.length;
|
854 |
dojo.forEach(_7b,function(c,idx){
|
855 |
dojo.toggleClass(c.domNode,"dojoxRollingListPaneCurrentChild",(idx==(_7c-1))); |
856 |
dojo.toggleClass(c.domNode,"dojoxRollingListPaneCurrentSelected",(idx==(_7c-2))); |
857 |
}); |
858 |
},startup:function(){ |
859 |
if(this._started){ |
860 |
return;
|
861 |
} |
862 |
if(!this.getParent||!this.getParent()){ |
863 |
this.resize();
|
864 |
this.connect(dojo.global,"onresize","resize"); |
865 |
} |
866 |
this.connect(this,"addChild","_updateChildClasses"); |
867 |
this.connect(this,"removeChild","_updateChildClasses"); |
868 |
this._setStore(this.store); |
869 |
this.set("showButtons",this.showButtons); |
870 |
this.inherited(arguments); |
871 |
this._lastExecutedValue=this.get("value"); |
872 |
},getChildItems:function(_7d){ |
873 |
var _7e,_7f=this.store; |
874 |
dojo.forEach(this.childrenAttrs,function(_80){ |
875 |
var _81=_7f.getValues(_7d,_80);
|
876 |
if(_81&&_81.length){
|
877 |
_7e=(_7e||[]).concat(_81); |
878 |
} |
879 |
}); |
880 |
return _7e;
|
881 |
},getMenuItemForItem:function(_82,_83,_84){ |
882 |
return new dijit.MenuItem({}); |
883 |
},getPaneForItem:function(_85,_86,_87){ |
884 |
if(!_85||_87){
|
885 |
return new dojox.widget._RollingListGroupPane({}); |
886 |
}else{
|
887 |
return null; |
888 |
} |
889 |
},onItemClick:function(_88,_89,_8a){ |
890 |
},onExecute:function(){ |
891 |
},onCancel:function(){ |
892 |
},onChange:function(_8b){ |
893 |
}}); |
894 |
} |