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 | 84a7e0e | 2021-11-03 19:11:33 +0100 | [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 | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 31 | 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] | 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 | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 102 | title: loc.TOUR_sear1ti, |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 103 | element: '#q-field', |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 104 | intro: loc.TOUR_sear1, |
| 105 | position: 'bottom' |
| 106 | }, |
| 107 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 108 | title: loc.TOUR_searAnnotti, |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 109 | element: '#hint', |
| 110 | intro: loc.TOUR_searAnnot, |
| 111 | position: 'bottom' |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 112 | }, |
| 113 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 114 | title: loc.TOUR_annotAssti, |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 115 | element: doe.querySelector("#hint > .menu.hint"), |
| 116 | intro: loc.TOUR_annotAss, |
| 117 | position: 'bottom', |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 118 | }, |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 119 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 120 | title:loc.TOUR_vccho1ti, |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 121 | element:'#vc-choose', |
| 122 | intro: loc.TOUR_vccho1, |
| 123 | position: "bottom", |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 124 | }, |
| 125 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 126 | title: loc.TOUR_vccho2ti, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 127 | element:'#vc-view', |
| 128 | intro: loc.TOUR_vccho2, |
| 129 | position: "bottom", |
| 130 | }, |
| 131 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 132 | title: loc.TOUR_vcStat1ti, |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 133 | element: doe.querySelector('.statistic'), |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 134 | intro: loc.TOUR_vcStat1, |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 135 | position: "left", |
| 136 | }, |
| 137 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 138 | title: loc.TOUR_vcStat2ti, |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 139 | element: doe.querySelector('.stattable'), |
| 140 | intro: loc.TOUR_vcStat2, |
| 141 | position: "bottom", |
| 142 | }, |
| 143 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 144 | title: loc.TOUR_qlfieldti, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 145 | element: doe.querySelector('#ql-field').parentNode, |
| 146 | intro: loc.TOUR_qlfield, |
| 147 | position: "bottom", |
| 148 | }, |
| 149 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 150 | title: loc.TOUR_glimpseti, |
hebasta | bd53f82 | 2021-10-26 21:50:06 +0200 | [diff] [blame] | 151 | element: doe.querySelector('#glimpse').parentNode, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 152 | intro: loc.TOUR_glimpse, |
| 153 | position: "bottom", |
| 154 | }, |
| 155 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 156 | title: loc.TOUR_helpti, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 157 | element:'#view-tutorial', |
| 158 | intro: loc.TOUR_help, |
| 159 | position: "bottom", |
| 160 | }, |
| 161 | { |
hebasta | 84a7e0e | 2021-11-03 19:11:33 +0100 | [diff] [blame] | 162 | title: loc.TOUR_seargoti, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 163 | element: '#qsubmit', |
| 164 | intro: loc.TOUR_seargo, |
| 165 | position: "bottom", |
| 166 | }, |
| 167 | ]; |
| 168 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 169 | //pass in the Steps array created earlier |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 170 | intro.setOptions({steps: Steps}); |
| 171 | this.testPrerequ(Steps, intro); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 172 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 173 | //changes before executing the single steps |
| 174 | intro.onbeforechange(function(targetedElement){ |
| 175 | switch(targetedElement.id){ |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 176 | case "q-field": |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 177 | /* |
| 178 | * TODO: |
| 179 | * #268 is not merged at the time beeing: |
| 180 | * introJs.currentStep() merge requested https://github.com/usablica/intro.js/pull/268/files |
| 181 | */ |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 182 | targetedElement.value = loc.TOUR_Qexample; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 183 | break; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 184 | case "vc-view": |
Akron | 0b37f3e | 2021-02-09 10:32:03 +0100 | [diff] [blame] | 185 | let vchoo = doe.querySelector("#vc-choose"); |
| 186 | let vcv = doe.querySelector("#vc-view"); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 187 | KorAP._delete.apply(KorAP.vc.root()); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 188 | |
| 189 | KorAP.vc.fromJson(loc.TOUR_vcQuery); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 190 | if(!(vcv.querySelector(".active"))){ |
| 191 | vchoo.click(); |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 192 | /* |
| 193 | * Intro.js caches elements at the beginning, so element and position has to be set again. |
| 194 | */ |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 195 | intro._introItems[6].element = doe.querySelector('.statistic'); |
| 196 | intro._introItems[6].position = "left"; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 197 | } |
| 198 | break; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 199 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 200 | } |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 201 | |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 202 | if(this._currentStep == 7){ |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 203 | let statbut = doe.querySelector('.statistic'); |
| 204 | statbut.click(); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 205 | intro._introItems[7].element = doe.querySelector(".stattable"); |
| 206 | intro._introItems[7].position = "bottom"; |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 207 | } |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 208 | }); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 209 | |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 210 | intro.onbeforeexit(function(){ |
| 211 | if(KorAP.Hint.active() && KorAP.Hint.active().dontHide){ |
| 212 | KorAP.Hint.unshow(); |
| 213 | } |
| 214 | }); |
| 215 | |
| 216 | intro.onchange(function(targetElement) { |
| 217 | var that = this; |
| 218 | switch(this._currentStep){ |
| 219 | //hides Hint if back button is pressed |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 220 | case 2: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 221 | if(KorAP.Hint.active()){ |
| 222 | KorAP.Hint.unshow(); |
| 223 | } |
| 224 | break; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 225 | case 3: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 226 | KorAP.Hint.show(false); |
| 227 | KorAP.Hint.active().dontHide = true; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 228 | intro._introItems[3].element = doe.querySelector(".menu.roll.hint"); |
| 229 | intro._introItems[3].position = doe.querySelector("bottom"); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 230 | break; |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 231 | case 4: |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 232 | KorAP.Hint.unshow(); |
| 233 | break; |
| 234 | } |
| 235 | }); |
| 236 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 237 | // Execute at the end of the tour (By clicking at the done-Button) |
| 238 | intro.oncomplete(function(){ |
| 239 | KorAP.session.set("tour", true); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 240 | doe.getElementById("qsubmit").click(); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 241 | }); |
| 242 | |
| 243 | return intro; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 244 | }, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 245 | |
| 246 | |
| 247 | /* Guided Tour to explain the different views of the results */ |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 248 | gTshowResults: function(elparam){ |
| 249 | |
| 250 | let tourR = introClass(); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 251 | tourR.setOptions(usabilityOpts); |
hebasta | ca61f81 | 2019-11-11 22:25:27 +0100 | [diff] [blame] | 252 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 253 | //for testing purposes |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 254 | if(elparam){ |
| 255 | doe = elparam; |
| 256 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 257 | let StepsSR = [ |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 258 | //Step 1, intro_item 0 |
| 259 | { |
| 260 | element: '#search', |
| 261 | intro: loc.TOUR_kwic , |
| 262 | position: "auto", |
| 263 | }, |
| 264 | //Step 2, intro_item 1 |
| 265 | { |
| 266 | element: doe.querySelector("#search > ol > li"), |
| 267 | intro: loc.TOUR_snippet, |
| 268 | position: "bottom", |
| 269 | }, |
| 270 | //Step 3, intro_item 2 |
| 271 | { |
| 272 | element: doe.querySelector("#search > ol > li"), |
| 273 | intro: loc.TOUR_snippetb, |
| 274 | position: "bottom", |
| 275 | }, |
| 276 | //Step 4, intro_item 3 |
| 277 | { |
| 278 | element: doe.querySelector(".action > .metatable"), |
| 279 | intro: loc.TOUR_metadatab, |
| 280 | position: "bottom", |
| 281 | }, |
| 282 | //Step 5, intro_item 4 |
| 283 | { |
| 284 | element: doe.querySelector(".view.metatable"), |
| 285 | intro: loc.TOUR_metadata, |
| 286 | position: "auto", |
| 287 | }, |
| 288 | //Step 6, intro_item 5 |
| 289 | { |
| 290 | element: doe.querySelector(".action > .info"), |
| 291 | intro: loc.TOUR_tokenb, |
| 292 | position: "bottom", |
| 293 | }, |
| 294 | //Step 7, intro_item 6 |
| 295 | { |
| 296 | element: doe.querySelector(".view.tokentable"), |
| 297 | intro: loc.TOUR_token, |
| 298 | position: "auto", |
| 299 | }, |
| 300 | //Step 8, intro_item 7 |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 301 | { |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 302 | element: doe.querySelector(".tree"), |
| 303 | intro: loc.TOUR_treeb, |
| 304 | position: "bottom", |
| 305 | }, |
| 306 | //Step 9, intro_item 8 |
| 307 | { |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 308 | element: doe.querySelector(".view.relations"), |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 309 | intro: loc.TOUR_tree, |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 310 | position: "bottom", |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 311 | }, |
| 312 | //Step 10, intro_item 9 |
| 313 | { |
| 314 | intro: loc.TOUR_tourdone, |
| 315 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 316 | ] |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 317 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 318 | tourR.setOptions({steps:StepsSR}); |
hebasta | ee7b8a8 | 2020-01-20 12:45:04 +0100 | [diff] [blame] | 319 | tourR.setOptions(labelOpts); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 320 | |
| 321 | tourR.onbeforeexit(function(){ |
| 322 | KorAP.session.set("tour", false); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 323 | }); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 324 | //See also: https://introjs.com/docs/intro/options/ |
| 325 | tourR.setOption('scrollToElement', true); |
| 326 | tourR.setOption('scrollTo','tooltip'); |
| 327 | this.testPrerequ(StepsSR, tourR); |
| 328 | |
| 329 | //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files |
| 330 | tourR.onbeforechange(function(targetedElement){ |
| 331 | |
| 332 | if(this._currentStep == 1){ |
| 333 | KorAP.session.set("tour", false); |
| 334 | } |
| 335 | |
| 336 | if(this._currentStep == 2){ |
| 337 | doe.querySelector("#search > ol > li").click(); |
| 338 | tourR._introItems[3].element = doe.querySelector('.action > .metatable'); |
| 339 | tourR._introItems[3].position = "bottom"; |
| 340 | } |
| 341 | |
| 342 | if(this._currentStep == 4){ |
| 343 | doe.querySelector(".metatable").click(); |
| 344 | tourR._introItems[4].element = doe.querySelector('.view.metatable'); |
| 345 | tourR._introItems[5].element = doe.querySelector('.action > .info'); |
| 346 | tourR._introItems[5].position = "bottom"; |
| 347 | } |
| 348 | |
| 349 | if(this._currentStep == 6){ |
| 350 | doe.querySelector(".info").click(); |
| 351 | tourR._introItems[6].element = doe.querySelector('.view.tokentable'); |
| 352 | tourR._introItems[7].element = doe.querySelector('.tree'); |
| 353 | tourR._introItems[7].position = "bottom"; |
| 354 | } |
| 355 | |
| 356 | if(this._currentStep == 8){ |
| 357 | doe.querySelector(".tree").click(); |
hebasta | 7fa6f08 | 2019-11-17 19:00:52 +0100 | [diff] [blame] | 358 | let collect = document.querySelectorAll(".button-group-list")[0].querySelectorAll('li'); |
| 359 | for(let i = 0; i < collect.length; i++){ |
| 360 | if (collect[i].innerText == loc.TOUR_Relations) { |
| 361 | collect[i].click(); |
| 362 | break; |
| 363 | } |
| 364 | } |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 365 | tourR._introItems[8].element = doe.querySelector(".view.relations"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 366 | } |
| 367 | }); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame] | 368 | |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 369 | return tourR; |
| 370 | }, |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 371 | /* |
| 372 | * The total number of steps and the text of the tooltips are needed for jasmine testing. |
| 373 | */ |
| 374 | testPrerequ: function(steps, tour){ |
| 375 | //TODO see also: introJS.totalSteps() merge requested: //github.com/usablica/intro.js/pull/268/files |
| 376 | let StepsT = steps; |
| 377 | let gtour = tour; |
| 378 | gtour.stepCount = StepsT.length; |
| 379 | |
| 380 | //Array of intro content needed for efficient testing |
| 381 | gtour.testIntros = []; |
| 382 | |
| 383 | for(let i = 0; i< StepsT.length; i++){ |
| 384 | gtour.testIntros.push(StepsT[i].intro); |
| 385 | } |
| 386 | }, |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 387 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 388 | } |
| 389 | }); |