now the slide is displayed when we first load the page

This commit is contained in:
Anton Georgiev 2014-08-01 14:54:48 +00:00
parent df0d0668c0
commit c8de68eaca
4 changed files with 27 additions and 16 deletions

View File

@ -28,8 +28,6 @@ Meteor.startup ->
{isActive:false, name:"Options", class: "optionsChatTab"} {isActive:false, name:"Options", class: "optionsChatTab"}
] ]
@whiteboardPaperModel = new WhiteboardPaperModel('whiteboard-paper')
Template.header.events Template.header.events
"click .usersListIcon": (event) -> "click .usersListIcon": (event) ->
toggleUsersList() toggleUsersList()

View File

@ -1,16 +1,26 @@
Template.whiteboard.png = -> Template.whiteboard.rendered = ->
alert "rendered - dom is ready"
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true}) currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true}) currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
console.log "the current slide is:" + currentSlide?.slide?.id console.log "the current slide is:" + currentSlide?.slide?.id
if currentSlide?.slide?.png_uri? if currentSlide?.slide?.png_uri?
Template.whiteboard.displaySlide((slide) ->
console.log "THIS SLIDE IS DISPLAYED:"# + JSON.stringify slide Template.whiteboard.createWhiteboardPaper((wpm)->
Template.whiteboard.displayShapeOnSlide(); Template.whiteboard.displaySlide(wpm, (currentSlide)->
) console.log "wpm=" + wpm
Template.whiteboard.displayShapeOnSlide()
))
Template.whiteboard.helpers Template.whiteboard.helpers
createWhiteboardPaper: (callback) ->
console.log "this should happen 1st" + document.getElementById('whiteboard-paper')
console.log "whiteboardPaperModel already exists" if whiteboardPaperModel?
whiteboardPaperModel = new WhiteboardPaperModel('whiteboard-paper')
callback(whiteboardPaperModel)
displayShapeOnSlide: -> displayShapeOnSlide: ->
console.log "this should happen third"
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true}) currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true}) currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
@ -30,14 +40,16 @@ Template.whiteboard.helpers
console.log "shapeType=" + shapeType console.log "shapeType=" + shapeType
console.log "data=" + JSON.stringify data console.log "data=" + JSON.stringify data
whiteboardPaperModel.makeShape(shapeType, data) #whiteboardPaperModel.makeShape(shapeType, data)
whiteboardPaperModel.updateShape(shapeType, data) #whiteboardPaperModel.updateShape(shapeType, data)
displaySlide: (callback) -> displaySlide: (wpm, callback) ->
console.log "this should happen second!"
console.log "wpm2=" + wpm
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true}) currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true}) currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
whiteboardPaperModel.create() #TODO maybe move this to main.coffee wpm.create() #TODO maybe move this to main.coffee
whiteboardPaperModel._displayPage(currentSlide?.slide?.png_uri) wpm._displayPage(currentSlide?.slide?.png_uri)
callback(currentSlide?.slide) callback(currentSlide?.slide)

View File

@ -3,6 +3,7 @@
<p>The whiteboard</p> <p>The whiteboard</p>
{{/if}} {{/if}}
<div id="whiteboard-paper" style="position: fixed; top: 10%; left: 30%;"> <div id="whiteboard-paper" style="position: fixed; top: 10%; left: 30%;">
<!-- {{createWhiteboardPaper}} -->
<p> <p>
{{png}} {{png}}
</p> </p>

View File

@ -33,9 +33,9 @@ class @WhiteboardPaperModel
@shiftPressed = false @shiftPressed = false
@currentPathCount = 0 @currentPathCount = 0
$(window).on "resize.whiteboard_paper", _.bind(@_onWindowResize, @) # $(window).on "resize.whiteboard_paper", _.bind(@_onWindowResize, @)
$(document).on "keydown.whiteboard_paper", _.bind(@_onKeyDown, @) # $(document).on "keydown.whiteboard_paper", _.bind(@_onKeyDown, @)
$(document).on "keyup.whiteboard_paper", _.bind(@_onKeyUp, @) # $(document).on "keyup.whiteboard_paper", _.bind(@_onKeyUp, @)
# Bind to the event triggered when the client connects to the server # Bind to the event triggered when the client connects to the server
# if globals.connection.isConnected() # if globals.connection.isConnected()