From 9ce6d9be767ee5d3e6d754561cf8780bd85d9187 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 23 Mar 2013 01:58:18 +0100 Subject: [PATCH] Contacts: Use inline css thumbnail for contacts wo profile pic. --- css/contacts.css | 4 ++++ js/contacts.js | 31 ++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/css/contacts.css b/css/contacts.css index 9cb1a0b1..10b0717e 100644 --- a/css/contacts.css +++ b/css/contacts.css @@ -415,6 +415,10 @@ input:not([type="checkbox"]).propertytype { text-align: right; margin: 0; } + +.thumbnail { + background-image:url('data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAALRSURBVDjLpZRLT1pREMftpo9VV03aT9EmXXTVxKTfpaum36Ab04RgUCxxw8oFEsEHYCAqmmAiaEIAQUBAeYgiL8Ob8Li3lOn8T0rT6C1pbheTueecmd+Ze878zwwRzUyznZ2dJ3t7e1/39/ezbrdbhscY89PypkLX19efMSQVjUaH7XabRqMRtVotOjs7G+7u7qawrgrscrn04XBYArDf71Oj0RBgSZIoEAhIWFcFdjqdRYCGwyGh4lqtRqVSSfi7uzvCuiqw3W6Xe72egKJawIrFIt3e3orKbTabrBZcAKxer1O1WqVyuUyFQkEY4AwuqAJvbW15MpmMqBSgm5sburq6Ej6VStHm5qZHFXhtbe1bMBgc41wBzOVylE6nKZ/Pk9/vH2NdFdhkMr23Wq0yqs5ms3RxcUGXl5fCNjY2pNXV1Q+qwDCLxWJkCCWTyd/mcDiI5+2qBQJjIcxub2/LfFF0cnJCrDhAf3Crzf4XmGX8zufzdXgDANEJ5PF4eiztN6rABwcHz7m6L2xtvjC52WyKc4ZPJBJQXYOr/sSyfvxPYA58wb+uY+udnp6KN+LX+0BHR0cUiUQEHH19fHw84POu8V98XllZefpXMPftKxZFky9I7nQ6NBgMxBvR7XYFfCIUtB96Gxvgmzfsc0+XuaiXimDuy7lQKPQd8q1UKgICAGyiPEgaykMv42jgMc99LZvN5jlFMPelIx6P0/X1tUiCICCMiTgwh55GH0N5fNaEeHzjqJCvCOZzSsZiMTo/PyeunPD9p/G7/MAQh3hsgHxFsNFo7KIKQHBRSqD7hjjEIw/5SuBHy8vLhcPDQ+L3gfgiRBVK1U7msI44fvTR24R8cB5UvLCw8NpgMMSXlpa6er2+z5c55n4mr9crNgMUHmPMs2DGi4uLfcQjD/lTBaLRaN6yfZyfn9dwsIOTozqdrq7VakfwGGMe64hD/H3GTxUf41MtMQBvAAAAAElFTkSuQmCC'); +} input[type="checkbox"].propertytype { width: 10px; } .contactphoto { float: left; display: inline-block; diff --git a/js/contacts.js b/js/contacts.js index b418f5a3..9958f786 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -34,6 +34,24 @@ OC.Contacts = OC.Contacts || {}; } }; + Contact.prototype.setThumbnail = function(refresh) { + if(this.getPreferredValue('PHOTO', null) === null) { + return; + } + var $elem = this.getListItemElement().find('td.name'); + if(!$elem.hasClass('thumbnail')) { + return; + } + $elem.removeClass('thumbnail'); + var refreshstr = refresh ? '&refresh='+Math.random() : ''; + $elem.css('background-image', 'url(' + OC.filePath('', '', 'remote.php') + +'/contactthumbnail?backend=' + +this.metadata.backend+'&parent=' + +this.metadata.parent+'&id=' + +this.id+refreshstr + ')' + ); + } + Contact.prototype.setAsSaving = function(obj, state) { if(!obj) { return; @@ -1446,6 +1464,7 @@ OC.Contacts = OC.Contacts || {}; */ ContactList.prototype.showContacts = function(contacts) { console.log('showContacts', contacts); + var self = this; if(contacts.length === 0) { // ~5 times faster $('tr:visible.contact').hide(); @@ -1453,7 +1472,16 @@ OC.Contacts = OC.Contacts || {}; } if(contacts === 'all') { // ~2 times faster - $('tr.contact:not(:visible)').show(); + var $elems = $('tr.contact:not(:visible)'); + $elems.show(); + $.each($elems, function(idx, elem) { + try { + var id = $(elem).data('id'); + self.contacts[id].setThumbnail(); + } catch(e) { + console.warn('Failed getting id from', $elem, e); + } + }); return; } for(var id in this.contacts) { @@ -1465,6 +1493,7 @@ OC.Contacts = OC.Contacts || {}; contact.getListItemElement().hide(); } else { contact.getListItemElement().show(); + contact.setThumbnail(); } } };