Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSHint Fixes. Fixes (mostly by hand) for JS style & syntax problems. #2

Merged
merged 1 commit into from
Oct 13, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/iD/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ declare("iD.Connection", null, {
return members;
}

},
}
});


Expand Down
4 changes: 2 additions & 2 deletions js/iD/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declare("iD.Controller", null, {
setState:function(newState) {
// summary: Enter a new ControllerState, firing exitState on the old one, and enterState on the new one.
if (newState==this.state) { return; }
if (this.state) {
if (this.state) {
this.state.exitState(newState);
on.emit(window, "exitState", { bubbles: true, cancelable: true, state: this.state.stateNameAsArray() });
}
Expand All @@ -40,7 +40,7 @@ declare("iD.Controller", null, {
if (!this.state) { return; }
var newState=this.state.processMouseEvent(event,entityUI);
this.setState(newState);
},
}

});

Expand Down
12 changes: 6 additions & 6 deletions js/iD/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ declare("iD.Entity", null, {
// summary: Rough-and-ready function to return a human-friendly name
// for the object. Really just a placeholder for something better.
// returns: A string such as 'river' or 'Fred's House'.
if (this.numTags()==0) { return ''; }
if (this.numTags()===0) { return ''; }
var n=[];
if (this.tags['name']) { n.push(this.tags['name']); }
if (this.tags['ref']) { n.push(this.tags['ref']); }
if (n.length==0) {
if (this.tags.name) { n.push(this.tags.name); }
if (this.tags.ref) { n.push(this.tags.ref); }
if (n.length===0) {
for (var i=0; i<this.MAINKEYS.length; i++) {
if (this.tags[this.MAINKEYS[i]]) { n.push(this.tags[this.MAINKEYS[i]]); break; }
}
}
return n.length==0 ? 'unknown' : n.join('; '); // String
return n.length===0 ? 'unknown' : n.join('; '); // String
},

// ---------------
Expand Down Expand Up @@ -148,7 +148,7 @@ declare("iD.Entity", null, {
if (p[i].entityType==_class) { c.push(p[i]); }
}
return c;
},
}
// Halcyon also implements:
// removeFromParents()
// hasParents()
Expand Down
2 changes: 1 addition & 1 deletion js/iD/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare("iD.Node", [iD.Entity], {
this.lat=Number(lat);
this.lon=Number(lon);
this.tags=tags;
this.loaded=(loaded==undefined) ? true : loaded;
this.loaded=(loaded===undefined) ? true : loaded;
this.project();
this.modified=this.id<0;
},
Expand Down
9 changes: 4 additions & 5 deletions js/iD/Relation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ declare("iD.Relation", [iD.Entity], {
this.members=members;
this.tags=tags;
this.modified=this.id<0;
this.loaded=(loaded==undefined) ? true : loaded;
var r=this; array.forEach(members,function(member) {
this.loaded=(loaded===undefined) ? true : loaded;
var r=this; array.forEach(members,function(member) {
member.entity.addParent(r);
});
},

}
});

// ----------------------------------------------------------------------
Expand All @@ -36,7 +35,7 @@ declare("iD.RelationMember", [], {
// summary: An object containing both the entity that is in the relation, and its role.
this.entity=entity;
this.role=role;
},
}
});

// ----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion js/iD/actions/AddNodeToWayAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ declare("iD.actions.AddNodeToWayAction", [iD.actions.UndoableEntityAction], {
way.refresh();

return this.SUCCESS;
},
}
});

