Improve styling & enable avatar-upload at personal page

This commit is contained in:
kondou 2013-08-02 08:03:51 +02:00
parent a58d270684
commit 252548c62c
10 changed files with 44 additions and 21 deletions

View File

@ -40,6 +40,11 @@ body { background:#fefefe; font:normal .8em/1.6em "Helvetica Neue",Helvetica,Ari
.header-right { float:right; vertical-align:middle; padding:0.5em; }
.header-right > * { vertical-align:middle; }
header .avatar {
float:right;
margin-top: 6px;
margin-right: 6px;
}
/* INPUTS */
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="email"], input[type="url"],

View File

@ -45,9 +45,11 @@
<a href="<?php print_unescaped(link_to('', 'index.php')); ?>" title="" id="owncloud"><img class="svg"
src="<?php print_unescaped(image_path('', 'logo-wide.svg')); ?>" alt="<?php p($theme->getName()); ?>" /></a>
<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
<?php if (isset($_['avatar'])) { print_unescaped($_['avatar']); } ?>
<ul id="settings" class="svg">
<span id="expand" tabindex="0" role="link">
<?php if (isset($_['avatar'])) { print_unescaped($_['avatar']); } ?>
<span id="expandDisplayName"><?php p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span>
<img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" />
</span>

View File

@ -20,7 +20,7 @@ class OC_TemplateLayout extends OC_Template {
// display avatars if they are enabled
if (OC_Config::getValue('avatar') === 'gravatar' || OC_Config::getValue('avatar', 'local') === 'local') {
$this->assign('avatar', '<img src="'.OC_Avatar::get(OC_User::getUser(), 32).'">');
$this->assign('avatar', '<img class="avatar" src="'.link_to('', 'avatar.php').'?user='.OC_User::getUser().'&size=32">');
}
// Update notification

View File

@ -13,12 +13,19 @@ if(isset($_POST['path'])) {
\OC_Avatar::setLocalAvatar($user, $path);
OC_JSON::success();
} catch (Exception $e) {
OC_JSON::error();
OC_JSON::error(array("msg" => $e->getMessage()));
}
}
} elseif (isset($_POST['image'])) { // upload a new image
\OC_Avatar::setLocalAvatar($user, $_POST['image']);
OC_JSON::success();
} elseif (!empty($_FILES)) { // upload a new image
$files = $_FILES['files'];
if ($files['error'][0] === 0) {
$data = file_get_contents($files['tmp_name'][0]);
\OC_Avatar::setLocalAvatar($user, $data);
unlink($files['tmp_name'][0]);
OC_JSON::success();
} else {
OC_JSON::error();
}
} else {
OC_JSON::error();
}

View File

@ -35,6 +35,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; }

View File

@ -144,6 +144,14 @@ $(document).ready(function(){
updateAvatar();
});
var uploadparms = {
done: function(e) {
updateAvatar();
}
};
$('#uploadavatar').fileupload(uploadparms);
$('#selectavatar').click(function(){
OC.dialogs.filepicker(t('settings', "Select an avatar"), selectAvatar, false, "image");
});

View File

@ -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' );
if (OC_Config::getValue('avatar', 'local') === 'local') {
\OC_Util::addScript('files', 'jquery.fileupload');
}
OC_App::setActiveNavigationEntry( 'personal' );
$storageInfo=OC_Helper::getStorageInfo();

View File

@ -121,10 +121,9 @@ if (!$_['internetconnectionworking']) {
<table class="nostyle">
<tr>
<td>
<input type="radio" name="avatarmode" value="gravatar"
id="avatar_gravatar" <?php if ($_['avatar'] === "gravatar") {
print_unescaped('checked="checked"');
} ?>>
<input type="radio" name="avatarmode" value="gravatar" id="avatar_gravatar"
<?php if ($_['avatar'] === "gravatar") { p('checked'); } ?>
<?php if (!$_['internetconnectionworking']) { p('disabled'); } ?>>
<label for="avatar_gravatar">Gravatar</label><br>
<em><?php print_unescaped($l->t('Use <a href="http://gravatar.com/">gravatar</a> for avatars')); ?></em><br>
<em><?php p($l->t('This sends data to gravatar')); ?></em>
@ -135,22 +134,18 @@ if (!$_['internetconnectionworking']) {
</tr>
<tr>
<td>
<input type="radio" name="avatarmode" value="local"
id="avatar_local" <?php if ($_['avatar'] === "local") {
print_unescaped('checked="checked"');
} ?>>
<input type="radio" name="avatarmode" value="local" id="avatar_local"
<?php if ($_['avatar'] === "local") { p('checked'); } ?>>
<label for="avatar_local"><?php p($l->t('Local avatars')); ?></label><br>
<em><?php p($l->t('Use local avatars, which each user has to upload themselves')); ?></em>
</td>
</tr>
<tr>
<td>
<input type="radio" name="avatarmode" value="none"
id="avatar_none" <?php if ($_['avatar'] === "none") {
print_unescaped('checked="checked"');
} ?>>
<input type="radio" name="avatarmode" value="none" id="avatar_none"
<?php if ($_['avatar'] === "none") { p('checked'); } ?>>
<label for="avatar_none"><?php p($l->t('No avatars')); ?></label><br>
<em><?php print_unescaped($l->t('Do not provide avatars')); ?></em>
<em><?php p($l->t('Do not provide avatars')); ?></em>
</td>
</tr>
</table>

View File

@ -87,7 +87,7 @@ if($_['passwordChangeSupported']) {
<form id="avatar">
<fieldset class="personalblock">
<legend><strong><?php p($l->t('Avatar')); ?></strong></legend>
<img src="<?php print_unescaped(\OC_Avatar::get(\OC_User::getUser(), 128)); ?>"><br>
<img src="<?php print_unescaped(link_to('', 'avatar.php').'?user='.OC_User::getUser().'&size=128'); ?>"><br>
<em><?php p($l->t('Your avatar has to be a square and either a PNG or JPG image')); ?></em><br>
<div class="inlineblock button" id="uploadavatar"><?php p($l->t('Upload a new avatar')); ?></div>
<div class="inlineblock button" id="selectavatar"><?php p($l->t('Select a new avatar from your files')); ?></div>

View File

@ -13,7 +13,7 @@ class Test_Avatar extends PHPUnit_Framework_TestCase {
\OC_Config::setValue('avatar', 'local');
$this->assertEquals('local', \OC_Avatar::getMode());
\OC_Config::setValue('avatar', 'gravatar');
$this->assertEquals('gravatar', \OC_Avatar::getMode());