403Webshell
Server IP : 104.171.130.249  /  Your IP : 216.73.216.146
Web Server : nginx/1.25.5
System : Linux 0dac65491b7e 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/wp-content/themes/matreshka/assets/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wp-content/themes/matreshka/assets/js/wishlist.js
/**
 * Wishlist functionality for Matreshka theme
 */
jQuery(document).ready(function($) {
    'use strict';

    // Handle wishlist toggle
    $(document).on('click', '.like-icon', function(e) {
        e.preventDefault();
        e.stopPropagation();
        
        var $icon = $(this);
        // На single product id лежит на <a ... data-product-id>, а не на .single-product.
        // На карточках — на .product-card.
        var $holder = $icon.closest('[data-product-id]').first();
        var productId = $holder.data('product-id');

        if (!productId) {
            // fallback: атрибут
            productId = $holder.attr('data-product-id');
        }

        if (!productId) {
            // fallback: Woo form add-to-cart
            var $form = $icon.closest('form.cart');
            if ($form.length) {
                productId = $form.find('input[name="add-to-cart"]').val();
            }
        }
        
        if (!productId) {
            console.error('Product ID not found');
            return;
        }
        
        var isInWishlist = $icon.hasClass('active');
        var action = isInWishlist ? 'matreshka_remove_from_wishlist' : 'matreshka_add_to_wishlist';
        
        // Optimistic UI update
        $icon.toggleClass('active');
        updateHeartIcon($icon, !isInWishlist);
        
        $.ajax({
            url: matreshka_ajax.ajax_url,
            type: 'POST',
            data: {
                action: action,
                product_id: productId,
                nonce: matreshka_wishlist.nonce
            },
            success: function(response) {
                if (response.success) {
                    // Update all instances of this product's heart icon
                    $('[data-product-id="' + productId + '"]').find('.like-icon')
                        .toggleClass('active', !isInWishlist);
                    
                    // Update icon for all instances
                    $('[data-product-id="' + productId + '"]').find('.like-icon').each(function() {
                        updateHeartIcon($(this), !isInWishlist);
                    });
                    
                    // Show notification
                    var message = isInWishlist ? 'Товар удален из избранного' : 'Товар добавлен в избранное';
                    showNotification(message);
                } else {
                    // Revert on error
                    $icon.toggleClass('active');
                    updateHeartIcon($icon, isInWishlist);
                    showNotification('Произошла ошибка', 'error');
                }
            },
            error: function() {
                // Revert on error
                $icon.toggleClass('active');
                updateHeartIcon($icon, isInWishlist);
                showNotification('Произошла ошибка', 'error');
            }
        });
    });
    
    // Update heart icon source
    function updateHeartIcon($icon, isActive) {
        var iconSrc = isActive 
            ? matreshka_wishlist.heart_icon 
            : matreshka_wishlist.like_icon;
        $icon.attr('src', iconSrc);
    }
    
    // Show notification
    function showNotification(message, type) {
        type = type || 'success';
        
        // Remove existing notifications
        $('.wishlist-notification').remove();
        
        var $notification = $('<div>')
            .addClass('wishlist-notification montserrat-bold')
            .addClass('wishlist-notification-' + type)
            .text(message)
            .css({
                'position': 'fixed',
                'top': '50px',
                'right': '20px',
                'background': type === 'success' ? '#528a4dd9' : '#f44336',
                'color': '#fff',
                'padding': '15px 20px',
                'border-radius': '8px',
                'box-shadow': '0 4px 12px rgba(0, 0, 0, 0.15)',
                'z-index': '10000',
                'font-family': 'Montserrat, sans-serif',
                'font-weight': '500',
                'opacity': '0',
                'transform': 'translateY(-20px)',
                'transition': 'all 0.3s ease'
            });
        
        $('body').append($notification);
        
        // Animate in
        setTimeout(function() {
            $notification.css({
                'opacity': '1',
                'transform': 'translateY(0)'
            });
        }, 10);
        
        // Animate out and remove
        setTimeout(function() {
            $notification.css({
                'opacity': '0',
                'transform': 'translateY(-20px)'
            });
            setTimeout(function() {
                $notification.remove();
            }, 300);
        }, 3000);
    }
    
    // Initialize heart icons on page load
    function initializeHeartIcons() {
        $('.like-icon.active').each(function() {
            updateHeartIcon($(this), true);
        });
    }
    
    initializeHeartIcons();
});

Youez - 2016 - github.com/yon3zu
LinuXploit