// ----------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions js/iD/actions/CreateEntityAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare("iD.actions.CreateEntityAction", [iD.actions.UndoableEntityAction], {
doAction:function() {
// summary: Call out to the specified method (in the Controller) to create the entity.
// See undoAction for explanation of special redo handling.
if (this.deleteAction!=null) {
if (this.deleteAction!==null) {
this.deleteAction.undoAction(); // redo
} else {
this.setCreate(this.entity, false); // first time
Expand All @@ -33,7 +33,7 @@ declare("iD.actions.CreateEntityAction", [iD.actions.UndoableEntityAction], {
// of simply removing the entity, we work through to make a Delete[Entity]Action,
// call that, and store it for later. Then, when this action is called again
// (i.e. a redo), instead of creating yet another entity, we call the deleteAction.undoAction.
if (this.deleteAction==null) { this.entity.remove(this.setAction); }
if (this.deleteAction===null) { this.entity.remove(this.setAction); }
this.deleteAction.doAction();
this.markClean();
return this.SUCCESS;
Expand All @@ -42,7 +42,7 @@ declare("iD.actions.CreateEntityAction", [iD.actions.UndoableEntityAction], {
setAction:function(action) {
// summary: Set the associated delete action (see undoAction for explanation).
deleteAction = action;
},
}

});

Expand Down
4 changes: 2 additions & 2 deletions js/iD/actions/CreatePOIAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare("iD.actions.CreatePOIAction", [iD.actions.CompositeUndoableAction], {
},

doAction:function() {
if (this.newNode==null) {
if (this.newNode===null) {
this.newNode=this.connection.doCreateNode(this.tags,this.lat,this.lon,lang.hitch(this,this.push));
}
this.inherited(arguments);
Expand All @@ -40,7 +40,7 @@ declare("iD.actions.CreatePOIAction", [iD.actions.CompositeUndoableAction], {

getNode:function() {
return this.newNode;
},
}

});

Expand Down
2 changes: 1 addition & 1 deletion js/iD/actions/MoveNodeAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ declare("iD.actions.MoveNodeAction", [iD.actions.UndoableEntityAction], {
return true;
}
return false;
},
}

});

Expand Down
6 changes: 3 additions & 3 deletions js/iD/actions/UndoStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ declare("iD.actions.UndoStack", null, {

getUndoDescription:function() {
// summary: Get the name of the topmost item on the undo stack.
if (this.undoActions.length==0) return null;
if (!this.undoActions.length) return null;
if (this.undoActions[this.undoActions.length-1].name) {
return this.undoActions[this.undoActions.length-1].name;
}
Expand All @@ -102,7 +102,7 @@ declare("iD.actions.UndoStack", null, {

getRedoDescription:function() {
// summary: Get the name of the topmost item on the redo stack.
if (this.redoActions.length==0) return null;
if (!this.redoActions.length) return null;
if (this.redoActions[this.redoActions.length-1].name) {
return this.redoActions[this.redoActions.length-1].name;
}
Expand All @@ -115,7 +115,7 @@ declare("iD.actions.UndoStack", null, {
var action = this.redoActions.pop();
action.doAction();
this.undoActions.push(action);
},
}

});

Expand Down
12 changes: 6 additions & 6 deletions js/iD/actions/UndoableAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ declare("iD.actions.UndoableAction", null, {
setName:function(_name) {
// summary: Set the name of an action. For UI and debugging purposes.
this.name=_name;
},
}

});

Expand Down Expand Up @@ -69,9 +69,9 @@ declare("iD.actions.UndoableEntityAction", [iD.actions.UndoableAction], {
if (!this.connectionWasDirty) this.entity.connection.markDirty();
},

markClean:function() {
// summary: If the entity was clean before, revert the dirty flag to that state.
if (!this.initialised) this.init();
markClean:function() {
// summary: If the entity was clean before, revert the dirty flag to that state.
if (!this.initialised) this.init();
if (!this.wasDirty) this.entity._markClean();
if (!this.connectionWasDirty) this.entity.connection.markClean();
},
Expand All @@ -85,7 +85,7 @@ declare("iD.actions.UndoableEntityAction", [iD.actions.UndoableAction], {

toString:function() {
return this.name + " " + this.entity.entityType + " " + this.entity.id;
},
}

});

Expand Down Expand Up @@ -153,7 +153,7 @@ declare("iD.actions.CompositeUndoableAction", [iD.actions.UndoableAction], {
this.actions[i].undoAction();
}
this.actionsDone=false;
},
}

});

Expand Down
13 changes: 7 additions & 6 deletions js/iD/controller/edit/EditBaseState.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ declare("iD.controller.edit.EditBaseState", [iD.controller.ControllerState], {
// x: Number Screen co-ordinate.
// y: Number Screen co-ordinate.
// entity: iD.Entity The entity to be edited.
var h=entity.friendlyName(); h = (h=='') ? h : h+"<br/>";
this.editortooltip = new dijit.TooltipDialog({
content: h+"<button data-dojo-type='dijit.form.Button' type='submit'>Edit tags</button> "
+"<button data-dojo-type='dijit.form.Button' type='submit'>Edit shape</button> ",
autoFocus: false
var h=entity.friendlyName();
if (h !== '') h = h + "<br/>";
this.editortooltip = new dijit.TooltipDialog({
content: h+"<button data-dojo-type='dijit.form.Button' type='submit'>Edit tags</button> " +
"<button data-dojo-type='dijit.form.Button' type='submit'>Edit shape</button> ",
autoFocus: false
});
dijit.popup.open({ popup: this.editortooltip, x: x, y: y });
},

closeEditorTooltip:function() {
// summary: Close the tooltip.
if (this.editortooltip) { dijit.popup.close(this.editortooltip); }
},
}

});

Expand Down
6 changes: 3 additions & 3 deletions js/iD/controller/edit/NoSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define(['dojo/_base/declare',
'iD/controller/edit/EditBaseState',
'iD/controller/edit/SelectedWay',
'iD/controller/edit/SelectedWayNode',
'iD/controller/edit/SelectedPOINode',
'iD/controller/edit/SelectedPOINode'
], function(declare){

// ----------------------------------------------------------------------
Expand All @@ -29,13 +29,13 @@ declare("iD.controller.edit.NoSelection", [iD.controller.edit.EditBaseState], {
case 'node':
var ways=entity.parentWays();
if (ways.length==0) { return new iD.controller.edit.SelectedPOINode(entity); }
else { return new iD.controller.edit.SelectedWayNode(entity,ways[0]); }
else { return new iD.controller.edit.SelectedWayNode(entity,ways[0]); }
case 'way':
return new iD.controller.edit.SelectedWay(entityUI.entity, event);
}
}
return this;
},
}

});

Expand Down
2 changes: 1 addition & 1 deletion js/iD/controller/edit/SelectedPOINode.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare("iD.controller.edit.SelectedPOINode", [iD.controller.edit.EditBaseState]
}
}
return this;
},
}

});

