[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
This commit is contained in:
Xavier Morel 2014-03-12 15:19:10 +01:00
parent 44523f4679
commit 8ad325614d
1 changed files with 18 additions and 3 deletions

View File

@ -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;
}