Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -120,7 +124,7 @@ if ('ontouchstart' in window && (!/BlackBerry/.test(ua))) {
move: 'mousemove',
end: 'mouseup'
};
}
}*/

/*
* All userAgent flags in this file are now DEPRECATED.
Expand Down
19 changes: 14 additions & 5 deletions src/platforms/browser/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -204,7 +213,7 @@ exports = Class(function () {
}
}

if (allowIOSScroll && type === eventTypes.SCROLL) {
if (allowIOSScroll && type === eventTypes.SCROLL) {
return;
}

Expand Down
12 changes: 8 additions & 4 deletions src/platforms/browser/MobileBrowserAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
Expand Down
16 changes: 12 additions & 4 deletions src/platforms/browser/inputDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ 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; }
target = target.parentNode;
}

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);
Expand All @@ -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);
};
Expand Down