summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2017-10-24 12:42:16 (GMT)
committerxjm2017-10-24 12:42:16 (GMT)
commit9032c68faa9ae6c056f75a1197d3966f370cf5ee (patch)
tree8b43237f6ef1191965fc7fee8eef6309060fa4dc
parent97346f0d28ed93abd100c44f5f5016dec2dde83b (diff)
Issue #2916154 by drpal, droplet, dawehner, alexpott, xjm: JS codestyle: no-multi-assign
-rw-r--r--core/.eslintrc.passing.json1
-rw-r--r--core/misc/displace.es6.js3
-rw-r--r--core/misc/displace.js3
-rw-r--r--core/misc/states.es6.js7
-rw-r--r--core/misc/states.js7
-rw-r--r--core/misc/tabledrag.es6.js8
-rw-r--r--core/misc/tabledrag.js8
-rw-r--r--core/modules/ckeditor/js/ckeditor.admin.es6.js4
-rw-r--r--core/modules/ckeditor/js/ckeditor.admin.js4
-rw-r--r--core/modules/contextual/js/contextual.toolbar.es6.js4
-rw-r--r--core/modules/contextual/js/contextual.toolbar.js4
-rw-r--r--core/modules/quickedit/js/editors/formEditor.es6.js3
-rw-r--r--core/modules/quickedit/js/editors/formEditor.js3
-rw-r--r--core/modules/quickedit/js/editors/plainTextEditor.es6.js9
-rw-r--r--core/modules/quickedit/js/editors/plainTextEditor.js8
-rw-r--r--core/modules/toolbar/js/toolbar.es6.js10
-rw-r--r--core/modules/toolbar/js/toolbar.js10
17 files changed, 54 insertions, 42 deletions
diff --git a/core/.eslintrc.passing.json b/core/.eslintrc.passing.json
index db5f24e..8489a7d 100644
--- a/core/.eslintrc.passing.json
+++ b/core/.eslintrc.passing.json
@@ -7,7 +7,6 @@
"no-shadow": "off",
"no-restricted-syntax": "off",
"no-new": "off",
- "no-multi-assign": "off",
"no-continue": "off",
"new-cap": "off",
"max-len": "off",
diff --git a/core/misc/displace.es6.js b/core/misc/displace.es6.js
index 0424d80..6ac09f4 100644
--- a/core/misc/displace.es6.js
+++ b/core/misc/displace.es6.js
@@ -73,7 +73,8 @@
* @fires event:drupalViewportOffsetChange
*/
function displace(broadcast) {
- offsets = Drupal.displace.offsets = calculateOffsets();
+ offsets = calculateOffsets();
+ Drupal.displace.offsets = offsets;
if (typeof broadcast === 'undefined' || broadcast) {
$(document).trigger('drupalViewportOffsetChange', offsets);
}
diff --git a/core/misc/displace.js b/core/misc/displace.js
index 890548f..777aee4 100644
--- a/core/misc/displace.js
+++ b/core/misc/displace.js
@@ -25,7 +25,8 @@
};
function displace(broadcast) {
- offsets = Drupal.displace.offsets = calculateOffsets();
+ offsets = calculateOffsets();
+ Drupal.displace.offsets = offsets;
if (typeof broadcast === 'undefined' || broadcast) {
$(document).trigger('drupalViewportOffsetChange', offsets);
}
diff --git a/core/misc/states.es6.js b/core/misc/states.es6.js
index fbf8db7..ec7a4e7 100644
--- a/core/misc/states.es6.js
+++ b/core/misc/states.es6.js
@@ -12,7 +12,7 @@
*
* @namespace Drupal.states
*/
- const states = Drupal.states = {
+ const states = {
/**
* An array of functions that should be postponed.
@@ -20,6 +20,8 @@
postponed: [],
};
+ Drupal.states = states;
+
/**
* Attaches the states.
*
@@ -508,7 +510,8 @@
/**
* Original unresolved name.
*/
- this.pristine = this.name = state;
+ this.pristine = state;
+ this.name = state;
// Normalize the state name.
let process = true;
diff --git a/core/misc/states.js b/core/misc/states.js
index 61bbf46..2b9d3b8 100644
--- a/core/misc/states.js
+++ b/core/misc/states.js
@@ -6,10 +6,12 @@
**/
(function ($, Drupal) {
- var states = Drupal.states = {
+ var states = {
postponed: []
};
+ Drupal.states = states;
+
Drupal.behaviors.states = {
attach: function attach(context, settings) {
var $states = $(context).find('[data-drupal-states]');
@@ -259,7 +261,8 @@
};
states.State = function (state) {
- this.pristine = this.name = state;
+ this.pristine = state;
+ this.name = state;
var process = true;
do {
diff --git a/core/misc/tabledrag.es6.js b/core/misc/tabledrag.es6.js
index ce621da..abbe193 100644
--- a/core/misc/tabledrag.es6.js
+++ b/core/misc/tabledrag.es6.js
@@ -1107,14 +1107,16 @@
const de = document.documentElement;
const b = document.body;
- const windowHeight = this.windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
+ const windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
+ this.windowHeight = windowHeight;
let scrollY;
if (document.all) {
- scrollY = this.scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
+ scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
}
else {
- scrollY = this.scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
+ scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
}
+ this.scrollY = scrollY;
const trigger = this.scrollSettings.trigger;
let delta = 0;
diff --git a/core/misc/tabledrag.js b/core/misc/tabledrag.js
index e828bfe..859b87e 100644
--- a/core/misc/tabledrag.js
+++ b/core/misc/tabledrag.js
@@ -701,13 +701,15 @@
var de = document.documentElement;
var b = document.body;
- var windowHeight = this.windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
+ var windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
+ this.windowHeight = windowHeight;
var scrollY = void 0;
if (document.all) {
- scrollY = this.scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
+ scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
} else {
- scrollY = this.scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
+ scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
}
+ this.scrollY = scrollY;
var trigger = this.scrollSettings.trigger;
var delta = 0;
diff --git a/core/modules/ckeditor/js/ckeditor.admin.es6.js b/core/modules/ckeditor/js/ckeditor.admin.es6.js
index 5a2828c..c875fd6 100644
--- a/core/modules/ckeditor/js/ckeditor.admin.es6.js
+++ b/core/modules/ckeditor/js/ckeditor.admin.es6.js
@@ -34,7 +34,7 @@
$configurationForm.append(drupalSettings.ckeditor.toolbarAdmin);
// Create a configuration model.
- const model = Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
+ Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
$textarea,
activeEditorConfig: JSON.parse($textarea.val()),
hiddenEditorConfig: drupalSettings.ckeditor.hiddenCKEditorConfig,
@@ -42,7 +42,7 @@
// Create the configuration Views.
const viewDefaults = {
- model,
+ model: Drupal.ckeditor.models.Model,
el: $('.ckeditor-toolbar-configuration'),
};
Drupal.ckeditor.views = {
diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js
index f51341d..c3b62ec 100644
--- a/core/modules/ckeditor/js/ckeditor.admin.js
+++ b/core/modules/ckeditor/js/ckeditor.admin.js
@@ -16,14 +16,14 @@
$configurationForm.append(drupalSettings.ckeditor.toolbarAdmin);
- var model = Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
+ Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
$textarea: $textarea,
activeEditorConfig: JSON.parse($textarea.val()),
hiddenEditorConfig: drupalSettings.ckeditor.hiddenCKEditorConfig
});
var viewDefaults = {
- model: model,
+ model: Drupal.ckeditor.models.Model,
el: $('.ckeditor-toolbar-configuration')
};
Drupal.ckeditor.views = {
diff --git a/core/modules/contextual/js/contextual.toolbar.es6.js b/core/modules/contextual/js/contextual.toolbar.es6.js
index 7d0ae12..9538288 100644
--- a/core/modules/contextual/js/contextual.toolbar.es6.js
+++ b/core/modules/contextual/js/contextual.toolbar.es6.js
@@ -22,7 +22,7 @@
}
const contextualToolbar = Drupal.contextualToolbar;
- const model = contextualToolbar.model = new contextualToolbar.StateModel({
+ contextualToolbar.model = new contextualToolbar.StateModel({
// Checks whether localStorage indicates we should start in edit mode
// rather than view mode.
// @see Drupal.contextualToolbar.VisualView.persist
@@ -33,7 +33,7 @@
const viewOptions = {
el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
- model,
+ model: contextualToolbar.model,
strings,
};
new contextualToolbar.VisualView(viewOptions);
diff --git a/core/modules/contextual/js/contextual.toolbar.js b/core/modules/contextual/js/contextual.toolbar.js
index b565f21..3b026d7 100644
--- a/core/modules/contextual/js/contextual.toolbar.js
+++ b/core/modules/contextual/js/contextual.toolbar.js
@@ -18,7 +18,7 @@
}
var contextualToolbar = Drupal.contextualToolbar;
- var model = contextualToolbar.model = new contextualToolbar.StateModel({
+ contextualToolbar.model = new contextualToolbar.StateModel({
isViewing: localStorage.getItem('Drupal.contextualToolbar.isViewing') !== 'false'
}, {
contextualCollection: Drupal.contextual.collection
@@ -26,7 +26,7 @@
var viewOptions = {
el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
- model: model,
+ model: contextualToolbar.model,
strings: strings
};
new contextualToolbar.VisualView(viewOptions);
diff --git a/core/modules/quickedit/js/editors/formEditor.es6.js b/core/modules/quickedit/js/editors/formEditor.es6.js
index 1950b47..be658d3 100644
--- a/core/modules/quickedit/js/editors/formEditor.es6.js
+++ b/core/modules/quickedit/js/editors/formEditor.es6.js
@@ -95,10 +95,11 @@
const id = `quickedit-form-for-${fieldModel.id.replace(/[\/\[\]]/g, '_')}`;
// Render form container.
- const $formContainer = this.$formContainer = $(Drupal.theme('quickeditFormContainer', {
+ const $formContainer = $(Drupal.theme('quickeditFormContainer', {
id,
loadingMsg: Drupal.t('Loading…'),
}));
+ this.$formContainer = $formContainer;
$formContainer
.find('.quickedit-form')
.addClass('quickedit-editable quickedit-highlighted quickedit-editing')
diff --git a/core/modules/quickedit/js/editors/formEditor.js b/core/modules/quickedit/js/editors/formEditor.js
index 6ff6990..c4d8750 100644
--- a/core/modules/quickedit/js/editors/formEditor.js
+++ b/core/modules/quickedit/js/editors/formEditor.js
@@ -59,10 +59,11 @@
var id = 'quickedit-form-for-' + fieldModel.id.replace(/[\/\[\]]/g, '_');
- var $formContainer = this.$formContainer = $(Drupal.theme('quickeditFormContainer', {
+ var $formContainer = $(Drupal.theme('quickeditFormContainer', {
id: id,
loadingMsg: Drupal.t('Loading…')
}));
+ this.$formContainer = $formContainer;
$formContainer.find('.quickedit-form').addClass('quickedit-editable quickedit-highlighted quickedit-editing').attr('role', 'dialog');
if (this.$el.css('display') === 'inline') {
diff --git a/core/modules/quickedit/js/editors/plainTextEditor.es6.js b/core/modules/quickedit/js/editors/plainTextEditor.es6.js
index bb4bb3c..92e5a5d 100644
--- a/core/modules/quickedit/js/editors/plainTextEditor.es6.js
+++ b/core/modules/quickedit/js/editors/plainTextEditor.es6.js
@@ -27,14 +27,9 @@
// Store the original value of this field. Necessary for reverting
// changes.
- let $textElement;
const $fieldItems = this.$el.find('.quickedit-field');
- if ($fieldItems.length) {
- $textElement = this.$textElement = $fieldItems.eq(0);
- }
- else {
- $textElement = this.$textElement = this.$el;
- }
+ const $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el;
+ this.$textElement = $textElement;
editorModel.set('originalValue', $.trim(this.$textElement.text()));
// Sets the state to 'changed' whenever the value changes.
diff --git a/core/modules/quickedit/js/editors/plainTextEditor.js b/core/modules/quickedit/js/editors/plainTextEditor.js
index e6f5afd..dde834b 100644
--- a/core/modules/quickedit/js/editors/plainTextEditor.js
+++ b/core/modules/quickedit/js/editors/plainTextEditor.js
@@ -15,13 +15,9 @@
var editorModel = this.model;
var fieldModel = this.fieldModel;
- var $textElement = void 0;
var $fieldItems = this.$el.find('.quickedit-field');
- if ($fieldItems.length) {
- $textElement = this.$textElement = $fieldItems.eq(0);
- } else {
- $textElement = this.$textElement = this.$el;
- }
+ var $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el;
+ this.$textElement = $textElement;
editorModel.set('originalValue', $.trim(this.$textElement.text()));
var previousText = editorModel.get('originalValue');
diff --git a/core/modules/toolbar/js/toolbar.es6.js b/core/modules/toolbar/js/toolbar.es6.js
index 4fdf090..f715fc7 100644
--- a/core/modules/toolbar/js/toolbar.es6.js
+++ b/core/modules/toolbar/js/toolbar.es6.js
@@ -46,18 +46,21 @@
// Process the administrative toolbar.
$(context).find('#toolbar-administration').once('toolbar').each(function () {
// Establish the toolbar models and views.
- const model = Drupal.toolbar.models.toolbarModel = new Drupal.toolbar.ToolbarModel({
+ const model = new Drupal.toolbar.ToolbarModel({
locked: JSON.parse(localStorage.getItem('Drupal.toolbar.trayVerticalLocked')),
activeTab: document.getElementById(JSON.parse(localStorage.getItem('Drupal.toolbar.activeTabID'))),
height: $('#toolbar-administration').outerHeight(),
});
+ Drupal.toolbar.models.toolbarModel = model;
+
// Attach a listener to the configured media query breakpoints.
// Executes it before Drupal.toolbar.views to avoid extra rendering.
for (const label in options.breakpoints) {
if (options.breakpoints.hasOwnProperty(label)) {
const mq = options.breakpoints[label];
- const mql = Drupal.toolbar.mql[label] = window.matchMedia(mq);
+ const mql = window.matchMedia(mq);
+ Drupal.toolbar.mql[label] = mql;
// Curry the model and the label of the media query breakpoint to
// the mediaQueryChangeHandler function.
mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
@@ -88,7 +91,8 @@
model.trigger('change:activeTray', model, model.get('activeTray'));
// Render collapsible menus.
- const menuModel = Drupal.toolbar.models.menuModel = new Drupal.toolbar.MenuModel();
+ const menuModel = new Drupal.toolbar.MenuModel();
+ Drupal.toolbar.models.menuModel = menuModel;
Drupal.toolbar.views.menuVisualView = new Drupal.toolbar.MenuVisualView({
el: $(this).find('.toolbar-menu-administration').get(0),
model: menuModel,
diff --git a/core/modules/toolbar/js/toolbar.js b/core/modules/toolbar/js/toolbar.js
index 4f4ff59..547bcd9 100644
--- a/core/modules/toolbar/js/toolbar.js
+++ b/core/modules/toolbar/js/toolbar.js
@@ -26,16 +26,19 @@
}
$(context).find('#toolbar-administration').once('toolbar').each(function () {
- var model = Drupal.toolbar.models.toolbarModel = new Drupal.toolbar.ToolbarModel({
+ var model = new Drupal.toolbar.ToolbarModel({
locked: JSON.parse(localStorage.getItem('Drupal.toolbar.trayVerticalLocked')),
activeTab: document.getElementById(JSON.parse(localStorage.getItem('Drupal.toolbar.activeTabID'))),
height: $('#toolbar-administration').outerHeight()
});
+ Drupal.toolbar.models.toolbarModel = model;
+
for (var label in options.breakpoints) {
if (options.breakpoints.hasOwnProperty(label)) {
var mq = options.breakpoints[label];
- var mql = Drupal.toolbar.mql[label] = window.matchMedia(mq);
+ var mql = window.matchMedia(mq);
+ Drupal.toolbar.mql[label] = mql;
mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
@@ -61,7 +64,8 @@
model.trigger('change:isFixed', model, model.get('isFixed'));
model.trigger('change:activeTray', model, model.get('activeTray'));
- var menuModel = Drupal.toolbar.models.menuModel = new Drupal.toolbar.MenuModel();
+ var menuModel = new Drupal.toolbar.MenuModel();
+ Drupal.toolbar.models.menuModel = menuModel;
Drupal.toolbar.views.menuVisualView = new Drupal.toolbar.MenuVisualView({
el: $(this).find('.toolbar-menu-administration').get(0),
model: menuModel,