Expand Down
11 changes: 6 additions & 5 deletions js/iD/controller/edit/SelectedWayNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ declare("iD.controller.edit.SelectedWayNode", [iD.controller.edit.EditBaseState]
var map=this.controller.map;
map.getUI(this.way ).setStateClass('shownodes').redraw();
map.getUI(this.node).setStateClass('selected' ).redraw();
this.openEditorTooltip(map.lon2screen(this.node.lon),
map.lat2screen(this.node.lat), this.node);
},
this.openEditorTooltip(map.lon2screen(this.node.lon),
map.lat2screen(this.node.lat), this.node);
},
exitState:function() {
var map=this.controller.map;
map.getUI(this.way ).resetStateClass('shownodes').redraw();
Expand All @@ -40,14 +40,15 @@ declare("iD.controller.edit.SelectedWayNode", [iD.controller.edit.EditBaseState]
case 'node':
var ways=entity.parentWays();
if (entity.hasParent(this.way)) { return new iD.controller.edit.SelectedWayNode(entity,this.way); }
else if (ways.length==0) { return new iD.controller.edit.SelectedPOINode(entity); }
else if (!ways.length) { return new iD.controller.edit.SelectedPOINode(entity); }
else { return new iD.controller.edit.SelectedWayNode(entity,ways[0]); }
break;
case 'way':
return new iD.controller.edit.SelectedWay(entityUI.entity, event);
}
}
return this;
},
}

});

Expand Down
14 changes: 8 additions & 6 deletions js/iD/controller/shape/DrawWay.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
var entity=entityUI ? entityUI.entity : null;
var entityType=entity ? entity.entityType : null;
var map=this.controller.map;
var ways;

if (event.type=='mouseover' && entityType=='way' && entityUI!=this.wayUI) {
// Mouse over way, show hover highlight
Expand All @@ -70,7 +71,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {

} else if (event.type=='mouseout' && entityType=='node') {
// Mouse left node, remove hover highlight from parent way too
var ways=entity.parentWays();
ways=entity.parentWays();
for (var i in ways) {
var ui=this.controller.map.getUI(ways[i]);
if (ui && ui.hasStateClass('shownodeshover')) {
Expand Down Expand Up @@ -105,10 +106,11 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
this.appendNode(entity, this.undoAdder() );
return this;
}
break;

case 'way':
// Click on way, add new junction node to way
var ways=[entity]; // ** needs to find all the ways under the mouse
ways=[entity]; // ** needs to find all the ways under the mouse
var undo=new iD.actions.CompositeUndoableAction();
var node=this.appendNewNode(event, undo);
array.forEach(ways, function(w) { w.doInsertNodeAtClosestPosition(node, true, lang.hitch(undo,undo.push)); } );
Expand Down Expand Up @@ -145,9 +147,9 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
},

appendNode:function(node, performAction) {
if (this.editEnd) { this.way.doAppendNode(node, performAction); }
else { this.way.doPrependNode(node, performAction); }
},
if (this.editEnd) { this.way.doAppendNode(node, performAction); }
else { this.way.doPrependNode(node, performAction); }
},

appendNewNode:function(event, undo) {
var map=this.controller.map;
Expand All @@ -157,7 +159,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) );
this.appendNode(node, lang.hitch(undo,undo.push));
return node;
},
}

});

Expand Down
4 changes: 2 additions & 2 deletions js/iD/controller/shape/NoSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define(['dojo/_base/declare','dojo/_base/lang',
'iD/controller/ControllerState',
'iD/controller/shape/DrawWay',
'iD/controller/shape/SelectedWay',
'iD/controller/shape/SelectedPOINode',
'iD/controller/shape/SelectedPOINode'
], function(declare,lang){

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -69,7 +69,7 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
}
}
return this;
},
}

});

Expand Down
Loading