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:
parent
d0ad2a5581
commit
6bc6d8f478
@ -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})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user