throttle iFrame loading in CoffeeScript

15 Jan
$.fn.src = (url, throttle) ->
????namespace = arguments.callee
????return if ($iframe=$(this)).attr("src")==url
????throttle = throttle||5000
????now = +new Date
????clearTimeout(arguments.callee.timer)
????timeSinceLastReload = +new Date – (namespace.lastReload||0)
????timeTillReload = Math.max(0,throttle-timeSinceLastReload)
????namespace.timer = setTimeout( () -> ?? ??$iframe.attr("src", url) ?? ??namespace.lastReload = now
????, timeTillReload)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: