Browse Source

objectDisplay: use common displayBlock function

master
parent
commit
382b24df53
  1. 20
      src/displayBlock.js
  2. 8
      src/exportAll.js
  3. 34
      src/objectDisplay.js

20
src/displayBlock.js

@ -0,0 +1,20 @@
module.exports = function displayBlock ({dom, content, title}) {
const block = document.createElement('div')
block.className = 'block'
if (title) {
const header = document.createElement('h3')
header.innerHTML = title
block.appendChild(header)
}
if (typeof content === 'string') {
const div = document.createElement('div')
div.innerHTML = content
block.appendChild(div)
} else {
block.appendChild(content)
}
dom.appendChild(block)
}

8
src/exportAll.js

@ -125,7 +125,9 @@ register_hook('init', function () {
})
})
module.exports = (data, div) => {
module.exports = (data) => {
const div = document.createElement('div')
let formExport = new form('exportOne', formDef())
let domForm = document.createElement('form')
@ -155,4 +157,8 @@ module.exports = (data, div) => {
})
}
div.appendChild(submit)
global.setTimeout(() => formExport.resize(), 0)
return div
}

34
src/objectDisplay.js

@ -1,5 +1,6 @@
const exportAll = require('./exportAll')
const tagsDisplay = require('./tagsDisplay').display
const displayBlock = require('./displayBlock')
function getProperty(data, id, displayId, fallbackIds) {
const idCap = id[0].toUpperCase() + id.substr(1)
@ -64,23 +65,17 @@ module.exports = function objectDisplay ({feature, category, dom, displayId, fal
feature.sublayer.updateAssets(div, feature)
}.bind(this, div))
h = document.createElement('h3')
h.innerHTML = lang('header:export')
dom.appendChild(h)
div = document.createElement('div')
dom.appendChild(div)
exportAll(feature, div)
h = document.createElement('h3')
h.innerHTML = lang('header:attributes')
dom.appendChild(h)
dom.appendChild(tagsDisplay(feature.object.tags))
displayBlock({
dom,
content: exportAll(feature),
title: lang('header:export')
})
h = document.createElement('h3')
h.innerHTML = lang('header:osm_meta')
dom.appendChild(h)
displayBlock({
dom,
content: tagsDisplay(feature.object.tags),
title: lang('header:attributes')
})
div = document.createElement('dl')
div.className = 'meta'
@ -104,7 +99,12 @@ module.exports = function objectDisplay ({feature, category, dom, displayId, fal
dd.appendChild(document.createTextNode(feature.object.meta[k]))
div.appendChild(dd)
}
dom.appendChild(div)
displayBlock({
dom,
content: div,
title: lang('header:osm_meta')
})
call_hooks_callback('show-' + displayId, feature, category, dom, err => {
if (err.length) {

Loading…
Cancel
Save