add CSS class name support for attribution button

This commit is contained in:
Mihai CAZACU
2020-08-06 20:06:28 +03:00
parent fe3295b469
commit ebf0d87aa8
2 changed files with 18 additions and 2 deletions

View File

@@ -23,9 +23,13 @@ import {removeChildren, replaceNode} from '../dom.js';
* @property {string} [label='i'] Text label to use for the
* collapsed attributions button.
* Instead of text, also an element (e.g. a `span` element) can be used.
* @property {string} [expandClassName==className + '-expand'] CSS class name for the
* collapsed attributions button.
* @property {string|HTMLElement} [collapseLabel='»'] Text label to use
* for the expanded attributions button.
* Instead of text, also an element (e.g. a `span` element) can be used.
* @property {string} [collapseClassName==className + '-collapse'] CSS class name for the
* expanded attributions button.
* @property {function(import("../MapEvent.js").default):void} [render] Function called when
* the control should be re-rendered. This is called in a `requestAnimationFrame`
* callback.
@@ -89,9 +93,19 @@ class Attribution extends Control {
const tipLabel =
options.tipLabel !== undefined ? options.tipLabel : 'Attributions';
const expandClassName =
options.expandClassName !== undefined
? options.expandClassName
: (className + '-expand');
const collapseLabel =
options.collapseLabel !== undefined ? options.collapseLabel : '\u00BB';
const collapseClassName =
options.collapseClassName !== undefined
? options.collapseClassName
: (className + '-collpase');
if (typeof collapseLabel === 'string') {
/**
* @private
@@ -99,6 +113,7 @@ class Attribution extends Control {
*/
this.collapseLabel_ = document.createElement('span');
this.collapseLabel_.textContent = collapseLabel;
this.collapseLabel_.className = collapseClassName;
} else {
this.collapseLabel_ = collapseLabel;
}
@@ -112,6 +127,7 @@ class Attribution extends Control {
*/
this.label_ = document.createElement('span');
this.label_.textContent = label;
this.label_.className = expandClassName;
} else {
this.label_ = label;
}

View File

@@ -51,11 +51,11 @@ class Zoom extends Control {
const zoomInClassName =
options.zoomInClassName !== undefined
? options.zoomInClassName
: className + '-in';
: (className + '-in');
const zoomOutClassName =
options.zoomOutClassName !== undefined
? options.zoomOutClassName
: className + '-out';
: (className + '-out');
const zoomInLabel =
options.zoomInLabel !== undefined ? options.zoomInLabel : '+';