]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * @private\r | |
3 | */\r | |
4 | Ext.define('Ext.device.device.Cordova', {\r | |
5 | alternateClassName: 'Ext.device.device.PhoneGap',\r | |
6 | \r | |
7 | extend: 'Ext.device.device.Abstract',\r | |
8 | \r | |
9 | availableListeners: [\r | |
10 | 'pause',\r | |
11 | 'resume',\r | |
12 | 'backbutton',\r | |
13 | 'batterycritical',\r | |
14 | 'batterylow',\r | |
15 | 'batterystatus',\r | |
16 | 'menubutton',\r | |
17 | 'searchbutton',\r | |
18 | 'startcallbutton',\r | |
19 | 'endcallbutton',\r | |
20 | 'volumeupbutton',\r | |
21 | 'volumedownbutton'\r | |
22 | ],\r | |
23 | \r | |
24 | constructor: function() {\r | |
25 | // We can't get the device details until the device is ready, so lets wait.\r | |
26 | if (Ext.isReady) {\r | |
27 | this.onReady();\r | |
28 | } else {\r | |
29 | Ext.onReady(this.onReady, this, {single: true});\r | |
30 | }\r | |
31 | },\r | |
32 | \r | |
33 | /**\r | |
34 | * @property {String} cordova\r | |
35 | * Returns the version of Cordova running on the device.\r | |
36 | *\r | |
37 | * alert('Device cordova: ' + Ext.device.Device.cordova);\r | |
38 | */\r | |
39 | \r | |
40 | /**\r | |
41 | * @property {String} version\r | |
42 | * Returns the operating system version.\r | |
43 | *\r | |
44 | * alert('Device Version: ' + Ext.device.Device.version);\r | |
45 | */\r | |
46 | \r | |
47 | /**\r | |
48 | * @property {String} model\r | |
49 | * Returns the device's model name.\r | |
50 | *\r | |
51 | * alert('Device Model: ' + Ext.device.Device.model);\r | |
52 | */\r | |
53 | \r | |
54 | /**\r | |
55 | * @event pause\r | |
56 | * Fires when the application goes into the background\r | |
57 | */\r | |
58 | \r | |
59 | /**\r | |
60 | * @event resume\r | |
61 | * Fires when the application goes into the foreground\r | |
62 | */\r | |
63 | \r | |
64 | /**\r | |
65 | * @event batterycritical\r | |
66 | * This event that fires when a Cordova application detects the percentage of battery \r | |
67 | * has reached the critical battery threshold.\r | |
68 | */\r | |
69 | \r | |
70 | /**\r | |
71 | * @event batterylow\r | |
72 | * This event that fires when a Cordova application detects the percentage of battery \r | |
73 | * has reached the low battery threshold.\r | |
74 | */\r | |
75 | \r | |
76 | /**\r | |
77 | * @event batterystatus\r | |
78 | * This event that fires when a Cordova application detects the percentage of battery \r | |
79 | * has changed by at least 1 percent.\r | |
80 | */\r | |
81 | \r | |
82 | /**\r | |
83 | * @event backbutton\r | |
84 | * This is an event that fires when the user presses the back button.\r | |
85 | */\r | |
86 | \r | |
87 | /**\r | |
88 | * @event menubutton\r | |
89 | * This is an event that fires when the user presses the menu button.\r | |
90 | */\r | |
91 | \r | |
92 | /**\r | |
93 | * @event searchbutton\r | |
94 | * This is an event that fires when the user presses the search button.\r | |
95 | */\r | |
96 | \r | |
97 | /**\r | |
98 | * @event startcallbutton\r | |
99 | * This is an event that fires when the user presses the start call button.\r | |
100 | */\r | |
101 | \r | |
102 | /**\r | |
103 | * @event endcallbutton\r | |
104 | * This is an event that fires when the user presses the end call button.\r | |
105 | */\r | |
106 | \r | |
107 | /**\r | |
108 | * @event volumeupbutton\r | |
109 | * This is an event that fires when the user presses the volume up button.\r | |
110 | */\r | |
111 | \r | |
112 | /**\r | |
113 | * @event volumedownbutton\r | |
114 | * This is an event that fires when the user presses the volume down button.\r | |
115 | */\r | |
116 | \r | |
117 | onReady: function() {\r | |
118 | var me = this,\r | |
119 | device = window.device;\r | |
120 | \r | |
121 | me.name = device.name || device.model;\r | |
122 | me.cordova = device.cordova;\r | |
123 | me.platform = device.platform || Ext.os.name;\r | |
124 | me.uuid = device.uuid;\r | |
125 | me.version = device.version;\r | |
126 | me.model = device.model;\r | |
127 | },\r | |
128 | \r | |
129 | privates: {\r | |
130 | doAddListener: function(name) {\r | |
131 | var me = this;\r | |
132 | \r | |
133 | if (!me.addedListeners) {\r | |
134 | me.addedListeners = [];\r | |
135 | }\r | |
136 | \r | |
137 | if (me.availableListeners.indexOf(name) != -1 && me.addedListeners.indexOf(name) == -1) {\r | |
138 | // Add the listeners\r | |
139 | me.addedListeners.push(name);\r | |
140 | \r | |
141 | document.addEventListener(name, function() {\r | |
142 | me.fireEvent(name, me);\r | |
143 | });\r | |
144 | }\r | |
145 | \r | |
146 | Ext.device.Device.mixins.observable.doAddListener.apply(Ext.device.Device.mixins.observable, arguments);\r | |
147 | }\r | |
148 | }\r | |
149 | });\r |