|
(function(window,undefined){ |
|
|
|
// Load Helpers |
|
var |
|
intervalScript, intervalJquery, |
|
loadScript = function(scriptUrl){ |
|
var e = document.createElement('script'); |
|
e.setAttribute('src',scriptUrl); |
|
window.document.body.appendChild(e); |
|
return e; |
|
}; |
|
|
|
// Load In Basic Dependencies |
|
if ( typeof window.jQuery === 'undefined' || /^1\.[0-3]/.test(window.jQuery.fn.jquery) ) { |
|
loadScript('https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'); |
|
} |
|
if ( typeof window.JSON === 'undefined' ) { |
|
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/json2.js'); |
|
} |
|
if ( typeof window.amplify === 'undefined' ) { |
|
loadScript.apply(window,['https://raw.github.com/balupton/history.js/master/scripts/compressed/amplify.store.js']); |
|
} |
|
|
|
// Load In Advanced Dependencies |
|
intervalJquery = setInterval(function(){ |
|
if ( typeof window.jQuery !== 'undefined' ) { |
|
clearInterval(intervalJquery); |
|
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/history.adapter.jquery.js'); |
|
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/history.js'); |
|
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/history.html4.js'); |
|
loadScript('https://raw.github.com/balupton/jquery-scrollto/master/scripts/jquery.scrollto.min.js'); |
|
} |
|
},500); |
|
|
|
// Load In Script |
|
intervalScript = setInterval(function(){ |
|
if ( typeof window.jQuery !== 'undefined' && typeof window.JSON !== 'undefined' && typeof window.amplify !== 'undefined' && typeof window.History !== 'undefined' && typeof window.History.initHtml4 !== 'undefined' ) { |
|
if ( window.console ) { |
|
window.console.log('Loading in script'); |
|
} |
|
$(loadScript('https://raw.github.com/gist/854622/ajaxify-html5.js')).bind('load',function(){ |
|
if ( typeof window.historyjsitNoAlert === 'undefined' ) { |
|
alert('History.js It! Is ready for action!'); |
|
} |
|
}); |
|
clearInterval(intervalScript); |
|
} |
|
else if ( window.console ) { |
|
window.console.log('Waiting for dependencies to load'); |
|
} |
|
},500); |
|
|
|
})(window); |