forked from migreyes/jquery.wanker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.wanker.js
58 lines (56 loc) · 1.47 KB
/
jquery.wanker.js
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
52
53
54
55
56
57
58
//
// 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
//
(function() {
(function(jQuery) {
return $.fn.wanker = function(options) {
var settings;
settings = $.extend({
delay: 1000,
duration: 1500
}, options);
return this.each(function() {
var $message, elapsed, fired, mobile, reset, start, timer;
$message = $(this);
mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (!mobile) {
fired = false;
start = null;
elapsed = null;
timer = null;
reset = function() {
fired = false;
return elapsed = null;
};
return $(window).resize(function() {
if (fired) {
elapsed = Math.abs(new Date() - start);
} else {
start = new Date();
fired = true;
}
if (elapsed > settings.delay) {
$message.fadeIn();
}
if (timer) {
clearTimeout(timer);
}
return timer = setTimeout(function() {
$message.fadeOut();
return reset();
}, settings.duration);
});
}
});
};
})($);
}).call(this);