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 =[ |
hebasta | 2f7e540 | 2021-11-02 20:09:38 +0100 | [diff] [blame^] | 95 | { |
| 96 | element: '#link-guided-tour', |
hebasta | a84c7a9 | 2021-10-26 21:12:40 +0200 | [diff] [blame] | 97 | title: loc.TOUR_welcti, |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 98 | intro: loc.TOUR_welc, |
hebasta | 2f7e540 | 2021-11-02 20:09:38 +0100 | [diff] [blame^] | 99 | position: 'right', |
hebasta | 1e2d98e | 2019-10-30 15:58:17 +0100 | [diff] [blame] | 100 | }, |
| 101 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 102 | element: '#q-field', |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 103 | intro: loc.TOUR_sear1, |
| 104 | position: 'bottom' |
| 105 | }, |
| 106 | { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 107 | element: '#hint', |
| 108 | intro: loc.TOUR_searAnnot, |
| 109 | position: 'bottom' |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 110 | }, |
| 111 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 112 | element: doe.querySelector("#hint > .menu.hint"), |
| 113 | intro: loc.TOUR_annotAss, |
| 114 | position: 'bottom', |
| 115 | }, |
| 116 | { |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 117 | element:'#vc-choose', |
| 118 | intro: loc.TOUR_vccho1, |
| 119 | position: "bottom", |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 120 | }, |
| 121 | { |
| 122 | element:'#vc-view', |
| 123 | intro: loc.TOUR_vccho2, |
| 124 | position: "bottom", |
| 125 | }, |
| 126 | { |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 127 | element: doe.querySelector('.statistic'), |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 128 | intro: loc.TOUR_vcStat1, |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 129 | position: "left", |
| 130 | }, |
| 131 | { |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 132 | element: doe.querySelector('.stattable'), |
| 133 | intro: loc.TOUR_vcStat2, |
| 134 | position: "bottom", |
| 135 | }, |
| 136 | { |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 137 | element: doe.querySelector('#ql-field').parentNode, |
| 138 | intro: loc.TOUR_qlfield, |
| 139 | position: "bottom", |
| 140 | }, |
| 141 | { |
hebasta | bd53f82 | 2021-10-26 21:50:06 +0200 | [diff] [blame] | 142 | element: doe.querySelector('#glimpse').parentNode, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 143 | intro: loc.TOUR_glimpse, |
| 144 | position: "bottom", |
| 145 | }, |
| 146 | { |
| 147 | element:'#view-tutorial', |
| 148 | intro: loc.TOUR_help, |
| 149 | position: "bottom", |
| 150 | }, |
| 151 | { |
| 152 | element: '#qsubmit', |
| 153 | intro: loc.TOUR_seargo, |
| 154 | position: "bottom", |
| 155 | }, |
| 156 | ]; |
| 157 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 158 | //pass in the Steps array created earlier |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 159 | intro.setOptions({steps: Steps}); |
| 160 | this.testPrerequ(Steps, intro); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 161 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 162 | //changes before executing the single steps |
| 163 | intro.onbeforechange(function(targetedElement){ |
| 164 | switch(targetedElement.id){ |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 165 | case "q-field": |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 166 | /* |
| 167 | * TODO: |
| 168 | * #268 is not merged at the time beeing: |
| 169 | * introJs.currentStep() merge requested https://github.com/usablica/intro.js/pull/268/files |
| 170 | */ |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 171 | targetedElement.value = loc.TOUR_Qexample; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 172 | break; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 173 | case "vc-view": |
Akron | 0b37f3e | 2021-02-09 10:32:03 +0100 | [diff] [blame] | 174 | let vchoo = doe.querySelector("#vc-choose"); |
| 175 | let vcv = doe.querySelector("#vc-view"); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 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 | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 184 | intro._introItems[6].element = doe.querySelector('.statistic'); |
| 185 | intro._introItems[6].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 | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 191 | if(this._currentStep == 7){ |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 192 | let statbut = doe.querySelector('.statistic'); |
| 193 | statbut.click(); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 194 | intro._introItems[7].element = doe.querySelector(".stattable"); |
| 195 | intro._introItems[7].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 | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 209 | case 2: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 210 | if(KorAP.Hint.active()){ |
| 211 | KorAP.Hint.unshow(); |
| 212 | } |
| 213 | break; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 214 | case 3: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 215 | KorAP.Hint.show(false); |
| 216 | KorAP.Hint.active().dontHide = true; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 217 | intro._introItems[3].element = doe.querySelector(".menu.roll.hint"); |
| 218 | intro._introItems[3].position = doe.querySelector("bottom"); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 219 | break; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 220 | case 4: |
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(); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 240 | tourR.setOptions(usabilityOpts); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 241 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 242 | //for testing purposes |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 243 | if(elparam){ |
| 244 | doe = elparam; |
| 245 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 246 | let StepsSR = [ |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 247 | //Step 1, intro_item 0 |
| 248 | { |
| 249 | element: '#search', |
| 250 | intro: loc.TOUR_kwic , |
| 251 | position: "auto", |
| 252 | }, |
| 253 | //Step 2, intro_item 1 |
| 254 | { |
| 255 | element: doe.querySelector("#search > ol > li"), |
| 256 | intro: loc.TOUR_snippet, |
| 257 | position: "bottom", |
| 258 | }, |
| 259 | //Step 3, intro_item 2 |
| 260 | { |
| 261 | element: doe.querySelector("#search > ol > li"), |
| 262 | intro: loc.TOUR_snippetb, |
| 263 | position: "bottom", |
| 264 | }, |
| 265 | //Step 4, intro_item 3 |
| 266 | { |
| 267 | element: doe.querySelector(".action > .metatable"), |
| 268 | intro: loc.TOUR_metadatab, |
| 269 | position: "bottom", |
| 270 | }, |
| 271 | //Step 5, intro_item 4 |
| 272 | { |
| 273 | element: doe.querySelector(".view.metatable"), |
| 274 | intro: loc.TOUR_metadata, |
| 275 | position: "auto", |
| 276 | }, |
| 277 | //Step 6, intro_item 5 |
| 278 | { |
| 279 | element: doe.querySelector(".action > .info"), |
| 280 | intro: loc.TOUR_tokenb, |
| 281 | position: "bottom", |
| 282 | }, |
| 283 | //Step 7, intro_item 6 |
| 284 | { |
| 285 | element: doe.querySelector(".view.tokentable"), |
| 286 | intro: loc.TOUR_token, |
| 287 | position: "auto", |
| 288 | }, |
| 289 | //Step 8, intro_item 7 |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 290 | { |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 291 | element: doe.querySelector(".tree"), |
| 292 | intro: loc.TOUR_treeb, |
| 293 | position: "bottom", |
| 294 | }, |
| 295 | //Step 9, intro_item 8 |
| 296 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 297 | element: doe.querySelector(".view.relations"), |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 298 | intro: loc.TOUR_tree, |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 299 | position: "bottom", |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 300 | }, |
| 301 | //Step 10, intro_item 9 |
| 302 | { |
| 303 | intro: loc.TOUR_tourdone, |
| 304 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 305 | ] |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 306 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 307 | tourR.setOptions({steps:StepsSR}); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 308 | tourR.setOptions(labelOpts); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 309 | |
| 310 | tourR.onbeforeexit(function(){ |
| 311 | KorAP.session.set("tour", false); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 312 | }); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 313 | //See also: https://introjs.com/docs/intro/options/ |
| 314 | tourR.setOption('scrollToElement', true); |
| 315 | tourR.setOption('scrollTo','tooltip'); |
| 316 | this.testPrerequ(StepsSR, tourR); |
| 317 | |
| 318 | //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files |
| 319 | tourR.onbeforechange(function(targetedElement){ |
| 320 | |
| 321 | if(this._currentStep == 1){ |
| 322 | KorAP.session.set("tour", false); |
| 323 | } |
| 324 | |
| 325 | if(this._currentStep == 2){ |
| 326 | doe.querySelector("#search > ol > li").click(); |
| 327 | tourR._introItems[3].element = doe.querySelector('.action > .metatable'); |
| 328 | tourR._introItems[3].position = "bottom"; |
| 329 | } |
| 330 | |
| 331 | if(this._currentStep == 4){ |
| 332 | doe.querySelector(".metatable").click(); |
| 333 | tourR._introItems[4].element = doe.querySelector('.view.metatable'); |
| 334 | tourR._introItems[5].element = doe.querySelector('.action > .info'); |
| 335 | tourR._introItems[5].position = "bottom"; |
| 336 | } |
| 337 | |
| 338 | if(this._currentStep == 6){ |
| 339 | doe.querySelector(".info").click(); |
| 340 | tourR._introItems[6].element = doe.querySelector('.view.tokentable'); |
| 341 | tourR._introItems[7].element = doe.querySelector('.tree'); |
| 342 | tourR._introItems[7].position = "bottom"; |
| 343 | } |
| 344 | |
| 345 | if(this._currentStep == 8){ |
| 346 | doe.querySelector(".tree").click(); |
hebasta | 7fa6f08 | 2019-11-17 19:00:52 +0100 | [diff] [blame] | 347 | let collect = document.querySelectorAll(".button-group-list")[0].querySelectorAll('li'); |
| 348 | for(let i = 0; i < collect.length; i++){ |
| 349 | if (collect[i].innerText == loc.TOUR_Relations) { |
| 350 | collect[i].click(); |
| 351 | break; |
| 352 | } |
| 353 | } |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 354 | tourR._introItems[8].element = doe.querySelector(".view.relations"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 355 | } |
| 356 | }); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 357 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 358 | return tourR; |
| 359 | }, |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 360 | /* |
| 361 | * The total number of steps and the text of the tooltips are needed for jasmine testing. |
| 362 | */ |
| 363 | testPrerequ: function(steps, tour){ |
| 364 | //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files |
| 365 | let StepsT = steps; |
| 366 | let gtour = tour; |
| 367 | gtour.stepCount = StepsT.length; |
| 368 | |
| 369 | //Array of intro content needed for efficient testing |
| 370 | gtour.testIntros = []; |
| 371 | |
| 372 | for(let i = 0; i< StepsT.length; i++){ |
| 373 | gtour.testIntros.push(StepsT[i].intro); |
| 374 | } |
| 375 | }, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 376 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 377 | } |
| 378 | }); |