mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-13 01:33:16 +00:00
Fix keyboard shortcuts such as Ctrl+S giving unnecessary warning
This commit is contained in:
parent
15e5225d4b
commit
cc7e6196c5
2 changed files with 10 additions and 1 deletions
|
|
@ -52,6 +52,9 @@ function initTagField(id, autocompleteUrl) {
|
|||
* - alwaysDirty - When set to true the form will always be considered dirty,
|
||||
* prompting the user even when nothing has been changed.
|
||||
*/
|
||||
|
||||
var canDirtyFormCheck = true;
|
||||
|
||||
function enableDirtyFormCheck(formSelector, options) {
|
||||
var $form = $(formSelector);
|
||||
var $ignoredButtons = $form.find(
|
||||
|
|
@ -72,7 +75,11 @@ function enableDirtyFormCheck(formSelector, options) {
|
|||
}
|
||||
});
|
||||
|
||||
if (!triggeredByIgnoredButton && (alwaysDirty || $form.serialize() != initialData)) {
|
||||
if (!canDirtyFormCheck) {
|
||||
triggeredByIgnoredButton = true;
|
||||
}
|
||||
|
||||
if (canDirtyFormCheck && !triggeredByIgnoredButton && (alwaysDirty || $form.serialize() != initialData)) {
|
||||
event.returnValue = confirmationMessage;
|
||||
return confirmationMessage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,11 +366,13 @@ function initCollapsibleBlocks() {
|
|||
|
||||
function initKeyboardShortcuts() {
|
||||
Mousetrap.bind(['mod+p'], function(e) {
|
||||
canDirtyFormCheck = false;
|
||||
$('.action-preview').trigger('click');
|
||||
return false;
|
||||
});
|
||||
|
||||
Mousetrap.bind(['mod+s'], function(e) {
|
||||
canDirtyFormCheck = false;
|
||||
$('.action-save').trigger('click');
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue