1(function ($) { 2 /*jslint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false */ 3 /*global jQuery,setTimeout,WebKitCSSMatrix */ 4 5 var origin = "0px 0px"; 6 // nearest 7 var scalingMode = "bilinear"; 8 9 /* 10 very stripped down version of 11 https://github.com/heygrady/transform/blob/master/README.md 12 */ 13 14 var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/; 15 16 // Steal some code from Modernizr 17 var m = document.createElement( 'modernizr' ), 18 m_style = m.style; 19 20 /** 21 * Find the prefix that this browser uses 22 */ 23 function getVendorPrefix() { 24 var property = { 25 transformProperty : '', 26 MozTransform : '-moz-', 27 WebkitTransform : '-webkit-', 28 OTransform : '-o-', 29 msTransform : '-ms-' 30 }; 31 for (var p in property) { 32 if (typeof m_style[p] != 'undefined') { 33 return property[p]; 34 } 35 } 36 return null; 37 } 38 39 function supportCssTransforms() { 40 var props = [ 'transformProperty', 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform' ]; 41 for ( var i in props ) { 42 if ( m_style[ props[i] ] !== undefined ) { 43 return true; 44 } 45 } 46 return false; 47 } 48 49 // Capture some basic properties 50 var vendorPrefix = getVendorPrefix(), 51 transformProperty = vendorPrefix !== null ? vendorPrefix + 'transform' : false, 52 transformOriginProperty = vendorPrefix !== null ? vendorPrefix + 'transform-origin' : false; 53 54 // store support in the jQuery Support object 55 $.support.csstransforms = supportCssTransforms(); 56 57 $.support.hw3dTransform = ('WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix()); 58 59 // IE9 public preview 6 requires the DOM names 60 if (vendorPrefix == '-ms-') { 61 transformProperty = 'msTransform'; 62 transformOriginProperty = 'msTransformOrigin'; 63 } 64 65 function transform(el,ratio,dx,dy,w,h,noFilter,forceCompat) { 66 if ($.support.csstransforms && !forceCompat) { 67 var offs; 68 var unit="px"; 69 70 if (typeof dx === "string" && dx.indexOf("%") > 0) { 71 unit = "%"; 72 } else if (w && h && (parseInt(dx,10) != dx || parseInt(dy,10) != dy)) { 73 dx=100*dx/w; 74 dy=100*dy/h; 75 76 dx=parseInt(dx*1000,10)/1000; 77 dy=parseInt(dy*1000,10)/1000; 78 79 unit="%"; 80 } else { 81 dx = parseInt(dx,10); 82 dy = parseInt(dy,10); 83 } 84 85 if ($.support.hw3dTransform) { 86 offs = (dx !== undefined ) ? "translate3d("+dx+unit+","+dy+unit+",0) " : "translateZ(0) "; 87 } else { 88 offs = (dx !== undefined ) ? "translate("+dx+unit+","+dy+unit+") " : ""; 89 } 90 91 $(el).css(transformOriginProperty,origin).css(transformProperty,offs+"scale("+ratio+")"); 92 93 } else if (!noFilter && !forceCompat && $.browser.msie) { 94 var style = el.style; 95 var matrixFilter = 'progid:DXImageTransform.Microsoft.Matrix(FilterType="'+scalingMode+'",M11='+ratio+',M12=0,M21=0,M22='+ratio+',Dx='+dx+',Dy='+dy+')'; 96 var filter = style.filter || $.curCSS( el, "filter" ) || ""; 97 style.filter = rmatrix.test(filter) ? filter.replace(rmatrix, matrixFilter) : filter ? filter + ' ' + matrixFilter : matrixFilter; 98 } else { 99 $(el) 100 .width(w*ratio) 101 .height(h*ratio) 102 .css({ 103 "margin-left": dx+"px", 104 "margin-top": dy+"px" 105 }); 106 } 107 } 108 109 $.fn.transform = function(ratio,dx,dy,w,h,noFilter,forceCompat) { 110 111 this.each(function() { 112 transform(this,ratio,dx,dy,w,h,noFilter,forceCompat); 113 }); 114 115 return this; 116 }; 117 118}(jQuery)); 119 120 121
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.