Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/ilovecveti.ru/bitrix/js/yandex.market/ui/form/ajaxreloader/ |
Upload File : |
this.BX=this.BX||{},this.BX.YandexMarket=this.BX.YandexMarket||{},this.BX.YandexMarket.Ui=this.BX.YandexMarket.Ui||{},function(e){"use strict";const t=window.YMarketJQuery||window.jQuery,r=window.BX,a=r.namespace("YandexMarket.Plugin"),i=r.namespace("YandexMarket.Utils");class n extends a.Base{initVars(){this._targets=[],this._listenValues={},this._reloadTimeout=null,this._reloadQuery=null}initialize(){this.resetValues(),this.bind()}destroy(){this.unbind(),super.destroy()}bind(){this.handleChange(!0)}unbind(){this.handleChange(!1)}handleChange(e){this.getElement("listen")[e?"on":"off"]("change",t.proxy(this.onChange,this))}onChange(e){const r=t(e.currentTarget),a=r.data("reloader-name"),i=this.fieldValue(r);if(i===this._listenValues[a])return;const n=r.data("reloader-target").split(",").map((e=>e.trim()));this._listenValues[a]=i,this.pushTargets(n),this.reloadDelayed()}resetValues(){const e=this.getElement("listen");for(let t=e.length-1;t>=0;--t){const r=e.eq(t),a=r.data("reloader-name");this._listenValues[a]=this.fieldValue(r)}}fieldValue(e){const t=this.fieldPlugin(e),r=e.data("reloaderSignificant");let a;return null!=t?(a=t.getValue(),a=this.pluginSignificant(a,r)):(a=this.rawValue(e),a=this.rawSignificant(a,r)),this.stringifyValue(a)}fieldPlugin(e){const t=this.getElement("controlCell",e).children().eq(0),r=a.manager.getInstance(t);return null==r||"function"!=typeof r.getValue?null:r}pluginSignificant(e,t){if(null==t||null==e)return e;if(Array.isArray(e))return e.map((e=>this.pluginSignificant(e,t)));if("object"!=typeof e)return e;const r={};for(const a of t.split(", "))null!=e[a]&&(r[a]=e[a]);return r}rawValue(e){return e.find("input, textarea, select").serializeArray()}rawSignificant(e,t){if(null==t)return e;const r=t.split(", "),a=[];for(const t of e)if(null!=t.name)for(const e of r)if(0===t.name.indexOf(e)){a.push(t);break}return a}stringifyValue(e){if(!Array.isArray(e))return JSON.stringify(e);const t=[];for(const r of e){const e=this.stringifyValue(r);-1===t.indexOf(e)&&t.push(e)}return t.join(", ")}pushTargets(e){for(const t of e)-1===this._targets.indexOf(t)&&this._targets.push(t)}reloadDelayed(){this.reloadCancel(),this._reloadTimeout=setTimeout((()=>{this.reload()}),this.options.reloadDelay)}reload(){this.reloadCancel(),this.resetValues(),this._reloadQuery=t.ajax({url:this.$el.attr("action"),method:"POST",data:this.reloadData(),dataType:"json"}),this._reloadQuery.then(t.proxy(this.reloadEnd,this),t.proxy(this.reloadStop,this))}reloadData(){const e=this.$el.serializeArray();return[{name:"ajaxReloader",value:"Y"},{name:"ajaxReloaderTarget",value:this._targets.join(", ")}].concat(e)}reloadEnd(e){for(const t of this._targets)null!=e[t]?this.updateTarget(t,e[t]):this.errorTarget(t,"missing data");this._targets=[]}reloadStop(e,t,r){if("abort"!==t)for(const e of this._targets)this.errorTarget(e,r||t)}reloadCancel(){null!=this._reloadTimeout&&(clearTimeout(this._reloadTimeout),this._reloadTimeout=null),null!=this._reloadQuery&&(this._reloadQuery.abort(),this._reloadQuery=null)}updateTarget(e,i){try{const n=r.processHTML(i,!0),s=t(n.HTML),l=this.targetElement(e);s.attr("style",l.attr("style")),a.manager.destroyContext(l),l.replaceWith(s),r.ajax.processScripts(n.SCRIPT),a.manager.initializeContext(s)}catch(t){console.error(t),this.errorTarget(e,t.message)}}errorTarget(e,t){const r=this.targetElement(e),a=this.getElement("error",r),n=i.compileTemplate(this.options.errorTemplate,{TITLE:this.getLang("ERROR_TITLE"),TEXT:t});if(a.length>0)return void a.replaceWith(n);const s=r.find(".b-form-section").not(".fill--primary");s.length>0?s.eq(0).before(n):r.prepend(n)}targetElement(e){return t("#"+e)}}n.dataName="uiFormAjaxReload",n.defaults=Object.assign({},a.Base.prototype.defaults,{listenElement:".js-ajax-reloader__field",controlCellElement:".adm-detail-content-cell-r",errorElement:".js-ajax-reloader__error",errorTemplate:'<p class="js-ajax-reloader__error" style="color: red;"><strong>#TITLE#</strong><br /> #TEXT#</p>',reloadMap:null,reloadDelay:5e3,lang:{},langPrefix:"YANDEX_MARKET_UI_FORM_AJAX_RELOADER_"}),e.AjaxReloader=n}(this.BX.YandexMarket.Ui.Form=this.BX.YandexMarket.Ui.Form||{}); //# sourceMappingURL=bundle.js.map