Permalink
524 lines (402 sloc) 10.2 KB
use('../nodes/vendor-helpers.js')
@import 'config'
/*
* Alias "nowrap" as "no-wrap".
*/
no-wrap = unquote('nowrap')
/*
* Helper to find out if a given value is a width
*/
is-width(val)
if auto == val
return true
else if val && 'unit' == type(val)
// Stylus does not short circuit so we need to perform this as a distinct
// operation to prevent errors
return '' != unit(val)
return false
/*
* Vendor support for the given prop / arguments, optionally specifying the
* only prefixes to utilize, or those which should be ignored.
*/
vendor(prop, args, only = null, ignore = null, vendor-property = true)
need_normalize = !vendor-property or prop in ('transition' 'transition-property' 'border-image' 'border-image-slice')
for prefix in vendor-prefixes
unless (only and !(prefix in only)) or (ignore and prefix in ignore)
if official == prefix
if need_normalize
{prop}: normalize(prop,('%s' % args))
else
{prop}: args
else
newprop = prop
newprop = '-' + prefix + '-' + prop if vendor-property
if need_normalize
{newprop}: normalize(prop,('%s' % args),prefix)
else
{newprop}: args
/*
* Vendorize the given value.
*/
vendor-value(arg, only = null, ignore = null)
prop = current-property[0]
for prefix in vendor-prefixes
unless (only and !(prefix in only)) or (ignore and prefix in ignore) or official == prefix
add-property(prop, '-%s-%s' % (prefix arg))
arg
/*
* Vendor "box-shadow" support.
*/
box-shadow()
vendor('box-shadow', arguments, only: webkit official)
/*
* Vendor "user-select" support.
*/
user-select()
vendor('user-select', arguments, only: webkit moz ms official)
/*
* Vendor "column-count" support.
*/
column-count()
vendor('column-count', arguments, only: webkit moz official)
/*
* Vendor "column-gap" support.
*/
column-gap()
vendor('column-gap', arguments, only: webkit moz official)
/*
* Vendor "column-rule" support.
*/
column-rule()
vendor('column-rule', arguments, only: webkit moz official)
/*
* Vendor "column-rule-color" support.
*/
column-rule-color()
vendor('column-rule-color', arguments, only: webkit moz official)
/*
* Vendor "column-rule-width" support.
*/
column-rule-width()
vendor('column-rule-width', arguments, only: webkit moz official)
/*
* Vendor "column-rule-style" support.
*/
column-rule-style()
vendor('column-rule-style', arguments, only: webkit moz official)
/*
* Vendor "column-width" support.
*/
column-width()
vendor('column-width', arguments, only: webkit moz official)
/*
* Vendor "column-span" support.
*/
column-span()
vendor('column-span', arguments, only: webkit official)
/*
* Vendor "column-fill" support.
*/
column-fill()
vendor('column-fill', arguments, only: moz)
/*
* Legacy syntax support for background-clip and background-origin
*/
legacy-bg-values(property, args)
legacy_args = ()
importance = unquote('')
for subargs in args
for arg in subargs
if arg in (border-box padding-box content-box)
arg = unquote('border') if arg == border-box
arg = unquote('padding') if arg == padding-box
arg = unquote('content') if arg == content-box
if arg != '!important'
push(legacy_args,arg)
else
importance = !important
vendor(property, unquote(join(', ',legacy_args)) importance, only: moz webkit)
/*
* Vendor "background-clip" support.
*/
background-clip()
if arguments[0] == text
vendor('background-clip', arguments, only: webkit)
else
legacy-bg-values('background-clip', arguments)
background-clip: arguments
/*
* Vendor "background-origin" support.
*/
background-origin()
legacy-bg-values('background-origin', arguments)
background-origin: arguments
/*
* Vendor "background-size" support.
*/
background-size()
vendor('background-size', arguments, only: webkit moz official)
/*
* Vendor "transform" support.
*/
transform()
vendor('transform', arguments)
/*
* Vendor "transform-origin" support.
*/
transform-origin()
vendor('transform-origin', arguments)
/*
* Vendor "transform-style" support.
*/
transform-style()
vendor('transform-style', arguments)
/*
* Vendor "border-image" support.
*/
border-image()
vendor('border-image', arguments, only: webkit moz o official)
/*
* Vendor "transition" support.
*/
transition()
vendor('transition', arguments)
/*
* Vendor "transition-property" support.
*/
transition-property()
vendor('transition-property', arguments)
/*
* Vendor "transition-duration" support.
*/
transition-duration()
vendor('transition-duration', arguments)
/*
* Vendor "transition-timing-function" support.
*/
transition-timing-function()
vendor('transition-timing-function', arguments)
/*
* Vendor "transition-delay" support.
*/
transition-delay()
vendor('transition-delay', arguments)
/*
* Vendor "backface-visibility" support.
*/
backface-visibility()
vendor('backface-visibility', arguments, only: webkit moz ms official)
/*
* Vendor "perspective" support.
*/
perspective()
if mixin
vendor('perspective', arguments, only: webkit moz ms official)
else
'perspective(%s)' % arguments
/*
* Vendor "perspective-origin" support.
*/
perspective-origin()
vendor('perspective-origin', arguments, only: webkit moz ms official)
/*
* Opacity with conditional IE support.
*/
opacity(n, args...)
opacity: n args
if support-for-ie
if n == inherit or n == initial
-ms-filter: n args
filter: n args
else
val = round(n * 100)
if val == 100
-ms-filter: none args
filter: none args
else
-ms-filter: '"progid:DXImageTransform.Microsoft.Alpha(Opacity=%s)"' % val args
filter: 'alpha(opacity=%s)' % val args
/*
* Vendor "text-size-adjust"
*/
text-size-adjust()
vendor('text-size-adjust', arguments)
/*
* Alias the "white-space" property.
*/
whitespace()
white-space: arguments
/*
* Vendor "box-sizing" support.
*/
box-sizing()
vendor('box-sizing', arguments, only: webkit moz official)
/*
* Vendor "box-orient" support.
*/
box-orient()
vendor('box-orient', arguments, only: webkit moz official)
/*
* Vendor "box-flex-group" support.
*/
box-flex-group()
vendor('box-flex-group', arguments, only: webkit moz official)
/*
* Vendor "box-ordinal-group" support.
*/
box-ordinal-group()
vendor('box-ordinal-group', arguments, only: webkit moz ms official)
/*
* Vendor "box-align" support.
*/
box-align()
vendor('box-align', arguments, only: webkit moz ms official)
/*
* Vendor "box-pack" support.
*/
box-pack()
vendor('box-pack', arguments, only: webkit moz ms official)
/*
* Vendor "box-direction" support.
*/
box-direction()
vendor('box-direction', arguments, only: webkit moz ms official)
/*
* Vendor "animation" support.
*/
animation()
vendor('animation', arguments)
/*
* Vendor "animation-name" support.
*/
animation-name()
vendor('animation-name', arguments)
/*
* Vendor "animation-duration" support.
*/
animation-duration()
vendor('animation-duration', arguments)
/*
* Vendor "animation-delay" support.
*/
animation-delay()
vendor('animation-delay', arguments)
/*
* Vendor "animation-direction" support.
*/
animation-direction()
vendor('animation-direction', arguments)
/*
* Vendor "animation-iteration-count" support.
*/
animation-iteration-count()
vendor('animation-iteration-count', arguments)
/*
* Vendor "animation-timing-function" support.
*/
animation-timing-function()
vendor('animation-timing-function', arguments)
/*
* Vendor "animation-play-state" support.
*/
animation-play-state()
vendor('animation-play-state', arguments)
/*
* Vendor "animation-fill-mode" support.
*/
animation-fill-mode()
vendor('animation-fill-mode', arguments)
/*
* Vendor "hyphens" support.
*/
hyphens()
vendor('hyphens', arguments, only: webkit moz ms official)
/*
* Vendor "appearance" support.
*/
appearance()
vendor('appearance', arguments, only: webkit moz official)
/*
* Vendor "tab-size" support.
*/
tab-size()
vendor('tab-size', arguments, only: moz o official)
/*
* Vendor "overflow-scrolling" support.
*/
overflow-scrolling()
vendor('overflow-scrolling', arguments, only: webkit official)
/*
* Vendor "text-overflow" support, , -o- for opera 9.* - 10.*
*/
text-overflow()
vendor('text-overflow', arguments, only: official o)
/*
* Vendor "text-size-adjust" support.
*/
text-size-adjust()
vendor('text-size-adjust', arguments, only: official webkit ms)
/*
* Vendor "font-smoothing" support, webkit only.
*/
font-smoothing()
vendor('font-smoothing', arguments, only: webkit)
/**
* Vendor input-placeholder/placeholder support.
*
* Examples:
* // Default syntax
* body
* placeholder(color #333, font-weight normal)
*
* // The comma is important
* .placeholder-red
* placeholder(color red,)
*
* // We can pass a function
* green-placeholder()
* color green
* .placeholder-green
* placeholder(green-placeholder)
*
* // We can pass a hash
* textarea
* placeholder((font-style italic) (font-weight bold) (padding '4px 10px'))
*/
placeholder()
for v in ':-webkit-input' '-moz' ':-moz' '-ms-input'
&:{v}-placeholder
for pair in arguments
if typeof(pair) == 'function'
pair()
else if pair is not null && pair[0] is not null
{pair[0]}: type(pair[1]) == 'string' ? s(pair[1]) : pair[1]
input-placeholder = placeholder
/*
* Vendor background support (gradients).
*/
background()
if match('-gradient\(', ''+arguments)
vendor('background', arguments, vendor-property: false)
else
background arguments
background-image()
if match('-gradient\(', ''+arguments)
vendor('background-image', arguments, vendor-property: false)
else
background-image arguments
cursor()
if match('-gradient\(', ''+arguments)
vendor('cursor', arguments, vendor-property: false)
else
cursor arguments
list-style()
if match('-gradient\(', ''+arguments)
vendor('list-style', arguments, vendor-property: false)
else
list-style arguments
list-style-image()
if match('-gradient\(', ''+arguments)
vendor('list-style-image', arguments, vendor-property: false)
else
list-style-image arguments