Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added option tapeColor #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ There are some options that are available to you as well:
typeDelay : 200,
clearOnHighlight : true,
typerDataAttr : 'data-typer-targets',
typerInterval : 2000
typerInterval : 2000,
tapeColor : 'auto' // 'auto' or a css color value
}
```

Expand Down
7 changes: 4 additions & 3 deletions src/jquery.typer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ String.prototype.rightChars = function(n){
typeDelay : 200,
clearOnHighlight : true,
typerDataAttr : 'data-typer-targets',
typerInterval : 2000
typerInterval : 2000,
tapeColor : 'auto'
},
highlight,
clearText,
Expand Down Expand Up @@ -130,7 +131,7 @@ String.prototype.rightChars = function(n){
.append(
spanWithColor(
$e.data('backgroundColor'),
$e.data('primaryColor')
$.typer.options.tapeColor === 'auto' ? $e.data('primaryColor') : $.typer.options.tapeColor
)
.append(highlightedText)
)
Expand Down Expand Up @@ -224,7 +225,7 @@ String.prototype.rightChars = function(n){
$e.data('oldRight', currentText.rightChars(j - 1));
$e.data('leftStop', i);
$e.data('rightStop', currentText.length - j);
$e.data('primaryColor', $e.css('color'));
$e.data('primaryColor', $.typer.options.tapeColor === 'auto' ? $e.data('primaryColor') : $.typer.options.tapeColor);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the second condition be $e.css('color') as in the original implementation?

$e.data('backgroundColor', $e.css('background-color'));
$e.data('text', newString);
highlight($e);
Expand Down
20 changes: 18 additions & 2 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@
<html>
<head>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/src/jquery.typer.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="src/jquery.typer.js"></script>
<style type="text/css">
h3 { color: blue; }
.cyan { background-color: cyan; padding: 1em; }
</style>
<body>

<h1>Hello, World!</h1>
<h2 data-typer-targets="Hello,Hi,Hola,Hallo,Haai,Ola,Kaixo,Moni,Aloha,Bonjour,Ciao,Hej">Welcome</h2>

<h2 data-typer-targets="abcdefgfedcba,afgfa">Welcome</h2>

<h3 data-typer-targets="foobar,lorem,ipsum">Hello World!</h3>

<div class="cyan">
<h3 data-typer-targets="foobar,lorem,ipsum">Hello World!</h3>
</div>

<p id="test"></p>

<script>
$(function () {
$.typer.options.tapeColor = 'orange';
//$.typer.options.tapeColor = '#ff9900';
$('[data-typer-targets]').typer();

$('#test').typeTo('Hello World');
});
</script>
</body>
Expand Down