/*! * jquery javascript library v1.8.3 * http://jquery.com/ * * includes sizzle.js * http://sizzlejs.com/ * * copyright 2012 jquery foundation and other contributors * released under the mit license * http://jquery.org/license * * date: tue nov 13 2012 08:20:33 gmt-0500 (eastern standard time) */ (function (window, undefined) { var // a central reference to the root jquery(document) rootjquery, // the deferred used on dom ready readylist, // use the correct document accordingly with window argument (sandbox) document = window.document, location = window.location, navigator = window.navigator, // map over jquery in case of overwrite _jquery = window.jquery, // map over the $ in case of overwrite _$ = window.$, // save a reference to some core methods core_push = array.prototype.push, core_slice = array.prototype.slice, core_indexof = array.prototype.indexof, core_tostring = object.prototype.tostring, core_hasown = object.prototype.hasownproperty, core_trim = string.prototype.trim, // define a local copy of jquery jquery = function (selector, context) { // the jquery object is actually just the init constructor 'enhanced' return new jquery.fn.init(selector, context, rootjquery); }, // used for matching numbers core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[ee][\-+]?\d+|)/.source, // used for detecting and trimming whitespace core_rnotwhite = /\s/, core_rspace = /\s+/, // make sure we trim bom and nbsp (here's looking at you, safari 5.0 and ie) rtrim = /^[\s\ufeff\xa0]+|[\s\ufeff\xa0]+$/g, // a simple way to check for html strings // prioritize #id over to avoid xss via location.hash (#9521) rquickexpr = /^(?:[^#<]*(<[\w\w]+>)[^>]*$|#([\w\-]*)$)/, // match a standalone tag rsingletag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, // json regexp rvalidchars = /^[\],:{}\s]*$/, rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fa-f]{4})/g, rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[ee][\-+]?\d+|)/g, // matches dashed string for camelizing rmsprefix = /^-ms-/, rdashalpha = /-([\da-z])/gi, // used by jquery.camelcase as callback to replace() fcamelcase = function (all, letter) { return (letter + "").touppercase(); }, // the ready event handler and self cleanup method domcontentloaded = function () { if (document.addeventlistener) { document.removeeventlistener("domcontentloaded", domcontentloaded, false); jquery.ready(); } else if (document.readystate === "complete") { // we're here because readystate === "complete" in oldie // which is good enough for us to call the dom ready! document.detachevent("onreadystatechange", domcontentloaded); jquery.ready(); } }, // [[class]] -> type pairs class2type = {}; jquery.fn = jquery.prototype = { constructor: jquery, init: function (selector, context, rootjquery) { var match, elem, ret, doc; // handle $(""), $(null), $(undefined), $(false) if (!selector) { return this; } // handle $(domelement) if (selector.nodetype) { this.context = this[0] = selector; this.length = 1; return this; } // handle html strings if (typeof selector === "string") { if (selector.charat(0) === "<" && selector.charat(selector.length - 1) === ">" && selector.length >= 3) { // assume that strings that start and end with <> are html and skip the regex check match = [null, selector, null]; } else { match = rquickexpr.exec(selector); } // match html or make sure no context is specified for #id if (match && (match[1] || !context)) { // handle: $(html) -> $(array) if (match[1]) { context = context instanceof jquery ? context[0] : context; doc = (context && context.nodetype ? context.ownerdocument || context : document); // scripts is true for back-compat selector = jquery.parsehtml(match[1], doc, true); if (rsingletag.test(match[1]) && jquery.isplainobject(context)) { this.attr.call(selector, context, true); } return jquery.merge(this, selector); // handle: $(#id) } else { elem = document.getelementbyid(match[2]); // check parentnode to catch when blackberry 4.6 returns // nodes that are no longer in the document #6963 if (elem && elem.parentnode) { // handle the case where ie and opera return items // by name instead of id if (elem.id !== match[2]) { return rootjquery.find(selector); } // otherwise, we inject the element directly into the jquery object this.length = 1; this[0] = elem; } this.context = document; this.selector = selector; return this; } // handle: $(expr, $(...)) } else if (!context || context.jquery) { return (context || rootjquery).find(selector); // handle: $(expr, context) // (which is just equivalent to: $(context).find(expr) } else { return this.constructor(context).find(selector); } // handle: $(function) // shortcut for document ready } else if (jquery.isfunction(selector)) { return rootjquery.ready(selector); } if (selector.selector !== undefined) { this.selector = selector.selector; this.context = selector.context; } return jquery.makearray(selector, this); }, // start with an empty selector selector: "", // the current version of jquery being used jquery: "1.8.3", // the default length of a jquery object is 0 length: 0, // the number of elements contained in the matched element set size: function () { return this.length; }, toarray: function () { return core_slice.call(this); }, // get the nth element in the matched element set or // get the whole matched element set as a clean array get: function (num) { return num == null ? // return a 'clean' array this.toarray() : // return just the object (num < 0 ? this[this.length + num] : this[num]); }, // take an array of elements and push it onto the stack // (returning the new matched element set) pushstack: function (elems, name, selector) { // build a new jquery matched element set var ret = jquery.merge(this.constructor(), 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; }, // execute a callback for every element in the matched set. // (you can seed the arguments with an array of args, but this is // only used internally.) each: function (callback, args) { return jquery.each(this, callback, args); }, ready: function (fn) { // add the callback jquery.ready.promise().done(fn); return this; }, eq: function (i) { i = +i; return i === -1 ? this.slice(i) : this.slice(i, i + 1); }, first: function () { return this.eq(0); }, last: function () { return this.eq(-1); }, slice: function () { return this.pushstack(core_slice.apply(this, arguments), "slice", core_slice.call(arguments).join(",")); }, map: function (callback) { return this.pushstack(jquery.map(this, function (elem, i) { return callback.call(elem, i, elem); })); }, end: function () { return this.prevobject || this.constructor(null); }, // for internal use only. // behaves like an array's method, not like a jquery method. push: core_push, sort: [].sort, splice: [].splice }; // give the init function the jquery prototype for later instantiation jquery.fn.init.prototype = jquery.fn; jquery.extend = jquery.fn.extend = function () { var options, name, src, copy, copyisarray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; // handle a deep copy situation if (typeof target === "boolean") { deep = target; target = arguments[1] || {}; // skip the boolean and the target i = 2; } // handle case when target is a string or something (possible in deep copy) if (typeof target !== "object" && !jquery.isfunction(target)) { target = {}; } // extend jquery itself if only one argument is passed if (length === i) { target = this; --i; } for (; i < length; i++) { // only deal with non-null/undefined values if ((options = arguments[i]) != null) { // extend the base object for (name in options) { src = target[name]; copy = options[name]; // prevent never-ending loop if (target === copy) { continue; } // recurse if we're merging plain objects or arrays if (deep && copy && (jquery.isplainobject(copy) || (copyisarray = jquery.isarray(copy)))) { if (copyisarray) { copyisarray = false; clone = src && jquery.isarray(src) ? src : []; } else { clone = src && jquery.isplainobject(src) ? src : {}; } // never move original objects, clone them target[name] = jquery.extend(deep, clone, copy); // don't bring in undefined values } else if (copy !== undefined) { target[name] = copy; } } } } // return the modified object return target; }; jquery.extend({ noconflict: function (deep) { if (window.$ === jquery) { window.$ = _$; } if (deep && window.jquery === jquery) { window.jquery = _jquery; } return jquery; }, // is the dom ready to be used? set to true once it occurs. isready: false, // a counter to track how many items to wait for before // the ready event fires. see #6781 readywait: 1, // hold (or release) the ready event holdready: function (hold) { if (hold) { jquery.readywait++; } else { jquery.ready(true); } }, // handle when the dom is ready ready: function (wait) { // abort if there are pending holds or we're already ready if (wait === true ? --jquery.readywait : jquery.isready) { return; } // make sure body exists, at least, in case ie gets a little overzealous (ticket #5443). if (!document.body) { return settimeout(jquery.ready, 1); } // remember that the dom is ready jquery.isready = true; // if a normal dom ready event fired, decrement, and wait if need be if (wait !== true && --jquery.readywait > 0) { return; } // if there are functions bound, to execute readylist.resolvewith(document, [jquery]); // trigger any bound ready events if (jquery.fn.trigger) { jquery(document).trigger("ready").off("ready"); } }, // see test/unit/core.js for details concerning isfunction. // since version 1.3, dom methods and functions like alert // aren't supported. they return false on ie (#2968). isfunction: function (obj) { return jquery.type(obj) === "function"; }, isarray: array.isarray || function (obj) { return jquery.type(obj) === "array"; }, iswindow: function (obj) { return obj != null && obj == obj.window; }, isnumeric: function (obj) { return !isnan(parsefloat(obj)) && isfinite(obj); }, type: function (obj) { return obj == null ? string(obj) : class2type[core_tostring.call(obj)] || "object"; }, isplainobject: function (obj) { // must be an object. // because of ie, we also have to check the presence of the constructor property. // make sure that dom nodes and window objects don't pass through, as well if (!obj || jquery.type(obj) !== "object" || obj.nodetype || jquery.iswindow(obj)) { return false; } try { // not own constructor property must be object if (obj.constructor && !core_hasown.call(obj, "constructor") && !core_hasown.call(obj.constructor.prototype, "isprototypeof")) { return false; } } catch (e) { // ie8,9 will throw exceptions on certain host objects #9897 return false; } // own properties are enumerated firstly, so to speed up, // if last one is own, then all properties are own. var key; for (key in obj) { } return key === undefined || core_hasown.call(obj, key); }, isemptyobject: function (obj) { var name; for (name in obj) { return false; } return true; }, error: function (msg) { throw new error(msg); }, // data: string of html // context (optional): if specified, the fragment will be created in this context, defaults to document // scripts (optional): if true, will include scripts passed in the html string parsehtml: function (data, context, scripts) { var parsed; if (!data || typeof data !== "string") { return null; } if (typeof context === "boolean") { scripts = context; context = 0; } context = context || document; // single tag if ((parsed = rsingletag.exec(data))) { return [context.createelement(parsed[1])]; } parsed = jquery.buildfragment([data], context, scripts ? null : []); return jquery.merge([], (parsed.cacheable ? jquery.clone(parsed.fragment) : parsed.fragment).childnodes); }, parsejson: function (data) { if (!data || typeof data !== "string") { return null; } // make sure leading/trailing whitespace is removed (ie can't handle it) data = jquery.trim(data); // attempt to parse using the native json parser first if (window.json && window.json.parse) { return window.json.parse(data); } // make sure the incoming data is actual json // logic borrowed from http://json.org/json2.js if (rvalidchars.test(data.replace(rvalidescape, "@") .replace(rvalidtokens, "]") .replace(rvalidbraces, ""))) { return (new function("return " + data))(); } jquery.error("invalid json: " + data); }, // cross-browser xml parsing parsexml: function (data) { var xml, tmp; if (!data || typeof data !== "string") { return null; } try { if (window.domparser) { // standard tmp = new domparser(); xml = tmp.parsefromstring(data, "text/xml"); } else { // ie xml = new activexobject("microsoft.xmldom"); xml.async = "false"; xml.loadxml(data); } } catch (e) { xml = undefined; } if (!xml || !xml.documentelement || xml.getelementsbytagname("parsererror").length) { jquery.error("invalid xml: " + data); } return xml; }, noop: function () { }, // evaluates a script in a global context // workarounds based on findings by jim driscoll // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context globaleval: function (data) { if (data && core_rnotwhite.test(data)) { // we use execscript on internet explorer // we use an anonymous function so that context is window // rather than jquery in firefox (window.execscript || function (data) { window["eval"].call(window, data); })(data); } }, // convert dashed to camelcase; used by the css and data modules // microsoft forgot to hump their vendor prefix (#9572) camelcase: function (string) { return string.replace(rmsprefix, "ms-").replace(rdashalpha, fcamelcase); }, nodename: function (elem, name) { return elem.nodename && elem.nodename.tolowercase() === name.tolowercase(); }, // args is for internal usage only each: function (obj, callback, args) { var name, i = 0, length = obj.length, isobj = length === undefined || jquery.isfunction(obj); if (args) { if (isobj) { for (name in obj) { if (callback.apply(obj[name], args) === false) { break; } } } else { for (; i < length;) { if (callback.apply(obj[i++], args) === false) { break; } } } // a special, fast, case for the most common use of each } else { if (isobj) { for (name in obj) { if (callback.call(obj[name], name, obj[name]) === false) { break; } } } else { for (; i < length;) { if (callback.call(obj[i], i, obj[i++]) === false) { break; } } } } return obj; }, // use native string.trim function wherever possible trim: core_trim && !core_trim.call("\ufeff\xa0") ? function (text) { return text == null ? "" : core_trim.call(text); } : // otherwise use our own trimming functionality function (text) { return text == null ? "" : (text + "").replace(rtrim, ""); }, // results is for internal usage only makearray: function (arr, results) { var type, ret = results || []; if (arr != null) { // the window, strings (and functions) also have 'length' // tweaked logic slightly to handle blackberry 4.7 regexp issues #6930 type = jquery.type(arr); if (arr.length == null || type === "string" || type === "function" || type === "regexp" || jquery.iswindow(arr)) { core_push.call(ret, arr); } else { jquery.merge(ret, arr); } } return ret; }, inarray: function (elem, arr, i) { var len; if (arr) { if (core_indexof) { return core_indexof.call(arr, elem, i); } len = arr.length; i = i ? i < 0 ? math.max(0, len + i) : i : 0; for (; i < len; i++) { // skip accessing in sparse arrays if (i in arr && arr[i] === elem) { return i; } } } return -1; }, merge: function (first, second) { var l = second.length, i = first.length, j = 0; if (typeof l === "number") { for (; j < l; j++) { first[i++] = second[j]; } } else { while (second[j] !== undefined) { first[i++] = second[j++]; } } first.length = i; return first; }, grep: function (elems, callback, inv) { var retval, ret = [], i = 0, length = elems.length; inv = !!inv; // go through the array, only saving the items // that pass the validator function for (; i < length; i++) { retval = !!callback(elems[i], i); if (inv !== retval) { ret.push(elems[i]); } } return ret; }, // arg is for internal usage only map: function (elems, callback, arg) { var value, key, ret = [], i = 0, length = elems.length, // jquery objects are treated as arrays isarray = elems instanceof jquery || length !== undefined && typeof length === "number" && ((length > 0 && elems[0] && elems[length - 1]) || length === 0 || jquery.isarray(elems)); // go through the array, translating each of the items to their if (isarray) { for (; i < length; i++) { value = callback(elems[i], i, arg); if (value != null) { ret[ret.length] = value; } } // go through every key on the object, } else { for (key in elems) { value = callback(elems[key], key, arg); if (value != null) { ret[ret.length] = value; } } } // flatten any nested arrays return ret.concat.apply([], ret); }, // a global guid counter for objects guid: 1, // bind a function to a context, optionally partially applying any // arguments. proxy: function (fn, context) { var tmp, args, proxy; if (typeof context === "string") { tmp = fn[context]; context = fn; fn = tmp; } // quick check to determine if target is callable, in the spec // this throws a typeerror, but we will just return undefined. if (!jquery.isfunction(fn)) { return undefined; } // simulated bind args = core_slice.call(arguments, 2); proxy = function () { return fn.apply(context, args.concat(core_slice.call(arguments))); }; // set the guid of unique handler to the same of original handler, so it can be removed proxy.guid = fn.guid = fn.guid || jquery.guid++; return proxy; }, // multifunctional method to get and set values of a collection // the value/s can optionally be executed if it's a function access: function (elems, fn, key, value, chainable, emptyget, pass) { var exec, bulk = key == null, i = 0, length = elems.length; // sets many values if (key && typeof key === "object") { for (i in key) { jquery.access(elems, fn, i, key[i], 1, emptyget, value); } chainable = 1; // sets one value } else if (value !== undefined) { // optionally, function values get executed if exec is true exec = pass === undefined && jquery.isfunction(value); if (bulk) { // bulk operations only iterate when executing function values if (exec) { exec = fn; fn = function (elem, key, value) { return exec.call(jquery(elem), value); }; // otherwise they run against the entire set } else { fn.call(elems, value); fn = null; } } if (fn) { for (; i < length; i++) { fn(elems[i], key, exec ? value.call(elems[i], i, fn(elems[i], key)) : value, pass); } } chainable = 1; } return chainable ? elems : // gets bulk ? fn.call(elems) : length ? fn(elems[0], key) : emptyget; }, now: function () { return (new date()).gettime(); } }); jquery.ready.promise = function (obj) { if (!readylist) { readylist = jquery.deferred(); // catch cases where $(document).ready() is called after the browser event has already occurred. // we once tried to use readystate "interactive" here, but it caused issues like the one // discovered by chriss here: http://bugs.jquery.com/ticket/12282#comment:15 if (document.readystate === "complete") { // handle it asynchronously to allow scripts the opportunity to delay ready settimeout(jquery.ready, 1); // standards-based browsers support domcontentloaded } else if (document.addeventlistener) { // use the handy event callback document.addeventlistener("domcontentloaded", domcontentloaded, false); // a fallback to window.onload, that will always work window.addeventlistener("load", jquery.ready, false); // if ie event model is used } else { // ensure firing before onload, maybe late but safe also for iframes document.attachevent("onreadystatechange", domcontentloaded); // a fallback to window.onload, that will always work window.attachevent("onload", jquery.ready); // if ie and not a frame // continually check to see if the document is ready var top = false; try { top = window.frameelement == null && document.documentelement; } catch (e) { } if (top && top.doscroll) { (function doscrollcheck() { if (!jquery.isready) { try { // use the trick by diego perini // http://javascript.nwbox.com/iecontentloaded/ top.doscroll("left"); } catch (e) { return settimeout(doscrollcheck, 50); } // and execute any waiting functions jquery.ready(); } })(); } } } return readylist.promise(obj); }; // populate the class2type map jquery.each("boolean number string function array date regexp object".split(" "), function (i, name) { class2type["[object " + name + "]"] = name.tolowercase(); }); // all jquery objects should point back to these rootjquery = jquery(document); // string to object options format cache var optionscache = {}; // convert string-formatted options into object-formatted ones and store in cache function createoptions(options) { var object = optionscache[options] = {}; jquery.each(options.split(core_rspace), function (_, flag) { object[flag] = true; }); return object; } /* * create a callback list using the following parameters: * * options: an optional list of space-separated options that will change how * the callback list behaves or a more traditional option object * * by default a callback list will act like an event callback list and can be * "fired" multiple times. * * possible options: * * once: will ensure the callback list can only be fired once (like a deferred) * * memory: will keep track of previous values and will call any callback added * after the list has been fired right away with the latest "memorized" * values (like a deferred) * * unique: will ensure a callback can only be added once (no duplicate in the list) * * stoponfalse: interrupt callings when a callback returns false * */ jquery.callbacks = function (options) { // convert options from string-formatted to object-formatted if needed // (we check in cache first) options = typeof options === "string" ? (optionscache[options] || createoptions(options)) : jquery.extend({}, options); var // last fire value (for non-forgettable lists) memory, // flag to know if list was already fired fired, // flag to know if list is currently firing firing, // first callback to fire (used internally by add and firewith) firingstart, // end of the loop when firing firinglength, // index of currently firing callback (modified by remove if needed) firingindex, // actual callback list list = [], // stack of fire calls for repeatable lists stack = !options.once && [], // fire callbacks fire = function (data) { memory = options.memory && data; fired = true; firingindex = firingstart || 0; firingstart = 0; firinglength = list.length; firing = true; for (; list && firingindex < firinglength; firingindex++) { if (list[firingindex].apply(data[0], data[1]) === false && options.stoponfalse) { memory = false; // to prevent further calls using add break; } } firing = false; if (list) { if (stack) { if (stack.length) { fire(stack.shift()); } } else if (memory) { list = []; } else { self.disable(); } } }, // actual callbacks object self = { // add a callback or a collection of callbacks to the list add: function () { if (list) { // first, we save the current length var start = list.length; (function add(args) { jquery.each(args, function (_, arg) { var type = jquery.type(arg); if (type === "function") { if (!options.unique || !self.has(arg)) { list.push(arg); } } else if (arg && arg.length && type !== "string") { // inspect recursively add(arg); } }); })(arguments); // do we need to add the callbacks to the // current firing batch? if (firing) { firinglength = list.length; // with memory, if we're not firing then // we should call right away } else if (memory) { firingstart = start; fire(memory); } } return this; }, // remove a callback from the list remove: function () { if (list) { jquery.each(arguments, function (_, arg) { var index; while ((index = jquery.inarray(arg, list, index)) > -1) { list.splice(index, 1); // handle firing indexes if (firing) { if (index <= firinglength) { firinglength--; } if (index <= firingindex) { firingindex--; } } } }); } return this; }, // control if a given callback is in the list has: function (fn) { return jquery.inarray(fn, list) > -1; }, // remove all callbacks from the list empty: function () { list = []; return this; }, // have the list do nothing anymore disable: function () { list = stack = memory = undefined; return this; }, // is it disabled? disabled: function () { return !list; }, // lock the list in its current state lock: function () { stack = undefined; if (!memory) { self.disable(); } return this; }, // is it locked? locked: function () { return !stack; }, // call all callbacks with the given context and arguments firewith: function (context, args) { args = args || []; args = [context, args.slice ? args.slice() : args]; if (list && (!fired || stack)) { if (firing) { stack.push(args); } else { fire(args); } } return this; }, // call all the callbacks with the given arguments fire: function () { self.firewith(this, arguments); return this; }, // to know if the callbacks have already been called at least once fired: function () { return !!fired; } }; return self; }; jquery.extend({ deferred: function (func) { var tuples = [ // action, add listener, listener list, final state ["resolve", "done", jquery.callbacks("once memory"), "resolved"], ["reject", "fail", jquery.callbacks("once memory"), "rejected"], ["notify", "progress", jquery.callbacks("memory")] ], state = "pending", promise = { state: function () { return state; }, always: function () { deferred.done(arguments).fail(arguments); return this; }, then: function ( /* fndone, fnfail, fnprogress */) { var fns = arguments; return jquery.deferred(function (newdefer) { jquery.each(tuples, function (i, tuple) { var action = tuple[0], fn = fns[i]; // deferred[ done | fail | progress ] for forwarding actions to newdefer deferred[tuple[1]](jquery.isfunction(fn) ? function () { var returned = fn.apply(this, arguments); if (returned && jquery.isfunction(returned.promise)) { returned.promise() .done(newdefer.resolve) .fail(newdefer.reject) .progress(newdefer.notify); } else { newdefer[action + "with"](this === deferred ? newdefer : this, [returned]); } } : newdefer[action] ); }); fns = null; }).promise(); }, // get a promise for this deferred // if obj is provided, the promise aspect is added to the object promise: function (obj) { return obj != null ? jquery.extend(obj, promise) : promise; } }, deferred = {}; // keep pipe for back-compat promise.pipe = promise.then; // add list-specific methods jquery.each(tuples, function (i, tuple) { var list = tuple[2], statestring = tuple[3]; // promise[ done | fail | progress ] = list.add promise[tuple[1]] = list.add; // handle state if (statestring) { list.add(function () { // state = [ resolved | rejected ] state = statestring; // [ reject_list | resolve_list ].disable; progress_list.lock }, tuples[i ^ 1][2].disable, tuples[2][2].lock); } // deferred[ resolve | reject | notify ] = list.fire deferred[tuple[0]] = list.fire; deferred[tuple[0] + "with"] = list.firewith; }); // make the deferred a promise promise.promise(deferred); // call given func if any if (func) { func.call(deferred, deferred); } // all done! return deferred; }, // deferred helper when: function (subordinate /* , ..., subordinaten */) { var i = 0, resolvevalues = core_slice.call(arguments), length = resolvevalues.length, // the count of uncompleted subordinates remaining = length !== 1 || (subordinate && jquery.isfunction(subordinate.promise)) ? length : 0, // the master deferred. if resolvevalues consist of only a single deferred, just use that. deferred = remaining === 1 ? subordinate : jquery.deferred(), // update function for both resolve and progress values updatefunc = function (i, contexts, values) { return function (value) { contexts[i] = this; values[i] = arguments.length > 1 ? core_slice.call(arguments) : value; if (values === progressvalues) { deferred.notifywith(contexts, values); } else if (!(--remaining)) { deferred.resolvewith(contexts, values); } }; }, progressvalues, progresscontexts, resolvecontexts; // add listeners to deferred subordinates; treat others as resolved if (length > 1) { progressvalues = new array(length); progresscontexts = new array(length); resolvecontexts = new array(length); for (; i < length; i++) { if (resolvevalues[i] && jquery.isfunction(resolvevalues[i].promise)) { resolvevalues[i].promise() .done(updatefunc(i, resolvecontexts, resolvevalues)) .fail(deferred.reject) .progress(updatefunc(i, progresscontexts, progressvalues)); } else { --remaining; } } } // if we're not waiting on anything, resolve the master if (!remaining) { deferred.resolvewith(resolvecontexts, resolvevalues); } return deferred.promise(); } }); jquery.support = (function () { var support, all, a, select, opt, input, fragment, eventname, i, issupported, clickfn, div = document.createelement("div"); // setup div.setattribute("classname", "t"); div.innerhtml = "
a"; // support tests won't run in some limited or non-browser environments all = div.getelementsbytagname("*"); a = div.getelementsbytagname("a")[0]; if (!all || !a || !all.length) { return {}; } // first batch of tests select = document.createelement("select"); opt = select.appendchild(document.createelement("option")); input = div.getelementsbytagname("input")[0]; a.style.csstext = "top:1px;float:left;opacity:.5"; support = { // ie strips leading whitespace when .innerhtml is used leadingwhitespace: (div.firstchild.nodetype === 3), // make sure that tbody elements aren't automatically inserted // ie will insert them into empty tables tbody: !div.getelementsbytagname("tbody").length, // make sure that link elements get serialized correctly by innerhtml // this requires a wrapper element in ie htmlserialize: !!div.getelementsbytagname("link").length, // get the style information from getattribute // (ie uses .csstext instead) style: /top/.test(a.getattribute("style")), // make sure that urls aren't manipulated // (ie normalizes it by default) hrefnormalized: (a.getattribute("href") === "/a"), // make sure that element opacity exists // (ie uses filter instead) // use a regex to work around a webkit issue. see #5145 opacity: /^0.5/.test(a.style.opacity), // verify style float existence // (ie uses stylefloat instead of cssfloat) cssfloat: !!a.style.cssfloat, // make sure that if no value is specified for a checkbox // that it defaults to "on". // (webkit defaults to "" instead) checkon: (input.value === "on"), // make sure that a selected-by-default option has a working selected property. // (webkit defaults to false instead of true, ie too, if it's in an optgroup) optselected: opt.selected, // test setattribute on camelcase class. if it works, we need attrfixes when doing get/setattribute (ie6/7) getsetattribute: div.classname !== "t", // tests for enctype support on a form (#6743) enctype: !!document.createelement("form").enctype, // makes sure cloning an html5 element does not cause problems // where outerhtml is undefined, this still works html5clone: document.createelement("nav").clonenode(true).outerhtml !== "<:nav>", // jquery.support.boxmodel deprecated in 1.8 since we don't support quirks mode boxmodel: (document.compatmode === "css1compat"), // will be defined later submitbubbles: true, changebubbles: true, focusinbubbles: false, deleteexpando: true, nocloneevent: true, inlineblockneedslayout: false, shrinkwrapblocks: false, reliablemarginright: true, boxsizingreliable: true, pixelposition: false }; // make sure checked status is properly cloned input.checked = true; support.noclonechecked = input.clonenode(true).checked; // make sure that the options inside disabled selects aren't marked as disabled // (webkit marks them as disabled) select.disabled = true; support.optdisabled = !opt.disabled; // test to see if it's possible to delete an expando from an element // fails in internet explorer try { delete div.test; } catch (e) { support.deleteexpando = false; } if (!div.addeventlistener && div.attachevent && div.fireevent) { div.attachevent("onclick", clickfn = function () { // cloning a node shouldn't copy over any // bound event handlers (ie does this) support.nocloneevent = false; }); div.clonenode(true).fireevent("onclick"); div.detachevent("onclick", clickfn); } // check if a radio maintains its value // after being appended to the dom input = document.createelement("input"); input.value = "t"; input.setattribute("type", "radio"); support.radiovalue = input.value === "t"; input.setattribute("checked", "checked"); // #11217 - webkit loses check when the name is after the checked attribute input.setattribute("name", "t"); div.appendchild(input); fragment = document.createdocumentfragment(); fragment.appendchild(div.lastchild); // webkit doesn't clone checked state correctly in fragments support.checkclone = fragment.clonenode(true).clonenode(true).lastchild.checked; // check if a disconnected checkbox will retain its checked // value of true after appended to the dom (ie6/7) support.appendchecked = input.checked; fragment.removechild(input); fragment.appendchild(div); // technique from juriy zaytsev // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ // we only care about the case where non-standard event systems // are used, namely in ie. short-circuiting here helps us to // avoid an eval call (in setattribute) which can cause csp // to go haywire. see: https://developer.mozilla.org/en/security/csp if (div.attachevent) { for (i in { submit: true, change: true, focusin: true }) { eventname = "on" + i; issupported = (eventname in div); if (!issupported) { div.setattribute(eventname, "return;"); issupported = (typeof div[eventname] === "function"); } support[i + "bubbles"] = issupported; } } // run tests that need a body at doc ready jquery(function () { var container, div, tds, margindiv, divreset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", body = document.getelementsbytagname("body")[0]; if (!body) { // return for frameset docs that don't have a body return; } container = document.createelement("div"); container.style.csstext = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; body.insertbefore(container, body.firstchild); // construct the test element div = document.createelement("div"); container.appendchild(div); // check if table cells still have offsetwidth/height when they are set // to display:none and there are still other visible table cells in a // table row; if so, offsetwidth/height are not reliable for use when // determining if an element has been hidden directly using // display:none (it is still safe to use offsets if a parent element is // hidden; don safety goggles and see bug #4512 for more information). // (only ie 8 fails this test) div.innerhtml = "
t
"; tds = div.getelementsbytagname("td"); tds[0].style.csstext = "padding:0;margin:0;border:0;display:none"; issupported = (tds[0].offsetheight === 0); tds[0].style.display = ""; tds[1].style.display = "none"; // check if empty table cells still have offsetwidth/height // (ie <= 8 fail this test) support.reliablehiddenoffsets = issupported && (tds[0].offsetheight === 0); // check box-sizing and margin behavior div.innerhtml = ""; div.style.csstext = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; support.boxsizing = (div.offsetwidth === 4); support.doesnotincludemargininbodyoffset = (body.offsettop !== 1); // note: to any future maintainer, we've window.getcomputedstyle // because jsdom on node.js will break without it. if (window.getcomputedstyle) { support.pixelposition = (window.getcomputedstyle(div, null) || {}).top !== "1%"; support.boxsizingreliable = (window.getcomputedstyle(div, null) || { width: "4px" }).width === "4px"; // check if div with explicit width and no margin-right incorrectly // gets computed margin-right based on width of container. for more // info see bug #3333 // fails in webkit before feb 2011 nightlies // webkit bug 13343 - getcomputedstyle returns wrong value for margin-right margindiv = document.createelement("div"); margindiv.style.csstext = div.style.csstext = divreset; margindiv.style.marginright = margindiv.style.width = "0"; div.style.width = "1px"; div.appendchild(margindiv); support.reliablemarginright = !parsefloat((window.getcomputedstyle(margindiv, null) || {}).marginright); } if (typeof div.style.zoom !== "undefined") { // check if natively block-level elements act like inline-block // elements when setting their display to 'inline' and giving // them layout // (ie < 8 does this) div.innerhtml = ""; div.style.csstext = divreset + "width:1px;padding:1px;display:inline;zoom:1"; support.inlineblockneedslayout = (div.offsetwidth === 3); // check if elements with layout shrink-wrap their children // (ie 6 does this) div.style.display = "block"; div.style.overflow = "visible"; div.innerhtml = "
"; div.firstchild.style.width = "5px"; support.shrinkwrapblocks = (div.offsetwidth !== 3); container.style.zoom = 1; } // null elements to avoid leaks in ie body.removechild(container); container = div = tds = margindiv = null; }); // null elements to avoid leaks in ie fragment.removechild(div); all = a = select = opt = input = fragment = div = null; return support; })(); var rbrace = /(?:\{[\s\s]*\}|\[[\s\s]*\])$/, rmultidash = /([a-z])/g; jquery.extend({ cache: {}, deletedids: [], // remove at next major release (1.9/2.0) uuid: 0, // unique for each copy of jquery on the page // non-digits removed to match rinlinejquery expando: "jquery" + (jquery.fn.jquery + math.random()).replace(/\d/g, ""), // the following elements throw uncatchable exceptions if you // attempt to add expando properties to them. nodata: { "embed": true, // ban all objects except for flash (which handle expandos) "object": "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "applet": true }, hasdata: function (elem) { elem = elem.nodetype ? jquery.cache[elem[jquery.expando]] : elem[jquery.expando]; return !!elem && !isemptydataobject(elem); }, data: function (elem, name, data, pvt /* internal use only */) { if (!jquery.acceptdata(elem)) { return; } var thiscache, ret, internalkey = jquery.expando, getbyname = typeof name === "string", // we have to handle dom nodes and js objects differently because ie6-7 // can't gc object references properly across the dom-js boundary isnode = elem.nodetype, // only dom nodes need the global jquery cache; js object data is // attached directly to the object so gc can occur automatically cache = isnode ? jquery.cache : elem, // only defining an id for js objects if its cache already exists allows // the code to shortcut on the same path as a dom node with no cache id = isnode ? elem[internalkey] : elem[internalkey] && internalkey; // avoid doing any more work than we need to when trying to get data on an // object that has no data at all if ((!id || !cache[id] || (!pvt && !cache[id].data)) && getbyname && data === undefined) { return; } if (!id) { // only dom nodes need a new unique id for each element since their data // ends up in the global cache if (isnode) { elem[internalkey] = id = jquery.deletedids.pop() || jquery.guid++; } else { id = internalkey; } } if (!cache[id]) { cache[id] = {}; // avoids exposing jquery metadata on plain js objects when the object // is serialized using json.stringify if (!isnode) { cache[id].tojson = jquery.noop; } } // an object can be passed to jquery.data instead of a key/value pair; this gets // shallow copied over onto the existing cache if (typeof name === "object" || typeof name === "function") { if (pvt) { cache[id] = jquery.extend(cache[id], name); } else { cache[id].data = jquery.extend(cache[id].data, name); } } thiscache = cache[id]; // jquery data() is stored in a separate object inside the object's internal data // cache in order to avoid key collisions between internal data and user-defined // data. if (!pvt) { if (!thiscache.data) { thiscache.data = {}; } thiscache = thiscache.data; } if (data !== undefined) { thiscache[jquery.camelcase(name)] = data; } // check for both converted-to-camel and non-converted data property names // if a data property was specified if (getbyname) { // first try to find as-is property data ret = thiscache[name]; // test for null|undefined property data if (ret == null) { // try to find the camelcased property ret = thiscache[jquery.camelcase(name)]; } } else { ret = thiscache; } return ret; }, removedata: function (elem, name, pvt /* internal use only */) { if (!jquery.acceptdata(elem)) { return; } var thiscache, i, l, isnode = elem.nodetype, // see jquery.data for more information cache = isnode ? jquery.cache : elem, id = isnode ? elem[jquery.expando] : jquery.expando; // if there is already no cache entry for this object, there is no // purpose in continuing if (!cache[id]) { return; } if (name) { thiscache = pvt ? cache[id] : cache[id].data; if (thiscache) { // support array or space separated string names for data keys if (!jquery.isarray(name)) { // try the string as a key before any manipulation if (name in thiscache) { name = [name]; } else { // split the camel cased version by spaces unless a key with the spaces exists name = jquery.camelcase(name); if (name in thiscache) { name = [name]; } else { name = name.split(" "); } } } for (i = 0, l = name.length; i < l; i++) { delete thiscache[name[i]]; } // if there is no data left in the cache, we want to continue // and let the cache object itself get destroyed if (!(pvt ? isemptydataobject : jquery.isemptyobject)(thiscache)) { return; } } } // see jquery.data for more information if (!pvt) { delete cache[id].data; // don't destroy the parent cache unless the internal data object // had been the only thing left in it if (!isemptydataobject(cache[id])) { return; } } // destroy the cache if (isnode) { jquery.cleandata([elem], true); // use delete when supported for expandos or `cache` is not a window per iswindow (#10080) } else if (jquery.support.deleteexpando || cache != cache.window) { delete cache[id]; // when all else fails, null } else { cache[id] = null; } }, // for internal use only. _data: function (elem, name, data) { return jquery.data(elem, name, data, true); }, // a method for determining if a dom node can handle the data expando acceptdata: function (elem) { var nodata = elem.nodename && jquery.nodata[elem.nodename.tolowercase()]; // nodes accept data unless otherwise specified; rejection can be conditional return !nodata || nodata !== true && elem.getattribute("classid") === nodata; } }); jquery.fn.extend({ data: function (key, value) { var parts, part, attr, name, l, elem = this[0], i = 0, data = null; // gets all values if (key === undefined) { if (this.length) { data = jquery.data(elem); if (elem.nodetype === 1 && !jquery._data(elem, "parsedattrs")) { attr = elem.attributes; for (l = attr.length; i < l; i++) { name = attr[i].name; if (!name.indexof("data-")) { name = jquery.camelcase(name.substring(5)); dataattr(elem, name, data[name]); } } jquery._data(elem, "parsedattrs", true); } } return data; } // sets multiple values if (typeof key === "object") { return this.each(function () { jquery.data(this, key); }); } parts = key.split(".", 2); parts[1] = parts[1] ? "." + parts[1] : ""; part = parts[1] + "!"; return jquery.access(this, function (value) { if (value === undefined) { data = this.triggerhandler("getdata" + part, [parts[0]]); // try to fetch any internally stored data first if (data === undefined && elem) { data = jquery.data(elem, key); data = dataattr(elem, key, data); } return data === undefined && parts[1] ? this.data(parts[0]) : data; } parts[1] = value; this.each(function () { var self = jquery(this); self.triggerhandler("setdata" + part, parts); jquery.data(this, key, value); self.triggerhandler("changedata" + part, parts); }); }, null, value, arguments.length > 1, null, false); }, removedata: function (key) { return this.each(function () { jquery.removedata(this, key); }); } }); function dataattr(elem, key, data) { // if nothing was found internally, try to fetch any // data from the html5 data-* attribute if (data === undefined && elem.nodetype === 1) { var name = "data-" + key.replace(rmultidash, "-$1").tolowercase(); data = elem.getattribute(name); if (typeof data === "string") { try { data = data === "true" ? true : data === "false" ? false : data === "null" ? null : // only convert to a number if it doesn't change the string +data + "" === data ? +data : rbrace.test(data) ? jquery.parsejson(data) : data; } catch (e) { } // make sure we set the data so it isn't changed later jquery.data(elem, key, data); } else { data = undefined; } } return data; } // checks a cache object for emptiness function isemptydataobject(obj) { var name; for (name in obj) { // if the public data object is empty, the private is still empty if (name === "data" && jquery.isemptyobject(obj[name])) { continue; } if (name !== "tojson") { return false; } } return true; } jquery.extend({ queue: function (elem, type, data) { var queue; if (elem) { type = (type || "fx") + "queue"; queue = jquery._data(elem, type); // speed up dequeue by getting out quickly if this is just a lookup if (data) { if (!queue || jquery.isarray(data)) { queue = jquery._data(elem, type, jquery.makearray(data)); } else { queue.push(data); } } return queue || []; } }, dequeue: function (elem, type) { type = type || "fx"; var queue = jquery.queue(elem, type), startlength = queue.length, fn = queue.shift(), hooks = jquery._queuehooks(elem, type), next = function () { jquery.dequeue(elem, type); }; // if the fx queue is dequeued, always remove the progress sentinel if (fn === "inprogress") { fn = queue.shift(); startlength--; } if (fn) { // add a progress sentinel to prevent the fx queue from being // automatically dequeued if (type === "fx") { queue.unshift("inprogress"); } // clear up the last queue stop function delete hooks.stop; fn.call(elem, next, hooks); } if (!startlength && hooks) { hooks.empty.fire(); } }, // not intended for public consumption - generates a queuehooks object, or returns the current one _queuehooks: function (elem, type) { var key = type + "queuehooks"; return jquery._data(elem, key) || jquery._data(elem, key, { empty: jquery.callbacks("once memory").add(function () { jquery.removedata(elem, type + "queue", true); jquery.removedata(elem, key, true); }) }); } }); jquery.fn.extend({ queue: function (type, data) { var setter = 2; if (typeof type !== "string") { data = type; type = "fx"; setter--; } if (arguments.length < setter) { return jquery.queue(this[0], type); } return data === undefined ? this : this.each(function () { var queue = jquery.queue(this, type, data); // ensure a hooks for this queue jquery._queuehooks(this, type); if (type === "fx" && queue[0] !== "inprogress") { jquery.dequeue(this, type); } }); }, dequeue: function (type) { return this.each(function () { jquery.dequeue(this, type); }); }, // based off of the plugin by clint helfers, with power. // http://blindsignals.com/index.php/2009/07/jquery-delay/ delay: function (time, type) { time = jquery.fx ? jquery.fx.speeds[time] || time : time; type = type || "fx"; return this.queue(type, function (next, hooks) { var timeout = settimeout(next, time); hooks.stop = function () { cleartimeout(timeout); }; }); }, clearqueue: function (type) { return this.queue(type || "fx", []); }, // get a promise resolved when queues of a certain type // are emptied (fx is the type by default) promise: function (type, obj) { var tmp, count = 1, defer = jquery.deferred(), elements = this, i = this.length, resolve = function () { if (!(--count)) { defer.resolvewith(elements, [elements]); } }; if (typeof type !== "string") { obj = type; type = undefined; } type = type || "fx"; while (i--) { tmp = jquery._data(elements[i], type + "queuehooks"); if (tmp && tmp.empty) { count++; tmp.empty.add(resolve); } } resolve(); return defer.promise(obj); } }); var nodehook, boolhook, fixspecified, rclass = /[\t\r\n]/g, rreturn = /\r/g, rtype = /^(?:button|input)$/i, rfocusable = /^(?:button|input|object|select|textarea)$/i, rclickable = /^a(?:rea|)$/i, rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, getsetattribute = jquery.support.getsetattribute; jquery.fn.extend({ attr: function (name, value) { return jquery.access(this, jquery.attr, name, value, arguments.length > 1); }, removeattr: function (name) { return this.each(function () { jquery.removeattr(this, name); }); }, prop: function (name, value) { return jquery.access(this, jquery.prop, name, value, arguments.length > 1); }, removeprop: function (name) { name = jquery.propfix[name] || name; return this.each(function () { // try/catch handles cases where ie balks (such as removing a property on window) try { this[name] = undefined; delete this[name]; } catch (e) { } }); }, addclass: function (value) { var classnames, i, l, elem, setclass, c, cl; if (jquery.isfunction(value)) { return this.each(function (j) { jquery(this).addclass(value.call(this, j, this.classname)); }); } if (value && typeof value === "string") { classnames = value.split(core_rspace); for (i = 0, l = this.length; i < l; i++) { elem = this[i]; if (elem.nodetype === 1) { if (!elem.classname && classnames.length === 1) { elem.classname = value; } else { setclass = " " + elem.classname + " "; for (c = 0, cl = classnames.length; c < cl; c++) { if (setclass.indexof(" " + classnames[c] + " ") < 0) { setclass += classnames[c] + " "; } } elem.classname = jquery.trim(setclass); } } } } return this; }, removeclass: function (value) { var removes, classname, elem, c, cl, i, l; if (jquery.isfunction(value)) { return this.each(function (j) { jquery(this).removeclass(value.call(this, j, this.classname)); }); } if ((value && typeof value === "string") || value === undefined) { removes = (value || "").split(core_rspace); for (i = 0, l = this.length; i < l; i++) { elem = this[i]; if (elem.nodetype === 1 && elem.classname) { classname = (" " + elem.classname + " ").replace(rclass, " "); // loop over each item in the removal list for (c = 0, cl = removes.length; c < cl; c++) { // remove until there is nothing to remove, while (classname.indexof(" " + removes[c] + " ") >= 0) { classname = classname.replace(" " + removes[c] + " ", " "); } } elem.classname = value ? jquery.trim(classname) : ""; } } } return this; }, toggleclass: function (value, stateval) { var type = typeof value, isbool = typeof stateval === "boolean"; if (jquery.isfunction(value)) { return this.each(function (i) { jquery(this).toggleclass(value.call(this, i, this.classname, 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(core_rspace); while ((classname = classnames[i++])) { // check each classname given, space separated 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__") || ""; } }); }, hasclass: function (selector) { var classname = " " + selector + " ", i = 0, l = this.length; for (; i < l; i++) { if (this[i].nodetype === 1 && (" " + this[i].classname + " ").replace(rclass, " ").indexof(classname) >= 0) { return true; } } return false; }, val: function (value) { var hooks, ret, isfunction, elem = this[0]; if (!arguments.length) { if (elem) { hooks = jquery.valhooks[elem.type] || jquery.valhooks[elem.nodename.tolowercase()]; if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) { return ret; } ret = elem.value; return typeof ret === "string" ? // handle most common string cases ret.replace(rreturn, "") : // handle cases where value is null/undef or number ret == null ? "" : ret; } return; } isfunction = jquery.isfunction(value); return this.each(function (i) { var val, self = jquery(this); if (this.nodetype !== 1) { return; } if (isfunction) { val = value.call(this, i, self.val()); } else { val = value; } // 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 + ""; }); } hooks = jquery.valhooks[this.type] || jquery.valhooks[this.nodename.tolowercase()]; // if set returns undefined, fall back to normal setting if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) { this.value = val; } }); } }); jquery.extend({ valhooks: { option: { get: function (elem) { // 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; } }, select: { get: function (elem) { var value, option, options = elem.options, index = elem.selectedindex, one = elem.type === "select-one" || index < 0, values = one ? null : [], max = one ? index + 1 : options.length, i = index < 0 ? max : one ? index : 0; // loop through all the selected options for (; i < max; i++) { option = options[i]; // oldie doesn't update selected after form reset (#2551) if ((option.selected || i === index) && // don't return options that are disabled or in a disabled optgroup (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); } } return values; }, set: function (elem, value) { var values = jquery.makearray(value); jquery(elem).find("option").each(function () { this.selected = jquery.inarray(jquery(this).val(), values) >= 0; }); if (!values.length) { elem.selectedindex = -1; } return values; } } }, // unused in 1.8, left in so attrfn-stabbers won't die; remove in 1.9 attrfn: {}, attr: function (elem, name, value, pass) { var ret, hooks, notxml, ntype = elem.nodetype; // don't get/set attributes on text, comment and attribute nodes if (!elem || ntype === 3 || ntype === 8 || ntype === 2) { return; } if (pass && jquery.isfunction(jquery.fn[name])) { return jquery(elem)[name](value); } // fallback to prop when attributes are not supported if (typeof elem.getattribute === "undefined") { return jquery.prop(elem, name, value); } notxml = ntype !== 1 || !jquery.isxmldoc(elem); // all attributes are lowercase // grab necessary hook if one is defined if (notxml) { name = name.tolowercase(); hooks = jquery.attrhooks[name] || (rboolean.test(name) ? boolhook : nodehook); } if (value !== undefined) { if (value === null) { jquery.removeattr(elem, name); return; } else if (hooks && "set" in hooks && notxml && (ret = hooks.set(elem, value, name)) !== undefined) { return ret; } else { elem.setattribute(name, value + ""); return value; } } else if (hooks && "get" in hooks && notxml && (ret = hooks.get(elem, name)) !== null) { return ret; } else { ret = elem.getattribute(name); // non-existent attributes return null, we normalize to undefined return ret === null ? undefined : ret; } }, removeattr: function (elem, value) { var propname, attrnames, name, isbool, i = 0; if (value && elem.nodetype === 1) { attrnames = value.split(core_rspace); for (; i < attrnames.length; i++) { name = attrnames[i]; if (name) { propname = jquery.propfix[name] || name; isbool = rboolean.test(name); // see #9699 for explanation of this approach (setting first, then removal) // do not do this for boolean attributes (see #10870) if (!isbool) { jquery.attr(elem, name, ""); } elem.removeattribute(getsetattribute ? name : propname); // set corresponding property to false for boolean attributes if (isbool && propname in elem) { elem[propname] = false; } } } } }, attrhooks: { type: { set: function (elem, value) { // we can't allow the type property to be changed (since it causes problems in ie) if (rtype.test(elem.nodename) && elem.parentnode) { jquery.error("type property can't be changed"); } else if (!jquery.support.radiovalue && value === "radio" && jquery.nodename(elem, "input")) { // setting the type on a radio button after the value resets the value in ie6-9 // reset value to it's default in case type is set after value // this is for element creation var val = elem.value; elem.setattribute("type", value); if (val) { elem.value = val; } return value; } } }, // use the value property for back compat // use the nodehook for button elements in ie6/7 (#1954) value: { get: function (elem, name) { if (nodehook && jquery.nodename(elem, "button")) { return nodehook.get(elem, name); } return name in elem ? elem.value : null; }, set: function (elem, value, name) { if (nodehook && jquery.nodename(elem, "button")) { return nodehook.set(elem, value, name); } // does not return so that setattribute is also used elem.value = value; } } }, propfix: { tabindex: "tabindex", readonly: "readonly", "for": "htmlfor", "class": "classname", maxlength: "maxlength", cellspacing: "cellspacing", cellpadding: "cellpadding", rowspan: "rowspan", colspan: "colspan", usemap: "usemap", frameborder: "frameborder", contenteditable: "contenteditable" }, prop: function (elem, name, value) { var ret, hooks, notxml, ntype = elem.nodetype; // don't get/set properties on text, comment and attribute nodes if (!elem || ntype === 3 || ntype === 8 || ntype === 2) { return; } notxml = ntype !== 1 || !jquery.isxmldoc(elem); if (notxml) { // fix name and attach hooks name = jquery.propfix[name] || name; hooks = jquery.prophooks[name]; } if (value !== undefined) { if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) { return ret; } else { return (elem[name] = value); } } else { if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) { return ret; } else { return elem[name]; } } }, prophooks: { tabindex: { get: function (elem) { // elem.tabindex doesn't always return the correct value when it hasn't been explicitly set // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ var attributenode = elem.getattributenode("tabindex"); return attributenode && attributenode.specified ? parseint(attributenode.value, 10) : rfocusable.test(elem.nodename) || rclickable.test(elem.nodename) && elem.href ? 0 : undefined; } } } }); // hook for boolean attributes boolhook = { get: function (elem, name) { // align boolean attributes with corresponding properties // fall back to attribute presence where some booleans are not supported var attrnode, property = jquery.prop(elem, name); return property === true || typeof property !== "boolean" && (attrnode = elem.getattributenode(name)) && attrnode.nodevalue !== false ? name.tolowercase() : undefined; }, set: function (elem, value, name) { var propname; if (value === false) { // remove boolean attributes when set to false jquery.removeattr(elem, name); } else { // value is true since we know at this point it's type boolean and not false // set boolean attributes to the same name and set the dom property propname = jquery.propfix[name] || name; if (propname in elem) { // only set the idl specifically if it already exists on the element elem[propname] = true; } elem.setattribute(name, name.tolowercase()); } return name; } }; // ie6/7 do not support getting/setting some attributes with get/setattribute if (!getsetattribute) { fixspecified = { name: true, id: true, coords: true }; // use this for any attribute in ie6/7 // this fixes almost every ie6/7 issue nodehook = jquery.valhooks.button = { get: function (elem, name) { var ret; ret = elem.getattributenode(name); return ret && (fixspecified[name] ? ret.value !== "" : ret.specified) ? ret.value : undefined; }, set: function (elem, value, name) { // set the existing or create a new attribute node var ret = elem.getattributenode(name); if (!ret) { ret = document.createattribute(name); elem.setattributenode(ret); } return (ret.value = value + ""); } }; // set width and height to auto instead of 0 on empty string( bug #8150 ) // this is for removals jquery.each(["width", "height"], function (i, name) { jquery.attrhooks[name] = jquery.extend(jquery.attrhooks[name], { set: function (elem, value) { if (value === "") { elem.setattribute(name, "auto"); return value; } } }); }); // set contenteditable to false on removals(#10429) // setting to empty string throws an error as an invalid value jquery.attrhooks.contenteditable = { get: nodehook.get, set: function (elem, value, name) { if (value === "") { value = "false"; } nodehook.set(elem, value, name); } }; } // some attributes require a special call on ie if (!jquery.support.hrefnormalized) { jquery.each(["href", "src", "width", "height"], function (i, name) { jquery.attrhooks[name] = jquery.extend(jquery.attrhooks[name], { get: function (elem) { var ret = elem.getattribute(name, 2); return ret === null ? undefined : ret; } }); }); } if (!jquery.support.style) { jquery.attrhooks.style = { get: function (elem) { // return undefined in the case of empty string // normalize to lowercase since ie uppercases css property names return elem.style.csstext.tolowercase() || undefined; }, set: function (elem, value) { return (elem.style.csstext = value + ""); } }; } // safari mis-reports the default selected property of an option // accessing the parent's selectedindex property fixes it if (!jquery.support.optselected) { jquery.prophooks.selected = jquery.extend(jquery.prophooks.selected, { get: function (elem) { var parent = elem.parentnode; if (parent) { parent.selectedindex; // make sure that it also works with optgroups, see #5701 if (parent.parentnode) { parent.parentnode.selectedindex; } } return null; } }); } // ie6/7 call enctype encoding if (!jquery.support.enctype) { jquery.propfix.enctype = "encoding"; } // radios and checkboxes getter/setter if (!jquery.support.checkon) { jquery.each(["radio", "checkbox"], function () { jquery.valhooks[this] = { get: function (elem) { // handle the case where in webkit "" is returned instead of "on" if a value isn't specified return elem.getattribute("value") === null ? "on" : elem.value; } }; }); } jquery.each(["radio", "checkbox"], function () { jquery.valhooks[this] = jquery.extend(jquery.valhooks[this], { set: function (elem, value) { if (jquery.isarray(value)) { return (elem.checked = jquery.inarray(jquery(elem).val(), value) >= 0); } } }); }); var rformelems = /^(?:textarea|input|select)$/i, rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, rhoverhack = /(?:^|\s)hover(\.\s+|)\b/, rkeyevent = /^key/, rmouseevent = /^(?:mouse|contextmenu)|click/, rfocusmorph = /^(?:focusinfocus|focusoutblur)$/, hoverhack = function (events) { return jquery.event.special.hover ? events : events.replace(rhoverhack, "mouseenter$1 mouseleave$1"); }; /* * helper functions for managing events -- not part of the public interface. * props to dean edwards' addevent library for many of the ideas. */ jquery.event = { add: function (elem, types, handler, data, selector) { var elemdata, eventhandle, events, t, tns, type, namespaces, handleobj, handleobjin, handlers, special; // don't attach events to nodata or text/comment nodes (allow plain objects tho) if (elem.nodetype === 3 || elem.nodetype === 8 || !types || !handler || !(elemdata = jquery._data(elem))) { return; } // caller can pass in an object of custom data in lieu of the handler if (handler.handler) { handleobjin = handler; handler = handleobjin.handler; selector = handleobjin.selector; } // make sure that the handler has a unique id, used to find/remove it later if (!handler.guid) { handler.guid = jquery.guid++; } // init the element's event structure and main handler, if this is the first events = elemdata.events; if (!events) { elemdata.events = events = {}; } eventhandle = elemdata.handle; if (!eventhandle) { elemdata.handle = eventhandle = function (e) { // discard the second event of a jquery.event.trigger() and // when an event is called after a page has unloaded return typeof jquery !== "undefined" && (!e || jquery.event.triggered !== e.type) ? jquery.event.dispatch.apply(eventhandle.elem, arguments) : undefined; }; // add elem as a property of the handle fn to prevent a memory leak with ie non-native events eventhandle.elem = elem; } // handle multiple events separated by a space // jquery(...).bind("mouseover mouseout", fn); types = jquery.trim(hoverhack(types)).split(" "); for (t = 0; t < types.length; t++) { tns = rtypenamespace.exec(types[t]) || []; type = tns[1]; namespaces = (tns[2] || "").split(".").sort(); // if event changes its type, use the special event handlers for the changed type special = jquery.event.special[type] || {}; // if selector defined, determine special event api type, otherwise given type type = (selector ? special.delegatetype : special.bindtype) || type; // update special based on newly reset type special = jquery.event.special[type] || {}; // handleobj is passed to all event handlers handleobj = jquery.extend({ type: type, origtype: tns[1], data: data, handler: handler, guid: handler.guid, selector: selector, needscontext: selector && jquery.expr.match.needscontext.test(selector), namespace: namespaces.join(".") }, handleobjin); // init the event handler queue if we're the first handlers = events[type]; if (!handlers) { handlers = events[type] = []; handlers.delegatecount = 0; // only use addeventlistener/attachevent if the special events handler returns false if (!special.setup || special.setup.call(elem, data, namespaces, eventhandle) === false) { // bind the global event handler to the element if (elem.addeventlistener) { elem.addeventlistener(type, eventhandle, false); } else if (elem.attachevent) { elem.attachevent("on" + type, eventhandle); } } } if (special.add) { special.add.call(elem, handleobj); if (!handleobj.handler.guid) { handleobj.handler.guid = handler.guid; } } // add to the element's handler list, delegates in front if (selector) { handlers.splice(handlers.delegatecount++, 0, handleobj); } else { handlers.push(handleobj); } // keep track of which events have ever been used, for event optimization jquery.event.global[type] = true; } // nullify elem to prevent memory leaks in ie elem = null; }, global: {}, // detach an event or set of events from an element remove: function (elem, types, handler, selector, mappedtypes) { var t, tns, type, origtype, namespaces, origcount, j, events, special, eventtype, handleobj, elemdata = jquery.hasdata(elem) && jquery._data(elem); if (!elemdata || !(events = elemdata.events)) { return; } // once for each type.namespace in types; type may be omitted types = jquery.trim(hoverhack(types || "")).split(" "); for (t = 0; t < types.length; t++) { tns = rtypenamespace.exec(types[t]) || []; type = origtype = tns[1]; namespaces = tns[2]; // unbind all events (on this namespace, if provided) for the element if (!type) { for (type in events) { jquery.event.remove(elem, type + types[t], handler, selector, true); } continue; } special = jquery.event.special[type] || {}; type = (selector ? special.delegatetype : special.bindtype) || type; eventtype = events[type] || []; origcount = eventtype.length; namespaces = namespaces ? new regexp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; // remove matching events for (j = 0; j < eventtype.length; j++) { handleobj = eventtype[j]; if ((mappedtypes || origtype === handleobj.origtype) && (!handler || handler.guid === handleobj.guid) && (!namespaces || namespaces.test(handleobj.namespace)) && (!selector || selector === handleobj.selector || selector === "**" && handleobj.selector)) { eventtype.splice(j--, 1); if (handleobj.selector) { eventtype.delegatecount--; } if (special.remove) { special.remove.call(elem, handleobj); } } } // remove generic event handler if we removed something and no more handlers exist // (avoids potential for endless recursion during removal of special event handlers) if (eventtype.length === 0 && origcount !== eventtype.length) { if (!special.teardown || special.teardown.call(elem, namespaces, elemdata.handle) === false) { jquery.removeevent(elem, type, elemdata.handle); } delete events[type]; } } // remove the expando if it's no longer used if (jquery.isemptyobject(events)) { delete elemdata.handle; // removedata also checks for emptiness and clears the expando if empty // so use it instead of delete jquery.removedata(elem, "events", true); } }, // events that are safe to short-circuit if no handlers are attached. // native dom events should not be added, they may have inline handlers. customevent: { "getdata": true, "setdata": true, "changedata": true }, trigger: function (event, data, elem, onlyhandlers) { // don't do events on text and comment nodes if (elem && (elem.nodetype === 3 || elem.nodetype === 8)) { return; } // event object or event type var cache, exclusive, i, cur, old, ontype, special, handle, eventpath, bubbletype, type = event.type || event, namespaces = []; // focus/blur morphs to focusin/out; ensure we're not firing them right now if (rfocusmorph.test(type + jquery.event.triggered)) { return; } if (type.indexof("!") >= 0) { // exclusive events trigger only for the exact event (no namespaces) type = type.slice(0, -1); exclusive = true; } if (type.indexof(".") >= 0) { // namespaced trigger; create a regexp to match event type in handle() namespaces = type.split("."); type = namespaces.shift(); namespaces.sort(); } if ((!elem || jquery.event.customevent[type]) && !jquery.event.global[type]) { // no jquery handlers for this event type, and it can't have inline handlers return; } // caller can pass in an event, object, or just an event type string event = typeof event === "object" ? // jquery.event object event[jquery.expando] ? event : // object literal new jquery.event(type, event) : // just the event type (string) new jquery.event(type); event.type = type; event.istrigger = true; event.exclusive = exclusive; event.namespace = namespaces.join("."); event.namespace_re = event.namespace ? new regexp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; ontype = type.indexof(":") < 0 ? "on" + type : ""; // handle a global trigger if (!elem) { // todo: stop taunting the data cache; remove global events and always attach to document cache = jquery.cache; for (i in cache) { if (cache[i].events && cache[i].events[type]) { jquery.event.trigger(event, data, cache[i].handle.elem, true); } } return; } // clean up the event in case it is being reused event.result = undefined; if (!event.target) { event.target = elem; } // clone any incoming data and prepend the event, creating the handler arg list data = data != null ? jquery.makearray(data) : []; data.unshift(event); // allow special events to draw outside the lines special = jquery.event.special[type] || {}; if (special.trigger && special.trigger.apply(elem, data) === false) { return; } // determine event propagation path in advance, per w3c events spec (#9951) // bubble up to document, then to window; watch for a global ownerdocument var (#9724) eventpath = [[elem, special.bindtype || type]]; if (!onlyhandlers && !special.nobubble && !jquery.iswindow(elem)) { bubbletype = special.delegatetype || type; cur = rfocusmorph.test(bubbletype + type) ? elem : elem.parentnode; for (old = elem; cur; cur = cur.parentnode) { eventpath.push([cur, bubbletype]); old = cur; } // only add window if we got to document (e.g., not plain obj or detached dom) if (old === (elem.ownerdocument || document)) { eventpath.push([old.defaultview || old.parentwindow || window, bubbletype]); } } // fire handlers on the event path for (i = 0; i < eventpath.length && !event.ispropagationstopped() ; i++) { cur = eventpath[i][0]; event.type = eventpath[i][1]; handle = (jquery._data(cur, "events") || {})[event.type] && jquery._data(cur, "handle"); if (handle) { handle.apply(cur, data); } // note that this is a bare js function and not a jquery handler handle = ontype && cur[ontype]; if (handle && jquery.acceptdata(cur) && handle.apply && handle.apply(cur, data) === false) { event.preventdefault(); } } event.type = type; // if nobody prevented the default action, do it now if (!onlyhandlers && !event.isdefaultprevented()) { if ((!special._default || special._default.apply(elem.ownerdocument, data) === false) && !(type === "click" && jquery.nodename(elem, "a")) && jquery.acceptdata(elem)) { // call a native dom method on the target with the same name name as the event. // can't use an .isfunction() check here because ie6/7 fails that test. // don't do default actions on window, that's where global variables be (#6170) // ie<9 dies on focus/blur to hidden element (#1486) if (ontype && elem[type] && ((type !== "focus" && type !== "blur") || event.target.offsetwidth !== 0) && !jquery.iswindow(elem)) { // don't re-trigger an onfoo event when we call its foo() method old = elem[ontype]; if (old) { elem[ontype] = null; } // prevent re-triggering of the same event, since we already bubbled it above jquery.event.triggered = type; elem[type](); jquery.event.triggered = undefined; if (old) { elem[ontype] = old; } } } } return event.result; }, dispatch: function (event) { // make a writable jquery.event from the native event object event = jquery.event.fix(event || window.event); var i, j, cur, ret, selmatch, matched, matches, handleobj, sel, related, handlers = ((jquery._data(this, "events") || {})[event.type] || []), delegatecount = handlers.delegatecount, args = core_slice.call(arguments), run_all = !event.exclusive && !event.namespace, special = jquery.event.special[event.type] || {}, handlerqueue = []; // use the fix-ed jquery.event rather than the (read-only) native event args[0] = event; event.delegatetarget = this; // call the predispatch hook for the mapped type, and let it bail if desired if (special.predispatch && special.predispatch.call(this, event) === false) { return; } // determine handlers that should run if there are delegated events // avoid non-left-click bubbling in firefox (#3861) if (delegatecount && !(event.button && event.type === "click")) { for (cur = event.target; cur != this; cur = cur.parentnode || this) { // don't process clicks (only) on disabled elements (#6911, #8165, #11382, #11764) if (cur.disabled !== true || event.type !== "click") { selmatch = {}; matches = []; for (i = 0; i < delegatecount; i++) { handleobj = handlers[i]; sel = handleobj.selector; if (selmatch[sel] === undefined) { selmatch[sel] = handleobj.needscontext ? jquery(sel, this).index(cur) >= 0 : jquery.find(sel, this, null, [cur]).length; } if (selmatch[sel]) { matches.push(handleobj); } } if (matches.length) { handlerqueue.push({ elem: cur, matches: matches }); } } } } // add the remaining (directly-bound) handlers if (handlers.length > delegatecount) { handlerqueue.push({ elem: this, matches: handlers.slice(delegatecount) }); } // run delegates first; they may want to stop propagation beneath us for (i = 0; i < handlerqueue.length && !event.ispropagationstopped() ; i++) { matched = handlerqueue[i]; event.currenttarget = matched.elem; for (j = 0; j < matched.matches.length && !event.isimmediatepropagationstopped() ; j++) { handleobj = matched.matches[j]; // triggered event must either 1) be non-exclusive and have no namespace, or // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). if (run_all || (!event.namespace && !handleobj.namespace) || event.namespace_re && event.namespace_re.test(handleobj.namespace)) { event.data = handleobj.data; event.handleobj = handleobj; ret = ((jquery.event.special[handleobj.origtype] || {}).handle || handleobj.handler) .apply(matched.elem, args); if (ret !== undefined) { event.result = ret; if (ret === false) { event.preventdefault(); event.stoppropagation(); } } } } } // call the postdispatch hook for the mapped type if (special.postdispatch) { special.postdispatch.call(this, event); } return event.result; }, // includes some event props shared by keyevent and mouseevent // *** attrchange attrname relatednode srcelement are not normalized, non-w3c, deprecated, will be removed in 1.8 *** props: "attrchange attrname relatednode srcelement altkey bubbles cancelable ctrlkey currenttarget eventphase metakey relatedtarget shiftkey target timestamp view which".split(" "), fixhooks: {}, keyhooks: { props: "char charcode key keycode".split(" "), filter: function (event, original) { // add which for key events if (event.which == null) { event.which = original.charcode != null ? original.charcode : original.keycode; } return event; } }, mousehooks: { props: "button buttons clientx clienty fromelement offsetx offsety pagex pagey screenx screeny toelement".split(" "), filter: function (event, original) { var eventdoc, doc, body, button = original.button, fromelement = original.fromelement; // calculate pagex/y if missing and clientx/y available if (event.pagex == null && original.clientx != null) { eventdoc = event.target.ownerdocument || document; doc = eventdoc.documentelement; body = eventdoc.body; event.pagex = original.clientx + (doc && doc.scrollleft || body && body.scrollleft || 0) - (doc && doc.clientleft || body && body.clientleft || 0); event.pagey = original.clienty + (doc && doc.scrolltop || body && body.scrolltop || 0) - (doc && doc.clienttop || body && body.clienttop || 0); } // add relatedtarget, if necessary if (!event.relatedtarget && fromelement) { event.relatedtarget = fromelement === event.target ? original.toelement : fromelement; } // add which for click: 1 === left; 2 === middle; 3 === right // note: button is not normalized, so don't use it if (!event.which && button !== undefined) { event.which = (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0))); } return event; } }, fix: function (event) { if (event[jquery.expando]) { return event; } // create a writable copy of the event object and normalize some properties var i, prop, originalevent = event, fixhook = jquery.event.fixhooks[event.type] || {}, copy = fixhook.props ? this.props.concat(fixhook.props) : this.props; event = jquery.event(originalevent); for (i = copy.length; i;) { prop = copy[--i]; event[prop] = originalevent[prop]; } // fix target property, if necessary (#1925, ie 6/7/8 & safari2) if (!event.target) { event.target = originalevent.srcelement || document; } // target should not be a text node (#504, safari) if (event.target.nodetype === 3) { event.target = event.target.parentnode; } // for mouse/key events, metakey==false if it's undefined (#3368, #11328; ie6/7/8) event.metakey = !!event.metakey; return fixhook.filter ? fixhook.filter(event, originalevent) : event; }, special: { load: { // prevent triggered image.load events from bubbling to window.load nobubble: true }, focus: { delegatetype: "focusin" }, blur: { delegatetype: "focusout" }, beforeunload: { setup: function (data, namespaces, eventhandle) { // we only want to do this special case on windows if (jquery.iswindow(this)) { this.onbeforeunload = eventhandle; } }, teardown: function (namespaces, eventhandle) { if (this.onbeforeunload === eventhandle) { this.onbeforeunload = null; } } } }, simulate: function (type, elem, event, bubble) { // piggyback on a donor event to simulate a different one. // fake originalevent to avoid donor's stoppropagation, but if the // simulated event prevents default then we do the same on the donor. var e = jquery.extend( new jquery.event(), event, { type: type, issimulated: true, originalevent: {} } ); if (bubble) { jquery.event.trigger(e, null, elem); } else { jquery.event.dispatch.call(elem, e); } if (e.isdefaultprevented()) { event.preventdefault(); } } }; // some plugins are using, but it's undocumented/deprecated and will be removed. // the 1.7 special event template should provide all the hooks needed now. jquery.event.handle = jquery.event.dispatch; jquery.removeevent = document.removeeventlistener ? function (elem, type, handle) { if (elem.removeeventlistener) { elem.removeeventlistener(type, handle, false); } } : function (elem, type, handle) { var name = "on" + type; if (elem.detachevent) { // #8545, #7054, preventing memory leaks for custom events in ie6-8 // detachevent needed property on element, by name of that event, to properly expose it to gc if (typeof elem[name] === "undefined") { elem[name] = null; } elem.detachevent(name, handle); } }; jquery.event = function (src, props) { // allow instantiation without the 'new' keyword if (!(this instanceof jquery.event)) { return new jquery.event(src, props); } // event object if (src && src.type) { this.originalevent = src; this.type = src.type; // events bubbling up the document may have been marked as prevented // by a handler lower down the tree; reflect the correct value. this.isdefaultprevented = (src.defaultprevented || src.returnvalue === false || src.getpreventdefault && src.getpreventdefault()) ? returntrue : returnfalse; // event type } else { this.type = src; } // put explicitly provided properties onto the event object if (props) { jquery.extend(this, props); } // create a timestamp if incoming event doesn't have one this.timestamp = src && src.timestamp || jquery.now(); // mark it as fixed this[jquery.expando] = true; }; function returnfalse() { return false; } function returntrue() { return true; } // jquery.event is based on dom3 events as specified by the ecmascript language binding // http://www.w3.org/tr/2003/wd-dom-level-3-events-20030331/ecma-script-binding.html jquery.event.prototype = { preventdefault: function () { this.isdefaultprevented = returntrue; var e = this.originalevent; if (!e) { return; } // if preventdefault exists run it on the original event if (e.preventdefault) { e.preventdefault(); // otherwise set the returnvalue property of the original event to false (ie) } else { e.returnvalue = false; } }, stoppropagation: function () { this.ispropagationstopped = returntrue; var e = this.originalevent; if (!e) { return; } // if stoppropagation exists run it on the original event if (e.stoppropagation) { e.stoppropagation(); } // otherwise set the cancelbubble property of the original event to true (ie) e.cancelbubble = true; }, stopimmediatepropagation: function () { this.isimmediatepropagationstopped = returntrue; this.stoppropagation(); }, isdefaultprevented: returnfalse, ispropagationstopped: returnfalse, isimmediatepropagationstopped: returnfalse }; // create mouseenter/leave events using mouseover/out and event-time checks jquery.each({ mouseenter: "mouseover", mouseleave: "mouseout" }, function (orig, fix) { jquery.event.special[orig] = { delegatetype: fix, bindtype: fix, handle: function (event) { var ret, target = this, related = event.relatedtarget, handleobj = event.handleobj, selector = handleobj.selector; // for mousenter/leave call the handler if related is outside the target. // nb: no relatedtarget if the mouse left/entered the browser window if (!related || (related !== target && !jquery.contains(target, related))) { event.type = handleobj.origtype; ret = handleobj.handler.apply(this, arguments); event.type = fix; } return ret; } }; }); // ie submit delegation if (!jquery.support.submitbubbles) { jquery.event.special.submit = { setup: function () { // only need this for delegated form submit events if (jquery.nodename(this, "form")) { return false; } // lazy-add a submit handler when a descendant form may potentially be submitted jquery.event.add(this, "click._submit keypress._submit", function (e) { // node name check avoids a vml-related crash in ie (#9807) var elem = e.target, form = jquery.nodename(elem, "input") || jquery.nodename(elem, "button") ? elem.form : undefined; if (form && !jquery._data(form, "_submit_attached")) { jquery.event.add(form, "submit._submit", function (event) { event._submit_bubble = true; }); jquery._data(form, "_submit_attached", true); } }); // return undefined since we don't need an event listener }, postdispatch: function (event) { // if form was submitted by the user, bubble the event up the tree if (event._submit_bubble) { delete event._submit_bubble; if (this.parentnode && !event.istrigger) { jquery.event.simulate("submit", this.parentnode, event, true); } } }, teardown: function () { // only need this for delegated form submit events if (jquery.nodename(this, "form")) { return false; } // remove delegated handlers; cleandata eventually reaps submit handlers attached above jquery.event.remove(this, "._submit"); } }; } // ie change delegation and checkbox/radio fix if (!jquery.support.changebubbles) { jquery.event.special.change = { setup: function () { if (rformelems.test(this.nodename)) { // ie doesn't fire change on a check/radio until blur; trigger it on click // after a propertychange. eat the blur-change in special.change.handle. // this still fires onchange a second time for check/radio after blur. if (this.type === "checkbox" || this.type === "radio") { jquery.event.add(this, "propertychange._change", function (event) { if (event.originalevent.propertyname === "checked") { this._just_changed = true; } }); jquery.event.add(this, "click._change", function (event) { if (this._just_changed && !event.istrigger) { this._just_changed = false; } // allow triggered, simulated change events (#11500) jquery.event.simulate("change", this, event, true); }); } return false; } // delegated event; lazy-add a change handler on descendant inputs jquery.event.add(this, "beforeactivate._change", function (e) { var elem = e.target; if (rformelems.test(elem.nodename) && !jquery._data(elem, "_change_attached")) { jquery.event.add(elem, "change._change", function (event) { if (this.parentnode && !event.issimulated && !event.istrigger) { jquery.event.simulate("change", this.parentnode, event, true); } }); jquery._data(elem, "_change_attached", true); } }); }, handle: function (event) { var elem = event.target; // swallow native change events from checkbox/radio, we already triggered them above if (this !== elem || event.issimulated || event.istrigger || (elem.type !== "radio" && elem.type !== "checkbox")) { return event.handleobj.handler.apply(this, arguments); } }, teardown: function () { jquery.event.remove(this, "._change"); return !rformelems.test(this.nodename); } }; } // create "bubbling" focus and blur events if (!jquery.support.focusinbubbles) { jquery.each({ focus: "focusin", blur: "focusout" }, function (orig, fix) { // attach a single capturing handler while someone wants focusin/focusout var attaches = 0, handler = function (event) { jquery.event.simulate(fix, event.target, jquery.event.fix(event), true); }; jquery.event.special[fix] = { setup: function () { if (attaches++ === 0) { document.addeventlistener(orig, handler, true); } }, teardown: function () { if (--attaches === 0) { document.removeeventlistener(orig, handler, true); } } }; }); } jquery.fn.extend({ on: function (types, selector, data, fn, /*internal*/ one) { var origfn, type; // types can be a map of types/handlers if (typeof types === "object") { // ( types-object, selector, data ) if (typeof selector !== "string") { // && selector != null // ( types-object, data ) data = data || selector; selector = undefined; } for (type in types) { this.on(type, selector, data, types[type], one); } return this; } if (data == null && fn == null) { // ( types, fn ) fn = selector; data = selector = undefined; } else if (fn == null) { if (typeof selector === "string") { // ( types, selector, fn ) fn = data; data = undefined; } else { // ( types, data, fn ) fn = data; data = selector; selector = undefined; } } if (fn === false) { fn = returnfalse; } else if (!fn) { return this; } if (one === 1) { origfn = fn; fn = function (event) { // can use an empty set, since event contains the info jquery().off(event); return origfn.apply(this, arguments); }; // use same guid so caller can remove using origfn fn.guid = origfn.guid || (origfn.guid = jquery.guid++); } return this.each(function () { jquery.event.add(this, types, fn, data, selector); }); }, one: function (types, selector, data, fn) { return this.on(types, selector, data, fn, 1); }, off: function (types, selector, fn) { var handleobj, type; if (types && types.preventdefault && types.handleobj) { // ( event ) dispatched jquery.event handleobj = types.handleobj; jquery(types.delegatetarget).off( handleobj.namespace ? handleobj.origtype + "." + handleobj.namespace : handleobj.origtype, handleobj.selector, handleobj.handler ); return this; } if (typeof types === "object") { // ( types-object [, selector] ) for (type in types) { this.off(type, selector, types[type]); } return this; } if (selector === false || typeof selector === "function") { // ( types [, fn] ) fn = selector; selector = undefined; } if (fn === false) { fn = returnfalse; } return this.each(function () { jquery.event.remove(this, types, fn, selector); }); }, bind: function (types, data, fn) { return this.on(types, null, data, fn); }, unbind: function (types, fn) { return this.off(types, null, fn); }, live: function (types, data, fn) { jquery(this.context).on(types, this.selector, data, fn); return this; }, die: function (types, fn) { jquery(this.context).off(types, this.selector || "**", fn); return this; }, delegate: function (selector, types, data, fn) { return this.on(types, selector, data, fn); }, undelegate: function (selector, types, fn) { // ( namespace ) or ( selector, types [, fn] ) return arguments.length === 1 ? this.off(selector, "**") : this.off(types, selector || "**", fn); }, trigger: function (type, data) { return this.each(function () { jquery.event.trigger(type, data, this); }); }, triggerhandler: function (type, data) { if (this[0]) { return jquery.event.trigger(type, data, this[0], true); } }, toggle: function (fn) { // save reference to arguments for access in closure var args = arguments, guid = fn.guid || jquery.guid++, i = 0, toggler = function (event) { // figure out which function to execute var lasttoggle = (jquery._data(this, "lasttoggle" + fn.guid) || 0) % i; jquery._data(this, "lasttoggle" + fn.guid, lasttoggle + 1); // make sure that clicks stop event.preventdefault(); // and execute the function return args[lasttoggle].apply(this, arguments) || false; }; // link all the functions, so any of them can unbind this click handler toggler.guid = guid; while (i < args.length) { args[i++].guid = guid; } return this.click(toggler); }, hover: function (fnover, fnout) { return this.mouseenter(fnover).mouseleave(fnout || fnover); } }); jquery.each(("blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup error contextmenu").split(" "), function (i, name) { // handle event binding jquery.fn[name] = function (data, fn) { if (fn == null) { fn = data; data = null; } return arguments.length > 0 ? this.on(name, null, data, fn) : this.trigger(name); }; if (rkeyevent.test(name)) { jquery.event.fixhooks[name] = jquery.event.keyhooks; } if (rmouseevent.test(name)) { jquery.event.fixhooks[name] = jquery.event.mousehooks; } }); /*! * sizzle css selector engine * copyright 2012 jquery foundation and other contributors * released under the mit license * http://sizzlejs.com/ */ (function (window, undefined) { var cachedruns, assertgetidnotname, expr, gettext, isxml, contains, compile, sortorder, hasduplicate, outermostcontext, basehasduplicate = true, strundefined = "undefined", expando = ("sizcache" + math.random()).replace(".", ""), token = string, document = window.document, docelem = document.documentelement, dirruns = 0, done = 0, pop = [].pop, push = [].push, slice = [].slice, // use a stripped-down indexof if a native one is unavailable indexof = [].indexof || function (elem) { var i = 0, len = this.length; for (; i < len; i++) { if (this[i] === elem) { return i; } } return -1; }, // augment a function for special use by sizzle markfunction = function (fn, value) { fn[expando] = value == null || value; return fn; }, createcache = function () { var cache = {}, keys = []; return markfunction(function (key, value) { // only keep the most recent entries if (keys.push(key) > expr.cachelength) { delete cache[keys.shift()]; } // retrieve with (key + " ") to avoid collision with native object.prototype properties (see issue #157) return (cache[key + " "] = value); }, cache); }, classcache = createcache(), tokencache = createcache(), compilercache = createcache(), // regex // whitespace characters http://www.w3.org/tr/css3-selectors/#whitespace whitespace = "[\\x20\\t\\r\\n\\f]", // http://www.w3.org/tr/css3-syntax/#characters characterencoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+", // loosely modeled on css identifier characters // an unquoted value should be a css identifier (http://www.w3.org/tr/css3-selectors/#attribute-selectors) // proper syntax: http://www.w3.org/tr/css21/syndata.html#value-def-identifier identifier = characterencoding.replace("w", "w#"), // acceptable operators http://www.w3.org/tr/selectors/#attribute-selectors operators = "([*^$|!~]?=)", attributes = "\\[" + whitespace + "*(" + characterencoding + ")" + whitespace + "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", // prefer arguments not in parens/brackets, // then attribute selectors and non-pseudos (denoted by :), // then anything else // these preferences are here to reduce the number of selectors // needing tokenize in the pseudo prefilter pseudos = ":(" + characterencoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)", // for matchexpr.pos and matchexpr.needscontext pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", // leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter rtrim = new regexp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), rcomma = new regexp("^" + whitespace + "*," + whitespace + "*"), rcombinators = new regexp("^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*"), rpseudo = new regexp(pseudos), // easily-parseable/retrievable id or tag or class selectors rquickexpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/, rnot = /^:not/, rsibling = /[\x20\t\r\n\f]*[+~]/, rendswithnot = /:not\($/, rheader = /h\d/i, rinputs = /input|select|textarea|button/i, rbackslash = /\\(?!\\)/g, matchexpr = { "id": new regexp("^#(" + characterencoding + ")"), "class": new regexp("^\\.(" + characterencoding + ")"), "name": new regexp("^\\[name=['\"]?(" + characterencoding + ")['\"]?\\]"), "tag": new regexp("^(" + characterencoding.replace("w", "w*") + ")"), "attr": new regexp("^" + attributes), "pseudo": new regexp("^" + pseudos), "pos": new regexp(pos, "i"), "child": new regexp("^:(only|nth|first|last)-child(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"), // for use in libraries implementing .is() "needscontext": new regexp("^" + whitespace + "*[>+~]|" + pos, "i") }, // support // used for testing something on an element assert = function (fn) { var div = document.createelement("div"); try { return fn(div); } catch (e) { return false; } finally { // release memory in ie div = null; } }, // check if getelementsbytagname("*") returns only elements asserttagnamenocomments = assert(function (div) { div.appendchild(document.createcomment("")); return !div.getelementsbytagname("*").length; }), // check if getattribute returns normalized href attributes asserthrefnotnormalized = assert(function (div) { div.innerhtml = ""; return div.firstchild && typeof div.firstchild.getattribute !== strundefined && div.firstchild.getattribute("href") === "#"; }), // check if attributes should be retrieved by attribute nodes assertattributes = assert(function (div) { div.innerhtml = ""; var type = typeof div.lastchild.getattribute("multiple"); // ie8 returns a string for some attributes even when not present return type !== "boolean" && type !== "string"; }), // check if getelementsbyclassname can be trusted assertusableclassname = assert(function (div) { // opera can't find a second classname (in 9.6) div.innerhtml = ""; if (!div.getelementsbyclassname || !div.getelementsbyclassname("e").length) { return false; } // safari 3.2 caches class attributes and doesn't catch changes div.lastchild.classname = "e"; return div.getelementsbyclassname("e").length === 2; }), // check if getelementbyid returns elements by name // check if getelementsbyname privileges form controls or returns elements by id assertusablename = assert(function (div) { // inject content div.id = expando + 0; div.innerhtml = "
"; docelem.insertbefore(div, docelem.firstchild); // test var pass = document.getelementsbyname && // buggy browsers will return fewer than the correct 2 document.getelementsbyname(expando).length === 2 + // buggy browsers will return more than the correct 0 document.getelementsbyname(expando + 0).length; assertgetidnotname = !document.getelementbyid(expando); // cleanup docelem.removechild(div); return pass; }); // if slice is not available, provide a backup try { slice.call(docelem.childnodes, 0)[0].nodetype; } catch (e) { slice = function (i) { var elem, results = []; for (; (elem = this[i]) ; i++) { results.push(elem); } return results; }; } function sizzle(selector, context, results, seed) { results = results || []; context = context || document; var match, elem, xml, m, nodetype = context.nodetype; if (!selector || typeof selector !== "string") { return results; } if (nodetype !== 1 && nodetype !== 9) { return []; } xml = isxml(context); if (!xml && !seed) { if ((match = rquickexpr.exec(selector))) { // speed-up: sizzle("#id") if ((m = match[1])) { if (nodetype === 9) { elem = context.getelementbyid(m); // check parentnode to catch when blackberry 4.6 returns // nodes that are no longer in the document #6963 if (elem && elem.parentnode) { // handle the case where ie, opera, and webkit return items // by name instead of id if (elem.id === m) { results.push(elem); return results; } } else { return results; } } else { // context is not a document if (context.ownerdocument && (elem = context.ownerdocument.getelementbyid(m)) && contains(context, elem) && elem.id === m) { results.push(elem); return results; } } // speed-up: sizzle("tag") } else if (match[2]) { push.apply(results, slice.call(context.getelementsbytagname(selector), 0)); return results; // speed-up: sizzle(".class") } else if ((m = match[3]) && assertusableclassname && context.getelementsbyclassname) { push.apply(results, slice.call(context.getelementsbyclassname(m), 0)); return results; } } } // all others return select(selector.replace(rtrim, "$1"), context, results, seed, xml); } sizzle.matches = function (expr, elements) { return sizzle(expr, null, null, elements); }; sizzle.matchesselector = function (elem, expr) { return sizzle(expr, null, null, [elem]).length > 0; }; // returns a function to use in pseudos for input types function createinputpseudo(type) { return function (elem) { var name = elem.nodename.tolowercase(); return name === "input" && elem.type === type; }; } // returns a function to use in pseudos for buttons function createbuttonpseudo(type) { return function (elem) { var name = elem.nodename.tolowercase(); return (name === "input" || name === "button") && elem.type === type; }; } // returns a function to use in pseudos for positionals function createpositionalpseudo(fn) { return markfunction(function (argument) { argument = +argument; return markfunction(function (seed, matches) { var j, matchindexes = fn([], seed.length, argument), i = matchindexes.length; // match elements found at the specified indexes while (i--) { if (seed[(j = matchindexes[i])]) { seed[j] = !(matches[j] = seed[j]); } } }); }); } /** * utility function for retrieving the text value of an array of dom nodes * @param {array|element} elem */ gettext = sizzle.gettext = function (elem) { var node, ret = "", i = 0, nodetype = elem.nodetype; if (nodetype) { if (nodetype === 1 || nodetype === 9 || nodetype === 11) { // use textcontent for elements // innertext usage removed for consistency of new lines (see #11153) if (typeof elem.textcontent === "string") { return elem.textcontent; } else { // traverse its children for (elem = elem.firstchild; elem; elem = elem.nextsibling) { ret += gettext(elem); } } } else if (nodetype === 3 || nodetype === 4) { return elem.nodevalue; } // do not include comment or processing instruction nodes } else { // if no nodetype, this is expected to be an array for (; (node = elem[i]) ; i++) { // do not traverse comment nodes ret += gettext(node); } } return ret; }; isxml = sizzle.isxml = function (elem) { // documentelement is verified for cases where it doesn't yet exist // (such as loading iframes in ie - #4833) var documentelement = elem && (elem.ownerdocument || elem).documentelement; return documentelement ? documentelement.nodename !== "html" : false; }; // element contains another contains = sizzle.contains = docelem.contains ? function (a, b) { var adown = a.nodetype === 9 ? a.documentelement : a, bup = b && b.parentnode; return a === bup || !!(bup && bup.nodetype === 1 && adown.contains && adown.contains(bup)); } : docelem.comparedocumentposition ? function (a, b) { return b && !!(a.comparedocumentposition(b) & 16); } : function (a, b) { while ((b = b.parentnode)) { if (b === a) { return true; } } return false; }; sizzle.attr = function (elem, name) { var val, xml = isxml(elem); if (!xml) { name = name.tolowercase(); } if ((val = expr.attrhandle[name])) { return val(elem); } if (xml || assertattributes) { return elem.getattribute(name); } val = elem.getattributenode(name); return val ? typeof elem[name] === "boolean" ? elem[name] ? name : null : val.specified ? val.value : null : null; }; expr = sizzle.selectors = { // can be adjusted by the user cachelength: 50, createpseudo: markfunction, match: matchexpr, // ie6/7 return a modified href attrhandle: asserthrefnotnormalized ? {} : { "href": function (elem) { return elem.getattribute("href", 2); }, "type": function (elem) { return elem.getattribute("type"); } }, find: { "id": assertgetidnotname ? function (id, context, xml) { if (typeof context.getelementbyid !== strundefined && !xml) { var m = context.getelementbyid(id); // check parentnode to catch when blackberry 4.6 returns // nodes that are no longer in the document #6963 return m && m.parentnode ? [m] : []; } } : function (id, context, xml) { if (typeof context.getelementbyid !== strundefined && !xml) { var m = context.getelementbyid(id); return m ? m.id === id || typeof m.getattributenode !== strundefined && m.getattributenode("id").value === id ? [m] : undefined : []; } }, "tag": asserttagnamenocomments ? function (tag, context) { if (typeof context.getelementsbytagname !== strundefined) { return context.getelementsbytagname(tag); } } : function (tag, context) { var results = context.getelementsbytagname(tag); // filter out possible comments if (tag === "*") { var elem, tmp = [], i = 0; for (; (elem = results[i]) ; i++) { if (elem.nodetype === 1) { tmp.push(elem); } } return tmp; } return results; }, "name": assertusablename && function (tag, context) { if (typeof context.getelementsbyname !== strundefined) { return context.getelementsbyname(name); } }, "class": assertusableclassname && function (classname, context, xml) { if (typeof context.getelementsbyclassname !== strundefined && !xml) { return context.getelementsbyclassname(classname); } } }, relative: { ">": { dir: "parentnode", first: true }, " ": { dir: "parentnode" }, "+": { dir: "previoussibling", first: true }, "~": { dir: "previoussibling" } }, prefilter: { "attr": function (match) { match[1] = match[1].replace(rbackslash, ""); // move the given value to match[3] whether quoted or unquoted match[3] = (match[4] || match[5] || "").replace(rbackslash, ""); if (match[2] === "~=") { match[3] = " " + match[3] + " "; } return match.slice(0, 4); }, "child": function (match) { /* matches from matchexpr["child"] 1 type (only|nth|...) 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 3 xn-component of xn+y argument ([+-]?\d*n|) 4 sign of xn-component 5 x of xn-component 6 sign of y-component 7 y of y-component */ match[1] = match[1].tolowercase(); if (match[1] === "nth") { // nth-child requires argument if (!match[2]) { sizzle.error(match[0]); } // numeric x and y parameters for expr.filter.child // remember that false/true cast respectively to 0/1 match[3] = +(match[3] ? match[4] + (match[5] || 1) : 2 * (match[2] === "even" || match[2] === "odd")); match[4] = +((match[6] + match[7]) || match[2] === "odd"); // other types prohibit arguments } else if (match[2]) { sizzle.error(match[0]); } return match; }, "pseudo": function (match) { var unquoted, excess; if (matchexpr["child"].test(match[0])) { return null; } if (match[3]) { match[2] = match[3]; } else if ((unquoted = match[4])) { // only check arguments that contain a pseudo if (rpseudo.test(unquoted) && // get excess from tokenize (recursively) (excess = tokenize(unquoted, true)) && // advance to the next closing parenthesis (excess = unquoted.indexof(")", unquoted.length - excess) - unquoted.length)) { // excess is a negative index unquoted = unquoted.slice(0, excess); match[0] = match[0].slice(0, excess); } match[2] = unquoted; } // return only captures needed by the pseudo filter method (type and argument) return match.slice(0, 3); } }, filter: { "id": assertgetidnotname ? function (id) { id = id.replace(rbackslash, ""); return function (elem) { return elem.getattribute("id") === id; }; } : function (id) { id = id.replace(rbackslash, ""); return function (elem) { var node = typeof elem.getattributenode !== strundefined && elem.getattributenode("id"); return node && node.value === id; }; }, "tag": function (nodename) { if (nodename === "*") { return function () { return true; }; } nodename = nodename.replace(rbackslash, "").tolowercase(); return function (elem) { return elem.nodename && elem.nodename.tolowercase() === nodename; }; }, "class": function (classname) { var pattern = classcache[expando][classname + " "]; return pattern || (pattern = new regexp("(^|" + whitespace + ")" + classname + "(" + whitespace + "|$)")) && classcache(classname, function (elem) { return pattern.test(elem.classname || (typeof elem.getattribute !== strundefined && elem.getattribute("class")) || ""); }); }, "attr": function (name, operator, check) { return function (elem, context) { var result = sizzle.attr(elem, name); if (result == null) { return operator === "!="; } if (!operator) { return true; } result += ""; return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexof(check) === 0 : operator === "*=" ? check && result.indexof(check) > -1 : operator === "$=" ? check && result.substr(result.length - check.length) === check : operator === "~=" ? (" " + result + " ").indexof(check) > -1 : operator === "|=" ? result === check || result.substr(0, check.length + 1) === check + "-" : false; }; }, "child": function (type, argument, first, last) { if (type === "nth") { return function (elem) { var node, diff, parent = elem.parentnode; if (first === 1 && last === 0) { return true; } if (parent) { diff = 0; for (node = parent.firstchild; node; node = node.nextsibling) { if (node.nodetype === 1) { diff++; if (elem === node) { break; } } } } // incorporate the offset (or cast to nan), then check against cycle size diff -= last; return diff === first || (diff % first === 0 && diff / first >= 0); }; } return function (elem) { var node = elem; switch (type) { case "only": case "first": while ((node = node.previoussibling)) { if (node.nodetype === 1) { return false; } } if (type === "first") { return true; } node = elem; /* falls through */ case "last": while ((node = node.nextsibling)) { if (node.nodetype === 1) { return false; } } return true; } }; }, "pseudo": function (pseudo, argument) { // pseudo-class names are case-insensitive // http://www.w3.org/tr/selectors/#pseudo-classes // prioritize by case sensitivity in case custom pseudos are added with uppercase letters // remember that setfilters inherits from pseudos var args, fn = expr.pseudos[pseudo] || expr.setfilters[pseudo.tolowercase()] || sizzle.error("unsupported pseudo: " + pseudo); // the user may use createpseudo to indicate that // arguments are needed to create the filter function // just as sizzle does if (fn[expando]) { return fn(argument); } // but maintain support for old signatures if (fn.length > 1) { args = [pseudo, pseudo, "", argument]; return expr.setfilters.hasownproperty(pseudo.tolowercase()) ? markfunction(function (seed, matches) { var idx, matched = fn(seed, argument), i = matched.length; while (i--) { idx = indexof.call(seed, matched[i]); seed[idx] = !(matches[idx] = matched[i]); } }) : function (elem) { return fn(elem, 0, args); }; } return fn; } }, pseudos: { "not": markfunction(function (selector) { // trim the selector passed to compile // to avoid treating leading and trailing // spaces as combinators var input = [], results = [], matcher = compile(selector.replace(rtrim, "$1")); return matcher[expando] ? markfunction(function (seed, matches, context, xml) { var elem, unmatched = matcher(seed, null, xml, []), i = seed.length; // match elements unmatched by `matcher` while (i--) { if ((elem = unmatched[i])) { seed[i] = !(matches[i] = elem); } } }) : function (elem, context, xml) { input[0] = elem; matcher(input, null, xml, results); return !results.pop(); }; }), "has": markfunction(function (selector) { return function (elem) { return sizzle(selector, elem).length > 0; }; }), "contains": markfunction(function (text) { return function (elem) { return (elem.textcontent || elem.innertext || gettext(elem)).indexof(text) > -1; }; }), "enabled": function (elem) { return elem.disabled === false; }, "disabled": function (elem) { return elem.disabled === true; }, "checked": function (elem) { // in css3, :checked should return both checked and selected elements // http://www.w3.org/tr/2011/rec-css3-selectors-20110929/#checked var nodename = elem.nodename.tolowercase(); return (nodename === "input" && !!elem.checked) || (nodename === "option" && !!elem.selected); }, "selected": function (elem) { // accessing this property makes selected-by-default // options in safari work properly if (elem.parentnode) { elem.parentnode.selectedindex; } return elem.selected === true; }, "parent": function (elem) { return !expr.pseudos["empty"](elem); }, "empty": function (elem) { // http://www.w3.org/tr/selectors/#empty-pseudo // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), // not comment, processing instructions, or others // thanks to diego perini for the nodename shortcut // greater than "@" means alpha characters (specifically not starting with "#" or "?") var nodetype; elem = elem.firstchild; while (elem) { if (elem.nodename > "@" || (nodetype = elem.nodetype) === 3 || nodetype === 4) { return false; } elem = elem.nextsibling; } return true; }, "header": function (elem) { return rheader.test(elem.nodename); }, "text": function (elem) { var type, attr; // ie6 and 7 will map elem.type to 'text' for new html5 types (search, etc) // use getattribute instead to test this case return elem.nodename.tolowercase() === "input" && (type = elem.type) === "text" && ((attr = elem.getattribute("type")) == null || attr.tolowercase() === type); }, // input types "radio": createinputpseudo("radio"), "checkbox": createinputpseudo("checkbox"), "file": createinputpseudo("file"), "password": createinputpseudo("password"), "image": createinputpseudo("image"), "submit": createbuttonpseudo("submit"), "reset": createbuttonpseudo("reset"), "button": function (elem) { var name = elem.nodename.tolowercase(); return name === "input" && elem.type === "button" || name === "button"; }, "input": function (elem) { return rinputs.test(elem.nodename); }, "focus": function (elem) { var doc = elem.ownerdocument; return elem === doc.activeelement && (!doc.hasfocus || doc.hasfocus()) && !!(elem.type || elem.href || ~elem.tabindex); }, "active": function (elem) { return elem === elem.ownerdocument.activeelement; }, // positional types "first": createpositionalpseudo(function () { return [0]; }), "last": createpositionalpseudo(function (matchindexes, length) { return [length - 1]; }), "eq": createpositionalpseudo(function (matchindexes, length, argument) { return [argument < 0 ? argument + length : argument]; }), "even": createpositionalpseudo(function (matchindexes, length) { for (var i = 0; i < length; i += 2) { matchindexes.push(i); } return matchindexes; }), "odd": createpositionalpseudo(function (matchindexes, length) { for (var i = 1; i < length; i += 2) { matchindexes.push(i); } return matchindexes; }), "lt": createpositionalpseudo(function (matchindexes, length, argument) { for (var i = argument < 0 ? argument + length : argument; --i >= 0;) { matchindexes.push(i); } return matchindexes; }), "gt": createpositionalpseudo(function (matchindexes, length, argument) { for (var i = argument < 0 ? argument + length : argument; ++i < length;) { matchindexes.push(i); } return matchindexes; }) } }; function siblingcheck(a, b, ret) { if (a === b) { return ret; } var cur = a.nextsibling; while (cur) { if (cur === b) { return -1; } cur = cur.nextsibling; } return 1; } sortorder = docelem.comparedocumentposition ? function (a, b) { if (a === b) { hasduplicate = true; return 0; } return (!a.comparedocumentposition || !b.comparedocumentposition ? a.comparedocumentposition : a.comparedocumentposition(b) & 4 ) ? -1 : 1; } : function (a, b) { // the nodes are identical, we can exit early if (a === b) { hasduplicate = true; return 0; // fallback to using sourceindex (in ie) if it's available on both nodes } else if (a.sourceindex && b.sourceindex) { return a.sourceindex - b.sourceindex; } var al, bl, ap = [], bp = [], aup = a.parentnode, bup = b.parentnode, cur = aup; // if the nodes are siblings (or identical) we can do a quick check if (aup === bup) { return siblingcheck(a, b); // if no parents were found then the nodes are disconnected } else if (!aup) { return -1; } else if (!bup) { return 1; } // otherwise they're somewhere else in the tree so we need // to build up a full list of the parentnodes for comparison while (cur) { ap.unshift(cur); cur = cur.parentnode; } cur = bup; while (cur) { bp.unshift(cur); cur = cur.parentnode; } al = ap.length; bl = bp.length; // start walking down the tree looking for a discrepancy for (var i = 0; i < al && i < bl; i++) { if (ap[i] !== bp[i]) { return siblingcheck(ap[i], bp[i]); } } // we ended someplace up the tree so do a sibling check return i === al ? siblingcheck(a, bp[i], -1) : siblingcheck(ap[i], b, 1); }; // always assume the presence of duplicates if sort doesn't // pass them to our comparison function (as in google chrome). [0, 0].sort(sortorder); basehasduplicate = !hasduplicate; // document sorting and removing duplicates sizzle.uniquesort = function (results) { var elem, duplicates = [], i = 1, j = 0; hasduplicate = basehasduplicate; results.sort(sortorder); if (hasduplicate) { for (; (elem = results[i]) ; i++) { if (elem === results[i - 1]) { j = duplicates.push(i); } } while (j--) { results.splice(duplicates[j], 1); } } return results; }; sizzle.error = function (msg) { throw new error("syntax error, unrecognized expression: " + msg); }; function tokenize(selector, parseonly) { var matched, match, tokens, type, sofar, groups, prefilters, cached = tokencache[expando][selector + " "]; if (cached) { return parseonly ? 0 : cached.slice(0); } sofar = selector; groups = []; prefilters = expr.prefilter; while (sofar) { // comma and first run if (!matched || (match = rcomma.exec(sofar))) { if (match) { // don't consume trailing commas as valid sofar = sofar.slice(match[0].length) || sofar; } groups.push(tokens = []); } matched = false; // combinators if ((match = rcombinators.exec(sofar))) { tokens.push(matched = new token(match.shift())); sofar = sofar.slice(matched.length); // cast descendant combinators to space matched.type = match[0].replace(rtrim, " "); } // filters for (type in expr.filter) { if ((match = matchexpr[type].exec(sofar)) && (!prefilters[type] || (match = prefilters[type](match)))) { tokens.push(matched = new token(match.shift())); sofar = sofar.slice(matched.length); matched.type = type; matched.matches = match; } } if (!matched) { break; } } // return the length of the invalid excess // if we're just parsing // otherwise, throw an error or return tokens return parseonly ? sofar.length : sofar ? sizzle.error(selector) : // cache the tokens tokencache(selector, groups).slice(0); } function addcombinator(matcher, combinator, base) { var dir = combinator.dir, checknonelements = base && combinator.dir === "parentnode", donename = done++; return combinator.first ? // check against closest ancestor/preceding element function (elem, context, xml) { while ((elem = elem[dir])) { if (checknonelements || elem.nodetype === 1) { return matcher(elem, context, xml); } } } : // check against all ancestor/preceding elements function (elem, context, xml) { // we can't set arbitrary data on xml nodes, so they don't benefit from dir caching if (!xml) { var cache, dirkey = dirruns + " " + donename + " ", cachedkey = dirkey + cachedruns; while ((elem = elem[dir])) { if (checknonelements || elem.nodetype === 1) { if ((cache = elem[expando]) === cachedkey) { return elem.sizset; } else if (typeof cache === "string" && cache.indexof(dirkey) === 0) { if (elem.sizset) { return elem; } } else { elem[expando] = cachedkey; if (matcher(elem, context, xml)) { elem.sizset = true; return elem; } elem.sizset = false; } } } } else { while ((elem = elem[dir])) { if (checknonelements || elem.nodetype === 1) { if (matcher(elem, context, xml)) { return elem; } } } } }; } function elementmatcher(matchers) { return matchers.length > 1 ? function (elem, context, xml) { var i = matchers.length; while (i--) { if (!matchers[i](elem, context, xml)) { return false; } } return true; } : matchers[0]; } function condense(unmatched, map, filter, context, xml) { var elem, newunmatched = [], i = 0, len = unmatched.length, mapped = map != null; for (; i < len; i++) { if ((elem = unmatched[i])) { if (!filter || filter(elem, context, xml)) { newunmatched.push(elem); if (mapped) { map.push(i); } } } } return newunmatched; } function setmatcher(prefilter, selector, matcher, postfilter, postfinder, postselector) { if (postfilter && !postfilter[expando]) { postfilter = setmatcher(postfilter); } if (postfinder && !postfinder[expando]) { postfinder = setmatcher(postfinder, postselector); } return markfunction(function (seed, results, context, xml) { var temp, i, elem, premap = [], postmap = [], preexisting = results.length, // get initial elements from seed or context elems = seed || multiplecontexts(selector || "*", context.nodetype ? [context] : context, []), // prefilter to get matcher input, preserving a map for seed-results synchronization matcherin = prefilter && (seed || !selector) ? condense(elems, premap, prefilter, context, xml) : elems, matcherout = matcher ? // if we have a postfinder, or filtered seed, or non-seed postfilter or preexisting results, postfinder || (seed ? prefilter : preexisting || postfilter) ? // ...intermediate processing is necessary [] : // ...otherwise use results directly results : matcherin; // find primary matches if (matcher) { matcher(matcherin, matcherout, context, xml); } // apply postfilter if (postfilter) { temp = condense(matcherout, postmap); postfilter(temp, [], context, xml); // un-match failing elements by moving them back to matcherin i = temp.length; while (i--) { if ((elem = temp[i])) { matcherout[postmap[i]] = !(matcherin[postmap[i]] = elem); } } } if (seed) { if (postfinder || prefilter) { if (postfinder) { // get the final matcherout by condensing this intermediate into postfinder contexts temp = []; i = matcherout.length; while (i--) { if ((elem = matcherout[i])) { // restore matcherin since elem is not yet a final match temp.push((matcherin[i] = elem)); } } postfinder(null, (matcherout = []), temp, xml); } // move matched elements from seed to results to keep them synchronized i = matcherout.length; while (i--) { if ((elem = matcherout[i]) && (temp = postfinder ? indexof.call(seed, elem) : premap[i]) > -1) { seed[temp] = !(results[temp] = elem); } } } // add elements to results, through postfinder if defined } else { matcherout = condense( matcherout === results ? matcherout.splice(preexisting, matcherout.length) : matcherout ); if (postfinder) { postfinder(null, results, matcherout, xml); } else { push.apply(results, matcherout); } } }); } function matcherfromtokens(tokens) { var checkcontext, matcher, j, len = tokens.length, leadingrelative = expr.relative[tokens[0].type], implicitrelative = leadingrelative || expr.relative[" "], i = leadingrelative ? 1 : 0, // the foundational matcher ensures that elements are reachable from top-level context(s) matchcontext = addcombinator(function (elem) { return elem === checkcontext; }, implicitrelative, true), matchanycontext = addcombinator(function (elem) { return indexof.call(checkcontext, elem) > -1; }, implicitrelative, true), matchers = [function (elem, context, xml) { return (!leadingrelative && (xml || context !== outermostcontext)) || ( (checkcontext = context).nodetype ? matchcontext(elem, context, xml) : matchanycontext(elem, context, xml)); }]; for (; i < len; i++) { if ((matcher = expr.relative[tokens[i].type])) { matchers = [addcombinator(elementmatcher(matchers), matcher)]; } else { matcher = expr.filter[tokens[i].type].apply(null, tokens[i].matches); // return special upon seeing a positional matcher if (matcher[expando]) { // find the next relative operator (if any) for proper handling j = ++i; for (; j < len; j++) { if (expr.relative[tokens[j].type]) { break; } } return setmatcher( i > 1 && elementmatcher(matchers), i > 1 && tokens.slice(0, i - 1).join("").replace(rtrim, "$1"), matcher, i < j && matcherfromtokens(tokens.slice(i, j)), j < len && matcherfromtokens((tokens = tokens.slice(j))), j < len && tokens.join("") ); } matchers.push(matcher); } } return elementmatcher(matchers); } function matcherfromgroupmatchers(elementmatchers, setmatchers) { var byset = setmatchers.length > 0, byelement = elementmatchers.length > 0, supermatcher = function (seed, context, xml, results, expandcontext) { var elem, j, matcher, setmatched = [], matchedcount = 0, i = "0", unmatched = seed && [], outermost = expandcontext != null, contextbackup = outermostcontext, // we must always have either seed elements or context elems = seed || byelement && expr.find["tag"]("*", expandcontext && context.parentnode || context), // nested matchers should use non-integer dirruns dirrunsunique = (dirruns += contextbackup == null ? 1 : math.e); if (outermost) { outermostcontext = context !== document && context; cachedruns = supermatcher.el; } // add elements passing elementmatchers directly to results for (; (elem = elems[i]) != null; i++) { if (byelement && elem) { for (j = 0; (matcher = elementmatchers[j]) ; j++) { if (matcher(elem, context, xml)) { results.push(elem); break; } } if (outermost) { dirruns = dirrunsunique; cachedruns = ++supermatcher.el; } } // track unmatched elements for set filters if (byset) { // they will have gone through all possible matchers if ((elem = !matcher && elem)) { matchedcount--; } // lengthen the array for every element, matched or not if (seed) { unmatched.push(elem); } } } // apply set filters to unmatched elements matchedcount += i; if (byset && i !== matchedcount) { for (j = 0; (matcher = setmatchers[j]) ; j++) { matcher(unmatched, setmatched, context, xml); } if (seed) { // reintegrate element matches to eliminate the need for sorting if (matchedcount > 0) { while (i--) { if (!(unmatched[i] || setmatched[i])) { setmatched[i] = pop.call(results); } } } // discard index placeholder values to get only actual matches setmatched = condense(setmatched); } // add matches to results push.apply(results, setmatched); // seedless set matches succeeding multiple successful matchers stipulate sorting if (outermost && !seed && setmatched.length > 0 && (matchedcount + setmatchers.length) > 1) { sizzle.uniquesort(results); } } // override manipulation of globals by nested matchers if (outermost) { dirruns = dirrunsunique; outermostcontext = contextbackup; } return unmatched; }; supermatcher.el = 0; return byset ? markfunction(supermatcher) : supermatcher; } compile = sizzle.compile = function (selector, group /* internal use only */) { var i, setmatchers = [], elementmatchers = [], cached = compilercache[expando][selector + " "]; if (!cached) { // generate a function of recursive functions that can be used to check each element if (!group) { group = tokenize(selector); } i = group.length; while (i--) { cached = matcherfromtokens(group[i]); if (cached[expando]) { setmatchers.push(cached); } else { elementmatchers.push(cached); } } // cache the compiled function cached = compilercache(selector, matcherfromgroupmatchers(elementmatchers, setmatchers)); } return cached; }; function multiplecontexts(selector, contexts, results) { var i = 0, len = contexts.length; for (; i < len; i++) { sizzle(selector, contexts[i], results); } return results; } function select(selector, context, results, seed, xml) { var i, tokens, token, type, find, match = tokenize(selector), j = match.length; if (!seed) { // try to minimize operations if there is only one group if (match.length === 1) { // take a shortcut and set the context if the root selector is an id tokens = match[0] = match[0].slice(0); if (tokens.length > 2 && (token = tokens[0]).type === "id" && context.nodetype === 9 && !xml && expr.relative[tokens[1].type]) { context = expr.find["id"](token.matches[0].replace(rbackslash, ""), context, xml)[0]; if (!context) { return results; } selector = selector.slice(tokens.shift().length); } // fetch a seed set for right-to-left matching for (i = matchexpr["pos"].test(selector) ? -1 : tokens.length - 1; i >= 0; i--) { token = tokens[i]; // abort if we hit a combinator if (expr.relative[(type = token.type)]) { break; } if ((find = expr.find[type])) { // search, expanding context for leading sibling combinators if ((seed = find( token.matches[0].replace(rbackslash, ""), rsibling.test(tokens[0].type) && context.parentnode || context, xml ))) { // if seed is empty or no tokens remain, we can return early tokens.splice(i, 1); selector = seed.length && tokens.join(""); if (!selector) { push.apply(results, slice.call(seed, 0)); return results; } break; } } } } } // compile and execute a filtering function // provide `match` to avoid retokenization if we modified the selector above compile(selector, match)( seed, context, xml, results, rsibling.test(selector) ); return results; } if (document.queryselectorall) { (function () { var disconnectedmatch, oldselect = select, rescape = /'|\\/g, rattributequotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, // qsa(:focus) reports false when true (chrome 21), no need to also add to buggymatches since matches checks buggyqsa // a support test would require too much code (would include document ready) rbuggyqsa = [":focus"], // matchesselector(:active) reports false when true (ie9/opera 11.5) // a support test would require too much code (would include document ready) // just skip matchesselector for :active rbuggymatches = [":active"], matches = docelem.matchesselector || docelem.mozmatchesselector || docelem.webkitmatchesselector || docelem.omatchesselector || docelem.msmatchesselector; // build qsa regex // regex strategy adopted from diego perini assert(function (div) { // select is set to empty string on purpose // this is to test ie's treatment of not explictly // setting a boolean content attribute, // since its presence should be enough // http://bugs.jquery.com/ticket/12359 div.innerhtml = ""; // ie8 - some boolean attributes are not treated correctly if (!div.queryselectorall("[selected]").length) { rbuggyqsa.push("\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)"); } // webkit/opera - :checked should return selected option elements // http://www.w3.org/tr/2011/rec-css3-selectors-20110929/#checked // ie8 throws error here (do not put tests after this one) if (!div.queryselectorall(":checked").length) { rbuggyqsa.push(":checked"); } }); assert(function (div) { // opera 10-12/ie9 - ^= $= *= and empty values // should not select anything div.innerhtml = "

"; if (div.queryselectorall("[test^='']").length) { rbuggyqsa.push("[*^$]=" + whitespace + "*(?:\"\"|'')"); } // ff 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) // ie8 throws error here (do not put tests after this one) div.innerhtml = ""; if (!div.queryselectorall(":enabled").length) { rbuggyqsa.push(":enabled", ":disabled"); } }); // rbuggyqsa always contains :focus, so no need for a length check rbuggyqsa = /* rbuggyqsa.length && */ new regexp(rbuggyqsa.join("|")); select = function (selector, context, results, seed, xml) { // only use queryselectorall when not filtering, // when this is not xml, // and when no qsa bugs apply if (!seed && !xml && !rbuggyqsa.test(selector)) { var groups, i, old = true, nid = expando, newcontext = context, newselector = context.nodetype === 9 && selector; // qsa works strangely on element-rooted queries // we can work around this by specifying an extra id on the root // and working up from there (thanks to andrew dupont for the technique) // ie 8 doesn't work on object elements if (context.nodetype === 1 && context.nodename.tolowercase() !== "object") { groups = tokenize(selector); if ((old = context.getattribute("id"))) { nid = old.replace(rescape, "\\$&"); } else { context.setattribute("id", nid); } nid = "[id='" + nid + "'] "; i = groups.length; while (i--) { groups[i] = nid + groups[i].join(""); } newcontext = rsibling.test(selector) && context.parentnode || context; newselector = groups.join(","); } if (newselector) { try { push.apply(results, slice.call(newcontext.queryselectorall( newselector ), 0)); return results; } catch (qsaerror) { } finally { if (!old) { context.removeattribute("id"); } } } } return oldselect(selector, context, results, seed, xml); }; if (matches) { assert(function (div) { // check to see if it's possible to do matchesselector // on a disconnected node (ie 9) disconnectedmatch = matches.call(div, "div"); // this should fail with an exception // gecko does not error, returns false instead try { matches.call(div, "[test!='']:sizzle"); rbuggymatches.push("!=", pseudos); } catch (e) { } }); // rbuggymatches always contains :active and :focus, so no need for a length check rbuggymatches = /* rbuggymatches.length && */ new regexp(rbuggymatches.join("|")); sizzle.matchesselector = function (elem, expr) { // make sure that attribute selectors are quoted expr = expr.replace(rattributequotes, "='$1']"); // rbuggymatches always contains :active, so no need for an existence check if (!isxml(elem) && !rbuggymatches.test(expr) && !rbuggyqsa.test(expr)) { try { var ret = matches.call(elem, expr); // ie 9's matchesselector returns false on disconnected nodes if (ret || disconnectedmatch || // as well, disconnected nodes are said to be in a document // fragment in ie 9 elem.document && elem.document.nodetype !== 11) { return ret; } } catch (e) { } } return sizzle(expr, null, null, [elem]).length > 0; }; } })(); } // deprecated expr.pseudos["nth"] = expr.pseudos["eq"]; // back-compat function setfilters() { } expr.filters = setfilters.prototype = expr.pseudos; expr.setfilters = new setfilters(); // override sizzle attribute retrieval sizzle.attr = jquery.attr; jquery.find = sizzle; jquery.expr = sizzle.selectors; jquery.expr[":"] = jquery.expr.pseudos; jquery.unique = sizzle.uniquesort; jquery.text = sizzle.gettext; jquery.isxmldoc = sizzle.isxml; jquery.contains = sizzle.contains; })(window); var runtil = /until$/, rparentsprev = /^(?:parents|prev(?:until|all))/, issimple = /^.[^:#\[\.,]*$/, rneedscontext = jquery.expr.match.needscontext, // methods guaranteed to produce a unique set when starting from a unique set guaranteedunique = { children: true, contents: true, next: true, prev: true }; jquery.fn.extend({ find: function (selector) { var i, l, length, n, r, ret, self = this; if (typeof selector !== "string") { return jquery(selector).filter(function () { for (i = 0, l = self.length; i < l; i++) { if (jquery.contains(self[i], this)) { return true; } } }); } ret = this.pushstack("", "find", selector); for (i = 0, l = this.length; i < l; i++) { length = ret.length; jquery.find(selector, this[i], ret); if (i > 0) { // make sure that the results are unique for (n = length; n < ret.length; n++) { for (r = 0; r < length; r++) { if (ret[r] === ret[n]) { ret.splice(n--, 1); break; } } } } } return ret; }, has: function (target) { var i, targets = jquery(target, this), len = targets.length; return this.filter(function () { for (i = 0; i < len; i++) { if (jquery.contains(this, targets[i])) { return true; } } }); }, not: function (selector) { return this.pushstack(winnow(this, selector, false), "not", selector); }, filter: function (selector) { return this.pushstack(winnow(this, selector, true), "filter", selector); }, is: function (selector) { return !!selector && ( typeof selector === "string" ? // if this is a positional/relative selector, check membership in the returned set // so $("p:first").is("p:last") won't return true for a doc with two "p". rneedscontext.test(selector) ? jquery(selector, this.context).index(this[0]) >= 0 : jquery.filter(selector, this).length > 0 : this.filter(selector).length > 0); }, closest: function (selectors, context) { var cur, i = 0, l = this.length, ret = [], pos = rneedscontext.test(selectors) || typeof selectors !== "string" ? jquery(selectors, context || this.context) : 0; for (; i < l; i++) { cur = this[i]; while (cur && cur.ownerdocument && cur !== context && cur.nodetype !== 11) { if (pos ? pos.index(cur) > -1 : jquery.find.matchesselector(cur, selectors)) { ret.push(cur); break; } cur = cur.parentnode; } } ret = ret.length > 1 ? jquery.unique(ret) : ret; return this.pushstack(ret, "closest", selectors); }, // determine the position of an element within // the matched set of elements index: function (elem) { // no argument, return index in parent if (!elem) { return (this[0] && this[0].parentnode) ? this.prevall().length : -1; } // index in selector if (typeof elem === "string") { return jquery.inarray(this[0], jquery(elem)); } // locate the position of the desired element return jquery.inarray( // if it receives a jquery object, the first element is used elem.jquery ? elem[0] : elem, this); }, add: function (selector, context) { var set = typeof selector === "string" ? jquery(selector, context) : jquery.makearray(selector && selector.nodetype ? [selector] : selector), all = jquery.merge(this.get(), set); return this.pushstack(isdisconnected(set[0]) || isdisconnected(all[0]) ? all : jquery.unique(all)); }, addback: function (selector) { return this.add(selector == null ? this.prevobject : this.prevobject.filter(selector) ); } }); jquery.fn.andself = jquery.fn.addback; // a painfully simple check to see if an element is disconnected // from a document (should be improved, where feasible). function isdisconnected(node) { return !node || !node.parentnode || node.parentnode.nodetype === 11; } function sibling(cur, dir) { do { cur = cur[dir]; } while (cur && cur.nodetype !== 1); return cur; } jquery.each({ parent: function (elem) { var parent = elem.parentnode; return parent && parent.nodetype !== 11 ? parent : null; }, parents: function (elem) { return jquery.dir(elem, "parentnode"); }, parentsuntil: function (elem, i, until) { return jquery.dir(elem, "parentnode", until); }, next: function (elem) { return sibling(elem, "nextsibling"); }, prev: function (elem) { return sibling(elem, "previoussibling"); }, nextall: function (elem) { return jquery.dir(elem, "nextsibling"); }, prevall: function (elem) { return jquery.dir(elem, "previoussibling"); }, nextuntil: function (elem, i, until) { return jquery.dir(elem, "nextsibling", until); }, prevuntil: function (elem, i, until) { return jquery.dir(elem, "previoussibling", until); }, siblings: function (elem) { return jquery.sibling((elem.parentnode || {}).firstchild, elem); }, children: function (elem) { return jquery.sibling(elem.firstchild); }, contents: function (elem) { return jquery.nodename(elem, "iframe") ? elem.contentdocument || elem.contentwindow.document : jquery.merge([], elem.childnodes); } }, function (name, fn) { jquery.fn[name] = function (until, selector) { var ret = jquery.map(this, fn, until); 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 && rparentsprev.test(name)) { ret = ret.reverse(); } return this.pushstack(ret, name, core_slice.call(arguments).join(",")); }; }); jquery.extend({ filter: function (expr, elems, not) { if (not) { expr = ":not(" + expr + ")"; } return elems.length === 1 ? jquery.find.matchesselector(elems[0], expr) ? [elems[0]] : [] : jquery.find.matches(expr, elems); }, dir: function (elem, dir, until) { var matched = [], cur = elem[dir]; while (cur && cur.nodetype !== 9 && (until === undefined || cur.nodetype !== 1 || !jquery(cur).is(until))) { if (cur.nodetype === 1) { matched.push(cur); } cur = cur[dir]; } return matched; }, sibling: function (n, elem) { var r = []; for (; n; n = n.nextsibling) { if (n.nodetype === 1 && n !== elem) { r.push(n); } } return r; } }); // implement the identical functionality for filter and not function winnow(elements, qualifier, keep) { // can't pass null or undefined to indexof in firefox 4 // set to 0 to skip string check qualifier = qualifier || 0; if (jquery.isfunction(qualifier)) { return jquery.grep(elements, function (elem, i) { var retval = !!qualifier.call(elem, i, elem); return retval === keep; }); } else if (qualifier.nodetype) { return jquery.grep(elements, function (elem, i) { return (elem === qualifier) === keep; }); } else if (typeof qualifier === "string") { var filtered = jquery.grep(elements, function (elem) { return elem.nodetype === 1; }); if (issimple.test(qualifier)) { return jquery.filter(qualifier, filtered, !keep); } else { qualifier = jquery.filter(qualifier, filtered); } } return jquery.grep(elements, function (elem, i) { return (jquery.inarray(elem, qualifier) >= 0) === keep; }); } function createsafefragment(document) { var list = nodenames.split("|"), safefrag = document.createdocumentfragment(); if (safefrag.createelement) { while (list.length) { safefrag.createelement( list.pop() ); } } return safefrag; } var nodenames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", rinlinejquery = / jquery\d+="(?:null|\d+)"/g, rleadingwhitespace = /^\s+/, rxhtmltag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rtagname = /<([\w:]+)/, rtbody = /]", "i"), rcheckabletype = /^(?:checkbox|radio)$/, // checked="checked" or checked rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rscripttype = /\/(java|ecma)script/i, rcleanscript = /^\s*\s*$/g, wrapmap = { option: [1, ""], legend: [1, "
", "
"], thead: [1, "", "
"], tr: [2, "", "
"], td: [3, "", "
"], col: [2, "", "
"], area: [1, "", ""], _default: [0, "", ""] }, safefragment = createsafefragment(document), fragmentdiv = safefragment.appendchild(document.createelement("div")); wrapmap.optgroup = wrapmap.option; wrapmap.tbody = wrapmap.tfoot = wrapmap.colgroup = wrapmap.caption = wrapmap.thead; wrapmap.th = wrapmap.td; // ie6-8 can't serialize link, script, style, or any html5 (noscope) tags, // unless wrapped in a div with non-breaking characters in front of it. if (!jquery.support.htmlserialize) { wrapmap._default = [1, "x
", "
"]; } jquery.fn.extend({ text: function (value) { return jquery.access(this, function (value) { return value === undefined ? jquery.text(this) : this.empty().append((this[0] && this[0].ownerdocument || document).createtextnode(value)); }, null, value, arguments.length); }, wrapall: function (html) { 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; }, wrapinner: function (html) { 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); } }); }, wrap: function (html) { var isfunction = jquery.isfunction(html); return this.each(function (i) { jquery(this).wrapall(isfunction ? html.call(this, i) : html); }); }, unwrap: function () { return this.parent().each(function () { if (!jquery.nodename(this, "body")) { jquery(this).replacewith(this.childnodes); } }).end(); }, append: function () { return this.dommanip(arguments, true, function (elem) { if (this.nodetype === 1 || this.nodetype === 11) { this.appendchild(elem); } }); }, prepend: function () { return this.dommanip(arguments, true, function (elem) { if (this.nodetype === 1 || this.nodetype === 11) { this.insertbefore(elem, this.firstchild); } }); }, before: function () { if (!isdisconnected(this[0])) { return this.dommanip(arguments, false, function (elem) { this.parentnode.insertbefore(elem, this); }); } if (arguments.length) { var set = jquery.clean(arguments); return this.pushstack(jquery.merge(set, this), "before", this.selector); } }, after: function () { if (!isdisconnected(this[0])) { return this.dommanip(arguments, false, function (elem) { this.parentnode.insertbefore(elem, this.nextsibling); }); } if (arguments.length) { var set = jquery.clean(arguments); return this.pushstack(jquery.merge(this, set), "after", this.selector); } }, // keepdata is for internal use only--do not document remove: function (selector, keepdata) { var elem, i = 0; for (; (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; }, empty: function () { var elem, i = 0; for (; (elem = this[i]) != null; i++) { // remove element nodes and prevent memory leaks if (elem.nodetype === 1) { jquery.cleandata(elem.getelementsbytagname("*")); } // remove any remaining nodes while (elem.firstchild) { elem.removechild(elem.firstchild); } } return this; }, clone: function (dataandevents, deepdataandevents) { dataandevents = dataandevents == null ? false : dataandevents; deepdataandevents = deepdataandevents == null ? dataandevents : deepdataandevents; return this.map(function () { return jquery.clone(this, dataandevents, deepdataandevents); }); }, html: function (value) { return jquery.access(this, function (value) { var elem = this[0] || {}, i = 0, l = this.length; if (value === undefined) { return elem.nodetype === 1 ? elem.innerhtml.replace(rinlinejquery, "") : undefined; } // see if we can take a shortcut and just use innerhtml if (typeof value === "string" && !rnoinnerhtml.test(value) && (jquery.support.htmlserialize || !rnoshimcache.test(value)) && (jquery.support.leadingwhitespace || !rleadingwhitespace.test(value)) && !wrapmap[(rtagname.exec(value) || ["", ""])[1].tolowercase()]) { value = value.replace(rxhtmltag, "<$1>"); try { for (; i < l; i++) { // remove element nodes and prevent memory leaks elem = this[i] || {}; if (elem.nodetype === 1) { jquery.cleandata(elem.getelementsbytagname("*")); elem.innerhtml = value; } } elem = 0; // if using innerhtml throws an exception, use the fallback method } catch (e) { } } if (elem) { this.empty().append(value); } }, null, value, arguments.length); }, replacewith: function (value) { if (!isdisconnected(this[0])) { // 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); } }); } return this.length ? this.pushstack(jquery(jquery.isfunction(value) ? value() : value), "replacewith", value) : this; }, detach: function (selector) { return this.remove(selector, true); }, dommanip: function (args, table, callback) { // flatten any nested arrays args = [].concat.apply([], args); var results, first, fragment, inoclone, i = 0, value = args[0], scripts = [], l = this.length; // we can't clonenode fragments that contain checked, in webkit if (!jquery.support.checkclone && l > 1 && typeof value === "string" && rchecked.test(value)) { return this.each(function () { jquery(this).dommanip(args, table, callback); }); } if (jquery.isfunction(value)) { return this.each(function (i) { var self = jquery(this); args[0] = value.call(this, i, table ? self.html() : undefined); self.dommanip(args, table, callback); }); } if (this[0]) { results = jquery.buildfragment(args, this, scripts); fragment = results.fragment; first = fragment.firstchild; if (fragment.childnodes.length === 1) { fragment = first; } if (first) { table = table && jquery.nodename(first, "tr"); // use the original fragment for the last item instead of the first because it can end up // being emptied incorrectly in certain situations (#8070). // fragments from the fragment cache must always be cloned and never used in place. for (inoclone = results.cacheable || l - 1; i < l; i++) { callback.call( table && jquery.nodename(this[i], "table") ? findorappend(this[i], "tbody") : this[i], i === inoclone ? fragment : jquery.clone(fragment, true, true) ); } } // fix #11809: avoid leaking memory fragment = first = null; if (scripts.length) { jquery.each(scripts, function (i, elem) { if (elem.src) { if (jquery.ajax) { jquery.ajax({ url: elem.src, type: "get", datatype: "script", async: false, global: false, "throws": true }); } else { jquery.error("no ajax"); } } else { jquery.globaleval((elem.text || elem.textcontent || elem.innerhtml || "").replace(rcleanscript, "")); } if (elem.parentnode) { elem.parentnode.removechild(elem); } }); } } return this; } }); function findorappend(elem, tag) { return elem.getelementsbytagname(tag)[0] || elem.appendchild(elem.ownerdocument.createelement(tag)); } function clonecopyevent(src, dest) { if (dest.nodetype !== 1 || !jquery.hasdata(src)) { return; } var type, i, l, olddata = jquery._data(src), curdata = jquery._data(dest, olddata), events = olddata.events; if (events) { delete curdata.handle; curdata.events = {}; for (type in events) { for (i = 0, l = events[type].length; i < l; i++) { jquery.event.add(dest, type, events[type][i]); } } } // make the cloned public data object a copy from the original if (curdata.data) { curdata.data = jquery.extend({}, curdata.data); } } function clonefixattributes(src, dest) { var nodename; // we do not need to do anything for non-elements if (dest.nodetype !== 1) { return; } // clearattributes removes the attributes, which we don't want, // but also removes the attachevent events, which we *do* want if (dest.clearattributes) { dest.clearattributes(); } // mergeattributes, in contrast, only merges back on the // original attributes, not the events if (dest.mergeattributes) { dest.mergeattributes(src); } nodename = dest.nodename.tolowercase(); if (nodename === "object") { // ie6-10 improperly clones children of object elements using classid. // ie10 throws nomodificationallowederror if parent is null, #12132. if (dest.parentnode) { dest.outerhtml = src.outerhtml; } // this path appears unavoidable for ie9. when cloning an object // element in ie9, the outerhtml strategy above is not sufficient. // if the src has innerhtml and the destination does not, // copy the src.innerhtml into the dest.innerhtml. #10324 if (jquery.support.html5clone && (src.innerhtml && !jquery.trim(dest.innerhtml))) { dest.innerhtml = src.innerhtml; } } else if (nodename === "input" && rcheckabletype.test(src.type)) { // ie6-8 fails to persist the checked state of a cloned checkbox // or radio button. worse, ie6-7 fail to give the cloned element // a checked appearance if the defaultchecked value isn't also set dest.defaultchecked = dest.checked = src.checked; // ie6-7 get confused and end up setting the value of a cloned // checkbox/radio button to an empty string instead of "on" if (dest.value !== src.value) { dest.value = src.value; } // ie6-8 fails to return the selected option to the default selected // state when cloning options } else if (nodename === "option") { dest.selected = src.defaultselected; // ie6-8 fails to set the defaultvalue to the correct value when // cloning other types of input fields } else if (nodename === "input" || nodename === "textarea") { dest.defaultvalue = src.defaultvalue; // ie blanks contents when cloning scripts } else if (nodename === "script" && dest.text !== src.text) { dest.text = src.text; } // event data gets referenced instead of copied if the expando // gets copied too dest.removeattribute(jquery.expando); } jquery.buildfragment = function (args, context, scripts) { var fragment, cacheable, cachehit, first = args[0]; // set context from what may come in as undefined or a jquery collection or a node // updated to fix #12266 where accessing context[0] could throw an exception in ie9/10 & // also doubles as fix for #8950 where plain objects caused createdocumentfragment exception context = context || document; context = !context.nodetype && context[0] || context; context = context.ownerdocument || context; // only cache "small" (1/2 kb) html strings that are associated with the main document // cloning options loses the selected state, so don't cache them // ie 6 doesn't like it when you put or elements in a fragment // also, webkit does not clone 'checked' attributes on clonenode, so don't cache // lastly, ie6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 if (args.length === 1 && typeof first === "string" && first.length < 512 && context === document && first.charat(0) === "<" && !rnocache.test(first) && (jquery.support.checkclone || !rchecked.test(first)) && (jquery.support.html5clone || !rnoshimcache.test(first))) { // mark cacheable and look for a hit cacheable = true; fragment = jquery.fragments[first]; cachehit = fragment !== undefined; } if (!fragment) { fragment = context.createdocumentfragment(); jquery.clean(args, context, fragment, scripts); // update the cache, but only store false // unless this is a second parsing of the same content if (cacheable) { jquery.fragments[first] = cachehit && fragment; } } return { fragment: fragment, cacheable: cacheable }; }; jquery.fragments = {}; jquery.each({ appendto: "append", prependto: "prepend", insertbefore: "before", insertafter: "after", replaceall: "replacewith" }, function (name, original) { jquery.fn[name] = function (selector) { var elems, i = 0, ret = [], insert = jquery(selector), l = insert.length, parent = this.length === 1 && this[0].parentnode; if ((parent == null || parent && parent.nodetype === 11 && parent.childnodes.length === 1) && l === 1) { insert[original](this[0]); return this; } else { for (; i < l; i++) { elems = (i > 0 ? this.clone(true) : this).get(); jquery(insert[i])[original](elems); ret = ret.concat(elems); } return this.pushstack(ret, name, insert.selector); } }; }); function getall(elem) { if (typeof elem.getelementsbytagname !== "undefined") { return elem.getelementsbytagname("*"); } else if (typeof elem.queryselectorall !== "undefined") { return elem.queryselectorall("*"); } else { return []; } } // used in clean, fixes the defaultchecked property function fixdefaultchecked(elem) { if (rcheckabletype.test(elem.type)) { elem.defaultchecked = elem.checked; } } jquery.extend({ clone: function (elem, dataandevents, deepdataandevents) { var srcelements, destelements, i, clone; if (jquery.support.html5clone || jquery.isxmldoc(elem) || !rnoshimcache.test("<" + elem.nodename + ">")) { clone = elem.clonenode(true); // ie<=8 does not properly clone detached, unknown element nodes } else { fragmentdiv.innerhtml = elem.outerhtml; fragmentdiv.removechild(clone = fragmentdiv.firstchild); } if ((!jquery.support.nocloneevent || !jquery.support.noclonechecked) && (elem.nodetype === 1 || elem.nodetype === 11) && !jquery.isxmldoc(elem)) { // ie copies events bound via attachevent when using clonenode. // calling detachevent on the clone will also remove the events // from the original. in order to get around this, we use some // proprietary methods to clear the events. thanks to mootools // guys for this hotness. clonefixattributes(elem, clone); // using sizzle here is crazy slow, so we use getelementsbytagname instead srcelements = getall(elem); destelements = getall(clone); // weird iteration because ie will replace the length property // with an element if you are cloning the body and one of the // elements on the page has a name or id of "length" for (i = 0; srcelements[i]; ++i) { // ensure that the destination node is not null; fixes #9587 if (destelements[i]) { clonefixattributes(srcelements[i], destelements[i]); } } } // copy the events from the original to the clone if (dataandevents) { clonecopyevent(elem, clone); if (deepdataandevents) { srcelements = getall(elem); destelements = getall(clone); for (i = 0; srcelements[i]; ++i) { clonecopyevent(srcelements[i], destelements[i]); } } } srcelements = destelements = null; // return the cloned set return clone; }, clean: function (elems, context, fragment, scripts) { var i, j, elem, tag, wrap, depth, div, hasbody, tbody, len, handlescript, jstags, safe = context === document && safefragment, ret = []; // ensure that context is a document if (!context || typeof context.createdocumentfragment === "undefined") { context = document; } // use the already-created safe fragment if context permits for (i = 0; (elem = elems[i]) != null; i++) { if (typeof elem === "number") { elem += ""; } if (!elem) { continue; } // convert html string into dom nodes if (typeof elem === "string") { if (!rhtml.test(elem)) { elem = context.createtextnode(elem); } else { // ensure a safe container in which to render the html safe = safe || createsafefragment(context); div = context.createelement("div"); safe.appendchild(div); // fix "xhtml"-style tags in all browsers elem = elem.replace(rxhtmltag, "<$1>"); // go to html and back, then peel off extra wrappers tag = (rtagname.exec(elem) || ["", ""])[1].tolowercase(); wrap = wrapmap[tag] || wrapmap._default; depth = wrap[0]; div.innerhtml = wrap[1] + elem + wrap[2]; // move to the right depth while (depth--) { div = div.lastchild; } // remove ie's autoinserted from table fragments if (!jquery.support.tbody) { // string was a , *may* have spurious hasbody = rtbody.test(elem); tbody = tag === "table" && !hasbody ? div.firstchild && div.firstchild.childnodes : // string was a bare or wrap[1] === "
" && !hasbody ? div.childnodes : []; for (j = tbody.length - 1; j >= 0 ; --j) { if (jquery.nodename(tbody[j], "tbody") && !tbody[j].childnodes.length) { tbody[j].parentnode.removechild(tbody[j]); } } } // ie completely kills leading whitespace when innerhtml is used if (!jquery.support.leadingwhitespace && rleadingwhitespace.test(elem)) { div.insertbefore(context.createtextnode(rleadingwhitespace.exec(elem)[0]), div.firstchild); } elem = div.childnodes; // take out of fragment container (we need a fresh div each time) div.parentnode.removechild(div); } } if (elem.nodetype) { ret.push(elem); } else { jquery.merge(ret, elem); } } // fix #11356: clear elements from safefragment if (div) { elem = div = safe = null; } // reset defaultchecked for any radios and checkboxes // about to be appended to the dom in ie 6/7 (#8060) if (!jquery.support.appendchecked) { for (i = 0; (elem = ret[i]) != null; i++) { if (jquery.nodename(elem, "input")) { fixdefaultchecked(elem); } else if (typeof elem.getelementsbytagname !== "undefined") { jquery.grep(elem.getelementsbytagname("input"), fixdefaultchecked); } } } // append elements to a provided document fragment if (fragment) { // special handling of each script element handlescript = function (elem) { // check if we consider it executable if (!elem.type || rscripttype.test(elem.type)) { // detach the script and store it in the scripts array (if provided) or the fragment // return truthy to indicate that it has been handled return scripts ? scripts.push(elem.parentnode ? elem.parentnode.removechild(elem) : elem) : fragment.appendchild(elem); } }; for (i = 0; (elem = ret[i]) != null; i++) { // check if we're done after handling an executable script if (!(jquery.nodename(elem, "script") && handlescript(elem))) { // append to fragment and handle embedded scripts fragment.appendchild(elem); if (typeof elem.getelementsbytagname !== "undefined") { // handlescript alters the dom, so use jquery.merge to ensure snapshot iteration jstags = jquery.grep(jquery.merge([], elem.getelementsbytagname("script")), handlescript); // splice the scripts into ret after their former ancestor and advance our index beyond them ret.splice.apply(ret, [i + 1, 0].concat(jstags)); i += jstags.length; } } } } return ret; }, cleandata: function (elems, /* internal */ acceptdata) { var data, id, elem, type, i = 0, internalkey = jquery.expando, cache = jquery.cache, deleteexpando = jquery.support.deleteexpando, special = jquery.event.special; for (; (elem = elems[i]) != null; i++) { if (acceptdata || jquery.acceptdata(elem)) { id = elem[internalkey]; data = id && cache[id]; if (data) { if (data.events) { for (type in data.events) { if (special[type]) { jquery.event.remove(elem, type); // this is a shortcut to avoid jquery.event.remove's overhead } else { jquery.removeevent(elem, type, data.handle); } } } // remove cache only if it was not already removed by jquery.event.remove if (cache[id]) { delete cache[id]; // ie does not allow us to delete expando properties from nodes, // nor does it have a removeattribute function on document nodes; // we must handle all of these cases if (deleteexpando) { delete elem[internalkey]; } else if (elem.removeattribute) { elem.removeattribute(internalkey); } else { elem[internalkey] = null; } jquery.deletedids.push(id); } } } } } }); // limit scope pollution from any deprecated api (function () { var matched, browser; // use of jquery.browser is frowned upon. // more details: http://api.jquery.com/jquery.browser // jquery.uamatch maintained for back-compat jquery.uamatch = function (ua) { ua = ua.tolowercase(); var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexof("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || []; return { browser: match[1] || "", version: match[2] || "0" }; }; matched = jquery.uamatch(navigator.useragent); browser = {}; if (matched.browser) { browser[matched.browser] = true; browser.version = matched.version; } // chrome is webkit, but webkit is also safari. if (browser.chrome) { browser.webkit = true; } else if (browser.webkit) { browser.safari = true; } jquery.browser = browser; jquery.sub = function () { function jquerysub(selector, context) { return new jquerysub.fn.init(selector, context); } jquery.extend(true, jquerysub, this); jquerysub.superclass = this; jquerysub.fn = jquerysub.prototype = this(); jquerysub.fn.constructor = jquerysub; jquerysub.sub = this.sub; jquerysub.fn.init = function init(selector, context) { if (context && context instanceof jquery && !(context instanceof jquerysub)) { context = jquerysub(context); } return jquery.fn.init.call(this, selector, context, rootjquerysub); }; jquerysub.fn.init.prototype = jquerysub.fn; var rootjquerysub = jquerysub(document); return jquerysub; }; })(); var curcss, iframe, iframedoc, ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, rposition = /^(top|right|bottom|left)$/, // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" // see here for display values: https://developer.mozilla.org/en-us/docs/css/display rdisplayswap = /^(none|table(?!-c[ea]).+)/, rmargin = /^margin/, rnumsplit = new regexp("^(" + core_pnum + ")(.*)$", "i"), rnumnonpx = new regexp("^(" + core_pnum + ")(?!px)[a-z%]+$", "i"), rrelnum = new regexp("^([-+])=(" + core_pnum + ")", "i"), elemdisplay = { body: "block" }, cssshow = { position: "absolute", visibility: "hidden", display: "block" }, cssnormaltransform = { letterspacing: 0, fontweight: 400 }, cssexpand = ["top", "right", "bottom", "left"], cssprefixes = ["webkit", "o", "moz", "ms"], eventstoggle = jquery.fn.toggle; // return a css property mapped to a potentially vendor prefixed property function vendorpropname(style, name) { // shortcut for names that are not vendor prefixed if (name in style) { return name; } // check for vendor prefixed names var capname = name.charat(0).touppercase() + name.slice(1), origname = name, i = cssprefixes.length; while (i--) { name = cssprefixes[i] + capname; if (name in style) { return name; } } return origname; } function ishidden(elem, el) { elem = el || elem; return jquery.css(elem, "display") === "none" || !jquery.contains(elem.ownerdocument, elem); } function showhide(elements, show) { var elem, display, values = [], index = 0, length = elements.length; for (; index < length; index++) { elem = elements[index]; if (!elem.style) { continue; } values[index] = jquery._data(elem, "olddisplay"); if (show) { // reset the inline display of this element to learn if it is // being hidden by cascaded rules or not if (!values[index] && elem.style.display === "none") { 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 (elem.style.display === "" && ishidden(elem)) { values[index] = jquery._data(elem, "olddisplay", css_defaultdisplay(elem.nodename)); } } else { display = curcss(elem, "display"); if (!values[index] && display !== "none") { jquery._data(elem, "olddisplay", display); } } } // set the display of most of the elements in a second loop // to avoid the constant reflow for (index = 0; index < length; index++) { elem = elements[index]; if (!elem.style) { continue; } if (!show || elem.style.display === "none" || elem.style.display === "") { elem.style.display = show ? values[index] || "" : "none"; } } return elements; } jquery.fn.extend({ css: function (name, value) { return jquery.access(this, function (elem, name, value) { return value !== undefined ? jquery.style(elem, name, value) : jquery.css(elem, name); }, name, value, arguments.length > 1); }, show: function () { return showhide(this, true); }, hide: function () { return showhide(this); }, toggle: function (state, fn2) { var bool = typeof state === "boolean"; if (jquery.isfunction(state) && jquery.isfunction(fn2)) { return eventstoggle.apply(this, arguments); } return this.each(function () { if (bool ? state : ishidden(this)) { jquery(this).show(); } else { jquery(this).hide(); } }); } }); jquery.extend({ // add in style property hooks for overriding the default // behavior of getting and setting a style property csshooks: { opacity: { get: function (elem, computed) { if (computed) { // we should always get a number back from opacity var ret = curcss(elem, "opacity"); return ret === "" ? "1" : ret; } } } }, // exclude the following css properties to add px cssnumber: { "fillopacity": true, "fontweight": true, "lineheight": true, "opacity": true, "orphans": true, "widows": true, "zindex": true, "zoom": true }, // add in properties whose names you wish to fix before // setting or getting the value cssprops: { // normalize float css property "float": jquery.support.cssfloat ? "cssfloat" : "stylefloat" }, // get and set the style property on a dom node style: function (elem, name, value, extra) { // don't set styles on text and comment nodes if (!elem || elem.nodetype === 3 || elem.nodetype === 8 || !elem.style) { return; } // make sure that we're working with the right name var ret, type, hooks, origname = jquery.camelcase(name), style = elem.style; name = jquery.cssprops[origname] || (jquery.cssprops[origname] = vendorpropname(style, origname)); // gets hook for the prefixed version // followed by the unprefixed version hooks = jquery.csshooks[name] || jquery.csshooks[origname]; // check if we're setting a value if (value !== undefined) { type = typeof value; // convert relative number strings (+= or -=) to relative numbers. #7345 if (type === "string" && (ret = rrelnum.exec(value))) { value = (ret[1] + 1) * ret[2] + parsefloat(jquery.css(elem, name)); // fixes bug #9237 type = "number"; } // make sure that nan and null values aren't set. see: #7116 if (value == null || type === "number" && isnan(value)) { return; } // if a number was passed in, add 'px' to the (except for certain css properties) if (type === "number" && !jquery.cssnumber[origname]) { value += "px"; } // if a hook was provided, use that value, otherwise just set the specified value if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value, extra)) !== undefined) { // wrapped to prevent ie from throwing errors when 'invalid' values are provided // fixes bug #5509 try { style[name] = value; } catch (e) { } } } else { // if a hook was provided get the non-computed value from there if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== undefined) { return ret; } // otherwise just get the value from the style object return style[name]; } }, css: function (elem, name, numeric, extra) { var val, num, hooks, origname = jquery.camelcase(name); // make sure that we're working with the right name name = jquery.cssprops[origname] || (jquery.cssprops[origname] = vendorpropname(elem.style, origname)); // gets hook for the prefixed version // followed by the unprefixed version hooks = jquery.csshooks[name] || jquery.csshooks[origname]; // if a hook was provided get the computed value from there if (hooks && "get" in hooks) { val = hooks.get(elem, true, extra); } // otherwise, if a way to get the computed value exists, use that if (val === undefined) { val = curcss(elem, name); } //convert "normal" to computed value if (val === "normal" && name in cssnormaltransform) { val = cssnormaltransform[name]; } // return, converting to number if forced or a qualifier was provided and val looks numeric if (numeric || extra !== undefined) { num = parsefloat(val); return numeric || jquery.isnumeric(num) ? num || 0 : val; } return val; }, // a method for quickly swapping in/out css properties to get correct calculations swap: function (elem, options, callback) { var ret, name, old = {}; // remember the old values, and insert the new ones for (name in options) { old[name] = elem.style[name]; elem.style[name] = options[name]; } ret = callback.call(elem); // revert the old values for (name in options) { elem.style[name] = old[name]; } return ret; } }); // note: to any future maintainer, we've window.getcomputedstyle // because jsdom on node.js will break without it. if (window.getcomputedstyle) { curcss = function (elem, name) { var ret, width, minwidth, maxwidth, computed = window.getcomputedstyle(elem, null), style = elem.style; if (computed) { // getpropertyvalue is only needed for .css('filter') in ie9, see #12537 ret = computed.getpropertyvalue(name) || computed[name]; if (ret === "" && !jquery.contains(elem.ownerdocument, elem)) { ret = jquery.style(elem, name); } // a tribute to the "awesome hack by dean edwards" // chrome < 17 and safari 5.0 uses "computed value" instead of "used value" for margin-right // safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels // this is against the cssom draft spec: http://dev.w3.org/csswg/cssom/#resolved-values if (rnumnonpx.test(ret) && rmargin.test(name)) { width = style.width; minwidth = style.minwidth; maxwidth = style.maxwidth; style.minwidth = style.maxwidth = style.width = ret; ret = computed.width; style.width = width; style.minwidth = minwidth; style.maxwidth = maxwidth; } } return ret; }; } else if (document.documentelement.currentstyle) { curcss = function (elem, name) { var left, rsleft, ret = elem.currentstyle && elem.currentstyle[name], style = elem.style; // avoid setting ret to empty string here // so we don't default to auto if (ret == null && style && style[name]) { ret = style[name]; } // from the awesome hack by dean edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // if we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels // but not position css attributes, as those are proportional to the parent element instead // and we can't measure the parent instead because it might trigger a "stacking dolls" problem if (rnumnonpx.test(ret) && !rposition.test(name)) { // remember the original values left = style.left; rsleft = elem.runtimestyle && elem.runtimestyle.left; // put in the new values to get a computed value out if (rsleft) { elem.runtimestyle.left = elem.currentstyle.left; } style.left = name === "fontsize" ? "1em" : ret; ret = style.pixelleft + "px"; // revert the changed values style.left = left; if (rsleft) { elem.runtimestyle.left = rsleft; } } return ret === "" ? "auto" : ret; }; } function setpositivenumber(elem, value, subtract) { var matches = rnumsplit.exec(value); return matches ? math.max(0, matches[1] - (subtract || 0)) + (matches[2] || "px") : value; } function augmentwidthorheight(elem, name, extra, isborderbox) { var i = extra === (isborderbox ? "border" : "content") ? // if we already have the right measurement, avoid augmentation 4 : // otherwise initialize for horizontal or vertical properties name === "width" ? 1 : 0, val = 0; for (; i < 4; i += 2) { // both box models exclude margin, so add it if we want it if (extra === "margin") { // we use jquery.css instead of curcss here // because of the reliablemarginright css hook! val += jquery.css(elem, extra + cssexpand[i], true); } // from this point on we use curcss for maximum performance (relevant in animations) if (isborderbox) { // border-box includes padding, so remove it if we want content if (extra === "content") { val -= parsefloat(curcss(elem, "padding" + cssexpand[i])) || 0; } // at this point, extra isn't border nor margin, so remove border if (extra !== "margin") { val -= parsefloat(curcss(elem, "border" + cssexpand[i] + "width")) || 0; } } else { // at this point, extra isn't content, so add padding val += parsefloat(curcss(elem, "padding" + cssexpand[i])) || 0; // at this point, extra isn't content nor padding, so add border if (extra !== "padding") { val += parsefloat(curcss(elem, "border" + cssexpand[i] + "width")) || 0; } } } return val; } function getwidthorheight(elem, name, extra) { // start with offset property, which is equivalent to the border-box value var val = name === "width" ? elem.offsetwidth : elem.offsetheight, valueisborderbox = true, isborderbox = jquery.support.boxsizing && jquery.css(elem, "boxsizing") === "border-box"; // some non-html elements return undefined for offsetwidth, so check for null/undefined // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // mathml - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 if (val <= 0 || val == null) { // fall back to computed then uncomputed css if necessary val = curcss(elem, name); if (val < 0 || val == null) { val = elem.style[name]; } // computed unit is not pixels. stop here and return. if (rnumnonpx.test(val)) { return val; } // we need the check for style in case a browser which returns unreliable values // for getcomputedstyle silently falls back to the reliable elem.style valueisborderbox = isborderbox && (jquery.support.boxsizingreliable || val === elem.style[name]); // normalize "", auto, and prepare for extra val = parsefloat(val) || 0; } // use the active box-sizing model to add/subtract irrelevant styles return (val + augmentwidthorheight( elem, name, extra || (isborderbox ? "border" : "content"), valueisborderbox ) ) + "px"; } // try to determine the default display value of an element function css_defaultdisplay(nodename) { if (elemdisplay[nodename]) { return elemdisplay[nodename]; } var elem = jquery("<" + nodename + ">").appendto(document.body), display = elem.css("display"); elem.remove(); // if the simple way fails, // get element's real default display by attaching it to a temp iframe if (display === "none" || display === "") { // use the already-created iframe if possible iframe = document.body.appendchild( iframe || jquery.extend(document.createelement("iframe"), { frameborder: 0, width: 0, height: 0 }) ); // create a cacheable copy of the iframe document on first call. // ie and opera will allow us to reuse the iframedoc without re-writing the fake html // document to it; webkit & firefox won't allow reusing the iframe document. if (!iframedoc || !iframe.createelement) { iframedoc = (iframe.contentwindow || iframe.contentdocument).document; iframedoc.write(""); iframedoc.close(); } elem = iframedoc.body.appendchild(iframedoc.createelement(nodename)); display = curcss(elem, "display"); document.body.removechild(iframe); } // store the correct default display elemdisplay[nodename] = display; return display; } jquery.each(["height", "width"], function (i, name) { jquery.csshooks[name] = { get: function (elem, computed, extra) { if (computed) { // certain elements can have dimension info if we invisibly show them // however, it must have a current display style that would benefit from this if (elem.offsetwidth === 0 && rdisplayswap.test(curcss(elem, "display"))) { return jquery.swap(elem, cssshow, function () { return getwidthorheight(elem, name, extra); }); } else { return getwidthorheight(elem, name, extra); } } }, set: function (elem, value, extra) { return setpositivenumber(elem, value, extra ? augmentwidthorheight( elem, name, extra, jquery.support.boxsizing && jquery.css(elem, "boxsizing") === "border-box" ) : 0 ); } }; }); if (!jquery.support.opacity) { jquery.csshooks.opacity = { get: function (elem, computed) { // ie uses filters for opacity return ropacity.test((computed && elem.currentstyle ? elem.currentstyle.filter : elem.style.filter) || "") ? (0.01 * parsefloat(regexp.$1)) + "" : computed ? "1" : ""; }, set: function (elem, value) { var style = elem.style, currentstyle = elem.currentstyle, opacity = jquery.isnumeric(value) ? "alpha(opacity=" + value * 100 + ")" : "", filter = currentstyle && currentstyle.filter || style.filter || ""; // ie has trouble with opacity if it does not have layout // force it by setting the zoom level style.zoom = 1; // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 if (value >= 1 && jquery.trim(filter.replace(ralpha, "")) === "" && style.removeattribute) { // setting style.filter to null, "" & " " still leave "filter:" in the csstext // if "filter:" is present at all, cleartype is disabled, we want to avoid this // style.removeattribute is ie only, but so apparently is this code path... style.removeattribute("filter"); // if there there is no filter style applied in a css rule, we are done if (currentstyle && !currentstyle.filter) { return; } } // otherwise, set new filter values style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : filter + " " + opacity; } }; } // these hooks cannot be added until dom ready because the support test // for it is not run until after dom ready jquery(function () { if (!jquery.support.reliablemarginright) { jquery.csshooks.marginright = { get: function (elem, computed) { // webkit bug 13343 - getcomputedstyle returns wrong value for margin-right // work around by temporarily setting element display to inline-block return jquery.swap(elem, { "display": "inline-block" }, function () { if (computed) { return curcss(elem, "marginright"); } }); } }; } // webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 // getcomputedstyle returns percent when specified for top/left/bottom/right // rather than make the css module depend on the offset module, we just check for it here if (!jquery.support.pixelposition && jquery.fn.position) { jquery.each(["top", "left"], function (i, prop) { jquery.csshooks[prop] = { get: function (elem, computed) { if (computed) { var ret = curcss(elem, prop); // if curcss returns percentage, fallback to offset return rnumnonpx.test(ret) ? jquery(elem).position()[prop] + "px" : ret; } } }; }); } }); if (jquery.expr && jquery.expr.filters) { jquery.expr.filters.hidden = function (elem) { return (elem.offsetwidth === 0 && elem.offsetheight === 0) || (!jquery.support.reliablehiddenoffsets && ((elem.style && elem.style.display) || curcss(elem, "display")) === "none"); }; jquery.expr.filters.visible = function (elem) { return !jquery.expr.filters.hidden(elem); }; } // these hooks are used by animate to expand properties jquery.each({ margin: "", padding: "", border: "width" }, function (prefix, suffix) { jquery.csshooks[prefix + suffix] = { expand: function (value) { var i, // assumes a single number if not a string parts = typeof value === "string" ? value.split(" ") : [value], expanded = {}; for (i = 0; i < 4; i++) { expanded[prefix + cssexpand[i] + suffix] = parts[i] || parts[i - 2] || parts[0]; } return expanded; } }; if (!rmargin.test(prefix)) { jquery.csshooks[prefix + suffix].set = setpositivenumber; } }); var r20 = /%20/g, rbracket = /\[\]$/, rcrlf = /\r?\n/g, rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, rselecttextarea = /^(?:select|textarea)/i; jquery.fn.extend({ serialize: function () { return jquery.param(this.serializearray()); }, serializearray: function () { 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(); } }); //serialize an array of form elements or a set of //key/values into a query string jquery.param = function (a, traditional) { var prefix, s = [], add = function (key, value) { // if value is a function, invoke it and return its value value = jquery.isfunction(value) ? value() : (value == null ? "" : value); s[s.length] = encodeuricomponent(key) + "=" + encodeuricomponent(value); }; // set traditional to true for jquery <= 1.3.2 behavior. if (traditional === undefined) { traditional = jquery.ajaxsettings && jquery.ajaxsettings.traditional; } // if an array was passed in, assume that it is an array of form elements. if (jquery.isarray(a) || (a.jquery && !jquery.isplainobject(a))) { // serialize the form elements jquery.each(a, function () { add(this.name, this.value); }); } else { // if traditional, encode the "old" way (the way 1.3.2 or older // did it), otherwise encode params recursively. for (prefix in a) { buildparams(prefix, a[prefix], traditional, add); } } // return the resulting serialization return s.join("&").replace(r20, "+"); }; function buildparams(prefix, obj, traditional, add) { var name; if (jquery.isarray(obj)) { // serialize array item. jquery.each(obj, function (i, v) { if (traditional || rbracket.test(prefix)) { // treat each array item as a scalar. add(prefix, v); } else { // if array item is non-scalar (array or object), encode its // numeric index to resolve deserialization ambiguity issues. // note that rack (as of 1.0.0) can't currently deserialize // nested arrays properly, and attempting to do so may cause // a server error. possible fixes are to modify rack's // deserialization algorithm or to provide an option or flag // to force array serialization to be shallow. buildparams(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add); } }); } else if (!traditional && jquery.type(obj) === "object") { // serialize object item. for (name in obj) { buildparams(prefix + "[" + name + "]", obj[name], traditional, add); } } else { // serialize scalar item. add(prefix, obj); } } var // document location ajaxlocparts, ajaxlocation, rhash = /#.*$/, rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // ie leaves an \r character at eol // #7653, #8125, #8152: local protocol detection rlocalprotocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, rnocontent = /^(?:get|head)$/, rprotocol = /^\/\//, rquery = /\?/, rscript = /)<[^<]*)*<\/script>/gi, rts = /([?&])_=[^&]*/, rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, // keep a copy of the old load method _load = jquery.fn.load, /* prefilters * 1) they are useful to introduce custom datatypes (see ajax/jsonp.js for an example) * 2) these are called: * - before asking for a transport * - after param serialization (s.data is a string if s.processdata is true) * 3) key is the datatype * 4) the catchall symbol "*" can be used * 5) execution will start with transport datatype and then continue down to "*" if needed */ prefilters = {}, /* transports bindings * 1) key is the datatype * 2) the catchall symbol "*" can be used * 3) selection will start with transport datatype and then go to "*" if needed */ transports = {}, // avoid comment-prolog char sequence (#10098); must appease lint and evade compression alltypes = ["*/"] + ["*"]; // #8138, ie may throw an exception when accessing // a field from window.location if document.domain has been set try { ajaxlocation = location.href; } catch (e) { // use the href attribute of an a element // since ie will modify it given document.location ajaxlocation = document.createelement("a"); ajaxlocation.href = ""; ajaxlocation = ajaxlocation.href; } // segment location into parts ajaxlocparts = rurl.exec(ajaxlocation.tolowercase()) || []; // base "constructor" for jquery.ajaxprefilter and jquery.ajaxtransport function addtoprefiltersortransports(structure) { // datatypeexpression is optional and defaults to "*" return function (datatypeexpression, func) { if (typeof datatypeexpression !== "string") { func = datatypeexpression; datatypeexpression = "*"; } var datatype, list, placebefore, datatypes = datatypeexpression.tolowercase().split(core_rspace), i = 0, length = datatypes.length; if (jquery.isfunction(func)) { // for each datatype in the datatypeexpression for (; i < length; i++) { datatype = datatypes[i]; // we control if we're asked to add before // any existing element placebefore = /^\+/.test(datatype); if (placebefore) { datatype = datatype.substr(1) || "*"; } list = structure[datatype] = structure[datatype] || []; // then we add to the structure accordingly list[placebefore ? "unshift" : "push"](func); } } }; } // base inspection function for prefilters and transports function inspectprefiltersortransports(structure, options, originaloptions, jqxhr, datatype /* internal */, inspected /* internal */) { datatype = datatype || options.datatypes[0]; inspected = inspected || {}; inspected[datatype] = true; var selection, list = structure[datatype], i = 0, length = list ? list.length : 0, executeonly = (structure === prefilters); for (; i < length && (executeonly || !selection) ; i++) { selection = list[i](options, originaloptions, jqxhr); // if we got redirected to another datatype // we try there if executing only and not done already if (typeof selection === "string") { if (!executeonly || inspected[selection]) { selection = undefined; } else { options.datatypes.unshift(selection); selection = inspectprefiltersortransports( structure, options, originaloptions, jqxhr, selection, inspected); } } } // if we're only executing or nothing was selected // we try the catchall datatype if not done already if ((executeonly || !selection) && !inspected["*"]) { selection = inspectprefiltersortransports( structure, options, originaloptions, jqxhr, "*", inspected); } // unnecessary when only executing (prefilters) // but it'll be ignored by the caller in that case return selection; } // a special extend for ajax options // that takes "flat" options (not to be deep extended) // fixes #9887 function ajaxextend(target, src) { var key, deep, flatoptions = jquery.ajaxsettings.flatoptions || {}; for (key in src) { if (src[key] !== undefined) { (flatoptions[key] ? target : (deep || (deep = {})))[key] = src[key]; } } if (deep) { jquery.extend(true, target, deep); } } jquery.fn.load = function (url, params, callback) { if (typeof url !== "string" && _load) { return _load.apply(this, arguments); } // don't do a request if no elements are being requested if (!this.length) { return this; } var selector, type, response, self = this, off = url.indexof(" "); if (off >= 0) { selector = url.slice(off, url.length); url = url.slice(0, off); } // if it's a function if (jquery.isfunction(params)) { // we assume that it's the callback callback = params; params = undefined; // otherwise, build a param string } else if (params && typeof params === "object") { type = "post"; } // request the remote document jquery.ajax({ url: url, // if "type" variable is undefined, then "get" method will be used type: type, datatype: "html", data: params, complete: function (jqxhr, status) { if (callback) { self.each(callback, response || [jqxhr.responsetext, status, jqxhr]); } } }).done(function (responsetext) { // save response for use in complete callback response = arguments; // see if a selector was specified self.html(selector ? // create a dummy div to hold the results jquery("
") // inject the contents of the document in, removing the scripts // to avoid any 'power denied' errors in ie .append(responsetext.replace(rscript, "")) // locate the specified elements .find(selector) : // if not, just inject the full result responsetext); }); return this; }; // attach a bunch of functions for handling common ajax events jquery.each("ajaxstart ajaxstop ajaxcomplete ajaxerror ajaxsuccess ajaxsend".split(" "), function (i, o) { jquery.fn[o] = function (f) { return this.on(o, f); }; }); jquery.each(["get", "post"], function (i, method) { jquery[method] = function (url, data, callback, type) { // shift arguments if data argument was omitted if (jquery.isfunction(data)) { type = type || callback; callback = data; data = undefined; } return jquery.ajax({ type: method, url: url, data: data, success: callback, datatype: type }); }; }); jquery.extend({ getscript: function (url, callback) { return jquery.get(url, undefined, callback, "script"); }, getjson: function (url, data, callback) { return jquery.get(url, data, callback, "json"); }, // creates a full fledged settings object into target // with both ajaxsettings and settings fields. // if target is omitted, writes into ajaxsettings. ajaxsetup: function (target, settings) { if (settings) { // building a settings object ajaxextend(target, jquery.ajaxsettings); } else { // extending ajaxsettings settings = target; target = jquery.ajaxsettings; } ajaxextend(target, settings); return target; }, ajaxsettings: { url: ajaxlocation, islocal: rlocalprotocol.test(ajaxlocparts[1]), global: true, type: "get", contenttype: "application/x-www-form-urlencoded; charset=utf-8", processdata: true, async: true, /* timeout: 0, data: null, datatype: null, username: null, password: null, cache: null, throws: false, traditional: false, headers: {}, */ accepts: { xml: "application/xml, text/xml", html: "text/html", text: "text/plain", json: "application/json, text/javascript", "*": alltypes }, contents: { xml: /xml/, html: /html/, json: /json/ }, responsefields: { xml: "responsexml", text: "responsetext" }, // list of data converters // 1) key format is "source_type destination_type" (a single space in-between) // 2) the catchall symbol "*" can be used for source_type converters: { // convert anything to text "* text": window.string, // text to html (true = no transformation) "text html": true, // evaluate text as a json expression "text json": jquery.parsejson, // parse text as xml "text xml": jquery.parsexml }, // for options that shouldn't be deep extended: // you can add your own custom options here if // and when you create one that shouldn't be // deep extended (see ajaxextend) flatoptions: { context: true, url: true } }, ajaxprefilter: addtoprefiltersortransports(prefilters), ajaxtransport: addtoprefiltersortransports(transports), // main method ajax: function (url, options) { // if url is an object, simulate pre-1.5 signature if (typeof url === "object") { options = url; url = undefined; } // force options to be an object options = options || {}; var // ifmodified key ifmodifiedkey, // response headers responseheadersstring, responseheaders, // transport transport, // timeout handle timeouttimer, // cross-domain detection vars parts, // to know if global events are to be dispatched fireglobals, // loop variable i, // create the final options object s = jquery.ajaxsetup({}, options), // callbacks context callbackcontext = s.context || s, // context for global events // it's the callbackcontext if one was provided in the options // and if it's a dom node or a jquery collection globaleventcontext = callbackcontext !== s && (callbackcontext.nodetype || callbackcontext instanceof jquery) ? jquery(callbackcontext) : jquery.event, // deferreds deferred = jquery.deferred(), completedeferred = jquery.callbacks("once memory"), // status-dependent callbacks statuscode = s.statuscode || {}, // headers (they are sent all at once) requestheaders = {}, requestheadersnames = {}, // the jqxhr state state = 0, // default abort message strabort = "canceled", // fake xhr jqxhr = { readystate: 0, // caches the header setrequestheader: function (name, value) { if (!state) { var lname = name.tolowercase(); name = requestheadersnames[lname] = requestheadersnames[lname] || name; requestheaders[name] = value; } return this; }, // raw string getallresponseheaders: function () { return state === 2 ? responseheadersstring : null; }, // builds headers hashtable if needed getresponseheader: function (key) { var match; if (state === 2) { if (!responseheaders) { responseheaders = {}; while ((match = rheaders.exec(responseheadersstring))) { responseheaders[match[1].tolowercase()] = match[2]; } } match = responseheaders[key.tolowercase()]; } return match === undefined ? null : match; }, // overrides response content-type header overridemimetype: function (type) { if (!state) { s.mimetype = type; } return this; }, // cancel the request abort: function (statustext) { statustext = statustext || strabort; if (transport) { transport.abort(statustext); } done(0, statustext); return this; } }; // callback for when everything is done // it is defined here because jslint complains if it is declared // at the end of the function (which would be more logical and readable) function done(status, nativestatustext, responses, headers) { var issuccess, success, error, response, modified, statustext = nativestatustext; // called once if (state === 2) { return; } // state is "done" now state = 2; // clear timeout if it exists if (timeouttimer) { cleartimeout(timeouttimer); } // dereference transport for early garbage collection // (no matter how long the jqxhr object will be used) transport = undefined; // cache response headers responseheadersstring = headers || ""; // set readystate jqxhr.readystate = status > 0 ? 4 : 0; // get response data if (responses) { response = ajaxhandleresponses(s, jqxhr, responses); } // if successful, handle type chaining if (status >= 200 && status < 300 || status === 304) { // set the if-modified-since and/or if-none-match header, if in ifmodified mode. if (s.ifmodified) { modified = jqxhr.getresponseheader("last-modified"); if (modified) { jquery.lastmodified[ifmodifiedkey] = modified; } modified = jqxhr.getresponseheader("etag"); if (modified) { jquery.etag[ifmodifiedkey] = modified; } } // if not modified if (status === 304) { statustext = "notmodified"; issuccess = true; // if we have data } else { issuccess = ajaxconvert(s, response); statustext = issuccess.state; success = issuccess.data; error = issuccess.error; issuccess = !error; } } else { // we extract error from statustext // then normalize statustext and status for non-aborts error = statustext; if (!statustext || status) { statustext = "error"; if (status < 0) { status = 0; } } } // set data for the fake xhr object jqxhr.status = status; jqxhr.statustext = (nativestatustext || statustext) + ""; // success/error if (issuccess) { deferred.resolvewith(callbackcontext, [success, statustext, jqxhr]); } else { deferred.rejectwith(callbackcontext, [jqxhr, statustext, error]); } // status-dependent callbacks jqxhr.statuscode(statuscode); statuscode = undefined; if (fireglobals) { globaleventcontext.trigger("ajax" + (issuccess ? "success" : "error"), [jqxhr, s, issuccess ? success : error]); } // complete completedeferred.firewith(callbackcontext, [jqxhr, statustext]); if (fireglobals) { globaleventcontext.trigger("ajaxcomplete", [jqxhr, s]); // handle the global ajax counter if (!(--jquery.active)) { jquery.event.trigger("ajaxstop"); } } } // attach deferreds deferred.promise(jqxhr); jqxhr.success = jqxhr.done; jqxhr.error = jqxhr.fail; jqxhr.complete = completedeferred.add; // status-dependent callbacks jqxhr.statuscode = function (map) { if (map) { var tmp; if (state < 2) { for (tmp in map) { statuscode[tmp] = [statuscode[tmp], map[tmp]]; } } else { tmp = map[jqxhr.status]; jqxhr.always(tmp); } } return this; }; // remove hash character (#7531: and string promotion) // add protocol if not provided (#5866: ie7 issue with protocol-less urls) // we also use the url parameter if available s.url = ((url || s.url) + "").replace(rhash, "").replace(rprotocol, ajaxlocparts[1] + "//"); // extract datatypes list s.datatypes = jquery.trim(s.datatype || "*").tolowercase().split(core_rspace); // a cross-domain request is in order when we have a protocol:host:port mismatch if (s.crossdomain == null) { parts = rurl.exec(s.url.tolowercase()); s.crossdomain = !!(parts && (parts[1] !== ajaxlocparts[1] || parts[2] !== ajaxlocparts[2] || (parts[3] || (parts[1] === "http:" ? 80 : 443)) != (ajaxlocparts[3] || (ajaxlocparts[1] === "http:" ? 80 : 443))) ); } // convert data if not already a string if (s.data && s.processdata && typeof s.data !== "string") { s.data = jquery.param(s.data, s.traditional); } // apply prefilters inspectprefiltersortransports(prefilters, s, options, jqxhr); // if request was aborted inside a prefilter, stop there if (state === 2) { return jqxhr; } // we can fire global events as of now if asked to fireglobals = s.global; // uppercase the type s.type = s.type.touppercase(); // determine if request has content s.hascontent = !rnocontent.test(s.type); // watch for a new set of requests if (fireglobals && jquery.active++ === 0) { jquery.event.trigger("ajaxstart"); } // more options handling for requests with no content if (!s.hascontent) { // if data is available, append data to url if (s.data) { s.url += (rquery.test(s.url) ? "&" : "?") + s.data; // #9682: remove data so that it's not used in an eventual retry delete s.data; } // get ifmodifiedkey before adding the anti-cache parameter ifmodifiedkey = s.url; // add anti-cache in url if needed if (s.cache === false) { var ts = jquery.now(), // try replacing _= if it is there ret = s.url.replace(rts, "$1_=" + ts); // if nothing was replaced, add timestamp to the end s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); } } // set the correct header, if data is being sent if (s.data && s.hascontent && s.contenttype !== false || options.contenttype) { jqxhr.setrequestheader("content-type", s.contenttype); } // set the if-modified-since and/or if-none-match header, if in ifmodified mode. if (s.ifmodified) { ifmodifiedkey = ifmodifiedkey || s.url; if (jquery.lastmodified[ifmodifiedkey]) { jqxhr.setrequestheader("if-modified-since", jquery.lastmodified[ifmodifiedkey]); } if (jquery.etag[ifmodifiedkey]) { jqxhr.setrequestheader("if-none-match", jquery.etag[ifmodifiedkey]); } } // set the accepts header for the server, depending on the datatype jqxhr.setrequestheader( "accept", s.datatypes[0] && s.accepts[s.datatypes[0]] ? s.accepts[s.datatypes[0]] + (s.datatypes[0] !== "*" ? ", " + alltypes + "; q=0.01" : "") : s.accepts["*"] ); // check for headers option for (i in s.headers) { jqxhr.setrequestheader(i, s.headers[i]); } // allow custom headers/mimetypes and early abort if (s.beforesend && (s.beforesend.call(callbackcontext, jqxhr, s) === false || state === 2)) { // abort if not done already and return return jqxhr.abort(); } // aborting is no longer a cancellation strabort = "abort"; // install callbacks on deferreds for (i in { success: 1, error: 1, complete: 1 }) { jqxhr[i](s[i]); } // get transport transport = inspectprefiltersortransports(transports, s, options, jqxhr); // if no transport, we auto-abort if (!transport) { done(-1, "no transport"); } else { jqxhr.readystate = 1; // send global event if (fireglobals) { globaleventcontext.trigger("ajaxsend", [jqxhr, s]); } // timeout if (s.async && s.timeout > 0) { timeouttimer = settimeout(function () { jqxhr.abort("timeout"); }, s.timeout); } try { state = 1; transport.send(requestheaders, done); } catch (e) { // propagate exception as error if not done if (state < 2) { done(-1, e); // simply rethrow otherwise } else { throw e; } } } return jqxhr; }, // counter for holding the number of active queries active: 0, // last-modified header cache for next request lastmodified: {}, etag: {} }); /* handles responses to an ajax request: * - sets all responsexxx fields accordingly * - finds the right datatype (mediates between content-type and expected datatype) * - returns the corresponding response */ function ajaxhandleresponses(s, jqxhr, responses) { var ct, type, finaldatatype, firstdatatype, contents = s.contents, datatypes = s.datatypes, responsefields = s.responsefields; // fill responsexxx fields for (type in responsefields) { if (type in responses) { jqxhr[responsefields[type]] = responses[type]; } } // remove auto datatype and get content-type in the process while (datatypes[0] === "*") { datatypes.shift(); if (ct === undefined) { ct = s.mimetype || jqxhr.getresponseheader("content-type"); } } // check if we're dealing with a known content-type if (ct) { for (type in contents) { if (contents[type] && contents[type].test(ct)) { datatypes.unshift(type); break; } } } // check to see if we have a response for the expected datatype if (datatypes[0] in responses) { finaldatatype = datatypes[0]; } else { // try convertible datatypes for (type in responses) { if (!datatypes[0] || s.converters[type + " " + datatypes[0]]) { finaldatatype = type; break; } if (!firstdatatype) { firstdatatype = type; } } // or just use first one finaldatatype = finaldatatype || firstdatatype; } // if we found a datatype // we add the datatype to the list if needed // and return the corresponding response if (finaldatatype) { if (finaldatatype !== datatypes[0]) { datatypes.unshift(finaldatatype); } return responses[finaldatatype]; } } // chain conversions given the request and the original response function ajaxconvert(s, response) { var conv, conv2, current, tmp, // work with a copy of datatypes in case we need to modify it for conversion datatypes = s.datatypes.slice(), prev = datatypes[0], converters = {}, i = 0; // apply the datafilter if provided if (s.datafilter) { response = s.datafilter(response, s.datatype); } // create converters map with lowercased keys if (datatypes[1]) { for (conv in s.converters) { converters[conv.tolowercase()] = s.converters[conv]; } } // convert to each sequential datatype, tolerating list modification for (; (current = datatypes[++i]) ;) { // there's only work to do if current datatype is non-auto if (current !== "*") { // convert response if prev datatype is non-auto and differs from current if (prev !== "*" && prev !== current) { // seek a direct converter conv = converters[prev + " " + current] || converters["* " + current]; // if none found, seek a pair if (!conv) { for (conv2 in converters) { // if conv2 outputs current tmp = conv2.split(" "); if (tmp[1] === current) { // if prev can be converted to accepted input conv = converters[prev + " " + tmp[0]] || converters["* " + tmp[0]]; if (conv) { // condense equivalence converters if (conv === true) { conv = converters[conv2]; // otherwise, insert the intermediate datatype } else if (converters[conv2] !== true) { current = tmp[0]; datatypes.splice(i--, 0, current); } break; } } } } // apply converter (if not an equivalence) if (conv !== true) { // unless errors are allowed to bubble, catch and return them if (conv && s["throws"]) { response = conv(response); } else { try { response = conv(response); } catch (e) { return { state: "parsererror", error: conv ? e : "no conversion from " + prev + " to " + current }; } } } } // update prev for next iteration prev = current; } } return { state: "success", data: response }; } var oldcallbacks = [], rquestion = /\?/, rjsonp = /(=)\?(?=&|$)|\?\?/, nonce = jquery.now(); // default jsonp settings jquery.ajaxsetup({ jsonp: "callback", jsonpcallback: function () { var callback = oldcallbacks.pop() || (jquery.expando + "_" + (nonce++)); this[callback] = true; return callback; } }); // detect, normalize options and install callbacks for jsonp requests jquery.ajaxprefilter("json jsonp", function (s, originalsettings, jqxhr) { var callbackname, overwritten, responsecontainer, data = s.data, url = s.url, hascallback = s.jsonp !== false, replaceinurl = hascallback && rjsonp.test(url), replaceindata = hascallback && !replaceinurl && typeof data === "string" && !(s.contenttype || "").indexof("application/x-www-form-urlencoded") && rjsonp.test(data); // handle iff the expected data type is "jsonp" or we have a parameter to set if (s.datatypes[0] === "jsonp" || replaceinurl || replaceindata) { // get callback name, remembering preexisting value associated with it callbackname = s.jsonpcallback = jquery.isfunction(s.jsonpcallback) ? s.jsonpcallback() : s.jsonpcallback; overwritten = window[callbackname]; // insert callback into url or form data if (replaceinurl) { s.url = url.replace(rjsonp, "$1" + callbackname); } else if (replaceindata) { s.data = data.replace(rjsonp, "$1" + callbackname); } else if (hascallback) { s.url += (rquestion.test(url) ? "&" : "?") + s.jsonp + "=" + callbackname; } // use data converter to retrieve json after script execution s.converters["script json"] = function () { if (!responsecontainer) { jquery.error(callbackname + " was not called"); } return responsecontainer[0]; }; // force json datatype s.datatypes[0] = "json"; // install callback window[callbackname] = function () { responsecontainer = arguments; }; // clean-up function (fires after converters) jqxhr.always(function () { // restore preexisting value window[callbackname] = overwritten; // save back as free if (s[callbackname]) { // make sure that re-using the options doesn't screw things around s.jsonpcallback = originalsettings.jsonpcallback; // save the callback name for future use oldcallbacks.push(callbackname); } // call if it was a function and we have a response if (responsecontainer && jquery.isfunction(overwritten)) { overwritten(responsecontainer[0]); } responsecontainer = overwritten = undefined; }); // delegate to script return "script"; } }); // install script datatype jquery.ajaxsetup({ accepts: { script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" }, contents: { script: /javascript|ecmascript/ }, converters: { "text script": function (text) { jquery.globaleval(text); return text; } } }); // handle cache's special case and global jquery.ajaxprefilter("script", function (s) { if (s.cache === undefined) { s.cache = false; } if (s.crossdomain) { s.type = "get"; s.global = false; } }); // bind script tag hack transport jquery.ajaxtransport("script", function (s) { // this transport only deals with cross domain requests if (s.crossdomain) { var script, head = document.head || document.getelementsbytagname("head")[0] || document.documentelement; return { send: function (_, callback) { script = document.createelement("script"); script.async = "async"; if (s.scriptcharset) { script.charset = s.scriptcharset; } script.src = s.url; // attach handlers for all browsers script.onload = script.onreadystatechange = function (_, isabort) { if (isabort || !script.readystate || /loaded|complete/.test(script.readystate)) { // handle memory leak in ie script.onload = script.onreadystatechange = null; // remove the script if (head && script.parentnode) { head.removechild(script); } // dereference the script script = undefined; // callback if not abort if (!isabort) { callback(200, "success"); } } }; // use insertbefore instead of appendchild to circumvent an ie6 bug. // this arises when a base node is used (#2709 and #4378). head.insertbefore(script, head.firstchild); }, abort: function () { if (script) { script.onload(0, 1); } } }; } }); var xhrcallbacks, // #5280: internet explorer will keep connections alive if we don't abort on unload xhronunloadabort = window.activexobject ? function () { // abort all pending requests for (var key in xhrcallbacks) { xhrcallbacks[key](0, 1); } } : false, xhrid = 0; // functions to create xhrs function createstandardxhr() { try { return new window.xmlhttprequest(); } catch (e) { } } function createactivexhr() { try { return new window.activexobject("microsoft.xmlhttp"); } catch (e) { } } // create the request object // (this is still attached to ajaxsettings for backward compatibility) jquery.ajaxsettings.xhr = window.activexobject ? /* microsoft failed to properly * implement the xmlhttprequest in ie7 (can't request local files), * so we use the activexobject when it is available * additionally xmlhttprequest can be disabled in ie7/ie8 so * we need a fallback. */ function () { return !this.islocal && createstandardxhr() || createactivexhr(); } : // for all other browsers, use the standard xmlhttprequest object createstandardxhr; // determine support properties (function (xhr) { jquery.extend(jquery.support, { ajax: !!xhr, cors: !!xhr && ("withcredentials" in xhr) }); })(jquery.ajaxsettings.xhr()); // create transport if the browser can provide an xhr if (jquery.support.ajax) { jquery.ajaxtransport(function (s) { // cross domain only allowed if supported through xmlhttprequest if (!s.crossdomain || jquery.support.cors) { var callback; return { send: function (headers, complete) { // get a new xhr var handle, i, xhr = s.xhr(); // open the socket // passing null username, generates a login popup on opera (#2865) if (s.username) { xhr.open(s.type, s.url, s.async, s.username, s.password); } else { xhr.open(s.type, s.url, s.async); } // apply custom fields if provided if (s.xhrfields) { for (i in s.xhrfields) { xhr[i] = s.xhrfields[i]; } } // override mime type if needed if (s.mimetype && xhr.overridemimetype) { xhr.overridemimetype(s.mimetype); } // x-requested-with header // for cross-domain requests, seeing as conditions for a preflight are // akin to a jigsaw puzzle, we simply never set it to be sure. // (it can always be set on a per-request basis or even using ajaxsetup) // for same-domain requests, won't change header if already provided. if (!s.crossdomain && !headers["x-requested-with"]) { headers["x-requested-with"] = "xmlhttprequest"; } // need an extra try/catch for cross domain requests in firefox 3 try { for (i in headers) { xhr.setrequestheader(i, headers[i]); } } catch (_) { } // do send the request // this may raise an exception which is actually // handled in jquery.ajax (so no try/catch here) xhr.send((s.hascontent && s.data) || null); // listener callback = function (_, isabort) { var status, statustext, responseheaders, responses, xml; // firefox throws exceptions when accessing properties // of an xhr when a network error occurred // http://helpful.knobs-dials.com/index.php/component_returned_failure_code:_0x80040111_(ns_error_not_available) try { // was never called and is aborted or complete if (callback && (isabort || xhr.readystate === 4)) { // only called once callback = undefined; // do not keep as active anymore if (handle) { xhr.onreadystatechange = jquery.noop; if (xhronunloadabort) { delete xhrcallbacks[handle]; } } // if it's an abort if (isabort) { // abort it manually if needed if (xhr.readystate !== 4) { xhr.abort(); } } else { status = xhr.status; responseheaders = xhr.getallresponseheaders(); responses = {}; xml = xhr.responsexml; // construct response list if (xml && xml.documentelement /* #4958 */) { responses.xml = xml; } // when requesting binary data, ie6-9 will throw an exception // on any attempt to access responsetext (#11426) try { responses.text = xhr.responsetext; } catch (e) { } // firefox throws an exception when accessing // statustext for faulty cross-domain requests try { statustext = xhr.statustext; } catch (e) { // we normalize with webkit giving an empty statustext statustext = ""; } // filter status for non standard behaviors // if the request is local and we have data: assume a success // (success with no data won't get notified, that's the best we // can do given current implementations) if (!status && s.islocal && !s.crossdomain) { status = responses.text ? 200 : 404; // ie - #1450: sometimes returns 1223 when it should be 204 } else if (status === 1223) { status = 204; } } } } catch (firefoxaccessexception) { if (!isabort) { complete(-1, firefoxaccessexception); } } // call complete if needed if (responses) { complete(status, statustext, responses, responseheaders); } }; if (!s.async) { // if we're in sync mode we fire the callback callback(); } else if (xhr.readystate === 4) { // (ie6 & ie7) if it's in cache and has been // retrieved directly we need to fire the callback settimeout(callback, 0); } else { handle = ++xhrid; if (xhronunloadabort) { // create the active xhrs callbacks list if needed // and attach the unload handler if (!xhrcallbacks) { xhrcallbacks = {}; jquery(window).unload(xhronunloadabort); } // add to list of active xhrs callbacks xhrcallbacks[handle] = callback; } xhr.onreadystatechange = callback; } }, abort: function () { if (callback) { callback(0, 1); } } }; } }); } var fxnow, timerid, rfxtypes = /^(?:toggle|show|hide)$/, rfxnum = new regexp("^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i"), rrun = /queuehooks$/, animationprefilters = [defaultprefilter], tweeners = { "*": [function (prop, value) { var end, unit, tween = this.createtween(prop, value), parts = rfxnum.exec(value), target = tween.cur(), start = +target || 0, scale = 1, maxiterations = 20; if (parts) { end = +parts[2]; unit = parts[3] || (jquery.cssnumber[prop] ? "" : "px"); // we need to compute starting value if (unit !== "px" && start) { // iteratively approximate from a nonzero starting point // prefer the current property, because this process will be trivial if it uses the same units // fallback to end or a simple constant start = jquery.css(tween.elem, prop, true) || end || 1; do { // if previous iteration zeroed out, double until we get *something* // use a string for doubling factor so we don't accidentally see scale as unchanged below scale = scale || ".5"; // adjust and apply start = start / scale; jquery.style(tween.elem, prop, start + unit); // update scale, tolerating zero or nan from tween.cur() // and breaking the loop if scale is unchanged or perfect, or if we've just had enough } while (scale !== (scale = tween.cur() / target) && scale !== 1 && --maxiterations); } tween.unit = unit; tween.start = start; // if a +=/-= token was provided, we're doing a relative animation tween.end = parts[1] ? start + (parts[1] + 1) * end : end; } return tween; }] }; // animations created synchronously will run synchronously function createfxnow() { settimeout(function () { fxnow = undefined; }, 0); return (fxnow = jquery.now()); } function createtweens(animation, props) { jquery.each(props, function (prop, value) { var collection = (tweeners[prop] || []).concat(tweeners["*"]), index = 0, length = collection.length; for (; index < length; index++) { if (collection[index].call(animation, prop, value)) { // we're done with this property return; } } }); } function animation(elem, properties, options) { var result, index = 0, tweenerindex = 0, length = animationprefilters.length, deferred = jquery.deferred().always(function () { // don't match elem in the :animated selector delete tick.elem; }), tick = function () { var currenttime = fxnow || createfxnow(), remaining = math.max(0, animation.starttime + animation.duration - currenttime), // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497) temp = remaining / animation.duration || 0, percent = 1 - temp, index = 0, length = animation.tweens.length; for (; index < length ; index++) { animation.tweens[index].run(percent); } deferred.notifywith(elem, [animation, percent, remaining]); if (percent < 1 && length) { return remaining; } else { deferred.resolvewith(elem, [animation]); return false; } }, animation = deferred.promise({ elem: elem, props: jquery.extend({}, properties), opts: jquery.extend(true, { specialeasing: {} }, options), originalproperties: properties, originaloptions: options, starttime: fxnow || createfxnow(), duration: options.duration, tweens: [], createtween: function (prop, end, easing) { var tween = jquery.tween(elem, animation.opts, prop, end, animation.opts.specialeasing[prop] || animation.opts.easing); animation.tweens.push(tween); return tween; }, stop: function (gotoend) { var index = 0, // if we are going to the end, we want to run all the tweens // otherwise we skip this part length = gotoend ? animation.tweens.length : 0; for (; index < length ; index++) { animation.tweens[index].run(1); } // resolve when we played the last frame // otherwise, reject if (gotoend) { deferred.resolvewith(elem, [animation, gotoend]); } else { deferred.rejectwith(elem, [animation, gotoend]); } return this; } }), props = animation.props; propfilter(props, animation.opts.specialeasing); for (; index < length ; index++) { result = animationprefilters[index].call(animation, elem, props, animation.opts); if (result) { return result; } } createtweens(animation, props); if (jquery.isfunction(animation.opts.start)) { animation.opts.start.call(elem, animation); } jquery.fx.timer( jquery.extend(tick, { anim: animation, queue: animation.opts.queue, elem: elem }) ); // attach callbacks from options return animation.progress(animation.opts.progress) .done(animation.opts.done, animation.opts.complete) .fail(animation.opts.fail) .always(animation.opts.always); } function propfilter(props, specialeasing) { var index, name, easing, value, hooks; // camelcase, specialeasing and expand csshook pass for (index in props) { name = jquery.camelcase(index); easing = specialeasing[name]; value = props[index]; if (jquery.isarray(value)) { easing = value[1]; value = props[index] = value[0]; } if (index !== name) { props[name] = value; delete props[index]; } hooks = jquery.csshooks[name]; if (hooks && "expand" in hooks) { value = hooks.expand(value); delete props[name]; // not quite $.extend, this wont overwrite keys already present. // also - reusing 'index' from above because we have the correct "name" for (index in value) { if (!(index in props)) { props[index] = value[index]; specialeasing[index] = easing; } } } else { specialeasing[name] = easing; } } } jquery.animation = jquery.extend(animation, { tweener: function (props, callback) { if (jquery.isfunction(props)) { callback = props; props = ["*"]; } else { props = props.split(" "); } var prop, index = 0, length = props.length; for (; index < length ; index++) { prop = props[index]; tweeners[prop] = tweeners[prop] || []; tweeners[prop].unshift(callback); } }, prefilter: function (callback, prepend) { if (prepend) { animationprefilters.unshift(callback); } else { animationprefilters.push(callback); } } }); function defaultprefilter(elem, props, opts) { var index, prop, value, length, datashow, toggle, tween, hooks, oldfire, anim = this, style = elem.style, orig = {}, handled = [], hidden = elem.nodetype && ishidden(elem); // handle queue: false promises if (!opts.queue) { hooks = jquery._queuehooks(elem, "fx"); if (hooks.unqueued == null) { hooks.unqueued = 0; oldfire = hooks.empty.fire; hooks.empty.fire = function () { if (!hooks.unqueued) { oldfire(); } }; } hooks.unqueued++; anim.always(function () { // doing this makes sure that the complete handler will be called // before this completes anim.always(function () { hooks.unqueued--; if (!jquery.queue(elem, "fx").length) { hooks.empty.fire(); } }); }); } // height/width overflow pass if (elem.nodetype === 1 && ("height" in props || "width" in props)) { // make sure that nothing sneaks out // record all 3 overflow attributes because ie does not // change the overflow attribute when overflowx and // overflowy are set to the same value opts.overflow = [style.overflow, style.overflowx, style.overflowy]; // set display property to inline-block for height/width // animations on inline elements that are having width/height animated if (jquery.css(elem, "display") === "inline" && jquery.css(elem, "float") === "none") { // inline-level elements accept inline-block; // block-level elements need to be inline with layout if (!jquery.support.inlineblockneedslayout || css_defaultdisplay(elem.nodename) === "inline") { style.display = "inline-block"; } else { style.zoom = 1; } } } if (opts.overflow) { style.overflow = "hidden"; if (!jquery.support.shrinkwrapblocks) { anim.done(function () { style.overflow = opts.overflow[0]; style.overflowx = opts.overflow[1]; style.overflowy = opts.overflow[2]; }); } } // show/hide pass for (index in props) { value = props[index]; if (rfxtypes.exec(value)) { delete props[index]; toggle = toggle || value === "toggle"; if (value === (hidden ? "hide" : "show")) { continue; } handled.push(index); } } length = handled.length; if (length) { datashow = jquery._data(elem, "fxshow") || jquery._data(elem, "fxshow", {}); if ("hidden" in datashow) { hidden = datashow.hidden; } // store state if its toggle - enables .stop().toggle() to "reverse" if (toggle) { datashow.hidden = !hidden; } if (hidden) { jquery(elem).show(); } else { anim.done(function () { jquery(elem).hide(); }); } anim.done(function () { var prop; jquery.removedata(elem, "fxshow", true); for (prop in orig) { jquery.style(elem, prop, orig[prop]); } }); for (index = 0 ; index < length ; index++) { prop = handled[index]; tween = anim.createtween(prop, hidden ? datashow[prop] : 0); orig[prop] = datashow[prop] || jquery.style(elem, prop); if (!(prop in datashow)) { datashow[prop] = tween.start; if (hidden) { tween.end = tween.start; tween.start = prop === "width" || prop === "height" ? 1 : 0; } } } } } function tween(elem, options, prop, end, easing) { return new tween.prototype.init(elem, options, prop, end, easing); } jquery.tween = tween; tween.prototype = { constructor: tween, init: function (elem, options, prop, end, easing, unit) { this.elem = elem; this.prop = prop; this.easing = easing || "swing"; this.options = options; this.start = this.now = this.cur(); this.end = end; this.unit = unit || (jquery.cssnumber[prop] ? "" : "px"); }, cur: function () { var hooks = tween.prophooks[this.prop]; return hooks && hooks.get ? hooks.get(this) : tween.prophooks._default.get(this); }, run: function (percent) { var eased, hooks = tween.prophooks[this.prop]; if (this.options.duration) { this.pos = eased = jquery.easing[this.easing]( percent, this.options.duration * percent, 0, 1, this.options.duration ); } else { this.pos = eased = percent; } this.now = (this.end - this.start) * eased + this.start; if (this.options.step) { this.options.step.call(this.elem, this.now, this); } if (hooks && hooks.set) { hooks.set(this); } else { tween.prophooks._default.set(this); } return this; } }; tween.prototype.init.prototype = tween.prototype; tween.prophooks = { _default: { get: function (tween) { var result; if (tween.elem[tween.prop] != null && (!tween.elem.style || tween.elem.style[tween.prop] == null)) { return tween.elem[tween.prop]; } // passing any value as a 4th parameter to .css will automatically // attempt a parsefloat and fallback to a string if the parse fails // so, simple values such as "10px" are parsed to float. // complex values such as "rotate(1rad)" are returned as is. result = jquery.css(tween.elem, tween.prop, false, ""); // empty strings, null, undefined and "auto" are converted to 0. return !result || result === "auto" ? 0 : result; }, set: function (tween) { // use step hook for back compat - use csshook if its there - use .style if its // available and use plain properties where available if (jquery.fx.step[tween.prop]) { jquery.fx.step[tween.prop](tween); } else if (tween.elem.style && (tween.elem.style[jquery.cssprops[tween.prop]] != null || jquery.csshooks[tween.prop])) { jquery.style(tween.elem, tween.prop, tween.now + tween.unit); } else { tween.elem[tween.prop] = tween.now; } } } }; // remove in 2.0 - this supports ie8's panic based approach // to setting things on disconnected nodes tween.prophooks.scrolltop = tween.prophooks.scrollleft = { set: function (tween) { if (tween.elem.nodetype && tween.elem.parentnode) { tween.elem[tween.prop] = tween.now; } } }; jquery.each(["toggle", "show", "hide"], function (i, name) { var cssfn = jquery.fn[name]; jquery.fn[name] = function (speed, easing, callback) { return speed == null || typeof speed === "boolean" || // special check for .toggle( handler, handler, ... ) (!i && jquery.isfunction(speed) && jquery.isfunction(easing)) ? cssfn.apply(this, arguments) : this.animate(genfx(name, true), speed, easing, callback); }; }); jquery.fn.extend({ fadeto: function (speed, to, easing, callback) { // show any hidden elements after setting opacity to 0 return this.filter(ishidden).css("opacity", 0).show() // animate to the value specified .end().animate({ opacity: to }, speed, easing, callback); }, animate: function (prop, speed, easing, callback) { var empty = jquery.isemptyobject(prop), optall = jquery.speed(speed, easing, callback), doanimation = function () { // operate on a copy of prop so per-property easing won't be lost var anim = animation(this, jquery.extend({}, prop), optall); // empty animations resolve immediately if (empty) { anim.stop(true); } }; return empty || optall.queue === false ? this.each(doanimation) : this.queue(optall.queue, doanimation); }, stop: function (type, clearqueue, gotoend) { var stopqueue = function (hooks) { var stop = hooks.stop; delete hooks.stop; stop(gotoend); }; if (typeof type !== "string") { gotoend = clearqueue; clearqueue = type; type = undefined; } if (clearqueue && type !== false) { this.queue(type || "fx", []); } return this.each(function () { var dequeue = true, index = type != null && type + "queuehooks", timers = jquery.timers, data = jquery._data(this); if (index) { if (data[index] && data[index].stop) { stopqueue(data[index]); } } else { for (index in data) { if (data[index] && data[index].stop && rrun.test(index)) { stopqueue(data[index]); } } } for (index = timers.length; index--;) { if (timers[index].elem === this && (type == null || timers[index].queue === type)) { timers[index].anim.stop(gotoend); dequeue = false; timers.splice(index, 1); } } // start the next in the queue if the last step wasn't forced // timers currently will call their complete callbacks, which will dequeue // but only if they were gotoend if (dequeue || !gotoend) { jquery.dequeue(this, type); } }); } }); // generate parameters to create a standard animation function genfx(type, includewidth) { var which, attrs = { height: type }, i = 0; // if we include width, step value is 1 to do all cssexpand values, // if we don't include width, step value is 2 to skip over left and right includewidth = includewidth ? 1 : 0; for (; i < 4 ; i += 2 - includewidth) { which = cssexpand[i]; attrs["margin" + which] = attrs["padding" + which] = type; } if (includewidth) { attrs.opacity = attrs.width = type; } return attrs; } // generate shortcuts for custom animations jquery.each({ slidedown: genfx("show"), slideup: genfx("hide"), slidetoggle: genfx("toggle"), fadein: { opacity: "show" }, fadeout: { opacity: "hide" }, fadetoggle: { opacity: "toggle" } }, function (name, props) { jquery.fn[name] = function (speed, easing, callback) { return this.animate(props, speed, easing, callback); }; }); jquery.speed = function (speed, easing, fn) { var opt = speed && typeof speed === "object" ? jquery.extend({}, speed) : { complete: fn || !fn && easing || jquery.isfunction(speed) && speed, duration: speed, easing: fn && easing || easing && !jquery.isfunction(easing) && easing }; opt.duration = jquery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration in jquery.fx.speeds ? jquery.fx.speeds[opt.duration] : jquery.fx.speeds._default; // normalize opt.queue - true/undefined/null -> "fx" if (opt.queue == null || opt.queue === true) { opt.queue = "fx"; } // queueing opt.old = opt.complete; opt.complete = function () { if (jquery.isfunction(opt.old)) { opt.old.call(this); } if (opt.queue) { jquery.dequeue(this, opt.queue); } }; return opt; }; jquery.easing = { linear: function (p) { return p; }, swing: function (p) { return 0.5 - math.cos(p * math.pi) / 2; } }; jquery.timers = []; jquery.fx = tween.prototype.init; jquery.fx.tick = function () { var timer, timers = jquery.timers, i = 0; fxnow = jquery.now(); for (; i < timers.length; i++) { timer = timers[i]; // checks the timer has not already been removed if (!timer() && timers[i] === timer) { timers.splice(i--, 1); } } if (!timers.length) { jquery.fx.stop(); } fxnow = undefined; }; jquery.fx.timer = function (timer) { if (timer() && jquery.timers.push(timer) && !timerid) { timerid = setinterval(jquery.fx.tick, jquery.fx.interval); } }; jquery.fx.interval = 13; jquery.fx.stop = function () { clearinterval(timerid); timerid = null; }; jquery.fx.speeds = { slow: 600, fast: 200, // default speed _default: 400 }; // back compat <1.8 extension point jquery.fx.step = {}; if (jquery.expr && jquery.expr.filters) { jquery.expr.filters.animated = function (elem) { return jquery.grep(jquery.timers, function (fn) { return elem === fn.elem; }).length; }; } var rroot = /^(?:body|html)$/i; jquery.fn.offset = function (options) { if (arguments.length) { return options === undefined ? this : this.each(function (i) { jquery.offset.setoffset(this, options, i); }); } var docelem, body, win, clienttop, clientleft, scrolltop, scrollleft, box = { top: 0, left: 0 }, elem = this[0], doc = elem && elem.ownerdocument; if (!doc) { return; } if ((body = doc.body) === elem) { return jquery.offset.bodyoffset(elem); } docelem = doc.documentelement; // make sure it's not a disconnected dom node if (!jquery.contains(docelem, elem)) { return box; } // if we don't have gbcr, just use 0,0 rather than error // blackberry 5, ios 3 (original iphone) if (typeof elem.getboundingclientrect !== "undefined") { box = elem.getboundingclientrect(); } win = getwindow(doc); clienttop = docelem.clienttop || body.clienttop || 0; clientleft = docelem.clientleft || body.clientleft || 0; scrolltop = win.pageyoffset || docelem.scrolltop; scrollleft = win.pagexoffset || docelem.scrollleft; return { top: box.top + scrolltop - clienttop, left: box.left + scrollleft - clientleft }; }; jquery.offset = { bodyoffset: function (body) { var top = body.offsettop, left = body.offsetleft; if (jquery.support.doesnotincludemargininbodyoffset) { top += parsefloat(jquery.css(body, "margintop")) || 0; left += parsefloat(jquery.css(body, "marginleft")) || 0; } return { top: top, left: left }; }, setoffset: function (elem, options, i) { var position = jquery.css(elem, "position"); // set position first, in-case top/left are set even on static elem if (position === "static") { elem.style.position = "relative"; } var curelem = jquery(elem), curoffset = curelem.offset(), curcsstop = jquery.css(elem, "top"), curcssleft = jquery.css(elem, "left"), calculateposition = (position === "absolute" || position === "fixed") && jquery.inarray("auto", [curcsstop, curcssleft]) > -1, props = {}, curposition = {}, curtop, curleft; // need to be able to calculate position if either top or left is auto and position is either absolute or fixed if (calculateposition) { curposition = curelem.position(); curtop = curposition.top; curleft = curposition.left; } else { curtop = parsefloat(curcsstop) || 0; curleft = parsefloat(curcssleft) || 0; } if (jquery.isfunction(options)) { options = options.call(elem, i, curoffset); } if (options.top != null) { props.top = (options.top - curoffset.top) + curtop; } if (options.left != null) { props.left = (options.left - curoffset.left) + curleft; } if ("using" in options) { options.using.call(elem, props); } else { curelem.css(props); } } }; jquery.fn.extend({ position: function () { if (!this[0]) { return; } 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 }; }, offsetparent: function () { 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 || document.body; }); } }); // create scrollleft and scrolltop methods jquery.each({ scrollleft: "pagexoffset", scrolltop: "pageyoffset" }, function (method, prop) { var top = /y/.test(prop); jquery.fn[method] = function (val) { return jquery.access(this, function (elem, method, val) { var win = getwindow(elem); if (val === undefined) { return win ? (prop in win) ? win[prop] : win.document.documentelement[method] : elem[method]; } if (win) { win.scrollto( !top ? val : jquery(win).scrollleft(), top ? val : jquery(win).scrolltop() ); } else { elem[method] = val; } }, method, val, arguments.length, null); }; }); function getwindow(elem) { return jquery.iswindow(elem) ? elem : elem.nodetype === 9 ? elem.defaultview || elem.parentwindow : false; } // create innerheight, innerwidth, height, width, outerheight and outerwidth methods jquery.each({ height: "height", width: "width" }, function (name, type) { jquery.each({ padding: "inner" + name, content: type, "": "outer" + name }, function (defaultextra, funcname) { // margin is only for outerheight, outerwidth jquery.fn[funcname] = function (margin, value) { var chainable = arguments.length && (defaultextra || typeof margin !== "boolean"), extra = defaultextra || (margin === true || value === true ? "margin" : "border"); return jquery.access(this, function (elem, type, value) { var doc; if (jquery.iswindow(elem)) { // as of 5/8/2012 this will yield incorrect results for mobile safari, but there // isn't a whole lot we can do. see pull request at this url for discussion: // https://github.com/jquery/jquery/pull/764 return elem.document.documentelement["client" + name]; } // get document width or height if (elem.nodetype === 9) { doc = elem.documentelement; // either scroll[width/height] or offset[width/height] or client[width/height], whichever is greatest // unfortunately, this causes bug #3838 in ie6/8 only, but there is currently no good, small way to fix it. return math.max( elem.body["scroll" + name], doc["scroll" + name], elem.body["offset" + name], doc["offset" + name], doc["client" + name] ); } return value === undefined ? // get width or height on the element, requesting but not forcing parsefloat jquery.css(elem, type, value, extra) : // set width or height on the element jquery.style(elem, type, value, extra); }, type, chainable ? margin : undefined, chainable, null); }; }); }); // expose jquery to the global object window.jquery = window.$ = jquery; // expose jquery as an amd module, but only for amd loaders that // understand the issues with loading multiple versions of jquery // in a page that all might call define(). the loader will indicate // they have special allowances for multiple jquery versions by // specifying define.amd.jquery = true. register as a named module, // since jquery can be concatenated with other files that may use define, // but not use a proper concatenation script that understands anonymous // amd modules. a named amd is safest and most robust way to register. // lowercase jquery is used because amd module names are derived from // file names, and jquery is normally delivered in a lowercase file name. // do this after creating the global so that if an amd module wants to call // noconflict to hide this version of jquery, it will work. if (typeof define === "function" && define.amd && define.amd.jquery) { define("jquery", [], function () { return jquery; }); } })(window);