Commits

Anonymous committed 6a49d99

stop button working

  • Participants
  • Parent commits 64e858c

Comments (0)

Files changed (2)

File coffee/app.coffee

         # buttons clicks
         @view.$container.querySelector('.next-play').addEventListener 'click', =>
             @next_play()
+        @view.$container.querySelector('.stop').addEventListener 'click', =>
+            @stop()
 
     end_callback: =>
         if @mode is 'play'
             @current++
             @view.turn @turnlist[@current], @end_callback
 
+    stop: =>
+        window.setTimeout =>
+            @mode = 'stop'
+            @end_callback()
+
 document.addEventListener 'DOMContentLoaded', ->
 
     for $container in document.querySelectorAll '.cubeofcoffee'
     CubeController.prototype.turnlist = ["R2", "U", "R", "U", "R'", "U'", "R'", "U'", "R'", "U", "R'"];
 
     function CubeController(cubeview) {
+      this.stop = __bind(this.stop, this);
+
       this.next_play = __bind(this.next_play, this);
 
       this.end_callback = __bind(this.end_callback, this);
       this.view.$container.querySelector('.next-play').addEventListener('click', function() {
         return _this.next_play();
       });
+      this.view.$container.querySelector('.stop').addEventListener('click', function() {
+        return _this.stop();
+      });
     }
 
     CubeController.prototype.end_callback = function() {
       });
     };
 
+    CubeController.prototype.stop = function() {
+      var _this = this;
+      return window.setTimeout(function() {
+        _this.mode = 'stop';
+        return _this.end_callback();
+      });
+    };
+
     return CubeController;
 
   })();