Notify.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. message:
  28. `<div style="max-width: 350px;">
  29. ${caption}
  30. <div style="color: ${messageColor}; overflow-wrap: break-word; word-wrap: break-word;">${message}</div>
  31. </div>`
  32. });
  33. }
  34. success(message, caption, options) {
  35. this.notify(Object.assign({color: 'positive', icon: 'la la-check-circle', message, caption}, options));
  36. }
  37. warning(message, caption, options) {
  38. this.notify(Object.assign({color: 'warning', icon: 'la la-exclamation-circle', message, caption}, options));
  39. }
  40. error(message, caption, options) {
  41. this.notify(Object.assign({color: 'negative', icon: 'la la-exclamation-circle', messageColor: 'yellow', captionColor: 'white', message, caption}, options));
  42. }
  43. info(message, caption, options) {
  44. this.notify(Object.assign({color: 'info', icon: 'la la-bell', message, caption}, options));
  45. }
  46. }
  47. export default vueComponent(Notify);
  48. //-----------------------------------------------------------------------------
  49. </script>