Use summary to calculate # in Save button

This commit is contained in:
John Firebaugh
2013-10-23 13:22:43 -07:00
parent b8e88a7aaf
commit 697faf0265
3 changed files with 2 additions and 22 deletions

View File

@@ -158,10 +158,6 @@ iD.History = function(context) {
return this.difference().length() > 0;
},
numChanges: function() {
return this.difference().length();
},
imageryUsed: function(sources) {
if (sources) {
imageryUsed = sources;

View File

@@ -42,13 +42,13 @@ iD.ui.Save = function(context) {
var numChanges = 0;
context.history().on('change.save', function() {
var _ = history.numChanges();
var _ = history.difference().summary().length;
if (_ === numChanges)
return;
numChanges = _;
tooltip.title(iD.ui.tooltipHtml(t(numChanges > 0 ?
'save.help' : 'save.no_changes'), key))
'save.help' : 'save.no_changes'), key));
button
.classed('disabled', numChanges === 0)

View File

@@ -211,22 +211,6 @@ describe("iD.History", function () {
});
});
describe("#numChanges", function() {
it("is 0 when there are no changes", function() {
expect(history.numChanges()).to.eql(0);
});
it("is the sum of all types of changes", function() {
var node1 = iD.Node({id: "n1"}),
node2 = iD.Node();
history.merge({ n1: node1 });
history.perform(function (graph) { return graph.remove(node1); });
expect(history.numChanges()).to.eql(1);
history.perform(function (graph) { return graph.replace(node2); });
expect(history.numChanges()).to.eql(2);
});
});
describe("#reset", function () {
it("clears the version stack", function () {
history.perform(action, "annotation");