Toggle save button depending on editor changes and return to editor instead of history pane after saving
This commit is contained in:
parent
f76046b612
commit
f14ef10e48
@ -71,7 +71,7 @@
|
|||||||
<label for='id_{{$commitMsg.0}}' id='label_{{$commitMsg.0}}'>{{$commitMsg.1}}{{if $commitMsg.4}}<span class="required"> {{$commitMsg.4}}</span>{{/if}}</label>
|
<label for='id_{{$commitMsg.0}}' id='label_{{$commitMsg.0}}'>{{$commitMsg.1}}{{if $commitMsg.4}}<span class="required"> {{$commitMsg.4}}</span>{{/if}}</label>
|
||||||
<span>
|
<span>
|
||||||
<input class="" style="width: 80%;" name='{{$commitMsg.0}}' id='id_{{$commitMsg.0}}' type="text" value="{{$commitMsg.2}}"{{if $commitMsg.5}} {{$commitMsg.5}}{{/if}}>
|
<input class="" style="width: 80%;" name='{{$commitMsg.0}}' id='id_{{$commitMsg.0}}' type="text" value="{{$commitMsg.2}}"{{if $commitMsg.5}} {{$commitMsg.5}}{{/if}}>
|
||||||
<a id="save-page" href="#" class="btn btn-primary btn-md">Save</a>
|
<a id="save-page" href="#" class="btn btn-primary btn-md disabled">Save</a>
|
||||||
</span>
|
</span>
|
||||||
<span id='help_{{$commitMsg.0}}' class='help-block'>{{$commitMsg.3}}</span>
|
<span id='help_{{$commitMsg.0}}' class='help-block'>{{$commitMsg.3}}</span>
|
||||||
|
|
||||||
@ -253,7 +253,10 @@
|
|||||||
window.console.log('Page saved successfully.');
|
window.console.log('Page saved successfully.');
|
||||||
window.wiki_page_content = currentContent;
|
window.wiki_page_content = currentContent;
|
||||||
$('#id_commitMsg').val(''); // Clear the commit message box
|
$('#id_commitMsg').val(''); // Clear the commit message box
|
||||||
$('#wiki-get-history').click();
|
$('#save-page').addClass('disabled'); // Disable the save button
|
||||||
|
window.editor.getSession().getUndoManager().markClean(); // Reset the undo history for the editor
|
||||||
|
window.editor.focus(); // Return focus to the editor for continued editing
|
||||||
|
// $('#wiki-get-history').click();
|
||||||
} else {
|
} else {
|
||||||
alert('Error saving page.'); // TODO: Replace alerts with auto-timeout popups
|
alert('Error saving page.'); // TODO: Replace alerts with auto-timeout popups
|
||||||
window.console.log('Error saving page.');
|
window.console.log('Error saving page.');
|
||||||
@ -460,6 +463,14 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
$('#new-wiki-button').hide();
|
$('#new-wiki-button').hide();
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
// using input event instead of change since it's called with some timeout
|
||||||
|
window.editor.on("input", function() {
|
||||||
|
if(window.editor.getSession().getUndoManager().isClean()) {
|
||||||
|
$('#save-page').addClass('disabled');
|
||||||
|
} else {
|
||||||
|
$('#save-page').removeClass('disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user