CC-3896: Playlist Builder: Using "select this page" to add songs to playlist, those songs will be added in by opposite order, like a stack

-fixed whitespace in library.js
This commit is contained in:
denise 2012-06-06 10:45:27 -04:00
parent 226ef262ba
commit 8e0c886350
1 changed files with 171 additions and 171 deletions

View File

@ -1,12 +1,12 @@
var AIRTIME = (function(AIRTIME) { var AIRTIME = (function(AIRTIME) {
var mod, var mod,
libraryInit, libraryInit,
oTable, oTable,
$libContent, $libContent,
$libTable, $libTable,
LIB_SELECTED_CLASS = "lib-selected", LIB_SELECTED_CLASS = "lib-selected",
chosenItems = {}, chosenItems = {},
visibleChosenItems = {}; visibleChosenItems = {};
if (AIRTIME.library === undefined) { if (AIRTIME.library === undefined) {
AIRTIME.library = {}; AIRTIME.library = {};
@ -28,14 +28,14 @@ var AIRTIME = (function(AIRTIME) {
} }
}); });
selected = Object.keys(visibleChosenItems).length; selected = Object.keys(visibleChosenItems).length;
visibleChosenItems = {}; visibleChosenItems = {};
return selected; return selected;
}; };
mod.getChosenAudioFilesLength = function(){ mod.getChosenAudioFilesLength = function(){
//var files = Object.keys(chosenItems), //var files = Object.keys(chosenItems),
var files, var files,
$trs, $trs,
cItem, cItem,
i, length, i, length,
@ -54,19 +54,19 @@ var AIRTIME = (function(AIRTIME) {
files = Object.keys(visibleChosenItems); files = Object.keys(visibleChosenItems);
for (i = 0, length = files.length; i < length; i++) { for (i = 0, length = files.length; i < length; i++) {
if (files[i].search(reAudio) !== -1) { if (files[i].search(reAudio) !== -1) {
count++; count++;
} }
} }
return count; return count;
}; };
mod.createToolbarDropDown = function() { mod.createToolbarDropDown = function() {
$.contextMenu({ $.contextMenu({
selector: '#library_content .ui-icon-document-b', selector: '#library_content .ui-icon-document-b',
trigger: "left", trigger: "left",
ignoreRightClick: true, ignoreRightClick: true,
@ -79,38 +79,38 @@ var AIRTIME = (function(AIRTIME) {
}; };
mod.checkDeleteButton = function() { mod.checkDeleteButton = function() {
var selected = mod.getChosenItemsLength(), var selected = mod.getChosenItemsLength(),
check = false; check = false;
if (selected !== 0) { if (selected !== 0) {
check = true; check = true;
} }
if (check === true) { if (check === true) {
AIRTIME.button.enableButton("lib-button-delete"); AIRTIME.button.enableButton("lib-button-delete");
} }
else { else {
AIRTIME.button.disableButton("lib-button-delete"); AIRTIME.button.disableButton("lib-button-delete");
} }
}; };
mod.checkToolBarIcons = function() { mod.checkToolBarIcons = function() {
AIRTIME.library.checkAddButton(); AIRTIME.library.checkAddButton();
AIRTIME.library.checkDeleteButton(); AIRTIME.library.checkDeleteButton();
}; };
mod.getSelectedData = function() { mod.getSelectedData = function() {
var id, var id,
data = [], data = [],
cItem, cItem,
$trs; $trs;
$.fn.reverse = [].reverse; $.fn.reverse = [].reverse;
// Get visible items and check if any chosenItems are visible // Get visible items and check if any chosenItems are visible
$trs = $libTable.find("tbody input:checkbox").parents("tr").reverse(); $trs = $libTable.find("tbody input:checkbox").parents("tr").reverse();
$trs.each(function(i){ $trs.each(function(i){
for (cItem in chosenItems) { for (cItem in chosenItems) {
if (cItem === $(this).attr("id")) { if (cItem === $(this).attr("id")) {
visibleChosenItems[cItem] = $(this).data('aData'); visibleChosenItems[cItem] = $(this).data('aData');
@ -118,79 +118,79 @@ var AIRTIME = (function(AIRTIME) {
} }
}); });
for (id in visibleChosenItems) { for (id in visibleChosenItems) {
if (visibleChosenItems.hasOwnProperty(id)) { if (visibleChosenItems.hasOwnProperty(id)) {
data.push(visibleChosenItems[id]); data.push(visibleChosenItems[id]);
} }
} }
return data; return data;
}; };
mod.redrawChosen = function() { mod.redrawChosen = function() {
var ids = Object.keys(chosenItems), var ids = Object.keys(chosenItems),
i, length, i, length,
$el; $el;
for (i = 0, length = ids.length; i < length; i++) { for (i = 0, length = ids.length; i < length; i++) {
$el = $libTable.find("#"+ids[i]); $el = $libTable.find("#"+ids[i]);
if ($el.length !== 0) { if ($el.length !== 0) {
mod.highlightItem($el); mod.highlightItem($el);
} }
} }
}; };
mod.isChosenItem = function($el) { mod.isChosenItem = function($el) {
var id = $el.attr("id"), var id = $el.attr("id"),
item = chosenItems[id]; item = chosenItems[id];
return item !== undefined ? true : false; return item !== undefined ? true : false;
}; };
mod.addToChosen = function($el) { mod.addToChosen = function($el) {
var id = $el.attr("id"); var id = $el.attr("id");
chosenItems[id] = $el.data('aData'); chosenItems[id] = $el.data('aData');
}; };
mod.removeFromChosen = function($el) { mod.removeFromChosen = function($el) {
var id = $el.attr("id"); var id = $el.attr("id");
//used to not keep dragged items selected. //used to not keep dragged items selected.
if (!$el.hasClass(LIB_SELECTED_CLASS)) { if (!$el.hasClass(LIB_SELECTED_CLASS)) {
delete chosenItems[id]; delete chosenItems[id];
} }
}; };
mod.highlightItem = function($el) { mod.highlightItem = function($el) {
var $input = $el.find("input"); var $input = $el.find("input");
$input.attr("checked", true); $input.attr("checked", true);
$el.addClass(LIB_SELECTED_CLASS); $el.addClass(LIB_SELECTED_CLASS);
}; };
mod.unHighlightItem = function($el) { mod.unHighlightItem = function($el) {
var $input = $el.find("input"); var $input = $el.find("input");
$input.attr("checked", false); $input.attr("checked", false);
$el.removeClass(LIB_SELECTED_CLASS); $el.removeClass(LIB_SELECTED_CLASS);
}; };
mod.selectItem = function($el) { mod.selectItem = function($el) {
mod.highlightItem($el); mod.highlightItem($el);
mod.addToChosen($el); mod.addToChosen($el);
mod.checkToolBarIcons(); mod.checkToolBarIcons();
}; };
mod.deselectItem = function($el) { mod.deselectItem = function($el) {
mod.unHighlightItem($el); mod.unHighlightItem($el);
mod.removeFromChosen($el); mod.removeFromChosen($el);
mod.checkToolBarIcons(); mod.checkToolBarIcons();
}; };
/* /*
@ -202,13 +202,13 @@ var AIRTIME = (function(AIRTIME) {
*/ */
mod.selectCurrentPage = function() { mod.selectCurrentPage = function() {
$.fn.reverse = [].reverse; $.fn.reverse = [].reverse;
var $trs = $libTable.find("tbody input:checkbox").parents("tr").reverse(); var $trs = $libTable.find("tbody input:checkbox").parents("tr").reverse();
$trs.each(function(i, el){ $trs.each(function(i, el){
$el = $(this); $el = $(this);
mod.selectItem($el); mod.selectItem($el);
}); });
}; };
/* /*
@ -217,25 +217,25 @@ var AIRTIME = (function(AIRTIME) {
*/ */
mod.deselectCurrentPage = function() { mod.deselectCurrentPage = function() {
var $trs = $libTable.find("tbody input:checkbox").filter(":checked").parents("tr"); var $trs = $libTable.find("tbody input:checkbox").filter(":checked").parents("tr");
$trs.each(function(i, el){ $trs.each(function(i, el){
$el = $(this); $el = $(this);
mod.deselectItem($el); mod.deselectItem($el);
}); });
}; };
mod.selectNone = function() { mod.selectNone = function() {
var $inputs = $libTable.find("tbody input:checkbox"), var $inputs = $libTable.find("tbody input:checkbox"),
$trs = $inputs.parents("tr"); $trs = $inputs.parents("tr");
$inputs.attr("checked", false); $inputs.attr("checked", false);
$trs.removeClass(LIB_SELECTED_CLASS); $trs.removeClass(LIB_SELECTED_CLASS);
chosenItems = {}; chosenItems = {};
mod.checkToolBarIcons(); mod.checkToolBarIcons();
}; };
mod.fnDeleteItems = function(aMedia) { mod.fnDeleteItems = function(aMedia) {
@ -276,18 +276,18 @@ var AIRTIME = (function(AIRTIME) {
* Icon hover states in the toolbar. * Icon hover states in the toolbar.
*/ */
$libContent.on("mouseenter", ".fg-toolbar ul li", function(ev) { $libContent.on("mouseenter", ".fg-toolbar ul li", function(ev) {
$el = $(this); $el = $(this);
if (!$el.hasClass("ui-state-disabled")) { if (!$el.hasClass("ui-state-disabled")) {
$el.addClass("ui-state-hover"); $el.addClass("ui-state-hover");
} }
}); });
$libContent.on("mouseleave", ".fg-toolbar ul li", function(ev) { $libContent.on("mouseleave", ".fg-toolbar ul li", function(ev) {
$el = $(this); $el = $(this);
if (!$el.hasClass("ui-state-disabled")) { if (!$el.hasClass("ui-state-disabled")) {
$el.removeClass("ui-state-hover"); $el.removeClass("ui-state-hover");
} }
}); });
$libTable = $libContent.find("table"); $libTable = $libContent.find("table");
@ -337,9 +337,9 @@ var AIRTIME = (function(AIRTIME) {
}, },
"fnStateSave": function (oSettings, oData) { "fnStateSave": function (oSettings, oData) {
localStorage.setItem('datatables-library', JSON.stringify(oData)); localStorage.setItem('datatables-library', JSON.stringify(oData));
$.ajax({ $.ajax({
url: "/usersettings/set-library-datatable", url: "/usersettings/set-library-datatable",
type: "POST", type: "POST",
data: {settings : oData, format: "json"}, data: {settings : oData, format: "json"},
@ -347,11 +347,11 @@ var AIRTIME = (function(AIRTIME) {
}); });
}, },
"fnStateLoad": function fnLibStateLoad(oSettings) { "fnStateLoad": function fnLibStateLoad(oSettings) {
var settings = localStorage.getItem('datatables-library'); var settings = localStorage.getItem('datatables-library');
if (settings !== "") { if (settings !== "") {
return JSON.parse(settings); return JSON.parse(settings);
} }
}, },
"fnStateLoadParams": function (oSettings, oData) { "fnStateLoadParams": function (oSettings, oData) {
var i, var i,
@ -361,16 +361,16 @@ var AIRTIME = (function(AIRTIME) {
//putting serialized data back into the correct js type to make //putting serialized data back into the correct js type to make
//sure everything works properly. //sure everything works properly.
for (i = 0, length = a.length; i < length; i++) { for (i = 0, length = a.length; i < length; i++) {
if (typeof(a[i]) === "string") { if (typeof(a[i]) === "string") {
a[i] = (a[i] === "true") ? true : false; a[i] = (a[i] === "true") ? true : false;
} }
} }
a = oData.ColReorder; a = oData.ColReorder;
for (i = 0, length = a.length; i < length; i++) { for (i = 0, length = a.length; i < length; i++) {
if (typeof(a[i]) === "string") { if (typeof(a[i]) === "string") {
a[i] = parseInt(a[i], 10); a[i] = parseInt(a[i], 10);
} }
} }
oData.iEnd = parseInt(oData.iEnd, 10); oData.iEnd = parseInt(oData.iEnd, 10);
@ -465,11 +465,11 @@ var AIRTIME = (function(AIRTIME) {
}); });
}, },
//remove any selected nodes before the draw. //remove any selected nodes before the draw.
"fnPreDrawCallback": function( oSettings ) { "fnPreDrawCallback": function( oSettings ) {
//make sure any dragging helpers are removed or else they'll be stranded on the screen. //make sure any dragging helpers are removed or else they'll be stranded on the screen.
$("#draggingContainer").remove(); $("#draggingContainer").remove();
}, },
"fnDrawCallback": AIRTIME.library.fnDrawCallback, "fnDrawCallback": AIRTIME.library.fnDrawCallback,
"aaSorting": [[3, 'asc']], "aaSorting": [[3, 'asc']],
@ -515,27 +515,27 @@ var AIRTIME = (function(AIRTIME) {
$libTable.find("tbody").on("click", "input[type=checkbox]", function(ev) { $libTable.find("tbody").on("click", "input[type=checkbox]", function(ev) {
var $cb = $(this), var $cb = $(this),
$prev, $prev,
$tr = $cb.parents("tr"), $tr = $cb.parents("tr"),
$trs; $trs;
if ($cb.is(":checked")) { if ($cb.is(":checked")) {
if (ev.shiftKey) { if (ev.shiftKey) {
$prev = $libTable.find("tbody").find("tr."+LIB_SELECTED_CLASS).eq(-1); $prev = $libTable.find("tbody").find("tr."+LIB_SELECTED_CLASS).eq(-1);
$trs = $prev.nextUntil($tr); $trs = $prev.nextUntil($tr);
$trs.each(function(i, el){ $trs.each(function(i, el){
mod.selectItem($(el)); mod.selectItem($(el));
}); });
} }
mod.selectItem($tr); mod.selectItem($tr);
} }
else { else {
mod.deselectItem($tr); mod.deselectItem($tr);
} }
}); });
checkImportStatus(); checkImportStatus();
@ -729,8 +729,8 @@ function addProgressIcon(id) {
function checkLibrarySCUploadStatus(){ function checkLibrarySCUploadStatus(){
var url = '/Library/get-upload-to-soundcloud-status', var url = '/Library/get-upload-to-soundcloud-status',
span, span,
id; id;
function checkSCUploadStatusCallback(json) { function checkSCUploadStatusCallback(json) {