Eliminate context dependency

This commit is contained in:
John Firebaugh
2013-05-13 17:22:36 -07:00
parent 9495f8f1c0
commit bb8e91da31
3 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ window.iD = function () {
};
/* Presets */
var presets = iD.presets(context)
var presets = iD.presets()
.load(iD.data.presets);
context.presets = function() {
+3 -4
View File
@@ -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)));
};
+5 -3
View File
@@ -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));
}
}
}