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
7c798280
Commit
7c798280
authored
Jan 17, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
22479859
d1bcc394
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
70 additions
and
47 deletions
+70
-47
dev.php
dist/dev.php
+7
-1
event.js
src/core/event.js
+3
-0
minder.event.js
src/core/minder.event.js
+3
-1
minder.select.js
src/core/minder.select.js
+1
-1
node.js
src/core/node.js
+6
-0
editor.js
src/module/editor.js
+32
-21
editor.receiver.js
src/module/editor.receiver.js
+3
-2
keyboard.js
src/module/keyboard.js
+8
-2
mouse.js
src/module/mouse.js
+7
-19
No files found.
dist/dev.php
View file @
7c798280
...
@@ -19,7 +19,13 @@ $dependency = Array(
...
@@ -19,7 +19,13 @@ $dependency = Array(
'src/module/layout.default.js'
,
'src/module/layout.default.js'
,
'src/module/layout.green.js'
,
'src/module/layout.green.js'
,
'src/core/minder.select.js'
,
'src/core/minder.select.js'
,
'src/module/keyboard.js'
'src/module/keyboard.js'
,
'src/module/mouse.js'
// 'src/module/editor.js',
// 'src/module/editor.range.js',
// 'src/module/editor.receiver.js',
// 'src/module/editor.cursor.js'
);
);
$content
=
""
;
$content
=
""
;
...
...
src/core/event.js
View file @
7c798280
...
@@ -38,5 +38,8 @@ var MinderEvent = kity.createClass( 'MindEvent', {
...
@@ -38,5 +38,8 @@ var MinderEvent = kity.createClass( 'MindEvent', {
shouldStopPropagationImmediately
:
function
()
{
shouldStopPropagationImmediately
:
function
()
{
return
this
.
_canstop
&&
this
.
_immediatelyStoped
;
return
this
.
_canstop
&&
this
.
_immediatelyStoped
;
},
preventDefault
:
function
(){
this
.
originEvent
.
preventDefault
();
}
}
}
);
}
);
\ No newline at end of file
src/core/minder.event.js
View file @
7c798280
...
@@ -13,7 +13,6 @@ kity.extendClass( Minder, {
...
@@ -13,7 +13,6 @@ kity.extendClass( Minder, {
},
},
// TODO: mousemove lazy bind
// TODO: mousemove lazy bind
_bindPaperEvents
:
function
()
{
_bindPaperEvents
:
function
()
{
var
minder
=
this
;
this
.
_paper
.
on
(
'click mousedown mouseup mousemove touchstart touchmove touchend'
,
this
.
_firePharse
.
bind
(
this
)
);
this
.
_paper
.
on
(
'click mousedown mouseup mousemove touchstart touchmove touchend'
,
this
.
_firePharse
.
bind
(
this
)
);
},
},
_bindKeyboardEvents
:
function
()
{
_bindKeyboardEvents
:
function
()
{
...
@@ -30,8 +29,11 @@ kity.extendClass( Minder, {
...
@@ -30,8 +29,11 @@ kity.extendClass( Minder, {
}
}
preEvent
=
new
MinderEvent
(
'pre'
+
e
.
type
,
e
,
false
);
preEvent
=
new
MinderEvent
(
'pre'
+
e
.
type
,
e
,
false
);
executeEvent
=
new
MinderEvent
(
e
.
type
,
e
,
false
);
executeEvent
=
new
MinderEvent
(
e
.
type
,
e
,
false
);
this
.
_fire
(
preEvent
);
this
.
_fire
(
preEvent
);
this
.
_fire
(
executeEvent
);
this
.
_fire
(
executeEvent
);
this
.
_fire
(
new
MinderEvent
(
'after'
+
e
.
type
,
e
,
false
));
if
(
~
'mousedown mouseup keydown keyup'
.
indexOf
(
e
.
type
)
)
{
if
(
~
'mousedown mouseup keydown keyup'
.
indexOf
(
e
.
type
)
)
{
this
.
_interactChange
(
e
);
this
.
_interactChange
(
e
);
}
}
...
...
src/core/minder.select.js
View file @
7c798280
...
@@ -65,7 +65,7 @@ kity.extendClass( Minder, function () {
...
@@ -65,7 +65,7 @@ kity.extendClass( Minder, function () {
this
.
_selectedNodes
=
nodes
;
this
.
_selectedNodes
=
nodes
;
},
},
isSingleSelect
:
function
(){
isSingleSelect
:
function
(){
return
this
.
getSelectedNodes
()
.
length
==
1
return
this
.
_selectedNodes
.
length
==
1
}
}
}
}
}()
);
}()
);
\ No newline at end of file
src/core/node.js
View file @
7c798280
...
@@ -11,6 +11,12 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -11,6 +11,12 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this
.
rc
=
new
kity
.
Group
();
this
.
rc
=
new
kity
.
Group
();
this
.
rc
.
minderNode
=
this
;
this
.
rc
.
minderNode
=
this
;
},
},
setText
:
function
(
text
){
this
.
setData
(
'text'
,
text
)
},
getText
:
function
(){
return
this
.
getData
(
'text'
)
},
isRoot
:
function
(){
isRoot
:
function
(){
return
this
.
getParent
()
==
null
?
true
:
false
;
return
this
.
getParent
()
==
null
?
true
:
false
;
},
},
...
...
src/module/editor.js
View file @
7c798280
...
@@ -3,17 +3,22 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -3,17 +3,22 @@ KityMinder.registerModule( "TextEditModule", function () {
var
receiver
=
new
Minder
.
Receiver
();
var
receiver
=
new
Minder
.
Receiver
();
var
range
=
new
Minder
.
Range
();
var
range
=
new
Minder
.
Range
();
this
.
getPaper
().
addShape
(
cursor
);
return
{
return
{
//插入光标
"init"
:
function
(){
this
.
getPaper
().
addShape
(
cursor
);
},
"events"
:
{
"events"
:
{
'mousedown'
:
function
(
e
){
'aftermousedown'
:
function
(
e
){
if
(
this
.
isSingleSelect
()){
var
originEvent
=
e
.
originEvent
;
debugger
var
targetShape
=
e
.
kityEvent
.
targetShape
;
var
node
=
this
.
getSelectedNode
();
var
position
=
e
.
getPosition
();
var
node_rc
=
node
.
getRenderContainer
();
if
(
targetShape
.
getType
()
!=
'Text'
){
var
position
=
e
.
getPosition
();
// var offset = e.getPosition();
if
(
node_rc
.
getType
()
!=
'Text'
){
// cursor.setShow().setPosition(offset);
var
offset
=
e
.
getPosition
();
cursor
.
setShow
().
setPosition
(
offset
);
// receiver.clear()
// receiver.clear()
// .setTextShape()
// .setTextShape()
// .setTextShapeSize(cursor.height)
// .setTextShapeSize(cursor.height)
...
@@ -21,22 +26,28 @@ KityMinder.registerModule( "TextEditModule", function () {
...
@@ -21,22 +26,28 @@ KityMinder.registerModule( "TextEditModule", function () {
// .setPosition(position)
// .setPosition(position)
// .setRange(range,0)
// .setRange(range,0)
// .setCursor(cursor)
// .setCursor(cursor)
}
else
{
receiver
.
setCursor
(
cursor
)
.
setKityMinder
(
this
)
.
setMinderNode
(
node
)
.
setTextShape
(
node_rc
)
.
setCursorHeight
()
.
setCurrentIndex
(
position
)
.
updateCursor
()
.
setRange
(
range
,
0
);
}
else
{
receiver
.
setCursor
(
cursor
)
//
receiver.setCursor(cursor)
.
setKityMinder
(
this
)
//
.setKityMinder(this)
.
setMinderNode
(
e
.
getTargetNode
())
//
.setMinderNode(e.getTargetNode())
.
setTextShape
(
targetShape
)
// .setTextShape(node_rc
)
.
setCursorHeight
()
//
.setCursorHeight()
.
setCurrentIndex
(
position
)
//
.setCurrentIndex(position)
.
updateCursor
()
//
.updateCursor()
.
setRange
(
range
);
//
.setRange(range);
}
}
}
},
'kbcreateandedit'
:
function
(){
receiver
.
clear
()
}
}
}
}
...
...
src/module/editor.receiver.js
View file @
7c798280
...
@@ -67,8 +67,9 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -67,8 +67,9 @@ Minder.Receiver = kity.createClass('Receiver',{
case
'keyup'
:
case
'keyup'
:
var
text
=
(
this
.
container
.
textContent
||
this
.
container
.
innerText
).
replace
(
/
\u
200b/g
,
''
);
var
text
=
(
this
.
container
.
textContent
||
this
.
container
.
innerText
).
replace
(
/
\u
200b/g
,
''
);
this
.
textShape
.
setContent
(
text
);
this
.
textShape
.
setContent
(
text
);
this
.
minderNode
.
setData
(
'text'
,
text
);
this
.
minderNode
.
setText
(
text
);
this
.
km
.
execCommand
(
'renderNode'
,
this
.
minderNode
);
this
.
km
.
renderNode
(
this
.
minderNode
);
this
.
updateTextData
();
this
.
updateTextData
();
this
.
updateCursor
();
this
.
updateCursor
();
this
.
timer
=
setTimeout
(
function
(){
this
.
timer
=
setTimeout
(
function
(){
...
...
src/module/keyboard.js
View file @
7c798280
...
@@ -66,10 +66,12 @@ KityMinder.registerModule( "KeyboardModule", function () {
...
@@ -66,10 +66,12 @@ KityMinder.registerModule( "KeyboardModule", function () {
case
13
:
case
13
:
// Enter
// Enter
this
.
execCommand
(
'appendSiblingNode'
,
new
MinderNode
(
'Topic'
));
this
.
execCommand
(
'appendSiblingNode'
,
new
MinderNode
(
'Topic'
));
e
.
preventDefault
();
break
;
break
;
case
9
:
case
9
:
// Tab
// Tab
this
.
execCommand
(
'appendChildNode'
,
new
MinderNode
(
'Topic'
));
this
.
execCommand
(
'appendChildNode'
,
new
MinderNode
(
'Topic'
));
e
.
preventDefault
();
break
;
break
;
case
8
:
case
8
:
case
46
:
case
46
:
...
@@ -87,9 +89,13 @@ KityMinder.registerModule( "KeyboardModule", function () {
...
@@ -87,9 +89,13 @@ KityMinder.registerModule( "KeyboardModule", function () {
40
:
'down'
40
:
'down'
}[
e
.
originEvent
.
keyCode
]);
}[
e
.
originEvent
.
keyCode
]);
}
}
e
.
preventDefault
();
break
;
break
;
}
}
}
}
}
}
}
;
}
}
);
}
);
\ No newline at end of file
src/module/mouse.js
View file @
7c798280
KityMinder
.
registerModule
(
"MouseModule"
,
function
()
{
KityMinder
.
registerModule
(
"MouseModule"
,
function
()
{
var
SingleSelectCommand
=
kity
.
createClass
(
'SingleSelectCommand'
,
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
var
deltaNodes
=
km
.
getSelectedNodes
();
km
.
clearSelect
();
if
(
node
)
{
km
.
selectSingle
(
node
);
deltaNodes
.
push
(
node
);
}
km
.
execCommand
(
'rendernode'
,
deltaNodes
);
this
.
setContentChanged
(
false
);
}
}
);
var
Draggable
=
(
function
()
{
var
Draggable
=
(
function
()
{
var
Paper
=
kity
.
Paper
;
var
Paper
=
kity
.
Paper
;
...
@@ -156,17 +143,18 @@ KityMinder.registerModule( "MouseModule", function () {
...
@@ -156,17 +143,18 @@ KityMinder.registerModule( "MouseModule", function () {
}
}
return
{
return
{
"init"
:
function
()
{
"init"
:
function
()
{
kity
.
extendClass
(
kity
.
Paper
,
Draggable
);
// kity.extendClass( kity.Paper, Draggable );
this
.
_paper
.
drag
();
// this._paper.drag();
},
"commands"
:
{
'selectsingle'
:
SingleSelectCommand
},
},
"events"
:
{
"events"
:
{
'mousedown touchstart'
:
function
(
e
)
{
'mousedown touchstart'
:
function
(
e
)
{
if
(
e
.
originEvent
.
touches
&&
e
.
originEvent
.
touches
.
length
!=
1
)
return
;
if
(
e
.
originEvent
.
touches
&&
e
.
originEvent
.
touches
.
length
!=
1
)
return
;
var
clickNode
=
e
.
getTargetNode
();
var
clickNode
=
e
.
getTargetNode
();
this
.
execCommand
(
'selectsingle'
,
clickNode
);
if
(
clickNode
){
this
.
select
(
clickNode
)
}
else
{
this
.
removeAllSelectedNodes
()
}
},
},
'touchstart'
:
function
(
e
)
{
'touchstart'
:
function
(
e
)
{
...
...
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