-
Notifications
You must be signed in to change notification settings - Fork 22
/
jquery.wanker.coffee
51 lines (43 loc) · 1.15 KB
/
jquery.wanker.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# Wanker 0.1.2
# http://mig.io/makes/wanker
#
# The web was meant to be read, not squished.
# Display a message on excessive browser resizing.
#
# MIT License
#
# by Mig Reyes, Designer at Basecamp
# http://twitter.com/migreyes
#
do (jQuery = $) ->
$.fn.wanker = (options) ->
settings = $.extend
delay: 1000
duration: 1500
, options
@each ->
$message = $(@)
mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
unless mobile
fired = false
start = null
elapsed = null
timer = null
reset = ->
fired = false
elapsed = null
$(window).resize ->
if fired
elapsed = Math.abs(new Date() - start)
else
start = new Date()
fired = true
# Reveal the message after the delay is surpassed.
if elapsed > settings.delay then $message.fadeIn()
# Countdown timer before closing and resetting.
clearTimeout timer if timer
timer = setTimeout ->
$message.fadeOut()
reset()
, settings.duration