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
2c77fc41
Commit
2c77fc41
authored
Jun 18, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
8f997604
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
372 additions
and
375 deletions
+372
-375
layout.js
src/adapter/layout.js
+57
-57
bottom.js
src/layout/bottom.js
+4
-4
filetree.js
src/layout/filetree.js
+3
-6
layout.js
src/module/layout.js
+307
-307
bottom.js
src/theme/bottom.js
+1
-1
No files found.
src/adapter/layout.js
View file @
2c77fc41
KM
.
registerToolbarUI
(
'switchlayout'
,
function
(
name
)
{
var
me
=
this
,
label
=
me
.
getLang
(
'tooltips.'
+
name
),
options
=
{
label
:
label
,
title
:
label
,
comboboxName
:
name
,
items
:
me
.
getLayoutStyleItems
()
||
[],
itemStyles
:
[],
value
:
me
.
getLayoutStyleItems
(),
autowidthitem
:
[],
enabledRecord
:
false
},
$combox
=
null
;
if
(
options
.
items
.
length
==
0
)
{
return
null
;
}
//
var me = this,
//
label = me.getLang('tooltips.' + name),
//
options = {
//
label: label,
//
title: label,
//
comboboxName: name,
//
items: me.getLayoutStyleItems() || [],
//
itemStyles: [],
//
value: me.getLayoutStyleItems(),
//
autowidthitem: [],
//
enabledRecord: false
//
},
//
$combox = null;
//
if (options.items.length == 0) {
//
return null;
//
}
utils
.
each
(
options
.
items
,
function
(
i
,
item
)
{
options
.
items
[
i
]
=
me
.
getLang
(
'layout'
)[
item
];
});
//实例化
$combox
=
$
.
kmuibuttoncombobox
(
options
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
var
comboboxWidget
=
$combox
.
kmui
();
//
utils.each(options.items, function(i, item) {
//
options.items[i] = me.getLang('layout')[item];
//
});
//
//
实例化
//
$combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
//
var comboboxWidget = $combox.kmui();
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
)
{
me
.
execCommand
(
name
,
res
.
value
);
me
.
initStyle
();
}).
on
(
"beforeshow"
,
function
()
{
if
(
$combox
.
parent
().
length
===
0
)
{
$combox
.
appendTo
(
me
.
$container
.
find
(
'.kmui-dialog-container'
));
}
//
comboboxWidget.on('comboboxselect', function(evt, res) {
//
me.execCommand(name, res.value);
//
me.initStyle();
//
}).on("beforeshow", function() {
//
if ($combox.parent().length === 0) {
//
$combox.appendTo(me.$container.find('.kmui-dialog-container'));
//
}
});
//状态反射
me
.
on
(
'interactchange'
,
function
()
{
var
state
=
this
.
queryCommandState
(
name
),
value
=
this
.
queryCommandValue
(
name
);
//设置按钮状态
//
});
//
//
状态反射
//
me.on('interactchange', function() {
//
var state = this.queryCommandState(name),
//
value = this.queryCommandValue(name);
//
//设置按钮状态
comboboxWidget
.
button
().
kmui
().
disabled
(
state
==
-
1
).
active
(
state
==
1
);
//
comboboxWidget.button().kmui().disabled(state == -1).active(state == 1);
if
(
value
)
{
//设置label
value
=
value
.
replace
(
/
[
'"
]
/g
,
''
).
toLowerCase
().
split
(
/
[
'|"
]?\s
*,
\s
*
[\1]?
/
);
comboboxWidget
.
selectItemByLabel
(
value
);
}
//
if (value) {
//
//设置label
//
value = value.replace(/['"]/g, '').toLowerCase().split(/['|"]?\s*,\s*[\1]?/);
//
comboboxWidget.selectItemByLabel(value);
//
}
});
//
});
// var data = [];
// utils.each(me.getLayoutStyleItems(), function (i, v) {
// data.push({
// label: me.getLang('tooltips.' + name) + ' ' + v,
// cmdName: 'switchlayout',
// exec: function () {
// me.execCommand('switchlayout', v);
// }
// });
// });
// data.push({
// divider: 1
// });
// me.addContextmenu(data);
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
//
//
var data = [];
//
//
utils.each(me.getLayoutStyleItems(), function (i, v) {
//
//
data.push({
//
//
label: me.getLang('tooltips.' + name) + ' ' + v,
//
//
cmdName: 'switchlayout',
//
//
exec: function () {
//
//
me.execCommand('switchlayout', v);
//
//
}
//
//
});
//
//
});
//
//
data.push({
//
//
divider: 1
//
//
});
//
//
me.addContextmenu(data);
//
return comboboxWidget.button().addClass('kmui-combobox');
});
\ No newline at end of file
src/layout/bottom.js
View file @
2c77fc41
...
...
@@ -50,20 +50,20 @@ KityMinder.registerLayout('bottom', kity.createClass({
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
));
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
cx
-
5
,
childContentBox
.
bottom
));
}
}
}
}));
KityMinder
.
registerConnectProvider
(
'bottom'
,
function
(
node
,
parent
)
{
KityMinder
.
registerConnectProvider
(
'bottom'
,
function
(
node
,
parent
,
connection
)
{
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
;
console
.
log
(
pathData
);
connection
.
setPathData
(
pathData
);
});
\ No newline at end of file
src/layout/filetree.js
View file @
2c77fc41
...
...
@@ -41,22 +41,19 @@ KityMinder.registerLayout('filetree', kity.createClass({
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
));
child
.
setLayoutVector
(
new
kity
.
Vector
(
childContentBox
.
left
+
10
,
childContentBox
.
bottom
));
}
}
}
}));
KityMinder
.
registerConnectProvider
(
'filetree'
,
function
(
node
,
parent
)
{
KityMinder
.
registerConnectProvider
(
'filetree'
,
function
(
node
,
parent
,
connection
)
{
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
;
connection
.
setPathData
(
pathData
)
;
});
\ No newline at end of file
src/module/layout.js
View file @
2c77fc41
KityMinder
.
registerModule
(
"LayoutModule"
,
function
()
{
var
me
=
this
;
var
clearPaper
=
function
()
{
me
.
_rc
.
remove
();
me
.
_rc
=
new
kity
.
Group
();
me
.
_paper
.
addShape
(
this
.
_rc
);
};
kity
.
extendClass
(
Minder
,
{
addLayoutStyle
:
function
(
name
,
style
)
{
if
(
!
this
.
_layoutStyles
)
this
.
_layoutStyles
=
{};
this
.
_layoutStyles
[
name
]
=
style
;
},
getLayoutStyle
:
function
(
name
)
{
return
this
.
_layoutStyles
[
name
];
},
KityMinder
.
registerModule
(
"LayoutModule"
,
function
()
{
var
me
=
this
;
var
clearPaper
=
function
()
{
me
.
_rc
.
remove
();
me
.
_rc
=
new
kity
.
Group
();
me
.
_paper
.
addShape
(
this
.
_rc
);
};
kity
.
extendClass
(
Minder
,
{
addLayoutStyle
:
function
(
name
,
style
)
{
if
(
!
this
.
_layoutStyles
)
this
.
_layoutStyles
=
{};
this
.
_layoutStyles
[
name
]
=
style
;
},
getLayoutStyle
:
function
(
name
)
{
return
this
.
_layoutStyles
[
name
];
},
getLayoutStyleItems
:
function
()
{
var
items
=
[];
for
(
var
key
in
this
.
_layoutStyles
)
{
items
.
push
(
key
);
}
return
items
;
},
getCurrentStyle
:
function
()
{
var
_root
=
this
.
getRoot
();
return
_root
.
getData
(
"currentstyle"
);
},
setCurrentStyle
:
function
(
name
)
{
var
_root
=
this
.
getRoot
();
_root
.
setData
(
"currentstyle"
,
name
);
return
name
;
},
getCurrentLayoutStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
return
this
.
getLayoutStyle
(
curStyle
).
getCurrentLayoutStyle
.
call
(
this
);
},
highlightNode
:
function
(
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
highlightNode
.
call
(
this
,
node
);
},
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
_rc
.
remove
();
var
transform
=
this
.
_rc
.
transform
;
this
.
_rc
=
new
kity
.
Group
();
this
.
_paper
.
addShape
(
this
.
_rc
);
getLayoutStyleItems
:
function
()
{
var
items
=
[];
for
(
var
key
in
this
.
_layoutStyles
)
{
items
.
push
(
key
);
}
return
items
;
},
getCurrentStyle
:
function
()
{
var
_root
=
this
.
getRoot
();
return
_root
.
getData
(
"currentstyle"
);
},
setCurrentStyle
:
function
(
name
)
{
var
_root
=
this
.
getRoot
();
_root
.
setData
(
"currentstyle"
,
name
);
return
name
;
},
getCurrentLayoutStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
return
this
.
getLayoutStyle
(
curStyle
).
getCurrentLayoutStyle
.
call
(
this
);
},
highlightNode
:
function
(
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
highlightNode
.
call
(
this
,
node
);
},
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
_rc
.
remove
();
var
transform
=
this
.
_rc
.
transform
;
this
.
_rc
=
new
kity
.
Group
();
this
.
_paper
.
addShape
(
this
.
_rc
);
this
.
_rc
.
transform
=
transform
;
this
.
_rc
.
_applyTransform
();
this
.
_rc
.
transform
=
transform
;
this
.
_rc
.
_applyTransform
();
var
_root
=
this
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
});
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
this
.
fire
(
'afterinitstyle'
);
},
appendChildNode
:
function
(
parent
,
node
,
index
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendChildNode
.
call
(
this
,
parent
,
node
,
index
);
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendSiblingNode
.
call
(
this
,
sibling
,
node
);
},
removeNode
:
function
(
nodes
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
removeNode
.
call
(
this
,
nodes
);
},
updateLayout
:
function
(
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
updateLayout
.
call
(
this
,
node
);
},
expandNode
:
function
(
ico
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
expandNode
.
call
(
this
,
ico
);
}
});
kity
.
extendClass
(
MinderNode
,
{
setLayout
:
function
(
k
,
v
)
{
if
(
this
.
_layout
===
undefined
)
{
this
.
_layout
=
{};
}
var
_pros
=
this
.
getLayout
();
Utils
.
extend
(
_pros
,
{
k
:
v
});
this
.
_layout
=
_pros
;
},
getLayout
:
function
(
k
)
{
if
(
k
===
undefined
)
{
return
this
.
_layout
;
}
return
this
.
_layout
[
k
];
},
clearLayout
:
function
()
{
this
.
_layout
=
{};
}
});
var
switchLayout
=
function
(
km
,
style
)
{
var
_root
=
km
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
setPoint
();
n
.
getBgRc
().
clear
();
});
km
.
setCurrentStyle
(
style
);
//km.initStyle();
return
style
;
};
var
SwitchLayoutCommand
=
kity
.
createClass
(
"SwitchLayoutCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
switchLayout
,
queryValue
:
function
(
km
)
{
return
km
.
getCurrentStyle
();
}
};
})());
var
AppendChildNodeCommand
=
kity
.
createClass
(
"AppendChildNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
var
parent
=
km
.
getSelectedNode
();
var
_root
=
this
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
});
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
this
.
fire
(
'afterinitstyle'
);
},
appendChildNode
:
function
(
parent
,
node
,
index
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendChildNode
.
call
(
this
,
parent
,
node
,
index
);
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendSiblingNode
.
call
(
this
,
sibling
,
node
);
},
removeNode
:
function
(
nodes
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
removeNode
.
call
(
this
,
nodes
);
},
updateLayout
:
function
(
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
updateLayout
.
call
(
this
,
node
);
},
expandNode
:
function
(
ico
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
expandNode
.
call
(
this
,
ico
);
}
});
kity
.
extendClass
(
MinderNode
,
{
setLayout
:
function
(
k
,
v
)
{
if
(
this
.
_layout
===
undefined
)
{
this
.
_layout
=
{};
}
var
_pros
=
this
.
getLayout
();
Utils
.
extend
(
_pros
,
{
k
:
v
});
this
.
_layout
=
_pros
;
},
getLayout
:
function
(
k
)
{
if
(
k
===
undefined
)
{
return
this
.
_layout
;
}
return
this
.
_layout
[
k
];
},
clearLayout
:
function
()
{
this
.
_layout
=
{};
}
});
var
switchLayout
=
function
(
km
,
style
)
{
var
_root
=
km
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
setPoint
();
n
.
getBgRc
().
clear
();
});
km
.
setCurrentStyle
(
style
);
//km.initStyle();
return
style
;
};
var
SwitchLayoutCommand
=
kity
.
createClass
(
"SwitchLayoutCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
switchLayout
,
queryValue
:
function
(
km
)
{
return
km
.
getCurrentStyle
();
}
};
})());
var
AppendChildNodeCommand
=
kity
.
createClass
(
"AppendChildNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
var
parent
=
km
.
getSelectedNode
();
if
(
!
parent
)
{
return
null
;
}
if
(
parent
.
getType
()
!==
"root"
&&
parent
.
getChildren
().
length
!==
0
&&
!
parent
.
isExpanded
())
{
km
.
expandNode
(
parent
);
}
parent
.
expand
();
km
.
appendChildNode
(
parent
,
node
);
km
.
select
(
node
,
true
);
return
node
;
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
-
1
;
}
else
{
return
0
;
}
}
};
})());
var
AppendSiblingNodeCommand
=
kity
.
createClass
(
"AppendSiblingNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
null
;
}
if
(
!
parent
)
{
return
null
;
}
if
(
parent
.
getType
()
!==
"root"
&&
parent
.
getChildren
().
length
!==
0
&&
!
parent
.
isExpanded
())
{
km
.
expandNode
(
parent
);
}
parent
.
expand
();
km
.
appendChildNode
(
parent
,
node
);
km
.
select
(
node
,
true
);
return
node
;
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
-
1
;
}
else
{
return
0
;
}
}
};
})());
var
AppendSiblingNodeCommand
=
kity
.
createClass
(
"AppendSiblingNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
null
;
}
if
(
selectedNode
.
isRoot
())
{
node
.
setType
(
"main"
);
km
.
appendChildNode
(
selectedNode
,
node
);
}
else
{
km
.
appendSiblingNode
(
selectedNode
,
node
);
}
km
.
select
(
node
,
true
);
return
node
;
},
queryState
:
function
(
km
)
{
var
selectedNodes
=
km
.
getSelectedNodes
();
//没选中节点和单选root的时候返回不可执行
if
(
selectedNodes
.
length
===
0
||
(
selectedNodes
.
length
===
1
&&
selectedNodes
[
0
]
===
km
.
getRoot
()))
{
return
-
1
;
}
else
{
return
0
;
}
}
};
})());
var
RemoveNodeCommand
=
kity
.
createClass
(
"RemoveNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
)
{
if
(
selectedNode
.
isRoot
())
{
node
.
setType
(
"main"
);
km
.
appendChildNode
(
selectedNode
,
node
);
}
else
{
km
.
appendSiblingNode
(
selectedNode
,
node
);
}
km
.
select
(
node
,
true
);
return
node
;
},
queryState
:
function
(
km
)
{
var
selectedNodes
=
km
.
getSelectedNodes
();
//没选中节点和单选root的时候返回不可执行
if
(
selectedNodes
.
length
===
0
||
(
selectedNodes
.
length
===
1
&&
selectedNodes
[
0
]
===
km
.
getRoot
()))
{
return
-
1
;
}
else
{
return
0
;
}
}
};
})());
var
RemoveNodeCommand
=
kity
.
createClass
(
"RemoveNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
)
{
if
(
km
.
getRoot
().
children
.
length
==
0
)
{
return
;
}
if
(
km
.
getRoot
().
children
.
length
==
0
)
{
return
;
}
var
selectedNodes
=
km
.
getSelectedNodes
();
var
_root
=
km
.
getRoot
();
var
_buffer
=
[];
for
(
var
i
=
0
;
i
<
selectedNodes
.
length
;
i
++
)
{
_buffer
.
push
(
selectedNodes
[
i
]);
}
do
{
var
parent
=
_buffer
[
0
].
getParent
();
if
(
parent
&&
_buffer
.
indexOf
(
parent
)
===
-
1
)
_buffer
.
push
(
parent
);
_buffer
.
shift
();
}
while
(
_buffer
.
length
>
1
);
km
.
removeNode
(
selectedNodes
);
km
.
select
(
_buffer
[
0
]);
},
queryState
:
function
(
km
)
{
var
selectedNodes
=
km
.
getSelectedNodes
();
if
(
selectedNodes
.
length
===
0
||
(
selectedNodes
.
length
===
1
&&
selectedNodes
[
0
]
===
km
.
getRoot
()))
{
return
-
1
;
}
else
{
return
0
;
}
}
};
})());
var
EditNodeCommand
=
kity
.
createClass
(
"EditNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
null
;
}
km
.
select
(
selectedNode
,
true
);
km
.
textEditNode
(
selectedNode
);
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
-
1
;
}
else
{
return
0
;
}
},
isNeedUndo
:
function
()
{
return
false
;
}
};
})());
var
selectedNodes
=
km
.
getSelectedNodes
();
var
_root
=
km
.
getRoot
();
var
_buffer
=
[];
for
(
var
i
=
0
;
i
<
selectedNodes
.
length
;
i
++
)
{
_buffer
.
push
(
selectedNodes
[
i
]);
}
do
{
var
parent
=
_buffer
[
0
].
getParent
();
if
(
parent
&&
_buffer
.
indexOf
(
parent
)
===
-
1
)
_buffer
.
push
(
parent
);
_buffer
.
shift
();
}
while
(
_buffer
.
length
>
1
);
km
.
removeNode
(
selectedNodes
);
km
.
select
(
_buffer
[
0
]);
},
queryState
:
function
(
km
)
{
var
selectedNodes
=
km
.
getSelectedNodes
();
if
(
selectedNodes
.
length
===
0
||
(
selectedNodes
.
length
===
1
&&
selectedNodes
[
0
]
===
km
.
getRoot
()))
{
return
-
1
;
}
else
{
return
0
;
}
}
};
})());
var
EditNodeCommand
=
kity
.
createClass
(
"EditNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
null
;
}
km
.
select
(
selectedNode
,
true
);
km
.
textEditNode
(
selectedNode
);
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
if
(
!
selectedNode
)
{
return
-
1
;
}
else
{
return
0
;
}
},
isNeedUndo
:
function
()
{
return
false
;
}
};
})());
return
{
"commands"
:
{
"appendchildnode"
:
AppendChildNodeCommand
,
"appendsiblingnode"
:
AppendSiblingNodeCommand
,
"removenode"
:
RemoveNodeCommand
,
"editnode"
:
EditNodeCommand
,
"switchlayout"
:
SwitchLayoutCommand
},
"events"
:
{
"ready"
:
function
()
{
this
.
setDefaultOptions
(
'layoutstyle'
,
this
.
getLayoutStyleItems
());
switchLayout
(
this
,
this
.
getOptions
(
'defaultlayoutstyle'
));
},
"click"
:
function
(
e
)
{
var
ico
=
e
.
kityEvent
.
targetShape
&&
e
.
kityEvent
.
targetShape
.
container
;
if
(
ico
&&
ico
.
class
===
"shicon"
)
{
this
.
expandNode
(
ico
);
this
.
fire
(
'contentchange'
);
}
},
"resize"
:
function
(
e
)
{
clearTimeout
(
this
.
_lastStyleResetTimeout
);
this
.
_lastStyleResetTimeout
=
setTimeout
(
function
()
{
this
.
updateLayout
(
this
.
getRoot
());
}.
bind
(
this
),
100
);
},
"import"
:
function
(
e
)
{
this
.
initStyle
();
}
},
'contextmenu'
:
[{
label
:
this
.
getLang
(
'node.appendsiblingnode'
),
exec
:
function
()
{
this
.
execCommand
(
'appendsiblingnode'
,
new
MinderNode
(
this
.
getLang
(
'topic'
)))
},
cmdName
:
'appendsiblingnode'
},
{
label
:
this
.
getLang
(
'node.appendchildnode'
),
exec
:
function
()
{
this
.
execCommand
(
'appendchildnode'
,
new
MinderNode
(
this
.
getLang
(
'topic'
)))
},
cmdName
:
'appendchildnode'
},
{
label
:
this
.
getLang
(
'node.editnode'
),
exec
:
function
()
{
this
.
execCommand
(
'editnode'
,
null
);
},
cmdName
:
'editnode'
},
{
label
:
this
.
getLang
(
'node.removenode'
),
cmdName
:
'removenode'
},
{
divider
:
1
},
{
label
:
this
.
getLang
(
'layout.default'
),
exec
:
function
()
{
this
.
execCommand
(
'switchlayout'
,
'default'
);
this
.
initStyle
();
},
cmdName
:
'switchlayout'
},
{
label
:
this
.
getLang
(
'layout.bottom'
),
exec
:
function
()
{
this
.
execCommand
(
'switchlayout'
,
'bottom'
);
this
.
initStyle
();
},
cmdName
:
'switchlayout'
}
return
{
"commands"
:
{
"appendchildnode"
:
AppendChildNodeCommand
,
"appendsiblingnode"
:
AppendSiblingNodeCommand
,
"removenode"
:
RemoveNodeCommand
,
"editnode"
:
EditNodeCommand
,
"switchlayout"
:
SwitchLayoutCommand
},
"events"
:
{
"ready"
:
function
()
{
this
.
setDefaultOptions
(
'layoutstyle'
,
this
.
getLayoutStyleItems
());
switchLayout
(
this
,
this
.
getOptions
(
'defaultlayoutstyle'
));
},
"click"
:
function
(
e
)
{
var
ico
=
e
.
kityEvent
.
targetShape
&&
e
.
kityEvent
.
targetShape
.
container
;
if
(
ico
&&
ico
.
class
===
"shicon"
)
{
this
.
expandNode
(
ico
);
this
.
fire
(
'contentchange'
);
}
},
"resize"
:
function
(
e
)
{
clearTimeout
(
this
.
_lastStyleResetTimeout
);
this
.
_lastStyleResetTimeout
=
setTimeout
(
function
()
{
this
.
updateLayout
(
this
.
getRoot
());
}.
bind
(
this
),
100
);
},
"import"
:
function
(
e
)
{
this
.
initStyle
();
}
},
'contextmenu'
:
[{
label
:
this
.
getLang
(
'node.appendsiblingnode'
),
exec
:
function
()
{
this
.
execCommand
(
'appendsiblingnode'
,
new
MinderNode
(
this
.
getLang
(
'topic'
)))
},
cmdName
:
'appendsiblingnode'
},
{
label
:
this
.
getLang
(
'node.appendchildnode'
),
exec
:
function
()
{
this
.
execCommand
(
'appendchildnode'
,
new
MinderNode
(
this
.
getLang
(
'topic'
)))
},
cmdName
:
'appendchildnode'
},
{
label
:
this
.
getLang
(
'node.editnode'
),
exec
:
function
()
{
this
.
execCommand
(
'editnode'
,
null
);
},
cmdName
:
'editnode'
},
{
label
:
this
.
getLang
(
'node.removenode'
),
cmdName
:
'removenode'
},
{
divider
:
1
},
{
label
:
this
.
getLang
(
'layout.default'
),
exec
:
function
()
{
this
.
execCommand
(
'switchlayout'
,
'default'
);
this
.
initStyle
();
},
cmdName
:
'switchlayout'
},
{
label
:
this
.
getLang
(
'layout.bottom'
),
exec
:
function
()
{
this
.
execCommand
(
'switchlayout'
,
'bottom'
);
this
.
initStyle
();
},
cmdName
:
'switchlayout'
}
],
"defaultOptions"
:
{
"defaultlayoutstyle"
:
"default"
,
"node"
:
{
'appendsiblingnode'
:
'appendsiblingnode'
,
'appendchildnode'
:
'appendchildnode'
,
'editnode'
:
'editnode'
,
'removenode'
:
'removenode'
},
'defaultExpand'
:
{
'defaultLayer'
:
0
,
'defaultSubShow'
:
0
}
}
};
],
"defaultOptions"
:
{
"defaultlayoutstyle"
:
"default"
,
"node"
:
{
'appendsiblingnode'
:
'appendsiblingnode'
,
'appendchildnode'
:
'appendchildnode'
,
'editnode'
:
'editnode'
,
'removenode'
:
'removenode'
},
'defaultExpand'
:
{
'defaultLayer'
:
0
,
'defaultSubShow'
:
0
}
}
};
});
\ No newline at end of file
src/theme/bottom.js
View file @
2c77fc41
...
...
@@ -5,7 +5,7 @@ KityMinder.registerTheme('bottom', {
'root-font-size'
:
24
,
'root-padding'
:
[
15
,
25
],
'root-margin'
:
0
,
'root-radius'
:
3
0
,
'root-radius'
:
0
,
'root-space'
:
10
,
'main-color'
:
'#333'
,
...
...
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