[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.
This commit is contained in:
qsm-odoo
2016-10-24 10:52:00 +02:00
parent dad7036ce2
commit 9a75c6d608
+7 -2
View File
@@ -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