vis.js is a dynamic, browser-based visualization library
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.

1336 lines
46 KiB

  1. var Emitter = require('emitter-component');
  2. var Hammer = require('../module/hammer');
  3. var hammerUtil = require('../hammerUtil');
  4. var util = require('../util');
  5. var TimeAxis = require('./component/TimeAxis');
  6. var Activator = require('../shared/Activator');
  7. var DateUtil = require('./DateUtil');
  8. var CustomTime = require('./component/CustomTime');
  9. /**
  10. * Create a timeline visualization
  11. * @constructor Core
  12. */
  13. function Core () {}
  14. // turn Core into an event emitter
  15. Emitter(Core.prototype);
  16. /**
  17. * Create the main DOM for the Core: a root panel containing left, right,
  18. * top, bottom, content, and background panel.
  19. * @param {Element} container The container element where the Core will
  20. * be attached.
  21. * @protected
  22. */
  23. Core.prototype._create = function (container) {
  24. this.dom = {};
  25. this.dom.container = container;
  26. this.dom.root = document.createElement('div');
  27. this.dom.background = document.createElement('div');
  28. this.dom.backgroundVertical = document.createElement('div');
  29. this.dom.backgroundHorizontal = document.createElement('div');
  30. this.dom.centerContainer = document.createElement('div');
  31. this.dom.leftContainer = document.createElement('div');
  32. this.dom.rightContainer = document.createElement('div');
  33. this.dom.center = document.createElement('div');
  34. this.dom.left = document.createElement('div');
  35. this.dom.right = document.createElement('div');
  36. this.dom.top = document.createElement('div');
  37. this.dom.bottom = document.createElement('div');
  38. this.dom.shadowTop = document.createElement('div');
  39. this.dom.shadowBottom = document.createElement('div');
  40. this.dom.shadowTopLeft = document.createElement('div');
  41. this.dom.shadowBottomLeft = document.createElement('div');
  42. this.dom.shadowTopRight = document.createElement('div');
  43. this.dom.shadowBottomRight = document.createElement('div');
  44. this.dom.rollingModeBtn = document.createElement('div');
  45. this.dom.root.className = 'vis-timeline';
  46. this.dom.background.className = 'vis-panel vis-background';
  47. this.dom.backgroundVertical.className = 'vis-panel vis-background vis-vertical';
  48. this.dom.backgroundHorizontal.className = 'vis-panel vis-background vis-horizontal';
  49. this.dom.centerContainer.className = 'vis-panel vis-center';
  50. this.dom.leftContainer.className = 'vis-panel vis-left';
  51. this.dom.rightContainer.className = 'vis-panel vis-right';
  52. this.dom.top.className = 'vis-panel vis-top';
  53. this.dom.bottom.className = 'vis-panel vis-bottom';
  54. this.dom.left.className = 'vis-content';
  55. this.dom.center.className = 'vis-content';
  56. this.dom.right.className = 'vis-content';
  57. this.dom.shadowTop.className = 'vis-shadow vis-top';
  58. this.dom.shadowBottom.className = 'vis-shadow vis-bottom';
  59. this.dom.shadowTopLeft.className = 'vis-shadow vis-top';
  60. this.dom.shadowBottomLeft.className = 'vis-shadow vis-bottom';
  61. this.dom.shadowTopRight.className = 'vis-shadow vis-top';
  62. this.dom.shadowBottomRight.className = 'vis-shadow vis-bottom';
  63. this.dom.rollingModeBtn.className = 'vis-rolling-mode-btn';
  64. this.dom.root.appendChild(this.dom.background);
  65. this.dom.root.appendChild(this.dom.backgroundVertical);
  66. this.dom.root.appendChild(this.dom.backgroundHorizontal);
  67. this.dom.root.appendChild(this.dom.centerContainer);
  68. this.dom.root.appendChild(this.dom.leftContainer);
  69. this.dom.root.appendChild(this.dom.rightContainer);
  70. this.dom.root.appendChild(this.dom.top);
  71. this.dom.root.appendChild(this.dom.bottom);
  72. this.dom.root.appendChild(this.dom.rollingModeBtn);
  73. this.dom.centerContainer.appendChild(this.dom.center);
  74. this.dom.leftContainer.appendChild(this.dom.left);
  75. this.dom.rightContainer.appendChild(this.dom.right);
  76. this.dom.centerContainer.appendChild(this.dom.shadowTop);
  77. this.dom.centerContainer.appendChild(this.dom.shadowBottom);
  78. this.dom.leftContainer.appendChild(this.dom.shadowTopLeft);
  79. this.dom.leftContainer.appendChild(this.dom.shadowBottomLeft);
  80. this.dom.rightContainer.appendChild(this.dom.shadowTopRight);
  81. this.dom.rightContainer.appendChild(this.dom.shadowBottomRight);
  82. // size properties of each of the panels
  83. this.props = {
  84. root: {},
  85. background: {},
  86. centerContainer: {},
  87. leftContainer: {},
  88. rightContainer: {},
  89. center: {},
  90. left: {},
  91. right: {},
  92. top: {},
  93. bottom: {},
  94. border: {},
  95. scrollTop: 0,
  96. scrollTopMin: 0
  97. };
  98. this.on('rangechange', function () {
  99. if (this.initialDrawDone === true) {
  100. this._redraw();
  101. }
  102. }.bind(this));
  103. this.on('rangechanged', function () {
  104. if (!this.initialRangeChangeDone) {
  105. this.initialRangeChangeDone = true;
  106. }
  107. }.bind(this));
  108. this.on('touch', this._onTouch.bind(this));
  109. this.on('panmove', this._onDrag.bind(this));
  110. var me = this;
  111. this._origRedraw = this._redraw.bind(this);
  112. this._redraw = util.throttle(this._origRedraw);
  113. this.on('_change', function (properties) {
  114. if (me.itemSet && me.itemSet.initialItemSetDrawn && properties && properties.queue == true) {
  115. me._redraw()
  116. } else {
  117. me._origRedraw();
  118. }
  119. });
  120. // create event listeners for all interesting events, these events will be
  121. // emitted via emitter
  122. this.hammer = new Hammer(this.dom.root);
  123. var pinchRecognizer = this.hammer.get('pinch').set({enable: true});
  124. hammerUtil.disablePreventDefaultVertically(pinchRecognizer);
  125. this.hammer.get('pan').set({threshold:5, direction: Hammer.DIRECTION_HORIZONTAL});
  126. this.listeners = {};
  127. var events = [
  128. 'tap', 'doubletap', 'press',
  129. 'pinch',
  130. 'pan', 'panstart', 'panmove', 'panend'
  131. // TODO: cleanup
  132. //'touch', 'pinch',
  133. //'tap', 'doubletap', 'hold',
  134. //'dragstart', 'drag', 'dragend',
  135. //'mousewheel', 'DOMMouseScroll' // DOMMouseScroll is needed for Firefox
  136. ];
  137. events.forEach(function (type) {
  138. var listener = function (event) {
  139. if (me.isActive()) {
  140. me.emit(type, event);
  141. }
  142. };
  143. me.hammer.on(type, listener);
  144. me.listeners[type] = listener;
  145. });
  146. // emulate a touch event (emitted before the start of a pan, pinch, tap, or press)
  147. hammerUtil.onTouch(this.hammer, function (event) {
  148. me.emit('touch', event);
  149. }.bind(this));
  150. // emulate a release event (emitted after a pan, pinch, tap, or press)
  151. hammerUtil.onRelease(this.hammer, function (event) {
  152. me.emit('release', event);
  153. }.bind(this));
  154. /**
  155. *
  156. * @param {WheelEvent} event
  157. */
  158. function onMouseWheel(event) {
  159. if (this.isActive()) {
  160. this.emit('mousewheel', event);
  161. }
  162. // deltaX and deltaY normalization from jquery.mousewheel.js
  163. var deltaX = 0;
  164. var deltaY = 0;
  165. // Old school scrollwheel delta
  166. if ( 'detail' in event ) { deltaY = event.detail * -1; }
  167. if ( 'wheelDelta' in event ) { deltaY = event.wheelDelta; }
  168. if ( 'wheelDeltaY' in event ) { deltaY = event.wheelDeltaY; }
  169. if ( 'wheelDeltaX' in event ) { deltaX = event.wheelDeltaX * -1; }
  170. // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
  171. if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {
  172. deltaX = deltaY * -1;
  173. deltaY = 0;
  174. }
  175. // New school wheel delta (wheel event)
  176. if ( 'deltaY' in event ) {
  177. deltaY = event.deltaY * -1;
  178. }
  179. if ( 'deltaX' in event ) {
  180. deltaX = event.deltaX;
  181. }
  182. // prevent scrolling when zoomKey defined or activated
  183. if (!this.options.zoomKey || event[this.options.zoomKey]) return;
  184. // Prevent default actions caused by mouse wheel
  185. // (else the page and timeline both scroll)
  186. event.preventDefault();
  187. if (this.options.verticalScroll && Math.abs(deltaY) >= Math.abs(deltaX)) {
  188. var current = this.props.scrollTop;
  189. var adjusted = current + deltaY;
  190. if (this.isActive()) {
  191. this._setScrollTop(adjusted);
  192. this._redraw();
  193. this.emit('scroll', event);
  194. }
  195. } else if (this.options.horizontalScroll) {
  196. var delta = Math.abs(deltaX) >= Math.abs(deltaY) ? deltaX : deltaY;
  197. // calculate a single scroll jump relative to the range scale
  198. var diff = (delta / 120) * (this.range.end - this.range.start) / 20;
  199. // calculate new start and end
  200. var newStart = this.range.start + diff;
  201. var newEnd = this.range.end + diff;
  202. var options = {
  203. animation: false,
  204. byUser: true,
  205. event: event
  206. };
  207. this.range.setRange(newStart, newEnd, options);
  208. }
  209. }
  210. if (this.dom.centerContainer.addEventListener) {
  211. // IE9, Chrome, Safari, Opera
  212. this.dom.centerContainer.addEventListener("mousewheel", onMouseWheel.bind(this), false);
  213. // Firefox
  214. this.dom.centerContainer.addEventListener("DOMMouseScroll", onMouseWheel.bind(this), false);
  215. } else {
  216. // IE 6/7/8
  217. this.dom.centerContainer.attachEvent("onmousewheel", onMouseWheel.bind(this));
  218. }
  219. /**
  220. *
  221. * @param {scroll} event
  222. */
  223. function onMouseScrollSide(event) {
  224. if (!me.options.verticalScroll) return;
  225. event.preventDefault();
  226. if (me.isActive()) {
  227. var adjusted = -event.target.scrollTop;
  228. me._setScrollTop(adjusted);
  229. me._redraw();
  230. me.emit('scrollSide', event);
  231. }
  232. }
  233. this.dom.left.parentNode.addEventListener('scroll', onMouseScrollSide.bind(this));
  234. this.dom.right.parentNode.addEventListener('scroll', onMouseScrollSide.bind(this));
  235. var itemAddedToTimeline = false;
  236. /**
  237. *
  238. * @param {dragover} event
  239. * @returns {boolean}
  240. */
  241. function handleDragOver(event) {
  242. if (event.preventDefault) {
  243. event.preventDefault(); // Necessary. Allows us to drop.
  244. }
  245. // make sure your target is a vis element
  246. if (!event.target.className.indexOf("vis") > -1) return;
  247. // make sure only one item is added every time you're over the timeline
  248. if (itemAddedToTimeline) return;
  249. event.dataTransfer.dropEffect = 'move';
  250. itemAddedToTimeline = true;
  251. return false;
  252. }
  253. /**
  254. *
  255. * @param {drop} event
  256. * @returns {boolean}
  257. */
  258. function handleDrop(event) {
  259. // prevent redirect to blank page - Firefox
  260. if(event.preventDefault) { event.preventDefault(); }
  261. if(event.stopPropagation) { event.stopPropagation(); }
  262. // return when dropping non-vis items
  263. try {
  264. var itemData = JSON.parse(event.dataTransfer.getData("text"))
  265. if (!itemData || !itemData.content) return
  266. } catch (err) {
  267. return false;
  268. }
  269. itemAddedToTimeline = false;
  270. event.center = {
  271. x: event.clientX,
  272. y: event.clientY
  273. };
  274. if (itemData.target !== 'item') {
  275. me.itemSet._onAddItem(event);
  276. } else {
  277. me.itemSet._onDropObjectOnItem(event);
  278. }
  279. me.emit('drop', me.getEventProperties(event))
  280. return false;
  281. }
  282. this.dom.center.addEventListener('dragover', handleDragOver.bind(this), false);
  283. this.dom.center.addEventListener('drop', handleDrop.bind(this), false);
  284. this.customTimes = [];
  285. // store state information needed for touch events
  286. this.touch = {};
  287. this.redrawCount = 0;
  288. this.initialDrawDone = false;
  289. this.initialRangeChangeDone = false;
  290. // attach the root panel to the provided container
  291. if (!container) throw new Error('No container provided');
  292. container.appendChild(this.dom.root);
  293. };
  294. /**
  295. * Set options. Options will be passed to all components loaded in the Timeline.
  296. * @param {Object} [options]
  297. * {String} orientation
  298. * Vertical orientation for the Timeline,
  299. * can be 'bottom' (default) or 'top'.
  300. * {string | number} width
  301. * Width for the timeline, a number in pixels or
  302. * a css string like '1000px' or '75%'. '100%' by default.
  303. * {string | number} height
  304. * Fixed height for the Timeline, a number in pixels or
  305. * a css string like '400px' or '75%'. If undefined,
  306. * The Timeline will automatically size such that
  307. * its contents fit.
  308. * {string | number} minHeight
  309. * Minimum height for the Timeline, a number in pixels or
  310. * a css string like '400px' or '75%'.
  311. * {string | number} maxHeight
  312. * Maximum height for the Timeline, a number in pixels or
  313. * a css string like '400px' or '75%'.
  314. * {number | Date | string} start
  315. * Start date for the visible window
  316. * {number | Date | string} end
  317. * End date for the visible window
  318. */
  319. Core.prototype.setOptions = function (options) {
  320. if (options) {
  321. // copy the known options
  322. var fields = [
  323. 'width', 'height', 'minHeight', 'maxHeight', 'autoResize',
  324. 'start', 'end', 'clickToUse', 'dataAttributes', 'hiddenDates',
  325. 'locale', 'locales', 'moment', 'rtl', 'zoomKey', 'horizontalScroll', 'verticalScroll'
  326. ];
  327. util.selectiveExtend(fields, this.options, options);
  328. this.dom.rollingModeBtn.style.visibility = 'hidden';
  329. if (this.options.rtl) {
  330. this.dom.container.style.direction = "rtl";
  331. this.dom.backgroundVertical.className = 'vis-panel vis-background vis-vertical-rtl';
  332. }
  333. if (this.options.verticalScroll) {
  334. if (this.options.rtl) {
  335. this.dom.rightContainer.className = 'vis-panel vis-right vis-vertical-scroll';
  336. } else {
  337. this.dom.leftContainer.className = 'vis-panel vis-left vis-vertical-scroll';
  338. }
  339. }
  340. if (typeof this.options.orientation !== 'object') {
  341. this.options.orientation = {item:undefined,axis:undefined};
  342. }
  343. if ('orientation' in options) {
  344. if (typeof options.orientation === 'string') {
  345. this.options.orientation = {
  346. item: options.orientation,
  347. axis: options.orientation
  348. };
  349. }
  350. else if (typeof options.orientation === 'object') {
  351. if ('item' in options.orientation) {
  352. this.options.orientation.item = options.orientation.item;
  353. }
  354. if ('axis' in options.orientation) {
  355. this.options.orientation.axis = options.orientation.axis;
  356. }
  357. }
  358. }
  359. if (this.options.orientation.axis === 'both') {
  360. if (!this.timeAxis2) {
  361. var timeAxis2 = this.timeAxis2 = new TimeAxis(this.body);
  362. timeAxis2.setOptions = function (options) {
  363. var _options = options ? util.extend({}, options) : {};
  364. _options.orientation = 'top'; // override the orientation option, always top
  365. TimeAxis.prototype.setOptions.call(timeAxis2, _options);
  366. };
  367. this.components.push(timeAxis2);
  368. }
  369. }
  370. else {
  371. if (this.timeAxis2) {
  372. var index = this.components.indexOf(this.timeAxis2);
  373. if (index !== -1) {
  374. this.components.splice(index, 1);
  375. }
  376. this.timeAxis2.destroy();
  377. this.timeAxis2 = null;
  378. }
  379. }
  380. // if the graph2d's drawPoints is a function delegate the callback to the onRender property
  381. if (typeof options.drawPoints == 'function') {
  382. options.drawPoints = {
  383. onRender: options.drawPoints
  384. };
  385. }
  386. if ('hiddenDates' in this.options) {
  387. DateUtil.convertHiddenOptions(this.options.moment, this.body, this.options.hiddenDates);
  388. }
  389. if ('clickToUse' in options) {
  390. if (options.clickToUse) {
  391. if (!this.activator) {
  392. this.activator = new Activator(this.dom.root);
  393. }
  394. }
  395. else {
  396. if (this.activator) {
  397. this.activator.destroy();
  398. delete this.activator;
  399. }
  400. }
  401. }
  402. if ('showCustomTime' in options) {
  403. throw new Error('Option `showCustomTime` is deprecated. Create a custom time bar via timeline.addCustomTime(time [, id])');
  404. }
  405. // enable/disable autoResize
  406. this._initAutoResize();
  407. }
  408. // propagate options to all components
  409. this.components.forEach(component => component.setOptions(options));
  410. // enable/disable configure
  411. if ('configure' in options) {
  412. if (!this.configurator) {
  413. this.configurator = this._createConfigurator();
  414. }
  415. this.configurator.setOptions(options.configure);
  416. // collect the settings of all components, and pass them to the configuration system
  417. var appliedOptions = util.deepExtend({}, this.options);
  418. this.components.forEach(function (component) {
  419. util.deepExtend(appliedOptions, component.options);
  420. });
  421. this.configurator.setModuleOptions({global: appliedOptions});
  422. }
  423. this._redraw();
  424. };
  425. /**
  426. * Returns true when the Timeline is active.
  427. * @returns {boolean}
  428. */
  429. Core.prototype.isActive = function () {
  430. return !this.activator || this.activator.active;
  431. };
  432. /**
  433. * Destroy the Core, clean up all DOM elements and event listeners.
  434. */
  435. Core.prototype.destroy = function () {
  436. // unbind datasets
  437. this.setItems(null);
  438. this.setGroups(null);
  439. // remove all event listeners
  440. this.off();
  441. // stop checking for changed size
  442. this._stopAutoResize();
  443. // remove from DOM
  444. if (this.dom.root.parentNode) {
  445. this.dom.root.parentNode.removeChild(this.dom.root);
  446. }
  447. this.dom = null;
  448. // remove Activator
  449. if (this.activator) {
  450. this.activator.destroy();
  451. delete this.activator;
  452. }
  453. // cleanup hammer touch events
  454. for (var event in this.listeners) {
  455. if (this.listeners.hasOwnProperty(event)) {
  456. delete this.listeners[event];
  457. }
  458. }
  459. this.listeners = null;
  460. this.hammer = null;
  461. // give all components the opportunity to cleanup
  462. this.components.forEach(component => component.destroy());
  463. this.body = null;
  464. };
  465. /**
  466. * Set a custom time bar
  467. * @param {Date} time
  468. * @param {number} [id=undefined] Optional id of the custom time bar to be adjusted.
  469. */
  470. Core.prototype.setCustomTime = function (time, id) {
  471. var customTimes = this.customTimes.filter(function (component) {
  472. return id === component.options.id;
  473. });
  474. if (customTimes.length === 0) {
  475. throw new Error('No custom time bar found with id ' + JSON.stringify(id))
  476. }
  477. if (customTimes.length > 0) {
  478. customTimes[0].setCustomTime(time);
  479. }
  480. };
  481. /**
  482. * Retrieve the current custom time.
  483. * @param {number} [id=undefined] Id of the custom time bar.
  484. * @return {Date | undefined} customTime
  485. */
  486. Core.prototype.getCustomTime = function(id) {
  487. var customTimes = this.customTimes.filter(function (component) {
  488. return component.options.id === id;
  489. });
  490. if (customTimes.length === 0) {
  491. throw new Error('No custom time bar found with id ' + JSON.stringify(id))
  492. }
  493. return customTimes[0].getCustomTime();
  494. };
  495. /**
  496. * Set a custom title for the custom time bar.
  497. * @param {string} [title] Custom title
  498. * @param {number} [id=undefined] Id of the custom time bar.
  499. * @returns {*}
  500. */
  501. Core.prototype.setCustomTimeTitle = function(title, id) {
  502. var customTimes = this.customTimes.filter(function (component) {
  503. return component.options.id === id;
  504. });
  505. if (customTimes.length === 0) {
  506. throw new Error('No custom time bar found with id ' + JSON.stringify(id))
  507. }
  508. if (customTimes.length > 0) {
  509. return customTimes[0].setCustomTitle(title);
  510. }
  511. };
  512. /**
  513. * Retrieve meta information from an event.
  514. * Should be overridden by classes extending Core
  515. * @param {Event} event
  516. * @return {Object} An object with related information.
  517. */
  518. Core.prototype.getEventProperties = function (event) {
  519. return { event: event };
  520. };
  521. /**
  522. * Add custom vertical bar
  523. * @param {Date | string | number} [time] A Date, unix timestamp, or
  524. * ISO date string. Time point where
  525. * the new bar should be placed.
  526. * If not provided, `new Date()` will
  527. * be used.
  528. * @param {number | string} [id=undefined] Id of the new bar. Optional
  529. * @return {number | string} Returns the id of the new bar
  530. */
  531. Core.prototype.addCustomTime = function (time, id) {
  532. var timestamp = time !== undefined
  533. ? util.convert(time, 'Date').valueOf()
  534. : new Date();
  535. var exists = this.customTimes.some(function (customTime) {
  536. return customTime.options.id === id;
  537. });
  538. if (exists) {
  539. throw new Error('A custom time with id ' + JSON.stringify(id) + ' already exists');
  540. }
  541. var customTime = new CustomTime(this.body, util.extend({}, this.options, {
  542. time : timestamp,
  543. id : id
  544. }));
  545. this.customTimes.push(customTime);
  546. this.components.push(customTime);
  547. this._redraw();
  548. return id;
  549. };
  550. /**
  551. * Remove previously added custom bar
  552. * @param {int} id ID of the custom bar to be removed
  553. * [at]returns {boolean} True if the bar exists and is removed, false otherwise
  554. */
  555. Core.prototype.removeCustomTime = function (id) {
  556. var customTimes = this.customTimes.filter(function (bar) {
  557. return (bar.options.id === id);
  558. });
  559. if (customTimes.length === 0) {
  560. throw new Error('No custom time bar found with id ' + JSON.stringify(id))
  561. }
  562. customTimes.forEach(function (customTime) {
  563. this.customTimes.splice(this.customTimes.indexOf(customTime), 1);
  564. this.components.splice(this.components.indexOf(customTime), 1);
  565. customTime.destroy();
  566. }.bind(this))
  567. };
  568. /**
  569. * Get the id's of the currently visible items.
  570. * @returns {Array} The ids of the visible items
  571. */
  572. Core.prototype.getVisibleItems = function() {
  573. return this.itemSet && this.itemSet.getVisibleItems() || [];
  574. };
  575. /**
  576. * Set Core window such that it fits all items
  577. * @param {Object} [options] Available options:
  578. * `animation: boolean | {duration: number, easingFunction: string}`
  579. * If true (default), the range is animated
  580. * smoothly to the new window. An object can be
  581. * provided to specify duration and easing function.
  582. * Default duration is 500 ms, and default easing
  583. * function is 'easeInOutQuad'.
  584. * @param {function} [callback] a callback funtion to be executed at the end of this function
  585. */
  586. Core.prototype.fit = function(options, callback) {
  587. var range = this.getDataRange();
  588. // skip range set if there is no min and max date
  589. if (range.min === null && range.max === null) {
  590. return;
  591. }
  592. // apply a margin of 1% left and right of the data
  593. var interval = range.max - range.min;
  594. var min = new Date(range.min.valueOf() - interval * 0.01);
  595. var max = new Date(range.max.valueOf() + interval * 0.01);
  596. var animation = (options && options.animation !== undefined) ? options.animation : true;
  597. this.range.setRange(min, max, { animation: animation }, callback);
  598. };
  599. /**
  600. * Calculate the data range of the items start and end dates
  601. * [at]returns {{min: [Date], max: [Date]}}
  602. * @protected
  603. */
  604. Core.prototype.getDataRange = function() {
  605. // must be implemented by Timeline and Graph2d
  606. throw new Error('Cannot invoke abstract method getDataRange');
  607. };
  608. /**
  609. * Set the visible window. Both parameters are optional, you can change only
  610. * start or only end. Syntax:
  611. *
  612. * TimeLine.setWindow(start, end)
  613. * TimeLine.setWindow(start, end, options)
  614. * TimeLine.setWindow(range)
  615. *
  616. * Where start and end can be a Date, number, or string, and range is an
  617. * object with properties start and end.
  618. *
  619. * @param {Date | number | string | Object} [start] Start date of visible window
  620. * @param {Date | number | string} [end] End date of visible window
  621. * @param {Object} [options] Available options:
  622. * `animation: boolean | {duration: number, easingFunction: string}`
  623. * If true (default), the range is animated
  624. * smoothly to the new window. An object can be
  625. * provided to specify duration and easing function.
  626. * Default duration is 500 ms, and default easing
  627. * function is 'easeInOutQuad'.
  628. * @param {function} [callback] a callback funtion to be executed at the end of this function
  629. */
  630. Core.prototype.setWindow = function(start, end, options, callback) {
  631. if (typeof arguments[2] == "function") {
  632. callback = arguments[2];
  633. options = {};
  634. }
  635. var animation;
  636. var range;
  637. if (arguments.length == 1) {
  638. range = arguments[0];
  639. animation = (range.animation !== undefined) ? range.animation : true;
  640. this.range.setRange(range.start, range.end, { animation: animation });
  641. }
  642. else if (arguments.length == 2 && typeof arguments[1] == "function") {
  643. range = arguments[0];
  644. callback = arguments[1];
  645. animation = (range.animation !== undefined) ? range.animation : true;
  646. this.range.setRange(range.start, range.end, { animation: animation }, callback);
  647. }
  648. else {
  649. animation = (options && options.animation !== undefined) ? options.animation : true;
  650. this.range.setRange(start, end, { animation: animation }, callback);
  651. }
  652. };
  653. /**
  654. * Move the window such that given time is centered on screen.
  655. * @param {Date | number | string} time
  656. * @param {Object} [options] Available options:
  657. * `animation: boolean | {duration: number, easingFunction: string}`
  658. * If true (default), the range is animated
  659. * smoothly to the new window. An object can be
  660. * provided to specify duration and easing function.
  661. * Default duration is 500 ms, and default easing
  662. * function is 'easeInOutQuad'.
  663. * @param {function} [callback] a callback funtion to be executed at the end of this function
  664. */
  665. Core.prototype.moveTo = function(time, options, callback) {
  666. if (typeof arguments[1] == "function") {
  667. callback = arguments[1];
  668. options = {};
  669. }
  670. var interval = this.range.end - this.range.start;
  671. var t = util.convert(time, 'Date').valueOf();
  672. var start = t - interval / 2;
  673. var end = t + interval / 2;
  674. var animation = (options && options.animation !== undefined) ? options.animation : true;
  675. this.range.setRange(start, end, { animation: animation }, callback);
  676. };
  677. /**
  678. * Get the visible window
  679. * @return {{start: Date, end: Date}} Visible range
  680. */
  681. Core.prototype.getWindow = function() {
  682. var range = this.range.getRange();
  683. return {
  684. start: new Date(range.start),
  685. end: new Date(range.end)
  686. };
  687. };
  688. /**
  689. * Zoom in the window such that given time is centered on screen.
  690. * @param {number} percentage - must be between [0..1]
  691. * @param {Object} [options] Available options:
  692. * `animation: boolean | {duration: number, easingFunction: string}`
  693. * If true (default), the range is animated
  694. * smoothly to the new window. An object can be
  695. * provided to specify duration and easing function.
  696. * Default duration is 500 ms, and default easing
  697. * function is 'easeInOutQuad'.
  698. * @param {function} [callback] a callback funtion to be executed at the end of this function
  699. */
  700. Core.prototype.zoomIn = function(percentage, options, callback) {
  701. if (!percentage || percentage < 0 || percentage > 1) return;
  702. if (typeof arguments[1] == "function") {
  703. callback = arguments[1];
  704. options = {};
  705. }
  706. var range = this.getWindow();
  707. var start = range.start.valueOf();
  708. var end = range.end.valueOf();
  709. var interval = end - start;
  710. var newInterval = interval / (1 + percentage);
  711. var distance = (interval - newInterval) / 2;
  712. var newStart = start + distance;
  713. var newEnd = end - distance;
  714. this.setWindow(newStart, newEnd, options, callback);
  715. };
  716. /**
  717. * Zoom out the window such that given time is centered on screen.
  718. * @param {number} percentage - must be between [0..1]
  719. * @param {Object} [options] Available options:
  720. * `animation: boolean | {duration: number, easingFunction: string}`
  721. * If true (default), the range is animated
  722. * smoothly to the new window. An object can be
  723. * provided to specify duration and easing function.
  724. * Default duration is 500 ms, and default easing
  725. * function is 'easeInOutQuad'.
  726. * @param {function} [callback] a callback funtion to be executed at the end of this function
  727. */
  728. Core.prototype.zoomOut = function(percentage, options, callback) {
  729. if (!percentage || percentage < 0 || percentage > 1) return
  730. if (typeof arguments[1] == "function") {
  731. callback = arguments[1];
  732. options = {};
  733. }
  734. var range = this.getWindow();
  735. var start = range.start.valueOf();
  736. var end = range.end.valueOf();
  737. var interval = end - start;
  738. var newStart = start - interval * percentage / 2;
  739. var newEnd = end + interval * percentage / 2;
  740. this.setWindow(newStart, newEnd, options, callback);
  741. };
  742. /**
  743. * Force a redraw. Can be overridden by implementations of Core
  744. *
  745. * Note: this function will be overridden on construction with a trottled version
  746. */
  747. Core.prototype.redraw = function() {
  748. this._redraw();
  749. };
  750. /**
  751. * Redraw for internal use. Redraws all components. See also the public
  752. * method redraw.
  753. * @protected
  754. */
  755. Core.prototype._redraw = function() {
  756. this.redrawCount++;
  757. var resized = false;
  758. var options = this.options;
  759. var props = this.props;
  760. var dom = this.dom;
  761. if (!dom || !dom.container || dom.root.offsetWidth == 0) return; // when destroyed, or invisible
  762. DateUtil.updateHiddenDates(this.options.moment, this.body, this.options.hiddenDates);
  763. // update class names
  764. if (options.orientation == 'top') {
  765. util.addClassName(dom.root, 'vis-top');
  766. util.removeClassName(dom.root, 'vis-bottom');
  767. }
  768. else {
  769. util.removeClassName(dom.root, 'vis-top');
  770. util.addClassName(dom.root, 'vis-bottom');
  771. }
  772. // update root width and height options
  773. dom.root.style.maxHeight = util.option.asSize(options.maxHeight, '');
  774. dom.root.style.minHeight = util.option.asSize(options.minHeight, '');
  775. dom.root.style.width = util.option.asSize(options.width, '');
  776. // calculate border widths
  777. props.border.left = (dom.centerContainer.offsetWidth - dom.centerContainer.clientWidth) / 2;
  778. props.border.right = props.border.left;
  779. props.border.top = (dom.centerContainer.offsetHeight - dom.centerContainer.clientHeight) / 2;
  780. props.border.bottom = props.border.top;
  781. props.borderRootHeight= dom.root.offsetHeight - dom.root.clientHeight;
  782. props.borderRootWidth = dom.root.offsetWidth - dom.root.clientWidth;
  783. // workaround for a bug in IE: the clientWidth of an element with
  784. // a height:0px and overflow:hidden is not calculated and always has value 0
  785. if (dom.centerContainer.clientHeight === 0) {
  786. props.border.left = props.border.top;
  787. props.border.right = props.border.left;
  788. }
  789. if (dom.root.clientHeight === 0) {
  790. props.borderRootWidth = props.borderRootHeight;
  791. }
  792. // calculate the heights. If any of the side panels is empty, we set the height to
  793. // minus the border width, such that the border will be invisible
  794. props.center.height = dom.center.offsetHeight;
  795. props.left.height = dom.left.offsetHeight;
  796. props.right.height = dom.right.offsetHeight;
  797. props.top.height = dom.top.clientHeight || -props.border.top;
  798. props.bottom.height = dom.bottom.clientHeight || -props.border.bottom;
  799. // TODO: compensate borders when any of the panels is empty.
  800. // apply auto height
  801. // TODO: only calculate autoHeight when needed (else we cause an extra reflow/repaint of the DOM)
  802. var contentHeight = Math.max(props.left.height, props.center.height, props.right.height);
  803. var autoHeight = props.top.height + contentHeight + props.bottom.height +
  804. props.borderRootHeight + props.border.top + props.border.bottom;
  805. dom.root.style.height = util.option.asSize(options.height, autoHeight + 'px');
  806. // calculate heights of the content panels
  807. props.root.height = dom.root.offsetHeight;
  808. props.background.height = props.root.height - props.borderRootHeight;
  809. var containerHeight = props.root.height - props.top.height - props.bottom.height -
  810. props.borderRootHeight;
  811. props.centerContainer.height = containerHeight;
  812. props.leftContainer.height = containerHeight;
  813. props.rightContainer.height = props.leftContainer.height;
  814. // calculate the widths of the panels
  815. props.root.width = dom.root.offsetWidth;
  816. props.background.width = props.root.width - props.borderRootWidth;
  817. if (!this.initialDrawDone) {
  818. props.scrollbarWidth = util.getScrollBarWidth();
  819. }
  820. if (options.verticalScroll) {
  821. if (options.rtl) {
  822. props.left.width = dom.leftContainer.clientWidth || -props.border.left;
  823. props.right.width = dom.rightContainer.clientWidth + props.scrollbarWidth || -props.border.right;
  824. } else {
  825. props.left.width = dom.leftContainer.clientWidth + props.scrollbarWidth || -props.border.left;
  826. props.right.width = dom.rightContainer.clientWidth || -props.border.right;
  827. }
  828. } else {
  829. props.left.width = dom.leftContainer.clientWidth || -props.border.left;
  830. props.right.width = dom.rightContainer.clientWidth || -props.border.right;
  831. }
  832. this._setDOM();
  833. // update the scrollTop, feasible range for the offset can be changed
  834. // when the height of the Core or of the contents of the center changed
  835. var offset = this._updateScrollTop();
  836. // reposition the scrollable contents
  837. if (options.orientation.item != 'top') {
  838. offset += Math.max(props.centerContainer.height - props.center.height -
  839. props.border.top - props.border.bottom, 0);
  840. }
  841. dom.center.style.top = offset + 'px';
  842. // show shadows when vertical scrolling is available
  843. var visibilityTop = props.scrollTop == 0 ? 'hidden' : '';
  844. var visibilityBottom = props.scrollTop == props.scrollTopMin ? 'hidden' : '';
  845. dom.shadowTop.style.visibility = visibilityTop;
  846. dom.shadowBottom.style.visibility = visibilityBottom;
  847. dom.shadowTopLeft.style.visibility = visibilityTop;
  848. dom.shadowBottomLeft.style.visibility = visibilityBottom;
  849. dom.shadowTopRight.style.visibility = visibilityTop;
  850. dom.shadowBottomRight.style.visibility = visibilityBottom;
  851. if (options.verticalScroll) {
  852. dom.rightContainer.className = 'vis-panel vis-right vis-vertical-scroll';
  853. dom.leftContainer.className = 'vis-panel vis-left vis-vertical-scroll';
  854. dom.shadowTopRight.style.visibility = "hidden";
  855. dom.shadowBottomRight.style.visibility = "hidden";
  856. dom.shadowTopLeft.style.visibility = "hidden";
  857. dom.shadowBottomLeft.style.visibility = "hidden";
  858. dom.left.style.top = '0px';
  859. dom.right.style.top = '0px';
  860. }
  861. if (!options.verticalScroll || props.center.height < props.centerContainer.height) {
  862. dom.left.style.top = offset + 'px';
  863. dom.right.style.top = offset + 'px';
  864. dom.rightContainer.className = dom.rightContainer.className.replace(new RegExp('(?:^|\\s)'+ 'vis-vertical-scroll' + '(?:\\s|$)'), ' ');
  865. dom.leftContainer.className = dom.leftContainer.className.replace(new RegExp('(?:^|\\s)'+ 'vis-vertical-scroll' + '(?:\\s|$)'), ' ');
  866. props.left.width = dom.leftContainer.clientWidth || -props.border.left;
  867. props.right.width = dom.rightContainer.clientWidth || -props.border.right;
  868. this._setDOM();
  869. }
  870. // enable/disable vertical panning
  871. var contentsOverflow = props.center.height > props.centerContainer.height;
  872. this.hammer.get('pan').set({
  873. direction: contentsOverflow ? Hammer.DIRECTION_ALL : Hammer.DIRECTION_HORIZONTAL
  874. });
  875. // redraw all components
  876. this.components.forEach(function (component) {
  877. resized = component.redraw() || resized;
  878. });
  879. var MAX_REDRAW = 5;
  880. if (resized) {
  881. if (this.redrawCount < MAX_REDRAW) {
  882. this.body.emitter.emit('_change');
  883. return;
  884. }
  885. else {
  886. console.log('WARNING: infinite loop in redraw?');
  887. }
  888. } else {
  889. this.redrawCount = 0;
  890. }
  891. //Emit public 'changed' event for UI updates, see issue #1592
  892. this.body.emitter.emit("changed");
  893. };
  894. Core.prototype._setDOM = function () {
  895. var props = this.props;
  896. var dom = this.dom;
  897. props.leftContainer.width = props.left.width;
  898. props.rightContainer.width = props.right.width;
  899. var centerWidth = props.root.width - props.left.width - props.right.width - props.borderRootWidth;
  900. props.center.width = centerWidth;
  901. props.centerContainer.width = centerWidth;
  902. props.top.width = centerWidth;
  903. props.bottom.width = centerWidth;
  904. // resize the panels
  905. dom.background.style.height = props.background.height + 'px';
  906. dom.backgroundVertical.style.height = props.background.height + 'px';
  907. dom.backgroundHorizontal.style.height = props.centerContainer.height + 'px';
  908. dom.centerContainer.style.height = props.centerContainer.height + 'px';
  909. dom.leftContainer.style.height = props.leftContainer.height + 'px';
  910. dom.rightContainer.style.height = props.rightContainer.height + 'px';
  911. dom.background.style.width = props.background.width + 'px';
  912. dom.backgroundVertical.style.width = props.centerContainer.width + 'px';
  913. dom.backgroundHorizontal.style.width = props.background.width + 'px';
  914. dom.centerContainer.style.width = props.center.width + 'px';
  915. dom.top.style.width = props.top.width + 'px';
  916. dom.bottom.style.width = props.bottom.width + 'px';
  917. // reposition the panels
  918. dom.background.style.left = '0';
  919. dom.background.style.top = '0';
  920. dom.backgroundVertical.style.left = (props.left.width + props.border.left) + 'px';
  921. dom.backgroundVertical.style.top = '0';
  922. dom.backgroundHorizontal.style.left = '0';
  923. dom.backgroundHorizontal.style.top = props.top.height + 'px';
  924. dom.centerContainer.style.left = props.left.width + 'px';
  925. dom.centerContainer.style.top = props.top.height + 'px';
  926. dom.leftContainer.style.left = '0';
  927. dom.leftContainer.style.top = props.top.height + 'px';
  928. dom.rightContainer.style.left = (props.left.width + props.center.width) + 'px';
  929. dom.rightContainer.style.top = props.top.height + 'px';
  930. dom.top.style.left = props.left.width + 'px';
  931. dom.top.style.top = '0';
  932. dom.bottom.style.left = props.left.width + 'px';
  933. dom.bottom.style.top = (props.top.height + props.centerContainer.height) + 'px';
  934. dom.center.style.left = '0';
  935. dom.left.style.left = '0';
  936. dom.right.style.left = '0';
  937. };
  938. // TODO: deprecated since version 1.1.0, remove some day
  939. Core.prototype.repaint = function () {
  940. throw new Error('Function repaint is deprecated. Use redraw instead.');
  941. };
  942. /**
  943. * Set a current time. This can be used for example to ensure that a client's
  944. * time is synchronized with a shared server time.
  945. * Only applicable when option `showCurrentTime` is true.
  946. * @param {Date | string | number} time A Date, unix timestamp, or
  947. * ISO date string.
  948. */
  949. Core.prototype.setCurrentTime = function(time) {
  950. if (!this.currentTime) {
  951. throw new Error('Option showCurrentTime must be true');
  952. }
  953. this.currentTime.setCurrentTime(time);
  954. };
  955. /**
  956. * Get the current time.
  957. * Only applicable when option `showCurrentTime` is true.
  958. * @return {Date} Returns the current time.
  959. */
  960. Core.prototype.getCurrentTime = function() {
  961. if (!this.currentTime) {
  962. throw new Error('Option showCurrentTime must be true');
  963. }
  964. return this.currentTime.getCurrentTime();
  965. };
  966. /**
  967. * Convert a position on screen (pixels) to a datetime
  968. * @param {int} x Position on the screen in pixels
  969. * @return {Date} time The datetime the corresponds with given position x
  970. * @protected
  971. */
  972. // TODO: move this function to Range
  973. Core.prototype._toTime = function(x) {
  974. return DateUtil.toTime(this, x, this.props.center.width);
  975. };
  976. /**
  977. * Convert a position on the global screen (pixels) to a datetime
  978. * @param {int} x Position on the screen in pixels
  979. * @return {Date} time The datetime the corresponds with given position x
  980. * @protected
  981. */
  982. // TODO: move this function to Range
  983. Core.prototype._toGlobalTime = function(x) {
  984. return DateUtil.toTime(this, x, this.props.root.width);
  985. //var conversion = this.range.conversion(this.props.root.width);
  986. //return new Date(x / conversion.scale + conversion.offset);
  987. };
  988. /**
  989. * Convert a datetime (Date object) into a position on the screen
  990. * @param {Date} time A date
  991. * @return {int} x The position on the screen in pixels which corresponds
  992. * with the given date.
  993. * @protected
  994. */
  995. // TODO: move this function to Range
  996. Core.prototype._toScreen = function(time) {
  997. return DateUtil.toScreen(this, time, this.props.center.width);
  998. };
  999. /**
  1000. * Convert a datetime (Date object) into a position on the root
  1001. * This is used to get the pixel density estimate for the screen, not the center panel
  1002. * @param {Date} time A date
  1003. * @return {int} x The position on root in pixels which corresponds
  1004. * with the given date.
  1005. * @protected
  1006. */
  1007. // TODO: move this function to Range
  1008. Core.prototype._toGlobalScreen = function(time) {
  1009. return DateUtil.toScreen(this, time, this.props.root.width);
  1010. //var conversion = this.range.conversion(this.props.root.width);
  1011. //return (time.valueOf() - conversion.offset) * conversion.scale;
  1012. };
  1013. /**
  1014. * Initialize watching when option autoResize is true
  1015. * @private
  1016. */
  1017. Core.prototype._initAutoResize = function () {
  1018. if (this.options.autoResize == true) {
  1019. this._startAutoResize();
  1020. }
  1021. else {
  1022. this._stopAutoResize();
  1023. }
  1024. };
  1025. /**
  1026. * Watch for changes in the size of the container. On resize, the Panel will
  1027. * automatically redraw itself.
  1028. * @private
  1029. */
  1030. Core.prototype._startAutoResize = function () {
  1031. var me = this;
  1032. this._stopAutoResize();
  1033. this._onResize = function() {
  1034. if (me.options.autoResize != true) {
  1035. // stop watching when the option autoResize is changed to false
  1036. me._stopAutoResize();
  1037. return;
  1038. }
  1039. if (me.dom.root) {
  1040. // check whether the frame is resized
  1041. // Note: we compare offsetWidth here, not clientWidth. For some reason,
  1042. // IE does not restore the clientWidth from 0 to the actual width after
  1043. // changing the timeline's container display style from none to visible
  1044. if ((me.dom.root.offsetWidth != me.props.lastWidth) ||
  1045. (me.dom.root.offsetHeight != me.props.lastHeight)) {
  1046. me.props.lastWidth = me.dom.root.offsetWidth;
  1047. me.props.lastHeight = me.dom.root.offsetHeight;
  1048. me.props.scrollbarWidth = util.getScrollBarWidth();
  1049. me.body.emitter.emit('_change');
  1050. }
  1051. }
  1052. };
  1053. // add event listener to window resize
  1054. util.addEventListener(window, 'resize', this._onResize);
  1055. //Prevent initial unnecessary redraw
  1056. if (me.dom.root) {
  1057. me.props.lastWidth = me.dom.root.offsetWidth;
  1058. me.props.lastHeight = me.dom.root.offsetHeight;
  1059. }
  1060. this.watchTimer = setInterval(this._onResize, 1000);
  1061. };
  1062. /**
  1063. * Stop watching for a resize of the frame.
  1064. * @private
  1065. */
  1066. Core.prototype._stopAutoResize = function () {
  1067. if (this.watchTimer) {
  1068. clearInterval(this.watchTimer);
  1069. this.watchTimer = undefined;
  1070. }
  1071. // remove event listener on window.resize
  1072. if (this._onResize) {
  1073. util.removeEventListener(window, 'resize', this._onResize);
  1074. this._onResize = null;
  1075. }
  1076. };
  1077. /**
  1078. * Start moving the timeline vertically
  1079. * @param {Event} event
  1080. * @private
  1081. */
  1082. Core.prototype._onTouch = function (event) { // eslint-disable-line no-unused-vars
  1083. this.touch.allowDragging = true;
  1084. this.touch.initialScrollTop = this.props.scrollTop;
  1085. };
  1086. /**
  1087. * Start moving the timeline vertically
  1088. * @param {Event} event
  1089. * @private
  1090. */
  1091. Core.prototype._onPinch = function (event) { // eslint-disable-line no-unused-vars
  1092. this.touch.allowDragging = false;
  1093. };
  1094. /**
  1095. * Move the timeline vertically
  1096. * @param {Event} event
  1097. * @private
  1098. */
  1099. Core.prototype._onDrag = function (event) {
  1100. if (!event) return
  1101. // refuse to drag when we where pinching to prevent the timeline make a jump
  1102. // when releasing the fingers in opposite order from the touch screen
  1103. if (!this.touch.allowDragging) return;
  1104. var delta = event.deltaY;
  1105. var oldScrollTop = this._getScrollTop();
  1106. var newScrollTop = this._setScrollTop(this.touch.initialScrollTop + delta);
  1107. if (this.options.verticalScroll) {
  1108. this.dom.left.parentNode.scrollTop = -this.props.scrollTop;
  1109. this.dom.right.parentNode.scrollTop = -this.props.scrollTop;
  1110. }
  1111. if (newScrollTop != oldScrollTop) {
  1112. this.emit("verticalDrag");
  1113. }
  1114. };
  1115. /**
  1116. * Apply a scrollTop
  1117. * @param {number} scrollTop
  1118. * @returns {number} scrollTop Returns the applied scrollTop
  1119. * @private
  1120. */
  1121. Core.prototype._setScrollTop = function (scrollTop) {
  1122. this.props.scrollTop = scrollTop;
  1123. this._updateScrollTop();
  1124. return this.props.scrollTop;
  1125. };
  1126. /**
  1127. * Update the current scrollTop when the height of the containers has been changed
  1128. * @returns {number} scrollTop Returns the applied scrollTop
  1129. * @private
  1130. */
  1131. Core.prototype._updateScrollTop = function () {
  1132. // recalculate the scrollTopMin
  1133. var scrollTopMin = Math.min(this.props.centerContainer.height - this.props.center.height, 0); // is negative or zero
  1134. if (scrollTopMin != this.props.scrollTopMin) {
  1135. // in case of bottom orientation, change the scrollTop such that the contents
  1136. // do not move relative to the time axis at the bottom
  1137. if (this.options.orientation.item != 'top') {
  1138. this.props.scrollTop += (scrollTopMin - this.props.scrollTopMin);
  1139. }
  1140. this.props.scrollTopMin = scrollTopMin;
  1141. }
  1142. // limit the scrollTop to the feasible scroll range
  1143. if (this.props.scrollTop > 0) this.props.scrollTop = 0;
  1144. if (this.props.scrollTop < scrollTopMin) this.props.scrollTop = scrollTopMin;
  1145. if (this.options.verticalScroll) {
  1146. this.dom.left.parentNode.scrollTop = -this.props.scrollTop;
  1147. this.dom.right.parentNode.scrollTop = -this.props.scrollTop;
  1148. }
  1149. return this.props.scrollTop;
  1150. };
  1151. /**
  1152. * Get the current scrollTop
  1153. * @returns {number} scrollTop
  1154. * @private
  1155. */
  1156. Core.prototype._getScrollTop = function () {
  1157. return this.props.scrollTop;
  1158. };
  1159. /**
  1160. * Load a configurator
  1161. * [at]returns {Object}
  1162. * @private
  1163. */
  1164. Core.prototype._createConfigurator = function () {
  1165. throw new Error('Cannot invoke abstract method _createConfigurator');
  1166. };
  1167. module.exports = Core;