CC-3900: Show Builder boxes remain checked even when the item is no longer visible

-only visible tracks can be added/deleted
This commit is contained in:
denise 2012-05-31 11:51:53 -04:00
parent 5e894f7351
commit 1b540626ed
1 changed files with 38 additions and 10 deletions

View File

@ -5,7 +5,8 @@ var AIRTIME = (function(AIRTIME) {
$libContent,
$libTable,
LIB_SELECTED_CLASS = "lib-selected",
chosenItems = {};
chosenItems = {},
visibleChosenItems = {};
if (AIRTIME.library === undefined) {
AIRTIME.library = {};
@ -13,8 +14,22 @@ var AIRTIME = (function(AIRTIME) {
mod = AIRTIME.library;
mod.getChosenItemsLength = function(){
var selected = Object.keys(chosenItems).length;
var cItem,
selected,
$trs;
// Get visible items and check if any chosenItems are visible
$trs = $libTable.find("tbody input:checkbox").parents("tr");
$trs.each(function(i){
for (cItem in chosenItems) {
if (cItem === $(this).attr("id")) {
visibleChosenItems[cItem] = $(this).data('aData');
}
}
});
selected = Object.keys(visibleChosenItems).length;
visibleChosenItems = {};
return selected;
};
@ -72,14 +87,27 @@ var AIRTIME = (function(AIRTIME) {
mod.getSelectedData = function() {
var id,
data = [];
data = [],
cItem,
$trs;
$.fn.reverse = [].reverse;
for (id in chosenItems) {
if (chosenItems.hasOwnProperty(id)) {
data.push(chosenItems[id]);
}
}
// Get visible items and check if any chosenItems are visible
$trs = $libTable.find("tbody input:checkbox").parents("tr").reverse();
$trs.each(function(i){
for (cItem in chosenItems) {
if (cItem === $(this).attr("id")) {
visibleChosenItems[cItem] = $(this).data('aData');
}
}
});
for (id in visibleChosenItems) {
if (visibleChosenItems.hasOwnProperty(id)) {
data.push(visibleChosenItems[id]);
}
}
return data;
};