forked from TurbineCSS/Turbine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbugfixes.php
executable file
·140 lines (112 loc) · 5.45 KB
/
bugfixes.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?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/
*/
/**
* A bunch of general browser bugfixes
*
* Usage: Nobrainer, just switch it on
* Example: -
* Status: Stable
* Version: 1.0
* Version: 1.2
*
* @param mixed &$parsed
* @return void
*/
function bugfixes(&$parsed){
global $cssp, $browser;
$changed = array();
// IE6: Image margin bottom bug
$changed['img']['vertical-align'][] = 'bottom';
// IE: remove scrollbars from textareas
$changed['textarea']['overflow'][] = 'auto';
// IE6: Background image flickers on hover
$changed['html']['filter'][] = 'expression(document.execCommand("BackgroundImageCache",false,true))';
// IE6: Fix transparent PNGs, see http://www.twinhelix.com/css/iepngfix/
$htc_path = rtrim(dirname($_SERVER['SCRIPT_NAME']),'/').'/plugins/bugfixes/iepngfix.htc';
$changed['img']['behavior'][] = 'url("'.$htc_path.'")';
// IE6 and 7: resample images bicubic instead of using nearest neighbor method
if($browser->browser == 'ie' && floatval($browser->browser_version) < 7){
// IE6: Image margin bottom bug
$changed['img']['vertical-align'][] = 'bottom';
// IE6: Background image flickers on hover
$changed['html']['filter'][] = 'expression(document.execCommand("BackgroundImageCache",false,true))';
// IE6: Fix transparent PNGs, see http://www.twinhelix.com/css/iepngfix/
$htc_path = rtrim(dirname($_SERVER['SCRIPT_NAME']),'/').'/plugins/bugfixes/iepngfix.htc';
$changed['img']['behavior'][] = 'url("'.$htc_path.'")';
// IE6: Input align, see http://tjkdesign.com/ez-css/css/base.css
$changed['img']['vertical-align'][] = 'text-bottom';
}
// IE 7: resample images bicubic instead of using nearest neighbor method
$changed['img']['-ms-interpolation-mode'][] = 'bicubic';
// IE6 and 7: Enable full styleability for buttons, see http://www.sitepoint.com/forums/showthread.php?t=547059
$changed['button']['overflow'][] = 'visible';
$changed['button']['width'][] = 'auto';
$changed['button']['white-space'][] = 'nowrap';
// IE6 and 7: Missing :hover-property on every tag except a, see http://www.xs4all.nl/~peterned/csshover.html
$htc_path = rtrim(dirname($_SERVER['SCRIPT_NAME']),'/').'/plugins/bugfixes/csshover3.htc';
$changed['body']['behavior'][] = 'url("'.$htc_path.'")';
// IE8: Reenable cleartype where filters are set
$htc_path = rtrim(dirname($_SERVER['SCRIPT_NAME']),'/').'/plugins/bugfixes/';
$changed['body']['behavior'][] = 'url("'.$htc_path.'csshover3.htc") url("'.$htc_path.'cleartypefix.htc")';
// Firefox: Ghost margin around buttons, see http://www.sitepoint.com/forums/showthread.php?t=547059
$changed['button::-moz-focus-inner']['padding'][] = '0';
$changed['button::-moz-focus-inner']['border'][] = 'none';
// Webkit: better antialiasing, see http://maxvoltar.com/archive/-webkit-font-smoothing
$changed['html']['-webkit-font-smoothing'][] = 'antialiased';
// Webkit: better kerning, see http://www.aestheticallyloyal.com/public/optimize-legibility/
$changed['html']['text-rendering'][] = 'optimizeLegibility';
// Add comments for the global fixes
foreach($changed as $selector => $styles){
foreach($styles as $property => $value){
CSSP::comment($changed[$selector], $property, 'Added by bugfix plugin');
}
}
// Insert the global bugfixes
$cssp->insert($changed, 'global');
// Apply per-element-bugfixes
// Apply per-block-bugfixes
foreach($cssp->parsed as $block => $css){
// Firefox: overflow:hidden printing bug
if(!isset($cssp->parsed[$block]['body']) || !isset($cssp->parsed[$block]['body']['overflow']))
{
$cssp->parsed[$block]['body']['overflow'][] = 'visible !important';
CSSP::comment($cssp->parsed[$block]['body'], 'overflow', 'Added by bugfix plugin');
}
// Apply per-element-bugfixes
foreach($cssp->parsed[$block] as $selector => $styles){
// IE 6 per-element-bugfixes
if($browser->browser == 'ie' && floatval($browser->browser_version) < 7){
// Float double margin bug, fixed with a behavior as this only affects the floating object and no descendant of it
if(isset($cssp->parsed[$block][$selector]['float']) && $cssp->get_final_value($cssp->parsed[$block][$selector]['float']) != 'none'){
$htc_path = rtrim(dirname($_SERVER['SCRIPT_NAME']),'/').'/plugins/bugfixes/doublemargin.htc';
$cssp->parsed[$block][$selector]['behavior'][] = 'url("'.$htc_path.'")';
CSSP::comment($cssp->parsed[$block][$selector], 'behavior', 'Added by bugfix plugin');
}
// Min-height for IE6
if(isset($cssp->parsed[$block][$selector]['min-height']) && !isset($cssp->parsed[$block][$selector]['height'])){
$cssp->parsed[$block][$selector]['height'] = $cssp->parsed[$block][$selector]['min-height'];
CSSP::comment($cssp->parsed[$block][$selector], 'height', 'Added by bugfix plugin');
}
}
// IE 6 + 7 per-element-bugfixes
if($browser->browser == 'ie' && floatval($browser->browser_version) < 8){
// Enable overflow:hidden, if present
if(isset($cssp->parsed[$block][$selector]['overflow']) && $cssp->get_final_value($cssp->parsed[$block][$selector]['overflow']) == 'hidden' && !isset($cssp->parsed[$block][$selector]['position'])){
$cssp->parsed[$block][$selector]['position'][] = 'relative';
CSSP::comment($cssp->parsed[$block][$selector], 'position', 'Added by bugfix plugin');
}
}
}
}
}
/**
* Register the plugin
*/
$cssp->register_plugin('bugfixes', 'bugfixes', 'before_compile', 0);
?>