Răsfoiți Sursa

jslint cleanup

Lutz Roeder 15 ani în urmă
părinte
comite
651174ad11

+ 12 - 12
Source/CanvasRenderingContext2D.js

@@ -32,17 +32,17 @@ CanvasRenderingContext2D.prototype.dashedLine = function(x1, y1, x2, y2)
 	}
 };
 
-CanvasRenderingContext2D.prototype.roundedRect = function(x, y, w, h, radius)
+CanvasRenderingContext2D.prototype.roundedRect = function(x, y, width, height, radius)
 {
-  context.beginPath();
-  context.moveTo(x + radius, y);
-  context.lineTo(x + width - radius, y);
-  context.quadraticCurveTo(x + width, y, x + width, y + radius);
-  context.lineTo(x + width, y + height - radius);
-  context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
-  context.lineTo(x + radius, y + height);
-  context.quadraticCurveTo(x, y + height, x, y + height - radius);
-  context.lineTo(x, y + radius);
-  context.quadraticCurveTo(x, y, x + radius, y);
-  context.closePath();
+  this.beginPath();
+  this.moveTo(x + radius, y);
+  this.lineTo(x + width - radius, y);
+  this.quadraticCurveTo(x + width, y, x + width, y + radius);
+  this.lineTo(x + width, y + height - radius);
+  this.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
+  this.lineTo(x + radius, y + height);
+  this.quadraticCurveTo(x, y + height, x, y + height - radius);
+  this.lineTo(x, y + radius);
+  this.quadraticCurveTo(x, y, x + radius, y);
+  this.closePath();
 };

+ 2 - 2
Source/ContentChangedUndoUnit.js

@@ -9,9 +9,9 @@ function ContentChangedUndoUnit(element, content)
 ContentChangedUndoUnit.prototype.undo = function()
 {
 	this.element.content = this.undoContent;
-}
+};
 
 ContentChangedUndoUnit.prototype.redo = function()
 {
 	this.element.content = this.redoContent;
-}
+};

+ 2 - 5
Source/Element.js

@@ -43,7 +43,7 @@ Element.prototype.getPageRectangle = function()
 	rectangle.x += canvas.offsetLeft;
 	rectangle.y += canvas.offsetTop;
 	return rectangle;
-}
+};
 
 Element.prototype.setRectangle = function(rectangle)
 {
@@ -172,10 +172,7 @@ Element.prototype.getConnectorPosition = function(connector)
 
 Element.prototype.setContent = function(content)
 {
-	this.owner.undoService.begin();
-	this.owner.undoService.add(new ContentChangedUndoUnit(this, content));
-	this.owner.undoService.commit();
-	this.owner.update();
+	this.owner.setElementContent(this, content);
 };
 
 Element.prototype.getContent = function()

+ 10 - 4
Source/Graph.js

@@ -509,14 +509,12 @@ Graph.prototype.updateMousePosition = function(e)
 {
 	this.mousePosition = new Point(e.pageX, e.pageY);
 	var node = this.canvas;
-	while (node != null)
+	while (node !== null)
 	{
 		this.mousePosition.x -= node.offsetLeft;
 		this.mousePosition.y -= node.offsetTop;
 		node = node.offsetParent;
 	}
-	
-//	this.mousePosition = new Point(e.pageX - this.canvas.offsetLeft, e.pageY - this.canvas.offsetTop);
 };
 
 Graph.prototype.addElement = function(template, point, content)
@@ -534,7 +532,7 @@ Graph.prototype.createElement = function(template)
 	this.activeTemplate = template;
 	this.newElement = new Element(template, this.mousePosition);
 	this.canvas.focus();
-}
+};
 
 Graph.prototype.addConnection = function(connector1, connector2)
 {
@@ -547,6 +545,14 @@ Graph.prototype.addConnection = function(connector1, connector2)
 	return connection;
 };
 
+Graph.prototype.setElementContent = function(element, content)
+{
+	this.owner.undoService.begin();
+	this.owner.undoService.add(new ContentChangedUndoUnit(element, content));
+	this.owner.undoService.commit();
+	this.owner.update();
+};
+
 Graph.prototype.update = function()
 {
 	var i, j, k;

+ 1 - 1
Tools/build.sh

@@ -22,7 +22,6 @@ cat	Function.js \
 	Element.js \
 	Connection.js \
 	Selection.js \
-	UndoService.js \
 	ContainerUndoUnit.js \
 	InsertElementUndoUnit.js \
 	DeleteElementUndoUnit.js \
@@ -31,6 +30,7 @@ cat	Function.js \
 	ContentChangedUndoUnit.js \
 	TransformUndoUnit.js \
 	SelectionUndoUnit.js \
+	UndoService.js \
 	Graph.js \
 	> ../Build/Debug/netron.js