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
14fba533
Commit
14fba533
authored
Jan 20, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added delete and a new style
parent
7c798280
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
289 additions
and
326 deletions
+289
-326
dev.html
demo/dev.html
+2
-2
node.js
src/core/node.js
+41
-41
keyboard.js
src/module/keyboard.js
+31
-30
layout.default.js
src/module/layout.default.js
+134
-108
layout.green.js
src/module/layout.green.js
+79
-144
layout.js
src/module/layout.js
+2
-1
No files found.
demo/dev.html
View file @
14fba533
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
</body>
</body>
<script>
<script>
minder
=
KM
.
createMinder
(
kityminder
);
minder
=
KM
.
createMinder
(
kityminder
);
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
(
'dsf'
)
);
//minder.execCommand("switchlayout","green"
);
minder
.
execCommand
(
"append
siblingnode"
,
new
MinderNode
(
'sdf'
));
minder
.
execCommand
(
"append
childnode"
,
new
MinderNode
(
"test"
));
</script>
</script>
</html>
</html>
\ No newline at end of file
src/core/node.js
View file @
14fba533
...
@@ -3,21 +3,21 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -3,21 +3,21 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this
.
parent
=
null
;
this
.
parent
=
null
;
this
.
children
=
[];
this
.
children
=
[];
this
.
data
=
{};
this
.
data
=
{};
if
(
utils
.
isString
(
options
))
{
if
(
utils
.
isString
(
options
)
)
{
this
.
setData
(
'text'
,
options
)
this
.
setData
(
'text'
,
options
)
}
else
{
}
else
{
this
.
setData
(
options
);
this
.
setData
(
options
);
}
}
this
.
rc
=
new
kity
.
Group
();
this
.
rc
=
new
kity
.
Group
();
this
.
rc
.
minderNode
=
this
;
this
.
rc
.
minderNode
=
this
;
},
},
setText
:
function
(
text
)
{
setText
:
function
(
text
)
{
this
.
setData
(
'text'
,
text
)
this
.
setData
(
'text'
,
text
)
},
},
getText
:
function
()
{
getText
:
function
()
{
return
this
.
getData
(
'text'
)
return
this
.
getData
(
'text'
)
},
},
isRoot
:
function
()
{
isRoot
:
function
()
{
return
this
.
getParent
()
==
null
?
true
:
false
;
return
this
.
getParent
()
==
null
?
true
:
false
;
},
},
getParent
:
function
()
{
getParent
:
function
()
{
...
@@ -36,8 +36,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -36,8 +36,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
getRoot
:
function
()
{
getRoot
:
function
()
{
var
root
=
this
;
var
root
=
this
;
while
(
root
.
parent
)
{
while
(
root
.
parent
)
{
root
=
root
.
parent
;
root
=
root
.
parent
;
}
}
return
root
;
return
root
;
},
},
...
@@ -84,13 +84,13 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -84,13 +84,13 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
// this.handelInsert( node );
// this.handelInsert( node );
},
},
//
//
// handelInsert: function ( node ) {
// handelInsert: function ( node ) {
// var root = this.getRoot();
// var root = this.getRoot();
// if ( root.tnh ) {
// if ( root.tnh ) {
// root.tnh.handelNodeInsert.call( root.tnh, node );
// root.tnh.handelNodeInsert.call( root.tnh, node );
// }
// }
// },
// },
appendChild
:
function
(
node
)
{
appendChild
:
function
(
node
)
{
return
this
.
insertChild
(
node
);
return
this
.
insertChild
(
node
);
...
@@ -109,25 +109,25 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -109,25 +109,25 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
if
(
index
>=
0
)
{
if
(
index
>=
0
)
{
removed
=
this
.
children
.
splice
(
index
,
1
)[
0
];
removed
=
this
.
children
.
splice
(
index
,
1
)[
0
];
removed
.
parent
=
null
;
removed
.
parent
=
null
;
// this.handelRemove( removed );
// this.handelRemove( removed );
}
}
},
},
// handelRemove: function ( node ) {
// handelRemove: function ( node ) {
// var root = this.getRoot();
// var root = this.getRoot();
// if ( root.tnh ) {
// if ( root.tnh ) {
// root.tnh.handelNodeRemove.call( root.tnh, node );
// root.tnh.handelNodeRemove.call( root.tnh, node );
// }
// }
// },
// },
getChild
:
function
(
index
)
{
getChild
:
function
(
index
)
{
return
this
.
children
[
index
];
return
this
.
children
[
index
];
},
},
getFirstChild
:
function
()
{
getFirstChild
:
function
()
{
return
this
.
children
[
0
]
return
this
.
children
[
0
]
},
},
getLastChild
:
function
()
{
getLastChild
:
function
()
{
return
this
.
children
[
this
.
children
.
length
-
1
]
return
this
.
children
[
this
.
children
.
length
-
1
]
},
},
getData
:
function
(
name
)
{
getData
:
function
(
name
)
{
if
(
name
===
undefined
)
{
if
(
name
===
undefined
)
{
...
@@ -148,36 +148,36 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -148,36 +148,36 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
getRenderContainer
:
function
()
{
getRenderContainer
:
function
()
{
return
this
.
rc
;
return
this
.
rc
;
},
},
getCommonAncestor
:
function
(
node
)
{
getCommonAncestor
:
function
(
node
)
{
if
(
this
===
node
)
{
if
(
this
===
node
)
{
return
this
.
parent
return
this
.
parent
}
}
if
(
this
.
contains
(
node
))
{
if
(
this
.
contains
(
node
)
)
{
return
this
return
this
}
}
if
(
node
.
contains
(
this
))
{
if
(
node
.
contains
(
this
)
)
{
return
node
return
node
}
}
var
parent
=
node
.
parent
;
var
parent
=
node
.
parent
;
while
(
!
parent
.
contains
(
node
))
{
while
(
!
parent
.
contains
(
node
)
)
{
parent
=
parent
.
parentNode
;
parent
=
parent
.
parentNode
;
}
}
return
parent
;
return
parent
;
},
},
contains
:
function
(
node
)
{
contains
:
function
(
node
)
{
if
(
this
===
node
)
{
if
(
this
===
node
)
{
return
true
;
return
true
;
}
}
if
(
this
===
node
.
parent
)
{
if
(
this
===
node
.
parent
)
{
return
true
;
return
true
;
}
}
var
isContain
=
false
;
var
isContain
=
false
;
utils
.
each
(
this
.
getChildren
(),
function
(
i
,
n
)
{
utils
.
each
(
this
.
getChildren
(),
function
(
i
,
n
)
{
isContain
=
n
.
contains
(
node
);
isContain
=
n
.
contains
(
node
);
if
(
isContain
===
true
)
{
if
(
isContain
===
true
)
{
return
false
return
false
}
}
});
}
);
return
isContain
;
return
isContain
;
}
}
...
...
src/module/keyboard.js
View file @
14fba533
...
@@ -47,10 +47,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
...
@@ -47,10 +47,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
}
function
KBNavigate
(
km
,
direction
)
{
function
KBNavigate
(
km
,
direction
)
{
var
nextNode
=
km
.
getSelectedNode
().
_nearestNodes
[
direction
];
var
nextNode
=
km
.
getSelectedNode
().
_nearestNodes
[
direction
];
if
(
nextNode
)
{
if
(
nextNode
)
{
km
.
select
(
nextNode
);
km
.
select
(
nextNode
);
}
}
}
}
return
{
return
{
...
@@ -63,34 +63,35 @@ KityMinder.registerModule( "KeyboardModule", function () {
...
@@ -63,34 +63,35 @@ KityMinder.registerModule( "KeyboardModule", function () {
switch
(
e
.
originEvent
.
keyCode
)
{
switch
(
e
.
originEvent
.
keyCode
)
{
case
13
:
case
13
:
// Enter
// Enter
this
.
execCommand
(
'appendSiblingNode'
,
new
MinderNode
(
'Topic'
));
this
.
execCommand
(
'appendSiblingNode'
,
new
MinderNode
(
'Topic'
)
);
e
.
preventDefault
();
e
.
preventDefault
();
break
;
break
;
case
9
:
case
9
:
// Tab
// Tab
this
.
execCommand
(
'appendChildNode'
,
new
MinderNode
(
'Topic'
));
this
.
execCommand
(
'appendChildNode'
,
new
MinderNode
(
'Topic'
)
);
e
.
preventDefault
();
e
.
preventDefault
();
break
;
break
;
case
8
:
case
8
:
case
46
:
case
46
:
this
.
execCommand
(
'removenode'
);
this
.
execCommand
(
'removenode'
);
break
;
e
.
preventDefault
();
case
37
:
break
;
case
38
:
case
37
:
case
39
:
case
38
:
case
40
:
case
39
:
if
(
this
.
isSingleSelect
()
)
{
case
40
:
KBNavigate
(
this
,{
if
(
this
.
isSingleSelect
()
)
{
37
:
'left'
,
KBNavigate
(
this
,
{
38
:
'top'
,
37
:
'left'
,
39
:
'right'
,
38
:
'top'
,
40
:
'down'
39
:
'right'
,
}[
e
.
originEvent
.
keyCode
]);
40
:
'down'
}
}[
e
.
originEvent
.
keyCode
]
);
e
.
preventDefault
();
}
break
;
e
.
preventDefault
();
break
;
}
}
...
...
src/module/layout.default.js
View file @
14fba533
This diff is collapsed.
Click to expand it.
src/module/layout.green.js
View file @
14fba533
This diff is collapsed.
Click to expand it.
src/module/layout.js
View file @
14fba533
...
@@ -11,7 +11,8 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -11,7 +11,8 @@ KityMinder.registerModule( "LayoutModule", function () {
var
_root
=
km
.
getRoot
();
var
_root
=
km
.
getRoot
();
_root
.
preTraverse
(
function
(
node
)
{
_root
.
preTraverse
(
function
(
node
)
{
node
.
clearData
();
node
.
setData
(
"style"
,
{}
);
node
.
setData
(
"shape"
,
null
);
node
.
getRenderContainer
().
clear
();
node
.
getRenderContainer
().
clear
();
}
);
}
);
km
.
initStyle
();
km
.
initStyle
();
...
...
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