Some fixes in the CSS for printout mode and correct selection of current theme in...
[hacks/simpleWebSlides.git] / simpleWebSlides.js
index 6229a74..76cbeba 100644 (file)
@@ -105,7 +105,7 @@ SWS.Templates = new function () {
     self.objectActivate = function (o) {
         if (!(o.hasClass("sws-active-object"))){
             o.removeClass("sws-inactive-object").addClass("sws-active-object");
-            o.css({'visibility':'visible'});
+            o.css('visibility','visible');
             return true;
         };
         return false;
@@ -153,7 +153,7 @@ SWS.Effects = new function () {
     var self = this;
 
     self.objectDeactivateFadeOut = function (o) {
-        o.animate({'opacity': '0.1'}, 200,
+        o.animate({'opacity': '0'}, 200,
                   function () { SWS.Templates.objectDeactivate(o)});
     };
 
@@ -168,11 +168,11 @@ SWS.Effects = new function () {
     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.2' }, 150,
+        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.3' });
+                      t.css({ 'left': '50%', 'width': '0pt','opacity':'0' });
                       SWS.Templates.slideActivate(t);
                       t.animate({'left':'0%', 'width': '100%','opacity':'1'});
                   });
@@ -180,10 +180,10 @@ SWS.Effects = new function () {
     self.slideChangeFadeOutIn = function (from, to) {
         var f = SWS.Presentation.getSlide(from);
         var t = SWS.Presentation.getSlide(to);
-        f.animate({ 'opacity': '0.4'}, 150,
+        f.animate({ 'opacity': '0'}, 150,
                   function () { SWS.Templates.slideDeactivate(f);
                                 SWS.Templates.slideActivate(t);
-                                t.css('opacity', '0.5');
+                                t.css('opacity', '0');
                                 t.animate({ 'opacity': '1'}, 150);
                               });
     };
@@ -195,14 +195,14 @@ SWS.Effects = new function () {
             t.css('opacity', '1');
             SWS.Templates.slideActivate(t);
             f.animate({ 'left': '-100%' }, 250, function () { SWS.Templates.slideDeactivate(f);
-                                                              f.css('opacity', '0.6');
+                                                              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.7');
+                                                             f.css('opacity', '0');
                                                            });
             t.css('opacity', '1');
             t.animate({ 'left': '0%' }, 250);
@@ -469,13 +469,14 @@ SWS.Presentation = new function () {
         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));
-                    console.log ("Step: " + steps);
                     SWS.Config['sws-slide-change'] = SWS.Templates.slideChange;
                     self.refresh();
-                    $($(".sws-canvas")[self.getCurrentSlide()]).css( { 'opacity': 1 });
+                    $($(".sws-canvas")[self.getCurrentSlide()]).css('opacity', 1 );
                     self.next();
                     steps--;
                     loop();
@@ -483,7 +484,6 @@ SWS.Presentation = new function () {
             } else {
                 $("#sws-percent-progress").text(100);
                 progress.remove();
-                window.print();
             }
         };
         loop();
@@ -601,11 +601,14 @@ SWS.Presentation = new function () {
     };
 
     /* Forces redrawing the page without reloading */
-    self.redraw = function () {
-        $("body").hide();
-        $("body").show();
+    self.redraw = function (f) {
+        if (SWS.Utils.isUndefined(f))
+            $("body").hide().show(400, function () {
+                $("body").css("display","block");
+                if (!SWS.Utils.isUndefined(f))
+                    f();
+            });
     };
-
     self.changeAspect = function() {
         $("html").removeClass("sws-aspect-4-3")
             .removeClass("sws-aspect-16-9")
@@ -614,6 +617,14 @@ SWS.Presentation = new function () {
         self.redraw();
     };
 
+    self.getCurrentTheme = function () { 
+        var l = $("link.sws-theme[rel='stylesheet']")[0];
+        console.log(l);
+        if (l) {
+            return  l.title;
+        } else
+            return ""
+    };
 
     self.changeTheme = function (name) {
         var theme_name;
@@ -621,26 +632,29 @@ SWS.Presentation = new function () {
             theme_name = $("#sws-theme-select").val()
         else
             theme_name = name;
+//        if (self.getCurrentTheme() == theme_name) {
+  //          return;
+    //    };
         _current_theme = theme_name;
         $("link.sws-theme").each (function (i) {
-            var e = $(this);
-            var title =  e.attr("title");
+            var e = this;
+            var title =  e.title;
             if (title == theme_name) {
-                e[0].rel = "stylesheet";
-                e[0].disabled = false;
-                e[0].media="all";
-
+                e.rel = "stylesheet";
+                e.disabled = false;
+                e.media="all";
             } else {
-                e[0].rel = "alternate stylesheet";
-                e[0].disabled = true;
-                e[0].media="all";
+                e.rel = "alternate stylesheet";
+                e.disabled = true;
+                e.media="all";
             };
         });
         self.redraw();
+
     };
 
     self.openPrint = function () {
-        window.open("?mode=print&theme=" + _current_theme);
+        window.open ("?mode=print&theme=" + self.getCurrentTheme());
     }
     var _fullscreen_icon_on = "";
     var _fullscreen_icon_off = "";
@@ -764,14 +778,12 @@ SWS.Presentation = new function () {
             self.changeTheme(passed_theme);
 
         if (SWS.Utils.getParameterByName("mode") == "print") {
-            self.printMode();
+           self.printMode();
         }
-        else 
+        else
             self.refresh();
-
         _initialized = true;
 
-
     };
 
 };