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