Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -272,9 +272,7 @@ |
273 | 273 | // in the form, to differentiate the inputs the form starts out |
274 | 274 | // with from any inputs added by the Javascript. |
275 | 275 | $section = str_replace( '[num]', "[{$instance_num}a]", $section ); |
276 | | - // @TODO - this replacement should be |
277 | | - // case- and spacing-insensitive |
278 | | - $section = str_replace( ' id=', ' origID=', $section ); |
| 276 | + |
279 | 277 | $text = "\t\t" . Xml::tags( 'div', |
280 | 278 | array( |
281 | 279 | // The "multipleTemplate" class is there for |
— | — | @@ -1206,15 +1204,14 @@ |
1207 | 1205 | // to 'current user', and it has no current value, set $cur_value |
1208 | 1206 | // to be the current user. |
1209 | 1207 | if ( $default_value == 'current user' && |
1210 | | - // if the date is hidden, cur_value will already be set |
1211 | | - // to the default value |
1212 | | - ( $cur_value == '' || $cur_value == 'current user' ) ) { |
1213 | | - if ( $input_type == 'text' || $input_type == '' ) { |
1214 | | - $cur_value_in_template = $wgUser->getName(); |
1215 | | - $cur_value = $cur_value_in_template; |
1216 | | - } |
| 1208 | + // if the date is hidden, cur_value will already be set |
| 1209 | + // to the default value |
| 1210 | + ( $cur_value == '' || $cur_value == 'current user' ) ) { |
| 1211 | + |
| 1212 | + $cur_value_in_template = $wgUser->getName(); |
| 1213 | + $cur_value = $cur_value_in_template; |
1217 | 1214 | } |
1218 | | - |
| 1215 | + |
1219 | 1216 | // Generate a hidden field with a placeholder value that will be replaced |
1220 | 1217 | // by the multiple-instances template output at form submission. |
1221 | 1218 | ////<input type="hidden" value="@replace_Town___mayors@" name="Town[town_mayors]" /> |
Index: trunk/extensions/SemanticForms/libs/SemanticForms.js |
— | — | @@ -309,13 +309,8 @@ |
310 | 310 | |
311 | 311 | // Display a div that would otherwise be hidden by "show on select". |
312 | 312 | function showDiv(div_id, instanceWrapperDiv) { |
313 | | - if (instanceWrapperDiv != null) { |
314 | | - instanceWrapperDiv.find('[origID=' + div_id + ']').find(".hiddenBySF").removeClass('hiddenBySF'); |
315 | | - instanceWrapperDiv.find('[origID=' + div_id + ']').show(); |
316 | | - } else { |
317 | | - jQuery('#' + div_id).find(".hiddenBySF").removeClass('hiddenBySF'); |
318 | | - jQuery('#' + div_id).show(); |
319 | | - } |
| 313 | + jQuery('[id="' + div_id + '"]', instanceWrapperDiv).find(".hiddenBySF").removeClass('hiddenBySF'); |
| 314 | + jQuery('[id="' + div_id + '"]', instanceWrapperDiv).show(); |
320 | 315 | } |
321 | 316 | |
322 | 317 | // Hide a div due to "show on select". The CSS class is there so that SF can |
— | — | @@ -328,13 +323,9 @@ |
329 | 324 | // hardcoded in English. |
330 | 325 | alert( "Warning: this form has \"show on select\" pointing to an invalid element ID (\"" + div_id + "\") - IDs in HTML cannot contain spaces." ); |
331 | 326 | } |
332 | | - if (instanceWrapperDiv != null) { |
333 | | - instanceWrapperDiv.find('[origID=' + div_id + ']').find("span, div").addClass('hiddenBySF'); |
334 | | - instanceWrapperDiv.find('[origID=' + div_id + ']').hide(); |
335 | | - } else { |
336 | | - jQuery('#' + div_id).find("span, div").addClass('hiddenBySF'); |
337 | | - jQuery('#' + div_id).hide(); |
338 | | - } |
| 327 | + |
| 328 | + jQuery('[id="' + div_id + '"]', instanceWrapperDiv).find("span, div").addClass('hiddenBySF'); |
| 329 | + jQuery('[id="' + div_id + '"]', instanceWrapperDiv).hide(); |
339 | 330 | } |
340 | 331 | |
341 | 332 | // Show this div if the current value is any of the relevant options - |
— | — | @@ -355,13 +346,9 @@ |
356 | 347 | // Used for handling 'show on select' for the 'dropdown' and 'listbox' inputs. |
357 | 348 | jQuery.fn.showIfSelected = function(partOfMultiple) { |
358 | 349 | var inputVal = this.val(); |
359 | | - if (partOfMultiple) { |
360 | | - var showOnSelectVals = sfgShowOnSelect[this.attr("origID")]; |
361 | | - var instanceWrapperDiv = this.closest(".multipleTemplateInstance"); |
362 | | - } else { |
363 | | - var showOnSelectVals = sfgShowOnSelect[this.attr("id")]; |
364 | | - var instanceWrapperDiv = null; |
365 | | - } |
| 350 | + var showOnSelectVals = sfgShowOnSelect[this.attr("id")]; |
| 351 | + var instanceWrapperDiv = null; |
| 352 | + |
366 | 353 | if ( showOnSelectVals !== undefined ) { |
367 | 354 | for ( var i = 0; i < showOnSelectVals.length; i++ ) { |
368 | 355 | var options = showOnSelectVals[i][0]; |
— | — | @@ -386,13 +373,10 @@ |
387 | 374 | // Used for handling 'show on select' for the 'checkboxes' and 'radiobutton' |
388 | 375 | // inputs. |
389 | 376 | jQuery.fn.showIfChecked = function(partOfMultiple) { |
390 | | - if (partOfMultiple) { |
391 | | - var showOnSelectVals = sfgShowOnSelect[this.attr("origID")]; |
392 | | - var instanceWrapperDiv = this.closest(".multipleTemplateInstance"); |
393 | | - } else { |
394 | | - var showOnSelectVals = sfgShowOnSelect[this.attr("id")]; |
395 | | - var instanceWrapperDiv = null; |
396 | | - } |
| 377 | + |
| 378 | + var showOnSelectVals = sfgShowOnSelect[this.attr("id")]; |
| 379 | + var instanceWrapperDiv = null; |
| 380 | + |
397 | 381 | if ( showOnSelectVals !== undefined ) { |
398 | 382 | for ( var i = 0; i < showOnSelectVals.length; i++ ) { |
399 | 383 | var options = showOnSelectVals[i][0]; |
— | — | @@ -404,13 +388,10 @@ |
405 | 389 | |
406 | 390 | // Used for handling 'show on select' for the 'checkbox' input. |
407 | 391 | jQuery.fn.showIfCheckedCheckbox = function(partOfMultiple) { |
408 | | - if (partOfMultiple) { |
409 | | - var div_id = sfgShowOnSelect[this.attr("origID")]; |
410 | | - var instanceWrapperDiv = this.closest(".multipleTemplateInstance"); |
411 | | - } else { |
412 | | - var div_id = sfgShowOnSelect[this.attr("id")]; |
413 | | - var instanceWrapperDiv = null; |
414 | | - } |
| 392 | + |
| 393 | + var div_id = sfgShowOnSelect[this.attr("id")]; |
| 394 | + var instanceWrapperDiv = null; |
| 395 | + |
415 | 396 | if (jQuery(this).is(":checked")) { |
416 | 397 | showDiv(div_id, instanceWrapperDiv); |
417 | 398 | } else { |