Commit 8dbc7357 authored by Francois Marier's avatar Francois Marier Committed by Gerrit Code Review
Browse files

Merge "Add select all/none links for view & collection checkboxes on edit access page"

parents 31436bca c3a078a1
......@@ -33,9 +33,19 @@ function pieform_element_checkboxes(Pieform $form, $element) {/*{{{*/
$value = $global[$element['name']];
}
$result = '';
if (count($element['elements']) > 1) {
$id = hsc($form->get_name() . '_' . $element['name']) . '_container';
$result .= '<a href="" onclick="pieform_element_checkboxes_update(\'' . $id . '\', true); return false;">' . get_string('All') . '</a>'
. '&nbsp;'
. ' <a href="" onclick="pieform_element_checkboxes_update(\'' . $id . '\', false); return false;">' . get_string('none') . '</a>';
}
$result .= '<div class="cl"></div>';
$element['name'] .= '[]';
$result = '';
foreach ($element['elements'] as $e) {
$checked = ($submitted && (!empty($value[$e['value']]) || in_array($e['value'], $value))) || (!$submitted && !empty($e['defaultvalue']));
$result .= '<div class="checkboxes-option"><input type="checkbox" value="' . $e['value'] . '" '
......@@ -65,3 +75,18 @@ function pieform_element_checkboxes_get_value(Pieform $form, $element) {/*{{{*/
return $values;
}/*}}}*/
function pieform_element_checkboxes_js() {/*{{{*/
return <<<EOF
function pieform_element_checkboxes_update(p, v) {
forEach(getElementsByTagAndClassName('input', 'checkboxes', p), function(e) {
e.checked = v;
});
}
EOF;
}/*}}}*/
function pieform_element_checkboxes_get_headdata() {/*{{{*/
$result = '<script type="text/javascript">' . pieform_element_checkboxes_js() . "\n</script>";
return array($result);
}/*}}}*/
......@@ -1893,7 +1893,7 @@ table.secreturls {
}
.checkboxes label {
clear: left;
display: block;
margin-right: 1em;
font-size: 1.1667em;
color: #1E6297;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment