Atualizar assets/admin-settings.js
This commit is contained in:
parent
34365c8a70
commit
25c01fa565
|
|
@ -1,12 +1,42 @@
|
||||||
(function ($) {
|
(function ($) {
|
||||||
|
const settings = window.flysystemOffloadSettings || {};
|
||||||
|
const s3Label = settings.labels ? settings.labels.s3 : 'Amazon S3 / Compatible';
|
||||||
|
|
||||||
|
function ensureS3Wrapper() {
|
||||||
|
const $heading = $('h2').filter(function () {
|
||||||
|
return $(this).text().trim() === s3Label;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($heading.length && !$heading.parent().hasClass('flysystem-offload-adapter-section')) {
|
||||||
|
const $table = $heading.next('table');
|
||||||
|
if ($table.length) {
|
||||||
|
const $wrapper = $('<div>', {
|
||||||
|
class: 'flysystem-offload-adapter-section',
|
||||||
|
'data-adapter': 's3'
|
||||||
|
});
|
||||||
|
|
||||||
|
$heading.add($table).wrapAll($wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleSections() {
|
function toggleSections() {
|
||||||
const adapter = $('#flysystem-offload-adapter').val();
|
const adapter = $('#flysystem-offload-adapter').val();
|
||||||
|
|
||||||
$('.flysystem-offload-adapter-section').hide();
|
$('.flysystem-offload-adapter-section').hide();
|
||||||
$(`.flysystem-offload-adapter-section[data-adapter="${adapter}"]`).show();
|
$('.flysystem-offload-field').closest('tr').hide();
|
||||||
|
|
||||||
|
if (adapter === 's3') {
|
||||||
|
$('.flysystem-offload-adapter-section[data-adapter="s3"]').show();
|
||||||
|
$('.flysystem-offload-field--s3').closest('tr').show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
ensureS3Wrapper();
|
||||||
toggleSections();
|
toggleSections();
|
||||||
$('#flysystem-offload-adapter').on('change', toggleSections);
|
$('#flysystem-offload-adapter').on('change', function () {
|
||||||
|
toggleSections();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue