1;(function($) { 2 3var style = document.createElement('div').style, 4 moz = style['MozBorderRadius'] !== undefined, 5 webkit = style['WebkitBorderRadius'] !== undefined, 6 radius = style['borderRadius'] !== undefined || style['BorderRadius'] !== undefined, 7 mode = document.documentMode || 0, 8 noBottomFold = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8), 9 10 expr = $.browser.msie && (function() { 11 var div = document.createElement('div'); 12 try { div.style.setExpression('width','0+0'); div.style.removeExpression('width'); } 13 catch(e) { return false; } 14 return true; 15 })(); 16 17$.support = $.support || {}; 18$.support.borderRadius = moz || webkit || radius; // so you can do: if (!$.support.borderRadius) $('#myDiv').corner(); 19 20function sz(el, p) { 21 return parseInt($.css(el,p))||0; 22}; 23function hex2(s) { 24 var s = parseInt(s).toString(16); 25 return ( s.length < 2 ) ? '0'+s : s; 26}; 27function gpc(node) { 28 while(node) { 29 var v = $.css(node,'backgroundColor'), rgb; 30 if (v && v != 'transparent' && v != 'rgba(0, 0, 0, 0)') { 31 if (v.indexOf('rgb') >= 0) { 32 rgb = v.match(/\d+/g); 33 return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]); 34 } 35 return v; 36 } 37 if (node.nodeName.toLowerCase() == 'html') 38 break; 39 node = node.parentNode; // keep walking if transparent 40 } 41 return '#ffffff'; 42}; 43 44function getWidth(fx, i, width) { 45 switch(fx) { 46 case 'round': return Math.round(width*(1-Math.cos(Math.asin(i/width)))); 47 case 'cool': return Math.round(width*(1+Math.cos(Math.asin(i/width)))); 48 case 'sharp': return Math.round(width*(1-Math.cos(Math.acos(i/width)))); 49 case 'bite': return Math.round(width*(Math.cos(Math.asin((width-i-1)/width)))); 50 case 'slide': return Math.round(width*(Math.atan2(i,width/i))); 51 case 'jut': return Math.round(width*(Math.atan2(width,(width-i-1)))); 52 case 'curl': return Math.round(width*(Math.atan(i))); 53 case 'tear': return Math.round(width*(Math.cos(i))); 54 case 'wicked': return Math.round(width*(Math.tan(i))); 55 case 'long': return Math.round(width*(Math.sqrt(i))); 56 case 'sculpt': return Math.round(width*(Math.log((width-i-1),width))); 57 case 'dogfold': 58 case 'dog': return (i&1) ? (i+1) : width; 59 case 'dog2': return (i&2) ? (i+1) : width; 60 case 'dog3': return (i&3) ? (i+1) : width; 61 case 'fray': return (i%2)*width; 62 case 'notch': return width; 63 case 'bevelfold': 64 case 'bevel': return i+1; 65 } 66}; 67 68$.fn.corner = function(options) { 69 // in 1.3+ we can fix mistakes with the ready state 70 if (this.length == 0) { 71 if (!$.isReady && this.selector) { 72 var s = this.selector, c = this.context; 73 $(function() { 74 $(s,c).corner(options); 75 }); 76 } 77 return this; 78 } 79 80 return this.each(function(index){ 81 var $this = $(this), 82 // meta values override options 83 o = [$this.attr($.fn.corner.defaults.metaAttr) || '', options || ''].join(' ').toLowerCase(), 84 keep = /keep/.test(o), // keep borders? 85 cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]), // corner color 86 sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]), // strip color 87 width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10, // corner width 88 re = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/, 89 fx = ((o.match(re)||['round'])[0]), 90 fold = /dogfold|bevelfold/.test(o), 91 edges = { T:0, B:1 }, 92 opts = { 93 TL: /top|tl|left/.test(o), TR: /top|tr|right/.test(o), 94 BL: /bottom|bl|left/.test(o), BR: /bottom|br|right/.test(o) 95 }, 96 // vars used in func later 97 strip, pad, cssHeight, j, bot, d, ds, bw, i, w, e, c, common, $horz; 98 99 if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR ) 100 opts = { TL:1, TR:1, BL:1, BR:1 }; 101 102 // support native rounding 103 if ($.fn.corner.defaults.useNative && fx == 'round' && (radius || moz || webkit) && !cc && !sc) { 104 if (opts.TL) 105 $this.css(radius ? 'border-top-left-radius' : moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px'); 106 if (opts.TR) 107 $this.css(radius ? 'border-top-right-radius' : moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px'); 108 if (opts.BL) 109 $this.css(radius ? 'border-bottom-left-radius' : moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px'); 110 if (opts.BR) 111 $this.css(radius ? 'border-bottom-right-radius' : moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px'); 112 return; 113 } 114
115 strip = document.createElement('div'); 116 $(strip).css({ 117 overflow: 'hidden', 118 height: '1px', 119 minHeight: '1px', 120 fontSize: '1px', 121 backgroundColor: sc || 'transparent', 122 borderStyle: 'solid' 123 }); 124 125 pad = { 126 T: parseInt($.css(this,'paddingTop'))||0, R: parseInt($.css(this,'paddingRight'))||0, 127 B: parseInt($.css(this,'paddingBottom'))||0, L: parseInt($.css(this,'paddingLeft'))||0 128 }; 129 130 if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE 131 if (!keep) this.style.border = 'none'; 132 strip.style.borderColor = cc || gpc(this.parentNode); 133 cssHeight = $(this).outerHeight(); 134 135 for (j in edges) { 136 bot = edges[j]; 137 // only add stips if needed 138 if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) { 139 strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none'); 140 d = document.createElement('div'); 141 $(d).addClass('jquery-corner'); 142 ds = d.style; 143 144 bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild); 145 146 if (bot && cssHeight != 'auto') { 147 if ($.css(this,'position') == 'static') 148 this.style.position = 'relative'; 149 ds.position = 'absolute'; 150 ds.bottom = ds.left = ds.padding = ds.margin = '0'; 151 if (expr) 152 ds.setExpression('width', 'this.parentNode.offsetWidth'); 153 else 154 ds.width = '100%'; 155 } 156 else if (!bot && $.browser.msie) { 157 if ($.css(this,'position') == 'static') 158 this.style.position = 'relative'; 159 ds.position = 'absolute'; 160 ds.top = ds.left = ds.right = ds.padding = ds.margin = '0'; 161 162 // fix ie6 problem when blocked element has a border width 163 if (expr) { 164 bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth'); 165 ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"'); 166 } 167 else 168 ds.width = '100%'; 169 } 170 else { 171 ds.position = 'relative'; 172 ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 173 (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px'; 174 } 175 176 for (i=0; i < width; i++) { 177 w = Math.max(0,getWidth(fx,i, width)); 178 e = strip.cloneNode(false); 179 e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px'; 180 bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild); 181 } 182 183 if (fold && $.support.boxModel) { 184 if (bot && noBottomFold) continue; 185 for (c in opts) { 186 if (!opts[c]) continue; 187 if (bot && (c == 'TL' || c == 'TR')) continue; 188 if (!bot && (c == 'BL' || c == 'BR')) continue; 189 190 common = { position: 'absolute', border: 'none', margin: 0, padding: 0, overflow: 'hidden', backgroundColor: strip.style.borderColor }; 191 $horz = $('<div/>').css(common).css({ width: width + 'px', height: '1px' }); 192 switch(c) { 193 case 'TL': $horz.css({ bottom: 0, left: 0 }); break; 194 case 'TR': $horz.css({ bottom: 0, right: 0 }); break; 195 case 'BL': $horz.css({ top: 0, left: 0 }); break; 196 case 'BR': $horz.css({ top: 0, right: 0 }); break; 197 } 198 d.appendChild($horz[0]); 199
200 var $vert = $('<div/>').css(common).css({ top: 0, bottom: 0, width: '1px', height: width + 'px' }); 201 switch(c) { 202 case 'TL': $vert.css({ left: width }); break; 203 case 'TR': $vert.css({ right: width }); break; 204 case 'BL': $vert.css({ left: width }); break; 205 case 'BR': $vert.css({ right: width }); break; 206 } 207 d.appendChild($vert[0]); 208 } 209 } 210 } 211 } 212 }); 213}; 214 215$.fn.uncorner = function() { 216 if (radius || moz || webkit) 217 this.css(radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius', 0); 218 $('div.jquery-corner', this).remove(); 219 return this; 220}; 221 222// expose options 223$.fn.corner.defaults = { 224 useNative: true, // true if plugin should attempt to use native browser support for border radius rounding 225 metaAttr: 'data-corner' // name of meta attribute to use for options 226}; 227 228})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.