// Load the new toolbar.
var savebtnhtml;
if(writeperms=="true"){
- var savebtnhtml = '<button id="editor_save">'+t('files_texteditor','Save')+'</button>';
+ var editorcontrols = '<button id="editor_save">'+t('files_texteditor','Save')+'</button><div class="separator"></div><button id="gotolinebtn">Go to line:</button><input type="text" id="gotolineval">';
}
var html = '<button id="editor_close">X</button>';
$('#controls').append(html);
$('#editorbar').fadeIn('slow');
var breadcrumbhtml = '<div class="crumb svg" id="breadcrumb_file" style="background-image:url("../core/img/breadcrumb.png")"><p>'+filename+'</p></div>';
- $('.actions').before(breadcrumbhtml).before(savebtnhtml);
+ $('.actions').before(breadcrumbhtml).before(editorcontrols);
});
}
function bindControlEvents(){
$("#editor_save").die('click',doFileSave).live('click',doFileSave);
$('#editor_close').die('click',hideFileEditor).live('click',hideFileEditor);
+ $('#gotolinebtn').die('click', goToLine).live('click', goToLine);
}
+// returns true or false if the editor is in view or not
function editorIsShown(){
// Not working as intended. Always returns true.
return is_editor_shown;
}
+// Moves the editor view to the line number speificed in #gotolineval
+function goToLine(){
+ // Go to the line specified
+ window.aceEditor.gotoLine($('#gotolineval').val());
+
+}
+
+// Tries to save the file.
function doFileSave(){
if(editorIsShown()){
// Get file path
}
};
+// Gives the editor focus
function giveEditorFocus(){
window.aceEditor.focus();
};
+// Loads the file editor. Accepts two parameters, dir and filename.
function showFileEditor(dir,filename){
if(!editorIsShown()){
// Loads the file editor and display it.
}
}
+// Fades out the editor.
function hideFileEditor(){
// Fade out controls
$('#editor_close').fadeOut('slow');
// Fade out the save button
$('#editor_save').fadeOut('slow');
+ // Goto line items
+ $('#gotolinebtn').fadeOut('slow');
+ $('#gotolineval').fadeOut('slow');
+ // Fade out separators
+ $('.separator').fadeOut('slow');
// Fade out breadcrumb
$('#breadcrumb_file').fadeOut('slow', function(){ $(this).remove();});
// Fade out editor
// Keyboard Shortcuts
var ctrlBtn = false;
-
+
+// returns true if ctrl+s or cmd+s is being pressed
function checkForSaveKeyPress(e){
if(e.which == 17 || e.which == 91) ctrlBtn=true;
if(e.which == 83 && ctrlBtn == true) {
}
}
+// resizes the editor window
$(window).resize(function() {
setEditorSize();
});
showFileEditor(dir,file);
});
}
- // Binds the file save and close editor events
+ // Binds the file save and close editor events, and gotoline button
bindControlEvents();
// Binds the save keyboard shortcut events