Skip to content

Commit

Permalink
Bug fix for new lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
stvwhtly committed Oct 19, 2015
1 parent 62bb501 commit 120e48e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ Installation
Options
-------

Option | Default | Description
--------------|-------------------------------------|------------
text | `['one','two','three']` (array) | List of strings to output.
typeDelay | `100` (integer) | Minimum delay, in ms, between typing characters.
backDelay | `50` (integer) | Minimum delay, in ms, between deleting characters.
blinkSpeed | `1000` (integer) | Interval, in ms, that the cursor will flash.
cursor | <code>"&#124;"</code> (string) | Character used to represent the cursor.
delay | `2000` (int) | Time in ms to pause before deleting the current text.
preserve | `false` (boolean) | Prevent auto delete of the current string and begin outputting the next string.
prefix | `""` (string) | Begin each string with this prefix value.
loop | `0` (int) | Number of times to loop through the output strings, for unlimited use `0`.
humanise | `true` (boolean) | Add a random delay before each character to represent human interaction.
callbackNext | `null` (function) | Callback function called every text item. See `Callback functions` below.
callbackType | `null` (function) | Callback function called every 'letter'. See `Callback functions` below.
Option | Default | Description
----------------------|-------------------------------------|------------
text | `['one','two','three']` (array) | List of strings to output.
typeDelay | `100` (integer) | Minimum delay, in ms, between typing characters.
backDelay | `50` (integer) | Minimum delay, in ms, between deleting characters.
blinkSpeed | `1000` (integer) | Interval, in ms, that the cursor will flash.
cursor | <code>"&#124;"</code> (string) | Character used to represent the cursor.
delay | `2000` (int) | Time in ms to pause before deleting the current text.
preserve | `false` (boolean) | Prevent auto delete of the current string and begin outputting the next string.
prefix | `""` (string) | Begin each string with this prefix value.
loop | `0` (int) | Number of times to loop through the output strings, for unlimited use `0`.
humanise | `true` (boolean) | Add a random delay before each character to represent human interaction.
callbackNext | `null` (function) | Callback function called every text item. See `Callback functions` below.
callbackType | `null` (function) | Callback function called every 'letter'. See `Callback functions` below.
callbackFinished | `null` (function) | Callback function called once everything is finished. See `Callback functions` below.

Methods
-------
Expand Down Expand Up @@ -150,16 +151,15 @@ callbackType: function( letter, current, teletype ) {

Callback function called immediately once the teletype process is entirely finished.

There are no parameters.
The single parameter `teletype` returns the teletype object itself.

```
callbackFinished: function() {
alert('Nothing left to type!');
callbackFinished: function( teletype ) {
alert( 'Nothing left to type!' );
}
```

Minification
---

The Minified version of this script was provided by UglifyJS 2 - an online version can be found at <http://gpbmike.github.io/refresh-sf/>.

17 changes: 9 additions & 8 deletions jquery.teletype.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Teletype jQuery Plugin
* @version 0.1.5
* @version 0.1.6
*
* @author Steve Whiteley
* @see http://teletype.rocks
* @see https://github.com/stvwhtly/jquery-teletype-plugin
*
* Copyright (c) 2014 Steve Whiteley
* Copyright (c) 2015 Steve Whiteley
* Dual licensed under the MIT or GPL Version 2 licenses.
*
*/
Expand All @@ -32,7 +32,7 @@
}
}
current.position = 0;
current.string = settings.text[current.index];
setCurrentString();
if ( typeof( settings.callbackNext ) == 'function' ) {
settings.callbackNext( current, object );
}
Expand Down Expand Up @@ -91,10 +91,8 @@
window.setTimeout( function() {
window.setTimeout( type, delay( settings.typeDelay ) );
}, settings.delay );
} else {
if ( typeof( settings.callbackFinished ) == 'function' ) {
settings.callbackFinished();
}
} else if ( typeof( settings.callbackFinished ) == 'function' ) {
settings.callbackFinished( object );
}
}
if ( typeof( settings.callbackType ) == 'function' ) {
Expand Down Expand Up @@ -127,11 +125,14 @@
}
return time;
};
var setCurrentString = function() {
current.string = settings.text[current.index].replace(/\n/g, "\\n");
}
this.setCursor = function( cursor ) {
$('.teletype-cursor', self).text( cursor );
};
return this.each( function() {
current.string = settings.text[current.index];
setCurrentString();
self.addClass( 'teletype' ).empty();
output = $( '<span />' ).addClass( 'teletype-text' ).appendTo( self );
if ( settings.cursor ) {
Expand Down
2 changes: 1 addition & 1 deletion jquery.teletype.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 120e48e

Please sign in to comment.