Skip to content

Commit

Permalink
Fix Microsoft.gradient issue with SASS asset compilation. Resolves tw…
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Jackson committed Dec 23, 2011
1 parent 47187a2 commit 2ae6483
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/bootstrap-sass.rb
Expand Up @@ -4,6 +4,8 @@ module Bootstrap
module Rails
class Engine < ::Rails::Engine
# Rails, will you please look in our vendor? kthx

paths["config/initializers"] << 'lib/bootstrap-sass/config'
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions lib/bootstrap-sass/config/bootstrap-sass.rb
@@ -0,0 +1,14 @@
require 'sass'

module Sass::Script::Functions
# LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9
# returns an IE hex string for a color with an alpha channel
# suitable for passing to IE filters.
def ie_hex_str(color)
assert_type color, :Color
alpha = (color.alpha * 255).round
alphastr = alpha.to_s(16).rjust(2, '0')
Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
end
declare :ie_hex_str, [:color]
end
14 changes: 14 additions & 0 deletions lib/bootstrap-sass/config/sass-ie_hex_str.rb
@@ -0,0 +1,14 @@
require 'sass'

module Sass::Script::Functions
# LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9
# returns an IE hex string for a color with an alpha channel
# suitable for passing to IE filters.
def ie_hex_str(color)
assert_type color, :Color
alpha = (color.alpha * 255).round
alphastr = alpha.to_s(16).rjust(2, '0')
Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
end
declare :ie_hex_str, [:color]
end
6 changes: 3 additions & 3 deletions vendor/assets/stylesheets/bootstrap/mixins.css.scss
Expand Up @@ -166,7 +166,7 @@
background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10
background-image: linear-gradient(left, $startColor, $endColor); // Le standard
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=1); // IE9 and down
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($startColor)}', endColorstr='#{ie-hex-str($endColor)}', GradientType=1); // IE9 and down
}
@mixin vertical-gradient($startColor: #555, $endColor: #333) {
background-color: $endColor;
Expand All @@ -178,7 +178,7 @@
background-image: -webkit-linear-gradient(top, $startColor, $endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(top, $startColor, $endColor); // Opera 11.10
background-image: linear-gradient(top, $startColor, $endColor); // The standard
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($startColor)}', endColorstr='#{ie-hex-str($endColor)}', GradientType=0); // IE9 and down
}
@mixin directional-gradient($startColor: #555, $endColor: #333, $deg: 45deg) {
background-color: $endColor;
Expand All @@ -198,7 +198,7 @@
background-image: -ms-linear-gradient($startColor, $midColor $colorStop, $endColor);
background-image: -o-linear-gradient($startColor, $midColor $colorStop, $endColor);
background-image: linear-gradient($startColor, $midColor $colorStop, $endColor);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down, gets no color-stop at all for proper fallback
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($startColor)}', endColorstr='#{ie-hex-str($endColor)}', GradientType=0); // IE9 and down, gets no color-stop at all for proper fallback
}

// Reset filters for IE
Expand Down

0 comments on commit 2ae6483

Please sign in to comment.