Completed
Push — master ( bca88f...074f85 )
by Thomas
12:45 queued 10s
created

Wilq32.PhotoEffect.constructor   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 34
rs 8.8571
cc 2
nc 2
nop 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A rotate.js ➔ ... ➔ $(this._img).bind(ꞌloadꞌ) 0 1 1
A rotate.js ➔ 0 8 1
1
// VERSION: 2.3 LAST UPDATE: 11.07.2013
2
/*
3
 * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
4
 *
5
 * Made by Wilq32, [email protected], Wroclaw, Poland, 01.2009
6
 * Website: http://jqueryrotate.com
7
 */
8
9
(function($) {
10
    var supportedCSS,supportedCSSOrigin, styles=document.getElementsByTagName("head")[0].style,toCheck="transformProperty WebkitTransform OTransform msTransform MozTransform".split(" ");
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
11
    for (var a = 0; a < toCheck.length; a++) if (styles[toCheck[a]] !== undefined) { supportedCSS = toCheck[a]; }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
{ was expected, but instead if was given.
Loading history...
12
    if (supportedCSS) {
13
      supportedCSSOrigin = supportedCSS.replace(/[tT]ransform/,"TransformOrigin");
14
      if (supportedCSSOrigin[0] == "T") supportedCSSOrigin[0] = "t";
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
=== was expected, but instead == was given.
Loading history...
Bug introduced by
{ was expected, but instead supportedCSSOrigin was given.
Loading history...
15
    }
16
17
    // Bad eval to preven google closure to remove it from code o_O
18
    eval('IE = "v"=="\v"');
0 ignored issues
show
Security Performance introduced by
Calls to eval are slow and potentially dangerous, especially on untrusted code. Please consider whether there is another way to achieve your goal.
Loading history...
Coding Style Security introduced by
The use of eval is generally not recommended.

The use of eval is discouraged because it can potentially make your code vulnerable to various injection attacks.

Besides it will also prevent certain optimizations that runtimes otherwise could make.

Loading history...
19
20
    jQuery.fn.extend({
21
        rotate:function(parameters)
22
        {
23
          if (this.length===0||typeof parameters=="undefined") return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
=== was expected, but instead == was given.
Loading history...
Bug introduced by
{ was expected, but instead return was given.
Loading history...
24
          if (typeof parameters=="number") parameters={angle:parameters};
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
=== was expected, but instead == was given.
Loading history...
Bug introduced by
{ was expected, but instead parameters was given.
Loading history...
25
          var returned=[];
26
          for (var i=0,i0=this.length;i<i0;i++)
27
          {
28
            var element=this.get(i);
29
            if (!element.Wilq32 || !element.Wilq32.PhotoEffect) {
30
31
              var paramClone = $.extend(true, {}, parameters);
32
              var newRotObject = new Wilq32.PhotoEffect(element,paramClone)._rootObj;
0 ignored issues
show
Bug introduced by
The variable Wilq32 seems to be never declared. If this is a global, consider adding a /** global: Wilq32 */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
Wilq32 does not seem to be defined.
Loading history...
33
34
              returned.push($(newRotObject));
35
            }
36
            else {
37
              element.Wilq32.PhotoEffect._handleRotation(parameters);
38
            }
39
          }
40
          return returned;
41
        },
42
        getRotateAngle: function(){
43
          var ret = [0];
44
          for (var i=0,i0=this.length;i<i0;i++)
45
          {
46
            var element=this.get(i);
47
            if (element.Wilq32 && element.Wilq32.PhotoEffect) {
48
              ret[i] = element.Wilq32.PhotoEffect._angle;
49
            }
50
          }
51
          return ret;
52
        },
53
        stopRotate: function(){
54
          for (var i=0,i0=this.length;i<i0;i++)
55
          {
56
            var element=this.get(i);
57
            if (element.Wilq32 && element.Wilq32.PhotoEffect) {
58
              clearTimeout(element.Wilq32.PhotoEffect._timer);
59
            }
60
          }
61
        }
62
    });
63
64
    // Library agnostic interface
65
66
    Wilq32=window.Wilq32||{};
0 ignored issues
show
Bug introduced by
The variable Wilq32 seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.Wilq32.
Loading history...
Bug introduced by
Wilq32 does not seem to be defined.
Loading history...
67
    Wilq32.PhotoEffect=(function(){
0 ignored issues
show
Bug introduced by
Wilq32 does not seem to be defined.
Loading history...
68
69
      if (supportedCSS) {
70
        return function(img,parameters){
71
          img.Wilq32 = {
72
            PhotoEffect: this
73
          };
74
75
          this._img = this._rootObj = this._eventObj = img;
76
          this._handleRotation(parameters);
77
        }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
78
      } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
79
        return function(img,parameters) {
80
          this._img = img;
81
          this._onLoadDelegate = [parameters];
82
83
          this._rootObj=document.createElement('span');
84
          this._rootObj.style.display="inline-block";
85
          this._rootObj.Wilq32 =
86
            {
87
              PhotoEffect: this
88
            };
89
          img.parentNode.insertBefore(this._rootObj,img);
90
91
          if (img.complete) {
92
            this._Loader();
93
          } else {
94
            var self=this;
95
            // TODO: Remove jQuery dependency
96
            jQuery(this._img).bind("load", function(){ self._Loader(); });
97
          }
98
        }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
99
      }
100
    })();
101
102
    Wilq32.PhotoEffect.prototype = {
0 ignored issues
show
Bug introduced by
Wilq32 does not seem to be defined.
Loading history...
103
      _setupParameters : function (parameters){
104
        this._parameters = this._parameters || {};
105
        if (typeof this._angle !== "number") { this._angle = 0 ; }
106
        if (typeof parameters.angle==="number") { this._angle = parameters.angle; }
107
        this._parameters.animateTo = (typeof parameters.animateTo === "number") ? (parameters.animateTo) : (this._angle);
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
108
109
        this._parameters.step = parameters.step || this._parameters.step || null;
110
        this._parameters.easing = parameters.easing || this._parameters.easing || this._defaultEasing;
111
        this._parameters.duration = 'duration' in parameters ? parameters.duration : parameters.duration || this._parameters.duration || 1000;
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
112
        this._parameters.callback = parameters.callback || this._parameters.callback || this._emptyFunction;
113
        this._parameters.center = parameters.center || this._parameters.center || ["50%","50%"];
114
        if (typeof this._parameters.center[0] == "string") {
0 ignored issues
show
Bug introduced by
=== was expected, but instead == was given.
Loading history...
115
          this._rotationCenterX = (parseInt(this._parameters.center[0],10) / 100) * this._imgWidth * this._aspectW;
116
        } else {
117
          this._rotationCenterX = this._parameters.center[0];
118
        }
119
        if (typeof this._parameters.center[1] == "string") {
0 ignored issues
show
Bug introduced by
=== was expected, but instead == was given.
Loading history...
120
          this._rotationCenterY = (parseInt(this._parameters.center[1],10) / 100) * this._imgHeight * this._aspectH;
121
        } else {
122
          this._rotationCenterY = this._parameters.center[1];
123
        }
124
125
        if (parameters.bind && parameters.bind != this._parameters.bind) { this._BindEvents(parameters.bind); }
0 ignored issues
show
Bug introduced by
!== was expected, but instead != was given.
Loading history...
126
      },
127
      _emptyFunction: function(){},
128
      _defaultEasing: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b },
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
129
      _handleRotation : function(parameters, dontcheck){
130
        if (!supportedCSS && !this._img.complete && !dontcheck) {
131
          this._onLoadDelegate.push(parameters);
132
          return;
133
        }
134
        this._setupParameters(parameters);
135
        if (this._angle==this._parameters.animateTo) {
0 ignored issues
show
Bug introduced by
=== was expected, but instead == was given.
Loading history...
136
          this._rotate(this._angle);
137
        }
138
        else {
139
          this._animateStart();
140
        }
141
      },
142
143
      _BindEvents:function(events){
144
        if (events && this._eventObj)
145
        {
146
          // Unbinding previous Events
147
          if (this._parameters.bind){
148
            var oldEvents = this._parameters.bind;
149
            for (var a in oldEvents) if (oldEvents.hasOwnProperty(a))
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
{ was expected, but instead if was given.
Loading history...
150
              // TODO: Remove jQuery dependency
151
              jQuery(this._eventObj).unbind(a,oldEvents[a]);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
{ was expected, but instead jQuery was given.
Loading history...
152
          }
153
154
        this._parameters.bind = events;
155
        for (var a in events) if (events.hasOwnProperty(a))
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable a already seems to be declared on line 149. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
It seems like a was already defined.
Loading history...
Bug introduced by
{ was expected, but instead if was given.
Loading history...
156
          // TODO: Remove jQuery dependency
157
          jQuery(this._eventObj).bind(a,events[a]);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
{ was expected, but instead jQuery was given.
Loading history...
158
        }
159
      },
160
161
      _Loader:(function()
162
      {
163
        if (IE)
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable IE is declared in the current environment, consider using typeof IE === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
164
          return function() {
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
{ was expected, but instead return was given.
Loading history...
165
            var width=this._img.width;
166
            var height=this._img.height;
167
            this._imgWidth = width;
168
            this._imgHeight = height;
169
            this._img.parentNode.removeChild(this._img);
170
171
            this._vimage = this.createVMLNode('image');
172
            this._vimage.src=this._img.src;
173
            this._vimage.style.height=height+"px";
174
            this._vimage.style.width=width+"px";
175
            this._vimage.style.position="absolute"; // FIXES IE PROBLEM - its only rendered if its on absolute position!
176
            this._vimage.style.top = "0px";
177
            this._vimage.style.left = "0px";
178
            this._aspectW = this._aspectH = 1;
179
180
            /* Group minifying a small 1px precision problem when rotating object */
181
            this._container = this.createVMLNode('group');
182
            this._container.style.width=width;
183
            this._container.style.height=height;
184
            this._container.style.position="absolute";
185
            this._container.style.top="0px";
186
            this._container.style.left="0px";
187
            this._container.setAttribute('coordsize',width-1+','+(height-1)); // This -1, -1 trying to fix ugly problem with small displacement on IE
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
188
            this._container.appendChild(this._vimage);
189
190
            this._rootObj.appendChild(this._container);
191
            this._rootObj.style.position="relative"; // FIXES IE PROBLEM
192
            this._rootObj.style.width=width+"px";
193
            this._rootObj.style.height=height+"px";
194
            this._rootObj.setAttribute('id',this._img.getAttribute('id'));
195
            this._rootObj.className=this._img.className;
196
            this._eventObj = this._rootObj;
197
            var parameters;
198
            while (parameters = this._onLoadDelegate.shift()) {
0 ignored issues
show
Bug introduced by
Are you sure that this assignment is correct, and you did not intend to make a comparison?

Even if this assignment is intended here, we recommend to make this explicit in order to make your code more readable and your intention clear:

1. Assignment in

var x;
if (x = 0) { // Very likely a bug.
    var b = 1;
}

// Instead

var x;
if (x === 0) {
    var b = 1;
}

2. Assignment in

functon setHeight(node, height) {
    do {
        node.height = height;
    } while (node = node.parentNode);
}

// Instead you could use

function setHeight(node, height) {
    do {
        node.height = height;
    } while ((node = node.parentNode) !== null);
}

3. Uninitialized loop variable

var i = 0, sum;
for (i < 10; i += 1) {
    sum += i;
}

// Instead

var i = 0, sum;
for (i = 0; i < 10; i += 1) {
    sum += i;
}
Loading history...
199
              this._handleRotation(parameters, true);
200
            }
201
          }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
202
          else return function () {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
Bug introduced by
{ was expected, but instead return was given.
Loading history...
203
            this._rootObj.setAttribute('id',this._img.getAttribute('id'));
204
            this._rootObj.className=this._img.className;
205
206
            this._imgWidth=this._img.naturalWidth;
207
            this._imgHeight=this._img.naturalHeight;
208
            var _widthMax=Math.sqrt((this._imgHeight)*(this._imgHeight) + (this._imgWidth) * (this._imgWidth));
209
            this._width = _widthMax * 3;
210
            this._height = _widthMax * 3;
211
212
            this._aspectW = this._img.offsetWidth/this._img.naturalWidth;
213
            this._aspectH = this._img.offsetHeight/this._img.naturalHeight;
214
215
            this._img.parentNode.removeChild(this._img);
216
217
218
            this._canvas=document.createElement('canvas');
219
            this._canvas.setAttribute('width',this._width);
220
            this._canvas.style.position="relative";
221
            this._canvas.style.left = -this._img.height * this._aspectW + "px";
222
            this._canvas.style.top = -this._img.width * this._aspectH + "px";
223
            this._canvas.Wilq32 = this._rootObj.Wilq32;
224
225
            this._rootObj.appendChild(this._canvas);
226
            this._rootObj.style.width=this._img.width*this._aspectW+"px";
227
            this._rootObj.style.height=this._img.height*this._aspectH+"px";
228
            this._eventObj = this._canvas;
229
230
            this._cnv=this._canvas.getContext('2d');
231
            var parameters;
232
            while (parameters = this._onLoadDelegate.shift()) {
0 ignored issues
show
Bug introduced by
Are you sure that this assignment is correct, and you did not intend to make a comparison?

Even if this assignment is intended here, we recommend to make this explicit in order to make your code more readable and your intention clear:

1. Assignment in

var x;
if (x = 0) { // Very likely a bug.
    var b = 1;
}

// Instead

var x;
if (x === 0) {
    var b = 1;
}

2. Assignment in

functon setHeight(node, height) {
    do {
        node.height = height;
    } while (node = node.parentNode);
}

// Instead you could use

function setHeight(node, height) {
    do {
        node.height = height;
    } while ((node = node.parentNode) !== null);
}

3. Uninitialized loop variable

var i = 0, sum;
for (i < 10; i += 1) {
    sum += i;
}

// Instead

var i = 0, sum;
for (i = 0; i < 10; i += 1) {
    sum += i;
}
Loading history...
233
              this._handleRotation(parameters, true);
234
            }
235
          }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
236
      })(),
237
238
      _animateStart:function()
239
      {
240
        if (this._timer) {
241
          clearTimeout(this._timer);
242
        }
243
        this._animateStartTime = +new Date;
0 ignored issues
show
Coding Style introduced by
The constructor invocation misses ().

This requirement purely is a coding style requirement and is not required to run on JavaScript engines:

new Date; // Bad
new Date(); // Good
Loading history...
244
        this._animateStartAngle = this._angle;
245
        this._animate();
246
      },
247
      _animate:function()
248
      {
249
        var actualTime = +new Date;
0 ignored issues
show
Coding Style introduced by
The constructor invocation misses ().

This requirement purely is a coding style requirement and is not required to run on JavaScript engines:

new Date; // Bad
new Date(); // Good
Loading history...
250
        var checkEnd = actualTime - this._animateStartTime > this._parameters.duration;
251
252
        // TODO: Bug for animatedGif for static rotation ? (to test)
253
        if (checkEnd && !this._parameters.animatedGif)
254
        {
255
          clearTimeout(this._timer);
256
        }
257
        else
258
        {
259
          if (this._canvas||this._vimage||this._img) {
260
            var angle = this._parameters.easing(0, actualTime - this._animateStartTime, this._animateStartAngle, this._parameters.animateTo - this._animateStartAngle, this._parameters.duration);
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
261
            this._rotate((~~(angle*10))/10);
262
          }
263
          if (this._parameters.step) {
264
            this._parameters.step(this._angle);
265
          }
266
          var self = this;
267
          this._timer = setTimeout(function()
268
          {
269
            self._animate.call(self);
270
          }, 10);
271
        }
272
273
      // To fix Bug that prevents using recursive function in callback I moved this function to back
274
      if (this._parameters.callback && checkEnd){
275
        this._angle = this._parameters.animateTo;
276
        this._rotate(this._angle);
277
        this._parameters.callback.call(this._rootObj);
278
      }
279
      },
280
281
      _rotate : (function()
282
      {
283
        var rad = Math.PI/180;
284
        if (IE)
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable IE is declared in the current environment, consider using typeof IE === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
285
          return function(angle)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
{ was expected, but instead return was given.
Loading history...
286
        {
287
          this._angle = angle;
288
          this._container.style.rotation=(angle%360)+"deg";
289
          this._vimage.style.top = -(this._rotationCenterY - this._imgHeight/2) + "px";
290
          this._vimage.style.left = -(this._rotationCenterX - this._imgWidth/2) + "px";
291
          this._container.style.top = this._rotationCenterY - this._imgHeight/2 + "px";
292
          this._container.style.left = this._rotationCenterX - this._imgWidth/2 + "px";
293
294
        }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
295
          else if (supportedCSS)
296
          return function(angle){
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
{ was expected, but instead return was given.
Loading history...
297
            this._angle = angle;
298
            this._img.style[supportedCSS]="rotate("+(angle%360)+"deg)";
299
            this._img.style[supportedCSSOrigin]=this._parameters.center.join(" ");
0 ignored issues
show
Bug introduced by
The variable supportedCSSOrigin does not seem to be initialized in case supportedCSS on line 12 is false. Are you sure this can never be the case?
Loading history...
300
          }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
301
          else
302
            return function(angle)
0 ignored issues
show
Bug introduced by
{ was expected, but instead return was given.
Loading history...
303
          {
304
            this._angle = angle;
305
            angle=(angle%360)* rad;
306
            // clear canvas
307
            this._canvas.width = this._width;//+this._widthAdd;
308
            this._canvas.height = this._height;//+this._heightAdd;
309
310
            // REMEMBER: all drawings are read from backwards.. so first function is translate, then rotate, then translate, translate..
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
311
            this._cnv.translate(this._imgWidth*this._aspectW,this._imgHeight*this._aspectH);	// at least center image on screen
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
312
            this._cnv.translate(this._rotationCenterX,this._rotationCenterY);			// we move image back to its orginal
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
313
            this._cnv.rotate(angle);										// rotate image
314
            this._cnv.translate(-this._rotationCenterX,-this._rotationCenterY);		// move image to its center, so we can rotate around its center
0 ignored issues
show
Coding Style introduced by
Line is too long.
Loading history...
315
            this._cnv.scale(this._aspectW,this._aspectH); // SCALE - if needed ;)
316
            this._cnv.drawImage(this._img, 0, 0);							// First - we draw image
317
          }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
318
319
      })()
320
      }
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
321
322
      if (IE)
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable IE is declared in the current environment, consider using typeof IE === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
323
      {
324
        Wilq32.PhotoEffect.prototype.createVMLNode=(function(){
0 ignored issues
show
Bug introduced by
Wilq32 does not seem to be defined.
Loading history...
Configuration introduced by
There were too many errors found in this file; checking aborted after 95%.

If JSHint finds too many errors in a file, it aborts checking altogether because it suspects a configuration issue.

Further Reading:

Loading history...
325
          document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
326
          try {
327
            !document.namespaces.rvml && document.namespaces.add("rvml", "urn:schemas-microsoft-com:vml");
0 ignored issues
show
Bug introduced by
Did you forget to assign or call a function?

This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function:

function someFunction(x) {
    (x > 0) ? callFoo() : callBar();
}

// JSHint expects you to assign the result to a variable:
function someFunction(x) {
    var rs = (x > 0) ? callFoo() : callBar();
}

// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
    if (x > 0) {
        callFoo();
    } else {
        callBar();
    }
}
Loading history...
328
            return function (tagName) {
329
              return document.createElement('<rvml:' + tagName + ' class="rvml">');
330
            };
331
          } catch (e) {
332
            return function (tagName) {
333
              return document.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
334
            };
335
          }
336
        })();
337
      }
338
339
})(jQuery);