%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.145.43.161
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/ui/cnt/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/ui/cnt/src/cnt.js
// @flow

import {Dom, Tag, Type} from 'main.core';
import CounterColor from './cnt-color';
import CounterSize from './cnt-size';

type CounterOptions = {
	value: number;
	maxValue: number;
	color: CounterColor;
	size: string;
};

export default class Counter
{
	static Color = CounterColor;
	static Size = CounterSize;

	constructor(options: CounterOptions)
	{
		this.options = Type.isPlainObject(options) ? options : {};

		this.container = null;
		this.counterContainer = null;
		this.animate = Type.isBoolean(this.options.animate) ? this.options.animate : false;
		this.value = Type.isNumber(this.options.value) ? this.options.value : 0;
		this.maxValue = Type.isNumber(this.options.maxValue) ? this.options.maxValue : 99;
		this.size = Type.isString(this.options.size) ? this.options.size : BX.UI.Counter.Size.MEDIUM;
		this.color = Type.isString(this.options.color) ? this.options.color : BX.UI.Counter.Color.PRIMARY;
	}

	//region Parameters
	setValue(value: number): this
	{
		if (Type.isNumber(value))
		{
			this.value = (value < 0) ? 0 : value;
		}

		return this;
	}

	getValue(): number
	{
		if (this.value < this.maxValue)
		{
			return this.value;
		}
		else
		{
			return this.maxValue + "+";
		}
	}

	setMaxValue(value: number): this
	{
		if (Type.isNumber(value))
		{
			this.value = (value < 0) ? 0 : value;
		}

		return this;
	}

	getMaxValue(): number
	{
		return this.maxValue;
	}

	setColor(color: CounterColor): this
	{
		if (Type.isStringFilled(color))
		{
			if (this.container === null)
			{
				this.createContainer();
			}

			Dom.removeClass(this.container, this.color);
			this.color = color;
			Dom.addClass(this.container, this.color);
		}

		return this;
	}

	setSize(size: CounterSize): this
	{
		if (Type.isStringFilled(size))
		{
			BX.removeClass(this.container, this.size);
			this.size = size;
			BX.addClass(this.container, this.size);
		}

		return this;
	}

	setAnimate(animate: boolean): this
	{
		if (Type.isBoolean(animate))
		{
			this.animate = animate;
		}

		return this;
	}

	//endregion

	// region Counter
	update(value)
	{
		if (this.container === null)
		{
			this.createContainer();
		}

		if (this.animate == true)
		{
			this.updateAnimated(value);
		}
		else if (this.animate == false)
		{
			this.setValue(value);
			Dom.adjust(this.counterContainer, {
				text: this.getValue()
			});
		}

	}

	updateAnimated(value)
	{
		if (this.container === null)
		{
			this.createContainer();
		}

		if (value > this.value && this.value < this.maxValue)
		{
			Dom.addClass(this.counterContainer, "ui-counter-plus");
		}
		else if (value < this.value && this.value < this.maxValue)
		{
			Dom.addClass(this.counterContainer, "ui-counter-minus");
		}

		setTimeout(function ()
			{
				this.setValue(value);
				Dom.adjust(this.counterContainer, {
					text: this.getValue()
				});
			}.bind(this),
			250);

		setTimeout(function ()
			{
				Dom.removeClass(this.counterContainer, "ui-counter-plus");
				Dom.removeClass(this.counterContainer, "ui-counter-minus");
			}.bind(this),
			500);
	}

	show()
	{
		if (this.container === null)
		{
			this.createContainer();
		}

		Dom.addClass(this.container, "ui-counter-show");
		Dom.removeClass(this.container, "ui-counter-hide");
	}

	hide()
	{
		if (this.container === null)
		{
			this.createContainer();
		}

		Dom.addClass(this.container, "ui-counter-hide");
		Dom.removeClass(this.container, "ui-counter-show");
	}

	getCounterContainer()
	{
		if (this.counterContainer === null)
		{
			this.counterContainer = Tag.render`
				<div class="ui-counter-inner">${this.value}</div>
			`;
		}

		return this.counterContainer;
	}

	createContainer(): HTMLElement
	{
		if (this.container === null)
		{
			this.container = Tag.render`
				<div class="ui-counter">${this.getCounterContainer()}</div>
			`;

			this.setSize(this.size);
			this.setColor(this.color);
		}

		return this.container;
	}

	//endregion

	getContainer(): Element
	{
		if (this.container === null)
		{
			this.createContainer();
		}

		return this.container;
	}

	renderTo(node: HTMLElement): HTMLElement | null
	{
		if (Type.isDomNode(node))
		{
			return node.appendChild(this.getContainer());
		}

		return null;
	}

	destroy(): void
	{
		Dom.remove(this.container);
		this.container = null;
		this.finished = false;
		this.textAfterContainer = null;
		this.textBeforeContainer = null;
		this.bar = null;
		this.svg = null;

		for (const property in this)
		{
			if (this.hasOwnProperty(property))
			{
				delete this[property];
			}
		}

		Object.setPrototypeOf(this, null);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit