mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-31 12:42:50 +08:00
CB-10636 Add JSHint for plugins
This commit is contained in:
parent
c1948fc0d4
commit
b16c5234d5
16
.jshintrc
Normal file
16
.jshintrc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"browser": true
|
||||||
|
, "devel": true
|
||||||
|
, "bitwise": true
|
||||||
|
, "undef": true
|
||||||
|
, "trailing": true
|
||||||
|
, "quotmark": false
|
||||||
|
, "indent": 4
|
||||||
|
, "unused": "vars"
|
||||||
|
, "latedef": "nofunc"
|
||||||
|
, "globals": {
|
||||||
|
"module": false,
|
||||||
|
"exports": false,
|
||||||
|
"require": false
|
||||||
|
}
|
||||||
|
}
|
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
language: node_js
|
||||||
|
sudo: false
|
||||||
|
node_js:
|
||||||
|
- "4.2"
|
@ -17,6 +17,8 @@
|
|||||||
# under the License.
|
# under the 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
|
# cordova-plugin-camera
|
||||||
|
|
||||||
This plugin defines a global `navigator.camera` object, which provides an API for taking pictures and for choosing images from
|
This plugin defines a global `navigator.camera` object, which provides an API for taking pictures and for choosing images from
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{{>cdv-license~}}
|
{{>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
|
# cordova-plugin-camera
|
||||||
|
|
||||||
This plugin defines a global `navigator.camera` object, which provides an API for taking pictures and for choosing images from
|
This plugin defines a global `navigator.camera` object, which provides an API for taking pictures and for choosing images from
|
||||||
|
@ -43,13 +43,16 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"precommit": "npm run gen-docs && git add README.md",
|
"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",
|
"author": "Apache Software Foundation",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dmd-plugin-cordova-plugin": "^0.1.0",
|
"dmd-plugin-cordova-plugin": "^0.1.0",
|
||||||
"husky": "^0.10.1",
|
"husky": "^0.10.1",
|
||||||
"jsdoc-to-markdown": "^1.2.0"
|
"jsdoc-to-markdown": "^1.2.0",
|
||||||
|
"jshint": "^2.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* globals qnx, FileError, PluginResult */
|
||||||
|
|
||||||
var PictureSourceType = {
|
var PictureSourceType = {
|
||||||
PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
|
PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
|
||||||
CAMERA : 1, // Take picture from camera
|
CAMERA : 1, // Take picture from camera
|
||||||
@ -40,7 +43,7 @@ window.qnx.webplatform.getApplication().invocation.queryTargets(
|
|||||||
},
|
},
|
||||||
function (error, targets) {
|
function (error, targets) {
|
||||||
invokeAvailable = !error && targets && targets instanceof Array &&
|
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;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -85,7 +88,7 @@ function showCameraDialog (done, cancel, fail) {
|
|||||||
//create unique name for saved file (same pattern as BB10 camera app)
|
//create unique name for saved file (same pattern as BB10 camera app)
|
||||||
function imgName() {
|
function imgName() {
|
||||||
var date = new Date(),
|
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()) + '_' +
|
return 'IMG_' + date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) + '_' +
|
||||||
pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + '.png';
|
pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + '.png';
|
||||||
}
|
}
|
||||||
@ -145,7 +148,7 @@ function encodeBase64(filePath, callback) {
|
|||||||
default:
|
default:
|
||||||
msg += "Unknown Error";
|
msg += "Unknown Error";
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
|
||||||
// set it back to original value
|
// set it back to original value
|
||||||
window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
|
window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
|
||||||
|
@ -32,8 +32,6 @@ function takePicture(success, error, opts) {
|
|||||||
input.name = 'files[]';
|
input.name = 'files[]';
|
||||||
|
|
||||||
input.onchange = function(inputEvent) {
|
input.onchange = function(inputEvent) {
|
||||||
var canvas = document.createElement('canvas');
|
|
||||||
|
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function(readerEvent) {
|
reader.onload = function(readerEvent) {
|
||||||
input.parentNode.removeChild(input);
|
input.parentNode.removeChild(input);
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* globals MozActivity */
|
||||||
|
|
||||||
function takePicture(success, error, opts) {
|
function takePicture(success, error, opts) {
|
||||||
var pick = new MozActivity({
|
var pick = new MozActivity({
|
||||||
name: "pick",
|
name: "pick",
|
||||||
@ -32,7 +34,7 @@ function takePicture(success, error, opts) {
|
|||||||
pick.onsuccess = function() {
|
pick.onsuccess = function() {
|
||||||
// image is returned as Blob in this.result.blob
|
// image is returned as Blob in this.result.blob
|
||||||
// we need to call success with url or base64 encoded image
|
// we need to call success with url or base64 encoded image
|
||||||
if (opts && opts.destinationType == 0) {
|
if (opts && opts.destinationType === 0) {
|
||||||
// TODO: base64
|
// TODO: base64
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -325,14 +325,14 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
CaptureNS = Windows.Media.Capture,
|
CaptureNS = Windows.Media.Capture,
|
||||||
sensor = null;
|
sensor = null;
|
||||||
|
|
||||||
var createCameraUI = function () {
|
function createCameraUI() {
|
||||||
// create style for take and cancel buttons
|
// create style for take and cancel buttons
|
||||||
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;";
|
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;";
|
||||||
|
|
||||||
// Create fullscreen preview
|
// Create fullscreen preview
|
||||||
// z-order style element for capturePreview and cameraCancelButton elts
|
// z-order style element for capturePreview and cameraCancelButton elts
|
||||||
// is necessary to avoid overriding by another page elements, -1 sometimes is not enough
|
// 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) + ";";
|
capturePreview.style.cssText = "position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: " + (HIGHEST_POSSIBLE_Z_INDEX - 1) + ";";
|
||||||
|
|
||||||
// Create capture button
|
// Create capture button
|
||||||
@ -349,9 +349,9 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
|
|
||||||
captureSettings = new CaptureNS.MediaCaptureInitializationSettings();
|
captureSettings = new CaptureNS.MediaCaptureInitializationSettings();
|
||||||
captureSettings.streamingCaptureMode = CaptureNS.StreamingCaptureMode.video;
|
captureSettings.streamingCaptureMode = CaptureNS.StreamingCaptureMode.video;
|
||||||
};
|
}
|
||||||
|
|
||||||
var startCameraPreview = function () {
|
function startCameraPreview() {
|
||||||
// Search for available camera devices
|
// Search for available camera devices
|
||||||
// This is necessary to detect which camera (front or back) we should use
|
// This is necessary to detect which camera (front or back) we should use
|
||||||
var DeviceEnum = Windows.Devices.Enumeration;
|
var DeviceEnum = Windows.Devices.Enumeration;
|
||||||
@ -443,9 +443,9 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
destroyCameraPreview();
|
destroyCameraPreview();
|
||||||
errorCallback('Camera intitialization error ' + err);
|
errorCallback('Camera intitialization error ' + err);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
var destroyCameraPreview = function () {
|
function destroyCameraPreview() {
|
||||||
// If sensor is available, remove event listener
|
// If sensor is available, remove event listener
|
||||||
if (sensor !== null) {
|
if (sensor !== null) {
|
||||||
sensor.removeEventListener('orientationchanged', onOrientationChange);
|
sensor.removeEventListener('orientationchanged', onOrientationChange);
|
||||||
@ -471,9 +471,9 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
capture.stopRecordAsync();
|
capture.stopRecordAsync();
|
||||||
capture = null;
|
capture = null;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
var captureAction = function () {
|
function captureAction() {
|
||||||
|
|
||||||
var encodingProperties,
|
var encodingProperties,
|
||||||
fileName,
|
fileName,
|
||||||
@ -535,9 +535,9 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
destroyCameraPreview();
|
destroyCameraPreview();
|
||||||
errorCallback(err);
|
errorCallback(err);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
var getAspectRatios = function (capture) {
|
function getAspectRatios(capture) {
|
||||||
var videoDeviceController = capture.videoDeviceController;
|
var videoDeviceController = capture.videoDeviceController;
|
||||||
var photoAspectRatios = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.photo).map(function (element) {
|
var photoAspectRatios = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.photo).map(function (element) {
|
||||||
return (element.width / element.height).toFixed(1);
|
return (element.width / element.height).toFixed(1);
|
||||||
@ -564,9 +564,9 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
return Object.keys(aspectObj).filter(function (k) {
|
return Object.keys(aspectObj).filter(function (k) {
|
||||||
return aspectObj[k] === 3;
|
return aspectObj[k] === 3;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
var setAspectRatio = function (capture, aspect) {
|
function setAspectRatio(capture, aspect) {
|
||||||
// Max photo resolution with desired aspect ratio
|
// Max photo resolution with desired aspect ratio
|
||||||
var videoDeviceController = capture.videoDeviceController;
|
var videoDeviceController = capture.videoDeviceController;
|
||||||
var photoResolution = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.photo)
|
var photoResolution = videoDeviceController.getAvailableMediaStreamProperties(CapMSType.photo)
|
||||||
@ -602,12 +602,12 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
.then(function () {
|
.then(function () {
|
||||||
return videoDeviceController.setMediaStreamPropertiesAsync(CapMSType.videoRecord, videoRecordResolution);
|
return videoDeviceController.setMediaStreamPropertiesAsync(CapMSType.videoRecord, videoRecordResolution);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When Capture button is clicked, try to capture a picture and return
|
* When Capture button is clicked, try to capture a picture and return
|
||||||
*/
|
*/
|
||||||
var onCameraCaptureButtonClick = function() {
|
function onCameraCaptureButtonClick() {
|
||||||
// Make sure user can't click more than once
|
// Make sure user can't click more than once
|
||||||
if (this.getAttribute('clicked') === '1') {
|
if (this.getAttribute('clicked') === '1') {
|
||||||
return false;
|
return false;
|
||||||
@ -615,12 +615,12 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
this.setAttribute('clicked', '1');
|
this.setAttribute('clicked', '1');
|
||||||
}
|
}
|
||||||
captureAction();
|
captureAction();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When Cancel button is clicked, destroy camera preview and return with error callback
|
* When Cancel button is clicked, destroy camera preview and return with error callback
|
||||||
*/
|
*/
|
||||||
var onCameraCancelButtonClick = function() {
|
function onCameraCancelButtonClick() {
|
||||||
// Make sure user can't click more than once
|
// Make sure user can't click more than once
|
||||||
if (this.getAttribute('clicked') === '1') {
|
if (this.getAttribute('clicked') === '1') {
|
||||||
return false;
|
return false;
|
||||||
@ -629,15 +629,15 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
}
|
}
|
||||||
destroyCameraPreview();
|
destroyCameraPreview();
|
||||||
errorCallback('no image selected');
|
errorCallback('no image selected');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the phone orientation change, get the event and change camera preview rotation
|
* When the phone orientation change, get the event and change camera preview rotation
|
||||||
* @param {Object} e - SimpleOrientationSensorOrientationChangedEventArgs
|
* @param {Object} e - SimpleOrientationSensorOrientationChangedEventArgs
|
||||||
*/
|
*/
|
||||||
var onOrientationChange = function (e) {
|
function onOrientationChange(e) {
|
||||||
setPreviewRotation(e.orientation);
|
setPreviewRotation(e.orientation);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts SimpleOrientation to a VideoRotation to remove difference between camera sensor orientation
|
* Converts SimpleOrientation to a VideoRotation to remove difference between camera sensor orientation
|
||||||
@ -645,7 +645,7 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
* @param {number} orientation - Windows.Devices.Sensors.SimpleOrientation
|
* @param {number} orientation - Windows.Devices.Sensors.SimpleOrientation
|
||||||
* @return {number} - Windows.Media.Capture.VideoRotation
|
* @return {number} - Windows.Media.Capture.VideoRotation
|
||||||
*/
|
*/
|
||||||
var orientationToRotation = function (orientation) {
|
function orientationToRotation(orientation) {
|
||||||
// VideoRotation enumerable and BitmapRotation enumerable have the same values
|
// VideoRotation enumerable and BitmapRotation enumerable have the same values
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.videorotation.aspx
|
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.videorotation.aspx
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.imaging.bitmaprotation.aspx
|
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.imaging.bitmaprotation.aspx
|
||||||
@ -669,15 +669,15 @@ function takePictureFromCameraWP(successCallback, errorCallback, args) {
|
|||||||
// Falling back to portrait default
|
// Falling back to portrait default
|
||||||
return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
|
return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotates the current MediaCapture's video
|
* Rotates the current MediaCapture's video
|
||||||
* @param {number} orientation - Windows.Devices.Sensors.SimpleOrientation
|
* @param {number} orientation - Windows.Devices.Sensors.SimpleOrientation
|
||||||
*/
|
*/
|
||||||
var setPreviewRotation = function(orientation) {
|
function setPreviewRotation(orientation) {
|
||||||
capture.setPreviewRotation(orientationToRotation(orientation));
|
capture.setPreviewRotation(orientationToRotation(orientation));
|
||||||
};
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
createCameraUI();
|
createCameraUI();
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* globals Camera, resolveLocalFileSystemURI, FileEntry, CameraPopoverOptions, FileTransfer, FileUploadOptions, LocalFileSystem, MSApp */
|
||||||
|
/* jshint jasmine: true */
|
||||||
|
|
||||||
exports.defineAutoTests = function () {
|
exports.defineAutoTests = function () {
|
||||||
describe('Camera (navigator.camera)', function () {
|
describe('Camera (navigator.camera)', function () {
|
||||||
it("should exist", function () {
|
it("should exist", function () {
|
||||||
@ -78,7 +81,6 @@ exports.defineAutoTests = function () {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||||
var platformId = cordova.require('cordova/platform').id;
|
|
||||||
var pictureUrl = null;
|
var pictureUrl = null;
|
||||||
var fileObj = null;
|
var fileObj = null;
|
||||||
var fileEntry = null;
|
var fileEntry = null;
|
||||||
@ -94,11 +96,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
var camCorrectOrientationDefault = ['correctOrientation', false];
|
var camCorrectOrientationDefault = ['correctOrientation', false];
|
||||||
var camSaveToPhotoAlbumDefault = ['saveToPhotoAlbum', true];
|
var camSaveToPhotoAlbumDefault = ['saveToPhotoAlbum', true];
|
||||||
|
|
||||||
var clearLog = function () {
|
|
||||||
var log = document.getElementById('info');
|
|
||||||
log.innerHTML = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function log(value) {
|
function log(value) {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n';
|
document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n';
|
||||||
@ -130,7 +127,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
img.src = url;
|
img.src = url;
|
||||||
img.onloadend = function () {
|
img.onloadend = function () {
|
||||||
log('Image tag load time: ' + (new Date() - startTime));
|
log('Image tag load time: ' + (new Date() - startTime));
|
||||||
callback && callback();
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,13 +140,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
function getPictureWin(data) {
|
function getPictureWin(data) {
|
||||||
setPicture(data);
|
setPicture(data);
|
||||||
// TODO: Fix resolveLocalFileSystemURI to work with native-uri.
|
// TODO: Fix resolveLocalFileSystemURI to work with native-uri.
|
||||||
if (pictureUrl.indexOf('file:') == 0 || pictureUrl.indexOf('content:') == 0 || pictureUrl.indexOf('ms-appdata:') === 0 || pictureUrl.indexOf('assets-library:') === 0) {
|
if (pictureUrl.indexOf('file:') === 0 || pictureUrl.indexOf('content:') === 0 || pictureUrl.indexOf('ms-appdata:') === 0 || pictureUrl.indexOf('assets-library:') === 0) {
|
||||||
resolveLocalFileSystemURI(data, function (e) {
|
resolveLocalFileSystemURI(data, function (e) {
|
||||||
fileEntry = e;
|
fileEntry = e;
|
||||||
logCallback('resolveLocalFileSystemURI()', true)(e.toURL());
|
logCallback('resolveLocalFileSystemURI()', true)(e.toURL());
|
||||||
readFile();
|
readFile();
|
||||||
}, logCallback('resolveLocalFileSystemURI()', false));
|
}, logCallback('resolveLocalFileSystemURI()', false));
|
||||||
} else if (pictureUrl.indexOf('data:image/jpeg;base64') == 0) {
|
} else if (pictureUrl.indexOf('data:image/jpeg;base64') === 0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
var path = pictureUrl.replace(/^file:\/\/(localhost)?/, '').replace(/%20/g, ' ');
|
var path = pictureUrl.replace(/^file:\/\/(localhost)?/, '').replace(/%20/g, ' ');
|
||||||
@ -165,13 +164,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
window.onorientationchange = function () {
|
window.onorientationchange = function () {
|
||||||
var newPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, 0);
|
var newPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, 0);
|
||||||
popoverHandle.setPosition(newPopoverOptions);
|
popoverHandle.setPosition(newPopoverOptions);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function uploadImage() {
|
function uploadImage() {
|
||||||
var ft = new FileTransfer(),
|
var ft = new FileTransfer(),
|
||||||
uploadcomplete = 0,
|
|
||||||
progress = 0,
|
|
||||||
options = new FileUploadOptions();
|
options = new FileUploadOptions();
|
||||||
options.fileKey = "photo";
|
options.fileKey = "photo";
|
||||||
options.fileName = 'test.jpg';
|
options.fileName = 'test.jpg';
|
||||||
@ -207,7 +204,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
img.style.display = "block";
|
img.style.display = "block";
|
||||||
img.src = evt.target.result;
|
img.src = evt.target.result;
|
||||||
log("FileReader.readAsDataURL success");
|
log("FileReader.readAsDataURL success");
|
||||||
};
|
}
|
||||||
|
|
||||||
function onFileReceived(file) {
|
function onFileReceived(file) {
|
||||||
log('Got file: ' + JSON.stringify(file));
|
log('Got file: ' + JSON.stringify(file));
|
||||||
@ -220,7 +217,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
reader.onerror = logCallback('FileReader.readAsDataURL', false);
|
reader.onerror = logCallback('FileReader.readAsDataURL', false);
|
||||||
reader.onloadend = onFileReadAsDataURL;
|
reader.onloadend = onFileReadAsDataURL;
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
};
|
}
|
||||||
|
|
||||||
// Test out onFileReceived when the file object was set via a native <input> elements.
|
// Test out onFileReceived when the file object was set via a native <input> elements.
|
||||||
if (fileObj) {
|
if (fileObj) {
|
||||||
onFileReceived(fileObj);
|
onFileReceived(fileObj);
|
||||||
@ -228,13 +226,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
fileEntry.file(onFileReceived, logCallback('FileEntry.file', false));
|
fileEntry.file(onFileReceived, logCallback('FileEntry.file', false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileInfo() {
|
function getFileInfo() {
|
||||||
// Test FileEntry API here.
|
// Test FileEntry API here.
|
||||||
fileEntry.getMetadata(logCallback('FileEntry.getMetadata', true), logCallback('FileEntry.getMetadata', false));
|
fileEntry.getMetadata(logCallback('FileEntry.getMetadata', true), logCallback('FileEntry.getMetadata', false));
|
||||||
fileEntry.setMetadata(logCallback('FileEntry.setMetadata', true), logCallback('FileEntry.setMetadata', false), { "com.apple.MobileBackup": 1 });
|
fileEntry.setMetadata(logCallback('FileEntry.setMetadata', true), logCallback('FileEntry.setMetadata', false), { "com.apple.MobileBackup": 1 });
|
||||||
fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false));
|
fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false));
|
||||||
fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false));
|
fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false));
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy image from library using a NATIVE_URI destination type
|
* Copy image from library using a NATIVE_URI destination type
|
||||||
@ -268,7 +267,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onFileSystemReceived, null);
|
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onFileSystemReceived, null);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write image to library using a NATIVE_URI destination type
|
* Write image to library using a NATIVE_URI destination type
|
||||||
@ -289,7 +288,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
|
|
||||||
fileEntry.createWriter(onFileWriterReceived, logCallback('FileEntry.createWriter', false));
|
fileEntry.createWriter(onFileWriterReceived, logCallback('FileEntry.createWriter', false));
|
||||||
fileEntry.createWriter(onFileTruncateWriterReceived, null);
|
fileEntry.createWriter(onFileTruncateWriterReceived, null);
|
||||||
};
|
}
|
||||||
|
|
||||||
function displayImageUsingCanvas() {
|
function displayImageUsingCanvas() {
|
||||||
var canvas = document.getElementById('canvas');
|
var canvas = document.getElementById('canvas');
|
||||||
@ -302,7 +301,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
canvas.height = h;
|
canvas.height = h;
|
||||||
var context = canvas.getContext('2d');
|
var context = canvas.getContext('2d');
|
||||||
context.drawImage(img, 0, 0, w, h);
|
context.drawImage(img, 0, 0, w, h);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove image from library using a NATIVE_URI destination type
|
* Remove image from library using a NATIVE_URI destination type
|
||||||
@ -310,7 +309,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
*/
|
*/
|
||||||
function removeImage() {
|
function removeImage() {
|
||||||
fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false));
|
fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false));
|
||||||
};
|
}
|
||||||
|
|
||||||
function testInputTag(inputEl) {
|
function testInputTag(inputEl) {
|
||||||
clearStatus();
|
clearStatus();
|
||||||
@ -319,7 +318,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
testNativeFile2(inputEl);
|
testNativeFile2(inputEl);
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
}
|
||||||
|
|
||||||
function testNativeFile2(inputEl) {
|
function testNativeFile2(inputEl) {
|
||||||
if (!inputEl.value) {
|
if (!inputEl.value) {
|
||||||
@ -349,15 +348,19 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
function extractOptions() {
|
function extractOptions() {
|
||||||
var els = document.querySelectorAll('#image-options select');
|
var els = document.querySelectorAll('#image-options select');
|
||||||
var ret = {};
|
var ret = {};
|
||||||
|
/*jshint -W084 */
|
||||||
for (var i = 0, el; el = els[i]; ++i) {
|
for (var i = 0, el; el = els[i]; ++i) {
|
||||||
var value = el.value;
|
var value = el.value;
|
||||||
if (value === '') continue;
|
if (value === '') continue;
|
||||||
|
value = +value;
|
||||||
|
|
||||||
if (el.isBool) {
|
if (el.isBool) {
|
||||||
ret[el.getAttribute("name")] = !!+value;
|
ret[el.getAttribute("name")] = !!value;
|
||||||
} else {
|
} else {
|
||||||
ret[el.getAttribute("name")] = +value;
|
ret[el.getAttribute("name")] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*jshint +W084 */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +369,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
var select = '<select name=' + name + ' id="' + name + '">';
|
var select = '<select name=' + name + ' id="' + name + '">';
|
||||||
|
|
||||||
var defaultOption = '';
|
var defaultOption = '';
|
||||||
if (selectionDefault == undefined) {
|
if (selectionDefault === undefined) {
|
||||||
defaultOption = '<option value="">default</option>';
|
defaultOption = '<option value="">default</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +465,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
var elements = document.getElementsByClassName("testInputTag");
|
var elements = document.getElementsByClassName("testInputTag");
|
||||||
var listener = function (e) {
|
var listener = function (e) {
|
||||||
testInputTag(e.target);
|
testInputTag(e.target);
|
||||||
}
|
};
|
||||||
for (var i = 0; i < elements.length; ++i) {
|
for (var i = 0; i < elements.length; ++i) {
|
||||||
var item = elements[i];
|
var item = elements[i];
|
||||||
item.addEventListener("change", listener, false);
|
item.addEventListener("change", listener, false);
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var exec = require('cordova/exec');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore in favour of ios' one
|
* @ignore in favour of ios' one
|
||||||
* A handle to an image picker popover.
|
* A handle to an image picker popover.
|
||||||
|
Loading…
Reference in New Issue
Block a user