Completed
Push — master ( 369c90...324e29 )
by Michael
04:57
created

jQuery.event.trigger   F

Complexity

Conditions 24
Paths 966

Size

Total Lines 81

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 24
c 1
b 0
f 0
nc 966
nop 5
dl 0
loc 81
rs 2.4691

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like jQuery.event.trigger often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
(function () {
2
    /*
3
     * jQuery 1.2.6 - New Wave Javascript
4
     *
5
     * Copyright (c) 2008 John Resig (jquery.com)
6
     * Dual licensed under the MIT (MIT-LICENSE.txt)
7
     * and GPL (GPL-LICENSE.txt) licenses.
8
     *
9
     * $Date: 2010-01-23 21:04:25 +0100 (sam., 23 janv. 2010) $
10
     * $Rev: 2 $
11
     */
12
13
// Map over jQuery in case of overwrite
14
    var _jQuery = window.jQuery,
15
// Map over the $ in case of overwrite
16
        _$ = window.$;
17
18
    var jQuery = window.jQuery = window.$ = function (selector, context) {
19
        // The jQuery object is actually just the init constructor 'enhanced'
20
        return new jQuery.fn.init(selector, context);
21
    };
22
23
// A simple way to check for HTML strings or ID strings
24
// (both of which we optimize for)
25
    var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
26
27
// Is it a simple selector
28
        isSimple = /^.[^:#\[\.]*$/,
29
30
// Will speed up references to undefined, and allows munging its name.
31
        undefined;
32
33
    jQuery.fn = jQuery.prototype = {
34
        init: function (selector, context) {
35
            // Make sure that a selection was provided
36
            selector = selector || document;
37
38
            // Handle $(DOMElement)
39
            if (selector.nodeType) {
40
                this[0] = selector;
41
                this.length = 1;
42
                return this;
43
            }
44
            // Handle HTML strings
45
            if (typeof selector == "string") {
46
                // Are we dealing with HTML string or an ID?
47
                var match = quickExpr.exec(selector);
48
49
                // Verify a match, and that no context was specified for #id
50
                if (match && (match[1] || !context)) {
51
52
                    // HANDLE: $(html) -> $(array)
53
                    if (match[1])
54
                        selector = jQuery.clean([match[1]], context);
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...
55
56
                    // HANDLE: $("#id")
57
                    else {
58
                        var elem = document.getElementById(match[3]);
59
60
                        // Make sure an element was located
61
                        if (elem) {
62
                            // Handle the case where IE and Opera return items
63
                            // by name instead of ID
64
                            if (elem.id != match[3])
65
                                return jQuery().find(selector);
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...
66
67
                            // Otherwise, we inject the element directly into the jQuery object
68
                            return jQuery(elem);
69
                        }
70
                        selector = [];
71
                    }
72
73
                    // HANDLE: $(expr, [context])
74
                    // (which is just equivalent to: $(content).find(expr)
75
                } else
76
                    return jQuery(context).find(selector);
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...
77
78
                // HANDLE: $(function)
79
                // Shortcut for document ready
80
            } else if (jQuery.isFunction(selector))
81
                return jQuery(document)[jQuery.fn.ready ? "ready" : "load"](selector);
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...
82
83
            return this.setArray(jQuery.makeArray(selector));
84
        },
85
86
        // The current version of jQuery being used
87
        jquery: "1.2.6",
88
89
        // The number of elements contained in the matched element set
90
        size: function () {
91
            return this.length;
92
        },
93
94
        // The number of elements contained in the matched element set
95
        length: 0,
96
97
        // Get the Nth element in the matched element set OR
98
        // Get the whole matched element set as a clean array
99
        get: function (num) {
100
            return num == undefined ?
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
101
102
                // Return a 'clean' array
103
                jQuery.makeArray(this) :
104
105
                // Return just the object
106
                this[num];
107
        },
108
109
        // Take an array of elements and push it onto the stack
110
        // (returning the new matched element set)
111
        pushStack: function (elems) {
112
            // Build a new jQuery matched element set
113
            var ret = jQuery(elems);
114
115
            // Add the old object onto the stack (as a reference)
116
            ret.prevObject = this;
117
118
            // Return the newly-formed element set
119
            return ret;
120
        },
121
122
        // Force the current matched set of elements to become
123
        // the specified array of elements (destroying the stack in the process)
124
        // You should use pushStack() in order to do this, but maintain the stack
125
        setArray: function (elems) {
126
            // Resetting the length to 0, then using the native Array push
127
            // is a super-fast way to populate an object with array-like properties
128
            this.length = 0;
129
            Array.prototype.push.apply(this, elems);
130
131
            return this;
132
        },
133
134
        // Execute a callback for every element in the matched set.
135
        // (You can seed the arguments with an array of args, but this is
136
        // only used internally.)
137
        each: function (callback, args) {
138
            return jQuery.each(this, callback, args);
139
        },
140
141
        // Determine the position of an element within
142
        // the matched set of elements
143
        index: function (elem) {
144
            var ret = -1;
0 ignored issues
show
Unused Code introduced by
The variable ret seems to be never used. Consider removing it.
Loading history...
145
146
            // Locate the position of the desired element
147
            return jQuery.inArray(
148
                // If it receives a jQuery object, the first element is used
149
                elem && elem.jquery ? elem[0] : elem
150
                , this);
151
        },
152
153
        attr: function (name, value, type) {
154
            var options = name;
155
156
            // Look for the case where we're accessing a style value
157
            if (name.constructor == String)
158
                if (value === undefined)
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
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...
159
                    return this[0] && jQuery[type || "attr"](this[0], name);
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...
160
161
                else {
162
                    options = {};
163
                    options[name] = value;
164
                }
165
166
            // Check to see if we're setting style values
167
            return this.each(function (i) {
168
                // Set all the styles
169
                for (name in options)
170
                    jQuery.attr(
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...
171
                        type ?
172
                            this.style :
173
                            this,
174
                        name, jQuery.prop(this, options[name], type, i, name)
0 ignored issues
show
introduced by
The variable name is changed by the for-each loop on line 169. Only the value of the last iteration will be visible in this function if it is called outside of the loop.
Loading history...
175
                    );
176
            });
177
        },
178
179
        css: function (key, value) {
180
            // ignore negative width and height values
181
            if ((key == 'width' || key == 'height') && parseFloat(value) < 0)
182
                value = undefined;
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
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...
183
            return this.attr(key, value, "curCSS");
184
        },
185
186
        text: function (text) {
187
            if (typeof text != "object" && text != null)
188
                return this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(text));
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...
189
190
            var ret = "";
191
192
            jQuery.each(text || this, function () {
193
                jQuery.each(this.childNodes, function () {
194
                    if (this.nodeType != 8)
195
                        ret += this.nodeType != 1 ?
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...
196
                            this.nodeValue :
197
                            jQuery.fn.text([this]);
198
                });
199
            });
200
201
            return ret;
202
        },
203
204
        wrapAll: function (html) {
205
            if (this[0])
206
            // The elements to wrap the target around
207
                jQuery(html, this[0].ownerDocument)
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...
208
                    .clone()
209
                    .insertBefore(this[0])
210
                    .map(function () {
211
                        var elem = this;
212
213
                        while (elem.firstChild)
214
                            elem = elem.firstChild;
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...
215
216
                        return elem;
217
                    })
218
                    .append(this);
219
220
            return this;
221
        },
222
223
        wrapInner: function (html) {
224
            return this.each(function () {
225
                jQuery(this).contents().wrapAll(html);
226
            });
227
        },
228
229
        wrap: function (html) {
230
            return this.each(function () {
231
                jQuery(this).wrapAll(html);
232
            });
233
        },
234
235
        append: function () {
236
            return this.domManip(arguments, true, false, function (elem) {
237
                if (this.nodeType == 1)
238
                    this.appendChild(elem);
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...
239
            });
240
        },
241
242
        prepend: function () {
243
            return this.domManip(arguments, true, true, function (elem) {
244
                if (this.nodeType == 1)
245
                    this.insertBefore(elem, this.firstChild);
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...
246
            });
247
        },
248
249
        before: function () {
250
            return this.domManip(arguments, false, false, function (elem) {
251
                this.parentNode.insertBefore(elem, this);
252
            });
253
        },
254
255
        after: function () {
256
            return this.domManip(arguments, false, true, function (elem) {
257
                this.parentNode.insertBefore(elem, this.nextSibling);
258
            });
259
        },
260
261
        end: function () {
262
            return this.prevObject || jQuery([]);
263
        },
264
265
        find: function (selector) {
266
            var elems = jQuery.map(this, function (elem) {
267
                return jQuery.find(selector, elem);
268
            });
269
270
            return this.pushStack(/[^+>] [^+>]/.test(selector) || selector.indexOf("..") > -1 ?
271
                jQuery.unique(elems) :
272
                elems);
273
        },
274
275
        clone: function (events) {
276
            // Do the clone
277
            var ret = this.map(function () {
278
                if (jQuery.browser.msie && !jQuery.isXMLDoc(this)) {
279
                    // IE copies events bound via attachEvent when
280
                    // using cloneNode. Calling detachEvent on the
281
                    // clone will also remove the events from the orignal
282
                    // In order to get around this, we use innerHTML.
283
                    // Unfortunately, this means some modifications to
284
                    // attributes in IE that are actually only stored
285
                    // as properties will not be copied (such as the
286
                    // the name attribute on an input).
287
                    var clone = this.cloneNode(true),
288
                        container = document.createElement("div");
289
                    container.appendChild(clone);
290
                    return jQuery.clean([container.innerHTML])[0];
291
                } else
292
                    return this.cloneNode(true);
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...
293
            });
294
295
            // Need to set the expando to null on the cloned set if it exists
296
            // removeData doesn't work here, IE removes it from the original as well
297
            // this is primarily for IE but the data expando shouldn't be copied over in any browser
298
            var clone = ret.find("*").andSelf().each(function () {
299
                if (this[expando] != undefined)
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
300
                    this[expando] = null;
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...
301
            });
302
303
            // Copy the events from the original to the clone
304
            if (events === true)
305
                this.find("*").andSelf().each(function (i) {
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...
306
                    if (this.nodeType == 3)
307
                        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...
308
                    var events = jQuery.data(this, "events");
309
310
                    for (var type in events)
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
311
                        for (var handler in events[type])
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...
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
312
                            jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data);
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...
313
                });
314
315
            // Return the cloned set
316
            return ret;
317
        },
318
319
        filter: function (selector) {
320
            return this.pushStack(
321
                jQuery.isFunction(selector) &&
322
                jQuery.grep(this, function (elem, i) {
323
                    return selector.call(elem, i);
324
                }) ||
325
326
                jQuery.multiFilter(selector, this));
327
        },
328
329
        not: function (selector) {
330
            if (selector.constructor == String)
331
            // test special case where just one selector is passed in
332
                if (isSimple.test(selector))
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...
333
                    return this.pushStack(jQuery.multiFilter(selector, this, true));
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...
334
                else
335
                    selector = jQuery.multiFilter(selector, this);
336
337
            var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
338
            return this.filter(function () {
339
                return isArrayLike ? jQuery.inArray(this, selector) < 0 : this != selector;
340
            });
341
        },
342
343
        add: function (selector) {
344
            return this.pushStack(jQuery.unique(jQuery.merge(
345
                this.get(),
346
                typeof selector == 'string' ?
347
                    jQuery(selector) :
348
                    jQuery.makeArray(selector)
349
            )));
350
        },
351
352
        is: function (selector) {
353
            return !!selector && jQuery.multiFilter(selector, this).length > 0;
354
        },
355
356
        hasClass: function (selector) {
357
            return this.is("." + selector);
358
        },
359
360
        val: function (value) {
361
            if (value == undefined) {
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
362
363
                if (this.length) {
364
                    var elem = this[0];
365
366
                    // We need to handle select boxes special
367
                    if (jQuery.nodeName(elem, "select")) {
368
                        var index = elem.selectedIndex,
369
                            values = [],
370
                            options = elem.options,
371
                            one = elem.type == "select-one";
372
373
                        // Nothing was selected
374
                        if (index < 0)
375
                            return null;
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...
376
377
                        // Loop through all the selected options
378
                        for (var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++) {
379
                            var option = options[i];
380
381
                            if (option.selected) {
382
                                // Get the specifc value for the option
383
                                value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
384
385
                                // We don't need an array for one selects
386
                                if (one)
387
                                    return value;
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...
388
389
                                // Multi-Selects return an array
390
                                values.push(value);
391
                            }
392
                        }
393
394
                        return values;
395
396
                        // Everything else, we just grab the value
397
                    } else
398
                        return (this[0].value || "").replace(/\r/g, "");
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...
399
400
                }
401
402
                return undefined;
403
            }
404
405
            if (value.constructor == Number)
406
                value += '';
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...
407
408
            return this.each(function () {
409
                if (this.nodeType != 1)
410
                    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...
411
412
                if (value.constructor == Array && /radio|checkbox/.test(this.type))
413
                    this.checked = (jQuery.inArray(this.value, value) >= 0 ||
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...
414
                    jQuery.inArray(this.name, value) >= 0);
415
416
                else if (jQuery.nodeName(this, "select")) {
417
                    var values = jQuery.makeArray(value);
418
419
                    jQuery("option", this).each(function () {
420
                        this.selected = (jQuery.inArray(this.value, values) >= 0 ||
421
                        jQuery.inArray(this.text, values) >= 0);
422
                    });
423
424
                    if (!values.length)
425
                        this.selectedIndex = -1;
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...
426
427
                } else
428
                    this.value = value;
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...
429
            });
430
        },
431
432
        html: function (value) {
433
            return value == undefined ?
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
434
                (this[0] ?
435
                    this[0].innerHTML :
436
                    null) :
437
                this.empty().append(value);
438
        },
439
440
        replaceWith: function (value) {
441
            return this.after(value).remove();
442
        },
443
444
        eq: function (i) {
445
            return this.slice(i, i + 1);
446
        },
447
448
        slice: function () {
449
            return this.pushStack(Array.prototype.slice.apply(this, arguments));
450
        },
451
452
        map: function (callback) {
453
            return this.pushStack(jQuery.map(this, function (elem, i) {
454
                return callback.call(elem, i, elem);
455
            }));
456
        },
457
458
        andSelf: function () {
459
            return this.add(this.prevObject);
460
        },
461
462
        data: function (key, value) {
463
            var parts = key.split(".");
464
            parts[1] = parts[1] ? "." + parts[1] : "";
465
466
            if (value === undefined) {
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
467
                var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
468
469
                if (data === undefined && this.length)
470
                    data = jQuery.data(this[0], key);
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...
471
472
                return data === undefined && parts[1] ?
473
                    this.data(parts[0]) :
474
                    data;
475
            } else
476
                return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(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...
477
                    jQuery.data(this, key, value);
478
                });
479
        },
480
481
        removeData: function (key) {
482
            return this.each(function () {
483
                jQuery.removeData(this, key);
484
            });
485
        },
486
487
        domManip: function (args, table, reverse, callback) {
488
            var clone = this.length > 1, elems;
489
490
            return this.each(function () {
491
                if (!elems) {
492
                    elems = jQuery.clean(args, this.ownerDocument);
493
494
                    if (reverse)
495
                        elems.reverse();
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...
496
                }
497
498
                var obj = this;
499
500
                if (table && jQuery.nodeName(this, "table") && jQuery.nodeName(elems[0], "tr"))
501
                    obj = this.getElementsByTagName("tbody")[0] || this.appendChild(this.ownerDocument.createElement("tbody"));
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...
502
503
                var scripts = jQuery([]);
504
505
                jQuery.each(elems, function () {
506
                    var elem = clone ?
507
                        jQuery(this).clone(true)[0] :
508
                        this;
509
510
                    // execute all scripts after the elements have been injected
511
                    if (jQuery.nodeName(elem, "script"))
512
                        scripts = scripts.add(elem);
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...
513
                    else {
514
                        // Remove any inner scripts for later evaluation
515
                        if (elem.nodeType == 1)
516
                            scripts = scripts.add(jQuery("script", elem).remove());
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...
517
518
                        // Inject the elements into the document
519
                        callback.call(obj, elem);
520
                    }
521
                });
522
523
                scripts.each(evalScript);
524
            });
525
        }
526
    };
