Sha256: 0a7a440ea8d9f7c1fccb72be654f96e53d1c2e86adde80f7a45f0552d02678c7

Contents?: true

Size: 1.13 KB

Versions: 105

Compression:

Stored size: 1.13 KB

Contents

# -*- encoding : utf-8 -*-
# not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string

# this will NOT stay in inline_forms, it belongs in an app.

def chicas_family_photo_list_show(object, attribute)
  # the attribute should be like members_photos
  # then it will look for object.family.members.photos
  # I know it's crappy.
  members, photos = attribute.to_s.split('_')
  photo_list = {}
  object.family.send(members).each do |member|
    member.send(photos).each do |photo|
      photo_list[photo.rating] ||= []
      photo_list[photo.rating] << photo
    end
  end
  out = ''
  if photo_list.empty?
    out = "<div class='row #{cycle('odd', 'even')}'>no photos</div>"
  else
    out << "<div class='row #{cycle('odd', 'even')}'>"
    photo_list.sort.reverse.each do |rating, photos|
      photos.each do |photo|
        out << image_tag(photo.image.url(:thumb), 
        	onclick: "this.src='#{photo.image.url(:palm)}'", 
        	onmouseout: "this.src='#{photo.image.url(:thumb)}'",
        	alt: photo.name,
        	title: photo.name)
      end
    end
    out << '</div>'
  end
  out.html_safe
end

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
inline_forms-3.0.47 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.46 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.45 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.44 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.43 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.42 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.41 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.40 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.39 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.38 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.37 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.36 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.35 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.34 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.32 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.31 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.30 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.29 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.28 lib/app/helpers/form_elements/chicas_family_photo_list.rb
inline_forms-3.0.27 lib/app/helpers/form_elements/chicas_family_photo_list.rb