mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-13 01:33:16 +00:00
Add a disableDirtyFormCheck function so we're not relying on sharing variables between scripts
This commit is contained in:
parent
cc7e6196c5
commit
4c96595d90
2 changed files with 8 additions and 8 deletions
|
|
@ -53,7 +53,7 @@ function initTagField(id, autocompleteUrl) {
|
|||
* prompting the user even when nothing has been changed.
|
||||
*/
|
||||
|
||||
var canDirtyFormCheck = true;
|
||||
var dirtyFormCheckIsActive = true;
|
||||
|
||||
function enableDirtyFormCheck(formSelector, options) {
|
||||
var $form = $(formSelector);
|
||||
|
|
@ -75,17 +75,17 @@ function enableDirtyFormCheck(formSelector, options) {
|
|||
}
|
||||
});
|
||||
|
||||
if (!canDirtyFormCheck) {
|
||||
triggeredByIgnoredButton = true;
|
||||
}
|
||||
|
||||
if (canDirtyFormCheck && !triggeredByIgnoredButton && (alwaysDirty || $form.serialize() != initialData)) {
|
||||
if (dirtyFormCheckIsActive && !triggeredByIgnoredButton && (alwaysDirty || $form.serialize() != initialData)) {
|
||||
event.returnValue = confirmationMessage;
|
||||
return confirmationMessage;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function disableDirtyFormCheck() {
|
||||
dirtyFormCheckIsActive = false;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// Add class to the body from which transitions may be hung so they don't appear to transition as the page loads
|
||||
$('body').addClass('ready');
|
||||
|
|
|
|||
|
|
@ -366,13 +366,13 @@ function initCollapsibleBlocks() {
|
|||
|
||||
function initKeyboardShortcuts() {
|
||||
Mousetrap.bind(['mod+p'], function(e) {
|
||||
canDirtyFormCheck = false;
|
||||
disableDirtyFormCheck();
|
||||
$('.action-preview').trigger('click');
|
||||
return false;
|
||||
});
|
||||
|
||||
Mousetrap.bind(['mod+s'], function(e) {
|
||||
canDirtyFormCheck = false;
|
||||
disableDirtyFormCheck();
|
||||
$('.action-save').trigger('click');
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue