Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-camera

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-camera - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

.jshintrc

20

jsdoc2md/TEMPLATE.md
{{>cdv-license~}}
[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-camera)
# cordova-plugin-camera

@@ -35,3 +37,3 @@

Take a photo and retrieve it as a base64-encoded image:
Take a photo and retrieve it as a Base64-encoded image:

@@ -75,3 +77,3 @@ navigator.camera.getPicture(onSuccess, onFail, { quality: 50,

images, and on phones with low memory, the Cordova activity may be killed. In this
scenario, the image may not appear when the cordova activity is restored.
scenario, the image may not appear when the Cordova activity is restored.

@@ -83,3 +85,3 @@ #### Android Quirks

scenario, the result from the plugin call will be delivered via the resume event.
See [the Android Lifecycle guide](http://cordova.apache.org/docs/en/dev/guide/platforms/android/lifecycle.html)
See [the Android Lifecycle guide][android_lifecycle]
for more information. The `pendingResult.result` value will contain the value that

@@ -92,7 +94,7 @@ would be passed to the callbacks (either the URI/URL or an error message). Check

Can only return photos as base64-encoded image.
Can only return photos as Base64-encoded image.
#### Firefox OS Quirks
Camera plugin is currently implemented using [Web Activities](https://hacks.mozilla.org/2013/01/introducing-web-activities/).
Camera plugin is currently implemented using [Web Activities][web_activities].

@@ -194,5 +196,9 @@ #### iOS Quirks

- Ignores the `saveToPhotoAlbum` parameter. IMPORTANT: All images taken with the wp7/8 cordova camera API are always copied to the phone's camera roll. Depending on the user's settings, this could also mean the image is auto-uploaded to their OneDrive. This could potentially mean the image is available to a wider audience than your app intended. If this a blocker for your application, you will need to implement the CameraCaptureTask as documented on msdn : [http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx](http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx)
You may also comment or up-vote the related issue in the [issue tracker](https://issues.apache.org/jira/browse/CB-2083)
- Ignores the `saveToPhotoAlbum` parameter. IMPORTANT: All images taken with the WP8/8 Cordova camera API are always copied to the phone's camera roll. Depending on the user's settings, this could also mean the image is auto-uploaded to their OneDrive. This could potentially mean the image is available to a wider audience than your app intended. If this is a blocker for your application, you will need to implement the CameraCaptureTask as [documented on MSDN][msdn_wp8_docs]. You may also comment or up-vote the related issue in the [issue tracker][wp8_bug].
- Ignores the `mediaType` property of `cameraOptions` as the Windows Phone SDK does not provide a way to choose videos from PHOTOLIBRARY.
[android_lifecycle]: http://cordova.apache.org/docs/en/dev/guide/platforms/android/lifecycle.html
[web_activities]: https://hacks.mozilla.org/2013/01/introducing-web-activities/
[wp8_bug]: https://issues.apache.org/jira/browse/CB-2083
[msdn_wp8_docs]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx
{
"name": "cordova-plugin-camera",
"version": "2.1.0",
"version": "2.1.1",
"description": "Cordova Camera Plugin",

@@ -46,11 +46,14 @@ "cordova": {

"precommit": "npm run gen-docs && git add README.md",
"gen-docs": "jsdoc2md --template \"jsdoc2md/TEMPLATE.md\" \"www/**/*.js\" --plugin \"dmd-plugin-cordova-plugin\" > README.md"
"gen-docs": "jsdoc2md --template \"jsdoc2md/TEMPLATE.md\" \"www/**/*.js\" --plugin \"dmd-plugin-cordova-plugin\" > README.md",
"test": "npm run jshint",
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
},
"author": "Apache Software Foundation",
"license": "Apache 2.0",
"license": "Apache-2.0",
"devDependencies": {
"dmd-plugin-cordova-plugin": "^0.1.0",
"husky": "^0.10.1",
"jsdoc-to-markdown": "^1.2.0"
"jsdoc-to-markdown": "^1.2.0",
"jshint": "^2.6.0"
}
}

@@ -20,2 +20,4 @@ <!---

[![Build Status](https://travis-ci.org/apache/cordova-plugin-camera.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-camera)
# cordova-plugin-camera

@@ -75,16 +77,16 @@

* [camera](#module_camera)
* [.getPicture(successCallback, errorCallback, options)](#module_camera.getPicture)
* [.cleanup()](#module_camera.cleanup)
* [.onError](#module_camera.onError) : <code>function</code>
* [.onSuccess](#module_camera.onSuccess) : <code>function</code>
* [.CameraOptions](#module_camera.CameraOptions) : <code>Object</code>
* [.getPicture(successCallback, errorCallback, options)](#module_camera.getPicture)
* [.cleanup()](#module_camera.cleanup)
* [.onError](#module_camera.onError) : <code>function</code>
* [.onSuccess](#module_camera.onSuccess) : <code>function</code>
* [.CameraOptions](#module_camera.CameraOptions) : <code>Object</code>
* [Camera](#module_Camera)
* [.DestinationType](#module_Camera.DestinationType) : <code>enum</code>
* [.EncodingType](#module_Camera.EncodingType) : <code>enum</code>
* [.MediaType](#module_Camera.MediaType) : <code>enum</code>
* [.PictureSourceType](#module_Camera.PictureSourceType) : <code>enum</code>
* [.PopoverArrowDirection](#module_Camera.PopoverArrowDirection) : <code>enum</code>
* [.Direction](#module_Camera.Direction) : <code>enum</code>
* [.DestinationType](#module_Camera.DestinationType) : <code>enum</code>
* [.EncodingType](#module_Camera.EncodingType) : <code>enum</code>
* [.MediaType](#module_Camera.MediaType) : <code>enum</code>
* [.PictureSourceType](#module_Camera.PictureSourceType) : <code>enum</code>
* [.PopoverArrowDirection](#module_Camera.PopoverArrowDirection) : <code>enum</code>
* [.Direction](#module_Camera.Direction) : <code>enum</code>

@@ -102,7 +104,7 @@ * [CameraPopoverHandle](#module_CameraPopoverHandle)

image gallery. The image is passed to the success callback as a
base64-encoded `String`, or as the URI for the image file.
Base64-encoded `String`, or as the URI for the image file.
The `camera.getPicture` function opens the device's default camera
application that allows users to snap pictures by default - this behavior occurs,
when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`](#module_Camera.PictureSourceType).
when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`](#module_Camera.PictureSourceType).
Once the user snaps the photo, the camera application closes and the application is restored.

@@ -121,3 +123,3 @@

- A `String` containing the base64-encoded photo image.
- A `String` containing the Base64-encoded photo image.

@@ -143,8 +145,14 @@ - A `String` representing the image file location on local storage (default).

![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png)
- Android
- BlackBerry
- Browser
- Firefox
- FireOS
- iOS
- Windows
- WP8
- Ubuntu
* [More examples](#camera-getPicture-examples)
More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks).
* [Quirks](#camera-getPicture-quirks)
**Kind**: static method of <code>[camera](#module_camera)</code>

@@ -171,3 +179,3 @@

![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png)
- iOS

@@ -340,3 +348,3 @@ **Kind**: static method of <code>[camera](#module_camera)</code>

![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png)
- iOS

@@ -346,3 +354,3 @@ **Example**

var cameraPopoverHandle = navigator.camera.getPicture(onSuccess, onFail,
{
{
destinationType: Camera.DestinationType.FILE_URI,

@@ -366,3 +374,3 @@ sourceType: Camera.PictureSourceType.PHOTOLIBRARY,

Take a photo and retrieve it as a base64-encoded image:
Take a photo and retrieve it as a Base64-encoded image:

@@ -406,3 +414,3 @@ navigator.camera.getPicture(onSuccess, onFail, { quality: 50,

images, and on phones with low memory, the Cordova activity may be killed. In this
scenario, the image may not appear when the cordova activity is restored.
scenario, the image may not appear when the Cordova activity is restored.

@@ -414,3 +422,3 @@ #### Android Quirks

scenario, the result from the plugin call will be delivered via the resume event.
See [the Android Lifecycle guide](http://cordova.apache.org/docs/en/dev/guide/platforms/android/lifecycle.html)
See [the Android Lifecycle guide][android_lifecycle]
for more information. The `pendingResult.result` value will contain the value that

@@ -423,7 +431,7 @@ would be passed to the callbacks (either the URI/URL or an error message). Check

Can only return photos as base64-encoded image.
Can only return photos as Base64-encoded image.
#### Firefox OS Quirks
Camera plugin is currently implemented using [Web Activities](https://hacks.mozilla.org/2013/01/introducing-web-activities/).
Camera plugin is currently implemented using [Web Activities][web_activities].

@@ -525,5 +533,9 @@ #### iOS Quirks

- Ignores the `saveToPhotoAlbum` parameter. IMPORTANT: All images taken with the wp7/8 cordova camera API are always copied to the phone's camera roll. Depending on the user's settings, this could also mean the image is auto-uploaded to their OneDrive. This could potentially mean the image is available to a wider audience than your app intended. If this a blocker for your application, you will need to implement the CameraCaptureTask as documented on msdn : [http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx](http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx)
You may also comment or up-vote the related issue in the [issue tracker](https://issues.apache.org/jira/browse/CB-2083)
- Ignores the `saveToPhotoAlbum` parameter. IMPORTANT: All images taken with the WP8/8 Cordova camera API are always copied to the phone's camera roll. Depending on the user's settings, this could also mean the image is auto-uploaded to their OneDrive. This could potentially mean the image is available to a wider audience than your app intended. If this is a blocker for your application, you will need to implement the CameraCaptureTask as [documented on MSDN][msdn_wp8_docs]. You may also comment or up-vote the related issue in the [issue tracker][wp8_bug].
- Ignores the `mediaType` property of `cameraOptions` as the Windows Phone SDK does not provide a way to choose videos from PHOTOLIBRARY.
[android_lifecycle]: http://cordova.apache.org/docs/en/dev/guide/platforms/android/lifecycle.html
[web_activities]: https://hacks.mozilla.org/2013/01/introducing-web-activities/
[wp8_bug]: https://issues.apache.org/jira/browse/CB-2083
[msdn_wp8_docs]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006.aspx

@@ -23,2 +23,28 @@ <!--

### 2.1.1 (Mar 09, 2016)
* [CB-10825](https://issues.apache.org/jira/browse/CB-10825) android: Always request READ permission for gallery source
* added apache license header to appium files
* [CB-10720](https://issues.apache.org/jira/browse/CB-10720) Fixed spelling, capitalization, and other small issues.
* [CB-10414](https://issues.apache.org/jira/browse/CB-10414) Adding focus handler to resume video when user comes back on leaving the app while preview was running
* Appium tests: adjust swipe distance on ** Android **
* [CB-10750](https://issues.apache.org/jira/browse/CB-10750) Appium tests: fail fast if session is irrecoverable
* Adding missing semi colon
* Adding focus handler to make sure filepicker gets launched when app is active on ** Windows **
* [CB-10128](https://issues.apache.org/jira/browse/CB-10128) **iOS** Fixed how checks access authorization to camera & library. This closes #146
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins
* [CB-10639](https://issues.apache.org/jira/browse/CB-10639) Appium tests: Added some timeouts, Taking a screenshot on failure, Retry taking a picture up to 3 times, Try to restart the Appium session if it's lost
* [CB-10552](https://issues.apache.org/jira/browse/CB-10552) Replacing images in README.md.
* Added a lot of more cases to get the real path on ** Android **
* [CB-10625](https://issues.apache.org/jira/browse/CB-10625) ** Android ** getPicture fails when getting a photo from the Photo Library - Google Photos
* [CB-10619](https://issues.apache.org/jira/browse/CB-10619) Appium tests: Properly switch to webview on ** Android **
* [CB-10397](https://issues.apache.org/jira/browse/CB-10397) Added Appium tests
* [CB-10576](https://issues.apache.org/jira/browse/CB-10576) MobileSpec can't get results for **Windows**-Store 8.1 Builds
* chore: edit package.json license to match SPDX id
* [CB-10539](https://issues.apache.org/jira/browse/CB-10539) Commenting out the verySmallQvga maxResolution option on ** Windows **
* [CB-10541](https://issues.apache.org/jira/browse/CB-10541) Changing default maxResoltion to be highestAvailable for CameraCaptureUI on ** Windows **
* [CB-10113](https://issues.apache.org/jira/browse/CB-10113) ** Browser ** - Layer camera UI on top of all!
* [CB-10502](https://issues.apache.org/jira/browse/CB-10502) ** Browser ** - Fix camera plugin exception in Chrome when click capture.
* Adding comments
* Camera tapping fix on ** Windows **
### 2.1.0 (Jan 15, 2016)

@@ -25,0 +51,0 @@ * added `.ratignore`

@@ -21,2 +21,5 @@ /*

*/
/* globals qnx, FileError, PluginResult */
var PictureSourceType = {

@@ -44,3 +47,3 @@ PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)

invokeAvailable = !error && targets && targets instanceof Array &&
targets.filter(function (t) { return t.default === 'sys.camera.card' }).length > 0;
targets.filter(function (t) { return t.default === 'sys.camera.card'; }).length > 0;
}

@@ -90,3 +93,3 @@ );

var date = new Date(),
pad = function (n) { return n < 10 ? '0' + n : n };
pad = function (n) { return n < 10 ? '0' + n : n; };
return 'IMG_' + date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) + '_' +

@@ -151,3 +154,3 @@ pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + '.png';

break;
};
}

@@ -154,0 +157,0 @@ // set it back to original value

@@ -22,2 +22,4 @@ /*

var HIGHEST_POSSIBLE_Z_INDEX = 2147483647;
function takePicture(success, error, opts) {

@@ -28,2 +30,4 @@ if (opts && opts[2] === 1) {

var input = document.createElement('input');
input.style.position = 'relative';
input.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX;
input.type = 'file';

@@ -33,4 +37,2 @@ input.name = 'files[]';

input.onchange = function(inputEvent) {
var canvas = document.createElement('canvas');
var reader = new FileReader();

@@ -43,3 +45,3 @@ reader.onload = function(readerEvent) {

return success(imageData.substr(imageData.indexOf(',') + 1));
}
};

@@ -58,2 +60,7 @@ reader.readAsDataURL(inputEvent.target.files[0]);

var button = document.createElement('button');
var parent = document.createElement('div');
parent.style.position = 'relative';
parent.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX;
parent.appendChild(video);
parent.appendChild(button);

@@ -68,3 +75,3 @@ video.width = 320;

canvas.getContext('2d').drawImage(video, 0, 0, 320, 240);
// convert image stored in canvas to base64 encoded image

@@ -74,9 +81,15 @@ var imageData = canvas.toDataURL('img/png');

// stop video stream, remove video and button
localMediaStream.stop();
video.parentNode.removeChild(video);
button.parentNode.removeChild(button);
// stop video stream, remove video and button.
// Note that MediaStream.stop() is deprecated as of Chrome 47.
if (localMediaStream.stop) {
localMediaStream.stop();
} else {
localMediaStream.getTracks().forEach(function (track) {
track.stop();
});
}
parent.parentNode.removeChild(parent);
return success(imageData);
}
};

@@ -93,5 +106,4 @@ navigator.getUserMedia = navigator.getUserMedia ||

document.body.appendChild(video);
document.body.appendChild(button);
}
document.body.appendChild(parent);
};

@@ -98,0 +110,0 @@ if (navigator.getUserMedia) {

@@ -22,2 +22,4 @@ /*

/* globals MozActivity */
function takePicture(success, error, opts) {

@@ -36,3 +38,3 @@ var pick = new MozActivity({

// we need to call success with url or base64 encoded image
if (opts && opts.destinationType == 0) {
if (opts && opts.destinationType === 0) {
// TODO: base64

@@ -39,0 +41,0 @@ return;

@@ -328,3 +328,3 @@ /*

var createCameraUI = function () {
function createCameraUI() {
// create style for take and cancel buttons

@@ -336,3 +336,3 @@ var buttonStyle = "width:45%;padding: 10px 16px;font-size: 18px;line-height: 1.3333333;color: #333;background-color: #fff;border-color: #ccc; border: 1px solid transparent;border-radius: 6px; display: block; margin: 20px; z-index: 1000;border-color: #adadad;";

// is necessary to avoid overriding by another page elements, -1 sometimes is not enough
capturePreview = document.createElement("video");
capturePreview = document.createElement("video");
capturePreview.style.cssText = "position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: " + (HIGHEST_POSSIBLE_Z_INDEX - 1) + ";";

@@ -354,5 +354,12 @@

captureSettings.streamingCaptureMode = CaptureNS.StreamingCaptureMode.video;
};
}
var startCameraPreview = function () {
function continueVideoOnFocus() {
// if preview is defined it would be stuck, play it
if (capturePreview) {
capturePreview.play();
}
}
function startCameraPreview() {
// Search for available camera devices

@@ -363,2 +370,5 @@ // This is necessary to detect which camera (front or back) we should use

// Add focus event handler to capture the event when user suspends the app and comes back while the preview is on
window.addEventListener("focus", continueVideoOnFocus);
DeviceEnum.DeviceInformation.findAllAsync(DeviceEnum.DeviceClass.videoCapture).then(function (devices) {

@@ -388,7 +398,13 @@ if (devices.length <= 0) {

capturePreview.addEventListener('click', function () {
// Make sure function isn't called again before previous focus is completed
if (this.getAttribute('clicked') === '1') {
return false;
} else {
this.setAttribute('clicked', '1');
}
var preset = Windows.Media.Devices.FocusPreset.autoNormal;
var parent = this;
FocusControl.setPresetAsync(preset).done(function () {
// set the clicked attribute back to '0' to allow focus again
parent.setAttribute('clicked', '0');
});

@@ -445,5 +461,5 @@ });

});
};
}
var destroyCameraPreview = function () {
function destroyCameraPreview() {
// If sensor is available, remove event listener

@@ -462,2 +478,5 @@ if (sensor !== null) {

// Remove the focus event handler
window.removeEventListener("focus", continueVideoOnFocus);
// Remove elements

@@ -475,5 +494,5 @@ [capturePreview, cameraCaptureButton, cameraCancelButton].forEach(function (elem) {

}
};
}
var captureAction = function () {
function captureAction() {

@@ -540,5 +559,5 @@ var encodingProperties,

});
};
}
var getAspectRatios = function (capture) {
function getAspectRatios(capture) {
var videoDeviceController = capture.videoDeviceController;

@@ -570,5 +589,5 @@ var photoAspectRatios = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.photo).map(function (element) {

});
};
}
var setAspectRatio = function (capture, aspect) {
function setAspectRatio(capture, aspect) {
// Max photo resolution with desired aspect ratio

@@ -609,3 +628,3 @@ var videoDeviceController = capture.videoDeviceController;

});
};
}

@@ -615,3 +634,3 @@ /**

*/
var onCameraCaptureButtonClick = function() {
function onCameraCaptureButtonClick() {
// Make sure user can't click more than once

@@ -624,3 +643,3 @@ if (this.getAttribute('clicked') === '1') {

captureAction();
};
}

@@ -630,3 +649,3 @@ /**

*/
var onCameraCancelButtonClick = function() {
function onCameraCancelButtonClick() {
// Make sure user can't click more than once

@@ -640,3 +659,3 @@ if (this.getAttribute('clicked') === '1') {

errorCallback('no image selected');
};
}

@@ -647,5 +666,5 @@ /**

*/
var onOrientationChange = function (e) {
function onOrientationChange(e) {
setPreviewRotation(e.orientation);
};
}

@@ -658,3 +677,3 @@ /**

*/
var orientationToRotation = function (orientation) {
function orientationToRotation(orientation) {
// VideoRotation enumerable and BitmapRotation enumerable have the same values

@@ -683,3 +702,3 @@ // https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.videorotation.aspx

}
};
}

@@ -690,5 +709,5 @@ /**

*/
var setPreviewRotation = function(orientation) {
function setPreviewRotation(orientation) {
capture.setPreviewRotation(orientationToRotation(orientation));
};
}

@@ -726,5 +745,10 @@ try {

if (totalPixels <= 320 * 240) {
if (targetWidth == -1 && targetHeight == -1) {
maxRes = UIMaxRes.highestAvailable;
}
// Temp fix for CB-10539
/*else if (totalPixels <= 320 * 240) {
maxRes = UIMaxRes.verySmallQvga;
} else if (totalPixels <= 640 * 480) {
}*/
else if (totalPixels <= 640 * 480) {
maxRes = UIMaxRes.smallVga;

@@ -743,9 +767,8 @@ } else if (totalPixels <= 1024 * 768) {

cameraCaptureUI.captureFileAsync(WMCapture.CameraCaptureUIMode.photo).done(function(picture) {
if (!picture) {
errorCallback("User didn't capture a photo.");
return;
}
var cameraPicture;
var savePhotoOnFocus = function() {
savePhoto(picture, {
window.removeEventListener("focus", savePhotoOnFocus);
// call only when the app is in focus again
savePhoto(cameraPicture, {
destinationType: destinationType,

@@ -757,4 +780,16 @@ targetHeight: targetHeight,

}, successCallback, errorCallback);
};
// add and delete focus eventHandler to capture the focus back from cameraUI to app
window.addEventListener("focus", savePhotoOnFocus);
cameraCaptureUI.captureFileAsync(WMCapture.CameraCaptureUIMode.photo).done(function(picture) {
if (!picture) {
errorCallback("User didn't capture a photo.");
window.removeEventListener("focus", savePhotoOnFocus);
return;
}
cameraPicture = picture;
}, function() {
errorCallback("Fail to capture a photo.");
window.removeEventListener("focus", savePhotoOnFocus);
});

@@ -761,0 +796,0 @@ }

@@ -22,2 +22,5 @@ /*

/* globals Camera, resolveLocalFileSystemURI, FileEntry, CameraPopoverOptions, FileTransfer, FileUploadOptions, LocalFileSystem, MSApp */
/* jshint jasmine: true */
exports.defineAutoTests = function () {

@@ -82,3 +85,2 @@ describe('Camera (navigator.camera)', function () {

exports.defineManualTests = function (contentEl, createActionButton) {
var platformId = cordova.require('cordova/platform').id;
var pictureUrl = null;

@@ -99,7 +101,2 @@ var fileObj = null;

var clearLog = function () {
var log = document.getElementById('info');
log.innerHTML = "";
}
function log(value) {

@@ -127,4 +124,4 @@ console.log(value);

// not DATA_URL
log('URL: ' + url.slice(0, 100));
}
log('URL: "' + url.slice(0, 90) + '"');

@@ -137,3 +134,5 @@ pictureUrl = url;

log('Image tag load time: ' + (new Date() - startTime));
callback && callback();
if (callback) {
callback();
}
};

@@ -149,8 +148,9 @@ }

// TODO: Fix resolveLocalFileSystemURI to work with native-uri.
if (pictureUrl.indexOf('file:') == 0 || pictureUrl.indexOf('content:') == 0 || pictureUrl.indexOf('ms-appdata:') === 0) {
if (pictureUrl.indexOf('file:') === 0 || pictureUrl.indexOf('content:') === 0 || pictureUrl.indexOf('ms-appdata:') === 0 || pictureUrl.indexOf('assets-library:') === 0) {
resolveLocalFileSystemURI(data, function (e) {
fileEntry = e;
logCallback('resolveLocalFileSystemURI()', true)(e.toURL());
readFile();
}, logCallback('resolveLocalFileSystemURI()', false));
} else if (pictureUrl.indexOf('data:image/jpeg;base64') == 0) {
} else if (pictureUrl.indexOf('data:image/jpeg;base64') === 0) {
// do nothing

@@ -173,3 +173,3 @@ } else {

popoverHandle.setPosition(newPopoverOptions);
}
};
}

@@ -179,4 +179,2 @@

var ft = new FileTransfer(),
uploadcomplete = 0,
progress = 0,
options = new FileUploadOptions();

@@ -217,3 +215,3 @@ options.fileKey = "photo";

log("FileReader.readAsDataURL success");
};
}

@@ -229,4 +227,6 @@ function onFileReceived(file) {

reader.onerror = logCallback('FileReader.readAsDataURL', false);
reader.onloadend = onFileReadAsDataURL;
reader.readAsDataURL(file);
};
}
// Test out onFileReceived when the file object was set via a native <input> elements.

@@ -239,2 +239,3 @@ if (fileObj) {

}
function getFileInfo() {

@@ -246,3 +247,3 @@ // Test FileEntry API here.

fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false));
};
}

@@ -281,3 +282,3 @@ /**

window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onFileSystemReceived, null);
};
}

@@ -303,3 +304,3 @@ /**

fileEntry.createWriter(onFileTruncateWriterReceived, null);
};
}

@@ -317,3 +318,3 @@ function displayImageUsingCanvas() {

context.drawImage(img, 0, 0, w, h);
};
}

@@ -326,3 +327,3 @@ /**

fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false));
};
}

@@ -336,3 +337,3 @@ function testInputTag(inputEl) {

}, 0);
};
}

@@ -367,11 +368,15 @@ function testNativeFile2(inputEl) {

var ret = {};
/*jshint -W084 */
for (var i = 0, el; el = els[i]; ++i) {
var value = el.value;
if (value === '') continue;
value = +value;
if (el.isBool) {
ret[el.getAttribute("name")] = !!+value;
ret[el.getAttribute("name")] = !!value;
} else {
ret[el.getAttribute("name")] = +value;
ret[el.getAttribute("name")] = value;
}
}
/*jshint +W084 */
return ret;

@@ -382,6 +387,6 @@ }

var openDiv = '<div style="display: inline-block">' + name + ': ';
var select = '<select name=' + name + '>';
var select = '<select name=' + name + ' id="' + name + '">';
var defaultOption = '';
if (selectionDefault == undefined) {
if (selectionDefault === undefined) {
defaultOption = '<option value="">default</option>';

@@ -482,3 +487,3 @@ }

testInputTag(e.target);
}
};
for (var i = 0; i < elements.length; ++i) {

@@ -485,0 +490,0 @@ var item = elements[i];

@@ -19,3 +19,3 @@ /*

*
*/
*/

@@ -22,0 +22,0 @@ document.addEventListener('DOMContentLoaded', function () {

@@ -28,3 +28,3 @@ /*

/**
/**
* @namespace navigator

@@ -84,9 +84,9 @@ */

* image gallery. The image is passed to the success callback as a
* base64-encoded `String`, or as the URI for the image file.
*
* Base64-encoded `String`, or as the URI for the image file.
*
* The `camera.getPicture` function opens the device's default camera
* application that allows users to snap pictures by default - this behavior occurs,
* when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}.
* when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}.
* Once the user snaps the photo, the camera application closes and the application is restored.
*
*
* If `Camera.sourceType` is `Camera.PictureSourceType.PHOTOLIBRARY` or

@@ -98,20 +98,20 @@ * `Camera.PictureSourceType.SAVEDPHOTOALBUM`, then a dialog displays

* example, when the device orientation changes.
*
*
* The return value is sent to the [`cameraSuccess`]{@link module:camera.onSuccess} callback function, in
* one of the following formats, depending on the specified
* `cameraOptions`:
*
* - A `String` containing the base64-encoded photo image.
*
*
* - A `String` containing the Base64-encoded photo image.
*
* - A `String` representing the image file location on local storage (default).
*
*
* You can do whatever you want with the encoded image or URI, for
* example:
*
*
* - Render the image in an `<img>` tag, as in the example below
*
*
* - Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.)
*
*
* - Post the data to a remote server
*
*
* __NOTE__: Photo resolution on newer devices is quite good. Photos

@@ -125,7 +125,14 @@ * selected from the device's gallery are not downscaled to a lower

*
* ![](doc/img/android-success.png) ![](doc/img/blackberry-success.png) ![](doc/img/browser-success.png) ![](doc/img/firefox-success.png) ![](doc/img/fireos-success.png) ![](doc/img/ios-success.png) ![](doc/img/windows-success.png) ![](doc/img/wp8-success.png) ![](doc/img/ubuntu-success.png)
* - Android
* - BlackBerry
* - Browser
* - Firefox
* - FireOS
* - iOS
* - Windows
* - WP8
* - Ubuntu
*
* * [More examples](#camera-getPicture-examples)
* More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks).
*
* * [Quirks](#camera-getPicture-quirks)
* @example

@@ -171,7 +178,7 @@ * navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);

*
* ![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png)
* - iOS
*
* @example
* navigator.camera.cleanup(onSuccess, onFail);
*
*
* function onSuccess() {

@@ -178,0 +185,0 @@ * console.log("Camera cleanup success.")

@@ -22,6 +22,4 @@ /*

var exec = require('cordova/exec');
/**
* @ignore in favour of ios' one
* @ignore in favour of iOS' one
* A handle to an image picker popover.

@@ -28,0 +26,0 @@ */

@@ -24,3 +24,3 @@ /*

/**
/**
* @namespace navigator

@@ -34,7 +34,7 @@ */

*
* ![](doc/img/android-fail.png) ![](doc/img/blackberry-fail.png) ![](doc/img/browser-fail.png) ![](doc/img/firefox-fail.png) ![](doc/img/fireos-fail.png) ![](doc/img/ios-success.png) ![](doc/img/windows-fail.png) ![](doc/img/wp8-fail.png) ![](doc/img/ubuntu-fail.png)
* - iOS
*
* @example
* var cameraPopoverHandle = navigator.camera.getPicture(onSuccess, onFail,
* {
* {
* destinationType: Camera.DestinationType.FILE_URI,

@@ -44,3 +44,3 @@ * sourceType: Camera.PictureSourceType.PHOTOLIBRARY,

* });
*
*
* // Reposition the popover if the orientation changes.

@@ -47,0 +47,0 @@ * window.onorientationchange = function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc