@worksafevictoria/wcl7.5 1.2.0 → 1.2.2

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,5 +1,5 @@
1
1
  <template>
2
- <container id="mainCookieContainer" class="hide">
2
+ <container id="mainCookieContainer">
3
3
  <row class="cookie-container">
4
4
  <column class="cookie-container__col">
5
5
  <h3 id="cookie_header" class="cookie-header hidden-on-xs">
@@ -222,32 +222,23 @@ export default {
222
222
  },
223
223
  showCookie() {
224
224
  //Check first if cookies have been turned on in the environment variable
225
- if (process.env.SHOW_COOKIE === 'true') {
226
- return 'true'
227
- } else {
228
- return 'false'
229
- }
225
+ return process.env.SHOW_COOKIE === false ? false : true
230
226
  }
231
227
  },
232
228
  mounted() {
233
- // required, as unable to check localStorage until window loaded
234
- window.addEventListener('load', this.checkCookie())
235
229
  // detect screen size to display smaller content
236
230
  this.screenWidth = window.innerWidth
237
- this.$nextTick(() => {
238
- window.addEventListener('resize', this.onScreenResize())
239
- })
240
- this.onScreenResize()
231
+ this.updateScreenWidth()
232
+ // required, as unable to check localStorage until window loaded
233
+ this.checkCookie()
234
+ window.addEventListener('resize', this.updateScreenWidth)
235
+
241
236
  },
242
237
  unmounted() {
243
- window.removeEventListener('load', this.checkCookie())
238
+ window.removeEventListener('load', this.checkCookie)
239
+ window.removeEventListener('resize', this.updateScreenWidth)
244
240
  },
