blob: 43ceea1204675cbed420fcfc570cca27e8fb0e9c [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
hebasta14bb8552021-11-10 16:35:31 +010054 loc.TOUR_kwicti = loc.TOUR_kwicti || "Results";
hebastaf898d7b2021-12-06 14:32:06 +010055 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.";
56 loc.TOUR_snippetti = loc.TOUR_snippetti || "KWIC (2)";
hebasta87f1b1f2019-07-30 13:03:23 +020057 loc.TOUR_snippet = loc.TOUR_snippet || "Click on a match to show a larger snippet.";
hebasta14bb8552021-11-10 16:35:31 +010058 loc.TOUR_snippetbti = loc.TOUR_snippetbti || "Snippet";
hebastaf898d7b2021-12-06 14:32:06 +010059 loc.TOUR_snippetb = loc.TOUR_snippetb || "At the bottom of the snippet, there is a group of buttons to show more result views.";
60 loc.TOUR_metadatabti = loc.TOUR_metadatabti || "Metadata (1)";
61 loc.TOUR_metadatab = loc.TOUR_metadatab || "Click here to display the metadata.";
62 loc.TOUR_metadatati = loc.TOUR_metadatati || "Metadata (2)";
hebasta14bb8552021-11-10 16:35:31 +010063 loc.TOUR_metadata = loc.TOUR_metadata || "Display of metadata";
64 loc.TOUR_tokenbti = loc.TOUR_tokenbti || "Token Annotations";
hebastaf898d7b2021-12-06 14:32:06 +010065 loc.TOUR_tokenb = loc.TOUR_tokenb || "Click here to show the token annotations.";
hebasta14bb8552021-11-10 16:35:31 +010066 loc.TOUR_tokenti = loc.TOUR_tokenti || "Annotations";
hebasta87f1b1f2019-07-30 13:03:23 +020067 loc.TOUR_token = loc.TOUR_token || "KorAP supports multiple annotations.";
hebastaf898d7b2021-12-06 14:32:06 +010068 loc.TOUR_treebti = loc.TOUR_treebti || "Relational Annotations (1)";
69 loc.TOUR_treeb = loc.TOUR_treeb || "Click here to display relational annotations.";
70 loc.TOUR_treeti = loc.TOUR_treeti || "Relational Annotations (2)"
71 loc.TOUR_tree = loc.TOUR_tree || "Relational annotations can be displayed as tree and arch views."
hebasta87f1b1f2019-07-30 13:03:23 +020072 loc.TOUR_tourdone = loc.TOUR_tourdone || "Have fun with KorAP!";
hebasta14bb8552021-11-10 16:35:31 +010073
hebasta75cfca52019-02-19 13:15:27 +010074
75 //localization of button labels
hebastaee7b8a82020-01-20 12:45:04 +010076 let labelOpts= {
hebasta5df796f2019-05-21 15:27:12 +020077 'prevLabel': loc.TOUR_lprev,
78 'nextLabel': loc.TOUR_lnext,
79 'doneLabel': loc.TOUR_ldone,
hebastaee7b8a82020-01-20 12:45:04 +010080 'showStepNumbers': false
81 };
82
83 //usability options of tours
84 let usabilityOpts ={
85 'showBullets': false,
hebastaa84c7a92021-10-26 21:12:40 +020086 'overlayOpacity': 0.5,
hebastaee7b8a82020-01-20 12:45:04 +010087 'exitOnOverlayClick': false,
hebastaa84c7a92021-10-26 21:12:40 +020088 'disableInteraction': true,
89 'tooltipClass': 'customTooltip',
hebastaee7b8a82020-01-20 12:45:04 +010090 'hidePrev': true
hebasta75cfca52019-02-19 13:15:27 +010091 };
hebasta87f1b1f2019-07-30 13:03:23 +020092
93 var doe = document;
hebasta5df796f2019-05-21 15:27:12 +020094
hebasta75cfca52019-02-19 13:15:27 +010095 return{
hebasta5df796f2019-05-21 15:27:12 +020096
hebasta75cfca52019-02-19 13:15:27 +010097 /**
hebasta5df796f2019-05-21 15:27:12 +020098 * Guided Tour gTstartSearch: Explains the search functionality
hebasta75cfca52019-02-19 13:15:27 +010099 */
hebasta5df796f2019-05-21 15:27:12 +0200100 gTstartSearch:function(elparam){
hebasta5df796f2019-05-21 15:27:12 +0200101 let intro = introClass();
hebastaee7b8a82020-01-20 12:45:04 +0100102 intro.setOptions(labelOpts);
hebastaca61f812019-11-11 22:25:27 +0100103 /*
104 * Sets button labels for the last step of the tour
105 * Because Kalamar is a multipage webapplication, this tours starts by
106 * completion the gTshowResults Tour. Therefore the label of the done button changed.
107 */
108 intro.setOption('doneLabel', loc.TOUR_ldoneSearch );
hebastaee7b8a82020-01-20 12:45:04 +0100109 intro.setOptions(usabilityOpts);
hebastaca61f812019-11-11 22:25:27 +0100110
hebasta5df796f2019-05-21 15:27:12 +0200111 //for testing purposes
hebasta75cfca52019-02-19 13:15:27 +0100112 if(elparam){
113 doe = elparam;
114 }
hebasta5df796f2019-05-21 15:27:12 +0200115
hebasta75cfca52019-02-19 13:15:27 +0100116 let input = doe.querySelector("#q-field");
117 input.value="";
118
hebasta5df796f2019-05-21 15:27:12 +0200119
hebasta75cfca52019-02-19 13:15:27 +0100120 //steps of the example tour
121 let Steps =[
hebastafa118342021-11-02 19:56:01 +0100122 //Step 1, intro_item 0
hebasta2f7e5402021-11-02 20:09:38 +0100123 {
hebastaa84c7a92021-10-26 21:12:40 +0200124 title: loc.TOUR_welcti,
hebasta1e2d98e2019-10-30 15:58:17 +0100125 intro: loc.TOUR_welc,
126 },
hebastafa118342021-11-02 19:56:01 +0100127 //Step 2, intro_item 1
hebasta1e2d98e2019-10-30 15:58:17 +0100128 {
hebasta84a7e0e2021-11-03 19:11:33 +0100129 title: loc.TOUR_sear1ti,
hebastaf95226b2019-09-19 11:37:00 +0200130 element: '#q-field',
hebasta75cfca52019-02-19 13:15:27 +0100131 intro: loc.TOUR_sear1,
132 position: 'bottom'
133 },
hebastafa118342021-11-02 19:56:01 +0100134 //Step 3, intro_item 2
hebasta75cfca52019-02-19 13:15:27 +0100135 {
hebasta84a7e0e2021-11-03 19:11:33 +0100136 title: loc.TOUR_searAnnotti,
hebasta75cfca52019-02-19 13:15:27 +0100137 element: '#hint',
138 intro: loc.TOUR_searAnnot,
hebastafa118342021-11-02 19:56:01 +0100139 position: 'auto'
hebasta5df796f2019-05-21 15:27:12 +0200140 },
hebastafa118342021-11-02 19:56:01 +0100141 //Step 4, intro_item 3
hebasta5df796f2019-05-21 15:27:12 +0200142 {
hebasta84a7e0e2021-11-03 19:11:33 +0100143 title: loc.TOUR_annotAssti,
hebastaf95226b2019-09-19 11:37:00 +0200144 element: doe.querySelector("#hint > .menu.hint"),
145 intro: loc.TOUR_annotAss,
146 position: 'bottom',
hebastafa118342021-11-02 19:56:01 +0100147 },
148 //Step 5, intro_item 4
hebastaf95226b2019-09-19 11:37:00 +0200149 {
hebastafa118342021-11-02 19:56:01 +0100150 title: loc.TOUR_vccho1ti,
hebasta75cfca52019-02-19 13:15:27 +0100151 element:'#vc-choose',
152 intro: loc.TOUR_vccho1,
153 position: "bottom",
hebasta5df796f2019-05-21 15:27:12 +0200154 },
hebastafa118342021-11-02 19:56:01 +0100155 //Step 6, intro_item 5
hebasta5df796f2019-05-21 15:27:12 +0200156 {
hebasta84a7e0e2021-11-03 19:11:33 +0100157 title: loc.TOUR_vccho2ti,
hebasta5df796f2019-05-21 15:27:12 +0200158 element:'#vc-view',
159 intro: loc.TOUR_vccho2,
160 position: "bottom",
161 },
hebastafa118342021-11-02 19:56:01 +0100162 //Step 7, intro_item 6
163 {
164 title: loc.TOUR_vccho3ti,
165 element: doe.querySelector('#vc-view * .doc > menu'),
166 intro: loc.TOUR_vccho3,
167 position: "left",
168 },
169 //Step 8, intro_item 7
170 {
171 title: loc.TOUR_vccho4ti,
172 element: doe.querySelector('#vc-view * .doc'),
173 intro: loc.TOUR_vccho4,
174 position: "left",
175 },
176 //Step 9, intro_item 8
hebasta5df796f2019-05-21 15:27:12 +0200177 {
hebasta84a7e0e2021-11-03 19:11:33 +0100178 title: loc.TOUR_vcStat1ti,
hebastad090a512019-07-10 16:36:01 +0200179 element: doe.querySelector('.statistic'),
hebasta94e47cb2019-07-24 22:24:27 +0200180 intro: loc.TOUR_vcStat1,
hebastad090a512019-07-10 16:36:01 +0200181 position: "left",
182 },
hebastafa118342021-11-02 19:56:01 +0100183 //Step 10, intro_item 9
hebastad090a512019-07-10 16:36:01 +0200184 {
hebasta84a7e0e2021-11-03 19:11:33 +0100185 title: loc.TOUR_vcStat2ti,
hebasta94e47cb2019-07-24 22:24:27 +0200186 element: doe.querySelector('.stattable'),
187 intro: loc.TOUR_vcStat2,
188 position: "bottom",
189 },
hebastafa118342021-11-02 19:56:01 +0100190 //Step 11, intro_item 10
hebasta94e47cb2019-07-24 22:24:27 +0200191 {
hebasta84a7e0e2021-11-03 19:11:33 +0100192 title: loc.TOUR_qlfieldti,
hebasta5df796f2019-05-21 15:27:12 +0200193 element: doe.querySelector('#ql-field').parentNode,
194 intro: loc.TOUR_qlfield,
195 position: "bottom",
196 },
197 {
hebasta84a7e0e2021-11-03 19:11:33 +0100198 title: loc.TOUR_glimpseti,
hebastabd53f822021-10-26 21:50:06 +0200199 element: doe.querySelector('#glimpse').parentNode,
hebasta5df796f2019-05-21 15:27:12 +0200200 intro: loc.TOUR_glimpse,
201 position: "bottom",
202 },
203 {
hebasta84a7e0e2021-11-03 19:11:33 +0100204 title: loc.TOUR_helpti,
hebasta5df796f2019-05-21 15:27:12 +0200205 element:'#view-tutorial',
206 intro: loc.TOUR_help,
207 position: "bottom",
208 },
209 {
hebasta84a7e0e2021-11-03 19:11:33 +0100210 title: loc.TOUR_seargoti,
hebasta5df796f2019-05-21 15:27:12 +0200211 element: '#qsubmit',
212 intro: loc.TOUR_seargo,
213 position: "bottom",
214 },
215 ];
216
hebasta75cfca52019-02-19 13:15:27 +0100217 //pass in the Steps array created earlier
hebasta87f1b1f2019-07-30 13:03:23 +0200218 intro.setOptions({steps: Steps});
219 this.testPrerequ(Steps, intro);
hebastaca61f812019-11-11 22:25:27 +0100220
hebasta5df796f2019-05-21 15:27:12 +0200221 //changes before executing the single steps
222 intro.onbeforechange(function(targetedElement){
223 switch(targetedElement.id){
hebastaf95226b2019-09-19 11:37:00 +0200224 case "q-field":
hebastad090a512019-07-10 16:36:01 +0200225 /*
226 * TODO:
227 * #268 is not merged at the time beeing:
228 * introJs.currentStep() merge requested https://github.com/usablica/intro.js/pull/268/files
229 */
hebastaf95226b2019-09-19 11:37:00 +0200230 targetedElement.value = loc.TOUR_Qexample;
hebasta5df796f2019-05-21 15:27:12 +0200231 break;
hebasta5df796f2019-05-21 15:27:12 +0200232 case "vc-view":
Akron0b37f3e2021-02-09 10:32:03 +0100233 let vchoo = doe.querySelector("#vc-choose");
234 let vcv = doe.querySelector("#vc-view");
hebasta5df796f2019-05-21 15:27:12 +0200235 if(!(vcv.querySelector(".active"))){
236 vchoo.click();
hebastad090a512019-07-10 16:36:01 +0200237 /*
238 * Intro.js caches elements at the beginning, so element and position has to be set again.
239 */
hebastafa118342021-11-02 19:56:01 +0100240 intro._introItems[8].element = doe.querySelector('.statistic');
241 intro._introItems[8].position = "left";
hebasta5df796f2019-05-21 15:27:12 +0200242 }
hebastafa118342021-11-02 19:56:01 +0100243 intro._introItems[7].element = doe.querySelector('#vc-view * .doc');
244 intro._introItems[7].position = "left";
245 break;
Helgef4107f12025-02-27 12:15:18 +0100246 }
247 /*
248 * Hides the tutorial. If it is opened in an iframe the searchbar which is needed for the tour is not visible anymore.
249 */
250 if(this._currentStep == 1){
Helge3567e332025-03-24 17:40:28 +0100251 if(doe.querySelector('#tutorial')){
Helgef4107f12025-02-27 12:15:18 +0100252 let tutel = doe.querySelector('#tutorial');
253 tutel.style.display = 'none';
Helge3567e332025-03-24 17:40:28 +0100254 }
Helgef4107f12025-02-27 12:15:18 +0100255 }
hebastafa118342021-11-02 19:56:01 +0100256 if(this._currentStep == 9){
hebasta94e47cb2019-07-24 22:24:27 +0200257 let statbut = doe.querySelector('.statistic');
258 statbut.click();
hebastafa118342021-11-02 19:56:01 +0100259 intro._introItems[9].element = doe.querySelector(".stattable");
260 intro._introItems[9].position = "bottom";
hebasta94e47cb2019-07-24 22:24:27 +0200261 }
hebasta75cfca52019-02-19 13:15:27 +0100262 });
hebasta5df796f2019-05-21 15:27:12 +0200263
hebastaf95226b2019-09-19 11:37:00 +0200264 intro.onbeforeexit(function(){
265 if(KorAP.Hint.active() && KorAP.Hint.active().dontHide){
266 KorAP.Hint.unshow();
267 }
hebastafa118342021-11-02 19:56:01 +0100268 if (KorAP._vcKeyMenu.dontHide){
269 KorAP._vcKeyMenu.dontHide = false;
270 KorAP._vcKeyMenu.hide();
271 }
hebastaf95226b2019-09-19 11:37:00 +0200272 });
273
274 intro.onchange(function(targetElement) {
275 var that = this;
276 switch(this._currentStep){
277 //hides Hint if back button is pressed
hebastaee7b8a82020-01-20 12:45:04 +0100278 case 2:
hebastaf95226b2019-09-19 11:37:00 +0200279 if(KorAP.Hint.active()){
280 KorAP.Hint.unshow();
281 }
282 break;
hebastaee7b8a82020-01-20 12:45:04 +0100283 case 3:
hebastaf95226b2019-09-19 11:37:00 +0200284 KorAP.Hint.show(false);
285 KorAP.Hint.active().dontHide = true;
hebastaee7b8a82020-01-20 12:45:04 +0100286 intro._introItems[3].element = doe.querySelector(".menu.roll.hint");
287 intro._introItems[3].position = doe.querySelector("bottom");
hebastaf95226b2019-09-19 11:37:00 +0200288 break;
hebastaee7b8a82020-01-20 12:45:04 +0100289 case 4:
hebastafa118342021-11-02 19:56:01 +0100290 KorAP.Hint.unshow();
291 KorAP._vcKeyMenu.dontHide = false;
hebastaf95226b2019-09-19 11:37:00 +0200292 break;
hebastafa118342021-11-02 19:56:01 +0100293 case 6:
294 let vccbut = doe.querySelector('#vc-view * .doc > span');
295 vccbut.click();
296 KorAP._vcKeyMenu.dontHide = true;
297 intro._introItems[6].element = doe.querySelector('#vc-view * .menu.roll');
298 intro._introItems[6].position = "left";
299 break;
300 case 7:
301 KorAP._vcKeyMenu.dontHide = false;
302 KorAP._vcKeyMenu.hide();
303 KorAP.vc.fromJson(loc.TOUR_vcQuery);
304 intro._introItems[7].element = doe.querySelector('#vc-view * .doc');
305 intro._introItems[7].position = "left";
hebastaf95226b2019-09-19 11:37:00 +0200306 }
307 });
308
hebasta5df796f2019-05-21 15:27:12 +0200309 // Execute at the end of the tour (By clicking at the done-Button)
310 intro.oncomplete(function(){
311 KorAP.session.set("tour", true);
hebasta94e47cb2019-07-24 22:24:27 +0200312 doe.getElementById("qsubmit").click();
hebasta5df796f2019-05-21 15:27:12 +0200313 });
314
315 return intro;
hebasta75cfca52019-02-19 13:15:27 +0100316 },
hebasta5df796f2019-05-21 15:27:12 +0200317
318
319 /* Guided Tour to explain the different views of the results */
hebastaca61f812019-11-11 22:25:27 +0100320 gTshowResults: function(elparam){
321
322 let tourR = introClass();
hebastaee7b8a82020-01-20 12:45:04 +0100323 tourR.setOptions(usabilityOpts);
hebastaca61f812019-11-11 22:25:27 +0100324
hebasta87f1b1f2019-07-30 13:03:23 +0200325 //for testing purposes
hebasta5df796f2019-05-21 15:27:12 +0200326 if(elparam){
327 doe = elparam;
328 }
hebasta5df796f2019-05-21 15:27:12 +0200329 let StepsSR = [
hebasta87f1b1f2019-07-30 13:03:23 +0200330 //Step 1, intro_item 0
hebasta14bb8552021-11-10 16:35:31 +0100331 {
332 title: loc.TOUR_kwicti,
hebasta87f1b1f2019-07-30 13:03:23 +0200333 element: '#search',
334 intro: loc.TOUR_kwic ,
335 position: "auto",
336 },
337 //Step 2, intro_item 1
hebasta14bb8552021-11-10 16:35:31 +0100338 {
339 title: loc.TOUR_snippetti,
hebasta87f1b1f2019-07-30 13:03:23 +0200340 element: doe.querySelector("#search > ol > li"),
341 intro: loc.TOUR_snippet,
342 position: "bottom",
343 },
344 //Step 3, intro_item 2
hebasta14bb8552021-11-10 16:35:31 +0100345 {
346 title: loc.TOUR_snippetbti,
hebasta87f1b1f2019-07-30 13:03:23 +0200347 element: doe.querySelector("#search > ol > li"),
348 intro: loc.TOUR_snippetb,
349 position: "bottom",
350 },
351 //Step 4, intro_item 3
hebasta14bb8552021-11-10 16:35:31 +0100352 {
353 title: loc.TOUR_metadatabti,
hebasta87f1b1f2019-07-30 13:03:23 +0200354 element: doe.querySelector(".action > .metatable"),
355 intro: loc.TOUR_metadatab,
356 position: "bottom",
357 },
358 //Step 5, intro_item 4
hebasta14bb8552021-11-10 16:35:31 +0100359 {
360 title: loc.TOUR_metadatati,
hebasta87f1b1f2019-07-30 13:03:23 +0200361 element: doe.querySelector(".view.metatable"),
362 intro: loc.TOUR_metadata,
363 position: "auto",
364 },
365 //Step 6, intro_item 5
hebasta14bb8552021-11-10 16:35:31 +0100366 {
367 title: loc.TOUR_tokenbti,
hebasta87f1b1f2019-07-30 13:03:23 +0200368 element: doe.querySelector(".action > .info"),
369 intro: loc.TOUR_tokenb,
370 position: "bottom",
371 },
372 //Step 7, intro_item 6
hebasta14bb8552021-11-10 16:35:31 +0100373 {
374 title: loc.TOUR_tokenti,
hebasta87f1b1f2019-07-30 13:03:23 +0200375 element: doe.querySelector(".view.tokentable"),
376 intro: loc.TOUR_token,
377 position: "auto",
378 },
379 //Step 8, intro_item 7
hebasta14bb8552021-11-10 16:35:31 +0100380 {
381 title: loc.TOUR_treebti,
hebasta87f1b1f2019-07-30 13:03:23 +0200382 element: doe.querySelector(".tree"),
383 intro: loc.TOUR_treeb,
384 position: "bottom",
385 },
386 //Step 9, intro_item 8
hebasta14bb8552021-11-10 16:35:31 +0100387 {
388 title: loc.TOUR_treeti,
hebastaf95226b2019-09-19 11:37:00 +0200389 element: doe.querySelector(".view.relations"),
hebasta87f1b1f2019-07-30 13:03:23 +0200390 intro: loc.TOUR_tree,
hebastaf95226b2019-09-19 11:37:00 +0200391 position: "bottom",
hebasta87f1b1f2019-07-30 13:03:23 +0200392 },
393 //Step 10, intro_item 9
394 {
395 intro: loc.TOUR_tourdone,
396 }
hebasta5df796f2019-05-21 15:27:12 +0200397 ]
hebasta5df796f2019-05-21 15:27:12 +0200398
hebasta87f1b1f2019-07-30 13:03:23 +0200399 tourR.setOptions({steps:StepsSR});
hebastaee7b8a82020-01-20 12:45:04 +0100400 tourR.setOptions(labelOpts);
hebastaf95226b2019-09-19 11:37:00 +0200401
402 tourR.onbeforeexit(function(){
403 KorAP.session.set("tour", false);
hebasta87f1b1f2019-07-30 13:03:23 +0200404 });
hebasta87f1b1f2019-07-30 13:03:23 +0200405 //See also: https://introjs.com/docs/intro/options/
406 tourR.setOption('scrollToElement', true);
407 tourR.setOption('scrollTo','tooltip');
408 this.testPrerequ(StepsSR, tourR);
409
410 //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files
411 tourR.onbeforechange(function(targetedElement){
412
413 if(this._currentStep == 1){
414 KorAP.session.set("tour", false);
415 }
416
417 if(this._currentStep == 2){
418 doe.querySelector("#search > ol > li").click();
419 tourR._introItems[3].element = doe.querySelector('.action > .metatable');
420 tourR._introItems[3].position = "bottom";
421 }
422
423 if(this._currentStep == 4){
424 doe.querySelector(".metatable").click();
425 tourR._introItems[4].element = doe.querySelector('.view.metatable');
426 tourR._introItems[5].element = doe.querySelector('.action > .info');
427 tourR._introItems[5].position = "bottom";
428 }
429
430 if(this._currentStep == 6){
431 doe.querySelector(".info").click();
432 tourR._introItems[6].element = doe.querySelector('.view.tokentable');
433 tourR._introItems[7].element = doe.querySelector('.tree');
434 tourR._introItems[7].position = "bottom";
435 }
436
437 if(this._currentStep == 8){
438 doe.querySelector(".tree").click();
hebasta7fa6f082019-11-17 19:00:52 +0100439 let collect = document.querySelectorAll(".button-group-list")[0].querySelectorAll('li');
440 for(let i = 0; i < collect.length; i++){
441 if (collect[i].innerText == loc.TOUR_Relations) {
442 collect[i].click();
443 break;
444 }
445 }
hebastaf95226b2019-09-19 11:37:00 +0200446 tourR._introItems[8].element = doe.querySelector(".view.relations");
hebasta87f1b1f2019-07-30 13:03:23 +0200447 }
448 });
hebastaf95226b2019-09-19 11:37:00 +0200449
hebasta5df796f2019-05-21 15:27:12 +0200450 return tourR;
451 },
hebasta87f1b1f2019-07-30 13:03:23 +0200452 /*
453 * The total number of steps and the text of the tooltips are needed for jasmine testing.
454 */
455 testPrerequ: function(steps, tour){
456 //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files
457 let StepsT = steps;
458 let gtour = tour;
459 gtour.stepCount = StepsT.length;
460
461 //Array of intro content needed for efficient testing
462 gtour.testIntros = [];
463
464 for(let i = 0; i< StepsT.length; i++){
465 gtour.testIntros.push(StepsT[i].intro);
466 }
467 },
hebasta5df796f2019-05-21 15:27:12 +0200468
hebasta75cfca52019-02-19 13:15:27 +0100469 }
470});