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/short-view/src/ |
Upload File : |
import { Dom, Type, Loc } from 'main.core'; import { EventEmitter } from 'main.core.events'; import { SplitButton, ButtonSize, ButtonColor } from 'ui.buttons'; import { SwitcherColor } from 'ui.switcher'; type Params = { isShortView: 'Y' | 'N' } export class ShortView extends EventEmitter { constructor(params: Params) { super(params); this.setEventNamespace('BX.UI.ShortView'); this.setShortView(params.isShortView); this.node = null; } renderTo(container: HTMLElement) { if (!Type.isDomNode(container)) { throw new Error('UI ShortView: HTMLElement not found'); } Dom.append(this.render(), container); } render(): HTMLElement { const checked = (this.getShortView() === 'Y'); this.node = new SplitButton({ text: Loc.getMessage('UI_SHORT_VIEW_LABEL'), round: true, size: ButtonSize.SMALL, color: ButtonColor.LIGHT_BORDER, className: 'ui-btn-themes', mainButton: { onclick: (button: SplitButton, event: MouseEvent) => { event.preventDefault(); this.node.getSwitcher().toggle(); }, }, switcher: { checked, color: SwitcherColor.primary, handlers: { toggled: () => this.onChange(), }, }, }); return this.node.render(); } setShortView(value: string) { this.shortView = (value === 'Y' ? 'Y' : 'N'); } getShortView(): 'Y' | 'N' { return this.shortView; } onChange() { this.setShortView(this.node.getSwitcher().isChecked() ? 'Y' : 'N'); this.emit('change', this.getShortView()); } }