Created
September 18, 2014 09:45
-
-
Save uniquelau/f9ff33f5efd8c9798db8 to your computer and use it in GitHub Desktop.
Basic application JavaScript file, has events for resize / etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Table of Contents | |
// [1] Globals | |
// [A] Event, Ready | |
// [B] Event, Loaded | |
// [C] Event, Resized | |
// [1] Globals | |
hasObject = false; | |
// [A] Event, Ready (fast) | |
$(document).ready(function () { | |
// Load the current pages functions, e.g. Home.js | |
if (typeof window[objectName] == 'function') { | |
window[objectName](); | |
window.hasObject = true; | |
} | |
}); | |
// [B] Loaded (e.g. images downloaded, etc, slow) | |
$(window).load(function () { | |
// Load the current pages 'load()' function. | |
if (hasObject) { | |
if (typeof window[objectName]["load"] == 'function') { | |
// If so load it. | |
window[objectName]["load"](); // some objects have a loadfunction | |
} | |
} | |
}); | |
// [C] Resize Events (triggers resize function & updates variables) | |
var resizeListener = function () { | |
$(window).one("resize", function () { //unbinds itself every time it fires | |
if (hasObject) { | |
if (typeof window[objectName]["resize"] == 'function') { | |
window[objectName]["resize"](); // some objects have a resize function | |
} | |
} | |
setTimeout(resizeListener, 100); //rebinds itself after 100ms | |
}); | |
}; | |
resizeListener(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment