Commit 59b1bac3 authored by xjm's avatar xjm

Revert "Issue #2915784 by dawehner, drpal, justafish, tedbow, xjm: 1/3 JS codestyle: camelcase"

This reverts commit 9b874acf.
parent 42634ef6
......@@ -86,11 +86,11 @@
}
}
Object.keys(settings.machineName).forEach((sourceId) => {
Object.keys(settings.machineName).forEach((source_id) => {
let machine = '';
const options = settings.machineName[sourceId];
const options = settings.machineName[source_id];
const $source = $context.find(sourceId).addClass('machine-name-source').once('machine-name');
const $source = $context.find(source_id).addClass('machine-name-source').once('machine-name');
const $target = $context.find(options.target).addClass('machine-name-target');
const $suffix = $context.find(options.suffix);
const $wrapper = $target.closest('.js-form-item');
......
......@@ -49,11 +49,11 @@
}
}
Object.keys(settings.machineName).forEach(function (sourceId) {
Object.keys(settings.machineName).forEach(function (source_id) {
var machine = '';
var options = settings.machineName[sourceId];
var options = settings.machineName[source_id];
var $source = $context.find(sourceId).addClass('machine-name-source').once('machine-name');
var $source = $context.find(source_id).addClass('machine-name-source').once('machine-name');
var $target = $context.find(options.target).addClass('machine-name-target');
var $suffix = $context.find(options.suffix);
var $wrapper = $target.closest('.js-form-item');
......
......@@ -61,7 +61,7 @@
$(context).find('[data-vertical-tabs-panes]').once('vertical-tabs').each(function () {
const $this = $(this).addClass('vertical-tabs__panes');
const focusID = $this.find(':hidden.vertical-tabs__active-tab').val();
let tabFocus;
let tab_focus;
// Check if there are some details that can be converted to
// vertical-tabs.
......@@ -71,45 +71,45 @@
}
// Create the tab column.
const tabList = $('<ul class="vertical-tabs__menu"></ul>');
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tabList);
const tab_list = $('<ul class="vertical-tabs__menu"></ul>');
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tab_list);
// Transform each details into a tab.
$details.each(function () {
const $that = $(this);
const verticalTab = new Drupal.verticalTab({
const vertical_tab = new Drupal.verticalTab({
title: $that.find('> summary').text(),
details: $that,
});
tabList.append(verticalTab.item);
tab_list.append(vertical_tab.item);
$that
.removeClass('collapsed')
// prop() can't be used on browsers not supporting details element,
// the style won't apply to them if prop() is used.
.attr('open', true)
.addClass('vertical-tabs__pane')
.data('verticalTab', verticalTab);
.data('verticalTab', vertical_tab);
if (this.id === focusID) {
tabFocus = $that;
tab_focus = $that;
}
});
$(tabList).find('> li').eq(0).addClass('first');
$(tabList).find('> li').eq(-1).addClass('last');
$(tab_list).find('> li').eq(0).addClass('first');
$(tab_list).find('> li').eq(-1).addClass('last');
if (!tabFocus) {
if (!tab_focus) {
// If the current URL has a fragment and one of the tabs contains an
// element that matches the URL fragment, activate that tab.
const $locationHash = $this.find(window.location.hash);
if (window.location.hash && $locationHash.length) {
tabFocus = $locationHash.closest('.vertical-tabs__pane');
tab_focus = $locationHash.closest('.vertical-tabs__pane');
}
else {
tabFocus = $this.find('> .vertical-tabs__pane').eq(0);
tab_focus = $this.find('> .vertical-tabs__pane').eq(0);
}
}
if (tabFocus.length) {
tabFocus.data('verticalTab').focus();
if (tab_focus.length) {
tab_focus.data('verticalTab').focus();
}
});
},
......
......@@ -26,42 +26,42 @@
$(context).find('[data-vertical-tabs-panes]').once('vertical-tabs').each(function () {
var $this = $(this).addClass('vertical-tabs__panes');
var focusID = $this.find(':hidden.vertical-tabs__active-tab').val();
var tabFocus = void 0;
var tab_focus = void 0;
var $details = $this.find('> details');
if ($details.length === 0) {
return;
}
var tabList = $('<ul class="vertical-tabs__menu"></ul>');
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tabList);
var tab_list = $('<ul class="vertical-tabs__menu"></ul>');
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tab_list);
$details.each(function () {
var $that = $(this);
var verticalTab = new Drupal.verticalTab({
var vertical_tab = new Drupal.verticalTab({
title: $that.find('> summary').text(),
details: $that
});
tabList.append(verticalTab.item);
$that.removeClass('collapsed').attr('open', true).addClass('vertical-tabs__pane').data('verticalTab', verticalTab);
tab_list.append(vertical_tab.item);
$that.removeClass('collapsed').attr('open', true).addClass('vertical-tabs__pane').data('verticalTab', vertical_tab);
if (this.id === focusID) {
tabFocus = $that;
tab_focus = $that;
}
});
$(tabList).find('> li').eq(0).addClass('first');
$(tabList).find('> li').eq(-1).addClass('last');
$(tab_list).find('> li').eq(0).addClass('first');
$(tab_list).find('> li').eq(-1).addClass('last');
if (!tabFocus) {
if (!tab_focus) {
var $locationHash = $this.find(window.location.hash);
if (window.location.hash && $locationHash.length) {
tabFocus = $locationHash.closest('.vertical-tabs__pane');
tab_focus = $locationHash.closest('.vertical-tabs__pane');
} else {
tabFocus = $this.find('> .vertical-tabs__pane').eq(0);
tab_focus = $this.find('> .vertical-tabs__pane').eq(0);
}
}
if (tabFocus.length) {
tabFocus.data('verticalTab').focus();
if (tab_focus.length) {
tab_focus.data('verticalTab').focus();
}
});
}
......
......@@ -24,7 +24,7 @@
attach(context, settings) {
const $input = $('input.block-filter-text').once('block-filter-text');
const $table = $($input.attr('data-element'));
let $filterRows;
let $filter_rows;
/**
* Filters the block list.
......@@ -52,7 +52,7 @@
// Filter if the length of the query is at least 2 characters.
if (query.length >= 2) {
$filterRows.each(toggleBlockEntry);
$filter_rows.each(toggleBlockEntry);
Drupal.announce(
Drupal.formatPlural(
$table.find('tr:visible').length - 1,
......@@ -62,14 +62,14 @@
);
}
else {
$filterRows.each(function (index) {
$filter_rows.each(function (index) {
$(this).parent().parent().show();
});
}
}
if ($table.length) {
$filterRows = $table.find('div.block-filter-text-source');
$filter_rows = $table.find('div.block-filter-text-source');
$input.on('keyup', debounce(filterBlockList, 200));
}
},
......
......@@ -10,7 +10,7 @@
attach: function attach(context, settings) {
var $input = $('input.block-filter-text').once('block-filter-text');
var $table = $($input.attr('data-element'));
var $filterRows = void 0;
var $filter_rows = void 0;
function filterBlockList(e) {
var query = $(e.target).val().toLowerCase();
......@@ -23,17 +23,17 @@
}
if (query.length >= 2) {
$filterRows.each(toggleBlockEntry);
$filter_rows.each(toggleBlockEntry);
Drupal.announce(Drupal.formatPlural($table.find('tr:visible').length - 1, '1 block is available in the modified list.', '@count blocks are available in the modified list.'));
} else {
$filterRows.each(function (index) {
$filter_rows.each(function (index) {
$(this).parent().parent().show();
});
}
}
if ($table.length) {
$filterRows = $table.find('div.block-filter-text-source');
$filter_rows = $table.find('div.block-filter-text-source');
$input.on('keyup', debounce(filterBlockList, 200));
}
}
......
......@@ -195,14 +195,14 @@
// Find the correct region and insert the row as the last in the
// region.
tableDrag.rowObject = new tableDrag.row(row[0]);
const regionMessage = table.find(`.region-${select[0].value}-message`);
const regionItems = regionMessage.nextUntil('.region-message, .region-title');
if (regionItems.length) {
regionItems.last().after(row);
const region_message = table.find(`.region-${select[0].value}-message`);
const region_items = region_message.nextUntil('.region-message, .region-title');
if (region_items.length) {
region_items.last().after(row);
}
// We found that regionMessage is the last row.
// We found that region_message is the last row.
else {
regionMessage.after(row);
region_message.after(row);
}
updateBlockWeights(table, select[0].value);
// Modify empty regions with added or removed fields.
......
......@@ -119,12 +119,12 @@
var select = $(this);
tableDrag.rowObject = new tableDrag.row(row[0]);
var regionMessage = table.find('.region-' + select[0].value + '-message');
var regionItems = regionMessage.nextUntil('.region-message, .region-title');
if (regionItems.length) {
regionItems.last().after(row);
var region_message = table.find('.region-' + select[0].value + '-message');
var region_items = region_message.nextUntil('.region-message, .region-title');
if (region_items.length) {
region_items.last().after(row);
} else {
regionMessage.after(row);
region_message.after(row);
}
updateBlockWeights(table, select[0].value);
......
......@@ -17,11 +17,10 @@
const $context = $(context);
const options = drupalSettings.contentTranslationDependentOptions;
let $fields;
let dependentColumns;
function fieldsChangeHandler($fields, dependentColumns) {
function fieldsChangeHandler($fields, dependent_columns) {
return function (e) {
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns, $(e.target));
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns, $(e.target));
};
}
......@@ -31,14 +30,14 @@
if (options && options.dependent_selectors) {
Object.keys(options.dependent_selectors).forEach((field) => {
$fields = $context.find(`input[name^="${field}"]`);
dependentColumns = options.dependent_selectors[field];
const dependent_columns = options.dependent_selectors[field];
$fields.on('change', fieldsChangeHandler($fields, dependentColumns));
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns);
$fields.on('change', fieldsChangeHandler($fields, dependent_columns));
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns);
});
}
},
check($fields, dependentColumns, $changed) {
check($fields, dependent_columns, $changed) {
let $element = $changed;
let column;
......@@ -48,8 +47,8 @@
// A field that has many different translatable parts can also define one
// or more columns that require all columns to be translatable.
Object.keys(dependentColumns).forEach((index) => {
column = dependentColumns[index];
Object.keys(dependent_columns).forEach((index) => {
column = dependent_columns[index];
if (!$changed) {
$element = $fields.filter(filterFieldsList);
......
......@@ -11,25 +11,24 @@
var $context = $(context);
var options = drupalSettings.contentTranslationDependentOptions;
var $fields = void 0;
var dependentColumns = void 0;
function fieldsChangeHandler($fields, dependentColumns) {
function fieldsChangeHandler($fields, dependent_columns) {
return function (e) {
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns, $(e.target));
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns, $(e.target));
};
}
if (options && options.dependent_selectors) {
Object.keys(options.dependent_selectors).forEach(function (field) {
$fields = $context.find('input[name^="' + field + '"]');
dependentColumns = options.dependent_selectors[field];
var dependent_columns = options.dependent_selectors[field];
$fields.on('change', fieldsChangeHandler($fields, dependentColumns));
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns);
$fields.on('change', fieldsChangeHandler($fields, dependent_columns));
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns);
});
}
},
check: function check($fields, dependentColumns, $changed) {
check: function check($fields, dependent_columns, $changed) {
var $element = $changed;
var column = void 0;
......@@ -37,8 +36,8 @@
return $(field).val() === column;
}
Object.keys(dependentColumns).forEach(function (index) {
column = dependentColumns[index];
Object.keys(dependent_columns).forEach(function (index) {
column = dependent_columns[index];
if (!$changed) {
$element = $fields.filter(filterFieldsList);
......
......@@ -14,10 +14,10 @@
* The text area DOM element, if it was found.
*/
function findFieldForFormatSelector($formatSelector) {
const fieldId = $formatSelector.attr('data-editor-for');
const field_id = $formatSelector.attr('data-editor-for');
// This selector will only find text areas in the top-level document. We do
// not support attaching editors on text areas within iframes.
return $(`#${fieldId}`).get(0);
return $(`#${field_id}`).get(0);
}
/**
......
......@@ -7,9 +7,9 @@
(function ($, Drupal, drupalSettings) {
function findFieldForFormatSelector($formatSelector) {
var fieldId = $formatSelector.attr('data-editor-for');
var field_id = $formatSelector.attr('data-editor-for');
return $('#' + fieldId).get(0);
return $('#' + field_id).get(0);
}
function changeTextEditor(field, newFormatID) {
......
......@@ -43,41 +43,41 @@
// in the form, but play nicely with user permissions and form
// alterations.
const $checkbox = $this.find('.js-form-item-menu-enabled input');
const $linkTitle = $context.find('.js-form-item-menu-title input');
const $link_title = $context.find('.js-form-item-menu-title input');
const $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 && $linkTitle.length && $title.length)) {
if (!($checkbox.length && $link_title.length && $title.length)) {
return;
}
// If there is a link title already, mark it as overridden. The user
// expects that toggling the checkbox twice will take over the node's
// title.
if ($checkbox.is(':checked') && $linkTitle.val().length) {
$linkTitle.data('menuLinkAutomaticTitleOverridden', true);
if ($checkbox.is(':checked') && $link_title.val().length) {
$link_title.data('menuLinkAutomaticTitleOverridden', true);
}
// Whenever the value is changed manually, disable this behavior.
$linkTitle.on('keyup', () => {
$linkTitle.data('menuLinkAutomaticTitleOverridden', true);
$link_title.on('keyup', () => {
$link_title.data('menuLinkAutomaticTitleOverridden', true);
});
// Global trigger on checkbox (do not fill-in a value when disabled).
$checkbox.on('change', () => {
if ($checkbox.is(':checked')) {
if (!$linkTitle.data('menuLinkAutomaticTitleOverridden')) {
$linkTitle.val($title.val());
if (!$link_title.data('menuLinkAutomaticTitleOverridden')) {
$link_title.val($title.val());
}
}
else {
$linkTitle.val('');
$linkTitle.removeData('menuLinkAutomaticTitleOverridden');
$link_title.val('');
$link_title.removeData('menuLinkAutomaticTitleOverridden');
}
$checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated');
$checkbox.trigger('formUpdated');
});
// Take over any title change.
$title.on('keyup', () => {
if (!$linkTitle.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) {
$linkTitle.val($title.val());
$linkTitle.val($title.val()).trigger('formUpdated');
if (!$link_title.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) {
$link_title.val($title.val());
$link_title.val($title.val()).trigger('formUpdated');
}
});
});
......
......@@ -26,38 +26,38 @@
var $this = $(this);
var $checkbox = $this.find('.js-form-item-menu-enabled input');
var $linkTitle = $context.find('.js-form-item-menu-title 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');
if (!($checkbox.length && $linkTitle.length && $title.length)) {
if (!($checkbox.length && $link_title.length && $title.length)) {
return;
}
if ($checkbox.is(':checked') && $linkTitle.val().length) {
$linkTitle.data('menuLinkAutomaticTitleOverridden', true);
if ($checkbox.is(':checked') && $link_title.val().length) {
$link_title.data('menuLinkAutomaticTitleOverridden', true);
}
$linkTitle.on('keyup', function () {
$linkTitle.data('menuLinkAutomaticTitleOverridden', true);
$link_title.on('keyup', function () {
$link_title.data('menuLinkAutomaticTitleOverridden', true);
});
$checkbox.on('change', function () {
if ($checkbox.is(':checked')) {
if (!$linkTitle.data('menuLinkAutomaticTitleOverridden')) {
$linkTitle.val($title.val());
if (!$link_title.data('menuLinkAutomaticTitleOverridden')) {
$link_title.val($title.val());
}
} else {
$linkTitle.val('');
$linkTitle.removeData('menuLinkAutomaticTitleOverridden');
$link_title.val('');
$link_title.removeData('menuLinkAutomaticTitleOverridden');
}
$checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated');
$checkbox.trigger('formUpdated');
});
$title.on('keyup', function () {
if (!$linkTitle.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) {
$linkTitle.val($title.val());
$linkTitle.val($title.val()).trigger('formUpdated');
if (!$link_title.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) {
$link_title.val($title.val());
$link_title.val($title.val()).trigger('formUpdated');
}
});
});
......
......@@ -35,10 +35,10 @@
$colorPreview.find('.color-preview-footer-wrapper').css('background-color', $colorPalette.find('input[name="palette[footer]"]').val());
// CSS3 Gradients.
const gradientStart = $colorPalette.find('input[name="palette[top]"]').val();
const gradientEnd = $colorPalette.find('input[name="palette[bottom]"]').val();
const gradient_start = $colorPalette.find('input[name="palette[top]"]').val();
const gradient_end = $colorPalette.find('input[name="palette[bottom]"]').val();
$colorPreview.find('.color-preview-header').attr('style', `background-color: ${gradientStart}; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(${gradientStart}), to(${gradientEnd})); background-image: -moz-linear-gradient(-90deg, ${gradientStart}, ${gradientEnd});`);
$colorPreview.find('.color-preview-header').attr('style', `background-color: ${gradient_start}; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(${gradient_start}), to(${gradient_end})); background-image: -moz-linear-gradient(-90deg, ${gradient_start}, ${gradient_end});`);
$colorPreview.find('.color-preview-site-name').css('color', $colorPalette.find('input[name="palette[titleslogan]"]').val());
},
......
......@@ -32,10 +32,10 @@
$colorPreview.find('.color-preview-footer-wrapper').css('background-color', $colorPalette.find('input[name="palette[footer]"]').val());
var gradientStart = $colorPalette.find('input[name="palette[top]"]').val();
var gradientEnd = $colorPalette.find('input[name="palette[bottom]"]').val();
var gradient_start = $colorPalette.find('input[name="palette[top]"]').val();
var gradient_end = $colorPalette.find('input[name="palette[bottom]"]').val();
$colorPreview.find('.color-preview-header').attr('style', 'background-color: ' + gradientStart + '; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(' + gradientStart + '), to(' + gradientEnd + ')); background-image: -moz-linear-gradient(-90deg, ' + gradientStart + ', ' + gradientEnd + ');');
$colorPreview.find('.color-preview-header').attr('style', 'background-color: ' + gradient_start + '; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(' + gradient_start + '), to(' + gradient_end + ')); background-image: -moz-linear-gradient(-90deg, ' + gradient_start + ', ' + gradient_end + ');');
$colorPreview.find('.color-preview-site-name').css('color', $colorPalette.find('input[name="palette[titleslogan]"]').val());
}
......
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