hr-design-system-handlebars 0.51.0 → 0.51.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v0.51.1 (Thu Jul 28 2022)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - FEATURE: All js files that get loaded by [#288](https://github.com/mumprod/hr-design-system-handlebars/pull/288) ([@szuelch](https://github.com/szuelch))
6
+
7
+ #### Authors: 1
8
+
9
+ - [@szuelch](https://github.com/szuelch)
10
+
11
+ ---
12
+
1
13
  # v0.51.0 (Wed Jul 27 2022)
2
14
 
3
15
  #### 🚀 Enhancement
@@ -7,5 +7,7 @@ const run = (cmd) => execSync(cmd, { stdio: 'inherit', cwd: root })
7
7
  // Copy hbs files into the dist folder
8
8
  run(`npx copyfiles \"./src/index.js\" dist --up=1`)
9
9
  run(`npx copyfiles \"./src/stories/views/**/*.{js,hbs}\" dist --up=2`)
10
- run(`npx copyfiles \"./src/stories/views/**/*Ds.{feature,subfeature}.js\" dist/assets/js --up=2`)
10
+ run(
11
+ `npx copyfiles -e \"./src/stories/views/**/clickTracking.feature.js\" \"./src/stories/views/**/*.{feature,subfeature}.js\" dist/assets/js --up=2`
12
+ )
11
13
  run(`npx copyfiles \"./src/assets/**/*.{woff,svg}\" dist --up=1`)
@@ -0,0 +1,36 @@
1
+ import TrackingCookie from 'components/externalService/trackingCookieDs.subfeature'
2
+
3
+ const isTrackingAllowed = () => {
4
+ const trackingCookie = new TrackingCookie()
5
+ return trackingCookie.isTrackingAccepted('ati')
6
+ }
7
+
8
+ const uxAction = (label, secondLevelId) => {
9
+ secondLevelId = secondLevelId || window.xtn2
10
+ if (window.xt_click && isTrackingAllowed()) {
11
+ window.xt_click('this', 'C', secondLevelId, label, 'A')
12
+ }
13
+ }
14
+
15
+ const uxNavigation = (label, secondLevelId) => {
16
+ secondLevelId = secondLevelId || window.xtn2
17
+ if (window.xt_click && isTrackingAllowed()) {
18
+ window.xt_click('this', 'C', secondLevelId, label, 'N')
19
+ }
20
+ }
21
+
22
+ const pi = (label, secondLevelId) => {
23
+ secondLevelId = secondLevelId || window.xtn2
24
+ if (window.xt_click && isTrackingAllowed()) {
25
+ window.xt_click('this', 'F', secondLevelId, label)
26
+ }
27
+ }
28
+
29
+ const download = (label, secondLevelId) => {
30
+ secondLevelId = secondLevelId || window.xtn2
31
+ if (window.xt_click && isTrackingAllowed()) {
32
+ window.xt_click('this', 'C', secondLevelId, label, 'T')
33
+ }
34
+ }
35
+
36
+ export { isTrackingAllowed, uxAction, uxNavigation, pi, download }
@@ -0,0 +1,193 @@
1
+ import { isTrackingAllowed, pi } from 'base/tracking/atiHelper.subfeature'
2
+
3
+ const ATIMediaHelper = function (
4
+ avType,
5
+ pageName,
6
+ secondLevelId,
7
+ length,
8
+ multcid,
9
+ multctype,
10
+ multcdate,
11
+ chapter
12
+ ) {
13
+ 'use strict'
14
+ ;(this.avType = avType),
15
+ (this.secondLevelId = secondLevelId),
16
+ (this.multcid = multcid),
17
+ (this.multctype = multctype),
18
+ (this.multcdate = multcdate),
19
+ (this.chapter = chapter),
20
+ (this.pageName = pageName),
21
+ (this.length = length),
22
+ (this.wasNeverPlayed = true)
23
+
24
+ /*console.log(this.avType)
25
+ console.log(this.secondLevelId)
26
+ console.log(this.pageName)
27
+ console.log(this.length)*/
28
+ }
29
+
30
+ ATIMediaHelper.prototype = {
31
+ xtRichMediaVideoHelper: function (data) {
32
+ if (window.xt_rm && isTrackingAllowed()) {
33
+ console.log('XT_RM')
34
+ console.log('A ID: ' + data.avType + '&plyr=' + data.pageName)
35
+ console.log('B SECONDLEVELID: ' + data.secondLevelId)
36
+ console.log('C PAGENAME: ' + data.pageName + ':' + data.avType + 'Play')
37
+ console.log('D ACTION: ' + data.action)
38
+ console.log('F REFRESH: ' + data.refresh)
39
+ console.log('G DURATION: ' + data.length)
40
+ console.log('H POSTIONBUF: ' + '0')
41
+ console.log('H POSITION: ' + 'rmp=' + data.position)
42
+ console.log('H POSITIONNEW: ' + data.positionNew)
43
+ console.log('J DATARATE: ' + data.datarate)
44
+ console.log('K LOCATION: ' + data.location)
45
+ console.log('L TYPE: ' + data.type)
46
+ console.log('M SIZE: ' + data.size)
47
+ console.log('N FORMAT: ' + data.format)
48
+ xt_rm(
49
+ data.avType + '&plyr=' + data.pageName,
50
+ data.secondLevelId,
51
+ data.pageName + ':' + data.avType + 'Play',
52
+ data.action,
53
+ '',
54
+ data.refresh,
55
+ data.length,
56
+ '&rmp=' + data.position + '&rmpf=' + data.positionNew + '&rmbufp=0',
57
+ '',
58
+ data.datarate,
59
+ data.location,
60
+ data.type,
61
+ data.size,
62
+ data.format
63
+ )
64
+ }
65
+ },
66
+
67
+ xtClickVideoHelper: function (data) {
68
+ if (window.xt_click) {
69
+ console.log('XT_CLICK ')
70
+ var uniqueId = Math.abs(this.hashCode(data.pageName))
71
+ uniqueId = uniqueId.length > 15 ? uniqueId.substring(0, 15) : uniqueId
72
+ pi(
73
+ data.pageName +
74
+ ':' +
75
+ data.avType +
76
+ 'Play' +
77
+ '&pid=' +
78
+ uniqueId +
79
+ '&pchap=' +
80
+ data.chapter +
81
+ '&pidt=' +
82
+ data.x5 +
83
+ '&x1=' +
84
+ data.x1 +
85
+ '&x2=' +
86
+ data.x2 +
87
+ '&x5=' +
88
+ data.x5.substring(0, 8),
89
+ data.secondLevelId
90
+ )
91
+ }
92
+ },
93
+
94
+ hashCode: function (string) {
95
+ var hash = 0,
96
+ i,
97
+ chr
98
+ if (string.length === 0) return hash
99
+ for (i = 0; i < string.length; i++) {
100
+ chr = string.charCodeAt(i)
101
+ hash = (hash << 5) - hash + chr
102
+ hash |= 0 // Convert to 32bit integer
103
+ }
104
+ return hash
105
+ },
106
+
107
+ trackInitialMediaPlay: function () {
108
+ const data = {}
109
+
110
+ if (this.wasNeverPlayed) {
111
+ if (this.avType === 'livestreamVideo' || this.avType === 'livestreamAudio') {
112
+ data.object = 'this'
113
+ data.click = 'F'
114
+ if (this.avType === 'livestreamVideo') {
115
+ data.pageName = this.pageName + ':video'
116
+ data.avType = 'video'
117
+ } else {
118
+ data.pageName = this.pageName + ':audio'
119
+ data.avType = 'audio'
120
+ }
121
+ data.secondLevelId = this.secondLevelId
122
+ data.x1 = this.multcid
123
+ data.x2 = this.multctype
124
+ data.x5 = this.multcdate
125
+ data.chapter = this.chapter
126
+ data.action = 'play'
127
+ data.refresh = '10'
128
+ data.length = ''
129
+ data.position = '0'
130
+ data.positionNew = '0'
131
+ data.datarate = ''
132
+ data.location = 'int'
133
+ data.type = 'live'
134
+ data.size = ''
135
+ data.format = ''
136
+ } else {
137
+ data.object = 'this'
138
+ data.click = 'F'
139
+ data.avType = this.avType
140
+ data.pageName = this.pageName
141
+ data.secondLevelId = this.secondLevelId
142
+ data.x1 = this.multcid
143
+ data.x2 = this.multctype
144
+ data.x5 = this.multcdate
145
+ data.chapter = this.chapter
146
+ data.action = 'play'
147
+ data.refresh = ''
148
+ data.length = this.length
149
+ data.position = '0'
150
+ data.positionNew = '0'
151
+ data.datarate = '19'
152
+ data.location = 'int'
153
+ data.type = 'clip'
154
+ data.size = '100000'
155
+ data.format = '9'
156
+ }
157
+
158
+ this.xtClickVideoHelper(data)
159
+ this.xtRichMediaVideoHelper(data)
160
+ }
161
+
162
+ this.wasNeverPlayed = false
163
+ },
164
+
165
+ trackMediaSeek: function (_from, _to) {
166
+ console.log(_from)
167
+ console.log(_to)
168
+
169
+ const data = {}
170
+
171
+ data.avType = this.avType
172
+ data.pageName = this.pageName
173
+ data.secondLevelId = this.secondLevelId
174
+ data.x1 = this.multcid
175
+ data.x2 = this.multctype
176
+ data.x5 = this.multcdate
177
+ data.chapter = this.chapter
178
+ data.action = 'move'
179
+ data.refresh = ''
180
+ data.length = this.length
181
+ data.position = _from
182
+ data.positionNew = _to
183
+ data.datarate = ''
184
+ data.location = 'int'
185
+ data.type = 'clip'
186
+ data.size = ''
187
+ data.format = ''
188
+
189
+ this.xtRichMediaVideoHelper(data)
190
+ },
191
+ }
192
+
193
+ export default ATIMediaHelper
@@ -0,0 +1,16 @@
1
+ import { hr$ } from 'hrQuery'
2
+ const Foo = (context) => {
3
+ const { options } = context
4
+ const { element: rootElement } = context
5
+ const { test } = options
6
+
7
+ const init = () => {
8
+ console.log(rootElement)
9
+ console.log(hr$('.inner', rootElement))
10
+ console.log(`Feature ${test} geladen`)
11
+ }
12
+
13
+ init()
14
+ }
15
+
16
+ export default Foo
@@ -0,0 +1,380 @@
1
+ import Initializer from 'initializer'
2
+ import loadFeature from 'loadFeature'
3
+
4
+ const hr$ = (selector, element) => {
5
+ // if element set, use it
6
+ // if not use document as default
7
+ const rootElement = element || document
8
+
9
+ // falls kein selector angegeben
10
+ // gib das element zurück
11
+ if (!selector) {
12
+ return rootElement
13
+ }
14
+
15
+ // wenn ein , oder ein leerzeichen '.class1 .class2'
16
+ // in der query dann qSA
17
+ if (
18
+ selector.indexOf(',') > 0 ||
19
+ selector.split(' ').length > 1 ||
20
+ selector.split('.').length > 1
21
+ ) {
22
+ return rootElement.querySelectorAll(selector)
23
+ }
24
+
25
+ if (selector[0] === '.') {
26
+ return rootElement.getElementsByClassName(selector.substring(1))
27
+ }
28
+
29
+ if (selector[0] === '#') {
30
+ return new Array(document.getElementById(selector.substring(1)))
31
+ }
32
+
33
+ // gib eine NodeList zurück
34
+ return rootElement.querySelectorAll(selector)
35
+ }
36
+
37
+ const stripTags = text => {
38
+ if (text) {
39
+ return text.replace(/(<([^>]+)>)/gi, '')
40
+ }
41
+ return false
42
+ }
43
+
44
+ const getViewportWidth = () =>
45
+ Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
46
+
47
+ const isString = value => Object.prototype.toString.call(value) === '[object String]'
48
+
49
+ const isElementInViewport = el => {
50
+ const rect = el.getBoundingClientRect()
51
+ return rect.top <= (document.documentElement || document.body).clientHeight
52
+ }
53
+
54
+ const getClosestParentWithTag = (tagName, node) => {
55
+ while (node !== null && node.tagName !== 'BODY') {
56
+ if (node.tagName && node.tagName.toLowerCase() === tagName) {
57
+ return node
58
+ }
59
+ node = node.parentNode
60
+ }
61
+ return false
62
+ }
63
+
64
+ const getNodeWithClassInPath = (className, startNode) => {
65
+ let node = startNode
66
+
67
+ while (node && node !== document) {
68
+ if (node.classList.contains(className)) {
69
+ return node
70
+ }
71
+ node = node.parentNode
72
+ }
73
+ return false
74
+ }
75
+
76
+ const isDescendant = (parent, child) => {
77
+ let node = child.parentNode
78
+ while (node !== null) {
79
+ if (node === parent) {
80
+ return true
81
+ }
82
+ node = node.parentNode
83
+ }
84
+ return false
85
+ }
86
+
87
+ /* wartet x ms seit dem letzen aufruf bis es ausgeführt wird */
88
+ const debounce = (fn, delay) => {
89
+ let timer = null
90
+ return (...args) => {
91
+ const context = this
92
+ clearTimeout(timer)
93
+ timer = setTimeout(() => {
94
+ fn.apply(context, args)
95
+ }, delay)
96
+ }
97
+ }
98
+ /* feuert all x ms */
99
+ const throttle = (fn, threshhold, scope) => {
100
+ threshhold = threshhold || 250
101
+ let last
102
+ let deferTimer
103
+ return (...args) => {
104
+ const context = scope || this
105
+
106
+ const now = +new Date()
107
+ if (last && now < last + threshhold) {
108
+ // hold on to it
109
+ clearTimeout(deferTimer)
110
+ deferTimer = setTimeout(() => {
111
+ last = now
112
+ fn.apply(context, args)
113
+ }, threshhold)
114
+ } else {
115
+ last = now
116
+ fn.apply(context, args)
117
+ }
118
+ }
119
+ }
120
+
121
+ /* Once, führt eine Funktion genau einmal aus, egal wie oft sie aufgerufen wird
122
+ * Usage
123
+ var canOnlyFireOnce = hr$.once(function() {
124
+ console.log('Fired!');
125
+ });
126
+
127
+ canOnlyFireOnce(); // "Fired!"
128
+ canOnlyFireOnce(); // nada
129
+ *
130
+ */
131
+ const once = (fn, context) => {
132
+ let result
133
+
134
+ return (...args) => {
135
+ if (fn) {
136
+ result = fn.apply(context || this, args)
137
+ fn = null
138
+ }
139
+
140
+ return result
141
+ }
142
+ }
143
+
144
+ const listen = (eventName, fn, documentNode) => {
145
+ documentNode = documentNode === undefined ? document : documentNode
146
+
147
+ if (window.attachEvent) {
148
+ documentNode.attachEvent(eventName, fn)
149
+ } else {
150
+ documentNode.addEventListener(eventName, fn)
151
+ }
152
+ }
153
+ const unlisten = (eventName, fn, documentNode) => {
154
+ documentNode = documentNode === undefined ? document : documentNode
155
+
156
+ if (window.attachEvent) {
157
+ documentNode.detachEvent(eventName, fn)
158
+ } else {
159
+ documentNode.removeEventListener(eventName, fn)
160
+ }
161
+ }
162
+ const listenOnce = (eventName, fn, documentNode) => {
163
+ documentNode = documentNode === undefined ? document : documentNode
164
+
165
+ documentNode.addEventListener(eventName, fn, { once: true })
166
+ }
167
+
168
+ const fireEvent = (event_name, data, handleIframe) => {
169
+ const event = document.createEvent('CustomEvent')
170
+
171
+ event.initCustomEvent(event_name, true, true, data)
172
+
173
+ document.dispatchEvent(event)
174
+
175
+ if (handleIframe) {
176
+ if (hr$('#js-iFrame')[0]) {
177
+ hr$('#js-iFrame')[0].contentWindow.document.dispatchEvent(event)
178
+ }
179
+ if (inIframe()) {
180
+ parent.document.dispatchEvent(event)
181
+ }
182
+ }
183
+ }
184
+
185
+ const inIframe = () => {
186
+ try {
187
+ return window.self !== window.top
188
+ } catch (e) {
189
+ return true
190
+ }
191
+ }
192
+
193
+ const setJSONCookie = (cookieName, cookieValue, cookieLifetime) => {
194
+ setCookie(cookieName, JSON.stringify(cookieValue), cookieLifetime)
195
+ }
196
+
197
+ const setCookie = (cookieName, cookieValue, cookieLifetime) => {
198
+ let expires
199
+
200
+ const domain = getDomain()
201
+
202
+ if (cookieLifetime) {
203
+ expires = new Date()
204
+ expires.setMilliseconds(expires.getMilliseconds() + cookieLifetime)
205
+ expires = expires.toUTCString()
206
+ } else {
207
+ expires = ''
208
+ }
209
+
210
+ document.cookie =
211
+ cookieName + '=' + cookieValue + ';expires=' + expires + ';domain=' + domain + ';path=/;'
212
+ }
213
+
214
+ const getJSONCookie = cookieName => {
215
+ let cookie
216
+
217
+ try {
218
+ cookie = JSON.parse(getCookie(cookieName))
219
+ } catch (e) {}
220
+
221
+ return cookie
222
+ }
223
+
224
+ const getCookie = cookieName => {
225
+ let cookieString = RegExp('' + cookieName + '[^;]+').exec(document.cookie)
226
+ return unescape(!!cookieString ? cookieString.toString().replace(/^[^=]+./, '') : '')
227
+ }
228
+
229
+ const deleteCookie = cookieName => {
230
+ const domain = getDomain()
231
+ document.cookie =
232
+ cookieName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=' + domain + ';path=/;'
233
+ }
234
+
235
+ const getDomain = () => {
236
+ return window.location.hostname.substring(window.location.hostname.indexOf('.') + 1)
237
+ }
238
+ const requestTimeout = (fn, delay) => {
239
+ var requestAnimFrame = (function() {
240
+ return (
241
+ window.requestAnimationFrame ||
242
+ function(callback, element) {
243
+ window.setTimeout(callback, 1000 / 60)
244
+ }
245
+ )
246
+ })(),
247
+ start = new Date().getTime(),
248
+ handle = {}
249
+ function loop() {
250
+ var current = new Date().getTime(),
251
+ delta = current - start
252
+ if (delta >= delay) {
253
+ fn.call()
254
+ } else {
255
+ handle.value = requestAnimFrame(loop)
256
+ }
257
+ }
258
+ handle.value = requestAnimFrame(loop)
259
+ return handle
260
+ }
261
+
262
+ const replaceAnimated = (
263
+ elem,
264
+ data,
265
+ rescan,
266
+ callback,
267
+ timeoutDelay,
268
+ valueFrom,
269
+ valueTo,
270
+ easing,
271
+ duration
272
+ ) => {
273
+ const property = 'opacity'
274
+ timeoutDelay = timeoutDelay || 800
275
+ valueFrom = valueFrom || 0.2
276
+ valueTo = valueTo || 1.0
277
+ easing = easing || 'ease-in-out'
278
+ duration = duration || '0.8s'
279
+
280
+ elem.style.WebkitTransition = property + ' ' + duration + ' ' + easing
281
+ elem.style.MozTransition = property + ' ' + duration + ' ' + easing
282
+ elem.style.transition = property + ' ' + duration + ' ' + easing
283
+
284
+ elem.style[property] = valueFrom
285
+
286
+ requestTimeout(function() {
287
+ if (data) {
288
+ elem.innerHTML = data
289
+ }
290
+ elem.style[property] = valueTo
291
+
292
+ if (rescan) {
293
+ Initializer.run(elem, loadFeature)
294
+ hrScriptLoad.rescanForModulesAndVariants(elem)
295
+ }
296
+
297
+ if (callback) {
298
+ callback()
299
+ }
300
+ }, timeoutDelay)
301
+ }
302
+
303
+ hr$.loadScript = function(id, scriptUrl, async, callback) {
304
+ if (document.getElementById(id)) return
305
+
306
+ var firstScriptTagInPage = hr$('script')[0],
307
+ scriptTag = document.createElement('script')
308
+
309
+ scriptTag.id = id
310
+ scriptTag.src = scriptUrl
311
+
312
+ if (async) {
313
+ scriptTag.setAttribute('async', !!async)
314
+ }
315
+
316
+ if (callback) {
317
+ scriptTag.addEventListener(
318
+ 'load',
319
+ function(e) {
320
+ callback(null, e)
321
+ },
322
+ false
323
+ )
324
+ }
325
+
326
+ firstScriptTagInPage.parentNode.insertBefore(scriptTag, firstScriptTagInPage)
327
+ }
328
+
329
+ const loadScript = (id, scriptUrl, async, callback) => {
330
+ if (document.getElementById(id)) return
331
+
332
+ let firstScriptTagInPage = hr$('script')[0],
333
+ scriptTag = document.createElement('script')
334
+
335
+ scriptTag.id = id
336
+ scriptTag.src = scriptUrl
337
+
338
+ if (async) {
339
+ scriptTag.setAttribute('async', !!async)
340
+ }
341
+
342
+ if (callback) {
343
+ scriptTag.addEventListener(
344
+ 'load',
345
+ function(e) {
346
+ callback(null, e)
347
+ },
348
+ false
349
+ )
350
+ }
351
+
352
+ firstScriptTagInPage.parentNode.insertBefore(scriptTag, firstScriptTagInPage)
353
+ }
354
+
355
+ export {
356
+ hr$,
357
+ stripTags,
358
+ getViewportWidth,
359
+ isString,
360
+ isElementInViewport,
361
+ getClosestParentWithTag,
362
+ getNodeWithClassInPath,
363
+ isDescendant,
364
+ debounce,
365
+ throttle,
366
+ once,
367
+ listen,
368
+ unlisten,
369
+ listenOnce,
370
+ fireEvent,
371
+ inIframe,
372
+ setCookie,
373
+ setJSONCookie,
374
+ getJSONCookie,
375
+ getCookie,
376
+ deleteCookie,
377
+ requestTimeout,
378
+ replaceAnimated,
379
+ loadScript
380
+ }
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": "0.51.0",
9
+ "version": "0.51.1",
10
10
  "scripts": {
11
11
  "test": "echo \"Error: no test specified\" && exit 1",
12
12
  "storybook": "start-storybook -p 6006 public",