Skip to content

Commit

Permalink
Merge pull request #147 from play/remove-alerts
Browse files Browse the repository at this point in the history
Remove alerts
  • Loading branch information
holman committed Apr 24, 2012
2 parents 80c3c78 + 14c286e commit eef8314
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/frontend/scripts/behaviors.js.coffee
Expand Up @@ -43,7 +43,7 @@ $(document).ready () ->
#
# data-artist - The Data attribute set on the link whose value is the
# artist name for this song.
$('.artist').live 'click', () ->
$(document).on 'click', '.artist', () ->
element = $(@)
artist = escape(element.data('artist'))
updateSongs("/artist/"+artist, "GET")
Expand All @@ -53,7 +53,7 @@ $(document).ready () ->
#
# data-artist - The Data attribute set on the link whose value is the
# artist name for this song.
$('.album').live 'click', () ->
$(document).on 'click', '.album', () ->
element = $(@)
artist = escape(element.data('artist'))
album = escape(element.data('album'))
Expand Down Expand Up @@ -118,7 +118,8 @@ $(document).ready () ->
#
# data-song-id - The Data attribute set on the link whose value is the
# persistent ID of the song.
$('.add-to-queue').live 'click', () ->
$(document).on 'click', '.add-to-queue', () ->
play.spin(true)
element = $(@)
id = element.data('song-id')
$.ajax
Expand All @@ -127,14 +128,16 @@ $(document).ready () ->
data:
id: id
success: (response) ->
alert 'added!'
element.replaceWith(queue(id, true))
play.spin(false)
false

# Removes this song from the queue.
#
# data-song-id - The Data attribute set on the link whose value is the
# persistent ID of the song.
$('.remove-from-queue').live 'click', () ->
$(document).on 'click', '.remove-from-queue', () ->
play.spin(true)
element = $(@)
id = element.data('song-id')
$.ajax
Expand All @@ -143,5 +146,6 @@ $(document).ready () ->
data:
id: id
success: (response) ->
alert 'removed!'
element.replaceWith(queue(id, false))
play.spin(false)
false
13 changes: 13 additions & 0 deletions app/frontend/scripts/helpers.js.coffee
Expand Up @@ -62,6 +62,19 @@ play.renderStar = (id, starred) ->
})
Mustache.to_html(templates.star,song,templates)

# Queue or unqueue a song
#
# id - The ID of the song
# queued - The Boolean value of whether this song should be queued or not.
# 'true' means Add to Queue, 'false' means Remove from Queue
#
play.queue = (id, queued) ->
song = new Song({
id: id
queued: queued
})
Mustache.to_html(templates.queuing,song,templates)

# Takes a JSON response and parses it for our common Song attributes.
#
# json - The common JSON endpoint we return.
Expand Down

0 comments on commit eef8314

Please sign in to comment.