blob: 9490780de1622e5c8324f9f6d36dcba96f164040 [file] [log] [blame]
hebasta75cfca52019-02-19 13:15:27 +01001/**
2 * Guided Tour to explain the UI
3 *
4 * @author Helge Stallkamp
5 */
Akrone51eaa32020-11-10 09:35:53 +01006"use strict";
hebasta75cfca52019-02-19 13:15:27 +01007
Akrone51eaa32020-11-10 09:35:53 +01008define(['lib/intro', 'vc', 'hint', 'menu', 'vc/doc', 'vc/docgroup'],
9 function(introClass, vcClass, hintClass, menuClass, docClass, docGroup) {
hebasta5df796f2019-05-21 15:27:12 +020010
hebasta75cfca52019-02-19 13:15:27 +010011 //needed for localization of labels and contents of the tour
12 const loc = KorAP.Locale;
hebasta5df796f2019-05-21 15:27:12 +020013
hebastaa84c7a92021-10-26 21:12:40 +020014 //labels for nextStep, previousStep and done
hebasta75cfca52019-02-19 13:15:27 +010015 loc.TOUR_lprev = loc.TOUR_lprev || "Back";
16 loc.TOUR_lnext = loc.TOUR_lnext || "Next";
17 loc.TOUR_ldone = loc.TOUR_ldone || "Done";
hebastaca61f812019-11-11 22:25:27 +010018 loc.TOUR_ldoneSearch = loc.TOUR_ldoneSearch || "Search";
19
hebasta5df796f2019-05-21 15:27:12 +020020 //localization guided tour gTstartSearch
hebastaa84c7a92021-10-26 21:12:40 +020021 loc.TOUR_welcti = loc.TOUR_welcti || "<span class='tgreeting'> Welcome to our guided tour! </span>";
22 loc.TOUR_welc = loc.TOUR_welc || "This tour should give you a quick introduction to KorAP. " +
hebasta84a7e0e2021-11-03 19:11:33 +010023 "We lead you step by step through an example.";
hebastaf898d7b2021-12-06 14:32:06 +010024 loc.TOUR_sear1ti = loc.TOUR_sear1ti || "Query";
25 loc.TOUR_sear1 = loc.TOUR_sear1 || "Enter your query here, for example the search for '" + loc.TOUR_Qexample + "'.";
26 loc.TOUR_searAnnotti = loc.TOUR_searAnnotti || "Annotation Assistant (1)";
27 loc.TOUR_searAnnot = loc.TOUR_searAnnot || "<p> For querying annotations you can use the annotation assistant. </p> " +
28 "<p> Click the orange bar " +
29 "or press the down arrow key &darr; for display. </p>";
30 loc.TOUR_annotAssti = loc.TOUR_annotAssti || "Annotation Assistant (2)";
31 loc.TOUR_annotAss = loc.TOUR_annotAss || "The annotation assistant helps in formulating queries by listing various annotation foundries and layers.";
32 loc.TOUR_vccho1ti = loc.TOUR_vccho1ti || "Corpora Selection",
33 loc.TOUR_vccho1 = loc.TOUR_vccho1 || "Click here to show the corpus assistant.";
hebastafa118342021-11-02 19:56:01 +010034 loc.TOUR_vccho2ti = loc.TOUR_vccho2ti || "Corpus Assistant (1)";
hebastaf898d7b2021-12-06 14:32:06 +010035 loc.TOUR_vccho2 = loc.TOUR_vccho2 || "With the help of the assistant you can define virtual corpora on the basis of metadata.";
hebastafa118342021-11-02 19:56:01 +010036 loc.TOUR_vccho3ti = loc.TOUR_vccho3ti || "Corpus Assistant (2)";
hebastaf898d7b2021-12-06 14:32:06 +010037 loc.TOUR_vccho3 = loc.TOUR_vccho3 || "A drop down box lists some of the available metadata fields.";
hebastafa118342021-11-02 19:56:01 +010038 loc.TOUR_vccho4ti = loc.TOUR_vccho4ti || "Corpus Assistant (3)";
Marc Kupietzbe90c942024-10-01 17:25:30 +020039 loc.TOUR_vccho4 = loc.TOUR_vccho4 || "This example defines a virtual corpus consisting of all texts published in " + loc.TOUR_pubDate + ".";
hebastaf898d7b2021-12-06 14:32:06 +010040 loc.TOUR_vcStat1ti = loc.TOUR_vcStat1ti || "Corpus Statistics (1)";
41 loc.TOUR_vcStat1 = loc.TOUR_vcStat1 || "Click here to display the corpus statistics.";
42 loc.TOUR_vcStat2ti = loc.TOUR_vcStat2ti || "Corpus Statistics (2)";
43 loc.TOUR_vcStat2 = loc.TOUR_vcStat2 || "Here you can see the corpus statistics.";
44 loc.TOUR_qlfieldti = loc.TOUR_qlfieldti ||"Query Languages";
45 loc.TOUR_qlfield = loc.TOUR_qlfield|| "You can use KorAP with different query languages. Choose your preferred query language here. ";
46 loc.TOUR_helpti = loc.TOUR_helpti || "Help";
hebasta14bb8552021-11-10 16:35:31 +010047 loc.TOUR_help = loc.TOUR_help || "Here you can find help and information about KorAP.";
hebastaf898d7b2021-12-06 14:32:06 +010048 loc.TOUR_glimpseti = loc.TOUR_glimpseti || "Glimpse";
hebastaca61f812019-11-11 22:25:27 +010049 loc.TOUR_glimpse = loc.TOUR_glimpse || "Select this to show only the first hits in undefined order.";
hebastaf898d7b2021-12-06 14:32:06 +010050 loc.TOUR_seargoti = loc.TOUR_seargoti || "Query";
51 loc.TOUR_seargo = loc.TOUR_seargo || "Start the search by clicking the magnifying glass.";
hebasta87f1b1f2019-07-30 13:03:23 +020052
hebasta5df796f2019-05-21 15:27:12 +020053 //localization guided Tour gTshowResults
Helge0115e7e2025-03-24 16:10:24 +010054 loc.TOUR_nokwicti = loc.TOUR_nokwicti || "The search has no results, therefore the tour ends here.";
hebasta14bb8552021-11-10 16:35:31 +010055 loc.TOUR_kwicti = loc.TOUR_kwicti || "Results";
hebastaf898d7b2021-12-06 14:32:06 +010056 loc.TOUR_kwic = loc.TOUR_kwic || "The results of the query are displayed as KWIC (keyword in context). On the left side, you can see the according text sigle.";
57 loc.TOUR_snippetti = loc.TOUR_snippetti || "KWIC (2)";
hebasta87f1b1f2019-07-30 13:03:23 +020058 loc.TOUR_snippet = loc.TOUR_snippet || "Click on a match to show a larger snippet.";
hebasta14bb8552021-11-10 16:35:31 +010059 loc.TOUR_snippetbti = loc.TOUR_snippetbti || "Snippet";
hebastaf898d7b2021-12-06 14:32:06 +010060 loc.TOUR_snippetb = loc.TOUR_snippetb || "At the bottom of the snippet, there is a group of buttons to show more result views.";
61 loc.TOUR_metadatabti = loc.TOUR_metadatabti || "Metadata (1)";
62 loc.TOUR_metadatab = loc.TOUR_metadatab || "Click here to display the metadata.";
63 loc.TOUR_metadatati = loc.TOUR_metadatati || "Metadata (2)";
hebasta14bb8552021-11-10 16:35:31 +010064 loc.TOUR_metadata = loc.TOUR_metadata || "Display of metadata";
65 loc.TOUR_tokenbti = loc.TOUR_tokenbti || "Token Annotations";
hebastaf898d7b2021-12-06 14:32:06 +010066 loc.TOUR_tokenb = loc.TOUR_tokenb || "Click here to show the token annotations.";
hebasta14bb8552021-11-10 16:35:31 +010067 loc.TOUR_tokenti = loc.TOUR_tokenti || "Annotations";
hebasta87f1b1f2019-07-30 13:03:23 +020068 loc.TOUR_token = loc.TOUR_token || "KorAP supports multiple annotations.";
hebastaf898d7b2021-12-06 14:32:06 +010069 loc.TOUR_treebti = loc.TOUR_treebti || "Relational Annotations (1)";
70 loc.TOUR_treeb = loc.TOUR_treeb || "Click here to display relational annotations.";
71 loc.TOUR_treeti = loc.TOUR_treeti || "Relational Annotations (2)"
72 loc.TOUR_tree = loc.TOUR_tree || "Relational annotations can be displayed as tree and arch views."
hebasta87f1b1f2019-07-30 13:03:23 +020073 loc.TOUR_tourdone = loc.TOUR_tourdone || "Have fun with KorAP!";
hebasta14bb8552021-11-10 16:35:31 +010074
hebasta75cfca52019-02-19 13:15:27 +010075
76 //localization of button labels
hebastaee7b8a82020-01-20 12:45:04 +010077 let labelOpts= {
hebasta5df796f2019-05-21 15:27:12 +020078 'prevLabel': loc.TOUR_lprev,
79 'nextLabel': loc.TOUR_lnext,
80 'doneLabel': loc.TOUR_ldone,
hebastaee7b8a82020-01-20 12:45:04 +010081 'showStepNumbers': false
82 };
83
84 //usability options of tours
85 let usabilityOpts ={
86 'showBullets': false,
hebastaa84c7a92021-10-26 21:12:40 +020087 'overlayOpacity': 0.5,
hebastaee7b8a82020-01-20 12:45:04 +010088 'exitOnOverlayClick': false,
hebastaa84c7a92021-10-26 21:12:40 +020089 'disableInteraction': true,
90 'tooltipClass': 'customTooltip',
hebastaee7b8a82020-01-20 12:45:04 +010091 'hidePrev': true
hebasta75cfca52019-02-19 13:15:27 +010092 };
hebasta87f1b1f2019-07-30 13:03:23 +020093
94 var doe = document;
hebasta5df796f2019-05-21 15:27:12 +020095
hebasta75cfca52019-02-19 13:15:27 +010096 return{
hebasta5df796f2019-05-21 15:27:12 +020097
hebasta75cfca52019-02-19 13:15:27 +010098 /**
hebasta5df796f2019-05-21 15:27:12 +020099 * Guided Tour gTstartSearch: Explains the search functionality
hebasta75cfca52019-02-19 13:15:27 +0100100 */
hebasta5df796f2019-05-21 15:27:12 +0200101 gTstartSearch:function(elparam){
hebasta5df796f2019-05-21 15:27:12 +0200102 let intro = introClass();
hebastaee7b8a82020-01-20 12:45:04 +0100103 intro.setOptions(labelOpts);
hebastaca61f812019-11-11 22:25:27 +0100104 /*
105 * Sets button labels for the last step of the tour
106 * Because Kalamar is a multipage webapplication, this tours starts by
107 * completion the gTshowResults Tour. Therefore the label of the done button changed.
108 */
109 intro.setOption('doneLabel', loc.TOUR_ldoneSearch );
hebastaee7b8a82020-01-20 12:45:04 +0100110 intro.setOptions(usabilityOpts);
hebastaca61f812019-11-11 22:25:27 +0100111
hebasta5df796f2019-05-21 15:27:12 +0200112 //for testing purposes
hebasta75cfca52019-02-19 13:15:27 +0100113 if(elparam){
114 doe = elparam;
115 }
hebasta5df796f2019-05-21 15:27:12 +0200116
hebasta75cfca52019-02-19 13:15:27 +0100117 let input = doe.querySelector("#q-field");
118 input.value="";
119
hebasta5df796f2019-05-21 15:27:12 +0200120
hebasta75cfca52019-02-19 13:15:27 +0100121 //steps of the example tour
122 let Steps =[
hebastafa118342021-11-02 19:56:01 +0100123 //Step 1, intro_item 0
hebasta2f7e5402021-11-02 20:09:38 +0100124 {
hebastaa84c7a92021-10-26 21:12:40 +0200125 title: loc.TOUR_welcti,
hebasta1e2d98e2019-10-30 15:58:17 +0100126 intro: loc.TOUR_welc,
127 },
hebastafa118342021-11-02 19:56:01 +0100128 //Step 2, intro_item 1
hebasta1e2d98e2019-10-30 15:58:17 +0100129 {
hebasta84a7e0e2021-11-03 19:11:33 +0100130 title: loc.TOUR_sear1ti,
hebastaf95226b2019-09-19 11:37:00 +0200131 element: '#q-field',
hebasta75cfca52019-02-19 13:15:27 +0100132 intro: loc.TOUR_sear1,
133 position: 'bottom'
134 },
hebastafa118342021-11-02 19:56:01 +0100135 //Step 3, intro_item 2
hebasta75cfca52019-02-19 13:15:27 +0100136 {
hebasta84a7e0e2021-11-03 19:11:33 +0100137 title: loc.TOUR_searAnnotti,
hebasta75cfca52019-02-19 13:15:27 +0100138 element: '#hint',
139 intro: loc.TOUR_searAnnot,
hebastafa118342021-11-02 19:56:01 +0100140 position: 'auto'
hebasta5df796f2019-05-21 15:27:12 +0200141 },
hebastafa118342021-11-02 19:56:01 +0100142 //Step 4, intro_item 3
hebasta5df796f2019-05-21 15:27:12 +0200143 {
hebasta84a7e0e2021-11-03 19:11:33 +0100144 title: loc.TOUR_annotAssti,
hebastaf95226b2019-09-19 11:37:00 +0200145 element: doe.querySelector("#hint > .menu.hint"),
146 intro: loc.TOUR_annotAss,
147 position: 'bottom',
hebastafa118342021-11-02 19:56:01 +0100148 },
149 //Step 5, intro_item 4
hebastaf95226b2019-09-19 11:37:00 +0200150 {
hebastafa118342021-11-02 19:56:01 +0100151 title: loc.TOUR_vccho1ti,
hebasta75cfca52019-02-19 13:15:27 +0100152 element:'#vc-choose',
153 intro: loc.TOUR_vccho1,
154 position: "bottom",
hebasta5df796f2019-05-21 15:27:12 +0200155 },
hebastafa118342021-11-02 19:56:01 +0100156 //Step 6, intro_item 5
hebasta5df796f2019-05-21 15:27:12 +0200157 {
hebasta84a7e0e2021-11-03 19:11:33 +0100158 title: loc.TOUR_vccho2ti,
hebasta5df796f2019-05-21 15:27:12 +0200159 element:'#vc-view',
160 intro: loc.TOUR_vccho2,
161 position: "bottom",
162 },
hebastafa118342021-11-02 19:56:01 +0100163 //Step 7, intro_item 6
164 {
165 title: loc.TOUR_vccho3ti,
166 element: doe.querySelector('#vc-view * .doc > menu'),
167 intro: loc.TOUR_vccho3,
168 position: "left",
169 },
170 //Step 8, intro_item 7
171 {
172 title: loc.TOUR_vccho4ti,
173 element: doe.querySelector('#vc-view * .doc'),
174 intro: loc.TOUR_vccho4,
175 position: "left",
176 },
177 //Step 9, intro_item 8
hebasta5df796f2019-05-21 15:27:12 +0200178 {
hebasta84a7e0e2021-11-03 19:11:33 +0100179 title: loc.TOUR_vcStat1ti,
hebastad090a512019-07-10 16:36:01 +0200180 element: doe.querySelector('.statistic'),
hebasta94e47cb2019-07-24 22:24:27 +0200181 intro: loc.TOUR_vcStat1,
hebastad090a512019-07-10 16:36:01 +0200182 position: "left",
183 },
hebastafa118342021-11-02 19:56:01 +0100184 //Step 10, intro_item 9
hebastad090a512019-07-10 16:36:01 +0200185 {
hebasta84a7e0e2021-11-03 19:11:33 +0100186 title: loc.TOUR_vcStat2ti,
hebasta94e47cb2019-07-24 22:24:27 +0200187 element: doe.querySelector('.stattable'),
188 intro: loc.TOUR_vcStat2,
189 position: "bottom",
190 },
hebastafa118342021-11-02 19:56:01 +0100191 //Step 11, intro_item 10
hebasta94e47cb2019-07-24 22:24:27 +0200192 {
hebasta84a7e0e2021-11-03 19:11:33 +0100193 title: loc.TOUR_qlfieldti,
hebasta5df796f2019-05-21 15:27:12 +0200194 element: doe.querySelector('#ql-field').parentNode,
195 intro: loc.TOUR_qlfield,
196 position: "bottom",
197 },
198 {
hebasta84a7e0e2021-11-03 19:11:33 +0100199 title: loc.TOUR_glimpseti,
hebastabd53f822021-10-26 21:50:06 +0200200 element: doe.querySelector('#glimpse').parentNode,
hebasta5df796f2019-05-21 15:27:12 +0200201 intro: loc.TOUR_glimpse,
202 position: "bottom",
203 },
204 {
hebasta84a7e0e2021-11-03 19:11:33 +0100205 title: loc.TOUR_helpti,
hebasta5df796f2019-05-21 15:27:12 +0200206 element:'#view-tutorial',
207 intro: loc.TOUR_help,
208 position: "bottom",
209 },
210 {
hebasta84a7e0e2021-11-03 19:11:33 +0100211 title: loc.TOUR_seargoti,
hebasta5df796f2019-05-21 15:27:12 +0200212 element: '#qsubmit',
213 intro: loc.TOUR_seargo,
214 position: "bottom",
215 },
216 ];
217
hebasta75cfca52019-02-19 13:15:27 +0100218 //pass in the Steps array created earlier
hebasta87f1b1f2019-07-30 13:03:23 +0200219 intro.setOptions({steps: Steps});
220 this.testPrerequ(Steps, intro);
hebastaca61f812019-11-11 22:25:27 +0100221
hebasta5df796f2019-05-21 15:27:12 +0200222 //changes before executing the single steps
223 intro.onbeforechange(function(targetedElement){
224 switch(targetedElement.id){
hebastaf95226b2019-09-19 11:37:00 +0200225 case "q-field":
hebastad090a512019-07-10 16:36:01 +0200226 /*
227 * TODO:
228 * #268 is not merged at the time beeing:
229 * introJs.currentStep() merge requested https://github.com/usablica/intro.js/pull/268/files
230 */
hebastaf95226b2019-09-19 11:37:00 +0200231 targetedElement.value = loc.TOUR_Qexample;
hebasta5df796f2019-05-21 15:27:12 +0200232 break;
hebasta5df796f2019-05-21 15:27:12 +0200233 case "vc-view":
Akron0b37f3e2021-02-09 10:32:03 +0100234 let vchoo = doe.querySelector("#vc-choose");
235 let vcv = doe.querySelector("#vc-view");
hebasta5df796f2019-05-21 15:27:12 +0200236 if(!(vcv.querySelector(".active"))){
237 vchoo.click();
hebastad090a512019-07-10 16:36:01 +0200238 /*
239 * Intro.js caches elements at the beginning, so element and position has to be set again.
240 */
hebastafa118342021-11-02 19:56:01 +0100241 intro._introItems[8].element = doe.querySelector('.statistic');
242 intro._introItems[8].position = "left";
hebasta5df796f2019-05-21 15:27:12 +0200243 }
hebastafa118342021-11-02 19:56:01 +0100244 intro._introItems[7].element = doe.querySelector('#vc-view * .doc');
245 intro._introItems[7].position = "left";
246 break;
Helgef4107f12025-02-27 12:15:18 +0100247 }
248 /*
249 * Hides the tutorial. If it is opened in an iframe the searchbar which is needed for the tour is not visible anymore.
250 */
251 if(this._currentStep == 1){
Helge3567e332025-03-24 17:40:28 +0100252 if(doe.querySelector('#tutorial')){
Helgef4107f12025-02-27 12:15:18 +0100253 let tutel = doe.querySelector('#tutorial');
254 tutel.style.display = 'none';
Helge3567e332025-03-24 17:40:28 +0100255 }
Helgef4107f12025-02-27 12:15:18 +0100256 }
hebastafa118342021-11-02 19:56:01 +0100257 if(this._currentStep == 9){
hebasta94e47cb2019-07-24 22:24:27 +0200258 let statbut = doe.querySelector('.statistic');
259 statbut.click();
hebastafa118342021-11-02 19:56:01 +0100260 intro._introItems[9].element = doe.querySelector(".stattable");
261 intro._introItems[9].position = "bottom";
hebasta94e47cb2019-07-24 22:24:27 +0200262 }
hebasta75cfca52019-02-19 13:15:27 +0100263 });
hebasta5df796f2019-05-21 15:27:12 +0200264
hebastaf95226b2019-09-19 11:37:00 +0200265 intro.onbeforeexit(function(){
266 if(KorAP.Hint.active() && KorAP.Hint.active().dontHide){
267 KorAP.Hint.unshow();
268 }
hebastafa118342021-11-02 19:56:01 +0100269 if (KorAP._vcKeyMenu.dontHide){
270 KorAP._vcKeyMenu.dontHide = false;
271 KorAP._vcKeyMenu.hide();
272 }
hebastaf95226b2019-09-19 11:37:00 +0200273 });
274
275 intro.onchange(function(targetElement) {
276 var that = this;
277 switch(this._currentStep){
278 //hides Hint if back button is pressed
hebastaee7b8a82020-01-20 12:45:04 +0100279 case 2:
hebastaf95226b2019-09-19 11:37:00 +0200280 if(KorAP.Hint.active()){
281 KorAP.Hint.unshow();
282 }
283 break;
hebastaee7b8a82020-01-20 12:45:04 +0100284 case 3:
hebastaf95226b2019-09-19 11:37:00 +0200285 KorAP.Hint.show(false);
286 KorAP.Hint.active().dontHide = true;
hebastaee7b8a82020-01-20 12:45:04 +0100287 intro._introItems[3].element = doe.querySelector(".menu.roll.hint");
288 intro._introItems[3].position = doe.querySelector("bottom");
hebastaf95226b2019-09-19 11:37:00 +0200289 break;
hebastaee7b8a82020-01-20 12:45:04 +0100290 case 4:
hebastafa118342021-11-02 19:56:01 +0100291 KorAP.Hint.unshow();
292 KorAP._vcKeyMenu.dontHide = false;
hebastaf95226b2019-09-19 11:37:00 +0200293 break;
hebastafa118342021-11-02 19:56:01 +0100294 case 6:
295 let vccbut = doe.querySelector('#vc-view * .doc > span');
296 vccbut.click();
297 KorAP._vcKeyMenu.dontHide = true;
298 intro._introItems[6].element = doe.querySelector('#vc-view * .menu.roll');
299 intro._introItems[6].position = "left";
300 break;
301 case 7:
302 KorAP._vcKeyMenu.dontHide = false;
303 KorAP._vcKeyMenu.hide();
304 KorAP.vc.fromJson(loc.TOUR_vcQuery);
305 intro._introItems[7].element = doe.querySelector('#vc-view * .doc');
306 intro._introItems[7].position = "left";
hebastaf95226b2019-09-19 11:37:00 +0200307 }
308 });
309
hebasta5df796f2019-05-21 15:27:12 +0200310 // Execute at the end of the tour (By clicking at the done-Button)
311 intro.oncomplete(function(){
312 KorAP.session.set("tour", true);
hebasta94e47cb2019-07-24 22:24:27 +0200313 doe.getElementById("qsubmit").click();
hebasta5df796f2019-05-21 15:27:12 +0200314 });
315
316 return intro;
hebasta75cfca52019-02-19 13:15:27 +0100317 },
hebasta5df796f2019-05-21 15:27:12 +0200318
319
320 /* Guided Tour to explain the different views of the results */
hebastaca61f812019-11-11 22:25:27 +0100321 gTshowResults: function(elparam){
322
323 let tourR = introClass();
hebastaee7b8a82020-01-20 12:45:04 +0100324 tourR.setOptions(usabilityOpts);
hebastaca61f812019-11-11 22:25:27 +0100325
hebasta87f1b1f2019-07-30 13:03:23 +0200326 //for testing purposes
hebasta5df796f2019-05-21 15:27:12 +0200327 if(elparam){
328 doe = elparam;
329 }
hebasta5df796f2019-05-21 15:27:12 +0200330 let StepsSR = [
hebasta87f1b1f2019-07-30 13:03:23 +0200331 //Step 1, intro_item 0
hebasta14bb8552021-11-10 16:35:31 +0100332 {
333 title: loc.TOUR_kwicti,
hebasta87f1b1f2019-07-30 13:03:23 +0200334 element: '#search',
335 intro: loc.TOUR_kwic ,
336 position: "auto",
337 },
338 //Step 2, intro_item 1
hebasta14bb8552021-11-10 16:35:31 +0100339 {
340 title: loc.TOUR_snippetti,
hebasta87f1b1f2019-07-30 13:03:23 +0200341 element: doe.querySelector("#search > ol > li"),
342 intro: loc.TOUR_snippet,
343 position: "bottom",
344 },
345 //Step 3, intro_item 2
hebasta14bb8552021-11-10 16:35:31 +0100346 {
347 title: loc.TOUR_snippetbti,
hebasta87f1b1f2019-07-30 13:03:23 +0200348 element: doe.querySelector("#search > ol > li"),
349 intro: loc.TOUR_snippetb,
350 position: "bottom",
351 },
352 //Step 4, intro_item 3
hebasta14bb8552021-11-10 16:35:31 +0100353 {
354 title: loc.TOUR_metadatabti,
hebasta87f1b1f2019-07-30 13:03:23 +0200355 element: doe.querySelector(".action > .metatable"),
356 intro: loc.TOUR_metadatab,
357 position: "bottom",
358 },
359 //Step 5, intro_item 4
hebasta14bb8552021-11-10 16:35:31 +0100360 {
361 title: loc.TOUR_metadatati,
hebasta87f1b1f2019-07-30 13:03:23 +0200362 element: doe.querySelector(".view.metatable"),
363 intro: loc.TOUR_metadata,
364 position: "auto",
365 },
366 //Step 6, intro_item 5
hebasta14bb8552021-11-10 16:35:31 +0100367 {
368 title: loc.TOUR_tokenbti,
hebasta87f1b1f2019-07-30 13:03:23 +0200369 element: doe.querySelector(".action > .info"),
370 intro: loc.TOUR_tokenb,
371 position: "bottom",
372 },
373 //Step 7, intro_item 6
hebasta14bb8552021-11-10 16:35:31 +0100374 {
375 title: loc.TOUR_tokenti,
hebasta87f1b1f2019-07-30 13:03:23 +0200376 element: doe.querySelector(".view.tokentable"),
377 intro: loc.TOUR_token,
378 position: "auto",
379 },
380 //Step 8, intro_item 7
hebasta14bb8552021-11-10 16:35:31 +0100381 {
382 title: loc.TOUR_treebti,
hebasta87f1b1f2019-07-30 13:03:23 +0200383 element: doe.querySelector(".tree"),
384 intro: loc.TOUR_treeb,
385 position: "bottom",
386 },
387 //Step 9, intro_item 8
hebasta14bb8552021-11-10 16:35:31 +0100388 {
389 title: loc.TOUR_treeti,
hebastaf95226b2019-09-19 11:37:00 +0200390 element: doe.querySelector(".view.relations"),
hebasta87f1b1f2019-07-30 13:03:23 +0200391 intro: loc.TOUR_tree,
hebastaf95226b2019-09-19 11:37:00 +0200392 position: "bottom",
hebasta87f1b1f2019-07-30 13:03:23 +0200393 },
394 //Step 10, intro_item 9
395 {
396 intro: loc.TOUR_tourdone,
397 }
hebasta5df796f2019-05-21 15:27:12 +0200398 ]
hebasta5df796f2019-05-21 15:27:12 +0200399
hebasta87f1b1f2019-07-30 13:03:23 +0200400 tourR.setOptions({steps:StepsSR});
hebastaee7b8a82020-01-20 12:45:04 +0100401 tourR.setOptions(labelOpts);
hebastaf95226b2019-09-19 11:37:00 +0200402
403 tourR.onbeforeexit(function(){
404 KorAP.session.set("tour", false);
hebasta87f1b1f2019-07-30 13:03:23 +0200405 });
hebasta87f1b1f2019-07-30 13:03:23 +0200406 //See also: https://introjs.com/docs/intro/options/
407 tourR.setOption('scrollToElement', true);
408 tourR.setOption('scrollTo','tooltip');
409 this.testPrerequ(StepsSR, tourR);
Helge0115e7e2025-03-24 16:10:24 +0100410
hebasta87f1b1f2019-07-30 13:03:23 +0200411 tourR.onbeforechange(function(targetedElement){
Helge0115e7e2025-03-24 16:10:24 +0100412 if(this._currentStep == 0){
413 KorAP.session.set("tour", false);
414 if(doe.querySelector("#search + p.no-results")){
415 tourR._introItems[0].intro = loc.TOUR_nokwicti;
416 tourR.goToStepNumber(10);
417 document.querySelector(".introjs-prevbutton").style.visibility = "hidden";
418 }
419 }
hebasta87f1b1f2019-07-30 13:03:23 +0200420
421 if(this._currentStep == 2){
422 doe.querySelector("#search > ol > li").click();
423 tourR._introItems[3].element = doe.querySelector('.action > .metatable');
424 tourR._introItems[3].position = "bottom";
425 }
426
427 if(this._currentStep == 4){
428 doe.querySelector(".metatable").click();
429 tourR._introItems[4].element = doe.querySelector('.view.metatable');
430 tourR._introItems[5].element = doe.querySelector('.action > .info');
431 tourR._introItems[5].position = "bottom";
432 }
433
434 if(this._currentStep == 6){
435 doe.querySelector(".info").click();
436 tourR._introItems[6].element = doe.querySelector('.view.tokentable');
437 tourR._introItems[7].element = doe.querySelector('.tree');
438 tourR._introItems[7].position = "bottom";
439 }
440
441 if(this._currentStep == 8){
442 doe.querySelector(".tree").click();
hebasta7fa6f082019-11-17 19:00:52 +0100443 let collect = document.querySelectorAll(".button-group-list")[0].querySelectorAll('li');
444 for(let i = 0; i < collect.length; i++){
445 if (collect[i].innerText == loc.TOUR_Relations) {
446 collect[i].click();
447 break;
448 }
449 }
hebastaf95226b2019-09-19 11:37:00 +0200450 tourR._introItems[8].element = doe.querySelector(".view.relations");
hebasta87f1b1f2019-07-30 13:03:23 +0200451 }
452 });
hebastaf95226b2019-09-19 11:37:00 +0200453
hebasta5df796f2019-05-21 15:27:12 +0200454 return tourR;
455 },
hebasta87f1b1f2019-07-30 13:03:23 +0200456 /*
457 * The total number of steps and the text of the tooltips are needed for jasmine testing.
458 */
459 testPrerequ: function(steps, tour){
460 //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files
461 let StepsT = steps;
462 let gtour = tour;
463 gtour.stepCount = StepsT.length;
464
465 //Array of intro content needed for efficient testing
466 gtour.testIntros = [];
467
468 for(let i = 0; i< StepsT.length; i++){
469 gtour.testIntros.push(StepsT[i].intro);
470 }
471 },
hebasta5df796f2019-05-21 15:27:12 +0200472
hebasta75cfca52019-02-19 13:15:27 +0100473 }
474});