527
528
// Give the init function the jQuery prototype for later instantiation
529
    jQuery.fn.init.prototype = jQuery.fn;
530
531
    function evalScript(i, elem) {
532
        if (elem.src)
533
            jQuery.ajax({
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...
534
                url: elem.src,
535
                async: false,
536
                dataType: "script"
537
            });
538
539
        else
540
            jQuery.globalEval(elem.text || elem.textContent || elem.innerHTML || "");
541
542
        if (elem.parentNode)
543
            elem.parentNode.removeChild(elem);
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...
544
    }
545
546
    function now() {
547
        return +new Date;
548
    }
549
550
    jQuery.extend = jQuery.fn.extend = function () {
551
        // copy reference to target object
552
        var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
553
554
        // Handle a deep copy situation
555
        if (target.constructor == Boolean) {
556
            deep = target;
557
            target = arguments[1] || {};
558
            // skip the boolean and the target
559
            i = 2;
560
        }
561
562
        // Handle case when target is a string or something (possible in deep copy)
563
        if (typeof target != "object" && typeof target != "function")
564
            target = {};
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...
565
566
        // extend jQuery itself if only one argument is passed
567
        if (length == i) {
568
            target = this;
569
            --i;
570
        }
571
572
        for (; i < length; i++)
573
            // Only deal with non-null/undefined values
574
            if ((options = arguments[i]) != null)
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...
575
            // Extend the base object
576
                for (var name in options) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
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...
577
                    var src = target[name], copy = options[name];
578
579
                    // Prevent never-ending loop
580
                    if (target === copy)
581
                        continue;
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...
582
583
                    // Recurse if we're merging object values
584
                    if (deep && copy && typeof copy == "object" && !copy.nodeType)
585
                        target[name] = jQuery.extend(deep,
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...
586
                            // Never move original objects, clone them
587
                            src || ( copy.length != null ? [] : {} )
588
                            , copy);
589
590
                    // Don't bring in undefined values
591
                    else if (copy !== undefined)
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
592
                        target[name] = copy;
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...
593
594
                }
595
596
        // Return the modified object
597
        return target;
598
    };
599
600
    var expando = "jQuery" + now(), uuid = 0, windowData = {},
601
        // exclude the following css properties to add px
602
        exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
603
        // cache defaultView
604
        defaultView = document.defaultView || {};
605
606
    jQuery.extend({
607
        noConflict: function (deep) {
608
            window.$ = _$;
609
610
            if (deep)
611
                window.jQuery = _jQuery;
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...
612
613
            return jQuery;
614
        },
615
616
        // See test/unit/core.js for details concerning this function.
617
        isFunction: function (fn) {
618
            return !!fn && typeof fn != "string" && !fn.nodeName &&
619
                fn.constructor != Array && /^[\s[]?function/.test(fn + "");
620
        },
621
622
        // check if an element is in a (or is an) XML document
623
        isXMLDoc: function (elem) {
624
            return elem.documentElement && !elem.body ||
625
                elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
626
        },
627
628
        // Evalulates a script in a global context
629
        globalEval: function (data) {
630
            data = jQuery.trim(data);
631
632
            if (data) {
633
                // Inspired by code by Andrea Giammarchi
634
                // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
635
                var head = document.getElementsByTagName("head")[0] || document.documentElement,
636
                    script = document.createElement("script");
637
638
                script.type = "text/javascript";
639
                if (jQuery.browser.msie)
640
                    script.text = data;
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...
641
                else
642
                    script.appendChild(document.createTextNode(data));
643
644
                // Use insertBefore instead of appendChild  to circumvent an IE6 bug.
645
                // This arises when a base node is used (#2709).
646
                head.insertBefore(script, head.firstChild);
647
                head.removeChild(script);
648
            }
649
        },
650
651
        nodeName: function (elem, name) {
652
            return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
653
        },
654
655
        cache: {},
656
657
        data: function (elem, name, data) {
658
            elem = elem == window ?
659
                windowData :
660
                elem;
661
662
            var id = elem[expando];
663
664
            // Compute a unique ID for the element
665
            if (!id)
666
                id = elem[expando] = ++uuid;
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...
667
668
            // Only generate the data cache if we're
669
            // trying to access or manipulate it
670
            if (name && !jQuery.cache[id])
671
                jQuery.cache[id] = {};
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...
672
673
            // Prevent overriding the named cache with undefined values
674
            if (data !== undefined)
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
675
                jQuery.cache[id][name] = data;
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...
676
677
            // Return the named cache data, or the ID for the element
678
            return name ?
679
                jQuery.cache[id][name] :
680
                id;
681
        },
682
683
        removeData: function (elem, name) {
684
            elem = elem == window ?
685
                windowData :
686
                elem;
687
688
            var id = elem[expando];
689
690
            // If we want to remove a specific section of the element's data
691
            if (name) {
692
                if (jQuery.cache[id]) {
693
                    // Remove the section of cache data
694
                    delete jQuery.cache[id][name];
695
696
                    // If we've removed all the data, remove the element's cache
697
                    name = "";
698
699
                    for (name in jQuery.cache[id])
700
                        break;
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...
701
702
                    if (!name)
703
                        jQuery.removeData(elem);
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...
704
                }
705
706
                // Otherwise, we want to remove all of the element's data
707
            } else {
708
                // Clean up the element expando
709
                try {
710
                    delete elem[expando];
711
                } catch (e) {
712
                    // IE has trouble directly removing the expando
713
                    // but it's ok with using removeAttribute
714
                    if (elem.removeAttribute)
715
                        elem.removeAttribute(expando);
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...
716
                }
717
718
                // Completely remove the data cache
719
                delete jQuery.cache[id];
720
            }
721
        },
722
723
        // args is for internal usage only
724
        each: function (object, callback, args) {
725
            var name, i = 0, length = object.length;
726
727
            if (args) {
728
                if (length == undefined) {
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
729
                    for (name in object)
730
                        if (callback.apply(object[name], args) === false)
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...
731
                            break;
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...
732
                } else
733
                    for (; i < length;)
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...
734
                        if (callback.apply(object[i++], args) === false)
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...
735
                            break;
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...
736
737
                // A special, fast, case for the most common use of each
738
            } else {
739
                if (length == undefined) {
740
                    for (name in object)
741
                        if (callback.call(object[name], name, object[name]) === false)
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...
742
                            break;
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...
743
                } else
744
                    for (var value = object[0];
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...
745
                         i < length && callback.call(value, i, value) !== false; value = object[++i]) {
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
746
                    }
747
            }
748
749
            return object;
750
        },
751
752
        prop: function (elem, value, type, i, name) {
753
            // Handle executable functions
754
            if (jQuery.isFunction(value))
755
                value = value.call(elem, i);
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...
756
757
            // Handle passing in a number to a CSS property
758
            return value && value.constructor == Number && type == "curCSS" && !exclude.test(name) ?
759
            value + "px" :
760
                value;
761
        },
762
763
        className: {
764
            // internal only, use addClass("class")
765
            add: function (elem, classNames) {
766
                jQuery.each((classNames || "").split(/\s+/), function (i, className) {
767
                    if (elem.nodeType == 1 && !jQuery.className.has(elem.className, className))
768
                        elem.className += (elem.className ? " " : "") + className;
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...
769
                });
770
            },
771
772
            // internal only, use removeClass("class")
773
            remove: function (elem, classNames) {
774
                if (elem.nodeType == 1)
775
                    elem.className = classNames != undefined ?
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
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...
776
                        jQuery.grep(elem.className.split(/\s+/), function (className) {
777
                            return !jQuery.className.has(classNames, className);
778
                        }).join(" ") :
779
                        "";
780
            },
781
782
            // internal only, use hasClass("class")
783
            has: function (elem, className) {
784
                return jQuery.inArray(className, (elem.className || elem).toString().split(/\s+/)) > -1;
785
            }
786
        },
787
788
        // A method for quickly swapping in/out CSS properties to get correct calculations
789
        swap: function (elem, options, callback) {
790
            var old = {};
791
            // Remember the old values, and insert the new ones
792
            for (var name in options) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
793
                old[name] = elem.style[name];
794
                elem.style[name] = options[name];
795
            }
796
797
            callback.call(elem);
798
799
            // Revert the old values
800
            for (var name in options)
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable name already seems to be declared on line 792. 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...
801
                elem.style[name] = old[name];
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...
802
        },
803
804
        css: function (elem, name, force) {
805
            if (name == "width" || name == "height") {
806
                var val, props = {position: "absolute", visibility: "hidden", display: "block"}, which = name == "width" ? ["Left", "Right"] : ["Top", "Bottom"];
807
808
                function getWH() {
0 ignored issues
show
Bug introduced by
The function getWH is declared conditionally. This is not supported by all runtimes. Consider moving it to root scope or using var getWH = function() { /* ... */ }; instead.
Loading history...
809
                    val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
810
                    var padding = 0, border = 0;
811
                    jQuery.each(which, function () {
812
                        padding += parseFloat(jQuery.curCSS(elem, "padding" + this, true)) || 0;
813
                        border += parseFloat(jQuery.curCSS(elem, "border" + this + "Width", true)) || 0;
814
                    });
815
                    val -= Math.round(padding + border);
816
                }
817
818
                if (jQuery(elem).is(":visible"))
819
                    getWH();
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...
820
                else
821
                    jQuery.swap(elem, props, getWH);
822
823
                return Math.max(0, val);
824
            }
825
826
            return jQuery.curCSS(elem, name, force);
827
        },
828
829
        curCSS: function (elem, name, force) {
830
            var ret, style = elem.style;
831
832
            // A helper method for determining if an element's values are broken
833
            function color(elem) {
834
                if (!jQuery.browser.safari)
835
                    return false;
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...
836
837
                // defaultView is cached
838
                var ret = defaultView.getComputedStyle(elem, null);
839
                return !ret || ret.getPropertyValue("color") == "";
840
            }
841
842
            // We need to handle opacity special in IE
843
            if (name == "opacity" && jQuery.browser.msie) {
844
                ret = jQuery.attr(style, "opacity");
845
846
                return ret == "" ?
847
                    "1" :
848
                    ret;
849
            }
850
            // Opera sometimes will give the wrong display answer, this fixes it, see #2037
851
            if (jQuery.browser.opera && name == "display") {
852
                var save = style.outline;
853
                style.outline = "0 solid black";
854
                style.outline = save;
855
            }
856
857
            // Make sure we're using the right name for getting the float value
858
            if (name.match(/float/i))
859
                name = styleFloat;
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...
860
861
            if (!force && style && style[name])
862
                ret = style[name];
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...
863
864
            else if (defaultView.getComputedStyle) {
865
866
                // Only "float" is needed here
867
                if (name.match(/float/i))
868
                    name = "float";
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...
869
870
                name = name.replace(/([A-Z])/g, "-$1").toLowerCase();
871
872
                var computedStyle = defaultView.getComputedStyle(elem, null);
873
874
                if (computedStyle && !color(elem))
875
                    ret = computedStyle.getPropertyValue(name);
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...
876
877
                // If the element isn't reporting its values properly in Safari
878
                // then some display: none elements are involved
879
                else {
880
                    var swap = [], stack = [], a = elem, i = 0;
881
882
                    // Locate all of the parent display: none elements
883
                    for (; a && color(a); a = a.parentNode)
884
                        stack.unshift(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...
885
886
                    // Go through and make them visible, but in reverse
887
                    // (It would be better if we knew the exact display type that they had)
888
                    for (; i < stack.length; i++)
889
                        if (color(stack[i])) {
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...
890
                            swap[i] = stack[i].style.display;
891
                            stack[i].style.display = "block";
892
                        }
893
894
                    // Since we flip the display style, we have to handle that
895
                    // one special, otherwise get the value
896
                    ret = name == "display" && swap[stack.length - 1] != null ?
897
                        "none" :
898
                    ( computedStyle && computedStyle.getPropertyValue(name) ) || "";
899
900
                    // Finally, revert the display styles back
901
                    for (i = 0; i < swap.length; i++)
902
                        if (swap[i] != null)
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...
903
                            stack[i].style.display = swap[i];
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...
904
                }
905
906
                // We should always get a number back from opacity
907
                if (name == "opacity" && ret == "")
908
                    ret = "1";
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...
909
910
            } else if (elem.currentStyle) {
911
                var camelCase = name.replace(/\-(\w)/g, function (all, letter) {
912
                    return letter.toUpperCase();
913
                });
914
915
                ret = elem.currentStyle[name] || elem.currentStyle[camelCase];
916
917
                // From the awesome hack by Dean Edwards
918
                // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
919
920
                // If we're not dealing with a regular pixel number
921
                // but a number that has a weird ending, we need to convert it to pixels
922
                if (!/^\d+(px)?$/i.test(ret) && /^\d/.test(ret)) {
923
                    // Remember the original values
924
                    var left = style.left, rsLeft = elem.runtimeStyle.left;
925
926
                    // Put in the new values to get a computed value out
927
                    elem.runtimeStyle.left = elem.currentStyle.left;
928
                    style.left = ret || 0;
929
                    ret = style.pixelLeft + "px";
930
931
                    // Revert the changed values
932
                    style.left = left;
933
                    elem.runtimeStyle.left = rsLeft;
934
                }
935
            }
936
937
            return ret;
0 ignored issues
show
Bug introduced by
The variable ret does not seem to be initialized in case elem.currentStyle on line 910 is false. Are you sure this can never be the case?
Loading history...
938
        },
939
940
        clean: function (elems, context) {
941
            var ret = [];
942
            context = context || document;
943
            // !context.createElement fails in IE with an error but returns typeof 'object'
944
            if (typeof context.createElement == 'undefined')
945
                context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
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...
946
947
            jQuery.each(elems, function (i, elem) {
948
                if (!elem)
949
                    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...
950
951
                if (elem.constructor == Number)
952
                    elem += '';
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...
953
954
                // Convert html string into DOM nodes
955
                if (typeof elem == "string") {
956
                    // Fix "XHTML"-style tags in all browsers
957
                    elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function (all, front, tag) {
958
                        return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
959
                            all :
960
                        front + "></" + tag + ">";
961
                    });
962
963
                    // Trim whitespace, otherwise indexOf won't work as expected
964
                    var tags = jQuery.trim(elem).toLowerCase(), div = context.createElement("div");
965
966
                    var wrap =
967
                        // option or optgroup
968
                        !tags.indexOf("<opt") &&
969
                        [1, "<select multiple='multiple'>", "</select>"] ||
970
971
                        !tags.indexOf("<leg") &&
972
                        [1, "<fieldset>", "</fieldset>"] ||
973
974
                        tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
975
                        [1, "<table>", "</table>"] ||
976
977
                        !tags.indexOf("<tr") &&
978
                        [2, "<table><tbody>", "</tbody></table>"] ||
979
980
                        // <thead> matched above
981
                        (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
982
                        [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
983
984
                        !tags.indexOf("<col") &&
985
                        [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"] ||
986
987
                        // IE can't serialize <link> and <script> tags normally
988
                        jQuery.browser.msie &&
989
                        [1, "div<div>", "</div>"] ||
990
991
                        [0, "", ""];
992
993
                    // Go to html and back, then peel off extra wrappers
994
                    div.innerHTML = wrap[1] + elem + wrap[2];
995
996
                    // Move to the right depth
997
                    while (wrap[0]--)
998
                        div = div.lastChild;
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...
999
1000
                    // Remove IE's autoinserted <tbody> from table fragments
1001
                    if (jQuery.browser.msie) {
1002
1003
                        // String was a <table>, *may* have spurious <tbody>
1004
                        var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
1005
                        div.firstChild && div.firstChild.childNodes :
1006
1007
                            // String was a bare <thead> or <tfoot>
1008
                            wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
1009
                                div.childNodes :
1010
                                [];
1011
1012
                        for (var j = tbody.length - 1; j >= 0; --j)
1013
                            if (jQuery.nodeName(tbody[j], "tbody") && !tbody[j].childNodes.length)
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...
1014
                                tbody[j].parentNode.removeChild(tbody[j]);
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...
1015
1016
                        // IE completely kills leading whitespace when innerHTML is used
1017
                        if (/^\s/.test(elem))
1018
                            div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]), div.firstChild);
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...
1019
1020
                    }
1021
1022
                    elem = jQuery.makeArray(div.childNodes);
1023
                }
1024
1025
                if (elem.length === 0 && (!jQuery.nodeName(elem, "form") && !jQuery.nodeName(elem, "select")))
1026
                    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...
1027
1028
                if (elem[0] == undefined || jQuery.nodeName(elem, "form") || elem.options)
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
1029
                    ret.push(elem);
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...
1030
1031
                else
1032
                    ret = jQuery.merge(ret, elem);
1033
1034
            });
1035
1036
            return ret;
1037
        },
1038
1039
        attr: function (elem, name, value) {
1040
            // don't set attributes on text and comment nodes
1041
            if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
1042
                return undefined;
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
The variable undefined seems to be never initialized.
Loading history...
1043
1044
            var notxml = !jQuery.isXMLDoc(elem),
1045
                // Whether we are setting (or getting)
1046
                set = value !== undefined,
1047
                msie = jQuery.browser.msie;
1048
1049
            // Try to normalize/fix the name
1050
            name = notxml && jQuery.props[name] || name;
1051
1052
            // Only do all the following if this is a node (faster for style)
1053
            // IE elem.getAttribute passes even for style
1054
            if (elem.tagName) {
1055
1056
                // These attributes require special treatment
1057
                var special = /href|src|style/.test(name);
1058
1059
                // Safari mis-reports the default selected property of a hidden option
1060
                // Accessing the parent's selectedIndex property fixes it
1061
                if (name == "selected" && jQuery.browser.safari)
1062
                    elem.parentNode.selectedIndex;
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...
1063
1064
                // If applicable, access the attribute via the DOM 0 way
1065
                if (name in elem && notxml && !special) {
1066
                    if (set) {
1067
                        // We can't allow the type property to be changed (since it causes problems in IE)
1068
                        if (name == "type" && jQuery.nodeName(elem, "input") && elem.parentNode)
1069
                            throw "type property can't be changed";
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...
1070
1071
                        elem[name] = value;
1072
                    }
1073
1074
                    // browsers index elements by id/name on forms, give priority to attributes.
1075
                    if (jQuery.nodeName(elem, "form") && elem.getAttributeNode(name))
1076
                        return elem.getAttributeNode(name).nodeValue;
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...
1077
1078
                    return elem[name];
1079
                }
1080
1081
                if (msie && notxml && name == "style")
1082
                    return jQuery.attr(elem.style, "cssText", value);
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...
1083
1084
                if (set)
1085
                // convert the value to a string (all browsers do this but IE) see #1070
1086
                    elem.setAttribute(name, "" + value);
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...
1087
1088
                var attr = msie && notxml && special
1089
                    // Some attributes require a special call on IE
1090
                    ? elem.getAttribute(name, 2)
1091
                    : elem.getAttribute(name);
1092
1093
                // Non-existent attributes return null, we normalize to undefined
1094
                return attr === null ? undefined : attr;
1095
            }
1096
1097
            // elem is actually elem.style ... set the style
1098
1099
            // IE uses filters for opacity
1100
            if (msie && name == "opacity") {
1101
                if (set) {
1102
                    // IE has trouble with opacity if it does not have layout
1103
                    // Force it by setting the zoom level
1104
                    elem.zoom = 1;
1105
1106
                    // Set the alpha filter to set the opacity
1107
                    elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/, "") +
1108
                        (parseInt(value) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
1109
                }
1110
1111
                return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
1112
                (parseFloat(elem.filter.match(/opacity=([^)]*)/)[1]) / 100) + '' :
1113
                    "";
1114
            }
1115
1116
            name = name.replace(/-([a-z])/ig, function (all, letter) {
1117
                return letter.toUpperCase();
1118
            });
1119
1120
            if (set)
1121
                elem[name] = value;
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...
1122
1123
            return elem[name];
1124
        },
1125
1126
        trim: function (text) {
1127
            return (text || "").replace(/^\s+|\s+$/g, "");
1128
        },
1129
1130
        makeArray: function (array) {
1131
            var ret = [];
1132
1133
            if (array != null) {
1134
                var i = array.length;
1135
                //the window, strings and functions also have 'length'
1136
                if (i == null || array.split || array.setInterval || array.call)
1137
                    ret[0] = array;
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...
1138
                else
1139
                    while (i)
1140
                        ret[--i] = array[i];
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...
1141
            }
1142
1143
            return ret;
1144
        },
1145
1146
        inArray: function (elem, array) {
1147
            for (var i = 0, length = array.length; i < length; i++)
1148
                // Use === because on IE, window == document
1149
                if (array[i] === elem)
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...
1150
                    return i;
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...
1151
1152
            return -1;
1153
        },
1154
1155
        merge: function (first, second) {
1156
            // We have to loop this way because IE & Opera overwrite the length
1157
            // expando of getElementsByTagName
1158
            var i = 0, elem, pos = first.length;
1159
            // Also, we need to make sure that the correct elements are being returned
1160
            // (IE returns comment nodes in a '*' query)
1161
            if (jQuery.browser.msie) {
1162
                while (elem = second[i++])
1163
                    if (elem.nodeType != 8)
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...
1164
                        first[pos++] = elem;
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...
1165
1166
            } else
1167
                while (elem = second[i++])
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...
1168
                    first[pos++] = elem;
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...
1169
1170
            return first;
1171
        },
1172
1173
        unique: function (array) {
1174
            var ret = [], done = {};
1175
1176
            try {
1177
1178
                for (var i = 0, length = array.length; i < length; i++) {
1179
                    var id = jQuery.data(array[i]);
1180
1181
                    if (!done[id]) {
1182
                        done[id] = true;
1183
                        ret.push(array[i]);
1184
                    }
1185
                }
1186
1187
            } catch (e) {
1188
                ret = array;
1189
            }
1190
1191
            return ret;
1192
        },
1193
1194
        grep: function (elems, callback, inv) {
1195
            var ret = [];
1196
1197
            // Go through the array, only saving the items
1198
            // that pass the validator function
1199
            for (var i = 0, length = elems.length; i < length; i++)
1200
                if (!inv != !callback(elems[i], i))
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...
1201
                    ret.push(elems[i]);
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...
1202
1203
            return ret;
1204
        },
1205
1206
        map: function (elems, callback) {
1207
            var ret = [];
1208
1209
            // Go through the array, translating each of the items to their
1210
            // new value (or values).
1211
            for (var i = 0, length = elems.length; i < length; i++) {
1212
                var value = callback(elems[i], i);
1213
1214
                if (value != null)
1215
                    ret[ret.length] = value;
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...
1216
            }
1217
1218
            return ret.concat.apply([], ret);
1219
        }
1220
    });
