compass 0.13.alpha.4 → 0.13.alpha.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.markdown +2 -3
- data/Rakefile +91 -5
- data/VERSION.yml +1 -1
- data/examples/compass/images/emblem-a043c4f148.png +0 -0
- data/examples/compass/images/flag-03c3b29b35.png +0 -0
- data/examples/compass/images/flag-21cfbfbfc8.png +0 -0
- data/examples/css3/extensions/fancy-fonts/templates/project/Prociono.otf +0 -0
- data/features/command_line.feature +2 -6
- data/features/step_definitions/command_line_steps.rb +1 -0
- data/frameworks/compass/stylesheets/compass/_css3.scss +0 -1
- data/frameworks/compass/stylesheets/compass/_support.scss +353 -35
- data/frameworks/compass/stylesheets/compass/css3/_animation.scss +49 -48
- data/frameworks/compass/stylesheets/compass/css3/_appearance.scss +4 -8
- data/frameworks/compass/stylesheets/compass/css3/_background-clip.scss +15 -19
- data/frameworks/compass/stylesheets/compass/css3/_background-origin.scss +17 -19
- data/frameworks/compass/stylesheets/compass/css3/_background-size.scss +4 -8
- data/frameworks/compass/stylesheets/compass/css3/_border-radius.scss +37 -39
- data/frameworks/compass/stylesheets/compass/css3/_box-shadow.scss +45 -20
- data/frameworks/compass/stylesheets/compass/css3/_box-sizing.scss +6 -8
- data/frameworks/compass/stylesheets/compass/css3/_box.scss +12 -13
- data/frameworks/compass/stylesheets/compass/css3/_columns.scss +46 -26
- data/frameworks/compass/stylesheets/compass/css3/_deprecated-support.scss +272 -0
- data/frameworks/compass/stylesheets/compass/css3/_filter.scss +17 -10
- data/frameworks/compass/stylesheets/compass/css3/_flexbox.scss +134 -281
- data/frameworks/compass/stylesheets/compass/css3/_font-face.scss +5 -5
- data/frameworks/compass/stylesheets/compass/css3/_hyphenation.scss +14 -11
- data/frameworks/compass/stylesheets/compass/css3/_images.scss +77 -67
- data/frameworks/compass/stylesheets/compass/css3/_inline-block.scss +15 -6
- data/frameworks/compass/stylesheets/compass/css3/_opacity.scss +6 -2
- data/frameworks/compass/stylesheets/compass/css3/_pie.scss +1 -73
- data/frameworks/compass/stylesheets/compass/css3/_regions.scss +7 -6
- data/frameworks/compass/stylesheets/compass/css3/_selection.scss +45 -17
- data/frameworks/compass/stylesheets/compass/css3/_shared.scss +4 -261
- data/frameworks/compass/stylesheets/compass/css3/_text-shadow.scss +1 -1
- data/frameworks/compass/stylesheets/compass/css3/_transform.scss +24 -32
- data/frameworks/compass/stylesheets/compass/css3/_transition.scss +102 -152
- data/frameworks/compass/stylesheets/compass/css3/_user-interface.scss +42 -27
- data/frameworks/compass/stylesheets/compass/typography/_vertical_rhythm.scss +2 -1
- data/frameworks/compass/stylesheets/compass/typography/links/_hover-link.scss +1 -1
- data/frameworks/compass/stylesheets/compass/typography/lists/_horizontal-list.scss +2 -2
- data/frameworks/compass/stylesheets/compass/typography/lists/_inline-list.scss +1 -1
- data/frameworks/compass/stylesheets/compass/typography/text/_ellipsis.scss +1 -1
- data/frameworks/compass/stylesheets/compass/utilities/_sass.scss +2 -0
- data/frameworks/compass/stylesheets/compass/utilities/color/_brightness.scss +12 -0
- data/frameworks/compass/stylesheets/compass/utilities/color/_contrast.scss +36 -12
- data/frameworks/compass/stylesheets/compass/utilities/general/_float.scss +6 -2
- data/frameworks/compass/stylesheets/compass/utilities/general/_hacks.scss +23 -4
- data/frameworks/compass/stylesheets/compass/utilities/general/_min.scss +1 -1
- data/frameworks/compass/stylesheets/compass/utilities/sass/_lists.scss +16 -0
- data/frameworks/compass/stylesheets/compass/utilities/sass/_maps.scss +19 -0
- data/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss +25 -18
- data/frameworks/compass/stylesheets/compass/utilities/sprites/_sprite-img.scss +3 -1
- data/frameworks/compass/stylesheets/compass/utilities/tables/_borders.scss +3 -3
- data/lib/compass.rb +1 -1
- data/lib/compass/browser_support.rb +1 -1
- data/lib/compass/caniuse.rb +247 -0
- data/lib/compass/configuration/adapters.rb +7 -1
- data/lib/compass/sass_extensions/functions.rb +5 -0
- data/lib/compass/sass_extensions/functions/constants.rb +2 -2
- data/lib/compass/sass_extensions/functions/cross_browser_support.rb +176 -1
- data/lib/compass/sass_extensions/functions/display.rb +24 -19
- data/lib/compass/sass_extensions/functions/env.rb +37 -8
- data/lib/compass/sass_extensions/functions/gradient_support.rb +10 -13
- data/lib/compass/sass_extensions/functions/math.rb +31 -13
- data/lib/compass/sass_extensions/functions/sprites.rb +48 -25
- data/lib/compass/sass_extensions/monkey_patches/browser_support.rb +42 -13
- data/lib/compass/sass_extensions/sprites/image.rb +14 -4
- data/lib/compass/sass_extensions/sprites/image_methods.rb +19 -3
- data/lib/compass/sprite_importer/content.erb +8 -7
- data/lib/compass/watcher/project_watcher.rb +75 -42
- data/lib/compass/watcher/watch.rb +35 -17
- data/test/fixtures/sprites/public/images/focus/ten-by-ten.png +0 -0
- data/test/fixtures/sprites/public/images/focus/ten-by-ten_active.png +0 -0
- data/test/fixtures/sprites/public/images/focus/ten-by-ten_focus.png +0 -0
- data/test/fixtures/sprites/public/images/focus/ten-by-ten_hover.png +0 -0
- data/test/fixtures/sprites/public/images/focus/ten-by-ten_target.png +0 -0
- data/test/fixtures/stylesheets/compass/config.rb +1 -0
- data/test/fixtures/stylesheets/compass/css/animation-with-legacy-ie.css +1 -9
- data/test/fixtures/stylesheets/compass/css/animation.css +1 -9
- data/test/fixtures/stylesheets/compass/css/appearance.css +3 -0
- data/test/fixtures/stylesheets/compass/css/background-clip.css +4 -8
- data/test/fixtures/stylesheets/compass/css/background-origin.css +4 -8
- data/test/fixtures/stylesheets/compass/css/background-size.css +3 -10
- data/test/fixtures/stylesheets/compass/css/border_radius.css +3 -3
- data/test/fixtures/stylesheets/compass/css/{box-sizeing.css → box-sizing.css} +2 -2
- data/test/fixtures/stylesheets/compass/css/box_shadow.css +15 -5
- data/test/fixtures/stylesheets/compass/css/brightness.css +14 -0
- data/test/fixtures/stylesheets/compass/css/browser-support.css +306 -0
- data/test/fixtures/stylesheets/compass/css/color.css +18 -0
- data/test/fixtures/stylesheets/compass/css/columns.css +27 -18
- data/test/fixtures/stylesheets/compass/css/filters.css +6 -6
- data/test/fixtures/stylesheets/compass/css/flexbox.css +84 -111
- data/test/fixtures/stylesheets/compass/css/fonts.css +1 -1
- data/test/fixtures/stylesheets/compass/css/gradients.css +53 -53
- data/test/fixtures/stylesheets/compass/css/grid_background.css +11 -11
- data/test/fixtures/stylesheets/compass/css/hyphenation.css +2 -4
- data/test/fixtures/stylesheets/compass/css/lists.css +6 -12
- data/test/fixtures/stylesheets/compass/css/regions.css +2 -2
- data/test/fixtures/stylesheets/compass/css/selection.css +41 -4
- data/test/fixtures/stylesheets/compass/css/sprites_with_explicit_separator.css +16 -0
- data/test/fixtures/stylesheets/compass/css/support.css +62 -0
- data/test/fixtures/stylesheets/compass/css/transform.css +64 -136
- data/test/fixtures/stylesheets/compass/css/transition.css +27 -45
- data/test/fixtures/stylesheets/compass/css/typography/links/hover-link.css +4 -0
- data/test/fixtures/stylesheets/compass/css/user-interface.css +34 -7
- data/test/fixtures/stylesheets/compass/css/utilities.css +7 -7
- data/test/fixtures/stylesheets/compass/css/vertical_rhythm.css +6 -9
- data/test/fixtures/stylesheets/compass/images/flag_states-sc42d7bf926.png +0 -0
- data/test/fixtures/stylesheets/compass/images/flag_states/foo.png +0 -0
- data/test/fixtures/stylesheets/compass/images/flag_states/foo_active.png +0 -0
- data/test/fixtures/stylesheets/compass/images/flag_states/foo_focus.png +0 -0
- data/test/fixtures/stylesheets/compass/images/flag_states/foo_hover.png +0 -0
- data/test/fixtures/stylesheets/compass/images/flag_states/foo_target.png +0 -0
- data/test/fixtures/stylesheets/compass/sass/animation-with-legacy-ie.scss +1 -3
- data/test/fixtures/stylesheets/compass/sass/appearance.scss +5 -0
- data/test/fixtures/stylesheets/compass/sass/background-clip.scss +0 -5
- data/test/fixtures/stylesheets/compass/sass/background-origin.scss +0 -5
- data/test/fixtures/stylesheets/compass/sass/background-size.scss +0 -5
- data/test/fixtures/stylesheets/compass/sass/{box-sizeing.scss → box-sizing.scss} +1 -1
- data/test/fixtures/stylesheets/compass/sass/box_shadow.scss +2 -0
- data/test/fixtures/stylesheets/compass/sass/brightness.scss +12 -0
- data/test/fixtures/stylesheets/compass/sass/browser-support.scss +30 -0
- data/test/fixtures/stylesheets/compass/sass/color.scss +22 -0
- data/test/fixtures/stylesheets/compass/sass/filters.scss +1 -0
- data/test/fixtures/stylesheets/compass/sass/flexbox.scss +84 -40
- data/test/fixtures/stylesheets/compass/sass/gradients.sass +3 -2
- data/test/fixtures/stylesheets/compass/sass/selection.scss +29 -4
- data/test/fixtures/stylesheets/compass/sass/sprites_with_explicit_separator.scss +7 -0
- data/test/fixtures/stylesheets/compass/sass/support.scss +137 -0
- data/test/fixtures/stylesheets/compass/sass/transition.scss +0 -3
- data/test/fixtures/stylesheets/compass/sass/typography/links/hover-link.scss +3 -0
- data/test/fixtures/stylesheets/compass/sass/user-interface.scss +16 -5
- data/test/fixtures/stylesheets/compass/sass/utilities.scss +4 -4
- data/test/fixtures/stylesheets/envtest/css/env.css +4 -4
- data/test/fixtures/stylesheets/envtest/tmp/env.css +4 -4
- data/test/integrations/sprites_test.rb +30 -1
- data/test/test_helper.rb +2 -2
- data/test/units/caniuse_test.rb +115 -0
- data/test/units/command_line_test.rb +1 -0
- data/test/units/sass_extensions_test.rb +5 -0
- data/test/units/sprites/image_test.rb +12 -0
- data/test/units/sprites/sprite_map_test.rb +11 -0
- data/test/units/watcher/project_watcher_test.rb +26 -18
- metadata +96 -42
- data/examples/compass/src/pie.scss +0 -110
- data/frameworks/compass/stylesheets/compass/css3/_transform-legacy.scss +0 -87
- data/frameworks/compass/templates/pie/LICENSE +0 -12
- data/frameworks/compass/templates/pie/LICENSE-APACHE2.txt +0 -13
- data/frameworks/compass/templates/pie/LICENSE-GPL2.txt +0 -278
- data/frameworks/compass/templates/pie/PIE.htc +0 -96
- data/frameworks/compass/templates/pie/manifest.rb +0 -39
- data/frameworks/compass/templates/pie/pie.scss +0 -74
- data/lib/compass/sass_extensions/functions/utility.rb +0 -10
- data/test/fixtures/stylesheets/compass/css/pie.css +0 -23
- data/test/fixtures/stylesheets/compass/sass/pie.scss +0 -47
@@ -1,27 +1,32 @@
|
|
1
1
|
module Compass::SassExtensions::Functions::Display
|
2
2
|
DEFAULT_DISPLAY = {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
"block" => %w{address article aside blockquote center dir div dd details dl dt fieldset
|
4
|
+
figcaption figure form footer frameset h1 h2 h3 h4 h5 h6 hr header hgroup
|
5
|
+
isindex menu nav noframes noscript ol p pre section summary ul},
|
6
|
+
"inline" => %w{a abbr acronym audio b basefont bdo big br canvas cite code command
|
7
|
+
datalist dfn em embed font i img input keygen kbd label mark meter output
|
8
|
+
progress q rp rt ruby s samp select small span strike strong sub
|
9
|
+
sup textarea time tt u var video wbr},
|
10
|
+
"inline-block" => %w{img},
|
11
|
+
"table" => %w{table},
|
12
|
+
"list-item" => %w{li},
|
13
|
+
"table-row-group" => %w{tbody},
|
14
|
+
"table-header-group" => %w{thead},
|
15
|
+
"table-footer-group" => %w{tfoot},
|
16
|
+
"table-row" => %w{tr},
|
17
|
+
"table-cell" => %w{th td},
|
18
|
+
"html5-block" => %w{article aside details figcaption figure footer header hgroup menu nav
|
19
|
+
section summary},
|
20
|
+
"html5-inline" => %w{audio canvas command datalist embed keygen mark meter output progress rp
|
21
|
+
rt ruby time video wbr},
|
22
|
+
"text-input" => %w{input textarea}
|
20
23
|
}
|
21
|
-
|
24
|
+
|
25
|
+
DEFAULT_DISPLAY["html5"] = (DEFAULT_DISPLAY["html5-block"] + DEFAULT_DISPLAY["html5-inline"]).sort.uniq
|
26
|
+
|
22
27
|
# returns a comma delimited string for all the
|
23
28
|
# elements according to their default css3 display value.
|
24
29
|
def elements_of_type(display)
|
25
|
-
Sass::Script::String.new(DEFAULT_DISPLAY.fetch(display.value.
|
30
|
+
Sass::Script::String.new(DEFAULT_DISPLAY.fetch(display.value.to_s).join(", "))
|
26
31
|
end
|
27
32
|
end
|
@@ -1,23 +1,52 @@
|
|
1
1
|
module Compass::SassExtensions::Functions::Env
|
2
|
+
extend Compass::SassExtensions::Functions::SassDeclarationHelper
|
2
3
|
|
3
4
|
def compass_env
|
4
5
|
Sass::Script::String.new((options[:compass][:environment] || "development").to_s)
|
5
6
|
end
|
7
|
+
register_sass_function :compass_env, []
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Sass::Script::String.new(
|
9
|
+
DEFAULT_TIME = Sass::Script::String.new("%T%:z")
|
10
|
+
def current_time(format = DEFAULT_TIME)
|
11
|
+
assert_type format, :String
|
12
|
+
Sass::Script::String.new(Time.now.strftime(format.value))
|
11
13
|
end
|
14
|
+
register_sass_function :current_time, []
|
15
|
+
register_sass_function :current_time, [:format]
|
12
16
|
|
13
|
-
|
17
|
+
DEFAULT_DATE = Sass::Script::String.new("%F")
|
18
|
+
def current_date(format = DEFAULT_DATE)
|
19
|
+
current_time(format)
|
20
|
+
end
|
21
|
+
register_sass_function :current_date, []
|
22
|
+
register_sass_function :current_date, [:format]
|
14
23
|
|
15
|
-
|
16
|
-
|
24
|
+
NOT_ABSOLUTE = Sass::Script::Bool.new(false)
|
25
|
+
def current_source_file(absolute = NOT_ABSOLUTE)
|
26
|
+
if absolute.to_bool
|
27
|
+
Sass::Script::String.new(options[:original_filename].to_s)
|
28
|
+
else
|
29
|
+
filename = Pathname.new(options[:original_filename].to_s)
|
30
|
+
sass_path = Pathname.new(Compass.configuration.sass_path)
|
31
|
+
relative_filename = filename.relative_path_from(sass_path).to_s rescue path
|
32
|
+
Sass::Script::String.new(relative_filename)
|
33
|
+
end
|
17
34
|
end
|
35
|
+
register_sass_function :current_source_file, []
|
36
|
+
register_sass_function :current_source_file, [:absolute]
|
18
37
|
|
19
|
-
def current_output_file
|
38
|
+
def current_output_file(absolute = NOT_ABSOLUTE)
|
20
39
|
Sass::Script::String.new(options[:css_filename].to_s)
|
40
|
+
if absolute.to_bool
|
41
|
+
Sass::Script::String.new(options[:css_filename].to_s)
|
42
|
+
else
|
43
|
+
filename = Pathname.new(options[:css_filename].to_s)
|
44
|
+
css_path = Pathname.new(Compass.configuration.css_path)
|
45
|
+
relative_filename = filename.relative_path_from(css_path).to_s rescue path
|
46
|
+
Sass::Script::String.new(relative_filename)
|
47
|
+
end
|
21
48
|
end
|
49
|
+
register_sass_function :current_output_file, []
|
50
|
+
register_sass_function :current_output_file, [:absolute]
|
22
51
|
|
23
52
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Compass::SassExtensions::Functions::GradientSupport
|
2
2
|
|
3
|
-
GRADIENT_ASPECTS = %w(webkit moz svg
|
3
|
+
GRADIENT_ASPECTS = %w(webkit moz svg css2 o owg).freeze
|
4
4
|
|
5
5
|
class ColorStop < Sass::Script::Literal
|
6
6
|
attr_accessor :color, :stop
|
@@ -67,6 +67,10 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
67
67
|
end
|
68
68
|
s
|
69
69
|
end
|
70
|
+
|
71
|
+
def to_sass(options = nil)
|
72
|
+
Sass::Script::String.new("color-stop(#{color.to_sass rescue nil}, #{stop.to_sass rescue nil})")
|
73
|
+
end
|
70
74
|
end
|
71
75
|
|
72
76
|
module Gradient
|
@@ -97,6 +101,10 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
97
101
|
true
|
98
102
|
end
|
99
103
|
|
104
|
+
def is_position(pos)
|
105
|
+
pos.value =~ Compass::SassExtensions::Functions::Constants::POSITIONS
|
106
|
+
end
|
107
|
+
|
100
108
|
def angle?(value)
|
101
109
|
value.is_a?(Sass::Script::Number) &&
|
102
110
|
value.numerator_units.size == 1 &&
|
@@ -148,11 +156,6 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
148
156
|
radial_svg_gradient(color_stops, position || _center_position)
|
149
157
|
end
|
150
158
|
|
151
|
-
def to_pie(options = self.options)
|
152
|
-
Compass::Logger.new.record(:warning, "PIE does not support radial-gradient.")
|
153
|
-
Sass::Script::String.new("-pie-radial-gradient(unsupported)")
|
154
|
-
end
|
155
|
-
|
156
159
|
def to_css2(options = self.options)
|
157
160
|
Sass::Script::String.new("")
|
158
161
|
end
|
@@ -224,12 +227,6 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
224
227
|
linear_svg_gradient(color_stops, position_or_angle || Sass::Script::String.new("top"))
|
225
228
|
end
|
226
229
|
|
227
|
-
def to_pie(options = self.options)
|
228
|
-
# PIE just uses the standard rep, but the property is prefixed so
|
229
|
-
# the presence of this attribute helps flag when to render a special rule.
|
230
|
-
Sass::Script::String.new to_s(options)
|
231
|
-
end
|
232
|
-
|
233
230
|
def to_css2(options = self.options)
|
234
231
|
Sass::Script::String.new("")
|
235
232
|
end
|
@@ -269,7 +266,7 @@ module Compass::SassExtensions::Functions::GradientSupport
|
|
269
266
|
Sass::Script::List.new(position.value.dup, position.separator)
|
270
267
|
end
|
271
268
|
# Handle unknown arguments by passing them along untouched.
|
272
|
-
unless position.value.all?{|p| is_position(p)
|
269
|
+
unless position.value.all?{|p| is_position(p) }
|
273
270
|
return original_value
|
274
271
|
end
|
275
272
|
if (position.value.first.value =~ /top|bottom/) or (position.value.last.value =~ /left|right/)
|
@@ -1,9 +1,12 @@
|
|
1
1
|
module Compass::SassExtensions::Functions::Math
|
2
2
|
|
3
|
+
extend Compass::SassExtensions::Functions::SassDeclarationHelper
|
4
|
+
|
5
|
+
PI = Sass::Script::Number.new(Math::PI)
|
3
6
|
def pi()
|
4
|
-
|
7
|
+
PI
|
5
8
|
end
|
6
|
-
|
9
|
+
register_sass_function :pi, []
|
7
10
|
|
8
11
|
def random(*args)
|
9
12
|
value = if args.length == 1
|
@@ -14,28 +17,43 @@ module Compass::SassExtensions::Functions::Math
|
|
14
17
|
end
|
15
18
|
Sass::Script::Number.new(value)
|
16
19
|
end
|
17
|
-
|
18
|
-
|
20
|
+
register_sass_function :random, [:limit]
|
21
|
+
register_sass_function :random, [:start, :limit]
|
19
22
|
|
20
23
|
def sin(number)
|
21
24
|
trig(:sin, number)
|
22
25
|
end
|
23
|
-
|
26
|
+
register_sass_function :sin, [:number]
|
27
|
+
|
28
|
+
def asin(number)
|
29
|
+
trig(:asin, number)
|
30
|
+
end
|
31
|
+
register_sass_function :asin, [:number]
|
24
32
|
|
25
33
|
def cos(number)
|
26
34
|
trig(:cos, number)
|
27
35
|
end
|
28
|
-
|
36
|
+
register_sass_function :cos, [:number]
|
37
|
+
|
38
|
+
def acos(number)
|
39
|
+
trig(:acos, number)
|
40
|
+
end
|
41
|
+
register_sass_function :acos, [:number]
|
29
42
|
|
30
43
|
def tan(number)
|
31
44
|
trig(:tan, number)
|
32
45
|
end
|
33
|
-
|
46
|
+
register_sass_function :tan, [:number]
|
47
|
+
|
48
|
+
def atan(number)
|
49
|
+
trig(:atan, number)
|
50
|
+
end
|
51
|
+
register_sass_function :atan, [:number]
|
34
52
|
|
35
53
|
def e
|
36
54
|
Sass::Script::Number.new(Math::E)
|
37
55
|
end
|
38
|
-
|
56
|
+
register_sass_function :e, []
|
39
57
|
|
40
58
|
def logarithm(number, base = e )
|
41
59
|
assert_type number, :Number
|
@@ -45,16 +63,16 @@ module Compass::SassExtensions::Functions::Math
|
|
45
63
|
result = Math.log(number.value, base.value) rescue Math.log(number.value) / Math.log(base.value)
|
46
64
|
Sass::Script::Number.new(result, number.numerator_units, number.denominator_units)
|
47
65
|
end
|
48
|
-
|
49
|
-
|
66
|
+
register_sass_function :logarithm, [:number]
|
67
|
+
register_sass_function :logarithm, [:number, :base]
|
50
68
|
|
51
69
|
def sqrt(number)
|
52
70
|
numeric_transformation(number) { |n| Math.sqrt(n) }
|
53
71
|
end
|
54
|
-
|
72
|
+
register_sass_function :sqrt, [:number]
|
55
73
|
|
56
74
|
alias square_root sqrt
|
57
|
-
|
75
|
+
register_sass_function :square_root, [:number]
|
58
76
|
|
59
77
|
def pow(number, exponent)
|
60
78
|
assert_type number, :Number
|
@@ -62,7 +80,7 @@ module Compass::SassExtensions::Functions::Math
|
|
62
80
|
raise Sass::SyntaxError, "exponent to pow must be unitless." unless exponent.unitless?
|
63
81
|
Sass::Script::Number.new(number.value**exponent.value, number.numerator_units, number.denominator_units)
|
64
82
|
end
|
65
|
-
|
83
|
+
register_sass_function :pow, [:number, :exponent]
|
66
84
|
|
67
85
|
private
|
68
86
|
def trig(operation, number)
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module Compass::SassExtensions::Functions::Sprites
|
2
|
+
|
3
|
+
extend Compass::SassExtensions::Functions::SassDeclarationHelper
|
4
|
+
|
2
5
|
ZERO = Sass::Script::Number::new(0)
|
3
6
|
BOOL_FALSE = Sass::Script::Bool::new(false)
|
4
|
-
VALID_SELECTORS = %w(hover active target)
|
7
|
+
VALID_SELECTORS = %w(hover active target focus)
|
5
8
|
# Provides a consistent interface for getting a variable in ruby
|
6
9
|
# from a keyword argument hash that accounts for underscores/dash equivalence
|
7
10
|
# and allows the caller to pass a symbol instead of a string.
|
@@ -18,8 +21,8 @@ module Compass::SassExtensions::Functions::Sprites
|
|
18
21
|
width, _ = image_dimensions(file)
|
19
22
|
Sass::Script::Number.new(width, ["px"])
|
20
23
|
end
|
21
|
-
|
22
|
-
|
24
|
+
register_sass_function :sprite_width, [:map]
|
25
|
+
register_sass_function :sprite_width, [:map, :sprite]
|
23
26
|
|
24
27
|
# Returns the height of the generated sprite map
|
25
28
|
def sprite_height(map, sprite=nil)
|
@@ -28,22 +31,22 @@ module Compass::SassExtensions::Functions::Sprites
|
|
28
31
|
_, height = image_dimensions(file)
|
29
32
|
Sass::Script::Number.new(height, ["px"])
|
30
33
|
end
|
31
|
-
|
32
|
-
|
34
|
+
register_sass_function :sprite_height, [:map]
|
35
|
+
register_sass_function :sprite_height, [:map, :sprite]
|
33
36
|
|
34
37
|
# Returns a list of all sprite names
|
35
38
|
def sprite_names(map)
|
36
39
|
verify_map(map, 'sprite-names')
|
37
40
|
Sass::Script::List.new(map.sprite_names.map { |f| Sass::Script::String.new(f) }, ' ')
|
38
41
|
end
|
39
|
-
|
42
|
+
register_sass_function :sprite_names, [:map]
|
40
43
|
|
41
44
|
# Returns the system path of the sprite file
|
42
45
|
def sprite_path(map)
|
43
46
|
verify_map(map, 'sprite-path')
|
44
47
|
Sass::Script::String.new(map.filename)
|
45
48
|
end
|
46
|
-
|
49
|
+
register_sass_function :sprite_path, [:map]
|
47
50
|
|
48
51
|
# Returns the sprite file as an inline image
|
49
52
|
# @include "icon/*.png";
|
@@ -56,7 +59,7 @@ module Compass::SassExtensions::Functions::Sprites
|
|
56
59
|
path = map.filename
|
57
60
|
inline_image_string(data(path), compute_mime_type(path))
|
58
61
|
end
|
59
|
-
|
62
|
+
register_sass_function :inline_sprite, [:map]
|
60
63
|
|
61
64
|
# Creates a Compass::SassExtensions::Sprites::SpriteMap object. A sprite map, when used in a property is the same
|
62
65
|
# as calling sprite-url. So the following background properties are equivalent:
|
@@ -71,7 +74,7 @@ module Compass::SassExtensions::Functions::Sprites
|
|
71
74
|
kwargs.extend VariableReader
|
72
75
|
Compass::SassExtensions::Sprites::SpriteMap.from_uri(glob, self, kwargs)
|
73
76
|
end
|
74
|
-
|
77
|
+
register_sass_function :sprite_map, [:glob], :var_kwargs => true
|
75
78
|
|
76
79
|
# Returns the image and background position for use in a single shorthand property:
|
77
80
|
#
|
@@ -95,10 +98,10 @@ module Compass::SassExtensions::Functions::Sprites
|
|
95
98
|
position = sprite_position(map, sprite, offset_x, offset_y, use_percentages)
|
96
99
|
Sass::Script::List.new([url] + position.value, :space)
|
97
100
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
101
|
+
register_sass_function :sprite, [:map, :sprite]
|
102
|
+
register_sass_function :sprite, [:map, :sprite, :offset_x]
|
103
|
+
register_sass_function :sprite, [:map, :sprite, :offset_x, :offset_y]
|
104
|
+
register_sass_function :sprite, [:map, :sprite, :offset_x, :offset_y, :use_percentages]
|
102
105
|
|
103
106
|
# Returns the name of a sprite map
|
104
107
|
# The name is derived from the folder than contains the sprites.
|
@@ -106,7 +109,7 @@ module Compass::SassExtensions::Functions::Sprites
|
|
106
109
|
verify_map(map, "sprite-map-name")
|
107
110
|
Sass::Script::String.new(map.name)
|
108
111
|
end
|
109
|
-
|
112
|
+
register_sass_function :sprite_name, [:sprite]
|
110
113
|
|
111
114
|
# Returns the path to the original image file for the sprite with the given name
|
112
115
|
def sprite_file(map, sprite)
|
@@ -119,7 +122,7 @@ module Compass::SassExtensions::Functions::Sprites
|
|
119
122
|
missing_image!(map, sprite)
|
120
123
|
end
|
121
124
|
end
|
122
|
-
|
125
|
+
register_sass_function :sprite_file, [:map, :sprite]
|
123
126
|
|
124
127
|
# Returns boolean if sprite has a parent
|
125
128
|
def sprite_does_not_have_parent(map, sprite)
|
@@ -129,7 +132,20 @@ module Compass::SassExtensions::Functions::Sprites
|
|
129
132
|
Sass::Script::Bool.new map.image_for(sprite.value).parent.nil?
|
130
133
|
end
|
131
134
|
|
132
|
-
|
135
|
+
register_sass_function :sprite_does_not_have_parent, [:map, :sprite]
|
136
|
+
|
137
|
+
#return the name of the selector file
|
138
|
+
def sprite_selector_file(map, sprite, selector)
|
139
|
+
sprite = convert_sprite_name(sprite)
|
140
|
+
image = map.image_for(sprite)
|
141
|
+
if map.send(:"has_#{selector.value}?", sprite.value)
|
142
|
+
return Sass::Script::String.new(image.send(selector.value).name)
|
143
|
+
end
|
144
|
+
|
145
|
+
raise Sass::SyntaxError, "Sprite: #{sprite.value} does not have a #{selector} state"
|
146
|
+
end
|
147
|
+
|
148
|
+
register_sass_function :sprite_selector_file, [:map, :sprite, :selector]
|
133
149
|
|
134
150
|
# Returns boolean if sprite has the selector
|
135
151
|
def sprite_has_selector(map, sprite, selector)
|
@@ -142,11 +158,12 @@ module Compass::SassExtensions::Functions::Sprites
|
|
142
158
|
Sass::Script::Bool.new map.send(:"has_#{selector.value}?", sprite.value)
|
143
159
|
end
|
144
160
|
|
145
|
-
|
161
|
+
register_sass_function :sprite_has_selector, [:map, :sprite, :selector]
|
146
162
|
|
147
163
|
# Determines if the CSS selector is valid
|
164
|
+
IDENTIFIER_RX = /\A#{Sass::SCSS::RX::IDENT}\Z/
|
148
165
|
def sprite_has_valid_selector(selector)
|
149
|
-
unless selector.value =~
|
166
|
+
unless selector.value =~ IDENTIFIER_RX
|
150
167
|
raise Sass::SyntaxError, "#{selector} must be a legal css identifier"
|
151
168
|
end
|
152
169
|
Sass::Script::Bool.new true
|
@@ -158,7 +175,7 @@ module Compass::SassExtensions::Functions::Sprites
|
|
158
175
|
map.generate
|
159
176
|
generated_image_url(Sass::Script::String.new("#{map.path}-s#{map.uniqueness_hash}.png"))
|
160
177
|
end
|
161
|
-
|
178
|
+
register_sass_function :sprite_url, [:map]
|
162
179
|
|
163
180
|
# Returns the position for the original image in the sprite.
|
164
181
|
# This is suitable for use as a value to background-position:
|
@@ -220,11 +237,11 @@ module Compass::SassExtensions::Functions::Sprites
|
|
220
237
|
end
|
221
238
|
Sass::Script::List.new([x, y],:space)
|
222
239
|
end
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
240
|
+
register_sass_function :sprite_position, [:map]
|
241
|
+
register_sass_function :sprite_position, [:map, :sprite]
|
242
|
+
register_sass_function :sprite_position, [:map, :sprite, :offset_x]
|
243
|
+
register_sass_function :sprite_position, [:map, :sprite, :offset_x, :offset_y]
|
244
|
+
register_sass_function :sprite_position, [:map, :sprite, :offset_x, :offset_y, :use_percentages]
|
228
245
|
|
229
246
|
protected
|
230
247
|
|
@@ -247,7 +264,13 @@ protected
|
|
247
264
|
def convert_sprite_name(sprite)
|
248
265
|
case sprite
|
249
266
|
when Sass::Script::Color
|
250
|
-
|
267
|
+
rgb = if reversed_color_names.keys.first.size == 3
|
268
|
+
sprite.rgb
|
269
|
+
else
|
270
|
+
# Sass 3.3 includes the alpha channel
|
271
|
+
sprite.rgba
|
272
|
+
end
|
273
|
+
Sass::Script::String.new(reversed_color_names[rgb])
|
251
274
|
when Sass::Script::Bool
|
252
275
|
Sass::Script::String.new(sprite.to_s)
|
253
276
|
else
|
@@ -1,8 +1,43 @@
|
|
1
|
-
require 'sass/script
|
2
|
-
require 'sass/script/literal'
|
3
|
-
require 'sass/script/funcall'
|
1
|
+
require 'sass/script'
|
4
2
|
|
5
3
|
module Sass::Script
|
4
|
+
module Value
|
5
|
+
class Base
|
6
|
+
NO_CHILDREN = []
|
7
|
+
def children
|
8
|
+
NO_CHILDREN
|
9
|
+
end
|
10
|
+
|
11
|
+
def options=(opts)
|
12
|
+
@options = opts
|
13
|
+
children.each {|c| c.options = opts}
|
14
|
+
opts
|
15
|
+
end
|
16
|
+
|
17
|
+
def opts(value)
|
18
|
+
value.options = options
|
19
|
+
value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class List < Base
|
24
|
+
def children
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class ArgList < List
|
30
|
+
def children
|
31
|
+
super + @keywords.values
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Map < Base
|
36
|
+
def children
|
37
|
+
to_a
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
6
41
|
module HasSimpleCrossBrowserFunctionSupport
|
7
42
|
def supports?(aspect)
|
8
43
|
return true if Compass::BrowserSupport.supports?(name, aspect)
|
@@ -39,7 +74,7 @@ module Sass::Script
|
|
39
74
|
s = "#{name}(#{args.join(", ")})"
|
40
75
|
end
|
41
76
|
|
42
|
-
%w(webkit moz o ms svg
|
77
|
+
%w(webkit moz o ms svg css2).each do |prefix|
|
43
78
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
44
79
|
def to_#{prefix}(options = self.options)
|
45
80
|
prefixed_args = args.map do |arg|
|
@@ -65,19 +100,13 @@ module Sass::Script
|
|
65
100
|
class Funcall < Node
|
66
101
|
include HasSimpleCrossBrowserFunctionSupport
|
67
102
|
|
68
|
-
|
69
|
-
alias sass_to_literal to_literal
|
70
|
-
else
|
71
|
-
def sass_to_literal
|
72
|
-
Script::String.new("#{name}(#{args.join(', ')})")
|
73
|
-
end
|
74
|
-
end
|
103
|
+
alias sass_to_value to_value
|
75
104
|
|
76
|
-
def
|
105
|
+
def to_value(args)
|
77
106
|
if has_aspect?(args)
|
78
107
|
CrossBrowserFunctionCall.new(name, args)
|
79
108
|
else
|
80
|
-
|
109
|
+
sass_to_value(args)
|
81
110
|
end
|
82
111
|
end
|
83
112
|
end
|