// source --> https://visagieworkshopsamsterdam.com/wp-content/themes/joyas-pro/vendors/combo-woocommerce-wishlist/js/myfunction.js?ver=6.9.4 
jQuery(document).ready( function() {

   jQuery(".mywishlist").click( function() {

		var post_id = jQuery(this).attr("data-value"),
        $this   = jQuery(this);

	  jQuery.ajax({
         type : "post",
         dataType : "json",
         url : myAjax.ajaxurl,
         data : {action: "mywishlist", post_id : post_id},
		 beforeSend: function() {
			jQuery('.apww-wishlist-modal').find('.button-btn').attr("href", myAjax.wishlistUrl);
          jQuery('.apww-wishlist-modal').find('.main-icon').addClass('bi-arrow-through-heart').removeClass('bi-bar-chart');
        $this.addClass('loading');
		},
     success: function(json) {
			 $this.removeClass('loading');
		
             jQuery('.apww-wishlist-modal').addClass('active').find('.apww-txt').html(json['success']);
           
        }
      })   

   });
  
   jQuery(".removewhlist").click( function() {
		 var post_id = jQuery(this).attr("data-value"),
        $this   = jQuery(this);
	  jQuery.ajax({
         type : "post",
         dataType : "json",
         url : myAjax.ajaxurl,
         data : {action: "removewhlist", post_id : post_id},
          beforeSend: function() {
            $this.addClass('loading');
          },
         success: function(json) {
            //location.reload();
            $this.parents('li.product').remove();
            jQuery('.removewhlist').removeClass('loading');
         }
      })   
   });
 /* compare product */
  jQuery(".compareproduct").click( function() {
		var post_id = jQuery(this).attr("data-value")
	  jQuery.ajax({
         type : "post",
         dataType : "json",
         url : myAjax.ajaxurl,
         data : {action: "compare", post_id : post_id},
		  beforeSend: function() {
			jQuery('.compareproduct').after('<div  class="loading-compare-single"></div>');
		},
         success: function(json) {
		jQuery('.loading-compare-single').remove();	 

        jQuery('.apww-wishlist-modal').addClass('active').find('.apww-txt').html(json['success']);
            
		
	     }

      })   
   });
  /* compare loop product */
 jQuery(".compare-loop").click( function() {
		  var post_id = jQuery(this).attr("data-value"),
        $this   = jQuery(this);
	  jQuery.ajax({
         type : "post",
         dataType : "json",
         url : myAjax.ajaxurl,
         data : {action: "compare", post_id : post_id},
		  beforeSend: function() {

        jQuery('.apww-wishlist-modal').find('.button-btn').attr("href", myAjax.compareUrl);
          jQuery('.apww-wishlist-modal').find('.main-icon').addClass('bi-bar-chart').removeClass('bi-arrow-through-heart');

			$this.addClass('loading');
		},
        success: function(json) {
		jQuery('.loading-compare').remove();	 
    $this.removeClass('loading');
    
       jQuery('.apww-wishlist-modal').addClass('active').find('.apww-txt').html(json['success']);
            ;
	   
	     }
      })   
   });  
       jQuery(".removecompare").click( function() {
		   var post_id = jQuery(this).attr("data-value"),
           $this   = jQuery(this);
    	  jQuery.ajax({
             type : "post",
             dataType : "json",
             url : myAjax.ajaxurl,
             data : {action: "removecompare", post_id : post_id},
             success: function(json) {
               $this.parents('tr').remove();
                //location.reload();
             }
          })   
       });


       jQuery(".appw-modal-close-button").click( function() {
           jQuery('.apww-wishlist-modal').removeClass('active');
       });


       
   
 })

 
 jQuery(document).ready(function($) {    
    jQuery('#upload_image_button').click(function() {
        formfield = $('#link_image').attr('name'); 
        tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
        return false;
    });
	jQuery('#upload_image_button1').click(function() {
        formfield = $('#link_image').attr('name'); 
        tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
        return false;
    });

    window.send_to_editor = function(html) {
        imgurl = $('img',html).attr('src');
        imgsrc = '<img src="'+imgurl+'">';
        jQuery('#link_image').val(imgurl); // this populates a text field with the image url
        jQuery('#my-link-img').html(imgsrc); // this prints the image into a div
        tb_remove();
    }
});