Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 37 → Rev 71

/trunk/css/least/Mixins.php
3,122 → 3,178
namespace de\pointedears\css\least;
 
/**
* Mix-ins for the LEAST extended CSS parser
* Mix-ins for the LEAST CSS preprocessor
*
* @author Thomas 'PointedEars' Lahn <php@PointedEars.de>
*/
abstract class Mixins
{
/** @section General functions */
/**
* Generates a CSS property declaration whose value is a
* <code>linear-gradient()</code> function call for
* supported function name prefixes.
* Generates a CSS section for each keyword prefix.
*
* @param string $property
* Property to be declared
* @param string $keyword
* Section keyword
* @param string $params
* Parameters to the <code>linear-gradient()</code> function
* @param array $prefixes
* Pass to override supported function name prefixes
* Section parameters (name, medium, etc.)
* @param string $content
* Section content
* @param array[string] $prefixes
* Keyword prefixes
*/
public static function linear_gradient ($property, $params,
array $prefixes = array('-moz-', '-o-', '-webkit-', ''))
public static function prefix_section ($keyword, $params,
$content, array $prefixes)
{
ob_start();
foreach ($prefixes as $prefix)
{
echo "{$property}: {$prefix}linear-gradient({$params});\n";
echo "@{$prefix}{$keyword} {$params} {\n {$content}\n}\n";
}
ob_end_flush();
}
 
/**
* Generates a CSS property declaration whose value is a
* <code>radial-gradient()</code> function call for
* supported function name prefixes.
* function call, for each function name prefix.
*
* @param string $property
* Property to be declared
* @param string $params
* Parameters to the <code>radial-gradient()</code> function
* @param array $prefixes
* Pass to override supported function name prefixes
* @param string $function
* CSS function to be called
* @param string $args
* Arguments to the function
* @param array[string] $prefixes
* Function name prefixes
*/
public static function radial_gradient ($property, $params,
array $prefixes = array('-moz-', '-webkit-'))
public static function prefix_function ($property, $function, $args,
array $prefixes)
{
ob_start();
foreach ($prefixes as $prefix)
{
echo "{$property}: {$prefix}radial-gradient({$params});\n";
echo "{$property}: {$prefix}{$function}({$args});\n";
}
ob_end_flush();
}
/**
* Generates a CSS property declaration for each
* property name prefix.
*
* @param string $suffix
* Property name suffix
* @param string $value
* Property value
* @param array[string] $prefixes
* Property name prefixes
*/
public static function prefix_property ($property, $suffix, $value,
array $prefixes)
{
ob_start();
foreach ($prefixes as $prefix)
{
echo "{$prefix}{$property}{$suffix}: {$value};\n";
}
ob_end_flush();
}
/** @section Gradients */
/**
* Generates a CSS property declaration whose value is a
* <code>linear-gradient()</code> function call for
* each function name prefix.
*
* @param string $property
* Property to be declared
* @param string $args
* Arguments to the <code>linear-gradient()</code> function
* @param array[string] $prefixes (optional)
* Pass to override supported function name prefixes
* @see self::prefix_function()
*/
public static function linear_gradient ($property, $args,
array $prefixes = array('-moz-', '-o-', '-webkit-', ''))
{
self::prefix_function($property, 'linear-gradient', $args, $prefixes);
}
 
/**
* Generates a CSS property declaration whose value is a
* <code>radial-gradient()</code> function call for each
* function name prefix.
*
* @param string $property
* Property to be declared
* @param string $args
* Arguments to the <code>radial-gradient()</code> function
* @param array[string] $prefixes (optional)
* Pass to override supported function name prefixes
* @see self::prefix_function()
*/
public static function radial_gradient ($property, $args,
array $prefixes = array('-moz-', '-webkit-'))
{
self::prefix_function($property, 'radial-gradient', $args, $prefixes);
}
/**
* Generates a CSS <code>transition</code> property declaration
* for supported property name prefixes.
* for each property name prefix.
*
* @param string $suffix
* Property name suffix
* @param string $value
* Property value
* @param array $prefixes
* @param array[string] $prefixes (optional)
* Pass to override supported property name prefixes
* @see self::prefix_property()
*/
public static function transition ($suffix, $value,
array $prefixes = array('-moz-', '-webkit-', ''))
{
ob_start();
foreach ($prefixes as $prefix)
{
echo "{$prefix}transition{$suffix}: {$value};\n";
}
ob_end_flush();
self::prefix_property('transition', $suffix, $value, $prefixes);
}
 
/** @section Animations */
/**
* Generates a CSS <code>@keyframes</code> section for
* supported keyword prefixes.
* each keyword prefix.
*
* @param string $name
* Animation name as referred by the <code>animation-name</code>
* property declaration.
* Animation name as referred by an <code>animation-name</code>
* property value.
* @param string $data
* Keyframes data
* @param array $prefixes
* @param array[string] $prefixes (optional)
* Pass to override supported keyword prefixes
* @see self::prefix_section()
*/
public static function keyframes ($name, $data,
array $prefixes = array('-moz-', '-webkit-', ''))
{
ob_start();
foreach ($prefixes as $prefix)
{
echo "@{$prefix}keyframes {$name} {\n {$data}\n}\n";
}
ob_end_flush();
self::prefix_section('keyframes', $name, $data, $prefixes);
}
 
/**
* Generates a CSS <code>animation</code> property declaration
* for supported property name prefixes.
* for each property name prefix.
*
* @param string $suffix
* Property name suffix
* Property name suffix, e.g. <tt>"-name"</tt> for
* <code>animation-name</code>
* @param string $value
* Property value
* @param array $prefixes
* @param array[string] $prefixes (optional)
* Pass to override supported property name prefixes
* @see self::prefix_property()
*/
public static function animation ($suffix, $value,
array $prefixes = array('-moz-', '-webkit-', ''))
{
ob_start();
foreach ($prefixes as $prefix)
{
echo "{$prefix}animation{$suffix}: {$value};\n";
}
ob_end_flush();
self::prefix_property('animation', $suffix, $value, $prefixes);
}
}