Reload etherpad iFrame immediatly on color change

Instead of waiting for the next opening of the etherpad menu
master
Daniel Berteaud 11 years ago
parent c4a87c698c
commit 479639e1f7
  1. 35
      public/js/vroom.js

@ -850,6 +850,19 @@ function initVroom(room) {
}, 3000); }, 3000);
} }
// Load etherpad in its iFrame
function loadEtherpadIframe(){
$('#etherpadContainer').pad({
host: etherpad.uri,
padId: etherpad.group + '$' + room,
showControls: true,
showLineNumbers: false,
height: maxHeight()-7 + 'px',
border: 2,
userColor: peers.local.color
});
}
// An owner is muting/unmuting someone // An owner is muting/unmuting someone
webrtc.on('owner_toggle_mute', function(data){ webrtc.on('owner_toggle_mute', function(data){
// Ignore this if the remote peer isn't the owner of the room // Ignore this if the remote peer isn't the owner of the room
@ -1831,7 +1844,10 @@ function initVroom(room) {
// Choose another color. Useful if two peers have the same // Choose another color. Useful if two peers have the same
$('#changeColorButton').click(function(){ $('#changeColorButton').click(function(){
peers.local.color = chooseColor(); peers.local.color = chooseColor();
colorChanged = true; // Reload etherpadiFrame if required
if (etherpad.enabled){
loadEtherpadIframe();
}
webrtc.sendToAll('peer_color', {color: peers.local.color}); webrtc.sendToAll('peer_color', {color: peers.local.color});
updateDisplayName('local'); updateDisplayName('local');
}); });
@ -1937,27 +1953,16 @@ function initVroom(room) {
$('#etherpadButton').change(function(){ $('#etherpadButton').change(function(){
var action = ($(this).is(':checked')) ? 'show':'hide'; var action = ($(this).is(':checked')) ? 'show':'hide';
if (action == 'show'){ if (action == 'show'){
// If not already loaded, or our color changed, load etherpad in the iFrame // If not already loaded, load etherpad in the iFrame
if ($('#etherpadContainer').html() == '' || colorChanged){ if ($('#etherpadContainer').html() == ''){
$('#etherpadContainer').pad({ loadEtherpadIframe();
host: etherpad.uri,
padId: etherpad.group + '$' + room,
showControls: true,
showLineNumbers: false,
height: maxHeight()-7 + 'px',
border: 2,
userColor: peers.local.color
});
colorChanged = false;
} }
$('#etherpadLabel').addClass('btn-danger'); $('#etherpadLabel').addClass('btn-danger');
$('#etherpadContainer').slideDown('200'); $('#etherpadContainer').slideDown('200');
$('#changeColorButton').addClass('disabled');
} }
else{ else{
$('#etherpadLabel').removeClass('btn-danger'); $('#etherpadLabel').removeClass('btn-danger');
$('#etherpadContainer').slideUp('200'); $('#etherpadContainer').slideUp('200');
$('#changeColorButton').removeClass('disabled');
} }
}); });
} }

Loading…
Cancel
Save