2015-09-10 01:24:57 +08:00
|
|
|
# scale the whiteboard to adapt to the resized window
|
|
|
|
@scaleWhiteboard = (callback) ->
|
2015-01-07 01:42:37 +08:00
|
|
|
adjustedDimensions = scaleSlide(getInSession('slideOriginalWidth'), getInSession('slideOriginalHeight'))
|
2015-12-04 01:03:04 +08:00
|
|
|
if whiteboardPaperModel?
|
|
|
|
whiteboardPaperModel.scale(adjustedDimensions.width, adjustedDimensions.height)
|
|
|
|
|
2015-03-31 07:03:41 +08:00
|
|
|
if callback
|
|
|
|
callback()
|
2015-03-28 08:59:56 +08:00
|
|
|
|
2015-05-08 02:14:47 +08:00
|
|
|
Template.whiteboard.helpers
|
|
|
|
presentationProgress: ->
|
|
|
|
currentPresentation = Meteor.Presentations.findOne({'presentation.current':true})
|
|
|
|
currentSlideNum = Meteor.Slides.findOne({'presentationId': currentPresentation?.presentation.id, 'slide.current':true})?.slide.num
|
|
|
|
totalSlideNum = Meteor.Slides.find({'presentationId': currentPresentation?.presentation.id})?.count()
|
2015-12-04 01:03:04 +08:00
|
|
|
# console.log('slide', currentSlideNum)
|
2015-05-26 06:30:57 +08:00
|
|
|
if currentSlideNum isnt undefined
|
|
|
|
return "#{currentSlideNum}/#{totalSlideNum}"
|
|
|
|
else
|
|
|
|
return ''
|
2015-12-04 07:04:17 +08:00
|
|
|
|
2015-07-21 09:23:42 +08:00
|
|
|
isPollStarted: ->
|
2015-07-29 04:25:04 +08:00
|
|
|
if BBB.isPollGoing(getInSession('userId'))
|
2015-07-21 09:23:42 +08:00
|
|
|
return true
|
|
|
|
else
|
2015-07-29 04:25:04 +08:00
|
|
|
return false
|
|
|
|
|
2015-11-18 02:53:01 +08:00
|
|
|
hasNoPresentation: ->
|
|
|
|
Meteor.Presentations.findOne({'presentation.current':true})
|
|
|
|
|
2015-12-04 01:03:04 +08:00
|
|
|
forceSlideShow: ->
|
|
|
|
reactOnSlideChange()
|
|
|
|
|
2015-12-04 07:04:17 +08:00
|
|
|
clearSlide: ->
|
2015-12-04 07:15:29 +08:00
|
|
|
#clear the slide
|
2015-12-04 07:04:17 +08:00
|
|
|
whiteboardPaperModel?.removeAllImagesFromPaper()
|
|
|
|
|
|
|
|
# hide the cursor
|
|
|
|
whiteboardPaperModel?.cursor?.remove()
|
|
|
|
|
2015-12-04 01:03:04 +08:00
|
|
|
|
2015-03-28 08:59:56 +08:00
|
|
|
Template.whiteboard.events
|
2015-06-04 05:49:26 +08:00
|
|
|
'click .whiteboardFullscreenButton': (event, template) ->
|
2015-06-03 05:44:06 +08:00
|
|
|
enterWhiteboardFullscreen()
|
2015-06-04 05:49:26 +08:00
|
|
|
|
|
|
|
'click .exitFullscreenButton': (event, template) ->
|
|
|
|
if document.exitFullscreen
|
|
|
|
document.exitFullscreen()
|
|
|
|
else if document.mozCancelFullScreen
|
|
|
|
document.mozCancelFullScreen()
|
|
|
|
else if document.webkitExitFullscreen
|
|
|
|
document.webkitExitFullscreen()
|
2015-06-11 02:45:11 +08:00
|
|
|
|
2015-10-06 01:02:52 +08:00
|
|
|
'click .sadEmojiButton.inactiveEmojiButton': (event) ->
|
2015-10-06 02:34:10 +08:00
|
|
|
if $('.sadEmojiButton').css('opacity') is '1'
|
|
|
|
BBB.setEmojiStatus(BBB.getMeetingId(), getInSession('userId'), getInSession('userId'), getInSession('authToken'), "sad")
|
2015-11-02 07:34:49 +08:00
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-02 03:41:43 +08:00
|
|
|
|
2015-10-06 01:02:52 +08:00
|
|
|
'click .happyEmojiButton.inactiveEmojiButton': (event) ->
|
2015-10-06 02:34:10 +08:00
|
|
|
if $('.happyEmojiButton').css('opacity') is '1'
|
|
|
|
BBB.setEmojiStatus(BBB.getMeetingId(), getInSession('userId'), getInSession('userId'), getInSession('authToken'), "happy")
|
2015-11-02 07:34:49 +08:00
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-02 03:41:43 +08:00
|
|
|
|
2015-10-06 01:02:52 +08:00
|
|
|
'click .confusedEmojiButton.inactiveEmojiButton': (event) ->
|
2015-10-06 02:34:10 +08:00
|
|
|
if $('.confusedEmojiButton').css('opacity') is '1'
|
|
|
|
BBB.setEmojiStatus(BBB.getMeetingId(), getInSession('userId'), getInSession('userId'), getInSession('authToken'), "confused")
|
2015-11-02 07:34:49 +08:00
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-02 03:41:43 +08:00
|
|
|
|
2015-10-06 01:02:52 +08:00
|
|
|
'click .neutralEmojiButton.inactiveEmojiButton': (event) ->
|
2015-10-06 02:34:10 +08:00
|
|
|
if $('.neutralEmojiButton').css('opacity') is '1'
|
|
|
|
BBB.setEmojiStatus(BBB.getMeetingId(), getInSession('userId'), getInSession('userId'), getInSession('authToken'), "neutral")
|
2015-11-02 07:34:49 +08:00
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-02 03:41:43 +08:00
|
|
|
|
2015-10-06 01:02:52 +08:00
|
|
|
'click .awayEmojiButton.inactiveEmojiButton': (event) ->
|
2015-10-06 02:34:10 +08:00
|
|
|
if $('.awayEmojiButton').css('opacity') is '1'
|
|
|
|
BBB.setEmojiStatus(BBB.getMeetingId(), getInSession('userId'), getInSession('userId'), getInSession('authToken'), "away")
|
2015-11-02 07:34:49 +08:00
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-02 03:41:43 +08:00
|
|
|
|
2015-10-06 01:02:52 +08:00
|
|
|
'click .raiseHandEmojiButton.inactiveEmojiButton': (event) ->
|
2015-10-06 02:34:10 +08:00
|
|
|
if $('.raiseHandEmojiButton').css('opacity') is '1'
|
|
|
|
BBB.setEmojiStatus(BBB.getMeetingId(), getInSession('userId'), getInSession('userId'), getInSession('authToken'), "raiseHand")
|
2015-11-02 07:34:49 +08:00
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-02 03:41:43 +08:00
|
|
|
|
2015-10-06 01:02:52 +08:00
|
|
|
'click .activeEmojiButton': (event) ->
|
2015-10-06 02:34:10 +08:00
|
|
|
if $('.activeEmojiButton').css('opacity') is '1'
|
|
|
|
BBB.setEmojiStatus(BBB.getMeetingId(), getInSession('userId'), getInSession('userId'), getInSession('authToken'), "none")
|
2015-11-02 07:34:49 +08:00
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-03 09:07:28 +08:00
|
|
|
|
2015-11-02 07:34:49 +08:00
|
|
|
'click .FABTriggerButton': (event) ->
|
|
|
|
$('.FABTriggerButton').blur()
|
|
|
|
toggleEmojisFAB()
|
2015-10-02 03:41:43 +08:00
|
|
|
|
2015-11-19 02:05:55 +08:00
|
|
|
Template.whiteboardControls.events
|
|
|
|
'click .whiteboard-buttons-slide > .prev':(event) ->
|
2015-09-09 07:57:39 +08:00
|
|
|
BBB.goToPreviousPage()
|
|
|
|
|
2015-11-19 02:05:55 +08:00
|
|
|
'click .whiteboard-buttons-slide > .next':(event) ->
|
2015-09-09 07:57:39 +08:00
|
|
|
BBB.goToNextPage()
|
|
|
|
|
|
|
|
'click .switchSlideButton': (event) ->
|
|
|
|
$('.tooltip').hide()
|
|
|
|
|
|
|
|
Template.polling.events
|
2015-07-31 08:08:12 +08:00
|
|
|
'click .pollButtons': (event) ->
|
|
|
|
_key = @.label
|
|
|
|
_id = @.answer
|
|
|
|
BBB.sendPollResponseMessage(_key, _id)
|
|
|
|
|
2015-09-09 07:57:39 +08:00
|
|
|
Template.polling.rendered = ->
|
2015-09-10 01:24:57 +08:00
|
|
|
scaleWhiteboard()
|
2015-09-09 07:57:39 +08:00
|
|
|
|
|
|
|
Template.polling.destroyed = ->
|
2015-09-10 01:24:57 +08:00
|
|
|
setTimeout(scaleWhiteboard, 0)
|
2015-09-09 07:57:39 +08:00
|
|
|
|
2015-11-19 02:05:55 +08:00
|
|
|
Template.whiteboardControls.rendered = ->
|
2015-09-10 01:24:57 +08:00
|
|
|
scaleWhiteboard()
|
2015-09-09 07:57:39 +08:00
|
|
|
|
2015-11-19 02:05:55 +08:00
|
|
|
Template.whiteboardControls.destroyed = ->
|
2015-09-10 01:24:57 +08:00
|
|
|
setTimeout(scaleWhiteboard, 0)
|
2015-09-09 07:57:39 +08:00
|
|
|
|
2015-07-23 05:15:20 +08:00
|
|
|
Template.whiteboard.rendered = ->
|
|
|
|
$('#whiteboard').resizable
|
|
|
|
handles: 'e'
|
|
|
|
minWidth: 150
|
2015-07-23 05:25:46 +08:00
|
|
|
resize: () ->
|
|
|
|
adjustChatInputHeight()
|
2015-07-23 05:15:20 +08:00
|
|
|
start: () ->
|
2015-07-23 06:32:10 +08:00
|
|
|
if $('#chat').width() / $('#panels').width() > 0.2 # chat shrinking can't make it smaller than one fifth of the whiteboard-chat area
|
|
|
|
$('#whiteboard').resizable('option', 'maxWidth', $('#panels').width() - 200) # gives the chat enough space (200px)
|
|
|
|
else
|
|
|
|
$('#whiteboard').resizable('option', 'maxWidth', $('#whiteboard').width())
|
2015-07-23 05:15:20 +08:00
|
|
|
stop: () ->
|
|
|
|
$('#whiteboard').css('width', 100 * $('#whiteboard').width() / $('#panels').width() + '%') # transforms width to %
|
|
|
|
$('#whiteboard').resizable('option', 'maxWidth', null)
|
2015-08-27 05:37:27 +08:00
|
|
|
|
|
|
|
# whiteboard element needs to be available
|
|
|
|
Meteor.NotificationControl = new NotificationControl('notificationArea')
|
|
|
|
|
|
|
|
$(document).foundation() # initialize foundation javascript
|
2015-11-19 02:05:55 +08:00
|
|
|
|
|
|
|
Template.presenterUploaderControl.created = ->
|
|
|
|
this.isOpen = new ReactiveVar(false);
|
2015-11-19 06:47:30 +08:00
|
|
|
this.files = new ReactiveList({
|
|
|
|
sort: (a, b) ->
|
|
|
|
# Put the ones who still uploading first
|
|
|
|
(a.isUploading == b.isUploading) ? 0 : a.isUploading ? -1 : 1;
|
|
|
|
});
|
|
|
|
this.presentations = Meteor.Presentations.find({},
|
|
|
|
{
|
|
|
|
sort: {'presentation.current': -1, 'presentation.name': 1}
|
|
|
|
fields: {'presentation': 1}
|
|
|
|
});
|
|
|
|
|
|
|
|
fakeUpload = (file, list) ->
|
|
|
|
setTimeout (->
|
|
|
|
file.uploadedSize = file.uploadedSize + (Math.floor(Math.random() * file.size + file.uploadedSize)/10)
|
|
|
|
unless file.size > file.uploadedSize
|
|
|
|
file.uploadedSize = file.size
|
|
|
|
file.isUploading = false
|
|
|
|
|
|
|
|
list.update(file.name, file)
|
|
|
|
|
|
|
|
if file.isUploading == true
|
|
|
|
fakeUpload(file, list)
|
|
|
|
else
|
|
|
|
# TODO: Here we should remove and update te presentation on mongo
|
|
|
|
list.remove(file.name)
|
|
|
|
), 200
|
2015-11-19 02:05:55 +08:00
|
|
|
|
|
|
|
Template.presenterUploaderControl.events
|
|
|
|
'click .js-open':(event, template) ->
|
|
|
|
template.isOpen.set(true);
|
2015-11-19 06:47:30 +08:00
|
|
|
|
2015-11-19 02:05:55 +08:00
|
|
|
'click .js-close':(event, template) ->
|
|
|
|
template.isOpen.set(false);
|
|
|
|
|
2015-11-19 06:47:30 +08:00
|
|
|
'dragover [data-dropzone]':(e) ->
|
|
|
|
e.preventDefault()
|
|
|
|
$(e.currentTarget).addClass('hover')
|
|
|
|
|
|
|
|
'dragleave [data-dropzone]':(e) ->
|
|
|
|
e.preventDefault()
|
|
|
|
$(e.currentTarget).removeClass('hover')
|
|
|
|
|
|
|
|
'drop [data-dropzone], change [data-dropzone] > input[type="file"]':(e, template) ->
|
|
|
|
e.preventDefault();
|
|
|
|
files = (e.originalEvent.dataTransfer || e.originalEvent.target).files
|
|
|
|
|
|
|
|
_.each(files, (file) ->
|
|
|
|
file.isUploading = true;
|
|
|
|
file.uploadedSize = 0;
|
|
|
|
file.percUploaded = 0;
|
|
|
|
|
|
|
|
template.files.insert(file.name, file)
|
|
|
|
fakeUpload(file, template.files)
|
|
|
|
)
|
|
|
|
|
2015-11-19 02:05:55 +08:00
|
|
|
Template.presenterUploaderControl.helpers
|
|
|
|
isOpen: -> Template.instance().isOpen.get()
|
|
|
|
files: -> Template.instance().files.fetch()
|
2015-11-19 06:47:30 +08:00
|
|
|
presentations: -> Template.instance().presentations.fetch().map((x) -> x.presentation)
|
|
|
|
|
|
|
|
Template.presenterUploaderControlFileListItem.helpers
|
|
|
|
percUploaded: -> Math.round((this.uploadedSize / this.size) * 100)
|
|
|
|
|
|
|
|
Template.presenterUploaderControlPresentationListItem.events
|
|
|
|
'click [data-action-show]':(event, template) ->
|
|
|
|
console.info('Should show the file `' + this.name + '`');
|
|
|
|
|
|
|
|
'click [data-action-delete]':(event, template) ->
|
|
|
|
console.info('Should delete the file `' + this.name + '`');
|