@lmjs/core 1.0.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle.js +264 -0
- package/build/plugins-registry.js +216 -0
- package/dist/lumenjs-core-with-plugins.js +59258 -0
- package/dist/lumenjs-core.js +50 -0
- package/dist/lumenjs-plugins.css +2822 -0
- package/package.json +59 -28
- package/src/_re.js +2307 -0
- package/src/dom-shim.js +473 -0
- package/src/index-bootstrap.js +47 -0
- package/src/lstnrs.js +1391 -0
- package/src/walk.js +749 -0
- package/src/workers/css.js +1 -0
- package/src/workers/cssRaw.js +1173 -0
- package/src/workers/esp.js +1 -0
- package/src/workers/espRaw.js +78 -0
- package/src/workers/up.js +1 -0
- package/src/workers/upRaw.js +491 -0
- package/src/workers/work.js +1 -0
- package/src/workers/workRaw.js +1097 -0
- package/src/ws.js +1162 -0
- package/vendor/astring.js +3 -0
- package/vendor/bootstrap2-less-stubs/mixins.less +16 -0
- package/vendor/bootstrap2-less-stubs/variables.less +13 -0
- package/vendor/md5.js +1 -0
- package/vendor/reconnecting-websocket.js +4118 -0
- package/vendor/webworker-helper.js +1 -0
- package/LICENSE +0 -201
- package/README.md +0 -3
- package/index.js +0 -14
|
@@ -0,0 +1,4118 @@
|
|
|
1
|
+
!function (a, b) {
|
|
2
|
+
"function" == typeof define && define.amd ? define([], b) : "undefined" != typeof module && module.exports ? module.exports = b() : a.ReconnectingWebSocket = b()
|
|
3
|
+
}(this, function () {
|
|
4
|
+
function a(b, c, d) {
|
|
5
|
+
function l(a, b) {
|
|
6
|
+
var c = document.createEvent("CustomEvent");
|
|
7
|
+
return c.initCustomEvent(a, !1, !1, b), c
|
|
8
|
+
}
|
|
9
|
+
var e = {
|
|
10
|
+
debug: !1,
|
|
11
|
+
automaticOpen: !0,
|
|
12
|
+
reconnectInterval: 1e3,
|
|
13
|
+
maxReconnectInterval: 3e4,
|
|
14
|
+
reconnectDecay: 1,
|
|
15
|
+
timeoutInterval: 3e3
|
|
16
|
+
};
|
|
17
|
+
d || (d = {});
|
|
18
|
+
for (var f in e) this[f] = "undefined" != typeof d[f] ? d[f] : e[f];
|
|
19
|
+
this.url = b, this.reconnectAttempts = 0, this.readyState = WebSocket.CONNECTING, this.protocol = null;
|
|
20
|
+
var h, g = this,
|
|
21
|
+
i = !1,
|
|
22
|
+
j = !1,
|
|
23
|
+
k = document.createElement("div");
|
|
24
|
+
k.addEventListener("open", function (a) {
|
|
25
|
+
g.onopen(a)
|
|
26
|
+
}), k.addEventListener("close", function (a) {
|
|
27
|
+
g.onclose(a)
|
|
28
|
+
}), k.addEventListener("connecting", function (a) {
|
|
29
|
+
g.onconnecting(a)
|
|
30
|
+
}), k.addEventListener("message", function (a) {
|
|
31
|
+
g.onmessage(a)
|
|
32
|
+
}), k.addEventListener("error", function (a) {
|
|
33
|
+
g.onerror(a)
|
|
34
|
+
}), this.addEventListener = k.addEventListener.bind(k), this.removeEventListener = k.removeEventListener.bind(k), this.dispatchEvent = k.dispatchEvent.bind(k), this.open = function (b) {
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
h = new WebSocket(g.url, c || []), b || k.dispatchEvent(l("connecting")), (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "attempt-connect", g.url);
|
|
38
|
+
var d = h,
|
|
39
|
+
e = setTimeout(function () {
|
|
40
|
+
(g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "connection-timeout", g.url), j = !0, j = !1;
|
|
41
|
+
if (d.readyState == 1) d.close();
|
|
42
|
+
}, g.timeoutInterval);
|
|
43
|
+
h.onopen = function () {
|
|
44
|
+
clearTimeout(e), (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onopen", g.url), g.protocol = h.protocol, g.readyState = WebSocket.OPEN, g.reconnectAttempts = 0;
|
|
45
|
+
var d = l("open");
|
|
46
|
+
d.isReconnect = b, b = !1, k.dispatchEvent(d)
|
|
47
|
+
}, h.onclose = function (c) {
|
|
48
|
+
if (clearTimeout(e), h = null, i) g.readyState = WebSocket.CLOSED, k.dispatchEvent(l("close"));
|
|
49
|
+
else {
|
|
50
|
+
g.readyState = WebSocket.CONNECTING;
|
|
51
|
+
var d = l("connecting");
|
|
52
|
+
d.code = c.code, d.reason = c.reason, d.wasClean = c.wasClean, k.dispatchEvent(d), b || j || ((g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onclose", g.url), k.dispatchEvent(l("close")));
|
|
53
|
+
var e = g.reconnectInterval * Math.pow(g.reconnectDecay, g.reconnectAttempts);
|
|
54
|
+
setTimeout(function () {
|
|
55
|
+
g.reconnectAttempts++, g.open(!0)
|
|
56
|
+
}, e > g.maxReconnectInterval ? g.maxReconnectInterval : e)
|
|
57
|
+
}
|
|
58
|
+
}, h.onmessage = function (b) {
|
|
59
|
+
(g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onmessage", g.url, b.data);
|
|
60
|
+
var c = l("message");
|
|
61
|
+
c.data = b.data, k.dispatchEvent(c)
|
|
62
|
+
}, h.onerror = function (b) {
|
|
63
|
+
(g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "onerror", g.url, b), k.dispatchEvent(l("error"))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
} catch (error) {
|
|
67
|
+
// Handle the WebSocket connection error here
|
|
68
|
+
console.error('WebSocket connection error:', error);
|
|
69
|
+
}
|
|
70
|
+
}, 1 == this.automaticOpen && this.open(!1), this.send = function (b) {
|
|
71
|
+
if (h) return (g.debug || a.debugAll) && console.debug("ReconnectingWebSocket", "send", g.url, b), h.send(b);
|
|
72
|
+
throw "INVALID_STATE_ERR : Pausing to reconnect websocket"
|
|
73
|
+
}, this.close = function (a, b) {
|
|
74
|
+
"undefined" == typeof a && (a = 1e3), i = !0, h && h.close(a, b)
|
|
75
|
+
}, this.refresh = function () {
|
|
76
|
+
h && h.readyState == 1 && h.close()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return a.prototype.onopen = function () { }, a.prototype.onclose = function () { }, a.prototype.onconnecting = function () { }, a.prototype.onmessage = function () { }, a.prototype.onerror = function () { }, a.debugAll = !1, a.CONNECTING = WebSocket.CONNECTING, a.OPEN = WebSocket.OPEN, a.CLOSING = WebSocket.CLOSING, a.CLOSED = WebSocket.CLOSED, a
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
let _isTipped = false;
|
|
83
|
+
var _debugMode = false;
|
|
84
|
+
var _initialized = null;
|
|
85
|
+
var _dbcrs = {};
|
|
86
|
+
var _dbcrsTime = 200;
|
|
87
|
+
var _tickTime = 20;
|
|
88
|
+
var _scW = 0;
|
|
89
|
+
var cl = console.log;
|
|
90
|
+
if (!_vcData) var _vcData = undefined;
|
|
91
|
+
if (!_beaTn) var _beaTn = undefined;
|
|
92
|
+
var beas;
|
|
93
|
+
var appSettings;
|
|
94
|
+
var execEl = "";
|
|
95
|
+
var currentlyValidTags = new Array();
|
|
96
|
+
// var _upwrk = new WebWorker('/js/wRaws/up.js');
|
|
97
|
+
var _upwrk = new WebWorker('_upw');
|
|
98
|
+
// var _csswrk = new WebWorker('/js/csswrk.js');
|
|
99
|
+
var _csswrk = new WebWorker('_cssw');
|
|
100
|
+
// var _jswacrk = new WebWorker('_jswac');
|
|
101
|
+
// _jswacrk.start();
|
|
102
|
+
// _upwrk.start();
|
|
103
|
+
_csswrk.start();
|
|
104
|
+
var _ups = [];
|
|
105
|
+
|
|
106
|
+
(function (e, t) {
|
|
107
|
+
typeof module != "undefined" && module.exports
|
|
108
|
+
? (module.exports = t())
|
|
109
|
+
: typeof define == "function" && define.amd
|
|
110
|
+
? define(t)
|
|
111
|
+
: (this[e] = t());
|
|
112
|
+
})("bea", function () {
|
|
113
|
+
function p(e, t) {
|
|
114
|
+
for (var n = 0, i = e.length; n < i; ++n) if (!t(e[n])) return r;
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
117
|
+
function d(e, t) {
|
|
118
|
+
p(e, function (e) {
|
|
119
|
+
return t(e), 1;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function v(e, t, n) {
|
|
123
|
+
function g(e) {
|
|
124
|
+
return e.call ? e() : u[e];
|
|
125
|
+
}
|
|
126
|
+
function y() {
|
|
127
|
+
if (!--h) {
|
|
128
|
+
(u[o] = 1), s && s();
|
|
129
|
+
for (var e in f) p(e.split("|"), g) && !d(f[e], g) && (f[e] = []);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
e = e[i] ? e : [e];
|
|
133
|
+
var r = t && t.call,
|
|
134
|
+
s = r ? t : n,
|
|
135
|
+
o = r ? e.join("") : t,
|
|
136
|
+
h = e.length;
|
|
137
|
+
return (
|
|
138
|
+
setTimeout(function () {
|
|
139
|
+
d(e, function t(e, n) {
|
|
140
|
+
if (e === null) return y();
|
|
141
|
+
/*!n &&
|
|
142
|
+
!/^https?:\/\//.test(e) &&
|
|
143
|
+
c &&
|
|
144
|
+
(e = e.indexOf(".js") === -1 ? c + e + ".js" : c + e);*/
|
|
145
|
+
if (l[e])
|
|
146
|
+
return (
|
|
147
|
+
o && (a[o] = 1),
|
|
148
|
+
l[e] == 2
|
|
149
|
+
? y()
|
|
150
|
+
: setTimeout(function () {
|
|
151
|
+
t(e, !0);
|
|
152
|
+
}, 0)
|
|
153
|
+
);
|
|
154
|
+
(l[e] = 1), o && (a[o] = 1), m(e, y);
|
|
155
|
+
});
|
|
156
|
+
}, 0),
|
|
157
|
+
v
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
function m(n, r) {
|
|
161
|
+
var i = e.createElement("script"),
|
|
162
|
+
u;
|
|
163
|
+
(i.onload =
|
|
164
|
+
i.onerror =
|
|
165
|
+
i[o] =
|
|
166
|
+
function () {
|
|
167
|
+
if ((i[s] && !/^c|loade/.test(i[s])) || u) return;
|
|
168
|
+
(i.onload = i[o] = null), (u = 1), (l[n] = 2), r();
|
|
169
|
+
}),
|
|
170
|
+
(i.async = 1),
|
|
171
|
+
i.setAttribute("crossorigin", "anonymous"),
|
|
172
|
+
i.setAttribute("data-permanent", 1),
|
|
173
|
+
(i.src = h ? n + (n.indexOf("?") === -1 ? "?" : "&") + h : n),
|
|
174
|
+
t.insertBefore(i, t.lastChild);
|
|
175
|
+
}
|
|
176
|
+
var e = document,
|
|
177
|
+
t = e.getElementsByTagName("head")[0],
|
|
178
|
+
n = "string",
|
|
179
|
+
r = !1,
|
|
180
|
+
i = "push",
|
|
181
|
+
s = "readyState",
|
|
182
|
+
o = "onreadystatechange",
|
|
183
|
+
u = {},
|
|
184
|
+
a = {},
|
|
185
|
+
f = {},
|
|
186
|
+
l = {},
|
|
187
|
+
c,
|
|
188
|
+
h;
|
|
189
|
+
return (
|
|
190
|
+
(v.get = m),
|
|
191
|
+
(v.order = function (e, t, n) {
|
|
192
|
+
(function r(i) {
|
|
193
|
+
(i = e.shift()), e.length ? v(i, r) : v(i, t, n);
|
|
194
|
+
})();
|
|
195
|
+
}),
|
|
196
|
+
(v.path = function (e) {
|
|
197
|
+
c = e;
|
|
198
|
+
}),
|
|
199
|
+
(v.urlArgs = function (e) {
|
|
200
|
+
h = e;
|
|
201
|
+
}),
|
|
202
|
+
(v.ready = function (e, t, n) {
|
|
203
|
+
e = e[i] ? e : [e];
|
|
204
|
+
var r = [];
|
|
205
|
+
return (
|
|
206
|
+
!d(e, function (e) {
|
|
207
|
+
u[e] || r[i](e);
|
|
208
|
+
}) &&
|
|
209
|
+
p(e, function (e) {
|
|
210
|
+
return u[e];
|
|
211
|
+
})
|
|
212
|
+
? t()
|
|
213
|
+
: !(function (e) {
|
|
214
|
+
(f[e] = f[e] || []), f[e][i](t), n && n(r);
|
|
215
|
+
})(e.join("|")),
|
|
216
|
+
v
|
|
217
|
+
);
|
|
218
|
+
}),
|
|
219
|
+
(v.done = function (e) {
|
|
220
|
+
v([null], e);
|
|
221
|
+
}),
|
|
222
|
+
v
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
(function (n, t) {
|
|
227
|
+
this[n] = t();
|
|
228
|
+
})("sbea", function () {
|
|
229
|
+
return function (x) {
|
|
230
|
+
beas = x;
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
(function (n, t) {
|
|
235
|
+
this[n] = t();
|
|
236
|
+
})("Reactor", function () {
|
|
237
|
+
return function (o) {
|
|
238
|
+
appSettings = o;
|
|
239
|
+
if (o.Base) beas = o.Base;
|
|
240
|
+
else {
|
|
241
|
+
var getUrl = window.location;
|
|
242
|
+
var baseUrl = getUrl.protocol + "//" + getUrl.host + "/";
|
|
243
|
+
if (o.subDirectory) baseUrl = baseUrl + o.subDirectory + "/";
|
|
244
|
+
appSettings.Base = baseUrl;
|
|
245
|
+
}
|
|
246
|
+
if (o.App) execEl = o.App;
|
|
247
|
+
if (o.Additional) {
|
|
248
|
+
bea([o.Additional], "ready", function () { });
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
var fullTB = [
|
|
254
|
+
{
|
|
255
|
+
items: [
|
|
256
|
+
"Source",
|
|
257
|
+
"-",
|
|
258
|
+
"searchCode",
|
|
259
|
+
"autoFormat",
|
|
260
|
+
"CommentSelectedRange",
|
|
261
|
+
"UncommentSelectedRange",
|
|
262
|
+
"AutoComplete",
|
|
263
|
+
"-",
|
|
264
|
+
"Save",
|
|
265
|
+
"NewPage",
|
|
266
|
+
"Preview",
|
|
267
|
+
"Print",
|
|
268
|
+
"-",
|
|
269
|
+
"Templates",
|
|
270
|
+
"-",
|
|
271
|
+
"Cut",
|
|
272
|
+
"Copy",
|
|
273
|
+
"Paste",
|
|
274
|
+
"PasteText",
|
|
275
|
+
"PasteFromWord",
|
|
276
|
+
"PasteCode",
|
|
277
|
+
"-",
|
|
278
|
+
"Undo",
|
|
279
|
+
"Redo",
|
|
280
|
+
"-",
|
|
281
|
+
"SelectAll",
|
|
282
|
+
"-",
|
|
283
|
+
"Find",
|
|
284
|
+
"-",
|
|
285
|
+
"Image",
|
|
286
|
+
"CodeSnippet",
|
|
287
|
+
"Flash",
|
|
288
|
+
"Table",
|
|
289
|
+
"HorizontalRule",
|
|
290
|
+
"Smiley",
|
|
291
|
+
"SpecialChar",
|
|
292
|
+
"PageBreak",
|
|
293
|
+
"Iframe",
|
|
294
|
+
"VideoDetector",
|
|
295
|
+
"-",
|
|
296
|
+
"Blockquote",
|
|
297
|
+
"CreateDiv",
|
|
298
|
+
"simplebutton",
|
|
299
|
+
"-",
|
|
300
|
+
"Link",
|
|
301
|
+
"Unlink",
|
|
302
|
+
"Anchor",
|
|
303
|
+
"-",
|
|
304
|
+
"TextColor",
|
|
305
|
+
"BGColor",
|
|
306
|
+
"-",
|
|
307
|
+
"Bold",
|
|
308
|
+
"Italic",
|
|
309
|
+
"Underline",
|
|
310
|
+
"Strike",
|
|
311
|
+
"Subscript",
|
|
312
|
+
"Superscript",
|
|
313
|
+
"-",
|
|
314
|
+
"JustifyLeft",
|
|
315
|
+
"JustifyCenter",
|
|
316
|
+
"JustifyRight",
|
|
317
|
+
"JustifyBlock",
|
|
318
|
+
"-",
|
|
319
|
+
"BidiLtr",
|
|
320
|
+
"BidiRtl",
|
|
321
|
+
"-",
|
|
322
|
+
"NumberedList",
|
|
323
|
+
"BulletedList",
|
|
324
|
+
"-",
|
|
325
|
+
"Outdent",
|
|
326
|
+
"Indent",
|
|
327
|
+
"-",
|
|
328
|
+
"CopyFormatting",
|
|
329
|
+
"RemoveFormat",
|
|
330
|
+
"-",
|
|
331
|
+
"lineheight",
|
|
332
|
+
"letterspacing",
|
|
333
|
+
"Styles",
|
|
334
|
+
"Format",
|
|
335
|
+
"Font",
|
|
336
|
+
"FontSize",
|
|
337
|
+
"-",
|
|
338
|
+
"ShowBlocks",
|
|
339
|
+
],
|
|
340
|
+
},
|
|
341
|
+
];
|
|
342
|
+
|
|
343
|
+
var normalTB = [
|
|
344
|
+
{
|
|
345
|
+
name: "basicstyles",
|
|
346
|
+
groups: ["basicstyles", "cleanup"],
|
|
347
|
+
items: [
|
|
348
|
+
"Bold",
|
|
349
|
+
"Italic",
|
|
350
|
+
"Underline",
|
|
351
|
+
"Strike",
|
|
352
|
+
"Subscript",
|
|
353
|
+
"Superscript",
|
|
354
|
+
"-",
|
|
355
|
+
"JustifyLeft",
|
|
356
|
+
"JustifyCenter",
|
|
357
|
+
"JustifyRight",
|
|
358
|
+
"JustifyBlock",
|
|
359
|
+
"-",
|
|
360
|
+
"BidiLtr",
|
|
361
|
+
"BidiRtl",
|
|
362
|
+
"Language",
|
|
363
|
+
"-",
|
|
364
|
+
"Undo",
|
|
365
|
+
"Redo",
|
|
366
|
+
"-",
|
|
367
|
+
"SelectAll",
|
|
368
|
+
"-",
|
|
369
|
+
"CopyFormatting",
|
|
370
|
+
"RemoveFormat",
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
"/",
|
|
374
|
+
{
|
|
375
|
+
items: [
|
|
376
|
+
"Find",
|
|
377
|
+
"-",
|
|
378
|
+
"Image",
|
|
379
|
+
"Table",
|
|
380
|
+
"HorizontalRule",
|
|
381
|
+
"Smiley",
|
|
382
|
+
"SpecialChar",
|
|
383
|
+
"Iframe",
|
|
384
|
+
"VideoDetector",
|
|
385
|
+
"-",
|
|
386
|
+
"Link",
|
|
387
|
+
"Unlink",
|
|
388
|
+
"Anchor",
|
|
389
|
+
],
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
name: "paragraph",
|
|
393
|
+
groups: ["list", "indent", "blocks", "align", "bidi"],
|
|
394
|
+
items: [
|
|
395
|
+
"TextColor",
|
|
396
|
+
"BGColor",
|
|
397
|
+
"-",
|
|
398
|
+
"NumberedList",
|
|
399
|
+
"BulletedList",
|
|
400
|
+
"-",
|
|
401
|
+
"Outdent",
|
|
402
|
+
"Indent",
|
|
403
|
+
],
|
|
404
|
+
},
|
|
405
|
+
"/",
|
|
406
|
+
{
|
|
407
|
+
name: "styles",
|
|
408
|
+
items: [
|
|
409
|
+
"lineheight",
|
|
410
|
+
"letterspacing",
|
|
411
|
+
"Styles",
|
|
412
|
+
"Format",
|
|
413
|
+
"Font",
|
|
414
|
+
"FontSize",
|
|
415
|
+
],
|
|
416
|
+
},
|
|
417
|
+
];
|
|
418
|
+
|
|
419
|
+
var miniTB = [
|
|
420
|
+
{
|
|
421
|
+
name: "basicstyles",
|
|
422
|
+
groups: ["basicstyles", "cleanup"],
|
|
423
|
+
items: [
|
|
424
|
+
"Bold",
|
|
425
|
+
"Italic",
|
|
426
|
+
"Underline",
|
|
427
|
+
"Strike",
|
|
428
|
+
"Subscript",
|
|
429
|
+
"Superscript",
|
|
430
|
+
"-",
|
|
431
|
+
"JustifyLeft",
|
|
432
|
+
"JustifyCenter",
|
|
433
|
+
"JustifyRight",
|
|
434
|
+
"JustifyBlock",
|
|
435
|
+
"-",
|
|
436
|
+
"BidiLtr",
|
|
437
|
+
"BidiRtl",
|
|
438
|
+
"Language",
|
|
439
|
+
"-",
|
|
440
|
+
"Link",
|
|
441
|
+
"Unlink",
|
|
442
|
+
"Anchor",
|
|
443
|
+
"-",
|
|
444
|
+
"CopyFormatting",
|
|
445
|
+
"RemoveFormat",
|
|
446
|
+
],
|
|
447
|
+
},
|
|
448
|
+
"/",
|
|
449
|
+
{
|
|
450
|
+
name: "paragraph",
|
|
451
|
+
groups: ["list", "indent", "blocks", "align", "bidi"],
|
|
452
|
+
items: [
|
|
453
|
+
"TextColor",
|
|
454
|
+
"BGColor",
|
|
455
|
+
"-",
|
|
456
|
+
"NumberedList",
|
|
457
|
+
"BulletedList",
|
|
458
|
+
"-",
|
|
459
|
+
"Outdent",
|
|
460
|
+
"Indent",
|
|
461
|
+
],
|
|
462
|
+
},
|
|
463
|
+
{ name: "styles", items: ["Styles", "Format", "Font", "FontSize"] },
|
|
464
|
+
];
|
|
465
|
+
|
|
466
|
+
(function (submit) {
|
|
467
|
+
HTMLFormElement.prototype.submit = function (data) {
|
|
468
|
+
$(this).submit();
|
|
469
|
+
return false;
|
|
470
|
+
// submit.call(this, data);
|
|
471
|
+
};
|
|
472
|
+
})(HTMLFormElement.prototype.submit);
|
|
473
|
+
|
|
474
|
+
HTMLElement.prototype.setAttributeNative = HTMLElement.prototype.setAttribute;
|
|
475
|
+
HTMLElement.prototype.removeAttributeNative = HTMLElement.prototype.removeAttribute;
|
|
476
|
+
HTMLElement.prototype.getAttributeNative = HTMLElement.prototype.getAttribute;
|
|
477
|
+
(function (setAttribute) {
|
|
478
|
+
HTMLElement.prototype.setAttribute = function (prop, val) {
|
|
479
|
+
if (prop.substr(0, 1) == "@") {
|
|
480
|
+
try {
|
|
481
|
+
this.events[prop] = val;
|
|
482
|
+
} catch (e) {
|
|
483
|
+
|
|
484
|
+
}
|
|
485
|
+
} else {
|
|
486
|
+
this.setAttributeNative(prop, val);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
})(HTMLElement.prototype.setAttribute);
|
|
490
|
+
(function (removeAttribute) {
|
|
491
|
+
HTMLElement.prototype.removeAttribute = function (prop, val) {
|
|
492
|
+
if (prop.substr(0, 1) == "@") {
|
|
493
|
+
try {
|
|
494
|
+
delete this.events[prop];
|
|
495
|
+
} catch (e) {
|
|
496
|
+
|
|
497
|
+
}
|
|
498
|
+
} else {
|
|
499
|
+
this.removeAttributeNative(prop, val);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
})(HTMLElement.prototype.removeAttribute);
|
|
503
|
+
(function (getAttribute) {
|
|
504
|
+
HTMLElement.prototype.getAttribute = function (prop, val) {
|
|
505
|
+
if (prop.substr(0, 1) == "@") {
|
|
506
|
+
try {
|
|
507
|
+
return this.events[prop];
|
|
508
|
+
} catch (e) {
|
|
509
|
+
return this.getAttributeNative(prop, val);
|
|
510
|
+
}
|
|
511
|
+
} else {
|
|
512
|
+
return this.getAttributeNative(prop, val);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
})(HTMLElement.prototype.getAttribute);
|
|
516
|
+
|
|
517
|
+
/*jolie */
|
|
518
|
+
// (function(){
|
|
519
|
+
// // Store a reference to the original remove method.
|
|
520
|
+
// var originalRemoveMethod = jQuery.fn.append;
|
|
521
|
+
// // Define overriding method.
|
|
522
|
+
// jQuery.fn.append = function(){
|
|
523
|
+
// cl("arguments ",arguments)
|
|
524
|
+
// // Execute the original method.
|
|
525
|
+
// // originalRemoveMethod.apply( this, arguments);
|
|
526
|
+
// }
|
|
527
|
+
// })();
|
|
528
|
+
|
|
529
|
+
var XHRs = new Array();
|
|
530
|
+
if (localStorage.getItem("globals") === null)
|
|
531
|
+
localStorage.setItem("globals", JSON.stringify({}));
|
|
532
|
+
if (localStorage.getItem("_rx") === null)
|
|
533
|
+
localStorage.setItem("_rx", JSON.stringify({}));
|
|
534
|
+
var globals = clone(JSON.parse(localStorage.getItem("globals")));
|
|
535
|
+
let _rx = clone(JSON.parse(localStorage.getItem("_rx")));
|
|
536
|
+
var watch = {};
|
|
537
|
+
var popups = {
|
|
538
|
+
"modals": [],
|
|
539
|
+
"react-modals": [],
|
|
540
|
+
};
|
|
541
|
+
var cntrlon = 0;
|
|
542
|
+
var _gn = 0,
|
|
543
|
+
_worker;
|
|
544
|
+
var nodes = [];
|
|
545
|
+
|
|
546
|
+
var _jsuid = {};
|
|
547
|
+
// 'use strict';
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
// _jswacrk.on('msg', function (e) {
|
|
551
|
+
// let data = e.originalEvent.data;
|
|
552
|
+
// _vuid[data.key].resolve(data);
|
|
553
|
+
// });
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
function clone(item) {
|
|
557
|
+
if (!item) {
|
|
558
|
+
return item;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
var types = [Number, String, Boolean],
|
|
562
|
+
result;
|
|
563
|
+
|
|
564
|
+
types.forEach(function (type) {
|
|
565
|
+
if (item instanceof type) {
|
|
566
|
+
result = type(item);
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
if (typeof result == "undefined") {
|
|
571
|
+
if (Object.prototype.toString.call(item) === "[object Array]") {
|
|
572
|
+
result = [];
|
|
573
|
+
item.forEach(function (child, index, array) {
|
|
574
|
+
result[index] = clone(child);
|
|
575
|
+
});
|
|
576
|
+
} else if (typeof item == "object") {
|
|
577
|
+
if (item.nodeType && typeof item.cloneNode == "function") {
|
|
578
|
+
result = item.cloneNode(true);
|
|
579
|
+
} else if (!item.prototype) {
|
|
580
|
+
if (item instanceof Date) {
|
|
581
|
+
result = new Date(item);
|
|
582
|
+
} else {
|
|
583
|
+
result = {};
|
|
584
|
+
for (var i in item) {
|
|
585
|
+
result[i] = clone(item[i]);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
} else {
|
|
589
|
+
if (false && item.constructor) {
|
|
590
|
+
result = new item.constructor();
|
|
591
|
+
} else {
|
|
592
|
+
result = item;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
} else {
|
|
596
|
+
result = item;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return result;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function isInput(o) {
|
|
604
|
+
if (
|
|
605
|
+
o.is(":checkbox") ||
|
|
606
|
+
o.is("input") ||
|
|
607
|
+
o.is("textarea") ||
|
|
608
|
+
o.is(":radio") ||
|
|
609
|
+
o.is("select")
|
|
610
|
+
)
|
|
611
|
+
return true;
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function getVal(o) {
|
|
616
|
+
if (isInput(o)) {
|
|
617
|
+
return $.trim(o.val());
|
|
618
|
+
}
|
|
619
|
+
return o.html();
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function setVal(o, v) {
|
|
623
|
+
if (isInput(o)) {
|
|
624
|
+
o.val(v);
|
|
625
|
+
} else o.html(v);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function iterateConditions(text) {
|
|
629
|
+
var results = [];
|
|
630
|
+
var opts = text.split("##");
|
|
631
|
+
var iff = opts.shift();
|
|
632
|
+
opts = opts.join("##");
|
|
633
|
+
if (opts.indexOf("#else#") > -1) var hasElse = true;
|
|
634
|
+
if (opts.indexOf("#elseif#") > -1) var hasElseIfs = true;
|
|
635
|
+
if (hasElse) {
|
|
636
|
+
opts = opts.split("#else#");
|
|
637
|
+
var elsee = opts.pop();
|
|
638
|
+
opts = opts.join("");
|
|
639
|
+
}
|
|
640
|
+
if (hasElseIfs) {
|
|
641
|
+
results["elseif"] = [];
|
|
642
|
+
var elseifs = opts.split("#elseif#");
|
|
643
|
+
var ifOpts = elseifs.shift();
|
|
644
|
+
results["if"] = { cond: iff, val: ifOpts };
|
|
645
|
+
for (var index = 0; index < elseifs.length; index++) {
|
|
646
|
+
var elf = elseifs[index].split("##");
|
|
647
|
+
results["elseif"].push({ cond: elf[0], val: elf[1] });
|
|
648
|
+
}
|
|
649
|
+
if (hasElse) results["else"] = elsee;
|
|
650
|
+
} else if (hasElse) {
|
|
651
|
+
results["if"] = { cond: iff, val: opts };
|
|
652
|
+
if (hasElse) results["else"] = elsee;
|
|
653
|
+
} else {
|
|
654
|
+
results["if"] = { cond: iff, val: opts };
|
|
655
|
+
}
|
|
656
|
+
return results;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function wait() {
|
|
660
|
+
_loader.show();
|
|
661
|
+
_initialized = false;
|
|
662
|
+
}
|
|
663
|
+
function resume() {
|
|
664
|
+
_loader.hide();
|
|
665
|
+
_initialized = true;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const pause = (msec) => new Promise((resolve, _) => {
|
|
669
|
+
setTimeout(resolve, msec);
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// 2026-09-14: guarded against firing before Reactor() has run (which sets
|
|
673
|
+
// appSettings, read by getURLNodes() below) — found testing a real project
|
|
674
|
+
// end-to-end. $(document).ready() fires SYNCHRONOUSLY, at registration
|
|
675
|
+
// time, whenever the document is already non-"loading" by the time this
|
|
676
|
+
// line runs, which this framework's own single, large concatenated bundle
|
|
677
|
+
// reliably triggers in practice. index.js (the only thing that calls
|
|
678
|
+
// Reactor()) is loaded and run separately — see index-bootstrap.js — and
|
|
679
|
+
// there's no ordering guarantee between that and this registration.
|
|
680
|
+
// Retries on a short timer instead, matching the same "hasn't loaded yet"
|
|
681
|
+
// pattern renderView() already uses elsewhere in this codebase.
|
|
682
|
+
function _lumenReadyHandler() {
|
|
683
|
+
if (typeof appSettings === 'undefined' || !appSettings) {
|
|
684
|
+
setTimeout(_lumenReadyHandler, 10);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
nodes = getURLNodes();
|
|
688
|
+
|
|
689
|
+
if (_initialized == null) _initialized = true;
|
|
690
|
+
$("html").removeClass("no_js");
|
|
691
|
+
// $('script:not("[tpl],[type="beajs"],[_dd]")').remove();
|
|
692
|
+
if (!$("[exec]").length)
|
|
693
|
+
$("body").append({ beajs: true, body: "<div exec class=h></div>" });
|
|
694
|
+
$(document).keyup(function (e) {
|
|
695
|
+
cntrlon = 0;
|
|
696
|
+
});
|
|
697
|
+
$(document).keydown(function (e) {
|
|
698
|
+
if (e.ctrlKey || e.metaKey) {
|
|
699
|
+
cntrlon = 1;
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
goToNode();
|
|
703
|
+
}
|
|
704
|
+
$(document).ready(_lumenReadyHandler);
|
|
705
|
+
|
|
706
|
+
function updateLocalVariable(k) {
|
|
707
|
+
if (k == "_rx") _rx = clone(JSON.parse(localStorage.getItem("_rx")));
|
|
708
|
+
else globals = clone(JSON.parse(localStorage.getItem("globals")));
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function setGlobals(x) {
|
|
712
|
+
localStorage.setItem("globals", JSON.stringify(x));
|
|
713
|
+
globals = clone(JSON.parse(localStorage.getItem("globals")));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function setRX(x) {
|
|
717
|
+
localStorage.setItem("_rx", JSON.stringify(x));
|
|
718
|
+
_rx = clone(JSON.parse(localStorage.getItem("_rx")));
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
$(window).on("storage", function (e) {
|
|
722
|
+
if (e.originalEvent.key == "globals") {
|
|
723
|
+
if (localStorage.getItem("globals") != null) updateLocalVariable();
|
|
724
|
+
else setGlobals(globals);
|
|
725
|
+
} else if (e.originalEvent.key == "_rx") {
|
|
726
|
+
if (localStorage.getItem("_rx") != null) updateLocalVariable("_rx");
|
|
727
|
+
else setRX(_rx);
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
var _work = function () {
|
|
732
|
+
if (!$(".prog").length)
|
|
733
|
+
$("body").append(
|
|
734
|
+
'<div class="prog"><div class=bar role=bar></div><div class=spinner role=spinner><div class="spinner-icon"></div></div></div>'
|
|
735
|
+
);
|
|
736
|
+
_worker = setTimeout(function () {
|
|
737
|
+
_gn = incri(_gn);
|
|
738
|
+
barSet(_gn, 200);
|
|
739
|
+
_work();
|
|
740
|
+
}, 200);
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
$(document)
|
|
744
|
+
.ajaxStart(function () {
|
|
745
|
+
_gn = 0;
|
|
746
|
+
_work();
|
|
747
|
+
if (typeof heartbeat === "function") heartbeat();
|
|
748
|
+
})
|
|
749
|
+
.ajaxStop(function () {
|
|
750
|
+
_gn = 0;
|
|
751
|
+
barSet(1, 200);
|
|
752
|
+
if (typeof heartbeat === "function") heartbeat();
|
|
753
|
+
globalWatch();
|
|
754
|
+
})
|
|
755
|
+
.ajaxError(function (e, xhr, opt) {
|
|
756
|
+
if (xhr.statusText == "error") {
|
|
757
|
+
if (xhr.status == "422") $("[exec]").html(xhr.responseText);
|
|
758
|
+
else if (xhr.status == "0") {
|
|
759
|
+
$("[dropzone].pending").removeClass("pending").addClass("error");
|
|
760
|
+
$("body").addClass("no-internet-connection");
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (typeof heartbeat === "function") heartbeat();
|
|
764
|
+
globalWatch();
|
|
765
|
+
_gn = 0;
|
|
766
|
+
barSet(1, 200);
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
(function ($) {
|
|
770
|
+
$.extend({
|
|
771
|
+
inArrayIn: function (elem, arr, i) {
|
|
772
|
+
if (typeof elem !== "string") {
|
|
773
|
+
return $.inArray.apply(this, arguments);
|
|
774
|
+
}
|
|
775
|
+
if (arr) {
|
|
776
|
+
var len = arr.length;
|
|
777
|
+
i = i ? (i < 0 ? Math.max(0, len + i) : i) : 0;
|
|
778
|
+
elem = elem.toLowerCase();
|
|
779
|
+
for (; i < len; i++) {
|
|
780
|
+
if (i in arr && arr[i].toLowerCase() == elem) {
|
|
781
|
+
return i;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return -1;
|
|
786
|
+
},
|
|
787
|
+
});
|
|
788
|
+
})(jQuery);
|
|
789
|
+
|
|
790
|
+
$.fn.priorityOn = function (type, selector, data, fn) {
|
|
791
|
+
this.each(function () {
|
|
792
|
+
var $this = $(this);
|
|
793
|
+
|
|
794
|
+
var types = type.split(" ");
|
|
795
|
+
|
|
796
|
+
for (var t in types) {
|
|
797
|
+
$this.on(types[t], selector, data, fn);
|
|
798
|
+
|
|
799
|
+
var currentBindings = $._data(this, "events")[types[t]];
|
|
800
|
+
if ($.isArray(currentBindings)) {
|
|
801
|
+
currentBindings.unshift(currentBindings.pop());
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
return this;
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
$.fn.onClose = function (selector, data, fn) {
|
|
809
|
+
this.each(function () {
|
|
810
|
+
var el = $(this);
|
|
811
|
+
var types = ["close"];
|
|
812
|
+
for (var t in types) {
|
|
813
|
+
el.on(types[t], selector, data, fn);
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
return this;
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
$.fn.attach = function (type, selector, data, fn) {
|
|
820
|
+
var el = $(this);
|
|
821
|
+
var types = type.split(" ");
|
|
822
|
+
for (var t in types) {
|
|
823
|
+
var lu =
|
|
824
|
+
"$.fn.on" +
|
|
825
|
+
types[t] +
|
|
826
|
+
" = function (selector, data, fn) {" +
|
|
827
|
+
"" +
|
|
828
|
+
" var el = $(this);" +
|
|
829
|
+
' var types = ["' +
|
|
830
|
+
types[t] +
|
|
831
|
+
'"];' +
|
|
832
|
+
" for (var t in types) {" +
|
|
833
|
+
" el.live(types[t], selector, data, fn);" +
|
|
834
|
+
" }" +
|
|
835
|
+
" return this;" +
|
|
836
|
+
"};";
|
|
837
|
+
try {
|
|
838
|
+
eval(lu);
|
|
839
|
+
} catch (e) { }
|
|
840
|
+
}
|
|
841
|
+
return this;
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
$.fn.hasAttr = function (k) {
|
|
845
|
+
return this.attr(k) !== undefined;
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
$.fn.hasKey = function (k) {
|
|
849
|
+
return typeof this.data(k) !== "undefined";
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
function dotsIntoObjs(keys, value) {
|
|
853
|
+
var tempObject = {};
|
|
854
|
+
var container = tempObject;
|
|
855
|
+
keys.split(".").map((k, i, values) => {
|
|
856
|
+
container = container[k] = i == values.length - 1 ? value : {};
|
|
857
|
+
});
|
|
858
|
+
return tempObject;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
$.fn.set = function (name, value) {
|
|
862
|
+
var splitter = name.split(".");
|
|
863
|
+
if (splitter.length > 1) {
|
|
864
|
+
var key = splitter.shift();
|
|
865
|
+
return this.data(key, dotsIntoObjs(splitter.join("."), value));
|
|
866
|
+
}
|
|
867
|
+
return this.data(name, value);
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
$.fn.props = function () {
|
|
871
|
+
return this.data("props");
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
$.fn.scope = function (_sview) {
|
|
875
|
+
var _scopedVariables = _sview(this, this.data("props") ?? {}) ?? {};
|
|
876
|
+
for (var x = 0; x < Object.keys(_scopedVariables).length; x++) {
|
|
877
|
+
var _key = Object.keys(_scopedVariables)[x];
|
|
878
|
+
var val = _scopedVariables[_key];
|
|
879
|
+
this.set(_key, val);
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
$.fn.isOverflown = function () {
|
|
884
|
+
return (
|
|
885
|
+
$(this)[0].scrollHeight > $(this)[0].clientHeight ||
|
|
886
|
+
$(this)[0].scrollWidth > $(this)[0].clientWidth
|
|
887
|
+
);
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
function removeEmptyElement(arr) {
|
|
891
|
+
var filtered = arr.filter(function (el) {
|
|
892
|
+
return el;
|
|
893
|
+
});
|
|
894
|
+
return filtered;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
function findInObject(object, property, value) {
|
|
898
|
+
for (var i = 0; i < object.length; i += 1) {
|
|
899
|
+
if (object[i][property] === value) {
|
|
900
|
+
return i;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
function compareUs(object1, object2) {
|
|
906
|
+
var areObjects = isObject(object1) && isObject(object2);
|
|
907
|
+
if (!areObjects) {
|
|
908
|
+
if (typeof object1 == "number" && typeof object2 == "number") {
|
|
909
|
+
if (isNaN(object1) && isNaN(object2)) return true;
|
|
910
|
+
}
|
|
911
|
+
return object1 == object2;
|
|
912
|
+
}
|
|
913
|
+
const keys1 = Object.keys(object1);
|
|
914
|
+
const keys2 = Object.keys(object2);
|
|
915
|
+
if (keys1.length !== keys2.length) {
|
|
916
|
+
return false;
|
|
917
|
+
}
|
|
918
|
+
// cl("compareUs", object1, object2);
|
|
919
|
+
for (const key of keys1) {
|
|
920
|
+
const val1 = object1[key];
|
|
921
|
+
const val2 = object2[key];
|
|
922
|
+
const areObjects = isObject(val1) && isObject(val2);
|
|
923
|
+
// cl("Aree", areObjects, val1, val2, compareUs(val1, val2));
|
|
924
|
+
if (
|
|
925
|
+
(areObjects && !compareUs(val1, val2)) ||
|
|
926
|
+
(!areObjects && val1 !== val2)
|
|
927
|
+
) {
|
|
928
|
+
return false;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return true;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function deepCompare(object1, object2, path = '') {
|
|
935
|
+
const areObjects = isObject(object1) && isObject(object2);
|
|
936
|
+
|
|
937
|
+
if (!areObjects) {
|
|
938
|
+
if (typeof object1 === "number" && typeof object2 === "number") {
|
|
939
|
+
if (isNaN(object1) && isNaN(object2)) {
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
if (object1 !== object2) {
|
|
945
|
+
// cl(`Difference at ${path}:`);
|
|
946
|
+
// cl(` - ${path}: ${object1}`);
|
|
947
|
+
// cl(` + ${path}: ${object2}`);
|
|
948
|
+
return false;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const keys1 = Object.keys(object1);
|
|
955
|
+
const keys2 = Object.keys(object2);
|
|
956
|
+
|
|
957
|
+
if (keys1.length !== keys2.length) {
|
|
958
|
+
// cl(`Difference at ${path}:`);
|
|
959
|
+
// cl(` - ${path}: ${keys1.length} keys`);
|
|
960
|
+
// cl(` + ${path}: ${keys2.length} keys`);
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
for (const key of keys1) {
|
|
965
|
+
const newPath = path ? `${path}.${key}` : key;
|
|
966
|
+
const val1 = object1[key];
|
|
967
|
+
const val2 = object2[key];
|
|
968
|
+
const areNestedObjects = isObject(val1) && isObject(val2);
|
|
969
|
+
|
|
970
|
+
if (!deepCompare(val1, val2, newPath)) {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
return true;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function isObject(object) {
|
|
979
|
+
return object != null && typeof object === "object";
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
(function (old) {
|
|
983
|
+
$.fn.attr = function () {
|
|
984
|
+
if (arguments.length === 0) {
|
|
985
|
+
if (this.length === 0) {
|
|
986
|
+
return null;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
var obj = {};
|
|
990
|
+
$.each(this[0].attributes, function () {
|
|
991
|
+
if (this.specified) {
|
|
992
|
+
obj[this.name] = this.value;
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
return obj;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
return old.apply(this, arguments);
|
|
999
|
+
};
|
|
1000
|
+
})($.fn.attr);
|
|
1001
|
+
|
|
1002
|
+
function st(b) {
|
|
1003
|
+
if (!isNaN(b))
|
|
1004
|
+
$("html,body")
|
|
1005
|
+
.stop()
|
|
1006
|
+
.animate({ scrollTop: b + "px" }, { duration: 400 });
|
|
1007
|
+
else
|
|
1008
|
+
$("html,body")
|
|
1009
|
+
.stop()
|
|
1010
|
+
.animate({ scrollTop: $(b).offset().top + "px" }, { duration: 400 });
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
function pushURL(url, d) {
|
|
1014
|
+
// url = url.toLowerCase();
|
|
1015
|
+
if (url || url == "") {
|
|
1016
|
+
if (history && history.pushState) {
|
|
1017
|
+
history.pushState(
|
|
1018
|
+
{},
|
|
1019
|
+
"",
|
|
1020
|
+
appSettings.Base + "/" + url.replace(new RegExp("^[" + "/" + "]+"), "")
|
|
1021
|
+
);
|
|
1022
|
+
goToNode(d);
|
|
1023
|
+
} else {
|
|
1024
|
+
parent.location.href = url;
|
|
1025
|
+
}
|
|
1026
|
+
} else {
|
|
1027
|
+
alert(url);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function formatBytes(bytes, decimals) {
|
|
1032
|
+
if (bytes == 0) return "0 Bytes";
|
|
1033
|
+
var k = 1024,
|
|
1034
|
+
dm = decimals <= 0 ? 0 : decimals || 2,
|
|
1035
|
+
sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
|
1036
|
+
i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1037
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
function passwordContainsSymbol(value) {
|
|
1041
|
+
var containsSymbol = false,
|
|
1042
|
+
symbols = "-!§$%&/()=?.:,~;'#+*-/\\|{}[]_<>\"".split("");
|
|
1043
|
+
|
|
1044
|
+
$.each(symbols, function (index, symbol) {
|
|
1045
|
+
if (value.indexOf(symbol) > -1) {
|
|
1046
|
+
containsSymbol = true;
|
|
1047
|
+
|
|
1048
|
+
return false;
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
return containsSymbol;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
function passwordStrength(pass) {
|
|
1056
|
+
var s = 0,
|
|
1057
|
+
n;
|
|
1058
|
+
|
|
1059
|
+
if (pass.length > 5) s += 10;
|
|
1060
|
+
if (/[a-z]/.test(pass)) s += 1;
|
|
1061
|
+
if (/[A-Z]/.test(pass)) s += 1;
|
|
1062
|
+
if (/[0-9]/.test(pass)) s += 1;
|
|
1063
|
+
if (passwordContainsSymbol(pass)) s += 1;
|
|
1064
|
+
|
|
1065
|
+
if (s == 14) n = "very-strong";
|
|
1066
|
+
else if (s == 13) n = "strong";
|
|
1067
|
+
else if (s == 12) n = "medium";
|
|
1068
|
+
else if (s == 11) n = "weak";
|
|
1069
|
+
else n = "";
|
|
1070
|
+
if (/\s/g.test(pass)) n = "has-spaces";
|
|
1071
|
+
|
|
1072
|
+
return n;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
function passwordValid(pass) {
|
|
1076
|
+
var n = passwordStrength(pass);
|
|
1077
|
+
if (n == "strong" || n == "very-strong") return true;
|
|
1078
|
+
return false;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
function incri(n) {
|
|
1082
|
+
var amount;
|
|
1083
|
+
if (n > 1) {
|
|
1084
|
+
return 0.994;
|
|
1085
|
+
} else {
|
|
1086
|
+
if (n >= 0 && n < 0.2) {
|
|
1087
|
+
amount = 0.1;
|
|
1088
|
+
} else if (n >= 0.2 && n < 0.5) {
|
|
1089
|
+
amount = 0.04;
|
|
1090
|
+
} else if (n >= 0.5 && n < 0.8) {
|
|
1091
|
+
amount = 0.02;
|
|
1092
|
+
} else if (n >= 0.8 && n < 0.99) {
|
|
1093
|
+
amount = 0.005;
|
|
1094
|
+
} else {
|
|
1095
|
+
amount = 0.0005;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
n = n + amount;
|
|
1099
|
+
if (n < 0.08) n = 0.08;
|
|
1100
|
+
else if (n > 0.994) n = 0.994;
|
|
1101
|
+
return n;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
function barSet(n, speed) {
|
|
1106
|
+
clearTimeout(_worker);
|
|
1107
|
+
if (n < 0.08) n = 0.08;
|
|
1108
|
+
else if (n > 1) n = 1;
|
|
1109
|
+
// cl(n);
|
|
1110
|
+
var bar = $('.bar[role="bar"]');
|
|
1111
|
+
// bar.css("margin-left");
|
|
1112
|
+
bar.css({
|
|
1113
|
+
transition: "all " + speed + "ms linear",
|
|
1114
|
+
"-webkit-transition": "all " + speed + "ms linear",
|
|
1115
|
+
"-moz-transition": "all " + speed + "ms linear",
|
|
1116
|
+
"-o-transition": "all " + speed + "ms linear",
|
|
1117
|
+
});
|
|
1118
|
+
if ($("body").hasClass("rtl"))
|
|
1119
|
+
bar.css({
|
|
1120
|
+
"margin-right": -100 + n * 100 + "%",
|
|
1121
|
+
});
|
|
1122
|
+
else
|
|
1123
|
+
bar.css({
|
|
1124
|
+
"margin-left": -100 + n * 100 + "%",
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
if (n == 1) {
|
|
1128
|
+
_worker = setTimeout(function () {
|
|
1129
|
+
$(".prog").animate(
|
|
1130
|
+
{ opacity: 0 },
|
|
1131
|
+
{
|
|
1132
|
+
duration: speed,
|
|
1133
|
+
complete: function () {
|
|
1134
|
+
$(".prog").remove();
|
|
1135
|
+
},
|
|
1136
|
+
}
|
|
1137
|
+
);
|
|
1138
|
+
}, speed);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function getFormData(form) {
|
|
1143
|
+
var unindexed_array = form.serializeArray();
|
|
1144
|
+
var indexed_array = {};
|
|
1145
|
+
$.map(unindexed_array, function (n, i) {
|
|
1146
|
+
if (n["name"].includes("[]")) {
|
|
1147
|
+
var key = n["name"].split("[]")[0];
|
|
1148
|
+
if (!indexed_array.hasOwnProperty(key)) indexed_array[key] = [];
|
|
1149
|
+
indexed_array[key].push(n["value"]);
|
|
1150
|
+
} else {
|
|
1151
|
+
indexed_array[n["name"]] = n["value"];
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
return indexed_array;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
$(window).on("popstate", function () {
|
|
1158
|
+
if (history && history.pushState) goToNode();
|
|
1159
|
+
});
|
|
1160
|
+
|
|
1161
|
+
var getLocation = function (href) {
|
|
1162
|
+
var l = document.createElement("a");
|
|
1163
|
+
l.href = href;
|
|
1164
|
+
return l;
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
function getURLNodes() {
|
|
1168
|
+
appSettings.Base = appSettings.Base.replace(
|
|
1169
|
+
new RegExp("[" + "/" + "]+$"),
|
|
1170
|
+
""
|
|
1171
|
+
);
|
|
1172
|
+
var base = getLocation(appSettings.Base);
|
|
1173
|
+
if (base.origin != window.location.origin) {
|
|
1174
|
+
appSettings.Base = window.location.origin + base.pathname;
|
|
1175
|
+
var base = getLocation(appSettings.Base);
|
|
1176
|
+
}
|
|
1177
|
+
var _nodes =
|
|
1178
|
+
base.pathname != "/"
|
|
1179
|
+
? window.location.pathname
|
|
1180
|
+
.split(base.pathname)
|
|
1181
|
+
.join("")
|
|
1182
|
+
.replace(new RegExp("^[" + "/" + "]+"), "")
|
|
1183
|
+
.split("/")
|
|
1184
|
+
: location.href
|
|
1185
|
+
.split(appSettings.Base)
|
|
1186
|
+
.join("")
|
|
1187
|
+
.replace(new RegExp("^[" + "/" + "]+"), "")
|
|
1188
|
+
.split("?")[0]
|
|
1189
|
+
.split("/");
|
|
1190
|
+
|
|
1191
|
+
// let authFunc = (appSettings.auth && typeof appSettings.auth === "function") ? appSettings.auth : (typeof Auth === "function" ? Auth : null);
|
|
1192
|
+
// if (typeof authFunc === 'function') authFunc();
|
|
1193
|
+
if (!_nodes[0]) _nodes[0] = appSettings.defaultView ?? "home";
|
|
1194
|
+
return _nodes;
|
|
1195
|
+
}
|
|
1196
|
+
var prevNodes = [];
|
|
1197
|
+
function goToNode(d) {
|
|
1198
|
+
if (_initialized) {
|
|
1199
|
+
prevNodes = clone(nodes);
|
|
1200
|
+
nodes = getURLNodes();
|
|
1201
|
+
renderView(nodes[0], null, d);
|
|
1202
|
+
} else {
|
|
1203
|
+
setTimeout(function () {
|
|
1204
|
+
goToNode(d);
|
|
1205
|
+
}, 100);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
var View = {};
|
|
1209
|
+
|
|
1210
|
+
function setError(e, t) {
|
|
1211
|
+
if (!e) {
|
|
1212
|
+
console.warn(t);
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
console.warn(t, e.message);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function renderTpl(el, n, vars) {
|
|
1219
|
+
if (!el.length) return;
|
|
1220
|
+
if (el.data("_status") == "error") return;
|
|
1221
|
+
if (!el.hasKey("_re")) {
|
|
1222
|
+
if (el.data("_status") == "pending") {
|
|
1223
|
+
getTpl(n, el, vars);
|
|
1224
|
+
}
|
|
1225
|
+
setTimeout(function () {
|
|
1226
|
+
renderTpl(el, n, vars);
|
|
1227
|
+
}, _tickTime);
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
function prepareNode(n, rep) {
|
|
1232
|
+
var _arr = n.split("/");
|
|
1233
|
+
if (_arr.length > 1) {
|
|
1234
|
+
for (var i = _arr.length - 1; i >= _arr.length - 1; i--)
|
|
1235
|
+
_arr[i] = _arr[i];//.toLowerCase();
|
|
1236
|
+
n = _arr.join("/");
|
|
1237
|
+
} else n = n;//.toLowerCase();
|
|
1238
|
+
return rep ? n.replace(new RegExp("^[" + "/" + "]+"), "") : n;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
var _esps = {};
|
|
1242
|
+
var _Views = {};
|
|
1243
|
+
function setAppFuncs() {
|
|
1244
|
+
let initFunc =
|
|
1245
|
+
appSettings.init && typeof appSettings.init === "function"
|
|
1246
|
+
? appSettings.init
|
|
1247
|
+
: typeof init === "function"
|
|
1248
|
+
? init
|
|
1249
|
+
: null;
|
|
1250
|
+
if (typeof initFunc === "function") initFunc();
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
function getView(n, el, d) {
|
|
1255
|
+
let filePath = "src/views/" + n + ".view";
|
|
1256
|
+
let fileKey = btoa(filePath);
|
|
1257
|
+
if ($("body").hasKey("view_" + fileKey)) {
|
|
1258
|
+
renderView(n, el, d, true);
|
|
1259
|
+
} else {
|
|
1260
|
+
if (_vcData && _vcData["views"].hasOwnProperty(fileKey)) {
|
|
1261
|
+
$("body").data("view_" + fileKey, _vcData["views"][fileKey]);
|
|
1262
|
+
renderView(n, el, d, true);
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
if (Nuke && Nuke._ws && Nuke._ws.readyState) {
|
|
1266
|
+
Nuke.emit("getview", fileKey, function (e) {
|
|
1267
|
+
var r = e.data;
|
|
1268
|
+
$("body").data("view_" + fileKey, r);
|
|
1269
|
+
renderView(n, el, d, true);
|
|
1270
|
+
});
|
|
1271
|
+
} else {
|
|
1272
|
+
setTimeout(() => {
|
|
1273
|
+
getView(n, el, d);
|
|
1274
|
+
}, _tickTime);
|
|
1275
|
+
// prom.reject();
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// function getWidgets(settings, getWidgetsFiles, render) {
|
|
1281
|
+
// let count = 0,
|
|
1282
|
+
// promed = 0;
|
|
1283
|
+
// if (settings.hasFooter) {
|
|
1284
|
+
// count++;
|
|
1285
|
+
// var fileName = settings.hasFooter == true ? "footer" : settings.hasFooter;
|
|
1286
|
+
// if (render) renderWidget(fileName, "footer");
|
|
1287
|
+
// else {
|
|
1288
|
+
// var prom = defer();
|
|
1289
|
+
// getWidget(fileName, "footer", prom);
|
|
1290
|
+
// prom
|
|
1291
|
+
// .then(function (val) {
|
|
1292
|
+
// promed++;
|
|
1293
|
+
// if (promed == count) getWidgetsFiles.resolve();
|
|
1294
|
+
// })
|
|
1295
|
+
// .catch((reason) => {
|
|
1296
|
+
// promed++;
|
|
1297
|
+
// if (promed == count) getWidgetsFiles.resolve();
|
|
1298
|
+
// });
|
|
1299
|
+
// }
|
|
1300
|
+
// } else {
|
|
1301
|
+
// $("[footer]").html("");
|
|
1302
|
+
// }
|
|
1303
|
+
// if (settings.hasNav) {
|
|
1304
|
+
// count++;
|
|
1305
|
+
// var fileName = settings.hasNav == true ? "nav" : settings.hasNav;
|
|
1306
|
+
// if (render) renderWidget(fileName, "nav");
|
|
1307
|
+
// else {
|
|
1308
|
+
// var prom = defer();
|
|
1309
|
+
// getWidget(fileName, "nav", prom);
|
|
1310
|
+
// prom
|
|
1311
|
+
// .then(function (val) {
|
|
1312
|
+
// promed++;
|
|
1313
|
+
// if (promed == count) getWidgetsFiles.resolve();
|
|
1314
|
+
// })
|
|
1315
|
+
// .catch((reason) => {
|
|
1316
|
+
// promed++;
|
|
1317
|
+
// if (promed == count) getWidgetsFiles.resolve();
|
|
1318
|
+
// });
|
|
1319
|
+
// }
|
|
1320
|
+
// } else {
|
|
1321
|
+
// $("[nav]").html("");
|
|
1322
|
+
// }
|
|
1323
|
+
// if (settings.hasHeader) {
|
|
1324
|
+
// count++;
|
|
1325
|
+
// var fileName = settings.hasHeader == true ? "header" : settings.hasHeader;
|
|
1326
|
+
// if (render) renderWidget(fileName, "header");
|
|
1327
|
+
// else {
|
|
1328
|
+
// var prom = defer();
|
|
1329
|
+
// getWidget(fileName, "header", prom);
|
|
1330
|
+
// prom
|
|
1331
|
+
// .then(function (val) {
|
|
1332
|
+
// promed++;
|
|
1333
|
+
// if (promed == count) getWidgetsFiles.resolve();
|
|
1334
|
+
// })
|
|
1335
|
+
// .catch((reason) => {
|
|
1336
|
+
// promed++;
|
|
1337
|
+
// if (promed == count) getWidgetsFiles.resolve();
|
|
1338
|
+
// });
|
|
1339
|
+
// }
|
|
1340
|
+
// } else {
|
|
1341
|
+
// $("[header]").html("");
|
|
1342
|
+
// }
|
|
1343
|
+
// if (!count) getWidgetsFiles.resolve();
|
|
1344
|
+
// }
|
|
1345
|
+
|
|
1346
|
+
// function renderWidget(n, b) {
|
|
1347
|
+
// let filePath = "src/views/widgets/" + n + ".view";
|
|
1348
|
+
// let fileKey = btoa(filePath);
|
|
1349
|
+
// if ($("body").hasKey("view_" + fileKey)) {
|
|
1350
|
+
// var widget = $("body").data("view_" + fileKey);
|
|
1351
|
+
// if (
|
|
1352
|
+
// $("[" + b + "]").attr("kd") != fileKey ||
|
|
1353
|
+
// $("[" + b + "]").html() == "" ||
|
|
1354
|
+
// $("[" + b + "]").hasClass("_render")
|
|
1355
|
+
// )
|
|
1356
|
+
// $("[" + b + "]")
|
|
1357
|
+
// .removeClass("_render")
|
|
1358
|
+
// .html(widget)
|
|
1359
|
+
// .attr("kd", fileKey);
|
|
1360
|
+
// } else {
|
|
1361
|
+
// cl("noooo", "view_" + fileKey);
|
|
1362
|
+
// }
|
|
1363
|
+
// }
|
|
1364
|
+
|
|
1365
|
+
// function getWidget(n, b, prom) {
|
|
1366
|
+
// let filePath = "src/views/widgets/" + n + ".view";
|
|
1367
|
+
// let fileKey = btoa(filePath);
|
|
1368
|
+
// if ($("body").hasKey("view_" + fileKey)) {
|
|
1369
|
+
// prom.resolve();
|
|
1370
|
+
// } else {
|
|
1371
|
+
// if (_vcData && _vcData["views"].hasOwnProperty(fileKey)) {
|
|
1372
|
+
// $("body").data("view_" + fileKey, _vcData["views"][fileKey]);
|
|
1373
|
+
// prom.resolve();
|
|
1374
|
+
// return;
|
|
1375
|
+
// }
|
|
1376
|
+
// if (Nuke && Nuke._ws && Nuke._ws.readyState) {
|
|
1377
|
+
// Nuke.emit("getview", fileKey, function (e) {
|
|
1378
|
+
// var r = e.data;
|
|
1379
|
+
// $("body").data("view_" + fileKey, r);
|
|
1380
|
+
// prom.resolve();
|
|
1381
|
+
// });
|
|
1382
|
+
// } else {
|
|
1383
|
+
// setTimeout(() => {
|
|
1384
|
+
// getWidget(n, b, prom);
|
|
1385
|
+
// }, _tickTime);
|
|
1386
|
+
// // prom.reject();
|
|
1387
|
+
// }
|
|
1388
|
+
// }
|
|
1389
|
+
// }
|
|
1390
|
+
|
|
1391
|
+
function fileToDataURL(file) {
|
|
1392
|
+
var reader = new FileReader();
|
|
1393
|
+
return new Promise(function (resolve, reject) {
|
|
1394
|
+
reader.onload = function (event) {
|
|
1395
|
+
resolve(event.target.result);
|
|
1396
|
+
};
|
|
1397
|
+
reader.readAsDataURL(file);
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function readFilesAsDataURL(files) {
|
|
1402
|
+
return Promise.all(files.map(fileToDataURL));
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
function defer() {
|
|
1406
|
+
var res, rej;
|
|
1407
|
+
var promise = new Promise((resolve, reject) => {
|
|
1408
|
+
res = resolve;
|
|
1409
|
+
rej = reject;
|
|
1410
|
+
});
|
|
1411
|
+
promise.resolve = res;
|
|
1412
|
+
promise.reject = rej;
|
|
1413
|
+
promise.success = res;
|
|
1414
|
+
promise.failed = rej;
|
|
1415
|
+
return promise;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
function getTpl(n, el, vaz) {
|
|
1419
|
+
// cl([n, el, vaz]);
|
|
1420
|
+
let filePath = "src/tpls/" + n + ".tpl";
|
|
1421
|
+
let fileKey = btoa(filePath);
|
|
1422
|
+
if (el.data("_status") != "pending") return;
|
|
1423
|
+
el.data("_status", "getting");
|
|
1424
|
+
if ($("body").hasKey("tpl_" + fileKey)) {
|
|
1425
|
+
let r = $("body").data("tpl_" + fileKey);
|
|
1426
|
+
el.html(r);
|
|
1427
|
+
if (!setRe(el, vaz)) setError(null, "Error in rendering template " + n);
|
|
1428
|
+
} else {
|
|
1429
|
+
if (_vcData && _vcData["tpls"].hasOwnProperty(fileKey)) {
|
|
1430
|
+
$("body").data("tpl_" + fileKey, _vcData["tpls"][fileKey]);
|
|
1431
|
+
el.html(_vcData["tpls"][fileKey]);
|
|
1432
|
+
if (!setRe(el, vaz)) setError(null, "Error in rendering template " + n);
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
if (Nuke && Nuke._ws && Nuke._ws.readyState) {
|
|
1436
|
+
Nuke.emit("gettpl", fileKey, function (e) {
|
|
1437
|
+
var r = e.data;
|
|
1438
|
+
$("body").data("tpl_" + fileKey, r);
|
|
1439
|
+
el.html(r);
|
|
1440
|
+
if (!setRe(el, vaz)) setError(null, "Error in rendering template " + n);
|
|
1441
|
+
});
|
|
1442
|
+
} else {
|
|
1443
|
+
setTimeout(() => {
|
|
1444
|
+
getTpl(n, el, vaz);
|
|
1445
|
+
}, _tickTime);
|
|
1446
|
+
// prom.reject();
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
function setRe(_el, vaz) {
|
|
1452
|
+
try {
|
|
1453
|
+
if (!_el.hasKey("_vars")) {
|
|
1454
|
+
if (_debugMode) cl("The Data Arrived", vaz);
|
|
1455
|
+
let data = {};
|
|
1456
|
+
let vars = vaz.split(",");
|
|
1457
|
+
vars = vars.map((s) => s.trim());
|
|
1458
|
+
|
|
1459
|
+
let binds = [];
|
|
1460
|
+
let dataNamesValues = [];
|
|
1461
|
+
|
|
1462
|
+
var _subView = _el.closest("[view]");
|
|
1463
|
+
|
|
1464
|
+
for (let x = 0; x < vars.length; x++) {
|
|
1465
|
+
if (vars[x] != "") {
|
|
1466
|
+
try {
|
|
1467
|
+
let varName = vars[x];
|
|
1468
|
+
let varValue = vars[x];
|
|
1469
|
+
let NameAs = null;
|
|
1470
|
+
|
|
1471
|
+
if (varName.indexOf(" as ") !== -1) {
|
|
1472
|
+
varName = varName.split(" as ");
|
|
1473
|
+
varValue = varName[0];
|
|
1474
|
+
varName = varName[1];
|
|
1475
|
+
NameAs = vars[x];
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
let val = "";
|
|
1479
|
+
if (_subView.length) {
|
|
1480
|
+
val = _subView.hasKey(varValue)
|
|
1481
|
+
? _subView.data(varValue)
|
|
1482
|
+
: eval(varValue);
|
|
1483
|
+
} else val = eval(varValue);
|
|
1484
|
+
dataNamesValues.push({
|
|
1485
|
+
Name: varName,
|
|
1486
|
+
NameAs: NameAs,
|
|
1487
|
+
Value: val,
|
|
1488
|
+
});
|
|
1489
|
+
} catch (e) {
|
|
1490
|
+
let varName = vars[x];
|
|
1491
|
+
let varValue = vars[x];
|
|
1492
|
+
let NameAs = null;
|
|
1493
|
+
|
|
1494
|
+
if (varName.indexOf(" as ") !== -1) {
|
|
1495
|
+
varName = varName.split(" as ");
|
|
1496
|
+
varValue = varName[0];
|
|
1497
|
+
varName = varName[1];
|
|
1498
|
+
NameAs = vars[x];
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
dataNamesValues.push({
|
|
1502
|
+
Name: varName,
|
|
1503
|
+
NameAs: NameAs,
|
|
1504
|
+
Value: undefined,
|
|
1505
|
+
});
|
|
1506
|
+
setError(e, "Error in bind variables for " + vars[x]);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
for (let x = 0; x < dataNamesValues.length; x++) {
|
|
1512
|
+
let dn = dataNamesValues[x];
|
|
1513
|
+
binds.push({
|
|
1514
|
+
dataName: dn["Name"],
|
|
1515
|
+
dataNameAs: dn["NameAs"],
|
|
1516
|
+
dataValue: clone(dn["Value"]),
|
|
1517
|
+
});
|
|
1518
|
+
data[dn["Name"]] = dn["Value"];
|
|
1519
|
+
}
|
|
1520
|
+
if (_debugMode) cl(["The Data Set", data, binds]);
|
|
1521
|
+
if (
|
|
1522
|
+
appSettings.beforetick &&
|
|
1523
|
+
typeof appSettings.beforetick === "function"
|
|
1524
|
+
)
|
|
1525
|
+
appSettings.beforetick();
|
|
1526
|
+
_el.data("_vars", binds).data("_re", new RenderEngine(_el, data));
|
|
1527
|
+
globalWatch();
|
|
1528
|
+
}
|
|
1529
|
+
_el.data("_status", "complete");
|
|
1530
|
+
return true;
|
|
1531
|
+
} catch (e) {
|
|
1532
|
+
_el.data("_status", "error");
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
return false;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
function parseFromString(html) {
|
|
1539
|
+
return doc = new DOMParser().parseFromString(html, "text/html");
|
|
1540
|
+
}
|
|
1541
|
+
// function htmlDecode(input) {
|
|
1542
|
+
// var doc = new DOMParser().parseFromString(input, "text/html");
|
|
1543
|
+
// return doc.documentElement.textContent;
|
|
1544
|
+
// }
|
|
1545
|
+
|
|
1546
|
+
var _binds = {};
|
|
1547
|
+
let _oldGlobals = clone(globals);
|
|
1548
|
+
let _oldRX = clone(_rx);
|
|
1549
|
+
let _watch = clone($("body").data("_watch"));
|
|
1550
|
+
|
|
1551
|
+
$("body").data("_watch", {
|
|
1552
|
+
old: {},
|
|
1553
|
+
list: [],
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1556
|
+
//NNNNNEEEEDDDD TO TURN ON
|
|
1557
|
+
// setInterval(function () {
|
|
1558
|
+
// if (!compareUs(_oldGlobals, globals)) {
|
|
1559
|
+
// _oldGlobals = clone(globals);
|
|
1560
|
+
// localStorage.setItem("globals", JSON.stringify(_oldGlobals));
|
|
1561
|
+
// }
|
|
1562
|
+
// if (!compareUs(_oldRX, _rx)) {
|
|
1563
|
+
// _oldRX = clone(_rx);
|
|
1564
|
+
// localStorage.setItem("_rx", JSON.stringify(_oldRX));
|
|
1565
|
+
// }
|
|
1566
|
+
// }, _tickTime);
|
|
1567
|
+
|
|
1568
|
+
function reloads() {
|
|
1569
|
+
$("[crslf].flickity-enabled.reload-on-bind").each(function () {
|
|
1570
|
+
var el = $(this);
|
|
1571
|
+
el.flickity("destroy");
|
|
1572
|
+
var opts = el.attr("crslf-opts");
|
|
1573
|
+
if (!opts) opts = {};
|
|
1574
|
+
else opts = JSON.parse(opts);
|
|
1575
|
+
el.flickity(opts);
|
|
1576
|
+
var flkty = el.data("flickity");
|
|
1577
|
+
flkty.on("dragStart", () =>
|
|
1578
|
+
flkty.slider.childNodes.forEach(
|
|
1579
|
+
(slide) => (slide.style.pointerEvents = "none")
|
|
1580
|
+
)
|
|
1581
|
+
);
|
|
1582
|
+
flkty.on("dragEnd", () =>
|
|
1583
|
+
flkty.slider.childNodes.forEach(
|
|
1584
|
+
(slide) => (slide.style.pointerEvents = "all")
|
|
1585
|
+
)
|
|
1586
|
+
);
|
|
1587
|
+
});
|
|
1588
|
+
$("[crsl].crsl-initialized").each(function () {
|
|
1589
|
+
$(this).crsl("refresh");
|
|
1590
|
+
});
|
|
1591
|
+
let tickFunc =
|
|
1592
|
+
appSettings.tick && typeof appSettings.tick === "function"
|
|
1593
|
+
? appSettings.tick
|
|
1594
|
+
: typeof tick === "function"
|
|
1595
|
+
? tick
|
|
1596
|
+
: null;
|
|
1597
|
+
if (typeof tickFunc === "function") tickFunc();
|
|
1598
|
+
|
|
1599
|
+
scsc.reset();
|
|
1600
|
+
dgsc.reset();
|
|
1601
|
+
applyTriggers();
|
|
1602
|
+
setTimeout(() => {
|
|
1603
|
+
scsc.reset();
|
|
1604
|
+
dgsc.reset();
|
|
1605
|
+
applyTriggers();
|
|
1606
|
+
}, _tickTime * 2);
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
function renderViewsTpls() {
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
$("[view]").each(function (i) {
|
|
1613
|
+
var el = $(this);
|
|
1614
|
+
|
|
1615
|
+
if (
|
|
1616
|
+
el.data("_status") != "pending" &&
|
|
1617
|
+
el.data("_status") != "error" &&
|
|
1618
|
+
el.data("_status") != "getting" &&
|
|
1619
|
+
el.data("_status") != "complete"
|
|
1620
|
+
) {
|
|
1621
|
+
var modal = el.closest("popup");
|
|
1622
|
+
var n = el.attr("view");
|
|
1623
|
+
var _props = el.attr(":props") ?? null;
|
|
1624
|
+
var _binds = el.attr(":props-bind") ?? null;
|
|
1625
|
+
el.data("_status", "pending");
|
|
1626
|
+
|
|
1627
|
+
let nn = n;
|
|
1628
|
+
var _arr = nn.split("/");
|
|
1629
|
+
if (_arr.length > 1) {
|
|
1630
|
+
for (var i = _arr.length - 1; i >= _arr.length - 1; i--) {
|
|
1631
|
+
_arr[i] = _arr[i].toLowerCase();
|
|
1632
|
+
}
|
|
1633
|
+
nn = _arr.join("/");
|
|
1634
|
+
} else {
|
|
1635
|
+
nn = nn.toLowerCase();
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
var _queryParams = nn.split("?");
|
|
1639
|
+
nn = _queryParams.shift();
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
if (el.attr(":data")) {
|
|
1646
|
+
let vaz = el.attr(":data");
|
|
1647
|
+
let data = {};
|
|
1648
|
+
let vars = vaz.split(",");
|
|
1649
|
+
let dataNamesValues = [];
|
|
1650
|
+
let binds = [];
|
|
1651
|
+
vars = vars.map((s) => s.trim());
|
|
1652
|
+
for (let x = 0; x < vars.length; x++) {
|
|
1653
|
+
if (vars[x] != "") {
|
|
1654
|
+
try {
|
|
1655
|
+
let varName = vars[x];
|
|
1656
|
+
let varValue = vars[x];
|
|
1657
|
+
let NameAs = null;
|
|
1658
|
+
|
|
1659
|
+
if (varName.indexOf(" as ") !== -1) {
|
|
1660
|
+
varName = varName.split(" as ");
|
|
1661
|
+
varValue = varName[0];
|
|
1662
|
+
varName = varName[1];
|
|
1663
|
+
NameAs = vars[x];
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
let val = "";
|
|
1667
|
+
val = eval(varValue);
|
|
1668
|
+
dataNamesValues.push({
|
|
1669
|
+
Name: varName,
|
|
1670
|
+
NameAs: NameAs,
|
|
1671
|
+
Value: val,
|
|
1672
|
+
});
|
|
1673
|
+
} catch (e) {
|
|
1674
|
+
cl(e);
|
|
1675
|
+
let varName = vars[x];
|
|
1676
|
+
let varValue = vars[x];
|
|
1677
|
+
let NameAs = null;
|
|
1678
|
+
|
|
1679
|
+
if (varName.indexOf(" as ") !== -1) {
|
|
1680
|
+
varName = varName.split(" as ");
|
|
1681
|
+
varValue = varName[0];
|
|
1682
|
+
varName = varName[1];
|
|
1683
|
+
NameAs = vars[x];
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
dataNamesValues.push({
|
|
1687
|
+
Name: varName,
|
|
1688
|
+
NameAs: NameAs,
|
|
1689
|
+
Value: undefined,
|
|
1690
|
+
});
|
|
1691
|
+
setError(e, "Error in bind variables for " + vars[x]);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
for (let x = 0; x < dataNamesValues.length; x++) {
|
|
1697
|
+
let dn = dataNamesValues[x];
|
|
1698
|
+
binds.push({
|
|
1699
|
+
dataName: dn["Name"],
|
|
1700
|
+
dataNameAs: dn["NameAs"],
|
|
1701
|
+
dataValue: clone(dn["Value"]),
|
|
1702
|
+
});
|
|
1703
|
+
data[dn["Name"]] = dn["Value"];
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
el.data("props", data);
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
|
|
1712
|
+
} else {
|
|
1713
|
+
var _d = paraToObj(getBind(_binds, _props));
|
|
1714
|
+
|
|
1715
|
+
el.data("params", paraToObj(_queryParams));
|
|
1716
|
+
if (modal.length) _d["modal"] = modal.data("props");
|
|
1717
|
+
el.data("props", _d);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
if (n == "" || !n || n.split("/").slice(-1) == "") {
|
|
1721
|
+
el.data("_status", "error");
|
|
1722
|
+
} else {
|
|
1723
|
+
renderView(n, el, _d);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
|
|
1728
|
+
// $("[tpl],[comp]").each(function () {
|
|
1729
|
+
// let el = $(this);
|
|
1730
|
+
// if (
|
|
1731
|
+
// el.data("_status") != "pending" &&
|
|
1732
|
+
// el.data("_status") != "error" &&
|
|
1733
|
+
// el.data("_status") != "getting" &&
|
|
1734
|
+
// el.data("_status") != "complete"
|
|
1735
|
+
// ) {
|
|
1736
|
+
// var modal = el.closest("modal");
|
|
1737
|
+
// if (!modal.length) {
|
|
1738
|
+
// let n = el.attr("tpl") ?? el.attr("comp");
|
|
1739
|
+
// el.data("_status", "pending");
|
|
1740
|
+
// if (n == "" || !n || n.split("/").slice(-1) == "") {
|
|
1741
|
+
// el.data("_status", "error");
|
|
1742
|
+
// } else renderTpl(el, n, el.attr(":data") ?? "");
|
|
1743
|
+
// }
|
|
1744
|
+
// }
|
|
1745
|
+
// });
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
|
|
1749
|
+
function renderPlugins() {
|
|
1750
|
+
$(
|
|
1751
|
+
"[crslf]:not(.flickity-enabled,[comp],[tpl],[view]),[crslf][comp]:not(.flickity-enabled),[crslf][tpl]:not(.flickity-enabled),[crslf][view]:not(.flickity-enabled)"
|
|
1752
|
+
).each(function () {
|
|
1753
|
+
var el = $(this);
|
|
1754
|
+
|
|
1755
|
+
if (el.hasAttr("[tpl]") || el.hasAttr("[comp]") || el.hasAttr("[view]")) {
|
|
1756
|
+
if (el.data("_status") != "complete") return;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
var opts = el.attr("crslf-opts");
|
|
1760
|
+
if (!opts) opts = {};
|
|
1761
|
+
else opts = JSON.parse(opts);
|
|
1762
|
+
el.flickity(opts);
|
|
1763
|
+
var flkty = el.data("flickity");
|
|
1764
|
+
flkty.on("dragStart", () =>
|
|
1765
|
+
flkty.slider.childNodes.forEach(
|
|
1766
|
+
(slide) => (slide.style.pointerEvents = "none")
|
|
1767
|
+
)
|
|
1768
|
+
);
|
|
1769
|
+
flkty.on("dragEnd", () =>
|
|
1770
|
+
flkty.slider.childNodes.forEach(
|
|
1771
|
+
(slide) => (slide.style.pointerEvents = "all")
|
|
1772
|
+
)
|
|
1773
|
+
);
|
|
1774
|
+
setTimeout(function () {
|
|
1775
|
+
globalWatch();
|
|
1776
|
+
}, 600);
|
|
1777
|
+
});
|
|
1778
|
+
$(
|
|
1779
|
+
"[crsl]:not(.crsl-initialized,[comp],[tpl],[view]),[crsl][comp]:not(.crsl-initialized),[crsl][tpl]:not(.crsl-initialized),[crsl][view]:not(.crsl-initialized)"
|
|
1780
|
+
).each(function () {
|
|
1781
|
+
var el = $(this);
|
|
1782
|
+
if (el.hasAttr("[tpl]") || el.hasAttr("[comp]") || el.hasAttr("[view]")) {
|
|
1783
|
+
if (el.data("_status") != "complete") return;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
el.crsl();
|
|
1787
|
+
el.on(
|
|
1788
|
+
"setPosition beforeChange",
|
|
1789
|
+
function (event, slick, currentSlide, nextSlide) {
|
|
1790
|
+
$(window).trigger("scroll.scsc");
|
|
1791
|
+
$(window).trigger("resize");
|
|
1792
|
+
}
|
|
1793
|
+
);
|
|
1794
|
+
});
|
|
1795
|
+
|
|
1796
|
+
$("[up]:not([upid])").each(function () {
|
|
1797
|
+
var u = _ups.length;
|
|
1798
|
+
var t = $(this);
|
|
1799
|
+
var mxf = t.attr('data-mxf') ? t.attr('data-mxf') : 10;
|
|
1800
|
+
if (!t.hasAttr("upid")) {
|
|
1801
|
+
var sl = "up_" + u;
|
|
1802
|
+
t.attr("upid", sl);
|
|
1803
|
+
t.prepend(`<input ` + (mxf > 1 ? 'multiple' : '') + ` type="file" ` + "" + ` files style="display:none;" />`);
|
|
1804
|
+
_ups.push(t);
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1807
|
+
|
|
1808
|
+
$("form:not(.binded,[norm])").each(function () {
|
|
1809
|
+
var el = $(this);
|
|
1810
|
+
var reset = false;
|
|
1811
|
+
if (el.hasAttr("reset")) reset = true;
|
|
1812
|
+
var actn = el.attr("action") ?? "";
|
|
1813
|
+
var local = false;
|
|
1814
|
+
el.addClass("binded");
|
|
1815
|
+
|
|
1816
|
+
if (actn == "") {
|
|
1817
|
+
actn = getURLNodes().join("/");
|
|
1818
|
+
local = true;
|
|
1819
|
+
} else local = isPathLocal(actn);
|
|
1820
|
+
|
|
1821
|
+
if (el.hasAttr("o-sub")) {
|
|
1822
|
+
el.ajaxForm({
|
|
1823
|
+
beforeSubmit: function (formData, f, options) {
|
|
1824
|
+
// options["url"] = beas + "a" + f.attr('action');
|
|
1825
|
+
let formDataMapped = {};
|
|
1826
|
+
let formDataMappedAdditionals = {};
|
|
1827
|
+
formDataMapped = Object.assign(
|
|
1828
|
+
{},
|
|
1829
|
+
...formData.map((x) => {
|
|
1830
|
+
if (x.type == "file") {
|
|
1831
|
+
if (!formDataMappedAdditionals.hasOwnProperty(x.name))
|
|
1832
|
+
formDataMappedAdditionals[x.name] = [];
|
|
1833
|
+
formDataMappedAdditionals[x.name].push(x["value"]);
|
|
1834
|
+
|
|
1835
|
+
return undefined;
|
|
1836
|
+
}
|
|
1837
|
+
if (x["name"].includes("[]")) {
|
|
1838
|
+
var key = x["name"].split("[]").join("");
|
|
1839
|
+
if (!formDataMappedAdditionals.hasOwnProperty(key))
|
|
1840
|
+
formDataMappedAdditionals[key] = [];
|
|
1841
|
+
formDataMappedAdditionals[key].push(x["value"]);
|
|
1842
|
+
return undefined;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
return { [x.name]: x.value };
|
|
1846
|
+
})
|
|
1847
|
+
);
|
|
1848
|
+
|
|
1849
|
+
formDataMapped = { ...formDataMapped, ...formDataMappedAdditionals };
|
|
1850
|
+
|
|
1851
|
+
// var d = getFormData(f);
|
|
1852
|
+
if (f.hasAttr("b-sub")) {
|
|
1853
|
+
var bfs = f.attr("b-sub");
|
|
1854
|
+
if (typeof window[bfs] === "function") {
|
|
1855
|
+
checkFormInputs(f);
|
|
1856
|
+
if (window[bfs](f, formDataMapped) === false) return false;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
if (!checkFormInputs(f)) return false;
|
|
1860
|
+
if (f.hasAttr("o-sub")) {
|
|
1861
|
+
var ofs = f.attr("o-sub");
|
|
1862
|
+
if (typeof window[ofs] === "function") {
|
|
1863
|
+
window[ofs](f, formDataMapped);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
return false;
|
|
1867
|
+
},
|
|
1868
|
+
clearForm: reset,
|
|
1869
|
+
resetForm: reset,
|
|
1870
|
+
success: function (responseText, statusText, xhr, f) { },
|
|
1871
|
+
timeout: 300000,
|
|
1872
|
+
error: function (xhr, textStatus, errorThrown) { },
|
|
1873
|
+
});
|
|
1874
|
+
|
|
1875
|
+
// el.attr('onsubmit','return false;');
|
|
1876
|
+
// el.on('submit',function(ev){
|
|
1877
|
+
// ev.preventDefault();
|
|
1878
|
+
// ev.stopPropagation();
|
|
1879
|
+
|
|
1880
|
+
// if(!checkFormInputs(el)) return false;
|
|
1881
|
+
|
|
1882
|
+
// var d = getFormData(el);
|
|
1883
|
+
// if (el.hasAttr('b-sub')) {
|
|
1884
|
+
// var bfs = el.attr('b-sub');
|
|
1885
|
+
// if (typeof window[bfs] === "function") {
|
|
1886
|
+
// if (window[bfs](el,d) === false) return false;
|
|
1887
|
+
// }
|
|
1888
|
+
// }
|
|
1889
|
+
// if (el.hasAttr('o-sub')) {
|
|
1890
|
+
// var ofs = el.attr('o-sub');
|
|
1891
|
+
// if (typeof window[ofs] === "function") {
|
|
1892
|
+
// window[ofs](el,d);
|
|
1893
|
+
// }
|
|
1894
|
+
// }
|
|
1895
|
+
// });
|
|
1896
|
+
} else {
|
|
1897
|
+
if (local) {
|
|
1898
|
+
el.ajaxForm({
|
|
1899
|
+
beforeSubmit: function (formData, f, options) {
|
|
1900
|
+
// options["url"] = beas + "a" + f.attr('action');
|
|
1901
|
+
if (!checkFormInputs(f)) return false;
|
|
1902
|
+
let formDataMapped = {};
|
|
1903
|
+
let formDataMappedAdditionals = {};
|
|
1904
|
+
formDataMapped = Object.assign(
|
|
1905
|
+
{},
|
|
1906
|
+
...formData.map((x) => {
|
|
1907
|
+
if (x.type == "file") {
|
|
1908
|
+
if (!formDataMappedAdditionals.hasOwnProperty(x.name))
|
|
1909
|
+
formDataMappedAdditionals[x.name] = [];
|
|
1910
|
+
formDataMappedAdditionals[x.name].push(x["value"]);
|
|
1911
|
+
|
|
1912
|
+
return undefined;
|
|
1913
|
+
}
|
|
1914
|
+
if (x["name"].includes("[]")) {
|
|
1915
|
+
var key = x["name"].split("[]").join("");
|
|
1916
|
+
if (!formDataMappedAdditionals.hasOwnProperty(key))
|
|
1917
|
+
formDataMappedAdditionals[key] = [];
|
|
1918
|
+
formDataMappedAdditionals[key].push(x["value"]);
|
|
1919
|
+
return undefined;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
return { [x.name]: x.value };
|
|
1923
|
+
})
|
|
1924
|
+
);
|
|
1925
|
+
|
|
1926
|
+
formDataMapped = {
|
|
1927
|
+
...formDataMapped,
|
|
1928
|
+
...formDataMappedAdditionals,
|
|
1929
|
+
};
|
|
1930
|
+
try {
|
|
1931
|
+
// var d = getFormData(f);
|
|
1932
|
+
if (f.hasAttr("b-sub")) {
|
|
1933
|
+
var bfs = f.attr("b-sub");
|
|
1934
|
+
if (typeof window[bfs] === "function") {
|
|
1935
|
+
if (window[bfs](f, formDataMapped) === false) return false;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
var actn = f.attr("action") ?? "";
|
|
1939
|
+
if (actn == "") {
|
|
1940
|
+
actn = getURLNodes().join("/");
|
|
1941
|
+
}
|
|
1942
|
+
if (validateInputs(f)) {
|
|
1943
|
+
var d = getFormData(f);
|
|
1944
|
+
if (f.attr("method")?.toLowerCase() == "get") {
|
|
1945
|
+
actn = addOrChangeParameters(actn, d);
|
|
1946
|
+
}
|
|
1947
|
+
pushURL(actn, d);
|
|
1948
|
+
}
|
|
1949
|
+
} catch (e) {
|
|
1950
|
+
cl(e);
|
|
1951
|
+
}
|
|
1952
|
+
return false;
|
|
1953
|
+
},
|
|
1954
|
+
clearForm: reset,
|
|
1955
|
+
resetForm: reset,
|
|
1956
|
+
success: function (responseText, statusText, xhr, f) { },
|
|
1957
|
+
timeout: 300000,
|
|
1958
|
+
error: function (xhr, textStatus, errorThrown) { },
|
|
1959
|
+
});
|
|
1960
|
+
|
|
1961
|
+
// el.attr('onsubmit','return false;');
|
|
1962
|
+
// el.on('submit',function(ev){
|
|
1963
|
+
// ev.preventDefault();
|
|
1964
|
+
// ev.stopPropagation();
|
|
1965
|
+
|
|
1966
|
+
// if(!checkFormInputs(el)) return false;
|
|
1967
|
+
// try{
|
|
1968
|
+
// var d = getFormData(el);
|
|
1969
|
+
// if (el.hasAttr('b-sub')) {
|
|
1970
|
+
// var bfs = el.attr('b-sub');
|
|
1971
|
+
// if (typeof window[bfs] === "function") {
|
|
1972
|
+
// if (window[bfs](el,d) === false) return false;
|
|
1973
|
+
// }
|
|
1974
|
+
// }
|
|
1975
|
+
// var actn = el.attr('action')??"";
|
|
1976
|
+
// if(actn==""){
|
|
1977
|
+
// actn = getURLNodes().join("/");
|
|
1978
|
+
// }
|
|
1979
|
+
// if(validateInputs(el)){
|
|
1980
|
+
// if(el.attr('method')?.toLowerCase()=="get"){
|
|
1981
|
+
// var d = getFormData(el);
|
|
1982
|
+
// actn = addOrChangeParameters(actn, d);
|
|
1983
|
+
// }
|
|
1984
|
+
// pushURL(actn,d);
|
|
1985
|
+
// }
|
|
1986
|
+
// } catch(e){
|
|
1987
|
+
// cl(e);
|
|
1988
|
+
// }
|
|
1989
|
+
// });
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
});
|
|
1993
|
+
|
|
1994
|
+
$("[editor]").each(function (i) {
|
|
1995
|
+
var editor = $(this);
|
|
1996
|
+
editor.removeAttr("editor");
|
|
1997
|
+
var TB = normalTB;
|
|
1998
|
+
if (editor.is("[mini]")) TB = miniTB;
|
|
1999
|
+
else if (editor.is("[full]")) TB = fullTB;
|
|
2000
|
+
|
|
2001
|
+
if (CKEDITOR !== undefined) {
|
|
2002
|
+
/*CKEDITOR.plugins.addExternal( 'autocomplete', 'https://s.beacdn.com/j/autocomplete/plugin.js' );*/
|
|
2003
|
+
CKEDITOR.replace(this, {
|
|
2004
|
+
uiColor: "#ffffff",
|
|
2005
|
+
language: $("html").attr("lang"),
|
|
2006
|
+
allowedContent: true,
|
|
2007
|
+
//extraPlugins: 'autocomplete',
|
|
2008
|
+
enterMode: CKEDITOR.ENTER_BR,
|
|
2009
|
+
toolbar: TB,
|
|
2010
|
+
on: {
|
|
2011
|
+
instanceReady: function (evt) {
|
|
2012
|
+
var itemTemplate =
|
|
2013
|
+
'<li class="l" data-id="{id}">' +
|
|
2014
|
+
'<div><strong class="item-title">{name}</strong></div>' +
|
|
2015
|
+
"<div><i>{description}</i></div>" +
|
|
2016
|
+
"</li>",
|
|
2017
|
+
outputTemplate = "<span class=hash>{linked}</span> ";
|
|
2018
|
+
|
|
2019
|
+
var autocomplete = new CKEDITOR.plugins.autocomplete(evt.editor, {
|
|
2020
|
+
textTestCallback: function (range) {
|
|
2021
|
+
if (!range.collapsed) {
|
|
2022
|
+
return null;
|
|
2023
|
+
}
|
|
2024
|
+
//cl(range);
|
|
2025
|
+
|
|
2026
|
+
//var range = new CKEDITOR.dom.range( evt.editor.document );
|
|
2027
|
+
//cl(range);
|
|
2028
|
+
|
|
2029
|
+
return CKEDITOR.plugins.textMatch.match(
|
|
2030
|
+
range,
|
|
2031
|
+
function (text, offset) {
|
|
2032
|
+
var left = text.slice(0, offset);
|
|
2033
|
+
var matchHash = left.match(/#\d*$/);
|
|
2034
|
+
var matchAt = left.match(
|
|
2035
|
+
/(@)[A-Za-z]+(?!\.)(?!.*\.$)(?!.*?\.\.)[a-zA-Z0-9.]+[A-Za-z0-9]{6,30}$/
|
|
2036
|
+
);
|
|
2037
|
+
|
|
2038
|
+
if (
|
|
2039
|
+
(!matchHash || matchHash == "#") &&
|
|
2040
|
+
(!matchAt || matchAt == "@")
|
|
2041
|
+
) {
|
|
2042
|
+
return null;
|
|
2043
|
+
}
|
|
2044
|
+
var match = matchHash;
|
|
2045
|
+
if (!match) match = matchAt;
|
|
2046
|
+
|
|
2047
|
+
return { start: match.index, end: offset };
|
|
2048
|
+
}
|
|
2049
|
+
);
|
|
2050
|
+
},
|
|
2051
|
+
dataCallback: function (matchInfo, callback) {
|
|
2052
|
+
var query = matchInfo.query;
|
|
2053
|
+
|
|
2054
|
+
if (myR["[ck]"]) myR["[ck]"].abort();
|
|
2055
|
+
|
|
2056
|
+
clearTimeout(debounceTimeout["[ck]"]);
|
|
2057
|
+
debounceTimeout["[ck]"] = setTimeout(function () {
|
|
2058
|
+
myR["[ck]"] = $.post(
|
|
2059
|
+
beas + "a" + "/hashes/get",
|
|
2060
|
+
{ id: query },
|
|
2061
|
+
function (result) {
|
|
2062
|
+
if (result) {
|
|
2063
|
+
result = $.parseJSON(result);
|
|
2064
|
+
var suggestions = result.filter(function (item) {
|
|
2065
|
+
return (
|
|
2066
|
+
String(item.name).indexOf(query.substring(1)) == 0
|
|
2067
|
+
);
|
|
2068
|
+
});
|
|
2069
|
+
callback(suggestions);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
);
|
|
2073
|
+
}, 500);
|
|
2074
|
+
},
|
|
2075
|
+
itemTemplate: itemTemplate,
|
|
2076
|
+
outputTemplate: outputTemplate,
|
|
2077
|
+
throttle: 100,
|
|
2078
|
+
});
|
|
2079
|
+
|
|
2080
|
+
autocomplete.getHtmlToInsert = function (item) {
|
|
2081
|
+
return this.outputTemplate.output(item);
|
|
2082
|
+
};
|
|
2083
|
+
},
|
|
2084
|
+
change: function (ev) {
|
|
2085
|
+
if ($.trim(ev.editor.getData()).length == 0)
|
|
2086
|
+
editor
|
|
2087
|
+
.closest(".fields")
|
|
2088
|
+
.addClass("is-empty")
|
|
2089
|
+
.removeClass("is-not-empty");
|
|
2090
|
+
else
|
|
2091
|
+
editor
|
|
2092
|
+
.closest(".fields")
|
|
2093
|
+
.removeClass("is-empty error")
|
|
2094
|
+
.addClass("is-not-empty");
|
|
2095
|
+
editor.val(ev.editor.getData()).trigger("change");
|
|
2096
|
+
},
|
|
2097
|
+
focus: function (ev) {
|
|
2098
|
+
editor.closest(".fields").addClass("focused");
|
|
2099
|
+
if ($.trim(ev.editor.getData()).length == 0)
|
|
2100
|
+
editor
|
|
2101
|
+
.closest(".fields")
|
|
2102
|
+
.addClass("is-empty")
|
|
2103
|
+
.removeClass("is-not-empty");
|
|
2104
|
+
else
|
|
2105
|
+
editor
|
|
2106
|
+
.closest(".fields")
|
|
2107
|
+
.removeClass("is-empty error")
|
|
2108
|
+
.addClass("is-not-empty");
|
|
2109
|
+
},
|
|
2110
|
+
blur: function (ev) {
|
|
2111
|
+
editor.closest(".fields").removeClass("focused");
|
|
2112
|
+
if ($.trim(ev.editor.getData()).length == 0)
|
|
2113
|
+
editor
|
|
2114
|
+
.closest(".fields")
|
|
2115
|
+
.addClass("is-empty")
|
|
2116
|
+
.removeClass("is-not-empty");
|
|
2117
|
+
else
|
|
2118
|
+
editor
|
|
2119
|
+
.closest(".fields")
|
|
2120
|
+
.removeClass("is-empty error")
|
|
2121
|
+
.addClass("is-not-empty");
|
|
2122
|
+
},
|
|
2123
|
+
},
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
});
|
|
2127
|
+
|
|
2128
|
+
$(".cke_autocomplete_panel").each(function () {
|
|
2129
|
+
if ($(this).html() == "") $(this).remove();
|
|
2130
|
+
});
|
|
2131
|
+
|
|
2132
|
+
$("[tags]:not(.tag-editor-hidden-src)").each(function () {
|
|
2133
|
+
var t = $(this);
|
|
2134
|
+
|
|
2135
|
+
var u = currentlyValidTags.length;
|
|
2136
|
+
t.attr("data-u", u);
|
|
2137
|
+
var del = t.attr("dl") ? t.attr("dl") : ", ";
|
|
2138
|
+
var maxTags = t.attr("mt") ? t.attr("mt") : 50;
|
|
2139
|
+
var maxLength = t.attr("ml") ? t.attr("ml") : 100;
|
|
2140
|
+
var plchldr = t.attr("placeholder") ? t.attr("placeholder") : "";
|
|
2141
|
+
var tagslower = t.attr("tags-lower") ? true : false;
|
|
2142
|
+
var autocomplete = t.attr("acs")
|
|
2143
|
+
? {
|
|
2144
|
+
delay: 250,
|
|
2145
|
+
autoFocus: true,
|
|
2146
|
+
position: { collision: "flip" },
|
|
2147
|
+
source: function (request, response) {
|
|
2148
|
+
$.post(beas + "a" + t.attr("acs"), request, response);
|
|
2149
|
+
},
|
|
2150
|
+
minLength: 1,
|
|
2151
|
+
select: function (event, ui) {
|
|
2152
|
+
/*t.trigger('change');*/
|
|
2153
|
+
// cl(ui);
|
|
2154
|
+
if (ui.item == null) {
|
|
2155
|
+
t.val("");
|
|
2156
|
+
/*t.focus();*/
|
|
2157
|
+
}
|
|
2158
|
+
},
|
|
2159
|
+
change: function (event, ui) {
|
|
2160
|
+
if (ui.item == null) {
|
|
2161
|
+
t.val("");
|
|
2162
|
+
/*t.focus();*/
|
|
2163
|
+
}
|
|
2164
|
+
},
|
|
2165
|
+
}
|
|
2166
|
+
: null;
|
|
2167
|
+
t.tagEditor({
|
|
2168
|
+
autocomplete: autocomplete,
|
|
2169
|
+
delimiter: del,
|
|
2170
|
+
removeDuplicates: true,
|
|
2171
|
+
forceLowercase: tagslower,
|
|
2172
|
+
placeholder: plchldr,
|
|
2173
|
+
animateDelete: 50,
|
|
2174
|
+
maxLength: maxLength,
|
|
2175
|
+
maxTags: maxTags,
|
|
2176
|
+
onChange: function (field, editor, tags) {
|
|
2177
|
+
field.trigger("change");
|
|
2178
|
+
},
|
|
2179
|
+
beforeTagSave: function (field, editor, tags, tag, val) {
|
|
2180
|
+
if (!t.attr("sts")) {
|
|
2181
|
+
if ($.inArrayIn(val, tags) !== -1) {
|
|
2182
|
+
return false;
|
|
2183
|
+
}
|
|
2184
|
+
} else {
|
|
2185
|
+
if ($.inArray(tag, currentlyValidTags[u][tags]) == -1) {
|
|
2186
|
+
return false;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
if (t.attr("tags-before")) {
|
|
2191
|
+
var bfs = t.attr("tags-before");
|
|
2192
|
+
if (typeof window[bfs] === "function") {
|
|
2193
|
+
if (window[bfs](t, field, editor, tags, tag, val) === false)
|
|
2194
|
+
return false;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
},
|
|
2198
|
+
});
|
|
2199
|
+
currentlyValidTags.push(t);
|
|
2200
|
+
});
|
|
2201
|
+
|
|
2202
|
+
$("[slct]:not(.select2-hidden-accessible)").each(function () {
|
|
2203
|
+
var t = $(this);
|
|
2204
|
+
var plchldr = t.attr("placeholder") ? t.attr("placeholder") : "";
|
|
2205
|
+
var dropdownParent = t.attr("prnt") ? t.attr("prnt") : "body";
|
|
2206
|
+
var tpl = t.attr("slct-tpl") ? t.attr("slct-tpl") : null;
|
|
2207
|
+
var dir = t.attr("slct-dir") ? t.attr("slct-dir") : "ltr";
|
|
2208
|
+
// var lang = t.attr('slct-lang') ? t.attr('slct-lang') : 'en';
|
|
2209
|
+
var minResultsForSearch = t.attr("mins") ? t.attr("mins") : "";
|
|
2210
|
+
if (dropdownParent == "self") dropdownParent = t.parent();
|
|
2211
|
+
else dropdownParent = $(dropdownParent);
|
|
2212
|
+
var allowNewTags = t.attr("ntgs") ? true : false;
|
|
2213
|
+
var ax = t.attr("axs")
|
|
2214
|
+
? {
|
|
2215
|
+
url: t.attr("axs"),
|
|
2216
|
+
dataType: "json",
|
|
2217
|
+
delay: 250,
|
|
2218
|
+
}
|
|
2219
|
+
: null;
|
|
2220
|
+
t.select2({
|
|
2221
|
+
dropdownParent: dropdownParent,
|
|
2222
|
+
placeholder: plchldr,
|
|
2223
|
+
dir: dir,
|
|
2224
|
+
// language: lang,
|
|
2225
|
+
allowClear: false,
|
|
2226
|
+
tags: allowNewTags,
|
|
2227
|
+
ajax: ax,
|
|
2228
|
+
minimumResultsForSearch: minResultsForSearch,
|
|
2229
|
+
templateSelection: function (data, container) {
|
|
2230
|
+
/*if(data.newTag) {
|
|
2231
|
+
|
|
2232
|
+
}*/
|
|
2233
|
+
/*$(data.element).attr('data-custom-attribute', data.customValue);*/
|
|
2234
|
+
|
|
2235
|
+
if (data.newTag) {
|
|
2236
|
+
/*alert(data.text);
|
|
2237
|
+
var new_state = $(data.text).text();
|
|
2238
|
+
alert(new_state);*/
|
|
2239
|
+
if (allowNewTags && t.attr("ntgs") != "true") {
|
|
2240
|
+
var tag = data.text;
|
|
2241
|
+
var id = data.id;
|
|
2242
|
+
$.post(beas + "a" + t.attr("ntgs"), { tag: tag }, function (r) {
|
|
2243
|
+
if (r == "true") {
|
|
2244
|
+
var newOption = new Option(tag, id, true, true);
|
|
2245
|
+
t.append(newOption).trigger("change");
|
|
2246
|
+
} else {
|
|
2247
|
+
alert("Error adding tag! Please Try again.");
|
|
2248
|
+
t.val(null).trigger("change");
|
|
2249
|
+
}
|
|
2250
|
+
});
|
|
2251
|
+
return data.text;
|
|
2252
|
+
} else {
|
|
2253
|
+
return data.text;
|
|
2254
|
+
}
|
|
2255
|
+
} else {
|
|
2256
|
+
return data.text;
|
|
2257
|
+
}
|
|
2258
|
+
},
|
|
2259
|
+
templateResult: function (state) {
|
|
2260
|
+
/*if (!state.id) {
|
|
2261
|
+
return state.text;
|
|
2262
|
+
}*/
|
|
2263
|
+
if (tpl) {
|
|
2264
|
+
if (typeof window[tpl] === "function") return window[tpl](state);
|
|
2265
|
+
}
|
|
2266
|
+
if (state.newTag) {
|
|
2267
|
+
if (allowNewTags && t.attr("ntgs") != "true") {
|
|
2268
|
+
var new_state = $("<span>+ Add <b>" + state.text + "</b></span>");
|
|
2269
|
+
|
|
2270
|
+
return new_state;
|
|
2271
|
+
}
|
|
2272
|
+
return state.text;
|
|
2273
|
+
} else return state.text;
|
|
2274
|
+
|
|
2275
|
+
/*return state.text;*/
|
|
2276
|
+
},
|
|
2277
|
+
tokenSeparators: [","] /*[',', ' ']*/,
|
|
2278
|
+
createTag: function (params) {
|
|
2279
|
+
var term = $.trim(params.term);
|
|
2280
|
+
|
|
2281
|
+
if (term === "") {
|
|
2282
|
+
return null;
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
return {
|
|
2286
|
+
id: term,
|
|
2287
|
+
text: term,
|
|
2288
|
+
newTag: true,
|
|
2289
|
+
};
|
|
2290
|
+
},
|
|
2291
|
+
insertTag: function (data, tag) {
|
|
2292
|
+
/* Insert the tag at the end of the results */
|
|
2293
|
+
data.push(tag);
|
|
2294
|
+
},
|
|
2295
|
+
});
|
|
2296
|
+
|
|
2297
|
+
if (t.attr("nosearch"))
|
|
2298
|
+
t.on("select2:opening select2:closing", function (event) {
|
|
2299
|
+
var searchfield = $(this).parent().find(".select2-search__field");
|
|
2300
|
+
searchfield.prop("disabled", true);
|
|
2301
|
+
});
|
|
2302
|
+
});
|
|
2303
|
+
|
|
2304
|
+
$("[sl]:not(.select2-hidden-accessible)").each(function () {
|
|
2305
|
+
var t = $(this);
|
|
2306
|
+
try {
|
|
2307
|
+
|
|
2308
|
+
var plchldr = t.attr("placeholder") ? t.attr("placeholder") : "";
|
|
2309
|
+
var dir = $("body").hasClass("rtl") ? "rtl" : "ltr";
|
|
2310
|
+
var nr = t.attr("sl-nrmsg") ? t.attr("sl-nrmsg") : "No results found";
|
|
2311
|
+
var minResultsForSearch = t.attr("sl-mins") ? t.attr("sl-mins") : 10;
|
|
2312
|
+
var allowNewTags = t.attr("sl-ntgs") ? true : false;
|
|
2313
|
+
var dropdownParent = t.attr("sl-prt") ? t.attr("sl-prt") : "body";
|
|
2314
|
+
if (dropdownParent == "self") dropdownParent = t.parent();
|
|
2315
|
+
else dropdownParent = $(dropdownParent);
|
|
2316
|
+
|
|
2317
|
+
var query = t.attr("sl-query") ? t.attr("sl-query") : null;
|
|
2318
|
+
|
|
2319
|
+
var uniquer = Date.now();
|
|
2320
|
+
if (typeof window[query] === "function") {
|
|
2321
|
+
let dbcrID = "dbcr_" + (Object.keys(_dbcrs).length + 1);
|
|
2322
|
+
|
|
2323
|
+
t.select2.amd.define(
|
|
2324
|
+
"adapt_" + uniquer,
|
|
2325
|
+
["select2/data/array", "select2/utils"],
|
|
2326
|
+
function (ArrayAdapter, Utils) {
|
|
2327
|
+
function CustomDataAdapter($element, options) {
|
|
2328
|
+
CustomDataAdapter.__super__.constructor.call(
|
|
2329
|
+
this,
|
|
2330
|
+
$element,
|
|
2331
|
+
options
|
|
2332
|
+
);
|
|
2333
|
+
}
|
|
2334
|
+
Utils.Extend(CustomDataAdapter, ArrayAdapter);
|
|
2335
|
+
CustomDataAdapter.prototype.query = function (params, callback) {
|
|
2336
|
+
clearTimeout(_dbcrs[dbcrID]);
|
|
2337
|
+
let _t = t;
|
|
2338
|
+
_dbcrs[dbcrID] = setTimeout(
|
|
2339
|
+
function () {
|
|
2340
|
+
window[query](params, callback, _t);
|
|
2341
|
+
},
|
|
2342
|
+
!_dbcrs.hasOwnProperty(dbcrID) ? 0 : _dbcrsTime
|
|
2343
|
+
);
|
|
2344
|
+
};
|
|
2345
|
+
|
|
2346
|
+
return CustomDataAdapter;
|
|
2347
|
+
}
|
|
2348
|
+
);
|
|
2349
|
+
|
|
2350
|
+
t.select2({
|
|
2351
|
+
dropdownParent: dropdownParent,
|
|
2352
|
+
minimumResultsForSearch: minResultsForSearch,
|
|
2353
|
+
placeholder: plchldr,
|
|
2354
|
+
dir: dir,
|
|
2355
|
+
tags: allowNewTags,
|
|
2356
|
+
allowClear: false,
|
|
2357
|
+
language: {
|
|
2358
|
+
noResults: function () {
|
|
2359
|
+
return nr;
|
|
2360
|
+
},
|
|
2361
|
+
},
|
|
2362
|
+
...(t.select2.amd.require("adapt_" + uniquer)
|
|
2363
|
+
? { ajax: {}, dataAdapter: t.select2.amd.require("adapt_" + uniquer) }
|
|
2364
|
+
: {}),
|
|
2365
|
+
});
|
|
2366
|
+
} else {
|
|
2367
|
+
t.select2({
|
|
2368
|
+
dropdownParent: dropdownParent,
|
|
2369
|
+
minimumResultsForSearch: minResultsForSearch,
|
|
2370
|
+
placeholder: plchldr,
|
|
2371
|
+
dir: dir,
|
|
2372
|
+
tags: allowNewTags,
|
|
2373
|
+
allowClear: false,
|
|
2374
|
+
language: {
|
|
2375
|
+
noResults: function () {
|
|
2376
|
+
return nr;
|
|
2377
|
+
},
|
|
2378
|
+
},
|
|
2379
|
+
});
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
if (t.attr("sl-nosrch"))
|
|
2383
|
+
t.on("select2:opening select2:closing", function (event) {
|
|
2384
|
+
var searchfield = $(this).parent().find(".select2-search__field");
|
|
2385
|
+
searchfield.prop("disabled", true);
|
|
2386
|
+
});
|
|
2387
|
+
if (t.attr("sl-class")) {
|
|
2388
|
+
t.on("select2:opening", function (event) {
|
|
2389
|
+
dropdownParent.addClass(t.attr("sl-class"));
|
|
2390
|
+
});
|
|
2391
|
+
t.on("select2:closing", function (event) {
|
|
2392
|
+
dropdownParent.removeClass(t.attr("sl-class"));
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
} catch (e) {
|
|
2397
|
+
cl(e);
|
|
2398
|
+
}
|
|
2399
|
+
// t.empty().trigger('change');
|
|
2400
|
+
});
|
|
2401
|
+
|
|
2402
|
+
$("[pinnable]:not(.pinnable)").each(function () {
|
|
2403
|
+
var t = $(this);
|
|
2404
|
+
var offsetU = t.attr("pinnable-offset-up") ?? 100;
|
|
2405
|
+
var offsetD = t.attr("pinnable-offset-down") ?? 50;
|
|
2406
|
+
var options = {
|
|
2407
|
+
// vertical offset in px before element is first unpinned
|
|
2408
|
+
offset: 0,
|
|
2409
|
+
// or you can specify offset individually for up/down scroll
|
|
2410
|
+
offset: {
|
|
2411
|
+
up: offsetU,
|
|
2412
|
+
down: offsetD,
|
|
2413
|
+
},
|
|
2414
|
+
// scroll tolerance in px before state changes
|
|
2415
|
+
tolerance: 0,
|
|
2416
|
+
// or you can specify tolerance individually for up/down scroll
|
|
2417
|
+
tolerance: {
|
|
2418
|
+
up: 5,
|
|
2419
|
+
down: 0,
|
|
2420
|
+
},
|
|
2421
|
+
// css classes to apply
|
|
2422
|
+
classes: {
|
|
2423
|
+
// when element is initialised
|
|
2424
|
+
initial: "pinnable",
|
|
2425
|
+
// when scrolling up
|
|
2426
|
+
pinned: "pinnable--pinned",
|
|
2427
|
+
// when scrolling down
|
|
2428
|
+
unpinned: "pinnable--unpinned",
|
|
2429
|
+
// when above offset
|
|
2430
|
+
top: "pinnable--top",
|
|
2431
|
+
// when below offset
|
|
2432
|
+
notTop: "pinnable--not-top",
|
|
2433
|
+
// when at bottom of scroll area
|
|
2434
|
+
bottom: "pinnable--bottom",
|
|
2435
|
+
// when not at bottom of scroll area
|
|
2436
|
+
notBottom: "pinnable--not-bottom",
|
|
2437
|
+
// when frozen method has been called
|
|
2438
|
+
frozen: "pinnable--frozen",
|
|
2439
|
+
// multiple classes are also supported with a space-separated list
|
|
2440
|
+
pinned: "pinnable--pinned",
|
|
2441
|
+
},
|
|
2442
|
+
// element to listen to scroll events on, defaults to `window`
|
|
2443
|
+
// scroller: `window`,
|
|
2444
|
+
// callback when pinned, `this` is pinnable object
|
|
2445
|
+
onPin: function () { },
|
|
2446
|
+
// callback when unpinned, `this` is pinnable object
|
|
2447
|
+
onUnpin: function () { },
|
|
2448
|
+
// callback when above offset, `this` is pinnable object
|
|
2449
|
+
onTop: function () { },
|
|
2450
|
+
// callback when below offset, `this` is pinnable object
|
|
2451
|
+
onNotTop: function () { },
|
|
2452
|
+
// callback when at bottom of page, `this` is pinnable object
|
|
2453
|
+
onBottom: function () { },
|
|
2454
|
+
// callback when moving away from bottom of page, `this` is pinnable object
|
|
2455
|
+
onNotBottom: function () { },
|
|
2456
|
+
};
|
|
2457
|
+
var pinnable = new Headroom(t[0], options);
|
|
2458
|
+
pinnable.init();
|
|
2459
|
+
});
|
|
2460
|
+
|
|
2461
|
+
$("[sort]").each(function (e) {
|
|
2462
|
+
let t = $(this);
|
|
2463
|
+
if (t.hasClass("ui-sortable")) return;
|
|
2464
|
+
let opts = {
|
|
2465
|
+
delay: 50,
|
|
2466
|
+
placeholder: "g_rows_helper",
|
|
2467
|
+
scrollSpeed: 40,
|
|
2468
|
+
opacity: 1,
|
|
2469
|
+
};
|
|
2470
|
+
opts = avc(t, "sort-axis", opts);
|
|
2471
|
+
opts = avc(t, "sort-handle", opts);
|
|
2472
|
+
opts = avc(t, "sort-cancel", opts);
|
|
2473
|
+
opts = avc(t, "sort-cursor", opts, "grabbing");
|
|
2474
|
+
opts = avc(t, "sort-helper", opts, "clone");
|
|
2475
|
+
if (opts.hasOwnProperty("helper") && opts["helper"] != "clone") {
|
|
2476
|
+
if (typeof window[opts["helper"]] === "function")
|
|
2477
|
+
opts["helper"] = window[opts["helper"]];
|
|
2478
|
+
}
|
|
2479
|
+
opts = avc(t, "sort-placeholder", opts);
|
|
2480
|
+
opts = avc(t, "sort-opacity", opts);
|
|
2481
|
+
opts = avc(t, "sort-items", opts);
|
|
2482
|
+
opts = avc(t, "sort-tolerance", opts, "pointer");
|
|
2483
|
+
opts = avc(t, "sort-revert", opts, false);
|
|
2484
|
+
opts = avc(t, "sort-forcePlaceholderSize", opts);
|
|
2485
|
+
opts = avc(t, "sort-containment", opts, "parent");
|
|
2486
|
+
opts = avc(t, "sort-connectWith", opts);
|
|
2487
|
+
if (opts.hasOwnProperty("forceplaceholdersize")) {
|
|
2488
|
+
opts["forcePlaceholderSize"] = opts["forceplaceholdersize"];
|
|
2489
|
+
delete opts["forceplaceholdersize"];
|
|
2490
|
+
}
|
|
2491
|
+
// cl(opts);
|
|
2492
|
+
t.sortable(opts);
|
|
2493
|
+
});
|
|
2494
|
+
|
|
2495
|
+
$("[drag]").each(function (e) {
|
|
2496
|
+
let t = $(this);
|
|
2497
|
+
let opts = {
|
|
2498
|
+
// delay: 50,
|
|
2499
|
+
// placeholder: "g_rows_helper",
|
|
2500
|
+
// scrollSpeed: 40,
|
|
2501
|
+
// opacity: 1,
|
|
2502
|
+
};
|
|
2503
|
+
// opts = avc(t, 'axis', opts);
|
|
2504
|
+
// opts = avc(t, 'handle', opts);
|
|
2505
|
+
// opts = avc(t, 'cancel', opts);
|
|
2506
|
+
// opts = avc(t, 'cursor', opts, 'grabbing');
|
|
2507
|
+
// opts = avc(t, 'helper', opts, 'clone');
|
|
2508
|
+
// opts = avc(t, 'placeholder', opts);
|
|
2509
|
+
opts = avc(t, "drag-connectToSortable", opts);
|
|
2510
|
+
opts = avc(t, "drag-scroll", opts, true);
|
|
2511
|
+
opts = avc(t, "drag-revert", opts, true);
|
|
2512
|
+
opts = avc(t, "drag-helper", opts, "clone");
|
|
2513
|
+
opts = avc(t, "drag-containment", opts, false);
|
|
2514
|
+
opts = avc(t, "drag-cursor", opts, "auto");
|
|
2515
|
+
opts = avc(t, "drag-appendTo", opts, "parent");
|
|
2516
|
+
opts = avc(t, "drag-disabled", opts, false);
|
|
2517
|
+
|
|
2518
|
+
if (opts.disabled == "false") delete opts.disabled;
|
|
2519
|
+
if (opts.hasOwnProperty("appendto")) {
|
|
2520
|
+
opts.appendTo = opts["appendto"];
|
|
2521
|
+
delete opts["appendto"];
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
if (opts.hasOwnProperty("helper") && opts["helper"] != "clone") {
|
|
2525
|
+
if (typeof window[opts["helper"]] === "function")
|
|
2526
|
+
opts["helper"] = window[opts["helper"]];
|
|
2527
|
+
}
|
|
2528
|
+
if (opts.hasOwnProperty("connecttosortable")) {
|
|
2529
|
+
opts["connectToSortable"] = opts["connecttosortable"];
|
|
2530
|
+
delete opts["connecttosortable"];
|
|
2531
|
+
}
|
|
2532
|
+
// opts = avc(t, 'containment', opts, 'parent');
|
|
2533
|
+
// opts = avc(t, 'connectWith', opts);
|
|
2534
|
+
t.draggable(opts);
|
|
2535
|
+
});
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
$("[drop]").each(function (e) {
|
|
2539
|
+
let t = $(this);
|
|
2540
|
+
let opts = {};
|
|
2541
|
+
|
|
2542
|
+
opts = avc(t, "drop-accept", opts);
|
|
2543
|
+
opts = avc(t, "drop-greedy", opts);
|
|
2544
|
+
opts = avc(t, "drop-hoverClass", opts);
|
|
2545
|
+
opts = avc(t, "drop-disabled", opts, false);
|
|
2546
|
+
|
|
2547
|
+
if (opts.disabled == "false") delete opts.disabled;
|
|
2548
|
+
|
|
2549
|
+
if (opts.hasOwnProperty("hoverclass")) {
|
|
2550
|
+
opts.hoverClass = opts["hoverclass"];
|
|
2551
|
+
delete opts["hoverclass"];
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
t.droppable(opts);
|
|
2555
|
+
});
|
|
2556
|
+
|
|
2557
|
+
$("body").on("touchstart mouseover", function (e) {
|
|
2558
|
+
let isTippedOe = true;
|
|
2559
|
+
if ($(e.target).closest(".oe").length) {
|
|
2560
|
+
let oe = $(e.target).closest(".oe");
|
|
2561
|
+
if (
|
|
2562
|
+
(oe.find("[tip]").length || oe.hasAttr("tip")) &&
|
|
2563
|
+
oe.isOverflown() &&
|
|
2564
|
+
$(window).width() > 480
|
|
2565
|
+
) {
|
|
2566
|
+
isTippedOe = true;
|
|
2567
|
+
} else isTippedOe = false;
|
|
2568
|
+
}
|
|
2569
|
+
if ($(e.target).closest("[tip]").length && isTippedOe) {
|
|
2570
|
+
var target = $(e.target).closest("[tip]");
|
|
2571
|
+
var tip = `<tip class="pa ${target.attr(
|
|
2572
|
+
"tip-class"
|
|
2573
|
+
)}"><div class="pa [[P]]"><span>[[T]]</span></div></tip>`;
|
|
2574
|
+
if (target.find("droplet").length == 0) {
|
|
2575
|
+
var t = target.attr("tip");
|
|
2576
|
+
var p = target.attr("tip-pos");
|
|
2577
|
+
if (!p) p = "";
|
|
2578
|
+
$("tip").remove();
|
|
2579
|
+
$("body").append(tip.replace("[[T]]", t).replace("[[P]]", p));
|
|
2580
|
+
_isTipped = true;
|
|
2581
|
+
let _tipSc = target;
|
|
2582
|
+
while (true) {
|
|
2583
|
+
if (_isScrollable(_tipSc) || _tipSc[0] == $("body")[0]) break;
|
|
2584
|
+
_tipSc = _tipSc.parent();
|
|
2585
|
+
}
|
|
2586
|
+
var self = target;
|
|
2587
|
+
_setPos(self, p, _tipSc);
|
|
2588
|
+
_setPos(self, p, _tipSc);
|
|
2589
|
+
target.data("_tipSc", _tipSc);
|
|
2590
|
+
_tipSc.unbind("scroll.kuku").bind("scroll.kuku", function () {
|
|
2591
|
+
_setPos(self, p, _tipSc);
|
|
2592
|
+
});
|
|
2593
|
+
} else {
|
|
2594
|
+
$("tip").remove();
|
|
2595
|
+
_isTipped = false;
|
|
2596
|
+
}
|
|
2597
|
+
} else {
|
|
2598
|
+
$("body").unbind("scroll.kuku");
|
|
2599
|
+
$("tip").remove();
|
|
2600
|
+
_isTipped = false;
|
|
2601
|
+
}
|
|
2602
|
+
});
|
|
2603
|
+
|
|
2604
|
+
$("[numeric]").each(function () {
|
|
2605
|
+
$(this).removeAttr("numeric").numeric();
|
|
2606
|
+
});
|
|
2607
|
+
|
|
2608
|
+
$("[pattern]").each(function () {
|
|
2609
|
+
$(this).data("pattern", $(this).attr("pattern")).removeAttr("pattern");
|
|
2610
|
+
});
|
|
2611
|
+
|
|
2612
|
+
$("[integer]:not([pve])").each(function () {
|
|
2613
|
+
$(this).removeAttr("integer").numeric(
|
|
2614
|
+
{
|
|
2615
|
+
decimal: false,
|
|
2616
|
+
} /*, function () { alert("Integers only!"); this.value = ""; this.focus(); }*/
|
|
2617
|
+
);
|
|
2618
|
+
});
|
|
2619
|
+
$("[integer][pve]").each(function () {
|
|
2620
|
+
$(this).removeAttr("integer").numeric(
|
|
2621
|
+
{
|
|
2622
|
+
decimal: false,
|
|
2623
|
+
negative: false,
|
|
2624
|
+
} /*, function () { alert("Positive integers only!"); this.value = ""; this.focus(); }*/
|
|
2625
|
+
);
|
|
2626
|
+
});
|
|
2627
|
+
$("[decimal]:not([pve])").each(function () {
|
|
2628
|
+
var places = -1;
|
|
2629
|
+
if ($(this).is("[dp0]")) places = 0;
|
|
2630
|
+
else if ($(this).is("[dp1]")) places = 1;
|
|
2631
|
+
else if ($(this).is("[dp2]")) places = 2;
|
|
2632
|
+
else if ($(this).is("[dp3]")) places = 3;
|
|
2633
|
+
else if ($(this).is("[dp4]")) places = 4;
|
|
2634
|
+
if (places >= 0)
|
|
2635
|
+
$(this)
|
|
2636
|
+
.removeAttr("decimal")
|
|
2637
|
+
.numeric(
|
|
2638
|
+
{
|
|
2639
|
+
decimalPlaces: places,
|
|
2640
|
+
decimal: places == 0 ? false : ".",
|
|
2641
|
+
} /*, function () { alert("Decimals Only!"); this.value = ""; this.focus(); }*/
|
|
2642
|
+
);
|
|
2643
|
+
else
|
|
2644
|
+
$(this)
|
|
2645
|
+
.removeAttr("decimal")
|
|
2646
|
+
.numeric(
|
|
2647
|
+
{} /*, function () { alert("Decimals Only!"); this.value = ""; this.focus(); }*/
|
|
2648
|
+
);
|
|
2649
|
+
});
|
|
2650
|
+
$("[decimal][pve]").each(function () {
|
|
2651
|
+
var places = -1;
|
|
2652
|
+
if ($(this).is("[dp0]")) places = 0;
|
|
2653
|
+
else if ($(this).is("[dp1]")) places = 1;
|
|
2654
|
+
else if ($(this).is("[dp2]")) places = 2;
|
|
2655
|
+
else if ($(this).is("[dp3]")) places = 3;
|
|
2656
|
+
else if ($(this).is("[dp4]")) places = 4;
|
|
2657
|
+
if (places >= 0)
|
|
2658
|
+
$(this)
|
|
2659
|
+
.removeAttr("decimal")
|
|
2660
|
+
.numeric(
|
|
2661
|
+
{
|
|
2662
|
+
negative: false,
|
|
2663
|
+
decimalPlaces: places,
|
|
2664
|
+
decimal: places == 0 ? false : ".",
|
|
2665
|
+
} /*, function () { alert("Positive Decimals Only!"); this.value = ""; this.focus(); }*/
|
|
2666
|
+
);
|
|
2667
|
+
else
|
|
2668
|
+
$(this).removeAttr("decimal").numeric(
|
|
2669
|
+
{
|
|
2670
|
+
negative: false,
|
|
2671
|
+
} /*, function () { alert("Positive Decimals Only!"); this.value = ""; this.focus(); }*/
|
|
2672
|
+
);
|
|
2673
|
+
});
|
|
2674
|
+
|
|
2675
|
+
$("[time]").each(function () {
|
|
2676
|
+
dtp($(this), "time");
|
|
2677
|
+
});
|
|
2678
|
+
$("[date]").each(function () {
|
|
2679
|
+
dtp($(this), "date");
|
|
2680
|
+
});
|
|
2681
|
+
$("[datetime]").each(function () {
|
|
2682
|
+
dtp($(this), "datetime");
|
|
2683
|
+
});
|
|
2684
|
+
|
|
2685
|
+
$("[color]").each(function () {
|
|
2686
|
+
$(this).removeAttr("color").colorpicker({
|
|
2687
|
+
format: "rgba",
|
|
2688
|
+
});
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
function dtp(el, t) {
|
|
2693
|
+
el.removeAttr(t);
|
|
2694
|
+
let opts = {
|
|
2695
|
+
format:
|
|
2696
|
+
t == "date" ? "yyyy-mm-dd" : t == "time" ? "hh:ii" : "yyyy-mm-dd hh:ii",
|
|
2697
|
+
weekStart: el.attr("date-week-start") ?? 1,
|
|
2698
|
+
startView: t == "time" ? 1 : 2,
|
|
2699
|
+
minView: el.attr("minview") ? el.attr("minview") : t == "time" ? 0 : t == "datetime" ? 0 : 2,
|
|
2700
|
+
maxView: el.attr("maxview") ? el.attr("maxview") : t == "time" ? 1 : 4,
|
|
2701
|
+
todayBtn: t == "time" ? 0 : el.attr("date-today") == "false" ? 0 : 1,
|
|
2702
|
+
todayHighlight: t == "time" ? 0 : el.attr("date-today") == "false" ? 0 : 1,
|
|
2703
|
+
language: el.attr("date-lang") ?? "en",
|
|
2704
|
+
minuteStep: el.attr("date-minute-step") ?? 5,
|
|
2705
|
+
pickerPosition: "top-right",
|
|
2706
|
+
autoclose: 1,
|
|
2707
|
+
showMeridian: false,
|
|
2708
|
+
};
|
|
2709
|
+
if (el.attr("date-start")) opts["startDate"] = el.attr("date-start");
|
|
2710
|
+
if (el.attr("date-end")) opts["endDate"] = el.attr("date-end");
|
|
2711
|
+
if (el.attr("date-value")) opts["date"] = el.attr("date-value");
|
|
2712
|
+
|
|
2713
|
+
el.datetimepicker(opts);
|
|
2714
|
+
|
|
2715
|
+
if (t == "time") {
|
|
2716
|
+
el.on("show", function (ev) {
|
|
2717
|
+
$(
|
|
2718
|
+
".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i"
|
|
2719
|
+
).attr(
|
|
2720
|
+
"style",
|
|
2721
|
+
"visibility: hidden; font-size:0px !Important; overflow: hidden; height: 0px;"
|
|
2722
|
+
);
|
|
2723
|
+
}).on("hide", function (ev) {
|
|
2724
|
+
$(
|
|
2725
|
+
".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i"
|
|
2726
|
+
).attr("style", "visibility: visible;");
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
if (el.attr("date-link-start")) {
|
|
2730
|
+
el.on("change", function (e) {
|
|
2731
|
+
let dp1 = el.data("datetimepicker");
|
|
2732
|
+
let dp2 = $(el.attr("date-link-start")).data("datetimepicker");
|
|
2733
|
+
dp2.setStartDate(dp1.getFormattedDate());
|
|
2734
|
+
if (
|
|
2735
|
+
dp2.getFormattedDate() < dp1.getFormattedDate() ||
|
|
2736
|
+
dp2.getFormattedDate() == ""
|
|
2737
|
+
)
|
|
2738
|
+
$(el.attr("date-link-start")).val(dp1.getFormattedDate());
|
|
2739
|
+
});
|
|
2740
|
+
} else if (el.attr("date-link-end")) {
|
|
2741
|
+
el.on("change", function (e) {
|
|
2742
|
+
let dp1 = $(el.attr("date-link-end")).data("datetimepicker");
|
|
2743
|
+
let dp2 = el.data("datetimepicker");
|
|
2744
|
+
dp1.setEndDate(dp2.getFormattedDate());
|
|
2745
|
+
// if(dp2.getFormattedDate()<dp1.getFormattedDate() || dp2.getFormattedDate()=='') $(el.attr('date-link-start')).val(dp1.getFormattedDate());
|
|
2746
|
+
});
|
|
2747
|
+
opts["useCurrent"] = false;
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
function avc(t, n, o, d = null) {
|
|
2752
|
+
if (t.attr(n.toLowerCase()))
|
|
2753
|
+
o[n.toLowerCase().split("sort-").join("").split("drop-").join("").split("drag-").join("")] = t.attr(
|
|
2754
|
+
n.toLowerCase()
|
|
2755
|
+
);
|
|
2756
|
+
else if (d != null)
|
|
2757
|
+
o[n.toLowerCase().split("sort-").join("").split("drop-").join("").split("drag-").join("")] = d;
|
|
2758
|
+
return o;
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
function applyTriggers() {
|
|
2762
|
+
$("[click]").each(function () {
|
|
2763
|
+
$(this).trigger("click").removeAttr("click");
|
|
2764
|
+
});
|
|
2765
|
+
$("[focus]").each(function () {
|
|
2766
|
+
$(this).trigger("focus").removeAttr("focus");
|
|
2767
|
+
});
|
|
2768
|
+
|
|
2769
|
+
let _Ns = [];
|
|
2770
|
+
for (let x = 9; x >= 0; x--) {
|
|
2771
|
+
let _els = $("[n" + x + "]");
|
|
2772
|
+
_els.each(function () {
|
|
2773
|
+
let _el = $(this);
|
|
2774
|
+
// if (!_el.data('_Ns')) {
|
|
2775
|
+
let _d = {};
|
|
2776
|
+
for (let y = 9; y >= 0; y--) {
|
|
2777
|
+
if (_el.hasAttr("n" + y)) {
|
|
2778
|
+
_d["n" + y] = _el.attr("n" + y).split(",");
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
_el.data('_Ns', _d);
|
|
2782
|
+
_Ns.push(_el);
|
|
2783
|
+
// _el.removeClass("active");
|
|
2784
|
+
// }
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
for (let i = 0; i < _Ns.length; i++) {
|
|
2789
|
+
const _n = _Ns[i];
|
|
2790
|
+
let _act = [];
|
|
2791
|
+
let attrs = _n.data('_Ns');
|
|
2792
|
+
|
|
2793
|
+
for (const nK in attrs) {
|
|
2794
|
+
if (Object.hasOwnProperty.call(attrs, nK)) {
|
|
2795
|
+
const nV = attrs[nK];
|
|
2796
|
+
let index = nK.slice(1);
|
|
2797
|
+
if (nV.indexOf(nodes[index]) != -1) {
|
|
2798
|
+
_act.push(true);
|
|
2799
|
+
} else {
|
|
2800
|
+
_act.push(false);
|
|
2801
|
+
break;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
setTimeout(() => {
|
|
2806
|
+
if (_act.indexOf(false) != -1) _n.removeClass("active");
|
|
2807
|
+
else _n.addClass("active");
|
|
2808
|
+
});
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
|
|
2812
|
+
// if (nodes[x]) {
|
|
2813
|
+
// $("[n" + x + "]").each(function () {
|
|
2814
|
+
// let attr = $(this)
|
|
2815
|
+
// .attr("n" + x)
|
|
2816
|
+
// .split(",");
|
|
2817
|
+
// for (let index = 0; index < attr.length; index++) {
|
|
2818
|
+
// if (attr[index] == nodes[x]) {
|
|
2819
|
+
// $(this).addClass("active");
|
|
2820
|
+
// }
|
|
2821
|
+
// }
|
|
2822
|
+
// });
|
|
2823
|
+
// }
|
|
2824
|
+
|
|
2825
|
+
|
|
2826
|
+
if (typeof viewLoaded === "function" && !_viewLoaded) {
|
|
2827
|
+
_viewLoaded = true;
|
|
2828
|
+
viewLoaded();
|
|
2829
|
+
}
|
|
2830
|
+
$(
|
|
2831
|
+
"[\\@scroll],[\\@scroll-start],[\\@scroll-end],[\\@scroll-left],[\\@scroll-right],[\\@scroll-top],[\\@scroll-bottom]"
|
|
2832
|
+
)
|
|
2833
|
+
.unbind("scroll touchmove scrollstart scrollend")
|
|
2834
|
+
.on("scroll touchmove scrollstart scrollend", function (ev) {
|
|
2835
|
+
let el = $(this);
|
|
2836
|
+
if (ev.type == "scrollend") {
|
|
2837
|
+
var newScrollLeft = el.scrollLeft(),
|
|
2838
|
+
newScrollTop = el.scrollTop(),
|
|
2839
|
+
width = el.width(),
|
|
2840
|
+
scrollWidth = el.get(0).scrollWidth,
|
|
2841
|
+
scrollHeight = el.get(0).scrollHeight;
|
|
2842
|
+
|
|
2843
|
+
var hasScX = el.prop("scrollWidth") > el.width();
|
|
2844
|
+
var hasScY = el.prop("scrollHeight") > el.height();
|
|
2845
|
+
|
|
2846
|
+
if (newScrollLeft == 0) {
|
|
2847
|
+
processEv(ev, el, "scroll-left");
|
|
2848
|
+
} else if (
|
|
2849
|
+
Math.round(
|
|
2850
|
+
scrollWidth - newScrollLeft - width - (hasScY ? -_scW : 0)
|
|
2851
|
+
) == 0
|
|
2852
|
+
) {
|
|
2853
|
+
processEv(ev, el, "scroll-right");
|
|
2854
|
+
}
|
|
2855
|
+
if (newScrollTop == 0) {
|
|
2856
|
+
processEv(ev, el, "scroll-top");
|
|
2857
|
+
} else if (
|
|
2858
|
+
newScrollTop + el.innerHeight() >=
|
|
2859
|
+
scrollHeight - (hasScX ? -_scW : 0)
|
|
2860
|
+
) {
|
|
2861
|
+
processEv(ev, el, "scroll-bottom");
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
processEv(
|
|
2865
|
+
ev,
|
|
2866
|
+
el,
|
|
2867
|
+
ev.type.length == 6 ? "scroll" : ev.type.split("scroll").join("scroll-")
|
|
2868
|
+
);
|
|
2869
|
+
});
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
_viewLoaded = false;
|
|
2873
|
+
function globalWatch() {
|
|
2874
|
+
if (!_initialized) return;
|
|
2875
|
+
|
|
2876
|
+
|
|
2877
|
+
return;
|
|
2878
|
+
|
|
2879
|
+
$("[beajs=1]").remove();
|
|
2880
|
+
$('script[type="beajs"]').each(function () {
|
|
2881
|
+
var html = $(this).html();
|
|
2882
|
+
$(this).remove();
|
|
2883
|
+
var myScript = document.createElement("script");
|
|
2884
|
+
myScript.setAttribute("beajs", "1");
|
|
2885
|
+
myScript.textContent = html;
|
|
2886
|
+
document.body.appendChild(myScript);
|
|
2887
|
+
});
|
|
2888
|
+
let bindsCount = 0;
|
|
2889
|
+
let prom = defer();
|
|
2890
|
+
$("[bind]:not(.binded)").each(function () {
|
|
2891
|
+
bindsCount++;
|
|
2892
|
+
let _el = $(this);
|
|
2893
|
+
_el.addClass("binded");
|
|
2894
|
+
if (!setRe(_el, _el.attr("bind")))
|
|
2895
|
+
setError(
|
|
2896
|
+
null,
|
|
2897
|
+
"Error in binding for the element that has these in its bind attribute " +
|
|
2898
|
+
_el.attr("bind")
|
|
2899
|
+
);
|
|
2900
|
+
});
|
|
2901
|
+
prom
|
|
2902
|
+
.then(function (val) {
|
|
2903
|
+
renderViewsTpls();
|
|
2904
|
+
renderPlugins();
|
|
2905
|
+
loadPics();
|
|
2906
|
+
reloads();
|
|
2907
|
+
let tickFunc =
|
|
2908
|
+
appSettings.tick && typeof appSettings.tick === "function"
|
|
2909
|
+
? appSettings.tick
|
|
2910
|
+
: typeof tick === "function"
|
|
2911
|
+
? tick
|
|
2912
|
+
: null;
|
|
2913
|
+
if (typeof tickFunc === "function") tickFunc();
|
|
2914
|
+
})
|
|
2915
|
+
.catch((reason) => {
|
|
2916
|
+
renderViewsTpls();
|
|
2917
|
+
renderPlugins();
|
|
2918
|
+
loadPics();
|
|
2919
|
+
reloads();
|
|
2920
|
+
let tickFunc =
|
|
2921
|
+
appSettings.tick && typeof appSettings.tick === "function"
|
|
2922
|
+
? appSettings.tick
|
|
2923
|
+
: typeof tick === "function"
|
|
2924
|
+
? tick
|
|
2925
|
+
: null;
|
|
2926
|
+
if (typeof tickFunc === "function") tickFunc();
|
|
2927
|
+
});
|
|
2928
|
+
if (bindsCount == 0) {
|
|
2929
|
+
prom.resolve();
|
|
2930
|
+
}
|
|
2931
|
+
reloads();
|
|
2932
|
+
let tickFunc =
|
|
2933
|
+
appSettings.tick && typeof appSettings.tick === "function"
|
|
2934
|
+
? appSettings.tick
|
|
2935
|
+
: typeof tick === "function"
|
|
2936
|
+
? tick
|
|
2937
|
+
: null;
|
|
2938
|
+
if (typeof tickFunc === "function") tickFunc();
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
function loadPics() {
|
|
2942
|
+
$("[lazy]").each(function () {
|
|
2943
|
+
let _el = $(this);
|
|
2944
|
+
_el.lazy({
|
|
2945
|
+
effect: "show",
|
|
2946
|
+
bind: "event",
|
|
2947
|
+
// effectTime: 200,
|
|
2948
|
+
threshold: 200 /*Amount of pixels below the viewport, in which all images gets loaded before the user sees them.*/,
|
|
2949
|
+
visibleOnly: false /*Determine if only visible elements should be load.*/,
|
|
2950
|
+
beforeLoad: function (element) {
|
|
2951
|
+
/*alert('before loading ' + element.attr('data-src'));*/
|
|
2952
|
+
_el.removeAttr("lazy");
|
|
2953
|
+
},
|
|
2954
|
+
afterLoad: function (element) {
|
|
2955
|
+
/*alert('after loading ' + element.attr('data-src'));*/
|
|
2956
|
+
},
|
|
2957
|
+
onError: function (element) {
|
|
2958
|
+
/*alert('error loading ' + element.attr('data-src'));*/
|
|
2959
|
+
cl("error loading " + _el.attr("data-src"));
|
|
2960
|
+
},
|
|
2961
|
+
onFinishedAll: function () {
|
|
2962
|
+
/*alert('finish all');*/
|
|
2963
|
+
},
|
|
2964
|
+
});
|
|
2965
|
+
});
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
function paraToObj(para) {
|
|
2969
|
+
if (para == "") return JSON.parse("{}");
|
|
2970
|
+
return JSON.parse(
|
|
2971
|
+
'{"' +
|
|
2972
|
+
decodeURI(para)
|
|
2973
|
+
.replace(/"/g, '\\"')
|
|
2974
|
+
.replace(/&/g, '","')
|
|
2975
|
+
.replace(/=/g, '":"') +
|
|
2976
|
+
'"}'
|
|
2977
|
+
);
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
function getBind(b, d) {
|
|
2981
|
+
d = d ? d.split("&") : new Array();
|
|
2982
|
+
if (b) {
|
|
2983
|
+
var binder = b.split(",");
|
|
2984
|
+
for (var x = 0; x < binder.length; x++) {
|
|
2985
|
+
var finder = binder[x].split(" as ");
|
|
2986
|
+
if (finder[0].indexOf(" attr ") !== -1) {
|
|
2987
|
+
var findz = finder[0].split(" attr ");
|
|
2988
|
+
d.push(finder[1] + "=" + $.trim($(findz[0]).attr(findz[1])));
|
|
2989
|
+
} else if (finder[0].indexOf(" find ") !== -1) {
|
|
2990
|
+
var findz = finder[0].split(" find ");
|
|
2991
|
+
var val = getVal($(findz[0]).find(findz[1]));
|
|
2992
|
+
d.push(finder[1] + "=" + $.trim(val));
|
|
2993
|
+
} else if (finder[0].indexOf(" from ") !== -1) {
|
|
2994
|
+
var findz = finder[0].split(" from ");
|
|
2995
|
+
if (findz[1].toLowerCase() == "ls") {
|
|
2996
|
+
d.push(finder[1] + "=" + localStorage.getItem(findz[0]));
|
|
2997
|
+
} else {
|
|
2998
|
+
d.push(finder[1] + "=" + findz[0]);
|
|
2999
|
+
}
|
|
3000
|
+
} else d.push(finder[1] + "=" + getVal($(finder[0])));
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
d = d.join("&");
|
|
3004
|
+
return d;
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
function isPathLocal(path) {
|
|
3008
|
+
var local = false;
|
|
3009
|
+
var l = getLocation(path);
|
|
3010
|
+
var l2 = getLocation(appSettings.Base);
|
|
3011
|
+
var url = "home";
|
|
3012
|
+
local = l.hostname == l2.hostname;
|
|
3013
|
+
return local;
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
function checkFormInputs(f, inp, classesOnly) {
|
|
3017
|
+
var inputs = inp ? [inp] : f.find("[\\:required]:not([disabled])");
|
|
3018
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
3019
|
+
let el = $(inputs[i]);
|
|
3020
|
+
let pat = el.data("pattern");
|
|
3021
|
+
let req = el.hasAttr(":required");
|
|
3022
|
+
let lbl = el.closest("label");
|
|
3023
|
+
let fs = el.closest("fieldset");
|
|
3024
|
+
let max = el.attr("max");
|
|
3025
|
+
let max_num = el.attr("max-num");
|
|
3026
|
+
let min_num = el.attr("min-num");
|
|
3027
|
+
let v = el.val();
|
|
3028
|
+
var or = el.attr("or");
|
|
3029
|
+
if (or != "") {
|
|
3030
|
+
var or = f.find("[name='" + or + "']");
|
|
3031
|
+
}
|
|
3032
|
+
var into;
|
|
3033
|
+
let allCls =
|
|
3034
|
+
"is-not-checked is-checked is-valid is-not-empty is-empty is-invalid error success not-4-chars not-on-pattern";
|
|
3035
|
+
el.removeClass(allCls);
|
|
3036
|
+
el.parent().removeClass(allCls);
|
|
3037
|
+
if (lbl.length) lbl.removeClass(allCls);
|
|
3038
|
+
if (fs.length) fs.removeClass(allCls);
|
|
3039
|
+
if (el.is(":checkbox") || el.is(":radio")) {
|
|
3040
|
+
var isCheck = "is-not-checked" + (req ? " is-invalid" : "");
|
|
3041
|
+
if (el.is(":checked")) {
|
|
3042
|
+
isCheck = "is-checked" + (req ? " is-valid" : "");
|
|
3043
|
+
} else {
|
|
3044
|
+
if (or.length) {
|
|
3045
|
+
if (or.is(":checked")) {
|
|
3046
|
+
isCheck = "is-checked" + (req ? " is-valid" : "");
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
if (el.is(":radio")) {
|
|
3051
|
+
f.find("[name='" + el.attr("Name") + "']:radio")
|
|
3052
|
+
.not(el[0])
|
|
3053
|
+
.each(function () {
|
|
3054
|
+
let _el = $(this);
|
|
3055
|
+
let _req = _el.hasAttr(":required");
|
|
3056
|
+
var _isCheck = "is-not-checked" + (_req ? " is-invalid" : "");
|
|
3057
|
+
var _or = _el.attr("or");
|
|
3058
|
+
let _lbl = _el.closest("label");
|
|
3059
|
+
// let _fs = _el.closest("fieldset");
|
|
3060
|
+
_el.removeClass(allCls);
|
|
3061
|
+
_el.parent().removeClass(allCls);
|
|
3062
|
+
if (_lbl.length) _lbl.removeClass(allCls);
|
|
3063
|
+
// if (_fs.length) _fs.removeClass(allCls);
|
|
3064
|
+
if (_or != "") {
|
|
3065
|
+
var _or = f.find("[name='" + _or + "']");
|
|
3066
|
+
}
|
|
3067
|
+
if (_el.is(":checked")) {
|
|
3068
|
+
_isCheck = "is-checked" + (_req ? " is-valid" : "");
|
|
3069
|
+
} else {
|
|
3070
|
+
if (_or.length) {
|
|
3071
|
+
if (_or.is(":checked")) {
|
|
3072
|
+
_isCheck = "is-checked" + (_req ? " is-valid" : "");
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
if (_el.parent().prop("nodeName") != "FORM")
|
|
3077
|
+
_el.parent().addClass(_isCheck);
|
|
3078
|
+
if (_lbl.length) _lbl.addClass(_isCheck);
|
|
3079
|
+
// if (_fs.length) _fs.addClass(_isCheck);
|
|
3080
|
+
_el.addClass(_isCheck);
|
|
3081
|
+
});
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3084
|
+
if (el.parent().prop("nodeName") != "FORM") el.parent().addClass(isCheck);
|
|
3085
|
+
if (lbl.length) lbl.addClass(isCheck);
|
|
3086
|
+
// if (fs.length) fs.addClass(isCheck);
|
|
3087
|
+
el.addClass(isCheck);
|
|
3088
|
+
} else {
|
|
3089
|
+
var isV = "is-empty" + (req ? " is-invalid" : "");
|
|
3090
|
+
if (el.is("[username]")) {
|
|
3091
|
+
if (v.length && v.length < 4) {
|
|
3092
|
+
isV = "not-4-chars is-not-empty" + (req ? " is-invalid" : "");
|
|
3093
|
+
} else {
|
|
3094
|
+
let vld = true;
|
|
3095
|
+
var k = v.match(/[a-z]+(?!\.)(?!.*\.$)(?!.*?\_\_)[a-z0-9_]+[a-z0-9]/);
|
|
3096
|
+
if (!k) {
|
|
3097
|
+
vld = false;
|
|
3098
|
+
} else {
|
|
3099
|
+
if (k.input != k[0]) {
|
|
3100
|
+
vld = false;
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
if (vld) isV = "is-not-empty" + (req ? " is-valid" : "");
|
|
3104
|
+
else isV = "not-on-pattern is-not-empty" + (req ? " is-invalid" : "");
|
|
3105
|
+
}
|
|
3106
|
+
} else if (el.is("[password]")) {
|
|
3107
|
+
if (!passwordValid(v)) {
|
|
3108
|
+
isV = "is-not-empty" + (req ? " is-invalid" : "");
|
|
3109
|
+
} else {
|
|
3110
|
+
isV = "is-not-empty" + (req ? " is-valid" : "");
|
|
3111
|
+
}
|
|
3112
|
+
} else if (el.is("[rpassword]")) {
|
|
3113
|
+
if ($.trim(v) != $.trim(f.find("[password]").val())) {
|
|
3114
|
+
isV = "is-not-empty" + (req ? " is-invalid" : "");
|
|
3115
|
+
} else {
|
|
3116
|
+
isV = "is-not-empty" + (req ? " is-valid" : "");
|
|
3117
|
+
}
|
|
3118
|
+
} else {
|
|
3119
|
+
if ($.trim(v).length != 0) {
|
|
3120
|
+
if (max != "" && !isNaN(max)) {
|
|
3121
|
+
if ($.trim(v).length > max) {
|
|
3122
|
+
el.val($.trim($.trim(v).substr(0, max)));
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
if (min_num != "" && !isNaN(min_num)) {
|
|
3126
|
+
if (!isNaN($.trim(v))) {
|
|
3127
|
+
if (parseFloat($.trim(v)) < parseFloat(min_num))
|
|
3128
|
+
el.val($.trim(min_num));
|
|
3129
|
+
} else {
|
|
3130
|
+
el.val(min_num);
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
if (max_num != "" && !isNaN(max_num)) {
|
|
3135
|
+
if (!isNaN($.trim(v))) {
|
|
3136
|
+
if (parseFloat($.trim(v)) > parseFloat(max_num))
|
|
3137
|
+
el.val($.trim(max_num));
|
|
3138
|
+
} else {
|
|
3139
|
+
if (min_num != "" && !isNaN(min_num)) el.val($.trim(min_num));
|
|
3140
|
+
else el.val("0");
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
isV = "is-not-empty";
|
|
3144
|
+
if (pat != "") {
|
|
3145
|
+
pat = new RegExp(pat);
|
|
3146
|
+
if (pat.test($.trim(v))) {
|
|
3147
|
+
isV += req ? " is-valid" : "";
|
|
3148
|
+
} else {
|
|
3149
|
+
isV += req ? " is-invalid" : "";
|
|
3150
|
+
el.val("");
|
|
3151
|
+
}
|
|
3152
|
+
} else isV += req ? " is-valid" : "";
|
|
3153
|
+
} else {
|
|
3154
|
+
if (or.length) {
|
|
3155
|
+
if ($.trim(or.val()).length != 0) {
|
|
3156
|
+
isV = "is-not-empty" + (req ? " is-valid" : "");
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
if (el.parent().prop("nodeName") != "FORM") el.parent().addClass(isV);
|
|
3162
|
+
if (lbl.length) lbl.addClass(isV);
|
|
3163
|
+
// if (fs.length) fs.addClass(isV);
|
|
3164
|
+
el.addClass(isV);
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
var isRadioChecked = false;
|
|
3168
|
+
if (el.is(":radio")) {
|
|
3169
|
+
if (el.hasClass("is-invalid")) {
|
|
3170
|
+
f.find("[name='" + el.attr("Name") + "']:radio")
|
|
3171
|
+
.not(el[0])
|
|
3172
|
+
.each(function () {
|
|
3173
|
+
if ($(this).hasClass("is-valid")) {
|
|
3174
|
+
isRadioChecked = true;
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
} else {
|
|
3178
|
+
isRadioChecked = true;
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
if (el.hasClass("is-invalid") || (el.is(":radio") && !isRadioChecked)) {
|
|
3183
|
+
if (el.hasAttr("data-into")) {
|
|
3184
|
+
let intoTxt = el.data("into");
|
|
3185
|
+
if (lbl.length) into = lbl.find(intoTxt);
|
|
3186
|
+
if (!into) if (fs.length) into = fs.find(intoTxt);
|
|
3187
|
+
if (!into) into = $(intoTxt);
|
|
3188
|
+
if (into.length) {
|
|
3189
|
+
if (el.is("[password]")) {
|
|
3190
|
+
if ($.trim(v).length == 0) into.text(el.attr("data-empty"));
|
|
3191
|
+
else if (el.hasAttr("data-wpm")) into.text(el.attr("data-wpm"));
|
|
3192
|
+
let rpass = f.find("[rpassword]");
|
|
3193
|
+
if (rpass.length)
|
|
3194
|
+
if ($.trim(rpass.val()).length != 0)
|
|
3195
|
+
checkFormInputs(f, rpass, true);
|
|
3196
|
+
} else if (el.is("[rpassword]")) {
|
|
3197
|
+
if ($.trim(v).length == 0) into.text(el.attr("data-empty"));
|
|
3198
|
+
else if (el.hasAttr("data-pnm")) into.text(el.attr("data-pnm"));
|
|
3199
|
+
} else if (el.is("[username]")) {
|
|
3200
|
+
let txt = el.hasAttr("data-empty")
|
|
3201
|
+
? el.attr("data-empty")
|
|
3202
|
+
: el.attr("placeholder");
|
|
3203
|
+
if ($.trim(v).length == 0) into.text(txt);
|
|
3204
|
+
else {
|
|
3205
|
+
if (el.hasClass("not-4-chars")) {
|
|
3206
|
+
if (el.hasAttr("data-4-chars")) txt = el.attr("data-4-chars");
|
|
3207
|
+
} else if (el.hasClass("not-on-pattern")) {
|
|
3208
|
+
if (el.hasAttr("data-chars-not-allowed"))
|
|
3209
|
+
txt = el.attr("data-chars-not-allowed");
|
|
3210
|
+
}
|
|
3211
|
+
into.text(txt);
|
|
3212
|
+
}
|
|
3213
|
+
} else if (el.hasAttr("data-empty")) {
|
|
3214
|
+
into.text(el.attr("data-empty"));
|
|
3215
|
+
} else {
|
|
3216
|
+
if (el.is(":checkbox") || el.is(":radio")) {
|
|
3217
|
+
// alert("checkbox or radio don't have data-empty attribute");
|
|
3218
|
+
into.text(el.attr("placeholder"));
|
|
3219
|
+
} else {
|
|
3220
|
+
into.text(el.attr("placeholder"));
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
if (!classesOnly) {
|
|
3226
|
+
if (el.is(":radio")) {
|
|
3227
|
+
if (!isRadioChecked) {
|
|
3228
|
+
if (fs.length) fs.addClass(isCheck);
|
|
3229
|
+
el.focus();
|
|
3230
|
+
return false;
|
|
3231
|
+
}
|
|
3232
|
+
} else {
|
|
3233
|
+
if (fs.length) fs.addClass(isV);
|
|
3234
|
+
el.focus();
|
|
3235
|
+
return false;
|
|
3236
|
+
}
|
|
3237
|
+
} else {
|
|
3238
|
+
if (el.is(":radio")) {
|
|
3239
|
+
if (!isRadioChecked) {
|
|
3240
|
+
if (fs.length) fs.addClass(isCheck);
|
|
3241
|
+
}
|
|
3242
|
+
} else {
|
|
3243
|
+
if (fs.length) fs.addClass(isV);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
} else if (el.hasClass("is-valid")) {
|
|
3247
|
+
if (el.hasAttr("data-into")) {
|
|
3248
|
+
let intoTxt = el.data("into");
|
|
3249
|
+
if (lbl.length) into = lbl.find(intoTxt);
|
|
3250
|
+
if (fs.length) into = fs.find(intoTxt);
|
|
3251
|
+
if (!into) into = $(intoTxt);
|
|
3252
|
+
if (into.length) {
|
|
3253
|
+
into.text("");
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
return true;
|
|
3260
|
+
}
|
|
3261
|
+
function validateInputs(f) {
|
|
3262
|
+
if (f.hasAttr("ax-before")) {
|
|
3263
|
+
var bfs = f.attr("ax-before");
|
|
3264
|
+
if (typeof window[bfs] === "function") {
|
|
3265
|
+
if (window[bfs](f) === false) return false;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
var inps = [];
|
|
3270
|
+
f.find("input.required,select.required,textarea.required").each(function () {
|
|
3271
|
+
inps.push($(this).attr("name"));
|
|
3272
|
+
});
|
|
3273
|
+
for (var i = 0; i < inps.length; i++) {
|
|
3274
|
+
var inp = f.find("input[name='" + inps[i] + "']");
|
|
3275
|
+
var sel = f.find('select[name="' + inps[i] + '"]');
|
|
3276
|
+
var txt = f.find('textarea[name="' + inps[i] + '"]');
|
|
3277
|
+
var e = inp;
|
|
3278
|
+
if (!e.length) e = sel;
|
|
3279
|
+
if (!e.length) e = txt;
|
|
3280
|
+
var or = e.attr("or");
|
|
3281
|
+
|
|
3282
|
+
if (or != "") {
|
|
3283
|
+
var inp2 = f.find("input[name='" + or + "']");
|
|
3284
|
+
var sel2 = f.find('select[name="' + or + '"]');
|
|
3285
|
+
var txt2 = f.find('textarea[name="' + or + '"]');
|
|
3286
|
+
var or = inp2;
|
|
3287
|
+
if (!or.length) or = sel2;
|
|
3288
|
+
if (!or.length) or = txt2;
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3291
|
+
if (e.is(":checkbox") || e.is(":radio")) {
|
|
3292
|
+
if (!e.is(":checked")) {
|
|
3293
|
+
if (or.length) {
|
|
3294
|
+
if (!or.is(":checked")) {
|
|
3295
|
+
alert(e.attr("placeholder") + " or " + or.attr("placeholder"));
|
|
3296
|
+
e.addClass("error");
|
|
3297
|
+
e.focus();
|
|
3298
|
+
return false;
|
|
3299
|
+
}
|
|
3300
|
+
} else {
|
|
3301
|
+
alert(e.attr("placeholder"));
|
|
3302
|
+
e.addClass("error");
|
|
3303
|
+
e.focus();
|
|
3304
|
+
return false;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
} else {
|
|
3308
|
+
if ($.trim(e.val()).length == 0) {
|
|
3309
|
+
if (or.length) {
|
|
3310
|
+
if ($.trim(or.val()).length == 0) {
|
|
3311
|
+
alert(e.attr("placeholder") + " or " + or.attr("placeholder"));
|
|
3312
|
+
e.addClass("error");
|
|
3313
|
+
e.focus();
|
|
3314
|
+
return false;
|
|
3315
|
+
}
|
|
3316
|
+
} else {
|
|
3317
|
+
alert(e.attr("placeholder"));
|
|
3318
|
+
e.addClass("error");
|
|
3319
|
+
e.focus();
|
|
3320
|
+
return false;
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
|
|
3324
|
+
if (e.is("[password]")) {
|
|
3325
|
+
if (!passwordValid(e.val())) {
|
|
3326
|
+
alert(e.attr("data-wpm"));
|
|
3327
|
+
e.addClass("error");
|
|
3328
|
+
e.focus();
|
|
3329
|
+
return false;
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
if (e.is("[rpassword]")) {
|
|
3333
|
+
if (
|
|
3334
|
+
$.trim(e.val()) != $.trim(e.closest("form").find("[password]").val())
|
|
3335
|
+
) {
|
|
3336
|
+
e.addClass("error");
|
|
3337
|
+
alert(e.attr("data-pnm"));
|
|
3338
|
+
e.focus();
|
|
3339
|
+
return false;
|
|
3340
|
+
}
|
|
3341
|
+
e.removeClass("error");
|
|
3342
|
+
$(".passStrength").remove();
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
return true;
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
|
|
3351
|
+
let _cookies = {
|
|
3352
|
+
getItem: function (sKey) {
|
|
3353
|
+
if (!sKey) { return null; }
|
|
3354
|
+
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
|
|
3355
|
+
},
|
|
3356
|
+
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
|
|
3357
|
+
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
|
|
3358
|
+
var sExpires = "";
|
|
3359
|
+
if (vEnd) {
|
|
3360
|
+
switch (vEnd.constructor) {
|
|
3361
|
+
case Number:
|
|
3362
|
+
sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
|
|
3363
|
+
break;
|
|
3364
|
+
case String:
|
|
3365
|
+
sExpires = "; expires=" + vEnd;
|
|
3366
|
+
break;
|
|
3367
|
+
case Date:
|
|
3368
|
+
sExpires = "; expires=" + vEnd.toUTCString();
|
|
3369
|
+
break;
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
3372
|
+
if (!sPath) sPath = "/";
|
|
3373
|
+
document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
|
|
3374
|
+
return true;
|
|
3375
|
+
},
|
|
3376
|
+
removeItem: function (sKey, sPath, sDomain) {
|
|
3377
|
+
if (!this.hasItem(sKey)) { return false; }
|
|
3378
|
+
document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "");
|
|
3379
|
+
return true;
|
|
3380
|
+
},
|
|
3381
|
+
hasItem: function (sKey) {
|
|
3382
|
+
if (!sKey) { return false; }
|
|
3383
|
+
return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
|
|
3384
|
+
},
|
|
3385
|
+
keys: function () {
|
|
3386
|
+
var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
|
|
3387
|
+
for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); }
|
|
3388
|
+
return aKeys;
|
|
3389
|
+
}
|
|
3390
|
+
};
|
|
3391
|
+
var cookies = new Proxy(_cookies, {
|
|
3392
|
+
get(target, key) {
|
|
3393
|
+
return target[key] ?? target.getItem(key) ?? undefined;
|
|
3394
|
+
},
|
|
3395
|
+
set(target, key, value) {
|
|
3396
|
+
if (key in target) {
|
|
3397
|
+
return false;
|
|
3398
|
+
}
|
|
3399
|
+
return target.setItem(key, value);
|
|
3400
|
+
},
|
|
3401
|
+
deleteProperty(target, key) {
|
|
3402
|
+
if (!(key in target)) {
|
|
3403
|
+
return false;
|
|
3404
|
+
}
|
|
3405
|
+
return target.removeItem(key);
|
|
3406
|
+
},
|
|
3407
|
+
ownKeys(target) {
|
|
3408
|
+
return target.keys();
|
|
3409
|
+
},
|
|
3410
|
+
has(target, key) {
|
|
3411
|
+
return key in target || target.hasItem(key);
|
|
3412
|
+
},
|
|
3413
|
+
defineProperty(target, key, descriptor) {
|
|
3414
|
+
if (descriptor && "value" in descriptor) {
|
|
3415
|
+
target.setItem(key, descriptor.value);
|
|
3416
|
+
}
|
|
3417
|
+
return target;
|
|
3418
|
+
},
|
|
3419
|
+
getOwnPropertyDescriptor(target, key) {
|
|
3420
|
+
const value = target.getItem(key);
|
|
3421
|
+
return value
|
|
3422
|
+
? {
|
|
3423
|
+
value,
|
|
3424
|
+
enumerable: true,
|
|
3425
|
+
configurable: true,
|
|
3426
|
+
}
|
|
3427
|
+
: undefined;
|
|
3428
|
+
},
|
|
3429
|
+
});
|
|
3430
|
+
|
|
3431
|
+
function getCookie(n) {
|
|
3432
|
+
return cookies[n];
|
|
3433
|
+
}
|
|
3434
|
+
|
|
3435
|
+
function setCookie(n, v, d, p, e) {
|
|
3436
|
+
var now = new Date();
|
|
3437
|
+
var time = now.getTime();
|
|
3438
|
+
if (!e) e = time + 24 * 60 * 60 * 1000 * 365;
|
|
3439
|
+
else e = time + e;
|
|
3440
|
+
if (!d) d = window.location.hostname;
|
|
3441
|
+
if (!p) p = "/";
|
|
3442
|
+
now.setTime(e);
|
|
3443
|
+
return cookies.setItem(n, v, now.toGMTString(), p, d, true);
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3446
|
+
function getComData(c, fromHTML) {
|
|
3447
|
+
if (fromHTML) {
|
|
3448
|
+
try {
|
|
3449
|
+
var el = $("<div></div>");
|
|
3450
|
+
el.html(c.html());
|
|
3451
|
+
var k = {};
|
|
3452
|
+
|
|
3453
|
+
var mtitle = $("modal-title", el).html();
|
|
3454
|
+
if (!mtitle) mtitle = "";
|
|
3455
|
+
|
|
3456
|
+
var mbody = $("modal-body", el).html();
|
|
3457
|
+
if (!mbody) mbody = "";
|
|
3458
|
+
|
|
3459
|
+
var mdesc = $("modal-description", el).html();
|
|
3460
|
+
if (!mdesc) mdesc = "";
|
|
3461
|
+
|
|
3462
|
+
var mfoot = $("modal-footer", el).html();
|
|
3463
|
+
if (!mfoot) mfoot = "";
|
|
3464
|
+
|
|
3465
|
+
k.Title = mtitle;
|
|
3466
|
+
k.Body = mbody;
|
|
3467
|
+
k.Description = mdesc;
|
|
3468
|
+
k.Footer = mfoot;
|
|
3469
|
+
c = k;
|
|
3470
|
+
return c;
|
|
3471
|
+
} catch (e) {
|
|
3472
|
+
return false;
|
|
3473
|
+
}
|
|
3474
|
+
|
|
3475
|
+
return false;
|
|
3476
|
+
}
|
|
3477
|
+
try {
|
|
3478
|
+
c = c
|
|
3479
|
+
.contents()
|
|
3480
|
+
.filter(function () {
|
|
3481
|
+
return this.nodeType === 8;
|
|
3482
|
+
})
|
|
3483
|
+
.get(0);
|
|
3484
|
+
|
|
3485
|
+
if (c.nodeValue == "") return false;
|
|
3486
|
+
try {
|
|
3487
|
+
c = JSON.parse(c.nodeValue);
|
|
3488
|
+
} catch (e) {
|
|
3489
|
+
try {
|
|
3490
|
+
c = JSON.parse(atob(c.nodeValue));
|
|
3491
|
+
} catch (e) {
|
|
3492
|
+
try {
|
|
3493
|
+
var el = $("<div></div>");
|
|
3494
|
+
el.html(c.nodeValue);
|
|
3495
|
+
var k = {};
|
|
3496
|
+
|
|
3497
|
+
var mtitle = $("modal-title", el).html();
|
|
3498
|
+
if (!mtitle) mtitle = "";
|
|
3499
|
+
|
|
3500
|
+
var mbody = $("modal-body", el).html();
|
|
3501
|
+
if (!mbody) mbody = "";
|
|
3502
|
+
|
|
3503
|
+
var mdesc = $("modal-description", el).html();
|
|
3504
|
+
if (!mdesc) mdesc = "";
|
|
3505
|
+
|
|
3506
|
+
var mfoot = $("modal-footer", el).html();
|
|
3507
|
+
if (!mfoot) mfoot = "";
|
|
3508
|
+
|
|
3509
|
+
k.Title = mtitle;
|
|
3510
|
+
k.Body = mbody;
|
|
3511
|
+
k.Description = mdesc;
|
|
3512
|
+
k.Footer = mfoot;
|
|
3513
|
+
c = k;
|
|
3514
|
+
} catch (e) {
|
|
3515
|
+
return false;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
return c;
|
|
3520
|
+
} catch (e) {
|
|
3521
|
+
return false;
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
|
|
3525
|
+
function addOrChangeParameters(url, params) {
|
|
3526
|
+
let splitParams = {};
|
|
3527
|
+
let splitPath = /(.*)[?](.*)/.exec(url);
|
|
3528
|
+
if (splitPath && splitPath[2])
|
|
3529
|
+
splitPath[2].split("&").forEach((k) => {
|
|
3530
|
+
let d = k.split("=");
|
|
3531
|
+
splitParams[d[0]] = d[1];
|
|
3532
|
+
});
|
|
3533
|
+
let newParams = Object.assign(splitParams, params);
|
|
3534
|
+
let finalParams = Object.keys(newParams)
|
|
3535
|
+
.map((a) => a + "=" + newParams[a])
|
|
3536
|
+
.join("&");
|
|
3537
|
+
return splitPath ? splitPath[1] + "?" + finalParams : url + "?" + finalParams;
|
|
3538
|
+
}
|
|
3539
|
+
|
|
3540
|
+
//class SDK//
|
|
3541
|
+
class BEA {
|
|
3542
|
+
Cart = null;
|
|
3543
|
+
Products = null;
|
|
3544
|
+
Authorize = null;
|
|
3545
|
+
Pay = null;
|
|
3546
|
+
localCache = true;
|
|
3547
|
+
_prom = null;
|
|
3548
|
+
proms = [];
|
|
3549
|
+
l = "En";
|
|
3550
|
+
fields = {
|
|
3551
|
+
Section: "Section,Title,Text",
|
|
3552
|
+
Product: "Name,Price,Quantity",
|
|
3553
|
+
};
|
|
3554
|
+
constructor(options) {
|
|
3555
|
+
if (options === undefined) options = {};
|
|
3556
|
+
if (!Object.keys(options).length == 0) {
|
|
3557
|
+
if (options.hasOwnProperty("fields")) {
|
|
3558
|
+
for (var i in options["fields"]) {
|
|
3559
|
+
this.fields[i] = options["fields"][i];
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
if (options.hasOwnProperty("localisation")) this.l = options.localisation;
|
|
3563
|
+
if (options.hasOwnProperty("locale") && options.locale === true) {
|
|
3564
|
+
this.getLocale();
|
|
3565
|
+
}
|
|
3566
|
+
if (options.hasOwnProperty("sections") && options.sections === true) {
|
|
3567
|
+
this.getSections();
|
|
3568
|
+
}
|
|
3569
|
+
if (
|
|
3570
|
+
options.hasOwnProperty("localCache") &&
|
|
3571
|
+
options.localCache === false
|
|
3572
|
+
) {
|
|
3573
|
+
this.localCache = false;
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
this.Cart = new Cart(this);
|
|
3577
|
+
this.Products = new Products(this);
|
|
3578
|
+
this.Authorize = new Authorize(this);
|
|
3579
|
+
this.Pay = new Pay(this);
|
|
3580
|
+
this._prom = Promise.all(this.proms);
|
|
3581
|
+
}
|
|
3582
|
+
|
|
3583
|
+
request(className, data, async, type, a) {
|
|
3584
|
+
var prom = defer();
|
|
3585
|
+
var x;
|
|
3586
|
+
API.req(className, data, null, type, a ?? 0).then((r) => {
|
|
3587
|
+
if (async) {
|
|
3588
|
+
prom.resolve(r);
|
|
3589
|
+
} else {
|
|
3590
|
+
x = r.results;
|
|
3591
|
+
}
|
|
3592
|
+
});
|
|
3593
|
+
if (async) return prom;
|
|
3594
|
+
return x;
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3597
|
+
getSections() {
|
|
3598
|
+
var sec = new Section(this);
|
|
3599
|
+
this.proms.push(sec._prom);
|
|
3600
|
+
return sec.get();
|
|
3601
|
+
}
|
|
3602
|
+
|
|
3603
|
+
getLocale() {
|
|
3604
|
+
var loc = new Locale(this);
|
|
3605
|
+
this.proms.push(loc._prom);
|
|
3606
|
+
return loc.get();
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
order() {
|
|
3610
|
+
let prom = defer();
|
|
3611
|
+
var ids = "";
|
|
3612
|
+
var productsInfo;
|
|
3613
|
+
var user;
|
|
3614
|
+
var orderData = {
|
|
3615
|
+
User: "",
|
|
3616
|
+
productItems: [],
|
|
3617
|
+
Amount: 0,
|
|
3618
|
+
};
|
|
3619
|
+
|
|
3620
|
+
user = this.Authorize.me();
|
|
3621
|
+
orderData.User = user.objectId;
|
|
3622
|
+
|
|
3623
|
+
$.each(this.Cart.cartData, function (key, value) {
|
|
3624
|
+
ids = ids + value.P + ",";
|
|
3625
|
+
});
|
|
3626
|
+
|
|
3627
|
+
this.Products.get(
|
|
3628
|
+
{
|
|
3629
|
+
fields: "Name,Price,Quantity",
|
|
3630
|
+
media: "images",
|
|
3631
|
+
crops: "ax200,ax600,ax700,200x200,ax300",
|
|
3632
|
+
},
|
|
3633
|
+
{ ids: ids },
|
|
3634
|
+
true
|
|
3635
|
+
).then((res) => {
|
|
3636
|
+
let productsInfo = res.results;
|
|
3637
|
+
var productsDB = Object.assign(
|
|
3638
|
+
{},
|
|
3639
|
+
...productsInfo.map((x) => ({ [x.objectId]: x }))
|
|
3640
|
+
);
|
|
3641
|
+
|
|
3642
|
+
$.each(this.Cart.cartData, function (key, value) {
|
|
3643
|
+
orderData.productItems.push({
|
|
3644
|
+
Qty: value.Q,
|
|
3645
|
+
Product: value.P,
|
|
3646
|
+
productData: JSON.stringify(productsDB[value.P]),
|
|
3647
|
+
Price: productsDB[value.P].Price,
|
|
3648
|
+
});
|
|
3649
|
+
orderData.Amount += value.Q * productsDB[value.P].Price;
|
|
3650
|
+
});
|
|
3651
|
+
|
|
3652
|
+
this.request(
|
|
3653
|
+
"/Order",
|
|
3654
|
+
{ User: orderData.User, Amount: orderData.Amount },
|
|
3655
|
+
true,
|
|
3656
|
+
"POST"
|
|
3657
|
+
).then((res) => {
|
|
3658
|
+
let orderId = res.results;
|
|
3659
|
+
for (var i = 0; i < orderData.productItems.length; i++) {
|
|
3660
|
+
orderData.productItems[i]["Order"] = orderId[0].objectId;
|
|
3661
|
+
this.request("/orderItems ", orderData.productItems[i], true, "POST");
|
|
3662
|
+
}
|
|
3663
|
+
prom.resolve(orderId);
|
|
3664
|
+
});
|
|
3665
|
+
});
|
|
3666
|
+
return prom;
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
sendEmail(data) {
|
|
3670
|
+
let prom = defer();
|
|
3671
|
+
this.request("/_Emails/send", data, true, "POST").then((res) => {
|
|
3672
|
+
prom.resolve(r);
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
batch(data) {
|
|
3677
|
+
return this.request("/batch", data, true, "POST");
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
query(className, data) {
|
|
3681
|
+
return this.request(className, data, true, "GET");
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
get(className, data, options = true) {
|
|
3685
|
+
return this.request(className, data, options, "GET");
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
post(className, data, options = true) {
|
|
3689
|
+
return this.request(className, data, options, "POST");
|
|
3690
|
+
}
|
|
3691
|
+
|
|
3692
|
+
put(className, data, options = true) {
|
|
3693
|
+
return this.request(className, data, options, "PUT");
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
delete(className, options = true) {
|
|
3697
|
+
return this.request(className, "", options, "DELETE");
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
//end SDK//
|
|
3701
|
+
|
|
3702
|
+
//class pay//
|
|
3703
|
+
class Pay {
|
|
3704
|
+
tsdk = null;
|
|
3705
|
+
object = {};
|
|
3706
|
+
constructor(tsdk) {
|
|
3707
|
+
this.tsdk = tsdk;
|
|
3708
|
+
let self = this;
|
|
3709
|
+
$(window)
|
|
3710
|
+
.unbind("message")
|
|
3711
|
+
.on("message", function (e) {
|
|
3712
|
+
let dd = $("#gosell-gateway")[0].contentWindow;
|
|
3713
|
+
if (e.originalEvent.source === dd && e.originalEvent.data == "close") {
|
|
3714
|
+
$(".gosell-gateway").remove();
|
|
3715
|
+
self.onClose();
|
|
3716
|
+
}
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3719
|
+
|
|
3720
|
+
create(data) {
|
|
3721
|
+
let prom = defer();
|
|
3722
|
+
API.post("https://pay.bea.com.lb/create", data, {}, 666)
|
|
3723
|
+
.then((d) => {
|
|
3724
|
+
this.object = d;
|
|
3725
|
+
cl(d);
|
|
3726
|
+
this.process(
|
|
3727
|
+
this.object.transaction.url.replace("mode=page", "mode=popup")
|
|
3728
|
+
);
|
|
3729
|
+
prom.resolve(this.object.id);
|
|
3730
|
+
})
|
|
3731
|
+
.catch((err) => {
|
|
3732
|
+
cl(err);
|
|
3733
|
+
});
|
|
3734
|
+
return prom;
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3737
|
+
process(link) {
|
|
3738
|
+
var d = `
|
|
3739
|
+
<div class="gosell-gateway" reactive>
|
|
3740
|
+
<div style="position: fixed;left: 0;right: 0;top: 0;bottom: 0;z-index: 9999;background-color: rgb(0,0,0,0.2);">
|
|
3741
|
+
<iframe id="gosell-gateway"
|
|
3742
|
+
src="${link}" width="100%"
|
|
3743
|
+
height="100%"
|
|
3744
|
+
style="display: block; position: absolute; inset: 0px; margin: auto; border: 0px; z-index: 2147483647;"></iframe>
|
|
3745
|
+
</div>
|
|
3746
|
+
</div>
|
|
3747
|
+
`;
|
|
3748
|
+
$("body").append(d);
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
retrieve(id) {
|
|
3752
|
+
let prom = defer();
|
|
3753
|
+
this.tsdk
|
|
3754
|
+
.request("https://pay.bea.com.lb/?tap_id=" + id, {}, true, "GET")
|
|
3755
|
+
.then((d) => {
|
|
3756
|
+
prom.resolve(d);
|
|
3757
|
+
})
|
|
3758
|
+
.catch((err) => {
|
|
3759
|
+
cl(err);
|
|
3760
|
+
});
|
|
3761
|
+
|
|
3762
|
+
return prom;
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
onClose() { }
|
|
3766
|
+
}
|
|
3767
|
+
//end pay//
|
|
3768
|
+
|
|
3769
|
+
//class section//
|
|
3770
|
+
class Section {
|
|
3771
|
+
tsdk = null;
|
|
3772
|
+
_prom = defer();
|
|
3773
|
+
constructor(tsdk) {
|
|
3774
|
+
this.tsdk = tsdk;
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
get() {
|
|
3778
|
+
var d = {
|
|
3779
|
+
fields: this.tsdk.fields.Section,
|
|
3780
|
+
limit: -1,
|
|
3781
|
+
locale: this.tsdk.l,
|
|
3782
|
+
media: "images",
|
|
3783
|
+
crops: "ax200,ax600,ax700,200x200,ax300",
|
|
3784
|
+
};
|
|
3785
|
+
this.tsdk.request("/Sections", d, true, "GET").then((r) => {
|
|
3786
|
+
cl("HEiii", r);
|
|
3787
|
+
if (r.results) {
|
|
3788
|
+
globals["sections"] = Object.assign(
|
|
3789
|
+
{},
|
|
3790
|
+
...r.results.map((x) => ({ [x?.Section]: x }))
|
|
3791
|
+
);
|
|
3792
|
+
} else cl("Sections", r);
|
|
3793
|
+
this._prom.resolve(r);
|
|
3794
|
+
});
|
|
3795
|
+
return globals["sections"];
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
//end section//
|
|
3799
|
+
|
|
3800
|
+
//class locale//
|
|
3801
|
+
class Locale {
|
|
3802
|
+
tsdk = null;
|
|
3803
|
+
_prom = defer();
|
|
3804
|
+
constructor(tsdk) {
|
|
3805
|
+
this.tsdk = tsdk;
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
get() {
|
|
3809
|
+
var d = { fields: "Key," + this.tsdk.l, limit: -1 };
|
|
3810
|
+
this.tsdk.request("/_Locale", d, true, "GET").then((r) => {
|
|
3811
|
+
if (r.results) {
|
|
3812
|
+
globals["locale"] = Object.assign(
|
|
3813
|
+
{},
|
|
3814
|
+
...r.results.map((x) => ({ [x?.Key]: x }))
|
|
3815
|
+
);
|
|
3816
|
+
} else cl("_Locale", r);
|
|
3817
|
+
this._prom.resolve(r);
|
|
3818
|
+
});
|
|
3819
|
+
return globals["locale"];
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
//end locale//
|
|
3823
|
+
|
|
3824
|
+
//class products//
|
|
3825
|
+
class Products {
|
|
3826
|
+
tsdk = null;
|
|
3827
|
+
constructor(tsdk) {
|
|
3828
|
+
this.tsdk = tsdk;
|
|
3829
|
+
}
|
|
3830
|
+
get(data, options, async = true) {
|
|
3831
|
+
var d = data;
|
|
3832
|
+
if (options.hasOwnProperty("limit")) {
|
|
3833
|
+
d["limit"] = options.limit;
|
|
3834
|
+
}
|
|
3835
|
+
|
|
3836
|
+
if (options.hasOwnProperty("key")) {
|
|
3837
|
+
if (!d.hasOwnProperty("where")) d["where"] = {};
|
|
3838
|
+
d.where["Name"] = { startswith: options.key };
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
if (options.hasOwnProperty("ids")) {
|
|
3842
|
+
if (!d.hasOwnProperty("where")) d["where"] = {};
|
|
3843
|
+
d.where["objectId"] = {
|
|
3844
|
+
in: [...new Set(options.ids.split(","))],
|
|
3845
|
+
};
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
if (options.hasOwnProperty("page")) {
|
|
3849
|
+
d["limit"] = options.limits ?? "15";
|
|
3850
|
+
d["offset"] = (options.page - 1) * d["limit"];
|
|
3851
|
+
}
|
|
3852
|
+
return this.tsdk.request("/Products", d, async, "GET");
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
//end products//
|
|
3856
|
+
|
|
3857
|
+
//class cart//
|
|
3858
|
+
class Cart {
|
|
3859
|
+
tsdk = null;
|
|
3860
|
+
cartData = {};
|
|
3861
|
+
constructor(tsdk) {
|
|
3862
|
+
this.tsdk = tsdk;
|
|
3863
|
+
try {
|
|
3864
|
+
if (getCookie("_cd") != undefined) {
|
|
3865
|
+
try {
|
|
3866
|
+
this.cartData = JSON.parse(getCookie("_cd"));
|
|
3867
|
+
} catch (e) {
|
|
3868
|
+
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
} catch (e) {
|
|
3872
|
+
this.cartData = JSON.parse("{}");
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
add(id, v, q) {
|
|
3876
|
+
var key = btoa(id + "::" + v);
|
|
3877
|
+
if (this.cartData.hasOwnProperty(key)) {
|
|
3878
|
+
this.cartData[key].Q += q;
|
|
3879
|
+
} else {
|
|
3880
|
+
this.cartData[key] = {
|
|
3881
|
+
P: id,
|
|
3882
|
+
Q: q,
|
|
3883
|
+
V: v,
|
|
3884
|
+
};
|
|
3885
|
+
}
|
|
3886
|
+
setCookie("_cd", JSON.stringify(this.cartData));
|
|
3887
|
+
}
|
|
3888
|
+
set(id, v, q) {
|
|
3889
|
+
var key = btoa(id + "::" + v);
|
|
3890
|
+
if (this.cartData.hasOwnProperty(key)) {
|
|
3891
|
+
this.cartData[key].Q = q;
|
|
3892
|
+
} else {
|
|
3893
|
+
this.cartData[key] = {
|
|
3894
|
+
P: id,
|
|
3895
|
+
Q: q,
|
|
3896
|
+
V: v,
|
|
3897
|
+
};
|
|
3898
|
+
}
|
|
3899
|
+
setCookie("_cd", JSON.stringify(this.cartData));
|
|
3900
|
+
}
|
|
3901
|
+
remove(id) {
|
|
3902
|
+
delete this.cartData[id];
|
|
3903
|
+
setCookie("_cd", JSON.stringify(this.cartData));
|
|
3904
|
+
}
|
|
3905
|
+
empty() {
|
|
3906
|
+
this.cartData = {};
|
|
3907
|
+
setCookie("_cd", JSON.stringify(this.cartData));
|
|
3908
|
+
}
|
|
3909
|
+
getCart() {
|
|
3910
|
+
return this.cartData;
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
getProductCart(d) {
|
|
3914
|
+
var ids = "";
|
|
3915
|
+
$.each(this.cartData, function (key, value) {
|
|
3916
|
+
ids = ids + value.P + ",";
|
|
3917
|
+
});
|
|
3918
|
+
var req = this.tsdk.Products.get(d, { ids: ids });
|
|
3919
|
+
return req;
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
//end cart//
|
|
3923
|
+
|
|
3924
|
+
//class auth//
|
|
3925
|
+
class Authorize {
|
|
3926
|
+
tsdk = null;
|
|
3927
|
+
constructor(tsdk) {
|
|
3928
|
+
this.tsdk = tsdk;
|
|
3929
|
+
}
|
|
3930
|
+
|
|
3931
|
+
login(data, options = true) {
|
|
3932
|
+
var prom = defer();
|
|
3933
|
+
this.tsdk.request("/Users", data, options, "GET").then((res) => {
|
|
3934
|
+
let req = res.results;
|
|
3935
|
+
|
|
3936
|
+
// if (!options) {
|
|
3937
|
+
globals["UserInfo"] = req[0];
|
|
3938
|
+
let x = window.btoa(JSON.stringify(globals.UserInfo));
|
|
3939
|
+
setCookie("U_USER", x);
|
|
3940
|
+
// } else {
|
|
3941
|
+
// req.then((r) => {
|
|
3942
|
+
// globals['UserInfo'] = r.results[0];
|
|
3943
|
+
// let x = window.btoa(JSON.stringify(globals.UserInfo))
|
|
3944
|
+
// setCookie("U_USER", x)
|
|
3945
|
+
// })
|
|
3946
|
+
// .catch((err) => {
|
|
3947
|
+
// cl(err)
|
|
3948
|
+
// })
|
|
3949
|
+
// }
|
|
3950
|
+
prom.resolve(res);
|
|
3951
|
+
});
|
|
3952
|
+
return prom;
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
register(data, options = true) {
|
|
3956
|
+
var prom = defer();
|
|
3957
|
+
this.tsdk.request("/Users", data, options, "POST").then((res) => {
|
|
3958
|
+
let req = res.results;
|
|
3959
|
+
// if (!options) {
|
|
3960
|
+
data["objectId"] = req[0].objectId;
|
|
3961
|
+
globals["UserInfo"] = data;
|
|
3962
|
+
let x = window.btoa(JSON.stringify(globals.UserInfo));
|
|
3963
|
+
setCookie("U_USER", x);
|
|
3964
|
+
// } else {
|
|
3965
|
+
// req.then((r) => {
|
|
3966
|
+
// data['objectId'] = r.results[0].objectId
|
|
3967
|
+
// globals['UserInfo'] = data;
|
|
3968
|
+
// let x = window.btoa(JSON.stringify(globals.UserInfo))
|
|
3969
|
+
// setCookie("U_USER", x)
|
|
3970
|
+
// })
|
|
3971
|
+
// .catch((err) => {
|
|
3972
|
+
// cl(err)
|
|
3973
|
+
// })
|
|
3974
|
+
// }
|
|
3975
|
+
prom.resolve(res);
|
|
3976
|
+
});
|
|
3977
|
+
return prom;
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
me() {
|
|
3981
|
+
var cookie = undefined;
|
|
3982
|
+
try {
|
|
3983
|
+
var cookie = JSON.parse(window.atob(getCookie("U_USER")));
|
|
3984
|
+
} catch (e) {
|
|
3985
|
+
|
|
3986
|
+
}
|
|
3987
|
+
return cookie;
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
isLoggedIn() {
|
|
3991
|
+
var result = false;
|
|
3992
|
+
if (getCookie("U_USER") != undefined) result = true;
|
|
3993
|
+
return result;
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
//end auth//
|
|
3997
|
+
|
|
3998
|
+
function generate() {
|
|
3999
|
+
let length = 10;
|
|
4000
|
+
const characters = "abcdefghijklmnopqrstuvwxyz1234567890";
|
|
4001
|
+
let result = "";
|
|
4002
|
+
const charactersLength = characters.length;
|
|
4003
|
+
for (let i = 0; i < length; i++) {
|
|
4004
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
4005
|
+
}
|
|
4006
|
+
return result;
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
function getScrollBarWidth() {
|
|
4010
|
+
var $outer = $("<div>")
|
|
4011
|
+
.css({ visibility: "hidden", width: 100, overflow: "scroll" })
|
|
4012
|
+
.appendTo("body"),
|
|
4013
|
+
widthWithScroll = $("<div>")
|
|
4014
|
+
.css({ width: "100%" })
|
|
4015
|
+
.appendTo($outer)
|
|
4016
|
+
.outerWidth();
|
|
4017
|
+
$outer.remove();
|
|
4018
|
+
return (100 - widthWithScroll) * 2;
|
|
4019
|
+
}
|
|
4020
|
+
_scW = getScrollBarWidth();
|
|
4021
|
+
|
|
4022
|
+
function daysBetween(date_1, date_2) {
|
|
4023
|
+
let difference = date_1.getTime() - date_2.getTime();
|
|
4024
|
+
let TotalDays = Math.ceil(difference / (1000 * 3600 * 24));
|
|
4025
|
+
return TotalDays < 0 ? TotalDays * -1 : TotalDays;
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
function notify(ti, tx, i, ty, al, rtl) {
|
|
4029
|
+
var notify =
|
|
4030
|
+
`<div class="notify {{Type}} nw sh20 h ` +
|
|
4031
|
+
(rtl ? "rtl" : "") +
|
|
4032
|
+
`">
|
|
4033
|
+
<div class="ov10 ra dash round3x bgb20 p2"></div>
|
|
4034
|
+
<div class="ov ra icon"><span class="cc mdi fs24 mdi-{{Icon}}"></span></div>
|
|
4035
|
+
<div class="ov la pointer" close-notify><span class="cc mdi fs18 mdi-close"></span></div>
|
|
4036
|
+
{{Title}}
|
|
4037
|
+
{{Text}}
|
|
4038
|
+
</div>`;
|
|
4039
|
+
if (!al) al = "topCenter";
|
|
4040
|
+
if (!ty) ty = "";
|
|
4041
|
+
if (!$("[notify]").length)
|
|
4042
|
+
$("body").append("<div notify class='" + al + "'></div>");
|
|
4043
|
+
else $("[notify]").attr("class", "").addClass(al);
|
|
4044
|
+
$("[notify]").prepend(
|
|
4045
|
+
notify
|
|
4046
|
+
.split("{{Title}}")
|
|
4047
|
+
.join(ti != "" ? "<h5>" + ti + "</h5>" : "")
|
|
4048
|
+
.split("{{Icon}}")
|
|
4049
|
+
.join(i)
|
|
4050
|
+
.split("{{Text}}")
|
|
4051
|
+
.join(tx)
|
|
4052
|
+
.split("{{Type}}")
|
|
4053
|
+
.join(ty)
|
|
4054
|
+
.split("{{Type}}")
|
|
4055
|
+
.join(ti)
|
|
4056
|
+
.split("{{Type}}")
|
|
4057
|
+
.join(ti)
|
|
4058
|
+
);
|
|
4059
|
+
$(".notify").fadeIn();
|
|
4060
|
+
setTimeout(function () {
|
|
4061
|
+
$("[close-notify]:last").click();
|
|
4062
|
+
}, 5000);
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
function _isScrollable(el) {
|
|
4066
|
+
let o1 =
|
|
4067
|
+
el.css("overflow-y") == "scroll" ||
|
|
4068
|
+
(el.css("overflow-y") == "auto" && el[0].scrollHeight > el.height() + 15);
|
|
4069
|
+
let o2 =
|
|
4070
|
+
el.css("overflow-x") == "scroll" ||
|
|
4071
|
+
(el.css("overflow-x") == "auto" && el[0].scrollWidth > el.width() + 15);
|
|
4072
|
+
return o1 || o2;
|
|
4073
|
+
}
|
|
4074
|
+
|
|
4075
|
+
function _setPos(self, p, el) {
|
|
4076
|
+
var left = self.offset().left;
|
|
4077
|
+
var top = self.offset().top;
|
|
4078
|
+
if (p == "" || p == "bottom") {
|
|
4079
|
+
left += self.innerWidth() / 2;
|
|
4080
|
+
top += self.innerHeight();
|
|
4081
|
+
} else if (p == "left") {
|
|
4082
|
+
top += self.innerHeight() / 2;
|
|
4083
|
+
} else if (p == "top") {
|
|
4084
|
+
left += self.innerWidth() / 2;
|
|
4085
|
+
} else {
|
|
4086
|
+
left += self.innerWidth();
|
|
4087
|
+
top += self.innerHeight() / 2;
|
|
4088
|
+
}
|
|
4089
|
+
$("tip").css({ left: left, top: top, right: "unset", bottom: "unset" });
|
|
4090
|
+
if (
|
|
4091
|
+
top + 15 < el.offset().top ||
|
|
4092
|
+
top > el.offset().top + el.height() + 10 ||
|
|
4093
|
+
left + 15 < el.offset().left ||
|
|
4094
|
+
left > el.offset().left + el.width() + 10
|
|
4095
|
+
)
|
|
4096
|
+
$("tip").hide();
|
|
4097
|
+
else $("tip").show();
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
String.prototype.rtrim = function (s) {
|
|
4101
|
+
if (s == undefined) s = "\\s";
|
|
4102
|
+
try {
|
|
4103
|
+
return this.replace(new RegExp("[" + s + "]+$"), "");
|
|
4104
|
+
} catch {
|
|
4105
|
+
return this.replace(new RegExp("[" + "\\" + s + "]+$"), "");
|
|
4106
|
+
}
|
|
4107
|
+
};
|
|
4108
|
+
|
|
4109
|
+
String.prototype.ltrim = function (s) {
|
|
4110
|
+
if (s == undefined) s = "\\s";
|
|
4111
|
+
try {
|
|
4112
|
+
return this.replace(new RegExp("^[" + s + "]+"), "");
|
|
4113
|
+
} catch {
|
|
4114
|
+
return this.replace(new RegExp("^[" + "\\" + s + "]+"), "");
|
|
4115
|
+
}
|
|
4116
|
+
};
|
|
4117
|
+
|
|
4118
|
+
|