Globals.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * (c) 2010-2019 Torstein Honsi
  3. *
  4. * License: www.highcharts.com/license
  5. */
  6. /**
  7. * Reference to the global SVGElement class as a workaround for a name conflict
  8. * in the Highcharts namespace.
  9. *
  10. * @global
  11. * @typedef {global.SVGElement} GlobalSVGElement
  12. *
  13. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  14. */
  15. 'use strict';
  16. /* global win, window */
  17. // glob is a temporary fix to allow our es-modules to work.
  18. var glob = typeof win === 'undefined' ? window : win,
  19. doc = glob.document,
  20. SVG_NS = 'http://www.w3.org/2000/svg',
  21. userAgent = (glob.navigator && glob.navigator.userAgent) || '',
  22. svg = (
  23. doc &&
  24. doc.createElementNS &&
  25. !!doc.createElementNS(SVG_NS, 'svg').createSVGRect
  26. ),
  27. isMS = /(edge|msie|trident)/i.test(userAgent) && !glob.opera,
  28. isFirefox = userAgent.indexOf('Firefox') !== -1,
  29. isChrome = userAgent.indexOf('Chrome') !== -1,
  30. hasBidiBug = (
  31. isFirefox &&
  32. parseInt(userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  33. );
  34. var Highcharts = glob.Highcharts ? glob.Highcharts.error(16, true) : {
  35. product: '@product.name@',
  36. version: '@product.version@',
  37. deg2rad: Math.PI * 2 / 360,
  38. doc: doc,
  39. hasBidiBug: hasBidiBug,
  40. hasTouch: doc && doc.documentElement.ontouchstart !== undefined,
  41. isMS: isMS,
  42. isWebKit: userAgent.indexOf('AppleWebKit') !== -1,
  43. isFirefox: isFirefox,
  44. isChrome: isChrome,
  45. isSafari: !isChrome && userAgent.indexOf('Safari') !== -1,
  46. isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
  47. SVG_NS: SVG_NS,
  48. chartCount: 0,
  49. seriesTypes: {},
  50. symbolSizes: {},
  51. svg: svg,
  52. win: glob,
  53. marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
  54. noop: function () {
  55. return undefined;
  56. },
  57. /**
  58. * An array containing the current chart objects in the page. A chart's
  59. * position in the array is preserved throughout the page's lifetime. When
  60. * a chart is destroyed, the array item becomes `undefined`.
  61. *
  62. * @name Highcharts.charts
  63. * @type {Array<Highcharts.Chart>}
  64. */
  65. charts: []
  66. };
  67. export default Highcharts;