Last active
December 19, 2015 16:49
-
-
Save lsmith/5986637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notifier.prototype.fire = function () { | |
// first arg to delegate notifier should be an object with currentTarget | |
var args = toArray(arguments, 0, true), | |
handle = this.handle, | |
ce = handle.evt, | |
sub = handle.sub, | |
thisObj = sub.context, | |
delegate = sub.filter, | |
event = e || {}, | |
ret; | |
if (this.emitFacade) { | |
if (!e || !e.preventDefault) { | |
event = ce._getFacade(); | |
if (isObject(e) && !e.preventDefault) { | |
Y.mix(event, e, true); | |
args[0] = event; | |
} else { | |
args.unshift(event); | |
} | |
} | |
event.type = ce.type; | |
event.details = args.slice(); | |
if (delegate) { | |
event.container = ce.host; | |
} | |
} else if (delegate && isObject(e) && e.currentTarget) { | |
args.shift(); | |
} | |
sub.context = thisObj || event.currentTarget || ce.host; | |
ret = ce.fire.apply(ce, args); | |
// have to handle preventedFn and stoppedFn manually because | |
// Notifier CustomEvents are forced to emitFacade=false | |
if (e.prevented && ce.preventedFn) { | |
ce.preventedFn.apply(ce, args); | |
} | |
if (e.stopped && ce.stoppedFn) { | |
ce.stoppedFn.apply(ce, args); | |
} | |
sub.context = thisObj; // reset for future firing | |
// to capture callbacks that return false to stopPropagation. | |
// Useful for delegate implementations | |
return ret; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Y.Event.define('tap', { | |
publishConfig: { | |
preventedFn: function (e) { | |
// This should be moved to a prototype | |
e.target.once('click', function (click) { | |
click.preventDefault(); | |
}); | |
} | |
}, | |
... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment