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
324bfbc2
Commit
324bfbc2
authored
Apr 11, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Issue #39] 修复草稿箱和社会化文件名不同步的问题
parent
77a99609
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
23 deletions
+40
-23
social.js
social/social.js
+7
-1
dropfile.js
src/module/dropfile.js
+33
-22
No files found.
social/social.js
View file @
324bfbc2
...
...
@@ -77,7 +77,7 @@ $( function () {
// 脑图实例
minder
=
window
.
km
,
// 草稿箱
draftManager
=
window
.
draftManager
||
new
window
.
DraftManager
(
minder
),
draftManager
=
window
.
draftManager
||
(
window
.
draftManager
=
new
window
.
DraftManager
(
minder
)
),
// 当前是否要检测文档内容是否变化的开关
watchingChanges
=
true
,
...
...
@@ -681,4 +681,10 @@ $( function () {
return
"很久之前"
;
}
window
.
social
=
{
setRemotePath
:
setRemotePath
,
watchChanges
:
function
(
value
)
{
watchingChanges
=
value
;
}
};
}
);
\ No newline at end of file
src/module/dropfile.js
View file @
324bfbc2
KityMinder
.
registerModule
(
"DropFile"
,
function
()
{
var
social
,
draftManager
,
importing
=
false
;
function
init
()
{
var
container
=
this
.
getPaper
().
getContainer
();
container
.
addEventListener
(
'dragover'
,
onDragOver
);
...
...
@@ -20,51 +24,58 @@ KityMinder.registerModule( "DropFile", function () {
var
files
=
e
.
dataTransfer
.
files
;
if
(
files
)
{
var
file
=
files
[
0
];
var
ext
=
file
.
type
||
(
/
(
.
)\w
+$/
).
exec
(
file
.
name
)[
0
];
var
file
=
files
[
0
];
var
ext
=
file
.
type
||
(
/
(
.
)\w
+$/
).
exec
(
file
.
name
)[
0
];
if
(
(
/xmind/g
).
test
(
ext
)
)
{
//xmind zip
if
(
(
/xmind/g
).
test
(
ext
)
)
{
//xmind zip
importSync
(
minder
,
file
,
'xmind'
);
}
else
if
(
(
/mmap/g
).
test
(
ext
)
)
{
// mindmanager zip
}
else
if
(
(
/mmap/g
).
test
(
ext
)
)
{
// mindmanager zip
importSync
(
minder
,
file
,
'mindmanager'
);
}
else
if
(
(
/mm/g
).
test
(
ext
)
)
{
//freemind xml
}
else
if
(
(
/mm/g
).
test
(
ext
)
)
{
//freemind xml
importAsync
(
minder
,
file
,
'freemind'
);
}
else
{
// txt json
}
else
{
// txt json
importAsync
(
minder
,
file
);
}
}
}
function
afterImport
()
{
if
(
!
importing
)
return
;
createDraft
(
this
);
social
.
setRemotePath
(
null
,
false
);
this
.
execCommand
(
'camera'
,
this
.
getRoot
()
);
setTimeout
(
function
()
{
social
.
watchChanges
(
true
);
},
10
);
importing
=
false
;
}
// 同步加载文件
function
importSync
(
minder
,
file
,
protocal
){
minder
.
importData
(
file
,
protocal
);
//zip文件的import是同步的
manageDraft
(
minder
);
minder
.
execCommand
(
'camera'
,
minder
.
getRoot
()
);
function
importSync
(
minder
,
file
,
protocal
)
{
social
=
social
||
window
.
social
;
social
.
watchChanges
(
false
);
importing
=
true
;
minder
.
importData
(
file
,
protocal
);
//zip文件的import是同步的
}
// 异步加载文件
function
importAsync
(
minder
,
file
,
protocal
){
function
importAsync
(
minder
,
file
,
protocal
)
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
minder
.
importData
(
e
.
target
.
result
,
protocal
);
//纯文本文件的import是同步的
manageDraft
(
minder
);
minder
.
execCommand
(
'camera'
,
minder
.
getRoot
()
);
importSync
(
minder
,
e
.
target
.
result
,
protocal
);
};
reader
.
readAsText
(
file
);
}
function
manageDraft
(
minder
){
if
(
!
window
.
draftManager
){
window
.
draftManager
=
new
window
.
DraftManager
(
minder
);
}
window
.
draftManager
.
create
();
function
createDraft
(
minder
)
{
draftManager
=
window
.
draftManager
;
draftManager
.
create
();
}
return
{
events
:
{
ready
:
init
'ready'
:
init
,
'import'
:
afterImport
}
};
}
);
\ 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