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
739ea841
Commit
739ea841
authored
Nov 03, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unused module
parent
7736f0f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
242 deletions
+0
-242
dropfile.js
src/module/dropfile.js
+0
-107
geometry.js
src/module/geometry.js
+0
-135
No files found.
src/module/dropfile.js
deleted
100644 → 0
View file @
7736f0f5
KityMinder
.
registerModule
(
'DropFile'
,
function
()
{
var
social
,
draftManager
,
importing
=
false
;
function
init
()
{
var
container
=
this
.
getPaper
().
getContainer
();
container
.
addEventListener
(
'dragover'
,
onDragOver
);
container
.
addEventListener
(
'drop'
,
onDrop
.
bind
(
this
));
}
function
onDragOver
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
dataTransfer
.
dropEffect
=
'copy'
;
}
function
onDrop
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
var
minder
=
this
;
if
(
kity
.
Browser
.
ie
&&
Number
(
kity
.
Browser
.
version
)
<
10
)
{
alert
(
'文件导入对 IE 浏览器仅支持 10 以上版本'
);
return
;
}
var
files
=
e
.
dataTransfer
.
files
;
if
(
files
)
{
var
file
=
files
[
0
];
importMinderFile
(
minder
,
file
);
}
}
function
importMinderFile
(
minder
,
file
,
encoding
)
{
if
(
!
file
)
return
;
var
ext
=
/
(
.
)\w
+$/
.
exec
(
file
.
name
);
if
(
!
ext
)
return
alert
(
'不支持导入此类文件!'
);
ext
=
ext
[
0
];
if
((
/xmind/g
).
test
(
ext
))
{
//xmind zip
importSync
(
minder
,
file
,
'xmind'
);
}
else
if
((
/mmap/g
).
test
(
ext
))
{
// mindmanager zip
importSync
(
minder
,
file
,
'mindmanager'
);
}
else
if
((
/mm/g
).
test
(
ext
))
{
//freemind xml
importAsync
(
minder
,
file
,
'freemind'
,
encoding
);
}
else
if
(
/km/
.
test
(
ext
))
{
// txt json
importAsync
(
minder
,
file
,
'json'
,
encoding
);
}
else
if
(
/txt/
.
test
(
ext
))
{
importAsync
(
minder
,
file
,
'plain'
,
encoding
);
}
else
{
alert
(
'不支持导入此类文件!'
);
}
}
function
afterImport
()
{
if
(
!
importing
)
return
;
createDraft
(
this
);
social
.
setRemotePath
(
null
,
false
);
this
.
execCommand
(
'camera'
,
this
.
getRoot
(),
800
);
setTimeout
(
function
()
{
social
.
watchChanges
(
true
);
},
10
);
importing
=
false
;
}
// 同步加载文件
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
,
encoding
)
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
importSync
(
minder
,
e
.
target
.
result
,
protocal
);
};
reader
.
readAsText
(
file
,
encoding
||
'utf8'
);
}
function
createDraft
(
minder
)
{
draftManager
=
window
.
draftManager
||
(
window
.
draftManager
=
new
window
.
DraftManager
(
minder
));
draftManager
.
create
();
}
kity
.
extendClass
(
Minder
,
{
importFile
:
function
(
file
,
encoding
)
{
importMinderFile
(
this
,
file
,
encoding
);
return
this
;
}
});
return
{
events
:
{
'ready'
:
init
,
'import'
:
afterImport
}
};
});
\ No newline at end of file
src/module/geometry.js
deleted
100644 → 0
View file @
7736f0f5
KityMinder
.
Geometry
=
(
function
()
{
var
g
=
{};
var
min
=
Math
.
min
,
max
=
Math
.
max
,
abs
=
Math
.
abs
;
var
own
=
Object
.
prototype
.
hasOwnProperty
;
g
.
isNumberInRange
=
function
(
number
,
range
)
{
return
number
>
range
[
0
]
&&
number
<
range
[
1
];
};
g
.
getDistance
=
function
(
p1
,
p2
)
{
return
kity
.
Vector
.
fromPoints
(
p1
,
p2
).
length
();
};
function
wrapBox
(
box
)
{
box
.
width
=
box
.
right
-
box
.
left
;
box
.
height
=
box
.
bottom
-
box
.
top
;
box
.
x
=
box
.
left
;
box
.
y
=
box
.
top
;
box
.
cx
=
box
.
x
+
box
.
width
/
2
;
box
.
cy
=
box
.
y
+
box
.
height
/
2
;
return
box
;
}
function
uniformBox
(
box
)
{
// duck check
if
(
'x'
in
box
)
{
box
.
left
=
box
.
x
;
box
.
right
=
box
.
x
+
box
.
width
;
box
.
top
=
box
.
y
;
box
.
bottom
=
box
.
y
+
box
.
height
;
}
}
g
.
wrapBox
=
wrapBox
;
g
.
getBox
=
function
(
p1
,
p2
)
{
return
wrapBox
({
left
:
min
(
p1
.
x
,
p2
.
x
),
right
:
max
(
p1
.
x
,
p2
.
x
),
top
:
min
(
p1
.
y
,
p2
.
y
),
bottom
:
max
(
p1
.
y
,
p2
.
y
)
});
};
g
.
mergeBox
=
function
(
b1
,
b2
)
{
uniformBox
(
b1
);
uniformBox
(
b2
);
return
wrapBox
({
left
:
min
(
b1
.
left
,
b2
.
left
),
right
:
max
(
b1
.
right
,
b2
.
right
),
top
:
min
(
b1
.
top
,
b2
.
top
),
bottom
:
max
(
b1
.
bottom
,
b2
.
bottom
)
});
};
g
.
getBoxRange
=
function
(
box
)
{
return
{
x
:
[
box
.
left
,
box
.
right
],
y
:
[
box
.
top
,
box
.
bottom
]
};
};
g
.
getBoxVertex
=
function
(
box
)
{
return
{
leftTop
:
{
x
:
box
.
left
,
y
:
box
.
top
},
rightTop
:
{
x
:
box
.
right
,
y
:
box
.
top
},
leftBottom
:
{
x
:
box
.
left
,
y
:
box
.
bottom
},
rightBottom
:
{
x
:
box
.
right
,
y
:
box
.
bottom
}
};
};
g
.
isPointInsideBox
=
function
(
p
,
b
)
{
uniformBox
(
b
);
var
ranges
=
g
.
getBoxRange
(
b
);
return
g
.
isNumberInRange
(
p
.
x
,
ranges
.
x
)
&&
g
.
isNumberInRange
(
p
.
y
,
ranges
.
y
);
};
g
.
getIntersectBox
=
function
(
b1
,
b2
)
{
uniformBox
(
b1
);
uniformBox
(
b2
);
var
minx
=
max
(
b1
.
left
,
b2
.
left
),
miny
=
max
(
b1
.
top
,
b2
.
top
),
maxx
=
min
(
b1
.
right
,
b2
.
right
),
maxy
=
min
(
b1
.
bottom
,
b2
.
bottom
);
return
minx
<
maxx
&&
miny
<
maxy
?
wrapBox
({
left
:
minx
,
right
:
maxx
,
top
:
miny
,
bottom
:
maxy
})
:
null
;
};
g
.
snapToSharp
=
function
(
unknown
)
{
if
(
utils
.
isNumber
(
unknown
))
{
return
(
unknown
|
0
)
+
0.5
;
}
if
(
utils
.
isArray
(
unknown
))
{
return
unknown
.
map
(
g
.
snapToSharp
);
}
[
'x'
,
'y'
,
'left'
,
'top'
,
'right'
,
'bottom'
].
forEach
(
function
(
n
)
{
if
(
own
.
call
(
unknown
,
n
))
{
unknown
[
n
]
=
g
.
snapToSharp
(
unknown
[
n
]);
}
});
return
unknown
;
};
g
.
expandBox
=
function
(
box
,
sizeX
,
sizeY
)
{
if
(
sizeY
===
undefined
)
{
sizeY
=
sizeX
;
}
return
wrapBox
({
left
:
box
.
left
-
sizeX
,
top
:
box
.
top
-
sizeY
,
right
:
box
.
right
+
sizeX
,
bottom
:
box
.
bottom
+
sizeY
});
};
return
g
;
})();
\ 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