cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/7] git commit: Add Tizen plugin.
Date Mon, 10 Feb 2014 23:21:37 GMT
Updated Branches:
  refs/heads/master bff09d290 -> 91d3c0058


Add Tizen plugin.


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

Branch: refs/heads/master
Commit: bcd7daab09f06cba264654942b333f36e6dcad00
Parents: b33f6b2
Author: Salvatore Iovene <salvatore@iovene.com>
Authored: Thu Dec 5 14:04:19 2013 +0200
Committer: Salvatore Iovene <salvatore@iovene.com>
Committed: Thu Dec 5 14:04:19 2013 +0200

----------------------------------------------------------------------
 plugin.xml                      |  8 +++++++-
 src/tizen/AccelerometerProxy.js | 30 ++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/bcd7daab/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index a224f49..9330be9 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -123,5 +123,11 @@
             <merges target="" />
         </js-module>
     </platform>
-    
+
+    <!-- tizen -->
+    <platform name="tizen">
+        <js-module src="src/tizen/AccelerometerProxy.js" name="AccelerometerProxy">
+            <runs/>
+        </js-module>
+    </platform>
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/bcd7daab/src/tizen/AccelerometerProxy.js
----------------------------------------------------------------------
diff --git a/src/tizen/AccelerometerProxy.js b/src/tizen/AccelerometerProxy.js
new file mode 100644
index 0000000..2712c15
--- /dev/null
+++ b/src/tizen/AccelerometerProxy.js
@@ -0,0 +1,30 @@
+(function(win) {
+    var cordova = require('cordova'),
+        Acceleration = require('org.apache.cordova.device-motion.Acceleration'),
+        accelerometerCallback = null;
+
+    module.exports = {
+        start: function (successCallback, errorCallback) {
+            if (accelerometerCallback) {
+                win.removeEventListener("devicemotion", accelerometerCallback, true);
+            }
+
+            accelerometerCallback = function (motion) {
+                successCallback({
+                    x: motion.accelerationIncludingGravity.x,
+                    y: motion.accelerationIncludingGravity.y,
+                    z: motion.accelerationIncludingGravity.z,
+                    timestamp: new Date().getTime()
+                });
+            };
+            win.addEventListener("devicemotion", accelerometerCallback, true);
+        },
+
+        stop: function (successCallback, errorCallback) {
+            win.removeEventListener("devicemotion", accelerometerCallback, true);
+            accelerometerCallback = null;
+        }
+    };
+
+    require("cordova/tizen/commandProxy").add("Accelerometer", module.exports);
+}(window));


Mime
View raw message