summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
Diffstat (limited to 'static')
-rw-r--r--static/init.js48
-rw-r--r--static/playlist.js8
-rw-r--r--static/style.css3
-rw-r--r--static/templates.js8
4 files changed, 59 insertions, 8 deletions
diff --git a/static/init.js b/static/init.js
index c4f6c2c..2c63ac8 100644
--- a/static/init.js
+++ b/static/init.js
@@ -60,7 +60,15 @@ function load_directory(dir_id, dir_item) {
$('#directory-add').prop('disabled', track_list.find('.ui-selected').length == 0);
return false;
});
- $(el, 'a.album').click(function() {
+ el.find('a.artist').click(function() {
+ var artist = {
+ id: item.metadata.artist_id,
+ name: item.metadata.artist
+ };
+ show_artist(artist);
+ return false;
+ });
+ el.find('a.album').click(function() {
var album = {
id: item.metadata.album_id,
name: item.metadata.album
@@ -108,6 +116,14 @@ function set_tracks(container, select, click) {
select.prop('disabled', container.find('.ui-selected').length == 0);
return false;
});
+ el.find('a.artist').click(function(event) {
+ var artist = {
+ id: track.metadata.artist_id,
+ name: track.metadata.artist
+ };
+ show_artist(artist);
+ return false;
+ });
el.find('a.album').click(function(event) {
var album = {
id: track.metadata.album_id,
@@ -130,6 +146,30 @@ function set_tracks(container, select, click) {
});
}
+function show_artist(artist) {
+ var tabs = $('#tabs');
+ var tabid = '#artist-tab-' + artist.id;
+ var tab = $(tabid);
+ if(tab.length > 0) {
+ tabs.tabs('select', tab.index()-1);
+ return;
+ }
+ var tabli = $(templates.artist_tabli({tabid: tabid, artist: artist}));
+ tabs.find('.ui-tabs-nav').append(tabli);
+ var tab = $(templates.artist_tab(artist));
+ tabs.append(tab).tabs('refresh');
+ $.get('/json/artist/' + artist.id, function(data) {
+ var albums = [];
+ $.each(data.albums, function(i, album) {
+ album.artist = {id: data.id, name: data.name};
+ albums.push(album);
+ });
+ tab.empty();
+ add_albums(tabid, albums);
+ }, 'json');
+ tabs.tabs('select', tab.index()-1);
+}
+
function show_album(album) {
var tabs = $('#tabs');
var tabid = '#album-tab-' + album.id;
@@ -155,8 +195,8 @@ function show_album(album) {
tabs.tabs('select', tab.index()-1);
}
-function add_albums(data) {
- var div = $('#albums-list');
+function add_albums(selector, data) {
+ var div = $(selector);
$.each(data, function(i, album) {
var el = $(templates.albums_item(album));
el.find('a').click(function() {
@@ -190,7 +230,7 @@ function load_albums(initiate_scrolling) {
albums_loading = true;
$.get('/json/albums/' + page, function(data) {
if(data.length > 0)
- add_albums(data);
+ add_albums('#albums-list', data);
else
albums_end = true;
if(initiate_scrolling == true)
diff --git a/static/playlist.js b/static/playlist.js
index 90167ce..07953ce 100644
--- a/static/playlist.js
+++ b/static/playlist.js
@@ -24,6 +24,14 @@ $(function(){
playsound(model);
return false;
});
+ $('a.artist', this.el).click(function() {
+ var artist = {
+ id: model.attributes.metadata.artist_id,
+ name: model.attributes.metadata.artist
+ };
+ show_artist(artist);
+ return false;
+ });
$('a.album', this.el).click(function() {
var album = {
id: model.attributes.metadata.album_id,
diff --git a/static/style.css b/static/style.css
index 058a3d8..8b2f1e8 100644
--- a/static/style.css
+++ b/static/style.css
@@ -17,8 +17,9 @@ html, body, #content { height: 100%; }
.track-table tr.ui-selected td { background-color: #fea; }
.track-table tr:hover td { background-color: #fbb; }
-.track-table a { color: inherit; text-decoration: inherit; background-repeat: no-repeat; padding-left: 20px; display: block; }
+.track-table a { color: inherit; text-decoration: inherit; display: block; }
.track-table a:hover { text-decoration: underline; }
+.track-table a.track, .track-table a.dir { background-repeat: no-repeat; padding-left: 20px; }
.track-table .dir { background-image: url('/static/icons/folder.png'); }
.track-table .track { background-image: url('/static/icons/music.png'); }
.track-table .track.nocache { background-image: url('/static/icons/music_nocache.png'); }
diff --git a/static/templates.js b/static/templates.js
index fa2a240..71b77e8 100644
--- a/static/templates.js
+++ b/static/templates.js
@@ -10,10 +10,12 @@ Handlebars.registerHelper('trackname', function() {
});
var templates = new (function Templates() {
- this.track_item = Handlebars.compile('<tr id="{{type}}-{{id}}"><td><a href="#" class="{{type}}{{#unless cache}} nocache{{/unless}}">{{trackname}}</a></td><td>{{metadata.artist}}</td><td><a href="#" class="album">{{metadata.album}}</a></td></tr>');
+ this.track_item = Handlebars.compile('<tr id="{{type}}-{{id}}"><td><a href="#" class="{{type}}{{#unless cache}} nocache{{/unless}}">{{trackname}}</a></td><td><a href="#" class="artist">{{metadata.artist}}</a></td><td><a href="#" class="album">{{metadata.album}}</a></td></tr>');
// The playlist automatically adds a tr tag.
- this.playlist_item = Handlebars.compile('<td><a href="#" class="play">{{trackname}}</a></td><td><a href="#" class="artist">{{metadata.artist}}</a></td><td><a href="#" class="album">{{metadata.album}}</a></td><td class="track-buttons"><a href="#" class="delete"><img src="/static/icons/delete.png" alt="Delete" title="Delete" /></a></td>');
+ this.playlist_item = Handlebars.compile('<td><a href="#" class="track play">{{trackname}}</a></td><td><a href="#" class="artist">{{metadata.artist}}</a></td><td><a href="#" class="album">{{metadata.album}}</a></td><td class="track-buttons"><a href="#" class="delete"><img src="/static/icons/delete.png" alt="Delete" title="Delete" /></a></td>');
this.albums_item = Handlebars.compile('<div class="album-tile" id="albums-album-{{id}}"><a href="#album-tab-{{id}}" title="{{name}} by {{artist.name}}"><img src="/album-cover/{{id}}.jpg" alt="{{name}} by {{artist.name}}" /><br /><span class="album-name">{{name}}</span></div>');
- this.album_tab = Handlebars.compile('<div id="album-tab-{{id}}"><input type="button" value="Add selected" /><table id="album-tab-{{id}}-table" class="track-table"><tbody><tr><td><img src="/static/icons/loading.gif" alt="Loading..." /></td></tr></tbody></table></div>');
+ this.album_tab = Handlebars.compile('<div id="album-tab-{{id}}"><input type="button" value="Add selected" /><table id="album-tab-{{id}}-table" class="track-table"><tbody><tr><td><img src="/static/icons/loading.gif" alt="Loading..." /> Loading...</td></tr></tbody></table></div>');
this.album_tabli = Handlebars.compile('<li><a href="{{tabid}}">Album: {{album.name}}</a> <span class="ui-icon ui-icon-close">Remove tab</span></li>');
+ this.artist_tab = Handlebars.compile('<div id="artist-tab-{{id}}"><img src="/static/icons/loading.gif" alt="Loading..." /> Loading...</div>');
+ this.artist_tabli = Handlebars.compile('<li><a href="{{tabid}}">Artist: {{artist.name}}</a> <span class="ui-icon ui-icon-close">Remove tab</span></li>');
})();