/** * * * Main file for javascript related to Tovek2014 template * * */ // Set domain of use for this file var sDomain = "ssl://tovek.se/"; /** * Script for topBar scrolling */ $(document).on( 'scroll', function() { if( $(document).scrollTop() > 53 ) { $("#topbar").addClass( "scroll" ); } else { $("#topbar").removeClass( "scroll" ); } } ); // ...and related cookie infoBar $(document).delegate("#cookiesInfo .link a", 'click', function(event) { event.preventDefault(); var dDate = new Date(); dDate.setTime( dDate.getTime() + (7*24*60*60*1000) ); var sExpires = "expires=" + dDate.toGMTString(); document.cookie = 'cookieInformation' + "=" + 'accepted' + "; " + sExpires + "; path=/"; $("#cookiesInfo").slideUp(); } ); /** * Global handling of ajax target links */ $(document).delegate( 'a.ajax[data-ajax-targetClass]', 'click', function(event) { event.preventDefault(); // Set target to class var sTarget = $(this).data( 'ajax-targetClass' ); if( typeof($(this).attr( 'data-ajax-targetid' )) !== 'undefined' ) { // Change targe to id var sTarget = $(this).data( 'ajax-targetid' ); } //console.log( $(this).attr("href") ); $.ajax( { url: $(this).attr("href"), type: "GET", data: "noCss=true", async: true, dataType: "html", beforeSend: function() {} } ).fail( function() { // Failed } ).done( function( data, textStatus, jqXHR ) { // Done $(sTarget).html(data).fadeIn( 400, function() { $(sTarget + " a.ajax[data-ajax-href]").each( function() { $(this).attr( "href", $(this).data("ajax-href") ); $(this).removeAttr( "data-ajax-href" ); } ); } ); setTimeout( function() { reloadTimers(); updateItemBid( null ); }, 500 ); } ); } ); /** * Deligated events block ---------------------------------------------- */ $(document).delegate("#autoscroll", 'click', function(event) { if( $('#autoscroll').prop('checked') === true ) { // On setCookie( "autoscroll", "on", "5" ); } else { // Off setCookie( "autoscroll", "off", "5" ); } } ); $(document).delegate("a.directLink", 'click', function(event) { event.preventDefault(); if( $(".directLinkContainer").hasClass("show") ) { $(".directLinkContainer").removeClass("show"); } else { $(".directLinkContainer").addClass("show"); } } ); $(document).delegate(".view.itemShow a.tellFriend", 'click', function(event) { event.preventDefault(); if( $(".tellFriendContainer").hasClass("show") ) { $(".tellFriendContainer").removeClass("show"); } else { $(".tellFriendContainer").addClass("show"); } } ); /** * End of deligated event block --------------------------------------- */ /** * Page load related jQuery */ $(document).ready( function() { $("img#spotlight-arrow").animate( { left: "-205px" }, 1000, function() { // Animation complete. } ); $("#spotlight div#spotlight-content").animate( { right: "165px" }, 1000, function() { // Animation complete. } ); /** * Function for global ajax target links */ initAjaxLinks(); var sAutoscrollStatus = getCookie( "autoscroll" ); if( sAutoscrollStatus == "on" ) { $("#autoscroll").attr( 'checked', 'checked' ); } var sCookieStatus = getCookie( "cookieInformation" ); if( typeof(sCookieStatus) !== "undefined" && sCookieStatus == "accepted" ) { $("#cookiesInfo").hide(); } } ); $( function() { $(".images ul li a.colorbox").colorbox( { rel: "itemImages", current: "Bild {current} av {total}", scalePhotos: true, width: "95%", height: "95%" } ); } ); $(document).delegate("a.ajaxPopup", 'click', function(event) { event.preventDefault(); var eLink = $(this); var sReturnUrl = window.location.href; var sTemplate = "