Вход Регистрация
Файл: templates/admincoreui/js/admin-dashboard.js
Строк: 107
<?php
$(function(){

    var 
ctxchartcontrollersectionperioddataUrltype;
    var 
chart_data = {};

    function 
initChart(){

        
ctx = $("#chart-canvas");
        
period = $('#chart').data('period');
        
dataUrl = $('#chart').data('url');
        
type = $('#chart').data('type');

        $(
'#chart select').on('change', function(e){

            var 
$option = $(this).find('option:selected');

            
controller $option.data('ctrl');
            
section $option.data('section');

            
loadChartData();

        }).
triggerHandler('change');

        $(
'#menu-period input').on('click', function(e){

            
e.preventDefault();

            var 
$link = $(this);

            
period $link.data('period');

            $(
'#menu-period label').removeClass('active')
            $(
this).closest('label').addClass('active');

            
loadChartData();

        });

        $(
'#toggle-type').on('click', function(e){

            if($(
this).hasClass('btn-primary')){
                
type 'bar';
            } else {
                
type 'line';
            }

            $(
this).toggleClass('btn-primary btn-outline-secondary');

            
loadChartData();

        });

    };

    function 
loadChartData(){

        $(
'#chart-spinner').show();

        $.
cookie('icms[dashboard_chart]'JSON.stringify({
            
ccontrollerssectionpperiodttype
        
}));

        $.
post(dataUrl, {idcontrollersectionsectionperiodperiod}, function(result){

            
chart_data result.result.chart_data;

            $(
'.chart-footer-show').remove();
            if(
result.result.footer.length 0){
                $(
'#chart-footer').show();
                for (var 
item in result.result.footer) {

                    var 
list_template = $('#chart-footer-tpl').clone(true).addClass('chart-footer-show');
                    $(
'.text-muted'list_template).html(result.result.footer[item].title);
                    $(
'strong'list_template).html(result.result.footer[item].count);
                    if(
result.result.footer[item].progress){
                        $(
'.callout'list_template).addClass('callout-'+result.result.footer[item].progress);
                    }
                    $(
'#chart-footer > .row').append($(list_template).show());
                }
            } else {
                $(
'#chart-footer').hide();
            }

            
renderChart();

        }, 
'json');


    };

    function 
renderChart(){
        if (
chart) { chart.destroy(); }
        var 
progress = $('#chart-spinner');
        
chart = new Chart(ctx, {
            
typetype,
            
options: {
                
animation: {
                    
onComplete: function() {
                        $(
progress).hide();
                    }
                },
                
legend: {
                    
displayfalse
                
},
                
tooltips: {
                    
mode'point'
                
},
                
maintainAspectRatiofalse,
                
scales: {
                    
xAxes: [{
                        
gridLines: {
                            
drawOnChartAreafalse
                        
}
                    }],
                    
yAxes: [{
                        
ticks: {
                            
stepSize1,
                            
beginAtZerotrue
                        
}
                    }]
                },
            },
            
datachart_data
        
});
    }

    $(
'#dashboard').sortable({
        
items".is-sortable:not(.disabled)",
        
handle'.card-header > .db-sortable-handle',
        
cursor'move',
        
opacity0.85,
        
delay150,
        
connectWith:".is-sortable:not(.disabled)",tolerance:'pointer',forcePlaceholderSize:true,
        
placeholder'colplaceholder',
        
start: function(eventui) {
            $(
ui.placeholder).addClass($(ui.item).attr('class'));
            $(
ui.placeholder).height($(ui.item).height());
        },
        
update: function(eventui) {
            var 
id_list = new Array();
            $(
'#dashboard .is-sortable:not(.disabled)').each(function(){
                var 
name = $(this).data('name');
                
id_list.push(name);
            });
            $.
post($('#dashboard').data('save_order_url'), {itemsid_list}, function(result){
                
toastr.success(result.success_text);
            }, 
'json');
        }
    }).
disableSelection();

    if($(
'#chart select').length 0){
        
initChart();
    }

});
?>
Онлайн: 0
Реклама