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
64058ae4
Commit
64058ae4
authored
Jun 11, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加连线随布局变化的机制
parent
e8a6e782
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
187 additions
and
29 deletions
+187
-29
resource.js
dialogs/resource/resource.js
+16
-17
import.js
import.js
+2
-1
connect.js
src/core/connect.js
+77
-0
default.js
src/layout/default.js
+54
-1
resource.js
src/module/resource.js
+38
-10
No files found.
dialogs/resource/resource.js
View file @
64058ae4
(
function
(
utils
)
{
(
function
(
utils
)
{
KM
.
registerWidget
(
'resource'
,
{
KM
.
registerWidget
(
'resource'
,
{
tpl
:
tpl
:
'<div class="resource-container">'
+
'<div class="resource-container">'
+
'<div class="add-resource">'
+
'<div class="add-resource">'
+
'<input type="text" /><button class="button">添加</button>'
+
'<input type="text" /><button class="button">添加</button>'
+
'<ul class="global-resource"></ul>'
+
'<ul class="global-resource"></ul>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'<div class="no-selected">未选中节点</div>'
,
'<div class="no-selected">未选中节点</div>'
,
initContent
:
function
(
km
,
$w
)
{
initContent
:
function
(
km
,
$w
)
{
var
lang
=
km
.
getLang
(
'dialogs.resource'
),
var
lang
=
km
.
getLang
(
'dialogs.resource'
),
html
=
$
.
parseTmpl
(
this
.
tpl
,
lang
);
html
=
$
.
parseTmpl
(
this
.
tpl
,
lang
);
this
.
root
().
html
(
html
);
this
.
root
().
html
(
html
);
},
},
initEvent
:
function
(
km
,
$w
)
{
initEvent
:
function
(
km
,
$w
)
{
var
$container
=
$w
.
find
(
'.resource-container'
);
var
$container
=
$w
.
find
(
'.resource-container'
);
var
$noSelected
=
$w
.
find
(
'.no-selected'
);
var
$noSelected
=
$w
.
find
(
'.no-selected'
);
var
$current
=
$w
.
find
(
'.current-resource'
).
hide
();
var
$current
=
$w
.
find
(
'.current-resource'
).
hide
();
...
@@ -43,7 +42,7 @@
...
@@ -43,7 +42,7 @@
$addInput
.
val
(
null
);
$addInput
.
val
(
null
);
}
}
$addInput
.
on
(
'keydown'
,
function
(
e
)
{
$addInput
.
on
(
'keydown'
,
function
(
e
)
{
if
(
e
.
keyCode
==
13
)
addResource
();
if
(
e
.
keyCode
==
13
)
addResource
();
});
});
...
@@ -51,25 +50,25 @@
...
@@ -51,25 +50,25 @@
switchDisplay
();
switchDisplay
();
$global
.
delegate
(
'input[type=checkbox]'
,
'change'
,
function
()
{
$global
.
delegate
(
'input[type=checkbox]'
,
'change'
,
function
()
{
km
.
execCommand
(
'resource'
,
$global
.
find
(
'input[type=checkbox]:checked'
).
map
(
function
(
index
,
chk
)
{
km
.
execCommand
(
'resource'
,
$global
.
find
(
'input[type=checkbox]:checked'
).
map
(
function
(
index
,
chk
)
{
return
$
(
chk
).
data
(
'resource'
);
return
$
(
chk
).
data
(
'resource'
);
}).
toArray
());
}).
toArray
());
});
});
km
.
on
(
'interactchange'
,
function
(
e
)
{
km
.
on
(
'interactchange'
,
function
(
e
)
{
var
resource
=
this
.
queryCommandValue
(
"resource"
);
var
resource
=
this
.
queryCommandValue
(
"resource"
);
var
used
=
this
.
getUsedResource
();
var
used
=
this
.
getUsedResource
();
switchDisplay
();
switchDisplay
();
$global
.
empty
().
append
(
used
.
map
(
function
(
name
)
{
$global
.
empty
().
append
(
used
.
map
(
function
(
name
)
{
var
$li
=
$
(
'<li></li>'
),
var
$li
=
$
(
'<li></li>'
),
$label
=
$
(
'<label></label>'
).
appendTo
(
$li
),
$label
=
$
(
'<label></label>'
).
appendTo
(
$li
),
$chk
=
$
(
'<input type="checkbox" />'
)
$chk
=
$
(
'<input type="checkbox" />'
)
.
data
(
'resource'
,
name
)
.
data
(
'resource'
,
name
)
.
prop
(
'checked'
,
~
resource
.
indexOf
(
name
))
.
prop
(
'checked'
,
~
resource
.
indexOf
(
name
))
.
appendTo
(
$label
);
.
appendTo
(
$label
);
$label
.
append
(
name
);
$label
.
append
(
name
);
var
color
=
km
.
getResourceColor
(
name
);
var
color
=
km
.
getResourceColor
(
name
);
return
$li
.
css
({
return
$li
.
css
({
...
...
import.js
View file @
64058ae4
...
@@ -15,12 +15,14 @@
...
@@ -15,12 +15,14 @@
'core/minder.module.js'
,
'core/minder.module.js'
,
'core/minder.command.js'
,
'core/minder.command.js'
,
'core/minder.node.js'
,
'core/minder.node.js'
,
'core/minder.select.js'
,
'core/keymap.js'
,
'core/keymap.js'
,
'core/minder.lang.js'
,
'core/minder.lang.js'
,
'core/minder.defaultoptions.js'
,
'core/minder.defaultoptions.js'
,
'core/minder.preference.js'
,
'core/minder.preference.js'
,
'core/browser.js'
,
'core/browser.js'
,
'core/layout.js'
,
'core/layout.js'
,
'core/connect.js'
,
'core/render.js'
,
'core/render.js'
,
'core/theme.js'
,
'core/theme.js'
,
'layout/default.js'
,
'layout/default.js'
,
...
@@ -34,7 +36,6 @@
...
@@ -34,7 +36,6 @@
'module/priority.js'
,
'module/priority.js'
,
'module/image.js'
,
'module/image.js'
,
'module/resource.js'
,
'module/resource.js'
,
'core/minder.select.js'
,
'module/view.js'
,
'module/view.js'
,
'module/dragtree.js'
,
'module/dragtree.js'
,
'module/dropfile.js'
,
'module/dropfile.js'
,
...
...
src/
modul
e/connect.js
→
src/
cor
e/connect.js
View file @
64058ae4
/* global Renderer: true */
/* global Renderer: true */
utils
.
extend
(
KityMinder
,
{
_connectProviders
:
{},
_defaultConnectProvider
:
function
(
node
,
parent
)
{
return
[
'M'
,
parent
.
getLayoutPoint
(),
'L'
,
node
.
getLayoutPoint
()
];
},
registerConnectProvider
:
function
(
layout
,
provider
)
{
KityMinder
.
_connectProviders
[
layout
]
=
provider
;
},
getConnectProvider
:
function
(
layout
)
{
return
KityMinder
.
_connectProviders
[
layout
]
||
KityMinder
.
_defaultConnectProvider
;
}
});
kity
.
extendClass
(
Minder
,
{
kity
.
extendClass
(
Minder
,
{
createConnect
:
function
(
node
)
{
createConnect
:
function
(
node
)
{
...
@@ -30,59 +49,14 @@ kity.extendClass(Minder, {
...
@@ -30,59 +49,14 @@ kity.extendClass(Minder, {
if
(
!
parent
)
return
;
if
(
!
parent
)
return
;
var
box
=
node
.
getLayoutBox
(),
pBox
=
parent
.
getLayoutBox
();
var
start
,
end
,
vector
;
var
abs
=
Math
.
abs
;
var
pathData
=
[];
var
side
=
box
.
cx
>
pBox
.
cx
?
'right'
:
'left'
;
if
(
parent
.
isCollapsed
())
{
if
(
parent
.
isCollapsed
())
{
connection
.
setVisible
(
false
);
connection
.
setVisible
(
false
);
return
;
return
;
}
}
connection
.
setVisible
(
true
);
connection
.
setVisible
(
true
);
switch
(
node
.
getType
())
{
var
provider
=
KityMinder
.
getConnectProvider
(
node
.
getLayout
());
var
pathData
=
provider
(
node
,
parent
);
case
'main'
:
start
=
new
kity
.
Point
(
pBox
.
cx
,
pBox
.
cy
);
end
=
side
==
'left'
?
new
kity
.
Point
(
box
.
right
,
box
.
cy
)
:
new
kity
.
Point
(
box
.
left
,
box
.
cy
);
vector
=
kity
.
Vector
.
fromPoints
(
start
,
end
);
pathData
.
push
(
'M'
,
start
);
pathData
.
push
(
'A'
,
abs
(
vector
.
x
),
abs
(
vector
.
y
),
0
,
0
,
(
vector
.
x
*
vector
.
y
>
0
?
0
:
1
),
end
);
break
;
case
'sub'
:
var
radius
=
node
.
getStyle
(
'connect-radius'
);
if
(
side
==
'right'
)
{
start
=
new
kity
.
Point
(
box
.
left
-
node
.
getStyle
(
'margin-left'
)
/
2
,
pBox
.
cy
);
end
=
new
kity
.
Point
(
box
.
right
+
node
.
getStyle
(
'margin-right'
)
/
2
,
box
.
bottom
);
}
else
{
start
=
new
kity
.
Point
(
box
.
right
+
node
.
getStyle
(
'margin-right'
)
/
2
,
pBox
.
cy
);
end
=
new
kity
.
Point
(
box
.
left
-
node
.
getStyle
(
'margin-left'
)
/
2
,
box
.
bottom
);
}
end
.
y
+=
1
;
var
isTop
=
parent
.
children
.
length
>
1
&&
node
.
getIndex
()
===
0
;
pathData
.
push
(
'M'
,
start
);
pathData
.
push
(
'L'
,
start
.
x
,
isTop
?
(
end
.
y
+
radius
)
:
(
end
.
y
-
radius
));
var
sf
=
+
(
side
==
'right'
&&
isTop
||
side
==
'left'
&&
!
isTop
);
var
ex
=
side
==
'right'
?
(
start
.
x
+
radius
)
:
(
start
.
x
-
radius
);
pathData
.
push
(
'A'
,
radius
,
radius
,
0
,
0
,
sf
,
ex
,
end
.
y
);
pathData
.
push
(
'L'
,
end
);
}
connection
.
setPathData
(
pathData
);
connection
.
setPathData
(
pathData
);
}
}
...
...
src/layout/default.js
View file @
64058ae4
/* global Layout:true */
/* global Layout:true */
window
.
layoutSwitch
=
true
;
window
.
layoutSwitch
=
true
;
KityMinder
.
registerLayout
(
'default'
,
kity
.
createClass
({
KityMinder
.
registerLayout
(
'default'
,
kity
.
createClass
({
base
:
Layout
,
base
:
Layout
,
...
@@ -107,4 +108,56 @@ KityMinder.registerLayout('default', kity.createClass({
...
@@ -107,4 +108,56 @@ KityMinder.registerLayout('default', kity.createClass({
});
});
}
}
}
}
}));
}));
\ No newline at end of file
KityMinder
.
registerConnectProvider
(
'default'
,
function
(
node
,
parent
)
{
var
box
=
node
.
getLayoutBox
(),
pBox
=
parent
.
getLayoutBox
();
var
start
,
end
,
vector
;
var
abs
=
Math
.
abs
;
var
pathData
=
[];
var
side
=
box
.
cx
>
pBox
.
cx
?
'right'
:
'left'
;
switch
(
node
.
getType
())
{
case
'main'
:
start
=
new
kity
.
Point
(
pBox
.
cx
,
pBox
.
cy
);
end
=
side
==
'left'
?
new
kity
.
Point
(
box
.
right
,
box
.
cy
)
:
new
kity
.
Point
(
box
.
left
,
box
.
cy
);
vector
=
kity
.
Vector
.
fromPoints
(
start
,
end
);
pathData
.
push
(
'M'
,
start
);
pathData
.
push
(
'A'
,
abs
(
vector
.
x
),
abs
(
vector
.
y
),
0
,
0
,
(
vector
.
x
*
vector
.
y
>
0
?
0
:
1
),
end
);
break
;
case
'sub'
:
var
radius
=
node
.
getStyle
(
'connect-radius'
);
if
(
side
==
'right'
)
{
start
=
new
kity
.
Point
(
box
.
left
-
node
.
getStyle
(
'margin-left'
)
/
2
,
pBox
.
cy
);
end
=
new
kity
.
Point
(
box
.
right
+
node
.
getStyle
(
'margin-right'
)
/
2
,
box
.
bottom
);
}
else
{
start
=
new
kity
.
Point
(
box
.
right
+
node
.
getStyle
(
'margin-right'
)
/
2
,
pBox
.
cy
);
end
=
new
kity
.
Point
(
box
.
left
-
node
.
getStyle
(
'margin-left'
)
/
2
,
box
.
bottom
);
}
end
.
y
+=
1
;
var
isTop
=
parent
.
children
.
length
>
1
&&
node
.
getIndex
()
===
0
;
pathData
.
push
(
'M'
,
start
);
pathData
.
push
(
'L'
,
start
.
x
,
isTop
?
(
end
.
y
+
radius
)
:
(
end
.
y
-
radius
));
var
sf
=
+
(
side
==
'right'
&&
isTop
||
side
==
'left'
&&
!
isTop
);
var
ex
=
side
==
'right'
?
(
start
.
x
+
radius
)
:
(
start
.
x
-
radius
);
pathData
.
push
(
'A'
,
radius
,
radius
,
0
,
0
,
sf
,
ex
,
end
.
y
);
pathData
.
push
(
'L'
,
end
);
}
return
pathData
;
});
src/module/resource.js
View file @
64058ae4
...
@@ -34,7 +34,7 @@ KityMinder.registerModule('Resource', function() {
...
@@ -34,7 +34,7 @@ KityMinder.registerModule('Resource', function() {
colorMapping
[
resource
]
=
nextIndex
;
colorMapping
[
resource
]
=
nextIndex
;
}
}
// 资源过多,找不到可用索引颜色,统一返回白色
åå
// 资源过多,找不到可用索引颜色,统一返回白色
return
RESOURCE_COLOR_SERIES
[
colorMapping
[
resource
]]
||
RESOURCE_COLOR_OVERFLOW
;
return
RESOURCE_COLOR_SERIES
[
colorMapping
[
resource
]]
||
RESOURCE_COLOR_OVERFLOW
;
},
},
...
@@ -162,27 +162,36 @@ KityMinder.registerModule('Resource', function() {
...
@@ -162,27 +162,36 @@ KityMinder.registerModule('Resource', function() {
var
ResourceOverlay
=
kity
.
createClass
(
'ResourceOverlay'
,
{
var
ResourceOverlay
=
kity
.
createClass
(
'ResourceOverlay'
,
{
base
:
kity
.
Group
,
base
:
kity
.
Group
,
constructor
:
function
(
container
,
resourceName
,
color
)
{
constructor
:
function
()
{
this
.
callBase
();
this
.
callBase
();
var
text
,
rect
;
rect
=
this
.
rect
=
new
kity
.
Rect
();
text
=
this
.
text
=
new
kity
.
Text
()
.
setFontSize
(
12
)
.
setVerticalAlign
(
'middle'
);
this
.
addShapes
([
rect
,
text
]);
},
setValue
:
function
(
resourceName
,
color
)
{
var
paddingX
=
8
,
var
paddingX
=
8
,
paddingY
=
4
,
paddingY
=
4
,
borderRadius
=
4
;
borderRadius
=
4
;
var
text
,
box
,
rect
;
var
text
,
box
,
rect
;
container
.
addShape
(
this
);
text
=
this
.
text
text
=
new
kity
.
Text
()
.
setContent
(
resourceName
)
.
setFontSize
(
12
)
.
setVerticalAlign
(
'middle'
)
.
setX
(
paddingX
)
.
setX
(
paddingX
)
.
setContent
(
resourceName
)
.
fill
(
color
.
dec
(
'l'
,
70
));
.
fill
(
color
.
dec
(
'l'
,
70
));
this
.
addShape
(
text
);
box
=
text
.
getBoundaryBox
();
box
=
text
.
getBoundaryBox
();
rect
.
setPosition
(
0
,
box
.
y
-
paddingY
);
rect
.
setSize
(
box
.
width
+
paddingX
*
2
,
box
.
height
+
paddingY
*
2
);
rect
=
new
kity
.
Rect
(
rect
=
new
kity
.
Rect
(
box
.
width
+
paddingX
*
2
,
box
.
width
+
paddingX
*
2
,
box
.
height
+
paddingY
*
2
,
box
.
height
+
paddingY
*
2
,
...
@@ -194,6 +203,21 @@ KityMinder.registerModule('Resource', function() {
...
@@ -194,6 +203,21 @@ KityMinder.registerModule('Resource', function() {
this
.
addShape
(
rect
);
this
.
addShape
(
rect
);
rect
.
bringRear
();
rect
.
bringRear
();
}
});
/**
* @class 资源渲染器
*/
var
ResourceRenderer
=
kity
.
createClass
(
'ResourceRenderer'
,
{
base
:
KityMinder
.
Renderer
,
create
:
function
(
node
)
{
this
.
container
=
new
kity
.
Group
();
this
.
overlays
=
[];
},
update
:
function
(
node
)
{
}
}
});
});
...
@@ -219,6 +243,10 @@ KityMinder.registerModule('Resource', function() {
...
@@ -219,6 +243,10 @@ KityMinder.registerModule('Resource', function() {
});
});
}
}
}
}
},
renderers
:
{
right
:
ResourceRenderer
}
}
};
};
});
});
\ 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