mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
code with words
This commit is contained in:
@ -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 || {});
|
||||
Reference in New Issue
Block a user