1221
1222
    var userAgent = navigator.userAgent.toLowerCase();
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ 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...
1223
1224
// Figure out what browser is being used
1225
    jQuery.browser = {
1226
        version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
1227
        safari: /webkit/.test(userAgent),
1228
        opera: /opera/.test(userAgent),
1229
        msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
1230
        mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
1231
    };
1232
1233
    var styleFloat = jQuery.browser.msie ?
1234
        "styleFloat" :
1235
        "cssFloat";
1236
1237
    jQuery.extend({
1238
        // Check to see if the W3C box model is being used
1239
        boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
1240
1241
        props: {
1242
            "for": "htmlFor",
1243
            "class": "className",
1244
            "float": styleFloat,
1245
            cssFloat: styleFloat,
1246
            styleFloat: styleFloat,
1247
            readonly: "readOnly",
1248
            maxlength: "maxLength",
1249
            cellspacing: "cellSpacing",
1250
            rowspan: "rowSpan"
1251
        }
1252
    });
1253
1254
    jQuery.each({
1255
        parent: function (elem) {
1256
            return elem.parentNode;
1257
        },
1258
        parents: function (elem) {
1259
            return jQuery.dir(elem, "parentNode");
1260
        },
1261
        next: function (elem) {
1262
            return jQuery.nth(elem, 2, "nextSibling");
1263
        },
1264
        prev: function (elem) {
1265
            return jQuery.nth(elem, 2, "previousSibling");
1266
        },
1267
        nextAll: function (elem) {
1268
            return jQuery.dir(elem, "nextSibling");
1269
        },
1270
        prevAll: function (elem) {
1271
            return jQuery.dir(elem, "previousSibling");
1272
        },
1273
        siblings: function (elem) {
1274
            return jQuery.sibling(elem.parentNode.firstChild, elem);
1275
        },
1276
        children: function (elem) {
1277
            return jQuery.sibling(elem.firstChild);
1278
        },
1279
        contents: function (elem) {
1280
            return jQuery.nodeName(elem, "iframe") ? elem.contentDocument || elem.contentWindow.document : jQuery.makeArray(elem.childNodes);
1281
        }
1282
    }, function (name, fn) {
1283
        jQuery.fn[name] = function (selector) {
1284
            var ret = jQuery.map(this, fn);
1285
1286
            if (selector && typeof selector == "string")
1287
                ret = jQuery.multiFilter(selector, ret);
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...
1288
1289
            return this.pushStack(jQuery.unique(ret));
1290
        };
1291
    });
1292
1293
    jQuery.each({
1294
        appendTo: "append",
1295
        prependTo: "prepend",
1296
        insertBefore: "before",
1297
        insertAfter: "after",
1298
        replaceAll: "replaceWith"
1299
    }, function (name, original) {
1300
        jQuery.fn[name] = function () {
1301
            var args = arguments;
1302
1303
            return this.each(function () {
1304
                for (var i = 0, length = args.length; i < length; i++)
1305
                    jQuery(args[i])[original](this);
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...
1306
            });
1307
        };
1308
    });
1309
1310
    jQuery.each({
1311
        removeAttr: function (name) {
1312
            jQuery.attr(this, name, "");
1313
            if (this.nodeType == 1)
1314
                this.removeAttribute(name);
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...
1315
        },
1316
1317
        addClass: function (classNames) {
1318
            jQuery.className.add(this, classNames);
1319
        },
1320
1321
        removeClass: function (classNames) {
1322
            jQuery.className.remove(this, classNames);
1323
        },
1324
1325
        toggleClass: function (classNames) {
1326
            jQuery.className[jQuery.className.has(this, classNames) ? "remove" : "add"](this, classNames);
1327
        },
1328
1329
        remove: function (selector) {
1330
            if (!selector || jQuery.filter(selector, [this]).r.length) {
1331
                // Prevent memory leaks
1332
                jQuery("*", this).add(this).each(function () {
1333
                    jQuery.event.remove(this);
1334
                    jQuery.removeData(this);
1335
                });
1336
                if (this.parentNode)
1337
                    this.parentNode.removeChild(this);
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...
1338
            }
1339
        },
1340
1341
        empty: function () {
1342
            // Remove element nodes and prevent memory leaks
1343
            jQuery(">*", this).remove();
1344
1345
            // Remove any remaining nodes
1346
            while (this.firstChild)
1347
                this.removeChild(this.firstChild);
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...
1348
        }
1349
    }, function (name, fn) {
1350
        jQuery.fn[name] = function () {
1351
            return this.each(fn, arguments);
1352
        };
1353
    });
1354
1355
    jQuery.each(["Height", "Width"], function (i, name) {
1356
        var type = name.toLowerCase();
1357
1358
        jQuery.fn[type] = function (size) {
1359
            // Get window width or height
1360
            return this[0] == window ?
1361
                // Opera reports document.body.client[Width/Height] properly in both quirks and standards
1362
            jQuery.browser.opera && document.body["client" + name] ||
1363
1364
            // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
1365
            jQuery.browser.safari && window["inner" + name] ||
1366
1367
            // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
1368
            document.compatMode == "CSS1Compat" && document.documentElement["client" + name] || document.body["client" + name] :
1369
1370
                // Get document width or height
1371
                this[0] == document ?
1372
                    // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
1373
                    Math.max(
1374
                        Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),
1375
                        Math.max(document.body["offset" + name], document.documentElement["offset" + name])
1376
                    ) :
1377
1378
                    // Get or set width or height on the element
1379
                    size == undefined ?
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
1380
                        // Get width or height on the element
1381
                        (this.length ? jQuery.css(this[0], type) : null) :
1382
1383
                        // Set the width or height on the element (default to pixels if value is unitless)
1384
                        this.css(type, size.constructor == String ? size : size + "px");
1385
        };
1386
    });
1387
1388
// Helper function used by the dimensions and offset modules
1389
    function num(elem, prop) {
1390
        return elem[0] && parseInt(jQuery.curCSS(elem[0], prop, true), 10) || 0;
1391
    }
1392
1393
    var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
1394
            "(?:[\\w*_-]|\\\\.)" :
1395
            "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
1396
        quickChild = new RegExp("^>\\s*(" + chars + "+)"),
1397
        quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
1398
        quickClass = new RegExp("^([#.]?)(" + chars + "*)");
