Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
3a14ba9e
Commit
3a14ba9e
authored
Jun 11, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构hyperlink
parent
aa0c2a52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
14 deletions
+36
-14
hyperlink.js
src/module/hyperlink.js
+36
-14
No files found.
src/module/hyperlink.js
View file @
3a14ba9e
...
@@ -9,9 +9,9 @@ KityMinder.registerModule( "hyperlink", function () {
...
@@ -9,9 +9,9 @@ KityMinder.registerModule( "hyperlink", function () {
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'hyperlink'
,
url
);
n
.
setData
(
'hyperlink'
,
url
);
km
.
updateLayout
(
n
);
n
.
render
(
);
}
);
}
);
km
.
layout
();
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
(),
var
nodes
=
km
.
getSelectedNodes
(),
...
@@ -39,8 +39,9 @@ KityMinder.registerModule( "hyperlink", function () {
...
@@ -39,8 +39,9 @@ KityMinder.registerModule( "hyperlink", function () {
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'hyperlink'
);
n
.
setData
(
'hyperlink'
);
km
.
updateLayout
(
n
);
n
.
render
(
);
}
);
}
);
km
.
layout
();
},
},
queryState
:
function
(
km
)
{
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
var
nodes
=
km
.
getSelectedNodes
();
...
@@ -62,33 +63,54 @@ KityMinder.registerModule( "hyperlink", function () {
...
@@ -62,33 +63,54 @@ KityMinder.registerModule( "hyperlink", function () {
}
}
}
)
}
)
},
},
"events"
:
{
'renderers'
:
{
"RenderNodeRight"
:
function
(
e
)
{
right
:
kity
.
createClass
(
'hyperlinkrender'
,
{
var
node
=
e
.
node
,
base
:
KityMinder
.
Renderer
,
url
=
node
.
getData
(
'hyperlink'
);
if
(
url
)
{
create
:
function
(
node
)
{
var
link
=
new
kity
.
HyperLink
(
url
);
var
link
=
new
kity
.
HyperLink
();
var
linkshape
=
new
kity
.
Path
();
var
linkshape
=
new
kity
.
Path
();
var
outline
=
new
kity
.
Rect
(
24
,
22
,
-
2
,
-
6
,
4
).
fill
(
'rgba(255, 255, 255, 0)'
);
var
outline
=
new
kity
.
Rect
(
24
,
22
,
-
2
,
-
6
,
4
).
fill
(
'rgba(255, 255, 255, 0)'
);
var
box
=
node
.
getContRc
().
getBoundaryBox
();
var
style
=
this
.
getCurrentLayoutStyle
()[
node
.
getType
()
];
linkshape
.
setPathData
(
linkShapePath
).
fill
(
'#666'
);
linkshape
.
setPathData
(
linkShapePath
).
fill
(
'#666'
);
link
.
setAttr
(
'xlink:title'
,
url
);
link
.
addShape
(
outline
);
link
.
addShape
(
outline
);
link
.
addShape
(
linkshape
);
link
.
addShape
(
linkshape
);
link
.
setTarget
(
'_blank'
);
link
.
setTarget
(
'_blank'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
node
.
getContRc
().
addShape
(
link
.
setTranslate
(
box
.
x
+
box
.
width
+
style
.
spaceLeft
+
5
,
-
5
)
);
link
.
on
(
'mouseover'
,
function
()
{
link
.
on
(
'mouseover'
,
function
()
{
outline
.
fill
(
'rgba(255, 255, 200, .8)'
);
outline
.
fill
(
'rgba(255, 255, 200, .8)'
);
}).
on
(
'mouseout'
,
function
()
{
}).
on
(
'mouseout'
,
function
()
{
outline
.
fill
(
'rgba(255, 255, 255, 0)'
);
outline
.
fill
(
'rgba(255, 255, 255, 0)'
);
});
});
return
link
;
},
shouldRender
:
function
(
node
)
{
return
node
.
getData
(
'hyperlink'
);
},
update
:
function
(
link
,
node
,
box
)
{
var
href
=
node
.
getData
(
'hyperlink'
);
link
.
setHref
(
href
);
link
.
setAttr
(
'xlink:title'
,
href
);
var
spaceRight
=
node
.
getStyle
(
'space-right'
);
link
.
setTranslate
(
box
.
right
+
spaceRight
+
2
,
-
5
);
return
{
x
:
box
.
right
+
spaceRight
,
y
:
-
11
,
width
:
24
,
height
:
22
};
}
}
}
}
)
}
}
};
};
}
);
}
);
\ No newline at end of file
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