HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/dailygoldindex/public_html/wp-content/plugins/jnews-essential/lib/vp/public/js/option.min.js
;(function($) {

    "use strict";

    // jQuery hacks
    var _addClass = $.fn.addClass;
    $.fn.addClass = function() {
        var result = _addClass.apply( this, arguments );
        if (this.prop('tagName') == 'BODY' && arguments[0] == 'folded') { calculatePositionAndSize(); }
        return result;
    };
    var _removeClass = $.fn.removeClass;
    $.fn.removeClass = function() {
        var result = _removeClass.apply( this, arguments );
        if (this.prop('tagName') == 'BODY' && arguments[0] == 'folded') { calculatePositionAndSize(); }
        return result;
    };

    // jQuery.browser hacks
    function uaMatch( ua ) {
        if ( ua === undefined ) {
            ua = window.navigator.userAgent;
        }
        ua = ua.toLowerCase();

        var match = /(edge)\/([\w.]+)/.exec( ua ) ||
         /(opr)[\/]([\w.]+)/.exec( ua ) ||
         /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
         /(iemobile)[\/]([\w.]+)/.exec( ua ) ||
         /(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
         /(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
         /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
         /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
         /(msie) ([\w.]+)/.exec( ua ) ||
         ua.indexOf( "trident" ) >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
         ua.indexOf( "compatible" ) < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || [];

        var platform_match = /(ipad)/.exec( ua ) ||
         /(ipod)/.exec( ua ) ||
         /(windows phone)/.exec( ua ) ||
         /(iphone)/.exec( ua ) ||
         /(kindle)/.exec( ua ) ||
         /(silk)/.exec( ua ) ||
         /(android)/.exec( ua ) ||
         /(win)/.exec( ua ) ||
         /(mac)/.exec( ua ) ||
         /(linux)/.exec( ua ) ||
         /(cros)/.exec( ua ) ||
         /(playbook)/.exec( ua ) ||
         /(bb)/.exec( ua ) ||
         /(blackberry)/.exec( ua ) || [];

        var browser = {},
         matched = {
             browser: match[5] || match[3] || match[1] || "",
             version: match[2] || match[4] || "0",
             versionNumber: match[4] || match[2] || "0",
             platform: platform_match[0] || ""
         };

        if ( matched.browser ) {
            browser[matched.browser] = true;
            browser.version = matched.version;
            browser.versionNumber = parseInt( matched.versionNumber, 10 );
        }

        if ( matched.platform ) {
            browser[matched.platform] = true;
        }

        if ( browser.android || browser.bb || browser.blackberry || browser.ipad || browser.iphone ||
         browser.ipod || browser.kindle || browser.playbook || browser.silk || browser["windows phone"] ) {
            browser.mobile = true;
        }

        if ( browser.cros || browser.mac || browser.linux || browser.win ) {
            browser.desktop = true;
        }

        if ( browser.chrome || browser.opr || browser.safari ) {
            browser.webkit = true;
        }

        if ( browser.rv || browser.iemobile ) {
            var ie = "msie";

            matched.browser = ie;
            browser[ie] = true;
        }

        if ( browser.edge ) {
            delete browser.edge;
            var msedge = "msedge";

            matched.browser = msedge;
            browser[msedge] = true;
        }

        if ( browser.safari && browser.blackberry ) {
            var blackberry = "blackberry";

            matched.browser = blackberry;
            browser[blackberry] = true;
        }

        if ( browser.safari && browser.playbook ) {
            var playbook = "playbook";

            matched.browser = playbook;
            browser[playbook] = true;
        }

        if ( browser.bb ) {
            var bb = "blackberry";

            matched.browser = bb;
            browser[bb] = true;
        }

        if ( browser.opr ) {
            var opera = "opera";

            matched.browser = opera;
            browser[opera] = true;
        }

        if ( browser.safari && browser.android ) {
            var android = "android";

            matched.browser = android;
            browser[android] = true;
        }

        if ( browser.safari && browser.kindle ) {
            var kindle = "kindle";

            matched.browser = kindle;
            browser[kindle] = true;
        }

        if ( browser.safari && browser.silk ) {
            var silk = "silk";

            matched.browser = silk;
            browser[silk] = true;
        }

        browser.name = matched.browser;
        browser.platform = matched.platform;
        return browser;
    }

    window.jquery_browser = uaMatch( window.navigator.userAgent );
    window.jquery_browser.uaMatch = uaMatch;

    if ( 'undefined' == typeof $.browser ) {
        $.browser = window.jquery_browser
    }

    var is_ie      = $.browser.msie;
    var ie_version = 0;

    if(is_ie)
    {
        ie_version = jQuery.browser.version;
        ie_version = parseFloat(ie_version);
    }

    // custom checkbox and radiobutton event binding
    vp.custom_check_radio_event(".vp-wrap", ".vp-field.vp-checked-field .field .input label");

    $(document).on('ready', function(){
        vp.init_controls($('.vp-wrap'));
    });

    /* BEGIN FETCHING ALL FIELDS' VALIDATION and BINDING RULES */
    var validation    = [];
    var bindings      = [];
    var items_binding = [];
    var dependencies  = [];
    var dep;
    $('.vp-menu-goto').each(function(i) {
        var href = $(this).attr('href'),
            $panel = $(href),
            fields = [];

        $panel.children('.vp-field').each(function(j) {
            var $field = $(this),
                name       = $field.attr('id'),
                rules      = $field.attr('data-vp-validation'),
                bind       = $field.attr('data-vp-bind'),
                items_bind = $field.attr('data-vp-items-bind'),
                type       = $field.getDatas().type,
                $input     = $('[name="' + name + '"]');

            dep = $field.attr('data-vp-dependency');

            dep         && dependencies.push({dep: dep, type: 'field', source: $field.attr('id')});
            bind        && bindings.push({bind: bind, type: type, source: name});
            items_bind  && items_binding.push({bind: items_bind, type: type, source: name});
            rules       && fields.push({name: name, rules: rules, type: type});
        });

        $panel.children('.vp-section').each(function(i) {
            var $section = $(this);

            dep = $section.attr('data-vp-dependency');
            dep && dependencies.push({dep: dep, type: 'section', source: $section.attr('id')});

            $section.find('.vp-field').each(function(j) {
                var $field     = $(this),
                    name       = $field.attr('id'),
                    rules      = $field.attr('data-vp-validation'),
                    bind       = $field.attr('data-vp-bind'),
                    items_bind = $field.attr('data-vp-items-bind'),
                    type       = $field.getDatas().type,
                    $input     = $('[name="' + name + '"]');

                dep = $field.attr('data-vp-dependency');

                dep         && dependencies.push({dep: dep, type: 'field', source: $field.attr('id')});
                bind        && bindings.push({bind: bind, type: type, source: name});
                items_bind  && items_binding.push({bind: items_bind, type: type, source: name});
                rules       && fields.push({name: name, rules: rules, type: type});

            });
        });

        if (fields.length > 0) validation.push({ name: href.trimChar('#'), fields: fields });
    });
    /* END FETCHING ALL FIELDS' VALIDATION and BINDING RULES */

    // get and click current hash
    $('.vp-js-menu-goto').on('click', function(e) {
        e.preventDefault();
        // add `_` prefix
        window.location.hash = '#_' + $(this).attr('href').substr(1);
        var $this     = $(this),
            $li       = $this.parent('li'),
            $parent   = $li.parents('li'),
            $siblings = $li.siblings('li'),
            $parent_siblings = $parent.siblings('li'),
            $panel    = $($this.attr('href'));
        $siblings.removeClass('vp-current');
        $parent_siblings.removeClass('vp-current');
        $parent.addClass('vp-current');
        $li.addClass('vp-current');
        $panel.siblings('.vp-panel').removeClass('vp-current');
        $panel.addClass('vp-current');
    });

    // goto current menu
    var hash = window.location.hash;
    if (hash !== '')
    {
        // remove `_` prefix
        hash = '#' + hash.substr(2);
        $('a[href="' + hash + '"]').trigger('click');
    }
    else
    {
        $('.vp-current > .vp-js-menu-goto').click();
    }

    $('.vp-js-menu-dropdown').on('click', function(e) {
        e.preventDefault();
        var $this = $(this),
            $parent = $this.parent('li'),
            $li = $parent.siblings('li'),
            $sub = $this.next('ul');
        if ($parent.hasClass('vp-current')) return;
        $li.removeClass('vp-current');
        $parent.addClass('vp-current');
        if($sub.children('li.vp-current').exists())
            $sub.children('li.vp-current').children('a').click();
        else
            $sub.children('li').first().children('a').click();
    });

    // Bindings
    for (var i = 0; i < bindings.length; i++)
    {
        var field = bindings[i],
            temp  = field.bind.split('|'),
            func  = temp[0],
            dest  = temp[1],
            ids   = [];

        dest = dest.split(/[\s,]+/);

        for (var j = 0; j < dest.length; j++)
        {
            ids.push(dest[j]);
        }

        for (var j = 0; j < ids.length; j++)
        {
            vp.binding_event(ids, j, field, func, '.vp-wrap', 'option');
        }
    }
    /* ============================================================ */

    // Items Binding
    for (var i = 0; i < items_binding.length; i++)
    {
        var field = items_binding[i],
            temp  = field.bind.split('|'),
            func  = temp[0],
            dest  = temp[1],
            ids   = [];

        dest = dest.split(/[\s,]+/);

        for (var j = 0; j < dest.length; j++)
        {
            ids.push(dest[j]);
        }

        for (var j = 0; j < ids.length; j++)
        {
            vp.items_binding_event(ids, j, field, func, '.vp-wrap', 'option');
        }
    }
    /* ============================================================ */

    // DEPENDENCY
    for (var i = 0; i < dependencies.length; i++)
    {
        var field = dependencies[i],
            temp  = field.dep.split('|'),
            func  = temp[0],
            dest  = temp[1],
            ids   = [];

        dest = dest.split(',');

        for (var j = 0; j < dest.length; j++)
        {
            ids.push(dest[j]);
        }

        for (var j = 0; j < ids.length; j++)
        {
            vp.dependency_event(ids, j, field, func, '.vp-wrap');
        }
    }

    // Ajax Saving
    $('.vp-js-option-form').on('submit', function(e) {
        e.preventDefault();

        // update tinyMCE textarea content
        vp.tinyMCE_save();

        $('.vp-js-option-form .vp-field').removeClass('vp-error');
        $('.validation-notif.vp-error').remove();
        $('.validation-msg.vp-error').remove();

        var allError = 0,
            menuNotifHTML = '<em class="validation-notif vp-error"></em>';

        for (var i=0; i<validation.length; i++)
        {
            var panel = validation[i];

            panel.nError = 0;
            panel.nError = vp.fields_validation_loop(panel.fields);

            if (panel.nError > 0)
            {
                // notify the menu which has the href
                var $notif  = $(menuNotifHTML),
                    $anchor = $('[href="#' + panel.name +'"]'),
                    $grandparent = $anchor.parent('li').parent('ul');
                $notif.appendTo($anchor);
                if ($grandparent.hasClass('vp-menu-level-2'))
                {
                    if ($grandparent.siblings('a').children('.validation-notif.vp-error').length === 0)
                    {
                        $notif.clone().appendTo($grandparent.siblings('a'));
                    }
                }
            }
            allError = allError + panel.nError;
        }

        // do not saving it any error occurs
        if (allError > 0) { return; }

        // otherwise, do saving
        var $loading = $('.vp-js-save-loader'),
            $button = $(this).find('.vp-save'),
            $save_status = $('.vp-js-save-status'),
            $form = $('#vp-option-form'),
            option = $form.serializeArray(),
            data = {
                action: 'vp_ajax_' + vp_opt.name + '_save',
                option: option,
                nonce : vp_opt.nonce
            };

        $button.attr('disabled', 'disabled');
        $loading.stop(true, true).fadeIn(100);

        $.post(ajaxurl, data, function(response) {
            $save_status.html(response.message);
            if (response.status)
            {
                $save_status.addClass('success');
            }
            else
            {
                $save_status.addClass('failed');
            }
            $loading.stop(true, true).fadeOut(100, function() {
                $save_status.stop(true, true).fadeIn(100);
            });

            setTimeout(function() {
                $button.removeAttr('disabled');
                $save_status.stop(true, true).fadeOut(1000, function() {
                    $save_status.removeClass('success').removeClass('failed');
                });
            }, 3000);
        }, 'JSON');

    });

    $('.vp-js-restore').on('click', function(e) {
        e.preventDefault();

        if (!confirm('The current options will be deleted, do you want to proceed?'))
            return;

        var $button = $(this),
            $parent = $button.parent(),
            $status = $parent.find('.vp-js-status'),
            $loader = $parent.find('.vp-js-loader'),
            data    = {action: 'vp_ajax_' + vp_opt.name + '_restore', nonce : vp_opt.nonce};

        $button.attr('disabled', 'disabled');
        $loader.fadeIn(100);

        $.post(ajaxurl, data, function(response) {
            $loader.fadeOut(0);
            switch(response.code)
            {
                case parseInt(vp_opt.SAVE_SUCCESS):
                    $status.html(vp_opt.util_msg.restore_success);
                    break;
                case parseInt(vp_opt.SAVE_NOCHANGES):
                    $status.html(vp_opt.util_msg.restore_nochanges);
                    break;
                case parseInt(vp_opt.SAVE_FAILED):
                    $status.html(vp_opt.util_msg.restore_failed + ': ' + response.message);
                    break;
            }
            $status.fadeIn(100);
            setTimeout(function() {
                $status.fadeOut(1000, function() {
                    $button.removeAttr('disabled');
                    $status.fadeOut(500);
                    if (response.code == parseInt(vp_opt.SAVE_SUCCESS))
                        location.reload();
                });
            }, 2000);
        }, 'JSON');
    });

    $('#vp-js-import').on('click', function(e) {
        e.preventDefault();

        var $textarea      = $('#vp-js-import_text'),
            $import_status = $('#vp-js-import-status'),
            $import_loader = $('#vp-js-import-loader'),
            $button        = $(this),
            data           = {action: 'vp_ajax_' + vp_opt.name + '_import_option', option: $textarea.val(), nonce : vp_opt.nonce};

        $button.attr('disabled', 'disabled');
        $import_loader.fadeIn(100);

        $.post(ajaxurl, data, function(response) {
            $import_loader.fadeOut(0);
            if (response.status)
            {
                $import_status.html(vp_opt.util_msg.import_success);
            }
            else
            {
                $import_status.html(vp_opt.util_msg.import_failed + ': ' + response.message);
            }
            $import_status.fadeIn(100);
            setTimeout(function() {
                $import_status.fadeOut(1000, function() {
                    $button.removeAttr('disabled');
                    $import_status.fadeOut(500);
                    if (response.status)
                        location.reload();
                });
            }, 2000);
        }, 'JSON');
    });

    $('#vp-js-export').on('click', function(e) {
        e.preventDefault();

        var $export_status = $('#vp-js-export-status'),
            $export_loader = $('#vp-js-export-loader'),
            $button        = $(this),
            data           = {action: 'vp_ajax_' + vp_opt.name + '_export_option', nonce : vp_opt.nonce};

        $button.attr('disabled', 'disabled');
        $export_loader.fadeIn(100);
        $.post(ajaxurl, data, function(response) {
            $export_loader.fadeOut(0);
            if (!$.isEmptyObject(response.option) && response.status)
            {
                $('#vp-js-export_text').val(response.option);
                $export_status.html(vp_opt.util_msg.export_success);
            }
            else
            {
                $export_status.html(vp_opt.util_msg.export_failed + ': ' + response.message);
            }
            $export_status.fadeIn(100);
            setTimeout(function() {
                $export_status.fadeOut(1000, function() {
                    $button.removeAttr('disabled');
                    $export_status.fadeOut(500);
                });
            }, 3000);
        }, 'JSON');
    });

    $(".vp-ajax-button > input").on('click', function(e){
        var $parent = $(this).parents(".vp-btn-ajax-call");
        var ajax_call = $(this).data('ajax-call');
        var $loader = $parent.find('.vp-ajax-button-response .vp-field-loader');
        var $ajaxnote = $parent.find('.vp-ajax-button-response .vp-ajax-response');
        var $button = $(this);

        var data = {
            action: ajax_call,
            nonce : vp_opt.nonce
        };

        // begin ajax call
        $loader.removeClass('vp-hide');
        $button.prop('disabled', true);
        $ajaxnote.text('');

        $.post(ajaxurl, data, function(response) {
            $loader.addClass('vp-hide');
            $button.prop('disabled', false);
            $ajaxnote.text(response);
        });
    });


}(jQuery));