From 8ad325614de9b600e73ad40a680b3fb56d1aa298 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 12 Mar 2014 15:19:10 +0100 Subject: [PATCH] [FIX] sprurious widgetification and editability of icon elements * tighten widget match: don't match elements with .fa which are also "view section" roots (~ editing hosts) as the classes themselves out not be editable and the result will thus be odd * correspondingly, only associate the icon "change" button to instances of the ``icons`` widget, other elements bearing ``.fa`` are not editable and should be excluded. bzr revid: xmo@openerp.com-20140312141910-a2apy22qj4wwxsne --- .../website/static/src/js/website.editor.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index a5cf89b3a4e..3965e1c3d1a 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -383,7 +383,11 @@ }); }, upcast: function (el) { - return el.hasClass('fa'); + return el.hasClass('fa') + // ignore ir.ui.view (other data-oe-model should + // already have been matched by oeref and + // monetary? + && !el.attributes['data-oe-model']; } }); } @@ -645,6 +649,11 @@ previous = null; }, 'btn-sm'); + function is_icons_widget(element) { + var w = editor.widgets.getByElement(element); + return w && w.name === 'icons'; + } + // previous is the state of the button-trigger: it's the // currently-ish hovered element which can trigger a button showing. // -ish, because when moving to the button itself ``previous`` is @@ -654,9 +663,15 @@ // Back from edit button -> ignore if (previous && previous === this) { return; } + // hover button should appear for "editable" links and images + // (img and a nodes whose *attributes* are editable, they + // can not be "editing hosts") *or* for non-editing-host + // elements bearing an ``fa`` class. These should have been + // made into CKE widgets which are editing hosts by + // definition, so instead check if the element has been + // converted/upcasted to an fa widget var selected = new CKEDITOR.dom.element(this); - // FIXME: fa nodes may not be editable widgets (?) - if (!is_editable_node(selected) && !selected.hasClass('fa')) { + if (!(is_editable_node(selected) || is_icons_widget(selected))) { return; }