implementing select all/none etc

This commit is contained in:
Naomi 2013-08-23 13:18:17 -04:00
parent 63ce35b38d
commit 59ba938334

View file

@ -65,9 +65,42 @@ var AIRTIME = (function(AIRTIME) {
} }
function emptySelectedLogItems() { 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 = {}; 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){ function getFileName(ext){
var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m"; 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"); filename = filename.replace(/:/g,"h");
@ -129,9 +162,9 @@ var AIRTIME = (function(AIRTIME) {
$.i18n._("Select")+" <span class='caret'></span>" + $.i18n._("Select")+" <span class='caret'></span>" +
"</button>" + "</button>" +
"<ul class='dropdown-menu'>" + "<ul class='dropdown-menu'>" +
"<li id='sb-select-page'><a href='#'>"+$.i18n._("Select this page")+"</a></li>" + "<li id='his-select-page'><a href='#'>"+$.i18n._("Select this page")+"</a></li>" +
"<li id='sb-dselect-page'><a href='#'>"+$.i18n._("Deselect this page")+"</a></li>" + "<li id='his-dselect-page'><a href='#'>"+$.i18n._("Deselect this page")+"</a></li>" +
"<li id='sb-dselect-all'><a href='#'>"+$.i18n._("Deselect all")+"</a></li>" + "<li id='his-dselect-all'><a href='#'>"+$.i18n._("Deselect all")+"</a></li>" +
"</ul>" + "</ul>" +
"</div>"); "</div>");
@ -257,6 +290,10 @@ var AIRTIME = (function(AIRTIME) {
$toolbar = $historyTableDiv.parents(".dataTables_wrapper").find(".fg-toolbar:first"); $toolbar = $historyTableDiv.parents(".dataTables_wrapper").find(".fg-toolbar:first");
createToolbarButtons($toolbar); createToolbarButtons($toolbar);
$("#his-select-page").click(selectCurrentPage);
$("#his-dselect-page").click(deselectCurrentPage);
$("#his-dselect-all").click(emptySelectedLogItems);
return oTable; return oTable;
} }
@ -457,7 +494,7 @@ var AIRTIME = (function(AIRTIME) {
redrawTables(); redrawTables();
}); });
$historyContentDiv.find("#his_trash").click(function(ev){ $historyContentDiv.on("click", "#his_trash", function(ev){
var items = getSelectedLogItems(), var items = getSelectedLogItems(),
url = baseUrl+"playouthistory/delete-list-items"; url = baseUrl+"playouthistory/delete-list-items";