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.

calendar-with-intervals.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _calendarBase = require('./calendar-base');
  6. var _calendarBase2 = _interopRequireDefault(_calendarBase);
  7. var _props = require('../util/props');
  8. var _props2 = _interopRequireDefault(_props);
  9. var _timestamp = require('../util/timestamp');
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. /* @vue/component */
  12. // Util
  13. exports.default = _calendarBase2.default.extend({
  14. name: 'calendar-with-intervals',
  15. props: _props2.default.intervals,
  16. computed: {
  17. parsedFirstInterval: function parsedFirstInterval() {
  18. return parseInt(this.firstInterval);
  19. },
  20. parsedIntervalMinutes: function parsedIntervalMinutes() {
  21. return parseInt(this.intervalMinutes);
  22. },
  23. parsedIntervalCount: function parsedIntervalCount() {
  24. return parseInt(this.intervalCount);
  25. },
  26. parsedIntervalHeight: function parsedIntervalHeight() {
  27. return parseFloat(this.intervalHeight);
  28. },
  29. firstMinute: function firstMinute() {
  30. return this.parsedFirstInterval * this.parsedIntervalMinutes;
  31. },
  32. bodyHeight: function bodyHeight() {
  33. return this.parsedIntervalCount * this.parsedIntervalHeight;
  34. },
  35. days: function days() {
  36. return (0, _timestamp.createDayList)(this.parsedStart, this.parsedEnd, this.times.today, this.weekdaySkips, this.maxDays);
  37. },
  38. intervals: function intervals() {
  39. var days = this.days;
  40. var first = this.parsedFirstInterval;
  41. var minutes = this.parsedIntervalMinutes;
  42. var count = this.parsedIntervalCount;
  43. var now = this.times.now;
  44. return days.map(function (d) {
  45. return (0, _timestamp.createIntervalList)(d, first, minutes, count, now);
  46. });
  47. },
  48. intervalFormatter: function intervalFormatter() {
  49. if (this.intervalFormat) {
  50. return this.intervalFormat;
  51. }
  52. var longOptions = { timeZone: 'UTC', hour12: true, hour: '2-digit', minute: '2-digit' };
  53. var shortOptions = { timeZone: 'UTC', hour12: true, hour: 'numeric', minute: '2-digit' };
  54. var shortHourOptions = { timeZone: 'UTC', hour12: true, hour: 'numeric' };
  55. return (0, _timestamp.createNativeLocaleFormatter)(this.locale, function (tms, short) {
  56. return short ? tms.minute === 0 ? shortHourOptions : shortOptions : longOptions;
  57. });
  58. }
  59. },
  60. methods: {
  61. showIntervalLabelDefault: function showIntervalLabelDefault(interval) {
  62. var first = this.intervals[0][0];
  63. var isFirst = first.hour === interval.hour && first.minute === interval.minute;
  64. return !isFirst && interval.minute === 0;
  65. },
  66. intervalStyleDefault: function intervalStyleDefault(_interval) {
  67. return undefined;
  68. },
  69. getTimestampAtEvent: function getTimestampAtEvent(e, day) {
  70. var timestamp = (0, _timestamp.copyTimestamp)(day);
  71. var bounds = e.currentTarget.getBoundingClientRect();
  72. var baseMinutes = this.firstMinute;
  73. var touchEvent = e;
  74. var mouseEvent = e;
  75. var touches = touchEvent.changedTouches || touchEvent.touches;
  76. var clientY = touches && touches[0] ? touches[0].clientY : mouseEvent.clientY;
  77. var addIntervals = (clientY - bounds.top) / this.parsedIntervalHeight;
  78. var addMinutes = Math.floor(addIntervals * this.parsedIntervalMinutes);
  79. var minutes = baseMinutes + addMinutes;
  80. return (0, _timestamp.updateMinutes)(timestamp, minutes, this.times.now);
  81. },
  82. getSlotScope: function getSlotScope(timestamp) {
  83. var scope = (0, _timestamp.copyTimestamp)(timestamp);
  84. scope.timeToY = this.timeToY;
  85. scope.minutesToPixels = this.minutesToPixels;
  86. return scope;
  87. },
  88. scrollToTime: function scrollToTime(time) {
  89. var y = this.timeToY(time);
  90. var pane = this.$refs.scrollArea;
  91. if (y === false || !pane) {
  92. return false;
  93. }
  94. pane.scrollTop = y;
  95. return true;
  96. },
  97. minutesToPixels: function minutesToPixels(minutes) {
  98. return minutes / this.parsedIntervalMinutes * this.parsedIntervalHeight;
  99. },
  100. timeToY: function timeToY(time) {
  101. var clamp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  102. var minutes = (0, _timestamp.parseTime)(time);
  103. if (minutes === false) {
  104. return false;
  105. }
  106. var min = this.firstMinute;
  107. var gap = this.parsedIntervalCount * this.parsedIntervalMinutes;
  108. var delta = (minutes - min) / gap;
  109. var y = delta * this.bodyHeight;
  110. if (clamp) {
  111. if (y < 0) {
  112. y = 0;
  113. }
  114. if (y > this.bodyHeight) {
  115. y = this.bodyHeight;
  116. }
  117. }
  118. return y;
  119. }
  120. }
  121. }); // Mixins
  122. //# sourceMappingURL=calendar-with-intervals.js.map