// source --> https://kviztenger.hu/wp-content/plugins/wp-viral-quiz_old/includes/plugin-updates/js/debug-bar.js?ver=20121026 
jQuery(function($) {

	function runAjaxAction(button, action) {
		button = $(button);
		var panel = button.closest('.puc-debug-bar-panel');
		var responseBox = button.closest('td').find('.puc-ajax-response');

		responseBox.text('Processing...').show();
		$.post(
			ajaxurl,
			{
				action  : action,
				slug    : panel.data('slug'),
				_wpnonce: panel.data('nonce')
			},
			function(data) {
				responseBox.html(data);
			},
			'html'
		);
	}

	$('.puc-debug-bar-panel input[name="puc-check-now-button"]').click(function() {
		runAjaxAction(this, 'puc_debug_check_now');
		return false;
	});

	$('.puc-debug-bar-panel input[name="puc-request-info-button"]').click(function() {
		runAjaxAction(this, 'puc_debug_request_info');
		return false;
	});


	// Debug Bar uses the panel class name as part of its link and container IDs. This means we can
	// end up with multiple identical IDs if more than one plugin uses the update checker library.
	// Fix it by replacing the class name with the plugin slug.
	var panels = $('#debug-menu-targets').find('.puc-debug-bar-panel');
	panels.each(function(index) {
		var panel = $(this);
		var slug = panel.data('slug');
		var target = panel.closest('.debug-menu-target');

		//Change the panel wrapper ID.
		target.attr('id', 'debug-menu-target-puc-' + slug);

		//Change the menu link ID as well and point it at the new target ID.
		$('#puc-debug-menu-link-' + panel.data('slug'))
			.closest('.debug-menu-link')
			.attr('id', 'debug-menu-link-puc-' + slug)
			.attr('href', '#' + target.attr('id'));
	});
});
// source --> https://kviztenger.hu/wp-content/plugins/ad-ace/assets/js/slideup.js?ver=1.3.2 
/* global jQuery */
/* global document */

(function($) {

	'use strict';

	$(document).ready(function(){
		slideUp();
	});

	var createCookie = function (name, value, time) {
        var expires;

        if (time) {
            var date = new Date();
            var ms = time;

            if (typeof time === 'object') {
                ms = time.value;

                switch (time.type) {
                    case 'days':
                        ms = ms * 24 * 60 * 60 * 1000;
                        break;
                }
            }

            date.setTime(date.getTime() + ms);
            expires = '; expires=' + date.toGMTString();
        }
        else {
            expires = '';
        }

        document.cookie = name + '=' + value + expires + '; path=/';
	};
	var readCookie = function (name) {
        var nameEQ = name + '=';
        var ca = document.cookie.split(';');

        for (var i = 0; i < ca.length; i += 1) {
            var c = ca[i];
            while (c.charAt(0) === ' ') {
                c = c.substring(1, c.length);
            }

            if (c.indexOf(nameEQ) === 0) {
                return c.substring(nameEQ.length, c.length);
            }
        }

        return null;
    };

	var slideUp = function() {
		var
	 	$slideUpSlotWrap = $('.adace-slideup-slot-wrap'),
		$slideUpCloserBtn = $slideUpSlotWrap.find('.adace-slideup-slot-closer'),
		SlideupCookie = readCookie('adace_slideup_disabled');
		$slideUpCloserBtn.on('click', function(e) {
			e.preventDefault();
			$slideUpSlotWrap.addClass('hidden');
			createCookie('adace_slideup_disabled', 1, 24 * 60 * 60 * 1000);
		});

		if ( SlideupCookie ) {
            $slideUpSlotWrap.remove();
        }
	};

})(jQuery);
// source --> https://kviztenger.hu/wp-content/plugins/ad-ace/includes/shoppable-images/assets/js/shoppable-images-front.js?ver=1.3.2 
/**************************
 *
 * document ready functions
 *
 *************************/

