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 | */ |
Akron | e51eaa3 | 2020-11-10 09:35:53 +0100 | [diff] [blame] | 6 | "use strict"; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 7 | |
Akron | e51eaa3 | 2020-11-10 09:35:53 +0100 | [diff] [blame] | 8 | define(['lib/intro', 'vc', 'hint', 'menu', 'vc/doc', 'vc/docgroup'], |
| 9 | function(introClass, vcClass, hintClass, menuClass, docClass, docGroup) { |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 10 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 11 | //needed for localization of labels and contents of the tour |
| 12 | const loc = KorAP.Locale; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 13 | |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame^] | 14 | //labels for nextStep, previousStep and done |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 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 | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame^] | 21 | 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. " + |
| 23 | "We lead you step by step through an example."; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 24 | loc.TOUR_sear1 = loc.TOUR_sear1 || "Input field for the query, 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 | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 49 | let labelOpts= { |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 50 | 'prevLabel': loc.TOUR_lprev, |
| 51 | 'nextLabel': loc.TOUR_lnext, |
| 52 | 'doneLabel': loc.TOUR_ldone, |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 53 | 'showStepNumbers': false |
| 54 | }; |
| 55 | |
| 56 | //usability options of tours |
| 57 | let usabilityOpts ={ |
| 58 | 'showBullets': false, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame^] | 59 | 'overlayOpacity': 0.5, |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 60 | 'exitOnOverlayClick': false, |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame^] | 61 | 'disableInteraction': true, |
| 62 | 'tooltipClass': 'customTooltip', |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 63 | 'hidePrev': true |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 64 | }; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 65 | |
| 66 | var doe = document; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 67 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 68 | return{ |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 69 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 70 | /** |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 71 | * Guided Tour gTstartSearch: Explains the search functionality |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 72 | */ |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 73 | gTstartSearch:function(elparam){ |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 74 | let intro = introClass(); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 75 | intro.setOptions(labelOpts); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 76 | /* |
| 77 | * Sets button labels for the last step of the tour |
| 78 | * Because Kalamar is a multipage webapplication, this tours starts by |
| 79 | * completion the gTshowResults Tour. Therefore the label of the done button changed. |
| 80 | */ |
| 81 | intro.setOption('doneLabel', loc.TOUR_ldoneSearch ); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 82 | intro.setOptions(usabilityOpts); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 83 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 84 | //for testing purposes |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 85 | if(elparam){ |
| 86 | doe = elparam; |
| 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 | let input = doe.querySelector("#q-field"); |
| 90 | input.value=""; |
| 91 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 92 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 93 | //steps of the example tour |
| 94 | let Steps =[ |
| 95 | { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame^] | 96 | title: loc.TOUR_welcti, |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 97 | intro: loc.TOUR_welc, |
| 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_sear1, |
| 102 | position: 'bottom' |
| 103 | }, |
| 104 | { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 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 | { |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame^] | 140 | element: '#glimpse', |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 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 | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 169 | targetedElement.value = loc.TOUR_Qexample; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 170 | break; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 171 | case "vc-view": |
Akron | 0b37f3e | 2021-02-09 10:32:03 +0100 | [diff] [blame] | 172 | let vchoo = doe.querySelector("#vc-choose"); |
| 173 | let vcv = doe.querySelector("#vc-view"); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 174 | KorAP._delete.apply(KorAP.vc.root()); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 175 | |
| 176 | KorAP.vc.fromJson(loc.TOUR_vcQuery); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 177 | if(!(vcv.querySelector(".active"))){ |
| 178 | vchoo.click(); |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 179 | /* |
| 180 | * Intro.js caches elements at the beginning, so element and position has to be set again. |
| 181 | */ |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 182 | intro._introItems[6].element = doe.querySelector('.statistic'); |
| 183 | intro._introItems[6].position = "left"; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 184 | } |
| 185 | break; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 186 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 187 | } |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 188 | |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 189 | if(this._currentStep == 7){ |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 190 | let statbut = doe.querySelector('.statistic'); |
| 191 | statbut.click(); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 192 | intro._introItems[7].element = doe.querySelector(".stattable"); |
| 193 | intro._introItems[7].position = "bottom"; |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 194 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 195 | }); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 196 | |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 197 | intro.onbeforeexit(function(){ |
| 198 | if(KorAP.Hint.active() && KorAP.Hint.active().dontHide){ |
| 199 | KorAP.Hint.unshow(); |
| 200 | } |
| 201 | }); |
| 202 | |
| 203 | intro.onchange(function(targetElement) { |
| 204 | var that = this; |
| 205 | switch(this._currentStep){ |
| 206 | //hides Hint if back button is pressed |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 207 | case 2: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 208 | if(KorAP.Hint.active()){ |
| 209 | KorAP.Hint.unshow(); |
| 210 | } |
| 211 | break; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 212 | case 3: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 213 | KorAP.Hint.show(false); |
| 214 | KorAP.Hint.active().dontHide = true; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 215 | intro._introItems[3].element = doe.querySelector(".menu.roll.hint"); |
| 216 | intro._introItems[3].position = doe.querySelector("bottom"); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 217 | break; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 218 | case 4: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 219 | KorAP.Hint.unshow(); |
| 220 | break; |
| 221 | } |
| 222 | }); |
| 223 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 224 | // Execute at the end of the tour (By clicking at the done-Button) |
| 225 | intro.oncomplete(function(){ |
| 226 | KorAP.session.set("tour", true); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 227 | doe.getElementById("qsubmit").click(); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 228 | }); |
| 229 | |
| 230 | return intro; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 231 | }, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 232 | |
| 233 | |
| 234 | /* Guided Tour to explain the different views of the results */ |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 235 | gTshowResults: function(elparam){ |
| 236 | |
| 237 | let tourR = introClass(); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 238 | tourR.setOptions(usabilityOpts); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 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}); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 306 | tourR.setOptions(labelOpts); |
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 | }); |