diff --git a/core/avatar/controller.php b/core/avatar/controller.php index 8492ee909c..64d9eafe52 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 363d36294b..b8c637d5ec 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 0000000000..22ebf29599 --- /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 0000000000..f6181e1c9e --- /dev/null +++ b/core/js/jquery.avatar.js @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013 Christopher Schäpers + * 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(''); + } + }); + }; +}(jQuery)); diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index dfcfd544cf..edac4c040f 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -46,7 +46,7 @@ src="" alt="getName()); ?>" /> - +