Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
殷洪(管理员)
/
raphael
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cad50508
authored
Sep 18, 2008
by
Dmitry Baranovskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added “text” attribute for text nodes + IE fixes
parent
9a01d454
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
30 deletions
+60
-30
raphael-packed.js
+0
-0
raphael.js
+60
-30
No files found.
raphael-packed.js
View file @
cad50508
This diff is collapsed.
Click to expand it.
raphael.js
View file @
cad50508
function
Raphael
()
{
function
Raphael
()
{
return
(
function
(
r
,
args
)
{
return
(
function
(
r
,
args
)
{
r
.
version
=
"0.5.
3
"
;
r
.
version
=
"0.5.
4b
"
;
var
C
=
{};
var
C
=
{};
function
Matrix
(
m11
,
m12
,
m21
,
m22
,
dx
,
dy
)
{
function
Matrix
(
m11
,
m12
,
m21
,
m22
,
dx
,
dy
)
{
this
.
m
=
[
this
.
m
=
[
...
@@ -362,6 +362,12 @@ function Raphael() {
...
@@ -362,6 +362,12 @@ function Raphael() {
arguments
.
callee
.
name
=
"Element"
;
arguments
.
callee
.
name
=
"Element"
;
this
[
0
].
attrs
=
{};
this
[
0
].
attrs
=
{};
this
.
Group
=
group
;
this
.
Group
=
group
;
this
.
hide
=
function
()
{
this
[
0
].
style
.
display
=
"none"
;
};
this
.
show
=
function
()
{
this
[
0
].
style
.
display
=
"block"
;
};
this
.
rotate
=
function
(
deg
)
{
this
.
rotate
=
function
(
deg
)
{
Rotation
+=
deg
;
Rotation
+=
deg
;
this
.
Group
.
style
.
rotation
=
Rotation
;
this
.
Group
.
style
.
rotation
=
Rotation
;
...
@@ -435,7 +441,7 @@ function Raphael() {
...
@@ -435,7 +441,7 @@ function Raphael() {
}
}
for
(
var
i
=
0
,
ii
=
children
.
length
;
i
<
ii
;
i
++
)
{
for
(
var
i
=
0
,
ii
=
children
.
length
;
i
<
ii
;
i
++
)
{
this
.
attr
.
apply
(
new
item
(
children
[
i
],
this
[
0
],
vml
),
arguments
);
this
.
attr
.
apply
(
new
item
(
children
[
i
],
this
[
0
],
vml
),
arguments
);
}
;
}
}
else
{
}
else
{
if
(
arguments
.
length
==
2
)
{
if
(
arguments
.
length
==
2
)
{
var
att
=
arguments
[
0
],
var
att
=
arguments
[
0
],
...
@@ -498,6 +504,11 @@ function Raphael() {
...
@@ -498,6 +504,11 @@ function Raphael() {
case
"id"
:
case
"id"
:
this
[
0
].
id
=
value
;
this
[
0
].
id
=
value
;
break
;
break
;
case
"text"
:
if
(
this
.
type
==
"text"
)
{
this
[
0
].
string
=
value
;
}
break
;
case
"gradient"
:
case
"gradient"
:
addGrdientFill
(
this
,
value
);
addGrdientFill
(
this
,
value
);
}
}
...
@@ -508,6 +519,9 @@ function Raphael() {
...
@@ -508,6 +519,9 @@ function Raphael() {
if
(
params
.
gradient
)
{
if
(
params
.
gradient
)
{
addGrdientFill
(
this
,
params
.
gradient
);
addGrdientFill
(
this
,
params
.
gradient
);
}
}
if
(
params
.
text
&&
this
.
type
==
"text"
)
{
this
[
0
].
string
=
params
.
text
;
}
if
(
params
.
id
)
{
if
(
params
.
id
)
{
this
[
0
].
id
=
params
.
id
;
this
[
0
].
id
=
params
.
id
;
}
}
...
@@ -588,20 +602,15 @@ function Raphael() {
...
@@ -588,20 +602,15 @@ function Raphael() {
var
g
=
document
.
createElement
(
"rvml:group"
),
gs
=
g
.
style
;
var
g
=
document
.
createElement
(
"rvml:group"
),
gs
=
g
.
style
;
var
el
=
document
.
createElement
(
"rvml:shape"
),
ol
=
el
.
style
;
var
el
=
document
.
createElement
(
"rvml:shape"
),
ol
=
el
.
style
;
var
path
=
document
.
createElement
(
"rvml:path"
),
ps
=
path
.
style
;
var
path
=
document
.
createElement
(
"rvml:path"
),
ps
=
path
.
style
;
path
.
v
=
[
"m"
,
x
,
", "
,
y
,
"l"
,
x
+
1
,
", "
,
y
].
join
(
""
);
path
.
v
=
[
"m"
,
Math
.
round
(
x
),
", "
,
Math
.
round
(
y
),
"l"
,
Math
.
round
(
x
)
+
1
,
", "
,
Math
.
round
(
y
)
].
join
(
""
);
path
.
textpathok
=
true
;
path
.
textpathok
=
true
;
ps
.
position
=
"absolute"
;
ol
.
width
=
vml
.
width
;
ps
.
top
=
0
;
ol
.
height
=
vml
.
height
;
ps
.
left
=
0
;
ol
.
width
=
vml
.
width
+
"px"
;
ol
.
height
=
vml
.
height
+
"px"
;
gs
.
position
=
"absolute"
;
gs
.
position
=
"absolute"
;
gs
.
left
=
0
;
gs
.
left
=
0
;
gs
.
top
=
0
;
gs
.
top
=
0
;
gs
.
width
=
vml
.
width
;
gs
.
width
=
vml
.
width
;
gs
.
height
=
vml
.
height
;
gs
.
height
=
vml
.
height
;
g
.
coordsize
=
vml
.
coordsize
;
g
.
coordorigin
=
vml
.
coordorigin
;
var
o
=
document
.
createElement
(
"rvml:textpath"
);
var
o
=
document
.
createElement
(
"rvml:textpath"
);
o
.
string
=
text
;
o
.
string
=
text
;
o
.
on
=
true
;
o
.
on
=
true
;
...
@@ -609,9 +618,9 @@ function Raphael() {
...
@@ -609,9 +618,9 @@ function Raphael() {
o
.
coordorigin
=
vml
.
coordorigin
;
o
.
coordorigin
=
vml
.
coordorigin
;
el
.
appendChild
(
o
);
el
.
appendChild
(
o
);
el
.
appendChild
(
path
);
el
.
appendChild
(
path
);
g
.
appendChild
(
el
);
//
g.appendChild(el);
vml
.
canvas
.
appendChild
(
g
);
vml
.
canvas
.
appendChild
(
el
);
var
res
=
new
Element
(
o
,
g
,
vml
);
var
res
=
new
Element
(
o
,
el
,
vml
);
res
.
shape
=
el
;
res
.
shape
=
el
;
res
.
type
=
"text"
;
res
.
type
=
"text"
;
return
res
;
return
res
;
...
@@ -749,6 +758,9 @@ function Raphael() {
...
@@ -749,6 +758,9 @@ function Raphael() {
SVG
.
canvas
.
appendChild
(
el
);
SVG
.
canvas
.
appendChild
(
el
);
}
}
var
p
=
new
Element
(
el
,
SVG
);
var
p
=
new
Element
(
el
,
SVG
);
for
(
var
attr
in
params
)
{
p
.
attrs
[
attr
]
=
params
[
attr
];
}
p
.
isAbsolute
=
true
;
p
.
isAbsolute
=
true
;
p
.
path
=
[];
p
.
path
=
[];
p
.
last
=
{
x
:
0
,
y
:
0
,
bx
:
0
,
by
:
0
};
p
.
last
=
{
x
:
0
,
y
:
0
,
bx
:
0
,
by
:
0
};
...
@@ -992,8 +1004,14 @@ function Raphael() {
...
@@ -992,8 +1004,14 @@ function Raphael() {
Scale
=
1
,
Scale
=
1
,
tMatrix
=
null
;
tMatrix
=
null
;
this
[
0
]
=
node
;
this
[
0
]
=
node
;
this
[
0
].
attrs
=
this
[
0
]
.
attrs
||
{};
this
.
attrs
=
this
.
attrs
||
{};
this
.
transformations
=
[];
this
.
transformations
=
[];
this
.
hide
=
function
()
{
this
[
0
].
style
.
display
=
"none"
;
};
this
.
show
=
function
()
{
this
[
0
].
style
.
display
=
"block"
;
};
this
.
rotate
=
function
(
deg
)
{
this
.
rotate
=
function
(
deg
)
{
var
bbox
=
this
.
getBBox
();
var
bbox
=
this
.
getBBox
();
this
.
transformations
.
push
(
"rotate("
+
deg
+
" "
+
(
bbox
.
x
+
bbox
.
width
/
2
)
+
" "
+
(
bbox
.
y
+
bbox
.
height
/
2
)
+
")"
);
this
.
transformations
.
push
(
"rotate("
+
deg
+
" "
+
(
bbox
.
x
+
bbox
.
width
/
2
)
+
" "
+
(
bbox
.
y
+
bbox
.
height
/
2
)
+
")"
);
...
@@ -1029,12 +1047,12 @@ function Raphael() {
...
@@ -1029,12 +1047,12 @@ function Raphael() {
};
};
this
.
attr
=
function
()
{
this
.
attr
=
function
()
{
if
(
arguments
.
length
==
1
&&
typeof
arguments
[
0
]
==
"string"
)
{
if
(
arguments
.
length
==
1
&&
typeof
arguments
[
0
]
==
"string"
)
{
return
this
[
0
]
.
attrs
[
arguments
[
0
]];
return
this
.
attrs
[
arguments
[
0
]];
}
}
if
(
arguments
.
length
==
1
&&
arguments
[
0
]
instanceof
Array
)
{
if
(
arguments
.
length
==
1
&&
arguments
[
0
]
instanceof
Array
)
{
var
values
=
{};
var
values
=
{};
for
(
var
j
in
arguments
[
0
])
{
for
(
var
j
in
arguments
[
0
])
{
values
[
arguments
[
0
][
j
]]
=
this
[
0
]
.
attrs
[
arguments
[
0
][
j
]];
values
[
arguments
[
0
][
j
]]
=
this
.
attrs
[
arguments
[
0
][
j
]];
}
}
return
values
;
return
values
;
}
}
...
@@ -1042,7 +1060,7 @@ function Raphael() {
...
@@ -1042,7 +1060,7 @@ function Raphael() {
var
att
=
arguments
[
0
],
var
att
=
arguments
[
0
],
value
=
arguments
[
1
];
value
=
arguments
[
1
];
this
[
att
]
=
value
;
this
[
att
]
=
value
;
this
[
0
]
.
attrs
[
att
]
=
value
;
this
.
attrs
[
att
]
=
value
;
switch
(
att
)
{
switch
(
att
)
{
case
"rx"
:
case
"rx"
:
case
"cx"
:
case
"cx"
:
...
@@ -1066,6 +1084,12 @@ function Raphael() {
...
@@ -1066,6 +1084,12 @@ function Raphael() {
case
"stroke-dasharray"
:
case
"stroke-dasharray"
:
this
[
0
].
setAttribute
(
att
,
value
.
replace
(
" "
,
","
));
this
[
0
].
setAttribute
(
att
,
value
.
replace
(
" "
,
","
));
break
;
break
;
case
"text"
:
if
(
this
.
type
==
"text"
)
{
this
[
0
].
removeChild
(
this
[
0
].
firstChild
);
this
[
0
].
appendChild
(
document
.
createTextNode
(
value
));
}
break
;
default
:
default
:
var
cssrule
=
att
.
replace
(
/
(\-
.
)
/g
,
function
(
w
)
{
var
cssrule
=
att
.
replace
(
/
(\-
.
)
/g
,
function
(
w
)
{
return
w
.
substring
(
1
).
toUpperCase
();
return
w
.
substring
(
1
).
toUpperCase
();
...
@@ -1076,19 +1100,20 @@ function Raphael() {
...
@@ -1076,19 +1100,20 @@ function Raphael() {
}
}
}
else
if
(
arguments
.
length
=
1
&&
typeof
arguments
[
0
]
==
"object"
)
{
}
else
if
(
arguments
.
length
=
1
&&
typeof
arguments
[
0
]
==
"object"
)
{
var
params
=
arguments
[
0
];
var
params
=
arguments
[
0
];
if
(
params
)
{
for
(
var
attr
in
params
)
{
for
(
var
attr
in
params
)
{
this
.
attrs
[
attr
]
=
params
[
attr
];
this
[
0
].
attrs
[
attr
]
=
params
[
attr
];
if
(
attr
==
"stroke-dasharray"
)
{
if
(
attr
==
"stroke-dasharray"
)
{
this
[
0
].
setAttribute
(
attr
,
params
[
attr
].
replace
(
" "
,
","
));
this
[
0
].
setAttribute
(
attr
,
params
[
attr
].
replace
(
" "
,
","
));
}
else
if
(
attr
==
"text"
&&
this
.
type
==
"text"
)
{
}
else
{
this
[
0
].
removeChild
(
this
[
0
].
firstChild
);
var
cssrule
=
attr
.
replace
(
/
(\-
.
)
/g
,
function
(
w
)
{
this
[
0
].
appendChild
(
document
.
createTextNode
(
params
[
attr
]));
return
w
.
substring
(
1
).
toUpperCase
();
}
else
{
});
var
cssrule
=
attr
.
replace
(
/
(\-
.
)
/g
,
function
(
w
)
{
this
[
0
].
style
[
cssrule
]
=
params
[
attr
];
return
w
.
substring
(
1
).
toUpperCase
();
// Need following line for Firefox
});
this
[
0
].
setAttribute
(
attr
,
params
[
attr
]);
this
[
0
].
style
[
cssrule
]
=
params
[
attr
];
}
// Need following line for Firefox
this
[
0
].
setAttribute
(
attr
,
params
[
attr
]);
}
}
}
}
if
(
params
.
gradient
)
{
if
(
params
.
gradient
)
{
...
@@ -1101,6 +1126,11 @@ function Raphael() {
...
@@ -1101,6 +1126,11 @@ function Raphael() {
this
.
toFront
=
function
()
{
this
.
toFront
=
function
()
{
this
[
0
].
parentNode
.
appendChild
(
this
[
0
]);
this
[
0
].
parentNode
.
appendChild
(
this
[
0
]);
};
};
this
.
toBack
=
function
()
{
if
(
this
[
0
].
parentNode
.
firstChild
!=
this
[
0
])
{
this
[
0
].
parentNode
.
insertBefore
(
this
[
0
],
this
[
0
].
parentNode
.
firstChild
);
}
};
};
};
var
theCircle
=
function
(
svg
,
x
,
y
,
r
)
{
var
theCircle
=
function
(
svg
,
x
,
y
,
r
)
{
var
el
=
document
.
createElementNS
(
svg
.
svgns
,
"circle"
);
var
el
=
document
.
createElementNS
(
svg
.
svgns
,
"circle"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment