2014-03-26 10:33:46 +00:00
|
|
|
var Prezi = (function (my) {
|
|
|
|
var preziPlayer = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reloads the current presentation.
|
|
|
|
*/
|
|
|
|
my.reloadPresentation = function() {
|
|
|
|
var iframe = document.getElementById(preziPlayer.options.preziId);
|
|
|
|
iframe.src = iframe.src;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows/hides a presentation.
|
|
|
|
*/
|
|
|
|
my.setPresentationVisible = function (visible) {
|
2014-11-28 14:02:48 +00:00
|
|
|
var prezi = $('#presentation>iframe');
|
2014-03-26 10:33:46 +00:00
|
|
|
if (visible) {
|
|
|
|
// Trigger the video.selected event to indicate a change in the
|
|
|
|
// large video.
|
|
|
|
$(document).trigger("video.selected", [true]);
|
|
|
|
|
2014-11-28 14:02:48 +00:00
|
|
|
$('#largeVideo').fadeOut(300);
|
|
|
|
prezi.fadeIn(300, function() {
|
|
|
|
prezi.css({opacity:'1'});
|
|
|
|
ToolbarToggler.dockToolbar(true);
|
2014-06-12 18:35:42 +00:00
|
|
|
VideoLayout.setLargeVideoVisible(false);
|
2014-03-26 10:33:46 +00:00
|
|
|
});
|
2014-12-12 09:32:16 +00:00
|
|
|
$('#activeSpeaker').css('visibility', 'hidden');
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-11-28 14:02:48 +00:00
|
|
|
if (prezi.css('opacity') == '1') {
|
|
|
|
prezi.fadeOut(300, function () {
|
|
|
|
prezi.css({opacity:'0'});
|
2014-03-26 10:33:46 +00:00
|
|
|
$('#reloadPresentation').css({display:'none'});
|
|
|
|
$('#largeVideo').fadeIn(300, function() {
|
2014-06-12 18:35:42 +00:00
|
|
|
VideoLayout.setLargeVideoVisible(true);
|
2014-09-04 13:18:28 +00:00
|
|
|
ToolbarToggler.dockToolbar(false);
|
2014-03-26 10:33:46 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns <tt>true</tt> if the presentation is visible, <tt>false</tt> -
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
my.isPresentationVisible = function () {
|
|
|
|
return ($('#presentation>iframe') != null
|
|
|
|
&& $('#presentation>iframe').css('opacity') == 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the Prezi dialog, from which the user could choose a presentation
|
|
|
|
* to load.
|
|
|
|
*/
|
|
|
|
my.openPreziDialog = function() {
|
|
|
|
var myprezi = connection.emuc.getPrezi(connection.emuc.myroomjid);
|
|
|
|
if (myprezi) {
|
2014-08-14 15:29:28 +00:00
|
|
|
messageHandler.openTwoButtonDialog("Remove Prezi",
|
|
|
|
"Are you sure you would like to remove your Prezi?",
|
|
|
|
false,
|
|
|
|
"Remove",
|
|
|
|
function(e,v,m,f) {
|
|
|
|
if(v) {
|
2014-03-26 10:33:46 +00:00
|
|
|
connection.emuc.removePreziFromPresence();
|
|
|
|
connection.emuc.sendPresence();
|
|
|
|
}
|
|
|
|
}
|
2014-08-14 15:29:28 +00:00
|
|
|
);
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
else if (preziPlayer != null) {
|
2014-08-14 15:29:28 +00:00
|
|
|
messageHandler.openTwoButtonDialog("Share a Prezi",
|
|
|
|
"Another participant is already sharing a Prezi." +
|
2014-03-26 10:33:46 +00:00
|
|
|
"This conference allows only one Prezi at a time.",
|
2014-08-14 15:29:28 +00:00
|
|
|
false,
|
|
|
|
"Ok",
|
|
|
|
function(e,v,m,f) {
|
|
|
|
$.prompt.close();
|
|
|
|
}
|
|
|
|
);
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
var openPreziState = {
|
2014-08-14 15:29:28 +00:00
|
|
|
state0: {
|
|
|
|
html: '<h2>Share a Prezi</h2>' +
|
|
|
|
'<input id="preziUrl" type="text" ' +
|
|
|
|
'placeholder="e.g. ' +
|
|
|
|
'http://prezi.com/wz7vhjycl7e6/my-prezi" autofocus>',
|
|
|
|
persistent: false,
|
|
|
|
buttons: { "Share": true , "Cancel": false},
|
|
|
|
defaultButton: 1,
|
|
|
|
submit: function(e,v,m,f){
|
|
|
|
e.preventDefault();
|
|
|
|
if(v)
|
2014-03-26 10:33:46 +00:00
|
|
|
{
|
2014-08-14 15:29:28 +00:00
|
|
|
var preziUrl = document.getElementById('preziUrl');
|
2014-03-26 10:33:46 +00:00
|
|
|
|
2014-08-14 15:29:28 +00:00
|
|
|
if (preziUrl.value)
|
2014-03-26 10:33:46 +00:00
|
|
|
{
|
2014-08-14 15:29:28 +00:00
|
|
|
var urlValue
|
|
|
|
= encodeURI(Util.escapeHtml(preziUrl.value));
|
|
|
|
|
|
|
|
if (urlValue.indexOf('http://prezi.com/') != 0
|
|
|
|
&& urlValue.indexOf('https://prezi.com/') != 0)
|
|
|
|
{
|
2014-03-26 10:33:46 +00:00
|
|
|
$.prompt.goToState('state1');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
2014-08-14 15:29:28 +00:00
|
|
|
var presIdTmp = urlValue.substring(
|
|
|
|
urlValue.indexOf("prezi.com/") + 10);
|
|
|
|
if (!isAlphanumeric(presIdTmp)
|
|
|
|
|| presIdTmp.indexOf('/') < 2) {
|
|
|
|
$.prompt.goToState('state1');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
connection.emuc
|
|
|
|
.addPreziToPresence(urlValue, 0);
|
|
|
|
connection.emuc.sendPresence();
|
|
|
|
$.prompt.close();
|
|
|
|
}
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-14 15:29:28 +00:00
|
|
|
else
|
|
|
|
$.prompt.close();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
state1: {
|
|
|
|
html: '<h2>Share a Prezi</h2>' +
|
|
|
|
'Please provide a correct prezi link.',
|
|
|
|
persistent: false,
|
|
|
|
buttons: { "Back": true, "Cancel": false },
|
|
|
|
defaultButton: 1,
|
|
|
|
submit:function(e,v,m,f) {
|
|
|
|
e.preventDefault();
|
|
|
|
if(v==0)
|
|
|
|
$.prompt.close();
|
|
|
|
else
|
|
|
|
$.prompt.goToState('state0');
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-08-14 15:29:28 +00:00
|
|
|
var focusPreziUrl = function(e) {
|
|
|
|
document.getElementById('preziUrl').focus();
|
|
|
|
};
|
|
|
|
messageHandler.openDialogWithStates(openPreziState, focusPreziUrl, focusPreziUrl);
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A new presentation has been added.
|
|
|
|
*
|
|
|
|
* @param event the event indicating the add of a presentation
|
|
|
|
* @param jid the jid from which the presentation was added
|
|
|
|
* @param presUrl url of the presentation
|
|
|
|
* @param currentSlide the current slide to which we should move
|
|
|
|
*/
|
|
|
|
var presentationAdded = function(event, jid, presUrl, currentSlide) {
|
|
|
|
console.log("presentation added", presUrl);
|
|
|
|
|
|
|
|
var presId = getPresentationId(presUrl);
|
2014-05-30 15:18:32 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
var elementId = 'participant_'
|
|
|
|
+ Strophe.getResourceFromJid(jid)
|
|
|
|
+ '_' + presId;
|
|
|
|
|
2014-05-30 15:18:32 +00:00
|
|
|
// We explicitly don't specify the peer jid here, because we don't want
|
|
|
|
// this video to be dealt with as a peer related one (for example we
|
|
|
|
// don't want to show a mute/kick menu for this one, etc.).
|
2014-06-12 18:35:42 +00:00
|
|
|
VideoLayout.addRemoteVideoContainer(null, elementId);
|
|
|
|
VideoLayout.resizeThumbnails();
|
2014-03-26 10:33:46 +00:00
|
|
|
|
|
|
|
var controlsEnabled = false;
|
|
|
|
if (jid === connection.emuc.myroomjid)
|
|
|
|
controlsEnabled = true;
|
|
|
|
|
|
|
|
Prezi.setPresentationVisible(true);
|
|
|
|
$('#largeVideoContainer').hover(
|
|
|
|
function (event) {
|
|
|
|
if (Prezi.isPresentationVisible()) {
|
|
|
|
var reloadButtonRight = window.innerWidth
|
|
|
|
- $('#presentation>iframe').offset().left
|
|
|
|
- $('#presentation>iframe').width();
|
|
|
|
|
|
|
|
$('#reloadPresentation').css({ right: reloadButtonRight,
|
|
|
|
display:'inline-block'});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
function (event) {
|
|
|
|
if (!Prezi.isPresentationVisible())
|
|
|
|
$('#reloadPresentation').css({display:'none'});
|
|
|
|
else {
|
|
|
|
var e = event.toElement || event.relatedTarget;
|
|
|
|
|
|
|
|
if (e && e.id != 'reloadPresentation' && e.id != 'header')
|
|
|
|
$('#reloadPresentation').css({display:'none'});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
preziPlayer = new PreziPlayer(
|
|
|
|
'presentation',
|
|
|
|
{preziId: presId,
|
|
|
|
width: getPresentationWidth(),
|
|
|
|
height: getPresentationHeihgt(),
|
|
|
|
controls: controlsEnabled,
|
|
|
|
debug: true
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#presentation>iframe').attr('id', preziPlayer.options.preziId);
|
|
|
|
|
|
|
|
preziPlayer.on(PreziPlayer.EVENT_STATUS, function(event) {
|
|
|
|
console.log("prezi status", event.value);
|
|
|
|
if (event.value == PreziPlayer.STATUS_CONTENT_READY) {
|
|
|
|
if (jid != connection.emuc.myroomjid)
|
|
|
|
preziPlayer.flyToStep(currentSlide);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
preziPlayer.on(PreziPlayer.EVENT_CURRENT_STEP, function(event) {
|
|
|
|
console.log("event value", event.value);
|
|
|
|
connection.emuc.addCurrentSlideToPresence(event.value);
|
|
|
|
connection.emuc.sendPresence();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#" + elementId).css( 'background-image',
|
|
|
|
'url(../images/avatarprezi.png)');
|
|
|
|
$("#" + elementId).click(
|
|
|
|
function () {
|
|
|
|
Prezi.setPresentationVisible(true);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A presentation has been removed.
|
|
|
|
*
|
|
|
|
* @param event the event indicating the remove of a presentation
|
|
|
|
* @param jid the jid for which the presentation was removed
|
|
|
|
* @param the url of the presentation
|
|
|
|
*/
|
|
|
|
var presentationRemoved = function (event, jid, presUrl) {
|
|
|
|
console.log('presentation removed', presUrl);
|
|
|
|
var presId = getPresentationId(presUrl);
|
|
|
|
Prezi.setPresentationVisible(false);
|
|
|
|
$('#participant_'
|
|
|
|
+ Strophe.getResourceFromJid(jid)
|
|
|
|
+ '_' + presId).remove();
|
|
|
|
$('#presentation>iframe').remove();
|
|
|
|
if (preziPlayer != null) {
|
|
|
|
preziPlayer.destroy();
|
|
|
|
preziPlayer = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-03-27 17:09:05 +00:00
|
|
|
/**
|
|
|
|
* Indicates if the given string is an alphanumeric string.
|
|
|
|
* Note that some special characters are also allowed (-, _ , /, &, ?, =, ;) for the
|
|
|
|
* purpose of checking URIs.
|
|
|
|
*/
|
|
|
|
function isAlphanumeric(unsafeText) {
|
|
|
|
var regex = /^[a-z0-9-_\/&\?=;]+$/i;
|
|
|
|
return regex.test(unsafeText);
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Returns the presentation id from the given url.
|
|
|
|
*/
|
|
|
|
function getPresentationId (presUrl) {
|
|
|
|
var presIdTmp = presUrl.substring(presUrl.indexOf("prezi.com/") + 10);
|
|
|
|
return presIdTmp.substring(0, presIdTmp.indexOf('/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the presentation width.
|
|
|
|
*/
|
|
|
|
function getPresentationWidth() {
|
|
|
|
var availableWidth = Util.getAvailableVideoWidth();
|
|
|
|
var availableHeight = getPresentationHeihgt();
|
|
|
|
|
|
|
|
var aspectRatio = 16.0 / 9.0;
|
|
|
|
if (availableHeight < availableWidth / aspectRatio) {
|
|
|
|
availableWidth = Math.floor(availableHeight * aspectRatio);
|
|
|
|
}
|
|
|
|
return availableWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the presentation height.
|
|
|
|
*/
|
|
|
|
function getPresentationHeihgt() {
|
|
|
|
var remoteVideos = $('#remoteVideos');
|
|
|
|
return window.innerHeight - remoteVideos.outerHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes the presentation iframe.
|
|
|
|
*/
|
|
|
|
function resize() {
|
|
|
|
if ($('#presentation>iframe')) {
|
|
|
|
$('#presentation>iframe').width(getPresentationWidth());
|
|
|
|
$('#presentation>iframe').height(getPresentationHeihgt());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Presentation has been removed.
|
|
|
|
*/
|
|
|
|
$(document).bind('presentationremoved.muc', presentationRemoved);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Presentation has been added.
|
|
|
|
*/
|
|
|
|
$(document).bind('presentationadded.muc', presentationAdded);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Indicates presentation slide change.
|
|
|
|
*/
|
|
|
|
$(document).bind('gotoslide.muc', function (event, jid, presUrl, current) {
|
2014-05-30 15:18:32 +00:00
|
|
|
if (preziPlayer && preziPlayer.getCurrentStep() != current) {
|
2014-03-26 10:33:46 +00:00
|
|
|
preziPlayer.flyToStep(current);
|
2014-05-30 15:18:32 +00:00
|
|
|
|
2014-04-18 21:52:15 +00:00
|
|
|
var animationStepsArray = preziPlayer.getAnimationCountOnSteps();
|
2014-05-30 15:18:32 +00:00
|
|
|
for (var i = 0; i < parseInt(animationStepsArray[current]); i++) {
|
|
|
|
preziPlayer.flyToStep(current, i);
|
2014-04-18 21:52:15 +00:00
|
|
|
}
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On video selected event.
|
|
|
|
*/
|
|
|
|
$(document).bind('video.selected', function (event, isPresentation) {
|
2014-11-28 14:02:48 +00:00
|
|
|
if (!isPresentation && $('#presentation>iframe')) {
|
2014-03-26 10:33:46 +00:00
|
|
|
Prezi.setPresentationVisible(false);
|
2014-11-28 14:02:48 +00:00
|
|
|
}
|
2014-03-26 10:33:46 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$(window).resize(function () {
|
|
|
|
resize();
|
|
|
|
});
|
|
|
|
|
|
|
|
return my;
|
2014-04-18 21:52:15 +00:00
|
|
|
}(Prezi || {}));
|