Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Commit

Permalink
Add option to fade on console on reset
Browse files Browse the repository at this point in the history
Gives the client the option whether to trigger a fade effect when the console
is reset.

README updated to reflect addition.
  • Loading branch information
nickbabcock committed Jul 27, 2013
1 parent afe2365 commit 8fb484a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README
Expand Up @@ -47,6 +47,9 @@ Options available:

cancelHandle function Handle a user-signaled interrupt.

fadeOnReset bool Whether to trigger a fade in/out when
the console is reset. Defaults to true.

LICENSE

Copyright 2010 Chris Done, Simon David Pratt. All rights reserved.
Expand Down
33 changes: 24 additions & 9 deletions jquery.console.js
Expand Up @@ -116,6 +116,7 @@
var promptText = '';
var restoreText = '';
var continuedText = '';
var fadeOnReset = config.fadeOnReset !== undefined ? config.fadeOnReset : true;
// Prompt history stack
var history = [];
var ringn = 0;
Expand Down Expand Up @@ -161,20 +162,34 @@
// Reset terminal
extern.reset = function(){
var welcome = (typeof config.welcomeMessage != 'undefined');
inner.parent().fadeOut(function(){

var removeElements = function() {
inner.find('div').each(function(){
if (!welcome) {
$(this).remove();
} else {
welcome = false;
}
} else {
welcome = false;
}
});
newPromptBox();
inner.parent().fadeIn(function(){
inner.addClass('jquery-console-focus');
typer.focus();
};

var focusConsole = function() {
inner.addClass('jquery-console-focus');
typer.focus();
};

if (fadeOnReset) {
inner.parent().fadeOut(function() {
removeElements();
newPromptBox();
inner.parent().fadeIn(focusConsole);
});
});
}
else {
removeElements();
newPromptBox();
focusConsole();
}
};

////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 8fb484a

Please sign in to comment.