6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/slideshow/helpers/background_helper.rb', line 6
def ( *args )
return "" unless .has_gradient?
theme = [ :gradient_theme ]
colors = [ :gradient_colors ].split(' ')
buf = ""
if theme == 'diagonal'
buf << "linear-gradient( top left, #{colors.join(', ')} )"
elsif theme == 'top-bottom'
buf << "linear-gradient( top, #{colors.join(', ')} )"
elsif theme == 'left-right'
buf << "linear-gradient( left, #{colors.join(', ')} )"
elsif theme == 'repeat'
buf << "repeating-linear-gradient( -60deg, #{colors.join(', ')} 10% )"
elsif theme == 'radial'
buf << "radial-gradient( #{colors.join(', ')} )"
elsif theme == 'radial-off-center'
buf << "radial-gradient( 70% 70%, ellipse, #{colors.join(', ')} )"
elsif theme == 'radial-repeat'
buf << "repeating-radial-gradient( 60% 60%, ellipse, #{colors.join(', ')} 10% )"
else
buf << "linear-gradient( #{colors.join(', ')} )"
puts "warning: unknown gradient themes #{theme} - falling back to default"
end
puts " Adding CSS for gradient background style rule using headers..."
puts " gradient-theme: #{theme}"
puts " gradient-colors: #{colors.join(' ')}"
content_for( :css, <<-EOS )
/****
* generated by gradient_from_headers helper; using headers:
* gradient-theme: #{theme}
* gradient-colors: #{colors.join(' ')}
*/
.slide { background-image: -webkit-#{buf};
background-image: -moz-#{buf};
background-image: -ms-#{buf};
background-image: -o-#{buf};
background-image: #{buf};
}
EOS
end
|