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:34 UTC

[06/16] cordova-plugin-screen-orientation git commit: Added promises to plugin

 Added promises to plugin


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/90f5f253
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/90f5f253
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/90f5f253

Branch: refs/heads/master
Commit: 90f5f2531a6a354d8e8b889e707099b214d9e09d
Parents: f881c95
Author: maverickmishra <vi...@gmail.com>
Authored: Tue Sep 20 10:36:36 2016 -0700
Committer: maverickmishra <vi...@gmail.com>
Committed: Tue Sep 20 10:36:36 2016 -0700

----------------------------------------------------------------------
 www/screenorientation.js | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/90f5f253/www/screenorientation.js
----------------------------------------------------------------------
diff --git a/www/screenorientation.js b/www/screenorientation.js
index 77f1f9f..8aaa51f 100644
--- a/www/screenorientation.js
+++ b/www/screenorientation.js
@@ -1,3 +1,4 @@
+cordova.define("cordova-plugin-screen-orientation.screenorientation", function(require, exports, module) {
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -72,12 +73,29 @@
                }
 
                screenObject.lockOrientation = function(orientation) {
-               if (Orientations.indexOf(orientation) == -1) {
-               console.log('INVALID ORIENTATION', orientation);
-               return;
-               }
-               screenOrientation.currOrientation = screenObject.orientation = orientation;
-               screenOrientation.setOrientation(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
+                                   }
+
+
+
+
+                                   });
+               return p;
+
+
                };
 
                screenObject.unlockOrientation = function() {
@@ -115,3 +133,5 @@
                window.addEventListener("orientationchange", orientationChange, true);
 
                module.exports = screenOrientation;
+
+});


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