From c4784fc75b60c6ce43cb89a03b631fc87ff674e1 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 20 Sep 2016 13:40:53 +0200 Subject: [FIX] web_editor: activate autoplay feature for videos The checkbox was there to activate autoplay... but was not doing anything since the web_editor/website split. --- addons/web_editor/static/src/js/widgets.js | 12 ++++++++++-- addons/web_editor/static/src/xml/editor.xml | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index 71a2f529263..3b08f8b89e2 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -784,7 +784,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); @@ -842,6 +844,10 @@ function createVideoNode(url) { .attr('src', url); } + if (options.autoplay) { + $video.attr("src", $video.attr("src") + "?autoplay=1"); + } + $video.attr('frameborder', 0); return $video; @@ -856,6 +862,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', @@ -874,6 +881,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(); @@ -898,7 +906,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; diff --git a/addons/web_editor/static/src/xml/editor.xml b/addons/web_editor/static/src/xml/editor.xml index 44abb32caf1..db805b04a33 100644 --- a/addons/web_editor/static/src/xml/editor.xml +++ b/addons/web_editor/static/src/xml/editor.xml @@ -269,7 +269,7 @@
- +
-- cgit v1.2.3 From ab06013e30d2a8ca561874c6141b2a52dc1843b1 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 20 Sep 2016 17:21:44 +0200 Subject: [FIX] mass_mailing: can't change color button snippet when edit mass mailing --- addons/web_editor/static/src/js/widgets.js | 4 +++- addons/web_editor/static/src/less/web_editor.ui.less | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index dcb5f58f5b8..792a9b51b95 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -1087,7 +1087,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/less/web_editor.ui.less b/addons/web_editor/static/src/less/web_editor.ui.less index 38bd5b7cd87..b464da9f70f 100644 --- a/addons/web_editor/static/src/less/web_editor.ui.less +++ b/addons/web_editor/static/src/less/web_editor.ui.less @@ -949,7 +949,7 @@ body.editor_enable { p { margin: initial; } - a, a:hover { + a:not(.btn), a:not(.btn):hover { color: inherit; } } -- cgit v1.2.3 From 9ea6861d7ee8eb9701818b22417572f694a3451c Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 21 Sep 2016 14:45:26 +0200 Subject: [FIX] web_editor: allow editing t-field links There is a hackish feature in the web_editor which forces the contenteditable to true on links which are clicked and removes it anywhere else in the page so that only the link is editable after click. This allows to add text at the end of a link without adding it outside of the link by mistake. The feature was badly implemented because, if the link was editable without having any parent which is editable, the contenteditable was forced to true, then immediatly forced to false when forcing to false every page element. This was the case for lots of t-field. By example the product categories in eCommerce are t-field links which are in non editable
  • elements... --- addons/web_editor/static/src/js/rte.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index 6df552a5ebd..17de4698939 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -516,7 +516,7 @@ var RTE = Widget.extend({ // add contenteditable on link to improve its editing behaviour $target.attr('contenteditable', true); setTimeout(function () { - $editable.attr('contenteditable', false); + $editable.not($target).attr('contenteditable', false); }); // once clicked outside, remove contenteditable on link var reactive_editable = function(e){ -- cgit v1.2.3 From 5a0a29b5285ea8f18716f936d58960b9b5c0f0d9 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 22 Sep 2016 13:44:06 +0200 Subject: [FIX] web_editor: prevent crash when deleting multiple snippets in one deletion Since saas-12, when deleting contents, parents are deleted too if they become empty (while it was not possible to delete contents in that case before). The problem here was that the history was recorded multiple times if one deletion made multiple snippets be deleted and this sometimes could crash. Now the history is recorded only on first deletion when the user ask for it. --- addons/web_editor/static/src/js/snippets.editor.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index 5a67b11707d..6cf2a9d33fd 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -1045,10 +1045,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) { @@ -1081,7 +1083,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(); }); } } -- cgit v1.2.3