From 3688ed73dfac0fcb85ef0aaedfa18febc4f175aa Mon Sep 17 00:00:00 2001 From: cel Date: Thu, 14 Dec 2017 13:55:55 -0800 Subject: Render image-map messages e.g. %VD9QdTWl4oNZtkrkEeKX6rhXPwchrB7J7EiPUqz78xY=.sha256 --- lib/render-msg.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib') 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) +} -- cgit v1.2.3