]>
Commit | Line | Data |
---|---|---|
6d6f0db0 SR |
1 | /* |
2 | * noVNC: HTML5 VNC client | |
3 | * Copyright (C) 2012 Joel Martin | |
4 | * Licensed under MPL 2.0 (see LICENSE.txt) | |
5 | * | |
6 | * See README.md for usage and integration instructions. | |
7 | */ | |
8 | ||
9 | import * as Log from './logging.js'; | |
10 | ||
6d6f0db0 SR |
11 | // Touch detection |
12 | export var isTouchDevice = ('ontouchstart' in document.documentElement) || | |
13 | // requried for Chrome debugger | |
14 | (document.ontouchstart !== undefined) || | |
15 | // required for MS Surface | |
16 | (navigator.maxTouchPoints > 0) || | |
17 | (navigator.msMaxTouchPoints > 0); | |
18 | window.addEventListener('touchstart', function onFirstTouch() { | |
19 | isTouchDevice = true; | |
20 | window.removeEventListener('touchstart', onFirstTouch, false); | |
21 | }, false); | |
22 | ||
23 | var _cursor_uris_supported = null; | |
24 | ||
25 | export function browserSupportsCursorURIs () { | |
26 | if (_cursor_uris_supported === null) { | |
27 | try { | |
28 | var target = document.createElement('canvas'); | |
29 | target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default'; | |
30 | ||
31 | if (target.style.cursor) { | |
32 | Log.Info("Data URI scheme cursor supported"); | |
33 | _cursor_uris_supported = true; | |
34 | } else { | |
35 | Log.Warn("Data URI scheme cursor not supported"); | |
36 | _cursor_uris_supported = false; | |
37 | } | |
38 | } catch (exc) { | |
39 | Log.Error("Data URI scheme cursor test exception: " + exc); | |
40 | _cursor_uris_supported = false; | |
41 | } | |
42 | } | |
43 | ||
44 | return _cursor_uris_supported; | |
45 | }; |