(function ($) {

    'use strict';

    $(document).ready(function () {
		$('.shoppable-image').each(function() {
			shoppable_image($(this));
		});

		$('body').on('shoppableImages', function(e, $content) {
			$content.find('.shoppable-image').each(function() {
				shoppable_image($(this));
			});
		});
    });

    var shoppable_image = function (ThisImagemap) {
		if (ThisImagemap.data('aceShoppableImageLoaded')) {
			return;
		}

		var
		Map     = ThisImagemap.find('.shoppable-image-map'),
		HideBtn = ThisImagemap.find('.shoppable-image-hideshow-btn');
		new Waypoint({
			element: ThisImagemap,
			handler: function (direction) {
				if (direction === 'down') {
					ThisImagemap.addClass('pins-visible');
				} else {
					ThisImagemap.removeClass('pins-visible');
				}
			},
			offset : '80%'
		});
		HideBtn.click(function(e){
			e.preventDefault();
			Map.toggleClass('hide-pins');
		});
		shoppable_image_resize(ThisImagemap);
		$(window).resize(function () {
			shoppable_image_resize(ThisImagemap);
		});

		ThisImagemap.data('aceShoppableImageLoaded', true);
	};

	var shoppable_image_resize = function(ThisImagemap){
		var
		Pins = ThisImagemap.find('.shoppable-image-pin');
		Pins.each(function(){
			var
			ThisPinBody = $(this).find('.shoppable-image-pin-body');
			ThisPinBody.css({ "margin-left": "auto"  });
			var
			BodyRect = ThisPinBody[0].getBoundingClientRect(),
			OffsetLeft = BodyRect.x,
			OffsetRight = ( BodyRect.x + BodyRect.width ) - window.innerWidth;
			if( OffsetLeft < 0 ) {
				ThisPinBody.css({ "margin-left": -OffsetLeft + 'px' });
			}
			if ( OffsetRight > 0 ) {
				ThisPinBody.css({ "margin-left": -OffsetRight + 'px' });
			}
		});
	};

})(jQuery);
// source --> https://kviztenger.hu/wp-content/plugins/ad-ace/assets/js/coupons.js?ver=1.3.2 
/* global jQuery */
/* global document */

(function($) {

	'use strict';

	$(document).ready(function(){
		copyCoupon();
	});

	var copyCoupon = function() {
		var
		Coupons = $('.adace-coupon-wrap');
		Coupons.each(function(){
			if ( $(this).hasClass('active') ){
				return;
			} else {
				$(this).addClass('active');
			}
			var
			CopyBtn        = $(this).find('.coupon-copy'),
			CopyAction     = $(this).find('.coupon-action'),
			CopyActionText = CopyAction.text(),
			CopyCode       = $(this).find('.coupon-code'),
			CopyCodeText   = CopyCode.text();
			CopyBtn.click(function(e){
				e.preventDefault();

				// Create element for this pin.
				var CopyArea = $('<input class="copy-area" style="visibillity:hidden;" value="' + CopyCodeText + '" />');

				// Copy code
				CopyCode.prepend(CopyArea);

				CopyArea = $('.copy-area');

				CopyArea.select();

				try {
					document.execCommand('copy');
				} catch (err) {
					alert( 'This feature is not supported in your browser, please copy the coupon manually.');
					$('.adace-coupon-code').select();
				}

				CopyArea.blur().remove();

				if( CopyBtn.hasClass('copied') ){
					return;
				}

				CopyBtn.addClass('copied blink');

				setTimeout(function(){
					CopyAction.html(CopyAction.data('copied'));
					CopyBtn.removeClass('blink');
				}, 375);

				setTimeout(function(){
					CopyBtn.addClass('blink');
				}, 4625);

				setTimeout(function(){
					CopyAction.html(CopyActionText);
					CopyBtn.removeClass('copied blink');
				}, 5000);
			});
		});
	};

})(jQuery);