Вход Регистрация
Файл: upload/static/jscript/jquery/plugin/jquery.corners.js
Строк: 424
<?php
/*!
 * jQuery Corners 0.3
 * Copyright (c) 2008 David Turnbull, Steven Wittens
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 */

jQuery.fn.corners = function(options) {
  var 
doneClass 'rounded_by_jQuery_corners'/* To prevent double rounding */
  
var settings parseOptions(options);
  var 
webkitAvailable false;
  try {
    
webkitAvailable = (document.body.style.WebkitBorderRadius !== undefined);
    
/* Google Chrome corners look awful */
    
var versionIndex navigator.userAgent.indexOf('Chrome');
    if (
versionIndex >= 0webkitAvailable false;
  } catch(
err) {}
  var 
mozillaAvailable false;
  try {
    
mozillaAvailable = (document.body.style.MozBorderRadius !== undefined);
    
/* Firefox 2 corners look worse */
    
var versionIndex navigator.userAgent.indexOf('Firefox');
    if (
versionIndex >= && parseInt(navigator.userAgent.substring(versionIndex+8)) < 3mozillaAvailable false;
  } catch(
err) {}
  return 
this.each(function(i,e){
    
$e jQuery(e);
    if (
$e.hasClass(doneClass)) return;
    
$e.addClass(doneClass);
    var 
classScan = /{(.*)}/.exec(e.className);
    var 
classScan parseOptions(classScan[1], settings) : settings;
    var 
nodeName e.nodeName.toLowerCase();
    if (
nodeName=='input'changeInput(e);
    if (
webkitAvailable && s.webkitroundWebkit(es);
    else if(
mozillaAvailable && s.mozilla && (s.sizex == s.sizey)) roundMozilla(es);
    else {
      var 
bgColor backgroundColor(e.parentNode);
      var 
fgColor backgroundColor(e);
      switch (
nodeName) {
        case 
'a':
        case 
'input':
          
roundLink(esbgColorfgColor);
          break;
        default:
          
roundDiv(esbgColorfgColor);
          break;
      }
    }
  });
  
  function 
roundWebkit(es) {
    var 
radius '' s.sizex 'px ' s.sizey 'px';
    var 
$e jQuery(e);
    if (
s.tl$e.css('WebkitBorderTopLeftRadius'radius);
    if (
s.tr$e.css('WebkitBorderTopRightRadius'radius);
    if (
s.bl$e.css('WebkitBorderBottomLeftRadius'radius);
    if (
s.br$e.css('WebkitBorderBottomRightRadius'radius);
  }
  
  function 
roundMozilla(es)
  {  
    var 
radius '' s.sizex 'px';
    var 
$e jQuery(e);
    if (
s.tl$e.css('-moz-border-radius-topleft'radius);
    if (
s.tr$e.css('-moz-border-radius-topright'radius);
    if (
s.bl$e.css('-moz-border-radius-bottomleft'radius);
    if (
s.br$e.css('-moz-border-radius-bottomright'radius);  
  }
  
  function 
roundLink(esbgColorfgColor) {
    var 
table tableElement("table");
    var 
tbody tableElement("tbody");
    
table.appendChild(tbody);
    var 
tr1 tableElement("tr");
    var 
td1 tableElement("td""top");
    
tr1.appendChild(td1);
    var 
tr2 tableElement("tr");
    var 
td2 relocateContent(estableElement("td"));
    
tr2.appendChild(td2);
    var 
tr3 tableElement("tr");
    var 
td3 tableElement("td""bottom");
    
tr3.appendChild(td3);
    if (
s.tl||s.tr) {
      
tbody.appendChild(tr1);
      
addCorners(td1sbgColorfgColortrue);
    }
    
tbody.appendChild(tr2);
    if (
s.bl||s.br) {
      
tbody.appendChild(tr3);
      
addCorners(td3sbgColorfgColorfalse);
    }
    
e.appendChild(table);
    
/* Clicking on $('a>table') in IE will trigger onclick but not the href  */
    
if (jQuery.browser.msietable.onclick ieLinkBypass;
    
/* Firefox 2 will render garbage unless we hide the overflow here */
    
e.style.overflow 'hidden';
  }
  
  function 
ieLinkBypass() {
    if (!
this.parentNode.onclickthis.parentNode.click();
  }
  
  function 
changeInput(e) {
    var 
a1 document.createElement("a");
    
a1.id e.id;
    
a1.className e.className;
    if (
e.onclick) {
      
a1.href 'javascript:'
      
a1.onclick e.onclick;
    } else {
      
jQuery(e).parent('form').each(function() {a1.href this.action;});
      
a1.onclick submitForm;
    }
    var 
a2 document.createTextNode(e.value);
    
a1.appendChild(a2);
    
e.parentNode.replaceChild(a1e);
    return 
a1;
  }

  function 
submitForm() {
    
jQuery(this).parent('form').each(function() {this.submit()});
    return 
false;
  }

  function 
roundDiv(esbgColorfgColor) {
    var 
div relocateContent(esdocument.createElement('div'));
    
e.appendChild(div);
    if (
s.tl||s.traddCorners(esbgColorfgColortrue);
    if (
s.bl||s.braddCorners(esbgColorfgColorfalse);
  }
  
  function 
relocateContent(esd) {
    var 
$e jQuery(e);
    var 
c;
    while(
c=e.firstChildd.appendChild(c);
    if (
e.style.height) {
      var 
parseInt($e.css('height'));
      
d.style.height 'px';
      
+= parseInt($e.css('padding-top')) + parseInt($e.css('padding-bottom'));
      
e.style.height 'px';
    }
    if (
e.style.width) {
      var 
parseInt($e.css('width'));
      
d.style.width 'px';
      
+= parseInt($e.css('padding-left')) + parseInt($e.css('padding-right'));
      
e.style.width 'px';
    }
    
d.style.paddingLeft $e.css('padding-left');
    
d.style.paddingRight $e.css('padding-right');
    if (
s.tl||s.tr) {
      
d.style.paddingTop adjustedPadding(es$e.css('padding-top'), true);
    } else {
      
d.style.paddingTop $e.css('padding-top');
    }
    if (
s.bl||s.br) {
      
d.style.paddingBottom adjustedPadding(es$e.css('padding-bottom'), false);
    } else {
      
d.style.paddingBottom $e.css('padding-bottom');
    }
    
e.style.padding 0;
    return 
d;
  }
  
  function 
adjustedPadding(espadtop) {
    if (
pad.indexOf("px") < 0) {
      try {
        
//TODO Make this check work otherwise remove it
        
console.error('%s padding not in pixels', (top 'top' 'bottom'), e);
      }
      catch(
err) {}
      
pad s.sizey 'px';
    }
    
pad parseInt(pad);
    if (
pad s.sizey 0) {
      try {
        
console.error('%s padding is %ipx for %ipx corner:', (top 'top' 'bottom'), pads.sizeye);
      }
      catch(
err) {}
      
pad s.sizey;
    }
    return 
pad s.sizey 'px';
  }

  function 
tableElement(kindvalign) {
    var 
document.createElement(kind)
    
e.style.border 'none';
    
e.style.borderCollapse 'collapse';
    
e.style.borderSpacing 0;
    
e.style.padding 0;
    
e.style.margin 0;
    if (
valigne.style.verticalAlign valign;
    return 
e;
  }
  
  function 
backgroundColor(e) {
    try {
      var 
jQuery.css(e"background-color");
      if ( 
c.match(/^(transparent|rgba(0,s*0,s*0,s*0))$/i) && e.parentNode )
         return 
backgroundColor(e.parentNode);
      if (
c==null)
        return 
"#ffffff";
      if (
c.indexOf("rgb") > -1)
          
rgb2hex(c);
      if (
c.length == 4)
          
hexShort2hex(c);
      return 
c;
    } catch(
err) {
      return 
"#ffffff";
    }
  }
  
  function 
hexShort2hex(c) {
    return 
'#' +
    
c.substring(1,2) +
    
c.substring(1,2) +
    
c.substring(2,3) +
    
c.substring(2,3) +
    
c.substring(3,4) +
    
c.substring(3,4);
  }

  function 
rgb2hex(c) {
      var 
255;
      var 
hex '';
      var 
i;
      var 
regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
      var array=
regexp.exec(c);
      for(
i=1;i<4;i++) hex += ('0'+parseInt(array[i]).toString(16)).slice(-2);
      return 
'#'+hex;
  }
  
  function 
parseOptions(optionssettings) {
    var 
options options || '';
    var 
= {sizex:5sizey:5tlfalsetrfalseblfalsebrfalsewebkit:truemozillatruetransparent:false};
    if (
settings) {
      
s.sizex settings.sizex;
      
s.sizey settings.sizey;
      
s.webkit settings.webkit;
      
s.transparent settings.transparent;
      
s.mozilla settings.mozilla;
    }
    var 
sizex_set false;
    var 
corner_set false;
    
jQuery.each(options.split(' '), function(idxoption) {
      
option option.toLowerCase();
      var 
parseInt(option);
      if (
&& option == 'px') {
        
s.sizey i;
        if (!
sizex_sets.sizex i;
        
sizex_set true;
      } else switch (
option) {
        case 
'no-native's.webkit s.mozilla false; break;
        case 
'webkit's.webkit true; break;
        case 
'no-webkit's.webkit false; break;
        case 
'mozilla's.mozilla true; break;
        case 
'no-mozilla's.mozilla false; break;
        case 
'anti-alias's.transparent false; break;
        case 
'transparent's.transparent true; break;
        case 
'top'corner_set s.tl s.tr true; break;
        case 
'right'corner_set s.tr s.br true; break;
        case 
'bottom'corner_set s.bl s.br true; break;
        case 
'left'corner_set s.tl s.bl true; break;
        case 
'top-left'corner_set s.tl true; break;
        case 
'top-right'corner_set s.tr true; break;
        case 
'bottom-left'corner_set s.bl true; break;
        case 
'bottom-right'corner_set s.br true; break;
      }
    });
    if (!
corner_set) {
      if (!
settings) {
        
s.tl s.tr s.bl s.br true;
      } else {
        
s.tl settings.tl;
        
s.tr settings.tr;
        
s.bl settings.bl;
        
s.br settings.br;
      }
    }
    return 
s;
  }
  
  function 
alphaBlend(abalpha) {
    var 
ca = Array(
      
parseInt('0x' a.substring(13)),
      
parseInt('0x' a.substring(35)),
      
parseInt('0x' a.substring(57))
    );
    var 
cb = Array(
      
parseInt('0x' b.substring(13)),
      
parseInt('0x' b.substring(35)),
      
parseInt('0x' b.substring(57))
    );
    
'0' Math.round(ca[0] + (cb[0] - ca[0])*alpha).toString(16);
    
'0' Math.round(ca[1] + (cb[1] - ca[1])*alpha).toString(16);
    
'0' Math.round(ca[2] + (cb[2] - ca[2])*alpha).toString(16);
    return 
'#'
      
r.substring(r.length 2)
      + 
g.substring(g.length 2)
      + 
b.substring(b.length 2);
  }

  function 
addCorners(esbgColorfgColortop) {
    if (
s.transparentaddTransparentCorners(esbgColortop);
    else 
addAntiAliasedCorners(esbgColorfgColortop);
  }
  
  function 
addAntiAliasedCorners(esbgColorfgColortop) {
    var 
ij;
    var 
document.createElement("div");
    
d.style.fontSize '1px';
    
d.style.backgroundColor bgColor;
    var 
lastarc 0;
    for (
1<= s.sizeyi++) {
      var 
coveragearc2arc3;
      
// Find intersection of arc with bottom of pixel row
      
arc Math.sqrt(1.0 Math.pow(1.0 s.sizey2)) * s.sizex;
      
// Calculate how many pixels are bg, fg and blended.
      
var n_bg s.sizex Math.ceil(arc);
      var 
n_fg Math.floor(lastarc);
      var 
n_aa s.sizex n_bg n_fg;
      
// Create pixel row wrapper
      
var document.createElement("div");
      var 
d;
      
x.style.margin "0px " n_bg "px";
      
x.style.height '1px';
      
x.style.overflow 'hidden';
      
// Create the pixel divs for a row (at least one)
      
for (1<= n_aaj++) {
        
// Calculate coverage per pixel (approximates arc within the pixel)
        
if (== 1) {
          if (
== n_aa) {
            
// Single pixel
            
coverage = ((arc lastarc) * .5) - n_fg;
          }
          else {
            
// First in a run
            
arc2 Math.sqrt(1.0 Math.pow(1.0 - (n_bg 1) / s.sizex2)) * s.sizey;
            
coverage = (arc2 - (s.sizey i)) * (arc n_fg n_aa 1) * .5;
          }
        }
        else if (
== n_aa) {
          
// Last in a run
          
arc2 Math.sqrt(1.0 Math.pow((s.sizex n_bg 1) / s.sizex2)) * s.sizey;
          
coverage 1.0 - (1.0 - (arc2 - (s.sizey i))) * (1.0 - (lastarc n_fg)) * .5;
        }
        else {
          
// Middle of a run
          
arc3 Math.sqrt(1.0 Math.pow((s.sizex n_bg j) / s.sizex2)) * s.sizey;
          
arc2 Math.sqrt(1.0 Math.pow((s.sizex n_bg 1) / s.sizex2)) * s.sizey;
          
coverage = ((arc2 arc3) * .5) - (s.sizey i);
        }
        
        
addCornerDiv(sxytopalphaBlend(bgColorfgColorcoverage));
        
x;
        var 
y.cloneNode(false);
        
x.style.margin "0px 1px";
      }
      
addCornerDiv(sxytopfgColor);
      
lastarc arc;
    }
    if (
top)
      
e.insertBefore(de.firstChild);
    else
      
e.appendChild(d);
  }
  
  function 
addCornerDiv(sxytopcolor) {
    if (
top && !s.tlx.style.marginLeft 0;
    if (
top && !s.trx.style.marginRight 0;
    if (!
top && !s.blx.style.marginLeft 0;
    if (!
top && !s.brx.style.marginRight 0;
    
x.style.backgroundColor color;
    if (
top)
      
y.appendChild(x);
    else
      
y.insertBefore(xy.firstChild);
  }

  function 
addTransparentCorners(esbgColortop) {
    var 
document.createElement("div");
    
d.style.fontSize '1px';
    var 
strip document.createElement('div');
    
strip.style.overflow 'hidden';
    
strip.style.height '1px';
    
strip.style.borderColor bgColor;
    
strip.style.borderStyle 'none solid';
    var 
sizex s.sizex-1;
    var 
sizey s.sizey-1;
    if (!
sizeysizey 1/* hint for 1x1 */
    
for (var i=0s.sizeyi++) {
      var 
sizex Math.floor(Math.sqrt(1.0 Math.pow(1.0 sizey2)) * sizex);
      if (
i==&& s.sizex==&& s.sizey==62/* hint for 6x6 */
      
var strip.cloneNode(false);
      
x.style.borderWidth '0 '+'px';
      if (
topx.style.borderWidth '0 '+(s.tr?w:0)+'px 0 '+(s.tl?w:0)+'px';
      else 
x.style.borderWidth '0 '+(s.br?w:0)+'px 0 '+(s.bl?w:0)+'px';
      
top d.appendChild(x) : d.insertBefore(xd.firstChild);
    } 
    if (
top)
      
e.insertBefore(de.firstChild);
    else
      
e.appendChild(d);
  }


}
?>
Онлайн: 0
Реклама