diff --git a/origo.js b/origo.js index 7a72cfcaf..5bde6a1a1 100644 --- a/origo.js +++ b/origo.js @@ -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 */ @@ -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; diff --git a/src/components/infowindow.js b/src/components/infowindow.js index ff914ef88..c876e9f68 100644 --- a/src/components/infowindow.js +++ b/src/components/infowindow.js @@ -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() { @@ -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()); @@ -51,12 +63,16 @@ const Infowindow = function Infowindow(options = {}) { return Component({ name: 'infowindow', close, + show, + getStatus() { return isActive }, changeContent, + getContentElement, onAdd() { this.on('render', this.onRender); this.render(); }, onInit() { + iwCmp = this; let iwElCls = isActive ? '' : ' faded'; let iwElStyle = ''; let hcElCls = '';