r75200 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75199‎ | r75200 | r75201 >
Date:16:24, 22 October 2010
Author:yaron
Status:deferred
Tags:
Comment:
Simplified Javascript - removed almost all inline Javascript; also made some other general improvements
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php
@@ -14,7 +14,7 @@
1515 * Creates an array of values that match the specified source name and type,
1616 * for use by both Javascript autocompletion and comboboxes.
1717 */
18 - static function createAutocompleteValuesArray( $source_name, $source_type ) {
 18+ static function getAutocompleteValues( $source_name, $source_type ) {
1919 $names_array = array();
2020 // the query depends on whether this is a property, category, concept
2121 // or namespace
@@ -33,22 +33,6 @@
3434 return $names_array;
3535 }
3636
37 -
38 - /**
39 - * Creates a comma-delimited string of values that match the specified
40 - * source name and type, for use by Javascript autocompletion.
41 - */
42 - static function createAutocompleteValuesString( $source_name, $source_type ) {
43 - $names_array = self::createAutocompleteValuesArray( $source_name, $source_type );
44 - // escape quotes, to avoid Javascript errors
45 - $names_array = array_map( 'addslashes', $names_array );
46 - $autocomplete_string = "['" . implode( "', '", $names_array ) . "']";
47 - // replace any newlines in the string, just to avoid breaking the Javascript
48 - $autocomplete_string = str_replace( "\n", ' ', $autocomplete_string );
49 - $autocomplete_string = str_replace( "\r", ' ', $autocomplete_string );
50 - return $autocomplete_string;
51 - }
52 -
5337 static function uploadLinkHTML( $input_id, $delimiter = null, $default_filename = null ) {
5438 global $wgOut, $sfgScriptPath, $sfgFancyBoxIncluded;
5539
@@ -69,6 +53,7 @@
7054
7155 if ( !$sfgFancyBoxIncluded ) {
7256 $sfgFancyBoxIncluded = true;
 57+ global $wgOut;
7358 $wgOut->addScriptFile( "$sfgScriptPath/libs/jquery.fancybox-1.3.1.js" );
7459 }
7560
@@ -178,7 +163,7 @@
179164 }
180165
181166 static function dropdownHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
182 - global $sfgTabIndex, $sfgFieldNum;
 167+ global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls;
183168
184169 $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
185170 if ( array_key_exists( 'class', $other_args ) )
@@ -186,20 +171,16 @@
187172 $input_id = "input_$sfgFieldNum";
188173 $info_id = "info_$sfgFieldNum";
189174 $disabled_text = ( $is_disabled ) ? "disabled" : "";
190 - $javascript_text = '';
191 - $return_js_text = '';
192175 if ( array_key_exists( 'show on select', $other_args ) ) {
193 - $javascript_text = 'onChange="';
194176 foreach ( $other_args['show on select'] as $div_id => $options ) {
195177 $options_str = implode( "', '", $options );
196 - $this_js_text = "showIfSelected('$input_id', ['$options_str'], '$div_id'); ";
197 - $javascript_text .= $this_js_text;
198 - $return_js_text .= $this_js_text . "\n";
 178+ $js_text = "showIfSelected('$input_id', ['$options_str'], '$div_id'); ";
 179+ $sfgShowOnSelectCalls[] = "$('#$input_id').change( function() { $js_text } );";
 180+ $sfgShowOnSelectCalls[] = $js_text;
199181 }
200 - $javascript_text .= '"';
201182 }
202183 $text = <<<END
203 - <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" $disabled_text $javascript_text>
 184+ <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" $disabled_text>
204185
205186 END;
206187 // add a blank value at the beginning, unless this is a mandatory field
@@ -225,7 +206,7 @@
226207 <span id="$info_id" class="errorMessage"></span>
227208
228209 END;
229 - return array( $text, $return_js_text );
 210+ return array( $text, null );
230211 }
231212
232213 /**
@@ -242,7 +223,7 @@
243224 }
244225
245226 static function listboxHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
246 - global $sfgTabIndex, $sfgFieldNum;
 227+ global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls;
247228
248229 $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
249230 if ( array_key_exists( 'class', $other_args ) )
@@ -264,26 +245,17 @@
265246 }
266247 $cur_values = self::getValuesArray( $cur_value, $delimiter );
267248
268 - $javascript_text = '';
269 - $return_js_text = '';
270 - if ( array_key_exists( 'show on select', $other_args ) ) {
271 - $javascript_text = 'onChange="';
272 - foreach ( $other_args['show on select'] as $div_id => $options ) {
273 - $options_str = implode( "', '", $options );
274 - $this_js_text = "showIfSelected('$input_id', ['$options_str'], '$div_id'); ";
275 - $javascript_text .= $this_js_text;
276 - $return_js_text .= $this_js_text . "\n";
277 - }
278 - $javascript_text .= '"';
279 - }
280 -
281249 $text = <<<END
282 - <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" multiple $size_text $disabled_text $javascript_text>
 250+ <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" multiple $size_text $disabled_text>
283251
284252 END;
285253 if ( ( $possible_values = $other_args['possible_values'] ) == null )
286254 $possible_values = array();
 255+ $enum_input_ids = array();
287256 foreach ( $possible_values as $possible_value ) {
 257+ // create array $enum_input_ids to associate values with their input IDs,
 258+ // for use in creating the 'show on select' Javascript later
 259+ $enum_input_ids[$possible_value] = $input_id;
288260 $text .= " <option value=\"$possible_value\"";
289261 if ( in_array( $possible_value, $cur_values ) ) { $text .= " selected"; }
290262 $text .= ">";
@@ -299,11 +271,32 @@
300272 <input type="hidden" name="$hidden_input_name" value="1" />
301273
302274 END;
303 - return array( $text, $return_js_text );
 275+
 276+ if ( array_key_exists( 'show on select', $other_args ) ) {
 277+ foreach ( $other_args['show on select'] as $div_id => $options ) {
 278+ $cur_input_ids = array();
 279+ foreach ( $options as $option ) {
 280+ if ( array_key_exists( $option, $enum_input_ids ) ) {
 281+ $cur_input_ids[] = $enum_input_ids[$option];
 282+ }
 283+ }
 284+ $options_str = "['" . implode( "', '", $options ) . "']";
 285+ $js_text = "showIfSelectedInListBox('$input_id', $options_str, '$div_id'); ";
 286+ $sfgShowOnSelectCalls[] = $js_text;
 287+ foreach ( $possible_values as $key => $possible_value ) {
 288+ $cur_input_id = $enum_input_ids[$possible_value];
 289+ if ( in_array( $possible_value, $options ) ) {
 290+ $sfgShowOnSelectCalls[] = "$('#$cur_input_id').click( function() { $js_text } );";
 291+ }
 292+ }
 293+ }
 294+ }
 295+
 296+ return array( $text, null );
304297 }
305298
306299 static function checkboxesHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
307 - global $sfgTabIndex, $sfgFieldNum;
 300+ global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls;
308301
309302 $checkbox_class = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
310303 $span_class = "checkboxSpan";
@@ -322,7 +315,6 @@
323316 if ( ( $possible_values = $other_args['possible_values'] ) == null )
324317 $possible_values = array();
325318 $text = "";
326 - $return_js_text = "";
327319 $enum_input_ids = array();
328320 foreach ( $possible_values as $key => $possible_value ) {
329321 // create array $enum_input_ids to associate values with their input IDs,
@@ -374,7 +366,6 @@
375367
376368 END;
377369
378 - $return_js_text = '';
379370 if ( array_key_exists( 'show on select', $other_args ) ) {
380371 foreach ( $other_args['show on select'] as $div_id => $options ) {
381372 $cur_input_ids = array();
@@ -384,35 +375,22 @@
385376 }
386377 }
387378 $options_str = "['" . implode( "', '", $cur_input_ids ) . "']";
388 - $cur_js_text = "showIfChecked($options_str, '$div_id'); ";
389 - $return_js_text .= $cur_js_text . "\n";
 379+ $js_text = "showIfChecked($options_str, '$div_id'); ";
 380+ $sfgShowOnSelectCalls[] = $js_text;
390381 foreach ( $possible_values as $key => $possible_value ) {
391382 $cur_input_id = $enum_input_ids[$possible_value];
392 - // we use addClickHandler(), instead of adding the Javascript via
393 - // onClick="", because MediaWiki's wikibits.js does its own handling
394 - // of checkboxes, which impacts their behavior in IE
395383 if ( in_array( $possible_value, $options ) ) {
396 - $return_js_text .= <<<END
397 -addClickHandler(
398 - document.getElementById('$cur_input_id'),
399 - function() { $cur_js_text }
400 -);
401 -
402 -END;
 384+ $sfgShowOnSelectCalls[] = "$('#$cur_input_id').click( function() { $js_text } );";
403385 }
404386 }
405387 }
406388 }
407389
408 - // do the replacements
409 - foreach ( $enum_input_ids as $enum_val => $input_id ) {
410 - $return_js_text = str_replace( "<<$enum_val>>", "'$input_id'", $return_js_text );
411 - }
412 - return array( $text, $return_js_text );
 390+ return array( $text, null );
413391 }
414392
415393 static function comboboxHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
416 - if ( array_key_exists( 'no autocomplete', $other_args ) &&
 394+ if ( array_key_exists( 'no autocomplete', $other_args ) &&
417395 $other_args['no autocomplete'] == true ) {
418396 unset( $other_args['autocompletion source'] );
419397 return SFFormInputs::textEntryHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
@@ -421,7 +399,9 @@
422400 if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null )
423401 return SFFormInputs::dropdownHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
424402
425 - global $sfgTabIndex, $sfgFieldNum,$wgOut, $sfgScriptPath,$wgJsMimeType, $smwgScriptPath,$smwgJqUIAutoIncluded;
 403+ global $sfgTabIndex, $sfgFieldNum, $wgOut, $sfgScriptPath, $wgJsMimeType;
 404+ global $smwgScriptPath, $smwgJqUIAutoIncluded;
 405+ global $sfgAutocompleteMappings, $sfgComboBoxInputs, $sfgAutogrowInputs;
426406
427407 $autocomplete_field_type = "";
428408 $autocompletion_source = "";
@@ -448,11 +428,9 @@
449429 $div_name = "div_" . $sfgFieldNum;
450430
451431 $options_str_key = str_replace( "'", "\'", $autocompletion_source );
452 - $javascript_text = "autocompletemappings[$sfgFieldNum] = '$options_str_key';\n";
 432+ $sfgAutocompleteMappings[$sfgFieldNum] = $options_str_key;
453433
454 - $values = array();
455 - $values = self::createAutocompleteValuesArray($autocompletion_source, $autocomplete_field_type );
456 -
 434+ $values = self::getAutocompleteValues($autocompletion_source, $autocomplete_field_type );
457435
458436 /*adding code for displaying dropdown of autocomplete values*/
459437
@@ -469,10 +447,8 @@
470448 </select>
471449 <span id="$info_id" class="errorMessage"></span>
472450 </div>
473 -<script type="text/javascript" >
474 -jQuery(function() {jQuery("#input_$sfgFieldNum").combobox();});
475 -</script>
476451 END;
 452+ $sfgComboBoxInputs[] = $sfgFieldNum;
