Skip to content

Commit 725ab03

Browse files
committed
can't close practice widget in a practice study
1 parent 9098733 commit 725ab03

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

ui/analyse/src/ctrl.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ module.exports = function(opts) {
452452
this.setAutoShapes();
453453
if (this.retro) this.retro.onCeval();
454454
if (this.practice) this.practice.onCeval();
455-
if (this.study && this.study.practice) this.study.practice.onCeval();
455+
if (this.studyPractice) this.studyPractice.onCeval();
456456
m.redraw();
457457
}
458458
}.bind(this));
@@ -634,6 +634,7 @@ module.exports = function(opts) {
634634
this.startCeval();
635635
this.explorer.setNode();
636636
this.study = opts.study ? makeStudy(opts.study, this, (opts.tagTypes || '').split(','), opts.practice) : null;
637+
this.studyPractice = this.study ? this.study.practice : null;
637638

638639
this.retro = null;
639640

ui/analyse/src/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
m.redraw.strategy("diff"); // prevents double full redraw on page load
2323
return controller.study;
2424
},
25-
view: controller.study.practice ? studyPracticeView.main : studyView.main
25+
view: controller.studyPractice ? studyPracticeView.main : studyView.main
2626
});
2727

2828
return {

ui/analyse/src/practice/practiceView.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var opposite = require('chessground').util.opposite;
44
function renderTitle(close) {
55
return m('div.title', [
66
m('span', 'Practice with the computer'),
7-
m('span.close[data-icon=L]', {
7+
close ? m('span.close[data-icon=L]', {
88
onclick: close
9-
})
9+
}) : null
1010
]);
1111
}
1212

@@ -116,7 +116,7 @@ module.exports = function(root) {
116116
return m('div', {
117117
class: 'practice_box ' + (comment ? comment.verdict : '')
118118
}, [
119-
renderTitle(root.togglePractice),
119+
renderTitle(root.studyPractice ? null : root.togglePractice),
120120
m('div.feedback', !running ? renderOffTrack(ctrl) : (end ? renderEnd(root, end) : renderRunning(root))),
121121
running ? m('div.comment', comment ? [
122122
m('span.verdict', commentText[comment.verdict]),

ui/analyse/src/study/studyView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module.exports = {
172172
},
173173

174174
underboard: function(ctrl) {
175-
if (ctrl.study && ctrl.study.practice) return practiceView.underboard(ctrl.study);
175+
if (ctrl.studyPractice) return practiceView.underboard(ctrl.study);
176176
if (ctrl.embed) return;
177177
var glyphForm = glyphFormView(ctrl.study.glyphForm);
178178
var commentForm = commentFormView(ctrl.study.commentForm);

ui/analyse/src/view.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ function dataAct(e) {
173173
function buttons(ctrl) {
174174
var canJumpPrev = ctrl.vm.path !== '';
175175
var canJumpNext = !!ctrl.vm.node.children[0];
176-
var isStudyPractice = ctrl.study && ctrl.study.practice;
177176
return m('div.game_control', {
178177
config: bindOnce('mousedown', function(e) {
179178
var action = dataAct(e);
@@ -186,7 +185,7 @@ function buttons(ctrl) {
186185
else if (action === 'menu') ctrl.actionMenu.toggle();
187186
})
188187
}, [
189-
(isStudyPractice || ctrl.embed) ? null : m('div.features', [
188+
(ctrl.studyPractice || ctrl.embed) ? null : m('div.features', [
190189
m('button', {
191190
'data-hint': ctrl.trans('openingExplorer'),
192191
'data-act': 'explorer',
@@ -208,7 +207,7 @@ function buttons(ctrl) {
208207
jumpButton('X', 'next', canJumpNext),
209208
jumpButton('V', 'last', canJumpNext)
210209
]),
211-
isStudyPractice ? null : m('button', {
210+
ctrl.studyPractice ? null : m('button', {
212211
class: 'hint--bottom' + (ctrl.actionMenu.open ? ' active' : ''),
213212
'data-hint': 'Menu',
214213
'data-act': 'menu'

0 commit comments

Comments
 (0)