245
241
  methods: {
246
- onScreenResize() {
247
- window.addEventListener('resize', () => {
248
- this.updateScreenWidth()
249
- })
250
- },
251
242
  updateScreenWidth() {
252
243
  this.screenWidth = window.innerWidth
253
244
  },
@@ -259,59 +250,56 @@ export default {
259
250
  const analyticsCookieName = 'analyticsCookies'
260
251
  const marketingCookieName = 'marketingCookies'
261
252
  var cookieElement = document.getElementById('mainCookieContainer')
262
- if (clickResponse === 'accept') {
263
- localStorage.setItem('cookieBannerDisplayed', 'false')
264
- localStorage.setItem(analyticsCookieName, 'granted')
265
- localStorage.setItem(marketingCookieName, 'granted')
266
- cookieElement.classList.add('hide')
267
- cookieElement.classList.remove('show')
268
- } else if (clickResponse === 'save') {
269
- const acb = document.getElementById('modal2CB')
270
- const mcb = document.getElementById('modal3CB')
271
- localStorage.setItem('cookieBannerDisplayed', 'false')
272
- if (acb.checked) {
253
+
254
+ if (cookieElement) {
255
+ localStorage.setItem('cookieBannerDisplayed', 'true') // Mark the banner as displayed
256
+
257
+ if (clickResponse === 'accept') {
258
+ // localStorage.setItem('cookieBannerDisplayed', 'false')
273
259
  localStorage.setItem(analyticsCookieName, 'granted')
274
- } else {
275
- localStorage.setItem(analyticsCookieName, 'denied')
276
- }
277
- if (mcb.checked) {
278
260
  localStorage.setItem(marketingCookieName, 'granted')
261
+
262
+ } else if (clickResponse === 'save') {
263
+ // localStorage.setItem('cookieBannerDisplayed', 'false')
264
+ const acb = document.getElementById('modal2CB')
265
+ const mcb = document.getElementById('modal3CB')
266
+
267
+ localStorage.setItem(analyticsCookieName, acb.checked ? 'granted' : 'denied')
268
+ localStorage.setItem(marketingCookieName, mcb.checked ? 'granted' : 'denied')
279
269
  } else {
270
+ // clickResponse === 'reject'
271
+ // localStorage.setItem('cookieBannerDisplayed', 'false')
272
+ localStorage.setItem(analyticsCookieName, 'denied')
280
273
  localStorage.setItem(marketingCookieName, 'denied')
281
274
  }
282
- cookieElement.classList.add('hide')
283
- cookieElement.classList.remove('show')
284
- } else {
285
- localStorage.setItem('cookieBannerDisplayed', 'false')
286
- localStorage.setItem(analyticsCookieName, 'denied')
287
- localStorage.setItem(marketingCookieName, 'denied')
275
+
288
276
  cookieElement.classList.add('hide')
289
277
  cookieElement.classList.remove('show')
290
278
  }
291
279
  },
292
280
  // function to update consent in GTM
293
281
  fireGTM() {
294
- if (this.$gtm) {
295
- // gather attrs
296
- let aConsent = localStorage.getItem('analyticsCookies')
297
- let mConsent = localStorage.getItem('marketingCookies')
298
- let attrs1 = {
299
- ad_storage: mConsent
300
- }
301
- // fire the event - marketing
302
- this.$gtm.push({
303
- event: 'gtm_consent_update',
304
- ...attrs1
305
- })
306
- let attrs2 = {
307
- analytics_storage: aConsent
308
- }
309
- // fire the event - analytics
310
- this.$gtm.push({
311
- event: 'gtm_consent_update',
312
- ...attrs2
313
- })
314
- }
282
+ // if (this.$gtm) {
283
+ // // gather attrs
284
+ // let aConsent = localStorage.getItem('analyticsCookies')
285
+ // let mConsent = localStorage.getItem('marketingCookies')
286
+ // let attrs1 = {
287
+ // ad_storage: mConsent
288
+ // }
289
+ // // fire the event - marketing
290
+ // this.$gtm.push({
291
+ // event: 'gtm_consent_update',
292
+ // ...attrs1
293
+ // })
294
+ // let attrs2 = {
295
+ // analytics_storage: aConsent
296
+ // }
297
+ // // fire the event - analytics
298
+ // this.$gtm.push({
299
+ // event: 'gtm_consent_update',
300
+ // ...attrs2
301
+ // })
302
+ // }
315
303
  },
316
304
  //function to remove from local storage based on partial match - called from checkCookie
317
305
  removeLocalStorage: function(cookieName) {
@@ -328,107 +316,112 @@ export default {
328
316
  },
329
317
  // function to remove cookies according to response from overlay or modal
330
318
  checkCookie: function() {
331
- var cookieElement = document.getElementById('mainCookieContainer')
332
- if (
333
- this.showCookie === 'true' &&
334
- !localStorage.getItem('cookieBannerDisplayed')
335
- ) {
336
- cookieElement.classList.remove('hide')
337
- cookieElement.classList.add('show')
338
- } else {
339
- // need to remove cookies in rejected categories, but first hide cookie overlay
340
- cookieElement.classList.add('hide')
341
- cookieElement.classList.remove('show')
319
+ const cookieElement = document.getElementById('mainCookieContainer');
320
+ const bannerDisplayed = localStorage.getItem('cookieBannerDisplayed');
342
321
 
343
- // get list of categorised cookies
344
- const analyticsArr = analyticsCookies
345
- const marketingArr = marketingCookies
346
322
 
347
- // get list of cookies to process
348
- var pairs = document.cookie.split(';')
349
- var cookieArr = []
350
- for (var i = 0; i < pairs.length; i++) {
351
- var pair = pairs[i].split('=')
352
- var nameVar = [pair[0].trim()]
353
- cookieArr.push(nameVar[0])
354
- }
355
- // identify which categories to process, initialising variables to false
356
- // will only be set to true if user has rejected any cookies
357
- var checkAnalytics = false
358
- var checkMarketing = false
323
+ if (this.showCookie && bannerDisplayed !== 'true') {
324
+ // Show the banner if it's not been displayed yet
325
+ console.log('** Show the banner if its not been displayed yet:-')
326
+ cookieElement.classList.remove('hide')
327
+ cookieElement.classList.add('show')
328
+ } else {
329
+ // Hide the banner if user has already made a selection
330
+ console.log('** Hide the banner if user has already made a selection:-')
331
+ // need to remove cookies in rejected categories, but first hide cookie overlay
332
+ cookieElement.classList.add('hide')
333
+ cookieElement.classList.remove('show')
359
334
 
360
- // get value of consent cookies to determine if cookies have to be removed
361
- var analyticsValue = localStorage.getItem('analyticsCookies')
362
- if (analyticsValue !== null && analyticsValue === 'denied') {
363
- checkAnalytics = true
364
- }
335
+ // get list of categorised cookies
336
+ const analyticsArr = analyticsCookies
337
+ const marketingArr = marketingCookies
365
338
 
366
- var marketingValue = localStorage.getItem('marketingCookies')
367
- if (marketingValue !== null && marketingValue === 'denied') {
368
- checkMarketing = true
369
- }
339
+ // get list of cookies to process
340
+ var pairs = document.cookie.split(';')
341
+ var cookieArr = []
342
+ for (var i = 0; i < pairs.length; i++) {
343
+ var pair = pairs[i].split('=')
344
+ var nameVar = [pair[0].trim()]
345
+ cookieArr.push(nameVar[0])
346
+ }
347
+ // identify which categories to process, initialising variables to false
348
+ // will only be set to true if user has rejected any cookies
349
+ var checkAnalytics = false
350
+ var checkMarketing = false
351
+
352
+ // get value of consent cookies to determine if cookies have to be removed
353
+ var analyticsValue = localStorage.getItem('analyticsCookies')
354
+ if (analyticsValue !== null && analyticsValue === 'denied') {
355
+ checkAnalytics = true
356
+ }
357
+
358
+ var marketingValue = localStorage.getItem('marketingCookies')
359
+ if (marketingValue !== null && marketingValue === 'denied') {
360
+ checkMarketing = true
361
+ }
370
362
 
371
- // Remove analytics cookies stored as cookies or localStorage
372
- if (checkAnalytics) {
373
- analyticsArr.forEach((cookieName) => {
374
- if (cookieName.name.slice(-1) === '*') {
375
- var tmpVar = cookieName.name.slice(0, -1)
376
- this.removeLocalStorage(tmpVar)
377
- var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
378
- tmpArr.forEach((tmpName) => {
363
+ // Remove analytics cookies stored as cookies or localStorage
364
+ if (checkAnalytics) {
365
+ analyticsArr.forEach((cookieName) => {
366
+ if (cookieName.name.slice(-1) === '*') {
367
+ var tmpVar = cookieName.name.slice(0, -1)
368
+ this.removeLocalStorage(tmpVar)
369
+ var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
370
+ tmpArr.forEach((tmpName) => {
371
+ document.cookie =
372
+ tmpName +
373
+ '=;expires=' +
374
+ new Date(0).toUTCString() +
375
+ ';domain=' +
376
+ cookieName.domain +
377
+ ';path=' +
378
+ cookieName.path
379
+ })
380
+ } else {
381
+ localStorage.removeItem(cookieName.name)
379
382
  document.cookie =
380
- tmpName +
383
+ cookieName.name +
381
384
  '=;expires=' +
382
385
  new Date(0).toUTCString() +
383
386
  ';domain=' +
384
387
  cookieName.domain +
385
388
  ';path=' +
386
389
  cookieName.path
387
- })
388
- } else {
389
- localStorage.removeItem(cookieName.name)
390
- document.cookie =
391
- cookieName.name +
392
- '=;expires=' +
393
- new Date(0).toUTCString() +
394
- ';domain=' +
395
- cookieName.domain +
396
- ';path=' +
397
- cookieName.path
398
- }
399
- })
400
- }
401
- // Remove marketing cookies stored as cookies or localStorage
402
- if (checkMarketing) {
403
- marketingArr.forEach((cookieName) => {
404
- if (cookieName.name.slice(-1) === '*') {
405
- var tmpVar = cookieName.name.slice(0, -1)
406
- this.removeLocalStorage(tmpVar)
407
- var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
408
- tmpArr.forEach((tmpName) => {
390
+ }
391
+ })
392
+ }
393
+ // Remove marketing cookies stored as cookies or localStorage
394
+ if (checkMarketing) {
395
+ marketingArr.forEach((cookieName) => {
396
+ if (cookieName.name.slice(-1) === '*') {
397
+ var tmpVar = cookieName.name.slice(0, -1)
398
+ this.removeLocalStorage(tmpVar)
399
+ var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
400
+ tmpArr.forEach((tmpName) => {
401
+ document.cookie =
402
+ tmpName +
403
+ '=;expires=' +
404
+ new Date(0).toUTCString() +
405
+ ';domain=' +
406
+ cookieName.domain +
407
+ ';path=' +
408
+ cookieName.path
409
+ })
410
+ } else {
411
+ localStorage.removeItem(cookieName.name)
409
412
  document.cookie =
410
- tmpName +
413
+ cookieName.name +
411
414
  '=;expires=' +
412
415
  new Date(0).toUTCString() +
413
416
  ';domain=' +
414
417
  cookieName.domain +
415
418
  ';path=' +
416
419
  cookieName.path
417
- })
418
- } else {
419
- localStorage.removeItem(cookieName.name)
420
- document.cookie =
421
- cookieName.name +
422
- '=;expires=' +
423
- new Date(0).toUTCString() +
424
- ';domain=' +
425
- cookieName.domain +
426
- ';path=' +
427
- cookieName.path
428
- }
429
- })
420
+ }
421
+ })
422
+ }
430
423
  }
431
- }
424
+
432
425
  }
433
426
  }
434
427
  }
@@ -69,6 +69,12 @@ export default {
69
69
  displayGlobal: false,
70
70
  }
71
71
  },
72
+ computed: {
73
+ showGlobalNotice() {
74
+ //Check first if SHOW_GLOBAL_NOTICE have been turned on in the environment variable
75
+ return process.env.SHOW_GLOBAL_NOTICE === false ? false : true
76
+ }
77
+ },
72
78
  mounted() {
73
79
  window.addEventListener('load', this.checkPage())
74
80
  },
@@ -89,12 +95,16 @@ export default {
89
95
  this.setCookie()
90
96
  this.displayGlobal = false
91
97
  } else if (typeof window !== 'undefined') {
98
+ console.log('**else this.showGlobalNotice:-', this.showGlobalNotice)
99
+ console.log('**else tocalStorage.getItem(globalModalHidden):-', localStorage.getItem('globalModalHidden'))
100
+
92
101
  this.displayGlobal =
93
- process.env.SHOW_GLOBAL_NOTICE === 'true' &&
102
+ this.showGlobalNotice === true &&
94
103
  !localStorage.getItem('globalModalHidden')
95
104
  } else {
96
- this.displayGlobal = process.env.SHOW_GLOBAL_NOTICE === 'true'
105
+ this.displayGlobal = process.env.SHOW_GLOBAL_NOTICE === true
97
106
  }
107
+ console.log('**this.displayGlobal:- ', this.displayGlobal)
98
108
  }
99
109
  }
