-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathVideoExplainer.js
More file actions
92 lines (80 loc) · 1.53 KB
/
VideoExplainer.js
File metadata and controls
92 lines (80 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* Sidebar Utilities View
*
* @since 7.2.0
* @version 7.2.0
*/
define( [], function() {
return Backbone.View.extend( {
/**
* HTML element selector.
*
* @type {string}
*/
el: '#llms-video-explainer',
/**
* Wrapper Tag name.
*
* @type {string}
*/
tagName: 'div',
/**
* Events.
*
* @type {Object}
*/
events: {
'click .llms-video-explainer-trigger': 'openPopup',
'click .llms-video-explainer-close': 'closePopup',
'click .llms-video-explainer-wrapper': 'closePopup',
},
/**
* Get the underscore template.
*/
template: wp.template( 'llms-video-explainer-template' ),
/**
* Compiles the template and renders the view.
*
* @since 7.2.0
*
* @return {self}
*/
render: function() {
this.$el.html( this.template() );
return this;
},
/**
* Open the popup.
*
* @since 7.2.0
*
* @param {Object} event JS event object.
* @return {void}
*/
openPopup: function( event ) {
event.preventDefault();
$( '.llms-video-explainer-wrapper' ).css( {
display: 'flex',
opacity: '1',
} );
},
/**
* Close the popup.
*
* @since 7.2.0
*
* @param {Object} event JS event object.
* @return {void}
*/
closePopup: function( event ) {
event.preventDefault();
$( '.llms-video-explainer-wrapper' ).css( {
display: 'none',
opacity: '0',
} );
const iframe = $( '.llms-video-explainer-iframe' );
const src = iframe.attr( 'src' );
iframe.attr( 'src', '' ).attr( 'src', src );
},
} );
} );