Skip to content

Commit

Permalink
[FIX] website_slides: load viewer for app's iframes only
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
qsm-odoo committed Mar 2, 2018
1 parent b882491 commit 80f97fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion addons/website_slides/models/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def _get_embed_code(self):
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
Expand Down
7 changes: 4 additions & 3 deletions addons/website_slides/static/src/js/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});


Expand Down

0 comments on commit 80f97fb

Please sign in to comment.