notifications.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. $(function () {
  2. $('.jsdemo-notification-button button').on('click', function () {
  3. var placementFrom = $(this).data('placement-from');
  4. var placementAlign = $(this).data('placement-align');
  5. var animateEnter = $(this).data('animate-enter');
  6. var animateExit = $(this).data('animate-exit');
  7. var colorName = $(this).data('color-name');
  8. showNotification(colorName, null, placementFrom, placementAlign, animateEnter, animateExit);
  9. });
  10. });
  11. function showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
  12. if (colorName === null || colorName === '') { colorName = 'bg-black'; }
  13. if (text === null || text === '') { text = 'Turning standard Bootstrap alerts'; }
  14. if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; }
  15. if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; }
  16. var allowDismiss = true;
  17. $.notify({
  18. message: text
  19. },
  20. {
  21. type: colorName,
  22. allow_dismiss: allowDismiss,
  23. newest_on_top: true,
  24. timer: 1000,
  25. placement: {
  26. from: placementFrom,
  27. align: placementAlign
  28. },
  29. animate: {
  30. enter: animateEnter,
  31. exit: animateExit
  32. },
  33. template: '<div data-notify="container" class="bootstrap-notify-container alert alert-dismissible {0} ' + (allowDismiss ? "p-r-35" : "") + '" role="alert">' +
  34. '<button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button>' +
  35. '<span data-notify="icon"></span> ' +
  36. '<span data-notify="title">{1}</span> ' +
  37. '<span data-notify="message">{2}</span>' +
  38. '<div class="progress" data-notify="progressbar">' +
  39. '<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
  40. '</div>' +
  41. '<a href="{3}" target="{4}" data-notify="url"></a>' +
  42. '</div>'
  43. });
  44. }