diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-12-06 11:59:38 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-12-06 11:59:38 +0100 |
| commit | f96a797fe6238306ec70d3db013b8a4d348ef181 (patch) | |
| tree | 40990f6ca69840a52421c4a52f68e439ba1a5b42 /addons/website/static/src/js | |
| parent | dc5755698cc41e0c5f51ab5dccee1356a0f23a3f (diff) | |
| parent | b8540eefe3b82fc4a54c8a808ce3bfa0bea8a29a (diff) | |
[MERGE] forward port branch saas-16 up to b8540eefe3b
Diffstat (limited to 'addons/website/static/src/js')
| -rw-r--r-- | addons/website/static/src/js/content/snippets.animation.js | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index e5115ec7b18..f4f49271b87 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -592,16 +592,35 @@ registry.mediaVideo = Animation.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_editableMode_display"> </div>'; - var size = '<div class="media_iframe_video_size"> </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"> </div>' + + '<div class="media_iframe_video_size"> </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; }, }); |