100
110
  }
@@ -104,6 +114,17 @@ export default {
104
114
  @import '../../../includes/scss/all';
105
115
 
106
116
  // modal and modal backdrop styles required in order to display the overlay behind the modal
117
+ #global-notice-modal {
118
+ .modal-dialog-centered {
119
+ border-radius: 6px !important;
120
+ // box-shadow: 0 0 16px 8px rgba(0, 0, 0, 0.24) !important;
121
+ left: 50%;
122
+ margin-left: -200px;
123
+ margin-top: -240px;
124
+ top: 50%;
125
+ width: 400px !important;
126
+ }
127
+ }
107
128
 
108
129
  .modal {
109
130
  background: rgba(0,0,0,0.5)
@@ -48,7 +48,8 @@
48
48
  class="wcl-hero-header__content-wrapper__content-col"
49
49
  :md="7"
50
50
  :class="{
51
- [`wcl-hero-header__content-wrapper__content-col--split`]: $slots.side
51
+ [`wcl-hero-header__content-wrapper__content-col--split`]:
52
+ $slots.side,
52
53
  }"
53
54
  >
54
55
  <breadcrumb
@@ -98,7 +99,7 @@
98
99
  >
99
100
  </column>
100
101
  </row>
101
- <social-share v-show="showSocial && type !== 'hero'" :rtl="rtl" />
102
+ <social-share v-show="showSocial && type !== 'hero'" :rtl="rtl" />
102
103
  </container>
