From 9a75c6d6080ce63ebbae2b241ad0667b6656d2e8 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 20 Oct 2016 13:35:50 +0200 Subject: [PATCH] [FIX] web_editor: correct ViewEditor widget life cycle These two fixes are now important since the ViewEditor is now also used in the backend. * The start method must return a deferred. * The destroy method must unbind the event on the document element. Note: in master, the ViewEditor is being refactored. --- addons/web_editor/static/src/js/ace.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/ace.js b/addons/web_editor/static/src/js/ace.js index 56500383851..c75caea6628 100644 --- a/addons/web_editor/static/src/js/ace.js +++ b/addons/web_editor/static/src/js/ace.js @@ -106,13 +106,18 @@ var ViewEditor = Widget.extend({ storeEditorWidth(); } } - document.body.addEventListener('mouseup', stopResizing, true); self.$('.ace_gutter').mouseup(stopResizing).mousedown(startResizing).click(stopResizing); - $(document).mousemove(updateWidth); + $(document).on("mousemove.ViewEditor", updateWidth).on("mouseup.ViewEditor", stopResizing); $('button[data-action=edit]').click(function () { self.close(); }); resizeEditor(readEditorWidth()); + + return this._super.apply(this, arguments); + }, + destroy: function () { + this._super.apply(this, arguments); + $(document).off(".ViewEditor"); }, // The 4 following methods are meant to be extended depending on the context