Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_texteditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-11-08 16:05:35 +0400
committerVincent Petry <pvince81@owncloud.com>2013-11-08 16:05:35 +0400
commit6da96a9cbcbe2be5a5a77c853c1af060222c4078 (patch)
tree8e62eeec9a03145924aa5e2065b029ffbb3fb2bd /js
parent7a94937509e9af08690ce289282470ea186adf40 (diff)
Added unsaved warning when closing tab / navigating away
Diffstat (limited to 'js')
-rw-r--r--js/editor.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/js/editor.js b/js/editor.js
index 1fa4961..5c7b86c 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -209,6 +209,7 @@ function showFileEditor(dir, filename) {
// Initialise the editor
if (window.FileList){
FileList.setViewerMode(true);
+ enableEditorUnsavedWarning(true);
}
// Show the control bar
showControls(dir, filename, result.data.writeable);
@@ -266,8 +267,20 @@ function showFileEditor(dir, filename) {
}
}
+function enableEditorUnsavedWarning(enable) {
+ $(window).unbind('beforeunload.texteditor');
+ if (enable) {
+ $(window).bind('beforeunload.texteditor', function () {
+ if ($('#editor').attr('data-edited') == 'true') {
+ return t('files_texteditor', 'There are unsaved changes in the text editor');
+ }
+ });
+ }
+}
+
// Fades out the editor.
function hideFileEditor() {
+ enableEditorUnsavedWarning(false);
if (window.FileList){
// reload the directory content with the updated file size + thumbnail
// and also the breadcrumb
@@ -298,6 +311,7 @@ function hideFileEditor() {
// Reopens the last document
function reopenEditor() {
FileList.setViewerMode(true);
+ enableEditorUnsavedWarning(true);
$('#controls .last').not('#breadcrumb_file').removeClass('last');
$('#editor_container').show();
$('#editorcontrols').show();