Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VSnackbar.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import '../../../src/stylus/components/_snackbars.styl';
  2. import Colorable from '../../mixins/colorable';
  3. import Toggleable from '../../mixins/toggleable';
  4. import { factory as PositionableFactory } from '../../mixins/positionable';
  5. import mixins from '../../util/mixins';
  6. export default mixins(Colorable, Toggleable, PositionableFactory(['absolute', 'top', 'bottom', 'left', 'right'])
  7. /* @vue/component */
  8. ).extend({
  9. name: 'v-snackbar',
  10. props: {
  11. autoHeight: Boolean,
  12. multiLine: Boolean,
  13. // TODO: change this to closeDelay to match other API in delayable.js
  14. timeout: {
  15. type: Number,
  16. default: 6000
  17. },
  18. vertical: Boolean
  19. },
  20. data: function data() {
  21. return {
  22. activeTimeout: -1
  23. };
  24. },
  25. computed: {
  26. classes: function classes() {
  27. return {
  28. 'v-snack--active': this.isActive,
  29. 'v-snack--absolute': this.absolute,
  30. 'v-snack--auto-height': this.autoHeight,
  31. 'v-snack--bottom': this.bottom || !this.top,
  32. 'v-snack--left': this.left,
  33. 'v-snack--multi-line': this.multiLine && !this.vertical,
  34. 'v-snack--right': this.right,
  35. 'v-snack--top': this.top,
  36. 'v-snack--vertical': this.vertical
  37. };
  38. }
  39. },
  40. watch: {
  41. isActive: function isActive() {
  42. this.setTimeout();
  43. }
  44. },
  45. mounted: function mounted() {
  46. this.setTimeout();
  47. },
  48. methods: {
  49. setTimeout: function setTimeout() {
  50. var _this = this;
  51. window.clearTimeout(this.activeTimeout);
  52. if (this.isActive && this.timeout) {
  53. this.activeTimeout = window.setTimeout(function () {
  54. _this.isActive = false;
  55. }, this.timeout);
  56. }
  57. }
  58. },
  59. render: function render(h) {
  60. return h('transition', {
  61. attrs: { name: 'v-snack-transition' }
  62. }, this.isActive && [h('div', {
  63. staticClass: 'v-snack',
  64. class: this.classes,
  65. on: this.$listeners
  66. }, [h('div', this.setBackgroundColor(this.color, {
  67. staticClass: 'v-snack__wrapper'
  68. }), [h('div', {
  69. staticClass: 'v-snack__content'
  70. }, this.$slots.default)])])]);
  71. }
  72. });
  73. //# sourceMappingURL=VSnackbar.js.map