Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | * TODO: Create lazy loading of objects including |
| 3 | * - obj.hint() |
| 4 | * - obj.alertify() |
| 5 | * - obj.session() |
| 6 | * - obj.tutorial() |
| 7 | * - obj.vc() // toggle |
| 8 | * - obj.matchCreate() (using webpack) |
| 9 | * - obj.koral() (show result, parse for errors ...) |
| 10 | * - obj.alignment() // toggle |
| 11 | */ |
| 12 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 13 | define([ |
| 14 | 'match', |
| 15 | 'hint', |
| 16 | 'vc', |
| 17 | 'tutorial', |
| 18 | 'lib/domReady', |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 19 | 'hint/array', |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 20 | 'vc/array', |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 21 | 'lib/alertify', |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 22 | 'session', |
Akron | be105b9 | 2016-01-04 14:13:20 +0100 | [diff] [blame] | 23 | 'tagger', |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 24 | 'selectMenu', |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 25 | 'api', |
Nils Diewald | c46003b | 2015-05-07 15:55:35 +0000 | [diff] [blame] | 26 | 'mailToChiffre', |
Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 27 | 'lib/highlight/highlight.pack', |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 28 | 'util' |
| 29 | ], function (matchClass, |
| 30 | hintClass, |
| 31 | vcClass, |
| 32 | tutClass, |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 33 | domReady, |
Nils Diewald | 4347ee9 | 2015-05-04 20:32:48 +0000 | [diff] [blame] | 34 | hintArray, |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 35 | vcArray, |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 36 | alertifyClass, |
Akron | be105b9 | 2016-01-04 14:13:20 +0100 | [diff] [blame] | 37 | sessionClass, |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 38 | tagger, |
| 39 | selectMenuClass) { |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 40 | |
| 41 | // Set hint array for hint helper |
| 42 | KorAP.hintArray = hintArray; |
| 43 | |
Akron | 9cc3eaf | 2015-06-10 22:15:52 +0200 | [diff] [blame] | 44 | // Localization values |
| 45 | var loc = KorAP.Locale; |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 46 | loc.VC_allCorpora = loc.VC_allCorpora || 'all Corpora'; |
| 47 | loc.VC_oneCollection = loc.VC_oneCollection || 'one Collection'; |
| 48 | loc.TOGGLE_ALIGN = loc.TOGGLE_ALIGN || 'toggle Alignment'; |
| 49 | loc.SHOW_KQ = loc.SHOW_KQ || 'show KoralQuery'; |
Akron | 9cc3eaf | 2015-06-10 22:15:52 +0200 | [diff] [blame] | 50 | |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 51 | // Override KorAP.log |
| 52 | window.alertify = alertifyClass; |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 53 | KorAP.log = function (code, msg) { |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 54 | |
| 55 | // Use alertify to log errors |
| 56 | alertifyClass.log( |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 57 | (code === 0 ? '' : code + ': ') + |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 58 | msg, |
| 59 | 'error', |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 60 | 10000 |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 61 | ); |
| 62 | }; |
| 63 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 64 | domReady(function (event) { |
| 65 | var obj = {}; |
Akron | 71b91e4 | 2016-06-01 22:12:43 +0200 | [diff] [blame] | 66 | |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 67 | var session = sessionClass.create('KalamarJS'); |
| 68 | |
| 69 | // What should be visible? |
| 70 | var show = session.get('show') || {}; |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 71 | |
| 72 | /** |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 73 | * Release notifications |
| 74 | */ |
| 75 | if (KorAP.Notifications !== undefined) { |
| 76 | var n = KorAP.Notifications; |
| 77 | for (var i = 0; i < n.length; i++) { |
| 78 | alertifyClass.log(n[i][1], n[i][0], 10000); |
| 79 | }; |
| 80 | }; |
| 81 | |
| 82 | /** |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 83 | * Replace Virtual Collection field |
| 84 | */ |
| 85 | var vcname; |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 86 | var input = document.getElementById('collection'); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 87 | if (input) { |
| 88 | input.style.display = 'none'; |
| 89 | vcname = document.createElement('span'); |
| 90 | vcname.setAttribute('id', 'vc-choose'); |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 91 | vcname.classList.add('select'); |
Akron | 941551e | 2015-06-11 16:06:22 +0200 | [diff] [blame] | 92 | |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 93 | var currentVC = loc.VC_allCorpora; |
| 94 | if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) { |
| 95 | currentVC = loc.VC_oneCollection; |
| 96 | }; |
| 97 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 98 | vcname.appendChild( |
| 99 | document.createTextNode( |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 100 | document.getElementById('collection-name').value || currentVC |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 101 | ) |
| 102 | ); |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 103 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 104 | input.parentNode.insertBefore(vcname, input); |
| 105 | }; |
| 106 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 107 | /** |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 108 | * Add actions to match entries |
| 109 | */ |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 110 | var inactiveLi = document.querySelectorAll( |
| 111 | '#search > ol > li:not(.active)' |
| 112 | ); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 113 | var i = 0; |
Akron | 6a535d4 | 2015-08-26 20:16:58 +0200 | [diff] [blame] | 114 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 115 | for (i = 0; i < inactiveLi.length; i++) { |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 116 | inactiveLi[i].addEventListener('click', function (e) { |
| 117 | if (this._match !== undefined) |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 118 | this._match.open(); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 119 | else { |
Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 120 | // lazyLoad |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 121 | matchClass.create(this).open(); |
| 122 | }; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 123 | e.halt(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 124 | }); |
Akron | 6a535d4 | 2015-08-26 20:16:58 +0200 | [diff] [blame] | 125 | inactiveLi[i].addEventListener('keydown', function (e) { |
| 126 | var code = _codeFromEvent(e); |
| 127 | |
| 128 | switch (code) { |
| 129 | case 32: |
| 130 | if (this._match !== undefined) |
| 131 | this._match.toggle(); |
| 132 | else { |
Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 133 | // lazyLoad |
Akron | 6a535d4 | 2015-08-26 20:16:58 +0200 | [diff] [blame] | 134 | matchClass.create(this).open(); |
| 135 | }; |
| 136 | e.halt(); |
| 137 | break; |
| 138 | }; |
| 139 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 142 | // Replace QL select menus with KorAP menus |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame^] | 143 | var qlField = document.getElementById('ql-field'); |
| 144 | if (qlField !== null) { |
| 145 | selectMenuClass.create( |
| 146 | document.getElementById('ql-field').parentNode |
| 147 | ).limit(5); |
| 148 | }; |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 149 | |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 150 | var result = document.getElementById('resultinfo'); |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 151 | var resultButton = null; |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 152 | if (result != null) { |
| 153 | resultButton = result.appendChild(document.createElement('div')); |
| 154 | resultButton.classList.add('result', 'button'); |
| 155 | }; |
| 156 | |
| 157 | // There is a koralQuery |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 158 | if (KorAP.koralQuery !== undefined) { |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 159 | |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 160 | if (resultButton !== null) { |
| 161 | var kq; |
| 162 | var toggle = document.createElement('a'); |
| 163 | toggle.setAttribute('title', loc.SHOW_KQ) |
| 164 | toggle.classList.add('show-kq', 'button'); |
| 165 | toggle.appendChild(document.createElement('span')) |
| 166 | .appendChild(document.createTextNode(loc.SHOW_KQ)); |
| 167 | resultButton.appendChild(toggle); |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 168 | |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 169 | var showKQ = function () { |
| 170 | if (kq === undefined) { |
| 171 | kq = document.createElement('div'); |
| 172 | kq.setAttribute('id', 'koralquery'); |
| 173 | kq.style.display = 'none'; |
| 174 | var kqInner = document.createElement('div'); |
| 175 | kq.appendChild(kqInner); |
| 176 | kqInner.innerHTML = JSON.stringify(KorAP.koralQuery, null, ' '); |
| 177 | hljs.highlightBlock(kqInner); |
| 178 | var sb = document.getElementById('search'); |
| 179 | sb.insertBefore(kq, sb.firstChild); |
| 180 | }; |
| 181 | |
| 182 | if (kq.style.display === 'none') { |
| 183 | kq.style.display = 'block'; |
| 184 | show['kq'] = true; |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 185 | } |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 186 | else { |
| 187 | kq.style.display = 'none'; |
| 188 | delete show['kq']; |
| 189 | }; |
| 190 | }; |
| 191 | |
| 192 | if (toggle !== undefined) { |
| 193 | |
| 194 | // Show koralquery |
| 195 | toggle.addEventListener('click', showKQ); |
| 196 | }; |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 197 | }; |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 198 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 199 | if (KorAP.koralQuery["errors"]) { |
| 200 | var errors = KorAP.koralQuery["errors"]; |
| 201 | for (var i in errors) { |
Akron | f0c31ed | 2016-06-11 11:27:01 +0200 | [diff] [blame] | 202 | |
| 203 | // Malformed query |
| 204 | if (errors[i][0] === 302 && errors[i][2]) { |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 205 | obj.hint = hintClass.create(); |
| 206 | obj.hint.alert(errors[i][2], errors[i][1]); |
| 207 | break; |
| 208 | } |
Akron | f0c31ed | 2016-06-11 11:27:01 +0200 | [diff] [blame] | 209 | |
| 210 | // no query |
| 211 | else if (errors[i][0] === 301) { |
| 212 | obj.hint = hintClass.create(); |
| 213 | obj.hint.alert(0, errors[i][1]); |
| 214 | } |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 215 | } |
| 216 | }; |
| 217 | |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 218 | // Session has KQ visibility stored |
| 219 | if (show["kq"]) |
| 220 | showKQ.apply(); |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 221 | }; |
| 222 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 223 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 224 | /** |
| 225 | * Toggle the alignment (left <=> right) |
| 226 | */ |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 227 | // querySelector('div.button.right'); |
| 228 | if (i > 0 && resultButton !== null) { |
| 229 | var toggle = document.createElement('a'); |
| 230 | toggle.setAttribute('title', loc.TOGGLE_ALIGN); |
| 231 | // Todo: Reuse old alignment from query |
| 232 | var cl = toggle.classList; |
| 233 | cl.add('align', 'right', 'button'); |
| 234 | toggle.addEventListener( |
| 235 | 'click', |
| 236 | function (e) { |
| 237 | var ol = document.querySelector('#search > ol'); |
| 238 | ol.toggleClass("align-left", "align-right"); |
| 239 | this.toggleClass("left", "right"); |
| 240 | }); |
| 241 | toggle.appendChild(document.createElement('span')) |
| 242 | .appendChild(document.createTextNode(loc.TOGGLE_ALIGN)); |
| 243 | resultButton.appendChild(toggle); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 244 | }; |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 245 | |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 246 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 247 | /** |
| 248 | * Toggle the Virtual Collection builder |
| 249 | */ |
| 250 | if (vcname) { |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 251 | var vc; |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 252 | var vcclick = function () { |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 253 | var view = document.getElementById('vc-view'); |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 254 | |
| 255 | // The vc is visible |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 256 | if (vcname.classList.contains('active')) { |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 257 | view.removeChild(vc.element()); |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 258 | vcname.classList.remove('active'); |
| 259 | delete show['collection']; |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | // The vc is not visible |
| 263 | else { |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 264 | if (vc === undefined) |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 265 | vc = _getCurrentVC(vcClass, vcArray); |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 266 | view.appendChild(vc.element()); |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 267 | vcname.classList.add('active'); |
| 268 | show['collection'] = true; |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 269 | }; |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 270 | }; |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 271 | vcname.onclick = vcclick; |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 272 | if (show['collection']) { |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 273 | vcclick.apply(); |
| 274 | }; |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 275 | }; |
| 276 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 277 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 278 | /** |
| 279 | * Init Tutorial view |
| 280 | */ |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 281 | if (document.getElementById('view-tutorial')) { |
| 282 | window.tutorial = tutClass.create( |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 283 | document.getElementById('view-tutorial'), |
| 284 | session |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 285 | ); |
| 286 | obj.tutorial = window.tutorial; |
| 287 | } |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 288 | |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 289 | // Tutorial is in parent |
| 290 | else if (window.parent) { |
| 291 | obj.tutorial = window.parent.tutorial; |
| 292 | }; |
| 293 | |
| 294 | // Initialize queries for document |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 295 | if (obj.tutorial) { |
Nils Diewald | 4347ee9 | 2015-05-04 20:32:48 +0000 | [diff] [blame] | 296 | obj.tutorial.initQueries(document); |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 297 | |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 298 | // Initialize documentation links |
| 299 | obj.tutorial.initDocLinks(document); |
| 300 | }; |
Nils Diewald | 61e6ff5 | 2015-05-07 17:26:50 +0000 | [diff] [blame] | 301 | |
Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 302 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 303 | /** |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 304 | * Add VC creation on submission. |
| 305 | */ |
| 306 | var form = document.getElementById('searchform'); |
Akron | 792f58b | 2015-07-08 18:59:36 +0200 | [diff] [blame] | 307 | if (form !== null) { |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 308 | form.addEventListener('submit', function (e) { |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 309 | var qf = document.getElementById('q-field'); |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 310 | |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 311 | // No query was defined |
| 312 | if (qf.value === undefined || qf.value === '') { |
| 313 | qf.focus(); |
| 314 | e.halt(); |
| 315 | KorAP.log(700, "No query given"); |
| 316 | return; |
| 317 | }; |
| 318 | |
| 319 | // Store session information |
| 320 | session.set("show", show); |
| 321 | |
| 322 | // Set Virtual collection |
| 323 | if (vc === undefined) { |
| 324 | vc = _getCurrentVC(vcClass, vcArray); |
| 325 | }; |
| 326 | |
| 327 | if (vc !== undefined) { |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 328 | input.value = vc.toQuery(); |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 329 | } |
| 330 | else { |
| 331 | delete input['value']; |
| 332 | }; |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 333 | }); |
| 334 | }; |
| 335 | |
| 336 | /** |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 337 | * Init hint helper |
| 338 | * has to be final because of |
| 339 | * reposition |
| 340 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 341 | // Todo: Pass an element, so this works with |
| 342 | // tutorial pages as well! |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 343 | if (obj.hint === undefined) |
| 344 | obj.hint = hintClass.create(); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 345 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 346 | return obj; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 347 | }); |
| 348 | }); |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 349 | |
| 350 | // Render Virtual collection |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 351 | function _getCurrentVC (vcClass, vcArray) { |
| 352 | var vc = vcClass.create(vcArray); |
| 353 | if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) { |
| 354 | vc.fromJson(KorAP.koralQuery["collection"]); |
| 355 | }; |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 356 | return vc; |
| 357 | }; |