Edit shared headers and footers as page types
This commit is contained in:
+12
-19
@@ -1,37 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
jQuery(function ($) {
|
||||
$('[data-layout-components]').on('click', '[data-component-move]', function () {
|
||||
const $item = $(this).closest('li');
|
||||
if (this.dataset.componentMove === '-1') $item.prevAll(':visible').first().before($item);
|
||||
else $item.nextAll(':visible').first().after($item);
|
||||
$(this).closest('[data-layout-components]').trigger('layout:order');
|
||||
$(this).trigger('focus');
|
||||
});
|
||||
$('[data-page-layout-editor]').each(function () {
|
||||
const {pageLayoutEditor: kind, defaultId} = this.dataset;
|
||||
const $link = $(this);
|
||||
$('#studio-page-settings').on('change', '[name="' + kind + '_id"]', function () {
|
||||
$link.attr('href', '/admin/design/' + kind + '/' + (this.value || defaultId || 'new?default=1'));
|
||||
$('#studio-page-settings').on('change', '[name="' + kind + '_choice"]', function () {
|
||||
const id = this.value || defaultId;
|
||||
$link.prop('hidden', this.value === 'hidden')
|
||||
.attr('href', id && this.value !== 'hidden' ? '/admin/pages/layout--' + kind + '-' + id : '/admin/new-page?type=' + kind);
|
||||
});
|
||||
});
|
||||
$('[data-new-page-type]').on('change', function () {
|
||||
const ordinary = this.value === 'page';
|
||||
$(this.form).find('[data-new-page-slug]').prop('hidden', !ordinary)
|
||||
.find('input').prop({required: ordinary, disabled: !ordinary});
|
||||
$('[data-open-page-templates]').prop('disabled', !ordinary);
|
||||
}).trigger('change');
|
||||
$('[data-provider-settings]').each(function () {
|
||||
const $settings = $(this);
|
||||
const $form = $settings.closest('form');
|
||||
const $preset = $form.find('[data-layout-preset]');
|
||||
const $account = $form.find('[name="components[]"][value=account]');
|
||||
const $mode = $settings.find('[name=provider_mode]');
|
||||
const sync = () => {
|
||||
$mode.on('change.layoutProvider', () => {
|
||||
const mode = $mode.val();
|
||||
const active = $preset.filter(':checked').val() === 'member' && $account.is(':checked');
|
||||
$settings.prop({hidden: !active, disabled: !active});
|
||||
$settings.find('[data-provider-field]').prop('hidden', !mode);
|
||||
$settings.find('[data-provider-mode]').each(function () {
|
||||
$(this).prop('hidden', this.dataset.providerMode !== mode);
|
||||
});
|
||||
};
|
||||
$preset.add($mode).add($account).on('change', sync);
|
||||
sync();
|
||||
}).triggerHandler('change.layoutProvider');
|
||||
});
|
||||
|
||||
$('[data-page-list]').each(function () {
|
||||
@@ -173,7 +167,6 @@ jQuery(function ($) {
|
||||
return;
|
||||
}
|
||||
finish();
|
||||
if (response?.field) $form.triggerHandler('studio:invalid', [response.field]);
|
||||
if (!designFieldError($form, response)) {
|
||||
formError($form, response?.message || '请求未完成,请稍后重试。', request.status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user