clare485
6/10/2013 - 4:17 PM

useful wordpress js

jQuery(function($){
  if($("body").hasClass("single-product")) {
    var PATTERN = /(Age[s]*\s[0-9]+.+[0-9]+)/gi;
    var title = $(".product_title").html();    
    title = title.replace(PATTERN, function(str, c1, c2){
      return "<span>"+c1+"</span>";
    });    
    $(".product_title").html(title);
  }
  //product page thumbs slider
  $('#thumbnails').flexslider({
    animation: "slide",
    //animationLoop: false,
    itemWidth: 100,
    controlNav:false
    //directionNav:false
  });
  // testimonials slider
  $('.flexslider').flexslider({
    animation: "fade",
    slideshowSpeed: 7000,
    controlNav:false,
    directionNav:false
  });
  
  //terms and conditions toggle
  $('#terms').hide();
  $('.toggler').click(function() {
      $('#terms').slideToggle('slow');
  });
  
  //add placeholder for subscribe form
  $(".mc_input").focus(function(){  
        showEmptyLabels();
        $(this).siblings("label").stop().fadeOut();
    });
    $(".mc_input").blur(function(){	
        showEmptyLabels();
    });
    $(".mc_merge_var label").bind("click", function() {
        $(this).siblings("div").find("input, textarea").focus();	
    });
    function showEmptyLabels() {
        $(".mc_input").each(function(){
            if( $(this).val() == "") {
                $(this).siblings("label").fadeIn();
            }
        });
    }
  
  
    // add placeholder for query form
  $(".wpcf7-form-control").focus(function(){	
      showEmptyLabels();
      $(this).parent("span").siblings("label").stop().fadeOut();
    });
    $(".wpcf7-form-control").blur(function(){	
        showEmptyLabels();
  });
    $("p.row label").bind("click", function() {
        $(this).siblings("span").find("input, textarea").focus();	
  });
    function showEmptyLabels() {
        $(".wpcf7-form-control").each(function(){
            if( $(this).val() == "") {
                $(this).parent("span").siblings("label").fadeIn();
            }
        });
     }
    
    //fancybox
    
    /*jQuery(function($){
        $(".frame").fancybox({
		'hideOnContentClick': true
	});        
    });*/

    
    // create fake add to cart buttons
   //$('<button class="button">add to cart</button>')
     //   .appendTo('.product-addon');
    
    
});