mirror of
https://github.com/xevidos/codiad.git
synced 2025-01-09 06:21:56 +01:00
Updated search functions for workspace replacement, Added callback to modal, Updated selection text for find and replace
This commit is contained in:
parent
6949de42ff
commit
7700671b1d
5 changed files with 66 additions and 60 deletions
|
@ -752,14 +752,18 @@
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
getSelectedText: function() {
|
getSelectedText: function() {
|
||||||
var path = this.getPath();
|
|
||||||
var session = this.sessions[path];
|
let path = this.getPath();
|
||||||
|
let session = this.sessions[path];
|
||||||
|
|
||||||
if( path && this.isOpen( path ) ) {
|
if( path && this.isOpen( path ) ) {
|
||||||
return session.getTextRange(
|
|
||||||
codiad.editor.getActive()
|
console.log( "Session:", session );
|
||||||
.getSelectionRange() );
|
console.log( "selection: ", codiad.editor.getActive().getSelectionRange() )
|
||||||
|
console.log( "text: ", session.getTextRange( codiad.editor.getActive().getSelectionRange() ) )
|
||||||
|
return session.getTextRange( codiad.editor.getActive().getSelectionRange() );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
codiad.message.error( i18n( 'No Open Files or Selected Text' ) );
|
codiad.message.error( i18n( 'No Open Files or Selected Text' ) );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -86,28 +86,3 @@ checkSession();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</form>
|
</form>
|
||||||
<script>
|
|
||||||
$( function() {
|
|
||||||
<?php
|
|
||||||
if( $_GET['action'] == 'search' ) {
|
|
||||||
?>
|
|
||||||
if( codiad.editor.multi_line ) {
|
|
||||||
|
|
||||||
$('textarea[name="find"]').val( codiad.active.getSelectedText() );
|
|
||||||
$('textarea[name="find"]').focus();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$('input[name="find"]').val( codiad.active.getSelectedText() );
|
|
||||||
$('input[name="find"]').focus();
|
|
||||||
}
|
|
||||||
<?php
|
|
||||||
} elseif( $_GET['action'] == 'sort' ) {
|
|
||||||
|
|
||||||
?>
|
|
||||||
$('textarea[name="sort"]').val( codiad.active.getSelectedText() );
|
|
||||||
$('textarea[name="sort"]').focus();
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
|
@ -1359,13 +1359,33 @@
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
openSearch: function( type ) {
|
openSearch: function( type ) {
|
||||||
|
|
||||||
if( this.getActive() ) {
|
if( this.getActive() ) {
|
||||||
codiad.modal.load( 400,
|
|
||||||
'components/editor/dialog.php?action=search&type=' +
|
let selected = codiad.active.getSelectedText();
|
||||||
type );
|
|
||||||
|
codiad.modal.load(
|
||||||
|
400,
|
||||||
|
'components/editor/dialog.php?action=search&type=' + type,
|
||||||
|
{},
|
||||||
|
function( c ) {
|
||||||
|
|
||||||
|
let input = c.find( 'input:first' );
|
||||||
|
let textarea = c.find( 'textarea:first' );
|
||||||
|
|
||||||
|
if( input.css( 'display' ) !== 'none' ) {
|
||||||
|
|
||||||
|
input.val( selected )
|
||||||
|
input.focus();
|
||||||
|
} else if( textarea.css( 'display' ) !== 'none' ) {
|
||||||
|
|
||||||
|
textarea.val( selected )
|
||||||
|
textarea.focus();
|
||||||
|
}
|
||||||
|
console.log( input, textarea );
|
||||||
codiad.modal.hideOverlay();
|
codiad.modal.hideOverlay();
|
||||||
} else {
|
}
|
||||||
codiad.message.error( 'No Open Files' );
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -649,7 +649,7 @@ class Filemanager extends Common {
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
$input = str_replace( '"', '', $query );
|
$input = str_replace( '"', '', $query );
|
||||||
$cmd = 'find -L ' . escapeshellarg( $path ) . ' -iregex '.escapeshellarg( '.*' . $options["filetype"] ) . ' -type f -print0 | xargs -0 grep -i -I -n -R -H ' . escapeshellarg( $input ) . '';
|
$cmd = 'find -L ' . escapeshellarg( $path ) . ' -iregex ' . escapeshellarg( '.*' . $options["filetype"] ) . ' -type f -print0 | xargs -0 grep -i -I -n -R -H ' . escapeshellarg( $input ) . '';
|
||||||
$output = shell_exec( $cmd );
|
$output = shell_exec( $cmd );
|
||||||
$output_arr = explode( "\n", $output );
|
$output_arr = explode( "\n", $output );
|
||||||
foreach ( $output_arr as $line ) {
|
foreach ( $output_arr as $line ) {
|
||||||
|
@ -660,7 +660,7 @@ class Filemanager extends Common {
|
||||||
|
|
||||||
$da['line'] = $data[1];
|
$da['line'] = $data[1];
|
||||||
$da['file'] = str_replace( $path, '', $data[0] );
|
$da['file'] = str_replace( $path, '', $data[0] );
|
||||||
$da['result'] = $_SESSION["project"] . str_replace( $path, '', $data[0] );
|
$da['result'] = str_replace( WORKSPACE . '/', '', $data[0] );
|
||||||
$da['string'] = str_replace( $data[0] . ":" . $data[1] . ':', '', $line );
|
$da['string'] = str_replace( $data[0] . ":" . $data[1] . ':', '', $line );
|
||||||
$return[] = $da;
|
$return[] = $da;
|
||||||
}
|
}
|
||||||
|
|
27
js/modal.js
27
js/modal.js
|
@ -19,10 +19,11 @@
|
||||||
.hide();
|
.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
load: function( width, url, data ) {
|
load: function( width, url, data, callback = null ) {
|
||||||
|
|
||||||
data = data || {};
|
data = data || {};
|
||||||
var bounds = this._getBounds( width );
|
let bounds = this._getBounds( width );
|
||||||
|
let content = $( '#modal-content' )
|
||||||
$('#modal')
|
$('#modal')
|
||||||
.css({
|
.css({
|
||||||
'top': bounds.top,
|
'top': bounds.top,
|
||||||
|
@ -33,21 +34,27 @@
|
||||||
.draggable({
|
.draggable({
|
||||||
handle: '#drag-handle'
|
handle: '#drag-handle'
|
||||||
});
|
});
|
||||||
$('#modal-content')
|
content.html('<div id="modal-loading"></div>');
|
||||||
.html('<div id="modal-loading"></div>');
|
|
||||||
this.load_process = $.get( url, data, function( data ) {
|
this.load_process = $.get( url, data, function( data ) {
|
||||||
$('#modal-content').html( data );
|
|
||||||
|
content.html( data );
|
||||||
// Fix for Firefox autofocus goofiness
|
// Fix for Firefox autofocus goofiness
|
||||||
$('input[autofocus="autofocus"]')
|
$('#modal-content input[autofocus="autofocus"]').focus();
|
||||||
.focus();
|
|
||||||
|
if( callback ) {
|
||||||
|
|
||||||
|
callback( content );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var event = {animationPerformed: false};
|
|
||||||
|
let event = {animationPerformed: false};
|
||||||
amplify.publish( 'modal.onLoad', event );
|
amplify.publish( 'modal.onLoad', event );
|
||||||
|
|
||||||
// If no plugin has provided a custom load animation
|
// If no plugin has provided a custom load animation
|
||||||
if( ! event.animationPerformed ) {
|
if( ! event.animationPerformed ) {
|
||||||
|
|
||||||
$('#modal, #modal-overlay')
|
$('#modal, #modal-overlay').fadeIn(200);
|
||||||
.fadeIn(200);
|
|
||||||
}
|
}
|
||||||
codiad.sidebars.modalLock = true;
|
codiad.sidebars.modalLock = true;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue