summaryrefslogtreecommitdiffstats
path: root/apps/files_texteditor
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2011-10-08 15:46:38 +0100
committerTom Needham <needham.thomas@gmail.com>2011-10-08 15:46:38 +0100
commitadebefad84e06d15a9bc5e1fadb4846c636b3347 (patch)
treee146e0f67f6b8359683a2e71635f10ebc62eca46 /apps/files_texteditor
parent538abb99f1ee5d2a3b32ba4de134ac1de463a3b9 (diff)
downloadnextcloud-server-adebefad84e06d15a9bc5e1fadb4846c636b3347.tar.gz
nextcloud-server-adebefad84e06d15a9bc5e1fadb4846c636b3347.zip
Fixed editor loading and file saving issue
Diffstat (limited to 'apps/files_texteditor')
-rw-r--r--apps/files_texteditor/js/editor.js53
1 files changed, 28 insertions, 25 deletions
diff --git a/apps/files_texteditor/js/editor.js b/apps/files_texteditor/js/editor.js
index 62a945c6faf..f7b924d494d 100644
--- a/apps/files_texteditor/js/editor.js
+++ b/apps/files_texteditor/js/editor.js
@@ -55,7 +55,7 @@ function showControls(filename){
var html = '<input type="button" id="editor_close" value="Close">';
$('#controls').append(html);
$('#editorbar').fadeIn('slow');
- var breadcrumbhtml = '<div class="crumb svg" id="breadcrumb_file" style="background-image:url(&quot;../core/img/breadcrumb.png&quot;)"><a href="#">'+filename+'</a></div>';
+ var breadcrumbhtml = '<div class="crumb svg" id="breadcrumb_file" style="background-image:url(&quot;../core/img/breadcrumb.png&quot;)"><p>'+filename+'</p></div>';
$('.actions').before(breadcrumbhtml);
$('.actions').before(savebtnhtml);
});
@@ -72,11 +72,12 @@ function bindControlEvents(){
}
function editorIsShown(){
- if($('#editor').length!=0){
+ // Not working as intended. Always returns true.
+ if(window.aceEditor){
return true;
} else {
return false;
- }
+ }
}
function updateSessionFileHash(path){
@@ -148,30 +149,32 @@ function giveEditorFocus(){
};
function showFileEditor(dir,filename){
- // Loads the file editor and display it.
- var data = $.ajax({
- url: OC.filePath('files','ajax','download.php')+'?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent(dir),
- complete: function(data){
- // Initialise the editor
- updateSessionFileHash(dir+'/'+filename);
- showControls(filename);
- $('table').fadeOut('slow', function() {
- $('#editor').text(data.responseText);
- // encodeURIComponenet?
- $('#editor').attr('data-dir', dir);
- $('#editor').attr('data-filename', filename);
- window.aceEditor = ace.edit("editor");
- aceEditor.setShowPrintMargin(false);
- setEditorSize();
- setSyntaxMode(getFileExtension(filename));
- OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){
- window.aceEditor.setTheme("ace/theme/clouds");
+ if(!editorIsShown()){
+ // Loads the file editor and display it.
+ var data = $.ajax({
+ url: OC.filePath('files','ajax','download.php')+'?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent(dir),
+ complete: function(data){
+ // Initialise the editor
+ updateSessionFileHash(dir+'/'+filename);
+ showControls(filename);
+ $('table').fadeOut('slow', function() {
+ $('#editor').text(data.responseText);
+ // encodeURIComponenet?
+ $('#editor').attr('data-dir', dir);
+ $('#editor').attr('data-filename', filename);
+ window.aceEditor = ace.edit("editor");
+ aceEditor.setShowPrintMargin(false);
+ setEditorSize();
+ setSyntaxMode(getFileExtension(filename));
+ OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){
+ window.aceEditor.setTheme("ace/theme/clouds");
+ });
});
+ // End success
+ }
+ // End ajax
});
- // End success
- }
- // End ajax
- });
+ }
}
function hideFileEditor(){