summaryrefslogtreecommitdiffstats
path: root/apps/media/js/collection.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-30 04:15:09 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-30 04:15:09 +0200
commit51e00d074cf4f1481c96f6a18da9c8ab7f412393 (patch)
tree87a180860b9a7d2928481260573d83d73ebbd9d2 /apps/media/js/collection.js
parenteee2a2266d66c5571aad1d71d9dd2b86c8adfabf (diff)
downloadnextcloud-server-51e00d074cf4f1481c96f6a18da9c8ab7f412393.tar.gz
nextcloud-server-51e00d074cf4f1481c96f6a18da9c8ab7f412393.zip
add play button to collection overview to add songs to the playlist and play them imediatly
Diffstat (limited to 'apps/media/js/collection.js')
-rw-r--r--apps/media/js/collection.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js
index 5aa0d058bdc..b8fd515ba60 100644
--- a/apps/media/js/collection.js
+++ b/apps/media/js/collection.js
@@ -53,10 +53,9 @@ Collection={
li.data('artist',artist);
li.removeClass('template');
li.addClass('artist');
+ li.data('type','artist');
li.children('span').text(artist.artist_name);
- li.children('button').click(function(){
- PlayList.add($(this).parent().data('artist'));
- })
+ Collection.addButtons(li);
Collection.parent.append(li);
}
}
@@ -81,10 +80,9 @@ Collection={
li.removeClass('template');
li.addClass('album');
li.data('album',album);
+ li.data('type','album');
li.children('span').text(album.album_name);
- li.children('button').click(function(){
- PlayList.add($(this).parent().data('album'));
- })
+ Collection.addButtons(li);
ul.append(li);
}
artistLi.append(ul);
@@ -102,10 +100,9 @@ Collection={
li.removeClass('template');
li.addClass('song');
li.data('song',song);
+ li.data('type','song');
li.children('span').text(song.song_name);
- li.children('button').click(function(){
- PlayList.add($(this).parent().data('song'));
- })
+ Collection.addButtons(li);
ul.append(li);
}
albumLi.append(ul);
@@ -124,6 +121,18 @@ Collection={
}
}
}
+ },
+ addButtons:function(parent){
+ parent.children('button.add').click(function(){
+ var type=$(this).parent().data('type');
+ PlayList.add($(this).parent().data(type));
+ });
+ parent.children('button.play').click(function(){
+ var type=$(this).parent().data('type');
+ var oldSize=PlayList.items.length;
+ PlayList.add($(this).parent().data(type));
+ PlayList.play(oldSize);
+ });
}
}