Files
SIG/Scripts/AjaxControlToolkit/Release/CascadingDropDown.js
JORGE LUIS CAUDILLO ESPARZA c35cf91883 Commit inicial Ventas Productivo
2019-08-14 16:40:54 -07:00

1 line
12 KiB
JavaScript

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