@bbn/bbn 2.0.110 → 2.0.112
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/dt/classes/dt.d.ts +1 -0
- package/dist/dt/classes/dt.js +8 -0
- 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 +45 -34
- package/package.json +1 -1
package/dist/dt/classes/dt.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ export declare abstract class bbnDt<TValue extends bbnDtTemporal> {
|
|
|
87
87
|
get S(): string;
|
|
88
88
|
get WW(): string;
|
|
89
89
|
get W(): string;
|
|
90
|
+
unix(ms?: boolean | number): number | bbnDt<any>;
|
|
90
91
|
format(format?: string): string;
|
|
91
92
|
matchFormat(value: any, format: string): boolean;
|
|
92
93
|
getWeekday(n: 0 | 1 | 2 | 3 | 4 | 5 | 6, mode?: string, locale?: string): string | object;
|
package/dist/dt/classes/dt.js
CHANGED
|
@@ -624,6 +624,14 @@ export class bbnDt {
|
|
|
624
624
|
}
|
|
625
625
|
return undefined;
|
|
626
626
|
}
|
|
627
|
+
unix(ms = false) {
|
|
628
|
+
if (typeof ms === 'number') {
|
|
629
|
+
const Ctor = this.constructor;
|
|
630
|
+
const d = new Date(ms);
|
|
631
|
+
return new Ctor(d);
|
|
632
|
+
}
|
|
633
|
+
return ms ? this.toEpochMs() : Math.floor(this.toEpochMs() / 1000);
|
|
634
|
+
}
|
|
627
635
|
format(format = 'YYYY-MM-DD HH:II:SS') {
|
|
628
636
|
let str = '';
|
|
629
637
|
if (format) {
|
package/dist/env.d.ts
CHANGED
package/dist/env.js
CHANGED
package/dist/fn/init.d.ts
CHANGED
package/dist/fn/init.js
CHANGED
|
@@ -10,6 +10,37 @@ import isTabletDevice from './browser/isTabletDevice.js';
|
|
|
10
10
|
import isFunction from './type/isFunction.js';
|
|
11
11
|
import log from './browser/log.js';
|
|
12
12
|
import timestamp from './datetime/timestamp.js';
|
|
13
|
+
const onActivity = (e) => {
|
|
14
|
+
bbn.env.last_focus = bbn.dt().unix();
|
|
15
|
+
if (bbn.env.nav !== "ajax") {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let target = e.target;
|
|
19
|
+
if (target instanceof HTMLElement && target.tagName !== "A") {
|
|
20
|
+
let p = target;
|
|
21
|
+
while (p && p.tagName !== "A") {
|
|
22
|
+
if (p.tagName === "BODY") {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
p = p.parentElement;
|
|
26
|
+
}
|
|
27
|
+
if (p && p.tagName === "A") {
|
|
28
|
+
target = p;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
target = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (target instanceof HTMLElement &&
|
|
35
|
+
target.hasAttribute("href") &&
|
|
36
|
+
!target.hasAttribute("target") &&
|
|
37
|
+
!target.classList.contains("bbn-no")) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
link(target.getAttribute("href"));
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
13
44
|
/**
|
|
14
45
|
* Initializes the library bbn basing on the given configuration object.
|
|
15
46
|
* - Gives to the environment the dimension of the window.innerWidth and window.innerHeight
|
|
@@ -48,51 +79,31 @@ export default function init(cfg, force) {
|
|
|
48
79
|
addColors(bbn.var.colors);
|
|
49
80
|
}
|
|
50
81
|
document.addEventListener("visibilitychange", () => {
|
|
51
|
-
if (document.hidden
|
|
52
|
-
bbn.env.
|
|
82
|
+
if (document.hidden) {
|
|
83
|
+
bbn.env.isVisible = false;
|
|
53
84
|
}
|
|
54
|
-
else
|
|
55
|
-
bbn.env.
|
|
85
|
+
else {
|
|
86
|
+
bbn.env.isVisible = true;
|
|
56
87
|
}
|
|
57
88
|
});
|
|
58
|
-
document.addEventListener("
|
|
89
|
+
document.addEventListener("focus", (e) => {
|
|
59
90
|
if (e.target instanceof HTMLElement &&
|
|
60
91
|
!e.target.classList.contains("bbn-no")) {
|
|
61
92
|
bbn.env.focused = e.target;
|
|
62
93
|
}
|
|
94
|
+
bbn.env.isFocused = true;
|
|
63
95
|
bbn.env.last_focus = timestamp();
|
|
64
96
|
});
|
|
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;
|
|
97
|
+
document.addEventListener("blur", (e) => {
|
|
98
|
+
if (e.target instanceof HTMLElement &&
|
|
99
|
+
!e.target.classList.contains("bbn-no")) {
|
|
100
|
+
bbn.env.focused = e.target;
|
|
94
101
|
}
|
|
102
|
+
bbn.env.isFocused = false;
|
|
103
|
+
bbn.env.last_focus = timestamp();
|
|
95
104
|
});
|
|
105
|
+
document.addEventListener("click", onActivity);
|
|
106
|
+
document.addEventListener("keydown", onActivity);
|
|
96
107
|
each(document.querySelectorAll("form:not(.bbn-no), form:not(.bbn-form)"), (ele) => {
|
|
97
108
|
ele.addEventListener("submit", (e) => {
|
|
98
109
|
submit(ele, e);
|