From c25836b5fcf0fdd5faac9c50a721f5790609e043 Mon Sep 17 00:00:00 2001 From: Anil Mandepudi Date: Tue, 14 Feb 2017 13:31:52 -0800 Subject: [PATCH] Option to upload without cropping (#5447) * Option to upload without cropping * Fix styling * Fix styling * Add missing semi-colon * I fail at styling :fail: --- public/less/generics.less | 2 +- public/src/client/account/edit.js | 15 +++++++++++++++ src/views/modals/crop_picture.tpl | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/public/less/generics.less b/public/less/generics.less index 0725264501..5193627445 100644 --- a/public/less/generics.less +++ b/public/less/generics.less @@ -132,7 +132,7 @@ } #crop-picture-modal { - .cropped-image { + #cropped-image { max-width: 100%; } diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.js index 752499f34f..2856d10f99 100644 --- a/public/src/client/account/edit.js +++ b/public/src/client/account/edit.js @@ -252,6 +252,9 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator', imageData: imageData }, function (err, imageData) { if (err) { + cropperModal.find('#upload-progress-box').hide(); + cropperModal.find('.upload-btn').removeClass('disabled'); + cropperModal.find('.crop-btn').removeClass('disabled'); app.alertError(err.message); } @@ -259,6 +262,18 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator', cropperModal.modal('hide'); }); }); + + cropperModal.find('.upload-btn').on('click', function () { + $(this).addClass('disabled'); + cropperTool.destroy(); + + cropperTool = new cropper.default(img, { + viewMode: 1, + autoCropArea: 1 + }); + + cropperModal.find('.crop-btn').trigger('click'); + }); }); }); } diff --git a/src/views/modals/crop_picture.tpl b/src/views/modals/crop_picture.tpl index d28a3a2d59..ba98860df4 100644 --- a/src/views/modals/crop_picture.tpl +++ b/src/views/modals/crop_picture.tpl @@ -32,6 +32,7 @@