@bbn/bbn 2.0.111 → 2.0.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/env.d.ts +1 -0
- package/dist/env.js +1 -0
- package/dist/fn/init.d.ts +1 -1
- package/dist/fn/init.js +47 -40
- package/package.json +1 -1
package/dist/env.d.ts
CHANGED
package/dist/env.js
CHANGED
package/dist/fn/init.d.ts
CHANGED
package/dist/fn/init.js
CHANGED
|
@@ -3,13 +3,43 @@ import each from './loop/each.js';
|
|
|
3
3
|
import extend from './object/extend.js';
|
|
4
4
|
import addColors from './style/addColors.js';
|
|
5
5
|
import link from './ajax/link.js';
|
|
6
|
-
import submit from './form/submit.js';
|
|
7
6
|
import resize from './style/resize.js';
|
|
8
7
|
import isMobile from './browser/isMobile.js';
|
|
9
8
|
import isTabletDevice from './browser/isTabletDevice.js';
|
|
10
9
|
import isFunction from './type/isFunction.js';
|
|
11
10
|
import log from './browser/log.js';
|
|
12
11
|
import timestamp from './datetime/timestamp.js';
|
|
12
|
+
const onActivity = (e) => {
|
|
13
|
+
bbn.env.last_focus = bbn.dt().unix();
|
|
14
|
+
if (bbn.env.nav !== "ajax") {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let target = e.target;
|
|
18
|
+
if (target instanceof HTMLElement && target.tagName !== "A") {
|
|
19
|
+
let p = target;
|
|
20
|
+
while (p && p.tagName !== "A") {
|
|
21
|
+
if (p.tagName === "BODY") {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
p = p.parentElement;
|
|
25
|
+
}
|
|
26
|
+
if (p && p.tagName === "A") {
|
|
27
|
+
target = p;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
target = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target instanceof HTMLElement &&
|
|
34
|
+
target.hasAttribute("href") &&
|
|
35
|
+
!target.hasAttribute("target") &&
|
|
36
|
+
!target.classList.contains("bbn-no")) {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
link(target.getAttribute("href"));
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
13
43
|
/**
|
|
14
44
|
* Initializes the library bbn basing on the given configuration object.
|
|
15
45
|
* - Gives to the environment the dimension of the window.innerWidth and window.innerHeight
|
|
@@ -48,56 +78,33 @@ export default function init(cfg, force) {
|
|
|
48
78
|
addColors(bbn.var.colors);
|
|
49
79
|
}
|
|
50
80
|
document.addEventListener("visibilitychange", () => {
|
|
51
|
-
if (document.hidden
|
|
52
|
-
bbn.env.
|
|
81
|
+
if (document.hidden) {
|
|
82
|
+
bbn.env.isVisible = false;
|
|
53
83
|
}
|
|
54
|
-
else
|
|
55
|
-
bbn.env.
|
|
84
|
+
else {
|
|
85
|
+
bbn.env.isVisible = true;
|
|
56
86
|
}
|
|
57
87
|
});
|
|
58
|
-
document.addEventListener("
|
|
88
|
+
document.addEventListener("focus", (e) => {
|
|
59
89
|
if (e.target instanceof HTMLElement &&
|
|
60
90
|
!e.target.classList.contains("bbn-no")) {
|
|
61
91
|
bbn.env.focused = e.target;
|
|
62
92
|
}
|
|
93
|
+
bbn.env.isFocused = true;
|
|
63
94
|
bbn.env.last_focus = timestamp();
|
|
64
95
|
});
|
|
65
|
-
document.addEventListener("
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
let target = e.target;
|
|
71
|
-
if (target instanceof HTMLElement && target.tagName !== "A") {
|
|
72
|
-
let p = target;
|
|
73
|
-
while (p && p.tagName !== "A") {
|
|
74
|
-
if (p.tagName === "BODY") {
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
p = p.parentElement;
|
|
78
|
-
}
|
|
79
|
-
if (p && p.tagName === "A") {
|
|
80
|
-
target = p;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
target = null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (target instanceof HTMLElement &&
|
|
87
|
-
target.hasAttribute("href") &&
|
|
88
|
-
!target.hasAttribute("target") &&
|
|
89
|
-
!target.classList.contains("bbn-no")) {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
e.stopPropagation();
|
|
92
|
-
link(target.getAttribute("href"));
|
|
93
|
-
return false;
|
|
96
|
+
document.addEventListener("blur", (e) => {
|
|
97
|
+
if (e.target instanceof HTMLElement &&
|
|
98
|
+
!e.target.classList.contains("bbn-no")) {
|
|
99
|
+
bbn.env.focused = e.target;
|
|
94
100
|
}
|
|
101
|
+
bbn.env.isFocused = false;
|
|
102
|
+
bbn.env.last_focus = timestamp();
|
|
95
103
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
104
|
+
document.addEventListener("click", onActivity);
|
|
105
|
+
document.addEventListener("keydown", onActivity);
|
|
106
|
+
document.addEventListener("focusin", onActivity);
|
|
107
|
+
document.addEventListener("focusout", onActivity);
|
|
101
108
|
window.addEventListener("hashchange", () => {
|
|
102
109
|
bbn.env.hashChanged = new Date().getTime();
|
|
103
110
|
}, false);
|