firefly-iii/public/js/reports.js

96 lines
2.8 KiB
JavaScript
Raw Normal View History

2015-06-27 05:04:53 -05:00
/* globals google, expenseRestShow:true, incomeRestShow:true, year, shared, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, columnChart, lineChart, stackedColumnChart */
$(function () {
"use strict";
if (typeof(google) !== 'undefined') {
google.setOnLoadCallback(drawChart);
} else {
drawChart();
}
});
2015-05-08 10:13:49 -05:00
function drawChart() {
2015-05-24 13:41:14 -05:00
"use strict";
2015-07-01 09:41:59 -05:00
if (typeof columnChart !== 'undefined' && typeof year !== 'undefined' && typeof month === 'undefined') {
2015-06-27 13:39:50 -05:00
columnChart('chart/report/in-out/' + year + shared, 'income-expenses-chart');
columnChart('chart/report/in-out-sum/' + year + shared, 'income-expenses-sum-chart');
}
2015-07-01 09:41:59 -05:00
if (typeof stackedColumnChart !== 'undefined' && typeof year !== 'undefined' && typeof month === 'undefined') {
2015-06-27 13:39:50 -05:00
stackedColumnChart('chart/budget/year/' + year + shared, 'budgets');
stackedColumnChart('chart/category/year/' + year + shared, 'categories');
}
2015-07-01 09:41:59 -05:00
if (typeof lineChart !== 'undefined' && typeof month !== 'undefined') {
2015-06-27 13:39:50 -05:00
lineChart('/chart/account/month/' + year + '/' + month + shared, 'account-balances-chart');
}
2015-05-08 10:13:49 -05:00
}
2015-05-16 00:28:58 -05: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 11:26:31 -05:00
return false;
}
2015-05-16 00:28:58 -05:00
function showIncomes() {
"use strict";
2015-05-17 11:03:16 -05:00
if (incomeRestShow) {
2015-05-16 00:28:58 -05: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 13:41:14 -05:00
"use strict";
2015-05-17 11:03:16 -05:00
if (expenseRestShow) {
2015-05-16 00:28:58 -05: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 13:41:14 -05: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);
});