1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-19 08:52:22 +01:00

Contacts: Fix loading default contact image

This commit is contained in:
Thomas Tanghus 2013-04-25 00:59:03 +02:00
parent d0ad2a5581
commit 6bc6d8f478
2 changed files with 16 additions and 24 deletions

View File

@ -1400,8 +1400,8 @@ OC.Contacts = OC.Contacts || {};
var finishLoad = function(image) { var finishLoad = function(image) {
console.log('finishLoad', self.getDisplayName(), image.width, image.height); console.log('finishLoad', self.getDisplayName(), image.width, image.height);
$(image).addClass('contactphoto'); $(image).addClass('contactphoto');
self.$photowrapper.removeClass('loading wait');
self.$photowrapper.css({width: image.width + 10, height: image.height + 10}); self.$photowrapper.css({width: image.width + 10, height: image.height + 10});
self.$photowrapper.removeClass('loading').removeClass('wait');
$(image).insertAfter($phototools).fadeIn(); $(image).insertAfter($phototools).fadeIn();
}; };
@ -2080,7 +2080,7 @@ OC.Contacts = OC.Contacts || {};
$(document).trigger('status.contact.error', { $(document).trigger('status.contact.error', {
message: message:
t('contacts', 'Failed loading contacts from {addressbook}: {error}', t('contacts', 'Failed loading contacts from {addressbook}: {error}',
{addressbook:addressBook['displayname'], error:err}) {addressbook:addressBook['displayname'], error:cbresponse.message})
}); });
} }
}); });

View File

@ -210,29 +210,21 @@ OC.Contacts = OC.Contacts || {};
*/ */
Storage.prototype.getDefaultPhoto = function() { Storage.prototype.getDefaultPhoto = function() {
console.log('Storage.getDefaultPhoto'); console.log('Storage.getDefaultPhoto');
if(!this._defaultPhoto) { if(!this.defaultPhoto) {
var defer = $.Deferred();
var url = OC.imagePath('contacts', 'person_large.png'); var url = OC.imagePath('contacts', 'person_large.png');
this._defaultPhoto = new Image(); this.defaultPhoto = new Image();
$.when( var self = this;
$(this._defaultPhoto) $(this.defaultPhoto)
.load(function() { .load(function() {
console.log('Default photo loaded', arguments); defer.resolve(this);
}).error(function() { }).error(function(event) {
console.log('Error loading default photo', arguments) defer.reject();
}).attr('src', url) }).attr('src', url)
) return defer.promise();
.then(function(response) { } else {
console.log('Storage.defaultPhoto', response); return this.defaultPhoto;
}) }
.fail(function(jqxhr, textStatus, error) {
var err = textStatus + ', ' + error;
console.log( "Request Failed: " + err);
$(document).trigger('status.contact.error', {
message: t('contacts', 'Failed loading default photo: {error}', {error:err})
});
});
};
return this._defaultPhoto;
} }
/** /**