- Patch #1162802 by Liam Morland: Asterisk * used for required or changed marker should be in abbr not span.

8.0.x
Dries Buytaert 2011-07-05 09:44:58 -04:00
parent bfaf647099
commit 624ef8b4e3
8 changed files with 18 additions and 15 deletions

View File

@ -3916,7 +3916,7 @@ function theme_form_required_marker($variables) {
'class' => 'form-required',
'title' => $t('This field is required.'),
);
return '<span' . drupal_attributes($attributes) . '>*</span>';
return '<abbr' . drupal_attributes($attributes) . '>*</abbr>';
}
/**

View File

@ -202,16 +202,16 @@ Drupal.ajax = function (base, element, element_settings) {
* will test to see if the key press is valid to trigger this event and
* if it is, trigger it for us and prevent other keypresses from triggering.
* In this case we're handling RETURN and SPACEBAR keypresses (event codes 13
* and 32. RETURN is often used to submit a form when in a textfield, and
* SPACE is often used to activate an element without submitting.
* and 32. RETURN is often used to submit a form when in a textfield, and
* SPACE is often used to activate an element without submitting.
*/
Drupal.ajax.prototype.keypressResponse = function (element, event) {
// Create a synonym for this to reduce code confusion.
var ajax = this;
// Detect enter key and space bar and allow the standard response for them,
// except for form elements of type 'text' and 'textarea', where the
// spacebar activation causes inappropriate activation if #ajax['keypress'] is
// except for form elements of type 'text' and 'textarea', where the
// spacebar activation causes inappropriate activation if #ajax['keypress'] is
// TRUE. On a text-type widget a space should always be a space.
if (event.which == 13 || (event.which == 32 && element.type != 'text' && element.type != 'textarea')) {
$(ajax.element_settings.element).trigger(ajax.element_settings.event);
@ -559,7 +559,7 @@ Drupal.ajax.prototype.commands = {
if (!$(response.selector).hasClass('ajax-changed')) {
$(response.selector).addClass('ajax-changed');
if (response.asterisk) {
$(response.selector).find(response.asterisk).append(' <span class="ajax-changed">*</span> ');
$(response.selector).find(response.asterisk).append(' <abbr class="ajax-changed" title="' + Drupal.t('Changed') + '">*</abbr> ');
}
}
},

View File

@ -363,7 +363,7 @@ states.State.prototype = {
$(document).bind('state:required', function(e) {
if (e.trigger) {
if (e.value) {
$(e.target).closest('.form-item, .form-wrapper').find('label').append('<span class="form-required">*</span>');
$(e.target).closest('.form-item, .form-wrapper').find('label').append('<abbr class="form-required" title="' + Drupal.t('This field is required.') + '">*</abbr>');
}
else {
$(e.target).closest('.form-item, .form-wrapper').find('label .form-required').remove();

View File

@ -1141,7 +1141,7 @@ Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
Drupal.tableDrag.prototype.row.prototype.markChanged = function () {
var marker = Drupal.theme('tableDragChangedMarker');
var cell = $('td:first', this.element);
if ($('span.tabledrag-changed', cell).length == 0) {
if ($('abbr.tabledrag-changed', cell).length == 0) {
cell.append(marker);
}
};
@ -1161,7 +1161,7 @@ Drupal.tableDrag.prototype.row.prototype.onSwap = function (swappedRow) {
};
Drupal.theme.prototype.tableDragChangedMarker = function () {
return '<span class="warning tabledrag-changed">*</span>';
return '<abbr class="warning tabledrag-changed" title="' + Drupal.t('Changed') + '">*</abbr>';
};
Drupal.theme.prototype.tableDragIndentation = function () {

View File

@ -250,7 +250,7 @@ function theme_field_multiple_value_form($variables) {
if ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
$table_id = drupal_html_id($element['#field_name'] . '_values');
$order_class = $element['#field_name'] . '-delta-order';
$required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required. ') . '">*</span>' : '';
$required = !empty($element['#required']) ? '<abbr class="form-required" title="' . t('This field is required. ') . '">*</abbr>' : '';
$header = array(
array(

View File

@ -65,7 +65,7 @@ class FormsTestCase extends DrupalWebTestCase {
$elements['file']['empty_values'] = $empty_strings;
// Regular expression to find the expected marker on required elements.
$required_marker_preg = '@<label.*<span class="form-required" title="This field is required\.">\*</span></label>@';
$required_marker_preg = '@<label.*<abbr class="form-required" title="This field is required\.">\*</abbr></label>@';
// Go through all the elements and all the empty values for them.
foreach ($elements as $type => $data) {
@ -598,16 +598,16 @@ class FormsElementsLabelsTestCase extends DrupalWebTestCase {
// Exercise various defaults for textboxes and modifications to ensure
// appropriate override and correct behaviour.
$elements = $this->xpath('//label[@for="edit-form-textfield-test-title-and-required"]/child::span[@class="form-required"]/parent::*/following-sibling::input[@id="edit-form-textfield-test-title-and-required"]');
$elements = $this->xpath('//label[@for="edit-form-textfield-test-title-and-required"]/child::abbr[@class="form-required"]/parent::*/following-sibling::input[@id="edit-form-textfield-test-title-and-required"]');
$this->assertTrue(isset($elements[0]), t("Label preceeds textfield, with required marker inside label."));
$elements = $this->xpath('//input[@id="edit-form-textfield-test-no-title-required"]/preceding-sibling::label[@for="edit-form-textfield-test-no-title-required"]/span[@class="form-required"]');
$elements = $this->xpath('//input[@id="edit-form-textfield-test-no-title-required"]/preceding-sibling::label[@for="edit-form-textfield-test-no-title-required"]/abbr[@class="form-required"]');
$this->assertTrue(isset($elements[0]), t("Label tag with required marker preceeds required textfield with no title."));
$elements = $this->xpath('//input[@id="edit-form-textfield-test-title-invisible"]/preceding-sibling::label[@for="edit-form-textfield-test-title-invisible" and @class="element-invisible"]');
$this->assertTrue(isset($elements[0]), t("Label preceeding field and label class is element-invisible."));
$elements = $this->xpath('//input[@id="edit-form-textfield-test-title"]/preceding-sibling::span[@class="form-required"]');
$elements = $this->xpath('//input[@id="edit-form-textfield-test-title"]/preceding-sibling::abbr[@class="form-required"]');
$this->assertFalse(isset($elements[0]), t("No required marker on non-required field."));
$elements = $this->xpath('//input[@id="edit-form-textfield-test-title-after"]/following-sibling::label[@for="edit-form-textfield-test-title-after" and @class="option"]');

View File

@ -104,6 +104,9 @@ input.form-radio {
.form-required {
color: #f00;
}
abbr.form-required, abbr.tabledrag-changed, abbr.ajax-changed {
border-bottom: none;
}
.form-item input.error,
.form-item textarea.error,
.form-item select.error {

View File

@ -264,7 +264,7 @@ tr:first-child td.category {
border-top-width: 0;
}
span.form-required {
abbr.form-required {
color: #ffae00;
}