Globals.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* *
  2. *
  3. * (c) 2010-2021 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. /* globals Image, window */
  12. /**
  13. * Reference to the global SVGElement class as a workaround for a name conflict
  14. * in the Highcharts namespace.
  15. *
  16. * @global
  17. * @typedef {global.SVGElement} GlobalSVGElement
  18. *
  19. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  20. */
  21. // glob is a temporary fix to allow our es-modules to work.
  22. var glob = ( // @todo UMD variable named `window`, and glob named `win`
  23. typeof win !== 'undefined' ?
  24. win :
  25. typeof window !== 'undefined' ?
  26. window :
  27. {}), doc = glob.document, SVG_NS = 'http://www.w3.org/2000/svg', userAgent = (glob.navigator && glob.navigator.userAgent) || '', svg = (doc &&
  28. doc.createElementNS &&
  29. !!doc.createElementNS(SVG_NS, 'svg').createSVGRect), isMS = /(edge|msie|trident)/i.test(userAgent) && !glob.opera, isFirefox = userAgent.indexOf('Firefox') !== -1, isChrome = userAgent.indexOf('Chrome') !== -1, hasBidiBug = (isFirefox &&
  30. parseInt(userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  31. ), noop = function () { },
  32. // Checks whether the browser supports passive events, (#11353).
  33. checkPassiveEvents = function () {
  34. var supportsPassive = false;
  35. // Object.defineProperty doesn't work on IE as well as passive events -
  36. // instead of using polyfill, we can exclude IE totally.
  37. if (!isMS) {
  38. var opts = Object.defineProperty({}, 'passive', {
  39. get: function () {
  40. supportsPassive = true;
  41. }
  42. });
  43. if (glob.addEventListener && glob.removeEventListener) {
  44. glob.addEventListener('testPassive', noop, opts);
  45. glob.removeEventListener('testPassive', noop, opts);
  46. }
  47. }
  48. return supportsPassive;
  49. };
  50. var H = {
  51. product: 'Highcharts',
  52. version: '9.0.1',
  53. deg2rad: Math.PI * 2 / 360,
  54. doc: doc,
  55. hasBidiBug: hasBidiBug,
  56. hasTouch: !!glob.TouchEvent,
  57. isMS: isMS,
  58. isWebKit: userAgent.indexOf('AppleWebKit') !== -1,
  59. isFirefox: isFirefox,
  60. isChrome: isChrome,
  61. isSafari: !isChrome && userAgent.indexOf('Safari') !== -1,
  62. isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
  63. SVG_NS: SVG_NS,
  64. chartCount: 0,
  65. seriesTypes: {},
  66. supportsPassiveEvents: checkPassiveEvents(),
  67. symbolSizes: {},
  68. svg: svg,
  69. win: glob,
  70. marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
  71. noop: noop,
  72. /**
  73. * Theme options that should get applied to the chart. In module mode it
  74. * might not be possible to change this property because of read-only
  75. * restrictions, instead use {@link Highcharts.setOptions}.
  76. *
  77. * @name Highcharts.theme
  78. * @type {Highcharts.Options}
  79. */
  80. /**
  81. * An array containing the current chart objects in the page. A chart's
  82. * position in the array is preserved throughout the page's lifetime. When
  83. * a chart is destroyed, the array item becomes `undefined`.
  84. *
  85. * @name Highcharts.charts
  86. * @type {Array<Highcharts.Chart|undefined>}
  87. */
  88. charts: [],
  89. /**
  90. * A hook for defining additional date format specifiers. New
  91. * specifiers are defined as key-value pairs by using the
  92. * specifier as key, and a function which takes the timestamp as
  93. * value. This function returns the formatted portion of the
  94. * date.
  95. *
  96. * @sample highcharts/global/dateformats/
  97. * Adding support for week number
  98. *
  99. * @name Highcharts.dateFormats
  100. * @type {Highcharts.Dictionary<Highcharts.TimeFormatCallbackFunction>}
  101. */
  102. dateFormats: {}
  103. };
  104. export default H;