477453 // there's no direct correspondence between the 'size=' attribute for
478454 // text inputs and the number of pixels, but multiplying by 6 seems to
479455 // be about right for the major browsers
@@ -483,7 +459,7 @@
484460 </style>
485461 END;
486462 $wgOut->addScript($combobox_css);
487 - return array( $text, $javascript_text );
 463+ return array( $text, null );
488464 }
489465
490466 static function textInputWithAutocompleteHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
@@ -497,12 +473,12 @@
498474 if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null )
499475 return SFFormInputs::dropdownHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
500476
501 - global $sfgTabIndex, $sfgFieldNum, $wgOut, $sfgScriptPath,$wgJsMimeType, $smwgScriptPath,$smwgJqUIAutoIncluded;
 477+ global $sfgTabIndex, $sfgFieldNum, $sfgScriptPath, $wgJsMimeType, $smwgScriptPath, $smwgJqUIAutoIncluded;
 478+ global $sfgAutogrowInputs, $sfgAutocompleteMappings, $sfgAutocompleteDataTypes, $sfgAutocompleteValues;
502479
503480 $className = ( $is_mandatory ) ? "autocompleteInput mandatoryField" : "autocompleteInput createboxInput";
504481 if ( array_key_exists( 'class', $other_args ) )
505482 $className .= " " . $other_args['class'];
506 - $disabled_text = ( $is_disabled ) ? "disabled" : "";
507483 if ( array_key_exists( 'autocomplete field type', $other_args ) ) {
508484 $autocomplete_field_type = $other_args['autocomplete field type'];
509485 $autocompletion_source = $other_args['autocompletion source'];
@@ -518,32 +494,37 @@
519495
520496 $rows = $other_args['rows'];
521497 $cols = $other_args['cols'];
 498+ $text = "";
 499+ if ( array_key_exists( 'autogrow', $other_args ) ) {
 500+ $sfgAutogrowInputs[] = $input_id;
 501+ $className .= ' autoGrow';
 502+ if ( ! method_exists( 'OutputPage', 'addModules' ) ) {
 503+ global $wgOut;
 504+ $wgOut->addScriptFile( "$sfgScriptPath/libs/SF_autogrow.js" );
 505+ }
 506+ }
 507+
 508+ $textarea_attrs = array(
 509+ 'tabindex' => $sfgTabIndex,
 510+ 'id' => $input_id,
 511+ 'name' => $input_name,
 512+ 'rows' => $rows,
 513+ 'cols' => $cols,
 514+ 'class' => $className,
 515+ );
 516+ if ( $is_disabled ) {
 517+ $textarea_attrs['disabled'] = 'disabled';
 518+ }
522519 if ( array_key_exists( 'maxlength', $other_args ) ) {
523520 $maxlength = $other_args['maxlength'];
524521 // is this an unnecessary performance load? Get the substring of the
525522 // text on every key press or release, regardless of the current length
526523 // of the text
527 - $js_call = " onKeyDown=\"this.value = this.value.substring(0, $maxlength);\" onKeyUp=\"this.value = this.value.substring(0, $maxlength);\"";
528 - } else {
529 - $js_call = "";
 524+ $textarea_attrs['onKeyDown'] = "this.value = this.value.substring(0, $maxlength);";
 525+ $textarea_attrs['onKeyUp'] = "this.value = this.value.substring(0, $maxlength);";
530526 }
531 - $text = "";
532 - if ( array_key_exists( 'autogrow', $other_args ) ) {
533 - $text .= <<<END
534 -<script type="text/javascript">
535 - jQuery.noConflict();
536 - jQuery(document).ready(function() {
537 - jQuery("#$input_id").autoGrow();
538 - });
539 -</script>
540 -
541 -END;
542 - $className .= ' autoGrow';
543 - }
544 -
545 - $text .= <<<END
546 - <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text $js_call></textarea>
547 -END;
 527+ $textarea_input = Xml::element('textarea', $textarea_attrs, '', false);
 528+ $text .= $textarea_input;
548529 } else {
549530 if ( array_key_exists( 'size', $other_args ) )
550531 $size = $other_args['size'];
@@ -593,14 +574,13 @@
594575 $options_str_key .= "," . $delimiter;
595576 }
596577 }
597 - $options_str_key = str_replace( "'", "\'", $options_str_key );
598 - $javascript_text = "autocompletemappings[$sfgFieldNum] = '$options_str_key';\n";
 578+ $sfgAutocompleteMappings[$sfgFieldNum] = $options_str_key;
