remove hasTouchEvents

pull/7235/head
Thibault Duplessis 2020-09-05 19:32:02 +02:00
parent bd250ca650
commit 8b81149644
12 changed files with 9 additions and 18 deletions

View File

@ -2,7 +2,6 @@ interface Lichess {
load: Promise<unknown>; // window.onload promise
info: any;
requestIdleCallback(f: () => void): void;
hasTouchEvents: boolean;
sri: string;
storage: LichessStorageHelper;
tempStorage: LichessStorageHelper;

View File

@ -93,7 +93,7 @@ export function view(ctrl: StudyCtrl): VNode {
const makeSortable = function() {
vData.sortable = window['Sortable'].create(el, {
draggable: '.draggable',
handle: window.lichess.hasTouchEvents ? 'span' : undefined,
handle: 'ontouchstart' in window ? 'span' : undefined,
onSort() {
ctrl.chapters.sort(vData.sortable.toArray());
}

View File

@ -306,7 +306,7 @@ export default function(ctrl: AnalyseCtrl): VNode {
ctrl.keyboardHelp ? keyboardView(ctrl) : null,
study ? studyView.overboard(study) : null,
intro || h(addChapterId(study, 'div.analyse__board.main-board'), {
hook: (window.lichess.hasTouchEvents || ctrl.gamebookPlay()) ? undefined : bind('wheel', (e: WheelEvent) => wheel(ctrl, e))
hook: ('ontouchstart' in window || ctrl.gamebookPlay()) ? undefined : bind('wheel', (e: WheelEvent) => wheel(ctrl, e))
}, [
...(clocks || []),
playerBars ? playerBars[ctrl.bottomIsWhite() ? 1 : 0] : null,

View File

@ -12,7 +12,7 @@ type State = any;
const menuHover = () => {
if (window.lichess.hasTouchEvents) return;
if ('ontouchstart' in window) return;
const interval = 100;
const sensitivity = 10;

View File

@ -86,5 +86,5 @@ function setupTextarea(area: HTMLTextAreaElement, contact: string, ctrl: MsgCtrl
});
area.addEventListener('send', send);
if (!window.lichess.hasTouchEvents) area.focus();
if (!('ontouchstart' in window)) area.focus();
}

View File

@ -36,7 +36,7 @@ export function bind(eventName: string, f: (e: Event) => void) {
}
export function bindMobileMousedown(f: (e: Event) => any) {
return bind(window.lichess.hasTouchEvents ? 'click' : 'mousedown', f);
return bind('ontouchstart' in window ? 'click' : 'mousedown', f);
}
export function spinner(): VNode {

View File

@ -93,7 +93,7 @@ export default function(ctrl: Controller): VNode {
side.userBox(ctrl)
]),
h('div.puzzle__board.main-board' + (ctrl.pref.blindfold ? '.blindfold' : ''), {
hook: window.lichess.hasTouchEvents ? undefined : bind('wheel', e => wheel(ctrl, e as WheelEvent))
hook: 'ontouchstart' in window ? undefined : bind('wheel', e => wheel(ctrl, e as WheelEvent))
}, [
chessground(ctrl),
ctrl.promotion.view()

View File

@ -63,7 +63,7 @@ export function main(ctrl: RoundController): VNode {
hook: util.onInsert(gridHacks.start)
}, [
h('div.round__app__board.main-board' + (ctrl.data.pref.blindfold ? '.blindfold' : ''), {
hook: window.lichess.hasTouchEvents ? undefined :
hook: 'ontouchstart' in window ? undefined :
util.bind('wheel', (e: WheelEvent) => wheel(ctrl, e), undefined, false)
}, [
renderGround(ctrl),

View File

@ -1,5 +1,3 @@
import hasTouchEvents from './touchEvents';
export const assetUrl = (path: string, opts: AssetUrlOpts = {}) => {
opts = opts || {};
const baseUrl = opts.sameDomain ? '' : document.body.getAttribute('data-asset-url'),
@ -40,5 +38,5 @@ export const hopscotch = () => {
export const slider = () =>
loadScript(
'javascripts/vendor/jquery-ui.slider' + (hasTouchEvents ? '.touch' : '') + '.min.js'
'javascripts/vendor/jquery-ui.slider' + ('ontouchstart' in window ? '.touch' : '') + '.min.js'
);

View File

@ -1,11 +1,10 @@
import spinnerHtml from './spinner';
import hasTouchEvents from './touchEvents';
import { requestIdleCallback } from './functions';
let hoverable: boolean;
function isHoverable() {
if (typeof hoverable === 'undefined')
hoverable = !hasTouchEvents /* Firefox <= 63 */ || !!getComputedStyle(document.body).getPropertyValue('--hoverable');
hoverable = !('ontouchstart' in window) /* Firefox <= 63 */ || !!getComputedStyle(document.body).getPropertyValue('--hoverable');
return hoverable;
}

View File

@ -1,3 +0,0 @@
const hasTouchEvents = 'ontouchstart' in window;
export default hasTouchEvents

View File

@ -2,7 +2,6 @@ import StrongSocket from "./component/socket";
import { requestIdleCallback, formAjax, numberFormat, escapeHtml } from "./component/functions";
import makeChat from './component/chat';
import once from './component/once';
import hasTouchEvents from './component/touchEvents';
import spinnerHtml from './component/spinner';
import sri from './component/sri';
import { storage, tempStorage } from "./component/storage";
@ -26,7 +25,6 @@ export default function() {
const l = window.lichess;
l.StrongSocket = StrongSocket;
l.requestIdleCallback = requestIdleCallback;
l.hasTouchEvents = hasTouchEvents;
l.sri = sri;
l.storage = storage;
l.tempStorage = tempStorage;