]> git.proxmox.com Git - sencha-touch.git/blob - src/src/device/camera/Cordova.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / src / device / camera / Cordova.js
1 /**
2 * @private
3 */
4 Ext.define('Ext.device.camera.Cordova', {
5 alternateClassName: 'Ext.device.camera.PhoneGap',
6 extend: 'Ext.device.camera.Abstract',
7
8 getPicture: function (onSuccess, onError, options){
9 try {
10 navigator.camera.getPicture(onSuccess, onError, options);
11 } catch (e) {
12 alert(e);
13 }
14 },
15
16 cleanup: function(onSuccess, onError) {
17 try {
18 navigator.camera.cleanup(onSuccess, onError);
19 } catch (e) {
20 alert(e);
21 }
22 },
23
24 capture: function(args) {
25 var onSuccess = args.success,
26 onError = args.failure,
27 scope = args.scope,
28 sources = this.source,
29 destinations = this.destination,
30 encodings = this.encoding,
31 source = args.source,
32 destination = args.destination,
33 encoding = args.encoding,
34 options = {};
35
36 if (scope) {
37 onSuccess = Ext.Function.bind(onSuccess, scope);
38 onError = Ext.Function.bind(onError, scope);
39 }
40
41 if (source !== undefined) {
42 options.sourceType = sources.hasOwnProperty(source) ? sources[source] : source;
43 }
44
45 if (destination !== undefined) {
46 options.destinationType = destinations.hasOwnProperty(destination) ? destinations[destination] : destination;
47 }
48
49 if (encoding !== undefined) {
50 options.encodingType = encodings.hasOwnProperty(encoding) ? encodings[encoding] : encoding;
51 }
52
53 if ('quality' in args) {
54 options.quality = args.quality;
55 }
56
57 if ('width' in args) {
58 options.targetWidth = args.width;
59 }
60
61 if ('height' in args) {
62 options.targetHeight = args.height;
63 }
64
65 this.getPicture(onSuccess, onError, options);
66 }
67 });