%PDF- %PDF-
Direktori : /home/bitrix/www/bitrix/components/bitrix/sale.order.ajax/templates/old_version/ |
Current File : //home/bitrix/www/bitrix/components/bitrix/sale.order.ajax/templates/old_version/script.min.js |
BX.saleOrderAjax={BXCallAllowed:false,options:{},indexCache:{},controls:{},modes:{},properties:{},init:function(e){var t=this;this.options=e;window.submitFormProxy=BX.proxy(function(){t.submitFormProxy.apply(t,arguments)},this);BX(function(){t.initDeferredControl()});BX(function(){t.BXCallAllowed=true});this.controls.scope=BX("bx-soa-order");BX.bindDelegate(this.controls.scope,"click",{className:"-bx-popup-set-mode-add-loc"},function(){var e=BX.create("input",{attrs:{type:"hidden",name:"PERMANENT_MODE_STEPS",value:"1"}});BX.prepend(e,BX("bx-soa-order"));t.BXCallAllowed=false;BX.Sale.OrderAjaxComponent.sendRequest()})},cleanUp:function(){for(var e in this.properties){if(this.properties.hasOwnProperty(e)){if(typeof this.properties[e].input!="undefined"){BX.unbindAll(this.properties[e].input);this.properties[e].input=null}if(typeof this.properties[e].control!="undefined")BX.unbindAll(this.properties[e].control)}}this.properties={}},addPropertyDesc:function(e){this.properties[e.id]=e.attributes;this.properties[e.id].id=e.id},initDeferredControl:function(){var e=this,t,i,o,r,n,s,p,a,l;if(typeof window.BX.locationsDeferred!="undefined"){this.BXCallAllowed=false;for(t in window.BX.locationsDeferred){window.BX.locationsDeferred[t].call(this);window.BX.locationsDeferred[t]=null;delete window.BX.locationsDeferred[t];this.properties[t].control=window.BX.locationSelectors[t];delete window.BX.locationSelectors[t]}}for(t in this.properties){if(this.properties[t].isZip){i=this.controls.scope.querySelector('[data-property-id-row="'+t+'"]');if(BX.type.isElementNode(i)){o=i.querySelector('input[type="text"]');if(BX.type.isElementNode(o)){this.properties[t].input=o;r=false;for(n in this.properties){if(this.properties[n].type=="LOCATION"){r=n;break}}if(r!==false){BX.bindDebouncedChange(o,function(t){o=null;i=null;if(BX.type.isNotEmptyString(t)&&/^\s*\d+\s*$/.test(t)&&t.length>3){e.getLocationByZip(t,function(t){e.properties[r].control.setValueByLocationId(t)},function(){try{e.properties[r].control.clearSelected(locationId)}catch(t){}})}})}}}}if(this.properties[t].type=="LOCATION"){if(typeof this.properties[t].control!="undefined"){s=this.properties[t].control;p=s.getSysCode();if(typeof this.properties[t].altLocationPropId!="undefined"){if(p=="sls"){s.replaceTemplate("nothing-found",this.options.messages.notFoundPrompt)}if(p=="slst"){(function(t,i){i.setOption("pseudoValues",["other"]);i.bindEvent("control-before-display-page",function(t){i=null;var o=t.getParentValue();if(o==this.getOption("rootNodeValue")||!this.checkCanSelectItem(o))return;var r=t.getControl();if(typeof r.vars.cache.nodes["other"]=="undefined"){r.fillCache([{CODE:"other",DISPLAY:e.options.messages.otherLocation,IS_PARENT:false,VALUE:"other"}],{modifyOrigin:true,modifyOriginPosition:"prepend"})}});a=BX("LOCATION_ALT_PROP_DISPLAY_MANUAL["+parseInt(t)+"]");i.bindEvent("after-select-real-value",function(){if(BX.type.isDomNode(a))a.value="0"});i.bindEvent("after-select-pseudo-value",function(){if(BX.type.isDomNode(a))a.value="1"});i.bindEvent("before-set-value",function(){if(BX.type.isDomNode(a))a.value="0"});if(BX.type.isDomNode(a)&&a.value=="1"){l=i.getAdapterAtPosition(i.getStackSize()-1);if(typeof l!="undefined"&&l!==null)l.setValuePair("other",e.options.messages.otherLocation)}})(t,s)}}}}}this.BXCallAllowed=true;if(BX.Sale.OrderAjaxComponent)BX.Sale.OrderAjaxComponent.locationsCompletion()},checkMode:function(e,t){if(t=="altLocationChoosen"){if(this.checkAbility(e,"canHaveAltLocation")){var i=this.getInputByPropId(this.properties[e].altLocationPropId);var o=this.properties[e].altLocationPropId;if(i!==false&&i.value.length>0&&!i.disabled&&this.properties[o].valueSource!="default"){return true}}}return false},checkAbility:function(e,t){if(typeof this.properties[e]=="undefined")this.properties[e]={};if(typeof this.properties[e].abilities=="undefined")this.properties[e].abilities={};if(typeof this.properties[e].abilities!="undefined"&&this.properties[e].abilities[t])return true;if(t=="canHaveAltLocation"){if(this.properties[e].type=="LOCATION"){if(typeof this.properties[e].altLocationPropId!="undefined"&&typeof this.properties[this.properties[e].altLocationPropId]){var i=this.properties[e].altLocationPropId;if(typeof this.properties[e].control!="undefined"&&this.properties[e].control.getSysCode()=="slst"){if(this.getInputByPropId(i)!==false){this.properties[e].abilities[t]=true;return true}}}}}return false},getInputByPropId:function(e){if(typeof this.properties[e].input!="undefined")return this.properties[e].input;var t=this.getRowByPropId(e);if(BX.type.isElementNode(t)){var i=t.querySelector('input[type="text"]');if(BX.type.isElementNode(i)){this.properties[e].input=i;return i}}return false},getRowByPropId:function(e){if(typeof this.properties[e].row!="undefined")return this.properties[e].row;var t=this.controls.scope.querySelector('[data-property-id-row="'+e+'"]');if(BX.type.isElementNode(t)){this.properties[e].row=t;return t}return false},getAltLocPropByRealLocProp:function(e){if(typeof this.properties[e].altLocationPropId!="undefined")return this.properties[this.properties[e].altLocationPropId];return false},toggleProperty:function(e,t,i){var o=this.properties[e];if(typeof o.row=="undefined")o.row=this.getRowByPropId(e);if(typeof o.input=="undefined")o.input=this.getInputByPropId(e);if(!t){if(!i)BX.hide(o.row);o.input.disabled=true}else{if(!i)BX.show(o.row);o.input.disabled=false}},submitFormProxy:function(e,t){var i=false;for(var o in this.properties){if(typeof this.properties[o].control!="undefined"&&this.properties[o].control==t){i=o;break}}if(e!="other"){if(this.BXCallAllowed){this.BXCallAllowed=false;setTimeout(function(){BX.Sale.OrderAjaxComponent.sendRequest()},20)}}},getPreviousAdapterSelectedNode:function(e,t){var i=t.getIndex();var o=e.getAdapterAtPosition(i-1);if(typeof o!=="undefined"&&o!=null){var r=o.getControl().getValue();if(typeof r!="undefined"){var n=e.getNodeByValue(r);if(typeof n!="undefined")return n;return false}}return false},getLocationByZip:function(e,t,i){if(typeof this.indexCache[e]!="undefined"){t.apply(this,[this.indexCache[e]]);return}var o;if(!(o=BX.Sale.OrderAjaxComponent.startLoader()))return;var r=this;BX.ajax({url:this.options.source,method:"post",dataType:"json",async:true,processData:true,emulateOnload:true,start:true,data:{ACT:"GET_LOC_BY_ZIP",ZIP:e},onsuccess:function(n){BX.Sale.OrderAjaxComponent.endLoader(o);if(n.result){r.indexCache[e]=n.data.ID;t.apply(r,[n.data.ID])}else i.call(r)},onfailure:function(e,t){BX.Sale.OrderAjaxComponent.endLoader(o)}})}}; //# sourceMappingURL=script.map.js