From 3f18d0490493cc9c5b7d419a917469d2a0b56335 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag <klapinklapin@gmail.com> Date: Mon, 9 May 2016 21:06:53 +0200 Subject: [PATCH] checkfunc() set textChanged only on real change - if #wiki__text (the default DokuWiki editor field) exists, the checkfunc() checks whether the field content is changed - if #wiki__text not exists it assumes that on all change and keydown events the content of the form #dw__editform is changed (give still false positives.) (for example the Data plugin has none #wiki__text) --- lib/scripts/edit.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 50de5a9b7..77378b060 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -213,6 +213,7 @@ function deleteDraft() { /** * Activate "not saved" dialog, add draft deletion to page unload, * add handlers to monitor changes + * Note: textChanged could be set by e.g. html_edit() as well * * Sets focus to the editbox as well */ @@ -234,19 +235,26 @@ jQuery(function () { sel.end = 0; DWsetSelection(sel); $edit_text.focus(); + + var edit_text_content = $edit_text.val(); } var checkfunc = function() { - textChanged = true; //global var + //global var textChanged + if ($edit_text.length > 0) { + textChanged = edit_text_content != $edit_text.val(); + } else { + textChanged = true; + } + summaryCheck(); }; $editform.change(checkfunc); $editform.keydown(checkfunc); - var edit_text_content = $edit_text.val(); window.onbeforeunload = function(){ - if(window.textChanged && edit_text_content != $edit_text.val()) { + if(window.textChanged) { return LANG.notsavedyet; } }; -- GitLab