Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
bbcde74c
Commit
bbcde74c
authored
Sep 12, 2015
by
Van
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kind editor upload image
parent
357589ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
323 additions
and
310 deletions
+323
-310
war/src/main/webapp/js/admin/editorKindEditor.js
war/src/main/webapp/js/admin/editorKindEditor.js
+1
-0
war/src/main/webapp/js/lib/KindEditor/plugins/image/image.js
war/src/main/webapp/js/lib/KindEditor/plugins/image/image.js
+322
-310
No files found.
war/src/main/webapp/js/admin/editorKindEditor.js
View file @
bbcde74c
...
@@ -50,6 +50,7 @@ admin.editors.KindEditor = {
...
@@ -50,6 +50,7 @@ admin.editors.KindEditor = {
}
else
{
}
else
{
try
{
try
{
this
[
conf
.
id
]
=
KindEditor
.
create
(
'
#
'
+
conf
.
id
,
{
this
[
conf
.
id
]
=
KindEditor
.
create
(
'
#
'
+
conf
.
id
,
{
'
uploadJson
'
:
'
kindeditor/php/upyunUpload.php
'
,
langType
:
language
,
langType
:
language
,
items
:
[
"
formatblock
"
,
"
fontname
"
,
"
fontsize
"
,
"
|
"
,
"
bold
"
,
"
italic
"
,
"
underline
"
,
"
strikethrough
"
,
"
forecolor
"
,
"
|
"
,
items
:
[
"
formatblock
"
,
"
fontname
"
,
"
fontsize
"
,
"
|
"
,
"
bold
"
,
"
italic
"
,
"
underline
"
,
"
strikethrough
"
,
"
forecolor
"
,
"
|
"
,
"
link
"
,
"
unlink
"
,
"
image
"
,
"
media
"
,
"
|
"
,
"
pagebreak
"
,
"
emoticons
"
,
"
code
"
,
"
/
"
,
"
link
"
,
"
unlink
"
,
"
image
"
,
"
media
"
,
"
|
"
,
"
pagebreak
"
,
"
emoticons
"
,
"
code
"
,
"
/
"
,
...
...
war/src/main/webapp/js/lib/KindEditor/plugins/image/image.js
View file @
bbcde74c
/*******************************************************************************
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
* Copyright (C) 2006-2011 kindsoft.net
*
*
* @author Roddy <luolonghao@gmail.com>
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
*******************************************************************************/
KindEditor
.
plugin
(
'
image
'
,
function
(
K
)
{
KindEditor
.
plugin
(
'
image
'
,
function
(
K
)
{
var
self
=
this
,
name
=
'
image
'
,
var
self
=
this
,
name
=
'
image
'
,
allowImageUpload
=
K
.
undef
(
self
.
allowImageUpload
,
true
),
allowImageUpload
=
K
.
undef
(
self
.
allowImageUpload
,
true
),
allowImageRemote
=
K
.
undef
(
self
.
allowImageRemote
,
true
),
formatUploadUrl
=
K
.
undef
(
self
.
formatUploadUrl
,
true
),
formatUploadUrl
=
K
.
undef
(
self
.
formatUploadUrl
,
true
),
allowFileManager
=
K
.
undef
(
self
.
allowFileManager
,
false
),
allowFileManager
=
K
.
undef
(
self
.
allowFileManager
,
false
),
uploadJson
=
K
.
undef
(
self
.
uploadJson
,
self
.
basePath
+
'
php/upload_json.php
'
),
uploadJson
=
K
.
undef
(
self
.
uploadJson
,
self
.
basePath
+
'
php/upload_json.php
'
),
...
@@ -20,7 +21,7 @@ KindEditor.plugin('image', function(K) {
...
@@ -20,7 +21,7 @@ KindEditor.plugin('image', function(K) {
fillDescAfterUploadImage
=
K
.
undef
(
self
.
fillDescAfterUploadImage
,
false
),
fillDescAfterUploadImage
=
K
.
undef
(
self
.
fillDescAfterUploadImage
,
false
),
lang
=
self
.
lang
(
name
+
'
.
'
);
lang
=
self
.
lang
(
name
+
'
.
'
);
self
.
plugin
.
imageDialog
=
function
(
options
)
{
self
.
plugin
.
imageDialog
=
function
(
options
)
{
var
imageUrl
=
options
.
imageUrl
,
var
imageUrl
=
options
.
imageUrl
,
imageWidth
=
K
.
undef
(
options
.
imageWidth
,
''
),
imageWidth
=
K
.
undef
(
options
.
imageWidth
,
''
),
imageHeight
=
K
.
undef
(
options
.
imageHeight
,
''
),
imageHeight
=
K
.
undef
(
options
.
imageHeight
,
''
),
...
@@ -32,7 +33,7 @@ KindEditor.plugin('image', function(K) {
...
@@ -32,7 +33,7 @@ KindEditor.plugin('image', function(K) {
clickFn
=
options
.
clickFn
;
clickFn
=
options
.
clickFn
;
var
target
=
'
kindeditor_upload_iframe_
'
+
new
Date
().
getTime
();
var
target
=
'
kindeditor_upload_iframe_
'
+
new
Date
().
getTime
();
var
hiddenElements
=
[];
var
hiddenElements
=
[];
for
(
var
k
in
extraParams
)
{
for
(
var
k
in
extraParams
)
{
hiddenElements
.
push
(
'
<input type="hidden" name="
'
+
k
+
'
" value="
'
+
extraParams
[
k
]
+
'
" />
'
);
hiddenElements
.
push
(
'
<input type="hidden" name="
'
+
k
+
'
" value="
'
+
extraParams
[
k
]
+
'
" />
'
);
}
}
var
html
=
[
var
html
=
[
...
@@ -89,14 +90,14 @@ KindEditor.plugin('image', function(K) {
...
@@ -89,14 +90,14 @@ KindEditor.plugin('image', function(K) {
var
dialogWidth
=
showLocal
||
allowFileManager
?
450
:
400
,
var
dialogWidth
=
showLocal
||
allowFileManager
?
450
:
400
,
dialogHeight
=
showLocal
&&
showRemote
?
300
:
250
;
dialogHeight
=
showLocal
&&
showRemote
?
300
:
250
;
var
dialog
=
self
.
createDialog
({
var
dialog
=
self
.
createDialog
({
name
:
name
,
name
:
name
,
width
:
dialogWidth
,
width
:
dialogWidth
,
height
:
dialogHeight
,
height
:
dialogHeight
,
title
:
self
.
lang
(
name
),
title
:
self
.
lang
(
name
),
body
:
html
,
body
:
html
,
yesBtn
:
{
yesBtn
:
{
name
:
self
.
lang
(
'
yes
'
),
name
:
self
.
lang
(
'
yes
'
),
click
:
function
(
e
)
{
click
:
function
(
e
)
{
// Bugfix: http://code.google.com/p/kindeditor/issues/detail?id=319
// Bugfix: http://code.google.com/p/kindeditor/issues/detail?id=319
if
(
dialog
.
isLoading
)
{
if
(
dialog
.
isLoading
)
{
return
;
return
;
...
@@ -118,7 +119,7 @@ KindEditor.plugin('image', function(K) {
...
@@ -118,7 +119,7 @@ KindEditor.plugin('image', function(K) {
height
=
heightBox
.
val
(),
height
=
heightBox
.
val
(),
title
=
titleBox
.
val
(),
title
=
titleBox
.
val
(),
align
=
''
;
align
=
''
;
alignBox
.
each
(
function
()
{
alignBox
.
each
(
function
()
{
if
(
this
.
checked
)
{
if
(
this
.
checked
)
{
align
=
this
.
value
;
align
=
this
.
value
;
return
false
;
return
false
;
...
@@ -142,7 +143,7 @@ KindEditor.plugin('image', function(K) {
...
@@ -142,7 +143,7 @@ KindEditor.plugin('image', function(K) {
clickFn
.
call
(
self
,
url
,
title
,
width
,
height
,
0
,
align
);
clickFn
.
call
(
self
,
url
,
title
,
width
,
height
,
0
,
align
);
}
}
},
},
beforeRemove
:
function
()
{
beforeRemove
:
function
()
{
viewServerBtn
.
unbind
();
viewServerBtn
.
unbind
();
widthBox
.
unbind
();
widthBox
.
unbind
();
heightBox
.
unbind
();
heightBox
.
unbind
();
...
@@ -163,17 +164,17 @@ KindEditor.plugin('image', function(K) {
...
@@ -163,17 +164,17 @@ KindEditor.plugin('image', function(K) {
var
tabs
;
var
tabs
;
if
(
showRemote
&&
showLocal
)
{
if
(
showRemote
&&
showLocal
)
{
tabs
=
K
.
tabs
({
tabs
=
K
.
tabs
({
src
:
K
(
'
.tabs
'
,
div
),
src
:
K
(
'
.tabs
'
,
div
),
afterSelect
:
function
(
i
)
{}
afterSelect
:
function
(
i
)
{}
});
});
tabs
.
add
({
tabs
.
add
({
title
:
lang
.
remoteImage
,
title
:
lang
.
remoteImage
,
panel
:
K
(
'
.tab1
'
,
div
)
panel
:
K
(
'
.tab1
'
,
div
)
});
tabs
.
add
({
title
:
lang
.
localImage
,
panel
:
K
(
'
.tab2
'
,
div
)
});
});
// tabs.add({
// title : lang.localImage,
// panel : K('.tab2', div)
// });
tabs
.
select
(
tabIndex
);
tabs
.
select
(
tabIndex
);
}
else
if
(
showRemote
)
{
}
else
if
(
showRemote
)
{
K
(
'
.tab1
'
,
div
).
show
();
K
(
'
.tab1
'
,
div
).
show
();
...
@@ -182,13 +183,12 @@ KindEditor.plugin('image', function(K) {
...
@@ -182,13 +183,12 @@ KindEditor.plugin('image', function(K) {
}
}
var
uploadbutton
=
K
.
uploadbutton
({
var
uploadbutton
=
K
.
uploadbutton
({
button
:
K
(
'
.ke-upload-button
'
,
div
)[
0
],
button
:
K
(
'
.ke-upload-button
'
,
div
)[
0
],
fieldName
:
filePostName
,
fieldName
:
filePostName
,
url
:
K
.
addParam
(
uploadJson
,
'
dir=image
'
),
form
:
K
(
'
.ke-form
'
,
div
),
form
:
K
(
'
.ke-form
'
,
div
),
target
:
target
,
target
:
target
,
width
:
60
,
width
:
60
,
afterUpload
:
function
(
data
)
{
afterUpload
:
function
(
data
)
{
dialog
.
hideLoading
();
dialog
.
hideLoading
();
if
(
data
.
error
===
0
)
{
if
(
data
.
error
===
0
)
{
var
url
=
data
.
url
;
var
url
=
data
.
url
;
...
@@ -209,21 +209,21 @@ KindEditor.plugin('image', function(K) {
...
@@ -209,21 +209,21 @@ KindEditor.plugin('image', function(K) {
alert
(
data
.
message
);
alert
(
data
.
message
);
}
}
},
},
afterError
:
function
(
html
)
{
afterError
:
function
(
html
)
{
dialog
.
hideLoading
();
dialog
.
hideLoading
();
self
.
errorDialog
(
html
);
self
.
errorDialog
(
html
);
}
}
});
});
uploadbutton
.
fileBox
.
change
(
function
(
e
)
{
uploadbutton
.
fileBox
.
change
(
function
(
e
)
{
localUrlBox
.
val
(
uploadbutton
.
fileBox
.
val
());
localUrlBox
.
val
(
uploadbutton
.
fileBox
.
val
());
});
});
if
(
allowFileManager
)
{
if
(
allowFileManager
)
{
viewServerBtn
.
click
(
function
(
e
)
{
viewServerBtn
.
click
(
function
(
e
)
{
self
.
loadPlugin
(
'
filemanager
'
,
function
()
{
self
.
loadPlugin
(
'
filemanager
'
,
function
()
{
self
.
plugin
.
filemanagerDialog
({
self
.
plugin
.
filemanagerDialog
({
viewType
:
'
VIEW
'
,
viewType
:
'
VIEW
'
,
dirName
:
'
image
'
,
dirName
:
'
image
'
,
clickFn
:
function
(
url
,
title
)
{
clickFn
:
function
(
url
,
title
)
{
if
(
self
.
dialogs
.
length
>
1
)
{
if
(
self
.
dialogs
.
length
>
1
)
{
K
(
'
[name="url"]
'
,
div
).
val
(
url
);
K
(
'
[name="url"]
'
,
div
).
val
(
url
);
if
(
self
.
afterSelectFile
)
{
if
(
self
.
afterSelectFile
)
{
...
@@ -245,25 +245,25 @@ KindEditor.plugin('image', function(K) {
...
@@ -245,25 +245,25 @@ KindEditor.plugin('image', function(K) {
originalWidth
=
width
;
originalWidth
=
width
;
originalHeight
=
height
;
originalHeight
=
height
;
}
}
refreshBtn
.
click
(
function
(
e
)
{
refreshBtn
.
click
(
function
(
e
)
{
var
tempImg
=
K
(
'
<img src="
'
+
urlBox
.
val
()
+
'
" />
'
,
document
).
css
({
var
tempImg
=
K
(
'
<img src="
'
+
urlBox
.
val
()
+
'
" />
'
,
document
).
css
({
position
:
'
absolute
'
,
position
:
'
absolute
'
,
visibility
:
'
hidden
'
,
visibility
:
'
hidden
'
,
top
:
0
,
top
:
0
,
left
:
'
-1000px
'
left
:
'
-1000px
'
});
});
tempImg
.
bind
(
'
load
'
,
function
()
{
tempImg
.
bind
(
'
load
'
,
function
()
{
setSize
(
tempImg
.
width
(),
tempImg
.
height
());
setSize
(
tempImg
.
width
(),
tempImg
.
height
());
tempImg
.
remove
();
tempImg
.
remove
();
});
});
K
(
document
.
body
).
append
(
tempImg
);
K
(
document
.
body
).
append
(
tempImg
);
});
});
widthBox
.
change
(
function
(
e
)
{
widthBox
.
change
(
function
(
e
)
{
if
(
originalWidth
>
0
)
{
if
(
originalWidth
>
0
)
{
heightBox
.
val
(
Math
.
round
(
originalHeight
/
originalWidth
*
parseInt
(
this
.
value
,
10
)));
heightBox
.
val
(
Math
.
round
(
originalHeight
/
originalWidth
*
parseInt
(
this
.
value
,
10
)));
}
}
});
});
heightBox
.
change
(
function
(
e
)
{
heightBox
.
change
(
function
(
e
)
{
if
(
originalHeight
>
0
)
{
if
(
originalHeight
>
0
)
{
widthBox
.
val
(
Math
.
round
(
originalWidth
/
originalHeight
*
parseInt
(
this
.
value
,
10
)));
widthBox
.
val
(
Math
.
round
(
originalWidth
/
originalHeight
*
parseInt
(
this
.
value
,
10
)));
}
}
...
@@ -271,45 +271,57 @@ KindEditor.plugin('image', function(K) {
...
@@ -271,45 +271,57 @@ KindEditor.plugin('image', function(K) {
urlBox
.
val
(
options
.
imageUrl
);
urlBox
.
val
(
options
.
imageUrl
);
setSize
(
options
.
imageWidth
,
options
.
imageHeight
);
setSize
(
options
.
imageWidth
,
options
.
imageHeight
);
titleBox
.
val
(
options
.
imageTitle
);
titleBox
.
val
(
options
.
imageTitle
);
alignBox
.
each
(
function
()
{
alignBox
.
each
(
function
()
{
if
(
this
.
value
===
options
.
imageAlign
)
{
if
(
this
.
value
===
options
.
imageAlign
)
{
this
.
checked
=
true
;
this
.
checked
=
true
;
return
false
;
return
false
;
}
}
});
});
if
(
tabIndex
===
0
)
{
if
(
showRemote
&&
tabIndex
===
0
)
{
urlBox
[
0
].
focus
();
urlBox
[
0
].
focus
();
urlBox
[
0
].
select
();
urlBox
[
0
].
select
();
}
}
return
dialog
;
return
dialog
;
};
};
self
.
plugin
.
image
=
{
self
.
plugin
.
image
=
{
edit
:
function
()
{
edit
:
function
()
{
var
img
=
self
.
plugin
.
getSelectedImage
();
var
img
=
self
.
plugin
.
getSelectedImage
();
self
.
plugin
.
imageDialog
({
self
.
plugin
.
imageDialog
({
imageUrl
:
img
?
img
.
attr
(
'
data-ke-src
'
)
:
'
http://
'
,
imageUrl
:
img
?
img
.
attr
(
'
data-ke-src
'
)
:
'
http://
'
,
imageWidth
:
img
?
img
.
width
()
:
''
,
imageWidth
:
img
?
img
.
width
()
:
''
,
imageHeight
:
img
?
img
.
height
()
:
''
,
imageHeight
:
img
?
img
.
height
()
:
''
,
imageTitle
:
img
?
img
.
attr
(
'
title
'
)
:
''
,
imageTitle
:
img
?
img
.
attr
(
'
title
'
)
:
''
,
imageAlign
:
img
?
img
.
attr
(
'
align
'
)
:
''
,
imageAlign
:
img
?
img
.
attr
(
'
align
'
)
:
''
,
showRemote
:
tru
e
,
showRemote
:
allowImageRemot
e
,
showLocal
:
allowImageUpload
,
showLocal
:
allowImageUpload
,
tabIndex
:
img
?
0
:
imageTabIndex
,
tabIndex
:
img
?
0
:
imageTabIndex
,
clickFn
:
function
(
url
,
title
,
width
,
height
,
border
,
align
)
{
clickFn
:
function
(
url
,
title
,
width
,
height
,
border
,
align
)
{
if
(
img
)
{
img
.
attr
(
'
src
'
,
url
);
img
.
attr
(
'
data-ke-src
'
,
url
);
img
.
attr
(
'
width
'
,
width
);
img
.
attr
(
'
height
'
,
height
);
img
.
attr
(
'
title
'
,
title
);
img
.
attr
(
'
align
'
,
align
);
img
.
attr
(
'
alt
'
,
title
);
}
else
{
self
.
exec
(
'
insertimage
'
,
url
,
title
,
width
,
height
,
border
,
align
);
self
.
exec
(
'
insertimage
'
,
url
,
title
,
width
,
height
,
border
,
align
);
}
// Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog
// Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog
setTimeout
(
function
()
{
setTimeout
(
function
()
{
self
.
hideDialog
().
focus
();
self
.
hideDialog
().
focus
();
},
0
);
},
0
);
}
}
});
});
},
},
'
delete
'
:
function
()
{
'
delete
'
:
function
()
{
var
target
=
self
.
plugin
.
getSelectedImage
();
var
target
=
self
.
plugin
.
getSelectedImage
();
if
(
target
.
parent
().
name
==
'
a
'
)
{
if
(
target
.
parent
().
name
==
'
a
'
)
{
target
=
target
.
parent
();
target
=
target
.
parent
();
}
}
target
.
remove
();
target
.
remove
();
// [IE] 删除图片后立即点击图片按钮出错
self
.
addBookmark
();
}
}
};
};
self
.
clickToolbar
(
name
,
self
.
plugin
.
image
.
edit
);
self
.
clickToolbar
(
name
,
self
.
plugin
.
image
.
edit
);
...
...
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