1399
1400
    jQuery.extend({
1401
        expr: {
1402
            "": function (a, i, m) {
1403
                return m[2] == "*" || jQuery.nodeName(a, m[2]);
1404
            },
1405
            "#": function (a, i, m) {
1406
                return a.getAttribute("id") == m[2];
1407
            },
1408
            ":": {
1409
                // Position Checks
1410
                lt: function (a, i, m) {
1411
                    return i < m[3] - 0;
1412
                },
1413
                gt: function (a, i, m) {
1414
                    return i > m[3] - 0;
1415
                },
1416
                nth: function (a, i, m) {
1417
                    return m[3] - 0 == i;
1418
                },
1419
                eq: function (a, i, m) {
1420
                    return m[3] - 0 == i;
1421
                },
1422
                first: function (a, i) {
1423
                    return i == 0;
1424
                },
1425
                last: function (a, i, m, r) {
1426
                    return i == r.length - 1;
1427
                },
1428
                even: function (a, i) {
1429
                    return i % 2 == 0;
1430
                },
1431
                odd: function (a, i) {
1432
                    return i % 2;
1433
                },
1434
1435
                // Child Checks
1436
                "first-child": function (a) {
1437
                    return a.parentNode.getElementsByTagName("*")[0] == a;
1438
                },
1439
                "last-child": function (a) {
1440
                    return jQuery.nth(a.parentNode.lastChild, 1, "previousSibling") == a;
1441
                },
1442
                "only-child": function (a) {
1443
                    return !jQuery.nth(a.parentNode.lastChild, 2, "previousSibling");
1444
                },
1445
1446
                // Parent Checks
1447
                parent: function (a) {
1448
                    return a.firstChild;
1449
                },
1450
                empty: function (a) {
1451
                    return !a.firstChild;
1452
                },
1453
1454
                // Text Check
1455
                contains: function (a, i, m) {
1456
                    return (a.textContent || a.innerText || jQuery(a).text() || "").indexOf(m[3]) >= 0;
1457
                },
1458
1459
                // Visibility
1460
                visible: function (a) {
1461
                    return "hidden" != a.type && jQuery.css(a, "display") != "none" && jQuery.css(a, "visibility") != "hidden";
1462
                },
1463
                hidden: function (a) {
1464
                    return "hidden" == a.type || jQuery.css(a, "display") == "none" || jQuery.css(a, "visibility") == "hidden";
1465
                },
1466
1467
                // Form attributes
1468
                enabled: function (a) {
1469
                    return !a.disabled;
1470
                },
1471
                disabled: function (a) {
1472
                    return a.disabled;
1473
                },
1474
                checked: function (a) {
1475
                    return a.checked;
1476
                },
1477
                selected: function (a) {
1478
                    return a.selected || jQuery.attr(a, "selected");
1479
                },
1480
1481
                // Form elements
1482
                text: function (a) {
1483
                    return "text" == a.type;
1484
                },
1485
                radio: function (a) {
1486
                    return "radio" == a.type;
1487
                },
1488
                checkbox: function (a) {
1489
                    return "checkbox" == a.type;
1490
                },
1491
                file: function (a) {
1492
                    return "file" == a.type;
1493
                },
1494
                password: function (a) {
1495
                    return "password" == a.type;
1496
                },
1497
                submit: function (a) {
1498
                    return "submit" == a.type;
1499
                },
1500
                image: function (a) {
1501
                    return "image" == a.type;
1502
                },
1503
                reset: function (a) {
1504
                    return "reset" == a.type;
1505
                },
1506
                button: function (a) {
1507
                    return "button" == a.type || jQuery.nodeName(a, "button");
1508
                },
1509
                input: function (a) {
1510
                    return /input|select|textarea|button/i.test(a.nodeName);
1511
                },
1512
1513
                // :has()
1514
                has: function (a, i, m) {
1515
                    return jQuery.find(m[3], a).length;
1516
                },
1517
1518
                // :header
1519
                header: function (a) {
1520
                    return /h\d/i.test(a.nodeName);
1521
                },
1522
1523
                // :animated
1524
                animated: function (a) {
1525
                    return jQuery.grep(jQuery.timers, function (fn) {
1526
                        return a == fn.elem;
1527
                    }).length;
1528
                }
1529
            }
1530
        },
1531
1532
        // The regular expressions that power the parsing engine
1533
        parse: [
1534
            // Match: [@value='test'], [@foo]
1535
            /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
1536
1537
            // Match: :contains('foo')
1538
            /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
1539
1540
            // Match: :even, :last-child, #id, .class
1541
            new RegExp("^([:.#]*)(" + chars + "+)")
1542
        ],
1543
1544
        multiFilter: function (expr, elems, not) {
1545
            var old, cur = [];
1546
1547
            while (expr && expr != old) {
0 ignored issues
show
Comprehensibility Bug introduced by
The variable old does not seem to be initialized in case the while loop on line 1547 is not entered. Are you sure this can never be the case?
Loading history...
1548
                old = expr;
1549
                var f = jQuery.filter(expr, elems, not);
1550
                expr = f.t.replace(/^\s*,\s*/, "");
1551
                cur = not ? elems = f.r : jQuery.merge(cur, f.r);
1552
            }
1553
1554
            return cur;
1555
        },
1556
1557
        find: function (t, context) {
1558
            // Quickly handle non-string expressions
1559
            if (typeof t != "string")
1560
                return [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...
1561
1562
            // check to make sure context is a DOM element or a document
1563
            if (context && context.nodeType != 1 && context.nodeType != 9)
1564
                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...
1565
1566
            // Set the correct context (if none is provided)
1567
            context = context || document;
1568
1569
            // Initialize the search
1570
            var ret = [context], done = [], last, nodeName;
1571
1572
            // Continue while a selector expression exists, and while
1573
            // we're no longer looping upon ourselves
1574
            while (t && last != t) {
0 ignored issues
show
Comprehensibility Bug introduced by
The variable last does not seem to be initialized in case the while loop on line 1574 is not entered. Are you sure this can never be the case?
Loading history...
1575
                var r = [];
1576
                last = t;
1577
1578
                t = jQuery.trim(t);
1579
1580
                var foundToken = false,
1581
1582
                    // An attempt at speeding up child selectors that
1583
                    // point to a specific element tag
1584
                    re = quickChild,
1585
1586
                    m = re.exec(t);
1587
1588
                if (m) {
1589
                    nodeName = m[1].toUpperCase();
1590
1591
                    // Perform our own iteration and filter
1592
                    for (var i = 0; ret[i]; i++)
1593
                        for (var c = ret[i].firstChild; c; c = c.nextSibling)
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...
1594
                            if (c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName))
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...
1595
                                r.push(c);
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...
1596
1597
                    ret = r;
1598
                    t = t.replace(re, "");
1599
                    if (t.indexOf(" ") == 0) continue;
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...
1600
                    foundToken = true;
1601
                } else {
1602
                    re = /^([>+~])\s*(\w*)/i;
1603
1604
                    if ((m = re.exec(t)) != null) {
1605
                        r = [];
1606
1607
                        var merge = {};
1608
                        nodeName = m[2].toUpperCase();
1609
                        m = m[1];
1610
1611
                        for (var j = 0, rl = ret.length; j < rl; j++) {
1612
                            var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
1613
                            for (; n; n = n.nextSibling)
1614
                                if (n.nodeType == 1) {
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...
1615
                                    var id = jQuery.data(n);
1616
1617
                                    if (m == "~" && merge[id]) break;
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...
1618
1619
                                    if (!nodeName || n.nodeName.toUpperCase() == nodeName) {
1620
                                        if (m == "~") merge[id] = true;
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...
1621
                                        r.push(n);
1622
                                    }
1623
1624
                                    if (m == "+") break;
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...
1625
                                }
1626
                        }
1627
1628
                        ret = r;
1629
1630
                        // And remove the token
1631
                        t = jQuery.trim(t.replace(re, ""));
1632
                        foundToken = true;
1633
                    }
1634
                }
1635
1636
                // See if there's still an expression, and that we haven't already
1637
                // matched a token
1638
                if (t && !foundToken) {
1639
                    // Handle multiple expressions
1640
                    if (!t.indexOf(",")) {
1641
                        // Clean the result set
1642
                        if (context == ret[0]) ret.shift();
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...
1643
1644
                        // Merge the result sets
1645
                        done = jQuery.merge(done, ret);
1646
1647
                        // Reset the context
1648
                        r = ret = [context];
1649
1650
                        // Touch up the selector string
1651
                        t = " " + t.substr(1, t.length);
1652
1653
                    } else {
1654
                        // Optimize for the case nodeName#idName
1655
                        var re2 = quickID;
1656
                        var m = re2.exec(t);
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable m already seems to be declared on line 1586. 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...
1657
1658
                        // Re-organize the results, so that they're consistent
1659
                        if (m) {
1660
                            m = [0, m[2], m[3], m[1]];
1661
1662
                        } else {
1663
                            // Otherwise, do a traditional filter check for
1664
                            // ID, class, and element selectors
1665
                            re2 = quickClass;
1666
                            m = re2.exec(t);
1667
                        }
1668
1669
                        m[2] = m[2].replace(/\\/g, "");
1670
1671
                        var elem = ret[ret.length - 1];
1672
1673
                        // Try to do a global search by ID, where we can
1674
                        if (m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem)) {
1675
                            // Optimization for HTML document case
1676
                            var oid = elem.getElementById(m[2]);
1677
1678
                            // Do a quick check for the existence of the actual ID attribute
1679
                            // to avoid selecting by the name attribute in IE
1680
                            // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
1681
                            if ((jQuery.browser.msie || jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2])
1682
                                oid = jQuery('[@id="' + m[2] + '"]', elem)[0];
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...
1683
1684
                            // Do a quick check for node name (where applicable) so
1685
                            // that div#foo searches will be really fast
1686
                            ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
1687
                        } else {
1688
                            // We need to find all descendant elements
1689
                            for (var i = 0; ret[i]; i++) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable i already seems to be declared on line 1592. 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...
1690
                                // Grab the tag name being searched for
1691
                                var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
1692
1693
                                // Handle IE7 being really dumb about <object>s
1694
                                if (tag == "*" && ret[i].nodeName.toLowerCase() == "object")
1695
                                    tag = "param";
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...
1696
1697
                                r = jQuery.merge(r, ret[i].getElementsByTagName(tag));
1698
                            }
1699
1700
                            // It's faster to filter by class and be done with it
1701
                            if (m[1] == ".")
1702
                                r = jQuery.classFilter(r, m[2]);
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...
1703
1704
                            // Same with ID filtering
1705
                            if (m[1] == "#") {
1706
                                var tmp = [];
1707
1708
                                // Try to find the element with the ID
1709
                                for (var i = 0; r[i]; i++)
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable i already seems to be declared on line 1592. 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...
1710
                                    if (r[i].getAttribute("id") == m[2]) {
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...
1711
                                        tmp = [r[i]];
1712
                                        break;
1713
                                    }
1714
1715
                                r = tmp;
1716
                            }
1717
1718
                            ret = r;
1719
                        }
1720
1721
                        t = t.replace(re2, "");
1722
                    }
1723
1724
                }
1725
1726
                // If a selector string still exists
1727
                if (t) {
1728
                    // Attempt to filter it
1729
                    var val = jQuery.filter(t, r);
1730
                    ret = r = val.r;
0 ignored issues
show
Unused Code introduced by
The assignment to variable r seems to be never used. Consider removing it.
Loading history...
1731
                    t = jQuery.trim(val.t);
1732
                }
1733
            }
1734
1735
            // An error occurred with the selector;
1736
            // just return an empty set instead
1737
            if (t)
1738
                ret = [];
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...
1739
1740
            // Remove the root context
1741
            if (ret && context == ret[0])
1742
                ret.shift();
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...
1743
1744
            // And combine the results
1745
            done = jQuery.merge(done, ret);
1746
1747
            return done;
1748
        },
1749
1750
        classFilter: function (r, m, not) {
1751
            m = " " + m + " ";
1752
            var tmp = [];
1753
            for (var i = 0; r[i]; i++) {
1754
                var pass = (" " + r[i].className + " ").indexOf(m) >= 0;
1755
                if (!not && pass || not && !pass)
1756
                    tmp.push(r[i]);
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...
1757
            }
1758
            return tmp;
1759
        },
1760
1761
        filter: function (t, r, not) {
1762
            var last;
1763
1764
            // Look for common filter expressions
1765
            while (t && t != last) {
0 ignored issues
show
Comprehensibility Bug introduced by
The variable last does not seem to be initialized in case the while loop on line 1765 is not entered. Are you sure this can never be the case?
Loading history...
1766
                last = t;
1767
1768
                var p = jQuery.parse, m;
1769
1770
                for (var i = 0; p[i]; i++) {
1771
                    m = p[i].exec(t);
1772
1773
                    if (m) {
1774
                        // Remove what we just matched
1775
                        t = t.substring(m[0].length);
1776
1777
                        m[2] = m[2].replace(/\\/g, "");
1778
                        break;
1779
                    }
1780
                }
1781
1782
                if (!m)
1783
                    break;
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...
1784
1785
                // :not() is a special case that can be optimized by
1786
                // keeping it out of the expression list
1787
                if (m[1] == ":" && m[2] == "not")
1788
                // optimize if only one selector found (most common case)
1789
                    r = isSimple.test(m[3]) ?
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...
1790
                        jQuery.filter(m[3], r, true).r :
1791
                        jQuery(r).not(m[3]);
1792
1793
                // We can get a big speed boost by filtering by class here
1794
                else if (m[1] == ".")
1795
                    r = jQuery.classFilter(r, m[2], not);
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...
1796
1797
                else if (m[1] == "[") {
1798
                    var tmp = [], type = m[3];
1799
1800
                    for (var i = 0, rl = r.length; i < rl; i++) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable i already seems to be declared on line 1770. 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...
1801
                        var a = r[i], z = a[jQuery.props[m[2]] || m[2]];
1802
1803
                        if (z == null || /href|src|selected/.test(m[2]))
1804
                            z = jQuery.attr(a, m[2]) || '';
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...
1805
1806
                        if ((type == "" && !!z ||
1807
                            type == "=" && z == m[5] ||
1808
                            type == "!=" && z != m[5] ||
1809
                            type == "^=" && z && !z.indexOf(m[5]) ||
1810
                            type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
1811
                            (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not)
1812
                            tmp.push(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...
1813
                    }
1814
1815
                    r = tmp;
1816
1817
                    // We can get a speed boost by handling nth-child here
1818
                } else if (m[1] == ":" && m[2] == "nth-child") {
1819
                    var merge = {}, tmp = [],
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable tmp already seems to be declared on line 1798. 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...
1820
                        // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
1821
                        test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
1822
                            m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
1823
                            !/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
1824
                        // calculate the numbers (first)n+(last) including if they are negative
1825
                        first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable last already seems to be declared on line 1762. 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...
1826
1827
                    // loop through all the elements left in the jQuery object
1828
                    for (var i = 0, rl = r.length; i < rl; i++) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable i already seems to be declared on line 1770. 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...
Comprehensibility Naming Best Practice introduced by
The variable rl already seems to be declared on line 1800. 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...
1829
                        var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
1830
1831
                        if (!merge[id]) {
1832
                            var c = 1;
1833
1834
                            for (var n = parentNode.firstChild; n; n = n.nextSibling)
1835
                                if (n.nodeType == 1)
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...
1836
                                    n.nodeIndex = c++;
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...
1837
1838
                            merge[id] = true;
1839
                        }
1840
1841
                        var add = false;
1842
1843
                        if (first == 0) {
1844
                            if (node.nodeIndex == last)
1845
                                add = true;
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...
1846
                        } else if ((node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0)
1847
                            add = true;
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...
1848
1849
                        if (add ^ not)
1850
                            tmp.push(node);
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...
1851
                    }
1852
1853
                    r = tmp;
1854
1855
                    // Otherwise, find the expression to execute
1856
                } else {
1857
                    var fn = jQuery.expr[m[1]];
1858
                    if (typeof fn == "object")
1859
                        fn = fn[m[2]];
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...
1860
1861
                    if (typeof fn == "string")
1862
                        fn = eval("false||function(a,i){return " + fn + ";}");
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...
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...
1863
1864
                    // Execute it against the current filter
1865
                    r = jQuery.grep(r, function (elem, i) {
1866
                        return fn(elem, i, m, r);
0 ignored issues
show
Bug introduced by
The variable r is changed as part of the while loop for example by tmp on line 1853. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
Bug introduced by
The variable m is changed as part of the while loop for example by p.i.exec(t) on line 1771. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
1867
                    }, not);
1868
                }
1869
            }
1870
1871
            // Return an array of filtered elements (r)
1872
            // and the modified expression string (t)
1873
            return {r: r, t: t};
1874
        },
1875
1876
        dir: function (elem, dir) {
1877
            var matched = [],
1878
                cur = elem[dir];
1879
            while (cur && cur != document) {
1880
                if (cur.nodeType == 1)
1881
                    matched.push(cur);
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...
1882
                cur = cur[dir];
1883
            }
1884
            return matched;
1885
        },
1886
1887
        nth: function (cur, result, dir, elem) {
0 ignored issues
show
Unused Code introduced by
The parameter elem is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
1888
            result = result || 1;
1889
            var num = 0;
1890
1891
            for (; cur; cur = cur[dir])
1892
                if (cur.nodeType == 1 && ++num == result)
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...
1893
                    break;
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...
1894
1895
            return cur;
1896
        },
1897
1898
        sibling: function (n, elem) {
1899
            var r = [];
1900
1901
            for (; n; n = n.nextSibling) {
1902
                if (n.nodeType == 1 && n != elem)
1903
                    r.push(n);
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...
1904
            }
1905
1906
            return r;
1907
        }
1908
    });
