1// The MIT License (MIT) 2 3// Typed.js | Copyright (c) 2014 Matt Boldt | www.mattboldt.com 4 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to deal 7// in the Software without restriction, including without limitation the rights 8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9// copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21// THE SOFTWARE. 22!function (t, s, e) { 23 "use strict"; 24 var i = function (t, s) { 25 var i = this; 26 this.el = t, this.options = {}, Object.keys(r).forEach(function (t) { 27 i.options[t] = r[t] 28 }), Object.keys(s).forEach(function (t) { 29 i.options[t] = s[t] 30 }), this.isInput = "input" === this.el.tagName.toLowerCase(), this.attr = this.options.attr, this.showCursor = !this.isInput && this.options.showCursor, this.elContent = this.attr ? this.el.getAttribute(this.attr) : this.el.textContent, this.contentType = this.options.contentType, this.typeSpeed = this.options.typeSpeed, this.startDelay = this.options.startDelay, this.backSpeed = this.options.backSpeed, this.backDelay = this.options.backDelay, this.fadeOut = this.options.fadeOut, this.fadeOutClass = this.options.fadeOutClass, this.fadeOutDelay = this.options.fadeOutDelay, e && this.options.stringsElement instanceof e ? this.stringsElement = this.options.stringsElement[0] : this.stringsElement = this.options.stringsElement, this.strings = this.options.strings, this.strPos = 0, this.arrayPos = 0, this.stopNum = 0, this.loop = this.options.loop, this.loopCount = this.options.loopCount, this.curLoop = 0, this.stop = !1, this.cursorChar = this.options.cursorChar, this.shuffle = this.options.shuffle, this.sequence = [], this.build() 31 }; 32 i.prototype = { 33 constructor: i, init: function () { 34 var t = this; 35 t.timeout = setTimeout(function () { 36 for (var s = 0; s < t.strings.length; ++s) t.sequence[s] = s; 37 t.shuffle && (t.sequence = t.shuffleArray(t.sequence)), t.typewrite(t.strings[t.sequence[t.arrayPos]], t.strPos) 38 }, t.startDelay) 39 }, build: function () { 40 var t = this; 41 if (this.showCursor === !0 && (this.cursor = s.createElement("span"), this.cursor.className = "typed-cursor", this.cursor.innerHTML = this.cursorChar, this.el.parentNode && this.el.parentNode.insertBefore(this.cursor, this.el.nextSibling)), this.stringsElement) { 42 this.strings = [], this.stringsElement.style.display = "none"; 43 var e = Array.prototype.slice.apply(this.stringsElement.children); 44 e.forEach(function (s) { 45 t.strings.push(s.innerHTML) 46 }) 47 } 48 this.init() 49 }, typewrite: function (t, s) { 50 if (this.stop !== !0) { 51 this.fadeOut && this.el.classList.contains(this.fadeOutClass) && (this.el.classList.remove(this.fadeOutClass), this.cursor.classList.remove(this.fadeOutClass)); 52 var e = Math.round(70 * Math.random()) + this.typeSpeed, i = this; 53 i.timeout = setTimeout(function () { 54 var e = 0, r = t.substr(s); 55 if ("^" === r.charAt(0)) { 56 var o = 1; 57 /^\^\d+/.test(r) && (r = /\d+/.exec(r)[0], o += r.length, e = parseInt(r)), t = t.substring(0, s) + t.substring(s + o) 58 } 59 if ("html" === i.contentType) { 60 var n = t.substr(s).charAt(0); 61 if ("<" === n || "&" === n) { 62 var a = "", h = ""; 63 for (h = "<" === n ? ">" : ";"; t.substr(s + 1).charAt(0) !== h && (a += t.substr(s).charAt(0), s++, !(s + 1 > t.length));) ; 64 s++, a += h 65 } 66 } 67 i.timeout = setTimeout(function () { 68 if (s === t.length) { 69 if (i.options.onStringTyped(i.arrayPos), i.arrayPos === i.strings.length - 1 && (i.options.callback(), i.curLoop++, i.loop === !1 || i.curLoop === i.loopCount)) return; 70 i.timeout = setTimeout(function () { 71 i.backspace(t, s) 72 }, i.backDelay) 73 } else { 74 0 === s && i.options.preStringTyped(i.arrayPos); 75 var e = t.substr(0, s + 1); 76 i.attr ? i.el.setAttribute(i.attr, e) : i.isInput ? i.el.value = e : "html" === i.contentType ? i.el.innerHTML = e : i.el.textContent = e, s++, i.typewrite(t, s) 77 } 78 }, e) 79 }, e) 80 } 81 }, backspace: function (t, s) { 82 var e = this; 83 if (this.stop !== !0) { 84 if (this.fadeOut) return void this.initFadeOut(); 85 var i = Math.round(70 * Math.random()) + this.backSpeed; 86 e.timeout = setTimeout(function () { 87 if ("html" === e.contentType && ">" === t.substr(s).charAt(0)) { 88 for (var i = ""; "<" !== t.substr(s - 1).charAt(0) && (i -= t.substr(s).charAt(0), s--, !(s < 0));) ; 89 s--, i += "<" 90 } 91 var r = t.substr(0, s); 92 e.replaceText(r), s > e.stopNum ? (s--, e.backspace(t, s)) : s <= e.stopNum && (e.arrayPos++, e.arrayPos === e.strings.length ? (e.arrayPos = 0, e.shuffle && (e.sequence = e.shuffleArray(e.sequence)), e.init(
92)) : e.typewrite(e.strings[e.sequence[e.arrayPos]], s)) 93 }, i) 94 } 95 }, initFadeOut: function () { 96 return self = this, this.el.className += " " + this.fadeOutClass, this.cursor.className += " " + this.fadeOutClass, setTimeout(function () { 97 self.arrayPos++, self.replaceText(""), self.strings.length > self.arrayPos ? self.typewrite(self.strings[self.sequence[self.arrayPos]], 0) : (self.typewrite(self.strings[0], 0), self.arrayPos = 0) 98 }, self.fadeOutDelay) 99 }, replaceText: function (t) { 100 this.attr ? this.el.setAttribute(this.attr, t) : this.isInput ? this.el.value = t : "html" === this.contentType ? this.el.innerHTML = t : this.el.textContent = t 101 }, shuffleArray: function (t) { 102 var s, e, i = t.length; 103 if (i) for (; --i;) e = Math.floor(Math.random() * (i + 1)), s = t[e], t[e] = t[i], t[i] = s; 104 return t 105 }, reset: function () { 106 var t = this; 107 clearInterval(t.timeout); 108 this.el.getAttribute("id"); 109 this.el.textContent = "", "undefined" != typeof this.cursor && "undefined" != typeof this.cursor.parentNode && this.cursor.parentNode.removeChild(this.cursor), this.strPos = 0, this.arrayPos = 0, this.curLoop = 0, this.options.resetCallback() 110 } 111 }, i["new"] = function (t, e) { 112 var r = Array.prototype.slice.apply(s.querySelectorAll(t)); 113 r.forEach(function (t) { 114 var s = t._typed, r = "object" == typeof e && e; 115 s && s.reset(), t._typed = s = new i(t, r), "string" == typeof e && s[e]() 116 }) 117 }, e && (e.fn.typed = function (t) { 118 return this.each(function () { 119 var s = e(this), r = s.data("typed"), o = "object" == typeof t && t; 120 r && r.reset(), s.data("typed", r = new i(this, o)), "string" == typeof t && r[t]() 121 }) 122 }), t.Typed = i; 123 var r = { 124 strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"], 125 stringsElement: null, 126 typeSpeed: 0, 127 startDelay: 0, 128 backSpeed: 0, 129 shuffle: !1, 130 backDelay: 500, 131 fadeOut: !1, 132 fadeOutClass: "typed-fade-out", 133 fadeOutDelay: 500, 134 loop: !1, 135 loopCount: !1, 136 showCursor: !0, 137 cursorChar: "|", 138 attr: null, 139 contentType: "html", 140 callback: function () { 141 }, 142 preStringTyped: function () { 143 }, 144 onStringTyped: function () { 145 }, 146 resetCallback: function () { 147 } 148 } 149}(window, document, window.jQuery);
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.