Changeset 4585


Ignore:
Timestamp:
08/21/10 14:24:37 (18 months ago)
Author:
vain
Message:
  • Dropped jQuery corner v1.99
  • Tagging jQuery corner v2.11
  • Updating [vendor][current] to v2.11
Location:
vendors/js-jquery-corner
Files:
2 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • vendors/js-jquery-corner/current/jquery.corner.js

    r3293 r4585  
    22 * jQuery corner plugin: simple corner rounding 
    33 * Examples and documentation at: http://jquery.malsup.com/corner/ 
    4  * version 1.99 (28-JUL-2009) 
     4 * version 2.11 (15-JUN-2010) 
     5 * Requires jQuery v1.3.2 or later 
    56 * Dual licensed under the MIT and GPL licenses: 
    67 * http://www.opensource.org/licenses/mit-license.php 
    78 * http://www.gnu.org/licenses/gpl.html 
     9 * Authors: Dave Methvin and Mike Alsup 
    810 */ 
    911 
     
    1214 * 
    1315 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round).  
    14  *  corners: one or more of: top, bottom, tr, tl, br, or bl.  
    15  *           by default, all four corners are adorned.  
     16 *  corners: one or more of: top, bottom, tr, tl, br, or bl.  (default is all corners) 
    1617 *  width:   width of the effect; in the case of rounded corners this is the radius.  
    17  *           specify this value using the px suffix such as 10px (and yes, it must be pixels). 
    18  * 
    19  * @name corner 
    20  * @type jQuery 
    21  * @param String options Options which control the corner style 
    22  * @cat Plugins/Corner 
    23  * @return jQuery 
    24  * @author Dave Methvin (http://methvin.com/jquery/jq-corner.html) 
    25  * @author Mike Alsup   (http://jquery.malsup.com/corner/) 
     18 *           specify this value using the px suffix such as 10px (yes, it must be pixels). 
    2619 */ 
    2720;(function($) {  
    2821 
    29 var expr = (function() { 
    30         if (! $.browser.msie) return false; 
    31     var div = document.createElement('div'); 
    32     try { div.style.setExpression('width','0+0'); } 
    33     catch(e) { return false; } 
    34     return true; 
    35 })(); 
    36      
     22var style = document.createElement('div').style, 
     23    moz = style['MozBorderRadius'] !== undefined, 
     24    webkit = style['WebkitBorderRadius'] !== undefined, 
     25    radius = style['borderRadius'] !== undefined || style['BorderRadius'] !== undefined, 
     26    mode = document.documentMode || 0, 
     27    noBottomFold = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8), 
     28 
     29    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 
     36$.support = $.support || {}; 
     37$.support.borderRadius = moz || webkit || radius; // so you can do:  if (!$.support.borderRadius) $('#myDiv').corner(); 
     38 
    3739function sz(el, p) {  
    3840    return parseInt($.css(el,p))||0;  
     
    4345}; 
    4446function gpc(node) { 
    45     for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) { 
    46         var v = $.css(node,'backgroundColor'); 
    47         if (v == 'rgba(0, 0, 0, 0)') 
    48             continue; // webkit 
    49         if (v.indexOf('rgb') >= 0) {  
    50             var rgb = v.match(/\d+/g);  
    51             return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]); 
    52         } 
    53         if ( v && v != 'transparent' ) 
     47    while(node) { 
     48        var v = $.css(node,'backgroundColor'), rgb; 
     49        if (v && v != 'transparent' && v != 'rgba(0, 0, 0, 0)') { 
     50            if (v.indexOf('rgb') >= 0) {  
     51                rgb = v.match(/\d+/g);  
     52                return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]); 
     53            } 
    5454            return v; 
     55        } 
     56        if (node.nodeName.toLowerCase() == 'html') 
     57            break; 
     58        node = node.parentNode; // keep walking if transparent 
    5559    } 
    5660    return '#ffffff'; 
     
    7074    case 'long':   return Math.round(width*(Math.sqrt(i))); 
    7175    case 'sculpt': return Math.round(width*(Math.log((width-i-1),width))); 
     76    case 'dogfold': 
    7277    case 'dog':    return (i&1) ? (i+1) : width; 
    7378    case 'dog2':   return (i&2) ? (i+1) : width; 
     
    7580    case 'fray':   return (i%2)*width; 
    7681    case 'notch':  return width;  
     82    case 'bevelfold': 
    7783    case 'bevel':  return i+1; 
    7884    } 
    7985}; 
    8086 
    81 $.fn.corner = function(o) { 
     87$.fn.corner = function(options) { 
    8288    // in 1.3+ we can fix mistakes with the ready state 
    83         if (this.length == 0) { 
     89    if (this.length == 0) { 
    8490        if (!$.isReady && this.selector) { 
    8591            var s = this.selector, c = this.context; 
    8692            $(function() { 
    87                 $(s,c).corner(o); 
     93                $(s,c).corner(options); 
    8894            }); 
    8995        } 
    9096        return this; 
    91         } 
    92  
    93     o = (o||"").toLowerCase(); 
    94     var keep = /keep/.test(o);                       // keep borders? 
    95     var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color 
    96     var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color 
    97     var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width 
    98     var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/; 
    99     var fx = ((o.match(re)||['round'])[0]); 
    100     var edges = { T:0, B:1 }; 
    101     var opts = { 
    102         TL:  /top|tl/.test(o),       TR:  /top|tr/.test(o), 
    103         BL:  /bottom|bl/.test(o),    BR:  /bottom|br/.test(o) 
    104     }; 
    105     if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR ) 
    106         opts = { TL:1, TR:1, BL:1, BR:1 }; 
    107     var strip = document.createElement('div'); 
    108     strip.style.overflow = 'hidden'; 
    109     strip.style.height = '1px'; 
    110     strip.style.backgroundColor = sc || 'transparent'; 
    111     strip.style.borderStyle = 'solid'; 
     97    } 
     98 
    11299    return this.each(function(index){ 
    113         var pad = { 
     100        var $this = $(this), 
     101            // meta values override options 
     102            o = [$this.attr($.fn.corner.defaults.metaAttr) || '', options || ''].join(' ').toLowerCase(), 
     103            keep = /keep/.test(o),                       // keep borders? 
     104            cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]),  // corner color 
     105            sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]),  // strip color 
     106            width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10, // corner width 
     107            re = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/, 
     108            fx = ((o.match(re)||['round'])[0]), 
     109            fold = /dogfold|bevelfold/.test(o), 
     110            edges = { T:0, B:1 }, 
     111            opts = { 
     112                TL:  /top|tl|left/.test(o),       TR:  /top|tr|right/.test(o), 
     113                BL:  /bottom|bl|left/.test(o),    BR:  /bottom|br|right/.test(o) 
     114            }, 
     115            // vars used in func later 
     116            strip, pad, cssHeight, j, bot, d, ds, bw, i, w, e, c, common, $horz; 
     117         
     118        if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR ) 
     119            opts = { TL:1, TR:1, BL:1, BR:1 }; 
     120             
     121        // support native rounding 
     122        if ($.fn.corner.defaults.useNative && fx == 'round' && (radius || moz || webkit) && !cc && !sc) { 
     123            if (opts.TL) 
     124                $this.css(radius ? 'border-top-left-radius' : moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px'); 
     125            if (opts.TR) 
     126                $this.css(radius ? 'border-top-right-radius' : moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px'); 
     127            if (opts.BL) 
     128                $this.css(radius ? 'border-bottom-left-radius' : moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px'); 
     129            if (opts.BR) 
     130                $this.css(radius ? 'border-bottom-right-radius' : moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px'); 
     131            return; 
     132        } 
     133             
     134        strip = document.createElement('div'); 
     135        $(strip).css({ 
     136            overflow: 'hidden', 
     137            height: '1px', 
     138            minHeight: '1px', 
     139            fontSize: '1px', 
     140            backgroundColor: sc || 'transparent', 
     141            borderStyle: 'solid' 
     142        }); 
     143     
     144        pad = { 
    114145            T: parseInt($.css(this,'paddingTop'))||0,     R: parseInt($.css(this,'paddingRight'))||0, 
    115146            B: parseInt($.css(this,'paddingBottom'))||0,  L: parseInt($.css(this,'paddingLeft'))||0 
     
    119150        if (!keep) this.style.border = 'none'; 
    120151        strip.style.borderColor = cc || gpc(this.parentNode); 
    121         var cssHeight = $.curCSS(this, 'height'); 
    122  
    123         for (var j in edges) { 
    124             var bot = edges[j]; 
     152        cssHeight = $(this).outerHeight(); 
     153 
     154        for (j in edges) { 
     155            bot = edges[j]; 
    125156            // only add stips if needed 
    126157            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) { 
    127158                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none'); 
    128                 var d = document.createElement('div'); 
     159                d = document.createElement('div'); 
    129160                $(d).addClass('jquery-corner'); 
    130                 var ds = d.style; 
     161                ds = d.style; 
    131162 
    132163                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild); 
     
    150181                    // fix ie6 problem when blocked element has a border width 
    151182                    if (expr) { 
    152                         var bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth'); 
     183                        bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth'); 
    153184                        ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"'); 
    154185                    } 
     
    157188                } 
    158189                else { 
    159                         ds.position = 'relative'; 
     190                    ds.position = 'relative'; 
    160191                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' :  
    161192                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                 
    162193                } 
    163194 
    164                 for (var i=0; i < width; i++) { 
    165                     var w = Math.max(0,getWidth(fx,i, width)); 
    166                     var e = strip.cloneNode(false); 
     195                for (i=0; i < width; i++) { 
     196                    w = Math.max(0,getWidth(fx,i, width)); 
     197                    e = strip.cloneNode(false); 
    167198                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px'; 
    168199                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild); 
    169200                } 
     201                 
     202                if (fold && $.support.boxModel) { 
     203                    if (bot && noBottomFold) continue; 
     204                    for (c in opts) { 
     205                        if (!opts[c]) continue; 
     206                        if (bot && (c == 'TL' || c == 'TR')) continue; 
     207                        if (!bot && (c == 'BL' || c == 'BR')) continue; 
     208                         
     209                        common = { position: 'absolute', border: 'none', margin: 0, padding: 0, overflow: 'hidden', backgroundColor: strip.style.borderColor }; 
     210                        $horz = $('<div/>').css(common).css({ width: width + 'px', height: '1px' }); 
     211                        switch(c) { 
     212                        case 'TL': $horz.css({ bottom: 0, left: 0 }); break; 
     213                        case 'TR': $horz.css({ bottom: 0, right: 0 }); break; 
     214                        case 'BL': $horz.css({ top: 0, left: 0 }); break; 
     215                        case 'BR': $horz.css({ top: 0, right: 0 }); break; 
     216                        } 
     217                        d.appendChild($horz[0]); 
     218                         
     219                        var $vert = $('<div/>').css(common).css({ top: 0, bottom: 0, width: '1px', height: width + 'px' }); 
     220                        switch(c) { 
     221                        case 'TL': $vert.css({ left: width }); break; 
     222                        case 'TR': $vert.css({ right: width }); break; 
     223                        case 'BL': $vert.css({ left: width }); break; 
     224                        case 'BR': $vert.css({ right: width }); break; 
     225                        } 
     226                        d.appendChild($vert[0]); 
     227                    } 
     228                } 
    170229            } 
    171230        } 
     
    174233 
    175234$.fn.uncorner = function() {  
    176         $('div.jquery-corner', this).remove(); 
    177         return this; 
     235    if (radius || moz || webkit) 
     236        this.css(radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius', 0); 
     237    $('div.jquery-corner', this).remove(); 
     238    return this; 
     239}; 
     240 
     241// expose options 
     242$.fn.corner.defaults = { 
     243    useNative: true, // true if plugin should attempt to use native browser support for border radius rounding 
     244    metaAttr:  'data-corner' // name of meta attribute to use for options 
    178245}; 
    179246     
Note: See TracChangeset for help on using the changeset viewer.