typedjsrails 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/typedjsrails.rb +5 -0
- data/lib/typedjsrails/version.rb +3 -0
- data/typedjsrails.gemspec +24 -0
- data/vendor/assets/javascripts/typed.js +434 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c22962dd33abdacb7ab6f6bfc39e5a15fd39d3a7
|
4
|
+
data.tar.gz: 65f04c31166977bccfd9206fd45fba49f85b86ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f581a76d6f2651ae29ece47f91cf8933b1d24c78a3cc2bdb8c26c0fe580d160bbc70b38ff6299b6c67a2d5b2fca90fcc9e6b70dc50c38d3e048631207fa24d5
|
7
|
+
data.tar.gz: ad4b6e01f8c41bc6ce790c22c03f7955f444bd711f4c29c2c1d5a5bba20cf626504ad6b65a3cbc731a55009ddd968acd14e57dee3b1c1c3ae0354805d5439ef3
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Rahul Lakhaney
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Typed.js Gem
|
2
|
+
|
3
|
+
[Developed by Matt Boldt](http://www.mattboldt.com)
|
4
|
+
Typed.js is a jQuery plugin that types. Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set.
|
5
|
+
|
6
|
+
[View the official Demo here](http://www.mattboldt.com/demos/typed-js/)
|
7
|
+
[View the demo on my website](http://www.codebrew.io)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'typedjs'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install typedjs
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
To your ```application.js``` file, add:
|
28
|
+
```Javascript
|
29
|
+
//= require typedjs
|
30
|
+
```
|
31
|
+
|
32
|
+
This is all you need to get going:
|
33
|
+
```Javascript
|
34
|
+
<script>
|
35
|
+
$(function(){
|
36
|
+
$(".element").typed({
|
37
|
+
strings: ["First sentence.", "Second sentence."],
|
38
|
+
typeSpeed: 0
|
39
|
+
});
|
40
|
+
});
|
41
|
+
</script>
|
42
|
+
...
|
43
|
+
|
44
|
+
<span class="element"></span>
|
45
|
+
```
|
46
|
+
|
47
|
+
## Customizations
|
48
|
+
|
49
|
+
[Visit the official typed.js repo for customizations and a more detailed usage guide.](https://github.com/mattboldt/typed.js/)
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rahullakhaney/typedjs.
|
54
|
+
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "typedjsrails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/typedjsrails.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'typedjsrails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "typedjsrails"
|
8
|
+
spec.version = Typedjsrails::VERSION
|
9
|
+
spec.authors = ["Rahul Lakhaney"]
|
10
|
+
spec.email = ["rahul.lakhaney@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gem for the typedjs library by Matt Boldt}
|
13
|
+
spec.description = %q{Typed.js is a jQuery plugin that types. Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set.}
|
14
|
+
spec.homepage = "https://github.com/rahullakhaney/typedjsrails"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
@@ -0,0 +1,434 @@
|
|
1
|
+
// The MIT License (MIT)
|
2
|
+
|
3
|
+
// Typed.js | Copyright (c) 2014 Matt Boldt | www.mattboldt.com
|
4
|
+
|
5
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
// of this software and associated documentation files (the "Software"), to deal
|
7
|
+
// in the Software without restriction, including without limitation the rights
|
8
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
// copies of the Software, and to permit persons to whom the Software is
|
10
|
+
// furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
// The above copyright notice and this permission notice shall be included in
|
13
|
+
// all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
// THE SOFTWARE.
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
! function($) {
|
27
|
+
|
28
|
+
"use strict";
|
29
|
+
|
30
|
+
var Typed = function(el, options) {
|
31
|
+
|
32
|
+
// chosen element to manipulate text
|
33
|
+
this.el = $(el);
|
34
|
+
|
35
|
+
// options
|
36
|
+
this.options = $.extend({}, $.fn.typed.defaults, options);
|
37
|
+
|
38
|
+
// attribute to type into
|
39
|
+
this.isInput = this.el.is('input');
|
40
|
+
this.attr = this.options.attr;
|
41
|
+
|
42
|
+
// show cursor
|
43
|
+
this.showCursor = this.isInput ? false : this.options.showCursor;
|
44
|
+
|
45
|
+
// text content of element
|
46
|
+
this.elContent = this.attr ? this.el.attr(this.attr) : this.el.text()
|
47
|
+
|
48
|
+
// html or plain text
|
49
|
+
this.contentType = this.options.contentType;
|
50
|
+
|
51
|
+
// typing speed
|
52
|
+
this.typeSpeed = this.options.typeSpeed;
|
53
|
+
|
54
|
+
// add a delay before typing starts
|
55
|
+
this.startDelay = this.options.startDelay;
|
56
|
+
|
57
|
+
// backspacing speed
|
58
|
+
this.backSpeed = this.options.backSpeed;
|
59
|
+
|
60
|
+
// amount of time to wait before backspacing
|
61
|
+
this.backDelay = this.options.backDelay;
|
62
|
+
|
63
|
+
// div containing strings
|
64
|
+
this.stringsElement = this.options.stringsElement;
|
65
|
+
|
66
|
+
// input strings of text
|
67
|
+
this.strings = this.options.strings;
|
68
|
+
|
69
|
+
// character number position of current string
|
70
|
+
this.strPos = 0;
|
71
|
+
|
72
|
+
// current array position
|
73
|
+
this.arrayPos = 0;
|
74
|
+
|
75
|
+
// number to stop backspacing on.
|
76
|
+
// default 0, can change depending on how many chars
|
77
|
+
// you want to remove at the time
|
78
|
+
this.stopNum = 0;
|
79
|
+
|
80
|
+
// Looping logic
|
81
|
+
this.loop = this.options.loop;
|
82
|
+
this.loopCount = this.options.loopCount;
|
83
|
+
this.curLoop = 0;
|
84
|
+
|
85
|
+
// for stopping
|
86
|
+
this.stop = false;
|
87
|
+
|
88
|
+
// custom cursor
|
89
|
+
this.cursorChar = this.options.cursorChar;
|
90
|
+
|
91
|
+
// shuffle the strings
|
92
|
+
this.shuffle = this.options.shuffle;
|
93
|
+
// the order of strings
|
94
|
+
this.sequence = [];
|
95
|
+
|
96
|
+
// All systems go!
|
97
|
+
this.build();
|
98
|
+
};
|
99
|
+
|
100
|
+
Typed.prototype = {
|
101
|
+
|
102
|
+
constructor: Typed
|
103
|
+
|
104
|
+
,
|
105
|
+
init: function() {
|
106
|
+
// begin the loop w/ first current string (global self.strings)
|
107
|
+
// current string will be passed as an argument each time after this
|
108
|
+
var self = this;
|
109
|
+
self.timeout = setTimeout(function() {
|
110
|
+
for (var i=0;i<self.strings.length;++i) self.sequence[i]=i;
|
111
|
+
|
112
|
+
// shuffle the array if true
|
113
|
+
if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
|
114
|
+
|
115
|
+
// Start typing
|
116
|
+
self.typewrite(self.strings[self.sequence[self.arrayPos]], self.strPos);
|
117
|
+
}, self.startDelay);
|
118
|
+
}
|
119
|
+
|
120
|
+
,
|
121
|
+
build: function() {
|
122
|
+
var self = this;
|
123
|
+
// Insert cursor
|
124
|
+
if (this.showCursor === true) {
|
125
|
+
this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
|
126
|
+
this.el.after(this.cursor);
|
127
|
+
}
|
128
|
+
if (this.stringsElement) {
|
129
|
+
self.strings = [];
|
130
|
+
this.stringsElement.hide();
|
131
|
+
var strings = this.stringsElement.find('p');
|
132
|
+
$.each(strings, function(key, value){
|
133
|
+
self.strings.push($(value).html());
|
134
|
+
});
|
135
|
+
}
|
136
|
+
this.init();
|
137
|
+
}
|
138
|
+
|
139
|
+
// pass current string state to each function, types 1 char per call
|
140
|
+
,
|
141
|
+
typewrite: function(curString, curStrPos) {
|
142
|
+
// exit when stopped
|
143
|
+
if (this.stop === true) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
|
147
|
+
// varying values for setTimeout during typing
|
148
|
+
// can't be global since number changes each time loop is executed
|
149
|
+
var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
|
150
|
+
var self = this;
|
151
|
+
|
152
|
+
// ------------- optional ------------- //
|
153
|
+
// backpaces a certain string faster
|
154
|
+
// ------------------------------------ //
|
155
|
+
// if (self.arrayPos == 1){
|
156
|
+
// self.backDelay = 50;
|
157
|
+
// }
|
158
|
+
// else{ self.backDelay = 500; }
|
159
|
+
|
160
|
+
// contain typing function in a timeout humanize'd delay
|
161
|
+
self.timeout = setTimeout(function() {
|
162
|
+
// check for an escape character before a pause value
|
163
|
+
// format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
|
164
|
+
// single ^ are removed from string
|
165
|
+
var charPause = 0;
|
166
|
+
var substr = curString.substr(curStrPos);
|
167
|
+
if (substr.charAt(0) === '^') {
|
168
|
+
var skip = 1; // skip atleast 1
|
169
|
+
if (/^\^\d+/.test(substr)) {
|
170
|
+
substr = /\d+/.exec(substr)[0];
|
171
|
+
skip += substr.length;
|
172
|
+
charPause = parseInt(substr);
|
173
|
+
}
|
174
|
+
|
175
|
+
// strip out the escape character and pause value so they're not printed
|
176
|
+
curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip);
|
177
|
+
}
|
178
|
+
|
179
|
+
if (self.contentType === 'html') {
|
180
|
+
// skip over html tags while typing
|
181
|
+
var curChar = curString.substr(curStrPos).charAt(0)
|
182
|
+
if (curChar === '<' || curChar === '&') {
|
183
|
+
var tag = '';
|
184
|
+
var endTag = '';
|
185
|
+
if (curChar === '<') {
|
186
|
+
endTag = '>'
|
187
|
+
} else {
|
188
|
+
endTag = ';'
|
189
|
+
}
|
190
|
+
while (curString.substr(curStrPos).charAt(0) !== endTag) {
|
191
|
+
tag += curString.substr(curStrPos).charAt(0);
|
192
|
+
curStrPos++;
|
193
|
+
}
|
194
|
+
curStrPos++;
|
195
|
+
tag += endTag;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
// timeout for any pause after a character
|
200
|
+
self.timeout = setTimeout(function() {
|
201
|
+
if (curStrPos === curString.length) {
|
202
|
+
// fires callback function
|
203
|
+
self.options.onStringTyped(self.arrayPos);
|
204
|
+
|
205
|
+
// is this the final string
|
206
|
+
if (self.arrayPos === self.strings.length - 1) {
|
207
|
+
// animation that occurs on the last typed string
|
208
|
+
self.options.callback();
|
209
|
+
|
210
|
+
self.curLoop++;
|
211
|
+
|
212
|
+
// quit if we wont loop back
|
213
|
+
if (self.loop === false || self.curLoop === self.loopCount)
|
214
|
+
return;
|
215
|
+
}
|
216
|
+
|
217
|
+
self.timeout = setTimeout(function() {
|
218
|
+
self.backspace(curString, curStrPos);
|
219
|
+
}, self.backDelay);
|
220
|
+
} else {
|
221
|
+
|
222
|
+
/* call before functions if applicable */
|
223
|
+
if (curStrPos === 0)
|
224
|
+
self.options.preStringTyped(self.arrayPos);
|
225
|
+
|
226
|
+
// start typing each new char into existing string
|
227
|
+
// curString: arg, self.el.html: original text inside element
|
228
|
+
var nextString = curString.substr(0, curStrPos + 1);
|
229
|
+
if (self.attr) {
|
230
|
+
self.el.attr(self.attr, nextString);
|
231
|
+
} else {
|
232
|
+
if (self.isInput) {
|
233
|
+
self.el.val(nextString);
|
234
|
+
} else if (self.contentType === 'html') {
|
235
|
+
self.el.html(nextString);
|
236
|
+
} else {
|
237
|
+
self.el.text(nextString);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
// add characters one by one
|
242
|
+
curStrPos++;
|
243
|
+
// loop the function
|
244
|
+
self.typewrite(curString, curStrPos);
|
245
|
+
}
|
246
|
+
// end of character pause
|
247
|
+
}, charPause);
|
248
|
+
|
249
|
+
// humanized value for typing
|
250
|
+
}, humanize);
|
251
|
+
|
252
|
+
}
|
253
|
+
|
254
|
+
,
|
255
|
+
backspace: function(curString, curStrPos) {
|
256
|
+
// exit when stopped
|
257
|
+
if (this.stop === true) {
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
|
261
|
+
// varying values for setTimeout during typing
|
262
|
+
// can't be global since number changes each time loop is executed
|
263
|
+
var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
|
264
|
+
var self = this;
|
265
|
+
|
266
|
+
self.timeout = setTimeout(function() {
|
267
|
+
|
268
|
+
// ----- this part is optional ----- //
|
269
|
+
// check string array position
|
270
|
+
// on the first string, only delete one word
|
271
|
+
// the stopNum actually represents the amount of chars to
|
272
|
+
// keep in the current string. In my case it's 14.
|
273
|
+
// if (self.arrayPos == 1){
|
274
|
+
// self.stopNum = 14;
|
275
|
+
// }
|
276
|
+
//every other time, delete the whole typed string
|
277
|
+
// else{
|
278
|
+
// self.stopNum = 0;
|
279
|
+
// }
|
280
|
+
|
281
|
+
if (self.contentType === 'html') {
|
282
|
+
// skip over html tags while backspacing
|
283
|
+
if (curString.substr(curStrPos).charAt(0) === '>') {
|
284
|
+
var tag = '';
|
285
|
+
while (curString.substr(curStrPos).charAt(0) !== '<') {
|
286
|
+
tag -= curString.substr(curStrPos).charAt(0);
|
287
|
+
curStrPos--;
|
288
|
+
}
|
289
|
+
curStrPos--;
|
290
|
+
tag += '<';
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
// ----- continue important stuff ----- //
|
295
|
+
// replace text with base text + typed characters
|
296
|
+
var nextString = curString.substr(0, curStrPos);
|
297
|
+
if (self.attr) {
|
298
|
+
self.el.attr(self.attr, nextString);
|
299
|
+
} else {
|
300
|
+
if (self.isInput) {
|
301
|
+
self.el.val(nextString);
|
302
|
+
} else if (self.contentType === 'html') {
|
303
|
+
self.el.html(nextString);
|
304
|
+
} else {
|
305
|
+
self.el.text(nextString);
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
// if the number (id of character in current string) is
|
310
|
+
// less than the stop number, keep going
|
311
|
+
if (curStrPos > self.stopNum) {
|
312
|
+
// subtract characters one by one
|
313
|
+
curStrPos--;
|
314
|
+
// loop the function
|
315
|
+
self.backspace(curString, curStrPos);
|
316
|
+
}
|
317
|
+
// if the stop number has been reached, increase
|
318
|
+
// array position to next string
|
319
|
+
else if (curStrPos <= self.stopNum) {
|
320
|
+
self.arrayPos++;
|
321
|
+
|
322
|
+
if (self.arrayPos === self.strings.length) {
|
323
|
+
self.arrayPos = 0;
|
324
|
+
|
325
|
+
// Shuffle sequence again
|
326
|
+
if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
|
327
|
+
|
328
|
+
self.init();
|
329
|
+
} else
|
330
|
+
self.typewrite(self.strings[self.sequence[self.arrayPos]], curStrPos);
|
331
|
+
}
|
332
|
+
|
333
|
+
// humanized value for typing
|
334
|
+
}, humanize);
|
335
|
+
|
336
|
+
}
|
337
|
+
/**
|
338
|
+
* Shuffles the numbers in the given array.
|
339
|
+
* @param {Array} array
|
340
|
+
* @returns {Array}
|
341
|
+
*/
|
342
|
+
,shuffleArray: function(array) {
|
343
|
+
var tmp, current, top = array.length;
|
344
|
+
if(top) while(--top) {
|
345
|
+
current = Math.floor(Math.random() * (top + 1));
|
346
|
+
tmp = array[current];
|
347
|
+
array[current] = array[top];
|
348
|
+
array[top] = tmp;
|
349
|
+
}
|
350
|
+
return array;
|
351
|
+
}
|
352
|
+
|
353
|
+
// Start & Stop currently not working
|
354
|
+
|
355
|
+
// , stop: function() {
|
356
|
+
// var self = this;
|
357
|
+
|
358
|
+
// self.stop = true;
|
359
|
+
// clearInterval(self.timeout);
|
360
|
+
// }
|
361
|
+
|
362
|
+
// , start: function() {
|
363
|
+
// var self = this;
|
364
|
+
// if(self.stop === false)
|
365
|
+
// return;
|
366
|
+
|
367
|
+
// this.stop = false;
|
368
|
+
// this.init();
|
369
|
+
// }
|
370
|
+
|
371
|
+
// Reset and rebuild the element
|
372
|
+
,
|
373
|
+
reset: function() {
|
374
|
+
var self = this;
|
375
|
+
clearInterval(self.timeout);
|
376
|
+
var id = this.el.attr('id');
|
377
|
+
this.el.after('<span id="' + id + '"/>')
|
378
|
+
this.el.remove();
|
379
|
+
if (typeof this.cursor !== 'undefined') {
|
380
|
+
this.cursor.remove();
|
381
|
+
}
|
382
|
+
// Send the callback
|
383
|
+
self.options.resetCallback();
|
384
|
+
}
|
385
|
+
|
386
|
+
};
|
387
|
+
|
388
|
+
$.fn.typed = function(option) {
|
389
|
+
return this.each(function() {
|
390
|
+
var $this = $(this),
|
391
|
+
data = $this.data('typed'),
|
392
|
+
options = typeof option == 'object' && option;
|
393
|
+
if (!data) $this.data('typed', (data = new Typed(this, options)));
|
394
|
+
if (typeof option == 'string') data[option]();
|
395
|
+
});
|
396
|
+
};
|
397
|
+
|
398
|
+
$.fn.typed.defaults = {
|
399
|
+
strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
|
400
|
+
stringsElement: null,
|
401
|
+
// typing speed
|
402
|
+
typeSpeed: 0,
|
403
|
+
// time before typing starts
|
404
|
+
startDelay: 0,
|
405
|
+
// backspacing speed
|
406
|
+
backSpeed: 0,
|
407
|
+
// shuffle the strings
|
408
|
+
shuffle: false,
|
409
|
+
// time before backspacing
|
410
|
+
backDelay: 500,
|
411
|
+
// loop
|
412
|
+
loop: false,
|
413
|
+
// false = infinite
|
414
|
+
loopCount: false,
|
415
|
+
// show cursor
|
416
|
+
showCursor: true,
|
417
|
+
// character for cursor
|
418
|
+
cursorChar: "|",
|
419
|
+
// attribute to type (null == text)
|
420
|
+
attr: null,
|
421
|
+
// either html or text
|
422
|
+
contentType: 'html',
|
423
|
+
// call when done callback function
|
424
|
+
callback: function() {},
|
425
|
+
// starting callback function before each string
|
426
|
+
preStringTyped: function() {},
|
427
|
+
//callback for every typed string
|
428
|
+
onStringTyped: function() {},
|
429
|
+
// callback for reset
|
430
|
+
resetCallback: function() {}
|
431
|
+
};
|
432
|
+
|
433
|
+
|
434
|
+
}(window.jQuery);
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: typedjsrails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rahul Lakhaney
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Typed.js is a jQuery plugin that types. Enter in any string, and watch
|
42
|
+
it type at the speed you've set, backspace what it's typed, and begin a new sentence
|
43
|
+
for however many strings you've set.
|
44
|
+
email:
|
45
|
+
- rahul.lakhaney@gmail.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- ".travis.yml"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- lib/typedjsrails.rb
|
59
|
+
- lib/typedjsrails/version.rb
|
60
|
+
- typedjsrails.gemspec
|
61
|
+
- vendor/assets/javascripts/typed.js
|
62
|
+
homepage: https://github.com/rahullakhaney/typedjsrails
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.4.5.1
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Gem for the typedjs library by Matt Boldt
|
86
|
+
test_files: []
|