
{% extends 'base.html.twig' %}

{% block localstyle %}
    #pageiframe { margin: 0px -30px;} 
{% endblock %}

{% if app.user %}
    {% set username = app.user.username %}
{% else %}
    {% set username = "" %}
{% endif %}

{% block pagewrapper %}
    {% if access=="config" %}
        <div class="pagemenu">
            <a href="{{ path('app_portal_config_page_view', {id:entity.id})}}">{{ entity.name }}</a>

            <a href='{{ path('app_portal_config_page_update', {id:entity.id}) }}' title='Modifier le card'><i class='fa fa-cog fa-fw'></i></a>
            <a href='{{ path('app_portal_config_page_delete', { id: entity.id }) }}' data-method='delete' data-confirm='Êtes-vous sûr de vouloir supprimer ?' title='Supprimer la page'><i class='fa fa-trash fa-fw'></i></a>
        </div>
    {% endif %}        

    <div id="pageiframe" style="{% if entity.maxwidth>0%} max-width:{{ entity.maxwidth }}px; margin:auto; {% endif %}">
        <iframe onload='this.contentWindow.focus()' src="{{entity.url|replace({'#login#': username})}}" id="frameContent" style="border:none;" width="100%" height="100%"></iframe>
    </div>
{% endblock %}


{% block localjavascript %}
    $(window).resize(function() {
        resizeFrame();
    });

    $('document').ready(function(){
        resizeFrame();
    });

    function resizeFrame() {
        $("body").css("overflow-y","hidden");
        $(".col-md-10").css("padding","0");

        var heightbody = $('html').height();
        var heightheader = $('.header').height();
        var heightmenu  = $('.pagemenu').height();
        
        var heightframe = heightbody-(heightheader?heightheader:0)-(heightmenu?heightmenu:0);

        if($("#frameContent").length>0) {
            $("#frameContent").height(heightframe);
        }
    }
{% endblock %}
