Small fixes:
[hacks/simpleWebSlides.git] / simpleWebSlides.js
index e73a1a2..89dea31 100644 (file)
@@ -361,7 +361,6 @@ SWS.Presentation = new function () {
             else
                 SWS.Config['sws-object-deactivate']($(this));
         });
-
         var callbacks;
         if (callbacks = info.callbacks.at_frame[self.getCurrentFrame()]){
             for (var k = 0; k < callbacks.length; k++)
@@ -474,7 +473,6 @@ SWS.Presentation = new function () {
                 ($("link.sws-theme[rel='stylesheet']")[0]).disabled = false;
                 $(".sws-canvas").find("*").addBack().promise().done(function() {
                     var percent = ((total_steps - steps) / total_steps) * 100;
-                    console.log(percent);
                     $("#sws-percent-progress").text(Math.round(percent));
                     SWS.Config['sws-slide-change'] = SWS.Templates.slideChange;
                     self.refresh();
@@ -492,10 +490,24 @@ SWS.Presentation = new function () {
 
     }
 
-    self.inputHandler = function (event) {
-        if (_disable_input_events || _print_mode ) return;
 
-        switch (event.which) {
+    var xstart = 0;
+    self.inputHandler = function (event) {
+        if (_disable_input_events || _print_mode) return;
+        var code = 0;
+        switch (event.type) {
+        case 'touchstart':
+            xstart = event.changedTouches[0].clientX;
+            return;
+        case 'touchend':
+            var dist = event.changedTouches[0].clientX - xstart;
+            if (dist > 20) code = 39
+            else if (dist < -20) code = 37
+            else code = 67;
+        case 'keydown':
+            code = event.which;
+        };
+        switch (code) {
         case 36:/* Home */
             self.setCurrentSlide(self.firstSlide());
             break;
@@ -522,16 +534,16 @@ SWS.Presentation = new function () {
             self.previousSlide();
             break;
         case 83: /* s */
-            self.cycleStyle();
+                self.cycleStyle();
             return;
         case 67: /* c */
             $("#sws-control-panel-canvas").toggle();
-            
+
         default:
             return;
         };
         self.refresh();
-    };
+};
 
 
 
@@ -564,7 +576,7 @@ SWS.Presentation = new function () {
             }
         };
 
-        var specials = null;
+        var specials = $([]);
 
         slide.find('*[class*="sws-onframe-"]').each(function(_){
             var cls = $(this).attr('class');
@@ -577,12 +589,10 @@ SWS.Presentation = new function () {
                 for(var f in o)
                     if (f > last_frame) last_frame = f;
                 $(this).find("*").andSelf().each(function(_){
-                    if (!SWS.Utils.isEmpty(o))
+                    if (!SWS.Utils.isEmpty(o)){
                         $(this).data("sws-frame-set", o);
-                    if (specials)
-                        specials.add($(this));
-                    else
-                        specials = $(this);
+                    }
+                    specials = specials.add($(this));
                 });
             };
         });
@@ -784,6 +794,8 @@ SWS.Presentation = new function () {
                 else
                     self.refresh();
                 $(document).keydown(self.inputHandler);
+                $(document).on('touchstart', self.inputHandler);
+                $(document).on('touchend', self.inputHandler);
 
                 _initialized = true;
             };