nodebb-plugin-facebook-post 1.0.10 → 1.0.11
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 +16 -9
package/package.json
CHANGED
package/static/lib/admin.js
CHANGED
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
function toCsv(arr) {
|
|
6
6
|
return (arr || []).map(String).map(s => s.trim()).filter(Boolean).join(',');
|
|
7
7
|
}
|
|
8
|
+
function fromCsv(s) {
|
|
9
|
+
return (s || '').split(',').map(v => v.trim()).filter(Boolean);
|
|
10
|
+
}
|
|
8
11
|
|
|
9
12
|
function init() {
|
|
10
13
|
const $form = $('.facebook-post-settings');
|
|
11
14
|
if (!$form.length) return;
|
|
12
15
|
|
|
13
16
|
require(['settings', 'alerts'], function (Settings, alerts) {
|
|
14
|
-
Settings.load('facebook-post', $form);
|
|
15
|
-
|
|
16
17
|
const $select = $('#allowedGroupsSelect');
|
|
17
18
|
const $hidden = $('#allowedGroups');
|
|
18
19
|
|
|
@@ -20,15 +21,21 @@
|
|
|
20
21
|
$hidden.val(toCsv($select.val() || []));
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
// Prevent full page refresh if user hits Enter
|
|
25
|
+
$form.off('submit.fbpost').on('submit.fbpost', function (e) { e.preventDefault(); return false; });
|
|
26
|
+
|
|
27
|
+
// IMPORTANT: wait for Settings.load to finish before reading hidden input
|
|
28
|
+
Settings.load('facebook-post', $form, function () {
|
|
29
|
+
const existing = fromCsv($hidden.val());
|
|
30
|
+
if (existing.length) {
|
|
31
|
+
$select.val(existing);
|
|
32
|
+
} else {
|
|
33
|
+
$select.val([]);
|
|
34
|
+
}
|
|
35
|
+
syncHidden();
|
|
36
|
+
});
|
|
29
37
|
|
|
30
38
|
$select.off('change.fbpost').on('change.fbpost', syncHidden);
|
|
31
|
-
$form.off('submit.fbpost').on('submit.fbpost', function (e) { e.preventDefault(); return false; });
|
|
32
39
|
|
|
33
40
|
$('#save').off('click.fbpost').on('click.fbpost', function (e) {
|
|
34
41
|
e.preventDefault();
|