Skip to content

Commit

Permalink
Infowindow in origo.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jokd committed Nov 8, 2024
1 parent 0f58c79 commit bc2f574
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions origo.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'drag-drop-touch';
import permalink from './src/permalink/permalink';
import * as Loader from './src/loading';
import Spinner from './src/utils/spinner';
import Infowindow from './src/components/infowindow';

const Origo = function Origo(configPath, options = {}) {
/** Reference to the returned Component */
Expand Down Expand Up @@ -146,6 +147,8 @@ const Origo = function Origo(configPath, options = {}) {
olInteraction.Draw.createBox = createBox;
olGeom.Polygon.fromCircle = fromCircle;
olGeom.Polygon.fromExtent = fromExtent;
Origo.components = {};
Origo.components.Infowindow = Infowindow;
Origo.controls = origoControls;
Origo.extensions = origoExtensions;
Origo.ui = ui;
Expand Down
16 changes: 16 additions & 0 deletions src/components/infowindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ const Infowindow = function Infowindow(options = {}) {
let titleComponent;
let infowindow;
let iwEl;
let iwCmp;
let closeButton;

const toggle = function toggle() {
iwEl.classList.toggle('faded');
isActive = !isActive;
iwCmp.dispatch('toggle');
};

const close = function close() {
Expand All @@ -32,6 +34,16 @@ const Infowindow = function Infowindow(options = {}) {
}
};

const show = function show() {
if (!isActive) {
toggle();
}
};

const getContentElement = function getContentElement() {
return document.getElementById(contentComponent.getId());
};

const changeContent = function changeContent(component, objTitle) {
document.getElementById(titleComponent.getId()).innerHTML = objTitle || title;
const contentEl = document.getElementById(contentComponent.getId());
Expand All @@ -51,12 +63,16 @@ const Infowindow = function Infowindow(options = {}) {
return Component({
name: 'infowindow',
close,
show,
getStatus() { return isActive },

Check failure on line 67 in src/components/infowindow.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
changeContent,
getContentElement,
onAdd() {
this.on('render', this.onRender);
this.render();
},
onInit() {
iwCmp = this;
let iwElCls = isActive ? '' : ' faded';
let iwElStyle = '';
let hcElCls = '';
Expand Down

0 comments on commit bc2f574

Please sign in to comment.