Skip to content

Commit

Permalink
Issue [#276](#276): Post Filters – "All" button instead showing all t…
Browse files Browse the repository at this point in the history
…he posts, is hiding them at all
  • Loading branch information
lumberman committed Sep 9, 2016
1 parent c22dfbc commit bc2b98f
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 33 deletions.
29 changes: 21 additions & 8 deletions js/frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,16 +832,29 @@ jQuery(document).ready(function($){
*/
$(document).on( 'click', '.dslc-post-filter', function(){

// Get info
var dslcCat = $(this).data('id');
var dslcPosts = $(this).closest('.dslc-module-front').find('.dslc-post');
var dslcFilterPosts = $(this).closest('.dslc-module-front').find('.dslc-post[data-cats*="' + dslcCat + '"]');
var dslcNotFilterPosts = $(this).closest('.dslc-module-front').find('.dslc-post:not([data-cats*="' + dslcCat + '"])');
var dslcContainer = dslcPosts.closest('.dslc-posts');
var dslcWrapper = $(this).closest('.dslc-module-front');
// Get info.
var selectedFilterEl = $(this);
var dslcContainer = selectedFilterEl.closest('.dslc-module-front').find('.dslc-posts');
var dslcWrapper = selectedFilterEl.closest('.dslc-module-front');

// Filter posts according to selected filter.
var dslcCat = selectedFilterEl.data('filter-id');
var dslcFilterPosts = $(); // Empty jQuery object.
var dslcNotFilterPosts = $();

if ( dslcCat === 'show-all' ) {

dslcFilterPosts = dslcContainer.closest('.dslc-module-front').find('.dslc-post');
dslcNotFilterPosts = $(); // Empty jQuery object.

} else {

dslcFilterPosts = dslcContainer.closest('.dslc-module-front').find('.dslc-post[data-cats*="' + dslcCat + '"]');
dslcNotFilterPosts = dslcContainer.closest('.dslc-module-front').find('.dslc-post:not([data-cats*="' + dslcCat + '"])');
}

// Set active
$(this).removeClass('dslc-inactive').addClass('dslc-active').siblings('.dslc-active').removeClass('dslc-active').addClass('dslc-inactive');
selectedFilterEl.removeClass('dslc-inactive').addClass('dslc-active').siblings('.dslc-active').removeClass('dslc-active').addClass('dslc-inactive');

if ( dslcContainer.hasClass('dslc-init-grid' ) ) {

Expand Down
4 changes: 2 additions & 2 deletions modules/blog/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3344,10 +3344,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">
<span class="dslc-post-filter dslc-active dslca-editable-content" data-id="<?php if ( $dslc_is_admin ){ echo 'main_filter_title_all'; } else { echo ''; } ?>" data-type="simple" <?php if ( $dslc_is_admin ) echo 'contenteditable'; ?> ><?php echo $options['main_filter_title_all']; ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
5 changes: 2 additions & 3 deletions modules/downloads/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2707,11 +2707,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">

<span class="dslc-post-filter dslc-active" data-id=" "><?php _ex( 'All', 'Post Filter', 'live-composer-page-builder' ); ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
5 changes: 2 additions & 3 deletions modules/galleries/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2793,11 +2793,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">

<span class="dslc-post-filter dslc-active" data-id=" "><?php _ex( 'All', 'Post Filter', 'live-composer-page-builder' ); ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
5 changes: 2 additions & 3 deletions modules/partners/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1785,11 +1785,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">

<span class="dslc-post-filter dslc-active" data-id=" "><?php _ex( 'All', 'Post Filter', 'live-composer-page-builder' ); ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
4 changes: 2 additions & 2 deletions modules/posts/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2874,10 +2874,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">
<span class="dslc-post-filter dslc-active dslca-editable-content" data-id="<?php if ( $dslc_is_admin ){ echo 'main_filter_title_all'; } else { echo ''; } ?>" data-type="simple" <?php if ( $dslc_is_admin ) echo 'contenteditable'; ?> ><?php echo $options['main_filter_title_all']; ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
5 changes: 2 additions & 3 deletions modules/projects/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2614,11 +2614,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">

<span class="dslc-post-filter dslc-active" data-id=" "><?php _ex( 'All', 'Post Filter', 'live-composer-page-builder' ); ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
5 changes: 2 additions & 3 deletions modules/staff/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2448,11 +2448,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">

<span class="dslc-post-filter dslc-active" data-id=" "><?php _ex( 'All', 'Post Filter', 'live-composer-page-builder' ); ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
5 changes: 2 additions & 3 deletions modules/testimonials/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2183,11 +2183,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">

<span class="dslc-post-filter dslc-active" data-id=" "><?php _ex( 'All', 'Post Filter', 'live-composer-page-builder' ); ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
5 changes: 2 additions & 3 deletions modules/woocommerce/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2862,11 +2862,10 @@ function output( $options ) {
?>

<div class="dslc-post-filters">

<span class="dslc-post-filter dslc-active" data-id=" "><?php _ex( 'All', 'Post Filter', 'live-composer-page-builder' ); ?></span>
<span class="dslc-post-filter dslc-active dslca-editable-content" data-filter-id="show-all" <?php if ( $dslc_is_admin ){ echo 'data-id="main_filter_title_all" data-type="simple" contenteditable '; } ?>><?php echo $options['main_filter_title_all']; ?></span>

<?php foreach ( $cats_array as $cat_slug => $cat_name ) : ?>
<span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<span class="dslc-post-filter dslc-inactive" data-filter-id="<?php echo $cat_slug; ?>"><?php echo $cat_name; ?></span>
<?php endforeach; ?>

</div><!-- .dslc-post-filters -->
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ The Page Builder Sandwich available on WordPress.org is a light version of Page
* Issue [#196](https://github.com/livecomposer/live-composer-page-builder/issues/196): Uncaught Error – cannot call methods on sortable prior to initialization; attempted to call method 'option'
* Issue [#202](https://github.com/livecomposer/live-composer-page-builder/issues/202): Inline Editor – Bold, Italic text styling do not apply in some themes.
* Issue [#193](https://github.com/livecomposer/live-composer-page-builder/issues/193): Navigation Module – Chevron not showing when enabled in navigation module
* Issue [#276](https://github.com/livecomposer/live-composer-page-builder/issues/276): Post Filters – "All" button instead showing all the posts, is hiding them at all

* Presets: Fixed presets auto-reload on module options change. (Thank you Paul!)
* Presets: Removed Infobox > Image and Infobox > Image Url form synchronization. (Thank you Paul!)
* Post Grids: Wrong post title centering over thumbnail. (Thank you Jacob!)
Expand Down

0 comments on commit bc2b98f

Please sign in to comment.