// function out(pid){ // var ajaxRequest; // try{ // ajaxRequest = new XMLHttpRequest(); // } catch (e){ // try{ // ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); // } catch (e) { // try{ // ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); // } catch (e){ // alert("error"); // return false; // } // } // } // ajaxRequest.onreadystatechange = function(){ // if(ajaxRequest.readyState == 4){ // } // // } // // ajaxRequest.open("GET", "/ajax/rc/"+pid, true); // ajaxRequest.send(null); // } // // // // var Yoffset = 50; // var Xvalue = 0; // var adOffset = 0; // var side = 'right'; // function mouseCoords(ev){ // ev = ev || window.event; // if(ev.pageX || ev.pageY){ // return {x:ev.pageX, y:ev.pageY}; // } // return { // x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, // y:ev.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) // }; // } // // // function mouseY(evt) { // if (!evt) evt = window.event; // if (evt.pageY) return evt.pageY; // else if (evt.clientY)return ev.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); // else return 0; // } // function overGame (ev, column, gameId){ // document.onmousemove = mouseMove; // document.onscroll = mouseMove; // switch(column){ // // case '1': // xPos = 193+adOffset; // direction = 'right'; // break; // case '2': // xPos = 383+adOffset; // direction = 'right'; // break; // case '3': // xPos = 573+adOffset; // direction = 'right'; // break; // case '4': // xPos = 763+adOffset; // direction = 'right'; // break; // } // Xvalue = xPos; // if(direction == 'right'){ // document.getElementById("dek").style.left = xPos + 'px'; // }else{ // document.getElementById("dek").style.left = Xvalue - 121 + 'px'; // } // side = direction; // changeContent(gameId); // document.getElementById("dek").style.display = 'block'; // } // function changeContent (gameId){ // document.getElementById("dek").innerHTML = ''; // } // function rollout (ev){ // ev = ev || window.event; // var relTarg = ev.relatedTarget || ev.toElement; // if(relTarg){ // if(relTarg.className != 'gr' && relTarg.className != 'gr_s'){ // document.getElementById("dek").style.display = 'none'; // document.getElementById("dek").style.left = 0 + 'px'; // document.onmousemove = null; // } // }else{ // document.getElementById("dek").style.display = 'none'; // document.getElementById("dek").style.left = 0 + 'px'; // document.onmousemove = null; // } // } // function mouseMove (ev) { // ev = ev || window.event; // var mousePos = mouseCoords(ev); // xMouse = mousePos.x; // yMouse = mousePos.y; // if(side == 'right'){ // document.getElementById("dek").style.left = Xvalue + 'px'; // document.getElementById("dek").style.padding = '4px 3px 3px 11px'; // document.getElementById("dek").style.backgroundImage = 'url(/i/roll-over_bg.gif)'; // }else{ // document.getElementById("dek").style.left = Xvalue - 121 + 'px'; // document.getElementById("dek").style.padding = '5px 18px 5px 5px'; // document.getElementById("dek").style.backgroundImage = 'url(/i/roll-over_bg.gif)'; // } // document.getElementById("dek").style.top = yMouse + 5 - Yoffset + 'px'; // } (function($) { // Accordion $.fn.accordion = function() { var animating = false; $(this).find('> .a-body').each(function(){ $(this).data('height', $(this).height()); }); $(this).find('> .a-h:not(.open)').addClass('closed') .next().hide().css('height',0); $(this).find('> .a-h').click(function(){ $('#views-today .list').getContent('popular/views/today'); if($(this).hasClass('closed') && animating == false){ animating = true; var domCurrent = $(this); var intCurrentHeight = domCurrent.next().data('height'); var domOpened = $(this).siblings('.open'); domOpened.addClass('closed').removeClass('open') .next().animate({'height': 0}, function() {$(this).hide()}); domCurrent.removeClass('closed').addClass('open') .next().show().animate({'height': intCurrentHeight}, function() { animating = false; }); } }); } })(jQuery); /* Game list Carousel */ (function($) { $.fn.gameListCarousel = function(method) { var defaults = { timeout: 2000, klass: 'current', child: '> li' } var settings = {} var methods = { init : function(options) { settings = $.extend({}, defaults, options) return this.each(function() { var $element = $(this), element = this, $next; $element.mouseenter(function() { clearTimeout($element.timer); }).mouseleave(function() { helpers.next($element); }); helpers.next($element); }); } } var helpers = { next: function($element) { $next = $element.find(settings.child + '.' + settings.klass).next(); if ($next.length == 0) { $next = $element.find(settings.child + ':first-child'); } $element.timer = setTimeout(function() { helpers.change($element, $next) }, settings.timeout); }, change: function($element, $next) { $next.siblings().removeClass(settings.klass); $next.addClass(settings.klass); helpers.next($element); } } if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { $.error( 'Method "' + method + '" does not exist in gameListCarousel plugin!'); } } })(jQuery); $(document).ready(function(){ $.scrolling = {status: false}; frontPageSliders(); tabTooltip(); rolOver(); //itemFocus(); itemClick(); $('#home-accordion').accordion(); var ftListCurrent = $('#ft-list').find('.current'); featuredRotator(); //$('.game-carousel-list').gameListCarousel(); // Ajaxed content for tabs sidebar // $('#rating-today .list').getContent('popular/rating/today'); // $('#rating-alltime .list').getContent('popular/rating/alltime'); // $('#views-today .list').getContent('popular/views/today'); // $('#views-alltime .list').getContent('popular/views/alltime'); }); function featuredRotator() { featuredtimer = setTimeout(function() { changeFeatured($('#ft-list .current').next().children(":first-child"), true) }, 2000); //console.log($('#ft-list .current').next().first()); $('#ft-list li').children(":first-child").mouseenter(function() { clearTimeout(featuredtimer); changeFeatured($(this)); }).mouseleave(function() { featuredtimer = setTimeout(function() { changeFeatured($('#ft-list .current').next().children(":first-child"), true) }, 2000); }); $('#ft-games li').children(":first-child").mouseenter(function() { clearTimeout(featuredtimer); }).mouseleave(function() { featuredtimer = setTimeout(function() { changeFeatured($('#ft-list .current').next().children(":first-child"), true) }, 2000); }); } function changeFeatured(item, rotate) { //console.info(item); if (item.length == 0) item = $('#ft-list li:first-child').children(":first-child"); var parentEl = item.parent('li'); var newClass = $(parentEl).siblings().removeAttr('class').end().addClass('current').attr('id'); $('#ft-bg').removeAttr('class').addClass(newClass); $('#ft-games li').removeClass('current'); $('#ft-games').find('.' + newClass).addClass('current'); if(rotate == true) featuredtimer = setTimeout(function() { changeFeatured(item.parent('li').next().children(":first-child"), true) }, 2000); } function frontPageSliders() { // Checking if there is enough elements in favorites if (!$('#top-slider .sb-content ul:nth-child(2)').length) $('#top-slider .sb-control').addClass('less'); // Slider for FP games $(".sb:not(.vertical) .sb-content").scrollable({ circular: true , onBeforeSeek: function() { $.scrolling.status = true; }, onSeek: function() { $.scrolling.status = false; } }); // Vertical slider .vertical .sb-content .items $(".vertical .sb-content").scrollable({ circular: true, vertical: true, onBeforeSeek: function(event, i) { $.scrolling.status = true; var index = this.getIndex()+1; if (i < 0) { index = this.getItems().length -1 ; } if(!this.getItems().eq(index).hasClass('sloaded')) { this.getItems().eq(index).addClass('loading'); } }, onSeek: function(event, tabIndex) { var root = this.getRoot(); var indx = 0; tabIndex += 1; if ($(root).parents('#games-preview').length > 0) { $(root).find('li[class~="act"]').each(function() { indx = $(this).index(); }); $('#games-preview ul:eq(' + tabIndex + ') li:eq(' + indx + ') a').click(); } $.scrolling.status = false; getSlide(this.getRoot(), tabIndex); } }); getSlide($(".vertical .sb-content")); $("ul.tabs").tabs("div.panes > .tab-item" , { onBeforeClick: function(event, i) { var pane = this.getPanes().eq(i) if (!pane.hasClass('ajaxed')) { var container = pane.find('.list'); container.html(''); container.load(this.getTabs().eq(i).attr("href")); pane.addClass('ajaxed'); } } }); // Disabling default click for slider controls & hide item-focus $('.next, .prev').click(function(){ $('#item-focus').css({'display': 'none'}); return false; }); } function getSlide(slider, slnum) { // // Function creates dom temp element, requests new sontent from php file and addis it to temp slides. // // Afterward it's cloned and added to scroller // // // // Noslides means that last time it checked for slides there wasn't any so it won't bother again. // // if (jQuery.data(slider.find('ul').eq(api.getIndex()+1)[0], "noslides") == true) return false; // // // Creating temp container for slides // if($('#temp-slide').length) $('#temp-slide').empty(); // else $('body').append('
'); // // // Main variables are set // var slider = slider; // var api = slider.data("scrollable"); // var id = slider.parent().parent().attr('id'); // // console.log(api.getIndex()); // var total = $("#"+id).attr('data'); // var slnum = api.getIndex()+1; // var size = api.getSize(); // var item = api.getItems().eq(slnum - 1); // // var sloaded = jQuery.data(slider[0], "sloaded"); // // console.log(slnum); // // // if (back) { // if(slnum == 1) { // slnum = total; // } else { // slnum = slnum - 1; // } // // } else { // // slnum = slnum+1; // if ( slnum > total) slnum = 1; // } // // // if (api.getItems().eq(slnum - 1).hasClass('sloaded')) { // slnum++ // // return false; // } // console.log('get me sl-num:' + slnum); // // current slide number // next or back // if back and zero restart to 6 // if back -1 // if next +1 var api = slider.data("scrollable"); if(slider.find('ul').eq(api.getIndex()+1).hasClass("sloaded")) { // console.log('skip'); return false; } // Creating temp container for slides if($('#temp-slide').length) $('#temp-slide').empty(); else $('body').append('
'); // // Main variables are set var slider = slider; var id = slider.parent().parent().attr('id'); // console.log(api.getIndex()); var total = $("#"+id).attr('data'); //var slnum = api.getIndex()+1; //var size = api.getSize(); // var item = api.getItems().eq(slnum - 1); // var sloaded = jQuery.data(slider[0], "sloaded"); // if(total <= api.getSize()) return false; // console.log(api.getIndex()); if(!slnum) var slnum = 1; if (!slider.hasClass('loaded')) { var i=1; for (i=1;i<= total -1 ;i++) { api.addItem($("#temp-slide ul").clone()); } slider.addClass('loaded'); } // Receiving data with ajax $.get('ajax/' + id + '/'+slnum, function(response, status, xhr) { if (status == "success" && response != false) { // slider.find('ul').eq(api.getIndex()+1).addClass("loading") $('#temp-slide').html(response).find('li').unwrap(); //$('#temp-slide ul').repaceWith($('#temp-slide ul li').contents()); //$('.my-wrapper').replaceWith( $('.my-wrapper').contents() ); // $('#temp-slide ul').addClass("sloaded"); slider.find('ul').eq(api.getIndex()+1).addClass("sloaded").html(response).find('li').unwrap(); jQuery.data(slider.find('ul').eq(api.getIndex()+1), "sloaded", true); //api.addItem($("#temp-slide ul").clone()); slider.find('ul').eq(api.getIndex()+1).removeClass("loading"); // jQuery.data(slider[0], "sloaded", sloaded++); } else { // As explained in begining of the function. This should stop unrequired requests to server. //jQuery.data(slider[0], "noslides", true); return false; } }); } function tabTooltip() { $('#home-accordion .tabs li a').mouseenter(function() { // Place content before calculate dimensions and positions $('#tab-tooltip p').text($(this).attr('title')); var pos = $(this).offset(); pos.top = pos.top - $('#tab-tooltip').height() - 5; pos.left = pos.left - $('#content').offset().left - 82 + $(this).innerWidth()/2; // Show tooltip $('#tab-tooltip').css({'top': pos.top, 'left':pos.left, 'visibility':'visible'}) }); $('#home-accordion .tabs li a').mouseleave(function() { var pos = false; $('#tab-tooltip').css('visibility','hidden'); }); } function rolOver () { $('body').mousemove(function(e){ $('#dek').css({'top': e.pageY - 45}); }); $('.game-list-column:not(:eq(3)) .game-list li a, .game-list-column:not(:eq(3)) .game-list li .aboutThisGame').live('mouseenter', function() { var img = $(this).attr('rel'); var pos = $(this).offset(); //$('#dek').removeClass('dek-left').find('img').attr('src',img).end().show().css({'top':pos.top -40, 'left':pos.left - $('#content').offset().left + 207 }); $('#dek').removeClass('dek-left').find('img').attr('src',img).end().show().css({'left':pos.left - $('#content').offset().left + 207 }); }); $('#home-accordion .list li a, #home-accordion .list li .aboutThisGame, .game-list-column:eq(3) .game-list li a, .game-list-column:eq(3) .game-list li .aboutThisGame').live('mouseenter', function() { var img = $(this).attr('rel'); var pos = $(this).offset(); $('#dek').addClass('dek-left').find('img').attr('src',img).end().show().css({'left':pos.left - $('#content').offset().left - 165 }); }); $('#home-accordion .list li a, .game-list li a, #home-accordion .list li .aboutThisGame, .game-list li .aboutThisGame').live('mouseleave', function() { $('#dek').hide(); }); } function changePreview(data) { var image = new Image(); $(image).load(function () { $(this).css('display', 'none'); $('.game-preview').append(this); $(this).fadeIn(function() { $('.game-title h4').html(data.title); $('.game-title a').html(data.category).attr({'href': data.href}); $('.game-title, .game-title-bg').animate({marginTop: 0}, 500); }); }).attr('src', data.src); } function makeAjax(data) { $.ajax({ beforeSend: function() { $('.game-preview img').remove(); $('.game-title, .game-title-bg').css({'margin-top': -60}); }, url: 'ajax.php', data: data, success: function(data) { changePreview(data); }, dataType: 'json' }); } $.fn.itemClickAction = function () { $(this).parents('div:first').find('li[class~="act"]').each(function() { $(this).removeClass('act'); }); var id = $(this).parent('li').attr('class'); $(this).parent('li').addClass('act'); makeAjax({id: id}); var minusContent = $('#content').offset().left; var pos = $(this).offset(); pos.left -= minusContent + 24; pos.top -= 0; $('#item-click').css({'display': 'block', 'left': pos.left, 'top': pos.top}); } $.fn.itemFocusAction = function () { if ($('#item-focus').length == 0) { var obj = $('
'); $('body').prepend(obj); } if (!$.scrolling.status) { $('#item-focus').removeAttr('class'); var args = arguments[0] || {}; var minusContent = $('#content').offset().left; className = typeof args.className == 'undefined' ? '' : args.className; minusleft = typeof args.minusleft == 'undefined' ? 17 : args.minusleft; minustop = typeof args.minustop == 'undefined' ? 23 : args.minustop; var href = $(this).attr('href'); var img = $(this).find('img'); var src = $(img).attr("src"); var title = $(img).attr("alt"); var pos = $(this).offset(); pos.left -= minusContent + minusleft; pos.top -= minustop; $('#item-focus a').attr({'title': title, 'href': href}); $('#item-focus img').attr('src', src); $('#item-focus span').html(title); $('#item-focus').addClass(className).css({'display': 'block', 'left': pos.left, 'top': pos.top}); $('#item-focus').mouseleave(function() { $(this).css({'display': 'none'}); }); } } function itemFocus() { $('#slider-big .sb:not(.vertical) .items ul li a, .orange .items ul li a, .red .items ul li a, .red .head ul li a, .green .head ul li a, .orange .head ul li a').mouseenter(function() { $(this).itemFocusAction(); }); $('#top-slider .items ul li a').mouseenter(function() { $(this).itemFocusAction({className: 'focus-blue'}); }); } function itemClick() { $('#games-preview .items ul li a').click(function() { $(this).itemClickAction(); return false; }); if ($('#games-preview').length > 0) { // If home page with game preview $('#slider-big .tabs li:last').click(function() { if ($('#item-click').length > 0) { $('#item-click').css({'visibility': 'visible', 'z-index': 100}); } else { // crete new element var obj = $('
').attr({'id': 'item-click'}); $('body').prepend(obj); $('#games-preview ul[class!="cloned"]:first li:eq(1) a').click(); } }); $('#slider-big .tabs li:first').click(function() { $('#item-click').css({'visibility': 'hidden', 'z-index': 0}); }); } } (function($){ $.fn.extend({ getContent: function(options) { var container = $(this); return this.each(function() { // Receiving data with ajax $.get('ajax/' + options, function(response, status, xhr) { if (status == "success" && response != false) { container.html(response); } else { } }); }); } }); })(jQuery);