mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
Fixes #2053 Move script and add a user interaction
Now, to let the selectize plugin initialize, at onChange we check whether one of the inputs has been focused
This commit is contained in:
@@ -32,6 +32,26 @@ $(document).ready(function () {
|
||||
$(".related-categories-container .breadcrumb-item .remove-item").on("click", function () {
|
||||
remove_related_category($(this).attr("id"));
|
||||
})
|
||||
// Unsaved settings message before leave this page
|
||||
let form_unsaved = false;
|
||||
let user_interacted = false;
|
||||
$('#pictureModify').find(':input').on('focus', function () {
|
||||
user_interacted = true;
|
||||
});
|
||||
$('#pictureModify').find(':input').on('change', function () {
|
||||
if (user_interacted) {
|
||||
form_unsaved = true;
|
||||
console.log($(this)[0].name, $(this));
|
||||
}
|
||||
});
|
||||
$(window).on('beforeunload', function () {
|
||||
if (form_unsaved) {
|
||||
return 'Somes changes are not registered';
|
||||
}
|
||||
});
|
||||
$('#pictureModify').on('submit', function () {
|
||||
form_unsaved = false;
|
||||
});
|
||||
})
|
||||
|
||||
function fill_results(cats) {
|
||||
|
||||
@@ -90,23 +90,6 @@ $('#action-delete-picture').on('click', function() {
|
||||
{/literal}
|
||||
|
||||
}());
|
||||
{literal}
|
||||
// Unsaved settings message before leave this page
|
||||
$(document).ready(function() {
|
||||
let form_unsaved = false;
|
||||
$('#pictureModify').find(':input').on('change', function() {
|
||||
form_unsaved = true;
|
||||
});
|
||||
$(window).on('beforeunload', function() {
|
||||
if (form_unsaved) {
|
||||
return 'Somes changes are not registered';
|
||||
}
|
||||
});
|
||||
$('#pictureModify').on('submit', function() {
|
||||
form_unsaved = false;
|
||||
});
|
||||
});
|
||||
{/literal}
|
||||
{/footer_script}
|
||||
|
||||
{combine_script id='picture_modify' load='footer' path='admin/themes/default/js/picture_modify.js'}
|
||||
|
||||
Reference in New Issue
Block a user