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.

169 lines
5.9 KiB

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