Merge pull request #5638 from Faldrian/5604-better-avatar-error-handling

5604 better avatar error handling
This commit is contained in:
Jason Robinson 2015-02-08 23:36:45 +02:00
commit e6d38db365
4 changed files with 13 additions and 12 deletions

View file

@ -46,6 +46,10 @@ app.views.Base = Backbone.View.extend({
this.$el
.html(this.template(presenter))
.attr("data-template", _.last(this.templateName.split("/")));
// add avatar fallback if it can't be loaded
this.$el.find(this.avatars.selector).error(this.avatars.fallback);
this.postRenderTemplate();
},
@ -136,6 +140,13 @@ app.views.Base = Backbone.View.extend({
});
}
},
avatars: {
fallback: function(evt) {
$(this).attr("src", ImagePaths.get("user/default.png"));
},
selector: "img.avatar"
}
});
app.views.StaticContentView = app.views.Base.extend({

View file

@ -26,9 +26,6 @@ var View = {
.on('click', this.dropdowns.selector, this.dropdowns.click)
.on('keypress', this.dropdowns.selector, this.dropdowns.click);
/* Avatars */
$(this.avatars.selector).error(this.avatars.fallback);
/* Clear forms after successful submit, this is some legacy dan hanson stuff, do we still want it? */
$.fn.clearForm = function() {
return this.each(function() {
@ -107,13 +104,6 @@ var View = {
},
selector: ".dropdown > .toggle",
parentSelector: ".dropdown > .wrapper"
},
avatars: {
fallback: function(evt) {
$(this).attr("src", ImagePaths.get("user/default.png"));
},
selector: "img.avatar"
}
};

View file

@ -85,7 +85,7 @@
}
}
.reshare {
div.reshare {
border-left: 2px solid $border-grey;
margin-top: 3px;

View file

@ -202,7 +202,7 @@
}
}
.stream_element .post-content .reshare {
.stream_element .post-content div.reshare {
border-left: 2px solid $border-grey;
}