You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.3 KiB
JavaScript
112 lines
3.3 KiB
JavaScript
function typeInput(a) {
|
|
var ct = div().class('form-group');
|
|
if (a.line != undefined) {
|
|
ct.css({
|
|
display: 'grid',
|
|
gridTemplateColumns: (function (a) {
|
|
if (Number.isInteger(a) === true) {
|
|
return a + `px auto`
|
|
} else {
|
|
return `80px auto`
|
|
}
|
|
})(a.line)
|
|
})
|
|
}
|
|
ct.child(
|
|
el('label').html(a.title).attr('for', a.name).css({
|
|
display: 'flex',
|
|
alignItems: 'center'
|
|
})
|
|
)
|
|
var inpt = el('input');
|
|
inpt.height('38px');
|
|
inpt = inpt;
|
|
inpt.type(a.type);
|
|
if(a.type === 'date'){
|
|
inpt.type('text');
|
|
}
|
|
inpt.class('form-control form-d').name(a.name).id(a.name).hold('...')
|
|
.css('height', '38px');
|
|
if (a.readonly == true) {
|
|
inpt.attr('readonly', 'true')
|
|
.css({
|
|
background: '#2E7D32',
|
|
color: '#fff'
|
|
});
|
|
}
|
|
if (a.type == 'date') {
|
|
inpt.addModule("a",a);
|
|
if(a.readonly === true){
|
|
inpt.attr('disabled',true);
|
|
}
|
|
inpt.data("type",'date');
|
|
inpt.load(function (e) {
|
|
var a = e.el.a;
|
|
$(" .form-d#" + a.name).mask("00-00-0000");
|
|
$(" .form-d#"+a.name).datepicker({ format: 'dd-mm-yyyy' });
|
|
e.el.max = new Date().toISOString().split("T")[0];
|
|
e.el.addEventListener('keyup', delay(function () {
|
|
if (tanggal(this.value).milisecond > tanggal().milisecond) {
|
|
this.value = tanggal().normal;
|
|
|
|
}
|
|
if(a.action != undefined){
|
|
a.action(this.value);
|
|
}
|
|
}, 500))
|
|
e.el.addEventListener('change', function () {
|
|
if (tanggal(this.value).milisecond > tanggal().milisecond) {
|
|
this.value = tanggal().normal;
|
|
|
|
}
|
|
if(a.action != undefined){
|
|
a.action(this.value);
|
|
}
|
|
})
|
|
})
|
|
}
|
|
if(a.type == 'date'){
|
|
ct.child(
|
|
div()
|
|
.css({
|
|
display: 'grid',
|
|
gridTemplateColumns: 'auto 45px'
|
|
})
|
|
.child(
|
|
inpt
|
|
)
|
|
.child(
|
|
div().css({
|
|
display: 'flex',
|
|
background: '#dddddd',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
cursor: 'pointer',
|
|
}).child(
|
|
i().class('la la-calendar')
|
|
)
|
|
.addModule('dataid', a.name)
|
|
.click(function(){
|
|
let id = this.dataid;
|
|
if(typeof _Help != 'undefined'){
|
|
_Help.getLabel(id).click()
|
|
}
|
|
})
|
|
)
|
|
);
|
|
}else{
|
|
ct.child(
|
|
inpt
|
|
);
|
|
}
|
|
if (a.info != undefined && typeof a.info === 'string') {
|
|
ct.child(
|
|
el('small').css('font-style', 'italic').html(a.info)
|
|
);
|
|
};
|
|
var dv = div().class('col-md-' + a.row).child(ct)
|
|
if (a.display != undefined) {
|
|
dv.css({ display: a.display })
|
|
}
|
|
return dv.get();
|
|
} |