Globals.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* *
  2. *
  3. * (c) 2010-2020 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. );
  32. var H = {
  33. product: 'Highcharts',
  34. version: '8.1.2',
  35. deg2rad: Math.PI * 2 / 360,
  36. doc: doc,
  37. hasBidiBug: hasBidiBug,
  38. hasTouch: !!glob.TouchEvent,
  39. isMS: isMS,
  40. isWebKit: userAgent.indexOf('AppleWebKit') !== -1,
  41. isFirefox: isFirefox,
  42. isChrome: isChrome,
  43. isSafari: !isChrome && userAgent.indexOf('Safari') !== -1,
  44. isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
  45. SVG_NS: SVG_NS,
  46. chartCount: 0,
  47. seriesTypes: {},
  48. symbolSizes: {},
  49. svg: svg,
  50. win: glob,
  51. marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
  52. noop: function () { },
  53. /**
  54. * An array containing the current chart objects in the page. A chart's
  55. * position in the array is preserved throughout the page's lifetime. When
  56. * a chart is destroyed, the array item becomes `undefined`.
  57. *
  58. * @name Highcharts.charts
  59. * @type {Array<Highcharts.Chart|undefined>}
  60. */
  61. charts: [],
  62. /**
  63. * A hook for defining additional date format specifiers. New
  64. * specifiers are defined as key-value pairs by using the
  65. * specifier as key, and a function which takes the timestamp as
  66. * value. This function returns the formatted portion of the
  67. * date.
  68. *
  69. * @sample highcharts/global/dateformats/
  70. * Adding support for week number
  71. *
  72. * @name Highcharts.dateFormats
  73. * @type {Highcharts.Dictionary<Highcharts.TimeFormatCallbackFunction>}
  74. */
  75. dateFormats: {}
  76. };
  77. export default H;