r39952 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39951‎ | r39952 | r39953 >
Date:16:37, 25 August 2008
Author:yaron
Status:old
Tags:
Comment:
Added Javascript handling for 'maxlength' parameter for text areas
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc
@@ -316,8 +316,17 @@
317317 if (array_key_exists('input_type', $other_args) && $other_args['input_type'] == "textarea") {
318318 $rows = $other_args['rows'];
319319 $cols = $other_args['cols'];
 320+ if (array_key_exists('maxlength', $other_args)) {
 321+ $maxlength = $other_args['maxlength'];
 322+ // is this an unnecessary performance load? Get the substring of the
 323+ // text on every key press or release, regardless of the current length
 324+ // of the text
 325+ $js_call = " onKeyDown=\"this.value = this.value.substring(0, $maxlength);\" onKeyUp=\"this.value = this.value.substring(0, $maxlength);\"";
 326+ } else {
 327+ $js_call = "";
 328+ }
320329 $text =<<<END
321 - <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text></textarea>
 330+ <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text $js_call></textarea>
322331
323332 END;
324333 } else {
@@ -412,9 +421,18 @@
413422
414423 $rows = $other_args['rows'];
415424 $cols = $other_args['cols'];
 425+ if (array_key_exists('maxlength', $other_args)) {
 426+ $maxlength = $other_args['maxlength'];
 427+ // is this an unnecessary performance load? Get the substring of the
 428+ // text on every key press or release, regardless of the current length
 429+ // of the text
 430+ $js_call = " onKeyDown=\"this.value = this.value.substring(0, $maxlength);\" onKeyUp=\"this.value = this.value.substring(0, $maxlength);\"";
 431+ } else {
 432+ $js_call = "";
 433+ }
416434
417435 $text =<<<END
418 - <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text>$cur_value</textarea>
 436+ <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text $js_call>$cur_value</textarea>
419437 <span id="$info_id" class="errorMessage"></span>
420438
421439 END;

Status & tagging log