analysis: exit variation with shift+left or shift+h

This commit is contained in:
Thibault Duplessis 2015-04-08 01:21:37 +02:00
parent 80a83f8899
commit 0dddd28e3c
3 changed files with 20 additions and 1 deletions

View file

@ -77,5 +77,11 @@ module.exports = {
enterVariation: function(ctrl) {
if (canEnterVariation(ctrl))
ctrl.userJump(path.withVariation(ctrl.vm.path, 1));
},
exitVariation: function(ctrl) {
var p = ctrl.vm.path
if (p.length > 1)
ctrl.userJump(path.withoutVariation(p));
}
};

View file

@ -19,11 +19,15 @@ module.exports = function(ctrl) {
control.prev(ctrl);
m.redraw();
}));
k.bind(['shift+left', 'shift+h'], preventing(function() {
control.exitVariation(ctrl);
m.redraw();
}));
k.bind(['right', 'l'], preventing(function() {
control.next(ctrl);
m.redraw();
}));
k.bind('shift+right', preventing(function() {
k.bind(['shift+right', 'shift+l'], preventing(function() {
control.enterVariation(ctrl);
m.redraw();
}));

View file

@ -58,5 +58,14 @@ module.exports = {
variation: null
});
return p2;
},
withoutVariation: function(path) {
var p2 = path.slice(0, path.length - 1);
var last = p2.length - 1;
p2[last] = copy(p2[last], {
variation: null
});
return p2;
}
};