mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
utils
This commit is contained in:
@ -20,6 +20,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<footer class="bar-footer">
|
<footer class="bar-footer">
|
||||||
</footer>
|
</footer>
|
||||||
|
<script src="../js/jquery/jquery-1.10.2.js"></script>
|
||||||
|
<script src="../js/framework/framework-utilities.js"></script>
|
||||||
|
<script src="../js/framework/test/event-listeners.js"></script>
|
||||||
<script src="../js/framework/framework-init.js"></script>
|
<script src="../js/framework/framework-init.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -1,22 +1,28 @@
|
|||||||
(function(window, document, framework) {
|
(function(window, document, framework) {
|
||||||
|
|
||||||
framework.init = function() {
|
// Start initalizing the framework
|
||||||
if(!framework._init) {
|
function initalize() {
|
||||||
framework._init = true;
|
|
||||||
console.log("Framwork init!");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( document.readyState === "complete" ) {
|
|
||||||
setTimeout( framework.init, 1 );
|
framework.trigger("initalized");
|
||||||
} else {
|
|
||||||
if ( document.addEventListener ) {
|
|
||||||
document.addEventListener( "DOMContentLoaded", framework.init, false );
|
|
||||||
window.addEventListener( "load", framework.init, false );
|
|
||||||
} else if ( document.attachEvent ) {
|
|
||||||
document.attachEvent( "onreadystatechange", framework.init );
|
|
||||||
window.attachEvent( "onload", framework.init );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})(this, document, this.FW || {});
|
// DOM has completed
|
||||||
|
function completed() {
|
||||||
|
document.removeEventListener( "DOMContentLoaded", completed, false );
|
||||||
|
window.removeEventListener( "load", completed, false );
|
||||||
|
framework.trigger("ready");
|
||||||
|
initalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// When the DOM is ready, call .ready()
|
||||||
|
if ( document.readyState === "complete" ) {
|
||||||
|
// DOM is already ready, run .ready() via setTimeout
|
||||||
|
setTimeout( completed );
|
||||||
|
} else {
|
||||||
|
// DOM isn't ready yet, add event listeners for when it is
|
||||||
|
document.addEventListener( "DOMContentLoaded", completed, false );
|
||||||
|
window.addEventListener( "load", completed, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
})(this, document, this.FM = this.FM || {});
|
||||||
11
js/framework/framework-utilities.js
Normal file
11
js/framework/framework-utilities.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
(function(window, document, framework) {
|
||||||
|
|
||||||
|
framework.trigger = function(type, data) {
|
||||||
|
window.dispatchEvent( new CustomEvent(type, data) );
|
||||||
|
};
|
||||||
|
|
||||||
|
framework.on = function(type, callback) {
|
||||||
|
window.addEventListener(type, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
})(this, document, this.FM = this.FM || {});
|
||||||
13
js/framework/test/event-listeners.js
Normal file
13
js/framework/test/event-listeners.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
(function(window, document, framework, $) {
|
||||||
|
|
||||||
|
framework.on("ready", function(){
|
||||||
|
console.log("ready")
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Test that the standard jQuery call works with our event system
|
||||||
|
$(window).on("initalized", function() {
|
||||||
|
console.log("initalized");
|
||||||
|
});
|
||||||
|
|
||||||
|
})(this, document, this.FM = this.FM || {}, jQuery);
|
||||||
9789
js/jquery/jquery-1.10.2.js
vendored
Normal file
9789
js/jquery/jquery-1.10.2.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user