Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
149354e4
Commit
149354e4
authored
Nov 07, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
头像上传和修改
parent
b93703bd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
262 additions
and
56 deletions
+262
-56
src/main/webapp/WEB-INF/common/_container.html
+1
-0
src/main/webapp/WEB-INF/system/user/user_view.html
+0
-0
src/main/webapp/assets/common/plugins/cropper/cropper.jquery.min.js
+11
-0
src/main/webapp/assets/modular/system/user/user_view.js
+250
-56
No files found.
src/main/webapp/WEB-INF/common/_container.html
View file @
149354e4
...
@@ -165,6 +165,7 @@
...
@@ -165,6 +165,7 @@
@}
@}
@if(array.contain(plugins,"cropper")){
@if(array.contain(plugins,"cropper")){
<script
src=
"${ctxPath}/assets/common/plugins/cropper/cropper.min.js"
></script>
<script
src=
"${ctxPath}/assets/common/plugins/cropper/cropper.min.js"
></script>
<script
src=
"${ctxPath}/assets/common/plugins/cropper/cropper.jquery.min.js"
></script>
@}
@}
@}
@}
...
...
src/main/webapp/WEB-INF/system/user/user_view.html
View file @
149354e4
This diff is collapsed.
Click to expand it.
src/main/webapp/assets/common/plugins/cropper/cropper.jquery.min.js
0 → 100644
View file @
149354e4
/*!
* jQuery Cropper v1.0.0
* https://github.com/fengyuanchen/jquery-cropper
*
* Copyright (c) 2018 Chen Fengyuan
* Released under the MIT license
*
* Date: 2018-04-01T06:20:13.168Z
*/
!
function
(
e
,
r
){
"object"
==
typeof
exports
&&
"undefined"
!=
typeof
module
?
r
(
require
(
"jquery"
),
require
(
"cropperjs"
)):
"function"
==
typeof
define
&&
define
.
amd
?
define
([
"jquery"
,
"cropperjs"
],
r
):
r
(
e
.
jQuery
,
e
.
Cropper
)}(
this
,
function
(
c
,
s
){
"use strict"
;
if
(
c
=
c
&&
c
.
hasOwnProperty
(
"default"
)?
c
.
default
:
c
,
s
=
s
&&
s
.
hasOwnProperty
(
"default"
)?
s
.
default
:
s
,
c
.
fn
){
var
e
=
c
.
fn
.
cropper
,
d
=
"cropper"
;
c
.
fn
.
cropper
=
function
(
p
){
for
(
var
e
=
arguments
.
length
,
a
=
Array
(
1
<
e
?
e
-
1
:
0
),
r
=
1
;
r
<
e
;
r
++
)
a
[
r
-
1
]
=
arguments
[
r
];
var
u
=
void
0
;
return
this
.
each
(
function
(
e
,
r
){
var
t
=
c
(
r
),
n
=
"destroy"
===
p
,
o
=
t
.
data
(
d
);
if
(
!
o
){
if
(
n
)
return
;
var
f
=
c
.
extend
({},
t
.
data
(),
c
.
isPlainObject
(
p
)
&&
p
);
o
=
new
s
(
r
,
f
),
t
.
data
(
d
,
o
)}
if
(
"string"
==
typeof
p
){
var
i
=
o
[
p
];
c
.
isFunction
(
i
)
&&
((
u
=
i
.
apply
(
o
,
a
))
===
o
&&
(
u
=
void
0
),
n
&&
t
.
removeData
(
d
))}}),
void
0
!==
u
?
u
:
this
},
c
.
fn
.
cropper
.
Constructor
=
s
,
c
.
fn
.
cropper
.
setDefaults
=
s
.
setDefaults
,
c
.
fn
.
cropper
.
noConflict
=
function
(){
return
c
.
fn
.
cropper
=
e
,
this
}}});
\ No newline at end of file
src/main/webapp/assets/modular/system/user/user_view.js
View file @
149354e4
/**
$
(
function
()
{
* 用户详情对话框(可用于添加和修改对话框)
'use strict'
;
*/
var
UserViewPage
=
{
data
:
{
id
:
""
,
account
:
""
,
sex
:
""
,
password
:
""
,
rePassword
:
""
,
avatar
:
""
,
email
:
""
,
name
:
""
,
birthday
:
""
,
deptid
:
""
,
deptName
:
""
,
phone
:
""
}
};
/**
* 关闭此对话框
*/
UserViewPage
.
close
=
function
()
{
};
var
console
=
window
.
console
||
{
log
:
function
()
{}
};
var
URL
=
window
.
URL
||
window
.
webkitURL
;
var
$image
=
$
(
'#image'
);
var
$download
=
$
(
'#download'
);
var
$dataX
=
$
(
'#dataX'
);
var
$dataY
=
$
(
'#dataY'
);
var
$dataHeight
=
$
(
'#dataHeight'
);
var
$dataWidth
=
$
(
'#dataWidth'
);
var
$dataRotate
=
$
(
'#dataRotate'
);
var
$dataScaleX
=
$
(
'#dataScaleX'
);
var
$dataScaleY
=
$
(
'#dataScaleY'
);
var
options
=
{
aspectRatio
:
16
/
9
,
preview
:
'.img-preview'
,
crop
:
function
(
e
)
{
$dataX
.
val
(
Math
.
round
(
e
.
detail
.
x
));
$dataY
.
val
(
Math
.
round
(
e
.
detail
.
y
));
$dataHeight
.
val
(
Math
.
round
(
e
.
detail
.
height
));
$dataWidth
.
val
(
Math
.
round
(
e
.
detail
.
width
));
$dataRotate
.
val
(
e
.
detail
.
rotate
);
$dataScaleX
.
val
(
e
.
detail
.
scaleX
);
$dataScaleY
.
val
(
e
.
detail
.
scaleY
);
}
};
var
originalImageURL
=
$image
.
attr
(
'src'
);
var
uploadedImageName
=
'cropped.jpg'
;
var
uploadedImageType
=
'image/jpeg'
;
var
uploadedImageURL
;
/**
// Tooltip
* 验证表单
$
(
'[data-toggle="tooltip"]'
).
tooltip
();
*/
UserViewPage
.
validateForm
=
function
()
{
var
data
=
UserViewPage
.
data
;
// Cropper
$image
.
on
({
ready
:
function
(
e
)
{
console
.
log
(
e
.
type
);
},
cropstart
:
function
(
e
)
{
console
.
log
(
e
.
type
,
e
.
detail
.
action
);
},
cropmove
:
function
(
e
)
{
console
.
log
(
e
.
type
,
e
.
detail
.
action
);
},
cropend
:
function
(
e
)
{
console
.
log
(
e
.
type
,
e
.
detail
.
action
);
},
crop
:
function
(
e
)
{
console
.
log
(
e
.
type
);
},
zoom
:
function
(
e
)
{
console
.
log
(
e
.
type
,
e
.
detail
.
ratio
);
}
}).
cropper
(
options
);
if
(
data
.
account
&&
data
.
password
&&
data
.
name
&&
data
.
deptid
)
{
// Buttons
return
true
;
if
(
!
$
.
isFunction
(
document
.
createElement
(
'canvas'
).
getContext
))
{
$
(
'button[data-method="getCroppedCanvas"]'
).
prop
(
'disabled'
,
true
);
}
}
if
(
!
data
.
account
)
{
if
(
typeof
document
.
createElement
(
'cropper'
).
style
.
transition
===
'undefined'
)
{
return
"请输入账号"
;
$
(
'button[data-method="rotate"]'
).
prop
(
'disabled'
,
true
);
}
$
(
'button[data-method="scale"]'
).
prop
(
'disabled'
,
true
);
if
(
!
(
data
.
password
===
data
.
rePassword
))
{
return
"两次密码输入不一致"
;
}
if
(
!
data
.
name
)
{
return
"请输入姓名"
;
}
}
if
(
!
data
.
deptid
)
{
return
"请选择部门"
;
// Download
if
(
typeof
$download
[
0
].
download
===
'undefined'
)
{
$download
.
addClass
(
'disabled'
);
}
}
};
$
(
function
()
{
// Options
$
(
'.docs-toggles'
).
on
(
'change'
,
'input'
,
function
()
{
var
$this
=
$
(
this
);
var
name
=
$this
.
attr
(
'name'
);
var
type
=
$this
.
prop
(
'type'
);
var
cropBoxData
;
var
canvasData
;
var
image
=
document
.
getElementById
(
'cropperImage'
);
if
(
!
$image
.
data
(
'cropper'
))
{
var
cropper
=
new
Cropper
(
image
,
{
return
;
aspectRatio
:
16
/
9
,
}
crop
(
event
)
{
console
.
log
(
event
.
detail
.
x
);
if
(
type
===
'checkbox'
)
{
console
.
log
(
event
.
detail
.
y
);
options
[
name
]
=
$this
.
prop
(
'checked'
);
console
.
log
(
event
.
detail
.
width
);
cropBoxData
=
$image
.
cropper
(
'getCropBoxData'
);
console
.
log
(
event
.
detail
.
height
);
canvasData
=
$image
.
cropper
(
'getCanvasData'
);
console
.
log
(
event
.
detail
.
rotate
);
console
.
log
(
event
.
detail
.
scaleX
);
options
.
ready
=
function
()
{
console
.
log
(
event
.
detail
.
scaleY
);
$image
.
cropper
(
'setCropBoxData'
,
cropBoxData
);
},
$image
.
cropper
(
'setCanvasData'
,
canvasData
);
};
}
else
if
(
type
===
'radio'
)
{
options
[
name
]
=
$this
.
val
();
}
$image
.
cropper
(
'destroy'
).
cropper
(
options
);
});
// Methods
$
(
'.docs-buttons'
).
on
(
'click'
,
'[data-method]'
,
function
()
{
var
$this
=
$
(
this
);
var
data
=
$this
.
data
();
var
cropper
=
$image
.
data
(
'cropper'
);
var
cropped
;
var
$target
;
var
result
;
if
(
$this
.
prop
(
'disabled'
)
||
$this
.
hasClass
(
'disabled'
))
{
return
;
}
if
(
cropper
&&
data
.
method
)
{
data
=
$
.
extend
({},
data
);
// Clone a new one
if
(
typeof
data
.
target
!==
'undefined'
)
{
$target
=
$
(
data
.
target
);
if
(
typeof
data
.
option
===
'undefined'
)
{
try
{
data
.
option
=
JSON
.
parse
(
$target
.
val
());
}
catch
(
e
)
{
console
.
log
(
e
.
message
);
}
}
}
cropped
=
cropper
.
cropped
;
switch
(
data
.
method
)
{
case
'rotate'
:
if
(
cropped
&&
options
.
viewMode
>
0
)
{
$image
.
cropper
(
'clear'
);
}
break
;
case
'getCroppedCanvas'
:
if
(
uploadedImageType
===
'image/jpeg'
)
{
if
(
!
data
.
option
)
{
data
.
option
=
{};
}
data
.
option
.
fillColor
=
'#fff'
;
}
break
;
}
result
=
$image
.
cropper
(
data
.
method
,
data
.
option
,
data
.
secondOption
);
switch
(
data
.
method
)
{
case
'rotate'
:
if
(
cropped
&&
options
.
viewMode
>
0
)
{
$image
.
cropper
(
'crop'
);
}
break
;
case
'scaleX'
:
case
'scaleY'
:
$
(
this
).
data
(
'option'
,
-
data
.
option
);
break
;
case
'getCroppedCanvas'
:
if
(
result
)
{
// Bootstrap's Modal
$
(
'#getCroppedCanvasModal'
).
modal
().
find
(
'.modal-body'
).
html
(
result
);
if
(
!
$download
.
hasClass
(
'disabled'
))
{
download
.
download
=
uploadedImageName
;
$download
.
attr
(
'href'
,
result
.
toDataURL
(
uploadedImageType
));
}
}
break
;
case
'destroy'
:
if
(
uploadedImageURL
)
{
URL
.
revokeObjectURL
(
uploadedImageURL
);
uploadedImageURL
=
''
;
$image
.
attr
(
'src'
,
originalImageURL
);
}
break
;
}
if
(
$
.
isPlainObject
(
result
)
&&
$target
)
{
try
{
$target
.
val
(
JSON
.
stringify
(
result
));
}
catch
(
e
)
{
console
.
log
(
e
.
message
);
}
}
}
});
});
// Keyboard
$
(
document
.
body
).
on
(
'keydown'
,
function
(
e
)
{
if
(
e
.
target
!==
this
||
!
$image
.
data
(
'cropper'
)
||
this
.
scrollTop
>
300
)
{
return
;
}
switch
(
e
.
which
)
{
case
37
:
e
.
preventDefault
();
$image
.
cropper
(
'move'
,
-
1
,
0
);
break
;
case
38
:
e
.
preventDefault
();
$image
.
cropper
(
'move'
,
0
,
-
1
);
break
;
case
39
:
e
.
preventDefault
();
$image
.
cropper
(
'move'
,
1
,
0
);
break
;
case
40
:
e
.
preventDefault
();
$image
.
cropper
(
'move'
,
0
,
1
);
break
;
}
});
// Import image
var
$inputImage
=
$
(
'#inputImage'
);
if
(
URL
)
{
$inputImage
.
change
(
function
()
{
var
files
=
this
.
files
;
var
file
;
if
(
!
$image
.
data
(
'cropper'
))
{
return
;
}
if
(
files
&&
files
.
length
)
{
file
=
files
[
0
];
if
(
/^image
\/\w
+$/
.
test
(
file
.
type
))
{
uploadedImageName
=
file
.
name
;
uploadedImageType
=
file
.
type
;
if
(
uploadedImageURL
)
{
URL
.
revokeObjectURL
(
uploadedImageURL
);
}
uploadedImageURL
=
URL
.
createObjectURL
(
file
);
$image
.
cropper
(
'destroy'
).
attr
(
'src'
,
uploadedImageURL
).
cropper
(
options
);
$inputImage
.
val
(
''
);
}
else
{
window
.
alert
(
'Please choose an image file.'
);
}
}
});
}
else
{
$inputImage
.
prop
(
'disabled'
,
true
).
parent
().
addClass
(
'disabled'
);
}
});
});
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