Class: Pageflow::BackgroundImageHelper::DivWithSizeAttributes
- Inherits:
-
Div
- Object
- Div
- Pageflow::BackgroundImageHelper::DivWithSizeAttributes
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
Instance Method Details
#data_attributes ⇒ Object
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_file ⇒ Object
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_style ⇒ Object
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" else
super
end
end
|
#padding_top ⇒ Object
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
|