Skip to content

Commit

Permalink
Merge pull request #3064 from openstreetmap/warn-on-google-mention
Browse files Browse the repository at this point in the history
Add a warning to the changeset page if a user mentions google
  • Loading branch information
bhousel committed Apr 15, 2016
2 parents 2e50422 + 39429fb commit 6be94e7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ en:
created: Created
about_changeset_comments: About changeset comments
about_changeset_comments_link: //wiki.openstreetmap.org/wiki/Good_changeset_comments
google_warning: "You mentioned Google in this comment: remember that copying from Google Maps is strictly forbidden."
google_warning_link: http://www.openstreetmap.org/copyright
contributors:
list: "Edits by {users}"
truncated_list: "Edits by {users} and {count} others"
Expand Down
4 changes: 3 additions & 1 deletion dist/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@
"deleted": "Deleted",
"created": "Created",
"about_changeset_comments": "About changeset comments",
"about_changeset_comments_link": "//wiki.openstreetmap.org/wiki/Good_changeset_comments"
"about_changeset_comments_link": "//wiki.openstreetmap.org/wiki/Good_changeset_comments",
"google_warning": "You mentioned Google in this comment: remember that copying from Google Maps is strictly forbidden.",
"google_warning_link": "http://www.openstreetmap.org/copyright"
},
"contributors": {
"list": "Edits by {users}",
Expand Down
27 changes: 27 additions & 0 deletions js/id/ui/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ iD.ui.Commit = function(context) {
.property('value', context.storage('comment') || '')
.on('input.save', enableDisableSaveButton)
.on('change.save', enableDisableSaveButton)
.on('input.save', detectForClippy)
.on('change.save', detectForClippy)
.on('blur.save', function() {
context.storage('comment', this.value);
});
Expand All @@ -49,6 +51,22 @@ iD.ui.Commit = function(context) {
.attr('disabled', (this.value.length ? null : true));
}

function detectForClippy() {
var googleWarning = clippyArea
.html('')
.selectAll('a')
.data(this.value.match(/google/i) ? [true] : []);
googleWarning.exit().remove();
googleWarning.enter()
.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-alert', 'inline'))
.attr('href', t('commit.google_warning_link'))
.append('span')
.text(t('commit.google_warning'));
}

commentField.node().select();

context.connection().userChangesets(function (err, changesets) {
Expand All @@ -68,6 +86,10 @@ iD.ui.Commit = function(context) {
commentField.call(d3.combobox().data(comments));
});

var clippyArea = commentSection.append('div')
.attr('class', 'clippy-area');


var changeSetInfo = commentSection.append('div')
.attr('class', 'changeset-info');

Expand Down Expand Up @@ -251,6 +273,11 @@ iD.ui.Commit = function(context) {
.suppressMenu(true));
}
}

// Call the enableDisableSaveButton and detectForClippy methods
// off the bat, in case a changeset comment is recovered from
// localStorage
commentField.trigger('input');
}

return d3.rebind(commit, dispatch, 'on');
Expand Down

0 comments on commit 6be94e7

Please sign in to comment.