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
ad872831
Commit
ad872831
authored
Dec 20, 2013
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format Files
parent
65b73774
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
50 deletions
+51
-50
minderevent.js
src/core/minderevent.js
+13
-13
mindernode.js
src/core/mindernode.js
+38
-37
No files found.
src/core/minderevent.js
View file @
ad872831
var
MinderEvent
=
kity
.
createClass
(
'MindEvent'
,
{
var
MinderEvent
=
kity
.
createClass
(
'MindEvent'
,
{
constructor
:
function
(
type
,
params
,
cancelable
)
{
constructor
:
function
(
type
,
params
,
cancelable
)
{
params
=
params
||
{};
params
=
params
||
{};
if
(
params
.
getType
&&
params
.
getType
()
==
'ShapeEvent'
)
{
if
(
params
.
getType
&&
params
.
getType
()
==
'ShapeEvent'
)
{
this
.
kityEvent
=
params
;
this
.
kityEvent
=
params
;
this
.
getPosition
=
params
.
getPosition
.
bind
(
params
);
this
.
getPosition
=
params
.
getPosition
.
bind
(
params
);
}
else
{
}
else
{
kity
.
Utils
.
extend
(
this
,
params
);
kity
.
Utils
.
extend
(
this
,
params
);
}
}
this
.
type
=
type
;
this
.
type
=
type
;
this
.
_cancelable
=
cancelable
||
false
;
this
.
_cancelable
=
cancelable
||
false
;
if
(
params
.
targetShape
)
{
if
(
params
.
targetShape
)
{
this
.
getTargetNode
=
function
()
{
this
.
getTargetNode
=
function
()
{
var
findShape
=
params
.
targetShape
;
var
findShape
=
params
.
targetShape
;
while
(
!
findShape
.
minderNode
&&
findShape
.
container
)
{
while
(
!
findShape
.
minderNode
&&
findShape
.
container
)
{
findShape
=
findShape
.
container
;
findShape
=
findShape
.
container
;
}
}
return
findShape
.
minderNode
||
null
;
return
findShape
.
minderNode
||
null
;
...
@@ -20,20 +20,20 @@ var MinderEvent = kity.createClass('MindEvent', {
...
@@ -20,20 +20,20 @@ var MinderEvent = kity.createClass('MindEvent', {
}
}
},
},
cancel
:
function
()
{
cancel
:
function
()
{
this
.
_canceled
=
true
;
this
.
_canceled
=
true
;
},
},
cancelImmediately
:
function
()
{
cancelImmediately
:
function
()
{
this
.
_immediatelyCanceld
=
true
;
this
.
_immediatelyCanceld
=
true
;
this
.
_canceled
=
true
;
this
.
_canceled
=
true
;
},
},
shouldCancel
:
function
()
{
shouldCancel
:
function
()
{
return
this
.
_cancelable
&&
this
.
_canceled
;
return
this
.
_cancelable
&&
this
.
_canceled
;
},
},
shouldCancelImmediately
:
function
()
{
shouldCancelImmediately
:
function
()
{
return
this
.
_cancelable
&&
this
.
_immediatelyCanceld
;
return
this
.
_cancelable
&&
this
.
_immediatelyCanceld
;
}
}
});
}
);
\ No newline at end of file
\ No newline at end of file
src/core/mindernode.js
View file @
ad872831
var
MinderNode
=
km
.
MinderNode
=
kity
.
createClass
(
"MinderNode"
,
{
var
MinderNode
=
km
.
MinderNode
=
kity
.
createClass
(
"MinderNode"
,
{
constructor
:
function
(
treeNotifyHandler
)
{
constructor
:
function
(
treeNotifyHandler
)
{
this
.
parent
=
null
;
this
.
parent
=
null
;
this
.
children
=
[];
this
.
children
=
[];
...
@@ -8,88 +8,89 @@ var MinderNode = km.MinderNode = kity.createClass("MinderNode", {
...
@@ -8,88 +8,89 @@ var MinderNode = km.MinderNode = kity.createClass("MinderNode", {
this
.
rc
.
minderNode
=
this
;
this
.
rc
.
minderNode
=
this
;
},
},
getParent
:
function
()
{
getParent
:
function
()
{
return
this
.
parent
;
return
this
.
parent
;
},
},
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
;
},
},
getChildren
:
function
()
{
getChildren
:
function
()
{
return
this
.
children
;
return
this
.
children
;
},
},
getIndex
:
function
()
{
getIndex
:
function
()
{
return
this
.
parent
?
this
.
parent
.
indexOf
(
this
)
:
-
1
;
return
this
.
parent
?
this
.
parent
.
indexOf
(
this
)
:
-
1
;
},
},
insertChild
:
function
(
node
,
index
)
{
insertChild
:
function
(
node
,
index
)
{
if
(
index
===
undefined
)
{
if
(
index
===
undefined
)
{
index
=
this
.
children
.
length
;
index
=
this
.
children
.
length
;
}
}
if
(
node
.
parent
)
{
if
(
node
.
parent
)
{
node
.
parent
.
removeChild
(
node
);
node
.
parent
.
removeChild
(
node
);
}
}
node
.
parent
=
this
;
node
.
parent
=
this
;
this
.
children
.
splice
(
index
,
0
,
node
);
this
.
children
.
splice
(
index
,
0
,
node
);
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
);
},
},
prependChild
:
function
(
node
)
{
prependChild
:
function
(
node
)
{
return
this
.
insertChild
(
node
,
0
);
return
this
.
insertChild
(
node
,
0
);
},
},
removeChild
:
function
(
elem
)
{
removeChild
:
function
(
elem
)
{
var
index
=
elem
,
removed
;
var
index
=
elem
,
if
(
elem
instanceof
MinderNode
)
{
removed
;
index
=
this
.
children
.
indexOf
(
elem
);
if
(
elem
instanceof
MinderNode
)
{
index
=
this
.
children
.
indexOf
(
elem
);
}
}
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
];
},
},
getData
:
function
(
name
)
{
getData
:
function
(
name
)
{
if
(
name
===
undefined
)
{
if
(
name
===
undefined
)
{
return
this
.
data
;
return
this
.
data
;
}
}
return
this
.
data
[
name
];
return
this
.
data
[
name
];
},
},
setData
:
function
(
name
,
value
)
{
setData
:
function
(
name
,
value
)
{
this
.
data
[
name
]
=
value
;
this
.
data
[
name
]
=
value
;
},
},
getRenderContainer
:
function
()
{
getRenderContainer
:
function
()
{
return
this
.
rc
;
return
this
.
rc
;
}
}
});
}
);
\ No newline at end of file
\ 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