mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
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
This commit is contained in:
parent
a36a2bc8e5
commit
9262d2d30f
@ -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);
|
||||
}
|
||||
|
@ -630,6 +630,9 @@ div.hide {
|
||||
width:100%;
|
||||
text-align:right;
|
||||
}
|
||||
.jsenabled .advancedbutton .showadvancedbtn {
|
||||
display:none;
|
||||
}
|
||||
.mform div.fitem {
|
||||
clear: both;
|
||||
width: 100%;
|
||||
|
Loading…
x
Reference in New Issue
Block a user