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
135460ed
Commit
135460ed
authored
Jun 16, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:fex-team/kityminder into dev
parents
d471a6a8
543a0834
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
189 additions
and
79 deletions
+189
-79
kity
kity
+1
-1
adapter.js
src/adapter/adapter.js
+77
-76
bottom.js
src/layout/bottom.js
+15
-2
filetree.js
src/layout/filetree.js
+62
-0
filetree.js
src/theme/filetree.js
+34
-0
No files found.
kity
@
437d9c16
Subproject commit
022e5cb489e65df8a38eedf8508478ee1d29c29c
Subproject commit
437d9c160a7961a3843cce3d9e2b01f64090f0df
src/adapter/adapter.js
View file @
135460ed
utils
.
extend
(
KityMinder
,
function
()
{
utils
.
extend
(
KityMinder
,
function
()
{
var
_kityminderUI
=
{},
_kityminderToolbarUI
=
{},
_activeWidget
=
null
,
_widgetData
=
{},
_widgetCallBack
=
{};
return
{
registerUI
:
function
(
uiname
,
fn
)
{
utils
.
each
(
uiname
.
split
(
/
\s
+/
),
function
(
i
,
name
)
{
_kityminderUI
[
name
]
=
fn
;
}
);
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
;
}
);
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
);
}
);
loadUI
:
function
(
km
)
{
utils
.
each
(
_kityminderUI
,
function
(
i
,
fn
)
{
fn
.
call
(
km
);
});
},
_createUI
:
function
(
id
)
{
var
$cont
=
$
(
'<div class="kmui-container"></div>'
),
_createUI
:
function
(
id
)
{
var
$cont
=
$
(
'<div class="kmui-container"></div>'
),
$toolbar
=
$
.
kmuitoolbar
(),
$kmbody
=
$
(
'<div class="kmui-editor-body"></div>'
),
$statusbar
=
$
(
'<div class="kmui-statusbar"></div>'
);
$kmbody
=
$
(
'<div class="kmui-editor-body"></div>'
),
$statusbar
=
$
(
'<div class="kmui-statusbar"></div>'
);
$cont
.
append
(
$toolbar
).
append
(
$kmbody
).
append
(
$statusbar
);
$
(
utils
.
isString
(
id
)
?
'#'
+
id
:
id
).
append
(
$cont
);
$cont
.
append
(
$toolbar
).
append
(
$kmbody
).
append
(
$statusbar
);
$
(
utils
.
isString
(
id
)
?
'#'
+
id
:
id
).
append
(
$cont
);
return
{
'$container'
:
$cont
,
...
...
@@ -36,108 +36,109 @@ utils.extend( KityMinder, function () {
'$statusbar'
:
$statusbar
};
},
_createToolbar
:
function
(
$toolbar
,
km
)
{
var
toolbars
=
km
.
getOptions
(
'toolbars'
);
if
(
toolbars
&&
toolbars
.
length
)
{
_createToolbar
:
function
(
$toolbar
,
km
)
{
var
toolbars
=
km
.
getOptions
(
'toolbars'
);
if
(
toolbars
&&
toolbars
.
length
)
{
var
btns
=
[];
$
.
each
(
toolbars
,
function
(
i
,
uiNames
)
{
$
.
each
(
uiNames
.
split
(
/
\s
+/
),
function
(
index
,
name
)
{
if
(
name
==
'|'
)
{
if
(
$
.
kmuiseparator
)
btns
.
push
(
$
.
kmuiseparator
()
);
$
.
each
(
toolbars
,
function
(
i
,
uiNames
)
{
$
.
each
(
uiNames
.
split
(
/
\s
+/
),
function
(
index
,
name
)
{
if
(
name
==
'|'
)
{
if
(
$
.
kmuiseparator
)
btns
.
push
(
$
.
kmuiseparator
()
);
}
else
{
if
(
_kityminderToolbarUI
[
name
]
)
{
var
ui
=
_kityminderToolbarUI
[
name
].
call
(
km
,
name
);
if
(
ui
)
btns
.
push
(
ui
);
if
(
_kityminderToolbarUI
[
name
]
)
{
var
ui
=
_kityminderToolbarUI
[
name
].
call
(
km
,
name
);
if
(
ui
)
btns
.
push
(
ui
);
}
}
}
);
if
(
btns
.
length
)
$toolbar
.
kmui
().
appendToBtnmenu
(
btns
);
}
);
$toolbar
.
append
(
$
(
'<div class="kmui-dialog-container"></div>'
)
);
}
else
{
});
if
(
btns
.
length
)
$toolbar
.
kmui
().
appendToBtnmenu
(
btns
);
});
$toolbar
.
append
(
$
(
'<div class="kmui-dialog-container"></div>'
)
);
}
else
{
$toolbar
.
hide
();
}
},
_createStatusbar
:
function
(
$statusbar
,
km
)
{
_createStatusbar
:
function
(
$statusbar
,
km
)
{
},
getKityMinder
:
function
(
id
,
options
)
{
var
containers
=
this
.
_createUI
(
id
);
var
km
=
this
.
getMinder
(
containers
.
$body
.
get
(
0
),
options
);
this
.
_createToolbar
(
containers
.
$toolbar
,
km
);
this
.
_createStatusbar
(
containers
.
$statusbar
,
km
);
getKityMinder
:
function
(
id
,
options
)
{
var
containers
=
this
.
_createUI
(
id
);
var
km
=
this
.
getMinder
(
containers
.
$body
.
get
(
0
),
options
);
this
.
_createToolbar
(
containers
.
$toolbar
,
km
);
this
.
_createStatusbar
(
containers
.
$statusbar
,
km
);
km
.
$container
=
containers
.
$container
;
this
.
loadUI
(
km
);
return
km
.
fire
(
'interactchange'
);
this
.
loadUI
(
km
);
return
km
.
fire
(
'interactchange'
);
},
registerWidget
:
function
(
name
,
pro
,
cb
)
{
_widgetData
[
name
]
=
$
.
extend2
(
pro
,
{
registerWidget
:
function
(
name
,
pro
,
cb
)
{
_widgetData
[
name
]
=
$
.
extend2
(
pro
,
{
$root
:
''
,
_preventDefault
:
false
,
root
:
function
(
$el
)
{
return
this
.
$root
||
(
this
.
$root
=
$el
);
root
:
function
(
$el
)
{
return
this
.
$root
||
(
this
.
$root
=
$el
);
},
preventDefault
:
function
()
{
preventDefault
:
function
()
{
this
.
_preventDefault
=
true
;
},
clear
:
false
}
);
if
(
cb
)
{
_widgetCallBack
[
name
]
=
cb
;
});
if
(
cb
)
{
_widgetCallBack
[
name
]
=
cb
;
}
},
getWidgetData
:
function
(
name
)
{
return
_widgetData
[
name
];
getWidgetData
:
function
(
name
)
{
return
_widgetData
[
name
];
},
setWidgetBody
:
function
(
name
,
$widget
,
km
)
{
if
(
!
km
.
_widgetData
)
{
setWidgetBody
:
function
(
name
,
$widget
,
km
)
{
if
(
!
km
.
_widgetData
)
{
utils
.
extend
(
km
,
{
utils
.
extend
(
km
,
{
_widgetData
:
{},
getWidgetData
:
function
(
name
)
{
return
this
.
_widgetData
[
name
];
getWidgetData
:
function
(
name
)
{
return
this
.
_widgetData
[
name
];
},
getWidgetCallback
:
function
(
widgetName
)
{
getWidgetCallback
:
function
(
widgetName
)
{
var
me
=
this
;
return
function
()
{
return
_widgetCallBack
[
widgetName
].
apply
(
me
,
[
me
,
$widget
].
concat
(
utils
.
argsToArray
(
arguments
,
0
)
)
);
return
function
()
{
return
_widgetCallBack
[
widgetName
].
apply
(
me
,
[
me
,
$widget
].
concat
(
utils
.
argsToArray
(
arguments
,
0
))
);
};
}
}
);
});
}
var
pro
=
_widgetData
[
name
];
if
(
!
pro
)
{
var
pro
=
_widgetData
[
name
];
if
(
!
pro
)
{
return
null
;
}
pro
=
km
.
_widgetData
[
name
];
if
(
!
pro
)
{
pro
=
_widgetData
[
name
];
pro
=
km
.
_widgetData
[
name
]
=
$
.
type
(
pro
)
==
'function'
?
pro
:
utils
.
clone
(
pro
);
pro
=
km
.
_widgetData
[
name
];
if
(
!
pro
)
{
pro
=
_widgetData
[
name
];
pro
=
km
.
_widgetData
[
name
]
=
$
.
type
(
pro
)
==
'function'
?
pro
:
utils
.
clone
(
pro
);
}
pro
.
root
(
$widget
.
kmui
().
getBodyContainer
()
);
pro
.
root
(
$widget
.
kmui
().
getBodyContainer
()
);
//清除光标
km
.
fire
(
'selectionclear'
);
pro
.
initContent
(
km
,
$widget
);
pro
.
initContent
(
km
,
$widget
);
//在dialog上阻止键盘冒泡,导致跟编辑输入冲突的问题
$widget
.
on
(
'keydown keyup keypress'
,
function
(
e
)
{
$widget
.
on
(
'keydown keyup keypress'
,
function
(
e
)
{
e
.
stopPropagation
();
});
if
(
!
pro
.
_preventDefault
)
{
pro
.
initEvent
(
km
,
$widget
);
if
(
!
pro
.
_preventDefault
)
{
pro
.
initEvent
(
km
,
$widget
);
}
if
(
pro
.
width
)
$widget
.
width
(
pro
.
width
);
if
(
pro
.
width
)
$widget
.
width
(
pro
.
width
);
},
setActiveWidget
:
function
(
$widget
)
{
setActiveWidget
:
function
(
$widget
)
{
_activeWidget
=
$widget
;
}
};
}()
);
\ No newline at end of file
}());
\ No newline at end of file
src/layout/bottom.js
View file @
135460ed
...
...
@@ -44,13 +44,26 @@ KityMinder.registerLayout('bottom', kity.createClass({
if
(
!
childContentBox
.
width
)
continue
;
//水平方向上的布局
x
+=
childTreeBox
.
width
/
2
;
if
(
i
>
1
)
{
if
(
i
>
0
)
{
x
+=
children
[
i
].
getStyle
(
'margin-left'
);
}
y
=
nodeContentBox
.
height
+
node
.
getStyle
(
'margin-bottom'
)
+
children
[
i
].
getStyle
(
'margin-top'
);
children
[
i
].
setLayoutTransform
(
new
kity
.
Matrix
().
translate
(
x
,
y
));
x
+=
childTreeBox
.
width
/
2
+
children
[
i
].
getStyle
(
'margin-right'
);
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
cx
,
childContentBox
.
bottom
));
}
}
}
}));
\ No newline at end of file
}));
KityMinder
.
registerConnectProvider
(
'bottom'
,
function
(
node
,
parent
)
{
var
box
=
node
.
getLayoutBox
(),
pBox
=
parent
.
getLayoutBox
();
var
abs
=
Math
.
abs
;
var
pathData
=
[];
pathData
.
push
(
'M'
,
new
kity
.
Point
(
pBox
.
cx
,
pBox
.
bottom
));
pathData
.
push
(
'L'
,
new
kity
.
Point
(
pBox
.
cx
,
pBox
.
bottom
+
parent
.
getStyle
(
'margin-bottom'
)));
pathData
.
push
(
'L'
,
new
kity
.
Point
(
box
.
cx
,
pBox
.
bottom
+
parent
.
getStyle
(
'margin-bottom'
)));
pathData
.
push
(
'L'
,
new
kity
.
Point
(
box
.
cx
,
box
.
top
));
return
pathData
;
});
\ No newline at end of file
src/layout/filetree.js
0 → 100644
View file @
135460ed
/* global Layout:true */
window
.
layoutSwitch
=
true
;
KityMinder
.
registerLayout
(
'filetree'
,
kity
.
createClass
({
base
:
Layout
,
doLayout
:
function
(
node
)
{
var
layout
=
this
;
if
(
node
.
isLayoutRoot
())
{
this
.
doLayoutRoot
(
node
);
}
else
{
this
.
arrange
(
node
);
}
},
doLayoutRoot
:
function
(
root
)
{
this
.
arrange
(
root
);
},
arrange
:
function
(
node
)
{
var
children
=
node
.
getChildren
();
var
_this
=
this
;
if
(
!
children
.
length
)
{
return
false
;
}
else
{
var
totalTreeWidth
=
0
;
// 计算每个 child 的树所占的矩形区域
var
childTreeBoxes
=
children
.
map
(
function
(
node
,
index
,
children
)
{
var
box
=
_this
.
getTreeBox
([
node
]);
return
box
;
});
var
nodeContentBox
=
node
.
getContentBox
();
var
i
,
x
,
y
,
child
,
childTreeBox
,
childContentBox
;
var
transform
=
new
kity
.
Matrix
();
y
=
nodeContentBox
.
bottom
+
node
.
getStyle
(
'margin-bottom'
);
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
child
=
children
[
i
];
childTreeBox
=
childTreeBoxes
[
i
];
childContentBox
=
child
.
getContentBox
();
if
(
!
childContentBox
.
width
)
continue
;
x
=
10
;
y
+=
child
.
getStyle
(
'margin-top'
);
child
.
setLayoutTransform
(
new
kity
.
Matrix
().
translate
(
x
,
y
));
y
+=
childTreeBox
.
height
+
children
[
i
].
getStyle
(
'margin-bottom'
);
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
left
+
5
,
childContentBox
.
cy
));
}
}
}
}));
KityMinder
.
registerConnectProvider
(
'filetree'
,
function
(
node
,
parent
)
{
var
box
=
node
.
getLayoutBox
(),
pBox
=
parent
.
getLayoutBox
();
var
abs
=
Math
.
abs
;
var
pathData
=
[];
var
side
=
box
.
cx
>
pBox
.
cx
?
'right'
:
'left'
;
var
left
=
pBox
.
left
+
5
;
pathData
.
push
(
'M'
,
new
kity
.
Point
(
left
,
pBox
.
bottom
));
pathData
.
push
(
'L'
,
new
kity
.
Point
(
left
,
box
.
cy
));
pathData
.
push
(
'L'
,
new
kity
.
Point
(
box
.
left
,
box
.
cy
));
return
pathData
;
});
\ No newline at end of file
src/theme/filetree.js
0 → 100644
View file @
135460ed
KityMinder
.
registerTheme
(
'filetree'
,
{
'root-color'
:
'#430'
,
'root-background'
:
'#e9df98'
,
'root-stroke'
:
'none'
,
'root-font-size'
:
24
,
'root-padding'
:
[
15
,
25
],
'root-margin'
:
100
,
'root-radius'
:
30
,
'root-space'
:
10
,
'main-color'
:
'#333'
,
'main-background'
:
'#a4c5c0'
,
'main-stroke'
:
'none'
,
'main-font-size'
:
16
,
'main-padding'
:
[
6
,
20
],
'main-margin'
:
[
30
,
0
,
10
,
0
],
'main-radius'
:
10
,
'main-space'
:
5
,
'sub-color'
:
'black'
,
'sub-background'
:
'white'
,
'sub-stroke'
:
'none'
,
'sub-font-size'
:
12
,
'sub-padding'
:
[
5
,
10
],
'sub-margin'
:
[
5
,
15
,
10
,
5
],
'sub-radius'
:
5
,
'sub-space'
:
5
,
'connect-color'
:
'white'
,
'connect-width'
:
2
,
'connect-radius'
:
5
,
'selected-background'
:
'rgb(254, 219, 0)'
});
\ 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