').prependTo(ul);
var a = $('')
.text(value)
.attr('href','javascript:setCurrentSection("'+value+'");')
.appendTo(li);
if(section === value) {
li.addClass('selected');
}
});
}
var nextIndex = slidenum + 1;
var nextSlide = (nextIndex >= slides.size()) ? $('') : slides.eq(nextIndex);
var nextThumb = $('#nextSlide .container');
var prevSlide = (slidenum > 0) ? slides.eq(slidenum - 1) : $('');
var prevThumb = $('#prevSlide .container');
nextThumb.html(nextSlide.html());
prevThumb.html(prevSlide.html());
copyBackground(nextSlide, nextThumb);
copyBackground(prevSlide, prevThumb);
if (windowIsOpen(nextWindow)) {
$(nextWindow.document.body).html(nextSlide.html());
}
if (windowIsOpen(notesWindow)) {
$(notesWindow.document.body).html(notes);
}
var fileName = currentSlide.children('div').first().attr('ref');
$('#slideFile').text(fileName);
$('#progress').progressbar({ max: slideTotal })
.progressbar('value', slidenum+1);
$("#notes div.form.wrapper").each(function(e) {
renderFormInterval = renderFormWatcher($(this));
});
if(currentSlide.hasClass('activity')) {
currentSlide.children('.activityToggle').replaceWith('0');
}
}
}
function presenterKeyDown(event){
var key = event.keyCode;
debug('keyDown: ' + key);
// avoid overriding browser commands
if (event.ctrlKey || event.altKey || event.metaKey) {
return true;
}
switch(getAction(event)) {
case 'DEBUG': toggleDebug(); break;
case 'PREV': presPrevStep(); break; // Watch that this uses presPrevStep and not prevStep
case 'PREVSEC': presPrevSec(); break; // Same here
case 'NEXT': presNextStep(); break; // Same here
case 'NEXTSEC': presNextSec(); break; // Same here
case 'REFRESH': reloadSlides(); break;
case 'RELOAD': reloadSlides(true); break;
case 'CONTENTS': toggleContents(); break;
case 'HELP': toggleHelp(); break;
case 'BLANK': blankScreen(); break;
case 'FOOTER': toggleFooter(); break;
case 'FOLLOW': toggleFollow(); break;
case 'NOTES': toggleNotes(); break;
case 'PAUSE': togglePause(); break;
case 'PRESHOW': togglePreShow(); break;
case 'CLEAR':
removeResults();
try {
slaveWindow.removeResults();
} catch (e) {}
break;
case 'EXECUTE':
debug('executeCode');
executeVisibleCodeBlock();
try {
slaveWindow.executeVisibleCodeBlock();
} catch (e) {}
break;
default:
switch (key) {
case 48: // 0
case 49: // 1
case 50: // 2
case 51: // 3
case 52: // 4
case 53: // 5
case 54: // 6
case 55: // 7
case 56: // 8
case 57: // 9
// concatenate numbers from previous keypress events
gotoSlidenum = gotoSlidenum * 10 + (key - 48);
break;
case 13: // enter/return
// check for a combination of numbers from previous keypress events
if (gotoSlidenum > 0) {
debug('go to ' + gotoSlidenum);
slidenum = gotoSlidenum - 1;
showSlide(true);
try {
slaveWindow.slidenum = gotoSlidenum - 1;
slaveWindow.showSlide(true);
} catch (e) {}
gotoSlidenum = 0;
}
break;
default:
break;
}
break;
}
return true;
}
//* TIMER *//
var timerRunning = false;
var timerIntervals = [];
function startTimer() {
timerRunning = true;
$("#timerLabel").hide();
$("#minStart").hide();
$('#stopTimer').val('Cancel');
$("#stopTimer").show();
$("#pauseTimer").show();
$("#timerDisplay").show();
$("#timerSection").addClass('open');
// keep the sidebar open while the timer is active
pinSidebar('timer');
var time = parseInt( $("#timerMinutes").val() ) * 60;
if(time) {
$('#timerDisplay')
.attr('data-timer', time)
.TimeCircles({
direction: 'Counter-clockwise',
total_duration: time,
count_past_zero: false,
time: {
Days: { show: false },
Hours: { show: false },
Seconds: { show: false },
}
}).addListener(timerProgress);
// add 60 seconds to each interval because the timer works on floor()
timerIntervals = [ time/2+60, time/4+60, time/8+60, time/16+60 ]
}
}
function timerProgress(unit, value, total){
if (timerIntervals.length > 0) {
if (total < timerIntervals[0]) {
ts = $('#timerSection');
// clear all classes except for the one sizing the container
ts.attr('class', 'open');
// remove all the intervals we've already passed
timerIntervals = timerIntervals.filter(function(val) { return val < total });
switch(timerIntervals.length) {
case 3: ts.addClass('intervalHalf'); break;
case 2: ts.addClass('intervalQuarter'); break;
case 1: ts.addClass('intervalWarning'); break;
case 0:
ts.addClass('intervalCritical');
$("#timerDisplay").TimeCircles({circle_bg_color: "red"});
// when timing short durations, sometimes the last interval doesn't get triggered until we end.
if( $("#timerDisplay").TimeCircles().getTime() <= 0 ) {
endTimer();
}
break;
}
}
}
else {
endTimer();
}
}
function toggleTimer() {
if (!timerRunning) {
timerRunning = true;
$('#pauseTimer').val('Pause');
$('#timerDisplay').removeClass('paused');
$("#timerDisplay").TimeCircles().start();
}
else {
timerRunning = false;
$('#pauseTimer').val('Resume');
$('#timerDisplay').addClass('paused');
$("#timerDisplay").TimeCircles().stop();
}
}
function endTimer() {
$('#stopTimer').val('Reset');
$("#pauseTimer").hide();
// don't unpin yet, we don't want the timer to just wander off into the distance!
}
function stopTimer() {
$("#timerDisplay").removeData('timer');
$("#timerDisplay").TimeCircles().destroy();
$("#timerLabel").show();
$("#minStart").show();
$("#stopTimer").hide();
$("#pauseTimer").hide();
$("#timerDisplay").hide();
$('#timerSection').removeClass();
// only unpin when the user has dismissed the timer
unpinSidebar('timer');
}
function initializeSettings() {
// enable this if we are the "master" presenter
$("#followerToggle").prop("checked", master);
mode.update = $("#followerToggle").prop("checked");
}
/********************
Follower Code
********************/
function toggleFollower()
{
mode.follow = $("#remoteToggle").prop("checked");
getPosition();
}
function toggleUpdater()
{
mode.update = $("#followerToggle").prop("checked");
update();
}
/********************
Annotations
********************/
function toggleAnnotations() {
mode.annotations = $("#annotationsToggle").prop("checked");
if(mode.annotations) {
$('#annotationToolbar').show();
$('canvas.annotations').show();
if (typeof(currentSlide) != 'undefined') {
currentSlide.find('canvas.annotations').annotate(annotations);
}
}
else {
$('#annotationToolbar').hide();
$('canvas.annotations').stopAnnotation();
$('canvas.annotations').hide();
}
}
function openNext() {
$("#nextWindowConfirmation").hide();
try {
if(windowIsClosed(nextWindow)){
nextWindow = blankStyledWindow("Next Slide Preview", 'width=320,height=300', 'next');
// Firefox doesn't load content properly unless we delay it slightly. Yay for race conditions.
// nextWindow.addEventListener("unload", function() {
window.setTimeout(function() {
// call back and update the parent presenter if the window is closed
nextWindow.onunload = function(e) {
nextWindow.opener.chooseLayout('default');
};
postSlide();
}, 500);
$("#settings-modal").dialog("close");
}
}
catch(e) {
console.log(e);
console.log('Failed to open or connect next window. Popup blocker?');
}
}
/********************
Layout selection incorporates previews and the old next window
********************/
function chooseLayout(layout)
{
// yay for half-baked data storage schemes
layout = layout || document.cookieHash['layout'] || 'default';
// in case we're being called externally, make the UI match
$('#layoutSelector').val(layout);
$("#nextWindowConfirmation").hide();
console.log("Setting layout to " + layout);
// change focus so we don't inadvertently change layout again by changing slides
$("#preview").focus();
$("#layoutSelector").blur();
// what we are switching *from*
switch(mode.layout) {
case 'thumbs':
$('#preview').removeClass('thumbs');
$('#preview .thumb').hide();
break;
case 'beside':
$('#preview').removeClass('beside');
$('#preview #nextSlide .container').removeAttr("style");
$('#preview #nextSlide').hide();
break;
case 'floating':
try {
if (nextWindow) {
// unregister the event so we don't accidentally double-fire
nextWindow.window.onunload = null;
nextWindow.close();
}
}
catch (e) {
console.log(e);
console.log('Next window failed to close properly.');
}
break;
default:
}
// what we are switching *to*
switch(layout) {
case 'thumbs':
$('#preview').addClass('thumbs');
$('#preview .thumb').show();
break;
case 'beside':
$('#preview').addClass('beside');
$('#preview #nextSlide').show();
var w = $('#nextSlide .container').width();
$('#nextSlide .container').height(w*.75)
break;
case 'floating':
$("#nextWindowConfirmation").show();
break;
default:
}
document.cookie = "layout="+layout
mode.layout = layout;
zoom(true);
}