jsuites 4.9.21 → 4.9.25
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/compile.php +86 -0
- package/dist/jsuites.basic.css +26 -0
- package/dist/jsuites.basic.js +128 -91
- package/dist/jsuites.css +26 -0
- package/dist/jsuites.js +203 -166
- package/dist/jsuites.layout.css +5 -0
- package/dist/jsuites.layout.js +1 -1
- package/docker-compose.yml +9 -0
- package/package.json +1 -1
- package/resources/Dockerfile +5 -0
- package/dist/jsuites.mobile.css +0 -1012
- package/dist/jsuites.mobile.js +0 -1016
package/dist/jsuites.mobile.js
DELETED
|
@@ -1,1016 +0,0 @@
|
|
|
1
|
-
jSuites.app = (function(el, options) {
|
|
2
|
-
var obj = {};
|
|
3
|
-
obj.options = {};
|
|
4
|
-
|
|
5
|
-
// Default configuration
|
|
6
|
-
var defaults = {
|
|
7
|
-
path: 'views',
|
|
8
|
-
onbeforechangepage: null,
|
|
9
|
-
onchangepage: null,
|
|
10
|
-
onbeforecreatepage: null,
|
|
11
|
-
oncreatepage: null,
|
|
12
|
-
onerrorpage: null,
|
|
13
|
-
onloadpage: null,
|
|
14
|
-
toolbar: null,
|
|
15
|
-
route: null,
|
|
16
|
-
ident: null,
|
|
17
|
-
detachHiddenPages: false
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Loop through our object
|
|
21
|
-
for (var property in defaults) {
|
|
22
|
-
if (options && options.hasOwnProperty(property)) {
|
|
23
|
-
obj.options[property] = options[property];
|
|
24
|
-
} else {
|
|
25
|
-
obj.options[property] = defaults[property];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// App
|
|
30
|
-
el.classList.add('japp');
|
|
31
|
-
|
|
32
|
-
// Toolbar
|
|
33
|
-
var toolbar = document.createElement('div');
|
|
34
|
-
|
|
35
|
-
obj.setToolbar = function(o) {
|
|
36
|
-
if (o) {
|
|
37
|
-
obj.options.toolbar = o;
|
|
38
|
-
}
|
|
39
|
-
// Force application
|
|
40
|
-
obj.options.toolbar.app = obj;
|
|
41
|
-
// Set toolbar
|
|
42
|
-
obj.toolbar = jSuites.toolbar(toolbar, obj.options.toolbar);
|
|
43
|
-
// Add to the DOM
|
|
44
|
-
el.appendChild(toolbar);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
obj.hideToolbar = function() {
|
|
48
|
-
if (toolbar.style.display == '') {
|
|
49
|
-
toolbar.style.display = 'none';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
obj.showToolbar = function() {
|
|
54
|
-
if (toolbar.style.display == 'none') {
|
|
55
|
-
toolbar.style.display = '';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Page identification
|
|
61
|
-
*/
|
|
62
|
-
var ident = function(route) {
|
|
63
|
-
route = route.split('?')[0];
|
|
64
|
-
|
|
65
|
-
if (typeof(obj.options.ident) == 'function') {
|
|
66
|
-
var ret = obj.options.ident(route);
|
|
67
|
-
if (typeof(ret) !== 'undefined') {
|
|
68
|
-
return ret;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return route;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/*
|
|
76
|
-
* Parse javascript from an element
|
|
77
|
-
*/
|
|
78
|
-
var parseScript = function(element) {
|
|
79
|
-
// Get javascript
|
|
80
|
-
var script = element.getElementsByTagName('script');
|
|
81
|
-
// Run possible inline scripts
|
|
82
|
-
for (var i = 0; i < script.length; i++) {
|
|
83
|
-
// Get type
|
|
84
|
-
var type = script[i].getAttribute('type');
|
|
85
|
-
if (! type || type == 'text/javascript' || type == 'text/loader') {
|
|
86
|
-
eval(script[i].text);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Pages
|
|
93
|
-
*/
|
|
94
|
-
obj.pages = function() {
|
|
95
|
-
/**
|
|
96
|
-
* Create or access a page
|
|
97
|
-
*/
|
|
98
|
-
var component = function(route, o, callback, element) {
|
|
99
|
-
var options = {};
|
|
100
|
-
|
|
101
|
-
if (o) {
|
|
102
|
-
if (typeof(o) == 'object') {
|
|
103
|
-
var options = o;
|
|
104
|
-
} else {
|
|
105
|
-
if (! callback && typeof(o) == 'function') {
|
|
106
|
-
callback = o;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (typeof(obj.options.route) == 'function') {
|
|
112
|
-
route = obj.options.route(route, options);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (route === false) {
|
|
116
|
-
console.error('JSUITES: Permission denied');
|
|
117
|
-
} else {
|
|
118
|
-
// Query string does not make part in the route
|
|
119
|
-
options.ident = ident(route);
|
|
120
|
-
// Current Route
|
|
121
|
-
options.route = route;
|
|
122
|
-
|
|
123
|
-
// If exists just open
|
|
124
|
-
var page = component.container[options.ident];
|
|
125
|
-
if (page) {
|
|
126
|
-
page.options.closed = 0;
|
|
127
|
-
component.show(page, options, callback);
|
|
128
|
-
} else {
|
|
129
|
-
// Closed
|
|
130
|
-
options.closed = options.closed ? 1 : 0;
|
|
131
|
-
|
|
132
|
-
// New page url
|
|
133
|
-
if (! options.url) {
|
|
134
|
-
options.url = obj.options.path + options.ident + '.html';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Create new page
|
|
138
|
-
page = component.create(options, callback, element);
|
|
139
|
-
|
|
140
|
-
// Container
|
|
141
|
-
component.container[options.ident] = page;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Create a new page
|
|
148
|
-
*/
|
|
149
|
-
component.create = function(o, callback, fromElement) {
|
|
150
|
-
// Create page
|
|
151
|
-
if (fromElement) {
|
|
152
|
-
var page = fromElement;
|
|
153
|
-
} else {
|
|
154
|
-
var page = document.createElement('div');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
page.classList.add('page');
|
|
158
|
-
|
|
159
|
-
// Keep options
|
|
160
|
-
page.options = o ? o : {};
|
|
161
|
-
|
|
162
|
-
// Create page overwrite
|
|
163
|
-
var ret = null;
|
|
164
|
-
if (typeof(obj.options.onbeforecreatepage) == 'function') {
|
|
165
|
-
ret = obj.options.onbeforecreatepage(obj, page);
|
|
166
|
-
if (ret === false) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
var success = function(result) {
|
|
172
|
-
// Remove to avoid id conflicts
|
|
173
|
-
if (component.current && obj.options.detachHiddenPages == true) {
|
|
174
|
-
while (component.element.children[0]) {
|
|
175
|
-
component.element.children[0].parentNode.removeChild(component.element.children[0]);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (! component.current) {
|
|
180
|
-
component.element.appendChild(page);
|
|
181
|
-
} else {
|
|
182
|
-
component.element.insertBefore(page, component.current.nextSibling);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Open page
|
|
186
|
-
if (result) {
|
|
187
|
-
page.innerHTML = result;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Get javascript
|
|
191
|
-
try {
|
|
192
|
-
parseScript(page);
|
|
193
|
-
} catch (e) {
|
|
194
|
-
console.log(e);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Create page overwrite
|
|
198
|
-
if (typeof(obj.options.oncreatepage) == 'function') {
|
|
199
|
-
obj.options.oncreatepage(obj, page, result);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Push to refresh controls
|
|
203
|
-
if (typeof(page.options.onpush) == 'function') {
|
|
204
|
-
jSuites.refresh(page, page.options.onpush);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Navbar
|
|
208
|
-
if (page.querySelector('.navbar')) {
|
|
209
|
-
page.classList.add('with-navbar');
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Global onload callback
|
|
213
|
-
if (typeof(obj.options.onloadpage) == 'function') {
|
|
214
|
-
obj.options.onloadpage(obj, page);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Specific online callback
|
|
218
|
-
if (typeof(o.onload) == 'function') {
|
|
219
|
-
o.onload(page);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Always hidden when created
|
|
223
|
-
page.style.display = 'none';
|
|
224
|
-
|
|
225
|
-
// Show page
|
|
226
|
-
if (! page.options.closed) {
|
|
227
|
-
component.show(page, o, callback);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// URL
|
|
232
|
-
if (o.url.indexOf('?') == -1) {
|
|
233
|
-
var url = o.url + '?';
|
|
234
|
-
} else {
|
|
235
|
-
var url = o.url + '&';
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (fromElement) {
|
|
239
|
-
success();
|
|
240
|
-
} else {
|
|
241
|
-
jSuites.ajax({
|
|
242
|
-
url: url + 'ts=' + new Date().getTime(),
|
|
243
|
-
method: 'GET',
|
|
244
|
-
dataType: 'html',
|
|
245
|
-
queue: true,
|
|
246
|
-
success: success,
|
|
247
|
-
error: function(a,b) {
|
|
248
|
-
if (typeof(obj.options.onerrorpage) == 'function') {
|
|
249
|
-
obj.options.onerrorpage(obj, page, a, b);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
component.destroy(page);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return page;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
component.show = function(page, o, callback) {
|
|
261
|
-
if (o) {
|
|
262
|
-
if (o.onenter) {
|
|
263
|
-
page.options.onenter = o.onenter;
|
|
264
|
-
}
|
|
265
|
-
if (o.onleave) {
|
|
266
|
-
page.options.onleave = o.onleave;
|
|
267
|
-
}
|
|
268
|
-
if (o.route) {
|
|
269
|
-
page.options.route = o.route;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Add history
|
|
274
|
-
if (! o || ! o.ignoreHistory) {
|
|
275
|
-
// Route
|
|
276
|
-
if (o && o.route) {
|
|
277
|
-
var route = o.route;
|
|
278
|
-
} else {
|
|
279
|
-
var route = page.options.route;
|
|
280
|
-
}
|
|
281
|
-
// Add history
|
|
282
|
-
window.history.pushState({ route: route }, page.options.title, route);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
var pageIsReady = function() {
|
|
286
|
-
if (component.current) {
|
|
287
|
-
component.current.style.display = 'none';
|
|
288
|
-
|
|
289
|
-
if (component.current && obj.options.detachHiddenPages == true) {
|
|
290
|
-
if (component.current.parentNode) {
|
|
291
|
-
component.current.parentNode.removeChild(component.current);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// New page
|
|
297
|
-
if (typeof(obj.options.onchangepage) == 'function') {
|
|
298
|
-
obj.options.onchangepage(obj, page, component.current, o);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Enter event
|
|
302
|
-
if (typeof(page.options.onenter) == 'function') {
|
|
303
|
-
page.options.onenter(obj, page, component.current);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Callback
|
|
307
|
-
if (typeof(callback) == 'function') {
|
|
308
|
-
callback(obj, page);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Current page
|
|
312
|
-
component.current = page;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// Append page in case was detached
|
|
316
|
-
if (! page.parentNode) {
|
|
317
|
-
component.element.appendChild(page);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (component.current) {
|
|
321
|
-
// Show page
|
|
322
|
-
page.style.display = '';
|
|
323
|
-
|
|
324
|
-
if (component.current != page) {
|
|
325
|
-
var a = Array.prototype.indexOf.call(component.element.children, component.current);
|
|
326
|
-
var b = Array.prototype.indexOf.call(component.element.children, page);
|
|
327
|
-
|
|
328
|
-
// Before leave the page
|
|
329
|
-
if (typeof(obj.options.onbeforechangepage) == 'function') {
|
|
330
|
-
var ret = obj.options.onbeforechangepage(obj, component.current, page, o);
|
|
331
|
-
if (ret === false) {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Leave event
|
|
337
|
-
if (typeof(page.options.onleave) == 'function') {
|
|
338
|
-
page.options.onleave(obj, component.current);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Animation only on mobile
|
|
342
|
-
var rect = component.element.getBoundingClientRect();
|
|
343
|
-
|
|
344
|
-
// Move to the top
|
|
345
|
-
window.scrollTo({ top: 0 });
|
|
346
|
-
|
|
347
|
-
// Page is ready
|
|
348
|
-
if (rect.width < 800 && obj.options.detachHiddenPages == false) {
|
|
349
|
-
jSuites.animation.slideLeft(component.element, (a < b ? 0 : 1), function() {
|
|
350
|
-
if (component.current != page) {
|
|
351
|
-
pageIsReady();
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
} else {
|
|
355
|
-
if (component.current != page) {
|
|
356
|
-
pageIsReady();
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
} else {
|
|
360
|
-
component.current = null;
|
|
361
|
-
|
|
362
|
-
pageIsReady();
|
|
363
|
-
}
|
|
364
|
-
} else {
|
|
365
|
-
// Show
|
|
366
|
-
page.style.display = '';
|
|
367
|
-
|
|
368
|
-
// Page is ready
|
|
369
|
-
pageIsReady();
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Select toolbar item
|
|
373
|
-
if (page.options.toolbarItem) {
|
|
374
|
-
obj.toolbar.selectItem(page.options.toolbarItem);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Get a page by route
|
|
380
|
-
*/
|
|
381
|
-
component.get = function(route) {
|
|
382
|
-
var key = ident(route);
|
|
383
|
-
if (component.container[key]) {
|
|
384
|
-
return component.container[key];
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Reset the page container
|
|
390
|
-
*/
|
|
391
|
-
component.reset = function() {
|
|
392
|
-
// Container
|
|
393
|
-
component.element.innerHTML = '';
|
|
394
|
-
// Current
|
|
395
|
-
component.current = null;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Reset the page container
|
|
400
|
-
*/
|
|
401
|
-
component.destroy = function(page) {
|
|
402
|
-
if (page) {
|
|
403
|
-
if (page.parentNode) {
|
|
404
|
-
page.remove();
|
|
405
|
-
}
|
|
406
|
-
delete component.container[page.options.ident];
|
|
407
|
-
} else {
|
|
408
|
-
// Reset container
|
|
409
|
-
component.reset();
|
|
410
|
-
// Destroy references
|
|
411
|
-
component.container = {};
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Page container controller
|
|
417
|
-
*/
|
|
418
|
-
component.container = {};
|
|
419
|
-
|
|
420
|
-
component.init = function() {
|
|
421
|
-
/**
|
|
422
|
-
* Pages DOM container
|
|
423
|
-
*/
|
|
424
|
-
var pagesContainer = el.querySelector('.pages');
|
|
425
|
-
if (pagesContainer) {
|
|
426
|
-
component.element = pagesContainer;
|
|
427
|
-
} else {
|
|
428
|
-
component.element = document.createElement('div');
|
|
429
|
-
component.element.className = 'pages';
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Prefetched content
|
|
433
|
-
var current = null;
|
|
434
|
-
if (el.innerHTML) {
|
|
435
|
-
// Create with the prefetched content
|
|
436
|
-
current = document.createElement('div');
|
|
437
|
-
while (el.childNodes[0]) {
|
|
438
|
-
current.appendChild(el.childNodes[0]);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// Append page container to the application
|
|
443
|
-
el.appendChild(component.element);
|
|
444
|
-
|
|
445
|
-
// Go to the current page
|
|
446
|
-
if (current) {
|
|
447
|
-
component(window.location.pathname, null, null, current);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return component;
|
|
452
|
-
}();
|
|
453
|
-
|
|
454
|
-
// Start page object
|
|
455
|
-
obj.pages.init();
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Panel methods
|
|
459
|
-
*/
|
|
460
|
-
obj.panel = function() {
|
|
461
|
-
var panel = null;
|
|
462
|
-
|
|
463
|
-
var component = function(route, o) {
|
|
464
|
-
if (! panel) {
|
|
465
|
-
// Create element
|
|
466
|
-
panel = document.createElement('div');
|
|
467
|
-
panel.classList.add('panel');
|
|
468
|
-
panel.classList.add('panel-left');
|
|
469
|
-
panel.style.display = 'none';
|
|
470
|
-
|
|
471
|
-
// Bind to the app
|
|
472
|
-
el.appendChild(panel);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// Remote content
|
|
476
|
-
if (route) {
|
|
477
|
-
// URL
|
|
478
|
-
if (! o) {
|
|
479
|
-
o = {};
|
|
480
|
-
}
|
|
481
|
-
if (! o.url) {
|
|
482
|
-
o.url = obj.options.path + route + '.html';
|
|
483
|
-
}
|
|
484
|
-
// Route
|
|
485
|
-
o.route = route;
|
|
486
|
-
// Panel
|
|
487
|
-
panel.options = o;
|
|
488
|
-
|
|
489
|
-
// Request remote data
|
|
490
|
-
jSuites.ajax({
|
|
491
|
-
url: o.url,
|
|
492
|
-
method: 'GET',
|
|
493
|
-
dataType: 'html',
|
|
494
|
-
success: function(result) {
|
|
495
|
-
// Create page overwrite
|
|
496
|
-
var ret = null;
|
|
497
|
-
if (typeof(obj.options.oncreatepage) == 'function') {
|
|
498
|
-
ret = obj.options.oncreatepage(obj, panel, result);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// Ignore create page actions
|
|
502
|
-
if (ret !== false) {
|
|
503
|
-
// Open page
|
|
504
|
-
panel.innerHTML = result;
|
|
505
|
-
// Get javascript
|
|
506
|
-
parseScript(page);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
} else {
|
|
511
|
-
component.show();
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
component.show = function() {
|
|
516
|
-
// Show panel
|
|
517
|
-
if (panel && panel.style.display == 'none') {
|
|
518
|
-
panel.style.display = '';
|
|
519
|
-
// Add animation
|
|
520
|
-
if (panel.classList.contains('panel-left')) {
|
|
521
|
-
jSuites.animation.slideLeft(panel, 1);
|
|
522
|
-
} else {
|
|
523
|
-
jSuites.animation.slideRight(panel, 1);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
component.hide = function() {
|
|
529
|
-
if (panel && panel.style.display == '') {
|
|
530
|
-
// Animation
|
|
531
|
-
if (panel.classList.contains('panel-left')) {
|
|
532
|
-
jSuites.animation.slideLeft(panel, 0, function() {
|
|
533
|
-
panel.style.display = 'none';
|
|
534
|
-
});
|
|
535
|
-
} else {
|
|
536
|
-
jSuites.animation.slideRight(panel, 0, function() {
|
|
537
|
-
panel.animation.style.display = 'none';
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
component.get = function() {
|
|
544
|
-
return panel;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
component.destroy = function() {
|
|
548
|
-
el.removeChild(panel);
|
|
549
|
-
panel = null;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
return component;
|
|
553
|
-
}();
|
|
554
|
-
|
|
555
|
-
// Actionsheet
|
|
556
|
-
obj.actionsheet = jSuites.actionsheet(el, obj);
|
|
557
|
-
|
|
558
|
-
var controlSwipeLeft = function(e) {
|
|
559
|
-
var element = jSuites.findElement(e.target, 'option');
|
|
560
|
-
|
|
561
|
-
if (element && element.querySelector('.option-actions')) {
|
|
562
|
-
element.scrollTo({
|
|
563
|
-
left: 100,
|
|
564
|
-
behavior: 'smooth'
|
|
565
|
-
});
|
|
566
|
-
} else {
|
|
567
|
-
obj.panel.hide();
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
var controlSwipeRight = function(e) {
|
|
572
|
-
var element = jSuites.findElement(e.target, 'option');
|
|
573
|
-
if (element && element.querySelector('.option-actions')) {
|
|
574
|
-
element.scrollTo({
|
|
575
|
-
left: 0,
|
|
576
|
-
behavior: 'smooth'
|
|
577
|
-
});
|
|
578
|
-
} else {
|
|
579
|
-
obj.panel.show();
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
var action = null;
|
|
584
|
-
|
|
585
|
-
var clicked = function(e) {
|
|
586
|
-
// Grouped options
|
|
587
|
-
if (e.target.classList.contains('option-title')) {
|
|
588
|
-
if (e.target.classList.contains('selected')) {
|
|
589
|
-
e.target.classList.remove('selected');
|
|
590
|
-
} else {
|
|
591
|
-
e.target.classList.add('selected');
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
// Grouped buttons
|
|
596
|
-
if (e.target.parentNode && e.target.parentNode.classList && e.target.parentNode.classList.contains('jbuttons-group')) {
|
|
597
|
-
for (var j = 0; j < e.target.parentNode.children.length; j++) {
|
|
598
|
-
e.target.parentNode.children[j].classList.remove('selected');
|
|
599
|
-
}
|
|
600
|
-
e.target.classList.add('selected');
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
// App links
|
|
604
|
-
var tmp = jSuites.findElement(e.target, function(el) {
|
|
605
|
-
return el.tagName == 'A' && el.getAttribute('href') ? el : false;
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
if (tmp) {
|
|
609
|
-
var h = tmp.getAttribute('href');
|
|
610
|
-
if (h.substr(0,2) == '//' || h.substr(0,4) == 'http' || tmp.classList.contains('link') || h.indexOf('#') >= 0) {
|
|
611
|
-
action = null;
|
|
612
|
-
} else {
|
|
613
|
-
var p = jSuites.getPosition(e);
|
|
614
|
-
action = {
|
|
615
|
-
h: h,
|
|
616
|
-
element: tmp,
|
|
617
|
-
target: e.target,
|
|
618
|
-
x: p[0],
|
|
619
|
-
y: p[1],
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
// Cancel click operation in 400ms
|
|
623
|
-
setTimeout(function() {
|
|
624
|
-
action = null;
|
|
625
|
-
}, 400);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
var actionDown = function(e) {
|
|
631
|
-
e = e || window.event;
|
|
632
|
-
if (e.buttons) {
|
|
633
|
-
var mouseButton = e.buttons;
|
|
634
|
-
} else if (e.button) {
|
|
635
|
-
var mouseButton = e.button;
|
|
636
|
-
} else {
|
|
637
|
-
var mouseButton = e.which;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (mouseButton < 2) {
|
|
641
|
-
clicked(e);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
var actionUp = function(e) {
|
|
646
|
-
obj.actionsheet.close();
|
|
647
|
-
// Action
|
|
648
|
-
if (action) {
|
|
649
|
-
var p = jSuites.getPosition(e);
|
|
650
|
-
// If mouse move cancel the click action
|
|
651
|
-
if (Math.abs(action.x - p[0]) < 5 && Math.abs(action.y - p[1]) < 5) {
|
|
652
|
-
// Go to the page
|
|
653
|
-
obj.pages(action.h);
|
|
654
|
-
}
|
|
655
|
-
// Prevent default
|
|
656
|
-
e.preventDefault();
|
|
657
|
-
action = null;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
el.addEventListener('swipeleft', controlSwipeLeft);
|
|
662
|
-
el.addEventListener('swiperight', controlSwipeRight);
|
|
663
|
-
|
|
664
|
-
if ('ontouchstart' in document.documentElement === true) {
|
|
665
|
-
document.addEventListener('touchstart', actionDown);
|
|
666
|
-
document.addEventListener('touchend', actionUp);
|
|
667
|
-
} else {
|
|
668
|
-
document.addEventListener('mousedown', actionDown);
|
|
669
|
-
document.addEventListener('click', actionUp);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
window.onpopstate = function(e) {
|
|
673
|
-
if (e.state && e.state.route) {
|
|
674
|
-
if (obj.pages.get(e.state.route)) {
|
|
675
|
-
obj.pages(e.state.route, { ignoreHistory: true });
|
|
676
|
-
} else {
|
|
677
|
-
window.location.href = e.state.route;
|
|
678
|
-
}
|
|
679
|
-
} else {
|
|
680
|
-
window.location.reload();
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
if (obj.options.toolbar) {
|
|
685
|
-
obj.setToolbar();
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
el.app = obj;
|
|
689
|
-
|
|
690
|
-
return obj;
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
jSuites.actionsheet = (function(el, component) {
|
|
694
|
-
var obj = function(options) {
|
|
695
|
-
// Reset container
|
|
696
|
-
actionContent.innerHTML = '';
|
|
697
|
-
|
|
698
|
-
// Create new elements
|
|
699
|
-
for (var i = 0; i < options.length; i++) {
|
|
700
|
-
var actionGroup = document.createElement('div');
|
|
701
|
-
actionGroup.className = 'jactionsheet-group';
|
|
702
|
-
|
|
703
|
-
for (var j = 0; j < options[i].length; j++) {
|
|
704
|
-
var v = options[i][j];
|
|
705
|
-
var actionItem = document.createElement('div');
|
|
706
|
-
var actionInput = document.createElement('input');
|
|
707
|
-
actionInput.type = 'button';
|
|
708
|
-
actionInput.value = v.title;
|
|
709
|
-
if (v.className) {
|
|
710
|
-
actionInput.className = v.className;
|
|
711
|
-
}
|
|
712
|
-
if (v.onclick) {
|
|
713
|
-
actionInput.event = v.onclick;
|
|
714
|
-
actionInput.onclick = function() {
|
|
715
|
-
this.event(component, this);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
if (v.action == 'cancel') {
|
|
719
|
-
actionInput.style.color = 'red';
|
|
720
|
-
}
|
|
721
|
-
actionItem.appendChild(actionInput);
|
|
722
|
-
actionGroup.appendChild(actionItem);
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
actionContent.appendChild(actionGroup);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
// Show
|
|
729
|
-
actionsheet.style.display = '';
|
|
730
|
-
|
|
731
|
-
// Animation
|
|
732
|
-
jSuites.animation.slideBottom(actionContent, true);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
obj.close = function() {
|
|
736
|
-
if (actionsheet.style.display != 'none') {
|
|
737
|
-
// Remove any existing actionsheet
|
|
738
|
-
jSuites.animation.slideBottom(actionContent, false, function() {
|
|
739
|
-
actionsheet.style.display = 'none';
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
obj.get = function() {
|
|
745
|
-
return actionsheet;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
// Init action sheet
|
|
749
|
-
var actionsheet = document.createElement('div');
|
|
750
|
-
actionsheet.className = 'jactionsheet';
|
|
751
|
-
actionsheet.style.display = 'none';
|
|
752
|
-
|
|
753
|
-
var actionContent = document.createElement('div');
|
|
754
|
-
actionContent.className = 'jactionsheet-content';
|
|
755
|
-
actionsheet.appendChild(actionContent);
|
|
756
|
-
|
|
757
|
-
// Append actionsheet container to the application
|
|
758
|
-
el.appendChild(actionsheet);
|
|
759
|
-
|
|
760
|
-
el.actionsheet = obj;
|
|
761
|
-
|
|
762
|
-
return obj;
|
|
763
|
-
});
|
|
764
|
-
|
|
765
|
-
jSuites.dialog = (function() {
|
|
766
|
-
var obj = {};
|
|
767
|
-
obj.options = {};
|
|
768
|
-
|
|
769
|
-
var dialog = null;
|
|
770
|
-
var dialogTitle = null;
|
|
771
|
-
var dialogHeader = null;
|
|
772
|
-
var dialogMessage = null;
|
|
773
|
-
var dialogFooter = null;
|
|
774
|
-
var dialogContainer = null;
|
|
775
|
-
var dialogConfirm = null;
|
|
776
|
-
var dialogConfirmButton = null;
|
|
777
|
-
var dialogCancel = null;
|
|
778
|
-
var dialogCancelButton = null;
|
|
779
|
-
|
|
780
|
-
obj.open = function(options) {
|
|
781
|
-
if (! jSuites.dialog.hasEvents) {
|
|
782
|
-
obj.init();
|
|
783
|
-
|
|
784
|
-
jSuites.dialog.hasEvents = true;
|
|
785
|
-
}
|
|
786
|
-
obj.options = options;
|
|
787
|
-
|
|
788
|
-
if (obj.options.title) {
|
|
789
|
-
dialogTitle.innerHTML = obj.options.title;
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
if (obj.options.message) {
|
|
793
|
-
dialogMessage.innerHTML = obj.options.message;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
if (! obj.options.confirmLabel) {
|
|
797
|
-
obj.options.confirmLabel = 'OK';
|
|
798
|
-
}
|
|
799
|
-
dialogConfirmButton.value = obj.options.confirmLabel;
|
|
800
|
-
|
|
801
|
-
if (! obj.options.cancelLabel) {
|
|
802
|
-
obj.options.cancelLabel = 'Cancel';
|
|
803
|
-
}
|
|
804
|
-
dialogCancelButton.value = obj.options.cancelLabel;
|
|
805
|
-
|
|
806
|
-
if (obj.options.type == 'confirm') {
|
|
807
|
-
dialogCancelButton.parentNode.style.display = '';
|
|
808
|
-
} else {
|
|
809
|
-
dialogCancelButton.parentNode.style.display = 'none';
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
// Append element to the app
|
|
813
|
-
dialog.style.opacity = 100;
|
|
814
|
-
|
|
815
|
-
// Append to the page
|
|
816
|
-
if (jSuites.el) {
|
|
817
|
-
jSuites.el.appendChild(dialog);
|
|
818
|
-
} else {
|
|
819
|
-
document.body.appendChild(dialog);
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
// Focus
|
|
823
|
-
dialog.focus();
|
|
824
|
-
|
|
825
|
-
// Show
|
|
826
|
-
setTimeout(function() {
|
|
827
|
-
dialogContainer.style.opacity = 100;
|
|
828
|
-
}, 0);
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
obj.close = function() {
|
|
832
|
-
dialog.style.opacity = 0;
|
|
833
|
-
dialogContainer.style.opacity = 0;
|
|
834
|
-
setTimeout(function() {
|
|
835
|
-
dialog.remove();
|
|
836
|
-
}, 100);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
obj.init = function() {
|
|
840
|
-
dialog = document.createElement('div');
|
|
841
|
-
dialog.setAttribute('tabindex', '901');
|
|
842
|
-
dialog.className = 'jdialog';
|
|
843
|
-
dialog.id = 'dialog';
|
|
844
|
-
|
|
845
|
-
dialogHeader = document.createElement('div');
|
|
846
|
-
dialogHeader.className = 'jdialog-header';
|
|
847
|
-
|
|
848
|
-
dialogTitle = document.createElement('div');
|
|
849
|
-
dialogTitle.className = 'jdialog-title';
|
|
850
|
-
dialogHeader.appendChild(dialogTitle);
|
|
851
|
-
|
|
852
|
-
dialogMessage = document.createElement('div');
|
|
853
|
-
dialogMessage.className = 'jdialog-message';
|
|
854
|
-
dialogHeader.appendChild(dialogMessage);
|
|
855
|
-
|
|
856
|
-
dialogFooter = document.createElement('div');
|
|
857
|
-
dialogFooter.className = 'jdialog-footer';
|
|
858
|
-
|
|
859
|
-
dialogContainer = document.createElement('div');
|
|
860
|
-
dialogContainer.className = 'jdialog-container';
|
|
861
|
-
dialogContainer.appendChild(dialogHeader);
|
|
862
|
-
dialogContainer.appendChild(dialogFooter);
|
|
863
|
-
|
|
864
|
-
// Confirm
|
|
865
|
-
dialogConfirm = document.createElement('div');
|
|
866
|
-
dialogConfirmButton = document.createElement('input');
|
|
867
|
-
dialogConfirmButton.value = obj.options.confirmLabel;
|
|
868
|
-
dialogConfirmButton.type = 'button';
|
|
869
|
-
dialogConfirmButton.onclick = function() {
|
|
870
|
-
if (typeof(obj.options.onconfirm) == 'function') {
|
|
871
|
-
obj.options.onconfirm();
|
|
872
|
-
}
|
|
873
|
-
obj.close();
|
|
874
|
-
};
|
|
875
|
-
dialogConfirm.appendChild(dialogConfirmButton);
|
|
876
|
-
dialogFooter.appendChild(dialogConfirm);
|
|
877
|
-
|
|
878
|
-
// Cancel
|
|
879
|
-
dialogCancel = document.createElement('div');
|
|
880
|
-
dialogCancelButton = document.createElement('input');
|
|
881
|
-
dialogCancelButton.value = obj.options.cancelLabel;
|
|
882
|
-
dialogCancelButton.type = 'button';
|
|
883
|
-
dialogCancelButton.onclick = function() {
|
|
884
|
-
if (typeof(obj.options.oncancel) == 'function') {
|
|
885
|
-
obj.options.oncancel();
|
|
886
|
-
}
|
|
887
|
-
obj.close();
|
|
888
|
-
}
|
|
889
|
-
dialogCancel.appendChild(dialogCancelButton);
|
|
890
|
-
dialogFooter.appendChild(dialogCancel);
|
|
891
|
-
|
|
892
|
-
// Dialog
|
|
893
|
-
dialog.appendChild(dialogContainer);
|
|
894
|
-
|
|
895
|
-
document.addEventListener('keydown', function(e) {
|
|
896
|
-
if (e.which == 13) {
|
|
897
|
-
if (typeof(obj.options.onconfirm) == 'function') {
|
|
898
|
-
jSuites.dialog.options.onconfirm();
|
|
899
|
-
}
|
|
900
|
-
obj.close();
|
|
901
|
-
} else if (e.which == 27) {
|
|
902
|
-
obj.close();
|
|
903
|
-
}
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
return obj;
|
|
908
|
-
})();
|
|
909
|
-
|
|
910
|
-
jSuites.confirm = (function(message, onconfirm) {
|
|
911
|
-
if (jSuites.getWindowWidth() < 800) {
|
|
912
|
-
jSuites.dialog.open({
|
|
913
|
-
type: 'confirm',
|
|
914
|
-
message: message,
|
|
915
|
-
title: 'Confirmation',
|
|
916
|
-
onconfirm: onconfirm,
|
|
917
|
-
});
|
|
918
|
-
} else {
|
|
919
|
-
if (confirm(message)) {
|
|
920
|
-
onconfirm();
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
jSuites.refresh = (function(el, options) {
|
|
927
|
-
// Controls
|
|
928
|
-
var touchPosition = null;
|
|
929
|
-
var pushToRefresh = null;
|
|
930
|
-
|
|
931
|
-
// Page touch move
|
|
932
|
-
var pageTouchMove = function(e, page) {
|
|
933
|
-
if (typeof(page.options.onpush) == 'function') {
|
|
934
|
-
if (page.scrollTop < 5) {
|
|
935
|
-
if (! touchPosition) {
|
|
936
|
-
touchPosition = {};
|
|
937
|
-
touchPosition.x = e.touches[0].clientX;
|
|
938
|
-
touchPosition.y = e.touches[0].clientY;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
var height = e.touches[0].clientY - touchPosition.y;
|
|
942
|
-
if (height > 70) {
|
|
943
|
-
if (! pushToRefresh.classList.contains('ready')) {
|
|
944
|
-
pushToRefresh.classList.add('ready');
|
|
945
|
-
}
|
|
946
|
-
} else {
|
|
947
|
-
if (pushToRefresh.classList.contains('ready')) {
|
|
948
|
-
pushToRefresh.classList.remove('ready');
|
|
949
|
-
}
|
|
950
|
-
pushToRefresh.style.height = height + 'px';
|
|
951
|
-
|
|
952
|
-
if (height > 20) {
|
|
953
|
-
if (! pushToRefresh.classList.contains('holding')) {
|
|
954
|
-
pushToRefresh.classList.add('holding');
|
|
955
|
-
page.insertBefore(pushToRefresh, page.firstChild);
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
// Page touch end
|
|
964
|
-
var pageTouchEnd = function(e, page) {
|
|
965
|
-
if (typeof(page.options.onpush) == 'function') {
|
|
966
|
-
// Remove holding
|
|
967
|
-
pushToRefresh.classList.remove('holding');
|
|
968
|
-
// Refresh or not refresh
|
|
969
|
-
if (! pushToRefresh.classList.contains('ready')) {
|
|
970
|
-
// Reset and not refresh
|
|
971
|
-
pushToRefresh.style.height = '';
|
|
972
|
-
obj.hide();
|
|
973
|
-
} else {
|
|
974
|
-
pushToRefresh.classList.remove('ready');
|
|
975
|
-
// Loading indication
|
|
976
|
-
setTimeout(function() {
|
|
977
|
-
obj.hide();
|
|
978
|
-
}, 1000);
|
|
979
|
-
|
|
980
|
-
// Refresh
|
|
981
|
-
if (typeof(page.options.onpush) == 'function') {
|
|
982
|
-
page.options.onpush(page);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
var obj = function(element, callback) {
|
|
989
|
-
if (! pushToRefresh) {
|
|
990
|
-
pushToRefresh = document.createElement('div');
|
|
991
|
-
pushToRefresh.className = 'jrefresh';
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
element.addEventListener('touchmove', function(e) {
|
|
995
|
-
pageTouchMove(e, element);
|
|
996
|
-
});
|
|
997
|
-
element.addEventListener('touchend', function(e) {
|
|
998
|
-
pageTouchEnd(e, element);
|
|
999
|
-
});
|
|
1000
|
-
if (! element.options) {
|
|
1001
|
-
element.options = {};
|
|
1002
|
-
}
|
|
1003
|
-
if (typeof(callback) == 'function') {
|
|
1004
|
-
element.options.onpush = callback;
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
obj.hide = function() {
|
|
1009
|
-
if (pushToRefresh.parentNode) {
|
|
1010
|
-
pushToRefresh.parentNode.removeChild(pushToRefresh);
|
|
1011
|
-
}
|
|
1012
|
-
touchPosition = null;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
return obj;
|
|
1016
|
-
})();
|