@penskemediacorp/larva-js 1.20.0 → 1.27.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.
Files changed (36) hide show
  1. package/build/video-showcase.js +1 -1
  2. package/package.json +2 -2
  3. package/src/__tests__/fixtures/markup.js +1 -1
  4. package/src/__tests__/utils/removeDesktopXlClasses.test.js +6 -4
  5. package/src/interface/Collapsible/Collapsible.js +31 -17
  6. package/src/interface/Collapsible/index.js +6 -2
  7. package/src/interface/EmailCapture/EmailCapture.js +17 -13
  8. package/src/interface/EmailCapture/index.js +6 -3
  9. package/src/interface/ExpandableSearch/ExpandableSearch.js +21 -21
  10. package/src/interface/ExpandableSearch/index.js +4 -4
  11. package/src/interface/Flickity/index.js +16 -11
  12. package/src/interface/MegaMenu/MegaMenu.js +22 -13
  13. package/src/interface/MegaMenu/index.js +12 -10
  14. package/src/interface/MobileHeightToggle/MobileHeightToggle.js +5 -4
  15. package/src/interface/MobileHeightToggle/MobileHeightToggle.test.js +22 -21
  16. package/src/interface/MobileHeightToggle/index.js +9 -8
  17. package/src/interface/Navigable/Navigable.js +29 -18
  18. package/src/interface/Navigable/index.js +1 -1
  19. package/src/interface/PopOver/PopOver.js +15 -15
  20. package/src/interface/PopOver/index.js +4 -4
  21. package/src/interface/ProfileFilter/ProfileFilter.js +40 -35
  22. package/src/interface/ProfileFilter/__test__/ProfileFilter.test.js +38 -31
  23. package/src/interface/ProfileFilter/index.js +2 -2
  24. package/src/interface/SelectNav/SelectNav.js +8 -6
  25. package/src/interface/SelectNav/index.js +2 -3
  26. package/src/interface/SideSkinAd/SideSkinAd.js +0 -2
  27. package/src/interface/SideSkinAd/index.js +10 -10
  28. package/src/interface/TabsManager/TabsManager.js +11 -6
  29. package/src/interface/TabsManager/index.js +1 -1
  30. package/src/interface/Tooltip/Tooltip.js +0 -1
  31. package/src/interface/VideoShowcase/VideoShowcase.js +77 -49
  32. package/src/interface/VideoShowcase/index.js +6 -2
  33. package/src/utils/ajaxIconSprite.js +4 -4
  34. package/src/utils/dom.js +6 -3
  35. package/src/utils/removeDesktopXlClasses.js +5 -7
  36. package/src/utils/webfontConfig.js +26 -40
@@ -6,34 +6,37 @@ import initMobileHeightToggles from './index';
6
6
  const TABLET = 768;
7
7
 
