petr's patch to fix problem with htmlarea breaking clientside validation. Also using id's with same naming convention as formslib for htmlareas.

This commit is contained in:
jamiesensei
2006-12-05 13:21:40 +00:00
parent eca038b50b
commit 0befbdfd8f
5 changed files with 17 additions and 11 deletions
+3 -1
View File
@@ -634,12 +634,14 @@ HTMLArea.prototype.generate = function () {
}
// Moodle hack end.
var a = this.__msh_prevOnSubmit;
var ret = true;
// call previous submit methods if they were there.
if (typeof a != "undefined") {
for (var i = a.length; --i >= 0;) {
a[i]();
ret = a[i]() && ret;
}
}
return ret;
};
if (typeof f.onreset == "function") {
var funcref = f.onreset;
+4
View File
@@ -810,12 +810,16 @@ function validate_' . $this->_attributes['id'] . '_' . $elementName . '(element)
$element->updateAttributes(array('onBlur' => $onBlur . $valFunc,
'onChange' => $onChange . $valFunc));
}
// do not rely on frm function parameter, because htmlarea breaks it when overloading the onsubmit method
$js .= '
function validate_' . $this->_attributes['id'] . '(frm) {
if (skipClientValidation) {
return true;
}
var ret = true;
var frm = document.getElementById(\''. $this->_attributes['id'] .'\')
' . $validateJS . ';
return ret;
}
+2 -2
View File
@@ -3578,7 +3578,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
}
}
}
$str .= '<textarea class="form=textarea" id="edit-'. $name .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
$str .= '<textarea class="form=textarea" id="id_'. $name .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
if ($usehtmleditor) {
$str .= htmlspecialchars($value); // needed for editing of cleaned text!
} else {
@@ -3621,7 +3621,7 @@ function print_richedit_javascript($form, $name, $source='no') {
function use_html_editor($name='', $editorhidebuttons='') {
$editor = 'editor_'.md5($name); //name might contain illegal characters
echo '<script language="javascript" type="text/javascript" defer="defer">'."\n";
echo "$editor = new HTMLArea('edit-$name');\n";
echo "$editor = new HTMLArea('id_$name');\n";
echo "var config = $editor.config;\n";
echo print_editor_config($editorhidebuttons);
+1 -1
View File
@@ -110,7 +110,7 @@
echo '</center>';
echo "\n<script type=\"text/javascript\">\n<!--\n"; /// Focus on the textarea
echo 'document.getElementById("edit-message").focus();'."\n";
echo 'document.getElementById("id_message").focus();'."\n";
echo "\n-->\n</script>\n\n";
echo '</body></html>';
+7 -7
View File
@@ -161,7 +161,7 @@
switch ($page->qtype) {
case LESSON_MATCHING:
if ($n == 0) {
echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('correctresponse', 'lesson').":</label></b>\n";
echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('correctresponse', 'lesson').":</label></b>\n";
if ($flags & LESSON_ANSWER_EDITOR) {
echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
"<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
@@ -177,7 +177,7 @@
print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
}
} elseif ($n == 1) {
echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('wrongresponse', 'lesson').":</label></b>\n";
echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('wrongresponse', 'lesson').":</label></b>\n";
if ($flags & LESSON_ANSWER_EDITOR) {
echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
"<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
@@ -194,7 +194,7 @@
}
} else {
$ncorrected = $n - 1;
echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('answer', 'lesson')." $ncorrected:</label></b>\n";
echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('answer', 'lesson')." $ncorrected:</label></b>\n";
if ($flags & LESSON_ANSWER_EDITOR) {
echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
"<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
@@ -210,7 +210,7 @@
print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
}
echo "</td></tr>\n";
echo "<tr><td><b><label for=\"edit-response[$n]\">".get_string('matchesanswer', 'lesson')." $ncorrected:</label></b>\n";
echo "<tr><td><b><label for=\"id_response[$n]\">".get_string('matchesanswer', 'lesson')." $ncorrected:</label></b>\n";
if ($flags & LESSON_RESPONSE_EDITOR) {
echo " [<label for=\"responseeditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
"<input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" checked=\"checked\" />";
@@ -232,7 +232,7 @@
case LESSON_MULTICHOICE:
case LESSON_SHORTANSWER:
case LESSON_NUMERICAL:
echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('answer', 'lesson')." $nplus1:</label></b>\n";
echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string('answer', 'lesson')." $nplus1:</label></b>\n";
if ($flags & LESSON_ANSWER_EDITOR and $page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
"<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
@@ -253,7 +253,7 @@
}
}
echo "</td></tr>\n";
echo "<tr><td><b><label for=\"edit-response[$n]\">".get_string('response', 'lesson')." $nplus1:</label></b>\n";
echo "<tr><td><b><label for=\"id_response[$n]\">".get_string('response', 'lesson')." $nplus1:</label></b>\n";
if ($flags & LESSON_RESPONSE_EDITOR) {
echo " [<label for=\"responseeditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
"<input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" checked=\"checked\" />";
@@ -271,7 +271,7 @@
echo "</td></tr>\n";
break;
case LESSON_BRANCHTABLE:
echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string("description", "lesson")." $nplus1:</label></b>\n";
echo "<tr><td><b><label for=\"id_answer[$n]\">".get_string("description", "lesson")." $nplus1:</label></b>\n";
if ($flags & LESSON_ANSWER_EDITOR) {
echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
"<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";