+
+ self.printMode = function () {
+ _print_mode = true;
+ var progress = $("<div style='position:fixed;top:0pt;left:0pt;background:white;color:black;width:100%;height:100vh;z-index:200;' id='sws-print-progress'>Rendering presentation: <span id='sws-percent-progress'></span>%</div>");
+ $("body").append(progress);
+
+ $("html").removeClass("sws-display").addClass("sws-print");
+ self.goToSlide(0,0);
+ var steps = self.getTotalSteps();
+ var total_steps = steps;
+ var loop;
+ loop = function () {
+ if (steps >= 0) {
+ //Crazy workaround for chromium
+ ($("link.sws-theme[rel='stylesheet']")[0]).disabled = false;
+ $(".sws-canvas").find("*").addBack().promise().done(function() {
+ var percent = ((total_steps - steps) / total_steps) * 100;
+ $("#sws-percent-progress").text(Math.round(percent));
+ SWS.Config['sws-slide-change'] = SWS.Templates.slideChange;
+ self.refresh();
+ $($(".sws-canvas")[self.getCurrentSlide()]).css('opacity', 1 );
+ self.next();
+ steps--;
+ loop();
+ })
+ } else {
+ $("#sws-percent-progress").text(100);
+ progress.remove();
+ }
+ };
+ loop();
+
+ }
+
+ self.buildFullTOC = function () {
+
+ var build_sections = function (doc) {
+ var res = [];
+ var h1s = doc.find("body").first().children("h1");
+ var slides = doc.find("body").first().children(".sws-slide");
+ var slide_num = 1;
+ var collection = h1s.add(slides);
+ collection.each (function () {
+ if ($(this).is("h1")) {
+ res.push({ 'title' : $(this).text(),
+ 'slide' : slide_num });
+ } else {
+ slide_num++;
+ }
+ });
+ return res;
+ };
+
+ var toc = [];
+
+ var append = function (a,e) {
+ return a.push(e);
+ };
+ var prepend = function (a,e) {
+ return a.unshift(e);
+ };
+
+ var loop = function (doc, dir, add, ignoreFirst) {
+ if (ignoreFirst !== true) {
+ var this_toc = { 'title' : doc.find("title").first().text(),
+ 'sections' : build_sections(doc) };
+ add(toc, this_toc);
+ };
+ var url = doc.find(dir).first().attr("href");
+ if (!SWS.Utils.isUndefined(url) && url != "") {
+ $.ajax({ 'url' : url, 'async' : false ,'success' : function (page) {
+ loop ($(page), dir, add, false);
+ }});
+ };
+ };
+ loop ($(document), ".sws-previous", prepend, false);
+ return toc;
+
+ };
+
+
+
+ var _xstart = 0;