hr-design-system-handlebars 1.95.0 → 1.96.0

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,51 +1,37 @@
1
- import { download, pi, uxAction, uxNavigation } from 'base/tracking/pianoHelper.subfeature'
1
+ import { download, pi, uxAction, uxNavigation } from 'base/tracking/pianoHelper.subfeature';
2
2
 
3
- const ClickTracking = function (context) {
4
- const { options } = context,
5
- { element: elementToTrack } = context,
6
- settings = options.settings || []
3
+ const ClickTracking = (context) => {
4
+ const { options, element: elementToTrack } = context;
5
+ const settings = options.settings || [];
7
6
 
8
- const init = function () {
9
- configureEventHandlers()
10
- }
11
-
12
- const configureEventHandlers = function () {
13
- if (window.attachEvent) {
14
- elementToTrack.attachEvent('click', clickHandler)
15
- } else {
16
- elementToTrack.addEventListener('click', clickHandler)
17
- }
18
- }
19
-
20
- const clickHandler = function (event) {
21
- settings.forEach(function (trackingSetting) {
7
+ const clickHandler = (event) => {
8
+ settings.forEach(({ type, clickLabel, secondLevelId }) => {
22
9
  /* use String.prototype.replace function with a regex and the global flag
23
10
  instead of String.prototype.replaceAll function to prevent errors in older
24
11
  browsers that don't know the replaceAll function
25
12
  see: https://www.designcise.com/web/tutorial/how-to-fix-replaceall-is-not-a-function-javascript-error
26
13
  */
27
- trackingSetting.clickLabel = trackingSetting.clickLabel.replace(/&/g, '-')
28
- switch (trackingSetting.type) {
14
+ const sanitizedLabel = clickLabel.replace(/&/g, '-');
15
+ switch (type) {
29
16
  case 'download':
30
- download(trackingSetting.clickLabel, trackingSetting.secondLevelId)
31
- break
17
+ download(sanitizedLabel, secondLevelId);
18
+ break;
32
19
  case 'pi':
33
- pi()
34
- break
20
+ pi();
21
+ break;
35
22
  case 'uxAction':
36
- uxAction(trackingSetting.clickLabel, trackingSetting.secondLevelId)
37
- break
23
+ uxAction(sanitizedLabel, secondLevelId);
24
+ break;
38
25
  case 'uxNavigation':
39
- uxNavigation(trackingSetting.clickLabel, trackingSetting.secondLevelId)
40
- break
26
+ uxNavigation(sanitizedLabel, secondLevelId);
27
+ break;
41
28
  default:
42
- console.log('Fehler, es wurde kein Tracking Typ angegeben.')
43
- break
29
+ console.error('Fehler, es wurde kein Tracking Typ angegeben.');
44
30
  }
45
- })
46
- }
31
+ });
32
+ };
47
33
 
48
- init()
49
- }
34
+ elementToTrack.addEventListener('click', clickHandler);
35
+ };
50
36
 
51
- export default ClickTracking
37
+ export default ClickTracking;
@@ -1,44 +1,36 @@
1
- import SettingsCookie from 'components/externalService/globalSettingsCookie.subfeature'
1
+ import SettingsCookie from 'components/externalService/globalSettingsCookie.subfeature';
2
2
 
3
3
  const isTrackingAllowed = () => {
4
- const settingsCookie = new SettingsCookie()
5
- return settingsCookie.isSettingsCookieAccepted('ati')
6
- }
7
-
8
- const uxAction = (label, secondLevelId) => {
9
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
10
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
11
- pa.sendEvent('click.action', {
12
- click: label,
13
- site_level2_id: secondLevelId,
14
- })
15
- }
16
- }
17
-
18
- const uxNavigation = (label, secondLevelId) => {
19
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
20
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
21
- pa.sendEvent('click.navigation', {
22
- click: label,
23
- site_level2_id: secondLevelId,
24
- })
25
- }
26
- }
4
+ const settingsCookie = new SettingsCookie();
5
+ return settingsCookie.isSettingsCookieAccepted('ati');
6
+ };
27
7
 
28
- const pi = () => {
29
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
30
- pa.sendEvent('page.display', pageDisplayConfig)
8
+ const sendEvent = (eventType, event) => {
9
+ if (typeof pa !== 'undefined' && pa !== undefined && isTrackingAllowed()) {
10
+ pa.sendEvent(eventType, event);
31
11
  }
32
- }
33
-
34
- const download = (label, secondLevelId) => {
35
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
36
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
37
- pa.sendEvent('click.download', {
38
- click: label,
39
- site_level2_id: secondLevelId,
40
- })
12
+ };
13
+
14
+ const getDefaultEvent = (label, secondLevelId) => {
15
+ return {
16
+ click: label,
17
+ site_level2_id: determineSecondLevelId(secondLevelId)
41
18
  }
42
- }
19
+ };
20
+
21
+ const determineSecondLevelId = (secondLevelId) => {
22
+ return secondLevelId !== undefined
23
+ ? secondLevelId
24
+ : pageDisplayConfig.site_level2_id;
25
+ };
26
+
27
+ const uxAction = (label, secondLevelId) => sendEvent('click.action', getDefaultEvent(label, secondLevelId));
28
+
29
+ const uxNavigation = (label, secondLevelId) => sendEvent('click.navigation', getDefaultEvent(label, secondLevelId));
30
+
31
+ const pi = () => sendEvent('page.display', pageDisplayConfig);
32
+
33
+ const download = (label, secondLevelId) => sendEvent('click.download', getDefaultEvent(label, secondLevelId));
34
+
43
35
 
