2015-05-14 01:49:09 +08:00
|
|
|
# Helper to load javascript libraries from the BBB server
|
2014-11-12 02:56:39 +08:00
|
|
|
loadLib = (libname) ->
|
|
|
|
successCallback = ->
|
|
|
|
|
|
|
|
retryMessageCallback = (param) ->
|
2014-11-13 05:04:03 +08:00
|
|
|
#Meteor.log.info "Failed to load library", param
|
|
|
|
console.log "Failed to load library", param
|
2014-11-12 02:56:39 +08:00
|
|
|
|
|
|
|
Meteor.Loader.loadJs("http://#{window.location.hostname}/client/lib/#{libname}", successCallback, 10000).fail(retryMessageCallback)
|
|
|
|
|
2014-06-14 02:20:36 +08:00
|
|
|
# These settings can just be stored locally in session, created at start up
|
|
|
|
Meteor.startup ->
|
2014-11-12 02:56:39 +08:00
|
|
|
# Load SIP libraries before the application starts
|
2014-11-18 06:02:17 +08:00
|
|
|
loadLib('sip.js')
|
2014-11-12 02:56:39 +08:00
|
|
|
loadLib('bbb_webrtc_bridge_sip.js')
|
2015-03-03 00:30:46 +08:00
|
|
|
loadLib('bbblogger.js')
|
2014-11-12 02:56:39 +08:00
|
|
|
|
2014-09-24 02:27:59 +08:00
|
|
|
@SessionAmplify = _.extend({}, Session,
|
|
|
|
keys: _.object(_.map(amplify.store(), (value, key) ->
|
|
|
|
[
|
|
|
|
key
|
|
|
|
JSON.stringify(value)
|
|
|
|
]
|
|
|
|
))
|
|
|
|
set: (key, value) ->
|
|
|
|
Session.set.apply this, arguments
|
|
|
|
amplify.store key, value
|
|
|
|
return
|
|
|
|
)
|
2015-03-05 05:31:05 +08:00
|
|
|
#
|
2014-06-14 02:20:36 +08:00
|
|
|
Template.header.events
|
2014-09-24 02:27:59 +08:00
|
|
|
"click .chatBarIcon": (event) ->
|
2014-11-02 07:11:06 +08:00
|
|
|
$(".tooltip").hide()
|
2014-09-24 02:27:59 +08:00
|
|
|
toggleChatbar()
|
2014-11-06 23:27:43 +08:00
|
|
|
|
|
|
|
"click .hideNavbarIcon": (event) ->
|
2014-11-02 07:11:06 +08:00
|
|
|
$(".tooltip").hide()
|
2014-11-06 23:27:43 +08:00
|
|
|
toggleNavbar()
|
|
|
|
|
2015-04-01 03:36:16 +08:00
|
|
|
"click .leaveAudioButton": (event) ->
|
|
|
|
exitVoiceCall event
|
|
|
|
|
2014-09-24 02:27:59 +08:00
|
|
|
"click .muteIcon": (event) ->
|
2014-11-02 07:11:06 +08:00
|
|
|
$(".tooltip").hide()
|
2014-09-24 02:27:59 +08:00
|
|
|
toggleMic @
|
2014-11-06 23:27:43 +08:00
|
|
|
|
2014-09-24 02:27:59 +08:00
|
|
|
"click .hideNavbarIcon": (event) ->
|
2014-11-02 07:11:06 +08:00
|
|
|
$(".tooltip").hide()
|
2014-09-24 02:27:59 +08:00
|
|
|
toggleNavbar()
|
2014-11-06 23:27:43 +08:00
|
|
|
|
|
|
|
"click .videoFeedIcon": (event) ->
|
2014-11-02 07:11:06 +08:00
|
|
|
$(".tooltip").hide()
|
2014-11-06 23:27:43 +08:00
|
|
|
toggleCam @
|
|
|
|
|
2015-05-15 03:17:07 +08:00
|
|
|
"click .toggleUserlistButton": (event) ->
|
2015-06-19 03:09:17 +08:00
|
|
|
if isLandscape()
|
|
|
|
toggleUsersList()
|
|
|
|
else
|
|
|
|
if $('.sl-right-drawer').hasClass('sl-right-drawer-out')
|
|
|
|
toggleRightDrawer()
|
|
|
|
toggleRightArrowClockwise()
|
2015-06-19 05:05:18 +08:00
|
|
|
else
|
|
|
|
toggleShield()
|
2015-06-19 03:09:17 +08:00
|
|
|
toggleLeftDrawer()
|
|
|
|
toggleLeftArrowClockwise()
|
2015-05-06 22:52:43 +08:00
|
|
|
|
2015-05-13 00:51:06 +08:00
|
|
|
"click .toggleMenuButton": (event) ->
|
2015-06-19 03:09:17 +08:00
|
|
|
if $('.sl-left-drawer').hasClass('sl-left-drawer-out')
|
|
|
|
toggleLeftDrawer()
|
|
|
|
toggleLeftArrowClockwise()
|
2015-06-19 05:05:18 +08:00
|
|
|
else
|
|
|
|
toggleShield()
|
2015-06-19 03:09:17 +08:00
|
|
|
toggleRightDrawer()
|
|
|
|
toggleRightArrowClockwise()
|
2015-05-13 00:51:06 +08:00
|
|
|
|
2015-05-13 02:10:30 +08:00
|
|
|
Template.menu.events
|
|
|
|
'click .slideButton': (event) ->
|
2015-06-19 04:33:48 +08:00
|
|
|
toggleShield()
|
|
|
|
toggleRightDrawer()
|
|
|
|
toggleRightArrowClockwise()
|
2015-05-13 02:10:30 +08:00
|
|
|
|
2015-05-27 05:09:54 +08:00
|
|
|
'click .toggleChatButton': (event) ->
|
|
|
|
toggleChatbar()
|
|
|
|
|
2014-11-21 11:15:29 +08:00
|
|
|
Template.main.rendered = ->
|
|
|
|
$("#dialog").dialog(
|
|
|
|
modal: true
|
|
|
|
draggable: false
|
|
|
|
resizable: false
|
|
|
|
autoOpen: false
|
|
|
|
dialogClass: 'no-close logout-dialog'
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
text: 'Yes'
|
|
|
|
click: () ->
|
2015-05-06 04:15:33 +08:00
|
|
|
userLogout BBB.getMeetingId(), getInSession("userId"), true
|
2014-11-21 11:15:29 +08:00
|
|
|
$(this).dialog("close")
|
|
|
|
class: 'btn btn-xs btn-primary active'
|
|
|
|
}
|
|
|
|
{
|
|
|
|
text: 'No'
|
|
|
|
click: () ->
|
|
|
|
$(this).dialog("close")
|
|
|
|
$(".tooltip").hide()
|
|
|
|
class: 'btn btn-xs btn-default'
|
|
|
|
}
|
|
|
|
]
|
2015-03-10 05:30:25 +08:00
|
|
|
open: (event, ui) ->
|
|
|
|
$('.ui-widget-overlay').bind 'click', () ->
|
|
|
|
if isMobile()
|
|
|
|
$("#dialog").dialog('close')
|
2014-11-21 11:15:29 +08:00
|
|
|
position:
|
|
|
|
my: 'right top'
|
|
|
|
at: 'right bottom'
|
|
|
|
of: '.signOutIcon'
|
|
|
|
)
|
|
|
|
|
2015-05-12 04:02:11 +08:00
|
|
|
Meteor.NotificationControl = new NotificationControl('notificationArea')
|
|
|
|
$(document).foundation() # initialize foundation javascript
|
2015-03-15 10:08:34 +08:00
|
|
|
|
2014-12-20 03:01:45 +08:00
|
|
|
$(window).resize( ->
|
|
|
|
$('#dialog').dialog('close')
|
|
|
|
)
|
|
|
|
|
2015-03-06 01:25:11 +08:00
|
|
|
$('#shield').click () ->
|
|
|
|
toggleSlidingMenu()
|
|
|
|
|
2015-04-16 23:39:06 +08:00
|
|
|
if Meteor.config.app.autoJoinAudio
|
2015-04-23 05:16:30 +08:00
|
|
|
onAudioJoinHelper()
|
2015-04-15 00:05:32 +08:00
|
|
|
|
2015-05-15 04:58:34 +08:00
|
|
|
Template.main.events
|
|
|
|
'click .shield': (event) ->
|
2015-06-19 04:14:54 +08:00
|
|
|
toggleShield()
|
|
|
|
closeMenus()
|
2015-05-15 04:58:34 +08:00
|
|
|
|
2015-05-27 02:05:19 +08:00
|
|
|
'click .settingsIcon': (event) ->
|
|
|
|
setInSession("tempFontSize", getInSession("messageFontSize"))
|
|
|
|
$("#settingsModal").foundation('reveal', 'open');
|
|
|
|
|
2015-05-27 04:27:41 +08:00
|
|
|
'click .signOutIcon': (event) ->
|
|
|
|
$('.signOutIcon').blur()
|
|
|
|
$("#logoutModal").foundation('reveal', 'open');
|
|
|
|
|
2015-07-25 06:20:00 +08:00
|
|
|
Template.main.gestures
|
|
|
|
'panstart #container': (event, template) ->
|
|
|
|
if isPortraitMobile() and isPanHorizontal(event)
|
2015-07-28 05:21:25 +08:00
|
|
|
panIsValid = getInSession('panIsValid')
|
|
|
|
initTransformValue = getInSession('initTransform')
|
|
|
|
menuPanned = getInSession('menuPanned')
|
|
|
|
screenWidth = $('#container').width()
|
|
|
|
|
2015-07-25 06:20:00 +08:00
|
|
|
setInSession 'panStarted', true
|
2015-07-28 05:21:25 +08:00
|
|
|
|
|
|
|
if panIsValid and
|
|
|
|
menuPanned is 'left' and
|
|
|
|
initTransformValue + event.deltaX >= 0 and
|
|
|
|
initTransformValue + event.deltaX <= $('.left-drawer').width()
|
|
|
|
$('.left-drawer').css('transform', 'translateX(' + (initTransformValue + event.deltaX) + 'px)')
|
|
|
|
|
|
|
|
else if panIsValid and
|
|
|
|
menuPanned is 'right' and
|
|
|
|
initTransformValue + event.deltaX >= screenWidth - $('.right-drawer').width() and
|
|
|
|
initTransformValue + event.deltaX <= screenWidth
|
|
|
|
$('.right-drawer').css('transform', 'translateX(' + (initTransformValue + event.deltaX) + 'px)')
|
2015-07-28 04:14:29 +08:00
|
|
|
|
2015-07-25 06:20:00 +08:00
|
|
|
'panend #container': (event, template) ->
|
2015-07-26 10:28:01 +08:00
|
|
|
if isPortraitMobile()
|
2015-07-28 05:21:25 +08:00
|
|
|
panIsValid = getInSession('panIsValid')
|
|
|
|
menuPanned = getInSession('menuPanned')
|
|
|
|
leftDrawerWidth = $('.left-drawer').width()
|
|
|
|
screenWidth = $('#container').width()
|
|
|
|
|
2015-07-25 06:20:00 +08:00
|
|
|
setInSession 'panStarted', false
|
2015-07-28 05:21:25 +08:00
|
|
|
|
|
|
|
if panIsValid and
|
|
|
|
menuPanned is 'left' and
|
2015-07-28 04:14:29 +08:00
|
|
|
$('.left-drawer').css('transform') isnt 'none'
|
2015-07-28 05:21:25 +08:00
|
|
|
|
|
|
|
if parseInt($('.left-drawer').css('transform').split(',')[4]) < leftDrawerWidth / 2
|
2015-07-27 09:51:18 +08:00
|
|
|
$('.shield').removeClass('animatedShield')
|
|
|
|
$('.shield').css('opacity', '')
|
|
|
|
$('.left-drawer').removeClass('sl-left-drawer-out')
|
|
|
|
$('.left-drawer').css('transform', '')
|
2015-07-27 23:54:46 +08:00
|
|
|
$('.toggleUserlistButton').removeClass('sl-toggled-on')
|
|
|
|
$('.shield').removeClass('darken') # in case it was opened by clicking a button
|
2015-07-26 10:28:01 +08:00
|
|
|
else
|
2015-07-28 05:21:25 +08:00
|
|
|
$('.left-drawer').css('transform', 'translateX(' + leftDrawerWidth + 'px)')
|
2015-07-27 09:51:18 +08:00
|
|
|
$('.shield').css('opacity', 0.5)
|
|
|
|
$('.left-drawer').addClass('sl-left-drawer-out')
|
|
|
|
$('.left-drawer').css('transform', '')
|
2015-07-27 23:54:46 +08:00
|
|
|
$('.toggleUserlistButton').addClass('sl-toggled-on')
|
2015-07-28 04:14:29 +08:00
|
|
|
|
2015-07-28 05:21:25 +08:00
|
|
|
if panIsValid and
|
|
|
|
menuPanned is 'right' and
|
|
|
|
parseInt($('.right-drawer').css('transform').split(',')[4]) isnt leftDrawerWidth
|
|
|
|
|
|
|
|
if parseInt($('.right-drawer').css('transform').split(',')[4]) > screenWidth - $('.right-drawer').width() / 2
|
2015-07-28 04:14:29 +08:00
|
|
|
$('.shield').removeClass('animatedShield')
|
|
|
|
$('.shield').css('opacity', '')
|
2015-07-28 05:21:25 +08:00
|
|
|
$('.right-drawer').css('transform', 'translateX(' + screenWidth + 'px)')
|
2015-07-28 04:14:29 +08:00
|
|
|
$('.right-drawer').removeClass('sl-right-drawer-out')
|
|
|
|
$('.right-drawer').css('transform', '')
|
|
|
|
$('.toggleMenuButton').removeClass('sl-toggled-on')
|
|
|
|
$('.shield').removeClass('darken') # in case it was opened by clicking a button
|
|
|
|
else
|
|
|
|
$('.shield').css('opacity', 0.5)
|
2015-07-28 05:21:25 +08:00
|
|
|
$('.right-drawer').css('transform', 'translateX(' + (screenWidth - $('.right-drawer').width()) + 'px)')
|
2015-07-28 04:14:29 +08:00
|
|
|
$('.right-drawer').addClass('sl-right-drawer-out')
|
|
|
|
$('.right-drawer').css('transform', '')
|
|
|
|
$('.toggleMenuButton').addClass('sl-toggled-on')
|
|
|
|
|
2015-07-25 06:20:00 +08:00
|
|
|
$('.left-drawer').addClass('sl-left-drawer')
|
|
|
|
$('.sl-left-drawer').removeClass('left-drawer')
|
2015-07-28 04:14:29 +08:00
|
|
|
|
|
|
|
$('.right-drawer').addClass('sl-right-drawer')
|
|
|
|
$('.sl-right-drawer').removeClass('right-drawer')
|
|
|
|
|
2015-07-25 06:20:00 +08:00
|
|
|
'panright #container, panleft #container': (event, template) ->
|
|
|
|
if isPortraitMobile() and isPanHorizontal(event)
|
2015-07-28 04:14:29 +08:00
|
|
|
|
|
|
|
# panright/panleft is always triggered once right before panstart
|
|
|
|
if !getInSession('panStarted')
|
|
|
|
|
|
|
|
# opening the left-hand menu
|
|
|
|
if event.type is 'panright' and
|
|
|
|
event.center.x <= $('#container').width() * 0.1
|
|
|
|
setInSession 'panIsValid', true
|
|
|
|
setInSession 'menuPanned', 'left'
|
|
|
|
|
|
|
|
# closing the left-hand menu
|
|
|
|
else if event.type is 'panleft' and
|
|
|
|
event.center.x < $('#container').width() * 0.9
|
|
|
|
setInSession 'panIsValid', true
|
|
|
|
setInSession 'menuPanned', 'left'
|
|
|
|
|
|
|
|
# opening the right-hand menu
|
|
|
|
else if event.type is 'panleft' and
|
|
|
|
event.center.x >= $('#container').width() * 0.9
|
|
|
|
setInSession 'panIsValid', true
|
|
|
|
setInSession 'menuPanned', 'right'
|
|
|
|
|
|
|
|
# closing the right-hand menu
|
|
|
|
else if event.type is 'panright' and
|
|
|
|
event.center.x > $('#container').width() * 0.1
|
2015-07-26 10:28:01 +08:00
|
|
|
setInSession 'panIsValid', true
|
2015-07-28 04:14:29 +08:00
|
|
|
setInSession 'menuPanned', 'right'
|
|
|
|
|
2015-07-26 10:28:01 +08:00
|
|
|
else
|
|
|
|
setInSession 'panIsValid', false
|
2015-07-28 04:14:29 +08:00
|
|
|
|
2015-07-26 10:28:01 +08:00
|
|
|
setInSession 'eventType', event.type
|
2015-07-28 04:14:29 +08:00
|
|
|
|
|
|
|
if getInSession('menuPanned') is 'left'
|
|
|
|
if $('.sl-left-drawer').css('transform') isnt 'none' # menu is already transformed
|
|
|
|
setInSession 'initTransform', parseInt($('.sl-left-drawer').css('transform').split(',')[4]) # translateX value
|
|
|
|
else if $('.sl-left-drawer').hasClass('sl-left-drawer-out')
|
|
|
|
setInSession 'initTransform', $('.sl-left-drawer').width()
|
|
|
|
else
|
|
|
|
setInSession 'initTransform', 0
|
|
|
|
$('.sl-left-drawer').addClass('left-drawer')
|
|
|
|
$('.left-drawer').removeClass('sl-left-drawer') # to prevent animations from Sled library
|
|
|
|
$('.left-drawer').removeClass('sl-left-drawer-content-delay') # makes the menu content movable too
|
|
|
|
|
|
|
|
else if getInSession('menuPanned') is 'right'
|
|
|
|
if $('.sl-right-drawer').css('transform') isnt 'none' # menu is already transformed
|
|
|
|
setInSession 'initTransform', parseInt($('.sl-right-drawer').css('transform').split(',')[4]) # translateX value
|
|
|
|
else if $('.sl-right-drawer').hasClass('sl-right-drawer-out')
|
|
|
|
setInSession 'initTransform', $('.sl-right-drawer').width()
|
|
|
|
else
|
|
|
|
setInSession 'initTransform', 0
|
|
|
|
$('.sl-right-drawer').addClass('right-drawer')
|
|
|
|
$('.right-drawer').removeClass('sl-right-drawer') # to prevent animations from Sled library
|
|
|
|
$('.right-drawer').removeClass('sl-right-drawer-content-delay') # makes the menu content movable too
|
|
|
|
|
2015-07-28 05:21:25 +08:00
|
|
|
initTransformValue = getInSession('initTransform')
|
|
|
|
panIsValid = getInSession('panIsValid')
|
|
|
|
menuPanned = getInSession('menuPanned')
|
|
|
|
leftDrawerWidth = $('.left-drawer').width()
|
|
|
|
rightDrawerWidth = $('.right-drawer').width()
|
|
|
|
screenWidth = $('#container').width()
|
|
|
|
|
2015-07-28 04:14:29 +08:00
|
|
|
# moving the left-hand menu
|
2015-07-28 05:21:25 +08:00
|
|
|
if panIsValid and
|
|
|
|
menuPanned is 'left' and
|
|
|
|
initTransformValue + event.deltaX >= 0 and
|
|
|
|
initTransformValue + event.deltaX <= leftDrawerWidth
|
2015-07-28 04:14:29 +08:00
|
|
|
|
|
|
|
if $('.sl-right-drawer').hasClass('sl-right-drawer-out')
|
|
|
|
toggleRightDrawer()
|
|
|
|
toggleRightArrowClockwise()
|
|
|
|
|
2015-07-28 05:21:25 +08:00
|
|
|
$('.left-drawer').css('transform', 'translateX(' + (initTransformValue + event.deltaX) + 'px)')
|
2015-07-28 04:14:29 +08:00
|
|
|
|
|
|
|
if !getInSession('panStarted')
|
|
|
|
$('.shield').addClass('animatedShield')
|
|
|
|
$('.shield').css('opacity',
|
2015-07-28 05:21:25 +08:00
|
|
|
0.5 * (initTransformValue + event.deltaX) / leftDrawerWidth)
|
2015-07-28 04:14:29 +08:00
|
|
|
|
|
|
|
# moving the right-hand menu
|
2015-07-28 05:21:25 +08:00
|
|
|
else if panIsValid and
|
|
|
|
menuPanned is 'right' and
|
|
|
|
initTransformValue + event.deltaX >= screenWidth - rightDrawerWidth and
|
|
|
|
initTransformValue + event.deltaX <= screenWidth
|
2015-07-28 04:14:29 +08:00
|
|
|
|
|
|
|
if $('.sl-left-drawer').hasClass('sl-left-drawer-out')
|
|
|
|
toggleLeftDrawer()
|
|
|
|
toggleLeftArrowClockwise()
|
|
|
|
|
2015-07-28 05:21:25 +08:00
|
|
|
$('.right-drawer').css('transform', 'translateX(' + (initTransformValue + event.deltaX) + 'px)')
|
2015-07-28 04:14:29 +08:00
|
|
|
|
2015-07-27 09:51:18 +08:00
|
|
|
if !getInSession('panStarted')
|
|
|
|
$('.shield').addClass('animatedShield')
|
2015-07-28 04:14:29 +08:00
|
|
|
$('.shield').css('opacity',
|
2015-07-28 05:21:25 +08:00
|
|
|
0.5 * (screenWidth - initTransformValue - event.deltaX) / rightDrawerWidth)
|
2015-07-25 06:20:00 +08:00
|
|
|
|
2014-07-31 04:22:23 +08:00
|
|
|
Template.makeButton.rendered = ->
|
2014-09-24 02:27:59 +08:00
|
|
|
$('button[rel=tooltip]').tooltip()
|