cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [5/5] cordova-plugin-statusbar git commit: added checks for running on windows when StatusBar is NOT available
Date Thu, 13 Nov 2014 02:05:22 GMT
added checks for running on windows when StatusBar is NOT available


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/commit/c89fdd46
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/tree/c89fdd46
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/diff/c89fdd46

Branch: refs/heads/master
Commit: c89fdd46174975fe22b4faccffe624c3ac765a22
Parents: 251e904
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Wed Nov 12 18:04:38 2014 -0800
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Wed Nov 12 18:04:38 2014 -0800

----------------------------------------------------------------------
 src/windows/StatusBarProxy.js | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/c89fdd46/src/windows/StatusBarProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/StatusBarProxy.js b/src/windows/StatusBarProxy.js
index 086c0ac..5770099 100644
--- a/src/windows/StatusBarProxy.js
+++ b/src/windows/StatusBarProxy.js
@@ -19,16 +19,20 @@
  *
  */
 
-function getViewStatusBar() {
-    return Windows.UI.ViewManagement.StatusBar.getForCurrentView();
-}
-
-function darkForeground () {
-    
-}
+ var isSupported = true; // we assume
 
-function lightForeground() {
-    
+function getViewStatusBar() {
+    if(isSupported) {
+        var ViewMan = Windows.UI.ViewManagement; // quick alias to save char
+        if( ViewMan.StatusBar && 
+            ViewMan.StatusBar.getForCurrentView ) {
+            return ViewMan.StatusBar.getForCurrentView();
+        }
+        else {
+            isSupported = false; // so we won't check again
+        }
+    }
+    return null;
 }
 
 function hexToRgb(hex) {
@@ -78,8 +82,10 @@ module.exports = {
     backgroundColorByHexString: function (win, fail, args) {
         var rgb = hexToRgb(args[0]);
         var statusBar = getViewStatusBar();
-        statusBar.backgroundColor = { a: 0, r: rgb.r, g: rgb.g, b: rgb.b };
-        statusBar.backgroundOpacity = 1;
+        if(statusBar) {
+            statusBar.backgroundColor = { a: 0, r: rgb.r, g: rgb.g, b: rgb.b };
+            statusBar.backgroundOpacity = 1;
+        }
     },
 
     show: function (win, fail) {


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


Mime
View raw message