vendor: 10,992 bytes, lines 1-301
1/*! 2 * typeahead.js 0.10.2 3 * https://github.com/twitter/typeahead.js 4 * Copyright 2013-2014 Twitter, Inc. and other contributors; Licensed MIT 5 */ 6 7! function(a) { 8 var b = { 9 isMsie: function() { 10 return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : !1 11 }, 12 isBlankString: function(a) { 13 return !a || /^\s*$/.test(a) 14 }, 15 escapeRegExChars: function(a) { 16 return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") 17 }, 18 isString: function(a) { 19 return "string" == typeof a 20 }, 21 isNumber: function(a) { 22 return "number" == typeof a 23 }, 24 isArray: a.isArray, 25 isFunction: a.isFunction, 26 isObject: a.isPlainObject, 27 isUndefined: function(a) { 28 return "undefined" == typeof a 29 }, 30 bind: a.proxy, 31 each: function(b, c) { 32 function d(a, b) { 33 return c(b, a) 34 } 35 a.each(b, d) 36 }, 37 map: a.map, 38 filter: a.grep, 39 every: function(b, c) { 40 var d = !0; 41 return b ? (a.each(b, function(a, e) { 42 return (d = c.call(null, e, a, b)) ? void 0 : !1 43 }), !! d) : d 44 }, 45 some: function(b, c) { 46 var d = !1; 47 return b ? (a.each(b, function(a, e) { 48 return (d = c.call(null, e, a, b)) ? !1 : void 0 49 }), !! d) : d 50 }, 51 mixin: a.extend, 52 getUniqueId: function() { 53 var a = 0; 54 return function() { 55 return a++ 56 } 57 }(), 58 templatify: function(b) { 59 function c() { 60 return String(b) 61 } 62 return a.isFunction(b) ? b : c 63 }, 64 defer: function(a) { 65 setTimeout(a, 0) 66 }, 67 debounce: function(a, b, c) { 68 var d, e; 69 return function() { 70 var f, g, h = this, 71 i = arguments; 72 return f = function() { 73 d = null, c || (e = a.apply(h, i)) 74 }, g = c && !d, clearTimeout(d), d = setTimeout(f, b), g && (e = a.apply(h, i)), e 75 } 76 }, 77 throttle: function(a, b) { 78 var c, d, e, f, g, h; 79 return g = 0, h = function() { 80 g = new Date, e = null, f = a.apply(c, d) 81 }, 82 function() { 83 var i = new Date, 84 j = b - (i - g); 85 return c = this, d = arguments, 0 >= j ? (clearTimeout(e), e = null, g = i, f = a.apply(c, d)) : e || (e = setTimeout(h, j)), f 86 } 87 }, 88 noop: function() {} 89 }, c = "0.10.2", 90 d = function() { 91 function a(a) { 92 return a.split(/\s+/) 93 } 94 95 function b(a) { 96 return a.split(/\W+/) 97 } 98 99 function c(a) { 100 return function(b) { 101 return function(c) { 102 return a(c[b]) 103 } 104 } 105 } 106 return { 107 nonword: b, 108 whitespace: a, 109 obj: { 110 nonword: c(b), 111 whitespace: c(a) 112 } 113 } 114 }(), 115 e = function() { 116 function a(a) { 117 this.maxSize = a || 100, this.size = 0, this.hash = {}, this.list = new c 118 } 119 120 function c() { 121 this.head = this.tail = null 122 } 123 124 function d(a, b) { 125 this.key = a, this.val = b, this.prev = this.next = null 126 } 127 return b.mixin(a.prototype, { 128 set: function(a, b) { 129 var c, e = this.list.tail; 130 this.size >= this.maxSize && (this.list.remove(e), delete this.hash[e.key]), (c = this.hash[a]) ? (c.val = b, this.list.moveToFront(c)) : (c = new d(a, b), this.list.add(c), this.hash[a] = c, this.size++) 131 }, 132 get: function(a) { 133 var b = this.hash[a]; 134 return b ? (this.list.moveToFront(b), b.val) : void 0 135 } 136 }), b.mixin(c.prototype, { 137 add: function(a) { 138 this.head && (a.next = this.head, this.head.prev = a), this.head = a, this.tail = this.tail || a 139 }, 140 remove: function(a) { 141 a.prev ? a.prev.next = a.next : this.head = a.next, a.next ? a.next.prev = a.prev : this.tail = a.prev 142 }, 143 moveToFront: function(a) { 144 this.remove(a), this.add(a) 145 } 146 }), a 147 }(), 148 f = function() { 149 function a(a) { 150 this.prefix = ["__", a, "__"].join(""), this.ttlKey = "__ttl__", this.keyMatcher = new RegExp("^" + this.prefix) 151 } 152 153 function c() { 154 return (new Date).getTime() 155 } 156 157 function d(a) { 158 return JSON.stringify(b.isUndefined(a) ? null : a) 159 } 160 161 function e(a) { 162 return JSON.parse(a) 163 } 164 var f, g; 165 try { 166 f = window.localStorage, f.setItem("~~~", "!"), f.removeItem("~~~") 167 } catch (h) { 168 f = null 169 } 170 return g = f && window.JSON ? { 171 _prefix: function(a) { 172 return this.prefix + a 173 }, 174 _ttlKey: function(a) { 175 return this._prefix(a) + this.ttlKey 176 }, 177 get: function(a) { 178 return this.isExpired(a) && this.remove(a), e(f.getItem(this._prefix(a))) 179 }, 180 set: function(a, e, g) { 181 return b.isNumber(g) ? f.setItem(this._ttlKey(a), d(c() + g)) : f.removeItem(this._ttlKey(a)), f.setItem(this._prefix(a), d(e)) 182 }, 183 remove: function(a) { 184 return f.removeItem(this._ttlKey(a)), f.removeItem(this._prefix(a)), this 185 }, 186 clear: function() { 187 var a, b, c = [], 188 d = f.length; 189 for (a = 0; d > a; a++)(b = f.key(a)).match(this.keyMatcher) && c.push(b.replace(this.keyMatcher, "")); 190 for (a = c.length; a--;) this.remove(c[a]); 191 return this 192 }, 193 isExpired: function(a) { 194 var d = e(f.getItem(this._ttlKey(a))); 195 return b.isNumber(d) && c() > d ? !0 : !1 196 } 197 } : { 198 get: b.noop, 199 set: b.noop, 200 remove: b.noop, 201 clear: b.noop, 202 isExpired: b.noop 203 }, b.mixin(a.prototype, g), a 204 }(), 205 g = function() { 206 function c(b) { 207 b = b || {}, this._send = b.transport ? d(b.transport) : a.ajax, this._get = b.rateLimiter ? b.rateLimiter(this._get) : this._get 208 } 209 210 function d(c) { 211 return function(d, e) { 212 function f(a) { 213 b.defer(function() { 214 h.resolve(a) 215 }) 216 } 217 218 function g(a) { 219 b.defer(function() { 220 h.reject(a) 221 }) 222 } 223 var h = a.Deferred(); 224 return c(d, e, f, g), h 225 } 226 } 227 var f = 0, 228 g = {}, h = 6, 229 i = new e(10); 230 return c.setMaxPendingRequests = function(a) { 231 h = a 232 }, c.resetCache = function() { 233 i = new e(10) 234 }, b.mixin(c.prototype, { 235 _get: function(a, b, c) { 236 function d(b) { 237 c && c(null, b), i.set(a, b) 238 } 239 240 function e() { 241 c && c(!0) 242 } 243 244 function j() { 245 f--, delete g[a], l.onDeckRequestArgs && (l._get.apply(l, l.onDeckRequestArgs), l.onDeckRequestArgs = null) 246 } 247 var k, l = this; 248 (k = g[a]) ? k.done(d).fail(e) : h > f ? (f++, g[a] = this._send(a, b).done(d).fail(e).always(j)) : this.onDeckRequestArgs = [].slice.call(arguments, 0) 249 }, 250 get: function(a, c, d) { 251 var e; 252 return b.isFunction(c) && (d = c, c = {}), (e = i.get(a)) ? b.defer(function() { 253 d && d(null, e) 254 }) : this._get(a, c, d), !! e 255 } 256 }), c 257 }(), 258 h = function() { 259 function c(b) { 260 b = b || {}, b.datumTokenizer && b.queryTokenizer || a.error("datumTokenizer and queryTokenizer are both required"), this.datumTokenizer = b.datumTokenizer, this.queryTokenizer = b.queryTokenizer, this.reset() 261 } 262 263 function d(a) { 264 return a = b.filter(a, function(a) { 265 return !!a 266 }), a = b.map(a, function(a) { 267 return a.toLowerCase() 268 }) 269 } 270 271 function e() { 272 return { 273 ids: [], 274 children: {} 275 } 276 } 277 278 function f(a) { 279 for (var b = {}, c = [], d = 0; d < a.length; d++) b[a[d]] || (b[a[d]] = !0, c.push(a[d])); 280 return c 281 } 282 283 function g(a, b) { 284 function c(a, b) { 285 return a - b 286 } 287 var d = 0, 288 e = 0, 289 f = []; 290 for (a = a.sort(c), b = b.sort(c); d < a.length && e < b.length;) a[d] < b[e] ? d++ : a[d] > b[e] ? e++ : (f.push(a[d]), d++, e++); 291 return f 292 } 293 return b.mixin(c.prototype, { 294 bootstrap: function(a) { 295 this.datums = a.datums, this.trie = a.trie 296 }, 297 add: function(a) { 298 var c = this; 299 a = b.isArray(a) ? a : [a], b.each(a, function(a) { 300 var f, g; 301 f = c.datums.push(a) - 1, g = d(c.datumTokenizer(a
301)), b.each(g, function(a) { 302 var b, d, g; 303 for (b = c.trie, d = a.split(""); g = d.shift();) b = b.children[g] || (b.children[g] = e()), b.ids.push(f) 304 }) 305 }) 306 }, 307 get: function(a) { 308 var c, e, h = this; 309 return c = d(this.queryTokenizer(a)), b.each(c, function(a) { 310 var b, c, d, f; 311 if (e && 0 === e.length) return !1; 312 for (b = h.trie, c = a.split(""); b && (d = c.shift());) b = b.children[d]; 313 return b && 0 === c.length ? (f = b.ids.slice(0), void(e = e ? g(e, f) : f)) : (e = [], !1) 314 }), e ? b.map(f(e), function(a) { 315 return h.datums[a] 316 }) : [] 317 }, 318 reset: function() { 319 this.datums = [], this.trie = e() 320 }, 321 serialize: function() { 322 return { 323 datums: this.datums, 324 trie: this.trie 325 } 326 } 327 }), c 328 }(), 329 i = function() { 330 function d(a) { 331 return a.local || null 332 } 333 334 function e(d) { 335 var e, f; 336 return f = { 337 url: null, 338 thumbprint: "", 339 ttl: 864e5, 340 filter: null, 341 ajax: {} 342 }, (e = d.prefetch || null) && (e = b.isString(e) ? { 343 url: e 344 } : e, e = b.mixin(f, e), e.thumbprint = c + e.thumbprint, e.ajax.type = e.ajax.type || "GET", e.ajax.dataType = e.ajax.dataType || "json", !e.url && a.error("prefetch requires url to be set")), e 345 } 346 347 function f(c) { 348 function d(a) { 349 return function(c) { 350 return b.debounce(c, a) 351 } 352 } 353 354 function e(a) { 355 return function(c) { 356 return b.throttle(c, a) 357 } 358 } 359 var f, g; 360 return g = { 361 url: null, 362 wildcard: "%QUERY", 363 replace: null, 364 rateLimitBy: "debounce", 365 rateLimitWait: 300, 366 send: null, 367 filter: null, 368 ajax: {} 369 }, (f = c.remote || null) && (f = b.isString(f) ? { 370 url: f 371 } : f, f = b.mixin(g, f), f.rateLimiter = /^throttle$/i.test(f.rateLimitBy) ? e(f.rateLimitWait) : d(f.rateLimitWait), f.ajax.type = f.ajax.type || "GET", f.ajax.dataType = f.ajax.dataType || "json", delete f.rateLimitBy, delete f.rateLimitWait, !f.url && a.error("remote requires url to be set")), f 372 } 373 return { 374 local: d, 375 prefetch: e, 376 remote: f 377 } 378 }(); 379 ! function(c) { 380 function e(b) { 381 b && (b.local || b.prefetch || b.remote) || a.error("one of local, prefetch, or remote is required"), this.limit = b.limit || 5, this.sorter = j(b.sorter), this.dupDetector = b.dupDetector || k, this.local = i.local(b), this.prefetch = i.prefetch(b), this.remote = i.remote(b), this.cacheKey = this.prefetch ? this.prefetch.cacheKey || this.prefetch.url : null, this.index = new h({ 382 datumTokenizer: b.datumTokenizer, 383 queryTokenizer: b.queryTokenizer 384 }), this.storage = this.cacheKey ? new f(this.cacheKey) : null 385 } 386 387 function j(a) { 388 function c(b) { 389 return b.sort(a) 390 } 391 392 function d(a) { 393 return a 394 } 395 return b.isFunction(a) ? c : d 396 } 397 398 function k() { 399 return !1 400 } 401 var l, m; 402 return l = c.Bloodhound, m = { 403 data: "data", 404 protocol: "protocol", 405 thumbprint: "thumbprint" 406 }, c.Bloodhound = e, e.noConflict = function() { 407 return c.Bloodhound = l, e 408 }, e.tokenizers = d, b.mixin(e.prototype, { 409 _loadPrefetch: function(b) { 410 function c(a) { 411 f.clear(), f.add(b.filter ? b.filter(a) : a), f._saveToStorage(f.index.serialize(), b.thumbprint, b.ttl) 412 } 413 var d, e, f = this; 414 return (d = this._readFromStorage(b.thumbprint)) ? (this.index.bootstrap(d), e = a.Deferred().resolve()) : e = a.ajax(b.url, b.ajax).done(c), e 415 }, 416 _getFromRemote: function(a, b) { 417 function c(a, c) { 418 b(a ? [] : f.remote.filter ? f.remote.filter(c) : c) 419 } 420 var d, e, f = this; 421 return a = a || "", e = encodeURIComponent(a), d = this.remote.replace ? this.remote.replace(this.remote.url, a) : this.remote.url.replace(this.remote.wildcard, e), this.transport.get(d, this.remote.ajax, c) 422 }, 423 _saveToStorage: function(a, b, c) { 424 this.storage && (this.storage.set(m.data, a, c), this.storage.set(m.protocol, location.protocol, c), this.storage.set(m.thumbprint, b, c)) 425 }, 426 _readFromStorage: function(a) { 427 var b, c = {}; 428 return this.storage && (c.data = this.storage.get(m.data), c.protocol = this.storage.get(m.protocol), c.thumbprint = this.storage.get(m.thumbprint)), b = c.thumbprint !== a || c.protocol !== location.protocol, c.data && !b ? c.data : null 429 }, 430 _initialize: function() { 431 function c() { 432 e.add(b.isFunction(f) ? f() : f) 433 } 434 var d, e = this, 435 f = this.local; 436 return d = this.prefetch ? this._loadPrefetch(this.prefetch) : a.Deferred().resolve(), f && d.done(c), this.transport = this.remote ? new g(this.remote) : null, this.initPromise = d.promise() 437 }, 438 initialize: function(a) { 439 return !this.initPromise || a ? this._initialize() : this.initPromise 440 }, 441 add: function(a) { 442 this.index.add(a) 443 }, 444 get: function(a, c) { 445 function d(a) { 446 var d = f.slice(0); 447 b.each(a, function(a) { 448 var c; 449 return c = b.some(d, function(b) { 450 return e.dupDetector(a, b) 451 }), !c && d.push(a), d.length < e.limit 452 }), c && c(e.sorter(d)) 453 } 454 var e = this, 455 f = [], 456 g = !1; 457 f = this.index.get(a), f = this.sorter(f).slice(0, this.limit), f.length < this.limit && this.transport && (g = this._getFromRemote(a, d)), g || (f.length > 0 || !this.transport) && c && c(f) 458 }, 459 clear: function() { 460 this.index.reset() 461 }, 462 clearPrefetchCache: function() { 463 this.storage && this.storage.clear() 464 }, 465 clearRemoteCache: function() { 466 this.transport && g.resetCache() 467 },
vendor: 33,826 bytes, lines 468-1195
468 ttAdapter: function() { 469 return b.bind(this.get, this) 470 } 471 }), e 472 }(this); 473 var j = { 474 wrapper: '<span class="twitter-typeahead"></span>', 475 dropdown: '<span class="tt-dropdown-menu"></span>', 476 dataset: '<div class="tt-dataset-%CLASS%"></div>', 477 suggestions: '<span class="tt-suggestions"></span>', 478 suggestion: '<div class="tt-suggestion"></div>' 479 }, k = { 480 wrapper: { 481 position: "relative", 482 display: "block" 483 }, 484 hint: { 485 position: "absolute", 486 top: "0", 487 left: "0", 488 borderColor: "transparent", 489 boxShadow: "none" 490 }, 491 input: { 492 position: "relative", 493 verticalAlign: "top", 494 backgroundColor: "transparent" 495 }, 496 inputWithNoHint: { 497 position: "relative", 498 verticalAlign: "top" 499 }, 500 dropdown: { 501 position: "absolute", 502 top: "100%", 503 left: "0", 504 zIndex: "100", 505 display: "none" 506 }, 507 suggestions: { 508 display: "block" 509 }, 510 suggestion: { 511 whiteSpace: "nowrap", 512 cursor: "pointer" 513 }, 514 suggestionChild: { 515 whiteSpace: "normal" 516 }, 517 ltr: { 518 left: "0", 519 right: "auto" 520 }, 521 rtl: { 522 left: "auto", 523 right: " 0" 524 } 525 }; 526 b.isMsie() && b.mixin(k.input, { 527 backgroundImage: "url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)" 528 }), b.isMsie() && b.isMsie() <= 7 && b.mixin(k.input, { 529 marginTop: "-1px" 530 }); 531 var l = function() { 532 function c(b) { 533 b && b.el || a.error("EventBus initialized without el"), this.$el = a(b.el) 534 } 535 var d = "typeahead:"; 536 return b.mixin(c.prototype, { 537 trigger: function(a) { 538 var b = [].slice.call(arguments, 1); 539 this.$el.trigger(d + a, b) 540 } 541 }), c 542 }(), 543 m = function() { 544 function a(a, b, c, d) { 545 var e; 546 if (!c) return this; 547 for (b = b.split(i), c = d ? h(c, d) : c, this._callbacks = this._callbacks || {}; e = b.shift();) this._callbacks[e] = this._callbacks[e] || { 548 sync: [], 549 async: [] 550 }, this._callbacks[e][a].push(c); 551 return this 552 } 553 554 function b(b, c, d) { 555 return a.call(this, "async", b, c, d) 556 } 557 558 function c(b, c, d) { 559 return a.call(this, "sync", b, c, d) 560 } 561 562 function d(a) { 563 var b; 564 if (!this._callbacks) return this; 565 for (a = a.split(i); b = a.shift();) delete this._callbacks[b]; 566 return this 567 } 568 569 function e(a) { 570 var b, c, d, e, g; 571 if (!this._callbacks) return this; 572 for (a = a.split(i), d = [].slice.call(arguments, 1); 573 (b = a.shift()) && (c = this._callbacks[b]);) e = f(c.sync, this, [b].concat(d)), g = f(c.async, this, [b].concat(d)), e() && j(g); 574 return this 575 } 576 577 function f(a, b, c) { 578 function d() { 579 for (var d, e = 0; !d && e < a.length; e += 1) d = a[e].apply(b, c) === !1; 580 return !d 581 } 582 return d 583 } 584 585 function g() { 586 var a; 587 return a = window.setImmediate ? function(a) { 588 setImmediate(function() { 589 a() 590 }) 591 } : function(a) { 592 setTimeout(function() { 593 a() 594 }, 0) 595 } 596 } 597 598 function h(a, b) { 599 return a.bind ? a.bind(b) : function() { 600 a.apply(b, [].slice.call(arguments, 0)) 601 } 602 } 603 var i = /\s+/, 604 j = g(); 605 return { 606 onSync: c, 607 onAsync: b, 608 off: d, 609 trigger: e 610 } 611 }(), 612 n = function(a) { 613 function c(a, c, d) { 614 for (var e, f = [], g = 0; g < a.length; g++) f.push(b.escapeRegExChars(a[g])); 615 return e = d ? "\\b(" + f.join("|") + ")\\b" : "(" + f.join("|") + ")", c ? new RegExp(e) : new RegExp(e, "i") 616 } 617 var d = { 618 node: null, 619 pattern: null, 620 tagName: "strong", 621 className: null, 622 wordsOnly: !1, 623 caseSensitive: !1 624 }; 625 return function(e) { 626 function f(b) { 627 var c, d; 628 return (c = h.exec(b.data)) && (wrapperNode = a.createElement(e.tagName), e.className && (wrapperNode.className = e.className), d = b.splitText(c.index), d.splitText(c[0].length), wrapperNode.appendChild(d.cloneNode(!0)), b.parentNode.replaceChild(wrapperNode, d)), !! c 629 } 630 631 function g(a, b) { 632 for (var c, d = 3, e = 0; e < a.childNodes.length; e++) c = a.childNodes[e], c.nodeType === d ? e += b(c) ? 1 : 0 : g(c, b) 633 } 634 var h; 635 e = b.mixin({}, d, e), e.node && e.pattern && (e.pattern = b.isArray(e.pattern) ? e.pattern : [e.pattern], h = c(e.pattern, e.caseSensitive, e.wordsOnly), g(e.node, f)) 636 } 637 }(window.document), 638 o = function() { 639 function c(c) { 640 var e, f, h, i, j = this; 641 c = c || {}, c.input || a.error("input is missing"), e = b.bind(this._onBlur, this), f = b.bind(this._onFocus, this), h = b.bind(this._onKeydown, this), i = b.bind(this._onInput, this), this.$hint = a(c.hint), this.$input = a(c.input).on("blur.tt", e).on("focus.tt", f).on("keydown.tt", h), 0 === this.$hint.length && (this.setHint = this.getHint = this.clearHint = this.clearHintIfInvalid = b.noop), b.isMsie() ? this.$input.on("keydown.tt keypress.tt cut.tt paste.tt", function(a) { 642 g[a.which || a.keyCode] || b.defer(b.bind(j._onInput, j, a)) 643 }) : this.$input.on("input.tt", i), this.query = this.$input.val(), this.$overflowHelper = d(this.$input) 644 } 645 646 function d(b) { 647 return a('<pre aria-hidden="true"></pre>').css({ 648 position: "absolute", 649 visibility: "hidden", 650 whiteSpace: "pre", 651 fontFamily: b.css("font-family"), 652 fontSize: b.css("font-size"), 653 fontStyle: b.css("font-style"), 654 fontVariant: b.css("font-variant"), 655 fontWeight: b.css("font-weight"), 656 wordSpacing: b.css("word-spacing"), 657 letterSpacing: b.css("letter-spacing"), 658 textIndent: b.css("text-indent"), 659 textRendering: b.css("text-rendering"), 660 textTransform: b.css("text-transform") 661 }).insertAfter(b) 662 } 663 664 function e(a, b) { 665 return c.normalizeQuery(a) === c.normalizeQuery(b) 666 } 667 668 function f(a) { 669 return a.altKey || a.ctrlKey || a.metaKey || a.shiftKey 670 } 671 var g; 672 return g = { 673 9: "tab", 674 27: "esc", 675 37: "left", 676 39: "right", 677 13: "enter", 678 38: "up", 679 40: "down" 680 }, c.normalizeQuery = function(a) { 681 return (a || "").replace(/^\s*/g, "").replace(/\s{2,}/g, " ") 682 }, b.mixin(c.prototype, m, { 683 _onBlur: function() { 684 this.resetInputValue(), this.trigger("blurred") 685 }, 686 _onFocus: function() { 687 this.trigger("focused") 688 }, 689 _onKeydown: function(a) { 690 var b = g[a.which || a.keyCode]; 691 this._managePreventDefault(b, a), b && this._shouldTrigger(b, a) && this.trigger(b + "Keyed", a) 692 }, 693 _onInput: function() { 694 this._checkInputValue() 695 }, 696 _managePreventDefault: function(a, b) { 697 var c, d, e; 698 switch (a) { 699 case "tab": 700 d = this.getHint(), e = this.getInputValue(), c = d && d !== e && !f(b); 701 break; 702 case "up": 703 case "down": 704 c = !f(b); 705 break; 706 default: 707 c = !1 708 } 709 c && b.preventDefault() 710 }, 711 _shouldTrigger: function(a, b) { 712 var c; 713 switch (a) { 714 case "tab": 715 c = !f(b); 716 break; 717 default: 718 c = !0 719 } 720 return c 721 }, 722 _checkInputValue: function() { 723 var a, b, c; 724 a = this.getInputValue(), b = e(a, this.query), c = b ? this.query.length !== a.length : !1, b ? c && this.trigger("whitespaceChanged", this.query) : this.trigger("queryChanged", this.query = a) 725 }, 726 focus: function() { 727 this.$input.focus() 728 }, 729 blur: function() { 730 this.$input.blur() 731 }, 732 getQuery: function() { 733 return this.query 734 }, 735 setQuery: function(a) { 736 this.query = a 737 }, 738 getInputValue: function() { 739 return this.$input.val() 740 }, 741 setInputValue: function(a, b) { 742 this.$input.val(a), b ? this.clearHint() : this._checkInputValue() 743 }, 744 resetInputValue: function() { 745 this.setInputValue(this.query, !0) 746 }, 747 getHint: function() { 748 return this.$hint.val() 749 }, 750 setHint: function(a) { 751 this.$hint.val(a) 752 }, 753 clearHint: function() { 754 this.setHint("") 755 }, 756 clearHintIfInvalid: function() { 757 var a, b, c, d; 758 a = this.getInputValue(), b = this.getHint(), c = a !== b && 0 === b.indexOf(a), d = "" !== a && c && !this.hasOverflow(), !d && this.clearHint() 759 }, 760 getLanguageDirection: function() { 761 return (this.$input.css("direction") || "ltr").toLowerCase() 762 }, 763 hasOverflow: function() { 764 var a = this.$input.width() - 2; 765 return this.$overflowHelper.text(this.getInputValue()), this.$overflowHelper.width() >= a 766 }, 767 isCursorAtEnd: function() { 768 var a, c, d; 769 return a = this.$input.val().length, c = this.$input[0].selectionStart, b.isNumber(c) ? c === a : document.selection ? (d = document.selection.createRange(), d.moveStart("character", -a), a === d.text.length) : !0 770 }, 771 destroy: function() { 772 this.$hint.off(".tt"), this.$input.off(".tt"), this.$hint = this.$input = this.$overflowHelper = null 773 } 774 }), c 775 }(), 776 p = function() { 777 function c(c) { 778 c = c || {}, c.templates = c.templates || {}, c.source || a.error("missing source"), c.name && !f(c.name) && a.error("invalid dataset name: " + c.name), this.query = null, this.highlight = !! c.highlight, this.name = c.name || b.getUniqueId(), this.source = c.source, this.displayFn = d(c.display || c.displayKey), this.templates = e(c.templates, this.displayFn), this.$el = a(j.dataset.replace("%CLASS%", this.name)) 779 } 780 781 function d(a) { 782 function c(b) { 783 return b[a] 784 } 785 return a = a || "value", b.isFunction(a) ? a : c 786 } 787 788 function e(a, c) { 789 function d(a) { 790 return "<p>" + c(a) + "</p>" 791 } 792 return { 793 empty: a.empty && b.templatify(a.empty), 794 header: a.header && b.templatify(a.header), 795 footer: a.footer && b.templatify(a.footer), 796 suggestion: a.suggestion || d 797 } 798 } 799 800 function f(a) { 801 return /^[_a-zA-Z0-9-]+$/.test(a) 802 } 803 var g = "ttDataset", 804 h = "ttValue", 805 i = "ttDatum"; 806 return c.extractDatasetName = function(b) { 807 return a(b).data(g) 808 }, c.extractValue = function(b) { 809 return a(b).data(h) 810 }, c.extractDatum = function(b) { 811 return a(b).data(i) 812 }, b.mixin(c.prototype, m, { 813 _render: function(c, d) { 814 function e() { 815 return p.templates.empty({ 816 query: c, 817 isEmpty: !0 818 }) 819 } 820 821 function f() { 822 function e(b) { 823 var c; 824 return c = a(j.suggestion).append(p.templates.suggestion(b)).data(g, p.name).data(h, p.displayFn(b)).data(i, b), c.children().each(function() { 825 a(this).css(k.suggestionChild) 826 }), c 827 } 828 var f, l; 829 return f = a(j.suggestions).css(k.suggestions), l = b.map(d, e), f.append.apply(f, l), p.highlight && n({ 830 node: f[0], 831 pattern: c 832 }), f 833 } 834 835 function l() { 836 return p.templates.header({ 837 query: c, 838 isEmpty: !o 839 }) 840 } 841 842 function m() { 843 return p.templates.footer({ 844 query: c, 845 isEmpty: !o 846 }) 847 } 848 if (this.$el) { 849 var o, p = this; 850 this.$el.empty(), o = d && d.length, !o && this.templates.empty ? this.$el.html(e()).prepend(p.templates.header ? l() : null).append(p.templates.footer ? m() : null) : o && this.$el.html(f()).prepend(p.templates.header ? l() : null).append(p.templates.footer ? m() : null), this.trigger("rendered") 851 } 852 }, 853 getRoot: function() { 854 return this.$el 855 }, 856 update: function(a) { 857 function b(b) { 858 c.canceled || a !== c.query || c._render(a, b) 859 } 860 var c = this; 861 this.query = a, this.canceled = !1, this.source(a, b) 862 }, 863 cancel: function() { 864 this.canceled = !0 865 }, 866 clear: function() { 867 this.cancel(), this.$el.empty(), this.trigger("rendered") 868 }, 869 isEmpty: function() { 870 return this.$el.is(":empty") 871 }, 872 destroy: function() { 873 this.$el = null 874 } 875 }), c 876 }(), 877 q = function() { 878 function c(c) { 879 var e, f, g, h = this; 880 c = c || {}, c.menu || a.error("menu is required"), this.isOpen = !1, this.isEmpty = !0, this.datasets = b.map(c.datasets, d), e = b.bind(this._onSuggestionClick, this), f = b.bind(this._onSuggestionMouseEnter, this), g = b.bind(this._onSuggestionMouseLeave, this), this.$menu = a(c.menu).on("click.tt", ".tt-suggestion", e).on("mouseenter.tt", ".tt-suggestion", f).on("mouseleave.tt", ".tt-suggestion", g), b.each(this.datasets, function(a) { 881 h.$menu.append(a.getRoot()), a.onSync("rendered", h._onRendered, h) 882 }) 883 } 884 885 function d(a) { 886 return new p(a) 887 } 888 return b.mixin(c.prototype, m, { 889 _onSuggestionClick: function(b) { 890 this.trigger("suggestionClicked", a(b.currentTarget)) 891 }, 892 _onSuggestionMouseEnter: function(b) { 893 this._removeCursor(), this._setCursor(a(b.currentTarget), !0) 894 }, 895 _onSuggestionMouseLeave: function() { 896 this._removeCursor() 897 }, 898 _onRendered: function() { 899 function a(a) { 900 return a.isEmpty() 901 } 902 this.isEmpty = b.every(this.datasets, a), this.isEmpty ? this._hide() : this.isOpen && this._show(), this.trigger("datasetRendered") 903 }, 904 _hide: function() { 905 this.$menu.hide() 906 }, 907 _show: function() { 908 this.$menu.css("display", "block") 909 }, 910 _getSuggestions: function() { 911 return this.$menu.find(".tt-suggestion") 912 }, 913 _getCursor: function() { 914 return this.$menu.find(".tt-cursor").first() 915 }, 916 _setCursor: function(a, b) { 917 a.first().addClass("tt-cursor"), !b && this.trigger("cursorMoved") 918 }, 919 _removeCursor: function() { 920 this._getCursor().removeClass("tt-cursor") 921 }, 922 _moveCursor: function(a) { 923 var b, c, d, e; 924 if (this.isOpen) { 925 if (c = this._getCursor(), b = this._getSuggestions(), this._removeCursor(), d = b.index(c) + a, d = (d + 1) % (b.length + 1) - 1, -1 === d) return void this.trigger("cursorRemoved"); - 1 > d && (d = b.length - 1), this._setCursor(e = b.eq(d)), this._ensureVisible(e) 926 } 927 }, 928 _ensureVisible: function(a) { 929 var b, c, d, e; 930 b = a.position().top, c = b + a.outerHeight(!0), d = this.$menu.scrollTop(), e = this.$menu.height() + parseInt(this.$menu.css("paddingTop"), 10) + parseInt(this.$menu.css("paddingBottom"), 10), 0 > b ? this.$menu.scrollTop(d + b) : c > e && this.$menu.scrollTop(d + (c - e)) 931 }, 932 close: function() { 933 this.isOpen && (this.isOpen = !1, this._removeCursor(), this._hide(), this.trigger("closed")) 934 }, 935 open: function() { 936 this.isOpen || (this.isOpen = !0, !this.isEmpty && this._show(), this.trigger("opened")) 937 }, 938 setLanguageDirection: function(a) { 939 this.$menu.css("ltr" === a ? k.ltr : k.rtl) 940 }, 941 moveCursorUp: function() { 942 this._moveCursor(-1) 943 }, 944 moveCursorDown: function() { 945 this._moveCursor(1) 946 }, 947 getDatumForSuggestion: function(a) { 948 var b = null; 949 return a.length && (b = { 950 raw: p.extractDatum(a), 951 value: p.extractValue(a), 952 datasetName: p.extractDatasetName(a) 953 }), b 954 }, 955 getDatumForCursor: function() { 956 return this.getDatumForSuggestion(this._getCursor().first()) 957 }, 958 getDatumForTopSuggestion: function() { 959 return this.getDatumForSuggestion(this._getSuggestions().first()) 960 }, 961 update: function(a) { 962 function c(b) { 963 b.update(a) 964 } 965 b.each(this.datasets, c) 966 }, 967 empty: function() { 968 function a(a) { 969 a.clear() 970 } 971 b.each(this.datasets, a), this.isEmpty = !0 972 }, 973 isVisible: function() { 974 return this.isOpen && !this.isEmpty 975 }, 976 destroy: function() { 977 function a(a) { 978 a.destroy() 979 } 980 this.$menu.off(".tt"), this.$menu = null, b.each(this.datasets, a) 981 } 982 }), c 983 }(), 984 r = function() { 985 function c(c) { 986 var e, f, g; 987 c = c || {}, c.input || a.error("missing input"), this.isActivated = !1, this.autoselect = !! c.autoselect, this.minLength = b.isNumber(c.minLength) ? c.minLength : 1, this.$node = d(c.input, c.withHint), e = this.$node.find(".tt-dropdown-menu"), f = this.$node.find(".tt-input"), g = this.$node.find(".tt-hint"), f.on("blur.tt", function(a) { 988 var c, d, g; 989 c = document.activeElement, d = e.is(c), g = e.has(c).length > 0, b.isMsie() && (d || g) && (a.preventDefault(), a.stopImmediatePropagation(), b.defer(function() { 990 f.focus() 991 })) 992 }), e.on("mousedown.tt", function(a) { 993 a.preventDefault() 994 }), this.eventBus = c.eventBus || new l({ 995 el: f 996 }), this.dropdown = new q({ 997 menu: e, 998 datasets: c.datasets 999 }).onSync("suggestionClicked", this._onSuggestionClicked, this).onSync("cursorMoved", this._onCursorMoved, this).onSync("cursorRemoved", this._onCursorRemoved, this).onSync("opened", this._onOpened, this).onSync("closed", this._onClosed, this).onAsync("datasetRendered", this._onDatasetRendered, this), this.input = new o({ 1000 input: f, 1001 hint: g 1002 }).onSync("focused", this._onFocused, this).onSync("blurred", this._onBlurred, this).onSync("enterKeyed", this._onEnterKeyed, this).onSync("tabKeyed", this._onTabKeyed, this).onSync("escKeyed", this._onEscKeyed, this).onSync("upKeyed", this._onUpKeyed, this).onSync("downKeyed", this._onDownKeyed, this).onSync("leftKeyed", this._onLeftKeyed, this).onSync("rightKeyed", this._onRightKeyed, this).onSync("queryChanged", this._onQueryChanged, this).onSync("whitespaceChanged", this._onWhitespaceChanged, this), this._setLanguageDirection() 1003 } 1004 1005 function d(b, c) { 1006 var d, f, h, i; 1007 d = a(b), f = a(j.wrapper).css(k.wrapper), h = a(j.dropdown).css(k.dropdown), i = d.clone().css(k.hint).css(e(d)), i.val("").removeData().addClass("tt-hint").removeAttr("id name placeholder").prop("disabled", !0).attr({ 1008 autocomplete: "off", 1009 spellcheck: "false" 1010 }), d.data(g, { 1011 dir: d.attr("dir"), 1012 autocomplete: d.attr("autocomplete"), 1013 spellcheck: d.attr("spellcheck"), 1014 style: d.attr("style") 1015 }), d.addClass("tt-input").attr({ 1016 autocomplete: "off", 1017 spellcheck: !1 1018 }).css(c ? k.input : k.inputWithNoHint); 1019 try { 1020 !d.attr("dir") && d.attr("dir", "auto") 1021 } catch (l) {} 1022 return d.wrap(f).parent().prepend(c ? i : null).append(h) 1023 } 1024 1025 function e(a) { 1026 return { 1027 backgroundAttachment: a.css("background-attachment"), 1028 backgroundClip: a.css("background-clip"), 1029 backgroundColor: a.css("background-color"), 1030 backgroundImage: a.css("background-image"), 1031 backgroundOrigin: a.css("background-origin"), 1032 backgroundPosition: a.css("background-position"), 1033 backgroundRepeat: a.css("background-repeat"), 1034 backgroundSize: a.css("background-size") 1035 } 1036 } 1037 1038 function f(a) { 1039 var c = a.find(".tt-input"); 1040 b.each(c.data(g), function(a, d) { 1041 b.isUndefined(a) ? c.removeAttr(d) : c.attr(d, a) 1042 }), c.detach().removeData(g).removeClass("tt-input").insertAfter(a), a.remove() 1043 } 1044 var g = "ttAttrs"; 1045 return b.mixin(c.prototype, { 1046 _onSuggestionClicked: function(a, b) { 1047 var c; 1048 (c = this.dropdown.getDatumForSuggestion(b)) && this._select(c) 1049 }, 1050 _onCursorMoved: function() { 1051 var a = this.dropdown.getDatumForCursor(); 1052 this.input.setInputValue(a.value, !0), this.eventBus.trigger("cursorchanged", a.raw, a.datasetName) 1053 }, 1054 _onCursorRemoved: function() { 1055 this.input.resetInputValue(), this._updateHint() 1056 }, 1057 _onDatasetRendered: function() { 1058 this._updateHint() 1059 }, 1060 _onOpened: function() { 1061 this._updateHint(), this.eventBus.trigger("opened") 1062 }, 1063 _onClosed: function() { 1064 this.input.clearHint(), this.eventBus.trigger("closed") 1065 }, 1066 _onFocused: function() { 1067 this.isActivated = !0, this.dropdown.open() 1068 }, 1069 _onBlurred: function() { 1070 this.isActivated = !1, this.dropdown.empty(), this.dropdown.close() 1071 }, 1072 _onEnterKeyed: function(a, b) { 1073 var c, d; 1074 c = this.dropdown.getDatumForCursor(), d = this.dropdown.getDatumForTopSuggestion(), c ? (this._select(c), b.preventDefault()) : this.autoselect && d && (this._select(d), b.preventDefault()) 1075 }, 1076 _onTabKeyed: function(a, b) { 1077 var c; 1078 (c = this.dropdown.getDatumForCursor()) ? (this._select(c), b.preventDefault()) : this._autocomplete(!0) 1079 }, 1080 _onEscKeyed: function() { 1081 this.dropdown.close(), this.input.resetInputValue() 1082 }, 1083 _onUpKeyed: function() { 1084 var a = this.input.getQuery(); 1085 this.dropdown.isEmpty && a.length >= this.minLength ? this.dropdown.update(a) : this.dropdown.moveCursorUp(), this.dropdown.open() 1086 }, 1087 _onDownKeyed: function() { 1088 var a = this.input.getQuery(); 1089 this.dropdown.isEmpty && a.length >= this.minLength ? this.dropdown.update(a) : this.dropdown.moveCursorDown(), this.dropdown.open() 1090 }, 1091 _onLeftKeyed: function() { 1092 "rtl" === this.dir && this._autocomplete() 1093 }, 1094 _onRightKeyed: function() { 1095 "ltr" === this.dir && this._autocomplete() 1096 }, 1097 _onQueryChanged: function(a, b) { 1098 this.input.clearHintIfInvalid(), b.length >= this.minLength ? this.dropdown.update(b) : this.dropdown.empty(), this.dropdown.open(), this._setLanguageDirection() 1099 }, 1100 _onWhitespaceChanged: function() { 1101 this._updateHint(), this.dropdown.open() 1102 }, 1103 _setLanguageDirection: function() { 1104 var a; 1105 this.dir !== (a = this.input.getLanguageDirection()) && (this.dir = a, this.$node.css("direction", a), this.dropdown.setLanguageDirection(a)) 1106 }, 1107 _updateHint: function() { 1108 var a, c, d, e, f, g; 1109 a = this.dropdown.getDatumForTopSuggestion(), a && this.dropdown.isVisible() && !this.input.hasOverflow() ? (c = this.input.getInputValue(), d = o.normalizeQuery(c), e = b.escapeRegExChars(d), f = new RegExp("^(?:" + e + ")(.+$)", "i"), g = f.exec(a.value), g ? this.input.setHint(c + g[1]) : this.input.clearHint()) : this.input.clearHint() 1110 }, 1111 _autocomplete: function(a) { 1112 var b, c, d, e; 1113 b = this.input.getHint(), c = this.input.getQuery(), d = a || this.input.isCursorAtEnd(), b && c !== b && d && (e = this.dropdown.getDatumForTopSuggestion(), e && this.input.setInputValue(e.value), this.eventBus.trigger("autocompleted", e.raw, e.datasetName)) 1114 }, 1115 _select: function(a) { 1116 this.input.setQuery(a.value), this.input.setInputValue(a.value, !0), this._setLanguageDirection(), this.eventBus.trigger("selected", a.raw, a.datasetName), this.dropdown.close(), b.defer(b.bind(this.dropdown.empty, this.dropdown)) 1117 }, 1118 open: function() { 1119 this.dropdown.open() 1120 }, 1121 close: function() { 1122 this.dropdown.close() 1123 }, 1124 setVal: function(a) { 1125 this.isActivated ? this.input.setInputValue(a) : (this.input.setQuery(a), this.input.setInputValue(a, !0)), this._setLanguageDirection() 1126 }, 1127 getVal: function() { 1128 return this.input.getQuery() 1129 }, 1130 destroy: function() { 1131 this.input.destroy(), this.dropdown.destroy(), f(this.$node), this.$node = null 1132 } 1133 }), c 1134 }(); 1135 ! function() { 1136 var c, d, e; 1137 c = a.fn.typeahead, d = "ttTypeahead", e = { 1138 initialize: function(c, e) { 1139 function f() { 1140 var f, g, h = a(this); 1141 b.each(e, function(a) { 1142 a.highlight = !! c.highlight 1143 }), g = new r({ 1144 input: h, 1145 eventBus: f = new l({ 1146 el: h 1147 }), 1148 withHint: b.isUndefined(c.hint) ? !0 : !! c.hint, 1149 minLength: c.minLength, 1150 autoselect: c.autoselect, 1151 datasets: e 1152 }), h.data(d, g) 1153 } 1154 return e = b.isArray(e) ? e : [].slice.call(arguments, 1), c = c || {}, this.each(f) 1155 }, 1156 open: function() { 1157 function b() { 1158 var b, c = a(this); 1159 (b = c.data(d)) && b.open() 1160 } 1161 return this.each(b) 1162 }, 1163 close: function() { 1164 function b() { 1165 var b, c = a(this); 1166 (b = c.data(d)) && b.close() 1167 } 1168 return this.each(b) 1169 }, 1170 val: function(b) { 1171 function c() { 1172 var c, e = a(this); 1173 (c = e.data(d)) && c.setVal(b) 1174 } 1175 1176 function e(a) { 1177 var b, c; 1178 return (b = a.data(d)) && (c = b.getVal()), c 1179 } 1180 return arguments.length ? this.each(c) : e(this.first()) 1181 }, 1182 destroy: function() { 1183 function b() { 1184 var b, c = a(this); 1185 (b = c.data(d)) && (b.destroy(), c.removeData(d)) 1186 } 1187 return this.each(b) 1188 } 1189 }, a.fn.typeahead = function(a) { 1190 return e[a] ? e[a].apply(this, [].slice.call(arguments, 1)) : e.initialize.apply(this, arguments) 1191 }, a.fn.typeahead.noConflict = function() { 1192 return a.fn.typeahead = c, this 1193 } 1194 }() 1195}(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.