mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-25 06:52:21 -05:00
c4652d82e2
* Updates spade.js vendor file, adds a sublime-project for developers to use * Moves server logic away from handlers * Moves session update logic to middleware, sets up server schema to autorender IDs as ObjectIDs * Modernizes the supermodel loading scheme and switches from constructor to initalize
43 lines
1.2 KiB
CoffeeScript
43 lines
1.2 KiB
CoffeeScript
RootView = require 'views/core/RootView'
|
|
template = require 'templates/admin/codelogs-view'
|
|
CodeLogCollection = require 'collections/CodeLogs'
|
|
CodeLog = require 'models/CodeLog'
|
|
utils = require 'core/utils'
|
|
|
|
module.exports = class CodeLogsView extends RootView
|
|
template: template
|
|
id: 'codelogs-view'
|
|
tooltip: null
|
|
events:
|
|
'click .playback': 'onClickPlayback'
|
|
|
|
initialize: ->
|
|
@spade = new Spade()
|
|
@codelogs = new CodeLogCollection()
|
|
@supermodel.trackRequest(@codelogs.fetch())
|
|
|
|
onClickPlayback: (e) ->
|
|
@deleteTooltip()
|
|
events = LZString.decompressFromUTF16($(e.target).data('codelog'))
|
|
events = @spade.expand(JSON.parse(events))
|
|
|
|
@tooltip = $(document.createElement('textarea'))
|
|
@tooltip.attr('id', "codelogs-tooltip")
|
|
@tooltip.css({left: e.pageX + 20, top: e.pageY}) # Position near the cursor
|
|
@tooltip.blur @onBlurTooltip
|
|
@$('#codelogs-view').append @tooltip
|
|
@tooltip.focus()
|
|
@spade.play(events, @tooltip.context)
|
|
|
|
deleteTooltip: ->
|
|
if @tooltip?
|
|
@tooltip.off 'blur'
|
|
@tooltip.remove()
|
|
@tooltip = null
|
|
|
|
onBlurTooltip: (e) =>
|
|
@deleteTooltip()
|
|
|
|
destroy: ->
|
|
@deleteTooltip()
|
|
super()
|