diff options
| author | qsm-odoo <qsm@odoo.com> | 2018-11-29 14:47:42 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2018-11-29 16:41:33 +0000 |
| commit | a153ed42a09f8b7f5e0865112eb7d5affc22a353 (patch) | |
| tree | 36da68c896ade6909f3225670430b0f018da8b28 /addons/website/static/src/js/menu | |
| parent | 962298c9205e8dbf6eab3f8d3a24c99ad2cea38b (diff) | |
[FIX] website, *: properly clean website widgets
* web_editor
When an user saves its website, all the animations are destroyed so that
a clean DOM is saved. This is particularly important for snippets like
the latest post one that would crash the page if not cleaned before
saving.
Two cases were found where animations were not cleaned before saving and
this is what this commit fixes:
- When an user used the undo/redo system, all animations were lost as
the DOM is recreated.
- When an user duplicated a snippet, animations were not restarted on
the cloned element.
closes odoo/odoo#29159
Diffstat (limited to 'addons/website/static/src/js/menu')
| -rw-r--r-- | addons/website/static/src/js/menu/edit.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/addons/website/static/src/js/menu/edit.js b/addons/website/static/src/js/menu/edit.js index 15e5d4cf20e..c42e2196887 100644 --- a/addons/website/static/src/js/menu/edit.js +++ b/addons/website/static/src/js/menu/edit.js @@ -15,6 +15,9 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ edit: '_startEditMode', }), custom_events: _.extend({}, websiteNavbarData.WebsiteNavbarActionWidget.custom_events || {}, { + content_will_be_destroyed: '_onContentWillBeDestroyed', + content_was_recreated: '_onContentWasRecreated', + snippet_cloned: '_onSnippetCloned', snippet_dropped: '_onSnippetDropped', }), @@ -84,6 +87,44 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ //-------------------------------------------------------------------------- /** + * Called when content will be destroyed in the page. Notifies the + * WebsiteRoot that is should stop the animations. + * + * @private + * @param {OdooEvent} ev + */ + _onContentWillBeDestroyed: function (ev) { + this.trigger_up('animation_stop_demand', { + $target: ev.data.$target, + }); + }, + /** + * Called when content will be recreated in the page. Notifies the + * WebsiteRoot that is should start the animations. + * + * @private + * @param {OdooEvent} ev + */ + _onContentWasRecreated: function (ev) { + this.trigger_up('animation_start_demand', { + editableMode: true, + $target: ev.data.$target, + }); + }, + /** + * Called when a snippet is cloned in the page. Notifies the WebsiteRoot + * that is should start the animations for this snippet. + * + * @private + * @param {OdooEvent} ev + */ + _onSnippetCloned: function (ev) { + this.trigger_up('animation_start_demand', { + editableMode: true, + $target: ev.data.$target, + }); + }, + /** * Called when a snippet is dropped in the page. Notifies the WebsiteRoot * that is should start the animations for this snippet. * |
