1/*! 2 * 3 * typed.js - A JavaScript Typing Animation Library 4 * Author: Matt Boldt <[email protected]> 5 * Version: v2.0.12 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() { 20return /******/ (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.options.onBegin(this); 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; // 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, false); 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.setAttribute('aria-hidden', true); 555 this.cursor.innerHTML = this.cursorChar; 556 this.el.parentNode && this.el.parentNode.insertBefore(this.cursor, this.el.nextSibling); 557 } 558 }]); 559 560 return Typed; 561 })(); 562 563 exports['default'] = Typed; 564 module.exports = exports['default']; 565 566/***/ }), 567/* 1 */ 568/***/ (function(module, exports, __webpack_require__) { 569 570 'use strict'; 571 572 Object.defineProperty(exports, '__esModule', { 573 value: true 574 }); 575 576 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; }; 577 578 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; }; })(); 579 580 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 581 582 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 583 584 var _defaultsJs = __webpack_require__(2); 585 586 var _defaultsJs2 = _interopRequireDefault(_defaultsJs); 587 588 /** 589 * Initialize the Typed object 590 */ 591 592 var Initializer = (function () { 593 function Initializer() { 594 _classCallCheck(this, Initializer); 595 } 596 597 _createClass(Initializer, [{ 598 key: 'load', 599 600 /** 601 * Load up defaults & options on the Typed instance 602 * @param {Typed} self instance of Typed 603 * @param {object} options options object 604 * @param {string} elementId HTML element ID _OR_ instance of HTML element 605 * @private 606 */ 607 608 value: function load(self, options, elementId) { 609 // chosen element to manipulate text 610 if (typeof elementId === 'string') { 611 self.el = document.querySelector(elementId); 612 } else { 613 self.el = elementId; 614 } 615 616 self.options = _extends({}, _defaultsJs2['default'], options); 617 618 // attribute to type into 619 self.isInput = self.el.tagName.toLowerCase() === 'input'; 620 self.attr = self.options.attr; 621 self.bindInputFocusEvents = self.options.bindInputFocusEvents; 622 623 // show cursor 624 self.showCursor = self.isInput ? false : self.options.showCursor; 625 626 // custom cursor 627 self.cursorChar = self.options.cursorChar; 628 629 // Is the cursor blinking 630 self.cursorBlinking = true; 631 632 // text content of element 633 self.elContent = self.attr ? self.el.getAttribute(self.attr) : self.el.textContent; 634 635 // html or plain text 636 self.contentType = self.options.contentType; 637 638 // typing speed 639 self.typeSpeed = self.options.typeSpeed; 640 641 // add a delay before typing starts 642 self.startDelay = self.options.startDelay; 643 644 // backspacing speed 645 self.backSpeed = self.options.backSpeed; 646 647 // only backspace what doesn't match the previous string 648 self.smartBackspace = self.options.smartBackspace; 649 650 // amount of time to wait before backspacing 651 self.backDelay = self.options.backDelay; 652 653 // Fade out instead of backspace 654 self.fadeOut = self.options.fadeOut; 655 self.fadeOutClass = self.options.fadeOutClass; 656 self.fadeOutDelay = self.options.fadeOutDelay; 657 658 // variable to check whether typing is currently paused 659 self.isPaused = false;
660 661 // input strings of text 662 self.strings = self.options.strings.map(function (s) { 663 return s.trim(); 664 }); 665 666 // div containing strings 667 if (typeof self.options.stringsElement === 'string') { 668 self.stringsElement = document.querySelector(self.options.stringsElement); 669 } else { 670 self.stringsElement = self.options.stringsElement; 671 } 672 673 if (self.stringsElement) { 674 self.strings = []; 675 self.stringsElement.style.display = 'none'; 676 var strings = Array.prototype.slice.apply(self.stringsElement.children); 677 var stringsLength = strings.length; 678 679 if (stringsLength) { 680 for (var i = 0; i < stringsLength; i += 1) { 681 var stringEl = strings[i]; 682 self.strings.push(stringEl.innerHTML.trim()); 683 } 684 } 685 } 686 687 // character number position of current string 688 self.strPos = 0; 689 690 // current array position 691 self.arrayPos = 0; 692 693 // index of string to stop backspacing on 694 self.stopNum = 0; 695 696 // Looping logic 697 self.loop = self.options.loop; 698 self.loopCount = self.options.loopCount; 699 self.curLoop = 0; 700 701 // shuffle the strings 702 self.shuffle = self.options.shuffle; 703 // the order of strings 704 self.sequence = []; 705 706 self.pause = { 707 status: false, 708 typewrite: true, 709 curString: '', 710 curStrPos: 0 711 }; 712 713 // When the typing is complete (when not looped) 714 self.typingComplete = false; 715 716 // Set the order in which the strings are typed 717 for (var i in self.strings) { 718 self.sequence[i] = i; 719 } 720 721 // If there is some text in the element 722 self.currentElContent = this.getCurrentElContent(self); 723 724 self.autoInsertCss = self.options.autoInsertCss; 725 726 this.appendAnimationCss(self); 727 } 728 }, { 729 key: 'getCurrentElContent', 730 value: function getCurrentElContent(self) { 731 var elContent = ''; 732 if (self.attr) { 733 elContent = self.el.getAttribute(self.attr); 734 } else if (self.isInput) { 735 elContent = self.el.value; 736 } else if (self.contentType === 'html') { 737 elContent = self.el.innerHTML; 738 } else { 739 elContent = self.el.textContent; 740 } 741 return elContent; 742 } 743 }, { 744 key: 'appendAnimationCss', 745 value: function appendAnimationCss(self) { 746 var cssDataName = 'data-typed-js-css'; 747 if (!self.autoInsertCss) { 748 return; 749 } 750 if (!self.showCursor && !self.fadeOut) { 751 return; 752 } 753 if (document.querySelector('[' + cssDataName + ']')) { 754 return; 755 } 756 757 var css = document.createElement('style'); 758 css.type = 'text/css'; 759 css.setAttribute(cssDataName, true); 760 761 var innerCss = ''; 762 if (self.showCursor) { 763 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 '; 764 } 765 if (self.fadeOut) { 766 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 '; 767 } 768 if (css.length === 0) { 769 return; 770 } 771 css.innerHTML = innerCss; 772 document.body.appendChild(css); 773 } 774 }]); 775 776 return Initializer; 777 })(); 778 779 exports['default'] = Initializer; 780 var initializer = new Initializer(); 781 exports.initializer = initializer; 782 783/***/ }), 784/* 2 */
785/***/ (function(module, exports) { 786 787 /** 788 * Defaults & options 789 * @returns {object} Typed defaults & options 790 * @public 791 */ 792 793 'use strict'; 794 795 Object.defineProperty(exports, '__esModule', { 796 value: true 797 }); 798 var defaults = { 799 /** 800 * @property {array} strings strings to be typed 801 * @property {string} stringsElement ID of element containing string children 802 */ 803 strings: ['These are the default values...', 'You know what you should do?', 'Use your own!', 'Have a great day!'], 804 stringsElement: null, 805 806 /** 807 * @property {number} typeSpeed type speed in milliseconds 808 */ 809 typeSpeed: 0, 810 811 /** 812 * @property {number} startDelay time before typing starts in milliseconds 813 */ 814 startDelay: 0, 815 816 /** 817 * @property {number} backSpeed backspacing speed in milliseconds 818 */ 819 backSpeed: 0, 820 821 /** 822 * @property {boolean} smartBackspace only backspace what doesn't match the previous string 823 */ 824 smartBackspace: true, 825 826 /** 827 * @property {boolean} shuffle shuffle the strings 828 */ 829 shuffle: false, 830 831 /** 832 * @property {number} backDelay time before backspacing in milliseconds 833 */ 834 backDelay: 700, 835 836 /** 837 * @property {boolean} fadeOut Fade out instead of backspace 838 * @property {string} fadeOutClass css class for fade animation 839 * @property {boolean} fadeOutDelay Fade out delay in milliseconds 840 */ 841 fadeOut: false, 842 fadeOutClass: 'typed-fade-out', 843 fadeOutDelay: 500, 844 845 /** 846 * @property {boolean} loop loop strings 847 * @property {number} loopCount amount of loops 848 */ 849 loop: false, 850 loopCount: Infinity, 851 852 /** 853 * @property {boolean} showCursor show cursor 854 * @property {string} cursorChar character for cursor 855 * @property {boolean} autoInsertCss insert CSS for cursor and fadeOut into HTML <head> 856 */ 857 showCursor: true, 858 cursorChar: '|', 859 autoInsertCss: true, 860 861 /** 862 * @property {string} attr attribute for typing 863 * Ex: input placeholder, value, or just HTML text 864 */ 865 attr: null, 866 867 /** 868 * @property {boolean} bindInputFocusEvents bind to focus and blur if el is text input 869 */ 870 bindInputFocusEvents: false, 871 872 /** 873 * @property {string} contentType 'html' or 'null' for plaintext 874 */ 875 contentType: 'html', 876 877 /** 878 * Before it begins typing 879 * @param {Typed} self 880 */ 881 onBegin: function onBegin(self) {}, 882 883 /** 884 * All typing is complete 885 * @param {Typed} self 886 */ 887 onComplete: function onComplete(self) {}, 888 889 /** 890 * Before each string is typed 891 * @param {number} arrayPos 892 * @param {Typed} self 893 */ 894 preStringTyped: function preStringTyped(arrayPos, self) {}, 895 896 /** 897 * After each string is typed 898 * @param {number} arrayPos 899 * @param {Typed} self 900 */ 901 onStringTyped: function onStringTyped(arrayPos, self) {}, 902 903 /** 904 * During looping, after last string is typed 905 * @param {Typed} self 906 */ 907 onLastStringBackspaced: function onLastStringBackspaced(self) {}, 908 909 /** 910 * Typing has been stopped 911 * @param {number} arrayPos 912 * @param {Typed} self 913 */ 914 onTypingPaused: function onTypingPaused(arrayPos, self) {}, 915 916 /** 917 * Typing has been started after being stopped 918 * @param {number} arrayPos 919 * @param {Typed} self 920 */ 921 onTypingResumed: function onTypingResumed(arrayPos, self) {}, 922 923 /** 924 * After reset 925 * @param {Typed} self 926 */ 927 onReset: function onReset(self) {}, 928 929 /** 930 * After stop 931 * @param {number} arrayPos 932 * @param {Typed} self 933 */ 934 onStop: function onStop(arrayPos, self) {}, 935 936 /** 937 * After start 938 * @param {number} arrayPos 939 * @param {Typed} self 940 */ 941 onStart: function onStart(arrayPos, self) {}, 942 943 /** 944 * After destroy 945 * @param {Typed} self 946 */ 947 onDestroy: function onDestroy(self) {} 948 }; 949 950 exports['default'] = defaults; 951 module.exports = exports['default']; 952 953/***/ }), 954/* 3 */ 955/***/ (function(module, exports) { 956 957 /** 958 * TODO: These methods can probably be combined somehow 959 * Parse HTML tags & HTML Characters 960 */ 961 962 'use strict'; 963 964 Object.defineProperty(exports, '__esModule', { 965 value: true 966 }); 967 968 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; }; })(); 969 970 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 971 972 var HTMLParser = (function () { 973 function HTMLParser() { 974 _classCallCheck(this, HTMLParser); 975 } 976 977 _createClass(HTMLParser, [{ 978 key: 'typeHtmlChars', 979 980 /** 981 * Type HTML tags & HTML Characters 982 * @param {string} curString Current string 983 * @param {number} curStrPos Position in current string 984 * @param {Typed} self instance of Typed 985 * @returns {number}
985 a new string position 986 * @private 987 */ 988 989 value: function typeHtmlChars(curString, curStrPos, self) { 990 if (self.contentType !== 'html') return curStrPos; 991 var curChar = curString.substr(curStrPos).charAt(0); 992 if (curChar === '<' || curChar === '&') { 993 var endTag = ''; 994 if (curChar === '<') { 995 endTag = '>'; 996 } else { 997 endTag = ';'; 998 } 999 while (curString.substr(curStrPos + 1).charAt(0) !== endTag) { 1000 curStrPos++; 1001 if (curStrPos + 1 > curString.length) { 1002 break; 1003 } 1004 } 1005 curStrPos++; 1006 } 1007 return curStrPos; 1008 } 1009 1010 /** 1011 * Backspace HTML tags and HTML Characters 1012 * @param {string} curString Current string 1013 * @param {number} curStrPos Position in current string 1014 * @param {Typed} self instance of Typed 1015 * @returns {number} a new string position 1016 * @private 1017 */ 1018 }, { 1019 key: 'backSpaceHtmlChars', 1020 value: function backSpaceHtmlChars(curString, curStrPos, self) { 1021 if (self.contentType !== 'html') return curStrPos; 1022 var curChar = curString.substr(curStrPos).charAt(0); 1023 if (curChar === '>' || curChar === ';') { 1024 var endTag = ''; 1025 if (curChar === '>') { 1026 endTag = '<'; 1027 } else { 1028 endTag = '&'; 1029 } 1030 while (curString.substr(curStrPos - 1).charAt(0) !== endTag) { 1031 curStrPos--; 1032 if (curStrPos < 0) { 1033 break; 1034 } 1035 } 1036 curStrPos--; 1037 } 1038 return curStrPos; 1039 } 1040 }]); 1041 1042 return HTMLParser; 1043 })(); 1044 1045 exports['default'] = HTMLParser; 1046 var htmlParser = new HTMLParser(); 1047 exports.htmlParser = htmlParser; 1048 1049/***/ }) 1050/******/ ]) 1051}); 1052;
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.