103
104
  </div>
104
105
  <!-- Type Default -->
@@ -176,63 +177,63 @@ export default {
176
177
  CtaButton,
177
178
  HeroHeaderChevron,
178
179
  RichText,
179
- Icon
180
+ Icon,
180
181
  },
181
182
  props: {
182
183
  type: {
183
184
  type: String,
184
- default: 'default'
185
+ default: 'default',
185
186
  },
186
187
  title: {
187
188
  type: String,
188
- default: ''
189
+ default: '',
189
190
  },
190
191
  description: {
191
192
  type: String,
192
- default: ''
193
+ default: '',
193
194
  },
194
195
  image: {
195
196
  type: Object,
196
- default: () => {}
197
+ default: () => {},
197
198
  },
198
199
  cta: {
199
200
  type: Object,
200
- default: () => {}
201
+ default: () => {},
201
202
  },
202
203
  bgColor: {
203
204
  type: Boolean,
204
- default: false
205
+ default: false,
205
206
  },
206
207
  breadcrumbItems: {
207
208
  type: Array,
208
- default: () => []
209
+ default: () => [],
209
210
  },
210
211
  rtl: {
211
212
  type: Boolean,
212
- default: false
213
+ default: false,
213
214
  },
214
215
  workwell: {
215
216
  type: Boolean,
216
- default: false
217
+ default: false,
217
218
  },
218
219
  showBreadcrumb: {
219
220
  type: Boolean,
220
- default: true
221
+ default: true,
221
222
  },
222
223
  showMask: {
223
224
  type: Boolean,
224
- default: true
225
+ default: true,
225
226
  },
226
227
  showSocial: {
227
228
  type: Boolean,
228
- default: true
229
- }
229
+ default: true,
230
+ },
230
231
  },
