author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Sat, 09 Oct 2010 00:05:52 +0200 | |
changeset 6427 | c8a5ac2d1eaa |
parent 4788 | de92a073faa8 |
child 7234 | 69aa3e68c231 |
permissions | -rw-r--r-- |
841
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
1 |
/* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
2 |
* jQuery corner plugin |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
3 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
4 |
* version 1.92 (12/18/2007) |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
5 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
6 |
* Dual licensed under the MIT and GPL licenses: |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
7 |
* http://www.opensource.org/licenses/mit-license.php |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
8 |
* http://www.gnu.org/licenses/gpl.html |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
9 |
*/ |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
10 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
11 |
/** |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
12 |
* The corner() method provides a simple way of styling DOM elements. |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
13 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
14 |
* corner() takes a single string argument: $().corner("effect corners width") |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
15 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
16 |
* effect: The name of the effect to apply, such as round or bevel. |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
17 |
* If you don't specify an effect, rounding is used. |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
18 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
19 |
* corners: The corners can be one or more of top, bottom, tr, tl, br, or bl. |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
20 |
* By default, all four corners are adorned. |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
21 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
22 |
* width: The width specifies the width of the effect; in the case of rounded corners this |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
23 |
* will be the radius of the width. |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
24 |
* Specify this value using the px suffix such as 10px, and yes it must be pixels. |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
25 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
26 |
* For more details see: http://methvin.com/jquery/jq-corner.html |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
27 |
* For a full demo see: http://malsup.com/jquery/corner/ |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
28 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
29 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
30 |
* @example $('.adorn').corner(); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
31 |
* @desc Create round, 10px corners |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
32 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
33 |
* @example $('.adorn').corner("25px"); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
34 |
* @desc Create round, 25px corners |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
35 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
36 |
* @example $('.adorn').corner("notch bottom"); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
37 |
* @desc Create notched, 10px corners on bottom only |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
38 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
39 |
* @example $('.adorn').corner("tr dog 25px"); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
40 |
* @desc Create dogeared, 25px corner on the top-right corner only |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
41 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
42 |
* @example $('.adorn').corner("round 8px").parent().css('padding', '4px').corner("round 10px"); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
43 |
* @desc Create a rounded border effect by styling both the element and its parent |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
44 |
* |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
45 |
* @name corner |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
46 |
* @type jQuery |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
47 |
* @param String options Options which control the corner style |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
48 |
* @cat Plugins/Corner |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
49 |
* @return jQuery |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
50 |
* @author Dave Methvin (dave.methvin@gmail.com) |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
51 |
* @author Mike Alsup (malsup@gmail.com) |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
52 |
*/ |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
53 |
(function($) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
54 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
55 |
$.fn.corner = function(o) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
56 |
var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
57 |
function sz(el, p) { return parseInt($.css(el,p))||0; }; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
58 |
function hex2(s) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
59 |
var s = parseInt(s).toString(16); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
60 |
return ( s.length < 2 ) ? '0'+s : s; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
61 |
}; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
62 |
function gpc(node) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
63 |
for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
64 |
var v = $.css(node,'backgroundColor'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
65 |
if ( v.indexOf('rgb') >= 0 ) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
66 |
if ($.browser.safari && v == 'rgba(0, 0, 0, 0)') |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
67 |
continue; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
68 |
var rgb = v.match(/\d+/g); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
69 |
return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
70 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
71 |
if ( v && v != 'transparent' ) |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
72 |
return v; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
73 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
74 |
return '#ffffff'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
75 |
}; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
76 |
function getW(i) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
77 |
switch(fx) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
78 |
case 'round': return Math.round(width*(1-Math.cos(Math.asin(i/width)))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
79 |
case 'cool': return Math.round(width*(1+Math.cos(Math.asin(i/width)))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
80 |
case 'sharp': return Math.round(width*(1-Math.cos(Math.acos(i/width)))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
81 |
case 'bite': return Math.round(width*(Math.cos(Math.asin((width-i-1)/width)))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
82 |
case 'slide': return Math.round(width*(Math.atan2(i,width/i))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
83 |
case 'jut': return Math.round(width*(Math.atan2(width,(width-i-1)))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
84 |
case 'curl': return Math.round(width*(Math.atan(i))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
85 |
case 'tear': return Math.round(width*(Math.cos(i))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
86 |
case 'wicked': return Math.round(width*(Math.tan(i))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
87 |
case 'long': return Math.round(width*(Math.sqrt(i))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
88 |
case 'sculpt': return Math.round(width*(Math.log((width-i-1),width))); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
89 |
case 'dog': return (i&1) ? (i+1) : width; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
90 |
case 'dog2': return (i&2) ? (i+1) : width; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
91 |
case 'dog3': return (i&3) ? (i+1) : width; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
92 |
case 'fray': return (i%2)*width; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
93 |
case 'notch': return width; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
94 |
case 'bevel': return i+1; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
95 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
96 |
}; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
97 |
o = (o||"").toLowerCase(); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
98 |
var keep = /keep/.test(o); // keep borders? |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
99 |
var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]); // corner color |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
100 |
var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]); // strip color |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
101 |
var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
102 |
var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
103 |
var fx = ((o.match(re)||['round'])[0]); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
104 |
var edges = { T:0, B:1 }; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
105 |
var opts = { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
106 |
TL: /top|tl/.test(o), TR: /top|tr/.test(o), |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
107 |
BL: /bottom|bl/.test(o), BR: /bottom|br/.test(o) |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
108 |
}; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
109 |
if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR ) |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
110 |
opts = { TL:1, TR:1, BL:1, BR:1 }; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
111 |
var strip = document.createElement('div'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
112 |
strip.style.overflow = 'hidden'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
113 |
strip.style.height = '1px'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
114 |
strip.style.backgroundColor = sc || 'transparent'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
115 |
strip.style.borderStyle = 'solid'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
116 |
return this.each(function(index){ |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
117 |
var pad = { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
118 |
T: parseInt($.css(this,'paddingTop'))||0, R: parseInt($.css(this,'paddingRight'))||0, |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
119 |
B: parseInt($.css(this,'paddingBottom'))||0, L: parseInt($.css(this,'paddingLeft'))||0 |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
120 |
}; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
121 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
122 |
if ($.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
123 |
if (!keep) this.style.border = 'none'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
124 |
strip.style.borderColor = cc || gpc(this.parentNode); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
125 |
var cssHeight = $.curCSS(this, 'height'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
126 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
127 |
for (var j in edges) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
128 |
var bot = edges[j]; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
129 |
// only add stips if needed |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
130 |
if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
131 |
strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
132 |
var d = document.createElement('div'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
133 |
$(d).addClass('jquery-corner'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
134 |
var ds = d.style; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
135 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
136 |
bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
137 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
138 |
if (bot && cssHeight != 'auto') { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
139 |
if ($.css(this,'position') == 'static') |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
140 |
this.style.position = 'relative'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
141 |
ds.position = 'absolute'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
142 |
ds.bottom = ds.left = ds.padding = ds.margin = '0'; |
4788
de92a073faa8
applied vgodard patch for jquery rounded corner w/ MSIE >= 8
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
841
diff
changeset
|
143 |
if (($.browser.msie) && ($.browser.version < 8.0)) |
841
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
144 |
ds.setExpression('width', 'this.parentNode.offsetWidth'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
145 |
else |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
146 |
ds.width = '100%'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
147 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
148 |
else if (!bot && $.browser.msie) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
149 |
if ($.css(this,'position') == 'static') |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
150 |
this.style.position = 'relative'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
151 |
ds.position = 'absolute'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
152 |
ds.top = ds.left = ds.right = ds.padding = ds.margin = '0'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
153 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
154 |
// fix ie6 problem when blocked element has a border width |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
155 |
var bw = 0; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
156 |
if (ie6 || !$.boxModel) |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
157 |
bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth'); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
158 |
ie6 ? ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"') : ds.width = '100%'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
159 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
160 |
else { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
161 |
ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
162 |
(pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
163 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
164 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
165 |
for (var i=0; i < width; i++) { |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
166 |
var w = Math.max(0,getW(i)); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
167 |
var e = strip.cloneNode(false); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
168 |
e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px'; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
169 |
bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
170 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
171 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
172 |
} |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
173 |
}); |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
174 |
}; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
175 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
176 |
$.fn.uncorner = function(o) { return $('.jquery-corner', this).remove(); }; |
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
177 |
|
ce9ba491f8ef
new jquery.corner.js version which doesn't make IE6 crash
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
30
diff
changeset
|
178 |
})(jQuery); |