nodebb-plugin-composer-default 7.0.13 → 7.0.17
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/package.json +1 -1
- package/static/lib/admin.js +2 -2
- package/static/lib/composer/drafts.js +3 -3
- package/static/lib/composer/resize.js +1 -1
- package/static/lib/composer/scheduler.js +2 -2
- package/static/lib/composer/tags.js +8 -8
- package/static/lib/composer/uploads.js +5 -4
- package/static/lib/composer.js +19 -7
package/package.json
CHANGED
package/static/lib/admin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
define('admin/plugins/composer-default', ['settings'], function (Settings) {
|
|
3
|
+
define('admin/plugins/composer-default', ['settings', 'alerts'], function (Settings, alerts) {
|
|
4
4
|
var ACP = {};
|
|
5
5
|
|
|
6
6
|
ACP.init = function () {
|
|
@@ -8,7 +8,7 @@ define('admin/plugins/composer-default', ['settings'], function (Settings) {
|
|
|
8
8
|
|
|
9
9
|
$('#save').on('click', function () {
|
|
10
10
|
Settings.save('composer-default', $('.composer-default-settings'), function () {
|
|
11
|
-
|
|
11
|
+
alerts.alert({
|
|
12
12
|
type: 'success',
|
|
13
13
|
alert_id: 'composer-default-saved',
|
|
14
14
|
title: 'Settings Saved',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
define('composer/drafts', ['api'], function (api) {
|
|
3
|
+
define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
|
|
4
4
|
var drafts = {};
|
|
5
|
-
var
|
|
5
|
+
var saveThrottleId;
|
|
6
6
|
|
|
7
7
|
drafts.init = function (postContainer, postData) {
|
|
8
8
|
var draftIconEl = postContainer.find('.draft-icon');
|
|
@@ -263,7 +263,7 @@ define('composer/drafts', ['api'], function (api) {
|
|
|
263
263
|
} else if (type === 'tid') {
|
|
264
264
|
socket.emit('topics.getTopic', id, function (err, topicObj) {
|
|
265
265
|
if (err) {
|
|
266
|
-
return
|
|
266
|
+
return alerts.error(err);
|
|
267
267
|
}
|
|
268
268
|
composer.newReply(id, undefined, topicObj.title, draft.text);
|
|
269
269
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
define('composer/scheduler', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
|
|
3
|
+
define('composer/scheduler', ['benchpress', 'bootbox', 'alerts'], function (Benchpress, bootbox, alerts) {
|
|
4
4
|
const scheduler = {};
|
|
5
5
|
const state = {
|
|
6
6
|
timestamp: 0,
|
|
@@ -128,7 +128,7 @@ define('composer/scheduler', ['benchpress', 'bootbox'], function (Benchpress, bo
|
|
|
128
128
|
if (!bothFilled || isNaN(timestamp) || timestamp < Date.now()) {
|
|
129
129
|
state.timestamp = 0;
|
|
130
130
|
const message = timestamp < Date.now() ? '[[error:scheduling-to-past]]' : '[[error:invalid-schedule-date]]';
|
|
131
|
-
|
|
131
|
+
alerts.alert({
|
|
132
132
|
type: 'danger',
|
|
133
133
|
timeout: 3000,
|
|
134
134
|
title: '',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
define('composer/tags', function () {
|
|
4
|
+
define('composer/tags', ['alerts'], function (alerts) {
|
|
5
5
|
var tags = {};
|
|
6
6
|
|
|
7
7
|
var minTags;
|
|
@@ -38,7 +38,7 @@ define('composer/tags', function () {
|
|
|
38
38
|
cid: postData.cid,
|
|
39
39
|
}, function (err, tags) {
|
|
40
40
|
if (err) {
|
|
41
|
-
return
|
|
41
|
+
return alerts.error(err);
|
|
42
42
|
}
|
|
43
43
|
if (tags) {
|
|
44
44
|
response(tags);
|
|
@@ -64,11 +64,11 @@ define('composer/tags', function () {
|
|
|
64
64
|
reachedMaxTags;
|
|
65
65
|
|
|
66
66
|
if (event.item.length < config.minimumTagLength) {
|
|
67
|
-
return
|
|
67
|
+
return alerts.error('[[error:tag-too-short, ' + config.minimumTagLength + ']]');
|
|
68
68
|
} else if (event.item.length > config.maximumTagLength) {
|
|
69
|
-
return
|
|
69
|
+
return alerts.error('[[error:tag-too-long, ' + config.maximumTagLength + ']]');
|
|
70
70
|
} else if (reachedMaxTags) {
|
|
71
|
-
return
|
|
71
|
+
return alerts.error('[[error:too-many-tags, ' + maxTags + ']]');
|
|
72
72
|
}
|
|
73
73
|
if (different) {
|
|
74
74
|
tagEl.tagsinput('add', cleanTag);
|
|
@@ -88,10 +88,10 @@ define('composer/tags', function () {
|
|
|
88
88
|
}
|
|
89
89
|
socket.emit('topics.canRemoveTag', { tag: event.item }, function (err, allowed) {
|
|
90
90
|
if (err) {
|
|
91
|
-
return
|
|
91
|
+
return alerts.error(err);
|
|
92
92
|
}
|
|
93
93
|
if (!allowed) {
|
|
94
|
-
|
|
94
|
+
alerts.error('[[error:cant-remove-system-tag]]');
|
|
95
95
|
skipAddCheck = true;
|
|
96
96
|
tagEl.tagsinput('add', event.item);
|
|
97
97
|
}
|
|
@@ -106,7 +106,7 @@ define('composer/tags', function () {
|
|
|
106
106
|
var cid = postData.hasOwnProperty('cid') ? postData.cid : ajaxify.data.cid;
|
|
107
107
|
socket.emit('topics.isTagAllowed', { tag: event.item, cid: cid || 0 }, function (err, allowed) {
|
|
108
108
|
if (err) {
|
|
109
|
-
return
|
|
109
|
+
return alerts.error(err);
|
|
110
110
|
}
|
|
111
111
|
if (!allowed) {
|
|
112
112
|
skipRemoveCheck = true;
|
|
@@ -4,8 +4,9 @@ define('composer/uploads', [
|
|
|
4
4
|
'composer/preview',
|
|
5
5
|
'composer/categoryList',
|
|
6
6
|
'translator',
|
|
7
|
+
'alerts',
|
|
7
8
|
'jquery-form',
|
|
8
|
-
], function (preview, categoryList, translator) {
|
|
9
|
+
], function (preview, categoryList, translator, alerts) {
|
|
9
10
|
var uploads = {
|
|
10
11
|
inProgress: {},
|
|
11
12
|
};
|
|
@@ -193,7 +194,7 @@ define('composer/uploads', [
|
|
|
193
194
|
for (i = 0; i < files.length; ++i) {
|
|
194
195
|
isImage = files[i].type.match(/image./);
|
|
195
196
|
if ((isImage && !app.user.privileges['upload:post:image']) || (!isImage && !app.user.privileges['upload:post:file'])) {
|
|
196
|
-
return
|
|
197
|
+
return alerts.error('[[error:no-privileges]]');
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
|
|
@@ -207,7 +208,7 @@ define('composer/uploads', [
|
|
|
207
208
|
|
|
208
209
|
if (files[i].size > parseInt(config.maximumFileSize, 10) * 1024) {
|
|
209
210
|
uploadForm[0].reset();
|
|
210
|
-
return
|
|
211
|
+
return alerts.error('[[error:file-too-big, ' + config.maximumFileSize + ']]');
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
text = insertText(text, textarea.getCursorPosition(), (isImage ? '!' : '') + '[' + filenameMapping[i] + '](' + uploadingText + ') ');
|
|
@@ -321,7 +322,7 @@ define('composer/uploads', [
|
|
|
321
322
|
if (xhr && xhr.status === 413) {
|
|
322
323
|
msg = xhr.statusText || 'Request Entity Too Large';
|
|
323
324
|
}
|
|
324
|
-
|
|
325
|
+
alerts.error(msg);
|
|
325
326
|
$(window).trigger('action:composer.uploadError', {
|
|
326
327
|
post_uuid: post_uuid,
|
|
327
328
|
message: msg,
|
package/static/lib/composer.js
CHANGED
|
@@ -18,10 +18,14 @@ define('composer', [
|
|
|
18
18
|
'topicThumbs',
|
|
19
19
|
'api',
|
|
20
20
|
'bootbox',
|
|
21
|
+
'alerts',
|
|
21
22
|
'hooks',
|
|
22
23
|
'messages',
|
|
24
|
+
'search',
|
|
23
25
|
], function (taskbar, translator, uploads, formatting, drafts, tags,
|
|
24
|
-
categoryList, preview, resize, autocomplete, scheduler, scrollStop,
|
|
26
|
+
categoryList, preview, resize, autocomplete, scheduler, scrollStop,
|
|
27
|
+
topicThumbs, api, bootbox, alerts, hooks, messagesModule, search
|
|
28
|
+
) {
|
|
25
29
|
var composer = {
|
|
26
30
|
active: undefined,
|
|
27
31
|
posts: {},
|
|
@@ -104,7 +108,7 @@ define('composer', [
|
|
|
104
108
|
|
|
105
109
|
function alreadyOpen(post) {
|
|
106
110
|
// If a composer for the same cid/tid/pid is already open, return the uuid, else return bool false
|
|
107
|
-
var
|
|
111
|
+
var type;
|
|
108
112
|
var id;
|
|
109
113
|
|
|
110
114
|
if (post.hasOwnProperty('cid')) {
|
|
@@ -169,7 +173,7 @@ define('composer', [
|
|
|
169
173
|
const { showAlert } = await hooks.fire('filter:composer.error', { post_uuid, message, showAlert: true });
|
|
170
174
|
|
|
171
175
|
if (showAlert) {
|
|
172
|
-
|
|
176
|
+
alerts.alert({
|
|
173
177
|
type: 'danger',
|
|
174
178
|
timeout: 3000,
|
|
175
179
|
title: '',
|
|
@@ -273,7 +277,7 @@ define('composer', [
|
|
|
273
277
|
composer.editPost = function (pid) {
|
|
274
278
|
socket.emit('plugins.composer.push', pid, function (err, threadData) {
|
|
275
279
|
if (err) {
|
|
276
|
-
return
|
|
280
|
+
return alerts.error(err);
|
|
277
281
|
}
|
|
278
282
|
threadData.action = 'posts.edit';
|
|
279
283
|
threadData.pid = pid;
|
|
@@ -294,7 +298,7 @@ define('composer', [
|
|
|
294
298
|
} else {
|
|
295
299
|
socket.emit('plugins.composer.getFormattingOptions', function (err, options) {
|
|
296
300
|
if (err) {
|
|
297
|
-
return
|
|
301
|
+
return alerts.error(err);
|
|
298
302
|
}
|
|
299
303
|
composer.formatting = options;
|
|
300
304
|
createNewComposer(post_uuid);
|
|
@@ -610,7 +614,7 @@ define('composer', [
|
|
|
610
614
|
return;
|
|
611
615
|
}
|
|
612
616
|
|
|
613
|
-
|
|
617
|
+
search.enableQuickSearch({
|
|
614
618
|
searchElements: {
|
|
615
619
|
inputEl: postContainer.find('input.title'),
|
|
616
620
|
resultEl: postContainer.find('.quick-search-container'),
|
|
@@ -767,7 +771,15 @@ define('composer', [
|
|
|
767
771
|
drafts.removeDraft(postData.save_id);
|
|
768
772
|
|
|
769
773
|
if (data.queued) {
|
|
770
|
-
|
|
774
|
+
alerts.alert({
|
|
775
|
+
type: 'success',
|
|
776
|
+
title: '[[global:alert.success]]',
|
|
777
|
+
message: data.message,
|
|
778
|
+
timeout: 10000,
|
|
779
|
+
clickfn: function () {
|
|
780
|
+
ajaxify.go(`/post-queue/${data.id}`);
|
|
781
|
+
},
|
|
782
|
+
});
|
|
771
783
|
} else if (action === 'topics.post') {
|
|
772
784
|
if (submitHookData.redirect) {
|
|
773
785
|
ajaxify.go('topic/' + data.slug, undefined, (onComposeRoute || composer.bsEnvironment === 'xs' || composer.bsEnvironment === 'sm'));
|