summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/widgets.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-09-22 15:27:35 +0200
committerChristophe Simonis <chs@odoo.com>2016-09-22 15:27:35 +0200
commitf308b09a9ab3f3bf452fdd1ac6c2c86812732110 (patch)
tree9506e8e830ce1e6737c1f7c87b451f60bbb2cbff /addons/web_editor/static/src/js/widgets.js
parent30260bbb0ee683c67cf8ddd0358f40fbd2f5dd0f (diff)
parent856476d4418390ca89ef161e31faf61248eeaa1d (diff)
[MERGE] forward port branch saas-13 up to 856476d
Diffstat (limited to 'addons/web_editor/static/src/js/widgets.js')
-rw-r--r--addons/web_editor/static/src/js/widgets.js35
1 files changed, 19 insertions, 16 deletions
diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js
index a34571a3f54..00a693d40f2 100644
--- a/addons/web_editor/static/src/js/widgets.js
+++ b/addons/web_editor/static/src/js/widgets.js
@@ -200,21 +200,14 @@ var MediaDialog = Dialog.extend({
$(document.body).trigger("media-saved", [media, self.old_media]);
self.trigger("saved", [media, self.old_media]);
- setTimeout(function () {
- if (!media.parentNode) {
- return;
- }
+
+ // Update editor bar after image edition (in case the image change to icon or other)
+ _.defer(function () {
+ if (!media.parentNode) return;
range.createFromNode(media).select();
click_event(media, "mousedown");
- if (!this.only_images) {
- setTimeout(function () {
- if($(media).parent().data("oe-field") !== "image") {
- click_event(media, "click");
- }
- click_event(media, "mouseup");
- },0);
- }
- },0);
+ click_event(media, "mouseup");
+ });
this._super.apply(this, arguments);
},
@@ -774,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);
@@ -844,6 +839,10 @@ function createVideoNode(url) {
});
}
+ if (options.autoplay) {
+ $video.attr("src", $video.attr("src") + "?autoplay=1");
+ }
+
$video.attr('frameborder', 0);
return $video;
@@ -858,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',
@@ -876,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);
@@ -900,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;
@@ -1091,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);
},