-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrbar.misc.js
53 lines (42 loc) · 1.54 KB
/
rbar.misc.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
/*
rbar-misc.js // ralf-bartsch.net // 2018-04-04
license and info: https://github.com/r84r/js-lib-rbar
*/
var rbar = (function(ns) {
ns.dom = (function(ns) {
/*
Funktion nach kompletten Laden der Seite ausführen
*/
ns.ready = function(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading")
fn();
else
document.addEventListener('DOMContentLoaded', fn);
}
/*
Ereignis auslösen
*/
ns.trigger = function(el, eventName, eventParam) {
if (arguments.length == 2) {
var event = document.createEvent('HTMLEvents');
event.initEvent(eventName, true, false);
} else {
if (window.CustomEvent) {
var event = new CustomEvent(eventName, {detail: {some: eventParam}});
} else {
var event = document.createEvent('CustomEvent');
event.initCustomEvent(eventName, true, true, {some: eventParam});
}
}
el.dispatchEvent(event);
}
/*
Gibt den Typ eines Objektes zurück
*/
ns.type = function(obj) {
return Object.prototype.toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase();
}
return ns;
})({});
return ns;
})(rbar || {})