| @@ -1,36 +1,36 @@ | ||
| 1 | -import * as Util from '../../../js/utils.js'; | |
| 2 | -export default function lpMaterialsLoad() { | |
| 3 | - document.addEventListener( 'click', function( e ) { | |
| 4 | - const target = e.target; | |
| 5 | - if ( target.classList.contains( 'lp-loadmore-material' ) ) { | |
| 6 | - const loadMoreButton = target; | |
| 7 | - const lpTarget = target.closest( '.lp-target' ); | |
| 8 | - const dataSend = window.lpAJAXG.getDataSetCurrent( lpTarget ); | |
| 9 | - dataSend.args.paged++; | |
| 10 | - | |
| 11 | - Util.lpSetLoadingEl( loadMoreButton, 1 ); | |
| 12 | - const callBack = { | |
| 13 | - success: ( response ) => { | |
| 14 | - const { status, message, data } = response; | |
| 15 | - if ( status === 'success' ) { | |
| 16 | - const tableBody = lpTarget.querySelector( 'table.course-material-table tbody' ); | |
| 17 | - tableBody.insertAdjacentHTML( 'beforeend', data.content ); | |
| 18 | - if ( data.paged === data.total_pages ) { | |
| 19 | - loadMoreButton.remove(); | |
| 20 | - } | |
| 21 | - window.lpAJAXG.setDataSetCurrent( lpTarget, dataSend ); | |
| 22 | - } else { | |
| 23 | - console.error( message ); | |
| 24 | - } | |
| 25 | - }, | |
| 26 | - error: ( error ) => { | |
| 27 | - console.error( error ); | |
| 28 | - }, | |
| 29 | - completed: () => { | |
| 30 | - Util.lpSetLoadingEl( loadMoreButton, 0 ); | |
| 31 | - }, | |
| 32 | - }; | |
| 33 | - window.lpAJAXG.fetchAJAX( dataSend, callBack ); | |
| 34 | - } | |
| 35 | - } ); | |
| 36 | -} | |
| 1 | +import * as Util from '../../../js/utils.js'; | |
| 2 | +export default function lpMaterialsLoad() { | |
| 3 | + document.addEventListener( 'click', function( e ) { | |
| 4 | + const target = e.target; | |
| 5 | + if ( target.classList.contains( 'lp-loadmore-material' ) ) { | |
| 6 | + const loadMoreButton = target; | |
| 7 | + const lpTarget = target.closest( '.lp-target' ); | |
| 8 | + const dataSend = window.lpAJAXG.getDataSetCurrent( lpTarget ); | |
| 9 | + dataSend.args.paged++; | |
| 10 | + | |
| 11 | + Util.lpSetLoadingEl( loadMoreButton, 1 ); | |
| 12 | + const callBack = { | |
| 13 | + success: ( response ) => { | |
| 14 | + const { status, message, data } = response; | |
| 15 | + if ( status === 'success' ) { | |
| 16 | + const tableBody = lpTarget.querySelector( 'table.course-material-table tbody' ); | |
| 17 | + tableBody.insertAdjacentHTML( 'beforeend', data.content ); | |
| 18 | + if ( data.paged === data.total_pages ) { | |
| 19 | + loadMoreButton.remove(); | |
| 20 | + } | |
| 21 | + window.lpAJAXG.setDataSetCurrent( lpTarget, dataSend ); | |
| 22 | + } else { | |
| 23 | + console.error( message ); | |
| 24 | + } | |
| 25 | + }, | |
| 26 | + error: ( error ) => { | |
| 27 | + console.error( error ); | |
| 28 | + }, | |
| 29 | + completed: () => { | |
| 30 | + Util.lpSetLoadingEl( loadMoreButton, 0 ); | |
| 31 | + }, | |
| 32 | + }; | |
| 33 | + window.lpAJAXG.fetchAJAX( dataSend, callBack ); | |
| 34 | + } | |
| 35 | + } ); | |
| 36 | +} | |