cleaned up js, fixed whitespace

This commit is contained in:
Jesse MacFadyen 2016-12-13 15:39:58 -08:00
parent b7e547794d
commit 216b99f432

View File

@ -1,4 +1,3 @@
cordova.define("cordova-plugin-screen-orientation.screenorientation", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@ -20,28 +19,21 @@ cordova.define("cordova-plugin-screen-orientation.screenorientation", function(r
*
*/
var screenOrientation = {},
var screenOrientation = {},
Orientations = [
'portrait-primary',
// The orientation is in the primary portrait mode.
'portrait-secondary',
// The orientation is in the secondary portrait mode.
'landscape-primary',
// The orientation is in the primary landscape mode.
'landscape-secondary',
// The orientation is in the secondary landscape mode.
'portrait',
// The orientation is either portrait-primary or portrait-secondary.
'landscape',
// The orientation is either landscape-primary or landscape-secondary.
'any'
// All orientations are supported (unlocked orientation)
'portrait', // either portrait-primary or portrait-secondary.
'landscape', // either landscape-primary or landscape-secondary.
'any' // All orientations are supported (unlocked orientation)
];
screenOrientation.Orientations = Orientations;
screenOrientation.currOrientation = 'any';
var orientationMask = 0;
screenOrientation.setOrientation = function(orientation) {
screenOrientation.Orientations = Orientations;
screenOrientation.currOrientation = 'any';
var orientationMask = 0;
screenOrientation.setOrientation = function(orientation) {
if(orientation == Orientations[0]){
orientationMask = 1;
}
@ -67,9 +59,9 @@ cordova.define("cordova-plugin-screen-orientation.screenorientation", function(r
cordova.exec(null, null, "CDVOrientation", "screenOrientation", [orientationMask, orientation]);
//console.log('setOrientation not supported on device');
};
};
function addScreenOrientationApi(screenObject) {
function addScreenOrientationApi(screenObject) {
if (screenObject.unlockOrientation || screenObject.lockOrientation) {
return;
}
@ -80,9 +72,7 @@ cordova.define("cordova-plugin-screen-orientation.screenorientation", function(r
if (Orientations.indexOf(orientation) == -1) {
var err = new Error();
err.name = "NotSupportedError";
reject(err);//"cannot change orientation");
}
else {
screenOrientation.currOrientation = screenObject.orientation = orientation;
@ -91,20 +81,18 @@ cordova.define("cordova-plugin-screen-orientation.screenorientation", function(r
}
});
return p;
};
screenObject.unlockOrientation = function() {
screenOrientation.currOrientation = screenObject.orientation = 'any';
screenOrientation.setOrientation('any');
};
}
}
addScreenOrientationApi(screen);
orientationChange();
addScreenOrientationApi(screen);
orientationChange();
function orientationChange() {
function orientationChange() {
var orientation;
switch (window.orientation) {
@ -125,10 +113,8 @@ cordova.define("cordova-plugin-screen-orientation.screenorientation", function(r
}
screen.orientation = orientation;
}
}
window.addEventListener("orientationchange", orientationChange, true);
window.addEventListener("orientationchange", orientationChange, true);
module.exports = screenOrientation;
});
module.exports = screenOrientation;