Fix the CSS a bit.
[hacks/simpleWebSlides.git] / simpleWebSlides.js
index 42448ea..9993a51 100644 (file)
@@ -2,7 +2,7 @@
   Namespace object.
 */
 
-var SWS = {};
+var SWS = SWS || {};
 
 
 
@@ -52,6 +52,14 @@ SWS.Utils = new function () {
 
 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>\
+</div>";
     self.slideActivate = function (o) {
         if (!(o.hasClass("sws-active-slide"))){
             o.removeClass("sws-inactive-slide").addClass("sws-active-slide");
@@ -121,14 +129,14 @@ SWS.Effects = new function () {
     var self = this;
 
     self.objectDeactivateFadeOut = function (o) {
-        o.animate({'opacity': '0'}, 150,
+        o.animate({'opacity': '0'}, 200,
                   function () { SWS.Templates.objectDeactivate(o)});
     };
 
     self.objectActivateFadeIn = function (o) {
 
         if (SWS.Templates.objectActivate(o)){
-            o.animate({'opacity': '1' }, 150);
+            o.animate({'opacity': '1' }, 200);
         };
 
     };
@@ -225,7 +233,7 @@ SWS.Presentation = new function () {
     if (typeof(Storage)!=="undefined"){
         self.getCurrentSlide = function () {
             //unary + casts to integer
-            var i = +(sessionStorage.current_slide);
+            var i = +(sessionStorage.getItem("current_slide"));
             if (!(i >= 0 && i < self.getNumSlides())){
                 return 0;
             } else {
@@ -234,7 +242,7 @@ SWS.Presentation = new function () {
         };
 
         self.setCurrentSlide = function (i) {
-            sessionStorage.current_slide = i;
+            sessionStorage.setItem("current_slide", i);
         };
 
     } else {
@@ -371,7 +379,7 @@ SWS.Presentation = new function () {
 
         case 32: /* space */
         case 39: /* -> */
-        case 1: /* mouse button 1 */
+
             self.next();
             break;
         case 34: /* PgDown */
@@ -386,6 +394,8 @@ SWS.Presentation = new function () {
         case 80: /* p */
             self.previousSlide();
             break;
+        case 67: /* c */
+            $("#sws-control-panel").toggle();
         default:
             return;
         };
@@ -463,12 +473,15 @@ SWS.Presentation = new function () {
     };
 
     self.init = function () {
+        console.log("inited");
+        $(window).bind('storage', function (e) {
+            console.log(e);
+        });
 
         _total_slides = $(".sws-slide").length;
 
         $(document).keydown(self.inputHandler);
-        $(document).mousedown(self.inputHandler);
-
+        $("body").append($(SWS.Templates.controlPanel));
         var cur = self.getCurrentSlide();
         $(".sws-slide").each (function (i) {
             var par = $(this).parent();