code with words

This commit is contained in:
Adam Bradley
2013-08-25 01:32:30 -05:00
parent 8f59ba549a
commit 583c0826eb
14 changed files with 244 additions and 90 deletions

View File

@ -1,31 +1,39 @@
(function(window, document, framework) {
// Start initalizing the framework
function initalize() {
framework.trigger("initalized");
}
// remove the ready listeners
document.removeEventListener( "DOMContentLoaded", initalize, false );
window.removeEventListener( "load", initalize, false );
// DOM has completed
function completed() {
// remove any listeners
document.removeEventListener( "DOMContentLoaded", completed, false );
window.removeEventListener( "load", completed, false );
// trigger that the DOM is ready
framework.trigger("ready");
// init the framework
initalize();
// ensure that the start page has an id
var mainElement = document.querySelector("main");
if(mainElement) {
if(!mainElement.id || mainElement.id === "") {
mainElement.id = "pg" + Math.floor( Math.random() * 999999 );
}
// remember what the active page's id is
framework.activePageId = mainElement.id;
// inform the framework that the start page has been added to the DOM
framework.trigger("pagecreate", {id: mainElement.id, url: location.href});
// trigger that the start page is in view
framework.trigger("pageview");
}
}
// When the DOM is ready, call completed()
// When the DOM is ready, initalize the webapp
if ( document.readyState === "complete" ) {
// DOM is already ready
setTimeout( completed );
setTimeout( initalize );
} else {
// DOM isn't ready yet, add event listeners
document.addEventListener( "DOMContentLoaded", completed, false );
window.addEventListener( "load", completed, false );
document.addEventListener( "DOMContentLoaded", initalize, false );
window.addEventListener( "load", initalize, false );
}
})(this, document, this.FM = this.FM || {});
})(this, document, FM = this.FM || {});