1909
    /*
1910
     * A number of helper functions used for managing events.
1911
     * Many of the ideas behind this code orignated from
1912
     * Dean Edwards' addEvent library.
1913
     */
1914
    jQuery.event = {
1915
1916
        // Bind an event to an element
1917
        // Original by Dean Edwards
1918
        add: function (elem, types, handler, data) {
1919
            if (elem.nodeType == 3 || elem.nodeType == 8)
1920
                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...
1921
1922
            // For whatever reason, IE has trouble passing the window object
1923
            // around, causing it to be cloned in the process
1924
            if (jQuery.browser.msie && elem.setInterval)
1925
                elem = window;
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...
1926
1927
            // Make sure that the function being executed has a unique ID
1928
            if (!handler.guid)
1929
                handler.guid = this.guid++;
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...
1930
1931
            // if data is passed, bind to handler
1932
            if (data != undefined) {
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
1933
                // Create temporary function pointer to original handler
1934
                var fn = handler;
1935
1936
                // Create unique handler function, wrapped around original handler
1937
                handler = this.proxy(fn, function () {
1938
                    // Pass arguments and context to original handler
1939
                    return fn.apply(this, arguments);
1940
                });
1941
1942
                // Store data in unique handler
1943
                handler.data = data;
1944
            }
1945
1946
            // Init the element's event structure
1947
            var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
1948
                handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function () {
1949
                        // Handle the second event of a trigger and when
1950
                        // an event is called after a page has unloaded
1951
                        if (typeof jQuery != "undefined" && !jQuery.event.triggered)
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if typeof jQuery != "undef...!jQuery.event.triggered is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
1952
                            return jQuery.event.handle.apply(arguments.callee.elem, arguments);
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...
1953
                    });
1954
            // Add elem as a property of the handle function
1955
            // This is to prevent a memory leak with non-native
1956
            // event in IE.
1957
            handle.elem = elem;
1958
1959
            // Handle multiple events separated by a space
1960
            // jQuery(...).bind("mouseover mouseout", fn);
1961
            jQuery.each(types.split(/\s+/), function (index, type) {
1962
                // Namespaced event handlers
1963
                var parts = type.split(".");
1964
                type = parts[0];
1965
                handler.type = parts[1];
1966
1967
                // Get the current list of functions bound to this event
1968
                var handlers = events[type];
1969
1970
                // Init the event handler queue
1971
                if (!handlers) {
1972
                    handlers = events[type] = {};
1973
1974
                    // Check for a special event handler
1975
                    // Only use addEventListener/attachEvent if the special
1976
                    // events handler returns false
1977
                    if (!jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false) {
1978
                        // Bind the global event handler to the element
1979
                        if (elem.addEventListener)
1980
                            elem.addEventListener(type, handle, false);
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...
1981
                        else if (elem.attachEvent)
1982
                            elem.attachEvent("on" + type, handle);
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...
1983
                    }
1984
                }
1985
1986
                // Add the function to the element's handler list
1987
                handlers[handler.guid] = handler;
1988
1989
                // Keep track of which events have been used, for global triggering
1990
                jQuery.event.global[type] = true;
1991
            });
1992
1993
            // Nullify elem to prevent memory leaks in IE
1994
            elem = null;
1995
        },
1996
1997
        guid: 1,
1998
        global: {},
1999
2000
        // Detach an event or set of events from an element
2001
        remove: function (elem, types, handler) {
2002
            // don't do events on text and comment nodes
2003
            if (elem.nodeType == 3 || elem.nodeType == 8)
2004
                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...
2005
2006
            var events = jQuery.data(elem, "events"), ret, index;
0 ignored issues
show
Unused Code introduced by
The variable index seems to be never used. Consider removing it.
Loading history...
2007
2008
            if (events) {
2009
                // Unbind all events for the element
2010
                if (types == undefined || (typeof types == "string" && types.charAt(0) == "."))
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
2011
                    for (var type in events)
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
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...
2012
                        this.remove(elem, type + (types || ""));
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...
2013
                else {
2014
                    // types is actually an event object here
2015
                    if (types.type) {
2016
                        handler = types.handler;
2017
                        types = types.type;
2018
                    }
2019
2020
                    // Handle multiple events seperated by a space
2021
                    // jQuery(...).unbind("mouseover mouseout", fn);
2022
                    jQuery.each(types.split(/\s+/), function (index, type) {
2023
                        // Namespaced event handlers
2024
                        var parts = type.split(".");
2025
                        type = parts[0];
2026
2027
                        if (events[type]) {
2028
                            // remove the given handler for the given type
2029
                            if (handler)
2030
                                delete events[type][handler.guid];
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...
2031
2032
                            // remove all handlers for the given type
2033
                            else
2034
                                for (handler in events[type])
2035
                                    // Handle the removal of namespaced events
2036
                                    if (!parts[1] || events[type][handler].type == parts[1])
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...
introduced by
The variable handler is changed by the for-each loop on line 2034. Only the value of the last iteration will be visible in this function if it is called outside of the loop.
Loading history...
2037
                                        delete events[type][handler];
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...
2038
2039
                            // remove generic event handler if no more handlers exist
2040
                            for (ret in events[type]) break;
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...
2041
                            if (!ret) {
2042
                                if (!jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false) {
2043
                                    if (elem.removeEventListener)
2044
                                        elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
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...
2045
                                    else if (elem.detachEvent)
2046
                                        elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
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...
2047
                                }
2048
                                ret = null;
2049
                                delete events[type];
2050
                            }
2051
                        }
2052
                    });
2053
                }
2054
2055
                // Remove the expando if it's no longer used
2056
                for (ret in events) break;
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...
2057
                if (!ret) {
2058
                    var handle = jQuery.data(elem, "handle");
2059
                    if (handle) handle.elem = null;
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...
2060
                    jQuery.removeData(elem, "events");
2061
                    jQuery.removeData(elem, "handle");
2062
                }
2063
            }
2064
        },
2065
2066
        trigger: function (type, data, elem, donative, extra) {
2067
            // Clone the incoming data, if any
2068
            data = jQuery.makeArray(data);
2069
2070
            if (type.indexOf("!") >= 0) {
2071
                type = type.slice(0, -1);
2072
                var exclusive = true;
2073
            }
2074
2075
            // Handle a global trigger
2076
            if (!elem) {
2077
                // Only trigger if we've ever bound an event for it
2078
                if (this.global[type])
2079
                    jQuery("*").add([window, document]).trigger(type, data);
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...
2080
2081
                // Handle triggering a single element
2082
            } else {
2083
                // don't do events on text and comment nodes
2084
                if (elem.nodeType == 3 || elem.nodeType == 8)
2085
                    return undefined;
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
The variable undefined seems to be never initialized.
Loading history...
2086
2087
                var val, ret, fn = jQuery.isFunction(elem[type] || null),
2088
                    // Check to see if we need to provide a fake event, or not
2089
                    event = !data[0] || !data[0].preventDefault;
2090
2091
                // Pass along a fake event
2092
                if (event) {
2093
                    data.unshift({
2094
                        type: type,
2095
                        target: elem,
2096
                        preventDefault: function () {
2097
                        },
2098
                        stopPropagation: function () {
2099
                        },
2100
                        timeStamp: now()
2101
                    });
2102
                    data[0][expando] = true; // no need to fix fake event
2103
                }
2104
2105
                // Enforce the right trigger type
2106
                data[0].type = type;
2107
                if (exclusive)
2108
                    data[0].exclusive = true;
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...
2109
2110
                // Trigger the event, it is assumed that "handle" is a function
2111
                var handle = jQuery.data(elem, "handle");
2112
                if (handle)
2113
                    val = handle.apply(elem, data);
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...
2114
2115
                // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
2116
                if ((!fn || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on" + type] && elem["on" + type].apply(elem, data) === false)
2117
                    val = false;
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...
2118
2119
                // Extra functions don't get the custom event object
2120
                if (event)
2121
                    data.shift();
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...
2122
2123
                // Handle triggering of extra function
2124
                if (extra && jQuery.isFunction(extra)) {
2125
                    // call the extra function and tack the current return value on the end for possible inspection
2126
                    ret = extra.apply(elem, val == null ? data : data.concat(val));
0 ignored issues
show
Bug introduced by
The variable val does not seem to be initialized in case handle on line 2112 is false. Are you sure this can never be the case?
Loading history...
2127
                    // if anything is returned, give it precedence and have it overwrite the previous value
2128
                    if (ret !== undefined)
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
2129
                        val = ret;
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...
2130
                }
2131
2132
                // Trigger the native events (except for clicks on links)
2133
                if (fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click")) {
2134
                    this.triggered = true;
2135
                    try {
2136
                        elem[type]();
2137
                        // prevent IE from throwing an error for some hidden elements
2138
                    } catch (e) {
2139
                    }
2140
                }
2141
2142
                this.triggered = false;
2143
            }
2144
2145
            return val;
2146
        },
2147
2148
        handle: function (event) {
2149
            // returned undefined or false
2150
            var val, ret, namespace, all, handlers;
2151
2152
            event = arguments[0] = jQuery.event.fix(event || window.event);
2153
2154
            // Namespaced event handlers
2155
            namespace = event.type.split(".");
2156
            event.type = namespace[0];
2157
            namespace = namespace[1];
2158
            // Cache this now, all = true means, any handler
2159
            all = !namespace && !event.exclusive;
2160
2161
            handlers = ( jQuery.data(this, "events") || {} )[event.type];
2162
2163
            for (var j in handlers) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
2164
                var handler = handlers[j];
2165
2166
                // Filter the functions by class
2167
                if (all || handler.type == namespace) {
2168
                    // Pass in a reference to the handler function itself
2169
                    // So that we can later remove it
2170
                    event.handler = handler;
2171
                    event.data = handler.data;
2172
2173
                    ret = handler.apply(this, arguments);
2174
2175
                    if (val !== false)
0 ignored issues
show
Bug introduced by
The variable val seems to not be initialized for all possible execution paths.
Loading history...
2176
                        val = ret;
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...
2177
2178
                    if (ret === false) {
2179
                        event.preventDefault();
2180
                        event.stopPropagation();
2181
                    }
2182
                }
2183
            }
2184
2185
            return val;
2186
        },
2187
2188
        props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" "),
2189
2190
        fix: function (event) {
2191
            if (event[expando] == true)
2192
                return event;
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...
2193
2194
            // store a copy of the original event object
2195
            // and "clone" to set read-only properties
2196
            var originalEvent = event;
2197
            event = {originalEvent: originalEvent};
2198
2199
            for (var i = this.props.length, prop; i;) {
2200
                prop = this.props[--i];
2201
                event[prop] = originalEvent[prop];
2202
            }
2203
2204
            // Mark it as fixed
2205
            event[expando] = true;
2206
2207
            // add preventDefault and stopPropagation since
2208
            // they will not work on the clone
2209
            event.preventDefault = function () {
2210
                // if preventDefault exists run it on the original event
2211
                if (originalEvent.preventDefault)
2212
                    originalEvent.preventDefault();
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...
2213
                // otherwise set the returnValue property of the original event to false (IE)
2214
                originalEvent.returnValue = false;
2215
            };
2216
            event.stopPropagation = function () {
2217
                // if stopPropagation exists run it on the original event
2218
                if (originalEvent.stopPropagation)
2219
                    originalEvent.stopPropagation();
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...
2220
                // otherwise set the cancelBubble property of the original event to true (IE)
2221
                originalEvent.cancelBubble = true;
2222
            };
2223
2224
            // Fix timeStamp
2225
            event.timeStamp = event.timeStamp || now();
2226
2227
            // Fix target property, if necessary
2228
            if (!event.target)
2229
                event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
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...
2230
2231
            // check if target is a textnode (safari)
2232
            if (event.target.nodeType == 3)
2233
                event.target = event.target.parentNode;
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...
2234
2235
            // Add relatedTarget, if necessary
2236
            if (!event.relatedTarget && event.fromElement)
2237
                event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
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...
2238
2239
            // Calculate pageX/Y if missing and clientX/Y available
2240
            if (event.pageX == null && event.clientX != null) {
2241
                var doc = document.documentElement, body = document.body;
2242
                event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
2243
                event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
2244
            }
2245
2246
            // Add which for key events
2247
            if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode))
2248
                event.which = event.charCode || event.keyCode;
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...
2249
2250
            // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
2251
            if (!event.metaKey && event.ctrlKey)
2252
                event.metaKey = event.ctrlKey;
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...
2253
2254
            // Add which for click: 1 == left; 2 == middle; 3 == right
2255
            // Note: button is not normalized, so don't use it
2256
            if (!event.which && event.button)
2257
                event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
0 ignored issues
show
introduced by
You have used a bitwise operator & in a condition. Did you maybe want to use the logical operator &&
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...
2258
2259
            return event;
2260
        },
2261
2262
        proxy: function (fn, proxy) {
2263
            // Set the guid of unique handler to the same of original handler, so it can be removed
2264
            proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
2265
            // So proxy can be declared as an argument
2266
            return proxy;
2267
        },
2268
2269
        special: {
2270
            ready: {
2271
                setup: function () {
2272
                    // Make sure the ready event is setup
2273
                    bindReady();
2274
                    return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
2275
                },
2276
2277
                teardown: function () {
2278
                    return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
2279
                }
2280
            },
2281
2282
            mouseenter: {
2283
                setup: function () {
2284
                    if (jQuery.browser.msie) return false;
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...
2285
                    jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
2286
                    return true;
2287
                },
2288
2289
                teardown: function () {
2290
                    if (jQuery.browser.msie) return false;
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...
2291
                    jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
2292
                    return true;
2293
                },
2294
2295
                handler: function (event) {
2296
                    // If we actually just moused on to a sub-element, ignore it
2297
                    if (withinElement(event, this)) return true;
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...
2298
                    // Execute the right handlers by setting the event type to mouseenter
2299
                    event.type = "mouseenter";
2300
                    return jQuery.event.handle.apply(this, arguments);
2301
                }
2302
            },
2303
2304
            mouseleave: {
2305
                setup: function () {
2306
                    if (jQuery.browser.msie) return false;
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...
2307
                    jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
2308
                    return true;
2309
                },
2310
2311
                teardown: function () {
2312
                    if (jQuery.browser.msie) return false;
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...
2313
                    jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
2314
                    return true;
2315
                },
2316
2317
                handler: function (event) {
2318
                    // If we actually just moused on to a sub-element, ignore it
2319
                    if (withinElement(event, this)) return true;
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...
2320
                    // Execute the right handlers by setting the event type to mouseleave
2321
                    event.type = "mouseleave";
2322
                    return jQuery.event.handle.apply(this, arguments);
2323
                }
2324
            }
2325
        }
