$(document).ready(function(){ //$("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded',social_tools:false, deeplinking: false, overlay_gallery: false}); /*$("a.inline").fancybox({ 'hideOnContentClick': true });*/ $(".fancybox").fancybox({ prevEffect : 'none', nextEffect : 'none', closeBtn : true, /*hideOnContentClick: true,*/ helpers: { title : { type : 'inside' }, /*buttons : {}*/ } }); // ošetřujeme lazy loading obrázků $( 'article img').not('img.banner').each(function( index ) { var src = $( this ).attr('src'); $( this ).attr('data-original', src); $( this ).attr('src', '/ui/images/transparent.gif'); $( this ).removeClass( 'lazyload' ); $( this ).addClass( 'lazyload' ); }); $( 'img.lazyload' ).lazyload({ /*effect : "fadeIn"*/ }); /* *** CAMERA arrows on window.resize *** */ handleCameraArrowsPosition(); $(window).on('resize', handleCameraArrowsPosition); function handleCameraArrowsPosition() { setTimeout(function () { var margin = 60; var win = $(this); //this = window var viewPort = $('#camera_both'); var wWin = win.width(); var wPort = viewPort.width(); // fix for max arrows distance var wWinCustom = 960 + (4 * margin); if(wWin >= wWinCustom){ wWin = wWinCustom; } //window.alert('wWidth: ' + win.width() + ', wHeight: ' + win.height() + ', pWidth: ' + viewPort.width() + ', pHeight: ' + viewPort.height()); if(wWin < 750){ var margin = 10; }else if(wWin < 1000){ var margin = 30; } var pos = (wPort - wWin) / 2 + margin; $('#camera_prev').css({'left':pos}); $('#camera_next').css({'right':pos}); }, 100); }; $("a#zobrazit-polozky").unbind("click").click(function(){ if ($("#kosik-wrapper").is(":hidden")){ $("#kosik-wrapper").slideDown("slow", function(){ // Callback function - will occur when sliding is complete. // $("input#hledat").focus(); //setTimeout(function() { document.getElementById('hledat').focus(); }, 10); }); } else{ $("#kosik-wrapper").slideUp("slow"); } }); // kraceni pro jednotlive stranky if ($(".shortplease.dsc3").length){ $(".shortplease.dsc3").ThreeDots({ max_rows: 3 }); } if ($(".shortplease.dsc4").length){ $(".shortplease.dsc4").ThreeDots({ max_rows: 4 }); } if ($(".shortplease.dsc5").length){ $(".shortplease.dsc5").ThreeDots({ max_rows: 5 }); } if ($(".shortplease.dsc7").length){ $(".shortplease.dsc7").ThreeDots({ max_rows: 7 }); } if ($(".shortplease.title1").length){ $(".shortplease.title1").ThreeDots({ max_rows: 1 }); } if ($(".shortplease.title2").length){ $(".shortplease.title2").ThreeDots({ max_rows: 2 }); } // move H3 element (if it's first child) one level up $( "div.item-label div.content" ).each(function( index ) { var customMaxHeight = 12; //132 //var customH3RowHeight = 31; var $child = $(this).find('> :first-child'); if($child.is('h3')){ /*var childHeight = $child.height(); if(childHeight > customH3RowHeight){ }*/ $child.remove(); $(this).parent().prepend($child); } var realHeight = $(this).height() / parseFloat($(this).find(' > p').css("font-size"));// >>> in em units if(realHeight > customMaxHeight){ $(this).removeClass( "showContent" ).addClass( "hideContent" ); $(this).parent().append("
Show more
"); }else{ $(this).removeClass( "hideContent" ).addClass( "showContent" ); } }); // show more content >> PRODUCTS $(".show-more a").on("click", function() { var $this = $(this); var $content = $this.parent().prev("div.content"); var linkText = $this.text().toUpperCase(); if(linkText === "SHOW MORE"){ linkText = "Show less"; $content.switchClass("hideContent", "showContent", 400); } else { linkText = "Show more"; $content.switchClass("showContent", "hideContent", 400); }; $this.text(linkText); }); $("input#hledat").click(function(){ var hledat = $("input#hledat").val(); if(hledat == "search"){ $("input#hledat").val(''); $("input#hledat").css("color","#000000"); } }); $("input#hledat").focus(function(){ var hledat = $("input#hledat").val(); if(hledat == "search"){ $("input#hledat").val(''); $("input#hledat").css("color","#000000"); }else{ $("input#hledat").css("color","#000000"); } }); $("input#hledat").blur(function(){ var hledat = $("input#hledat").val(); if(hledat == ""){ $("input#hledat").val('search'); $("input#hledat").css("color","#ababab"); }else{ $("input#hledat").css("color","#000000"); } }); // prevent default form submit $("#search-form-id").submit(function(e){ return false; }); $("input#hledat").keypress(function(event){ var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ var hledat = $("input#hledat").val(); if(hledat != "" && hledat != "search"){ var url = getURL() + "/products/hledat/"; var query = encodeURI($("input#hledat").val()); url = url + query window.location = url; }else{ alert('A: Please type the query into the search field.'); } } }); $("a#b-hledat").click(function(){ var hledat = $("input#hledat").val(); if(hledat != "" && hledat != "search"){ var url = getURL() + "/products/hledat/"; var query = encodeURI($("input#hledat").val()); url = url + query; window.location = url; }else{ alert('B: Please type the query into the search field.'); } }); /* ***** pridavame do kosiku ***** */ $('#b-do-kosiku').click(function () { var varval = $("input:radio[name='varianty']").val(); if($("input:radio[name='varianty']").is(":checked") || varval == undefined) { // window.alert("ok"); $('#form-do-kosiku').submit(); }else{ window.alert('Nejdříve zvolte variantu zboží.'); } }); /* ***** prepocitavame kosik ***** */ $('#b-prepocitat-kosik').click(function() { $('#form-kosik').submit(); }); /* ***** osobni udaje ***** */ $('#b-udaje-pokracovat').click(function() { $('#form-osobni-udaje').submit(); }); /* ***** validate onlyNumerics ***** */ $("input:text.numeric").keyup(function(){ // value is present var tval=trim($(this).val()); if (tval=='') return true; reg=/^0*/; tval=tval.replace(reg,''); if (tval!='') val=parseInt(tval); else val=0; var min=parseInt($(this).attr('min')); var max=parseInt($(this).attr('max')); var msg=""; if(min!='' && max !=''){ msg='Zboží lze objednat v množství od '+ min + ' do ' + max + ' kusů.' ; } else{ if(min!=''){msg='Minimální počet možných objednaných kusů je '+ min +'.';} else{ if(max!=''){msg='Maximální počet možných objednavých kusů je '+ max +'.';} } } if(min!=''){ if (min>val) { alert(msg); $(this).val(min); //$(this).css('background',_alertColor); } } if (max!=''){ if (val>max) { alert(msg); $(this).val(max); //$(this).css('background',_alertColor); } } }); $("input#refjmeno").focus(function(){ var hledat = $("input#refjmeno").val(); if(hledat == 'Jméno, město…' || hledat == 'Jan Novák'){ $("input#refjmeno").val(''); }else{ this.select(); } }); $("input#refemail").focus(function(){ var hledat = $("input#refemail").val(); if(hledat == '@'){ // $("input#refemail").val(''); }else{ this.select(); } }); $("textarea#reftext").focus(function(){ var hledat = $("textarea#reftext").val(); if(hledat == 'Text…' || hledat == 'Váš názor na toto zboží.'){ $("textarea#reftext").val(''); }else{ this.select(); } }); $("a#b-refodeslat").unbind("click").click(function(){ var f_refjmeno = $("#refjmeno").val(); var f_reftext = $("#reftext").val(); var f_refemail = $("#refemail").val(); $.ajax({ type: "POST", url: "/cs/reference/pridat-form", data: ({ jmeno:f_refjmeno, text: f_reftext, email: f_refemail }), success: function(msg){ $('div#ajax-msg-box-reference').html(msg); // nulujeme form if(msg == '

Děkujeme, vaše reference čeká na schválení editorem.

'){ $("#refjmeno").val("Jméno, město…"); $("#reftext").val("Text…"); $("#refemail").val("@"); } $("div#ajax-msg-box-reference:hidden").show("fast"); // $("html, body").animate({ scrollTop: 0 }, "slow"); }, error: function(msg){ $('div#ajax-msg-box-reference').html(msg); $("div#ajax-msg-box-reference:hidden").show("fast"); // $("html, body").animate({ scrollTop: 0 }, "slow"); } }); }); $("a#b-hododeslat").unbind("click").click(function(){ var f_refjmeno = $("#refjmeno").val(); var f_reftext = $("#reftext").val(); var f_refemail = $("#refemail").val(); var f_zbozi = $("#refzbozi").val(); $.ajax({ type: "POST", url: "/cs/products/pridat-form", data: ({ jmeno:f_refjmeno, text: f_reftext, email: f_refemail, zbozi: f_zbozi }), success: function(msg){ $('div#ajax-msg-box-reference').html(msg); // nulujeme form if(msg == '

Děkujeme, vaše hodnocení/recenze čeká na schválení editorem.

'){ $("#refjmeno").val("Jan Novák"); $("#reftext").val("Váš názor na toto zboží."); $("#refemail").val("@"); } $("div#ajax-msg-box-reference:hidden").show("fast"); // $("html, body").animate({ scrollTop: 0 }, "slow"); }, error: function(msg){ $('div#ajax-msg-box-reference').html(msg); $("div#ajax-msg-box-reference:hidden").show("fast"); // $("html, body").animate({ scrollTop: 0 }, "slow"); } }); }); // handle promo cookie /*if ($.cookies.get('promo-no-2') !== 1) { window.setTimeout("callFancyBox();", 1200) $.cookies.set('promo-no-2', 1); // // $.cookie('promo-no-2', '1', { expires: 24 * 60 * 60 * 1000 }); } // jquery UI TABS init $( "#tabs" ).tabs();*/ }); function tabJump(){ //get href ID as a number var thisID = Number($(this).attr('href').replace(/#tabs-/, '')) - 1; // this should trigger the new tab based on this href id. $("#tabs").tabs("select" , "#tabs-" + thisID); } function callFancyBox() { $('#promo-link').trigger('click'); } function setSearchInputColor(){ var hledat = $("input#hledat").val(); if(hledat == "search"){ $("input#hledat").css("color","#ababab"); } } function productCenaSliderChange(event, value, url){ var rozsah = "/rozsah/"; var hodnota = value; hodnota = hodnota.replace(" - ", "-"); hodnota = hodnota.replace(" Kč", ""); var url = window.location.protocol + "//" + window.location.host + url + rozsah + hodnota; //console.log(url); window.location = url; } function getURL() { var url = window.location.protocol + "//" + window.location.host; return url; } function zboziRazeni(url, sort) { var sort_field = $("select#sort-field").val(); var razeni = '/razeni/' + sort_field + '_' + sort; var url = window.location.protocol + "//" + window.location.host + url + razeni; //console.log(url); window.location = url; } function zboziPolozek(url) { var items_field = $("select#items-field").val(); var polozek = '/polozek/' + items_field; console.log(url); var url = window.location.protocol + "//" + window.location.host + url + polozek; //console.log(url); window.location = url; } function trim(data){ return data.replace(/^\s*/, "").replace(/\s*$/, ""); }