/** * Ajaxy - An Ajax-integration solution * (c) Copyright James Padolsey * For sale on ThemeForest.net */ // Delete this line in production code: if ( !window.jQuery ) { alert("jQuery is required for Ajaxy to run."); throw new Error("Ajaxy requires jQuery!"); } jQuery.ajaxy = (function(){ var settings = { /*** SETTINGS ***/ /* See documentation file, it will tell you how to configure Ajaxy */ domainBase: 'http://www.wvpe.com', base: '', homepage: 'index.php', anchorFilter: function() { // Add mailto to keep from redirecting mailto links. Jeremy Barngrover (3/23/2010) return !/.(pdf|jpe?g|gif|png|bmp|tif|txt|mp3|wmv|wma)$|(mailto)/.test(this.href); }, update: ['#container','title', '#session_data'], updateHandler: { '#container': function(newContent) { // '#content': function(newContent) { jQuery(this).animate({ height: "hide", opacity: 0 }, function(){ jQuery(this).html(newContent).animate({ height: "show", opacity: 1 }); log(jQuery('#container .script')+jQuery('#container .script').size()); jQuery.each(jQuery('#container .script'), function() { eval(this.innerHTML); } ); }); } }, initialStyles: "h1{visibility:hidden;} #content{height:0;opacity:0;overflow:hidden;}", loader: { css: { position: 'relative', background: '#FFF url(media/images/loader2.gif) no-repeat center', MozBorderRadius: 4, WebkitBorderRadius: 4, padding: '5px', fontSize: '.8em', opacity: 0, top: jQuery('#header').offset().top, left: -12, height: 16, width: 16 }, html: "", attr: {}, init: function(loader){ loader.appendTo('#header'); jQuery(document).ready(function(){ loader.css({ top: jQuery('#header').position().top + 88 }); }); }, show: function(loader, href){ loader.stop(true).animate({ opacity: 1 }); }, hide: function(loader){ loader.animate({ opacity: 0 }); } }, errorHandler: function( XHR ) { if (XHR.status === 404) { //$('#content').html('
404 Page Not Found
'); jQuery.ajaxy.load("404.php"); settings.loader.hide( ajaxy.loader ); } }, autoInit: true, cache: false /*** END SETTINGS ***/ }, /********************************** *** DON'T TOUCH ANYTHING BELOW *** **********************************/ run = false, HEAD = jQuery('head')[0], BODY = document.body, util = { isExternal: function(url) { return !RegExp('^' + location.href.match(/.+?\/(?=[^\/])/)[0] + location.hostname).test(url); }, hash: { bind: function(newHashFn) { //jQuery.historyInit( newHashFn ); jQuery.history.init(newHashFn); }, load: function(h){ return jQuery.history.load(h); } } }; function log(a) { arguments[0] = '[AJAXY] ' + a; return window.console && console.log && console.log.apply( console, arguments ); } /** Ajaxy **/ function load(href) { log("Load called: ", href); if (ajaxy.requestInProgress) { return; } /* Prepare loader */ if (!ajaxy.loader) { ajaxy.loader = jQuery(''); ajaxy.loader .css(settings.loader.css) .html(settings.loader.html) .attr(settings.loader.attr) .appendTo(BODY); settings.loader.init(ajaxy.loader); } settings.loader.show( ajaxy.loader, href ); ajaxy.requestInProgress = true; var requestPath = /\//.test(href) ? href.replace(/\/[^\/]+$/, '/') : ''; // Deal with absolute URLs href = href.replace( window.location.href.replace(/(:\/\/.+?\/).+/, '$1') + settings.base, '' ); // Deal with based-relative URLs href = href.replace( settings.base, '' ); jQuery.ajax({ url: href, cache: settings.cache, type: 'GET', complete: function(response, status) { log("XHR: " + status); if ( status !== "success" && status !== "notmodified" ) { return; } ajaxy.requestInProgress = false; var responseText = response.responseText .replace(//,'') .replace(/<(\/?)(body|head|html|title)(?=.*?>)/g, '<$1ajaxy$2') .replace(/