/* * show.js * Copyright (C) 2016 thegrumpydictator@gmail.com * * This software may be modified and distributed under the terms of the * Creative Commons Attribution-ShareAlike 4.0 International License. * * See the LICENSE file for details. */ var fixHelper = function (e, tr) { "use strict"; var $originals = tr.children(); 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 $helper; }; $(function () { "use strict"; lineChart(chartUri, 'overview-chart'); pieChart(incomeCategoryUri, 'account-cat-in'); pieChart(expenseCategoryUri, 'account-cat-out'); pieChart(expenseBudgetUri, 'account-budget-out'); // sortable! if (typeof $(".sortable-table tbody").sortable !== "undefined") { $(".sortable-table tbody").sortable( { helper: fixHelper, items: 'tr:not(.ignore)', stop: sortStop, handle: '.handle', start: function (event, ui) { // Build a placeholder cell that spans all the cells in the row var cellCount = 0; $('td, th', ui.helper).each(function () { // For each TD or TH try and get it's colspan attribute, and add that or 1 to the total var colspan = 1; var colspanAttr = $(this).attr('colspan'); if (colspanAttr > 1) { colspan = colspanAttr; } cellCount += colspan; }); // Add the placeholder UI - note that this is the item's content, so TD rather than TR ui.placeholder.html('