<?xml version="1.0" encoding="UTF-8" ?>
<!--

    Copyright 2020 CreuBlanca
    License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

  -->
<templates xml:space="preserve">
    <t t-name="FieldBinaryPreview.Content" t-extend="DocumentViewer.Content">
        <!-- We need to replace in order to change all the called options,
            the new item will contain the same elements than the original one
        -->
        <t t-jquery=".o_viewer_zoomer" t-operation="replace">
            <div class="o_viewer_zoomer">
                <div
                    t-if="widget.activeAttachment.fileType == 'image'"
                    class="o_loading_img text-center"
                >
                    <i
                        class="fa fa-circle-o-notch fa-spin text-gray-light fa-3x fa-fw"
                        role="img"
                        aria-label="Loading"
                        title="Loading"
                    />
                </div>
                <img
                    t-if="widget.activeAttachment.fileType === 'image'"
                    class="o_viewer_img"
                    t-attf-src="/web/image/#{model}/#{widget.activeAttachment.id}/#{widget.fieldName}?unique=1&amp;signature=#{widget.activeAttachment.checksum}&amp;model=#{model}"
                    alt="Viewer"
                />
                <iframe
                    t-if="widget.activeAttachment.fileType == 'application/pdf'"
                    class="mt32 o_viewer_pdf"
                    t-attf-src="/web/static/lib/pdfjs/web/viewer.html?file=/web/content/#{model}/#{widget.activeAttachment.id}/#{widget.fieldName}"
                />
                <iframe
                    t-if="(widget.activeAttachment.fileType || '').indexOf('text') !== -1"
                    class="mt32 o_viewer_text"
                    t-attf-src="/web/content/#{model}/#{widget.activeAttachment.id}/#{widget.fieldName}"
                />
                <iframe
                    t-if="widget.activeAttachment.fileType == 'youtu'"
                    class="mt32 o_viewer_text"
                    allow="autoplay; encrypted-media"
                    width="560"
                    height="315"
                    t-attf-src="https://www.youtube.com/embed/#{widget.activeAttachment.youtube}"
                />
                <video
                    t-if="widget.activeAttachment.fileType == 'video'"
                    class="o_viewer_video"
                    controls="controls"
                >
                    <source
                        t-attf-src="/web/image/#{model}/#{widget.activeAttachment.id}/#{widget.fieldName}"
                        t-att-data-type="widget.activeAttachment.mimetype"
                    />
                </video>
            </div>
        </t>
    </t>
    <t t-name="FieldBinaryPreview" t-extend="DocumentViewer">
        <!-- We need to replace in order to change the called options-->
        <t t-jquery=".o_document_viewer_content_call" t-operation="replace">
            <t
                class="o_document_viewer_content_call"
                t-call="FieldBinaryPreview.Content"
            />
        </t>
    </t>
</templates>