8
8
  describe( 'MobileHeightToggle', () => {
9
-
10
- it('starts with an initially closed state', () => {
11
- const dropdown = new MobileHeightToggle( document.querySelector( '.test' ) );
9
+ it( 'starts with an initially closed state', () => {
10
+ const dropdown = new MobileHeightToggle(
11
+ document.querySelector( '.test' )
12
+ );
12
13
  assert.equal( dropdown.isExpanded, false );
13
- });
14
+ } );
14
15
 
15
16
  it( 'adds the class is expanded when trigger is clicked', () => {
16
-
17
- document.querySelector('.test').innerHTML = `
17
+ document.querySelector( '.test' ).innerHTML = `
18
18
  <div class="lrv-js-MobileHeightToggle">
19
19
  <div class="lrv-js-MobileHeightToggle-trigger"></div>
20
20
  <div class="lrv-js-MobileHeightToggle-target"></div>
21
21
  </div>
22
22
  `;
23
23
 
24
- const dropdown = new MobileHeightToggle( document.querySelector( '.lrv-js-MobileHeightToggle' ) );
24
+ const dropdown = new MobileHeightToggle(
25
+ document.querySelector( '.lrv-js-MobileHeightToggle' )
26
+ );
25
27
 
26
- dropdown.toggle({
27
- preventDefault: () => {},
28
- target: document.querySelector( '.lrv-js-MobileHeightToggle-trigger' )
29
- });
28
+ dropdown.toggle( {
29
+ preventDefault: () => {},
30
+ target: document.querySelector(
31
+ '.lrv-js-MobileHeightToggle-trigger'
32
+ ),
33
+ } );
30
34
 
31
35
  assert.equal( dropdown.el.classList.contains( 'is-expanded' ), true );
32
- });
36
+ } );
33
37
 
34
38
  it( 'does not initialize MobileHeightToggles on tablet', () => {
35
-
36
- document.querySelector('.test').innerHTML = `
39
+ document.querySelector( '.test' ).innerHTML = `
37
40
  <div class="lrv-js-MobileHeightToggle">
38
41
  <div class="lrv-js-MobileHeightToggle-trigger"></div>
39
42
  <div class="lrv-js-MobileHeightToggle-target"></div>
@@ -43,13 +46,12 @@ describe( 'MobileHeightToggle', () => {
43
46
  initMobileHeightToggles( TABLET + 1 );
44
47
 
45
48
  const el = document.querySelector( '.lrv-js-MobileHeightToggle' );
46
-
49
+
47
50
  assert.equal( el.pmcMobileHeightToggle, undefined );
48
- });
51
+ } );
49
52
 
50
53
  it( 'does initialize MobileHeightToggles on below tablet', () => {
51
-
52
- document.querySelector('.test').innerHTML = `
54
+ document.querySelector( '.test' ).innerHTML = `
53
55
  <div class="lrv-js-MobileHeightToggle">
54
56
  <div class="lrv-js-MobileHeightToggle-trigger"></div>
55
57
  <div class="lrv-js-MobileHeightToggle-target"></div>
@@ -61,6 +63,5 @@ describe( 'MobileHeightToggle', () => {
61
63
  const el = document.querySelector( '.lrv-js-MobileHeightToggle' );
62
64
 
63
65
  assert.notEqual( el.pmcMobileHeightToggle, undefined );
64
- });
65
-
66
- });
66
+ } );
67
+ } );
@@ -2,17 +2,18 @@ import MobileHeightToggle from './MobileHeightToggle';
2
2
 
3
3
  // Initialize all Dropdowns.
4
4
 
5
- export default function( width ) {
6
- const dropdowns = [ ... document.querySelectorAll( '.lrv-js-MobileHeightToggle' ) ];
7
-
8
- dropdowns.forEach( el => {
5
+ export default function ( width ) {
6
+ const dropdowns = [
7
+ ...document.querySelectorAll( '.lrv-js-MobileHeightToggle' ),
8
+ ];
9
9
 
10
+ dropdowns.forEach( ( el ) => {
10
11
  if ( 768 > width && undefined === el.pmcMobileHeightToggle ) {
11
- new MobileHeightToggle( el );
12
+ new MobileHeightToggle( el );
12
13
  }
13
-
14
+
14
15
  if ( 768 <= width && undefined !== el.pmcMobileHeightToggle ) {
15
16
  el.pmcMobileHeightToggle.destroy();
16
17
  }
17
- });
18
- };
18
+ } );
19
+ }
@@ -1,34 +1,41 @@
1
1
  /**
2
2
  * Navigable
3
- *
3
+ *
4
4
  * Allows o-nav object to be accessible/navigable by keyboard tab.
5
- *
5
+ *
6
6
  * The HTML attributes required for the navigation to work:
7
7
  * - class lrv-js-Navigable to initiate the module, on a `nav` element
8
8
  */
9
9
 
10
10
  export default class Navigable {
11
-
12
- constructor( el ) {
13
- this.el = el;
14
- this.oNavList = el.querySelector( '.o-nav__list' );
15
- this.oNavListItems = [ ...el.querySelectorAll( '.o-nav__list-item a' ) ];
11
+ constructor( el ) {
12
+ this.el = el;
13
+ this.oNavList = el.querySelector( '.o-nav__list' );
14
+ this.oNavListItems = [
15
+ ...el.querySelectorAll( '.o-nav__list-item a' ),
16
+ ];
16
17
 
17
18
  this.el.addEventListener( 'focus', this.onFocus.bind( this ) );
18
19
  this.el.addEventListener( 'focusout', this.onFocusOut.bind( this ) );
19
20
  this.el.addEventListener( 'keyup', this.onKeyup.bind( this ) );
20
-
21
+
21
22
  if ( this.oNavListItems.length ) {
22
23
  this.oNavListItems.forEach( ( oNavListItem ) => {
23
- oNavListItem.addEventListener( 'focus', this.onFocusListItem.bind( this ) );
24
- oNavListItem.addEventListener( 'focusout', this.onFocusOutListItem.bind( this ) );
24
+ oNavListItem.addEventListener(
25
+ 'focus',
26
+ this.onFocusListItem.bind( this )
27
+ );
28
+ oNavListItem.addEventListener(
29
+ 'focusout',
30
+ this.onFocusOutListItem.bind( this )
31
+ );
25
32
  } );
26
33
  }
27
34
  }
28
35
 
29
36
  onFocus() {
30
37
  this.oNavList.style.visibility = 'visible';
31
- this.oNavList.style.opacity = '1';
38
+ this.oNavList.style.opacity = '1';
32
39
  }
33
40
 
34
41
  onFocusOut( event ) {
@@ -36,22 +43,26 @@ export default class Navigable {
36
43
  return;
37
44
  }
38
45
  this.oNavList.style.visibility = 'hidden';
39
- this.oNavList.style.opacity = '0';
46
+ this.oNavList.style.opacity = '0';
40
47
  }
41
-
48
+
42
49
  onFocusListItem( event ) {
43
- event.currentTarget.classList.add( 'lrv-u-background-color-brand-primary' );
50
+ event.currentTarget.classList.add(
51
+ 'lrv-u-background-color-brand-primary'
52
+ );
44
53
  }
45
54
 
46
55
  onFocusOutListItem( event ) {
47
- event.currentTarget.classList.remove( 'lrv-u-background-color-brand-primary' );
56
+ event.currentTarget.classList.remove(
57
+ 'lrv-u-background-color-brand-primary'
58
+ );
48
59
  }
49
60
 
50
61
  onKeyup( event ) {
51
62
  // Hide nav if Escape key is pressed.
52
- if ( "Escape" === event.key ) {
63
+ if ( 'Escape' === event.key ) {
53
64
  this.oNavList.style.visibility = 'hidden';
54
- this.oNavList.style.opacity = '0';
55
- }
65
+ this.oNavList.style.opacity = '0';
66
+ }
56
67
  }
57
68
  }
@@ -4,6 +4,6 @@ export default function initNavigable() {
4
4
  const oNavs = [ ...document.querySelectorAll( '.lrv-js-Navigable' ) ];
5
5
 
6
6
  if ( oNavs.length ) {
7
- oNavs.forEach( oNav => new Navigable( oNav ) );
7
+ oNavs.forEach( ( oNav ) => new Navigable( oNav ) );
8
8
  }
9
9
  }
@@ -1,43 +1,43 @@
1
1
  export default class PopOver {
2
- constructor(el) {
2
+ constructor( el ) {
3
3
  this.el = el;
4
4
  this.isOpen = false;
5
- this.target = this.el.querySelector('.js-PopOver-target');
5
+ this.target = this.el.querySelector( '.js-PopOver-target' );
6
6
 
7
7
  // Close PopOver on ESC.
8
- document.addEventListener('keydown', () => {
8
+ document.addEventListener( 'keydown', () => {
9
9
  this.closePopOver();
10
- });
10
+ } );
11
11
 
12
12
  // Open PopOver on mouseover.
13
- this.el.addEventListener('mouseover', () => {
13
+ this.el.addEventListener( 'mouseover', () => {
14
14
  this.openPopOver();
15
- });
15
+ } );
16
16
 
17
17
  // Open PopOver on mouseover.
18
- this.el.addEventListener('mouseout', () => {
18
+ this.el.addEventListener( 'mouseout', () => {
19
19
  this.closePopOver();
20
- });
20
+ } );
21
21
 
22
22
  // Open PopOver on focus.
23
- this.el.addEventListener('focus', () => {
23
+ this.el.addEventListener( 'focus', () => {
24
24
  this.openPopOver();
25
- });
25
+ } );
26
26
 
27
27
  // Open PopOver on blur.
28
- this.el.addEventListener('blur', () => {
28
+ this.el.addEventListener( 'blur', () => {
29
29
  this.closePopOver();
30
- });
30
+ } );
31
31
  }
32
32
 
33
33
  openPopOver() {
34
34
  this.isOpen = true;
35
- this.target.classList.add('js-PopOver-is-opened');
35
+ this.target.classList.add( 'js-PopOver-is-opened' );
36
36
  }
37
37
 
38
38
  closePopOver() {
39
- if (this.isOpen) {
40
- this.target.classList.remove('js-PopOver-is-opened');
39
+ if ( this.isOpen ) {
40
+ this.target.classList.remove( 'js-PopOver-is-opened' );
41
41
  }
42
42
  }
43
43
  }
@@ -1,9 +1,9 @@
1
1
  import PopOver from './PopOver.js';
2
2
 
3
3
  export default function initPopOver() {
4
- const searches = [...document.querySelectorAll('.js-PopOver')];
4
+ const searches = [ ...document.querySelectorAll( '.js-PopOver' ) ];
5
5
 
6
- searches.forEach((el) => {
7
- return new PopOver(el);
8
- });
6
+ searches.forEach( ( el ) => {
7
+ return new PopOver( el );
8
+ } );
9
9
  }
@@ -24,11 +24,17 @@ export default class ProfileFilter {
24
24
  this.el.pmcProfileFilter = this;
25
25
 
26
26
  // UI
27
- this.resultContainer = this.el.querySelector( '.js-ProfileFilter-results' );
27
+ this.resultContainer = this.el.querySelector(
28
+ '.js-ProfileFilter-results'
29
+ );
28
30
  this.form = this.el.querySelector( '.js-ProfileFilter-form' );
29
- this.loadMoreButton = this.el.querySelector( '.js-ProfileFilter-loadMore' );
31
+ this.loadMoreButton = this.el.querySelector(
32
+ '.js-ProfileFilter-loadMore'
33
+ );
30
34
 
31
- this.submitButton = this.form.querySelector( '.js-ProfileFilter-submit' );
35
+ this.submitButton = this.form.querySelector(
36
+ '.js-ProfileFilter-submit'
37
+ );
32
38
 
33
39
  // Event handlers
34
40
  this.onSubmit = this.onSubmit.bind( this );
@@ -41,7 +47,9 @@ export default class ProfileFilter {
41
47
  this.actionUrl = this.form.getAttribute( 'action' );
42
48
 
43
49
  // The endpoint where we will fetch the posts
44
- this.restUrlBase = window.location.origin + '/wp-json/pmc_core/v1/pmc_core_modules/pmc-profiles';
50
+ this.restUrlBase =
51
+ window.location.origin +
52
+ '/wp-json/pmc_core/v1/pmc_core_modules/pmc-profiles';
45
53
 
46
54
  // Object to hold the data from which we will create the request URL.
47
55
  // This should be created fresh each time it is used with this.setQueryObject
@@ -53,15 +61,15 @@ export default class ProfileFilter {
53
61
  if ( undefined !== window.wp ) {
54
62
  this.template = wp.template( 'profile-card' );
55
63
  }
56
-
57
64
  }
58
65
 
59
66
  getCheckedBoxes() {
60
- return [ ... this.form.querySelectorAll( 'input[type="checkbox"]:checked' ) ];
67
+ return [
68
+ ...this.form.querySelectorAll( 'input[type="checkbox"]:checked' ),
69
+ ];
61
70
  }
62
71
 
63
72
  setQueryObject( url = false ) {
64
-
65
73
  const els = this.getCheckedBoxes();
66
74
 
67
75
  // Get query from checkboxes, if they are checked,
@@ -76,12 +84,11 @@ export default class ProfileFilter {
76
84
  }
77
85
 
78
86
  setQueryObjectFromCheckboxes( els ) {
79
- let obj = {};
87
+ const obj = {};
80
88
 
81
89
  els.map( ( el ) => {
82
-
83
90
  // If the key doesn't exist, create it
84
- let key = el.getAttribute( 'name' );
91
+ const key = el.getAttribute( 'name' );
85
92
 
86
93
  if ( ! ( key in obj ) ) {
87
94
  obj[ key ] = [];
@@ -96,19 +103,19 @@ export default class ProfileFilter {
96
103
 
97
104
  // filterQueryString should be window.location.search, e.g. ?filter_top200location=scottdale&filter_sourceofwealth=money
98
105
  setQueryObjectFromUrl( filterQueryString ) {
99
- let queryObject = {};
106
+ const queryObject = {};
100
107
 
101
- let params = new URLSearchParams( filterQueryString );
108
+ const params = new URLSearchParams( filterQueryString );
102
109
 
103
110
  params.forEach( ( value, key ) => {
104
- let values = value.split( ',' );
111
+ const values = value.split( ',' );
105
112
 
106
113
  if ( ! ( key in queryObject ) ) {
107
114
  queryObject[ key ] = [];
108
115
  }
109
116
 
110
117
  queryObject[ key ] = [];
111
- queryObject[ key ].push( ... values );
118
+ queryObject[ key ].push( ...values );
112
119
  } );
113
120
 
114
121
  this.queryObject = Object.assign( {}, queryObject );
@@ -119,9 +126,12 @@ export default class ProfileFilter {
119
126
  }
120
127
 
121
128
  getRestEndpointUrl() {
122
-
123
129
  // REST params do not have filter_ prefix, so replace with empty string
124
- return this.restUrlBase + '?' + this.createQueryStringFromObject().replace( /filter_/g, '' );
130
+ return (
131
+ this.restUrlBase +
132
+ '?' +
133
+ this.createQueryStringFromObject().replace( /filter_/g, '' )
134
+ );
125
135
  }
126
136
 
127
137
  updateActionAttr() {
@@ -140,7 +150,6 @@ export default class ProfileFilter {
140
150
  // If fetch is supported, fetch posts from REST API endpoint, otherwise
141
151
  // we use default form behavior and window will reload to the action URL
142
152
  if ( window.fetch ) {
143
-
144
153
  e.preventDefault();
145
154
 
146
155
  // TODO: add better error handling - output result of e in updateResults
@@ -161,11 +170,13 @@ export default class ProfileFilter {
161
170
  }
162
171
 
163
172
  fetchData() {
164
- let url = this.getRestEndpointUrl();
173
+ const url = this.getRestEndpointUrl();
165
174
 
166
- const response = fetch( url ).then( ( result ) => {
167
- return result.json();
168
- } ).catch( e => e );
175
+ const response = fetch( url )
176
+ .then( ( result ) => {
177
+ return result.json();
178
+ } )
179
+ .catch( ( e ) => e );
169
180
 
170
181
  return response;
171
182
  }
@@ -176,7 +187,7 @@ export default class ProfileFilter {
176
187
 
177
188
  updateWindowUrl() {
178
189
  const url = '?' + this.createQueryStringFromObject();
179
- let obj = this.queryObject;
190
+ const obj = this.queryObject;
180
191
 
181
192
  if ( window.history.pushState ) {
182
193
  window.history.pushState( obj, '', url );
@@ -184,7 +195,6 @@ export default class ProfileFilter {
184
195
  }
185
196
 
186
197
  updateResults( posts, shouldClearResults = true ) {
187
-
188
198
  this.maybeHideLoadMore( this.maxPages );
189
199
 
190
200
  // TODO: better as maybeClearResults func
@@ -194,16 +204,15 @@ export default class ProfileFilter {
194
204
 
195
205
  this.updateWindowUrl();
196
206
 
197
- if ( undefined === posts[0].name ) {
198
-
207
+ if ( undefined === posts[ 0 ].name ) {
199
208
  // Update with "No posts found" text and exit
200
- this.resultContainer.innerHTML = posts[0];
209
+ this.resultContainer.innerHTML = posts[ 0 ];
201
210
  return;
202
211
  }
203
212
 
204
- posts.forEach( post => {
205
- let tmpl = this.template( post );
206
- let li = document.createElement( 'li' );
213
+ posts.forEach( ( post ) => {
214
+ const tmpl = this.template( post );
215
+ const li = document.createElement( 'li' );
207
216
  li.innerHTML = tmpl;
208
217
 
209
218
  // TODO: this should be removed upon finding solution for escaping {{data.url}} as an attribute
@@ -217,19 +226,15 @@ export default class ProfileFilter {
217
226
  }
218
227
 
219
228
  maybeHideLoadMore() {
220
-
221
229
  const isHidden = this.loadMoreButton.classList.contains( 'a-hidden' );
222
230
 
223
231
  if ( this.maxPages > this.page ) {
224
232
  if ( isHidden ) {
225
233
  this.loadMoreButton.classList.remove( 'a-hidden' );
226
234
  }
227
- } else {
228
- if ( ! isHidden ) {
229
- this.loadMoreButton.classList.add( 'a-hidden' );
230
- }
235
+ } else if ( ! isHidden ) {
236
+ this.loadMoreButton.classList.add( 'a-hidden' );
231
237
  }
232
-
233
238
  }
234
239
 
235
240
  increasePage() {
@@ -30,34 +30,34 @@ describe( 'initProfileFilter', () => {
30
30
  initProfileFilter();
31
31
 
32
32
  it( 'initializes the class', () => {
33
- let obj = document.querySelector( '.js-ProfileFilter' ).pmcProfileFilter;
33
+ const obj =
34
+ document.querySelector( '.js-ProfileFilter' ).pmcProfileFilter;
34
35
 
35
36
  assert.equal( typeof obj, 'object' );
36
37
  } );
37
-
38
38
  } );
39
39
 
40
40
  describe( 'ProfileFilter', () => {
41
- var pf = new ProfileFilter( document.querySelector( '.js-ProfileFilter' ) );
41
+ const pf = new ProfileFilter(
42
+ document.querySelector( '.js-ProfileFilter' )
43
+ );
42
44
 
43
- var allCheckboxes = [ ... document.querySelectorAll( 'input[type="checkbox"]' ) ];
45
+ const allCheckboxes = [
46
+ ...document.querySelectorAll( 'input[type="checkbox"]' ),
47
+ ];
44
48
 
45
- var checkedBoxes = [
46
- allCheckboxes[2], // top200location, new-york
47
- allCheckboxes[4], // collectingarea, llamas
48
- allCheckboxes[5] // collectingarea, coffee
49
+ const checkedBoxes = [
50
+ allCheckboxes[ 2 ], // top200location, new-york
51
+ allCheckboxes[ 4 ], // collectingarea, llamas
52
+ allCheckboxes[ 5 ], // collectingarea, coffee
49
53
  ];
50
54
 
51
55
  it( 'gets initial query from url', () => {
52
-
53
56
  // let obj = document.querySelector( '.js-ProfileFilter' ).pmcProfileFilter;
54
57
  const windowLocationSearchMock = '?filter_top200year=2020%2C2019';
55
58
  const expectedObject = {
56
- 'page': 1,
57
- 'filter_top200year': [
58
- '2020',
59
- '2019'
60
- ]
59
+ page: 1,
60
+ filter_top200year: [ '2020', '2019' ],
61
61
  };
62
62
 
63
63
  pf.setQueryObject( windowLocationSearchMock );
@@ -89,14 +89,9 @@ describe( 'ProfileFilter', () => {
89
89
 
90
90
  it( 'creates an object with the names/values from checked boxes', () => {
91
91
  const expectedObject = {
92
- 'filter_top200location': [
93
- 'new-york'
94
- ],
95
- 'filter_collectingarea': [
96
- 'llamas',
97
- 'coffee'
98
- ],
99
- 'page': 1
92
+ filter_top200location: [ 'new-york' ],
93
+ filter_collectingarea: [ 'llamas', 'coffee' ],
94
+ page: 1,
100
95
  };
101
96
 
102
97
  pf.setQueryObject();
@@ -106,13 +101,16 @@ describe( 'ProfileFilter', () => {
106
101
  } );
107
102
 
108
103
  it( 'creates query string from the object', () => {
109
- const expectedUrl = 'filter_top200location=new-york&filter_collectingarea=llamas%2Ccoffee&page=1'; // comma is encoded
104
+ const expectedUrl =
105
+ 'filter_top200location=new-york&filter_collectingarea=llamas%2Ccoffee&page=1'; // comma is encoded
110
106
 
111
107
  assert.equal( pf.createQueryStringFromObject(), expectedUrl );
112
108
  } );
113
109
 
114
110
  it( 'updates the action URL', () => {
115
- const expectedUrl = pf.actionUrl + '?filter_top200location=new-york&filter_collectingarea=llamas%2Ccoffee&page=1'; // comma is encoded
111
+ const expectedUrl =
112
+ pf.actionUrl +
113
+ '?filter_top200location=new-york&filter_collectingarea=llamas%2Ccoffee&page=1'; // comma is encoded
116
114
 
117
115
  pf.updateActionAttr();
118
116
 
@@ -120,21 +118,25 @@ describe( 'ProfileFilter', () => {
120
118
  } );
121
119
 
122
120
  it( 'gets url to fetch from rest api', () => {
123
- const expectedUrl = pf.restUrlBase + '?top200location=new-york&collectingarea=llamas%2Ccoffee&page=1'; // comma is encoded
121
+ const expectedUrl =
122
+ pf.restUrlBase +
123
+ '?top200location=new-york&collectingarea=llamas%2Ccoffee&page=1'; // comma is encoded
124
124
 
125
125
  assert.equal( pf.getRestEndpointUrl(), expectedUrl );
126
126
  } );
127
127
 
128
128
  it( 'increments the paged value when clicked', () => {
129
-
130
129
  pf.increasePage();
131
130
 
132
131
  assert.equal( pf.page, 2 );
133
132
  } );
134
133
 
135
134
  it( 'updates the fetch url with new paged value', () => {
136
- const expectedUrl = pf.restUrlBase + '?top200location=new-york&collectingarea=llamas%2Ccoffee&page=2'; // comma is encoded
137
- const searchUrlStub = '?filter_top200location=new-york&filter_collectingarea=llamas%2Ccoffee&page=1';
135
+ const expectedUrl =
136
+ pf.restUrlBase +
137
+ '?top200location=new-york&collectingarea=llamas%2Ccoffee&page=2'; // comma is encoded
138
+ const searchUrlStub =
139
+ '?filter_top200location=new-york&filter_collectingarea=llamas%2Ccoffee&page=1';
138
140
 
139
141
  pf.setQueryObject( searchUrlStub ); // This would be called by loadMoreClick
140
142
 
@@ -145,14 +147,19 @@ describe( 'ProfileFilter', () => {
145
147
  pf.maxPages = 2; // this.queryObject.page is currently 2
146
148
  pf.maybeHideLoadMore();
147
149
 
148
- assert.equal( pf.loadMoreButton.classList.contains( 'a-hidden' ), true );
150
+ assert.equal(
151
+ pf.loadMoreButton.classList.contains( 'a-hidden' ),
152
+ true
153
+ );
149
154
  } );
150
155
 
151
156
  it( 'shows load more if there are more pages', () => {
152
157
  pf.maxPages = 6; // this.queryObject.page is currently 2
153
158
  pf.maybeHideLoadMore();
154
159
 
155
- assert.equal( pf.loadMoreButton.classList.contains( 'a-hidden' ), false );
160
+ assert.equal(
161
+ pf.loadMoreButton.classList.contains( 'a-hidden' ),
162
+ false
163
+ );
156
164
  } );
157
-
158
165
  } );
@@ -1,6 +1,6 @@
1
1
  import ProfileFilter from './ProfileFilter';
2
2
 
3
3
  export default function initProfileFilter() {
4
- const filters = [ ... document.querySelectorAll( '.js-ProfileFilter' ) ];
5
- filters.forEach( el => el.ProfileFilter = new ProfileFilter( el ) );
4
+ const filters = [ ...document.querySelectorAll( '.js-ProfileFilter' ) ];
5
+ filters.forEach( ( el ) => ( el.ProfileFilter = new ProfileFilter( el ) ) );
6
6
  }
@@ -10,25 +10,27 @@
10
10
  * It is build to work with the patterns `o-select-nav` and `c-select-option`
11
11
  *
12
12
  * @since 11-22-2019
13
- */
13
+ */
14
14
 
15
15
  export default class SelectNav {
16
-
17
16
  constructor( el ) {
18
-
19
17
  this.el = el;
20
18
 
21
19
  this.selectEl = el.querySelector( '.js-SelectNav-select' );
22
20
 
23
21
  // If there is a class js-SelectNav-redirect, then only redirect.
24
22
  if ( el.classList.contains( 'js-SelectNav-redirect' ) ) {
25
- this.selectEl.addEventListener( 'change', this.onChange.bind( this ) );
23
+ this.selectEl.addEventListener(
24
+ 'change',
25
+ this.onChange.bind( this )
26
+ );
26
27
  }
27
-
28
28
  }
29
29
 
30
30
  onChange() {
31
- const redirectTo = this.selectEl.options[ this.selectEl.selectedIndex ].dataset.selectUrl;
31
+ const redirectTo =
32
+ this.selectEl.options[ this.selectEl.selectedIndex ].dataset
33
+ .selectUrl;
32
34
  if ( redirectTo ) {
33
35
  window.location.href = redirectTo;
34
36
  }
@@ -2,8 +2,7 @@ import SelectNav from './SelectNav';
2
2
 
3
3
  // Initialize all SelectNav.
4
4
  export default function initSelectNav() {
5
+ const SelectNavs = [ ...document.querySelectorAll( '.js-SelectNav' ) ];
5
6
 
6
- const SelectNavs = [ ... document.querySelectorAll( '.js-SelectNav' ) ];
7
-
8
- SelectNavs.forEach( el => new SelectNav( el ) );
7
+ SelectNavs.forEach( ( el ) => new SelectNav( el ) );
9
8
  }
@@ -9,13 +9,11 @@
9
9
  * Use a counter to ensure this script only runs one time.
10
10
  **/
11
11
 
12
-
13
12
  import removeDesktopXlClasses from '../../utils/removeDesktopXlClasses';
14
13
 
15
14
  // TODO: Should refactor to follow our exporting classes pattern, and
16
15
  // include the conditions from index.js in the class
17
16
  export default function reflowForSideSkinAd() {
18
-
19
17
  if ( undefined === window.pmc_side_skin_classes_removed ) {
20
18
  document.documentElement.classList.add( 'has-side-skins' );
21
19
  removeDesktopXlClasses();