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
ab550838
Commit
ab550838
authored
Jan 20, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改history
parent
ca60958e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
134 additions
and
65 deletions
+134
-65
dev.php
dist/dev.php
+2
-1
utils.js
spec/core/utils.js
+1
-1
minder.js
src/core/minder.js
+9
-3
minder.module.js
src/core/minder.module.js
+2
-1
minder.node.js
src/core/minder.node.js
+3
-1
node.js
src/core/node.js
+13
-2
utils.js
src/core/utils.js
+1
-1
history.js
src/module/history.js
+103
-52
layout.js
src/module/layout.js
+0
-3
No files found.
dist/dev.php
View file @
ab550838
...
...
@@ -20,7 +20,8 @@ $dependency = Array(
'src/module/layout.green.js'
,
'src/core/minder.select.js'
,
'src/module/keyboard.js'
,
'src/module/mouse.js'
'src/module/mouse.js'
,
'src/module/history.js'
// 'src/module/editor.js',
// 'src/module/editor.range.js',
// 'src/module/editor.receiver.js',
...
...
spec/core/utils.js
View file @
ab550838
...
...
@@ -6,7 +6,7 @@ describe("utils", function () {
'test'
:[
1
,
2
],
'test1'
:
1
};
var
obj2
=
utils
.
clone
(
obj1
);
var
obj2
=
utils
.
clone
PlainObject
(
obj1
);
it
(
'相等'
,
function
(){
expect
(
utils
.
compareObject
(
obj1
,
obj2
)).
toBeTruthy
();
...
...
src/core/minder.js
View file @
ab550838
...
...
@@ -27,6 +27,15 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getOptions
:
function
(
key
)
{
return
this
.
_options
[
key
];
},
setDefaultOptions
:
function
(
key
,
val
){
var
obj
=
{};
if
(
utils
.
isString
(
key
))
{
obj
[
key
]
=
val
}
else
{
obj
=
key
;
}
utils
.
extend
(
this
.
_options
,
obj
,
true
);
},
_initMinder
:
function
()
{
this
.
_rc
=
new
kity
.
Group
();
...
...
@@ -40,9 +49,6 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
renderTo
(
this
.
_options
.
renderTo
);
}
},
clearPaper
:
function
(){
this
.
_rc
.
clear
();
},
renderTo
:
function
(
target
)
{
this
.
_paper
.
renderTo
(
this
.
_renderTarget
=
target
);
this
.
_bindEvents
();
...
...
src/core/minder.module.js
View file @
ab550838
...
...
@@ -21,7 +21,8 @@ kity.extendClass( Minder, {
this
.
_modules
[
name
]
=
moduleDeals
;
if
(
moduleDeals
.
init
)
{
moduleDeals
.
init
.
call
(
me
,
Utils
.
extend
(
moduleDeals
.
defaultOptions
||
{},
this
.
_options
)
);
this
.
setDefaultOptions
(
moduleDeals
.
defaultOptions
||
{});
moduleDeals
.
init
.
call
(
me
,
this
.
_options
);
}
//command加入命令池子
...
...
src/core/minder.node.js
View file @
ab550838
...
...
@@ -3,7 +3,9 @@ kity.extendClass( Minder, {
getRoot
:
function
()
{
return
this
.
_root
;
},
setRoot
:
function
(
root
){
this
.
_root
=
root
;
},
handelNodeInsert
:
function
(
node
)
{
var
rc
=
this
.
_rc
;
node
.
traverse
(
function
(
current
)
{
...
...
src/core/node.js
View file @
ab550838
...
...
@@ -188,8 +188,19 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
clone
:
function
(){
return
utils
.
clone
(
this
)
},
function
cloneNode
(
parent
,
isClonedNode
){
var
_tmp
=
new
KM
.
MinderNode
(
isClonedNode
.
getData
());
_tmp
.
parent
=
parent
;
for
(
var
i
=
0
,
ci
;
ci
=
isClonedNode
.
children
[
i
++
];){
cloneNode
(
_tmp
,
ci
);
}
return
_tmp
;
}
return
function
(){
return
cloneNode
(
null
,
this
);
}
}(),
equals
:
function
(
node
){
if
(
node
.
children
.
length
!=
this
.
children
.
length
){
return
false
;
...
...
src/core/utils.js
View file @
ab550838
...
...
@@ -109,7 +109,7 @@ var utils = Utils = KityMinder.Utils = {
argsToArray
:
function
(
args
,
index
)
{
return
Array
.
prototype
.
slice
.
call
(
args
,
index
||
0
);
},
clone
:
function
(
source
,
target
)
{
clone
PlainObject
:
function
(
source
,
target
)
{
var
tmp
;
target
=
target
||
{};
for
(
var
i
in
source
)
{
...
...
src/module/history.js
View file @
ab550838
KityMinder
.
registerModule
(
"HistoryModule"
,
function
()
{
var
Scene
=
kity
.
createClass
(
'Scene'
,{
constructor
:
function
(
root
){
this
.
data
=
root
.
clone
();
},
getData
:
function
(){
return
this
.
data
;
},
cloneData
:
function
(){
return
this
.
getData
().
clone
();
},
equals
:
function
(
scene
){
return
this
.
getData
().
equals
(
scene
.
getData
())
}
})
var
Undo
Manager
=
kity
.
createClass
(
'UndoManager'
,{
constructor
:
function
(){
})
;
var
History
Manager
=
kity
.
createClass
(
'UndoManager'
,{
constructor
:
function
(
km
){
this
.
list
=
[];
this
.
index
=
0
;
this
.
hasUndo
=
false
;
this
.
hasRedo
=
false
;
this
.
km
=
km
;
},
undo
:
function
(){
if
(
this
.
hasUndo
)
{
if
(
!
this
.
list
[
this
.
index
-
1
]
&&
this
.
list
.
length
==
1
)
{
this
.
reset
();
return
;
}
while
(
this
.
list
[
this
.
index
].
equals
(
this
.
list
[
this
.
index
-
1
]))
{
this
.
index
--
;
if
(
this
.
index
==
0
)
{
return
this
.
restore
(
0
);
}
})
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
);
}
this
.
restore
(
--
this
.
index
);
}
},
queryState
:
function
(
km
)
{
return
getStack
(
km
,
'undo'
).
empty
()
?
-
1
:
0
;
redo
:
function
(){
if
(
this
.
hasRedo
)
{
while
(
this
.
list
[
this
.
index
].
equals
(
this
.
list
[
this
.
index
+
1
]))
{
this
.
index
++
;
if
(
this
.
index
==
this
.
list
.
length
-
1
)
{
return
this
.
restore
(
this
.
index
);
}
}
this
.
restore
(
++
this
.
index
);
}
},
restore
:
function
(){
var
scene
=
this
.
list
[
this
.
index
];
this
.
km
.
setRoot
(
scene
.
cloneData
());
this
.
km
.
initStyle
();
this
.
update
();
},
getScene
:
function
(){
return
new
Scene
(
this
.
km
.
getRoot
())
},
saveScene
:
function
(){
var
currentScene
=
this
.
getScene
();
var
lastScene
=
this
.
list
[
this
.
index
];
if
(
lastScene
&&
lastScene
.
equals
(
currentScene
)){
return
}
this
.
list
=
this
.
list
.
slice
(
0
,
this
.
index
+
1
);
this
.
list
.
push
(
currentScene
);
//如果大于最大数量了,就把最前的剔除
if
(
this
.
list
.
length
>
this
.
km
.
getOptions
(
'maxUndoCount'
))
{
this
.
list
.
shift
();
}
}
);
this
.
index
=
this
.
list
.
length
-
1
;
//跟新undo/redo状态
this
.
update
();
},
update
:
function
()
{
this
.
hasRedo
=
!!
this
.
list
[
this
.
index
+
1
];
this
.
hasUndo
=
!!
this
.
list
[
this
.
index
-
1
];
},
reset
:
function
(){
this
.
list
=
[];
this
.
index
=
0
;
this
.
hasUndo
=
false
;
this
.
hasRedo
=
false
;
}
});
this
.
historyManager
=
new
HistoryManager
(
this
);
var
RedoCommand
=
kity
.
createClass
(
"RedoCommand"
,
{
return
{
defaultOptions
:{
maxUndoCount
:
20
},
"commands"
:
{
"undo"
:
kity
.
createClass
(
"UndoCommand"
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
undoStack
=
getStack
(
km
,
"undo"
),
redoStack
=
getStack
(
km
,
"redo"
),
contextStack
,
context
;
km
.
historyManager
.
undo
()
},
if
(
!
redoStack
.
empty
()
)
{
contextStack
=
redoStack
.
pop
();
undoStack
.
push
(
contextStack
);
queryState
:
function
(
km
)
{
km
.
historyManager
.
hasUndo
?
0
:
-
1
;
},
isNeedUndo
:
true
}
),
"redo"
:
kity
.
createClass
(
"RedoCommand"
,
{
base
:
Command
,
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
);
}
execute
:
function
(
km
)
{
km
.
historyManager
.
redo
()
},
queryState
:
function
(
km
)
{
return
getStack
(
km
,
'redo'
).
empty
()
?
-
1
:
0
;
}
}
);
return
{
"commands"
:
{
"undo"
:
UndoCommand
,
"redo"
:
RedoCommand
return
km
.
historyManager
.
hasRedo
?
0
:
-
1
;
},
isNeedUndo
:
true
}
)
},
"events"
:
{
"saveScene"
:
function
(
e
)
{
this
.
historyManager
.
saveScene
();
}
}
};
...
...
src/module/layout.js
View file @
ab550838
...
...
@@ -19,9 +19,6 @@ KityMinder.registerModule( "LayoutModule", function () {
clearLayout
:
function
()
{
this
.
setData
(
'layout'
,
{}
);
this
.
getRenderContainer
().
clear
();
},
updateLayout
:
function
(
km
)
{
km
.
updateLayout
(
this
);
}
}
);
var
switchLayout
=
function
(
km
,
style
)
{
...
...
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