1 2 3 4(function($){ 5 6 "use strict"; 7 8 var WooCommerce; 9 var $cartWrapper; 10 11 WooCommerce = { 12 13 init: function(){ 14 $cartWrapper = $('#ait-woocommerce-cart-wrapper'); 15 16 WooCommerce.cartDropdown(); 17 18 WooCommerce.productsContainerClasses(); 19 20 WooCommerce.productsCarousel($('#container ul.ait-products-carousel')); 21 22 WooCommerce.prodcutThumbnailsCarousel($('body.woocommerce-page').find('.product-details-wrapper .images > .thumbnails')); 23 24 WooCommerce.productReviews(); 25 26 WooCommerce.select2Class(); 27 }, 28 29 30 31 /** 32 * Cart Dropdown 33 */ 34 cartDropdown: function(){ 35 var $cart = $cartWrapper.find('#ait-woocommerce-cart').css({display: 'none', opacity: 0}); 36 37 if($cart.children().length){ 38 $cartWrapper.hover( 39 function(){ 40 $cart.css({display: 'block'}).stop().animate({opacity: 1}); 41 }, 42 function(){ 43 $cart.stop().animate( 44 {opacity: 0}, 45 function(){ 46 $cart.css({display:'none'}); 47 }); 48 } 49 ); 50 } 51 }, 52 53 54 55 /** 56 * Creates products carousel from shortcode 57 * @param {jQuery} $items Unordered list with products 58 */ 59 productsCarousel: function($items){ 60 if($items.length && $items.children().length){ 61 62 var $carouselWrraper = $('.ait-products-carousel-wrapper'), 63 $itemsWrapper = $('.ait-products-carousel-items-wrapper'); 64 65 $carouselWrraper.append('<a class="jcarousel-arrow jcarousel-prev" href="#"></a><a class="jcarousel-arrow jcarousel-next" href="#"></a>'); 66 67 $itemsWrapper.jcarousel({'animation': 'slow'}); 68 69 $carouselWrraper.find('.jcarousel-prev').jcarouselControl({target: '-=3'}); 70 $carouselWrraper.find('.jcarousel-next').jcarouselControl({target: '+=3'}); 71 } 72 }, 73 74 75 76 /** 77 * Creates product thumbnails carousel on product detail page 78 * @param {jQuery} $items Unordered list with products 79 */ 80 prodcutThumbnailsCarousel: function($items){ 81 if($items.length && $items.children().length){ 82 83 var $listWrapper = $items.wrapAll('<div class="ait-product-thumbnails-carousel" />').parent(); 84 85 var $carouselWrraper = $listWrapper.wrapAll('<div class="ait-product-thumbnails-carousel-wrapper" />').parent(); 86 87 $carouselWrraper.append('<a class="jcarousel-arrow jcarousel-prev" href="#"></a><a class="jcarousel-arrow jcarousel-next" href="#"></a>'); 88 89 $listWrapper.jcarousel({'animation': 'slow'}); 90 91 $carouselWrraper.find('.jcarousel-prev').jcarouselControl({target: '-=3'}); 92 $carouselWrraper.find('.jcarousel-next').jcarouselControl({target: '+=3'}); 93 } 94 }, 95 96 97 98 /** 99 * Adds classes with number of columns 100 */ 101 productsContainerClasses: function(){ 102 var $uls = $('#content ul.products:not(.ait-products-carousel)'), 103 defaultColumns = 4; // see woocommerce shortcodes default values 104 105 106 $uls.each(function(i){ 107 var $ul = $(this); 108 var lastIndex = $ul.children().index($ul.find('.last')); 109 var $children = $ul.children(); 110 var children = $children.length; 111 //var isSidebar = $('.sidebar').length; // old var 112 var hasSidebar = $('.sidebar-right-area').length || $('.sidebar-left-area').length; 113 114 lastIndex = lastIndex == -1 ? defaultColumns : lastIndex + 1; 115 116 // special case if there are just 5 items 117 if(children == 5 && lastIndex == 4 && !hasSidebar){ 118 $children.eq(lastIndex - 1).removeClass('last'); 119 $children.eq(lastIndex).attr('class', 'product last'); 120 lastIndex = 5; 121 } 122 123 if(lastIndex >= 3 && lastIndex <= 5) 124 $ul.addClass('columns-' + lastIndex); 125 }); 126 }, 127 128 /** 129 * Replace reviews form by popup window 130 */ 131 productReviews: function(){ 132 var reviewFormHref = $('.woocommerce-tabs #reviews .show_review_form').attr('href'); 133 var reviewFormHtml = $(reviewFormHref).clone(); 134 $(reviewFormHref).hide(); 135 $('.woocommerce-tabs #reviews a.show_review_form').colorbox({ 136 html: reviewFormHtml, 137 width: isResponsive(480)? "100%" : "50%", 138 className: 'ait-wc-product-review-form', 139 }); 140 141 $(document).bind('cbox_complete', function(e, test){ 142 if( $('#colorbox').hasClass('ait-wc-product-review-form') ){ 143 // resize colorbox content only for wc product review form 144 $.colorbox.resize(); 145 } 146 }); 147 }, 148 149 select2Class : function(){ 150 $('.woocommerce-page .woocommerce select').on("select2-open", function(){ 151 $('.select2-drop').addClass('ait-woocommerce-select2'); 152 }); 153 154 $('.woocommerce-page .woocommerce select').on("select2-close", function() { 155 $('.select2-drop').removeClass('ait-woocommerce-select2'); 156 }); 157 }, 158 159 /*productVariationsFormFix : function(){ 160 $('form.variations_form a.reset_variations').on('click', function(e){ 161 //e.preventDefault(); 162 var selectId; 163 var oldStyle; 164 165 $('form.variations_form select option').removeAttr('selected'); 166 $('form.variations_form select').selectbox('detach'); 167 $('form.variations_form select').selectbox({ 168 onOpen: function(inst){ 169 selectId = inst.settings.classHolder+"_"+inst.uid; 170 $("#"+selectId).attr('style', 'z-index: 100 !important'); 171 }, 172 onClose: function(inst){ 173 $("#"+selectId).delay(100).queue(function(next){ 174 $(this).removeAttr("style"); 175 next(); 176 }); 177 } 178 }); 179 }); 180 }*/ 181 }; 182 183 184 185 $(function(){ 186 WooCommerce.init(); 187 }); 188 189 /*$(window).on('load', function(){ 190 WooCommerce.productVariationsFormFix(); 191 });*/ 192 193 /* Fix for progressive preloading enabled */ 194 // woocemmerce updates the checkout form -> specially the payment types are loaded via ajax 195 $(document.body).on('updated_checkout', function(){ 196 var $container = $("body.woocommerce-page.woocommerce-checkout"); 197 if($container.hasClass('preloading-enabled')){ 198 var $element = $container.find('.elm-content-main'); 199 $element.find('img').each(function(){ 200 $(this).addClass('load-finished'); 201 }); 202 } 203 }); 204 /* Fix for progressive preloading enabled */ 205 206})(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.