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
bac03aa0
Commit
bac03aa0
authored
Feb 24, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
merge save to png
parents
b72d7ac9
e601b7b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
200 deletions
+118
-200
dev.js
dist/dev.js
+106
-191
index.html
dist/index.html
+2
-2
kity
kity
+1
-1
saveto.js
src/adapter/saveto.js
+9
-6
No files found.
dist/dev.js
View file @
bac03aa0
...
@@ -756,16 +756,6 @@ var MinderEvent = kity.createClass( 'MindEvent', {
...
@@ -756,16 +756,6 @@ var MinderEvent = kity.createClass( 'MindEvent', {
}
}
}
);
}
);
/* @require <kityminder.js>
* @require <module.js>
* @require <event.js>
* @require <node.js>
* @reuqire <command.js>
* @require <utils.js>
*
* @description KityMinder 使用类
*/
var
Minder
=
KityMinder
.
Minder
=
kity
.
createClass
(
"KityMinder"
,
{
var
Minder
=
KityMinder
.
Minder
=
kity
.
createClass
(
"KityMinder"
,
{
constructor
:
function
(
options
)
{
constructor
:
function
(
options
)
{
this
.
_options
=
Utils
.
extend
(
window
.
KITYMINDER_CONFIG
||
{},
options
);
this
.
_options
=
Utils
.
extend
(
window
.
KITYMINDER_CONFIG
||
{},
options
);
...
@@ -1827,8 +1817,9 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -1827,8 +1817,9 @@ KityMinder.registerModule( "LayoutModule", function () {
},
},
initStyle
:
function
()
{
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
var
curStyle
=
this
.
getCurrentStyle
();
var
lastTransform
=
this
.
_rc
.
getTransform
();
this
.
_rc
.
remove
();
this
.
_rc
.
remove
();
this
.
_rc
=
new
kity
.
Group
();
this
.
_rc
=
new
kity
.
Group
()
.
setTransform
(
lastTransform
)
;
this
.
_paper
.
addShape
(
this
.
_rc
);
this
.
_paper
.
addShape
(
this
.
_rc
);
var
_root
=
this
.
getRoot
();
var
_root
=
this
.
getRoot
();
...
@@ -3252,170 +3243,87 @@ kity.extendClass( Minder, function () {
...
@@ -3252,170 +3243,87 @@ kity.extendClass( Minder, function () {
};
};
}()
);
}()
);
kity
.
Draggable
=
(
function
()
{
var
ViewDragger
=
kity
.
createClass
(
"ViewDragger"
,
{
var
Paper
=
kity
.
Paper
;
constructor
:
function
(
minder
)
{
this
.
_minder
=
minder
;
var
touchable
=
window
.
ontouchstart
!==
undefined
;
this
.
_enabled
=
false
;
var
DRAG_START_EVENT
=
touchable
?
'touchstart'
:
'mousedown'
,
this
.
_offset
=
{
DRAG_MOVE_EVENT
=
touchable
?
'touchmove'
:
'mousemove'
,
x
:
0
,
DRAG_END_EVENT
=
touchable
?
'touchend'
:
'mouseup'
;
y
:
0
};
this
.
_bind
();
},
isEnabled
:
function
()
{
return
this
.
_enabled
;
},
setEnabled
:
function
(
value
)
{
var
paper
=
this
.
_minder
.
getPaper
();
paper
.
setStyle
(
'cursor'
,
value
?
'pointer'
:
'default'
);
paper
.
setStyle
(
'cursor'
,
value
?
'-webkit-grab'
:
'default'
);
this
.
_enabled
=
value
;
},
return
kity
.
createClass
(
{
_bind
:
function
()
{
drag
:
function
(
opt
)
{
var
dragger
=
this
,
isRootDrag
=
false
,
lastPosition
=
null
,
currentPosition
=
null
;
if
(
this
.
dragEnabled
)
{
this
.
_minder
.
on
(
'beforemousedown'
,
function
(
e
)
{
return
;
// 已经被用户打开拖放模式
if
(
dragger
.
isEnabled
()
)
{
lastPosition
=
e
.
getPosition
();
e
.
stopPropagation
();
}
// 点击未选中的根节点临时开启
else
if
(
e
.
getTargetNode
()
==
this
.
getRoot
()
&&
(
!
this
.
getRoot
().
isSelected
()
||
!
this
.
isSingleSelect
()))
{
lastPosition
=
e
.
getPosition
();
dragger
.
setEnabled
(
true
);
isRootDrag
=
true
;
}
}
var
dragStart
=
opt
&&
opt
.
start
||
this
.
dragStart
,
}
)
dragMove
=
opt
&&
opt
.
move
||
this
.
dragMove
,
dragEnd
=
opt
&&
opt
.
end
||
this
.
dragEnd
,
dragTarget
=
opt
&&
opt
.
target
||
this
.
dragTarget
||
this
,
me
=
this
;
this
.
dragEnabled
=
true
;
this
.
dragTarget
=
dragTarget
;
function
bindEvents
(
paper
)
{
var
startPosition
,
lastPosition
,
dragging
=
false
;
var
dragFn
=
function
(
e
)
{
if
(
!
dragging
)
{
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
}
if
(
e
.
originEvent
.
touches
&&
e
.
originEvent
.
touches
.
length
!==
1
)
return
;
var
currentPosition
=
e
.
getPosition
();
var
movement
=
{
x
:
currentPosition
.
x
-
startPosition
.
x
,
y
:
currentPosition
.
y
-
startPosition
.
y
};
var
delta
=
{
x
:
currentPosition
.
x
-
lastPosition
.
x
,
y
:
currentPosition
.
y
-
lastPosition
.
y
};
var
dragInfo
=
{
position
:
currentPosition
,
movement
:
movement
,
delta
:
delta
};
lastPosition
=
currentPosition
;
if
(
dragMove
)
{
dragMove
.
call
(
me
,
dragInfo
);
}
else
if
(
me
instanceof
Paper
)
{
// treate paper drag different
var
view
=
me
.
getViewPort
();
view
.
center
.
x
-=
movement
.
x
;
view
.
center
.
y
-=
movement
.
y
;
me
.
setViewPort
(
view
);
}
else
{
me
.
translate
(
delta
.
x
,
delta
.
y
);
}
dragTarget
.
trigger
(
'dragmove'
,
dragInfo
);
e
.
stopPropagation
();
e
.
preventDefault
();
};
dragTarget
.
on
(
DRAG_START_EVENT
,
dragTarget
.
_dragStartHandler
=
function
(
e
)
{
if
(
e
.
originEvent
.
button
)
{
return
;
}
dragging
=
true
;
var
dragInfo
=
{
position
:
lastPosition
=
startPosition
=
e
.
getPosition
()
};
if
(
dragStart
)
{
var
cancel
=
dragStart
.
call
(
me
,
dragInfo
)
===
false
;
if
(
cancel
)
{
return
;
}
}
paper
.
on
(
DRAG_MOVE_EVENT
,
dragFn
);
dragTarget
.
trigger
(
'dragstart'
,
dragInfo
);
e
.
stopPropagation
();
e
.
preventDefault
();
}
);
paper
.
on
(
DRAG_END_EVENT
,
dragTarget
.
_dragEndHandler
=
function
(
e
)
{
if
(
dragging
)
{
dragging
=
false
;
if
(
dragEnd
)
{
dragEnd
.
call
(
me
);
}
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
.
on
(
'beforemousemove'
,
function
(
e
)
{
dragTarget
.
trigger
(
'dragend'
);
if
(
lastPosition
)
{
currentPosition
=
e
.
getPosition
();
if
(
e
)
{
// 当前偏移加上历史偏移
e
.
stopPropagation
();
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
currentPosition
);
e
.
preventDefault
();
}
}
}
);
}
if
(
me
instanceof
Paper
)
{
this
.
getRenderContainer
().
translate
(
offset
.
x
,
offset
.
y
);
bindEvents
(
me
);
e
.
stopPropagation
();
}
else
if
(
me
.
getPaper
()
)
{
lastPosition
=
currentPosition
;
bindEvents
(
me
.
getPaper
()
);
}
else
{
var
listener
=
function
(
e
)
{
if
(
e
.
targetShape
.
getPaper
()
)
{
bindEvents
(
e
.
targetShape
.
getPaper
()
);
me
.
off
(
'add'
,
listener
);
me
.
off
(
'treeadd'
,
listener
);
}
};
me
.
on
(
'add treeadd'
,
listener
);
}
}
return
this
;
}
)
},
// end of drag
.
on
(
'mouseup'
,
function
(
e
)
{
lastPosition
=
null
;
undrag
:
function
()
{
// 临时拖动需要还原状态
var
target
=
this
.
dragTarget
;
if
(
isRootDrag
)
{
target
.
off
(
DRAG_START_EVENT
,
target
.
_dragStartHandler
);
dragger
.
setEnabled
(
false
);
target
.
_dragEndHandler
();
isRootDrag
=
false
;
target
.
getPaper
().
off
(
DRAG_END_EVENT
,
target
.
_dragEndHandler
);
}
delete
target
.
_dragStartHandler
;
}
);
delete
target
.
_dragEndHandler
;
}
this
.
dragEnabled
=
false
;
}
);
return
this
;
}
}
);
}
)();
KityMinder
.
registerModule
(
'Hand'
,
function
()
{
KityMinder
.
registerModule
(
'Hand'
,
function
()
{
var
ToggleHandCommand
=
kity
.
createClass
(
"ToggleHandCommand"
,
{
var
ToggleHandCommand
=
kity
.
createClass
(
"ToggleHandCommand"
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
minder
)
{
execute
:
function
(
minder
)
{
var
drag
=
minder
.
_onDragMode
=
!
minder
.
_onDragMode
;
minder
.
_viewDragger
.
setEnabled
(
!
minder
.
_viewDragger
.
isEnabled
()
);
minder
.
getPaper
().
setStyle
(
'cursor'
,
drag
?
'pointer'
:
'default'
);
minder
.
getPaper
().
setStyle
(
'cursor'
,
drag
?
'-webkit-grab'
:
'default'
);
if
(
drag
)
{
minder
.
getPaper
().
drag
();
}
else
{
minder
.
getPaper
().
undrag
();
}
},
},
queryState
:
function
(
minder
)
{
queryState
:
function
(
minder
)
{
return
minder
.
_
onDragMode
?
1
:
0
;
return
minder
.
_
viewDragger
.
isEnabled
()
?
1
:
0
;
}
}
}
);
}
);
return
{
return
{
init
:
function
()
{
init
:
function
()
{
this
.
_onDragMode
=
false
;
this
.
_viewDragger
=
new
ViewDragger
(
this
);
kity
.
extendClass
(
kity
.
Paper
,
kity
.
Draggable
);
},
},
commands
:
{
commands
:
{
'hand'
:
ToggleHandCommand
'hand'
:
ToggleHandCommand
...
@@ -3426,11 +3334,6 @@ KityMinder.registerModule( 'Hand', function () {
...
@@ -3426,11 +3334,6 @@ KityMinder.registerModule( 'Hand', function () {
this
.
execCommand
(
'hand'
);
this
.
execCommand
(
'hand'
);
e
.
preventDefault
();
e
.
preventDefault
();
}
}
},
beforemousemove
:
function
(
e
)
{
if
(
this
.
_onDragMode
)
{
e
.
stopPropagation
();
}
}
}
}
}
};
};
...
@@ -3599,7 +3502,7 @@ var DragBox = kity.createClass( "DragBox", {
...
@@ -3599,7 +3502,7 @@ var DragBox = kity.createClass( "DragBox", {
_drawForDragMode
:
function
()
{
_drawForDragMode
:
function
()
{
this
.
_text
.
setContent
(
this
.
_dragSources
.
length
+
' items'
);
this
.
_text
.
setContent
(
this
.
_dragSources
.
length
+
' items'
);
this
.
_text
.
setPosition
(
this
.
_startPosition
.
x
,
this
.
_startPosition
.
y
+
5
);
this
.
_text
.
setPosition
(
this
.
_startPosition
.
x
,
this
.
_startPosition
.
y
+
5
);
this
.
_minder
.
get
RenderContain
er
().
addShape
(
this
);
this
.
_minder
.
get
Pap
er
().
addShape
(
this
);
},
},
_shrink
:
function
()
{
_shrink
:
function
()
{
// 合并所有拖放源图形的矩形即可
// 合并所有拖放源图形的矩形即可
...
@@ -6875,7 +6778,7 @@ $.wordCountAdaptive = function( word, hasSuffix ) {
...
@@ -6875,7 +6778,7 @@ $.wordCountAdaptive = function( word, hasSuffix ) {
utils
.
extend
(
KityMinder
,
function
()
{
utils
.
extend
(
KityMinder
,
function
()
{
var
_kityminderUI
=
{},
var
_kityminderUI
=
{},
_kityminderToolbarUI
=
{},
_kityminderToolbarUI
=
{},
_activeWidget
=
null
,
_activeWidget
=
null
,
_widgetData
=
{},
_widgetData
=
{},
_widgetCallBack
=
{};
_widgetCallBack
=
{};
...
@@ -6890,9 +6793,9 @@ utils.extend( KityMinder, function () {
...
@@ -6890,9 +6793,9 @@ utils.extend( KityMinder, function () {
_kityminderToolbarUI
[
name
]
=
fn
;
_kityminderToolbarUI
[
name
]
=
fn
;
}
)
}
)
},
},
loadUI
:
function
(
km
)
{
loadUI
:
function
(
km
)
{
utils
.
each
(
_kityminderUI
,
function
(
i
,
fn
)
{
utils
.
each
(
_kityminderUI
,
function
(
i
,
fn
)
{
fn
.
call
(
km
)
fn
.
call
(
km
)
}
)
}
)
},
},
_createUI
:
function
(
id
)
{
_createUI
:
function
(
id
)
{
...
@@ -6943,7 +6846,7 @@ utils.extend( KityMinder, function () {
...
@@ -6943,7 +6846,7 @@ utils.extend( KityMinder, function () {
this
.
_createStatusbar
(
containers
.
$statusbar
,
km
);
this
.
_createStatusbar
(
containers
.
$statusbar
,
km
);
km
.
$container
=
containers
.
$container
;
km
.
$container
=
containers
.
$container
;
this
.
loadUI
(
km
);
this
.
loadUI
(
km
);
return
km
.
fire
(
'interactchange'
);
return
km
.
fire
(
'interactchange'
);
},
},
registerWidget
:
function
(
name
,
pro
,
cb
)
{
registerWidget
:
function
(
name
,
pro
,
cb
)
{
...
@@ -7212,7 +7115,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
...
@@ -7212,7 +7115,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
itemStyles
:
[],
itemStyles
:
[],
value
:
[],
value
:
[],
autowidthitem
:
[],
autowidthitem
:
[],
enabledRecord
:
false
enabledRecord
:
false
},
},
$combox
=
null
,
$combox
=
null
,
comboboxWidget
=
null
;
comboboxWidget
=
null
;
...
@@ -7235,15 +7138,19 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
...
@@ -7235,15 +7138,19 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
)
{
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
)
{
if
(
res
.
value
===
"png"
)
{
if
(
res
.
value
===
"png"
)
{
var
svghtml
=
$
(
"#kityminder .kmui-editor-body"
).
html
();
var
svghtml
=
$
(
"#kityminder .kmui-editor-body"
).
html
();
var
rootBox
=
me
.
getRoot
().
getRenderContainer
().
getRenderBox
();
var
bgImg
=
$
(
"#kityminder .kmui-editor-body"
).
css
(
"backgroundImage"
).
replace
(
/"/g
,
""
).
replace
(
/url
\(
|
\)
$/ig
,
""
);
var
renderBox
=
me
.
getRenderContainer
().
getRenderBox
(
"top"
);
var
renderContainer
=
me
.
getRenderContainer
();
var
transform
=
renderContainer
.
getTransform
();
renderContainer
.
resetTransform
();
var
svg
=
$
(
svghtml
).
attr
(
{
var
svg
=
$
(
svghtml
).
attr
(
{
width
:
r
ootBox
.
x
+
me
.
getRenderContainer
().
getWidth
()
+
20
,
width
:
r
enderBox
.
x
+
renderBox
.
width
,
height
:
r
ootBox
.
y
+
me
.
getRenderContainer
().
getHeight
()
+
20
,
height
:
r
enderBox
.
y
+
renderBox
.
height
,
viewBox
:
null
viewBox
:
null
}
);
}
);
var
div
=
$
(
"<div></div>"
).
append
(
svg
);
var
div
=
$
(
"<div></div>"
).
append
(
svg
);
svghtml
=
div
.
html
();
svghtml
=
div
.
html
();
var
canvas
=
$
(
'<canvas
style="border:2px solid black;" width="'
+
svg
.
attr
(
"width"
)
+
'" height="'
+
svg
.
attr
(
"height"
)
+
'"></canvas>'
);
var
canvas
=
$
(
'<canvas
width="'
+
(
parseInt
(
renderBox
.
width
)
+
40
)
+
'" height="'
+
(
parseInt
(
renderBox
.
height
)
+
40
)
+
'"></canvas>'
);
var
ctx
=
canvas
[
0
].
getContext
(
"2d"
);
var
ctx
=
canvas
[
0
].
getContext
(
"2d"
);
var
DOMURL
=
self
.
URL
||
self
.
webkitURL
||
self
;
var
DOMURL
=
self
.
URL
||
self
.
webkitURL
||
self
;
var
img
=
new
Image
();
var
img
=
new
Image
();
...
@@ -7252,30 +7159,38 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
...
@@ -7252,30 +7159,38 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
}
);
}
);
var
url
=
DOMURL
.
createObjectURL
(
svg
);
var
url
=
DOMURL
.
createObjectURL
(
svg
);
img
.
onload
=
function
()
{
img
.
onload
=
function
()
{
ctx
.
drawImage
(
img
,
0
,
0
);
var
bgTexture
=
document
.
createElement
(
'img'
);
DOMURL
.
revokeObjectURL
(
url
);
bgTexture
.
src
=
bgImg
;
var
type
=
'png'
;
bgTexture
.
onload
=
function
()
{
var
imgData
=
canvas
[
0
].
toDataURL
(
type
);
var
bgfill
=
ctx
.
createPattern
(
bgTexture
,
"repeat"
);
var
_fixType
=
function
(
type
)
{
ctx
.
fillStyle
=
bgfill
;
type
=
type
.
toLowerCase
().
replace
(
/jpg/i
,
'jpeg'
);
ctx
.
fillRect
(
0
,
0
,
renderBox
.
width
+
40
,
renderBox
.
height
+
40
);
var
r
=
type
.
match
(
/png|jpeg|bmp|gif/
)[
0
];
ctx
.
drawImage
(
img
,
-
renderBox
.
x
+
20
,
-
renderBox
.
y
+
20
);
return
'image/'
+
r
;
DOMURL
.
revokeObjectURL
(
url
);
};
var
type
=
'png'
;
imgData
=
imgData
.
replace
(
_fixType
(
type
),
'image/octet-stream'
);
var
imgData
=
canvas
[
0
].
toDataURL
(
type
);
var
saveFile
=
function
(
data
,
filename
)
{
var
_fixType
=
function
(
type
)
{
var
save_link
=
document
.
createElementNS
(
'http://www.w3.org/1999/xhtml'
,
'a'
);
type
=
type
.
toLowerCase
().
replace
(
/jpg/i
,
'jpeg'
);
save_link
.
href
=
data
;
var
r
=
type
.
match
(
/png|jpeg|bmp|gif/
)[
0
];
save_link
.
download
=
filename
;
return
'image/'
+
r
;
};
var
event
=
document
.
createEvent
(
'MouseEvents'
);
imgData
=
imgData
.
replace
(
_fixType
(
type
),
'image/octet-stream'
);
event
.
initMouseEvent
(
'click'
,
true
,
false
,
window
,
0
,
0
,
0
,
0
,
0
,
false
,
false
,
false
,
false
,
0
,
null
);
var
saveFile
=
function
(
data
,
filename
)
{
save_link
.
dispatchEvent
(
event
);
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
;
var
filename
=
'kityminder_'
+
(
new
Date
()
).
getTime
()
+
'.'
+
type
;
// download
// download
saveFile
(
imgData
,
filename
);
saveFile
(
imgData
,
filename
);
renderContainer
.
setTransform
(
transform
);
};
};
};
img
.
src
=
url
;
img
.
src
=
url
;
return
"png"
;
return
"png"
;
...
...
dist/index.html
View file @
bac03aa0
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
<script
src=
"social.js"
charset=
"utf-8"
></script>
<script
src=
"social.js"
charset=
"utf-8"
></script>
<script
src=
"../kity/dist/kitygraph.all.js"
></script>
<script
src=
"../kity/dist/kitygraph.all.js"
></script>
<script
src=
"../configure.js"
></script>
<script
src=
"../configure.js"
></script>
<script
src=
"../dist/dev.
php
"
></script>
<script
src=
"../dist/dev.
js
"
></script>
<script
src=
"../lang/zh-cn/zh-cn.js"
charset=
"utf-8"
></script>
<script
src=
"../lang/zh-cn/zh-cn.js"
charset=
"utf-8"
></script>
<link
href=
"../themes/default/
_
css/import.css"
type=
"text/css"
rel=
"stylesheet"
>
<link
href=
"../themes/default/css/import.css"
type=
"text/css"
rel=
"stylesheet"
>
<style>
<style>
.km_receiver
{
.km_receiver
{
width
:
0
;
width
:
0
;
...
...
kity
@
a9630e63
Subproject commit
7c0498012df602619a38e6b88785a486cd92396d
Subproject commit
a9630e638b29633f62cdc2df239bc702118b231a
src/adapter/saveto.js
View file @
bac03aa0
...
@@ -35,15 +35,17 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
...
@@ -35,15 +35,17 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var
svghtml
=
$
(
"#kityminder .kmui-editor-body"
).
html
();
var
svghtml
=
$
(
"#kityminder .kmui-editor-body"
).
html
();
var
bgImg
=
$
(
"#kityminder .kmui-editor-body"
).
css
(
"backgroundImage"
).
replace
(
/"/g
,
""
).
replace
(
/url
\(
|
\)
$/ig
,
""
);
var
bgImg
=
$
(
"#kityminder .kmui-editor-body"
).
css
(
"backgroundImage"
).
replace
(
/"/g
,
""
).
replace
(
/url
\(
|
\)
$/ig
,
""
);
var
renderBox
=
me
.
getRenderContainer
().
getRenderBox
(
"top"
);
var
renderBox
=
me
.
getRenderContainer
().
getRenderBox
(
"top"
);
//debugger;
var
renderContainer
=
me
.
getRenderContainer
();
var
transform
=
renderContainer
.
getTransform
();
renderContainer
.
resetTransform
();
var
svg
=
$
(
svghtml
).
attr
(
{
var
svg
=
$
(
svghtml
).
attr
(
{
width
:
renderBox
.
x
+
me
.
getRenderContainer
().
getWidth
()
,
width
:
renderBox
.
x
+
renderBox
.
width
,
height
:
renderBox
.
y
+
me
.
getRenderContainer
().
getHeight
()
,
height
:
renderBox
.
y
+
renderBox
.
height
,
viewBox
:
null
viewBox
:
null
}
);
}
);
var
div
=
$
(
"<div></div>"
).
append
(
svg
);
var
div
=
$
(
"<div></div>"
).
append
(
svg
);
svghtml
=
div
.
html
();
svghtml
=
div
.
html
();
var
canvas
=
$
(
'<canvas width="'
+
renderBox
.
width
+
'" height="'
+
renderBox
.
height
+
'"></canvas>'
);
var
canvas
=
$
(
'<canvas width="'
+
(
parseInt
(
renderBox
.
width
)
+
40
)
+
'" height="'
+
(
parseInt
(
renderBox
.
height
)
+
40
)
+
'"></canvas>'
);
var
ctx
=
canvas
[
0
].
getContext
(
"2d"
);
var
ctx
=
canvas
[
0
].
getContext
(
"2d"
);
var
DOMURL
=
self
.
URL
||
self
.
webkitURL
||
self
;
var
DOMURL
=
self
.
URL
||
self
.
webkitURL
||
self
;
var
img
=
new
Image
();
var
img
=
new
Image
();
...
@@ -57,8 +59,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
...
@@ -57,8 +59,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
bgTexture
.
onload
=
function
()
{
bgTexture
.
onload
=
function
()
{
var
bgfill
=
ctx
.
createPattern
(
bgTexture
,
"repeat"
);
var
bgfill
=
ctx
.
createPattern
(
bgTexture
,
"repeat"
);
ctx
.
fillStyle
=
bgfill
;
ctx
.
fillStyle
=
bgfill
;
ctx
.
fillRect
(
0
,
0
,
renderBox
.
width
,
renderBox
.
height
);
ctx
.
fillRect
(
0
,
0
,
renderBox
.
width
+
40
,
renderBox
.
height
+
40
);
ctx
.
drawImage
(
img
,
-
renderBox
.
x
,
-
renderBox
.
y
);
ctx
.
drawImage
(
img
,
-
renderBox
.
x
+
20
,
-
renderBox
.
y
+
20
);
DOMURL
.
revokeObjectURL
(
url
);
DOMURL
.
revokeObjectURL
(
url
);
var
type
=
'png'
;
var
type
=
'png'
;
var
imgData
=
canvas
[
0
].
toDataURL
(
type
);
var
imgData
=
canvas
[
0
].
toDataURL
(
type
);
...
@@ -82,6 +84,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
...
@@ -82,6 +84,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var
filename
=
'kityminder_'
+
(
new
Date
()
).
getTime
()
+
'.'
+
type
;
var
filename
=
'kityminder_'
+
(
new
Date
()
).
getTime
()
+
'.'
+
type
;
// download
// download
saveFile
(
imgData
,
filename
);
saveFile
(
imgData
,
filename
);
renderContainer
.
setTransform
(
transform
);
};
};
};
};
img
.
src
=
url
;
img
.
src
=
url
;
...
...
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