Update js [skip ci]

This commit is contained in:
James Cole
2015-05-24 20:41:14 +02:00
parent 8daccbfbb4
commit 860a0f790e
6 changed files with 36 additions and 27 deletions

View File

@@ -1,3 +1,4 @@
/* globals require */
var elixir = require('laravel-elixir'); var elixir = require('laravel-elixir');
/* /*
@@ -12,5 +13,6 @@ var elixir = require('laravel-elixir');
*/ */
elixir(function(mix) { elixir(function(mix) {
"use strict";
mix.less('app.less'); mix.less('app.less');
}); });

View File

@@ -53,7 +53,7 @@ function updateSingleRange(e) {
// update the link if relevant: // update the link if relevant:
$('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition); $('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition);
}); });
if (input.attr('type') == 'number') { if (input.attr('type') === 'number') {
// update the range-input: // update the range-input:
$('#budget-range-' + id).val(value); $('#budget-range-' + id).val(value);
} else { } else {
@@ -126,13 +126,8 @@ function updateRanges() {
// update small display: // update small display:
$('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2)); $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
// update progress bar (if relevant)
var barHolder = $('#budget-progress-' + id);
var spent = parseFloat(barHolder.data('spent'));
// send a post to Firefly to update the amount: // send a post to Firefly to update the amount:
$.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) { $.post('budgets/amount/' + id, {amount: value, _token: token});
});
}); });

View File

