// source --> https://sturzbuegel.de/wp-content/plugins/wp-mailster/asset/js/wpmstsubscribe.js?ver=6.9.4 
jQuery(function($){

    $(".wpmst-subscribe-form").submit(function(e) {
        console.log($(this));
        var formIdentifier = $(this).data('wpmstformid');
        console.log(formIdentifier);
        $('#subscr'+formIdentifier+' .subscribe-result').hide();
        $('#subscr'+formIdentifier+' .ajax_call_in_progress').show();

        var data = $('#subscr'+formIdentifier).serialize();

        $.post(wpmst_ajax_object.ajaxurl, data // serializes the form's elements.
        , function(data) {
                console.log(data);

                $('#subscr'+formIdentifier+' .ajax_call_in_progress').hide();
                var resultObj = JSON.parse(data);
                console.log(data);
                console.log(resultObj);
                $('#subscr'+formIdentifier+' .subscribe-result-success').html('');
                $('#subscr'+formIdentifier+' .subscribe-result-error').html('');
                $('#subscr'+formIdentifier+' .subscribe-result-errorMsgs').html('');
                if(resultObj.res == true){
                    $('#subscr'+formIdentifier+' .subscribe-result-success').html(resultObj.resultMsg);
                    var successMessageElement = $('#subscr'+formIdentifier+' .subscribe-result-success').detach();
                    $('#subscr'+formIdentifier).empty().append(successMessageElement);
                }else{
                    $('#subscr'+formIdentifier+' .subscribe-result-error').html(resultObj.resultMsg);
                    jQuery.each(resultObj.errorMsgs, function(index, item) {
                        $('#subscr'+formIdentifier+' .subscribe-result-errorMsgs').append('<span>'+item['msg']+'</span><br/>');
                    });
                }
                $('.subscribe-result').show();


        });
        e.preventDefault(); // avoid to execute the actual submit of the form.
    });

    $(".wpmst-unsubscribe-form").submit(function(e) {
        console.log($(this));
        var formIdentifier = $(this).data('wpmstformid');
        console.log(formIdentifier);
        $('#unsubscr'+formIdentifier+' .unsubscribe-result').hide();
        $('#unsubscr'+formIdentifier+' .ajax_call_in_progress').show();

        var data = $('#unsubscr'+formIdentifier).serialize();
        console.log(data);
        $.post(wpmst_ajax_object.ajaxurl, data // serializes the form's elements.
            , function(data) {
                console.log(data);

                $('#unsubscr'+formIdentifier+' .ajax_call_in_progress').hide();
                var resultObj = JSON.parse(data);
                console.log(data);
                console.log(resultObj);
                $('#unsubscr'+formIdentifier+' .unsubscribe-result-success').html('');
                $('#unsubscr'+formIdentifier+' .unsubscribe-result-error').html('');
                $('#unsubscr'+formIdentifier+' .unsubscribe-result-errorMsgs').html('');
                if(resultObj.res == true){
                    $('#unsubscr'+formIdentifier+' .unsubscribe-result-success').html(resultObj.resultMsg);
                    var successMessageElement = $('#unsubscr'+formIdentifier+' .unsubscribe-result-success').detach();
                    $('#unsubscr'+formIdentifier).empty().append(successMessageElement);
                }else{
                    $('#unsubscr'+formIdentifier+' .unsubscribe-result-error').html(resultObj.resultMsg);
                    jQuery.each(resultObj.errorMsgs, function(index, item) {
                        $('#unsubscr'+formIdentifier+' .unsubscribe-result-errorMsgs').append('<span>'+item['msg']+'</span><br/>');
                    });
                }
                $('.unsubscribe-result').show();


            });
        e.preventDefault(); // avoid to execute the actual submit of the form.
    });

});
// source --> https://sturzbuegel.de/wp-content/plugins/wp-media-folder/assets/js/single_image_lightbox/single_image_lightbox.js?ver=6.2.2 
(function ($) {
    $(document).ready(function () {
        if (jQuery().magnificPopup) {
            /* open lightbox when click to image */
            if ($('.wpmf_image_lightbox, .open-lightbox-feature-image').length) {
                $('.wpmf_image_lightbox, .open-lightbox-feature-image').magnificPopup({
                    gallery: {
                        enabled: true,
                        tCounter: '<span class="mfp-counter">%curr% / %total%</span>',
                        arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>' // markup of an arrow button
                    },
                    callbacks: {
                        elementParse: function (q) {
                            if (q.el.closest('a').length) {
                                q.src = q.el.closest('a').attr('href');
                            } else {
                                q.src = q.el.attr('src');
                            }
                        }
                    },
                    type: 'image',
                    showCloseBtn: false,
                    image: {
                        titleSrc: 'title'
                    }
                });
            }

            /* open lightbox when click to image */
            $('body a').each(function(i,v){
                if($(v).find('img[data-wpmflightbox="1"]').length !== 0){
                    $(v).magnificPopup({
                        delegate: 'img',
                        gallery: {
                            enabled: true,
                            tCounter: '<span class="mfp-counter">%curr% / %total%</span>',
                            arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>' // markup of an arrow button
                        },
                        callbacks: {
                            elementParse: function(q) { 
                                var wpmf_lightbox = q.el.data('wpmf_image_lightbox');
                                if(typeof wpmf_lightbox === "undefined"){
                                    q.src = q.el.attr('src'); 
                                }else{
                                    q.src = wpmf_lightbox; 
                                }
                            }
                        },
                        type: 'image',
                        showCloseBtn : false,
                        image: {
                            titleSrc: 'title'
                        }
                    });
                }
            });
        }
    });
})(jQuery);
// source --> https://sturzbuegel.de/wp-content/plugins/ultimate-member/assets/js/um-gdpr.min.js?ver=2.11.3 
jQuery(document).on("click","a.um-toggle-gdpr",function(e){var e=jQuery(e.currentTarget),t=e.closest(".um-field-area"),g=t.find(".um-gdpr-content");g.is(":visible")?(t.find("a.um-toggle-gdpr").text(e.data("toggle-show")),g.hide().find("a.um-toggle-gdpr").remove(),e.length&&e.get(0).scrollIntoView()):(t.find("a.um-toggle-gdpr").text(e.data("toggle-hide")),g.show().prepend(e.clone()))});