%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.15.4.52 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/landing/ui/field/ |
Upload File : |
;(function() { "use strict"; BX.namespace("BX.Landing.UI.Field"); var create = BX.Landing.Utils.create; var bind = BX.Landing.Utils.bind; var fireCustomEvent = BX.Landing.Utils.fireCustomEvent; var FORMAT_SECONDS = "s"; var FORMAT_MILLISECONDS = "ms"; /** * Implements interface for works with date field * * @extends {BX.Landing.UI.Field.BaseField} * * @inheritDoc * @constructor */ BX.Landing.UI.Field.Date = function(data) { data.textOnly = true; BX.Landing.UI.Field.BaseField.apply(this, arguments); this.format = data.format === FORMAT_SECONDS || data.format === FORMAT_MILLISECONDS ? data.format : FORMAT_SECONDS; this.time = data.time === true; this.hiddenInput = create("input", {props: {type: "hidden"}, value: data.content}); bind(this.input, "click", this.onInputClick.bind(this)); this.setValue(this.formatDateToValue(data.content)); }; BX.Landing.UI.Field.Date.prototype = { constructor: BX.Landing.UI.Field.Date, __proto__: BX.Landing.UI.Field.BaseField.prototype, /** * Handles input click event */ onInputClick: function() { var params = { node: this.input, field: this.hiddenInput, bTime: this.time, value: BX.date.format(this.getFormat(), new Date(this.formatDateToValue(this.hiddenInput.value) * 1000)), bHideTime: !this.time, callback_after: function(date) { this.setValue(date.getTime() / 1000); }.bind(this) }; return BX.calendar(params); }, getFormat: function() { return BX.date.convertBitrixFormat(BX.Landing.Loc.getMessage(this.time ? "FORMAT_DATETIME" : "FORMAT_DATE")); }, reset: function() { this.setValue(""); }, /** * @param {Integer|string} value - timestamp in seconds */ setValue: function(value) { if (value) { this.input.innerText = BX.date.format(this.getFormat(), new Date(value * 1000)); this.hiddenInput.value = this.formatValue(value); this.onValueChangeHandler(this); var event = new BX.Event.BaseEvent({ data: {value: this.getValue()}, compatData: [this.getValue()], }); this.emit('change', event); } }, /** * Format seconds * @param value * @return {integer} */ formatValue: function(value) { switch (this.format) { case FORMAT_SECONDS: return value; case FORMAT_MILLISECONDS: return value * 1000; default: break; } }, /** * To seconds * @param formattedValue * @return {*} */ formatDateToValue: function(formattedValue) { switch (this.format) { case FORMAT_SECONDS: return formattedValue; case FORMAT_MILLISECONDS: return formattedValue / 1000; default: break; } }, getValue: function() { return this.formatValue(this.formatDateToValue(this.hiddenInput.value)); }, clone: function(fieldData) { var data = Object.assign( {}, fieldData || this.data, {content: (new Date()).getTime()} ); var field = new this.constructor(data); if (this.type) { field.type = this.type; } return field; } } })();