mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-26 15:33:50 +00:00
add recent presets to defaults
This commit is contained in:
@@ -15,7 +15,8 @@ iD.presets = function(context) {
|
||||
},
|
||||
all = iD.presets.Collection([iD.presets.Preset(other)]),
|
||||
defaults = { area: all, line: all, point: all, vertex: all },
|
||||
forms = {};
|
||||
forms = {},
|
||||
recent = iD.presets.Collection([]);
|
||||
|
||||
all.load = function(d) {
|
||||
|
||||
@@ -46,8 +47,15 @@ iD.presets = function(context) {
|
||||
}
|
||||
};
|
||||
|
||||
all.defaults = function(entity) {
|
||||
return defaults[entity.geometry(context.graph())];
|
||||
all.defaults = function(entity, n) {
|
||||
var rec = recent.matchType(entity, context.graph()).collection.slice(0, 4),
|
||||
def = defaults[entity.geometry(context.graph())].collection.slice(0, n - rec.length - 1);
|
||||
return iD.presets.Collection(_.unique(rec.concat(def).concat(other)));
|
||||
};
|
||||
|
||||
all.choose = function(preset) {
|
||||
recent = iD.presets.Collection(_.unique([preset].concat(recent.collection)));
|
||||
return all;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ iD.ui.PresetGrid = function(context) {
|
||||
|
||||
var grid = selection.append('div')
|
||||
.attr('class', 'preset-grid fillD inspector-body ' + entity.geometry(context.graph()))
|
||||
.call(drawGrid, context.presets().defaults(entity));
|
||||
.call(drawGrid, context.presets().defaults(entity, 12));
|
||||
|
||||
var search = searchwrap.append('input')
|
||||
.attr('class', 'preset-grid-search')
|
||||
@@ -48,7 +48,7 @@ iD.ui.PresetGrid = function(context) {
|
||||
message.text(t('inspector.results', {n: results.collection.length, search: value}));
|
||||
grid.call(drawGrid, results);
|
||||
} else {
|
||||
grid.call(drawGrid, context.presets().defaults(entity));
|
||||
grid.call(drawGrid, context.presets().defaults(entity, 12));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -69,6 +69,7 @@ iD.ui.PresetGrid = function(context) {
|
||||
|
||||
// Preset
|
||||
} else {
|
||||
context.presets().choose(d);
|
||||
event.choose(d);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user