summaryrefslogtreecommitdiffstats
path: root/core/js/jquery.avatar.js
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/js/jquery.avatar.js
parente66113f50d9e39e3e370be0e714669f2917f9ccf (diff)
downloadnextcloud-server-0c708be76bd7c7449779ef12e48e99d9c2cd3d82.tar.gz
nextcloud-server-0c708be76bd7c7449779ef12e48e99d9c2cd3d82.zip
Use defaultavatars
Diffstat (limited to 'core/js/jquery.avatar.js')
-rw-r--r--core/js/jquery.avatar.js37
1 files changed, 37 insertions, 0 deletions
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));