Created
November 18, 2016 10:27
-
-
Save vinhlh/1268d389f0d55edce463eece1bc3b532 to your computer and use it in GitHub Desktop.
Typehead facebook search implement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.prototype.throttleSendRemoteQuery = function() { | |
'use strict'; | |
var n = c('FacebarGlobalOptions').sendRemoteQueryThrottleTime; | |
if (n === 0) { | |
this.sendRemoteQueryThrottled = this.sendRemoteQuery; | |
} else if (c('FacebarGlobalOptions').lazyThrottleRemoteQuery) { | |
var o = Date.now() | |
, p = c('FacebarGlobalOptions').enableSendRemoteQueryDelay | |
, q = c('FacebarGlobalOptions').sendRemoteQueryDelayTime; | |
this.sendRemoteQueryThrottled = function() { | |
for (var r = arguments.length, s = Array(r), t = 0; t < r; t++) | |
s[t] = arguments[t]; | |
var u = Date.now(); | |
if (o + n < u) { | |
o = u; | |
if (p) { | |
c('setTimeoutAcrossTransitions')(function() { | |
this.sendRemoteQuery.apply(this, s); | |
} | |
.bind(this), q); | |
} else | |
this.sendRemoteQuery.apply(this, s); | |
} | |
} | |
.bind(this); | |
} else { | |
if (c('FacebarGlobalOptions').typingSpeedThrottleTime > 0) | |
n = c('FacebarGlobalOptions').typingSpeedThrottleTime; | |
this.sendRemoteQueryThrottled = c('throttle').withBlocking(this.sendRemoteQuery, n, this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment