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 2012/04/20 23:16:04 UTC
[4/5] git commit: CB-337 capture options.limit < 1
CB-337 capture options.limit < 1
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/e034157c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/e034157c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/e034157c
Branch: refs/heads/master
Commit: e034157cb25fa3de442ddb10f47bb802b29d1fc4
Parents: da58dee
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Apr 18 17:29:30 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Apr 18 17:29:30 2012 -0700
----------------------------------------------------------------------
lib/common/plugin/capture.js | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e034157c/lib/common/plugin/capture.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/capture.js b/lib/common/plugin/capture.js
index e088ba6..781b21f 100644
--- a/lib/common/plugin/capture.js
+++ b/lib/common/plugin/capture.js
@@ -1,5 +1,6 @@
var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
+ MediaFile = require('cordova/plugin/MediaFile'),
+ CaptureError = require('cordova/plugin/CaptureError');
/**
* Launches a capture of different types.
@@ -11,9 +12,11 @@ var exec = require('cordova/exec'),
*/
function _capture(type, successCallback, errorCallback, options) {
var win = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.length; i++) {
+ var mediaFiles = []
+ ,i
+ ,len = pluginResult.length;
+
+ for (i = 0; i < len; i++) {
var mediaFile = new MediaFile();
mediaFile.name = pluginResult[i].name;
mediaFile.fullPath = pluginResult[i].fullPath;
@@ -24,7 +27,17 @@ function _capture(type, successCallback, errorCallback, options) {
}
successCallback(mediaFiles);
};
- exec(win, errorCallback, "Capture", type, [options]);
+ if(options && options.limit & options.limit < 1) {
+ if(errorCallback) {
+ setTimeout(function(){
+ errorCallback({code:CaptureError.CAPTURE_INVALID_ARGUMENT});
+ },0);
+ }
+ // else ?? Exception ? console.error ?
+ }
+ else {
+ exec(win, errorCallback, "Capture", type, [options]);
+ }
}
/**
* The Capture interface exposes an interface to the camera and microphone of the hosting device.