Skip to content

Commit

Permalink
Merge pull request twbs#20 from rjackson/master
Browse files Browse the repository at this point in the history
Add function to handle IE Hex based color strings.  Resolves twbs#14.
  • Loading branch information
thomas-mcdonald committed Jan 17, 2012
2 parents 38d99c7 + 2cf32b0 commit 4a41b6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/bootstrap-sass.rb
Original file line number Diff line number Diff line change
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/sass-ie_hex_str.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 4a41b6b

Please sign in to comment.