lila/public/javascripts/study/tour-chapter.js

92 lines
2.9 KiB
JavaScript
Raw Normal View History

2019-04-09 18:18:32 -06:00
function loadShepherd(f) {
2021-09-19 06:20:05 -06:00
var theme = 'shepherd-theme-' + ($('body').hasClass('dark') ? 'dark' : 'default');
2021-09-19 06:30:53 -06:00
lichess.loadCss('vendor/' + theme + '.css');
2021-02-06 06:26:05 -07:00
lichess.loadScript('vendor/shepherd/dist/js/tether.js', { noVersion: true }).then(function () {
lichess.loadScript('vendor/shepherd/dist/js/shepherd.min.js', { noVersion: true }).then(function () {
2019-04-09 18:18:32 -06:00
f(theme);
});
});
2021-02-06 06:26:05 -07:00
}
lichess.studyTourChapter = function (study) {
loadShepherd(function (theme) {
var onTab = function (tab) {
2016-05-21 08:42:37 -06:00
return {
2021-02-06 06:26:05 -07:00
'before-show': function () {
2016-05-21 08:42:37 -06:00
study.setTab(tab);
2021-02-06 06:26:05 -07:00
},
2016-05-21 08:05:16 -06:00
};
};
var tour = new Shepherd.Tour({
defaults: {
classes: theme,
2016-05-21 08:42:37 -06:00
scrollTo: false,
2021-02-06 06:26:05 -07:00
showCancelLink: true,
},
2016-05-21 08:05:16 -06:00
});
2021-02-06 06:26:05 -07:00
[
{
title: "Let's create a study chapter",
text:
'A study can have several chapters.<br>' +
'Each chapter has a distinct move tree,<br>' +
'and can be created in various ways.',
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap label[for=chapter-name] left',
2021-02-06 06:26:05 -07:00
},
{
title: 'From initial position',
text: 'Just a board setup for a new game.<br>' + 'Suited to explore openings.',
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap .tabs-horiz .init top',
2021-02-06 06:26:05 -07:00
when: onTab('init'),
},
{
title: 'Custom position',
text: 'Setup the board your way.<br>' + 'Suited to explore endgames.',
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap .tabs-horiz .edit bottom',
2021-02-06 06:26:05 -07:00
when: onTab('edit'),
},
{
title: 'Load an existing lichess game',
text:
'Paste a lichess game URL<br>' + '(like lichess.org/7fHIU0XI)<br>' + 'to load the game moves in the chapter.',
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap .tabs-horiz .game top',
2021-02-06 06:26:05 -07:00
when: onTab('game'),
},
{
title: 'From a FEN string',
text:
'Paste a position in FEN format<br>' +
'<i>4k3/4rb2/8/7p/8/5Q2/1PP5/1K6 w</i><br>' +
'to start the chapter from a position.',
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap .tabs-horiz .fen top',
2021-02-06 06:26:05 -07:00
when: onTab('fen'),
},
{
title: 'From a PGN game',
text: 'Paste a game in PGN format.<br>' + 'to load moves, comments and variations in the chapter.',
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap .tabs-horiz .pgn top',
2021-02-06 06:26:05 -07:00
when: onTab('pgn'),
},
{
title: 'Studies support variants',
text: 'Yes, you can study crazyhouse,<br>' + 'and all lichess variants!',
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap label[for=chapter-variant] left',
2021-02-06 06:26:05 -07:00
when: onTab('init'),
},
{
title: 'Thanks for your time',
text: 'Chapters are saved forever.<br>' + 'Have fun organizing your chess content!',
buttons: [
{
text: 'Done',
action: tour.next,
},
],
2021-07-16 06:56:47 -06:00
attachTo: '#modal-wrap .help bottom',
2021-02-06 06:26:05 -07:00
},
].forEach(function (s) {
2016-05-21 08:42:37 -06:00
tour.addStep(s.title, s);
2016-05-21 08:05:16 -06:00
});
tour.start();
});
};