diff --git a/app/assets/javascripts/player.coffee b/app/assets/javascripts/player.coffee
index be7bfe0..15ce70a 100644
--- a/app/assets/javascripts/player.coffee
+++ b/app/assets/javascripts/player.coffee
@@ -49,30 +49,31 @@ class window.Player
self.setTrack next
false
- addTrack: (item, autoplay) ->
- if typeof item in ["number", "string"]
- item = @library[item]
+ addTrack: (track, autoplay) ->
+ if typeof track in ["number", "string"]
+ track = @library[track]
if not autoplay?
autoplay = false
initial_count = $('.playlist li').length
- len = parseInt(item.length, 10)
- m = Math.floor(len / 60)
- s = len - Math.floor(len / 60) * 60
- duration = m + ':' + (if s < 10 then '0' else '') + s
- item_class = (if item.available == false then 'unavailable' else '')
- $('.playlist').append "
-
- #{duration}
- remove
-
- #{item.name}
- "
- _player.playlist.push item
- $('.playlist').sortable axis: 'y', cursor: 'move'
+ $('.playlist').append this.generateTrackHtml track
+ $('.playlist').sortable "refresh"
if initial_count == 0 and not _player.hasTrack()
_player.setTrack($('.playlist li').first().attr('id').split('i')[1])
false
+ generateTrackHtml: (track) ->
+ len = parseInt(track.length, 10)
+ m = Math.floor(len / 60)
+ s = len - Math.floor(len / 60) * 60
+ duration = m + ':' + (if s < 10 then '0' else '') + s
+ item_class = (if track.available == false then 'unavailable' else '')
+ "
+ #{duration}
+ remove
+
+ #{track.name}
+ "
+
getDataFromLi: (obj) ->
id = $(obj).attr 'data-id'
track_name = $(obj).find('.trackname').html()
@@ -207,6 +208,9 @@ class window.Player
if data.tracks?
for track in data.tracks
@library[track.id] = track
+ $('.track').draggable
+ helper: 'clone'
+ connectToSortable: '.playlist'
false
@@ -242,6 +246,25 @@ $('.do_empty').live 'click', ->
# Playlist Actions
+$ ->
+ $('.playlist').sortable
+ distance: 5
+ axis: 'y'
+ cursor: 'move'
+ stop: (e, ui) ->
+ if $(ui.item).prop("tagName") == "TR"
+ ui.item.replaceWith(_player.generateTrackHtml(_player.library[$(ui.item).find('.s-add').data('id')]))
+ false
+ $('.playlist').droppable
+ accept: '.track'
+ drop: (e, ui) ->
+ $(this).sortable "refresh"
+ window.setTimeout ->
+ $('.playlist tr.track').remove()
+ , 0
+ false
+ false
+
$('.playlist li .remove').live 'click', (e) ->
$li = $(this).parent()
if $li.hasClass 'now'
diff --git a/app/assets/stylesheets/player.scss b/app/assets/stylesheets/player.scss
index e5197de..ad9f5e9 100644
--- a/app/assets/stylesheets/player.scss
+++ b/app/assets/stylesheets/player.scss
@@ -80,6 +80,7 @@
.playlist {
margin: 20px 0 0 0;
+ min-height: 300px;
li {
list-style: none;
background-color: #ffffff;
@@ -117,4 +118,11 @@
}
}
}
+ tr.track {
+ display: block !important;
+ background-color: #fff;
+ width: 280px;
+ height: 47px;
+ visibility: hidden !important;
+ }
}
\ No newline at end of file
diff --git a/app/views/artist/_page.html.haml b/app/views/artist/_page.html.haml
index a60f347..92a8c45 100644
--- a/app/views/artist/_page.html.haml
+++ b/app/views/artist/_page.html.haml
@@ -40,7 +40,7 @@
%small= " ("+album[:year].to_s+")"
%table.zebra-striped.tracklist
- album[:tracks].each do |track|
- %tr{ class: (track[:available] == false ? "unavailable" : nil) }
+ %tr.track{ class: (track[:available] == false ? "unavailable" : nil) }
%td.song-title= track[:name]
%td.song-duration
.s-duration= (track[:duration] != '0:00' ? track[:duration] : ' '.html_safe)
diff --git a/app/views/playlist/_tracks.html.haml b/app/views/playlist/_tracks.html.haml
index 16070c9..2c2a3d9 100644
--- a/app/views/playlist/_tracks.html.haml
+++ b/app/views/playlist/_tracks.html.haml
@@ -8,7 +8,7 @@
%h3= @data[:name]
%table.zebra-striped.tracklist
- @data[:tracks].each do |track|
- %tr{ class: (track[:available] == false ? "unavailable" : nil) }
+ %tr.track{ class: (track[:available] == false ? "unavailable" : nil) }
%td.album-pic
%img{ src: track[:album_pic]}
%td.song-title
diff --git a/public/templates/about.html b/public/templates/about.html
deleted file mode 100644
index a3198e8..0000000
--- a/public/templates/about.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Now back to the good part!
-
\ No newline at end of file
diff --git a/public/templates/search.html b/public/templates/search.html
deleted file mode 100644
index 819f0cd..0000000
--- a/public/templates/search.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/public/templates/settings.html b/public/templates/settings.html
deleted file mode 100644
index 3f4fca6..0000000
--- a/public/templates/settings.html
+++ /dev/null
@@ -1,48 +0,0 @@
-
\ No newline at end of file
diff --git a/public/templates/whee.html b/public/templates/whee.html
deleted file mode 100644
index 3086cb0..0000000
--- a/public/templates/whee.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
WHEE!
- We never known anything about this artist
but now we found something interesting.
Please come back in a minute.
-
\ No newline at end of file