1/*! 2 * 3 * typed.js - A JavaScript Typing Animation Library 4 * Author: Matt Boldt <[email protected]> 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 clearInterval(this.timeout);
116 if (this.typingComplete) return; 117 if (this.pause.status) return; 118 this.toggleBlinking(true); 119 this.pause.status = true; 120 this.options.onStop(this.arrayPos, this); 121 } 122 123 /** 124 * Start typing / backspacing after being stopped 125 * @public 126 */ 127 }, { 128 key: 'start', 129 value: function start() { 130 if (this.typingComplete) return; 131 if (!this.pause.status) return; 132 this.pause.status = false; 133 if (this.pause.typewrite) { 134 this.typewrite(this.pause.curString, this.pause.curStrPos); 135 } else { 136 this.backspace(this.pause.curString, this.pause.curStrPos); 137 } 138 this.options.onStart(this.arrayPos, this); 139 } 140 141 /** 142 * Destroy this instance of Typed 143 * @public 144 */ 145 }, { 146 key: 'destroy', 147 value: function destroy() { 148 this.reset(false); 149 this.options.onDestroy(this); 150 } 151 152 /** 153 * Reset Typed and optionally restarts 154 * @param {boolean} restart 155 * @public 156 */ 157 }, { 158 key: 'reset', 159 value: function reset() { 160 var restart = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; 161 162 clearInterval(this.timeout); 163 this.replaceText(''); 164 if (this.cursor && this.cursor.parentNode) { 165 this.cursor.parentNode.removeChild(this.cursor); 166 this.cursor = null; 167 } 168 this.strPos = 0; 169 this.arrayPos = 0; 170 this.curLoop = 0; 171 if (restart) { 172 this.insertCursor(); 173 this.options.onReset(this); 174 this.begin(); 175 } 176 } 177 178 /** 179 * Begins the typing animation 180 * @private 181 */ 182 }, { 183 key: 'begin', 184 value: function begin() { 185 var _this = this; 186 187 this.typingComplete = false; 188 this.shuffleStringsIfNeeded(this); 189 this.insertCursor(); 190 if (this.bindInputFocusEvents) this.bindFocusEvents(); 191 this.timeout = setTimeout(function () { 192 // Check if there is some text in the element, if yes start by backspacing the default message 193 if (!_this.currentElContent || _this.currentElContent.length === 0) { 194 _this.typewrite(_this.strings[_this.sequence[_this.arrayPos]], _this.strPos); 195 } else { 196 // Start typing 197 _this.backspace(_this.currentElContent, _this.currentElContent.length); 198 } 199 }, this.startDelay); 200 } 201 202 /** 203 * Called for each character typed 204 * @param {string} curString the current string in the strings array 205 * @param {number} curStrPos the current position in the curString 206 * @private 207 */ 208 }, { 209 key: 'typewrite', 210 value: function typewrite(curString, curStrPos) { 211 var _this2 = this; 212 213 if (this.fadeOut && this.el.classList.contains(this.fadeOutClass)) { 214 this.el.classList.remove(this.fadeOutClass); 215 if (this.cursor) this.cursor.classList.remove(this.fadeOutClass); 216 } 217 218 var humanize = this.humanizer(this.typeSpeed); 219 var numChars = 1; 220 221 if (this.pause.status === true) { 222 this.setPauseStatus(curString, curStrPos, true); 223 return; 224 } 225 226 // contain typing function in a timeout humanize'd delay 227 this.timeout = setTimeout(function () { 228 // skip over any HTML chars 229 curStrPos = _htmlParserJs.htmlParser.typeHtmlChars(curString, curStrPos, _this2); 230 231 var pauseTime = 0; 232 var substr = curString.substr(curStrPos); 233 // check for an escape character before a pause value 234 // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^ 235 // single ^ are removed from string 236 if (substr.charAt(0) === '^') { 237 if (/^\^\d+/.test(substr)) { 238 var skip = 1;
238 // skip at least 1 239 substr = /\d+/.exec(substr)[0]; 240 skip += substr.length; 241 pauseTime = parseInt(substr); 242 _this2.temporaryPause = true; 243 _this2.options.onTypingPaused(_this2.arrayPos, _this2); 244 // strip out the escape character and pause value so they're not printed 245 curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip); 246 _this2.toggleBlinking(true); 247 } 248 } 249 250 // check for skip characters formatted as 251 // "this is a `string to print NOW` ..." 252 if (substr.charAt(0) === '`') { 253 while (curString.substr(curStrPos + numChars).charAt(0) !== '`') { 254 numChars++; 255 if (curStrPos + numChars > curString.length) break; 256 } 257 // strip out the escape characters and append all the string in between 258 var stringBeforeSkip = curString.substring(0, curStrPos); 259 var stringSkipped = curString.substring(stringBeforeSkip.length + 1, curStrPos + numChars); 260 var stringAfterSkip = curString.substring(curStrPos + numChars + 1); 261 curString = stringBeforeSkip + stringSkipped + stringAfterSkip; 262 numChars--; 263 } 264 265 // timeout for any pause after a character 266 _this2.timeout = setTimeout(function () { 267 // Accounts for blinking while paused 268 _this2.toggleBlinking(false); 269 270 // We're done with this sentence! 271 if (curStrPos >= curString.length) { 272 _this2.doneTyping(curString, curStrPos); 273 } else { 274 _this2.keepTyping(curString, curStrPos, numChars); 275 } 276 // end of character pause 277 if (_this2.temporaryPause) { 278 _this2.temporaryPause = false; 279 _this2.options.onTypingResumed(_this2.arrayPos, _this2); 280 } 281 }, pauseTime); 282 283 // humanized value for typing 284 }, humanize); 285 } 286 287 /** 288 * Continue to the next string & begin typing 289 * @param {string} curString the current string in the strings array 290 * @param {number} curStrPos the current position in the curString 291 * @private 292 */ 293 }, { 294 key: 'keepTyping', 295 value: function keepTyping(curString, curStrPos, numChars) { 296 // call before functions if applicable 297 if (curStrPos === 0) { 298 this.toggleBlinking(false); 299 this.options.preStringTyped(this.arrayPos, this); 300 } 301 // start typing each new char into existing string 302 // curString: arg, this.el.html: original text inside element 303 curStrPos += numChars; 304 var nextString = curString.substr(0, curStrPos); 305 this.replaceText(nextString); 306 // loop the function 307 this.typewrite(curString, curStrPos); 308 } 309 310 /** 311 * We're done typing the current string 312 * @param {string} curString the current string in the strings array 313 * @param {number} curStrPos the current position in the curString 314 * @private 315 */ 316 }, { 317 key: 'doneTyping', 318 value: function doneTyping(curString, curStrPos) { 319 var _this3 = this; 320 321 // fires callback function 322 this.options.onStringTyped(this.arrayPos, this); 323 this.toggleBlinking(true); 324 // is this the final string 325 if (this.arrayPos === this.strings.length - 1) { 326 // callback that occurs on the last typed string 327 this.complete(); 328 // quit if we wont loop back 329 if (this.loop === false || this.curLoop === this.loopCount) { 330 return; 331 } 332 } 333 this.timeout = setTimeout(function () { 334 _this3.backspace(curString, curStrPos); 335 }, this.backDelay); 336 } 337 338 /** 339 * Backspaces 1 character at a time 340 * @param {string} curString the current string in the strings array 341 * @param {number} curStrPos the current position in the curString 342 * @private 343 */ 344 }, { 345 key: 'backspace', 346 value: function backspace(curString, curStrPos) { 347 var _this4 = this; 348 349 if (this.pause.status === true) { 350 this.setPauseStatus(curString, curStrPos, true); 351 return; 352 } 353 if (this.fadeOut) return this.initFadeOut(); 354 355 this.toggleBlinking(false); 356 var humanize = this.humanizer(this.backSpeed); 357 358 this.timeout = setTimeout(function () { 359 curStrPos = _htmlParserJs.htmlParser.backSpaceHtmlChars(curString, curStrPos, _this4); 360 // replace text with base text + typed characters 361 var curStringAtPosition = curString.substr(0, curStrPos); 362 _this4.replaceText(curStringAtPosition); 363 364 // if smartBack is enabled 365 if (_this4.smartBackspace) { 366 // the remaining part of the current string is equal of the same part of the new string 367 var nextString = _this4.strings[_this4.arrayPos + 1]; 368 if (nextString && curStringAtPosition === nextString.substr(0, curStrPos)) { 369 _this4.stopNum = curStrPos; 370 } else { 371 _this4.stopNum = 0; 372 } 373 } 374 375 // if the number (id of character in current string) is 376 // less than the stop number, keep going 377 if (curStrPos > _this4.stopNum) { 378 // subtract characters one by one 379 curStrPos--; 380 // loop the function 381 _this4.backspace(curString, curStrPos); 382 } else if (curStrPos <= _this4.stopNum) { 383 // if the stop number has been reached, increase 384 // array position to next string 385 _this4.arrayPos++; 386 // When looping, begin at the beginning after backspace complete 387 if (_this4.arrayPos === _this4.strings.length) { 388 _this4.arrayPos = 0; 389 _this4.options.onLastStringBackspaced(); 390 _this4.shuffleStringsIfNeeded(); 391 _this4.begin(); 392 } else { 393 _this4.typewrite(_this4.strings[_this4.sequence[_this4.arrayPos
393]], curStrPos); 394 } 395 } 396 // humanized value for typing 397 }, humanize); 398 } 399 400 /** 401 * Full animation is complete 402 * @private 403 */ 404 }, { 405 key: 'complete', 406 value: function complete() { 407 this.options.onComplete(this); 408 if (this.loop) { 409 this.curLoop++; 410 } else { 411 this.typingComplete = true; 412 } 413 } 414 415 /** 416 * Has the typing been stopped 417 * @param {string} curString the current string in the strings array 418 * @param {number} curStrPos the current position in the curString 419 * @param {boolean} isTyping 420 * @private 421 */ 422 }, { 423 key: 'setPauseStatus', 424 value: function setPauseStatus(curString, curStrPos, isTyping) { 425 this.pause.typewrite = isTyping; 426 this.pause.curString = curString; 427 this.pause.curStrPos = curStrPos; 428 } 429 430 /** 431 * Toggle the blinking cursor 432 * @param {boolean} isBlinking 433 * @private 434 */ 435 }, { 436 key: 'toggleBlinking', 437 value: function toggleBlinking(isBlinking) { 438 if (!this.cursor) return; 439 // if in paused state, don't toggle blinking a 2nd time 440 if (this.pause.status) return; 441 if (this.cursorBlinking === isBlinking) return; 442 this.cursorBlinking = isBlinking; 443 if (isBlinking) { 444 this.cursor.classList.add('typed-cursor--blink'); 445 } else { 446 this.cursor.classList.remove('typed-cursor--blink'); 447 } 448 } 449 450 /** 451 * Speed in MS to type 452 * @param {number} speed 453 * @private 454 */ 455 }, { 456 key: 'humanizer', 457 value: function humanizer(speed) { 458 return Math.round(Math.random() * speed / 2) + speed; 459 } 460 461 /** 462 * Shuffle the sequence of the strings array 463 * @private 464 */ 465 }, { 466 key: 'shuffleStringsIfNeeded', 467 value: function shuffleStringsIfNeeded() { 468 if (!this.shuffle) return; 469 this.sequence = this.sequence.sort(function () { 470 return Math.random() - 0.5; 471 }); 472 } 473 474 /** 475 * Adds a CSS class to fade out current string 476 * @private 477 */ 478 }, { 479 key: 'initFadeOut', 480 value: function initFadeOut() { 481 var _this5 = this; 482 483 this.el.className += ' ' + this.fadeOutClass; 484 if (this.cursor) this.cursor.className += ' ' + this.fadeOutClass; 485 return setTimeout(function () { 486 _this5.arrayPos++; 487 _this5.replaceText(''); 488 489 // Resets current string if end of loop reached 490 if (_this5.strings.length > _this5.arrayPos) { 491 _this5.typewrite(_this5.strings[_this5.sequence[_this5.arrayPos]], 0); 492 } else { 493 _this5.typewrite(_this5.strings[0], 0); 494 _this5.arrayPos = 0; 495 } 496 }, this.fadeOutDelay); 497 } 498 499 /** 500 * Replaces current text in the HTML element 501 * depending on element type 502 * @param {string} str 503 * @private 504 */ 505 }, { 506 key: 'replaceText', 507 value: function replaceText(str) { 508 if (this.attr) { 509 this.el.setAttribute(this.attr, str); 510 } else { 511 if (this.isInput) { 512 this.el.value = str; 513 } else if (this.contentType === 'html') { 514 this.el.innerHTML = str; 515 } else { 516 this.el.textContent = str; 517 } 518 } 519 } 520 521 /** 522 * If using input elements, bind focus in order to 523 * start and stop the animation 524 * @private 525 */ 526 }, { 527 key: 'bindFocusEvents', 528 value: function bindFocusEvents() { 529 var _this6 = this; 530 531 if (!this.isInput) return; 532 this.el.addEventListener('focus', function (e) { 533 _this6.stop(); 534 }); 535 this.el.addEventListener('blur', function (e) { 536 if (_this6.el.value && _this6.el.value.length !== 0) { 537 return; 538 } 539 _this6.start(); 540 }); 541 } 542 543 /** 544 * On init, insert the cursor element 545 * @private 546 */ 547 }, { 548 key: 'insertCursor', 549 value: function insertCursor() { 550 if (!this.showCursor) return; 551 if (this.cursor) return; 552 this.cursor = document.createElement('span'); 553 this.cursor.className = 'typed-cursor'; 554 this.cursor.innerHTML = this.cursorChar; 555 this.el.parentNode && this.el.parentNode.insertBefore(this.cursor, this.el.nextSibling); 556 } 557 }]); 558 559 return Typed; 560 })(); 561 562 exports['default'] = Typed; 563 module.exports = exports['default']; 564 565 /***/ }), 566 /* 1 */ 567 /***/ (function(module, exports, __webpack_require__) { 568 569 'use strict'; 570 571 Object.defineProperty(exports, '__esModule', { 572 value: true 573 }); 574 575 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; }; 576 577 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; }; })(); 578 579 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 580 581 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 582 583 var _defaultsJs = __webpack_require__(2); 584 585 var _defaultsJs2 = _interopRequireDefault(_defaultsJs); 586 587 /** 588 * Initialize the Typed object 589 */ 590 591 var Initializer = (function () { 592 function Initializer() { 593 _classCallCheck(this, Initializer); 594 } 595 596 _createClass(Initializer, [{ 597 key: 'load', 598 599 /** 600 * Load up defaults & options on the Typed instance 601 * @param {Typed} self instance of Typed 602 * @param {object} options options object 603 * @param {string} elementId HTML element ID _OR_ instance of HTML element 604 * @private 605 */ 606 607 value: function load(self, options, elementId) { 608 // chosen element to manipulate text 609 if (typeof elementId === 'string') { 610 self.el = document.querySelector(elementId); 611 } else { 612 self.el = elementId; 613 } 614 615 self.options = _extends({}, _defaultsJs2['default'], options); 616 617 // attribute to type into 618 self.isInput = self.el.tagName.toLowerCase() === 'input'; 619 self.attr = self.options.attr; 620 self.bindInputFocusEvents = self.options.bindInputFocusEvents; 621 622 // show cursor 623 self.showCursor = self.isInput ? false : self.options.showCursor; 624 625 // custom cursor 626 self.cursorChar = self.options.cursorChar; 627 628 // Is the cursor blinking 629 self.cursorBlinking = true; 630 631 // text content of element 632 self.elContent = self.attr ? self.el.getAttribute(self.attr) : self.el.textContent; 633 634 // html or plain text 635 self.contentType = self.options.contentType; 636 637 // typing speed 638 self.typeSpeed = self.options.typeSpeed; 639 640 // add a delay before typing starts 641 self.startDelay = self.options.startDelay; 642 643 // backspacing speed 644 self.backSpeed = self.options.backSpeed; 645 646 // only backspace what doesn't match the previous string 647 self.smartBackspace = self.options.smartBackspace; 648 649 // amount of time to wait before backspacing 650 self.backDelay = self.options.backDelay; 651 652 // Fade out instead of backspace 653 self.fadeOut = self.options.fadeOut; 654 self.fadeOutClass = self.options.fadeOutClass; 655 self.fadeOutDelay = self.options.fadeOutDelay; 656 657 // variable to check whether typing is currently paused 658 self.isPaused = false;
659 660 // input strings of text 661 self.strings = self.options.strings.map(function (s) { 662 return s.trim(); 663 }); 664 665 // div containing strings 666 if (typeof self.options.stringsElement === 'string') { 667 self.stringsElement = document.querySelector(self.options.stringsElement); 668 } else { 669 self.stringsElement = self.options.stringsElement; 670 } 671 672 if (self.stringsElement) { 673 self.strings = []; 674 self.stringsElement.style.display = 'none'; 675 var strings = Array.prototype.slice.apply(self.stringsElement.children); 676 var stringsLength = strings.length; 677 678 if (stringsLength) { 679 for (var i = 0; i < stringsLength; i += 1) { 680 var stringEl = strings[i]; 681 self.strings.push(stringEl.innerHTML.trim()); 682 } 683 } 684 } 685 686 // character number position of current string 687 self.strPos = 0; 688 689 // current array position 690 self.arrayPos = 0; 691 692 // index of string to stop backspacing on 693 self.stopNum = 0; 694 695 // Looping logic 696 self.loop = self.options.loop; 697 self.loopCount = self.options.loopCount; 698 self.curLoop = 0; 699 700 // shuffle the strings 701 self.shuffle = self.options.shuffle; 702 // the order of strings 703 self.sequence = []; 704 705 self.pause = { 706 status: false, 707 typewrite: true, 708 curString: '', 709 curStrPos: 0 710 }; 711 712 // When the typing is complete (when not looped) 713 self.typingComplete = false; 714 715 // Set the order in which the strings are typed 716 for (var i in self.strings) { 717 self.sequence[i] = i; 718 } 719 720 // If there is some text in the element 721 self.currentElContent = this.getCurrentElContent(self); 722 723 self.autoInsertCss = self.options.autoInsertCss; 724 725 this.appendAnimationCss(self); 726 } 727 }, { 728 key: 'getCurrentElContent', 729 value: function getCurrentElContent(self) { 730 var elContent = ''; 731 if (self.attr) { 732 elContent = self.el.getAttribute(self.attr); 733 } else if (self.isInput) { 734 elContent = self.el.value; 735 } else if (self.contentType === 'html') { 736 elContent = self.el.innerHTML; 737 } else { 738 elContent = self.el.textContent; 739 } 740 return elContent; 741 } 742 }, { 743 key: 'appendAnimationCss', 744 value: function appendAnimationCss(self) { 745 var cssDataName = 'data-typed-js-css'; 746 if (!self.autoInsertCss) { 747 return; 748 } 749 if (!self.showCursor && !self.fadeOut) { 750 return; 751 } 752 if (document.querySelector('[' + cssDataName + ']')) { 753 return; 754 } 755 756 var css = document.createElement('style'); 757 css.type = 'text/css'; 758 css.setAttribute(cssDataName, true); 759 760 var innerCss = ''; 761 if (self.showCursor) { 762 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 '; 763 } 764 if (self.fadeOut) { 765 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 '; 766 } 767 if (css.length === 0) { 768 return; 769 } 770 css.innerHTML = innerCss; 771 document.body.appendChild(css); 772 } 773 }]); 774 775 return Initializer; 776 })(); 777 778 exports['default'] = Initializer; 779 var initializer = new Initializer(); 780 exports.initializer = initializer; 781 782 /***/ }), 783 /* 2 */
784 /***/ (function(module, exports) { 785 786 /** 787 * Defaults & options 788 * @returns {object} Typed defaults & options 789 * @public 790 */ 791 792 'use strict'; 793 794 Object.defineProperty(exports, '__esModule', { 795 value: true 796 }); 797 var defaults = { 798 /** 799 * @property {array} strings strings to be typed 800 * @property {string} stringsElement ID of element containing string children 801 */ 802 strings: ['These are the default values...', 'You know what you should do?', 'Use your own!', 'Have a great day!'], 803 stringsElement: null, 804 805 /** 806 * @property {number} typeSpeed type speed in milliseconds 807 */ 808 typeSpeed: 0, 809 810 /** 811 * @property {number} startDelay time before typing starts in milliseconds 812 */ 813 startDelay: 0, 814 815 /** 816 * @property {number} backSpeed backspacing speed in milliseconds 817 */ 818 backSpeed: 0, 819 820 /** 821 * @property {boolean} smartBackspace only backspace what doesn't match the previous string 822 */ 823 smartBackspace: true, 824 825 /** 826 * @property {boolean} shuffle shuffle the strings 827 */ 828 shuffle: false, 829 830 /** 831 * @property {number} backDelay time before backspacing in milliseconds 832 */ 833 backDelay: 700, 834 835 /** 836 * @property {boolean} fadeOut Fade out instead of backspace 837 * @property {string} fadeOutClass css class for fade animation 838 * @property {boolean} fadeOutDelay Fade out delay in milliseconds 839 */ 840 fadeOut: false, 841 fadeOutClass: 'typed-fade-out', 842 fadeOutDelay: 500, 843 844 /** 845 * @property {boolean} loop loop strings 846 * @property {number} loopCount amount of loops 847 */ 848 loop: false, 849 loopCount: Infinity, 850 851 /** 852 * @property {boolean} showCursor show cursor 853 * @property {string} cursorChar character for cursor 854 * @property {boolean} autoInsertCss insert CSS for cursor and fadeOut into HTML <head> 855 */ 856 showCursor: true, 857 cursorChar: '|', 858 autoInsertCss: true, 859 860 /** 861 * @property {string} attr attribute for typing 862 * Ex: input placeholder, value, or just HTML text 863 */ 864 attr: null, 865 866 /** 867 * @property {boolean} bindInputFocusEvents bind to focus and blur if el is text input 868 */ 869 bindInputFocusEvents: false, 870 871 /** 872 * @property {string} contentType 'html' or 'null' for plaintext 873 */ 874 contentType: 'html', 875 876 /** 877 * All typing is complete 878 * @param {Typed} self 879 */ 880 onComplete: function onComplete(self) {}, 881 882 /** 883 * Before each string is typed 884 * @param {number} arrayPos 885 * @param {Typed} self 886 */ 887 preStringTyped: function preStringTyped(arrayPos, self) {}, 888 889 /** 890 * After each string is typed 891 * @param {number} arrayPos 892 * @param {Typed} self 893 */ 894 onStringTyped: function onStringTyped(arrayPos, self) {}, 895 896 /** 897 * During looping, after last string is typed 898 * @param {Typed} self 899 */ 900 onLastStringBackspaced: function onLastStringBackspaced(self) {}, 901 902 /** 903 * Typing has been stopped 904 * @param {number} arrayPos 905 * @param {Typed} self 906 */ 907 onTypingPaused: function onTypingPaused(arrayPos, self) {}, 908 909 /** 910 * Typing has been started after being stopped 911 * @param {number} arrayPos 912 * @param {Typed} self 913 */ 914 onTypingResumed: function onTypingResumed(arrayPos, self) {}, 915 916 /** 917 * After reset 918 * @param {Typed} self 919 */ 920 onReset: function onReset(self) {}, 921 922 /** 923 * After stop 924 * @param {number} arrayPos 925 * @param {Typed} self 926 */ 927 onStop: function onStop(arrayPos, self) {}, 928 929 /** 930 * After start 931 * @param {number} arrayPos 932 * @param {Typed} self 933 */ 934 onStart: function onStart(arrayPos, self) {}, 935 936 /** 937 * After destroy 938 * @param {Typed} self 939 */ 940 onDestroy: function onDestroy(self) {} 941 }; 942 943 exports['default'] = defaults; 944 module.exports = exports['default']; 945 946 /***/ }), 947 /* 3 */
948 /***/ (function(module, exports) { 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;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.