From a528267f181a130c9b507dc172df4f997ec078ab Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 17 Aug 2013 00:20:05 +0100 Subject: [PATCH] Add support for an externally provided asset map This allows an embedding site to provide a map from individual asset names to the URLs to use, thus allowing them to be served through (for example) the rails asset pipeline. --- js/id/id.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/id/id.js b/js/id/id.js index d8c5e565a..cbfd267ec 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -212,8 +212,16 @@ window.iD = function () { return context; }; + var assetMap = {}; + context.assetMap = function(_) { + if (!arguments.length) return assetMap; + assetMap = _; + return context; + }; + context.imagePath = function(_) { - return assetPath + 'img/' + _; + var asset = 'img/' + _; + return assetMap[asset] || assetPath + asset; }; context.toggleFullscreen = function() {