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
2828 # Events
2929 #
3030
31−$.on = (el, event, callback) ->
31+$.on = (el, event, callback, useCapture = false) ->
3232 if event.indexOf(' ') >= 0
3333 $.on el, name, callback for name in event.split(' ')
3434 else
35− el.addEventListener(event, callback)
35+ el.addEventListener(event, callback, useCapture)
3636 return
3737
38−$.off = (el, event, callback) ->
38+$.off = (el, event, callback, useCapture = false) ->
3939 if event.indexOf(' ') >= 0
4040 $.off el, name, callback for name in event.split(' ')
4141 else
42− el.removeEventListener(event, callback)
42+ el.removeEventListener(event, callback, useCapture)
4343 return
4444
4545 $.trigger = (el, type, canBubble = true, cancelable = true) ->