Show all features as auto-hidden when map is not editable

This commit is contained in:
John Firebaugh
2014-11-11 13:45:30 -08:00
parent c66091c00c
commit 916a901b8f
4 changed files with 11 additions and 9 deletions

View File

@@ -185,7 +185,7 @@ window.iD = function () {
}; };
context.editable = function() { context.editable = function() {
return map.editable() && mode && mode.id !== 'save'; return map.editable();
}; };
/* Behaviors */ /* Behaviors */
@@ -205,7 +205,7 @@ window.iD = function () {
context.background = function() { return background; }; context.background = function() { return background; };
/* Features */ /* Features */
var features = iD.Features(); var features = iD.Features(context);
context.features = function() { return features; }; context.features = function() { return features; };
context.hasHiddenConnections = function(id) { context.hasHiddenConnections = function(id) {
var graph = history.graph(), var graph = history.graph(),

View File

@@ -1,4 +1,4 @@
iD.Features = function() { iD.Features = function(context) {
var major_roads = { var major_roads = {
'motorway': true, 'motorway': true,
'motorway_link': true, 'motorway_link': true,
@@ -65,7 +65,7 @@ iD.Features = function() {
defaultMax: (max || Infinity), defaultMax: (max || Infinity),
enable: function() { this.enabled = true; this.currentMax = this.defaultMax; }, enable: function() { this.enabled = true; this.currentMax = this.defaultMax; },
disable: function() { this.enabled = false; this.currentMax = 0; }, disable: function() { this.enabled = false; this.currentMax = 0; },
hidden: function() { return this.count > this.currentMax * _cullFactor; }, hidden: function() { return !context.editable() || this.count > this.currentMax * _cullFactor; },
autoHidden: function() { return this.hidden() && this.currentMax > 0; } autoHidden: function() { return this.hidden() && this.currentMax > 0; }
}; };
} }

View File

@@ -4,6 +4,10 @@ iD.ui.Modes = function(context) {
iD.modes.AddLine(context), iD.modes.AddLine(context),
iD.modes.AddArea(context)]; iD.modes.AddArea(context)];
function editable() {
return context.editable() && context.mode().id !== 'save'
}
return function(selection) { return function(selection) {
var buttons = selection.selectAll('button.add-button') var buttons = selection.selectAll('button.add-button')
.data(modes); .data(modes);
@@ -31,8 +35,6 @@ iD.ui.Modes = function(context) {
context context
.on('enter.modes', update); .on('enter.modes', update);
update();
buttons.append('span') buttons.append('span')
.attr('class', function(mode) { return mode.id + ' icon icon-pre-text'; }); .attr('class', function(mode) { return mode.id + ' icon icon-pre-text'; });
@@ -54,14 +56,14 @@ iD.ui.Modes = function(context) {
var keybinding = d3.keybinding('mode-buttons'); var keybinding = d3.keybinding('mode-buttons');
modes.forEach(function(m) { modes.forEach(function(m) {
keybinding.on(m.key, function() { if (context.editable()) context.enter(m); }); keybinding.on(m.key, function() { if (editable()) context.enter(m); });
}); });
d3.select(document) d3.select(document)
.call(keybinding); .call(keybinding);
function update() { function update() {
buttons.property('disabled', !context.editable()); buttons.property('disabled', !editable());
} }
}; };
}; };

View File

@@ -15,7 +15,7 @@ iD.ui.Notice = function(context) {
.text(t('zoom_in_edit')); .text(t('zoom_in_edit'));
function disableTooHigh() { function disableTooHigh() {
div.style('display', context.map().editable() ? 'none' : 'block'); div.style('display', context.editable() ? 'none' : 'block');
} }
context.map() context.map()