parent
e66113f50d
commit
0c708be76b
@ -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
|
||||
}); |
@ -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)); |
Loading…
Reference in new issue