root / trunk / web / dojo / dijit / form / ComboBox.js @ 12
History | View | Annotate | Download (19 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["dijit.form.ComboBox"]){ |
||
| 9 | dojo._hasResource["dijit.form.ComboBox"]=true; |
||
| 10 | dojo.provide("dijit.form.ComboBox");
|
||
| 11 | dojo.require("dojo.window");
|
||
| 12 | dojo.require("dojo.regexp");
|
||
| 13 | dojo.require("dojo.data.util.simpleFetch");
|
||
| 14 | dojo.require("dojo.data.util.filter");
|
||
| 15 | dojo.require("dijit._CssStateMixin");
|
||
| 16 | dojo.require("dijit.form._FormWidget");
|
||
| 17 | dojo.require("dijit.form.ValidationTextBox");
|
||
| 18 | dojo.requireLocalization("dijit.form","ComboBox",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"); |
||
| 19 | dojo.declare("dijit.form.ComboBoxMixin",null,{item:null,pageSize:Infinity,store:null,fetchProperties:{},query:{},autoComplete:true,highlightMatch:"first",searchDelay:100,searchAttr:"name",labelAttr:"",labelType:"text",queryExpr:"${0}*",ignoreCase:true,hasDownArrow:true,templateString:dojo.cache("dijit.form","templates/ComboBox.html","<div class=\"dijit dijitReset dijitInlineTable dijitLeft\"\n\tid=\"widget_${id}\"\n\tdojoAttachPoint=\"comboNode\" waiRole=\"combobox\"\n\t><div class='dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer'\n\t\tdojoAttachPoint=\"downArrowNode\" waiRole=\"presentation\"\n\t\tdojoAttachEvent=\"onmousedown:_onArrowMouseDown\"\n\t\t><input class=\"dijitReset dijitInputField dijitArrowButtonInner\" value=\"▼ \" type=\"text\" tabIndex=\"-1\" readOnly waiRole=\"presentation\"\n\t\t\t${_buttonInputDisabled}\n\t/></div\n\t><div class='dijitReset dijitValidationContainer'\n\t\t><input class=\"dijitReset dijitInputField dijitValidationIcon dijitValidationInner\" value=\"Χ \" type=\"text\" tabIndex=\"-1\" readOnly waiRole=\"presentation\"\n\t/></div\n\t><div class=\"dijitReset dijitInputField dijitInputContainer\"\n\t\t><input class='dijitReset dijitInputInner' ${!nameAttrSetting} type=\"text\" autocomplete=\"off\"\n\t\t\tdojoAttachEvent=\"onkeypress:_onKeyPress,compositionend\"\n\t\t\tdojoAttachPoint=\"textbox,focusNode\" waiRole=\"textbox\" waiState=\"haspopup-true,autocomplete-list\"\n\t/></div\n></div>\n"),baseClass:"dijitTextBox dijitComboBox",cssStateNodes:{"downArrowNode":"dijitDownArrowButton"},_getCaretPos:function(_1){ |
||
| 20 | var _2=0; |
||
| 21 | if(typeof (_1.selectionStart)=="number"){ |
||
| 22 | _2=_1.selectionStart; |
||
| 23 | }else{
|
||
| 24 | if(dojo.isIE){
|
||
| 25 | var tr=dojo.doc.selection.createRange().duplicate();
|
||
| 26 | var _3=_1.createTextRange();
|
||
| 27 | tr.move("character",0); |
||
| 28 | _3.move("character",0); |
||
| 29 | try{
|
||
| 30 | _3.setEndPoint("EndToEnd",tr);
|
||
| 31 | _2=String(_3.text).replace(/\r/g,"").length; |
||
| 32 | } |
||
| 33 | catch(e){
|
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | return _2;
|
||
| 38 | },_setCaretPos:function(_4,_5){ |
||
| 39 | _5=parseInt(_5); |
||
| 40 | dijit.selectInputText(_4,_5,_5); |
||
| 41 | },_setDisabledAttr:function(_6){ |
||
| 42 | this.inherited(arguments); |
||
| 43 | dijit.setWaiState(this.comboNode,"disabled",_6); |
||
| 44 | },_abortQuery:function(){ |
||
| 45 | if(this.searchTimer){ |
||
| 46 | clearTimeout(this.searchTimer);
|
||
| 47 | this.searchTimer=null; |
||
| 48 | } |
||
| 49 | if(this._fetchHandle){ |
||
| 50 | if(this._fetchHandle.abort){ |
||
| 51 | this._fetchHandle.abort();
|
||
| 52 | } |
||
| 53 | this._fetchHandle=null; |
||
| 54 | } |
||
| 55 | },_onInput:function(_7){ |
||
| 56 | if(!this.searchTimer&&(_7.type=="paste"||_7.type=="input")&&this._lastInput!=this.textbox.value){ |
||
| 57 | this.searchTimer=setTimeout(dojo.hitch(this,function(){ |
||
| 58 | this._onKeyPress({charOrCode:229}); |
||
| 59 | }),100);
|
||
| 60 | } |
||
| 61 | this.inherited(arguments); |
||
| 62 | },_onKeyPress:function(_8){ |
||
| 63 | var _9=_8.charOrCode;
|
||
| 64 | if(_8.altKey||((_8.ctrlKey||_8.metaKey)&&(_9!="x"&&_9!="v"))||_9==dojo.keys.SHIFT){ |
||
| 65 | return;
|
||
| 66 | } |
||
| 67 | var _a=false; |
||
| 68 | var _b="_startSearchFromInput"; |
||
| 69 | var pw=this._popupWidget; |
||
| 70 | var dk=dojo.keys;
|
||
| 71 | var _c=null; |
||
| 72 | this._prev_key_backspace=false; |
||
| 73 | this._abortQuery();
|
||
| 74 | if(this._isShowingNow){ |
||
| 75 | pw.handleKey(_9); |
||
| 76 | _c=pw.getHighlightedOption(); |
||
| 77 | } |
||
| 78 | switch(_9){
|
||
| 79 | case dk.PAGE_DOWN:
|
||
| 80 | case dk.DOWN_ARROW:
|
||
| 81 | case dk.PAGE_UP:
|
||
| 82 | case dk.UP_ARROW:
|
||
| 83 | if(!this._isShowingNow){ |
||
| 84 | _a=true;
|
||
| 85 | _b="_startSearchAll";
|
||
| 86 | }else{
|
||
| 87 | this._announceOption(_c);
|
||
| 88 | } |
||
| 89 | dojo.stopEvent(_8); |
||
| 90 | break;
|
||
| 91 | case dk.ENTER:
|
||
| 92 | if(_c){
|
||
| 93 | if(_c==pw.nextButton){
|
||
| 94 | this._nextSearch(1); |
||
| 95 | dojo.stopEvent(_8); |
||
| 96 | break;
|
||
| 97 | }else{
|
||
| 98 | if(_c==pw.previousButton){
|
||
| 99 | this._nextSearch(-1); |
||
| 100 | dojo.stopEvent(_8); |
||
| 101 | break;
|
||
| 102 | } |
||
| 103 | } |
||
| 104 | }else{
|
||
| 105 | this._setBlurValue();
|
||
| 106 | this._setCaretPos(this.focusNode,this.focusNode.value.length); |
||
| 107 | } |
||
| 108 | _8.preventDefault(); |
||
| 109 | case dk.TAB:
|
||
| 110 | var _d=this.get("displayedValue"); |
||
| 111 | if(pw&&(_d==pw._messages["previousMessage"]||_d==pw._messages["nextMessage"])){ |
||
| 112 | break;
|
||
| 113 | } |
||
| 114 | if(_c){
|
||
| 115 | this._selectOption();
|
||
| 116 | } |
||
| 117 | if(this._isShowingNow){ |
||
| 118 | this._lastQuery=null; |
||
| 119 | this._hideResultList();
|
||
| 120 | } |
||
| 121 | break;
|
||
| 122 | case " ": |
||
| 123 | if(_c){
|
||
| 124 | dojo.stopEvent(_8); |
||
| 125 | this._selectOption();
|
||
| 126 | this._hideResultList();
|
||
| 127 | }else{
|
||
| 128 | _a=true;
|
||
| 129 | } |
||
| 130 | break;
|
||
| 131 | case dk.ESCAPE:
|
||
| 132 | if(this._isShowingNow){ |
||
| 133 | dojo.stopEvent(_8); |
||
| 134 | this._hideResultList();
|
||
| 135 | } |
||
| 136 | break;
|
||
| 137 | case dk.DELETE:
|
||
| 138 | case dk.BACKSPACE:
|
||
| 139 | this._prev_key_backspace=true; |
||
| 140 | _a=true;
|
||
| 141 | break;
|
||
| 142 | default:
|
||
| 143 | _a=typeof _9=="string"||_9==229; |
||
| 144 | } |
||
| 145 | if(_a){
|
||
| 146 | this.item=undefined; |
||
| 147 | this.searchTimer=setTimeout(dojo.hitch(this,_b),1); |
||
| 148 | } |
||
| 149 | },_autoCompleteText:function(_e){ |
||
| 150 | var fn=this.focusNode; |
||
| 151 | dijit.selectInputText(fn,fn.value.length); |
||
| 152 | var _f=this.ignoreCase?"toLowerCase":"substr"; |
||
| 153 | if(_e[_f](0).indexOf(this.focusNode.value[_f](0))==0){ |
||
| 154 | var _10=this._getCaretPos(fn); |
||
| 155 | if((_10+1)>fn.value.length){ |
||
| 156 | fn.value=_e; |
||
| 157 | dijit.selectInputText(fn,_10); |
||
| 158 | } |
||
| 159 | }else{
|
||
| 160 | fn.value=_e; |
||
| 161 | dijit.selectInputText(fn); |
||
| 162 | } |
||
| 163 | },_openResultList:function(_11,_12){ |
||
| 164 | this._fetchHandle=null; |
||
| 165 | if(this.disabled||this.readOnly||(_12.query[this.searchAttr]!=this._lastQuery)){ |
||
| 166 | return;
|
||
| 167 | } |
||
| 168 | this._popupWidget.clearResultList();
|
||
| 169 | if(!_11.length&&!this._maxOptions){ |
||
| 170 | this._hideResultList();
|
||
| 171 | return;
|
||
| 172 | } |
||
| 173 | _12._maxOptions=this._maxOptions;
|
||
| 174 | var _13=this._popupWidget.createOptions(_11,_12,dojo.hitch(this,"_getMenuLabelFromItem")); |
||
| 175 | this._showResultList();
|
||
| 176 | if(_12.direction){
|
||
| 177 | if(1==_12.direction){ |
||
| 178 | this._popupWidget.highlightFirstOption();
|
||
| 179 | }else{
|
||
| 180 | if(-1==_12.direction){ |
||
| 181 | this._popupWidget.highlightLastOption();
|
||
| 182 | } |
||
| 183 | } |
||
| 184 | this._announceOption(this._popupWidget.getHighlightedOption()); |
||
| 185 | }else{
|
||
| 186 | if(this.autoComplete&&!this._prev_key_backspace&&!/^[*]+$/.test(_12.query[this.searchAttr])){ |
||
| 187 | this._announceOption(_13[1]); |
||
| 188 | } |
||
| 189 | } |
||
| 190 | },_showResultList:function(){ |
||
| 191 | this._hideResultList();
|
||
| 192 | this.displayMessage(""); |
||
| 193 | dojo.style(this._popupWidget.domNode,{width:"",height:""}); |
||
| 194 | var _14=this.open(); |
||
| 195 | var _15=dojo.marginBox(this._popupWidget.domNode); |
||
| 196 | this._popupWidget.domNode.style.overflow=((_14.h==_15.h)&&(_14.w==_15.w))?"hidden":"auto"; |
||
| 197 | var _16=_14.w;
|
||
| 198 | if(_14.h<this._popupWidget.domNode.scrollHeight){ |
||
| 199 | _16+=16;
|
||
| 200 | } |
||
| 201 | dojo.marginBox(this._popupWidget.domNode,{h:_14.h,w:Math.max(_16,this.domNode.offsetWidth)}); |
||
| 202 | if(_16<this.domNode.offsetWidth){ |
||
| 203 | this._popupWidget.domNode.parentNode.style.left=dojo.position(this.domNode,true).x+"px"; |
||
| 204 | } |
||
| 205 | dijit.setWaiState(this.comboNode,"expanded","true"); |
||
| 206 | },_hideResultList:function(){ |
||
| 207 | this._abortQuery();
|
||
| 208 | if(this._isShowingNow){ |
||
| 209 | dijit.popup.close(this._popupWidget);
|
||
| 210 | this._isShowingNow=false; |
||
| 211 | dijit.setWaiState(this.comboNode,"expanded","false"); |
||
| 212 | dijit.removeWaiState(this.focusNode,"activedescendant"); |
||
| 213 | } |
||
| 214 | },_setBlurValue:function(){ |
||
| 215 | var _17=this.get("displayedValue"); |
||
| 216 | var pw=this._popupWidget; |
||
| 217 | if(pw&&(_17==pw._messages["previousMessage"]||_17==pw._messages["nextMessage"])){ |
||
| 218 | this._setValueAttr(this._lastValueReported,true); |
||
| 219 | }else{
|
||
| 220 | if(typeof this.item=="undefined"){ |
||
| 221 | this.item=null; |
||
| 222 | this.set("displayedValue",_17); |
||
| 223 | }else{
|
||
| 224 | if(this.value!=this._lastValueReported){ |
||
| 225 | dijit.form._FormValueWidget.prototype._setValueAttr.call(this,this.value,true); |
||
| 226 | } |
||
| 227 | this._refreshState();
|
||
| 228 | } |
||
| 229 | } |
||
| 230 | },_onBlur:function(){ |
||
| 231 | this._hideResultList();
|
||
| 232 | this.inherited(arguments); |
||
| 233 | },_setItemAttr:function(_18,_19,_1a){ |
||
| 234 | if(!_1a){
|
||
| 235 | _1a=this.labelFunc(_18,this.store); |
||
| 236 | } |
||
| 237 | this.value=this._getValueField()!=this.searchAttr?this.store.getIdentity(_18):_1a; |
||
| 238 | this.item=_18;
|
||
| 239 | dijit.form.ComboBox.superclass._setValueAttr.call(this,this.value,_19,_1a); |
||
| 240 | },_announceOption:function(_1b){ |
||
| 241 | if(!_1b){
|
||
| 242 | return;
|
||
| 243 | } |
||
| 244 | var _1c;
|
||
| 245 | if(_1b==this._popupWidget.nextButton||_1b==this._popupWidget.previousButton){ |
||
| 246 | _1c=_1b.innerHTML; |
||
| 247 | this.item=undefined; |
||
| 248 | this.value=""; |
||
| 249 | }else{
|
||
| 250 | _1c=this.labelFunc(_1b.item,this.store); |
||
| 251 | this.set("item",_1b.item,false,_1c); |
||
| 252 | } |
||
| 253 | this.focusNode.value=this.focusNode.value.substring(0,this._lastInput.length); |
||
| 254 | dijit.setWaiState(this.focusNode,"activedescendant",dojo.attr(_1b,"id")); |
||
| 255 | this._autoCompleteText(_1c);
|
||
| 256 | },_selectOption:function(evt){ |
||
| 257 | if(evt){
|
||
| 258 | this._announceOption(evt.target);
|
||
| 259 | } |
||
| 260 | this._hideResultList();
|
||
| 261 | this._setCaretPos(this.focusNode,this.focusNode.value.length); |
||
| 262 | dijit.form._FormValueWidget.prototype._setValueAttr.call(this,this.value,true); |
||
| 263 | },_onArrowMouseDown:function(evt){ |
||
| 264 | if(this.disabled||this.readOnly){ |
||
| 265 | return;
|
||
| 266 | } |
||
| 267 | dojo.stopEvent(evt); |
||
| 268 | this.focus();
|
||
| 269 | if(this._isShowingNow){ |
||
| 270 | this._hideResultList();
|
||
| 271 | }else{
|
||
| 272 | this._startSearchAll();
|
||
| 273 | } |
||
| 274 | },_startSearchAll:function(){ |
||
| 275 | this._startSearch(""); |
||
| 276 | },_startSearchFromInput:function(){ |
||
| 277 | this._startSearch(this.focusNode.value.replace(/([\\\*\?])/g,"\\$1")); |
||
| 278 | },_getQueryString:function(_1d){ |
||
| 279 | return dojo.string.substitute(this.queryExpr,[_1d]); |
||
| 280 | },_startSearch:function(key){ |
||
| 281 | if(!this._popupWidget){ |
||
| 282 | var _1e=this.id+"_popup"; |
||
| 283 | this._popupWidget=new dijit.form._ComboBoxMenu({onChange:dojo.hitch(this,this._selectOption),id:_1e,dir:this.dir}); |
||
| 284 | dijit.removeWaiState(this.focusNode,"activedescendant"); |
||
| 285 | dijit.setWaiState(this.textbox,"owns",_1e); |
||
| 286 | } |
||
| 287 | var _1f=dojo.clone(this.query); |
||
| 288 | this._lastInput=key;
|
||
| 289 | this._lastQuery=_1f[this.searchAttr]=this._getQueryString(key); |
||
| 290 | this.searchTimer=setTimeout(dojo.hitch(this,function(_20,_21){ |
||
| 291 | this.searchTimer=null; |
||
| 292 | var _22={queryOptions:{ignoreCase:this.ignoreCase,deep:true},query:_20,onBegin:dojo.hitch(this,"_setMaxOptions"),onComplete:dojo.hitch(this,"_openResultList"),onError:function(_23){ |
||
| 293 | _21._fetchHandle=null;
|
||
| 294 | console.error("dijit.form.ComboBox: "+_23);
|
||
| 295 | dojo.hitch(_21,"_hideResultList")();
|
||
| 296 | },start:0,count:this.pageSize}; |
||
| 297 | dojo.mixin(_22,_21.fetchProperties); |
||
| 298 | this._fetchHandle=_21.store.fetch(_22);
|
||
| 299 | var _24=function(_25,_26){ |
||
| 300 | _25.start+=_25.count*_26; |
||
| 301 | _25.direction=_26; |
||
| 302 | this._fetchHandle=this.store.fetch(_25); |
||
| 303 | }; |
||
| 304 | this._nextSearch=this._popupWidget.onPage=dojo.hitch(this,_24,this._fetchHandle); |
||
| 305 | },_1f,this),this.searchDelay); |
||
| 306 | },_setMaxOptions:function(_27,_28){ |
||
| 307 | this._maxOptions=_27;
|
||
| 308 | },_getValueField:function(){ |
||
| 309 | return this.searchAttr; |
||
| 310 | },compositionend:function(evt){ |
||
| 311 | this._onKeyPress({charOrCode:229}); |
||
| 312 | },constructor:function(){ |
||
| 313 | this.query={};
|
||
| 314 | this.fetchProperties={};
|
||
| 315 | },postMixInProperties:function(){ |
||
| 316 | if(!this.store){ |
||
| 317 | var _29=this.srcNodeRef; |
||
| 318 | this.store=new dijit.form._ComboBoxDataStore(_29); |
||
| 319 | if(!("value" in this.params)){ |
||
| 320 | var _2a=this.store.fetchSelectedItem(); |
||
| 321 | if(_2a){
|
||
| 322 | var _2b=this._getValueField(); |
||
| 323 | this.value=_2b!=this.searchAttr?this.store.getValue(_2a,_2b):this.labelFunc(_2a,this.store); |
||
| 324 | } |
||
| 325 | } |
||
| 326 | } |
||
| 327 | this.inherited(arguments); |
||
| 328 | },postCreate:function(){ |
||
| 329 | if(!this.hasDownArrow){ |
||
| 330 | this.downArrowNode.style.display="none"; |
||
| 331 | } |
||
| 332 | var _2c=dojo.query("label[for=\""+this.id+"\"]"); |
||
| 333 | if(_2c.length){
|
||
| 334 | _2c[0].id=(this.id+"_label"); |
||
| 335 | var cn=this.comboNode; |
||
| 336 | dijit.setWaiState(cn,"labelledby",_2c[0].id); |
||
| 337 | } |
||
| 338 | this.inherited(arguments); |
||
| 339 | },uninitialize:function(){ |
||
| 340 | if(this._popupWidget&&!this._popupWidget._destroyed){ |
||
| 341 | this._hideResultList();
|
||
| 342 | this._popupWidget.destroy();
|
||
| 343 | } |
||
| 344 | this.inherited(arguments); |
||
| 345 | },_getMenuLabelFromItem:function(_2d){ |
||
| 346 | var _2e=this.labelAttr?this.store.getValue(_2d,this.labelAttr):this.labelFunc(_2d,this.store); |
||
| 347 | var _2f=this.labelType; |
||
| 348 | if(this.highlightMatch!="none"&&this.labelType=="text"&&this._lastInput){ |
||
| 349 | _2e=this.doHighlight(_2e,this._escapeHtml(this._lastInput)); |
||
| 350 | _2f="html";
|
||
| 351 | } |
||
| 352 | return {html:_2f=="html",label:_2e}; |
||
| 353 | },doHighlight:function(_30,_31){ |
||
| 354 | var _32="i"+(this.highlightMatch=="all"?"g":""); |
||
| 355 | var _33=this._escapeHtml(_30); |
||
| 356 | _31=dojo.regexp.escapeString(_31); |
||
| 357 | var ret=_33.replace(new RegExp("(^|\\s)("+_31+")",_32),"$1<span class=\"dijitComboBoxHighlightMatch\">$2</span>"); |
||
| 358 | return ret;
|
||
| 359 | },_escapeHtml:function(str){ |
||
| 360 | str=String(str).replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">").replace(/"/gm,"""); |
||
| 361 | return str;
|
||
| 362 | },open:function(){ |
||
| 363 | this._isShowingNow=true; |
||
| 364 | return dijit.popup.open({popup:this._popupWidget,around:this.domNode,parent:this}); |
||
| 365 | },reset:function(){ |
||
| 366 | this.item=null; |
||
| 367 | this.inherited(arguments); |
||
| 368 | },labelFunc:function(_34,_35){ |
||
| 369 | return _35.getValue(_34,this.searchAttr).toString(); |
||
| 370 | }}); |
||
| 371 | dojo.declare("dijit.form._ComboBoxMenu",[dijit._Widget,dijit._Templated,dijit._CssStateMixin],{templateString:"<ul class='dijitReset dijitMenu' dojoAttachEvent='onmousedown:_onMouseDown,onmouseup:_onMouseUp,onmouseover:_onMouseOver,onmouseout:_onMouseOut' tabIndex='-1' style='overflow: \"auto\"; overflow-x: \"hidden\";'>"+"<li class='dijitMenuItem dijitMenuPreviousButton' dojoAttachPoint='previousButton' waiRole='option'></li>"+"<li class='dijitMenuItem dijitMenuNextButton' dojoAttachPoint='nextButton' waiRole='option'></li>"+"</ul>",_messages:null,baseClass:"dijitComboBoxMenu",postMixInProperties:function(){ |
||
| 372 | this._messages=dojo.i18n.getLocalization("dijit.form","ComboBox",this.lang); |
||
| 373 | this.inherited(arguments); |
||
| 374 | },_setValueAttr:function(_36){ |
||
| 375 | this.value=_36;
|
||
| 376 | this.onChange(_36);
|
||
| 377 | },onChange:function(_37){ |
||
| 378 | },onPage:function(_38){ |
||
| 379 | },postCreate:function(){ |
||
| 380 | this.previousButton.innerHTML=this._messages["previousMessage"]; |
||
| 381 | this.nextButton.innerHTML=this._messages["nextMessage"]; |
||
| 382 | this.inherited(arguments); |
||
| 383 | },onClose:function(){ |
||
| 384 | this._blurOptionNode();
|
||
| 385 | },_createOption:function(_39,_3a){ |
||
| 386 | var _3b=_3a(_39);
|
||
| 387 | var _3c=dojo.doc.createElement("li"); |
||
| 388 | dijit.setWaiRole(_3c,"option");
|
||
| 389 | if(_3b.html){
|
||
| 390 | _3c.innerHTML=_3b.label; |
||
| 391 | }else{
|
||
| 392 | _3c.appendChild(dojo.doc.createTextNode(_3b.label)); |
||
| 393 | } |
||
| 394 | if(_3c.innerHTML==""){ |
||
| 395 | _3c.innerHTML=" ";
|
||
| 396 | } |
||
| 397 | _3c.item=_39; |
||
| 398 | return _3c;
|
||
| 399 | },createOptions:function(_3d,_3e,_3f){ |
||
| 400 | this.previousButton.style.display=(_3e.start==0)?"none":""; |
||
| 401 | dojo.attr(this.previousButton,"id",this.id+"_prev"); |
||
| 402 | dojo.forEach(_3d,function(_40,i){
|
||
| 403 | var _41=this._createOption(_40,_3f); |
||
| 404 | _41.className="dijitReset dijitMenuItem"+(this.isLeftToRight()?"":" dijitMenuItemRtl"); |
||
| 405 | dojo.attr(_41,"id",this.id+i); |
||
| 406 | this.domNode.insertBefore(_41,this.nextButton); |
||
| 407 | },this);
|
||
| 408 | var _42=false; |
||
| 409 | if(_3e._maxOptions&&_3e._maxOptions!=-1){ |
||
| 410 | if((_3e.start+_3e.count)<_3e._maxOptions){
|
||
| 411 | _42=true;
|
||
| 412 | }else{
|
||
| 413 | if((_3e.start+_3e.count)>_3e._maxOptions&&_3e.count==_3d.length){
|
||
| 414 | _42=true;
|
||
| 415 | } |
||
| 416 | } |
||
| 417 | }else{
|
||
| 418 | if(_3e.count==_3d.length){
|
||
| 419 | _42=true;
|
||
| 420 | } |
||
| 421 | } |
||
| 422 | this.nextButton.style.display=_42?"":"none"; |
||
| 423 | dojo.attr(this.nextButton,"id",this.id+"_next"); |
||
| 424 | return this.domNode.childNodes; |
||
| 425 | },clearResultList:function(){ |
||
| 426 | while(this.domNode.childNodes.length>2){ |
||
| 427 | this.domNode.removeChild(this.domNode.childNodes[this.domNode.childNodes.length-2]); |
||
| 428 | } |
||
| 429 | },_onMouseDown:function(evt){ |
||
| 430 | dojo.stopEvent(evt); |
||
| 431 | },_onMouseUp:function(evt){ |
||
| 432 | if(evt.target===this.domNode||!this._highlighted_option){ |
||
| 433 | return;
|
||
| 434 | }else{
|
||
| 435 | if(evt.target==this.previousButton){ |
||
| 436 | this.onPage(-1); |
||
| 437 | }else{
|
||
| 438 | if(evt.target==this.nextButton){ |
||
| 439 | this.onPage(1); |
||
| 440 | }else{
|
||
| 441 | var tgt=evt.target;
|
||
| 442 | while(!tgt.item){
|
||
| 443 | tgt=tgt.parentNode; |
||
| 444 | } |
||
| 445 | this._setValueAttr({target:tgt},true); |
||
| 446 | } |
||
| 447 | } |
||
| 448 | } |
||
| 449 | },_onMouseOver:function(evt){ |
||
| 450 | if(evt.target===this.domNode){ |
||
| 451 | return;
|
||
| 452 | } |
||
| 453 | var tgt=evt.target;
|
||
| 454 | if(!(tgt==this.previousButton||tgt==this.nextButton)){ |
||
| 455 | while(!tgt.item){
|
||
| 456 | tgt=tgt.parentNode; |
||
| 457 | } |
||
| 458 | } |
||
| 459 | this._focusOptionNode(tgt);
|
||
| 460 | },_onMouseOut:function(evt){ |
||
| 461 | if(evt.target===this.domNode){ |
||
| 462 | return;
|
||
| 463 | } |
||
| 464 | this._blurOptionNode();
|
||
| 465 | },_focusOptionNode:function(_43){ |
||
| 466 | if(this._highlighted_option!=_43){ |
||
| 467 | this._blurOptionNode();
|
||
| 468 | this._highlighted_option=_43;
|
||
| 469 | dojo.addClass(this._highlighted_option,"dijitMenuItemSelected"); |
||
| 470 | } |
||
| 471 | },_blurOptionNode:function(){ |
||
| 472 | if(this._highlighted_option){ |
||
| 473 | dojo.removeClass(this._highlighted_option,"dijitMenuItemSelected"); |
||
| 474 | this._highlighted_option=null; |
||
| 475 | } |
||
| 476 | },_highlightNextOption:function(){ |
||
| 477 | if(!this.getHighlightedOption()){ |
||
| 478 | var fc=this.domNode.firstChild; |
||
| 479 | this._focusOptionNode(fc.style.display=="none"?fc.nextSibling:fc); |
||
| 480 | }else{
|
||
| 481 | var ns=this._highlighted_option.nextSibling; |
||
| 482 | if(ns&&ns.style.display!="none"){ |
||
| 483 | this._focusOptionNode(ns);
|
||
| 484 | }else{
|
||
| 485 | this.highlightFirstOption();
|
||
| 486 | } |
||
| 487 | } |
||
| 488 | dojo.window.scrollIntoView(this._highlighted_option);
|
||
| 489 | },highlightFirstOption:function(){ |
||
| 490 | var _44=this.domNode.firstChild; |
||
| 491 | var _45=_44.nextSibling;
|
||
| 492 | this._focusOptionNode(_45.style.display=="none"?_44:_45); |
||
| 493 | dojo.window.scrollIntoView(this._highlighted_option);
|
||
| 494 | },highlightLastOption:function(){ |
||
| 495 | this._focusOptionNode(this.domNode.lastChild.previousSibling); |
||
| 496 | dojo.window.scrollIntoView(this._highlighted_option);
|
||
| 497 | },_highlightPrevOption:function(){ |
||
| 498 | if(!this.getHighlightedOption()){ |
||
| 499 | var lc=this.domNode.lastChild; |
||
| 500 | this._focusOptionNode(lc.style.display=="none"?lc.previousSibling:lc); |
||
| 501 | }else{
|
||
| 502 | var ps=this._highlighted_option.previousSibling; |
||
| 503 | if(ps&&ps.style.display!="none"){ |
||
| 504 | this._focusOptionNode(ps);
|
||
| 505 | }else{
|
||
| 506 | this.highlightLastOption();
|
||
| 507 | } |
||
| 508 | } |
||
| 509 | dojo.window.scrollIntoView(this._highlighted_option);
|
||
| 510 | },_page:function(up){ |
||
| 511 | var _46=0; |
||
| 512 | var _47=this.domNode.scrollTop; |
||
| 513 | var _48=dojo.style(this.domNode,"height"); |
||
| 514 | if(!this.getHighlightedOption()){ |
||
| 515 | this._highlightNextOption();
|
||
| 516 | } |
||
| 517 | while(_46<_48){
|
||
| 518 | if(up){
|
||
| 519 | if(!this.getHighlightedOption().previousSibling||this._highlighted_option.previousSibling.style.display=="none"){ |
||
| 520 | break;
|
||
| 521 | } |
||
| 522 | this._highlightPrevOption();
|
||
| 523 | }else{
|
||
| 524 | if(!this.getHighlightedOption().nextSibling||this._highlighted_option.nextSibling.style.display=="none"){ |
||
| 525 | break;
|
||
| 526 | } |
||
| 527 | this._highlightNextOption();
|
||
| 528 | } |
||
| 529 | var _49=this.domNode.scrollTop; |
||
| 530 | _46+=(_49-_47)*(up?-1:1); |
||
| 531 | _47=_49; |
||
| 532 | } |
||
| 533 | },pageUp:function(){ |
||
| 534 | this._page(true); |
||
| 535 | },pageDown:function(){ |
||
| 536 | this._page(false); |
||
| 537 | },getHighlightedOption:function(){ |
||
| 538 | var ho=this._highlighted_option; |
||
| 539 | return (ho&&ho.parentNode)?ho:null; |
||
| 540 | },handleKey:function(key){ |
||
| 541 | switch(key){
|
||
| 542 | case dojo.keys.DOWN_ARROW:
|
||
| 543 | this._highlightNextOption();
|
||
| 544 | break;
|
||
| 545 | case dojo.keys.PAGE_DOWN:
|
||
| 546 | this.pageDown();
|
||
| 547 | break;
|
||
| 548 | case dojo.keys.UP_ARROW:
|
||
| 549 | this._highlightPrevOption();
|
||
| 550 | break;
|
||
| 551 | case dojo.keys.PAGE_UP:
|
||
| 552 | this.pageUp();
|
||
| 553 | break;
|
||
| 554 | } |
||
| 555 | }}); |
||
| 556 | dojo.declare("dijit.form.ComboBox",[dijit.form.ValidationTextBox,dijit.form.ComboBoxMixin],{_setValueAttr:function(_4a,_4b,_4c){ |
||
| 557 | this.item=null; |
||
| 558 | if(!_4a){
|
||
| 559 | _4a="";
|
||
| 560 | } |
||
| 561 | dijit.form.ValidationTextBox.prototype._setValueAttr.call(this,_4a,_4b,_4c);
|
||
| 562 | }}); |
||
| 563 | dojo.declare("dijit.form._ComboBoxDataStore",null,{constructor:function(_4d){ |
||
| 564 | this.root=_4d;
|
||
| 565 | if(_4d.tagName!="SELECT"&&_4d.firstChild){ |
||
| 566 | _4d=dojo.query("select",_4d);
|
||
| 567 | if(_4d.length>0){ |
||
| 568 | _4d=_4d[0];
|
||
| 569 | }else{
|
||
| 570 | this.root.innerHTML="<SELECT>"+this.root.innerHTML+"</SELECT>"; |
||
| 571 | _4d=this.root.firstChild;
|
||
| 572 | } |
||
| 573 | this.root=_4d;
|
||
| 574 | } |
||
| 575 | dojo.query("> option",_4d).forEach(function(_4e){ |
||
| 576 | _4e.innerHTML=dojo.trim(_4e.innerHTML); |
||
| 577 | }); |
||
| 578 | },getValue:function(_4f,_50,_51){ |
||
| 579 | return (_50=="value")?_4f.value:(_4f.innerText||_4f.textContent||""); |
||
| 580 | },isItemLoaded:function(_52){ |
||
| 581 | return true; |
||
| 582 | },getFeatures:function(){ |
||
| 583 | return {"dojo.data.api.Read":true,"dojo.data.api.Identity":true}; |
||
| 584 | },_fetchItems:function(_53,_54,_55){ |
||
| 585 | if(!_53.query){
|
||
| 586 | _53.query={};
|
||
| 587 | } |
||
| 588 | if(!_53.query.name){
|
||
| 589 | _53.query.name="";
|
||
| 590 | } |
||
| 591 | if(!_53.queryOptions){
|
||
| 592 | _53.queryOptions={};
|
||
| 593 | } |
||
| 594 | var _56=dojo.data.util.filter.patternToRegExp(_53.query.name,_53.queryOptions.ignoreCase),_57=dojo.query("> option",this.root).filter(function(_58){ |
||
| 595 | return (_58.innerText||_58.textContent||"").match(_56); |
||
| 596 | }); |
||
| 597 | if(_53.sort){
|
||
| 598 | _57.sort(dojo.data.util.sorter.createSortFunction(_53.sort,this));
|
||
| 599 | } |
||
| 600 | _54(_57,_53); |
||
| 601 | },close:function(_59){ |
||
| 602 | return;
|
||
| 603 | },getLabel:function(_5a){ |
||
| 604 | return _5a.innerHTML;
|
||
| 605 | },getIdentity:function(_5b){ |
||
| 606 | return dojo.attr(_5b,"value"); |
||
| 607 | },fetchItemByIdentity:function(_5c){ |
||
| 608 | var _5d=dojo.query("> option[value='"+_5c.identity+"']",this.root)[0]; |
||
| 609 | _5c.onItem(_5d); |
||
| 610 | },fetchSelectedItem:function(){ |
||
| 611 | var _5e=this.root,si=_5e.selectedIndex; |
||
| 612 | return typeof si=="number"?dojo.query("> option:nth-child("+(si!=-1?si+1:1)+")",_5e)[0]:null; |
||
| 613 | }}); |
||
| 614 | dojo.extend(dijit.form._ComboBoxDataStore,dojo.data.util.simpleFetch); |
||
| 615 | } |