hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1 | /** |
| 2 | * Guided Tour to explain the UI |
| 3 | * |
| 4 | * @author Helge Stallkamp |
| 5 | */ |
| 6 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 7 | |
| 8 | define(['lib/intro', 'vc', 'hint', 'menu', 'vc/doc', 'vc/docgroup'], function(introClass, vcClass, hintClass, menuClass, docClass, docGroup) { |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 9 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 10 | //needed for localization of labels and contents of the tour |
| 11 | const loc = KorAP.Locale; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 12 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 13 | //labels for nextStep, previousStep, done and abort |
| 14 | loc.TOUR_lskip = loc.TOUR_lskip || "Abort"; |
| 15 | loc.TOUR_lprev = loc.TOUR_lprev || "Back"; |
| 16 | loc.TOUR_lnext = loc.TOUR_lnext || "Next"; |
| 17 | loc.TOUR_ldone = loc.TOUR_ldone || "Done"; |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame^] | 18 | loc.TOUR_ldoneSearch = loc.TOUR_ldoneSearch || "Search"; |
| 19 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 20 | //localization guided tour gTstartSearch |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 21 | loc.TOUR_welc = loc.TOUR_welc || "<span class='tgreeting'> Welcome to our guided tour!</span>" + |
| 22 | "<p class='pfirstStep'> This tour should give you a quick introduction to KorAP. </p>" + |
| 23 | "<p> Please note, that if you already defined a corpus or query, these definitions are deleted during the guided tour. " + |
| 24 | "If you don't want that, you can stop the tour now with <code>" + |
| 25 | loc.TOUR_lskip + "</code>. </p> </div>"; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 26 | loc.TOUR_sear1 = loc.TOUR_sear1 || "Enter your search enquiry here."; |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 27 | loc.TOUR_sear2 = loc.TOUR_sear2 || "For example the search for '" + loc.TOUR_Qexample + "'."; |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 28 | loc.TOUR_searAnnot = loc.TOUR_searAnnot || "Annotation helper"; |
| 29 | loc.TOUR_annotAss = loc.TOUR_annotAss || "The assistant displays the annotations of the different layers and helps to formulate queries."; |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 30 | loc.TOUR_vccho1 = loc.TOUR_vccho1 || "Choose corpus"; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 31 | loc.TOUR_vccho2 = loc.TOUR_vccho2 || "Define your corpus here."; |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 32 | loc.TOUR_vcStat1 = loc.TOUR_vcStat1 || "Click here to display corpus statistic."; |
| 33 | loc.TOUR_vcStat2 = loc.TOUR_vcStat2 || "Corpus statistic"; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 34 | loc.TOUR_qlfield = loc.TOUR_qlfield|| "Selection of the query language: You can use KorAP with different query languages."; |
| 35 | loc.TOUR_help = loc.TOUR_help || "Help and information about KorAP."; |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame^] | 36 | loc.TOUR_glimpse = loc.TOUR_glimpse || "Select this to show only the first hits in undefined order."; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 37 | loc.TOUR_seargo = loc.TOUR_seargo || "Start the search"; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 38 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 39 | //localization guided Tour gTshowResults |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 40 | loc.TOUR_kwic = loc.TOUR_kwic || "KWIC result (keyword in context)"; |
| 41 | loc.TOUR_snippet = loc.TOUR_snippet || "Click on a match to show a larger snippet."; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 42 | loc.TOUR_snippetb = loc.TOUR_snippetb || "Snippet"; |
| 43 | loc.TOUR_metadatab = loc.TOUR_metadatab || "Display of metadata"; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 44 | loc.TOUR_metadata = loc.TOUR_metadata || "Metadata"; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 45 | loc.TOUR_tokenb = loc.TOUR_tokenb || "Display of token annotations"; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 46 | loc.TOUR_token = loc.TOUR_token || "KorAP supports multiple annotations."; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 47 | loc.TOUR_treeb = loc.TOUR_treeb || "Display further annotations" |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 48 | loc.TOUR_tree = loc.TOUR_tree || "Further annotations can be displayed as tree and arch views." |
| 49 | loc.TOUR_tourdone = loc.TOUR_tourdone || "Have fun with KorAP!"; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 50 | |
| 51 | //localization of button labels |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 52 | let labelOptions = { |
| 53 | 'skipLabel': loc.TOUR_lskip, |
| 54 | 'prevLabel': loc.TOUR_lprev, |
| 55 | 'nextLabel': loc.TOUR_lnext, |
| 56 | 'doneLabel': loc.TOUR_ldone, |
| 57 | 'showStepNumbers': false, |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 58 | }; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 59 | |
| 60 | var doe = document; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 61 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 62 | return{ |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 63 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 64 | /** |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 65 | * Guided Tour gTstartSearch: Explains the search functionality |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 66 | */ |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 67 | gTstartSearch:function(elparam){ |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 68 | let intro = introClass(); |
| 69 | intro.setOptions(labelOptions); |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 70 | intro.setOption('tooltipClass', 'gTstartSearch'); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame^] | 71 | intro.setOption('hideNext', true); |
| 72 | intro.setOption('hidePrev', true); |
| 73 | /* |
| 74 | * Sets button labels for the last step of the tour |
| 75 | * Because Kalamar is a multipage webapplication, this tours starts by |
| 76 | * completion the gTshowResults Tour. Therefore the label of the done button changed. |
| 77 | */ |
| 78 | intro.setOption('doneLabel', loc.TOUR_ldoneSearch ); |
| 79 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 80 | //for testing purposes |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 81 | if(elparam){ |
| 82 | doe = elparam; |
| 83 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 84 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 85 | let input = doe.querySelector("#q-field"); |
| 86 | input.value=""; |
| 87 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 88 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 89 | //steps of the example tour |
| 90 | let Steps =[ |
| 91 | { |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 92 | intro: loc.TOUR_welc, |
| 93 | }, |
| 94 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 95 | element: '#q-field', |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 96 | intro: loc.TOUR_sear1, |
| 97 | position: 'bottom' |
| 98 | }, |
| 99 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 100 | element: '#q-field', |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 101 | intro: loc.TOUR_sear2, |
| 102 | position: 'bottom' |
| 103 | }, |
| 104 | { |
| 105 | element: '#hint', |
| 106 | intro: loc.TOUR_searAnnot, |
| 107 | position: 'bottom' |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 108 | }, |
| 109 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 110 | element: doe.querySelector("#hint > .menu.hint"), |
| 111 | intro: loc.TOUR_annotAss, |
| 112 | position: 'bottom', |
| 113 | }, |
| 114 | { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 115 | element:'#vc-choose', |
| 116 | intro: loc.TOUR_vccho1, |
| 117 | position: "bottom", |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 118 | }, |
| 119 | { |
| 120 | element:'#vc-view', |
| 121 | intro: loc.TOUR_vccho2, |
| 122 | position: "bottom", |
| 123 | }, |
| 124 | { |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 125 | element: doe.querySelector('.statistic'), |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 126 | intro: loc.TOUR_vcStat1, |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 127 | position: "left", |
| 128 | }, |
| 129 | { |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 130 | element: doe.querySelector('.stattable'), |
| 131 | intro: loc.TOUR_vcStat2, |
| 132 | position: "bottom", |
| 133 | }, |
| 134 | { |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 135 | element: doe.querySelector('#ql-field').parentNode, |
| 136 | intro: loc.TOUR_qlfield, |
| 137 | position: "bottom", |
| 138 | }, |
| 139 | { |
| 140 | element:'#glimpse', |
| 141 | intro: loc.TOUR_glimpse, |
| 142 | position: "bottom", |
| 143 | }, |
| 144 | { |
| 145 | element:'#view-tutorial', |
| 146 | intro: loc.TOUR_help, |
| 147 | position: "bottom", |
| 148 | }, |
| 149 | { |
| 150 | element: '#qsubmit', |
| 151 | intro: loc.TOUR_seargo, |
| 152 | position: "bottom", |
| 153 | }, |
| 154 | ]; |
| 155 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 156 | //pass in the Steps array created earlier |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 157 | intro.setOptions({steps: Steps}); |
| 158 | this.testPrerequ(Steps, intro); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame^] | 159 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 160 | //changes before executing the single steps |
| 161 | intro.onbeforechange(function(targetedElement){ |
| 162 | switch(targetedElement.id){ |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 163 | case "q-field": |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 164 | /* |
| 165 | * TODO: |
| 166 | * #268 is not merged at the time beeing: |
| 167 | * introJs.currentStep() merge requested https://github.com/usablica/intro.js/pull/268/files |
| 168 | */ |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 169 | if(this._currentStep == 2){ |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 170 | targetedElement.value = loc.TOUR_Qexample; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 171 | } |
| 172 | break; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 173 | case "vc-view": |
| 174 | vchoo = doe.querySelector("#vc-choose"); |
| 175 | vcv = doe.querySelector("#vc-view"); |
| 176 | KorAP._delete.apply(KorAP.vc.root()); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 177 | |
| 178 | KorAP.vc.fromJson(loc.TOUR_vcQuery); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 179 | if(!(vcv.querySelector(".active"))){ |
| 180 | vchoo.click(); |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 181 | /* |
| 182 | * Intro.js caches elements at the beginning, so element and position has to be set again. |
| 183 | */ |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 184 | intro._introItems[7].element = doe.querySelector('.statistic'); |
| 185 | intro._introItems[7].position = "left"; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 186 | } |
| 187 | break; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 188 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 189 | } |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 190 | |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 191 | if(this._currentStep == 8){ |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 192 | let statbut = doe.querySelector('.statistic'); |
| 193 | statbut.click(); |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 194 | intro._introItems[8].element = doe.querySelector(".stattable"); |
| 195 | intro._introItems[8].position = "bottom"; |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 196 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 197 | }); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 198 | |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 199 | intro.onbeforeexit(function(){ |
| 200 | if(KorAP.Hint.active() && KorAP.Hint.active().dontHide){ |
| 201 | KorAP.Hint.unshow(); |
| 202 | } |
| 203 | }); |
| 204 | |
| 205 | intro.onchange(function(targetElement) { |
| 206 | var that = this; |
| 207 | switch(this._currentStep){ |
| 208 | //hides Hint if back button is pressed |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 209 | case 3: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 210 | if(KorAP.Hint.active()){ |
| 211 | KorAP.Hint.unshow(); |
| 212 | } |
| 213 | break; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 214 | case 4: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 215 | KorAP.Hint.show(false); |
| 216 | KorAP.Hint.active().dontHide = true; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 217 | intro._introItems[4].element = doe.querySelector(".menu.roll.hint"); |
| 218 | intro._introItems[4].position = doe.querySelector("bottom"); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 219 | break; |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 220 | case 5: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 221 | KorAP.Hint.unshow(); |
| 222 | break; |
| 223 | } |
| 224 | }); |
| 225 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 226 | // Execute at the end of the tour (By clicking at the done-Button) |
| 227 | intro.oncomplete(function(){ |
| 228 | KorAP.session.set("tour", true); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 229 | doe.getElementById("qsubmit").click(); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 230 | }); |
| 231 | |
| 232 | return intro; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 233 | }, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 234 | |
| 235 | |
| 236 | /* Guided Tour to explain the different views of the results */ |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame^] | 237 | gTshowResults: function(elparam){ |
| 238 | |
| 239 | let tourR = introClass(); |
| 240 | tourR.setOption('hideNext', true); |
| 241 | tourR.setOption('hidePrev', true); |
| 242 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 243 | //for testing purposes |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 244 | if(elparam){ |
| 245 | doe = elparam; |
| 246 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 247 | let StepsSR = [ |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 248 | //Step 1, intro_item 0 |
| 249 | { |
| 250 | element: '#search', |
| 251 | intro: loc.TOUR_kwic , |
| 252 | position: "auto", |
| 253 | }, |
| 254 | //Step 2, intro_item 1 |
| 255 | { |
| 256 | element: doe.querySelector("#search > ol > li"), |
| 257 | intro: loc.TOUR_snippet, |
| 258 | position: "bottom", |
| 259 | }, |
| 260 | //Step 3, intro_item 2 |
| 261 | { |
| 262 | element: doe.querySelector("#search > ol > li"), |
| 263 | intro: loc.TOUR_snippetb, |
| 264 | position: "bottom", |
| 265 | }, |
| 266 | //Step 4, intro_item 3 |
| 267 | { |
| 268 | element: doe.querySelector(".action > .metatable"), |
| 269 | intro: loc.TOUR_metadatab, |
| 270 | position: "bottom", |
| 271 | }, |
| 272 | //Step 5, intro_item 4 |
| 273 | { |
| 274 | element: doe.querySelector(".view.metatable"), |
| 275 | intro: loc.TOUR_metadata, |
| 276 | position: "auto", |
| 277 | }, |
| 278 | //Step 6, intro_item 5 |
| 279 | { |
| 280 | element: doe.querySelector(".action > .info"), |
| 281 | intro: loc.TOUR_tokenb, |
| 282 | position: "bottom", |
| 283 | }, |
| 284 | //Step 7, intro_item 6 |
| 285 | { |
| 286 | element: doe.querySelector(".view.tokentable"), |
| 287 | intro: loc.TOUR_token, |
| 288 | position: "auto", |
| 289 | }, |
| 290 | //Step 8, intro_item 7 |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 291 | { |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 292 | element: doe.querySelector(".tree"), |
| 293 | intro: loc.TOUR_treeb, |
| 294 | position: "bottom", |
| 295 | }, |
| 296 | //Step 9, intro_item 8 |
| 297 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 298 | element: doe.querySelector(".view.relations"), |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 299 | intro: loc.TOUR_tree, |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 300 | position: "bottom", |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 301 | }, |
| 302 | //Step 10, intro_item 9 |
| 303 | { |
| 304 | intro: loc.TOUR_tourdone, |
| 305 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 306 | ] |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 307 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 308 | tourR.setOptions({steps:StepsSR}); |
| 309 | tourR.setOptions(labelOptions); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 310 | |
| 311 | tourR.onbeforeexit(function(){ |
| 312 | KorAP.session.set("tour", false); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 313 | }); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 314 | //See also: https://introjs.com/docs/intro/options/ |
| 315 | tourR.setOption('scrollToElement', true); |
| 316 | tourR.setOption('scrollTo','tooltip'); |
| 317 | this.testPrerequ(StepsSR, tourR); |
| 318 | |
| 319 | //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files |
| 320 | tourR.onbeforechange(function(targetedElement){ |
| 321 | |
| 322 | if(this._currentStep == 1){ |
| 323 | KorAP.session.set("tour", false); |
| 324 | } |
| 325 | |
| 326 | if(this._currentStep == 2){ |
| 327 | doe.querySelector("#search > ol > li").click(); |
| 328 | tourR._introItems[3].element = doe.querySelector('.action > .metatable'); |
| 329 | tourR._introItems[3].position = "bottom"; |
| 330 | } |
| 331 | |
| 332 | if(this._currentStep == 4){ |
| 333 | doe.querySelector(".metatable").click(); |
| 334 | tourR._introItems[4].element = doe.querySelector('.view.metatable'); |
| 335 | tourR._introItems[5].element = doe.querySelector('.action > .info'); |
| 336 | tourR._introItems[5].position = "bottom"; |
| 337 | } |
| 338 | |
| 339 | if(this._currentStep == 6){ |
| 340 | doe.querySelector(".info").click(); |
| 341 | tourR._introItems[6].element = doe.querySelector('.view.tokentable'); |
| 342 | tourR._introItems[7].element = doe.querySelector('.tree'); |
| 343 | tourR._introItems[7].position = "bottom"; |
| 344 | } |
| 345 | |
| 346 | if(this._currentStep == 8){ |
| 347 | doe.querySelector(".tree").click(); |
| 348 | document.querySelectorAll(".button-group-list")[0].querySelectorAll('li')[1].click(); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 349 | tourR._introItems[8].element = doe.querySelector(".view.relations"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 350 | } |
| 351 | }); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 352 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 353 | return tourR; |
| 354 | }, |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 355 | /* |
| 356 | * The total number of steps and the text of the tooltips are needed for jasmine testing. |
| 357 | */ |
| 358 | testPrerequ: function(steps, tour){ |
| 359 | //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files |
| 360 | let StepsT = steps; |
| 361 | let gtour = tour; |
| 362 | gtour.stepCount = StepsT.length; |
| 363 | |
| 364 | //Array of intro content needed for efficient testing |
| 365 | gtour.testIntros = []; |
| 366 | |
| 367 | for(let i = 0; i< StepsT.length; i++){ |
| 368 | gtour.testIntros.push(StepsT[i].intro); |
| 369 | } |
| 370 | }, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 371 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 372 | } |
| 373 | }); |