www/js/profile_styles.js

changeset 522
35675eadc655
parent 494
af28ebe4a779
child 563
acdd54144838
equal deleted inserted replaced
519:c6021dd94afb 522:35675eadc655
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 23
24 function createDelElements() { 24 function createDelElements() {
25 $('#eventWindow').jqxWindow({ 25 $('#eventWindow').jqxWindow({
26 theme: theme, 26 theme: theme,
27 position: { x: 490, y: 210 }, 27 position: { x: 490, y: 210 },
28 width: 300, 28 width: 300,
29 height: 175, 29 height: 175,
30 resizable: false, 30 resizable: false,
31 isModal: true, 31 isModal: true,
32 modalOpacity: 0.4, 32 modalOpacity: 0.4,
33 okButton: $('#delOk'), 33 okButton: $('#delOk'),
34 cancelButton: $('#delCancel'), 34 cancelButton: $('#delCancel'),
35 initContent: function () { 35 initContent: function() {
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); 36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); 37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
38 $('#delCancel').focus(); 38 $('#delCancel').focus();
39 } 39 }
40 }); 40 });
41 $('#eventWindow').jqxWindow('hide'); 41 $('#eventWindow').jqxWindow('hide');
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function() {
46 46
47 var dataRecord = {}, 47 var dataRecord = {},
48 url = 'includes/db_profile_styles.php', 48 url = 'includes/db_profile_styles.php',
49 source = { 49 source = {
50 datatype: "json", 50 datatype: 'json',
51 cache: false, 51 cache: false,
52 datafields: [ 52 datafields: [
53 { name: 'record', type: 'number' }, 53 { name: 'record', type: 'number' },
54 { name: 'name', type: 'string' }, 54 { name: 'name', type: 'string' },
55 { name: 'category', type: 'string' }, 55 { name: 'category', type: 'string' },
56 { name: 'category_number', type: 'number' }, 56 { name: 'category_number', type: 'number' },
57 { name: 'style_letter', type: 'string' }, 57 { name: 'style_letter', type: 'string' },
58 { name: 'style_guide', type: 'string' }, 58 { name: 'style_guide', type: 'string' },
59 { name: 'type', type: 'int' }, 59 { name: 'type', type: 'int' },
60 { name: 'og_min', type: 'float' }, 60 { name: 'og_min', type: 'float' },
61 { name: 'og_max', type: 'float' }, 61 { name: 'og_max', type: 'float' },
62 { name: 'fg_min', type: 'float' }, 62 { name: 'fg_min', type: 'float' },
63 { name: 'fg_max', type: 'float' }, 63 { name: 'fg_max', type: 'float' },
64 { name: 'ibu_min', type: 'float' }, 64 { name: 'ibu_min', type: 'float' },
65 { name: 'ibu_max', type: 'float' }, 65 { name: 'ibu_max', type: 'float' },
66 { name: 'color_min', type: 'float' }, 66 { name: 'color_min', type: 'float' },
67 { name: 'color_max', type: 'float' }, 67 { name: 'color_max', type: 'float' },
68 { name: 'carb_min', type: 'float' }, 68 { name: 'carb_min', type: 'float' },
69 { name: 'carb_max', type: 'float' }, 69 { name: 'carb_max', type: 'float' },
70 { name: 'abv_min', type: 'float' }, 70 { name: 'abv_min', type: 'float' },
71 { name: 'abv_max', type: 'float' }, 71 { name: 'abv_max', type: 'float' },
72 { name: 'notes', type: 'string' }, 72 { name: 'notes', type: 'string' },
73 { name: 'profile', type: 'string' }, 73 { name: 'profile', type: 'string' },
74 { name: 'ingredients', type: 'string' }, 74 { name: 'ingredients', type: 'string' },
75 { name: 'examples', type: 'string' } 75 { name: 'examples', type: 'string' }
76 ], 76 ],
77 id: 'record', 77 id: 'record',
78 url: url, 78 url: url,
79 deleterow: function (rowid, commit) { 79 deleterow: function(rowid, commit) {
80 // synchronize with the server - send delete command 80 // synchronize with the server - send delete command
81 var data = "delete=true&" + $.param({ record: rowid }); 81 var data = 'delete=true&' + $.param({ record: rowid });
82 $.ajax({ 82 $.ajax({
83 dataType: 'json', 83 dataType: 'json',
84 url: url, 84 url: url,
85 cache: false, 85 cache: false,
86 data: data, 86 data: data,
87 type: "POST", 87 type: 'POST',
88 success: function (data, status, xhr) { 88 success: function(data, status, xhr) {
89 commit(true); 89 commit(true);
90 location.reload( true ); 90 location.reload(true);
91 }, 91 },
92 error: function (jqXHR, textStatus, errorThrown) { 92 error: function(jqXHR, textStatus, errorThrown) {
93 commit(false); 93 commit(false);
94 } 94 }
95 }); 95 });
96 }, 96 },
97 addrow: function (rowid, rowdata, position, commit) { 97 addrow: function(rowid, rowdata, position, commit) {
98 var data = "insert=true&" + $.param(rowdata); 98 var data = 'insert=true&' + $.param(rowdata);
99 $.ajax({ 99 $.ajax({
100 dataType: 'json', 100 dataType: 'json',
101 url: url, 101 url: url,
102 cache: false, 102 cache: false,
103 data: data, 103 data: data,
104 type: "POST", 104 type: 'POST',
105 success: function (data, status, xhr) { 105 success: function(data, status, xhr) {
106 commit(true); 106 commit(true);
107 location.reload( true ); 107 location.reload(true);
108 }, 108 },
109 error: function(jqXHR, textStatus, errorThrown) { 109 error: function(jqXHR, textStatus, errorThrown) {
110 commit(false); 110 commit(false);
111 } 111 }
112 }); 112 });
113 }, 113 },
114 updaterow: function (rowid, rowdata, commit) { 114 updaterow: function(rowid, rowdata, commit) {
115 var data = "update=true&" + $.param(rowdata); 115 var data = 'update=true&' + $.param(rowdata);
116 $.ajax({ 116 $.ajax({
117 dataType: 'json', 117 dataType: 'json',
118 url: url, 118 url: url,
119 cache: false, 119 cache: false,
120 data: data, 120 data: data,
121 type: "POST", 121 type: 'POST',
122 success: function (data, status, xhr) { 122 success: function(data, status, xhr) {
123 commit(true); 123 commit(true);
124 location.reload( true ); 124 location.reload(true);
125 }, 125 },
126 error: function(jqXHR, textStatus, errorThrown) { 126 error: function(jqXHR, textStatus, errorThrown) {
127 commit(false); 127 commit(false);
128 } 128 }
129 }); 129 });
130 } 130 }
131 }, 131 },
132 dataAdapter = new $.jqx.dataAdapter(source), 132 dataAdapter = new $.jqx.dataAdapter(source),
133 editrow = -1; 133 editrow = -1;
134 134
135 // initialize the input fields. 135 // initialize the input fields.
136 $("#name").jqxInput({ theme: theme, width: 320, height: 23 }); 136 $('#name').jqxInput({ theme: theme, width: 320, height: 23 });
137 $("#category").jqxInput({ theme: theme, width: 320, height: 23 }); 137 $('#category').jqxInput({ theme: theme, width: 320, height: 23 });
138 $("#category_number").jqxNumberInput( PosInt ); 138 $('#category_number').jqxNumberInput(PosInt);
139 $("#style_letter").jqxInput({ theme: theme, width: 250, height: 23 }); 139 $('#style_letter').jqxInput({ theme: theme, width: 250, height: 23 });
140 $("#style_guide").jqxInput({ theme: theme, width: 320, height: 23 }); 140 $('#style_guide').jqxInput({ theme: theme, width: 320, height: 23 });
141 $("#type").jqxDropDownList({ 141 $('#type').jqxDropDownList({
142 theme: theme, 142 theme: theme,
143 source: StyleTypeAdapter, 143 source: StyleTypeAdapter,
144 valueMember: 'id', 144 valueMember: 'id',
145 displayMember: 'nl', 145 displayMember: 'nl',
146 width: 180, 146 width: 180,
147 height: 23, 147 height: 23,
148 autoDropDownHeight: true 148 autoDropDownHeight: true
149 }); 149 });
150 $("#og_min").jqxNumberInput( SGopts ); 150 $('#og_min').jqxNumberInput(SGopts);
151 $("#og_max").jqxNumberInput( SGopts ); 151 $('#og_max').jqxNumberInput(SGopts);
152 $("#fg_min").jqxNumberInput( SGopts ); 152 $('#fg_min').jqxNumberInput(SGopts);
153 $("#fg_max").jqxNumberInput( SGopts ); 153 $('#fg_max').jqxNumberInput(SGopts);
154 $("#ibu_min").jqxNumberInput( PosInt ); 154 $('#ibu_min').jqxNumberInput(PosInt);
155 $("#ibu_min").jqxNumberInput({ max: 200 }); 155 $('#ibu_min').jqxNumberInput({ max: 200 });
156 $("#ibu_max").jqxNumberInput( PosInt ); 156 $('#ibu_max').jqxNumberInput(PosInt);
157 $("#ibu_max").jqxNumberInput({ max: 200 }); 157 $('#ibu_max').jqxNumberInput({ max: 200 });
158 $("#color_min").jqxNumberInput( PosInt ); 158 $('#color_min').jqxNumberInput(PosInt);
159 $("#color_min").jqxNumberInput({ max: 200 }); 159 $('#color_min').jqxNumberInput({ max: 200 });
160 $("#color_max").jqxNumberInput( PosInt ); 160 $('#color_max').jqxNumberInput(PosInt);
161 $("#color_max").jqxNumberInput({ max: 200 }); 161 $('#color_max').jqxNumberInput({ max: 200 });
162 $("#carb_min").jqxNumberInput( Spin1dec ); 162 $('#carb_min').jqxNumberInput(Spin1dec);
163 $("#carb_min").jqxNumberInput({ max: 5 }); 163 $('#carb_min').jqxNumberInput({ max: 5 });
164 $("#carb_max").jqxNumberInput( Spin1dec ); 164 $('#carb_max').jqxNumberInput(Spin1dec);
165 $("#carb_max").jqxNumberInput({ max: 5 }); 165 $('#carb_max').jqxNumberInput({ max: 5 });
166 $("#abv_min").jqxNumberInput( Spin1dec ); 166 $('#abv_min').jqxNumberInput(Spin1dec);
167 $("#abv_min").jqxNumberInput({ max: 20 }); 167 $('#abv_min').jqxNumberInput({ max: 20 });
168 $("#abv_max").jqxNumberInput( Spin1dec ); 168 $('#abv_max').jqxNumberInput(Spin1dec);
169 $("#abv_max").jqxNumberInput({ max: 20 }); 169 $('#abv_max').jqxNumberInput({ max: 20 });
170 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); 170 $('#notes').jqxInput({ theme: theme, width: 800, height: 100 });
171 $("#profile").jqxInput({ theme: theme, width: 800, height: 48 }); 171 $('#profile').jqxInput({ theme: theme, width: 800, height: 48 });
172 $("#ingredients").jqxInput({ theme: theme, width: 800, height: 23 }); 172 $('#ingredients').jqxInput({ theme: theme, width: 800, height: 23 });
173 $("#examples").jqxInput({ theme: theme, width: 800, height: 48 }); 173 $('#examples').jqxInput({ theme: theme, width: 800, height: 48 });
174 174
175 // initialize jqxGrid 175 // initialize jqxGrid
176 $("#jqxgrid").jqxGrid({ 176 $('#jqxgrid').jqxGrid({
177 width: 1280, 177 width: 1280,
178 height: 630, 178 height: 630,
179 source: dataAdapter, 179 source: dataAdapter,
180 theme: theme, 180 theme: theme,
181 showstatusbar: true, 181 showstatusbar: true,
182 renderstatusbar: function (statusbar) { 182 renderstatusbar: function(statusbar) {
183 var container, addButton, impButton; 183 var container, addButton, impButton;
184 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 184 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
185 addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>"); 185 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
186 impButton = $("<div style='float: right; margin-right: 50px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Import</span></div>"); 186 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>');
187 container.append(addButton); 187 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
188 container.append(impButton); 188 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Import</span></div>');
189 statusbar.append(container); 189 container.append(addButton);
190 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 190 container.append(impButton);
191 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); 191 statusbar.append(container);
192 // add new row. 192 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
193 addButton.click(function (event) { 193 impButton.jqxButton({ theme: theme, width: 90, height: 20 });
194 editrow = -1; 194 // add new row.
195 $("#name").val('Nieuwe stijl'); 195 addButton.click(function(event) {
196 $("#category").val(''); 196 editrow = -1;
197 $("#category_number").val(''); 197 $('#name').val('Nieuwe stijl');
198 $("#style_letter").val(''); 198 $('#category').val('');
199 $("#style_guide").val('BKG 2015'); 199 $('#category_number').val('');
200 $("#type").val(0); 200 $('#style_letter').val('');
201 $("#og_min").val(1.030); 201 $('#style_guide').val('BKG 2015');
202 $("#og_max").val(1.050); 202 $('#type').val(0);
203 $("#fg_min").val(1.005); 203 $('#og_min').val(1.030);
204 $("#fg_max").val(1.010); 204 $('#og_max').val(1.050);
205 $("#ibu_min").val(20); 205 $('#fg_min').val(1.005);
206 $("#ibu_max").val(30); 206 $('#fg_max').val(1.010);
207 $("#color_min").val(52); 207 $('#ibu_min').val(20);
208 $("#color_max").val(79); 208 $('#ibu_max').val(30);
209 $("#carb_min").val(2.0); 209 $('#color_min').val(52);
210 $("#carb_max").val(2.5); 210 $('#color_max').val(79);
211 $("#abv_min").val(4.0); 211 $('#carb_min').val(2.0);
212 $("#abv_max").val(5.0); 212 $('#carb_max').val(2.5);
213 $("#notes").val(''); 213 $('#abv_min').val(4.0);
214 $("#profile").val(''); 214 $('#abv_max').val(5.0);
215 $("#ingredients").val(''); 215 $('#notes').val('');
216 $("#examples").val(''); 216 $('#profile').val('');
217 $("#popupWindow").jqxWindow('open'); 217 $('#ingredients').val('');
218 }); 218 $('#examples').val('');
219 impButton.click(function (event) { 219 $('#popupWindow').jqxWindow('open');
220 window.location.href = 'import_ingredients.php?select=styles'; 220 });
221 }); 221 impButton.click(function(event) {
222 }, 222 window.location.href = 'import_ingredients.php?select=styles';
223 filterable: true, 223 });
224 filtermode: 'excel', 224 },
225 columns: [ 225 filterable: true,
226 { text: 'Gids', datafield: 'style_guide', width: 100 }, 226 filtermode: 'excel',
227 { text: 'Groep', datafield: 'style_letter', width: 30 }, 227 columns: [
228 { text: 'Style Name', menu: false, datafield: 'name' }, 228 { text: 'Gids', datafield: 'style_guide', width: 100 },
229 { text: 'OG', menu: false, datafield: 'og_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, 229 { text: 'Groep', datafield: 'style_letter', width: 30 },
230 { text: 'OG', menu: false, datafield: 'og_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, 230 { text: 'Style Name', menu: false, datafield: 'name' },
231 { text: 'FG', menu: false, datafield: 'fg_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, 231 { text: 'OG', menu: false, datafield: 'og_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
232 { text: 'FG', menu: false, datafield: 'fg_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, 232 { text: 'OG', menu: false, datafield: 'og_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
233 { text: 'IBU', menu: false, datafield: 'ibu_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, 233 { text: 'FG', menu: false, datafield: 'fg_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
234 { text: 'IBU', menu: false, datafield: 'ibu_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, 234 { text: 'FG', menu: false, datafield: 'fg_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
235 { text: 'EBC', menu: false, datafield: 'color_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, 235 { text: 'IBU', menu: false, datafield: 'ibu_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' },
236 { text: 'EBC', menu: false, datafield: 'color_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, 236 { text: 'IBU', menu: false, datafield: 'ibu_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' },
237 { text: 'Co2', menu: false, datafield: 'carb_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 237 { text: 'EBC', menu: false, datafield: 'color_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' },
238 { text: 'Co2', menu: false, datafield: 'carb_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 238 { text: 'EBC', menu: false, datafield: 'color_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f0' },
239 { text: 'ABV', menu: false, datafield: 'abv_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 239 { text: 'Co2', menu: false, datafield: 'carb_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
240 { text: 'ABV', menu: false, datafield: 'abv_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 240 { text: 'Co2', menu: false, datafield: 'carb_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
241 { text: '', menu: false, datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { 241 { text: 'ABV', menu: false, datafield: 'abv_min', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
242 return "Wijzig"; 242 { text: 'ABV', menu: false, datafield: 'abv_max', width: 50, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
243 }, buttonclick: function (row) { 243 { text: '', menu: false, datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function() {
244 // open the popup window when the user clicks a button. 244 return 'Wijzig';
245 editrow = row; 245 }, buttonclick: function(row) {
246 // get the clicked row's data and initialize the input fields. 246 // open the popup window when the user clicks a button.
247 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 247 editrow = row;
248 $("#name").val(dataRecord.name); 248 // get the clicked row's data and initialize the input fields.
249 $("#category").val(dataRecord.category); 249 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
250 $("#category_number").val(dataRecord.category_number); 250 $('#name').val(dataRecord.name);
251 $("#style_letter").val(dataRecord.style_letter); 251 $('#category').val(dataRecord.category);
252 $("#style_guide").val(dataRecord.style_guide); 252 $('#category_number').val(dataRecord.category_number);
253 $("#type").val(dataRecord.type); 253 $('#style_letter').val(dataRecord.style_letter);
254 $("#og_min").val(dataRecord.og_min); 254 $('#style_guide').val(dataRecord.style_guide);
255 $("#og_max").val(dataRecord.og_max); 255 $('#type').val(dataRecord.type);
256 $("#fg_min").val(dataRecord.fg_min); 256 $('#og_min').val(dataRecord.og_min);
257 $("#fg_max").val(dataRecord.fg_max); 257 $('#og_max').val(dataRecord.og_max);
258 $("#ibu_min").val(dataRecord.ibu_min); 258 $('#fg_min').val(dataRecord.fg_min);
259 $("#ibu_max").val(dataRecord.ibu_max); 259 $('#fg_max').val(dataRecord.fg_max);
260 $("#color_min").val(dataRecord.color_min); 260 $('#ibu_min').val(dataRecord.ibu_min);
261 $("#color_max").val(dataRecord.color_max); 261 $('#ibu_max').val(dataRecord.ibu_max);
262 $("#carb_min").val(dataRecord.carb_min); 262 $('#color_min').val(dataRecord.color_min);
263 $("#carb_max").val(dataRecord.carb_max); 263 $('#color_max').val(dataRecord.color_max);
264 $("#abv_min").val(dataRecord.abv_min); 264 $('#carb_min').val(dataRecord.carb_min);
265 $("#abv_max").val(dataRecord.abv_max); 265 $('#carb_max').val(dataRecord.carb_max);
266 $("#notes").val(dataRecord.notes); 266 $('#abv_min').val(dataRecord.abv_min);
267 $("#profile").val(dataRecord.profile); 267 $('#abv_max').val(dataRecord.abv_max);
268 $("#ingredients").val(dataRecord.ingredients); 268 $('#notes').val(dataRecord.notes);
269 $("#examples").val(dataRecord.examples); 269 $('#profile').val(dataRecord.profile);
270 // show the popup window. 270 $('#ingredients').val(dataRecord.ingredients);
271 $("#popupWindow").jqxWindow('open'); 271 $('#examples').val(dataRecord.examples);
272 } 272 // show the popup window.
273 } 273 $('#popupWindow').jqxWindow('open');
274 ] 274 }
275 }); 275 }
276 // initialize the popup window and buttons. 276 ]
277 $("#popupWindow").jqxWindow({ 277 });
278 width: 1050, 278 // initialize the popup window and buttons.
279 position: { x: 110, y: 30 }, 279 $('#popupWindow').jqxWindow({
280 resizable: false, 280 width: 1050,
281 theme: theme, 281 position: { x: 110, y: 30 },
282 isModal: true, 282 resizable: false,
283 autoOpen: false, 283 theme: theme,
284 cancelButton: $("#Cancel"), 284 isModal: true,
285 modalOpacity: 0.40 285 autoOpen: false,
286 }); 286 cancelButton: $('#Cancel'),
287 $("#popupWindow").on('open', function () { 287 modalOpacity: 0.40
288 $("#name").jqxInput('selectAll'); 288 });
289 }); 289 $('#popupWindow').on('open', function() {
290 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); 290 $('#name').jqxInput('selectAll');
291 $("#Delete").click(function () { 291 });
292 if (editrow >= 0) { 292 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme });
293 // Open a popup to confirm this action. 293 $('#Delete').click(function() {
294 $('#eventWindow').jqxWindow('open'); 294 if (editrow >= 0) {
295 $("#delOk").click(function () { 295 // Open a popup to confirm this action.
296 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 296 $('#eventWindow').jqxWindow('open');
297 $("#jqxgrid").jqxGrid('deleterow', rowID); 297 $('#delOk').click(function() {
298 }); 298 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
299 } 299 $('#jqxgrid').jqxGrid('deleterow', rowID);
300 $("#popupWindow").jqxWindow('hide'); 300 });
301 }); 301 }
302 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); 302 $('#popupWindow').jqxWindow('hide');
303 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 303 });
304 // update the edited row when the user clicks the 'Save' button. 304 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
305 $("#Save").click(function () { 305 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
306 var row, rowID = -1; 306 // update the edited row when the user clicks the 'Save' button.
307 if (editrow >= 0) { 307 $('#Save').click(function() {
308 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 308 var row, rowID = -1;
309 } 309 if (editrow >= 0) {
310 row = { 310 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
311 record: rowID, 311 }
312 name: $("#name").val(), 312 row = {
313 category: $("#category").val(), 313 record: rowID,
314 category_number: parseFloat($("#category_number").jqxNumberInput('decimal')), 314 name: $('#name').val(),
315 style_letter: $("#style_letter").val(), 315 category: $('#category').val(),
316 style_guide: $("#style_guide").val(), 316 category_number: parseFloat($('#category_number').jqxNumberInput('decimal')),
317 type: $("#type").val(), 317 style_letter: $('#style_letter').val(),
318 og_min: parseFloat($("#og_min").jqxNumberInput('decimal')), 318 style_guide: $('#style_guide').val(),
319 og_max: parseFloat($("#og_max").jqxNumberInput('decimal')), 319 type: $('#type').val(),
320 fg_min: parseFloat($("#fg_min").jqxNumberInput('decimal')), 320 og_min: parseFloat($('#og_min').jqxNumberInput('decimal')),
321 fg_max: parseFloat($("#fg_max").jqxNumberInput('decimal')), 321 og_max: parseFloat($('#og_max').jqxNumberInput('decimal')),
322 ibu_min: parseFloat($("#ibu_min").jqxNumberInput('decimal')), 322 fg_min: parseFloat($('#fg_min').jqxNumberInput('decimal')),
323 ibu_max: parseFloat($("#ibu_max").jqxNumberInput('decimal')), 323 fg_max: parseFloat($('#fg_max').jqxNumberInput('decimal')),
324 color_min: parseFloat($("#color_min").jqxNumberInput('decimal')), 324 ibu_min: parseFloat($('#ibu_min').jqxNumberInput('decimal')),
325 color_max: parseFloat($("#color_max").jqxNumberInput('decimal')), 325 ibu_max: parseFloat($('#ibu_max').jqxNumberInput('decimal')),
326 carb_min: parseFloat($("#carb_min").jqxNumberInput('decimal')), 326 color_min: parseFloat($('#color_min').jqxNumberInput('decimal')),
327 carb_max: parseFloat($("#carb_max").jqxNumberInput('decimal')), 327 color_max: parseFloat($('#color_max').jqxNumberInput('decimal')),
328 abv_min: parseFloat($("#abv_min").jqxNumberInput('decimal')), 328 carb_min: parseFloat($('#carb_min').jqxNumberInput('decimal')),
329 abv_max: parseFloat($("#abv_max").jqxNumberInput('decimal')), 329 carb_max: parseFloat($('#carb_max').jqxNumberInput('decimal')),
330 notes: $("#notes").val(), 330 abv_min: parseFloat($('#abv_min').jqxNumberInput('decimal')),
331 profile: $("#profile").val(), 331 abv_max: parseFloat($('#abv_max').jqxNumberInput('decimal')),
332 ingredients: $("#ingredients").val(), 332 notes: $('#notes').val(),
333 examples: $("#examples").val() 333 profile: $('#profile').val(),
334 }; 334 ingredients: $('#ingredients').val(),
335 if (editrow >= 0) { 335 examples: $('#examples').val()
336 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 336 };
337 } else { 337 if (editrow >= 0) {
338 $('#jqxgrid').jqxGrid('addrow', null, row); 338 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
339 } 339 } else {
340 $("#popupWindow").jqxWindow('hide'); 340 $('#jqxgrid').jqxGrid('addrow', null, row);
341 }); 341 }
342 createDelElements(); 342 $('#popupWindow').jqxWindow('hide');
343 });
344 createDelElements();
343 }); 345 });
344 346

mercurial