Your IP : 3.143.222.84


Current Path : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/js/disk/document/
Upload File :
Current File : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/js/disk/document/editprocess.min.js

(function(){"use strict";BX.namespace("BX.Disk.Document");BX.Disk.Document.EditProcess=function(e){this.objectId=e.objectId;this.attachedObjectId=e.attachedObjectId;this.serviceCode=e.serviceCode;this.service=null;this.popupConfirm=null;this.onAfterSave=null;this.modalWindow=e.modalWindow;if(BX.type.isFunction(e.onAfterSave)){this.onAfterSave=e.onAfterSave}};BX.Disk.Document.EditProcess.prototype={start:function(){this.modalWindow=this.buildModalWindow();this.loadServiceDescription().then(function(e){this.openEditConfirm()}.bind(this))},buildModalWindow:function(){return this.openModal(BX.util.add_url_param("/bitrix/services/main/ajax.php",{action:"disk.api.documentService.goToEdit",serviceCode:this.serviceCode,objectId:this.objectId||0,attachedObjectId:this.attachedObjectId||0}))},isActive:function(){return this.popupConfirm&&this.popupConfirm.isShown()},openModal:function(e,i,t){i=i||1030;t=t||700;if(this.modalWindow){this.modalWindow.location=e}var o=this.modalWindow||BX.util.popup(e,i,t);window.addEventListener("message",function(e){if(e.origin!=window.location.origin){return}if(e.data.reason==="disk-work-with-document"){this.setDataForCommit(e.data)}else if(e.data.reason==="disk-work-close-edit-document"){this.closeEditConfirm()}}.bind(this),false);return o},closeModal:function(){if(this.modalWindow){try{this.modalWindow.close()}catch(e){}}},getDataForCommit:function(){return this.dataForCommit},setDataForCommit:function(e){this.dataForCommit=e},getService:function(){return this.service},loadServiceDescription:function(){var e=new BX.Promise;if(this.service){e.fulfill(this.service);return e}BX.ajax.runAction("disk.api.documentService.get",{data:{serviceCode:this.serviceCode}}).then(function(i){this.service=i.data.documentService;e.fulfill(this.service)}.bind(this));return e},buildLinkToCommit:function(){var e=this.objectId?this.service.links.edit:this.service.links.uf.edit;e=e.replace("FILE_ID",this.objectId);e=e.replace("ATTACHED_ID",this.attachedObjectId);e=BX.util.remove_url_param(e,"document_action");e=BX.util.add_url_param(e,{document_action:"commit"});return e},save:function(){return this.commit().then(function(e){console.log("commit",e);if(e.status!=="success"){BX.UI.Viewer.Instance.close();BX.Disk.showModalWithStatusAction(e);return e}if(e.originalIsLocked){BX.UI.Viewer.Instance.close();BX.Disk.InformationPopups.showWarningLockedDocument({link:BX.Disk.getUrlToShowObjectInGrid(e.forkedObject.id)})}else{this.onAfterSave.call(this,e)}return e}.bind(this))},commit:function(){console.log("commit");var e=new BX.Promise;var i=this.getDataForCommit()||{};var t=i.idDoc||i.id;if(!t){console.log("There is no parameters for commit");e.fulfill({status:"error"});return e}return BX.ajax.promise({method:"POST",dataType:"json",url:this.buildLinkToCommit(),data:{commit:1,editSessionId:i.editSessionId,id:t,sessid:BX.bitrix_sessid()}})},buildLinkToDiscard:function(){return this.urlHelper().getUrlDiscardFile(this.buildLinkToCommit())},discard:function(){console.log("discard");var e=new BX.Promise;var i=this.getDataForCommit()||{};var t=i.idDoc||i.id;if(!t){console.log("There is no parameters for commit");e.fulfill({status:"error"});return e}BX.ajax({method:"POST",dataType:"json",url:this.buildLinkToDiscard(),data:{discard:1,editSessionId:i.editSessionId,id:t,sessid:BX.bitrix_sessid()},onsuccess:function(e){console.log("discard",e)}})},getViewerZindex:function(){if(BX.getClass("BX.UI.Viewer.Instance")){return BX.UI.Viewer.Instance.getZindex()}return null},closeEditConfirm:function(){this.popupConfirm&&this.popupConfirm.close()},getConfirmMessages:function(){return{title:BX.message("JS_DISK_DOC_PROCESS_NOW_EDITING_IN_SERVICE").replace("#SERVICE#",this.service.name),text:BX.message("JS_DISK_DOC_PROCESS_IFRAME_DESCR_SAVE_DOC_F").replace("#SAVE_DOC#",BX.message("JS_DISK_DOC_PROCESS_SAVE")),saveButton:BX.message("DISK_JS_BTN_SAVE")}},openEditConfirm:function(){var e=BX.create("div",{props:{className:"bx-disk-document-edit-confirm"},children:[BX.create("div",{props:{className:"bx-disk-document-edit-confirm-title"},text:this.getConfirmMessages().title,children:[]}),BX.create("div",{props:{className:"bx-disk-document-edit-confirm-text-wrap"},children:[BX.create("span",{props:{className:"bx-disk-document-edit-confirm-text-alignment"}}),BX.create("span",{props:{className:"bx-disk-document-edit-confirm-text"},text:this.getConfirmMessages().text})]})]});this.popupConfirm=BX.PopupWindowManager.create("document-edit-confirm",null,{content:e,overlay:true,buttons:[new BX.PopupWindowCustomButton({text:this.getConfirmMessages().saveButton,className:"ui-btn ui-btn-success",events:{click:function(){var e=BX.Disk.showActionModal({text:BX.message("JS_DISK_DOC_PROCESS_IFRAME_PROCESS_SAVE_DOC"),showLoaderIcon:true,autoHide:false});this.popupConfirm.close();this.closeModal();window.onbeforeunload=null;this.save().then(function(){console.log("actionModal.close");e.close()})}.bind(this)}}),new BX.PopupWindowCustomButton({text:BX.message("DISK_JS_BTN_CANCEL"),className:"ui-btn ui-btn-link",events:{click:function(){this.discard();this.popupConfirm.close();this.closeModal()}.bind(this)}})],autoHide:false,closeByEsc:false,zIndex:this.getViewerZindex(),events:{onPopupClose:function(){this.destroy()}}});this.popupConfirm.show()},urlHelper:function(){var e=this.serviceCode;return{ajaxDocUrl:"/bitrix/tools/disk/document.php",ajaxUfDocUrl:"/bitrix/tools/disk/uf.php",normalizeServiceName:function(e){switch(e.toLowerCase()){case"g":case"google":case"gdrive":e="gdrive";break;case"s":case"skydrive":case"sky-drive":case"onedrive":e="onedrive";break;case"office365":e="office365";break;case"myoffice":e="myoffice";break;case"l":case"local":e="l";break;default:e="gdrive";break}return e},getUrlViewFile:function(e){e=this.addToLinkParam(e,"service","gvdrive");e=this.addToLinkParam(e,"document_action","show");return e},getUrlCheckView:function(e){e=this.addToLinkParam(e,"service","gvdrive");e=this.addToLinkParam(e,"document_action","checkView");return e},getUrlStartPublishBlank:function(i,t){i=this.addToLinkParam(i,"service",e);i=this.addToLinkParam(i,"type",t);return i},getUrlCommitBlank:function(i,t,o){i=this.addToLinkParam(i,"service",e);i=this.addToLinkParam(i,"document_action","saveBlank");i=this.addToLinkParam(i,"type",t);if(o){i=this.addToLinkParam(i,"targetFolderId",o)}return i},getUrlRenameFile:function(i){i=this.addToLinkParam(i,"service",e);i=this.addToLinkParam(i,"document_action","rename");return i},getUrlCopyToMe:function(e){e=this.addToLinkParam(e,"action","copyToMe");return e},getUrlEditFile:function(i,t){i=this.addToLinkParam(i,"service",e);return i},getUrlCommitFile:function(i){i=this.addToLinkParam(i,"service",e);i=this.addToLinkParam(i,"document_action","commit");return i},getUrlDiscardFile:function(i){i=this.addToLinkParam(i,"service",e);i=this.addToLinkParam(i,"document_action","discard");return i},getUrlDiscardBlankFile:function(i){i=this.addToLinkParam(i,"service",e);i=this.addToLinkParam(i,"document_action","discardBlank");return i},addToLinkParam:function(e,i,t){if(!e.length){return"?"+i+"="+t}e=BX.util.remove_url_param(e,i);if(e.indexOf("?")!=-1){return e+"&"+i+"="+t}return e+"?"+i+"="+t}}}}})();
//# sourceMappingURL=editprocess.map.js