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
94f12382
Commit
94f12382
authored
Jan 17, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构了layout相关的内容
parent
0f1ab1e3
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
279 additions
and
350 deletions
+279
-350
dev.html
demo/dev.html
+6
-0
dev.php
dist/dev.php
+1
-7
minder.command.js
src/core/minder.command.js
+1
-1
minder.js
src/core/minder.js
+8
-0
minder.select.js
src/core/minder.select.js
+30
-29
layout.default.js
src/module/layout.default.js
+218
-301
layout.js
src/module/layout.js
+15
-12
No files found.
demo/dev.html
View file @
94f12382
...
...
@@ -16,5 +16,11 @@
<script>
minder
=
KM
.
createMinder
(
kityminder
);
minder
.
execCommand
(
"switchlayout"
,
"default"
);
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
());
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
());
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
());
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
());
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
());
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
());
</script>
</html>
\ No newline at end of file
dist/dev.php
View file @
94f12382
...
...
@@ -13,18 +13,12 @@ $dependency = Array(
'src/core/minder.module.js'
,
'src/core/minder.command.js'
,
'src/core/minder.node.js'
,
'src/core/minder.select.js'
,
'src/module/history.js'
,
'src/module/icon.js'
,
'src/module/layout.js'
,
'src/module/layout.default.js'
,
'src/module/layout.green.js'
,
'src/module/mouse.js'
,
'src/module/keyboard.js'
,
'src/module/editor.js'
,
'src/module/editor.cursor.js'
,
'src/module/editor.range.js'
,
'src/module/editor.receiver.js'
'src/core/minder.select.js'
,
);
$content
=
""
;
...
...
src/core/minder.command.js
View file @
94f12382
...
...
@@ -24,7 +24,7 @@ kity.extendClass( Minder, {
execCommand
:
function
(
name
)
{
name
=
name
.
toLowerCase
();
var
cmdArgs
=
utils
.
argsToArray
(
arguments
,
1
),
var
cmdArgs
=
Utils
.
argsToArray
(
arguments
,
1
),
cmd
,
stoped
,
result
,
eventParams
;
var
me
=
this
;
cmd
=
this
.
_getCommand
(
name
);
...
...
src/core/minder.js
View file @
94f12382
...
...
@@ -15,6 +15,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
constructor
:
function
(
options
)
{
this
.
_options
=
Utils
.
extend
(
window
.
KITYMINDER_CONFIG
||
{},
MinderDefaultOptions
,
options
);
this
.
_layoutStyles
=
{};
this
.
_currentStyle
=
""
;
this
.
_initEvents
();
this
.
_initMinder
();
this
.
_initSelection
();
...
...
@@ -54,6 +55,13 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getLayoutStyle
:
function
(
name
)
{
return
this
.
_layoutStyles
[
name
];
},
getCurrentStyle
:
function
()
{
return
this
.
_currentStyle
;
},
setCurrentStyle
:
function
(
name
)
{
this
.
_currentStyle
=
name
;
return
name
;
},
getRenderTarget
:
function
()
{
return
this
.
_renderTarget
;
}
...
...
src/core/minder.select.js
View file @
94f12382
// 选区管理
kity
.
extendClass
(
Minder
,
function
()
{
function
highlightNode
(
km
,
node
)
{
kity
.
extendClass
(
Minder
,
function
()
{
function
highlightNode
(
km
,
node
)
{
node
.
setData
(
"highlight"
,
true
);
km
.
renderNode
(
node
);
}
function
unhighlightNode
(
km
,
node
){
function
unhighlightNode
(
km
,
node
)
{
node
.
setData
(
"highlight"
,
false
);
km
.
renderNode
(
node
);
}
...
...
@@ -14,52 +15,52 @@ kity.extendClass( Minder, function(){
},
getSelectedNodes
:
function
()
{
//如果没有选中节点,默认是root节点
if
(
this
.
_selectedNodes
.
length
==
0
)
{
this
.
_selectedNodes
.
push
(
this
.
getRoot
())
if
(
this
.
_selectedNodes
.
length
===
0
)
{
this
.
_selectedNodes
.
push
(
this
.
getRoot
()
);
}
//不能克隆返回,会对当前选区操作,从而影响querycommand
return
this
.
_selectedNodes
;
},
getSelectedNode
:
function
()
{
return
this
.
getSelectedNodes
()[
0
]
getSelectedNode
:
function
()
{
return
this
.
getSelectedNodes
()[
0
];
},
removeAllSelectedNodes
:
function
()
{
utils
.
each
(
this
.
getSelectedNodes
(),
function
(
i
,
n
)
{
unhighlightNode
(
this
,
n
);
});
this
.
_selectedNodes
=
[]
removeAllSelectedNodes
:
function
()
{
Utils
.
each
(
this
.
getSelectedNodes
(),
function
(
i
,
n
)
{
unhighlightNode
(
this
,
n
);
}
);
this
.
_selectedNodes
=
[]
;
},
select
:
function
(
nodes
)
{
this
.
removeAllSelectedNodes
();
var
me
=
this
;
utils
.
each
(
utils
.
isArray
(
nodes
)
?
nodes
:
[
nodes
],
function
(
i
,
n
)
{
me
.
_selectedNodes
.
push
(
n
);
highlightNode
(
this
,
n
)
});
utils
.
each
(
utils
.
isArray
(
nodes
)
?
nodes
:
[
nodes
],
function
(
i
,
n
)
{
me
.
_selectedNodes
.
push
(
n
);
highlightNode
(
this
,
n
);
}
);
return
this
;
},
isNodeSelected
:
function
(
node
)
{
return
node
.
getData
(
'highlight'
)
===
true
return
node
.
getData
(
'highlight'
)
===
true
},
//当前选区中的节点在给定的节点范围内的保留选中状态,没在给定范围的取消选中,给定范围中的但没在当前选中范围的也做选中效果
toggleSelect
:
function
(
nodes
)
{
nodes
=
utils
.
isArray
(
nodes
)
?
nodes
:
[
nodes
];
var
selectedNodes
=
this
.
getSelectedNodes
().
slice
(
0
);
nodes
=
utils
.
isArray
(
nodes
)
?
nodes
:
[
nodes
];
var
selectedNodes
=
this
.
getSelectedNodes
().
slice
(
0
);
this
.
removeAllSelectedNodes
();
for
(
var
i
=
0
,
n
;
n
=
selectedNodes
[
i
];)
{
var
index
=
utils
.
indexOf
(
nodes
,
n
);
if
(
index
!=
-
1
)
{
nodes
.
push
(
n
);
for
(
var
i
=
0
,
n
;
n
=
selectedNodes
[
i
];
)
{
var
index
=
utils
.
indexOf
(
nodes
,
n
);
if
(
index
!=
-
1
)
{
nodes
.
push
(
n
);
i
++
;
}
else
{
unhighlightNode
(
this
,
n
);
selectedNodes
.
splice
(
i
,
1
)
}
else
{
unhighlightNode
(
this
,
n
);
selectedNodes
.
splice
(
i
,
1
)
}
}
var
me
=
this
;
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
highlightNode
(
me
,
n
)
});
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
highlightNode
(
me
,
n
)
}
);
this
.
_selectedNodes
=
nodes
;
}
}
...
...
src/module/layout.default.js
View file @
94f12382
This diff is collapsed.
Click to expand it.
src/module/layout.js
View file @
94f12382
...
...
@@ -7,8 +7,8 @@ KityMinder.registerModule( "LayoutModule", function () {
if
(
!
_style
)
return
false
;
km
.
renderNode
=
_style
.
renderNode
;
km
.
initStyle
=
_style
.
initStyle
;
km
.
createChildNode
=
_style
.
create
ChildNode
;
km
.
createSiblingNode
=
_style
.
create
SiblingNode
;
km
.
appendChildNode
=
_style
.
append
ChildNode
;
km
.
appendSiblingNode
=
_style
.
append
SiblingNode
;
km
.
removeNode
=
_style
.
removeNode
;
//清空节点上附加的数据
var
_root
=
km
.
getRoot
();
...
...
@@ -21,35 +21,38 @@ KityMinder.registerModule( "LayoutModule", function () {
}
};
}
)()
);
var
CreateChildNodeCommand
=
kity
.
createClass
(
"Create
ChildNodeCommand"
,
(
function
()
{
var
AppendChildNodeCommand
=
kity
.
createClass
(
"Append
ChildNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
parent
)
{
return
km
.
createChildNode
(
parent
);
execute
:
function
(
km
,
node
)
{
var
parent
=
km
.
getSelectedNode
();
return
km
.
appendChildNode
(
parent
,
node
);
}
};
}
)()
);
var
CreateSiblingNodeCommand
=
kity
.
createClass
(
"Create
SiblingNodeCommand"
,
(
function
()
{
var
AppendSiblingNodeCommand
=
kity
.
createClass
(
"Append
SiblingNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
sibling
)
{
return
km
.
createSiblingNode
(
sibling
);
execute
:
function
(
km
,
node
)
{
var
sibling
=
km
.
getSelectedNode
();
return
km
.
appendSiblingNode
(
sibling
.
getParent
(),
node
);
}
};
}
)()
);
var
RemoveNodeCommand
=
kity
.
createClass
(
"RemoveNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
km
.
removeNode
(
node
);
execute
:
function
(
km
,
node
s
)
{
km
.
removeNode
(
node
s
);
}
};
}
)()
);
return
{
"commands"
:
{
"
createchildnode"
:
Create
ChildNodeCommand
,
"
createsiblingnode"
:
Create
SiblingNodeCommand
,
"
appendchildnode"
:
Append
ChildNodeCommand
,
"
appendsiblingnode"
:
Append
SiblingNodeCommand
,
"removenode"
:
RemoveNodeCommand
,
"switchlayout"
:
SwitchLayoutCommand
}
...
...
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