1;(function($){ 2 "use strict"; 3 4 var WooLentorQuickView = { 5 6 body: $('body'), 7 modal: $('#woolentor-quickview-modal'), 8 modalbody: $('.woolentor-quickview-modal-body'), 9 10 /** 11 * [init] 12 * @return {[void]} Initial Function 13 */ 14 init: function(){ 15 this.wrapperHeight(); 16 $( document ) 17 .on( 'click.WooLentorQuickView', 'a.woolentor-quickview-btn,.woolentorquickview', this.openQuickView ) 18 .on( 'click.WooLentorQuickView', '.woolentor-quickview-modal-close', this.closeQuickView ) 19 .on( 'click.WooLentorQuickView', '.woolentor-quickview-overlay', this.closeQuickView ); 20 21 $( document ).keyup( this.closeKeyUp ); 22 23 if( woolentorQuickView.optionData['enableAjaxCart'] === 'on' ){ 24 $( document ).on( 'click.WooLentorQuickView', '.woolentor-quickview-modal-content .woolentorquickview-content-template:not(.external) .single_add_to_cart_button:not(.disabled)', this.addToCart ); 25 } 26 27 }, 28 29 /** 30 * [openQuickView] Open quickview 31 * @param event 32 * @return {[void]} 33 */ 34 openQuickView: function( event ){ 35 event.preventDefault(); 36 37 var $this = $(this), 38 id = $this.data('product_id'); 39 40 WooLentorQuickView.modalbody.html(''); /*clear content*/ 41 WooLentorQuickView.body.addClass('woolentor-quickview-loader'); 42 43 $this.addClass('loading'); 44 WooLentorQuickView.modal.addClass('loading'); 45 46 $.ajax({ 47 url: woolentorQuickView.ajaxUrl, 48 data: { 49 action: 'woolentor_quickview', 50 id: id, 51 nonce: woolentorQuickView.ajaxNonce, 52 }, 53 method: 'POST', 54 success: function (response) { 55 if ( response ) { 56 WooLentorQuickView.body.removeClass('woolentor-quickview-loader'); 57 WooLentorQuickView.modal.removeClass('loading').addClass('woolentor-quickview-open'); 58 $this.removeClass('loading'); 59 60 WooLentorQuickView.modalbody.html( response ); 61 WooLentorQuickView.variation( WooLentorQuickView.modalbody ); 62 63 $(document).trigger('woolentor_quick_view_rendered'); 64 65 if( woolentorQuickView.optionData['thumbnailLayout'] === 'slider' ){ 66 WooLentorQuickView.imageSlider(); 67 } 68 69 } else { 70 console.log( 'Something wrong loading fetching product data' ); 71 } 72 }, 73 error: function (response) { 74 console.log('Something wrong with AJAX response.'); 75 }, 76 complete: function () { 77 $this.removeClass('loading'); 78 }, 79 }); 80 81 }, 82 83 /** 84 * [variation] Product variation data manager 85 * @param {[String]} $container 86 * @return {[void]} 87 */ 88 variation: function( $container ){ 89 90 var $formvariation = $container.find('.variations_form'); 91 $formvariation.each( function() { 92 $( this ).wc_variation_form(); 93 }); 94 95 $formvariation.trigger( 'check_variations' ); 96 $formvariation.trigger( 'reset_image' ); 97 98 if( typeof $.fn.wc_product_gallery !== 'undefined' ) { 99 $container.find('.woocommerce-product-gallery').each( function () { 100 $(this).wc_product_gallery(); 101 } ); 102 } 103 104 if( woolentorQuickView.optionData['thumbnailLayout'] === 'slider' ){ 105 WooLentorQuickView.variationData( $container ); 106 } 107 108 }, 109 110 /** 111 * [variationData] Manage varition data 112 * @param {[String]} $product 113 * @return {[void]} 114 */ 115 variationData: function( $product ){ 116 117 $( '.single_variation_wrap' ).on( 'show_variation', function ( event, variation ) { 118 $product.find('.woolentor-quickview-main-image-slider').slick('slickGoTo', 0); 119 }); 120 121 }, 122 123 /** 124 * [closeQuickView] Close quickview 125 * @param event 126 * @return {[void]} 127 */ 128 closeQuickView: function( event ) { 129 event.preventDefault(); 130 WooLentorQuickView.modal.removeClass('woolentor-quickview-open'); 131 }, 132 133 /** 134 * [closeKeyUp] Close quickview after press ESC Button 135 * @param event 136 * @return {[void]} 137 */ 138 closeKeyUp: function(event){ 139 if( event.keyCode === 27 ){ 140 WooLentorQuickView.modal.removeClass('woolentor-quickview-open'); 141 } 142 }, 143 144 /** 145 * [wrapperHeight] Manage Modal wrapper height 146 * @return {[void]} 147 */ 148 wrapperHeight: function(){ 149 var window_width = $(window).width(), 150 window_height = $(window).height(); 151 152 $('.woolentor-quickview-modal-wrapper').css({"max-height": ( window_height-150 )+"px"}); 153 }, 154 155 /* 156 * Cuctom image slider 157 */ 158 MainImageSlider: function(){ 159 $('.woolentor-quickview-main-image-slider').slick({ 160 slidesToShow: 1, 161 slidesToScroll: 1, 162 arrows: true, 163 fade: true,
164 asNavFor: '.woolentor-quickview-thumbnail-slider', 165 prevArrow: '<span class="woolentor-quickview-slick-prev">←</span>', 166 nextArrow: '<span class="woolentor-quickview-slick-next">→</span>', 167 }); 168 }, 169 ThumbnailSlider: function(){ 170 $('.woolentor-quickview-thumbnail-slider').slick({ 171 slidesToShow: 4, 172 slidesToScroll: 1, 173 asNavFor: '.woolentor-quickview-main-image-slider', 174 dots: false, 175 arrows: true, 176 focusOnSelect: true, 177 prevArrow: '<span class="woolentor-quickview-slick-prev">←</span>', 178 nextArrow: '<span class="woolentor-quickview-slick-next">→</span>', 179 }); 180 }, 181 imageSlider: function(){ 182 this.MainImageSlider(); 183 this.ThumbnailSlider(); 184 }, 185 186 /** 187 * [addToCart] 188 * @param event 189 */ 190 addToCart: function( event ){ 191 event.preventDefault(); 192 193 var $this = $(this), 194 $form = $this.closest('form.cart'), 195 all_data = $form.serialize(), 196 product_qty = $form.find('input[name=quantity]').val() || 1, 197 product_id = $form.find('input[name=product_id]').val() || $this.val(), 198 variation_id = $form.find('input[name=variation_id]').val() || 0; 199 200 201 /* For Variation product */ 202 var item = {}, 203 variations = $form.find( 'select[name^=attribute]' ); 204 if ( !variations.length) { 205 variations = $form.find( '[name^=attribute]:checked' ); 206 } 207 if ( !variations.length) {
208 variations = $form.find( 'input[name^=attribute]' ); 209 } 210 211 variations.each( function() { 212 var $thisitem = $( this ), 213 attributeName = $thisitem.attr( 'name' ), 214 attributevalue = $thisitem.val(), 215 index, 216 attributeTaxName; 217 $thisitem.removeClass( 'error' ); 218 if ( attributevalue.length === 0 ) { 219 index = attributeName.lastIndexOf( '_' ); 220 attributeTaxName = attributeName.substring( index + 1 ); 221 $thisitem.addClass( 'required error' ); 222 } else { 223 item[attributeName] = attributevalue; 224 } 225 }); 226 227 var data = { 228 product_id: product_id, 229 product_sku: '', 230 quantity: product_qty, 231 variation_id: variation_id, 232 variations: item, 233 all_data: all_data, 234 }; 235 236 var alldata = data.all_data + '&product_id='+ data.product_id + '&product_sku='+ data.product_sku + '&quantity='+ data.quantity + '&variation_id='+ data.variation_id + '&variations='+ JSON.stringify( data.variations ) +'&action=woolentor_quickview_insert_to_cart' +'&nonce='+woolentorQuickView.ajaxNonce; 237 238 $( document.body ).trigger('adding_to_cart', [$this, data]); 239 240 $.ajax({ 241 type: 'POST', 242 url: woolentorQuickView.ajaxUrl, 243 data: alldata, 244 245 beforeSend: function (response) { 246 $this.removeClass('added').addClass('loading'); 247 }, 248 249 complete: function (response) { 250 $this.addClass('added').removeClass('loading'); 251 }, 252 253 success: function (response) { 254 255 if ( response.error & response.product_url ) { 256 window.location = response.product_url; 257 return; 258 } else { 259 $( document.body ).trigger( 'wc_fragment_refresh' ); 260 $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $this]); 261 } 262 263 }, 264 265 }); 266 267 } 268 269 }; 270 271 $( document ).ready( function() { 272 WooLentorQuickView.init(); 273 $( window ).on( 'resize', WooLentorQuickView.wrapperHeight ); 274 }); 275 276})(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.