599579 if ( array_key_exists( 'remote autocompletion', $other_args ) &&
600580 $other_args['remote autocompletion'] == true ) {
601 - $javascript_text .= "autocompletedatatypes['$options_str_key'] = '$autocomplete_field_type';\n";
 581+ $sfgAutocompleteDataTypes[$options_str_key] = $autocomplete_field_type;
602582 } elseif ( $autocompletion_source != '' ) {
603 - $autocomplete_string = self::createAutocompleteValuesString( $autocompletion_source, $autocomplete_field_type );
604 - $javascript_text .= "autocompletestrings['$options_str_key'] = $autocomplete_string;\n";
 583+ $autocomplete_values = self::getAutocompleteValues( $autocompletion_source, $autocomplete_field_type );
 584+ $sfgAutocompleteValues[$options_str_key] = $autocomplete_values;
605585 }
606586 if ( $cur_value ) {
607587 // replace various values to not break the Javascript
@@ -610,7 +590,7 @@
611591 $text .= "document.getElementById('$input_id').value = \"$cur_value\"\n";
612592 }
613593 $text .= '/* ]]> */</script>';
614 - return array( $text, $javascript_text );
 594+ return array( $text, null );
615595 }
616596
617597 static function textAreaHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
@@ -627,7 +607,7 @@
628608 return SFFormInputs::textInputWithAutocompleteHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
629609 }
630610
631 - global $sfgTabIndex, $sfgFieldNum, $smwgScriptPath, $sfgScriptPath,$wgOut;
 611+ global $sfgTabIndex, $sfgFieldNum, $smwgScriptPath, $sfgScriptPath, $sfgAutogrowInputs;
