Class: Pageflow::BackgroundImageHelper::DivWithSizeAttributes

Inherits:
Div
  • Object
show all
Defined in:
app/helpers/pageflow/background_image_helper.rb

Instance Attribute Summary

Attributes inherited from Div

#configuration, #options, #property_base_name

Instance Method Summary collapse

Methods inherited from Div

#initialize, #render

Constructor Details

This class inherits a constructor from Pageflow::BackgroundImageHelper::Div

Instance Method Details

#data_attributesObject



61
62
63
64
65
# File 'app/helpers/pageflow/background_image_helper.rb', line 61

def data_attributes
  if image_file
    {:width => image_file.width, :height => image_file.height}
  end
end

#image_fileObject



83
84
85
86
# File 'app/helpers/pageflow/background_image_helper.rb', line 83

def image_file
  @image_file ||= (ImageFile.find_by_id(image_id) || :none)
  @image_file == :none ? nil : @image_file
end

#inline_styleObject



67
68
69
70
71
72
73
# File 'app/helpers/pageflow/background_image_helper.rb', line 67

def inline_style
  if options[:spanning]
    "padding-top: #{padding_top}%; width: 100%; background-position: 0 0" # fix me (yet disables background_position option)
  else
    super
  end
end

#padding_topObject



75
76
77
78
79
80
81
# File 'app/helpers/pageflow/background_image_helper.rb', line 75

def padding_top
  if image_file
    image_file.height / image_file.width.to_f * 100
  else
    0
  end
end