function jQuery jQuery fx step clip function fx if fx state if typeof

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
(function(jQuery){
jQuery.fx.step.clip = function(fx){
if( fx.state == 0)
{
if(typeof(jQuery(fx.elem).css("clip")) == 'undefined')
{
var start = "rect(" + jQuery(fx.elem).css("clipTop") + " " + jQuery(fx.elem).css("clipRight") + " " + jQuery(fx.elem).css("clipBottom") + " " + jQuery(fx.elem).css("clipLeft") +")";
var cRE = /rect\(([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em)\)/;
fx.start = cRE.exec(start.replace(/,/g, ''));
fx.end = cRE.exec(fx.end.replace(/,/g, '') );
}
else if(jQuery.trim(jQuery(fx.elem).css("clip")) == '')
{
var stylesNum = jQuery("link[@rel*=style]").length;
var _timer = setInterval (
function()
{
if(document.styleSheets.length >= stylesNum)
{
clearInterval(_timer);
delete _timer;
for(i in document.styleSheets)
{
if(document.styleSheets[i].href != null)
{
d = document.styleSheets[i];
}
else
{
d = document.styleSheets[i].cssRules[0].styleSheet;
}
if (d.rules)
{
for (var i = 0, n = d.rules.length; i < n; i++)
{
if (jQuery.trim(d.rules[i] && d.rules[i].style.clip) != '')
{
if(jQuery(d.rules[i].selectorText)[0] == jQuery(fx.elem)[0])
{
var start = d.rules[i].style.clip;
var cRE = /rect\(([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em)\)/;
fx.start = cRE.exec(start.replace(/,/g, ''));
fx.end = cRE.exec(fx.end.replace(/,/g, '') );
}
}
}
}
else if (d.cssRules)
{
for (var i = 0, n = d.cssRules.length; i < n; i++)
{
if (jQuery.trim(d.cssRules[i] && d.cssRules[i].style.clip) != '')
{
//alert("document.styleSheets[0].cssRules[" + i + "].style.clip = " + d.cssRules[i].style.clip);
if(jQuery(d.cssRules[i].selectorText)[0] == jQuery(fx.elem)[0])
{
var start = d.cssRules[i].style.clip;
var cRE = /rect\(([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em)\)/;
fx.start = cRE.exec(start.replace(/,/g, ''));
fx.end = cRE.exec(fx.end.replace(/,/g, '') );
}
}
}
}
}
}
}, 1);
}
else
{
var start = jQuery(fx.elem).css("clip");
var cRE = /rect\(([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em) ([0-9]{1,3})(px|em)\)/;
fx.start = cRE.exec(start.replace(/,/g, ''));
fx.end = cRE.exec(fx.end.replace(/,/g, '') );
}
}
var timer_ = setInterval (
function()
{
if(fx.start != null)
{
clearInterval(timer_);
delete timer_;
var sarr = new Array(), earr = new Array(), spos = fx.start.length, epos = fx.end.length,
emOffset = fx.start[ss+1] == 'em' ? ( parseInt($(fx.elem).css('fontSize')) * 1.333 * parseInt(fx.start[ss]) ) : 1;
for ( var ss = 1; ss < spos; ss+=2 ) { sarr.push( parseInt( emOffset * fx.start[ss] ) ); }
for ( var es = 1; es < epos; es+=2 ) { earr.push( parseInt( emOffset * fx.end[es] ) ); }
fx.elem.style.clip = 'rect(' +
parseInt( ( fx.pos * ( earr[0] - sarr[0] ) ) + sarr[0] ) + 'px ' +
parseInt( ( fx.pos * ( earr[1] - sarr[1] ) ) + sarr[1] ) + 'px ' +
parseInt( ( fx.pos * ( earr[2] - sarr[2] ) ) + sarr[2] ) + 'px ' +
parseInt( ( fx.pos * ( earr[3] - sarr[3] ) ) + sarr[3] ) + 'px)';
}
},1);
}
})(jQuery);