\
💻\
@@ -150,8 +163,9 @@ SWS.Config = new SWS.ConfigBuilder ();
SWS.Effects = new function () {
var self = this;
-
+
self.objectDeactivateFadeOut = function (o) {
+ if (o.is("embed")) return;
o.animate({'opacity': '0'}, 200,
function () {
@@ -296,7 +310,6 @@ SWS.Presentation = new function () {
var slides = $(".sws-slide");
var h1s = $("body").children("h1");
var slide_num = slides.add(h1s).length - 1;
-
SWS.Utils.push2(_slide_callbacks, slide_num,{ 'fn': f, 'frame': i });
};
@@ -316,11 +329,18 @@ SWS.Presentation = new function () {
sessionStorage.setItem("current_slide", i);
};
+ self.showHelpAtStartup = function () {
+ var r = sessionStorage.getItem("show_help");
+ if (r == "hide") return false;
+ sessionStorage.setItem("show_help", "hide");
+ return true;
+ };
+
} else {
var _current_slide = 0;
self.getCurrentSlide = function () { return _current_slide; };
self.setCurrentSlide = function (i) { _current_slide = i; };
-
+ self.showHelpAtStartup = function () { return false; };
};
self.firstSlide = function () { return 0; };
self.lastSlide = function () { return self.getNumSlides() - 1; };
@@ -374,7 +394,7 @@ SWS.Presentation = new function () {
};
all.find("*").addBack().promise().done(function() {
//wait for all elements to finish transitionning, in case a callback animate something
- //an denable _input_events again.
+ //and enable _input_events again.
_disable_input_events = false;
});
});
@@ -466,6 +486,11 @@ SWS.Presentation = new function () {
self.printMode = function () {
_print_mode = true;
+
+ var old_fx_status = $.fx.off;
+ //disable animation while printing.
+
+ $.fx.off = true;
var progress = $("
Rendering presentation: %
");
$("body").append(progress);
@@ -491,6 +516,9 @@ SWS.Presentation = new function () {
} else {
$("#sws-percent-progress").text(100);
progress.remove();
+ window.status = 'Ready';
+ $.fx.off = old_fx_status;
+
}
};
loop();
@@ -527,7 +555,12 @@ SWS.Presentation = new function () {
var loop = function (doc, dir, add, ignoreFirst) {
if (ignoreFirst !== true) {
- var this_toc = { 'title' : doc.find("title").first().text(),
+ var this_toc = { 'title' : doc.find("title").first().text()
+ .replace ("&", "&")
+ .replace("'","'")
+ .replace('"', """)
+ .replace("<", "<")
+ .replace(">", ">"),
'sections' : build_sections(doc) };
add(toc, this_toc);
};
@@ -545,20 +578,25 @@ SWS.Presentation = new function () {
- var _xstart = 0;
+ var _startTouch = null;
+
self.inputHandler = function (event) {
if (_disable_input_events || _print_mode) return;
var code = 0;
switch (event.type) {
case 'touchstart':
- _xstart = event.changedTouches[0].clientX;
+ _startTouch = event.changedTouches[0];
return;
case 'touchend':
-
- var dist = event.changedTouches[0].clientX - _xstart;
- if (dist > 20) code = 37
- else if (dist < -20) code = 39
- else if (!$("#sws-control-panel-canvas").is(":visible")) code = 67;
+ if (!_startTouch) return;
+ var _endTouch = event.changedTouches[0];
+ var Xdist = _endTouch.clientX - _startTouch.clientX;
+ var Ydist = _endTouch.clientY - _startTouch.clientY;
+ if (Xdist > 40) code = 39
+ else if (Xdist < -40) code = 37
+ else if (Ydist > 20 && !$("#sws-control-panel-canvas").is(":visible")) code = 67;
+ else if (Ydist < -20 && $("#sws-control-panel-canvas").is(":visible")) code = 67;
+ else code = 39;
break;
case 'keydown':
code = event.which;
@@ -566,6 +604,7 @@ SWS.Presentation = new function () {
default:
return;
};
+
switch (code) {
case 36:/* Home */
self.setCurrentSlide(self.firstSlide());
@@ -577,6 +616,8 @@ SWS.Presentation = new function () {
case 32: /* space */
case 34: /* PgDown */
case 39: /* -> */
+ case 176: /* Multimedia skip forward */
+ case 179: /* Multimedia play/pause */
if (self.getCurrentSlide() == self.lastSlide()
&& self.getCurrentFrame() == self.lastFrame()) return;
self.next();
@@ -587,6 +628,7 @@ SWS.Presentation = new function () {
case 8: /* backspace */
case 33: /* PgUp */
case 37: /* <- */
+ case 177: /* Multimedia skip backward */
self.previous();
break;
case 80: /* p */
@@ -597,6 +639,9 @@ SWS.Presentation = new function () {
return;
case 67: /* c */
$("#sws-control-panel-canvas").toggle();
+ return;
+ case 72: /* h */
+ $("#sws-help-panel-canvas").toggle();
default:
return;
@@ -682,10 +727,22 @@ SWS.Presentation = new function () {
});
};
self.changeAspect = function() {
+ if (_print_mode) return;
+ var newClass = $("#sws-aspect-select").val();
+ var args = newClass.split("-");
+ var targetRatio = (args[2] - 0) / (args[3] - 0);
+ var realRatio = window.innerWidth / window.innerHeight;
+ var byClass = (targetRatio > realRatio ) ? "sws-by-height" : "sws-by-width";
+ if ($("html").hasClass(newClass)
+ && $("html").hasClass(byClass))
+ return;
+
$("html").removeClass("sws-aspect-4-3")
.removeClass("sws-aspect-16-9")
.removeClass("sws-aspect-16-10")
- .addClass($("#sws-aspect-select").val());
+ .removeClass("sws-by-width")
+ .removeClass("sws-by-height")
+ .addClass(newClass).addClass(byClass);
self.redraw();
};
@@ -782,12 +839,12 @@ SWS.Presentation = new function () {
var j;
var secnum = toc.length + '.';
for (j = 0; j < i; ++j)
- this_html += "
" + secnum + (j+1) + ' ' +
+ this_html += "" + secnum + (j+1) + ' ' +
sections[j].title + "";
this_html += "
" + secnum + (i+1) + ' ' +
sections[i].title + "";
for (j = i+1; j < sections.length; j++)
- this_html += "
" + secnum + (j+1) + ' '
+ this_html += "" + secnum + (j+1) + ' '
+sections[j].title + "";
this_html += "
";
$(this).after(this_html);
@@ -804,18 +861,28 @@ SWS.Presentation = new function () {
if (!($(this).hasClass("sws-option-noheader"))) {
canvas.append($(''));
};
+
if (!$(this).hasClass("sws-cover")) {
var title = $($(this).find("h1")[0]);
var title_div = $('
');
title_div.append(title);
canvas.append(title_div);
- }
+ };
+
var inner = $('
');
$(this).find('script[type="text/javascript"]').remove();
content.append($(this));
inner.append(content);
canvas.append(inner);
+ var that = this;
+ [ "sws-cover", "sws-toc" ].forEach(
+ function(v) {
+ if ($(that).hasClass(v)) {
+ inner.addClass(v);
+ $(that).removeClass(v);
+ }
+ });
if (!($(this).hasClass("sws-option-nofooter"))) {
canvas.append($(''));
@@ -838,6 +905,7 @@ SWS.Presentation = new function () {
// Initialize the control panel
$("body").append($(SWS.Templates.controlPanel));
+ $("body").append($(SWS.Templates.helpPanel));
// Fill the theme switcher
$("link.sws-theme").each (function (i) {
var e = $(this);
@@ -864,7 +932,6 @@ SWS.Presentation = new function () {
nav.attr("max", SWS.Presentation.lastSlide() + 1);
$('#sws-control-panel-total-slides').text('/' + SWS.Presentation.getNumSlides());
_update_ui();
-
_slide_callbacks = null; /* avoid a leak */
var passed_theme = SWS.Utils.getParameterByName("theme");
@@ -879,15 +946,19 @@ SWS.Presentation = new function () {
if (SWS.Utils.getParameterByName("mode") == "print") {
self.printMode();
}
- else
+ else {
+ if (self.showHelpAtStartup()) $("#sws-help-panel-canvas").show().delay(5000).hide();
+ self.changeAspect();
self.refresh();
+ };
$(document).keydown(self.inputHandler);
document.body.addEventListener('touchstart',self.inputHandler, false);
document.body.addEventListener('touchend',self.inputHandler, false);
-
+ $(window).resize(self.changeAspect);
_initialized = true;
};
- setTimeout(f, 100);
+ //setTimeout(f, 100);
+ f();
};
};