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
|
(function (FMS, Backbone, _, $) {
_.extend( FMS, {
DetailsView: FMS.FMSView.extend({
template: 'details',
id: 'details-page',
prev: 'photo',
next: 'submit-email',
events: {
'pagehide': 'destroy',
'pageshow': 'afterDisplay',
'click .ui-btn-left': 'onClickButtonPrev',
'click .ui-btn-right': 'onClickButtonNext',
'change textarea': 'updateCurrentReport',
'change select': 'updateCurrentReport',
'blur input': 'updateCurrentReport'
},
afterRender: function() {
if ( this.model.get('category') ) {
this.$('#form_category').val( this.model.get('category') );
}
},
onClickButtonPrev: function() {
this.updateCurrentReport();
this.navigate( this.prev );
},
onClickButtonNext: function() {
this.clearValidationErrors();
var valid = 1;
if ( !$('#form_title').val() ) {
valid = 0;
this.validationError( 'form_title', FMS.validationStrings.title );
}
if ( !$('#form_detail').val() ) {
valid = 0;
this.validationError( 'form_detail', FMS.validationStrings.detail );
}
var cat = $('#form_category').val();
if ( cat == '-- Pick a category --' ) {
valid = 0;
this.validationError( 'form_category', FMS.validationStrings.category );
}
if ( valid ) {
this.clearValidationErrors();
this.updateCurrentReport();
this.navigate( this.next );
}
},
updateCurrentReport: function() {
this.model.set('category', $('#form_category').val());
this.model.set('title', $('#form_title').val());
this.model.set('details', $('#form_detail').val());
FMS.saveCurrentDraft();
}
})
});
})(FMS, Backbone, _, $);
|