-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·177 lines (152 loc) · 6.19 KB
/
index.html
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html>
<head>
<!--<base href="http://www.server.com/app-name/path/">-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="libs/jquery.mobile-1.0.1/jquery.mobile-1.0.1.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src="libs/jquery-1.7.1.min.js"></script>
<script type='text/javascript' src="libs/jquery.mobile-1.0.1/jquery.mobile-1.0.1.min.js"></script>
<script type='text/javascript' src="libs/knockout-2.0.0.js"></script>
<script type='text/javascript' src="libs/data-model.js"></script>
</head>
<body>
<div data-role="page" id="page_Vehicles" data-add-back-btn="true">
<div data-role="header">
<h3>Re-Fuel: Vehicles</h3>
<a href="#" data-role="button" data-icon="gear" class="ui-btn-left" data-iconpos="left" data-bind="visible: isReadMode, click: VehicleList_ToggleEditClicked">Edit</a>
<a href="#" data-role="button" data-icon="cancel" class="ui-btn-left" data-iconpos="left" data-bind="visible: isEditMode, click: VehicleList_ToggleEditClicked">Done</a>
<a href="#" data-role="button" data-icon="cancel" class="ui-btn-right" data-iconpos="left" data-bind="click: VehicleList_AddClicked">Add</a>
</div>
<div data-role="content">
<ul data-role="listview" data-bind="foreach: vehicleList">
<li>
<a href="#" data-icon="gear" data-bind="click: VehicleClicked, attr: { 'vehicle-id': $data.vehicleId }">
<span data-bind="text: $data.vehicleTitle"></span></a>
<a href="#" data-role="button" data-icon="delete" data-bind="visible: $parent.isEditMode, click: $parent.deleteVehicle">Button</a>
</li>
</ul>
</div>
<div data-role="footer" data-position="fixed" data-id="footer_Main">
<div data-role="navbar" data-iconpos="top">
<ul>
<li>
<a href="#page_Home" data-theme="" data-icon="" data-transition="none">
Home
</a>
</li>
<li>
<a href="#page_Vehicles" data-theme="" data-icon="" class="ui-btn-active ui-state-persist">
Vehicles
</a>
</li>
<li>
<a href="#page_PetrolStations" rel="external" data-theme="" data-icon="" data-transition="none">
Petrol Stations
</a>
</li>
<li>
<a href="#page_FuelType" data-theme="" data-icon="" data-transition="none">
Fuel Type
</a>
</li>
</ul>
</div>
</div>
</div>
<div data-role="page" id="page_VehicleDetails" data-add-back-btn="true">
<div data-role="header">
<h3>Vehicle Details: <span data-bind="text: vehicleTitle"></span>
</h3>
<a href="#" data-role="button" data-icon="gear" class="ui-btn-right" data-iconpos="left" data-bind="click: Vehicle_SaveClicked">Save</a>
</div>
<div data-role="content">
<div class="ui-grid-a" id="VehicleDetails_EditMode">
<div class="ui-block-a">Vehicle Id</div>
<div class="ui-block-b"><span data-bind="text: vehicleId"></span></div>
<div data-role="fieldcontain">
<label for="txtVehicleTitle">Vehicle Title</label>
<input type="text" name="txtVehicleTitle" id="txtVehicleTitle" data-bind="value: vehicleTitle" />
</div>
<div data-role="fieldcontain">
<label for="txtVehicleNumber">Vehicle Number</label>
<input type="text" name="txtVehicleNumber" id="txtVehicleNumber" data-bind="value: vehicleNumber" />
</div>
</div>
</div>
<div data-role="footer" data-position="fixed" data-id="footer_Main">
<div data-role="navbar" data-iconpos="top">
<ul>
<li>
<a href="#page_Home" data-theme="" data-icon="" data-transition="none">
Home
</a>
</li>
<li>
<a href="#page_Vehicles" data-theme="" data-icon="" class="ui-btn-active ui-state-persist">
Vehicles
</a>
</li>
<li>
<a href="#page_PetrolStations" rel="external" data-theme="" data-icon="" data-transition="none">
Petrol Stations
</a>
</li>
<li>
<a href="#page_FuelType" data-theme="" data-icon="" data-transition="none">
Fuel Type
</a>
</li>
</ul>
</div>
</div>
</div>
<script type="text/javascript">
$("#page_Vehicles").live('pageinit', function(event) {
var vehicleList = new VehicleList();
ko.applyBindings(vehicleList, this);
vehicleList.loadData();
});
$("#page_PetrolStations").live('pageinit', function(event) {
var petrolStationList = new PetrolStationList();
ko.applyBindings(petrolStationList, this);
petrolStationList.loadData();
});
$("#page_FuelType").live('pageinit', function(event) {
var fuelTypeList = new FuelTypeList();
ko.applyBindings(fuelTypeList, this);
fuelTypeList.loadData();
});
$("#page_Home").live('pageinit', function(event) {
var refuelList = new RefuelList();
ko.applyBindings(refuelList, this);
refuelList.loadData();
});
var selectedVehicle = null;
var editedVehicle = new Vehicle('0', '');
function VehicleClicked(vehicle, args) {
selectedVehicle = vehicle;
editedVehicle.copyDataFromVehicle(vehicle);
$.mobile.changePage( "#page_VehicleDetails", { transition: "slide"});
}
$("#page_VehicleDetails").live("pageinit", function(event, ui) {
ko.applyBindings(editedVehicle, this);
});
function Vehicle_SaveClicked(vehicle, args) {
selectedVehicle.copyDataFromVehicle(editedVehicle);
//TODO: selectedVehicle.saveToDB();
$.mobile.changePage( "#page_Vehicles", { transition: "slide"});
}
function VehicleList_ToggleEditClicked(data, args) {
data.isEditMode(!data.isEditMode());
}
function VehicleList_AddClicked(data, args) {
var newVehicle = data.addVehicle();
selectedVehicle = newVehicle;
editedVehicle.copyDataFromVehicle(newVehicle);
$.mobile.changePage( "#page_VehicleDetails", { transition: "slide"});
}
</script>
</body>
</html>