bigbluebutton-Github/bigbluebutton-html5/app/client/main.coffee

322 lines
12 KiB
CoffeeScript
Raw Normal View History

# Helper to load javascript libraries from the BBB server
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
2015-09-04 23:48:51 +08:00
Meteor.Loader.loadJs("https://#{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 ->
# Load SIP libraries before the application starts
2014-11-18 06:02:17 +08:00
loadLib('sip.js')
loadLib('bbb_webrtc_bridge_sip.js')
2015-03-03 00:30:46 +08:00
loadLib('bbblogger.js')
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
)
#
2014-06-14 02:20:36 +08:00
Template.header.events
2014-09-24 02:27:59 +08:00
"click .chatBarIcon": (event) ->
$(".tooltip").hide()
2014-09-24 02:27:59 +08:00
toggleChatbar()
"click .hideNavbarIcon": (event) ->
$(".tooltip").hide()
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) ->
$(".tooltip").hide()
2014-09-24 02:27:59 +08:00
toggleMic @
2014-09-24 02:27:59 +08:00
"click .hideNavbarIcon": (event) ->
$(".tooltip").hide()
2014-09-24 02:27:59 +08:00
toggleNavbar()
"click .videoFeedIcon": (event) ->
$(".tooltip").hide()
toggleCam @
"click .toggleUserlistButton": (event) ->
if isLandscape() or isLandscapeMobile()
2015-06-19 03:09:17 +08:00
toggleUsersList()
else
if $('.sl-right-drawer').hasClass('sl-right-drawer-out')
toggleRightDrawer()
toggleRightArrowClockwise()
else
toggleShield()
2015-06-19 03:09:17 +08:00
toggleLeftDrawer()
toggleLeftArrowClockwise()
"click .toggleMenuButton": (event) ->
2015-06-19 03:09:17 +08:00
if $('.sl-left-drawer').hasClass('sl-left-drawer-out')
toggleLeftDrawer()
toggleLeftArrowClockwise()
else
toggleShield()
2015-06-19 03:09:17 +08:00
toggleRightDrawer()
toggleRightArrowClockwise()
"click .btn": (event) ->
$(".ui-tooltip").hide()
Template.menu.events
'click .slideButton': (event) ->
toggleShield()
toggleRightDrawer()
toggleRightArrowClockwise()
$('.slideButton').blur()
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'
}
]
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'
)
$(window).resize( ->
$('#dialog').dialog('close')
)
$('#shield').click () ->
toggleSlidingMenu()
2015-04-16 23:39:06 +08:00
if Meteor.config.app.autoJoinAudio
onAudioJoinHelper()
Template.main.events
'click .shield': (event) ->
$(".tooltip").hide()
toggleShield()
closeMenus()
'click .settingsIcon': (event) ->
setInSession("tempFontSize", getInSession("messageFontSize"))
$("#settingsModal").foundation('reveal', 'open');
'click .signOutIcon': (event) ->
$('.signOutIcon').blur()
$("#logoutModal").foundation('reveal', 'open');
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()
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)')
'panend #container': (event, template) ->
if isPortraitMobile()
2015-07-28 05:21:25 +08:00
panIsValid = getInSession('panIsValid')
menuPanned = getInSession('menuPanned')
leftDrawerWidth = $('.left-drawer').width()
screenWidth = $('#container').width()
setInSession 'panStarted', false
2015-07-28 05:21:25 +08:00
if panIsValid and
menuPanned is 'left' and
$('.left-drawer').css('transform') isnt 'none'
2015-07-28 05:21:25 +08:00
if parseInt($('.left-drawer').css('transform').split(',')[4]) < leftDrawerWidth / 2
$('.shield').removeClass('animatedShield')
$('.shield').css('opacity', '')
$('.left-drawer').removeClass('sl-left-drawer-out')
$('.left-drawer').css('transform', '')
$('.toggleUserlistButton').removeClass('sl-toggled-on')
$('.shield').removeClass('darken') # in case it was opened by clicking a button
else
2015-07-28 05:21:25 +08:00
$('.left-drawer').css('transform', 'translateX(' + leftDrawerWidth + 'px)')
$('.shield').css('opacity', 0.5)
$('.left-drawer').addClass('sl-left-drawer-out')
$('.left-drawer').css('transform', '')
$('.toggleUserlistButton').addClass('sl-toggled-on')
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
$('.shield').removeClass('animatedShield')
$('.shield').css('opacity', '')
2015-07-28 05:21:25 +08:00
$('.right-drawer').css('transform', 'translateX(' + screenWidth + 'px)')
$('.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)')
$('.right-drawer').addClass('sl-right-drawer-out')
$('.right-drawer').css('transform', '')
$('.toggleMenuButton').addClass('sl-toggled-on')
$('.left-drawer').addClass('sl-left-drawer')
$('.sl-left-drawer').removeClass('left-drawer')
$('.sl-left-drawer').addClass('sl-left-drawer-content-delay')
$('.right-drawer').addClass('sl-right-drawer')
$('.sl-right-drawer').removeClass('right-drawer')
$('.sl-right-drawer').addClass('sl-right-drawer-content-delay')
'panright #container, panleft #container': (event, template) ->
if isPortraitMobile() and isPanHorizontal(event)
# 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
setInSession 'panIsValid', true
setInSession 'menuPanned', 'right'
else
setInSession 'panIsValid', false
setInSession 'eventType', event.type
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()
# 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
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)')
if !getInSession('panStarted')
$('.shield').addClass('animatedShield')
$('.shield').css('opacity',
2015-07-28 05:21:25 +08:00
0.5 * (initTransformValue + event.deltaX) / leftDrawerWidth)
# 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
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)')
if !getInSession('panStarted')
$('.shield').addClass('animatedShield')
$('.shield').css('opacity',
2015-07-28 05:21:25 +08:00
0.5 * (screenWidth - initTransformValue - event.deltaX) / rightDrawerWidth)
2014-07-31 04:22:23 +08:00
Template.makeButton.rendered = ->
2014-09-24 02:27:59 +08:00
$('button[rel=tooltip]').tooltip()