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.

VCalendarWeekly.js 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Styles
  6. // Mixins
  7. // Util
  8. require('../../../src/stylus/components/_calendar-weekly.styl');
  9. var _calendarBase = require('./mixins/calendar-base');
  10. var _calendarBase2 = _interopRequireDefault(_calendarBase);
  11. var _props = require('./util/props');
  12. var _props2 = _interopRequireDefault(_props);
  13. var _timestamp = require('./util/timestamp');
  14. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  16. /* @vue/component */
  17. exports.default = _calendarBase2.default.extend({
  18. name: 'v-calendar-weekly',
  19. props: _props2.default.weeks,
  20. computed: {
  21. staticClass: function staticClass() {
  22. return 'v-calendar-weekly';
  23. },
  24. classes: function classes() {
  25. return this.themeClasses;
  26. },
  27. parsedMinWeeks: function parsedMinWeeks() {
  28. return parseInt(this.minWeeks);
  29. },
  30. days: function days() {
  31. var minDays = this.parsedMinWeeks * this.weekdays.length;
  32. var start = this.getStartOfWeek(this.parsedStart);
  33. var end = this.getEndOfWeek(this.parsedEnd);
  34. return (0, _timestamp.createDayList)(start, end, this.times.today, this.weekdaySkips, Number.MAX_SAFE_INTEGER, minDays);
  35. },
  36. todayWeek: function todayWeek() {
  37. var today = this.times.today;
  38. var start = this.getStartOfWeek(today);
  39. var end = this.getEndOfWeek(today);
  40. return (0, _timestamp.createDayList)(start, end, today, this.weekdaySkips, this.weekdays.length, this.weekdays.length);
  41. },
  42. monthFormatter: function monthFormatter() {
  43. if (this.monthFormat) {
  44. return this.monthFormat;
  45. }
  46. var longOptions = { timeZone: 'UTC', month: 'long' };
  47. var shortOptions = { timeZone: 'UTC', month: 'short' };
  48. return (0, _timestamp.createNativeLocaleFormatter)(this.locale, function (_tms, short) {
  49. return short ? shortOptions : longOptions;
  50. });
  51. }
  52. },
  53. methods: {
  54. isOutside: function isOutside(day) {
  55. var dayIdentifier = (0, _timestamp.getDayIdentifier)(day);
  56. return dayIdentifier < (0, _timestamp.getDayIdentifier)(this.parsedStart) || dayIdentifier > (0, _timestamp.getDayIdentifier)(this.parsedEnd);
  57. },
  58. genHead: function genHead() {
  59. return this.$createElement('div', {
  60. staticClass: 'v-calendar-weekly__head'
  61. }, this.genHeadDays());
  62. },
  63. genHeadDays: function genHeadDays() {
  64. return this.todayWeek.map(this.genHeadDay);
  65. },
  66. genHeadDay: function genHeadDay(day, index) {
  67. var outside = this.isOutside(this.days[index]);
  68. var color = day.present ? this.color : undefined;
  69. return this.$createElement('div', this.setTextColor(color, {
  70. key: day.date,
  71. staticClass: 'v-calendar-weekly__head-weekday',
  72. class: this.getRelativeClasses(day, outside)
  73. }), this.weekdayFormatter(day, this.shortWeekdays));
  74. },
  75. genWeeks: function genWeeks() {
  76. var days = this.days;
  77. var weekDays = this.weekdays.length;
  78. var weeks = [];
  79. for (var i = 0; i < days.length; i += weekDays) {
  80. weeks.push(this.genWeek(days.slice(i, i + weekDays)));
  81. }
  82. return weeks;
  83. },
  84. genWeek: function genWeek(week) {
  85. return this.$createElement('div', {
  86. key: week[0].date,
  87. staticClass: 'v-calendar-weekly__week'
  88. }, week.map(this.genDay));
  89. },
  90. genDay: function genDay(day) {
  91. var outside = this.isOutside(day);
  92. var slot = this.$scopedSlots.day;
  93. var slotData = _extends({ outside: outside }, day);
  94. var hasMonth = day.day === 1 && this.showMonthOnFirst;
  95. return this.$createElement('div', {
  96. key: day.date,
  97. staticClass: 'v-calendar-weekly__day',
  98. class: this.getRelativeClasses(day, outside),
  99. on: this.getDefaultMouseEventHandlers(':day', function (_e) {
  100. return day;
  101. })
  102. }, [this.genDayLabel(day), hasMonth ? this.genDayMonth(day) : '', slot ? slot(slotData) : '']);
  103. },
  104. genDayLabel: function genDayLabel(day) {
  105. var color = day.present ? this.color : undefined;
  106. var slot = this.$scopedSlots.dayLabel;
  107. return this.$createElement('div', this.setTextColor(color, {
  108. staticClass: 'v-calendar-weekly__day-label',
  109. on: this.getMouseEventHandlers({
  110. 'click:date': { event: 'click', stop: true },
  111. 'contextmenu:date': { event: 'contextmenu', stop: true, prevent: true, result: false }
  112. }, function (_e) {
  113. return day;
  114. })
  115. }), slot ? slot(day) : this.dayFormatter(day, false));
  116. },
  117. genDayMonth: function genDayMonth(day) {
  118. var color = day.present ? this.color : undefined;
  119. var slot = this.$scopedSlots.dayMonth;
  120. return this.$createElement('div', this.setTextColor(color, {
  121. staticClass: 'v-calendar-weekly__day-month'
  122. }), slot ? slot(day) : this.monthFormatter(day, this.shortMonths));
  123. }
  124. },
  125. render: function render(h) {
  126. return h('div', {
  127. staticClass: this.staticClass,
  128. class: this.classes,
  129. nativeOn: {
  130. dragstart: function dragstart(e) {
  131. e.preventDefault();
  132. }
  133. }
  134. }, [!this.hideHeader ? this.genHead() : ''].concat(_toConsumableArray(this.genWeeks())));
  135. }
  136. });
  137. //# sourceMappingURL=VCalendarWeekly.js.map