Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for new Analytics.js, + scroll fallback #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions ajaxify-html5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Ajaxify
// v1.0.1 - 30 September, 2012
// v1.0.2, October 2015
// https://github.com/browserstate/ajaxify
(function(window,undefined){

Expand Down Expand Up @@ -167,12 +167,20 @@
});

// Complete the change
if ( $body.ScrollTo||false ) { $body.ScrollTo(scrollOptions); } /* http://balupton.com/projects/jquery-scrollto */
if ( $body.ScrollTo ) {
$body.ScrollTo(scrollOptions);
} /* http://balupton.com/projects/jquery-scrollto */
else{
// fallback if scrollTo plugin is not loaded:
$body.scrollTop( 0 );
}
$body.removeClass('loading');
$window.trigger(completedEventName);

// Inform Google Analytics of the change
if ( typeof window._gaq !== 'undefined' ) {
if ( typeof window.ga !== 'undefined' ){ // the new analytics API
window.ga( 'send', 'pageview', relativeUrl );
}else if ( typeof window._gaq !== 'undefined' ) { // the old API
window._gaq.push(['_trackPageview', relativeUrl]);
}

Expand All @@ -192,4 +200,4 @@

}); // end onDomLoad

})(window); // end closure
})(window); // end closure