<div class="modal create-page" id="create-page">
  <div class="modal-dialog">
    <div class="modal-content">

      <div class="modal-header bg-primary">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <div class="modal-title">{{ t('New Page') }}</div>
      </div>

      <div class="modal-body">

        <form class="row form-horizontal" id="create-page-today" role="form">
          <fieldset class="col-xs-12">
            <legend>{{ t("Create today's") }}</legend>
            <div class="d-flex create-page-input-container">
              <div class="create-page-input-row d-flex align-items-center">
                <span class="page-today-prefix">{{ userPageRoot(user) }}/</span>
                <input type="text" data-prefix="{{ userPageRoot(user) }}/" class="page-today-input1 form-control text-center" value="{{ t('Memo') }}" id="" name="">
                <span class="page-today-suffix">/{{ now|datetz('Y/m/d') }}/</span>
                <input type="text" data-prefix="/{{ now|datetz('Y/m/d') }}/" class="page-today-input2 form-control" id="page-today-input2" name="" placeholder="{{ t('Input page name (optional)') }}">
              </div>
              <div class="create-page-button-container">
                <button type="submit" class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b"><i class="icon-fw icon-doc"></i>{{ t('Create') }}</button>
              </div>
            </div>
          </fieldset>
        </form>

        <form class="row form-horizontal m-t-15" id="create-page-under-tree" role="form">
          <fieldset class="col-xs-12">
            <legend>{{ t('Create under') }}</legend>
            <div class="d-flex create-page-input-container">
              <div class="create-page-input-row d-flex align-items-center">
                {% if searchConfigured() %}
                <div id="page-name-input"></div>
                {% else %}
                <input type="text" value="{{ parentPath(path) }}" class="page-name-input form-control " placeholder="{{ t('Input page name') }}" required />
                {% endif %}
              </div>
              <div class="create-page-button-container">
                <button type="submit" class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b"><i class="icon-fw icon-doc"></i>{{ t('Create') }}</button>
              </div>
            </div>
          </fieldset>
        </form>

        <div id="template-form" class="row form-horizontal m-t-15">
          <fieldset class="col-xs-12">
            <legend>{{ t('template.modal_label.Create template under', parentPath(path | preventXss | escape)) }}</legend>
            <div class="d-flex create-page-input-container">
              <div class="create-page-input-row d-flex align-items-center">
                <select id="template-type" class="form-control selectpicker" title="{{ t('template.option_label.select') }}">
                  <option value="children" data-subtext="- {{ t('template.children.desc') }}">{{ t('template.children.label') }}(_template)</option>
                  <option value="decentants" data-subtext="- {{ t('template.decendants.desc') }}">{{ t('template.decendants.label') }}(__template)</option>
                </select>
              </div>
              <div class="create-page-button-container">
                <a id="link-to-template" href="{{ page.path || path }}" class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b disabled">
                  <i class="icon-fw icon-doc"></i>
                  <span id="create-template-button-link">{{ t('Edit') }}</span>
                </a>
              </div>
            </div>
          </fieldset>
        </div>

        <script>
          $('#template-type').on('change', function() {
            // enable button
            $('#link-to-template').removeClass('disabled');

            // modify href
            const value = $(this).val();
            const pageName = (value === 'children') ? '_template' : '__template';
            const link = '{{ page.path || path }}/' + pageName + '#edit-form';
            $('#link-to-template').attr('href', link);
          });
        </script>

      </div><!-- /.modal-body -->

    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
