mirror of
https://github.com/xevidos/codiad.git
synced 2024-12-22 22:02:15 +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() {
|
||||
var path = this.getPath();
|
||||
var session = this.sessions[path];
|
||||
|
||||
let path = this.getPath();
|
||||
let session = this.sessions[path];
|
||||
|
||||
if( path && this.isOpen( path ) ) {
|
||||
return session.getTextRange(
|
||||
codiad.editor.getActive()
|
||||
.getSelectionRange() );
|
||||
|
||||
console.log( "Session:", session );
|
||||
console.log( "selection: ", codiad.editor.getActive().getSelectionRange() )
|
||||
console.log( "text: ", session.getTextRange( codiad.editor.getActive().getSelectionRange() ) )
|
||||
return session.getTextRange( codiad.editor.getActive().getSelectionRange() );
|
||||
} else {
|
||||
|
||||
codiad.message.error( i18n( 'No Open Files or Selected Text' ) );
|
||||
}
|
||||
},
|
||||
|
|
|
@ -86,28 +86,3 @@ checkSession();
|
|||
}
|
||||
?>
|
||||
</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 ) {
|
||||
|
||||
if( this.getActive() ) {
|
||||
codiad.modal.load( 400,
|
||||
'components/editor/dialog.php?action=search&type=' +
|
||||
type );
|
||||
codiad.modal.hideOverlay();
|
||||
} else {
|
||||
codiad.message.error( 'No Open Files' );
|
||||
|
||||
let selected = codiad.active.getSelectedText();
|
||||
|
||||
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();
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -649,7 +649,7 @@ class Filemanager extends Common {
|
|||
|
||||
$return = array();
|
||||
$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_arr = explode( "\n", $output );
|
||||
foreach ( $output_arr as $line ) {
|
||||
|
@ -660,7 +660,7 @@ class Filemanager extends Common {
|
|||
|
||||
$da['line'] = $data[1];
|
||||
$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 );
|
||||
$return[] = $da;
|
||||
}
|
||||
|
|
51
js/modal.js
51
js/modal.js
|
@ -19,35 +19,42 @@
|
|||
.hide();
|
||||
},
|
||||
|
||||
load: function( width, url, data ) {
|
||||
load: function( width, url, data, callback = null ) {
|
||||
|
||||
data = data || {};
|
||||
var bounds = this._getBounds( width );
|
||||
let bounds = this._getBounds( width );
|
||||
let content = $( '#modal-content' )
|
||||
$('#modal')
|
||||
.css({
|
||||
'top': bounds.top,
|
||||
'left': bounds.left,
|
||||
'min-width': width + 'px',
|
||||
'margin-left': '-' + Math.ceil( width / 2 ) + 'px'
|
||||
})
|
||||
.draggable({
|
||||
handle: '#drag-handle'
|
||||
});
|
||||
$('#modal-content')
|
||||
.html('<div id="modal-loading"></div>');
|
||||
this.load_process = $.get( url, data, function( data ) {
|
||||
$('#modal-content').html( data );
|
||||
// Fix for Firefox autofocus goofiness
|
||||
$('input[autofocus="autofocus"]')
|
||||
.focus();
|
||||
.css({
|
||||
'top': bounds.top,
|
||||
'left': bounds.left,
|
||||
'min-width': width + 'px',
|
||||
'margin-left': '-' + Math.ceil( width / 2 ) + 'px'
|
||||
})
|
||||
.draggable({
|
||||
handle: '#drag-handle'
|
||||
});
|
||||
var event = {animationPerformed: false};
|
||||
amplify.publish( 'modal.onLoad', event );
|
||||
content.html('<div id="modal-loading"></div>');
|
||||
|
||||
this.load_process = $.get( url, data, function( data ) {
|
||||
|
||||
content.html( data );
|
||||
// Fix for Firefox autofocus goofiness
|
||||
$('#modal-content input[autofocus="autofocus"]').focus();
|
||||
|
||||
if( callback ) {
|
||||
|
||||
callback( content );
|
||||
}
|
||||
});
|
||||
|
||||
let event = {animationPerformed: false};
|
||||
amplify.publish( 'modal.onLoad', event );
|
||||
|
||||
// If no plugin has provided a custom load animation
|
||||
if( ! event.animationPerformed ) {
|
||||
|
||||
$('#modal, #modal-overlay')
|
||||
.fadeIn(200);
|
||||
$('#modal, #modal-overlay').fadeIn(200);
|
||||
}
|
||||
codiad.sidebars.modalLock = true;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue