This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vuetify/es5/components/VDatePicker/VDatePickerYears.js

102 lines
2.8 KiB
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("../../../src/components/VDatePicker/VDatePickerYears.sass");
var _colorable = _interopRequireDefault(require("../../mixins/colorable"));
var _localable = _interopRequireDefault(require("../../mixins/localable"));
var _util = require("./util");
var _mixins = _interopRequireDefault(require("../../util/mixins"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Mixins
// Utils
var _default = (0, _mixins.default)(_colorable.default, _localable.default
/* @vue/component */
).extend({
name: 'v-date-picker-years',
props: {
format: Function,
min: [Number, String],
max: [Number, String],
readonly: Boolean,
value: [Number, String]
},
data: function data() {
return {
defaultColor: 'primary'
};
},
computed: {
formatter: function formatter() {
return this.format || (0, _util.createNativeLocaleFormatter)(this.currentLocale, {
year: 'numeric',
timeZone: 'UTC'
}, {
length: 4
});
}
},
mounted: function mounted() {
var _this = this;
setTimeout(function () {
var activeItem = _this.$el.getElementsByClassName('active')[0];
if (activeItem) {
_this.$el.scrollTop = activeItem.offsetTop - _this.$el.offsetHeight / 2 + activeItem.offsetHeight / 2;
} else {
_this.$el.scrollTop = _this.$el.scrollHeight / 2 - _this.$el.offsetHeight / 2;
}
});
},
methods: {
genYearItem: function genYearItem(year) {
var _this2 = this;
var formatted = this.formatter("".concat(year));
var active = parseInt(this.value, 10) === year;
var color = active && (this.color || 'primary');
return this.$createElement('li', this.setTextColor(color, {
key: year,
class: {
active: active
},
on: {
click: function click() {
return _this2.$emit('input', year);
}
}
}), formatted);
},
genYearItems: function genYearItems() {
var children = [];
var selectedYear = this.value ? parseInt(this.value, 10) : new Date().getFullYear();
var maxYear = this.max ? parseInt(this.max, 10) : selectedYear + 100;
var minYear = Math.min(maxYear, this.min ? parseInt(this.min, 10) : selectedYear - 100);
for (var year = maxYear; year >= minYear; year--) {
children.push(this.genYearItem(year));
}
return children;
}
},
render: function render() {
return this.$createElement('ul', {
staticClass: 'v-date-picker-years',
ref: 'years'
}, this.genYearItems());
}
});
exports.default = _default;
//# sourceMappingURL=VDatePickerYears.js.map