summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorkondou <kondou@ts.unde.re>2013-08-29 14:26:11 +0200
committerkondou <kondou@ts.unde.re>2013-08-29 14:26:11 +0200
commit0c708be76bd7c7449779ef12e48e99d9c2cd3d82 (patch)
treee58bdf611bb96f3f73d469d9a65179dbc1f1838e /core
parente66113f50d9e39e3e370be0e714669f2917f9ccf (diff)
downloadnextcloud-server-0c708be76bd7c7449779ef12e48e99d9c2cd3d82.tar.gz
nextcloud-server-0c708be76bd7c7449779ef12e48e99d9c2cd3d82.zip
Use defaultavatars
Diffstat (limited to 'core')
-rw-r--r--core/avatar/controller.php2
-rw-r--r--core/css/styles.css2
-rw-r--r--core/js/avatar.js10
-rw-r--r--core/js/jquery.avatar.js37
-rw-r--r--core/templates/layout.user.php2
5 files changed, 50 insertions, 3 deletions
diff --git a/core/avatar/controller.php b/core/avatar/controller.php
index 8492ee909c6..64d9eafe52b 100644
--- a/core/avatar/controller.php
+++ b/core/avatar/controller.php
@@ -31,7 +31,7 @@ class OC_Core_Avatar_Controller {
if ($image instanceof \OC_Image) {
$image->show();
} elseif ($image === false) {
- \OC_JSON::success(array('user' => $user, 'size' => $size));
+ \OC_JSON::success(array('user' => \OC_User::getDisplayName($user), 'size' => $size));
}
}
diff --git a/core/css/styles.css b/core/css/styles.css
index 363d36294b2..b8c637d5ec1 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -40,7 +40,7 @@ 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 {
+header .avatardiv {
float:right;
margin-top: 6px;
margin-right: 6px;
diff --git a/core/js/avatar.js b/core/js/avatar.js
new file mode 100644
index 00000000000..22ebf295999
--- /dev/null
+++ b/core/js/avatar.js
@@ -0,0 +1,10 @@
+$(document).ready(function(){
+ $('header .avatardiv').avatar(OC.currentUser, 32);
+ // Personal settings
+ $('#avatar .avatardiv').avatar(OC.currentUser, 128);
+ // User settings
+ $.each($('td.avatar .avatardiv'), function(i, data) {
+ $(data).avatar($(data).parent().parent().data('uid'), 32); // TODO maybe a better way of getting the current name …
+ });
+ // TODO when creating a new user, he gets a previously used avatar
+});
diff --git a/core/js/jquery.avatar.js b/core/js/jquery.avatar.js
new file mode 100644
index 00000000000..f6181e1c9e2
--- /dev/null
+++ b/core/js/jquery.avatar.js
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+(function ($) {
+ $.fn.avatar = function(user, height) {
+ // TODO there has to be a better way …
+ if (typeof(height) === 'undefined') {
+ height = this.height();
+ }
+ if (height === 0) {
+ height = 64;
+ }
+
+ this.height(height);
+ this.width(height);
+
+ if (typeof(user) === 'undefined') {
+ this.placeholder('x');
+ return;
+ }
+
+ var $div = this;
+
+ //$.get(OC.Router.generate('core_avatar_get', {user: user, size: height}), function(result) { // TODO does not work "Uncaught TypeError: Cannot use 'in' operator to search for 'core_avatar_get' in undefined" router.js L22
+ $.get(OC.router_base_url+'/avatar/'+user+'/'+height, function(result) {
+ if (typeof(result) === 'object') {
+ $div.placeholder(result.user);
+ } else {
+ $div.html('<img src="'+OC.Router.generate('core_avatar_get', {user: user, size: height})+'">');
+ }
+ });
+ };
+}(jQuery));
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index dfcfd544cfe..edac4c040fa 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -46,7 +46,7 @@
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 print_unescaped($_['avatar']); ?>
+ <div class="avatardiv"></div>
<ul id="settings" class="svg">
<span id="expand" tabindex="0" role="link">