2326
    };
2327
2328
    jQuery.fn.extend({
2329
        bind: function (type, data, fn) {
2330
            return type == "unload" ? this.one(type, data, fn) : this.each(function () {
2331
                jQuery.event.add(this, type, fn || data, fn && data);
2332
            });
2333
        },
2334
2335
        one: function (type, data, fn) {
2336
            var one = jQuery.event.proxy(fn || data, function (event) {
2337
                jQuery(this).unbind(event, one);
2338
                return (fn || data).apply(this, arguments);
2339
            });
2340
            return this.each(function () {
2341
                jQuery.event.add(this, type, one, fn && data);
2342
            });
2343
        },
2344
2345
        unbind: function (type, fn) {
2346
            return this.each(function () {
2347
                jQuery.event.remove(this, type, fn);
2348
            });
2349
        },
2350
2351
        trigger: function (type, data, fn) {
2352
            return this.each(function () {
2353
                jQuery.event.trigger(type, data, this, true, fn);
2354
            });
2355
        },
2356
2357
        triggerHandler: function (type, data, fn) {
2358
            return this[0] && jQuery.event.trigger(type, data, this[0], false, fn);
2359
        },
2360
2361
        toggle: function (fn) {
2362
            // Save reference to arguments for access in closure
2363
            var args = arguments, i = 1;
2364
2365
            // link all the functions, so any of them can unbind this click handler
2366
            while (i < args.length)
2367
                jQuery.event.proxy(fn, args[i++]);
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...
2368
2369
            return this.click(jQuery.event.proxy(fn, function (event) {
2370
                // Figure out which function to execute
2371
                this.lastToggle = ( this.lastToggle || 0 ) % i;
2372
2373
                // Make sure that clicks stop
2374
                event.preventDefault();
2375
2376
                // and execute the function
2377
                return args[this.lastToggle++].apply(this, arguments) || false;
2378
            }));
2379
        },
2380
2381
        hover: function (fnOver, fnOut) {
2382
            return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut);
2383
        },
2384
2385
        ready: function (fn) {
2386
            // Attach the listeners
2387
            bindReady();
2388
2389
            // If the DOM is already ready
2390
            if (jQuery.isReady)
2391
            // Execute the function immediately
2392
                fn.call(document, jQuery);
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...
2393
2394
            // Otherwise, remember the function for later
2395
            else
2396
            // Add the function to the wait list
2397
                jQuery.readyList.push(function () {
2398
                    return fn.call(this, jQuery);
2399
                });
2400
2401
            return this;
2402
        }
2403
    });
2404
2405
    jQuery.extend({
2406
        isReady: false,
2407
        readyList: [],
2408
        // Handle when the DOM is ready
2409
        ready: function () {
2410
            // Make sure that the DOM is not already loaded
2411
            if (!jQuery.isReady) {
2412
                // Remember that the DOM is ready
2413
                jQuery.isReady = true;
2414
2415
                // If there are functions bound, to execute
2416
                if (jQuery.readyList) {
2417
                    // Execute all of them
2418
                    jQuery.each(jQuery.readyList, function () {
2419
                        this.call(document);
2420
                    });
2421
2422
                    // Reset the list of functions
2423
                    jQuery.readyList = null;
2424
                }
2425
2426
                // Trigger any bound ready events
2427
                jQuery(document).triggerHandler("ready");
2428
            }
2429
        }
2430
    });
2431
2432
    var readyBound = false;
2433
2434
    function bindReady() {
2435
        if (readyBound) 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...
2436
        readyBound = true;
2437
2438
        // Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
2439
        if (document.addEventListener && !jQuery.browser.opera)
2440
        // Use the handy event callback
2441
            document.addEventListener("DOMContentLoaded", jQuery.ready, false);
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...
2442
2443
        // If IE is used and is not in a frame
2444
        // Continually check to see if the document is ready
2445
        if (jQuery.browser.msie && window == top) (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
The variable top seems to be never declared. If this is a global, consider adding a /** global: top */ 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...
2446
            if (jQuery.isReady) 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...
2447
            try {
2448
                // If IE is used, use the trick by Diego Perini
2449
                // http://javascript.nwbox.com/IEContentLoaded/
2450
                document.documentElement.doScroll("left");
2451
            } catch (error) {
2452
                setTimeout(arguments.callee, 0);
2453
                return;
2454
            }
2455
            // and execute any waiting functions
2456
            jQuery.ready();
2457
        })();
2458
2459
        if (jQuery.browser.opera)
2460
            document.addEventListener("DOMContentLoaded", 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...
2461
                if (jQuery.isReady) 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...
2462
                for (var i = 0; i < document.styleSheets.length; i++)
2463
                    if (document.styleSheets[i].disabled) {
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...
2464
                        setTimeout(arguments.callee, 0);
2465
                        return;
2466
                    }
2467
                // and execute any waiting functions
2468
                jQuery.ready();
2469
            }, false);
2470
2471
        if (jQuery.browser.safari) {
2472
            var numStyles;
2473
            (function () {
2474
                if (jQuery.isReady) 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...
2475
                if (document.readyState != "loaded" && document.readyState != "complete") {
2476
                    setTimeout(arguments.callee, 0);
2477
                    return;
2478
                }
2479
                if (numStyles === undefined)
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
2480
                    numStyles = jQuery("style, link[rel=stylesheet]").length;
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...
2481
                if (document.styleSheets.length != numStyles) {
0 ignored issues
show
Bug introduced by
The variable numStyles does not seem to be initialized in case numStyles === undefined on line 2479 is false. Are you sure this can never be the case?
Loading history...
2482
                    setTimeout(arguments.callee, 0);
2483
                    return;
2484
                }
2485
                // and execute any waiting functions
2486
                jQuery.ready();
2487
            })();
2488
        }
2489
2490
        // A fallback to window.onload, that will always work
2491
        jQuery.event.add(window, "load", jQuery.ready);
2492
    }
2493
2494
    jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick," +
2495
    "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
2496
    "submit,keydown,keypress,keyup,error").split(","), function (i, name) {
2497
2498
        // Handle event binding
2499
        jQuery.fn[name] = function (fn) {
2500
            return fn ? this.bind(name, fn) : this.trigger(name);
2501
        };
2502
    });
2503
2504
// Checks if an event happened on an element within another element
2505
// Used in jQuery.event.special.mouseenter and mouseleave handlers
2506
    var withinElement = function (event, elem) {
2507
        // Check if mouse(over|out) are still within the same parent element
2508
        var parent = event.relatedTarget;
2509
        // Traverse up the tree
2510
        while (parent && parent != elem) try {
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...
2511
            parent = parent.parentNode;
2512
        } catch (error) {
2513
            parent = elem;
2514
        }
2515
        // Return true if we actually just moused on to a sub-element
2516
        return parent == elem;
2517
    };
2518
2519
// Prevent memory leaks in IE
2520
// And prevent errors on refresh with events like mouseover in other browsers
2521
// Window isn't included so as not to unbind existing unload events
2522
    jQuery(window).bind("unload", function () {
2523
        jQuery("*").add(document).unbind();
2524
    });
2525
    jQuery.fn.extend({
2526
        // Keep a copy of the old load
2527
        _load: jQuery.fn.load,
2528
2529
        load: function (url, params, callback) {
2530
            if (typeof url != 'string')
2531
                return this._load(url);
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...
2532
2533
            var off = url.indexOf(" ");
2534
            if (off >= 0) {
2535
                var selector = url.slice(off, url.length);
2536
                url = url.slice(0, off);
2537
            }
2538
2539
            callback = callback || function () {
2540
                };
2541
2542
            // Default to a GET request
2543
            var type = "GET";
2544
2545
            // If the second parameter was provided
2546
            if (params)
2547
            // If it's a function
2548
                if (jQuery.isFunction(params)) {
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...
2549
                    // We assume that it's the callback
2550
                    callback = params;
2551
                    params = null;
2552
2553
                    // Otherwise, build a param string
2554
                } else if (typeof params == 'object') {
2555
                    params = jQuery.param(params);
2556
                    type = "POST";
2557
                }
2558
2559
            var self = this;
2560
2561
            // Request the remote document
2562
            jQuery.ajax({
2563
                url: url,
2564
                type: type,
2565
                dataType: "html",
2566
                data: params,
2567
                complete: function (res, status) {
2568
                    // If successful, inject the HTML into all the matched elements
2569
                    if (status == "success" || status == "notmodified")
2570
                    // See if a selector was specified
2571
                        self.html(selector ?
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...
2572
                            // Create a dummy div to hold the results
2573
                            jQuery("<div/>")
2574
                            // inject the contents of the document in, removing the scripts
2575
                            // to avoid any 'Permission Denied' errors in IE
2576
                                .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
2577
2578
                                // Locate the specified elements
2579
                                .find(selector) :
2580
2581
                            // If not, just inject the full result
2582
                            res.responseText);
2583
2584
                    self.each(callback, [res.responseText, status, res]);
2585
                }
2586
            });
2587
            return this;
2588
        },
2589
2590
        serialize: function () {
2591
            return jQuery.param(this.serializeArray());
2592
        },
2593
        serializeArray: function () {
2594
            return this.map(function () {
2595
                return jQuery.nodeName(this, "form") ?
2596
                    jQuery.makeArray(this.elements) : this;
2597
            })
2598
                .filter(function () {
2599
                    return this.name && !this.disabled &&
2600
                        (this.checked || /select|textarea/i.test(this.nodeName) ||
2601
                        /text|hidden|password/i.test(this.type));
2602
                })
2603
                .map(function (i, elem) {
2604
                    var val = jQuery(this).val();
2605
                    return val == null ? null :
2606
                        val.constructor == Array ?
2607
                            jQuery.map(val, function (val, i) {
0 ignored issues
show
Unused Code introduced by
The parameter i is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
2608
                                return {name: elem.name, value: val};
2609
                            }) :
2610
                        {name: elem.name, value: val};
2611
                }).get();
2612
        }
2613
    });
2614
2615
// Attach a bunch of functions for handling common AJAX events
2616
    jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function (i, o) {
2617
        jQuery.fn[o] = function (f) {
2618
            return this.bind(o, f);
2619
        };
2620
    });
2621
2622
    var jsc = now();
