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