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
4b354b10
Commit
4b354b10
authored
Dec 19, 2013
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make private sign
parent
d9a86469
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
30 deletions
+79
-30
.jshintrc
.jshintrc
+1
-1
dev.html
demo/dev.html
+4
-2
kityminder.js
src/core/kityminder.js
+55
-19
minderevent.js
src/core/minderevent.js
+19
-8
No files found.
.jshintrc
View file @
4b354b10
...
...
@@ -2,7 +2,7 @@
"undef" : true,
"unused" : false,
"strict" : false,
"curly" :
tru
e,
"curly" :
fals
e,
"newcap" : true,
"trailing" : true,
"white": false,
...
...
demo/dev.html
View file @
4b354b10
...
...
@@ -24,7 +24,7 @@
}
minder
.
on
(
allEvent
(),
function
(
e
)
{
console
.
log
(
e
.
typ
e
);
//console.log(e.type,
e);
});
minder
.
importData
({
data
:
{
...
...
@@ -53,7 +53,9 @@
}]
}]
});
console
.
log
(
minder
);
minder
.
update
();
m
=
minder
;
//console.log(minder.exportData());
</script>
</html>
\ No newline at end of file
src/core/kityminder.js
View file @
4b354b10
var
KityMinderId
=
0
;
var
KityMinder
=
km
.
KityMinder
=
kity
.
createClass
(
"KityMinder"
,
{
constructor
:
function
(
id
,
option
)
{
// 初始化
...
...
@@ -7,14 +9,14 @@ var KityMinder = km.KityMinder = kity.createClass("KityMinder", {
},
_initMinder
:
function
(
id
,
option
)
{
this
.
id
=
id
;
this
.
id
=
id
||
KityMinderId
++
;
this
.
rc
=
new
kity
.
Group
();
this
.
paper
=
new
kity
.
Paper
(
option
.
renderTo
||
document
.
body
);
this
.
paper
.
addShape
(
this
.
rc
);
this
.
_
rc
=
new
kity
.
Group
();
this
.
_
paper
=
new
kity
.
Paper
(
option
.
renderTo
||
document
.
body
);
this
.
_paper
.
addShape
(
this
.
_
rc
);
this
.
root
=
new
MinderNode
(
this
);
this
.
rc
.
addShape
(
this
.
root
.
getRenderContainer
());
this
.
_
root
=
new
MinderNode
(
this
);
this
.
_rc
.
addShape
(
this
.
_
root
.
getRenderContainer
());
}
});
...
...
@@ -118,7 +120,7 @@ kity.extendClass(KityMinder, (function(){
kity
.
extendClass
(
KityMinder
,
{
getRoot
:
function
()
{
return
this
.
root
;
return
this
.
_
root
;
},
traverse
:
function
(
node
,
fn
)
{
...
...
@@ -131,18 +133,18 @@ kity.extendClass(KityMinder, {
handelNodeInsert
:
function
(
node
)
{
this
.
traverse
(
node
,
function
(
current
)
{
this
.
rc
.
addShape
(
current
.
getRenderContainer
());
this
.
_
rc
.
addShape
(
current
.
getRenderContainer
());
});
},
handelNodeRemove
:
function
(
node
)
{
this
.
traverse
(
node
,
function
(
current
)
{
this
.
rc
.
removeShape
(
current
.
getRenderContainer
());
this
.
_
rc
.
removeShape
(
current
.
getRenderContainer
());
});
},
update
:
function
(
node
)
{
node
=
node
||
this
.
root
;
node
=
node
||
this
.
_
root
;
this
.
traverse
(
node
,
function
(
current
)
{
var
rc
=
current
.
getRenderContainer
();
var
x
=
current
.
getData
(
'x'
)
||
0
,
...
...
@@ -177,7 +179,7 @@ kity.extendClass(KityMinder, {
// TODO: mousemove lazy bind
_bindPaperEvents
:
function
()
{
var
minder
=
this
;
this
.
paper
.
on
(
'click mousedown mouseup mousemove'
,
this
.
_firePharse
.
bind
(
this
));
this
.
_
paper
.
on
(
'click mousedown mouseup mousemove'
,
this
.
_firePharse
.
bind
(
this
));
},
_bindKeyboardEvents
:
function
()
{
var
minder
=
this
;
...
...
@@ -300,18 +302,22 @@ kity.extendClass(KityMinder, {
node
.
appendChild
(
childNode
);
}
}
var
params
=
{
importData
:
treeData
};
var
canceled
=
this
.
_fire
(
new
MinderEvent
(
'beforeimport'
,
params
,
true
));
if
(
canceled
)
return
this
;
this
.
_fire
(
new
MinderEvent
(
'preimport'
,
params
,
false
));
while
(
this
.
root
.
getChildren
().
length
)
{
this
.
root
.
removeChild
(
0
);
while
(
this
.
_
root
.
getChildren
().
length
)
{
this
.
_
root
.
removeChild
(
0
);
}
importToNode
(
treeData
,
this
.
root
);
importToNode
(
treeData
,
this
.
_
root
);
this
.
_fire
(
new
MinderEvent
(
'import'
,
params
,
false
));
this
.
_firePharse
(
{
type
:
'contentchange'
}
);
return
this
;
}
});
...
...
@@ -319,22 +325,52 @@ kity.extendClass(KityMinder, {
// 选区管理
kity
.
extendClass
(
KityMinder
,
{
getSelectedNodes
:
function
()
{
return
this
.
_selectedNodes
||
(
this
.
_selectedNodes
=
[]);
},
select
:
function
(
nodes
)
{
var
selection
=
this
.
getSelectedNodes
();
if
(
false
===
nodes
instanceof
Array
)
nodes
=
[
nodes
];
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
if
(
selection
.
indexOf
(
nodes
[
i
])
!==
-
1
)
{
selection
.
push
(
nodes
[
i
]);
}
}
return
this
;
},
selectSingle
:
function
(
node
)
{
return
this
.
clearSelect
().
select
(
node
);
},
toggleSelect
:
function
(
nodes
)
{
var
selection
=
this
.
getSelectedNodes
();
var
needAdd
=
[],
needRemove
=
[];
if
(
false
===
nodes
instanceof
Array
)
nodes
=
[
nodes
];
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
if
(
selection
.
indexOf
(
nodes
[
i
])
===
-
1
)
{
needAdd
.
push
(
nodes
[
i
]);
}
else
{
needRemove
.
push
(
nodes
[
i
]);
}
}
this
.
clearSelect
(
needRemove
);
this
.
select
(
needAdd
);
},
clearSelect
:
function
(
nodes
)
{
if
(
!
nodes
)
{
this
.
_selectedNodes
=
[];
return
this
;
}
var
originSelection
=
this
.
getSelectedNodes
();
var
newSelection
=
[];
for
(
var
i
=
0
;
i
<
originSelection
.
length
;
i
++
)
{
if
(
nodes
.
indexOf
(
originSelection
[
i
])
!==
-
1
)
{
newSelection
.
push
(
originSelection
[
i
]);
}
}
this
.
_selectedNodes
=
newSelection
;
return
this
;
}
});
\ No newline at end of file
src/core/minderevent.js
View file @
4b354b10
var
MinderEvent
=
kity
.
createClass
(
'MindEvent'
,
{
constructor
:
function
(
type
,
params
,
cancelable
)
{
params
=
params
||
{};
if
(
params
.
getType
&&
params
.
getType
()
==
'ShapeEvent'
)
{
this
.
kityEvent
=
params
;
this
.
getPosition
=
params
.
getPosition
.
bind
(
params
);
}
else
{
kity
.
Utils
.
extend
(
this
,
params
);
}
this
.
type
=
type
;
this
.
cancelable
=
cancelable
||
false
;
this
.
_
cancelable
=
cancelable
||
false
;
if
(
params
.
targetShape
)
{
this
.
targetNode
=
params
.
targetShape
.
minderNode
||
null
;
this
.
getTargetNode
=
function
()
{
var
findShape
=
params
.
targetShape
;
while
(
!
findShape
.
minderNode
&&
findShape
.
container
)
{
findShape
=
findShape
.
container
;
}
return
findShape
.
minderNode
||
null
;
};
}
},
cancel
:
function
()
{
this
.
canceled
=
true
;
this
.
_
canceled
=
true
;
},
cancelImmediately
:
function
()
{
this
.
immediatelyCanceld
=
true
;
this
.
canceled
=
true
;
this
.
_
immediatelyCanceld
=
true
;
this
.
_
canceled
=
true
;
},
shouldCancel
:
function
()
{
return
this
.
cancelable
&&
this
.
canceled
;
return
this
.
_cancelable
&&
this
.
_
canceled
;
},
shouldCancelImmediately
:
function
()
{
return
this
.
cancelable
&&
this
.
immediatelyCanceld
;
return
this
.
_cancelable
&&
this
.
_
immediatelyCanceld
;
}
});
\ 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