some minor changes to the text editor loading
This commit is contained in:
parent
4cc68eac6d
commit
352d73f1e0
|
@ -174,41 +174,40 @@ function giveEditorFocus(){
|
||||||
function showFileEditor(dir,filename){
|
function showFileEditor(dir,filename){
|
||||||
if(!editorIsShown()){
|
if(!editorIsShown()){
|
||||||
// Loads the file editor and display it.
|
// Loads the file editor and display it.
|
||||||
var data = $.ajax({
|
var data = $.getJSON(
|
||||||
url: OC.filePath('files_texteditor','ajax','loadfile.php'),
|
OC.filePath('files_texteditor','ajax','loadfile.php'),
|
||||||
data: 'file='+encodeURIComponent(filename)+'&dir='+encodeURIComponent(dir),
|
{file:filename,dir:dir},
|
||||||
complete: function(data){
|
function(result){
|
||||||
result = jQuery.parseJSON(data.responseText);
|
if(result.status == 'success'){
|
||||||
if(result.status == 'success'){
|
// Save mtime
|
||||||
// Save mtime
|
$('#editor').attr('data-mtime', result.data.mtime);
|
||||||
$('#editor').attr('data-mtime', result.data.mtime);
|
// Initialise the editor
|
||||||
// Initialise the editor
|
showControls(filename,result.data.write);
|
||||||
showControls(filename,result.data.write);
|
$('table').fadeOut('slow', function() {
|
||||||
$('table').fadeOut('slow', function() {
|
// Update document title
|
||||||
// Update document title
|
document.title = filename;
|
||||||
document.title = filename;
|
$('#editor').text(result.data.filecontents);
|
||||||
$('#editor').text(result.data.filecontents);
|
$('#editor').attr('data-dir', dir);
|
||||||
$('#editor').attr('data-dir', dir);
|
$('#editor').attr('data-filename', filename);
|
||||||
$('#editor').attr('data-filename', filename);
|
window.aceEditor = ace.edit("editor");
|
||||||
window.aceEditor = ace.edit("editor");
|
aceEditor.setShowPrintMargin(false);
|
||||||
aceEditor.setShowPrintMargin(false);
|
if(result.data.write=='false'){
|
||||||
if(result.data.write=='false'){
|
aceEditor.setReadOnly(true);
|
||||||
aceEditor.setReadOnly(true);
|
}
|
||||||
}
|
setEditorSize();
|
||||||
setEditorSize();
|
setSyntaxMode(getFileExtension(filename));
|
||||||
setSyntaxMode(getFileExtension(filename));
|
OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){
|
||||||
OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){
|
window.aceEditor.setTheme("ace/theme/clouds");
|
||||||
window.aceEditor.setTheme("ace/theme/clouds");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
// Failed to get the file.
|
} else {
|
||||||
alert(result.data.message);
|
// Failed to get the file.
|
||||||
}
|
alert(result.data.message);
|
||||||
// End success
|
|
||||||
}
|
}
|
||||||
// End ajax
|
// End success
|
||||||
});
|
}
|
||||||
|
// End ajax
|
||||||
|
);
|
||||||
is_editor_shown = true;
|
is_editor_shown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue