From 51ad6d006c28ba7bdc1160ada42a90754958d653 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 18 Sep 2015 11:55:09 -0400 Subject: [PATCH] Disable save button when changeset comment is empty (closes #1488) --- js/id/ui/commit.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/id/ui/commit.js b/js/id/ui/commit.js index e70606844..8c7121dc2 100644 --- a/js/id/ui/commit.js +++ b/js/id/ui/commit.js @@ -38,7 +38,11 @@ iD.ui.Commit = function(context) { .attr('placeholder', t('commit.description_placeholder')) .attr('maxlength', 255) .property('value', context.storage('comment') || '') - .on('blur.save', function () { + .on('input.save', function() { + d3.selectAll('.save-section .save-button') + .attr('disabled', (this.value.length ? null : true)); + }) + .on('blur.save', function() { context.storage('comment', this.value); }); @@ -117,7 +121,11 @@ iD.ui.Commit = function(context) { .attr('class','buttons fillL cf'); var saveButton = buttonSection.append('button') - .attr('class', 'action col5 button') + .attr('class', 'action col5 button save-button') + .attr('disabled', function() { + var n = d3.select('.commit-form textarea').node(); + return (n && n.value.length) ? null : true; + }) .on('click.save', function() { dispatch.save({ comment: commentField.node().value @@ -129,7 +137,7 @@ iD.ui.Commit = function(context) { .text(t('commit.save')); var cancelButton = buttonSection.append('button') - .attr('class', 'action col5 button') + .attr('class', 'action col5 button cancel-button') .on('click.cancel', function() { dispatch.cancel(); }); cancelButton.append('span')