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