r41493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41492‎ | r41493 | r41494 >
Date:15:43, 1 October 2008
Author:yaron
Status:old
Tags:
Comment:
Added validation for mandatory checkboxes, removed all Javascript for
form-leaving confirmation
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -735,7 +735,9 @@
736736 } else {
737737 if ($allow_multiple) {
738738 $sfgJSValidationCalls[] = "validate_multiple_mandatory_fields($sfgFieldNum)";
739 - // if it's an enum...
 739+ } elseif (($form_field->template_field->is_list && $form_field->template_field->field_type == 'enumeration' && $input_type != 'listbox') || ($input_type == 'checkboxes')) {
 740+ $sfgJSValidationCalls[] = "validate_mandatory_checkboxes('$input_id', '$info_id')";
 741+ // if it's not a radiobutton...
740742 } elseif ($input_type != 'radiobutton' && $form_field->template_field->field_type != 'enumeration') {
741743 $sfgJSValidationCalls[] = "validate_mandatory_field('$input_id', '$info_id')";
742744 }
@@ -1049,30 +1051,6 @@
10501052 $javascript_text .= SFFormUtils::validationJavascript();
10511053 $javascript_text .= SFFormUtils::instancesJavascript($using_choosers);
10521054 $javascript_text .= SFFormUtils::autocompletionJavascript();
1053 - $confirm_script =<<<END
1054 - // ask the user to confirm before leaving the page - due to
1055 - // Javascript strangeness, the question itself is hardcoded in
1056 - // English and can't be changed
1057 - function confirm_text(evt) {
1058 - // show this confirmation message only if the user didn't
1059 - // click on a form element.
1060 - // unfortunately, Internet Explorer doesn't pass in any value to
1061 - // this function, so we can't tell if it was called when a user
1062 - // hit "Save page", etc. - in the interest of not causing user
1063 - // confusion, we'll just do nothing if the browser is IE
1064 - if (typeof evt == 'undefined') {
1065 - return;
1066 - }
1067 - if (evt.target.className != "createbox") {
1068 - return "Changes to the form will not be saved.";
1069 - }
1070 - }
1071 - window.onbeforeunload = confirm_text;
1072 -
1073 -END;
1074 - global $sfgConfirmFormExit;
1075 - if ($sfgConfirmFormExit)
1076 - $javascript_text .= $confirm_script;
10771055 if ($free_text_was_included && $showFCKEditor > 0) {
10781056 $javascript_text .= SFFormUtils::mainFCKJavascript($showFCKEditor);
10791057 if ($showFCKEditor & (RTE_TOGGLE_LINK | RTE_POPUP)) {

Status & tagging log