From 62fb1bb92493b00bd45ed3f4eced5ca8b23f81d6 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 18 May 2016 18:02:51 +0200 Subject: [REF] web_editor: code refactoring and simplification * Remove dead code + optimization * Use Dialog API from web module * Reorganize files * Correct buggy $() function for snippet option class * Add comments * Fix the snippet parent navigation : If a page contained a three level snippet structure (i.e A contains B contains C), when editing the following bug occured : If B or C was selected first, parenting buttons were correctly set. But if selecting A then C, clicking on the parent lead to going back on A instead of going on B. * Fix snippet thumbnail layout * Better isolate ui css from themes * MediaDialog image list : prevent displaying empty attachments * ... --- addons/web_editor/static/src/js/inline.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'addons/web_editor/static/src/js/inline.js') diff --git a/addons/web_editor/static/src/js/inline.js b/addons/web_editor/static/src/js/inline.js index 8f63d603b20..765ce7682df 100644 --- a/addons/web_editor/static/src/js/inline.js +++ b/addons/web_editor/static/src/js/inline.js @@ -9,26 +9,25 @@ var snippet_editor = require('web_editor.snippet.editor'); widget.MediaDialog.include({ start: function () { - this._super(); + this._super.apply(this, arguments); this.$('[href="#editor-media-video"]').addClass('hidden'); } }); editor.Class.include({ start: function () { - var self = this; if (location.search.indexOf("enable_editor") !== -1) { this.on('rte:start', this, function () { // move the caret at the end of the text when click after all content $("#wrapwrap").on('click', function (event) { if ($(event.target).is("#wrapwrap") || $(event.target).is("#editable_area:empty")) { - setTimeout(function () { + _.defer(function () { var node = $("#editable_area *") .filter(function () { return this.textContent.match(/\S|\u00A0/); }) .add($("#editable_area")) .last()[0]; $.summernote.core.range.create(node, $.summernote.core.dom.nodeLength(node)).select(); - },0); + }); } }); }); @@ -39,8 +38,7 @@ editor.Class.include({ snippet_editor.Class.include({ start: function () { - var self = this; - this._super(); + this._super.apply(this, arguments); setTimeout(function () { var $editable = $("#editable_area"); transcoder.img_to_font($editable); @@ -51,7 +49,7 @@ snippet_editor.Class.include({ }); }, clean_for_save: function () { - this._super(); + this._super.apply(this, arguments); var $editable = $("#editable_area"); transcoder.font_to_img($editable); transcoder.class_to_style($editable); @@ -65,7 +63,6 @@ snippet_editor.Class.include({ }); }); }, - }); window.top.odoo[callback+"_updown"] = function (value, fields_values) { @@ -76,7 +73,7 @@ window.top.odoo[callback+"_updown"] = function (value, fields_values) { if (snippet_editor.instance) { snippet_editor.instance.make_active(false); } - + $editable.html(value); transcoder.img_to_font($editable); @@ -88,5 +85,4 @@ window.top.odoo[callback+"_updown"] = function (value, fields_values) { $editable.trigger("content_changed"); } }; - -}); \ No newline at end of file +}); -- cgit v1.2.3