9
0
mirror of https://gitee.com/shuto/customCamera.git synced 2024-10-06 18:32:07 +08:00
customCamera/www/customCamera.js

55 lines
1.8 KiB
JavaScript
Raw Normal View History

"use strict";
(function(require, module) {
// Get cordova plugin.
var exec = require("cordova/exec");
// constructor.
function CustomCameraExport() {}
/**
* Start custom camera.
*
* @param {object} options Options to plugin.
* @param {function} successFct Callback function to success action.
* @param {function} failFct Callback function to fail action.
*/
CustomCameraExport.prototype.startCamera = function(options, successFct, failFct) {
var defaultOptions = {
imgBackgroundBase64: null, // background picture in base64.
miniature: true, // active or disable the miniature function.
cameraBackgroundColor: "#e26760", // color of the camera button.
cameraBackgroundColorPressed: "#dc453d" // color of the pressed camera button.
// To get supported color formats, go to see method parseColor : http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
};
for (var nameOption in defaultOptions) {
if (options[nameOption] === undefined) {
options[nameOption] = defaultOptions[nameOption];
}
}
var successFctCallback = function(data) {
successFct(data);
};
var failFctCallback = function(data) {
failFct(data.code, data.message);
};
exec(
successFctCallback,
failFctCallback,
"CustomCamera",
"startCamera",
[
options.imgBackgroundBase64,
options.miniature,
options.cameraBackgroundColor,
options.cameraBackgroundColorPressed
]
);
};
module.exports = new CustomCameraExport();
})(require, module);