@worksafevictoria/wcl7.5 1.1.0 → 1.1.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,405 +0,0 @@
1
- <template>
2
- <div class="wcl-search">
3
- <div class="gcse-search"></div>
4
- </div>
5
- </template>
6
-
7
- <script>
8
- export default {
9
- mounted() {
10
- // console.log('Component mounted')
11
- this.setupCustomeStyle()
12
-
13
- // Introduce a delay before setting up addEventListener
14
- setTimeout(() => {
15
- this.setupCustomAttr()
16
- this.handleSearchResultLinkTitle()
17
- }, 2000) // Adjust the delay time as needed
18
- },
19
-
20
- beforeDestroy() {
21
- // Remove event listeners before the component is destroyed
22
- const targetNode = document.querySelector('input[name="search"]')
23
- const buttonNode = document.querySelector('button.gsc-search-button')
24
-
25
- if (targetNode) {
26
- // Add keyup.enter event listener
27
- targetNode.removeEventListener('keyup', this.handleKeyUp)
28
- buttonNode.removeEventListener('click', this.handleKeyUp)
29
- }
30
- const paginationNodes = document.querySelectorAll('.gsc-cursor-page')
31
- paginationNodes.forEach((paginationNode) => {
32
- paginationNode.removeEventListener('click', this.handleSearchResultTitle)
33
- })
34
- },
35
-
36
- methods: {
37
- // Method to customize google search style
38
- setupCustomeStyle() {
39
- const script = document.createElement('script')
40
- script.async = true
41
- script.src = 'https://cse.google.com/cse.js?cx=53b1506aa03c64160'
42
- document.head.appendChild(script)
43
-
44
- // Create a new style element
45
- const style = document.createElement('style')
46
- style.id = 'searchStyle' // Assign an ID to the style element
47
- // The CSS we are going to inject
48
- const cssVar = 'table.gssb_c {display: none !important;}'
49
- // Inject the style element into the head
50
- document.head.appendChild(style)
51
- // Set the text content of the style element to the CSS text
52
- style.textContent = cssVar
53
- },
54
-
55
- // Method to add google search input attributes
56
- setupCustomAttr() {
57
- console.log('setupCustomInputAttr ...')
58
-
59
- const targetNode = document.querySelector('input[name="search"]')
60
- const buttonNode = document.querySelector('button.gsc-search-button')
61
-
62
- if (targetNode) {
63
- // Add keyup.enter event listener
64
- targetNode.addEventListener('keyup', this.handleKeyUp)
65
- buttonNode.addEventListener('click', this.handleKeyUp)
66
- }
67
-
68
- this.setupPaginationEvent()
69
- },
70
-
71
- setupPaginationEvent() {
72
- console.log('setupPaginationEvent ....')
73
- // Introduce a delay before setting up addEventListener on pagination
74
- setTimeout(() => {
75
- this.handleSearchResultLinkTitle()
76
- const paginationNodes = document.querySelectorAll('.gsc-cursor-page')
77
- console.log('paginationNodes length ..', paginationNodes.length)
78
-
79
- if (paginationNodes && paginationNodes.length > 0) {
80
- console.log('FOUND PAGINATION ....', paginationNodes)
81
-
82
- // Loop through each element and add a click event listener
83
- paginationNodes.forEach((paginationNode) => {
84
- // Check if the click event listener has already been added
85
- if (!paginationNode.clickEventListenerAdded) {
86
- // Add a click event listener
87
- paginationNode.addEventListener(
88
- 'click',
89
- this.handleSearchResultTitle
90
- )
91
- // Mark that the click event listener has been added
92
- paginationNode.clickEventListenerAdded = true
93
- console.log('Adding a click event listener')
94
- }
95
- })
96
- }
97
- }, 2000) // Adjust the delay time as needed
98
- },
99
-
100
- // Method to trim text after '|'
101
- handleSearchResultTitle() {
102
- //alert('handleSearchResultTitle ....')
103
- this.setupPaginationEvent()
104
- },
105
-
106
- handleSearchResultLinkTitle() {
107
- //alert('handleSearchResultLinkTitle ....')
108
- // Get all targetNodes with class "a.gs-title"
109
- var targetNodes = document.querySelectorAll('a.gs-title')
110
- console.log('search list title targetNodes :- ', targetNodes)
111
-
112
- // Loop through each element and hide the text after the "|"
113
- targetNodes.forEach(function(element) {
114
- // Get the text content
115
- var text = element.textContent || element.innerText
116
-
117
- // Find the index of the "|" symbol
118
- var pipeIndex = text.indexOf('|')
119
- console.log('text :- ', text)
120
- // If the "|" symbol is found, update the text content to display only the part before "|"
121
- if (pipeIndex !== -1) {
122
- element.textContent = text.substring(0, pipeIndex).trim()
123
- }
124
- })
125
- },
126
-
127
- handleKeyUp(event) {
128
- if (event.key === 'Enter' || event.type === 'click') {
129
- let keyword = event.key
130
- ? event.target.value
131
- : document.querySelector('input[name="search"]').value
132
-
133
- // console.log('Enter key pressed. Value:', keyword)
134
-
135
- // Check if the URL does not contain "/search"
136
- if (keyword && !window.location.href.includes('/search')) {
137
- let origin = window.location.origin
138
- let hash = window.location.hash
139
- let pathname = 'search'
140
- let URL = origin + '/' + pathname + hash
141
- // console.log('URL does not contains "/search" ...', URL)
142
- window.location.assign(URL)
143
- }
144
-
145
- this.setupPaginationEvent
146
- }
147
- }
148
- }
149
- }
150
- </script>
151
- <style lang="scss" scoped>
152
- @import '../../../includes/scss/all';
153
-
154
- .wcl-search {
155
- :deep(form.gsc-search-box) {
156
- position: relative;
157
- display: -ms-flexbox;
158
- display: flex;
159
- -ms-flex-wrap: wrap;
160
- flex-wrap: wrap;
161
- -ms-flex-align: stretch;
162
- align-items: stretch;
163
- width: 100%;
164
- }
165
- :deep(.gsib_a) {
166
- padding: 0 !important;
167
- height: 56px;
168
- }
169
- :deep(.gsib_b) {
170
- position: absolute;
171
- right: 5px;
172
- top: 15px;
173
- }
174
- :deep(.gcsc-more-maybe-branding-root) {
175
- display: none;
176
- }
177
- :deep(table.gsc-input) {
178
- position: relative;
179
- }
180
- :deep(td.gsc-input) {
181
- border: none;
182
- padding: 0;
183
- width: 100%;
184
- }
185
- :deep(.gsc-input-box) {
186
- border: none;
187
- }
188
- :deep(input.gsc-input) {
189
- border-radius: 8px 0px 0px 8px;
190
- border: 1px solid $gray !important;
191
- border-right: 0 !important;
192
- background: none !important;
193
- color: #495057;
194
- height: 56px !important;
195
- position: relative;
196
- -ms-flex: 1 1 auto;
197
- flex: 1 1 auto;
198
- padding: 0.375rem 0.75rem !important;
199
-
200
- @media screen and (max-width: 320px) {
201
- width: 220px;
202
- }
203
-
204
- &:focus {
205
- box-shadow: none;
206
- }
207
- }
208
- :deep(.gsc-search-button) {
209
- display: -ms-flexbox;
210
- display: flex;
211
- margin-left: 0px;
212
- height: 56px;
213
- margin-top: 0px;
214
- }
215
- :deep(button.gsc-search-button) {
216
- background: $orange;
217
- border: none;
218
- border-radius: 0px 8px 8px 0px;
219
- color: $black;
220
- display: flex;
221
- align-items: center;
222
- height: 56px !important;
223
- font-size: 16px;
224
- font-weight: 700;
225
- padding-right: 32px;
226
- padding-left: 32px;
227
-
228
- &:before {
229
- content: 'Search';
230
- }
231
- @media screen and (max-width: 767px) {
232
- margin-top: 6px;
233
- }
234
- @media screen and (max-width: 320px) {
235
- padding-right: 16px;
236
- padding-left: 16px;
237
- }
238
-
239
- svg {
240
- fill: black;
241
- height: 18px;
242
- width: 18px;
243
- margin-left: 10px;
244
- }
245
-
246
- :focus {
247
- box-shadow: 0px;
248
- }
249
- }
250
-
251
- :deep(.gsst_a .gscb_a) {
252
- color: #191919;
253
- }
254
- :deep(.gsc-result-info) {
255
- color: #191919;
256
- font-size: 16px;
257
- font-weight: 400;
258
- }
259
- :deep(.gsc-above-wrapper-area) {
260
- padding: 20px 0;
261
- border-bottom: none;
262
- }
263
- /* search list start */
264
- :deep(.gsc-url-top) {
265
- display: none;
266
- }
267
- :deep(.gsc-table-result) {
268
- line-height: 1.6;
269
- padding: 0 5px;
270
- font-size: 16px;
271
- font-weight: 400;
272
- width: 80%;
273
- b {
274
- color: #191919;
275
- font-size: 16px;
276
- font-weight: normal;
277
- }
278
- }
279
- :deep(.gsc-resultsRoot.gsc-tabData) {
280
- width: 100%;
281
- margin-left: auto;
282
- margin-right: auto;
283
- padding-left: 15px;
284
- padding-right: 15px;
285
-
286
- &:hover {
287
- border: none;
288
- }
289
- }
290
- :deep(.gs-bidi-start-align.gs-snippet) {
291
- color: #191919 !important;
292
- line-height: 24px;
293
- }
294
- :deep(.gsc-thumbnail-inside) {
295
- position: relative;
296
- padding: 0;
297
-
298
- &::after {
299
- content: ' ';
300
- position: absolute;
301
- height: 16px;
302
- width: 11px;
303
- top: 5px;
304
- right: 16px;
305
- background-repeat: no-repeat;
306
- background-image: url(../../../assets/icons/chev-right.svg);
307
- background-size: 100%;
308
- }
309
- div.gs-title {
310
- width: 90%;
311
- margin-bottom: 12px;
312
- overflow: visible;
313
- }
314
- a.gs-title {
315
- color: #191919 !important;
316
- font-weight: 700;
317
- line-height: 24px;
318
- font-size: 20px;
319
- border: 3px solid transparent;
320
- padding-left: 5px;
321
- padding-right: 5px;
322
- text-decoration: underline;
323
-
324
- &:hover {
325
- border: 3px solid #da47ff;
326
- color: #006bff !important;
327
- b {
328
- color: #006bff !important;
329
- }
330
- }
331
-
332
- b {
333
- color: #191919 !important;
334
- font-size: 20px;
335
- }
336
- }
337
- }
338
- :deep(.gsc-orderby-label) {
339
- font-size: 16px;
340
- font-weight: 700;
341
- color: #191919;
342
- }
343
- :deep(.gsc-selected-option-container) {
344
- background-color: white;
345
- border-radius: 10px;
346
- margin-top: 0px;
347
- padding-top: 6px;
348
- margin-right: 0;
349
- margin-left: 4px;
350
- padding-left: 20px;
351
- padding-bottom: 6px;
352
- height: 40px;
353
- .gsc-selected-option {
354
- font-size: 16px;
355
- font-weight: 400;
356
- line-height: 24px;
357
- margin-right: 20px;
358
- }
359
- }
360
- :deep(.gsc-control-cse .gsc-option-selector) {
361
- margin-top: 0;
362
- margin-right: 10px;
363
- }
364
- :deep(.gsc-expansionArea > .gsc-webResult.gsc-result) {
365
- border: 0;
366
- flex: 0 0 100%;
367
- max-width: 100%;
368
- padding: 0;
369
- &:first-child {
370
- border-top: 1px solid #bababa;
371
- }
372
- > div {
373
- border-bottom: 1px solid #bababa;
374
- padding: 32px 0;
375
- }
376
- }
377
-
378
- :deep(.gsc-results .gsc-cursor-box .gsc-cursor-current-page) {
379
- background-color: lightgrey;
380
- }
381
- :deep(.gsc-results .gsc-cursor-box .gsc-cursor-page) {
382
- border: 1px solid grey;
383
- color: #333333;
384
- padding: 10px 12px;
385
- border-radius: 5px;
386
- font-size: 16px;
387
- font-weight: 400;
388
- }
389
- :deep(.gsc-results .gsc-cursor-box) {
390
- margin-top: 50px;
391
- }
392
-
393
- /* search list end */
394
- @include mq('xs') {
395
- .not-extra-small-screen {
396
- display: none;
397
- }
398
- }
399
- }
400
- @media screen and (max-width: 767px) {
401
- :deep(.gssb_c) {
402
- width: 85% !important;
403
- }
404
- }
405
- </style>