summaryrefslogtreecommitdiff
path: root/addons/website/static/lib/summernote/src/js/EventHandler.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2014-12-17 10:38:29 +0100
committerChristophe Matthieu <chm@odoo.com>2015-01-05 10:59:42 +0100
commit12bbcda4c26b350680ba25c49a47e861386f72ea (patch)
treebaf24bb261abd594852ac1829e406fd517049e20 /addons/website/static/lib/summernote/src/js/EventHandler.js
parent9069d0127c176317436b67b23ae5677dd9d53de7 (diff)
[IMP] summernote lib: check if a plugin add a method before the summernote methods because the plugins may be want to overwrite a default comportment. Key and click call plugins with more arguments (to allow the change and use of the lib) and the same arguments (some plugins can use button and key command for the same method)
https://github.com/summernote/summernote/pull/809
Diffstat (limited to 'addons/website/static/lib/summernote/src/js/EventHandler.js')
-rw-r--r--addons/website/static/lib/summernote/src/js/EventHandler.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/addons/website/static/lib/summernote/src/js/EventHandler.js b/addons/website/static/lib/summernote/src/js/EventHandler.js
index 2dba3357d06..97409ac385f 100644
--- a/addons/website/static/lib/summernote/src/js/EventHandler.js
+++ b/addons/website/static/lib/summernote/src/js/EventHandler.js
@@ -369,8 +369,6 @@ define([
var layoutInfo = makeLayoutInfo(event.target);
- event.preventDefault();
-
// before command: detect control selection element($target)
var $target;
if ($.inArray(eventName, ['resize', 'floatMe', 'removeMedia', 'imageShape']) !== -1) {
@@ -384,14 +382,16 @@ define([
$btn.parents('.popover').hide();
}
- if (editor[eventName]) { // on command
+ if ($.isFunction($.summernote.pluginEvents[eventName])) {
+ $.summernote.pluginEvents[eventName](event, editor, layoutInfo, value);
+ } else if (editor[eventName]) { // on command
var $editable = layoutInfo.editable();
$editable.trigger('focus');
editor[eventName]($editable, value, $target);
+ event.preventDefault();
} else if (commands[eventName]) {
commands[eventName].call(this, layoutInfo);
- } else if ($.isFunction($.summernote.pluginEvents[eventName])) {
- $.summernote.pluginEvents[eventName](layoutInfo, value, $target);
+ event.preventDefault();
}
// after command
@@ -585,17 +585,17 @@ define([
eventName = 'visible';
}
if (eventName) {
- event.preventDefault();
-
- if (editor[eventName]) {
+ if ($.summernote.pluginEvents[eventName]) {
+ var plugin = $.summernote.pluginEvents[eventName];
+ if ($.isFunction(plugin)) {
+ plugin(event, editor, layoutInfo);
+ }
+ } else if (editor[eventName]) {
editor[eventName]($editable, $editor.data('options'));
+ event.preventDefault();
} else if (commands[eventName]) {
commands[eventName].call(this, layoutInfo);
- } else if ($.summernote.plugins[eventName]) {
- var plugin = $.summernote.plugins[eventName];
- if ($.isFunction(plugin.event)) {
- plugin.event(event, editor, layoutInfo);
- }
+ event.preventDefault();
}
} else if (key.isEdit(event.keyCode)) {
editor.afterCommand($editable);