Licitator 1.0
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.

178 lines
6.8 KiB

5 years ago
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3. typeof define === 'function' && define.amd ? define(factory) :
  4. (global = global || self, global.WeekendHighlight = factory());
  5. }(this, (function () { 'use strict';
  6. /**
  7. * @license
  8. * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
  9. * This code may only be used under the BSD style license found at
  10. * http://polymer.github.io/LICENSE.txt
  11. * The complete set of authors may be found at
  12. * http://polymer.github.io/AUTHORS.txt
  13. * The complete set of contributors may be found at
  14. * http://polymer.github.io/CONTRIBUTORS.txt
  15. * Code distributed by Google as part of the polymer project is also
  16. * subject to an additional IP rights grant found at
  17. * http://polymer.github.io/PATENTS.txt
  18. */
  19. /**
  20. * @license
  21. * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
  22. * This code may only be used under the BSD style license found at
  23. * http://polymer.github.io/LICENSE.txt
  24. * The complete set of authors may be found at
  25. * http://polymer.github.io/AUTHORS.txt
  26. * The complete set of contributors may be found at
  27. * http://polymer.github.io/CONTRIBUTORS.txt
  28. * Code distributed by Google as part of the polymer project is also
  29. * subject to an additional IP rights grant found at
  30. * http://polymer.github.io/PATENTS.txt
  31. */
  32. /**
  33. * An expression marker with embedded unique key to avoid collision with
  34. * possible text in templates.
  35. */
  36. const marker = `{{lit-${String(Math.random()).slice(2)}}}`;
  37. /**
  38. * Used to clone existing node instead of each time creating new one which is
  39. * slower
  40. */
  41. const markerNode = document.createComment('');
  42. /**
  43. * Used to clone existing node instead of each time creating new one which is
  44. * slower
  45. */
  46. const emptyTemplateNode = document.createElement('template');
  47. /**
  48. * Used to clone text node instead of each time creating new one which is slower
  49. */
  50. const emptyTextNode = document.createTextNode('');
  51. // Detect event listener options support. If the `capture` property is read
  52. // from the options object, then options are supported. If not, then the third
  53. // argument to add/removeEventListener is interpreted as the boolean capture
  54. // value so we should only pass the `capture` property.
  55. let eventOptionsSupported = false;
  56. // Wrap into an IIFE because MS Edge <= v41 does not support having try/catch
  57. // blocks right into the body of a module
  58. (() => {
  59. try {
  60. const options = {
  61. get capture() {
  62. eventOptionsSupported = true;
  63. return false;
  64. }
  65. };
  66. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  67. window.addEventListener('test', options, options);
  68. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  69. window.removeEventListener('test', options, options);
  70. }
  71. catch (_e) {
  72. // noop
  73. }
  74. })();
  75. /**
  76. * @license
  77. * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
  78. * This code may only be used under the BSD style license found at
  79. * http://polymer.github.io/LICENSE.txt
  80. * The complete set of authors may be found at
  81. * http://polymer.github.io/AUTHORS.txt
  82. * The complete set of contributors may be found at
  83. * http://polymer.github.io/CONTRIBUTORS.txt
  84. * Code distributed by Google as part of the polymer project is also
  85. * subject to an additional IP rights grant found at
  86. * http://polymer.github.io/PATENTS.txt
  87. */
  88. // IMPORTANT: do not change the property name or the assignment expression.
  89. // This line will be used in regexes to search for lit-html usage.
  90. // TODO(justinfagnani): inject version number at build time
  91. const isBrowser = typeof window !== 'undefined';
  92. if (isBrowser) {
  93. // If we run in the browser set version
  94. (window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.1.7');
  95. }
  96. /**
  97. * Used to clone existing node instead of each time creating new one which is
  98. * slower
  99. */
  100. const emptyTemplateNode$1 = document.createElement('template');
  101. class Action {
  102. constructor() {
  103. this.isAction = true;
  104. }
  105. }
  106. Action.prototype.isAction = true;
  107. const defaultOptions = {
  108. element: document.createTextNode(''),
  109. axis: 'xy',
  110. threshold: 10,
  111. onDown(data) { },
  112. onMove(data) { },
  113. onUp(data) { },
  114. onWheel(data) { }
  115. };
  116. /**
  117. * Weekend highlight plugin
  118. *
  119. * @copyright Rafal Pospiech <https://neuronet.io>
  120. * @author Rafal Pospiech <neuronet.io@gmail.com>
  121. * @package gantt-schedule-timeline-calendar
  122. * @license AGPL-3.0 (https://github.com/neuronetio/gantt-schedule-timeline-calendar/blob/master/LICENSE)
  123. * @link https://github.com/neuronetio/gantt-schedule-timeline-calendar
  124. */
  125. function WeekendHiglight(options = {}) {
  126. const weekdays = options.weekdays || [6, 0];
  127. let className;
  128. let api;
  129. let enabled = true;
  130. class WeekendHighlightAction extends Action {
  131. constructor(element, data) {
  132. super();
  133. this.highlight(element, data.time.leftGlobal);
  134. }
  135. update(element, data) {
  136. this.highlight(element, data.time.leftGlobal);
  137. }
  138. highlight(element, time) {
  139. const hasClass = element.classList.contains(className);
  140. if (!enabled) {
  141. if (hasClass) {
  142. element.classList.remove(className);
  143. }
  144. return;
  145. }
  146. const isWeekend = weekdays.includes(api.time.date(time).day());
  147. if (!hasClass && isWeekend) {
  148. element.classList.add(className);
  149. }
  150. else if (hasClass && !isWeekend) {
  151. element.classList.remove(className);
  152. }
  153. }
  154. }
  155. return function initialize(vido) {
  156. api = vido.api;
  157. className = options.className || api.getClass('chart-timeline-grid-row-block') + '--weekend';
  158. const destroy = vido.state.subscribe('_internal.chart.time.format.period', period => (enabled = period === 'day'));
  159. vido.state.update('config.actions.chart-timeline-grid-row-block', actions => {
  160. actions.push(WeekendHighlightAction);
  161. return actions;
  162. });
  163. return function onDestroy() {
  164. destroy();
  165. };
  166. };
  167. }
  168. return WeekendHiglight;
  169. })));
  170. //# sourceMappingURL=WeekendHighlight.plugin.js.map