[REF] web, *: improve behavior of jQuery extension 'prependEvent'
* web_editor Odoo extends jQuery to add some utility functions. The 'prependEvent' one add the possibility to add an event handler on an element (like the jQuery built-in 'on' function) but to be executed before the already binded ones. This function was however incomplete and did not allow to use jQuery namespaced events.
This commit is contained in:
+2
-1
@@ -110,7 +110,8 @@ $.fn.extend({
|
||||
events = events.split(' ');
|
||||
return this.each(function () {
|
||||
var el = this;
|
||||
_.each(events, function (evName) {
|
||||
_.each(events, function (evNameNamespaced) {
|
||||
var evName = evNameNamespaced.split('.')[0];
|
||||
var handler = $._data(el, 'events')[evName].pop();
|
||||
$._data(el, 'events')[evName].unshift(handler);
|
||||
});
|
||||
|
||||
@@ -207,7 +207,7 @@ var Translate = Widget.extend({
|
||||
var trans = self.getTranlationObject(this);
|
||||
trans.value = (trans.value ? trans.value : $node.html() ).replace(/[ \t\n\r]+/, ' ');
|
||||
});
|
||||
this.$target.parent().prependEvent('click', this, this.__unbind_click);
|
||||
this.$target.parent().prependEvent('click.translator', this, this.__unbind_click);
|
||||
|
||||
// attributes
|
||||
|
||||
@@ -221,14 +221,14 @@ var Translate = Widget.extend({
|
||||
});
|
||||
});
|
||||
|
||||
this.$target_attr.prependEvent('mousedown click mouseup', this, this.__translate_attribute);
|
||||
this.$target_attr.prependEvent('mousedown.translator click.translator mouseup.translator', this, this.__translate_attribute);
|
||||
|
||||
console.info('Click on CTRL when you click in an translatable area to have the default behavior');
|
||||
},
|
||||
unarkTranslatableNode: function () {
|
||||
this.$target.removeClass('o_editable').removeAttr('contentEditable');
|
||||
this.$target.parent().off('click', this.__unbind_click);
|
||||
this.$target_attr.off('mousedown click mouseup', this.__translate_attribute);
|
||||
this.$target.parent().off('.translator');
|
||||
this.$target_attr.off('.translator');
|
||||
},
|
||||
save_and_reload: function () {
|
||||
return this.save().then(function () {
|
||||
|
||||
Reference in New Issue
Block a user