typedjs-rails 1.0.4 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b22c296e5c40e944c8e4026e20dd550177cddf2e
4
- data.tar.gz: e63e005b8ad935e1e184454bb6a157759f4ee4b4
3
+ metadata.gz: 976782d6183cd396e7a8419c475616205287260d
4
+ data.tar.gz: ac2969b4fba2de726a1154d7ca25d5d643d3b671
5
5
  SHA512:
6
- metadata.gz: e1bdb70776c70196394129b3dcdd25e20508aa689be1e41f8ef6de5652e2a099000203e3236c69a7dfab6dcfd9bc4d77566aa961eb6b349c954aea5378e5d6cd
7
- data.tar.gz: fc9d1a774d72689545df98e6c4d5eeb0662617bdd2b458986e120c92443d5d3af4e7576abd9fc6756be6ee29d1113c0bf0b5061fcc74cbd99ffd95ec7476e9d7
6
+ metadata.gz: a47b592e8c22936ee2c1b5cbae55e0676c34b94a8a57ab877f0e56d99a0c586614c28d55dc642cf4c945623aa402d432876e9af194c348fe616bfd95350307a0
7
+ data.tar.gz: 1fd902688d47ba18d6aff2abde73ec8a5193028b01bf7da9c469f3d8b56f1c32a4131a0405cc85f8e39aa7c6890eb5863a056767444127a51ba5d75790d6afb2
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # typedjs-rails
2
2
  This gem just includes [Typed.js](https://github.com/mattboldt/typed.js) as an asset in the Rails 3.1 (or newer) asset pipeline.
3
3
 
4
- The current version in the gem is Typed.js 1.1.4
4
+ The current version in the gem is Typed.js 2.0.9
5
5
 
6
6
  ## Installation
7
7
 
8
8
  Add the gem to the Gemfile
9
9
 
10
- gem "typedjs-rails", "~> 1.0.4"
10
+ gem "typedjs-rails", "~> 2.0.9"
11
11
 
12
12
  ## Usage
13
13
 
@@ -1,438 +1,1045 @@
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
- init: function() {
105
- // begin the loop w/ first current string (global self.strings)
106
- // current string will be passed as an argument each time after this
107
- var self = this;
108
- self.timeout = setTimeout(function() {
109
- for (var i=0;i<self.strings.length;++i) self.sequence[i]=i;
110
-
111
- // shuffle the array if true
112
- if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
113
-
114
- // Start typing
115
- self.typewrite(self.strings[self.sequence[self.arrayPos]], self.strPos);
116
- }, self.startDelay);
117
- },
118
-
119
- build: function() {
120
- var self = this;
121
- // Insert cursor
122
- if (this.showCursor === true) {
123
- this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
124
- this.el.after(this.cursor);
125
- }
126
- if (this.stringsElement) {
127
- this.strings = [];
128
- this.stringsElement.hide();
129
- console.log(this.stringsElement.children());
130
- var strings = this.stringsElement.children();
131
- $.each(strings, function(key, value){
132
- self.strings.push($(value).html());
133
- });
134
- }
135
- this.init();
136
- },
137
-
138
- // pass current string state to each function, types 1 char per call
139
- typewrite: function(curString, curStrPos) {
140
- // exit when stopped
141
- if (this.stop === true) {
142
- return;
143
- }
144
-
145
- // varying values for setTimeout during typing
146
- // can't be global since number changes each time loop is executed
147
- var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
148
- var self = this;
149
-
150
- // ------------- optional ------------- //
151
- // backpaces a certain string faster
152
- // ------------------------------------ //
153
- // if (self.arrayPos == 1){
154
- // self.backDelay = 50;
155
- // }
156
- // else{ self.backDelay = 500; }
157
-
158
- // contain typing function in a timeout humanize'd delay
159
- self.timeout = setTimeout(function() {
160
- // check for an escape character before a pause value
161
- // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
162
- // single ^ are removed from string
163
- var charPause = 0;
164
- var substr = curString.substr(curStrPos);
165
- if (substr.charAt(0) === '^') {
166
- var skip = 1; // skip atleast 1
167
- if (/^\^\d+/.test(substr)) {
168
- substr = /\d+/.exec(substr)[0];
169
- skip += substr.length;
170
- charPause = parseInt(substr);
171
- }
172
-
173
- // strip out the escape character and pause value so they're not printed
174
- curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip);
175
- }
176
-
177
- if (self.contentType === 'html') {
178
- // skip over html tags while typing
179
- var curChar = curString.substr(curStrPos).charAt(0)
180
- if (curChar === '<' || curChar === '&') {
181
- var tag = '';
182
- var endTag = '';
183
- if (curChar === '<') {
184
- endTag = '>'
185
- }
186
- else {
187
- endTag = ';'
188
- }
189
- while (curString.substr(curStrPos + 1).charAt(0) !== endTag) {
190
- tag += curString.substr(curStrPos).charAt(0);
191
- curStrPos++;
192
- if (curStrPos + 1 > curString.length) { break; }
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
-
221
- } else {
222
-
223
- /* call before functions if applicable */
224
- if (curStrPos === 0) {
225
- self.options.preStringTyped(self.arrayPos);
226
- }
227
-
228
- // start typing each new char into existing string
229
- // curString: arg, self.el.html: original text inside element
230
- var nextString = curString.substr(0, curStrPos + 1);
231
- if (self.attr) {
232
- self.el.attr(self.attr, nextString);
233
- } else {
234
- if (self.isInput) {
235
- self.el.val(nextString);
236
- } else if (self.contentType === 'html') {
237
- self.el.html(nextString);
238
- } else {
239
- self.el.text(nextString);
240
- }
241
- }
242
-
243
- // add characters one by one
244
- curStrPos++;
245
- // loop the function
246
- self.typewrite(curString, curStrPos);
247
- }
248
- // end of character pause
249
- }, charPause);
250
-
251
- // humanized value for typing
252
- }, humanize);
253
-
254
- },
255
-
256
- backspace: function(curString, curStrPos) {
257
- // exit when stopped
258
- if (this.stop === true) {
259
- return;
260
- }
261
-
262
- // varying values for setTimeout during typing
263
- // can't be global since number changes each time loop is executed
264
- var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
265
- var self = this;
266
-
267
- self.timeout = setTimeout(function() {
268
-
269
- // ----- this part is optional ----- //
270
- // check string array position
271
- // on the first string, only delete one word
272
- // the stopNum actually represents the amount of chars to
273
- // keep in the current string. In my case it's 14.
274
- // if (self.arrayPos == 1){
275
- // self.stopNum = 14;
276
- // }
277
- //every other time, delete the whole typed string
278
- // else{
279
- // self.stopNum = 0;
280
- // }
281
-
282
- if (self.contentType === 'html') {
283
- // skip over html tags while backspacing
284
- if (curString.substr(curStrPos).charAt(0) === '>') {
285
- var tag = '';
286
- while (curString.substr(curStrPos - 1).charAt(0) !== '<') {
287
- tag -= curString.substr(curStrPos).charAt(0);
288
- curStrPos--;
289
- if (curStrPos < 0) { break; }
290
- }
291
- curStrPos--;
292
- tag += '<';
293
- }
294
- }
295
-
296
- // ----- continue important stuff ----- //
297
- // replace text with base text + typed characters
298
- var nextString = curString.substr(0, curStrPos);
299
- if (self.attr) {
300
- self.el.attr(self.attr, nextString);
301
- } else {
302
- if (self.isInput) {
303
- self.el.val(nextString);
304
- } else if (self.contentType === 'html') {
305
- self.el.html(nextString);
306
- } else {
307
- self.el.text(nextString);
308
- }
309
- }
310
-
311
- // if the number (id of character in current string) is
312
- // less than the stop number, keep going
313
- if (curStrPos > self.stopNum) {
314
- // subtract characters one by one
315
- curStrPos--;
316
- // loop the function
317
- self.backspace(curString, curStrPos);
318
- }
319
- // if the stop number has been reached, increase
320
- // array position to next string
321
- else if (curStrPos <= self.stopNum) {
322
- self.arrayPos++;
323
-
324
- if (self.arrayPos === self.strings.length) {
325
- self.arrayPos = 0;
326
-
327
- // Shuffle sequence again
328
- if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
329
-
330
- self.init();
331
- } else
332
- self.typewrite(self.strings[self.sequence[self.arrayPos]], curStrPos);
333
- }
334
-
335
- // humanized value for typing
336
- }, humanize);
337
-
338
- },
339
- /**
340
- * Shuffles the numbers in the given array.
341
- * @param {Array} array
342
- * @returns {Array}
343
- */
344
- shuffleArray: function(array) {
345
- var tmp, current, top = array.length;
346
- if(top) while(--top) {
347
- current = Math.floor(Math.random() * (top + 1));
348
- tmp = array[current];
349
- array[current] = array[top];
350
- array[top] = tmp;
351
- }
352
- return array;
353
- },
354
-
355
- // Start & Stop currently not working
356
-
357
- // , stop: function() {
358
- // var self = this;
359
-
360
- // self.stop = true;
361
- // clearInterval(self.timeout);
362
- // }
363
-
364
- // , start: function() {
365
- // var self = this;
366
- // if(self.stop === false)
367
- // return;
368
-
369
- // this.stop = false;
370
- // this.init();
371
- // }
372
-
373
- // Reset and rebuild the element
374
- reset: function() {
375
- var self = this;
376
- clearInterval(self.timeout);
377
- var id = this.el.attr('id');
378
- this.el.empty();
379
- if (typeof this.cursor !== 'undefined') {
380
- this.cursor.remove();
381
- }
382
- this.strPos = 0;
383
- this.arrayPos = 0;
384
- this.curLoop = 0;
385
- // Send the callback
386
- this.options.resetCallback();
387
- }
388
-
389
- };
390
-
391
- $.fn.typed = function(option) {
392
- return this.each(function() {
393
- var $this = $(this),
394
- data = $this.data('typed'),
395
- options = typeof option == 'object' && option;
396
- if (data) { data.reset(); }
397
- $this.data('typed', (data = new Typed(this, options)));
398
- if (typeof option == 'string') data[option]();
399
- });
400
- };
401
-
402
- $.fn.typed.defaults = {
403
- strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
404
- stringsElement: null,
405
- // typing speed
406
- typeSpeed: 0,
407
- // time before typing starts
408
- startDelay: 0,
409
- // backspacing speed
410
- backSpeed: 0,
411
- // shuffle the strings
412
- shuffle: false,
413
- // time before backspacing
414
- backDelay: 500,
415
- // loop
416
- loop: false,
417
- // false = infinite
418
- loopCount: false,
419
- // show cursor
420
- showCursor: true,
421
- // character for cursor
422
- cursorChar: "|",
423
- // attribute to type (null == text)
424
- attr: null,
425
- // either html or text
426
- contentType: 'html',
427
- // call when done callback function
428
- callback: function() {},
429
- // starting callback function before each string
430
- preStringTyped: function() {},
431
- //callback for every typed string
432
- onStringTyped: function() {},
433
- // callback for reset
434
- resetCallback: function() {}
435
- };
436
-
437
-
438
- }(window.jQuery);
1
+ /*!
2
+ *
3
+ * typed.js - A JavaScript Typing Animation Library
4
+ * Author: Matt Boldt <me@mattboldt.com>
5
+ * Version: v2.0.9
6
+ * Url: https://github.com/mattboldt/typed.js
7
+ * License(s): MIT
8
+ *
9
+ */
10
+ (function webpackUniversalModuleDefinition(root, factory) {
11
+ if(typeof exports === 'object' && typeof module === 'object')
12
+ module.exports = factory();
13
+ else if(typeof define === 'function' && define.amd)
14
+ define([], factory);
15
+ else if(typeof exports === 'object')
16
+ exports["Typed"] = factory();
17
+ else
18
+ root["Typed"] = factory();
19
+ })(this, function() {
20
+ return /******/ (function(modules) { // webpackBootstrap
21
+ /******/ // The module cache
22
+ /******/ var installedModules = {};
23
+ /******/
24
+ /******/ // The require function
25
+ /******/ function __webpack_require__(moduleId) {
26
+ /******/
27
+ /******/ // Check if module is in cache
28
+ /******/ if(installedModules[moduleId])
29
+ /******/ return installedModules[moduleId].exports;
30
+ /******/
31
+ /******/ // Create a new module (and put it into the cache)
32
+ /******/ var module = installedModules[moduleId] = {
33
+ /******/ exports: {},
34
+ /******/ id: moduleId,
35
+ /******/ loaded: false
36
+ /******/ };
37
+ /******/
38
+ /******/ // Execute the module function
39
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
40
+ /******/
41
+ /******/ // Flag the module as loaded
42
+ /******/ module.loaded = true;
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /******/
49
+ /******/ // expose the modules object (__webpack_modules__)
50
+ /******/ __webpack_require__.m = modules;
51
+ /******/
52
+ /******/ // expose the module cache
53
+ /******/ __webpack_require__.c = installedModules;
54
+ /******/
55
+ /******/ // __webpack_public_path__
56
+ /******/ __webpack_require__.p = "";
57
+ /******/
58
+ /******/ // Load entry module and return exports
59
+ /******/ return __webpack_require__(0);
60
+ /******/ })
61
+ /************************************************************************/
62
+ /******/ ([
63
+ /* 0 */
64
+ /***/ (function(module, exports, __webpack_require__) {
65
+
66
+ 'use strict';
67
+
68
+ Object.defineProperty(exports, '__esModule', {
69
+ value: true
70
+ });
71
+
72
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
73
+
74
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
75
+
76
+ var _initializerJs = __webpack_require__(1);
77
+
78
+ var _htmlParserJs = __webpack_require__(3);
79
+
80
+ /**
81
+ * Welcome to Typed.js!
82
+ * @param {string} elementId HTML element ID _OR_ HTML element
83
+ * @param {object} options options object
84
+ * @returns {object} a new Typed object
85
+ */
86
+
87
+ var Typed = (function () {
88
+ function Typed(elementId, options) {
89
+ _classCallCheck(this, Typed);
90
+
91
+ // Initialize it up
92
+ _initializerJs.initializer.load(this, options, elementId);
93
+ // All systems go!
94
+ this.begin();
95
+ }
96
+
97
+ /**
98
+ * Toggle start() and stop() of the Typed instance
99
+ * @public
100
+ */
101
+
102
+ _createClass(Typed, [{
103
+ key: 'toggle',
104
+ value: function toggle() {
105
+ this.pause.status ? this.start() : this.stop();
106
+ }
107
+
108
+ /**
109
+ * Stop typing / backspacing and enable cursor blinking
110
+ * @public
111
+ */
112
+ }, {
113
+ key: 'stop',
114
+ value: function stop() {
115
+ if (this.typingComplete) return;
116
+ if (this.pause.status) return;
117
+ this.toggleBlinking(true);
118
+ this.pause.status = true;
119
+ this.options.onStop(this.arrayPos, this);
120
+ }
121
+
122
+ /**
123
+ * Start typing / backspacing after being stopped
124
+ * @public
125
+ */
126
+ }, {
127
+ key: 'start',
128
+ value: function start() {
129
+ if (this.typingComplete) return;
130
+ if (!this.pause.status) return;
131
+ this.pause.status = false;
132
+ if (this.pause.typewrite) {
133
+ this.typewrite(this.pause.curString, this.pause.curStrPos);
134
+ } else {
135
+ this.backspace(this.pause.curString, this.pause.curStrPos);
136
+ }
137
+ this.options.onStart(this.arrayPos, this);
138
+ }
139
+
140
+ /**
141
+ * Destroy this instance of Typed
142
+ * @public
143
+ */
144
+ }, {
145
+ key: 'destroy',
146
+ value: function destroy() {
147
+ this.reset(false);
148
+ this.options.onDestroy(this);
149
+ }
150
+
151
+ /**
152
+ * Reset Typed and optionally restarts
153
+ * @param {boolean} restart
154
+ * @public
155
+ */
156
+ }, {
157
+ key: 'reset',
158
+ value: function reset() {
159
+ var restart = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
160
+
161
+ clearInterval(this.timeout);
162
+ this.replaceText('');
163
+ if (this.cursor && this.cursor.parentNode) {
164
+ this.cursor.parentNode.removeChild(this.cursor);
165
+ this.cursor = null;
166
+ }
167
+ this.strPos = 0;
168
+ this.arrayPos = 0;
169
+ this.curLoop = 0;
170
+ if (restart) {
171
+ this.insertCursor();
172
+ this.options.onReset(this);
173
+ this.begin();
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Begins the typing animation
179
+ * @private
180
+ */
181
+ }, {
182
+ key: 'begin',
183
+ value: function begin() {
184
+ var _this = this;
185
+
186
+ this.typingComplete = false;
187
+ this.shuffleStringsIfNeeded(this);
188
+ this.insertCursor();
189
+ if (this.bindInputFocusEvents) this.bindFocusEvents();
190
+ this.timeout = setTimeout(function () {
191
+ // Check if there is some text in the element, if yes start by backspacing the default message
192
+ if (!_this.currentElContent || _this.currentElContent.length === 0) {
193
+ _this.typewrite(_this.strings[_this.sequence[_this.arrayPos]], _this.strPos);
194
+ } else {
195
+ // Start typing
196
+ _this.backspace(_this.currentElContent, _this.currentElContent.length);
197
+ }
198
+ }, this.startDelay);
199
+ }
200
+
201
+ /**
202
+ * Called for each character typed
203
+ * @param {string} curString the current string in the strings array
204
+ * @param {number} curStrPos the current position in the curString
205
+ * @private
206
+ */
207
+ }, {
208
+ key: 'typewrite',
209
+ value: function typewrite(curString, curStrPos) {
210
+ var _this2 = this;
211
+
212
+ if (this.fadeOut && this.el.classList.contains(this.fadeOutClass)) {
213
+ this.el.classList.remove(this.fadeOutClass);
214
+ if (this.cursor) this.cursor.classList.remove(this.fadeOutClass);
215
+ }
216
+
217
+ var humanize = this.humanizer(this.typeSpeed);
218
+ var numChars = 1;
219
+
220
+ if (this.pause.status === true) {
221
+ this.setPauseStatus(curString, curStrPos, true);
222
+ return;
223
+ }
224
+
225
+ // contain typing function in a timeout humanize'd delay
226
+ this.timeout = setTimeout(function () {
227
+ // skip over any HTML chars
228
+ curStrPos = _htmlParserJs.htmlParser.typeHtmlChars(curString, curStrPos, _this2);
229
+
230
+ var pauseTime = 0;
231
+ var substr = curString.substr(curStrPos);
232
+ // check for an escape character before a pause value
233
+ // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
234
+ // single ^ are removed from string
235
+ if (substr.charAt(0) === '^') {
236
+ if (/^\^\d+/.test(substr)) {
237
+ var skip = 1; // skip at least 1
238
+ substr = /\d+/.exec(substr)[0];
239
+ skip += substr.length;
240
+ pauseTime = parseInt(substr);
241
+ _this2.temporaryPause = true;
242
+ _this2.options.onTypingPaused(_this2.arrayPos, _this2);
243
+ // strip out the escape character and pause value so they're not printed
244
+ curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip);
245
+ _this2.toggleBlinking(true);
246
+ }
247
+ }
248
+
249
+ // check for skip characters formatted as
250
+ // "this is a `string to print NOW` ..."
251
+ if (substr.charAt(0) === '`') {
252
+ while (curString.substr(curStrPos + numChars).charAt(0) !== '`') {
253
+ numChars++;
254
+ if (curStrPos + numChars > curString.length) break;
255
+ }
256
+ // strip out the escape characters and append all the string in between
257
+ var stringBeforeSkip = curString.substring(0, curStrPos);
258
+ var stringSkipped = curString.substring(stringBeforeSkip.length + 1, curStrPos + numChars);
259
+ var stringAfterSkip = curString.substring(curStrPos + numChars + 1);
260
+ curString = stringBeforeSkip + stringSkipped + stringAfterSkip;
261
+ numChars--;
262
+ }
263
+
264
+ // timeout for any pause after a character
265
+ _this2.timeout = setTimeout(function () {
266
+ // Accounts for blinking while paused
267
+ _this2.toggleBlinking(false);
268
+
269
+ // We're done with this sentence!
270
+ if (curStrPos >= curString.length) {
271
+ _this2.doneTyping(curString, curStrPos);
272
+ } else {
273
+ _this2.keepTyping(curString, curStrPos, numChars);
274
+ }
275
+ // end of character pause
276
+ if (_this2.temporaryPause) {
277
+ _this2.temporaryPause = false;
278
+ _this2.options.onTypingResumed(_this2.arrayPos, _this2);
279
+ }
280
+ }, pauseTime);
281
+
282
+ // humanized value for typing
283
+ }, humanize);
284
+ }
285
+
286
+ /**
287
+ * Continue to the next string & begin typing
288
+ * @param {string} curString the current string in the strings array
289
+ * @param {number} curStrPos the current position in the curString
290
+ * @private
291
+ */
292
+ }, {
293
+ key: 'keepTyping',
294
+ value: function keepTyping(curString, curStrPos, numChars) {
295
+ // call before functions if applicable
296
+ if (curStrPos === 0) {
297
+ this.toggleBlinking(false);
298
+ this.options.preStringTyped(this.arrayPos, this);
299
+ }
300
+ // start typing each new char into existing string
301
+ // curString: arg, this.el.html: original text inside element
302
+ curStrPos += numChars;
303
+ var nextString = curString.substr(0, curStrPos);
304
+ this.replaceText(nextString);
305
+ // loop the function
306
+ this.typewrite(curString, curStrPos);
307
+ }
308
+
309
+ /**
310
+ * We're done typing all strings
311
+ * @param {string} curString the current string in the strings array
312
+ * @param {number} curStrPos the current position in the curString
313
+ * @private
314
+ */
315
+ }, {
316
+ key: 'doneTyping',
317
+ value: function doneTyping(curString, curStrPos) {
318
+ var _this3 = this;
319
+
320
+ // fires callback function
321
+ this.options.onStringTyped(this.arrayPos, this);
322
+ this.toggleBlinking(true);
323
+ // is this the final string
324
+ if (this.arrayPos === this.strings.length - 1) {
325
+ // callback that occurs on the last typed string
326
+ this.complete();
327
+ // quit if we wont loop back
328
+ if (this.loop === false || this.curLoop === this.loopCount) {
329
+ return;
330
+ }
331
+ }
332
+ this.timeout = setTimeout(function () {
333
+ _this3.backspace(curString, curStrPos);
334
+ }, this.backDelay);
335
+ }
336
+
337
+ /**
338
+ * Backspaces 1 character at a time
339
+ * @param {string} curString the current string in the strings array
340
+ * @param {number} curStrPos the current position in the curString
341
+ * @private
342
+ */
343
+ }, {
344
+ key: 'backspace',
345
+ value: function backspace(curString, curStrPos) {
346
+ var _this4 = this;
347
+
348
+ if (this.pause.status === true) {
349
+ this.setPauseStatus(curString, curStrPos, true);
350
+ return;
351
+ }
352
+ if (this.fadeOut) return this.initFadeOut();
353
+
354
+ this.toggleBlinking(false);
355
+ var humanize = this.humanizer(this.backSpeed);
356
+
357
+ this.timeout = setTimeout(function () {
358
+ curStrPos = _htmlParserJs.htmlParser.backSpaceHtmlChars(curString, curStrPos, _this4);
359
+ // replace text with base text + typed characters
360
+ var curStringAtPosition = curString.substr(0, curStrPos);
361
+ _this4.replaceText(curStringAtPosition);
362
+
363
+ // if smartBack is enabled
364
+ if (_this4.smartBackspace) {
365
+ // the remaining part of the current string is equal of the same part of the new string
366
+ var nextString = _this4.strings[_this4.arrayPos + 1];
367
+ if (nextString && curStringAtPosition === nextString.substr(0, curStrPos)) {
368
+ _this4.stopNum = curStrPos;
369
+ } else {
370
+ _this4.stopNum = 0;
371
+ }
372
+ }
373
+
374
+ // if the number (id of character in current string) is
375
+ // less than the stop number, keep going
376
+ if (curStrPos > _this4.stopNum) {
377
+ // subtract characters one by one
378
+ curStrPos--;
379
+ // loop the function
380
+ _this4.backspace(curString, curStrPos);
381
+ } else if (curStrPos <= _this4.stopNum) {
382
+ // if the stop number has been reached, increase
383
+ // array position to next string
384
+ _this4.arrayPos++;
385
+ // When looping, begin at the beginning after backspace complete
386
+ if (_this4.arrayPos === _this4.strings.length) {
387
+ _this4.arrayPos = 0;
388
+ _this4.options.onLastStringBackspaced();
389
+ _this4.shuffleStringsIfNeeded();
390
+ _this4.begin();
391
+ } else {
392
+ _this4.typewrite(_this4.strings[_this4.sequence[_this4.arrayPos]], curStrPos);
393
+ }
394
+ }
395
+ // humanized value for typing
396
+ }, humanize);
397
+ }
398
+
399
+ /**
400
+ * Full animation is complete
401
+ * @private
402
+ */
403
+ }, {
404
+ key: 'complete',
405
+ value: function complete() {
406
+ this.options.onComplete(this);
407
+ if (this.loop) {
408
+ this.curLoop++;
409
+ } else {
410
+ this.typingComplete = true;
411
+ }
412
+ }
413
+
414
+ /**
415
+ * Has the typing been stopped
416
+ * @param {string} curString the current string in the strings array
417
+ * @param {number} curStrPos the current position in the curString
418
+ * @param {boolean} isTyping
419
+ * @private
420
+ */
421
+ }, {
422
+ key: 'setPauseStatus',
423
+ value: function setPauseStatus(curString, curStrPos, isTyping) {
424
+ this.pause.typewrite = isTyping;
425
+ this.pause.curString = curString;
426
+ this.pause.curStrPos = curStrPos;
427
+ }
428
+
429
+ /**
430
+ * Toggle the blinking cursor
431
+ * @param {boolean} isBlinking
432
+ * @private
433
+ */
434
+ }, {
435
+ key: 'toggleBlinking',
436
+ value: function toggleBlinking(isBlinking) {
437
+ if (!this.cursor) return;
438
+ // if in paused state, don't toggle blinking a 2nd time
439
+ if (this.pause.status) return;
440
+ if (this.cursorBlinking === isBlinking) return;
441
+ this.cursorBlinking = isBlinking;
442
+ if (isBlinking) {
443
+ this.cursor.classList.add('typed-cursor--blink');
444
+ } else {
445
+ this.cursor.classList.remove('typed-cursor--blink');
446
+ }
447
+ }
448
+
449
+ /**
450
+ * Speed in MS to type
451
+ * @param {number} speed
452
+ * @private
453
+ */
454
+ }, {
455
+ key: 'humanizer',
456
+ value: function humanizer(speed) {
457
+ return Math.round(Math.random() * speed / 2) + speed;
458
+ }
459
+
460
+ /**
461
+ * Shuffle the sequence of the strings array
462
+ * @private
463
+ */
464
+ }, {
465
+ key: 'shuffleStringsIfNeeded',
466
+ value: function shuffleStringsIfNeeded() {
467
+ if (!this.shuffle) return;
468
+ this.sequence = this.sequence.sort(function () {
469
+ return Math.random() - 0.5;
470
+ });
471
+ }
472
+
473
+ /**
474
+ * Adds a CSS class to fade out current string
475
+ * @private
476
+ */
477
+ }, {
478
+ key: 'initFadeOut',
479
+ value: function initFadeOut() {
480
+ var _this5 = this;
481
+
482
+ this.el.className += ' ' + this.fadeOutClass;
483
+ if (this.cursor) this.cursor.className += ' ' + this.fadeOutClass;
484
+ return setTimeout(function () {
485
+ _this5.arrayPos++;
486
+ _this5.replaceText('');
487
+
488
+ // Resets current string if end of loop reached
489
+ if (_this5.strings.length > _this5.arrayPos) {
490
+ _this5.typewrite(_this5.strings[_this5.sequence[_this5.arrayPos]], 0);
491
+ } else {
492
+ _this5.typewrite(_this5.strings[0], 0);
493
+ _this5.arrayPos = 0;
494
+ }
495
+ }, this.fadeOutDelay);
496
+ }
497
+
498
+ /**
499
+ * Replaces current text in the HTML element
500
+ * depending on element type
501
+ * @param {string} str
502
+ * @private
503
+ */
504
+ }, {
505
+ key: 'replaceText',
506
+ value: function replaceText(str) {
507
+ if (this.attr) {
508
+ this.el.setAttribute(this.attr, str);
509
+ } else {
510
+ if (this.isInput) {
511
+ this.el.value = str;
512
+ } else if (this.contentType === 'html') {
513
+ this.el.innerHTML = str;
514
+ } else {
515
+ this.el.textContent = str;
516
+ }
517
+ }
518
+ }
519
+
520
+ /**
521
+ * If using input elements, bind focus in order to
522
+ * start and stop the animation
523
+ * @private
524
+ */
525
+ }, {
526
+ key: 'bindFocusEvents',
527
+ value: function bindFocusEvents() {
528
+ var _this6 = this;
529
+
530
+ if (!this.isInput) return;
531
+ this.el.addEventListener('focus', function (e) {
532
+ _this6.stop();
533
+ });
534
+ this.el.addEventListener('blur', function (e) {
535
+ if (_this6.el.value && _this6.el.value.length !== 0) {
536
+ return;
537
+ }
538
+ _this6.start();
539
+ });
540
+ }
541
+
542
+ /**
543
+ * On init, insert the cursor element
544
+ * @private
545
+ */
546
+ }, {
547
+ key: 'insertCursor',
548
+ value: function insertCursor() {
549
+ if (!this.showCursor) return;
550
+ if (this.cursor) return;
551
+ this.cursor = document.createElement('span');
552
+ this.cursor.className = 'typed-cursor';
553
+ this.cursor.innerHTML = this.cursorChar;
554
+ this.el.parentNode && this.el.parentNode.insertBefore(this.cursor, this.el.nextSibling);
555
+ }
556
+ }]);
557
+
558
+ return Typed;
559
+ })();
560
+
561
+ exports['default'] = Typed;
562
+ module.exports = exports['default'];
563
+
564
+ /***/ }),
565
+ /* 1 */
566
+ /***/ (function(module, exports, __webpack_require__) {
567
+
568
+ 'use strict';
569
+
570
+ Object.defineProperty(exports, '__esModule', {
571
+ value: true
572
+ });
573
+
574
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
575
+
576
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
577
+
578
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
579
+
580
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
581
+
582
+ var _defaultsJs = __webpack_require__(2);
583
+
584
+ var _defaultsJs2 = _interopRequireDefault(_defaultsJs);
585
+
586
+ /**
587
+ * Initialize the Typed object
588
+ */
589
+
590
+ var Initializer = (function () {
591
+ function Initializer() {
592
+ _classCallCheck(this, Initializer);
593
+ }
594
+
595
+ _createClass(Initializer, [{
596
+ key: 'load',
597
+
598
+ /**
599
+ * Load up defaults & options on the Typed instance
600
+ * @param {Typed} self instance of Typed
601
+ * @param {object} options options object
602
+ * @param {string} elementId HTML element ID _OR_ instance of HTML element
603
+ * @private
604
+ */
605
+
606
+ value: function load(self, options, elementId) {
607
+ // chosen element to manipulate text
608
+ if (typeof elementId === 'string') {
609
+ self.el = document.querySelector(elementId);
610
+ } else {
611
+ self.el = elementId;
612
+ }
613
+
614
+ self.options = _extends({}, _defaultsJs2['default'], options);
615
+
616
+ // attribute to type into
617
+ self.isInput = self.el.tagName.toLowerCase() === 'input';
618
+ self.attr = self.options.attr;
619
+ self.bindInputFocusEvents = self.options.bindInputFocusEvents;
620
+
621
+ // show cursor
622
+ self.showCursor = self.isInput ? false : self.options.showCursor;
623
+
624
+ // custom cursor
625
+ self.cursorChar = self.options.cursorChar;
626
+
627
+ // Is the cursor blinking
628
+ self.cursorBlinking = true;
629
+
630
+ // text content of element
631
+ self.elContent = self.attr ? self.el.getAttribute(self.attr) : self.el.textContent;
632
+
633
+ // html or plain text
634
+ self.contentType = self.options.contentType;
635
+
636
+ // typing speed
637
+ self.typeSpeed = self.options.typeSpeed;
638
+
639
+ // add a delay before typing starts
640
+ self.startDelay = self.options.startDelay;
641
+
642
+ // backspacing speed
643
+ self.backSpeed = self.options.backSpeed;
644
+
645
+ // only backspace what doesn't match the previous string
646
+ self.smartBackspace = self.options.smartBackspace;
647
+
648
+ // amount of time to wait before backspacing
649
+ self.backDelay = self.options.backDelay;
650
+
651
+ // Fade out instead of backspace
652
+ self.fadeOut = self.options.fadeOut;
653
+ self.fadeOutClass = self.options.fadeOutClass;
654
+ self.fadeOutDelay = self.options.fadeOutDelay;
655
+
656
+ // variable to check whether typing is currently paused
657
+ self.isPaused = false;
658
+
659
+ // input strings of text
660
+ self.strings = self.options.strings.map(function (s) {
661
+ return s.trim();
662
+ });
663
+
664
+ // div containing strings
665
+ if (typeof self.options.stringsElement === 'string') {
666
+ self.stringsElement = document.querySelector(self.options.stringsElement);
667
+ } else {
668
+ self.stringsElement = self.options.stringsElement;
669
+ }
670
+
671
+ if (self.stringsElement) {
672
+ self.strings = [];
673
+ self.stringsElement.style.display = 'none';
674
+ var strings = Array.prototype.slice.apply(self.stringsElement.children);
675
+ var stringsLength = strings.length;
676
+
677
+ if (stringsLength) {
678
+ for (var i = 0; i < stringsLength; i += 1) {
679
+ var stringEl = strings[i];
680
+ self.strings.push(stringEl.innerHTML.trim());
681
+ }
682
+ }
683
+ }
684
+
685
+ // character number position of current string
686
+ self.strPos = 0;
687
+
688
+ // current array position
689
+ self.arrayPos = 0;
690
+
691
+ // index of string to stop backspacing on
692
+ self.stopNum = 0;
693
+
694
+ // Looping logic
695
+ self.loop = self.options.loop;
696
+ self.loopCount = self.options.loopCount;
697
+ self.curLoop = 0;
698
+
699
+ // shuffle the strings
700
+ self.shuffle = self.options.shuffle;
701
+ // the order of strings
702
+ self.sequence = [];
703
+
704
+ self.pause = {
705
+ status: false,
706
+ typewrite: true,
707
+ curString: '',
708
+ curStrPos: 0
709
+ };
710
+
711
+ // When the typing is complete (when not looped)
712
+ self.typingComplete = false;
713
+
714
+ // Set the order in which the strings are typed
715
+ for (var i in self.strings) {
716
+ self.sequence[i] = i;
717
+ }
718
+
719
+ // If there is some text in the element
720
+ self.currentElContent = this.getCurrentElContent(self);
721
+
722
+ self.autoInsertCss = self.options.autoInsertCss;
723
+
724
+ this.appendAnimationCss(self);
725
+ }
726
+ }, {
727
+ key: 'getCurrentElContent',
728
+ value: function getCurrentElContent(self) {
729
+ var elContent = '';
730
+ if (self.attr) {
731
+ elContent = self.el.getAttribute(self.attr);
732
+ } else if (self.isInput) {
733
+ elContent = self.el.value;
734
+ } else if (self.contentType === 'html') {
735
+ elContent = self.el.innerHTML;
736
+ } else {
737
+ elContent = self.el.textContent;
738
+ }
739
+ return elContent;
740
+ }
741
+ }, {
742
+ key: 'appendAnimationCss',
743
+ value: function appendAnimationCss(self) {
744
+ var cssDataName = 'data-typed-js-css';
745
+ if (!self.autoInsertCss) {
746
+ return;
747
+ }
748
+ if (!self.showCursor && !self.fadeOut) {
749
+ return;
750
+ }
751
+ if (document.querySelector('[' + cssDataName + ']')) {
752
+ return;
753
+ }
754
+
755
+ var css = document.createElement('style');
756
+ css.type = 'text/css';
757
+ css.setAttribute(cssDataName, true);
758
+
759
+ var innerCss = '';
760
+ if (self.showCursor) {
761
+ innerCss += '\n .typed-cursor{\n opacity: 1;\n }\n .typed-cursor.typed-cursor--blink{\n animation: typedjsBlink 0.7s infinite;\n -webkit-animation: typedjsBlink 0.7s infinite;\n animation: typedjsBlink 0.7s infinite;\n }\n @keyframes typedjsBlink{\n 50% { opacity: 0.0; }\n }\n @-webkit-keyframes typedjsBlink{\n 0% { opacity: 1; }\n 50% { opacity: 0.0; }\n 100% { opacity: 1; }\n }\n ';
762
+ }
763
+ if (self.fadeOut) {
764
+ innerCss += '\n .typed-fade-out{\n opacity: 0;\n transition: opacity .25s;\n }\n .typed-cursor.typed-cursor--blink.typed-fade-out{\n -webkit-animation: 0;\n animation: 0;\n }\n ';
765
+ }
766
+ if (css.length === 0) {
767
+ return;
768
+ }
769
+ css.innerHTML = innerCss;
770
+ document.body.appendChild(css);
771
+ }
772
+ }]);
773
+
774
+ return Initializer;
775
+ })();
776
+
777
+ exports['default'] = Initializer;
778
+ var initializer = new Initializer();
779
+ exports.initializer = initializer;
780
+
781
+ /***/ }),
782
+ /* 2 */
783
+ /***/ (function(module, exports) {
784
+
785
+ /**
786
+ * Defaults & options
787
+ * @returns {object} Typed defaults & options
788
+ * @public
789
+ */
790
+
791
+ 'use strict';
792
+
793
+ Object.defineProperty(exports, '__esModule', {
794
+ value: true
795
+ });
796
+ var defaults = {
797
+ /**
798
+ * @property {array} strings strings to be typed
799
+ * @property {string} stringsElement ID of element containing string children
800
+ */
801
+ strings: ['These are the default values...', 'You know what you should do?', 'Use your own!', 'Have a great day!'],
802
+ stringsElement: null,
803
+
804
+ /**
805
+ * @property {number} typeSpeed type speed in milliseconds
806
+ */
807
+ typeSpeed: 0,
808
+
809
+ /**
810
+ * @property {number} startDelay time before typing starts in milliseconds
811
+ */
812
+ startDelay: 0,
813
+
814
+ /**
815
+ * @property {number} backSpeed backspacing speed in milliseconds
816
+ */
817
+ backSpeed: 0,
818
+
819
+ /**
820
+ * @property {boolean} smartBackspace only backspace what doesn't match the previous string
821
+ */
822
+ smartBackspace: true,
823
+
824
+ /**
825
+ * @property {boolean} shuffle shuffle the strings
826
+ */
827
+ shuffle: false,
828
+
829
+ /**
830
+ * @property {number} backDelay time before backspacing in milliseconds
831
+ */
832
+ backDelay: 700,
833
+
834
+ /**
835
+ * @property {boolean} fadeOut Fade out instead of backspace
836
+ * @property {string} fadeOutClass css class for fade animation
837
+ * @property {boolean} fadeOutDelay Fade out delay in milliseconds
838
+ */
839
+ fadeOut: false,
840
+ fadeOutClass: 'typed-fade-out',
841
+ fadeOutDelay: 500,
842
+
843
+ /**
844
+ * @property {boolean} loop loop strings
845
+ * @property {number} loopCount amount of loops
846
+ */
847
+ loop: false,
848
+ loopCount: Infinity,
849
+
850
+ /**
851
+ * @property {boolean} showCursor show cursor
852
+ * @property {string} cursorChar character for cursor
853
+ * @property {boolean} autoInsertCss insert CSS for cursor and fadeOut into HTML <head>
854
+ */
855
+ showCursor: true,
856
+ cursorChar: '|',
857
+ autoInsertCss: true,
858
+
859
+ /**
860
+ * @property {string} attr attribute for typing
861
+ * Ex: input placeholder, value, or just HTML text
862
+ */
863
+ attr: null,
864
+
865
+ /**
866
+ * @property {boolean} bindInputFocusEvents bind to focus and blur if el is text input
867
+ */
868
+ bindInputFocusEvents: false,
869
+
870
+ /**
871
+ * @property {string} contentType 'html' or 'null' for plaintext
872
+ */
873
+ contentType: 'html',
874
+
875
+ /**
876
+ * All typing is complete
877
+ * @param {Typed} self
878
+ */
879
+ onComplete: function onComplete(self) {},
880
+
881
+ /**
882
+ * Before each string is typed
883
+ * @param {number} arrayPos
884
+ * @param {Typed} self
885
+ */
886
+ preStringTyped: function preStringTyped(arrayPos, self) {},
887
+
888
+ /**
889
+ * After each string is typed
890
+ * @param {number} arrayPos
891
+ * @param {Typed} self
892
+ */
893
+ onStringTyped: function onStringTyped(arrayPos, self) {},
894
+
895
+ /**
896
+ * During looping, after last string is typed
897
+ * @param {Typed} self
898
+ */
899
+ onLastStringBackspaced: function onLastStringBackspaced(self) {},
900
+
901
+ /**
902
+ * Typing has been stopped
903
+ * @param {number} arrayPos
904
+ * @param {Typed} self
905
+ */
906
+ onTypingPaused: function onTypingPaused(arrayPos, self) {},
907
+
908
+ /**
909
+ * Typing has been started after being stopped
910
+ * @param {number} arrayPos
911
+ * @param {Typed} self
912
+ */
913
+ onTypingResumed: function onTypingResumed(arrayPos, self) {},
914
+
915
+ /**
916
+ * After reset
917
+ * @param {Typed} self
918
+ */
919
+ onReset: function onReset(self) {},
920
+
921
+ /**
922
+ * After stop
923
+ * @param {number} arrayPos
924
+ * @param {Typed} self
925
+ */
926
+ onStop: function onStop(arrayPos, self) {},
927
+
928
+ /**
929
+ * After start
930
+ * @param {number} arrayPos
931
+ * @param {Typed} self
932
+ */
933
+ onStart: function onStart(arrayPos, self) {},
934
+
935
+ /**
936
+ * After destroy
937
+ * @param {Typed} self
938
+ */
939
+ onDestroy: function onDestroy(self) {}
940
+ };
941
+
942
+ exports['default'] = defaults;
943
+ module.exports = exports['default'];
944
+
945
+ /***/ }),
946
+ /* 3 */
947
+ /***/ (function(module, exports) {
948
+
949
+
950
+ /**
951
+ * TODO: These methods can probably be combined somehow
952
+ * Parse HTML tags & HTML Characters
953
+ */
954
+
955
+ 'use strict';
956
+
957
+ Object.defineProperty(exports, '__esModule', {
958
+ value: true
959
+ });
960
+
961
+ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
962
+
963
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
964
+
965
+ var HTMLParser = (function () {
966
+ function HTMLParser() {
967
+ _classCallCheck(this, HTMLParser);
968
+ }
969
+
970
+ _createClass(HTMLParser, [{
971
+ key: 'typeHtmlChars',
972
+
973
+ /**
974
+ * Type HTML tags & HTML Characters
975
+ * @param {string} curString Current string
976
+ * @param {number} curStrPos Position in current string
977
+ * @param {Typed} self instance of Typed
978
+ * @returns {number} a new string position
979
+ * @private
980
+ */
981
+
982
+ value: function typeHtmlChars(curString, curStrPos, self) {
983
+ if (self.contentType !== 'html') return curStrPos;
984
+ var curChar = curString.substr(curStrPos).charAt(0);
985
+ if (curChar === '<' || curChar === '&') {
986
+ var endTag = '';
987
+ if (curChar === '<') {
988
+ endTag = '>';
989
+ } else {
990
+ endTag = ';';
991
+ }
992
+ while (curString.substr(curStrPos + 1).charAt(0) !== endTag) {
993
+ curStrPos++;
994
+ if (curStrPos + 1 > curString.length) {
995
+ break;
996
+ }
997
+ }
998
+ curStrPos++;
999
+ }
1000
+ return curStrPos;
1001
+ }
1002
+
1003
+ /**
1004
+ * Backspace HTML tags and HTML Characters
1005
+ * @param {string} curString Current string
1006
+ * @param {number} curStrPos Position in current string
1007
+ * @param {Typed} self instance of Typed
1008
+ * @returns {number} a new string position
1009
+ * @private
1010
+ */
1011
+ }, {
1012
+ key: 'backSpaceHtmlChars',
1013
+ value: function backSpaceHtmlChars(curString, curStrPos, self) {
1014
+ if (self.contentType !== 'html') return curStrPos;
1015
+ var curChar = curString.substr(curStrPos).charAt(0);
1016
+ if (curChar === '>' || curChar === ';') {
1017
+ var endTag = '';
1018
+ if (curChar === '>') {
1019
+ endTag = '<';
1020
+ } else {
1021
+ endTag = '&';
1022
+ }
1023
+ while (curString.substr(curStrPos - 1).charAt(0) !== endTag) {
1024
+ curStrPos--;
1025
+ if (curStrPos < 0) {
1026
+ break;
1027
+ }
1028
+ }
1029
+ curStrPos--;
1030
+ }
1031
+ return curStrPos;
1032
+ }
1033
+ }]);
1034
+
1035
+ return HTMLParser;
1036
+ })();
1037
+
1038
+ exports['default'] = HTMLParser;
1039
+ var htmlParser = new HTMLParser();
1040
+ exports.htmlParser = htmlParser;
1041
+
1042
+ /***/ })
1043
+ /******/ ])
1044
+ });
1045
+ ;