compass 0.11.beta.7 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/frameworks/compass/stylesheets/compass/layout/_grid-background.scss +40 -22
- data/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss +6 -1
- data/frameworks/compass/templates/extension/manifest.rb +8 -2
- data/lib/compass/commands/print_version.rb +3 -0
- data/lib/compass/commands/update_project.rb +23 -9
- data/lib/compass/commands/watch_project.rb +41 -8
- data/lib/compass/compiler.rb +2 -3
- data/lib/compass/configuration.rb +34 -0
- data/lib/compass/configuration/adapters.rb +6 -2
- data/lib/compass/configuration/data.rb +1 -0
- data/lib/compass/configuration/defaults.rb +1 -1
- data/lib/compass/configuration/serialization.rb +1 -0
- data/lib/compass/exec/project_options_parser.rb +3 -3
- data/lib/compass/sass_extensions/functions/gradient_support.rb +81 -65
- data/lib/compass/sass_extensions/sprites/sprites.rb +9 -0
- data/lib/compass/version.rb +1 -1
- data/test/configuration_test.rb +67 -6
- data/test/fixtures/stylesheets/blueprint/css/screen.css +1 -1
- data/test/fixtures/stylesheets/blueprint/css/single-imports/debug.css +1 -1
- data/test/fixtures/stylesheets/compass/css/gradients.css +46 -24
- data/test/fixtures/stylesheets/compass/css/grid_background.css +8 -0
- data/test/fixtures/stylesheets/compass/sass/gradients.sass +8 -2
- data/test/fixtures/stylesheets/compass/sass/grid_background.scss +4 -0
- metadata +18 -19
- data/lib/vendor/fssm/fssm.rb +0 -33
- data/lib/vendor/fssm/fssm/backends/fsevents.rb +0 -36
- data/lib/vendor/fssm/fssm/backends/inotify.rb +0 -26
- data/lib/vendor/fssm/fssm/backends/polling.rb +0 -25
- data/lib/vendor/fssm/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/lib/vendor/fssm/fssm/monitor.rb +0 -26
- data/lib/vendor/fssm/fssm/path.rb +0 -91
- data/lib/vendor/fssm/fssm/pathname.rb +0 -502
- data/lib/vendor/fssm/fssm/state/directory.rb +0 -57
- data/lib/vendor/fssm/fssm/state/file.rb +0 -24
- data/lib/vendor/fssm/fssm/support.rb +0 -63
- data/lib/vendor/fssm/fssm/tree.rb +0 -176
data/VERSION.yml
CHANGED
@@ -2,27 +2,34 @@
|
|
2
2
|
@import "compass/css3/background-size";
|
3
3
|
|
4
4
|
// Set the color of your columns
|
5
|
-
$grid-background-column-color : rgba(100, 100, 225, 0.25)
|
5
|
+
$grid-background-column-color : rgba(100, 100, 225, 0.25) !default;
|
6
6
|
// Set the color of your gutters
|
7
|
-
$grid-background-gutter-color : rgba(0, 0, 0, 0)
|
7
|
+
$grid-background-gutter-color : rgba(0, 0, 0, 0) !default;
|
8
8
|
|
9
9
|
// Set the total number of columns in your grid
|
10
|
-
$grid-background-total-columns : 24
|
10
|
+
$grid-background-total-columns : 24 !default;
|
11
11
|
// Set the width of your columns
|
12
|
-
$grid-background-column-width : 30px
|
12
|
+
$grid-background-column-width : 30px !default;
|
13
13
|
// Set the width of your gutters
|
14
|
-
$grid-background-gutter-width : 10px
|
14
|
+
$grid-background-gutter-width : 10px !default;
|
15
15
|
// Set the offset, if your columns are padded in from the container edge
|
16
|
-
$grid-background-offset : 0px
|
16
|
+
$grid-background-offset : 0px !default;
|
17
17
|
|
18
18
|
// Set the color of your baseline
|
19
|
-
$grid-background-baseline-color : rgba(0, 0, 0, 0.5)
|
19
|
+
$grid-background-baseline-color : rgba(0, 0, 0, 0.5) !default;
|
20
20
|
// Set the height of your baseline grid
|
21
|
-
$grid-background-baseline-height : 1.5em
|
21
|
+
$grid-background-baseline-height : 1.5em !default;
|
22
|
+
|
23
|
+
// toggle your columns grids on and off
|
24
|
+
$show-column-grid-backgrounds : true !default;
|
25
|
+
// toggle your vertical grids on and off
|
26
|
+
$show-baseline-grid-backgrounds : true !default;
|
27
|
+
// toggle all your grids on and off
|
28
|
+
$show-grid-backgrounds : true !default;
|
22
29
|
|
23
30
|
// optionally force your grid-image to remain fluid
|
24
31
|
// no matter what units you used to declared your grid.
|
25
|
-
$grid-background-force-fluid : false
|
32
|
+
$grid-background-force-fluid : false !default;
|
26
33
|
|
27
34
|
|
28
35
|
// Create the gradient needed for baseline grids
|
@@ -118,9 +125,11 @@ $grid-background-force-fluid : false !default;
|
|
118
125
|
$baseline : $grid-background-baseline-height,
|
119
126
|
$color : $grid-background-baseline-color
|
120
127
|
) {
|
121
|
-
@
|
122
|
-
|
123
|
-
|
128
|
+
@if $show-grid-backgrounds and $show-baseline-grid-backgrounds {
|
129
|
+
@include background-image(get-baseline-gradient($color));
|
130
|
+
@include background-size(100% $baseline);
|
131
|
+
background-position: left top;
|
132
|
+
}
|
124
133
|
}
|
125
134
|
|
126
135
|
// Add just the horizontal grid to an element's background
|
@@ -133,10 +142,12 @@ $grid-background-force-fluid : false !default;
|
|
133
142
|
$gutter-color : $grid-background-gutter-color,
|
134
143
|
$force-fluid : $grid-background-force-fluid
|
135
144
|
) {
|
136
|
-
@
|
137
|
-
|
138
|
-
|
139
|
-
|
145
|
+
@if $show-grid-backgrounds and $show-column-grid-backgrounds {
|
146
|
+
@include background-image(
|
147
|
+
get-column-gradient($total,$column,$gutter,$offset,$column-color,$gutter-color, $force-fluid)
|
148
|
+
);
|
149
|
+
background-position: left top;
|
150
|
+
}
|
140
151
|
}
|
141
152
|
|
142
153
|
// Add both horizontal and baseline grids to an element's background
|
@@ -151,10 +162,17 @@ $grid-background-force-fluid : false !default;
|
|
151
162
|
$baseline-color : $grid-background-baseline-color,
|
152
163
|
$force-fluid : $grid-background-force-fluid
|
153
164
|
) {
|
154
|
-
@
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
165
|
+
@if $show-grid-backgrounds {
|
166
|
+
@if $show-baseline-grid-backgrounds and $show-column-grid-backgrounds {
|
167
|
+
@include background-image(
|
168
|
+
get-baseline-gradient($baseline-color),
|
169
|
+
get-column-gradient($total,$column,$gutter,$offset,$column-color,$gutter-color, $force-fluid)
|
170
|
+
);
|
171
|
+
@include background-size(100% $baseline, auto);
|
172
|
+
background-position: left top;
|
173
|
+
} @else {
|
174
|
+
@include baseline-grid-background($baseline, $baseline-color);
|
175
|
+
@include column-grid-background($total,$column,$gutter,$offset,$column-color,$gutter-color, $force-fluid);
|
176
|
+
}
|
177
|
+
}
|
160
178
|
}
|
@@ -20,12 +20,17 @@ $sprite-selectors: hover, target, active !default;
|
|
20
20
|
// class or you can specify the `sprite-url` explicitly like this:
|
21
21
|
//
|
22
22
|
// background: $map no-repeat;
|
23
|
+
|
24
|
+
$disable-magic-sprite-selectors:false !default;
|
25
|
+
|
23
26
|
@mixin sprite($map, $sprite, $dimensions: false, $offset-x: 0, $offset-y: 0) {
|
24
27
|
@include sprite-background-position($map, $sprite, $offset-x, $offset-y);
|
25
28
|
@if $dimensions {
|
26
29
|
@include sprite-dimensions($map, $sprite);
|
27
30
|
}
|
28
|
-
@
|
31
|
+
@if not $disable-magic-sprite-selectors {
|
32
|
+
@include sprite-selectors($map, $sprite, $sprite);
|
33
|
+
}
|
29
34
|
}
|
30
35
|
|
31
36
|
// Include the selectors for the `$sprite` given the `$map` and the
|
@@ -1,8 +1,14 @@
|
|
1
1
|
description "Generate a compass extension."
|
2
2
|
|
3
|
-
|
3
|
+
unless options.include?(:preferred_syntax)
|
4
|
+
options[:preferred_syntax] = 'sass'
|
5
|
+
end
|
6
|
+
|
4
7
|
file 'templates/project/manifest.rb'
|
5
|
-
file
|
8
|
+
file "stylesheets/main.sass", :to => "stylesheets/_#{File.basename(options[:pattern_name]||options[:project_name]||'main')}.#{options[:preferred_syntax]}"
|
9
|
+
|
10
|
+
file "templates/project/screen.sass", :to => "templates/project/screen.#{options[:preferred_syntax]}"
|
11
|
+
|
6
12
|
|
7
13
|
help %Q{
|
8
14
|
To generate a compass extension:
|
@@ -57,6 +57,9 @@ Options:
|
|
57
57
|
def long_output_string
|
58
58
|
lines = []
|
59
59
|
lines << "Compass #{::Compass.version[:string]}"
|
60
|
+
if name = ::Compass.version[:name]
|
61
|
+
lines.last << " (#{name})"
|
62
|
+
end
|
60
63
|
lines << "Copyright (c) 2008-#{Time.now.year} Chris Eppstein"
|
61
64
|
lines << "Released under the MIT License."
|
62
65
|
lines << "Compass is charityware."
|
@@ -49,17 +49,28 @@ module Compass
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def new_compiler_instance(additional_options = {})
|
52
|
-
compiler_opts
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
@compiler_opts ||= begin
|
53
|
+
compiler_opts = Compass.sass_engine_options
|
54
|
+
compiler_opts.merge!(:force => options[:force],
|
55
|
+
:sass_files => explicit_sass_files,
|
56
|
+
:dry_run => options[:dry_run])
|
57
|
+
compiler_opts[:quiet] = options[:quiet] if options[:quiet]
|
58
|
+
compiler_opts[:time] = options[:time] if options[:time]
|
59
|
+
compiler_opts
|
60
|
+
end
|
61
|
+
|
62
|
+
@memory_store ||= Sass::CacheStores::Memory.new
|
63
|
+
@backing_store ||= compiler_opts[:cache_store]
|
64
|
+
@backing_store ||= Sass::CacheStores::Filesystem.new(determine_cache_location)
|
65
|
+
@cache_store ||= Sass::CacheStores::Chain.new(@memory_store, @backing_store)
|
66
|
+
@memory_store.reset!
|
67
|
+
|
68
|
+
Compass::Compiler.new(
|
69
|
+
working_path,
|
60
70
|
Compass.configuration.sass_path,
|
61
71
|
Compass.configuration.css_path,
|
62
|
-
compiler_opts)
|
72
|
+
@compiler_opts.merge(:cache_store => @cache_store).merge(additional_options)
|
73
|
+
)
|
63
74
|
end
|
64
75
|
|
65
76
|
def explicit_sass_files
|
@@ -73,6 +84,9 @@ module Compass
|
|
73
84
|
end
|
74
85
|
end
|
75
86
|
|
87
|
+
def determine_cache_location
|
88
|
+
Compass.configuration.cache_path || Sass::Plugin.options[:cache_location] || File.join(working_path, ".sass-cache")
|
89
|
+
end
|
76
90
|
|
77
91
|
class << self
|
78
92
|
def option_parser(arguments)
|
@@ -2,6 +2,7 @@ require 'fileutils'
|
|
2
2
|
require 'pathname'
|
3
3
|
require 'compass/commands/base'
|
4
4
|
require 'compass/commands/update_project'
|
5
|
+
require 'sass/plugin'
|
5
6
|
|
6
7
|
module Compass
|
7
8
|
module Commands
|
@@ -24,12 +25,39 @@ module Compass
|
|
24
25
|
|
25
26
|
end
|
26
27
|
end
|
28
|
+
module MemoryDebugger
|
29
|
+
def report_on_instances(type, options = {})
|
30
|
+
@@runs ||= 0
|
31
|
+
@@runs += 1
|
32
|
+
@@object_id_tracker ||= {}
|
33
|
+
@@object_id_tracker[type] ||= []
|
34
|
+
GC.start
|
35
|
+
sleep options.fetch(:gc_pause, 1)
|
36
|
+
count = ObjectSpace.each_object(type) do |obj|
|
37
|
+
if options.fetch(:verbose, true)
|
38
|
+
if @@runs > 2
|
39
|
+
if !@@object_id_tracker[type].include?(obj.object_id)
|
40
|
+
begin
|
41
|
+
puts obj.inspect
|
42
|
+
rescue
|
43
|
+
end
|
44
|
+
puts "#{obj.class.name}:#{obj.object_id}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
@@object_id_tracker[type] << obj.object_id
|
48
|
+
end
|
49
|
+
end
|
50
|
+
puts "#{type}: #{count} instances."
|
51
|
+
end
|
52
|
+
end
|
27
53
|
class WatchProject < UpdateProject
|
28
54
|
|
29
55
|
register :watch
|
30
56
|
|
31
57
|
attr_accessor :last_update_time, :last_sass_files
|
32
58
|
|
59
|
+
include MemoryDebugger
|
60
|
+
|
33
61
|
def perform
|
34
62
|
Signal.trap("INT") do
|
35
63
|
puts ""
|
@@ -39,12 +67,8 @@ module Compass
|
|
39
67
|
check_for_sass_files!(new_compiler_instance)
|
40
68
|
recompile
|
41
69
|
|
42
|
-
|
43
|
-
|
44
|
-
rescue LoadError
|
45
|
-
$: << File.join(Compass.lib_directory, 'vendor', 'fssm')
|
46
|
-
retry
|
47
|
-
end
|
70
|
+
require 'fssm'
|
71
|
+
|
48
72
|
|
49
73
|
if options[:poll]
|
50
74
|
require "fssm/backends/polling"
|
@@ -58,8 +82,10 @@ module Compass
|
|
58
82
|
|
59
83
|
puts ">>> Compass is #{action} for changes. Press Ctrl-C to Stop."
|
60
84
|
|
85
|
+
begin
|
61
86
|
FSSM.monitor do |monitor|
|
62
87
|
Compass.configuration.sass_load_paths.each do |load_path|
|
88
|
+
load_path = load_path.root if load_path.respond_to?(:root)
|
63
89
|
next unless load_path.is_a? String
|
64
90
|
monitor.path load_path do |path|
|
65
91
|
path.glob '**/*.s[ac]ss'
|
@@ -88,7 +114,12 @@ module Compass
|
|
88
114
|
end
|
89
115
|
|
90
116
|
end
|
91
|
-
|
117
|
+
rescue FSSM::CallbackError => e
|
118
|
+
# FSSM catches exit? WTF.
|
119
|
+
if e.message =~ /exit/
|
120
|
+
exit
|
121
|
+
end
|
122
|
+
end
|
92
123
|
end
|
93
124
|
|
94
125
|
def remove_obsolete_css(base = nil, relative = nil)
|
@@ -103,11 +134,13 @@ module Compass
|
|
103
134
|
end
|
104
135
|
|
105
136
|
def recompile(base = nil, relative = nil)
|
137
|
+
@memory_cache.reset! if @memory_cache
|
106
138
|
compiler = new_compiler_instance(:quiet => true)
|
107
139
|
if file = compiler.out_of_date?
|
108
140
|
begin
|
109
|
-
puts ">>> Change detected to: #{file}"
|
141
|
+
puts ">>> Change detected to: #{relative || compiler.relative_stylesheet_name(file)}"
|
110
142
|
compiler.run
|
143
|
+
GC.start
|
111
144
|
rescue StandardError => e
|
112
145
|
::Compass::Exec::Helpers.report_error(e, options)
|
113
146
|
end
|
data/lib/compass/compiler.rb
CHANGED
@@ -11,8 +11,7 @@ module Compass
|
|
11
11
|
self.logger = options.delete(:logger)
|
12
12
|
self.options = options
|
13
13
|
self.options[:cache_location] ||= determine_cache_location
|
14
|
-
|
15
|
-
self.importer = Sass::Importers::Filesystem.new(from)
|
14
|
+
options[:importer] = self.importer = Sass::Importers::Filesystem.new(from)
|
16
15
|
self.staleness_checker = Sass::Plugin::StalenessChecker.new(options)
|
17
16
|
end
|
18
17
|
|
@@ -58,7 +57,7 @@ module Compass
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def needs_update?(css_filename, sass_filename)
|
61
|
-
staleness_checker.stylesheet_needs_update?(css_filename,
|
60
|
+
staleness_checker.stylesheet_needs_update?(css_filename, File.expand_path(sass_filename), importer)
|
62
61
|
end
|
63
62
|
|
64
63
|
# Determines if the configuration file is newer than any css file
|
@@ -41,6 +41,40 @@ module Compass
|
|
41
41
|
:sprite_engine
|
42
42
|
].flatten
|
43
43
|
|
44
|
+
# Registers a new configuration property.
|
45
|
+
# Extensions can use this to add new configuration options to compass.
|
46
|
+
#
|
47
|
+
# @param [Symbol] name The name of the property.
|
48
|
+
# @param [String] comment A comment for the property.
|
49
|
+
# @param [Proc] default A method to calculate the default value for the property.
|
50
|
+
# The proc is executed in the context of the project's configuration data.
|
51
|
+
def self.add_configuration_property(name, comment = nil, &default)
|
52
|
+
ATTRIBUTES << name
|
53
|
+
if comment.is_a?(String)
|
54
|
+
unless comment[0..0] == "#"
|
55
|
+
comment = "# #{comment}"
|
56
|
+
end
|
57
|
+
unless comment[-1..-1] == "\n"
|
58
|
+
comment = comment + "\n"
|
59
|
+
end
|
60
|
+
Data.class_eval <<-COMMENT
|
61
|
+
def comment_for_#{name}
|
62
|
+
#{comment.inspect}
|
63
|
+
end
|
64
|
+
COMMENT
|
65
|
+
end
|
66
|
+
Data.send(:define_method, :"default_#{name}", &default) if default
|
67
|
+
Data.inherited_accessor(name)
|
68
|
+
if name.to_s =~ /dir|path/
|
69
|
+
strip_trailing_separator(name)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# For testing purposes
|
74
|
+
def self.remove_configuration_property(name)
|
75
|
+
ATTRIBUTES.delete(name)
|
76
|
+
end
|
77
|
+
|
44
78
|
end
|
45
79
|
end
|
46
80
|
|
@@ -55,10 +55,14 @@ module Compass
|
|
55
55
|
def sass_load_paths
|
56
56
|
load_paths = []
|
57
57
|
load_paths << sass_path if sass_path
|
58
|
-
Compass::Frameworks::ALL.each do |
|
59
|
-
load_paths <<
|
58
|
+
Compass::Frameworks::ALL.each do |f|
|
59
|
+
load_paths << f.stylesheets_directory if File.directory?(f.stylesheets_directory)
|
60
60
|
end
|
61
61
|
load_paths += resolve_additional_import_paths
|
62
|
+
load_paths.map! do |p|
|
63
|
+
next p if p.respond_to?(:find_relative)
|
64
|
+
Sass::Importers::Filesystem.new(p.to_s)
|
65
|
+
end
|
62
66
|
load_paths << Compass::Sprites.new
|
63
67
|
load_paths
|
64
68
|
end
|
@@ -125,6 +125,7 @@ module Compass
|
|
125
125
|
Compass::Frameworks.register_directory framework_dir
|
126
126
|
end
|
127
127
|
|
128
|
+
# Finds all extensions within a directory and registers them.
|
128
129
|
def discover(frameworks_dir)
|
129
130
|
(self.framework_path ||= []) << frameworks_dir
|
130
131
|
Compass::Frameworks.discover frameworks_dir
|
@@ -50,6 +50,7 @@ module Compass
|
|
50
50
|
$stderr.puts "WARNING: #{prop} is code and cannot be written to a file. You'll need to copy it yourself."
|
51
51
|
end
|
52
52
|
if respond_to?("comment_for_#{prop}")
|
53
|
+
contents << "\n"
|
53
54
|
contents << send("comment_for_#{prop}")
|
54
55
|
end
|
55
56
|
if block_given? && (to_emit = yield(prop, value))
|
@@ -37,14 +37,14 @@ module Compass::Exec::ProjectOptionsParser
|
|
37
37
|
end
|
38
38
|
|
39
39
|
opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment.',
|
40
|
-
' One of: development
|
40
|
+
' One of: development (default), production') do |env|
|
41
41
|
self.options[:environment] = env
|
42
|
-
|
42
|
+
end
|
43
43
|
|
44
44
|
opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode.',
|
45
45
|
' One of: nested, expanded, compact, compressed') do |style|
|
46
46
|
self.options[:output_style] = style
|
47
|
-
|
47
|
+
end
|
48
48
|
|
49
49
|
opts.on('--relative-assets', :NONE, 'Make compass asset helpers generate relative urls to assets.') do
|
50
50
|
self.options[:relative_assets] = true
|
@@ -33,82 +33,112 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
module Gradient
|
37
|
+
|
38
|
+
def self.included(base)
|
39
|
+
base.extend ClassMethods
|
40
|
+
end
|
41
|
+
|
42
|
+
module ClassMethods
|
43
|
+
def standardized_prefix(prefix)
|
44
|
+
class_eval %Q{
|
45
|
+
def to_#{prefix}(options = self.options)
|
46
|
+
Sass::Script::String.new("-#{prefix}-\#{to_s(options)}")
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def inspect
|
53
|
+
to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
def supports?(aspect)
|
57
|
+
GRADIENT_ASPECTS.include?(aspect)
|
58
|
+
end
|
59
|
+
|
60
|
+
def has_aspect?
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
def angle?(value)
|
65
|
+
value.is_a?(Sass::Script::Number) &&
|
66
|
+
value.numerator_units.size == 1 &&
|
67
|
+
value.numerator_units.first == "deg" &&
|
68
|
+
value.denominator_units.empty?
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
36
73
|
class RadialGradient < Sass::Script::Literal
|
37
|
-
|
74
|
+
include Gradient
|
75
|
+
|
76
|
+
attr_accessor :position, :shape_and_size, :color_stops
|
77
|
+
|
38
78
|
def children
|
39
|
-
[color_stops,
|
79
|
+
[color_stops, position, shape_and_size].compact
|
40
80
|
end
|
41
|
-
|
81
|
+
|
82
|
+
def initialize(position, shape_and_size, color_stops)
|
42
83
|
unless color_stops.value.size >= 2
|
43
84
|
raise Sass::SyntaxError, "At least two color stops are required for a radial-gradient"
|
44
85
|
end
|
45
|
-
|
86
|
+
if angle?(position)
|
87
|
+
raise Sass::SyntaxError, "CSS no longer allows angles in radial-gradients."
|
88
|
+
end
|
89
|
+
self.position = position
|
46
90
|
self.shape_and_size = shape_and_size
|
47
91
|
self.color_stops = color_stops
|
48
92
|
end
|
49
|
-
|
50
|
-
to_s
|
51
|
-
end
|
93
|
+
|
52
94
|
def to_s(options = self.options)
|
53
95
|
s = "radial-gradient("
|
54
|
-
s <<
|
96
|
+
s << position.to_s(options) << ", " if position
|
55
97
|
s << shape_and_size.to_s(options) << ", " if shape_and_size
|
56
98
|
s << color_stops.to_s(options)
|
57
99
|
s << ")"
|
58
100
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
Compass::Util.compass_warn("Warning: Angle-based gradients are not yet supported in SVG. Found: #{position_or_angle}")
|
65
|
-
false
|
66
|
-
end
|
67
|
-
else
|
68
|
-
GRADIENT_ASPECTS.include?(aspect)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
def has_aspect?
|
72
|
-
true
|
73
|
-
end
|
74
|
-
def to_webkit(options = self.options)
|
75
|
-
Sass::Script::String.new("-webkit-#{to_s(options)}")
|
76
|
-
end
|
101
|
+
|
102
|
+
standardized_prefix :webkit
|
103
|
+
standardized_prefix :moz
|
104
|
+
standardized_prefix :o
|
105
|
+
|
77
106
|
def to_owg(options = self.options)
|
78
107
|
args = [
|
79
|
-
grad_point(
|
108
|
+
grad_point(position || _center_position),
|
80
109
|
Sass::Script::String.new("0"),
|
81
|
-
grad_point(
|
110
|
+
grad_point(position || _center_position),
|
82
111
|
grad_end_position(color_stops, Sass::Script::Bool.new(true)),
|
83
112
|
grad_color_stops(color_stops)
|
84
113
|
]
|
85
114
|
args.each {|a| a.options = options}
|
86
115
|
Sass::Script::String.new("-webkit-gradient(radial, #{args.join(', ')})")
|
87
116
|
end
|
88
|
-
|
89
|
-
Sass::Script::String.new("-moz-#{to_s(options)}")
|
90
|
-
end
|
91
|
-
def to_o(options = self.options)
|
92
|
-
Sass::Script::String.new("-o-#{to_s(options)}")
|
93
|
-
end
|
117
|
+
|
94
118
|
def to_svg(options = self.options)
|
95
119
|
# XXX Add shape support if possible
|
96
|
-
radial_svg_gradient(color_stops,
|
120
|
+
radial_svg_gradient(color_stops, position || _center_position)
|
97
121
|
end
|
122
|
+
|
98
123
|
def to_pie(options = self.options)
|
99
124
|
Compass::Logger.new.record(:warning, "PIE does not support radial-gradient.")
|
100
125
|
Sass::Script::String.new("-pie-radial-gradient(unsupported)")
|
101
126
|
end
|
127
|
+
|
102
128
|
def to_css2(options = self.options)
|
103
129
|
Sass::Script::String.new("")
|
104
130
|
end
|
105
131
|
end
|
106
132
|
|
107
133
|
class LinearGradient < Sass::Script::Literal
|
134
|
+
include Gradient
|
135
|
+
|
108
136
|
attr_accessor :color_stops, :position_or_angle
|
137
|
+
|
109
138
|
def children
|
110
139
|
[color_stops, position_or_angle].compact
|
111
140
|
end
|
141
|
+
|
112
142
|
def initialize(position_or_angle, color_stops)
|
113
143
|
unless color_stops.value.size >= 2
|
114
144
|
raise Sass::SyntaxError, "At least two color stops are required for a linear-gradient"
|
@@ -116,33 +146,18 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
116
146
|
self.position_or_angle = position_or_angle
|
117
147
|
self.color_stops = color_stops
|
118
148
|
end
|
119
|
-
|
120
|
-
to_s
|
121
|
-
end
|
149
|
+
|
122
150
|
def to_s(options = self.options)
|
123
151
|
s = "linear-gradient("
|
124
152
|
s << position_or_angle.to_s(options) << ", " if position_or_angle
|
125
153
|
s << color_stops.to_s(options)
|
126
154
|
s << ")"
|
127
155
|
end
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
Compass::Util.compass_warn("Warning: Angle-based gradients are not yet supported in SVG. Found: #{position_or_angle}")
|
134
|
-
false
|
135
|
-
end
|
136
|
-
else
|
137
|
-
GRADIENT_ASPECTS.include?(aspect)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
def has_aspect?
|
141
|
-
true
|
142
|
-
end
|
143
|
-
def to_webkit(options = self.options)
|
144
|
-
Sass::Script::String.new("-webkit-#{to_s(options)}")
|
145
|
-
end
|
156
|
+
|
157
|
+
standardized_prefix :webkit
|
158
|
+
standardized_prefix :moz
|
159
|
+
standardized_prefix :o
|
160
|
+
|
146
161
|
# Output the original webkit gradient syntax
|
147
162
|
def to_owg(options = self.options)
|
148
163
|
args = []
|
@@ -152,20 +167,17 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
152
167
|
args.each{|a| a.options = options}
|
153
168
|
Sass::Script::String.new("-webkit-gradient(linear, #{args.join(', ')})")
|
154
169
|
end
|
155
|
-
|
156
|
-
Sass::Script::String.new("-moz-#{to_s(options)}")
|
157
|
-
end
|
158
|
-
def to_o(options = self.options)
|
159
|
-
Sass::Script::String.new("-o-#{to_s(options)}")
|
160
|
-
end
|
170
|
+
|
161
171
|
def to_svg(options = self.options)
|
162
172
|
linear_svg_gradient(color_stops, position_or_angle || Sass::Script::String.new("top"))
|
163
173
|
end
|
174
|
+
|
164
175
|
def to_pie(options = self.options)
|
165
176
|
# PIE just uses the standard rep, but the property is prefixed so
|
166
177
|
# the presence of this attribute helps flag when to render a special rule.
|
167
178
|
Sass::Script::String.new to_s(options)
|
168
179
|
end
|
180
|
+
|
169
181
|
def to_css2(options = self.options)
|
170
182
|
Sass::Script::String.new("")
|
171
183
|
end
|
@@ -289,7 +301,7 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
289
301
|
stop = pos.stop
|
290
302
|
stop = stop.div(max).times(Sass::Script::Number.new(100,["%"])) if stop.numerator_units == max.numerator_units && max.numerator_units != ["%"]
|
291
303
|
# Make sure the color stops are specified in the right order.
|
292
|
-
if last_value && stop.numerator_units == last_value.numerator_units && stop.denominator_units == last_value.denominator_units && stop.value < last_value.value
|
304
|
+
if last_value && stop.numerator_units == last_value.numerator_units && stop.denominator_units == last_value.denominator_units && (stop.value * 1000).round < (last_value.value * 1000).round
|
293
305
|
raise Sass::SyntaxError.new("Color stops must be specified in increasing order. #{stop.value} came after #{last_value.value}.")
|
294
306
|
end
|
295
307
|
last_value = stop
|
@@ -445,9 +457,13 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
445
457
|
arg.all?{|a| color_stop?(a)} ? arg : nil
|
446
458
|
end
|
447
459
|
end
|
448
|
-
|
460
|
+
|
449
461
|
def linear_svg(color_stops, x1, y1, x2, y2)
|
450
|
-
|
462
|
+
transform = ''
|
463
|
+
if angle?(position_or_angle)
|
464
|
+
transform = %Q{ gradientTransform = "rotate(#{position_or_angle.value})"}
|
465
|
+
end
|
466
|
+
gradient = %Q{<linearGradient id="grad" gradientUnits="userSpaceOnUse" x1="#{x1}" y1="#{y1}" x2="#{x2}" y2="#{y2}"#{transform}>#{color_stops_svg(color_stops)}</linearGradient>}
|
451
467
|
svg(gradient)
|
452
468
|
end
|
453
469
|
|