# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 382 def initialize(position_or_angle, color_stops, legacy=false) unless color_stops.value.size >= 2 raise Sass::SyntaxError, "At least two color stops are required for a linear-gradient" end self.position_or_angle = position_or_angle self.color_stops = color_stops self.legacy = legacy end
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 378 def children [color_stops, position_or_angle].compact end
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 402 def convert_to_or_from_legacy(position_or_angle, options = self.options) input = if position_or_angle.is_a?(Sass::Script::Value::Number) position_or_angle else opts(list(position_or_angle.to_s.split(' ').map {|s| identifier(s) }, :space)) end return convert_angle_from_offical(input).to_s(options) end
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 426 def supports?(aspect) # I don't know how to support degree-based gradients in old webkit gradients (owg) or svg so we just disable them. if %(owg).include?(aspect) && position_or_angle.is_a?(Sass::Script::Value::Number) && position_or_angle.numerator_units.include?("deg") false elsif %(owg svg).include?(aspect) && color_stops.value.any?{|cs| cs.stop.is_a?(Sass::Script::Value::String) } # calc expressions cannot be represented in svg or owg false else super end end
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 455 def to_css2(options = self.options) null end
Output the original webkit gradient syntax
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 439 def to_owg(options = self.options) position_list = reverse_side_or_corner(position_or_angle) start_point = grad_point(position_list) args = [] args << start_point args << linear_end_position(position_list, start_point, color_stops.value.last.stop) args << grad_color_stops(color_stops) args.each{|a| a.options = options} Sass::Script::String.new("-webkit-gradient(linear, #{args.join(', ')})") end
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 411 def to_s(options = self.options) s = 'linear-gradient(' if legacy s << convert_to_or_from_legacy(position_or_angle, options) << ", " if position_or_angle else s << position_or_angle.to_s(options) << ", " if position_or_angle end s << color_stops.to_s(options) s << ")" end
# File lib/compass/core/sass_extensions/functions/gradient_support.rb, line 391 def to_s_prefixed(options = self.options) s = "linear-gradient(" if legacy s << position_or_angle.to_s(options) << ", " if position_or_angle else s << convert_to_or_from_legacy(position_or_angle, options) << ", " if position_or_angle end s << color_stops.to_s(options) s << ")" end
Generated with the Darkfish Rdoc Generator 2.