-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathready.js
More file actions
50 lines (38 loc) · 958 Bytes
/
ready.js
File metadata and controls
50 lines (38 loc) · 958 Bytes
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
/*!
* Load JS
* https://github.com/vistoyn/loadjs
* Copyright (c) 2016 - 2017 Ildar Bikmamatov
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
* Version: 3.2
*/
ObjectAssign( $load, {
_rw : [],
/**
* Регистрация наблюдателя
* @param {string} selector - селектор
* @param {callable} f - функция
*/
onReady: function(s, f){
this._rw.push({
's': s,
'f': f,
});
var l = document.querySelectorAll(s);
for (var j=0, sz=l.length; j < sz; j++){
f(l[j]);
}
},
/**
* Запуск наблюдателей на DOM элементе
* @param {dom} dom - DOM объект, который мониторим
*/
runReady: function(dom){
for (var i=0, sz1=this._rw.length; i < sz1; i++){
var o = this._rw[i];
var l = dom.querySelectorAll(o.s);
for (var j=0, sz2=l.length; j < sz2; j++){
o.f(l[j]);
}
}
},
});