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.

72 lines
1.8 KiB
JavaScript

function typeNumber(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').type('text')
.class('form-control form-d').name(a.name).id(a.name).hold('0').css({
textAlign: 'right',
height: '38px'
})
if (a.readonly == true) {
inpt.attr('readonly', 'true')
.css({
background: '#2E7D32',
color: '#fff'
});
}
if (a.bold == true) {
inpt.css('font-weight', 'bold')
}
inpt.addModule('a', a)
inpt.load(function (e) {
e.el.addEventListener('keyup', function () {
var c = this.value;
var a = this.a;
var pis = c.length - 1;
if (c[pis] == ".") {
c = c.substr(0, pis) + ",";
}
c = c.replace(/\./g, "");
this.value = formatRupiah(c, "");
if (a.action != undefined) {
a.action(this.value.number())
}
}, false)
})
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();
}