{% include 'admin/cms/page/plugin/change_form.html' %}

{% comment %}
The following script disable controls options if Vimeo selected as hosting. Because Vimeo disallow hiding controls
{% endcomment %}

<script>
    const selectHostingElement = document.querySelector("#django-cms-qe-hosting-choices");
    selectHostingElement.addEventListener("change", hostingChanged);

    function hostingChanged() {
        const selectedIndex = selectHostingElement.selectedIndex;
        const selectedHosting = selectHostingElement.options[selectedIndex].innerHTML;
        console.log(selectedHosting);
        const controlsElement = document.querySelector("#django-cms-qe-vimeo-disabled");
        if (selectedHosting == 'Vimeo') {
            controlsElement.setAttribute("disabled", "");
            controlsElement.checked = true;
        }
        else
            controlsElement.removeAttribute("disabled");
    }
</script>
