Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
/**
|
||||
* @module ol/control/Attribution
|
||||
*/
|
||||
import {equals} from '../array.js';
|
||||
import Control from './Control.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_COLLAPSED} from '../css.js';
|
||||
import {removeChildren, replaceNode} from '../dom.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {CLASS_COLLAPSED, CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
import {equals} from '../array.js';
|
||||
import {inView} from '../layer/Layer.js';
|
||||
|
||||
import {removeChildren, replaceNode} from '../dom.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
@@ -32,7 +31,6 @@ import {inView} from '../layer/Layer.js';
|
||||
* callback.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Control to show all the attributions associated with the layer sources
|
||||
@@ -43,18 +41,16 @@ import {inView} from '../layer/Layer.js';
|
||||
* @api
|
||||
*/
|
||||
class Attribution extends Control {
|
||||
|
||||
/**
|
||||
* @param {Options=} opt_options Attribution options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
super({
|
||||
element: document.createElement('div'),
|
||||
render: options.render || render,
|
||||
target: options.target
|
||||
target: options.target,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -67,7 +63,8 @@ class Attribution extends Control {
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true;
|
||||
this.collapsed_ =
|
||||
options.collapsed !== undefined ? options.collapsed : true;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -79,18 +76,21 @@ class Attribution extends Control {
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.collapsible_ = options.collapsible !== undefined ?
|
||||
options.collapsible : true;
|
||||
this.collapsible_ =
|
||||
options.collapsible !== undefined ? options.collapsible : true;
|
||||
|
||||
if (!this.collapsible_) {
|
||||
this.collapsed_ = false;
|
||||
}
|
||||
|
||||
const className = options.className !== undefined ? options.className : 'ol-attribution';
|
||||
const className =
|
||||
options.className !== undefined ? options.className : 'ol-attribution';
|
||||
|
||||
const tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Attributions';
|
||||
const tipLabel =
|
||||
options.tipLabel !== undefined ? options.tipLabel : 'Attributions';
|
||||
|
||||
const collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00BB';
|
||||
const collapseLabel =
|
||||
options.collapseLabel !== undefined ? options.collapseLabel : '\u00BB';
|
||||
|
||||
if (typeof collapseLabel === 'string') {
|
||||
/**
|
||||
@@ -116,19 +116,27 @@ class Attribution extends Control {
|
||||
this.label_ = label;
|
||||
}
|
||||
|
||||
|
||||
const activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||
this.collapseLabel_ : this.label_;
|
||||
const activeLabel =
|
||||
this.collapsible_ && !this.collapsed_ ? this.collapseLabel_ : this.label_;
|
||||
const button = document.createElement('button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(activeLabel);
|
||||
|
||||
button.addEventListener(EventType.CLICK, this.handleClick_.bind(this), false);
|
||||
button.addEventListener(
|
||||
EventType.CLICK,
|
||||
this.handleClick_.bind(this),
|
||||
false
|
||||
);
|
||||
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||
(this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
|
||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||
const cssClasses =
|
||||
className +
|
||||
' ' +
|
||||
CLASS_UNSELECTABLE +
|
||||
' ' +
|
||||
CLASS_CONTROL +
|
||||
(this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
|
||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||
const element = this.element;
|
||||
element.className = cssClasses;
|
||||
element.appendChild(this.ulElement_);
|
||||
@@ -146,7 +154,6 @@ class Attribution extends Control {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.renderedVisible_ = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +197,10 @@ class Attribution extends Control {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this.overrideCollapsible_ && source.getAttributionsCollapsible() === false) {
|
||||
if (
|
||||
!this.overrideCollapsible_ &&
|
||||
source.getAttributionsCollapsible() === false
|
||||
) {
|
||||
this.setCollapsible(false);
|
||||
}
|
||||
|
||||
@@ -320,7 +330,6 @@ class Attribution extends Control {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the attribution element.
|
||||
* @param {import("../MapEvent.js").default} mapEvent Map event.
|
||||
@@ -330,5 +339,4 @@ export function render(mapEvent) {
|
||||
this.updateElement_(mapEvent.frameState);
|
||||
}
|
||||
|
||||
|
||||
export default Attribution;
|
||||
|
||||
Reference in New Issue
Block a user