front end ninja
Контакты

Достижения

Все достижения (4)

Наибольший вклад в теги

Все теги (18)

Лучшие ответы пользователя

Все ответы (4)
  • Как сделать фон иконки под размер иконки?

    @alex5792 Автор вопроса
    front man
    bb730b65e4a24254b5fbae803c81613f.jpg
    Ответ написан
    Комментировать
  • Не выполняется скрипт при нажатии?

    @alex5792 Автор вопроса
    front man
    Вот код кнопки
    <a href="#" class="button yith-wcqv-button" data-product_id="389">Quick View</a>


    А вот сам скрипт плагина
    /**
     * frontend.js
     *
     * @author Your Inspiration Themes
     * @package YITH WooCommerce Quick View
     * @version 1.0.0
     */
    
    jQuery(document).ready(function($){
        "use strict";
    
        var buttons     = '',
            qv_modal    = '',
            qv_content  = '',
            qv_close    = '',
            qv_nav      = '',
            products_ids = [],
            center_modal = function() {
    
                var t = $(document).find( '.yith-quick-view .yith-wcqv-wrapper' ),
                    window_w = $(window).width(),
                    window_h = $(window).height(),
                    width    = ( ( window_w - 60 ) > yith_qv.popup_size_width ) ? yith_qv.popup_size_width : ( window_w - 60 ),
                    height   = ( ( window_h - 120 ) > yith_qv.popup_size_height ) ? yith_qv.popup_size_height : ( window_h - 120 );
    
                t.css({
                    'left' : (( window_w/2 ) - ( width/2 )),
                    'top' : (( window_h/2 ) - ( height/2 )),
                    'width'     : width + 'px',
                    'height'    : height + 'px'
                });
            };
    
        if( typeof yith_qv === 'undefined' ) {
            return;
        }
    
        /*==================
         * INIT PLUGIN
         ==================*/
    
        $.fn.yith_wcqv_init = function() {
    
            buttons     = $(document).find( '.yith-wcqv-button' );
            qv_modal    = yith_qv.type != 'yith-inline' ? $(document).find( '.yith-quick-view' ) : $(document).find( '.yith-quick-view' ).clone();
            qv_content  = qv_modal.find( '.yith-quick-view-content' );
            qv_close    = qv_modal.find( '.yith-quick-view-close' );
            qv_nav      = qv_modal.find( '.yith-quick-view-nav' );
    
    
            // build products id array
            $.each( buttons, function(){
                var product_id = $(this).data('product_id');
                if( $.inArray( product_id, products_ids ) == -1 ) {
                    products_ids.push( product_id );
                }
            } );
    
            // nav event
            if( qv_nav.length ) {
                nav_ajax_call(qv_nav);
            }
            // close event
            close_modal_qv( qv_close );
    
            // responsive
            if( yith_qv.type != 'yith-inline' ) {
                center_modal();
                $( window ).on( 'resize', center_modal );
            }
    
            // off old event ( prevent multiple open )
            buttons.off( 'click' );
    
            // calculate position
            if( buttons.hasClass( 'inside-thumb' ) ) {
                imagesLoaded( qv_content, function(){
                    button_position( buttons );
                });
            }
    
            $(document).on( 'click', '.yith-wcqv-button', function(e){
    
                var t           = $(this),
                    data_type   = t.data('type'),
                    product_id  = t.data( 'product_id' );
    
                if( ! product_id ) {
                    return;
                }
    
                e.preventDefault();
    
                if( ! yith_qv.enable_loading ) {
                    qv_loader( t );
                }
    
                // if is inline move modal
                if ( yith_qv.type == 'yith-inline' ) {
    
                    var elem        = t.parents( yith_qv.main_product ),
                        last_elem   = ( elem.hasClass( 'last' ) ) ? elem : elem.nextUntil( '.first', '.last' );
    
                    if( ! last_elem.length ){
                        last_elem = t.closest( '.products' ).find( yith_qv.main_product ).last();
                    }
    
    
                    if( last_elem.next( '.yith-quick-view' ).length ) {
                        // if in same row of li call qv_loader
                        qv_loader( qv_content );
                    }
                    else if ( qv_modal.hasClass('open') ) {
                        // if in another row close it and move
                        qv_modal.removeClass('open').removeClass('loading');
    
                        qv_modal.slideUp( 'slow', function(){
                            last_elem.after( qv_modal );
    
                            // ajax call
                            ajax_call( t, product_id );
                        });
    
                        return;
                    }
                    else {
                        // and move it
                        last_elem.after( qv_modal );
                    }
                }
                else {
                    // add loading effect
                    $(document).trigger( 'qv_loading' );
                }
    
                ajax_call( t, product_id );
    
            });
        };
    
        /*=====================
        * MAIN BUTTON POSITION
         =======================*/
    
        var button_position = function( buttons ){
    
            var img_height = $(document).find( 'img.attachment-shop_catalog' ).height(),
                trigger_h = buttons.height();
    
            // add position
            buttons.css({
                'top'     : ( img_height - trigger_h ) / 2 + 'px'
    Ответ написан
    Комментировать

Лучшие вопросы пользователя

Все вопросы (110)