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 5.9KB

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