summaryrefslogtreecommitdiff
path: root/addons/web_editor
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-09-20 13:40:53 +0200
committerqsm-odoo <qsm@odoo.com>2016-09-20 13:40:53 +0200
commitc4784fc75b60c6ce43cb89a03b631fc87ff674e1 (patch)
tree78552e1829066adacfe3917a5d9b497622626ffb /addons/web_editor
parentf978d85f058db4919afca912d4a0e426d7a48ea1 (diff)
[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.
Diffstat (limited to 'addons/web_editor')
-rw-r--r--addons/web_editor/static/src/js/widgets.js12
-rw-r--r--addons/web_editor/static/src/xml/editor.xml2
2 files changed, 11 insertions, 3 deletions
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 @@
<div class="text-center mt32">
<div class="checkbox">
- <label><input type="checkbox" id="autoplay"/> Autoplay</label>
+ <label title="The feature might not be supported for every video type"><input type="checkbox" id="autoplay"/> Autoplay</label>
</div>
</div>
</form>