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