/* ------------------------------------------------------------------------------
* Author: DMCWebZone
* Author URL: https://web-zone.org
* Copyright © Airin Blog by DMCWebZone. All Rights Reserved.
* @package Airin Blog
* Description: Woo
* ------------------------------------------------------------------------------ */


jQuery(document).ready(function($) {

    'use strict';

    // Add a class to everything except empty fields
    $('.airinblog-css-widget-area .widget_block').each(function() {
        if ($(this).text().trim() != '') {
            $(this).addClass('widget-block-box');
        }
    });

    // Adding a class for filters
    $('.wc-blocks-filter-wrapper:not([hidden])').closest('.airinblog-css-widget-area .widget_block').addClass('widget-block-box');

    // Del a class for filters
    $('.wc-blocks-filter-wrapper[hidden]').closest('.airinblog-css-widget-area .widget_block').removeClass('widget-block-box');

    // Add a class for the rest
    let n1 = document.querySelectorAll('.airinblog-css-widget-area .widget_block figure, \
    .airinblog-css-widget-area .widget_block img');
    $(n1).closest('.airinblog-css-widget-area .widget_block').addClass('widget-block-box');


    // Repeat for filters
    const filtersInterval = setInterval(airinblog_fun_js_woo_filters, 2000);
    setTimeout(filtersStopFunction, 15000);
    function filtersStopFunction() {
        clearInterval(filtersInterval);
    }
    function airinblog_fun_js_woo_filters() {

        $('.wc-blocks-filter-wrapper[hidden]').closest('.airinblog-css-widget-area .widget_block').removeClass('widget-block-box');

        let n2 = document.querySelectorAll('.airinblog-css-widget-area .widget_block .wc-block-review-list');
        $(n2).closest('.airinblog-css-widget-area .widget_block').addClass('widget-block-box');
        
    }

});