@worksafevictoria/wcl7.5 1.1.0-beta.73 → 1.1.0-beta.74

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.
@@ -18,7 +18,7 @@
18
18
  </div>
19
19
  </column>
20
20
  <!-- Cookie buttons displayed when not xs -->
21
- <column class="cookie-container__col hidden-on-xs">
21
+ <column class="cookie-container__col hidden-on-xs">
22
22
  <div class="cookie-buttons mt-md-3">
23
23
  <button
24
24
  id="moreBtn"
@@ -34,9 +34,9 @@
34
34
  id="accept_all"
35
35
  role="button"
36
36
  class="cookieBtn yellow hasIcon"
37
- style="order:1;"
37
+ style="order: 1"
38
38
  aria-label="Accept all cookies"
39
- @click="clickedCookie('accept'), fireGTM()"
39
+ @click="(clickedCookie('accept'), fireGTM())"
40
40
  >
41
41
  Accept all
42
42
  </button>
@@ -44,9 +44,9 @@
44
44
  id="reject_all"
45
45
  role="button"
46
46
  class="cookieBtn black hasIcon"
47
- style="order:2;"
47
+ style="order: 2"
48
48
  aria-label="Reject all cookies"
49
- @click="clickedCookie('reject'), fireGTM(), checkCookie()"
49
+ @click="(clickedCookie('reject'), fireGTM(), checkCookie())"
50
50
  >
51
51
  Reject all
52
52
  </button>
@@ -61,126 +61,155 @@
61
61
  <a
62
62
  id="acceptAllLink"
63
63
  href="#"
64
- @click="clickedCookie('accept'), fireGTM()"
64
+ @click="(clickedCookie('accept'), fireGTM())"
65
65
  >Accept all</a
66
66
  >
67
67
  <a
68
68
  id="rejectAllLink"
69
69
  href="#"
70
- @click="clickedCookie('reject'), fireGTM(), checkCookie()"
70
+ @click="(clickedCookie('reject'), fireGTM(), checkCookie())"
71
71
  >Reject all</a
72
72
  >
73
73
  </div>
74
74
  </row>
75
75
  </row>
76
76
  <!-- Modal -->
