%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.14.129.43 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/label/src/ |
Upload File : |
// @flow import {Dom, Tag, Type} from 'main.core'; import LabelColor from './label-color'; import LabelSize from './label-size'; type LabelOptions = { text: string; color: LabelColor; size: LabelSize; link: string; fill: boolean; customClass: string; icon: Object; }; export default class Label { static Color = LabelColor; static Size = LabelSize; text: string; color: string; size: string; link: string; fill: boolean; customClass: string; icon: Object; constructor(options: LabelOptions) { this.text = options.text; this.color = options.color; this.size = options.size; this.link = options.link; this.icon = options.icon; this.fill = !!options.fill ? true : options.fill; this.customClass = options.customClass; this.classList = "ui-label"; this.setText(this.text); this.setLink(this.link); this.setColor(this.color); this.setFill(this.fill); this.setCustomClass(this.customClass); } //region COLOR setColor(color: string) { this.color = color; this.setClassList(); } getColor() { return this.color; } // endregion //region FILL setFill(fill: boolean) { this.fill = !!fill ? true : false; this.setClassList(); } getFill() { return this.fill; } // endregion //region SIZE setSize(size: string) { this.size = size; this.setClassList(); } getSize() { return this.size; } // endregion //region LINK setLink(link: string) { this.link = link; } getLink() { return this.link; } // endregion //region TEXT setText(text: string): this { this.text = text; if (Type.isStringFilled(text)) { this.getTextContainer().textContent = text; } } getText() { return this.text; } getTextContainer() { if (!this.textContainer) { this.textContainer = Tag.render`<span class="ui-label-inner">${this.getText()}</span>`; } return this.textContainer; } // endregion //region CUSTOM CLASS setCustomClass(customClass: string) { this.customClass = customClass; this.updateClassList(); } getCustomClass() { return this.customClass; } // endregion //region CLASS LIST setClassList() { this.classList = "ui-label"; if(typeof this.getColor() != "undefined") { this.classList = this.classList + " " + this.color; } if(typeof this.getSize() != "undefined") { this.classList = this.classList + " " + this.size; } if(typeof this.getCustomClass() != "undefined") { this.classList = this.classList + " " + this.customClass; } if(this.fill) { this.classList = this.classList + " ui-label-fill"; } this.updateClassList() } getClassList() { return this.classList; } updateClassList() { if (!this.container) { this.getContainer() } this.container.setAttribute("class", this.classList); } getIconAction() { this.iconNode = Tag.render`<div class="ui-label-icon"></div>`; for(let key in this.icon) { this.iconNode.addEventListener(key, this.icon[key]) } return this.iconNode; } // endregion getContainer() { if(!this.container) { if (this.getLink()) { this.container = Tag.render`<a href="${this.link}" class="${this.getClassList()}">${this.getTextContainer()}</a>`; } else { this.container = Tag.render`<div class="${this.getClassList()}">${this.getTextContainer()}</div>`; } if (typeof this.icon === 'object') { this.container.appendChild(this.getIconAction()); } } return this.container; } render(): HTMLElement { return this.getContainer(); } }