bookwyrm/bookwyrm/templates/guided_tour/search.html
Hugh Rundle 3f67bc3b61 standardise ids for tour anchors
To make it harder to accidentally mess up the tour when making changes to pages, this commit adds ids with 'tour' prefixes to (nearly) all elements used by the guided tour as anchor points. The exception is where an element already had an id that is being used by something else in Bookwyrm.

Some minor changes also made to clean up the wording of the tour.
2022-07-03 15:57:10 +10:00

171 lines
5.4 KiB
HTML

{% load i18n %}
<script>
let localResult = document.querySelector(".local-book-search-result");
let remoteResult = document.querySelector(".remote-book-search-result");
let otherCatalogues = document.querySelector("#tour-load-from-other-catalogues");
let manuallyAdd = document.querySelector("#tour-manually-add-book");
const tour = new Shepherd.Tour({
exitOnEsc: true,
});
console.log("remote", remoteResult)
if (remoteResult) {
tour.addStep(
{
text: "{% trans 'If the book you are looking for is available on a remote catalogue such as Open Library, click on' %}\
<code>\
{% trans 'Import book' %}\
</code>.",
title: "{% trans 'Searching' %}",
attachTo: {
element: "#tour-remote-search-result",
on: "top",
},
buttons: [
{
action() {
disableGuidedTour(csrf_token);
return this.complete();
},
secondary: true,
text: "{% trans 'End Tour' %}",
classes: "is-danger guided-tour-cancel-button",
},
{
action() {
return this.next();
},
text: "{% trans 'Next' %}",
},
],
});
} else if (localResult) {
tour.addStep(
{
text: "{% trans 'If the book you are looking for is already on this server, you can click on the title to go to the book\'s page.' %}",
title: "{% trans 'Searching' %}",
attachTo: {
element: "#tour-local-book-search-result",
on: "top",
},
buttons: [
{
action() {
disableGuidedTour(csrf_token);
return this.complete();
},
secondary: true,
text: "{% trans 'End Tour' %}",
classes: "is-danger guided-tour-cancel-button",
},
{
action() {
return this.next();
},
text: "{% trans 'Next' %}",
},
],
});
}
if (otherCatalogues) {
tour.addStep({
text: "{% trans 'If the book you are looking for is not listed, try loading more records from other sources like Open Library or Inventaire.' %}",
title: "{% trans 'Load more records' %}",
attachTo: {
element: "#tour-load-from-other-catalogues",
on: "right",
},
buttons: [
{
action() {
return this.back();
},
secondary: true,
text: "{% trans 'Back' %}",
},
{
action() {
return this.next();
},
text: "{% trans 'Next' %}",
},
],
})
}
if (manuallyAdd) {
tour.addSteps([
{
text: "{% trans 'If your book is not in the results, try adjusting your search terms.' %}",
title: "{% trans 'Search again' %}",
attachTo: {
element: '#tour-search-page-input',
on: "right",
},
buttons: [
{
action() {
return this.back();
},
secondary: true,
text: "{% trans 'Back' %}",
},
{
action() {
return this.next();
},
text: "{% trans 'Next' %}",
},
],
},
{
text: "{% trans 'If you still can\'t find your book, you can add a record manually.' %}",
title: "{% trans 'Add a record manally' %}",
attachTo: {
element: "#tour-manually-add-book",
on: "right",
},
buttons: [
{
action() {
return this.back();
},
secondary: true,
text: "{% trans 'Back' %}",
},
{
action() {
return this.next();
},
text: "{% trans 'Next' %}",
},
],
}])
}
tour.addStep({
text: "{% trans 'Import, manually add, or view an existing book to continue the tour.' %}",
title: "{% trans 'Continue the tour' %}",
buttons: [
{
action() {
return this.back();
},
secondary: true,
text: "{% trans 'Back' %}",
},
{
action() {
return this.next();
},
text: "{% trans 'Ok' %}",
},
],
})
tour.start()
</script>