Skip to content

Commit

Permalink
Missing function, fixes style.
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoFara committed Jan 3, 2024
1 parent 562b76a commit cf87044
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
6 changes: 3 additions & 3 deletions js/pgm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 40 additions & 40 deletions src/js/unloadformcheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author andreask7 <[email protected]>
* @since 1.6.16-fork
* @since 2.3.1-fork You should not only include this script to check before unload
* but also call ask_before_exiting once.
* but also call ask_before_exiting once.
* @since 2.10.0-fork This file was refactored in a single object, use it instead
*/

Expand All @@ -15,7 +15,7 @@
*
* @deprecated Since 2.10.0, use lwt_form_check instead
*/
var DIRTY = 0;
let DIRTY = 0;

/**
* Keeps track of a modified form.
Expand All @@ -25,63 +25,63 @@ const lwt_form_check = {
dirty: false,

/**
* Check the DIRTY status and ask before leaving.
*
* @returns {string} Confirmation string
*/
* Check the DIRTY status and ask before leaving.
*
* @returns {string} Confirmation string
*/
isDirtyMessage: function () {
if (lwt_form_check.dirty) {
return '** You have unsaved changes! **';
}
if (lwt_form_check.dirty) {
return '** You have unsaved changes! **';
}
},

/**
* Set the DIRTY variable to 1.
*/
* Set the DIRTY variable to 1.
*/
makeDirty: function () {
lwt_form_check.dirty = true;
},

/**
* Set the DIRTY variable to 0.
*/
* Set the DIRTY variable to 0.
*/
resetDirty: function () {
lwt_form_check.dirty = false;
},

/**
* Set DIRTY to 1 if tag object changed.
*
* @param {*} _ An event, unused
* @param {object} ui UI object
* @returns {true} Always return true
*/
* Set DIRTY to 1 if tag object changed.
*
* @param {*} _ An event, unused
* @param {object} ui UI object
* @returns {true} Always return true
*/
tagChanged: function (_, ui) {
if (!ui.duringInitialization) {
if (!ui.duringInitialization) {
lwt_form_check.dirty = true;
}
return true;
}
return true;
},

/**
* Call this function if you want to ask the user
* before exiting the form.
*
* @returns {undefined}
*/
* Call this function if you want to ask the user
* before exiting the form.
*
* @returns {undefined}
*/
askBeforeExit: function () {
$('#termtags').tagit({
afterTagAdded: lwt_form_check.tagChanged,
afterTagRemoved: lwt_form_check.tagChanged
});
$('#texttags').tagit({
afterTagAdded: lwt_form_check.tagChanged,
afterTagRemoved: lwt_form_check.tagChanged
});
$('input,checkbox,textarea,radio,select')
.not('#quickmenu').on('change', lwt_form_check.makeDirty);
$(':reset,:submit').on('click', lwt_form_check.resetDirty);
$(window).on('beforeunload', lwt_form_check.isDirtyMessage);
$('#termtags').tagit({
afterTagAdded: lwt_form_check.tagChanged,
afterTagRemoved: lwt_form_check.tagChanged
});
$('#texttags').tagit({
afterTagAdded: lwt_form_check.tagChanged,
afterTagRemoved: lwt_form_check.tagChanged
});
$('input,checkbox,textarea,radio,select')
.not('#quickmenu').on('change', lwt_form_check.makeDirty);
$(':reset,:submit').on('click', lwt_form_check.resetDirty);
$(window).on('beforeunload', lwt_form_check.isDirtyMessage);
}
};

Expand Down Expand Up @@ -131,5 +131,5 @@ function tagChanged (_, ui) {
* @deprecated Since 2.10.0, use return lwt_form_check.askBeforeExit instead
*/
function ask_before_exiting () {
return lwt_form_check.askBeforeExiting();
return lwt_form_check.askBeforeExit();
}

0 comments on commit cf87044

Please sign in to comment.