copy dari repo om Irfan

This commit is contained in:
2026-06-13 16:02:07 +10:00
commit db327c0305
5376 changed files with 2770667 additions and 0 deletions
+187
View File
@@ -0,0 +1,187 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Jquery-idletimer : provides you a way to monitor user activity with a page." />
<title>Jquery-idletimer</title>
<!-- jQuery and idleTimer -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../src/idle-timer.js"></script>
<!-- Bootstrap/respond (ie8) and moment -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.js"></script>
<!-- Respond.js proxy on external server -->
<link href="//netdna.bootstrapcdn.com/respond-proxy.html" id="respond-proxy" rel="respond-proxy" />
<link href="respond.proxy.gif" id="respond-redirect" rel="respond-redirect" />
<script src="respond.proxy.js"></script>
<style>
.bold {
font-weight: bold;
}
body {
margin-top: 40px;
margin-bottom: 40px;
}
</style>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Jquery-idletimer</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Main Demo</a></li>
<li><a href="defaultbinding.html">Default Binding</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer">Documentation</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/thorst/jquery-idletimer/zipball/master">Zip</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer/tarball/master">Tar</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer">Github</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="container">
<h2>Concept</h2>
<p>
Wait 10 seconds, you will see a expiring warning. Wait 10 more seconds and you will see that you have been logged out.
</p>
<p>
In the real world I forward them to the logout url, which intern fowards them to login screen, instead of showing the 2nd dialog.
You can modify the session.logout function.
</p>
<p>
We could use the active.idleTimer event to clearTimeout, however I prefer the user to explicitly say they want to keep the
session open by clicking ok, not just moving the mouse on the screen.
</p>
<p>
This demo takes into account when a mobile device closes the browser, and after the idle timeout expires, launches the browser again. Instead
of displaying the warning, it will jump straight to the logged out dialog.
</p>
<p>
For the sake of complete demo, I've included the code needed to call a keepalive url to keep the server side session valid.
</p>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Session Expiration Warning</h4>
</div>
<div class="modal-body">
<p>You've been inactive for a while. For your security, we'll log you out automatically. Click "Stay Online" to continue your session. </p>
<p>Your session will expire in <span class="bold" id="sessionSecondsRemaining">120</span> seconds.</p>
</div>
<div class="modal-footer">
<button id="extendSession" type="button" class="btn btn-default btn-success" data-dismiss="modal">Stay Online</button>
<button id="logoutSession" type="button" class="btn btn-default" data-dismiss="modal">Logout</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="mdlLoggedOut" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">You have been logged out</h4>
</div>
<div class="modal-body">
<p>Your session has expired.</p>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<script>
(function ($) {
var
session = {
//Logout Settings
inactiveTimeout: 10000, //(ms) The time until we display a warning message
warningTimeout: 10000, //(ms) The time until we log them out
minWarning: 5000, //(ms) If they come back to page (on mobile), The minumum amount, before we just log them out
warningStart: null, //Date time the warning was started
warningTimer: null, //Timer running every second to countdown to logout
logout: function () { //Logout function once warningTimeout has expired
//window.location = settings.autologout.logouturl;
$("#mdlLoggedOut").modal("show");
},
//Keepalive Settings
keepaliveTimer: null,
keepaliveUrl: "",
keepaliveInterval: 5000, //(ms) the interval to call said url
keepAlive: function () {
$.ajax({ url: session.keepaliveUrl });
}
}
;
$(document).on("idle.idleTimer", function (event, elem, obj) {
//Get time when user was last active
var
diff = (+new Date()) - obj.lastActive - obj.timeout,
warning = (+new Date()) - diff
;
//On mobile js is paused, so see if this was triggered while we were sleeping
if (diff >= session.warningTimeout || warning <= session.minWarning) {
$("#mdlLoggedOut").modal("show");
} else {
//Show dialog, and note the time
$('#sessionSecondsRemaining').html(Math.round((session.warningTimeout - diff) / 1000));
$("#myModal").modal("show");
session.warningStart = (+new Date()) - diff;
//Update counter downer every second
session.warningTimer = setInterval(function () {
var remaining = Math.round((session.warningTimeout / 1000) - (((+new Date()) - session.warningStart) / 1000));
if (remaining >= 0) {
$('#sessionSecondsRemaining').html(remaining);
} else {
session.logout();
}
}, 1000)
}
});
// create a timer to keep server session alive, independent of idle timer
session.keepaliveTimer = setInterval(function () {
session.keepAlive();
}, session.keepaliveInterval);
//User clicked ok to extend session
$("#extendSession").click(function () {
clearTimeout(session.warningTimer);
});
//User clicked logout
$("#logoutSession").click(function () {
session.logout();
});
//Set up the timer, if inactive for 10 seconds log them out
$(document).idleTimer(session.inactiveTimeout);
})(jQuery);
</script>
</body>
</html>
+455
View File
@@ -0,0 +1,455 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Jquery-idletimer : provides you a way to monitor user activity with a page." />
<title>Jquery-idletimer</title>
<!-- jQuery and idleTimer -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../src/idle-timer.js"></script>
<!-- Bootstrap/respond (ie8) and moment -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.js"></script>
<!-- Respond.js proxy on external server -->
<link href="//netdna.bootstrapcdn.com/respond-proxy.html" id="respond-proxy" rel="respond-proxy" />
<link href="respond.proxy.gif" id="respond-redirect" rel="respond-redirect" />
<script src="respond.proxy.js"></script>
<style>
body {
margin-top: 40px;
margin-bottom: 40px;
}
.btn {
padding: 5px 6px;
}
</style>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Jquery-idletimer</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Main Demo</a></li>
<li><a href="autologout.html">Auto Logout</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer">Documentation</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/thorst/jquery-idletimer/zipball/master">Zip</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer/tarball/master">Tar</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer">Github</a></li>
</ul>
</div> <!--/.nav-collapse -->
</div>
</div>
<div class="container">
<h2>Concept</h2>
<p>Here we use default bindings. Instead of explicitly telling idleTimer which element to bind to, it assumes document.</p>
<p>Some previous versions had issues mixing default binding with explicit calling on document.</p>
<p>This should no longer be the case. To test I've added 2 sets of buttons to show that they can be mixed.</p>
<p>The background color changes to show that it is returning a jQuery object</p>
<div class="row">
<div class="col-md-12">
<h3>Document <small><span id="docTimeout"></span> second timeout</small></h3>
<h4>default binding</h4>
<div class="btn-group">
<a href="#" id="btDefaultPause" class="btn btn-default btn-sm">Pause</a>
<a href="#" id="btDefaultResume" class="btn btn-default btn-sm">Resume</a>
<a href="#" id="btDefaultElapsed" class="btn btn-default btn-sm">Elapsed</a>
<a href="#" id="btDefaultInit" class="btn btn-default btn-sm">Init</a>
<a href="#" id="btDefaultDestroy" class="btn btn-default btn-sm">Destroy</a>
<a href="#" id="btDefaultReset" class="btn btn-default btn-sm">Reset</a>
<a href="#" id="btDefaultLastActive" class="btn btn-default btn-sm">Last Active</a>
<a href="#" id="btDefaultRemaining" class="btn btn-default btn-sm">Remaining</a>
<a href="#" id="btDefaultState" class="btn btn-default btn-sm">State</a>
</div>
<h4>explicit binding</h4>
<div class="btn-group">
<a href="#" id="btExplicitPause" class="btn btn-default btn-sm">Pause</a>
<a href="#" id="btExplicitResume" class="btn btn-default btn-sm">Resume</a>
<a href="#" id="btExplicitElapsed" class="btn btn-default btn-sm">Elapsed</a>
<a href="#" id="btExplicitInit" class="btn btn-default btn-sm">Init</a>
<a href="#" id="btExplicitDestroy" class="btn btn-default btn-sm">Destroy</a>
<a href="#" id="btExplicitReset" class="btn btn-default btn-sm">Reset</a>
<a href="#" id="btExplicitLastActive" class="btn btn-default btn-sm">Last Active</a>
<a href="#" id="btExplicitRemaining" class="btn btn-default btn-sm">Remaining</a>
<a href="#" id="btExplicitState" class="btn btn-default btn-sm">State</a>
</div>
<textarea rows="10" cols="30" id="docStatus" class="form-control"></textarea><br />
</div>
</div>
</div>
<script>
/*
scrollToBottom plugin, chainable
*/
$.fn.scrollToBottom = function () {
this.scrollTop(this[0].scrollHeight);
return this;
};
var rndColor = function () {
return '#' + Math.floor(Math.random() * 16777215).toString(16);
}
var
docTimeout = 5000
;
</script>
<script>
/*
Code for document idle timer
*/
(function ($) {
// Display the actual timeout on the page
$('#docTimeout').text(docTimeout / 1000);
//Clear old statuses
$('#docStatus').val('');
//Handle idle event
$(document).on("idle.idleTimer", function () {
$("#docStatus")
.val(function (i, v) {
return v + "Idle @ " + new Date() + " \n";
})
.removeClass("alert-success")
.addClass("alert-warning")
.scrollToBottom();
});
//Handle active event
$(document).on("active.idleTimer", function () {
$('#docStatus')
.val(function (i, v) {
return v + "Active @ " + new Date() + " \n";
})
.addClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
});
//Start timeout, passing no options
//Same as $(document).idleTimer(docTimeout);
$.idleTimer(docTimeout);
//For demo purposes, get initial state and style accordingly
if ($.idleTimer("isIdle")) {
$("#docStatus")
.val(function (i, v) {
return v + "Initial Idle @ " + new Date() + " \n";
})
.removeClass("alert-success")
.addClass("alert-warning")
.scrollToBottom();
} else {
$('#docStatus')
.val(function (i, v) {
return v + "Initial Active @ " + new Date() + " \n";
})
.addClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
}
})(jQuery);
</script>
<script>
(function ($) {
/*
Handle button events
*/
$("#btDefaultPause").click(function () {
//pause
$.idleTimer("pause").find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Paused @ " + new Date() + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btDefaultResume").click(function () {
//resume
$.idleTimer("resume").find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Resumed @ " + new Date() + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btDefaultElapsed").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "Elapsed: " + $.idleTimer("getElapsedTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btDefaultInit").click(function () {
// for demo purposes show init with just object
$.idleTimer({ timeout: docTimeout }).find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Init: @ " + moment().format() + " \n";
})
.scrollToBottom();
//Apply classes for default state
if ($.idleTimer("isIdle")) {
$('#docStatus')
.removeClass("alert-success")
.addClass("alert-warning");
} else {
$('#docStatus')
.addClass("alert-success")
.removeClass("alert-warning");
}
$(this).blur();
return false;
});
$("#btDefaultDestroy").click(function () {
// console.log($.idleTimer("destroy"));
$.idleTimer("destroy").find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Destroyed: @ " + moment().format() + " \n";
})
.removeClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
$(this).blur();
return false;
});
$("#btDefaultReset").click(function () {
//Reset
var s = $.idleTimer("reset").find("h2").css({ "background-color": rndColor() });
//Output
$('#docStatus')
.val(function (i, v) {
return v + "Reset @ " + new Date() + " \n";
})
.scrollToBottom();
//Apply classes for default state
var idle = $.idleTimer("isIdle");
if (idle) {
$('#docStatus')
.removeClass("alert-success")
.addClass("alert-warning");
} else {
$('#docStatus')
.addClass("alert-success")
.removeClass("alert-warning");
}
$(this).blur();
return false;
});
$("#btDefaultLastActive").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "Last Active: " + $.idleTimer("getLastActiveTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btDefaultRemaining").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "Remaining: " + $.idleTimer("getRemainingTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btDefaultState").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "State: " + ($.idleTimer("isIdle") ? "idle" : "active") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
})(jQuery);
</script>
<script>
(function ($) {
/*
Handle button events
*/
$("#btExplicitPause").click(function () {
//pause
$(document).idleTimer("pause").find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Paused @ " + new Date() + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btExplicitResume").click(function () {
//resume
$(document).idleTimer("resume").find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Resumed @ " + new Date() + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btExplicitElapsed").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "Elapsed: " + $(document).idleTimer("getElapsedTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btExplicitInit").click(function () {
// for demo purposes show init with just object
$.idleTimer({ timeout: docTimeout }).find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Init: @ " + moment().format() + " \n";
})
.scrollToBottom();
//Apply classes for default state
if ($(document).idleTimer("isIdle")) {
$('#docStatus')
.removeClass("alert-success")
.addClass("alert-warning");
} else {
$('#docStatus')
.addClass("alert-success")
.removeClass("alert-warning");
}
$(this).blur();
return false;
});
$("#btExplicitDestroy").click(function () {
$(document).idleTimer("destroy").find("h2").css({ "background-color": rndColor() });
$('#docStatus')
.val(function (i, v) {
return v + "Destroyed: @ " + moment().format() + " \n";
})
.removeClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
$(this).blur();
return false;
});
$("#btExplicitReset").click(function () {
//Reset
var s = $(document).idleTimer("reset").find("h2").css({ "background-color": rndColor() });
//Output
$('#docStatus')
.val(function (i, v) {
return v + "Reset @ " + new Date() + " \n";
})
.scrollToBottom();
//Apply classes for default state
var idle = $(document).idleTimer("isIdle");
if (idle) {
$('#docStatus')
.removeClass("alert-success")
.addClass("alert-warning");
} else {
$('#docStatus')
.addClass("alert-success")
.removeClass("alert-warning");
}
$(this).blur();
return false;
});
$("#btExplicitLastActive").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "Last Active: " + $(document).idleTimer("getLastActiveTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btExplicitRemaining").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "Remaining: " + $(document).idleTimer("getRemainingTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btExplicitState").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "State: " + ($(document).idleTimer("isIdle") ? "idle" : "active") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
})(jQuery);
</script>
</body>
</html>
+388
View File
@@ -0,0 +1,388 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Jquery-idletimer : provides you a way to monitor user activity with a page." />
<title>Jquery-idletimer</title>
<!-- jQuery and idleTimer -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../src/idle-timer.js"></script>
<!-- Bootstrap/respond (ie8) and moment -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.js"></script>
<!-- Respond.js proxy on external server -->
<link href="//netdna.bootstrapcdn.com/respond-proxy.html" id="respond-proxy" rel="respond-proxy" />
<link href="respond.proxy.gif" id="respond-redirect" rel="respond-redirect" />
<script src="respond.proxy.js"></script>
<style>
body {
margin-top: 40px;
margin-bottom: 40px;
}
.btn {
padding: 5px 6px;
}
</style>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Jquery-idletimer</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="autologout.html">Auto Logout</a></li>
<li><a href="defaultbinding.html">Default Binding</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer">Documentation</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/thorst/jquery-idletimer/zipball/master">Zip</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer/tarball/master">Tar</a></li>
<li><a href="https://github.com/thorst/jquery-idletimer">Github</a></li>
</ul>
</div> <!--/.nav-collapse -->
</div>
</div>
<div class="container">
<h2>Concept</h2>
<p>The idle timer is built on <a href="http://jquery.com/">jQuery</a> and provides two events: <code>idle.idleTimer</code> and <code>active.idleTimer</code>, which fire when the user's idle state has changed.</p>
<p>When you move your mouse over the page or start typing, you're considered "active".</p>
<p>On this page we have two idle timers. One for the entire document. Another for the text area on the right (or bottom if your on mobile).</p>
<p>I use explicit instantiation here</p>
<div class="row">
<div class="col-md-6">
<h3>Document <small><span id="docTimeout"></span> second timeout</small></h3>
<div class="btn-group">
<a href="#" id="btPause" class="btn btn-default btn-sm">Pause</a>
<a href="#" id="btResume" class="btn btn-default btn-sm">Resume</a>
<a href="#" id="btElapsed" class="btn btn-default btn-sm">Elapsed</a>
<a href="#" id="btInit" class="btn btn-default btn-sm">Init</a>
<a href="#" id="btDestroy" class="btn btn-default btn-sm">Destroy</a>
</div>
<textarea rows="10" cols="30" id="docStatus" class="form-control"></textarea><br />
</div>
<div class="col-md-6">
<h3>Element <small><span id="elTimeout"></span> second timeout</small></h3>
<div class="btn-group">
<a href="#" id="btReset" class="btn btn-default btn-sm">Reset</a>
<a href="#" id="btLastActive" class="btn btn-default btn-sm">Last Active</a>
<a href="#" id="btRemaining" class="btn btn-default btn-sm">Remaining</a>
<a href="#" id="btState" class="btn btn-default btn-sm">State</a>
</div>
<textarea rows="10" cols="30" id="elStatus" class="form-control"></textarea><br />
</div>
</div>
<h3>Dialogs</h3>
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch modal
</button>
<button id="alert" class="btn btn-primary btn-lg">
Launch alert
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script>
/*
scrollToBottom plugin, chainable
*/
$.fn.scrollToBottom = function () {
this.scrollTop(this[0].scrollHeight);
return this;
};
/*
click event for alert button
*/
(function ($) {
//Display alert
$("#alert").click(function () { alert("Hello!"); return false; });
})(jQuery);
</script>
<script type="text/javascript">
/*
Code for document idle timer
*/
(function ($) {
//Define default
var
docTimeout = 5000
;
/*
Handle raised idle/active events
*/
$(document).on("idle.idleTimer", function (event, elem, obj) {
$("#docStatus")
.val(function (i, v) {
return v + "Idle @ " + moment().format() + " \n";
})
.removeClass("alert-success")
.addClass("alert-warning")
.scrollToBottom();
});
$(document).on("active.idleTimer", function (event, elem, obj, e) {
$('#docStatus')
.val(function (i, v) {
return v + "Active [" + e.type + "] [" + e.target.nodeName + "] @ " + moment().format() + " \n";
})
.addClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
});
/*
Handle button events
*/
$("#btPause").click(function () {
$(document).idleTimer("pause");
$('#docStatus')
.val(function (i, v) {
return v + "Paused @ " + moment().format() + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btResume").click(function () {
$(document).idleTimer("resume");
$('#docStatus')
.val(function (i, v) {
return v + "Resumed @ " + moment().format() + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btElapsed").click(function () {
$('#docStatus')
.val(function (i, v) {
return v + "Elapsed (since becoming active): " + $(document).idleTimer("getElapsedTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btDestroy").click(function () {
$(document).idleTimer("destroy");
$('#docStatus')
.val(function (i, v) {
return v + "Destroyed: @ " + moment().format() + " \n";
})
.removeClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
$(this).blur();
return false;
});
$("#btInit").click(function () {
// for demo purposes show init with just object
$(document).idleTimer({ timeout: docTimeout });
$('#docStatus')
.val(function (i, v) {
return v + "Init: @ " + moment().format() + " \n";
})
.scrollToBottom();
//Apply classes for default state
if ($(document).idleTimer("isIdle")) {
$('#docStatus')
.removeClass("alert-success")
.addClass("alert-warning");
} else {
$('#docStatus')
.addClass("alert-success")
.removeClass("alert-warning");
}
$(this).blur();
return false;
});
//Clear old statuses
$('#docStatus').val('');
//Start timeout, passing no options
//Same as $.idleTimer(docTimeout, docOptions);
$(document).idleTimer(docTimeout);
//For demo purposes, style based on initial state
if ($(document).idleTimer("isIdle")) {
$("#docStatus")
.val(function (i, v) {
return v + "Initial Idle State @ " + moment().format() + " \n";
})
.removeClass("alert-success")
.addClass("alert-warning")
.scrollToBottom();
} else {
$('#docStatus')
.val(function (i, v) {
return v + "Initial Active State @ " + moment().format() + " \n";
})
.addClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
}
//For demo purposes, display the actual timeout on the page
$('#docTimeout').text(docTimeout / 1000);
})(jQuery);
</script>
<script type="text/javascript">
/*
Code for element idle timer
*/
(function ($) {
//Define textarea settings
var
taTimeout = 3000
;
/*
Handle raised idle/active events
*/
$('#elStatus').on("idle.idleTimer", function (event, elem, obj) {
//If you dont stop propagation it will bubble up to document event handler
event.stopPropagation();
$('#elStatus')
.val(function (i, v) {
return v + "Idle @ " + moment().format() + " \n";
})
.removeClass("alert-success")
.addClass("alert-warning")
.scrollToBottom();
});
$('#elStatus').on("active.idleTimer", function (event) {
//If you dont stop propagation it will bubble up to document event handler
event.stopPropagation();
$('#elStatus')
.val(function (i, v) {
return v + "Active @ " + moment().format() + " \n";
})
.addClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
});
/*
Handle button events
*/
$("#btReset").click(function () {
$('#elStatus')
.idleTimer("reset")
.val(function (i, v) {
return v + "Reset @ " + moment().format() + " \n";
})
.scrollToBottom();
//Apply classes for default state
if ($("#elStatus").idleTimer("isIdle")) {
$('#elStatus')
.removeClass("alert-success")
.addClass("alert-warning");
} else {
$('#elStatus')
.addClass("alert-success")
.removeClass("alert-warning");
}
$(this).blur();
return false;
});
$("#btRemaining").click(function () {
$('#elStatus')
.val(function (i, v) {
return v + "Remaining: " + $("#elStatus").idleTimer("getRemainingTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btLastActive").click(function () {
$('#elStatus')
.val(function (i, v) {
return v + "LastActive: " + $("#elStatus").idleTimer("getLastActiveTime") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
$("#btState").click(function () {
$('#elStatus')
.val(function (i, v) {
return v + "State: " + ($("#elStatus").idleTimer("isIdle")? "idle":"active") + " \n";
})
.scrollToBottom();
$(this).blur();
return false;
});
//Clear value if there was one cached & start time
$('#elStatus').val('').idleTimer(taTimeout);
//For demo purposes, show initial state
if ($("#elStatus").idleTimer("isIdle")) {
$("#elStatus")
.val(function (i, v) {
return v + "Initial Idle @ " + moment().format() + " \n";
})
.removeClass("alert-success")
.addClass("alert-warning")
.scrollToBottom();
} else {
$('#elStatus')
.val(function (i, v) {
return v + "Initial Active @ " + moment().format() + " \n";
})
.addClass("alert-success")
.removeClass("alert-warning")
.scrollToBottom();
}
// Display the actual timeout on the page
$('#elTimeout').text(taTimeout / 1000);
})(jQuery);
</script>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 35 B

+129
View File
@@ -0,0 +1,129 @@
/*! Respond.js: min/max-width media query polyfill. Remote proxy (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */
(function(win, doc, undefined){
var docElem = doc.documentElement,
proxyURL = doc.getElementById("respond-proxy").href,
redirectURL = (doc.getElementById("respond-redirect") || location).href,
baseElem = doc.getElementsByTagName("base")[0],
urls = [],
refNode;
function encode(url){
return win.encodeURIComponent(url);
}
function fakejax( url, callback ){
var iframe,
AXO;
// All hail Google http://j.mp/iKMI19
// Behold, an iframe proxy without annoying clicky noises.
if ( "ActiveXObject" in win ) {
AXO = new ActiveXObject( "htmlfile" );
AXO.open();
AXO.write( '<iframe id="x"></iframe>' );
AXO.close();
iframe = AXO.getElementById( "x" );
} else {
iframe = doc.createElement( "iframe" );
iframe.style.cssText = "position:absolute;top:-99em";
docElem.insertBefore(iframe, docElem.firstElementChild || docElem.firstChild );
}
iframe.src = checkBaseURL(proxyURL) + "?url=" + encode(redirectURL) + "&css=" + encode(checkBaseURL(url));
function checkFrameName() {
var cssText;
try {
cssText = iframe.contentWindow.name;
}
catch (e) { }
if (cssText) {
// We've got what we need. Stop the iframe from loading further content.
iframe.src = "about:blank";
iframe.parentNode.removeChild(iframe);
iframe = null;
// Per http://j.mp/kn9EPh, not taking any chances. Flushing the ActiveXObject
if (AXO) {
AXO = null;
if (win.CollectGarbage) {
win.CollectGarbage();
}
}
callback(cssText);
}
else{
win.setTimeout(checkFrameName, 100);
}
}
win.setTimeout(checkFrameName, 500);
}
// http://stackoverflow.com/a/472729
function checkBaseURL(href) {
var el = document.createElement('div'),
escapedURL = href.split('&').join('&amp;').
split('<').join('&lt;').
split('"').join('&quot;');
el.innerHTML = '<a href="' + escapedURL + '">x</a>';
return el.firstChild.href;
}
function checkRedirectURL() {
// IE6 & IE7 don't build out absolute urls in <link /> attributes.
// So respond.proxy.gif remains relative instead of http://example.com/respond.proxy.gif.
// This trickery resolves that issue.
if (~ !redirectURL.indexOf(location.host)) {
var fakeLink = doc.createElement("div");
fakeLink.innerHTML = '<a href="' + redirectURL + '"></a>';
docElem.insertBefore(fakeLink, docElem.firstElementChild || docElem.firstChild );
// Grab the parsed URL from that dummy object
redirectURL = fakeLink.firstChild.href;
// Clean up
fakeLink.parentNode.removeChild(fakeLink);
fakeLink = null;
}
}
function buildUrls(){
var links = doc.getElementsByTagName( "link" );
for( var i = 0, linkl = links.length; i < linkl; i++ ){
var thislink = links[i],
href = links[i].href,
extreg = (/^([a-zA-Z:]*\/\/(www\.)?)/).test( href ),
ext = (baseElem && !extreg) || extreg;
//make sure it's an external stylesheet
if( thislink.rel.indexOf( "stylesheet" ) >= 0 && ext ){
(function( link ){
fakejax( href, function( css ){
link.styleSheet.rawCssText = css;
respond.update();
} );
})( thislink );
}
}
}
if( !respond.mediaQueriesSupported ){
checkRedirectURL();
buildUrls();
}
})( window, document );