-
-
Save QGao/5397581 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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; |
This file contains hidden or 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
$.orientationUpdate = function(_type) { | |
// handle stuff here | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment