Files
firefly-iii/public/js/reports.js

87 lines
2.4 KiB
JavaScript
Raw Normal View History

2015-06-27 12:04:53 +02:00
/* globals google, expenseRestShow:true, incomeRestShow:true, year, shared, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, columnChart, lineChart, stackedColumnChart */
2015-05-24 18:22:41 +02:00
if (typeof(google) !== 'undefined') {
2015-02-23 20:25:48 +01:00
google.setOnLoadCallback(drawChart);
}
2015-05-08 17:13:49 +02:00
function drawChart() {
2015-05-24 20:41:14 +02:00
"use strict";
2015-06-27 12:04:53 +02:00
columnChart('chart/report/in-out/' + year + shared, 'income-expenses-chart');
columnChart('chart/report/in-out-sum/' + year + shared, 'income-expenses-sum-chart');
2015-05-08 17:13:49 +02:00
2015-06-27 12:04:53 +02:00
stackedColumnChart('chart/budget/year/' + year + shared, 'budgets');
stackedColumnChart('chart/category/year/' + year + shared, 'categories');
2015-05-17 18:03:16 +02:00
2015-06-27 12:04:53 +02:00
lineChart('/chart/account/month/' + year + '/' + month + shared, 'account-balances-chart');
2015-05-08 17:13:49 +02:00
}
2015-05-16 07:28:58 +02:00
function openModal(e) {
"use strict";
var target = $(e.target).parent();
var URL = target.attr('href');
$.get(URL).success(function (data) {
$('#defaultModal').empty().html(data).modal('show');
}).fail(function () {
alert('Could not load data.');
});
2015-03-10 17:26:31 +01:00
return false;
}
2015-05-16 07:28:58 +02:00
function showIncomes() {
"use strict";
2015-05-17 18:03:16 +02:00
if (incomeRestShow) {
2015-05-16 07:28:58 +02:00
// hide everything, make button say "show"
$('#showIncomes').text(showTheRest);
$('.incomesCollapsed').removeClass('in').addClass('out');
// toggle:
incomeRestShow = false;
} else {
// show everything, make button say "hide".
$('#showIncomes').text(hideTheRest);
$('.incomesCollapsed').removeClass('out').addClass('in');
// toggle:
incomeRestShow = true;
}
return false;
}
function showExpenses() {
2015-05-24 20:41:14 +02:00
"use strict";
2015-05-17 18:03:16 +02:00
if (expenseRestShow) {
2015-05-16 07:28:58 +02:00
// hide everything, make button say "show"
$('#showExpenses').text(showTheRestExpense);
$('.expenseCollapsed').removeClass('in').addClass('out');
// toggle:
expenseRestShow = false;
} else {
// show everything, make button say "hide".
$('#showExpenses').text(hideTheRestExpense);
$('.expenseCollapsed').removeClass('out').addClass('in');
// toggle:
expenseRestShow = true;
}
return false;
2015-05-24 20:41:14 +02:00
}
$(function () {
"use strict";
$('.openModal').on('click', openModal);
// click open the top X income list:
$('#showIncomes').click(showIncomes);
// click open the top X expense list:
$('#showExpenses').click(showExpenses);
});