@ntlab/ntjs-repo 3.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/Bootstrap/Dialog/Confirm.js +82 -0
- package/Bootstrap/Dialog/Input.js +85 -0
- package/Bootstrap/Dialog/Message.js +63 -0
- package/Bootstrap/Dialog/Wait.js +136 -0
- package/Bootstrap/Dialog/index.js +345 -0
- package/Bootstrap/FormPost.js +145 -0
- package/Bootstrap/Notification.js +94 -0
- package/Bootstrap/index.js +45 -0
- package/BootstrapIcons.js +42 -0
- package/JQuery/AjaxHelper.js +82 -0
- package/JQuery/Define.js +81 -0
- package/JQuery/FormPost.js +278 -0
- package/JQuery/Notification.js +127 -0
- package/JQuery/PostErrorHelper.js +266 -0
- package/JQuery/PostHandler.js +78 -0
- package/JQuery/ScrollTo.js +63 -0
- package/JQuery/Util.js +112 -0
- package/JQuery/index.js +71 -0
- package/LICENSE +21 -0
- package/Popper.js +65 -0
- package/README.md +3 -0
- package/SemanticUI/Dialog/Confirm.js +79 -0
- package/SemanticUI/Dialog/Input.js +79 -0
- package/SemanticUI/Dialog/Message.js +59 -0
- package/SemanticUI/Dialog/Wait.js +75 -0
- package/SemanticUI/Dialog/index.js +228 -0
- package/SemanticUI/Loader.js +157 -0
- package/SemanticUI/Notification.js +58 -0
- package/SemanticUI/index.js +46 -0
- package/SocketIO/index.js +43 -0
- package/index.js +29 -0
- package/package.json +30 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023-2025 Toha <tohenk@yahoo.com>
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
+
* of the Software, and to permit persons to whom the Software is furnished to do
|
|
11
|
+
* so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const { ScriptRepository, ScriptManager } = require('@ntlab/ntjs');
|
|
26
|
+
const JQuery = ScriptManager.require('JQuery');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* JQuery/AjaxHelper script repository.
|
|
30
|
+
*/
|
|
31
|
+
class AjaxHelper extends JQuery {
|
|
32
|
+
|
|
33
|
+
initialize() {
|
|
34
|
+
this.name = 'AjaxHelper';
|
|
35
|
+
this.position = ScriptRepository.POSITION_FIRST;
|
|
36
|
+
this.addDependencies(['JQuery']);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getScript() {
|
|
40
|
+
return `
|
|
41
|
+
$.ajaxhelper = function(el) {
|
|
42
|
+
const helper = {
|
|
43
|
+
el: null,
|
|
44
|
+
dataKey: '_acxhr',
|
|
45
|
+
load(url, params, callback) {
|
|
46
|
+
const self = this;
|
|
47
|
+
if (typeof params === 'function') {
|
|
48
|
+
callback = params;
|
|
49
|
+
params = {};
|
|
50
|
+
}
|
|
51
|
+
const oxhr = self.el.data(self.dataKey);
|
|
52
|
+
if (oxhr && 'pending' === oxhr.state()) {
|
|
53
|
+
oxhr.abort();
|
|
54
|
+
}
|
|
55
|
+
self.el.trigger('xhrstart');
|
|
56
|
+
const xhr = $.ajax({
|
|
57
|
+
url: url,
|
|
58
|
+
dataType: 'json',
|
|
59
|
+
data: params
|
|
60
|
+
}).done(function(data) {
|
|
61
|
+
callback(data);
|
|
62
|
+
}).always(function() {
|
|
63
|
+
self.el.trigger('xhrend');
|
|
64
|
+
});
|
|
65
|
+
self.el.data(self.dataKey, xhr);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (typeof el === 'string') {
|
|
69
|
+
helper.el = $(el);
|
|
70
|
+
} else {
|
|
71
|
+
helper.el = el;
|
|
72
|
+
}
|
|
73
|
+
return helper;
|
|
74
|
+
}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static instance() {
|
|
78
|
+
return new this();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = AjaxHelper;
|
package/JQuery/Define.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018-2025 Toha <tohenk@yahoo.com>
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
+
* of the Software, and to permit persons to whom the Software is furnished to do
|
|
11
|
+
* so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const { ScriptRepository, ScriptManager } = require('@ntlab/ntjs');
|
|
26
|
+
const JQuery = ScriptManager.require('JQuery');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* JQuery/Define script repository.
|
|
30
|
+
*/
|
|
31
|
+
class Define extends JQuery {
|
|
32
|
+
|
|
33
|
+
initialize() {
|
|
34
|
+
this.name = 'Define';
|
|
35
|
+
this.position = ScriptRepository.POSITION_FIRST;
|
|
36
|
+
this.addDependencies(['JQuery']);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getScript() {
|
|
40
|
+
return `
|
|
41
|
+
if (!$.define) {
|
|
42
|
+
'use strict';
|
|
43
|
+
$.namespace = {
|
|
44
|
+
create(ns) {
|
|
45
|
+
let o = $;
|
|
46
|
+
const p = ns.split('.');
|
|
47
|
+
for (let i = 0; i < p.length; i++) {
|
|
48
|
+
o[p[i]] = o[p[i]] || {};
|
|
49
|
+
o = o[p[i]];
|
|
50
|
+
}
|
|
51
|
+
return o;
|
|
52
|
+
},
|
|
53
|
+
has(ns) {
|
|
54
|
+
let o = $;
|
|
55
|
+
const p = ns.split('.');
|
|
56
|
+
for (let i = 0; i < p.length; i++) {
|
|
57
|
+
if (!o[p[i]]) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
o = o[p[i]];
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
},
|
|
64
|
+
define(ns, o, e) {
|
|
65
|
+
if (!e && $.namespace.has(ns)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
Object.assign($.namespace.create(ns), o);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
$.define = $.namespace.define;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static instance() {
|
|
77
|
+
return new this();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = Define;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018-2025 Toha <tohenk@yahoo.com>
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
+
* of the Software, and to permit persons to whom the Software is furnished to do
|
|
11
|
+
* so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const Stringify = require('@ntlab/ntlib/stringify');
|
|
26
|
+
const { ScriptRepository, ScriptManager } = require('@ntlab/ntjs');
|
|
27
|
+
const JQuery = ScriptManager.require('JQuery');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* JQuery/FormPost script repository.
|
|
31
|
+
*/
|
|
32
|
+
class FormPost extends JQuery {
|
|
33
|
+
|
|
34
|
+
initialize() {
|
|
35
|
+
this.name = 'FormPost';
|
|
36
|
+
this.position = ScriptRepository.POSITION_FIRST;
|
|
37
|
+
this.addDependencies(['JQuery', 'JQuery/Util', 'JQuery/PostHandler']);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getOverrides() {
|
|
41
|
+
return {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getErrHelperOptions() {
|
|
46
|
+
return {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getScript() {
|
|
51
|
+
const title = this.translate('Form saved');
|
|
52
|
+
const error = this.translate('Error');
|
|
53
|
+
const ok = this.translate('OK');
|
|
54
|
+
const message = this.translate('Please wait while your data being saved.');
|
|
55
|
+
const redirDelay = FormPost.getOption('redir-delay', 0);
|
|
56
|
+
|
|
57
|
+
return `
|
|
58
|
+
$.formpost = function(form, options) {
|
|
59
|
+
const fp = {
|
|
60
|
+
errhelper: null,
|
|
61
|
+
message: '${message}',
|
|
62
|
+
xhr: false,
|
|
63
|
+
progress: true,
|
|
64
|
+
url: null,
|
|
65
|
+
paramName: null,
|
|
66
|
+
redirDelay: ${redirDelay},
|
|
67
|
+
onsubmit: null,
|
|
68
|
+
onfail: null,
|
|
69
|
+
onerror: null,
|
|
70
|
+
onalways: null,
|
|
71
|
+
onconfirm: null,
|
|
72
|
+
hasRequired(form) {
|
|
73
|
+
const self = this;
|
|
74
|
+
let status = false;
|
|
75
|
+
if (self.errhelper.requiredSelector) {
|
|
76
|
+
form.find(self.errhelper.requiredSelector).each(function() {
|
|
77
|
+
const el = $(this);
|
|
78
|
+
if ((el.is('input') || el.is('select') || el.is('textarea')) && el.is(':visible') && !el.is(':disabled')) {
|
|
79
|
+
const value = el.val();
|
|
80
|
+
if (!value) {
|
|
81
|
+
status = true;
|
|
82
|
+
self.errhelper.focused = el;
|
|
83
|
+
self.errhelper.focusError();
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return status;
|
|
90
|
+
},
|
|
91
|
+
formPost(form, url, success_cb, error_cb) {
|
|
92
|
+
let params, request;
|
|
93
|
+
form.trigger('formpost');
|
|
94
|
+
if (fp.paramName) {
|
|
95
|
+
params = form.data('submit-params');
|
|
96
|
+
params = typeof params === 'object' ? params : {};
|
|
97
|
+
params[fp.paramName] = form.serialize();
|
|
98
|
+
} else {
|
|
99
|
+
params = form.serializeArray();
|
|
100
|
+
}
|
|
101
|
+
const xtra = form.data('submit');
|
|
102
|
+
if (Array.isArray(xtra) && xtra.length) {
|
|
103
|
+
for (let i = 0; i < xtra.length; i++) {
|
|
104
|
+
params.push(xtra[i]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
fp.errhelper.resetError();
|
|
108
|
+
form.trigger('formrequest');
|
|
109
|
+
if (fp.xhr) {
|
|
110
|
+
request = $.ajax({
|
|
111
|
+
url: url,
|
|
112
|
+
type: 'POST',
|
|
113
|
+
dataType: 'json',
|
|
114
|
+
data: params,
|
|
115
|
+
headers: {
|
|
116
|
+
'X-Requested-With': 'XMLHttpRequest'
|
|
117
|
+
},
|
|
118
|
+
xhrFields: {
|
|
119
|
+
'withCredentials': true
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
request = $.post(url, params);
|
|
124
|
+
}
|
|
125
|
+
request
|
|
126
|
+
.done(function(data) {
|
|
127
|
+
$.handlePostData(data, fp.errhelper, function(data) {
|
|
128
|
+
if (typeof success_cb === 'function') {
|
|
129
|
+
success_cb(data);
|
|
130
|
+
}
|
|
131
|
+
}, function(data) {
|
|
132
|
+
if (typeof error_cb === 'function') {
|
|
133
|
+
error_cb(data);
|
|
134
|
+
}
|
|
135
|
+
if (typeof fp.onerror === 'function') {
|
|
136
|
+
fp.onerror(data);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
})
|
|
140
|
+
.fail(function() {
|
|
141
|
+
if (typeof fp.onfail === 'function') {
|
|
142
|
+
fp.onfail();
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
.always(function() {
|
|
146
|
+
if (typeof fp.onalways === 'function') {
|
|
147
|
+
fp.onalways();
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
;
|
|
151
|
+
},
|
|
152
|
+
bind(form) {
|
|
153
|
+
const self = this;
|
|
154
|
+
const submitclicker = function(e) {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
const submitter = $(this);
|
|
157
|
+
const xtra = [];
|
|
158
|
+
if (submitter.attr('name')) {
|
|
159
|
+
xtra.push({name: submitter.attr('name'), value: submitter.val()});
|
|
160
|
+
}
|
|
161
|
+
form.data('submit', xtra).submit();
|
|
162
|
+
}
|
|
163
|
+
form.find('[type=submit]').on('click', submitclicker);
|
|
164
|
+
const doit = function() {
|
|
165
|
+
if (typeof self.onsubmit === 'function' && !self.onsubmit(form)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const url = self.url || form.attr('action');
|
|
169
|
+
if (self.progress) {
|
|
170
|
+
$.ntdlg.wait(self.message);
|
|
171
|
+
}
|
|
172
|
+
self.formPost(form, url, function(json) {
|
|
173
|
+
form.trigger('formsaved', [json]);
|
|
174
|
+
if (json.notice) {
|
|
175
|
+
self.showSuccessMessage('${title}', json.notice, {
|
|
176
|
+
withOkay: !json.redir,
|
|
177
|
+
autoClose: typeof $.fpRedir === 'function'
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (json.redir) {
|
|
181
|
+
if (typeof $.fpRedir === 'function') {
|
|
182
|
+
$.fpRedir(json.redir);
|
|
183
|
+
} else {
|
|
184
|
+
if (self.redirDelay > 0) {
|
|
185
|
+
setTimeout(function() {
|
|
186
|
+
window.location.href = json.redir;
|
|
187
|
+
}, self.redirDelay);
|
|
188
|
+
} else {
|
|
189
|
+
window.location.href = json.redir;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, function(json) {
|
|
194
|
+
if (typeof self.onalways === 'function') {
|
|
195
|
+
self.onalways();
|
|
196
|
+
}
|
|
197
|
+
const f = function() {
|
|
198
|
+
self.errhelper.focusError();
|
|
199
|
+
form.trigger('formerror', [json]);
|
|
200
|
+
if (typeof $.formErrorHandler === 'function') {
|
|
201
|
+
$.formErrorHandler(form);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// handle global error
|
|
205
|
+
if (json.global || json.error_msg) {
|
|
206
|
+
if (json.global && json.global.length) {
|
|
207
|
+
if (self.errhelper.errorContainer) {
|
|
208
|
+
self.errhelper.addError(json.global, self.errhelper.errorContainer, self.errhelper.ERROR_ASLIST);
|
|
209
|
+
} else {
|
|
210
|
+
// concate error as part of error mesage
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (json.error_msg) {
|
|
214
|
+
self.showErrorMessage('${error}', json.error_msg, f);
|
|
215
|
+
} else {
|
|
216
|
+
f();
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
f();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
form.on('submit', function(e) {
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
if (self.hasRequired(form)) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (typeof self.onconfirm === 'function') {
|
|
229
|
+
self.onconfirm(form, doit);
|
|
230
|
+
} else {
|
|
231
|
+
doit();
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
showSuccessMessage(title, message, opts) {
|
|
236
|
+
const autoclose = opts.autoClose !== undefined ? opts.autoClose : false;
|
|
237
|
+
const withokay = opts.withOkay !== undefined ? opts.withOkay : true;
|
|
238
|
+
const buttons = {};
|
|
239
|
+
if (withokay && !autoclose) {
|
|
240
|
+
buttons['${ok}'] = function() {
|
|
241
|
+
$.ntdlg.close($(this));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const dlg = $.ntdlg.dialog('form_post_success', title, message, $.ntdlg.ICON_SUCCESS, buttons);
|
|
245
|
+
if (autoclose) {
|
|
246
|
+
dlg.on('dialogopen', function() {
|
|
247
|
+
$.ntdlg.close($(this));
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
showErrorMessage(title, message, callback) {
|
|
252
|
+
$.ntdlg.dialog('form_post_error', title, message, $.ntdlg.ICON_ERROR, {
|
|
253
|
+
['${ok}']() {
|
|
254
|
+
$.ntdlg.close($(this));
|
|
255
|
+
}
|
|
256
|
+
}, callback);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
Object.assign(fp, ${Stringify.from(this.getOverrides(), 1)});
|
|
260
|
+
const props = ['message', 'progress', 'xhr', 'url', 'paramName', 'onsubmit', 'onconfirm'];
|
|
261
|
+
$.util.applyProp(props, options, fp, true);
|
|
262
|
+
fp.bind(form);
|
|
263
|
+
fp.errhelper = $.errhelper(form, ${Stringify.from(this.getErrHelperOptions(), 1)});
|
|
264
|
+
fp.onalways = function() {
|
|
265
|
+
if (fp.progress) {
|
|
266
|
+
$.ntdlg.wait();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return fp;
|
|
270
|
+
}`;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static instance() {
|
|
274
|
+
return new this();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
module.exports = FormPost;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018-2025 Toha <tohenk@yahoo.com>
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
+
* of the Software, and to permit persons to whom the Software is furnished to do
|
|
11
|
+
* so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const { ScriptManager, ScriptRepository } = require('@ntlab/ntjs');
|
|
26
|
+
const JQuery = ScriptManager.require('JQuery');
|
|
27
|
+
|
|
28
|
+
class Notification extends JQuery {
|
|
29
|
+
|
|
30
|
+
initialize() {
|
|
31
|
+
this.name = 'Notification';
|
|
32
|
+
this.position = ScriptRepository.POSITION_MIDDLE;
|
|
33
|
+
this.dependencies = ['JQuery/Define'];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getScript() {
|
|
37
|
+
const title = this.translate('Notification');
|
|
38
|
+
|
|
39
|
+
return `
|
|
40
|
+
$.define('notif', {
|
|
41
|
+
title: '${title}',
|
|
42
|
+
supported() {
|
|
43
|
+
const self = this;
|
|
44
|
+
if ($.notif.allowed === undefined) {
|
|
45
|
+
let allowed = false;
|
|
46
|
+
// https://developer.mozilla.org/en/docs/Web/API/notification
|
|
47
|
+
if (window.Notification && Notification.permission !== 'denied') {
|
|
48
|
+
if (Notification.permission !== 'granted') {
|
|
49
|
+
Notification.requestPermission(function(permission) {
|
|
50
|
+
if (permission === 'granted') {
|
|
51
|
+
allowed = true;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
allowed = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
$.notif.allowed = allowed;
|
|
59
|
+
}
|
|
60
|
+
return $.notif.allowed;
|
|
61
|
+
},
|
|
62
|
+
notifyNotification(message, options) {
|
|
63
|
+
const self = this;
|
|
64
|
+
if (typeof options === 'string') {
|
|
65
|
+
let icon;
|
|
66
|
+
switch (options) {
|
|
67
|
+
case 'success':
|
|
68
|
+
// https://www.iconfinder.com/iconpack
|
|
69
|
+
icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGIAAACACAYAAADwKbyHAAAKi0lEQVR4nO2dX4xVxR3Hf8suayWadv3z0tB229BCs5pCbtjdy54zM8s9d+anq7GFHBtNDImpPtjSNlE0IjGr+yDxQQkhjQsIAXTvnpkhfdmUB/8kTQhEFhEwiJYWagOCNTbhadcqu31Ytqy6Z865954/95L5JOcF9pz5/eZ7Zn4zv5k5F8BisVgsFovFYrFYLBaLxWKxWCwWi8VisVgsFovF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uOl4cv9sRX1GJR4jGFxzpOfbtr4Glr/bdTAJOqOLrmRLbmBQHqMTjROIFovAyVThJFU4ShZeJxAtU4nEmxQGmxDaq+HpaKbmJnU+wWCwWi8VisVgsFovFYrFYLBaLxWKxWCwWi8VisVgsWfA/jkO6bA7+m44AAAAASUVORK5CYII=';
|
|
70
|
+
break;
|
|
71
|
+
case 'error':
|
|
72
|
+
// https://www.iconfinder.com/iconpack
|
|
73
|
+
icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGIAAACACAYAAADwKbyHAAAKrElEQVR4nO2d349VxR3AZwWxEk1DtS8NTWhjIw2aSldZdu+Z7yyFEBR/ATl0d+89852aeh+a8KRoRGK0PEh8kRgeDBqMPtiEPwAf/NE0IRDZ1SIGF7rsnjMzULBGrU9gFW4f7l5E4Myce37eJfNJbrIPe2e+M59z5vc5lxCHw+FwOBwOh8PhcDgcDofD4XA4HA6Hw+FwOBwOh8MxV5De2CLp8TWaiq0K8HXN8APJxKRi/AvNxDkFeEEBXtBMnFOMfyGZmNQg3tcMX1OAT0qPr5He2KKqyzHn2Of7CxTgWg1il2b801PDf2pl/SgmLmomjirAl6XH10z0N2+supw9SYuQvrBWX6mZ2KOZ+CqPyjd9NOCXCsSr00P1+1qE9FVd/sqZ6G/eKL0gkAw/Lrry4z4SxEcR8LEWGZ5fdX2UTosMz1fAH1MgZFUCrtF8hRI4tnx/XtX1UwrS42sU4LGqKz622WLiaOg1hquup8KYWu7/XDH+dtUV3YWQtyZXbLit6nrLFenxBxXD/2SolHOaicOK8b0K8FkJHCOK61WtQUMvGAi9YEDVGjSiuF4CRwW4XTF8QzM+rgHPp26uAM+GXmNd1fWXmYn+5o0axK4U7fVFScUBSfGZGcpX7PP9BWlj2Of7C0IvGFCMb5MMD6YRIhl/ac525if6m7drwH90eeX/S1Ox9Xht5BdFxTU1UF8sgT+tGZ/qSgYV7825ieHJwcYd3RRUUnEgguCBFiE3lBVji5AbpBc8pJk4lPzOEJPhypElZcW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5kWuGYme9E9ZXejHWyiCxvgaQDJEtmIYz+tXcUp9Po/LYlfRHF6XSZmonl7IwleQnsN6M4nTqwObjBZWQdAA1vVq8ONUiGt5A0w3hwqXJ5FKfTyDqARK5UN/9BI5EmsvaqTaIVxtD57YPd/FeAhreB/Wbpnfi2cC+KdJb9E2QVS/5xvjLULMkrcPKg2H0uHLekH6Pl9HRhUFaZXPsUkHRYpJ2Is7NA0in8opDoDSR5U5zUGGB9hKRDZH1YRo8s78Dp9XyR0+cNkjtlGlYFndxD9k/zRex36iu9mcMIUF/tnwf2W/kBSDMz34mKmk2ufQrfT+kE7VC3pN1cjSX9bFrhWNmelQLMhhHLup8fgDUtM4EDBSgzgao7UCXAyaR/oXAHgP0z62TxMAIgyX3r/HpBw/0Wsrw9jACW5D2SXstXNXfHgaQzsZyd+ZcBGkl2Dkn2TCuMFYqBZMmSvDQm1PKMfz5/7hhqQPIanLTLhDVmIYwC+01IhrfKFeRjnSxa9htmNoyULoridApZe41Emn9j3kjkqiXtnljtnqpcjPHgErL2gIa3857j94Qaktz9at6/WNn8O1GcToHzHyzJq4k4O1umppFk54DktWW/caCb/8JCGAWSJSDpIMs7dHKvvto/b9qhbmbDiGmH+smkfwFJ7n/9arIHTtqV3rwUzd1xcHod2T8F9luWtGtZ9y1pF9hvWefXkfRaqa92xP/CF/G5d2q21MVhAAAAAElFTkSuQmCC';
|
|
78
|
+
break;
|
|
79
|
+
case 'warn':
|
|
80
|
+
// https://www.iconfinder.com/yanlu
|
|
81
|
+
icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACR0lEQVRYhe2VP2gUQRTG5zQS4+Vy2ZkXBcEgqAGb1CksooIYEYJFCsWglSIKQkjuLjvzIoJlehEsbWyEgJUoiGAS9QoPBI0HFqYJpDC5nHfz3knGwkSiub2s96/xPthi3/v2/T5mdhghWmqpBsUmc32AnAbkt/GJlSPNpY+43WD4nTL2htKUUIbnhHC7msZX2t5SaJ/9enMRhTzrGXu9KfB9ie8HAYm7UqtHN2uen+9XSPno7fyBhgcApMfS0J1tdcPToOlRQ+HS2LOgeUEMZdu3NUeXooD0VfnF042hjyx2SOQvcVM8FWRRmoYB+bO46vbWna8M3ft7iQE5DYbf/FEzNFNui2pSZ2LtuELKd46v7d9a75kquZ6pktta85KuF5B+dE2sHqsT3kUA+WW5Y1YugBBCgLbjCu1zIVykZrzSfEUhz5YbFhRADLo2qTnj+XSpJnjsZk4B0orn5/vL9QMDCCGkLgxIY5fjKedVHQA0PwTD00H9SgGEEAKQHyjk+1XBPV08AYYWxehStNoA8ZTzpLHLUhcG/o1+ze1RyB+UpuFKNoU8Lw2/rujx6bJEfi8GXVtovjKUBEMzoT/YQWDsC6ntWChzd+rbYUBa95Kut14BYpO5PjBU6hgrHNrB6iKA9iloOx5mMCCnFfJ8OC/dVUhPKpqUpgtScybsfoX5B35rKNuuNGc9Y88HDzQ81+0XT4YaWIU2LqtXgQZA/uQZe64xeBfxNF2UmjOBFmnsGdC8sHm+6/kA0jpo/ljpOm+ppf9PPwHiDETAsgiBMAAAAABJRU5ErkJggg==';
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
options = {};
|
|
85
|
+
if (icon) options.icon = icon;
|
|
86
|
+
}
|
|
87
|
+
const title = options.title || self.title;
|
|
88
|
+
const content = {body: message};
|
|
89
|
+
if (options.icon) {
|
|
90
|
+
content.icon = options.icon;
|
|
91
|
+
}
|
|
92
|
+
const n = new Notification(title, content);
|
|
93
|
+
setTimeout(n.close.bind(n), options.delay || 5000);
|
|
94
|
+
return n;
|
|
95
|
+
},
|
|
96
|
+
notify(message, options) {
|
|
97
|
+
const self = this;
|
|
98
|
+
if (typeof self.notifyMessage === 'function') {
|
|
99
|
+
self.notifyMessage(message, options);
|
|
100
|
+
} else {
|
|
101
|
+
if (self.supported()) {
|
|
102
|
+
self.notifyNotification(message, options);
|
|
103
|
+
} else {
|
|
104
|
+
alert(message);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
init() {
|
|
109
|
+
const self = this;
|
|
110
|
+
if ($.notify === undefined) {
|
|
111
|
+
$.notify = self.notify.bind(self);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, true);
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getInitScript() {
|
|
119
|
+
this.addLast(`$.notif.init();`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static instance() {
|
|
123
|
+
return new this();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
module.exports = Notification;
|