+ Checkboxes now support being required (properly) as opposed to pretending they don't. [Bug 742] ! The default state selector should now work properly in all browsers. [Bug 742]
gruffen

gruffen commited on 2011-06-03 04:02:32
Showing 3 changed files, with 10 additions and 19 deletions.

... ...
@@ -302,7 +302,7 @@ function shd_admin_custom_save()
302 302
 	$_POST['description'] = $smcFunc['htmlspecialchars'](isset($_POST['description']) ? $_POST['description'] : '');
303 303
 	preparsecode($_POST['description']);
304 304
 	$_POST['bbc'] = isset($_POST['bbc']) && in_array($_POST['field_type'], array(CFIELD_TYPE_TEXT, CFIELD_TYPE_LARGETEXT)) ? 1 : 0;
305
-	$_POST['display_empty'] = isset($_POST['display_empty']) && $_POST['field_type'] != CFIELD_TYPE_CHECKBOX ? 1 : 0;
305
+	$_POST['display_empty'] = isset($_POST['display_empty']) ? 1 : 0;
306 306
 
307 307
 	$_POST['field_type'] == isset($_POST['field_type']) ? (int) $_POST['field_type'] : 0;
308 308
 
... ...
@@ -119,8 +119,6 @@ function template_shd_custom_field_edit()
119 119
 
120 120
 					document.getElementById("max_length_dt").style.display = ftype == ', CFIELD_TYPE_TEXT, ' || ftype == ', CFIELD_TYPE_LARGETEXT, ' ? "" : "none";
121 121
 					document.getElementById("max_length_dd").style.display = ftype == ', CFIELD_TYPE_TEXT, ' || ftype == ', CFIELD_TYPE_LARGETEXT, ' ? "" : "none";
122
-					document.getElementById("display_empty_dt").style.display = ftype != ', CFIELD_TYPE_CHECKBOX, ' ? "" : "none";
123
-					document.getElementById("display_empty_dd").style.display = ftype != ', CFIELD_TYPE_CHECKBOX, ' ? "" : "none";
124 122
 					document.getElementById("dimension_dt").style.display = ftype == ', CFIELD_TYPE_LARGETEXT, ' ? "" : "none";
125 123
 					document.getElementById("dimension_dd").style.display = ftype == ', CFIELD_TYPE_LARGETEXT, ' ? "" : "none";
126 124
 					document.getElementById("bbc_dt").style.display = ftype == ', CFIELD_TYPE_TEXT, ' || ftype == ', CFIELD_TYPE_LARGETEXT, ' ? "" : "none";
... ...
@@ -150,17 +148,10 @@ function template_shd_custom_field_edit()
150 148
 					var field_list = [', implode(',', array_keys($context['dept_fields'])), '];
151 149
 					var cbstyle = ftype != ', CFIELD_TYPE_CHECKBOX, ' ? "" : "none";
152 150
 					for (i = 0, n = field_list.length; i < n; i++)
153
-					{
154
-						if (ftype != ', CFIELD_TYPE_CHECKBOX, ')
155 151
 					{
156 152
 						document.getElementById("required_dept" + field_list[i] + "_span").style.display = "";
157 153
 						document.getElementById("required_dept" + field_list[i]).style.display = ftype == ', CFIELD_TYPE_MULTI, ' ? "none" : "";
158 154
 						document.getElementById("required_dept_multi_" + field_list[i]).style.display = ftype != ', CFIELD_TYPE_MULTI, ' ? "none" : "";
159
-						}
160
-						else
161
-						{
162
-							document.getElementById("required_dept" + field_list[i] + "_span").style.display = "none";
163
-						}
164 155
 					}';
165 156
 	}
166 157
 	echo '
... ...
@@ -190,7 +181,7 @@ function template_shd_custom_field_edit()
190 181
 				}
191 182
 				function update_default_label(defstate)
