PageSourceSearch

https://jobmatchingbd.com/wp-content/themes/superio/js/woocommerce.js?ver=20150330

js jobmatchingbd.com collected 2026-10-07 00:56:50 UTC 11,271 bytes, 272 lines download raw bytes

1(function($) {
2    "use strict";
3    
4    $.extend($.apusThemeCore, {
5        /**
6         *  Initialize scripts
7         */
8        woo_init: function() {
9            var self = this;
10
11            self.productDetail();
12
13            $( 'body' ).on( 'found_variation', function( event, variation ) {
14                self.variationsImageUpdate(variation);
15            });
16
17            $( 'body' ).on( 'reset_image', function( event, variation ) {
18                self.variationsImageUpdate(variation);
19            });
20            $('body').on('hover', '.apus-topcart .cart_list', function(){
21                $(this).perfectScrollbar();
22            });
23            
24        },
25        productDetail: function(){
26            // review click link
27            $('.woocommerce-review-link').on('click', function(){
28                $('.woocommerce-tabs a[href="#tabs-list-reviews"]').trigger('click');
29                $('html, body').animate({
30                    scrollTop: $("#reviews").offset().top
31                }, 1000);
32                return false;
33            });
34        },
35        variationsImageUpdate: function( variation ) {
36            var $form             = $('.variations_form'),
37                $product          = $form.closest( '.product' ),
38                $product_gallery  = $product.find( '.apus-woocommerce-product-gallery-wrapper' ),
39                $gallery_img      = $product.find( '.apus-woocommerce-product-gallery-thumbs img:eq(0)' ),
40                $product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ),
41                $product_img      = $product_img_wrap.find( '.wp-post-image' ),
42                $product_link     = $product_img_wrap.find( 'a' ).eq( 0 );
43
44
45            if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) {
46                
47                if ( $( '.apus-woocommerce-product-gallery-thumbs img[src="' + variation.image.thumb_src + '"]' ).length > 0 ) {
48                    $( '.apus-woocommerce-product-gallery-thumbs img[src="' + variation.image.thumb_src + '"]' ).trigger( 'click' );
49                    $form.attr( 'current-image', variation.image_id );
50                    return;
51                } else {
52                    $product_img.wc_set_variation_attr( 'src', variation.image.src );
53                    $product_img.wc_set_variation_attr( 'height', variation.image.src_h );
54                    $product_img.wc_set_variation_attr( 'width', variation.image.src_w );
55                    $product_img.wc_set_variation_attr( 'srcset', variation.image.srcset );
56                    $product_img.wc_set_variation_attr( 'sizes', variation.image.sizes );
57                    $product_img.wc_set_variation_attr( 'title', variation.image.title );
58                    $product_img.wc_set_variation_attr( 'alt', variation.image.alt );
59                    $product_img.wc_set_variation_attr( 'data-src', variation.image.full_src );
60                    $product_img.wc_set_variation_attr( 'data-large_image', variation.image.full_src );
61                    $product_img.wc_set_variation_attr( 'data-large_image_width', variation.image.full_src_w );
62                    $product_img.wc_set_variation_attr( 'data-large_image_height', variation.image.full_src_h );
63                    $product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src );
64                    $gallery_img.wc_set_variation_attr( 'src', variation.image.thumb_src );
65                    $gallery_img.wc_set_variation_attr( 'srcset', variation.image.thumb_srcset );
66
67                    $product_link.wc_set_variation_attr( 'href', variation.image.full_src );
68                    $gallery_img.removeAttr('srcset');
69                    $('.apus-woocommerce-product-gallery').slick('slickGoTo', 0);
70                    
71                }
72            } else {
73                $product_img.wc_reset_variation_attr( 'src' );
74                $product_img.wc_reset_variation_attr( 'width' );
75                $product_img.wc_reset_variation_attr( 'height' );
76                $product_img.wc_reset_variation_attr( 'srcset' );
77                $product_img.wc_reset_variation_attr( 'sizes' );
78                $product_img.wc_reset_variation_attr( 'title' );
79                $product_img.wc_reset_variation_attr( 'alt' );
80                $product_img.wc_reset_variation_attr( 'data-src' );
81                $product_img.wc_reset_variation_attr( 'data-large_image' );
82                $product_img.wc_reset_variation_attr( 'data-large_image_width' );
83                $product_img.wc_reset_variation_attr( 'data-large_image_height' );
84                $product_img_wrap.wc_reset_variation_attr( 'data-thumb' );
85                $gallery_img.wc_reset_variation_attr( 'src' );
86                $product_link.wc_reset_variation_attr( 'href' );
87            }
88
89            window.setTimeout( function() {
90                $( window ).trigger( 'resize' );
91                $form.wc_maybe_trigger_slide_position_reset( variation );
92                $product_gallery.trigger( 'woocommerce_gallery_init_zoom' );
93            }, 20 );
94        }
95    });
96
97    $.apusThemeExtensions.shop = $.apusThemeCore.woo_init;
98
99
100    // gallery
101
102    var ApusProductGallery = function( $target, args ) {
103        var self = this;
104        this.$target = $target;
105        this.$images = $( '.woocommerce-product-gallery__image', $target );
106
107        // No images? Abort.
108        if ( 0 === this.$images.length ) {
109            this.$target.css( 'opacity', 1 );
110            return;
111        }
112
113        // Make this object available.
114        $target.data( 'product_gallery', this );
115
116        // Pick functionality to initialize...
117        this.zoom_enabled       = $.isFunction( $.fn.zoom ) && wc_single_product_params.zoom_enabled;
118        this.photoswipe_enabled = typeof PhotoSwipe !== 'undefined' && wc_single_product_params.photoswipe_enabled;
119
120        // ...also taking args into account.
121        if ( args ) {
122            this.zoom_enabled       = false === args.zoom_enabled ? false : this.zoom_enabled;
123            this.photoswipe_enabled = false === args.photoswipe_enabled ? false : this.photoswipe_enabled;
124        }
125
126        
127
128        // Bind functions to this.
129        this.initZoom             = this.initZoom.bind( this );
130        this.initZoomForTarget    = this.initZoomForTarget.bind( this );
131        this.initPhotoswipe       = this.initPhotoswipe.bind( this );
132        this.getGalleryItems      = this.getGalleryItems.bind( this );
133        this.openPhotoswipe       = this.openPhotoswipe.bind( this );
134
135            this.$target.css( 'opacity', 1 );
136
137        if ( this.zoom_enabled ) {
138            this.initZoom();
139            $target.on( 'woocommerce_gallery_init_zoom', this.initZoom );
140        }
141
142        if ( this.photoswipe_enabled ) {
143            this.initPhotoswipe();
144        }
145
146        $('.apus-woocommerce-product-gallery').on('beforeChange', function(event, slick, currentSlide, nextSlide){
147            self.initZoomForTarget( self.$images.eq(nextSlide) );
148        });
149    };
150
151
152    /**
153     * Init zoom.
154     */
155    ApusProductGallery.prototype.initZoom = function() {
156        this.initZoomForTarget( this.$images.first() );
157    };
158
159    /**
160     * Init zoom.
161     */
162    ApusProductGallery.prototype.initZoomForTarget = function( zoomTarget ) {
163        if ( ! this.zoom_enabled ) {
164            return false;
165        }
166
167        var galleryWidth = this.$target.width(),
168            zoomEnabled  = false;
169
170        $( zoomTarget ).each( function( index, target ) {
171            var image = $( target ).find( 'img' );
172
173            if ( image.data( 'large_image_width' ) > galleryWidth ) {
174                zoomEnabled = true;
175                return false;
176            }
177        } );
178
179        // But only zoom if the img is larger than its container.
180        if ( zoomEnabled ) {
181            var zoom_options = {
182                touch: false
183            };
184
185            if ( 'ontouchstart' in window ) {
186                zoom_options.on = 'click';
187            }
188
189            zoomTarget.trigger( 'zoom.destroy' );
190            zoomTarget.zoom( zoom_options );
191        }
192    };
193
194    /**
195     * Init PhotoSwipe.
196     */
197    ApusProductGallery.prototype.initPhotoswipe = function() {
198        if ( this.zoom_enabled && this.$images.length > 0 ) {
199            this.$target.prepend( '<a href="#" class="woocommerce-product-gallery__trigger"><i class="fa fa-search-plus" aria-hidden="true"></i></a>' );
200            this.$target.on( 'click', '.woocommerce-product-gallery__trigger', this.openPhotoswipe );
201        }
202        // this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
203    };
204
205    /**
206     * Get product gallery image items.
207     */
208    ApusProductGallery.prototype.getGalleryItems = function() {
209        var $slides = this.$images,
210            items   = [];
211
212        if ( $slides.length > 0 ) {
213            $slides.each( function( i, el ) {
214                var img = $( el ).find( 'img' ),
215                    large_image_src = img.attr( 'data-large_image' ),
216                    large_image_w   = img.attr( 'data-large_image_width' ),
217                    large_image_h   = img.attr( 'data-large_image_height' ),
218                    item            = {
219                        src  : large_image_src,
220                        w    : large_image_w,
221                        h    : large_image_h,
222                        title: img.attr( 'data-caption' ) ? img.attr( 'data-caption' ) : img.attr( 'title' )
223                    };
224                items.push( item );
225            } );
226        }
227
228        return items;
229    };
230
231    /**
232     * Open photoswipe modal.
233     */
234    ApusProductGallery.prototype.openPhotoswipe = function( e ) {
235        e.preventDefault();
236
237        var pswpElement = $( '.pswp' )[0],
238            items       = this.getGalleryItems(),
239            eventTarget = $( e.target ),
240            clicked;
241
242        if ( this.$target.find( '.woocommerce-product-gallery__image.slick-current' ).length > 0 ) {
243            clicked = this.$target.find( '.woocommerce-product-gallery__image.slick-current' );
244        } else {
245            clicked = eventTarget.closest( '.woocommerce-product-gallery__image' );
246        }
247        var options = $.extend( {
248            index: $( clicked ).index()
249        }, wc_single_product_params.photoswipe_options );
250
251        // Initializes and opens PhotoSwipe.
252        var photoswipe = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options );
253        photoswipe.init();
254    };
255
256    /**
257     * Function to call wc_product_gallery on jquery selector.
258     */
259    $.fn.apus_wc_product_gallery = function( args ) {
260        new ApusProductGallery( this, args );
261        return this;
262    };
263
264    /*
265     * Initialize all galleries on page.
266     */
267    $( '.apus-woocommerce-product-gallery-wrapper' ).each( function() {
268        $( this ).apus_wc_product_gallery();
269    } );
270
271    
272})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.