From d9279f406260960c70c8811194fddd9537c092ac Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sat, 4 May 2019 15:52:17 +0700 Subject: [PATCH] board editor code tweaks --- ui/editor/src/keyboard.js | 17 +++-------------- ui/editor/src/view.js | 7 +------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/ui/editor/src/keyboard.js b/ui/editor/src/keyboard.js index 6f8db8e020..c4d5f1276d 100644 --- a/ui/editor/src/keyboard.js +++ b/ui/editor/src/keyboard.js @@ -1,21 +1,10 @@ var k = Mousetrap; var m = require('mithril'); -function preventing(f) { - return function(e) { - if (e.preventDefault) { - e.preventDefault(); - } else { - // internet explorer - e.returnValue = false; - } - f(); - }; -} - module.exports = function(ctrl) { - k.bind('f', preventing(function() { + k.bind('f', function(e) { + e.preventDefault(); ctrl.chessground.toggleOrientation(); m.redraw(); - })); + }); }; diff --git a/ui/editor/src/view.js b/ui/editor/src/view.js index 836de06958..868286a94c 100644 --- a/ui/editor/src/view.js +++ b/ui/editor/src/view.js @@ -254,15 +254,12 @@ function sparePieces(ctrl, color, orientation, position) { function onSelectSparePiece(ctrl, s, upEvent) { return function(e) { + e.preventDefault(); if (['pointer', 'trash'].includes(s)) { ctrl.selected(s); } else { ctrl.selected('pointer'); - if (e.type === 'touchstart') { - e.preventDefault(); - } - dragNewPiece(ctrl.chessground.state, { color: s[0], role: s[1] @@ -292,8 +289,6 @@ function makeCursor(selected) { return 'url(' + url + '), default !important'; } -var eventNames = ['mousedown', 'touchstart']; - module.exports = function(ctrl) { var fen = ctrl.computeFen(); var color = ctrl.bottomColor();