add keyboard shortcut for zen mode

pull/3523/head
Thibault Duplessis 2017-08-25 10:00:23 -05:00
parent 5ba9a2f512
commit 2af36a8edf
4 changed files with 14 additions and 2 deletions

View File

@ -127,7 +127,7 @@
}
#dasher_app .selector a:hover::before {
opacity: 1;
color: #fff;
color: #3893E8;
}
#dasher_app .selector a.active::before {
opacity: 1;

View File

@ -77,7 +77,10 @@ export default function(ctrl: DasherCtrl): VNode {
const zenToggle = ctrl.opts.playing ? h('div.zen.selector', [
h('a', {
class: { active: !!ctrl.data.zen },
attrs: { 'data-icon': ctrl.data.zen ? 'E' : 'K' },
attrs: {
'data-icon': ctrl.data.zen ? 'E' : 'K',
title: 'Keyboard: z'
},
hook: bind('click', ctrl.toggleZen)
}, noarg('zenMode'))
]) : null;

View File

@ -645,6 +645,14 @@ export default class RoundController {
}
};
toggleZen = () => {
if (game.isPlayerPlaying(this.data)) {
const zen = !$('body').hasClass('zen');
$('body').toggleClass('zen', zen)
$.post('/pref/zen', { zen: zen ? 1 : 0 });
}
}
private delayedInit = () => {
if (game.isPlayerPlaying(this.data) && game.nbMoves(this.data, this.data.player.color) === 0 && !this.isSimulHost()) {
li.sound.genericNotify();

View File

@ -39,4 +39,5 @@ export function init(ctrl: RoundController) {
ctrl.redraw();
}));
k.bind('f', preventing(ctrl.flipNow));
k.bind('z', preventing(ctrl.toggleZen));
}