Added live search
This commit is contained in:
parent
3f67918522
commit
6d37c7d351
|
@ -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 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 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"><div class="separator"></div>';
|
||||||
}
|
}
|
||||||
var html = '<button id="editor_close">X</button>';
|
var html = '<label for="editorseachval">Search:</label><input type="text" name="editorsearchval" id="editorsearchval"><div class="separator"></div><button id="editor_close">'+t('files_texteditor','Close')+'</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("../core/img/breadcrumb.png")"><p>'+filename+'</p></div>';
|
var breadcrumbhtml = '<div class="crumb svg" id="breadcrumb_file" style="background-image:url("../core/img/breadcrumb.png")"><p>'+filename+'</p></div>';
|
||||||
|
@ -74,6 +74,9 @@ function bindControlEvents(){
|
||||||
$("#editor_save").die('click',doFileSave).live('click',doFileSave);
|
$("#editor_save").die('click',doFileSave).live('click',doFileSave);
|
||||||
$('#editor_close').die('click',hideFileEditor).live('click',hideFileEditor);
|
$('#editor_close').die('click',hideFileEditor).live('click',hideFileEditor);
|
||||||
$('#gotolinebtn').die('click', goToLine).live('click', goToLine);
|
$('#gotolinebtn').die('click', goToLine).live('click', goToLine);
|
||||||
|
$('#editorsearchval').die('keyup', doSearch).live('keyup', doSearch);
|
||||||
|
$('#clearsearchbtn').die('click', resetSearch).live('click', resetSearch);
|
||||||
|
$('#nextsearchbtn').die('click', nextSearchResult).live('click', nextSearchResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true or false if the editor is in view or not
|
// returns true or false if the editor is in view or not
|
||||||
|
@ -89,6 +92,48 @@ function goToLine(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//resets the search
|
||||||
|
function resetSearch(){
|
||||||
|
$('#editorsearchval').val('');
|
||||||
|
$('#nextsearchbtn').remove();
|
||||||
|
$('#clearsearchbtn').remove();
|
||||||
|
window.aceEditor.gotoLine(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// moves the cursor to the next search resukt
|
||||||
|
function nextSearchResult(){
|
||||||
|
window.aceEditor.findNext();
|
||||||
|
}
|
||||||
|
// Performs the initial search
|
||||||
|
function doSearch(){
|
||||||
|
// check if search box empty?
|
||||||
|
if($('#editorsearchval').val()==''){
|
||||||
|
// Hide clear button
|
||||||
|
window.aceEditor.gotoLine(0);
|
||||||
|
$('#nextsearchbtn').remove();
|
||||||
|
$('#clearsearchbtn').remove();
|
||||||
|
} else {
|
||||||
|
// New search
|
||||||
|
// Reset cursor
|
||||||
|
window.aceEditor.gotoLine(0);
|
||||||
|
// Do search
|
||||||
|
window.aceEditor.find($('#editorsearchval').val(),{
|
||||||
|
backwards: false,
|
||||||
|
wrap: false,
|
||||||
|
caseSensitive: false,
|
||||||
|
wholeWord: false,
|
||||||
|
regExp: false
|
||||||
|
});
|
||||||
|
// Show next and clear buttons
|
||||||
|
// check if already there
|
||||||
|
if($('#nextsearchbtn').length==0){
|
||||||
|
var nextbtnhtml = '<button id="nextsearchbtn">Next</button>';
|
||||||
|
var clearbtnhtml = '<button id="clearsearchbtn">Clear</button>';
|
||||||
|
$('#editorsearchval').after(nextbtnhtml).after(clearbtnhtml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tries to save the file.
|
// Tries to save the file.
|
||||||
function doFileSave(){
|
function doFileSave(){
|
||||||
if(editorIsShown()){
|
if(editorIsShown()){
|
||||||
|
@ -168,22 +213,13 @@ function showFileEditor(dir,filename){
|
||||||
|
|
||||||
// Fades out the editor.
|
// Fades out the editor.
|
||||||
function hideFileEditor(){
|
function hideFileEditor(){
|
||||||
// Fade out controls
|
// Fades out editor controls
|
||||||
$('#editor_close').fadeOut('slow');
|
$('#controls > :not(.actions,#file_access_panel),#breadcrumb_file').fadeOut('slow',function(){
|
||||||
// Fade out the save button
|
$(this).remove();
|
||||||
$('#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
|
// Fade out editor
|
||||||
$('#editor').fadeOut('slow', function(){
|
$('#editor').fadeOut('slow', function(){
|
||||||
$('#editor_close').remove();
|
$(this).remove();
|
||||||
$('#editor_save').remove();
|
|
||||||
$('#editor').remove();
|
|
||||||
var editorhtml = '<div id="editor"></div>';
|
var editorhtml = '<div id="editor"></div>';
|
||||||
$('table').after(editorhtml);
|
$('table').after(editorhtml);
|
||||||
$('.actions,#file_access_panel').fadeIn('slow');
|
$('.actions,#file_access_panel').fadeIn('slow');
|
||||||
|
|
Loading…
Reference in New Issue