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
0c2f2610
Commit
0c2f2610
authored
Feb 22, 2014
by
campaign
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
06027381
d7485a62
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
171 additions
and
11 deletions
+171
-11
dev.php
dist/dev.php
+1
-0
layout.js
src/adapter/layout.js
+8
-0
saveto.js
src/adapter/saveto.js
+50
-9
dragtree.js
src/module/dragtree.js
+1
-1
layout.bottom.js
src/module/layout.bottom.js
+5
-0
layout.js
src/module/layout.js
+4
-1
png.js
src/protocal/png.js
+102
-0
No files found.
dist/dev.php
View file @
0c2f2610
...
...
@@ -66,6 +66,7 @@ $dependency = Array(
,
'src/adapter/node.js'
,
'src/protocal/plain.js'
,
'src/protocal/json.js'
,
'src/protocal/png.js'
);
$content
=
""
;
...
...
src/adapter/layout.js
View file @
0c2f2610
...
...
@@ -26,6 +26,14 @@ KM.registerToolbarUI( 'layout', function ( name ) {
$combox
.
appendTo
(
me
.
$container
.
find
(
'.kmui-dialog-container'
)
);
}
}
);
me
.
on
(
'interactchange'
,
function
()
{
var
value
=
this
.
queryCommandValue
(
"switchlayout"
);
if
(
value
)
{
//设置label
comboboxWidget
.
selectItemByLabel
(
value
);
}
}
);
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
}
);
\ No newline at end of file
src/adapter/saveto.js
View file @
0c2f2610
...
...
@@ -24,11 +24,59 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
options
.
autowidthitem
.
push
(
$
.
wordCountAdaptive
(
text
),
true
);
}
);
//实例化
$combox
=
$
.
kmuibuttoncombobox
(
options
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
comboboxWidget
=
$combox
.
kmui
();
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
)
{
if
(
res
.
value
===
"png"
)
{
var
svghtml
=
$
(
"#kityminder .kmui-editor-body"
).
html
();
var
rootBox
=
me
.
getRoot
().
getRenderContainer
().
getRenderBox
();
var
svg
=
$
(
svghtml
).
attr
(
{
width
:
rootBox
.
x
+
me
.
getRenderContainer
().
getWidth
()
+
20
,
height
:
rootBox
.
y
+
me
.
getRenderContainer
().
getHeight
()
+
20
,
viewBox
:
null
}
);
var
div
=
$
(
"<div></div>"
).
append
(
svg
);
svghtml
=
div
.
html
();
var
canvas
=
$
(
'<canvas style="border:2px solid black;" width="'
+
svg
.
attr
(
"width"
)
+
'" height="'
+
svg
.
attr
(
"height"
)
+
'"></canvas>'
);
var
ctx
=
canvas
[
0
].
getContext
(
"2d"
);
var
DOMURL
=
self
.
URL
||
self
.
webkitURL
||
self
;
var
img
=
new
Image
();
var
svg
=
new
Blob
(
[
svghtml
],
{
type
:
"image/svg+xml;charset=utf-8"
}
);
var
url
=
DOMURL
.
createObjectURL
(
svg
);
img
.
onload
=
function
()
{
ctx
.
drawImage
(
img
,
0
,
0
);
DOMURL
.
revokeObjectURL
(
url
);
var
type
=
'png'
;
var
imgData
=
canvas
[
0
].
toDataURL
(
type
);
var
_fixType
=
function
(
type
)
{
type
=
type
.
toLowerCase
().
replace
(
/jpg/i
,
'jpeg'
);
var
r
=
type
.
match
(
/png|jpeg|bmp|gif/
)[
0
];
return
'image/'
+
r
;
};
imgData
=
imgData
.
replace
(
_fixType
(
type
),
'image/octet-stream'
);
var
saveFile
=
function
(
data
,
filename
)
{
var
save_link
=
document
.
createElementNS
(
'http://www.w3.org/1999/xhtml'
,
'a'
);
save_link
.
href
=
data
;
save_link
.
download
=
filename
;
var
event
=
document
.
createEvent
(
'MouseEvents'
);
event
.
initMouseEvent
(
'click'
,
true
,
false
,
window
,
0
,
0
,
0
,
0
,
0
,
false
,
false
,
false
,
false
,
0
,
null
);
save_link
.
dispatchEvent
(
event
);
};
// 下载后的问题名
var
filename
=
'kityminder_'
+
(
new
Date
()
).
getTime
()
+
'.'
+
type
;
// download
saveFile
(
imgData
,
filename
);
};
img
.
src
=
url
;
return
"png"
;
}
var
data
=
me
.
exportData
(
res
.
value
);
var
p
=
KityMinder
.
findProtocal
(
res
.
value
);
var
a
=
downloadLink
;
...
...
@@ -39,15 +87,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
if
(
$combox
.
parent
().
length
===
0
)
{
$combox
.
appendTo
(
me
.
$container
.
find
(
'.kmui-dialog-container'
)
);
}
var
combox
=
$combox
.
kmui
();
combox
.
traverseItems
(
function
(
label
,
value
)
{
if
(
me
.
queryCommandState
(
value
)
==
-
1
)
{
combox
.
disableItemByLabel
(
label
)
}
else
{
combox
.
enableItemByLabel
(
label
)
}
}
)
}
).
on
(
'aftercomboboxselect'
,
function
()
{
this
.
setLabelWithDefaultValue
();
}
);
...
...
src/module/dragtree.js
View file @
0c2f2610
...
...
@@ -32,7 +32,7 @@ var MoveToParentCommand = kity.createClass( 'MoveToParentCommand', {
function
boxMapper
(
node
)
{
return
node
.
getRenderContainer
().
getRenderBox
();
return
node
.
getRenderContainer
().
getRenderBox
(
'top'
);
}
// 对拖动对象的一个替代盒子,控制整个拖放的逻辑,包括:
...
...
src/module/layout.bottom.js
View file @
0c2f2610
...
...
@@ -464,6 +464,11 @@ KityMinder.registerModule( "LayoutBottom", function () {
translateNode
(
set
[
j
]
);
updateConnectAndshIcon
(
set
[
j
]
);
}
var
set1
=
updateLayoutMain
();
for
(
var
k
=
0
;
k
<
set1
.
length
;
k
++
)
{
translateNode
(
set1
[
k
]
);
updateConnectAndshIcon
(
set1
[
k
]
);
}
var
_buffer
=
[
nodes
[
0
]
];
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
...
...
src/module/layout.js
View file @
0c2f2610
...
...
@@ -94,7 +94,10 @@ KityMinder.registerModule( "LayoutModule", function () {
var
SwitchLayoutCommand
=
kity
.
createClass
(
"SwitchLayoutCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
switchLayout
execute
:
switchLayout
,
queryValue
:
function
(
km
)
{
return
km
.
getCurrentStyle
();
}
};
}
)()
);
var
AppendChildNodeCommand
=
kity
.
createClass
(
"AppendChildNodeCommand"
,
(
function
()
{
...
...
src/protocal/png.js
0 → 100644
View file @
0c2f2610
KityMinder
.
registerProtocal
(
"png"
,
function
()
{
var
LINE_ENDING
=
'
\
n'
,
TAB_CHAR
=
'
\
t'
;
function
repeat
(
s
,
n
)
{
var
result
=
""
;
while
(
n
--
)
result
+=
s
;
return
result
;
}
function
encode
(
json
,
level
)
{
var
local
=
""
;
level
=
level
||
0
;
local
+=
repeat
(
TAB_CHAR
,
level
);
local
+=
json
.
data
.
text
+
LINE_ENDING
;
if
(
json
.
children
)
{
json
.
children
.
forEach
(
function
(
child
)
{
local
+=
encode
(
child
,
level
+
1
);
}
);
}
return
local
;
}
function
isEmpty
(
line
)
{
return
!
/
\S
/
.
test
(
line
);
}
function
getLevel
(
line
)
{
var
level
=
0
;
while
(
line
.
charAt
(
level
)
===
TAB_CHAR
)
level
++
;
return
level
;
}
function
getNode
(
line
)
{
return
{
data
:
{
text
:
line
.
replace
(
new
RegExp
(
'^'
+
TAB_CHAR
+
'*'
),
''
)
}
};
}
function
decode
(
local
)
{
var
json
,
parentMap
=
{},
lines
=
local
.
split
(
LINE_ENDING
),
line
,
level
,
node
;
function
addChild
(
parent
,
child
)
{
var
children
=
parent
.
children
||
(
parent
.
children
=
[]
);
children
.
push
(
child
);
}
for
(
var
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
line
=
lines
[
i
];
if
(
isEmpty
(
line
)
)
continue
;
level
=
getLevel
(
line
);
node
=
getNode
(
line
);
if
(
level
===
0
)
{
if
(
json
)
{
throw
new
Error
(
'Invalid local format'
);
}
json
=
node
;
}
else
{
if
(
!
parentMap
[
level
-
1
]
)
{
throw
new
Error
(
'Invalid local format'
);
}
addChild
(
parentMap
[
level
-
1
],
node
);
}
parentMap
[
level
]
=
node
;
}
return
json
;
}
var
lastTry
,
lastResult
;
function
recognize
(
local
)
{
if
(
!
Utils
.
isString
(
local
)
)
return
false
;
lastTry
=
local
;
try
{
lastResult
=
decode
(
local
);
}
catch
(
e
)
{
lastResult
=
null
;
}
return
!!
lastResult
;
}
return
{
fileDescription
:
'png'
,
fileExtension
:
'.png'
,
encode
:
function
(
json
)
{
return
encode
(
json
,
0
);
},
decode
:
function
(
local
)
{
if
(
lastTry
==
local
&&
lastResult
)
{
return
lastResult
;
}
return
decode
(
local
);
},
recognize
:
recognize
,
recognizePriority
:
-
1
};
}
);
\ 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