@penskemediacorp/larva-js 1.66.4 → 1.69.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.
- package/package.json +2 -2
- package/src/interface/MegaMenu/MegaMenu.js +11 -8
- package/src/interface/MegaMenu/index.js +4 -0
- package/src/interface/MobileHeightToggle/MobileHeightToggle.js +2 -2
- package/src/interface/MobileHeightToggle/{MobileHeightToggle.test.js → __test__/MobileHeightToggle.test.js} +2 -2
- package/src/interface/ProfileFilter/ProfileFilter.js +1 -0
- package/src/interface/SideSkinAd/SideSkinAd.js +1 -1
- package/src/interface/TabsManager/TabsManager.js +1 -2
- package/src/interface/VideoShowcase/VideoShowcase.js +32 -32
- package/src/larva-ui/index.js +0 -1
- package/src/utils/ajaxIconSprite.js +2 -2
- package/src/utils/removeDesktopXlClasses.js +1 -1
- package/src/utils/webfontConfig.js +5 -5
- package/src/video-showcase.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@penskemediacorp/larva-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.69.0",
|
|
4
4
|
"description": "Larva JS patterns.",
|
|
5
5
|
"author": "laras126 <laras126@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/penske-media-corp/pmc-larva#readme",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"webpack": "^5",
|
|
27
27
|
"webpack-cli": "^5"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "9655cabc42a4d705c189ea9b65e6d34788a809e9"
|
|
30
30
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// no-global-active-element not needed for non-React context.
|
|
2
|
+
// https://wordpress.stackexchange.com/a/387511
|
|
3
|
+
/* eslint-disable @wordpress/no-global-active-element */
|
|
4
|
+
|
|
1
5
|
export default class MegaMenu {
|
|
2
6
|
constructor( el ) {
|
|
3
7
|
this.el = el;
|
|
@@ -63,15 +67,14 @@ export default class MegaMenu {
|
|
|
63
67
|
lastFocusableElement.focus();
|
|
64
68
|
event.preventDefault();
|
|
65
69
|
}
|
|
66
|
-
|
|
70
|
+
|
|
67
71
|
// tab key
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
72
|
+
} else if (
|
|
73
|
+
document.activeElement === lastFocusableElement &&
|
|
74
|
+
firstFocusableElement
|
|
75
|
+
) {
|
|
76
|
+
firstFocusableElement.focus();
|
|
77
|
+
event.preventDefault();
|
|
75
78
|
}
|
|
76
79
|
};
|
|
77
80
|
|
|
@@ -25,7 +25,7 @@ export default class MobileHeightToggle {
|
|
|
25
25
|
delete this.el.pmcMobileHeightToggle;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
onBlur(
|
|
28
|
+
onBlur() {
|
|
29
29
|
document.removeEventListener( 'keydown', this.keyDown );
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -35,7 +35,7 @@ export default class MobileHeightToggle {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
onFocus(
|
|
38
|
+
onFocus() {
|
|
39
39
|
document.addEventListener( 'keydown', this.keyDown );
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const assert = require( 'assert' );
|
|
2
2
|
|
|
3
|
-
import MobileHeightToggle from '
|
|
4
|
-
import initMobileHeightToggles from '
|
|
3
|
+
import MobileHeightToggle from '../MobileHeightToggle';
|
|
4
|
+
import initMobileHeightToggles from '../index';
|
|
5
5
|
|
|
6
6
|
const TABLET = 768;
|
|
7
7
|
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @todo Add hover support
|
|
5
5
|
* @see https://bitbucket.org/penskemediacorp/pmc-indiewire-2016/src/master/assets/src/js/modules/TabsManager/TabsManager.js
|
|
6
|
-
*
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
export default class TabsManager {
|
|
10
9
|
/**
|
|
11
10
|
* Initialize
|
|
12
11
|
*
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {HTMLElement} el Tabs container
|
|
14
13
|
*/
|
|
15
14
|
constructor( el ) {
|
|
16
15
|
this.el = el;
|
|
@@ -53,8 +53,8 @@ export default class VideoShowcase {
|
|
|
53
53
|
*
|
|
54
54
|
* @type {Object}
|
|
55
55
|
* @property {boolean} isPlayerSetup - Whether or not the player has been setup or played. Set in onFirstTimePlay()
|
|
56
|
-
* @property {string}
|
|
57
|
-
* @property {string}
|
|
56
|
+
* @property {string} videoID - A Youtube or JWPlayer ID extracted from a `data-video-showcase-trigger` e.g. f1FX5wvC3DA
|
|
57
|
+
* @property {string} videoType - "youtube" or "jwplayer" from `data-video-showcase-type`
|
|
58
58
|
*/
|
|
59
59
|
this.state = {
|
|
60
60
|
isPlayerSetup: false,
|
|
@@ -70,11 +70,11 @@ export default class VideoShowcase {
|
|
|
70
70
|
* Note: the title and dek are using class selectors so they can be added to existing patterns.
|
|
71
71
|
*
|
|
72
72
|
* @type {Object}
|
|
73
|
-
* @property {
|
|
74
|
-
* @property {
|
|
75
|
-
* @property {
|
|
76
|
-
* @property {
|
|
77
|
-
* @property {
|
|
73
|
+
* @property {HTMLElement} title - A anchor element that will receive both a permalink and heading text.
|
|
74
|
+
* @property {HTMLElement} dek - An element containing a direct child paragraph that will support the dek text.
|
|
75
|
+
* @property {HTMLElement} iframe - The iframe that will recieve an src when a trigger with the Youtube video type is clicked.
|
|
76
|
+
* @property {HTMLElement} jwplayerContainer - The placeholder element where JWPlayer will be applied.
|
|
77
|
+
* @property {HTMLElement} social - The main social share container that will be replaced with social share from triggers.
|
|
78
78
|
*/
|
|
79
79
|
this.playerUI = {
|
|
80
80
|
title: el.querySelector( '.js-VideoShowcase-title' ),
|
|
@@ -128,14 +128,14 @@ export default class VideoShowcase {
|
|
|
128
128
|
* to the main player card. These are all strings from data attributes except the
|
|
129
129
|
* social share, which replaces an entire block of HTML.
|
|
130
130
|
*
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
131
|
+
* @param {HTMLElement} type - Video type.
|
|
132
|
+
* @param {HTMLElement} el - A trigger.
|
|
133
133
|
*
|
|
134
|
-
* @return
|
|
135
|
-
* @property {string}
|
|
136
|
-
* @property {string}
|
|
137
|
-
* @property {string}
|
|
138
|
-
* @property {string}
|
|
134
|
+
* @return {Object} - An object containing the data needed to update the player.
|
|
135
|
+
* @property {string} title - Title text from the `data-video-showcase-title`
|
|
136
|
+
* @property {string} dek - Dek text from the `data-video-showcase-dek`
|
|
137
|
+
* @property {string} permalink - Link from `data-video-showcase-permalink`
|
|
138
|
+
* @property {string} socialString - HTML string returned from wp.template.
|
|
139
139
|
*/
|
|
140
140
|
|
|
141
141
|
getPlayerCardData( type, el ) {
|
|
@@ -168,8 +168,8 @@ export default class VideoShowcase {
|
|
|
168
168
|
*
|
|
169
169
|
* Apply the assembled data to the UI.
|
|
170
170
|
*
|
|
171
|
-
* @param {
|
|
172
|
-
* @param {Object}
|
|
171
|
+
* @param {HTMLElement} el - A trigger.
|
|
172
|
+
* @param {Object} data - An object of data from getPlayerCardData.
|
|
173
173
|
*/
|
|
174
174
|
|
|
175
175
|
updatePlayerCardData( el, data ) {
|
|
@@ -233,7 +233,6 @@ export default class VideoShowcase {
|
|
|
233
233
|
if ( 'connatix' === type || 'iframe' === type ) {
|
|
234
234
|
return id;
|
|
235
235
|
}
|
|
236
|
-
|
|
237
236
|
}
|
|
238
237
|
|
|
239
238
|
/**
|
|
@@ -256,19 +255,21 @@ export default class VideoShowcase {
|
|
|
256
255
|
* @param {string} playerId - Connatix player id.
|
|
257
256
|
*/
|
|
258
257
|
playConnatix( mediaId, playerId ) {
|
|
259
|
-
this.playerUI.connatixContainer.removeAttribute('hidden');
|
|
260
|
-
const eleId = this.playerUI.connatixContainer.getAttribute('id');
|
|
258
|
+
this.playerUI.connatixContainer.removeAttribute( 'hidden' );
|
|
259
|
+
const eleId = this.playerUI.connatixContainer.getAttribute( 'id' );
|
|
261
260
|
// eslint-disable-next-line no-undef
|
|
262
261
|
new Image().src =
|
|
263
262
|
'https://capi.elements.video/tr/si?token=094029a3-814c-41d5-8a62-2c3adc647176&cid=1ffe63de-eb53-11e9-b4d2-06948452ae1a';
|
|
264
263
|
// eslint-disable-next-line no-undef
|
|
265
|
-
pmcCnx.cmd.push(function () {
|
|
264
|
+
pmcCnx.cmd.push( function () {
|
|
266
265
|
// eslint-disable-next-line no-undef
|
|
267
|
-
pmcCnx({
|
|
266
|
+
pmcCnx( {
|
|
268
267
|
playerId,
|
|
269
268
|
mediaId,
|
|
270
|
-
})
|
|
271
|
-
|
|
269
|
+
} )
|
|
270
|
+
.render( eleId )
|
|
271
|
+
.play();
|
|
272
|
+
} );
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
/**
|
|
@@ -302,9 +303,8 @@ export default class VideoShowcase {
|
|
|
302
303
|
* If there is something amiss, this is a good place to trouble shoot - it's possible we need to
|
|
303
304
|
* getPlaylist() first to retrieve an individual video, then play it, but this was working.
|
|
304
305
|
*
|
|
305
|
-
* @
|
|
306
|
-
* @param playlistUrl
|
|
307
|
-
* @param {string} jwplayerUrl - A Youtube embed URL from returnUrl.
|
|
306
|
+
* @see https://developer.jwplayer.com/jw-player/docs/developer-guide/customization/configuration-reference/#playlist
|
|
307
|
+
* @param {string} playlistUrl - YouTube playlist URL.
|
|
308
308
|
*/
|
|
309
309
|
playJW( playlistUrl ) {
|
|
310
310
|
this.playerUI.jwplayerContainer.removeAttribute( 'hidden' );
|
|
@@ -325,8 +325,8 @@ export default class VideoShowcase {
|
|
|
325
325
|
*
|
|
326
326
|
* Reset player from previous state, update state and player UI, play the video.
|
|
327
327
|
*
|
|
328
|
-
* @param {
|
|
329
|
-
* @param {
|
|
328
|
+
* @param {Event} e
|
|
329
|
+
* @param {HTMLElement} el - Clicked trigger element.
|
|
330
330
|
*/
|
|
331
331
|
handleTriggerClick( e, el ) {
|
|
332
332
|
if ( e ) {
|
|
@@ -428,7 +428,7 @@ export default class VideoShowcase {
|
|
|
428
428
|
* Hide both players and either remove JWPlayer or reset the src for the iframe according
|
|
429
429
|
* to the previous type of video played.
|
|
430
430
|
*
|
|
431
|
-
* @
|
|
431
|
+
* @todo this could check for the current type and only run if the current type is not the
|
|
432
432
|
* same as the past type.
|
|
433
433
|
*
|
|
434
434
|
* @param {string} pastType - Youtube or JWplayer ID, should be from this.state.videoID, e.g. f1FX5wvC3DA
|
|
@@ -447,8 +447,8 @@ export default class VideoShowcase {
|
|
|
447
447
|
if ( 'connatix' === pastType ) {
|
|
448
448
|
const elements =
|
|
449
449
|
document.getElementsByClassName( 'cnx-main-container' );
|
|
450
|
-
while (elements.length > 0) {
|
|
451
|
-
elements[0].parentNode.removeChild( elements[0] );
|
|
450
|
+
while ( elements.length > 0 ) {
|
|
451
|
+
elements[ 0 ].parentNode.removeChild( elements[ 0 ] );
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
}
|
|
@@ -466,7 +466,7 @@ export default class VideoShowcase {
|
|
|
466
466
|
*/
|
|
467
467
|
setActiveTrigger( type, id ) {
|
|
468
468
|
let trigger = '';
|
|
469
|
-
if( 'connatix' === type ) {
|
|
469
|
+
if ( 'connatix' === type ) {
|
|
470
470
|
trigger = this.el.querySelector(
|
|
471
471
|
`.related-videos [data-video-media-id="${ id }"]`
|
|
472
472
|
);
|
package/src/larva-ui/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import '../vendor/prism';
|
|
|
5
5
|
|
|
6
6
|
export default function initLarvaUi() {
|
|
7
7
|
// This rule is meant for React components.
|
|
8
|
-
// eslint-disable-next-line @wordpress/no-global-event-listener
|
|
9
8
|
document.addEventListener( 'DOMContentLoaded', () => {
|
|
10
9
|
/**
|
|
11
10
|
* Initialize local storage toggle button.
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Ajax the SVG sprite and append a DOM hidden element
|
|
3
3
|
* containing the responseText.
|
|
4
4
|
*
|
|
5
|
-
* @param {string}
|
|
6
|
-
* @param iconPath
|
|
5
|
+
* @param {string} iconPath
|
|
7
6
|
*/
|
|
8
7
|
export default function ( iconPath ) {
|
|
8
|
+
// eslint-disable-next-line no-undef
|
|
9
9
|
const ajax = new XMLHttpRequest();
|
|
10
10
|
const div = document.createElement( 'div' );
|
|
11
11
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* global pmc, pmc_common_urls, WebFont */
|
|
2
|
+
|
|
1
3
|
// TODO:
|
|
2
4
|
// post launch task from GUT-67 is to pull the
|
|
3
5
|
// IW related values into configuration
|
|
@@ -15,10 +17,6 @@ const webFontConfig = {
|
|
|
15
17
|
},
|
|
16
18
|
|
|
17
19
|
load: function load( type ) {
|
|
18
|
-
const currentThemeUrl = this.getThemeUrl();
|
|
19
|
-
|
|
20
|
-
const loadcount = this.loadcount++;
|
|
21
|
-
|
|
22
20
|
WebFont.load( {
|
|
23
21
|
google: {
|
|
24
22
|
families: [ 'PT Sans:400,700', 'Teko:300,400' ],
|
|
@@ -29,13 +27,15 @@ const webFontConfig = {
|
|
|
29
27
|
|
|
30
28
|
active: function webfontsLoaderActive() {
|
|
31
29
|
try {
|
|
32
|
-
if ( 'load'
|
|
30
|
+
if ( 'load' === type ) {
|
|
33
31
|
pmc.cookie.set(
|
|
34
32
|
'iw_fonts_loaded',
|
|
35
33
|
1,
|
|
36
34
|
7 * 24 * 60 * 60
|
|
37
35
|
);
|
|
38
36
|
}
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
39
|
console.log( 'fonts loaded ' + type );
|
|
40
40
|
} catch ( e ) {}
|
|
41
41
|
},
|
package/src/video-showcase.js
CHANGED
|
@@ -3,7 +3,6 @@ import initFlickity from './interface/Flickity';
|
|
|
3
3
|
import initVideoShowcase from './interface/VideoShowcase';
|
|
4
4
|
|
|
5
5
|
// This rule is meant for React components.
|
|
6
|
-
// eslint-disable-next-line @wordpress/no-global-event-listener
|
|
7
6
|
document.addEventListener( 'DOMContentLoaded', () => {
|
|
8
7
|
initCollapsible();
|
|
9
8
|
initFlickity();
|