Files
CKB/public/js/init.js

98 lines
2.6 KiB
JavaScript
Executable File

"use strict";
function moneyFormat(n, currency) {
n = n != null ? n : 0;
var v = parseFloat(n).toFixed(0);
return (
currency +
" " +
v.replace(/./g, function (c, i, a) {
return i > 0 && c !== "," && (a.length - i) % 3 === 0 ? "." + c : c;
})
);
}
var KTToastr = (function () {
var successToastr = function (msg, title) {
toastr.options = {
closeButton: true,
debug: false,
newestOnTop: false,
progressBar: false,
positionClass: "toast-top-right",
preventDuplicates: true,
onclick: null,
showDuration: "500",
hideDuration: "500",
timeOut: "3000",
extendedTimeOut: "3000",
showEasing: "swing",
hideEasing: "swing",
showMethod: "fadeIn",
hideMethod: "fadeOut",
};
var $toast = toastr["success"](msg, title);
if (typeof $toast === "undefined") {
return;
}
};
var errorToastr = function (msg, title) {
toastr.options = {
closeButton: true,
debug: false,
newestOnTop: false,
progressBar: false,
positionClass: "toast-top-right",
preventDuplicates: true,
onclick: null,
showDuration: "500",
hideDuration: "500",
timeOut: "3000",
extendedTimeOut: "3000",
showEasing: "swing",
hideEasing: "swing",
showMethod: "fadeIn",
hideMethod: "fadeOut",
};
var $toast = toastr["error"](msg, title);
if (typeof $toast === "undefined") {
return;
}
};
return {
initSuccess: function (msg, title) {
successToastr(msg, title);
},
initError: function (msg, title) {
errorToastr(msg, title);
},
};
})();
jQuery(document).ready(function () {
var li = $(".kt-menu__item--active");
li.closest("li.kt-menu__item--submenu").addClass("kt-menu__item--open");
// Initialize Select2 globally
if (typeof $.fn.select2 !== "undefined") {
$(".select2").select2({
theme: "bootstrap4",
width: "100%",
});
}
// Initialize DatePicker globally
if (typeof $.fn.datepicker !== "undefined") {
$(".datepicker").datepicker({
format: "yyyy-mm-dd",
autoclose: true,
todayHighlight: true,
orientation: "bottom auto",
});
}
});