MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/www/support/wp-content/plugins/echo-widgets/js/public-scripts.js
jQuery(document).ready(function($) {

    /********************************************************************
     *                      Search
     ********************************************************************/

    // handle KB search form
    $( 'body' ).on( 'submit', '.widg-search-form', function( e ) {
        e.preventDefault();  // do not submit the form

        var this_form = $( this );

        if ( this_form.find('.widg-search-terms').val() === '' ) {
            return;
        }

        var postData = {
            action: 'widg-search-kb',
            widg_kb_id: this_form.find('#widg_kb_id').val(),
            search_words: this_form.find('.widg-search-terms').val()
        };

        var msg = '';

        $.ajax({
            type: 'GET',
            dataType: 'json',
            data: postData,
            url: widg_vars.ajaxurl,
            beforeSend: function (xhr)
            {
                //Loading Spinner
                this_form.find( '.widg-loading-spinner').css( 'display','block');
                this_form.find('#widg-ajax-in-progress').show();
            }

        }).done(function (response) {
            response = ( response ? response : '' );

            //Hide Spinner
            this_form.find( '.widg-loading-spinner').css( 'display','none');

            if ( response.error || response.status !== 'success') {
                //noinspection JSUnresolvedVariable
                msg = widg_vars.msg_try_again;
            } else {
                msg = response.search_result;
            }

        }).fail(function (response, textStatus, error) {
            //noinspection JSUnresolvedVariable
            msg = widg_vars.msg_try_again + '. [' + ( error ? error : widg_vars.unknown_error ) + ']';

        }).always(function () {
            this_form.find('#widg-ajax-in-progress').hide();

            if ( msg ) {
                this_form.find( '.widg-search-results' ).css( 'display','block' );
                this_form.find( '.widg-search-results' ).html( msg );

            }

        });
    });

    $(".widg-search-terms").on( 'keyup', function() {

        if (!this.value) {
            $('.widg-search-results').css( 'display','none' );
        }

    });

    // Hide Search results when click triggered.
    $( 'body' ).on( 'click', function() {
        $( '.widg-search-results' ).hide();
    });
});