History

Add useCapture option to $.on/off

Thibaut committed 11 years ago

Commit b5f2ba51 parent fa73dba1 file · +4 −4Browse files

Unified · Split

assets/javascripts/lib/util.coffee+4−4
@@ -28,18 +28,18 @@ $.closestLink = (el, parent = document.body) -> · 27 unmodified lines
28# Events28# Events
29#29#
30 30
31$.on = (el, event, callback) ->31$.on = (el, event, callback, useCapture = false) ->
32 if event.indexOf(' ') >= 032 if event.indexOf(' ') >= 0
33 $.on el, name, callback for name in event.split(' ')33 $.on el, name, callback for name in event.split(' ')
34 else34 else
35 el.addEventListener(event, callback)35 el.addEventListener(event, callback, useCapture)
36 return36 return
37 37
38$.off = (el, event, callback) ->38$.off = (el, event, callback, useCapture = false) ->
39 if event.indexOf(' ') >= 039 if event.indexOf(' ') >= 0
40 $.off el, name, callback for name in event.split(' ')40 $.off el, name, callback for name in event.split(' ')
41 else41 else
42 el.removeEventListener(event, callback)42 el.removeEventListener(event, callback, useCapture)
43 return43 return
44 44
45$.trigger = (el, type, canBubble = true, cancelable = true) ->45$.trigger = (el, type, canBubble = true, cancelable = true) ->