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