PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.1
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.1
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / src / apps / js / frontend / single-curriculum / components / comment.js

comment.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.1, at assets/src/apps/js/frontend/single-curriculum/components/comment.js

54 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Toogle form Comment for Lesson.
3 *
4 * @author Nhamdv.
5 */
6
7 export const commentForm = () => {
8 const btn = document.querySelector( '.lp-lesson-comment-btn' );
9
10 if ( ! btn ) {
11 return;
12 }
13
14 const btnOpen = btn.textContent;
15 const btnClose = btn.dataset.close;
16 const hashComment = window.location.hash;
17
18 if ( hashComment.includes( 'comment' ) ) {
19 btn.parentNode.classList.add( 'open-comments' );
20 }
21
22 const toogleText = ( btn, btnParent ) => {
23 if ( btnParent.classList.contains( 'open-comments' ) ) {
24 btn.textContent = btnClose;
25 } else {
26 btn.textContent = btnOpen;
27 }
28 };
29
30 toogleText( btn, btn.parentNode );
31
32 btn.addEventListener( 'click', ( e ) => {
33 e.preventDefault();
34
35 btn.parentNode.classList.toggle( 'open-comments' );
36 toogleText( btn, btn.parentNode );
37 } );
38
39 // Use for Rest API.
40 // const toogle = $( '#learn-press-item-comments-toggle' );
41
42 // toogle.on( 'change', async function() {
43 // if ( ! toogle[ 0 ].checked ) {
44 // return;
45 // }
46
47 // const response = await wp.apiFetch( {
48 // path: 'lp/v1/courses/339/item-comments/50',
49 // } );
50
51 // $( '.learn-press-comments' ).html( response.comments );
52 // } );
53 };
54