-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
97 lines (79 loc) · 3.16 KB
/
events.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Wrapper for the events API in Cordova.
* Cordova lifecycle events.
*
* @author Brian Milton
* @version 1.0.0
*
* Important information
* ---------------------
* This routes all DOM events to the pubsub... However, it might not be necessary... Why not just use the DOM event?...
* What we could do is trigger the pubsub on every event with some kind of generic object containing the event information...
*
* cordova/eventTrigger --> Returns an object with the information of the event triggered.
*
*/
define(["troopjs/component/widget"],function cordovaEventsWrapper(Widget){"use strict";
var DEVICE_READY = false;
return Widget.extend({
"dom:memory/deviceready" : function onDeviceReady() {
var me = this;
me[DEVICE_READY] = true;
me.publish("cordova/deviceReady");
},
"dom:memory/pause" : function onPause() {
this.publish("cordova/appPause")
},
"dom:memory/resume" : function onResume() {
this.publish("cordova/appResume");
},
"dom:memory/online" : function onOnline() {
this.publish("cordova/online");
},
"dom:memory/offline" : function onOffline() {
this.publish("cordova/offline");
},
"dom:memory/backbutton" : function onBackKeyDown() {
this.publish("cordova/backButton");
},
"dom:memory/batterycritical" : function onBatteryCritical(info) {
/* info object:
* level : The percentage of the battery (0 - 100) (Number)
* isPlugged : A boolean that indicates whether the device is plugged in. (Boolean)
*/
this.publish("cordova/batteryCritical",info);
},
"dom:memory/batterylow" : function onBatteryLow(info) {
/* info object:
* level : The percentage of the battery (0 - 100) (Number)
* isPlugged : A boolean that indicates whether the device is plugged in. (Boolean)
*/
this.publish("cordova/batteryLow",info);
},
"dom:memory/batterystatus" : function onBatteryStatus(info) {
/* info object:
* level : The percentage of the battery (0 - 100) (Number)
* isPlugged : A boolean that indicates whether the device is plugged in. (Boolean)
*/
this.publish("cordova/batteryStatusChanged",info);
},
"dom:memory/menubutton" : function onMenuKeyDown() {
this.publish("cordova/menuKey");
},
"dom:memory/searchbutton" : function onSearchKeyDown() {
this.publish("cordova/searchKey");
},
"dom:memory/startcallbutton" : function onStartCallKeyDown() {
this.publish("cordova/startCallKey");
},
"dom:memory/endcallbutton" : function onEndCallKeyDown() {
this.publish("cordova/endCallKey");
},
"dom:memory/volumedownbutton" : function onVolumeDownKeyDown() {
this.publish("cordova/volumeDown");
},
"dom:memory/volumeupbotton" : function onVolumeUpKeyDown() {
this.publish("cordova/volumeUp");
}
});
});