38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
jQuery(document).ready(function ($) {
|
|
const $modalsRoot = $('.modals');
|
|
|
|
const showModal = function (modalClass) {
|
|
$modalsRoot.removeClass('hidden').find('form').trigger('reset');
|
|
$modalsRoot.find('.modal').addClass('hidden');
|
|
$modalsRoot.find('.modal.' + modalClass).removeClass('hidden');
|
|
};
|
|
|
|
const hideModal = function () {
|
|
$modalsRoot.addClass('hidden').find('form').trigger('reset');
|
|
};
|
|
|
|
const main = function () {
|
|
|
|
};
|
|
|
|
$(document).on('click', '.modal-close', function () {
|
|
hideModal();
|
|
});
|
|
|
|
$(document).on('click', '.variable-edit', function () {
|
|
const variable = JSON.parse($(this).parents('tr:eq(0)').attr('data-entity'));
|
|
showModal('modal-variable-edit');
|
|
$('.modal-variable-edit input:visible:eq(0)').focus().select();
|
|
$('#variable-edit-name').val(variable.name);
|
|
$('#variable-edit-value').val(variable.value);
|
|
$('#variable-edit-id').val(variable.id);
|
|
});
|
|
|
|
$(document).keyup(function (e) {
|
|
if (e.key === "Escape") {
|
|
hideModal();
|
|
}
|
|
});
|
|
|
|
main();
|
|
}); |