From 697faf0265269b4d4bd38bccd3fcd44e298c9f66 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 23 Oct 2013 13:22:43 -0700 Subject: [PATCH] Use summary to calculate # in Save button --- js/id/core/history.js | 4 ---- js/id/ui/save.js | 4 ++-- test/spec/core/history.js | 16 ---------------- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/js/id/core/history.js b/js/id/core/history.js index 98f27a6d7..4a8edb5d3 100644 --- a/js/id/core/history.js +++ b/js/id/core/history.js @@ -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; diff --git a/js/id/ui/save.js b/js/id/ui/save.js index 4d12e0062..926a0e60d 100644 --- a/js/id/ui/save.js +++ b/js/id/ui/save.js @@ -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) diff --git a/test/spec/core/history.js b/test/spec/core/history.js index ad68efff4..ec584711e 100644 --- a/test/spec/core/history.js +++ b/test/spec/core/history.js @@ -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");