You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-11Lines changed: 61 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,10 @@ As long as the user is active, the (optional) keep-alive URL keeps getting pinge
15
15
16
16
## Getting Started
17
17
18
-
1.Include `jQuery`
19
-
2.Include `bootstrap.js` and `bootstrap.css`<br>(to support the modal dialog, unless you plan on using your own callback)
20
-
3. Include `bootstrap-session-timeout.js` or the minified `bootstrap-session-timeout.min.js`
21
-
4. Call `$.sessionTimeout();`after document ready
18
+
1.Download or git clone.
19
+
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).
20
+
3. Include `bootstrap-session-timeout.js` or the minified version `bootstrap-session-timeout.min.js`
21
+
4. Call `$.sessionTimeout();`on document ready. See available options below or take a look at the examples.
22
22
23
23
24
24
@@ -136,13 +136,38 @@ Default: `false`
136
136
137
137
If `true`, this will launch the Bootstrap warning dialog / redirect (or callback functions) in a set amounts of time regardless of user activity. This in turn makes the plugin act much like the [jquery-sessionTimeout-bootstrap by maxfierke](https://github.com/maxfierke/jquery-sessionTimeout-bootstrap) plugin.
138
138
139
+
**countdownMessage**
140
+
141
+
Type: `String` or `Boolean`
142
+
143
+
Default: `false`
144
+
145
+
If you want a custom sentence to appear in the warning dialog with a timer showing the seconds remaining, use this option. Example: `countdownMessage: 'Redirecting in {timer} seconds.'` Place the `{timer}` string where you want the numeric countdown (seconds) to appear. Another example: `countdownMessage: '{timer} seconds remaining.'`. Can be combined with countdownBar option or used independently.
146
+
147
+
**countdownBar**
148
+
149
+
Type: `Boolean`
150
+
151
+
Default: `false`
152
+
153
+
If `true`, ads a countdown bar (uses Bootstrap progress bar) to the warning dialog. Can be combined with countdownMessage option or used independently.
154
+
155
+
**onStart**
156
+
157
+
Type: `Function` or `Boolean`
158
+
159
+
Default: `false`
160
+
161
+
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.
162
+
163
+
139
164
**onWarn**
140
165
141
166
Type: `Function` or `Boolean`
142
167
143
168
Default: `false`
144
169
145
-
Custom callback you can use instead of showing the Bootstrap warning dialog.
170
+
Custom callback you can use instead of showing the Bootstrap warning dialog. Takes options object as the only argument.
146
171
147
172
Redirect action will still occur unless you also add the `onRedir` callback.
148
173
@@ -152,10 +177,13 @@ Type: `Function` or `Boolean`
152
177
153
178
Default: `false`
154
179
155
-
Custom callback you can use instead of redirectiong the user to `redirUrl`.
180
+
Custom callback you can use instead of redirectiong the user to `redirUrl`. Takes options object as the only argument.
156
181
157
182
## Examples
158
183
184
+
You can play around with the examples in the `/examples` directory.
185
+
186
+
159
187
**Basic Usage**
160
188
161
189
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.
@@ -180,7 +208,7 @@ $.sessionTimeout({
180
208
redirUrl:'locked.html',
181
209
warnAfter:60000,
182
210
redirAfter:120000,
183
-
onWarn:function{
211
+
onWarn:function () {
184
212
alert('Warning!');
185
213
}
186
214
});
@@ -194,21 +222,43 @@ Console logs the "Your session will soon expire!" text after one minute. If user
194
222
$.sessionTimeout({
195
223
warnAfter:60000,
196
224
redirAfter:180000,
197
-
onWarn:function{
225
+
onWarn:function () {
198
226
console.log('Your session will soon expire!');
199
227
},
200
-
onRedir:function{
228
+
onRedir:function () {
201
229
alert('Your session has expired!');
202
230
}
203
231
});
204
232
```
205
233
234
+
**With countdown message and bar displayed in warning dialog**
235
+
236
+
Same as basic usage except you'll also see the countdown message and countdown bar in the warning dialog. Uses Bootstrap progress bar. In countdownMessage place the `{timer}` string where you want the numeric countdown (seconds) to appear.
237
+
238
+
```js
239
+
$.sessionTimeout({
240
+
keepAliveUrl:'keep-alive.html',
241
+
logoutUrl:'login.html',
242
+
redirUrl:'locked.html',
243
+
warnAfter:60000,
244
+
redirAfter:120000,
245
+
countdownMessage:'Redirecting in {timer} seconds.',
246
+
countdownBar:true
247
+
});
248
+
```
249
+
206
250
## Contributing
207
251
In lieu of a formal styleguide, take care to maintain the existing coding style. Add comments for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
208
252
209
253
## Release History
210
-
* 2014-01-23 v1.0.1 Added an option to send data to the keep-alive URL.
211
-
* 2014-01-22 v1.0.0 Initial release.
254
+
***1.0.2**`2015-02-10`
255
+
* Added optional onStart callback.
256
+
* All custom callbacks nowreceive options object as argument.
257
+
* Added optional countdown message. Added optional countdown bar.
258
+
***1.0.1**`2014-01-23`
259
+
* Added an option to send data to the keep-alive URL.
260
+
***1.0.0**`2014-01-22`
261
+
* Initial release.
212
262
213
263
## License
214
264
Copyright (c) 2014 [Orange Hill](http://www.orangehilldev.com). Licensed under the MIT license.
0 commit comments