From f2b428b4fe1eecd66ee95513da779470f7c621aa Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Wed, 31 Dec 2014 19:04:26 +0000 Subject: Modes proof-of-concept. --- lib/handler_stack.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/handler_stack.coffee') diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee index 858f2ec9..728ea4bc 100644 --- a/lib/handler_stack.coffee +++ b/lib/handler_stack.coffee @@ -5,6 +5,7 @@ class root.HandlerStack constructor: -> @stack = [] @counter = 0 + @passThrough = {} genId: -> @counter = ++@counter & 0xffff @@ -18,6 +19,7 @@ class root.HandlerStack # propagation by returning a falsy value. bubbleEvent: (type, event) -> for i in [(@stack.length - 1)..0] by -1 + console.log i, type handler = @stack[i] # We need to check for existence of handler because the last function call may have caused the release # of more than one handler. @@ -27,6 +29,10 @@ class root.HandlerStack if not passThrough DomUtils.suppressEvent(event) return false + # If @passThrough is returned, then discontinue further bubbling and pass the event through to the + # underlying page. The event is not suppresssed. + if passThrough == @passThrough + return false true remove: (id = @currentId) -> @@ -35,3 +41,5 @@ class root.HandlerStack if handler.id == id @stack.splice(i, 1) break + +root.handlerStack = new HandlerStack -- cgit v1.2.3