confirm close when there are unsaved changes

This commit is contained in:
Tom Needham 2012-04-02 17:44:15 +00:00
parent dc499c5b4e
commit adc9d906e4
1 changed files with 14 additions and 1 deletions

View File

@ -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