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
6fbd73c8
Commit
6fbd73c8
authored
Dec 20, 2013
by
Akikonata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
Conflicts: src/core/kityminder.js
parents
469d5306
8b7c0bfa
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
246 additions
and
16 deletions
+246
-16
history.html
demo/history.html
+86
-0
dev.php
dist/dev.php
+5
-1
kityminder.js
src/core/kityminder.js
+9
-12
_example.js
src/module/_example.js
+2
-2
history.js
src/module/history.js
+143
-1
render.js
src/module/render.js
+1
-0
No files found.
demo/history.html
0 → 100644
View file @
6fbd73c8
<!DOCTYPE html>
<html>
<head>
<script
src=
"../kity/dist/kitygraph.all.js"
></script>
<script
src=
"../dist/dev.php"
></script>
</head>
<body>
</body>
<script>
KityMinder
.
registerModule
(
"Test"
,
function
()
{
var
AppendCommand
=
kity
.
createClass
({
base
:
Command
,
execute
:
function
(
km
,
str
)
{
km
.
text
=
km
.
text
+
str
;
this
.
appendLength
=
str
.
length
;
},
revert
:
function
(
km
)
{
km
.
text
=
km
.
text
.
substr
(
0
,
km
.
text
.
length
-
this
.
appendLength
);
}
});
var
DeleteCommand
=
kity
.
createClass
({
base
:
Command
,
execute
:
function
(
km
,
count
)
{
this
.
deleted
=
km
.
text
.
substr
(
km
.
text
.
length
-
count
);
km
.
text
=
km
.
text
.
substr
(
0
,
km
.
text
.
length
-
count
);
},
revert
:
function
(
km
)
{
km
.
text
+=
this
.
deleted
;
}
});
var
BatchCommand
=
kity
.
createClass
({
base
:
Command
,
execute
:
function
(
km
)
{
var
combines
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
var
cmd
;
while
(
combines
.
length
)
{
cmd
=
combines
.
shift
().
split
(
':'
);
switch
(
cmd
[
0
])
{
case
'a'
:
km
.
execCommand
(
'append'
,
cmd
[
1
]);
break
;
case
'd'
:
km
.
execCommand
(
'delete'
,
cmd
[
1
]);
break
;
}
}
}
});
return
{
commands
:
{
'append'
:
AppendCommand
,
'delete'
:
DeleteCommand
,
'batch'
:
BatchCommand
}
}
});
minder
=
new
km
.
KityMinder
();
minder
.
text
=
""
;
function
run
(
name
)
{
minder
.
execCommand
.
apply
(
minder
,
arguments
);
console
.
log
(
name
,
': '
,
minder
.
text
);
}
run
(
'append'
,
'techird'
);
run
(
'append'
,
' good '
);
run
(
'batch'
,
'a:good '
,
'a:study'
);
run
(
'undo'
);
run
(
'redo'
);
run
(
'undo'
);
run
(
'redo'
);
run
(
'delete'
,
5
);
run
(
'undo'
);
</script>
</html>
\ No newline at end of file
dist/dev.php
View file @
6fbd73c8
...
...
@@ -21,5 +21,9 @@ $content = "";
header
(
'Content-Type: text/javascript; charset=utf-8'
);
foreach
(
$dependency
as
$index
=>
$dep
)
{
echo
file_get_contents
(
"../
$dep
"
)
.
"
\n\n
"
;
if
(
$_GET
[
'join'
]
!=
null
)
{
echo
file_get_contents
(
"../
$dep
"
)
.
"
\n\n
"
;
}
else
{
echo
"document.write('<script charset=utf-8 src=
\"
../
$dep
\"
></script>');"
;
}
}
\ No newline at end of file
src/core/kityminder.js
View file @
6fbd73c8
...
...
@@ -78,25 +78,22 @@ kity.extendClass( KityMinder, ( function () {
var
me
=
this
;
var
_action
=
new
_commands
[
name
.
toLowerCase
()
]();
var
args
=
arguments
;
args
[
0
]
=
this
;
var
_sendingArgs
=
(
function
()
{
var
_args
=
[];
for
(
var
i
=
1
;
i
<
args
.
length
;
i
++
)
{
_args
.
push
(
args
[
i
]
);
}
return
_args
;
}
)();
var
cmdArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
var
eventParams
=
{
command
:
_action
,
commandName
:
name
.
toLowerCase
(),
commandArgs
:
_sending
Args
commandArgs
:
cmd
Args
};
var
canceled
=
me
.
_fire
(
new
MinderEvent
(
'beforecommand'
,
eventParams
,
true
)
);
if
(
!
canceled
)
{
me
.
_fire
(
new
MinderEvent
(
"precommand"
,
eventParams
,
false
)
);
_action
.
execute
.
apply
(
_action
,
args
);
_action
.
execute
.
apply
(
_action
,
[
this
].
concat
(
cmdArgs
)
);
me
.
_fire
(
new
MinderEvent
(
"command"
,
eventParams
,
false
)
);
if
(
_action
.
isContentChanged
()
)
{
...
...
@@ -189,7 +186,7 @@ kity.extendClass( KityMinder, {
var
listen
=
function
(
name
,
callback
)
{
if
(
window
.
addEventListener
)
{
window
.
addEventListener
(
name
,
callback
);
}
else
if
(
window
.
attachEvent
)
{
}
else
if
(
window
.
attachEvent
)
{
window
.
attachEvent
(
name
,
callback
);
}
};
...
...
src/module/_example.js
View file @
6fbd73c8
...
...
@@ -78,12 +78,12 @@ KityMinder.registerModule( "ExampleModule", function () {
"beforecommand"
:
function
(
e
)
{
// e.cancel() 方法可以阻止 before 事件进入下个阶段
// e.cancelImmediately() 方法可以阻止当前回调后的回调执行,并且阻止事件进入下个阶段
console
.
log
(
e
.
type
+
' fired'
);
//
console.log( e.type + ' fired' );
},
"command"
:
function
(
e
)
{
// 命令执行后的事件
console
.
log
(
e
.
type
+
' fired'
);
//
console.log( e.type + ' fired' );
},
"contentchange"
:
function
(
e
)
{
...
...
src/module/history.js
View file @
6fbd73c8
KityMinder
.
registerModule
(
"HistoryModule"
,
function
()
{
var
Stack
=
kity
.
createClass
(
"Stack"
,
{
constructor
:
function
(
size
)
{
this
.
size
=
size
||
Number
.
MAX_VALUE
;
this
.
length
=
0
;
},
push
:
function
(
elem
)
{
if
(
this
.
length
===
this
.
size
)
{
this
.
shift
();
}
this
[
this
.
length
++
]
=
elem
;
},
top
:
function
()
{
return
this
[
this
.
length
-
1
];
},
pop
:
function
()
{
return
this
[
--
this
.
length
];
},
empty
:
function
()
{
return
this
.
length
===
0
;
},
clear
:
function
()
{
this
.
length
=
0
;
},
splice
:
function
()
{
// just to make stack array-like
}
}
);
function
getStack
(
km
,
type
)
{
var
stacks
=
km
.
_hisoryStacks
||
(
km
.
_hisoryStacks
=
{}
);
return
stacks
[
type
]
||
(
stacks
[
type
]
=
new
Stack
()
);
}
function
markExecuting
(
km
,
command
)
{
km
.
_commandExecuting
=
command
;
}
function
getExecuting
(
km
)
{
return
km
.
_commandExecuting
||
null
;
}
function
markRedoing
(
km
,
redoing
)
{
km
.
_redoing
=
redoing
;
}
function
isRedoing
(
km
)
{
return
km
.
_redoing
;
}
function
shouldIgnore
(
cmdName
)
{
return
cmdName
==
'undo'
||
cmdName
==
'redo'
;
}
function
getCommandContext
(
e
)
{
return
{
name
:
e
.
commandName
,
args
:
e
.
commandArgs
,
command
:
e
.
command
};
}
var
UndoCommand
=
kity
.
createClass
(
"UndoCommand"
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
undoStack
=
getStack
(
km
,
"undo"
),
redoStack
=
getStack
(
km
,
"redo"
),
contextStack
,
context
;
if
(
!
undoStack
.
empty
()
)
{
contextStack
=
undoStack
.
pop
();
redoStack
.
push
(
contextStack
);
for
(
var
i
=
contextStack
.
length
-
1
;
i
>=
0
;
i
--
)
{
context
=
contextStack
[
i
];
context
.
command
.
revert
(
km
);
}
}
},
queryState
:
function
(
km
)
{
return
getStack
(
km
,
'undo'
).
empty
()
?
-
1
:
0
;
}
}
);
var
RedoCommand
=
kity
.
createClass
(
"RedoCommand"
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
undoStack
=
getStack
(
km
,
"undo"
),
redoStack
=
getStack
(
km
,
"redo"
),
contextStack
,
context
;
if
(
!
redoStack
.
empty
()
)
{
contextStack
=
redoStack
.
pop
();
undoStack
.
push
(
contextStack
);
markRedoing
(
km
,
true
);
for
(
var
i
=
0
;
i
<
contextStack
.
length
;
i
++
)
{
context
=
contextStack
[
i
];
context
.
command
.
execute
.
apply
(
context
.
command
,
[
km
].
concat
(
context
.
args
)
);
}
markRedoing
(
km
,
false
);
}
},
queryState
:
function
(
km
)
{
return
getStack
(
km
,
'redo'
).
empty
()
?
-
1
:
0
;
}
}
);
return
{
"commands"
:
{
"undo"
:
UndoCommand
,
"redo"
:
RedoCommand
},
"events"
:
{
"beforecommand"
:
function
(
e
)
{
if
(
isRedoing
(
this
)
)
{
e
.
cancel
();
}
},
"precommand"
:
function
(
e
)
{
if
(
shouldIgnore
(
e
.
commandName
)
)
return
;
var
undoStack
=
getStack
(
this
,
"undo"
),
redoStack
=
getStack
(
this
,
"redo"
),
contextStack
;
if
(
getExecuting
(
this
)
===
null
)
{
markExecuting
(
this
,
e
.
command
);
undoStack
.
push
(
new
Stack
()
);
redoStack
.
clear
();
}
contextStack
=
undoStack
.
top
();
contextStack
.
push
(
getCommandContext
(
e
)
);
},
"command"
:
function
(
e
)
{
if
(
shouldIgnore
(
e
.
commandName
)
)
return
;
if
(
getExecuting
(
this
)
===
e
.
command
)
{
markExecuting
(
this
,
null
);
}
}
}
};
}
);
\ No newline at end of file
src/module/render.js
View file @
6fbd73c8
...
...
@@ -6,6 +6,7 @@ KityMinder.registerModule( "RenderModule", ( function () {
radius
:
5
,
text
:
"Root"
,
fill
:
"#7ecef4"
,
stroke
:
"white"
};
var
drawRectNode
=
function
(
kR
,
node
)
{
if
(
!
node
)
{
...
...
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