Your IP : 3.145.99.240


Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/ui/accessrights/src/item/
Upload File :
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/ui/accessrights/src/item/changer.js

import {EventEmitter} from "main.core.events";
import {Dom, Tag} from "main.core";
import Base from "./base";
import ColumnItemOptions from "../columnitem";

export default class Changer extends Base
{
	constructor(options: ColumnItemOptions)
	{
		super(options);

		this.isModify = false;
	}

	getChanger(): HTMLElement
	{
		if (!this.changer)
		{
			this.changer = Tag.render`<a class='ui-access-rights-column-item-changer'></a>`
		}

		return this.changer;
	}

	bindEvents(): void
	{
		EventEmitter.subscribe('BX.UI.AccessRights:reset', this.offChanger.bind(this));
		EventEmitter.subscribe('BX.UI.AccessRights:refresh', this.refreshStatus.bind(this));
	}

	refreshStatus(): void
	{
		Dom.removeClass(this.getChanger(), 'ui-access-rights-column-item-changer-on')
	}

	offChanger(): void
	{
		if (this.isModify)
		{
			setTimeout(() => {
				this.refreshStatus();
			});
		}
	}

	adjustChanger(): void
	{
		this.isModify = !this.isModify;

		Dom.toggleClass(this.getChanger(), 'ui-access-rights-column-item-changer-on');
	}
}