forked from henriqueboaventura/jquery.idle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
49 lines (49 loc) · 1.43 KB
/
index.html
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
<html>
<head>
<title>jQuery Idle</title>
<style>
#status, #visibility{
background-color: #E6EFC2;
border-color: #C6D880;
color: #264409;
padding:20px;
text-align: center;
width:100px;
}
#status.idle, #visibility.idle{
background-color: #FFF6BF;
border-color: #FFD324;
color: #514721;
}
</style>
</head>
<body>
<h1>jQuery Idle</h1>
<p>This is a simple example that will print in the box below the user status (active or idle). In this example, after 5 seconds idle, it will be displayed... "Idle!", of course :)</p>
<div id="status">Active!</div>
<div id="visibility">Visible!</div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.idle.js"></script>
<script type="text/javascript">
$(document).idle({
onIdle: function(){
$('#status').toggleClass('idle').html('Idle!');
},
onActive: function(){
$('#status').toggleClass('idle').html('Active!');
},
onHide: function(){
$('#visibility').toggleClass('idle').html('Hidden!');
},
onShow: function(){
// Add a slight pause so you can see the change
setTimeout(function(){
$('#visibility').toggleClass('idle').html('Visible!');
}, 250);
},
idle: 2000,
keepTracking: true
});
</script>
</body>
</html>