SWS.Templates = new function () {
var self = this;
- self.controlPanel = "<div id='sws-control-panel'>\
-<a onclick='SWS.Presentation.goToSlide(SWS.Presentation.firstSlide());'>◀◀◀</a>\
-<a onclick='SWS.Presentation.previousSlide();SWS.Presentation.refresh();'>◀◀ </a>\
-<a onclick='SWS.Presentation.previous();SWS.Presentation.refresh();'>◀</a>\
-<a onclick='SWS.Presentation.next();SWS.Presentation.refresh();'>▶</a>\
-<a onclick='SWS.Presentation.nextSlide();SWS.Presentation.refresh();'>▶▶</a>\
-<a rel='Last slide' onclick='SWS.Presentation.goToSlide(SWS.Presentation.lastSlide());'>▶▶▶</a>\
+ self.controlPanel = "<div id='sws-control-panel-canvas'><div id='sws-control-panel'>\
+<div id='sws-control-panel-title-bar'>\
+<a title='Toggle fullscreen' id='sws-control-panel-fullscreen' class='sws-symbol' onclick='SWS.Presentation.toggleFullScreen();'></a>\
+<a title='Close panel' id='sws-control-panel-close' onclick='$(\"#sws-control-panel-canvas\").toggle();'>✖</a>\
+</div>\
+<div id='sws-control-panel-options'>\
+<span title='Change the aspect ratio' class='sws-symbol' >💻</span><select id='sws-aspect-select' onchange='SWS.Presentation.changeAspect();'>\
+<option value='sws-aspect-4-3'>4:3</option>\
+<option value='sws-aspect-16-9'>16:9</option>\
+<option value='sws-aspect-16-10'>16:10</option>\
+</select>\
+<span title='Change the theme' class='sws-symbol'>🎨</span><select id='sws-theme-select' onchange='SWS.Presentation.changeTheme();'></select>\
+</div>\
+<div id='sws-control-panel-navigation'>\
+<a title='First slide' class='sws-symbol' onclick='SWS.Presentation.goToSlide(SWS.Presentation.firstSlide());' >⏮</a>\
+<a title='Previous slide' class='sws-symbol' onclick='SWS.Presentation.previousSlide();SWS.Presentation.refresh();'>⏪</a>\
+<a title='Previous step' class='sws-symbol' style='-webkit-transform: scaleX(-1);' onclick='SWS.Presentation.previous();SWS.Presentation.refresh();'>▶</a>\
+<a title='Next step' class='sws-symbol' onclick='SWS.Presentation.next();SWS.Presentation.refresh();'>▶</a>\
+<a title='Next slide' class='sws-symbol' onclick='SWS.Presentation.nextSlide();SWS.Presentation.refresh();'>⏩</a>\
+<a title='Last slide' class='sws-symbol' onclick='SWS.Presentation.goToSlide(SWS.Presentation.lastSlide());'>⏭</a>\
+<br/>\
+<span class='sws-symbol'></span><input type='text' id='sws-control-panel-slide-input' oninput='SWS.Presentation.goToSlide($(\"#sws-control-panel-slide-input\").val()-1);'></input><span id='sws-control-panel-total-slides'></span>\
+<input type='range' title='Navigate the presentation' id='sws-control-panel-navigation-bar' onchange='SWS.Presentation.navigate();' step='1'></input>\
+</div>\
+</div>\
</div>";
self.slideActivate = function (o) {
if (!(o.hasClass("sws-active-slide"))){
var t = SWS.Presentation.getSlide(to);
if (from < to) {
t.css('left', '100%');
+ t.css('opacity', '1');
SWS.Templates.slideActivate(t);
- f.animate({ 'left': '-100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
- t.animate({ 'left': '0%' }, 250);
+ f.animate({ 'left': '-100%' }, 250, function () { SWS.Templates.slideDeactivate(f);
+ f.css('opacity', '0');
+ t.animate({ 'left': '0%' }, 250);
+ });
} else {
t.css('left', '-100%');
SWS.Templates.slideActivate(t);
- f.animate({ 'left': '100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
+ f.animate({ 'left': '100%' }, 250, function () { SWS.Templates.slideDeactivate(f);
+ f.css('opacity', '0');
+ });
+ t.css('opacity', '1');
t.animate({ 'left': '0%' }, 250);
};
};
};
+SWS.Fullscreen = new function () {
+ var self = this;
+
+ if (SWS.Utils.isUndefined(document.fullScreen)) {
+ if (SWS.Utils.isUndefined(document.mozfullScreen)) {
+ self.status = function () { return document.webkitIsFullScreen; };
+ self.enter = function(e) {
+ e.webkitRequestFullScreen();
+ };
+ self.exit = function () {
+ document.webkitCancelFullScreen();
+ };
+
+ } else {
+ self.status = function () { return document.mozfullScreen; };
+ self.enter = function(e) {
+ e.mozRequestFullScreen();
+ };
+ self.exit = function () {
+ document.mozCancelFullScreen();
+ };
+
+ };
+ } else {
+ self.status = function () { return document.fullScreen; };
+ self.enter = function(e) {
+ e.requestFullScreen();
+ };
+ self.exit = function () {
+ document.cancelFullScreen();
+ };
+
+ };
+
+
+};
+
SWS.Presentation = new function () {
var to_slide_num = self.getCurrentSlide();
var watch_slide_anim = false;
var to_slide = $(canvas[to_slide_num]);
+ var from_slide = $(canvas[from_slide_num]);
var slide_change = (from_slide_num != to_slide_num);
var info = to_slide.data("sws-frame-info");
callbacks[k]($(to_slide));
};
- var to_watch = $(to_slide).find("*");
- if (watch_slide_anim) {
- to_watch = to_watch.add(to_slide).add($(canvas[from_slide_num]));
- };
-
- to_watch.find("*").promise().done(function() {
+ var all = $(from_slide).add(to_slide);
+ all.find("*").addBack().promise().done(function() {
_disable_input_events = false;
});
};
case 32: /* space */
case 39: /* -> */
-
+ if (self.getCurrentSlide() == self.lastSlide()
+ && self.getCurrentFrame() == self.lastFrame()) return;
self.next();
break;
case 34: /* PgDown */
self.cycleStyle();
return;
case 67: /* c */
- $("#sws-control-panel").toggle();
+ $("#sws-control-panel-canvas").toggle();
default:
return;
};
};
+ /* Forces redrawing the page without reloading */
+ self.redraw = function () {
+ $("body").hide();
+ $("body").show();
+ };
+
+ self.changeAspect = function() {
+ $("html").removeClass("sws-aspect-4-3")
+ .removeClass("sws-aspect-16-9")
+ .removeClass("sws-aspect-16-10")
+ .addClass($("#sws-aspect-select").val());
+ self.redraw();
+ };
+
+
+ self.changeTheme = function () {
+ var theme_name = $("#sws-theme-select").val();
+ $("link.sws-theme").each (function (i) {
+ var e = $(this);
+ var title = e.attr("title");
+ e[0].disabled = (title != theme_name);
+ });
+ self.redraw();
+ };
+
+
+ var _fullscreen_icon_on = "";
+ var _fullscreen_icon_off = "";
+
+ self.toggleFullScreen = function () {
+ if (SWS.Fullscreen.status()) {
+ SWS.Fullscreen.exit();
+ $("a#sws-control-panel-fullscreen")
+ .html(_fullscreen_icon_off);
+
+
+
+ } else {
+ SWS.Fullscreen.enter($("body")[0]);
+ $("a#sws-control-panel-fullscreen")
+ .html(_fullscreen_icon_on);
+ };
+ };
+ function _update_ui() {
+ var nav = $('#sws-control-panel-navigation-bar');
+ nav.val(SWS.Presentation.getCurrentSlide() + 1);
+ $('#sws-control-panel-slide-input').val(nav.val());
+ }
+ self.navigate = function () {
+ self.goToSlide($("#sws-control-panel-navigation-bar").val()-1);
+ _update_ui();
+ };
+
+
self.init = function () {
- console.log("inited");
+
+
+
+ $(window).resize(self.redraw);
+
+
$(window).bind('storage', function (e) {
console.log(e);
});
_total_slides = $(".sws-slide").length;
$(document).keydown(self.inputHandler);
- $("body").append($(SWS.Templates.controlPanel));
+
+
var cur = self.getCurrentSlide();
$(".sws-slide").each (function (i) {
var par = $(this).parent();
var canvas = $('<div class="sws-canvas"/>');
if (!($(this).hasClass("sws-option-noheader"))) {
- canvas.append($('<div class="sws-header"/>'));
+ canvas.append($('<div class="sws-header"/><br/>'));
};
+
var inner = $('<div class="sws-inner-canvas"/>');
- var h1 = $(this).children("h1");
- if (h1) {
- var title = $('<div class="sws-title"/>');
- h1.detach();
- title.append(h1);
- inner.append(title);
- }
+ var content = $('<div class="sws-content"/>');
$(this).find('script[type="text/javascript"]').remove();
- if (!($(this).hasClass("sws-option-nofiller"))) {
- inner.append('<div class="sws-filler"/>');
- inner.append('<div class="sws-filler"/>');
- };
- inner.append($(this));
- if (!($(this).hasClass("sws-option-nofiller"))) {
- inner.append('<div class="sws-filler"/>');
- inner.append('<div class="sws-filler"/>');
- };
- inner.append('<div class="sws-filler"/>');
+ content.append($(this));
+ inner.append(content);
+ inner.append($('<span class="sws-vertical-align"> </span><br/>'));
canvas.append(inner);
+
if (!($(this).hasClass("sws-option-nofooter"))) {
canvas.append($('<div class="sws-footer"/>'));
};
+
par.append(canvas);
if (i == cur) {
init_canvas(canvas,_slide_callbacks[i]);
});
+
+
+
+ // Initialize the control panel
+ $("body").append($(SWS.Templates.controlPanel));
+ // Fill the theme switcher
+ $("link.sws-theme").each (function (i) {
+ var e = $(this);
+ var opt = "<option value='";
+ opt += e.attr("title");
+ opt += "' ";
+ if (e.attr("rel") == "stylesheet") {
+ opt+= "selected='selected'";
+ };
+ opt += ">" + e.attr("title") + "</option>";
+ $("#sws-theme-select").append($(opt));
+ });
+ // Set the fullscreen icon
+ if (SWS.Fullscreen.status()) {
+ $("a#sws-control-panel-fullscreen")
+ .html(_fullscreen_icon_on);
+ } else {
+ $("a#sws-control-panel-fullscreen")
+ .html(_fullscreen_icon_off);
+ };
+ // Put the navigation range at the correct position
+ var nav = $('#sws-control-panel-navigation-bar');
+ nav.attr("min", SWS.Presentation.firstSlide() + 1);
+ nav.attr("max", SWS.Presentation.lastSlide() + 1);
+ $('#sws-control-panel-total-slides').text('/' + SWS.Presentation.getNumSlides());
+ _update_ui();
+
_slide_callbacks = null; /* avoid a leak */
self.refresh();
_initialized = true;
+
};
};