77
- <div v-if="showCookieModal" class="modal fade show" tabindex="-1" aria-modal="true" role="dialog" style="display: block;">
78
- <div class="modal-dialog">
79
- <div class="modal-content">
80
- <div class="modal-header">
81
- <div class="modal-heading-text">
82
- {{ cookieContent.modal.heading }}
83
- </div>
84
- <button type="button" class="btn-close" @click="showCookieModal = !showCookieModal" aria-label="close"></button>
85
- </div>
86
- <div class="modal-body">
87
- <fieldset>
88
- <row>
89
- <column>
90
- <h5>{{ cookieContent.modal.functional.heading }}</h5>
91
- </column>
92
- <column>
93
- <label for="modal1CB" class="option">
94
- Necessary<span class="visually-hidden">functional label</span>
95
- <input
96
- id="modal1CB"
97
- type="checkbox"
98
- value="functional"
99
- checked
100
- disabled
101
- />
102
- </label>
103
- </column>
104
- </row>
105
- <row>
106
- <column class="modal-description">
107
- {{cookieContent.modal.functional.description}}
108
- </column>
109
- </row>
110
- <hr />
111
- <row>
112
- <column>
113
- <h5>{{ cookieContent.modal.analytics.heading }}</h5>
114
- </column>
115
- <column>
116
- <label for="modal2CB" class="option">
117
- <span class="visually-hidden">analytics checkbox</span>
118
- <input
119
- id="modal2CB"
120
- type="checkbox"
121
- name="modal2CB"
122
- value="analytics"
123
- />
124
- </label>
125
- </column>
126
- </row>
127
- <row>
128
- <column class="modal-description">
129
- {{cookieContent.modal.analytics.description}}
130
- </column>
131
- </row>
132
- <hr />
133
- <row>
134
- <column>
135
- <h5>{{ cookieContent.modal.marketing.heading }}</h5>
136
- </column>
137
- <column text-align="right">
138
- <label for="modal3CB" class="option">
139
- <span class="visually-hidden">marketing checkbox</span>
140
- <input
141
- id="modal3CB"
142
- type="checkbox"
143
- name="modal3CB"
144
- value="marketing"
145
- />
146
- </label>
147
- </column>
148
- </row>
149
- <row>
150
- <column class="modal-description">
151
- {{cookieContent.modal.marketing.description}}
152
- </column>
153
- </row>
154
- </fieldset>
155
- </div>
156
- <div class="modal-footer">
157
- <button
158
- id="modal_save"
159
- type="button"
160
- role="button"
161
- class="cookieBtn yellow hasIcon"
162
- style="order:1;"
163
- aria-label="Save cookie settings"
164
- @click="clickedCookie('save'), fireGTM(), checkCookie(), showCookieModal = !showCookieModal"
165
- >
166
- Save
167
- </button>
168
- <button
169
- id="modal_accept"
170
- type="button"
171
- role="button"
172
- class="cookieBtn black hasIcon"
173
- style="order:2;"
174
- data-bs-dismiss="cookieModal"
175
- aria-label="Accept all cookies"
176
- @click="clickedCookie('accept'), fireGTM(), showCookieModal = !showCookieModal"
177
- >
178
- Accept all
179
- </button>
180
- </div>
181
- </div>
77
+ <b-modal
78
+ v-model="showCookieModal"
79
+ scrollable
80
+ @hidden="reset"
81
+ footer-border-variant="null"
82
+ no-header
83
+ size="md"
84
+ >
85
+ <template #default="{ close }">
86
+ <form ref="clearForm">
87
+ <container>
88
+ <row
89
+ ><column>
90
+ <div class="modal-heading">
91
+ {{ cookieContent.modal.heading }}
92
+ </div>
93
+ </column></row
94
+ >
95
+ <row>
96
+ <column>
97
+ <h5>{{ cookieContent.modal.functional.heading }}</h5>
98
+ </column>
99
+ <column>
100
+ <fieldset style="float: right">
101
+ <label for="modal1CB" class="option">
102
+ Necessary<span class="sr-only">functional label</span>
103
+ <input
104
+ id="modal1CB"
105
+ type="checkbox"
106
+ value="functional"
107
+ checked
108
+ disabled
109
+ @keyup.enter="(e) => e.target.click()"
110
+ />
111
+ </label>
112
+ </fieldset>
113
+ </column>
114
+ </row>
115
+ <row>
116
+ <column class="modal-description">{{
117
+ cookieContent.modal.functional.description
118
+ }}</column>
119
+ </row>
120
+ <hr />
121
+ <row>
122
+ <column>
123
+ <h5>{{ cookieContent.modal.analytics.heading }}</h5>
124
+ </column>
125
+ <column>
126
+ <fieldset style="float: right">
127
+ <label for="modal2CB" class="option"
128
+ ><span class="sr-only">analytics checkbox</span>
129
+ <input
130
+ id="modal2CB"
131
+ type="checkbox"
132
+ name="modal2CB"
133
+ value="analytics"
134
+ @keyup.enter="(e) => e.target.click()"
135
+ /></label>
136
+ </fieldset>
137
+ </column>
138
+ </row>
139
+ <row>
140
+ <column class="modal-description">{{
141
+ cookieContent.modal.analytics.description
142
+ }}</column>
143
+ </row>
144
+ <hr />
145
+ <row>
146
+ <column>
147
+ <h5>{{ cookieContent.modal.marketing.heading }}</h5>
148
+ </column>
149
+ <column>
150
+ <fieldset style="float: right">
151
+ <label for="modal3CB" class="option"
152
+ ><span class="sr-only">marketing checkbox</span>
153
+ <input
154
+ id="modal3CB"
155
+ type="checkbox"
156
+ name="modal3CB"
157
+ value="marketing"
158
+ @keyup.enter="(e) => e.target.click()"
159
+ /></label>
160
+ </fieldset>
161
+ </column>
162
+ </row>
163
+ <row>
164
+ <column class="modal-description">{{
165
+ cookieContent.modal.marketing.description
166
+ }}</column>
167
+ </row>
168
+ </container>
169
+ </form>
170
+ </template>
171
+
172
+ <template #footer="{ close }">
173
+ <div>
174
+ <button
175
+ id="modal_save"
176
+ type="button"
177
+ role="button"
178
+ class="cookieBtn yellow hasIcon"
179
+ style="order: 1"
180
+ aria-label="Save cookie settings"
181
+ @click="
182
+ () => {
183
+ clickedCookie('save')
184
+ fireGTM()
185
+ checkCookie()
186
+ close()
187
+ }
188
+ "
189
+ >
190
+ Save
191
+ </button>
192
+ <button
193
+ id="modal_accept"
194
+ type="button"
195
+ role="button"
196
+ class="cookieBtn black hasIcon"
197
+ style="order: 2"
198
+ data-bs-dismiss="cookieModal"
199
+ aria-label="Accept all cookies"
200
+ @click="
201
+ () => {
202
+ clickedCookie('accept')
203
+ fireGTM()
204
+ close()
205
+ }
206
+ "
207
+ >
208
+ Accept all
209
+ </button>
182
210
  </div>
