make round next button glow

This commit is contained in:
Thibault Duplessis 2015-04-07 22:37:06 +02:00
parent 8f524daf93
commit 79325df085
4 changed files with 13 additions and 6 deletions

View file

@ -27,9 +27,14 @@ function aborted(data) {
return data.game.status.id == ids.aborted;
}
function playing(data) {
return started(data) && !finished(data) && !aborted(data);
}
module.exports = {
ids: ids,
started: started,
finished: finished,
aborted: aborted
aborted: aborted,
playing: playing
};

View file

@ -71,8 +71,7 @@ module.exports = function(opts) {
this.apiMove = function(o) {
m.startComputation();
if (this.replay.active) this.replay.vm.late = true;
else this.chessground.apiMove(o.from, o.to);
if (!this.replay.active) this.chessground.apiMove(o.from, o.to);
if (this.data.game.threefold) this.data.game.threefold = false;
this.data.game.moves.push(o.san);
game.setOnGame(this.data, o.color, true);

View file

@ -1,5 +1,6 @@
var Chess = require('chessli.js').Chess;
var game = require('game').game;
var status = require('game').status;
var xhr = require('../xhr');
module.exports = function(root) {
@ -10,7 +11,6 @@ module.exports = function(root) {
this.ply = 0;
this.vm = {
late: false,
hash: ''
};
@ -62,7 +62,6 @@ module.exports = function(root) {
var disable = function() {
this.ply = 0;
this.vm.late = false;
root.chessground.set({
movable: {
color: game.isPlayerPlaying(root.data) ? root.data.player.color : null,
@ -99,4 +98,8 @@ module.exports = function(root) {
d.pref.replay === 1 && (d.game.speed === 'classical' || d.game.speed === 'unlimited')
);
}.bind(this);
this.isLate = function() {
return this.active && status.playing(root.data);
}.bind(this);
}

View file

@ -88,7 +88,7 @@ function renderButtons(ctrl, curPly) {
return m('a', {
class: 'button ' + b[0] + ' ' + classSet({
disabled: (ctrl.broken || !enabled),
glowing: ctrl.vm.late && b[0] === 'last'
glowing: b[0] === 'last' && ctrl.isLate()
}),
'data-icon': b[1],
onclick: enabled ? partial(ctrl.jump, b[2]) : null