adf-aos-editonline-action
Version:
Alfresco ADF AOS action
3 lines (2 loc) • 3.67 kB
JavaScript
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@angular/core"),require("@alfresco/adf-core"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@alfresco/adf-core","@angular/common"],o):o(e["adf-aos-editonline-action"]={},e.ng.core,e.adfCore,e.ng.common)}(this,function(e,o,t,n){"use strict";var i=function(){function e(e,o,t,n){this.alfrescoApiService=e,this.alfrescoAuthenticationService=o,this.appConfigService=t,this.notificationService=n}return e.prototype.onActionEditOnlineAos=function(e){if(e.isFile)if(e.isLocked){var o=e.aspectNames.find(function(e){return"cm:checkedOut"===e}),t=e.properties["cm:lockOwner"],n=t.id!==this.alfrescoAuthenticationService.getEcmUsername();o&&n?this.onAlreadyLockedNotification(e.id,t):this.triggerEditOnlineAos(e)}else this.triggerEditOnlineAos(e)},e.prototype.getUserAgent=function(){return navigator.userAgent.toLowerCase()},e.prototype.isWindows=function(){return-1!==this.getUserAgent().indexOf("win")},e.prototype.isMacOs=function(){return-1!==this.getUserAgent().indexOf("mac")},e.prototype.onAlreadyLockedNotification=function(e,o){this.notificationService.openSnackMessage("Document {nodeId} locked by {lockOwner}",3e3)},e.prototype.getProtocolForFileExtension=function(o){return e.MS_PROTOCOL_NAMES[o]},e.prototype.triggerEditOnlineAos=function(e){var o=this.onlineEditUrlAos(e),t=null!==e.name.split(".").pop()?e.name.split(".").pop().toLowerCase():"",n=this.getProtocolForFileExtension(t);n!==undefined?this.isWindows()||this.isMacOs()?this.aos_tryToLaunchOfficeByMsProtocolHandler(n,o):this.notificationService.openSnackMessage("Only supported for Windows and Mac",3e3):this.notificationService.openSnackMessage("No protocol handler found for {fileExtension}",3e3)},e.prototype.onlineEditUrlAos=function(o){for(var t="/",n=0,i=o.path.elements.slice(1,o.path.elements.length);n<i.length;n++){t=t+i[n].name+"/"}var r=this.appConfigService.get(e.ECM_HOST_CONFIG_KEY),s=r+"/alfresco/aos"+t+"/"+o.name;return encodeURI(s).length>256&&(s=r+"/alfresco/aos/_aos_nodeid/"+o.id+"/"+o.name),s},e.prototype.aos_tryToLaunchOfficeByMsProtocolHandler=function(e,o){var t=e+":ofe%7Cu%7C"+o,n=document.createElement("input"),i=document.body.scrollTop+10;n.setAttribute("style","z-index: 1000; background-color: rgba(0, 0, 0, 0); border: none; outline: none; position: absolute; left: 10px; top: "+i+"px;"),document.getElementsByTagName("body")[0].appendChild(n),n.focus(),n.onblur=function(){},location.href=t,setTimeout(function(){n.onblur=null,n.remove()},500)},e}();i.ECM_HOST_CONFIG_KEY="ecmHost",i.AOS_EDITONLINE_ACTION_HANDLER_KEY="aos-editonline",i.MS_PROTOCOL_NAMES={doc:"ms-word",docx:"ms-word",docm:"ms-word",dot:"ms-word",dotx:"ms-word",dotm:"ms-word",xls:"ms-excel",xlsx:"ms-excel",xlsb:"ms-excel",xlsm:"ms-excel",xlt:"ms-excel",xltx:"ms-excel",xltm:"ms-excel",ppt:"ms-powerpoint",pptx:"ms-powerpoint",pot:"ms-powerpoint",potx:"ms-powerpoint",potm:"ms-powerpoint",pptm:"ms-powerpoint",pps:"ms-powerpoint",ppsx:"ms-powerpoint",ppam:"ms-powerpoint",ppsm:"ms-powerpoint",sldx:"ms-powerpoint",sldm:"ms-powerpoint"},i.decorators=[{type:o.Injectable}],i.ctorParameters=function(){return[{type:t.AlfrescoApiService},{type:t.AuthenticationService},{type:t.AppConfigService},{type:t.NotificationService}]};var r=function(){return function(){}}();r.decorators=[{type:o.NgModule,args:[{imports:[n.CommonModule],declarations:[],exports:[],providers:[i]}]}],r.ctorParameters=function(){return[]},e.AosEditOnlineService=i,e.AosModule=r,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=adf-aos-editonline-action.umd.min.js.map