44
- export { isTrackingAllowed, uxAction, uxNavigation, pi, download }
36
+ export { isTrackingAllowed, uxAction, uxNavigation, pi, download };
@@ -100,4 +100,18 @@
100
100
  {{~> components/base/image/icon _addClass="w-full h-full fill-link hover:scale-105" _icon="kontakt-ds" _iconmap="icons" ~}}
101
101
  </a>
102
102
  </li>
103
+ {{/with}}
104
+ {{~#with this.printLink}}
105
+ <li class="">
106
+ <button class="{{#with ../_trackingData}} js-load{{/with}} flex order-2 ds-button font-heading active:scale-95 w-8 h-8"
107
+ title="{{loca "share_copy_linktitle" }}"
108
+ onclick="window.print()"
109
+ {{#with ../_trackingData}}
110
+ data-hr-click-tracking='{"settings": [{"type":"uxAction","secondLevelId": "{{this.secondLevelId}}","clickLabel": "socialShareClick::{{if ../../_socialSharingType ../../_socialSharingType "default" }}::print"}]}'
111
+ {{/with}}
112
+ >
113
+ <span x-cloak class="flex items-center justify-center w-full h-full">{{~> components/base/image/icon _addClass="w-full h-full fill-link hover:scale-105" _icon="print-ds" _iconmap="icons" ~}}</span>
114
+
115
+ </button>
116
+ </li>
103
117
  {{/with}}
@@ -100,4 +100,18 @@
100
100
  {{~> components/base/image/icon _addClass="w-full h-full fill-link hover:scale-105" _icon="kontakt-ds" _iconmap="icons" ~}}
101
101
  </a>
102
102
  </li>
103
+ {{/with}}
104
+ {{~#with this.printLink}}
105
+ <li class="">
106
+ <button class="{{#with ../_trackingData}} js-load{{/with}} flex order-2 ds-button font-heading active:scale-95 w-8 h-8"
107
+ title="{{loca "share_copy_linktitle" }}"
108
+ onclick="window.print()"
109
+ {{#with ../_trackingData}}
110
+ data-hr-click-tracking='{"settings": [{"type":"uxAction","secondLevelId": "{{this.secondLevelId}}","clickLabel": "socialShareClick::{{if ../../_socialSharingType ../../_socialSharingType "default" }}::print"}]}'
111
+ {{/with}}
112
+ >
113
+ <span x-cloak class="flex items-center justify-center w-full h-full">{{~> components/base/image/icon _addClass="w-full h-full fill-link hover:scale-105" _icon="print-ds" _iconmap="icons" ~}}</span>
114
+
115
+ </button>
116
+ </li>
103
117
  {{/with}}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
8
  "repository": "https://github.com/szuelch/hr-design-system-handlebars",
9
- "version": "1.95.0",
9
+ "version": "1.96.0",
10
10
  "scripts": {
11
11
  "test": "echo \"Error: no test specified\" && exit 1",
12
12
  "storybook": "storybook dev -p 6006 public",
@@ -2,6 +2,18 @@
2
2
 
3
3
  "@->jsoninclude": "page/story/story.inc.json",
4
4
  "@->overrides": [
5
+ {
6
+ "@->contentpath": "socialSharing",
7
+ "@->value": {
8
+ "twitterLink": "/twitterLink-url",
9
+ "facebookLink": "/facebookLink-url",
10
+ "whatsappLink": "/whatsappLink-url",
11
+ "mailtoLink": "/mailtoLink-url",
12
+ "copyToClipboardLink": "/copyToClipboard-url",
13
+ "printLink": true
14
+
15
+ }
16
+ },
5
17
  {
6
18
  "@->contentpath": "label",
7
19
  "@->value":
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 320 320">
2
+ <path d="M268.8,86.1h-19.9c0-.6,0-1.2,0-1.9v-39.5c0-11.4-9.3-20.7-20.7-20.7H90.8c-11.4,0-20.7,9.3-20.7,20.7v39.5c0,.6,0,1.3,0,1.9h-18.9c-15.6,0-28.2,12.7-28.2,28.2v96c0,15.6,12.7,28.2,28.2,28.2h18.8v36.7c0,11.4,9.3,20.7,20.7,20.7h137.5c11.4,0,20.7-9.3,20.7-20.7v-36.7h19.8c15.6,0,28.2-12.7,28.2-28.2v-96c0-15.6-12.7-28.2-28.2-28.2ZM88.9,44.7c0-1,.8-1.9,1.9-1.9h137.5c1,0,1.9.8,1.9,1.9v39.5c0,1-.8,1.9-1.9,1.9H90.8c-1,0-1.9-.8-1.9-1.9v-39.5ZM230.1,275.3c0,1-.8,1.9-1.9,1.9H90.8c-1,0-1.9-.8-1.9-1.9v-92.3c0-1,.8-1.9,1.9-1.9h137.5c1,0,1.9.8,1.9,1.9v92.3ZM278.2,210.4c0,5.2-4.2,9.4-9.4,9.4h-19.8v-36.7c0-11.4-9.3-20.7-20.7-20.7H90.8c-11.4,0-20.7,9.3-20.7,20.7v36.7h-18.8c-5.2,0-9.4-4.2-9.4-9.4v-96c0-5.2,4.2-9.4,9.4-9.4h217.5c5.2,0,9.4,4.2,9.4,9.4v96Z"/>
3
+ <path d="M207,194.8h-94.2c-5.2,0-9.4,4.2-9.4,9.4s4.2,9.4,9.4,9.4h94.2c5.2,0,9.4-4.2,9.4-9.4s-4.2-9.4-9.4-9.4Z"/>
4
+ <path d="M207,231.6h-94.2c-5.2,0-9.4,4.2-9.4,9.4s4.2,9.4,9.4,9.4h94.2c5.2,0,9.4-4.2,9.4-9.4s-4.2-9.4-9.4-9.4Z"/>
5
+ </svg>