nodebb-plugin-facebook-post 1.0.11 → 1.0.12
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/composer.js +22 -11
package/package.json
CHANGED
package/static/lib/composer.js
CHANGED
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function injectUI($composer) {
|
|
16
|
+
if (!$composer || !$composer.length) return;
|
|
16
17
|
if ($composer.find('[data-fbpost-wrap]').length) return;
|
|
17
18
|
|
|
18
19
|
const html = `
|
|
19
20
|
<div class="mb-2" data-fbpost-wrap>
|
|
20
21
|
<div class="form-check mb-2">
|
|
21
22
|
<input type="checkbox" class="form-check-input" id="fbPostEnabled" data-fbpost-enabled>
|
|
22
|
-
<label class="form-check-label" for="fbPostEnabled">Publier ce nouveau topic sur Facebook</label>
|
|
23
|
+
<label class="form-check-label" for="fbPostEnabled">Publier ce nouveau topic sur Facebook (et Insta si activé)</label>
|
|
23
24
|
</div>
|
|
24
25
|
|
|
25
26
|
<div class="mb-2" data-fbpost-place-wrap style="display:none;">
|
|
@@ -28,13 +29,18 @@
|
|
|
28
29
|
</label>
|
|
29
30
|
<input type="text" class="form-control" data-fbpost-place-id placeholder="ex: 123456789012345">
|
|
30
31
|
<div class="form-text" style="font-size: 11px;">
|
|
31
|
-
|
|
32
|
+
Utilisé comme <code>place</code> sur Facebook et <code>location_id</code> sur Instagram.
|
|
32
33
|
</div>
|
|
33
34
|
</div>
|
|
34
35
|
</div>
|
|
35
36
|
`;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
// More robust placement across themes
|
|
39
|
+
const $targets = $composer.find(
|
|
40
|
+
'.composer-body, .composer-content, .write, .composer .write, .composer .composer-body, .composer .composer-content'
|
|
41
|
+
);
|
|
42
|
+
const $target = $targets.first();
|
|
43
|
+
|
|
38
44
|
if ($target.length) $target.prepend(html);
|
|
39
45
|
else $composer.prepend(html);
|
|
40
46
|
|
|
@@ -45,7 +51,7 @@
|
|
|
45
51
|
$placeWrap.toggle($enabled.is(':checked'));
|
|
46
52
|
});
|
|
47
53
|
|
|
48
|
-
//
|
|
54
|
+
// Attach once per composer instance
|
|
49
55
|
$(window).off('filter:composer.submit.fbpost')
|
|
50
56
|
.on('filter:composer.submit.fbpost', function (ev2, submitData) {
|
|
51
57
|
const enabled = $enabled.is(':checked');
|
|
@@ -60,18 +66,23 @@
|
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
async function onComposerLoaded(ev, data) {
|
|
64
70
|
try {
|
|
65
|
-
const $composer = data && data.composer ? data.composer : $('.composer');
|
|
66
|
-
if (!$composer
|
|
71
|
+
const $composer = $(data && data.composer ? data.composer : $('.composer')).first();
|
|
72
|
+
if (!$composer.length) return;
|
|
67
73
|
|
|
68
74
|
const perm = await canPost();
|
|
69
75
|
if (!perm.allowed) return;
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
// Defer injection slightly (composer DOM may still be mounting)
|
|
78
|
+
setTimeout(() => injectUI($composer), 0);
|
|
79
|
+
} catch {
|
|
73
80
|
// ignore
|
|
74
81
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
$(window).on('action:composer.loaded', onComposerLoaded);
|
|
77
85
|
|
|
86
|
+
// Some themes trigger different events; listen to opened as well.
|
|
87
|
+
$(window).on('action:composer.opened', onComposerLoaded);
|
|
88
|
+
})();
|