forked from chaosarium/lwt
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
||
|
@@ -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. | ||
|
@@ -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); | ||
} | ||
}; | ||
|
||
|
@@ -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(); | ||
} |