mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-05-26 15:13:36 +00:00
term: do not re-focus on keyup when on mobile
Doing this will mess up the mobile browsers. Although we still don't support mobile browsers very well, this can at least make it usable on them.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var $, State, Terminal, cancel, cols, openTs, quit, rows, s, ws,
|
||||
var $, State, Terminal, cancel, cols, isMobile, openTs, quit, rows, s, ws,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
cols = rows = null;
|
||||
@@ -131,6 +131,10 @@
|
||||
return false;
|
||||
};
|
||||
|
||||
isMobile = function() {
|
||||
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
||||
};
|
||||
|
||||
s = 0;
|
||||
|
||||
State = {
|
||||
@@ -201,11 +205,13 @@
|
||||
this.inputHelper.addEventListener('keypress', this.keyPress.bind(this));
|
||||
addEventListener('keydown', this.keyDown.bind(this));
|
||||
addEventListener('keypress', this.keyPress.bind(this));
|
||||
addEventListener('keyup', (function(_this) {
|
||||
return function() {
|
||||
return _this.inputHelper.focus();
|
||||
};
|
||||
})(this));
|
||||
if (!isMobile()) {
|
||||
addEventListener('keyup', (function(_this) {
|
||||
return function() {
|
||||
return _this.inputHelper.focus();
|
||||
};
|
||||
})(this));
|
||||
}
|
||||
addEventListener('focus', this.focus.bind(this));
|
||||
addEventListener('blur', this.blur.bind(this));
|
||||
addEventListener('resize', (function(_this) {
|
||||
|
||||
4
butterfly/static/main.min.js
vendored
4
butterfly/static/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -34,6 +34,9 @@ cancel = (ev) ->
|
||||
ev.cancelBubble = true
|
||||
false
|
||||
|
||||
isMobile = ->
|
||||
/iPhone|iPad|iPod|Android/i.test navigator.userAgent
|
||||
|
||||
s = 0
|
||||
State =
|
||||
normal: s++
|
||||
@@ -123,7 +126,9 @@ class Terminal
|
||||
addEventListener 'keydown', @keyDown.bind(@)
|
||||
addEventListener 'keypress', @keyPress.bind(@)
|
||||
# Always focus on the inputHelper textarea
|
||||
addEventListener 'keyup', => @inputHelper.focus()
|
||||
# Don't do this on mobile, it will mess up the IME
|
||||
unless isMobile()
|
||||
addEventListener 'keyup', => @inputHelper.focus()
|
||||
addEventListener 'focus', @focus.bind(@)
|
||||
addEventListener 'blur', @blur.bind(@)
|
||||
addEventListener 'resize', => @resize()
|
||||
|
||||
Reference in New Issue
Block a user