Advertisement
Guest User

woocommerce-mod.js

a guest
Sep 19th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.  
  3.     cart_improvement_functions();
  4.     cart_button_animation();
  5.     cart_dropdown_improvement();
  6.     avia_select_unify('select:not(.checkout select)');
  7.     avia_cloud_zoom('.cloudzoom_active .images .woocommerce-product-gallery__image:first a', '.cloudzoom_active .thumbnails');
  8.    
  9.    
  10.     function avia_apply_quant_btn()
  11.     {
  12.         jQuery(".quantity input[type=number]").each(function() {
  13.         var number = $(this),
  14.                 max = parseFloat( number.attr( 'max' ) ),
  15.                 min = parseFloat( number.attr( 'min' ) ),
  16.                 step = parseInt( number.attr( 'step' ), 10 ),
  17.                 newNum = jQuery(jQuery('<div />').append(number.clone(true)).html().replace('number','text')).insertAfter(number);
  18.                 number.remove();
  19.    
  20.             setTimeout(function(){
  21.                 if(newNum.next('.plus').length == 0) {
  22.                     var minus = jQuery('<input type="button" value="-" class="minus">').insertBefore(newNum),
  23.                             plus    = jQuery('<input type="button" value="+" class="plus">').insertAfter(newNum);
  24.        
  25.                     minus.on('click', function(){
  26.                         var the_val = parseInt( newNum.val(), 10 ) - step;
  27.                         the_val = the_val < 0 ? 0 : the_val;
  28.                         the_val = the_val < min ? min : the_val;
  29.                         newNum.val(the_val).trigger("change");
  30.                     });
  31.                     plus.on('click', function(){
  32.                         var the_val = parseInt( newNum.val(), 10 ) + step;
  33.                         the_val = the_val > max ? max : the_val;
  34.                         newNum.val(the_val).trigger("change");
  35.        
  36.                     });
  37.                 }
  38.             },10);
  39.        
  40.         });
  41.     }
  42.    
  43.     avia_apply_quant_btn();
  44.    
  45.     //if the cart gets updated via ajax (woocommerce 2.6 and higher) we need to re apply the +/- buttons
  46.     $( document ).on( 'updated_cart_totals', avia_apply_quant_btn );
  47.    
  48.    
  49.     setTimeout(first_load_amount, 10);
  50.     $('body').on('added_to_cart', update_cart_dropdown);
  51.    
  52.    
  53. });
  54.  
  55.  
  56. //updates the shopping cart in the sidebar, hooks into the added_to_cart event whcih is triggered by woocommerce
  57. function update_cart_dropdown()
  58. {
  59.     setTimeout(function(){
  60.                 var menu_cart       = jQuery('.cart_dropdown'),
  61.                     dropdown_cart   = menu_cart.find('.dropdown_widget_cart:eq(0)'),
  62.                     subtotal        = menu_cart.find('.cart_subtotal'),
  63.                     subtotal_new    = dropdown_cart.find('.total .amount');            
  64.                     subtotal.html(subtotal_new.html());
  65.         }, 500);
  66. }
  67.  
  68. //function that pre fills the amount value of the cart
  69. function first_load_amount()
  70. {
  71.     var counter = 0,
  72.         limit = 5,
  73.         ms = 300,
  74.         check = function()
  75.         {
  76.             var new_total = jQuery('.cart_dropdown .dropdown_widget_cart:eq(0) .total .amount');
  77.            
  78.             if(new_total.length)
  79.             {
  80.                 update_cart_dropdown();
  81.             }
  82.             else
  83.             {
  84.                 counter++;
  85.                 if(counter < limit)
  86.                 {
  87.                     setTimeout(check, ms);
  88.                 }
  89.                
  90.                 if(counter == 2)
  91.                 {
  92.                     var cur_total  = jQuery('.cart_dropdown:eq(0) .cart_subtotal:eq(0) .amount'),
  93.                         symbol_pos = isNaN(cur_total.text().charAt(0)) ? "before" : "after",
  94.                         symbol     = cur_total.text().replace(/\d|\.|,|-|_/g,'');
  95.                    
  96.                     symbol_pos == "after" ? cur_total.html("0" + symbol)    : cur_total.html(symbol + "0");
  97.                 }
  98.                
  99.             }
  100.         };
  101.        
  102.         check();
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109. // little fixes and modifications to the dom
  110. function cart_improvement_functions()
  111. {
  112.     //single products are added via ajax //doesnt work currently
  113.     //jQuery('.summary .cart .button[type=submit]').addClass('add_to_cart_button product_type_simple');
  114.    
  115.     //downloadable products are now added via ajax as well
  116.     jQuery('.product_type_downloadable, .product_type_virtual').addClass('product_type_simple');
  117.    
  118.     //clicking tabs dont activate smoothscrooling
  119.     jQuery('.woocommerce-tabs .tabs a').addClass('no-scroll');
  120.    
  121.     //connect thumbnails on single product page via lightbox
  122.     jQuery('.prev_image_container>.images a').attr('rel','product_images[grouped]');
  123.    
  124.     //equal height and width for thumbnail container
  125.     var thumbContainer = jQuery('.thumbnail_container');
  126.    
  127.     thumbContainer.each(function()
  128.     {
  129.         var container = jQuery(this);
  130.             container.css('min-height', container.height());
  131.     });
  132. }
  133.  
  134.  
  135. //improve layout of select dropdowns
  136. function avia_select_unify(select_el)
  137. {
  138.     var selects = jQuery(select_el).not('#rating');
  139.  
  140.      //unify select dropdowns
  141.     selects.each(function()
  142.     {
  143.         var el = jQuery(this);
  144.        
  145.         if(el.css('display') == 'none') return;
  146.        
  147.         el.wrap('<span class="avia_style_wrap" />').wrap('<span class="avia_select_unify" />').after('<span class="avia_select_fake_val"></span>');
  148.         el.css('opacity',0).next('.avia_select_fake_val').text(el.find('option:selected').text());
  149.    
  150.      
  151.         jQuery(document).on('change', this, function()
  152.         {
  153.             el.next('.avia_select_fake_val').text(el.find('option:selected').text());
  154.         });
  155.        
  156.      });
  157. }
  158.  
  159.  
  160. //small function that improves shoping cart button behaviour
  161. function cart_button_animation()
  162. {
  163.     var containers  = jQuery('.thumbnail_container');
  164.    
  165.     containers.each(function()
  166.     {
  167.         var container = jQuery(this), buttons = container.find('.button');
  168.             container.containerHeight = container.height()/2;
  169.        
  170.         buttons.css({opacity:0, visibility:'visible', top: container.containerHeight});
  171.         container.hover(
  172.         function()
  173.         {
  174.             if(container.containerHeight < 20)
  175.             {
  176.                 container.containerHeight = container.height()/2; buttons.css({top: container.containerHeight});
  177.             }
  178.                        
  179.             if(buttons.length > 1)
  180.             {
  181.                
  182.                 buttons.each(function(i)
  183.                 {
  184.                     var button = jQuery(this);
  185.                    
  186.                     if(i == 0)
  187.                     {
  188.                         var newPos = container.containerHeight - button.outerHeight()/2;
  189.                             button.stop().animate({top:newPos - 3, opacity:1})
  190.                        
  191.                     }
  192.                     else
  193.                     {
  194.                         var newPos = container.containerHeight + button.outerHeight()/2;
  195.                             button.stop().animate({top:newPos + 3, opacity:1})
  196.                     }
  197.                
  198.                 });
  199.                
  200.             }
  201.             else
  202.             {
  203.                 buttons.stop().animate({opacity:1});
  204.             }
  205.         },
  206.         function()
  207.         {
  208.             buttons.stop().animate({opacity:0, top: container.containerHeight});
  209.         });
  210.     });
  211. }
  212.  
  213.  
  214.  
  215. //small function that improves shoping cart hover behaviour in the menu
  216. function cart_dropdown_improvement()
  217. {
  218.     var dropdown = jQuery('.cart_dropdown'), subelement = dropdown.find('.dropdown_widget').css({display:'none', opacity:0});
  219.    
  220.     dropdown.hover(
  221.     function(){ subelement.css({display:'block'}).stop().animate({opacity:1}); },
  222.     function(){ subelement.stop().animate({opacity:0}, function(){ subelement.css({display:'none'}); }); }
  223.     );
  224. }
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232. //enhances product images with the cloudzoom feature
  233. function avia_cloud_zoom(target, thumbnails)
  234. {
  235.     var image_target        = jQuery(target),
  236.         thumb_container     = jQuery(thumbnails),
  237.         image_thumbnails    = thumb_container.find('a'),
  238.         rel                 = 'adjustX: 38, adjustY:0, zoomWidth:613';
  239.        
  240.     //if(image_thumbnails.length)
  241.     //{
  242.     //  var clone               = image_target.clone().prependTo(thumb_container);
  243.     //      image_thumbnails    = thumb_container.find('a');
  244.     //}
  245.        
  246.    
  247.     image_target.addClass('cloud-zoom').attr('rel', rel).CloudZoom();
  248.                
  249.     image_thumbnails.bind('click', function()
  250.     {
  251.         var image = jQuery(this).clone(false);
  252.         image.insertAfter(image_target);   
  253.         image_target.remove();
  254.         jQuery('.mousetrap').remove();
  255.         image_target = image;
  256.         image_target.addClass('cloud-zoom').attr('rel', rel).CloudZoom();
  257.         return false;
  258.     });
  259.        
  260. }
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276. /*plugins*/
  277.  
  278. //////////////////////////////////////////////////////////////////////////////////
  279. // Cloud Zoom V1.0.2
  280. // (c) 2010 by R Cecco. <http://www.professorcloud.com>
  281. // MIT License
  282. //
  283. // Please retain this copyright header in all versions of the software
  284. //////////////////////////////////////////////////////////////////////////////////
  285. (function ($) {
  286.  
  287.  
  288.     function format(str) {
  289.         for (var i = 1; i < arguments.length; i++) {
  290.             str = str.replace('%' + (i - 1), arguments[i]);
  291.         }
  292.         return str;
  293.     }
  294.  
  295.     function CloudZoom(jWin, opts) {
  296.         var sImg = $('img', jWin);
  297.         var img1;
  298.         var img2;
  299.         var zoomDiv = null;
  300.         var $mouseTrap = null;
  301.         var lens = null;
  302.         var $tint = null;
  303.         var softFocus = null;
  304.         var $ie6Fix = null;
  305.         var zoomImage;
  306.         var controlTimer = 0;      
  307.         var cw, ch;
  308.         var destU = 0;
  309.         var destV = 0;
  310.         var currV = 0;
  311.         var currU = 0;      
  312.         var filesLoaded = 0;
  313.         var mx,
  314.             my;
  315.         var ctx = this, zw;
  316.         // Display an image loading message. This message gets deleted when the images have loaded and the zoom init function is called.
  317.         // We add a small delay before the message is displayed to avoid the message flicking on then off again virtually immediately if the
  318.         // images load really fast, e.g. from the cache.
  319.         //var   ctx = this;
  320.        
  321.         setTimeout(function () {
  322.             //                       <img src="/images/loading.gif"/>
  323.             if ($mouseTrap === null) {
  324.                 var w = jWin.width();
  325.                 jWin.parent().append(format('<div style="width:%0px;position:absolute;top:75%;left:%1px;text-align:center" class="cloud-zoom-loading" >Loading...</div>', w / 3, (w / 2) - (w / 6))).find(':last').css('opacity', 0.5);
  326.             }
  327.         }, 200);
  328.  
  329.  
  330.         var ie6FixRemove = function () {
  331.  
  332.             if ($ie6Fix !== null) {
  333.                 $ie6Fix.remove();
  334.                 $ie6Fix = null;
  335.             }
  336.         };
  337.  
  338.         // Removes cursor, tint layer, blur layer etc.
  339.         this.removeBits = function () {
  340.             //$mouseTrap.unbind();
  341.             if (lens) {
  342.                 lens.remove();
  343.                 lens = null;            
  344.             }
  345.             if ($tint) {
  346.                 $tint.remove();
  347.                 $tint = null;
  348.             }
  349.             if (softFocus) {
  350.                 softFocus.remove();
  351.                 softFocus = null;
  352.             }
  353.             ie6FixRemove();
  354.  
  355.             $('.cloud-zoom-loading', jWin.parent()).remove();
  356.         };
  357.  
  358.  
  359.         this.destroy = function () {
  360.             jWin.data('zoom', null);
  361.  
  362.             if ($mouseTrap) {
  363.                 $mouseTrap.unbind();
  364.                 $mouseTrap.remove();
  365.                 $mouseTrap = null;
  366.             }
  367.             if (zoomDiv) {
  368.                 zoomDiv.remove();
  369.                 zoomDiv = null;
  370.             }
  371.             //ie6FixRemove();
  372.             this.removeBits();
  373.             // DON'T FORGET TO REMOVE JQUERY 'DATA' VALUES
  374.         };
  375.  
  376.  
  377.         // This is called when the zoom window has faded out so it can be removed.
  378.         this.fadedOut = function () {
  379.            
  380.             if (zoomDiv) {
  381.                 zoomDiv.remove();
  382.                 zoomDiv = null;
  383.             }
  384.              this.removeBits();
  385.             //ie6FixRemove();
  386.         };
  387.  
  388.         this.controlLoop = function () {
  389.             if (lens) {
  390.                 var x = (mx - sImg.offset().left - (cw * 0.5)) >> 0;
  391.                 var y = (my - sImg.offset().top - (ch * 0.5)) >> 0;
  392.                
  393.                 if (x < 0) {
  394.                     x = 0;
  395.                 }
  396.                 else if (x > (sImg.outerWidth() - cw)) {
  397.                     x = (sImg.outerWidth() - cw);
  398.                 }
  399.                 if (y < 0) {
  400.                     y = 0;
  401.                 }
  402.                 else if (y > (sImg.outerHeight() - ch)) {
  403.                     y = (sImg.outerHeight() - ch);
  404.                 }
  405.  
  406.                 lens.css({
  407.                     left: x,
  408.                     top: y
  409.                 });
  410.                 lens.css('background-position', (-x) + 'px ' + (-y) + 'px');
  411.  
  412.                 destU = (((x) / sImg.outerWidth()) * zoomImage.width) >> 0;
  413.                 destV = (((y) / sImg.outerHeight()) * zoomImage.height) >> 0;
  414.                 currU += (destU - currU) / opts.smoothMove;
  415.                 currV += (destV - currV) / opts.smoothMove;
  416.  
  417.                 zoomDiv.css('background-position', (-(currU >> 0) + 'px ') + (-(currV >> 0) + 'px'));              
  418.             }
  419.             controlTimer = setTimeout(function () {
  420.                 ctx.controlLoop();
  421.             }, 30);
  422.         };
  423.  
  424.         this.init2 = function (img, id) {
  425.  
  426.             filesLoaded++;
  427.             //console.log(img.src + ' ' + id + ' ' + img.width);   
  428.             if (id === 1) {
  429.                 zoomImage = img;
  430.             }
  431.             //this.images[id] = img;
  432.             if (filesLoaded === 2) {
  433.                 this.init();
  434.             }
  435.         };
  436.  
  437.         /* Init function start.  */
  438.         this.init = function () {
  439.             // Remove loading message (if present);
  440.             $('.cloud-zoom-loading', jWin.parent()).remove();
  441.  
  442.  
  443. /* Add a box (mouseTrap) over the small image to trap mouse events.
  444.         It has priority over zoom window to avoid issues with inner zoom.
  445.         We need the dummy background image as IE does not trap mouse events on
  446.         transparent parts of a div. background-image:url(\".\")
  447.         */
  448.             $mouseTrap = jWin.parent().append(format("<div class='mousetrap' style=';z-index:999;position:absolute;width:%0px;height:%1px;left:%2px;top:%3px;\'></div>", sImg.outerWidth(), sImg.outerHeight(), 0, 0)).find(':last');
  449.  
  450.  
  451.             //////////////////////////////////////////////////////////////////////         
  452.             /* Do as little as possible in mousemove event to prevent slowdown. */
  453.             $mouseTrap.bind('mousemove', this, function (event) {
  454.                 // Just update the mouse position
  455.                 mx = event.pageX;
  456.                 my = event.pageY;
  457.                
  458.             });
  459.             //////////////////////////////////////////////////////////////////////                 
  460.             $mouseTrap.bind('mouseleave', this, function (event) {
  461.                 clearTimeout(controlTimer);
  462.                 //event.data.removeBits();                
  463.                 if(lens) { lens.fadeOut(299); }
  464.                 if($tint) { $tint.fadeOut(299); }
  465.                 if(softFocus) { softFocus.fadeOut(299); }
  466.                 zoomDiv.fadeOut(300, function () {
  467.                     ctx.fadedOut();
  468.                 });                                                            
  469.                 return false;
  470.             });
  471.             //////////////////////////////////////////////////////////////////////         
  472.             $mouseTrap.bind('mouseenter', this, function (event) {
  473.                 mx = event.pageX;
  474.                 my = event.pageY;
  475.                 zw = event.data;
  476.                 if (zoomDiv) {
  477.                     zoomDiv.stop(true, false);
  478.                     zoomDiv.remove();
  479.                 }
  480.  
  481.                 var xPos = opts.adjustX,
  482.                     yPos = opts.adjustY;
  483.                              
  484.                 var siw = sImg.outerWidth();
  485.                 var sih = sImg.outerHeight();
  486.  
  487.                 var w = opts.zoomWidth;
  488.                 var h = opts.zoomHeight;
  489.                 if (opts.zoomWidth == 'auto') {
  490.                     w = siw;
  491.                 }
  492.                 if (opts.zoomHeight == 'auto') {
  493.                     h = sih;
  494.                 }
  495.                 //$('#info').text( xPos + ' ' + yPos + ' ' + siw + ' ' + sih );
  496.                 var appendTo = jWin.parent(); // attach to the wrapper         
  497.                 switch (opts.position) {
  498.                 case 'top':
  499.                     yPos -= h; // + opts.adjustY;
  500.                     break;
  501.                 case 'right':
  502.                     xPos += siw; // + opts.adjustX;                
  503.                     break;
  504.                 case 'bottom':
  505.                     yPos += sih; // + opts.adjustY;
  506.                     break;
  507.                 case 'left':
  508.                     xPos -= w; // + opts.adjustX;                  
  509.                     break;
  510.                 case 'inside':
  511.                     w = siw;
  512.                     h = sih;
  513.                     break;
  514.                     // All other values, try and find an id in the dom to attach to.
  515.                 default:
  516.                     appendTo = $('#' + opts.position);
  517.                     // If dom element doesn't exit, just use 'right' position as default.
  518.                     if (!appendTo.length) {
  519.                         appendTo = jWin;
  520.                         xPos += siw; //+ opts.adjustX;
  521.                         yPos += sih; // + opts.adjustY;
  522.                     } else {
  523.                         w = appendTo.innerWidth();
  524.                         h = appendTo.innerHeight();
  525.                     }
  526.                 }
  527.  
  528.                 zoomDiv = appendTo.append(format('<div id="cloud-zoom-big" class="cloud-zoom-big" style="display:none;position:absolute;left:%0px;top:%1px;width:%2px;height:%3px;background-image:url(\'%4\');z-index:99;"></div>', xPos, yPos, w, h, zoomImage.src)).find(':last');
  529.  
  530.                 // Add the title from title tag.
  531.                 if (sImg.attr('title') && opts.showTitle) {
  532.                     zoomDiv.append(format('<div class="cloud-zoom-title">%0</div>', sImg.attr('title'))).find(':last').css('opacity', opts.titleOpacity);
  533.                 }
  534.  
  535.                 // Fix ie6 select elements wrong z-index bug. Placing an iFrame over the select element solves the issue...    
  536.                 if ($.browser.msie && $.browser.version < 7) {
  537.                     $ie6Fix = $('<iframe frameborder="0" src="#"></iframe>').css({
  538.                         position: "absolute",
  539.                         left: xPos,
  540.                         top: yPos,
  541.                         zIndex: 99,
  542.                         width: w,
  543.                         height: h
  544.                     }).insertBefore(zoomDiv);
  545.                 }
  546.  
  547.                 zoomDiv.fadeIn(500);
  548.  
  549.                 if (lens) {
  550.                     lens.remove();
  551.                     lens = null;
  552.                 } /* Work out size of cursor */
  553.                 cw = (sImg.outerWidth() / zoomImage.width) * zoomDiv.width();
  554.                 ch = (sImg.outerHeight() / zoomImage.height) * zoomDiv.height();
  555.  
  556.                 // Attach mouse, initially invisible to prevent first frame glitch
  557.                 lens = jWin.append(format("<div class = 'cloud-zoom-lens' style='display:none;z-index:98;position:absolute;width:%0px;height:%1px;'></div>", cw, ch)).find(':last');
  558.  
  559.                 $mouseTrap.css('cursor', lens.css('cursor'));
  560.  
  561.                 var noTrans = false;
  562.  
  563.                 // Init tint layer if needed. (Not relevant if using inside mode)          
  564.                 if (opts.tint) {
  565.                     lens.css('background', 'url("' + sImg.attr('src') + '")');
  566.                     $tint = jWin.append(format('<div style="display:none;position:absolute; left:0px; top:0px; width:%0px; height:%1px; background-color:%2;" />', sImg.outerWidth(), sImg.outerHeight(), opts.tint)).find(':last');
  567.                     $tint.css('opacity', opts.tintOpacity);                    
  568.                     noTrans = true;
  569.                     $tint.fadeIn(500);
  570.  
  571.                 }
  572.                 if (opts.softFocus) {
  573.                     lens.css('background', 'url("' + sImg.attr('src') + '")');
  574.                     softFocus = jWin.append(format('<div style="position:absolute;display:none;top:2px; left:2px; width:%0px; height:%1px;" />', sImg.outerWidth() - 2, sImg.outerHeight() - 2, opts.tint)).find(':last');
  575.                     softFocus.css('background', 'url("' + sImg.attr('src') + '")');
  576.                     softFocus.css('opacity', 0.5);
  577.                     noTrans = true;
  578.                     softFocus.fadeIn(500);
  579.                 }
  580.  
  581.                 if (!noTrans) {
  582.                     lens.css('opacity', opts.lensOpacity);                                     
  583.                 }
  584.                 if ( opts.position !== 'inside' ) { lens.fadeIn(500); }
  585.  
  586.                 // Start processing.
  587.                 zw.controlLoop();
  588.  
  589.                 return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
  590.             });
  591.         };
  592.  
  593.         img1 = new Image();
  594.         $(img1).load(function () {
  595.             ctx.init2(this, 0);
  596.         });
  597.         img1.src = sImg.attr('src');
  598.  
  599.         img2 = new Image();
  600.         $(img2).load(function () {
  601.             ctx.init2(this, 1);
  602.         });
  603.         img2.src = jWin.attr('href');
  604.     }
  605.  
  606.     $.fn.CloudZoom = function (options) {
  607.    
  608.    
  609.         // IE6 background image flicker fix
  610.         try {
  611.             document.execCommand("BackgroundImageCache", false, true);
  612.         } catch (e) {}
  613.         this.each(function () {
  614.             var relOpts, opts;
  615.             // Hmm...eval...slap on wrist.
  616.             eval('var   a = {' + $(this).attr('rel') + '}');
  617.             relOpts = a;
  618.             if ($(this).is('.cloud-zoom')) {
  619.                 $(this).css({
  620.                     'position': 'relative',
  621.                     'display': 'block'
  622.                 });
  623.                 $('img', $(this)).css({
  624.                     'display': 'block'
  625.                 });
  626.                 // Wrap an outer div around the link so we can attach things without them becoming part of the link.
  627.                 // But not if wrap already exists.
  628.                 if ($(this).parent().attr('id') != 'wrap') {
  629.                     $(this).wrap('<div id="wrap" style="top:0px;z-index:9999;position:relative;"></div>');
  630.                 }
  631.                 opts = $.extend({}, $.fn.CloudZoom.defaults, options);
  632.                 opts = $.extend({}, opts, relOpts);
  633.                 $(this).data('zoom', new CloudZoom($(this), opts));
  634.  
  635.             } else if ($(this).is('.cloud-zoom-gallery')) {
  636.                 opts = $.extend({}, relOpts, options);
  637.                 $(this).data('relOpts', opts);
  638.                 $(this).bind('click', $(this), function (event) {
  639.                     var data = event.data.data('relOpts');
  640.                     // Destroy the previous zoom
  641.                     $('#' + data.useZoom).data('zoom').destroy();
  642.                     // Change the biglink to point to the new big image.
  643.                     $('#' + data.useZoom).attr('href', event.data.attr('href'));
  644.                     // Change the small image to point to the new small image.
  645.                     $('#' + data.useZoom + ' img').attr('src', event.data.data('relOpts').smallImage);
  646.                     // Init a new zoom with the new images.            
  647.                     $('#' + event.data.data('relOpts').useZoom).CloudZoom();
  648.                     return false;
  649.                 });
  650.             }
  651.         });
  652.         return this;
  653.     };
  654.  
  655.     $.fn.CloudZoom.defaults = {
  656.         zoomWidth: 'auto',
  657.         zoomHeight: 'auto',
  658.         position: 'right',
  659.         tint: false,
  660.         tintOpacity: 0.5,
  661.         lensOpacity: 0.5,
  662.         softFocus: false,
  663.         smoothMove: 3,
  664.         showTitle: true,
  665.         titleOpacity: 0.5,
  666.         adjustX: 0,
  667.         adjustY: 0
  668.     };
  669.  
  670. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement