Commit 9a7a4c20 authored by alexpott's avatar alexpott

Issue #2473955 by Cottser: Prefix form-wrapper classes with js-

parent 0f88b173
......@@ -54,9 +54,9 @@ public function getInfo() {
public static function preRenderDetails($element) {
Element::setAttributes($element, array('id'));
// The .form-wrapper class is required for #states to treat details like
// The .js-form-wrapper class is required for #states to treat details like
// containers.
static::setAttributes($element, array('form-wrapper'));
static::setAttributes($element, array('js-form-wrapper', 'form-wrapper'));
// Collapsible details.
$element['#attached']['library'][] = 'core/drupal.collapse';
......
......@@ -596,7 +596,7 @@
if (e.trigger) {
$(e.target)
.prop('disabled', e.value)
.closest('.form-item, .js-form-submit, .form-wrapper').toggleClass('form-disabled', e.value)
.closest('.form-item, .js-form-submit, .js-form-wrapper').toggleClass('form-disabled', e.value)
.find('select, input, textarea').prop('disabled', e.value);
// Note: WebKit nightlies don't reflect that change correctly.
......@@ -607,21 +607,21 @@
$(document).on('state:required', function (e) {
if (e.trigger) {
if (e.value) {
var $label = $(e.target).attr({'required': 'required', 'aria-required': 'aria-required'}).closest('.form-item, .form-wrapper').find('label');
var $label = $(e.target).attr({'required': 'required', 'aria-required': 'aria-required'}).closest('.form-item, .js-form-wrapper').find('label');
// Avoids duplicate required markers on initialization.
if (!$label.hasClass('form-required').length) {
$label.addClass('form-required');
}
}
else {
$(e.target).removeAttr('required aria-required').closest('.form-item, .form-wrapper').find('label.form-required').removeClass('form-required');
$(e.target).removeAttr('required aria-required').closest('.form-item, .js-form-wrapper').find('label.form-required').removeClass('form-required');
}
}
});
$(document).on('state:visible', function (e) {
if (e.trigger) {
$(e.target).closest('.form-item, .js-form-submit, .form-wrapper').toggle(e.value);
$(e.target).closest('.form-item, .js-form-submit, .js-form-wrapper').toggle(e.value);
}
});
......
......@@ -17,4 +17,10 @@
* @ingroup themeable
*/
#}
<div{{ attributes.addClass(has_parent ? 'form-wrapper') }}>{{ children }}</div>
{%
set classes = [
has_parent ? 'js-form-wrapper',
has_parent ? 'form-wrapper',
]
%}
<div{{ attributes.addClass(classes) }}>{{ children }}</div>
......@@ -22,7 +22,14 @@
* @ingroup themeable
*/
#}
<fieldset{{ attributes.addClass('form-item', 'form-wrapper') }}>
{%
set classes = [
'form-item',
'js-form-wrapper',
'form-wrapper',
]
%}
<fieldset{{ attributes.addClass(classes) }}>
{%
set legend_span_classes = [
'fieldset-legend',
......
......@@ -71,7 +71,7 @@ public function testViewElement() {
// Test a form.
$this->drupalGet('views_test_data_element_form');
$xpath = $this->xpath('//div[@class="views-element-container form-wrapper"]');
$xpath = $this->xpath('//div[@class="views-element-container js-form-wrapper form-wrapper"]');
$this->assertTrue($xpath, 'The view container has been found on the form.');
$xpath = $this->xpath('//div[@class="view-content"]');
......@@ -138,7 +138,7 @@ public function testViewElementEmbed() {
// Test a form.
$this->drupalGet('views_test_data_element_embed_form');
$xpath = $this->xpath('//div[@class="views-element-container form-wrapper"]');
$xpath = $this->xpath('//div[@class="views-element-container js-form-wrapper form-wrapper"]');
$this->assertTrue($xpath, 'The view container has been found on the form.');
$xpath = $this->xpath('//div[@class="view-content"]');
......
......@@ -15,4 +15,10 @@
* @see template_preprocess_container()
*/
#}
<div{{ attributes.addClass(has_parent ? 'form-wrapper') }}>{{ children }}</div>
{%
set classes = [
has_parent ? 'js-form-wrapper',
has_parent ? 'form-wrapper',
]
%}
<div{{ attributes.addClass(classes) }}>{{ children }}</div>
......@@ -20,7 +20,14 @@
* @see template_preprocess_fieldset()
*/
#}
<fieldset{{ attributes.addClass('form-item', 'form-wrapper') }}>
{%
set classes = [
'form-item',
'js-form-wrapper',
'form-wrapper',
]
%}
<fieldset{{ attributes.addClass(classes) }}>
{%
set legend_span_classes = [
'fieldset-legend',
......
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