summaryrefslogtreecommitdiff
path: root/addons/website
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-12-04 16:24:24 +0100
committerChristophe Simonis <chs@odoo.com>2017-12-04 16:24:24 +0100
commit426e269c220073c77894d7ef2fa108f97eadf9b3 (patch)
treef7078f83ff6c54f4737633b4f1d45f84da98f265 /addons/website
parentbe64ba60694a2498e1f023d722775b299554cb85 (diff)
parent067a241ea8eee57a7a375a31ac99e67437539141 (diff)
[MERGE] forward port branch 10.0 up to 067a241ea8e
Diffstat (limited to 'addons/website')
-rw-r--r--addons/website/static/src/js/website.snippets.animation.js35
1 files changed, 27 insertions, 8 deletions
diff --git a/addons/website/static/src/js/website.snippets.animation.js b/addons/website/static/src/js/website.snippets.animation.js
index 1213b986472..bed19b0acde 100644
--- a/addons/website/static/src/js/website.snippets.animation.js
+++ b/addons/website/static/src/js/website.snippets.animation.js
@@ -415,16 +415,35 @@ animation.registry.media_video = animation.Class.extend({
start: function () {
// TODO: this code should be refactored to make more sense and be better
// integrated with Odoo (this refactoring should be done in master).
- this.$target.find('iframe').remove();
- if (!this.$target.has('.media_iframe_video_size').length) {
- var editor = '<div class="css_editable_mode_display">&nbsp;</div>';
- var size = '<div class="media_iframe_video_size">&nbsp;</div>';
- this.$target.html(editor+size);
+ var def = this._super.apply(this, arguments);
+ if (this.$target.children('iframe').length) {
+ // There already is an <iframe/>, do nothing
+ return def;
}
- // rebuilding the iframe, from https://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
- this.$target.html(this.$target.html()+'<iframe sandbox="allow-scripts allow-same-origin" src="'+_.escape(this.$target.data("oe-expression"))+'" frameborder="0" allowfullscreen="allowfullscreen"></iframe>');
- return this._super.apply(this, arguments);
+
+ // Bug fix / compatibility: empty the <div/> element as all information
+ // to rebuild the iframe should have been saved on the <div/> element
+ this.$target.empty();
+
+ // Add extra content for size / edition
+ this.$target.append(
+ '<div class="css_editable_mode_display">&nbsp;</div>' +
+ '<div class="media_iframe_video_size">&nbsp;</div>'
+ );
+
+ // Rebuild the iframe. Depending on version / compatibility / instance,
+ // the src is saved in the 'data-src' attribute or the
+ // 'data-oe-expression' one (the latter is used as a workaround in 10.0
+ // system but should obviously be reviewed in master).
+ this.$target.append($('<iframe/>', {
+ src: _.escape(this.$target.data('oe-expression') || this.$target.data('src')),
+ frameborder: '0',
+ allowfullscreen: 'allowfullscreen',
+ sandbox: 'allow-scripts allow-same-origin', // https://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
+ }));
+
+ return def;
},
});