aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_texteditor/js
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-04-02 17:27:06 +0000
committerTom Needham <needham.thomas@gmail.com>2012-04-02 17:27:06 +0000
commitdc499c5b4e9dc1c64ca81487bfa979121bd407f6 (patch)
treed911edfb91779590c5b88dfc15785f7d4bf34af6 /apps/files_texteditor/js
parentd0cb99e3474b7ef81b42af461930d141bb75baa5 (diff)
downloadnextcloud-server-dc499c5b4e9dc1c64ca81487bfa979121bd407f6.tar.gz
nextcloud-server-dc499c5b4e9dc1c64ca81487bfa979121bd407f6.zip
add * to filename when changes have been made
Diffstat (limited to 'apps/files_texteditor/js')
-rw-r--r--apps/files_texteditor/js/editor.js68
1 files changed, 42 insertions, 26 deletions
diff --git a/apps/files_texteditor/js/editor.js b/apps/files_texteditor/js/editor.js
index 9a87601a4f7..ca6a3a965fb 100644
--- a/apps/files_texteditor/js/editor.js
+++ b/apps/files_texteditor/js/editor.js
@@ -141,31 +141,38 @@ function doSearch(){
// Tries to save the file.
function doFileSave(){
if(editorIsShown()){
- // Get file path
- var path = $('#editor').attr('data-dir')+'/'+$('#editor').attr('data-filename');
- // Get original mtime
- var mtime = $('#editor').attr('data-mtime');
- // Show saving spinner
- $("#editor_save").die('click',doFileSave);
- $('#save_result').remove();
- $('#editor_save').text(t('files_texteditor','Saving...'));
- // Get the data
- var filecontents = window.aceEditor.getSession().getValue();
- // Send the data
- $.post(OC.filePath('files_texteditor','ajax','savefile.php'), { filecontents: filecontents, path: path, mtime: mtime },function(jsondata){
- if(jsondata.status!='success'){
- // Save failed
- $('#editor_save').text(t('files_texteditor','Save'));
- $('#editor_save').after('<p id="save_result" style="float: left">Failed to save file</p>');
- $("#editor_save").live('click',doFileSave);
- } else {
- // Save OK
- // Update mtime
- $('#editor').attr('data-mtime',jsondata.data.mtime);
- $('#editor_save').text(t('files_texteditor','Save'));
- $("#editor_save").live('click',doFileSave);
- }
- },'json');
+ // Changed contents?
+ if($('#editor').attr('data-edited')=='true'){
+ // Get file path
+ var path = $('#editor').attr('data-dir')+'/'+$('#editor').attr('data-filename');
+ // Get original mtime
+ var mtime = $('#editor').attr('data-mtime');
+ // Show saving spinner
+ $("#editor_save").die('click',doFileSave);
+ $('#save_result').remove();
+ $('#editor_save').text(t('files_texteditor','Saving...'));
+ // Get the data
+ var filecontents = window.aceEditor.getSession().getValue();
+ // Send the data
+ $.post(OC.filePath('files_texteditor','ajax','savefile.php'), { filecontents: filecontents, path: path, mtime: mtime },function(jsondata){
+ if(jsondata.status!='success'){
+ // Save failed
+ $('#editor_save').text(t('files_texteditor','Save'));
+ $('#editor_save').after('<p id="save_result" style="float: left">Failed to save file</p>');
+ $("#editor_save").live('click',doFileSave);
+ } else {
+ // Save OK
+ // Update mtime
+ $('#editor').attr('data-mtime',jsondata.data.mtime);
+ $('#editor_save').text(t('files_texteditor','Save'));
+ $("#editor_save").live('click',doFileSave);
+ // Update titles
+ $('#editor').attr('data-edited', 'false');
+ $('#breadcrumb_file').text($('#editor').attr('data-filename'));
+ document.title = $('#editor').attr('data-filename')+' - ownCloud';
+ }
+ },'json');
+ }
}
};
@@ -192,10 +199,11 @@ function showFileEditor(dir,filename){
// Show the control bar
showControls(filename,result.data.write);
// Update document title
- document.title = filename;
+ document.title = filename+' - ownCloud';
$('#editor').text(result.data.filecontents);
$('#editor').attr('data-dir', dir);
$('#editor').attr('data-filename', filename);
+ $('#editor').attr('data-edited', 'false');
window.aceEditor = ace.edit("editor");
aceEditor.setShowPrintMargin(false);
aceEditor.getSession().setUseWrapMode(true);
@@ -207,6 +215,13 @@ function showFileEditor(dir,filename){
OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){
window.aceEditor.setTheme("ace/theme/clouds");
});
+ window.aceEditor.getSession().on('change', function(){
+ if($('#editor').attr('data-edited')!='true'){
+ $('#editor').attr('data-edited', 'true');
+ $('#breadcrumb_file').text($('#breadcrumb_file').text()+' *');
+ document.title = $('#editor').attr('data-filename')+' * - ownCloud';
+ }
+ });
});
} else {
// Failed to get the file.
@@ -287,4 +302,5 @@ $(document).ready(function(){
$('#editor').remove();
// Binds the save keyboard shortcut events
//$(document).unbind('keydown').bind('keydown',checkForSaveKeyPress);
+
});