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