YetiForceCompany/YetiForceCRM

View on GitHub
public_html/layouts/basic/modules/MailIntegration/resources/outlookMessageDetail.min.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';

/* {[The file is published on the basis of YetiForce Public License 6.5 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */window.MailIntegration_Start={iframe:{},/**
     * Set iframe element.
     */setIframe:function setIframe(){this.iframe=$("#js-iframe");},/**
     * Show detail view.
     *
     * @param   {object}  mailItem  Office mailbox.item
     */showDetailView:function showDetailView(mailItem){var _this=this;AppConnector.request($.extend({module:"MailIntegration",view:"Iframe",mailFrom:mailItem.from.emailAddress,mailSender:mailItem.sender.emailAddress,mailSubject:mailItem.subject,mailNormalizedSubject:mailItem.normalizedSubject,mailMessageId:mailItem.internetMessageId,mailDateTimeCreated:mailItem.dateTimeCreated.toISOString()},window.PanelParams)).done(function(responseData){$("#page").html(responseData),_this.registerLogoutEvents();}).fail(function(){Office.context.mailbox.item.notificationMessages.replaceAsync("error",{type:"errorMessage",message:app.vtranslate("JS_ERROR")});});},/**
     * Register logout events
     */registerLogoutEvents:function registerLogoutEvents(){var _this2=this;this.setIframe();this.iframe.on("load",function reloadPanelAfterLogout(){_this2.isUserLoggedIn()||window.location.reload();});},/**
     * Register login events.
     */registerLoginEvents:function registerLoginEvents(){var loader,_this3=this,reloadPanelAfterLogin=function reloadPanelAfterLogin(){_this3.isUserLoggedIn()?window.location.reload():loader.progressIndicator({mode:"hide"});};this.iframe.on("load",reloadPanelAfterLogin),$(this.iframe[0].contentWindow).on("unload",function showLoader(){loader=$.progressIndicator({blockInfo:{enabled:!0},message:!1,blockOverlayCSS:{"background-color":"white",opacity:1}});});var src=this.iframe[0].getAttribute("src-a");src&&this.iframe[0].getAttribute("src")==null&&(this.iframe[0].removeAttribute("src-a"),this.iframe[0].setAttribute("src",src));},/**
     * Is user logged in.
     *
     * @return  {boolean}
     */isUserLoggedIn:function isUserLoggedIn(){return "Users"!=this.iframe[0].contentWindow.document.body.dataset.module||"Login"!=this.iframe[0].contentWindow.document.body.dataset.view},showConsole:function showConsole(){var s="",x="";for(var p in navigator)s+=p+" : "+navigator[p]+"<br>",x+=p+" : "+navigator[p]+"\n";console.log(x),document.body.innerHTML+="<div style=\"position:absolute;width:100%;height:100%;z-index:100;background:#fff;left: 0px; top: 50%;overflow-y: auto;\">"+s+"</div>";},/**
     * Register events.
     *
     * @param   {object}  mailbox  Office mailbox
     */registerEvents:function registerEvents(mailbox){$(".js-exception-error").length||(this.setIframe(),"login"===this.iframe.data("view")?this.registerLoginEvents():this.showDetailView(mailbox.item));},reloadView:function reloadView(data){window.MailIntegration_Start.showDetailView(Office.context.mailbox.item);}},"undefined"==typeof Office?app.showNotify({title:app.vtranslate("JS_ERROR"),type:"error"}):Office.onReady(function(info){window.PanelParams={source:"Outlook",device:Office.context.mailbox.diagnostics.hostName},info.host===Office.HostType.Outlook&&(window.MailIntegration_Start.registerEvents(Office.context.mailbox),Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged,window.MailIntegration_Start.reloadView));});
//# sourceMappingURL=outlookMessageDetail.min.js.map