@worksafevictoria/wcl7.5 1.13.0-beta.8 → 1.13.0-beta.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worksafevictoria/wcl7.5",
3
- "version": "1.13.0-beta.8",
3
+ "version": "1.13.0-beta.9",
4
4
  "main": "src/index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -118,7 +118,7 @@ methods: {
118
118
  position: relative;
119
119
  margin-bottom: 10px;
120
120
  }
121
-
121
+ /* Introduced changes to make image responsive */
122
122
  .carousel img {
123
123
  object-fit: cover;
124
124
  max-height: 420px;
@@ -1,6 +1,7 @@
1
1
  import HomepageHeader from './index.vue'
2
2
  import { mockCarouselItems } from '../../../mock/carousel-items'
3
3
 
4
+ // Introduced an additional headerLink
4
5
 
5
6
  const headerLinks = [
6
7
  {
@@ -14,6 +14,7 @@
14
14
  <div class="homepage-header__content-wrapper">
15
15
  <container class="homepage-header__content-wrapper__content">
16
16
  <row>
17
+ <!-- changes made to bootstrap grid breakpoints -->
17
18
  <column
18
19
  class="homepage-header__content-wrapper__content-col col-12 col-md-7 col-lg-8 homepage-header__content-wrapper__content-col--split wcl-rich-text--ltr"
19
20
  >
@@ -6,12 +6,11 @@
6
6
  </div>
7
7
  </template>
8
8
  <template v-else>
9
- <BInputGroup>
9
+ <b-input-group>
10
10
  <label class="visually-hidden" for="site-search"
11
- >Search by keyword (Typed keyword automatically filters below
12
- results)</label
11
+ >Search by keyword (Typed keyword automatically filters below results)</label
13
12
  >
14
- <BFormInput
13
+ <b-form-input
15
14
  id="site-search"
16
15
  autofocus
17
16
  ref="siteSearch"
@@ -22,14 +21,14 @@
22
21
  trim
23
22
  @update="onChange"
24
23
  @keyup.enter="onChange"
25
- ></BFormInput>
24
+ ></b-form-input>
26
25
  <template #append>
27
- <BButton size="sm" class="search-button" @click="onSearch"
26
+ <b-button size="sm" class="search-button" @click="onSearch"
28
27
  ><span class="not-extra-small-screen">Search</span>
29
28
  <img alt="search icon" :src="searchIcon"
30
- /></BButton>
29
+ /></b-button>
31
30
  </template>
32
- </BInputGroup>
31
+ </b-input-group>
33
32
  <search-listing
34
33
  v-if="loadSearchList && (searchResults || isLoading)"
35
34
  :class="{
@@ -55,13 +54,14 @@
55
54
  </div>
56
55
  </template>
57
56
  <script>
58
- import axios from 'axios'
59
- import searchIcon from '../../../assets/icons/search.svg?url'
60
- import SearchListing from './SearchListing/index.vue'
61
- import { BButton, BInputGroup, BFormInput } from 'bootstrap-vue-next'
57
+ import axios from "axios";
58
+ import searchIcon from "../../../assets/icons/search.svg?url";
59
+ import SearchListing from "./SearchListing/index.vue";
60
+ import { BButton, BInputGroup, BFormInput } from "bootstrap-vue-next";
62
61
 
63
62
  export default {
64
63
  components: { SearchListing, BButton, BInputGroup, BFormInput },
64
+
65
65
  props: {
66
66
  pageLimit: {
67
67
  type: Number,
@@ -77,11 +77,11 @@ export default {
77
77
  },
78
78
  initialSearchQuery: {
79
79
  type: String,
80
- default: '',
80
+ default: "",
81
81
  },
82
82
  googleSearchFlag: {
83
83
  type: String,
84
- default: 'solar',
84
+ default: "solar",
85
85
  },
86
86
  visibleSearchList: {
87
87
  type: Boolean,
@@ -91,39 +91,40 @@ export default {
91
91
  data() {
92
92
  return {
93
93
  searchIcon,
94
- searchQuery: '',
94
+ searchQuery: "",
95
95
  searchResults: null,
96
96
  isLoading: false,
97
- field_language: '8671',
97
+ field_language: "8671",
98
98
  searchType: this.googleSearchFlag,
99
99
  googleSearchScript: false,
100
100
  loadSearchList: this.visibleSearchList,
101
- }
101
+ };
102
102
  },
103
103
  computed: {
104
104
  searchClass() {
105
105
  return {
106
- 'wcl-search': true,
107
- 'wcl-search__google': this.searchType !== 'solar',
108
- }
106
+ "wcl-search": true,
107
+ "wcl-search__google": this.searchType !== "solar",
108
+ };
109
109
  },
110
110
  },
111
111
  mounted() {
112
- if (this.searchType === 'google') {
113
- this.setupGoogleStyle()
112
+
113
+ if (this.searchType === "google") {
114
+ this.setupGoogleStyle();
114
115
  } else {
115
116
  if (this.initialSearchQuery) {
116
- this.searchQuery = this.initialSearchQuery
117
- this.onSearch()
117
+ this.searchQuery = this.initialSearchQuery;
118
+ this.onSearch();
118
119
  }
119
120
  if (this.isTypeahead && window) {
120
- window.document.addEventListener('click', this.closeSearchResults)
121
+ window.document.addEventListener("click", this.closeSearchResults);
121
122
  }
122
123
  }
123
124
  },
124
125
  beforeDestroy() {
125
126
  if (this.isTypeahead && window && document) {
126
- window.document.removeEventListener('click', this.closeSearchResults)
127
+ window.document.removeEventListener("click", this.closeSearchResults);
127
128
  }
128
129
  },
129
130
  methods: {
@@ -138,54 +139,54 @@ export default {
138
139
  q: query,
139
140
  start: start,
140
141
  },
141
- },
142
- )
143
- return response
142
+ }
143
+ );
144
+ return response;
144
145
  } catch (error) {
145
- console.error('Error fetching search results:', error)
146
- return []
146
+ console.error("Error fetching search results:", error);
147
+ return [];
147
148
  }
148
149
  },
149
150
  async onGoogleSearch(pageNr = 1, searchQuery) {
150
- this.$emit('loading', true)
151
- this.isLoading = true
151
+ this.$emit("loading", true);
152
+ this.isLoading = true;
152
153
 
153
- const apiKey = 'AIzaSyD76GAmQQ6DuxKWf-aLXPZ9pwdz4nOvs2c'
154
- const searchEngineId = '53b1506aa03c64160'
154
+ const apiKey = "AIzaSyD76GAmQQ6DuxKWf-aLXPZ9pwdz4nOvs2c";
155
+ const searchEngineId = "53b1506aa03c64160";
155
156
 
156
- const start = (pageNr - 1) * this.pageLimit
157
+ const start = (pageNr - 1) * this.pageLimit;
157
158
  let response = await this.fetchSearchResults(
158
159
  apiKey,
159
160
  searchEngineId,
160
161
  searchQuery,
161
- start,
162
- )
163
- let items = []
164
- let suggest = response?.data?.spelling?.correctedQuery || ''
162
+ start
163
+ );
164
+ let items = [];
165
+ let suggest = response?.data?.spelling?.correctedQuery || "";
165
166
  if (response?.data?.spelling?.correctedQuery) {
166
167
  response = await this.fetchSearchResults(
167
168
  apiKey,
168
169
  searchEngineId,
169
170
  response?.data?.spelling?.correctedQuery,
170
- start,
171
- )
172
- items = response?.data?.items
171
+ start
172
+ );
173
+ items = response?.data?.items;
173
174
  } else if (response?.data?.items) {
174
- items = response?.data?.items
175
+ items = response?.data?.items;
175
176
  }
176
177
  if (items.length > 0) {
177
- const totalResults = response?.data?.searchInformation?.totalResults
178
+ const totalResults = response?.data?.searchInformation?.totalResults;
178
179
  // Loop through each item in the items array
179
180
  const modifiedResults = items.map((item) => {
180
181
  // Update the title using the handleSearchResultLinkTitle function
181
- const modifiedTitle = this.handleSearchResultLinkTitle(item.title)
182
+ const modifiedTitle = this.handleSearchResultLinkTitle(item.title);
182
183
 
183
184
  // Return the modified item with the updated title
184
185
  return {
185
186
  ...item,
186
187
  title: modifiedTitle,
187
- }
188
- })
188
+ };
189
+ });
189
190
 
