![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /proc/thread-self/root/var/www/html/libs/absol-form/js/components/ |
Upload File : |
import FCore from "../core/FCore"; import ScalableComponent from "../core/ScalableComponent"; import {beginOfDay, compareDate} from "absol/src/Time/datetime"; import OOP from "absol/src/HTML5/OOP"; import inheritComponentClass from "../core/inheritComponentClass"; import InputAttributeHandlers, {InputAttributeNames} from "./handlers/InputAttributeHandlers"; import {AssemblerInstance} from "../core/Assembler"; var _ = FCore._; /*** * @extends ScalableComponent * @constructor */ function DateInput() { ScalableComponent.call(this); } inheritComponentClass(DateInput, ScalableComponent); DateInput.prototype.tag = "DateInput"; DateInput.prototype.menuIcon = "span.mdi.mdi-calendar-edit"; DateInput.prototype.SUPPORT_EVENT_NAMES = ['change']; Object.assign(DateInput.prototype.attributeHandlers, InputAttributeHandlers); DateInput.prototype.attributeHandlers.value = { set: function (value) { var prev = this.domElt.value; if (value instanceof Date) this.domElt.value = value; else if (typeof value == 'string' || typeof value == "number") { value = new Date(value); this.domElt.value = value; } else { value = null; this.domElt.value = null; } var cur = this.domElt.value; if (!!prev !== !!cur || (prev && cur && compareDate(prev, cur) !== 0)) this.pinFire('value'); }, get: function () { return this.view.value; }, descriptor: { type: 'date', nullable: true, defaultValue: beginOfDay(new Date()), sign: 'SimpleDate' } }; DateInput.prototype.attributeHandlers.format = { set: function (value) { this.domElt.format = value || 'dd/MM/yyyy'; }, get: function () { return this.domElt.format; }, descriptor:{ type:'enum', values:['dd/MM/yyyy', 'MM/dd/yyyy', 'yyyy/MM/dd','dd-MM-yyyy', 'MM-dd-yyyy', 'MM/yyyy', 'MM-yyyy', 'yyyy'] } }; DateInput.prototype.pinHandlers.min = { receives: function (value) { this.domElt.min = value; }, descriptor: { type: "Date" } }; DateInput.prototype.pinHandlers.max = { receives: function (value) { this.domElt.max = value; }, descriptor: { type: "Date" } }; DateInput.prototype.pinHandlers.value = { receives: function (value) { this.attributes.value = value; }, get: function () { return this.domElt.value; }, descriptor: { type: "Date" } }; DateInput.prototype.render = function () { return _('dateinput'); }; DateInput.prototype.onCreate = function () { ScalableComponent.prototype.onCreate.call(this); this.attributes.value = null; this.style.width = 100; this.style.height = 30; }; DateInput.prototype.onCreated = function () { ScalableComponent.prototype.onCreated.call(this); this.domElt.on('change', this.ev_inputChange.bind(this)); }; DateInput.prototype.getAcceptsEventNames = function () { return ScalableComponent.prototype.getAcceptsEventNames.call(this).concat(['change']); }; DateInput.prototype.measureMinSize = function () { return { width: 75, height: 16 }; }; DateInput.prototype.createDataBindingDescriptor = function () { var thisC = this; return { configurable: true, set: function (value) { thisC.setAttribute('value', value); }, get: function () { return thisC.getAttribute('value'); } }; }; DateInput.prototype.ev_inputChange = function () { this.pinFire('value'); }; AssemblerInstance.addClass(DateInput); export default DateInput;