function getViewport(){return{width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,scrollTop:window.pageYOffset||document.documentElement.scrollTop,scrollLeft:window.pageXOffset||document.documentElement.scrollLeft}}; (function($){ var oldAttr = $.fn.attr; $.fn.attr = function() { var ret = oldAttr.apply(this, arguments); if(this.length>0 && arguments.length == 1 && arguments[0] == 'hash'){ var ha = this[0].hash; return ha; } return ret; } })(jQuery); $.fn.load = function(arg) { this.on('load',arg); } $.fn.live = function(n,arg) { this.on(n,arg); } $(function(){ $(".gallery a > img").each(function(a,c){var b=$(this).parent().attr("href");$(this).parent().attr("rel","prettyPhoto[pp_gal]");$(this).parent().attr("href",b).prettyPhoto({show_title:true,overlay_gallery:false})}) $("a[rel^='prettyPhoto']").prettyPhoto({show_title:true,overlay_gallery:false}); //--------MENU LEWE--------- var aChildrenLeft = $("div.menuLeft li a"); var aArrayLeft = []; var firstChildMenuLeft = aChildrenLeft[0]; var aFirstHref = $(firstChildMenuLeft).attr('href'); var firstHa = $(firstChildMenuLeft).attr('hash'); if(aFirstHref) var aHrf = aFirstHref.replace(firstHa,''); for (var i=0; i < aChildrenLeft.length; i++) { var aChildL = aChildrenLeft[i]; var ahref = $(aChildL).attr('href'); var ha = $(aChildL).attr('hash'); if(ha != '') aArrayLeft.push(ha); } //------------------------------ /* //--------MENU GĂRNE--------- var aChildren = $("div.menuTop li a"); var aArray = []; var firstChildMenu = aChildren[0]; var homeFirstHref = $(firstChildMenu).attr('href'); var firstHomeHa = $(firstChildMenu).attr('hash'); if(homeFirstHref) var aHomeRf = homeFirstHref.replace(firstHomeHa,''); for (var i=0; i < aChildren.length; i++) { var aChild = aChildren[i]; var ahref = $(aChild).attr('href'); var ha = $(aChild).attr('hash'); if(ha != '') aArray.push(ha); } //------------------------------------ */ /* TOP Menu */ var hMenuStart = 1000;//if 0 always hamburger menu (function(){ var tm = $('div.menuTop>div.inMenu'), bck = false,//$('body').append('
').children(':last').get(0), right = false, hasHMenu = false, hMenu = $('div.menuTop>a.showMenu'), fnClick = function(e){ e.preventDefault(); var hasVisible = tm.is(':visible'); if(right === false){ right = tm.outerWidth() * -1; if(!hasVisible){ tm.css({right:right}); } } if(hasVisible){ tm.animate({right:right},100,function(){ $(this).hide(); $('body').removeAttr('style'); if(bck) bck.style.display = 'none'; }); $(this).removeClass('selShow'); } else { if(bck) bck.style.display = 'block'; tm.show().animate({right:0},100,function(){ //$('body').css({overflow:'hidden',position:'fixed',width:'100%'}); }); $(this).addClass('selShow'); } }; hMenu.on('click', fnClick); if(bck) bck.addEventListener('click', fnClick); if(hMenuStart > 0){ oListenSize([hMenuStart], function( size, isLess ){ if(!isLess){ hasHMenu = false; if(bck) bck.style.display = 'none'; $('body').removeAttr('style'); tm.removeAttr('style'); } else { hasHMenu = true; } }); } else hasHMenu = true; /* HASH Link */ var hash = document.querySelectorAll('li.runHash>a'), l = hash.length, i = 0, runID = function(){ var ha = this.hash, $elem = $(ha); i = 0; for( ; i < l; i++ ){ var parent = hash[i].parentNode, cName = parent.className.replace(/\s+sel|sel\s*/g, ''); if(hash[i].hash === ha){ parent.className = cName + ( parent.className ? ' ' : '' ) + 'sel'; var p = parent.parentNode; while(p !== null && p.nodeType === 1 && ( p.tagName === 'UL' || p.tagName === 'LI' )){ if(p.tagName === 'LI' && /(?:\s|^)runHash(?:\s|$)/.test(p.className)){ $(p).addClass('sel') .children('a') .addClass('sel'); } p = p.parentNode; } } else { parent.className = cName; } hash[i].className = parent.className; } if(hasHMenu){ hMenu.trigger('click', fnClick); } console.log(ha); $('html, body').animate({ scrollTop: $elem.offset().top- parseInt($('.box_menu_top').height()) }, 1000); }; for( ; i < l; i++ ){ if(hash[i].hash){ hash[i].addEventListener('click', runID); if(location.hash === hash[i].hash){ var parent = hash[i].parentNode, cName = parent.className.replace(/\s+sel|sel\s*/g, ''); parent.className = cName + ( parent.className ? ' ' : '' ) + 'sel'; hash[i].className = parent.className; } } } /* EOT HASH Link */ })(); /* EOT TOP Menu */ var hBoxTop = 1; //--------MENU GĂRNE--------- //----------------------------- var scrollDownObj = null, isMenuFix = 0, //MENU posMenu = 0,//MENU heightMenu = 0,//MENU timeoutLId = null,//MENU //hBoxTop = 1,//MENU isFix = 0,//MENU samochody = $('.product_detail_out'), resizeFn = function(){ //------------------ TOP IMAGE ----------------- var contImage = $('#box_image > img').width(), w = Math.min(contImage,$(document).width()); if(w < contImage){ $('#box_image > img').css('left',-((contImage-w)/2)); $('#box_image > img').css('visibility','visible'); } else{ $('#box_image > img').css('left',((w-contImage)/2)); $('#box_image > img').css('visibility','visible'); } //------------------------------------------ if(scrollDownObj === null){ scrollDownObj = { obj:$('body').append('').find('a.scrollDown'), stat: 0 }; scrollDownObj.obj.on('click', function(e){ $('html,body').animate({scrollTop:0},400); $(this).css('opacity',0.3).hide(); e.preventDefault(); }); } }, hasLanser = $('#sliderVid'), scrollFn = function(){ var scrollTop = getViewport().scrollTop; //-------- LANSER ----------------------------- if(hasLanser.length){ var lOffT = hasLanser.offset().top; if((lOffT - scrollTop) < 0){ var xTrans2 = ( scrollTop - lOffT ) / 2; var xTrans3 = -( scrollTop - lOffT )/1.5; $('#sliderVid').css('transform', 'translateY('+xTrans2+'px)'); $('#sliderVid').find('.opis2').css('transform', 'translateY('+xTrans3+'px)'); //$('.liSlider>img').css('transform', 'translateY('+xTrans2+'px)'); //$('.divEffect').css('transform', 'translateY('+xTrans2+'px)'); //$('#slider .prev').css('transform', 'translateY('+xTrans2+'px)'); //$('#slider .next').css('transform', 'translateY('+xTrans2+'px)'); //$('#slider .opisS').css('transform', 'translateY('+(xTrans2)+'px)'); //$('#slider .opis').css('transform', 'translateY('+(xTrans2)+'px)'); }else{ $('#sliderVid').css('transform', ''); $('#sliderVid').find('.opis2').css('transform', ''); //$('.liSlider>img').css('transform', ''); //$('.divEffect').css('transform', ''); //$('#slider .prev').css('transform', ''); //$('#slider .next').css('transform', ''); //$('#slider .opisS').css('transform', ''); } } //-------------------------------------------- //-------------------- TOP IMAGE ----------------- (function(){ var boxImg = $('#box_image'); if(boxImg.length){ var offsetTop = boxImg.offset().top; if((offsetTop - scrollTop) < 0){ var xTransIm = ( scrollTop - offsetTop ) / 2; $('img', boxImg).css('transform', 'translateY('+xTransIm+'px)'); $('.imgOpis', boxImg).css('transform', 'translateY('+xTransIm+'px)'); } else{ $('img', boxImg).css('transform', ''); $('.imgOpis', boxImg).css('transform', ''); } } })(); //--------------------------------------------- //--------- MENU GĂłRNE MENU LEWE------------------- var windowHeight = $(window).height(); var docHeight = $(document).height(); //---------------- MENU LEWE ZAZNACZENIE AKTYWNEJ----------------------- for (var i=0; i < aArrayLeft.length; i++) { var theID = aArrayLeft[i]; if($(theID)[0] != undefined){ var divPos = $(theID).offset().top; var divHeight = $(theID).parent().height(); var actH; divPos = divPos - divHeight/3; if (scrollTop >= divPos && scrollTop < (divPos + divHeight)) { if (timeoutLId) clearTimeout(timeoutLId); $("div.menuLeft li").removeClass("sel"); $("div.menuLeft a[href='"+aHrf+"" + theID + "']").parent().addClass("sel"); actH = theID; } } } //if($("div.menuLeft .sel")[0] == undefined){ // $(firstChildMenuLeft).parent().addClass("sel"); //} //------------------------------------------------- //---------------- MENU LEWE FIXED----------------------- if($('.menuLinks')[0] != undefined){ if(isMenuFix == 0){ heightMenu = $('.menuLinks').height(); } if(heightMenu < $(window).height() && heightMenu < $('.content-text').height()){ var v = getViewport(); var timeoutId = null; if (timeoutId) clearTimeout(timeoutId); // timeoutId = setTimeout(function(){ var contentPos = $('.content-text').position().top+$('.content-text').height(); var menuLeftOuter = $('.menuLinks').height()+window.scrollY; var contentPos2 = contentPos-parseInt($('.menuTop').height()); if(contentPos2 <= menuLeftOuter){ $('.menuLinks').css('top','auto'); $('.menuLinks').css('top',contentPos-$('.menuLinks').height()); $('.menuLinks').addClass('menuAbs'); } else{ $('.menuLinks').removeClass('menuAbs'); $('.menuLinks').css('top',parseInt($('.box_menu_top').height())); } var posContent = $('.content-text')[0].getBoundingClientRect().top-parseInt($('.box_menu_top').height()); if(posContent<= 0){ isMenuFix = 1; $('.menuLinks').addClass('menuFix'); } else{ isMenuFix = 0; $('.menuLinks').removeClass('menuFix'); } //}, 20); } } //----------------------------------------- /* //---------------- MENU GĂRNE ZAZNACZENIE AKTYWNEJ----------------------- for (var i=0; i < aArray.length; i++) { var theID = aArray[i]; if($(theID)[0] != undefined){ var divPos = $(theID).offset().top-100; var divHeight = $(theID).parent().height(); var actH; if (scrollTop >= divPos && scrollTop < (divPos + divHeight)) { $("div.menuTop li").removeClass("sel"); $("div.menuTop a[href='"+aHomeRf+"" + theID + "']").parent().addClass("sel"); actH = theID; } else { $("div.menuTop a[href!='/" + actH + "']").parent().removeClass("sel"); } } } if($("div.menuTop .sel")[0] == undefined){ $(firstChildMenu).parent().addClass("sel"); } //-------------------------------------------------------- */ //---------------- MENU GĂRNE FIXED ----------------------- if(scrollTop >= hBoxTop && isFix == 0){ isFix = 1; $('body').addClass('hfix'); }else if(scrollTop < hBoxTop && isFix == 1){ isFix = 0; $('body').removeClass('hfix'); } //------------------------------------------------------- if(getViewport().height < scrollTop){ if(scrollDownObj.stat === 1) return; scrollDownObj.obj.show(); scrollDownObj.stat = 1; } else { if(scrollDownObj.stat === 2) return; scrollDownObj.obj.hide(); scrollDownObj.stat = 2; } }; $(window) .on('resize', resizeFn) .trigger('resize', resizeFn) .on('scroll', scrollFn) .trigger('scroll', scrollFn); var ha = window.location.hash; if(ha != '' && ($(ha).length>0)){ $('.menuLeft').find('li').removeClass('sel'); $('.menuLeft').find('li a').each(function(){ if($(this).attr('hash') == ha){ $(this).parent().addClass('sel'); } }) $('html, body').animate({ scrollTop: $(ha).offset().top- parseInt($('.div-top').height()) }, 1000); } /* //----- MENU GĂRNE ZAZNACZENIE AKTYWNEJ var ha = window.location.hash; if(ha != ''){ $('.menuLeft').find('li').removeClass('sel'); $('.menuLeft').find('li a').each(function(){ if($(this).attr('hash') == ha){ $(this).parent().addClass('sel'); } }) } //---------------------------------------- */ $('#changeLang').find('li').on('click',function(){ if($(this).hasClass('sel')){ $(this).parent().find('li').each(function(){ if($(this).hasClass('sel') == false){ if($(this).css('display') == 'none'){ $(this).addClass('animatedA'); $(this).addClass('fadeInDownA'); $(this).addClass('langAnim'); //$(this).toggle(); } else{ //$(this).removeClass('animated'); $(this).removeClass('fadeInDownA'); //$(this).removeClass('langAnim'); $(this).addClass('fadeOutUpA'); $(this).one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) { $(this).off('webkitAnimationEnd oanimationend msAnimationEnd animationend'); $(this).removeClass('animatedA'); $(this).removeClass('langAnim'); $(this).removeClass('fadeOutUpA'); }); } } }) } else{ window.location = $(this).find('a').attr('href'); } return false; }) }); //------------------- MENU GĂRNE --------------------- function runID(el){ var ha = el.hash; if(typeof $(ha)[0] !== 'undefined'){ var v = getViewport(); $(el).parent().siblings().removeClass('sel'); $(el).parent().addClass('sel'); if(ha != ''){ $('.menuLeft').find('li').removeClass('sel'); $('.menuLeft').find('li a').each(function(){ if($(this).attr('hash') == ha){ $(this).parent().addClass('sel'); } }) } if(v.width <= 890){ var tm = $('div.menuTop>div.inMenu'), right = tm.outerWidth() * -1; tm.animate({right:right},100,function(){ $(this).hide(); $('body').removeAttr('style'); }); } $('html, body').animate({ scrollTop: $(ha).offset().top- parseInt($('.div-top').height()) }, 1000); } } // EOT MENU GĂRNE ------------------------------------------- /* $(window).load(function(){ //--------------- SCROLL DO TEKSTU ------------ var v = getViewport(); offHeight = 70; //if(v.width <= 768){ if($('.content-text')[0] != undefined){ $('html, body').animate({ scrollTop: $('.content-text').offset().top-offHeight }, 1000); } //} //------------------------------------- //-------------- moduĹ szukaj ------------------- $('.modSearchBttn').on('click',function(e){ $( "#formSearch" ).toggle( 0, function() { if(!$('#formSearch').is(':visible')){ $('#formSearch').removeAttr('style',''); } else{ $('#formSearch').css('display','block'); } }); if($('#formSearch').is(':visible')) $('input[type="text"]', '#formSearch').val('').focus(); tm.css({right:'-90%',display:'none'}); $('body').removeAttr('style'); e.preventDefault(); e.stopPropagation(); }) //------------------------------------------- }); */