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
e3974368
Commit
e3974368
authored
Jun 03, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stash
parent
ff77b6ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
31 deletions
+58
-31
重构方案.md
doc/重构方案.md
+26
-0
adapter.js
src/adapter/adapter.js
+16
-15
minder.module.js
src/core/minder.module.js
+6
-6
basestyle.js
src/module/basestyle.js
+10
-10
No files found.
doc/重构方案.md
0 → 100644
View file @
e3974368
KityMinder 渲染和布局重构方案
=====
## 背景
当前的节点渲染和布局把很多部分的功能都揉在一起来实现,维护和添加新功能都比较困难,所以决定把现有的 layout.js、layout.default.js 和 layout.bottom.js 重构。
## 约定
为了不产生误会,下面约定一些词汇的意思。
渲染:对节点的绘制的过程。渲染参照的坐标系是节点画布的坐标系。
布局:对节点定位的过程,发生在渲染之后。定位使用的坐标系是脑图画布的坐标系。
节点树多边形:表示一个节点以及其子树所占的多边形区域。
### Layout
Layout
### Render
### Connect
### Expander
src/adapter/adapter.js
View file @
e3974368
...
...
@@ -8,17 +8,17 @@ utils.extend( KityMinder, function () {
registerUI
:
function
(
uiname
,
fn
)
{
utils
.
each
(
uiname
.
split
(
/
\s
+/
),
function
(
i
,
name
)
{
_kityminderUI
[
name
]
=
fn
;
}
)
}
)
;
},
registerToolbarUI
:
function
(
uiname
,
fn
)
{
utils
.
each
(
uiname
.
split
(
/
\s
+/
),
function
(
i
,
name
)
{
_kityminderToolbarUI
[
name
]
=
fn
;
}
)
}
)
;
},
loadUI
:
function
(
km
)
{
utils
.
each
(
_kityminderUI
,
function
(
i
,
fn
)
{
fn
.
call
(
km
)
}
)
fn
.
call
(
km
)
;
}
)
;
},
_createUI
:
function
(
id
)
{
var
$cont
=
$
(
'<div class="kmui-container"></div>'
),
...
...
@@ -43,21 +43,21 @@ utils.extend( KityMinder, function () {
$
.
each
(
toolbars
,
function
(
i
,
uiNames
)
{
$
.
each
(
uiNames
.
split
(
/
\s
+/
),
function
(
index
,
name
)
{
if
(
name
==
'|'
)
{
$
.
kmuiseparator
&&
btns
.
push
(
$
.
kmuiseparator
()
);
if
(
$
.
kmuiseparator
)
btns
.
push
(
$
.
kmuiseparator
()
);
}
else
{
if
(
_kityminderToolbarUI
[
name
]
)
{
var
ui
=
_kityminderToolbarUI
[
name
].
call
(
km
,
name
);
ui
&&
btns
.
push
(
ui
);
if
(
ui
)
btns
.
push
(
ui
);
}
}
}
);
btns
.
length
&&
$toolbar
.
kmui
().
appendToBtnmenu
(
btns
);
if
(
btns
.
length
)
$toolbar
.
kmui
().
appendToBtnmenu
(
btns
);
}
);
$toolbar
.
append
(
$
(
'<div class="kmui-dialog-container"></div>'
)
);
}
else
{
$toolbar
.
hide
()
$toolbar
.
hide
()
;
}
},
...
...
@@ -91,7 +91,7 @@ utils.extend( KityMinder, function () {
}
},
getWidgetData
:
function
(
name
)
{
return
_widgetData
[
name
]
return
_widgetData
[
name
]
;
},
setWidgetBody
:
function
(
name
,
$widget
,
km
)
{
if
(
!
km
.
_widgetData
)
{
...
...
@@ -104,10 +104,10 @@ utils.extend( KityMinder, function () {
getWidgetCallback
:
function
(
widgetName
)
{
var
me
=
this
;
return
function
()
{
return
_widgetCallBack
[
widgetName
].
apply
(
me
,
[
me
,
$widget
].
concat
(
utils
.
argsToArray
(
arguments
,
0
)
)
)
}
return
_widgetCallBack
[
widgetName
].
apply
(
me
,
[
me
,
$widget
].
concat
(
utils
.
argsToArray
(
arguments
,
0
)
)
)
;
}
;
}
}
)
}
)
;
}
var
pro
=
_widgetData
[
name
];
...
...
@@ -125,18 +125,19 @@ utils.extend( KityMinder, function () {
//清除光标
km
.
fire
(
'selectionclear'
);
pro
.
initContent
(
km
,
$widget
);
//在dialog上阻止键盘冒泡,导致跟编辑输入冲突的问题
$widget
.
on
(
'keydown keyup keypress'
,
function
(
e
){
e
.
stopPropagation
()
e
.
stopPropagation
()
;
});
if
(
!
pro
.
_preventDefault
)
{
pro
.
initEvent
(
km
,
$widget
);
}
pro
.
width
&&
$widget
.
width
(
pro
.
width
);
if
(
pro
.
width
)
$widget
.
width
(
pro
.
width
);
},
setActiveWidget
:
function
(
$widget
)
{
_activeWidget
=
$widget
;
}
}
}
;
}()
);
\ No newline at end of file
src/core/minder.module.js
View file @
e3974368
...
...
@@ -8,7 +8,7 @@ kity.extendClass( Minder, {
this
.
_query
=
{};
this
.
_modules
=
{};
var
i
,
name
,
module
,
moduleDeals
,
dealCommands
,
dealEvents
;
var
i
,
name
,
type
,
module
,
moduleDeals
,
dealCommands
,
dealEvents
;
var
me
=
this
;
for
(
i
=
0
;
i
<
modulesToLoad
.
length
;
i
++
)
{
...
...
@@ -26,14 +26,14 @@ kity.extendClass( Minder, {
//command加入命令池子
dealCommands
=
moduleDeals
.
commands
;
for
(
var
name
in
dealCommands
)
{
this
.
_commands
[
name
.
toLowerCase
()
]
=
new
dealCommands
[
name
];
for
(
name
in
dealCommands
)
{
this
.
_commands
[
name
.
toLowerCase
()
]
=
new
dealCommands
[
name
]
()
;
}
//绑定事件
dealEvents
=
moduleDeals
.
events
;
if
(
dealEvents
)
{
for
(
var
type
in
dealEvents
)
{
for
(
type
in
dealEvents
)
{
me
.
on
(
type
,
dealEvents
[
type
]
);
}
}
...
...
@@ -43,12 +43,12 @@ kity.extendClass( Minder, {
}
//添加模块的快捷键
if
(
moduleDeals
.
addShortcutKeys
)
{
this
.
addShortcutKeys
(
moduleDeals
.
addShortcutKeys
)
this
.
addShortcutKeys
(
moduleDeals
.
addShortcutKeys
)
;
}
//添加邮件菜单
if
(
moduleDeals
.
contextmenu
){
this
.
addContextmenu
(
moduleDeals
.
contextmenu
)
this
.
addContextmenu
(
moduleDeals
.
contextmenu
)
;
}
}
},
...
...
src/module/basestyle.js
View file @
e3974368
...
...
@@ -12,20 +12,20 @@ KityMinder.registerModule( "basestylemodule", function () {
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'bold'
);
n
.
getTextShape
().
setAttr
(
'font-weight'
);
km
.
updateLayout
(
n
)
}
)
km
.
updateLayout
(
n
)
;
}
)
;
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'bold'
,
true
);
n
.
getTextShape
().
setAttr
(
'font-weight'
,
'bold'
);
km
.
updateLayout
(
n
)
}
)
km
.
updateLayout
(
n
)
;
}
)
;
}
},
queryState
:
function
()
{
var
nodes
=
km
.
getSelectedNodes
(),
result
=
0
;
if
(
nodes
.
length
==
0
)
{
if
(
nodes
.
length
==
=
0
)
{
return
-
1
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
...
...
@@ -47,20 +47,20 @@ KityMinder.registerModule( "basestylemodule", function () {
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'italic'
);
n
.
getTextShape
().
setAttr
(
'font-style'
);
km
.
updateLayout
(
n
)
}
)
km
.
updateLayout
(
n
)
;
}
)
;
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'italic'
,
true
);
n
.
getTextShape
().
setAttr
(
'font-style'
,
'italic'
);
km
.
updateLayout
(
n
)
}
)
km
.
updateLayout
(
n
)
;
}
)
;
}
},
queryState
:
function
()
{
var
nodes
=
km
.
getSelectedNodes
(),
result
=
0
;
if
(
nodes
.
length
==
0
)
{
if
(
nodes
.
length
==
=
0
)
{
return
-
1
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
...
...
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