From 59ba938334fceca287981223811fa0cd1fca5e2d Mon Sep 17 00:00:00 2001 From: Naomi Date: Fri, 23 Aug 2013 13:18:17 -0400 Subject: [PATCH] implementing select all/none etc --- .../js/airtime/playouthistory/historytable.js | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/public/js/airtime/playouthistory/historytable.js b/airtime_mvc/public/js/airtime/playouthistory/historytable.js index 4004d4e13..72687a9de 100644 --- a/airtime_mvc/public/js/airtime/playouthistory/historytable.js +++ b/airtime_mvc/public/js/airtime/playouthistory/historytable.js @@ -65,9 +65,42 @@ var AIRTIME = (function(AIRTIME) { } function emptySelectedLogItems() { + var $inputs = $historyContentDiv.find(".his_checkbox").find("input"), + id, $tr, $input; + + $.each($inputs, function(index, input) { + $input = $(input); + $input.prop('checked', false); + }); selectedLogItems = {}; } + function selectCurrentPage() { + var $inputs = $historyContentDiv.find(".his_checkbox").find("input"), + id, $tr, $input; + + $.each($inputs, function(index, input) { + $input = $(input); + $input.prop('checked', true); + $tr = $input.parents("tr"); + id = $tr.data("his-id"); + addSelectedLogItem(id); + }); + } + + function deselectCurrentPage() { + var $inputs = $historyContentDiv.find(".his_checkbox").find("input"), + id, $tr, $input; + + $.each($inputs, function(index, input) { + $input = $(input); + $input.prop('checked', false); + $tr = $input.parents("tr"); + id = $tr.data("his-id"); + removeSelectedLogItem(id); + }); + } + function getFileName(ext){ var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m"; filename = filename.replace(/:/g,"h"); @@ -129,9 +162,9 @@ var AIRTIME = (function(AIRTIME) { $.i18n._("Select")+" " + "" + "" + ""); @@ -256,7 +289,11 @@ var AIRTIME = (function(AIRTIME) { $toolbar = $historyTableDiv.parents(".dataTables_wrapper").find(".fg-toolbar:first"); createToolbarButtons($toolbar); - + + $("#his-select-page").click(selectCurrentPage); + $("#his-dselect-page").click(deselectCurrentPage); + $("#his-dselect-all").click(emptySelectedLogItems); + return oTable; } @@ -457,7 +494,7 @@ var AIRTIME = (function(AIRTIME) { redrawTables(); }); - $historyContentDiv.find("#his_trash").click(function(ev){ + $historyContentDiv.on("click", "#his_trash", function(ev){ var items = getSelectedLogItems(), url = baseUrl+"playouthistory/delete-list-items";