/js/tool.js

https://bitbucket.org/baniol/mobilang · JavaScript · 35 lines · 17 code · 5 blank · 13 comment · 2 complexity · 980e41007fef2d95e32545562e512226 MD5 · raw file

  1. var fijsTool = {
  2. /**
  3. * True if mobile
  4. */
  5. mobileDevice: false,
  6. /**
  7. * Click/touch event trigger (mobile/fix)
  8. */
  9. triggerEvent:null,
  10. /**
  11. * Global settings
  12. */
  13. initFijsTool: function(){
  14. // mobile detect
  15. if(this.detectMobile()){
  16. this.startEvent = 'touchstart';
  17. this.endEvent = 'touchend';
  18. }else{
  19. this.startEvent = 'mousedown';
  20. this.endEvent = 'mouseup';
  21. }
  22. },
  23. /**
  24. * Returns true if mobile browser
  25. */
  26. detectMobile: function(){
  27. var check = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/);
  28. return check !== null || this.phonegap ? true: false;
  29. }
  30. }