Removed direct reference to screen in addScreenOrientationApi function

This commit is contained in:
Grant Benvenuti 2015-08-10 09:37:38 +10:00
parent 1195b40612
commit c8b89002f9

View File

@ -45,24 +45,22 @@ screenOrientation.setOrientation = function(orientation) {
console.log('setOrientation not supported on device'); console.log('setOrientation not supported on device');
}; };
function addScreenOrientationApi(obj) { function addScreenOrientationApi(screenObject) {
if (obj.unlockOrientation || obj.lockOrientation) { if (screenObject.unlockOrientation || screenObject.lockOrientation) {
return; return;
} }
obj.lockOrientation = function(orientation) { screenObject.lockOrientation = function(orientation) {
if (Orientations.indexOf(orientation) == -1) { if (Orientations.indexOf(orientation) == -1) {
console.log('INVALID ORIENTATION', orientation); console.log('INVALID ORIENTATION', orientation);
return; return;
} }
screenOrientation.currOrientation = orientation; screenOrientation.currOrientation = screenObject.orientation = orientation;
screen.orientation = screenOrientation.currOrientation;
screenOrientation.setOrientation(orientation); screenOrientation.setOrientation(orientation);
}; };
obj.unlockOrientation = function() { screenObject.unlockOrientation = function() {
screenOrientation.currOrientation = 'unlocked'; screenOrientation.currOrientation = screenObject.orientation = 'unlocked';
screen.orientation = screenOrientation.currOrientation;
screenOrientation.setOrientation('unlocked'); screenOrientation.setOrientation('unlocked');
}; };
} }