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:
authorTom Needham <tom@owncloud.com>2015-10-14 13:56:09 +0300
committerTom Needham <tom@owncloud.com>2015-11-04 20:27:14 +0300
commit6f4c03a4022354af8ae6a99d5605082b9631c89c (patch)
treebe607693f097d590ddcf57792e8dfa5800be5932 /js
parent6ea330ccc8e7003ee9eee4b279b04707f1930775 (diff)
Handle editing whilst saving, preserve title, fixes #121
Diffstat (limited to 'js')
-rw-r--r--js/editor.js38
1 files changed, 26 insertions, 12 deletions
diff --git a/js/editor.js b/js/editor.js
index b90fd13..341357b 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -49,6 +49,16 @@ var Files_Texteditor = {
saveTimer: null,
/**
+ * Stores the old page title
+ */
+ oldTitle: null,
+
+ /**
+ * Stores the timeout for the saving message
+ */
+ saveMessageTimeout: null,
+
+ /**
* preview plugins by mimetype
*/
previewPlugins: {},
@@ -77,9 +87,12 @@ var Files_Texteditor = {
return;
} else {
OCA.Files_Texteditor.saving = true;
- OCA.Files_Texteditor.edited = false;
+ OCA.Files_Texteditor.file.edited = false;
}
+ // Can any fade outs on the saving message
+ clearTimeout(OCA.Files_Texteditor.saveMessageTimeout);
+
// Set the saving status
$('#editor_controls small.saving-message')
.text(t('files_texteditor', 'saving...'))
@@ -90,25 +103,26 @@ var Files_Texteditor = {
OCA.Files_Texteditor.file,
function(data){
// Yay
- // TODO only reset edited value if not editing during saving
- document.title = document.title.slice(2);
- $('small.unsaved-star').css('display', 'none');
+ if(OCA.Files_Texteditor.file.edited == false) {
+ document.title = OCA.Files_Texteditor.file.name + ' - ' + OCA.Files_Texteditor.oldTitle;
+ $('small.unsaved-star').css('display', 'none');
+ }
OCA.Files_Texteditor.file.mtime = data.mtime;
OCA.Files_Texteditor.file.size = data.size;
- OCA.Files_Texteditor.file.edited = false;
+
$('#editor_controls small.saving-message')
.text(t('files_texteditor', 'saved!'));
- setTimeout(function() {
+ OCA.Files_Texteditor.saveMessageTimeout = setTimeout(function() {
$('small.saving-message').fadeOut(200);
}, 2000);
},
function(message){
// Boo
$('small.saving-message').text(t('files_texteditor', 'failed!'));
- setTimeout(function() {
+ OCA.Files_Texteditor.saveMessageTimeout = setTimeout(function() {
$('small.saving-message').fadeOut(200);
}, 5000);
- OCA.Files_Texteditor.edited = true;
+ OCA.Files_Texteditor.file.edited = true;
}
);
OCA.Files_Texteditor.saving = false;
@@ -136,7 +150,7 @@ var Files_Texteditor = {
'files_texteditor',
'Saved'
)
- );
+ )
// Remove the editor
OCA.Files_Texteditor.closeEditor();
},
@@ -161,7 +175,7 @@ var Files_Texteditor = {
*/
_onReOpenTrigger: function() {
if($('#notification').data('reopeneditor') == true) {
- document.title = OCA.Files_Texteditor.file.name + ' - ' + document.title;
+ document.title = OCA.Files_Texteditor.file.name + ' - ' + OCA.Files_Texteditor.oldTitle;
OCA.Files_Texteditor.$container.show();
}
},
@@ -203,7 +217,7 @@ var Files_Texteditor = {
* Handler when unsaved work is detected
*/
_onUnsaved: function() {
- document.title = '* '+document.title;
+ document.title = '* '+ OCA.Files_Texteditor.file.name + ' - ' + OCA.Files_Texteditor.oldTitle;
$('small.unsaved-star').css('display', 'inline-block');
},
@@ -274,7 +288,7 @@ var Files_Texteditor = {
function(file, data){
// Success!
// Sort the title
- document.title = file.name + ' - ' + document.title;
+ document.title = file.name + ' - ' + OCA.Files_Texteditor.oldTitle;
// Load ace
$('#'+_self.editor).text(data);
// Configure ace