@brandocms/jupiter 3.47.0 → 3.48.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.
Files changed (37) hide show
  1. package/package.json +9 -9
  2. package/src/events/index.js +1 -0
  3. package/src/index.js +5 -7
  4. package/src/modules/Application/index.js +110 -77
  5. package/src/modules/Breakpoints/index.js +14 -17
  6. package/src/modules/Cookies/index.js +86 -43
  7. package/src/modules/CoverOverlay/index.js +6 -3
  8. package/src/modules/Dataloader/index.js +173 -7
  9. package/src/modules/Dom/index.js +26 -26
  10. package/src/modules/Dropdown/index.js +14 -14
  11. package/src/modules/EqualHeightElements/index.js +70 -0
  12. package/src/modules/EqualHeightImages/index.js +17 -18
  13. package/src/modules/FeatureTests/index.js +22 -15
  14. package/src/modules/FixedHeader/index.js +79 -75
  15. package/src/modules/Fontloader/index.js +5 -3
  16. package/src/modules/FooterReveal/index.js +1 -1
  17. package/src/modules/HeroSlider/index.js +33 -23
  18. package/src/modules/HeroVideo/index.js +15 -13
  19. package/src/modules/Lazyload/index.js +119 -65
  20. package/src/modules/Lightbox/index.js +40 -43
  21. package/src/modules/Links/index.js +8 -7
  22. package/src/modules/Marquee/index.js +40 -34
  23. package/src/modules/MobileMenu/index.js +112 -65
  24. package/src/modules/Moonwalk/index.js +256 -203
  25. package/src/modules/Parallax/index.js +24 -14
  26. package/src/modules/Popup/index.js +24 -21
  27. package/src/modules/ScrollSpy/index.js +5 -5
  28. package/src/modules/StackedBoxes/index.js +5 -5
  29. package/src/modules/StickyHeader/index.js +73 -70
  30. package/src/modules/Toggler/index.js +2 -2
  31. package/src/modules/Typography/index.js +13 -10
  32. package/src/utils/dispatchElementEvent.js +2 -2
  33. package/src/utils/imageIsLoaded.js +1 -1
  34. package/src/utils/imagesAreLoaded.js +3 -3
  35. package/src/utils/loadScript.js +9 -8
  36. package/src/utils/rafCallback.js +12 -10
  37. package/src/utils/zoom.js +11 -8
@@ -10,7 +10,7 @@ const DEFAULT_OPTIONS = {
10
10
  }
11
11
 
