mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-01 12:41:36 +02:00
JSHint Fixes. Fixes (mostly by hand) for JS style & syntax problems.
Basically these are mainly == in 0/null comparisons (typecasting is dangerous in js), mixed spaces/tabs (style/indentation), and trailing commas (will break IE7).
This commit is contained in:
@@ -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