@kizmann/pico-js 1.0.12 → 1.0.13
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/pico-js.js +1 -1
- package/dist/pico-js.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +9 -11
- package/src/library/data.js +1 -1
- package/src/library/locale.js +2 -2
- package/src/library/route.js +1 -1
- package/src/utility/any.js +13 -0
- package/src/utility/now.js +6 -4
- package/src/utility/object.js +1 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -69,24 +69,22 @@ export const Pico = {
|
|
|
69
69
|
Route: Route,
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
* @const window
|
|
74
|
-
*/
|
|
72
|
+
let win = Any.global();
|
|
75
73
|
|
|
76
|
-
if ( typeof
|
|
77
|
-
|
|
74
|
+
if ( typeof win.IE === 'undefined' && win.navigator ) {
|
|
75
|
+
win.IE = !! win.navigator.userAgent.match(/Edge\/|Trident\/|MSIE /);
|
|
78
76
|
}
|
|
79
77
|
|
|
80
|
-
if ( typeof
|
|
81
|
-
|
|
78
|
+
if ( typeof win.WIN === 'undefined' && win.navigator ) {
|
|
79
|
+
win.WIN = !! win.navigator.userAgent.match(/Windows/);
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
if ( typeof
|
|
85
|
-
|
|
82
|
+
if ( typeof win.pi === 'undefined' && win.navigator ) {
|
|
83
|
+
win.pi = Pico;
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
if ( typeof
|
|
89
|
-
|
|
86
|
+
if ( typeof win.pi !== 'undefined' && win.document ) {
|
|
87
|
+
win.pi.Dom.ready(win.pi.Element.listen);
|
|
90
88
|
}
|
|
91
89
|
|
|
92
90
|
export default Pico;
|
package/src/library/data.js
CHANGED
package/src/library/locale.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Obj } from "../index.js";
|
|
1
|
+
import { Obj, Any } from "../index.js";
|
|
2
2
|
|
|
3
3
|
export class Locale
|
|
4
4
|
{
|
|
5
5
|
/**
|
|
6
6
|
* Get locales from window if present.
|
|
7
7
|
*/
|
|
8
|
-
static locales = Obj.get(
|
|
8
|
+
static locales = Obj.get(Any.global(), '_locales', {});
|
|
9
9
|
|
|
10
10
|
static pickByCount(splits, count)
|
|
11
11
|
{
|
package/src/library/route.js
CHANGED
package/src/utility/any.js
CHANGED
|
@@ -2,6 +2,19 @@ import { Arr, Obj, Now } from "../index.js";
|
|
|
2
2
|
|
|
3
3
|
export class Any
|
|
4
4
|
{
|
|
5
|
+
static global(fallback = {})
|
|
6
|
+
{
|
|
7
|
+
if ( window !== undefined ) {
|
|
8
|
+
return window;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if ( global !== undefined ) {
|
|
12
|
+
return global;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
static isEmpty(val)
|
|
6
19
|
{
|
|
7
20
|
if ( this.isNumber(val) ) {
|
package/src/utility/now.js
CHANGED
|
@@ -7,7 +7,9 @@ export class Now
|
|
|
7
7
|
|
|
8
8
|
constructor(date = null, format = 'YYYY-MM-DD HH:mm:ss')
|
|
9
9
|
{
|
|
10
|
-
|
|
10
|
+
let win = Any.global();
|
|
11
|
+
|
|
12
|
+
if ( ! win.moment ) {
|
|
11
13
|
throw new Error('Moment.js is required for pi.Now');
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -18,14 +20,14 @@ export class Now
|
|
|
18
20
|
this.initialDate = date;
|
|
19
21
|
|
|
20
22
|
if ( ! Any.isString(date) ) {
|
|
21
|
-
this.moment =
|
|
23
|
+
this.moment = win.moment(date || new Date, format);
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
if ( this.moment !== null ) {
|
|
25
27
|
return this;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
this.moment =
|
|
30
|
+
this.moment = win.moment(date.match(/^now/) ?
|
|
29
31
|
new Date : date, format);
|
|
30
32
|
|
|
31
33
|
let second = this.initialDate.match(/(\+|-)([0-9]+)seconds?/);
|
|
@@ -92,7 +94,7 @@ export class Now
|
|
|
92
94
|
valid()
|
|
93
95
|
{
|
|
94
96
|
return ! Any.isEmpty(this.initialDate) &&
|
|
95
|
-
|
|
97
|
+
Any.global().moment(this.initialDate).isValid();
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
clone()
|
package/src/utility/object.js
CHANGED