PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.5
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.5
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 / sidebar.js

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

73 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const $ = jQuery;
2 const { throttle } = lodash;
3
4 export const Sidebar = () => {
5 // Tungnx - Show/hide sidebar curriculumn
6 const elSidebarToggle = document.querySelector( '#sidebar-toggle' );
7
8 // For style of theme
9 const toggleSidebar = ( toggle ) => {
10 $( 'body' ).removeClass( 'lp-sidebar-toggle__open' );
11 $( 'body' ).removeClass( 'lp-sidebar-toggle__close' );
12
13 if ( toggle ) {
14 $( 'body' ).addClass( 'lp-sidebar-toggle__close' );
15 } else {
16 $( 'body' ).addClass( 'lp-sidebar-toggle__open' );
17 }
18 };
19
20 // For lp and theme
21 if ( elSidebarToggle ) {
22 if ( $( window ).innerWidth() <= 768 ) {
23 elSidebarToggle.setAttribute( 'checked', 'checked' );
24 } else if ( LP.Cookies.get( 'sidebar-toggle' ) ) {
25 elSidebarToggle.setAttribute( 'checked', 'checked' );
26 } else {
27 elSidebarToggle.removeAttribute( 'checked' );
28 }
29 }
30 // End editor by tungnx
31
32 // Code for old curriculum
33 /*const $curriculum = $( '#learn-press-course-curriculum' );
34 $curriculum.find( '.section-desc' ).each( ( i, el ) => {
35 const a = $( '<span class="show-desc"></span>' ).on( 'click', () => {
36 b.toggleClass( 'c' );
37 } );
38 const b = $( el ).siblings( '.section-title' ).append( a );
39 } );*/
40
41 // Code for old curriculum
42 /*$( '.section' ).each( function() {
43 const $section = $( this ),
44 $toggle = $section.find( '.section-left' );
45
46 $toggle.on( 'click', function() {
47 const isClose = $section.toggleClass( 'closed' ).hasClass( 'closed' );
48 const sections = LP.Cookies.get( 'closed-section-' + lpGlobalSettings.post_id ) || [];
49 const sectionId = parseInt( $section.data( 'section-id' ) );
50 const at = sections.findIndex( ( id ) => {
51 return id == sectionId;
52 } );
53
54 if ( isClose ) {
55 sections.push( parseInt( $section.data( 'section-id' ) ) );
56 } else {
57 sections.splice( at, 1 );
58 }
59
60 LP.Cookies.remove( 'closed-section-(.*)' );
61 LP.Cookies.set( 'closed-section-' + lpGlobalSettings.post_id, [ ...new Set( sections ) ] );
62 } );
63 } );*/
64
65 document.addEventListener( 'click', ( e ) => {
66 if ( e.target.id === 'sidebar-toggle' ) {
67 LP.Cookies.set( 'sidebar-toggle', e.target.checked ? true : false );
68 toggleSidebar( LP.Cookies.get( 'sidebar-toggle' ) );
69 }
70 } );
71 };
72
73