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
c9b61560
Commit
c9b61560
authored
Jan 14, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed argument getting method
parent
9631b740
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
81 deletions
+86
-81
dev.html
demo/dev.html
+9
-8
command.js
src/core/command.js
+1
-1
minder.command.js
src/core/minder.command.js
+14
-13
utils.js
src/core/utils.js
+61
-59
layout.js
src/module/layout.js
+1
-0
No files found.
demo/dev.html
View file @
c9b61560
...
@@ -46,15 +46,16 @@
...
@@ -46,15 +46,16 @@
_root
.
setData
(
"appendside"
,
"right"
);
_root
.
setData
(
"appendside"
,
"right"
);
minder
.
renderNode
(
_root
);
minder
.
renderNode
(
_root
);
minder
.
execCommand
(
"createchildnode"
,
_root
);
//模拟生成一个初始图
//模拟生成一个初始图
for
(
var
j
=
0
;
j
<
20
;
j
++
){
//
for(var j=0;j
<
20
;
j
++
){
var
appendSide
=
Math
.
random
()
>
0.5
?
"left"
:
"right"
;
//
var appendSide = Math.random()>0.5?"left":"right";
var
layerArray
=
_root
.
getData
(
"layer"
+
appendSide
);
//
var layerArray = _root.getData("layer"+appendSide);
var
layer
=
parseInt
(
Math
.
random
()
*
layerArray
.
length
);
//
var layer = parseInt(Math.random()*layerArray.length);
var
layerData
=
layerArray
[
layer
];
//
var layerData = layerArray[layer];
var
root
=
layerData
[
parseInt
(
Math
.
random
()
*
layerData
.
length
)]
//
var root = layerData[parseInt(Math.random()*layerData.length)]
minder
.
execCommand
(
"createchildnode"
,
root
);
//
minder.execCommand("createchildnode",root);
}
//
}
</script>
</script>
</html>
</html>
\ No newline at end of file
src/core/command.js
View file @
c9b61560
...
@@ -31,7 +31,7 @@ var Command = kity.createClass( "Command", {
...
@@ -31,7 +31,7 @@ var Command = kity.createClass( "Command", {
queryValue
:
function
(
km
)
{
queryValue
:
function
(
km
)
{
return
0
;
return
0
;
},
},
isNeedUndo
:
function
()
{
isNeedUndo
:
function
()
{
return
true
;
return
true
;
}
}
}
);
}
);
\ No newline at end of file
src/core/minder.command.js
View file @
c9b61560
...
@@ -5,29 +5,30 @@ kity.extendClass( Minder, {
...
@@ -5,29 +5,30 @@ kity.extendClass( Minder, {
_queryCommand
:
function
(
name
,
type
,
args
)
{
_queryCommand
:
function
(
name
,
type
,
args
)
{
var
cmd
=
this
.
_getCommand
(
name
);
var
cmd
=
this
.
_getCommand
(
name
);
if
(
cmd
)
{
if
(
cmd
)
{
var
queryCmd
=
cmd
[
'query'
+
type
];
var
queryCmd
=
cmd
[
'query'
+
type
];
if
(
queryCmd
)
if
(
queryCmd
)
return
queryCmd
.
apply
(
cmd
,[
this
].
concat
(
args
))
return
queryCmd
.
apply
(
cmd
,
[
this
].
concat
(
args
)
);
}
}
return
0
return
0
;
},
},
queryCommandState
:
function
(
name
)
{
queryCommandState
:
function
(
name
)
{
return
this
.
_queryCommand
(
name
,
"State"
,
utils
.
argsToArray
(
1
)
);
return
this
.
_queryCommand
(
name
,
"State"
,
Utils
.
argsToArray
(
1
)
);
},
},
queryCommandValue
:
function
(
name
)
{
queryCommandValue
:
function
(
name
)
{
return
this
.
_queryCommand
(
name
,
"Value"
,
utils
.
argsToArray
(
1
)
);
return
this
.
_queryCommand
(
name
,
"Value"
,
Utils
.
argsToArray
(
1
)
);
},
},
execCommand
:
function
(
name
)
{
execCommand
:
function
(
name
)
{
name
=
name
.
toLowerCase
();
name
=
name
.
toLowerCase
();
var
cmdArgs
=
utils
.
argsToArray
(
1
),
cmd
,
stoped
,
result
,
eventParams
;
var
cmdArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
),
cmd
,
stoped
,
result
,
eventParams
;
var
me
=
this
;
var
me
=
this
;
cmd
=
this
.
_getCommand
(
name
);
cmd
=
this
.
_getCommand
(
name
);
console
.
log
(
cmdArgs
);
eventParams
=
{
eventParams
=
{
command
:
cmd
,
command
:
cmd
,
...
@@ -38,13 +39,13 @@ kity.extendClass( Minder, {
...
@@ -38,13 +39,13 @@ kity.extendClass( Minder, {
return
false
;
return
false
;
}
}
if
(
!
this
.
_hasEnterExecCommand
&&
cmd
.
isNeedUndo
())
{
if
(
!
this
.
_hasEnterExecCommand
&&
cmd
.
isNeedUndo
()
)
{
this
.
_hasEnterExecCommand
=
true
;
this
.
_hasEnterExecCommand
=
true
;
stoped
=
this
.
_fire
(
new
MinderEvent
(
'beforeExecCommand'
,
eventParams
,
true
)
);
stoped
=
this
.
_fire
(
new
MinderEvent
(
'beforeExecCommand'
,
eventParams
,
true
)
);
if
(
!
stoped
)
{
if
(
!
stoped
)
{
//保存场景
//保存场景
this
.
_fire
(
new
MinderEvent
(
'saveScene'
)
);
this
.
_fire
(
new
MinderEvent
(
'saveScene'
)
);
this
.
_fire
(
new
MinderEvent
(
"preExecCommand"
,
eventParams
,
false
)
);
this
.
_fire
(
new
MinderEvent
(
"preExecCommand"
,
eventParams
,
false
)
);
...
@@ -53,7 +54,7 @@ kity.extendClass( Minder, {
...
@@ -53,7 +54,7 @@ kity.extendClass( Minder, {
this
.
_fire
(
new
MinderEvent
(
'execCommand'
,
eventParams
,
false
)
);
this
.
_fire
(
new
MinderEvent
(
'execCommand'
,
eventParams
,
false
)
);
//保存场景
//保存场景
this
.
_fire
(
new
MinderEvent
(
'saveScene'
)
);
this
.
_fire
(
new
MinderEvent
(
'saveScene'
)
);
if
(
cmd
.
isContentChanged
()
)
{
if
(
cmd
.
isContentChanged
()
)
{
this
.
_firePharse
(
new
MinderEvent
(
'contentchange'
)
);
this
.
_firePharse
(
new
MinderEvent
(
'contentchange'
)
);
...
@@ -64,7 +65,7 @@ kity.extendClass( Minder, {
...
@@ -64,7 +65,7 @@ kity.extendClass( Minder, {
this
.
_firePharse
(
new
MinderEvent
(
'interactchange'
)
);
this
.
_firePharse
(
new
MinderEvent
(
'interactchange'
)
);
}
}
this
.
_hasEnterExecCommand
=
false
;
this
.
_hasEnterExecCommand
=
false
;
}
else
{
}
else
{
result
=
cmd
.
execute
.
apply
(
cmd
,
[
me
].
concat
(
cmdArgs
)
);
result
=
cmd
.
execute
.
apply
(
cmd
,
[
me
].
concat
(
cmdArgs
)
);
}
}
...
...
src/core/utils.js
View file @
c9b61560
var
utils
=
Utils
=
KityMinder
.
Utils
=
{
var
utils
=
Utils
=
KityMinder
.
Utils
=
{
extend
:
kity
.
Utils
.
extend
.
bind
(
kity
.
Utils
),
extend
:
kity
.
Utils
.
extend
.
bind
(
kity
.
Utils
),
listen
:
function
(
element
,
type
,
handler
)
{
listen
:
function
(
element
,
type
,
handler
)
{
var
types
=
utils
.
isArray
(
type
)
?
type
:
utils
.
trim
(
type
).
split
(
/
\s
+/
),
var
types
=
utils
.
isArray
(
type
)
?
type
:
utils
.
trim
(
type
).
split
(
/
\s
+/
),
k
=
types
.
length
;
k
=
types
.
length
;
if
(
k
)
while
(
k
--
)
{
if
(
k
)
type
=
types
[
k
];
while
(
k
--
)
{
if
(
element
.
addEventListener
)
{
type
=
types
[
k
];
element
.
addEventListener
(
type
,
handler
,
false
);
if
(
element
.
addEventListener
)
{
element
.
addEventListener
(
type
,
handler
,
false
);
}
else
{
}
else
{
if
(
!
handler
.
_d
)
{
if
(
!
handler
.
_d
)
{
handler
.
_d
=
{
handler
.
_d
=
{
els
:
[]
els
:
[]
};
};
}
}
var
key
=
type
+
handler
.
toString
(),
index
=
utils
.
indexOf
(
handler
.
_d
.
els
,
element
);
var
key
=
type
+
handler
.
toString
(),
if
(
!
handler
.
_d
[
key
]
||
index
==
-
1
)
{
index
=
utils
.
indexOf
(
handler
.
_d
.
els
,
element
);
if
(
index
==
-
1
){
if
(
!
handler
.
_d
[
key
]
||
index
==
-
1
)
{
handler
.
_d
.
els
.
push
(
element
);
if
(
index
==
-
1
)
{
handler
.
_d
.
els
.
push
(
element
);
}
}
if
(
!
handler
.
_d
[
key
])
{
if
(
!
handler
.
_d
[
key
]
)
{
handler
.
_d
[
key
]
=
function
(
evt
)
{
handler
.
_d
[
key
]
=
function
(
evt
)
{
return
handler
.
call
(
evt
.
srcElement
,
evt
||
window
.
event
);
return
handler
.
call
(
evt
.
srcElement
,
evt
||
window
.
event
);
};
};
}
}
element
.
attachEvent
(
'on'
+
type
,
handler
.
_d
[
key
]
);
element
.
attachEvent
(
'on'
+
type
,
handler
.
_d
[
key
]
);
}
}
}
}
}
}
element
=
null
;
element
=
null
;
},
},
trim
:
function
(
str
)
{
trim
:
function
(
str
)
{
return
str
.
replace
(
/
(
^
[
\t\n\r]
+
)
|
([
\t\n\r]
+$
)
/g
,
''
);
return
str
.
replace
(
/
(
^
[
\t\n\r]
+
)
|
([
\t\n\r]
+$
)
/g
,
''
);
},
},
each
:
function
(
obj
,
iterator
,
context
)
{
each
:
function
(
obj
,
iterator
,
context
)
{
if
(
obj
==
null
)
return
;
if
(
obj
==
null
)
return
;
if
(
obj
.
length
===
+
obj
.
length
)
{
if
(
obj
.
length
===
+
obj
.
length
)
{
for
(
var
i
=
0
,
l
=
obj
.
length
;
i
<
l
;
i
++
)
{
for
(
var
i
=
0
,
l
=
obj
.
length
;
i
<
l
;
i
++
)
{
if
(
iterator
.
call
(
context
,
i
,
obj
[
i
],
obj
)
===
false
)
if
(
iterator
.
call
(
context
,
i
,
obj
[
i
],
obj
)
===
false
)
return
false
;
return
false
;
}
}
}
else
{
}
else
{
for
(
var
key
in
obj
)
{
for
(
var
key
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
key
)
)
{
if
(
obj
.
hasOwnProperty
(
key
)
)
{
if
(
iterator
.
call
(
context
,
key
,
obj
[
key
],
obj
)
===
false
)
if
(
iterator
.
call
(
context
,
key
,
obj
[
key
],
obj
)
===
false
)
return
false
;
return
false
;
}
}
}
}
}
}
},
},
addCssRule
:
function
(
key
,
style
,
doc
)
{
addCssRule
:
function
(
key
,
style
,
doc
)
{
var
head
,
node
;
var
head
,
node
;
if
(
style
===
undefined
||
style
&&
style
.
nodeType
&&
style
.
nodeType
==
9
)
{
if
(
style
===
undefined
||
style
&&
style
.
nodeType
&&
style
.
nodeType
==
9
)
{
//获取样式
//获取样式
doc
=
style
&&
style
.
nodeType
&&
style
.
nodeType
==
9
?
style
:
(
doc
||
document
);
doc
=
style
&&
style
.
nodeType
&&
style
.
nodeType
==
9
?
style
:
(
doc
||
document
);
node
=
doc
.
getElementById
(
key
);
node
=
doc
.
getElementById
(
key
);
return
node
?
node
.
innerHTML
:
undefined
;
return
node
?
node
.
innerHTML
:
undefined
;
}
}
doc
=
doc
||
document
;
doc
=
doc
||
document
;
node
=
doc
.
getElementById
(
key
);
node
=
doc
.
getElementById
(
key
);
//清除样式
//清除样式
if
(
style
===
''
)
{
if
(
style
===
''
)
{
if
(
node
)
{
if
(
node
)
{
node
.
parentNode
.
removeChild
(
node
);
node
.
parentNode
.
removeChild
(
node
);
return
true
return
true
}
}
return
false
;
return
false
;
}
}
//添加样式
//添加样式
if
(
node
)
{
if
(
node
)
{
node
.
innerHTML
=
style
;
node
.
innerHTML
=
style
;
}
else
{
}
else
{
node
=
doc
.
createElement
(
'style'
);
node
=
doc
.
createElement
(
'style'
);
node
.
id
=
key
;
node
.
id
=
key
;
node
.
innerHTML
=
style
;
node
.
innerHTML
=
style
;
doc
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
node
);
doc
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
node
);
}
}
},
},
keys
:
function
(
plain
)
{
keys
:
function
(
plain
)
{
var
keys
=
[];
var
keys
=
[];
for
(
var
key
in
plain
)
{
for
(
var
key
in
plain
)
{
if
(
plain
.
hasOwnProperty
(
key
)
)
{
if
(
plain
.
hasOwnProperty
(
key
)
)
{
...
@@ -88,30 +90,30 @@ var utils = Utils = KityMinder.Utils = {
...
@@ -88,30 +90,30 @@ var utils = Utils = KityMinder.Utils = {
}
}
return
keys
;
return
keys
;
},
},
proxy
:
function
(
fn
,
context
)
{
proxy
:
function
(
fn
,
context
)
{
return
function
()
{
return
function
()
{
return
fn
.
apply
(
context
,
arguments
);
return
fn
.
apply
(
context
,
arguments
);
};
};
},
},
indexOf
:
function
(
array
,
item
,
start
)
{
indexOf
:
function
(
array
,
item
,
start
)
{
var
index
=
-
1
;
var
index
=
-
1
;
start
=
this
.
isNumber
(
start
)
?
start
:
0
;
start
=
this
.
isNumber
(
start
)
?
start
:
0
;
this
.
each
(
array
,
function
(
v
,
i
)
{
this
.
each
(
array
,
function
(
v
,
i
)
{
if
(
i
>=
start
&&
v
===
item
)
{
if
(
i
>=
start
&&
v
===
item
)
{
index
=
i
;
index
=
i
;
return
false
;
return
false
;
}
}
});
}
);
return
index
;
return
index
;
},
},
argsToArray
:
function
(
index
)
{
argsToArray
:
function
(
index
)
{
return
Array
.
prototype
.
slice
.
call
(
arguments
,
index
||
0
);
return
Array
.
prototype
.
slice
.
call
(
arguments
,
index
||
0
);
}
}
};
};
Utils
.
each
(
[
'String'
,
'Function'
,
'Array'
,
'Number'
,
'RegExp'
,
'Object'
],
function
(
i
,
v
)
{
Utils
.
each
(
[
'String'
,
'Function'
,
'Array'
,
'Number'
,
'RegExp'
,
'Object'
],
function
(
i
,
v
)
{
KityMinder
.
Utils
[
'is'
+
v
]
=
function
(
obj
)
{
KityMinder
.
Utils
[
'is'
+
v
]
=
function
(
obj
)
{
return
Object
.
prototype
.
toString
.
apply
(
obj
)
==
'[object '
+
v
+
']'
;
return
Object
.
prototype
.
toString
.
apply
(
obj
)
==
'[object '
+
v
+
']'
;
}
}
});
}
);
\ No newline at end of file
\ No newline at end of file
src/module/layout.js
View file @
c9b61560
...
@@ -83,6 +83,7 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -83,6 +83,7 @@ KityMinder.registerModule( "LayoutModule", function () {
};
};
var
createChildNode
=
function
(
km
,
parent
,
index
)
{
var
createChildNode
=
function
(
km
,
parent
,
index
)
{
console
.
log
(
km
,
parent
);
var
root
=
km
.
getRoot
();
var
root
=
km
.
getRoot
();
var
appendSide
=
parent
.
getData
(
"appendside"
);
var
appendSide
=
parent
.
getData
(
"appendside"
);
var
_node
=
new
MinderNode
();
var
_node
=
new
MinderNode
();
...
...
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