Merge pull request #10 from GunioRobot/clean

Hi! I cleaned up your code for you!
This commit is contained in:
Dennis Hotson 2011-12-18 07:05:29 -08:00
commit 3c95b6312b
2 changed files with 59 additions and 9 deletions

50
.gitignore vendored Normal file
View File

@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc
# Numerous always-ignore extensions
###################
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
*.sass-cache
# Folders to ignore
###################
.hg
.svn
.CVS
# OS or Editor folders
###################
.DS_Store
Icon?
Thumbs.db
ehthumbs.db
nbproject
.cache
.project
.settings
.tmproj
*.esproj
*.sublime-project
*.sublime-workspace
# Dreamweaver added files
###################
_notes
dwsync.xml
# Komodo
###################
*.komodoproject
.komodotools

View File

@ -14,8 +14,8 @@
/**
* Usage:
* connect two shapes
* parameters:
* source shape [or connection for redrawing],
* parameters:
* source shape [or connection for redrawing],
* target shape,
* style with { fg : linecolor, bg : background color, directed: boolean }
* returns:
@ -45,7 +45,7 @@ Raphael.fn.connection = function (obj1, obj2, style) {
{x: bb2.x - off2, y: bb2.y + bb2.height / 2}, /* WEST 2 */
{x: bb2.x + bb2.width + off2, y: bb2.y + bb2.height / 2} /* EAST 2 */
];
/* distances between objects and according coordinates connection */
var d = {}, dis = [];
@ -89,18 +89,18 @@ Raphael.fn.connection = function (obj1, obj2, style) {
{x:(norm(x4-x3)+norm(y4-y3)+x4).toFixed(3), y:(norm(y4-y3)+norm(x4-x3)+y4).toFixed(3)},
{x:(norm(x4-x3)-norm(y4-y3)+x4).toFixed(3), y:(norm(y4-y3)-norm(x4-x3)+y4).toFixed(3)}
];
path = path + ",M"+arr[0].x+","+arr[0].y+",L"+x4+","+y4+",L"+arr[1].x+","+arr[1].y;
path = path + ",M"+arr[0].x+","+arr[0].y+",L"+x4+","+y4+",L"+arr[1].x+","+arr[1].y;
}
/* function to be used for moving existent path(s), e.g. animate() or attr() */
var move = "attr";
/* applying path(s) */
edge.fg && edge.fg[move]({path:path})
edge.fg && edge.fg[move]({path:path})
|| (edge.fg = selfRef.path(path).attr({stroke: style && style.stroke || "#000", fill: "none"}).toBack());
edge.bg && edge.bg[move]({path:path})
|| style && style.fill && (edge.bg = style.fill.split && selfRef.path(path).attr({stroke: style.fill.split("|")[0], fill: "none", "stroke-width": style.fill.split("|")[1] || 3}).toBack());
/* setting label */
style && style.label
&& (edge.label && edge.label.attr({x:(x1+x4)/2, y:(y1+y4)/2})
style && style.label
&& (edge.label && edge.label.attr({x:(x1+x4)/2, y:(y1+y4)/2})
|| (edge.label = selfRef.text((x1+x4)/2, (y1+y4)/2, style.label).attr({fill: "#000", "font-size": style["font-size"] || "12px"})));
style && style.label && style["label-style"] && edge.label && edge.label.attr(style["label-style"]);
style && style.callback && style.callback(edge);
@ -173,7 +173,7 @@ function doit() {
// calculate bounding box of graph layout.. with ease-in
var currentBB = layout.getBoundingBox();
var targetBB = {bottomleft: new Vector(-2, -2), topright: new Vector(2, 2)};
// auto adjusting bounding box
Layout.requestAnimationFrame(function adjust() {
targetBB = layout.getBoundingBox();
@ -195,7 +195,7 @@ function doit() {
var sy = p.subtract(currentBB.bottomleft).divide(size.y).y * r.height;
return new Vector(sx, sy);
};
var renderer = new Renderer(10, layout,
function clear() {