compass-core 1.0.0.alpha.15 → 1.0.0.alpha.16
Sign up to get free protection for your applications and to get access to all the features.
- data/RELEASE_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/compass/configuration.rb +1 -0
- data/lib/compass/core/sass_extensions/functions/colors.rb +3 -3
- data/lib/compass/core/sass_extensions/functions/constants.rb +14 -14
- data/lib/compass/core/sass_extensions/functions/cross_browser_support.rb +23 -22
- data/lib/compass/core/sass_extensions/functions/display.rb +1 -1
- data/lib/compass/core/sass_extensions/functions/enumerate.rb +2 -2
- data/lib/compass/core/sass_extensions/functions/env.rb +10 -18
- data/lib/compass/core/sass_extensions/functions/font_files.rb +5 -4
- data/lib/compass/core/sass_extensions/functions/gradient_support.rb +79 -85
- data/lib/compass/core/sass_extensions/functions/image_size.rb +2 -2
- data/lib/compass/core/sass_extensions/functions/inline_image.rb +3 -3
- data/lib/compass/core/sass_extensions/functions/lists.rb +24 -23
- data/lib/compass/core/sass_extensions/functions/math.rb +11 -8
- data/lib/compass/core/sass_extensions/functions/selectors.rb +39 -24
- data/lib/compass/core/sass_extensions/functions/urls.rb +14 -14
- data/lib/compass/core/sass_extensions/monkey_patches/browser_support.rb +3 -2
- data/stylesheets/compass/typography/lists/_inline-list.scss +2 -2
- metadata +5 -5
@@ -4,13 +4,13 @@ module Compass::Core::SassExtensions::Functions::ImageSize
|
|
4
4
|
# Returns the width of the image relative to the images directory
|
5
5
|
def image_width(image_file)
|
6
6
|
width, _ = image_dimensions(image_file)
|
7
|
-
|
7
|
+
number(width, "px")
|
8
8
|
end
|
9
9
|
|
10
10
|
# Returns the height of the image relative to the images directory
|
11
11
|
def image_height(image_file)
|
12
12
|
_, height = image_dimensions(image_file)
|
13
|
-
|
13
|
+
number(height, "px")
|
14
14
|
end
|
15
15
|
|
16
16
|
class ImageProperties
|
@@ -12,16 +12,16 @@ module Compass::Core::SassExtensions::Functions::InlineImage
|
|
12
12
|
path = path.value
|
13
13
|
real_path = File.join(Compass.configuration.fonts_path, path)
|
14
14
|
data = inline_image_string(data(real_path), compute_mime_type(path))
|
15
|
-
files <<
|
15
|
+
files << list(data, unquoted_string("format('#{type}')"), :space)
|
16
16
|
end
|
17
|
-
|
17
|
+
list(files, :comma)
|
18
18
|
end
|
19
19
|
|
20
20
|
protected
|
21
21
|
def inline_image_string(data, mime_type)
|
22
22
|
data = [data].flatten.pack('m').gsub("\n","")
|
23
23
|
url = "url('data:#{mime_type};base64,#{data}')"
|
24
|
-
|
24
|
+
unquoted_string(url)
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
@@ -3,26 +3,26 @@ module Compass::Core::SassExtensions::Functions::Lists
|
|
3
3
|
# Returns true when the object is false, an empty string, or an empty list
|
4
4
|
def blank(obj)
|
5
5
|
case obj
|
6
|
-
when Sass::Script::Bool
|
7
|
-
|
8
|
-
when Sass::Script::String
|
9
|
-
|
10
|
-
when Sass::Script::List
|
11
|
-
|
6
|
+
when Sass::Script::Value::Bool, Sass::Script::Value::Null
|
7
|
+
bool(!obj.to_bool)
|
8
|
+
when Sass::Script::Value::String
|
9
|
+
bool(obj.value.strip.size == 0)
|
10
|
+
when Sass::Script::Value::List
|
11
|
+
bool(obj.value.size == 0 || obj.value.all?{|el| blank(el).to_bool})
|
12
12
|
else
|
13
|
-
|
13
|
+
bool(false)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
# Returns a new list after removing any non-true values
|
18
18
|
def compact(*args)
|
19
19
|
sep = :comma
|
20
|
-
if args.size == 1 && args.first.is_a?(Sass::Script::List)
|
20
|
+
if args.size == 1 && args.first.is_a?(Sass::Script::Value::List)
|
21
21
|
list = args.first
|
22
22
|
args = list.value
|
23
23
|
sep = list.separator
|
24
24
|
end
|
25
|
-
|
25
|
+
list(args.reject{|a| !a.to_bool}, sep)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Get the nth value from a list
|
@@ -41,49 +41,50 @@ module Compass::Core::SassExtensions::Functions::Lists
|
|
41
41
|
# This can be used to unpack a space separated list that got turned
|
42
42
|
# into a string by sass before it was passed to a mixin.
|
43
43
|
def _compass_list(arg)
|
44
|
-
if arg.is_a?(Sass::Script::List)
|
45
|
-
|
44
|
+
if arg.is_a?(Sass::Script::Value::List)
|
45
|
+
list(arg.value.dup, arg.separator)
|
46
46
|
else
|
47
|
-
|
47
|
+
list(arg, :space)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
# If the argument is a list, it will return a new list that is space delimited
|
52
52
|
# Otherwise it returns a new, single element, space-delimited list.
|
53
53
|
def _compass_space_list(list)
|
54
|
-
if list.is_a?(Sass::Script::List)
|
55
|
-
|
54
|
+
if list.is_a?(Sass::Script::Value::List)
|
55
|
+
list(list.value.dup, :space)
|
56
56
|
else
|
57
|
-
|
57
|
+
list(list, :space)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
# Returns the size of the list.
|
62
62
|
def _compass_list_size(list)
|
63
63
|
assert_list list
|
64
|
-
|
64
|
+
number(list.value.size)
|
65
65
|
end
|
66
66
|
|
67
67
|
# slice a sublist from a list
|
68
68
|
def _compass_slice(list, start_index, end_index = nil)
|
69
|
-
end_index ||=
|
69
|
+
end_index ||= number(-1)
|
70
70
|
start_index = start_index.value
|
71
71
|
end_index = end_index.value
|
72
72
|
start_index -= 1 unless start_index < 0
|
73
73
|
end_index -= 1 unless end_index < 0
|
74
|
-
|
74
|
+
list(list.values[start_index..end_index], list.separator)
|
75
75
|
end
|
76
76
|
|
77
77
|
# removes the given values from the list.
|
78
78
|
def reject(list, *values)
|
79
|
-
|
79
|
+
list(list.value.reject{|v| values.any?{|o| v == o}}, list.separator)
|
80
80
|
end
|
81
81
|
|
82
82
|
# returns the first value of a space delimited list.
|
83
83
|
def first_value_of(list)
|
84
|
-
if list.is_a?(Sass::Script::String)
|
85
|
-
|
86
|
-
|
84
|
+
if list.is_a?(Sass::Script::Value::String)
|
85
|
+
r = list.value.split(/\s+/).first
|
86
|
+
list.type == :identifier ? identifier(r) : quoted_string(r)
|
87
|
+
elsif list.is_a?(Sass::Script::Value::List)
|
87
88
|
list.value.first
|
88
89
|
else
|
89
90
|
list
|
@@ -93,7 +94,7 @@ module Compass::Core::SassExtensions::Functions::Lists
|
|
93
94
|
protected
|
94
95
|
|
95
96
|
def assert_list(value)
|
96
|
-
unless value.is_a?(Sass::Script::List)
|
97
|
+
unless value.is_a?(Sass::Script::Value::List)
|
97
98
|
raise ArgumentError.new("#{value.inspect} is not a list")
|
98
99
|
end
|
99
100
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module Compass::Core::SassExtensions::Functions::Math
|
2
2
|
extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
|
3
|
+
extend Sass::Script::Value::Helpers
|
4
|
+
|
5
|
+
PI = number(Math::PI)
|
6
|
+
E = number(Math::E)
|
3
7
|
|
4
|
-
PI = Sass::Script::Number.new(Math::PI)
|
5
8
|
def pi()
|
6
9
|
PI
|
7
10
|
end
|
@@ -14,7 +17,7 @@ module Compass::Core::SassExtensions::Functions::Math
|
|
14
17
|
range = (args.first.value..args.last.value).to_a
|
15
18
|
range[rand(range.length)]
|
16
19
|
end
|
17
|
-
|
20
|
+
number(value)
|
18
21
|
end
|
19
22
|
declare :random, [:limit]
|
20
23
|
declare :random, [:start, :limit]
|
@@ -50,7 +53,7 @@ module Compass::Core::SassExtensions::Functions::Math
|
|
50
53
|
declare :atan, [:number]
|
51
54
|
|
52
55
|
def e
|
53
|
-
|
56
|
+
E
|
54
57
|
end
|
55
58
|
declare :e, []
|
56
59
|
|
@@ -60,7 +63,7 @@ module Compass::Core::SassExtensions::Functions::Math
|
|
60
63
|
raise Sass::SyntaxError, "base to logarithm must be unitless." unless base.unitless?
|
61
64
|
|
62
65
|
result = Math.log(number.value, base.value) rescue Math.log(number.value) / Math.log(base.value)
|
63
|
-
|
66
|
+
number(result, number.unit_str)
|
64
67
|
end
|
65
68
|
declare :logarithm, [:number]
|
66
69
|
declare :logarithm, [:number, :base]
|
@@ -77,16 +80,16 @@ module Compass::Core::SassExtensions::Functions::Math
|
|
77
80
|
assert_type number, :Number
|
78
81
|
assert_type exponent, :Number
|
79
82
|
raise Sass::SyntaxError, "exponent to pow must be unitless." unless exponent.unitless?
|
80
|
-
|
83
|
+
number(number.value**exponent.value, number.unit_str)
|
81
84
|
end
|
82
85
|
declare :pow, [:number, :exponent]
|
83
86
|
|
84
87
|
private
|
85
88
|
def trig(operation, number)
|
86
|
-
if number.
|
87
|
-
|
89
|
+
if number.unit_str == "deg"
|
90
|
+
number(Math.send(operation, Math::PI * number.value / 180))
|
88
91
|
else
|
89
|
-
|
92
|
+
number(Math.send(operation, number.value), number.unit_str)
|
90
93
|
end
|
91
94
|
end
|
92
95
|
end
|
@@ -4,39 +4,54 @@ module Compass::Core::SassExtensions::Functions::Selectors
|
|
4
4
|
# Permute multiple selectors each of which may be comma delimited, the end result is
|
5
5
|
# a new selector that is the equivalent of nesting each under the previous selector.
|
6
6
|
# To illustrate, the following mixins are equivalent:
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
7
|
+
#
|
8
|
+
# @include mixin-a($selector1, $selector2, $selector3) {
|
9
|
+
# #{$selector1} {
|
10
|
+
# #{$selector2} {
|
11
|
+
# #{$selector3} {
|
12
|
+
# width: 2px
|
13
|
+
# }
|
14
|
+
# }
|
15
|
+
# }
|
16
|
+
# }
|
17
|
+
# @include mixin-b($selector1, $selector2, $selector3) {
|
18
|
+
# #{nest($selector, $selector2, $selector3)} {
|
11
19
|
# width: 2px
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# width: 2px
|
20
|
+
# }
|
21
|
+
# }
|
15
22
|
def nest(*arguments)
|
16
23
|
nested = arguments.map{|a| a.value}.inject do |memo,arg|
|
17
24
|
ancestors = memo.split(COMMA_SEPARATOR)
|
18
25
|
descendants = arg.split(COMMA_SEPARATOR)
|
19
26
|
ancestors.map{|a| descendants.map{|d| "#{a} #{d}"}.join(", ")}.join(", ")
|
20
27
|
end
|
21
|
-
|
28
|
+
unquoted_string(nested)
|
22
29
|
end
|
23
30
|
|
24
31
|
# Permute two selectors, the first may be comma delimited.
|
25
32
|
# The end result is a new selector that is the equivalent of nesting the second
|
26
33
|
# selector under the first one in a sass file and preceding it with an &.
|
27
|
-
# To illustrate, the following mixins are equivalent
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
34
|
+
# To illustrate, the following mixins are equivalent, except the second
|
35
|
+
# mixin handles:
|
36
|
+
#
|
37
|
+
# @include mixin-a($selector, $to-append) {
|
38
|
+
# #{$selector} {
|
39
|
+
# &#{$to-append} {
|
40
|
+
# width: 2px
|
41
|
+
# }
|
42
|
+
# }
|
43
|
+
# }
|
44
|
+
#
|
45
|
+
# @include mixin-b($selector, $to-append) {
|
46
|
+
# #{append_selector($selector, $to-append)} {
|
47
|
+
# width: 2px
|
48
|
+
# }
|
49
|
+
# }
|
35
50
|
def append_selector(selector, to_append)
|
36
51
|
ancestors = selector.value.split(COMMA_SEPARATOR)
|
37
52
|
descendants = to_append.value.split(COMMA_SEPARATOR)
|
38
53
|
nested = ancestors.map{|a| descendants.map{|d| "#{a}#{d}"}.join(", ")}.join(", ")
|
39
|
-
|
54
|
+
unquoted_string(nested)
|
40
55
|
end
|
41
56
|
|
42
57
|
# Return the header selectors for the levels indicated
|
@@ -47,18 +62,18 @@ module Compass::Core::SassExtensions::Functions::Selectors
|
|
47
62
|
# headers(2,4) => h2, h3, h4
|
48
63
|
def headers(from = nil, to = nil)
|
49
64
|
if from && !to
|
50
|
-
if from.is_a?(Sass::Script::String) && from.value == "all"
|
51
|
-
from =
|
52
|
-
to =
|
65
|
+
if from.is_a?(Sass::Script::Value::String) && from.value == "all"
|
66
|
+
from = number(1)
|
67
|
+
to = number(6)
|
53
68
|
else
|
54
69
|
to = from
|
55
|
-
from =
|
70
|
+
from = number(1)
|
56
71
|
end
|
57
72
|
else
|
58
|
-
from ||=
|
59
|
-
to ||=
|
73
|
+
from ||= number(1)
|
74
|
+
to ||= number(6)
|
60
75
|
end
|
61
|
-
|
76
|
+
list((from.value..to.value).map{|n| identifier("h#{n}")}, :comma)
|
62
77
|
end
|
63
78
|
alias headings headers
|
64
79
|
end
|
@@ -19,7 +19,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
19
19
|
base.declare :stylesheet_url, [:path, :only_path]
|
20
20
|
end
|
21
21
|
end
|
22
|
-
def stylesheet_url(path, only_path =
|
22
|
+
def stylesheet_url(path, only_path = bool(false))
|
23
23
|
# Compute the path to the stylesheet, either root relative or stylesheet relative
|
24
24
|
# or nil if the http_images_path is not set in the configuration.
|
25
25
|
http_stylesheets_path = if relative?
|
@@ -32,7 +32,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
32
32
|
|
33
33
|
path = "#{http_stylesheets_path}/#{path.value}"
|
34
34
|
if only_path.to_bool
|
35
|
-
|
35
|
+
unquoted_string(clean_path(path))
|
36
36
|
else
|
37
37
|
clean_url(path)
|
38
38
|
end
|
@@ -47,12 +47,12 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
47
47
|
base.declare :font_url, [:path, :only_path, :cache_buster]
|
48
48
|
end
|
49
49
|
end
|
50
|
-
def font_url(path, only_path =
|
50
|
+
def font_url(path, only_path = bool(false), cache_buster = bool(true))
|
51
51
|
path = path.value # get to the string value of the literal.
|
52
52
|
|
53
53
|
# Short curcuit if they have provided an absolute url.
|
54
54
|
if absolute_path?(path)
|
55
|
-
return
|
55
|
+
return unquoted_string("url(#{path})")
|
56
56
|
end
|
57
57
|
|
58
58
|
# Compute the path to the font file, either root relative or stylesheet relative
|
@@ -82,7 +82,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
82
82
|
# Compute and append the cache buster if there is one.
|
83
83
|
if cache_buster.to_bool
|
84
84
|
path, anchor = path.split("#", 2)
|
85
|
-
if cache_buster.is_a?(Sass::Script::String)
|
85
|
+
if cache_buster.is_a?(Sass::Script::Value::String)
|
86
86
|
path += "?#{cache_buster.value}"
|
87
87
|
else
|
88
88
|
path = cache_busted_path(path, real_path)
|
@@ -94,7 +94,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
94
94
|
path = "#{asset_host}#{'/' unless path[0..0] == "/"}#{path}" if asset_host
|
95
95
|
|
96
96
|
if only_path.to_bool
|
97
|
-
|
97
|
+
unquoted_string(clean_path(path))
|
98
98
|
else
|
99
99
|
clean_url(path)
|
100
100
|
end
|
@@ -109,7 +109,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
109
109
|
base.declare :image_url, [:path, :only_path, :cache_buster]
|
110
110
|
end
|
111
111
|
end
|
112
|
-
def image_url(path, only_path =
|
112
|
+
def image_url(path, only_path = bool(false), cache_buster = bool(true))
|
113
113
|
path = path.value # get to the string value of the literal.
|
114
114
|
|
115
115
|
if path =~ %r{^#{Regexp.escape(Compass.configuration.http_images_path)}/(.*)}
|
@@ -118,7 +118,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
118
118
|
path = $1
|
119
119
|
elsif absolute_path?(path)
|
120
120
|
# Short curcuit if they have provided an absolute url.
|
121
|
-
return
|
121
|
+
return unquoted_string("url(#{path})")
|
122
122
|
end
|
123
123
|
|
124
124
|
# Compute the path to the image, either root relative or stylesheet relative
|
@@ -152,7 +152,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
152
152
|
# Compute and append the cache buster if there is one.
|
153
153
|
if cache_buster.to_bool
|
154
154
|
path, anchor = path.split("#", 2)
|
155
|
-
if cache_buster.is_a?(Sass::Script::String)
|
155
|
+
if cache_buster.is_a?(Sass::Script::Value::String)
|
156
156
|
path += "?#{cache_buster.value}"
|
157
157
|
else
|
158
158
|
path = cache_busted_path(path, real_path)
|
@@ -164,7 +164,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
164
164
|
path = "#{asset_host}#{'/' unless path[0..0] == "/"}#{path}" if asset_host
|
165
165
|
|
166
166
|
if only_path.to_bool
|
167
|
-
|
167
|
+
unquoted_string(clean_path(path))
|
168
168
|
else
|
169
169
|
clean_url(path)
|
170
170
|
end
|
@@ -178,7 +178,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
178
178
|
base.declare :generated_image_url, [:path, :cache_buster]
|
179
179
|
end
|
180
180
|
end
|
181
|
-
def generated_image_url(path, cache_buster =
|
181
|
+
def generated_image_url(path, cache_buster = bool(false))
|
182
182
|
path = path.value # get to the string value of the literal.
|
183
183
|
|
184
184
|
if path =~ %r{^#{Regexp.escape(Compass.configuration.http_generated_images_path)}/(.*)}
|
@@ -187,7 +187,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
187
187
|
path = $1
|
188
188
|
elsif absolute_path?(path)
|
189
189
|
# Short curcuit if they have provided an absolute url.
|
190
|
-
return
|
190
|
+
return unquoted_string("url(#{path})")
|
191
191
|
end
|
192
192
|
|
193
193
|
# Compute the path to the image, either root relative or stylesheet relative
|
@@ -221,7 +221,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
221
221
|
# Compute and append the cache buster if there is one.
|
222
222
|
if cache_buster.to_bool
|
223
223
|
path, anchor = path.split("#", 2)
|
224
|
-
if cache_buster.is_a?(Sass::Script::String)
|
224
|
+
if cache_buster.is_a?(Sass::Script::Value::String)
|
225
225
|
path += "?#{cache_buster.value}"
|
226
226
|
else
|
227
227
|
path = cache_busted_path(path, real_path)
|
@@ -246,7 +246,7 @@ module Compass::Core::SassExtensions::Functions::Urls
|
|
246
246
|
|
247
247
|
# Emits a url, taking off any leading "./"
|
248
248
|
def clean_url(url)
|
249
|
-
|
249
|
+
unquoted_string("url('#{clean_path(url)}')")
|
250
250
|
end
|
251
251
|
|
252
252
|
def relative?
|
@@ -50,6 +50,7 @@ module Sass::Script
|
|
50
50
|
attr_accessor :name, :args
|
51
51
|
|
52
52
|
include HasSimpleCrossBrowserFunctionSupport
|
53
|
+
include Sass::Script::Value::Helpers
|
53
54
|
|
54
55
|
def initialize(name, args)
|
55
56
|
self.name = name
|
@@ -81,9 +82,9 @@ module Sass::Script
|
|
81
82
|
end
|
82
83
|
contents = prefixed_args.join(', ')
|
83
84
|
if contents.size > 0
|
84
|
-
opts(
|
85
|
+
opts(identifier("\#{prefixed_name}(\#{contents})"))
|
85
86
|
else
|
86
|
-
opts(
|
87
|
+
opts(null)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
RUBY
|