183
- </div>
211
+ </template>
212
+ </b-modal>
184
213
  </container>
185
214
  </template>
186
215
 
@@ -189,23 +218,25 @@ import Container from './../../Containers/Container/index.vue'
189
218
  import Row from './../../Containers/Row/index.vue'
190
219
  import Column from './../../Containers/Column/index.vue'
191
220
  import { analyticsCookies, marketingCookies } from './Constants'
221
+ import { BModal } from 'bootstrap-vue-next'
192
222
 
193
223
  export default {
194
224
  name: 'Cookies',
195
225
  components: {
196
226
  Container,
197
227
  Row,
198
- Column
228
+ Column,
229
+ 'b-modal': BModal,
199
230
  },
200
231
  props: {
201
232
  cookieHeader: {
202
233
  type: String,
203
- default: 'Accept and Reject Cookies'
234
+ default: 'Accept and Reject Cookies',
204
235
  },
205
236
  cookieContent: {
206
237
  type: Object,
207
- default: () => {}
208
- }
238
+ default: () => {},
239
+ },
209
240
  },
210
241
  data() {
211
242
  return {
@@ -213,7 +244,7 @@ export default {
213
244
  analyticsCookies,
214
245
  marketingCookies,
215
246
  screenWidth: 0,
216
- showCookieModal: false
247
+ showCookieModal: false,
217
248
  }
218
249
  },
219
250
  computed: {
@@ -223,7 +254,7 @@ export default {
223
254
  showCookie() {
224
255
  //Check first if cookies have been turned on in the environment variable
225
256
  return process.env.SHOW_COOKIE === false ? false : true
226
- }
257
+ },
227
258
  },
228
259
  mounted() {
229
260
  // detect screen size to display smaller content
@@ -232,7 +263,6 @@ export default {
232
263
  // required, as unable to check localStorage until window loaded
233
264
  this.checkCookie()
234
265
  window.addEventListener('resize', this.updateScreenWidth)
235
-
236
266
  },
237
267
  unmounted() {
238
268
  window.removeEventListener('load', this.checkCookie)
@@ -243,29 +273,36 @@ export default {
243
273
  this.screenWidth = window.innerWidth
244
274
  },
245
275
  reset() {
246
- this.$emit('input', null)
276
+ this.$refs.clearForm.reset()
277
+ //this.$emit('input', null)
247
278
  },
279
+
248
280
  //function to set cookies based on response in overlay or modal
249
281
  clickedCookie: (clickResponse) => {
250
282
  const analyticsCookieName = 'analyticsCookies'
251
283
  const marketingCookieName = 'marketingCookies'
252
284
  var cookieElement = document.getElementById('mainCookieContainer')
253
-
285
+
254
286
  if (cookieElement) {
255
287
  localStorage.setItem('cookieBannerDisplayed', 'true') // Mark the banner as displayed
256
-
288
+
257
289
  if (clickResponse === 'accept') {
258
290
  // localStorage.setItem('cookieBannerDisplayed', 'false')
259
291
  localStorage.setItem(analyticsCookieName, 'granted')
260
292
  localStorage.setItem(marketingCookieName, 'granted')
261
-
262
293
  } else if (clickResponse === 'save') {
263
294
  // localStorage.setItem('cookieBannerDisplayed', 'false')
264
295
  const acb = document.getElementById('modal2CB')
265
296
  const mcb = document.getElementById('modal3CB')
266
297
 
267
- localStorage.setItem(analyticsCookieName, acb.checked ? 'granted' : 'denied')
268
- localStorage.setItem(marketingCookieName, mcb.checked ? 'granted' : 'denied')
298
+ localStorage.setItem(
299
+ analyticsCookieName,
300
+ acb.checked ? 'granted' : 'denied',
301
+ )
302
+ localStorage.setItem(
303
+ marketingCookieName,
304
+ mcb.checked ? 'granted' : 'denied',
305
+ )
269
306
  } else {
270
307
  // clickResponse === 'reject'
271
308
  // localStorage.setItem('cookieBannerDisplayed', 'false')
@@ -279,30 +316,30 @@ export default {
279
316
  },
280
317
  // function to update consent in GTM
281
318
  fireGTM() {
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
- // }
319
+ if (this.$gtm) {
320
+ // gather attrs
321
+ let aConsent = localStorage.getItem('analyticsCookies')
322
+ let mConsent = localStorage.getItem('marketingCookies')
323
+ let attrs1 = {
324
+ ad_storage: mConsent,
325
+ }
326
+ // fire the event - marketing
327
+ this.$gtm.push({
328
+ event: 'gtm_consent_update',
329
+ ...attrs1,
330
+ })
331
+ let attrs2 = {
332
+ analytics_storage: aConsent,
333
+ }
334
+ // fire the event - analytics
335
+ this.$gtm.push({
336
+ event: 'gtm_consent_update',
337
+ ...attrs2,
338
+ })
339
+ }
303
340
  },
304
341
  //function to remove from local storage based on partial match - called from checkCookie
305
- removeLocalStorage: function(cookieName) {
342
+ removeLocalStorage: function (cookieName) {
306
343
  var removeArr = []
307
344
  for (var i = 0; i < localStorage.length; i++) {
308
345
  var x = localStorage.key(i)
@@ -315,123 +352,124 @@ export default {
315
352
  })
316
353
  },
317
354
  // function to remove cookies according to response from overlay or modal
318
- checkCookie: function() {
319
- const cookieElement = document.getElementById('mainCookieContainer');
320
- const bannerDisplayed = localStorage.getItem('cookieBannerDisplayed');
321
-
355
+ checkCookie: function () {
356
+ const cookieElement = document.getElementById('mainCookieContainer')
357
+ const bannerDisplayed = localStorage.getItem('cookieBannerDisplayed')
322
358
 
323
- if (this.showCookie && bannerDisplayed !== 'true') {
324
- // Show the banner if it's not been displayed yet
325
- cookieElement.classList.remove('hide')
326
- cookieElement.classList.add('show')
327
- } else {
328
- // Hide the banner if user has already made a selection
329
- // need to remove cookies in rejected categories, but first hide cookie overlay
330
- cookieElement.classList.add('hide')
331
- cookieElement.classList.remove('show')
359
+ if (this.showCookie && bannerDisplayed !== 'true') {
360
+ // Show the banner if it's not been displayed yet
361
+ cookieElement.classList.remove('hide')
362
+ cookieElement.classList.add('show')
363
+ } else {
364
+ // Hide the banner if user has already made a selection
365
+ // need to remove cookies in rejected categories, but first hide cookie overlay
366
+ cookieElement.classList.add('hide')
367
+ cookieElement.classList.remove('show')
332
368
 
333
- // get list of categorised cookies
334
- const analyticsArr = analyticsCookies
335
- const marketingArr = marketingCookies
369
+ // get list of categorised cookies
370
+ const analyticsArr = analyticsCookies
371
+ const marketingArr = marketingCookies
336
372
 
337
- // get list of cookies to process
338
- var pairs = document.cookie.split(';')
339
- var cookieArr = []
340
- for (var i = 0; i < pairs.length; i++) {
341
- var pair = pairs[i].split('=')
342
- var nameVar = [pair[0].trim()]
343
- cookieArr.push(nameVar[0])
344
- }
345
- // identify which categories to process, initialising variables to false
346
- // will only be set to true if user has rejected any cookies
347
- var checkAnalytics = false
348
- var checkMarketing = false
373
+ // get list of cookies to process
374
+ var pairs = document.cookie.split(';')
375
+ var cookieArr = []
376
+ for (var i = 0; i < pairs.length; i++) {
377
+ var pair = pairs[i].split('=')
378
+ var nameVar = [pair[0].trim()]
379
+ cookieArr.push(nameVar[0])
380
+ }
381
+ // identify which categories to process, initialising variables to false
382
+ // will only be set to true if user has rejected any cookies
383
+ var checkAnalytics = false
384
+ var checkMarketing = false
349
385
 
350
- // get value of consent cookies to determine if cookies have to be removed
351
- var analyticsValue = localStorage.getItem('analyticsCookies')
352
- if (analyticsValue !== null && analyticsValue === 'denied') {
353
- checkAnalytics = true
354
- }
386
+ // get value of consent cookies to determine if cookies have to be removed
387
+ var analyticsValue = localStorage.getItem('analyticsCookies')
388
+ if (analyticsValue !== null && analyticsValue === 'denied') {
389
+ checkAnalytics = true
390
+ }
355
391
 
356
- var marketingValue = localStorage.getItem('marketingCookies')
357
- if (marketingValue !== null && marketingValue === 'denied') {
358
- checkMarketing = true
359
- }
392
+ var marketingValue = localStorage.getItem('marketingCookies')
393
+ if (marketingValue !== null && marketingValue === 'denied') {
394
+ checkMarketing = true
395
+ }
360
396
 
361
- // Remove analytics cookies stored as cookies or localStorage
362
- if (checkAnalytics) {
363
- analyticsArr.forEach((cookieName) => {
364
- if (cookieName.name.slice(-1) === '*') {
365
- var tmpVar = cookieName.name.slice(0, -1)
366
- this.removeLocalStorage(tmpVar)
367
- var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
368
- tmpArr.forEach((tmpName) => {
369
- document.cookie =
370
- tmpName +
371
- '=;expires=' +
372
- new Date(0).toUTCString() +
373
- ';domain=' +
374
- cookieName.domain +
375
- ';path=' +
376
- cookieName.path
377
- })
378
- } else {
379
- localStorage.removeItem(cookieName.name)
397
+ // Remove analytics cookies stored as cookies or localStorage
398
+ if (checkAnalytics) {
399
+ analyticsArr.forEach((cookieName) => {
400
+ if (cookieName.name.slice(-1) === '*') {
401
+ var tmpVar = cookieName.name.slice(0, -1)
402
+ this.removeLocalStorage(tmpVar)
403
+ var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
404
+ tmpArr.forEach((tmpName) => {
380
405
  document.cookie =
381
- cookieName.name +
406
+ tmpName +
382
407
  '=;expires=' +
383
408
  new Date(0).toUTCString() +
384
409
  ';domain=' +
385
410
  cookieName.domain +
386
411
  ';path=' +
387
412
  cookieName.path
388
- }
389
- })
390
- }
391
- // Remove marketing cookies stored as cookies or localStorage
392
- if (checkMarketing) {
393
- marketingArr.forEach((cookieName) => {
394
- if (cookieName.name.slice(-1) === '*') {
395
- var tmpVar = cookieName.name.slice(0, -1)
396
- this.removeLocalStorage(tmpVar)
397
- var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
398
- tmpArr.forEach((tmpName) => {
399
- document.cookie =
400
- tmpName +
401
- '=;expires=' +
402
- new Date(0).toUTCString() +
403
- ';domain=' +
404
- cookieName.domain +
405
- ';path=' +
406
- cookieName.path
407
- })
408
- } else {
409
- localStorage.removeItem(cookieName.name)
413
+ })
414
+ } else {
415
+ localStorage.removeItem(cookieName.name)
416
+ document.cookie =
417
+ cookieName.name +
418
+ '=;expires=' +
419
+ new Date(0).toUTCString() +
420
+ ';domain=' +
421
+ cookieName.domain +
422
+ ';path=' +
423
+ cookieName.path
424
+ }
425
+ })
426
+ }
427
+ // Remove marketing cookies stored as cookies or localStorage
428
+ if (checkMarketing) {
429
+ marketingArr.forEach((cookieName) => {
430
+ if (cookieName.name.slice(-1) === '*') {
431
+ var tmpVar = cookieName.name.slice(0, -1)
432
+ this.removeLocalStorage(tmpVar)
433
+ var tmpArr = cookieArr.filter((x) => x.match(cookieName.name))
434
+ tmpArr.forEach((tmpName) => {
410
435
  document.cookie =
411
- cookieName.name +
436
+ tmpName +
412
437
  '=;expires=' +
413
438
  new Date(0).toUTCString() +
414
439
  ';domain=' +
415
440
  cookieName.domain +
416
441
  ';path=' +
417
442
  cookieName.path
418
- }
419
- })
420
- }
443
+ })
444
+ } else {
445
+ localStorage.removeItem(cookieName.name)
446
+ document.cookie =
447
+ cookieName.name +
448
+ '=;expires=' +
449
+ new Date(0).toUTCString() +
450
+ ';domain=' +
451
+ cookieName.domain +
452
+ ';path=' +
453
+ cookieName.path
454
+ }
455
+ })
421
456
  }
422
-
423
- }
424
- }
457
+ }
458
+ },
459
+ },
425
460
  }
426
461
  </script>
427
462
 
428
463
  <style lang="scss" scoped>
464
+ /* Removed scoped */
429
465
  @import './styles';
430
-
431
- #mainCookieContainer {
432
- .modal-dialog {
433
- max-width: var(--bs-modal-width);
434
- margin: 1.75rem auto;
435
- }
466
+ :deep(.modal-heading) {
467
+ font-size: 26px;
468
+ font-weight: 700;
469
+ line-height: 30px;
470
+ letter-spacing: 0px;
471
+ margin-bottom: 16px;
472
+ display: flex;
473
+ justify-content: flex-end !important;
436
474
  }
437
475
  </style>