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) {
console.log('finishLoad', self.getDisplayName(), image.width, image.height);
$(image).addClass('contactphoto');
self.$photowrapper.removeClass('loading wait');
self.$photowrapper.css({width: image.width + 10, height: image.height + 10});
self.$photowrapper.removeClass('loading').removeClass('wait');
$(image).insertAfter($phototools).fadeIn();
};
@ -2080,7 +2080,7 @@ OC.Contacts = OC.Contacts || {};
$(document).trigger('status.contact.error', {
message:
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() {
console.log('Storage.getDefaultPhoto');
if(!this._defaultPhoto) {
if(!this.defaultPhoto) {
var defer = $.Deferred();
var url = OC.imagePath('contacts', 'person_large.png');
this._defaultPhoto = new Image();
$.when(
$(this._defaultPhoto)
.load(function() {
console.log('Default photo loaded', arguments);
}).error(function() {
console.log('Error loading default photo', arguments)
}).attr('src', url)
)
.then(function(response) {
console.log('Storage.defaultPhoto', response);
})
.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;
this.defaultPhoto = new Image();
var self = this;
$(this.defaultPhoto)
.load(function() {
defer.resolve(this);
}).error(function(event) {
defer.reject();
}).attr('src', url)
return defer.promise();
} else {
return this.defaultPhoto;
}
}
/**