/*
* Permatex
* (c) 2013, Web factory Ltd
*/
jQuery(function($) {
//$('#teaser').height($('.teaser-right').height()); Editado
// lightbox gallery on carosel
if ($(window).width() > 767) {
if ($("a[data-gal^='prettyPhoto']").length) {
$("a[data-gal^='prettyPhoto']").each(function(ind, el) {
$(el).attr('rel', $(el).attr('data-gal'));
});
$("a[rel^='prettyPhoto']").prettyPhoto({social_tools: false, deeplinking: false});
}
} else {
$("a[data-gal^='prettyPhoto']").click(function() {
return false;
});
}
// carosel slider/gallery
if ($(window).width() > 767) {
if ($('.flexslider-carousel').length) {
$('.flexslider-carousel').flexslider({
animation: "slide",
easing: "swing",
slideshow: true,
slideshowSpeed: 7000,
animationSpeed: 600,
touch: true,
controlNav: false,
directionNav: true,
animationLoop: true,
itemWidth: 220,
itemMargin: 0,
minItems: 4,
maxItems: 4
});
}
}
// Equal height widgets
var max_height = 0;
$('.tiw').each(function(i, item) {
var current_element_height = $(item).height();
if (current_element_height > max_height) {
max_height = current_element_height;
}
});
$('.tiw').each(function(i, item) {
$(item).height(max_height + 'px');
});
// header slider
if ($('.flexslider').length) {
$('.flexslider').flexslider({
animationSpeed: 800,
pauseOnAction: true,
direction: 'horizontal'
});
}
// smooth scrolling anchors
$('.smoothscroll').click(function(e) {
el = $(this).attr('href');
$('html, body').animate({scrollTop: $(el).offset().top - 0}, 'slow');
console.log('Hola');
console.log($(el).offset().top - 0);
e.preventDefault();
return false;
});
// main menu
$('#main-navigation>li').hover(function(){
var sub = $('.sub-menu', $(this));
if ($(sub).length) {
$(sub).fadeIn(300);
}
}, function(){
var sub = $('.sub-menu', $(this));
if ($(sub).length) {
$(sub).stop().fadeOut(300);
}
});
// generate mobile menu
if ($('.menu_mobile').length) {
var mobile_menu = $('.menu_mobile');
$('#main-navigation li a').each(function(index, elem) {
if ($(elem).parents('ul.sub-menu').length) {
tmp = ' - ' + $(elem).html();
} else {
tmp = $(elem).html();
}
if ($(elem).parent('li').hasClass('current-menu-item')) {
mobile_menu.append($('').val($(elem).attr('href')).html(tmp).attr('selected', 'selected'));
} else {
mobile_menu.append($('').val($(elem).attr('href')).html(tmp));
}
});
}
// mark submenus
$('#main-navigation ul.sub-menu').parent('li').children('a').html(function(){ return $(this).html() + ' +'; });
// mobile menu click
$('#primary_menu_mobile').change(function() {
link = $(this).val();
if (!link) {
return;
}
document.location.href = link;
return false;
});
// links & icons hover effects
$('#logo,.store-buttons a,.social-icon span,.flexslider-carousel img').css('opacity', '1');
$('#logo,.store-buttons a,.social-icon span,.flexslider-carousel img').hover(
function () {
$(this).stop().animate({ opacity: .35 }, 'normal');
},
function () {
$(this).stop().animate({ opacity: 1 }, 'normal');
});
$('.over').css('opacity', '0');
$('.over').hover(
function () {
$(this).stop().animate({ opacity: 1 }, 'slow');
},
function () {
$(this).stop().animate({ opacity: 0 }, 'slow');
});
});