diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-03-17 22:59:43 +0300 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-03-17 23:02:42 +0300 |
commit | 647f28bd1d92eabe239a7f0f4a65eb100c0cda73 (patch) | |
tree | ca3fbcd3a51c6c9bd14110b8f33482001e9e997b /app/assets/javascripts/gl_crop.js.coffee | |
parent | bc70597908c2aa144472b28c891306a6d9390c34 (diff) |
Make it generic
Diffstat (limited to 'app/assets/javascripts/gl_crop.js.coffee')
-rw-r--r-- | app/assets/javascripts/gl_crop.js.coffee | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/app/assets/javascripts/gl_crop.js.coffee b/app/assets/javascripts/gl_crop.js.coffee index 6ab0afc184f..137d025ed26 100644 --- a/app/assets/javascripts/gl_crop.js.coffee +++ b/app/assets/javascripts/gl_crop.js.coffee @@ -10,28 +10,32 @@ class GitLabCrop # Set defaults { - @form = @fileInput.parents('form') - @filename = '.js-avatar-filename' - @previewImage = $('.avatar-image .avatar') - @modalCrop = '.modal-profile-crop' @exportWidth = 200 @exportHeight = 200 @cropBoxWidth = 200 @cropBoxHeight = 200 + @form = @fileInput.parents('form') - # Button where user clicks to open file dialog - # If not passed as argument let's pick a default one - @pickImageEl = @fileInput.parent().find('.js-choose-user-avatar-button') - @uploadImageBtn = $('.js-upload-user-avatar') + # Required params + @filename + @previewImage + @modalCrop + @pickImageEl + @uploadImageBtn + @modalCropImg } = opts # Ensure needed elements are jquery objects - @filename = if _.isString(@filename) then @$(@filename) else @filename + # If selector is provided we will convert them to a jQuery Object + @filename = @$(@filename) + @previewImage = @$(@previewImage) + @pickImageEl = @$(@pickImageEl) - # Modal usually is outside the wrapper element + # Modal elements usually are outside the @form element @modalCrop = if _.isString(@modalCrop) then $(@modalCrop) else @modalCrop + @uploadImageBtn = if _.isString(@uploadImageBtn) then $(@uploadImageBtn) else @uploadImageBtn + @modalCropImg = if _.isString(@modalCropImg) then $(@modalCropImg) else @modalCropImg - @modalCropImg = $('.modal-profile-crop-image') @cropActionsBtn = @modalCrop.find('[data-method]') @bindEvents() |