[FIX] website_slides: load viewer for app's iframes only

The website_slides JS was working on all iframe in all pages while it
should only affect its own ones, which contains a PDF document.
This commit is contained in:
qsm-odoo
2018-03-02 18:13:22 +01:00
parent b8824913a7
commit 80f97fbd19
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -322,7 +322,7 @@ class Slide(models.Model):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
for record in self:
if record.datas and (not record.document_id or record.slide_type in ['document', 'presentation']):
record.embed_code = '<iframe src="%s/slides/embed/%s?page=1" allowFullScreen="true" height="%s" width="%s" frameborder="0"></iframe>' % (base_url, record.id, 315, 420)
record.embed_code = '<iframe src="%s/slides/embed/%s?page=1" class="o_wslides_iframe_viewer" allowFullScreen="true" height="%s" width="%s" frameborder="0"></iframe>' % (base_url, record.id, 315, 420)
elif record.slide_type == 'video' and record.document_id:
if not record.mime_type:
# embed youtube video
@@ -108,11 +108,12 @@ $(document).ready(function () {
},
});
$('iframe').ready(function() {
$('iframe.o_wslides_iframe_viewer').ready(function() {
// TODO : make it work. For now, once the iframe is loaded, the value of #page_count is
// still now set (the pdf is still loading)
var max_page = $('iframe').contents().find('#page_count').val();
new SlideSocialEmbed($(this), max_page).setElement($('.oe_slide_js_embed_code_widget'));
var $iframe = $(this);
var max_page = $iframe.contents().find('#page_count').val();
new SlideSocialEmbed($iframe, max_page).setElement($('.oe_slide_js_embed_code_widget'));
});