Skip to content
Snippets Groups Projects
Commit 5462edca authored by Gerrit Uitslag's avatar Gerrit Uitslag
Browse files

added doku_hasTextBeenModified, rename doku_checkSummary

checkfunc is mainly replaced by doku_hasTextBeenModified, which is put
in  global scope to allow overriding by plugins.
parent 3f18d049
No related branches found
No related tags found
No related merge requests found
......@@ -187,6 +187,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
*/
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment