2011-07-30 01:53:22 +04:00
|
|
|
PlayList.render=function(){
|
|
|
|
$('#playlist').show();
|
2012-01-08 02:41:51 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We should not empty() PlayList.parent() but thorougly manage its
|
|
|
|
* elements instead because some code might be attached to those.
|
|
|
|
* JQuery tipsies are one of them. The following line make sure they
|
|
|
|
* are all removed before we delete the associated <li/>.
|
|
|
|
*/
|
|
|
|
$(".tipsy").remove();
|
|
|
|
|
2011-07-30 01:53:22 +04:00
|
|
|
PlayList.parent.empty();
|
|
|
|
for(var i=0;i<PlayList.items.length;i++){
|
|
|
|
var item=PlayList.items[i];
|
2011-08-11 13:27:14 +04:00
|
|
|
var li=$('<li/>');
|
2012-01-08 02:41:51 +04:00
|
|
|
li.attr('class', 'jp-playlist-' + i);
|
|
|
|
li.attr('title', item.artist + ' - ' + item.name + '<br/>(' + item.album + ')');
|
|
|
|
var div = $('<div class="label">' + item.name + '</div>');
|
|
|
|
li.append(div);
|
|
|
|
$('.jp-playlist-' + i).tipsy({gravity:'w', fade:true, live:true, html:true});
|
2011-08-13 07:27:50 +04:00
|
|
|
var img=$('<img class="remove svg action" src="'+OC.imagePath('core','actions/delete')+'"/>');
|
2011-08-11 13:27:14 +04:00
|
|
|
img.click(function(event){
|
2011-07-30 01:53:22 +04:00
|
|
|
event.stopPropagation();
|
2011-08-11 13:27:14 +04:00
|
|
|
PlayList.remove($(this).parent().data('index'));
|
|
|
|
});
|
|
|
|
li.click(function(event){
|
|
|
|
PlayList.play($(this).data('index'));
|
2011-07-30 01:53:22 +04:00
|
|
|
});
|
2012-02-22 01:31:35 +04:00
|
|
|
li.append(img);
|
2011-08-11 13:27:14 +04:00
|
|
|
li.data('index',i);
|
|
|
|
li.addClass('song');
|
|
|
|
PlayList.parent.append(li);
|
2011-07-30 01:53:22 +04:00
|
|
|
}
|
2011-09-28 13:45:22 +04:00
|
|
|
$(".jp-playlist-" + PlayList.current).addClass("collection_playing");
|
2012-02-22 01:31:35 +04:00
|
|
|
};
|
2011-07-30 01:53:22 +04:00
|
|
|
PlayList.getSelected=function(){
|
2011-07-30 02:05:44 +04:00
|
|
|
return $('tbody td.name input:checkbox:checked').parent().parent();
|
2012-02-22 01:31:35 +04:00
|
|
|
};
|
2011-07-30 01:53:22 +04:00
|
|
|
PlayList.hide=function(){
|
|
|
|
$('#playlist').hide();
|
2012-02-22 01:31:35 +04:00
|
|
|
};
|
2011-07-30 01:53:22 +04:00
|
|
|
|
|
|
|
$(document).ready(function(){
|
2011-08-11 13:27:14 +04:00
|
|
|
PlayList.parent=$('#leftcontent');
|
2011-09-29 00:20:26 +04:00
|
|
|
PlayList.init();
|
2011-07-30 01:53:22 +04:00
|
|
|
$('#selectAll').click(function(){
|
|
|
|
if($(this).attr('checked')){
|
|
|
|
// Check all
|
2011-08-11 13:27:14 +04:00
|
|
|
$('#leftcontent li.song input:checkbox').attr('checked', true);
|
|
|
|
$('#leftcontent li.song input:checkbox').parent().addClass('selected');
|
2011-07-30 01:53:22 +04:00
|
|
|
}else{
|
|
|
|
// Uncheck all
|
2011-08-11 13:27:14 +04:00
|
|
|
$('#leftcontent li.song input:checkbox').attr('checked', false);
|
|
|
|
$('#leftcontent li.song input:checkbox').parent().removeClass('selected');
|
2011-07-30 01:53:22 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|