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