2014-11-25 23:54:18 +08:00
"use strict" ;
2014-11-01 00:02:45 +08:00
2015-01-14 19:29:08 +08:00
( function ( require , module ) {
// Get cordova plugin.
var exec = require ( "cordova/exec" ) ;
// constructor.
function CustomCameraExport ( ) { }
2015-02-03 18:52:29 +08:00
CustomCameraExport . prototype . FlashModes = { DISABLE : 0 , ACTIVE : 1 , AUTO : 2 } ;
2015-01-14 19:29:08 +08:00
/ * *
* 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-30 01:58:52 +08:00
imgBackgroundBase64OtherOrientation : null , // background picture in base64 for second orientation. If it's not defined, imgBackgroundBase64 is used.
2015-01-14 19:29:08 +08:00
miniature : true , // active or disable the miniature function.
2015-01-19 21:13:11 +08:00
saveInGallery : false , // save or not the picture in gallery.
2015-01-14 19:29:08 +08:00
cameraBackgroundColor : "#e26760" , // color of the camera button.
2015-01-20 00:21:39 +08:00
cameraBackgroundColorPressed : "#dc453d" , // color of the pressed camera button.
2015-01-14 19:29:08 +08: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 17:19:07 +08: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")
2015-02-03 18:52:29 +08:00
opacity : true , // active or disable the opacity function.
defaultFlash : this . FlashModes . DISABLE , // default state for flash. Corrects values = 0 (disable) / 1 (active) / 2 (auto)
switchFlash : true // active or disable the switch flash button.
2015-01-14 19:29:08 +08:00
} ;
for ( var nameOption in defaultOptions ) {
if ( options [ nameOption ] === undefined ) {
options [ nameOption ] = defaultOptions [ nameOption ] ;
}
2015-01-05 19:00:00 +08:00
}
2014-11-21 22:50:38 +08:00
2015-01-19 16:54:09 +08:00
function successFctCallback ( data ) {
2015-01-14 19:29:08 +08:00
successFct ( data ) ;
2015-01-19 16:54:09 +08:00
}
2015-01-14 19:29:08 +08:00
2015-01-19 16:54:09 +08:00
function failFctCallback ( data ) {
2015-01-14 19:29:08 +08:00
failFct ( data . code , data . message ) ;
2015-01-19 16:54:09 +08:00
}
2015-01-14 19:29:08 +08:00
exec (
successFctCallback ,
failFctCallback ,
"CustomCamera" ,
"startCamera" ,
[
options . imgBackgroundBase64 ,
2015-01-30 01:58:52 +08:00
options . imgBackgroundBase64OtherOrientation ,
2015-01-14 19:29:08 +08:00
options . miniature ,
2015-01-19 21:13:11 +08:00
options . saveInGallery ,
2015-01-14 19:29:08 +08:00
options . cameraBackgroundColor ,
2015-01-20 00:21:39 +08:00
options . cameraBackgroundColorPressed ,
2015-01-26 17:19:07 +08:00
options . quality ,
2015-02-03 18:52:29 +08:00
options . opacity ,
options . defaultFlash ,
options . switchFlash
2015-01-14 19:29:08 +08:00
]
) ;
2014-11-25 23:54:18 +08:00
} ;
2015-01-14 19:29:08 +08:00
module . exports = new CustomCameraExport ( ) ;
} ) ( require , module ) ;