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.

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