diff --git a/.eslintignore b/.eslintignore index 4690c5a7a65abe3a75f421813cb788605a4663c0..abf79d9e2a8bfde849ff6b4f76b83dbcb99dfe26 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,3 +5,4 @@ sites/**/files/**/* libraries/**/* sites/**/libraries/**/* profiles/**/libraries/**/* +**/js_test_files/**/* diff --git a/.eslintrc b/.eslintrc index d371f58acf6c12e3ea20a60c98b9833fea81949d..b517ef8ef9bc5eeb5c42ac60c6e8ba0dcd5ad1bb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,6 +31,7 @@ "no-undef": 2, "no-undefined": 2, "no-unused-vars": [2, {"vars": "local", "args": "none"}], + "one-var": [2, "never"], "semi": [2, "always"], "space-after-keywords": [2, "always", {"checkFunctionKeyword": true}], "space-before-blocks": [2, "always"], diff --git a/core/misc/active-link.js b/core/misc/active-link.js index c33c0ce6f687ddd3d35bdd0bfdd151e395cb7280..3a2f818b009e4b4c80b2994f90e3812d5871c74f 100644 --- a/core/misc/active-link.js +++ b/core/misc/active-link.js @@ -46,14 +46,16 @@ // Query the DOM. var activeLinks = context.querySelectorAll(selectors.join(',')); - for (var i = 0, il = activeLinks.length; i < il; i += 1) { + var il = activeLinks.length; + for (var i = 0; i < il; i++) { activeLinks[i].classList.add('is-active'); } }, detach: function (context, settings, trigger) { if (trigger === 'unload') { var activeLinks = context.querySelectorAll('[data-drupal-link-system-path].is-active'); - for (var i = 0, il = activeLinks.length; i < il; i += 1) { + var il = activeLinks.length; + for (var i = 0; i < il; i++) { activeLinks[i].classList.remove('is-active'); } } diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 91e8e1c5ccfc4bdba7fff7e154262d76b25937dd..e2aeab15caf21f7f0b8bcb6b80d543e4ed622436 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -84,7 +84,11 @@ */ Drupal.AjaxError = function (xmlhttp, uri) { - var statusCode, statusText, pathText, responseText, readyStateText; + var statusCode; + var statusText; + var pathText; + var responseText; + var readyStateText; if (xmlhttp.status) { statusCode = "\n" + Drupal.t("An AJAX HTTP error occurred.") + "\n" + Drupal.t("HTTP Result Code: !status", {'!status': xmlhttp.status}); } @@ -100,7 +104,9 @@ try { statusText = "\n" + Drupal.t("StatusText: !statusText", {'!statusText': $.trim(xmlhttp.statusText)}); } - catch (e) {} + catch (e) { + // empty + } responseText = ''; // Again, we don't have a way to know for sure whether accessing @@ -108,7 +114,9 @@ try { responseText = "\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText)}); } - catch (e) {} + catch (e) { + // empty + } // Make the responseText more readable by stripping HTML tags and newlines. responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, ""); @@ -375,7 +383,8 @@ // @see \Drupal\Component\Utility\Html::getUniqueId() var ids = document.querySelectorAll('[id]'); var ajaxHtmlIds = []; - for (var i = 0, il = ids.length; i < il; i++) { + var il = ids.length; + for (var i = 0; i < il; i++) { ajaxHtmlIds.push(ids[i].id); } // Join IDs to minimize request size. @@ -727,7 +736,8 @@ // Add the styles in the normal way. $('head').prepend(response.data); // Add imports in the styles using the addImport method if available. - var match, importMatch = /^@import url\("(.*)"\);$/igm; + var match; + var importMatch = /^@import url\("(.*)"\);$/igm; if (document.styleSheets[0].addImport && importMatch.test(response.data)) { importMatch.lastIndex = 0; do { diff --git a/core/misc/announce.js b/core/misc/announce.js index 00ce14b118865c3b1098c2f34a880125fc10a813..9aafbbcbce4a7ed55e2cbc68d78e103bb7cf60a0 100644 --- a/core/misc/announce.js +++ b/core/misc/announce.js @@ -49,7 +49,8 @@ // Create an array of announcement strings to be joined and appended to the // aria live region. - for (var i = 0, il = announcements.length; i < il; i++) { + var il = announcements.length; + for (var i = 0; i < il; i++) { announcement = announcements.pop(); text.unshift(announcement.text); // If any of the announcements has a priority of assertive then the group diff --git a/core/misc/autocomplete.js b/core/misc/autocomplete.js index 639f9dc18e5939cde9587efdc7ad1318322e870d..92bb86785af0fb591f83834cb63f330c8e560414 100644 --- a/core/misc/autocomplete.js +++ b/core/misc/autocomplete.js @@ -17,9 +17,9 @@ var quote = false; var current = ''; var valueLength = value.length; - var i, character; + var character; - for (i = 0; i < valueLength; i++) { + for (var i = 0; i < valueLength; i++) { character = value.charAt(i); if (character === '"') { current += character; @@ -90,7 +90,8 @@ */ function showSuggestions(suggestions) { var tagged = autocomplete.splitValues(request.term); - for (var i = 0, il = tagged.length; i < il; i++) { + var il = tagged.length; + for (var i = 0; i < il; i++) { var index = suggestions.indexOf(tagged[i]); if (index >= 0) { suggestions.splice(index, 1); diff --git a/core/misc/debounce.js b/core/misc/debounce.js index 97312578bacdc8678070d737dfeebce4230304f4..45a5b87358a42cf167af0ec52e5ec0fd99a5c8f6 100644 --- a/core/misc/debounce.js +++ b/core/misc/debounce.js @@ -23,7 +23,8 @@ Drupal.debounce = function (func, wait, immediate) { "use strict"; - var timeout, result; + var timeout; + var result; return function () { var context = this; var args = arguments; diff --git a/core/misc/dialog/dialog.jquery-ui.js b/core/misc/dialog/dialog.jquery-ui.js index 59f9073008b1bc64b7b1c48e60866a440d46ca3c..cd6e863fec588023557f93856b00f3b9298774a4 100644 --- a/core/misc/dialog/dialog.jquery-ui.js +++ b/core/misc/dialog/dialog.jquery-ui.js @@ -15,8 +15,9 @@ var opts = this.options; var primaryIndex; var $buttons; - var index, il; - for (index = 0, il = opts.buttons.length; index < il; index += 1) { + var index; + var il = opts.buttons.length; + for (index = 0; index < il; index++) { if (opts.buttons[index].primary && opts.buttons[index].primary === true) { primaryIndex = index; delete opts.buttons[index].primary; diff --git a/core/misc/dialog/dialog.position.js b/core/misc/dialog/dialog.position.js index ae1ddf59e477efd0808864be2a1924677afee969..3e08574a6947c0e9e588906861fa449c4dd64f45 100644 --- a/core/misc/dialog/dialog.position.js +++ b/core/misc/dialog/dialog.position.js @@ -17,7 +17,9 @@ var positionOptions = ['width', 'height', 'minWidth', 'minHeight', 'maxHeight', 'maxWidth', 'position']; var adjustedOptions = {}; var windowHeight = $(window).height(); - var option, optionValue, adjustedValue; + var option; + var optionValue; + var adjustedValue; for (var n = 0; n < positionOptions.length; n++) { option = positionOptions[n]; optionValue = event.data.settings[option]; diff --git a/core/misc/displace.js b/core/misc/displace.js index 6dca569b3bbf81920bd20f2de140d99471b56bf4..a52a82650ed389abdfbf146dd033badad64673a0 100644 --- a/core/misc/displace.js +++ b/core/misc/displace.js @@ -85,7 +85,8 @@ function calculateOffset(edge) { var edgeOffset = 0; var displacingElements = document.querySelectorAll('[data-offset-' + edge + ']'); - for (var i = 0, n = displacingElements.length; i < n; i++) { + var n = displacingElements.length; + for (var i = 0; i < n; i++) { var el = displacingElements[i]; // If the element is not visible, do consider its dimensions. if (el.style.display === 'none') { diff --git a/core/misc/dropbutton/dropbutton.js b/core/misc/dropbutton/dropbutton.js index ebad07af8c06436c01d1567c4865b5fbbd1458d5..eebf354ef9df7944055f472937786247af02b0dc 100644 --- a/core/misc/dropbutton/dropbutton.js +++ b/core/misc/dropbutton/dropbutton.js @@ -15,7 +15,8 @@ $body.on('click', '.dropbutton-toggle', dropbuttonClickHandler); } // Initialize all buttons. - for (var i = 0, il = $dropbuttons.length; i < il; i++) { + var il = $dropbuttons.length; + for (var i = 0; i < il; i++) { DropButton.dropbuttons.push(new DropButton($dropbuttons[i], settings.dropbutton)); } } diff --git a/core/misc/drupal.js b/core/misc/drupal.js index b1b4125d4b3db27acf2985ff74200c8bce9cd53f..9e9d24e0438cfe1f326094c64b8b5c0e973c3163 100644 --- a/core/misc/drupal.js +++ b/core/misc/drupal.js @@ -32,7 +32,8 @@ if (window.jQuery) { // Makes the list of errors readable. var messageList = []; messageList.push(this.event); - for (var i = 0, il = this.list.length; i < il; i++) { + var il = this.list.length; + for (var i = 0; i < il; i++) { messageList.push(this.list[i].behavior + ': ' + this.list[i].error.message); } this.message = messageList.join(' ; '); @@ -81,9 +82,10 @@ if (window.jQuery) { Drupal.attachBehaviors = function (context, settings) { context = context || document; settings = settings || drupalSettings; - var i, errors = [], behaviors = Drupal.behaviors; + var errors = []; + var behaviors = Drupal.behaviors; // Execute all of them. - for (i in behaviors) { + for (var i in behaviors) { if (behaviors.hasOwnProperty(i) && typeof behaviors[i].attach === 'function') { // Don't stop the execution of behaviors in case of an error. try { @@ -147,9 +149,10 @@ if (window.jQuery) { context = context || document; settings = settings || drupalSettings; trigger = trigger || 'unload'; - var i, errors = [], behaviors = Drupal.behaviors; + var errors = []; + var behaviors = Drupal.behaviors; // Execute all of them. - for (i in behaviors) { + for (var i in behaviors) { if (behaviors.hasOwnProperty(i) && typeof behaviors[i].detach === 'function') { // Don't stop the execution of behaviors in case of an error. try { @@ -369,9 +372,9 @@ if (window.jQuery) { args = args || {}; args['@count'] = count; - var pluralDelimiter = drupalSettings.pluralDelimiter, - translations = Drupal.t(singular + pluralDelimiter + plural, args, options).split(pluralDelimiter), - index = 0; + var pluralDelimiter = drupalSettings.pluralDelimiter; + var translations = Drupal.t(singular + pluralDelimiter + plural, args, options).split(pluralDelimiter); + var index = 0; // Determine the index of the plural form. if (typeof drupalTranslations !== 'undefined' && drupalTranslations.pluralFormula) { diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js index b9e87a6d1b8e01ee21ef284de98ebf325ce5237f..d0e4d127b8c9a89d379335e01758f92548f58289 100644 --- a/core/misc/machine-name.js +++ b/core/misc/machine-name.js @@ -75,7 +75,8 @@ } Object.keys(settings.machineName).forEach(function (source_id) { - var machine, eventData; + var machine; + var eventData; var options = settings.machineName[source_id]; var $source = $context.find(source_id).addClass('machine-name-source').once('machine-name'); diff --git a/core/misc/states.js b/core/misc/states.js index 680e86e234c560ac305447c603194fc14e27b659..c68d1b597932d41906c49f33ba01e32ceeb7f54c 100644 --- a/core/misc/states.js +++ b/core/misc/states.js @@ -22,8 +22,10 @@ Drupal.behaviors.states = { attach: function (context, settings) { var $states = $(context).find('[data-drupal-states]'); - var config, state; - for (var i = 0, il = $states.length; i < il; i += 1) { + var config; + var state; + var il = $states.length; + for (var i = 0; i < il; i++) { config = JSON.parse($states[i].getAttribute('data-drupal-states')); for (state in config) { if (config.hasOwnProperty(state)) { @@ -98,7 +100,8 @@ * dependee's compliance status. */ initializeDependee: function (selector, dependeeStates) { - var state, self = this; + var state; + var self = this; function stateEventHandler(e) { self.update(e.data.selector, e.data.state, e.value); @@ -212,7 +215,8 @@ if ($.isArray(constraints)) { // This constraint is an array (OR or XOR). var hasXor = $.inArray('xor', constraints) === -1; - for (var i = 0, len = constraints.length; i < len; i++) { + var len = constraints.length; + for (var i = 0; i < len; i++) { if (constraints[i] !== 'xor') { var constraint = this.checkConstraints(constraints[i], selector, i); // Return if this is OR and we have a satisfied constraint or if this diff --git a/core/misc/tabbingmanager.js b/core/misc/tabbingmanager.js index b80f2a3c8f9e7318d88f575d5be18a72683595f3..dc21c0263bf956f6064205af8f447e3acf79c96e 100644 --- a/core/misc/tabbingmanager.js +++ b/core/misc/tabbingmanager.js @@ -39,7 +39,8 @@ // Deactivate all tabbingContexts to prepare for the new constraint. A // tabbingContext instance will only be reactivated if the stack is unwound // to it in the _unwindStack() method. - for (var i = 0, il = this.stack.length; i < il; i++) { + var il = this.stack.length; + for (var i = 0; i < il; i++) { this.stack[i].deactivate(); } @@ -110,7 +111,8 @@ // Set the disabled set on the tabbingContext. tabbingContext.$disabledElements = $disabledSet; // Record the tabindex for each element, so we can restore it later. - for (var i = 0, il = $disabledSet.length; i < il; i++) { + var il = $disabledSet.length; + for (var i = 0; i < il; i++) { this.recordTabindex($disabledSet.eq(i), level); } // Make all tabbable elements outside of the active tabbing set unreachable. @@ -142,7 +144,8 @@ deactivate: function (tabbingContext) { var $set = tabbingContext.$disabledElements; var level = tabbingContext.level; - for (var i = 0, il = $set.length; i < il; i++) { + var il = $set.length; + for (var i = 0; i < il; i++) { this.restoreTabindex($set.eq(i), level); } }, diff --git a/core/misc/tabledrag.js b/core/misc/tabledrag.js index 1cc75151abffe461e643469e237c0c93fe414219..61f8e29e80d7f98e8c824d74bed5a5a61ec06e02 100644 --- a/core/misc/tabledrag.js +++ b/core/misc/tabledrag.js @@ -153,7 +153,9 @@ */ Drupal.tableDrag.prototype.initColumns = function () { var $table = this.$table; - var hidden, cell, columnIndex; + var hidden; + var cell; + var columnIndex; for (var group in this.tableSettings) { if (this.tableSettings.hasOwnProperty(group)) { // Find the first field in this group. for (var d in this.tableSettings[group]) { @@ -586,7 +588,8 @@ * Pointerup behavior. */ Drupal.tableDrag.prototype.dropRow = function (event, self) { - var droppedRow, $droppedRow; + var droppedRow; + var $droppedRow; // Drop row functionality. if (self.rowObject !== null) { @@ -1048,7 +1051,8 @@ Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) { var $row = $(row); if (this.indentEnabled) { - var prevRow, nextRow; + var prevRow; + var nextRow; if (this.direction === 'down') { prevRow = row; nextRow = $row.next('tr').get(0); @@ -1108,7 +1112,8 @@ */ Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) { var $prevRow = $(prevRow); - var minIndent, maxIndent; + var minIndent; + var maxIndent; // Minimum indentation: // Do not orphan the next row. diff --git a/core/misc/tableheader.js b/core/misc/tableheader.js index 448d0b289d6ed144f768c1cfe038af6d5b92aeb8..2d6ce16e100353072c0e54fd9cf4d03f6dbf2a41 100644 --- a/core/misc/tableheader.js +++ b/core/misc/tableheader.js @@ -18,7 +18,8 @@ // Select and initialize sticky table headers. function tableHeaderInitHandler(e) { var $tables = $(e.data.context).find('table.sticky-enabled').once('tableheader'); - for (var i = 0, il = $tables.length; i < il; i++) { + var il = $tables.length; + for (var i = 0; i < il; i++) { TableHeader.tables.push(new TableHeader($tables[i])); } forTables('onScroll'); @@ -27,7 +28,8 @@ // Helper method to loop through tables and execute a method. function forTables(method, arg) { var tables = TableHeader.tables; - for (var i = 0, il = tables.length; i < il; i++) { + var il = tables.length; + for (var i = 0; i < il; i++) { tables[i][method](arg); } } @@ -234,7 +236,8 @@ // Resize header and its cell widths. // Only apply width to visible table cells. This prevents the header from // displaying incorrectly when the sticky header is no longer visible. - for (var i = 0, il = this.$originalHeaderCells.length; i < il; i++) { + var il = this.$originalHeaderCells.length; + for (var i = 0; i < il; i++) { $that = $(this.$originalHeaderCells[i]); $stickyCell = this.$stickyHeaderCells.eq($that.index()); display = $that.css('display'); diff --git a/core/misc/tableresponsive.js b/core/misc/tableresponsive.js index e13acce40d8bc285fbd50a703f37fe73318e8534..b4eab625c827ea5c1a4820b7b7090305242b1b38 100644 --- a/core/misc/tableresponsive.js +++ b/core/misc/tableresponsive.js @@ -9,7 +9,8 @@ attach: function (context, settings) { var $tables = $(context).find('table.responsive-enabled').once('tableresponsive'); if ($tables.length) { - for (var i = 0, il = $tables.length; i < il; i++) { + var il = $tables.length; + for (var i = 0; i < il; i++) { TableResponsive.tables.push(new TableResponsive($tables[i])); } } diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js index 8f91d5e3585da3204c5618c1512ef0dcd4979f9e..78e8c90fd1046d9f3bbf229b7348477c580cd15d 100644 --- a/core/misc/tableselect.js +++ b/core/misc/tableselect.js @@ -16,7 +16,9 @@ } // Keep track of the table, which checkbox is checked and alias the settings. - var table = this, checkboxes, lastChecked; + var table = this; + var checkboxes; + var lastChecked; var $table = $(table); var strings = {'selectAll': Drupal.t('Select all rows in this table'), 'selectNone': Drupal.t('Deselect all rows in this table')}; var updateSelectAll = function (state) { @@ -71,7 +73,8 @@ var mode = from.rowIndex > to.rowIndex ? 'previousSibling' : 'nextSibling'; // Traverse through the sibling nodes. - for (var i = from[mode], $i; i; i = i[mode]) { + for (var i = from[mode]; i; i = i[mode]) { + var $i; // Make sure that we're only dealing with elements. if (i.nodeType !== 1) { continue; diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index 89739c7caf0ff709f3e57a33ba1684b65f64ef07..b8f9682421bbe6f77e6003f78dcf1aab3eeeeaa4 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -13,7 +13,8 @@ attach: function (context, settings) { var $input = $('input.block-filter-text').once('block-filter-text'); var $element = $($input.attr('data-element')); - var $blocks, $details; + var $blocks; + var $details; /** * Hides the <details> element for a category if it has no visible blocks. diff --git a/core/modules/block/js/block.js b/core/modules/block/js/block.js index 3a42f37206bd35ac891c521642ccd35a64bac041..c3a4d0d672ccd0aa440b0f1d0a5deb1532e3521e 100644 --- a/core/modules/block/js/block.js +++ b/core/modules/block/js/block.js @@ -17,7 +17,8 @@ function checkboxesSummary(context) { var vals = []; var $checkboxes = $(context).find('input[type="checkbox"]:checked + label'); - for (var i = 0, il = $checkboxes.length; i < il; i += 1) { + var il = $checkboxes.length; + for (var i = 0; i < il; i++) { vals.push($($checkboxes[i]).text()); } if (!vals.length) { diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index d649885f1490d9e22508e8c40c125f3e79f3e1dc..fd18c5a8d1d4f4457a7bbf9aeb7e004f16d59873 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -114,8 +114,8 @@ editor.fire('saveSnapshot'); // Pass `true` so DocumentFragment will also be returned. - var container = widget.wrapper.getParent(true), - image = widget.parts.image; + var container = widget.wrapper.getParent(true); + var image = widget.parts.image; // Set the updated widget data, after the necessary conversions from // the dialog's return values. diff --git a/core/modules/ckeditor/js/plugins/drupallink/plugin.js b/core/modules/ckeditor/js/plugins/drupallink/plugin.js index 76e6de2bc4d7779f00603ebefbb46db51f34ed62..04d8aba93a903471d3535212be1a51a3bb0ec3f7 100644 --- a/core/modules/ckeditor/js/plugins/drupallink/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupallink/plugin.js @@ -25,7 +25,8 @@ linkDOMElement = linkElement.$; // Populate an array with the link's current attributes. - var attribute = null, attributeName; + var attribute = null; + var attributeName; for (var attrIndex = 0; attrIndex < linkDOMElement.attributes.length; attrIndex++) { attribute = linkDOMElement.attributes.item(attrIndex); attributeName = attribute.nodeName.toLowerCase(); diff --git a/core/modules/ckeditor/js/views/ControllerView.js b/core/modules/ckeditor/js/views/ControllerView.js index aff0f8d47691f5dd3fe1ac0453e1b7ddeaafb766..7d779439d800e331a56618b109fff4397acc283b 100644 --- a/core/modules/ckeditor/js/views/ControllerView.js +++ b/core/modules/ckeditor/js/views/ControllerView.js @@ -162,7 +162,8 @@ // First collect all CKEditor allowedContent rules. var CKEFeatureRulesMap = {}; var rules = e.editor.filter.allowedContent; - var rule, name; + var rule; + var name; for (var i = 0; i < rules.length; i++) { rule = rules[i]; name = rule.featureName || ':('; @@ -233,9 +234,11 @@ var existingButtons = []; // Loop through each button group after flattening the groups from the // toolbar row arrays. - for (var i = 0, buttonGroups = _.flatten(this.model.get('activeEditorConfig')); i < buttonGroups.length; i++) { + var buttonGroups = _.flatten(this.model.get('activeEditorConfig')); + for (var i = 0; i < buttonGroups.length; i++) { // Pull the button names from each toolbar button group. - for (var k = 0, buttons = buttonGroups[i].items; k < buttons.length; k++) { + var buttons = buttonGroups[i].items; + for (var k = 0; k < buttons.length; k++) { existingButtons.push(buttons[k]); } } diff --git a/core/modules/ckeditor/js/views/KeyboardView.js b/core/modules/ckeditor/js/views/KeyboardView.js index 285b963939ec120a48277e9f4d59537d9295aa9f..2a2868ae861f40dc2a41089b7ea85e5438f8b504 100644 --- a/core/modules/ckeditor/js/views/KeyboardView.js +++ b/core/modules/ckeditor/js/views/KeyboardView.js @@ -216,7 +216,8 @@ var $group = $(event.currentTarget); var $container = $group.parent(); var $siblings = $container.children(); - var index, dir; + var index; + var dir; // Move groups between sibling groups. if (_.indexOf(leftRightKeys, event.keyCode) > -1) { index = $siblings.index($group); diff --git a/core/modules/color/color.js b/core/modules/color/color.js index a44f49f6200622a23e62fc85e9c022463b242534..afb4dd4af9c028779c68bc83f3dcda22d0a4260d 100644 --- a/core/modules/color/color.js +++ b/core/modules/color/color.js @@ -9,7 +9,9 @@ Drupal.behaviors.color = { attach: function (context, settings) { - var i, j, colors; + var i; + var j; + var colors; // This behavior attaches by ID, so is only valid once on a page. var form = $(context).find('#system-theme-settings .color-form').once('color'); if (form.length === 0) { @@ -56,7 +58,8 @@ // Set up colorScheme selector. form.find('#edit-scheme').on('change', function () { - var schemes = settings.color.schemes, colorScheme = this.options[this.selectedIndex].value; + var schemes = settings.color.schemes; + var colorScheme = this.options[this.selectedIndex].value; if (colorScheme !== '' && schemes[colorScheme]) { // Get colors of active scheme. colors = schemes[colorScheme]; diff --git a/core/modules/color/preview.js b/core/modules/color/preview.js index 4c99ffa15239d5053a9ee83761b7b8f901a3c553..84cf2aa3f26d964ed751663ddafe155437ffdaf3 100644 --- a/core/modules/color/preview.js +++ b/core/modules/color/preview.js @@ -9,7 +9,8 @@ Drupal.color = { callback: function (context, settings, form, farb, height, width) { - var accum, delta; + var accum; + var delta; // Solid background. form.find('#preview').css('backgroundColor', form.find('#palette input[name="palette[base]"]').val()); @@ -27,7 +28,8 @@ } // Set up gradients if there are some. - var color_start, color_end; + var color_start; + var color_end; for (var i in settings.gradients) { if (settings.gradients.hasOwnProperty(i)) { color_start = farb.unpack(form.find('#palette input[name="palette[' + settings.gradients[i].colors[0] + ']"]').val()); diff --git a/core/modules/content_translation/content_translation.admin.js b/core/modules/content_translation/content_translation.admin.js index 1f4224befe0e966d88968bf34a102168da737412..857cbd75a3ec7654cf77d506c11b6f79d8e0ffff 100644 --- a/core/modules/content_translation/content_translation.admin.js +++ b/core/modules/content_translation/content_translation.admin.js @@ -9,7 +9,8 @@ attach: function (context) { var $context = $(context); var options = drupalSettings.contentTranslationDependentOptions; - var $fields, dependent_columns; + var $fields; + var dependent_columns; function fieldsChangeHandler($fields, dependent_columns) { return function (e) { diff --git a/core/modules/editor/js/editor.admin.js b/core/modules/editor/js/editor.admin.js index cbd15103a511f6bbffe39b7b5e50c5ad9960e1ec..7c54759e8111624b5d6ea0e249652638a4e47788 100644 --- a/core/modules/editor/js/editor.admin.js +++ b/core/modules/editor/js/editor.admin.js @@ -293,8 +293,8 @@ // Check if a tag in the universe is forbidden. var allRequiredTags = _.keys(universe); - var filterRule, i; - for (i = 0; i < filterStatus.rules.length; i++) { + var filterRule; + for (var i = 0; i < filterStatus.rules.length; i++) { filterRule = filterStatus.rules[i]; if (filterRule.allow === false) { if (_.intersection(allRequiredTags, filterRule.tags).length > 0) { @@ -305,16 +305,15 @@ // Check if a property value of a tag in the universe is forbidden. // For all filter rules… - var j, k; - for (i = 0; i < filterStatus.rules.length; i++) { - filterRule = filterStatus.rules[i]; + for (var n = 0; n < filterStatus.rules.length; n++) { + filterRule = filterStatus.rules[n]; // … if there are tags with restricted property values … if (filterRule.restrictedTags.tags.length && !emptyProperties(filterRule.restrictedTags.forbidden)) { // … for all those tags … - for (j = 0; j < filterRule.restrictedTags.tags.length; j++) { + for (var j = 0; j < filterRule.restrictedTags.tags.length; j++) { var tag = filterRule.restrictedTags.tags[j]; // … then iterate over all properties … - for (k = 0; k < properties.length; k++) { + for (var k = 0; k < properties.length; k++) { var property = properties[k]; // … and return true if just one of the forbidden property values // for this tag and property is listed in the universe. @@ -339,12 +338,13 @@ var properties = ['attributes', 'styles', 'classes']; // Check if a tag in the universe is allowed. - var filterRule, tag, i, j; - for (i = 0; !_.isEmpty(universe) && i < filterStatus.rules.length; i++) { - filterRule = filterStatus.rules[i]; + var filterRule; + var tag; + for (var l = 0; !_.isEmpty(universe) && l < filterStatus.rules.length; l++) { + filterRule = filterStatus.rules[l]; if (filterRule.allow === true) { - for (j = 0; !_.isEmpty(universe) && j < filterRule.tags.length; j++) { - tag = filterRule.tags[j]; + for (var m = 0; !_.isEmpty(universe) && m < filterRule.tags.length; m++) { + tag = filterRule.tags[m]; if (_.has(universe, tag)) { universe[tag].tag = true; deleteFromUniverseIfAllowed(universe, tag); @@ -355,16 +355,15 @@ // Check if a property value of a tag in the universe is allowed. // For all filter rules… - var k; - for (i = 0; !_.isEmpty(universe) && i < filterStatus.rules.length; i++) { + for (var i = 0; !_.isEmpty(universe) && i < filterStatus.rules.length; i++) { filterRule = filterStatus.rules[i]; // … if there are tags with restricted property values … if (filterRule.restrictedTags.tags.length && !emptyProperties(filterRule.restrictedTags.allowed)) { // … for all those tags … - for (j = 0; !_.isEmpty(universe) && j < filterRule.restrictedTags.tags.length; j++) { + for (var j = 0; !_.isEmpty(universe) && j < filterRule.restrictedTags.tags.length; j++) { tag = filterRule.restrictedTags.tags[j]; // … then iterate over all properties … - for (k = 0; k < properties.length; k++) { + for (var k = 0; k < properties.length; k++) { var property = properties[k]; // … and try to delete this tag from the universe if just one of // the allowed property values for this tag and property is listed diff --git a/core/modules/filter/filter.filter_html.admin.js b/core/modules/filter/filter.filter_html.admin.js index a74b938e7c633fc4b1e3b19f5696aa4f466c57ee..a2a20405faa48d841202a93c4713c87cfcc6f80b 100644 --- a/core/modules/filter/filter.filter_html.admin.js +++ b/core/modules/filter/filter.filter_html.admin.js @@ -15,7 +15,8 @@ Drupal.filterConfiguration.liveSettingParsers.filter_html = { getRules: function () { var currentValue = $('#edit-filters-filter-html-settings-allowed-html').val(); - var rules = [], rule; + var rules = []; + var rule; // Build a FilterHTMLRule that reflects the hard-coded behavior that // strips all "style" attribute and all "on*" attributes. diff --git a/core/modules/locale/locale.admin.js b/core/modules/locale/locale.admin.js index fc310cf842b3aaedff1d506279d3b8d07158996f..9c32c5e547d83b32857e107e23d90ed38e92fffb 100644 --- a/core/modules/locale/locale.admin.js +++ b/core/modules/locale/locale.admin.js @@ -17,10 +17,9 @@ }); // Highlight changed row. $form.on('formUpdated.localeTranslateDirty', 'tr', function () { - var - $row = $(this), - $rowToMark = $row.once('localemark'), - marker = Drupal.theme('localeTranslateChangedMarker'); + var $row = $(this); + var $rowToMark = $row.once('localemark'); + var marker = Drupal.theme('localeTranslateChangedMarker'); $row.addClass('changed'); // Add an asterisk only once if row changed. diff --git a/core/modules/node/node.js b/core/modules/node/node.js index 60db08f07b74185b96666ce1d9eff952c179759e..cf0f979fa7620d2401e2105609b7b33d722488d3 100644 --- a/core/modules/node/node.js +++ b/core/modules/node/node.js @@ -27,8 +27,8 @@ $context.find('.node-form-author').drupalSetSummary(function (context) { var $authorContext = $(context); - var name = $authorContext.find('.field-name-uid input').val(), - date = $authorContext.find('.field-name-created input').val(); + var name = $authorContext.find('.field-name-uid input').val(); + var date = $authorContext.find('.field-name-created input').val(); return date ? Drupal.t('By @name on @date', {'@name': name, '@date': date}) : Drupal.t('By @name', {'@name': name}); diff --git a/core/modules/quickedit/js/views/AppView.js b/core/modules/quickedit/js/views/AppView.js index c911da5f582da0fbb8ec359516d17d2ecfa07800..a5873d62bfb0d1ce0e0f1dfbe84f4fa861d2832a 100644 --- a/core/modules/quickedit/js/views/AppView.js +++ b/core/modules/quickedit/js/views/AppView.js @@ -175,7 +175,8 @@ // If it's not against the general principle, then here are more // disallowed cases to check. if (accept) { - var activeField, activeFieldState; + var activeField; + var activeFieldState; // Ensure only one field (editor) at a time is active … but allow a user // to hop from one field to the next, even if we still have to start // saving the field that is currently active: assume it will be valid, diff --git a/core/modules/quickedit/js/views/EntityToolbarView.js b/core/modules/quickedit/js/views/EntityToolbarView.js index 0cd7f0d42125fe741a165a4d28f2090b5cdbbd6d..e811cb8c1dbf976c8bd3c252bd454c20d57aaac4 100644 --- a/core/modules/quickedit/js/views/EntityToolbarView.js +++ b/core/modules/quickedit/js/views/EntityToolbarView.js @@ -175,7 +175,9 @@ // ignore that padding when positioning the toolbar, to not unnecessarily // move the toolbar horizontally, which feels annoying. var horizontalPadding = 0; - var of, activeField, highlightedField; + var of; + var activeField; + var highlightedField; // There are several elements in the page that the entity toolbar might be // positioned against. They are considered below in a priority order. do { diff --git a/core/modules/quickedit/js/views/FieldDecorationView.js b/core/modules/quickedit/js/views/FieldDecorationView.js index 93549e35efe4e60470f8862ad38a29c1cd32c966..49491da617f9ab0b58a962c76799b3fa7ed88bc7 100644 --- a/core/modules/quickedit/js/views/FieldDecorationView.js +++ b/core/modules/quickedit/js/views/FieldDecorationView.js @@ -297,13 +297,13 @@ * @param DOM $e */ _getPositionProperties: function ($e) { - var p, - r = {}, - props = [ - 'top', 'left', 'bottom', 'right', - 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', - 'margin-bottom' - ]; + var p; + var r = {}; + var props = [ + 'top', 'left', 'bottom', 'right', + 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', + 'margin-bottom' + ]; var propCount = props.length; for (var i = 0; i < propCount; i++) { diff --git a/core/modules/system/system.modules.js b/core/modules/system/system.modules.js index 4964a1a8825a82cd03c405082d45b1bf0d5029f0..45ddf3bf4ea7454d54caff3536a7ae6106062f82 100644 --- a/core/modules/system/system.modules.js +++ b/core/modules/system/system.modules.js @@ -16,7 +16,9 @@ attach: function (context, settings) { var $input = $('input.table-filter-text').once('table-filter-text'); var $table = $($input.attr('data-table')); - var $rowsAndDetails, $rows, $details; + var $rowsAndDetails; + var $rows; + var $details; var searching = false; function hidePackageDetails(index, element) { diff --git a/core/modules/user/user.js b/core/modules/user/user.js index 45f554cf8c0535ccaee2802f18e25e3e0499a8c0..98d1d0e0542bdc72d2df52bcb4066d09e0eaf018 100644 --- a/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -89,7 +89,11 @@ * Returns the estimated strength and the relevant output message. */ Drupal.evaluatePasswordStrength = function (password, translate) { - var indicatorText, indicatorClass, weaknesses = 0, strength = 100, msg = []; + var indicatorText; + var indicatorClass; + var weaknesses = 0; + var strength = 100; + var msg = []; var hasLowercase = /[a-z]+/.test(password); var hasUppercase = /[A-Z]+/.test(password); diff --git a/core/modules/user/user.permissions.js b/core/modules/user/user.permissions.js index d47ee9ac568f4fad8441dbdea9b102c262057c8a..6c28f070e4a33c8e32f86236fc776e237f94124b 100644 --- a/core/modules/user/user.permissions.js +++ b/core/modules/user/user.permissions.js @@ -15,7 +15,8 @@ // performed without triggering internal layout and re-rendering processes // in the browser. var $table = $(this); - var $ancestor, method; + var $ancestor; + var method; if ($table.prev().length) { $ancestor = $table.prev(); method = 'after'; @@ -58,7 +59,8 @@ * checkboxes are shown, the real checkboxes otherwise. */ toggle: function () { - var authCheckbox = this, $row = $(this).closest('tr'); + var authCheckbox = this; + var $row = $(this).closest('tr'); // jQuery performs too many layout calculations for .hide() and .show(), // leading to a major page rendering lag on sites with many roles and // permissions. Therefore, we toggle visibility directly. diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index 7f217dc718200d912f46484059392eaa174f7441..d0534cf77651cf6f4a7c1f997a72cad1ce450180 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -335,10 +335,12 @@ * shown and hidden depending on the user's search terms. */ getOptions: function ($allOptions) { - var i, $label, $description, $option; + var $label; + var $description; + var $option; var options = []; var length = $allOptions.length; - for (i = 0; i < length; i++) { + for (var i = 0; i < length; i++) { $option = $($allOptions[i]); $label = $option.find('label'); $description = $option.find('div.description'); @@ -358,7 +360,9 @@ * Keyup handler for the search box that hides or shows the relevant options. */ handleKeyup: function (event) { - var found, i, j, option, zebraClass; + var found; + var option; + var zebraClass; // Determine the user's search query. The search text has been converted to // lowercase. @@ -371,13 +375,13 @@ // Search through the search texts in the form for matching text. var length = this.options.length; - for (i = 0; i < length; i++) { + for (var i = 0; i < length; i++) { // Use a local variable for the option being searched, for performance. option = this.options[i]; found = true; // Each word in the search string has to match the item in order for the // item to be shown. - for (j = 0; j < wordsLength; j++) { + for (var j = 0; j < wordsLength; j++) { if (option.searchText.indexOf(words[j]) === -1) { found = false; } @@ -559,7 +563,9 @@ * duplicate it between any subsequent groups. */ duplicateGroupsOperator: function () { - var dropdowns, newRow, titleRow; + var dropdowns; + var newRow; + var titleRow; var titleRows = $('tr.views-group-title'); @@ -584,10 +590,10 @@ newRow = $('<tr class="filter-group-operator-row"><td colspan="5"></td></tr>'); newRow.find('td').append(this.operator); newRow.insertBefore(titleRow); - var i, length = titleRows.length; + var length = titleRows.length; // Starting with the third group, copy the operator to a new row above the // group title. - for (i = 2; i < length; i++) { + for (var i = 2; i < length; i++) { titleRow = $(titleRows[i]); // Make a copy of the operator dropdown and put it in a new table row. var fakeOperator = this.operator.clone(); @@ -741,10 +747,13 @@ * Update the rowspan attribute of each cell containing an operator dropdown. */ updateRowspans: function () { - var i, $row, $currentEmptyRow, draggableCount, $operatorCell; + var $row; + var $currentEmptyRow; + var draggableCount; + var $operatorCell; var rows = $(this.table).find('tr'); var length = rows.length; - for (i = 0; i < length; i++) { + for (var i = 0; i < length; i++) { $row = $(rows[i]); if ($row.hasClass('views-group-title')) { // This row is a title row.