]> git.mjollnir.org Git - moodle.git/commitdiff
formslib MDL-19626 Fixed broken show/hide advanced button
authorsamhemelryk <samhemelryk>
Mon, 29 Jun 2009 01:58:11 +0000 (01:58 +0000)
committersamhemelryk <samhemelryk>
Mon, 29 Jun 2009 01:58:11 +0000 (01:58 +0000)
Updated formslib showadvanced inline JS to use new $PAGE methods
and replaced inline noscript with css handled display

lib/formslib.php
theme/standard/styles_layout.css

index 72d39f56725fb6827698f403987a38fd341a78a1..e3b9aa13956d223bdb4611683ae6bcd86c562cc2 100644 (file)
@@ -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 = '<input name="'.$elementName.'" value="'.$buttonlabel.'" type="submit" />';
+            $button_nojs = '<input name="'.$elementName.'" id="'.$elementName.(string)$advformcount.'" class="showadvancedbtn" value="'.$buttonlabel.'" type="submit" />';
 
             $buttonlabel = addslashes_js($buttonlabel);
             $showtext = addslashes_js(get_string('showadvanced', 'form'));
             $hidetext = addslashes_js(get_string('hideadvanced', 'form'));
-            $button = '<script id="' . $name . '_script" type="text/javascript">' . "
-showAdvancedInit('{$name}_script', '$elementName', '$buttonlabel', '$hidetext', '$showtext');
-" . '</script><noscript><div style="display:inline">'.$button_nojs.'</div></noscript>';  // 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);
         }
index d20b5e7628f470cb2a27c26d904f0f6a5f541bfa..80c0cf7119cbe2484830bf856c6ffb848c7d5931 100644 (file)
@@ -630,6 +630,9 @@ div.hide {
    width:100%;
    text-align:right;
 }
+.jsenabled .advancedbutton .showadvancedbtn {
+  display:none;
+}
 .mform div.fitem {
   clear: both;
   width: 100%;