Your IP : 18.118.164.105


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/bizproc/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/bizproc/starter.min.js

(function(){"use strict";BX.namespace("BX.Bizproc");if(BX.Bizproc.Starter){return}var e=0;var t=function(){window.alert(BX.message("BIZPROC_JS_BP_STARTER_REQUEST_FAILURE"))};var i={instances:[],put:function(e){this.instances.push(e);return this},findSimilar:function(e){var t=[e];for(var i=0;i<this.instances.length;++i){var a=this.instances[i];if(a!==e&&a.moduleId===e.moduleId&&a.entity===e.entity&&a.documentType===e.documentType){t.push(a)}}return t},fireEvent:function(e,t,i){var a=this.findSimilar(e);for(var n=0;n<a.length;++n){BX.onCustomEvent(a[n],t,i)}}};var a=function(t){this.id=++e;this.templates=t.templates||null;this.moduleId=t.moduleId;this.entity=t.entity;this.documentType=t.documentType;this.documentId=t.documentId;this.ajaxUrl=t.ajaxUrl||"/bitrix/components/bitrix/bizproc.workflow.start/ajax.php";i.put(this)};a.singleStart=function(e,t){var i=new a(e);if(BX.type.isFunction(t)){BX.addCustomEvent(i,"onAfterStartWorkflow",t)}if(e.hasParameters){i.showParametersPopup(e.templateId,{title:e.templateName})}else{i.startWorkflow(e.templateId)}};a.prototype={showTemplatesMenu:function(e){if(this.templates===null){this.loadTemplates(this.showTemplatesPopupMenu.bind(this,e))}else{this.showTemplatesPopupMenu(e)}},showTemplatesPopupMenu:function(e){var t=this,i,a,n,o=[];var s=function(e,i){this.popupWindow.close();e.preventDefault();t.onTemplateMenuItemClick(i.template)};for(i=0;i<this.templates.length;++i){a=this.templates[i];n={text:a["name"],template:a,title:a["description"],onclick:s};o.push(n)}if(!o.length){this.showEmptyTemplatesHint(e)}else{BX.PopupMenu.show("bp-starter-tpl-menu-"+this.id,e,o,{closeByEsc:true,zIndex:200,autoHide:true})}},showEmptyTemplatesHint:function(e){var t=BX.message("BIZPROC_JS_BP_STARTER_NO_TEMPLATES");var i=new BX.PopupWindow("bp-starter-tpl-empty"+this.id,e,{lightShadow:true,autoHide:true,darkMode:true,offsetLeft:40,angle:{position:"top",offset:40},bindOptions:{position:"bottom"},zIndex:1100,events:{onPopupClose:function(){this.destroy()}},content:BX.create("div",{attrs:{style:"padding-right: 5px; width: 200px;"},text:t})});i.show()},loadTemplates:function(e){var t=this;this.callAction("get_templates",{},function(i){t.templates=i.templates;e(i)})},onTemplateMenuItemClick:function(e){if(!e.hasParameters){this.startWorkflow(e["id"])}else{this.showParametersPopup(e["id"],{title:e["name"]})}},startWorkflow:function(e){var t=this;this.callAction("start_workflow",{template_id:e},function(e){i.fireEvent(t,"onAfterStartWorkflow",e)})},showParametersPopup:function(e,t){var a=this;if(!BX.type.isPlainObject(t)){t={}}this.loadParametersHtml({template_id:e},function(o){var s,r=BX.create("div",{html:o});var l=r.querySelector('[data-role="bizproc-start-form"]');a.prepareParametersForm(l,e);var d=l.querySelector('[data-role="bizproc-form-buttons"]');if(d){BX.remove(d)}var c=new n(l);c.init();var p=new BX.PopupWindowButton({text:BX.message("BIZPROC_JS_BP_STARTER_START"),className:"popup-window-button-accept",events:{click:function(e){BX.fireEvent(l,"submit")}}});s=new BX.PopupWindow("bp-starter-parameters-popup-"+a.id,null,{content:r,width:600,closeIcon:true,titleBar:t.title||"",closeByEsc:true,draggable:{restrict:false},events:{onPopupClose:function(e){e.destroy()}},buttons:[p,new BX.PopupWindowButtonLink({text:BX.message("BIZPROC_JS_BP_STARTER_CANCEL"),className:"popup-window-button-link-cancel",events:{click:function(e){s.close()}}})]});BX.bind(l,"submit",function(e){e.preventDefault();p.addClassName("popup-window-button-wait");a.submitParametersForm(l,function(e){p.removeClassName("popup-window-button-wait");if(e.success){s.close();i.fireEvent(a,"onAfterStartWorkflow",e.data)}})});s.show()})},showAutoStartParametersPopup:function(e,t){var i=this;if(!BX.type.isPlainObject(t)){t={}}var a=function(e){var a;if(BX.type.isDomNode(e)){a=e.firstChild}else{a=BX.create("div",{html:e})}var o=a.querySelector('[data-role="bizproc-start-form"]');i.prepareParametersForm(o,null,"check_parameters");var s=new n(o);s.init();var r=new BX.PopupWindowButton({text:BX.message("BIZPROC_JS_BP_STARTER_SAVE"),className:"popup-window-button-accept",events:{click:function(e){BX.fireEvent(o,"submit")}}});var l=new BX.PopupWindow("bp-starter-parameters-popup-"+i.id,null,{content:a,width:600,closeIcon:true,titleBar:t.title||BX.message("BIZPROC_JS_BP_STARTER_AUTOSTART"),closeByEsc:true,draggable:{restrict:false},events:{onPopupClose:function(e){e.destroy()}},buttons:[r,new BX.PopupWindowButtonLink({text:BX.message("BIZPROC_JS_BP_STARTER_CANCEL"),className:"popup-window-button-link-cancel",events:{click:function(e){l.close()}}})]});BX.bind(o,"submit",function(e){e.preventDefault();r.addClassName("popup-window-button-wait");i.submitParametersForm(o,function(e){r.removeClassName("popup-window-button-wait");if(e.success){l.close();if(t.callback){t.callback(e.data)}}})});l.show()};if(t.contentNode){a(t.contentNode)}else{this.loadParametersHtml({auto_execute_type:e},a.bind(this))}},loadParametersHtml:function(e,i){e["sessid"]=BX.bitrix_sessid();e["site_id"]=BX.message("SITE_ID");e["module_id"]=this.moduleId;e["entity"]=this.entity;e["document_type"]=this.documentType;if(this.documentId){e["document_id"]=this.documentId}BX.ajax({method:"POST",dataType:"html",url:"/bitrix/components/bitrix/bizproc.workflow.start/popup.php",data:e,onsuccess:function(e){i(e)},onfailure:t})},prepareParametersForm:function(e,t,i){if(t){e.appendChild(BX.create("input",{attrs:{type:"hidden",name:"template_id",value:t}}))}e.appendChild(BX.create("input",{attrs:{type:"hidden",name:"module_id",value:this.moduleId}}));e.appendChild(BX.create("input",{attrs:{type:"hidden",name:"entity",value:this.entity}}));e.appendChild(BX.create("input",{attrs:{type:"hidden",name:"ajax_action",value:i?i:"start_workflow"}}));e.action=this.ajaxUrl},submitParametersForm:function(e,i){if(e.__requestInProgress){return}e.__requestInProgress=true;var a=new FormData(e);BX.ajax({method:"POST",dataType:"json",url:this.ajaxUrl,data:a,preparePost:false,onsuccess:function(t){delete e.__requestInProgress;if(!t.success){window.alert(t.errors.join("\n"))}if(i){i(t)}},onfailure:t})},callAction:function(e,i,a){i["sessid"]=BX.bitrix_sessid();i["site"]=BX.message("SITE_ID");i["ajax_action"]=e;i["module_id"]=this.moduleId;i["entity"]=this.entity;i["document_type"]=this.documentType;i["document_id"]=this.documentId;BX.ajax({method:"POST",dataType:"json",url:this.ajaxUrl,data:i,onsuccess:function(e){if(e.success){a(e.data,e)}else{window.alert(e.errors.join("\n"))}},onfailure:t})}};BX.Bizproc.Starter=a;var n=function(e,t){this.node=e;this.config=t||{}};n.prototype={init:function(){this.replaceControls()},replaceControls:function(){var e;if(o.canUse()){var t=this.node.querySelectorAll(".bizproc-modern-type-control-wrapper-user");for(e=0;e<t.length;++e){this.replaceUserControl(t[e])}}var i=this.node.querySelectorAll(".bizproc-modern-type-control-wrapper-file");for(e=0;e<i.length;++e){this.replaceFileControl(i[e])}},replaceUserControl:function(e){var t={};var i=e.querySelector(".bizproc-modern-type-control");t.valueInputName=i.name;t.multiple=BX.hasClass(i,"bizproc-modern-type-control-multiple");t.required=BX.hasClass(i,"bizproc-modern-type-control-required");BX.cleanNode(e);new o(this,e,t)},replaceFileControl:function(e){var t=e.querySelector(".bizproc-modern-type-control");var i=BX.hasClass(t,"bizproc-modern-type-control-multiple");var a=i?t.name.replace("[n0]","[]"):t.name;BX.cleanNode(e);e.appendChild(this.createFileControlNode(a));if(i){var n=BX.create("span",{attrs:{className:"webform-small-button webform-small-button-accept bizproc-modern-type-control-file-clone-button"},text:BX.message("BIZPROC_JS_BP_STARTER_CONTROL_CLONE"),events:{click:this.cloneFileControl.bind(this,e,a)}});e.appendChild(n)}},createFileControlNode:function(e){var t=BX.create("input",{props:{type:"file",name:e}});var i=BX.create("span",{attrs:{className:"bizproc-modern-type-control-button"},children:[BX.create("span",{attrs:{className:"webform-small-button"},text:BX.message("BIZPROC_JS_BP_STARTER_FILE_CHOOSE")}),t]});var a=BX.create("span",{attrs:{className:"bizproc-modern-type-control-file-value-name"}});BX.bind(t,"change",function(){a.textContent=this.parseFileLabel(t.value)}.bind(this));return BX.create("div",{children:[i,a],attrs:{className:"bizproc-modern-type-control-file-replaced"}})},cloneFileControl:function(e,t){e.insertBefore(this.createFileControlNode(t),e.lastChild)},parseFileLabel:function(e){var t;if(e.lastIndexOf("\\")){t=e.lastIndexOf("\\")+1}else{t=e.lastIndexOf("/")+1}return e.slice(t)},getAjaxUrl:function(){return this.config.ajaxUrl||"/bitrix/components/bitrix/bizproc.workflow.start/ajax.php"}};var o=function(e,t,i){var a=this;this.container=t;this.itemsNode=BX.create("span");this.inputBoxNode=BX.create("span",{attrs:{className:"feed-add-destination-input-box"}});this.inputNode=BX.create("input",{props:{type:"text"},attrs:{className:"feed-add-destination-inp"}});this.inputBoxNode.appendChild(this.inputNode);this.tagNode=BX.create("a",{attrs:{className:"feed-add-destination-link"}});BX.addClass(t,"bizproc-modern-destination");t.appendChild(this.itemsNode);t.appendChild(this.inputBoxNode);t.appendChild(this.tagNode);this.component=e;this.data=null;this.dialogId=BX.util.getRandomString(7);this.createValueNode(i.valueInputName||"");this.selected=i.selected?BX.clone(i.selected):[];this.selectOne=!i.multiple;this.required=i.required||false;BX.bind(this.tagNode,"focus",function(e){a.openDialog({bByFocusEvent:true});return BX.PreventDefault(e)});BX.bind(this.container,"click",function(e){a.openDialog();return BX.PreventDefault(e)});this.addItems(this.selected);this.tagNode.innerHTML=this.selected.length<=0?BX.message("BIZPROC_JS_BP_STARTER_DESTINATION_CHOOSE"):BX.message("BIZPROC_JS_BP_STARTER_DESTINATION_EDIT")};o.canUse=function(){return!!BX.SocNetLogDestination};o.prototype={getData:function(e){var t=this;if(t.ajaxProgress)return;t.ajaxProgress=true;BX.ajax({method:"POST",dataType:"json",url:t.component.getAjaxUrl(),data:{ajax_action:"get_destination_data",sessid:BX.bitrix_sessid(),site:BX.message("SITE_ID")},onsuccess:function(i){t.data=i.data||{};t.ajaxProgress=false;t.initDialog(e)}})},initDialog:function(e){var t,i=this,a=this.data;if(!a){i.getData(e);return}var n={};for(t=0;t<i.selected.length;++t){n[i.selected[t].id]=i.selected[t].entityType}var o={users:a.USERS||{},department:a.DEPARTMENT||{},departmentRelation:a.DEPARTMENT_RELATION||{}};var s={users:a.LAST.USERS||{}};if(!o["departmentRelation"]){o["departmentRelation"]=BX.SocNetLogDestination.buildDepartmentRelation(o["department"])}if(!i.inited){i.inited=true;var r=i.inputNode;r.id=i.dialogId+"input";var l=i.inputBoxNode;l.id=i.dialogId+"input-box";var d=this.tagNode;d.id=this.dialogId+"tag";var c=i.itemsNode;BX.SocNetLogDestination.init({name:i.dialogId,searchInput:r,extranetUser:false,bindMainPopup:{node:i.container,offsetTop:"5px",offsetLeft:"15px"},bindSearchPopup:{node:i.container,offsetTop:"5px",offsetLeft:"15px"},departmentSelectDisable:true,sendAjaxSearch:true,callback:{select:function(e,t,a,n){i.addItem(e,t);if(i.selectOne)BX.SocNetLogDestination.closeDialog()},unSelect:function(e){if(i.selectOne)return;i.unsetValue(e.entityId);BX.SocNetLogDestination.BXfpUnSelectCallback.call({formName:i.dialogId,inputContainerName:c,inputName:r.id,tagInputName:d.id,tagLink1:BX.message("BIZPROC_JS_BP_STARTER_DESTINATION_CHOOSE"),tagLink2:BX.message("BIZPROC_JS_BP_STARTER_DESTINATION_EDIT")},e)},openDialog:BX.delegate(BX.SocNetLogDestination.BXfpOpenDialogCallback,{inputBoxName:l.id,inputName:r.id,tagInputName:d.id}),closeDialog:BX.delegate(BX.SocNetLogDestination.BXfpCloseDialogCallback,{inputBoxName:l.id,inputName:r.id,tagInputName:d.id}),openSearch:BX.delegate(BX.SocNetLogDestination.BXfpOpenDialogCallback,{inputBoxName:l.id,inputName:r.id,tagInputName:d.id}),closeSearch:BX.delegate(BX.SocNetLogDestination.BXfpCloseSearchCallback,{inputBoxName:l.id,inputName:r.id,tagInputName:d.id})},items:o,itemsLast:s,itemsSelected:n,useClientDatabase:false,destSort:a.DEST_SORT||{},allowAddUser:false});BX.bind(r,"keyup",BX.delegate(BX.SocNetLogDestination.BXfpSearch,{formName:i.dialogId,inputName:r.id,tagInputName:d.id}));BX.bind(r,"keydown",BX.delegate(BX.SocNetLogDestination.BXfpSearchBefore,{formName:i.dialogId,inputName:r.id}));BX.SocNetLogDestination.BXfpSetLinkName({formName:i.dialogId,tagInputName:d.id,tagLink1:BX.message("BIZPROC_JS_BP_STARTER_DESTINATION_CHOOSE"),tagLink2:BX.message("BIZPROC_JS_BP_STARTER_DESTINATION_EDIT")})}e()},addItem:function(e,t){var i=this;var a=this.inputNode;var n=this.tagNode;var o=this.itemsNode;if(!BX.findChild(o,{attr:{"data-id":e.id}},false,false)){if(i.selectOne&&i.inited){var s=[];for(var r=0;r<o.childNodes.length;++r){s.push({itemId:o.childNodes[r].getAttribute("data-id"),itemType:o.childNodes[r].getAttribute("data-type")})}i.initDialog(function(){for(var e=0;e<s.length;++e){BX.SocNetLogDestination.deleteItem(s[e].itemId,s[e].itemType,i.dialogId)}});BX.cleanNode(o);i.cleanValue()}var l=this.createItemNode({text:e.name,deleteEvents:{click:function(a){if(i.selectOne&&i.required){i.openDialog()}else{i.initDialog(function(){BX.SocNetLogDestination.deleteItem(e.id,t,i.dialogId);BX.remove(l);i.unsetValue(e.entityId)})}BX.PreventDefault(a)}}});this.setValue(e.entityId);l.setAttribute("data-id",e.id);l.setAttribute("data-type",t);o.appendChild(l);if(!e.entityType)e.entityType=t}a.value="";n.innerHTML=BX.message("BIZPROC_JS_BP_STARTER_DESTINATION_EDIT")},addItems:function(e){for(var t=0;t<e.length;++t){this.addItem(e[t],e[t].entityType)}},openDialog:function(e){var t=this;this.initDialog(function(){BX.SocNetLogDestination.openDialog(t.dialogId,e)})},destroy:function(){if(this.inited){if(BX.SocNetLogDestination.isOpenDialog()){BX.SocNetLogDestination.closeDialog()}BX.SocNetLogDestination.closeSearch()}},createItemNode:function(e){return BX.create("span",{attrs:{className:"bizproc-modern-destination-item"},children:[BX.create("span",{attrs:{className:"bizproc-modern-destination-name"},html:e.text||""}),BX.create("span",{attrs:{className:"bizproc-modern-destination-delete"},events:e.deleteEvents})]})},createValueNode:function(e){this.valueNode=BX.create("input",{props:{type:"hidden",name:e}});this.container.appendChild(this.valueNode)},setValue:function(e){if(/^\d+$/.test(e))e="["+e+"]";if(this.selectOne)this.valueNode.value=e;else{var t,i=[],a=this.valueNode.value.split(";");for(t=0;t<a.length;++t){if(!a[t]||e==a[t])continue;i.push(a[t])}i.push(e);this.valueNode.value=i.join(";")}},unsetValue:function(e){if(/^\d+$/.test(e))e="["+e+"]";if(this.selectOne)this.valueNode.value="";else{var t,i=[],a=this.valueNode.value.split(";");for(t=0;t<a.length;++t){if(!a[t]||e==a[t])continue;i.push(a[t])}this.valueNode.value=i.join(";")}},cleanValue:function(){this.valueNode.value=""}}})();