Skip to content

Commit b7e09ee

Browse files
committed
Options for modal translation + ajax request Type
Add extra options to translate modal text: title and buttons Add an option to specify the ajax method type (get, post ...)
1 parent 443ac21 commit b7e09ee

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

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 );

0 commit comments

Comments
 (0)