maqetta/maqetta — Issue #1113: Code cleanup: Context.js:getContentPosition()
Author: JonFerraiolo
Created: 2011-10-28 20:32:04+00:00
State: open
Labels: Priority Low, Visual Editor

@peller, @jhpedemonte

At some point we should get rid of Context.js:getContentPosition(). As it stands today, it looks like this:

```
//FIXME: remove?
getContentPosition: function(position){
if(!position){
return undefined;
}
if(position.target){ // event
position = {x: position.pageX, y: position.pageY};
}
/*
var containerNode = this.getContainerNode();
var x = position.x + containerNode.scrollLeft;
var y = position.y + containerNode.scrollTop;
return {x: x, y: y};
*/
return position;
},

```

which amounts to the following:

* if the argument passed in is an event object, then return {x: event.pageX, y: event.pageY}
* else return the obj that was passed in

Seems sort of ridiculous. For the first bullet, just replace the function call with ```var position = {x: event.pageX, y: event.pageY};``` For the second bullet, just don't call getContentPosition() because the original obj is not being altered.

This function is only called by a few places:

```
JonFerraioloMacBookPro:ve jonferraiolo$ grep -rn getContentPosition *
Context.js:1377:	getContentPosition: function(position){
themeEditor/Context.js:196:	/*var p = this.getContentPosition(box);
themeEditor/SelectTool.js:51:	var p = this._context.getContentPosition(box);
themeEditor/SelectTool.js:207:	var p = this._context.getContentPosition(this._context.getDojo().position(parentNode, true));
tools/CreateTool.js:54:	this._mdPosition = this._context.getContentPosition(event); // mouse down position
tools/CreateTool.js:73:	var p = context.getContentPosition(event);
tools/CreateTool.js:132:	this._position = this._mdPosition ? this._mdPosition : context.getContentPosition(event);
tools/CreateTool.js:210:	var p = context.getContentPosition(event);
tools/CreateTool.js:336:	var p = this._context.getContentPosition(dojo.coords(parentNode));
tools/SelectTool.js:243:	var p = this._context.getContentPosition(this._context.getDojo().position(parentNode, true));
widget.js:87:	p = context.getContentPosition(c),
widget.js:107:	p = context.getContentPosition(c);
JonFerraioloMacBookPro:ve jonferraiolo$
```