File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/js/calendar/sync/manager/dist/manager.bundle.min.js
Back
this.BX=this.BX||{};this.BX.Calendar=this.BX.Calendar||{};this.BX.Calendar.Sync=this.BX.Calendar.Sync||{};(function(exports,main_popup,main_core_events,calendar_util,main_core){"use strict";let _=e=>e,_t,_t2,_t3,_t4,_t5;class SyncStatusPopup extends main_core_events.EventEmitter{constructor(e){super();this.setEventNamespace("BX.Calendar.Sync.Interface.SyncStatusPopup");this.connections=e.connections;this.withUpdateButton=e.withUpdateButton;this.node=e.node;this.id=e.id;this.init()}static createInstance(e){return new this(e)}init(){this.setPopupContent()}createPopup(){this.popup=new main_popup.Popup({className:this.id,bindElement:this.node,content:this.container,angle:true,width:360,offsetLeft:60,offsetTop:5,padding:7,darkMode:true,autoHide:true,zIndexAbsolute:3010})}show(){this.createPopup();this.popup.show()}setPopupContent(){this.container=main_core.Tag.render(_t||(_t=_` <div class="calendar-sync-popup-list"></div> `));this.connections.forEach((e=>{if(e.getConnectStatus()!==true){return}const t={};t.syncTime=this.getFormattedTime(e.getSyncDate());t.classStatus=e.getSyncStatus()?"calendar-sync-popup-item-status-success":"calendar-sync-popup-item-status-fail";t.classLable="calendar-sync-popup-item-text-"+e.getClassLabel();t.title=e.getConnectionName();const n=this.getSyncElement(t);this.container.append(n)}));if(this.withUpdateButton){this.container.append(this.getContentRefreshBlock());if(SyncStatusPopup.IS_RUN_REFRESH){this.showRefreshStatus()}}return this.container}hide(){this.popup.destroy()}getContainer(){return this.container}getPopup(){return this.popup}getFormattedTime(e){const t=new Date;let n=e;if(main_core.Type.isDate(e)){n=Math.round(e.getTime()/1e3);let s=parseInt((t-e)/1e3);if(s<60){return main_core.Loc.getMessage("CAL_JUST")}}return BX.date.format([["tommorow","tommorow, H:i:s"],["i","iago"],["H","Hago"],["d","dago"],["m100","mago"],["m","mago"],["-",""]],n)}getSyncElement(e){return main_core.Tag.render(_t2||(_t2=_` <div class="calendar-sync-popup-item"> <span class="calendar-sync-popup-item-text ${0}">${0}</span> <div class="calendar-sync-popup-item-detail"> <span class="calendar-sync-popup-item-time">${0}</span> <span class="calendar-sync-popup-item-status ${0}"></span> </div> </div> `),e.classLable,BX.util.htmlspecialchars(e.title),e.syncTime,e.classStatus)}refresh(e){this.connections=e;this.popup.setContent(this.setPopupContent());this.setRefreshStatusBlock()}setRefreshStatusBlock(){setTimeout((()=>{this.removeRefreshStatusBlock();this.enableRefreshButton();SyncStatusPopup.IS_RUN_REFRESH=false}),12e4)}removeRefreshStatusBlock(){if(main_core.Type.isElementNode(this.refreshStatusBlock)){this.refreshStatusBlock.remove()}}enableRefreshButton(){if(main_core.Type.isElementNode(this.refreshButton)){this.refreshButton.className="calendar-sync-popup-footer-btn"}}disableRefreshButton(){if(main_core.Type.isElementNode(this.refreshButton)){this.refreshButton.className="calendar-sync-popup-footer-btn calendar-sync-popup-footer-btn-disabled"}}getContentRefreshBlock(){this.footerWrapper=main_core.Tag.render(_t3||(_t3=_` <div class="calendar-sync-popup-footer-wrap"> ${0} </div> `),this.getContentRefreshButton());return this.footerWrapper}getContentRefreshButton(){this.refreshButton=main_core.Tag.render(_t4||(_t4=_` <button class="calendar-sync-popup-footer-btn">${0}</button> `),main_core.Loc.getMessage("CAL_REFRESH"));this.refreshButton.addEventListener("click",(()=>{main_core.Dom.addClass(this.refreshButton,"calendar-sync-popup-footer-btn-load");SyncStatusPopup.IS_RUN_REFRESH=true;this.refreshButton.innerText=main_core.Loc.getMessage("CAL_REFRESHING");this.runRefresh()}));return this.refreshButton}showRefreshStatus(){this.disableRefreshButton();this.footerWrapper.prepend(this.getRefreshStatus())}getRefreshStatus(){this.refreshStatusBlock=main_core.Tag.render(_t5||(_t5=_` <span class="calendar-sync-popup-footer-status">${0}</span> `),main_core.Loc.getMessage("CAL_REFRESH_JUST"));return this.refreshStatusBlock}runRefresh(){this.emit("onRefresh",{})}getId(){return this.id}}SyncStatusPopup.IS_RUN_REFRESH=false;class SyncButton{constructor(e){this.BUTTON_SIZE=BX.UI.Button.Size.EXTRA_SMALL;this.BUTTON_ROUND=true;this.connectionsProviders=e.connectionsProviders;this.wrapper=e.wrapper;this.userId=e.userId;this.status=e.status;this.buttonEnterTimeout=null;this.buttonLeaveTimeout=null}static createInstance(e){return new this(e)}show(){const e=this.getButtonData();this.button=new BX.UI.Button({text:e.text,round:this.BUTTON_ROUND,size:this.BUTTON_SIZE,color:e.color,className:"ui-btn-themes "+(e.iconClass||""),onclick:()=>{this.handleClick()},events:{mouseenter:this.handlerMouseEnter.bind(this),mouseleave:this.handlerMouseLeave.bind(this)}});this.button.renderTo(this.wrapper)}showPopup(e){if(this.status!=="not_connected"){const t=[];const n=Object.values(this.connectionsProviders);n.forEach((e=>{const n=e.getConnections();if(n.length>0){n.forEach((e=>{if(e.getConnectStatus()===true){t.push(e)}}))}}));this.popup=SyncStatusPopup.createInstance({connections:t,withUpdateButton:true,node:e.getContainer(),id:"calendar-sync-button-status"});this.popup.show();this.popup.getPopup().getPopupContainer().addEventListener("mouseenter",(e=>{clearTimeout(this.buttonEnterTimeout);clearTimeout(this.buttonLeaveTimeout)}));this.popup.getPopup().getPopupContainer().addEventListener("mouseleave",(()=>{this.hidePopup()}))}}hidePopup(){if(this.popup){this.popup.hide()}}refresh(e){this.status=e;const t=this.getButtonData();this.button.setColor(t.color);this.button.setText(t.text);this.button.removeClass("ui-btn-icon-fail ui-btn-icon-success ui-btn-clock");this.button.addClass(t.iconClass)}handleClick(){clearTimeout(this.buttonEnterTimeout);(window.top.BX||window.BX).Runtime.loadExtension("calendar.sync.interface").then((e=>{if(!main_core.Dom.hasClass(this.button.button,"ui-btn-clock")){BX.ajax.runAction("calendar.api.calendarajax.analytical",{analyticsLabel:{sync_button_click:"Y",has_active_connection:this.status==="not_connected"?"N":"Y"}});this.syncPanel=new e.SyncPanel({connectionsProviders:this.connectionsProviders,userId:this.userId,status:this.status});this.syncPanel.openSlider()}}))}handlerMouseEnter(e){clearTimeout(this.buttonEnterTimeout);this.buttonEnterTimeout=setTimeout((()=>{this.buttonEnterTimeout=null;if(!main_core.Dom.hasClass(e.button,"ui-btn-clock")){this.showPopup(e)}}),500)}handlerMouseLeave(){if(this.buttonEnterTimeout!==null){clearTimeout(this.buttonEnterTimeout);this.buttonEnterTimeout=null;return}this.buttonLeaveTimeout=setTimeout((()=>{this.hidePopup()}),500)}getButtonData(){if(this.status==="success"){return{text:main_core.Loc.getMessage("STATUS_BUTTON_SYNCHRONIZATION"),color:BX.UI.Button.Color.LIGHT_BORDER,iconClass:"ui-btn-icon-success"}}else if(this.status==="failed"){return{text:main_core.Loc.getMessage("STATUS_BUTTON_FAILED"),color:BX.UI.Button.Color.LIGHT_BORDER,iconClass:"ui-btn-icon-fail"}}else if(this.status==="synchronizing"){return{text:main_core.Loc.getMessage("STATUS_BUTTON_SYNCHRONIZATION"),color:BX.UI.Button.Color.LIGHT_BORDER,iconClass:"ui-btn-clock"}}return{text:main_core.Loc.getMessage("STATUS_BUTTON_SYNC_CALENDAR_NEW"),color:BX.UI.Button.Color.PRIMARY}}getSyncPanel(){return this.syncPanel}setConnectionProviders(e){this.connectionsProviders=e}}const isConnectionItemProperty=Symbol.for("BX.Calendar.Sync.Manager.ConnectionItem.isConnectionItem");class ConnectionItem{constructor(e){this[isConnectionItemProperty]=true;this.syncDate=main_core.Type.isDate(e.syncDate)?e.syncDate:new Date;this.connectionName=e.connectionName;this.status=e.status;this.connected=e.connected;this.addParams=e.addParams;this.type=e.type;this.id=e.type;this.userName=e.userName}static createInstance(e){return new this(e)}static isConnectionItem(e){return main_core.Type.isObject(e)&&e[isConnectionItemProperty]===true}getSyncDate(){return this.syncDate}getConnectionName(){return this.connectionName}getSyncStatus(){return this.status}getConnectStatus(){return this.connected}getStatus(){if(this.connected){return this.status?"success":"failed"}else{return"not_connected"}}getClassLabel(){return this.type}getSections(){return this.addParams.sections}getId(){return this.addParams.id}getConnectionAccountName(){return this.userName}getType(){return this.type}setId(e){this.addParams.id=e}setStatus(e){this.status=e}setUserName(e){this.userName=e}setConnected(e){this.connected=e}setSyncDate(e){this.syncDate=e}}class ConnectionProvider extends main_core_events.EventEmitter{constructor(e){super();this.MENU_WIDTH=200;this.MENU_PADDING=7;this.MENU_INDEX=3020;this.SLIDER_WIDTH=606;this.STATUS_SYNCHRONIZING="synchronizing";this.STATUS_SUCCESS="success";this.STATUS_FAILED="failed";this.STATUS_PENDING="pending";this.STATUS_NOT_CONNECTED="not_connected";this.ERROR_CODE="error";this.STATUS_LIST=[this.STATUS_SYNCHRONIZING,this.STATUS_SUCCESS,this.STATUS_FAILED,this.STATUS_PENDING,this.STATUS_NOT_CONNECTED];this.WAITING_MODE_MAX_TIME=36e4;this.setEventNamespace("BX.Calendar.Sync.Manager.ConnectionProvider");this.status=e.status;this.connected=e.connected;this.userName=e.userName||"";this.mainPanel=e.mainPanel===true;this.pendingStatus=e.pendingStatus===true;this.gridTitle=e.gridTitle;this.gridColor=e.gridColor;this.gridIcon=e.gridIcon;this.type=e.type;this.viewClassification=e.viewClassification;this.templateClass=e.templateClass;this.connections=[];this.id=e.id||""}static createInstance(e){return new this(e)}isActive(){return this.connected}hasMenu(){return false}setAdditionalParams(e){this.additionalParams=e}setSyncDate(e){e=parseInt(e);if(e>60){this.syncDate=new Date((new Date).getTime()-e*1e3)}else if(!isNaN(e)){this.syncDate=new Date}else{this.syncDate=null}if(this.getConnection()){this.getConnection().syncDate=this.syncDate}}getSyncDate(){return this.syncDate}setSections(e){this.sections=e}setStatus(e){if(this.STATUS_LIST.includes(e)){this.status=e;if(!this.connected&&(e===this.STATUS_SUCCESS||e===this.STATUS_FAILED)){this.connected=true}else if(this.connected&&e===this.STATUS_NOT_CONNECTED){this.connected=false}}return this}getGridTitle(){return this.gridTitle}getGridColor(){return this.gridColor}getGridIcon(){return this.gridIcon}clearConnections(){this.connections=[]}setConnections(){this.connections.push(ConnectionItem.createInstance({syncDate:this.getSyncDate(),connectionName:this.connectionName,status:this.status,connected:this.connected,userName:this.userName,addParams:{sections:this.sections,id:this.id||this.type},type:this.type}))}setInterfaceUnit(e){this.interfaceUnit=e}getInterfaceUnit(){return this.interfaceUnit}getConnections(){return this.connections}getConnection(){return this.connections[0]}getType(){return this.type}getViewClassification(){return this.viewClassification}getConnectStatus(){return this.connected}getSyncStatus(){return this.status}getStatus(){if(this.getWizardSyncMode()){return"synchronizing"}if(this.connected){return this.status?"success":"failed"}else if(this.pendingStatus){return"pending"}else{return"not_connected"}}getTemplateClass(){return this.templateClass}openSlider(e){BX.SidePanel.Instance.open(e.sliderId,{contentCallback(t){return new Promise(((t,n)=>{t(e.content)}))},data:e.data||{},cacheable:e.cacheable,width:this.SLIDER_WIDTH,allowChangeHistory:false,events:{onLoad:e=>{this.itemSlider=e.getSlider()}}})}closeSlider(){if(this.itemSlider){this.itemSlider.close()}}openInfoConnectionSlider(){const e=this.getClassTemplateItem().createInstance(this).getInfoConnectionContent();this.openSlider({sliderId:"calendar:item-sync-connect-"+this.type,content:e,cacheable:false,data:{provider:this}})}openActiveConnectionSlider(e){const t=this.getClassTemplateItem().createInstance(this,e);if(this.type==="google"){t.getSectionsForGoogle().then((()=>{this.openActiveConnectionSliderVendor(t,e)}))}else if(this.type==="icloud"){t.getSectionsForIcloud().then((()=>{this.openActiveConnectionSliderVendor(t,e)}))}else if(this.type==="office365"){t.getSectionsForOffice365().then((()=>{this.openActiveConnectionSliderVendor(t,e)}))}else{this.openActiveConnectionSliderVendor(t,e)}}openActiveConnectionSliderVendor(e,t){const n=e.getActiveConnectionContent();this.openSlider({sliderId:"calendar:item-sync-"+t.id,content:n,cacheable:false,data:{provider:this,connection:t,itemInterface:e}})}getClassTemplateItem(){const e=main_core.Reflection.getClass(this.getTemplateClass());if(main_core.Type.isFunction(e)){return e}return null}getConnectionById(e){const t=this.getConnections();if(t.length>0){const n=t.filter((t=>t.getId()==e));if(n){return n[0]}}return null}getSyncPanelTitle(){return this.gridTitle}getSyncPanelLogo(){return"--"+this.type}setWizardSyncMode(e){this.wizardSyncMode=e}getWizardSyncMode(){return this.wizardSyncMode}setWizardState(e){const t=this.getActiveWizard();if(t){if(e.status===this.ERROR_CODE){t.setErrorState(e)}else{t.handleUpdateState(e)}}}setUserName(e=""){this.userName=e;if(this.getConnection()){this.getConnection().setUserName(e)}}setActiveWizard(e){this.activeWizard=e;e.subscribe("onConnectionCreated",this.handleCreatedConnection.bind(this));e.subscribe("onClose",this.handleCloseWizard.bind(this));e.subscribe("startWizardWaitingMode",this.startWaitingMode.bind(this));e.subscribe("endWizardWaitingMode",this.endWaitingMode.bind(this))}getActiveWizard(){return this.activeWizard||null}startWaitingMode(){this.emit("onStartWaitingMode");this.waitingModeReserveTimeout=setTimeout((()=>{if(this.getActiveWizard()&&this.getActiveWizard().getSlider()){BX.reload()}}),this.WAITING_MODE_MAX_TIME)}endWaitingMode(){this.emit("onEndWaitingMode");if(this.waitingModeReserveTimeout){clearTimeout(this.waitingModeReserveTimeout);this.waitingModeReserveTimeout=null}}handleCreatedConnection(){this.setStatus(this.STATUS_SUCCESS);this.getInterfaceUnit().setSyncStatus(this.STATUS_SUCCESS);BX.ajax.runAction("calendar.api.syncajax.clearSuccessfulConnectionNotifier",{data:{accountType:this.getType()}});const e=calendar_util.Util.getCalendarContext();if(e){e.syncInterface.refreshDebounce()}}handleCloseWizard(){const e=this.getActiveWizard();this.setWizardSyncMode(false);if(e&&e.isSyncFinished()){this.setStatus(this.STATUS_SUCCESS);this.getInterfaceUnit().setSyncStatus(this.STATUS_SUCCESS)}else{this.setStatus(this.STATUS_SYNCHRONIZING);this.getInterfaceUnit().setSyncStatus(this.STATUS_SYNCHRONIZING);BX.SidePanel.Instance.getOpenSliders().forEach((e=>{if(["calendar:sync-slider","calendar:section-slider"].includes(e.getUrl())){e.close()}}))}this.getInterfaceUnit().refreshButton();this.emit("onEndWaitingMode");this.emit("onCloseSyncWizard");if(e){e.unsubscribeAll()}}refresh(e){this.status=e.syncInfo.status||false;this.connected=e.syncInfo.connected||false;this.id=e.syncInfo.id||null;if(e.syncLink){this.syncLink=e.syncLink}this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.clearConnections();this.setConnections()}}class GoogleProvider extends ConnectionProvider{constructor(e){super({id:e.syncInfo.id||null,status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,userName:e.syncInfo.userName||"",gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_GOOGLE"),gridColor:"#387ced",gridIcon:"/bitrix/images/calendar/sync/google.svg",type:"google",interfaceClassName:"",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.GoogleTemplate",mainPanel:e.mainPanel});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_GOOGLE");this.isSetSyncGoogleSettings=e.isSetSyncGoogleSettings;this.syncLink=e.syncLink;this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}getSyncLink(){return this.syncLink}hasSetSyncGoogleSettings(){return this.isSetSyncGoogleSettings}saveConnection(){BX.ajax.runAction("calendar.api.syncajax.createGoogleConnection",{data:{}}).then((e=>{var t;if((e==null?void 0:(t=e.data)==null?void 0:t.status)===this.ERROR_CODE){var n,s;this.setStatus(this.STATUS_FAILED);this.setWizardState({status:this.ERROR_CODE,vendorName:this.type,accountName:e==null?void 0:(n=e.data)==null?void 0:(s=n.googleApiStatus)==null?void 0:s.googleCalendarPrimaryId})}else{var i,o;this.setWizardState({stage:"connection_created",vendorName:this.type,accountName:e==null?void 0:(i=e.data)==null?void 0:(o=i.googleApiStatus)==null?void 0:o.googleCalendarPrimaryId})}this.emit("onSyncInfoUpdated",new main_core.Event.BaseEvent({data:{syncInfo:e.data.syncInfo}}))}),(e=>{this.setStatus(this.STATUS_FAILED);this.setWizardState({status:this.ERROR_CODE,vendorName:this.type})}))}}class Office365Provider extends ConnectionProvider{constructor(e){super({id:e.syncInfo.id||null,status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,userName:e.syncInfo.userName||e.syncInfo.connectionName||"",gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_OFFICE365"),gridColor:"#fc1d1d",gridIcon:"/bitrix/images/calendar/sync/office365.svg",type:"office365",interfaceClassName:"",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.Office365template",mainPanel:true});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_OFFICE365");this.syncLink=e.syncLink||"";this.isSetSyncOffice365Settings=e.isSetSyncOffice365Settings;this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}getSyncLink(){return this.syncLink}hasSetSyncOffice365Settings(){return this.isSetSyncOffice365Settings}removeConnection(e){BX.ajax.runAction("calendar.api.syncajax.deactivateConnection",{data:{connectionId:e}}).then((()=>{BX.reload()}))}}class ICloudProvider extends ConnectionProvider{constructor(e){super({id:e.syncInfo.id||null,status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,userName:e.syncInfo.userName||"",gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_ICLOUD"),gridColor:"#948f8f",gridIcon:"/bitrix/images/calendar/sync/icloud.svg",type:"icloud",interfaceClassName:"",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.IcloudTemplate",mainPanel:true});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_ICLOUD");this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}}class AndroidProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_ANDROID"),gridColor:"#9ece03",gridIcon:"/bitrix/images/calendar/sync/android.svg",type:"android",viewClassification:"mobile",templateClass:"BX.Calendar.Sync.Interface.AndroidTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_ANDROID");this.setSyncDate(e.syncInfo.syncOffset);this.setConnections()}}class CaldavConnection extends ConnectionProvider{constructor(e){super(e)}static calculateStatus(e){if(e.length===0){return false}for(let t in e){if(this.isFailedConnections(e[t])){return false}}return true}static isFailedConnections(e){if(e.syncInfo.connected===true&&e.syncInfo.status===false){return true}return false}hasMenu(){return this.connected}showMenu(e){if(this.menu){this.menu.destroy()}const t=this.getMenuItems();t.push(...this.getMenuItemConnect());this.menu=this.getMenu(e,t);this.addMenuHandler();this.menu.show()}addMenuHandler(){if(this.menu){this.menu.getMenuContainer().addEventListener("click",(()=>{this.menu.close()}))}}getMenuItems(){const e=[];this.connections.forEach((t=>{t.type=this.type;t.id=t.addParams.id;t.text=t.connectionName;t.onclick=()=>{this.openActiveConnectionSlider(t)};e.push(t)}));return e}getMenuItemConnect(){return[{delimiter:true},{id:"connect",text:main_core.Loc.getMessage("ADD_MENU_CONNECTION"),onclick:()=>{this.openInfoConnectionSlider()}}]}getMenu(e,t){return new(window.top.BX||window.BX).Main.Menu({className:"calendar-sync-popup-status",bindElement:e,items:t,width:this.MENU_WIDTH,padding:this.MENU_PADDING,zIndexAbsolute:this.MENU_INDEX,autoHide:true,closeByEsc:true,id:this.getType()+"-menu",offsetLeft:-40})}setConnections(){if(this.connectionsSyncInfo.length>0){this.connectionsSyncInfo.forEach((e=>{this.connections.push(ConnectionItem.createInstance({connectionName:e.syncInfo.connectionName,status:e.syncInfo.status,connected:e.syncInfo.connected,addParams:{sections:e.sections,id:e.syncInfo.id,userName:e.syncInfo.userName,server:e.syncInfo.server},type:this.type}))}))}}}class CaldavProvider extends CaldavConnection{constructor(e){super({status:e.status,connected:e.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_CALDAV"),gridColor:"#1eae43",gridIcon:"/bitrix/images/calendar/sync/caldav.svg",type:"caldav",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.CaldavTemplate"});this.connectionsSyncInfo=e.connections;if(e.connections&&e.connections[0]&&e.connections[0].syncInfo){this.setSyncDate(e.connections[0].syncInfo.syncOffset)}this.setConnections()}}class ExchangeProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_EXCHANGE"),gridColor:"#54d0df",gridIcon:"/bitrix/images/calendar/sync/exchange.svg",type:"exchange",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.ExchangeTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_EXCHANGE");this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}}class IphoneProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_IPHONE"),gridColor:"#2fc6f6",gridIcon:"/bitrix/images/calendar/sync/iphone.svg",type:"iphone",viewClassification:"mobile",templateClass:"BX.Calendar.Sync.Interface.IphoneTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_IPHONE");this.setSyncDate(e.syncInfo.syncOffset);this.setConnections()}}class MacProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_MAC"),gridColor:"#ff5752",gridIcon:"/bitrix/images/calendar/sync/mac.svg",type:"mac",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.MacTemplate"});this.portalAddress=e.portalAddress;this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_MAC");this.setSyncDate(e.syncInfo.syncOffset);this.setConnections()}getPortalAddress(){return this.portalAddress}}class OutlookProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_OUTLOOK"),gridColor:"#ffa900",gridIcon:"/bitrix/images/calendar/sync/outlook.svg",type:"outlook",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.OutlookTemplate"});this.setSyncDate(e.syncInfo.syncOffset);this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_OUTLOOK");this.sections=e.sections;this.infoBySections=e.infoBySections;this.setConnections()}hasMenu(){return this.sections.length>0}showMenu(e){if(this.hasMenu()){if(this.menu){this.menu.destroy()}const t=this.getConnection().getSections();t.forEach((e=>{if(this.infoBySections[e.id]){e.className="calendar-sync-outlook-popup-item"}e.onclick=()=>{this.connectToOutlook(e)}}));this.menu=new(window.top.BX||window.BX).Main.Menu({className:"calendar-sync-popup-status",bindElement:e,items:t,padding:7,autoHide:true,closeByEsc:true,zIndexAbsolute:3020,id:this.getType()+"-menu",offsetLeft:-40});this.menu.getMenuContainer().addEventListener("click",(()=>{this.menu.close()}));this.menu.show()}}connectToOutlook(section){if(section.id){BX.ajax.runAction("calendar.api.syncajax.getOutlookLink",{data:{id:section.id}}).then((response=>{const url=response.data.result;eval(url)}))}}}class YandexProvider extends CaldavConnection{constructor(e){super({status:e.status,connected:e.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_YANDEX"),gridColor:"#f9c500",gridIcon:"/bitrix/images/calendar/sync/yandex.svg",type:"yandex",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.YandexTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_YANDEX");this.connectionsSyncInfo=e.connections;if(e.connections&&e.connections[0]&&e.connections[0].syncInfo){this.setSyncDate(e.connections[0].syncInfo.syncOffset)}this.setConnections()}}class Manager extends main_core_events.EventEmitter{constructor(e){super();this.status="not_connected";this.STATUS_SUCCESS="success";this.STATUS_FAILED="failed";this.STATUS_NOT_CONNECTED="not_connected";this.WIZARD_SYNC_MODE="wizard_sync_mode";this.STATUS_SYNCHRONIZING="synchronizing";this.WAITING_MODE_PERIODIC_TIMEOUT=5e3;this.REFRESH_DELAY=300;this.REFRESH_CONTENT_DELAY=300;this.WIZARD_SLIDER_PREFIX="calendar:sync-wizard";this.setEventNamespace("BX.Calendar.Sync.Manager.Manager");this.wrapper=e.wrapper;this.setSyncInfo(e.syncInfo);this.userId=e.userId;this.syncLinks=e.syncLinks;this.sections=e.sections;this.portalAddress=e.portalAddress;this.isRuZone=e.isRuZone;this.calendarInstance=e.calendar;this.isSetSyncGoogleSettings=e.isSetSyncGoogleSettings;this.isSetSyncOffice365Settings=e.isSetSyncOffice365Settings;this.refreshDebounce=main_core.Runtime.debounce(this.refresh,this.REFRESH_DELAY,this);this.refreshContentDebounce=main_core.Runtime.debounce(this.refreshContent,this.REFRESH_CONTENT_DELAY,this);this.init();this.subscribeOnEvent()}subscribeOnEvent(){main_core_events.EventEmitter.subscribe("BX.Calendar.Sync.Interface.SyncStatusPopup:onRefresh",(e=>{this.refreshDebounce(e)}));main_core_events.EventEmitter.subscribe("BX.Calendar.Sync.Interface.InterfaceTemplate:reDrawCalendarGrid",(e=>{this.reDrawCalendarGrid()}));window.addEventListener("message",(e=>{if(e.data.title==="googleOAuthSuccess"){window.location.reload()}}))}showSyncButton(){this.syncButton=new SyncButton({status:this.status,wrapper:this.wrapper,connectionsProviders:this.connectionsProviders,userId:this.userId});this.syncButton.show()}init(){this.connectionsProviders={};const e=[];const t=[];const n=this.syncInfo;this.sectionsByType=this.sortSections();for(let s in n){if(n.hasOwnProperty(s)){switch(n[s].type){case"yandex":e.push({syncInfo:n[s],sections:this.sectionsByType.caldav["caldav"+n[s].id],isRuZone:this.isRuZone});break;case"caldav":t.push({syncInfo:n[s],sections:this.sectionsByType.caldav["caldav"+n[s].id]});break}}}this.connectionsProviders={google:this.getGoogleProvider(),office365:this.getOffice365Provider(),icloud:this.getIcloudProvider(),caldav:this.getCaldavProvider(t),iphone:this.getIphoneProvider(),android:this.getAndroidProvider(),mac:this.getMacProvider()};if(this.isRuZone){this.connectionsProviders.yandex=this.getYandexProvider(e)}if(!BX.browser.IsMac()){this.connectionsProviders.outlook=this.getOutlookProvider()}if(n.hasOwnProperty("exchange")){this.connectionsProviders.exchange=this.getExchangeProvider()}this.status=this.getSummarySyncStatus();this.subscribeEventHandlers()}setSyncMode(e){this.syncMode=e}getSyncMode(){return this.syncMode}isWizardSyncMode(){for(let e in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(e)&&this.connectionsProviders[e].getWizardSyncMode()){return true}}return false}isSyncInProcess(){for(let e in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(e)&&this.connectionsProviders[e].getSyncStatus()===this.STATUS_SYNCHRONIZING){return true}}return false}sortSections(){const e=this.sections;const t=[];const n=[];const s=[];const i={};const o=[];const c=[];i.caldav={};e.forEach((e=>{if(e.belongsToView()&&e.data.OUTLOOK_JS&&e.data["EXTERNAL_TYPE"]==="local"){o.push({id:e.id,connectURL:e.data.OUTLOOK_JS,text:e.name})}if(e.data["IS_EXCHANGE"]===true){t.push(e.data)}else if(e.data["GAPI_CALENDAR_ID"]&&e.data["CAL_DAV_CON"]&&e.data["EXTERNAL_TYPE"]!=="local"){n.push(e.data)}else if(e.data["EXTERNAL_TYPE"]==="icloud"){s.push(e.data)}else if(e.data["EXTERNAL_TYPE"]==="office365"){c.push(e.data)}else if(e.data["CAL_DAV_CON"]&&e.data["CAL_DAV_CAL"]){i.caldav["caldav"+e.data["CAL_DAV_CON"]]=e.data}}));i.google=n;i.icloud=s;i.office365=c;i.exchange=t;i.outlook=o;return i}refresh(e){return new Promise((t=>{BX.ajax.runAction("calendar.api.syncajax.updateConnection",{data:{type:"user",requestUid:calendar_util.Util.registerRequestId()}}).then((n=>{this.setSyncInfo(n.data);this.status=this.getSummarySyncStatus();const s=e&&e.getTarget?e.getTarget():null;this.refreshContent(s);t()}))}))}refreshContent(e={}){this.init();this.refreshCalendarGrid();if(this.syncButton){this.syncButton.refresh(this.status);this.syncButton.setConnectionProviders(this.connectionsProviders)}if(e){this.refreshActivePopup(e);this.refreshOpenSliders(e)}}refreshCalendarGrid(){this.calendarInstance.reload()}refreshActivePopup(e){if(e instanceof SyncStatusPopup&&e.getId()==="calendar-syncPanel-status"){e.refresh(this.getConnections())}else if(this.syncButton.popup instanceof SyncStatusPopup&&this.syncButton.popup.getId()==="calendar-sync-button-status"){this.syncButton.popup.refresh(this.getConnections())}}refreshOpenSliders(e={}){const t=BX.SidePanel.Instance.getOpenSliders();if(t.length>0){t.forEach((t=>{if(t.getUrl()==="calendar:auxiliary-sync-slider"){this.refreshMainSlider(this.syncButton.getSyncPanel())}else if(t.getUrl().indexOf("calendar:item-sync-")!==-1){this.refreshConnectionSlider(t,e)}}))}}refreshConnectionSlider(e,t){let n=undefined;const s=e.getData().get("itemInterface");const i=e.getData().get("connection");if(i){n=this.connectionsProviders[i.getType()].getConnectionById(i.getId())}if(t instanceof SyncStatusPopup&&n){t.refresh([n])}if(s&&n){s.refresh(n)}e.reload()}refreshMainSlider(e){e.refresh(this.status,this.connectionsProviders)}getConnections(){const e=[];const t=Object.values(this.connectionsProviders);t.forEach((t=>{const n=t.getConnections();if(n.length>0){n.forEach((t=>{if(t.getConnectStatus()===true){e.push(t)}}))}}));return e}reDrawCalendarGrid(){this.calendarInstance.reloadDebounce()}updateSyncStatus(e){for(let t in e.syncInfo){if(e.syncInfo.hasOwnProperty(t)&&this.syncInfo[t]){this.syncInfo[t]={...this.syncInfo[t],...e.syncInfo[t]}}}this.status=this.STATUS_SUCCESS;this.refreshContentDebounce()}addSyncConnection(e){for(const t in e.syncInfo){if(["yandex","caldav"].includes(e.syncInfo[t].type)){BX.reload()}if(BX.Calendar.Util.checkRequestId(e.requestUid)){if(this.syncInfo[t]){this.syncInfo[t]={...this.syncInfo[t],...e.syncInfo[t]}}}}this.status=this.STATUS_SUCCESS;this.refreshContentDebounce()}deleteSyncConnection(e){if(!BX.Calendar.Util.checkRequestId(e.requestUid)){return}if(e.connectionId){for(const t in this.syncInfo){if(this.syncInfo.hasOwnProperty(t)&&this.syncInfo[t]&&parseInt(this.syncInfo[t].id)===parseInt(e.connectionId)){delete this.syncInfo[t]}}}if(e.syncInfo){for(const t in e.syncInfo){if(this.syncInfo[t]){delete this.syncInfo[t]}}}if(this.status!==this.STATUS_NOT_CONNECTED){this.status=this.STATUS_SUCCESS}this.refreshDebounce()}getProviderById(e){let t;for(let n in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(n)&&this.connectionsProviders[n].connected&&["google","caldav","yandex","icloud","office365"].includes(n)){t=this.connectionsProviders[n].getConnectionById(e);if(t){return[this.connectionsProviders[n],t]}}}return[undefined,undefined]}processSyncConnection(e){for(let t in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(t)&&this.connectionsProviders[t].getWizardSyncMode()&&t===(e==null?void 0:e.vendorName)){if(e.accountName){this.connectionsProviders[t].setUserName(e.accountName)}this.connectionsProviders[t].setWizardState(e);break}}}handlePullEvent(e){let t=this.isWizardSyncMode();switch(e.command){case"refresh_sync_status":if(!t){this.updateSyncStatus(e)}break;case"add_sync_connection":if(!t){this.addSyncConnection(e)}break;case"delete_sync_connection":if(!t){this.deleteSyncConnection(e)}break;case"process_sync_connection":if(t){this.processSyncConnection(e)}break}}setSyncInfo(e){this.syncInfo=e}subscribeEventHandlers(){for(let e in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(e)){this.connectionsProviders[e].unsubscribeAll("onStartWaitingMode");this.connectionsProviders[e].unsubscribeAll("onEndWaitingMode");this.connectionsProviders[e].unsubscribeAll("onCloseSyncWizard");this.connectionsProviders[e].subscribe("onStartWaitingMode",this.handleStartWaitingMode.bind(this));this.connectionsProviders[e].subscribe("onEndWaitingMode",this.handleEndWaitingMode.bind(this));this.connectionsProviders[e].subscribe("onCloseSyncWizard",this.handleCloseSyncWizard.bind(this))}}}handleCloseSyncWizard(){if(this.isSyncInProcess()){if(this.syncButton){this.syncButton.refresh(this.STATUS_SYNCHRONIZING)}}else{this.refreshContentDebounce()}}handleStartWaitingMode(){this.doPeriodicRefresh()}handleEndWaitingMode(){this.stopPeriodicRefresh()}doPeriodicRefresh(){if(!this.hasOpenedWizard()){return}if(calendar_util.Util.documentIsDisplayingNow()){this.refresh().then((()=>{this.refreshTimeout=setTimeout(this.doPeriodicRefresh.bind(this),this.WAITING_MODE_PERIODIC_TIMEOUT)}))}else{this.refreshTimeout=setTimeout(this.doPeriodicRefresh.bind(this),this.WAITING_MODE_PERIODIC_TIMEOUT)}}stopPeriodicRefresh(){if(this.refreshTimeout){clearInterval(this.refreshTimeout);this.refreshTimeout=null}}openSyncPanel(){this.syncButton.handleClick()}getSummarySyncStatus(){let e=this.STATUS_NOT_CONNECTED;for(let t in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(t)){if([this.STATUS_SUCCESS,this.STATUS_FAILED].includes(this.connectionsProviders[t].getStatus())){e=this.connectionsProviders[t].getStatus();break}}}return e}getGoogleProvider(){if(!this.googleProvider){this.googleProvider=GoogleProvider.createInstance({syncInfo:this.syncInfo.google||{},sections:this.sectionsByType.google||{},syncLink:this.syncLinks.google||null,isSetSyncGoogleSettings:this.isSetSyncGoogleSettings,mainPanel:true})}else{this.googleProvider.refresh({syncInfo:this.syncInfo.google||{},sections:this.sectionsByType.google||{},syncLink:this.syncLinks.google||null})}return this.googleProvider}getOffice365Provider(){if(!this.office365Provider){this.office365Provider=Office365Provider.createInstance({syncInfo:this.syncInfo.office365||{},sections:this.sectionsByType.office365||{},syncLink:this.syncLinks.office365||null,isSetSyncOffice365Settings:this.isSetSyncOffice365Settings,mainPanel:true})}else{this.office365Provider.refresh({syncInfo:this.syncInfo.office365||{},sections:this.sectionsByType.office365||{},syncLink:this.syncLinks.office365||null})}return this.office365Provider}getIcloudProvider(){if(!this.icloudProvider){this.icloudProvider=ICloudProvider.createInstance({syncInfo:this.syncInfo.icloud||{},sections:this.sectionsByType.icloud||{},mainPanel:true})}else{this.icloudProvider.refresh({syncInfo:this.syncInfo.icloud||{},sections:this.sectionsByType.icloud||{}})}return this.icloudProvider}getCaldavProvider(e){return CaldavProvider.createInstance({status:CaldavConnection.calculateStatus(e),connected:e.length>0,connections:e})}getIphoneProvider(){return IphoneProvider.createInstance({syncInfo:this.syncInfo.iphone})}getAndroidProvider(){return AndroidProvider.createInstance({syncInfo:this.syncInfo.android})}getMacProvider(){return MacProvider.createInstance({syncInfo:this.syncInfo.mac,portalAddress:this.portalAddress})}getYandexProvider(e){return YandexProvider.createInstance({status:CaldavConnection.calculateStatus(e),connected:e.length>0,connections:e})}getOutlookProvider(){return OutlookProvider.createInstance({syncInfo:this.syncInfo.outlook,sections:this.sectionsByType.outlook,infoBySections:this.syncInfo.outlook.infoBySections||{}})}getExchangeProvider(){return ExchangeProvider.createInstance({syncInfo:this.syncInfo.exchange,sections:this.sectionsByType.exchange})}hasOpenedWizard(){const e=BX.SidePanel.Instance.getOpenSliders();for(let t in e){if(e.hasOwnProperty(t)&&e[t].getUrl().indexOf(this.WIZARD_SLIDER_PREFIX)!==-1){return true}}return false}}exports.Manager=Manager;exports.SyncButton=SyncButton;exports.SyncStatusPopup=SyncStatusPopup;exports.ConnectionItem=ConnectionItem})(this.BX.Calendar.Sync.Manager=this.BX.Calendar.Sync.Manager||{},BX.Main,BX.Event,BX.Calendar,BX); //# sourceMappingURL=manager.bundle.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings