summaryrefslogtreecommitdiffstats
path: root/apps/files_texteditor
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-04-02 17:44:15 +0000
committerTom Needham <needham.thomas@gmail.com>2012-04-02 17:44:15 +0000
commitadc9d906e4b45082dc08463afce6835a49feb438 (patch)
tree5192334e2dfb86155da0d4b67003204f1e6ae6ad /apps/files_texteditor
parentdc499c5b4e9dc1c64ca81487bfa979121bd407f6 (diff)
downloadnextcloud-server-adc9d906e4b45082dc08463afce6835a49feb438.tar.gz
nextcloud-server-adc9d906e4b45082dc08463afce6835a49feb438.zip
confirm close when there are unsaved changes
Diffstat (limited to 'apps/files_texteditor')
-rw-r--r--apps/files_texteditor/js/editor.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/apps/files_texteditor/js/editor.js b/apps/files_texteditor/js/editor.js
index ca6a3a965fb..1e136fe68e5 100644
--- a/apps/files_texteditor/js/editor.js
+++ b/apps/files_texteditor/js/editor.js
@@ -76,7 +76,7 @@ function showControls(filename,writeperms){
function bindControlEvents(){
$("#editor_save").die('click',doFileSave).live('click',doFileSave);
- $('#editor_close').die('click',hideFileEditor).live('click',hideFileEditor);
+ $('#editor_close').die('click',closeBtnClick).live('click',closeBtnClick);
$('#gotolineval').die('keyup', goToLine).live('keyup', goToLine);
$('#editorsearchval').die('keyup', doSearch).live('keyup', doSearch);
$('#clearsearchbtn').die('click', resetSearch).live('click', resetSearch);
@@ -235,6 +235,19 @@ function showFileEditor(dir,filename){
}
}
+function closeBtnClick(){
+ if($('#editor').attr('data-edited')=='true'){
+ // Show confirm
+ OC.dialogs.confirm(t('files_texteditor','You have unsaved changes that will be lost! Do you still want to close?'),t('files_texteditor','Really close?'),function(close){
+ if(close){
+ hideFileEditor();
+ }
+ });
+ } else {
+ hideFileEditor();
+ }
+}
+
// Fades out the editor.
function hideFileEditor(){
// Fades out editor controls