Skip to content

Instantly share code, notes, and snippets.

Created August 23, 2013 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/33932b179af7c6405a06 to your computer and use it in GitHub Desktop.
Save anonymous/33932b179af7c6405a06 to your computer and use it in GitHub Desktop.
v.event = {
add: function(e, n, r, i, s) {
var o, u, a, f, l, c, h, p, d, m, g;
if (e.nodeType === 3 || e.nodeType === 8 || !n || !r || !(o = v._data(e))) return;
r.handler && (d = r, r = d.handler, s = d.selector), r.guid || (r.guid = v.guid++), a = o.events, a || (o.events = a = {}), u = o.handle, u || (o.handle = u = function(e) {
return typeof v == "undefined" || !! e && v.event.triggered === e.type ? t : v.event.dispatch.apply(u.elem, arguments)
}, u.elem = e), n = v.trim(Z(n)).split(" ");
for (f = 0; f < n.length; f++) {
l = J.exec(n[f]) || [], c = l[1], h = (l[2] || "").split(".").sort(), g = v.event.special[c] || {}, c = (s ? g.delegateType : g.bindType) || c, g = v.event.special[c] || {}, p = v.extend({
type: c,
origType: l[1],
data: i,
handler: r,
guid: r.guid,
selector: s,
needsContext: s && v.expr.match.needsContext.test(s),
namespace: h.join(".")
}, d), m = a[c];
if (!m) {
m = a[c] = [], m.delegateCount = 0;
if (!g.setup || g.setup.call(e, i, h, u) === !1) e.addEventListener ? e.addEventListener(c, u, !1) : e.attachEvent && e.attachEvent("on" + c, u)
}
g.add && (g.add.call(e, p), p.handler.guid || (p.handler.guid = r.guid)), s ? m.splice(m.delegateCount++, 0, p) : m.push(p), v.event.global[c] = !0
}
e = null
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment