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.

VCalendar.js 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. // import '../../stylus/components/_calendar-daily.styl'
  7. // Mixins
  8. // Util
  9. // Calendars
  10. var _calendarBase = require('./mixins/calendar-base');
  11. var _calendarBase2 = _interopRequireDefault(_calendarBase);
  12. var _props = require('./util/props');
  13. var _props2 = _interopRequireDefault(_props);
  14. var _timestamp = require('./util/timestamp');
  15. var _VCalendarMonthly = require('./VCalendarMonthly');
  16. var _VCalendarMonthly2 = _interopRequireDefault(_VCalendarMonthly);
  17. var _VCalendarDaily = require('./VCalendarDaily');
  18. var _VCalendarDaily2 = _interopRequireDefault(_VCalendarDaily);
  19. var _VCalendarWeekly = require('./VCalendarWeekly');
  20. var _VCalendarWeekly2 = _interopRequireDefault(_VCalendarWeekly);
  21. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22. /* @vue/component */
  23. exports.default = _calendarBase2.default.extend({
  24. name: 'v-calendar',
  25. props: _extends({}, _props2.default.calendar, _props2.default.weeks, _props2.default.intervals),
  26. data: function data() {
  27. return {
  28. lastStart: null,
  29. lastEnd: null
  30. };
  31. },
  32. computed: {
  33. parsedValue: function parsedValue() {
  34. return (0, _timestamp.parseTimestamp)(this.value) || this.parsedStart || this.times.today;
  35. },
  36. renderProps: function renderProps() {
  37. var around = this.parsedValue;
  38. var component = 'div';
  39. var maxDays = this.maxDays;
  40. var start = around;
  41. var end = around;
  42. switch (this.type) {
  43. case 'month':
  44. component = _VCalendarMonthly2.default;
  45. start = (0, _timestamp.getStartOfMonth)(around);
  46. end = (0, _timestamp.getEndOfMonth)(around);
  47. break;
  48. case 'week':
  49. component = _VCalendarDaily2.default;
  50. start = this.getStartOfWeek(around);
  51. end = this.getEndOfWeek(around);
  52. maxDays = 7;
  53. break;
  54. case 'day':
  55. component = _VCalendarDaily2.default;
  56. maxDays = 1;
  57. break;
  58. case '4day':
  59. component = _VCalendarDaily2.default;
  60. end = (0, _timestamp.relativeDays)((0, _timestamp.copyTimestamp)(end), _timestamp.nextDay, 4);
  61. (0, _timestamp.updateFormatted)(end);
  62. maxDays = 4;
  63. break;
  64. case 'custom-weekly':
  65. component = _VCalendarWeekly2.default;
  66. start = this.parsedStart || around;
  67. end = this.parsedEnd;
  68. break;
  69. case 'custom-daily':
  70. component = _VCalendarDaily2.default;
  71. start = this.parsedStart || around;
  72. end = this.parsedEnd;
  73. break;
  74. }
  75. return { component: component, start: start, end: end, maxDays: maxDays };
  76. }
  77. },
  78. watch: {
  79. renderProps: 'checkChange'
  80. },
  81. methods: {
  82. checkChange: function checkChange() {
  83. var _renderProps = this.renderProps,
  84. start = _renderProps.start,
  85. end = _renderProps.end;
  86. if (start !== this.lastStart || end !== this.lastEnd) {
  87. this.lastStart = start;
  88. this.lastEnd = end;
  89. this.$emit('change', { start: start, end: end });
  90. }
  91. },
  92. move: function move() {
  93. var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  94. var moved = (0, _timestamp.copyTimestamp)(this.parsedValue);
  95. var forward = amount > 0;
  96. var mover = forward ? _timestamp.nextDay : _timestamp.prevDay;
  97. var limit = forward ? _timestamp.DAYS_IN_MONTH_MAX : _timestamp.DAY_MIN;
  98. var times = forward ? amount : -amount;
  99. while (--times >= 0) {
  100. switch (this.type) {
  101. case 'month':
  102. moved.day = limit;
  103. mover(moved);
  104. break;
  105. case 'week':
  106. (0, _timestamp.relativeDays)(moved, mover, _timestamp.DAYS_IN_WEEK);
  107. break;
  108. case 'day':
  109. mover(moved);
  110. break;
  111. case '4day':
  112. (0, _timestamp.relativeDays)(moved, mover, 4);
  113. break;
  114. }
  115. }
  116. (0, _timestamp.updateWeekday)(moved);
  117. (0, _timestamp.updateFormatted)(moved);
  118. (0, _timestamp.updateRelative)(moved, this.times.now);
  119. this.$emit('input', moved.date);
  120. this.$emit('moved', moved);
  121. },
  122. next: function next() {
  123. var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  124. this.move(amount);
  125. },
  126. prev: function prev() {
  127. var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  128. this.move(-amount);
  129. },
  130. timeToY: function timeToY(time) {
  131. var clamp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  132. var c = this.$children[0];
  133. if (c && c.timeToY) {
  134. return c.timeToY(time, clamp);
  135. } else {
  136. return false;
  137. }
  138. },
  139. minutesToPixels: function minutesToPixels(minutes) {
  140. var c = this.$children[0];
  141. if (c && c.minutesToPixels) {
  142. return c.minutesToPixels(minutes);
  143. } else {
  144. return -1;
  145. }
  146. },
  147. scrollToTime: function scrollToTime(time) {
  148. var c = this.$children[0];
  149. if (c && c.scrollToTime) {
  150. return c.scrollToTime(time);
  151. } else {
  152. return false;
  153. }
  154. }
  155. },
  156. render: function render(h) {
  157. var _this = this;
  158. var _renderProps2 = this.renderProps,
  159. start = _renderProps2.start,
  160. end = _renderProps2.end,
  161. maxDays = _renderProps2.maxDays,
  162. component = _renderProps2.component;
  163. return h(component, {
  164. staticClass: 'v-calendar',
  165. props: _extends({}, this.$props, {
  166. start: start.date,
  167. end: end.date,
  168. maxDays: maxDays
  169. }),
  170. on: _extends({}, this.$listeners, {
  171. 'click:date': function clickDate(day) {
  172. if (_this.$listeners['input']) {
  173. _this.$emit('input', day.date);
  174. }
  175. if (_this.$listeners['click:date']) {
  176. _this.$emit('click:date', day);
  177. }
  178. }
  179. }),
  180. scopedSlots: this.$scopedSlots
  181. });
  182. }
  183. });
  184. //# sourceMappingURL=VCalendar.js.map