forked from laysense/laysense.cn
Migrate Laysense to unmodified LaySite 1.5.2
This commit is contained in:
+39
-12
@@ -28,20 +28,40 @@ jQuery(function ($) {
|
||||
$actionDialog.on('click', '[data-action-cancel]', () => $actionDialog.get(0).close());
|
||||
|
||||
$('[data-page-layout-editor]').each(function () {
|
||||
const {pageLayoutEditor: kind, defaultId} = this.dataset;
|
||||
const {pageLayoutEditor: kind, defaultSlug} = this.dataset;
|
||||
const $link = $(this);
|
||||
$('#studio-page-settings').on('change', '[name="' + kind + '_choice"]', function () {
|
||||
const id = this.value || defaultId;
|
||||
const slug = this.value ? this.selectedOptions[0]?.dataset.layoutSlug : defaultSlug;
|
||||
$link.prop('hidden', this.value === 'hidden')
|
||||
.attr('href', id && this.value !== 'hidden' ? '/admin/pages/layout--' + kind + '-' + id : '/admin/new-page?type=' + kind);
|
||||
.attr('href', slug ? '/admin/pages/' + slug : '/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-palette-picker]').each(function () {
|
||||
const $picker = $(this);
|
||||
const $select = $picker.find('select');
|
||||
const $details = $picker.find('details');
|
||||
const $options = $picker.find('[data-palette-option]');
|
||||
function updatePalette() {
|
||||
const $selected = $options.filter((_, option) => option.dataset.paletteOption === $select.val());
|
||||
$options.attr('aria-pressed', 'false');
|
||||
$selected.attr('aria-pressed', 'true');
|
||||
$picker.find('[data-palette-current]').empty().append($selected.children().clone());
|
||||
}
|
||||
$select.on('change.palettePicker', updatePalette).prop('hidden', true);
|
||||
$details.prop('hidden', false).on('click', '[data-palette-option]', function () {
|
||||
$select.val(this.dataset.paletteOption).trigger('change');
|
||||
$details.prop('open', false).find('summary').trigger('focus');
|
||||
}).on('keydown', (event) => {
|
||||
if (event.key === 'Escape' && $details.prop('open')) {
|
||||
event.stopPropagation();
|
||||
$details.prop('open', false).find('summary').trigger('focus');
|
||||
}
|
||||
});
|
||||
$(document).on('click', (event) => {
|
||||
if (!$picker.get(0).contains(event.target)) $details.prop('open', false);
|
||||
});
|
||||
updatePalette();
|
||||
});
|
||||
$('[data-provider-settings]').each(function () {
|
||||
const $settings = $(this);
|
||||
const $mode = $settings.find('[name=provider_mode]');
|
||||
@@ -65,7 +85,8 @@ jQuery(function ($) {
|
||||
const status = $status.val();
|
||||
let count = 0;
|
||||
$pages.each(function () {
|
||||
const visible = (!status || this.dataset.pageItem === status) && this.dataset.pageLabel.toLowerCase().includes(query);
|
||||
const visible = (!status || this.dataset.pageItem === status || this.dataset.pagePublicStatus === status)
|
||||
&& this.dataset.pageLabel.toLowerCase().includes(query);
|
||||
$(this).prop('hidden', !visible);
|
||||
if (visible) count++;
|
||||
});
|
||||
@@ -89,7 +110,7 @@ jQuery(function ($) {
|
||||
};
|
||||
|
||||
function clearSavedStatus() {
|
||||
$('[data-save-confirmation]').prop('hidden', true);
|
||||
$('[data-save-confirmation], [data-page-save-feedback]').prop('hidden', true);
|
||||
}
|
||||
|
||||
if (document.querySelector('[data-save-confirmation]')) {
|
||||
@@ -181,8 +202,14 @@ jQuery(function ($) {
|
||||
contentType: multipart ? false : 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
if ($form.is('[data-save-inline]') && response.saved === true && !response.redirect) {
|
||||
$form.triggerHandler('studio:saved', [response, submitter]);
|
||||
finish();
|
||||
if (document.activeElement === document.body) submitter?.focus({preventScroll: true});
|
||||
return;
|
||||
}
|
||||
if (response.redirect) {
|
||||
$form.triggerHandler('studio:saved');
|
||||
$form.triggerHandler('studio:saved', [response, submitter]);
|
||||
window.location.assign(response.redirect);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user