FluidbookInput.prototype = {
init: function () {
+ var $this = this;
if (Modernizr.ftouch) {
this.hasTouch = true;
} else {
this.usingMouse = this.hasMouse = this.forceMouse = true;
this.usingTouch = this.hasTouch = this.forceTouch = false;
+ this.setMouseClasses();
return;
}
if (Modernizr.iOS || Modernizr.android) {
this.usingTouch = this.hasTouch = this.forceTouch = true;
this.usingMouse = this.hasMouse = this.forceMouse = false;
+ this.setTouchClasses();
return;
}
this.forceTouch = this.forceMouse = false;
$(document).on('mousemove', function () {
- this.hasMouse = this.usingMouse = true;
- this.usingTouch = false;
+ $this.useMouse();
return true;
});
$(document).on('touchstart touchmove touchend', function () {
- this.hasTouch = this.usingTouch = true;
- this.usingMouse = false;
+ $this.useTouch();
return true;
});
},
+
+ isUsingTouch: function () {
+ return this.usingTouch;
+ },
+
+ isUsingMouse: function () {
+ return this.usingMouse;
+ },
+
+ useTouch: function () {
+ if (!this.usingTouch) {
+ this.hasTouch = this.usingTouch = true;
+ this.usingMouse = false;
+ this.setTouchClasses();
+ }
+ },
+ useMouse: function () {
+ if (!this.usingMouse) {
+ this.hasMouse = this.usingMouse = true;
+ this.usingTouch = false;
+ this.setMouseClasses();
+ }
+ },
+
+ setTouchClasses: function () {
+ $('html').removeClass('using-mouse')
+ .removeClass('no-using-touch')
+ .addClass('no-using-mouse')
+ .addClass('using-touch');
+ },
+ setMouseClasses: function () {
+ $('html').addClass('using-mouse')
+ .addClass('no-using-touch')
+ .removeClass('no-using-mouse')
+ .removeClass('using-touch');
+ }
};
\ No newline at end of file