190
191
  this.searchResults = {
191
192
  offset: Number(pageNr === 1 ? pageNr - 1 : pageNr),
@@ -193,19 +194,19 @@ export default {
193
194
  query: this.searchQuery,
194
195
  results: modifiedResults,
195
196
  suggestion: suggest,
196
- }
197
+ };
197
198
  } else {
198
199
  this.searchResults = {
199
200
  offset: 0,
200
201
  numFound: 0,
201
- query: this.searchQuery ?? '',
202
+ query: this.searchQuery ?? "",
202
203
  results: [],
203
204
  suggestion: suggest,
204
- }
205
+ };
205
206
  }
206
- this.$emit('loading', false)
207
- this.isLoading = false
208
- this.$emit('results', this.searchResults)
207
+ this.$emit("loading", false);
208
+ this.isLoading = false;
209
+ this.$emit("results", this.searchResults);
209
210
 
210
211
  // wait for the page title to be updated and then fire the search event
211
212
  setTimeout(() => {
@@ -213,82 +214,78 @@ export default {
213
214
  pageTitle: document.title,
214
215
  pageURL: this.$route?.fullPath,
215
216
  location:
216
- this.$route?.path === '/'
217
- ? 'Homepage'
218
- : this.$route?.path === '/search'
219
- ? 'Search Page'
220
- : this.$route?.path,
217
+ this.$route?.path === "/"
218
+ ? "Homepage"
219
+ : this.$route?.path === "/search"
220
+ ? "Search Page"
221
+ : this.$route?.path,
221
222
  label: this.searchQuery,
222
223
  results: this.searchResults.numFound,
223
- }
224
+ };
224
225
  if (this.$gtm) {
225
- this.$gtm.push({ event: 'custom.search.site.submit', ...attrs })
226
+ this.$gtm.push({ event: "custom.search.site.submit", ...attrs });
226
227
  }
227
- }, 300)
228
+ }, 300);
228
229
  },
