1(function($) { 2var supportedCSS,styles=document.getElementsByTagName("head")[0].style,toCheck="transformProperty WebkitTransform OTransform msTransform MozTransform".split(" "); 3for (var a=0;a<toCheck.length;a++) if (styles[toCheck[a]] !== undefined) supportedCSS = toCheck[a]; 4// Bad eval to preven google closure to remove it from code o_O 5// After compresion replace it back to var IE = 'v' == '\v' 6var IE = eval('"v"=="\v"'); 7 8$.fn.extend({ 9ImageRotate:function(parameters) 10{ 11 // If this element is already a Wilq32.PhotoEffect object, skip creation 12 if (this.Wilq32&&this.Wilq32.PhotoEffect) return; 13 // parameters might be applied to many objects - so because we use them later - a fresh instance is needed 14 var paramClone = $.extend(true, {}, parameters); 15 return (new Wilq32.PhotoEffect(this.get(0),paramClone))._rootObj; 16}, 17rotate:function(parameters) 18{ 19 if (this.length===0||typeof parameters=="undefined") return; 20 if (typeof parameters=="number") parameters={angle:parameters}; 21 var returned=[]; 22 for (var i=0,i0=this.length;i<i0;i++) 23 { 24 var element=this.get(i); 25 if (typeof element.Wilq32 == "undefined") 26 returned.push($($(element).ImageRotate(parameters))); 27 else 28 element.Wilq32.PhotoEffect._handleRotation(parameters); 29 } 30 return returned; 31} 32}); 33 34// Library agnostic interface 35 36Wilq32=window.Wilq32||{}; 37Wilq32.PhotoEffect=(function(){ 38 39 if (supportedCSS) { 40 return function(img,parameters){ 41 img.Wilq32 = { 42 PhotoEffect: this 43 }; 44 45 this._img = this._rootObj = this._eventObj = img; 46 this._handleRotation(parameters); 47 } 48 } else { 49 return function(img,parameters) { 50 // Make sure that class and id are also copied - just in case you would like to refeer to an newly created object 51 this._img = img; 52 53 this._rootObj=document.createElement('span'); 54 this._rootObj.style.display="inline-block"; 55 this._rootObj.Wilq32 = 56 { 57 PhotoEffect: this 58 }; 59 img.parentNode.insertBefore(this._rootObj,img); 60 61 if (img.complete) { 62 this._Loader(parameters); 63 } else { 64 var self=this; 65 // TODO: Remove $ dependency 66 $(this._img).bind("load", function() 67 { 68 self._Loader(parameters); 69 }); 70 } 71 } 72 } 73})(); 74 75Wilq32.PhotoEffect.prototype={ 76 _setupParameters : function (parameters){ 77 this._parameters = this._parameters || {}; 78 if (typeof this._angle !== "number") this._angle = 0 ; 79 if (typeof parameters.angle==="number") this._angle = parameters.angle; 80 this._parameters.animateTo = (typeof parameters.animateTo==="number") ? (parameters.animateTo) : (this._angle); 81 82 this._parameters.easing = parameters.easing || this._parameters.easing || function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; } 83 this._parameters.duration = parameters.duration || this._parameters.duration || 1000; 84 this._parameters.callback = parameters.callback || this._parameters.callback || function(){}; 85 if (parameters.bind && parameters.bind != this._parameters.bind) this._BindEvents(parameters.bind); 86 }, 87 _handleRotation : function(parameters){ 88 this._setupParameters(parameters); 89 if (this._angle==this._parameters.animateTo) { 90 this._rotate(this._angle); 91 } 92 else { 93 this._animateStart(); 94 } 95 }, 96 97 _BindEvents:function(events){ 98 if (events && this._eventObj) 99 { 100 // Unbinding previous Events 101 if (this._parameters.bind){ 102 var oldEvents = this._parameters.bind; 103 for (var a in oldEvents) if (oldEvents.hasOwnProperty(a)) 104 // TODO: Remove $ dependency 105 $(this._eventObj).unbind(a,oldEvents[a]); 106 } 107 108 this._parameters.bind = events; 109 for (var a in events) if (events.hasOwnProperty(a)) 110 // TODO: Remove $ dependency 111 $(this._eventObj).bind(a,events[a]); 112 } 113 }, 114 115 _Loader:(function() 116 { 117 if (IE) 118 return function(parameters) 119 { 120 var width=this._img.width; 121 var height=this._img.height; 122 this._img.parentNode.removeChild(this._img); 123 124 this._vimage = this.createVMLNode('image'); 125 this._vimage.src=this._img.src; 126 this._vimage.style.height=height+"px"; 127 this._vimage.style.width=width+"px"; 128 this._vimage.style.position="absolute"; // FIXES IE PROBLEM - its only rendered if its on absolute position! 129 this._vimage.style.top = "0px";
130 this._vimage.style.left = "0px"; 131 132 /* Group minifying a small 1px precision problem when rotating object */ 133 this._container = this.createVMLNode('group'); 134 this._container.style.width=width; 135 this._container.style.height=height; 136 this._container.style.position="absolute"; 137 this._container.setAttribute('coordsize',width-1+','+(height-1)); // This -1, -1 trying to fix ugly problem with small displacement on IE 138 this._container.appendChild(this._vimage); 139 140 this._rootObj.appendChild(this._container); 141 this._rootObj.style.position="relative"; // FIXES IE PROBLEM 142 this._rootObj.style.width=width+"px"; 143 this._rootObj.style.height=height+"px"; 144 this._rootObj.setAttribute('id',this._img.getAttribute('id')); 145 this._rootObj.className=this._img.className; 146 this._eventObj = this._rootObj; 147 this._handleRotation(parameters); 148 } 149 else 150 return function (parameters) 151 { 152 this._rootObj.setAttribute('id',this._img.getAttribute('id')); 153 this._rootObj.className=this._img.className; 154 155 this._width=this._img.width; 156 this._height=this._img.height; 157 this._widthHalf=this._width/2; // used for optimisation 158 this._heightHalf=this._height/2;// used for optimisation 159 160 var _widthMax=Math.sqrt((this._height)*(this._height) + (this._width) * (this._width)); 161 162 this._widthAdd = _widthMax - this._width; 163 this._heightAdd = _widthMax - this._height; // widthMax because maxWidth=maxHeight 164 this._widthAddHalf=this._widthAdd/2; // used for optimisation 165 this._heightAddHalf=this._heightAdd/2;// used for optimisation 166 167 this._img.parentNode.removeChild(this._img); 168 169 this._aspectW = ((parseInt(this._img.style.width,10)) || this._width)/this._img.width; 170 this._aspectH = ((parseInt(this._img.style.height,10)) || this._height)/this._img.height; 171 172 this._canvas=document.createElement('canvas'); 173 this._canvas.setAttribute('width',this._width); 174 this._canvas.style.position="relative"; 175 this._canvas.style.left = -this._widthAddHalf + "px"; 176 this._canvas.style.top = -this._heightAddHalf + "px"; 177 this._canvas.Wilq32 = this._rootObj.Wilq32; 178 179 this._rootObj.appendChild(this._canvas); 180 this._rootObj.style.width=this._width+"px"; 181 this._rootObj.style.height=this._height+"px"; 182 this._eventObj = this._canvas; 183 184 this._cnv=this._canvas.getContext('2d'); 185 this._handleRotation(parameters); 186 } 187 })(), 188 189 _animateStart:function() 190 { 191 if (this._timer) { 192 clearTimeout(this._timer); 193 } 194 this._animateStartTime = +new Date; 195 this._animateStartAngle = this._angle; 196 this._animate(); 197 }, 198_animate:function() 199 { 200 var actualTime = +new Date; 201 var checkEnd = actualTime - this._animateStartTime > this._parameters.duration; 202 203 // TODO: Bug for animatedGif for static rotation ? (to test) 204 if (checkEnd && !this._parameters.animatedGif) 205 { 206 clearTimeout(this._timer); 207 } 208 else 209 { 210 if (this._canvas||this._vimage||this._img) { 211 var angle = this._parameters.easing(0, actualTime - this._animateStartTime, this._animateStartAngle, this._parameters.animateTo - this._animateStartAngle, this._parameters.duration); 212 this._rotate((~~(angle*10))/10); 213 } 214 var self = this; 215 this._timer = setTimeout(function() 216 { 217 self._animate.call(self); 218 }, 10); 219 } 220 221 // To fix Bug that prevents using recursive function in callback I moved this function to back 222 if (this._parameters.callback && checkEnd){ 223 this._angle = this._parameters.animateTo; 224 this._rotate(this._angle); 225 this._parameters.callback.call(this._rootObj); 226 } 227 }, 228 229 _rotate : (function() 230 { 231 var rad = Math.PI/180; 232 if (IE) 233 return function(angle) 234 { 235 this._angle = angle; 236 this._container.style.rotation=(angle%360)+"deg"; 237 } 238 else if (supportedCSS) 239 return function(angle){ 240 this._angle = angle; 241 this._img.style[supportedCSS]="rotate("+(angle%360)+"deg)"; 242 } 243 else 244 return function(angle) 245 { 246 this._angle = angle; 247 angle=(angle%360)* rad; 248 // clear canvas 249 this._canvas.width = this._width+this._widthAdd; 250 this._canvas.height = this._height+this._heightAdd; 251 252 // REMEMBER: all drawings are read from backwards.. so first function is translate, then rotate, then translate, translate.. 253 this._cnv.translate(this._widthAddHalf,this._heightAddHalf); // at least center image on screen 254 this._cnv.translate(this._widthHalf,this._heightHalf); // we move image back to its orginal 255 this._cnv.rotate(angle); // rotate image 256 this._cnv.translate(-this._widthHalf,-this._heightHalf); // move image to its center, so we can rotate around its center 257 this._cnv.scale(this._aspectW,this._aspectH); // SCALE - if needed ;) 258 this._cnv.drawImage(this._img, 0, 0); // First - we draw image 259 } 260 261 })() 262} 263 264if (IE) 265{ 266Wilq32.PhotoEffect.prototype.createVMLNode=(function(){ 267document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); 268 try { 269 !document.namespaces.rvml && document.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"); 270 return function (tagName) { 271 return document.createElement('<rvml:' + tagName + ' class="rvml">'); 272 }; 273 } catch (e) { 274 return function (tagName) { 275 return document.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">'); 276 }; 277 } 278})(); 279} 280 281})(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.