summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2017-10-21 20:49:45 (GMT)
committerAlex Pott2017-10-21 20:49:45 (GMT)
commit27266234c20ebc2bc61f51ce0df36349e35137e5 (patch)
treee7c5aa20bab57aa2a3d8da8406c087211eaa3698
parent169e867159f93895763d62f4f77cd36ac8cbe78d (diff)
Revert "Issue #2916154 by drpal, dawehner, xjm: JS codestyle: no-multi-assign"
This reverts commit 169e867159f93895763d62f4f77cd36ac8cbe78d.
-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, 42 insertions, 54 deletions
diff --git a/core/.eslintrc.passing.json b/core/.eslintrc.passing.json
index 8489a7d..db5f24e 100644
--- a/core/.eslintrc.passing.json
+++ b/core/.eslintrc.passing.json
@@ -7,6 +7,7 @@
"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 6ac09f4..0424d80 100644
--- a/core/misc/displace.es6.js
+++ b/core/misc/displace.es6.js
@@ -73,8 +73,7 @@
* @fires event:drupalViewportOffsetChange
*/
function displace(broadcast) {
- offsets = calculateOffsets();
- Drupal.displace.offsets = offsets;
+ offsets = Drupal.displace.offsets = calculateOffsets();
if (typeof broadcast === 'undefined' || broadcast) {
$(document).trigger('drupalViewportOffsetChange', offsets);
}
diff --git a/core/misc/displace.js b/core/misc/displace.js
index 777aee4..890548f 100644
--- a/core/misc/displace.js
+++ b/core/misc/displace.js
@@ -25,8 +25,7 @@
};
function displace(broadcast) {
- offsets = calculateOffsets();
- Drupal.displace.offsets = offsets;
+ offsets = Drupal.displace.offsets = calculateOffsets();
if (typeof broadcast === 'undefined' || broadcast) {
$(document).trigger('drupalViewportOffsetChange', offsets);
}
diff --git a/core/misc/states.es6.js b/core/misc/states.es6.js
index ec7a4e7..fbf8db7 100644
--- a/core/misc/states.es6.js
+++ b/core/misc/states.es6.js
@@ -12,7 +12,7 @@
*
* @namespace Drupal.states
*/
- const states = {
+ const states = Drupal.states = {
/**
* An array of functions that should be postponed.
@@ -20,8 +20,6 @@
postponed: [],
};
- Drupal.states = states;
-
/**
* Attaches the states.
*
@@ -510,8 +508,7 @@
/**
* Original unresolved name.
*/
- this.pristine = state;
- this.name = state;
+ this.pristine = this.name = state;
// Normalize the state name.
let process = true;
diff --git a/core/misc/states.js b/core/misc/states.js
index 2b9d3b8..61bbf46 100644
--- a/core/misc/states.js
+++ b/core/misc/states.js
@@ -6,12 +6,10 @@
**/
(function ($, Drupal) {
- var states = {
+ var states = Drupal.states = {
postponed: []
};
- Drupal.states = states;
-
Drupal.behaviors.states = {
attach: function attach(context, settings) {
var $states = $(context).find('[data-drupal-states]');
@@ -261,8 +259,7 @@
};
states.State = function (state) {
- this.pristine = state;
- this.name = state;
+ this.pristine = this.name = state;
var process = true;
do {
diff --git a/core/misc/tabledrag.es6.js b/core/misc/tabledrag.es6.js
index abbe193..ce621da 100644
--- a/core/misc/tabledrag.es6.js
+++ b/core/misc/tabledrag.es6.js
@@ -1107,16 +1107,14 @@
const de = document.documentElement;
const b = document.body;
- const windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
- this.windowHeight = windowHeight;
+ const windowHeight = this.windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
let scrollY;
if (document.all) {
- scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
+ scrollY = this.scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
}
else {
- scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
+ scrollY = this.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 859b87e..e828bfe 100644
--- a/core/misc/tabledrag.js
+++ b/core/misc/tabledrag.js
@@ -701,15 +701,13 @@
var de = document.documentElement;
var b = document.body;
- var windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
- this.windowHeight = windowHeight;
+ var windowHeight = this.windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
var scrollY = void 0;
if (document.all) {
- scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
+ scrollY = this.scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
} else {
- scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
+ scrollY = this.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 c875fd6..5a2828c 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.
- Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
+ const 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: Drupal.ckeditor.models.Model,
+ 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 c3b62ec..f51341d 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);
- Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
+ var model = Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
$textarea: $textarea,
activeEditorConfig: JSON.parse($textarea.val()),
hiddenEditorConfig: drupalSettings.ckeditor.hiddenCKEditorConfig
});
var viewDefaults = {
- model: Drupal.ckeditor.models.Model,
+ model: 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 9538288..7d0ae12 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;
- contextualToolbar.model = new contextualToolbar.StateModel({
+ const model = 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: contextualToolbar.model,
+ 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 3b026d7..b565f21 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;
- contextualToolbar.model = new contextualToolbar.StateModel({
+ var model = 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: contextualToolbar.model,
+ model: 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 be658d3..1950b47 100644
--- a/core/modules/quickedit/js/editors/formEditor.es6.js
+++ b/core/modules/quickedit/js/editors/formEditor.es6.js
@@ -95,11 +95,10 @@
const id = `quickedit-form-for-${fieldModel.id.replace(/[\/\[\]]/g, '_')}`;
// Render form container.
- const $formContainer = $(Drupal.theme('quickeditFormContainer', {
+ const $formContainer = this.$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 c4d8750..6ff6990 100644
--- a/core/modules/quickedit/js/editors/formEditor.js
+++ b/core/modules/quickedit/js/editors/formEditor.js
@@ -59,11 +59,10 @@
var id = 'quickedit-form-for-' + fieldModel.id.replace(/[\/\[\]]/g, '_');
- var $formContainer = $(Drupal.theme('quickeditFormContainer', {
+ var $formContainer = this.$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 92e5a5d..bb4bb3c 100644
--- a/core/modules/quickedit/js/editors/plainTextEditor.es6.js
+++ b/core/modules/quickedit/js/editors/plainTextEditor.es6.js
@@ -27,9 +27,14 @@
// Store the original value of this field. Necessary for reverting
// changes.
+ let $textElement;
const $fieldItems = this.$el.find('.quickedit-field');
- const $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el;
- this.$textElement = $textElement;
+ if ($fieldItems.length) {
+ $textElement = this.$textElement = $fieldItems.eq(0);
+ }
+ else {
+ $textElement = this.$textElement = this.$el;
+ }
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 dde834b..e6f5afd 100644
--- a/core/modules/quickedit/js/editors/plainTextEditor.js
+++ b/core/modules/quickedit/js/editors/plainTextEditor.js
@@ -15,9 +15,13 @@
var editorModel = this.model;
var fieldModel = this.fieldModel;
+ var $textElement = void 0;
var $fieldItems = this.$el.find('.quickedit-field');
- var $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el;
- this.$textElement = $textElement;
+ if ($fieldItems.length) {
+ $textElement = this.$textElement = $fieldItems.eq(0);
+ } else {
+ $textElement = this.$textElement = this.$el;
+ }
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 f715fc7..4fdf090 100644
--- a/core/modules/toolbar/js/toolbar.es6.js
+++ b/core/modules/toolbar/js/toolbar.es6.js
@@ -46,21 +46,18 @@
// Process the administrative toolbar.
$(context).find('#toolbar-administration').once('toolbar').each(function () {
// Establish the toolbar models and views.
- const model = new Drupal.toolbar.ToolbarModel({
+ const model = Drupal.toolbar.models.toolbarModel = 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 = window.matchMedia(mq);
- Drupal.toolbar.mql[label] = mql;
+ const mql = Drupal.toolbar.mql[label] = window.matchMedia(mq);
// Curry the model and the label of the media query breakpoint to
// the mediaQueryChangeHandler function.
mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
@@ -91,8 +88,7 @@
model.trigger('change:activeTray', model, model.get('activeTray'));
// Render collapsible menus.
- const menuModel = new Drupal.toolbar.MenuModel();
- Drupal.toolbar.models.menuModel = menuModel;
+ const menuModel = Drupal.toolbar.models.menuModel = new Drupal.toolbar.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 547bcd9..4f4ff59 100644
--- a/core/modules/toolbar/js/toolbar.js
+++ b/core/modules/toolbar/js/toolbar.js
@@ -26,19 +26,16 @@
}
$(context).find('#toolbar-administration').once('toolbar').each(function () {
- var model = new Drupal.toolbar.ToolbarModel({
+ var model = Drupal.toolbar.models.toolbarModel = 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 = window.matchMedia(mq);
- Drupal.toolbar.mql[label] = mql;
+ var mql = Drupal.toolbar.mql[label] = window.matchMedia(mq);
mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
@@ -64,8 +61,7 @@
model.trigger('change:isFixed', model, model.get('isFixed'));
model.trigger('change:activeTray', model, model.get('activeTray'));
- var menuModel = new Drupal.toolbar.MenuModel();
- Drupal.toolbar.models.menuModel = menuModel;
+ var menuModel = Drupal.toolbar.models.menuModel = new Drupal.toolbar.MenuModel();
Drupal.toolbar.views.menuVisualView = new Drupal.toolbar.MenuVisualView({
el: $(this).find('.toolbar-menu-administration').get(0),
model: menuModel,