229
230
  pageChanged(newPageNumber) {
230
- if (this.searchType === 'solar') {
231
+ if (this.searchType === "solar") {
231
232
  // Reset search results before fetching new results
232
- this.resetSearchResults()
233
- this.performSearch(newPageNumber, this.searchQuery, this.pageLimit)
233
+ this.resetSearchResults();
234
+ this.performSearch(newPageNumber, this.searchQuery, this.pageLimit);
234
235
  } else {
235
236
  // Fetch new search results with the updated page number
236
- this.onGoogleSearch(newPageNumber, this.searchQuery)
237
+ this.onGoogleSearch(newPageNumber, this.searchQuery);
237
238
  }
238
239
  },
239
240
  onSearch(e) {
240
- const { path } = this.$route || {}
241
+ const { path } = this.$route || {};
241
242
 
242
243
  // Home page
243
244
  if (
244
- (e?.type === 'click' || e?.key == 'Enter') &&
245
+ (e?.type === "click" || e?.key == "Enter") &&
245
246
  this.searchQuery &&
246
247
  this.searchQuery.length > 2 &&
247
- path === '/'
248
+ path === "/"
248
249
  ) {
249
250
  // Search page
250
- const searchQuery = encodeURIComponent(this.searchQuery)
251
- const origin = window.location.origin
252
- const hash = window.location.hash
253
- const pathname = 'search'
254
- const URL = `${origin}/${pathname}${hash}?q=${searchQuery}`
251
+ const searchQuery = encodeURIComponent(this.searchQuery);
252
+ const origin = window.location.origin;
253
+ const hash = window.location.hash;
254
+ const pathname = "search";
255
+ const URL = `${origin}/${pathname}${hash}?q=${searchQuery}`;
255
256
 
256
257
  // Uncomment below commented code when goes live
257
- window.location.assign(URL)
258
+ window.location.assign(URL);
258
259
  } else {
259
- this.resetSearchResults()
260
- this.$emit('query', this.searchQuery)
260
+ this.resetSearchResults();
261
+ this.$emit("query", this.searchQuery);
261
262
 
262
- if (this.searchType === 'solar') {
263
- this.performSearch(1, this.searchQuery, this.pageLimit)
263
+ if (this.searchType === "solar") {
264
+ this.performSearch(1, this.searchQuery, this.pageLimit);
264
265
  } else {
265
- this.onGoogleSearch(1, this.searchQuery)
266
+ this.onGoogleSearch(1, this.searchQuery);
266
267
  }
267
268
  }
268
269
  },
269
270
  resetSearchResults() {
270
- this.searchResults = null
271
+ this.searchResults = null;
271
272
  },
272
273
  closeSearchResults(ev) {
273
- if (
274
- this.isTypeahead &&
275
- this.searchResults &&
276
- ev?.target?.id !== 'site-search'
277
- ) {
278
- this.resetSearchResults()
279
- this.searchQuery = null
280
- this.$emit('query', null)
274
+ if (this.isTypeahead && this.searchResults && ev?.target?.id !== "site-search") {
275
+ this.resetSearchResults();
276
+ this.searchQuery = null;
277
+ this.$emit("query", null);
281
278
  }
282
279
  },
283
280
  onChange(e) {
284
281
  if (this.searchQuery && this.searchQuery.length > 2) {
285
- this.onSearch(e)
282
+ this.onSearch(e);
286
283
  }
287
284
  },
288
285
  performSearch(pageNr = 1, searchQuery, pageLimit) {
289
286
  if (searchQuery) {
290
- this.$emit('loading', true)
291
- this.isLoading = true
287
+ this.$emit("loading", true);
288
+ this.isLoading = true;
292
289
  this.contentParser({
293
290
  query: searchQuery,
294
291
  start: pageNr > 1 ? (pageNr - 1) * pageLimit : 0,
@@ -302,100 +299,100 @@ export default {
302
299
  query: searchQuery,
303
300
  results: res.results,
304
301
  suggestion: null,
305
- }
302
+ };
306
303
  } else {
307
304
  this.searchResults = {
308
305
  offset: 0,
309
306
  numFound: 0,
310
- query: this.searchQuery ?? '',
307
+ query: this.searchQuery ?? "",
311
308
  results: [],
312
309
  suggestion: null,
313
- }
310
+ };
314
311
  }
315
- this.$emit('loading', false)
316
- this.isLoading = false
317
- this.$emit('results', this.searchResults)
312
+ this.$emit("loading", false);
313
+ this.isLoading = false;
314
+ this.$emit("results", this.searchResults);
318
315
  // wait for the page title to be updated and then fire the search event
319
316
  setTimeout(() => {
320
317
  const attrs = {
321
318
  pageTitle: document.title,
322
319
  pageURL: this.$route?.fullPath,
323
320
  location:
324
- this.$route?.path === '/'
325
- ? 'Homepage'
326
- : this.$route?.path === '/search'
327
- ? 'Search Page'
328
- : this.$route?.path,
321
+ this.$route?.path === "/"
322
+ ? "Homepage"
323
+ : this.$route?.path === "/search"
324
+ ? "Search Page"
325
+ : this.$route?.path,
329
326
  label: this.searchQuery,
330
327
  results: this.searchResults.numFound,
331
- }
328
+ };
332
329
  if (this.$gtm) {
333
- this.$gtm.push({ event: 'custom.search.site.submit', ...attrs })
330
+ this.$gtm.push({ event: "custom.search.site.submit", ...attrs });
334
331
  }
335
- }, 300)
336
- })
332
+ }, 300);
333
+ });
337
334
  }
