Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to hide action buttons #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ Idle time is defined as no mouse, keyboard or touch event activity registered by

As long as the user is active, the (optional) keep-alive URL keeps getting pinged and the session stays alive. If you have no need to keep the server-side session alive via the keep-alive URL, you can also use this plugin as a simple lock mechanism that redirects to your lock-session or log-out URL after a set amount of idle time.


## Getting Started

1. Download or git clone.
2. Run `bower install` to install dependencies or if you prefer to do it manually: include jQuery, Bootstrap JS and CSS (required if you want to use Bootstrap modal window).
3. Include `bootstrap-session-timeout.js` or the minified version `bootstrap-session-timeout.min.js`
4. Call `$.sessionTimeout();` on document ready. See available options below or take a look at the examples.



## Documentation
### Options
**title**<br>
Expand Down Expand Up @@ -169,7 +166,6 @@ Default: `false`

Optional callback fired when first calling the plugin and every time user refreshes the session (on any mouse, keyboard or touch action). Takes options object as the only argument.


**onWarn**

Type: `Function` or `Boolean`
Expand All @@ -188,11 +184,18 @@ Default: `false`

Custom callback you can use instead of redirecting the user to `redirUrl`. Takes options object as the only argument.

**hideButtons**

Type: `Boolean`

Default: `false`

Disable action buttons

## Examples

You can play around with the examples in the `/examples` directory.


**Basic Usage**

Shows the warning dialog after one minute. The dialog is visible for another minute. If user takes no action (interacts with the page in any way), browser is redirected to `redirUrl`. On any user action (mouse, keyboard or touch) the timeout timer is reset. Of course, you will still need to close the dialog.
Expand Down Expand Up @@ -264,7 +267,7 @@ In lieu of a formal styleguide, take care to maintain the existing coding style.
* Fixes various reported bugs
* **1.0.2** `2015-02-10`
* Added optional onStart callback.
* All custom callbacks nowreceive options object as argument.
* All custom callbacks nowreceive options object as argument.
* Added optional countdown message. Added optional countdown bar.
* **1.0.1** `2014-01-23`
* Added an option to send data to the keep-alive URL.
Expand Down
43 changes: 25 additions & 18 deletions dist/bootstrap-session-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
onRedir: false,
countdownMessage: false,
countdownBar: false,
countdownSmart: false
countdownSmart: false,
hideButtons: false
};

var opt = defaults,
Expand Down Expand Up @@ -61,25 +62,31 @@
</div>' : '';

// Create timeout warning dialog
$('body').append('<div class="modal fade" id="session-timeout-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">' + opt.title + '</h4> \
</div> \
<div class="modal-body"> \
<p>' + opt.message + '</p> \
' + countdownMessage + ' \
' + coundownBarHtml + ' \
</div> \
<div class="modal-footer"> \
<button id="session-timeout-dialog-logout" type="button" class="btn btn-default">' + opt.logoutButton + '</button> \
<button id="session-timeout-dialog-keepalive" type="button" class="btn btn-primary" data-dismiss="modal">' + opt.keepAliveButton + '</button> \
var warningText =
'<div class="modal fade" id="session-timeout-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">' + opt.title + '</h4> \
</div> \
<div class="modal-body"> \
<p>' + opt.message + '</p> \
' + countdownMessage + ' \
' + coundownBarHtml + ' \
</div>';
if(!opt.hideButtons){
warningText += ' \
<div class="modal-footer"> \
<button id="session-timeout-dialog-logout" type="button" class="btn btn-default">' + opt.logoutButton + '</button> \
<button id="session-timeout-dialog-keepalive" type="button" class="btn btn-primary" data-dismiss="modal">' + opt.keepAliveButton + '</button> \
</div>';
}
warningText += ' \
</div> \
</div> \
</div> \
</div>');
</div>';
$('body').append(warningText);

// "Logout" button click
$('#session-timeout-dialog-logout').on('click', function() {
Expand Down