MD Umbau
This commit is contained in:
32
kb-markdown-importer/assets/js/admin-settings.js
Normal file
32
kb-markdown-importer/assets/js/admin-settings.js
Normal file
@@ -0,0 +1,32 @@
|
||||
(function ($) {
|
||||
const button = $('#kb-markdown-upload-theme-css');
|
||||
const input = $('#custom_theme_css_url');
|
||||
|
||||
if (!button.length || !input.length || typeof wp === 'undefined' || !wp.media) {
|
||||
return;
|
||||
}
|
||||
|
||||
button.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
const frame = wp.media({
|
||||
title: 'Select theme.css',
|
||||
button: {
|
||||
text: 'Use this CSS file'
|
||||
},
|
||||
multiple: false,
|
||||
library: {
|
||||
type: ['text/css', 'text/plain']
|
||||
}
|
||||
});
|
||||
|
||||
frame.on('select', function () {
|
||||
const attachment = frame.state().get('selection').first().toJSON();
|
||||
if (attachment && attachment.url) {
|
||||
input.val(attachment.url);
|
||||
}
|
||||
});
|
||||
|
||||
frame.open();
|
||||
});
|
||||
}(jQuery));
|
||||
13
kb-markdown-importer/assets/js/frontend.js
Normal file
13
kb-markdown-importer/assets/js/frontend.js
Normal file
@@ -0,0 +1,13 @@
|
||||
(function () {
|
||||
const switcher = document.getElementById('kb-version-switcher');
|
||||
if (!switcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
switcher.addEventListener('change', function () {
|
||||
const selected = switcher.options[switcher.selectedIndex];
|
||||
if (selected && selected.dataset.url) {
|
||||
window.location.href = selected.dataset.url;
|
||||
}
|
||||
});
|
||||
}());
|
||||
Reference in New Issue
Block a user