forked from TurbineCSS/Turbine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboxsizing.php
50 lines (44 loc) · 1.26 KB
/
boxsizing.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* This file is part of Turbine
* http://github.com/SirPepe/Turbine
*
* Copyright Peter Kröner
* Licensed under GNU LGPL 3, see license.txt or http://www.gnu.org/licenses/
*/
/**
* Cross-browser-box-sizing
*
* Usage: box-sizing:inherit|content-box|border-box
* Status: Beta
* Version: 1.0
*
* @param mixed &$parsed
* @return void
*/
function boxsizing(&$parsed){
global $browser, $cssp;
$htc_path = rtrim(dirname($_SERVER['SCRIPT_NAME']),'/').'/plugins/boxsizing/boxsizing.htc';
foreach($parsed as $block => $css){
foreach($parsed[$block] as $selector => $styles){
if(isset($styles['box-sizing'])){
// Create the vendor-specific rules and insert them
$boxsizing_rules = array(
'-moz-box-sizing' => $styles['box-sizing'],
'-webkit-box-sizing' => $styles['box-sizing'],
'behavior' => array('url('.$htc_path.')')
);
$cssp->insert_properties($boxsizing_rules, $block, $selector, null, 'box-sizing');
// Comment the newly inserted properties
foreach($boxsizing_rules as $property => $value){
CSSP::comment($parsed[$block][$selector], $property, 'Added by box-sizing plugin');
}
}
}
}
}
/**
* Register the plugin
*/
$cssp->register_plugin('boxsizing', 'boxsizing', 'before_glue', 0);
?>