diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2016-05-19 00:17:12 +0200 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2016-05-19 00:17:12 +0200 |
commit | 5462edca1f7eb2ece8ce280b3cb15cb33d24c0d9 (patch) | |
tree | 3bb904231381932a9b8449d8230bdfe4cbcffc9c /lib | |
parent | 3f18d0490493cc9c5b7d419a917469d2a0b56335 (diff) | |
download | dokuwiki-5462edca1f7eb2ece8ce280b3cb15cb33d24c0d9.tar.gz dokuwiki-5462edca1f7eb2ece8ce280b3cb15cb33d24c0d9.zip |
added doku_hasTextBeenModified, rename doku_checkSummary
checkfunc is mainly replaced by doku_hasTextBeenModified, which is put
in global scope to allow overriding by plugins.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/scripts/edit.js | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 77378b060..579afd8f1 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -188,6 +188,10 @@ function currentHeadlineLevel(textboxId){ window.textChanged = false; /** + * global var which stores original editor content + */ +window.doku_edit_text_content = ''; +/** * Delete the draft before leaving the page */ function deleteDraft() { @@ -236,22 +240,17 @@ jQuery(function () { DWsetSelection(sel); $edit_text.focus(); - var edit_text_content = $edit_text.val(); + doku_edit_text_content = $edit_text.val(); } - var checkfunc = function() { - //global var textChanged - if ($edit_text.length > 0) { - textChanged = edit_text_content != $edit_text.val(); - } else { - textChanged = true; - } + var changeHandler = function() { + doku_hasTextBeenModified(); - summaryCheck(); + doku_summaryCheck(); }; - $editform.change(checkfunc); - $editform.keydown(checkfunc); + $editform.change(changeHandler); + $editform.keydown(changeHandler); window.onbeforeunload = function(){ if(window.textChanged) { @@ -276,18 +275,33 @@ jQuery(function () { ); var $summary = jQuery('#edit__summary'); - $summary.change(summaryCheck); - $summary.keyup(summaryCheck); + $summary.change(doku_summaryCheck); + $summary.keyup(doku_summaryCheck); - if (textChanged) summaryCheck(); + if (textChanged) doku_summaryCheck(); }); /** + * Updates textChanged variable if content of the editor has been modified + */ +function doku_hasTextBeenModified() { + if (!textChanged) { + var $edit_text = jQuery('#wiki__text'); + + if ($edit_text.length > 0) { + textChanged = doku_edit_text_content != $edit_text.val(); + } else { + textChanged = true; + } + } +} + +/** * Checks if a summary was entered - if not the style is changed * * @author Andreas Gohr <andi@splitbrain.org> */ -function summaryCheck(){ +function doku_summaryCheck(){ var $sum = jQuery('#edit__summary'), missing = $sum.val() === ''; $sum.toggleClass('missing', missing).toggleClass('edit', !missing); |