webseite-grav/plugins/admin/themes/grav/app/forms/fields/folder.js

21 lines
545 B
JavaScript
Raw Permalink Normal View History

2021-04-30 11:23:26 +02:00
import $ from 'jquery';
const Regenerate = (field = '[name="data[folder]"]') => {
const element = $(field);
const title = $('[name="data[header][title]"]');
const slug = $.slugify(title.val(), {custom: {"'": ''}});
element.addClass('highlight').val(slug);
setTimeout(() => element.removeClass('highlight'), 500);
};
$(document).on('click', '[data-regenerate]', (event) => {
const target = $(event.currentTarget);
const field = $(target.data('regenerate'));
Regenerate(field);
});
export default Regenerate;