Add lazy_load option to participant avatar helper
This commit is contained in:
parent
8b1a3d40e7
commit
9cd87f6fa9
2 changed files with 6 additions and 3 deletions
|
@ -21,11 +21,14 @@ module ProjectsHelper
|
||||||
classes = %W[avatar avatar-inline s#{opts[:size]}]
|
classes = %W[avatar avatar-inline s#{opts[:size]}]
|
||||||
classes << opts[:avatar_class] if opts[:avatar_class]
|
classes << opts[:avatar_class] if opts[:avatar_class]
|
||||||
|
|
||||||
image_tag(avatar_icon(author, opts[:size]), width: opts[:size], class: classes, alt: '')
|
avatar = avatar_icon(author, opts[:size])
|
||||||
|
src = opts[:lazy_load] ? nil : avatar
|
||||||
|
|
||||||
|
image_tag(src, width: opts[:size], class: classes, alt: '', "data-src" => avatar)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_member(project, author, opts = {}, &block)
|
def link_to_member(project, author, opts = {}, &block)
|
||||||
default_opts = { avatar: true, name: true, size: 16, author_class: 'author', title: ":name", tooltip: false }
|
default_opts = { avatar: true, name: true, size: 16, author_class: 'author', title: ":name", tooltip: false, lazy_load: false }
|
||||||
opts = default_opts.merge(opts)
|
opts = default_opts.merge(opts)
|
||||||
|
|
||||||
return "(deleted)" unless author
|
return "(deleted)" unless author
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
.hide-collapsed.participants-list
|
.hide-collapsed.participants-list
|
||||||
- participants.each do |participant|
|
- participants.each do |participant|
|
||||||
.participants-author.js-participants-author
|
.participants-author.js-participants-author
|
||||||
= link_to_member(@project, participant, name: false, size: 24)
|
= link_to_member(@project, participant, name: false, size: 24, lazy_load: true)
|
||||||
- if participants_extra > 0
|
- if participants_extra > 0
|
||||||
.hide-collapsed.participants-more
|
.hide-collapsed.participants-more
|
||||||
%a.js-participants-more{ href: "#", data: { original_text: "+ #{participants_size - 7} more", less_text: "- show less" } }
|
%a.js-participants-more{ href: "#", data: { original_text: "+ #{participants_size - 7} more", less_text: "- show less" } }
|
||||||
|
|
Loading…
Reference in a new issue