Commit b9ae4cd1 authored by alexpott's avatar alexpott

Issue #2473947 by Cottser, davidhernandez, rachel_norfolk, rteijeiro, cilefen,...

Issue #2473947 by Cottser, davidhernandez, rachel_norfolk, rteijeiro, cilefen, alimac, akalata, YesCT, mortendk: Prefix form-item-* classes with js-
parent d271293c
......@@ -23,14 +23,13 @@
var $context = $(context);
$context.find('.block-content-form-revision-information').drupalSetSummary(function (context) {
var $revisionContext = $(context);
var revisionCheckbox = $revisionContext.find('.form-item-revision input');
// Return 'New revision' if the 'Create new revision' checkbox is
// checked, or if the checkbox doesn't exist, but the revision log does.
// For users without the "Administer content" permission the checkbox
// won't appear, but the revision log will if the content type is set
// to auto-revision.
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.form-item-revision-log textarea').length)) {
var revisionCheckbox = $revisionContext.find('.js-form-item-revision input');
// Return 'New revision' if the 'Create new revision' checkbox is checked,
// or if the checkbox doesn't exist, but the revision log does. For users
// without the "Administer content" permission the checkbox won't appear,
// but the revision log will if the content type is set to auto-revision.
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length)) {
return Drupal.t('New revision');
}
......@@ -40,13 +39,13 @@
$context.find('fieldset.block-content-translation-options').drupalSetSummary(function (context) {
var $translationContext = $(context);
var translate;
var $checkbox = $translationContext.find('.form-item-translation-translate input');
var $checkbox = $translationContext.find('.js-form-item-translation-translate input');
if ($checkbox.size()) {
translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
}
else {
$checkbox = $translationContext.find('.form-item-translation-retranslate input');
$checkbox = $translationContext.find('.js-form-item-translation-retranslate input');
translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated');
}
......
......@@ -25,9 +25,9 @@
var $configurationForm = $(context).find('.ckeditor-toolbar-configuration').once('ckeditor-configuration');
if ($configurationForm.length) {
var $textarea = $configurationForm
// Hide the textarea that contains the serialized representation of
// the CKEditor configuration.
.find('.form-item-editor-settings-toolbar-button-groups')
// Hide the textarea that contains the serialized representation of the
// CKEditor configuration.
.find('.js-form-item-editor-settings-toolbar-button-groups')
.hide()
// Return the textarea child node from this expression.
.find('textarea');
......
......@@ -15,7 +15,7 @@
attach: function (context) {
var $context = $(context);
$context.find('fieldset.comment-entity-settings-form').drupalSetSummary(function (context) {
return Drupal.checkPlain($(context).find('.form-item-comment input:checked').next('label').text());
return Drupal.checkPlain($(context).find('.js-form-item-comment input:checked').next('label').text());
});
}
};
......
......@@ -23,9 +23,9 @@
// submitted at the same time. The actual validation will happen
// server-side.
$form.find(
'.form-item-label label,' +
'.form-item-field-name label,' +
'.form-item-existing-storage-label label')
'.js-form-item-label label,' +
'.js-form-item-field-name label,' +
'.js-form-item-existing-storage-label label')
.addClass('js-form-required form-required');
var $newFieldType = $form.find('select[name="new_storage_type"]');
......
......@@ -34,7 +34,7 @@ tips:
body: '<p>You can change the default language of the site by choosing one of your configured languages as default. The site will use the default language in situations where no choice is made but a language should be set, for example as the language of the displayed interface.</p>'
weight: 4
attributes:
data-class: form-item-site-default-language
data-class: js-form-item-site-default-language
language-operations:
id: language-operations
plugin: text
......
......@@ -19,8 +19,8 @@
attach: function (context) {
$(context).find('.menu-link-form').drupalSetSummary(function (context) {
var $context = $(context);
if ($context.find('.form-item-menu-enabled input').is(':checked')) {
return Drupal.checkPlain($context.find('.form-item-menu-title input').val());
if ($context.find('.js-form-item-menu-enabled input').is(':checked')) {
return Drupal.checkPlain($context.find('.js-form-item-menu-title input').val());
}
else {
return Drupal.t('Not in menu');
......@@ -46,9 +46,9 @@
// Try to find menu settings widget elements as well as a 'title' field
// in the form, but play nicely with user permissions and form
// alterations.
var $checkbox = $this.find('.form-item-menu-enabled input');
var $link_title = $context.find('.form-item-menu-title input');
var $title = $this.closest('form').find('.form-item-title-0-value input');
var $checkbox = $this.find('.js-form-item-menu-enabled input');
var $link_title = $context.find('.js-form-item-menu-title input');
var $title = $this.closest('form').find('.js-form-item-title-0-value input');
// Bail out if we do not have all required fields.
if (!($checkbox.length && $link_title.length && $title.length)) {
return;
......
......@@ -37,7 +37,7 @@
$('#edit-language', context).drupalSetSummary(function (context) {
var vals = [];
vals.push($(".form-item-language-configuration-langcode select option:selected", context).text());
vals.push($(".js-form-item-language-configuration-langcode select option:selected", context).text());
$('input:checked', context).next('label').each(function () {
vals.push(Drupal.checkPlain($(this).text()));
......
......@@ -20,14 +20,14 @@
var $context = $(context);
$context.find('.node-form-revision-information').drupalSetSummary(function (context) {
var $revisionContext = $(context);
var revisionCheckbox = $revisionContext.find('.form-item-revision input');
var revisionCheckbox = $revisionContext.find('.js-form-item-revision input');
// Return 'New revision' if the 'Create new revision' checkbox is
// checked, or if the checkbox doesn't exist, but the revision log does.
// For users without the "Administer content" permission the checkbox
// won't appear, but the revision log will if the content type is set to
// auto-revision.
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.form-item-revision-log textarea').length)) {
// Return 'New revision' if the 'Create new revision' checkbox is
// checked, or if the checkbox doesn't exist, but the revision log does.
// For users without the "Administer content" permission the checkbox
// won't appear, but the revision log will if the content type is set to
// auto-revision.
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length)) {
return Drupal.t('New revision');
}
......@@ -61,13 +61,13 @@
$context.find('fieldset.node-translation-options').drupalSetSummary(function (context) {
var $translationContext = $(context);
var translate;
var $checkbox = $translationContext.find('.form-item-translation-translate input');
var $checkbox = $translationContext.find('.js-form-item-translation-translate input');
if ($checkbox.size()) {
translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
}
else {
$checkbox = $translationContext.find('.form-item-translation-retranslate input');
$checkbox = $translationContext.find('.js-form-item-translation-retranslate input');
translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated');
}
......
......@@ -17,7 +17,7 @@
Drupal.behaviors.pathDetailsSummaries = {
attach: function (context) {
$(context).find('.path-form').drupalSetSummary(function (context) {
var path = $('.form-item-path-0-alias input').val();
var path = $('.js-form-item-path-0-alias input').val();
return path ?
Drupal.t('Alias: @alias', {'@alias': path}) :
......
......@@ -71,7 +71,7 @@ function testFormLabels() {
$elements = $this->xpath('//label[@for="edit-form-textfield-test-title-no-show"]');
$this->assertFalse(isset($elements[0]), 'No label tag when title set not to display.');
$elements = $this->xpath('//div[contains(@class, "form-item-form-textfield-test-title-invisible") and contains(@class, "form-no-label")]');
$elements = $this->xpath('//div[contains(@class, "js-form-item-form-textfield-test-title-invisible") and contains(@class, "form-no-label")]');
$this->assertTrue(isset($elements[0]), 'Field class is form-no-label when there is no label.');
// Check #field_prefix and #field_suffix placement.
......@@ -82,10 +82,10 @@ function testFormLabels() {
$this->assertTrue(isset($elements[0]), 'Properly places the #field_suffix element immediately after the form field.');
// Check #prefix and #suffix placement.
$elements = $this->xpath('//div[@id="form-test-textfield-title-prefix"]/following-sibling::div[contains(@class, \'form-item-form-textfield-test-title\')]');
$elements = $this->xpath('//div[@id="form-test-textfield-title-prefix"]/following-sibling::div[contains(@class, \'js-form-item-form-textfield-test-title\')]');
$this->assertTrue(isset($elements[0]), 'Properly places the #prefix element before the form item.');
$elements = $this->xpath('//div[@id="form-test-textfield-title-suffix"]/preceding-sibling::div[contains(@class, \'form-item-form-textfield-test-title\')]');
$elements = $this->xpath('//div[@id="form-test-textfield-title-suffix"]/preceding-sibling::div[contains(@class, \'js-form-item-form-textfield-test-title\')]');
$this->assertTrue(isset($elements[0]), 'Properly places the #suffix element before the form item.');
// Check title attribute for radios and checkboxes.
......
......@@ -109,7 +109,7 @@ function testPreserveFormActionAfterAJAX() {
// Ensure that the form contains two items in the multi-valued field, so we
// know we're testing a form that was correctly retrieved from cache.
$this->assert(count($this->xpath('//form[contains(@id, "node-page-form")]//div[contains(@class, "form-item-field-ajax-test")]//input[@type="text"]')) == 2, 'Form retained its state from cache.');
$this->assert(count($this->xpath('//form[contains(@id, "node-page-form")]//div[contains(@class, "js-form-item-field-ajax-test")]//input[@type="text"]')) == 2, 'Form retained its state from cache.');
// Ensure that the form's action is correct.
$forms = $this->xpath('//form[contains(@class, "node-page-form")]');
......
......@@ -96,7 +96,7 @@ function testThemeSettings() {
// Verify logo path examples.
$elements = $this->xpath('//div[contains(@class, :item)]/div[@class=:description]/code', array(
':item' => 'form-item-logo-path',
':item' => 'js-form-item-logo-path',
':description' => 'description',
));
// Expected default values (if all else fails).
......
......@@ -52,6 +52,7 @@
'form-item',
'js-form-type-' ~ type|clean_class,
'form-item-' ~ name|clean_class,
'js-form-item-' ~ name|clean_class,
title_display not in ['after', 'before'] ? 'form-no-label',
disabled == 'disabled' ? 'form-disabled',
errors ? 'form-item--error',
......
......@@ -601,7 +601,7 @@
}
var $context = $(context);
var $table = $context.find('#views-rearrange-filters').once('views-rearrange-filters');
var $operator = $context.find('.form-item-filter-groups-operator').once('views-rearrange-filters');
var $operator = $context.find('.js-form-item-filter-groups-operator').once('views-rearrange-filters');
if ($table.length) {
new Drupal.viewsUi.RearrangeFilterHandler($table, $operator);
}
......@@ -1004,9 +1004,9 @@
attach: function (context) {
var $context = $(context);
var $selectAll = $context.find('.form-item-options-value-all').once('filterConfigSelectAll');
var $selectAll = $context.find('.js-form-item-options-value-all').once('filterConfigSelectAll');
var $selectAllCheckbox = $selectAll.find('input[type=checkbox]');
var $checkboxes = $selectAll.closest('.form-checkboxes').find('.js-form-type-checkbox:not(.form-item-options-value-all) input[type="checkbox"]');
var $checkboxes = $selectAll.closest('.form-checkboxes').find('.js-form-type-checkbox:not(.js-form-item-options-value-all) input[type="checkbox"]');
if ($selectAll.length) {
// Show the select all checkbox.
......
......@@ -50,6 +50,7 @@
'form-item',
'js-form-type-' ~ type|clean_class,
'form-type-' ~ type|clean_class,
'js-form-item-' ~ name|clean_class,
'form-item-' ~ name|clean_class,
title_display not in ['after', 'before'] ? 'form-no-label',
disabled == 'disabled' ? 'form-disabled',
......
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