hlp 3.3.2 → 3.3.3

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.
Files changed (3) hide show
  1. package/_js/_build/script.js +2111 -2566
  2. package/hlp.js +1 -1
  3. package/package.json +1 -1
@@ -1,2766 +1,2311 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
16
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
17
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
- var hlp = /*#__PURE__*/function () {
20
- function hlp() {
21
- (0, _classCallCheck2.default)(this, hlp);
22
- }
23
- (0, _createClass2.default)(hlp, null, [{
24
- key: "x",
25
- value: function x(input) {
26
- if (typeof input === 'function') {
27
- try {
28
- input = input();
29
- return this.x(input);
30
- } catch (e) {
31
- return false;
32
- }
33
- }
34
- if (input === null || input === false || typeof input === 'string' && input.trim() == '' || (0, _typeof2.default)(input) === 'object' && Object.keys(input).length === 0 && input.constructor === Object || typeof input === 'undefined' || Array.isArray(input) && input.length === 0 || Array.isArray(input) && input.length === 1 && input[0] === '') {
7
+ class hlp {
8
+ static x(input) {
9
+ if (typeof input === 'function') {
10
+ try {
11
+ input = input();
12
+ return this.x(input);
13
+ } catch (e) {
35
14
  return false;
36
15
  }
37
- return true;
38
16
  }
39
- }, {
40
- key: "nx",
41
- value: function nx(input) {
42
- return !this.x(input);
43
- }
44
- }, {
45
- key: "true",
46
- value: function _true(input) {
47
- if (typeof input === 'function') {
48
- try {
49
- input = input();
50
- return this.true(input);
51
- } catch (e) {
52
- return false;
53
- }
54
- }
55
- if (input === undefined) {
56
- return false;
57
- }
58
- if (input === null) {
59
- return false;
60
- }
61
- if (input === false) {
62
- return false;
63
- }
64
- if (Array.isArray(input) && input.length === 0) {
65
- return false;
66
- }
67
- if (Array.isArray(input) && hlp.first(input) === '') {
68
- return false;
69
- }
70
- if ((0, _typeof2.default)(input) === 'object' && Object.keys(input).length === 0 && input.constructor === Object) {
71
- return false;
72
- }
73
- if (input === 0) {
74
- return false;
75
- }
76
- if (input === '0') {
77
- return false;
78
- }
79
- if (input === '') {
80
- return false;
81
- }
82
- if (input === ' ') {
83
- return false;
84
- }
85
- if (input === 'null') {
17
+ if (input === null || input === false || typeof input === 'string' && input.trim() == '' || typeof input === 'object' && Object.keys(input).length === 0 && input.constructor === Object || typeof input === 'undefined' || Array.isArray(input) && input.length === 0 || Array.isArray(input) && input.length === 1 && input[0] === '') {
18
+ return false;
19
+ }
20
+ return true;
21
+ }
22
+ static nx(input) {
23
+ return !this.x(input);
24
+ }
25
+ static true(input) {
26
+ if (typeof input === 'function') {
27
+ try {
28
+ input = input();
29
+ return this.true(input);
30
+ } catch (e) {
86
31
  return false;
87
32
  }
88
- if (input === 'false') {
33
+ }
34
+ if (input === undefined) {
35
+ return false;
36
+ }
37
+ if (input === null) {
38
+ return false;
39
+ }
40
+ if (input === false) {
41
+ return false;
42
+ }
43
+ if (Array.isArray(input) && input.length === 0) {
44
+ return false;
45
+ }
46
+ if (Array.isArray(input) && hlp.first(input) === '') {
47
+ return false;
48
+ }
49
+ if (typeof input === 'object' && Object.keys(input).length === 0 && input.constructor === Object) {
50
+ return false;
51
+ }
52
+ if (input === 0) {
53
+ return false;
54
+ }
55
+ if (input === '0') {
56
+ return false;
57
+ }
58
+ if (input === '') {
59
+ return false;
60
+ }
61
+ if (input === ' ') {
62
+ return false;
63
+ }
64
+ if (input === 'null') {
65
+ return false;
66
+ }
67
+ if (input === 'false') {
68
+ return false;
69
+ }
70
+ return true;
71
+ }
72
+ static false(input) {
73
+ if (typeof input === 'function') {
74
+ try {
75
+ input = input();
76
+ return this.false(input);
77
+ } catch (e) {
89
78
  return false;
90
79
  }
80
+ }
81
+ if (input === undefined) {
82
+ return false;
83
+ }
84
+ if (input === null) {
85
+ return false;
86
+ }
87
+ if (input === false) {
91
88
  return true;
92
89
  }
93
- }, {
94
- key: "false",
95
- value: function _false(input) {
96
- if (typeof input === 'function') {
97
- try {
98
- input = input();
99
- return this.false(input);
100
- } catch (e) {
101
- return false;
102
- }
103
- }
104
- if (input === undefined) {
105
- return false;
106
- }
107
- if (input === null) {
108
- return false;
109
- }
110
- if (input === false) {
111
- return true;
112
- }
113
- if (Array.isArray(input) && input.length === 0) {
114
- return false;
115
- }
116
- if (Array.isArray(input) && hlp.first(input) === '') {
117
- return false;
118
- }
119
- if ((0, _typeof2.default)(input) === 'object' && Object.keys(input).length === 0 && input.constructor === Object) {
120
- return false;
121
- }
122
- if (input === 0) {
123
- return true;
124
- }
125
- if (input === '0') {
126
- return true;
127
- }
128
- if (input === '') {
129
- return false;
130
- }
131
- if (input === ' ') {
132
- return false;
133
- }
134
- if (input === 'null') {
135
- return false;
136
- }
137
- if (input === 'false') {
138
- return true;
139
- }
90
+ if (Array.isArray(input) && input.length === 0) {
140
91
  return false;
141
92
  }
142
- }, {
143
- key: "v",
144
- value: function v() {
145
- if (this.nx(arguments)) {
146
- return '';
147
- }
148
- for (var i = 0; i < arguments.length; i++) {
149
- if (this.x(arguments[i])) {
150
- return arguments[i];
151
- }
152
- }
93
+ if (Array.isArray(input) && hlp.first(input) === '') {
94
+ return false;
95
+ }
96
+ if (typeof input === 'object' && Object.keys(input).length === 0 && input.constructor === Object) {
97
+ return false;
98
+ }
99
+ if (input === 0) {
100
+ return true;
101
+ }
102
+ if (input === '0') {
103
+ return true;
104
+ }
105
+ if (input === '') {
106
+ return false;
107
+ }
108
+ if (input === ' ') {
109
+ return false;
110
+ }
111
+ if (input === 'null') {
112
+ return false;
113
+ }
114
+ if (input === 'false') {
115
+ return true;
116
+ }
117
+ return false;
118
+ }
119
+ static v() {
120
+ if (this.nx(arguments)) {
153
121
  return '';
154
122
  }
155
- }, {
156
- key: "loop",
157
- value: function loop(input, fun) {
158
- if (this.nx(input)) {
159
- return null;
160
- }
161
- if (Array.isArray(input)) {
162
- input.forEach(function (input__value, input__key) {
163
- fun(input__value, input__key);
164
- });
165
- } else if ((0, _typeof2.default)(input) === 'object') {
166
- Object.entries(input).forEach(function (_ref) {
167
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
168
- input__key = _ref2[0],
169
- input__value = _ref2[1];
170
- fun(input__value, input__key);
171
- });
123
+ for (let i = 0; i < arguments.length; i++) {
124
+ if (this.x(arguments[i])) {
125
+ return arguments[i];
172
126
  }
173
127
  }
174
- }, {
175
- key: "map",
176
- value: function map(obj, fn, ctx) {
177
- return Object.keys(obj).reduce(function (a, b) {
178
- a[b] = fn.call(ctx || null, b, obj[b]);
179
- return a;
180
- }, {});
181
- }
182
- }, {
183
- key: "first",
184
- value: function first(input) {
185
- if (Array.isArray(input)) {
186
- var ret = null;
187
- input.forEach(function (input__value, input__key) {
188
- if (ret === null) {
189
- ret = input__value;
190
- }
191
- });
192
- return ret;
193
- }
194
- if ((0, _typeof2.default)(input) === 'object') {
195
- var ret = null;
196
- Object.entries(input).forEach(function (_ref3) {
197
- var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
198
- input__key = _ref4[0],
199
- input__value = _ref4[1];
200
- if (ret === null) {
201
- ret = input__value;
202
- }
203
- });
204
- return ret;
205
- }
128
+ return '';
129
+ }
130
+ static loop(input, fun) {
131
+ if (this.nx(input)) {
206
132
  return null;
207
133
  }
208
- }, {
209
- key: "last",
210
- value: function last(input) {
211
- if (Array.isArray(input)) {
212
- var ret = null;
213
- input.forEach(function (input__value, input__key) {
134
+ if (Array.isArray(input)) {
135
+ input.forEach((input__value, input__key) => {
136
+ fun(input__value, input__key);
137
+ });
138
+ } else if (typeof input === 'object') {
139
+ Object.entries(input).forEach(_ref => {
140
+ let [input__key, input__value] = _ref;
141
+ fun(input__value, input__key);
142
+ });
143
+ }
144
+ }
145
+ static map(obj, fn, ctx) {
146
+ return Object.keys(obj).reduce((a, b) => {
147
+ a[b] = fn.call(ctx || null, b, obj[b]);
148
+ return a;
149
+ }, {});
150
+ }
151
+ static first(input) {
152
+ if (Array.isArray(input)) {
153
+ var ret = null;
154
+ input.forEach((input__value, input__key) => {
155
+ if (ret === null) {
214
156
  ret = input__value;
215
- });
216
- return ret;
217
- }
218
- if ((0, _typeof2.default)(input) === 'object') {
219
- var _ret = null;
220
- Object.entries(input).forEach(function (_ref5) {
221
- var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
222
- input__key = _ref6[0],
223
- input__value = _ref6[1];
224
- _ret = input__value;
225
- });
226
- return _ret;
227
- }
228
- return null;
157
+ }
158
+ });
159
+ return ret;
229
160
  }
230
- }, {
231
- key: "rand",
232
- value: function rand(input) {
233
- if (Array.isArray(input)) {
234
- return input[Math.floor(Math.random() * input.length)];
235
- }
236
- if ((0, _typeof2.default)(input) === 'object') {
237
- var input = Object.values(input);
238
- return input[Math.floor(Math.random() * input.length)];
239
- }
240
- return null;
161
+ if (typeof input === 'object') {
162
+ var ret = null;
163
+ Object.entries(input).forEach(_ref2 => {
164
+ let [input__key, input__value] = _ref2;
165
+ if (ret === null) {
166
+ ret = input__value;
167
+ }
168
+ });
169
+ return ret;
241
170
  }
242
- }, {
243
- key: "random_string",
244
- value: function random_string() {
245
- var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
246
- var chars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
247
- if (chars === null) {
248
- chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
249
- }
250
- var chars_length = chars.length,
251
- random_string = '';
252
- for (var i = 0; i < length; i++) {
253
- random_string += chars[~~(Math.random() * (chars_length - 1 - 0 + 1)) + 0];
254
- }
255
- return random_string;
256
- }
257
- }, {
258
- key: "round",
259
- value: function round() {
260
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
261
- var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
262
- return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
263
- }
264
- }, {
265
- key: "isInteger",
266
- value: function isInteger(value) {
267
- return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10));
268
- }
269
- }, {
270
- key: "random_int",
271
- value: function random_int() {
272
- var min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
273
- var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 99999;
274
- if (!this.isInteger(min) || !this.isInteger(max)) {
275
- return false;
276
- }
277
- if (min > max) {
278
- var _ref7 = [max, min];
279
- min = _ref7[0];
280
- max = _ref7[1];
281
- }
282
- return ~~(Math.random() * (max - min + 1)) + min;
283
- }
284
- }, {
285
- key: "capitalize",
286
- value: function capitalize() {
287
- var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
288
- if (string === null) {
289
- return string;
290
- }
291
- if (string === '') {
292
- return string;
293
- }
294
- return string.charAt(0).toUpperCase() + string.slice(1);
171
+ return null;
172
+ }
173
+ static last(input) {
174
+ if (Array.isArray(input)) {
175
+ let ret = null;
176
+ input.forEach((input__value, input__key) => {
177
+ ret = input__value;
178
+ });
179
+ return ret;
295
180
  }
296
- }, {
297
- key: "cookieExists",
298
- value: function cookieExists(cookie_name) {
299
- if (document.cookie !== undefined && this.cookieGet(cookie_name) !== null) {
300
- return true;
301
- }
181
+ if (typeof input === 'object') {
182
+ let ret = null;
183
+ Object.entries(input).forEach(_ref3 => {
184
+ let [input__key, input__value] = _ref3;
185
+ ret = input__value;
186
+ });
187
+ return ret;
188
+ }
189
+ return null;
190
+ }
191
+ static rand(input) {
192
+ if (Array.isArray(input)) {
193
+ return input[Math.floor(Math.random() * input.length)];
194
+ }
195
+ if (typeof input === 'object') {
196
+ var input = Object.values(input);
197
+ return input[Math.floor(Math.random() * input.length)];
198
+ }
199
+ return null;
200
+ }
201
+ static random_string() {
202
+ let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
203
+ let chars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
204
+ if (chars === null) {
205
+ chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
206
+ }
207
+ let chars_length = chars.length,
208
+ random_string = '';
209
+ for (let i = 0; i < length; i++) {
210
+ random_string += chars[~~(Math.random() * (chars_length - 1 - 0 + 1)) + 0];
211
+ }
212
+ return random_string;
213
+ }
214
+ static round() {
215
+ let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
216
+ let decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
217
+ return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
218
+ }
219
+ static isInteger(value) {
220
+ return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10));
221
+ }
222
+ static random_int() {
223
+ let min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
224
+ let max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 99999;
225
+ if (!this.isInteger(min) || !this.isInteger(max)) {
302
226
  return false;
303
227
  }
304
- }, {
305
- key: "cookieGet",
306
- value: function cookieGet(cookie_name) {
307
- var cookie_match = document.cookie.match(new RegExp(cookie_name + '=([^;]+)'));
308
- if (cookie_match) {
309
- return decodeURIComponent(cookie_match[1]);
310
- }
311
- return null;
228
+ if (min > max) {
229
+ [min, max] = [max, min];
312
230
  }
313
- }, {
314
- key: "cookieSet",
315
- value: function cookieSet(cookie_name, cookie_value, days) {
316
- var full_domain = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
317
- var samesite = '';
318
- if (window.location.protocol.indexOf('https') > -1) {
319
- samesite = '; SameSite=None; Secure';
320
- }
321
- document.cookie = cookie_name + '=' + encodeURIComponent(cookie_value) + '; ' + 'expires=' + new Date(new Date().getTime() + days * 24 * 60 * 60 * 1000).toUTCString() + '; path=/' + samesite + '; domain=' + (full_domain === true ? this.urlHostTopLevel() : '');
322
- }
323
- }, {
324
- key: "cookieDelete",
325
- value: function cookieDelete(cookie_name) {
326
- var full_domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
327
- var samesite = '';
328
- if (window.location.protocol.indexOf('https') > -1) {
329
- samesite = '; SameSite=None; Secure';
330
- }
331
- document.cookie = cookie_name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/' + samesite + '; domain=' + (full_domain === true ? this.urlHostTopLevel() : '');
332
- }
333
- }, {
334
- key: "localStorageSet",
335
- value: function localStorageSet(key, value) {
336
- var ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
337
- ttl = ttl * (24 * 60 * 60 * 1000);
338
- var now = new Date(),
339
- item = {
340
- value: value,
341
- expiry: now.getTime() + ttl
342
- };
343
- localStorage.setItem(key, JSON.stringify(item));
231
+ return ~~(Math.random() * (max - min + 1)) + min;
232
+ }
233
+ static capitalize() {
234
+ let string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
235
+ if (string === null) {
236
+ return string;
344
237
  }
345
- }, {
346
- key: "localStorageGet",
347
- value: function localStorageGet(key) {
348
- var itemStr = localStorage.getItem(key);
349
- if (!itemStr) {
350
- return null;
351
- }
352
- var item = JSON.parse(itemStr),
353
- now = new Date();
354
- if (now.getTime() > item.expiry) {
355
- localStorage.removeItem(key);
356
- return null;
357
- }
358
- return item.value;
238
+ if (string === '') {
239
+ return string;
359
240
  }
360
- }, {
361
- key: "localStorageDelete",
362
- value: function localStorageDelete(key) {
363
- localStorage.removeItem(key);
241
+ return string.charAt(0).toUpperCase() + string.slice(1);
242
+ }
243
+ static cookieExists(cookie_name) {
244
+ if (document.cookie !== undefined && this.cookieGet(cookie_name) !== null) {
245
+ return true;
364
246
  }
365
- }, {
366
- key: "localStorageExists",
367
- value: function localStorageExists(key) {
368
- return this.localStorageGet(key) !== null;
247
+ return false;
248
+ }
249
+ static cookieGet(cookie_name) {
250
+ var cookie_match = document.cookie.match(new RegExp(cookie_name + '=([^;]+)'));
251
+ if (cookie_match) {
252
+ return decodeURIComponent(cookie_match[1]);
369
253
  }
370
- }, {
371
- key: "getParam",
372
- value: function getParam(variable) {
373
- var url = window.location.search;
374
- if (this.nx(url)) {
375
- return null;
376
- }
377
- var query = url.substring(1),
378
- vars = query.split('&');
379
- for (var i = 0; i < vars.length; i++) {
380
- var pair = vars[i].split('=');
381
- if (pair[0] == variable && this.x(pair[1])) {
382
- return pair[1];
383
- }
384
- }
254
+ return null;
255
+ }
256
+ static cookieSet(cookie_name, cookie_value, days) {
257
+ let full_domain = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
258
+ let samesite = '';
259
+ if (window.location.protocol.indexOf('https') > -1) {
260
+ samesite = '; SameSite=None; Secure';
261
+ }
262
+ document.cookie = cookie_name + '=' + encodeURIComponent(cookie_value) + '; ' + 'expires=' + new Date(new Date().getTime() + days * 24 * 60 * 60 * 1000).toUTCString() + '; path=/' + samesite + '; domain=' + (full_domain === true ? this.urlHostTopLevel() : '');
263
+ }
264
+ static cookieDelete(cookie_name) {
265
+ let full_domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
266
+ let samesite = '';
267
+ if (window.location.protocol.indexOf('https') > -1) {
268
+ samesite = '; SameSite=None; Secure';
269
+ }
270
+ document.cookie = cookie_name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/' + samesite + '; domain=' + (full_domain === true ? this.urlHostTopLevel() : '');
271
+ }
272
+ static localStorageSet(key, value) {
273
+ let ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
274
+ ttl = ttl * (24 * 60 * 60 * 1000);
275
+ let now = new Date(),
276
+ item = {
277
+ value: value,
278
+ expiry: now.getTime() + ttl
279
+ };
280
+ localStorage.setItem(key, JSON.stringify(item));
281
+ }
282
+ static localStorageGet(key) {
283
+ let itemStr = localStorage.getItem(key);
284
+ if (!itemStr) {
385
285
  return null;
386
286
  }
387
- }, {
388
- key: "getDevice",
389
- value: function getDevice() {
390
- if (this.isPhone()) {
391
- return 'phone';
392
- }
393
- if (this.isTablet()) {
394
- return 'tablet';
395
- }
396
- return 'desktop';
397
- }
398
- }, {
399
- key: "isPhone",
400
- value: function isPhone() {
401
- // based on detectmobilebrowsers.com
402
- var a = navigator.userAgent || navigator.vendor || window.opera;
403
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
404
- }
405
- }, {
406
- key: "isTablet",
407
- value: function isTablet() {
408
- // based on detectmobilebrowsers.com
409
- var a = navigator.userAgent || navigator.vendor || window.opera;
410
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
411
- }
412
- }, {
413
- key: "isDesktop",
414
- value: function isDesktop() {
415
- return !this.isPhone() && !this.isTablet();
416
- }
417
- }, {
418
- key: "isMobile",
419
- value: function isMobile() {
420
- // viewport width based OR phone based
421
- if (window.innerWidth < 750 || this.isPhone()) {
422
- return true;
287
+ let item = JSON.parse(itemStr),
288
+ now = new Date();
289
+ if (now.getTime() > item.expiry) {
290
+ localStorage.removeItem(key);
291
+ return null;
292
+ }
293
+ return item.value;
294
+ }
295
+ static localStorageDelete(key) {
296
+ localStorage.removeItem(key);
297
+ }
298
+ static localStorageExists(key) {
299
+ return this.localStorageGet(key) !== null;
300
+ }
301
+ static getParam(variable) {
302
+ let url = window.location.search;
303
+ if (this.nx(url)) {
304
+ return null;
305
+ }
306
+ let query = url.substring(1),
307
+ vars = query.split('&');
308
+ for (var i = 0; i < vars.length; i++) {
309
+ var pair = vars[i].split('=');
310
+ if (pair[0] == variable && this.x(pair[1])) {
311
+ return pair[1];
423
312
  }
313
+ }
314
+ return null;
315
+ }
316
+ static getDevice() {
317
+ if (this.isPhone()) {
318
+ return 'phone';
319
+ }
320
+ if (this.isTablet()) {
321
+ return 'tablet';
322
+ }
323
+ return 'desktop';
324
+ }
325
+ static isPhone() {
326
+ // based on detectmobilebrowsers.com
327
+ let a = navigator.userAgent || navigator.vendor || window.opera;
328
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
329
+ }
330
+ static isTablet() {
331
+ // based on detectmobilebrowsers.com
332
+ let a = navigator.userAgent || navigator.vendor || window.opera;
333
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
334
+ }
335
+ static isDesktop() {
336
+ return !this.isPhone() && !this.isTablet();
337
+ }
338
+ static isMobile() {
339
+ // viewport width based OR phone based
340
+ if (window.innerWidth < 750 || this.isPhone()) {
341
+ return true;
342
+ }
343
+ return false;
344
+ }
345
+ static isTouch() {
346
+ return 'ontouchstart' in window || navigator.maxTouchPoints || false;
347
+ }
348
+ static isMac() {
349
+ return hlp.getOs() === 'mac';
350
+ }
351
+ static isLinux() {
352
+ return hlp.getOs() === 'linux';
353
+ }
354
+ static isWindows() {
355
+ return hlp.getOs() === 'windows';
356
+ }
357
+ static getOs() {
358
+ let userAgent = window.navigator.userAgent,
359
+ platform = window.navigator.platform,
360
+ macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
361
+ windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
362
+ iosPlatforms = ['iPhone', 'iPad', 'iPod'],
363
+ os = 'unknown';
364
+ if (macosPlatforms.indexOf(platform) !== -1) {
365
+ os = 'mac';
366
+ } else if (iosPlatforms.indexOf(platform) !== -1) {
367
+ os = 'mac';
368
+ } else if (windowsPlatforms.indexOf(platform) !== -1) {
369
+ os = 'windows';
370
+ } else if (/Android/.test(userAgent)) {
371
+ os = 'linux';
372
+ } else if (/Linux/.test(platform)) {
373
+ os = 'linux';
374
+ }
375
+ return os;
376
+ }
377
+ static getBrowser() {
378
+ let browser_name = '',
379
+ isIE = /*@cc_on!@*/false || !!document.documentMode,
380
+ isEdge = !isIE && !!window.StyleMedia;
381
+ if (navigator.userAgent.indexOf('Opera') != -1 || navigator.userAgent.indexOf('OPR') != -1) {
382
+ browser_name = 'opera';
383
+ } else if (navigator.userAgent.indexOf('Chrome') != -1 && !isEdge) {
384
+ browser_name = 'chrome';
385
+ } else if (navigator.userAgent.indexOf('Safari') != -1 && !isEdge) {
386
+ browser_name = 'safari';
387
+ } else if (navigator.userAgent.indexOf('Firefox') != -1) {
388
+ browser_name = 'firefox';
389
+ } else if (navigator.userAgent.indexOf('MSIE') != -1 || !!document.documentMode == true) {
390
+ //IF IE > 10
391
+ browser_name = 'ie';
392
+ } else if (isEdge) {
393
+ browser_name = 'edge';
394
+ } else {
395
+ browser_name = 'unknown';
396
+ }
397
+ return browser_name;
398
+ }
399
+ static isObject(a) {
400
+ return !!a && a.constructor === Object;
401
+ }
402
+ static isArray(a) {
403
+ return !!a && a.constructor === Array;
404
+ }
405
+ static isString(string) {
406
+ return typeof string === 'string' || string instanceof String;
407
+ }
408
+ static isDate(string) {
409
+ if (this.nx(string)) {
424
410
  return false;
425
411
  }
426
- }, {
427
- key: "isTouch",
428
- value: function isTouch() {
429
- return 'ontouchstart' in window || navigator.maxTouchPoints || false;
430
- }
431
- }, {
432
- key: "isMac",
433
- value: function isMac() {
434
- return hlp.getOs() === 'mac';
435
- }
436
- }, {
437
- key: "isLinux",
438
- value: function isLinux() {
439
- return hlp.getOs() === 'linux';
440
- }
441
- }, {
442
- key: "isWindows",
443
- value: function isWindows() {
444
- return hlp.getOs() === 'windows';
445
- }
446
- }, {
447
- key: "getOs",
448
- value: function getOs() {
449
- var userAgent = window.navigator.userAgent,
450
- platform = window.navigator.platform,
451
- macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
452
- windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
453
- iosPlatforms = ['iPhone', 'iPad', 'iPod'],
454
- os = 'unknown';
455
- if (macosPlatforms.indexOf(platform) !== -1) {
456
- os = 'mac';
457
- } else if (iosPlatforms.indexOf(platform) !== -1) {
458
- os = 'mac';
459
- } else if (windowsPlatforms.indexOf(platform) !== -1) {
460
- os = 'windows';
461
- } else if (/Android/.test(userAgent)) {
462
- os = 'linux';
463
- } else if (/Linux/.test(platform)) {
464
- os = 'linux';
465
- }
466
- return os;
467
- }
468
- }, {
469
- key: "getBrowser",
470
- value: function getBrowser() {
471
- var browser_name = '',
472
- isIE = /*@cc_on!@*/false || !!document.documentMode,
473
- isEdge = !isIE && !!window.StyleMedia;
474
- if (navigator.userAgent.indexOf('Opera') != -1 || navigator.userAgent.indexOf('OPR') != -1) {
475
- browser_name = 'opera';
476
- } else if (navigator.userAgent.indexOf('Chrome') != -1 && !isEdge) {
477
- browser_name = 'chrome';
478
- } else if (navigator.userAgent.indexOf('Safari') != -1 && !isEdge) {
479
- browser_name = 'safari';
480
- } else if (navigator.userAgent.indexOf('Firefox') != -1) {
481
- browser_name = 'firefox';
482
- } else if (navigator.userAgent.indexOf('MSIE') != -1 || !!document.documentMode == true) {
483
- //IF IE > 10
484
- browser_name = 'ie';
485
- } else if (isEdge) {
486
- browser_name = 'edge';
487
- } else {
488
- browser_name = 'unknown';
489
- }
490
- return browser_name;
491
- }
492
- }, {
493
- key: "isObject",
494
- value: function isObject(a) {
495
- return !!a && a.constructor === Object;
496
- }
497
- }, {
498
- key: "isArray",
499
- value: function isArray(a) {
500
- return !!a && a.constructor === Array;
501
- }
502
- }, {
503
- key: "isString",
504
- value: function isString(string) {
505
- return typeof string === 'string' || string instanceof String;
506
- }
507
- }, {
508
- key: "isDate",
509
- value: function isDate(string) {
510
- if (this.nx(string)) {
511
- return false;
512
- }
513
- // if string is of object date
514
- if (Object.prototype.toString.call(string) === '[object Date]') {
515
- return true;
516
- }
517
- // if this is not a string
518
- if (!this.isString(string)) {
519
- return false;
520
- }
521
- // strong check
522
- if (string.split('-').length !== 3) {
523
- return false;
524
- }
525
- var day = parseInt(string.split('-')[2]),
526
- month = parseInt(string.split('-')[1]),
527
- year = parseInt(string.split('-')[0]),
528
- date = new Date();
529
- date.setFullYear(year, month - 1, day);
530
- if (date.getFullYear() == year && date.getMonth() + 1 == month && date.getDate() == day) {
531
- return true;
532
- }
412
+ // if string is of object date
413
+ if (Object.prototype.toString.call(string) === '[object Date]') {
414
+ return true;
415
+ }
416
+ // if this is not a string
417
+ if (!this.isString(string)) {
533
418
  return false;
534
419
  }
535
- }, {
536
- key: "formatDate",
537
- value: function formatDate(format) {
538
- var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
539
- if (date === false || date === true || date === null || date === '') {
540
- date = new Date();
541
- } else if ((0, _typeof2.default)(date) !== 'object') {
542
- date = new Date(date.replace(/-/g, '/'));
543
- }
544
- var string = '',
545
- mo = date.getMonth(),
546
- m1 = mo + 1,
547
- dow = date.getDay(),
548
- d = date.getDate(),
549
- y = date.getFullYear(),
550
- h = date.getHours(),
551
- mi = date.getMinutes(),
552
- s = date.getSeconds();
553
- for (var i = 0, len = format.length; i < len; i++) {
554
- switch (format[i]) {
555
- case 'j':
556
- string += d;
557
- break;
558
- case 'd':
559
- string += d < 10 ? '0' + d : d;
560
- break;
561
- case 'l':
562
- var days = Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
563
- string += days[dow];
564
- break;
565
- case 'w':
566
- string += dow;
567
- break;
568
- case 'D':
569
- days = Array('Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat');
570
- string += days[dow];
571
- break;
572
- case 'm':
573
- string += m1 < 10 ? '0' + m1 : m1;
574
- break;
575
- case 'n':
576
- string += m1;
577
- break;
578
- case 'F':
579
- var months = Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
580
- string += months[mo];
581
- break;
582
- case 'M':
583
- months = Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
584
- string += months[mo];
585
- break;
586
- case 'Y':
587
- string += y;
588
- break;
589
- case 'y':
590
- string += y.toString().slice(-2);
591
- break;
592
- case 'H':
593
- string += h < 10 ? '0' + h : h;
594
- break;
595
- case 'g':
596
- var hour = h === 0 ? 12 : h;
597
- string += hour > 12 ? hour - 12 : hour;
598
- break;
599
- case 'h':
600
- hour = h === 0 ? 12 : h;
601
- hour = hour > 12 ? hour - 12 : hour;
602
- string += hour < 10 ? '0' + hour : hour;
603
- break;
604
- case 'a':
605
- string += h < 12 ? 'am' : 'pm';
606
- break;
607
- case 'i':
608
- string += mi < 10 ? '0' + mi : mi;
609
- break;
610
- case 's':
611
- string += s < 10 ? '0' + s : s;
612
- break;
613
- case 'c':
614
- string += date.toISOString();
615
- break;
616
- default:
617
- string += format[i];
618
- }
619
- }
620
- return string;
420
+ // strong check
421
+ if (string.split('-').length !== 3) {
422
+ return false;
621
423
  }
622
- }, {
623
- key: "deepCopy",
624
- value: function deepCopy(obj) {
625
- var hash = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
626
- if (Object(obj) !== obj) return obj; // primitives
627
- if (hash.has(obj)) return hash.get(obj); // cyclic reference
628
- var result = obj instanceof Date ? new Date(obj) : obj instanceof RegExp ? new RegExp(obj.source, obj.flags) : obj.constructor ? new obj.constructor() : Object.create(null);
629
- hash.set(obj, result);
630
- if (obj instanceof Map) Array.from(obj, function (_ref8) {
631
- var _ref9 = (0, _slicedToArray2.default)(_ref8, 2),
632
- key = _ref9[0],
633
- val = _ref9[1];
634
- return result.set(key, hlp.deepCopy(val, hash));
635
- });
636
- return Object.assign.apply(Object, [result].concat((0, _toConsumableArray2.default)(Object.keys(obj).map(function (key) {
637
- return (0, _defineProperty2.default)({}, key, hlp.deepCopy(obj[key], hash));
638
- }))));
639
- }
640
- }, {
641
- key: "jsonStringToObject",
642
- value: function jsonStringToObject(string) {
643
- if (this.nx(string) || !this.isString(string)) {
644
- return null;
645
- }
646
- try {
647
- return JSON.parse(string);
648
- } catch (error) {
649
- return null;
650
- }
424
+ let day = parseInt(string.split('-')[2]),
425
+ month = parseInt(string.split('-')[1]),
426
+ year = parseInt(string.split('-')[0]),
427
+ date = new Date();
428
+ date.setFullYear(year, month - 1, day);
429
+ if (date.getFullYear() == year && date.getMonth() + 1 == month && date.getDate() == day) {
430
+ return true;
651
431
  }
652
- }, {
653
- key: "isJsonString",
654
- value: function isJsonString(string) {
655
- if (this.nx(string) || !this.isString(string)) {
656
- return false;
657
- }
658
- try {
659
- var json = JSON.parse(string);
660
- return true;
661
- } catch (error) {
662
- return false;
432
+ return false;
433
+ }
434
+ static formatDate(format) {
435
+ let date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
436
+ if (date === false || date === true || date === null || date === '') {
437
+ date = new Date();
438
+ } else if (typeof date !== 'object') {
439
+ date = new Date(date.replace(/-/g, '/'));
440
+ }
441
+ let string = '',
442
+ mo = date.getMonth(),
443
+ m1 = mo + 1,
444
+ dow = date.getDay(),
445
+ d = date.getDate(),
446
+ y = date.getFullYear(),
447
+ h = date.getHours(),
448
+ mi = date.getMinutes(),
449
+ s = date.getSeconds();
450
+ for (let i = 0, len = format.length; i < len; i++) {
451
+ switch (format[i]) {
452
+ case 'j':
453
+ string += d;
454
+ break;
455
+ case 'd':
456
+ string += d < 10 ? '0' + d : d;
457
+ break;
458
+ case 'l':
459
+ let days = Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
460
+ string += days[dow];
461
+ break;
462
+ case 'w':
463
+ string += dow;
464
+ break;
465
+ case 'D':
466
+ days = Array('Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat');
467
+ string += days[dow];
468
+ break;
469
+ case 'm':
470
+ string += m1 < 10 ? '0' + m1 : m1;
471
+ break;
472
+ case 'n':
473
+ string += m1;
474
+ break;
475
+ case 'F':
476
+ let months = Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
477
+ string += months[mo];
478
+ break;
479
+ case 'M':
480
+ months = Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
481
+ string += months[mo];
482
+ break;
483
+ case 'Y':
484
+ string += y;
485
+ break;
486
+ case 'y':
487
+ string += y.toString().slice(-2);
488
+ break;
489
+ case 'H':
490
+ string += h < 10 ? '0' + h : h;
491
+ break;
492
+ case 'g':
493
+ let hour = h === 0 ? 12 : h;
494
+ string += hour > 12 ? hour - 12 : hour;
495
+ break;
496
+ case 'h':
497
+ hour = h === 0 ? 12 : h;
498
+ hour = hour > 12 ? hour - 12 : hour;
499
+ string += hour < 10 ? '0' + hour : hour;
500
+ break;
501
+ case 'a':
502
+ string += h < 12 ? 'am' : 'pm';
503
+ break;
504
+ case 'i':
505
+ string += mi < 10 ? '0' + mi : mi;
506
+ break;
507
+ case 's':
508
+ string += s < 10 ? '0' + s : s;
509
+ break;
510
+ case 'c':
511
+ string += date.toISOString();
512
+ break;
513
+ default:
514
+ string += format[i];
663
515
  }
664
516
  }
665
- }, {
666
- key: "jsonObjectToString",
667
- value: function jsonObjectToString(object) {
668
- try {
669
- return JSON.stringify(object);
670
- } catch (error) {
671
- return null;
672
- }
517
+ return string;
518
+ }
519
+ static deepCopy(obj) {
520
+ let hash = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
521
+ if (Object(obj) !== obj) return obj; // primitives
522
+ if (hash.has(obj)) return hash.get(obj); // cyclic reference
523
+ const result = obj instanceof Date ? new Date(obj) : obj instanceof RegExp ? new RegExp(obj.source, obj.flags) : obj.constructor ? new obj.constructor() : Object.create(null);
524
+ hash.set(obj, result);
525
+ if (obj instanceof Map) Array.from(obj, _ref4 => {
526
+ let [key, val] = _ref4;
527
+ return result.set(key, hlp.deepCopy(val, hash));
528
+ });
529
+ return Object.assign(result, ...Object.keys(obj).map(key => ({
530
+ [key]: hlp.deepCopy(obj[key], hash)
531
+ })));
532
+ }
533
+ static jsonStringToObject(string) {
534
+ if (this.nx(string) || !this.isString(string)) {
535
+ return null;
673
536
  }
674
- }, {
675
- key: "uuid",
676
- value: function uuid() {
677
- function s4() {
678
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
679
- }
680
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
681
- }
682
- }, {
683
- key: "guid",
684
- value: function guid() {
685
- return this.uuid();
686
- }
687
- }, {
688
- key: "replaceAll",
689
- value: function replaceAll(string, search, replace) {
690
- return string.split(search).join(replace);
691
- }
692
- }, {
693
- key: "replaceLast",
694
- value: function replaceLast(string, search, replace) {
695
- var n = string.lastIndexOf(search);
696
- string = string.slice(0, n) + string.slice(n).replace(search, replace);
537
+ try {
538
+ return JSON.parse(string);
539
+ } catch (error) {
540
+ return null;
541
+ }
542
+ }
543
+ static isJsonString(string) {
544
+ if (this.nx(string) || !this.isString(string)) {
545
+ return false;
546
+ }
547
+ try {
548
+ let json = JSON.parse(string);
549
+ return true;
550
+ } catch (error) {
551
+ return false;
552
+ }
553
+ }
554
+ static jsonObjectToString(object) {
555
+ try {
556
+ return JSON.stringify(object);
557
+ } catch (error) {
558
+ return null;
559
+ }
560
+ }
561
+ static uuid() {
562
+ function s4() {
563
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
564
+ }
565
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
566
+ }
567
+ static guid() {
568
+ return this.uuid();
569
+ }
570
+ static replaceAll(string, search, replace) {
571
+ return string.split(search).join(replace);
572
+ }
573
+ static replaceLast(string, search, replace) {
574
+ let n = string.lastIndexOf(search);
575
+ string = string.slice(0, n) + string.slice(n).replace(search, replace);
576
+ return string;
577
+ }
578
+ static replaceFirst(string, search, replace) {
579
+ return string.replace(search, replace);
580
+ }
581
+ static findAllPositions(searchStr, str) {
582
+ let searchStrLen = searchStr.length,
583
+ startIndex = 0,
584
+ index,
585
+ indices = [];
586
+ if (searchStrLen == 0) {
587
+ return [];
588
+ }
589
+ while ((index = str.indexOf(searchStr, startIndex)) > -1) {
590
+ indices.push(index);
591
+ startIndex = index + searchStrLen;
592
+ }
593
+ return indices;
594
+ }
595
+ static findAllPositionsCaseInsensitive(searchStr, str) {
596
+ let searchStrLen = searchStr.length,
597
+ startIndex = 0,
598
+ index,
599
+ indices = [];
600
+ if (searchStrLen == 0) {
601
+ return [];
602
+ }
603
+ while ((index = this.indexOfCaseInsensitive(searchStr, str, startIndex)) > -1) {
604
+ indices.push(index);
605
+ startIndex = index + searchStrLen;
606
+ }
607
+ return indices;
608
+ }
609
+ static countAllOccurences(value, str) {
610
+ let regExp = new RegExp(value, 'g');
611
+ return (str.match(regExp) || []).length;
612
+ }
613
+ static countAllOccurencesCaseInsensitive(value, str) {
614
+ let regExp = new RegExp(value, 'gi');
615
+ return (str.match(regExp) || []).length;
616
+ }
617
+ static indexOfCaseInsensitive(searchStr, str, offset) {
618
+ return str.toLowerCase().indexOf(searchStr.toLowerCase(), offset);
619
+ }
620
+ static highlight(string, query) {
621
+ let strip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
622
+ let strip_length = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500;
623
+ if (this.nx(string) || this.nx(query)) {
697
624
  return string;
698
625
  }
699
- }, {
700
- key: "replaceFirst",
701
- value: function replaceFirst(string, search, replace) {
702
- return string.replace(search, replace);
703
- }
704
- }, {
705
- key: "findAllPositions",
706
- value: function findAllPositions(searchStr, str) {
707
- var searchStrLen = searchStr.length,
708
- startIndex = 0,
709
- index,
710
- indices = [];
711
- if (searchStrLen == 0) {
712
- return [];
713
- }
714
- while ((index = str.indexOf(searchStr, startIndex)) > -1) {
715
- indices.push(index);
716
- startIndex = index + searchStrLen;
717
- }
718
- return indices;
719
- }
720
- }, {
721
- key: "findAllPositionsCaseInsensitive",
722
- value: function findAllPositionsCaseInsensitive(searchStr, str) {
723
- var searchStrLen = searchStr.length,
724
- startIndex = 0,
725
- index,
726
- indices = [];
727
- if (searchStrLen == 0) {
728
- return [];
729
- }
730
- while ((index = this.indexOfCaseInsensitive(searchStr, str, startIndex)) > -1) {
731
- indices.push(index);
732
- startIndex = index + searchStrLen;
733
- }
734
- return indices;
735
- }
736
- }, {
737
- key: "countAllOccurences",
738
- value: function countAllOccurences(value, str) {
739
- var regExp = new RegExp(value, 'g');
740
- return (str.match(regExp) || []).length;
741
- }
742
- }, {
743
- key: "countAllOccurencesCaseInsensitive",
744
- value: function countAllOccurencesCaseInsensitive(value, str) {
745
- var regExp = new RegExp(value, 'gi');
746
- return (str.match(regExp) || []).length;
747
- }
748
- }, {
749
- key: "indexOfCaseInsensitive",
750
- value: function indexOfCaseInsensitive(searchStr, str, offset) {
751
- return str.toLowerCase().indexOf(searchStr.toLowerCase(), offset);
752
- }
753
- }, {
754
- key: "highlight",
755
- value: function highlight(string, query) {
756
- var strip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
757
- var strip_length = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500;
758
- if (this.nx(string) || this.nx(query)) {
759
- return string;
760
- }
761
- if (strip === true) {
762
- var dots = '...';
763
- // get all query begin positions in spot
764
- var _positions = this.findAllPositionsCaseInsensitive(query, string);
765
- // strip away parts
766
- var words = string.split(' ');
767
- var i = 0;
768
- words.forEach(function (words__value, words__key) {
769
- var strip_now = true;
770
- _positions.forEach(function (positions__value) {
771
- if (i >= positions__value - strip_length && i <= positions__value + query.length + strip_length - 1) {
772
- strip_now = false;
773
- }
774
- });
775
- if (strip_now === true) {
776
- words[words__key] = dots;
626
+ if (strip === true) {
627
+ let dots = '...';
628
+ // get all query begin positions in spot
629
+ let positions = this.findAllPositionsCaseInsensitive(query, string);
630
+ // strip away parts
631
+ let words = string.split(' ');
632
+ let i = 0;
633
+ words.forEach((words__value, words__key) => {
634
+ let strip_now = true;
635
+ positions.forEach(positions__value => {
636
+ if (i >= positions__value - strip_length && i <= positions__value + query.length + strip_length - 1) {
637
+ strip_now = false;
777
638
  }
778
- i += words__value.length + 1;
779
639
  });
780
- string = words.join(' ');
781
- while (string.indexOf(dots + ' ' + dots) > -1) {
782
- string = this.replaceAll(string, dots + ' ' + dots, dots);
783
- }
784
- string = string.trim();
785
- }
786
- // again: get all query begin positions in spot
787
- var positions = this.findAllPositionsCaseInsensitive(query, string);
788
- // wrap span element around them
789
- var wrap_begin = '<strong class="highlight">';
790
- var wrap_end = '</strong>';
791
- for (var x = 0; x < positions.length; x++) {
792
- string = string.substring(0, positions[x]) + wrap_begin + string.substring(positions[x], positions[x] + query.length) + wrap_end + string.substring(positions[x] + query.length);
793
- // shift other positions
794
- for (var y = x + 1; y < positions.length; y++) {
795
- positions[y] = positions[y] + wrap_begin.length + wrap_end.length;
640
+ if (strip_now === true) {
641
+ words[words__key] = dots;
796
642
  }
643
+ i += words__value.length + 1;
644
+ });
645
+ string = words.join(' ');
646
+ while (string.indexOf(dots + ' ' + dots) > -1) {
647
+ string = this.replaceAll(string, dots + ' ' + dots, dots);
797
648
  }
798
- return string;
649
+ string = string.trim();
799
650
  }
800
- }, {
801
- key: "get",
802
- value: function get(url) {
803
- var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
804
- return this.call('GET', url, args);
805
- }
806
- }, {
807
- key: "post",
808
- value: function post(url) {
809
- var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
810
- return this.call('POST', url, args);
811
- }
812
- }, {
813
- key: "call",
814
- value: function call(method, url) {
815
- var _this2 = this;
816
- var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
817
- if (args === null) {
818
- args = {};
819
- }
820
- if (!('data' in args)) {
821
- args.data = {};
651
+ // again: get all query begin positions in spot
652
+ let positions = this.findAllPositionsCaseInsensitive(query, string);
653
+ // wrap span element around them
654
+ let wrap_begin = '<strong class="highlight">';
655
+ let wrap_end = '</strong>';
656
+ for (let x = 0; x < positions.length; x++) {
657
+ string = string.substring(0, positions[x]) + wrap_begin + string.substring(positions[x], positions[x] + query.length) + wrap_end + string.substring(positions[x] + query.length);
658
+ // shift other positions
659
+ for (let y = x + 1; y < positions.length; y++) {
660
+ positions[y] = positions[y] + wrap_begin.length + wrap_end.length;
822
661
  }
823
- if (!('headers' in args)) {
824
- args.headers = null;
825
- }
826
- if (!('throttle' in args)) {
827
- args.throttle = 0;
828
- }
829
- if (!('allow_errors' in args)) {
830
- args.allow_errors = true;
831
- }
832
- return new Promise(function (resolve, reject) {
833
- setTimeout(function () {
834
- if (url.indexOf('http') !== 0) {
835
- url = hlp.baseUrl() + '/' + url;
836
- }
837
- var xhr = new XMLHttpRequest();
838
- xhr.open(method, url, true);
839
- if (method === 'POST') {
840
- if ('data' in args && args.data !== null && (0, _typeof2.default)(args.data) === 'object' && !(args.data instanceof FormData)) {
841
- xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
842
- args.data = JSON.stringify(args.data);
843
- }
844
- xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
845
- }
846
- if (_this2.x(args.headers)) {
847
- Object.entries(args.headers).forEach(function (_ref11) {
848
- var _ref12 = (0, _slicedToArray2.default)(_ref11, 2),
849
- headers__key = _ref12[0],
850
- headers__value = _ref12[1];
851
- xhr.setRequestHeader(headers__key, headers__value);
852
- });
662
+ }
663
+ return string;
664
+ }
665
+ static get(url) {
666
+ let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
667
+ return this.call('GET', url, args);
668
+ }
669
+ static post(url) {
670
+ let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
671
+ return this.call('POST', url, args);
672
+ }
673
+ static call(method, url) {
674
+ let args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
675
+ if (args === null) {
676
+ args = {};
677
+ }
678
+ if (!('data' in args)) {
679
+ args.data = {};
680
+ }
681
+ if (!('headers' in args)) {
682
+ args.headers = null;
683
+ }
684
+ if (!('throttle' in args)) {
685
+ args.throttle = 0;
686
+ }
687
+ if (!('allow_errors' in args)) {
688
+ args.allow_errors = true;
689
+ }
690
+ return new Promise((resolve, reject) => {
691
+ setTimeout(() => {
692
+ if (url.indexOf('http') !== 0) {
693
+ url = hlp.baseUrl() + '/' + url;
694
+ }
695
+ let xhr = new XMLHttpRequest();
696
+ xhr.open(method, url, true);
697
+ if (method === 'POST') {
698
+ if ('data' in args && args.data !== null && typeof args.data === 'object' && !(args.data instanceof FormData)) {
699
+ xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
700
+ args.data = JSON.stringify(args.data);
853
701
  }
854
- xhr.onload = function () {
855
- if (xhr.readyState != 4 || args.allow_errors !== true && xhr.status != 200 && xhr.status != 304) {
856
- if (_this2.isJsonString(xhr.responseText)) {
857
- reject(_this2.jsonStringToObject(xhr.responseText));
858
- } else {
859
- reject(xhr.responseText);
860
- }
861
- }
862
- if (_this2.isJsonString(xhr.responseText)) {
863
- resolve(_this2.jsonStringToObject(xhr.responseText));
702
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
703
+ }
704
+ if (this.x(args.headers)) {
705
+ Object.entries(args.headers).forEach(_ref5 => {
706
+ let [headers__key, headers__value] = _ref5;
707
+ xhr.setRequestHeader(headers__key, headers__value);
708
+ });
709
+ }
710
+ xhr.onload = () => {
711
+ if (xhr.readyState != 4 || args.allow_errors !== true && xhr.status != 200 && xhr.status != 304) {
712
+ if (this.isJsonString(xhr.responseText)) {
713
+ reject(this.jsonStringToObject(xhr.responseText));
864
714
  } else {
865
- resolve(xhr.responseText);
715
+ reject(xhr.responseText);
866
716
  }
867
- };
868
- xhr.onerror = function () {
869
- reject([xhr.readyState, xhr.status, xhr.statusText]);
870
- };
871
- if (method === 'GET') {
872
- xhr.send(null);
873
717
  }
874
- if (method === 'POST') {
875
- xhr.send(args.data);
876
- }
877
- }, args.throttle);
878
- });
879
- }
880
- }, {
881
- key: "onResizeHorizontal",
882
- value: function onResizeHorizontal(fun) {
883
- var windowWidth = window.innerWidth,
884
- windowWidthNew,
885
- timeout;
886
- window.addEventListener('resize', function () {
887
- windowWidthNew = window.innerWidth;
888
- if (windowWidthNew != windowWidth) {
889
- windowWidth = windowWidthNew;
890
- if (timeout) {
891
- clearTimeout(timeout);
718
+ if (this.isJsonString(xhr.responseText)) {
719
+ resolve(this.jsonStringToObject(xhr.responseText));
720
+ } else {
721
+ resolve(xhr.responseText);
892
722
  }
893
- timeout = window.setTimeout(function () {
894
- fun();
895
- }, 50);
723
+ };
724
+ xhr.onerror = () => {
725
+ reject([xhr.readyState, xhr.status, xhr.statusText]);
726
+ };
727
+ if (method === 'GET') {
728
+ xhr.send(null);
896
729
  }
897
- });
898
- fun();
899
- }
900
- }, {
901
- key: "onResizeVertical",
902
- value: function onResizeVertical(fun) {
903
- var windowHeight = window.innerHeight,
904
- windowHeightNew,
905
- timeout;
906
- window.addEventListener('resize', function () {
907
- windowHeightNew = window.innerHeight;
908
- if (windowHeightNew != windowHeight) {
909
- windowHeight = windowHeightNew;
910
- if (timeout) {
911
- clearTimeout(timeout);
912
- }
913
- timeout = window.setTimeout(function () {
914
- fun();
915
- }, 50);
730
+ if (method === 'POST') {
731
+ xhr.send(args.data);
916
732
  }
917
- });
918
- fun();
919
- }
920
- }, {
921
- key: "removeEmpty",
922
- value: function removeEmpty(array) {
923
- var _this3 = this;
924
- if (this.nx(array) || !Array.isArray(array)) {
925
- return array;
733
+ }, args.throttle);
734
+ });
735
+ }
736
+ static onResizeHorizontal(fun) {
737
+ let windowWidth = window.innerWidth,
738
+ windowWidthNew,
739
+ timeout;
740
+ window.addEventListener('resize', () => {
741
+ windowWidthNew = window.innerWidth;
742
+ if (windowWidthNew != windowWidth) {
743
+ windowWidth = windowWidthNew;
744
+ if (timeout) {
745
+ clearTimeout(timeout);
746
+ }
747
+ timeout = window.setTimeout(() => {
748
+ fun();
749
+ }, 50);
926
750
  }
927
- array = array.filter(function (array__value) {
928
- return _this3.x(array__value);
929
- });
930
- return array;
931
- }
932
- }, {
933
- key: "uniqueArray",
934
- value: function uniqueArray(array) {
935
- var seen = {},
936
- ret_arr = [];
937
- for (var i = 0; i < array.length; i++) {
938
- if (!(array[i] in seen)) {
939
- ret_arr.push(array[i]);
940
- seen[array[i]] = true;
751
+ });
752
+ fun();
753
+ }
754
+ static onResizeVertical(fun) {
755
+ var windowHeight = window.innerHeight,
756
+ windowHeightNew,
757
+ timeout;
758
+ window.addEventListener('resize', () => {
759
+ windowHeightNew = window.innerHeight;
760
+ if (windowHeightNew != windowHeight) {
761
+ windowHeight = windowHeightNew;
762
+ if (timeout) {
763
+ clearTimeout(timeout);
941
764
  }
765
+ timeout = window.setTimeout(() => {
766
+ fun();
767
+ }, 50);
942
768
  }
943
- return ret_arr;
769
+ });
770
+ fun();
771
+ }
772
+ static removeEmpty(array) {
773
+ if (this.nx(array) || !Array.isArray(array)) {
774
+ return array;
944
775
  }
945
- }, {
946
- key: "powerset",
947
- value: function powerset(array) {
948
- if (!Array.isArray(array)) {
949
- return array;
950
- }
951
- return array.reduce(function (subsets, value) {
952
- return subsets.concat(subsets.map(function (set) {
953
- return [].concat((0, _toConsumableArray2.default)(set), [value]);
954
- }));
955
- }, [[]]);
956
- }
957
- }, {
958
- key: "charToInt",
959
- value: function charToInt(val) {
960
- val = val.toUpperCase();
961
- var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
962
- i,
963
- j,
964
- result = 0;
965
- for (i = 0, j = val.length - 1; i < val.length; i += 1, j -= 1) {
966
- result += Math.pow(base.length, j) * (base.indexOf(val[i]) + 1);
776
+ array = array.filter(array__value => {
777
+ return this.x(array__value);
778
+ });
779
+ return array;
780
+ }
781
+ static uniqueArray(array) {
782
+ let seen = {},
783
+ ret_arr = [];
784
+ for (let i = 0; i < array.length; i++) {
785
+ if (!(array[i] in seen)) {
786
+ ret_arr.push(array[i]);
787
+ seen[array[i]] = true;
967
788
  }
968
- return result;
969
789
  }
970
- }, {
971
- key: "intToChar",
972
- value: function intToChar(num) {
973
- for (var ret = '', a = 1, b = 26; (num -= a) >= 0; a = b, b *= 26) {
974
- ret = String.fromCharCode(parseInt(num % b / a) + 65) + ret;
975
- }
976
- return ret;
790
+ return ret_arr;
791
+ }
792
+ static powerset(array) {
793
+ if (!Array.isArray(array)) {
794
+ return array;
977
795
  }
978
- }, {
979
- key: "slugify",
980
- value: function slugify(text) {
981
- return text.toString().toLowerCase().trim().split('ä').join('ae').split('ö').join('oe').split('ü').join('ue').split('ß').join('ss').replace(/[^\w\s-]/g, '') // remove non-word [a-z0-9_], non-whitespace, non-hyphen characters
982
- .replace(/[\s_-]+/g, '-') // swap any length of whitespace, underscore, hyphen characters with a single -
983
- .replace(/^-+|-+$/g, ''); // remove leading, trailing -
984
- }
985
- }, {
986
- key: "incChar",
987
- value: function incChar(char) {
988
- var shift = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
989
- return this.intToChar(this.charToInt(char) + shift);
990
- }
991
- }, {
992
- key: "decChar",
993
- value: function decChar(char) {
994
- var shift = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
995
- return this.intToChar(this.charToInt(char) - shift);
996
- }
997
- }, {
998
- key: "range",
999
- value: function range(start, end) {
1000
- var range = [],
1001
- typeofStart = (0, _typeof2.default)(start),
1002
- typeofEnd = (0, _typeof2.default)(end),
1003
- step = 1;
1004
- if (typeofStart == 'undefined' || typeofEnd == 'undefined' || typeofStart != typeofEnd) {
1005
- return null;
1006
- }
1007
- if (end < start) {
1008
- step = -step;
1009
- }
1010
- if (typeofStart == 'number') {
1011
- while (step > 0 ? end >= start : end <= start) {
1012
- range.push(start);
1013
- start += step;
1014
- }
1015
- } else if (typeofStart == 'string') {
1016
- if (start.length != 1 || end.length != 1) {
1017
- return null;
1018
- }
1019
- start = start.charCodeAt(0);
1020
- end = end.charCodeAt(0);
1021
- while (step > 0 ? end >= start : end <= start) {
1022
- range.push(String.fromCharCode(start));
1023
- start += step;
1024
- }
1025
- } else {
1026
- return null;
1027
- }
1028
- return range;
1029
- }
1030
- }, {
1031
- key: "dateToWeek",
1032
- value: function dateToWeek() {
1033
- var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1034
- if (d === null) {
1035
- d = new Date();
1036
- }
1037
- d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
1038
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
1039
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)),
1040
- weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
1041
- return weekNo;
1042
- }
1043
- }, {
1044
- key: "weekToDate",
1045
- value: function weekToDate(week, year) {
1046
- if (year == null) {
1047
- year = new Date().getFullYear();
1048
- }
1049
- var date = new Date();
1050
- date.setYear(year);
1051
- date.setDate(1);
1052
- date.setMonth(0);
1053
- date.setHours(0);
1054
- date.setMinutes(0);
1055
- date.setSeconds(0);
1056
- date.setMilliseconds(0);
1057
- var FIRST_DAY_OF_WEEK = 1;
1058
- var WEEK_LENGTH = 7;
1059
- var day = date.getDay();
1060
- day = day === 0 ? 7 : day;
1061
- var dayOffset = -day + FIRST_DAY_OF_WEEK;
1062
- if (WEEK_LENGTH - day + 1 < 4) {
1063
- dayOffset += WEEK_LENGTH;
1064
- }
1065
- date = new Date(date.getTime() + dayOffset * 24 * 60 * 60 * 1000);
1066
- var weekTime = 1000 * 60 * 60 * 24 * 7 * (week - 1);
1067
- var targetTime = date.getTime() + weekTime;
1068
- date.setTime(targetTime);
1069
- date.setHours(0);
1070
- date.setMinutes(0);
1071
- date.setSeconds(0);
1072
- date.setMilliseconds(0);
1073
- return date;
1074
- }
1075
- }, {
1076
- key: "addDays",
1077
- value: function addDays(date, days) {
1078
- var result = new Date(date);
1079
- result.setDate(result.getDate() + days);
1080
- return result;
796
+ return array.reduce((subsets, value) => subsets.concat(subsets.map(set => [...set, value])), [[]]);
797
+ }
798
+ static charToInt(val) {
799
+ val = val.toUpperCase();
800
+ let base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
801
+ i,
802
+ j,
803
+ result = 0;
804
+ for (i = 0, j = val.length - 1; i < val.length; i += 1, j -= 1) {
805
+ result += Math.pow(base.length, j) * (base.indexOf(val[i]) + 1);
806
+ }
807
+ return result;
808
+ }
809
+ static intToChar(num) {
810
+ for (var ret = '', a = 1, b = 26; (num -= a) >= 0; a = b, b *= 26) {
811
+ ret = String.fromCharCode(parseInt(num % b / a) + 65) + ret;
1081
812
  }
1082
- }, {
1083
- key: "objectsAreEqual",
1084
- value: function objectsAreEqual(x, y) {
1085
- var _this = this;
1086
- if (x === null || x === undefined || y === null || y === undefined) {
1087
- return x === y;
1088
- }
1089
- if (x.constructor !== y.constructor) {
1090
- return false;
1091
- }
1092
- if (x instanceof Function) {
1093
- return x === y;
1094
- }
1095
- if (x instanceof RegExp) {
1096
- return x === y;
1097
- }
1098
- if (x === y || x.valueOf() === y.valueOf()) {
1099
- return true;
1100
- }
1101
- if (Array.isArray(x) && x.length !== y.length) {
1102
- return false;
1103
- }
1104
- if (x instanceof Date) {
1105
- return false;
813
+ return ret;
814
+ }
815
+ static slugify(text) {
816
+ return text.toString().toLowerCase().trim().split('ä').join('ae').split('ö').join('oe').split('ü').join('ue').split('ß').join('ss').replace(/[^\w\s-]/g, '') // remove non-word [a-z0-9_], non-whitespace, non-hyphen characters
817
+ .replace(/[\s_-]+/g, '-') // swap any length of whitespace, underscore, hyphen characters with a single -
818
+ .replace(/^-+|-+$/g, ''); // remove leading, trailing -
819
+ }
820
+
821
+ static incChar(char) {
822
+ let shift = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
823
+ return this.intToChar(this.charToInt(char) + shift);
824
+ }
825
+ static decChar(char) {
826
+ let shift = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
827
+ return this.intToChar(this.charToInt(char) - shift);
828
+ }
829
+ static range(start, end) {
830
+ let range = [],
831
+ typeofStart = typeof start,
832
+ typeofEnd = typeof end,
833
+ step = 1;
834
+ if (typeofStart == 'undefined' || typeofEnd == 'undefined' || typeofStart != typeofEnd) {
835
+ return null;
836
+ }
837
+ if (end < start) {
838
+ step = -step;
839
+ }
840
+ if (typeofStart == 'number') {
841
+ while (step > 0 ? end >= start : end <= start) {
842
+ range.push(start);
843
+ start += step;
1106
844
  }
1107
- if (!(x instanceof Object)) {
1108
- return false;
845
+ } else if (typeofStart == 'string') {
846
+ if (start.length != 1 || end.length != 1) {
847
+ return null;
1109
848
  }
1110
- if (!(y instanceof Object)) {
1111
- return false;
849
+ start = start.charCodeAt(0);
850
+ end = end.charCodeAt(0);
851
+ while (step > 0 ? end >= start : end <= start) {
852
+ range.push(String.fromCharCode(start));
853
+ start += step;
1112
854
  }
1113
- var p = Object.keys(x);
1114
- return Object.keys(y).every(function (i) {
1115
- return p.indexOf(i) !== -1;
1116
- }) && p.every(function (i) {
1117
- return _this.objectsAreEqual(x[i], y[i]);
1118
- });
855
+ } else {
856
+ return null;
1119
857
  }
1120
- }, {
1121
- key: "containsObject",
1122
- value: function containsObject(obj, list) {
1123
- var x;
1124
- for (x in list) {
1125
- if (list.hasOwnProperty(x) && this.objectsAreEqual(list[x], obj)) {
1126
- return true;
1127
- }
1128
- }
858
+ return range;
859
+ }
860
+ static dateToWeek() {
861
+ let d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
862
+ if (d === null) {
863
+ d = new Date();
864
+ }
865
+ d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
866
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
867
+ let yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)),
868
+ weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
869
+ return weekNo;
870
+ }
871
+ static weekToDate(week, year) {
872
+ if (year == null) {
873
+ year = new Date().getFullYear();
874
+ }
875
+ let date = new Date();
876
+ date.setYear(year);
877
+ date.setDate(1);
878
+ date.setMonth(0);
879
+ date.setHours(0);
880
+ date.setMinutes(0);
881
+ date.setSeconds(0);
882
+ date.setMilliseconds(0);
883
+ let FIRST_DAY_OF_WEEK = 1;
884
+ let WEEK_LENGTH = 7;
885
+ let day = date.getDay();
886
+ day = day === 0 ? 7 : day;
887
+ let dayOffset = -day + FIRST_DAY_OF_WEEK;
888
+ if (WEEK_LENGTH - day + 1 < 4) {
889
+ dayOffset += WEEK_LENGTH;
890
+ }
891
+ date = new Date(date.getTime() + dayOffset * 24 * 60 * 60 * 1000);
892
+ let weekTime = 1000 * 60 * 60 * 24 * 7 * (week - 1);
893
+ let targetTime = date.getTime() + weekTime;
894
+ date.setTime(targetTime);
895
+ date.setHours(0);
896
+ date.setMinutes(0);
897
+ date.setSeconds(0);
898
+ date.setMilliseconds(0);
899
+ return date;
900
+ }
901
+ static addDays(date, days) {
902
+ var result = new Date(date);
903
+ result.setDate(result.getDate() + days);
904
+ return result;
905
+ }
906
+ static objectsAreEqual(x, y) {
907
+ var _this = this;
908
+ if (x === null || x === undefined || y === null || y === undefined) {
909
+ return x === y;
910
+ }
911
+ if (x.constructor !== y.constructor) {
1129
912
  return false;
1130
913
  }
1131
- }, {
1132
- key: "fadeOut",
1133
- value: function fadeOut(el) {
1134
- var speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1135
- if (speed <= 25) {
1136
- speed = 25;
1137
- }
1138
- return new Promise(function (resolve) {
1139
- el.style.opacity = 1;
1140
- (function fade() {
1141
- if ((el.style.opacity -= 25 / speed) < 0) {
1142
- el.style.display = 'none';
1143
- resolve();
1144
- } else {
1145
- requestAnimationFrame(fade);
1146
- }
1147
- })();
1148
- });
914
+ if (x instanceof Function) {
915
+ return x === y;
1149
916
  }
1150
- }, {
1151
- key: "fadeIn",
1152
- value: function fadeIn(el) {
1153
- var speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1154
- if (speed <= 25) {
1155
- speed = 25;
1156
- }
1157
- return new Promise(function (resolve) {
1158
- el.style.opacity = 0;
1159
- el.style.display = 'block';
1160
- (function fade() {
1161
- var val = parseFloat(el.style.opacity);
1162
- if (!((val += 25 / speed) > 1)) {
1163
- el.style.opacity = val;
1164
- requestAnimationFrame(fade);
1165
- } else {
1166
- resolve();
1167
- }
1168
- })();
1169
- });
917
+ if (x instanceof RegExp) {
918
+ return x === y;
1170
919
  }
1171
- }, {
1172
- key: "scrollTop",
1173
- value: function scrollTop() {
1174
- var doc = document.documentElement;
1175
- return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
1176
- }
1177
- }, {
1178
- key: "scrollLeft",
1179
- value: function scrollLeft() {
1180
- var doc = document.documentElement;
1181
- return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
1182
- }
1183
- }, {
1184
- key: "closestScrollable",
1185
- value: function closestScrollable(node) {
1186
- var isElement = node instanceof HTMLElement,
1187
- overflowY = isElement && window.getComputedStyle(node).overflowY,
1188
- isScrollable = overflowY && !(overflowY.includes('hidden') || overflowY.includes('visible'));
1189
- if (!node) {
1190
- return null;
1191
- } else if (isScrollable && node.scrollHeight >= node.clientHeight) {
1192
- return node;
920
+ if (x === y || x.valueOf() === y.valueOf()) {
921
+ return true;
922
+ }
923
+ if (Array.isArray(x) && x.length !== y.length) {
924
+ return false;
925
+ }
926
+ if (x instanceof Date) {
927
+ return false;
928
+ }
929
+ if (!(x instanceof Object)) {
930
+ return false;
931
+ }
932
+ if (!(y instanceof Object)) {
933
+ return false;
934
+ }
935
+ var p = Object.keys(x);
936
+ return Object.keys(y).every(function (i) {
937
+ return p.indexOf(i) !== -1;
938
+ }) && p.every(function (i) {
939
+ return _this.objectsAreEqual(x[i], y[i]);
940
+ });
941
+ }
942
+ static containsObject(obj, list) {
943
+ var x;
944
+ for (x in list) {
945
+ if (list.hasOwnProperty(x) && this.objectsAreEqual(list[x], obj)) {
946
+ return true;
1193
947
  }
1194
- return this.closestScrollable(node.parentNode) || document.scrollingElement || document.body;
1195
- }
1196
- }, {
1197
- key: "offsetTop",
1198
- value: function offsetTop(el) {
1199
- return el.getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop;
1200
- }
1201
- }, {
1202
- key: "offsetLeft",
1203
- value: function offsetLeft(el) {
1204
- return el.getBoundingClientRect().left + window.pageXOffset - document.documentElement.clientLeft;
1205
- }
1206
- }, {
1207
- key: "offsetRight",
1208
- value: function offsetRight(el) {
1209
- return el.getBoundingClientRect().left + window.pageXOffset - document.documentElement.clientLeft + el.offsetWidth;
1210
- }
1211
- }, {
1212
- key: "offsetBottom",
1213
- value: function offsetBottom(el) {
1214
- return el.getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop + el.offsetHeight;
1215
- }
1216
- }, {
1217
- key: "offsetTopWithMargin",
1218
- value: function offsetTopWithMargin(el) {
1219
- return this.offsetTop(el) - parseInt(getComputedStyle(el).marginTop);
1220
- }
1221
- }, {
1222
- key: "offsetLeftWithMargin",
1223
- value: function offsetLeftWithMargin(el) {
1224
- return this.offsetLeft(el) - parseInt(getComputedStyle(el).marginLeft);
1225
- }
1226
- }, {
1227
- key: "offsetRightWithMargin",
1228
- value: function offsetRightWithMargin(el) {
1229
- return this.offsetRight(el) + parseInt(getComputedStyle(el).marginRight);
1230
- }
1231
- }, {
1232
- key: "offsetBottomWithMargin",
1233
- value: function offsetBottomWithMargin(el) {
1234
- return this.offsetBottom(el) + parseInt(getComputedStyle(el).marginBottom);
1235
- }
1236
- }, {
1237
- key: "documentHeight",
1238
- value: function documentHeight() {
1239
- return Math.max(document.body.offsetHeight, document.body.scrollHeight, document.documentElement.clientHeight, document.documentElement.offsetHeight, document.documentElement.scrollHeight);
1240
- }
1241
- }, {
1242
- key: "documentWidth",
1243
- value: function documentWidth() {
1244
- return document.documentElement.clientWidth || document.body.clientWidth;
1245
- }
1246
- }, {
1247
- key: "windowWidth",
1248
- value: function windowWidth() {
1249
- return window.innerWidth;
1250
- }
1251
- }, {
1252
- key: "windowHeight",
1253
- value: function windowHeight() {
1254
- return window.innerHeight;
1255
- }
1256
- }, {
1257
- key: "windowWidthWithoutScrollbar",
1258
- value: function windowWidthWithoutScrollbar() {
1259
- return document.documentElement.clientWidth || document.body.clientWidth;
1260
- }
1261
- }, {
1262
- key: "windowHeightWithoutScrollbar",
1263
- value: function windowHeightWithoutScrollbar() {
1264
- return document.documentElement.clientHeight || document.body.clientHeight;
1265
- }
1266
- }, {
1267
- key: "outerWidthWithMargin",
1268
- value: function outerWidthWithMargin(el) {
1269
- return el.offsetWidth + parseInt(getComputedStyle(el).marginLeft) + parseInt(getComputedStyle(el).marginRight);
1270
- }
1271
- }, {
1272
- key: "outerHeightWithMargin",
1273
- value: function outerHeightWithMargin(el) {
1274
- return el.offsetHeight + parseInt(getComputedStyle(el).marginTop) + parseInt(getComputedStyle(el).marginBottom);
1275
- }
1276
- }, {
1277
- key: "scrollTo",
1278
- value: function scrollTo(to) {
1279
- var _this4 = this;
1280
- var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1281
- var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1282
- var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1283
- var only_up = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1284
- return new Promise(function (resolve) {
1285
- if (element === null) {
1286
- element = document.scrollingElement || document.documentElement;
948
+ }
949
+ return false;
950
+ }
951
+ static fadeOut(el) {
952
+ let speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
953
+ if (speed <= 25) {
954
+ speed = 25;
955
+ }
956
+ return new Promise(resolve => {
957
+ el.style.opacity = 1;
958
+ (function fade() {
959
+ if ((el.style.opacity -= 25 / speed) < 0) {
960
+ el.style.display = 'none';
961
+ resolve();
962
+ } else {
963
+ requestAnimationFrame(fade);
1287
964
  }
1288
- if (!hlp.isNumeric(to)) {
1289
- if (element === (document.scrollingElement || documentElement)) {
1290
- to = _this4.offsetTopWithMargin(to);
1291
- } else {
1292
- to = to.getBoundingClientRect().top - parseInt(getComputedStyle(to).marginTop) - (element.getBoundingClientRect().top - element.scrollTop - parseInt(getComputedStyle(element).marginTop));
1293
- }
965
+ })();
966
+ });
967
+ }
968
+ static fadeIn(el) {
969
+ let speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
970
+ if (speed <= 25) {
971
+ speed = 25;
972
+ }
973
+ return new Promise(resolve => {
974
+ el.style.opacity = 0;
975
+ el.style.display = 'block';
976
+ (function fade() {
977
+ var val = parseFloat(el.style.opacity);
978
+ if (!((val += 25 / speed) > 1)) {
979
+ el.style.opacity = val;
980
+ requestAnimationFrame(fade);
981
+ } else {
982
+ resolve();
1294
983
  }
1295
- var offset_calc = 0;
1296
- if (!Array.isArray(offset)) {
1297
- offset = [offset];
984
+ })();
985
+ });
986
+ }
987
+ static scrollTop() {
988
+ let doc = document.documentElement;
989
+ return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
990
+ }
991
+ static scrollLeft() {
992
+ let doc = document.documentElement;
993
+ return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
994
+ }
995
+ static closestScrollable(node) {
996
+ let isElement = node instanceof HTMLElement,
997
+ overflowY = isElement && window.getComputedStyle(node).overflowY,
998
+ isScrollable = overflowY && !(overflowY.includes('hidden') || overflowY.includes('visible'));
999
+ if (!node) {
1000
+ return null;
1001
+ } else if (isScrollable && node.scrollHeight >= node.clientHeight) {
1002
+ return node;
1003
+ }
1004
+ return this.closestScrollable(node.parentNode) || document.scrollingElement || document.body;
1005
+ }
1006
+ static offsetTop(el) {
1007
+ return el.getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop;
1008
+ }
1009
+ static offsetLeft(el) {
1010
+ return el.getBoundingClientRect().left + window.pageXOffset - document.documentElement.clientLeft;
1011
+ }
1012
+ static offsetRight(el) {
1013
+ return el.getBoundingClientRect().left + window.pageXOffset - document.documentElement.clientLeft + el.offsetWidth;
1014
+ }
1015
+ static offsetBottom(el) {
1016
+ return el.getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop + el.offsetHeight;
1017
+ }
1018
+ static offsetTopWithMargin(el) {
1019
+ return this.offsetTop(el) - parseInt(getComputedStyle(el).marginTop);
1020
+ }
1021
+ static offsetLeftWithMargin(el) {
1022
+ return this.offsetLeft(el) - parseInt(getComputedStyle(el).marginLeft);
1023
+ }
1024
+ static offsetRightWithMargin(el) {
1025
+ return this.offsetRight(el) + parseInt(getComputedStyle(el).marginRight);
1026
+ }
1027
+ static offsetBottomWithMargin(el) {
1028
+ return this.offsetBottom(el) + parseInt(getComputedStyle(el).marginBottom);
1029
+ }
1030
+ static documentHeight() {
1031
+ return Math.max(document.body.offsetHeight, document.body.scrollHeight, document.documentElement.clientHeight, document.documentElement.offsetHeight, document.documentElement.scrollHeight);
1032
+ }
1033
+ static documentWidth() {
1034
+ return document.documentElement.clientWidth || document.body.clientWidth;
1035
+ }
1036
+ static windowWidth() {
1037
+ return window.innerWidth;
1038
+ }
1039
+ static windowHeight() {
1040
+ return window.innerHeight;
1041
+ }
1042
+ static windowWidthWithoutScrollbar() {
1043
+ return document.documentElement.clientWidth || document.body.clientWidth;
1044
+ }
1045
+ static windowHeightWithoutScrollbar() {
1046
+ return document.documentElement.clientHeight || document.body.clientHeight;
1047
+ }
1048
+ static outerWidthWithMargin(el) {
1049
+ return el.offsetWidth + parseInt(getComputedStyle(el).marginLeft) + parseInt(getComputedStyle(el).marginRight);
1050
+ }
1051
+ static outerHeightWithMargin(el) {
1052
+ return el.offsetHeight + parseInt(getComputedStyle(el).marginTop) + parseInt(getComputedStyle(el).marginBottom);
1053
+ }
1054
+ static scrollTo(to) {
1055
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1056
+ let element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1057
+ let offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1058
+ let only_up = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1059
+ return new Promise(resolve => {
1060
+ if (element === null) {
1061
+ element = document.scrollingElement || document.documentElement;
1062
+ }
1063
+ if (!hlp.isNumeric(to)) {
1064
+ if (element === (document.scrollingElement || documentElement)) {
1065
+ to = this.offsetTopWithMargin(to);
1066
+ } else {
1067
+ to = to.getBoundingClientRect().top - parseInt(getComputedStyle(to).marginTop) - (element.getBoundingClientRect().top - element.scrollTop - parseInt(getComputedStyle(element).marginTop));
1298
1068
  }
1299
- offset.forEach(function (offset__value) {
1300
- if (hlp.isNumeric(offset__value)) {
1301
- offset_calc += offset__value;
1302
- } else {
1303
- if (offset__value !== null) {
1304
- if (window.getComputedStyle(offset__value).position === 'fixed') {
1305
- offset_calc += -1 * offset__value.offsetHeight;
1306
- }
1069
+ }
1070
+ let offset_calc = 0;
1071
+ if (!Array.isArray(offset)) {
1072
+ offset = [offset];
1073
+ }
1074
+ offset.forEach(offset__value => {
1075
+ if (hlp.isNumeric(offset__value)) {
1076
+ offset_calc += offset__value;
1077
+ } else {
1078
+ if (offset__value !== null) {
1079
+ if (window.getComputedStyle(offset__value).position === 'fixed') {
1080
+ offset_calc += -1 * offset__value.offsetHeight;
1307
1081
  }
1308
1082
  }
1309
- });
1310
- to += offset_calc;
1311
- var start = element.scrollTop,
1312
- change = to - start,
1313
- startDate = +new Date(),
1314
- // t = current time
1315
- // b = start value
1316
- // c = change in value
1317
- // d = duration
1318
- easeInOutQuad = function easeInOutQuad(t, b, c, d) {
1319
- t /= d / 2;
1320
- if (t < 1) return c / 2 * t * t + b;
1321
- t--;
1322
- return -c / 2 * (t * (t - 2) - 1) + b;
1323
- },
1324
- easeInOutCirc = function easeInOutCirc(t, b, c, d) {
1325
- t /= d / 2;
1326
- if (t < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
1327
- t -= 2;
1328
- return c / 2 * (Math.sqrt(1 - t * t) + 1) + b;
1329
- },
1330
- animateScroll = function animateScroll() {
1331
- var currentDate = +new Date();
1332
- var currentTime = currentDate - startDate;
1333
- element.scrollTop = parseInt(easeInOutCirc(currentTime, start, change, duration));
1334
- if (currentTime < duration) {
1335
- requestAnimationFrame(animateScroll);
1336
- } else {
1337
- element.scrollTop = to;
1338
- resolve();
1339
- }
1340
- };
1341
- if (only_up === true && change > 0) {
1342
- resolve();
1343
- return;
1344
1083
  }
1345
- animateScroll();
1346
1084
  });
1347
- }
1348
- }, {
1349
- key: "loadJs",
1350
- value: function loadJs(urls) {
1351
- if (!hlp.isArray(urls)) {
1352
- urls = [urls];
1353
- }
1354
- var promises = [];
1355
- hlp.loop(urls, function (urls__value, urls__key) {
1356
- promises.push(new Promise(function (resolve, reject) {
1357
- var script = document.createElement('script');
1358
- script.src = urls__value;
1359
- script.onload = function () {
1085
+ to += offset_calc;
1086
+ const start = element.scrollTop,
1087
+ change = to - start,
1088
+ startDate = +new Date(),
1089
+ // t = current time
1090
+ // b = start value
1091
+ // c = change in value
1092
+ // d = duration
1093
+ easeInOutQuad = function (t, b, c, d) {
1094
+ t /= d / 2;
1095
+ if (t < 1) return c / 2 * t * t + b;
1096
+ t--;
1097
+ return -c / 2 * (t * (t - 2) - 1) + b;
1098
+ },
1099
+ easeInOutCirc = function (t, b, c, d) {
1100
+ t /= d / 2;
1101
+ if (t < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
1102
+ t -= 2;
1103
+ return c / 2 * (Math.sqrt(1 - t * t) + 1) + b;
1104
+ },
1105
+ animateScroll = function () {
1106
+ const currentDate = +new Date();
1107
+ const currentTime = currentDate - startDate;
1108
+ element.scrollTop = parseInt(easeInOutCirc(currentTime, start, change, duration));
1109
+ if (currentTime < duration) {
1110
+ requestAnimationFrame(animateScroll);
1111
+ } else {
1112
+ element.scrollTop = to;
1360
1113
  resolve();
1361
- };
1362
- document.head.appendChild(script);
1363
- }));
1364
- });
1365
- return Promise.all(promises);
1366
- }
1367
- }, {
1368
- key: "loadJsSequentially",
1369
- value: function () {
1370
- var _loadJsSequentially = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(urls) {
1371
- var _iterator, _step, urls__value;
1372
- return _regenerator.default.wrap(function _callee$(_context) {
1373
- while (1) switch (_context.prev = _context.next) {
1374
- case 0:
1375
- if (!hlp.isArray(urls)) {
1376
- urls = [urls];
1377
- }
1378
- _iterator = _createForOfIteratorHelper(urls);
1379
- _context.prev = 2;
1380
- _iterator.s();
1381
- case 4:
1382
- if ((_step = _iterator.n()).done) {
1383
- _context.next = 10;
1384
- break;
1385
- }
1386
- urls__value = _step.value;
1387
- _context.next = 8;
1388
- return hlp.loadJs(urls__value);
1389
- case 8:
1390
- _context.next = 4;
1391
- break;
1392
- case 10:
1393
- _context.next = 15;
1394
- break;
1395
- case 12:
1396
- _context.prev = 12;
1397
- _context.t0 = _context["catch"](2);
1398
- _iterator.e(_context.t0);
1399
- case 15:
1400
- _context.prev = 15;
1401
- _iterator.f();
1402
- return _context.finish(15);
1403
- case 18:
1404
- return _context.abrupt("return");
1405
- case 19:
1406
- case "end":
1407
- return _context.stop();
1408
1114
  }
1409
- }, _callee, null, [[2, 12, 15, 18]]);
1410
- }));
1411
- function loadJsSequentially(_x) {
1412
- return _loadJsSequentially.apply(this, arguments);
1115
+ };
1116
+ if (only_up === true && change > 0) {
1117
+ resolve();
1118
+ return;
1413
1119
  }
1414
- return loadJsSequentially;
1415
- }()
1416
- }, {
1417
- key: "triggerAfterAllImagesLoaded",
1418
- value: function triggerAfterAllImagesLoaded(selectorContainer, selectorImage, fn) {
1419
- var _this5 = this;
1420
- window.addEventListener('load', function (e) {
1421
- if (document.querySelector(selectorContainer + ' ' + selectorImage) !== null) {
1422
- document.querySelectorAll(selectorContainer + ' ' + selectorImage).forEach(function (el) {
1423
- _this5.triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn);
1424
- });
1425
- }
1426
- });
1427
- document.addEventListener('DOMContentLoaded', function () {
1428
- if (document.querySelector(selectorContainer) !== null) {
1429
- new MutationObserver(function (mutations) {
1430
- mutations.forEach(function (mutation) {
1431
- if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
1432
- mutation.addedNodes.forEach(function (el) {
1433
- _this5.triggerAfterAllImagesLoadedHandleEl(el, selectorContainer, selectorImage, fn);
1434
- });
1435
- } else if (mutation.type === 'attributes' && mutation.attributeName === 'src' && mutation.target.classList.contains(selectorImage.replace('.', '')) && mutation.oldValue !== mutation.target.getAttribute('src')) {
1436
- _this5.triggerAfterAllImagesLoadedHandleEl(mutation.target, selectorContainer, selectorImage, fn);
1437
- }
1438
- });
1439
- }).observe(document.querySelector(selectorContainer), {
1440
- attributes: true,
1441
- childList: true,
1442
- characterData: false,
1443
- subtree: true,
1444
- attributeOldValue: true,
1445
- characterDataOldValue: false
1446
- });
1447
- }
1448
- });
1120
+ animateScroll();
1121
+ });
1122
+ }
1123
+ static loadJs(urls) {
1124
+ if (!hlp.isArray(urls)) {
1125
+ urls = [urls];
1126
+ }
1127
+ let promises = [];
1128
+ hlp.loop(urls, (urls__value, urls__key) => {
1129
+ promises.push(new Promise((resolve, reject) => {
1130
+ let script = document.createElement('script');
1131
+ script.src = urls__value;
1132
+ script.onload = () => {
1133
+ resolve();
1134
+ };
1135
+ document.head.appendChild(script);
1136
+ }));
1137
+ });
1138
+ return Promise.all(promises);
1139
+ }
1140
+ static async loadJsSequentially(urls) {
1141
+ if (!hlp.isArray(urls)) {
1142
+ urls = [urls];
1143
+ }
1144
+ for (let urls__value of urls) {
1145
+ await hlp.loadJs(urls__value);
1449
1146
  }
1450
- }, {
1451
- key: "triggerAfterAllImagesLoadedHandleEl",
1452
- value: function triggerAfterAllImagesLoadedHandleEl(el, selectorContainer, selectorImage, fn) {
1453
- var _this6 = this;
1454
- if (el.nodeType === Node.ELEMENT_NODE) {
1455
- el.classList.remove('loaded-img');
1456
- el.closest(selectorContainer).classList.remove('loaded-all');
1457
- // only bind if not yet binded
1458
- if (!el.classList.contains('binded-trigger')) {
1459
- el.classList.add('binded-trigger');
1460
- el.addEventListener('load', function () {
1461
- _this6.triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn);
1147
+ return;
1148
+ }
1149
+ static triggerAfterAllImagesLoaded(selectorContainer, selectorImage, fn) {
1150
+ window.addEventListener('load', e => {
1151
+ if (document.querySelector(selectorContainer + ' ' + selectorImage) !== null) {
1152
+ document.querySelectorAll(selectorContainer + ' ' + selectorImage).forEach(el => {
1153
+ this.triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn);
1154
+ });
1155
+ }
1156
+ });
1157
+ document.addEventListener('DOMContentLoaded', () => {
1158
+ if (document.querySelector(selectorContainer) !== null) {
1159
+ new MutationObserver(mutations => {
1160
+ mutations.forEach(mutation => {
1161
+ if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
1162
+ mutation.addedNodes.forEach(el => {
1163
+ this.triggerAfterAllImagesLoadedHandleEl(el, selectorContainer, selectorImage, fn);
1164
+ });
1165
+ } else if (mutation.type === 'attributes' && mutation.attributeName === 'src' && mutation.target.classList.contains(selectorImage.replace('.', '')) && mutation.oldValue !== mutation.target.getAttribute('src')) {
1166
+ this.triggerAfterAllImagesLoadedHandleEl(mutation.target, selectorContainer, selectorImage, fn);
1167
+ }
1462
1168
  });
1463
- }
1169
+ }).observe(document.querySelector(selectorContainer), {
1170
+ attributes: true,
1171
+ childList: true,
1172
+ characterData: false,
1173
+ subtree: true,
1174
+ attributeOldValue: true,
1175
+ characterDataOldValue: false
1176
+ });
1464
1177
  }
1465
- }
1466
- }, {
1467
- key: "triggerAfterAllImagesLoadedBindLoadEvent",
1468
- value: function triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn) {
1469
- el.classList.add('loaded-img');
1470
- if (el.closest(selectorContainer).querySelectorAll('.loaded-img').length === el.closest(selectorContainer).querySelectorAll(selectorImage).length) {
1471
- el.closest(selectorContainer).classList.add('loaded-all');
1472
- fn();
1178
+ });
1179
+ }
1180
+ static triggerAfterAllImagesLoadedHandleEl(el, selectorContainer, selectorImage, fn) {
1181
+ if (el.nodeType === Node.ELEMENT_NODE) {
1182
+ el.classList.remove('loaded-img');
1183
+ el.closest(selectorContainer).classList.remove('loaded-all');
1184
+ // only bind if not yet binded
1185
+ if (!el.classList.contains('binded-trigger')) {
1186
+ el.classList.add('binded-trigger');
1187
+ el.addEventListener('load', () => {
1188
+ this.triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn);
1189
+ });
1473
1190
  }
1474
1191
  }
1475
- }, {
1476
- key: "isVisible",
1477
- value: function isVisible(el) {
1478
- return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
1192
+ }
1193
+ static triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn) {
1194
+ el.classList.add('loaded-img');
1195
+ if (el.closest(selectorContainer).querySelectorAll('.loaded-img').length === el.closest(selectorContainer).querySelectorAll(selectorImage).length) {
1196
+ el.closest(selectorContainer).classList.add('loaded-all');
1197
+ fn();
1198
+ }
1199
+ }
1200
+ static isVisible(el) {
1201
+ return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
1202
+ }
1203
+ static isVisibleInViewport(el) {
1204
+ if (!this.isVisible(el)) {
1205
+ return false;
1479
1206
  }
1480
- }, {
1481
- key: "isVisibleInViewport",
1482
- value: function isVisibleInViewport(el) {
1483
- if (!this.isVisible(el)) {
1484
- return false;
1485
- }
1486
- var rect = el.getBoundingClientRect();
1487
- return !(rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight);
1488
- }
1489
- }, {
1490
- key: "textareaAutoHeight",
1491
- value: function textareaAutoHeight() {
1492
- var _this7 = this;
1493
- var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'textarea';
1207
+ let rect = el.getBoundingClientRect();
1208
+ return !(rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight);
1209
+ }
1210
+ static textareaAutoHeight() {
1211
+ let selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'textarea';
1212
+ this.textareaSetHeights(selector);
1213
+ this.onResizeHorizontal(() => {
1494
1214
  this.textareaSetHeights(selector);
1495
- this.onResizeHorizontal(function () {
1496
- _this7.textareaSetHeights(selector);
1215
+ });
1216
+ [].forEach.call(document.querySelectorAll(selector), el => {
1217
+ el.addEventListener('keyup', e => {
1218
+ this.textareaSetHeight(e.target);
1497
1219
  });
1498
- [].forEach.call(document.querySelectorAll(selector), function (el) {
1499
- el.addEventListener('keyup', function (e) {
1500
- _this7.textareaSetHeight(e.target);
1501
- });
1220
+ });
1221
+ }
1222
+ static textareaSetHeights() {
1223
+ let selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'textarea';
1224
+ [].forEach.call(document.querySelectorAll(selector), el => {
1225
+ if (this.isVisible(el)) {
1226
+ this.textareaSetHeight(el);
1227
+ }
1228
+ });
1229
+ }
1230
+ static textareaSetHeight(el) {
1231
+ el.style.height = '5px';
1232
+ el.style.height = el.scrollHeight + 'px';
1233
+ }
1234
+ static real100vh() {
1235
+ let selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1236
+ let percent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
1237
+ if (selector === null) {
1238
+ // apply trick from https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
1239
+ let fn = () => {
1240
+ let vh = window.innerHeight * 0.01;
1241
+ document.documentElement.style.setProperty('--vh', "".concat(vh, "px"));
1242
+ };
1243
+ fn();
1244
+ window.addEventListener('resize', () => {
1245
+ fn();
1502
1246
  });
1503
- }
1504
- }, {
1505
- key: "textareaSetHeights",
1506
- value: function textareaSetHeights() {
1507
- var _this8 = this;
1508
- var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'textarea';
1509
- [].forEach.call(document.querySelectorAll(selector), function (el) {
1510
- if (_this8.isVisible(el)) {
1511
- _this8.textareaSetHeight(el);
1247
+ } else {
1248
+ let fn = () => {
1249
+ console.log(selector);
1250
+ if (document.querySelector(selector) !== null) {
1251
+ document.querySelectorAll(selector).forEach(selector__value => {
1252
+ selector__value.style.height = window.innerHeight * (percent / 100) + 'px';
1253
+ });
1512
1254
  }
1255
+ };
1256
+ fn();
1257
+ window.addEventListener('resize', () => {
1258
+ fn();
1513
1259
  });
1514
1260
  }
1515
- }, {
1516
- key: "textareaSetHeight",
1517
- value: function textareaSetHeight(el) {
1518
- el.style.height = '5px';
1519
- el.style.height = el.scrollHeight + 'px';
1520
- }
1521
- }, {
1522
- key: "real100vh",
1523
- value: function real100vh() {
1524
- var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1525
- var percent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
1526
- if (selector === null) {
1527
- // apply trick from https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
1528
- var fn = function fn() {
1529
- var vh = window.innerHeight * 0.01;
1530
- document.documentElement.style.setProperty('--vh', "".concat(vh, "px"));
1531
- };
1532
- fn();
1533
- window.addEventListener('resize', function () {
1534
- fn();
1535
- });
1261
+ }
1262
+ static iOsRemoveHover() {
1263
+ if (hlp.getBrowser() === 'safari' && hlp.getDevice() !== 'desktop') {
1264
+ hlp.on('touchend', 'a', (e, el) => {
1265
+ el.click();
1266
+ });
1267
+ }
1268
+ }
1269
+ static isNumeric(n) {
1270
+ return !isNaN(parseFloat(n)) && isFinite(n);
1271
+ }
1272
+ static animate(el, from, to, easing, duration) {
1273
+ return new Promise(resolve => {
1274
+ // on durations smaller than 50, the end event does not trigger!
1275
+ if (duration <= 50) {
1276
+ duration = 50;
1277
+ }
1278
+ let properties = [];
1279
+ from.split(';').forEach(from__value => {
1280
+ properties.push(from__value.split(':')[0].trim());
1281
+ });
1282
+ let transition = [];
1283
+ properties.forEach(properties__value => {
1284
+ transition.push(properties__value + ' ' + Math.round(duration / 1000 * 10) / 10 + 's ' + easing);
1285
+ });
1286
+ transition = 'transition: ' + transition.join(', ') + ' !important;';
1287
+ let els = null;
1288
+ if (NodeList.prototype.isPrototypeOf(el)) {
1289
+ els = Array.from(el);
1290
+ } else if (el === null) {
1291
+ console.log('cannot animate element from ' + from + ' to ' + to + ' because it does not exist');
1292
+ resolve();
1536
1293
  } else {
1537
- var _fn = function _fn() {
1538
- console.log(selector);
1539
- if (document.querySelector(selector) !== null) {
1540
- document.querySelectorAll(selector).forEach(function (selector__value) {
1541
- selector__value.style.height = window.innerHeight * (percent / 100) + 'px';
1294
+ els = [el];
1295
+ }
1296
+ let toFinish = els.length;
1297
+ els.forEach((els__value, els__key) => {
1298
+ // add random class
1299
+ let random_class = hlp.random_string(10, 'abcdefghijklmnopqrstuvwxyz');
1300
+ els__value.classList.add(random_class);
1301
+ window.requestAnimationFrame(() => {
1302
+ // set from style inline (don't fully remove previous style)
1303
+ let new_style = [];
1304
+ let prev_style = els__value.getAttribute('style');
1305
+ if (prev_style !== null) {
1306
+ prev_style.split(';').forEach(prev_style__value => {
1307
+ if (!properties.includes(prev_style__value.split(':')[0].trim())) {
1308
+ new_style.push(prev_style__value);
1309
+ }
1542
1310
  });
1543
1311
  }
1544
- };
1545
- _fn();
1546
- window.addEventListener('resize', function () {
1547
- _fn();
1548
- });
1549
- }
1550
- }
1551
- }, {
1552
- key: "iOsRemoveHover",
1553
- value: function iOsRemoveHover() {
1554
- if (hlp.getBrowser() === 'safari' && hlp.getDevice() !== 'desktop') {
1555
- hlp.on('touchend', 'a', function (e, el) {
1556
- el.click();
1557
- });
1558
- }
1559
- }
1560
- }, {
1561
- key: "isNumeric",
1562
- value: function isNumeric(n) {
1563
- return !isNaN(parseFloat(n)) && isFinite(n);
1564
- }
1565
- }, {
1566
- key: "animate",
1567
- value: function animate(el, from, to, easing, duration) {
1568
- var _this9 = this;
1569
- return new Promise(function (resolve) {
1570
- // on durations smaller than 50, the end event does not trigger!
1571
- if (duration <= 50) {
1572
- duration = 50;
1573
- }
1574
- var properties = [];
1575
- from.split(';').forEach(function (from__value) {
1576
- properties.push(from__value.split(':')[0].trim());
1577
- });
1578
- var transition = [];
1579
- properties.forEach(function (properties__value) {
1580
- transition.push(properties__value + ' ' + Math.round(duration / 1000 * 10) / 10 + 's ' + easing);
1581
- });
1582
- transition = 'transition: ' + transition.join(', ') + ' !important;';
1583
- var els = null;
1584
- if (NodeList.prototype.isPrototypeOf(el)) {
1585
- els = Array.from(el);
1586
- } else if (el === null) {
1587
- console.log('cannot animate element from ' + from + ' to ' + to + ' because it does not exist');
1588
- resolve();
1589
- } else {
1590
- els = [el];
1591
- }
1592
- var toFinish = els.length;
1593
- els.forEach(function (els__value, els__key) {
1594
- // add random class
1595
- var random_class = hlp.random_string(10, 'abcdefghijklmnopqrstuvwxyz');
1596
- els__value.classList.add(random_class);
1597
- window.requestAnimationFrame(function () {
1598
- // set from style inline (don't fully remove previous style)
1599
- var new_style = [];
1600
- var prev_style = els__value.getAttribute('style');
1601
- if (prev_style !== null) {
1602
- prev_style.split(';').forEach(function (prev_style__value) {
1603
- if (!properties.includes(prev_style__value.split(':')[0].trim())) {
1604
- new_style.push(prev_style__value);
1605
- }
1606
- });
1607
- }
1608
- new_style = new_style.join(';') + from + ';';
1609
- els__value.setAttribute('style', new_style);
1610
- window.requestAnimationFrame(function () {
1611
- // add transition property
1612
- var style = document.createElement('style');
1613
- style.innerHTML = '.' + random_class + ' { ' + transition + ' }';
1614
- document.head.appendChild(style);
1615
- window.requestAnimationFrame(function () {
1616
- // set last style inline
1617
- els__value.setAttribute('style', els__value.getAttribute('style').replace(from + ';', '') + to + ';');
1618
- if (_this9.isVisible(els__value)) {
1619
- var fired = false;
1620
- hlp.addEventListenerOnce(els__value, 'transitionend', function (event) {
1621
- fired = true;
1312
+ new_style = new_style.join(';') + from + ';';
1313
+ els__value.setAttribute('style', new_style);
1314
+ window.requestAnimationFrame(() => {
1315
+ // add transition property
1316
+ let style = document.createElement('style');
1317
+ style.innerHTML = '.' + random_class + ' { ' + transition + ' }';
1318
+ document.head.appendChild(style);
1319
+ window.requestAnimationFrame(() => {
1320
+ // set last style inline
1321
+ els__value.setAttribute('style', els__value.getAttribute('style').replace(from + ';', '') + to + ';');
1322
+ if (this.isVisible(els__value)) {
1323
+ let fired = false;
1324
+ hlp.addEventListenerOnce(els__value, 'transitionend', event => {
1325
+ fired = true;
1622
1326
 
1623
- // transitionend fires also, when animating child elements
1624
- // the following line ensures, that those events do not bubble up
1625
- // in that case, we return false and ensure, the event listener is still alive
1626
- if (event.target !== event.currentTarget) {
1627
- return false;
1628
- }
1327
+ // transitionend fires also, when animating child elements
1328
+ // the following line ensures, that those events do not bubble up
1329
+ // in that case, we return false and ensure, the event listener is still alive
1330
+ if (event.target !== event.currentTarget) {
1331
+ return false;
1332
+ }
1629
1333
 
1630
- // remove previous styles property
1631
- document.head.removeChild(style);
1334
+ // remove previous styles property
1335
+ document.head.removeChild(style);
1632
1336
 
1633
- // remove random class
1634
- els__value.classList.remove(random_class);
1337
+ // remove random class
1338
+ els__value.classList.remove(random_class);
1339
+
1340
+ // resolve promise when last is finished
1341
+ toFinish--;
1342
+ if (toFinish <= 0) {
1343
+ window.requestAnimationFrame(() => {
1344
+ resolve();
1345
+ });
1346
+ }
1347
+ });
1635
1348
 
1636
- // resolve promise when last is finished
1349
+ // safeguard
1350
+ // in some edge cases, transitionend does not fire
1351
+ setTimeout(() => {
1352
+ if (fired === false) {
1353
+ document.head.removeChild(style);
1354
+ els__value.classList.remove(random_class);
1637
1355
  toFinish--;
1638
1356
  if (toFinish <= 0) {
1639
- window.requestAnimationFrame(function () {
1640
- resolve();
1641
- });
1642
- }
1643
- });
1644
-
1645
- // safeguard
1646
- // in some edge cases, transitionend does not fire
1647
- setTimeout(function () {
1648
- if (fired === false) {
1649
- document.head.removeChild(style);
1650
- els__value.classList.remove(random_class);
1651
- toFinish--;
1652
- if (toFinish <= 0) {
1653
- resolve();
1654
- }
1357
+ resolve();
1655
1358
  }
1656
- }, duration * 1.5);
1657
- } else {
1658
- document.head.removeChild(style);
1659
- els__value.classList.remove(random_class);
1660
- toFinish--;
1661
- if (toFinish <= 0) {
1662
- resolve();
1663
1359
  }
1360
+ }, duration * 1.5);
1361
+ } else {
1362
+ document.head.removeChild(style);
1363
+ els__value.classList.remove(random_class);
1364
+ toFinish--;
1365
+ if (toFinish <= 0) {
1366
+ resolve();
1664
1367
  }
1665
- });
1368
+ }
1666
1369
  });
1667
1370
  });
1668
1371
  });
1669
1372
  });
1670
- }
1671
- }, {
1672
- key: "addEventListenerOnce",
1673
- value: function addEventListenerOnce(target, type, listener, addOptions, removeOptions) {
1674
- target.addEventListener(type, function fn(event) {
1675
- var result = listener.apply(this, arguments, addOptions);
1676
- if (result !== false) {
1677
- target.removeEventListener(type, fn, removeOptions);
1678
- }
1679
- });
1680
- }
1681
- }, {
1682
- key: "htmlDecode",
1683
- value: function htmlDecode(value) {
1684
- var tmp = document.createElement('textarea');
1685
- tmp.innerHTML = value;
1686
- return tmp.value;
1687
- }
1688
- }, {
1689
- key: "htmlEncode",
1690
- value: function htmlEncode(value) {
1691
- return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/`/g, '&#96;');
1692
- }
1693
- }, {
1694
- key: "nl2br",
1695
- value: function nl2br(str) {
1696
- if (typeof str === 'undefined' || str === null) {
1697
- return '';
1698
- }
1699
- var breakTag = '<br/>',
1700
- replaceStr = '$1' + breakTag;
1701
- return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, replaceStr);
1702
- }
1703
- }, {
1704
- key: "br2nl",
1705
- value: function br2nl(str) {
1706
- if (typeof str === 'undefined' || str === null) {
1707
- return '';
1373
+ });
1374
+ }
1375
+ static addEventListenerOnce(target, type, listener, addOptions, removeOptions) {
1376
+ target.addEventListener(type, function fn(event) {
1377
+ let result = listener.apply(this, arguments, addOptions);
1378
+ if (result !== false) {
1379
+ target.removeEventListener(type, fn, removeOptions);
1708
1380
  }
1709
- var replaceStr = '\n';
1710
- return str.replace(/<\s*\/?br\s*[\/]?>/gi, replaceStr);
1381
+ });
1382
+ }
1383
+ static htmlDecode(value) {
1384
+ let tmp = document.createElement('textarea');
1385
+ tmp.innerHTML = value;
1386
+ return tmp.value;
1387
+ }
1388
+ static htmlEncode(value) {
1389
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/`/g, '&#96;');
1390
+ }
1391
+ static nl2br(str) {
1392
+ if (typeof str === 'undefined' || str === null) {
1393
+ return '';
1711
1394
  }
1712
- }, {
1713
- key: "closest",
1714
- value: function closest(el, selector) {
1715
- if (!document.documentElement.contains(el)) {
1716
- return null;
1717
- }
1718
- do {
1719
- if (this.matches(el, selector)) {
1720
- return el;
1721
- }
1722
- el = el.parentElement || el.parentNode;
1723
- } while (el !== null && el.nodeType === 1);
1395
+ let breakTag = '<br/>',
1396
+ replaceStr = '$1' + breakTag;
1397
+ return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, replaceStr);
1398
+ }
1399
+ static br2nl(str) {
1400
+ if (typeof str === 'undefined' || str === null) {
1401
+ return '';
1402
+ }
1403
+ let replaceStr = '\n';
1404
+ return str.replace(/<\s*\/?br\s*[\/]?>/gi, replaceStr);
1405
+ }
1406
+ static closest(el, selector) {
1407
+ if (!document.documentElement.contains(el)) {
1724
1408
  return null;
1725
1409
  }
1726
- }, {
1727
- key: "matches",
1728
- value: function matches(el, selector) {
1729
- var node = el,
1730
- nodes = (node.parentNode || node.document).querySelectorAll(selector),
1731
- i = -1;
1732
- while (nodes[++i] && nodes[i] != node);
1733
- return !!nodes[i];
1734
- }
1735
- }, {
1736
- key: "wrap",
1737
- value: function wrap(el, html) {
1738
- if (el === null) {
1739
- return;
1740
- }
1741
- var wrapper = new DOMParser().parseFromString(html, 'text/html').body.childNodes[0];
1742
- el.parentNode.insertBefore(wrapper, el.nextSibling);
1743
- wrapper.appendChild(el);
1744
- }
1745
- }, {
1746
- key: "wrapTextNodes",
1747
- value: function wrapTextNodes(el, tag) {
1748
- if (el === null) {
1749
- return;
1410
+ do {
1411
+ if (this.matches(el, selector)) {
1412
+ return el;
1750
1413
  }
1751
- Array.from(el.childNodes).filter(function (node) {
1752
- return node.nodeType === 3 && node.textContent.trim().length > 1;
1753
- }).forEach(function (node) {
1754
- var wrapper = document.createElement(tag);
1755
- node.after(wrapper);
1756
- wrapper.appendChild(node);
1757
- });
1414
+ el = el.parentElement || el.parentNode;
1415
+ } while (el !== null && el.nodeType === 1);
1416
+ return null;
1417
+ }
1418
+ static matches(el, selector) {
1419
+ let node = el,
1420
+ nodes = (node.parentNode || node.document).querySelectorAll(selector),
1421
+ i = -1;
1422
+ while (nodes[++i] && nodes[i] != node);
1423
+ return !!nodes[i];
1424
+ }
1425
+ static wrap(el, html) {
1426
+ if (el === null) {
1427
+ return;
1758
1428
  }
1759
- }, {
1760
- key: "html2dom",
1761
- value: function html2dom(html) {
1762
- var template = document.createElement('template');
1763
- html = html.trim();
1764
- template.innerHTML = html;
1765
- if (template.content === undefined) {
1766
- return this.html2domLegacy(html);
1767
- }
1768
- return template.content.firstChild;
1769
- }
1770
- }, {
1771
- key: "html2domLegacy",
1772
- value: function html2domLegacy(html) {
1773
- /* source: https://gist.github.com/Munawwar/6e6362dbdf77c7865a99 */
1774
- var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
1775
- rtagName = /<([\w:]+)/,
1776
- rhtml = /<|&#?\w+;/,
1777
- wrapMap = {
1778
- option: [1, "<select multiple='multiple'>", '</select>'],
1779
- thead: [1, '<table>', '</table>'],
1780
- col: [2, '<table><colgroup>', '</colgroup></table>'],
1781
- tr: [2, '<table><tbody>', '</tbody></table>'],
1782
- td: [3, '<table><tbody><tr>', '</tr></tbody></table>'],
1783
- _default: [0, '', '']
1784
- },
1785
- context = document;
1786
- var tmp,
1787
- tag,
1788
- wrap,
1789
- j,
1790
- fragment = context.createDocumentFragment();
1791
- if (!rhtml.test(html)) {
1792
- fragment.appendChild(context.createTextNode(html));
1793
- } else {
1794
- tmp = fragment.appendChild(context.createElement('div'));
1795
- tag = (rtagName.exec(html) || ['', ''])[1].toLowerCase();
1796
- wrap = wrapMap[tag] || wrapMap._default;
1797
- tmp.innerHTML = wrap[1] + html.replace(rxhtmlTag, '<$1></$2>') + wrap[2];
1798
- j = wrap[0];
1799
- while (j--) {
1800
- tmp = tmp.lastChild;
1801
- }
1802
- fragment.removeChild(fragment.firstChild);
1803
- while (tmp.firstChild) {
1804
- fragment.appendChild(tmp.firstChild);
1805
- }
1806
- }
1807
- return fragment.querySelector('*');
1429
+ let wrapper = new DOMParser().parseFromString(html, 'text/html').body.childNodes[0];
1430
+ el.parentNode.insertBefore(wrapper, el.nextSibling);
1431
+ wrapper.appendChild(el);
1432
+ }
1433
+ static wrapTextNodes(el, tag) {
1434
+ if (el === null) {
1435
+ return;
1808
1436
  }
1809
- }, {
1810
- key: "prev",
1811
- value: function prev(elem, filter) {
1812
- var prev = elem.previousElementSibling;
1813
- if (prev === null) {
1814
- return null;
1815
- }
1816
- if (filter === undefined || this.matches(prev, filter)) {
1817
- return prev;
1818
- }
1437
+ Array.from(el.childNodes).filter(node => node.nodeType === 3 && node.textContent.trim().length > 1).forEach(node => {
1438
+ const wrapper = document.createElement(tag);
1439
+ node.after(wrapper);
1440
+ wrapper.appendChild(node);
1441
+ });
1442
+ }
1443
+ static html2dom(html) {
1444
+ let template = document.createElement('template');
1445
+ html = html.trim();
1446
+ template.innerHTML = html;
1447
+ if (template.content === undefined) {
1448
+ return this.html2domLegacy(html);
1449
+ }
1450
+ return template.content.firstChild;
1451
+ }
1452
+ static html2domLegacy(html) {
1453
+ /* source: https://gist.github.com/Munawwar/6e6362dbdf77c7865a99 */
1454
+ var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
1455
+ rtagName = /<([\w:]+)/,
1456
+ rhtml = /<|&#?\w+;/,
1457
+ wrapMap = {
1458
+ option: [1, "<select multiple='multiple'>", '</select>'],
1459
+ thead: [1, '<table>', '</table>'],
1460
+ col: [2, '<table><colgroup>', '</colgroup></table>'],
1461
+ tr: [2, '<table><tbody>', '</tbody></table>'],
1462
+ td: [3, '<table><tbody><tr>', '</tr></tbody></table>'],
1463
+ _default: [0, '', '']
1464
+ },
1465
+ context = document;
1466
+ var tmp,
1467
+ tag,
1468
+ wrap,
1469
+ j,
1470
+ fragment = context.createDocumentFragment();
1471
+ if (!rhtml.test(html)) {
1472
+ fragment.appendChild(context.createTextNode(html));
1473
+ } else {
1474
+ tmp = fragment.appendChild(context.createElement('div'));
1475
+ tag = (rtagName.exec(html) || ['', ''])[1].toLowerCase();
1476
+ wrap = wrapMap[tag] || wrapMap._default;
1477
+ tmp.innerHTML = wrap[1] + html.replace(rxhtmlTag, '<$1></$2>') + wrap[2];
1478
+ j = wrap[0];
1479
+ while (j--) {
1480
+ tmp = tmp.lastChild;
1481
+ }
1482
+ fragment.removeChild(fragment.firstChild);
1483
+ while (tmp.firstChild) {
1484
+ fragment.appendChild(tmp.firstChild);
1485
+ }
1486
+ }
1487
+ return fragment.querySelector('*');
1488
+ }
1489
+ static prev(elem, filter) {
1490
+ let prev = elem.previousElementSibling;
1491
+ if (prev === null) {
1819
1492
  return null;
1820
1493
  }
1821
- }, {
1822
- key: "next",
1823
- value: function next(elem, filter) {
1824
- var next = elem.nextElementSibling;
1825
- if (next === null) {
1826
- return null;
1827
- }
1828
- if (filter === undefined || this.matches(next, filter)) {
1829
- return next;
1830
- }
1831
- return null;
1494
+ if (filter === undefined || this.matches(prev, filter)) {
1495
+ return prev;
1832
1496
  }
1833
- }, {
1834
- key: "prevAll",
1835
- value: function prevAll(elem, filter) {
1836
- var sibs = [];
1837
- while (elem = elem.previousElementSibling) {
1838
- if (filter === undefined || this.matches(elem, filter)) {
1839
- sibs.push(elem);
1840
- }
1841
- }
1842
- return sibs;
1843
- }
1844
- }, {
1845
- key: "nextAll",
1846
- value: function nextAll(elem, filter) {
1847
- var sibs = [];
1848
- while (elem = elem.nextElementSibling) {
1849
- if (filter === undefined || this.matches(elem, filter)) {
1850
- sibs.push(elem);
1851
- }
1852
- }
1853
- return sibs;
1854
- }
1855
- }, {
1856
- key: "prevUntil",
1857
- value: function prevUntil(elem, filter) {
1858
- var sibs = [];
1859
- while (elem = elem.previousElementSibling) {
1860
- if (!this.matches(elem, filter)) {
1861
- sibs.push(elem);
1862
- } else {
1863
- break;
1864
- }
1865
- }
1866
- return sibs;
1867
- }
1868
- }, {
1869
- key: "nextUntil",
1870
- value: function nextUntil(elem, filter) {
1871
- var sibs = [];
1872
- while (elem = elem.nextElementSibling) {
1873
- if (!this.matches(elem, filter)) {
1874
- sibs.push(elem);
1875
- } else {
1876
- break;
1877
- }
1878
- }
1879
- return sibs;
1880
- }
1881
- }, {
1882
- key: "siblings",
1883
- value: function siblings(elem, filter) {
1884
- var sibs = [];
1885
- var self = elem;
1886
- elem = elem.parentNode.firstChild;
1887
- while (elem = elem.nextElementSibling) {
1888
- if (filter === undefined || this.matches(elem, filter)) {
1889
- if (self !== elem) {
1890
- sibs.push(elem);
1891
- }
1892
- }
1893
- }
1894
- return sibs;
1895
- }
1896
- }, {
1897
- key: "parents",
1898
- value: function parents(elem, selector) {
1899
- var elements = [];
1900
- var ishaveselector = selector !== undefined;
1901
- while ((elem = elem.parentElement) !== null) {
1902
- if (elem.nodeType !== Node.ELEMENT_NODE) {
1903
- continue;
1904
- }
1905
- if (!ishaveselector || this.matches(elem, selector)) {
1906
- elements.push(elem);
1907
- }
1908
- }
1909
- return elements;
1910
- }
1911
- }, {
1912
- key: "css",
1913
- value: function css(el) {
1914
- var sheets = document.styleSheets,
1915
- o = {};
1916
- for (var sheets__key in sheets) {
1917
- try {
1918
- var rules = sheets[sheets__key].rules || sheets[sheets__key].cssRules;
1919
- for (var rules__key in rules) {
1920
- if (this.matches(el, rules[rules__key].selectorText)) {
1921
- o = Object.assign(o, this.css2json(rules[rules__key].style), this.css2json(el.getAttribute('style')));
1922
- }
1923
- }
1924
- } catch (e) {}
1925
- }
1926
- return o;
1927
- }
1928
- }, {
1929
- key: "css2json",
1930
- value: function css2json(css) {
1931
- var obj = {};
1932
- if (!css) {
1933
- return obj;
1934
- }
1935
- if (css instanceof CSSStyleDeclaration) {
1936
- for (var css__key in css) {
1937
- if (css[css__key].toLowerCase && css[css[css__key]] !== undefined) {
1938
- obj[css[css__key].toLowerCase()] = css[css[css__key]];
1939
- }
1940
- }
1941
- } else if (typeof css == 'string') {
1942
- css = css.split(';');
1943
- for (var _css__key in css) {
1944
- if (css[_css__key].indexOf(':') > -1) {
1945
- var val = css[_css__key].split(':');
1946
- obj[val[0].toLowerCase().trim()] = val[1].trim();
1947
- }
1948
- }
1949
- }
1950
- return obj;
1497
+ return null;
1498
+ }
1499
+ static next(elem, filter) {
1500
+ let next = elem.nextElementSibling;
1501
+ if (next === null) {
1502
+ return null;
1951
1503
  }
1952
- }, {
1953
- key: "compareDates",
1954
- value: function compareDates(d1, d2) {
1955
- // safari has problems in parsing "2019-01-01 00:00:00"
1956
- if (typeof d1 === 'string') {
1957
- d1 = d1.split(' ').join('T');
1958
- }
1959
- if (typeof d2 === 'string') {
1960
- d2 = d2.split(' ').join('T');
1961
- }
1962
- d1 = new Date(d1);
1963
- d2 = new Date(d2);
1964
- d1.setHours(0);
1965
- d1.setMinutes(0);
1966
- d1.setSeconds(0);
1967
- d1.setMilliseconds(0);
1968
- d2.setHours(0);
1969
- d2.setMinutes(0);
1970
- d2.setSeconds(0);
1971
- d2.setMilliseconds(0);
1972
- if (d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate()) {
1973
- return 0;
1974
- }
1975
- if (d1 < d2) {
1976
- return -1;
1504
+ if (filter === undefined || this.matches(next, filter)) {
1505
+ return next;
1506
+ }
1507
+ return null;
1508
+ }
1509
+ static prevAll(elem, filter) {
1510
+ let sibs = [];
1511
+ while (elem = elem.previousElementSibling) {
1512
+ if (filter === undefined || this.matches(elem, filter)) {
1513
+ sibs.push(elem);
1977
1514
  }
1978
- return 1;
1979
1515
  }
1980
- }, {
1981
- key: "spaceship",
1982
- value: function spaceship(val1, val2) {
1983
- if (val1 === null || val2 === null || (0, _typeof2.default)(val1) != (0, _typeof2.default)(val2)) {
1984
- return null;
1516
+ return sibs;
1517
+ }
1518
+ static nextAll(elem, filter) {
1519
+ let sibs = [];
1520
+ while (elem = elem.nextElementSibling) {
1521
+ if (filter === undefined || this.matches(elem, filter)) {
1522
+ sibs.push(elem);
1985
1523
  }
1986
- if (typeof val1 === 'string') {
1987
- return val1.localeCompare(val2);
1524
+ }
1525
+ return sibs;
1526
+ }
1527
+ static prevUntil(elem, filter) {
1528
+ let sibs = [];
1529
+ while (elem = elem.previousElementSibling) {
1530
+ if (!this.matches(elem, filter)) {
1531
+ sibs.push(elem);
1988
1532
  } else {
1989
- if (val1 > val2) {
1990
- return 1;
1991
- } else if (val1 < val2) {
1992
- return -1;
1993
- }
1994
- return 0;
1533
+ break;
1995
1534
  }
1996
1535
  }
1997
- }, {
1998
- key: "focus",
1999
- value: function focus(selector) {
2000
- hlp.unfocus();
2001
- var el = null;
2002
- if (typeof selector === 'string' || selector instanceof String) {
2003
- el = document.querySelector(selector);
1536
+ return sibs;
1537
+ }
1538
+ static nextUntil(elem, filter) {
1539
+ let sibs = [];
1540
+ while (elem = elem.nextElementSibling) {
1541
+ if (!this.matches(elem, filter)) {
1542
+ sibs.push(elem);
2004
1543
  } else {
2005
- el = selector;
1544
+ break;
2006
1545
  }
2007
- if (el !== null) {
2008
- var mask = document.createElement('div');
2009
- mask.classList.add('hlp-focus-mask');
2010
- mask.style.position = 'fixed';
2011
- mask.style.top = 0;
2012
- mask.style.bottom = 0;
2013
- mask.style.left = 0;
2014
- mask.style.right = 0;
2015
- mask.style.backgroundColor = 'rgba(0,0,0,0.8)';
2016
- mask.style.zIndex = 2147483646;
2017
- el.before(mask);
2018
- el.setAttribute('data-focussed', 1);
2019
- el.setAttribute('data-focussed-orig-z-index', el.style.zIndex);
2020
- el.setAttribute('data-focussed-orig-position', el.style.position);
2021
- el.setAttribute('data-focussed-orig-background-color', el.style.backgroundColor);
2022
- el.setAttribute('data-focussed-orig-box-shadow', el.style.boxShadow);
2023
- el.style.zIndex = 2147483647;
2024
- el.style.position = 'relative';
2025
- el.style.backgroundColor = '#ffffff';
2026
- el.style.boxShadow = '0px 0px 0px 20px #fff';
1546
+ }
1547
+ return sibs;
1548
+ }
1549
+ static siblings(elem, filter) {
1550
+ let sibs = [];
1551
+ let self = elem;
1552
+ elem = elem.parentNode.firstChild;
1553
+ while (elem = elem.nextElementSibling) {
1554
+ if (filter === undefined || this.matches(elem, filter)) {
1555
+ if (self !== elem) {
1556
+ sibs.push(elem);
1557
+ }
2027
1558
  }
2028
1559
  }
2029
- }, {
2030
- key: "unfocus",
2031
- value: function unfocus() {
2032
- if (document.querySelector('.hlp-focus-mask') !== null) {
2033
- document.querySelectorAll('.hlp-focus-mask').forEach(function (el) {
2034
- hlp.remove(el);
2035
- });
1560
+ return sibs;
1561
+ }
1562
+ static parents(elem, selector) {
1563
+ let elements = [];
1564
+ let ishaveselector = selector !== undefined;
1565
+ while ((elem = elem.parentElement) !== null) {
1566
+ if (elem.nodeType !== Node.ELEMENT_NODE) {
1567
+ continue;
2036
1568
  }
2037
- if (document.querySelector('[data-focussed]') !== null) {
2038
- document.querySelectorAll('[data-focussed]').forEach(function (el) {
2039
- el.style.zIndex = el.getAttribute('data-focussed-orig-z-index');
2040
- el.style.position = el.getAttribute('data-focussed-orig-position');
2041
- el.style.backgroundColor = el.getAttribute('data-focussed-orig-background-color');
2042
- el.style.boxShadow = el.getAttribute('data-focussed-orig-box-shadow');
2043
- el.removeAttribute('data-focussed');
2044
- el.removeAttribute('data-focussed-orig-z-index');
2045
- el.removeAttribute('data-focussed-orig-position');
2046
- el.removeAttribute('data-focussed-orig-background-color');
2047
- el.removeAttribute('data-focussed-orig-box-shadow');
2048
- });
1569
+ if (!ishaveselector || this.matches(elem, selector)) {
1570
+ elements.push(elem);
2049
1571
  }
2050
1572
  }
2051
- }, {
2052
- key: "remove",
2053
- value: function remove(el) {
2054
- if (el !== null) {
2055
- el.parentNode.removeChild(el);
2056
- }
1573
+ return elements;
1574
+ }
1575
+ static css(el) {
1576
+ let sheets = document.styleSheets,
1577
+ o = {};
1578
+ for (let sheets__key in sheets) {
1579
+ try {
1580
+ let rules = sheets[sheets__key].rules || sheets[sheets__key].cssRules;
1581
+ for (let rules__key in rules) {
1582
+ if (this.matches(el, rules[rules__key].selectorText)) {
1583
+ o = Object.assign(o, this.css2json(rules[rules__key].style), this.css2json(el.getAttribute('style')));
1584
+ }
1585
+ }
1586
+ } catch (e) {}
2057
1587
  }
2058
- }, {
2059
- key: "on",
2060
- value: function on(event, selector, scope) {
2061
- var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
2062
- if (callback === null) {
2063
- callback = scope;
2064
- scope = document;
2065
- } else {
2066
- scope = document.querySelector(scope);
1588
+ return o;
1589
+ }
1590
+ static css2json(css) {
1591
+ let obj = {};
1592
+ if (!css) {
1593
+ return obj;
1594
+ }
1595
+ if (css instanceof CSSStyleDeclaration) {
1596
+ for (let css__key in css) {
1597
+ if (css[css__key].toLowerCase && css[css[css__key]] !== undefined) {
1598
+ obj[css[css__key].toLowerCase()] = css[css[css__key]];
1599
+ }
2067
1600
  }
2068
- scope.addEventListener(event, function (e) {
2069
- var el = hlp.closest(e.target, selector);
2070
- if (el) {
2071
- callback(e, el);
1601
+ } else if (typeof css == 'string') {
1602
+ css = css.split(';');
1603
+ for (let css__key in css) {
1604
+ if (css[css__key].indexOf(':') > -1) {
1605
+ let val = css[css__key].split(':');
1606
+ obj[val[0].toLowerCase().trim()] = val[1].trim();
2072
1607
  }
2073
- }, false);
2074
- }
2075
- }, {
2076
- key: "url",
2077
- value: function url() {
2078
- return window.location.protocol + '//' + window.location.host + window.location.pathname;
2079
- }
2080
- }, {
2081
- key: "urlWithHash",
2082
- value: function urlWithHash() {
2083
- return window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.hash;
2084
- }
2085
- }, {
2086
- key: "fullUrl",
2087
- value: function fullUrl() {
2088
- return window.location.href;
2089
- }
2090
- }, {
2091
- key: "urlWithArgs",
2092
- value: function urlWithArgs() {
2093
- return window.location.href.split('#')[0];
2094
- }
2095
- }, {
2096
- key: "baseUrl",
2097
- value: function baseUrl() {
2098
- return window.location.protocol + '//' + window.location.host;
2099
- }
2100
- }, {
2101
- key: "urlProtocol",
2102
- value: function urlProtocol() {
2103
- return window.location.protocol + '//';
2104
- }
2105
- }, {
2106
- key: "urlHost",
2107
- value: function urlHost() {
2108
- return window.location.host;
2109
- }
2110
- }, {
2111
- key: "urlHostTopLevel",
2112
- value: function urlHostTopLevel() {
2113
- var host = window.location.host;
2114
- // ipv4
2115
- if (host.match(/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)) {
2116
- return host;
2117
1608
  }
2118
- host = host.split('.');
2119
- while (host.length > 2) {
2120
- host.shift();
1609
+ }
1610
+ return obj;
1611
+ }
1612
+ static compareDates(d1, d2) {
1613
+ // safari has problems in parsing "2019-01-01 00:00:00"
1614
+ if (typeof d1 === 'string') {
1615
+ d1 = d1.split(' ').join('T');
1616
+ }
1617
+ if (typeof d2 === 'string') {
1618
+ d2 = d2.split(' ').join('T');
1619
+ }
1620
+ d1 = new Date(d1);
1621
+ d2 = new Date(d2);
1622
+ d1.setHours(0);
1623
+ d1.setMinutes(0);
1624
+ d1.setSeconds(0);
1625
+ d1.setMilliseconds(0);
1626
+ d2.setHours(0);
1627
+ d2.setMinutes(0);
1628
+ d2.setSeconds(0);
1629
+ d2.setMilliseconds(0);
1630
+ if (d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate()) {
1631
+ return 0;
1632
+ }
1633
+ if (d1 < d2) {
1634
+ return -1;
1635
+ }
1636
+ return 1;
1637
+ }
1638
+ static spaceship(val1, val2) {
1639
+ if (val1 === null || val2 === null || typeof val1 != typeof val2) {
1640
+ return null;
1641
+ }
1642
+ if (typeof val1 === 'string') {
1643
+ return val1.localeCompare(val2);
1644
+ } else {
1645
+ if (val1 > val2) {
1646
+ return 1;
1647
+ } else if (val1 < val2) {
1648
+ return -1;
2121
1649
  }
2122
- host = host.join('.');
1650
+ return 0;
1651
+ }
1652
+ }
1653
+ static focus(selector) {
1654
+ hlp.unfocus();
1655
+ let el = null;
1656
+ if (typeof selector === 'string' || selector instanceof String) {
1657
+ el = document.querySelector(selector);
1658
+ } else {
1659
+ el = selector;
1660
+ }
1661
+ if (el !== null) {
1662
+ let mask = document.createElement('div');
1663
+ mask.classList.add('hlp-focus-mask');
1664
+ mask.style.position = 'fixed';
1665
+ mask.style.top = 0;
1666
+ mask.style.bottom = 0;
1667
+ mask.style.left = 0;
1668
+ mask.style.right = 0;
1669
+ mask.style.backgroundColor = 'rgba(0,0,0,0.8)';
1670
+ mask.style.zIndex = 2147483646;
1671
+ el.before(mask);
1672
+ el.setAttribute('data-focussed', 1);
1673
+ el.setAttribute('data-focussed-orig-z-index', el.style.zIndex);
1674
+ el.setAttribute('data-focussed-orig-position', el.style.position);
1675
+ el.setAttribute('data-focussed-orig-background-color', el.style.backgroundColor);
1676
+ el.setAttribute('data-focussed-orig-box-shadow', el.style.boxShadow);
1677
+ el.style.zIndex = 2147483647;
1678
+ el.style.position = 'relative';
1679
+ el.style.backgroundColor = '#ffffff';
1680
+ el.style.boxShadow = '0px 0px 0px 20px #fff';
1681
+ }
1682
+ }
1683
+ static unfocus() {
1684
+ if (document.querySelector('.hlp-focus-mask') !== null) {
1685
+ document.querySelectorAll('.hlp-focus-mask').forEach(el => {
1686
+ hlp.remove(el);
1687
+ });
1688
+ }
1689
+ if (document.querySelector('[data-focussed]') !== null) {
1690
+ document.querySelectorAll('[data-focussed]').forEach(el => {
1691
+ el.style.zIndex = el.getAttribute('data-focussed-orig-z-index');
1692
+ el.style.position = el.getAttribute('data-focussed-orig-position');
1693
+ el.style.backgroundColor = el.getAttribute('data-focussed-orig-background-color');
1694
+ el.style.boxShadow = el.getAttribute('data-focussed-orig-box-shadow');
1695
+ el.removeAttribute('data-focussed');
1696
+ el.removeAttribute('data-focussed-orig-z-index');
1697
+ el.removeAttribute('data-focussed-orig-position');
1698
+ el.removeAttribute('data-focussed-orig-background-color');
1699
+ el.removeAttribute('data-focussed-orig-box-shadow');
1700
+ });
1701
+ }
1702
+ }
1703
+ static remove(el) {
1704
+ if (el !== null) {
1705
+ el.parentNode.removeChild(el);
1706
+ }
1707
+ }
1708
+ static on(event, selector, scope) {
1709
+ let callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1710
+ if (callback === null) {
1711
+ callback = scope;
1712
+ scope = document;
1713
+ } else {
1714
+ scope = document.querySelector(scope);
1715
+ }
1716
+ scope.addEventListener(event, e => {
1717
+ var el = hlp.closest(e.target, selector);
1718
+ if (el) {
1719
+ callback(e, el);
1720
+ }
1721
+ }, false);
1722
+ }
1723
+ static url() {
1724
+ return window.location.protocol + '//' + window.location.host + window.location.pathname;
1725
+ }
1726
+ static urlWithHash() {
1727
+ return window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.hash;
1728
+ }
1729
+ static fullUrl() {
1730
+ return window.location.href;
1731
+ }
1732
+ static urlWithArgs() {
1733
+ return window.location.href.split('#')[0];
1734
+ }
1735
+ static baseUrl() {
1736
+ return window.location.protocol + '//' + window.location.host;
1737
+ }
1738
+ static urlProtocol() {
1739
+ return window.location.protocol + '//';
1740
+ }
1741
+ static urlHost() {
1742
+ return window.location.host;
1743
+ }
1744
+ static urlHostTopLevel() {
1745
+ let host = window.location.host;
1746
+ // ipv4
1747
+ if (host.match(/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)) {
2123
1748
  return host;
2124
1749
  }
2125
- }, {
2126
- key: "urlPath",
2127
- value: function urlPath() {
2128
- return window.location.pathname;
2129
- }
2130
- }, {
2131
- key: "urlHash",
2132
- value: function urlHash() {
2133
- return window.location.hash;
2134
- }
2135
- }, {
2136
- key: "urlArgs",
2137
- value: function urlArgs() {
2138
- return window.location.search;
2139
- }
2140
- }, {
2141
- key: "urlOfScript",
2142
- value: function urlOfScript() {
2143
- if (document.currentScript) {
2144
- return document.currentScript.src;
2145
- } else {
2146
- var scripts = document.getElementsByTagName('script');
2147
- return scripts[scripts.length - 1].src;
2148
- }
1750
+ host = host.split('.');
1751
+ while (host.length > 2) {
1752
+ host.shift();
1753
+ }
1754
+ host = host.join('.');
1755
+ return host;
1756
+ }
1757
+ static urlPath() {
1758
+ return window.location.pathname;
1759
+ }
1760
+ static urlHash() {
1761
+ return window.location.hash;
1762
+ }
1763
+ static urlArgs() {
1764
+ return window.location.search;
1765
+ }
1766
+ static urlOfScript() {
1767
+ if (document.currentScript) {
1768
+ return document.currentScript.src;
1769
+ } else {
1770
+ let scripts = document.getElementsByTagName('script');
1771
+ return scripts[scripts.length - 1].src;
2149
1772
  }
2150
- }, {
2151
- key: "pathOfScript",
2152
- value: function pathOfScript() {
2153
- var script = this.urlOfScript(),
2154
- path = script.substring(0, script.lastIndexOf('/'));
2155
- return path;
2156
- }
2157
- }, {
2158
- key: "waitUntil",
2159
- value: function waitUntil(selector) {
2160
- var css_option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2161
- var css_value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2162
- return new Promise(function (resolve, reject) {
2163
- var timeout = setInterval(function () {
2164
- if (document.querySelector(selector) !== null && (css_option === null || css_value === null && window.getComputedStyle(document.querySelector(selector))[css_option] !== undefined && window.getComputedStyle(document.querySelector(selector))[css_option] != '' || css_value !== null && window.getComputedStyle(document.querySelector(selector))[css_option] === css_value)) {
1773
+ }
1774
+ static pathOfScript() {
1775
+ let script = this.urlOfScript(),
1776
+ path = script.substring(0, script.lastIndexOf('/'));
1777
+ return path;
1778
+ }
1779
+ static waitUntil(selector) {
1780
+ let css_option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1781
+ let css_value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1782
+ return new Promise((resolve, reject) => {
1783
+ let timeout = setInterval(() => {
1784
+ if (document.querySelector(selector) !== null && (css_option === null || css_value === null && window.getComputedStyle(document.querySelector(selector))[css_option] !== undefined && window.getComputedStyle(document.querySelector(selector))[css_option] != '' || css_value !== null && window.getComputedStyle(document.querySelector(selector))[css_option] === css_value)) {
1785
+ window.clearInterval(timeout);
1786
+ resolve();
1787
+ }
1788
+ }, 30);
1789
+ });
1790
+ }
1791
+ static waitUntilVar() {
1792
+ let arg1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1793
+ let arg2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1794
+ let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1795
+ let varName = null,
1796
+ parentContainer = null;
1797
+ if (arg2 === null) {
1798
+ varName = arg1;
1799
+ parentContainer = window;
1800
+ } else {
1801
+ varName = arg2;
1802
+ parentContainer = arg1;
1803
+ }
1804
+ return new Promise((resolve, reject) => {
1805
+ let timeout = setInterval(() => {
1806
+ if (parentContainer[varName] !== undefined && parentContainer[varName] !== null) {
1807
+ if (value === null || parentContainer[varName] === value) {
2165
1808
  window.clearInterval(timeout);
2166
1809
  resolve();
2167
1810
  }
2168
- }, 30);
2169
- });
2170
- }
2171
- }, {
2172
- key: "waitUntilVar",
2173
- value: function waitUntilVar() {
2174
- var arg1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2175
- var arg2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2176
- var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2177
- var varName = null,
2178
- parentContainer = null;
2179
- if (arg2 === null) {
2180
- varName = arg1;
2181
- parentContainer = window;
1811
+ }
1812
+ }, 30);
1813
+ });
1814
+ }
1815
+ static ready() {
1816
+ return new Promise(resolve => {
1817
+ if (document.readyState !== 'loading') {
1818
+ return resolve();
2182
1819
  } else {
2183
- varName = arg2;
2184
- parentContainer = arg1;
2185
- }
2186
- return new Promise(function (resolve, reject) {
2187
- var timeout = setInterval(function () {
2188
- if (parentContainer[varName] !== undefined && parentContainer[varName] !== null) {
2189
- if (value === null || parentContainer[varName] === value) {
2190
- window.clearInterval(timeout);
2191
- resolve();
2192
- }
2193
- }
2194
- }, 30);
2195
- });
2196
- }
2197
- }, {
2198
- key: "ready",
2199
- value: function ready() {
2200
- return new Promise(function (resolve) {
2201
- if (document.readyState !== 'loading') {
1820
+ document.addEventListener('DOMContentLoaded', () => {
2202
1821
  return resolve();
2203
- } else {
2204
- document.addEventListener('DOMContentLoaded', function () {
2205
- return resolve();
2206
- });
2207
- }
2208
- });
2209
- }
2210
- }, {
2211
- key: "load",
2212
- value: function load() {
2213
- return new Promise(function (resolve) {
2214
- if (document.readyState === 'complete') {
1822
+ });
1823
+ }
1824
+ });
1825
+ }
1826
+ static load() {
1827
+ return new Promise(resolve => {
1828
+ if (document.readyState === 'complete') {
1829
+ return resolve();
1830
+ } else {
1831
+ window.addEventListener('load', () => {
2215
1832
  return resolve();
2216
- } else {
2217
- window.addEventListener('load', function () {
2218
- return resolve();
2219
- });
2220
- }
2221
- });
2222
- }
2223
- }, {
2224
- key: "runForEl",
2225
- value: function runForEl(selector, callback) {
2226
- hlp.ready().then(function () {
2227
- // add unique id
2228
- var id = hlp.pushId();
1833
+ });
1834
+ }
1835
+ });
1836
+ }
1837
+ static runForEl(selector, callback) {
1838
+ hlp.ready().then(() => {
1839
+ // add unique id
1840
+ let id = hlp.pushId();
2229
1841
 
2230
- // also run for existing
2231
- if (document.querySelector(selector) !== null) {
2232
- document.querySelectorAll(selector).forEach(function (el) {
2233
- if (el.runForEl === undefined) {
2234
- el.runForEl = [];
2235
- }
2236
- if (!el.runForEl.includes(id)) {
2237
- el.runForEl.push(id);
2238
- callback(el);
1842
+ // also run for existing
1843
+ if (document.querySelector(selector) !== null) {
1844
+ document.querySelectorAll(selector).forEach(el => {
1845
+ if (el.runForEl === undefined) {
1846
+ el.runForEl = [];
1847
+ }
1848
+ if (!el.runForEl.includes(id)) {
1849
+ el.runForEl.push(id);
1850
+ callback(el);
1851
+ }
1852
+ });
1853
+ }
1854
+ // setup queue
1855
+ if (window.runForEl_queue === undefined) {
1856
+ window.runForEl_queue = [];
1857
+ }
1858
+ // setup observer
1859
+ if (window.runForEl_observer === undefined) {
1860
+ window.runForEl_observer = new MutationObserver(mutations => {
1861
+ mutations.forEach(mutations__value => {
1862
+ if (!mutations__value.addedNodes) {
1863
+ return;
2239
1864
  }
2240
- });
2241
- }
2242
- // setup queue
2243
- if (window.runForEl_queue === undefined) {
2244
- window.runForEl_queue = [];
2245
- }
2246
- // setup observer
2247
- if (window.runForEl_observer === undefined) {
2248
- window.runForEl_observer = new MutationObserver(function (mutations) {
2249
- mutations.forEach(function (mutations__value) {
2250
- if (!mutations__value.addedNodes) {
2251
- return;
2252
- }
2253
- var _loop = function _loop() {
2254
- var node = mutations__value.addedNodes[i];
2255
- if (node.nodeType === Node.ELEMENT_NODE) {
2256
- window.runForEl_queue.forEach(function (queue__value) {
2257
- if (node.matches(queue__value.selector)) {
2258
- if (node.runForEl === undefined) {
2259
- node.runForEl = [];
2260
- }
2261
- if (!node.runForEl.includes(queue__value.id)) {
2262
- node.runForEl.push(queue__value.id);
2263
- queue__value.callback(node);
2264
- }
1865
+ for (let i = 0; i < mutations__value.addedNodes.length; i++) {
1866
+ let node = mutations__value.addedNodes[i];
1867
+ if (node.nodeType === Node.ELEMENT_NODE) {
1868
+ window.runForEl_queue.forEach(queue__value => {
1869
+ if (node.matches(queue__value.selector)) {
1870
+ if (node.runForEl === undefined) {
1871
+ node.runForEl = [];
2265
1872
  }
2266
- // if you modify lots of html (e.g. with innerHTML), also check childs
2267
- if (node.querySelector(queue__value.selector) !== null) {
2268
- node.querySelectorAll(queue__value.selector).forEach(function (nodes__value) {
2269
- if (nodes__value.runForEl === undefined) {
2270
- nodes__value.runForEl = [];
2271
- }
2272
- if (!nodes__value.runForEl.includes(queue__value.id)) {
2273
- nodes__value.runForEl.push(queue__value.id);
2274
- queue__value.callback(nodes__value);
2275
- }
2276
- });
1873
+ if (!node.runForEl.includes(queue__value.id)) {
1874
+ node.runForEl.push(queue__value.id);
1875
+ queue__value.callback(node);
2277
1876
  }
2278
- });
2279
- }
2280
- };
2281
- for (var i = 0; i < mutations__value.addedNodes.length; i++) {
2282
- _loop();
1877
+ }
1878
+ // if you modify lots of html (e.g. with innerHTML), also check childs
1879
+ if (node.querySelector(queue__value.selector) !== null) {
1880
+ node.querySelectorAll(queue__value.selector).forEach(nodes__value => {
1881
+ if (nodes__value.runForEl === undefined) {
1882
+ nodes__value.runForEl = [];
1883
+ }
1884
+ if (!nodes__value.runForEl.includes(queue__value.id)) {
1885
+ nodes__value.runForEl.push(queue__value.id);
1886
+ queue__value.callback(nodes__value);
1887
+ }
1888
+ });
1889
+ }
1890
+ });
2283
1891
  }
2284
- });
2285
- }).observe(document.body, {
2286
- attributes: false,
2287
- childList: true,
2288
- characterData: false,
2289
- subtree: true,
2290
- attributeOldValue: false,
2291
- characterDataOldValue: false
1892
+ }
2292
1893
  });
2293
- }
2294
- // push to queue
2295
- window.runForEl_queue.push({
2296
- id: id,
2297
- selector: selector,
2298
- callback: callback
1894
+ }).observe(document.body, {
1895
+ attributes: false,
1896
+ childList: true,
1897
+ characterData: false,
1898
+ subtree: true,
1899
+ attributeOldValue: false,
1900
+ characterDataOldValue: false
2299
1901
  });
1902
+ }
1903
+ // push to queue
1904
+ window.runForEl_queue.push({
1905
+ id: id,
1906
+ selector: selector,
1907
+ callback: callback
2300
1908
  });
1909
+ });
1910
+ }
1911
+ static fmath(op, x, y) {
1912
+ let precision = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 8;
1913
+ let n = {
1914
+ '*': x * y,
1915
+ '-': x - y,
1916
+ '+': x + y,
1917
+ '/': x / y
1918
+ }[op];
1919
+ return Math.round(n * 10 * Math.pow(10, precision)) / (10 * Math.pow(10, precision));
1920
+ }
1921
+ static trim(str, charlist) {
1922
+ let whitespace = [' ', '\n', '\r', '\t', '\f', '\x0b', '\xa0', '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006', '\u2007', '\u2008', '\u2009', '\u200a', '\u200b', '\u2028', '\u2029', '\u3000'].join('');
1923
+ let l = 0;
1924
+ let i = 0;
1925
+ str += '';
1926
+ if (charlist) {
1927
+ whitespace = (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '$1');
2301
1928
  }
2302
- }, {
2303
- key: "fmath",
2304
- value: function fmath(op, x, y) {
2305
- var precision = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 8;
2306
- var n = {
2307
- '*': x * y,
2308
- '-': x - y,
2309
- '+': x + y,
2310
- '/': x / y
2311
- }[op];
2312
- return Math.round(n * 10 * Math.pow(10, precision)) / (10 * Math.pow(10, precision));
2313
- }
2314
- }, {
2315
- key: "trim",
2316
- value: function trim(str, charlist) {
2317
- var whitespace = [' ', '\n', '\r', '\t', '\f', '\x0b', '\xa0', "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u200B", "\u2028", "\u2029", "\u3000"].join('');
2318
- var l = 0;
2319
- var i = 0;
2320
- str += '';
2321
- if (charlist) {
2322
- whitespace = (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '$1');
2323
- }
2324
- l = str.length;
2325
- for (i = 0; i < l; i++) {
2326
- if (whitespace.indexOf(str.charAt(i)) === -1) {
2327
- str = str.substring(i);
2328
- break;
2329
- }
2330
- }
2331
- l = str.length;
2332
- for (i = l - 1; i >= 0; i--) {
2333
- if (whitespace.indexOf(str.charAt(i)) === -1) {
2334
- str = str.substring(0, i + 1);
2335
- break;
2336
- }
2337
- }
2338
- return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
2339
- }
2340
- }, {
2341
- key: "ltrim",
2342
- value: function ltrim(str, charlist) {
2343
- charlist = !charlist ? " \\s\xA0" : (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '$1');
2344
- var re = new RegExp('^[' + charlist + ']+', 'g');
2345
- return (str + '').replace(re, '');
2346
- }
2347
- }, {
2348
- key: "rtrim",
2349
- value: function rtrim(str, charlist) {
2350
- charlist = !charlist ? " \\s\xA0" : (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '\\$1');
2351
- var re = new RegExp('[' + charlist + ']+$', 'g');
2352
- return (str + '').replace(re, '');
2353
- }
2354
- }, {
2355
- key: "pushId",
2356
- value: function pushId() {
2357
- /* source https://gist.github.com/mikelehen/3596a30bd69384624c11 */
2358
- var pushIdData = null;
2359
- // browser
2360
- if (window !== undefined) {
2361
- if (window.pushIdDataGlobal === undefined) {
2362
- window.pushIdDataGlobal = {};
2363
- }
2364
- pushIdData = window.pushIdDataGlobal;
1929
+ l = str.length;
1930
+ for (i = 0; i < l; i++) {
1931
+ if (whitespace.indexOf(str.charAt(i)) === -1) {
1932
+ str = str.substring(i);
1933
+ break;
2365
1934
  }
2366
- // node.js
2367
- if (global !== undefined) {
2368
- if (global.pushIdDataGlobal === undefined) {
2369
- global.pushIdDataGlobal = {};
2370
- }
2371
- pushIdData = global.pushIdDataGlobal;
2372
- }
2373
- // first run
2374
- if (hlp.objectsAreEqual(pushIdData, {})) {
2375
- pushIdData.lastPushTime = 0;
2376
- pushIdData.lastRandChars = [];
2377
- pushIdData.PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
2378
- }
2379
- var now = new Date().getTime(),
2380
- duplicateTime = now === pushIdData.lastPushTime;
2381
- pushIdData.lastPushTime = now;
2382
- var timeStampChars = new Array(8);
2383
- for (var i = 7; i >= 0; i--) {
2384
- timeStampChars[i] = pushIdData.PUSH_CHARS.charAt(now % 64);
2385
- now = Math.floor(now / 64);
2386
- }
2387
- if (now !== 0) {
2388
- throw new Error();
2389
- }
2390
- var id = timeStampChars.join('');
2391
- if (!duplicateTime) {
2392
- for (i = 0; i < 12; i++) {
2393
- pushIdData.lastRandChars[i] = Math.floor(Math.random() * 64);
2394
- }
2395
- } else {
2396
- for (i = 11; i >= 0 && pushIdData.lastRandChars[i] === 63; i--) {
2397
- pushIdData.lastRandChars[i] = 0;
2398
- }
2399
- pushIdData.lastRandChars[i]++;
1935
+ }
1936
+ l = str.length;
1937
+ for (i = l - 1; i >= 0; i--) {
1938
+ if (whitespace.indexOf(str.charAt(i)) === -1) {
1939
+ str = str.substring(0, i + 1);
1940
+ break;
2400
1941
  }
1942
+ }
1943
+ return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
1944
+ }
1945
+ static ltrim(str, charlist) {
1946
+ charlist = !charlist ? ' \\s\u00A0' : (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '$1');
1947
+ const re = new RegExp('^[' + charlist + ']+', 'g');
1948
+ return (str + '').replace(re, '');
1949
+ }
1950
+ static rtrim(str, charlist) {
1951
+ charlist = !charlist ? ' \\s\u00A0' : (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '\\$1');
1952
+ const re = new RegExp('[' + charlist + ']+$', 'g');
1953
+ return (str + '').replace(re, '');
1954
+ }
1955
+ static pushId() {
1956
+ /* source https://gist.github.com/mikelehen/3596a30bd69384624c11 */
1957
+ let pushIdData = null;
1958
+ // browser
1959
+ if (window !== undefined) {
1960
+ if (window.pushIdDataGlobal === undefined) {
1961
+ window.pushIdDataGlobal = {};
1962
+ }
1963
+ pushIdData = window.pushIdDataGlobal;
1964
+ }
1965
+ // node.js
1966
+ if (global !== undefined) {
1967
+ if (global.pushIdDataGlobal === undefined) {
1968
+ global.pushIdDataGlobal = {};
1969
+ }
1970
+ pushIdData = global.pushIdDataGlobal;
1971
+ }
1972
+ // first run
1973
+ if (hlp.objectsAreEqual(pushIdData, {})) {
1974
+ pushIdData.lastPushTime = 0;
1975
+ pushIdData.lastRandChars = [];
1976
+ pushIdData.PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
1977
+ }
1978
+ let now = new Date().getTime(),
1979
+ duplicateTime = now === pushIdData.lastPushTime;
1980
+ pushIdData.lastPushTime = now;
1981
+ let timeStampChars = new Array(8);
1982
+ for (var i = 7; i >= 0; i--) {
1983
+ timeStampChars[i] = pushIdData.PUSH_CHARS.charAt(now % 64);
1984
+ now = Math.floor(now / 64);
1985
+ }
1986
+ if (now !== 0) {
1987
+ throw new Error();
1988
+ }
1989
+ let id = timeStampChars.join('');
1990
+ if (!duplicateTime) {
2401
1991
  for (i = 0; i < 12; i++) {
2402
- id += pushIdData.PUSH_CHARS.charAt(pushIdData.lastRandChars[i]);
2403
- }
2404
- if (id.length != 20) {
2405
- throw new Error();
1992
+ pushIdData.lastRandChars[i] = Math.floor(Math.random() * 64);
2406
1993
  }
2407
- return id;
2408
- }
2409
- }, {
2410
- key: "getProp",
2411
- value: function getProp(obj, desc) {
2412
- var arr = desc.split('.');
2413
- while (arr.length && (obj = obj[arr.shift()]));
2414
- return obj;
2415
- }
2416
- }, {
2417
- key: "base64toblob",
2418
- value: function base64toblob(base64) {
2419
- var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2420
- var sliceSize = 512,
2421
- byteCharacters = atob(base64),
2422
- byteArrays = [];
2423
- for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
2424
- var slice = byteCharacters.slice(offset, offset + sliceSize),
2425
- byteNumbers = new Array(slice.length);
2426
- for (var i = 0; i < slice.length; i++) {
2427
- byteNumbers[i] = slice.charCodeAt(i);
2428
- }
2429
- var byteArray = new Uint8Array(byteNumbers);
2430
- byteArrays.push(byteArray);
1994
+ } else {
1995
+ for (i = 11; i >= 0 && pushIdData.lastRandChars[i] === 63; i--) {
1996
+ pushIdData.lastRandChars[i] = 0;
2431
1997
  }
2432
- var blob = new Blob(byteArrays, {
2433
- type: contentType
2434
- });
2435
- return blob;
2436
- }
2437
- }, {
2438
- key: "blobtobase64",
2439
- value: function blobtobase64(blob) {
2440
- return new Promise(function (resolve) {
2441
- var reader = new FileReader();
2442
- reader.onload = function () {
2443
- var dataUrl = reader.result;
2444
- var base64 = dataUrl.split(',')[1];
2445
- resolve(base64);
2446
- };
2447
- reader.readAsDataURL(blob);
2448
- });
2449
- }
2450
- }, {
2451
- key: "stringtoblob",
2452
- value: function stringtoblob(string) {
2453
- var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2454
- var blob = new Blob([string], {
2455
- type: contentType
2456
- });
2457
- return blob;
2458
- }
2459
- }, {
2460
- key: "blobtostring",
2461
- value: function blobtostring(blob) {
2462
- return new Promise(function (resolve) {
2463
- var reader = new FileReader();
2464
- reader.onload = function () {
2465
- resolve(reader.result);
2466
- };
2467
- reader.readAsText(blob);
2468
- });
1998
+ pushIdData.lastRandChars[i]++;
2469
1999
  }
2470
- }, {
2471
- key: "filetobase64",
2472
- value: function filetobase64(file) {
2473
- return new Promise(function (resolve, reject) {
2474
- var reader = new FileReader();
2475
- reader.readAsDataURL(file);
2476
- reader.onload = function () {
2477
- return resolve(reader.result.split(',')[1]);
2478
- };
2479
- reader.onerror = function (error) {
2480
- return reject(error);
2481
- };
2482
- });
2000
+ for (i = 0; i < 12; i++) {
2001
+ id += pushIdData.PUSH_CHARS.charAt(pushIdData.lastRandChars[i]);
2483
2002
  }
2484
- }, {
2485
- key: "blobtofile",
2486
- value: function blobtofile(blob) {
2487
- var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'file.txt';
2488
- var file = null;
2489
- try {
2490
- file = new File([blob], filename);
2491
- } catch (_unused) {
2492
- // ie 11
2493
- file = new Blob([blob], filename);
2494
- }
2495
- return file;
2496
- }
2497
- }, {
2498
- key: "filetoblob",
2499
- value: function filetoblob(file) {
2500
- return new Blob([file]);
2501
- }
2502
- }, {
2503
- key: "base64tofile",
2504
- value: function base64tofile(base64) {
2505
- var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2506
- var filename = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'file.txt';
2507
- return this.blobtofile(this.base64toblob(base64, contentType), filename);
2508
- }
2509
- }, {
2510
- key: "blobtourl",
2511
- value: function blobtourl(blob) {
2512
- return URL.createObjectURL(blob, {
2513
- type: 'text/plain'
2514
- });
2003
+ if (id.length != 20) {
2004
+ throw new Error();
2515
2005
  }
2516
- }, {
2517
- key: "stringtourl",
2518
- value: function stringtourl(string) {
2519
- return this.blobtourl(this.stringtoblob(string));
2520
- }
2521
- }, {
2522
- key: "base64tostring",
2523
- value: function base64tostring(base64) {
2524
- return atob(base64);
2525
- }
2526
- }, {
2527
- key: "stringtobase64",
2528
- value: function stringtobase64(string) {
2529
- return btoa(string);
2530
- }
2531
- }, {
2532
- key: "base64tourl",
2533
- value: function base64tourl(base64) {
2534
- return this.blobtourl(this.base64toblob(base64));
2535
- }
2536
- }, {
2537
- key: "filetourl",
2538
- value: function filetourl(file) {
2539
- return this.blobtourl(this.filetoblob(file));
2540
- }
2541
- }, {
2542
- key: "getImageOrientation",
2543
- value: function getImageOrientation(base64) {
2544
- var _this10 = this;
2545
- return new Promise(function (resolve, reject) {
2546
- base64 = base64.replace('data:image/jpeg;base64,', '');
2547
- var file = _this10.base64tofile(base64),
2548
- reader = new FileReader();
2549
- reader.onload = function (e) {
2550
- var view = new DataView(e.target.result);
2551
- if (view.getUint16(0, false) != 0xffd8) {
2552
- resolve(-2);
2006
+ return id;
2007
+ }
2008
+ static getProp(obj, desc) {
2009
+ let arr = desc.split('.');
2010
+ while (arr.length && (obj = obj[arr.shift()]));
2011
+ return obj;
2012
+ }
2013
+ static base64toblob(base64) {
2014
+ let contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2015
+ let sliceSize = 512,
2016
+ byteCharacters = atob(base64),
2017
+ byteArrays = [];
2018
+ for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
2019
+ let slice = byteCharacters.slice(offset, offset + sliceSize),
2020
+ byteNumbers = new Array(slice.length);
2021
+ for (let i = 0; i < slice.length; i++) {
2022
+ byteNumbers[i] = slice.charCodeAt(i);
2023
+ }
2024
+ let byteArray = new Uint8Array(byteNumbers);
2025
+ byteArrays.push(byteArray);
2026
+ }
2027
+ let blob = new Blob(byteArrays, {
2028
+ type: contentType
2029
+ });
2030
+ return blob;
2031
+ }
2032
+ static blobtobase64(blob) {
2033
+ return new Promise(resolve => {
2034
+ let reader = new FileReader();
2035
+ reader.onload = () => {
2036
+ var dataUrl = reader.result;
2037
+ var base64 = dataUrl.split(',')[1];
2038
+ resolve(base64);
2039
+ };
2040
+ reader.readAsDataURL(blob);
2041
+ });
2042
+ }
2043
+ static stringtoblob(string) {
2044
+ let contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2045
+ let blob = new Blob([string], {
2046
+ type: contentType
2047
+ });
2048
+ return blob;
2049
+ }
2050
+ static blobtostring(blob) {
2051
+ return new Promise(resolve => {
2052
+ let reader = new FileReader();
2053
+ reader.onload = () => {
2054
+ resolve(reader.result);
2055
+ };
2056
+ reader.readAsText(blob);
2057
+ });
2058
+ }
2059
+ static filetobase64(file) {
2060
+ return new Promise((resolve, reject) => {
2061
+ const reader = new FileReader();
2062
+ reader.readAsDataURL(file);
2063
+ reader.onload = () => resolve(reader.result.split(',')[1]);
2064
+ reader.onerror = error => reject(error);
2065
+ });
2066
+ }
2067
+ static blobtofile(blob) {
2068
+ let filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'file.txt';
2069
+ let file = null;
2070
+ try {
2071
+ file = new File([blob], filename);
2072
+ } catch {
2073
+ // ie 11
2074
+ file = new Blob([blob], filename);
2075
+ }
2076
+ return file;
2077
+ }
2078
+ static filetoblob(file) {
2079
+ return new Blob([file]);
2080
+ }
2081
+ static base64tofile(base64) {
2082
+ let contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2083
+ let filename = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'file.txt';
2084
+ return this.blobtofile(this.base64toblob(base64, contentType), filename);
2085
+ }
2086
+ static blobtourl(blob) {
2087
+ return URL.createObjectURL(blob, {
2088
+ type: 'text/plain'
2089
+ });
2090
+ }
2091
+ static stringtourl(string) {
2092
+ return this.blobtourl(this.stringtoblob(string));
2093
+ }
2094
+ static base64tostring(base64) {
2095
+ return atob(base64);
2096
+ }
2097
+ static stringtobase64(string) {
2098
+ return btoa(string);
2099
+ }
2100
+ static base64tourl(base64) {
2101
+ return this.blobtourl(this.base64toblob(base64));
2102
+ }
2103
+ static filetourl(file) {
2104
+ return this.blobtourl(this.filetoblob(file));
2105
+ }
2106
+ static getImageOrientation(base64) {
2107
+ return new Promise((resolve, reject) => {
2108
+ base64 = base64.replace('data:image/jpeg;base64,', '');
2109
+ let file = this.base64tofile(base64),
2110
+ reader = new FileReader();
2111
+ reader.onload = e => {
2112
+ var view = new DataView(e.target.result);
2113
+ if (view.getUint16(0, false) != 0xffd8) {
2114
+ resolve(-2);
2115
+ return;
2116
+ }
2117
+ var length = view.byteLength,
2118
+ offset = 2;
2119
+ while (offset < length) {
2120
+ if (view.getUint16(offset + 2, false) <= 8) {
2121
+ resolve(-1);
2553
2122
  return;
2554
2123
  }
2555
- var length = view.byteLength,
2556
- offset = 2;
2557
- while (offset < length) {
2558
- if (view.getUint16(offset + 2, false) <= 8) {
2124
+ var marker = view.getUint16(offset, false);
2125
+ offset += 2;
2126
+ if (marker == 0xffe1) {
2127
+ if (view.getUint32(offset += 2, false) != 0x45786966) {
2559
2128
  resolve(-1);
2560
2129
  return;
2561
2130
  }
2562
- var marker = view.getUint16(offset, false);
2131
+ var little = view.getUint16(offset += 6, false) == 0x4949;
2132
+ offset += view.getUint32(offset + 4, little);
2133
+ var tags = view.getUint16(offset, little);
2563
2134
  offset += 2;
2564
- if (marker == 0xffe1) {
2565
- if (view.getUint32(offset += 2, false) != 0x45786966) {
2566
- resolve(-1);
2135
+ for (var i = 0; i < tags; i++) {
2136
+ if (view.getUint16(offset + i * 12, little) == 0x0112) {
2137
+ resolve(view.getUint16(offset + i * 12 + 8, little));
2567
2138
  return;
2568
2139
  }
2569
- var little = view.getUint16(offset += 6, false) == 0x4949;
2570
- offset += view.getUint32(offset + 4, little);
2571
- var tags = view.getUint16(offset, little);
2572
- offset += 2;
2573
- for (var i = 0; i < tags; i++) {
2574
- if (view.getUint16(offset + i * 12, little) == 0x0112) {
2575
- resolve(view.getUint16(offset + i * 12 + 8, little));
2576
- return;
2577
- }
2578
- }
2579
- } else if ((marker & 0xff00) != 0xff00) {
2580
- break;
2581
- } else {
2582
- offset += view.getUint16(offset, false);
2583
2140
  }
2584
- }
2585
- resolve(-1);
2586
- return;
2587
- };
2588
- reader.readAsArrayBuffer(file);
2589
- });
2590
- }
2591
- }, {
2592
- key: "resetImageOrientation",
2593
- value: function resetImageOrientation(srcBase64, srcOrientation) {
2594
- return new Promise(function (resolve, reject) {
2595
- var img = new Image();
2596
- img.onload = function () {
2597
- var width = img.width,
2598
- height = img.height,
2599
- canvas = document.createElement('canvas'),
2600
- ctx = canvas.getContext('2d');
2601
- if (4 < srcOrientation && srcOrientation < 9) {
2602
- canvas.width = height;
2603
- canvas.height = width;
2141
+ } else if ((marker & 0xff00) != 0xff00) {
2142
+ break;
2604
2143
  } else {
2605
- canvas.width = width;
2606
- canvas.height = height;
2144
+ offset += view.getUint16(offset, false);
2607
2145
  }
2608
- switch (srcOrientation) {
2609
- case 2:
2610
- ctx.transform(-1, 0, 0, 1, width, 0);
2611
- break;
2612
- case 3:
2613
- ctx.transform(-1, 0, 0, -1, width, height);
2614
- break;
2615
- case 4:
2616
- ctx.transform(1, 0, 0, -1, 0, height);
2617
- break;
2618
- case 5:
2619
- ctx.transform(0, 1, 1, 0, 0, 0);
2620
- break;
2621
- case 6:
2622
- ctx.transform(0, 1, -1, 0, height, 0);
2623
- break;
2624
- case 7:
2625
- ctx.transform(0, -1, -1, 0, height, width);
2626
- break;
2627
- case 8:
2628
- ctx.transform(0, -1, 1, 0, 0, width);
2629
- break;
2630
- default:
2631
- break;
2632
- }
2633
- ctx.drawImage(img, 0, 0);
2634
- var base64 = canvas.toDataURL();
2635
- base64 = 'data:image/jpeg;base64,' + base64.split(',')[1];
2636
- resolve(base64);
2637
- return;
2638
- };
2639
- img.src = srcBase64;
2640
- });
2641
- }
2642
- }, {
2643
- key: "fixImageOrientation",
2644
- value: function fixImageOrientation(base64) {
2645
- var _this11 = this;
2646
- return new Promise(function (resolve, reject) {
2647
- if (base64.indexOf('data:') === -1) {
2648
- resolve(base64);
2649
- return;
2650
2146
  }
2651
- if (base64.indexOf('data:image/jpeg;base64,') === 0) {
2652
- base64 = base64.replace('data:image/jpeg;base64,', '');
2147
+ resolve(-1);
2148
+ return;
2149
+ };
2150
+ reader.readAsArrayBuffer(file);
2151
+ });
2152
+ }
2153
+ static resetImageOrientation(srcBase64, srcOrientation) {
2154
+ return new Promise((resolve, reject) => {
2155
+ var img = new Image();
2156
+ img.onload = () => {
2157
+ var width = img.width,
2158
+ height = img.height,
2159
+ canvas = document.createElement('canvas'),
2160
+ ctx = canvas.getContext('2d');
2161
+ if (4 < srcOrientation && srcOrientation < 9) {
2162
+ canvas.width = height;
2163
+ canvas.height = width;
2164
+ } else {
2165
+ canvas.width = width;
2166
+ canvas.height = height;
2167
+ }
2168
+ switch (srcOrientation) {
2169
+ case 2:
2170
+ ctx.transform(-1, 0, 0, 1, width, 0);
2171
+ break;
2172
+ case 3:
2173
+ ctx.transform(-1, 0, 0, -1, width, height);
2174
+ break;
2175
+ case 4:
2176
+ ctx.transform(1, 0, 0, -1, 0, height);
2177
+ break;
2178
+ case 5:
2179
+ ctx.transform(0, 1, 1, 0, 0, 0);
2180
+ break;
2181
+ case 6:
2182
+ ctx.transform(0, 1, -1, 0, height, 0);
2183
+ break;
2184
+ case 7:
2185
+ ctx.transform(0, -1, -1, 0, height, width);
2186
+ break;
2187
+ case 8:
2188
+ ctx.transform(0, -1, 1, 0, 0, width);
2189
+ break;
2190
+ default:
2191
+ break;
2653
2192
  }
2654
- _this11.getImageOrientation(base64).then(function (orientation) {
2655
- base64 = 'data:image/jpeg;base64,' + base64;
2656
- if (orientation <= 1) {
2657
- resolve(base64);
2193
+ ctx.drawImage(img, 0, 0);
2194
+ let base64 = canvas.toDataURL();
2195
+ base64 = 'data:image/jpeg;base64,' + base64.split(',')[1];
2196
+ resolve(base64);
2197
+ return;
2198
+ };
2199
+ img.src = srcBase64;
2200
+ });
2201
+ }
2202
+ static fixImageOrientation(base64) {
2203
+ return new Promise((resolve, reject) => {
2204
+ if (base64.indexOf('data:') === -1) {
2205
+ resolve(base64);
2206
+ return;
2207
+ }
2208
+ if (base64.indexOf('data:image/jpeg;base64,') === 0) {
2209
+ base64 = base64.replace('data:image/jpeg;base64,', '');
2210
+ }
2211
+ this.getImageOrientation(base64).then(orientation => {
2212
+ base64 = 'data:image/jpeg;base64,' + base64;
2213
+ if (orientation <= 1) {
2214
+ resolve(base64);
2215
+ return;
2216
+ } else {
2217
+ this.resetImageOrientation(base64, orientation).then(base64_new => {
2218
+ resolve(base64_new);
2658
2219
  return;
2659
- } else {
2660
- _this11.resetImageOrientation(base64, orientation).then(function (base64_new) {
2661
- resolve(base64_new);
2662
- return;
2663
- });
2664
- }
2665
- });
2220
+ });
2221
+ }
2666
2222
  });
2667
- }
2668
- }, {
2669
- key: "debounce",
2670
- value: function debounce(func, wait, immediate) {
2671
- var timeout;
2672
- return function () {
2673
- var context = this,
2674
- args = arguments;
2675
- var later = function later() {
2676
- timeout = null;
2677
- if (!immediate) func.apply(context, args);
2678
- };
2679
- var callNow = immediate && !timeout;
2680
- clearTimeout(timeout);
2681
- timeout = setTimeout(later, wait);
2682
- if (callNow) func.apply(context, args);
2683
- };
2684
- }
2685
- }, {
2686
- key: "throttle",
2687
- value: function throttle(func, wait, options) {
2688
- var context, args, result;
2689
- var timeout = null;
2690
- var previous = 0;
2691
- if (!options) options = {};
2692
- var later = function later() {
2693
- previous = options.leading === false ? 0 : Date.now();
2223
+ });
2224
+ }
2225
+ static debounce(func, wait, immediate) {
2226
+ var timeout;
2227
+ return function () {
2228
+ var context = this,
2229
+ args = arguments;
2230
+ var later = function () {
2694
2231
  timeout = null;
2695
- result = func.apply(context, args);
2696
- if (!timeout) context = args = null;
2232
+ if (!immediate) func.apply(context, args);
2697
2233
  };
2698
- return function () {
2699
- var now = Date.now();
2700
- if (!previous && options.leading === false) previous = now;
2701
- var remaining = wait - (now - previous);
2702
- context = this;
2703
- args = arguments;
2704
- if (remaining <= 0 || remaining > wait) {
2705
- if (timeout) {
2706
- clearTimeout(timeout);
2707
- timeout = null;
2708
- }
2709
- previous = now;
2710
- result = func.apply(context, args);
2711
- if (!timeout) context = args = null;
2712
- } else if (!timeout && options.trailing !== false) {
2713
- timeout = setTimeout(later, remaining);
2234
+ var callNow = immediate && !timeout;
2235
+ clearTimeout(timeout);
2236
+ timeout = setTimeout(later, wait);
2237
+ if (callNow) func.apply(context, args);
2238
+ };
2239
+ }
2240
+ static throttle(func, wait, options) {
2241
+ var context, args, result;
2242
+ var timeout = null;
2243
+ var previous = 0;
2244
+ if (!options) options = {};
2245
+ var later = function () {
2246
+ previous = options.leading === false ? 0 : Date.now();
2247
+ timeout = null;
2248
+ result = func.apply(context, args);
2249
+ if (!timeout) context = args = null;
2250
+ };
2251
+ return function () {
2252
+ var now = Date.now();
2253
+ if (!previous && options.leading === false) previous = now;
2254
+ var remaining = wait - (now - previous);
2255
+ context = this;
2256
+ args = arguments;
2257
+ if (remaining <= 0 || remaining > wait) {
2258
+ if (timeout) {
2259
+ clearTimeout(timeout);
2260
+ timeout = null;
2714
2261
  }
2715
- return result;
2716
- };
2717
- }
2718
- }, {
2719
- key: "shuffle",
2720
- value: function shuffle(array) {
2721
- var currentIndex = array.length,
2722
- temporaryValue,
2723
- randomIndex;
2724
- while (0 !== currentIndex) {
2725
- randomIndex = Math.floor(Math.random() * currentIndex);
2726
- currentIndex -= 1;
2727
- temporaryValue = array[currentIndex];
2728
- array[currentIndex] = array[randomIndex];
2729
- array[randomIndex] = temporaryValue;
2262
+ previous = now;
2263
+ result = func.apply(context, args);
2264
+ if (!timeout) context = args = null;
2265
+ } else if (!timeout && options.trailing !== false) {
2266
+ timeout = setTimeout(later, remaining);
2730
2267
  }
2731
- return array;
2732
- }
2733
- }, {
2734
- key: "findRecursiveInObject",
2735
- value: function findRecursiveInObject(object) {
2736
- var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2737
- var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2738
- var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
2739
- var paths = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
2740
- if (object !== null && (0, _typeof2.default)(object) === 'object') {
2741
- for (var _i = 0, _Object$entries = Object.entries(object); _i < _Object$entries.length; _i++) {
2742
- var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
2743
- object__key = _Object$entries$_i[0],
2744
- object__value = _Object$entries$_i[1];
2745
- if (object__value !== null && (0, _typeof2.default)(object__value) === 'object') {
2746
- this.findRecursiveInObject(object__value, key, value, (path === '' ? '' : path + '.') + object__key, paths);
2747
- } else if ((key === null || object__key === key) && (value === null || object__value === value)) {
2748
- paths.push(path);
2749
- break; // only take first
2750
- }
2268
+ return result;
2269
+ };
2270
+ }
2271
+ static shuffle(array) {
2272
+ let currentIndex = array.length,
2273
+ temporaryValue,
2274
+ randomIndex;
2275
+ while (0 !== currentIndex) {
2276
+ randomIndex = Math.floor(Math.random() * currentIndex);
2277
+ currentIndex -= 1;
2278
+ temporaryValue = array[currentIndex];
2279
+ array[currentIndex] = array[randomIndex];
2280
+ array[randomIndex] = temporaryValue;
2281
+ }
2282
+ return array;
2283
+ }
2284
+ static findRecursiveInObject(object) {
2285
+ let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2286
+ let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2287
+ let path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
2288
+ let paths = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
2289
+ if (object !== null && typeof object === 'object') {
2290
+ for (const [object__key, object__value] of Object.entries(object)) {
2291
+ if (object__value !== null && typeof object__value === 'object') {
2292
+ this.findRecursiveInObject(object__value, key, value, (path === '' ? '' : path + '.') + object__key, paths);
2293
+ } else if ((key === null || object__key === key) && (value === null || object__value === value)) {
2294
+ paths.push(path);
2295
+ break; // only take first
2751
2296
  }
2752
2297
  }
2753
-
2754
- return paths;
2755
2298
  }
2756
- }]);
2757
- return hlp;
2758
- }();
2299
+
2300
+ return paths;
2301
+ }
2302
+ }
2303
+
2759
2304
  /* expose all functions to window */
2760
2305
  exports.default = hlp;
2761
2306
  if (typeof window !== 'undefined') {
2762
2307
  window.hlp = {};
2763
- Object.getOwnPropertyNames(hlp).forEach(function (value, key) {
2308
+ Object.getOwnPropertyNames(hlp).forEach((value, key) => {
2764
2309
  if (value === 'length' || value === 'name' || value === 'prototype' || value === 'caller' || value === 'arguments') {
2765
2310
  return;
2766
2311
  }