var width=0; var height=0; function jqUpdateSize(){ // Get the dimensions of the viewport width = $(window).width(); height = $(window).height(); }; $(window).resize(function(){ jqUpdateSize(); }); $(window).load(function(){ /** ************************************************************ *************** THIS IS THE NAVIGATION CODE **************** ************************************************************ **/ if (matchMedia) { var mq = window.matchMedia("(min-width: 769px)"); mq.addListener(WidthChange); WidthChange(mq); } function WidthChange(mq) { if (mq.matches) { $(function() { // Stick the #nav to the top of the window var nav = $('#sticky'); var navHomeY = nav.offset().top; var isFixed = false; var $w = $(window); $w.scroll(function() { var scrollTop = $w.scrollTop(); var shouldBeFixed = scrollTop > 70; if (shouldBeFixed && !isFixed) { nav.css({ position: 'fixed', top: 0, left: nav.offset().left, width: nav.width() }); isFixed = true; } else if (!shouldBeFixed && isFixed) { nav.css({ position: 'static' }); isFixed = false; } }); }); }else{ $(function() { // Stick the #nav to the top of the window var nav = $('#sticky'); var navHomeY = nav.offset().top; var isFixed = false; var $w = $(window); var scrollTop = $w.scrollTop(); var shouldBeFixed = scrollTop > navHomeY; nav.css({ position: 'fixed', top: 0, left: nav.offset().left, width: nav.width() }); }); } } });//]]> $(document).ready(function(){ jqUpdateSize(); function setCookie(c_name, value, exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value = escape(value) + ((exdays == null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } $('#accept_cookies').click(function(evt) { setCookie("cookies_accepted", 1, 365); $('.cookies_footer').animate({ 'height': 'toggle'}); //$('.cookies_footer').slideDown(400, function() { $('#wrapper').css({ 'margin-bottom':'50px' }); }); evt.preventDefault(); }); jQuery('button#contactme').click(function(evt){ evt.preventDefault(); var form = $('form#contactmeform'); //$('button#contactme').fadeOut(); //$('img#loadingSpinner').fadeIn(); $.ajax({ type: "POST", url: "/contactme", data: form.serialize(), dataType: 'json', complete:function(xmlHttp) { // xmlHttp is a XMLHttpRquest object if (xmlHttp.status == 403) { //top.location.href = '/login?error=login'; } }, success: function(data){ $('input#name').css({'border':'1px solid #ccc'}); $('input#phone').css({'border':'1px solid #ccc'}); if(data.status){ $('div#contactcontainer').hide(); $('div#thanks').show(); //return true; }else{ var errors = data.errors; var obj = jQuery.parseJSON( errors ); $.each(obj, function(i,a) { $('input#'+i).css({'border':'1px solid red'}); $('#text_'+i).css({'color':'red'}); }); return false; } } }); }); $('.collapse').on('shown.bs.collapse', function(){ //Open //$(this).parent().find(".glyphicon-chevron-down").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"); var collapseId = $(this).attr('id'); var button = $(this).parent().find('a[href$="#'+collapseId+'"]'); var closetitle = button.data('closetitle'); button.html(closetitle+' '); }).on('hidden.bs.collapse', function(){ //Close //$(this).parent().find(".glyphicon-chevron-up").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"); var collapseId = $(this).attr('id'); var button = $(this).parent().find('a[href$="#'+collapseId+'"]'); var opentitle = button.data('opentitle'); button.html(opentitle+' '); if ( $("div#"+collapseId+"Start").length >0) { $('html,body').animate({ scrollTop: ($("div#"+collapseId+"Start").offset().top-100) }, 500); } }); $('body').on('click','.imgThumb',function(){ var $this = $(this); var imgURL = $this[0].dataset.imgbig; var destination = $('figure#main-pic > img'); destination.animate({opacity: 0}, 500, function() { destination .attr('src',imgURL) .animate({opacity: 1}); }); }); //********************** Carousel entregas ************************ var owl1 = $('.owl-entregas'); owl1.owlCarousel({center: false, nav:true, navText:['prev', 'next'], items:3, loop:true, margin:10, responsive:{ 0:{ items:1, nav:true, loop:true, margin:0},650:{items:2,nav:true,loop:true},1000:{items:3,nav:true,loop:true} } }); owl1.on('changed.owl.carousel', function(event) { var current = event.item.index; var currentObj = $(event.target).find(".owl-item").eq(current); var dataId = currentObj.find('div').attr('data-id'); $.ajax({ type: "POST", url: "/ajax_entregadetalle", data: {'entregaId':dataId}, dataType: 'json', complete:function(xmlHttp) { // xmlHttp is a XMLHttpRquest object if (xmlHttp.status == 403) { //top.location.href = '/login?error=login'; } }, success: function(data){ if(data.status){ $('div#delivery-item').animate({opacity: 0}, 500, function() { if(data.addClass){ $('div#delivery-item').addClass('item-nogadget');} else{ $('div#delivery-item').removeClass('item-nogadget'); } $('div#delivery-item').html(data.html) .animate({opacity: 1}); }); }else{ } } }); }) owl1.on('click', '.owl-item', function(e) { //if(width > 649){ var elementindex = ($(this).index()-3); var destination = $('div.entregadetailcontainer'); destination.animate({opacity: 0}, 'slow', function() { destination.slideDown(500,function(){ //$('div#containerTitle').addClass('hiddenafter'); //$('span#spanTitle').slideUp('slow'); }).animate({opacity: 1}); }); if(width > 649) { owl1.trigger('to.owl.carousel', [elementindex, 300, true]); } $('html, body').animate({ scrollTop: $("#detail").offset().top-50 }, 2000); //} }); /*********************** Carrousel coleccion *************************************/ var owl2 = $('.owl-coleccion'); owl2.owlCarousel({ center: false, nav:true, navText:['prev', 'next'], items:1, loop:true, autoplay:false, margin:10, responsive:{600:{items:1}} }); $('body').on('click','#prev-detail',function(){ owl1.trigger('prev.owl.carousel', [300]); }); $('body').on('click','#next-detail',function(){ owl1.trigger('next.owl.carousel'); }); $('.nav > li:not(.active)').on("click", function() { $(this).addClass("selected"); $(this).siblings().removeClass("selected"); }); /*********************** Carrousel destacado *************************************/ var owl3 = $('.owl-destacado'); owl3.owlCarousel({ center: false, nav:true, navText:['prev', 'next'], items:1, loop:true, margin:0 }); }); $(function() { $(window).scroll(function () { if($(this).scrollTop() < 70){ $('#sticky').removeClass('static-nav'); }else{ $('#sticky').addClass('static-nav'); } }); });