PluginProbe
BeyondWords – AI audio for publishers / 4.0.2
BeyondWords – AI audio for publishers v4.0.2
7.2.0 7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 All 44 releases
speechkit / src / Compatibility / Elementor / js / index.js

index.js in BeyondWords – AI audio for publishers 4.0.2, at src/Compatibility/Elementor/js/index.js

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global jQuery, $e */
2
3 import { BeyondwordsComponent } from './components';
4 import { BeyondWordsSdk } from '@beyondwords/audio-player';
5
6 export default class BeyondwordsElementorCompatibility {
7 constructor() {
8 jQuery( window ).on( 'elementor/init', function () {
9 $e.components.register( new BeyondwordsComponent() );
10 } );
11 }
12
13 /**
14 * For now, this has been mostly copied from src/Core/Player.php.
15 *
16 * @todo Support all player params e.g. `beyondwords_player_size`.
17 *
18 * @param {*} params Params are NOT being passed at the moment
19 * @return {Promise}
20 */
21 async initPlayer( params ) {
22 const PLAYER_ID = `beyondwords-elementor-editor-player`;
23 const PLAYER_SELECTOR = `div#${ PLAYER_ID }:not([data-beyondwords-init])`;
24
25 const el = document.querySelector( PLAYER_SELECTOR );
26
27 const projectId = el.getAttribute( 'data-beyondwords-project-id' ).toString();
28 const contentId = el.getAttribute( 'data-beyondwords-content-id' ).toString();
29
30 const renderNode = PLAYER_ID;
31
32 if ( ! projectId || ! contentId ) {
33 return false;
34 }
35
36 // console.log( 'BeyondwordsElementorCompatibility::initPlayer', {
37 // projectId,
38 // contentId,
39 // renderNode,
40 // } );
41
42 // console.log('BeyondWordsSdk', BeyondWordsSdk);
43
44 return await BeyondWordsSdk.player( {
45 projectId,
46 podcastId: contentId,
47 renderNode,
48 processingStatus: true,
49 } ).then( ( player ) => {
50 el.setAttribute( 'data-beyondwords-init', 'true' );
51 console.log( `🔊 Elementor player #${ PLAYER_ID } is initialized`, player );
52 } );
53 }
54 }
55
56 window.beyondwordsElementorCompatibility =
57 new BeyondwordsElementorCompatibility();
58