Skip to content

Commit

Permalink
Merge pull request #47 from nawroth/externalconsole
Browse files Browse the repository at this point in the history
Added button for opening console in external window.
  • Loading branch information
simpsonjulian committed Aug 17, 2012
2 parents a50b56a + d34fb62 commit 19c61d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Binary file added src/main/resources/css/external.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/resources/css/neo.css
Expand Up @@ -124,7 +124,7 @@ div.navheader
position: absolute;
right: 0;
top: 160px;
width: 154px;
width: 180px;
text-align: right;
font-size: 0.9375em;
border-top: 1px solid #DDDDDD;
Expand Down
33 changes: 23 additions & 10 deletions src/main/resources/js/cypherconsole.js
Expand Up @@ -23,6 +23,7 @@

jQuery( document ).ready( function()
{
if ( jQuery.browser.msie ) return;
createCypherConsoles( jQuery );
});

Expand All @@ -43,11 +44,18 @@ function createCypherConsoles( $ )
var command = context.find( 'span.command > strong' ).eq(0).text();
if ( !command ) return;
var button = $( '<button class="cypherconsole" type="button"><img src="css/utilities-terminal.png" /> ' + title + '</button>' );
var url = getUrl( database, command );
var link = $( '<button class="cypherconsole" type="button" title="Open the console in a new window."><img style="position:relative;right:-0.3em;" src="css/external.png" />&#8201;</button>' );
link.click( function()
{
window.open( url, '_blank' );
});
button.click( function()
{
handleCypherClick( button, database, command, title );
handleCypherClick( button, link, url, title );
});
button.insertAfter( this );
link.insertAfter( button );
});

$( RESOURCE_FILES ).each( function()
Expand All @@ -57,7 +65,19 @@ function createCypherConsoles( $ )
// $.get( target );
});

function handleCypherClick( button, database, command, title )
function getUrl( database, command )
{
var url = REQUEST_BASE;
url += "init=" + encodeURIComponent( database );
url += "&query=" + encodeURIComponent( command );
if ( window.neo4jVersion != undefined )
{
url += "&version=" + encodeURIComponent( neo4jVersion );
}
return url;
}

function handleCypherClick( button, link, url, title )
{
var iframe=$( "#console" );
if ( iframe.length )
Expand All @@ -70,15 +90,8 @@ function createCypherConsoles( $ )
currentButton = null;
return;
}
var url= REQUEST_BASE;
url += "init=" + encodeURIComponent( database );
url += "&query=" + encodeURIComponent( command );
if ( window.neo4jVersion != undefined )
{
url += "&version=" + encodeURIComponent( neo4jVersion );
}
iframe = $( "<iframe/>" ).attr( "id", "console" ).addClass( "console" ).attr( "src", url );
button.after( iframe );
link.after( iframe );
currentButton = button;
}
}
Expand Down

0 comments on commit 19c61d1

Please sign in to comment.