2012-12-11 00:34:06 +08:00
|
|
|
define [
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'globals'
|
|
|
|
], ($, _, Backbone, globals) ->
|
|
|
|
|
|
|
|
# The navbar in a session
|
|
|
|
# The contents are rendered by SessionView, this class is Used to
|
|
|
|
# manage the events in the navbar.
|
|
|
|
SessionNavbarView = Backbone.View.extend
|
|
|
|
events:
|
2012-12-13 10:04:43 +08:00
|
|
|
"click #chat-btn": "toggleChat"
|
|
|
|
"click #users-btn": "toggleUsers"
|
2012-12-11 00:34:06 +08:00
|
|
|
"click #logout-btn": "logout"
|
|
|
|
"click #prev-slide-btn": "previousSlide"
|
|
|
|
"click #next-slide-btn": "nextSlide"
|
|
|
|
"click #tool-pan-btn": "toolPan"
|
|
|
|
"click #tool-line-btn": "toolLine"
|
|
|
|
"click #tool-rect-btn": "toolRect"
|
|
|
|
"click #tool-ellipse-btn": "toolEllipse"
|
|
|
|
|
|
|
|
initialize: ->
|
|
|
|
@$parentEl = null
|
|
|
|
|
2012-12-13 10:04:43 +08:00
|
|
|
# Ensure the status of the toggle buttons is ok
|
|
|
|
setToggleButtonsStatus: ->
|
2012-12-11 00:34:06 +08:00
|
|
|
$("#chat-btn", @$el).toggleClass "active", @$parentEl.hasClass("chat-enabled")
|
|
|
|
$("#users-btn", @$el).toggleClass "active", @$parentEl.hasClass("users-enabled")
|
|
|
|
|
2012-12-13 10:04:43 +08:00
|
|
|
# don't really need to render anything, the rendering is done by SessionView
|
2012-12-11 00:34:06 +08:00
|
|
|
render: ->
|
2012-12-13 10:04:43 +08:00
|
|
|
@setToggleButtonsStatus()
|
2012-12-11 00:34:06 +08:00
|
|
|
|
2012-12-13 10:04:43 +08:00
|
|
|
# Toggle the visibility of the chat panel
|
|
|
|
toggleChat: ->
|
|
|
|
clearTimeout @toggleChatTimeout if @toggleChatTimeout?
|
2012-12-11 00:34:06 +08:00
|
|
|
@$parentEl.toggleClass "chat-enabled"
|
2012-12-13 10:04:43 +08:00
|
|
|
@setToggleButtonsStatus()
|
2012-12-11 00:34:06 +08:00
|
|
|
# TODO
|
2012-12-13 10:04:43 +08:00
|
|
|
# @toggleChatTimeout = setTimeout(->
|
2012-12-11 00:34:06 +08:00
|
|
|
# Whiteboard.windowResized()
|
|
|
|
# , 510)
|
|
|
|
|
2012-12-13 10:04:43 +08:00
|
|
|
# Toggle the visibility of the users panel
|
|
|
|
toggleUsers: ->
|
|
|
|
clearTimeout @toggleUsersTimeout if @toggleUsersTimeout?
|
2012-12-11 00:34:06 +08:00
|
|
|
@$parentEl.toggleClass "users-enabled"
|
2012-12-13 10:04:43 +08:00
|
|
|
@setToggleButtonsStatus()
|
2012-12-11 00:34:06 +08:00
|
|
|
# TODO
|
2012-12-13 10:04:43 +08:00
|
|
|
# @toggleUsersTimeout = setTimeout(->
|
2012-12-11 00:34:06 +08:00
|
|
|
# Whiteboard.windowResized()
|
|
|
|
# , 510)
|
|
|
|
|
|
|
|
# Log out of the session
|
|
|
|
logout: ->
|
|
|
|
globals.connection.emitLogout()
|
2012-12-11 09:51:01 +08:00
|
|
|
globals.currentAuth = null
|
2012-12-11 00:34:06 +08:00
|
|
|
|
|
|
|
# Go to the previous slide
|
|
|
|
previousSlide: ->
|
2012-12-14 01:26:02 +08:00
|
|
|
globals.connection.emitPreviousSlide()
|
2012-12-11 00:34:06 +08:00
|
|
|
|
|
|
|
# Go to the next slide
|
|
|
|
nextSlide: ->
|
|
|
|
globals.connection.emitNextSlide()
|
|
|
|
|
|
|
|
# "Pan" tool was clicked
|
|
|
|
toolPan: ->
|
|
|
|
globals.connection.emitChangeTool("panzoom")
|
|
|
|
|
|
|
|
# "Line" tool was clicked
|
|
|
|
toolLine: ->
|
|
|
|
globals.connection.emitChangeTool("line")
|
|
|
|
|
|
|
|
# "Rect" tool was clicked
|
|
|
|
toolRect: ->
|
|
|
|
globals.connection.emitChangeTool("rect")
|
|
|
|
|
|
|
|
# "Ellipse" tool was clicked
|
|
|
|
toolEllipse: ->
|
|
|
|
globals.connection.emitChangeTool("ellipse")
|
|
|
|
|
|
|
|
SessionNavbarView
|