controlbarMouseDownOffsetY: 0,
keyboardVisible: false,
- isTouchDevice: false,
isSafari: false,
rememberedClipSetting: null,
lastKeyboardinput: null,
start: function(callback) {
// Setup global variables first
- UI.isTouchDevice = 'ontouchstart' in document.documentElement;
UI.isSafari = (navigator.userAgent.indexOf('Safari') !== -1 &&
navigator.userAgent.indexOf('Chrome') === -1);
UI.initSettings();
// Adapt the interface for touch screen devices
- if (UI.isTouchDevice) {
+ if (Util.isTouchDevice) {
document.documentElement.classList.add("noVNC_touch");
// Remove the address bar
setTimeout(function() { window.scrollTo(0, 1); }, 100);
UI.initSetting('password', '');
UI.initSetting('encrypt', (window.location.protocol === "https:"));
UI.initSetting('true_color', true);
- UI.initSetting('cursor', !UI.isTouchDevice);
+ UI.initSetting('cursor', !Util.isTouchDevice);
UI.initSetting('resize', 'off');
UI.initSetting('shared', true);
UI.initSetting('view_only', false);
if (Util.browserSupportsCursorURIs()) {
document.getElementById('noVNC_setting_cursor').disabled = UI.connected;
} else {
- UI.updateSetting('cursor', !UI.isTouchDevice);
+ UI.updateSetting('cursor', !Util.isTouchDevice);
document.getElementById('noVNC_setting_cursor').disabled = true;
}
if (Util.browserSupportsCursorURIs()) {
UI.updateSetting('cursor');
} else {
- UI.updateSetting('cursor', !UI.isTouchDevice);
+ UI.updateSetting('cursor', !Util.isTouchDevice);
document.getElementById('noVNC_setting_cursor').disabled = true;
}
UI.updateSetting('clip');
// Restore view clip to what it was before fullscreen on IE
UI.setViewClip(UI.rememberedClipSetting);
document.getElementById('noVNC_setting_clip').disabled =
- UI.connected || UI.isTouchDevice;
+ UI.connected || Util.isTouchDevice;
} else {
document.getElementById('noVNC_setting_clip').disabled =
- UI.connected || UI.isTouchDevice;
- if (UI.isTouchDevice) {
+ UI.connected || Util.isTouchDevice;
+ if (Util.isTouchDevice) {
UI.setViewClip(true);
}
}
// Different behaviour for touch vs non-touch
// The button is disabled instead of hidden on touch devices
- if (UI.isTouchDevice) {
+ if (Util.isTouchDevice) {
viewDragButton.classList.remove("noVNC_hidden");
if (clipping) {
* ------v------*/
showVirtualKeyboard: function() {
- if (!UI.isTouchDevice) return;
+ if (!Util.isTouchDevice) return;
var input = document.getElementById('noVNC_keyboardinput');
},
hideVirtualKeyboard: function() {
- if (!UI.isTouchDevice) return;
+ if (!Util.isTouchDevice) return;
var input = document.getElementById('noVNC_keyboardinput');
grab: function () {
var c = this._target;
- if ('ontouchstart' in document.documentElement) {
+ if (Util.isTouchDevice) {
c.addEventListener('touchstart', this._eventHandlers.mousedown);
window.addEventListener('touchend', this._eventHandlers.mouseup);
c.addEventListener('touchend', this._eventHandlers.mouseup);
ungrab: function () {
var c = this._target;
- if ('ontouchstart' in document.documentElement) {
+ if (Util.isTouchDevice) {
c.removeEventListener('touchstart', this._eventHandlers.mousedown);
window.removeEventListener('touchend', this._eventHandlers.mouseup);
c.removeEventListener('touchend', this._eventHandlers.mouseup);
e.preventDefault();
};
+// Touch detection
+Util.isTouchDevice = ('ontouchstart' in document.documentElement) ||
+ // requried for Chrome debugger
+ (document.ontouchstart !== undefined) ||
+ // required for MS Surface
+ (navigator.maxTouchPoints > 0) ||
+ (navigator.msMaxTouchPoints > 0);
+window.addEventListener('touchstart', function onFirstTouch() {
+ Util.isTouchDevice = true;
+ window.removeEventListener('touchstart', onFirstTouch, false);
+}, false);
+
Util._cursor_uris_supported = null;
Util.browserSupportsCursorURIs = function () {