board editor code tweaks
This commit is contained in:
parent
7fb0d4e854
commit
d9279f4062
|
@ -1,21 +1,10 @@
|
||||||
var k = Mousetrap;
|
var k = Mousetrap;
|
||||||
var m = require('mithril');
|
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) {
|
module.exports = function(ctrl) {
|
||||||
k.bind('f', preventing(function() {
|
k.bind('f', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
ctrl.chessground.toggleOrientation();
|
ctrl.chessground.toggleOrientation();
|
||||||
m.redraw();
|
m.redraw();
|
||||||
}));
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -254,15 +254,12 @@ function sparePieces(ctrl, color, orientation, position) {
|
||||||
|
|
||||||
function onSelectSparePiece(ctrl, s, upEvent) {
|
function onSelectSparePiece(ctrl, s, upEvent) {
|
||||||
return function(e) {
|
return function(e) {
|
||||||
|
e.preventDefault();
|
||||||
if (['pointer', 'trash'].includes(s)) {
|
if (['pointer', 'trash'].includes(s)) {
|
||||||
ctrl.selected(s);
|
ctrl.selected(s);
|
||||||
} else {
|
} else {
|
||||||
ctrl.selected('pointer');
|
ctrl.selected('pointer');
|
||||||
|
|
||||||
if (e.type === 'touchstart') {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
dragNewPiece(ctrl.chessground.state, {
|
dragNewPiece(ctrl.chessground.state, {
|
||||||
color: s[0],
|
color: s[0],
|
||||||
role: s[1]
|
role: s[1]
|
||||||
|
@ -292,8 +289,6 @@ function makeCursor(selected) {
|
||||||
return 'url(' + url + '), default !important';
|
return 'url(' + url + '), default !important';
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventNames = ['mousedown', 'touchstart'];
|
|
||||||
|
|
||||||
module.exports = function(ctrl) {
|
module.exports = function(ctrl) {
|
||||||
var fen = ctrl.computeFen();
|
var fen = ctrl.computeFen();
|
||||||
var color = ctrl.bottomColor();
|
var color = ctrl.bottomColor();
|
||||||
|
|
Loading…
Reference in a new issue