mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 07:25:15 +02:00
Eliminate context dependency
This commit is contained in:
+1
-1
@@ -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
@@ -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)));
|
||||
};
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user