| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <div class="modal create-template" id="create-template">
- <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">×</button>
- <div class="modal-title">{{ t('template.modal_label.Create/Edit Template Page') }}</div>
- </div>
- <div class="modal-body">
- <div class="form-group">
- <label class="mb-4">{{ t('template.modal_label.Create template under', page.path ) }}</label>
- <div class="row">
- <div class="col-sm-6">
- <div class="panel panel-default panel-select-template">
- <div class="panel-heading">{{ t('template.children.label') }}</div>
- <div class="panel-body">
- <p class="text-center"><code>_template</code></p>
- <p class="help-block text-center"><small>{{ t('template.children.desc') }}</small></p>
- </div>
- <div class="panel-footer text-center">
- <a href="{% if page.path.endsWith('/') %}{{ page.path }}{% else %}{{ page.path}}/{% endif %}_template#edit-form"
- class="btn btn-sm btn-primary" id="template-button-children">
- 作成/編集
- </a>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="panel panel-default panel-select-template">
- <div class="panel-heading">{{ t('template.decendants.label') }}</div>
- <div class="panel-body">
- <p class="text-center"><code>__template</code></p>
- <p class="help-block text-center"><small>{{ t('template.decendants.desc') }}</small></p>
- </div>
- <div class="panel-footer text-center">
- <a href="{% if page.path.endsWith('/') %}{{ page.path }}{% else %}{{ page.path }}/{% endif %}__template#edit-form"
- class="btn btn-sm btn-primary" id="template-button-decendants">
- 作成/編集
- </a>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
- </div><!-- /.modal -->
- <script>
- let pagePath = $('#link-to-template').attr('href');
- if (pagePath.endsWith('/')) {
- pagePath = pagePath.slice(0, -1);
- };
- $.get('/_api/pages.templates?path=' + pagePath) // don't use template literal(`...${}`) for IE11
- .then(function(templateInfo) { // don't use arrow function for IE11
- const buttonTextChildren = templateInfo.childrenTemplateExists ? '{{ t("Edit") }}' : '{{ t("Create") }}';
- const buttonTextDecendants = templateInfo.decendantsTemplateExists ? '{{ t("Edit") }}' : '{{ t("Create") }}';
- $('#template-button-children').text(buttonTextChildren);
- $('#template-button-decendants').text(buttonTextDecendants);
- $('#template-type').on('change', function() {
- // enable button
- $('#link-to-template').removeClass('disabled');
- if ($('#template-type').val() === 'children') {
- href = pagePath + '/_template#edit-form';
- $('#link-to-template').attr('href', href);
- $('#create-template-button-link').text(buttonTextChildren);
- }
- else if ($('#template-type').val() === 'decentants') {
- href = pagePath + '/__template#edit-form';
- $('#link-to-template').attr("href", href);
- $('#create-template-button-link').text(buttonTextDecendants);
- };
- });
- });
- </script>
|