forked from dciccale/ki.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathki.ie8.js
78 lines (69 loc) · 1.95 KB
/
ki.ie8.js
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
/*!
* ki.js - jQuery-like API super-tiny JavaScript library
* Copyright (c) 2015 Denis Ciccale (@tdecs)
* Released under MIT license
*/
!function (b, c, d, e, f) {
// addEventListener support?
f = b['add' + e]
/*
* init function (internal use)
* a = selector, dom element or function
* d = placeholder for matched elements
* i = placeholder for length of matched elements
*/
function i(a, d, i) {
for(d = (a && a.nodeType ? [a] : '' + a === a ? b.querySelectorAll(a) : c), i = d.length; i--; c.unshift.call(this, d[i]));
}
/*
* $ main function
* a = css selector, dom object, or function
* http://www.dustindiaz.com/smallest-domready-ever
* returns instance or executes function on ready
*/
$ = function (a) {
return /^f/.test(typeof a) ? /in/.test(b.readyState) ? setTimeout('$('+a+')', 9) : a() : new i(a)
}
// set ki prototype
$[d] = i[d] = {
// default length
length: 0,
/*
* on method
* a = string event type i.e 'click'
* b = function
* return this
*/
on: function (a, b) {
return this.each(function (c) {
f ? c['add' + e](a, b, false) : c.attachEvent('on' + a, b)
})
},
/*
* off method
* a = string event type i.e 'click'
* b = function
* return this
*/
off: function (a, b) {
return this.each(function (c) {
f ? c['remove' + e](a, b) : c.detachEvent('on' + a, b)
})
},
/*
* each method
* a = the function to call on each iteration
* b = the this value for that function (the current iterated native dom element by default)
* return this
*/
each: function (a, b) {
for (var c = this, d = 0, e = c.length; d < e; ++d) {
a.call(b || c[d], c[d], d, c)
}
return c
},
// for some reason is needed to get an array-like
// representation instead of an object
splice: c.splice
}
}(document, [], 'prototype', 'EventListener');