mirror of
https://gitlab.com/Deukhoofd/BattleSim.git
synced 2025-10-29 02:30:05 +00:00
Lots of stuff
This commit is contained in:
34
client/app/js/views/replays/replay_view.coffee
Normal file
34
client/app/js/views/replays/replay_view.coffee
Normal file
@@ -0,0 +1,34 @@
|
||||
class @ReplayView extends Backbone.View
|
||||
replayTemplate: JST['replay']
|
||||
|
||||
events:
|
||||
'click .delete-replay': 'deleteReplay'
|
||||
|
||||
render: =>
|
||||
@$el.empty()
|
||||
|
||||
templates = @collection.map((replay) => @replayTemplate({window, replay}))
|
||||
groups = for x in [0...templates.length] by 3
|
||||
_.compact([ templates[x], templates[x + 1], templates[x + 2] ])
|
||||
|
||||
for groupHTML in groups
|
||||
$row = $('<div/>').addClass('row-fluid')
|
||||
$row.append(groupHTML)
|
||||
$row.appendTo(@$el)
|
||||
|
||||
if @collection.length == 0
|
||||
@$el.append($("<p/>").text("You have not saved any replays."))
|
||||
|
||||
this
|
||||
|
||||
deleteReplay: (e) =>
|
||||
return unless confirm("Do you really want to delete this replay?")
|
||||
$target = $(e.currentTarget)
|
||||
$spinner = $target.closest('.clickable-box').find('.show_spinner')
|
||||
|
||||
$spinner.removeClass('hidden')
|
||||
cid = $target.data('cid')
|
||||
replay = @collection.get(cid)
|
||||
replay
|
||||
.destroy()
|
||||
.complete(@render)
|
||||
Reference in New Issue
Block a user