cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/2] git commit: orientation plugin
Date Thu, 24 Oct 2013 23:43:53 GMT
Updated Branches:
  refs/heads/dev adac39198 -> 5053698d5


orientation plugin


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

Branch: refs/heads/dev
Commit: ac6b46c4a161c2479b02b830a9a24c59e01062f7
Parents: 1870cd9
Author: Piotr Zalewa <piotr@zalewa.info>
Authored: Thu Oct 24 14:23:35 2013 +0200
Committer: Piotr Zalewa <piotr@zalewa.info>
Committed: Thu Oct 24 14:23:35 2013 +0200

----------------------------------------------------------------------
 plugin.xml               | 13 +++++++++++++
 src/firefoxos/compass.js | 23 +++++++++++++++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/ac6b46c4/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index f82b98c..e6389c3 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -22,6 +22,19 @@
         <clobbers target="navigator.compass" />
     </js-module>
 
+    <!-- firefoxos -->
+    <platform name="firefoxos">
+        <config-file target="config.xml" parent="/*">
+            <feature name="Compass">
+                <param name="firefoxos-package" value="Compass" />
+            </feature>
+        </config-file>                                         
+        
+        <js-module src="src/firefoxos/compass.js" name="compass-impl">
+          <runs />
+        </js-module>
+    </platform>
+
     <!-- android -->
     <platform name="android">
         <config-file target="res/xml/config.xml" parent="/*">

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/ac6b46c4/src/firefoxos/compass.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/compass.js b/src/firefoxos/compass.js
new file mode 100644
index 0000000..53ad72c
--- /dev/null
+++ b/src/firefoxos/compass.js
@@ -0,0 +1,23 @@
+
+var Compass = {
+    getHeading: function(success, error) {
+        var listener = function(ev) {
+            var orient = {
+                trueHeading: ev.alpha,
+                magneticHeading: ev.alpha,
+                headingAccuracy: 0,
+                timestamp: new Date().getTime()
+            }
+            success(orient);
+            // remove listener after first response
+            window.removeEventListener('deviceorientation', listener, false);
+        }
+        return window.addEventListener('deviceorientation', listener, false);
+    },
+};
+
+var firefoxos = require('cordova/platform');
+
+module.exports = Compass;
+require('cordova/firefoxos/commandProxy').add('Compass', Compass);
+


Mime
View raw message