Commit ce86e09d authored by webchick's avatar webchick

Issue #2915784 by dawehner, drpal, mikejw, justafish, tedbow, xjm, webchick:...

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