a11y: add filename to remove file icon title (#40878)
gitea/wcs/pipeline/head This commit looks good Details

This commit is contained in:
Frédéric Péters 2023-04-05 19:52:29 +02:00
parent db8d4dd99a
commit 08b598bc0f
2 changed files with 7 additions and 4 deletions

View File

@ -376,12 +376,15 @@ $.WcsFileUpload = {
return;
}
$(base_widget).find('.fileprogress').hide();
var base_file_name = data.result[0].name;
if (data.result[0].url) {
$(base_widget).find('.filename').empty().append(
$('<a>', {href: data.result[0].url, download: data.result[0].name, text: data.result[0].name}));
$('<a>', {href: data.result[0].url, download: base_file_name, text: base_file_name}));
} else {
$(base_widget).find('.filename').text(data.result[0].name);
$(base_widget).find('.filename').text(base_file_name);
}
var $remove_button = $(base_widget).find('a.remove');
$remove_button.attr('title', $remove_button[0].dataset.titlePrefix + ' ' + base_file_name);
$(base_widget).find('.fileinfo').show();
$(base_widget).find('input[type=text]').val(data.result[0].token);
$(base_widget).parents('form').find('div.buttons button').prop('disabled', false);
@ -390,7 +393,7 @@ $.WcsFileUpload = {
$(base_widget).addClass('has-file').removeClass('has-no-file');
$(this).trigger('change');
$(base_widget).find('input[type=text]').trigger('change');
$(base_widget).find('a.remove').focus();
$remove_button.find('a.remove').focus();
},
fail: function(e, data) {
$(base_widget).find('.fileprogress').addClass('upload-error');

View File

@ -28,7 +28,7 @@
download="{{widget.tempfile.base_filename}}"
>{{ widget.tempfile.base_filename }}</a>{% elif widget.tempfile %}{{ widget.tempfile.base_filename }}{% endif %}</p>
{% if not widget.readonly %}
<a href="#" role="button" class="remove" title="{% trans 'Remove this file' %}">{% trans "remove" %}</a>
<a href="#" role="button" class="remove" data-title-prefix="{% trans "Remove the file:" %}" title="{% trans 'Remove the file:' %} {{ widget.tempfile.base_filename }}">{% trans "remove" %}</a>
{% elif widget.has_tempfile_image %}
<img alt="" src="tempfile?t={{ widget.tempfile.token }}&thumbnail=1"/>
{% endif %}