12
12
  export default class Parallax {
13
- constructor (app, opts = {}) {
13
+ constructor(app, opts = {}) {
14
14
  this.app = app
15
15
  this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
16
16
  this.elements = {}
@@ -28,40 +28,50 @@ export default class Parallax {
28
28
  window.addEventListener(Events.APPLICATION_SCROLL, this.onScroll.bind(this))
29
29
  }
30
30
 
31
- initializeTimeline () {
31
+ initializeTimeline() {
32
32
  this.timeline = gsap.timeline({
33
33
  useFrames: true,
34
34
  paused: true
35
35
  })
36
36
 
37
37
  if (this.opts.fadeContent) {
38
- this.timeline
39
- .to(this.elements.content, {
38
+ this.timeline.to(
39
+ this.elements.content,
40
+ {
40
41
  duration: this.app.size.height * 0.4,
41
42
  opacity: 0,
42
43
  ease: 'power0.none'
43
- }, 0)
44
+ },
45
+ 0
46
+ )
44
47
  }
45
48
 
46
- this.timeline
47
- .to(this.elements.content, {
49
+ this.timeline.to(
50
+ this.elements.content,
51
+ {
48
52
  duration: this.app.size.height * 0.5,
49
53
  y: this.app.size.height * 0.1,
50
54
  ease: 'power0.none'
51
- }, 0)
55
+ },
56
+ 0
57
+ )
52
58
 
53
- this.timeline
54
- .fromTo(this.elements.figure, {
59
+ this.timeline.fromTo(
60
+ this.elements.figure,
61
+ {
55
62
  duration: this.app.size.height,
56
63
  yPercent: 0
57
- }, {
64
+ },
65
+ {
58
66
  duration: this.app.size.height,
59
- yPercent: ((this.app.size.height * this.opts.factor) / 100),
67
+ yPercent: (this.app.size.height * this.opts.factor) / 100,
60
68
  ease: 'power0.none'
61
- }, 0)
69
+ },
70
+ 0
71
+ )
62
72
  }
63
73
 
64
- onScroll () {
74
+ onScroll() {
65
75
  const elTop = this.elements.wrapper.getBoundingClientRect().top
66
76
  const progress = Math.max(0, Math.min(elTop / this.timeline.duration(), 1))
67
77
  this.timeline.progress(progress)
@@ -2,7 +2,6 @@ import { gsap } from 'gsap'
2
2
  import _defaultsDeep from 'lodash.defaultsdeep'
3
3
 
4
4
  const DEFAULT_OPTIONS = {
5
-
6
5
  /**
7
6
  * responsive
8
7
  *
@@ -23,20 +22,24 @@ const DEFAULT_OPTIONS = {
23
22
  duration: 0.3,
24
23
  opacity: 1,
25
24
  onComplete: () => {
26
- gsap.fromTo(target, {
27
- duration: 0.3,
28
- yPercent: -50,
29
- x: -5,
30
- xPercent: -50,
31
- opacity: 0,
32
- display: 'block'
33
- }, {
34
- duration: 0.3,
35
- yPercent: -50,
36
- xPercent: -50,
37
- x: 0,
38
- opacity: 1
39
- })
25
+ gsap.fromTo(
26
+ target,
27
+ {
28
+ duration: 0.3,
29
+ yPercent: -50,
30
+ x: -5,
31
+ xPercent: -50,
32
+ opacity: 0,
33
+ display: 'block'
34
+ },
35
+ {
36
+ duration: 0.3,
37
+ yPercent: -50,
38
+ xPercent: -50,
39
+ x: 0,
40
+ opacity: 1
41
+ }
42
+ )
40
43
  }
41
44
  })
42
45
  },
@@ -59,14 +62,14 @@ const DEFAULT_OPTIONS = {
59
62
  }
60
63
 
61
64
  export default class Popup {
62
- constructor (app, opts = {}) {
65
+ constructor(app, opts = {}) {
63
66
  this.app = app
64
67
  this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
65
68
  this.createBackdrop()
66
69
  this.bindTriggers()
67
70
  }
68
71
 
69
- bindTriggers () {
72
+ bindTriggers() {
70
73
  const triggers = document.querySelectorAll('[data-popup-trigger]')
71
74
  const closers = document.querySelectorAll('[data-popup-close]')
72
75
 
@@ -91,7 +94,7 @@ export default class Popup {
91
94
  })
92
95
  }
93
96
 
94
- createBackdrop () {
97
+ createBackdrop() {
95
98
  const backdrop = document.createElement('div')
96
99
  backdrop.setAttribute('data-popup-backdrop', '')
97
100
  gsap.set(backdrop, { opacity: 0, display: 'none', zIndex: 4999 })
@@ -105,7 +108,7 @@ export default class Popup {
105
108
  this.backdrop = backdrop
106
109
  }
107
110
 
108
- open (trigger, target) {
111
+ open(trigger, target) {
109
112
  this.keyUpListener = this.onKeyup.bind(this)
110
113
  document.addEventListener('keyup', this.keyUpListener)
111
114
  if (typeof target === 'string') {
@@ -119,13 +122,13 @@ export default class Popup {
119
122
  this.opts.tweenIn(trigger, target, this)
120
123
  }
121
124
 
122
- close () {
125
+ close() {
123
126
  document.removeEventListener('keyup', this.keyUpListener)
124
127
  this.opts.onClose(this)
125
128
  this.opts.tweenOut(this)
126
129
  }
127
130
 
128
- onKeyup (e) {
131
+ onKeyup(e) {
129
132
  const key = e.keyCode || e.which
130
133
 
131
134
  switch (key) {
@@ -4,30 +4,30 @@ import Dom from '../Dom'
4
4
  const DEFAULT_OPTIONS = {}
5
5
 
6
6
  export default class ScrollSpy {
7
- constructor (app, opts = {}) {
7
+ constructor(app, opts = {}) {
8
8
  this.app = app
9
9
  this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
10
10
  this.initialize()
11
11
  }
12
12
 
13
- initialize () {
13
+ initialize() {
14
14
  this.triggers = Dom.all('[data-scrollspy-trigger]')
15
15
  const config = {
16
16
  rootMargin: '-55px 0px -85%'
17
17
  }
18
18
 
19
- const observer = new IntersectionObserver((entries => {
19
+ const observer = new IntersectionObserver(entries => {
20
20
  entries.forEach(entry => {
21
21
  if (entry.isIntersecting) {
22
22
  this.intersectionHandler(entry)
23
23
  }
24
24
  })
25
- }), config)
25
+ }, config)
26
26
 
27
27
  this.triggers.forEach(section => observer.observe(section))
28
28
  }
29
29
 
30
- intersectionHandler (entry) {
30
+ intersectionHandler(entry) {
31
31
  const id = entry.target.dataset.scrollspyTrigger
32
32
  const currentlyActive = document.querySelector('[data-scrollspy-active]')
33
33
  const shouldBeActive = document.querySelector(`[data-scrollspy-target="${id}"]`)
@@ -4,13 +4,13 @@ import _defaultsDeep from 'lodash.defaultsdeep'
4
4
  const DEFAULT_OPTIONS = {}
5
5
 
6
6
  export default class StackedBoxes {
7
- constructor (app, opts = {}) {
7
+ constructor(app, opts = {}) {
8
8
  this.app = app
9
9
  this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
10
10
  this.initialize()
11
11
  }
12
12
 
13
- initialize () {
13
+ initialize() {
14
14
  const boxes = document.querySelectorAll('[data-boxes-stacked]')
15
15
 
16
16
  const observer = new IntersectionObserver(entries => {
@@ -25,7 +25,7 @@ export default class StackedBoxes {
25
25
  })
26
26
  }
27
27
 
28
- adjustBox (box) {
28
+ adjustBox(box) {
29
29
  const sizeTarget = box.querySelector('[data-boxes-stacked-size-target]')
30
30
  const sizeSrc = box.querySelector('[data-boxes-stacked-size-src]')
31
31
 
@@ -59,11 +59,11 @@ export default class StackedBoxes {
59
59
  }
60
60
  }
61
61
 
62
- pull (box, amnt) {
62
+ pull(box, amnt) {
63
63
  gsap.set(box, { y: amnt * -1, marginBottom: amnt * -1 })
64
64
  }
65
65
 
66
- size (target, src) {
66
+ size(target, src) {
67
67
  gsap.set(target, { height: src.clientHeight })
68
68
  }
69
69
  }
@@ -85,7 +85,10 @@ const DEFAULT_OPTIONS = {
85
85
  .set(h.auxEl, { yPercent: -100 })
86
86
  .set(h.lis, { opacity: 0 })
87
87
  .to(h.auxEl, 1, {
88
- yPercent: 0, delay: h.opts.enterDelay, ease: 'power3.out', autoRound: true
88
+ yPercent: 0,
89
+ delay: h.opts.enterDelay,
90
+ ease: 'power3.out',
91
+ autoRound: true
89
92
  })
90
93
  .staggerTo(h.lis, 0.8, { opacity: 1, ease: 'sine.in' }, 0.1, '-=1')
91
94
  },
@@ -99,7 +102,7 @@ const DEFAULT_OPTIONS = {
99
102
  }
100
103
 
101
104
  export default class StickyHeader {
102
- constructor (app, opts = {}) {
105
+ constructor(app, opts = {}) {
103
106
  this.app = app
104
107
  this.mainOpts = _defaultsDeep(opts, DEFAULT_OPTIONS)
105
108
 
@@ -120,7 +123,6 @@ export default class StickyHeader {
120
123
  return
121
124
  }
122
125
 
123
-
124
126
  const section = document.body.getAttribute('data-script')
125
127
  this.opts = this._getOptionsForSection(section, opts)
126
128
 
@@ -154,7 +156,7 @@ export default class StickyHeader {
154
156
  this.initialize()
155
157
  }
156
158
 
157
- initialize () {
159
+ initialize() {
158
160
  // bind to canvas scroll
159
161
  this.lastKnownScrollY = this.getScrollY()
160
162
  this.currentScrollY = this.lastKnownScrollY
@@ -177,11 +179,9 @@ export default class StickyHeader {
177
179
  this.opts.beforeEnter(this)
178
180
  }
179
181
 
180
- setupObserver () {
182
+ setupObserver() {
181
183
  this.observer = new IntersectionObserver(entries => {
182
- const [{
183
- isIntersecting
184
- }] = entries
184
+ const [{ isIntersecting }] = entries
185
185
 
186
186
  if (isIntersecting) {
187
187
  if (this._navVisible !== true) {
@@ -207,19 +207,23 @@ export default class StickyHeader {
207
207
  this.unpin()
208
208
  this.preventPin = true
209
209
  })
210
- window.addEventListener(Events.APPLICATION_FORCED_SCROLL_END, () => {
211
- this.preventPin = false
212
- this.pin()
213
- this.preventUnpin = false
214
- }, false)
210
+ window.addEventListener(
211
+ Events.APPLICATION_FORCED_SCROLL_END,
212
+ () => {
213
+ this.preventPin = false
214
+ this.pin()
215
+ this.preventUnpin = false
216
+ },
217
+ false
218
+ )
215
219
  }
216
220
  }
217
221
 
218
- bindObserver () {
222
+ bindObserver() {
219
223
  this.observer.observe(this.el)
220
224
  }
221
225
 
222
- setResizeTimer () {
226
+ setResizeTimer() {
223
227
  this._isResizing = true
224
228
  if (this._pinned) {
225
229
  // unpin if resizing to prevent visual clutter
@@ -236,29 +240,29 @@ export default class StickyHeader {
236
240
  }, 500)
237
241
  }
238
242
 
239
- _hideAlt () {
243
+ _hideAlt() {
240
244
  this.unpin()
241
245
  }
242
246
 
243
- _showAlt () {
247
+ _showAlt() {
244
248
  this.pin()
245
249
  }
246
250
 
247
- update () {
251
+ update() {
248
252
  this.redraw(false)
249
253
  }
250
254
 
251
- lock () {
255
+ lock() {
252
256
  this.preventPin = true
253
257
  this.preventUnpin = true
254
258
  }
255
259
 
256
- unlock () {
260
+ unlock() {
257
261
  this.preventPin = false
258
262
  this.preventUnpin = false
259
263
  }
260
264
 
261
- checkSize (force) {
265
+ checkSize(force) {
262
266
  if (this.currentScrollY > this.opts.offsetSmall) {
263
267
  if (force) {
264
268
  this.small()
@@ -272,7 +276,7 @@ export default class StickyHeader {
272
276
  }
273
277
  }
274
278
 
275
- checkTop (force) {
279
+ checkTop(force) {
276
280
  if (this.currentScrollY <= this.opts.offset) {
277
281
  if (force) {
278
282
  this.top()
@@ -286,7 +290,7 @@ export default class StickyHeader {
286
290
  }
287
291
  }
288
292
 
289
- checkBot (force) {
293
+ checkBot(force) {
290
294
  if (this.currentScrollY + this.getViewportHeight() >= this.getScrollerHeight()) {
291
295
  if (force) {
292
296
  this.bottom()
@@ -300,7 +304,7 @@ export default class StickyHeader {
300
304
  }
301
305
  }
302
306
 
303
- checkPin (force, toleranceExceeded) {
307
+ checkPin(force, toleranceExceeded) {
304
308
  if (this._navVisible) {
305
309
  if (this._pinned) {
306
310
  this.unpin()
@@ -322,11 +326,12 @@ export default class StickyHeader {
322
326
  }
323
327
  }
324
328
 
325
- redraw (force = false) {
329
+ redraw(force = false) {
326
330
  this.currentScrollY = this.getScrollY()
327
331
  const toleranceExceeded = this.toleranceExceeded()
328
332
 
329
- if (this.isOutOfBounds()) { // Ignore bouncy scrolling in OSX
333
+ if (this.isOutOfBounds()) {
334
+ // Ignore bouncy scrolling in OSX
330
335
  return
331
336
  }
332
337
 
@@ -335,42 +340,42 @@ export default class StickyHeader {
335
340
  this._firstLoad = false
336
341
  }
337
342
 
338
- notTop () {
343
+ notTop() {
339
344
  this._top = false
340
345
  this.el.removeAttribute('data-header-top')
341
346
  this.el.setAttribute('data-header-not-top', '')
342
347
  this.opts.onNotTop(this)
343
348
  }
344
349
 
345
- top () {
350
+ top() {
346
351
  this._top = true
347
352
  this.el.setAttribute('data-header-top', '')
348
353
  this.el.removeAttribute('data-header-not-top')
349
354
  this.opts.onTop(this)
350
355
  }
351
356
 
352
- notBottom () {
357
+ notBottom() {
353
358
  this._bottom = false
354
359
  this.el.setAttribute('data-header-not-bottom', '')
355
360
  this.el.removeAttribute('data-header-bottom')
356
361
  this.opts.onNotBottom(this)
357
362
  }
358
363
 
359
- bottom () {
364
+ bottom() {
360
365
  this._bottom = true
361
366
  this.el.setAttribute('data-header-bottom', '')
362
367
  this.el.removeAttribute('data-header-not-bottom')
363
368
  this.opts.onBottom(this)
364
369
  }
365
370
 
366
- unpin () {
371
+ unpin() {
367
372
  if (!this.preventUnpin) {
368
373
  this._pinned = false
369
374
  this.opts.onUnpin(this)
370
375
  }
371
376
  }
372
377
 
373
- pin () {
378
+ pin() {
374
379
  if (!this.preventPin) {
375
380
  this._pinned = true
376
381
  this.opts.onSmall(this)
@@ -378,21 +383,21 @@ export default class StickyHeader {
378
383
  }
379
384
  }
380
385
 
381
- notSmall () {
386
+ notSmall() {
382
387
  this._small = false
383
388
  this.auxEl.setAttribute('data-header-big', '')
384
389
  this.auxEl.removeAttribute('data-header-small')
385
390
  this.opts.onNotSmall(this)
386
391
  }
387
392
 
388
- small () {
393
+ small() {
389
394
  this._small = true
390
395
  this.auxEl.setAttribute('data-header-small', '')
391
396
  this.auxEl.removeAttribute('data-header-big')
392
397
  this.opts.onSmall(this)
393
398
  }
394
399
 
395
- shouldUnpin (toleranceExceeded) {
400
+ shouldUnpin(toleranceExceeded) {
396
401
  if (this._navVisible) {
397
402
  return true
398
403
  }
@@ -402,7 +407,7 @@ export default class StickyHeader {
402
407
  return scrollingDown && pastOffset && toleranceExceeded
403
408
  }
404
409
 
405
- shouldPin (toleranceExceeded) {
410
+ shouldPin(toleranceExceeded) {
406
411
  if (this._isResizing) {
407
412
  return false
408
413
  }
@@ -411,60 +416,55 @@ export default class StickyHeader {
411
416
  return (scrollingUp && toleranceExceeded) || pastOffset
412
417
  }
413
418
 
414
- isOutOfBounds () {
419
+ isOutOfBounds() {
415
420
  const pastTop = this.currentScrollY < 0
416
- const pastBottom = this.currentScrollY
417
- + this.getScrollerPhysicalHeight()
418
- > this.getScrollerHeight()
421
+ const pastBottom =
422
+ this.currentScrollY + this.getScrollerPhysicalHeight() > this.getScrollerHeight()
419
423
 
420
424
  return pastTop || pastBottom
421
425
  }
422
426
 
423
- getScrollerPhysicalHeight () {
424
- return (this.opts.canvas === window || this.opts.canvas === document.body)
427
+ getScrollerPhysicalHeight() {
428
+ return this.opts.canvas === window || this.opts.canvas === document.body
425
429
  ? this.getViewportHeight()
426
430
  : this.getElementPhysicalHeight(this.opts.canvas)
427
431
  }
428
432
 
429
- getScrollerHeight () {
430
- return (this.opts.canvas === window || this.opts.canvas === document.body)
433
+ getScrollerHeight() {
434
+ return this.opts.canvas === window || this.opts.canvas === document.body
431
435
  ? this.getDocumentHeight()
432
436
  : this.getElementHeight(this.opts.canvas)
433
437
  }
434
438
 
435
- getDocumentHeight () {
439
+ getDocumentHeight() {
436
440
  const { body } = document
437
441
  const { documentElement } = document
438
442
 
439
443
  return Math.max(
440
- body.scrollHeight, documentElement.scrollHeight,
441
- body.offsetHeight, documentElement.offsetHeight,
442
- body.clientHeight, documentElement.clientHeight
444
+ body.scrollHeight,
445
+ documentElement.scrollHeight,
446
+ body.offsetHeight,
447
+ documentElement.offsetHeight,
448
+ body.clientHeight,
449
+ documentElement.clientHeight
443
450
  )
444
451
  }
445
452
 
446
- getViewportHeight () {
447
- return window.innerHeight
448
- || document.documentElement.clientHeight
449
- || document.body.clientHeight
453
+ getViewportHeight() {
454
+ return (
455
+ window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
456
+ )
450
457
  }
451
458
 
452
- getElementHeight (el) {
453
- return Math.max(
454
- el.scrollHeight,
455
- el.offsetHeight,
456
- el.clientHeight
457
- )
459
+ getElementHeight(el) {
460
+ return Math.max(el.scrollHeight, el.offsetHeight, el.clientHeight)
458
461
  }
459
462
 
460
- getElementPhysicalHeight (el) {
461
- return Math.max(
462
- el.offsetHeight,
463
- el.clientHeight
464
- )
463
+ getElementPhysicalHeight(el) {
464
+ return Math.max(el.offsetHeight, el.clientHeight)
465
465
  }
466
466
 
467
- getScrollY () {
467
+ getScrollY() {
468
468
  if (this.opts.canvas.pageYOffset !== undefined) {
469
469
  return this.opts.canvas.pageYOffset
470
470
  }
@@ -474,13 +474,16 @@ export default class StickyHeader {
474
474
  return (document.documentElement || document.body.parentNode || document.body).scrollTop
475
475
  }
476
476
 
477
- toleranceExceeded () {
477
+ toleranceExceeded() {
478
478
  return Math.abs(this.currentScrollY - this.lastKnownScrollY) >= this.opts.tolerance
479
479
  }
480
480
 
481
- _getOptionsForSection (section, opts) {
481
+ _getOptionsForSection(section, opts) {
482
482
  // if section is not a key in opts, return default opts
483
- if (!Object.prototype.hasOwnProperty.call(opts, 'sections') || !Object.prototype.hasOwnProperty.call(opts.sections, section)) {
483
+ if (
484
+ !Object.prototype.hasOwnProperty.call(opts, 'sections') ||
485
+ !Object.prototype.hasOwnProperty.call(opts.sections, section)
486
+ ) {
484
487
  return opts.default
485
488
  }
486
489
 
@@ -490,7 +493,7 @@ export default class StickyHeader {
490
493
  return opts
491
494
  }
492
495
 
493
- _bindMobileMenuListeners () {
496
+ _bindMobileMenuListeners() {
494
497
  window.addEventListener(
495
498
  Events.APPLICATION_MOBILE_MENU_OPEN,
496
499
  this._onMobileMenuOpen.bind(this)
@@ -501,11 +504,11 @@ export default class StickyHeader {
501
504
  )
502
505
  }
503
506
 
504
- _onMobileMenuOpen () {
507
+ _onMobileMenuOpen() {
505
508
  this.mobileMenuOpen = true
506
509
  }
507
510
 
508
- _onMobileMenuClose () {
511
+ _onMobileMenuClose() {
509
512
  this.mobileMenuOpen = false
510
513
  }
511
514
  }
@@ -2,7 +2,7 @@ import { gsap } from 'gsap'
2
2
  import Dom from '../Dom'
3
3
 
4
4
  const DEFAULT_OPTIONS = {}
5
-
5
+
6
6
  export default class Toggler {
7
7
  constructor(app, el) {
8
8
  this.open = false
@@ -43,4 +43,4 @@ export default class Toggler {
43
43
  this.open = true
44
44
  }
45
45
  }
46
- }
46
+ }
@@ -1,5 +1,5 @@
1
1
  export default class Typography {
2
- constructor (parent, settings = {}) {
2
+ constructor(parent, settings = {}) {
3
3
  const self = this
4
4
 
5
5
  // Set some settings, by merging defaults and passed settings
@@ -14,7 +14,7 @@ export default class Typography {
14
14
  self.elems = []
15
15
 
16
16
  // Either load from root or the passed parent element
17
- if (typeof (parent) === 'undefined') {
17
+ if (typeof parent === 'undefined') {
18
18
  self.elems = [...self.elems, ...document.querySelectorAll(self.settings.selector)]
19
19
  } else {
20
20
  self.elems = [...self.elems, ...parent.querySelectorAll(self.settings.selector)]
@@ -33,7 +33,7 @@ export default class Typography {
33
33
  * Apply formatting to the loaded elements
34
34
  * @return void
35
35
  */
36
- apply () {
36
+ apply() {
37
37
  const self = this
38
38
 
39
39
  self.elems.map(elem => {
@@ -46,7 +46,10 @@ export default class Typography {
46
46
  let result = ''
47
47
 
48
48
  // Split words/tags into array
49
- let textItems = elem.innerHTML.trim().replace(/&nbsp;/g, ' ').split(/ (?=[^>]*(?:<|$))/)
49
+ let textItems = elem.innerHTML
50
+ .trim()
51
+ .replace(/&nbsp;/g, ' ')
52
+ .split(/ (?=[^>]*(?:<|$))/)
50
53
 
51
54
  // Check if the text warrants this module
52
55
  if (textItems.length < self.settings.minWords) {
@@ -73,12 +76,12 @@ export default class Typography {
73
76
  * Apply the orphans filter to the passed text and return it
74
77
  * @param {string} textItems
75
78
  */
76
- preventOrphans (textItems) {
79
+ preventOrphans(textItems) {
77
80
  // Find the second to last work
78
- const targetWord = textItems[(textItems.length - 2)]
81
+ const targetWord = textItems[textItems.length - 2]
79
82
 
80
83
  // Stick a no break space to the end of the word and replace the instance in the array
81
- textItems[(textItems.length - 2)] = `${targetWord}&nbsp;`
84
+ textItems[textItems.length - 2] = `${targetWord}&nbsp;`
82
85
 
83
86
  return textItems
84
87
  }
@@ -87,7 +90,7 @@ export default class Typography {
87
90
  * Reset any formatting
88
91
  * @return void
89
92
  */
90
- reset () {
93
+ reset() {
91
94
  const self = this
92
95
 
93
96
  self.elems.map(elem => {
@@ -107,12 +110,12 @@ export default class Typography {
107
110
  * @param {HTMLElement} elem
108
111
  * @returns boolean
109
112
  */
110
- shouldElementBeIgnored (elem) {
113
+ shouldElementBeIgnored(elem) {
111
114
  const self = this
112
115
 
113
116
  // Check if the element already contains 1 or more &nbsp; characters and the
114
117
  // ignore setting is true. If so: bail.
115
- if ((elem.innerHTML.indexOf('&nbsp;') > -1) && self.settings.ignoreExistingSpaceChars) {
118
+ if (elem.innerHTML.indexOf('&nbsp;') > -1 && self.settings.ignoreExistingSpaceChars) {
116
119
  return true
117
120
  }
118
121