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() { 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.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
392]], 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}
978 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.