blob: f33c56d8fd03f56c67297ca356ee8e8c2d42deac [file] [log] [blame]
hebasta75cfca52019-02-19 13:15:27 +01001/**
2 * Guided Tour to explain the UI
3 *
4 * @author Helge Stallkamp
5 */
6
7define(['lib/intro', 'vc'], function(introClass, vcClass) {
8
9 //needed for localization of labels and contents of the tour
10 const loc = KorAP.Locale;
11
12 //labels for nextStep, previousStep, done and abort
13 loc.TOUR_lskip = loc.TOUR_lskip || "Abort";
14 loc.TOUR_lprev = loc.TOUR_lprev || "Back";
15 loc.TOUR_lnext = loc.TOUR_lnext || "Next";
16 loc.TOUR_ldone = loc.TOUR_ldone || "Done";
17
18 //localization tours
19 loc.TOUR_sear1 = loc.TOUR_sear1 || "Enter your search enquiry here.";
20 loc.TOUR_sear2 = loc.TOUR_sear2 || "For example the search for 'Baum'...";
21 loc.TOUR_searAnnot = loc.TOUR_searAnnot || "Annotation helper: By clicking here, the annotations of the differents layers are displayed and can be selected.";
22 loc.TOUR_annotAss = loc.TOUR_annotAss || "The annoation assistant helps to formulate queries with annotations";
23 loc.TOUR_vccho1 = loc.TOUR_vccho1 || "Choose corpus by clicking here.";
24 loc.TOUR_vccho2 = loc.TOUR_vccho2 || "Define your corpus here.";
25 loc.TOUR_vcStat = loc.TOUR_vcStat || "Display corpus statistic.";
26 loc.TOUR_qlfield = loc.TOUR_qlfield|| "You can use KorAP with different query languages, select the query language here.";
27 loc.TOUR_help = loc.TOUR_help || "Help and more information about KorAP.";
28 loc.TOUR_glimpse = loc.TOUR_glimpse || "Select to show only the first hits in arbitrary order.";
29 loc.TOUR_seargo = loc.TOUR_seargo || "Start the search.";
30
31 //localization of button labels
32 let labelOptions = {
33 'skipLabel': loc.TOUR_lskip,
34 'prevLabel': loc.TOUR_lprev,
35 'nextLabel': loc.TOUR_lnext,
36 'doneLabel': loc.TOUR_ldone,
37 'showStepNumbers': false,
38 };
39
40 let intro = introClass();
41 intro.setOptions(labelOptions);
42
43
44 return{
45
46 /**
47 * Guided Tour: Definition of steps
48 */
49 guidedTour:function(elparam){
50
51 var doe = document;
52 if(elparam){
53 doe = elparam;
54 }
55
56 let input = doe.querySelector("#q-field");
57 input.value="";
58
59 //steps of the example tour
60 let Steps =[
61 {
62 element: '#searchbar',
63 intro: loc.TOUR_sear1,
64 position: 'bottom'
65 },
66 {
67 element: '#searchbar',
68 intro: loc.TOUR_sear2,
69 position: 'bottom'
70 },
71 {
72 element: '#hint',
73 intro: loc.TOUR_searAnnot,
74 position: 'bottom'
75 },
76 {
77 element:'#vc-choose',
78 intro: loc.TOUR_vccho1,
79 position: "bottom",
80 },
81 {
82 element:'#vc-view',
83 intro: loc.TOUR_vccho2,
84 position: "bottom",
85 },
86 {
87 element: doe.querySelector('#ql-field').parentNode,
88 intro: loc.TOUR_qlfield,
89 position: "bottom",
90 },
91 {
Akrone9e5e832019-04-02 14:56:23 +020092 element:'#glimpse',
hebasta75cfca52019-02-19 13:15:27 +010093 intro: loc.TOUR_glimpse,
94 position: "bottom",
95 },
96 {
97 element:'#view-tutorial',
98 intro: loc.TOUR_help,
99 position: "bottom",
100 },
101 {
102 element: doe.querySelector('#searchbar button[type=submit]'),
103 intro: loc.TOUR_seargo,
104 position: "bottom",
105 },
106 ];
107
108 //pass in the Steps array created earlier
109 intro.setOptions({steps: Steps});
110
111 //total number of steps, needed for jasmine tests
112 //See also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files
113 intro.stepCount = Steps.length;
114
115 //array of intro content needed for efficient testing
116 intro.testIntros = [];
117 for(let i = 0; i< Steps.length; i++){
118 intro.testIntros.push(Steps[i].intro);
119 }
120
121 //changes before executing the single steps
122 intro.onbeforechange(function(targetedElement){
123 switch(targetedElement.id){
124 case "searchbar":
125 if(this._currentStep == 1){
126 input = doe.querySelector('#q-field');
127 input.value="Baum";
128 }
129 break;
130
131 case "vc-view":
132 vchoo = doe.querySelector("#vc-choose");
133 vcv = doe.querySelector("#vc-view");
134 KorAP._delete.apply(KorAP.vc.root());
135 KorAP.vc.root().key("creationDate").update();
136 KorAP.vc.root().value("1820").update();
137 if(!(vcv.querySelector(".active"))){
138 vchoo.click();
139 }
140 break;
141 }
142 });
143
144 // Execute at the end of the tour (By clicking at the done-Button)
145 intro.oncomplete(function(){
146 input.value="";
147 KorAP._delete.apply(KorAP.vc.root());
148 });
149
150 return intro;
151 },
152 }
153});