You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2016/12/13 23:48:35 UTC

[07/16] cordova-plugin-screen-orientation git commit: added comments and formatted code

added comments and formatted code


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/commit/84b013f1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/84b013f1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/84b013f1

Branch: refs/heads/master
Commit: 84b013f17c71922fa42bfd9185dbc9be3a1fe831
Parents: 90f5f25
Author: maverickmishra <vi...@gmail.com>
Authored: Mon Oct 17 11:12:53 2016 -0700
Committer: maverickmishra <vi...@gmail.com>
Committed: Mon Oct 17 11:12:53 2016 -0700

----------------------------------------------------------------------
 www/screenorientation.js | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/84b013f1/www/screenorientation.js
----------------------------------------------------------------------
diff --git a/www/screenorientation.js b/www/screenorientation.js
index 8aaa51f..e03f7ee 100644
--- a/www/screenorientation.js
+++ b/www/screenorientation.js
@@ -32,33 +32,35 @@ cordova.define("cordova-plugin-screen-orientation.screenorientation", function(r
                                // The orientation is in the secondary landscape mode.
                                'portrait',
                                // The orientation is either portrait-primary or portrait-secondary.
-                               'landscape'
+                               'landscape',
                                // The orientation is either landscape-primary or landscape-secondary.
+                               'any'
+                               // All orientations are supported
                                ];
 
                screenOrientation.Orientations = Orientations;
                screenOrientation.currOrientation = 'any';
                var orientationMask = 0;
                screenOrientation.setOrientation = function(orientation) {
-               if(orientation == 'portrait-primary'){
+               if(orientation == Orientations[0]){
                orientationMask = 1;
                }
-               else if(orientation == 'portrait-secondary'){
+               else if(orientation == Orientations[1]){
                orientationMask = 2;
                }
-               else if(orientation == 'landscape-primary'){
+               else if(orientation == Orientations[2]){
                orientationMask = 4;
                }
-               else if(orientation == 'landscape-secondary'){
+               else if(orientation == Orientations[3]){
                orientationMask = 8;
                }
-               else if(orientation == 'portrait'){
+               else if(orientation == Orientations[4]){
                orientationMask = 3;
                }
-               else if(orientation == 'landscape'){
+               else if(orientation == Orientations[5]){
                orientationMask = 12;
                }
-               else if(orientation == 'any'){
+               else if(orientation == Orientations[6]){
                orientationMask = 15;
                }
 
@@ -73,29 +75,24 @@ cordova.define("cordova-plugin-screen-orientation.screenorientation", function(r
                }
 
                screenObject.lockOrientation = function(orientation) {
-
+               
                var p = new Promise(function(resolve,reject){
                                    if (Orientations.indexOf(orientation) == -1) {
-                                   //   console.log('INVALID ORIENTATION', orientation);
                                    var err = new Error();
                                    err.name = "NotSupportedError";
-
+                                   
                                    reject(err);//"cannot change orientation");
-
+                                   
                                    }
                                    else {
                                 screenOrientation.currOrientation = screenObject.orientation = orientation;
                                 screenOrientation.setOrientation(orientation);
-                                   resolve("Orientation changed"); // orientation change successful
+                                   resolve("Orientation set"); // orientation change successful
                                    }
-
-
-
-
-                                   });
+                                  });
                return p;
-
-
+               
+              
                };
 
                screenObject.unlockOrientation = function() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org