632612
633613 $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
634614 if ( array_key_exists( 'class', $other_args ) )
@@ -635,39 +615,43 @@
636616 $info_id = "info_$sfgFieldNum";
637617 // use a special ID for the free text field, for FCK's needs
638618 $input_id = $input_name == "free_text" ? "free_text" : "input_$sfgFieldNum";
639 - $disabled_text = ( $is_disabled ) ? "disabled" : "";
640619
641620 $rows = $other_args['rows'];
642621 $cols = $other_args['cols'];
643 - if ( array_key_exists( 'maxlength', $other_args ) ) {
644 - $maxlength = $other_args['maxlength'];
645 - // is this an unnecessary performance load? Get the substring of the
646 - // text on every key press or release, regardless of the current length
647 - // of the text
648 - $js_call = " onKeyDown=\"this.value = this.value.substring(0, $maxlength);\" onKeyUp=\"this.value = this.value.substring(0, $maxlength);\"";
649 - } else {
650 - $js_call = "";
651 - }
652622
653623 $cur_value = htmlspecialchars( $cur_value );
654624 $text = "";
655625 if ( array_key_exists( 'autogrow', $other_args ) ) {
656 - $wgOut->addScriptFile( "$sfgScriptPath/libs/SF_autogrow.js" );
657 - $text .= <<<END
658 -<script type="text/javascript">
659 - jQuery.noConflict();
660 - jQuery(document).ready(function(){
661 - jQuery("#$input_id").autoGrow();
662 - });
663 -</script>
664 -
665 -END;
 626+ $sfgAutogrowInputs[] = $input_id;
666627 $className .= ' autoGrow';
 628+ if ( ! method_exists( 'OutputPage', 'addModules' ) ) {
 629+ global $wgOut;
 630+ $wgOut->addScriptFile( "$sfgScriptPath/libs/SF_autogrow.js" );
 631+ }
667632 }
668633
 634+ $textarea_attrs = array(
 635+ 'tabindex' => $sfgTabIndex,
 636+ 'id' => $input_id,
 637+ 'name' => $input_name,
 638+ 'rows' => $rows,
 639+ 'cols' => $cols,
 640+ 'class' => $className,
 641+ );
 642+ if ( $is_disabled ) {
 643+ $textarea_attrs['disabled'] = 'disabled';
 644+ }
 645+ if ( array_key_exists( 'maxlength', $other_args ) ) {
 646+ $maxlength = $other_args['maxlength'];
 647+ // is this an unnecessary performance load? Get the substring of the
 648+ // text on every key press or release, regardless of the current length
 649+ // of the text
 650+ $textarea_attrs['onKeyDown'] = "this.value = this.value.substring(0, $maxlength);";
 651+ $textarea_attrs['onKeyUp'] = "this.value = this.value.substring(0, $maxlength);";
 652+ }
 653+ $textarea_input = Xml::element( 'textarea', $textarea_attrs, '', false );