@@ -1,5 +1,8 @@
/* globals $, googleLineChart, token */
// Return a helper with preserved width of cells // Return a helper with preserved width of cells
var fixHelper = function(e, tr) { var fixHelper = function (e, tr) {
"use strict";
var $originals = tr.children(); var $originals = tr.children();
var $helper = tr.clone(); var $helper = tr.clone();
$helper.children().each(function (index) { $helper.children().each(function (index) {
@@ -10,6 +13,7 @@ var fixHelper = function(e, tr) {
}; };
$(function () { $(function () {
"use strict";
$('.addMoney').on('click', addMoney); $('.addMoney').on('click', addMoney);
$('.removeMoney').on('click', removeMoney); $('.removeMoney').on('click', removeMoney);
@@ -43,8 +47,8 @@ $(function () {
}); });
function addMoney(e) { function addMoney(e) {
"use strict";
var pigID = parseInt($(e.target).data('id')); var pigID = parseInt($(e.target).data('id'));
$('#moneyManagementModal').empty().load('piggy-banks/add/' + pigID, function () { $('#moneyManagementModal').empty().load('piggy-banks/add/' + pigID, function () {
$('#moneyManagementModal').modal('show'); $('#moneyManagementModal').modal('show');
@@ -54,6 +58,7 @@ function addMoney(e) {
} }
function removeMoney(e) { function removeMoney(e) {
"use strict";
var pigID = parseInt($(e.target).data('id')); var pigID = parseInt($(e.target).data('id'));
$('#moneyManagementModal').empty().load('piggy-banks/remove/' + pigID, function () { $('#moneyManagementModal').empty().load('piggy-banks/remove/' + pigID, function () {
$('#moneyManagementModal').modal('show'); $('#moneyManagementModal').modal('show');
@@ -62,15 +67,15 @@ function removeMoney(e) {
return false; return false;
} }
function stopSorting() { function stopSorting() {
"use strict";
$('.loadSpin').addClass('fa fa-refresh fa-spin'); $('.loadSpin').addClass('fa fa-refresh fa-spin');
var order = []; var order = [];
$.each($('#sortable>tbody>tr'), function(i,v) { $.each($('#sortable>tbody>tr'), function (i, v) {
var holder = $(v); var holder = $(v);
var id = holder.data('id'); var id = holder.data('id');
order.push(id); order.push(id);
}); });
$.post('/piggy-banks/sort',{_token: token, order: order}).success(function(data) { $.post('/piggy-banks/sort', {_token: token, order: order}).success(function () {
"use strict";
$('.loadSpin').removeClass('fa fa-refresh fa-spin'); $('.loadSpin').removeClass('fa fa-refresh fa-spin');
}); });
} }

View File

@@ -1,9 +1,11 @@
/* globals expenseRestShow:true, incomeRestShow:true, year, shared, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, googleColumnChart, googleLineChart, googleStackedColumnChartg */
if (typeof(google) !== 'undefined') { if (typeof(google) !== 'undefined') {
google.setOnLoadCallback(drawChart); google.setOnLoadCallback(drawChart);
} }
function drawChart() { function drawChart() {
"use strict";
googleColumnChart('chart/report/in-out/' + year + shared, 'income-expenses-chart'); googleColumnChart('chart/report/in-out/' + year + shared, 'income-expenses-chart');
googleColumnChart('chart/report/in-out-sum/' + year + shared, 'income-expenses-sum-chart'); googleColumnChart('chart/report/in-out-sum/' + year + shared, 'income-expenses-sum-chart');
@@ -13,16 +15,8 @@ function drawChart() {
googleLineChart('/chart/account/month/' + year + '/' + month + shared, 'account-balances-chart'); googleLineChart('/chart/account/month/' + year + '/' + month + shared, 'account-balances-chart');
} }
$(function () {
$('.openModal').on('click', openModal);
// click open the top X income list:
$('#showIncomes').click(showIncomes);
// click open the top X expense list:
$('#showExpenses').click(showExpenses);
});
function openModal(e) { function openModal(e) {
"use strict"; "use strict";
var target = $(e.target).parent(); var target = $(e.target).parent();
@@ -61,6 +55,7 @@ function showIncomes() {
} }
function showExpenses() { function showExpenses() {
"use strict";
if (expenseRestShow) { if (expenseRestShow) {
// hide everything, make button say "show" // hide everything, make button say "show"
$('#showExpenses').text(showTheRestExpense); $('#showExpenses').text(showTheRestExpense);
@@ -78,4 +73,15 @@ function showExpenses() {
} }
return false; return false;
} }
$(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);
});

View File

@@ -1,5 +1,6 @@
/* globals zoomLevel, token, google, latitude, longitude */
$(function () { $(function () {
"use strict";
/* /*
Hide and show the tag index help. Hide and show the tag index help.
*/ */
@@ -47,7 +48,7 @@ function clearLocation() {
} }
function initialize() { function initialize() {
"use strict";
/* /*
Create new map: Create new map:
*/ */
@@ -91,6 +92,7 @@ function saveZoomLevel() {
* @param event * @param event
*/ */
function placeMarker(event) { function placeMarker(event) {
"use strict";
deleteMarkers(); deleteMarkers();
var marker = new google.maps.Marker({position: event.latLng, map: map}); var marker = new google.maps.Marker({position: event.latLng, map: map});
$('input[name="latitude"]').val(event.latLng.lat()); $('input[name="latitude"]').val(event.latLng.lat());
@@ -105,6 +107,7 @@ function placeMarker(event) {
* Deletes all markers in the array by removing references to them. * Deletes all markers in the array by removing references to them.
*/ */
function deleteMarkers() { function deleteMarkers() {
"use strict";
for (var i = 0; i < markers.length; i++) { for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null); markers[i].setMap(null);
} }

View File

@@ -1,8 +1,6 @@
/* globals what, $ */
$(document).ready(function () { $(document).ready(function () {
if (typeof googleTablePaged != 'undefined') { "use strict";
googleTablePaged('table/transactions/' + what, 'transaction-table');
}
if ($('input[name="expense_account"]').length > 0) { if ($('input[name="expense_account"]').length > 0) {
$.getJSON('json/expense-accounts').success(function (data) { $.getJSON('json/expense-accounts').success(function (data) {
$('input[name="expense_account"]').typeahead({source: data}); $('input[name="expense_account"]').typeahead({source: data});