From bb8e91da3120705899b0ea11178e22446f394707 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 13 May 2013 17:22:36 -0700 Subject: [PATCH] Eliminate context dependency --- js/id/id.js | 2 +- js/id/presets.js | 7 +++---- js/id/ui/preset_grid.js | 8 +++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/js/id/id.js b/js/id/id.js index 54c5bb6cc..c3c6ca029 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -161,7 +161,7 @@ window.iD = function () { }; /* Presets */ - var presets = iD.presets(context) + var presets = iD.presets() .load(iD.data.presets); context.presets = function() { diff --git a/js/id/presets.js b/js/id/presets.js index 29e4f7ba3..832b95f7c 100644 --- a/js/id/presets.js +++ b/js/id/presets.js @@ -1,4 +1,4 @@ -iD.presets = function(context) { +iD.presets = function() { // an iD.presets.Collection with methods for // loading new data and returning defaults @@ -56,9 +56,8 @@ iD.presets = function(context) { return universal; }; - all.defaults = function(entity, n) { - var geometry = entity.geometry(context.graph()), - rec = recent.matchGeometry(geometry).collection.slice(0, 4), + all.defaults = function(geometry, n) { + var rec = recent.matchGeometry(geometry).collection.slice(0, 4), def = _.uniq(rec.concat(defaults[geometry].collection)).slice(0, n - 1); return iD.presets.Collection(_.unique(rec.concat(def).concat(geometry === 'area' ? other_area : other))); }; diff --git a/js/id/ui/preset_grid.js b/js/id/ui/preset_grid.js index f1d20fad0..32a3f346e 100644 --- a/js/id/ui/preset_grid.js +++ b/js/id/ui/preset_grid.js @@ -30,12 +30,14 @@ iD.ui.PresetGrid = function(context, entity) { .attr('class', 'icon close'); } + var geometry = entity.geometry(context.graph()); + var gridwrap = selection.append('div') - .attr('class', 'fillL2 inspector-body inspector-body-' + entity.geometry(context.graph())); + .attr('class', 'fillL2 inspector-body inspector-body-' + geometry); var grid = gridwrap.append('div') .attr('class', 'preset-grid fillL cf') - .call(drawGrid, context.presets().defaults(entity, 36)); + .call(drawGrid, context.presets().defaults(geometry, 36)); function keydown() { // hack to let delete shortcut work when search is autofocused @@ -71,7 +73,7 @@ iD.ui.PresetGrid = function(context, entity) { })); grid.call(drawGrid, results); } else { - grid.call(drawGrid, context.presets().defaults(entity, 36)); + grid.call(drawGrid, context.presets().defaults(geometry, 36)); } } }