diff --git a/src/device.js b/src/device.js index d61762ba..4a1e7b87 100644 --- a/src/device.js +++ b/src/device.js @@ -107,8 +107,12 @@ util.setProperty(exports, 'defaultFontFamily', { value: 'Helvetica' }); exports.defaultFontWeight = ""; - -if ('ontouchstart' in window && (!/BlackBerry/.test(ua))) { +exports.events = { + start: ['touchstart', 'mousedown'], + move: ['touchmove', 'mousemove'], + end: ['touchend', 'mouseup'] +}; +/*if ('ontouchstart' in window && (!/BlackBerry/.test(ua))) { exports.events = { start: 'touchstart', move: 'touchmove', @@ -120,7 +124,7 @@ if ('ontouchstart' in window && (!/BlackBerry/.test(ua))) { move: 'mousemove', end: 'mouseup' }; -} +}*/ /* * All userAgent flags in this file are now DEPRECATED. diff --git a/src/platforms/browser/Input.js b/src/platforms/browser/Input.js index ba5754de..c9bc7581 100644 --- a/src/platforms/browser/Input.js +++ b/src/platforms/browser/Input.js @@ -65,7 +65,9 @@ exports = Class(function () { this._keyListener = opts.keyListener; if (device.useDOM) { - $.onEvent(document, device.events.start, this, 'handleMouse', eventTypes.START); + for (var i = 0; i < device.events.start.length; i++) { + $.onEvent(document, device.events.start, this, 'handleMouse', eventTypes.START); + } } if (opts.engine) { @@ -90,8 +92,13 @@ exports = Class(function () { if (this._isEnabled) { return; } this._isEnabled = true; - this._handleMove = $.onEvent(document, device.events.move, this, 'handleMouse', eventTypes.MOVE); - this._handleSelect = $.onEvent(document, device.events.end, this, 'handleMouse', eventTypes.SELECT); + for (var i = 0; i < device.events.move.length; i++) { + this._handleMove = $.onEvent(document, device.events.move[i], this, 'handleMouse', eventTypes.MOVE); + } + for (i = 0; i < device.events.end.length; i++) { + this._handleSelect = $.onEvent(document, device.events.end[i], this, 'handleMouse', eventTypes.SELECT); + } + this._handleScroll = $.onEvent(window, 'DOMMouseScroll', this, 'handleMouse', eventTypes.SCROLL); // FF this._handleWheel = $.onEvent(window, 'mousewheel', this, 'handleMouse', eventTypes.SCROLL); // webkit @@ -156,7 +163,9 @@ exports = Class(function () { this._elEvents = []; if (!device.useDOM) { - this._elEvents.push($.onEvent(el, device.events.start, this, 'handleMouse', eventTypes.START)); + for (var i = 0; i < device.events.start.length; i++) { + this._elEvents.push($.onEvent(el, device.events.start[i], this, 'handleMouse', eventTypes.START)); + } } if (!device.isMobileBrowser && !device.isNative) { @@ -204,7 +213,7 @@ exports = Class(function () { } } - if (allowIOSScroll && type === eventTypes.SCROLL) { + if (allowIOSScroll && type === eventTypes.SCROLL) { return; } diff --git a/src/platforms/browser/MobileBrowserAPI.js b/src/platforms/browser/MobileBrowserAPI.js index d3b5db2d..6dcac06e 100644 --- a/src/platforms/browser/MobileBrowserAPI.js +++ b/src/platforms/browser/MobileBrowserAPI.js @@ -50,8 +50,10 @@ var AudioAPI = exports = Class(lib.PubSub, function (supr) { this._load(); if (this.oneChannelOnly) { this._boundLoadHandler = bind(this, '_playFirst'); - document.body.addEventListener(device.events.start, - this._boundLoadHandler, true); + for (var i = 0; i < device.events.start.length; i++) { + document.body.addEventListener(device.events.start[i], + this._boundLoadHandler, true); + } } window.addEventListener('pagehide', bind(this, 'pause'), false); } @@ -109,8 +111,10 @@ var AudioAPI = exports = Class(lib.PubSub, function (supr) { } this._playFirst = function () { - document.body.removeEventListener(device.events.start, - this._boundLoadHandler, true); + for (var i = 0; i < device.events.start.length; i++) { + document.body.removeEventListener(device.events.start[i], + this._boundLoadHandler, true); + } this._audios['AUDIO'].play(); } diff --git a/src/platforms/browser/inputDialog.js b/src/platforms/browser/inputDialog.js index dcd64929..9889d552 100644 --- a/src/platforms/browser/inputDialog.js +++ b/src/platforms/browser/inputDialog.js @@ -131,7 +131,7 @@ var InputDialog = Class(function () { children: [dialog] }); - $.onEvent(this._el, device.events.move, function (e) { + function onMove(e) { var target = e.target; while (target && target != document.body) { if (target == dialog) { return; } @@ -139,7 +139,11 @@ var InputDialog = Class(function () { } e.preventDefault(); - }); + } + + for (var i = 0; i < device.events.move.length; i++) { + $.onEvent(this._el, device.events.move[i], onMove); + } if (addClasses) { css.sizeAndPositionDialog(dialog, body); @@ -165,12 +169,16 @@ var InputDialog = Class(function () { attrs: {noCapture: true} }); - $.onEvent(btn, device.events.end, function () { + var onEnd = function() { this.close(); if (cb) { cb && cb(this.getValue()); } - }.bind(this)); + }.bind(this); + + for (var i = 0; i < device.events.end.length; i++) { + $.onEvent(btn, device.events.end[i], onEnd); + } this._buttons.push(btn); };