%PDF- %PDF-
Direktori : /home/bitrix/www/bitrix/components/bitrix/sale.location.import/templates/admin/ |
Current File : /home/bitrix/www/bitrix/components/bitrix/sale.location.import/templates/admin/script.min.js |
BX.namespace("BX.Sale.component.location");if(typeof BX.Sale.component.location.import=="undefined"&&typeof BX.ui!="undefined"&&typeof BX.ui.widget!="undefined"){BX.Sale.component.location.import=function(t,e){this.parentConstruct(BX.Sale.component.location.import,t);BX.merge(this,{opts:{url:"/somewhere.php",ajaxFlag:"AJAX_MODE",progressWidth:500,firstImport:false,statistics:{}},vars:{stage:false,state:"remote",formSubmitted:false,fileUploaded:false,awaitInterruption:false,firstImport:false,statistics:{}},ctrls:{buttons:{}},sys:{code:"loc-i"}});this.handleInitStack(e,BX.Sale.component.location.import,t)};BX.extend(BX.Sale.component.location.import,BX.ui.widget);BX.merge(BX.Sale.component.location.import.prototype,{init:function(){var t=this.opts,e=this.vars,s=this.ctrls,a=this;e.firstImport=t.firstImport;e.statistics=BX.clone(t.statistics);e.iterator=new BX.iterator({source:t.url,interval:100,waitAjaxOnStop:true,whenHit:function(t){a.setPercent(t.data.PERCENT);var s=t.data.NEXT_STAGE;if(BX.type.isNotEmptyString(s)&&e.stage!=t.data.NEXT_STAGE)a.setStage(t.data.NEXT_STAGE);var i=t.data.PERCENT<100;if(!i){if(typeof t.data.STAT!="undefined")a.updateStatistics(t.data.STAT);var r=this.vars.fields;if(typeof r.OPTIONS!="undefined"&&typeof r.OPTIONS.DROP_ALL!="undefined"||typeof r.ONLY_DELETE_ALL!="undefined")e.firstImport=false}return i}});e.iterator.bindEvent("set-status",function(i){if(this.vars.fields.ONLY_DELETE_ALL==1){if(i=="R"){s.buttons.startStop.setAttribute("disabled","disabled");s.buttons.deleteAll.setAttribute("disabled","disabled");a.setCSSState("running")}else if(i=="S"){s.buttons.startStop.removeAttribute("disabled");s.buttons.deleteAll.removeAttribute("disabled");a.dropCSSState("running");a.setStage("COMPLETE_REMOVE_ALL")}}else{if(i=="R"){s.buttons.startStop.value=t.messages.stop;a.setCSSState("running")}else if(i=="I"){s.buttons.startStop.value=t.messages.stopping;s.buttons.startStop.setAttribute("disabled","disabled");a.setStage("INTERRUPTING");e.awaitInterruption=true}else if(i=="S"){function r(){s.buttons.startStop.value=t.messages.start;a.dropCSSState("running");s.buttons.startStop.removeAttribute("disabled");a.setStage(e.awaitInterruption?"INTERRUPTED":"COMPLETE");e.awaitInterruption=false}if(false&&e.awaitInterruption){BX.ajax({url:t.url,method:"post",dataType:"html",async:true,processData:true,emulateOnload:true,start:true,data:{RESTORE_INDEXES:1},onsuccess:r,onfailure:r})}else r()}}});e.tree=new BX.ui.itemTree({scope:this.getControl("location-set"),bindEvents:{"toggle-bundle-before":function(t,e){BX[t?"addClass":"removeClass"](e.expander,"expanded")}}});s.fLoader=new BX.ui.fileAsyncLoader({scope:a.getControl("userfile"),url:t.pageUrl});var i=function(){var t=BX.findChildren(this.ctrls.inputContainer,{className:"adm-input-file"});t[0].appendChild(this.ctrls.input)};s.fLoader.bindEvent("upload-success",function(){e.fileUploaded=true;i.call(this)});s.fLoader.bindEvent("upload-fail",function(){e.fileUploaded=false;i.call(this)});s.buttons.startStop=this.getControl("button-start");s.buttons.deleteAll=this.getControl("delete-all");s.nameOfSet=this.getControl("location-set");s.percentIndicator=this.getControl("percents",false,false,true);s.percentGrade=this.getControl("adm-progress-bar-inner");s.statusText=this.getControl("status-text");s.statictics={list:this.getControl("stat-list"),all:this.getControl("stat-all"),groups:this.getControl("stat-groups")};this.pushFuncStack("bindEvents",BX.Sale.component.location.import)},bindEvents:function(){var t=this.ctrls,e=this.vars,s=this.opts,a=this;BX.bind(t.buttons.startStop,"click",function(){if(e.iterator.getIsRunning()){e.iterator.stop()}else{var i=BX.findChildren(t.nameOfSet,{tag:"input"},true);var r=[];for(var n in i){if(i[n].checked&&i[n].name.length>0&&i[n].value.length>0)r.push(i[n].value)}if(e.state=="remote"&&!r.length){alert(s.messages.selectItems);return}if(e.state=="file"&&!e.fileUploaded){alert(s.messages.uploadFile);return}var o={LOCATION_SETS:r,ADDITIONAL:a.getFormControlValues("additional"),OPTIONS:a.getFormControlValues("option")};o[s.ajaxFlag]=1;if(o.OPTIONS.DROP_ALL&&!a.askRemove())return;a.setPercent(0);a.setStage("DOWNLOAD_FILES");BX.show(a.getControl("progressbar"));e.iterator.start(o)}});BX.bind(t.buttons.deleteAll,"click",function(t){if(a.askRemove()){var i={ONLY_DELETE_ALL:1};i[s.ajaxFlag]=1;a.setPercent(0);a.setStage("DELETE_ALL");BX.show(a.getControl("progressbar"));e.iterator.start(i)}BX.PreventDefault(t)});var i=function(e){t.buttons.startStop.value=s.messages.start;var i=[];if(typeof e!="undefined"){for(var r in e){if(e[r].message)i.push(e[r].message)}}a.setStatusText(s.messages.error_occured+": "+i.join(", "),true)};e.iterator.bindEvent("server-error",i);e.iterator.bindEvent("ajax-error",i);var r=function(s,i){t.scope.className="";a.setCSSState("mode-"+s);e.state=s};BX.bindDelegate(this.getControl("mode-switch"),"change",{tag:"input"},function(){r(this.value)});r("remote",true)},askRemove:function(){var t=this.opts;if(typeof this.vars.statistics.TOTAL!="undefined"&&this.vars.statistics.TOTAL.CNT==0)return true;var e=this.vars.firstImport;var s=confirm(t.messages[e?"confirm_delete_relic":"confirm_delete"]);return e&&!s||!e&&s},setPercent:function(t){var e=this.ctrls,s=this.opts;t=parseInt(t);if(t<0)t=0;if(t>100)t=100;if(e.percentIndicator!=null){for(var a in e.percentIndicator){e.percentIndicator[a].innerHTML=t}}t=t*(s.progressWidth/100)-4;if(t<0)t=0;BX.style(e.percentGrade,"width",t+"px")},setStatusText:function(t,e){this.ctrls.statusText.innerHTML=BX.util.htmlspecialchars(t);BX.style(this.ctrls.statusText,"color",e?"red":"inherit")},setStage:function(t){var e=this.opts,s=this.vars;if(typeof e.messages["stage_"+t]=="undefined"){this.setStatusText(BX.util.htmlspecialchars(t),true);s.stage=false;return}this.setStatusText(this.opts.messages["stage_"+t],false);s.stage=t},getFormControlValues:function(t){var e={};var s=this.getControl(t,true,false,true);for(var a=0;a<s.length;a++){var i=s[a];if("name"in i){var r=i.name;if(!("type"in i))continue;if(i.nodeName=="INPUT"&&(i.type=="checkbox"||i.type=="radio")&&!i.checked)continue;e[r]=i.value}}return e},setTab:function(t){BX.style(this.ctrls.buttons.startStop,"visibility",t=="tab_cleanup"?"hidden":"visible")},updateStatistics:function(t){var e=this.ctrls;BX.cleanNode(e.statictics.list);var s="";var a=0;var i=0;for(var r in t){if(typeof this.vars.statistics[t[r].CODE]=="undefined")this.vars.statistics[t[r].CODE]={};this.vars.statistics[t[r].CODE].CNT=t[r].CNT;if(typeof t[r].NAME=="string"&&t[r].NAME.length>0){s+=this.getHTMLByTemplate("stat-item",{type:t[r].NAME,count:parseInt(t[r].CNT)})}if(t[r].CODE=="TOTAL")a=parseInt(t[r].CNT);if(t[r].CODE=="GROUPS")i=parseInt(t[r].CNT)}BX.html(e.statictics.list,s);BX.html(e.statictics.all,a);BX.html(e.statictics.groups,i)}})} //# sourceMappingURL=script.map.js