diff --git a/ajaxify-html5.js b/ajaxify-html5.js index c232db7..d61255d 100755 --- a/ajaxify-html5.js +++ b/ajaxify-html5.js @@ -2,7 +2,7 @@ // v1.0.1 - 30 September, 2012 // https://github.com/browserstate/ajaxify (function(window,undefined){ - + // Prepare our Variables var History = window.History, @@ -35,12 +35,12 @@ duration: 800, easing:'swing' }; - + // Ensure Content if ( $content.length === 0 ) { $content = $body; } - + // Internal Helper $.expr[':'].internal = function(obj, index, meta, stack){ // Prepare @@ -48,14 +48,14 @@ $this = $(obj), url = $this.attr('href')||'', isInternalLink; - + // Check link isInternalLink = url.substring(0,rootUrl.length) === rootUrl || url.indexOf(':') === -1; - + // Ignore or Keep return isInternalLink; }; - + // HTML Helper var documentHtml = function(html){ // Prepare @@ -64,40 +64,40 @@ .replace(/<(html|head|body|title|meta|script)([\s\>])/gi,'
/gi,'
') ; - + // Return return $.trim(result); }; - + // Ajaxify Helper $.fn.ajaxify = function(){ // Prepare var $this = $(this); - + // Ajaxify - $this.find('a:internal:not(.no-ajaxy)').click(function(event){ + $this.find('a:internal:not(.no-ajaxy),area:not(.no-ajaxy)').click(function(event){ // Prepare var $this = $(this), url = $this.attr('href'), title = $this.attr('title')||null; - + // Continue as normal for cmd clicks etc if ( event.which == 2 || event.metaKey ) { return true; } - + // Ajaxify this link History.pushState(null,title,url); event.preventDefault(); return false; }); - + // Chain return $this; }; - + // Ajaxify our Internal Links $body.ajaxify(); - + // Hook into State Changes $window.bind('statechange',function(){ // Prepare Variables @@ -113,7 +113,7 @@ // Animating to opacity to 0 still keeps the element's height intact // Which prevents that annoying pop bang issue when loading in new content $content.animate({opacity:0},800); - + // Ajax Request the Traditional Page $.ajax({ url: url, @@ -124,7 +124,7 @@ $dataBody = $data.find('.document-body:first'), $dataContent = $dataBody.find(contentSelector).filter(':first'), $menuChildren, contentHtml, $scripts; - + // Fetch the scripts $scripts = $dataContent.find('.document-script'); if ( $scripts.length ) { @@ -137,7 +137,7 @@ document.location.href = url; return false; } - + // Update the menu $menuChildren = $menu.find(menuChildrenSelector); $menuChildren.filter(activeSelector).removeClass(activeClass); @@ -154,7 +154,7 @@ document.getElementsByTagName('title')[0].innerHTML = document.title.replace('<','<').replace('>','>').replace(' & ',' & '); } catch ( Exception ) { } - + // Add the scripts $scripts.each(function(){ var $script = $(this), scriptText = $script.text(), scriptNode = document.createElement('script'); @@ -170,7 +170,7 @@ if ( $body.ScrollTo||false ) { $body.ScrollTo(scrollOptions); } /* http://balupton.com/projects/jquery-scrollto */ $body.removeClass('loading'); $window.trigger(completedEventName); - + // Inform Google Analytics of the change if ( typeof window._gaq !== 'undefined' ) { window._gaq.push(['_trackPageview', relativeUrl]);