403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/calendar/sync/interface/src/controls/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/calendar/sync/interface/src/controls/statusblock.js
// @flow
'use strict';

import {Loc, Tag} from "main.core";
import {SyncStatusPopup} from "calendar.sync.manager";

export default class StatusBlock
{
	constructor(options)
	{
		this.status = options.status;
		this.connections = options.connections;
		this.withStatusLabel = options.withStatusLabel;
		this.popupWithUpdateButton = options.popupWithUpdateButton;
		this.popupId = options.popupId;
	}

	static createInstance(options)
	{
		return new this(options);
	}

	setStatus(status)
	{
		this.status = status;

		return this;
	}

	setConnections(connections)
	{
		this.connections = connections;

		return this;
	}

	getContent()
	{
		let statusInfoBlock;
		if (this.status === 'success')
		{
			statusInfoBlock = Tag.render `
				<div id="status-info-block" class="ui-alert ui-alert-success calendar-sync-status-info">
					<span class="ui-alert-message">${Loc.getMessage('SYNC_STATUS_SUCCESS')}</span>
				</div>
			`;
		}
		else if (this.status === 'failed')
		{
			statusInfoBlock = Tag.render `
				<div id="status-info-block" class="ui-alert ui-alert-danger calendar-sync-status-info">
					<span class="ui-alert-message">${Loc.getMessage('SYNC_STATUS_ALERT')}</span>
				</div>
			`;
		}
		else
		{
			statusInfoBlock = Tag.render `
				<div id="status-info-block" class="ui-alert ui-alert-primary calendar-sync-status-info">
					<span class="ui-alert-message">${Loc.getMessage('SYNC_STATUS_NOT_CONNECTED')}</span>
				</div>
			`;
		}

		statusInfoBlock.addEventListener('mouseenter', () => {
			this.handlerMouseEnter(statusInfoBlock);
		});

		statusInfoBlock.addEventListener('mouseleave', () => {
			this.handlerMouseLeave();
		});

		this.statusBlock = Tag.render `
			<div class="calendar-sync-status-block" id="calendar-sync-status-block">
				${this.getStatusTextLabel()}
				${statusInfoBlock}
			</div>
		`;

		return this.statusBlock;
	}

	getStatusTextLabel()
	{
		return this.withStatusLabel
			? Tag.render`
				<div class="calendar-sync-status-subtitle">
					<span data-hint=""></span>
					<span class="calendar-sync-status-text">${Loc.getMessage('LABEL_STATUS_INFO')}:</span>
				</div>`
			: ''
		;
	}

	handlerMouseEnter(statusBlock)
	{
		clearTimeout(this.statusBlockEnterTimeout);
		this.buttonEnterTimeout = setTimeout(() =>
			{
				this.statusBlockEnterTimeout = null;
				this.showPopup(statusBlock);
			}, 500
		);
	}

	handlerMouseLeave()
	{
		if (this.statusBlockEnterTimeout !== null)
		{
			clearTimeout(this.statusBlockEnterTimeout);
			this.statusBlockEnterTimeout = null;
			return;
		}

		this.statusBlockLeaveTimeout = setTimeout(() =>
			{
				this.hidePopup();
			}, 500
		);
	}

	showPopup(node)
	{
		if(this.status !== 'not_connected')
		{
			this.popup = this.getPopup(node);
			this.popup.show();

			this.addPopupHandlers();
		}
	}

	hidePopup()
	{
		if (this.popup)
		{
			this.popup.hide();
		}
	}

	addPopupHandlers()
	{
		this.popup.getPopup().getPopupContainer().addEventListener('mouseenter', () =>
		{
			clearTimeout(this.statusBlockEnterTimeout);
			clearTimeout(this.statusBlockLeaveTimeout);
		});

		this.popup.getPopup().getPopupContainer().addEventListener('mouseleave', () =>
		{
			this.hidePopup();
		});
	}

	getPopup(node)
	{
		return SyncStatusPopup.createInstance({
			connections: this.connections,
			withUpdateButton: this.popupWithUpdateButton,
			node: node,
			id: this.popupId,
		});
	}

	refresh(status, connections)
	{
		this.status = status;
		this.connections = connections;

		return this;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit