/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dijit.form.ComboBox"]){
dojo._hasResource["dijit.form.ComboBox"]=true;
dojo.provide("dijit.form.ComboBox");
dojo.require("dojo.window");
dojo.require("dojo.regexp");
dojo.require("dojo.data.util.simpleFetch");
dojo.require("dojo.data.util.filter");
dojo.require("dijit._CssStateMixin");
dojo.require("dijit.form._FormWidget");
dojo.require("dijit.form.ValidationTextBox");
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");
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","
\n"),baseClass:"dijitTextBox dijitComboBox",cssStateNodes:{"downArrowNode":"dijitDownArrowButton"},_getCaretPos:function(_1){
var _2=0;
if(typeof (_1.selectionStart)=="number"){
_2=_1.selectionStart;
}else{
if(dojo.isIE){
var tr=dojo.doc.selection.createRange().duplicate();
var _3=_1.createTextRange();
tr.move("character",0);
_3.move("character",0);
try{
_3.setEndPoint("EndToEnd",tr);
_2=String(_3.text).replace(/\r/g,"").length;
}
catch(e){
}
}
}
return _2;
},_setCaretPos:function(_4,_5){
_5=parseInt(_5);
dijit.selectInputText(_4,_5,_5);
},_setDisabledAttr:function(_6){
this.inherited(arguments);
dijit.setWaiState(this.comboNode,"disabled",_6);
},_abortQuery:function(){
if(this.searchTimer){
clearTimeout(this.searchTimer);
this.searchTimer=null;
}
if(this._fetchHandle){
if(this._fetchHandle.abort){
this._fetchHandle.abort();
}
this._fetchHandle=null;
}
},_onInput:function(_7){
if(!this.searchTimer&&(_7.type=="paste"||_7.type=="input")&&this._lastInput!=this.textbox.value){
this.searchTimer=setTimeout(dojo.hitch(this,function(){
this._onKeyPress({charOrCode:229});
}),100);
}
this.inherited(arguments);
},_onKeyPress:function(_8){
var _9=_8.charOrCode;
if(_8.altKey||((_8.ctrlKey||_8.metaKey)&&(_9!="x"&&_9!="v"))||_9==dojo.keys.SHIFT){
return;
}
var _a=false;
var _b="_startSearchFromInput";
var pw=this._popupWidget;
var dk=dojo.keys;
var _c=null;
this._prev_key_backspace=false;
this._abortQuery();
if(this._isShowingNow){
pw.handleKey(_9);
_c=pw.getHighlightedOption();
}
switch(_9){
case dk.PAGE_DOWN:
case dk.DOWN_ARROW:
case dk.PAGE_UP:
case dk.UP_ARROW:
if(!this._isShowingNow){
_a=true;
_b="_startSearchAll";
}else{
this._announceOption(_c);
}
dojo.stopEvent(_8);
break;
case dk.ENTER:
if(_c){
if(_c==pw.nextButton){
this._nextSearch(1);
dojo.stopEvent(_8);
break;
}else{
if(_c==pw.previousButton){
this._nextSearch(-1);
dojo.stopEvent(_8);
break;
}
}
}else{
this._setBlurValue();
this._setCaretPos(this.focusNode,this.focusNode.value.length);
}
_8.preventDefault();
case dk.TAB:
var _d=this.get("displayedValue");
if(pw&&(_d==pw._messages["previousMessage"]||_d==pw._messages["nextMessage"])){
break;
}
if(_c){
this._selectOption();
}
if(this._isShowingNow){
this._lastQuery=null;
this._hideResultList();
}
break;
case " ":
if(_c){
dojo.stopEvent(_8);
this._selectOption();
this._hideResultList();
}else{
_a=true;
}
break;
case dk.ESCAPE:
if(this._isShowingNow){
dojo.stopEvent(_8);
this._hideResultList();
}
break;
case dk.DELETE:
case dk.BACKSPACE:
this._prev_key_backspace=true;
_a=true;
break;
default:
_a=typeof _9=="string"||_9==229;
}
if(_a){
this.item=undefined;
this.searchTimer=setTimeout(dojo.hitch(this,_b),1);
}
},_autoCompleteText:function(_e){
var fn=this.focusNode;
dijit.selectInputText(fn,fn.value.length);
var _f=this.ignoreCase?"toLowerCase":"substr";
if(_e[_f](0).indexOf(this.focusNode.value[_f](0))==0){
var _10=this._getCaretPos(fn);
if((_10+1)>fn.value.length){
fn.value=_e;
dijit.selectInputText(fn,_10);
}
}else{
fn.value=_e;
dijit.selectInputText(fn);
}
},_openResultList:function(_11,_12){
this._fetchHandle=null;
if(this.disabled||this.readOnly||(_12.query[this.searchAttr]!=this._lastQuery)){
return;
}
this._popupWidget.clearResultList();
if(!_11.length&&!this._maxOptions){
this._hideResultList();
return;
}
_12._maxOptions=this._maxOptions;
var _13=this._popupWidget.createOptions(_11,_12,dojo.hitch(this,"_getMenuLabelFromItem"));
this._showResultList();
if(_12.direction){
if(1==_12.direction){
this._popupWidget.highlightFirstOption();
}else{
if(-1==_12.direction){
this._popupWidget.highlightLastOption();
}
}
this._announceOption(this._popupWidget.getHighlightedOption());
}else{
if(this.autoComplete&&!this._prev_key_backspace&&!/^[*]+$/.test(_12.query[this.searchAttr])){
this._announceOption(_13[1]);
}
}
},_showResultList:function(){
this._hideResultList();
this.displayMessage("");
dojo.style(this._popupWidget.domNode,{width:"",height:""});
var _14=this.open();
var _15=dojo.marginBox(this._popupWidget.domNode);
this._popupWidget.domNode.style.overflow=((_14.h==_15.h)&&(_14.w==_15.w))?"hidden":"auto";
var _16=_14.w;
if(_14.h$2");
return ret;
},_escapeHtml:function(str){
str=String(str).replace(/&/gm,"&").replace(//gm,">").replace(/"/gm,""");
return str;
},open:function(){
this._isShowingNow=true;
return dijit.popup.open({popup:this._popupWidget,around:this.domNode,parent:this});
},reset:function(){
this.item=null;
this.inherited(arguments);
},labelFunc:function(_34,_35){
return _35.getValue(_34,this.searchAttr).toString();
}});
dojo.declare("dijit.form._ComboBoxMenu",[dijit._Widget,dijit._Templated,dijit._CssStateMixin],{templateString:"