Add and use a constant for the collapsed CSS class

This commit is contained in:
Marc Jansen
2018-02-15 18:27:07 +01:00
parent a01b38bc36
commit 0aac821633
3 changed files with 16 additions and 6 deletions

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import {equals} from '../array.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 {listen} from '../events.js';
import EventType from '../events/EventType.js';
@@ -90,7 +90,7 @@ const Attribution = function(opt_options) {
listen(button, EventType.CLICK, this.handleClick_, this);
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
(this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') +
(this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
(this.collapsible_ ? '' : ' ol-uncollapsible');
const element = document.createElement('div');
element.className = cssClasses;
@@ -246,7 +246,7 @@ Attribution.prototype.handleClick_ = function(event) {
* @private
*/
Attribution.prototype.handleToggle_ = function() {
this.element.classList.toggle('ol-collapsed');
this.element.classList.toggle(CLASS_COLLAPSED);
if (this.collapsed_) {
replaceNode(this.collapseLabel_, this.label_);
} else {