2012-12-14 01:26:02 +08:00
|
|
|
define [
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'raphael',
|
|
|
|
'globals'
|
|
|
|
], ($, _, Backbone, Raphael, globals) ->
|
|
|
|
|
|
|
|
# The whiteboard controls
|
|
|
|
SessionWhiteboardControlsView = Backbone.View.extend
|
|
|
|
events:
|
|
|
|
"click #slide-clean-btn": "_cleanClick"
|
|
|
|
"click #slide-text-btn": "_textClick"
|
|
|
|
"click #slide-undo-btn": "_undoClick"
|
|
|
|
"click #slide-fit-to-page-btn": "_fitToPageClick"
|
|
|
|
"click #slide-fit-to-width-btn": "_fitToWidthClick"
|
|
|
|
"change #slide-upload-file": "_uploadFileSelected"
|
|
|
|
"submit #slide-upload-form": "_uploadFormSubmit"
|
|
|
|
|
|
|
|
initialize: ->
|
|
|
|
# Bind to the event triggered when the client connects to the server
|
|
|
|
globals.connection.bind "connection:connected",
|
|
|
|
@_registerConnectionEvents, @
|
|
|
|
|
2012-12-15 08:58:14 +08:00
|
|
|
# don't need to render anything, the rendering is done by the parent view.
|
2012-12-14 01:26:02 +08:00
|
|
|
render: ->
|
|
|
|
|
|
|
|
clearUploadStatus: ->
|
|
|
|
@$("#slide-upload-status").text ""
|
|
|
|
|
|
|
|
# @param {string} message update message of status of upload progress
|
|
|
|
# @param {boolean} fade true if you wish the message to automatically disappear after 3 seconds
|
|
|
|
setUploadStatus: (message, fade) ->
|
|
|
|
$textInput = @$("#slide-upload-status")
|
|
|
|
$textInput.text message
|
|
|
|
if fade
|
|
|
|
setTimeout (->
|
|
|
|
$textInput.text ""
|
|
|
|
), 3000
|
|
|
|
|
2012-12-15 08:41:30 +08:00
|
|
|
# Registers listeners for events in the application socket.
|
|
|
|
_registerConnectionEvents: ->
|
|
|
|
socket = globals.connection.socket
|
|
|
|
|
|
|
|
# Received event to update the status of the upload progress
|
|
|
|
# @param {string} message update message of status of upload progress
|
|
|
|
# @param {boolean} fade true if you wish the message to automatically disappear after 3 seconds
|
|
|
|
socket.on "uploadStatus", (message, fade) =>
|
|
|
|
console.log "received uploadStatus"
|
|
|
|
@setUploadStatus message, fade
|
|
|
|
|
2012-12-14 01:26:02 +08:00
|
|
|
_uploadFileSelected: ->
|
|
|
|
@$("#slide-upload-form").submit()
|
|
|
|
|
|
|
|
_uploadFormSubmit: ->
|
|
|
|
@setUploadStatus "Uploading..."
|
|
|
|
@$("#slide-upload-form").ajaxSubmit
|
|
|
|
error: (xhr) ->
|
|
|
|
console.log "Error uploading file:", xhr.status
|
|
|
|
success: (response) ->
|
|
|
|
console.log "Success uploading file!"
|
|
|
|
# Have to stop the form from submitting and causing refresh
|
|
|
|
false
|
|
|
|
|
|
|
|
_cleanClick: ->
|
|
|
|
globals.connection.emitClearCanvas()
|
|
|
|
|
|
|
|
_textClick: ->
|
|
|
|
globals.connection.emitChangeTool("text")
|
|
|
|
|
|
|
|
_undoClick: ->
|
|
|
|
globals.connection.emitUndo()
|
|
|
|
|
|
|
|
_fitToPageClick: ->
|
|
|
|
globals.connection.emitFitToPage(true)
|
|
|
|
|
|
|
|
_fitToWidthClick: ->
|
|
|
|
globals.connection.emitFitToPage(false)
|
|
|
|
|
|
|
|
SessionWhiteboardControlsView
|