Skip to content

Commit

Permalink
Merge pull request #29 from a8cteam51/add/loading-class
Browse files Browse the repository at this point in the history
Add loading class when in loading state
  • Loading branch information
Ninodevo authored Dec 20, 2024
2 parents 02a7eb5 + 232eab9 commit 16d1e98
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/js/build/frontend.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'e794f26b7ef47600cb0a');
<?php return array('dependencies' => array(), 'version' => '2ce08fc3c1cd1c49f53c');
2 changes: 1 addition & 1 deletion assets/js/build/frontend.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions assets/js/src/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ const fetchPosts = ( url, container, clickedButton ) => {
// Update the window URL.
window.history.pushState( {}, '', url );

const $button = clickedButton.closest('.wp-block-button');

console.log( $button );

if ( $button ) {
$button.classList.remove( 'loading' );
}

// Remove button.
clickedButton.remove();

Expand Down Expand Up @@ -190,6 +198,12 @@ document.addEventListener( 'DOMContentLoaded', function () {
.querySelector( '.wp-block-post-template' ),
url = thisButton.getAttribute( 'href' );

const $button = thisButton.closest('.wp-block-button');

if ( $button ) {
$button.classList.add( 'loading' );
}

// Update button text.
thisButton.innerText =
thisButton.getAttribute( 'data-loading-text' );
Expand Down
2 changes: 1 addition & 1 deletion query-loop-load-more.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Query Loop Load More
* Plugin URI: https://github.com/a8cteam51/query-loop-load-more
* Description: Adds a load more option to the Query Loop Pagination block in Gutenberg.
* Version: 1.0.5
* Version: 1.0.6
* Requires at least: 6.2
* Tested up to: 6.6.1
* Requires PHP: 8.0
Expand Down

0 comments on commit 16d1e98

Please sign in to comment.