split the whiteboard template so that when the slide info is loaded/modified we trigger an event and rerender the slide template

This commit is contained in:
Anton Georgiev 2014-08-05 21:05:31 +00:00
parent c8de68eaca
commit 327b547014
5 changed files with 72 additions and 4 deletions

View File

@ -109,6 +109,12 @@ Handlebars.registerHelper "isUserTalking", (u) ->
Handlebars.registerHelper "isUserSharingAudio", (u) ->
if u? then u.voiceUser?.joined
else return false
Handlebars.registerHelper "getCurrenctSlide", ->
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id
Meteor.Slides.find({"presentationId": presentationId, "slide.current": true})
# Starts the entire logout procedure. Can be called for signout out
# meeting: the meeting the user is in

View File

@ -0,0 +1,55 @@
Template.slide.rendered = ->
console.log "rendered - dom is ready"
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
console.log "the current slide is:" + currentSlide?.slide?.id
if currentSlide?.slide?.png_uri?
Template.slide.createWhiteboardPaper((wpm)->
Template.slide.displaySlide(wpm, (currentSlide)->
console.log "wpm=" + wpm
Template.slide.displayShapeOnSlide()
))
Template.slide.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: ->
console.log "this should happen third"
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
console.log "(shapesOnSlide)the current slide is:" + currentSlide?.slide?.id
console.log "(shapesOnSlide) and there are #{Meteor.Shapes.find({whiteboardId: currentSlide?.slide?.id}).count()} shapes"
for shape in Meteor.Shapes.find({whiteboardId: currentSlide?.slide?.id}).fetch()
console.log "displaying shape on slide for a " + JSON.stringify shape.shape
shapeType = shape.shape?.shape?.type
data = shape.shape?.shape # TODO change some of these!!
data.points[0] = data.points[0] / 100
data.points[1] = data.points[1] / 100
data.points[2] = data.points[2] / 100
data.points[3] = data.points[3] / 100
console.log "shapeType=" + shapeType
console.log "data=" + JSON.stringify data
#whiteboardPaperModel.makeShape(shapeType, data)
#whiteboardPaperModel.updateShape(shapeType, data)
displaySlide: (wpm, callback) ->
console.log "this should happen second!"
console.log "wpm2=" + wpm
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
wpm.create() #TODO maybe move this to main.coffee
wpm._displayPage(currentSlide?.slide?.png_uri)
callback(currentSlide?.slide)

View File

@ -0,0 +1,3 @@
<template name="slide">
</template>

View File

@ -1,5 +1,5 @@
Template.whiteboard.rendered = ->
alert "rendered - dom is ready"
###Template.whiteboard.rendered = ->
console.log "rendered - dom is ready"
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
presentationId = currentPresentation?.presentation?.id
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
@ -53,3 +53,4 @@ Template.whiteboard.helpers
wpm.create() #TODO maybe move this to main.coffee
wpm._displayPage(currentSlide?.slide?.png_uri)
callback(currentSlide?.slide)
###

View File

@ -2,10 +2,13 @@
{{#if getInSession "display_whiteboard"}}
<p>The whiteboard</p>
{{/if}}
{{#each getCurrenctSlide}}
{{> slide}}
{{/each}}
<div id="whiteboard-paper" style="position: fixed; top: 10%; left: 30%;">
<!-- {{createWhiteboardPaper}} -->
<p>
{{png}}
<!-- {{png}} -->
</p>
</div>
</template>