ttrss/lib/dijit/form/_AutoCompleterMixin.js

2 lines
7.3 KiB
JavaScript
Raw Permalink Normal View History

2012-08-14 14:59:10 +00:00
//>>built
define("dijit/form/_AutoCompleterMixin",["dojo/aspect","dojo/_base/declare","dojo/dom-attr","dojo/keys","dojo/_base/lang","dojo/query","dojo/regexp","dojo/sniff","./DataList","./_TextBoxMixin","./_SearchMixin"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b){var _c=_2("dijit.form._AutoCompleterMixin",_b,{item:null,autoComplete:true,highlightMatch:"first",labelAttr:"",labelType:"text",maxHeight:-1,_stopClickEvents:false,_getCaretPos:function(_d){var _e=0;if(typeof (_d.selectionStart)=="number"){_e=_d.selectionStart;}else{if(_8("ie")){var tr=_d.ownerDocument.selection.createRange().duplicate();var _f=_d.createTextRange();tr.move("character",0);_f.move("character",0);try{_f.setEndPoint("EndToEnd",tr);_e=String(_f.text).replace(/\r/g,"").length;}catch(e){}}}return _e;},_setCaretPos:function(_10,_11){_11=parseInt(_11);_a.selectInputText(_10,_11,_11);},_setDisabledAttr:function(_12){this.inherited(arguments);this.domNode.setAttribute("aria-disabled",_12?"true":"false");},_onKey:function(evt){if(evt.charCode>=32){return;}var key=evt.charCode||evt.keyCode;if(key==_4.ALT||key==_4.CTRL||key==_4.META||key==_4.SHIFT){return;}var pw=this.dropDown;var _13=null;this._abortQuery();this.inherited(arguments);if(evt.altKey||evt.ctrlKey||evt.metaKey){return;}if(this._opened){_13=pw.getHighlightedOption();}switch(key){case _4.PAGE_DOWN:case _4.DOWN_ARROW:case _4.PAGE_UP:case _4.UP_ARROW:if(this._opened){this._announceOption(_13);}evt.stopPropagation();evt.preventDefault();break;case _4.ENTER:if(_13){if(_13==pw.nextButton){this._nextSearch(1);evt.stopPropagation();evt.preventDefault();break;}else{if(_13==pw.previousButton){this._nextSearch(-1);evt.stopPropagation();evt.preventDefault();break;}}evt.stopPropagation();evt.preventDefault();}else{this._setBlurValue();this._setCaretPos(this.focusNode,this.focusNode.value.length);}case _4.TAB:var _14=this.get("displayedValue");if(pw&&(_14==pw._messages["previousMessage"]||_14==pw._messages["nextMessage"])){break;}if(_13){this._selectOption(_13);}case _4.ESCAPE:if(this._opened){this._lastQuery=null;this.closeDropDown();}break;}},_autoCompleteText:function(_15){var fn=this.focusNode;_a.selectInputText(fn,fn.value.length);var _16=this.ignoreCase?"toLowerCase":"substr";if(_15[_16](0).indexOf(this.focusNode.value[_16](0))==0){var _17=this.autoComplete?this._getCaretPos(fn):fn.value.length;if((_17+1)>fn.value.length){fn.value=_15;_a.selectInputText(fn,_17);}}else{fn.value=_15;_a.selectInputText(fn);}},_openResultList:function(_18,_19,_1a){var _1b=this.dropDown.getHighlightedOption();this.dropDown.clearResultList();if(!_18.length&&_1a.start==0){this.closeDropDown();return;}this._nextSearch=this.dropDown.onPage=_5.hitch(this,function(_1c){_18.nextPage(_1c!==-1);this.focus();});this.dropDown.createOptions(_18,_1a,_5.hitch(this,"_getMenuLabelFromItem"));this._showResultList();if("direction" in _1a){if(_1a.direction){this.dropDown.highlightFirstOption();}else{if(!_1a.direction){this.dropDown.highlightLastOption();}}if(_1b){this._announceOption(this.dropDown.getHighlightedOption());}}else{if(this.autoComplete&&!this._prev_key_backspace&&!/^[*]+$/.test(_19[this.searchAttr].toString())){this._announceOption(this.dropDown.containerNode.firstChild.nextSibling);}}},_showResultList:function(){this.closeDropDown(true);this.openDropDown();this.domNode.setAttribute("aria-expanded","true");},loadDropDown:function(){this._startSearchAll();},isLoaded:function(){return false;},closeDropDown:function(){this._abortQuery();if(this._opened){this.inherited(arguments);this.domNode.setAttribute("aria-expanded","false");}},_setBlurValue:function(){var _1d=this.get("displayedValue");var pw=this.dropDown;if(pw&&(_1d==pw._messages["previousMessage"]||_1d==pw._messages["nextMessage"])){this._setValueAttr(this._lastValueReported,true);}else{if(typeof this.item=="undefined"){this.item=null;this.set("displayedValue",_1d);}else{if(this.value!=this._lastValueReported){this._handleOnChange(this.value,true);}this._refreshState();}}this.focusNode.removeAttribute("aria-activedescendant");},_setItemAttr:function(_1e,_1f,_20){var _21="";if(_1e){if(!_