8
0

env.js 792 B

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * @license Copyright (c) 2003-2016, 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. export default {
  14. /**
  15. * Indicates that application is running on Macintosh.
  16. *
  17. * @member {Boolean}
  18. */
  19. mac: isMac( userAgent )
  20. };
  21. /**
  22. * Checks if User Agent represented by the string is running on Macintosh.
  23. *
  24. * @function isMac
  25. * @param {String} userAgent **Lowercase** `navigator.userAgent` string.
  26. * @returns {Boolean} Whether User Agent is running on Macintosh or not.
  27. */
  28. export function isMac( userAgent ) {
  29. return userAgent.indexOf( 'macintosh' ) > -1;
  30. }