Skip to content

Instantly share code, notes, and snippets.

@rblalock
Last active December 16, 2015 06:59
Show Gist options
  • Save rblalock/5395399 to your computer and use it in GitHub Desktop.
Save rblalock/5395399 to your computer and use it in GitHub Desktop.
/**
* Global singleton
*/
var APP = {
/**
* This sets up global events, persistant things
* throughout the app, etc. Only should be called
* when the app is booted.
*/
init: function() {
Ti.Geolocation.addEventListener("location", APP.location);
Ti.Gesture.addEventListener('orientationchange', APP.orientationObserverUpdate);
},
location: function(_event) {
// etc.
},
orientationchange: function(_event) {
var type = (_event.source.isLandscape()) ? 'landscape' : 'portrait';
// Handle registerd controllers that have an orientation method
for(controller in APP.Controllers) {
if(APP.Controllers[controller].orientationUpdate) {
APP.Controllers[controller].orientationUpdate( type );
}
}
}
};
module.exports = APP;
$.orientationUpdate = function(_type) {
// handle stuff here
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment