blob: 4858d1e446857e4a49b5543a52fca142110dd9ea [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.";
hebastaee7b8a82020-01-20 12:45:04 +010024 loc.TOUR_sear1 = loc.TOUR_sear1 || "Input field for the query, for example the search for '" + loc.TOUR_Qexample + "'.";
hebastaf95226b2019-09-19 11:37:00 +020025 loc.TOUR_searAnnot = loc.TOUR_searAnnot || "Annotation helper";
26 loc.TOUR_annotAss = loc.TOUR_annotAss || "The assistant displays the annotations of the different layers and helps to formulate queries.";
hebastafa118342021-11-02 19:56:01 +010027 loc.TOUR_vccho1 = loc.TOUR_vccho1 || "Choose corpus";
28 loc.TOUR_vccho2ti = loc.TOUR_vccho2ti || "Corpus Assistant (1)";
hebasta75cfca52019-02-19 13:15:27 +010029 loc.TOUR_vccho2 = loc.TOUR_vccho2 || "Define your corpus here.";
hebastafa118342021-11-02 19:56:01 +010030 loc.TOUR_vccho3ti = loc.TOUR_vccho3ti || "Corpus Assistant (2)";
31 loc.TOUR_vccho3 = loc.TOUR_vccho3 || "Several of the available metadata can be choosen in a drop down box.";
32 loc.TOUR_vccho4ti = loc.TOUR_vccho4ti || "Corpus Assistant (3)";
33 loc.TOUR_vccho4 = loc.TOUR_vccho4 || "For example to request all documents with the document sigle " + loc.TOUR_DocSigle + " .";
hebasta94e47cb2019-07-24 22:24:27 +020034 loc.TOUR_vcStat1 = loc.TOUR_vcStat1 || "Click here to display corpus statistic.";
35 loc.TOUR_vcStat2 = loc.TOUR_vcStat2 || "Corpus statistic";
hebasta14bb8552021-11-10 16:35:31 +010036 loc.TOUR_qlfield = loc.TOUR_qlfield|| "You can use KorAP with different query languages. You can choose your preferred query language here. ";
37 loc.TOUR_help = loc.TOUR_help || "Here you can find help and information about KorAP.";
hebastaca61f812019-11-11 22:25:27 +010038 loc.TOUR_glimpse = loc.TOUR_glimpse || "Select this to show only the first hits in undefined order.";
hebasta1e2d98e2019-10-30 15:58:17 +010039 loc.TOUR_seargo = loc.TOUR_seargo || "Start the search";
hebasta87f1b1f2019-07-30 13:03:23 +020040
hebasta5df796f2019-05-21 15:27:12 +020041 //localization guided Tour gTshowResults
hebasta14bb8552021-11-10 16:35:31 +010042 loc.TOUR_kwicti = loc.TOUR_kwicti || "Results";
hebasta87f1b1f2019-07-30 13:03:23 +020043 loc.TOUR_kwic = loc.TOUR_kwic || "KWIC result (keyword in context)";
hebasta14bb8552021-11-10 16:35:31 +010044 loc.TOUR_snippetti = loc.TOUR_snippetti || "KWIC(2)";
hebasta87f1b1f2019-07-30 13:03:23 +020045 loc.TOUR_snippet = loc.TOUR_snippet || "Click on a match to show a larger snippet.";
hebasta14bb8552021-11-10 16:35:31 +010046 loc.TOUR_snippetbti = loc.TOUR_snippetbti || "Snippet";
47 loc.TOUR_snippetb = loc.TOUR_snippetb || "Display of snippet";
48 loc.TOUR_metadatabti = loc.TOUR_metadatabti || "Metadata(1)";
49 loc.TOUR_metadatab = loc.TOUR_metadatab || "Click here to display metadata.";
50 loc.TOUR_metadatati = loc.TOUR_metadatati || "Metadata(2)";
51 loc.TOUR_metadata = loc.TOUR_metadata || "Display of metadata";
52 loc.TOUR_tokenbti = loc.TOUR_tokenbti || "Token Annotations";
hebasta1e2d98e2019-10-30 15:58:17 +010053 loc.TOUR_tokenb = loc.TOUR_tokenb || "Display of token annotations";
hebasta14bb8552021-11-10 16:35:31 +010054 loc.TOUR_tokenti = loc.TOUR_tokenti || "Annotations";
hebasta87f1b1f2019-07-30 13:03:23 +020055 loc.TOUR_token = loc.TOUR_token || "KorAP supports multiple annotations.";
hebasta14bb8552021-11-10 16:35:31 +010056 loc.TOUR_treebti = loc.TOUR_treebti || "Further Annotations(1)";
57 loc.TOUR_treeb = loc.TOUR_treeb || "Display further annotations";
58 loc.TOUR_treeti = loc.TOUR_treeti || "Further Annotations(2)"
hebasta87f1b1f2019-07-30 13:03:23 +020059 loc.TOUR_tree = loc.TOUR_tree || "Further annotations can be displayed as tree and arch views."
60 loc.TOUR_tourdone = loc.TOUR_tourdone || "Have fun with KorAP!";
hebasta14bb8552021-11-10 16:35:31 +010061
hebasta75cfca52019-02-19 13:15:27 +010062
63 //localization of button labels
hebastaee7b8a82020-01-20 12:45:04 +010064 let labelOpts= {
hebasta5df796f2019-05-21 15:27:12 +020065 'prevLabel': loc.TOUR_lprev,
66 'nextLabel': loc.TOUR_lnext,
67 'doneLabel': loc.TOUR_ldone,
hebastaee7b8a82020-01-20 12:45:04 +010068 'showStepNumbers': false
69 };
70
71 //usability options of tours
72 let usabilityOpts ={
73 'showBullets': false,
hebastaa84c7a92021-10-26 21:12:40 +020074 'overlayOpacity': 0.5,
hebastaee7b8a82020-01-20 12:45:04 +010075 'exitOnOverlayClick': false,
hebastaa84c7a92021-10-26 21:12:40 +020076 'disableInteraction': true,
77 'tooltipClass': 'customTooltip',
hebastaee7b8a82020-01-20 12:45:04 +010078 'hidePrev': true
hebasta75cfca52019-02-19 13:15:27 +010079 };
hebasta87f1b1f2019-07-30 13:03:23 +020080
81 var doe = document;
hebasta5df796f2019-05-21 15:27:12 +020082
hebasta75cfca52019-02-19 13:15:27 +010083 return{
hebasta5df796f2019-05-21 15:27:12 +020084
hebasta75cfca52019-02-19 13:15:27 +010085 /**
hebasta5df796f2019-05-21 15:27:12 +020086 * Guided Tour gTstartSearch: Explains the search functionality
hebasta75cfca52019-02-19 13:15:27 +010087 */
hebasta5df796f2019-05-21 15:27:12 +020088 gTstartSearch:function(elparam){
hebasta5df796f2019-05-21 15:27:12 +020089 let intro = introClass();
hebastaee7b8a82020-01-20 12:45:04 +010090 intro.setOptions(labelOpts);
hebastaca61f812019-11-11 22:25:27 +010091 /*
92 * Sets button labels for the last step of the tour
93 * Because Kalamar is a multipage webapplication, this tours starts by
94 * completion the gTshowResults Tour. Therefore the label of the done button changed.
95 */
96 intro.setOption('doneLabel', loc.TOUR_ldoneSearch );
hebastaee7b8a82020-01-20 12:45:04 +010097 intro.setOptions(usabilityOpts);
hebastaca61f812019-11-11 22:25:27 +010098
hebasta5df796f2019-05-21 15:27:12 +020099 //for testing purposes
hebasta75cfca52019-02-19 13:15:27 +0100100 if(elparam){
101 doe = elparam;
102 }
hebasta5df796f2019-05-21 15:27:12 +0200103
hebasta75cfca52019-02-19 13:15:27 +0100104 let input = doe.querySelector("#q-field");
105 input.value="";
106
hebasta5df796f2019-05-21 15:27:12 +0200107
hebasta75cfca52019-02-19 13:15:27 +0100108 //steps of the example tour
109 let Steps =[
hebastafa118342021-11-02 19:56:01 +0100110 //Step 1, intro_item 0
hebasta2f7e5402021-11-02 20:09:38 +0100111 {
112 element: '#link-guided-tour',
hebastaa84c7a92021-10-26 21:12:40 +0200113 title: loc.TOUR_welcti,
hebasta1e2d98e2019-10-30 15:58:17 +0100114 intro: loc.TOUR_welc,
hebasta2f7e5402021-11-02 20:09:38 +0100115 position: 'right',
hebasta1e2d98e2019-10-30 15:58:17 +0100116 },
hebastafa118342021-11-02 19:56:01 +0100117 //Step 2, intro_item 1
hebasta1e2d98e2019-10-30 15:58:17 +0100118 {
hebasta84a7e0e2021-11-03 19:11:33 +0100119 title: loc.TOUR_sear1ti,
hebastaf95226b2019-09-19 11:37:00 +0200120 element: '#q-field',
hebasta75cfca52019-02-19 13:15:27 +0100121 intro: loc.TOUR_sear1,
122 position: 'bottom'
123 },
hebastafa118342021-11-02 19:56:01 +0100124 //Step 3, intro_item 2
hebasta75cfca52019-02-19 13:15:27 +0100125 {
hebasta84a7e0e2021-11-03 19:11:33 +0100126 title: loc.TOUR_searAnnotti,
hebasta75cfca52019-02-19 13:15:27 +0100127 element: '#hint',
128 intro: loc.TOUR_searAnnot,
hebastafa118342021-11-02 19:56:01 +0100129 position: 'auto'
hebasta5df796f2019-05-21 15:27:12 +0200130 },
hebastafa118342021-11-02 19:56:01 +0100131 //Step 4, intro_item 3
hebasta5df796f2019-05-21 15:27:12 +0200132 {
hebasta84a7e0e2021-11-03 19:11:33 +0100133 title: loc.TOUR_annotAssti,
hebastaf95226b2019-09-19 11:37:00 +0200134 element: doe.querySelector("#hint > .menu.hint"),
135 intro: loc.TOUR_annotAss,
136 position: 'bottom',
hebastafa118342021-11-02 19:56:01 +0100137 },
138 //Step 5, intro_item 4
hebastaf95226b2019-09-19 11:37:00 +0200139 {
hebastafa118342021-11-02 19:56:01 +0100140 title: loc.TOUR_vccho1ti,
hebasta75cfca52019-02-19 13:15:27 +0100141 element:'#vc-choose',
142 intro: loc.TOUR_vccho1,
143 position: "bottom",
hebasta5df796f2019-05-21 15:27:12 +0200144 },
hebastafa118342021-11-02 19:56:01 +0100145 //Step 6, intro_item 5
hebasta5df796f2019-05-21 15:27:12 +0200146 {
hebasta84a7e0e2021-11-03 19:11:33 +0100147 title: loc.TOUR_vccho2ti,
hebasta5df796f2019-05-21 15:27:12 +0200148 element:'#vc-view',
149 intro: loc.TOUR_vccho2,
150 position: "bottom",
151 },
hebastafa118342021-11-02 19:56:01 +0100152 //Step 7, intro_item 6
153 {
154 title: loc.TOUR_vccho3ti,
155 element: doe.querySelector('#vc-view * .doc > menu'),
156 intro: loc.TOUR_vccho3,
157 position: "left",
158 },
159 //Step 8, intro_item 7
160 {
161 title: loc.TOUR_vccho4ti,
162 element: doe.querySelector('#vc-view * .doc'),
163 intro: loc.TOUR_vccho4,
164 position: "left",
165 },
166 //Step 9, intro_item 8
hebasta5df796f2019-05-21 15:27:12 +0200167 {
hebasta84a7e0e2021-11-03 19:11:33 +0100168 title: loc.TOUR_vcStat1ti,
hebastad090a512019-07-10 16:36:01 +0200169 element: doe.querySelector('.statistic'),
hebasta94e47cb2019-07-24 22:24:27 +0200170 intro: loc.TOUR_vcStat1,
hebastad090a512019-07-10 16:36:01 +0200171 position: "left",
172 },
hebastafa118342021-11-02 19:56:01 +0100173 //Step 10, intro_item 9
hebastad090a512019-07-10 16:36:01 +0200174 {
hebasta84a7e0e2021-11-03 19:11:33 +0100175 title: loc.TOUR_vcStat2ti,
hebasta94e47cb2019-07-24 22:24:27 +0200176 element: doe.querySelector('.stattable'),
177 intro: loc.TOUR_vcStat2,
178 position: "bottom",
179 },
hebastafa118342021-11-02 19:56:01 +0100180 //Step 11, intro_item 10
hebasta94e47cb2019-07-24 22:24:27 +0200181 {
hebasta84a7e0e2021-11-03 19:11:33 +0100182 title: loc.TOUR_qlfieldti,
hebasta5df796f2019-05-21 15:27:12 +0200183 element: doe.querySelector('#ql-field').parentNode,
184 intro: loc.TOUR_qlfield,
185 position: "bottom",
186 },
187 {
hebasta84a7e0e2021-11-03 19:11:33 +0100188 title: loc.TOUR_glimpseti,
hebastabd53f822021-10-26 21:50:06 +0200189 element: doe.querySelector('#glimpse').parentNode,
hebasta5df796f2019-05-21 15:27:12 +0200190 intro: loc.TOUR_glimpse,
191 position: "bottom",
192 },
193 {
hebasta84a7e0e2021-11-03 19:11:33 +0100194 title: loc.TOUR_helpti,
hebasta5df796f2019-05-21 15:27:12 +0200195 element:'#view-tutorial',
196 intro: loc.TOUR_help,
197 position: "bottom",
198 },
199 {
hebasta84a7e0e2021-11-03 19:11:33 +0100200 title: loc.TOUR_seargoti,
hebasta5df796f2019-05-21 15:27:12 +0200201 element: '#qsubmit',
202 intro: loc.TOUR_seargo,
203 position: "bottom",
204 },
205 ];
206
hebasta75cfca52019-02-19 13:15:27 +0100207 //pass in the Steps array created earlier
hebasta87f1b1f2019-07-30 13:03:23 +0200208 intro.setOptions({steps: Steps});
209 this.testPrerequ(Steps, intro);
hebastaca61f812019-11-11 22:25:27 +0100210
hebasta5df796f2019-05-21 15:27:12 +0200211 //changes before executing the single steps
212 intro.onbeforechange(function(targetedElement){
213 switch(targetedElement.id){
hebastaf95226b2019-09-19 11:37:00 +0200214 case "q-field":
hebastad090a512019-07-10 16:36:01 +0200215 /*
216 * TODO:
217 * #268 is not merged at the time beeing:
218 * introJs.currentStep() merge requested https://github.com/usablica/intro.js/pull/268/files
219 */
hebastaf95226b2019-09-19 11:37:00 +0200220 targetedElement.value = loc.TOUR_Qexample;
hebasta5df796f2019-05-21 15:27:12 +0200221 break;
hebasta5df796f2019-05-21 15:27:12 +0200222 case "vc-view":
Akron0b37f3e2021-02-09 10:32:03 +0100223 let vchoo = doe.querySelector("#vc-choose");
224 let vcv = doe.querySelector("#vc-view");
hebasta5df796f2019-05-21 15:27:12 +0200225 KorAP._delete.apply(KorAP.vc.root());
hebasta5df796f2019-05-21 15:27:12 +0200226 if(!(vcv.querySelector(".active"))){
227 vchoo.click();
hebastad090a512019-07-10 16:36:01 +0200228 /*
229 * Intro.js caches elements at the beginning, so element and position has to be set again.
230 */
hebastafa118342021-11-02 19:56:01 +0100231 intro._introItems[8].element = doe.querySelector('.statistic');
232 intro._introItems[8].position = "left";
hebasta5df796f2019-05-21 15:27:12 +0200233 }
hebastafa118342021-11-02 19:56:01 +0100234 intro._introItems[7].element = doe.querySelector('#vc-view * .doc');
235 intro._introItems[7].position = "left";
236 break;
hebasta5df796f2019-05-21 15:27:12 +0200237 }
hebastafa118342021-11-02 19:56:01 +0100238 if(this._currentStep == 9){
hebasta94e47cb2019-07-24 22:24:27 +0200239 let statbut = doe.querySelector('.statistic');
240 statbut.click();
hebastafa118342021-11-02 19:56:01 +0100241 intro._introItems[9].element = doe.querySelector(".stattable");
242 intro._introItems[9].position = "bottom";
hebasta94e47cb2019-07-24 22:24:27 +0200243 }
hebasta75cfca52019-02-19 13:15:27 +0100244 });
hebasta5df796f2019-05-21 15:27:12 +0200245
hebastaf95226b2019-09-19 11:37:00 +0200246 intro.onbeforeexit(function(){
247 if(KorAP.Hint.active() && KorAP.Hint.active().dontHide){
248 KorAP.Hint.unshow();
249 }
hebastafa118342021-11-02 19:56:01 +0100250 if (KorAP._vcKeyMenu.dontHide){
251 KorAP._vcKeyMenu.dontHide = false;
252 KorAP._vcKeyMenu.hide();
253 }
hebastaf95226b2019-09-19 11:37:00 +0200254 });
255
256 intro.onchange(function(targetElement) {
257 var that = this;
258 switch(this._currentStep){
259 //hides Hint if back button is pressed
hebastaee7b8a82020-01-20 12:45:04 +0100260 case 2:
hebastaf95226b2019-09-19 11:37:00 +0200261 if(KorAP.Hint.active()){
262 KorAP.Hint.unshow();
263 }
264 break;
hebastaee7b8a82020-01-20 12:45:04 +0100265 case 3:
hebastaf95226b2019-09-19 11:37:00 +0200266 KorAP.Hint.show(false);
267 KorAP.Hint.active().dontHide = true;
hebastaee7b8a82020-01-20 12:45:04 +0100268 intro._introItems[3].element = doe.querySelector(".menu.roll.hint");
269 intro._introItems[3].position = doe.querySelector("bottom");
hebastaf95226b2019-09-19 11:37:00 +0200270 break;
hebastaee7b8a82020-01-20 12:45:04 +0100271 case 4:
hebastafa118342021-11-02 19:56:01 +0100272 KorAP.Hint.unshow();
273 KorAP._vcKeyMenu.dontHide = false;
hebastaf95226b2019-09-19 11:37:00 +0200274 break;
hebastafa118342021-11-02 19:56:01 +0100275 case 6:
276 let vccbut = doe.querySelector('#vc-view * .doc > span');
277 vccbut.click();
278 KorAP._vcKeyMenu.dontHide = true;
279 intro._introItems[6].element = doe.querySelector('#vc-view * .menu.roll');
280 intro._introItems[6].position = "left";
281 break;
282 case 7:
283 KorAP._vcKeyMenu.dontHide = false;
284 KorAP._vcKeyMenu.hide();
285 KorAP.vc.fromJson(loc.TOUR_vcQuery);
286 intro._introItems[7].element = doe.querySelector('#vc-view * .doc');
287 intro._introItems[7].position = "left";
hebastaf95226b2019-09-19 11:37:00 +0200288 }
289 });
290
hebasta5df796f2019-05-21 15:27:12 +0200291 // Execute at the end of the tour (By clicking at the done-Button)
292 intro.oncomplete(function(){
293 KorAP.session.set("tour", true);
hebasta94e47cb2019-07-24 22:24:27 +0200294 doe.getElementById("qsubmit").click();
hebasta5df796f2019-05-21 15:27:12 +0200295 });
296
297 return intro;
hebasta75cfca52019-02-19 13:15:27 +0100298 },
hebasta5df796f2019-05-21 15:27:12 +0200299
300
301 /* Guided Tour to explain the different views of the results */
hebastaca61f812019-11-11 22:25:27 +0100302 gTshowResults: function(elparam){
303
304 let tourR = introClass();
hebastaee7b8a82020-01-20 12:45:04 +0100305 tourR.setOptions(usabilityOpts);
hebastaca61f812019-11-11 22:25:27 +0100306
hebasta87f1b1f2019-07-30 13:03:23 +0200307 //for testing purposes
hebasta5df796f2019-05-21 15:27:12 +0200308 if(elparam){
309 doe = elparam;
310 }
hebasta5df796f2019-05-21 15:27:12 +0200311 let StepsSR = [
hebasta87f1b1f2019-07-30 13:03:23 +0200312 //Step 1, intro_item 0
hebasta14bb8552021-11-10 16:35:31 +0100313 {
314 title: loc.TOUR_kwicti,
hebasta87f1b1f2019-07-30 13:03:23 +0200315 element: '#search',
316 intro: loc.TOUR_kwic ,
317 position: "auto",
318 },
319 //Step 2, intro_item 1
hebasta14bb8552021-11-10 16:35:31 +0100320 {
321 title: loc.TOUR_snippetti,
hebasta87f1b1f2019-07-30 13:03:23 +0200322 element: doe.querySelector("#search > ol > li"),
323 intro: loc.TOUR_snippet,
324 position: "bottom",
325 },
326 //Step 3, intro_item 2
hebasta14bb8552021-11-10 16:35:31 +0100327 {
328 title: loc.TOUR_snippetbti,
hebasta87f1b1f2019-07-30 13:03:23 +0200329 element: doe.querySelector("#search > ol > li"),
330 intro: loc.TOUR_snippetb,
331 position: "bottom",
332 },
333 //Step 4, intro_item 3
hebasta14bb8552021-11-10 16:35:31 +0100334 {
335 title: loc.TOUR_metadatabti,
hebasta87f1b1f2019-07-30 13:03:23 +0200336 element: doe.querySelector(".action > .metatable"),
337 intro: loc.TOUR_metadatab,
338 position: "bottom",
339 },
340 //Step 5, intro_item 4
hebasta14bb8552021-11-10 16:35:31 +0100341 {
342 title: loc.TOUR_metadatati,
hebasta87f1b1f2019-07-30 13:03:23 +0200343 element: doe.querySelector(".view.metatable"),
344 intro: loc.TOUR_metadata,
345 position: "auto",
346 },
347 //Step 6, intro_item 5
hebasta14bb8552021-11-10 16:35:31 +0100348 {
349 title: loc.TOUR_tokenbti,
hebasta87f1b1f2019-07-30 13:03:23 +0200350 element: doe.querySelector(".action > .info"),
351 intro: loc.TOUR_tokenb,
352 position: "bottom",
353 },
354 //Step 7, intro_item 6
hebasta14bb8552021-11-10 16:35:31 +0100355 {
356 title: loc.TOUR_tokenti,
hebasta87f1b1f2019-07-30 13:03:23 +0200357 element: doe.querySelector(".view.tokentable"),
358 intro: loc.TOUR_token,
359 position: "auto",
360 },
361 //Step 8, intro_item 7
hebasta14bb8552021-11-10 16:35:31 +0100362 {
363 title: loc.TOUR_treebti,
hebasta87f1b1f2019-07-30 13:03:23 +0200364 element: doe.querySelector(".tree"),
365 intro: loc.TOUR_treeb,
366 position: "bottom",
367 },
368 //Step 9, intro_item 8
hebasta14bb8552021-11-10 16:35:31 +0100369 {
370 title: loc.TOUR_treeti,
hebastaf95226b2019-09-19 11:37:00 +0200371 element: doe.querySelector(".view.relations"),
hebasta87f1b1f2019-07-30 13:03:23 +0200372 intro: loc.TOUR_tree,
hebastaf95226b2019-09-19 11:37:00 +0200373 position: "bottom",
hebasta87f1b1f2019-07-30 13:03:23 +0200374 },
375 //Step 10, intro_item 9
376 {
377 intro: loc.TOUR_tourdone,
378 }
hebasta5df796f2019-05-21 15:27:12 +0200379 ]
hebasta5df796f2019-05-21 15:27:12 +0200380
hebasta87f1b1f2019-07-30 13:03:23 +0200381 tourR.setOptions({steps:StepsSR});
hebastaee7b8a82020-01-20 12:45:04 +0100382 tourR.setOptions(labelOpts);
hebastaf95226b2019-09-19 11:37:00 +0200383
384 tourR.onbeforeexit(function(){
385 KorAP.session.set("tour", false);
hebasta87f1b1f2019-07-30 13:03:23 +0200386 });
hebasta87f1b1f2019-07-30 13:03:23 +0200387 //See also: https://introjs.com/docs/intro/options/
388 tourR.setOption('scrollToElement', true);
389 tourR.setOption('scrollTo','tooltip');
390 this.testPrerequ(StepsSR, tourR);
391
392 //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files
393 tourR.onbeforechange(function(targetedElement){
394
395 if(this._currentStep == 1){
396 KorAP.session.set("tour", false);
397 }
398
399 if(this._currentStep == 2){
400 doe.querySelector("#search > ol > li").click();
401 tourR._introItems[3].element = doe.querySelector('.action > .metatable');
402 tourR._introItems[3].position = "bottom";
403 }
404
405 if(this._currentStep == 4){
406 doe.querySelector(".metatable").click();
407 tourR._introItems[4].element = doe.querySelector('.view.metatable');
408 tourR._introItems[5].element = doe.querySelector('.action > .info');
409 tourR._introItems[5].position = "bottom";
410 }
411
412 if(this._currentStep == 6){
413 doe.querySelector(".info").click();
414 tourR._introItems[6].element = doe.querySelector('.view.tokentable');
415 tourR._introItems[7].element = doe.querySelector('.tree');
416 tourR._introItems[7].position = "bottom";
417 }
418
419 if(this._currentStep == 8){
420 doe.querySelector(".tree").click();
hebasta7fa6f082019-11-17 19:00:52 +0100421 let collect = document.querySelectorAll(".button-group-list")[0].querySelectorAll('li');
422 for(let i = 0; i < collect.length; i++){
423 if (collect[i].innerText == loc.TOUR_Relations) {
424 collect[i].click();
425 break;
426 }
427 }
hebastaf95226b2019-09-19 11:37:00 +0200428 tourR._introItems[8].element = doe.querySelector(".view.relations");
hebasta87f1b1f2019-07-30 13:03:23 +0200429 }
430 });
hebastaf95226b2019-09-19 11:37:00 +0200431
hebasta5df796f2019-05-21 15:27:12 +0200432 return tourR;
433 },
hebasta87f1b1f2019-07-30 13:03:23 +0200434 /*
435 * The total number of steps and the text of the tooltips are needed for jasmine testing.
436 */
437 testPrerequ: function(steps, tour){
438 //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files
439 let StepsT = steps;
440 let gtour = tour;
441 gtour.stepCount = StepsT.length;
442
443 //Array of intro content needed for efficient testing
444 gtour.testIntros = [];
445
446 for(let i = 0; i< StepsT.length; i++){
447 gtour.testIntros.push(StepsT[i].intro);
448 }
449 },
hebasta5df796f2019-05-21 15:27:12 +0200450
hebasta75cfca52019-02-19 13:15:27 +0100451 }
452});