improved ui and save button action

remotes/origin/stable
Tom Needham 13 years ago
parent 19186bf37b
commit 3be0564040
  1. 2
      apps/files_texteditor/css/style.css
  2. 27
      apps/files_texteditor/js/editor.js

@ -14,7 +14,7 @@
} }
#editor_close{ #editor_close{
margin-left: auto; margin-left: auto;
margin-right: 167px; margin-right: 170px;
display: block; display: block;
} }
#editor_save{ #editor_save{

@ -60,9 +60,9 @@ function showControls(filename,writeperms){
// Load the new toolbar. // Load the new toolbar.
var savebtnhtml; var savebtnhtml;
if(writeperms=="true"){ if(writeperms=="true"){
var savebtnhtml = '<input type="button" id="editor_save" value="'+t('files_texteditor','Save')+'">'; var savebtnhtml = '<button id="editor_save">'+t('files_texteditor','Save')+'</button>';
} }
var html = '<input type="button" id="editor_close" value="Close">'; var html = '<button id="editor_close">X</button>';
$('#controls').append(html); $('#controls').append(html);
$('#editorbar').fadeIn('slow'); $('#editorbar').fadeIn('slow');
var breadcrumbhtml = '<div class="crumb svg" id="breadcrumb_file" style="background-image:url(&quot;../core/img/breadcrumb.png&quot;)"><p>'+filename+'</p></div>'; var breadcrumbhtml = '<div class="crumb svg" id="breadcrumb_file" style="background-image:url(&quot;../core/img/breadcrumb.png&quot;)"><p>'+filename+'</p></div>';
@ -88,34 +88,23 @@ function doFileSave(){
var mtime = $('#editor').attr('data-mtime'); var mtime = $('#editor').attr('data-mtime');
// Show saving spinner // Show saving spinner
$("#editor_save").die('click',doFileSave); $("#editor_save").die('click',doFileSave);
$('#editor_save').after('<img id="saving_icon" src="'+OC.filePath('core','img','loading.gif')+'"></img>'); $('#save_result').remove();
$('#editor_save').text(t('files_texteditor','Saving...'));//after('<img id="saving_icon" src="'+OC.filePath('core','img','loading.gif')+'"></img>');
// Get the data // Get the data
var filecontents = window.aceEditor.getSession().getValue(); var filecontents = window.aceEditor.getSession().getValue();
// Send the data // Send the data
$.post(OC.filePath('files_texteditor','ajax','savefile.php'), { filecontents: filecontents, path: path, mtime: mtime },function(jsondata){ $.post(OC.filePath('files_texteditor','ajax','savefile.php'), { filecontents: filecontents, path: path, mtime: mtime },function(jsondata){
if(jsondata.status!='success'){ if(jsondata.status!='success'){
// Save failed // Save failed
$('#saving_icon').remove(); $('#editor_save').text(t('files_texteditor','Save'));
$('#editor_save').after('<p id="save_result" style="float: left">Failed to save file</p>'); $('#editor_save').after('<p id="save_result" style="float: left">Failed to save file</p>');
setTimeout(function() { $("#editor_save").live('click',doFileSave);
$('#save_result').fadeOut('slow',function(){
$(this).remove();
$("#editor_save").live('click',doFileSave);
});
}, 2000);
} else { } else {
// Save OK // Save OK
// Update mtime // Update mtime
$('#editor').attr('data-mtime',jsondata.data.mtime); $('#editor').attr('data-mtime',jsondata.data.mtime);
// Show result $('#editor_save').text(t('files_texteditor','Save'));
$('#saving_icon').remove(); $("#editor_save").live('click',doFileSave);
$('#editor_save').after('<p id="save_result" style="float: left">Saved</p>')
setTimeout(function() {
$('#save_result').fadeOut('slow',function(){
$(this).remove();
$("#editor_save").live('click',doFileSave);
});
}, 2000);
} }
},'json'); },'json');
} }

Loading…
Cancel
Save