var pageLoader = new Class({ Implements: [Options, Events], options: { links: 'a.ajax:not([target="_blank"])', container: null, onStart: function () {}, onComplete: function () {}, }, initialize: function (options) { var _this = this; this.setOptions(options); window.history.uniqueStateId = 0; window.history.data = {}; //this.addEvents(); this.formCheck = null; this.url = null; this.hisReq = null; this.noScroll = false; this.clickedElement = null; this.fx1 = new Fx.Tween($(this.options.container)); this.fx2 = new Fx.Tween($(this.options.container)); this.fx1.addEvent( "onComplete", function () { this.formCheckReset(); $(this.options.container).set("html", this.html); this.fx2.start("opacity", 1); alerts.clear(); this.initPage(); if (!this.noScroll) { fxWindow.start(0, $("main").getCoordinates().bottom - 50); } else { fxWindow.set(0, 0); } //var scripts=$(this.options.container).getElements('script'); $(this.options.container) .getElements("script") .each(function (script) { eval(script.get("text")); }); if ($("recaptcha")) { try { grecaptcha.render("recaptcha", { sitekey: "6LeXwgcUAAAAACVjycsrVopWdvzEaWCQYsHOQy4C", }); } catch (error) {} } //eval(.get('text')); }.bind(this) ); this.hisReq = new Request.JSON({ link: "cancel", onSuccess: function (resp) { _this.html = resp.html; document.title = resp.title; $(document) .getElement("meta[name=description]") .setProperty("content", resp.description); $(document) .getElement("meta[name=keywords]") .setProperty("content", resp.keywords); $(document) .getElement("meta[name=robots]") .setProperty("content", resp.robots); _this.fx1.start("opacity", [1, 0]); }, }); if (!!window.history) { (function () { var historyAjax = function (url, state) { if (state && state.stateId) { setActiveLink(window.history.data[state.stateId].lastClicked); } else { setActiveLink(false); } var fullscreenButton = $(document.body).getElement( "header a.scroll.active" ); if (fullscreenButton) { fullscreenButton.fireEvent("click"); } if (url.indexOf("#") > -1) { url = url.split("#").pop(); _this.noScroll = false; } else { _this.noScroll = true; } // else // url=''; //if(url.indexOf('/')==0) // url=url.substr(1); _this.hisReq .setOptions({ url: url.replace("#", "") + (url.indexOf("?") > -1 ? "&ajax=1" : "?ajax=1"), }) .get(); }; History.addEvent("change", historyAjax); var listener = function (event) { if (event.target.tagName == "A" || event.target.getParent("a")) { event.stop(); _this.clickedElement = event.target.getParent("a") ? event.target.getParent("a") : event.target; try { ga("send", "pageview", this.get("href")); } catch (err) {} var data = { lastClicked: event.target }; var uniqueStateId = Date.now(); window.history.data[uniqueStateId] = data; History.push(_this.clickedElement.get("href"), document.title, { stateId: uniqueStateId, }); } }; $(document.body).addEvent( 'click:relay(a.ajax:not([target="_blank"]))', listener ); /*if (!History.hasPushState()) window.addEvent('domready', function(){ var hash = document.location.hash.substr(1); if (!hash) return; var path = document.location.pathname.split('/'); path = path[path.length - 1]; if (hash == path) return; historyAjax(hash); */ var hash = document.location.hash.substr(1); if (hash) historyAjax(window.location.href); /*});*/ })(); } }, start: function (url, data) { this.hisReq .setOptions({ url: url + (url.indexOf("?") > -1 ? "&ajax=1" : "?ajax=1"), }) .post(data); }, initPage: function () { var _this = this; //if(Browser.name=='ie'){ if (document.documentMode || /Edge/.test(navigator.userAgent)) { new imgBicubicInterpolation($$("img:not(.notbicubic)")); } if (navigator.userAgent.match("Buliba")) { $$('a[data-target="_blank"]').each(function (el) { el.setAttribute("target", "_blank"); }); } installFC(); /* $$('div.orphans,div.orphans *').each(function(el){ if(el.get('html').stripTags('br')==el.get('html').stripTags()){ var tekst=el.get('html'); tekst=tekst.replace(/(\s)([\S])[\s]+/g,"$1$2 "); tekst = tekst.replace(/(\s)([^<][\S]{1})[\s]+/g,"$1$2 "); el.set('html',tekst); } }); */ $$("a.ajax").each(function (el) { if (!el.retrieve("ajaxed")) { el.addEvent("click", function (e) { //e.stopPropagation(); //setActiveLink(this); // window.scrollTo(0,bodySize.y-60); //fxWindow.start(0,bodySize.y-60); }); el.setProperty( "href", document.location.href.split("#").shift() + "#" + el.getProperty("href") ).store("ajaxed", true); } }); this.removeOrphans(); if ($("signin")) { $("signin") .getElement("#labregister") .addEvent("click", function () { fxWindow.start(0, $("register").getCoordinates().top - 100); }); } $$('input[name="guest-book-step"]').each(function (el, i) { el.addEvent("click", function (e) { (function () { if (el.checked) { //(function(){new Fx.Scroll($(window),{duration:1000,offset:{x:0,y:-50}}).toElement($$('div.add-comment,div.view-all')[i]);}).delay(500); new Fx.Scroll($(window), { duration: 1000, offset: { x: 0, y: -50 }, }).toElement($("guest-book").getElement("div.add-comment")); } else { new Fx.Scroll($(window), { duration: 1000, offset: { x: 0, y: -50 }, }).toElement($("guest-book")); } }.delay(100)); }); }); if ($("guest-book-slider")) { var slides = $$("#guest-book-slider>div"); var currentSlide = 0; var slideInterval = setInterval(nextSlide, 5000); function nextSlide() { slides[currentSlide].removeClass("showing"); currentSlide = (currentSlide + 1) % slides.length; slides[currentSlide].addClass("showing"); } /* if($$('#guest-book-slider>div').length>0){ new SlideShow($('guest-book-slider'), { autoplay: true, delay: 5000, duration: 1500, transition: 'fadeThroughBackground', selector:'>div' }); }*/ // $('guest-book-slider').getElement('a.addcomment').addEvent('click',function(){ // this.destroy(); // }); } if ($("guest-book-all")) { $$("#guest-book-all a.prev,#guest-book a.next").addEvent( "click", function (e) { e.stop(); var _this = this; $("guest-book-all").getElement(">div").removeClass("showing"); (function () { new Request.JSON({ url: _this.getProperty("href"), link: "cancel", onSuccess: function (resp) { //$('guest-book-all').getElement('div.comment').set('text',resp.wpis.tresc); //$('guest-book-all').getElement('span.nick span').set('text',resp.wpis.nick); //$('guest-book-all').getElement('span.nick em').set('text',resp.wpis.wiek); $("guest-book-all") .getElement(">div") .set("html", resp.html) .addClass("showing"); // $('guest-book-all').getElement('>div').fade('in'); if (resp.last == 1) { $("guest-book-all") .getElement("a.next") .addClass("invisible"); } else { $("guest-book-all") .getElement("a.next") .removeClass("invisible"); } if (resp.first == 1) { $("guest-book-all") .getElement("a.prev") .addClass("invisible"); } else { $("guest-book-all") .getElement("a.prev") .removeClass("invisible"); } }, }).post("act=" + (_this.hasClass("prev") ? "prev" : "next")); }.delay(500)); } ); } if ($("send-to-friend")) { if ( navigator.userAgent.indexOf("Safari") != -1 && navigator.userAgent.indexOf("Chrome") == -1 ) { $("send-to-friend").addEvent("mousemove", function (e) { if (isDrawing) { $("pencil").setStyles({ left: e.event.clientX, top: e.event.clientY, }); } else { $("pencil").removeProperty("style"); } }); } var isDrawing = false; var curColor = $$("#send-to-friend span.color")[0].getProperty( "data-color" ); var sX, sY; var paint; var canvasDiv = $("send-to-friend").getElement("#canvas"); canvas = document.createElement("canvas"); var size = canvasDiv.measure(function () { return this.getSize(); }); canvas.setAttribute("width", size.x); canvas.setAttribute("height", size.y); //canvas.setAttribute('id','canvas'); canvasDiv.appendChild(canvas); if (typeof G_vmlCanvasManager != "undefined") { canvas = G_vmlCanvasManager.initElement(canvas); } context = canvas.getContext("2d"); context.rect(0, 0, context.canvas.width, context.canvas.height); context.fillStyle = "white"; context.fill(); context.lineJoin = "round"; context.lineWidth = 5; $$("#send-to-friend span.color").addEvent("click", function (e) { e.stop(); $$("#send-to-friend span.color").removeClass("selected"); this.addClass("selected"); curColor = this.getProperty("data-color"); $("send-to-friend").addClass("drawing"); $("pencil").setStyles({ left: e.event.clientX, top: e.event.clientY }); isDrawing = true; }); var fc = new FormCheck($("send-to-friend"), { onValidateSuccess: function () { $("send-to-friend").getElement('input[name="image"]').value = canvas.toDataURL(); }, ajaxSubmit: true, ajaxOptions: { onSuccess: function (resp) { var resp = JSON.decode(resp); context.rect(0, 0, context.canvas.width, context.canvas.height); context.fillStyle = "white"; context.fill(); clearForm($("send-to-friend")); alerts.alert(resp.msg, { callbacks: [ { label: "ok", callback: function () {}, }, { label: "no", callback: function () {}, }, ], klass: null, width: resp.width, }); }, }, container: $(document.body), display: { showErrors: 0, titlesInsteadNames: true, scrollToFirst: true, tipsPosition: "right", tipsOffsetX: -20, tipsOffsetY: -10, replaceTipsEffect: 0, }, }); $("send-to-friend").store("fc", fc); $("send-to-friend").addEvent("mouseleave", function () { this.removeClass("drawing"); isDrawing = false; $("pencil").removeProperty("style"); }); $("send-to-friend") .getElements("fieldset fieldset,fieldset fieldset *") .addEvent("click", function (e) { e.stopPropagation(); $("send-to-friend").removeClass("drawing"); isDrawing = false; $("pencil").removeProperty("style"); }); $("send-to-friend").addEvent("mousedown", function (e) { if (e.target.get("tag") != "input" && e.target.get("tag") != "button") { e.stop(); isDrawing = true; $("send-to-friend").addClass("drawing"); $("pencil").setStyles({ left: e.event.clientX, top: e.event.clientY, }); } }); /* $('send-to-friend').addEvent('submit',function(e){ e.stop(); new Request.HTML({ url:'polec-nas.html', onComplete:function(text){ context.rect(0,0,context.canvas.width,context.canvas.height); context.fillStyle="white"; context.fill(); } }).post($('send-to-friend')); }); */ $("canvas").addEvent("mousedown", function (e) { sX = e.page.x - this.getCoordinates().left; sY = e.page.y - this.getCoordinates().top; paint = true; $("send-to-friend").addClass("drawing"); //$('send-to-friend').getElement('fieldset fieldset').addClass('hidden'); }); $("canvas").addEvent("mousemove", function (e) { if (paint) { mX = e.page.x - this.getCoordinates().left; mY = e.page.y - this.getCoordinates().top; context.beginPath(); context.moveTo(sX, sY); context.lineTo(mX, mY); context.closePath(); context.strokeStyle = curColor; context.stroke(); (sX = mX), (sY = mY); } }); $("canvas").addEvent("mouseup", function (e) { paint = false; // $('send-to-friend').getElement('fieldset fieldset').removeClass('hidden'); }); $("canvas").addEvent("mouseleave", function (e) { paint = false; // $('send-to-friend').getElement('fieldset fieldset').removeClass('hidden'); }); } if ($("kup")) { $$("#rprzelew").addEvent("click", function () { $$( '#kup>fieldset>fieldset:nth-of-type(3) input[type="radio"]' ).setProperty("checked", false); }); $$("#rsms").addEvent("click", function () { $$( '#kup>fieldset>fieldset:nth-of-type(2) input[type="radio"]' ).setProperty("checked", false); $("kup").retrieve("fc").reinitialize("forced"); }); $$('#kup input[type="radio"].sms').addEvent("click", function () { $("back").set("text", this.getProperty("data-gra")); }); $("kup") .getElement("fieldset.details fieldset.right a") .addEvent("click", function (e) { e.stop(); new Request({ method: "post", url: "./index.php", data: "url=sms&kod=" + $("kup").getElement('input[name="kod"]').getProperty("value") + "&key=" + $("kup") .getElement('input[type="radio"].sms:checked') .getProperty("value"), onSuccess: function (json) { var resp = JSON.decode(json); alerts.alert(resp.msg, { callbacks: [ { label: "ok", callback: function () { if (resp.backurl) { window.location.href = resp.backurl; } }, }, { label: "no", callback: function () {}, }, ], }); }, }).send(); }); } // milkbox.reloadPageGalleries(); if ($("galeria")) { /* var carouselDefault = new PureJSCarousel({ carousel: '#galeria', slide: '.slide' }); */ /*pureJSCarousel({ container: '#galeria', infinite : false, item:'a.slide', speed : 1000 });*/ new tbCarousel({ container: "galeria", navContainer: "galeria-nav", rows: 1, }); } if ($("account")) { $$("#account fieldset.gamers").addEvent( 'keyup:relay(input[type="text"])', function (event, target) { target.setProperty("size", target.getProperty("value").length + 3); } ); $$('fieldset.gamers input[type="text"]').each(function (el) { if (el.getProperty("value") != "") { el.setProperty("size", el.getProperty("value").length + 3); } }); $$("#account fieldset.gamers").addEvent( 'focus:relay(input[type="text"][name="age"][data-id])', function (event, target) { var age = parseInt(target.getProperty("value")); if (!isNaN(age)) { target.value = age; } else { target.value = ""; } } ); $$("#account fieldset.gamers").addEvent( 'blur:relay(input[type="text"][data-id])', function (event, target) { var parent = target.getParent(); var name = parent .getElement('input[name="name"]') .getProperty("value") .trim(); var age = parseInt( parent.getElement('input[name="age"]').getProperty("value") ); if (isNaN(age)) { age = 0; } if (target.getProperty("name") == "name" && !name) { parent.destroy(); } new Request.JSON({ url: "index.php", onComplete: function (resp) { if (resp.status == "OK") { if (target.getProperty("name") == "age") { if (age > 0) { var postfix = ""; if (age == 1) { postfix = target .getParent("fieldset.gamers") .getProperty("data-age1"); } else if ( age % 10 > 1 && age % 10 < 5 && !(age % 100 >= 10 && age % 100 <= 21) ) { //console.log(1); postfix = target .getParent("fieldset.gamers") .getProperty("data-age2"); } else { postfix = target .getParent("fieldset.gamers") .getProperty("data-age21"); } target.value = age + " " + postfix; } else { target.value = ""; } } /* $$('fieldset.gamers input[type="text"]').each(function(el){ el.setProperty('size',el.getProperty('value').length+3); });*/ } }, }).post( "url=gamers&id=" + target.getProperty("data-id") + "&name=" + name + "&age=" + age ); } ); $("account") .getElement("fieldset.gamers a") .addEvent("click", function (event) { event.stop(); var _this = this; var previous = this.getPrevious("span"); var name = previous .getElement('input[name="name"]') .getProperty("value") .trim(); var age = parseInt( previous.getElement('input[name="age"]').getProperty("value") ); if (isNaN(age)) { age = 0; } if (name) { new Request.JSON({ url: "index.php", onComplete: function (resp) { if (resp.status == "OK") { var postfix = ""; if (age == 1) { postfix = _this .getParent("fieldset.gamers") .getProperty("data-age1"); } else if ( age % 10 > 1 && age % 10 < 5 && !(age % 100 >= 10 && age % 100 <= 21) ) { postfix = _this .getParent("fieldset.gamers") .getProperty("data-age2"); } else { postfix = _this .getParent("fieldset.gamers") .getProperty("data-age21"); } var spanContainer = new Element("span").inject( previous, "before" ); new Element("input", { type: "text", name: "name", value: name, "data-id": resp.id, }).inject(spanContainer); new Element("input", { type: "text", name: "age", value: age > 0 ? age + " " + postfix : "", "data-id": resp.id, }).inject(spanContainer); previous.getElements("input").setProperty("value", ""); $$('fieldset.gamers input[type="text"]').each(function (el) { el.setProperty("size", el.getProperty("value").length + 3); }); } }, }).post("url=gamers&id=&name=" + name + "&age=" + age); } }); var logoutLink = $("account").getElement("fieldset.end a"); logoutLink.setProperty( "href", logoutLink + "?back=" + encodeURIComponent(location.pathname) ); /*$$('#account fieldset.my-games a.subscription').addEvent('click',function(e){ e.stop(); var _this=this; new Request({ url:_this.getProperty('href'), onComplete:function(html){ $('account').getNext().set('html',html); fxWindow.start(0,$('kup').getCoordinates().top-100); } }).post(); });*/ } if ($("subscriptions")) { var subscriptionsCarousel = new tbCarousel({ container: $("subscriptions").getElement("div.grid"), navContainer: "subscriptions-nav", rows: 3, }); $(document.body).addEvent( "click:relay(#subscriptions a.slide)", function (e, target) { if (e !== undefined) e.stop(); $$("#subscriptions a.slide").removeClass("active"); new Request({ url: "index.php", onComplete: function (text) { target.addClass("active"); $("subscription-details").set("html", text); _this.removeOrphans(); //if(Browser.name=='ie'){ if (document.documentMode || /Edge/.test(navigator.userAgent)) { new imgBicubicInterpolation($$("img:not(.notbicubic)")); } }, }).post("url=subscription&id=" + target.getProperty("data-id")); } ); //$(document.body).fireEvent('click:relay(#subscriptions a.slide:first-of-type)'); } if ($("my-games")) { new tbCarousel({ container: "my-games", navContainer: "my-games-nav", slidesSelector: "div.slide", rows: 1, }); /* $$('#my-games .slide>div>a+a').addEvent('click',function(e){ e.stop(); var id=this.getProperty('href').replace('#',''); subscriptionsCarousel.toPage($$('#subscriptions a[data-id="'+id+'"]')[0].getProperty('data-page')); });*/ } /* if($('galeria')){ if($$('#galeria div.image').length>1){ var slider=new SlideShow($('galeria'), { autoplay: true, delay: 5000, duration: 500, transition: 'pushLeft', selector:'div.image', onShow:function(data){ $$('#galeria-nav span').removeClass('active'); $$('#galeria-nav span')[data.next.index].addClass('active'); } }); $('galeria').store('slider',slider); $('galeria').getElements('a.prev,a.next').addEvent('click',function(e){ e.stop(); if(this.hasClass('prev')) $('galeria').retrieve('slider').show('previous',{transition:'pushRight'}); else $('galeria').retrieve('slider').show('next',{transition:'pushLeft'}); }); $$('#galeria-nav span').each(function(el,i){ el.store('index',i); el.addEvent('click',function(){ $('galeria').retrieve('slider').show(this.retrieve('index')); }); }); $$('#galeria div.image').addEvents({ 'touchstart':function(e){ if(is_touch_device()){ e.preventDefault(); $('galeria').store('touchX',e.touches[0].pageX); } }, 'touchmove':function(e){ if(is_touch_device()){ e.preventDefault(); var touchX=$('galeria').retrieve('touchX'); if(Math.abs(touchX-e.touches[0].pageX)>10){ if(touchXdiv *,#subscription-details>div").each( function (el) { //if(el.get('html').stripTags('br')==el.get('html').stripTags()){ var tekst = el.get("html"); tekst = tekst.replace(/(\s)([\S])[\s]+/g, "$1$2 "); // tekst = tekst.replace(/(\s)([^<][\S]{1})[\s]+/g,"$1$2 "); // tekst = tekst.replace(/(\s)([^<][\S]{2})[\s]+/g,"$1$2 "); el.set("html", tekst); //} } ); }, formCheckReset: function () { $$("form").each(function (el) { var fc = el.retrieve("fc"); if (fc) { fc.reinitialize("forced"); } }); //if(this.formCheck!=null) //this.formCheck.reinitialize('forced'); }, });