2014-11-25 16:54:18 +01:00
"use strict" ;
2014-10-31 17:02:45 +01:00
2015-01-14 12:29:08 +01:00
( 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.
2015-01-29 18:58:52 +01:00
imgBackgroundBase64OtherOrientation : null , // background picture in base64 for second orientation. If it's not defined, imgBackgroundBase64 is used.
2015-01-14 12:29:08 +01:00
miniature : true , // active or disable the miniature function.
2015-01-19 14:13:11 +01:00
saveInGallery : false , // save or not the picture in gallery.
2015-01-14 12:29:08 +01:00
cameraBackgroundColor : "#e26760" , // color of the camera button.
2015-01-19 17:21:39 +01:00
cameraBackgroundColorPressed : "#dc453d" , // color of the pressed camera button.
2015-01-14 12:29:08 +01:00
// To get supported color formats, go to see method parseColor : http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
2015-01-26 10:19:07 +01:00
quality : 100 , // picture's quality : range 0 - 100 : http://developer.android.com/reference/android/graphics/Bitmap.html#compress(android.graphics.Bitmap.CompressFormat, int, java.io.OutputStream) (parameter "quality")
opacity : true // active or disable the opacity function.
2015-01-14 12:29:08 +01:00
} ;
for ( var nameOption in defaultOptions ) {
if ( options [ nameOption ] === undefined ) {
options [ nameOption ] = defaultOptions [ nameOption ] ;
}
2015-01-05 12:00:00 +01:00
}
2014-11-21 15:50:38 +01:00
2015-01-19 09:54:09 +01:00
function successFctCallback ( data ) {
2015-01-14 12:29:08 +01:00
successFct ( data ) ;
2015-01-19 09:54:09 +01:00
}
2015-01-14 12:29:08 +01:00
2015-01-19 09:54:09 +01:00
function failFctCallback ( data ) {
2015-01-14 12:29:08 +01:00
failFct ( data . code , data . message ) ;
2015-01-19 09:54:09 +01:00
}
2015-01-14 12:29:08 +01:00
exec (
successFctCallback ,
failFctCallback ,
"CustomCamera" ,
"startCamera" ,
[
options . imgBackgroundBase64 ,
2015-01-29 18:58:52 +01:00
options . imgBackgroundBase64OtherOrientation ,
2015-01-14 12:29:08 +01:00
options . miniature ,
2015-01-19 14:13:11 +01:00
options . saveInGallery ,
2015-01-14 12:29:08 +01:00
options . cameraBackgroundColor ,
2015-01-19 17:21:39 +01:00
options . cameraBackgroundColorPressed ,
2015-01-26 10:19:07 +01:00
options . quality ,
options . opacity
2015-01-14 12:29:08 +01:00
]
) ;
2014-11-25 16:54:18 +01:00
} ;
2015-01-14 12:29:08 +01:00
module . exports = new CustomCameraExport ( ) ;
} ) ( require , module ) ;