2623
2624
    jQuery.extend({
2625
        get: function (url, data, callback, type) {
2626
            // shift arguments if data argument was ommited
2627
            if (jQuery.isFunction(data)) {
2628
                callback = data;
2629
                data = null;
2630
            }
2631
2632
            return jQuery.ajax({
2633
                type: "GET",
2634
                url: url,
2635
                data: data,
2636
                success: callback,
2637
                dataType: type
2638
            });
2639
        },
2640
2641
        getScript: function (url, callback) {
2642
            return jQuery.get(url, null, callback, "script");
2643
        },
2644
2645
        getJSON: function (url, data, callback) {
2646
            return jQuery.get(url, data, callback, "json");
2647
        },
2648
2649
        post: function (url, data, callback, type) {
2650
            if (jQuery.isFunction(data)) {
2651
                callback = data;
2652
                data = {};
2653
            }
2654
2655
            return jQuery.ajax({
2656
                type: "POST",
2657
                url: url,
2658
                data: data,
2659
                success: callback,
2660
                dataType: type
2661
            });
2662
        },
2663
2664
        ajaxSetup: function (settings) {
2665
            jQuery.extend(jQuery.ajaxSettings, settings);
2666
        },
2667
2668
        ajaxSettings: {
2669
            url: location.href,
2670
            global: true,
2671
            type: "GET",
2672
            timeout: 0,
2673
            contentType: "application/x-www-form-urlencoded",
2674
            processData: true,
2675
            async: true,
2676
            data: null,
2677
            username: null,
2678
            password: null,
2679
            accepts: {
2680
                xml: "application/xml, text/xml",
2681
                html: "text/html",
2682
                script: "text/javascript, application/javascript",
2683
                json: "application/json, text/javascript",
2684
                text: "text/plain",
2685
                _default: "*/*"
2686
            }
2687
        },
2688
2689
        // Last-Modified header cache for next request
2690
        lastModified: {},
2691
2692
        ajax: function (s) {
2693
            // Extend the settings, but re-extend 's' so that it can be
2694
            // checked again later (in the test suite, specifically)
2695
            s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
2696
2697
            var jsonp, jsre = /=\?(&|$)/g, status, data,
2698
                type = s.type.toUpperCase();
2699
2700
            // convert data if not already a string
2701
            if (s.data && s.processData && typeof s.data != "string")
2702
                s.data = jQuery.param(s.data);
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...
2703
2704
            // Handle JSONP Parameter Callbacks
2705
            if (s.dataType == "jsonp") {
2706
                if (type == "GET") {
2707
                    if (!s.url.match(jsre))
2708
                        s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
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...
2709
                } else if (!s.data || !s.data.match(jsre))
2710
                    s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
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...
2711
                s.dataType = "json";
2712
            }
2713
2714
            // Build temporary JSONP function
2715
            if (s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre))) {
2716
                jsonp = "jsonp" + jsc++;
2717
2718
                // Replace the =? sequence both in the query string and the data
2719
                if (s.data)
2720
                    s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
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...
2721
                s.url = s.url.replace(jsre, "=" + jsonp + "$1");
2722
2723
                // We need to make sure
2724
                // that a JSONP style response is executed properly
2725
                s.dataType = "script";
2726
2727
                // Handle JSONP-style loading
2728
                window[jsonp] = function (tmp) {
2729
                    data = tmp;
2730
                    success();
2731
                    complete();
2732
                    // Garbage collect
2733
                    window[jsonp] = undefined;
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
2734
                    try {
2735
                        delete window[jsonp];
2736
                    } catch (e) {
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
2737
                    }
2738
                    if (head)
2739
                        head.removeChild(script);
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...
2740
                };
2741
            }
2742
2743
            if (s.dataType == "script" && s.cache == null)
2744
                s.cache = false;
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...
2745
2746
            if (s.cache === false && type == "GET") {
2747
                var ts = now();
2748
                // try replacing _= if it is there
2749
                var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
2750
                // if nothing was replaced, add timestamp to the end
2751
                s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
2752
            }
2753
2754
            // If data is available, append data to url for get requests
2755
            if (s.data && type == "GET") {
2756
                s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
2757
2758
                // IE likes to send both get and post data, prevent this
2759
                s.data = null;
2760
            }
2761
2762
            // Watch for a new set of requests
2763
            if (s.global && !jQuery.active++)
2764
                jQuery.event.trigger("ajaxStart");
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...
2765
2766
            // Matches an absolute URL, and saves the domain
2767
            var remote = /^(?:\w+:)?\/\/([^\/?#]+)/;
2768
2769
            // If we're requesting a remote document
2770
            // and trying to load JSON or Script with a GET
2771
            if (s.dataType == "script" && type == "GET"
2772
                && remote.test(s.url) && remote.exec(s.url)[1] != location.host) {
2773
                var head = document.getElementsByTagName("head")[0];
2774
                var script = document.createElement("script");
2775
                script.src = s.url;
2776
                if (s.scriptCharset)
2777
                    script.charset = s.scriptCharset;
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...
2778
2779
                // Handle Script loading
2780
                if (!jsonp) {
2781
                    var done = false;
2782
2783
                    // Attach handlers for all browsers
2784
                    script.onload = script.onreadystatechange = function () {
2785
                        if (!done && (!this.readyState ||
2786
                            this.readyState == "loaded" || this.readyState == "complete")) {
2787
                            done = true;
2788
                            success();
2789
                            complete();
2790
                            head.removeChild(script);
2791
                        }
2792
                    };
2793
                }
2794
2795
                head.appendChild(script);
2796
2797
                // We handle everything using the script element injection
2798
                return undefined;
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
2799
            }
2800
2801
            var requestDone = false;
2802
2803
            // Create the request object; Microsoft failed to properly
2804
            // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
2805
            var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
0 ignored issues
show
Bug introduced by
The variable ActiveXObject seems to be never declared. If this is a global, consider adding a /** global: ActiveXObject */ 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
The variable XMLHttpRequest seems to be never declared. If this is a global, consider adding a /** global: XMLHttpRequest */ 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...
2806
2807
            // Open the socket
2808
            // Passing null username, generates a login popup on Opera (#2865)
2809
            if (s.username)
2810
                xhr.open(type, s.url, s.async, s.username, s.password);
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...
2811
            else
2812
                xhr.open(type, s.url, s.async);
2813
2814
            // Need an extra try/catch for cross domain requests in Firefox 3
2815
            try {
2816
                // Set the correct header, if data is being sent
2817
                if (s.data)
2818
                    xhr.setRequestHeader("Content-Type", s.contentType);
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...
2819
2820
                // Set the If-Modified-Since header, if ifModified mode.
2821
                if (s.ifModified)
2822
                    xhr.setRequestHeader("If-Modified-Since",
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...
2823
                        jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT");
2824
2825
                // Set header so the called script knows that it's an XMLHttpRequest
2826
                xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
2827
2828
                // Set the Accepts header for the server, depending on the dataType
2829
                xhr.setRequestHeader("Accept", s.dataType && s.accepts[s.dataType] ?
2830
                s.accepts[s.dataType] + ", */*" :
2831
                    s.accepts._default);
2832
            } catch (e) {
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
2833
            }
2834
2835
            // Allow custom headers/mimetypes
2836
            if (s.beforeSend && s.beforeSend(xhr, s) === false) {
2837
                // cleanup active request counter
2838
                s.global && jQuery.active--;
2839
                // close opended socket
2840
                xhr.abort();
2841
                return false;
2842
            }
2843
2844
            if (s.global)
2845
                jQuery.event.trigger("ajaxSend", [xhr, s]);
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...
2846
2847
            // Wait for a response to come back
2848
            var onreadystatechange = function (isTimeout) {
2849
                // The transfer is complete and the data is available, or the request timed out
2850
                if (!requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout")) {
2851
                    requestDone = true;
2852
2853
                    // clear poll interval
2854
                    if (ival) {
2855
                        clearInterval(ival);
2856
                        ival = null;
2857
                    }
2858
2859
                    status = isTimeout == "timeout" ? "timeout" :
2860
                        !jQuery.httpSuccess(xhr) ? "error" :
2861
                            s.ifModified && jQuery.httpNotModified(xhr, s.url) ? "notmodified" :
2862
                                "success";
2863
2864
                    if (status == "success") {
2865
                        // Watch for, and catch, XML document parse errors
2866
                        try {
2867
                            // process the data (runs the xml through httpData regardless of callback)
2868
                            data = jQuery.httpData(xhr, s.dataType, s.dataFilter);
2869
                        } catch (e) {
2870
                            status = "parsererror";
2871
                        }
2872
                    }
2873
2874
                    // Make sure that the request was successful or notmodified
2875
                    if (status == "success") {
2876
                        // Cache Last-Modified header, if ifModified mode.
2877
                        var modRes;
2878
                        try {
2879
                            modRes = xhr.getResponseHeader("Last-Modified");
2880
                        } catch (e) {
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
2881
                        } // swallow exception thrown by FF if header is not available
2882
2883
                        if (s.ifModified && modRes)
2884
                            jQuery.lastModified[s.url] = modRes;
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...
2885
2886
                        // JSONP handles its own success callback
2887
                        if (!jsonp)
2888
                            success();
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...
2889
                    } else
2890
                        jQuery.handleError(s, xhr, status);
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...
2891
2892
                    // Fire the complete handlers
2893
                    complete();
2894
2895
                    // Stop memory leaks
2896
                    if (s.async)
2897
                        xhr = null;
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...
2898
                }
2899
            };
2900
2901
            if (s.async) {
2902
                // don't attach the handler to the request, just poll it instead
2903
                var ival = setInterval(onreadystatechange, 13);
2904
2905
                // Timeout checker
2906
                if (s.timeout > 0)
2907
                    setTimeout(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...
2908
                        // Check to see if the request is still happening
2909
                        if (xhr) {
2910
                            // Cancel the request
2911
                            xhr.abort();
2912
2913
                            if (!requestDone)
2914
                                onreadystatechange("timeout");
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...
2915
                        }
2916
                    }, s.timeout);
2917
            }
2918
2919
            // Send the data
2920
            try {
2921
                xhr.send(s.data);
2922
            } catch (e) {
2923
                jQuery.handleError(s, xhr, null, e);
2924
            }
2925
2926
            // firefox 1.5 doesn't fire statechange for sync requests
2927
            if (!s.async)
2928
                onreadystatechange();
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...
2929
2930
            function success() {
2931
                // If a local callback was specified, fire it and pass it the data
2932
                if (s.success)
2933
                    s.success(data, status);
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...
2934
2935
                // Fire the global callback
2936
                if (s.global)
2937
                    jQuery.event.trigger("ajaxSuccess", [xhr, s]);
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...
2938
            }
2939
2940
            function complete() {
2941
                // Process result
2942
                if (s.complete)
2943
                    s.complete(xhr, status);
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...
2944
2945
                // The request was completed
2946
                if (s.global)
2947
                    jQuery.event.trigger("ajaxComplete", [xhr, s]);
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...
2948
2949
                // Handle the global AJAX counter
2950
                if (s.global && !--jQuery.active)
2951
                    jQuery.event.trigger("ajaxStop");
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...
2952
            }
2953
2954
            // return XMLHttpRequest to allow aborting the request etc.
2955
            return xhr;
2956
        },
2957
2958
        handleError: function (s, xhr, status, e) {
2959
            // If a local callback was specified, fire it
2960
            if (s.error) s.error(xhr, status, e);
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...
2961
2962
            // Fire the global callback
2963
            if (s.global)
2964
                jQuery.event.trigger("ajaxError", [xhr, s, e]);
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...
2965
        },
2966
2967
        // Counter for holding the number of active queries
2968
        active: 0,
2969
2970
        // Determines if an XMLHttpRequest was successful or not
2971
        httpSuccess: function (xhr) {
2972
            try {
2973
                // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
2974
                return !xhr.status && location.protocol == "file:" ||
2975
                    ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 ||
2976
                    jQuery.browser.safari && xhr.status == undefined;
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
2977
            } catch (e) {
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
2978
            }
2979
            return false;
2980
        },
2981
2982
        // Determines if an XMLHttpRequest returns NotModified
2983
        httpNotModified: function (xhr, url) {
2984
            try {
2985
                var xhrRes = xhr.getResponseHeader("Last-Modified");
2986
2987
                // Firefox always returns 200. check Last-Modified date
2988
                return xhr.status == 304 || xhrRes == jQuery.lastModified[url] ||
2989
                    jQuery.browser.safari && xhr.status == undefined;
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
2990
            } catch (e) {
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
2991
            }
2992
            return false;
2993
        },
2994
2995
        httpData: function (xhr, type, filter) {
2996
            var ct = xhr.getResponseHeader("content-type"),
2997
                xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
2998
                data = xml ? xhr.responseXML : xhr.responseText;
2999
3000
            if (xml && data.documentElement.tagName == "parsererror")
3001
                throw "parsererror";
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...
3002
3003
            // Allow a pre-filtering function to sanitize the response
3004
            if (filter)
3005
                data = filter(data, type);
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...
3006
3007
            // If the type is "script", eval it in global context
3008
            if (type == "script")
3009
                jQuery.globalEval(data);
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...
3010
3011
            // Get the JavaScript object, if JSON is used.
3012
            if (type == "json")
3013
                data = eval("(" + data + ")");
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...
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...
3014
3015
            return data;
3016
        },
3017
3018
        // Serialize an array of form elements or a set of
3019
        // key/values into a query string
3020
        param: function (a) {
3021
            var s = [];
3022
3023
            function add(key, value) {
3024
                s[s.length] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
3025
            };
3026
3027
            // If an array was passed in, assume that it is an array
3028
            // of form elements
3029
            if (a.constructor == Array || a.jquery)
3030
            // Serialize the form elements
3031
                jQuery.each(a, 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...
3032
                    add(this.name, this.value);
3033
                });
3034
3035
            // Otherwise, assume that it's an object of key/value pairs
3036
            else
3037
            // Serialize the key/values
3038
                for (var j in a)
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
3039
                    // If the value is an array then the key names need to be repeated
3040
                    if (a[j] && a[j].constructor == Array)
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...
3041
                        jQuery.each(a[j], 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...
3042
                            add(j, this);
0 ignored issues
show
introduced by
The variable j is changed by the for-each loop on line 3038. Only the value of the last iteration will be visible in this function if it is called outside of the loop.
Loading history...
3043
                        });
3044
                    else
3045
                        add(j, jQuery.isFunction(a[j]) ? a[j]() : a[j]);
3046
3047
            // Return the resulting serialization
3048
            return s.join("&").replace(/%20/g, "+");
3049
        }
3050
3051
    });
3052
    jQuery.fn.extend({
3053
        show: function (speed, callback) {
3054
            return speed ?
3055
                this.animate({
3056
                    height: "show", width: "show", opacity: "show"
3057
                }, speed, callback) :
3058
3059
                this.filter(":hidden").each(function () {
3060
                    this.style.display = this.oldblock || "";
3061
                    if (jQuery.css(this, "display") == "none") {
3062
                        var elem = jQuery("<" + this.tagName + " />").appendTo("body");
3063
                        this.style.display = elem.css("display");
3064
                        // handle an edge condition where css is - div { display:none; } or similar
3065
                        if (this.style.display == "none")
3066
                            this.style.display = "block";
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...
3067
                        elem.remove();
3068
                    }
3069
                }).end();
3070
        },
3071
3072
        hide: function (speed, callback) {
3073
            return speed ?
3074
                this.animate({
3075
                    height: "hide", width: "hide", opacity: "hide"
3076
                }, speed, callback) :
3077
3078
                this.filter(":visible").each(function () {
3079
                    this.oldblock = this.oldblock || jQuery.css(this, "display");
3080
                    this.style.display = "none";
3081
                }).end();
3082
        },
3083
3084
        // Save the old toggle function
3085
        _toggle: jQuery.fn.toggle,
3086
3087
        toggle: function (fn, fn2) {
3088
            return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
3089
                this._toggle.apply(this, arguments) :
3090
                fn ?
3091
                    this.animate({
3092
                        height: "toggle", width: "toggle", opacity: "toggle"
3093
                    }, fn, fn2) :
3094
                    this.each(function () {
3095
                        jQuery(this)[jQuery(this).is(":hidden") ? "show" : "hide"]();
3096
                    });
3097
        },
3098
3099
        slideDown: function (speed, callback) {
3100
            return this.animate({height: "show"}, speed, callback);
3101
        },
3102
3103
        slideUp: function (speed, callback) {
3104
            return this.animate({height: "hide"}, speed, callback);
3105
        },
3106
3107
        slideToggle: function (speed, callback) {
3108
            return this.animate({height: "toggle"}, speed, callback);
3109
        },
3110
3111
        fadeIn: function (speed, callback) {
3112
            return this.animate({opacity: "show"}, speed, callback);
3113
        },
3114
3115
        fadeOut: function (speed, callback) {
3116
            return this.animate({opacity: "hide"}, speed, callback);
3117
        },
3118
3119
        fadeTo: function (speed, to, callback) {
3120
            return this.animate({opacity: to}, speed, callback);
3121
        },
3122
3123
        animate: function (prop, speed, easing, callback) {
3124
            var optall = jQuery.speed(speed, easing, callback);
3125
3126
            return this[optall.queue === false ? "each" : "queue"](function () {
3127
                if (this.nodeType != 1)
3128
                    return false;
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...
3129
3130
                var opt = jQuery.extend({}, optall), p,
3131
                    hidden = jQuery(this).is(":hidden"), self = this;
3132
3133
                for (p in prop) {
3134
                    if (prop[p] == "hide" && hidden || prop[p] == "show" && !hidden)
3135
                        return opt.complete.call(this);
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...
3136
3137
                    if (p == "height" || p == "width") {
3138
                        // Store display property
3139
                        opt.display = jQuery.css(this, "display");
3140
3141
                        // Make sure that nothing sneaks out
3142
                        opt.overflow = this.style.overflow;
3143
                    }
3144
                }
3145
3146
                if (opt.overflow != null)
3147
                    this.style.overflow = "hidden";
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...
3148
3149
                opt.curAnim = jQuery.extend({}, prop);
3150
3151
                jQuery.each(prop, function (name, val) {
3152
                    var e = new jQuery.fx(self, opt, name);
3153
3154
                    if (/toggle|show|hide/.test(val))
3155
                        e[val == "toggle" ? hidden ? "show" : "hide" : val](prop);
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...
3156
                    else {
3157
                        var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
3158
                            start = e.cur(true) || 0;
3159
3160
                        if (parts) {
3161
                            var end = parseFloat(parts[2]),
3162
                                unit = parts[3] || "px";
3163
3164
                            // We need to compute starting value
3165
                            if (unit != "px") {
3166
                                self.style[name] = (end || 1) + unit;
3167
                                start = ((end || 1) / e.cur(true)) * start;
3168
                                self.style[name] = start + unit;
3169
                            }
3170
3171
                            // If a +=/-= token was provided, we're doing a relative animation
3172
                            if (parts[1])
3173
                                end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
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...
3174
3175
                            e.custom(start, end, unit);
3176
                        } else
3177
                            e.custom(start, val, "");
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...
3178
                    }
3179
                });
3180
3181
                // For JS strict compliance
3182
                return true;
3183
            });
3184
        },
3185
3186
        queue: function (type, fn) {
3187
            if (jQuery.isFunction(type) || ( type && type.constructor == Array )) {
3188
                fn = type;
3189
                type = "fx";
3190
            }
3191
3192
            if (!type || (typeof type == "string" && !fn))
3193
                return queue(this[0], type);
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...
3194
3195
            return this.each(function () {
3196
                if (fn.constructor == Array)
3197
                    queue(this, type, fn);
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...
3198
                else {
3199
                    queue(this, type).push(fn);
3200
3201
                    if (queue(this, type).length == 1)
3202
                        fn.call(this);
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...
3203
                }
3204
            });
3205
        },
3206
3207
        stop: function (clearQueue, gotoEnd) {
3208
            var timers = jQuery.timers;
3209
3210
            if (clearQueue)
3211
                this.queue([]);
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...
3212
3213
            this.each(function () {
3214
                // go in reverse order so anything added to the queue during the loop is ignored
3215
                for (var i = timers.length - 1; i >= 0; i--)
3216
                    if (timers[i].elem == this) {
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...
3217
                        if (gotoEnd)
3218
                        // force the next step to be the last
3219
                            timers[i](true);
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...
3220
                        timers.splice(i, 1);
3221
                    }
3222
            });
3223
3224
            // start the next in the queue if the last step wasn't forced
3225
            if (!gotoEnd)
3226
                this.dequeue();
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...
3227
3228
            return this;
3229
        }
3230
3231
    });
