Skip to content

Commit ed43bf9

Browse files
committed
Merge pull request orangehill#5 from xibman/master
Thanks @xibman for the updates. I'm a bit late to merge it, but better late than never :)
2 parents 443ac21 + 776c8e7 commit ed43bf9

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ As long as the user is active, the (optional) keep-alive URL keeps getting pinge
2424

2525
## Documentation
2626
### Options
27+
**title**<br>
28+
29+
Type: `String`
30+
31+
Default: `'Your session is about to expire!'`
32+
33+
This is the text shown to user via Bootstrap warning dialog after warning period. (modal title)
34+
2735
**message**<br>
2836

2937
Type: `String`
@@ -32,6 +40,22 @@ Default: `'Your session is about to expire.'`
3240

3341
This is the text shown to user via Bootstrap warning dialog after warning period.
3442

43+
**logoutButton**<br>
44+
45+
Type: `String`
46+
47+
Default: `'Logout'`
48+
49+
This is the text shown to user via Bootstrap warning dialog after warning period in the logout button.
50+
51+
**keepAliveButton**<br>
52+
53+
Type: `String`
54+
55+
Default: `'Stay Connected'`
56+
57+
This is the text shown to user via Bootstrap warning dialog after warning period in the Kepp Alive button.
58+
3559
**keepAliveUrl**
3660

3761
Type: `String`
@@ -56,6 +80,14 @@ Default: `5000` (5 seconds)
5680

5781
Time in milliseconds between two keep-alive pings.
5882

83+
**ajaxType**
84+
85+
Type: `String`
86+
87+
Default: `'POST'`
88+
89+
If you need to specify the ajax method
90+
5991
**ajaxData**
6092

6193
Type: `String`

dist/bootstrap-session-timeout.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
(function( $ ){
1212
jQuery.sessionTimeout = function( options ) {
1313
var defaults = {
14+
title : 'Your Session is About to Expire!',
1415
message : 'Your session is about to expire.',
16+
logoutButton : 'Logout',
17+
keepAliveButton : 'Stay Connected',
1518
keepAliveUrl : '/keep-alive',
19+
ajaxType : 'POST',
1620
ajaxData : '',
1721
redirUrl : '/timed-out',
1822
logoutUrl : '/log-out',
@@ -45,7 +49,21 @@
4549
// unless user set his own callback function, prepare bootstrap modal elements and events
4650
if(typeof opt.onWarn !== 'function'){
4751
// create timeout warning dialog
48-
$('body').append('<div class="modal fade" id="sessionTimeout-dialog"><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">Your Session is About to Expire!</h4></div><div class="modal-body">'+ opt.message +'</div><div class="modal-footer"><button id="sessionTimeout-dialog-logout" type="button" class="btn btn-default">Logout</button><button id="sessionTimeout-dialog-keepalive" type="button" class="btn btn-primary" data-dismiss="modal">Stay Connected</button></div></div></div></div>');
52+
$('body').append('<div class="modal fade" id="sessionTimeout-dialog"> \
53+
<div class="modal-dialog"> \
54+
<div class="modal-content"> \
55+
<div class="modal-header"> \
56+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> \
57+
<h4 class="modal-title">'+ opt.title +'</h4> \
58+
</div> \
59+
<div class="modal-body">'+ opt.message +'</div> \
60+
<div class="modal-footer"> \
61+
<button id="sessionTimeout-dialog-logout" type="button" class="btn btn-default">'+ opt.logoutButton +'</button> \
62+
<button id="sessionTimeout-dialog-keepalive" type="button" class="btn btn-primary" data-dismiss="modal">'+ opt.keepAliveButton +'</button> \
63+
</div> \
64+
</div> \
65+
</div> \
66+
</div>');
4967

5068
// "Logout" button click
5169
$('#sessionTimeout-dialog-logout').on('click', function () { window.location = opt.logoutUrl; });
@@ -69,7 +87,7 @@
6987
function keepAlive () {
7088
if (!keepAlivePinged){
7189
$.ajax({
72-
type: 'POST',
90+
type: opt.ajaxType,
7391
url: opt.keepAliveUrl,
7492
data: opt.ajaxData
7593
});
@@ -125,4 +143,4 @@
125143
// start session timer
126144
startSessionTimer();
127145
};
128-
})( jQuery );
146+
})( jQuery );

dist/bootstrap-session-timeout.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)