You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ld...@apache.org on 2014/08/07 18:58:47 UTC

[07/12] git commit: vibrate([num]) is treated as a vibrate not vibrate with pattern

vibrate([num]) is treated as a vibrate not vibrate with pattern


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/17441b74
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/17441b74
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/17441b74

Branch: refs/heads/master
Commit: 17441b748194efccec9227d21af2de763d5d362b
Parents: 7eedea3
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Wed Jul 23 14:32:46 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Wed Jul 23 14:32:46 2014 -0400

----------------------------------------------------------------------
 www/vibration.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/17441b74/www/vibration.js
----------------------------------------------------------------------
diff --git a/www/vibration.js b/www/vibration.js
index 270a536..75e097b 100644
--- a/www/vibration.js
+++ b/www/vibration.js
@@ -58,8 +58,20 @@ module.exports = {
         if ((typeof param == 'number') && param != 0)
             exec(null, null, "Vibration", "vibrate", [param]);
 
+        //vibrate with array ( i.e. vibrate([3000]) )
+        else if ((typeof param == 'object') && param.length == 1)
+        {
+            //cancel if vibrate([0])
+            if (param[0] == 0)
+                exec(null, null, "Vibration", "cancelVibration", []);
+
+            //else vibrate
+            else
+                exec(null, null, "Vibration", "vibrate", [param[0]]);
+        }
+
         //vibrate with a pattern
-        else if ((typeof param == 'object') && param.length != 0)
+        else if ((typeof param == 'object') && param.length > 1)
         {
             var repeat = -1; //no repeat
             exec(null, null, "Vibration", "vibrateWithPattern", [param, repeat]);