playlist.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. PlayList.render=function(){
  2. $('#playlist').show();
  3. /*
  4. * We should not empty() PlayList.parent() but thorougly manage its
  5. * elements instead because some code might be attached to those.
  6. * JQuery tipsies are one of them. The following line make sure they
  7. * are all removed before we delete the associated <li/>.
  8. */
  9. $(".tipsy").remove();
  10. PlayList.parent.empty();
  11. for(var i=0;i<PlayList.items.length;i++){
  12. var item=PlayList.items[i];
  13. var li=$('<li/>');
  14. li.attr('class', 'jp-playlist-' + i);
  15. li.attr('title', item.artist + ' - ' + item.name + '<br/>(' + item.album + ')');
  16. var div = $('<div class="label">' + item.name + '</div>');
  17. li.append(div);
  18. $('.jp-playlist-' + i).tipsy({gravity:'w', fade:true, live:true, html:true});
  19. var img=$('<img class="remove svg action" src="'+OC.imagePath('core','actions/delete')+'"/>');
  20. img.click(function(event){
  21. event.stopPropagation();
  22. PlayList.remove($(this).parent().data('index'));
  23. });
  24. li.click(function(event){
  25. PlayList.play($(this).data('index'));
  26. });
  27. li.append(img);
  28. li.data('index',i);
  29. li.addClass('song');
  30. PlayList.parent.append(li);
  31. }
  32. $(".jp-playlist-" + PlayList.current).addClass("collection_playing");
  33. };
  34. PlayList.getSelected=function(){
  35. return $('tbody td.name input:checkbox:checked').parent().parent();
  36. };
  37. PlayList.hide=function(){
  38. $('#playlist').hide();
  39. };
  40. $(document).ready(function(){
  41. PlayList.parent=$('#leftcontent');
  42. PlayList.init();
  43. $('#selectAll').click(function(){
  44. if($(this).attr('checked')){
  45. // Check all
  46. $('#leftcontent li.song input:checkbox').attr('checked', true);
  47. $('#leftcontent li.song input:checkbox').parent().addClass('selected');
  48. }else{
  49. // Uncheck all
  50. $('#leftcontent li.song input:checkbox').attr('checked', false);
  51. $('#leftcontent li.song input:checkbox').parent().removeClass('selected');
  52. }
  53. });
  54. });