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
|
(function (FMS, Backbone, _, $) {
_.extend( FMS, {
ExistingView: FMS.FMSView.extend({
template: 'existing',
id: 'existing',
events: {
'pagehide': 'destroy',
'pagebeforeshow': 'beforeDisplay',
'pageshow': 'afterDisplay',
'vclick #use_report': 'useReport',
'vclick #save_report': 'saveReport',
'vclick #discard': 'discardReport'
},
_back: function() {
navigator.app.exitApp();
},
setHeight: function(content, height) {
content.css( 'min-height', content + 'px');
},
useReport: function(e) {
e.preventDefault();
FMS.setCurrentDraft(this.model);
this.navigate('around');
},
saveReport: function(e) {
e.preventDefault();
FMS.clearCurrentDraft();
this.navigate('around');
},
discardReport: function(e) {
e.preventDefault();
var reset = FMS.removeDraft(this.model.id, true);
var that = this;
reset.done( function() { that.onDraftRemove(); } );
reset.fail( function() { that.onDraftRemove(); } );
},
onDraftRemove: function() {
FMS.clearCurrentDraft();
this.navigate( 'around', 'left' );
}
})
});
})(FMS, Backbone, _, $);
|