
var napTime = 0;
var isSleeping = false; //Hey, I'm not sleeping
function initSleepMode() {
if(typeof(jQuery) == “undefined”) {
setTimeout(“initSleepMode();”, 100); //Oops, no dinner yet
}
else {
jQuery(function() {
jQuery(document).ready(function() {
setInterval(“isNapping();”, 1000); //Increase napping time
jQuery(“body”).append(‘
Sleeping mode…
-By Tutkiun.com
‘);
jQuery(“#divSleep”).hide();
jQuery(document).keypress(function(e) {
napTime = 0;
wakeUp();
});
jQuery(this).mousemove(function(e) {
napTime = 0;
wakeUp();
});
});
});
}
}
Napping, Sleeping and Wake-up
function isNapping() { //Keep my bed ready..
napTime += 10;
if(napTime > 60) {
sleepMode();
}
}
function sleepMode() { //huh! I’m feelin sleepy
if(!isSleeping) {
jQuery(“#divSleep”).show().css({
height: “0″,
width: “0″,
left: “10%”,
top: “10%”
}).animate({
width: “100%”,
height: jQuery(window).height(),
left: “0″,
top: “0″,
opacity: “1″
}, 1500);
isSleeping = true;
}
}
function wakeUp() { //Wake’up Time!
if(isSleeping) {
jQuery(“#divSleep”).animate({
width: “0″,
height: “0″,
opacity: “0″,
left: “50%”,
top: “50%”
}, 500);
setTimeout(‘jQuery(“#divSleep”).hide();’, 700);
isSleeping = false;
}
}
Adding Styles
CSS styles can be applied to newly inserted div as
div#divSleep{
margin: 0; padding: 0;
position: absolute;
left: 50%; top: 50%; opacity: 0;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";/* IE, sucks
*/
filter: alpha(opacity=0); text-align: center;
z-index: 100; border: 0; background-color: #000000;
}
@media screen{body>div#divSleep { position: fixed;}}
div#divSleep p {
margin: 0; padding: 0;
width: 100%; font-size: 32px;
font-family: arial; color:#242424;
position: relative; top: 45%;
line-height: 20px; font-weight: bolder;
text-align: center;
}
Merging and Packaging
We are now done with implementing all functionalities. The above code modules should be integrated in a sequence with your web pages as
-
ellisgl
-
http://www.tutkiun.com/ Mayur
-
Bkilinc
-
Joe
-
http://www.tutkiun.com/ Mayur
-
http://www.sareez.com/ sarees
-
http://www.sareez.com/ sarees
-
Buzz
-
Murgapandian
-
Mads
-
http://www.tutkiun.com/2010/09/decrease-bounce-rates-apture-hover-in-or-headup.html Decrease bounce rates -Apture, hover.in or HeadUp | Tutkiun!
-
http://javarevisited.blogspot.com/ Javin Paul