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.

VDatePickerYears.js 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. require('../../../src/stylus/components/_date-picker-years.styl');
  6. var _colorable = require('../../mixins/colorable');
  7. var _colorable2 = _interopRequireDefault(_colorable);
  8. var _util = require('./util');
  9. var _mixins = require('../../util/mixins');
  10. var _mixins2 = _interopRequireDefault(_mixins);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. // Utils
  13. exports.default = (0, _mixins2.default)(_colorable2.default
  14. /* @vue/component */
  15. ).extend({
  16. name: 'v-date-picker-years',
  17. props: {
  18. format: Function,
  19. locale: {
  20. type: String,
  21. default: 'en-us'
  22. },
  23. min: [Number, String],
  24. max: [Number, String],
  25. readonly: Boolean,
  26. value: [Number, String]
  27. },
  28. data: function data() {
  29. return {
  30. defaultColor: 'primary'
  31. };
  32. },
  33. computed: {
  34. formatter: function formatter() {
  35. return this.format || (0, _util.createNativeLocaleFormatter)(this.locale, { year: 'numeric', timeZone: 'UTC' }, { length: 4 });
  36. }
  37. },
  38. mounted: function mounted() {
  39. var _this = this;
  40. setTimeout(function () {
  41. var activeItem = _this.$el.getElementsByClassName('active')[0];
  42. if (activeItem) {
  43. _this.$el.scrollTop = activeItem.offsetTop - _this.$el.offsetHeight / 2 + activeItem.offsetHeight / 2;
  44. } else {
  45. _this.$el.scrollTop = _this.$el.scrollHeight / 2 - _this.$el.offsetHeight / 2;
  46. }
  47. });
  48. },
  49. methods: {
  50. genYearItem: function genYearItem(year) {
  51. var _this2 = this;
  52. var formatted = this.formatter('' + year);
  53. var active = parseInt(this.value, 10) === year;
  54. var color = active && (this.color || 'primary');
  55. return this.$createElement('li', this.setTextColor(color, {
  56. key: year,
  57. 'class': { active: active },
  58. on: {
  59. click: function click() {
  60. return _this2.$emit('input', year);
  61. }
  62. }
  63. }), formatted);
  64. },
  65. genYearItems: function genYearItems() {
  66. var children = [];
  67. var selectedYear = this.value ? parseInt(this.value, 10) : new Date().getFullYear();
  68. var maxYear = this.max ? parseInt(this.max, 10) : selectedYear + 100;
  69. var minYear = Math.min(maxYear, this.min ? parseInt(this.min, 10) : selectedYear - 100);
  70. for (var year = maxYear; year >= minYear; year--) {
  71. children.push(this.genYearItem(year));
  72. }
  73. return children;
  74. }
  75. },
  76. render: function render() {
  77. return this.$createElement('ul', {
  78. staticClass: 'v-date-picker-years',
  79. ref: 'years'
  80. }, this.genYearItems());
  81. }
  82. });
  83. // Mixins
  84. //# sourceMappingURL=VDatePickerYears.js.map