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.

VProgressLinear.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. require('../../../src/stylus/components/_progress-linear.styl');
  6. var _colorable = require('../../mixins/colorable');
  7. var _colorable2 = _interopRequireDefault(_colorable);
  8. var _helpers = require('../../util/helpers');
  9. var _mixins = require('../../util/mixins');
  10. var _mixins2 = _interopRequireDefault(_mixins);
  11. var _transitions = require('../transitions');
  12. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  14. // Mixins
  15. // Helpers
  16. /* @vue/component */
  17. exports.default = (0, _mixins2.default)(_colorable2.default).extend({
  18. name: 'v-progress-linear',
  19. props: {
  20. active: {
  21. type: Boolean,
  22. default: true
  23. },
  24. backgroundColor: {
  25. type: String,
  26. default: null
  27. },
  28. backgroundOpacity: {
  29. type: [Number, String],
  30. default: null
  31. },
  32. bufferValue: {
  33. type: [Number, String],
  34. default: 100
  35. },
  36. color: {
  37. type: String,
  38. default: 'primary'
  39. },
  40. height: {
  41. type: [Number, String],
  42. default: 7
  43. },
  44. indeterminate: Boolean,
  45. query: Boolean,
  46. value: {
  47. type: [Number, String],
  48. default: 0
  49. }
  50. },
  51. computed: {
  52. backgroundStyle: function backgroundStyle() {
  53. var backgroundOpacity = this.backgroundOpacity == null ? this.backgroundColor ? 1 : 0.3 : parseFloat(this.backgroundOpacity);
  54. return {
  55. height: this.active ? (0, _helpers.convertToUnit)(this.height) : 0,
  56. opacity: backgroundOpacity,
  57. width: this.normalizedBufer + '%'
  58. };
  59. },
  60. effectiveWidth: function effectiveWidth() {
  61. if (!this.normalizedBufer) {
  62. return 0;
  63. }
  64. return +this.normalizedValue * 100 / +this.normalizedBufer;
  65. },
  66. normalizedBufer: function normalizedBufer() {
  67. if (this.bufferValue < 0) {
  68. return 0;
  69. }
  70. if (this.bufferValue > 100) {
  71. return 100;
  72. }
  73. return parseFloat(this.bufferValue);
  74. },
  75. normalizedValue: function normalizedValue() {
  76. if (this.value < 0) {
  77. return 0;
  78. }
  79. if (this.value > 100) {
  80. return 100;
  81. }
  82. return parseFloat(this.value);
  83. },
  84. styles: function styles() {
  85. var styles = {};
  86. if (!this.active) {
  87. styles.height = 0;
  88. }
  89. if (!this.indeterminate && parseFloat(this.normalizedBufer) !== 100) {
  90. styles.width = this.normalizedBufer + '%';
  91. }
  92. return styles;
  93. }
  94. },
  95. methods: {
  96. genDeterminate: function genDeterminate(h) {
  97. return h('div', this.setBackgroundColor(this.color, {
  98. ref: 'front',
  99. staticClass: 'v-progress-linear__bar__determinate',
  100. style: {
  101. width: this.effectiveWidth + '%'
  102. }
  103. }));
  104. },
  105. genBar: function genBar(h, name) {
  106. return h('div', this.setBackgroundColor(this.color, {
  107. staticClass: 'v-progress-linear__bar__indeterminate',
  108. class: _defineProperty({}, name, true)
  109. }));
  110. },
  111. genIndeterminate: function genIndeterminate(h) {
  112. return h('div', {
  113. ref: 'front',
  114. staticClass: 'v-progress-linear__bar__indeterminate',
  115. class: {
  116. 'v-progress-linear__bar__indeterminate--active': this.active
  117. }
  118. }, [this.genBar(h, 'long'), this.genBar(h, 'short')]);
  119. }
  120. },
  121. render: function render(h) {
  122. var fade = h(_transitions.VFadeTransition, this.indeterminate ? [this.genIndeterminate(h)] : []);
  123. var slide = h(_transitions.VSlideXTransition, this.indeterminate ? [] : [this.genDeterminate(h)]);
  124. var bar = h('div', {
  125. staticClass: 'v-progress-linear__bar',
  126. style: this.styles
  127. }, [fade, slide]);
  128. var background = h('div', this.setBackgroundColor(this.backgroundColor || this.color, {
  129. staticClass: 'v-progress-linear__background',
  130. style: this.backgroundStyle
  131. }));
  132. var content = this.$slots.default && h('div', {
  133. staticClass: 'v-progress-linear__content'
  134. }, this.$slots.default);
  135. return h('div', {
  136. staticClass: 'v-progress-linear',
  137. attrs: {
  138. 'role': 'progressbar',
  139. 'aria-valuemin': 0,
  140. 'aria-valuemax': this.normalizedBufer,
  141. 'aria-valuenow': this.indeterminate ? undefined : this.normalizedValue
  142. },
  143. class: {
  144. 'v-progress-linear--query': this.query
  145. },
  146. style: {
  147. height: (0, _helpers.convertToUnit)(this.height)
  148. },
  149. on: this.$listeners
  150. }, [background, bar, content]);
  151. }
  152. });
  153. //# sourceMappingURL=VProgressLinear.js.map