1 line
31 KiB
JavaScript
1 line
31 KiB
JavaScript
Type.registerNamespace("Sys.Extended.UI"),Sys.Extended.UI.ComboBoxAutoCompleteMode=function(){},Sys.Extended.UI.ComboBoxAutoCompleteMode.prototype={None:0,Append:1,Suggest:2,SuggestAppend:3},Sys.Extended.UI.ComboBoxAutoCompleteMode.registerEnum("Sys.Extended.UI.ComboBoxAutoCompleteMode",!1),Sys.Extended.UI.ComboBoxStyle=function(){},Sys.Extended.UI.ComboBoxStyle.prototype={DropDownList:0,DropDown:1,Simple:2},Sys.Extended.UI.ComboBoxStyle.registerEnum("Sys.Extended.UI.ComboBoxStyle",!1),Sys.Extended.UI.ComboBoxTextSelectionStrategy=function(){},Sys.Extended.UI.ComboBoxTextSelectionStrategy.prototype={Unknown:0,Microsoft:1,W3C:2},Sys.Extended.UI.ComboBoxTextSelectionStrategy.registerEnum("Sys.Extended.UI.ComboBoxTextSelectionStrategy",!1),Sys.Extended.UI.ComboBox=function(t){Sys.Extended.UI.ComboBox.initializeBase(this,[t]),this._comboTableControl=null,this._textBoxControl=null,this._optionListControl=null,this._buttonControl=null,this._hiddenFieldControl=null,this._autoPostBack=!1,this._autoCompleteMode=null,this._dropDownStyle=null,this._caseSensitive=!1,this._originalSelectedIndex=null,this._listItemHoverCssClass=null,this._popupBehavior=null,this._supressFocusHide=!0,this._doingPostBack=!1,this._textSelectionStrategy=null,this._highlightSuggestedItem=!1,this._highlightedIndex=null,this._optionListItems=null,this._optionListItemHeight=null,this._optionListHeight=null,this._optionListWidth=null,this.clearDelegates()},Sys.Extended.UI.ComboBox.prototype={initialize:function(){Sys.Extended.UI.ComboBox.callBaseMethod(this,"initialize"),ComboBox_Elements[ComboBox_Elements.length]=this;var t,e,o=this._findHiddenParent(this.get_comboTableControl());null!=o&&(t=o.style.display,e=o.style.visibility,o.style.visibility="visible",o.style.display="block"),this.createDelegates(),this.initializeTextBox(),this.initializeButton(),this.initializeOptionList(),this.addHandlers(),null!=o&&(o.style.visibility=e,o.style.display=t)},dispose:function(){this._popupBehavior&&(this._popupBehavior.remove_showing(this._popupShowingHandler),this._popupBehavior.remove_shown(this._popupShownHandler),this._popupBehavior.remove_hiding(this._popupHidingHandler),this._popupBehavior.dispose(),this._popupBehavior=null),this.clearHandlers(),this.clearDelegates(),Sys.Extended.UI.ComboBox.callBaseMethod(this,"dispose")},_findHiddenParent:function(t){var e=t.parentElement;return null==e||"hidden"==e.style.visibility||"none"==e.style.display?e:this._findHiddenParent(e)},createDelegates:function(){this._listMouseOverHandler=Function.createDelegate(this,this._onListMouseOver),this._listMouseOutHandler=Function.createDelegate(this,this._onListMouseOut),this._listMouseDownHandler=Function.createDelegate(this,this._onListMouseDown),this._listClickHandler=Function.createDelegate(this,this._onListClick),this._listDragHandler=Function.createDelegate(this,this._onListDrag),this._listSelectStartHandler=Function.createDelegate(this,this._onListSelectStart),this._listMouseWheelHandler=Function.createDelegate(this,this._onListMouseWheel),this._textBoxClickHandler=Function.createDelegate(this,this._onTextBoxClick),this._textBoxFocusHandler=Function.createDelegate(this,this._onTextBoxFocus),this._textBoxBlurHandler=Function.createDelegate(this,this._onTextBoxBlur),this._textBoxKeyPressHandler=Function.createDelegate(this,this._onTextBoxKeyPress),this._textBoxKeyDownHandler=Function.createDelegate(this,this._onTextBoxKeyDown),this._buttonClickHandler=Function.createDelegate(this,this._onButtonClick),this._buttonBlurHandler=Function.createDelegate(this,this._onButtonBlur),this._buttonKeyDownHandler=Function.createDelegate(this,this._onButtonKeyDown),this._buttonKeyPressHandler=Function.createDelegate(this,this._onButtonKeyPress),this._documentClickHandler=Function.createDelegate(this,this._onDocumentClick),this._documentMouseWheelHandler=Function.createDelegate(this,this._onDocumentMouseWheel),this._popupShowingHandler=Function.createDelegate(this,this._popupShowing),this._popupShownHandler=Function.createDelegate(this,this._popupShown),this._popupHidingHandler=Function.createDelegate(this,this._popupHiding)},clearDelegates:function(){this._listMouseOverHandler=null,this._listMouseOutHandler=null,this._listMouseDownHandler=null,this._listClickHandler=null,this._listDragHandler=null,this._listSelectStartHandler=null,this._listMouseWheelHandler=null,this._textBoxClickHandler=null,this._textBoxFocusHandler=null,this._textBoxBlurHandler=null,this._textBoxKeyPressHandler=null,this._textBoxKeyDownHandler=null,this._buttonClickHandler=null,this._buttonBlurHandler=null,this._buttonKeyDownHandler=null,this._buttonKeyPressHandler=null,this._documentClickHandler=null,this._documentMouseWheelHandler=null,this._popupShowingHandler=null,this._popupShownHandler=null,this._popupHidingHandler=null},addHandlers:function(){var t=this.get_optionListControl();$addHandlers(t,{mouseover:this._listMouseOverHandler,mouseout:this._listMouseOutHandler,mousedown:this._listMouseDownHandler,click:this._listClickHandler,drag:this._listDragHandler,selectstart:this._listSelectStartHandler},this),$addHandlers(this.get_textBoxControl(),{click:this._textBoxClickHandler,focus:this._textBoxFocusHandler,blur:this._textBoxBlurHandler,keypress:this._textBoxKeyPressHandler,keydown:this._textBoxKeyDownHandler},this),$addHandlers(this.get_buttonControl(),{click:this._buttonClickHandler,blur:this._buttonBlurHandler,keydown:this._buttonKeyDownHandler,keypress:this._buttonKeyPressHandler},this),$addHandler(document,"click",this._documentClickHandler),"undefined"==typeof t.onmousewheel?($addHandler(t,"DOMMouseScroll",this._listMouseWheelHandler),$addHandler(document,"DOMMouseScroll",this._documentMouseWheelHandler)):($addHandler(t,"mousewheel",this._listMouseWheelHandler),$addHandler(document,"mousewheel",this._documentMouseWheelHandler))},clearHandlers:function(){$clearHandlers(this.get_optionListControl()),$clearHandlers(this.get_textBoxControl()),$clearHandlers(this.get_buttonControl()),$clearHandlers(document)},initializeTextBox:function(){var t=this.get_textBoxControl().style;""==t.margin&&(t.margin="0px")},initializeButton:function(){var t=this.get_buttonControl().style;""==t.height&&this.get_textBoxControl().offsetHeight>=0&&(t.height=this.get_textBoxControl().offsetHeight+"px"),""==t.width&&(t.width=t.height),""==t.padding&&(t.padding="0px")},initializeOptionList:function(){if(null==this.get_optionListControl()){var t=document.createElement("ul");this.get_element().appendChild(t),this.set_optionListControl(t)}var e=this.get_optionListControl();if(Sys.Browser.agent===Sys.Browser.Safari){var o=e.parentNode;null!=o&&o.removeChild(e);for(var i=this.get_element().parentNode;typeof i!=typeof document.forms[0];)i=i.parentNode;var n=document.createElement("div");n.className=this.get_element().className,n.appendChild(e),i.appendChild(n)}var s=e.style;s.display="block",s.zIndex=Sys.Extended.UI.zIndex.ComboBoxList,this._optionListItems=new Array;for(var l=e.childNodes,h=0;h<l.length;h++){var r=l[h];if(void 0!=r.tagName&&"LI"==r.tagName.toUpperCase()){for(var d=new Object,a=r.innerHTML.trim(),u=a.indexOf("\r");u>=0;)a=a.substring(0,u).trim()+" "+a.substring(u+1,a.length).trim(),u=a.indexOf("\r");for(var g=a.indexOf("\n");g>=0;)a=a.substring(0,g).trim()+" "+a.substring(g+1,a.length).trim(),g=a.indexOf("\n");a=a.replace(/\&/g,"&").replace(/\"/g,'"').replace(/\>/g,">").replace(/\</g,"<"),d.text=a.trim(),Array.add(this._optionListItems,d),this.initializeOptionListItem(r)}else e.removeChild(r),h--}s.width=this._getOptionListBounds().width+"px",s.width="0px",this._popupBehavior=$create(Sys.Extended.UI.PopupBehavior,{id:this.get_id()+"_PopupBehavior",parentElement:this.get_textBoxControl(),positioningMode:Sys.Extended.UI.PositioningMode.BottomLeft},null,null,e),this._popupBehavior.add_showing(this._popupShowingHandler),this._popupBehavior.add_shown(this._popupShownHandler),this._popupBehavior.add_hiding(this._popupHidingHandler),this.get_selectedIndex()>=0?(this._highlightListItem(this.get_selectedIndex()),this.get_textBoxControl().value=this._optionListItems[this.get_selectedIndex()].text):this.get_textBoxControl().value="",this._popupShowing(),e.style.display="none"},initializeOptionListItem:function(t){t._textIsEmpty=!1,t.innerHTML.length<1&&(t.innerHTML=" ",t._textIsEmpty=!0)},_popupShowing:function(){var t=this._getWindowBounds(),e=Sys.UI.DomElement.getBounds(this.get_comboTableControl()),o=this._getOptionListBounds(),i=30,n=t.y+t.height/2,s=e.y+e.height,l=t.x+t.width/2,h=e.x+e.width/2,r=e.y-t.y,d="Top";s<=n&&(d="Bottom",r=t.height-e.height-r);var a=this._getOptionListItemHeight();r=r>=o.height?o.height:a*(Math.floor(r/a)-2);var u=r/a,g=u<this._optionListItems.length,_=20;"Top"==d&&r<t.height-e.y&&(d="Bottom");var p=e.x-t.x,c="Left";h<=l?p=t.width-p:(c="Right",p=e.width+p),p-=i;var x=o.width;g?(x+=_,p>=x&&(p=x)):p>=x&&(p=x),"Right"==c&&p<t.width-e.x&&(c="Left"),r<0&&(r=0),p<0&&(p=0);var y=this.get_optionListControl().style;y.height=r+"px",y.width=p+"px",g?(y.overflow="auto",y.overflowX="hidden"):y.overflow="hidden";var m=d+c;"BottomLeft"==m?this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomLeft):"BottomRight"==m?this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomRight):"TopLeft"==m?this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopLeft):"TopRight"==m&&this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopRight),y.visibility="hidden"},_popupShown:function(){var t=this.get_optionListControl();t.style.display="block";var e,o=(Sys.UI.DomElement.getBounds(this.get_comboTableControl()),Sys.UI.DomElement.getBounds(t)),i=Sys.UI.DomElement.getBounds(this.get_textBoxControl()),n=o.y;this._popupBehavior.get_positioningMode()===Sys.Extended.UI.PositioningMode.BottomLeft||this._popupBehavior.get_positioningMode()===Sys.Extended.UI.PositioningMode.TopLeft?e=i.x:this._popupBehavior.get_positioningMode()!==Sys.Extended.UI.PositioningMode.BottomRight&&this._popupBehavior.get_positioningMode()!==Sys.Extended.UI.PositioningMode.TopRight||(e=i.x-(o.width-i.width)),"absolute"==$common.getCurrentStyle(this.get_textBoxControl(),"position","")&&Sys.UI.DomElement.setLocation(t,e,n),this._ensureHighlightedIndex(),this._ensureScrollTop(),t.style.visibility="visible"},_popupHiding:function(){this._highlightSuggestedItem=!1;var t=this.get_optionListControl().style;t.display="none",t.visibility="hidden"},_onButtonClick:function(t){return Sys.Extended.UI.ComboBox.IsOpen(this),this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.Simple?this._popupBehavior.show():this._popupBehavior._visible?this._popupBehavior.hide():this._popupBehavior.show(),t.preventDefault(),t.stopPropagation(),!1},_onButtonBlur:function(t){1!=this.get_autoPostBack()||this._doingPostBack||this._originalSelectedIndex==this.get_selectedIndex()||(this._doingPostBack=!0,__doPostBack(this.get_element().id,""))},_onButtonKeyDown:function(t){if(t.keyCode==Sys.UI.Key.tab||16==t.keyCode)return!0;this._popupBehavior._visible||t.keyCode!=Sys.UI.Key.enter&&t.keyCode!=Sys.UI.Key.down?!this._popupBehavior._visible||t.keyCode!=Sys.UI.Key.enter&&t.keyCode!=Sys.UI.Key.up||this._popupBehavior.hide():this._popupBehavior.show(),t.stopPropagation(),t.preventDefault();var e=this.get_textBoxControl().id;return setTimeout(function(){document.getElementById(e).focus()},0),!1},_onButtonKeyPress:function(t){return t.charCode==Sys.UI.Key.tab||16==t.charCode||(t.stopPropagation(),t.preventDefault(),!1)},_onListMouseWheel:function(t){var e;return e="undefined"==typeof t.rawEvent.wheelDelta?t.rawEvent.detail>=1?1:-1:t.rawEvent.wheelDelta>1?-1:1,this.get_optionListControl().scrollTop+=this._getOptionListItemHeight()*e,t.stopPropagation(),t.preventDefault(),!1},_onListMouseOver:function(t){var e=this.get_optionListControl();if(t.target!==e)for(var o=t.target,i=e.childNodes,n=0;n<i.length;++n)if(o===i[n]){this._highlightListItem(n,!0);break}},_onListMouseOut:function(t){this._popupBehavior._visible&&this.get_autoCompleteMode()==Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend&&this._highlightListItem(this._highlightedIndex,!1)},_onListMouseDown:function(t){var e=this.get_optionListControl();if(t.target==e||"scrollbar"==t.target.tagName)return!0;if(t.target===e)return!0;var o=(e.childNodes[this._highlightedIndex],this._optionListItems[this._highlightedIndex].text);return this.get_textBoxControl().value=o,this.set_selectedIndex(this._highlightedIndex),this._supressFocusHide=!1,this._handleTextBoxFocus(null),t.preventDefault(),t.stopPropagation(),!1},_onListClick:function(t){return t.target==this.get_optionListControl()||(t.preventDefault(),t.stopPropagation(),!1)},_onListDrag:function(t){return t.preventDefault(),t.stopPropagation(),!1},_onListSelectStart:function(t){return t.preventDefault(),t.stopPropagation(),!1},_onTextBoxClick:function(t){return this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.Simple&&this._popupBehavior.show(),t.preventDefault(),t.stopPropagation(),!1},_onTextBoxFocus:function(t){Sys.Extended.UI.ComboBox.IsOpen(this),this._handleTextBoxFocus(t)},_onTextBoxBlur:function(t){for(var e=this.get_textBoxControl().value.trim(),o=-3,i=0;i<this._optionListItems.length;i++){var n=this._optionListItems[i];if(this._isExactMatch(n.text,e)){o=i;break}}1==this._highlightSuggestedItem&&null!=this._highlightedIndex&&this._highlightedIndex>=0?(this.set_selectedIndex(this._highlightedIndex),this.get_textBoxControl().value=this._optionListItems[this.get_selectedIndex()].text):o==-3&&e.length>0&&this.get_dropDownStyle()!=Sys.Extended.UI.ComboBoxStyle.DropDownList?this.set_selectedIndex(-2):this._optionListItems.length<1&&(""==e||this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.DropDownList)?(this.set_selectedIndex(-1),this.get_textBoxControl().value=""):this._optionListItems.length>=0&&o==-3&&this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.DropDownList?(this.set_selectedIndex(0),this.get_textBoxControl().value=this._optionListItems[0].text):o>=0&&(this.set_selectedIndex(o),this.get_textBoxControl().value=this._optionListItems[o].text),this._popupBehavior.hide(),1!=this.get_autoPostBack()||this._doingPostBack||this._originalSelectedIndex==this.get_selectedIndex()||(this._doingPostBack=!0,__doPostBack(this.get_element().id,""))},_onTextBoxKeyDown:function(t){var e=this._handleEnterKey(t);if(null!=e)return e;this._handleArrowKey(t);var o=this._handleErasureKeys(t);return null==o||o},_onTextBoxKeyPress:function(t){var e=this._handleEnterKey(t);if(null!=e)return e;var o=this._handleArrowKey(t);if(null!=o)return o;var i=this._handleNonCharacterKey(t);if(null!=i)return i;if(this.get_dropDownStyle()!=Sys.Extended.UI.ComboBoxStyle.Simple||this._popupBehavior._visible||this._popupBehavior.show(),this.get_selectedIndex()==-1&&this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.DropDownList&&0==this._optionListItems.length)return this.get_textBoxControl().value="",t.preventDefault(),t.stopPropagation(),!1;var n=this._getTextSelectionInfo(this.get_textBoxControl(),t),s=n.selectionStart,l=n.selectionEnd,h=n.selectionPrefix+n.typedCharacter+n.selectionText.substring(1)+n.selectionSuffix,r=n.selectionPrefix+n.typedCharacter,d=this.get_textBoxControl().maxLength;d<0&&(d=Number.MAX_VALUE),r.length>d&&(r=r.substring(0,this.get_textBoxControl().maxLength));var a=this._suggestIndex(h,r);this.get_autoCompleteMode()!=Sys.Extended.UI.ComboBoxAutoCompleteMode.Suggest&&this.get_autoCompleteMode()!=Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend||(this._highlightSuggestedItem=!0,this._popupBehavior._visible||this._popupBehavior.show()),a>=0?this.get_autoCompleteMode()==Sys.Extended.UI.ComboBoxAutoCompleteMode.Append||this.get_autoCompleteMode()==Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend?(this.get_textBoxControl().value=this._optionListItems[a].text,s=n.selectionStart+1,l=this.get_textBoxControl().value.length):(this.get_textBoxControl().value=this._optionListItems[a].text.substring(0,r.length),s=this.get_textBoxControl().value.length,l=this.get_textBoxControl().value.length):this.get_dropDownStyle()!=Sys.Extended.UI.ComboBoxStyle.Simple&&this.get_dropDownStyle()!=Sys.Extended.UI.ComboBoxStyle.DropDown||(this.get_textBoxControl().value=r,s=r.length,l=r.length);var u=this._handleErasureKeys(t);return null!=u?u:(this._ensureHighlightedIndex(),this._ensureScrollTop(),this._setTextSelectionRange(this.get_textBoxControl(),s,l),t.preventDefault(),t.stopPropagation(),!1)},_onDocumentClick:function(t){this._popupBehavior._visible&&this._popupBehavior.hide()},_onDocumentMouseWheel:function(t){return this._popupBehavior&&this._popupBehavior.hide(),!0},_handleTextBoxFocus:function(t){!this._supressFocusHide&&this._popupBehavior._visible&&(this._popupBehavior.hide(),this._supressFocusHide=!0,this.get_autoPostBack()&&!this._doingPostBack&&this._originalSelectedIndex!=this.get_selectedIndex()&&(this._doingPostBack=!0,__doPostBack(this.get_element().id,""))),this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.Simple&&this._popupBehavior.show(),this._setTextSelectionRange(this.get_textBoxControl(),0,this.get_textBoxControl().value.length),null!=t&&(t.preventDefault(),t.stopPropagation())},_highlightListItem:function(t,e){if(void 0==t||t<0)return void(void 0!=this._highlightedIndex&&this._highlightedIndex>=0&&this._highlightListItem(this._highlightedIndex,!1));var o=this.get_optionListControl().childNodes,i=o[t];if(1==e){if(this._highlightedIndex==t)return;t>=0&&(void 0==this.get_listItemHoverCssClass()||""==this.get_listItemHoverCssClass()?(i.style.backgroundColor="Highlight",i.style.color="HighlightText"):i.className=this.get_listItemHoverCssClass()),null!=this._highlightedIndex&&this._highlightedIndex!=t&&this._highlightedIndex>=0&&this._highlightListItem(this._highlightedIndex,!1),this._highlightedIndex=t}else void 0==this.get_listItemHoverCssClass()||""==this.get_listItemHoverCssClass()?(i.style.backgroundColor="",i.style.color=""):i.className="",t==this._highlightedIndex&&(this._highlightedIndex=-1)},_suggestIndex:function(t,e){for(var o=-1,i=!1,n=!1,s=0;s<this._optionListItems.length;s++)if(itemText=this._optionListItems[s].text,!(itemText.length<1)&&itemText.substring(0,1).toLowerCase()==e.substring(0,1).toLowerCase()){var l=itemText.substring(0,t.length);if(n=l==t,n||this.get_caseSensitive()||(n=l.toLowerCase()==t.toLowerCase()),n){o=s;break}if(!i){var h=itemText.substring(0,e.length);i=h==e,i||this.get_caseSensitive()||(i=h.toLowerCase()==e.toLowerCase()),i&&(o=s)}}return o},_getKeyboardCode:function(t){return"keypress"==t.type?t.charCode:"keydown"==t.type?t.keyCode:void 0},_handleArrowKey:function(t){if(1==t.shiftKey)return null;var e=this._getKeyboardCode(t);if(e==Sys.UI.Key.up||e==Sys.UI.Key.down){this._popupBehavior._visible||(this._popupBehavior.show(),this._highlightedIndex=this._highlightedIndex||-1);var o=e-39;if(o==-1&&this._highlightedIndex>0||1==o&&this._highlightedIndex<this._optionListItems.length-1){var i=this._highlightedIndex+o;this.get_textBoxControl().value=this._optionListItems[i].text,this._highlightListItem(i,!0),this.set_selectedIndex(i),this._ensureScrollTop()}return"keypress"!=t.type||(t.preventDefault(),t.stopPropagation(),!1)}return null},_handleEnterKey:function(t){var e=this._getKeyboardCode(t);return e==Sys.UI.Key.enter?this._popupBehavior._visible?(this._highlightedIndex>=0&&(this.get_textBoxControl().value=this._optionListItems[this._highlightedIndex].text,this.set_selectedIndex(this._highlightedIndex),this.get_autoPostBack()&&__doPostBack(this.get_element().id,"")),this._popupBehavior.hide(),t.preventDefault(),t.stopPropagation(),!1):this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.Simple||this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.DropDown||(this._highlightedIndex==this.get_selectedIndex()||(t.preventDefault(),t.stopPropagation(),!1)):null},_handleErasureKeys:function(t){var e=this._getKeyboardCode(t),o=e==Sys.UI.Key.backspace,i=e==Sys.UI.Key.del;if("undefined"==typeof window.event&&"keypress"==t.type&&(i=46==t.rawEvent.keyCode),o||i){var n,s,l=this._getTextSelectionInfo(this.get_textBoxControl(),t);if(l.selectionStart<l.selectionEnd)this.get_textBoxControl().value=l.selectionPrefix+l.selectionSuffix,n=l.selectionStart,s=l.selectionStart;else if(l.selectionStart==l.selectionEnd){var h;if(o&&l.selectionStart>0){var r=1;8==l.selectionPrefix.charCodeAt(l.selectionPrefix.length-1)&&(r=2),h=l.selectionPrefix.substr(0,l.selectionPrefix.length-r),h+=l.selectionSuffix,this.get_textBoxControl().value=h,n=l.selectionStart-1,s=l.selectionStart-1}else i&&l.selectionStart<l.textBoxValue.length&&(h=l.selectionSuffix,h=l.selectionPrefix+h.substr(1,l.selectionSuffix.length-1),this.get_textBoxControl().value=h,n=l.selectionStart,s=l.selectionStart,this._setTextSelectionRange(this.get_textBoxControl(),l.selectionStart,l.selectionStart))}if(this._ensureHighlightedIndex(),this._ensureScrollTop(),this._setTextSelectionRange(this.get_textBoxControl(),n,s),(this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.Simple||this.get_dropDownStyle()==Sys.Extended.UI.ComboBoxStyle.DropDown)&&(this.get_autoCompleteMode()==Sys.Extended.UI.ComboBoxAutoCompleteMode.Suggest||this.get_autoCompleteMode()==Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend)&&null!=this._highlightedIndex&&this._highlightedIndex>=0){var d=this._isExactMatch(this._optionListItems[this._highlightedIndex].text,this.get_textBoxControl().value);d||this._highlightListItem(this._highlightedIndex,!1)}return t.preventDefault(),t.stopPropagation(),!1}return null},_handleNonCharacterKey:function(t){var e=this._getKeyboardCode(t),o=e==Sys.UI.Key.backspace,i=e==Sys.UI.Key.del;return"keypress"==t.type&&(i=46==t.rawEvent.code),o||i?null:this._isNonCharacterKey(t)?e!=Sys.UI.Key.esc||(this._popupBehavior.hide(),this.get_textBoxControl().blur(),t.preventDefault(),t.stopPropagation(),!1):null},_isNonCharacterKey:function(t){var e=this._getKeyboardCode(t);if(e==Sys.UI.Key.enter||e==Sys.UI.Key.esc)return!0;if(Sys.Browser.agent==Sys.Browser.Safari&&Sys.Browser.version<500){if(8==e||9==e||63272==e||63276==e||63277==e||63275==e||63273==e||63234==e||63235==e||e>=63236&&e<=63243||63248==e)return!0}else if(Sys.Browser.agent!=Sys.Browser.InternetExplorer)if(8==e||9==e||33==e||34==e||35==e||36==e||37==e||39==e||45==e||46==e){if(!t.shiftKey)return!0}else{if(145==e)return!0;if(19==e)return!0;if(Sys.Browser.agent==Sys.Browser.Opera){if(0==e||16==e||17==e)return!0}else if(Sys.Browser.agent==Sys.Browser.Firefox&&(91==e||92==e||93==e))return!0}else if(Sys.Browser.agent==Sys.Browser.InternetExplorer&&46==e)return!0;return!1},_ensureScrollTop:function(){var t=this.get_optionListControl();if(this._highlightedIndex>=0){var e=this._getOptionListItemHeight(),o=e*this._highlightedIndex,i=t.scrollTop+t.clientHeight;(o<=t.scrollTop||o>=i)&&(t.scrollTop=this._highlightedIndex*e)}},_ensureSelectedIndex:function(){var t=this.get_hiddenFieldControl().value;""==t&&(t=this._optionListItems.length>0?0:-1,this.get_hiddenFieldControl().value=t.toString()),null==this._originalSelectedIndex&&(this._originalSelectedIndex=parseInt(t))},_ensureHighlightedIndex:function(){var t=this.get_textBoxControl().value;if(!(null!=this._highlightedIndex&&this._highlightedIndex>=0&&this._isExactMatch(this._optionListItems[this._highlightedIndex].text,t))){for(var e=-1,o=!1,i=0;i<this._optionListItems.length;i++){var n=this._optionListItems[i].text;if(this._isExactMatch(n,t)){this._highlightListItem(i,!0),o=!0;break}e<0&&this._highlightSuggestedItem&&this._isPrefixMatch(n,t)&&(e=i)}o||this._highlightListItem(e,!0)}},_isExactMatch:function(t,e){var o=t==e;return o||this.get_caseSensitive()||(o=t.toLowerCase()==e.toLowerCase()),o},_isPrefixMatch:function(t,e){return this._isExactMatch(t.substring(0,e.length),e)},_setTextSelectionRange:function(t,e,o){var i=this._getTextSelectionStrategy();if(i==Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft){var n=t.createTextRange();n.collapse(!0),n.moveEnd("character",o),n.moveStart("character",e),n.select(),Sys.Browser.agent==Sys.Browser.Opera&&t.setSelectionRange(e,o)}else i==Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C&&t.setSelectionRange(e,o)},_getTextSelectionStrategy:function(){return null==this._textSelectionStrategy&&(Sys.Browser.agent===Sys.Browser.InternetExplorer&&Sys.Browser.version<=8?this._textSelectionStrategy=Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft:this.get_textBoxControl().setSelectionRange?this._textSelectionStrategy=Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C:this._textSelectionStrategy=Sys.Extended.UI.ComboBoxTextSelectionStrategy.Unknown),this._textSelectionStrategy},_getTextSelectionInfo:function(t,e){var o=new Object;if(o.strategy=this._getTextSelectionStrategy(),o.strategy==Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft){var i=document.selection.createRange();for(o.selectionStart=0,o.selectionEnd=t.value.length;0!=i.moveStart("character",-1);)o.selectionStart++;for(;0!=i.moveEnd("character",1);)o.selectionEnd--}else o.strategy==Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C&&(o.selectionStart=t.selectionStart,o.selectionEnd=t.selectionEnd);return o.typedCharacter=String.fromCharCode(e.rawEvent.charCode||e.rawEvent.keyCode),o.textBoxValue=t.value,o.selectionPrefix=o.textBoxValue.length>=o.selectionStart?o.textBoxValue.substring(0,o.selectionStart):"",o.selectionText=o.textBoxValue.length>=o.selectionEnd?o.textBoxValue.substring(o.selectionStart,o.selectionEnd):"",o.selectionSuffix=o.textBoxValue.length>=o.selectionEnd?o.textBoxValue.substring(o.selectionEnd,o.textBoxValue.length):"",o.selectionTextFirst=o.selectionText.substring(0,1),o},_getOptionListItemHeight:function(){var t=this.get_optionListControl();return null==this._optionListItemHeight&&t.scrollHeight>0?this._optionListItemHeight=Math.round(t.scrollHeight/this._optionListItems.length):Sys.Browser.agent===Sys.Browser.InternetExplorer&&Sys.Browser.version<7&&Math.round(t.scrollHeight/this._optionListItems.length)<this._optionListItemHeight&&(this._optionListItemHeight=Math.round(t.scrollHeight/this._optionListItems.length)),this._optionListItemHeight},_getOptionListBounds:function(){var t={width:this._getOptionListWidth(),height:this._getOptionListHeight()};return t},_getOptionListHeight:function(){return(null==this._optionListHeight||this._getOptionListItemHeight()*this._optionListItems.length<this._optionListHeight)&&(this._optionListHeight=this._getOptionListItemHeight()*this._optionListItems.length),this._optionListHeight<0&&(this._optionListHeight=0),this._optionListHeight},_getOptionListWidth:function(){var t=this.get_optionListControl();if(null==this._optionListWidth){var e=1,o=1,i=0,n=0,s=t.style;s.overflow="auto";var l=this.get_comboTableControl().offsetWidth;l-=e+o,l<0&&(l=0);var h=s.width;s.width=l+"px",this.get_comboTableControl().offsetWidth<t.scrollWidth&&(l=t.scrollWidth+n+i),s.overflow="hidden",s.width=h,this._optionListWidth=l}return this._optionListWidth<0&&(this._optionListWidth=0),this._optionListWidth},_getWindowBounds:function(){var t={x:this._getScrollLeft(),y:this._getScrollTop(),width:this._getWindowWidth(),height:this._getWindowHeight()};return t},_getWindowHeight:function(){var t=0;return"number"==typeof window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),t},_getWindowWidth:function(){var t=0;return"number"==typeof window.innerWidth?t=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?t=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(t=document.body.clientWidth),t},_getScrollTop:function(){var t=0;return"number"==typeof window.pageYOffset&&(t=window.pageYOffset),document.body&&document.body.scrollTop?t=document.body.scrollTop:document.documentElement&&document.documentElement.scrollTop&&(t=document.documentElement.scrollTop),t},_getScrollLeft:function(){var t=0;return"number"==typeof window.pageXOffset?t=window.pageXOffset:document.body&&document.body.scrollLeft?t=document.body.scrollLeft:document.documentElement&&document.documentElement.scrollLeft&&(t=document.documentElement.scrollLeft),t},get_comboTableControl:function(){return this._comboTableControl},set_comboTableControl:function(t){this._comboTableControl!==t&&(this._comboTableControl=t,this.raisePropertyChanged("comboTableControl"))},get_textBoxControl:function(){return this._textBoxControl},set_textBoxControl:function(t){this._textBoxControl!==t&&(this._textBoxControl=t,this.raisePropertyChanged("textBoxControl"))},get_buttonControl:function(){return this._buttonControl},set_buttonControl:function(t){this._buttonControl!==t&&(this._buttonControl=t,this.raisePropertyChanged("buttonControl"))},get_optionListControl:function(){return this._optionListControl},set_optionListControl:function(t){this._optionListControl!==t&&(this._optionListControl=t,this.raisePropertyChanged("optionListControl"))},get_hiddenFieldControl:function(){return this._hiddenFieldControl},set_hiddenFieldControl:function(t){this._hiddenFieldControl!==t&&(this._hiddenFieldControl=t,this.raisePropertyChanged("hiddenFieldControl"))},get_selectedIndex:function(){this._ensureSelectedIndex();var t=this.get_hiddenFieldControl().value;return parseInt(t)},set_selectedIndex:function(t){if(this.get_hiddenFieldControl().value!==t.toString()){var e=+this.get_hiddenFieldControl().value;this.get_hiddenFieldControl().value=t.toString(),this._ensureSelectedIndex(),this.raisePropertyChanged("selectedIndex"),this.raise_selectedIndexChanged({oldIndex:e,newIndex:t})}},get_autoPostBack:function(){return this._autoPostBack},set_autoPostBack:function(t){this._autoPostBack!==t&&(this._autoPostBack=t,this.raisePropertyChanged("autoPostBack"))},get_autoCompleteMode:function(){return this._autoCompleteMode},set_autoCompleteMode:function(t){this._autoCompleteMode!==t&&(this._autoCompleteMode=t,this.raisePropertyChanged("autoCompleteMode"))},get_dropDownStyle:function(){return this._dropDownStyle},set_dropDownStyle:function(t){this._dropDownStyle!==t&&(this._dropDownStyle=t,this.raisePropertyChanged("dropDownStyle"))},get_caseSensitive:function(){return this._caseSensitive},set_caseSensitive:function(t){this._caseSensitive!==t&&(this._caseSensitive=t,this.raisePropertyChanged("caseSensitive"))},get_listItemHoverCssClass:function(){return this._listItemHoverCssClass},set_listItemHoverCssClass:function(t){this._listItemHoverCssClass!==t&&(this._listItemHoverCssClass=t,this.raisePropertyChanged("listItemHoverCssClass"))},add_selectedIndexChanged:function(t){this.get_events().addHandler("selectedIndexChanged",t)},remove_selectedIndexChanged:function(t){this.get_events().removeHandler("selectedIndexChanged",t)},raise_selectedIndexChanged:function(t){var e=this.get_events().getHandler("selectedIndexChanged");e&&e(this,t)}},Sys.Extended.UI.ComboBox.registerClass("Sys.Extended.UI.ComboBox",Sys.UI.Control);var ComboBox_Elements=new Array;Sys.Extended.UI.ComboBox.IsOpen=function(t){for(var e=Sys.Application.getComponents(),o=0;o<e.length;o++){var i=e[o];Sys.Extended.UI.ComboBox.isInstanceOfType(i)&&i!=t&&i._popupBehavior._visible&&i._popupBehavior.hide()}}; |