-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathborder-radius-v4.htc
108 lines (88 loc) · 3.77 KB
/
border-radius-v4.htc
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
--Do not remove this if you are using--
Original Author: Remiz Rahnas
Original Author URL: http://www.htmlremix.com
Published date: 2008/09/24
Changes by Nick Fetchak:
- IE8 standards mode compatibility
- VML elements now positioned behind original box rather than inside of it - should be less prone to breakage
Published date : 2009/11/18
Changes by Tyler Waters, BCGOV
- fixed 'createStyleSheet' invalid operation issue
- revised positioning and removed resize code
- various other improvements
Published date: 2011-09-29
<public:attach event="oncontentready" onevent="oncontentready('v08vnSVo78t4JfjH')" />
<script type="text/javascript">
function oncontentready(clsid){
//console.log("oncontentreaday: " + this.id)
// make sure we aren't running this more than once on the same element
if (this.className.match(clsid)) { return(false); }
// add VML bits to the document (v: namespace, as well as default style rule that must be present for VML )
if (!document.namespaces.v) { document.namespaces.add("vml", "urn:schemas-microsoft-com:vml"); }
for( var s=window.document.styleSheets, x=s.length-1; x>=0; x-=1 ) if(s[x].title==="VML") break;
if( x === -1 ) {
var vmlcss = window.document.createStyleSheet();
vmlcss.addRule("vml\\:roundrect", "behavior: url(#default#VML)");
vmlcss.addRule("vml\\:fill", "behavior: url(#default#VML)");
vmlcss.title = "VML";
//css2 = window.document.createStyleSheet();
vmlcss.addRule("."+clsid , "background:transparent !important; border:0 transparent !important;");
//css2.disabled = 'disabled'
}
// find the existing element styles from context -- these will be worked into the RECT/FILL elements.
var el = this,
w = el.offsetWidth,
h = el.offsetHeight,
s = el.currentStyle,
mz = s["-moz-border-radius"],
wk = s["-webkit-border-radius"],
w3 = s["border-radius"],
kn = s["-khtml-border-radius"],
fillColor = s["backgroundColor"],
fillSrc = (s["backgroundImage"] || "").replace(/^url\(["']?(.+?)["']?\)$/, "$1"),
strokeColor = s["borderColor"],
strokeWeight = parseInt(s["borderWidth"]),
stroked = "true",
arcSize = Math.min(parseInt( w3 || mz || wk || kn || 0 ) / Math.min(w, h), 1),
rect = document.createElement("vml:roundrect"),
isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
// vml assumes transparent means black. none works.
fillColor = fillColor === 'transparent' ? 'none' : fillColor ;
// when border not present, use fill details
if (isNaN(strokeWeight)) {
strokeWeight = 0;
strokeColor = fillColor;
stroked = "false";
}
// when position isn't relative/absolute/fixed, set to relative.
// this is important, because the RECT uses position:absolute.
if( s.position === "static" ) { el.style.position = "relative"; }
// IE6 doesn't support transparent borders, use padding to offset original element
if (isIE6 && (strokeWeight > 0)) {
el.style.borderStyle = "none";
el.style.paddingTop = parseInt(s.paddingTop || 0) + strokeWeight;
el.style.paddingBottom = parseInt(s.paddingBottom || 0) + strokeWeight;
}
rect.arcsize = arcSize + "px";
rect.strokecolor = strokeColor;
rect.strokeWeight = strokeWeight + "px";
rect.stroked = stroked;
rect.style.display = "block";
rect.style.position = "absolute";
rect.style.top = "0";
rect.style.left = "0";
rect.style.width = "100%";
rect.style.height = "100%";
rect.style.antialias = true;
rect.style.zIndex = -1;
if( fillSrc !== 'none' ) {
var fill = document.createElement("vml:fill")
fill.src = fillSrc;
fill.type = "tile";
rect.appendChild(fill)
}
else {rect.fillcolor = fillColor }
el.appendChild( rect );
el.className = this.className.concat(" ", clsid);
}
</script>