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 2015/02/15 08:41:03 UTC

[1/2] cordova-windows git commit: CB-8321 Add supported orientations config.xml preference handling for `windows` platform

Repository: cordova-windows
Updated Branches:
  refs/heads/master fd18e17de -> efa068a09


CB-8321 Add supported orientations config.xml preference handling for `windows` platform


Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/2425d17b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/2425d17b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/2425d17b

Branch: refs/heads/master
Commit: 2425d17bb72bff94de24e1f5a9ea998b2b11d257
Parents: 6e33d84
Author: daserge <da...@yandex.ru>
Authored: Sat Jan 17 15:02:44 2015 +0300
Committer: daserge <da...@yandex.ru>
Committed: Mon Jan 19 12:13:58 2015 +0300

----------------------------------------------------------------------
 template/cordova/lib/prepare.js | 59 ++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/2425d17b/template/cordova/lib/prepare.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/prepare.js b/template/cordova/lib/prepare.js
index 5e3f533..2162cda 100644
--- a/template/cordova/lib/prepare.js
+++ b/template/cordova/lib/prepare.js
@@ -124,6 +124,65 @@ function applyCoreProperties(config, manifest) {
             publisherNameElement.text = author;
         }
     }
+
+    // Supported orientations
+    var isWin80 = manifest.find('.//VisualElements') != null;
+    var isWin81 = manifest.find('.//m2:VisualElements') != null;
+    var isWP81 = manifest.find('.//m3:VisualElements') != null;
+
+    var rotationPreferenceName, rotationPreferenceRootName;
+
+    if(isWin80) {
+        rotationPreferenceName = 'Rotation';
+        rotationPreferenceRootName = 'InitialRotationPreference';
+    } else if(isWin81) {
+        rotationPreferenceName = 'm2:Rotation';
+        rotationPreferenceRootName = 'm2:InitialRotationPreference';
+    } else if(isWP81) {
+        rotationPreferenceName = 'm3:Rotation';
+        rotationPreferenceRootName = 'm3:InitialRotationPreference';
+    }
+
+    var orientation = config.getPreference('Orientation');
+    if (orientation) {
+        var rotationPreferenceRoot = manifest.find('.//' + rotationPreferenceRootName);
+        if(rotationPreferenceRoot == null) {
+            visualElems.append(et.Element(rotationPreferenceRootName));
+            rotationPreferenceRoot = manifest.find('.//' + rotationPreferenceRootName);
+        }
+
+        rotationPreferenceRoot.clear();
+
+        function applyOrientations(orientationsArr) {
+            orientationsArr.forEach(function(orientationValue) {
+                var el = et.Element(rotationPreferenceName)
+                el.attrib.Preference = orientationValue;
+                rotationPreferenceRoot.append(el);
+            });
+        }
+
+        // Updates supported orientations
+        //<InitialRotationPreference>
+        //    <Rotation Preference = "portrait" | "landscape" | "portraitFlipped" | "landscapeFlipped" /> {1,4}
+        //</InitialRotationPreference>
+        var orientations;
+        if(orientation === 'default') {
+            // This means landscape and portrait
+            applyOrientations(['portrait', 'landscape', 'landscapeFlipped']);
+        } else if(orientation === 'portrait') {
+            applyOrientations(['portrait']);
+        } else if(orientation === 'landscape') {
+            applyOrientations(['landscape', 'landscapeFlipped']);
+        } else { // Platform-specific setting like "portrait,landscape,portraitFlipped"
+            applyOrientations(orientation.split(','));
+        }
+    } else {
+        // Remove InitialRotationPreference root element to revert to defaults
+        var rotationPreferenceRoot = visualElems.find('.//' + rotationPreferenceRootName);
+        if(rotationPreferenceRoot != null) {
+            visualElems.remove(null, rotationPreferenceRoot);
+        }
+    }
 }
 
 // Adjust version number as per CB-5337 Windows8 build fails due to invalid app version


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


[2/2] cordova-windows git commit: Merge branch 'CB-8321' of https://github.com/MSOpenTech/cordova-windows

Posted by pu...@apache.org.
Merge branch 'CB-8321' of https://github.com/MSOpenTech/cordova-windows


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

Branch: refs/heads/master
Commit: efa068a099e97ff8b1b07f1114d0957851531884
Parents: fd18e17 2425d17
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Sat Feb 14 23:40:37 2015 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Sat Feb 14 23:40:37 2015 -0800

----------------------------------------------------------------------

----------------------------------------------------------------------



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