+/*
+ Namespace object.
+*/
+
+var SWS = SWS || {};
+
+
+
+SWS.Utils = new function () {
+ var self = this;
+
+ self.isUndefined = function (o) { return typeof o == "undefined"; };
+ self.push2 = function (t, i, v) {
+ if ((typeof t[i]) == 'undefined') {
+ t[i] = new Array();
+ };
+ var l = t[i].length;
+ t[i][l] = v;
+ };
+
+ self.isEmpty = function (o) {
+ for(var _ in o) return false;
+ return true;
+ };
+
+ self.parseFrameSpec = function (s) {
+ var elems = s.split("_");
+ var result = {};
+ var min_last = 10000;
+ var max_value = -1;
+ for(var i = 0; i < elems.length; i++){
+ var bounds = elems[i].split("-");
+ if (bounds.length > 2 || bounds.length == 0) return {};
+ if (bounds.length == 1) bounds[1] = bounds[0];
+ var a = parseInt(bounds[0]);
+ var b = parseInt(bounds[1])
+ if (!isFinite(a) || !isFinite(b)) return {};
+ a = Math.min(a, 1000); // don't allow more than 1000 frames/slide
+ b = Math.min(b, 1000);
+ if (b > max_value) max_value = b;
+ for (var j = a; j <= b; j++)
+ result[j] = true;
+ };
+ return result;
+ };
+
+ self.getParameterByName = function (name) {
+ name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
+ var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
+ results = regex.exec(location.search);
+ return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+ }
+};
+
+
+
+
+SWS.Templates = new function () {
+ var self = this;
+ 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>\
+<a onclick='SWS.Presentation.openPrint()' ><span title='Open Print-Out' class='sws-symbol'></span></a>\
+</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"))){
+ o.removeClass("sws-inactive-slide").addClass("sws-active-slide");
+ };
+ };
+
+ self.slideDeactivate = function (o) {
+ if (!(o.hasClass("sws-inactive-slide"))){
+ o.removeClass("sws-active-slide").addClass("sws-inactive-slide");
+ };
+ };
+
+ self.slideChange = function (from, to) {
+ var canvas = $(".sws-canvas");
+ self.slideDeactivate($(canvas[from]));
+ self.slideActivate($(canvas[to]));
+ };
+
+ self.objectActivate = function (o) {
+ if (!(o.hasClass("sws-active-object"))){
+ o.removeClass("sws-inactive-object").addClass("sws-active-object");
+ return true;
+ };
+ return false;
+ };
+
+ self.objectDeactivate = function (o) {
+ if (!(o.hasClass("sws-inactive-object"))){
+ o.addClass("sws-inactive-object").removeClass("sws-active-object");
+ return true;
+ };
+ return false;
+ };
+
+ self.updateFooter = function (o) {
+ var footer = o.find(".sws-footer");
+ if (footer.length && (footer.children("*").length == 0)) {
+ var i = SWS.Presentation.getCurrentSlide();
+ var cur = $( "<span class='sws-current-slide-number'>"
+ + (i + 1)
+ +"</span>");
+ var sep = $( "<span class='sws-slide-num-sep' />");
+ var tot = $( "<span class='sws-last-slide-number'>"
+ + (SWS.Presentation.getNumSlides())
+ +"</span>");
+ footer.append(cur).append(sep).append(tot);
+ };
+ };
+ self.updateHeader = function (o) {};
+};
+SWS.ConfigBuilder = function () {
+ var self = this;
+ self['sws-object-activate'] = SWS.Templates.objectActivate;
+ self['sws-object-deactivate'] = SWS.Templates.objectDeactivate;
+ self['sws-slide-change'] = SWS.Templates.slideChange;
+ self['sws-update-footer'] = SWS.Templates.updateFooter;
+ self['sws-update-header'] = SWS.Templates.updateHeader;
+};
+
+SWS.Defaults = new SWS.ConfigBuilder ();
+
+SWS.Config = new SWS.ConfigBuilder ();
+
+
+SWS.Effects = new function () {
+ var self = this;
+
+ self.objectDeactivateFadeOut = function (o) {
+ o.animate({'opacity': '0'}, 200,
+ function () {
+
+ SWS.Templates.objectDeactivate(o);
+ });
+ };
+
+ self.objectActivateFadeIn = function (o) {
+
+ if (SWS.Templates.objectActivate(o)){
+ o.animate({'opacity': '1' }, 200);
+ };
+
+ };
+
+ self.slideChangeHorizontalFlip = function (from, to){
+ var f = SWS.Presentation.getSlide(from);
+ var t = SWS.Presentation.getSlide(to);
+ f.animate({ 'left': '50%', 'width': '0pt', 'opacity':'0' }, 150,
+ function () {
+ SWS.Templates.slideDeactivate(f);
+ f.css({'left':'0%', 'width': '100%'});
+ t.css({ 'left': '50%', 'width': '0pt','opacity':'0' });
+ SWS.Templates.slideActivate(t);
+ t.animate({'left':'0%', 'width': '100%','opacity':'1'});
+ });
+ };
+ self.slideChangeFadeOutIn = function (from, to) {
+ var f = SWS.Presentation.getSlide(from);
+ var t = SWS.Presentation.getSlide(to);
+ f.animate({ 'opacity': '0'}, 150,
+ function () { SWS.Templates.slideDeactivate(f);
+ SWS.Templates.slideActivate(t);
+ t.css('opacity', '0');
+ t.animate({ 'opacity': '1'}, 150);
+ });
+ };
+ self.slideChangeHorizontalSlide = function (from, to) {
+ var f = SWS.Presentation.getSlide(from);
+ 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);
+ 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.css('opacity', '0');
+ });
+ t.css('opacity', '1');
+ t.animate({ 'left': '0%' }, 250);
+ };
+ };
+
+
+ self.slideChangeVerticalSlide = function (from, to) {
+ var f = SWS.Presentation.getSlide(from);
+ var t = SWS.Presentation.getSlide(to);
+ if (from < to) {
+ t.css('top', '100%');
+ SWS.Templates.slideActivate(t);
+ f.animate({ 'top': '-100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
+ t.animate({ 'top': '0%' }, 250);
+ } else {
+ t.css('top', '-100%');
+ SWS.Templates.slideActivate(t);
+ f.animate({ 'top': '100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
+ t.animate({ 'top': '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 self = this;
+
+ //TODO move outside of the Presentation object
+
+