diff --git a/src/CategoryOverpass.js b/src/CategoryOverpass.js index 7bb52d12..d92d4a4b 100644 --- a/src/CategoryOverpass.js +++ b/src/CategoryOverpass.js @@ -11,8 +11,7 @@ var tabs = require('modulekit-tabs') var markers = require('./markers') var maki = require('./maki') var qs = require('sheet-router/qs') -var editLink = require('./editLink') -const objectDisplay = require('./objectDisplay') +const ObjectDisplay = require('./ObjectDisplay') const showMore = require('./showMore') @@ -54,13 +53,6 @@ var defaultValues = { preferredZoom: 16 }, layouts: { - popup: - '
' + - '{% if object.popupDetails or object.details %}
{{ object.popupDetails|default(object.details) }}
{% endif %}' + - '{% if object.popupDescription or object.description %}
{{ object.popupDescription|default(object.description) }}
{% endif %}' + - '{% if object.popupTitle or object.title %}
{{ object.popupTitle|default(object.title) }}
{% endif %}' + - '
' + - '
{{ object.popupBody|default(object.body) }}
', list: listTemplate.replace(/template/g, 'list') }, queryOptions: { @@ -108,6 +100,7 @@ function CategoryOverpass (options, data, repository) { data.styleNoBindPopup = [ 'selected' ] data.stylesNoAutoShow = [ 'selected' ] data.updateAssets = this.updateAssets.bind(this) + data.layouts.popup = () => null this.layer = new OverpassLayer(data) @@ -132,11 +125,6 @@ function CategoryOverpass (options, data, repository) { return } - this.updatePopupContent(ob, ob.popup) - - // Move close button into the content, to make its position depending whether a scrollbar is visible or not - ob.popup._contentNode.insertBefore(ob.popup._closeButton, ob.popup._contentNode.firstChild) - this.emit('update', object, ob) }.bind(this)) this.layer.on('add', (ob, data) => this.emit('add', ob, data)) @@ -535,26 +523,9 @@ CategoryOverpass.prototype.notifyPopupOpen = function (object, popup) { popup._contentNode.style = '' } - this.updatePopupContent(object, popup) this.currentSelected = this.layer.show(object.id, layerOptions, function () {}) -} - -CategoryOverpass.prototype.notifyPopupClose = function (object, popup) { - if (this.currentSelected) { - this.currentSelected.hide() - this.currentSelected = null - } - - if (this.currentDetails) { - this.currentDetails.hide() - this.currentDetails = null - } -} - -CategoryOverpass.prototype.updatePopupContent = function (object, popup) { - let id_with_sublayer = (object.sublayer_id === 'main' ? '' : object.sublayer_id + ':') + object.id - objectDisplay({ + this.currentPopupDisplay = new ObjectDisplay({ feature: object, category: this, dom: popup._contentNode, @@ -563,49 +534,25 @@ CategoryOverpass.prototype.updatePopupContent = function (object, popup) { console.log('popup done') }) - /* - if (this.popupBodyTemplate) { - let popupBody = popup._contentNode.querySelector('#popupBody') - if (!popupBody) { - popupBody = document.createElement('div') - popupBody.className = 'popupBody' - popupBody.id = 'popupBody' - popup._contentNode.appendChild(popupBody) - } - - let html = this.popupBodyTemplate.render(object.twigData) - if (popupBody.currentHTML !== html) { - popupBody.innerHTML = html - this.updateAssets(popup._contentNode) - } + // Move close button into the content, to make its position depending whether a scrollbar is visible or not + popup._contentNode.insertBefore(popup._closeButton, popup._contentNode.firstChild) +} - popupBody.currentHTML = html +CategoryOverpass.prototype.notifyPopupClose = function (object, popup) { + if (this.currentSelected) { + this.currentSelected.hide() + this.currentSelected = null } - let hasBody = false - Array.from(popup._contentNode.querySelectorAll('.popupBody')).forEach(div => { - if (!div.innerHTML.match(/^\s*(