/* Plugin Name: Advanced AJAX Page Loader Version: 2.6.0 Plugin URI: http://software.resplace.net/WordPress/AjaxPageLoader.php Description: Load pages within blog without reloading page, shows loading bar and updates the browsers URL so that the user can bookmark or share the url as if they had loaded a page normally. Also updates there history so they have a track of there browsing habbits on your blog! Author URI: http://dean.resplace.net Author: Dean Williams */ //Set this to true if your getting some javascript problems var AAPL_reloadDocumentReady = false; //Dont mess with these... var AAPL_isLoad = false; var AAPL_started = false; var AAPL_searchPath = null; var AAPL_ua = jQuery.browser; //The holy grail... jQuery(document).ready(function() { if (AAPL_warnings == true) { AAPL_jqVersion = jQuery().jquery; if (AAPL_jqVersion.substr(0,3) != "1.8" && AAPL_warnings == true) { alert("cmon guys, your jQuery version is outdated, please update it - I can see version: " + AAPL_jqVersion); } } AAPL_loadPageInit(""); }); window.onpopstate = function(event) { //We now have a smart multi-ignore feature controlled by the admin panel if (AAPL_started === true && AAPL_check_ignore(document.location.toString()) == true) { AAPL_loadPage(document.location.toString(),1); } }; function AAPL_loadPageInit(scope){ jQuery(scope + "a").click(function(event){ //if its not an admin url, or doesnt contain # if (this.href.indexOf(AAPLhome) >= 0 && AAPL_check_ignore(this.href) == true){ // stop default behaviour event.preventDefault(); // remove click border this.blur(); // get caption: either title or name attribute var caption = this.title || this.name || ""; // get rel attribute for image groups var group = this.rel || false; //Load click code - pass reference. try { AAPL_click_code(this); } catch(err) { if (AAPL_warnings == true) { txt="There was an error with click_code.\n\n"; txt+="Error description: " + err.message + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } } // display the box for the elements href AAPL_loadPage(this.href); } }); jQuery('.' + AAPL_search_class).each(function(index) { if (jQuery(this).attr("action")) { //Get the current action so we know where to submit to AAPL_searchPath = jQuery(this).attr("action"); //bind our code to search submit, now we can load everything through ajax :) //jQuery('#searchform').name = 'searchform'; jQuery(this).submit(function() { submitSearch(jQuery(this).serialize()); return false; }); } else { if (AAPL_warnings == true) { alert("Search form found but attribute 'action' missing!?!?!"); } } }); if (scope == "") { if (jQuery('#searchform').attr("action")) { //Get the current action so we know where to submit to AAPL_searchPath = jQuery('#searchform').attr("action"); //bind our code to search submit, now we can load everything through ajax :) //jQuery('#searchform').name = 'searchform'; jQuery('#searchform').submit(function() { submitSearch(jQuery(this).serialize()); return false; }); } else { if (AAPL_warnings == true) { alert("Could not bind to search form...\nCould not find element with id='searchform' or attribute 'action' missing."); } } } } function AAPL_loadPage(url, push, getData){ if (!AAPL_isLoad){ if (AAPL_scroll_top == true) { scroll(0,0); } AAPL_isLoad = true; //enable onpopstate AAPL_started = true; //AJAX Load page and update address bar url! :) //get domain name... nohttp = url.replace("http://","").replace("https://",""); firstsla = nohttp.indexOf("/"); pathpos = url.indexOf(nohttp); path = url.substring(pathpos + firstsla); //Only do a history state if clicked on the page. if (push != 1) { //TODO: implement a method for IE if (typeof window.history.pushState == "function") { var stateObj = { foo: 1000 + Math.random()*1001 }; history.pushState(stateObj, "ajax page loaded...", path); } else { if (AAPL_warnings == true) { alert("'pushState' method not supported in this browser, sorry about that!"); } } } if (!jQuery('#' + AAPL_content)) { if (AAPL_warnings == true) { alert("Could not find content region, you need to set an ID to an element that surrounds the content on the page, make sure the 'content' variable is also set to the ID name."); return false; } } //start changing the page content. jQuery('#' + AAPL_content).fadeOut("slow", function() { //See the below - NEVER TRUST jQuery to sort ALL your problems - this breaks Ie7 + 8 :o //jQuery('#' + AAPL_content).html(AAPL_loading_code); //Nothing like good old pure JavaScript... document.getElementById(AAPL_content).innerHTML = AAPL_loading_code; jQuery('#' + AAPL_content).fadeIn("slow", function() { jQuery.ajax({ type: "GET", url: url, data: getData, cache: false, dataType: "html", success: function(data) { AAPL_isLoad = false; //get title attribute datax = data.split('