mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Merge pull request #2 from tmcw/jshint-fixes
JSHint Fixes. Fixes (mostly by hand) for JS style & syntax problems.
This commit is contained in:
@@ -273,7 +273,7 @@ declare("iD.Connection", null, {
|
||||
return members;
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -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() });
|
||||
}
|
||||
@@ -40,7 +40,7 @@ declare("iD.Controller", null, {
|
||||
if (!this.state) { return; }
|
||||
var newState=this.state.processMouseEvent(event,entityUI);
|
||||
this.setState(newState);
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
// ---------------
|
||||
@@ -148,7 +148,7 @@ declare("iD.Entity", null, {
|
||||
if (p[i].entityType==_class) { c.push(p[i]); }
|
||||
}
|
||||
return c;
|
||||
},
|
||||
}
|
||||
// Halcyon also implements:
|
||||
// removeFromParents()
|
||||
// hasParents()
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -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;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -57,7 +57,7 @@ declare("iD.actions.AddNodeToWayAction", [iD.actions.UndoableEntityAction], {
|
||||
way.refresh();
|
||||
|
||||
return this.SUCCESS;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -40,7 +40,7 @@ declare("iD.actions.CreatePOIAction", [iD.actions.CompositeUndoableAction], {
|
||||
|
||||
getNode:function() {
|
||||
return this.newNode;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ declare("iD.actions.MoveNodeAction", [iD.actions.UndoableEntityAction], {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ declare("iD.actions.UndoStack", null, {
|
||||
var action = this.redoActions.pop();
|
||||
action.doAction();
|
||||
this.undoActions.push(action);
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
@@ -85,7 +85,7 @@ declare("iD.actions.UndoableEntityAction", [iD.actions.UndoableAction], {
|
||||
|
||||
toString:function() {
|
||||
return this.name + " " + this.entity.entityType + " " + this.entity.id;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -153,7 +153,7 @@ declare("iD.actions.CompositeUndoableAction", [iD.actions.UndoableAction], {
|
||||
this.actions[i].undoAction();
|
||||
}
|
||||
this.actionsDone=false;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@ 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 });
|
||||
},
|
||||
@@ -31,7 +32,7 @@ declare("iD.controller.edit.EditBaseState", [iD.controller.ControllerState], {
|
||||
closeEditorTooltip:function() {
|
||||
// summary: Close the tooltip.
|
||||
if (this.editortooltip) { dijit.popup.close(this.editortooltip); }
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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){
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -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;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ declare("iD.controller.edit.SelectedPOINode", [iD.controller.edit.EditBaseState]
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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();
|
||||
@@ -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;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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')) {
|
||||
@@ -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)); } );
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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){
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -69,7 +69,7 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
define(['dojo/_base/declare',
|
||||
'iD/actions/UndoableAction',
|
||||
'iD/controller/ControllerState',
|
||||
'iD/controller/ControllerState'
|
||||
], function(declare){
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -27,7 +27,7 @@ declare("iD.controller.shape.SelectedPOINode", [iD.controller.ControllerState],
|
||||
var entityType=entity ? entity.entityType : null;
|
||||
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
define(['dojo/_base/declare','dojo/_base/lang',
|
||||
'iD/actions/UndoableAction',
|
||||
'iD/controller/ControllerState',
|
||||
'iD/controller/ControllerState'
|
||||
], function(declare,lang){
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -45,6 +45,7 @@ declare("iD.controller.shape.SelectedWay", [iD.controller.ControllerState], {
|
||||
processMouseEvent:function(event,entityUI) {
|
||||
var entity=entityUI ? entityUI.entity : null;
|
||||
var entityType=entity ? entity.entityType : null;
|
||||
var way;
|
||||
|
||||
if (event.type=='click') {
|
||||
switch (entityType) {
|
||||
@@ -54,16 +55,17 @@ declare("iD.controller.shape.SelectedWay", [iD.controller.ControllerState], {
|
||||
var ways=entity.parentWays();
|
||||
if (entity.hasParent(this.way)) {
|
||||
// start a branching way from an existing point
|
||||
var way = this.getConnection().doCreateWay({}, [entity], lang.hitch(this,this.undoAdder) );
|
||||
way = this.getConnection().doCreateWay({}, [entity], lang.hitch(this,this.undoAdder) );
|
||||
this.controller.map.createUI(way);
|
||||
return new iD.controller.shape.DrawWay(way);
|
||||
} else if (ways.length==0) {
|
||||
} else if (ways.length===0) {
|
||||
// convert POI into way
|
||||
return this;
|
||||
} else {
|
||||
// select another way
|
||||
return new iD.controller.shape.SelectedWay(entity.getParents()[0]);
|
||||
}
|
||||
} else {
|
||||
// select another way
|
||||
return new iD.controller.shape.SelectedWay(entity.getParents()[0]);
|
||||
}
|
||||
break;
|
||||
case 'way':
|
||||
if (entity==this.way) {
|
||||
// start a branching way from a new point
|
||||
@@ -74,7 +76,7 @@ declare("iD.controller.shape.SelectedWay", [iD.controller.ControllerState], {
|
||||
map.coord2lat(map.mouseY(event)),
|
||||
map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) );
|
||||
entity.doInsertNodeAtClosestPosition(startNode, true, lang.hitch(undo,undo.push));
|
||||
var way = this.getConnection().doCreateWay({}, [startNode], lang.hitch(undo,undo.push) );
|
||||
way = this.getConnection().doCreateWay({}, [startNode], lang.hitch(undo,undo.push) );
|
||||
this.controller.undoStack.addAction(undo);
|
||||
this.controller.map.createUI(way);
|
||||
return new iD.controller.shape.DrawWay(way);
|
||||
@@ -86,7 +88,7 @@ declare("iD.controller.shape.SelectedWay", [iD.controller.ControllerState], {
|
||||
} else {
|
||||
}
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user