1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
Type.registerNamespace("Sys.Extended.UI"),Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs=function(e,t){Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs.initializeBase(this),this._oldValue=e,this._newValue=t},Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs.prototype={get_oldValue:function(){return this._oldValue},get_newValue:function(){return this._newValue}},Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs.registerClass("Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs",Sys.EventArgs),Sys.Extended.UI.CascadingDropDownBehavior=function(e){Sys.Extended.UI.CascadingDropDownBehavior.initializeBase(this,[e]),this._parentControlID=null,this._category=null,this._promptText=null,this._loadingText=null,this._promptValue=null,this._emptyValue=null,this._emptyText=null,this._servicePath=location.pathname,this._serviceMethod=null,this._contextKey=null,this._useContextKey=!1,this._useHttpGet=!1,this._enableAtLoading=!1,this._clearSelectedItemOnParentChange=!1,this._parentElement=null,this._changeHandler=null,this._parentChangeHandler=null,this._lastParentValues=null,this._selectedValue=null,this._actualDisabledStatus=!1},Sys.Extended.UI.CascadingDropDownBehavior.prototype={initialize:function(){Sys.Extended.UI.CascadingDropDownBehavior.callBaseMethod(this,"initialize"),$common.prepareHiddenElementForATDeviceUpdate();var e=this.get_element();this._actualDisabledStatus=e.disabled,this._clearItems(),e.CascadingDropDownCategory=this._category,this._changeHandler=Function.createDelegate(this,this._onChange),$addHandler(e,"change",this._changeHandler),this._parentControlID&&(this._parentElement=$get(this._parentControlID),this._parentElement||Sys.Debug.fail(String.format(Sys.Extended.UI.Resources.CascadingDropDown_NoParentElement,this._parentControlID)),this._parentElement&&(e.CascadingDropDownParentControlID=this._parentControlID,this._parentChangeHandler=Function.createDelegate(this,this._onParentChange),$addHandler(this._parentElement,"change",this._parentChangeHandler),this._parentElement.childDropDown||(this._parentElement.childDropDown=new Array),this._parentElement.childDropDown.push(this))),this._onParentChange(null,!0);var t=this;setTimeout(function(){t._actualDisabledStatus&&(e.disabled=t._actualDisabledStatus)},50)},dispose:function(){var e=this.get_element();this._changeHandler&&($removeHandler(e,"change",this._changeHandler),this._changeHandler=null),this._parentChangeHandler&&(this._parentElement&&$removeHandler(this._parentElement,"change",this._parentChangeHandler),this._parentChangeHandler=null),Sys.Extended.UI.CascadingDropDownBehavior.callBaseMethod(this,"dispose")},_clearItems:function(){var e=this.get_element();if(null!=e&&null!=e.options)for(;0<e.options.length;)e.remove(0)},_isPopulated:function(){var e=this.get_element().options.length;return this._promptText?e>1:e>0},_setOptions:function(e,t,n){if(this.get_isInitialized()){var s=this.get_element();this._clearItems();var i,a="";n&&this._loadingText?(i=this._loadingText,this._selectedValue&&(a=this._selectedValue)):!n&&e&&0==e.length&&null!=this._emptyText?(i=this._emptyText,this._emptyValue&&(a=this._emptyValue)):this._promptText&&(i=this._promptText,this._promptValue&&(a=this._promptValue));var r;i&&(r=new Option(i,a),s.options[s.options.length]=r);var o=null,l=-1;if(e){for(var h=0;h<e.length;h++){var d=e[h],_=d.name,c=d.value,p=d.optionTitle;d.isDefaultValue&&(this.set_selectedValue(c,_,p),l=h,this._promptText&&l++),r=new Option(_,c),c==this._selectedValue&&(o=r),p&&r.setAttribute("title",p),s.options[s.options.length]=r}o&&(o.selected=!0)}if(o?this.set_selectedValue(s.options[s.selectedIndex].value,s.options[s.selectedIndex].text):o||l==-1?t||o||n||this._promptText||!(s.options.length>0)?t||o||n||this.set_selectedValue("",""):this.set_selectedValue(s.options[0].value,s.options[0].text):(s.options[l].selected=!0,this.set_selectedValue(s.options[l].value,s.options[l].text)),s.childDropDown&&!n)for(var h=0;h<s.childDropDown.length;h++)s.childDropDown[h]._onParentChange();else if(e&&Sys.Browser.agent!==Sys.Browser.Firefox&&Sys.Browser.agent!==Sys.Browser.Safari&&Sys.Browser.agent!==Sys.Browser.Opera)if(document.createEvent){var u=document.createEvent("HTMLEvents");u.initEvent("change",!0,!1),this.get_element().dispatchEvent(u)}else document.createEventObject&&this.get_element().fireEvent("onchange");this._enableAtLoading||((this._loadingText||this._promptText||this._emptyText)&&(s.disabled=!e||0==e.length),this._actualDisabledStatus&&(s.disabled=this._actualDisabledStatus))}},_onChange:function(){if(this._isPopulated()){var e=this.get_element();-1==e.selectedIndex||this._promptText&&0==e.selectedIndex?this.set_selectedValue("",""):this.set_selectedValue(e.options[e.selectedIndex].value,e.options[e.selectedIndex].text,e.options[e.selectedIndex].title)}},_onParentChange:function(e,t){this.get_clearSelectedItemOnParentChange()&&this.set_selectedValue("","");for(var n=(this.get_element(),""),s=this._parentControlID;s;){var i=$get(s);if(i&&-1!=i.selectedIndex){var a=i.options[i.selectedIndex].value;if(a&&""!=a){n=i.CascadingDropDownCategory+":"+a+";"+n,s=i.CascadingDropDownParentControlID;continue}}break}if(""==n||this._lastParentValues!=n){if(this._lastParentValues=n,""==n&&this._parentControlID)return void this._setOptions(null,t);if(this._setOptions(null,t,!0),this._servicePath&&this._serviceMethod){var r=new Sys.CancelEventArgs;if(this.raise_populating(r),r.get_cancel())return;var o={knownCategoryValues:n,category:this._category};this._useContextKey&&(o.contextKey=this._contextKey),Sys.Net.WebServiceProxy.invoke(this._servicePath,this._serviceMethod,this._useHttpGet,o,Function.createDelegate(this,this._onMethodComplete),Function.createDelegate(this,this._onMethodError)),$common.updateFormToRefreshATDeviceBuffer()}}},_onMethodComplete:function(e,t,n){this._setOptions(e),this.raise_populated(Sys.EventArgs.Empty)},_onMethodError:function(e,t,n){e.get_timedOut()?this._setOptions([this._makeNameValueObject(Sys.Extended.UI.Resources.CascadingDropDown_MethodTimeout)]):this._setOptions([this._makeNameValueObject(String.format(Sys.Extended.UI.Resources.CascadingDropDown_MethodError,e.get_statusCode()))])},_makeNameValueObject:function(e){return{name:e,value:e}},get_parentControlID:function(){return this._parentControlID},set_parentControlID:function(e){this._parentControlID!=e&&(this._parentControlID=e,this.raisePropertyChanged("parentControlID"))},get_ParentControlID:function(){return Sys.Extended.Deprecated("get_ParentControlID","get_parentControlID"),this.get_parentControlID()},set_ParentControlID:function(e){Sys.Extended.Deprecated("set_ParentControlID","set_parentControlID"),this.set_parentControlID(e)},get_category:function(){return this._category},set_category:function(e){this._category!=e&&(this._category=e,this.raisePropertyChanged("category"))},get_Category:function(){return Sys.Extended.Deprecated("get_Category","get_category"),this.get_category()},set_Category:function(e){Sys.Extended.Deprecated("set_Category","set_category"),this.set_category(e)},get_promptText:function(){return this._promptText},set_promptText:function(e){this._promptText!=e&&(this._promptText=e,this.raisePropertyChanged("promptText"))},get_PromptText:function(){return Sys.Extended.Deprecated("get_PromptText","get_promptText"),this.get_promptText()},set_PromptText:function(e){Sys.Extended.Deprecated("set_PromptText","set_promptText"),this.set_promptText(e)},get_promptValue:function(){return this._promptValue},set_promptValue:function(e){this._promptValue!=e&&(this._promptValue=e,this.raisePropertyChanged("promptValue"))},get_PromptValue:function(){return Sys.Extended.Deprecated("get_PromptValue","get_promptValue"),this.get_promptValue()},set_PromptValue:function(e){Sys.Extended.Deprecated("set_PromptValue","set_promptValue"),this.set_promptValue(e)},get_emptyText:function(){return this._emptyText},set_emptyText:function(e){this._emptyText!=e&&(this._emptyText=e,this.raisePropertyChanged("emptyText"))},get_EmptyText:function(){return Sys.Extended.Deprecated("get_EmptyText","get_emptyText"),this.get_emptyText()},set_EmptyText:function(e){Sys.Extended.Deprecated("set_EmptyText","set_emptyText"),this.set_emptyText(e)},get_emptyValue:function(){return this._emptyValue},set_emptyValue:function(e){this._emptyValue!=e&&(this._emptyValue=e,this.raisePropertyChanged("emptyValue"))},get_EmptyValue:function(){return Sys.Extended.Deprecated("get_EmptyValue","get_emptyValue"),this.get_emptyValue()},set_EmptyValue:function(e){Sys.Extended.Deprecated("set_EmptyValue","set_emptyValue"),this.set_emptyValue(e)},get_loadingText:function(){return this._loadingText},set_loadingText:function(e){this._loadingText!=e&&(this._loadingText=e,this.raisePropertyChanged("loadingText"))},get_LoadingText:function(){return Sys.Extended.Deprecated("get_LoadingText","get_loadingText"),this.get_loadingText()},set_LoadingText:function(e){Sys.Extended.Deprecated("set_LoadingText","set_loadingText"),this.set_loadingText(e)},get_selectedValue:function(){return this._selectedValue},set_selectedValue:function(e,t,n){if(this._selectedValue!=e){if(!t){var s=e.indexOf(":::");-1!=s&&(t=e.slice(s+3),e=e.slice(0,s),s=t.indexOf(":::"),-1!=s&&(n=t.slice(s+3),t=t.slice(0,s)))}var i=this._selectedValue;this._selectedValue=e,this.raisePropertyChanged("selectedValue"),this.raise_selectionChanged(new Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs(i,e))}Sys.Extended.UI.CascadingDropDownBehavior.callBaseMethod(this,"set_ClientState",[this._selectedValue+":::"+t+":::"+(n?":::"+n:"")])},get_SelectedValue:function(){return Sys.Extended.Deprecated("get_SelectedValue","get_selectedValue"),this.get_selectedValue()},set_SelectedValue:function(e,t,n){Sys.Extended.Deprecated("set_SelectedValue(value, text, title)","set_selectedValue(value, text, title)"),this.set_selectedValue(e,t,n)},get_servicePath:function(){return this._servicePath},set_servicePath:function(e){this._servicePath!=e&&(this._servicePath=e,this.raisePropertyChanged("servicePath"))},get_ServicePath:function(){return Sys.Extended.Deprecated("get_ServicePath","get_servicePath"),this.get_servicePath()},set_ServicePath:function(e){Sys.Extended.Deprecated("set_ServicePath","set_servicePath"),this.set_servicePath(e)},get_serviceMethod:function(){return this._serviceMethod},set_serviceMethod:function(e){this._serviceMethod!=e&&(this._serviceMethod=e,this.raisePropertyChanged("serviceMethod"))},get_ServiceMethod:function(){return Sys.Extended.Deprecated("get_ServiceMethod","get_serviceMethod"),this.get_serviceMethod()},set_ServiceMethod:function(e){Sys.Extended.Deprecated("set_ServiceMethod","set_serviceMethod"),this.set_serviceMethod(e)},get_contextKey:function(){return this._contextKey},set_contextKey:function(e){this._contextKey!=e&&(this._contextKey=e,this.set_useContextKey(!0),this.raisePropertyChanged("contextKey"))},get_useContextKey:function(){return this._useContextKey},set_useContextKey:function(e){this._useContextKey!=e&&(this._useContextKey=e,this.raisePropertyChanged("useContextKey"))},get_useHttpGet:function(){return this._useHttpGet},set_useHttpGet:function(e){this._useHttpGet!=e&&(this._useHttpGet=e,this.raisePropertyChanged("useHttpGet"))},get_enableAtLoading:function(){return this._enableAtLoading},set_enableAtLoading:function(e){this._enableAtLoading!=e&&(this._enableAtLoading=e,this.raisePropertyChanged("enableAtLoading"))},get_clearSelectedItemOnParentChange:function(){return this._clearSelectedItemOnParentChange},set_clearSelectedItemOnParentChange:function(e){this._clearSelectedItemOnParentChange!=e&&(this._clearSelectedItemOnParentChange=e,this.raisePropertyChanged("clearSelectedItemOnParentChange"))},add_selectionChanged:function(e){this.get_events().addHandler("selectionChanged",e)},remove_selectionChanged:function(e){this.get_events().removeHandler("selectionChanged",e)},raise_selectionChanged:function(e){var t=this.get_events().getHandler("selectionChanged");t&&t(this,e)},raiseSelectionChanged:function(e){Sys.Extended.Deprecated("raiseSelectionChanged(eventArgs)","raise_selectionChanged(eventArgs)"),this.raise_selectionChanged(e)},add_populating:function(e){this.get_events().addHandler("populating",e)},remove_populating:function(e){this.get_events().removeHandler("populating",e)},raise_populating:function(e){var t=this.get_events().getHandler("populating");t&&t(this,e)},raisePopulating:function(e){Sys.Extended.Deprecated("raisePopulating(eventArgs)","raise_populating(eventArgs)"),this.raise_populating(e)},add_populated:function(e){this.get_events().addHandler("populated",e)},remove_populated:function(e){this.get_events().removeHandler("populated",e)},raise_populated:function(e){var t=this.get_events().getHandler("populated");t&&t(this,e)},raisePopulated:function(e){Sys.Extended.Deprecated("raisePopulated(eventArgs)","raise_populated(eventArgs)"),this.raise_populated(e)}},Sys.Extended.UI.CascadingDropDownBehavior.registerClass("Sys.Extended.UI.CascadingDropDownBehavior",Sys.Extended.UI.BehaviorBase); |