You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

67 line
1.4 KiB

  1. import { detect } from 'detect-browser';
  2. import mobile from 'is-mobile';
  3. const $ = require('jquery');
  4. export default class ihk {
  5. static getBrowser(){
  6. return detect();
  7. }
  8. static isMobile(){
  9. return mobile();
  10. }
  11. static init() {
  12. const mobile = ihk.isMobile();
  13. const browser = ihk.getBrowser();
  14. const html = $('html');
  15. html.addClass( mobile ? 'mobile' : 'desktop' );
  16. html.attr('data-browser', browser.name);
  17. html.attr('data-os', browser.os);
  18. }
  19. static getUrlVars() {
  20. let vars = {};
  21. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
  22. vars[key] = value;
  23. });
  24. return vars;
  25. }
  26. static realVH() {
  27. const vh = window.innerHeight * 0.01;
  28. document.documentElement.style.setProperty('--viewport-height', vh + 'px');
  29. }
  30. }
  31. /*
  32. const ihk = {
  33. browser: detect(),
  34. mobile: mobile(),
  35. ready: false,
  36. init: function () {
  37. //console.log(this.browser);
  38. const html = $('html');
  39. html.addClass( this.mobile ? 'mobile' : 'desktop' );
  40. html.attr('data-browser', this.browser.name);
  41. html.attr('data-os', this.browser.os);
  42. }
  43. }
  44. ihk.getUrlVars = function () {
  45. var vars = {};
  46. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  47. vars[key] = value;
  48. });
  49. return vars;
  50. };
  51. ihk.realVH = function () {
  52. var vh = window.innerHeight * 0.01;
  53. document.documentElement.style.setProperty('--viewport-height', vh + 'px');
  54. };
  55. */
  56. //export default ihk;