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/ui/info-helper/src/providers/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/ui/info-helper/src/providers/popup-provider.js
import { Type } from 'main.core';
import { PopupWithHeader, SaleTemplate } from 'ui.popup-with-header';
import { ProviderRequestFactory } from '../provider-request-factory';
import type { PopupProviderConfiguration } from '../types/configurations';
import { ProvidersType } from '../types/providers-type';
import { Analytics } from '../analytics';
import { BaseProvider } from './base-provider';

export class PopupProvider extends BaseProvider
{
	#dataSource: Promise;
	#bindElement: HTMLElement;
	#popup: PopupWithHeader;
	#code: string;
	#analytics: Analytics;

	constructor(config: PopupProviderConfiguration)
	{
		super();

		if (Type.isDomNode(config.bindElement))
		{
			this.#bindElement = config.bindElement;
		}
		else
		{
			throw new Error("Invalid parameter 'bindElement'");
		}

		if (Type.isString(config.code))
		{
			this.#code = config.code;
		}
		else
		{
			throw new Error("Invalid parameter 'code'");
		}

		if (config.dataSource && config.dataSource instanceof Promise)
		{
			this.#dataSource = config.dataSource;
		}
		else
		{
			const providerRequestFactoryConfiguration = {
				type: ProvidersType.POPUP,
				code: this.#code,
				featureId: config.featureId,
			};
			this.#dataSource = (new ProviderRequestFactory(providerRequestFactoryConfiguration)).getRequest();
		}

		this.#analytics = new Analytics(this.#code, ProvidersType.POPUP);
	}

	show(code, params): void
	{
		this.#getPopup().show();
		this.#analytics.sendByEventName('show');
	}

	close()
	{
		this.#getPopup().close();
		this.#analytics.sendByEventName('close');
	}

	#getPopup(): PopupWithHeader
	{
		if (!this.#popup)
		{
			this.#popup = new PopupWithHeader({
				target: this.#bindElement,
				id: `demo-popup-components-maker-${Math.random(8)}`,
				width: 344,
				content: [],
				asyncData: this.#dataSource,
				template: new SaleTemplate(),
				analyticsCallback: (event, additionalParameter) => {
					if (this.#analytics)
					{
						this.#analytics.sendByEventName(event, additionalParameter);
					}
				},
			});
		}

		return this.#popup;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit