Notify.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div class="hidden"></div>
  3. </template>
  4. <script>
  5. //-----------------------------------------------------------------------------
  6. import vueComponent from '../vueComponent.js';
  7. class Notify {
  8. notify(opts) {
  9. let {
  10. caption = null,
  11. captionColor = 'black',
  12. color = 'positive',
  13. icon = '',
  14. iconColor = 'white',
  15. message = '',
  16. messageColor = 'black',
  17. position = 'top-right',
  18. } = opts;
  19. caption = (caption ? `<div style="font-size: 120%; color: ${captionColor}"><b>${caption}</b></div><br>` : '');
  20. return this.$q.notify({
  21. position,
  22. color,
  23. textColor: iconColor,
  24. icon,
  25. actions: [{icon: 'la la-times notify-button-icon', color: 'black'}],
  26. html: true,
  27. classes: 'notify-margin',
  28. message:
  29. `<div style="max-width: 350px">
  30. ${caption}
  31. <div style="color: ${messageColor}; overflow-wrap: break-word; word-wrap: break-word;">${message}</div>
  32. </div>`
  33. });
  34. }
  35. success(message, caption, options) {
  36. this.notify(Object.assign({color: 'positive', icon: 'la la-check-circle', message, caption}, options));
  37. }
  38. warning(message, caption, options) {
  39. this.notify(Object.assign({color: 'warning', icon: 'la la-exclamation-circle', message, caption}, options));
  40. }
  41. error(message, caption, options) {
  42. this.notify(Object.assign({color: 'negative', icon: 'la la-exclamation-circle', messageColor: 'yellow', captionColor: 'white', message, caption}, options));
  43. }
  44. info(message, caption, options) {
  45. this.notify(Object.assign({color: 'info', icon: 'la la-bell', message, caption}, options));
  46. }
  47. }
  48. export default vueComponent(Notify);
  49. //-----------------------------------------------------------------------------
  50. </script>