3232
3233
    var queue = function (elem, type, array) {
3234
        if (elem) {
3235
3236
            type = type || "fx";
3237
3238
            var q = jQuery.data(elem, type + "queue");
3239
3240
            if (!q || array)
3241
                q = jQuery.data(elem, type + "queue", jQuery.makeArray(array));
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...
3242
3243
        }
3244
        return q;
0 ignored issues
show
Bug introduced by
The variable q does not seem to be initialized in case elem on line 3234 is false. Are you sure this can never be the case?
Loading history...
3245
    };
3246
3247
    jQuery.fn.dequeue = function (type) {
3248
        type = type || "fx";
3249
3250
        return this.each(function () {
3251
            var q = queue(this, type);
3252
3253
            q.shift();
3254
3255
            if (q.length)
3256
                q[0].call(this);
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...
3257
        });
3258
    };
3259
3260
    jQuery.extend({
3261
3262
        speed: function (speed, easing, fn) {
3263
            var opt = speed && speed.constructor == Object ? speed : {
3264
                complete: fn || !fn && easing ||
3265
                jQuery.isFunction(speed) && speed,
3266
                duration: speed,
3267
                easing: fn && easing || easing && easing.constructor != Function && easing
3268
            };
3269
3270
            opt.duration = (opt.duration && opt.duration.constructor == Number ?
3271
                    opt.duration :
3272
                    jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
3273
3274
            // Queueing
3275
            opt.old = opt.complete;
3276
            opt.complete = function () {
3277
                if (opt.queue !== false)
3278
                    jQuery(this).dequeue();
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...
3279
                if (jQuery.isFunction(opt.old))
3280
                    opt.old.call(this);
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...
3281
            };
3282
3283
            return opt;
3284
        },
3285
3286
        easing: {
3287
            linear: function (p, n, firstNum, diff) {
3288
                return firstNum + diff * p;
3289
            },
3290
            swing: function (p, n, firstNum, diff) {
3291
                return ((-Math.cos(p * Math.PI) / 2) + 0.5) * diff + firstNum;
3292
            }
3293
        },
3294
3295
        timers: [],
3296
        timerId: null,
3297
3298
        fx: function (elem, options, prop) {
3299
            this.options = options;
3300
            this.elem = elem;
3301
            this.prop = prop;
3302
3303
            if (!options.orig)
3304
                options.orig = {};
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...
3305
        }
3306
3307
    });
3308
3309
    jQuery.fx.prototype = {
3310
3311
        // Simple function for setting a style value
3312
        update: function () {
3313
            if (this.options.step)
3314
                this.options.step.call(this.elem, this.now, this);
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...
3315
3316
            (jQuery.fx.step[this.prop] || jQuery.fx.step._default)(this);
3317
3318
            // Set display property to block for height/width animations
3319
            if (this.prop == "height" || this.prop == "width")
3320
                this.elem.style.display = "block";
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...
3321
        },
3322
3323
        // Get the current size
3324
        cur: function (force) {
3325
            if (this.elem[this.prop] != null && this.elem.style[this.prop] == null)
3326
                return this.elem[this.prop];
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...
3327
3328
            var r = parseFloat(jQuery.css(this.elem, this.prop, force));
3329
            return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
3330
        },
3331
3332
        // Start an animation from one number to another
3333
        custom: function (from, to, unit) {
3334
            this.startTime = now();
3335
            this.start = from;
3336
            this.end = to;
3337
            this.unit = unit || this.unit || "px";
3338
            this.now = this.start;
3339
            this.pos = this.state = 0;
3340
            this.update();
3341
3342
            var self = this;
3343
3344
            function t(gotoEnd) {
3345
                return self.step(gotoEnd);
3346
            }
3347
3348
            t.elem = this.elem;
3349
3350
            jQuery.timers.push(t);
3351
3352
            if (jQuery.timerId == null) {
3353
                jQuery.timerId = setInterval(function () {
3354
                    var timers = jQuery.timers;
3355
3356
                    for (var i = 0; i < timers.length; i++)
3357
                        if (!timers[i]())
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...
3358
                            timers.splice(i--, 1);
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...
Complexity Coding Style introduced by
You seem to be assigning a new value to the loop variable i here. Please check if this was indeed your intention. Even if it was, consider using another kind of loop instead.
Loading history...
3359
3360
                    if (!timers.length) {
3361
                        clearInterval(jQuery.timerId);
3362
                        jQuery.timerId = null;
3363
                    }
3364
                }, 13);
3365
            }
3366
        },
3367
3368
        // Simple 'show' function
3369
        show: function () {
3370
            // Remember where we started, so that we can go back to it later
3371
            this.options.orig[this.prop] = jQuery.attr(this.elem.style, this.prop);
3372
            this.options.show = true;
3373
3374
            // Begin the animation
3375
            this.custom(0, this.cur());
3376
3377
            // Make sure that we start at a small width/height to avoid any
3378
            // flash of content
3379
            if (this.prop == "width" || this.prop == "height")
3380
                this.elem.style[this.prop] = "1px";
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...
3381
3382
            // Start by showing the element
3383
            jQuery(this.elem).show();
3384
        },
3385
3386
        // Simple 'hide' function
3387
        hide: function () {
3388
            // Remember where we started, so that we can go back to it later
3389
            this.options.orig[this.prop] = jQuery.attr(this.elem.style, this.prop);
3390
            this.options.hide = true;
3391
3392
            // Begin the animation
3393
            this.custom(this.cur(), 0);
3394
        },
3395
3396
        // Each step of an animation
3397
        step: function (gotoEnd) {
3398
            var t = now();
3399
3400
            if (gotoEnd || t > this.options.duration + this.startTime) {
3401
                this.now = this.end;
3402
                this.pos = this.state = 1;
3403
                this.update();
3404
3405
                this.options.curAnim[this.prop] = true;
3406
3407
                var done = true;
3408
                for (var i in this.options.curAnim)
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
3409
                    if (this.options.curAnim[i] !== true)
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...
3410
                        done = false;
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...
3411
3412
                if (done) {
3413
                    if (this.options.display != null) {
3414
                        // Reset the overflow
3415
                        this.elem.style.overflow = this.options.overflow;
3416
3417
                        // Reset the display
3418
                        this.elem.style.display = this.options.display;
3419
                        if (jQuery.css(this.elem, "display") == "none")
3420
                            this.elem.style.display = "block";
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...
3421
                    }
3422
3423
                    // Hide the element if the "hide" operation was done
3424
                    if (this.options.hide)
3425
                        this.elem.style.display = "none";
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...
3426
3427
                    // Reset the properties, if the item has been hidden or shown
3428
                    if (this.options.hide || this.options.show)
3429
                        for (var p in this.options.curAnim)
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...
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
3430
                            jQuery.attr(this.elem.style, p, this.options.orig[p]);
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...
3431
                }
3432
3433
                if (done)
3434
                // Execute the complete function
3435
                    this.options.complete.call(this.elem);
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...
3436
3437
                return false;
3438
            } else {
3439
                var n = t - this.startTime;
3440
                this.state = n / this.options.duration;
3441
3442
                // Perform the easing function, defaults to swing
3443
                this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
3444
                this.now = this.start + ((this.end - this.start) * this.pos);
3445
3446
                // Perform the next step of the animation
3447
                this.update();
3448
            }
3449
3450
            return true;
3451
        }
3452
3453
    };
3454
3455
    jQuery.extend(jQuery.fx, {
3456
        speeds: {
3457
            slow: 600,
3458
            fast: 200,
3459
            // Default speed
3460
            def: 400
3461
        },
3462
        step: {
3463
            scrollLeft: function (fx) {
3464
                fx.elem.scrollLeft = fx.now;
3465
            },
3466
3467
            scrollTop: function (fx) {
3468
                fx.elem.scrollTop = fx.now;
3469
            },
3470
3471
            opacity: function (fx) {
3472
                jQuery.attr(fx.elem.style, "opacity", fx.now);
3473
            },
3474
3475
            _default: function (fx) {
3476
                fx.elem.style[fx.prop] = fx.now + fx.unit;
3477
            }
3478
        }
3479
    });
3480
// The Offset Method
3481
// Originally By Brandon Aaron, part of the Dimension Plugin
3482
// http://jquery.com/plugins/project/dimensions
3483
    jQuery.fn.offset = function () {
3484
        var left = 0, top = 0, elem = this[0], results;
3485
3486
        if (elem) with (jQuery.browser) {
0 ignored issues
show
introduced by
This code is unreachable and can thus be removed without consequences.
Loading history...
Comprehensibility Compatibility Best Practice introduced by
The use of the with statement is discouraged as it makes your code harder to understand and may not be forward compatible with newer versions of javascript.
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...
3487
            var parent = elem.parentNode,
3488
                offsetChild = elem,
3489
                offsetParent = elem.offsetParent,
3490
                doc = elem.ownerDocument,
3491
                safari2 = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent),
3492
                css = jQuery.curCSS,
3493
                fixed = css(elem, "position") == "fixed";
3494
3495
            // Use getBoundingClientRect if available
3496
            if (!(mozilla && elem == document.body) && elem.getBoundingClientRect) {
3497
                var box = elem.getBoundingClientRect();
3498
3499
                // Add the document scroll offsets
3500
                add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
3501
                    box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
3502
3503
                // IE adds the HTML element's border, by default it is medium which is 2px
3504
                // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
3505
                // IE 7 standards mode, the border is always 2px
3506
                // This border/offset is typically represented by the clientLeft and clientTop properties
3507
                // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
3508
                // Therefore this method will be off by 2px in IE while in quirksmode
3509
                add(-doc.documentElement.clientLeft, -doc.documentElement.clientTop);
3510
3511
                // Otherwise loop through the offsetParents and parentNodes
3512
            } else {
3513
3514
                // Initial element offsets
3515
                add(elem.offsetLeft, elem.offsetTop);
3516
3517
                // Get parent offsets
3518
                while (offsetParent) {
3519
                    // Add offsetParent offsets
3520
                    add(offsetParent.offsetLeft, offsetParent.offsetTop);
3521
3522
                    // Mozilla and Safari > 2 does not include the border on offset parents
3523
                    // However Mozilla adds the border for table or table cells
3524
                    if (mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2)
3525
                        border(offsetParent);
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...
3526
3527
                    // Add the document scroll offsets if position is fixed on any offsetParent
3528
                    if (!fixed && css(offsetParent, "position") == "fixed")
3529
                        fixed = true;
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...
3530
3531
                    // Set offsetChild to previous offsetParent unless it is the body element
3532
                    offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
3533
                    // Get next offsetParent
3534
                    offsetParent = offsetParent.offsetParent;
3535
                }
3536
3537
                // Get parent scroll offsets
3538
                while (parent && parent.tagName && !/^body|html$/i.test(parent.tagName)) {
3539
                    // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
3540
                    if (!/^inline|table.*$/i.test(css(parent, "display")))
3541
                    // Subtract parent scroll offsets
3542
                        add(-parent.scrollLeft, -parent.scrollTop);
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...
3543
3544
                    // Mozilla does not add the border for a parent that has overflow != visible
3545
                    if (mozilla && css(parent, "overflow") != "visible")
3546
                        border(parent);
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...
3547
3548
                    // Get next parent
3549
                    parent = parent.parentNode;
3550
                }
3551
3552
                // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
3553
                // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
3554
                if ((safari2 && (fixed || css(offsetChild, "position") == "absolute")) ||
3555
                    (mozilla && css(offsetChild, "position") != "absolute"))
3556
                    add(-doc.body.offsetLeft, -doc.body.offsetTop);
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...
3557
3558
                // Add the document scroll offsets if position is fixed
3559
                if (fixed)
3560
                    add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
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...
3561
                        Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
3562
            }
3563
3564
            // Return an object with top and left properties
3565
            results = {top: top, left: left};
3566
        }
3567
3568
        function border(elem) {
3569
            add(jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true));
3570
        }
3571
3572
        function add(l, t) {
3573
            left += parseInt(l, 10) || 0;
3574
            top += parseInt(t, 10) || 0;
3575
        }
3576
3577
        return results;
0 ignored issues
show
Bug introduced by
The variable results does not seem to be initialized in case elem on line 3486 is false. Are you sure this can never be the case?
Loading history...
3578
    };
3579
3580
3581
    jQuery.fn.extend({
3582
        position: function () {
3583
            var left = 0, top = 0, results;
3584
3585
            if (this[0]) {
3586
                // Get *real* offsetParent
3587
                var offsetParent = this.offsetParent(),
3588
3589
                    // Get correct offsets
3590
                    offset = this.offset(),
3591
                    parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? {top: 0, left: 0} : offsetParent.offset();
3592
3593
                // Subtract element margins
3594
                // note: when an element has margin: auto the offsetLeft and marginLeft
3595
                // are the same in Safari causing offset.left to incorrectly be 0
3596
                offset.top -= num(this, 'marginTop');
3597
                offset.left -= num(this, 'marginLeft');
3598
3599
                // Add offsetParent borders
3600
                parentOffset.top += num(offsetParent, 'borderTopWidth');
3601
                parentOffset.left += num(offsetParent, 'borderLeftWidth');
3602
3603
                // Subtract the two offsets
3604
                results = {
3605
                    top: offset.top - parentOffset.top,
3606
                    left: offset.left - parentOffset.left
3607
                };
3608
            }
3609
3610
            return results;
0 ignored issues
show
Bug introduced by
The variable results does not seem to be initialized in case this.0 on line 3585 is false. Are you sure this can never be the case?
Loading history...
3611
        },
3612
3613
        offsetParent: function () {
3614
            var offsetParent = this[0].offsetParent;
3615
            while (offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static'))
3616
                offsetParent = offsetParent.offsetParent;
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...
3617
            return jQuery(offsetParent);
3618
        }
3619
    });
3620
3621
3622
// Create scrollLeft and scrollTop methods
3623
    jQuery.each(['Left', 'Top'], function (i, name) {
3624
        var method = 'scroll' + name;
3625
3626
        jQuery.fn[method] = function (val) {
3627
            if (!this[0]) 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...
3628
3629
            return val != undefined ?
0 ignored issues
show
Bug introduced by
The variable undefined seems to be never initialized.
Loading history...
3630
3631
                // Set the scroll offset
3632
                this.each(function () {
3633
                    this == window || this == document ?
3634
                        window.scrollTo(
3635
                            !i ? val : jQuery(window).scrollLeft(),
3636
                            i ? val : jQuery(window).scrollTop()
3637
                        ) :
3638
                        this[method] = val;
3639
                }) :
3640
3641
                // Return the scroll offset
3642
                this[0] == window || this[0] == document ?
3643
                self[i ? 'pageYOffset' : 'pageXOffset'] ||
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ 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...
3644
                jQuery.boxModel && document.documentElement[method] ||
3645
                document.body[method] :
3646
                    this[0][method];
3647
        };
3648
    });
3649
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
3650
    jQuery.each(["Height", "Width"], function (i, name) {
3651
3652
        var tl = i ? "Left" : "Top",  // top or left
3653
            br = i ? "Right" : "Bottom"; // bottom or right
3654
3655
        // innerHeight and innerWidth
3656
        jQuery.fn["inner" + name] = function () {
3657
            return this[name.toLowerCase()]() +
3658
                num(this, "padding" + tl) +
3659
                num(this, "padding" + br);
3660
        };
3661
3662
        // outerHeight and outerWidth
3663
        jQuery.fn["outer" + name] = function (margin) {
3664
            return this["inner" + name]() +
3665
                num(this, "border" + tl + "Width") +
3666
                num(this, "border" + br + "Width") +
3667
                (margin ?
3668
                num(this, "margin" + tl) + num(this, "margin" + br) : 0);
3669
        };
3670
3671
    });
3672
})();
3673