From 9c3bba4a5e6d10c80addf3fb11dc8639a9d2e4a7 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 19 Oct 2012 14:36:35 -0400 Subject: [PATCH] Fix references to conn --- js/iD/controller/ControllerState.js | 4 ++-- js/iD/controller/shape/DrawWay.js | 14 ++++++++------ js/iD/controller/shape/NoSelection.js | 8 ++++---- js/iD/renderer/Map.js | 13 ++++++------- js/iD/styleparser/RuleSet.js | 16 ++++++++-------- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/js/iD/controller/ControllerState.js b/js/iD/controller/ControllerState.js index 764d11328..2250ce085 100755 --- a/js/iD/controller/ControllerState.js +++ b/js/iD/controller/ControllerState.js @@ -42,10 +42,10 @@ declare("iD.controller.ControllerState", null, { return this.__proto__.declaredClass.split('.').slice(2); }, - getConnection:function() { + getConnection: function() { // summary: Shorthand to return the Connection associated with this Controller (via its Map object). // return: iD.Connection - return this.controller.map.conn; + return this.controller.map.connection; }, undoAdder:function() { diff --git a/js/iD/controller/shape/DrawWay.js b/js/iD/controller/shape/DrawWay.js index 9f8b6bf4c..b79b3692f 100644 --- a/js/iD/controller/shape/DrawWay.js +++ b/js/iD/controller/shape/DrawWay.js @@ -52,7 +52,8 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], { var map = this.controller.map; var ways, undo, action; - if (event.type=='mouseover' && entityType=='way' && + if (event.type === 'mouseover' && + entityType === 'way' && entityUI !== this.wayUI) { // Mouse over way, show hover highlight @@ -144,7 +145,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], { }, updateElastic:function(event) { - var map=this.controller.map; + var map = this.controller.map; map.drawElastic( map.lon2coord(this.getDrawingNode().lon), map.lat2coord(this.getDrawingNode().lat), @@ -153,11 +154,13 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], { }, getDrawingNode:function() { - return (this.editEnd ? this.way.nodes[this.way.nodes.length - 1] : this.way.nodes[0]); + return this.editEnd ? + this.way.nodes[this.way.nodes.length - 1] : this.way.nodes[0]; }, getStartNode:function() { - return (this.editEnd ? this.way.nodes[0] : this.way.nodes[this.way.nodes.length - 1]); + return this.editEnd ? + this.way.nodes[0] : this.way.nodes[this.way.nodes.length - 1]; }, appendNode:function(node, performAction) { @@ -170,8 +173,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], { appendNewNode:function(event, undo) { var map=this.controller.map; - var node=this.getConnection().doCreateNode( - {}, + var node=this.getConnection().doCreateNode({}, map.coord2lat(map.mouseY(event)), map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) ); this.appendNode(node, lang.hitch(undo,undo.push)); diff --git a/js/iD/controller/shape/NoSelection.js b/js/iD/controller/shape/NoSelection.js index 3404a3577..58436ab88 100644 --- a/js/iD/controller/shape/NoSelection.js +++ b/js/iD/controller/shape/NoSelection.js @@ -13,13 +13,13 @@ */ -define(['dojo/_base/declare','dojo/_base/lang', +define(['dojo/_base/declare', 'iD/actions/UndoableAction', 'iD/controller/ControllerState', 'iD/controller/shape/DrawWay', 'iD/controller/shape/SelectedWay', 'iD/controller/shape/SelectedPOINode' - ], function(declare,lang){ + ], function(declare) { // ---------------------------------------------------------------------- // ControllerState base class @@ -68,8 +68,8 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], { var undo = new iD.actions.CompositeUndoableAction(); var startNode = this.getConnection().doCreateNode({}, map.coord2lat(map.mouseY(event)), - map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) ); - var way = this.getConnection().doCreateWay({}, [startNode], lang.hitch(undo,undo.push) ); + map.coord2lon(map.mouseX(event)), _.bind(undo.push, undo) ); + var way = this.getConnection().doCreateWay({}, [startNode], _.bind(undo.push, undo) ); this.controller.undoStack.addAction(undo); this.controller.map.createUI(way); return new iD.controller.shape.DrawWay(way); diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index e55201fc4..529b292eb 100755 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -278,26 +278,25 @@ declare("iD.renderer.Map", null, { zoomIn: function() { // summary: Zoom in by one level (unless maximum reached). - if (this.zoom !== this.MAXSCALE) { - this.changeScale(this.zoom + 1); - } + return this.changeScale(this.zoom + 1); }, zoomOut: function() { // summary: Zoom out by one level (unless minimum reached). - if (this.zoom !== this.MINSCALE) { - this.changeScale(this.zoom - 1); - } + this.changeScale(this.zoom - 1); this.download(); + return this; }, changeScale: function(zoom) { + if (zoom < this.MINSCALE || zoom > this.MAXSCALE) return this; // summary: Redraw the map at a new zoom level. this.zoom = zoom; this._setScaleFactor(); this._blankTiles(); this.updateCoordsFromLatLon(this.centrelat, this.centrelon); // recentre this.updateUIs(true, true); + return this; }, _setScaleFactor: function() { @@ -386,7 +385,7 @@ declare("iD.renderer.Map", null, { var mask = 1 << (zoom - 1); if ((coord.x & mask) !== 0) byte++; if ((coord.y & mask) !== 0) byte += 2; - u = u + byte.toString(); + u += byte.toString(); } return this.tilebaseURL .replace('$z', coord.z) diff --git a/js/iD/styleparser/RuleSet.js b/js/iD/styleparser/RuleSet.js index 69cbe16a5..f2277d0be 100755 --- a/js/iD/styleparser/RuleSet.js +++ b/js/iD/styleparser/RuleSet.js @@ -12,17 +12,17 @@ declare("iD.styleparser.RuleSet", null, { choosers: [], // list of StyleChoosers callback: null, - constructor:function() { + constructor: function() { // summary: An entire stylesheet in parsed form. - this.choosers=[]; + this.choosers = []; }, - registerCallback:function(callback) { + registerCallback: function(callback) { // summary: Set a callback function to be called when the CSS is loaded and parsed. - this.callback=callback; + this.callback = callback; }, - getStyles:function(entity, tags, zoom) { + getStyles: function(entity, tags, zoom) { // summary: Find the styles for a given entity. var sl=new iD.styleparser.StyleList(); for (var i in this.choosers) { @@ -39,11 +39,11 @@ declare("iD.styleparser.RuleSet", null, { parseCSS:function(css) { // summary: Parse a CSS document into a set of StyleChoosers. var previous=0; // what was the previous CSS word? - var sc=new iD.styleparser.StyleChooser(); // currently being assembled - this.choosers=[]; + var sc = new iD.styleparser.StyleChooser(); // currently being assembled + this.choosers = []; css = css.replace(/[\r\n]/g,""); // strip linebreaks because JavaScript doesn't have the /s modifier - var o={}; + var o = {}; while (css.length>0) { // CSS comment