338
335
  },
339
336
 
340
337
  // Method to customize google search style
341
338
  setupGoogleStyle() {
342
339
  if (this.googleSearchScript === false) {
343
- const script = document.createElement('script')
344
- script.async = true
340
+ const script = document.createElement("script");
341
+ script.async = true;
345
342
  script.src = this.$config
346
343
  ? this.$config.public.googleSearch
347
- : process.env.GOOGLE__URL
348
- document.head.appendChild(script)
349
- this.googleSearchScript = true
344
+ : process.env.GOOGLE__URL;
345
+ document.head.appendChild(script);
346
+ this.googleSearchScript = true;
350
347
 
351
348
  // Create a new style element
352
- const style = document.createElement('style')
353
- style.id = 'searchStyle' // Assign an ID to the style element
349
+ const style = document.createElement("style");
350
+ style.id = "searchStyle"; // Assign an ID to the style element
354
351
  // The CSS we are going to inject
355
- const cssVar = 'table.gssb_c {display: none !important;}'
352
+ const cssVar = "table.gssb_c {display: none !important;}";
356
353
  // Inject the style element into the head
357
- document.head.appendChild(style)
354
+ document.head.appendChild(style);
358
355
  // Set the text content of the style element to the CSS text
359
- style.textContent = cssVar
356
+ style.textContent = cssVar;
360
357
  }
361
358
  },
