5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/sigmund/liquid/filters/color.rb', line 5
def css_gradient(input)
css = ""
if input.blank?
return css
end
if colors = input.match(/#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})/i)
red, green, blue = colors.captures
explorerShit = '#00' + red + green + blue
red = red.hex.to_s
green = green.hex.to_s
blue = blue.hex.to_s
css << "background: -moz-linear-gradient(left, rgba(#{red}, #{green}, #{blue}, 0) 0%, rgba(#{red}, #{green}, #{blue}, 0.8) 70%, #{input} 100%);"
css << "background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(#{red}, #{green}, #{blue}, 0)), color-stop(70%, rgba(#{red}, #{green}, #{blue}, 0.8)), color-stop(100%, #{input}));"
css << "background: -webkit-linear-gradient(left, rgba(#{red}, #{green}, #{blue}, 0) 0%, rgba(#{red}, #{green}, #{blue}, 0.8) 70%, #{input} 100%);"
css << "background: -o-linear-gradient(left, rgba(#{red}, #{green}, #{blue}, 0) 0%, rgba(#{red}, #{green}, #{blue}, 0.8) 70%, #{input} 100%);"
css << "background: -ms-linear-gradient(left, rgba(#{red}, #{green}, #{blue}, 0) 0%, rgba(#{red}, #{green}, #{blue}, 0.8) 70%, #{input} 100%);"
css << "background: linear-gradient(to right, rgba(#{red}, #{green}, #{blue}, 0) 0%, rgba(#{red}, #{green}, #{blue}, 0.8) 70%, #{input} 100%);"
css << "filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#{explorerShit}, endColorstr='#{input}',GradientType=1 );"
end
css
end
|