board editor code tweaks

v2
Thibault Duplessis 2019-05-04 15:52:17 +07:00
parent 7fb0d4e854
commit d9279f4062
2 changed files with 4 additions and 20 deletions

View File

@ -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();
}));
});
};

View File

@ -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();