362
359
 
363
360
  // function to handle search result link titles
364
361
  handleSearchResultLinkTitle(title) {
365
362
  // Split the title by the '|' character
366
- const titleParts = title.split('|')
363
+ const titleParts = title.split("|");
367
364
 
368
365
  // Remove any leading or trailing whitespace from each part
369
- const cleanedTitleParts = titleParts.map((part) => part.trim())
366
+ const cleanedTitleParts = titleParts.map((part) => part.trim());
370
367
 
371
368
  // Join the cleaned title parts back together without the text after the '|' character
372
- const modifiedTitle = cleanedTitleParts[0] // Take only the first part before '|'
369
+ const modifiedTitle = cleanedTitleParts[0]; // Take only the first part before '|'
373
370
 
374
- return modifiedTitle
371
+ return modifiedTitle;
375
372
  },
376
373
 
377
374
  handleKeyUp(event) {
378
- if (event.key === 'Enter' || event.type === 'click') {
375
+ if (event.key === "Enter" || event.type === "click") {
379
376
  let keyword = event.key
380
377
  ? event.target.value
381
- : document.querySelector('input[name="search"]').value
378
+ : document.querySelector('input[name="search"]').value;
382
379
 
383
380
  // Check if the URL does not contain "/search"
384
- if (keyword && !window.location.href.includes('/search')) {
385
- let origin = window.location.origin
386
- let hash = window.location.hash
387
- let pathname = 'search'
388
- let URL = origin + '/' + pathname + hash
381
+ if (keyword && !window.location.href.includes("/search")) {
382
+ let origin = window.location.origin;
383
+ let hash = window.location.hash;
384
+ let pathname = "search";
385
+ let URL = origin + "/" + pathname + hash;
389
386
  }
390
387
 
391
- this.setupPaginationEvent()
388
+ this.setupPaginationEvent();
392
389
  }
393
390
  },
394
391
  },
395
- }
392
+ };
396
393
  </script>
397
394
  <style lang="scss" scoped>
398
- @import '../../../includes/scss/all';
395
+ @import "../../../includes/scss/all";
399
396
 
400
397
  .wcl-search {
401
398
  position: relative;
@@ -453,7 +450,7 @@ export default {
453
450
  }
454
451
  }
455
452
 
456
- @include mq('xs') {
453
+ @include mq("xs") {
457
454
  .not-extra-small-screen {
458
455
  display: none;
459
456
  }
@@ -543,7 +540,7 @@ export default {
543
540
  padding-left: 32px;
544
541
 
545
542
  &:before {
546
- content: 'Search';
543
+ content: "Search";
547
544
  }
548
545
 
549
546
  @media screen and (max-width: 767px) {
@@ -623,7 +620,7 @@ export default {
623
620
  padding: 0;
624
621
 
625
622
  &::after {
626
- content: ' ';
623
+ content: " ";
627
624
  position: absolute;
628
625
  height: 16px;
629
626
  width: 11px;
@@ -730,7 +727,7 @@ export default {
730
727
  }
731
728
 
732
729
  /* search list end */
733
- @include mq('xs') {
730
+ @include mq("xs") {
734
731
  .not-extra-small-screen {
735
732
  display: none;
736
733
  }