cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ldel...@apache.org
Subject [01/12] git commit: changes made to align with w3c spec
Date Thu, 07 Aug 2014 16:58:41 GMT
Repository: cordova-plugin-vibration
Updated Branches:
  refs/heads/master 90c6e5f2e -> 108e71220


changes made to align with w3c spec


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

Branch: refs/heads/master
Commit: bf582d3ea959d23cab84d273d35d9b7b9cbe3f62
Parents: 112254e
Author: Edna Morales <ednamorales@ednas-mbp-2.raleigh.ibm.com>
Authored: Fri Jul 18 09:19:53 2014 -0400
Committer: Edna Morales <ednamorales@ednas-mbp-2.raleigh.ibm.com>
Committed: Fri Jul 18 09:19:53 2014 -0400

----------------------------------------------------------------------
 plugin.xml       |  1 +
 www/vibration.js | 41 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/bf582d3e/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 32c805e..bab6566 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -32,6 +32,7 @@
 
     <js-module src="www/vibration.js" name="notification">
         <merges target="navigator.notification" />
+        <merges target="navigator" />
     </js-module>
 
     <!-- firefoxos -->

http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/bf582d3e/www/vibration.js
----------------------------------------------------------------------
diff --git a/www/vibration.js b/www/vibration.js
index 34b16fb..d1206ed 100644
--- a/www/vibration.js
+++ b/www/vibration.js
@@ -28,12 +28,45 @@ var exec = require('cordova/exec');
 module.exports = {
 
     /**
-     * Vibrates the device for a given amount of time.
+     * Vibrates the device for a given amount of time or for a given pattern or immediately
cancels any ongoing vibrations (depending on the parameter).
      *
-     * @param {Integer} mills       The number of milliseconds to vibrate.
+     * @param {Integer} param       The number of milliseconds to vibrate (if 0, cancels
vibration)
+     *
+     *
+     * @param {Array of Integer} param    Pattern with which to vibrate the device.
+     *                                      Pass in an array of integers that
+     *                                      are the durations for which to
+     *                                      turn on or off the vibrator in
+     *                                      milliseconds. The first value
+     *                                      indicates the number of milliseconds
+     *                                      to wait before turning the vibrator
+     *                                      on. The next value indicates the
+     *                                      number of milliseconds for which
+     *                                      to keep the vibrator on before
+     *                                      turning it off. Subsequent values
+     *                                      alternate between durations in
+     *                                      milliseconds to turn the vibrator
+     *                                      off or to turn the vibrator on.
+     *                                      (if empty, cancels vibration)
      */
-    vibrate: function(mills) {
-        exec(null, null, "Vibration", "vibrate", [mills]);
+    vibrate: function(param) {
+
+        /* Aligning with w3c spec */
+        
+        //vibrate
+        if ((typeof param == 'number') && param != 0)
+            exec(null, null, "Vibration", "vibrate", [param]);
+
+        //vibrate with a pattern
+        else if ((typeof param == 'object') && param.length != 0)
+        {
+            var repeat = -1; //no repeat
+            exec(null, null, "Vibration", "vibrateWithPattern", [param, repeat]);
+        }
+
+        //cancel vibration (param = 0 or [])
+        else
+            exec(null, null, "Vibration", "cancelVibration", []);
     },
 
     /**


Mime
View raw message