Commit 169e8671 authored by alexpott's avatar alexpott

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

parent 2f1622a8
......@@ -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",
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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 {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 = {
......
......@@ -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 = {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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')
......
......@@ -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') {
......
......@@ -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.
......
......@@ -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');
......
......@@ -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,
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment