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