Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
95cc46a4
Commit
95cc46a4
authored
Mar 17, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to set crop box and export image dimensions
parent
7216ce97
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
app/assets/javascripts/gl_crop.js.coffee
app/assets/javascripts/gl_crop.js.coffee
+17
-5
No files found.
app/assets/javascripts/gl_crop.js.coffee
View file @
95cc46a4
...
@@ -6,8 +6,13 @@ class GitLabCrop
...
@@ -6,8 +6,13 @@ class GitLabCrop
# Set defaults
# Set defaults
{
{
@
filename
@
filename
@
previewImage
=
$
(
'.avatar-image .avatar'
)
@
form
=
@
fileInput
.
parents
(
'form'
)
@
form
=
@
fileInput
.
parents
(
'form'
)
@
modalCrop
=
'.modal-profile-crop'
@
modalCrop
=
'.modal-profile-crop'
@
exportWidth
=
200
@
exportHeight
=
200
@
cropBoxWidth
=
200
@
cropBoxHeight
=
200
# Button where user clicks to open file dialog
# Button where user clicks to open file dialog
# If not passed as argument let's pick a default one
# If not passed as argument let's pick a default one
...
@@ -40,6 +45,7 @@ class GitLabCrop
...
@@ -40,6 +45,7 @@ class GitLabCrop
@
fileInput
.
trigger
(
'click'
)
@
fileInput
.
trigger
(
'click'
)
onModalShow
:
=>
onModalShow
:
=>
self
=
@
@
modalCropImg
.
cropper
(
@
modalCropImg
.
cropper
(
viewMode
:
1
viewMode
:
1
center
:
false
center
:
false
...
@@ -57,8 +63,8 @@ class GitLabCrop
...
@@ -57,8 +63,8 @@ class GitLabCrop
toggleDragModeOnDblclick
:
false
toggleDragModeOnDblclick
:
false
built
:
->
built
:
->
container
=
$
(
@
).
cropper
'getContainerData'
container
=
$
(
@
).
cropper
'getContainerData'
cropBoxWidth
=
200
;
cropBoxWidth
=
self
.
cropBoxWidth
;
cropBoxHeight
=
200
;
cropBoxHeight
=
self
.
cropBoxHeight
;
$
(
@
).
cropper
(
'setCropBoxData'
,
$
(
@
).
cropper
(
'setCropBoxData'
,
width
:
cropBoxWidth
,
width
:
cropBoxWidth
,
...
@@ -77,8 +83,8 @@ class GitLabCrop
...
@@ -77,8 +83,8 @@ class GitLabCrop
onUploadImageBtnClick
:
(
e
)
=>
onUploadImageBtnClick
:
(
e
)
=>
e
.
preventDefault
()
e
.
preventDefault
()
@
setBlob
()
@
setBlob
()
@
setPreview
()
@
modalCrop
.
modal
(
'hide'
)
@
modalCrop
.
modal
(
'hide'
)
# @form.submit();
onActionBtnClick
:
(
btn
)
->
onActionBtnClick
:
(
btn
)
->
data
=
$
(
btn
).
data
()
data
=
$
(
btn
).
data
()
...
@@ -106,9 +112,15 @@ class GitLabCrop
...
@@ -106,9 +112,15 @@ class GitLabCrop
array
.
push
(
binary
.
charCodeAt
(
k
))
array
.
push
(
binary
.
charCodeAt
(
k
))
new
Blob
([
new
Uint8Array
(
array
)],
type
:
'image/png'
)
new
Blob
([
new
Uint8Array
(
array
)],
type
:
'image/png'
)
setPreview
:
->
@
previewImage
.
attr
(
'src'
,
@
dataURL
)
setBlob
:
->
setBlob
:
->
dataURL
=
@
modalCropImg
.
cropper
(
'getCroppedCanvas'
).
toDataURL
(
'image/png'
)
@
dataURL
=
@
modalCropImg
.
cropper
(
'getCroppedCanvas'
,
@
croppedImageBlob
=
@
dataURLtoBlob
(
dataURL
)
width
:
200
height
:
200
).
toDataURL
(
'image/png'
)
@
croppedImageBlob
=
@
dataURLtoBlob
(
@
dataURL
)
getBlob
:
->
getBlob
:
->
@
croppedImageBlob
@
croppedImageBlob
...
...
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