From 61417657790d29718dc44784d54df03d2a94645a Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 14 Mar 2012 20:52:32 +0100 Subject: Minor changes to playlist looks. --- static/index.html | 1 + static/init.js | 23 ----------------------- static/playlist.js | 7 ++++++- static/style.css | 3 ++- static/templates.js | 23 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 static/templates.js (limited to 'static') diff --git a/static/index.html b/static/index.html index c337499..be4476e 100644 --- a/static/index.html +++ b/static/index.html @@ -9,6 +9,7 @@ + diff --git a/static/init.js b/static/init.js index b45539c..2cdd84b 100644 --- a/static/init.js +++ b/static/init.js @@ -23,29 +23,6 @@ function preload_images() { }); } -Handlebars.registerHelper('trackname', function() { - var item = this; - if(!item.metadata) - return item.name; - - var s = ''; - if(item.metadata.title) - s = item.metadata.title; - if(item.metadata.artist) { - if(s.length) { - s = ' - ' + s; - s = item.metadata.artist + s; - } - } - if(!s.length) - s = item.name; - return s; -}); - -var templates = new (function Templates() { - this.directory_item = Handlebars.compile('
  • {{trackname}}'); -})(); - function load_directory(dir_id, dir_item) { $.get('/json/list/' + dir_id, function(data) { var dir_list = $('#directory-list'); diff --git a/static/playlist.js b/static/playlist.js index eabd56e..45a4a07 100644 --- a/static/playlist.js +++ b/static/playlist.js @@ -10,7 +10,7 @@ $(function(){ window.items = new Playlist; PlaylistItemView = Backbone.View.extend({ tagName: 'tr', - template: Handlebars.compile('{{trackname}}Delete'), + template: templates.playlist_item, render: function() { var model = this.model; var item = model.toJSON(); @@ -54,6 +54,11 @@ $(function(){ if(item.attributes.nocache) $(el).addClass('nocache'); $('#playlist').append(el); + if(item.attributes.cache !== undefined || item.attributes.nocache !== undefined) { + delete item.attributes.cache; + delete item.attributes.nocache; + item.save(); + } }, removeOne: function(item) { $('#playlist #cid-' + item.cid).remove(); diff --git a/static/style.css b/static/style.css index 1fd114b..9466b71 100644 --- a/static/style.css +++ b/static/style.css @@ -13,5 +13,6 @@ #playlist .loading a.play { background-image: url('/static/icons/loading.gif'); } #playlist { border-collapse: collapse; background: white; width: 100%; } #playlist tr td:first-child { width: 100%; } -#playlist td { padding: .3em; background: white; border: 1px solid #ddd; } +#playlist td { padding: .3em; background: white; border: 1px solid #ddd; border-width: 0 1px; } +#playlist tr:last-child td { border-bottom-width: 1px; } #playlist th { background: #ddd; text-align: left; padding: .5em; } diff --git a/static/templates.js b/static/templates.js new file mode 100644 index 0000000..f1d6bed --- /dev/null +++ b/static/templates.js @@ -0,0 +1,23 @@ +Handlebars.registerHelper('trackname', function() { + var item = this; + if(!item.metadata) + return item.name; + + var s = ''; + if(item.metadata.title) + s = item.metadata.title; + if(item.metadata.artist) { + if(s.length) { + s = ' - ' + s; + s = item.metadata.artist + s; + } + } + if(!s.length) + s = item.name; + return s; +}); + +var templates = new (function Templates() { + this.directory_item = Handlebars.compile('
  • {{trackname}}'); + this.playlist_item = Handlebars.compile('{{trackname}}Delete'); +})(); -- cgit v1.2.3