diff options
Diffstat (limited to 'settings')
-rw-r--r-- | settings/css/settings.css | 5 | ||||
-rw-r--r-- | settings/js/personal.js | 92 | ||||
-rw-r--r-- | settings/personal.php | 4 | ||||
-rw-r--r-- | settings/templates/personal.php | 13 | ||||
-rw-r--r-- | settings/templates/users.php | 2 |
5 files changed, 116 insertions, 0 deletions
diff --git a/settings/css/settings.css b/settings/css/settings.css index d5ffe448482..a2c3eaf6263 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -21,6 +21,8 @@ input#openid, input#webdav { width:20em; } input#identity { width:20em; } #email { width: 17em; } +#avatar .warning { width: 350px; } + .msg.success{ color:#fff; background-color:#0f0; padding:3px; text-shadow:1px 1px #000; } .msg.error{ color:#fff; background-color:#f00; padding:3px; text-shadow:1px 1px #000; } @@ -35,6 +37,9 @@ td.name, td.password { padding-left:.8em; } td.password>img,td.displayName>img, td.remove>a, td.quota>img { visibility:hidden; } td.password, td.quota, td.displayName { width:12em; cursor:pointer; } td.password>span, td.quota>span, rd.displayName>span { margin-right: 1.2em; color: #C7C7C7; } +td.avatar img { + margin-top: 6px; +} td.remove { width:1em; padding-right:1em; } tr:hover>td.password>span, tr:hover>td.displayName>span { margin:0; cursor:pointer; } diff --git a/settings/js/personal.js b/settings/js/personal.js index 8ad26c086b5..5d9219dd7e5 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -44,6 +44,68 @@ function changeDisplayName(){ } } +function selectAvatar (path) { + $.post(OC.router_base_url+'/avatar/', {path: path}, avatarResponseHandler); +} + +function updateAvatar () { + $avatarimg = $('#avatar img'); + $avatarimg.attr('src', $avatarimg.attr('src') + '#'); +} + +function showAvatarCropper() { + var $dlg = $('<div id="cropperbox" title="'+t('settings', 'Crop')+'"></div>'); + $('body').append($dlg); + $('#cropperbox').ocdialog({ + width: '600px', + height: '600px', + buttons: [{ + text: t('settings', 'Crop'), + click: sendCropData, + defaultButton: true + }] + }); + var cropper = new Image(); + $(cropper).load(function() { + $(this).attr('id', 'cropper'); + $('#cropperbox').html(this); + $(this).Jcrop({ + onChange: saveCoords, + onSelect: saveCoords, + aspectRatio: 1 + }); + }).attr('src', OC.router_base_url+'/avatartmp/512'); +} + +function sendCropData() { + $('#cropperbox').ocdialog('close'); + var cropperdata = $('#cropper').data(); + var data = { + x: cropperdata.x, + y: cropperdata.y, + w: cropperdata.w, + h: cropperdata.h + }; + $.post(OC.router_base_url+'/avatar/cropped', {crop: data}, avatarResponseHandler); +} + +function saveCoords(c) { + $('#cropper').data(c); +} + +function avatarResponseHandler(data) { + $warning = $('#avatar .warning'); + $warning.hide(); + if (data.status === "success") { + updateAvatar(); + } else if (data.data.message === "notsquare") { + showAvatarCropper(); + } else { + $warning.show(); + $warning.text(data.data.message); + } +} + $(document).ready(function(){ $("#passwordbutton").click( function(){ if ($('#pass1').val() !== '' && $('#pass2').val() !== '') { @@ -128,6 +190,36 @@ $(document).ready(function(){ } }); + $('#uploadavatar').click(function(){ + alert('To be done'); + updateAvatar(); + }); + + var uploadparms = { + done: function(e, data) { + avatarResponseHandler(data.result); + } + }; + + $('#uploadavatarbutton').click(function(){ + $('#uploadavatar').click(); + }); + + $('#uploadavatar').fileupload(uploadparms); + + $('#selectavatar').click(function(){ + OC.dialogs.filepicker(t('settings', "Select an avatar"), selectAvatar, false, "image"); + }); + + $('#removeavatar').click(function(){ + $.ajax({ + type: 'DELETE', + url: OC.router_base_url+'/avatar/', + success: function(msg) { + updateAvatar(); + } + }); + }); } ); OC.Encryption = { diff --git a/settings/personal.php b/settings/personal.php index 112eaa3c748..b0d62645d5a 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -15,6 +15,9 @@ OC_Util::addScript( 'settings', 'personal' ); OC_Util::addStyle( 'settings', 'settings' ); OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' ); OC_Util::addStyle( '3rdparty', 'chosen' ); +\OC_Util::addScript('files', 'jquery.fileupload'); +\OC_Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop.min'); +\OC_Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop.min'); OC_App::setActiveNavigationEntry( 'personal' ); $storageInfo=OC_Helper::getStorageInfo('/'); @@ -84,6 +87,7 @@ $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User: $tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser())); $tmpl->assign('displayName', OC_User::getDisplayName()); $tmpl->assign('enableDecryptAll' , $enableDecryptAll); +$tmpl->assign('avatar', OC_Config::getValue('avatar', 'local')); $forms=OC_App::getForms('personal'); $tmpl->assign('forms', array()); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 63e1258b958..b94b8452585 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -80,6 +80,19 @@ if($_['passwordChangeSupported']) { } ?> +<form id="avatar" method="post" action="<?php p(\OC_Helper::linkToRoute('core_avatar_post')); ?>"> + <fieldset class="personalblock"> + <legend><strong><?php p($l->t('Profile Image')); ?></strong></legend> + <img src="<?php print_unescaped(\OC_Helper::linkToRoute('core_avatar_get').'/'.OC_User::getUser().'/128'); ?>"><br> + <em><?php p($l->t('Has to be square and either PNG or JPG')); ?></em><br> + <div class="warning hidden"></div> + <div class="inlineblock button" id="uploadavatarbutton"><?php p($l->t('Upload new')); ?></div> + <input type="file" class="hidden" name="files[]" id="uploadavatar"> + <div class="inlineblock button" id="selectavatar"><?php p($l->t('Select new from files')); ?></div> + <div class="inlineblock button" id="removeavatar"><?php p($l->t('Remove image')); ?></div> + </fieldset> +</form> + <form> <fieldset class="personalblock"> <legend><strong><?php p($l->t('Language'));?></strong></legend> diff --git a/settings/templates/users.php b/settings/templates/users.php index 22450fdf25f..32ca6e0b106 100644 --- a/settings/templates/users.php +++ b/settings/templates/users.php @@ -81,6 +81,7 @@ $_['subadmingroups'] = array_flip($items); <table class="hascontrols" data-groups="<?php p(json_encode($allGroups));?>"> <thead> <tr> + <th id='headerAvatar'></th> <th id='headerName'><?php p($l->t('Username'))?></th> <th id="headerDisplayName"><?php p($l->t( 'Display Name' )); ?></th> <th id="headerPassword"><?php p($l->t( 'Password' )); ?></th> @@ -96,6 +97,7 @@ $_['subadmingroups'] = array_flip($items); <?php foreach($_["users"] as $user): ?> <tr data-uid="<?php p($user["name"]) ?>" data-displayName="<?php p($user["displayName"]) ?>"> + <td class="avatar"><img src="<?php print_unescaped(\OC_Helper::linkToRoute('core_avatar_get')); ?>/<?php p($user['name']); ?>/32"></td> <td class="name"><?php p($user["name"]); ?></td> <td class="displayName"><span><?php p($user["displayName"]); ?></span> <img class="svg action" src="<?php p(image_path('core', 'actions/rename.svg'))?>" |