$(document).ready(function () { // menu 3 poziom $('[data-toggle=tab]').click(function () { if ($(this).parent().hasClass('active')) { $($(this).attr("href")).toggleClass('active'); setTimeout(function () { $("li[role=presentation]").removeClass("active"); $("li[role=presentation] a").attr("aria-expanded", "").blur(); }, 50); } }); // menu więcej var show_more_button = $('#menu3lineCont .show-more-wrapper'); $('[href=#produkt]').on('click', function () { if (show_more_button.hasClass('hidden')) { show_more_button.removeClass('hidden'); } else { show_more_button.addClass('hidden'); } }); if($(".stronnice").length!=0) { $(".stronnice").first().removeClass("hidden"); } if($(".pages").length!=0) { $(".pages li a").click(function(){ var numer = $(this).text(); $(".stronnice").addClass("hidden"); $("#cat"+numer).removeClass("hidden"); $(".pages li a").removeClass("current"); $(this).addClass("current"); $(".pagination-prev,.pagination-next").removeClass("disabled"); if($(".current").text()=="1") $(".pagination-prev").addClass("disabled"); if($(".pages li a").last().hasClass("current")) $(".pagination-next").addClass("disabled"); }); $(".pagination-prev").click(function(){ $(".pages li a.current").parent().prev().find("a").click(); return false; }); $(".pagination-next").click(function(){ $(".pages li a.current").parent().next().find("a").click(); return false; }); if(window.location.hash) { $(".pages li a[href='"+window.location.hash+"']").click(); } } // slider $('.morelist').slick({ prevArrow: false, nextArrow: false, dots: true, autoplay: true, autoplaySpeed: 5000 }); $('.suwak').slick({ prevArrow: $(".slajder .arrowleft"), nextArrow: $(".slajder .arrowright"), dots: false, autoplay: true, autoplaySpeed: 5000 }); $('.slider').slick({ prevArrow: $(".slider .slider1innerLeftArrow"), nextArrow: $(".slider .slider1innerRightArrow"), dots: true, autoplay: true, autoplaySpeed: 5000 }); $('.brand-products-slider').slick({ prevArrow: $(".brand-products-slider .arrow-left"), nextArrow: $(".brand-products-slider .arrow-right"), dots: true, autoplay: true, autoplaySpeed: 500000 }); $('.cechy .container').slick({ prevArrow: $(".cechy .leftarrow"), nextArrow: $(".cechy .rightarrow"), dots: true, autoplay: true, autoplaySpeed: 5000, draggable: false }); $('.nowosciBox3slider').slick({ arrows: false, dots: true, autoplay: true, autoplaySpeed: 5000 }); $('.wiecejProdSlider').slick({ arrows: false, dots: true, autoplay: true, autoplaySpeed: 5000 }); $('.rekomendowaneProdSlider').slick({ arrows: false, dots: true, autoplay: true, autoplaySpeed: 5000 }); // Button w stopce do przewijania strony do góry $('#scroll-to-top').smoothScroll({offset: -100}); $(".compare").click(function(){ var i = $(this).attr("id").replace("prod",""); if( $(this).hasClass("compared") ) { compareDel( $("#compare"+i).data("compare") ); } else compare(i); return false; }); $(".porownajTxt").hover(function(){ $(".porownajPozycje").fadeIn(0).stop().animate({opacity:1},400); }, function(){ $(".porownajPozycje").stop().animate({opacity:0},400,function(){ $(this).fadeOut(0); }); }); $.each( $(".porownajPozycja"), function(){ var il = $(this).find("span").first().attr("id").replace("compare",""); if( $("#compare"+il).length != 0 ) $("#prod"+il).addClass("compared").text( $("#prod"+il).data("langtextcancel") ); }); compare = function(i) { $(".porownajPozycje").fadeIn(0).stop().animate({opacity:1},400); $.ajax( { url: "/en/main/ajax/compare/"+i, method: "GET" }).done(function(data) { if (JSON.parse(data).result == 'ok') { $("#prod"+i).addClass("compared").text( $("#prod"+i).data("langtextcancel") ); $('#'+JSON.parse(data).id).addClass('compareClose').find(".remove-from-comparison").attr("id","compare"+JSON.parse(data).number); $('#'+JSON.parse(data).id+' img').attr('src','http://tryton.ro/'+JSON.parse(data).src).attr('alt',JSON.parse(data).name); $("#porownajCount").text(JSON.parse(data).count); $("#porownajCount").removeClass('red').removeClass('white').addClass(JSON.parse(data).color); if( JSON.parse(data).count==2 ) { $("#prod"+$('#'+JSON.parse(data).id+" span").first().attr("id").replace("compare","") ).removeClass("compared").text( $("#prod"+i).data("langtextok") ); setTimeout(function(){ window.location=JSON.parse(data).foward; },200); } else { $(".porownajPozycje").delay(600).animate({opacity:0},400,function(){ $(this).fadeOut(0); }); } } else { alert('błąd'+i); } }); return false; } compareDel = function(i) { $(".porownajPozycje").fadeIn(0).stop().animate({opacity:1},400); $.ajax( { url: "/en/main/ajax/compareDel/"+i, method: "GET" }).done(function(data) { if (JSON.parse(data).result == 'ok') { $.each( $(".remove-from-comparison"), function(){ if( $(this).data("compare")==i ) $("#prod"+ $(this).attr("id").replace("compare","") ).removeClass("compared").text( $("#prod"+ $(this).attr("id").replace("compare","") ).data("langtextok") ); }); if (JSON.parse(data).redirect == 1) { location.href = '/en/category/wszystkie'; } else { if (i=='left') { $('#porownaj1').removeClass('compareClose'); $('#porownaj1 a').attr("href","/en/category/wszystkie"); $('#porownaj1 img').attr('src','http://tryton.ro/public/img/plus.png').attr('alt',''); } if (i=='right') { $('#porownaj2').removeClass('compareClose'); $('#porownaj2 a').attr("href","/en/category/wszystkie"); $('#porownaj2 img').attr('src','http://tryton.ro/public/img/plus.png').attr('alt',''); } $("#porownajCount").text(JSON.parse(data).count); $("#porownajCount").removeClass('red').removeClass('white').addClass(JSON.parse(data).color); } //alert('usunięto z porównania'); $(".porownajPozycje").delay(600).animate({opacity:0},400,function(){ $(this).fadeOut(0); }); } else { alert('błąd'+i); } }); return false; } }); $(".contact-form form").ajaxForm(function(data) { if(data!="ok") console.log(data); if(data!="ok") alert("Error! Please try again..."); if(data=="ok") $(".contact-form form").fadeOut(300,function(){ $(this).html('

').fadeIn(); }); }); catPic = function (imgsrc) { console.log(imgsrc); $("#catImg").css('background-image', 'url("' + imgsrc + '")'); }; var notSupportedBrowsers = []; var displayPoweredBy = true; var noticeLang = 'professional'; var noticeLangCustom = null; var supportedBrowsers = []; var BrowserDetection = { init: function(){ if(notSupportedBrowsers == null || notSupportedBrowsers.length < 1){ notSupportedBrowsers = this.defaultNotSupportedBrowsers; } this.detectBrowser(); this.detectOS(); if(this.browser == '' || this.browser == 'Unknown' || this.os == '' || this.os == 'Unknown' || this.browserVersion == '' || this.browserVersion == 0) { return; } // Check if this is old browser var oldBrowser = false; for(var i = 0; i < notSupportedBrowsers.length; i++){ if(notSupportedBrowsers[i].os == 'Any' || notSupportedBrowsers[i].os == this.os){ if(notSupportedBrowsers[i].browser == 'Any' || notSupportedBrowsers[i].browser == this.browser){ if(notSupportedBrowsers[i].version == "Any" || this.browserVersion <= parseFloat(notSupportedBrowsers[i].version)){ oldBrowser = true; break; } } } } if(oldBrowser){ this.displayNotice(); } }, getEl: function(id){ return window.document.getElementById(id); }, getElSize: function(id){ var el = this.getEl(id); if(el == null){ return null; } return { 'width': parseInt(el.offsetWidth), 'height': parseInt(el.offsetHeight) }; }, getWindowSize: function(){ if(typeof window.innerWidth != 'undefined'){ return {'width': parseInt(window.innerWidth), 'height': parseInt(window.innerHeight)}; } else { if(window.document.documentElement.clientWidth != 0){ return {'width': parseInt(window.document.documentElement.clientWidth), 'height': parseInt(window.document.documentElement.clientHeight)}; } else { return {'width': parseInt(window.document.body.clientWidth), 'height': parseInt(window.document.body.clientHeight)}; } } }, positionNotice: function(){ var noticeSize = this.getElSize('browser-detection'); var windowSize = this.getWindowSize(); var noticeEl = this.getEl('browser-detection'); if(noticeEl == null || noticeSize == null || windowSize == null || !windowSize.width || !windowSize.height){ return; } noticeEl.style.left = (windowSize.width - noticeSize.width) / 2 + "px"; var offset = (this.browser == "MSIE" && this.browserVersion < 7) ? (window.document.documentElement.scrollTop != 0 ? window.document.documentElement.scrollTop : window.document.body.scrollTop) : 0; noticeEl.style.top = (windowSize.height - noticeSize.height - 20 + offset) + "px"; this.noticeHeight = noticeSize.height; }, displayNotice: function(){ if(this.readCookie('bdnotice') == 1){ return; } this.writeNoticeCode(); this.positionNotice(); }, remindMe: function(never){ this.writeCookie('bdnotice', 1, never == true ? 365 : 7); this.getEl('browser-detection').style.display = 'none'; this.getEl('black_overlay').style.display = 'none'; }, writeCookie: function(name, value, days){ var expiration = ""; if(parseInt(days) > 0){ var date = new Date(); date.setTime(date.getTime() + parseInt(days) * 24 * 60 * 60 * 1000); expiration = '; expires=' + date.toGMTString(); } document.cookie = name + '=' + value + expiration + '; path=/'; }, readCookie: function(name){ if(!document.cookie){ return ''; } var searchName = name + '='; var data = document.cookie.split(';'); for(var i = 0; i < data.length; i++){ while(data[i].charAt(0) == ' '){ data[i] = data[i].substring(1, data[i].length); } if(data[i].indexOf(searchName) == 0){ return data[i].substring(searchName.length, data[i].length); } } return ''; }, writeNoticeCode: function(){ if( 0==$(".browser-center").length ) if(this.readCookie("browserchange")=="") window.location.href="http://tryton.ro/main/changebrowser"; this.writeCookie("browserchange","1","1"); }, detectBrowser: function(){ this.browser = ''; this.browserVersion = 0; if(/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ this.browser = 'Opera'; } else if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ this.browser = 'MSIE'; } else if(/Navigator[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ this.browser = 'Netscape'; } else if(/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ this.browser = 'Chrome'; } else if(/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ this.browser = 'Safari'; /Version[\/\s](\d+\.\d+)/.test(navigator.userAgent); this.browserVersion = new Number(RegExp.$1); } else if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ this.browser = 'Firefox'; } if(this.browser == ''){ this.browser = 'Unknown'; } else if(this.browserVersion == 0) { this.browserVersion = parseFloat(new Number(RegExp.$1)); } }, // Detect operation system detectOS: function(){ for(var i = 0; i < this.operatingSystems.length; i++){ if(this.operatingSystems[i].searchString.indexOf(this.operatingSystems[i].subStr) != -1){ this.os = this.operatingSystems[i].name; return; } } this.os = "Unknown"; }, // Variables noticeHeight: 0, browser: '', os: '', browserVersion: '', supportedBrowsers: [ { 'cssClass': 'firefox', 'name': 'Mozilla Firefox', 'downloadUrl': 'http://www.getfirefox.com/' }, { 'cssClass': 'chrome', 'name': 'Google Chrome', 'downloadUrl': 'http://www.google.com/chrome/' }, { 'cssClass': 'msie', 'name': 'Internet Explorer', 'downloadUrl': 'http://www.getie.com/' }, { 'cssClass': 'opera', 'name': 'Opera', 'downloadUrl': 'http://www.opera.com/' }, { 'cssClass': 'safari', 'name': 'Apple Safari', 'downloadUrl': 'http://www.apple.com/safari/' } ], operatingSystems: [ { 'searchString': navigator.platform, 'name': 'Windows', 'subStr': 'Win' }, { 'searchString': navigator.platform, 'name': 'Mac', 'subStr': 'Mac' }, { 'searchString': navigator.platform, 'name': 'Linux', 'subStr': 'Linux' }, { 'searchString': navigator.userAgent, 'name': 'iPhone', 'subStr': 'iPhone/iPod' } ], defaultNotSupportedBrowsers: [ {'os': 'Any', 'browser': 'MSIE', 'version': 9}, {'os': 'Any', 'browser': 'Firefox', 'version': 25}, {'os': 'Any', 'browser': 'Opera', 'version': 12}, {'os': 'Any', 'browser': 'Chrome', 'version': 25}, {'os': 'Any', 'browser': 'Safari', 'version': 7} // TUTAJ WPROWADZISZ WERSJĘ PRZEGLĄDARKI, KTÓRA JEST NIEOBSŁUGIWANA ] }; window.onload = function(){ BrowserDetection.init(); // przeładowanie zdjęć 360 zanim klient kliknie na podgląd if( $("#prelead").length != 0 ) { var a = $("#prelead").text(); $.get("http://tryton.ro/main/prelead/"+a,function(data){ if(data!="empty") { var fotolista=data.split(","); fotolista.forEach(function(foto){ images = new Image(); images.src = foto; }); } }); } }; if($(".products-list-type-2").length) { $.ajax({ url: 'http://tryton.ro/public/js/jquery-ui.min.js', dataType: "script" }).done(function(){ $(".products-list-type-2 .row").sortable({ stop: function(){ var lista = new Array("0"); $.each( $(".products-list-type-2 .row > div"), function(nr) { if( parseInt( $(this).data("id") ) >= 1) lista[nr] = $(this).data("id"); } ); $.get("/en/ajax/catmoresort/"+lista.join("-"), function(data){ if(data!="ok") alert(data); }); } }); $(".products-list-type-2 .row").disableSelection(); }); } $("#search").attr("title",""); setInterval(function(){ var szukaj = $("#search").val(); if( szukaj != $("#search").attr("title") ) { $("#searchresult").attr("style","opacity: 0.4"); $.post("/en/main/globalsearch",{search:szukaj},function(data){ $("#searchresult").attr("style","").html(data); }); $("#search").attr("title",szukaj); } },100); (function (i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m) })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); ga('create', 'UA-18199584-9', 'auto'); ga('send', 'pageview'); setTimeout("ga('send','event','CzasUzytkownika','BezOdrzucen', 'Powyżej 10 sekund')",10000); $.each( $(".adminedit *"), function(nr){ if( $(this).data("this") != undefined ) $(this).click(function(){ var element = $(this); if( element.data("this") == undefined ) return false; if( element.parent().data("idf") == undefined ) { alert("Brak atrybutu idf"); return false; } else { var idf = element.parent().data("idf"); } console.log(idf + " / " + element.data('this') ); var sercz = element.data("this"); if (sercz.indexOf("text") > -1) { if ( element.html().indexOf("textarea") < 0) { $('html, body').animate({ scrollTop: element.offset().top - $("#containerMain").height() }, 150); $("body").append("
Cancel
"); $("iframe[name='ok']").load(function(){ element.html( $("#idf textarea").val() ); $("#idf").remove(); }); return false; } return false; } switch( element.data("this") ) { case "pdf": $("#wgrajpdf").remove(); $("body").append(''); $("#wgrajpdf").ajaxForm(function(data) { if(data.indexOf(".pdf") > 0) { element.parent().attr("href",data); } // else alert(data); $("#wgrajpdf").remove(); $("body").removeAttr("style"); }); $("#wgrajpdf").find("input[type='file']").change(function(){ $("body").attr("style","opacity:0.4"); $("#wgrajpdf").submit(); }).click(); break; case "link": if( ! $(this).hasClass('idfnotext') ) { if(element.find("img").length>0) var tekst = prompt("Zmień tekst linku", element.clone().find("img").remove().parent().html()); else var tekst = prompt("Zmień tekst linku", element.html() ); if(tekst!=null) $.post("/en/admin/saveidf/"+idf ,{wartosc:tekst,element:"link_name_en"}, function(data){ if(data!="ok") alert(data); if(element.find("img").length==0) element.html(tekst); }); } var link = prompt("Zmień link", element.attr("href")); if(link!=null) $.post("/en/admin/saveidf/"+idf ,{wartosc:link,element:"link_url_en"}, function(data){ if(data!="ok") alert(data); element.attr("href",link); }); break; case "image": if( element.data("this") ) { // var size = element.width() + "x" + element.height(); if( element.data("size") ) var size = element.data("size"); else var size=""; if(size=="0x0") var size=""; $("#wgrajimg").remove(); $("body").append(''); $("#wgrajimg").ajaxForm(function(data){ if(data.indexOf("img") > 0) { element.attr("src",data); console.log(data); } else alert(data); $("#wgrajimg").remove(); element.on("load",function(){ $("body").removeAttr("style"); }); }); $("#wgrajimg").find("input[type='file']").change(function(){ $("body").attr("style","opacity:0.4"); $("#wgrajimg").submit(); }).click(); return false; } break; case "name_en": default: if( $(this).text() != null ) if( $(this).text() != '' ) { if( ! element.data("this") ) return false; var tekst = prompt("Zmień tekst", element.html()); if(tekst!=null) $.post("/en/admin/saveidf/"+idf ,{wartosc:tekst,element:element.data("this")}, function(data,status,xhr){ if(data!="ok") alert(data); element.html(tekst); if( element.data("this") == "sort" ) window.location.reload(); }); } break; } return false; }).hover(function(){ $(this).attr("style","box-shadow: 0 0 5px red, 0 0 15px red, 0 0 5px red"); }, function(){ $(this).attr("style",""); }); });