@qld-gov-au/qgds-bootstrap5 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.js +1 -1
- package/.storybook/preview.js +8 -0
- package/README.md +96 -46
- package/dist/assets/css/qld.bootstrap.css +1 -1
- package/dist/assets/css/qld.bootstrap.css.map +3 -3
- package/dist/assets/js/handlebars.helpers.bundle.js +1 -1
- package/dist/assets/js/handlebars.helpers.bundle.js.map +3 -3
- package/dist/assets/js/handlebars.helpers.js +4 -8
- package/dist/assets/js/qld.bootstrap.min.js +9 -9
- package/dist/assets/js/qld.bootstrap.min.js.map +4 -4
- package/dist/components/bs5/breadcrumbs/breadcrumbs.hbs +1 -1
- package/dist/components/bs5/button/button.hbs +30 -9
- package/dist/components/bs5/header/header.hbs +15 -17
- package/dist/components/bs5/navbar/navbar.hbs +1 -1
- package/dist/components/bs5/quickexit/quickexit.hbs +28 -20
- package/dist/components/bs5/searchInput/searchInput.hbs +9 -3
- package/dist/components/handlebars.helpers.js +4 -8
- package/dist/components/handlebars.init.bundle.js +1 -1
- package/dist/components/handlebars.init.bundle.js.map +3 -3
- package/dist/sample-data/button/button.data.json +2 -1
- package/dist/sample-data/header/header.data.json +134 -75
- package/dist/sample-data/navbar/navbar.data.json +8 -8
- package/dist/sample-data/quickexit/quickexit.data.json +8 -1
- package/dist/sample-data/searchInput/searchInput.data.json +10 -1
- package/package.json +20 -19
- package/src/components/bs5/breadcrumbs/breadcrumb.functions.js +71 -32
- package/src/components/bs5/breadcrumbs/breadcrumbs.hbs +1 -1
- package/src/components/bs5/button/button.data.json +2 -1
- package/src/components/bs5/button/button.hbs +30 -9
- package/src/components/bs5/button/button.scss +87 -44
- package/src/components/bs5/button/button.stories.js +121 -27
- package/src/components/bs5/callout/callout.scss +1 -1
- package/src/components/bs5/header/_colours.scss +0 -52
- package/src/components/bs5/header/header.data.json +134 -75
- package/src/components/bs5/header/header.functions.js +1 -180
- package/src/components/bs5/header/header.hbs +15 -17
- package/src/components/bs5/header/header.scss +7 -156
- package/src/components/bs5/header/header.stories.js +10 -50
- package/src/components/bs5/modal/modal.scss +54 -35
- package/src/components/bs5/modal/modal.stories.js +2 -2
- package/src/components/bs5/navbar/_colours.scss +46 -82
- package/src/components/bs5/navbar/navbar.data.json +8 -8
- package/src/components/bs5/navbar/navbar.hbs +1 -1
- package/src/components/bs5/navbar/navbar.scss +15 -6
- package/src/components/bs5/quickexit/_colours.scss +28 -0
- package/src/components/bs5/quickexit/quickexit.data.json +8 -1
- package/src/components/bs5/quickexit/quickexit.hbs +28 -20
- package/src/components/bs5/quickexit/quickexit.scss +236 -156
- package/src/components/bs5/quickexit/quickexit.stories.js +35 -13
- package/src/components/bs5/searchInput/_colours.scss +63 -0
- package/src/components/bs5/searchInput/search.functions.js +170 -0
- package/src/components/bs5/searchInput/searchInput.data.json +10 -1
- package/src/components/bs5/searchInput/searchInput.hbs +9 -3
- package/src/components/bs5/searchInput/searchInput.scss +122 -21
- package/src/components/bs5/searchInput/searchInput.stories.js +1 -1
- package/src/components/bs5/tag/tag.scss +4 -2
- package/src/js/handlebars.helpers.js +4 -8
- package/src/main.js +24 -7
- package/src/main.scss +6 -3
- package/src/scss/qld-print.scss +365 -0
- package/src/scss/qld-variables.scss +87 -101
- package/src/components/common/header/Header.js +0 -11
- package/src/components/common/header/header.html +0 -259
- package/src/components/common/header/header.scss +0 -118
- /package/src/components/bs5/{header/_search.json → searchInput/search.json} +0 -0
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
"icons": {
|
|
5
5
|
"menu-icon": "qld__icon__mobile-menu",
|
|
6
6
|
"search-icon": "qld__icon__search",
|
|
7
|
-
"close-icon": "qld__icon__close"
|
|
7
|
+
"close-icon": "qld__icon__close",
|
|
8
|
+
"chevron_down": "qld__icon__chevron-down"
|
|
8
9
|
},
|
|
9
10
|
"sitePreHeader": {
|
|
10
11
|
"url": {
|
|
@@ -19,9 +20,6 @@
|
|
|
19
20
|
"url": {
|
|
20
21
|
"value": "#"
|
|
21
22
|
},
|
|
22
|
-
"icon": {
|
|
23
|
-
"value": "ctaIcon"
|
|
24
|
-
},
|
|
25
23
|
"text": {
|
|
26
24
|
"value": "For Queenslanders"
|
|
27
25
|
},
|
|
@@ -77,9 +75,6 @@
|
|
|
77
75
|
"url": {
|
|
78
76
|
"value": "#"
|
|
79
77
|
},
|
|
80
|
-
"icon": {
|
|
81
|
-
"value": "ctaIcon"
|
|
82
|
-
},
|
|
83
78
|
"text": {
|
|
84
79
|
"value": "Business and Industry"
|
|
85
80
|
},
|
|
@@ -135,9 +130,6 @@
|
|
|
135
130
|
"url": {
|
|
136
131
|
"value": "#"
|
|
137
132
|
},
|
|
138
|
-
"icon": {
|
|
139
|
-
"value": "ctaIcon"
|
|
140
|
-
},
|
|
141
133
|
"text": {
|
|
142
134
|
"value": "Login"
|
|
143
135
|
},
|
|
@@ -194,7 +186,8 @@
|
|
|
194
186
|
"icons": {
|
|
195
187
|
"menu-icon": "qld__icon__mobile-menu",
|
|
196
188
|
"search-icon": "qld__icon__search",
|
|
197
|
-
"close-icon": "qld__icon__close"
|
|
189
|
+
"close-icon": "qld__icon__close",
|
|
190
|
+
"chevron_down": "qld__icon__chevron-down"
|
|
198
191
|
},
|
|
199
192
|
"sitePreHeader": {
|
|
200
193
|
"url": {
|
|
@@ -203,48 +196,134 @@
|
|
|
203
196
|
"text": {
|
|
204
197
|
"value": "Queensland Government websites"
|
|
205
198
|
},
|
|
206
|
-
"
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
"
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
"
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
199
|
+
"CTA": [
|
|
200
|
+
{
|
|
201
|
+
"id": "CTAone",
|
|
202
|
+
"url": {
|
|
203
|
+
"value": "#"
|
|
204
|
+
},
|
|
205
|
+
"text": {
|
|
206
|
+
"value": "For Queenslanders"
|
|
207
|
+
},
|
|
208
|
+
"dropdown_enabled": true,
|
|
209
|
+
"dropdown_options": {
|
|
210
|
+
"dropdown_type": "list",
|
|
211
|
+
"view_more_label": "Browse all information and services",
|
|
212
|
+
"view_more_url": "https://www.qld.gov.au/queenslanders",
|
|
213
|
+
"dropdown_config": {
|
|
214
|
+
"groups": [
|
|
215
|
+
{
|
|
216
|
+
"action": "_blank",
|
|
217
|
+
"url": "#",
|
|
218
|
+
"label": "Transport and motoring"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"action": "_blank",
|
|
222
|
+
"url": "#",
|
|
223
|
+
"label": "Employment and jobs"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"action": "_blank",
|
|
227
|
+
"url": "#",
|
|
228
|
+
"label": "Education and training"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"action": "_blank",
|
|
232
|
+
"url": "#",
|
|
233
|
+
"label": "Queensland and its government"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"action": "_blank",
|
|
237
|
+
"url": "#",
|
|
238
|
+
"label": "Health and wellbeing"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"action": "_blank",
|
|
242
|
+
"url": "#",
|
|
243
|
+
"label": "Community support"
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"view_more": true,
|
|
247
|
+
"view_more_options": {
|
|
248
|
+
"url": "#",
|
|
249
|
+
"label": "View more",
|
|
250
|
+
"target": "_blank"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
236
254
|
},
|
|
237
|
-
|
|
238
|
-
"
|
|
255
|
+
{
|
|
256
|
+
"id": "CTAtwo",
|
|
257
|
+
"url": {
|
|
258
|
+
"value": "#"
|
|
259
|
+
},
|
|
260
|
+
"text": {
|
|
261
|
+
"value": "Business and Industry"
|
|
262
|
+
},
|
|
263
|
+
"dropdown_enabled": true,
|
|
264
|
+
"dropdown_options": {
|
|
265
|
+
"dropdown_type": "list",
|
|
266
|
+
"view_more_label": "All categories",
|
|
267
|
+
"view_more_url": "https://www.business.qld.gov.au/",
|
|
268
|
+
"dropdown_config": {
|
|
269
|
+
"groups": [
|
|
270
|
+
{
|
|
271
|
+
"action": "_blank",
|
|
272
|
+
"url": "#",
|
|
273
|
+
"label": "Starting a business"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"action": "_blank",
|
|
277
|
+
"url": "#",
|
|
278
|
+
"label": "Running a business"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"action": "_blank",
|
|
282
|
+
"url": "#",
|
|
283
|
+
"label": "Employing people"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"action": "_blank",
|
|
287
|
+
"url": "#",
|
|
288
|
+
"label": "Payroll tax"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"action": "_blank",
|
|
292
|
+
"url": "#",
|
|
293
|
+
"label": "Industries"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"action": "_blank",
|
|
297
|
+
"url": "#",
|
|
298
|
+
"label": "Investing in Queensland"
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"view_more": true,
|
|
302
|
+
"view_more_options": {
|
|
303
|
+
"url": "#",
|
|
304
|
+
"label": "View more",
|
|
305
|
+
"target": "_blank"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
239
309
|
},
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
"
|
|
243
|
-
|
|
244
|
-
|
|
310
|
+
{
|
|
311
|
+
"id": "CTAthree",
|
|
312
|
+
"url": {
|
|
313
|
+
"value": "#"
|
|
314
|
+
},
|
|
315
|
+
"text": {
|
|
316
|
+
"value": "Login"
|
|
317
|
+
},
|
|
318
|
+
"dropdown_enabled": true,
|
|
319
|
+
"dropdown_options": {
|
|
320
|
+
"dropdown_type": "form",
|
|
321
|
+
"dropdown_config": {
|
|
322
|
+
"content": "<div></div>"
|
|
323
|
+
}
|
|
245
324
|
}
|
|
246
325
|
}
|
|
247
|
-
|
|
326
|
+
]
|
|
248
327
|
},
|
|
249
328
|
"siteHeader": {
|
|
250
329
|
"config": {
|
|
@@ -274,9 +353,7 @@
|
|
|
274
353
|
"placeholder": "Placeholder",
|
|
275
354
|
"label": "Label",
|
|
276
355
|
"formAction": {
|
|
277
|
-
"url": "https://www.forgov.qld.gov.au/search"
|
|
278
|
-
"suggestions": "https://discover.search.qld.gov.au/s/suggest.json",
|
|
279
|
-
"results": "https://discover.search.qld.gov.au/s/search.json"
|
|
356
|
+
"url": "https://www.forgov.qld.gov.au/search"
|
|
280
357
|
},
|
|
281
358
|
"options": {
|
|
282
359
|
"borderStyle": {
|
|
@@ -290,7 +367,8 @@
|
|
|
290
367
|
"icons": {
|
|
291
368
|
"menu-icon": "qld__icon__mobile-menu",
|
|
292
369
|
"search-icon": "qld__icon__search",
|
|
293
|
-
"close-icon": "qld__icon__close"
|
|
370
|
+
"close-icon": "qld__icon__close",
|
|
371
|
+
"chevron_down": "qld__icon__chevron-down"
|
|
294
372
|
},
|
|
295
373
|
"sitePreHeader": {
|
|
296
374
|
"url": {
|
|
@@ -305,9 +383,6 @@
|
|
|
305
383
|
"url": {
|
|
306
384
|
"value": "#"
|
|
307
385
|
},
|
|
308
|
-
"icon": {
|
|
309
|
-
"value": "ctaIcon"
|
|
310
|
-
},
|
|
311
386
|
"text": {
|
|
312
387
|
"value": "For Queenslanders"
|
|
313
388
|
},
|
|
@@ -363,9 +438,6 @@
|
|
|
363
438
|
"url": {
|
|
364
439
|
"value": "#"
|
|
365
440
|
},
|
|
366
|
-
"icon": {
|
|
367
|
-
"value": "ctaIcon"
|
|
368
|
-
},
|
|
369
441
|
"text": {
|
|
370
442
|
"value": "Business and Industry"
|
|
371
443
|
},
|
|
@@ -421,9 +493,6 @@
|
|
|
421
493
|
"url": {
|
|
422
494
|
"value": "#"
|
|
423
495
|
},
|
|
424
|
-
"icon": {
|
|
425
|
-
"value": "ctaIcon"
|
|
426
|
-
},
|
|
427
496
|
"text": {
|
|
428
497
|
"value": "Login"
|
|
429
498
|
},
|
|
@@ -464,9 +533,7 @@
|
|
|
464
533
|
"placeholder": "",
|
|
465
534
|
"label": "",
|
|
466
535
|
"formAction": {
|
|
467
|
-
"url": "https://www.forgov.qld.gov.au/search"
|
|
468
|
-
"suggestions": "https://discover.search.qld.gov.au/s/suggest.json",
|
|
469
|
-
"results": "https://discover.search.qld.gov.au/s/search.json"
|
|
536
|
+
"url": "https://www.forgov.qld.gov.au/search"
|
|
470
537
|
},
|
|
471
538
|
"options": {
|
|
472
539
|
"borderStyle": {
|
|
@@ -480,7 +547,8 @@
|
|
|
480
547
|
"icons": {
|
|
481
548
|
"menu-icon": "qld__icon__mobile-menu",
|
|
482
549
|
"search-icon": "qld__icon__search",
|
|
483
|
-
"close-icon": "qld__icon__close"
|
|
550
|
+
"close-icon": "qld__icon__close",
|
|
551
|
+
"chevron_down": "qld__icon__chevron-down"
|
|
484
552
|
},
|
|
485
553
|
"sitePreHeader": {
|
|
486
554
|
"url": {
|
|
@@ -495,9 +563,6 @@
|
|
|
495
563
|
"url": {
|
|
496
564
|
"value": "#"
|
|
497
565
|
},
|
|
498
|
-
"icon": {
|
|
499
|
-
"value": "ctaIcon"
|
|
500
|
-
},
|
|
501
566
|
"text": {
|
|
502
567
|
"value": "For Queenslanders"
|
|
503
568
|
},
|
|
@@ -553,9 +618,6 @@
|
|
|
553
618
|
"url": {
|
|
554
619
|
"value": "#"
|
|
555
620
|
},
|
|
556
|
-
"icon": {
|
|
557
|
-
"value": "ctaIcon"
|
|
558
|
-
},
|
|
559
621
|
"text": {
|
|
560
622
|
"value": "Business and Industry"
|
|
561
623
|
},
|
|
@@ -611,9 +673,6 @@
|
|
|
611
673
|
"url": {
|
|
612
674
|
"value": "#"
|
|
613
675
|
},
|
|
614
|
-
"icon": {
|
|
615
|
-
"value": "ctaIcon"
|
|
616
|
-
},
|
|
617
676
|
"text": {
|
|
618
677
|
"value": "Login"
|
|
619
678
|
},
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { createPopper } from '@popperjs/core';
|
|
2
|
-
import { defaultSuggestions } from './_search.json';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Toggles the class on a search div based on button click.
|
|
6
3
|
*
|
|
@@ -49,180 +46,4 @@ export function toggleSearch(event) {
|
|
|
49
46
|
const isExpanded = searchDiv.classList.contains('qld__header__site-search--open');
|
|
50
47
|
event.currentTarget.setAttribute('aria-expanded', isExpanded);
|
|
51
48
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Fetches suggestions from the provided URL.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} url - The URL to fetch suggestions from.
|
|
58
|
-
* @returns {Promise<Object>} - A promise that resolves to the fetched suggestions.
|
|
59
|
-
*/
|
|
60
|
-
async function fetchSuggestions(url) {
|
|
61
|
-
try {
|
|
62
|
-
const response = await fetch(url);
|
|
63
|
-
if (!response.ok) {
|
|
64
|
-
throw new Error('Network response was not ok');
|
|
65
|
-
}
|
|
66
|
-
const data = await response.json();
|
|
67
|
-
return data;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error("Error fetching suggestions:", error);
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Fetches related services from the provided URL.
|
|
76
|
-
*
|
|
77
|
-
* @param {string} url - The URL to fetch related services from.
|
|
78
|
-
* @returns {Promise<Object>} - A promise that resolves to the fetched services.
|
|
79
|
-
*/
|
|
80
|
-
async function fetchServices(url) {
|
|
81
|
-
try {
|
|
82
|
-
const response = await fetch(url);
|
|
83
|
-
if (!response.ok) {
|
|
84
|
-
throw new Error('Network response was not ok');
|
|
85
|
-
}
|
|
86
|
-
const data = await response.json();
|
|
87
|
-
return data;
|
|
88
|
-
} catch (error) {
|
|
89
|
-
console.error("Error fetching services:", error);
|
|
90
|
-
return {};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Sets the selected suggestion into the input field and submits the form.
|
|
96
|
-
*
|
|
97
|
-
* @param {string} value - The selected suggestion.
|
|
98
|
-
* @returns {void}
|
|
99
|
-
*/
|
|
100
|
-
export function selectSuggestion(value) {
|
|
101
|
-
const searchInput = document.getElementById('search-input');
|
|
102
|
-
const suggestions = document.getElementById('suggestions');
|
|
103
|
-
const form = document.getElementById('site-search');
|
|
104
|
-
|
|
105
|
-
if (searchInput && suggestions && form) {
|
|
106
|
-
searchInput.value = value;
|
|
107
|
-
suggestions.style.display = 'none';
|
|
108
|
-
|
|
109
|
-
// Construct the action URL with query and other parameters
|
|
110
|
-
const baseUrl = form.getAttribute('action');
|
|
111
|
-
const collection = 'qgov~sp-search';
|
|
112
|
-
const profile = 'qld';
|
|
113
|
-
const query = encodeURIComponent(value);
|
|
114
|
-
const actionUrl = `${baseUrl}?query=${query}&collection=${collection}&profile=${profile}`;
|
|
115
|
-
|
|
116
|
-
// Update the form's action attribute
|
|
117
|
-
form.setAttribute('action', actionUrl);
|
|
118
|
-
|
|
119
|
-
// Submit the form
|
|
120
|
-
form.submit();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Shows suggestions based on the user's input.
|
|
126
|
-
*
|
|
127
|
-
* @param {string} value - The current input value.
|
|
128
|
-
* @param {boolean} isDefault - Whether to show default suggestions or not.
|
|
129
|
-
* @returns {void}
|
|
130
|
-
**/
|
|
131
|
-
export async function showSuggestions(value = '', isDefault = false) {
|
|
132
|
-
const suggestions = document.getElementById('suggestions');
|
|
133
|
-
const searchInput = document.getElementById('search-input');
|
|
134
|
-
|
|
135
|
-
if (!suggestions || !searchInput) {
|
|
136
|
-
console.error("Required elements not found.");
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Clear previous suggestions and services
|
|
141
|
-
suggestions.innerHTML = '';
|
|
142
|
-
|
|
143
|
-
const loadedSuggestions = defaultSuggestions;
|
|
144
|
-
|
|
145
|
-
if (isDefault) {
|
|
146
|
-
suggestions.innerHTML = `
|
|
147
|
-
<div class="suggestions-category mt-2">
|
|
148
|
-
<strong>Popular services</strong>
|
|
149
|
-
<ul class="mt-2">${loadedSuggestions.popular_services.slice(0, 4).map(item => `<li onclick="window.selectSuggestion('${item.title}')"><a href="${item.href}">${item.title}</a></li>`).join('')}</ul>
|
|
150
|
-
</div>
|
|
151
|
-
<hr>
|
|
152
|
-
<div class="suggestions-category mt-2">
|
|
153
|
-
<strong>Browse by category</strong>
|
|
154
|
-
<ul class="mt-2">${loadedSuggestions.categories.slice(0, 4).map(item => `<li onclick="window.selectSuggestion('${item.title}')"><a href="${item.href}">${item.title}</a></li>`).join('')}</ul>
|
|
155
|
-
</div>
|
|
156
|
-
<!--${loadedSuggestions.options.view_more ? `<div class="suggestions-category mt-4 mb-4"><a href="${loadedSuggestions.options.href}">${loadedSuggestions.options.label}</a></div>-->` : ''}
|
|
157
|
-
`;
|
|
158
|
-
suggestions.classList.add('show');
|
|
159
|
-
createPopper(searchInput, suggestions, {
|
|
160
|
-
placement: 'bottom-start',
|
|
161
|
-
});
|
|
162
|
-
suggestions.style.display = 'block';
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (value.length === 0) {
|
|
167
|
-
suggestions.innerHTML = '';
|
|
168
|
-
suggestions.style.display = 'none';
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Fetch suggestions from the provided URL
|
|
173
|
-
const form = document.getElementById('site-search');
|
|
174
|
-
const suggestUrl = form.getAttribute('data-suggestions');
|
|
175
|
-
const resultsUrl = form.getAttribute('data-results-url');
|
|
176
|
-
|
|
177
|
-
if (suggestUrl) {
|
|
178
|
-
const fetchedSuggestions = await fetchSuggestions(`${suggestUrl}?collection=qgov~sp-search&fmt=json%2B%2B&alpha=0.5&profile=qld&partial_query=${encodeURIComponent(value)}`);
|
|
179
|
-
|
|
180
|
-
// Use the fetched suggestions to populate the suggestions dropdown
|
|
181
|
-
if (fetchedSuggestions.length > 0) {
|
|
182
|
-
suggestions.innerHTML = `
|
|
183
|
-
<div class="suggestions-category mt-2">
|
|
184
|
-
<strong>Suggestions</strong>
|
|
185
|
-
<ul class="mt-2">${fetchedSuggestions.slice(0, 4).map(item => {
|
|
186
|
-
if (!item.disp) return ''; // Check if item.disp is defined
|
|
187
|
-
const highlightedText = item.disp.replace(new RegExp(`(${value})`, 'gi'), '<strong>$1</strong>');
|
|
188
|
-
return `<li onclick="window.selectSuggestion('${item.disp}')"><a href="#">${highlightedText}</a></li>`;
|
|
189
|
-
}).join('')}</ul>
|
|
190
|
-
</div>
|
|
191
|
-
`;
|
|
192
|
-
suggestions.classList.add('show');
|
|
193
|
-
|
|
194
|
-
// Initialize Popper.js to manage the dropdown position
|
|
195
|
-
createPopper(searchInput, suggestions, {
|
|
196
|
-
placement: 'bottom-start',
|
|
197
|
-
});
|
|
198
|
-
suggestions.style.display = 'block';
|
|
199
|
-
} else {
|
|
200
|
-
suggestions.innerHTML = '';
|
|
201
|
-
suggestions.style.display = 'none';
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (resultsUrl) {
|
|
206
|
-
const fetchedServices = await fetchServices(`${resultsUrl}?collection=qgov~sp-search&profile=qld&smeta_sfinder_sand=yes&query=${encodeURIComponent(value)}`);
|
|
207
|
-
|
|
208
|
-
// Use the fetched services to populate the services dropdown
|
|
209
|
-
if (fetchedServices.response.resultPacket && fetchedServices.response.resultPacket.results.length > 0) {
|
|
210
|
-
suggestions.innerHTML += `
|
|
211
|
-
<div class="suggestions-category feature pt-2">
|
|
212
|
-
<strong>Services</strong>
|
|
213
|
-
<ul class="mt-2">${fetchedServices.response.resultPacket.results.slice(0, 4).map(item => `<li class="pb-2" onclick="window.selectSuggestion('${item.title}')"><a href="${item.liveUrl}">${item.title}</a></li>`).join('')}</ul>
|
|
214
|
-
</div>
|
|
215
|
-
`;
|
|
216
|
-
suggestions.classList.add('show');
|
|
217
|
-
|
|
218
|
-
// Initialize Popper.js to manage the dropdown position
|
|
219
|
-
createPopper(searchInput, suggestions, {
|
|
220
|
-
placement: 'bottom-start',
|
|
221
|
-
});
|
|
222
|
-
suggestions.style.display = 'block';
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Attach the function to the window object to make it globally accessible
|
|
228
|
-
window.selectSuggestion = selectSuggestion;
|
|
49
|
+
}
|
|
@@ -189,12 +189,12 @@
|
|
|
189
189
|
href="{{url.value}}"
|
|
190
190
|
class="qld__header__cta-link"
|
|
191
191
|
{{/if}}>
|
|
192
|
-
{{#if icon.value}}
|
|
193
|
-
<span class="qld__header__cta-link-icon">
|
|
194
|
-
<i class="{{icon-root}}#{{icon.value}}"></i>
|
|
195
|
-
</span>
|
|
196
|
-
{{/if}}
|
|
197
192
|
<span class="qld__header__cta-link-text">{{text.value}}</span>
|
|
193
|
+
{{#if dropdown_enabled}}
|
|
194
|
+
<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" class="qld__header__cta-link-icon">
|
|
195
|
+
<use href="{{@root.icon-root}}#{{@root.icons.chevron_down}}"></use>
|
|
196
|
+
</svg>
|
|
197
|
+
{{/if}}
|
|
198
198
|
</a>
|
|
199
199
|
|
|
200
200
|
{{#if dropdown_enabled}}
|
|
@@ -242,15 +242,15 @@
|
|
|
242
242
|
{{#if siteSearchAsset.value}}
|
|
243
243
|
<button aria-controls="qld-header-search" class="qld__header__toggle-main-nav qld__main-nav__toggle-search" aria-expanded="false">
|
|
244
244
|
<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" class="qld__icon qld__icon--lg">
|
|
245
|
-
<use class="icon-search" href="{{icon-root}}#{{icons.search-icon}}" style="display: block;"></use>
|
|
246
|
-
<use class="icon-close" href="{{icon-root}}#{{icons.close-icon}}" style="display: none;"></use>
|
|
245
|
+
<use class="icon-search" href="{{@root.icon-root}}#{{@root.icons.search-icon}}" style="display: block;"></use>
|
|
246
|
+
<use class="icon-close" href="{{@root.icon-root}}#{{@root.icons.close-icon}}" style="display: none;"></use>
|
|
247
247
|
</svg>
|
|
248
248
|
<span class="qld__main-nav__toggle-text">Search</span>
|
|
249
249
|
</button>
|
|
250
250
|
{{/if}}
|
|
251
251
|
<button aria-controls="main-nav" class="qld__header__toggle-main-nav qld__main-nav__toggle--open" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
252
252
|
<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" class="qld__icon qld__icon--lg">
|
|
253
|
-
<use href="{{icon-root}}#{{icons.menu-icon}}"></use>
|
|
253
|
+
<use href="{{@root.icon-root}}#{{@root.icons.menu-icon}}"></use>
|
|
254
254
|
</svg>
|
|
255
255
|
<span class="qld__main-nav__toggle-text">Menu</span>
|
|
256
256
|
</button>
|
|
@@ -880,15 +880,13 @@
|
|
|
880
880
|
{{/if}}
|
|
881
881
|
{{#if siteSearchAsset.value}}
|
|
882
882
|
<div id="qld-header-search" class="qld__header__site-search qld__header__site-search--closed">
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
<ul id="suggestions" class="suggestions-dropdown suggestions-dropdown__group"></ul>
|
|
891
|
-
<input type="submit" class="btn btn-primary" value="{{#if siteSearchAsset.label}}{{siteSearchAsset.label}}{{else}}Search{{/if}}">
|
|
883
|
+
<form class="site-search" role="search"
|
|
884
|
+
{{#if siteSearchAsset.formAction.url}}
|
|
885
|
+
action="{{siteSearchAsset.formAction.url}}"
|
|
886
|
+
{{else}}
|
|
887
|
+
action="https://www.qld.gov.au/search"
|
|
888
|
+
{{/if}}>
|
|
889
|
+
{{{ searchInput }}}
|
|
892
890
|
</form>
|
|
893
891
|
</div>
|
|
894
892
|
{{/if}}
|