I noticed a weird page jump in the piggy bank section so it seemed a good moment to clean up some javascript.

This commit is contained in:
James Cole
2016-01-29 17:31:07 +01:00
parent b044d85e90
commit c38e4b86b4
5 changed files with 42 additions and 12 deletions

7
public/js/lib/jquery-ui.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,23 @@
/*
* index.js
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/* globals $, lineChart, token, piggyBankID */ /* globals $, lineChart, token, piggyBankID */
// Return a helper with preserved width of cells // Return a helper with preserved width of cells
var fixHelper = function (e, ui) { var fixHelper = function (e, tr) {
"use strict"; "use strict";
ui.children().each(function () { var $originals = tr.children();
$(this).width($(this).width()); var $helper = tr.clone();
$helper.children().each(function (index) {
// Set helper cell sizes to match the original sizes
$(this).width($originals.eq(index).width());
}); });
return ui; return $helper;
}; };
$(function () { $(function () {
@@ -14,10 +25,6 @@ $(function () {
$('.addMoney').on('click', addMoney); $('.addMoney').on('click', addMoney);
$('.removeMoney').on('click', removeMoney); $('.removeMoney').on('click', removeMoney);
if (typeof(lineChart) === 'function' && typeof(piggyBankID) !== 'undefined') {
lineChart('chart/piggy-bank/' + piggyBankID, 'piggy-bank-history');
}
$('#sortable tbody').sortable( $('#sortable tbody').sortable(
{ {
helper: fixHelper, helper: fixHelper,

View File

@@ -0,0 +1,16 @@
/*
* show.js
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/* globals $, lineChart, piggyBankID */
$(function () {
"use strict";
if (typeof(lineChart) === 'function' && typeof(piggyBankID) !== 'undefined') {
lineChart('chart/piggy-bank/' + piggyBankID, 'piggy-bank-history');
}
});

View File

@@ -41,7 +41,7 @@
<tbody> <tbody>
{% for id,info in accounts %} {% for id,info in accounts %}
<tr> <tr>
<td><a href="{{ route('accounts.show',id) }}">{{ info.name }}</a></td> <td><a href="{{ route('accounts.show',id) }}" title="{{ info.name }}">{{ info.name }}</a></td>
<td class="hidden-sm hidden-xs">{{ info.balance|formatAmount }}</td> <td class="hidden-sm hidden-xs">{{ info.balance|formatAmount }}</td>
<td>{{ info.leftForPiggyBanks|formatAmount }}</td> <td>{{ info.leftForPiggyBanks|formatAmount }}</td>
<td class="hidden-sm hidden-xs">{{ info.sumOfTargets|formatAmount }}</td> <td class="hidden-sm hidden-xs">{{ info.sumOfTargets|formatAmount }}</td>
@@ -57,6 +57,6 @@
</div> </div>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="js/jquery-ui.min.js" type="text/javascript"></script> <script src="js/lib/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/piggy-banks.js"></script> <script type="text/javascript" src="js/piggy-banks/index.js"></script>
{% endblock %} {% endblock %}

View File

@@ -94,5 +94,5 @@
<script type="text/javascript" src="js/Chart.min.js"></script> <script type="text/javascript" src="js/Chart.min.js"></script>
<script type="text/javascript" src="js/charts.js"></script> <script type="text/javascript" src="js/charts.js"></script>
<script type="text/javascript" src="js/piggy-banks.js"></script> <script type="text/javascript" src="js/piggy-banks/show.js"></script>
{% endblock %} {% endblock %}