diff options
Diffstat (limited to 'addons/web_editor')
| -rw-r--r-- | addons/web_editor/static/lib/summernote/src/js/module/Editor.js | 4 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/rte.js | 2 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 10 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/widgets.js | 16 | ||||
| -rw-r--r-- | addons/web_editor/static/src/xml/editor.xml | 2 |
5 files changed, 23 insertions, 11 deletions
diff --git a/addons/web_editor/static/lib/summernote/src/js/module/Editor.js b/addons/web_editor/static/lib/summernote/src/js/module/Editor.js index a30ee9c18c8..b7ba30bfcd1 100644 --- a/addons/web_editor/static/lib/summernote/src/js/module/Editor.js +++ b/addons/web_editor/static/lib/summernote/src/js/module/Editor.js @@ -616,7 +616,6 @@ define([ var linkUrl = linkInfo.url; var linkText = linkInfo.text; var isNewWindow = linkInfo.isNewWindow; - var className = linkInfo.className || null; // ODOO: addition var rng = linkInfo.range || this.createRange($editable); var isTextChanged = rng.toString() !== linkText; @@ -647,7 +646,8 @@ define([ $.each(anchors, function (idx, anchor) { $(anchor).attr('href', linkUrl); - $(anchor).attr('class', className); // ODOO: addition + $(anchor).attr('class', linkInfo.className || null); // ODOO: addition + $(anchor).css(linkInfo.style || {}); // ODOO: addition if (isNewWindow) { $(anchor).attr('target', '_blank'); } else { diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index 1ed12eb4a73..b0366583aea 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -509,7 +509,7 @@ var RTE = Widget.extend({ */ $target.attr('contenteditable', true); _.defer(function () { - $editable.attr('contenteditable', false); + $editable.not($target).attr('contenteditable', false); $target.focus(); }); diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index f20b693c458..dcfabb6feb4 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -1001,10 +1001,12 @@ data.Editor = Class.extend({ }, on_remove: function (event) { - event.preventDefault(); - this.on_blur(); + if (event !== undefined) { + event.preventDefault(); + this.buildingBlock.getParent().rte.historyRecordUndo(this.$target); + } - this.buildingBlock.getParent().rte.historyRecordUndo(this.$target); + this.on_blur(); var index = _.indexOf(this.buildingBlock.snippets, this.$target.get(0)); this.buildingBlock.call_for_all_snippets(this.$target, function (editor, $snippet) { @@ -1037,7 +1039,7 @@ data.Editor = Class.extend({ } if ($parent.children().length === 0 && $parent.text().trim() === "") { _.defer(function () { - $parent.data("snippet-editor").on_remove(event); + $parent.data("snippet-editor").on_remove(); }); } } diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index 985a0783ef6..00a693d40f2 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -767,7 +767,9 @@ var fontIconsDialog = Widget.extend({ }); -function createVideoNode(url) { +function createVideoNode(url, options) { + options = options || {}; + // video url patterns(youtube, instagram, vimeo, dailymotion, youku) var ytRegExp = /^(?:(?:https?:)?\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/; var ytMatch = url.match(ytRegExp); @@ -837,6 +839,10 @@ function createVideoNode(url) { }); } + if (options.autoplay) { + $video.attr("src", $video.attr("src") + "?autoplay=1"); + } + $video.attr('frameborder', 0); return $video; @@ -851,6 +857,7 @@ var VideoDialog = Widget.extend({ events : _.extend({}, Dialog.prototype.events, { 'click input#urlvideo ~ button': 'get_video', 'click input#embedvideo ~ button': 'get_embed_video', + 'change input#autoplay': 'get_video', 'change input#urlvideo': 'change_input', 'keyup input#urlvideo': 'change_input', 'change input#embedvideo': 'change_input', @@ -869,6 +876,7 @@ var VideoDialog = Widget.extend({ if ($media.hasClass("media_iframe_video")) { var src = $media.data('src'); this.$("input#urlvideo").val(src); + this.$("input#autoplay").prop("checked", (src || "").indexOf("autoplay") >= 0); this.get_video(); } return this._super.apply(this, arguments); @@ -893,7 +901,7 @@ var VideoDialog = Widget.extend({ }, get_video: function (event) { if (event) event.preventDefault(); - var $video = createVideoNode(this.$("input#urlvideo").val()); + var $video = createVideoNode(this.$("input#urlvideo").val(), {autoplay: this.$("input#autoplay").is(":checked")}); this.$iframe.replaceWith($video); this.$iframe = $video; return false; @@ -1084,7 +1092,9 @@ var LinkDialog = Dialog.extend({ self.data.isNewWindow = new_window; self.data.text = label; self.data.className = classes.replace(/\s+/gi, ' ').replace(/^\s+|\s+$/gi, ''); - + if (classes.replace(/(^|[ ])(btn-default|btn-success|btn-primary|btn-info|btn-warning|btn-danger)([ ]|$)/gi, ' ')) { + self.data.style = {'background-color': '', 'color': ''}; + } self.trigger("save", self.data); }).then(_super); }, diff --git a/addons/web_editor/static/src/xml/editor.xml b/addons/web_editor/static/src/xml/editor.xml index 138c84da6f0..27213d7fdd8 100644 --- a/addons/web_editor/static/src/xml/editor.xml +++ b/addons/web_editor/static/src/xml/editor.xml @@ -210,7 +210,7 @@ </div> <div class="text-center mt32"> <div class="checkbox"> - <label> + <label title="The feature might not be supported for every video type"> <input id="autoplay" type="checkbox"/>Autoplay</label> </div> </div> |
