[FIX] website: remove 'enable_editor' from the URL before edition

This commit is contained in:
Christophe Matthieu
2019-02-19 08:43:51 +00:00
parent 832357f0b7
commit e3ad11d972
4 changed files with 7 additions and 9 deletions
@@ -26,8 +26,6 @@ var EditorMenu = Widget.extend({
request_save: '_onSnippetRequestSave',
},
LOCATION_SEARCH: 'enable_editor',
/**
* @override
*/
@@ -180,12 +178,7 @@ var EditorMenu = Widget.extend({
$('body').addClass('o_wait_reload');
this.wysiwyg.destroy();
window.location.hash = 'scrollTop=' + window.document.body.scrollTop;
if (window.location.search.indexOf(this.LOCATION_SEARCH) >= 0) {
var regExp = new RegExp('[&?]' + this.LOCATION_SEARCH + '(=[^&]*)?', 'g');
window.location.href = window.location.href.replace(regExp, '?');
} else {
window.location.reload(true);
}
window.location.reload(true);
return $.Deferred();
},
@@ -54,7 +54,6 @@ var WysiwygTranslate = Wysiwyg.extend({
});
var TranslatorMenu = EditorMenu.extend({
LOCATION_SEARCH: 'edit_translations',
/**
* @override
@@ -40,6 +40,8 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
},
});
this._editorAutoStart = (context.editable && window.location.search.indexOf('enable_editor') >= 0);
var url = window.location.href.replace(/([?&])&*enable_editor[^&#]*&?/, '\$1');
window.history.replaceState({}, null, url);
},
/**
* Auto-starts the editor if necessary or add the welcome message otherwise.
@@ -26,6 +26,9 @@ var TranslatePageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
});
this._mustEditTranslations = context.edit_translations;
if (this._mustEditTranslations) {
var url = window.location.href.replace(/([?&])&*edit_translations[^&#]*&?/, '\$1');
window.history.replaceState({}, null, url);
this._startTranslateMode();
}
return this._super.apply(this, arguments);
@@ -71,6 +74,7 @@ var TranslatePageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
window.location.search += '&edit_translations';
return $.Deferred();
}
var translator = new TranslatorMenu(this);
return translator.prependTo(document.body);
},