From 9262d2d30fe844632ab1a17f71763fac3bb9e423 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Mon, 29 Jun 2009 01:58:11 +0000 Subject: [PATCH] formslib MDL-19626 Fixed broken show/hide advanced button Updated formslib showadvanced inline JS to use new $PAGE methods and replaced inline noscript with css handled display --- lib/formslib.php | 20 ++++++++++++++------ theme/standard/styles_layout.css | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/formslib.php b/lib/formslib.php index 72d39f5672..e3b9aa1395 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -2113,6 +2113,15 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ */ function renderHeader(&$header) { global $PAGE; + static $advformcount; + + // This ensures that if 2(+) advanced buttons are used + // that all show/hide buttons appear in the correct place + // Because of now using $PAGE->requires->js_function_call + if ($advformcount==null) { + $advformcount = 1; + } + $name = $header->getName(); $id = empty($name) ? '' : ' id="' . $name . '"'; @@ -2141,16 +2150,15 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ $PAGE->requires->yui_lib('event'); // this is tricky - the first submit button on form is "clicked" if user presses enter // we do not want to "submit" using advanced button if javascript active - $button_nojs = ''; + $button_nojs = ''; $buttonlabel = addslashes_js($buttonlabel); $showtext = addslashes_js(get_string('showadvanced', 'form')); $hidetext = addslashes_js(get_string('hideadvanced', 'form')); - $button = ''; // the extra div should fix xhtml validation - - $header_html = str_replace('{button}', $button, $header_html); + $PAGE->requires->js_function_call('showAdvancedInit', Array($elementName.(string)$advformcount, $elementName, $buttonlabel, $hidetext, $showtext)); + + $advformcount++; + $header_html = str_replace('{button}', $button_nojs, $header_html); } else { $header_html = str_replace('{button}', '', $header_html); } diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index d20b5e7628..80c0cf7119 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -630,6 +630,9 @@ div.hide { width:100%; text-align:right; } +.jsenabled .advancedbutton .showadvancedbtn { + display:none; +} .mform div.fitem { clear: both; width: 100%; -- 2.39.5