From 3d8f2ffb84646a81fa8458c470e18322a01e97a4 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 4 Feb 2013 16:08:34 -0500 Subject: [PATCH] Consistify syntax --- js/id/graph/history.js | 24 ++++++++++++------------ js/id/modes/select.js | 12 ++++++------ js/id/ui.js | 16 ++++++++-------- js/id/ui/save.js | 4 +++- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/js/id/graph/history.js b/js/id/graph/history.js index 7d1098027..a0930203c 100644 --- a/js/id/graph/history.js +++ b/js/id/graph/history.js @@ -27,11 +27,11 @@ iD.History = function() { } var history = { - graph: function () { + graph: function() { return stack[index].graph; }, - merge: function (entities) { + merge: function(entities) { for (var i = 0; i < stack.length; i++) { stack[i].graph.rebase(entities); } @@ -39,7 +39,7 @@ iD.History = function() { dispatch.change(); }, - perform: function () { + perform: function() { var previous = stack[index].graph; stack = stack.slice(0, index + 1); @@ -49,7 +49,7 @@ iD.History = function() { return change(previous); }, - replace: function () { + replace: function() { var previous = stack[index].graph; // assert(index == stack.length - 1) @@ -58,7 +58,7 @@ iD.History = function() { return change(previous); }, - pop: function () { + pop: function() { var previous = stack[index].graph; if (index > 0) { @@ -68,7 +68,7 @@ iD.History = function() { } }, - undo: function () { + undo: function() { var previous = stack[index].graph; // Pop to the first annotated state. @@ -87,7 +87,7 @@ iD.History = function() { return change(previous); }, - redo: function () { + redo: function() { var previous = stack[index].graph; while (index < stack.length - 1) { @@ -99,7 +99,7 @@ iD.History = function() { return change(previous); }, - undoAnnotation: function () { + undoAnnotation: function() { var i = index; while (i >= 0) { if (stack[i].annotation) return stack[i].annotation; @@ -107,7 +107,7 @@ iD.History = function() { } }, - redoAnnotation: function () { + redoAnnotation: function() { var i = index + 1; while (i <= stack.length - 1) { if (stack[i].annotation) return stack[i].annotation; @@ -115,13 +115,13 @@ iD.History = function() { } }, - difference: function () { + difference: function() { var base = stack[0].graph, head = stack[index].graph; return iD.Difference(base, head); }, - changes: function () { + changes: function() { var difference = history.difference(); return { modified: difference.modified(), @@ -145,7 +145,7 @@ iD.History = function() { undefined, 'Custom'); }, - reset: function () { + reset: function() { stack = [{graph: iD.Graph()}]; index = 0; dispatch.change(); diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 02db6a57f..ec6017ae3 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -39,11 +39,11 @@ iD.modes.Select = function(context, selection, initial) { }); var operations = d3.values(iD.operations) - .map(function (o) { return o(selection, context); }) - .filter(function (o) { return o.available(); }); + .map(function(o) { return o(selection, context); }) + .filter(function(o) { return o.available(); }); operations.forEach(function(operation) { - keybinding.on(operation.key, function () { + keybinding.on(operation.key, function() { if (operation.enabled()) { operation(); } @@ -87,7 +87,7 @@ iD.modes.Select = function(context, selection, initial) { context.history().on('change.select', function() { context.surface().call(radialMenu.close); - if (_.any(selection, function (id) { return !context.entity(id); })) { + if (_.any(selection, function(id) { return !context.entity(id); })) { // Exit mode if selected entity gets undone context.enter(iD.modes.Browse(context)); @@ -128,7 +128,7 @@ iD.modes.Select = function(context, selection, initial) { context.surface() .on('dblclick.select', dblclick) .selectAll("*") - .filter(function (d) { return d && selection.indexOf(d.id) >= 0; }) + .filter(function(d) { return d && selection.indexOf(d.id) >= 0; }) .classed('selected', true); radialMenu = iD.ui.RadialMenu(operations); @@ -144,7 +144,7 @@ iD.modes.Select = function(context, selection, initial) { } }; - mode.exit = function () { + mode.exit = function() { if (singular()) { changeTags(singular(), inspector.tags()); } diff --git a/js/id/ui.js b/js/id/ui.js index f8c58903f..03e5c6199 100644 --- a/js/id/ui.js +++ b/js/id/ui.js @@ -1,4 +1,4 @@ -iD.ui = function (context) { +iD.ui = function(context) { return function(container) { context.container(container); @@ -42,12 +42,12 @@ iD.ui = function (context) { .data(modes) .enter().append('button') .attr('tabindex', -1) - .attr('class', function (mode) { return mode.title + ' add-button col3'; }) + .attr('class', function(mode) { return mode.title + ' add-button col3'; }) .call(bootstrap.tooltip().placement('bottom').html(true)) - .attr('data-original-title', function (mode) { + .attr('data-original-title', function(mode) { return hintprefix(mode.key, mode.description); }) - .on('click.editor', function (mode) { context.enter(mode); }); + .on('click.editor', function(mode) { context.enter(mode); }); function disableTooHigh() { if (map.editable()) { @@ -74,14 +74,14 @@ iD.ui = function (context) { return d.id + ' icon icon-pre-text'; }); - buttons.append('span').attr('class', 'label').text(function (mode) { return mode.title; }); + buttons.append('span').attr('class', 'label').text(function(mode) { return mode.title; }); - context.on('enter.editor', function (entered) { - buttons.classed('active', function (mode) { return entered.button === mode.button; }); + context.on('enter.editor', function(entered) { + buttons.classed('active', function(mode) { return entered.button === mode.button; }); container.classed("mode-" + entered.id, true); }); - context.on('exit.editor', function (exited) { + context.on('exit.editor', function(exited) { container.classed("mode-" + exited.id, false); }); diff --git a/js/id/ui/save.js b/js/id/ui/save.js index 773ae4d50..fc593c463 100644 --- a/js/id/ui/save.js +++ b/js/id/ui/save.js @@ -17,7 +17,9 @@ iD.ui.save = function(context) { d3.select('.shaded').remove(); var l = iD.ui.loading(t('uploading_changes'), true); - connection.putChangeset(history.changes(), e.comment, history.imagery_used(), function(err, changeset_id) { + connection.putChangeset(history.changes(), + e.comment, + history.imagery_used(), function(err, changeset_id) { l.remove(); history.reset(); map.flush().redraw();