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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
20 deletions
+50
-20
raphael-packed.js
+0
-0
raphael.js
+50
-20
No files found.
raphael-packed.js
View file @
cad50508
This diff is collapsed.
Click to expand it.
raphael.js
View file @
cad50508
function
Raphael
()
{
return
(
function
(
r
,
args
)
{
r
.
version
=
"0.5.
3
"
;
r
.
version
=
"0.5.
4b
"
;
var
C
=
{};
function
Matrix
(
m11
,
m12
,
m21
,
m22
,
dx
,
dy
)
{
this
.
m
=
[
...
...
@@ -362,6 +362,12 @@ function Raphael() {
arguments
.
callee
.
name
=
"Element"
;
this
[
0
].
attrs
=
{};
this
.
Group
=
group
;
this
.
hide
=
function
()
{
this
[
0
].
style
.
display
=
"none"
;
};
this
.
show
=
function
()
{
this
[
0
].
style
.
display
=
"block"
;
};
this
.
rotate
=
function
(
deg
)
{
Rotation
+=
deg
;
this
.
Group
.
style
.
rotation
=
Rotation
;
...
...
@@ -435,7 +441,7 @@ function Raphael() {
}
for
(
var
i
=
0
,
ii
=
children
.
length
;
i
<
ii
;
i
++
)
{
this
.
attr
.
apply
(
new
item
(
children
[
i
],
this
[
0
],
vml
),
arguments
);
}
;
}
}
else
{
if
(
arguments
.
length
==
2
)
{
var
att
=
arguments
[
0
],
...
...
@@ -498,6 +504,11 @@ function Raphael() {
case
"id"
:
this
[
0
].
id
=
value
;
break
;
case
"text"
:
if
(
this
.
type
==
"text"
)
{
this
[
0
].
string
=
value
;
}
break
;
case
"gradient"
:
addGrdientFill
(
this
,
value
);
}
...
...
@@ -508,6 +519,9 @@ function Raphael() {
if
(
params
.
gradient
)
{
addGrdientFill
(
this
,
params
.
gradient
);
}
if
(
params
.
text
&&
this
.
type
==
"text"
)
{
this
[
0
].
string
=
params
.
text
;
}
if
(
params
.
id
)
{
this
[
0
].
id
=
params
.
id
;
}
...
...
@@ -588,20 +602,15 @@ function Raphael() {
var
g
=
document
.
createElement
(
"rvml:group"
),
gs
=
g
.
style
;
var
el
=
document
.
createElement
(
"rvml:shape"
),
ol
=
el
.
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
;
ps
.
position
=
"absolute"
;
ps
.
top
=
0
;
ps
.
left
=
0
;
ol
.
width
=
vml
.
width
+
"px"
;
ol
.
height
=
vml
.
height
+
"px"
;
ol
.
width
=
vml
.
width
;
ol
.
height
=
vml
.
height
;
gs
.
position
=
"absolute"
;
gs
.
left
=
0
;
gs
.
top
=
0
;
gs
.
width
=
vml
.
width
;
gs
.
height
=
vml
.
height
;
g
.
coordsize
=
vml
.
coordsize
;
g
.
coordorigin
=
vml
.
coordorigin
;
var
o
=
document
.
createElement
(
"rvml:textpath"
);
o
.
string
=
text
;
o
.
on
=
true
;
...
...
@@ -609,9 +618,9 @@ function Raphael() {
o
.
coordorigin
=
vml
.
coordorigin
;
el
.
appendChild
(
o
);
el
.
appendChild
(
path
);
g
.
appendChild
(
el
);
vml
.
canvas
.
appendChild
(
g
);
var
res
=
new
Element
(
o
,
g
,
vml
);
//
g.appendChild(el);
vml
.
canvas
.
appendChild
(
el
);
var
res
=
new
Element
(
o
,
el
,
vml
);
res
.
shape
=
el
;
res
.
type
=
"text"
;
return
res
;
...
...
@@ -749,6 +758,9 @@ function Raphael() {
SVG
.
canvas
.
appendChild
(
el
);
}
var
p
=
new
Element
(
el
,
SVG
);
for
(
var
attr
in
params
)
{
p
.
attrs
[
attr
]
=
params
[
attr
];
}
p
.
isAbsolute
=
true
;
p
.
path
=
[];
p
.
last
=
{
x
:
0
,
y
:
0
,
bx
:
0
,
by
:
0
};
...
...
@@ -992,8 +1004,14 @@ function Raphael() {
Scale
=
1
,
tMatrix
=
null
;
this
[
0
]
=
node
;
this
[
0
].
attrs
=
this
[
0
]
.
attrs
||
{};
this
.
attrs
=
this
.
attrs
||
{};
this
.
transformations
=
[];
this
.
hide
=
function
()
{
this
[
0
].
style
.
display
=
"none"
;
};
this
.
show
=
function
()
{
this
[
0
].
style
.
display
=
"block"
;
};
this
.
rotate
=
function
(
deg
)
{
var
bbox
=
this
.
getBBox
();
this
.
transformations
.
push
(
"rotate("
+
deg
+
" "
+
(
bbox
.
x
+
bbox
.
width
/
2
)
+
" "
+
(
bbox
.
y
+
bbox
.
height
/
2
)
+
")"
);
...
...
@@ -1029,12 +1047,12 @@ function Raphael() {
};
this
.
attr
=
function
()
{
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
)
{
var
values
=
{};
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
;
}
...
...
@@ -1042,7 +1060,7 @@ function Raphael() {
var
att
=
arguments
[
0
],
value
=
arguments
[
1
];
this
[
att
]
=
value
;
this
[
0
]
.
attrs
[
att
]
=
value
;
this
.
attrs
[
att
]
=
value
;
switch
(
att
)
{
case
"rx"
:
case
"cx"
:
...
...
@@ -1066,6 +1084,12 @@ function Raphael() {
case
"stroke-dasharray"
:
this
[
0
].
setAttribute
(
att
,
value
.
replace
(
" "
,
","
));
break
;
case
"text"
:
if
(
this
.
type
==
"text"
)
{
this
[
0
].
removeChild
(
this
[
0
].
firstChild
);
this
[
0
].
appendChild
(
document
.
createTextNode
(
value
));
}
break
;
default
:
var
cssrule
=
att
.
replace
(
/
(\-
.
)
/g
,
function
(
w
)
{
return
w
.
substring
(
1
).
toUpperCase
();
...
...
@@ -1076,11 +1100,13 @@ function Raphael() {
}
}
else
if
(
arguments
.
length
=
1
&&
typeof
arguments
[
0
]
==
"object"
)
{
var
params
=
arguments
[
0
];
if
(
params
)
{
for
(
var
attr
in
params
)
{
this
[
0
]
.
attrs
[
attr
]
=
params
[
attr
];
this
.
attrs
[
attr
]
=
params
[
attr
];
if
(
attr
==
"stroke-dasharray"
)
{
this
[
0
].
setAttribute
(
attr
,
params
[
attr
].
replace
(
" "
,
","
));
}
else
if
(
attr
==
"text"
&&
this
.
type
==
"text"
)
{
this
[
0
].
removeChild
(
this
[
0
].
firstChild
);
this
[
0
].
appendChild
(
document
.
createTextNode
(
params
[
attr
]));
}
else
{
var
cssrule
=
attr
.
replace
(
/
(\-
.
)
/g
,
function
(
w
)
{
return
w
.
substring
(
1
).
toUpperCase
();
...
...
@@ -1090,7 +1116,6 @@ function Raphael() {
this
[
0
].
setAttribute
(
attr
,
params
[
attr
]);
}
}
}
if
(
params
.
gradient
)
{
this
[
0
].
attrs
.
gradient
=
params
.
gradient
;
addGrdientFill
(
this
[
0
],
params
.
gradient
,
svg
);
...
...
@@ -1101,6 +1126,11 @@ function Raphael() {
this
.
toFront
=
function
()
{
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
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