669654 $text .= <<<END
670 -
671 - <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text $js_call>$cur_value</textarea>
 655+ $textarea_input
672656 <span id="$info_id" class="errorMessage"></span>
673657
674658 END;
@@ -808,11 +792,11 @@
809793 $text .= ' <input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[timezone]" type="text" value="' . $timezone . '" size="2"/ ' . $disabled_text . '>' . "\n";
810794 }
811795
812 - return array( $text, $javascript_text );
 796+ return array( $text, null );
813797 }
814798
815799 static function radioButtonHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
816 - global $sfgTabIndex, $sfgFieldNum;
 800+ global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelectCalls;
817801
818802 $span_class = "checkboxSpan";
819803 if ( array_key_exists( 'class', $other_args ) )
@@ -905,7 +889,6 @@
906890 END;
907891
908892 // Finally, we do the 'show on select' handling.
909 - $return_js_text = '';
910893 if ( array_key_exists( 'show on select', $other_args ) ) {
911894 foreach ( $other_args['show on select'] as $div_id => $options ) {
912895 $cur_input_ids = array();
@@ -919,32 +902,23 @@
920903 continue;
921904 }
922905 $options_str = "['" . implode( "', '", $cur_input_ids ) . "']";
923 - $cur_js_text = "showIfChecked($options_str, '$div_id'); ";
924 - $return_js_text .= $cur_js_text . "\n";
 906+ $js_text = "showIfChecked($options_str, '$div_id');";
 907+ $sfgShowOnSelectCalls[] = $js_text;
925908 foreach ( $possible_values as $key => $possible_value ) {
926909 // We need to add each click handler to each radiobutton,
927910 // because there doesn't seem to be any way for a radiobutton
928911 // to know that it was unchecked - rather, the newly-checked
929912 // radiobutton has to handle the change.
930913 foreach ( $enum_input_ids as $cur_input_id ) {
931 - // we use addClickHandler(), instead of adding the Javascript via
932 - // onClick="", because MediaWiki's wikibits.js does its own handling
933 - // of checkboxes, which impacts their behavior in IE
934914 if ( in_array( $possible_value, $options ) ) {
935 - $return_js_text .= <<<END
936 -addClickHandler(
937 - document.getElementById('$cur_input_id'),
938 - function() { $cur_js_text }
939 -);
940 -
941 -END;
 915+ $sfgShowOnSelectCalls[] = "$('#$cur_input_id').click( function() { $js_text } );";
942916 }
943917 }
944918 }
945919 }
946920 }
947921
948 - return array( $text, $return_js_text );
 922+ return array( $text, null );
949923 }
950924
951925 static function checkboxHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
@@ -956,21 +930,10 @@
957931 $info_id = "info_$sfgFieldNum";
958932 $input_id = "input_$sfgFieldNum";
959933 $disabled_text = ( $is_disabled ) ? "disabled" : "";
960 - $return_js_text = '';
961934 if ( array_key_exists( 'show on select', $other_args ) ) {
962935 $div_id = key( $other_args['show on select'] );
963 - $this_js_text = "showIfChecked(['$input_id'], '$div_id');";
964 - // we use addClickHandler(), instead of adding the Javascript via
965 - // onClick="", because MediaWiki's wikibits.js does its own handling
966 - // of checkboxes, which impacts their behavior in IE
967 - $return_js_text = <<<END
968 -$this_js_text;
969 -addClickHandler(
970 - document.getElementById("$input_id"),
971 - function() { $this_js_text }
972 -);
973 -
974 -END;
 936+ $js_text = "showIfChecked(['$input_id'], '$div_id');";
 937+ $sfgShowOnSelectCalls[] = "$('#$input_id').click( function() { $js_text } );";
975938 }
976939
977940 // can show up here either as an array or a string, depending on
@@ -994,7 +957,7 @@
995958 <span id="$info_id" class="errorMessage"></span>
996959
997960 END;
998 - return array( $text, $return_js_text );
 961+ return array( $text, null );
999962 }
1000963
1001964 static function categoryHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r75356Oops - fixed major bug in r75200 - regular textareas had their contents blankedyaron15:30, 25 October 2010

Status & tagging log