diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/render-msg.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js index cb5ae8a..825bb02 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -276,6 +276,7 @@ RenderMsg.prototype.message = function (cb) { case 'macaco_maluco-sombrio-tombstone': return this.sombrioTombstone(cb) case 'macaco_maluco-sombrio-score': return this.sombrioScore(cb) case 'blog': return this.blog(cb) + case 'image-map': return this.imageMap(cb) default: return this.object(cb) } } @@ -1439,3 +1440,29 @@ RenderMsg.prototype.blog = function (cb) { self.c.summary || '') )), cb) } + +RenderMsg.prototype.imageMap = function (cb) { + var self = this + var imgLink = u.toLink(self.c.image) + var imgRef = imgLink && imgLink.link + var mapName = 'map' + token() + self.wrap(h('div', [ + h('map', {name: mapName}, + u.toArray(self.c.areas).map(function (areaLink) { + var href = areaLink && self.toUrl(areaLink.link) + return href ? h('area', { + shape: String(areaLink.shape), + coords: String(areaLink.coords), + href: href, + }) : '' + }) + ), + imgRef && imgRef[0] === '&' ? h('img', { + src: self.render.imageUrl(imgRef), + width: Number(imgLink.width) || undefined, + height: Number(imgLink.height) || undefined, + alt: String(imgLink.name || ''), + usemap: '#' + mapName, + }) : '' + ]), cb) +} |