192 183
 				{
193
-					if (defstate == "on")
184
+					if (defstate)
194 185
 						document.getElementById("default_label").innerHTML = "', $txt['shd_admin_default_state_on'],'";
195 186
 					else
196 187
 						document.getElementById("default_label").innerHTML = "', $txt['shd_admin_default_state_off'],'";
... ...
@@ -374,12 +365,12 @@ function template_shd_custom_field_edit()
374 365
 									<strong>', $txt['shd_admin_custom_field_default_state'], ':</strong>
375 366
 								</dt>
376 367
 								<dd id="default_dd"', $context['field_type_value'] == CFIELD_TYPE_CHECKBOX ? '' : ' style="display: none;"', '>
377
-									<input type="checkbox" name="default_check" class="input_check"',($context['custom_field']['default_value'] == 1 ? ' checked="checked"' : ''), 'onchange="javascript:update_default_label(this.value);" />
368
+									<input type="checkbox" name="default_check" class="input_check"',($context['custom_field']['default_value'] == 1 ? ' checked="checked"' : ''), ' onclick="update_default_label(this.checked);" />
378 369
 									<span class="smalltext" id="default_label">', $txt['shd_admin_default_state_' . ($context['custom_field']['default_value'] == 1 ? 'on' : 'off')], '</span>
379 370
 								</dd>
380
-								<dt id="display_empty_dt"', $context['field_type_value'] != CFIELD_TYPE_CHECKBOX ? '' : ' style="display: none;"', '><strong>', $txt['shd_admin_custom_field_display_empty'], ':</strong><br /><span class="smalltext">', $txt['shd_admin_custom_field_display_empty_desc'], '</span></dt>
381
-								<dd id="display_empty_dd"', $context['field_type_value'] != CFIELD_TYPE_CHECKBOX ? '' : ' style="display: none;"', '>
382
-									<input type="checkbox"', (!empty($context['custom_field']['display_empty']) && $context['custom_field']['display_empty'] == 1 ? ' checked="checked"' : ''), ' name="display_empty" id="cf_display_empty"', (!empty($context['custom_field']['required']) && $context['custom_field']['required'] == 1 ? ' disabled="disabled"' : ''), '/>
371
+								<dt id="display_empty_dt"><strong>', $txt['shd_admin_custom_field_display_empty'], ':</strong><br /><span class="smalltext">', $txt['shd_admin_custom_field_display_empty_desc'], '</span></dt>
372
+								<dd id="display_empty_dd">
373
+									<input type="checkbox" class="input_check"', (!empty($context['custom_field']['display_empty']) && $context['custom_field']['display_empty'] == 1 ? ' checked="checked"' : ''), ' name="display_empty" id="cf_display_empty"', (!empty($context['custom_field']['required']) && $context['custom_field']['required'] == 1 ? ' disabled="disabled"' : ''), '/>
383 374
 								</dd>
384 375
 							</dl>
385 376
 						</div>
... ...
@@ -229,13 +229,13 @@ function template_viewticket()
229 229
 										<dt>', !empty($field['icon']) ? '<img src="' . $settings['default_images_url'] . '/simpledesk/cf/' . $field['icon'] . '" alt="" class="shd_smallicon" />' : '', ' ', $field['name'],':</dt>
230 230
 										<dd>';
231 231
 
232
-							if (empty($field['value']) && $field['display_empty'])
232
+							if ($field['type'] == CFIELD_TYPE_CHECKBOX)
233
+								echo !empty($field['value']) ? $txt['yes'] : $txt['no'];
234
+							elseif (empty($field['value']) && $field['display_empty'])
233 235
 								echo $txt['shd_ticket_empty_field'];
234 236
 							elseif (isset($field['value']))
235 237
 							{
236
-								if ($field['type'] == CFIELD_TYPE_CHECKBOX)
237
-									echo !empty($field['value']) ? $txt['yes'] : $txt['no'];
238
-								elseif ($field['type'] == CFIELD_TYPE_SELECT || $field['type'] == CFIELD_TYPE_RADIO)
238
+								if ($field['type'] == CFIELD_TYPE_SELECT || $field['type'] == CFIELD_TYPE_RADIO)
239 239
 									echo $field['options'][$field['value']];
240 240
 								elseif ($field['type'] == CFIELD_TYPE_MULTI)
241 241
 								{
242 242