94 lines
3.2 KiB
JavaScript
94 lines
3.2 KiB
JavaScript
/*******************************************************************
|
|
|
|
Module : /apps/js/index.js
|
|
Desc. : JS - Halaman Utama Desktop
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : May 24th, 2010.
|
|
Last Modified : August 15th, 2019.
|
|
|
|
(c) 2010 - 2020, 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
$(document).ready(function(){
|
|
jQuery("#preloader").remove();
|
|
loadSidebar();
|
|
IndexJS.loading();
|
|
});
|
|
|
|
var IndexJS = {
|
|
|
|
loading: function(){
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=default'],
|
|
onSuccess: (ares) => {
|
|
$('#pageContent').html(ares.content);
|
|
$('#pageToolbarTop').html('');
|
|
$('#pageToolbarBot').html('');
|
|
//this.loadPagu();
|
|
//this.loadChart();
|
|
}
|
|
}).send();
|
|
},
|
|
|
|
loadPagu: function(){
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=pagu-info'],
|
|
onSuccess: function(ares){
|
|
$('#divHome1').html(ares.html);
|
|
}
|
|
}).send();
|
|
},
|
|
|
|
loadChart: function(){
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=pagu-chart'],
|
|
onSuccess: function(data){
|
|
var ctx = $('#pieChart');
|
|
var pieOptions = {
|
|
legend: { display: true, position: 'bottom', labels:{pointStyle:'circle', usePointStyle:true} },
|
|
aspectRatio: 1.3,
|
|
cutoutPercentage: 35,
|
|
responsiveAnimationDuration: 10,
|
|
responsive: true,
|
|
maintainAspectRatio: true,
|
|
onResize: function(mcha, size) {
|
|
var leg = (size.width <= 330) ? false : true;
|
|
mcha.options.legend.display = leg;
|
|
}
|
|
};
|
|
var myChart = new Chart(ctx, {
|
|
type: 'doughnut',
|
|
data: data,
|
|
options: pieOptions
|
|
});
|
|
}
|
|
}).send();
|
|
}
|
|
};
|
|
|
|
function loadSidebar(){
|
|
const mySidebar = document.getElementById('sidebarMain');
|
|
mySidebar.addEventListener('shown.bs.modal', () => {
|
|
document.querySelectorAll('.sidebar .nav-link').forEach((element) => {
|
|
element.addEventListener('click', (e) => {
|
|
let nextEl = element.nextElementSibling, parentEl = element.parentElement;
|
|
if (nextEl){
|
|
e.preventDefault();
|
|
let mycollapse = new bootstrap.Collapse(nextEl);
|
|
if (nextEl.classList.contains('show')){
|
|
mycollapse.hide();
|
|
} else {
|
|
mycollapse.show();
|
|
var opened_submenu = parentEl.parentElement.querySelector('.submenu.show');
|
|
if (opened_submenu){ new bootstrap.Collapse(opened_submenu); }
|
|
}
|
|
}
|
|
});
|
|
})
|
|
});
|
|
}
|