From dd0e08b244b6f36659f15a29fa26ebe6321bc664 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 20 Oct 2014 16:33:32 -0700 Subject: [PATCH] Write presets and imagery to standalone files --- .gitignore | 2 + Makefile | 2 + build.js | 16 ++++--- dist/index.html | 7 ++- index.html | 5 +- js/id/id.js | 14 ++++-- js/id/renderer/background.js | 80 +++++++++++++++++--------------- test/index_packaged.html | 2 + test/spec/behavior/hash.js | 2 +- test/spec/behavior/lasso.js | 2 +- test/spec/behavior/select.js | 2 +- test/spec/modes/add_point.js | 2 + test/spec/renderer/map.js | 2 +- test/spec/svg/points.js | 2 +- test/spec/ui/preset/access.js | 2 +- test/spec/ui/preset/wikipedia.js | 2 +- 16 files changed, 86 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index f3c254660..fd6ff4db1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ node_modules dist/iD.js dist/iD.min.js dist/iD.css +dist/presets.js +dist/imagery.js transifex.auth diff --git a/Makefile b/Makefile index 73ef4ab58..e697a7544 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ all: \ dist/iD.css \ dist/iD.js \ dist/iD.min.js \ + dist/presets.js \ + dist/imagery.js \ dist/img/line-presets.png \ dist/img/relation-presets.png diff --git a/build.js b/build.js index ad9c53459..2573558c6 100644 --- a/build.js +++ b/build.js @@ -270,14 +270,7 @@ fs.writeFileSync('dist/locales/en.json', stringify(en.en)); fs.writeFileSync('data/data.js', 'iD.data = ' + stringify({ deprecated: r('deprecated.json'), discarded: r('discarded.json'), - imagery: r('imagery.json'), wikipedia: r('wikipedia.json'), - presets: { - presets: rp('presets.json'), - defaults: rp('defaults.json'), - categories: rp('categories.json'), - fields: rp('fields.json') - }, imperial: r('imperial.json'), featureIcons: r('feature-icons.json'), operations: r('operations-sprite.json'), @@ -286,3 +279,12 @@ fs.writeFileSync('data/data.js', 'iD.data = ' + stringify({ suggestions: r('name-suggestions.json'), addressFormats: r('address-formats.json') }) + ';'); + +fs.writeFileSync('dist/presets.js', 'iD.data.presets = ' + stringify({ + presets: rp('presets.json'), + defaults: rp('defaults.json'), + categories: rp('categories.json'), + fields: rp('fields.json') +}) + ';'); + +fs.writeFileSync('dist/imagery.js', 'iD.data.imagery = ' + stringify(r('imagery.json')) + ';'); diff --git a/dist/index.html b/dist/index.html index 44e53a3d7..16fafe5d8 100644 --- a/dist/index.html +++ b/dist/index.html @@ -19,6 +19,8 @@ + + @@ -62,7 +64,10 @@ document.getElementById('id-container').innerHTML = 'Sorry, Internet Explorer is not currently supported. Please use Potlatch 2 to edit the map.'; document.getElementById('id-container').className = 'unsupported'; } else { - var id = iD(); + var id = iD() + .presets(iD.data.presets) + .imagery(iD.data.imagery); + d3.select('#id-container') .call(id.ui()); } diff --git a/index.html b/index.html index b50fa5e49..de6a75035 100644 --- a/index.html +++ b/index.html @@ -230,7 +230,10 @@
+ + diff --git a/test/spec/behavior/hash.js b/test/spec/behavior/hash.js index 707c1687d..dce4c2fb6 100644 --- a/test/spec/behavior/hash.js +++ b/test/spec/behavior/hash.js @@ -4,7 +4,7 @@ describe('iD.behavior.Hash', function () { var hash, context; beforeEach(function () { - context = iD(); + context = iD().imagery(iD.data.imagery); context.container(d3.select(document.createElement('div'))); // Neuter connection diff --git a/test/spec/behavior/lasso.js b/test/spec/behavior/lasso.js index c0bf77a74..160cb2f52 100644 --- a/test/spec/behavior/lasso.js +++ b/test/spec/behavior/lasso.js @@ -2,7 +2,7 @@ describe("iD.behavior.Lasso", function () { var lasso, context; beforeEach(function () { - context = iD(); + context = iD().imagery(iD.data.imagery); context.container(d3.select(document.createElement('div'))); // Neuter connection diff --git a/test/spec/behavior/select.js b/test/spec/behavior/select.js index dabfaa4ce..b393dd555 100644 --- a/test/spec/behavior/select.js +++ b/test/spec/behavior/select.js @@ -4,7 +4,7 @@ describe("iD.behavior.Select", function() { beforeEach(function() { container = d3.select('body').append('div'); - context = iD().container(container); + context = iD().imagery(iD.data.imagery).container(container); a = iD.Node({loc: [0, 0]}); b = iD.Node({loc: [0, 0]}); diff --git a/test/spec/modes/add_point.js b/test/spec/modes/add_point.js index 0a3e375a2..4cde8c8ad 100644 --- a/test/spec/modes/add_point.js +++ b/test/spec/modes/add_point.js @@ -5,6 +5,8 @@ describe("iD.modes.AddPoint", function() { var container = d3.select(document.createElement('div')); context = iD() + .presets(iD.data.presets) + .imagery(iD.data.imagery) .container(container); container.call(context.map()) diff --git a/test/spec/renderer/map.js b/test/spec/renderer/map.js index 663030246..43e9c59f1 100644 --- a/test/spec/renderer/map.js +++ b/test/spec/renderer/map.js @@ -2,7 +2,7 @@ describe('iD.Map', function() { var context, map; beforeEach(function() { - context = iD(); + context = iD().imagery(iD.data.imagery); context.container(d3.select(document.createElement('div'))); map = context.map(); d3.select(document.createElement('div')) diff --git a/test/spec/svg/points.js b/test/spec/svg/points.js index 71c59fcc4..d6a7f5e85 100644 --- a/test/spec/svg/points.js +++ b/test/spec/svg/points.js @@ -4,7 +4,7 @@ describe("iD.svg.Points", function () { context; beforeEach(function () { - context = iD(); + context = iD().presets(iD.data.presets); surface = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'svg')) .call(iD.svg.Surface(context)); }); diff --git a/test/spec/ui/preset/access.js b/test/spec/ui/preset/access.js index aa6dcf788..702677063 100644 --- a/test/spec/ui/preset/access.js +++ b/test/spec/ui/preset/access.js @@ -3,7 +3,7 @@ describe('iD.ui.preset.access', function() { beforeEach(function() { selection = d3.select(document.createElement('div')); - field = iD().presets().field('access'); + field = iD().presets(iD.data.presets).presets().field('access'); }); it('creates inputs for a variety of modes of access', function() { diff --git a/test/spec/ui/preset/wikipedia.js b/test/spec/ui/preset/wikipedia.js index aabb4594b..e74757e10 100644 --- a/test/spec/ui/preset/wikipedia.js +++ b/test/spec/ui/preset/wikipedia.js @@ -3,7 +3,7 @@ describe('iD.ui.preset.wikipedia', function() { beforeEach(function() { selection = d3.select(document.createElement('div')); - field = iD().presets().field('wikipedia'); + field = iD().presets(iD.data.presets).presets().field('wikipedia'); }); it('recognizes lang:title format', function() {