")
// inject the contents of the document in, removing the scripts
// to avoid any 'Permission Denied' errors in IE
.append(responseText.replace(rscript, ""))
// Locate the specified elements
.find(selector) :
// If not, just inject the full result
responseText);
}
if (callback) {
self.each(callback, [responseText, status, jqXHR]);
}
}
});
return this;
};
jQuery.prototype.map = function (callback) {
///
/// Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
///
///
/// A function object that will be invoked for each element in the current set.
///
///
return this.pushStack(jQuery.map(this, function (elem, i) {
return callback.call(elem, i, elem);
}));
};
jQuery.prototype.mousedown = function (data, fn) {
///
/// Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element.
/// 1 - mousedown(handler(eventObject))
/// 2 - mousedown(eventData, handler(eventObject))
/// 3 - mousedown()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.mouseenter = function (data, fn) {
///
/// Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element.
/// 1 - mouseenter(handler(eventObject))
/// 2 - mouseenter(eventData, handler(eventObject))
/// 3 - mouseenter()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.mouseleave = function (data, fn) {
///
/// Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element.
/// 1 - mouseleave(handler(eventObject))
/// 2 - mouseleave(eventData, handler(eventObject))
/// 3 - mouseleave()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.mousemove = function (data, fn) {
///
/// Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element.
/// 1 - mousemove(handler(eventObject))
/// 2 - mousemove(eventData, handler(eventObject))
/// 3 - mousemove()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.mouseout = function (data, fn) {
///
/// Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element.
/// 1 - mouseout(handler(eventObject))
/// 2 - mouseout(eventData, handler(eventObject))
/// 3 - mouseout()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.mouseover = function (data, fn) {
///
/// Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element.
/// 1 - mouseover(handler(eventObject))
/// 2 - mouseover(eventData, handler(eventObject))
/// 3 - mouseover()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.mouseup = function (data, fn) {
///
/// Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element.
/// 1 - mouseup(handler(eventObject))
/// 2 - mouseup(eventData, handler(eventObject))
/// 3 - mouseup()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.next = function (until, selector) {
///
/// Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
///
///
/// A string containing a selector expression to match elements against.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.nextAll = function (until, selector) {
///
/// Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
///
///
/// A string containing a selector expression to match elements against.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.nextUntil = function (until, selector) {
///
/// Get all following siblings of each element up to but not including the element matched by the selector.
///
///
/// A string containing a selector expression to indicate where to stop matching following sibling elements.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.not = function (selector) {
///
/// Remove elements from the set of matched elements.
/// 1 - not(selector)
/// 2 - not(elements)
/// 3 - not(function(index))
///
///
/// A string containing a selector expression to match elements against.
///
///
return this.pushStack(winnow(this, selector, false), "not", selector);
};
jQuery.prototype.offset = function (options) {
///
/// 1: Get the current coordinates of the first element in the set of matched elements, relative to the document.
/// 1.1 - offset()
/// 2: Set the current coordinates of every element in the set of matched elements, relative to the document.
/// 2.1 - offset(coordinates)
/// 2.2 - offset(function(index, coords))
///
///
/// An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
///
///
var elem = this[0], box;
if (options) {
return this.each(function (i) {
jQuery.offset.setOffset(this, options, i);
});
}
if (!elem || !elem.ownerDocument) {
return null;
}
if (elem === elem.ownerDocument.body) {
return jQuery.offset.bodyOffset(elem);
}
try {
box = elem.getBoundingClientRect();
} catch (e) { }
var doc = elem.ownerDocument,
docElem = doc.documentElement;
// Make sure we're not dealing with a disconnected DOM node
if (!box || !jQuery.contains(docElem, elem)) {
return box ? { top: box.top, left: box.left} : { top: 0, left: 0 };
}
var body = doc.body,
win = getWindow(doc),
clientTop = docElem.clientTop || body.clientTop || 0,
clientLeft = docElem.clientLeft || body.clientLeft || 0,
scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop),
scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
top = box.top + scrollTop - clientTop,
left = box.left + scrollLeft - clientLeft;
return { top: top, left: left };
};
jQuery.prototype.offsetParent = function () {
///
/// Get the closest ancestor element that is positioned.
///
///
return this.map(function () {
var offsetParent = this.offsetParent || document.body;
while (offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static")) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent;
});
};
jQuery.prototype.one = function (type, data, fn) {
///
/// Attach a handler to an event for the elements. The handler is executed at most once per element.
///
///
/// A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute at the time the event is triggered.
///
///
// Handle object literals
if (typeof type === "object") {
for (var key in type) {
this[name](key, data, type[key], fn);
}
return this;
}
if (jQuery.isFunction(data) || data === false) {
fn = data;
data = undefined;
}
var handler = name === "one" ? jQuery.proxy(fn, function (event) {
jQuery(this).unbind(event, handler);
return fn.apply(this, arguments);
}) : fn;
if (type === "unload" && name !== "one") {
this.one(type, data, fn);
} else {
for (var i = 0, l = this.length; i < l; i++) {
jQuery.event.add(this[i], type, handler, data);
}
}
return this;
};
jQuery.prototype.outerHeight = function (margin) {
///
/// Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin.
///
///
/// A Boolean indicating whether to include the element's margin in the calculation.
///
///
return this[0] ?
parseFloat(jQuery.css(this[0], type, margin ? "margin" : "border")) :
null;
};
jQuery.prototype.outerWidth = function (margin) {
///
/// Get the current computed width for the first element in the set of matched elements, including padding and border.
///
///
/// A Boolean indicating whether to include the element's margin in the calculation.
///
///
return this[0] ?
parseFloat(jQuery.css(this[0], type, margin ? "margin" : "border")) :
null;
};
jQuery.prototype.parent = function (until, selector) {
///
/// Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
///
///
/// A string containing a selector expression to match elements against.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.parents = function (until, selector) {
///
/// Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
///
///
/// A string containing a selector expression to match elements against.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.parentsUntil = function (until, selector) {
///
/// Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector.
///
///
/// A string containing a selector expression to indicate where to stop matching ancestor elements.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.position = function () {
///
/// Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
///
///
if (!this[0]) {
return null;
}
var elem = this[0],
// Get *real* offsetParent
offsetParent = this.offsetParent(),
// Get correct offsets
offset = this.offset(),
parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0} : offsetParent.offset();
// Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0
offset.top -= parseFloat(jQuery.css(elem, "marginTop")) || 0;
offset.left -= parseFloat(jQuery.css(elem, "marginLeft")) || 0;
// Add offsetParent borders
parentOffset.top += parseFloat(jQuery.css(offsetParent[0], "borderTopWidth")) || 0;
parentOffset.left += parseFloat(jQuery.css(offsetParent[0], "borderLeftWidth")) || 0;
// Subtract the two offsets
return {
top: offset.top - parentOffset.top,
left: offset.left - parentOffset.left
};
};
jQuery.prototype.prepend = function () {
///
/// Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
/// 1 - prepend(content, content)
/// 2 - prepend(function(index, html))
///
///
/// DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements.
///
///
/// One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements.
///
///
return this.domManip(arguments, true, function (elem) {
if (this.nodeType === 1) {
this.insertBefore(elem, this.firstChild);
}
});
};
jQuery.prototype.prependTo = function (selector) {
///
/// Insert every element in the set of matched elements to the beginning of the target.
///
///
/// A selector, element, HTML string, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter.
///
///
var ret = [],
insert = jQuery(selector),
parent = this.length === 1 && this[0].parentNode;
if (parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1) {
insert[original](this[0]);
return this;
} else {
for (var i = 0, l = insert.length; i < l; i++) {
var elems = (i > 0 ? this.clone(true) : this).get();
jQuery(insert[i])[original](elems);
ret = ret.concat(elems);
}
return this.pushStack(ret, name, insert.selector);
}
};
jQuery.prototype.prev = function (until, selector) {
///
/// Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.
///
///
/// A string containing a selector expression to match elements against.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.prevAll = function (until, selector) {
///
/// Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
///
///
/// A string containing a selector expression to match elements against.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.prevUntil = function (until, selector) {
///
/// Get all preceding siblings of each element up to but not including the element matched by the selector.
///
///
/// A string containing a selector expression to indicate where to stop matching preceding sibling elements.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.pushStack = function (elems, name, selector) {
///
/// Add a collection of DOM elements onto the jQuery stack.
/// 1 - pushStack(elements)
/// 2 - pushStack(elements, name, arguments)
///
///
/// An array of elements to push onto the stack and make into a new jQuery object.
///
///
/// The name of a jQuery method that generated the array of elements.
///
///
/// The arguments that were passed in to the jQuery method (for serialization).
///
///
// Build a new jQuery matched element set
var ret = this.constructor();
if (jQuery.isArray(elems)) {
push.apply(ret, elems);
} else {
jQuery.merge(ret, elems);
}
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
ret.context = this.context;
if (name === "find") {
ret.selector = this.selector + (this.selector ? " " : "") + selector;
} else if (name) {
ret.selector = this.selector + "." + name + "(" + selector + ")";
}
// Return the newly-formed element set
return ret;
};
jQuery.prototype.queue = function (type, data) {
///
/// 1: Show the queue of functions to be executed on the matched elements.
/// 1.1 - queue(queueName)
/// 2: Manipulate the queue of functions to be executed on the matched elements.
/// 2.1 - queue(queueName, newQueue)
/// 2.2 - queue(queueName, callback( next ))
///
///
/// A string containing the name of the queue. Defaults to fx, the standard effects queue.
///
///
/// An array of functions to replace the current queue contents.
///
///
if (typeof type !== "string") {
data = type;
type = "fx";
}
if (data === undefined) {
return jQuery.queue(this[0], type);
}
return this.each(function (i) {
var queue = jQuery.queue(this, type, data);
if (type === "fx" && queue[0] !== "inprogress") {
jQuery.dequeue(this, type);
}
});
};
jQuery.prototype.ready = function (fn) {
///
/// Specify a function to execute when the DOM is fully loaded.
///
///
/// A function to execute after the DOM is ready.
///
///
// Attach the listeners
jQuery.bindReady();
// Add the callback
readyList.done(fn);
return this;
};
jQuery.prototype.remove = function (selector, keepData) {
///
/// Remove the set of matched elements from the DOM.
///
///
/// A selector expression that filters the set of matched elements to be removed.
///
///
for (var i = 0, elem; (elem = this[i]) != null; i++) {
if (!selector || jQuery.filter(selector, [elem]).length) {
if (!keepData && elem.nodeType === 1) {
jQuery.cleanData(elem.getElementsByTagName("*"));
jQuery.cleanData([elem]);
}
if (elem.parentNode) {
elem.parentNode.removeChild(elem);
}
}
}
return this;
};
jQuery.prototype.removeAttr = function (name, fn) {
///
/// Remove an attribute from each element in the set of matched elements.
///
///
/// An attribute to remove.
///
///
return this.each(function () {
jQuery.attr(this, name, "");
if (this.nodeType === 1) {
this.removeAttribute(name);
}
});
};
jQuery.prototype.removeClass = function (value) {
///
/// Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
/// 1 - removeClass(className)
/// 2 - removeClass(function(index, class))
///
///
/// A class name to be removed from the class attribute of each matched element.
///
///
if (jQuery.isFunction(value)) {
return this.each(function (i) {
var self = jQuery(this);
self.removeClass(value.call(this, i, self.attr("class")));
});
}
if ((value && typeof value === "string") || value === undefined) {
var classNames = (value || "").split(rspaces);
for (var i = 0, l = this.length; i < l; i++) {
var elem = this[i];
if (elem.nodeType === 1 && elem.className) {
if (value) {
var className = (" " + elem.className + " ").replace(rclass, " ");
for (var c = 0, cl = classNames.length; c < cl; c++) {
className = className.replace(" " + classNames[c] + " ", " ");
}
elem.className = jQuery.trim(className);
} else {
elem.className = "";
}
}
}
}
return this;
};
jQuery.prototype.removeData = function (key) {
///
/// Remove a previously-stored piece of data.
///
///
/// A string naming the piece of data to delete.
///
///
return this.each(function () {
jQuery.removeData(this, key);
});
};
jQuery.prototype.replaceAll = function (selector) {
///
/// Replace each target element with the set of matched elements.
///
///
/// A selector expression indicating which element(s) to replace.
///
///
var ret = [],
insert = jQuery(selector),
parent = this.length === 1 && this[0].parentNode;
if (parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1) {
insert[original](this[0]);
return this;
} else {
for (var i = 0, l = insert.length; i < l; i++) {
var elems = (i > 0 ? this.clone(true) : this).get();
jQuery(insert[i])[original](elems);
ret = ret.concat(elems);
}
return this.pushStack(ret, name, insert.selector);
}
};
jQuery.prototype.replaceWith = function (value) {
///
/// Replace each element in the set of matched elements with the provided new content.
/// 1 - replaceWith(newContent)
/// 2 - replaceWith(function)
///
///
/// The content to insert. May be an HTML string, DOM element, or jQuery object.
///
///
if (this[0] && this[0].parentNode) {
// Make sure that the elements are removed from the DOM before they are inserted
// this can help fix replacing a parent with child elements
if (jQuery.isFunction(value)) {
return this.each(function (i) {
var self = jQuery(this), old = self.html();
self.replaceWith(value.call(this, i, old));
});
}
if (typeof value !== "string") {
value = jQuery(value).detach();
}
return this.each(function () {
var next = this.nextSibling,
parent = this.parentNode;
jQuery(this).remove();
if (next) {
jQuery(next).before(value);
} else {
jQuery(parent).append(value);
}
});
} else {
return this.pushStack(jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value);
}
};
jQuery.prototype.resize = function (data, fn) {
///
/// Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.
/// 1 - resize(handler(eventObject))
/// 2 - resize(eventData, handler(eventObject))
/// 3 - resize()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.scroll = function (data, fn) {
///
/// Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element.
/// 1 - scroll(handler(eventObject))
/// 2 - scroll(eventData, handler(eventObject))
/// 3 - scroll()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.scrollLeft = function (val) {
///
/// 1: Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
/// 1.1 - scrollLeft()
/// 2: Set the current horizontal position of the scroll bar for each of the set of matched elements.
/// 2.1 - scrollLeft(value)
///
///
/// An integer indicating the new position to set the scroll bar to.
///
///
var elem = this[0], win;
if (!elem) {
return null;
}
if (val !== undefined) {
// Set the scroll offset
return this.each(function () {
win = getWindow(this);
if (win) {
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
i ? val : jQuery(win).scrollTop()
);
} else {
this[method] = val;
}
});
} else {
win = getWindow(elem);
// Return the scroll offset
return win ? ("pageXOffset" in win) ? win[i ? "pageYOffset" : "pageXOffset"] :
jQuery.support.boxModel && win.document.documentElement[method] ||
win.document.body[method] :
elem[method];
}
};
jQuery.prototype.scrollTop = function (val) {
///
/// 1: Get the current vertical position of the scroll bar for the first element in the set of matched elements.
/// 1.1 - scrollTop()
/// 2: Set the current vertical position of the scroll bar for each of the set of matched elements.
/// 2.1 - scrollTop(value)
///
///
/// An integer indicating the new position to set the scroll bar to.
///
///
var elem = this[0], win;
if (!elem) {
return null;
}
if (val !== undefined) {
// Set the scroll offset
return this.each(function () {
win = getWindow(this);
if (win) {
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
i ? val : jQuery(win).scrollTop()
);
} else {
this[method] = val;
}
});
} else {
win = getWindow(elem);
// Return the scroll offset
return win ? ("pageXOffset" in win) ? win[i ? "pageYOffset" : "pageXOffset"] :
jQuery.support.boxModel && win.document.documentElement[method] ||
win.document.body[method] :
elem[method];
}
};
jQuery.prototype.select = function (data, fn) {
///
/// Bind an event handler to the "select" JavaScript event, or trigger that event on an element.
/// 1 - select(handler(eventObject))
/// 2 - select(eventData, handler(eventObject))
/// 3 - select()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.serialize = function () {
///
/// Encode a set of form elements as a string for submission.
///
///
return jQuery.param(this.serializeArray());
};
jQuery.prototype.serializeArray = function () {
///
/// Encode a set of form elements as an array of names and values.
///
///
return this.map(function () {
return this.elements ? jQuery.makeArray(this.elements) : this;
})
.filter(function () {
return this.name && !this.disabled &&
(this.checked || rselectTextarea.test(this.nodeName) ||
rinput.test(this.type));
})
.map(function (i, elem) {
var val = jQuery(this).val();
return val == null ?
null :
jQuery.isArray(val) ?
jQuery.map(val, function (val, i) {
return { name: elem.name, value: val.replace(rCRLF, "\r\n") };
}) :
{ name: elem.name, value: val.replace(rCRLF, "\r\n") };
}).get();
};
jQuery.prototype.show = function (speed, easing, callback) {
///
/// Display the matched elements.
/// 1 - show()
/// 2 - show(duration, callback)
/// 3 - show(duration, easing, callback)
///
///
/// A string or number determining how long the animation will run.
///
///
/// A string indicating which easing function to use for the transition.
///
///
/// A function to call once the animation is complete.
///
///
var elem, display;
if (speed || speed === 0) {
return this.animate(genFx("show", 3), speed, easing, callback);
} else {
for (var i = 0, j = this.length; i < j; i++) {
elem = this[i];
display = elem.style.display;
// Reset the inline display of this element to learn if it is
// being hidden by cascaded rules or not
if (!jQuery._data(elem, "olddisplay") && display === "none") {
display = elem.style.display = "";
}
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// for such an element
if (display === "" && jQuery.css(elem, "display") === "none") {
jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
}
}
// Set the display of most of the elements in a second loop
// to avoid the constant reflow
for (i = 0; i < j; i++) {
elem = this[i];
display = elem.style.display;
if (display === "" || display === "none") {
elem.style.display = jQuery._data(elem, "olddisplay") || "";
}
}
return this;
}
};
jQuery.prototype.siblings = function (until, selector) {
///
/// Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
///
///
/// A string containing a selector expression to match elements against.
///
///
var ret = jQuery.map(this, fn, until),
// The variable 'args' was introduced in
// https://github.com/jquery/jquery/commit/52a0238
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
// http://code.google.com/p/v8/issues/detail?id=1050
args = slice.call(arguments);
if (!runtil.test(name)) {
selector = until;
}
if (selector && typeof selector === "string") {
ret = jQuery.filter(selector, ret);
}
ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
ret = ret.reverse();
}
return this.pushStack(ret, name, args.join(","));
};
jQuery.prototype.size = function () {
///
/// Return the number of elements in the jQuery object.
///
///
return this.length;
};
jQuery.prototype.slice = function () {
///
/// Reduce the set of matched elements to a subset specified by a range of indices.
///
///
/// An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set.
///
///
/// An integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set.
///
///
return this.pushStack(slice.apply(this, arguments),
"slice", slice.call(arguments).join(","));
};
jQuery.prototype.slideDown = function (speed, easing, callback) {
///
/// Display the matched elements with a sliding motion.
/// 1 - slideDown(duration, callback)
/// 2 - slideDown(duration, easing, callback)
///
///
/// A string or number determining how long the animation will run.
///
///
/// A string indicating which easing function to use for the transition.
///
///
/// A function to call once the animation is complete.
///
///
return this.animate(props, speed, easing, callback);
};
jQuery.prototype.slideToggle = function (speed, easing, callback) {
///
/// Display or hide the matched elements with a sliding motion.
/// 1 - slideToggle(duration, callback)
/// 2 - slideToggle(duration, easing, callback)
///
///
/// A string or number determining how long the animation will run.
///
///
/// A string indicating which easing function to use for the transition.
///
///
/// A function to call once the animation is complete.
///
///
return this.animate(props, speed, easing, callback);
};
jQuery.prototype.slideUp = function (speed, easing, callback) {
///
/// Hide the matched elements with a sliding motion.
/// 1 - slideUp(duration, callback)
/// 2 - slideUp(duration, easing, callback)
///
///
/// A string or number determining how long the animation will run.
///
///
/// A string indicating which easing function to use for the transition.
///
///
/// A function to call once the animation is complete.
///
///
return this.animate(props, speed, easing, callback);
};
jQuery.prototype.stop = function (clearQueue, gotoEnd) {
///
/// Stop the currently-running animation on the matched elements.
///
///
/// A Boolean indicating whether to remove queued animation as well. Defaults to false.
///
///
/// A Boolean indicating whether to complete the current animation immediately. Defaults to false.
///
///
var timers = jQuery.timers;
if (clearQueue) {
this.queue([]);
}
this.each(function () {
// go in reverse order so anything added to the queue during the loop is ignored
for (var i = timers.length - 1; i >= 0; i--) {
if (timers[i].elem === this) {
if (gotoEnd) {
// force the next step to be the last
timers[i](true);
}
timers.splice(i, 1);
}
}
});
// start the next in the queue if the last step wasn't forced
if (!gotoEnd) {
this.dequeue();
}
return this;
};
jQuery.prototype.submit = function (data, fn) {
///
/// Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.
/// 1 - submit(handler(eventObject))
/// 2 - submit(eventData, handler(eventObject))
/// 3 - submit()
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.text = function (text) {
///
/// 1: Get the combined text contents of each element in the set of matched elements, including their descendants.
/// 1.1 - text()
/// 2: Set the content of each element in the set of matched elements to the specified text.
/// 2.1 - text(textString)
/// 2.2 - text(function(index, text))
///
///
/// A string of text to set as the content of each matched element.
///
///
if (jQuery.isFunction(text)) {
return this.each(function (i) {
var self = jQuery(this);
self.text(text.call(this, i, self.text()));
});
}
if (typeof text !== "object" && text !== undefined) {
return this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(text));
}
return jQuery.text(this);
};
jQuery.prototype.toArray = function () {
///
/// Retrieve all the DOM elements contained in the jQuery set, as an array.
///
///
return slice.call(this, 0);
};
jQuery.prototype.toggle = function (fn, fn2, callback) {
///
/// 1: Bind two or more handlers to the matched elements, to be executed on alternate clicks.
/// 1.1 - toggle(handler(eventObject), handler(eventObject), handler(eventObject))
/// 2: Display or hide the matched elements.
/// 2.1 - toggle(duration, callback)
/// 2.2 - toggle(duration, easing, callback)
/// 2.3 - toggle(showOrHide)
///
///
/// A function to execute every even time the element is clicked.
///
///
/// A function to execute every odd time the element is clicked.
///
///
/// Additional handlers to cycle through after clicks.
///
///
var bool = typeof fn === "boolean";
if (jQuery.isFunction(fn) && jQuery.isFunction(fn2)) {
this._toggle.apply(this, arguments);
} else if (fn == null || bool) {
this.each(function () {
var state = bool ? fn : jQuery(this).is(":hidden");
jQuery(this)[state ? "show" : "hide"]();
});
} else {
this.animate(genFx("toggle", 3), fn, fn2, callback);
}
return this;
};
jQuery.prototype.toggleClass = function (value, stateVal) {
///
/// Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
/// 1 - toggleClass(className)
/// 2 - toggleClass(className, switch)
/// 3 - toggleClass(function(index, class), switch)
///
///
/// One or more class names (separated by spaces) to be toggled for each element in the matched set.
///
///
/// A boolean value to determine whether the class should be added or removed.
///
///
var type = typeof value,
isBool = typeof stateVal === "boolean";
if (jQuery.isFunction(value)) {
return this.each(function (i) {
var self = jQuery(this);
self.toggleClass(value.call(this, i, self.attr("class"), stateVal), stateVal);
});
}
return this.each(function () {
if (type === "string") {
// toggle individual class names
var className,
i = 0,
self = jQuery(this),
state = stateVal,
classNames = value.split(rspaces);
while ((className = classNames[i++])) {
// check each className given, space seperated list
state = isBool ? state : !self.hasClass(className);
self[state ? "addClass" : "removeClass"](className);
}
} else if (type === "undefined" || type === "boolean") {
if (this.className) {
// store className if set
jQuery._data(this, "__className__", this.className);
}
// toggle whole className
this.className = this.className || value === false ? "" : jQuery._data(this, "__className__") || "";
}
});
};
jQuery.prototype.trigger = function (type, data) {
///
/// Execute all handlers and behaviors attached to the matched elements for the given event type.
/// 1 - trigger(eventType, extraParameters)
/// 2 - trigger(event)
///
///
/// A string containing a JavaScript event type, such as click or submit.
///
///
/// An array of additional parameters to pass along to the event handler.
///
///
return this.each(function () {
jQuery.event.trigger(type, data, this);
});
};
jQuery.prototype.triggerHandler = function (type, data) {
///
/// Execute all handlers attached to an element for an event.
///
///
/// A string containing a JavaScript event type, such as click or submit.
///
///
/// An array of additional parameters to pass along to the event handler.
///
///
if (this[0]) {
var event = jQuery.Event(type);
event.preventDefault();
event.stopPropagation();
jQuery.event.trigger(event, data, this[0]);
return event.result;
}
};
jQuery.prototype.unbind = function (type, fn) {
///
/// Remove a previously-attached event handler from the elements.
/// 1 - unbind(eventType, handler(eventObject))
/// 2 - unbind(eventType, false)
/// 3 - unbind(event)
///
///
/// A string containing a JavaScript event type, such as click or submit.
///
///
/// The function that is to be no longer executed.
///
///
// Handle object literals
if (typeof type === "object" && !type.preventDefault) {
for (var key in type) {
this.unbind(key, type[key]);
}
} else {
for (var i = 0, l = this.length; i < l; i++) {
jQuery.event.remove(this[i], type, fn);
}
}
return this;
};
jQuery.prototype.undelegate = function (selector, types, fn) {
///
/// Remove a handler from the event for all elements which match the current selector, now or in the future, based upon a specific set of root elements.
/// 1 - undelegate()
/// 2 - undelegate(selector, eventType)
/// 3 - undelegate(selector, eventType, handler)
///
///
/// A selector which will be used to filter the event results.
///
///
/// A string containing a JavaScript event type, such as "click" or "keydown"
///
///
/// A function to execute at the time the event is triggered.
///
///
if (arguments.length === 0) {
return this.unbind("live");
} else {
return this.die(types, null, fn, selector);
}
};
jQuery.prototype.unload = function (data, fn) {
///
/// Bind an event handler to the "unload" JavaScript event.
/// 1 - unload(handler(eventObject))
/// 2 - unload(eventData, handler(eventObject))
///
///
/// A map of data that will be passed to the event handler.
///
///
/// A function to execute each time the event is triggered.
///
///
if (fn == null) {
fn = data;
data = null;
}
return arguments.length > 0 ?
this.bind(name, data, fn) :
this.trigger(name);
};
jQuery.prototype.unwrap = function () {
///
/// Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
///
///
return this.parent().each(function () {
if (!jQuery.nodeName(this, "body")) {
jQuery(this).replaceWith(this.childNodes);
}
}).end();
};
jQuery.prototype.val = function (value) {
///
/// 1: Get the current value of the first element in the set of matched elements.
/// 1.1 - val()
/// 2: Set the value of each element in the set of matched elements.
/// 2.1 - val(value)
/// 2.2 - val(function(index, value))
///
///
/// A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked.
///
///
if (!arguments.length) {
var elem = this[0];
if (elem) {
if (jQuery.nodeName(elem, "option")) {
// attributes.value is undefined in Blackberry 4.7 but
// uses .value. See #6932
var val = elem.attributes.value;
return !val || val.specified ? elem.value : elem.text;
}
// We need to handle select boxes special
if (jQuery.nodeName(elem, "select")) {
var index = elem.selectedIndex,
values = [],
options = elem.options,
one = elem.type === "select-one";
// Nothing was selected
if (index < 0) {
return null;
}
// Loop through all the selected options
for (var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++) {
var option = options[i];
// Don't return options that are disabled or in a disabled optgroup
if (option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
(!option.parentNode.disabled || !jQuery.nodeName(option.parentNode, "optgroup"))) {
// Get the specific value for the option
value = jQuery(option).val();
// We don't need an array for one selects
if (one) {
return value;
}
// Multi-Selects return an array
values.push(value);
}
}
// Fixes Bug #2551 -- select.val() broken in IE after form.reset()
if (one && !values.length && options.length) {
return jQuery(options[index]).val();
}
return values;
}
// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
if (rradiocheck.test(elem.type) && !jQuery.support.checkOn) {
return elem.getAttribute("value") === null ? "on" : elem.value;
}
// Everything else, we just grab the value
return (elem.value || "").replace(rreturn, "");
}
return undefined;
}
var isFunction = jQuery.isFunction(value);
return this.each(function (i) {
var self = jQuery(this), val = value;
if (this.nodeType !== 1) {
return;
}
if (isFunction) {
val = value.call(this, i, self.val());
}
// Treat null/undefined as ""; convert numbers to string
if (val == null) {
val = "";
} else if (typeof val === "number") {
val += "";
} else if (jQuery.isArray(val)) {
val = jQuery.map(val, function (value) {
return value == null ? "" : value + "";
});
}
if (jQuery.isArray(val) && rradiocheck.test(this.type)) {
this.checked = jQuery.inArray(self.val(), val) >= 0;
} else if (jQuery.nodeName(this, "select")) {
var values = jQuery.makeArray(val);
jQuery("option", this).each(function () {
this.selected = jQuery.inArray(jQuery(this).val(), values) >= 0;
});
if (!values.length) {
this.selectedIndex = -1;
}
} else {
this.value = val;
}
});
};
jQuery.prototype.width = function (size) {
///
/// 1: Get the current computed width for the first element in the set of matched elements.
/// 1.1 - width()
/// 2: Set the CSS width of each element in the set of matched elements.
/// 2.1 - width(value)
/// 2.2 - width(function(index, width))
///
///
/// An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
///
///
// Get window width or height
var elem = this[0];
if (!elem) {
return size == null ? null : this;
}
if (jQuery.isFunction(size)) {
return this.each(function (i) {
var self = jQuery(this);
self[type](size.call(this, i, self[type]()));
});
}
if (jQuery.isWindow(elem)) {
// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
// 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
var docElemProp = elem.document.documentElement["client" + name];
return elem.document.compatMode === "CSS1Compat" && docElemProp ||
elem.document.body["client" + name] || docElemProp;
// Get document width or height
} else if (elem.nodeType === 9) {
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
return Math.max(
elem.documentElement["client" + name],
elem.body["scroll" + name], elem.documentElement["scroll" + name],
elem.body["offset" + name], elem.documentElement["offset" + name]
);
// Get or set width or height on the element
} else if (size === undefined) {
var orig = jQuery.css(elem, type),
ret = parseFloat(orig);
return jQuery.isNaN(ret) ? orig : ret;
// Set the width or height on the element (default to pixels if value is unitless)
} else {
return this.css(type, typeof size === "string" ? size : size + "px");
}
};
jQuery.prototype.wrap = function (html) {
///
/// Wrap an HTML structure around each element in the set of matched elements.
/// 1 - wrap(wrappingElement)
/// 2 - wrap(wrappingFunction)
///
///
/// An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the matched elements.
///
///
return this.each(function () {
jQuery(this).wrapAll(html);
});
};
jQuery.prototype.wrapAll = function (html) {
///
/// Wrap an HTML structure around all elements in the set of matched elements.
///
///
/// An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the matched elements.
///
///
if (jQuery.isFunction(html)) {
return this.each(function (i) {
jQuery(this).wrapAll(html.call(this, i));
});
}
if (this[0]) {
// The elements to wrap the target around
var wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true);
if (this[0].parentNode) {
wrap.insertBefore(this[0]);
}
wrap.map(function () {
var elem = this;
while (elem.firstChild && elem.firstChild.nodeType === 1) {
elem = elem.firstChild;
}
return elem;
}).append(this);
}
return this;
};
jQuery.prototype.wrapInner = function (html) {
///
/// Wrap an HTML structure around the content of each element in the set of matched elements.
/// 1 - wrapInner(wrappingElement)
/// 2 - wrapInner(wrappingFunction)
///
///
/// An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements.
///
///
if (jQuery.isFunction(html)) {
return this.each(function (i) {
jQuery(this).wrapInner(html.call(this, i));
});
}
return this.each(function () {
var self = jQuery(this),
contents = self.contents();
if (contents.length) {
contents.wrapAll(html);
} else {
self.append(html);
}
});
};
jQuery.fn = jQuery.prototype;
jQuery.fn.init.prototype = jQuery.fn;
window.jQuery = window.$ = jQuery;
})(window);