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/sign-up/src/tabs/ |
Upload File : |
import {EventEmitter} from 'main.core.events'; import {Tag, Cache, Text, Dom} from 'main.core'; import type {TabOptions} from './types/tabs-options'; import typeof {Content} from '../content/content'; import './css/tab.css'; export class Tab extends EventEmitter { cache = new Cache.MemoryCache(); constructor(options: TabOptions) { super(); this.setOptions(options); this.setEventNamespace('BX.UI.SignUp.Tabs.Tab'); this.subscribeFromOptions(options.events); } setOptions(options: TabOptions) { this.cache.set('options', {...options}); } getOptions(): TabOptions { return this.cache.get('options', {}); } getIconNode(): HTMLSpanElement { return this.cache.remember('iconNode', () => { return Tag.render` <span style="background-image: url('${this.getOptions().icon}');"></span> `; }); } getHeaderLayout(): HTMLDivElement { return this.cache.remember('headerLayout', () => { return Tag.render` <div class="ui-sign-up-tabs-tab-header" data-id="${Text.encode(this.getOptions().id)}" onclick="${this.onHeaderClick.bind(this)}" > <div class="ui-sign-up-tabs-tab-header-icon"> ${this.getIconNode()} </div> <div class="ui-sign-up-tabs-tab-header-text"> <span>${this.getOptions().header}</span> </div> </div> `; }); } onHeaderClick(event: MouseEvent) { event.preventDefault(); this.emit('onHeaderClick'); } getContent(): Content { return this.getOptions().content; } activate() { Dom.addClass(this.getHeaderLayout(), 'ui-sign-up-tabs-tab-header-active'); Dom.style(this.getIconNode(), { 'background-image': `url('${this.getOptions().activeIcon}')` }); } deactivate() { Dom.removeClass(this.getHeaderLayout(), 'ui-sign-up-tabs-tab-header-active'); Dom.style(this.getIconNode(), { 'background-image': `url('${this.getOptions().icon}')` }); } isActive(): boolean { return Dom.hasClass(this.getHeaderLayout(), 'ui-sign-up-tabs-tab-header-active'); } }