From f32d659d173669425cd19657f4831648910d9b0b Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sun, 9 Nov 2014 22:59:47 +0100 Subject: [PATCH] toggle analysis comments with keyboard --- app/views/analyse/replay.scala.html | 3 +-- ui/analyse/src/ctrl.js | 3 ++- ui/analyse/src/keyboard.js | 9 +++++++++ ui/analyse/src/view.js | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/views/analyse/replay.scala.html b/app/views/analyse/replay.scala.html index 2a235af1d3..7d6c6c264a 100644 --- a/app/views/analyse/replay.scala.html +++ b/app/views/analyse/replay.scala.html @@ -32,8 +32,7 @@ i18n: @round.jsI18n() You can also scroll over the board to move in the game. diff --git a/ui/analyse/src/ctrl.js b/ui/analyse/src/ctrl.js index 21d32c940e..3ac4abd36c 100644 --- a/ui/analyse/src/ctrl.js +++ b/ui/analyse/src/ctrl.js @@ -17,7 +17,8 @@ module.exports = function(cfg, router, i18n, onChange) { path: initialPath, pathStr: treePath.write(initialPath), situation: null, - continue: false + continue: false, + comments: true }; var situationCache = {}; diff --git a/ui/analyse/src/keyboard.js b/ui/analyse/src/keyboard.js index 80e822bc5c..c838aae137 100644 --- a/ui/analyse/src/keyboard.js +++ b/ui/analyse/src/keyboard.js @@ -30,4 +30,13 @@ module.exports = function(ctrl) { control.last(ctrl); m.redraw(); })); + k.bind('c', preventing(function() { + ctrl.vm.comments = !ctrl.vm.comments; + if (!ctrl.vm.comments && ctrl.vm.path.length > 1) { + path = [ctrl.vm.path[0]]; + path[0].variation = null; + ctrl.jump(path); + } + m.redraw(); + })); }; diff --git a/ui/analyse/src/view.js b/ui/analyse/src/view.js index da95f225e7..21e2613be7 100644 --- a/ui/analyse/src/view.js +++ b/ui/analyse/src/view.js @@ -78,6 +78,7 @@ function renderOpening(ctrl, opening) { } function renderMeta(ctrl, move, path) { + if (!ctrl.vm.comments) return; var opening = ctrl.data.game.opening; opening = (move && opening && opening.size == move.ply) ? renderOpening(ctrl, opening) : null; if (!move || (!opening && !move.comments.length && !move.variations.length)) return;