From 4724d60ecd600cd778e1bb9bc56888df290887db Mon Sep 17 00:00:00 2001 From: kondou Date: Tue, 3 Sep 2013 17:40:41 +0200 Subject: [PATCH] Partly fix cropper in IE8 and don't use a dialog for it --- settings/js/personal.js | 38 +++++++++++++++++---------------- settings/templates/personal.php | 21 ++++++++++++------ 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/settings/js/personal.js b/settings/js/personal.js index d9b6836568e..f60ab72f8e6 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -55,16 +55,17 @@ function updateAvatar () { } function showAvatarCropper() { - var $dlg = $(''); - $('body').append($dlg); - - $cropperbox = $('#cropperbox'); $cropper = $('#cropper'); + $cropperImage = $('#cropper img'); + + $cropperImage.attr('src', OC.Router.generate('core_avatar_get_tmp')); - $cropper.on('load', function() { - $cropperbox.show(); + // Looks weird, but on('load', ...) doesn't work in IE8 + $cropperImage.ready(function(){ + $('#displayavatar').hide(); + $cropper.show(); - $cropper.Jcrop({ + $cropperImage.Jcrop({ onChange: saveCoords, onSelect: saveCoords, aspectRatio: 1, @@ -72,21 +73,13 @@ function showAvatarCropper() { boxWidth: 500, setSelect: [0, 0, 300, 300] }); - - $cropperbox.ocdialog({ - buttons: [{ - text: t('settings', 'Crop'), - click: sendCropData, - defaultButton: true - }], - close: function(){ - $(this).remove(); - } - }); }); } function sendCropData() { + $('#displayavatar').show(); + $cropper.hide(); + var cropperdata = $('#cropper').data(); var data = { x: cropperdata.x, @@ -224,6 +217,15 @@ $(document).ready(function(){ } }); }); + + $('#abortcropperbutton').click(function(){ + $('#displayavatar').show(); + $cropper.hide(); + }); + + $('#sendcropperbutton').click(function(){ + sendCropData(); + }); } ); OC.Encryption = { diff --git a/settings/templates/personal.php b/settings/templates/personal.php index fcef0f8a578..07a7ea0050c 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -84,13 +84,20 @@ if($_['passwordChangeSupported']) {
t('Profile picture')); ?> -

- -
t('Upload new')); ?>
- -
t('Select new from Files')); ?>
-
t('Remove image')); ?>

- t('Either png or jpg. Ideally square but you will be able to crop it.')); ?> +
+

+ +
t('Upload new')); ?>
+ +
t('Select new from Files')); ?>
+
t('Remove image')); ?>

+ t('Either png or jpg. Ideally square but you will be able to crop it.')); ?> +
+