Replace core.Utils.isDefined for $defined.

This commit is contained in:
Paulo Veiga
2011-07-27 13:44:09 -03:00
parent f60755fd8e
commit 0b67b42045
66 changed files with 406 additions and 401 deletions

View File

@@ -25,7 +25,7 @@ web2d.Element = function(peer, attributes)
}
this._dispatcherByEventType = new Hash({});
if (core.Utils.isDefined(attributes))
if ($defined(attributes))
{
this._initialize(attributes);
}
@@ -42,7 +42,7 @@ web2d.Element.prototype._initialize = function(attributes)
{
var funcName = this._attributeNameToFuncName(key, 'set');
var funcArgs = batchExecute[funcName];
if (!core.Utils.isDefined(funcArgs))
if (!$defined(funcArgs))
{
funcArgs = [];
}
@@ -63,7 +63,7 @@ web2d.Element.prototype._initialize = function(attributes)
for (var key in batchExecute)
{
var func = this[key];
if (!core.Utils.isDefined(func))
if (!$defined(func))
{
throw "Could not find function: " + key;
}
@@ -223,7 +223,7 @@ web2d.Element.prototype._propertyNameToSignature =
web2d.Element.prototype._attributeNameToFuncName = function(attributeKey, prefix)
{
var signature = this._propertyNameToSignature[attributeKey];
if (!core.Utils.isDefined(signature))
if (!$defined(signature))
{
throw "Unsupported attribute: " + attributeKey;
}
@@ -292,13 +292,13 @@ web2d.Element.prototype.getAttribute = function(key)
var getterResult = getter.apply(this, []);
var attibuteName = signature[2];
if (!core.Utils.isDefined(attibuteName))
if (!$defined(attibuteName))
{
throw "Could not find attribute mapping for:" + key;
}
var result = getterResult[attibuteName];
if (!core.Utils.isDefined(result))
if (!$defined(result))
{
throw "Could not find attribute with name:" + attibuteName;
}

View File

@@ -35,7 +35,7 @@ web2d.EventDispatcher = function(element)
web2d.EventDispatcher.prototype.addListener = function(type, listener)
{
if (!core.Utils.isDefined(listener))
if (!$defined(listener))
{
throw "Listener can not be null.";
}
@@ -44,7 +44,7 @@ web2d.EventDispatcher.prototype.addListener = function(type, listener)
web2d.EventDispatcher.prototype.removeListener = function(type, listener)
{
if (!core.Utils.isDefined(listener))
if (!$defined(listener))
{
throw "Listener can not be null.";
}

View File

@@ -37,7 +37,7 @@ objects.extend(web2d.Group, web2d.Element);
*/
web2d.Group.prototype.removeChild = function(element)
{
if (!core.Utils.isDefined(element))
if (!$defined(element))
{
throw "Child element can not be null";
}
@@ -61,7 +61,7 @@ web2d.Group.prototype.removeChild = function(element)
*/
web2d.Group.prototype.appendChild = function(element)
{
if (!core.Utils.isDefined(element))
if (!$defined(element))
{
throw "Child element can not be null";
}
@@ -144,7 +144,7 @@ web2d.Group.prototype.getCoordSize = function()
web2d.Group.prototype.appendDomChild = function(DomElement)
{
if (!core.Utils.isDefined(DomElement))
if (!$defined(DomElement))
{
throw "Child element can not be null";
}

View File

@@ -56,7 +56,7 @@ web2d.Workspace.prototype._disableTextSelection = function()
contaier.onselectstart = new Function("return false");
//if the browser is NS6
if (core.Utils.isDefined(window.sidebar))
if ($defined(window.sidebar))
{
contaier.onmousedown = disabletext;
contaier.onclick = reEnable;
@@ -73,7 +73,7 @@ web2d.Workspace.prototype.getType = function()
*/
web2d.Workspace.prototype.appendChild = function(element)
{
if (!core.Utils.isDefined(element))
if (!$defined(element))
{
throw "Child element can not be null";
}
@@ -96,7 +96,7 @@ web2d.Workspace.prototype.appendChild = function(element)
*/
web2d.Workspace.prototype.addItAsChildTo = function(element)
{
if (!core.Utils.isDefined(element))
if (!$defined(element))
{
throw "Workspace div container can not be null";
}
@@ -131,13 +131,13 @@ web2d.Workspace.prototype._createDivContainer = function(domElement)
web2d.Workspace.prototype.setSize = function(width, height)
{
// HTML container must have the size of the group element.
if (core.Utils.isDefined(width))
if ($defined(width))
{
this._htmlContainer.style.width = width;
}
if (core.Utils.isDefined(height))
if ($defined(height))
{
this._htmlContainer.style.height = height;
}
@@ -232,7 +232,7 @@ web2d.Workspace.prototype.getCoordSize = function()
*/
web2d.Workspace.prototype.removeChild = function(element)
{
if (!core.Utils.isDefined(element))
if (!$defined(element))
{
throw "Child element can not be null";
}

View File

@@ -51,7 +51,7 @@ web2d.peer.svg.ArrowPeer.prototype.setStrokeWidth = function(width)
};
web2d.peer.svg.ArrowPeer.prototype.setDashed = function(isDashed, length, spacing){
if(core.Utils.isDefined(isDashed) && isDashed && core.Utils.isDefined(length) && core.Utils.isDefined(spacing)){
if($defined(isDashed) && isDashed && $defined(length) && $defined(spacing)){
this._native.setAttribute("stroke-dasharray",length+","+spacing);
} else {
this._native.setAttribute("stroke-dasharray","");

View File

@@ -34,7 +34,7 @@ objects.extend(web2d.peer.svg.CurvedLinePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){
this._customControlPoint_1 = true;
var change = this._control1.x!=control.x || this._control1.y!=control.y;
if(core.Utils.isDefined(control.x)){
if($defined(control.x)){
this._control1 = control;
this._control1.x = parseInt(this._control1.x);
this._control1.y = parseInt(this._control1.y)
@@ -46,7 +46,7 @@ web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){
web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){
this._customControlPoint_2 = true;
var change = this._control2.x!=control.x || this._control2.y!=control.y;
if(core.Utils.isDefined(control.x)){
if($defined(control.x)){
this._control2 = control;
this._control2.x = parseInt(this._control2.x);
this._control2.y = parseInt(this._control2.y)
@@ -160,7 +160,7 @@ web2d.peer.svg.CurvedLinePeer.prototype.isShowStartArrow = function(){
web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix)
{
if(core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y2))
if($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2))
{
this._calculateAutoControlPoints(avoidControlPointFix);
var path = "M"+this._x1+","+this._y1
@@ -189,18 +189,18 @@ web2d.peer.svg.CurvedLinePeer.prototype._updateStyle = function()
web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(avoidControlPointFix){
//Both points available, calculate real points
var defaultpoints = core.Utils.calculateDefaultControlPoints(new core.Point(this._x1, this._y1),new core.Point(this._x2,this._y2));
if(!this._customControlPoint_1 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==0)){
if(!this._customControlPoint_1 && !($defined(avoidControlPointFix) && avoidControlPointFix==0)){
this._control1.x = defaultpoints[0].x;
this._control1.y = defaultpoints[0].y;
}
if(!this._customControlPoint_2 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==1)){
if(!this._customControlPoint_2 && !($defined(avoidControlPointFix) && avoidControlPointFix==1)){
this._control2.x = defaultpoints[1].x;
this._control2.y = defaultpoints[1].y;
}
};
web2d.peer.svg.CurvedLinePeer.prototype.setDashed = function(length,spacing){
if(core.Utils.isDefined(length) && core.Utils.isDefined(spacing)){
if($defined(length) && $defined(spacing)){
this._native.setAttribute("stroke-dasharray",length+","+spacing);
} else {
this._native.setAttribute("stroke-dasharray","");

View File

@@ -36,7 +36,7 @@ web2d.peer.svg.ElementPeer.prototype.setChildren = function(children)
web2d.peer.svg.ElementPeer.prototype.getChildren = function()
{
var result = this._children;
if (!core.Utils.isDefined(result))
if (!$defined(result))
{
result = [];
this._children = result;
@@ -152,13 +152,13 @@ web2d.peer.svg.ElementPeer.prototype.removeEventListener = function(type, listen
web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height)
{
if (core.Utils.isDefined(width) && this._size.width != parseInt(width))
if ($defined(width) && this._size.width != parseInt(width))
{
this._size.width = parseInt(width);
this._native.setAttribute('width', parseInt(width));
}
if (core.Utils.isDefined(height) && this._size.height != parseInt(height))
if ($defined(height) && this._size.height != parseInt(height))
{
this._size.height = parseInt(height);
this._native.setAttribute('height', parseInt(height));
@@ -174,11 +174,11 @@ web2d.peer.svg.ElementPeer.prototype.getSize = function()
web2d.peer.svg.ElementPeer.prototype.setFill = function(color, opacity)
{
if (core.Utils.isDefined(color))
if ($defined(color))
{
this._native.setAttribute('fill', color);
}
if (core.Utils.isDefined(opacity))
if ($defined(opacity))
{
this._native.setAttribute('fill-opacity', opacity);
}
@@ -204,15 +204,15 @@ web2d.peer.svg.ElementPeer.prototype.getStroke = function()
web2d.peer.svg.ElementPeer.prototype.__stokeStyleToStrokDasharray = {solid:[],dot:[1,3],dash:[4,3],longdash:[10,2],dashdot:[5,3,1,3]};
web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, opacity)
{
if (core.Utils.isDefined(width))
if ($defined(width))
{
this._native.setAttribute('stroke-width', width + "px");
}
if (core.Utils.isDefined(color))
if ($defined(color))
{
this._native.setAttribute('stroke', color);
}
if (core.Utils.isDefined(style))
if ($defined(style))
{
// Scale the dash array in order to be equal to VML. In VML, stroke style doesn't scale.
var dashArrayPoints = this.__stokeStyleToStrokDasharray[style];
@@ -235,7 +235,7 @@ web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, o
this._stokeStyle = style;
}
if (core.Utils.isDefined(opacity))
if ($defined(opacity))
{
this._native.setAttribute('stroke-opacity', opacity);
}
@@ -270,7 +270,7 @@ web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle = function()
web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type, listener)
{
var listeners = this.getChangeEventListeners(type);
if (!core.Utils.isDefined(listener))
if (!$defined(listener))
{
throw "Listener can not be null";
}
@@ -280,7 +280,7 @@ web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type,
web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type)
{
var listeners = this._changeListeners[type];
if (!core.Utils.isDefined(listeners))
if (!$defined(listeners))
{
listeners = [];
this._changeListeners[type] = listeners;

View File

@@ -29,12 +29,12 @@ objects.extend(web2d.peer.svg.ElipsePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.ElipsePeer.prototype.setSize = function(width, height)
{
web2d.peer.svg.ElipsePeer.superClass.setSize.call(this, width, height);
if (core.Utils.isDefined(width))
if ($defined(width))
{
this._native.setAttribute('rx', width / 2);
}
if (core.Utils.isDefined(height))
if ($defined(height))
{
this._native.setAttribute('ry', height / 2);
}
@@ -48,12 +48,12 @@ web2d.peer.svg.ElipsePeer.prototype.setPosition = function(cx, cy)
var size =this.getSize();
cx =cx + size.width/2;
cy =cy + size.height/2;
if (core.Utils.isDefined(cx))
if ($defined(cx))
{
this._native.setAttribute('cx', cx);
}
if (core.Utils.isDefined(cy))
if ($defined(cy))
{
this._native.setAttribute('cy', cy);
}

View File

@@ -25,15 +25,15 @@ web2d.peer.svg.Font = function()
web2d.peer.svg.Font.prototype.init = function(args)
{
if (core.Utils.isDefined(args.size))
if ($defined(args.size))
{
this._size = parseInt(args.size);
}
if (core.Utils.isDefined(args.style))
if ($defined(args.style))
{
this._style = args.style;
}
if (core.Utils.isDefined(args.weight))
if ($defined(args.weight))
{
this._weight = args.weight;
}

View File

@@ -84,12 +84,12 @@ web2d.peer.svg.GroupPeer.prototype.updateTransform = function()
web2d.peer.svg.GroupPeer.prototype.setCoordOrigin = function(x, y)
{
var change = x!=this._coordOrigin.x || y!=this._coordOrigin.y;
if (core.Utils.isDefined(x))
if ($defined(x))
{
this._coordOrigin.x = x;
}
if (core.Utils.isDefined(y))
if ($defined(y))
{
this._coordOrigin.y = y;
}
@@ -108,12 +108,12 @@ web2d.peer.svg.GroupPeer.prototype.setSize = function(width, height)
web2d.peer.svg.GroupPeer.prototype.setPosition = function(x, y)
{
var change = x!=this._position.x || y!=this._position.y;
if (core.Utils.isDefined(x))
if ($defined(x))
{
this._position.x = parseInt(x);
}
if (core.Utils.isDefined(y))
if ($defined(y))
{
this._position.y = parseInt(y);
}

View File

@@ -55,12 +55,12 @@ web2d.peer.svg.LinePeer.prototype.getTo = function(){
*/
web2d.peer.svg.LinePeer.prototype.setArrowStyle = function(startStyle, endStyle)
{
if (core.Utils.isDefined(startStyle))
if ($defined(startStyle))
{
// Todo: This must be implemented ...
}
if (core.Utils.isDefined(endStyle))
if ($defined(endStyle))
{
// Todo: This must be implemented ...
}

View File

@@ -79,7 +79,7 @@ web2d.peer.svg.PolyLinePeer.prototype._updatePath = function()
web2d.peer.svg.PolyLinePeer.prototype._updateStraightPath = function()
{
if (core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._y2))
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2))
{
var path = web2d.PolyLine.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
this._native.setAttribute('points', path);
@@ -92,7 +92,7 @@ web2d.peer.svg.PolyLinePeer.prototype._updateMiddleCurvePath = function()
var y1 = this._y1;
var x2 = this._x2;
var y2 = this._y2;
if (core.Utils.isDefined(x1) && core.Utils.isDefined(x2) && core.Utils.isDefined(y1) && core.Utils.isDefined(y2))
if ($defined(x1) && $defined(x2) && $defined(y1) && $defined(y2))
{
var diff = x2 - x1;
var middlex = (diff / 2) + x1;
@@ -113,7 +113,7 @@ web2d.peer.svg.PolyLinePeer.prototype._updateMiddleCurvePath = function()
web2d.peer.svg.PolyLinePeer.prototype._updateCurvePath = function()
{
if (core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._y2))
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2))
{
var path = web2d.PolyLine.buildCurvedPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
this._native.setAttribute('points', path);

View File

@@ -31,11 +31,11 @@ objects.extend(web2d.peer.svg.RectPeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.RectPeer.prototype.setPosition = function(x, y)
{
if (core.Utils.isDefined(x))
if ($defined(x))
{
this._native.setAttribute('x', parseInt(x));
}
if (core.Utils.isDefined(y))
if ($defined(y))
{
this._native.setAttribute('y', parseInt(y));
}
@@ -53,7 +53,7 @@ web2d.peer.svg.RectPeer.prototype.setSize = function(width, height)
web2d.peer.svg.RectPeer.superClass.setSize.call(this, width, height);
var min = width < height?width:height;
if (core.Utils.isDefined(this._arc))
if ($defined(this._arc))
{
// Transform percentages to SVG format.
var arc = (min / 2) * this._arc;

View File

@@ -45,7 +45,7 @@ web2d.peer.svg.TextPeer.prototype.setText = function(text)
{
text = core.Utils.escapeInvalidTags(text);
var child = this._native.firstChild;
if (core.Utils.isDefined(child))
if ($defined(child))
{
this._native.removeChild(child);
}
@@ -63,7 +63,7 @@ web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y)
{
this._position = {x:x, y:y};
var height = this._font.getSize();
if(core.Utils.isDefined(this._parent) && core.Utils.isDefined(this._native.getBBox))
if($defined(this._parent) && $defined(this._native.getBBox))
height = this.getHeight();
var size = parseInt(height);
this._native.setAttribute('y', y+size*3/4);
@@ -78,19 +78,19 @@ web2d.peer.svg.TextPeer.prototype.getPosition = function()
web2d.peer.svg.TextPeer.prototype.setFont = function(font, size, style, weight)
{
if (core.Utils.isDefined(font))
if ($defined(font))
{
this._font = new web2d.Font(font, this);
}
if (core.Utils.isDefined(style))
if ($defined(style))
{
this._font.setStyle(style);
}
if (core.Utils.isDefined(weight))
if ($defined(weight))
{
this._font.setWeight(weight);
}
if (core.Utils.isDefined(size))
if ($defined(size))
{
this._font.setSize(size);
}

View File

@@ -46,12 +46,12 @@ web2d.peer.svg.WorkspacePeer.prototype.setCoordSize = function(width, height)
{
coords = viewBox.split(/ /);
}
if (core.Utils.isDefined(width))
if ($defined(width))
{
coords[2] = width;
}
if (core.Utils.isDefined(height))
if ($defined(height))
{
coords[3] = height;
}
@@ -83,12 +83,12 @@ web2d.peer.svg.WorkspacePeer.prototype.setCoordOrigin = function(x, y)
coords = viewBox.split(/ /);
}
if (core.Utils.isDefined(x))
if ($defined(x))
{
coords[0] = x;
}
if (core.Utils.isDefined(y))
if ($defined(y))
{
coords[1] = y;
}

View File

@@ -21,7 +21,7 @@ web2d.peer.utils.EventUtils =
broadcastChangeEvent:function (elementPeer, type)
{
var listeners = elementPeer.getChangeEventListeners(type);
if (core.Utils.isDefined(listeners))
if ($defined(listeners))
{
for (var i = 0; i < listeners.length; i++)
{