nodebb-plugin-composer-default 10.3.11 → 10.3.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/library.js +0 -1
- package/package.json +1 -1
- package/static/lib/composer/preview.js +1 -0
- package/static/lib/composer.js +20 -37
package/library.js
CHANGED
package/package.json
CHANGED
|
@@ -63,6 +63,7 @@ define('composer/preview', ['hooks'], function (hooks) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function togglePreview(show) {
|
|
66
|
+
const isMobile = ['xs', 'sm'].includes(preview.env);
|
|
66
67
|
if (isMobile) {
|
|
67
68
|
previewContainer.classList.toggle('hide', false);
|
|
68
69
|
writeContainer.classList.toggle('maximized', false);
|
package/static/lib/composer.js
CHANGED
|
@@ -40,7 +40,7 @@ define('composer', [
|
|
|
40
40
|
localStorage.removeItem('category:' + data.data.cid + ':bookmark:clicked');
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
window.addEventListener('popstate', function () {
|
|
44
44
|
var env = utils.findBootstrapEnvironment();
|
|
45
45
|
if (composer.active && (env === 'xs' || env === 'sm')) {
|
|
46
46
|
if (!composer.posts[composer.active].modified) {
|
|
@@ -74,29 +74,17 @@ define('composer', [
|
|
|
74
74
|
var env = utils.findBootstrapEnvironment();
|
|
75
75
|
var isMobile = env === 'xs' || env === 'sm';
|
|
76
76
|
|
|
77
|
-
if (preview.toggle) {
|
|
78
|
-
if (preview.env !== env && isMobile) {
|
|
79
|
-
preview.env = env;
|
|
80
|
-
preview.toggle(false);
|
|
81
|
-
}
|
|
77
|
+
if (preview.toggle && preview.env !== env) {
|
|
82
78
|
preview.env = env;
|
|
79
|
+
preview.toggle(!isMobile);
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
if (composer.active !== undefined) {
|
|
86
83
|
resize.reposition($('.composer[data-uuid="' + composer.active + '"]'));
|
|
87
84
|
|
|
88
|
-
if (!isMobile && window.
|
|
89
|
-
/*
|
|
90
|
-
* If this conditional is met, we're no longer in mobile/tablet
|
|
91
|
-
* resolution but we've somehow managed to have a mobile
|
|
92
|
-
* composer load, so let's go back to the topic
|
|
93
|
-
*/
|
|
85
|
+
if (!isMobile && window.history.state && window.history.state.composerBackState) {
|
|
94
86
|
history.back();
|
|
95
|
-
} else if (isMobile
|
|
96
|
-
/*
|
|
97
|
-
* In this case, we're in mobile/tablet resolution but the composer
|
|
98
|
-
* that loaded was a regular composer, so let's fix the address bar
|
|
99
|
-
*/
|
|
87
|
+
} else if (isMobile) {
|
|
100
88
|
mobileHistoryAppend();
|
|
101
89
|
}
|
|
102
90
|
}
|
|
@@ -562,27 +550,22 @@ define('composer', [
|
|
|
562
550
|
}
|
|
563
551
|
|
|
564
552
|
function mobileHistoryAppend() {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
//
|
|
569
|
-
if (
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
553
|
+
// add a fake entry to the browser history so that the user can
|
|
554
|
+
// press back to return to where they were before opening the composer
|
|
555
|
+
// popstate listener in this file closes the composer on mobile,
|
|
556
|
+
// browser automatically removes the fake entry when user presses back
|
|
557
|
+
if (window.history.state && !window.history.state.composerBackState) {
|
|
558
|
+
// modify current state so that ajaxify.go doesn't
|
|
559
|
+
// trigger when user presses back from composer
|
|
560
|
+
window.history.replaceState({
|
|
561
|
+
url: null,
|
|
562
|
+
returnPath: history.state.url,
|
|
563
|
+
}, ''); // 3rd param optional url, we dont change it
|
|
564
|
+
|
|
565
|
+
window.history.pushState({
|
|
566
|
+
composerBackState: true,
|
|
567
|
+
}, ''); // 3rd param optional url, we dont change it
|
|
574
568
|
}
|
|
575
|
-
|
|
576
|
-
// Add in return path to be caught by ajaxify when post is completed, or if back is pressed
|
|
577
|
-
window.history.replaceState({
|
|
578
|
-
url: null,
|
|
579
|
-
returnPath: returnPath,
|
|
580
|
-
}, '', `${config.relative_path}/${returnPath}`);
|
|
581
|
-
|
|
582
|
-
// Update address bar in case f5 is pressed
|
|
583
|
-
window.history.pushState({
|
|
584
|
-
url: path,
|
|
585
|
-
}, '', `${config.relative_path}/${returnPath}`);
|
|
586
569
|
}
|
|
587
570
|
|
|
588
571
|
function handleRemotePid(postContainer) {
|