Commit 7c62675a authored by Jono Mingard's avatar Jono Mingard
Browse files

Use labels in 'files' pieforms element (Bug #1277290)



Added hidden labels to each file input and changed the [+] button to use
the standard add icon with accessible alt text.

Change-Id: I526cc39e7a62814bbb34cd0203089cc726dc69e0
Signed-off-by: default avatarJono Mingard <jonom@catalyst.net.nz>
parent 82926646
......@@ -31,6 +31,8 @@ $string['element.expiry.months'] = 'Months';
$string['element.expiry.years'] = 'Years';
$string['element.expiry.noenddate'] = 'No end date';
$string['element.files.addattachment'] = 'Add attachment';
$string['element.select.other'] = 'Other';
$string['element.color.or'] = 'or';
......
......@@ -31,6 +31,8 @@ function pieform_element_files(Pieform $form, $element) {
}
$smarty->assign('name', $form->get_name() . '_' . $element['name']);
$smarty->assign('title', $element['title']);
$smarty->assign('addattachment', $form->i18n('element', 'files', 'addattachment', $element));
if (isset($element['maxfilesize']) && is_int($element['maxfilesize'])){
$smarty->assign('maxfilesize', $element['maxfilesize']);
......
......@@ -734,6 +734,11 @@ input.calendar.required {
#mce_fullscreen_container .mceEditor {
display: block;
}
/* files */
a.btn-addfile {
display: inline-block;
margin-top: 5px;
}
/******************** Buttons ********************/
/* Default buttons */
/* default state */
......
......@@ -5,8 +5,10 @@
function {{$name}}_new() {
{{$name}}_current++;
{{$name}}_newrefinput = INPUT({'type': 'file', 'name': '{{$name}}_files_' + {{$name}}_current});
var {{$name}}_newref = DIV(null,{{$name}}_newrefinput);
var id = '{{$name}}_files_' + {{$name}}_current;
{{$name}}_newlabel = LABEL({'for': id, 'class': 'accessible-hidden'}, $('{{$name}}_files_label').innerHTML);
{{$name}}_newrefinput = INPUT({'type': 'file', 'id': id, 'name': id});
var {{$name}}_newref = DIV(null,{{$name}}_newlabel, {{$name}}_newrefinput);
appendChildNodes('{{$name}}_list', {{$name}}_newref);
......@@ -17,6 +19,9 @@
{{if $maxfilesize}}
<input type="hidden" name="MAX_FILE_SIZE" value="{{$maxfilesize}}">
{{/if}}
<input type="file" name="{{$name}}_files_0">
<label id="{{$name}}_files_label" class="accessible-hidden" for="{{$name}}_files_0">{{$title}}</label>
<input type="file" id="{{$name}}_files_0" name="{{$name}}_files_0">
</div>
<a href="" onclick="{{$name}}_new(); return false;">[+]</a>
<a class="btn-addfile" href="" onclick="{{$name}}_new(); return false;">
<img src="{{theme_url images/btn_add.png}}" alt="{{str tag=element.files.addattachment section=pieforms}}">
</a>
Supports Markdown
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