@qhealth-design-system/core 1.16.3 → 1.16.4

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.
@@ -1,116 +0,0 @@
1
-
2
- (function(QLD) {
3
- "use strict";
4
-
5
- /**
6
- * @module userLocationFinder
7
- */
8
- var userLocationFinder = {};
9
-
10
- /**
11
- * Initialise the location finder
12
- *
13
- * @memberof module:userLocationFinder
14
- */
15
- userLocationFinder.init = function() {
16
-
17
-
18
- // Need to move this stuff into a central location as it's also used for BSQ location finder
19
- var $ = require('jquery');
20
- var ausPostUrl = typeof site !== 'undefined' ? site.metadata.ausPostUrl.value : ``;
21
- var Bloodhound = require('corejs-typeahead/dist/bloodhound.js');
22
- var datumLocationData;
23
- require('corejs-typeahead/dist/typeahead.jquery.js');
24
-
25
- console.log(ausPostUrl);
26
-
27
- var addressPacket = new Bloodhound({
28
- datumTokenizer: function(d) {
29
- var locationTokens = Bloodhound.tokenizers.whitespace(d.location);
30
- var postcodeTokens = Bloodhound.tokenizers.whitespace(d.postcode);
31
-
32
- return locationTokens.concat(postcodeTokens);
33
- },
34
- queryTokenizer: Bloodhound.tokenizers.whitespace,
35
- limit: 20,
36
- remote: {
37
- url: ausPostUrl,
38
- prepare: function (query, settings) {
39
- settings.url = encodeURI(settings.url + '?query=' + query);
40
- return settings;
41
- }
42
- }
43
- });
44
-
45
-
46
- var $updateLocationInput = $(".qld__update-location-input");
47
-
48
- $updateLocationInput.typeahead('destroy');
49
-
50
- $updateLocationInput.typeahead(null, {
51
- name: 'addresses',
52
- minLength: 3,
53
- display: 'location',
54
- limit: 10,
55
- source: addressPacket,
56
- templates: {
57
- suggestion: function(data) {
58
- return `<p><strong>${data.location}</strong>, ${data.postcode}</p>`;
59
- }
60
- }
61
- }).on('typeahead:select', function (obj, datum, name) {
62
- if(datum.latitude && datum.longitude) {
63
- datumLocationData = datum;
64
- }
65
- });
66
-
67
- $(document).on('click', '[data-action="set-location"]', function(e) {
68
- let $this = $(this);
69
- let $form = $this.closest('form');
70
-
71
- if($form[0].checkValidity()) {
72
- e.preventDefault();
73
-
74
- if(datumLocationData) {
75
- var location = {
76
- "latitude": datumLocationData.latitude,
77
- "longitude": datumLocationData.longitude,
78
- "isGeolocated": false,
79
- "location": datumLocationData.location
80
- }
81
- QLD.utils.setUserLocation(location);
82
- } else {
83
- console.log('Location not found in search field.');
84
- }
85
- } else {
86
- $form[0].reportValidity();
87
- }
88
- });
89
-
90
- var $setCurrentLocationBtn = $('[data-action="set-current-location"]');
91
-
92
- if($setCurrentLocationBtn.length > 0) {
93
- if(QLD.utils.isGeolocated()) {
94
- $setCurrentLocationBtn.addClass('active').attr('disabled', true);
95
- }
96
-
97
- $setCurrentLocationBtn.on('click', function() {
98
- var errorCallback = function() {
99
- $setCurrentLocationBtn.replaceWith('<p class="qld__input--error">Unable to locate</p>');
100
- }
101
- QLD.utils.geolocateUser(true, errorCallback);
102
- });
103
- }
104
- }
105
-
106
- var QLD = QLD ? QLD : {};
107
- QLD.userLocationFinder = userLocationFinder;
108
- window.QLD = QLD;
109
-
110
- document.addEventListener("DOMContentLoaded", function(event) {
111
- if ($(".qld__update-location-input").length > 0) {
112
- QLD.userLocationFinder.init();
113
- }
114
- });
115
-
116
- }(window.QLD));