env.js 845 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals navigator:false */
  6. /**
  7. * @module utils/env
  8. */
  9. const userAgent = navigator.userAgent.toLowerCase();
  10. /**
  11. * A namespace containing environment and browser information.
  12. *
  13. * @namespace
  14. */
  15. const env = {
  16. /**
  17. * Indicates that application is running on Macintosh.
  18. *
  19. * @static
  20. * @member {Boolean} module:utils/env~env#mac
  21. */
  22. mac: isMac( userAgent )
  23. };
  24. export default env;
  25. /**
  26. * Checks if User Agent represented by the string is running on Macintosh.
  27. *
  28. * @param {String} userAgent **Lowercase** `navigator.userAgent` string.
  29. * @returns {Boolean} Whether User Agent is running on Macintosh or not.
  30. */
  31. export function isMac( userAgent ) {
  32. return userAgent.indexOf( 'macintosh' ) > -1;
  33. }