1/* 2 * rotate: A jQuery cssHooks adding a cross browser 'rotate' property to $.fn.css() and $.fn.animate() 3 * 4 * Copyright (c) 2010 Louis-Rémi Babé 5 * Licensed under the MIT license. 6 * 7 * This saved you an hour of work? 8 * Send me music http://www.amazon.fr/wishlist/HNTU0468LQON 9 * 10 */ 11(function($) { 12 13var div = document.createElement('div'), 14 divStyle = div.style, 15 support = $.support; 16 17support.transform = 18 divStyle.MozTransform === ''? 'MozTransform' : 19 (divStyle.MsTransform === ''? 'MsTransform' : 20 (divStyle.WebkitTransform === ''? 'WebkitTransform' : 21 (divStyle.OTransform === ''? 'OTransform' : 22 false))); 23support.matrixFilter = !support.transform && divStyle.filter === ''; 24div = null; 25 26$.cssNumber.rotate = true; 27$.cssHooks.rotate = { 28 set: function( elem, value ) { 29 var _support = support, 30 supportTransform = _support.transform, 31 cos, sin, 32 centerOrigin; 33 34 if (typeof value === 'string') { 35 value = toRadian(value); 36 } 37 38 $.data( elem, 'transform', { 39 rotate: value 40 }); 41 42 if (supportTransform) { 43 elem.style[supportTransform] = 'rotate('+ value +'rad)'; 44 45 } else if (_support.matrixFilter) { 46 cos = Math.cos(value); 47 sin = Math.sin(value); 48 elem.style.filter = [ 49 "progid:DXImageTransform.Microsoft.Matrix(", 50 "M11="+cos+",", 51 "M12="+(-sin)+",", 52 "M21="+sin+",", 53 "M22="+cos+",", 54 "SizingMethod='auto expand'", 55 ")" 56 ].join(''); 57 58 // From pbakaus's Transformie http://github.com/pbakaus/transformie 59 if(centerOrigin = $.rotate.centerOrigin) { 60 elem.style[centerOrigin == 'margin' ? 'marginLeft' : 'left'] = -(elem.offsetWidth/2) + (elem.clientWidth/2) + "px"; 61 elem.style[centerOrigin == 'margin' ? 'marginTop' : 'top'] = -(elem.offsetHeight/2) + (elem.clientHeight/2) + "px"; 62 } 63 } 64 }, 65 get: function( elem, computed ) { 66 var transform = $.data( elem, 'transform' ); 67 return transform && transform.rotate? transform.rotate : 0; 68 } 69}; 70$.fx.step.rotate = function( fx ) { 71 $.cssHooks.rotate.set( fx.elem, fx.now+fx.unit ); 72}; 73 74function radToDeg( rad ) { 75 return rad * 180 / Math.PI; 76} 77function toRadian(value) { 78 if(value.indexOf("deg") != -1) { 79 return parseInt(value,10) * (Math.PI * 2 / 360); 80 } else if (value.indexOf("grad") != -1) { 81 return parseInt(value,10) * (Math.PI/200); 82 } 83 return parseFloat(value); 84} 85 86$.rotate = { 87 centerOrigin: 'margin', 88 radToDeg: radToDeg 89}; 90 91})(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.