Skip to content

Commit

Permalink
feat(js): Add config to disable asynchronous content loading
Browse files Browse the repository at this point in the history
  • Loading branch information
oswaldoacauan committed May 27, 2014
1 parent f0a4adf commit f794505
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/assets/js/scripts.js
Expand Up @@ -4,6 +4,7 @@
'use strict';

$(function () {
var GHOSTIUM = window.GHOSTIUM;

// Cache a couple of useful elements
// =================
Expand Down Expand Up @@ -42,7 +43,7 @@
// DISQUS Handlers
// =================
var _disqusHandler = function() {
if(!window.GHOSTIUM.haveDisqus) return;
if(!GHOSTIUM.haveDisqus) return;

if(typeof DISQUS === 'object' && $('#disqus_thread').length) {
DISQUS.reset({
Expand All @@ -55,7 +56,7 @@
};

var _disqusCounterHandler = function() {
if(!window.GHOSTIUM.haveDisqus) {
if(!GHOSTIUM.haveDisqus) {
$('[data-disqus-identifier]').parent('li').remove();
return;
}
Expand Down Expand Up @@ -88,7 +89,7 @@
// GA Handler
// =================
var _gaHandler = function() {
if(!window.GHOSTIUM.haveGA) return;
if(!GHOSTIUM.haveGA) return;

if(typeof ga === 'function') {
ga('set', 'location', window.location.href);
Expand All @@ -98,7 +99,7 @@

// PJax bindings
// =================
if ($.support.pjax) {
if ($.support.pjax && GHOSTIUM.enablePjax) {
$document.on('pjax:start', function() {
$surface.scrollTop(0);
});
Expand Down
1 change: 1 addition & 0 deletions src/default.hbs
Expand Up @@ -57,6 +57,7 @@
window.GHOSTIUM = {};
GHOSTIUM.haveGA = typeof ga_ua !== 'undefined' && ga_ua !== 'UA-XXXXX-X';
GHOSTIUM.haveDisqus = typeof disqus_shortname !== 'undefined' && disqus_shortname !== 'example';
GHOSTIUM.enablePjax = typeof enable_pjax !== 'undefined' ? enable_pjax : false;
</script>

<!-- build:js /assets/js/head-scripts.min.js -->
Expand Down
3 changes: 3 additions & 0 deletions src/partials/custom/config.hbs
Expand Up @@ -3,3 +3,6 @@ var ga_ua = 'UA-XXXXX-X';

{{! Your Disqus shortname }}
var disqus_shortname = 'example';

{{! Enable Pjax for asynchronous (AJAX) content loading }}
var enable_pjax = true;

0 comments on commit f794505

Please sign in to comment.