{% from 'forms/_form.html' import form_fieldset, form_rows, simple_form %}

{% call simple_form(form, form_header_kwargs={'id': 'timetable-pdf-export-form', 'method': 'get'},
                    submit=_('Generate'), back=_('Cancel'), disabled_until_change=false) %}
    {{ form_rows(form, skip=form._pdf_options_fields) }}
{% endcall %}

<script>
    (function() {
        'use strict';

        var $form = $('#timetable-pdf-export-form');
        $form.find('[name=document_settings][value=showCoverPage], [name=document_settings][value=showTableContents], ' +
                   '[name=document_settings][value=showSessionTOC]').prop('checked', true);
        $form.find('[name=contribution_info][value=showContribId], [name=contribution_info][value=showSpeakerTitle]')
             .prop('checked', true);
        $form.find('[name=session_info][value=useSessionColorCodes], [name=session_info][value=showSessionDescription]')
             .prop('checked', true);
        $form.find('[name=visible_entries][value=showContribsAtConfLevel], ' +
                   '[name=visible_entries][value=showBreaksAtConfLevel]')
             .prop('checked', true);
        $form.find('[name=document_settings][value=showTableContents]').on('change', function() {
            var $showSessionToc = $form.find('[name=document_settings][value=showSessionTOC]');
            $showSessionToc.closest('.i-checkbox').toggle(this.checked);
            if (!this.checked) {
                $showSessionToc.prop('checked', false);
            }
        }).trigger('change');
        $form.find('[name=contribution_info][value=showAbstract]').on('change', function() {
            $form.find('[name=contribution_info][value=dontShowPosterAbstract]').closest('.i-checkbox').toggle(this.checked);
        }).trigger('change');
    })();
</script>
