| @@ -72,9 +72,9 @@ | ||
| 72 | 72 | // register flag when hovering the mouse |
| 73 | 73 | // above the toast message |
| 74 | 74 | VBOToast.mouseHover = true; |
| 75 | 75 | }, () => { |
| 76 | - if (VBOToast.mouseHover) { | |
| 76 | + if (VBOToast.mouseHover && VBOToast.disposeDelay) { | |
| 77 | 77 | // reset timeout |
| 78 | 78 | clearTimeout(VBOToast.timerHandler); |
| 79 | 79 | |
| 80 | 80 | // schedule timeout again to dispose the toast |
| @@ -222,16 +222,45 @@ | ||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | content.attr('style', style); |
| 225 | 225 | |
| 226 | - // slide in the toast message | |
| 227 | - toast.addClass('toast-slide-in'); | |
| 228 | - | |
| 229 | 226 | // overwrite delay in case it was specified |
| 230 | 227 | if (message.hasOwnProperty('delay')) { |
| 231 | - delay = message.delay; | |
| 228 | + let ms = parseInt(message.delay); | |
| 229 | + | |
| 230 | + if (isNaN(delay)) { | |
| 231 | + // do not auto-dispose | |
| 232 | + delay = 0; | |
| 233 | + } else { | |
| 234 | + // use the given delay | |
| 235 | + delay = Math.abs(message.delay); | |
| 236 | + } | |
| 232 | 237 | } |
| 233 | 238 | |
| 239 | + // register delay | |
| 240 | + VBOToast.disposeDelay = delay; | |
| 241 | + | |
| 242 | + if (VBOToast.disposeDelay) { | |
| 243 | + // register timer to dispose the toast message once the specified | |
| 244 | + // delay is passed | |
| 245 | + VBOToast.timerHandler = setTimeout(VBOToast.dispose, delay); | |
| 246 | + } else { | |
| 247 | + // flag timer handler to properly process the queue | |
| 248 | + VBOToast.timerHandler = true; | |
| 249 | + | |
| 250 | + // dispose only after clicking the notification | |
| 251 | + toast.addClass('clickable').on('click', () => { | |
| 252 | + // force closure because we are above the toast | |
| 253 | + // and the mouseHover flag could be active | |
| 254 | + VBOToast.dispose(true); | |
| 255 | + }); | |
| 256 | + } | |
| 257 | + | |
| 258 | + setTimeout(() => { | |
| 259 | + // slide in the toast message | |
| 260 | + toast.addClass('toast-slide-in ready'); | |
| 261 | + }, 32); | |
| 262 | + | |
| 234 | 263 | // execute callback, if specified |
| 235 | 264 | if (message.hasOwnProperty('callback') && typeof message.callback === 'function') { |
| 236 | 265 | message.callback(message); |
| 237 | 266 | } |
| @@ -239,15 +268,8 @@ | ||
| 239 | 268 | if (message.sound) { |
| 240 | 269 | // auto-play the sound when the message slide in |
| 241 | 270 | VBOToastSound.play(message.sound, delay * 2); |
| 242 | 271 | } |
| 243 | - | |
| 244 | - // register delay | |
| 245 | - VBOToast.disposeDelay = delay; | |
| 246 | - | |
| 247 | - // register timer to dispose the toast message once the specified | |
| 248 | - // delay is passed | |
| 249 | - VBOToast.timerHandler = setTimeout(VBOToast.dispose, delay); | |
| 250 | 272 | } |
| 251 | 273 | |
| 252 | 274 | /** |
| 253 | 275 | * Enqueues the message for being displayed once the |
| @@ -355,8 +377,9 @@ | ||
| 355 | 377 | */ |
| 356 | 378 | VBOToast.POSITION_TOP_LEFT = 'top-left'; |
| 357 | 379 | VBOToast.POSITION_TOP_CENTER = 'top-center'; |
| 358 | 380 | VBOToast.POSITION_TOP_RIGHT = 'top-right'; |
| 381 | + VBOToast.POSITION_CENTER_CENTER = 'center-center'; | |
| 359 | 382 | VBOToast.POSITION_BOTTOM_LEFT = 'bottom-left'; |
| 360 | 383 | VBOToast.POSITION_BOTTOM_CENTER = 'bottom-center'; |
| 361 | 384 | VBOToast.POSITION_BOTTOM_RIGHT = 'bottom-right'; |
| 362 | 385 | |