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
02ac2067
Commit
02ac2067
authored
Jan 22, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed funcs
parent
ae46c37d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
50 deletions
+70
-50
minder.js
src/core/minder.js
+24
-41
layout.default.js
src/module/layout.default.js
+0
-1
layout.js
src/module/layout.js
+46
-8
No files found.
src/core/minder.js
View file @
02ac2067
...
...
@@ -16,8 +16,6 @@ var MinderDefaultOptions = {
var
Minder
=
KityMinder
.
Minder
=
kity
.
createClass
(
"KityMinder"
,
{
constructor
:
function
(
options
)
{
this
.
_options
=
Utils
.
extend
(
window
.
KITYMINDER_CONFIG
||
{},
MinderDefaultOptions
,
options
);
this
.
_layoutStyles
=
{};
this
.
_currentStyle
=
""
;
this
.
_initEvents
();
this
.
_initMinder
();
this
.
_initSelection
();
...
...
@@ -29,14 +27,14 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getOptions
:
function
(
key
)
{
return
this
.
_options
[
key
];
},
setDefaultOptions
:
function
(
key
,
val
)
{
setDefaultOptions
:
function
(
key
,
val
)
{
var
obj
=
{};
if
(
utils
.
isString
(
key
)
)
{
obj
[
key
]
=
val
if
(
Utils
.
isString
(
key
)
)
{
obj
[
key
]
=
val
;
}
else
{
obj
=
key
;
}
utils
.
extend
(
this
.
_options
,
obj
,
true
);
Utils
.
extend
(
this
.
_options
,
obj
,
true
);
},
_initMinder
:
function
()
{
...
...
@@ -46,7 +44,6 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this
.
_paper
.
getNode
().
setAttribute
(
'contenteditable'
,
true
);
this
.
_root
=
new
MinderNode
();
this
.
_rc
.
addShape
(
this
.
_root
.
getRenderContainer
()
);
if
(
this
.
_options
.
renderTo
)
{
this
.
renderTo
(
this
.
_options
.
renderTo
);
}
...
...
@@ -64,62 +61,48 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getPaper
:
function
()
{
return
this
.
_paper
;
},
addLayoutStyle
:
function
(
name
,
style
)
{
this
.
_layoutStyles
[
name
]
=
style
;
},
getLayoutStyle
:
function
(
name
)
{
return
this
.
_layoutStyles
[
name
];
},
getCurrentStyle
:
function
()
{
return
this
.
_currentStyle
;
},
setCurrentStyle
:
function
(
name
)
{
this
.
_currentStyle
=
name
;
return
name
;
},
getRenderTarget
:
function
()
{
return
this
.
_renderTarget
;
},
_initShortcutKey
:
function
()
{
_initShortcutKey
:
function
()
{
this
.
_shortcutkeys
=
{};
this
.
_bindshortcutKeys
();
},
addShortcutKeys
:
function
(
cmd
,
keys
)
{
addShortcutKeys
:
function
(
cmd
,
keys
)
{
var
obj
=
{};
if
(
keys
)
{
obj
[
cmd
]
=
keys
if
(
keys
)
{
obj
[
cmd
]
=
keys
}
else
{
obj
=
cmd
;
}
utils
.
extend
(
this
.
_shortcutkeys
,
obj
)
utils
.
extend
(
this
.
_shortcutkeys
,
obj
)
},
_bindshortcutKeys
:
function
()
{
var
me
=
this
,
shortcutkeys
=
this
.
_shortcutkeys
;
me
.
on
(
'keydown'
,
function
(
e
)
{
var
me
=
this
,
shortcutkeys
=
this
.
_shortcutkeys
;
me
.
on
(
'keydown'
,
function
(
e
)
{
var
originEvent
=
e
.
originEvent
;
var
keyCode
=
originEvent
.
keyCode
||
originEvent
.
which
;
for
(
var
i
in
shortcutkeys
)
{
var
tmp
=
shortcutkeys
[
i
].
split
(
','
);
for
(
var
t
=
0
,
ti
;
ti
=
tmp
[
t
++
];)
{
ti
=
ti
.
split
(
':'
);
var
key
=
ti
[
0
],
param
=
ti
[
1
];
if
(
/^
(
ctrl
)(\+
shift
)?\+(\d
+
)
$/
.
test
(
key
.
toLowerCase
())
||
/^
(\d
+
)
$/
.
test
(
key
))
{
if
((
(
RegExp
.
$1
==
'ctrl'
?
(
originEvent
.
ctrlKey
||
originEvent
.
metaKey
)
:
0
)
&&
(
RegExp
.
$2
!=
""
?
originEvent
[
RegExp
.
$2
.
slice
(
1
)
+
"Key"
]
:
1
)
&&
keyCode
==
RegExp
.
$3
)
||
for
(
var
i
in
shortcutkeys
)
{
var
tmp
=
shortcutkeys
[
i
].
split
(
','
);
for
(
var
t
=
0
,
ti
;
ti
=
tmp
[
t
++
];
)
{
ti
=
ti
.
split
(
':'
);
var
key
=
ti
[
0
],
param
=
ti
[
1
];
if
(
/^
(
ctrl
)(\+
shift
)?\+(\d
+
)
$/
.
test
(
key
.
toLowerCase
()
)
||
/^
(\d
+
)
$/
.
test
(
key
)
)
{
if
(
(
(
RegExp
.
$1
==
'ctrl'
?
(
originEvent
.
ctrlKey
||
originEvent
.
metaKey
)
:
0
)
&&
(
RegExp
.
$2
!=
""
?
originEvent
[
RegExp
.
$2
.
slice
(
1
)
+
"Key"
]
:
1
)
&&
keyCode
==
RegExp
.
$3
)
||
keyCode
==
RegExp
.
$1
)
{
if
(
me
.
queryCommandState
(
i
,
param
)
!=
-
1
)
me
.
execCommand
(
i
,
param
);
)
{
if
(
me
.
queryCommandState
(
i
,
param
)
!=
-
1
)
me
.
execCommand
(
i
,
param
);
e
.
preventDefault
();
}
}
}
}
});
}
);
}
}
);
...
...
src/module/layout.default.js
View file @
02ac2067
...
...
@@ -328,7 +328,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
break
;
}
};
//判断根据父节点位置定位还是自身已经带有位置属性
if
(
parent
)
{
countX
(
node
);
...
...
src/module/layout.js
View file @
02ac2067
KityMinder
.
registerModule
(
"LayoutModule"
,
function
()
{
kity
.
extendClass
(
Minder
,
{
addLayoutStyle
:
function
(
name
,
style
)
{
if
(
!
this
.
_layoutStyles
)
this
.
_layoutStyles
=
{};
this
.
_layoutStyles
[
name
]
=
style
;
},
getLayoutStyle
:
function
(
name
)
{
return
this
.
_layoutStyles
[
name
];
},
getCurrentStyle
:
function
()
{
var
_root
=
this
.
getRoot
();
return
_root
.
getData
(
"currentstyle"
);
},
setCurrentStyle
:
function
(
name
)
{
var
_root
=
this
.
getRoot
();
_root
.
setData
(
"currentstyle"
,
name
);
return
name
;
},
renderNode
:
function
(
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
renderNode
.
call
(
this
,
node
);
},
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
},
appendChildNode
:
function
(
parent
,
node
,
index
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendChildNode
.
call
(
this
,
parent
,
node
,
index
);
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendSiblingNode
.
call
(
this
,
sibling
,
node
);
},
removeNode
:
function
(
nodes
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
appendChildNode
.
call
(
this
,
nodes
);
},
updateLayout
:
function
(
node
)
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getLayoutStyle
(
curStyle
).
updateLayout
.
call
(
this
,
node
);
}
}
);
kity
.
extendClass
(
MinderNode
,
{
setLayout
:
function
(
k
,
v
)
{
if
(
this
.
setData
(
'layout'
)
===
undefined
)
{
...
...
@@ -26,14 +68,7 @@ KityMinder.registerModule( "LayoutModule", function () {
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
}
);
var
_style
=
km
.
getLayoutStyle
(
style
);
if
(
!
_style
)
return
false
;
km
.
renderNode
=
_style
.
renderNode
;
km
.
initStyle
=
_style
.
initStyle
;
km
.
appendChildNode
=
_style
.
appendChildNode
;
km
.
appendSiblingNode
=
_style
.
appendSiblingNode
;
km
.
removeNode
=
_style
.
removeNode
;
km
.
updateLayout
=
_style
.
updateLayout
;
km
.
setCurrentStyle
(
style
);
km
.
initStyle
();
return
style
;
};
...
...
@@ -90,6 +125,9 @@ KityMinder.registerModule( "LayoutModule", function () {
"ready"
:
function
()
{
switchLayout
(
this
,
this
.
getOptions
(
'layoutstyle'
)
);
}
},
"defaultOptions"
:
{
"layoutstyle"
:
"default"
}
};
}
);
\ 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