Globals.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. /* *
  12. *
  13. * Constants
  14. *
  15. * */
  16. /**
  17. * @private
  18. * @deprecated
  19. * @todo Rename UMD argument `win` to `window`; move code to `Globals.win`
  20. */
  21. var w = (typeof win !== 'undefined' ?
  22. win :
  23. typeof window !== 'undefined' ?
  24. window :
  25. {}
  26. // eslint-disable-next-line node/no-unsupported-features/es-builtins
  27. );
  28. /* *
  29. *
  30. * Namespace
  31. *
  32. * */
  33. /**
  34. * Shared Highcharts properties.
  35. */
  36. var Globals;
  37. (function (Globals) {
  38. /* *
  39. *
  40. * Constants
  41. *
  42. * */
  43. Globals.SVG_NS = 'http://www.w3.org/2000/svg', Globals.product = 'Highcharts', Globals.version = '9.1.0', Globals.win = w, Globals.doc = Globals.win.document, Globals.svg = (Globals.doc &&
  44. Globals.doc.createElementNS &&
  45. !!Globals.doc.createElementNS(Globals.SVG_NS, 'svg').createSVGRect), Globals.userAgent = (Globals.win.navigator && Globals.win.navigator.userAgent) || '', Globals.isChrome = Globals.userAgent.indexOf('Chrome') !== -1, Globals.isFirefox = Globals.userAgent.indexOf('Firefox') !== -1, Globals.isMS = /(edge|msie|trident)/i.test(Globals.userAgent) && !Globals.win.opera, Globals.isSafari = !Globals.isChrome && Globals.userAgent.indexOf('Safari') !== -1, Globals.isTouchDevice = /(Mobile|Android|Windows Phone)/.test(Globals.userAgent), Globals.isWebKit = Globals.userAgent.indexOf('AppleWebKit') !== -1, Globals.deg2rad = Math.PI * 2 / 360, Globals.hasBidiBug = (Globals.isFirefox &&
  46. parseInt(Globals.userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  47. ), Globals.hasTouch = !!Globals.win.TouchEvent, Globals.marginNames = [
  48. 'plotTop',
  49. 'marginRight',
  50. 'marginBottom',
  51. 'plotLeft'
  52. ], Globals.noop = function () { }, Globals.supportsPassiveEvents = (function () {
  53. // Checks whether the browser supports passive events, (#11353).
  54. var supportsPassive = false;
  55. // Object.defineProperty doesn't work on IE as well as passive
  56. // events - instead of using polyfill, we can exclude IE totally.
  57. if (!Globals.isMS) {
  58. var opts = Object.defineProperty({}, 'passive', {
  59. get: function () {
  60. supportsPassive = true;
  61. }
  62. });
  63. if (Globals.win.addEventListener && Globals.win.removeEventListener) {
  64. Globals.win.addEventListener('testPassive', Globals.noop, opts);
  65. Globals.win.removeEventListener('testPassive', Globals.noop, opts);
  66. }
  67. }
  68. return supportsPassive;
  69. }());
  70. /**
  71. * An array containing the current chart objects in the page. A chart's
  72. * position in the array is preserved throughout the page's lifetime. When
  73. * a chart is destroyed, the array item becomes `undefined`.
  74. *
  75. * @name Highcharts.charts
  76. * @type {Array<Highcharts.Chart|undefined>}
  77. */
  78. Globals.charts = [];
  79. /**
  80. * A hook for defining additional date format specifiers. New
  81. * specifiers are defined as key-value pairs by using the
  82. * specifier as key, and a function which takes the timestamp as
  83. * value. This function returns the formatted portion of the
  84. * date.
  85. *
  86. * @sample highcharts/global/dateformats/
  87. * Adding support for week number
  88. *
  89. * @name Highcharts.dateFormats
  90. * @type {Record<string, Highcharts.TimeFormatCallbackFunction>}
  91. */
  92. Globals.dateFormats = {};
  93. /**
  94. * @private
  95. * @deprecated
  96. * @todo Use only `Core/Series/SeriesRegistry.seriesTypes`
  97. */
  98. Globals.seriesTypes = {};
  99. /**
  100. * @private
  101. */
  102. Globals.symbolSizes = {};
  103. })(Globals || (Globals = {}));
  104. /* *
  105. *
  106. * Default Export
  107. *
  108. * */
  109. export default Globals;