Add and use a constant for the collapsed CSS class
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
import {inherits} from '../index.js';
|
import {inherits} from '../index.js';
|
||||||
import {equals} from '../array.js';
|
import {equals} from '../array.js';
|
||||||
import Control from '../control/Control.js';
|
import Control from '../control/Control.js';
|
||||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_COLLAPSED} from '../css.js';
|
||||||
import {removeChildren, replaceNode} from '../dom.js';
|
import {removeChildren, replaceNode} from '../dom.js';
|
||||||
import {listen} from '../events.js';
|
import {listen} from '../events.js';
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
@@ -90,7 +90,7 @@ const Attribution = function(opt_options) {
|
|||||||
listen(button, EventType.CLICK, this.handleClick_, this);
|
listen(button, EventType.CLICK, this.handleClick_, this);
|
||||||
|
|
||||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||||
(this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') +
|
(this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
|
||||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('div');
|
||||||
element.className = cssClasses;
|
element.className = cssClasses;
|
||||||
@@ -246,7 +246,7 @@ Attribution.prototype.handleClick_ = function(event) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Attribution.prototype.handleToggle_ = function() {
|
Attribution.prototype.handleToggle_ = function() {
|
||||||
this.element.classList.toggle('ol-collapsed');
|
this.element.classList.toggle(CLASS_COLLAPSED);
|
||||||
if (this.collapsed_) {
|
if (this.collapsed_) {
|
||||||
replaceNode(this.collapseLabel_, this.label_);
|
replaceNode(this.collapseLabel_, this.label_);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import OverlayPositioning from '../OverlayPositioning.js';
|
|||||||
import ViewProperty from '../ViewProperty.js';
|
import ViewProperty from '../ViewProperty.js';
|
||||||
import Control from '../control/Control.js';
|
import Control from '../control/Control.js';
|
||||||
import {rotate as rotateCoordinate, add as addCoordinate} from '../coordinate.js';
|
import {rotate as rotateCoordinate, add as addCoordinate} from '../coordinate.js';
|
||||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_COLLAPSED} from '../css.js';
|
||||||
import {replaceNode} from '../dom.js';
|
import {replaceNode} from '../dom.js';
|
||||||
import {listen, listenOnce, unlisten} from '../events.js';
|
import {listen, listenOnce, unlisten} from '../events.js';
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
@@ -150,7 +150,7 @@ const OverviewMap = function(opt_options) {
|
|||||||
this.ovmap_.addOverlay(this.boxOverlay_);
|
this.ovmap_.addOverlay(this.boxOverlay_);
|
||||||
|
|
||||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||||
(this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') +
|
(this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
|
||||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('div');
|
||||||
element.className = cssClasses;
|
element.className = cssClasses;
|
||||||
@@ -491,7 +491,7 @@ OverviewMap.prototype.handleClick_ = function(event) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
OverviewMap.prototype.handleToggle_ = function() {
|
OverviewMap.prototype.handleToggle_ = function() {
|
||||||
this.element.classList.toggle('ol-collapsed');
|
this.element.classList.toggle(CLASS_COLLAPSED);
|
||||||
if (this.collapsed_) {
|
if (this.collapsed_) {
|
||||||
replaceNode(this.collapseLabel_, this.label_);
|
replaceNode(this.collapseLabel_, this.label_);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ export const CLASS_UNSUPPORTED = 'ol-unsupported';
|
|||||||
export const CLASS_CONTROL = 'ol-control';
|
export const CLASS_CONTROL = 'ol-control';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CSS class that we'll give the DOM elements that are collapsed, i.e.
|
||||||
|
* to those elements which usually can be expanded.
|
||||||
|
*
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const CLASS_COLLAPSED = 'ol-collapsed';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of font families from a font spec. Note that this doesn't work
|
* Get the list of font families from a font spec. Note that this doesn't work
|
||||||
* for font families that have commas in them.
|
* for font families that have commas in them.
|
||||||
|
|||||||
Reference in New Issue
Block a user