231
232
  data() {
232
233
  return {
233
234
  socialShareToggle: false,
234
235
  HeroHeaderChevron,
235
- CaretDown
236
+ CaretDown,
236
237
  }
237
238
  },
238
239
  computed: {
@@ -269,7 +270,7 @@ export default {
269
270
  // }
270
271
  // }
271
272
  return this.title
272
- }
273
+ },
273
274
  // Will reintroduce if business requirement
274
275
  // strippedDescription() {
275
276
  // let strippedString = this.description.replace(/(<([^>]+)>)/gi, '')
@@ -281,15 +282,16 @@ export default {
281
282
  },
282
283
  mounted() {
283
284
  if (this.$nuxt?.$on) {
284
- this.$nuxt.$on('scrollToTop', () => {
285
- setTimeout(() => {
286
- const title = this.$refs.title
287
- if (title) {
288
- title.$el.setAttribute('tabindex', 0)
289
- title.$el.focus()
290
- }
291
- }, 500)
292
- })
285
+ // console.log('🚀 ~ this.$nuxt.$on ~ this.$nuxt:', this.$nuxt)
286
+ // this.$nuxt.$on('scrollToTop', () => {
287
+ // setTimeout(() => {
288
+ // const title = this.$refs.title
289
+ // if (title) {
290
+ // title.$el.setAttribute('tabindex', 0)
291
+ // title.$el.focus()
292
+ // }
293
+ // }, 500)
294
+ // })
293
295
  }
294
296
  },
295
297
  beforeDestroy() {
@@ -314,20 +316,20 @@ export default {
314
316
  ev.target.scrollIntoView({
315
317
  behavior: 'smooth',
316
318
  alignToTop: true,
317
- block: 'start'
319
+ block: 'start',
318
320
  })
319
321
  }
320
322
  },
321
323
  fireGTM() {
322
324
  let attrs = {
323
325
  label: this.cta.uri,
324
- document_title: this.cta.filename
326
+ document_title: this.cta.filename,
325
327
  }
326
328
  if (this.$gtm) {
327
329
  this.$gtm.push({ event: 'custom.interaction.download', ...attrs })
328
330
  }
329
- }
330
- }
331
+ },
332
+ },
331
333
  }
332
334
  </script>
333
335
  <style lang="scss" scoped>