Revert "Issue #2916154 by drpal, dawehner, xjm: JS codestyle: no-multi-assign"

This reverts commit 169e867159.
8.5.x
Alex Pott 2017-10-21 21:49:45 +01:00
parent 169e867159
commit 27266234c2
17 changed files with 42 additions and 54 deletions

View File

@ -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",

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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);

View File

@ -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);

View File

@ -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')

View File

@ -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') {

View File

@ -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.

View File

@ -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');

View File

@ -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,

View File

@ -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,