bind function type fn capture var str this selector type Event new evt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
bind: function(type, fn, capture) {
var str = this.selector + '|' + type,
Event = new evtKonstruktor(type, fn, str);
if (!Konstruktor._cache.event[str]) Konstruktor._cache.event[str] = [];
return this.each(function(i) {
Event.build(this, i);
});
}
unbind: function(type) {
var Event = new evtKonstruktor(type, null, this.selector + '|' + type);
return this.each(function() {
Event.remove(this, type);
});
}
var evtKonstruktor = function(type, fn, evt) {
this.type = type;
this.el = null;
this.fn = this.mainFn = fn;
this.evt = evt;
}
evtKonstruktor.prototype = {
add: function(fn, index) {
Konstruktor._cache.event[this.evt][index] = fn;
var o = this.el,
e = this.type,
r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []),
a,
c,
d,
s;
r[r.length] = [fn, s || o],
o[e] = function(e) {
try { (e = e || event).preventDefault || (e.preventDefault = function() {
e.returnValue = false;
});
e.stopPropagation || (e.stopPropagation = function() {
e.cancelBubble = true;
});
e.target || (e.target = e.srcElement || null);
e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
} catch(f) {}
for (d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
return e = null,
!!d;
}
},
_remove: function(o, e, f, s) {
for (var i = (e = o["_on" + e] || []).length; i;) if (e[--i] && e[i][0] == f && (s || o) == e[i][1]) return delete e[i];
return false;
},
remove: function(obj, type) {
var fn, j = -1,
c;
while ((fn = Konstruktor._cache.event[this.evt][++j]) && !(c = this._remove(obj, type, fn)));
if (c) Konstruktor._cache.event[this.evt].splice(j, 1);
},
_build: (function(a, o) {
return a ?
function(obj, fn, evt) {
return function(e) {
var el = $(obj);
el.selector = evt.split('|')[0];
fn.call(el, e);
}
}: function(obj, fn, evt) {
return function(e) {
if (!o) e.x = e.pageX,
e.y = e.pageY;
var el = $(obj);
el.selector = evt.split('|')[0];
fn.call(el, e);
}
}
})(0
/*@cc_on + 1 @*/
, Konstruktor.info.opera),
build: function(obj, i) {
this.el = obj;
if (!this.evt) return this.add(this.mainFn, i);
var newFn = this._build(obj, this.mainFn, this.evt);
this.fn = newFn;
return this.add(newFn, i);
}
}