1(function() { 2 var Utilities, 3 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 4 __hasProp = {}.hasOwnProperty, 5 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 6 7 Utilities = (function() { 8 function Utilities() { 9 this._fireEvent = __bind(this._fireEvent, this); 10 this._empty = __bind(this._empty, this); 11 this._each = __bind(this._each, this); 12 } 13 14 Utilities.prototype._addEvent = function(element, event, fn, useCapture) { 15 if (useCapture == null) { 16 useCapture = false; 17 } 18 return element.addEventListener(event, fn, useCapture); 19 }; 20 21 Utilities.prototype._forEach = function(array, fn, bind) { 22 var i, l, _results; 23 i = 0; 24 l = array.length; 25 _results = []; 26 while (i < l) { 27 if (i in array) { 28 fn.call(bind, array[i], i, array); 29 } 30 _results.push(i++); 31 } 32 return _results; 33 }; 34 35 Utilities.prototype._each = function(array, fn, bind) { 36 if (array) { 37 this._forEach(array, fn, bind); 38 return array; 39 } 40 }; 41 42 Utilities.prototype._pass = function(fn, args, bind) { 43 if (args == null) { 44 args = []; 45 } 46 return function() { 47 return fn.apply(bind, args); 48 }; 49 }; 50 51 Utilities.prototype._delay = function(fn, delay, bind, args) { 52 if (args == null) { 53 args = []; 54 } 55 return setTimeout(this._pass(fn, args, bind), delay); 56 }; 57 58 Utilities.prototype._periodical = function(fn, periodical, bind, args) { 59 if (args == null) { 60 args = []; 61 } 62 return setInterval(this._pass(fn, args, bind), periodical); 63 }; 64 65 Utilities.prototype._setHtml = function(element, string) { 66 return element.innerHTML = string; 67 }; 68 69 Utilities.prototype._getHtml = function(element) { 70 return element.innerHTML; 71 }; 72 73 Utilities.prototype._empty = function(element) { 74 return this._setHtml(element, ""); 75 }; 76 77 Utilities.prototype._fireEvent = function(event, text) { 78 if (this.options[event]) { 79 return this.options[event].call(this, text, this.options); 80 } 81 }; 82 83 Utilities.prototype._extend = function(object, properties) { 84 var key, val; 85 for (key in properties) { 86 val = properties[key]; 87 object[key] = val; 88 } 89 return object; 90 }; 91 92 return Utilities; 93 94 })(); 95 96 this.Typist = (function(_super) { 97 __extends(Typist, _super); 98 99 function Typist(element, options) { 100 if (options == null) { 101 options = {}; 102 } 103 this.typeLetter = __bind(this.typeLetter, this); 104 this.typeLetters = __bind(this.typeLetters, this); 105 this.typeText = __bind(this.typeText, this); 106 this.selectOffset = __bind(this.selectOffset, this); 107 this.selectText = __bind(this.selectText, this); 108 this.fetchVariations = __bind(this.fetchVariations, this); 109 this.next = __bind(this.next, this); 110 this.slide = __bind(this.slide, this); 111 this.setupDefaults = __bind(this.setupDefaults, this); 112 this.options = { 113 typist: element, 114 letterSelectInterval: 60, 115 interval: 3000, 116 selectClassName: "selectedText" 117 }; 118 this.options = this._extend(this.options, options); 119 this.elements = { 120 typist: this.options.typist 121 }; 122 this.offsets = { 123 current: { 124 index: 0, 125 text: "" 126 } 127 }; 128 if (this.elements.typist) { 129 this.setupDefaults(); 130 } 131 } 132 133 Typist.prototype.setupDefaults = function() { 134 this.variations = this.fetchVariations(this.elements.typist); 135 this.newText = []; 136 return this.timer = this._periodical(this.slide, this.options.interval); 137 }; 138 139 Typist.prototype.slide = function(forcedText) { 140 this.offsets.current.text = this.variations[this.offsets.current.index]; 141 this.offsets.current.text = this.offsets.current.text.split(""); 142 this._each(this.offsets.current.text, this.selectText); 143 this.offsets.current.index = this.next(this.offsets.current.index); 144 this._delay((function(_this) { 145 return function() { 146 _this.options.currentSlideIndex = _this.offsets.current.index; 147 return _this.typeText(_this.variations[_this.offsets.current.index]); 148 }; 149 })(this), this.options.letterSelectInterval * this.offsets.current.text.length); 150 if (this.variations.length <= this.offsets.current.index) { 151 this.offsets.current.index = 0; 152 } else if (this.offsets.current.index === 0) { 153 this.offsets.current.index = this.variations.length; 154 } else { 155 this.offsets.current.index = this.offsets.current.index; 156 } 157 return this.newText.length = 0; 158 }; 159 160 Typist.prototype.next = function(offset) { 161 return offset = offset + 1; 162 }; 163 164 Typist.prototype.fetchVariations = function(element) { 165 var text, value, variations; 166 text = element.getAttribute("data-typist"); 167 value = this._getHtml(element); 168 variations = text.split(","); 169 variations.splice(0, 0, value); 170 return variations; 171 }; 172 173 Typist.prototype.selectText = function(letter, index) { 174 return this._delay((function(_this) { 175 return function() { 176 return _this.selectOffset((_this.offsets.current.text.length - index) - 1); 177 }; 178 })(this), index * this.options.letterSelectInterval); 179 }; 180 181 Typist.prototype.selectOffset = function(offset) { 182 var selected, text, unselected; 183 text = this.offsets.current.text; 184 selected = text.slice(offset, text.length); 185 selected = selected.join(""); 186 unselected = text.slice(0, offset); 187 unselected = unselected.join(""); 188 return this._setHtml(this.elements.typist, "" + unselected + "<em class=\"" + this.options.selectClassName + "\">" + selected + "</em>"); 189 }; 190 191 Typist.prototype.typeText = function(text) { 192 this.typeTextSplit = text.split(""); 193 this._each(this.typeTextSplit, this.typeLetters); 194 return this._fireEvent("onSlide", text); 195 }; 196 197 Typist.prototype.typeLetters = function(letter, index) { 198 clearInterval(this.timer); 199 return this._delay((function(_this) { 200 return function() { 201 return _this.typeLetter(letter, index); 202 }; 203 })(this), index * this.options.letterSelectInterval); 204 }; 205 206 Typist.prototype.typeLetter = function(letter, index) { 207 this._empty(this.elements.typist); 208 this.newText.push(letter); 209 this._setHtml(this.elements.typist, this.newText.join(""));
210 if (this.typeTextSplit.length === index + 1) { 211 return this.timer = this._periodical(this.slide, this.options.interval); 212 } 213 }; 214 215 return Typist; 216 217 })(Utilities); 218 219}).call(this);
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.