Moves recording button related code to toolbar.js.

This commit is contained in:
Boris Grozev 2014-07-23 10:47:00 +03:00
parent 256694b966
commit 05975e30a3
2 changed files with 25 additions and 18 deletions

24
app.js
View File

@ -636,7 +636,7 @@ $(document).bind('joined.muc', function (event, jid, info) {
focus.setEndpointDisplayName(connection.emuc.myroomjid, focus.setEndpointDisplayName(connection.emuc.myroomjid,
nickname); nickname);
} }
showRecordingButton(false); Toolbar.showRecordingButton(false);
} }
if (focus && config.etherpad_base) { if (focus && config.etherpad_base) {
@ -668,7 +668,7 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
if (focus.confid === null) { if (focus.confid === null) {
console.log('make new conference with', jid); console.log('make new conference with', jid);
focus.makeConference(Object.keys(connection.emuc.members)); focus.makeConference(Object.keys(connection.emuc.members));
showRecordingButton(true); Toolbar.showRecordingButton(true);
} else { } else {
console.log('invite', jid, 'into conference'); console.log('invite', jid, 'into conference');
focus.addNewParticipant(jid); focus.addNewParticipant(jid);
@ -721,7 +721,7 @@ $(document).bind('left.muc', function (event, jid) {
if (Object.keys(connection.emuc.members).length > 0) { if (Object.keys(connection.emuc.members).length > 0) {
focus.makeConference(Object.keys(connection.emuc.members)); focus.makeConference(Object.keys(connection.emuc.members));
showRecordingButton(true); Toolbar.showRecordingButton(true);
} }
$(document).trigger('focusechanged.muc', [focus]); $(document).trigger('focusechanged.muc', [focus]);
} }
@ -735,7 +735,7 @@ $(document).bind('left.muc', function (event, jid) {
focus.setEndpointDisplayName(connection.emuc.myroomjid, focus.setEndpointDisplayName(connection.emuc.myroomjid,
nickname); nickname);
} }
showRecordingButton(false); Toolbar.showRecordingButton(false);
} }
if (connection.emuc.getPrezi(jid)) { if (connection.emuc.getPrezi(jid)) {
$(document).trigger('presentationremoved.muc', $(document).trigger('presentationremoved.muc',
@ -943,14 +943,14 @@ function toggleRecording() {
} }
var oldState = focus.recordingEnabled; var oldState = focus.recordingEnabled;
$('#recordButton').toggleClass('active'); Toolbar.toggleRecordingButtonState();
focus.setRecording(!oldState, focus.setRecording(!oldState,
recordingToken, recordingToken,
function (state) { function (state) {
console.log("New recording state: ", state); console.log("New recording state: ", state);
if (state == oldState) //failed to change, reset the token because it might have been wrong if (state == oldState) //failed to change, reset the token because it might have been wrong
{ {
$('#recordButton').toggleClass('active'); Toolbar.toggleRecordingButtonState();
setRecordingToken(null); setRecordingToken(null);
} }
} }
@ -1263,19 +1263,7 @@ function setView(viewName) {
// } // }
} }
function showRecordingButton(show) {
if (!config.enableRecording) {
return;
}
if (show) {
$('#recording').css({display: "inline"});
}
else {
$('#recording').css({display: "none"});
}
}
$(document).bind('fatalError.jingle', $(document).bind('fatalError.jingle',
function (event, session, error) function (event, session, error)

View File

@ -284,5 +284,24 @@ var Toolbar = (function (my) {
} }
}; };
// Shows or hides the 'recording' button.
my.showRecordingButton = function (show) {
if (!config.enableRecording) {
return;
}
if (show) {
$('#recording').css({display: "inline"});
}
else {
$('#recording').css({display: "none"});
}
};
// Toggle the state of the recording button
my.toggleRecordingButtonState = function() {
$('#recordButton').toggleClass('active');
};
return my; return my;
}(Toolbar || {})); }(Toolbar || {}));