blob: 4167af33f2e57fcf0fa9481523054da65b769b7b [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/** vim: et:ts=4:sw=4:sts=4
2 * @license RequireJS 2.0.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
3 * Available via the MIT or new BSD license.
4 * see: http://github.com/jrburke/requirejs for details
5 */
6/*jslint regexp: true, nomen: true */
7/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
8
9var requirejs, require, define;
10(function (global) {
11 'use strict';
12
13 var version = '0.0.0',
14 commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
15 cjsRequireRegExp = /require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
16 jsSuffixRegExp = /\.js$/,
17 currDirRegExp = /^\.\//,
18 ostring = Object.prototype.toString,
19 ap = Array.prototype,
20 aps = ap.slice,
21 apsp = ap.splice,
22 isBrowser = !!(typeof window !== 'undefined' && navigator && document),
23 isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
24 //PS3 indicates loaded and complete, but need to wait for complete
25 //specifically. Sequence is 'loading', 'loaded', execution,
26 // then 'complete'. The UA check is unfortunate, but not sure how
27 //to feature test w/o causing perf issues.
28 readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
29 /^complete$/ : /^(complete|loaded)$/,
30 defContextName = '_',
31 //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
32 isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
33 contexts = {},
34 cfg = {},
35 globalDefQueue = [],
36 useInteractive = false,
37 req, s, head, baseElement, dataMain, src,
38 interactiveScript, currentlyAddingScript, mainScript, subPath;
39
40 function isFunction(it) {
41 return ostring.call(it) === '[object Function]';
42 }
43
44 function isArray(it) {
45 return ostring.call(it) === '[object Array]';
46 }
47
48 /**
49 * Helper function for iterating over an array. If the func returns
50 * a true value, it will break out of the loop.
51 */
52 function each(ary, func) {
53 if (ary) {
54 var i;
55 for (i = 0; i < ary.length; i += 1) {
56 if (ary[i] && func(ary[i], i, ary)) {
57 break;
58 }
59 }
60 }
61 }
62
63 /**
64 * Helper function for iterating over an array backwards. If the func
65 * returns a true value, it will break out of the loop.
66 */
67 function eachReverse(ary, func) {
68 if (ary) {
69 var i;
70 for (i = ary.length - 1; i > -1; i -= 1) {
71 if (ary[i] && func(ary[i], i, ary)) {
72 break;
73 }
74 }
75 }
76 }
77
78 function hasProp(obj, prop) {
79 return obj.hasOwnProperty(prop);
80 }
81
82 /**
83 * Cycles over properties in an object and calls a function for each
84 * property value. If the function returns a truthy value, then the
85 * iteration is stopped.
86 */
87 function eachProp(obj, func) {
88 var prop;
89 for (prop in obj) {
90 if (obj.hasOwnProperty(prop)) {
91 if (func(obj[prop], prop)) {
92 break;
93 }
94 }
95 }
96 }
97
98 /**
99 * Simple function to mix in properties from source into target,
100 * but only if target does not already have a property of the same name.
101 * This is not robust in IE for transferring methods that match
102 * Object.prototype names, but the uses of mixin here seem unlikely to
103 * trigger a problem related to that.
104 */
105 function mixin(target, source, force, deepStringMixin) {
106 if (source) {
107 eachProp(source, function (value, prop) {
108 if (force || !hasProp(target, prop)) {
109 if (deepStringMixin && typeof value !== 'string') {
110 if (!target[prop]) {
111 target[prop] = {};
112 }
113 mixin(target[prop], value, force, deepStringMixin);
114 } else {
115 target[prop] = value;
116 }
117 }
118 });
119 }
120 return target;
121 }
122
123 //Similar to Function.prototype.bind, but the 'this' object is specified
124 //first, since it is easier to read/figure out what 'this' will be.
125 function bind(obj, fn) {
126 return function () {
127 return fn.apply(obj, arguments);
128 };
129 }
130
131 function scripts() {
132 return document.getElementsByTagName('script');
133 }
134
135 //Allow getting a global that expressed in
136 //dot notation, like 'a.b.c'.
137 function getGlobal(value) {
138 if (!value) {
139 return value;
140 }
141 var g = global;
142 each(value.split('.'), function (part) {
143 g = g[part];
144 });
145 return g;
146 }
147
148 function makeContextModuleFunc(func, relMap, enableBuildCallback) {
149 return function () {
150 //A version of a require function that passes a moduleName
151 //value for items that may need to
152 //look up paths relative to the moduleName
153 var args = aps.call(arguments, 0), lastArg;
154 if (enableBuildCallback &&
155 isFunction((lastArg = args[args.length - 1]))) {
156 lastArg.__requireJsBuild = true;
157 }
158 args.push(relMap);
159 return func.apply(null, args);
160 };
161 }
162
163 function addRequireMethods(req, context, relMap) {
164 each([
165 ['toUrl'],
166 ['undef'],
167 ['defined', 'requireDefined'],
168 ['specified', 'requireSpecified']
169 ], function (item) {
170 var prop = item[1] || item[0];
171 req[item[0]] = context ? makeContextModuleFunc(context[prop], relMap) :
172 //If no context, then use default context. Reference from
173 //contexts instead of early binding to default context, so
174 //that during builds, the latest instance of the default
175 //context with its config gets used.
176 function () {
177 var ctx = contexts[defContextName];
178 return ctx[prop].apply(ctx, arguments);
179 };
180 });
181 }
182
183 /**
184 * Constructs an error with a pointer to an URL with more information.
185 * @param {String} id the error ID that maps to an ID on a web page.
186 * @param {String} message human readable error.
187 * @param {Error} [err] the original error, if there is one.
188 *
189 * @returns {Error}
190 */
191 function makeError(id, msg, err, requireModules) {
192 var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
193 e.requireType = id;
194 e.requireModules = requireModules;
195 if (err) {
196 e.originalError = err;
197 }
198 return e;
199 }
200
201 if (typeof define !== 'undefined') {
202 //If a define is already in play via another AMD loader,
203 //do not overwrite.
204 return;
205 }
206
207 if (typeof requirejs !== 'undefined') {
208 if (isFunction(requirejs)) {
209 //Do not overwrite and existing requirejs instance.
210 return;
211 }
212 cfg = requirejs;
213 requirejs = undefined;
214 }
215
216 //Allow for a require config object
217 if (typeof require !== 'undefined' && !isFunction(require)) {
218 //assume it is a config object.
219 cfg = require;
220 require = undefined;
221 }
222
223 function newContext(contextName) {
224 var config = {
225 waitSeconds: 7,
226 baseUrl: './',
227 paths: {},
228 pkgs: {},
229 shim: {}
230 },
231 registry = {},
232 undefEvents = {},
233 defQueue = [],
234 defined = {},
235 urlFetched = {},
236 requireCounter = 1,
237 unnormalizedCounter = 1,
238 //Used to track the order in which modules
239 //should be executed, by the order they
240 //load. Important for consistent cycle resolution
241 //behavior.
242 waitAry = [],
243 inCheckLoaded, Module, context, handlers,
244 checkLoadedTimeoutId;
245
246 /**
247 * Trims the . and .. from an array of path segments.
248 * It will keep a leading path segment if a .. will become
249 * the first path segment, to help with module name lookups,
250 * which act like paths, but can be remapped. But the end result,
251 * all paths that use this function should look normalized.
252 * NOTE: this method MODIFIES the input array.
253 * @param {Array} ary the array of path segments.
254 */
255 function trimDots(ary) {
256 var i, part;
257 for (i = 0; ary[i]; i+= 1) {
258 part = ary[i];
259 if (part === '.') {
260 ary.splice(i, 1);
261 i -= 1;
262 } else if (part === '..') {
263 if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
264 //End of the line. Keep at least one non-dot
265 //path segment at the front so it can be mapped
266 //correctly to disk. Otherwise, there is likely
267 //no path mapping for a path starting with '..'.
268 //This can still fail, but catches the most reasonable
269 //uses of ..
270 break;
271 } else if (i > 0) {
272 ary.splice(i - 1, 2);
273 i -= 2;
274 }
275 }
276 }
277 }
278
279 /**
280 * Given a relative module name, like ./something, normalize it to
281 * a real name that can be mapped to a path.
282 * @param {String} name the relative name
283 * @param {String} baseName a real name that the name arg is relative
284 * to.
285 * @param {Boolean} applyMap apply the map config to the value. Should
286 * only be done if this normalization is for a dependency ID.
287 * @returns {String} normalized name
288 */
289 function normalize(name, baseName, applyMap) {
290 var baseParts = baseName && baseName.split('/'),
291 map = config.map,
292 starMap = map && map['*'],
293 pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
294 foundMap;
295
296 //Adjust any relative paths.
297 if (name && name.charAt(0) === '.') {
298 //If have a base name, try to normalize against it,
299 //otherwise, assume it is a top-level require that will
300 //be relative to baseUrl in the end.
301 if (baseName) {
302 if (config.pkgs[baseName]) {
303 //If the baseName is a package name, then just treat it as one
304 //name to concat the name with.
305 baseParts = [baseName];
306 } else {
307 //Convert baseName to array, and lop off the last part,
308 //so that . matches that 'directory' and not name of the baseName's
309 //module. For instance, baseName of 'one/two/three', maps to
310 //'one/two/three.js', but we want the directory, 'one/two' for
311 //this normalization.
312 baseParts = baseParts.slice(0, baseParts.length - 1);
313 }
314
315 name = baseParts.concat(name.split('/'));
316 trimDots(name);
317
318 //Some use of packages may use a . path to reference the
319 //'main' module name, so normalize for that.
320 pkgConfig = config.pkgs[(pkgName = name[0])];
321 name = name.join('/');
322 if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
323 name = pkgName;
324 }
325 } else if (name.indexOf('./') === 0) {
326 // No baseName, so this is ID is resolved relative
327 // to baseUrl, pull off the leading dot.
328 name = name.substring(2);
329 }
330 }
331
332 //Apply map config if available.
333 if (applyMap && (baseParts || starMap) && map) {
334 nameParts = name.split('/');
335
336 for (i = nameParts.length; i > 0; i -= 1) {
337 nameSegment = nameParts.slice(0, i).join('/');
338
339 if (baseParts) {
340 //Find the longest baseName segment match in the config.
341 //So, do joins on the biggest to smallest lengths of baseParts.
342 for (j = baseParts.length; j > 0; j -= 1) {
343 mapValue = map[baseParts.slice(0, j).join('/')];
344
345 //baseName segment has config, find if it has one for
346 //this name.
347 if (mapValue) {
348 mapValue = mapValue[nameSegment];
349 if (mapValue) {
350 //Match, update name to the new value.
351 foundMap = mapValue;
352 break;
353 }
354 }
355 }
356 }
357
358 if (!foundMap && starMap && starMap[nameSegment]) {
359 foundMap = starMap[nameSegment];
360 }
361
362 if (foundMap) {
363 nameParts.splice(0, i, foundMap);
364 name = nameParts.join('/');
365 break;
366 }
367 }
368 }
369
370 return name;
371 }
372
373 function removeScript(name) {
374 if (isBrowser) {
375 each(scripts(), function (scriptNode) {
376 if (scriptNode.getAttribute('data-requiremodule') === name &&
377 scriptNode.getAttribute('data-requirecontext') === context.contextName) {
378 scriptNode.parentNode.removeChild(scriptNode);
379 return true;
380 }
381 });
382 }
383 }
384
385 function hasPathFallback(id) {
386 var pathConfig = config.paths[id];
387 if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
388 removeScript(id);
389 //Pop off the first array value, since it failed, and
390 //retry
391 pathConfig.shift();
392 context.undef(id);
393 context.require([id]);
394 return true;
395 }
396 }
397
398 /**
399 * Creates a module mapping that includes plugin prefix, module
400 * name, and path. If parentModuleMap is provided it will
401 * also normalize the name via require.normalize()
402 *
403 * @param {String} name the module name
404 * @param {String} [parentModuleMap] parent module map
405 * for the module name, used to resolve relative names.
406 * @param {Boolean} isNormalized: is the ID already normalized.
407 * This is true if this call is done for a define() module ID.
408 * @param {Boolean} applyMap: apply the map config to the ID.
409 * Should only be true if this map is for a dependency.
410 *
411 * @returns {Object}
412 */
413 function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
414 var index = name ? name.indexOf('!') : -1,
415 prefix = null,
416 parentName = parentModuleMap ? parentModuleMap.name : null,
417 originalName = name,
418 isDefine = true,
419 normalizedName = '',
420 url, pluginModule, suffix;
421
422 //If no name, then it means it is a require call, generate an
423 //internal name.
424 if (!name) {
425 isDefine = false;
426 name = '_@r' + (requireCounter += 1);
427 }
428
429 if (index !== -1) {
430 prefix = name.substring(0, index);
431 name = name.substring(index + 1, name.length);
432 }
433
434 if (prefix) {
435 prefix = normalize(prefix, parentName, applyMap);
436 pluginModule = defined[prefix];
437 }
438
439 //Account for relative paths if there is a base name.
440 if (name) {
441 if (prefix) {
442 if (pluginModule && pluginModule.normalize) {
443 //Plugin is loaded, use its normalize method.
444 normalizedName = pluginModule.normalize(name, function (name) {
445 return normalize(name, parentName, applyMap);
446 });
447 } else {
448 normalizedName = normalize(name, parentName, applyMap);
449 }
450 } else {
451 //A regular module.
452 normalizedName = normalize(name, parentName, applyMap);
453
454 //Calculate url for the module, if it has a name.
455 //Use name here since nameToUrl also calls normalize,
456 //and for relative names that are outside the baseUrl
457 //this causes havoc. Was thinking of just removing
458 //parentModuleMap to avoid extra normalization, but
459 //normalize() still does a dot removal because of
460 //issue #142, so just pass in name here and redo
461 //the normalization. Paths outside baseUrl are just
462 //messy to support.
463 url = context.nameToUrl(name, null, parentModuleMap);
464 }
465 }
466
467 //If the id is a plugin id that cannot be determined if it needs
468 //normalization, stamp it with a unique ID so two matching relative
469 //ids that may conflict can be separate.
470 suffix = prefix && !pluginModule && !isNormalized ?
471 '_unnormalized' + (unnormalizedCounter += 1) :
472 '';
473
474 return {
475 prefix: prefix,
476 name: normalizedName,
477 parentMap: parentModuleMap,
478 unnormalized: !!suffix,
479 url: url,
480 originalName: originalName,
481 isDefine: isDefine,
482 id: (prefix ?
483 prefix + '!' + normalizedName :
484 normalizedName) + suffix
485 };
486 }
487
488 function getModule(depMap) {
489 var id = depMap.id,
490 mod = registry[id];
491
492 if (!mod) {
493 mod = registry[id] = new context.Module(depMap);
494 }
495
496 return mod;
497 }
498
499 function on(depMap, name, fn) {
500 var id = depMap.id,
501 mod = registry[id];
502
503 if (hasProp(defined, id) &&
504 (!mod || mod.defineEmitComplete)) {
505 if (name === 'defined') {
506 fn(defined[id]);
507 }
508 } else {
509 getModule(depMap).on(name, fn);
510 }
511 }
512
513 function onError(err, errback) {
514 var ids = err.requireModules,
515 notified = false;
516
517 if (errback) {
518 errback(err);
519 } else {
520 each(ids, function (id) {
521 var mod = registry[id];
522 if (mod) {
523 //Set error on module, so it skips timeout checks.
524 mod.error = err;
525 if (mod.events.error) {
526 notified = true;
527 mod.emit('error', err);
528 }
529 }
530 });
531
532 if (!notified) {
533 req.onError(err);
534 }
535 }
536 }
537
538 /**
539 * Internal method to transfer globalQueue items to this context's
540 * defQueue.
541 */
542 function takeGlobalQueue() {
543 //Push all the globalDefQueue items into the context's defQueue
544 if (globalDefQueue.length) {
545 //Array splice in the values since the context code has a
546 //local var ref to defQueue, so cannot just reassign the one
547 //on context.
548 apsp.apply(defQueue,
549 [defQueue.length - 1, 0].concat(globalDefQueue));
550 globalDefQueue = [];
551 }
552 }
553
554 /**
555 * Helper function that creates a require function object to give to
556 * modules that ask for it as a dependency. It needs to be specific
557 * per module because of the implication of path mappings that may
558 * need to be relative to the module name.
559 */
560 function makeRequire(mod, enableBuildCallback, altRequire) {
561 var relMap = mod && mod.map,
562 modRequire = makeContextModuleFunc(altRequire || context.require,
563 relMap,
564 enableBuildCallback);
565
566 addRequireMethods(modRequire, context, relMap);
567 modRequire.isBrowser = isBrowser;
568
569 return modRequire;
570 }
571
572 handlers = {
573 'require': function (mod) {
574 return makeRequire(mod);
575 },
576 'exports': function (mod) {
577 mod.usingExports = true;
578 if (mod.map.isDefine) {
579 return (mod.exports = defined[mod.map.id] = {});
580 }
581 },
582 'module': function (mod) {
583 return (mod.module = {
584 id: mod.map.id,
585 uri: mod.map.url,
586 config: function () {
587 return (config.config && config.config[mod.map.id]) || {};
588 },
589 exports: defined[mod.map.id]
590 });
591 }
592 };
593
594 function removeWaiting(id) {
595 //Clean up machinery used for waiting modules.
596 delete registry[id];
597
598 each(waitAry, function (mod, i) {
599 if (mod.map.id === id) {
600 waitAry.splice(i, 1);
601 if (!mod.defined) {
602 context.waitCount -= 1;
603 }
604 return true;
605 }
606 });
607 }
608
609 function findCycle(mod, traced) {
610 var id = mod.map.id,
611 depArray = mod.depMaps,
612 foundModule;
613
614 //Do not bother with unitialized modules or not yet enabled
615 //modules.
616 if (!mod.inited) {
617 return;
618 }
619
620 //Found the cycle.
621 if (traced[id]) {
622 return mod;
623 }
624
625 traced[id] = true;
626
627 //Trace through the dependencies.
628 each(depArray, function (depMap) {
629 var depId = depMap.id,
630 depMod = registry[depId];
631
632 if (!depMod) {
633 return;
634 }
635
636 if (!depMod.inited || !depMod.enabled) {
637 //Dependency is not inited, so this cannot
638 //be used to determine a cycle.
639 foundModule = null;
640 delete traced[id];
641 return true;
642 }
643
644 //mixin traced to a new object for each dependency, so that
645 //sibling dependencies in this object to not generate a
646 //false positive match on a cycle. Ideally an Object.create
647 //type of prototype delegation would be used here, but
648 //optimizing for file size vs. execution speed since hopefully
649 //the trees are small for circular dependency scans relative
650 //to the full app perf.
651 return (foundModule = findCycle(depMod, mixin({}, traced)));
652 });
653
654 return foundModule;
655 }
656
657 function forceExec(mod, traced, uninited) {
658 var id = mod.map.id,
659 depArray = mod.depMaps;
660
661 if (!mod.inited || !mod.map.isDefine) {
662 return;
663 }
664
665 if (traced[id]) {
666 return defined[id];
667 }
668
669 traced[id] = mod;
670
671 each(depArray, function(depMap) {
672 var depId = depMap.id,
673 depMod = registry[depId],
674 value;
675
676 if (handlers[depId]) {
677 return;
678 }
679
680 if (depMod) {
681 if (!depMod.inited || !depMod.enabled) {
682 //Dependency is not inited,
683 //so this module cannot be
684 //given a forced value yet.
685 uninited[id] = true;
686 return;
687 }
688
689 //Get the value for the current dependency
690 value = forceExec(depMod, traced, uninited);
691
692 //Even with forcing it may not be done,
693 //in particular if the module is waiting
694 //on a plugin resource.
695 if (!uninited[depId]) {
696 mod.defineDepById(depId, value);
697 }
698 }
699 });
700
701 mod.check(true);
702
703 return defined[id];
704 }
705
706 function modCheck(mod) {
707 mod.check();
708 }
709
710 function checkLoaded() {
711 var waitInterval = config.waitSeconds * 1000,
712 //It is possible to disable the wait interval by using waitSeconds of 0.
713 expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
714 noLoads = [],
715 stillLoading = false,
716 needCycleCheck = true,
717 map, modId, err, usingPathFallback;
718
719 //Do not bother if this call was a result of a cycle break.
720 if (inCheckLoaded) {
721 return;
722 }
723
724 inCheckLoaded = true;
725
726 //Figure out the state of all the modules.
727 eachProp(registry, function (mod) {
728 map = mod.map;
729 modId = map.id;
730
731 //Skip things that are not enabled or in error state.
732 if (!mod.enabled) {
733 return;
734 }
735
736 if (!mod.error) {
737 //If the module should be executed, and it has not
738 //been inited and time is up, remember it.
739 if (!mod.inited && expired) {
740 if (hasPathFallback(modId)) {
741 usingPathFallback = true;
742 stillLoading = true;
743 } else {
744 noLoads.push(modId);
745 removeScript(modId);
746 }
747 } else if (!mod.inited && mod.fetched && map.isDefine) {
748 stillLoading = true;
749 if (!map.prefix) {
750 //No reason to keep looking for unfinished
751 //loading. If the only stillLoading is a
752 //plugin resource though, keep going,
753 //because it may be that a plugin resource
754 //is waiting on a non-plugin cycle.
755 return (needCycleCheck = false);
756 }
757 }
758 }
759 });
760
761 if (expired && noLoads.length) {
762 //If wait time expired, throw error of unloaded modules.
763 err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
764 err.contextName = context.contextName;
765 return onError(err);
766 }
767
768 //Not expired, check for a cycle.
769 if (needCycleCheck) {
770
771 each(waitAry, function (mod) {
772 if (mod.defined) {
773 return;
774 }
775
776 var cycleMod = findCycle(mod, {}),
777 traced = {};
778
779 if (cycleMod) {
780 forceExec(cycleMod, traced, {});
781
782 //traced modules may have been
783 //removed from the registry, but
784 //their listeners still need to
785 //be called.
786 eachProp(traced, modCheck);
787 }
788 });
789
790 //Now that dependencies have
791 //been satisfied, trigger the
792 //completion check that then
793 //notifies listeners.
794 eachProp(registry, modCheck);
795 }
796
797 //If still waiting on loads, and the waiting load is something
798 //other than a plugin resource, or there are still outstanding
799 //scripts, then just try back later.
800 if ((!expired || usingPathFallback) && stillLoading) {
801 //Something is still waiting to load. Wait for it, but only
802 //if a timeout is not already in effect.
803 if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
804 checkLoadedTimeoutId = setTimeout(function () {
805 checkLoadedTimeoutId = 0;
806 checkLoaded();
807 }, 50);
808 }
809 }
810
811 inCheckLoaded = false;
812 }
813
814 Module = function (map) {
815 this.events = undefEvents[map.id] || {};
816 this.map = map;
817 this.shim = config.shim[map.id];
818 this.depExports = [];
819 this.depMaps = [];
820 this.depMatched = [];
821 this.pluginMaps = {};
822 this.depCount = 0;
823
824 /* this.exports this.factory
825 this.depMaps = [],
826 this.enabled, this.fetched
827 */
828 };
829
830 Module.prototype = {
831 init: function(depMaps, factory, errback, options) {
832 options = options || {};
833
834 //Do not do more inits if already done. Can happen if there
835 //are multiple define calls for the same module. That is not
836 //a normal, common case, but it is also not unexpected.
837 if (this.inited) {
838 return;
839 }
840
841 this.factory = factory;
842
843 if (errback) {
844 //Register for errors on this module.
845 this.on('error', errback);
846 } else if (this.events.error) {
847 //If no errback already, but there are error listeners
848 //on this module, set up an errback to pass to the deps.
849 errback = bind(this, function (err) {
850 this.emit('error', err);
851 });
852 }
853
854 //Do a copy of the dependency array, so that
855 //source inputs are not modified. For example
856 //"shim" deps are passed in here directly, and
857 //doing a direct modification of the depMaps array
858 //would affect that config.
859 this.depMaps = depMaps && depMaps.slice(0);
860 this.depMaps.rjsSkipMap = depMaps.rjsSkipMap;
861
862 this.errback = errback;
863
864 //Indicate this module has be initialized
865 this.inited = true;
866
867 this.ignore = options.ignore;
868
869 //Could have option to init this module in enabled mode,
870 //or could have been previously marked as enabled. However,
871 //the dependencies are not known until init is called. So
872 //if enabled previously, now trigger dependencies as enabled.
873 if (options.enabled || this.enabled) {
874 //Enable this module and dependencies.
875 //Will call this.check()
876 this.enable();
877 } else {
878 this.check();
879 }
880 },
881
882 defineDepById: function (id, depExports) {
883 var i;
884
885 //Find the index for this dependency.
886 each(this.depMaps, function (map, index) {
887 if (map.id === id) {
888 i = index;
889 return true;
890 }
891 });
892
893 return this.defineDep(i, depExports);
894 },
895
896 defineDep: function (i, depExports) {
897 //Because of cycles, defined callback for a given
898 //export can be called more than once.
899 if (!this.depMatched[i]) {
900 this.depMatched[i] = true;
901 this.depCount -= 1;
902 this.depExports[i] = depExports;
903 }
904 },
905
906 fetch: function () {
907 if (this.fetched) {
908 return;
909 }
910 this.fetched = true;
911
912 context.startTime = (new Date()).getTime();
913
914 var map = this.map;
915
916 //If the manager is for a plugin managed resource,
917 //ask the plugin to load it now.
918 if (this.shim) {
919 makeRequire(this, true)(this.shim.deps || [], bind(this, function () {
920 return map.prefix ? this.callPlugin() : this.load();
921 }));
922 } else {
923 //Regular dependency.
924 return map.prefix ? this.callPlugin() : this.load();
925 }
926 },
927
928 load: function() {
929 var url = this.map.url;
930
931 //Regular dependency.
932 if (!urlFetched[url]) {
933 urlFetched[url] = true;
934 context.load(this.map.id, url);
935 }
936 },
937
938 /**
939 * Checks is the module is ready to define itself, and if so,
940 * define it. If the silent argument is true, then it will just
941 * define, but not notify listeners, and not ask for a context-wide
942 * check of all loaded modules. That is useful for cycle breaking.
943 */
944 check: function (silent) {
945 if (!this.enabled || this.enabling) {
946 return;
947 }
948
949 var id = this.map.id,
950 depExports = this.depExports,
951 exports = this.exports,
952 factory = this.factory,
953 err, cjsModule;
954
955 if (!this.inited) {
956 this.fetch();
957 } else if (this.error) {
958 this.emit('error', this.error);
959 } else if (!this.defining) {
960 //The factory could trigger another require call
961 //that would result in checking this module to
962 //define itself again. If already in the process
963 //of doing that, skip this work.
964 this.defining = true;
965
966 if (this.depCount < 1 && !this.defined) {
967 if (isFunction(factory)) {
968 //If there is an error listener, favor passing
969 //to that instead of throwing an error.
970 if (this.events.error) {
971 try {
972 exports = context.execCb(id, factory, depExports, exports);
973 } catch (e) {
974 err = e;
975 }
976 } else {
977 exports = context.execCb(id, factory, depExports, exports);
978 }
979
980 if (this.map.isDefine) {
981 //If setting exports via 'module' is in play,
982 //favor that over return value and exports. After that,
983 //favor a non-undefined return value over exports use.
984 cjsModule = this.module;
985 if (cjsModule &&
986 cjsModule.exports !== undefined &&
987 //Make sure it is not already the exports value
988 cjsModule.exports !== this.exports) {
989 exports = cjsModule.exports;
990 } else if (exports === undefined && this.usingExports) {
991 //exports already set the defined value.
992 exports = this.exports;
993 }
994 }
995
996 if (err) {
997 err.requireMap = this.map;
998 err.requireModules = [this.map.id];
999 err.requireType = 'define';
1000 return onError((this.error = err));
1001 }
1002
1003 } else {
1004 //Just a literal value
1005 exports = factory;
1006 }
1007
1008 this.exports = exports;
1009
1010 if (this.map.isDefine && !this.ignore) {
1011 defined[id] = exports;
1012
1013 if (req.onResourceLoad) {
1014 req.onResourceLoad(context, this.map, this.depMaps);
1015 }
1016 }
1017
1018 //Clean up
1019 delete registry[id];
1020
1021 this.defined = true;
1022 context.waitCount -= 1;
1023 if (context.waitCount === 0) {
1024 //Clear the wait array used for cycles.
1025 waitAry = [];
1026 }
1027 }
1028
1029 //Finished the define stage. Allow calling check again
1030 //to allow define notifications below in the case of a
1031 //cycle.
1032 this.defining = false;
1033
1034 if (!silent) {
1035 if (this.defined && !this.defineEmitted) {
1036 this.defineEmitted = true;
1037 this.emit('defined', this.exports);
1038 this.defineEmitComplete = true;
1039 }
1040 }
1041 }
1042 },
1043
1044 callPlugin: function() {
1045 var map = this.map,
1046 id = map.id,
1047 pluginMap = makeModuleMap(map.prefix, null, false, true);
1048
1049 on(pluginMap, 'defined', bind(this, function (plugin) {
1050 var name = this.map.name,
1051 parentName = this.map.parentMap ? this.map.parentMap.name : null,
1052 load, normalizedMap, normalizedMod;
1053
1054 //If current map is not normalized, wait for that
1055 //normalized name to load instead of continuing.
1056 if (this.map.unnormalized) {
1057 //Normalize the ID if the plugin allows it.
1058 if (plugin.normalize) {
1059 name = plugin.normalize(name, function (name) {
1060 return normalize(name, parentName, true);
1061 }) || '';
1062 }
1063
1064 normalizedMap = makeModuleMap(map.prefix + '!' + name,
1065 this.map.parentMap,
1066 false,
1067 true);
1068 on(normalizedMap,
1069 'defined', bind(this, function (value) {
1070 this.init([], function () { return value; }, null, {
1071 enabled: true,
1072 ignore: true
1073 });
1074 }));
1075 normalizedMod = registry[normalizedMap.id];
1076 if (normalizedMod) {
1077 if (this.events.error) {
1078 normalizedMod.on('error', bind(this, function (err) {
1079 this.emit('error', err);
1080 }));
1081 }
1082 normalizedMod.enable();
1083 }
1084
1085 return;
1086 }
1087
1088 load = bind(this, function (value) {
1089 this.init([], function () { return value; }, null, {
1090 enabled: true
1091 });
1092 });
1093
1094 load.error = bind(this, function (err) {
1095 this.inited = true;
1096 this.error = err;
1097 err.requireModules = [id];
1098
1099 //Remove temp unnormalized modules for this module,
1100 //since they will never be resolved otherwise now.
1101 eachProp(registry, function (mod) {
1102 if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
1103 removeWaiting(mod.map.id);
1104 }
1105 });
1106
1107 onError(err);
1108 });
1109
1110 //Allow plugins to load other code without having to know the
1111 //context or how to 'complete' the load.
1112 load.fromText = function (moduleName, text) {
1113 /*jslint evil: true */
1114 var hasInteractive = useInteractive;
1115
1116 //Turn off interactive script matching for IE for any define
1117 //calls in the text, then turn it back on at the end.
1118 if (hasInteractive) {
1119 useInteractive = false;
1120 }
1121
1122 //Prime the system by creating a module instance for
1123 //it.
1124 getModule(makeModuleMap(moduleName));
1125
1126 req.exec(text);
1127
1128 if (hasInteractive) {
1129 useInteractive = true;
1130 }
1131
1132 //Support anonymous modules.
1133 context.completeLoad(moduleName);
1134 };
1135
1136 //Use parentName here since the plugin's name is not reliable,
1137 //could be some weird string with no path that actually wants to
1138 //reference the parentName's path.
1139 plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb) {
1140 deps.rjsSkipMap = true;
1141 return context.require(deps, cb);
1142 }), load, config);
1143 }));
1144
1145 context.enable(pluginMap, this);
1146 this.pluginMaps[pluginMap.id] = pluginMap;
1147 },
1148
1149 enable: function () {
1150 this.enabled = true;
1151
1152 if (!this.waitPushed) {
1153 waitAry.push(this);
1154 context.waitCount += 1;
1155 this.waitPushed = true;
1156 }
1157
1158 //Set flag mentioning that the module is enabling,
1159 //so that immediate calls to the defined callbacks
1160 //for dependencies do not trigger inadvertent load
1161 //with the depCount still being zero.
1162 this.enabling = true;
1163
1164 //Enable each dependency
1165 each(this.depMaps, bind(this, function (depMap, i) {
1166 var id, mod, handler;
1167
1168 if (typeof depMap === 'string') {
1169 //Dependency needs to be converted to a depMap
1170 //and wired up to this module.
1171 depMap = makeModuleMap(depMap,
1172 (this.map.isDefine ? this.map : this.map.parentMap),
1173 false,
1174 !this.depMaps.rjsSkipMap);
1175 this.depMaps[i] = depMap;
1176
1177 handler = handlers[depMap.id];
1178
1179 if (handler) {
1180 this.depExports[i] = handler(this);
1181 return;
1182 }
1183
1184 this.depCount += 1;
1185
1186 on(depMap, 'defined', bind(this, function (depExports) {
1187 this.defineDep(i, depExports);
1188 this.check();
1189 }));
1190
1191 if (this.errback) {
1192 on(depMap, 'error', this.errback);
1193 }
1194 }
1195
1196 id = depMap.id;
1197 mod = registry[id];
1198
1199 //Skip special modules like 'require', 'exports', 'module'
1200 //Also, don't call enable if it is already enabled,
1201 //important in circular dependency cases.
1202 if (!handlers[id] && mod && !mod.enabled) {
1203 context.enable(depMap, this);
1204 }
1205 }));
1206
1207 //Enable each plugin that is used in
1208 //a dependency
1209 eachProp(this.pluginMaps, bind(this, function (pluginMap) {
1210 var mod = registry[pluginMap.id];
1211 if (mod && !mod.enabled) {
1212 context.enable(pluginMap, this);
1213 }
1214 }));
1215
1216 this.enabling = false;
1217
1218 this.check();
1219 },
1220
1221 on: function(name, cb) {
1222 var cbs = this.events[name];
1223 if (!cbs) {
1224 cbs = this.events[name] = [];
1225 }
1226 cbs.push(cb);
1227 },
1228
1229 emit: function (name, evt) {
1230 each(this.events[name], function (cb) {
1231 cb(evt);
1232 });
1233 if (name === 'error') {
1234 //Now that the error handler was triggered, remove
1235 //the listeners, since this broken Module instance
1236 //can stay around for a while in the registry/waitAry.
1237 delete this.events[name];
1238 }
1239 }
1240 };
1241
1242 function callGetModule(args) {
1243 getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
1244 }
1245
1246 function removeListener(node, func, name, ieName) {
1247 //Favor detachEvent because of IE9
1248 //issue, see attachEvent/addEventListener comment elsewhere
1249 //in this file.
1250 if (node.detachEvent && !isOpera) {
1251 //Probably IE. If not it will throw an error, which will be
1252 //useful to know.
1253 if (ieName) {
1254 node.detachEvent(ieName, func);
1255 }
1256 } else {
1257 node.removeEventListener(name, func, false);
1258 }
1259 }
1260
1261 /**
1262 * Given an event from a script node, get the requirejs info from it,
1263 * and then removes the event listeners on the node.
1264 * @param {Event} evt
1265 * @returns {Object}
1266 */
1267 function getScriptData(evt) {
1268 //Using currentTarget instead of target for Firefox 2.0's sake. Not
1269 //all old browsers will be supported, but this one was easy enough
1270 //to support and still makes sense.
1271 var node = evt.currentTarget || evt.srcElement;
1272
1273 //Remove the listeners once here.
1274 removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
1275 removeListener(node, context.onScriptError, 'error');
1276
1277 return {
1278 node: node,
1279 id: node && node.getAttribute('data-requiremodule')
1280 };
1281 }
1282
1283 return (context = {
1284 config: config,
1285 contextName: contextName,
1286 registry: registry,
1287 defined: defined,
1288 urlFetched: urlFetched,
1289 waitCount: 0,
1290 defQueue: defQueue,
1291 Module: Module,
1292 makeModuleMap: makeModuleMap,
1293
1294 /**
1295 * Set a configuration for the context.
1296 * @param {Object} cfg config object to integrate.
1297 */
1298 configure: function (cfg) {
1299 //Make sure the baseUrl ends in a slash.
1300 if (cfg.baseUrl) {
1301 if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
1302 cfg.baseUrl += '/';
1303 }
1304 }
1305
1306 //Save off the paths and packages since they require special processing,
1307 //they are additive.
1308 var pkgs = config.pkgs,
1309 shim = config.shim,
1310 paths = config.paths,
1311 map = config.map;
1312
1313 //Mix in the config values, favoring the new values over
1314 //existing ones in context.config.
1315 mixin(config, cfg, true);
1316
1317 //Merge paths.
1318 config.paths = mixin(paths, cfg.paths, true);
1319
1320 //Merge map
1321 if (cfg.map) {
1322 config.map = mixin(map || {}, cfg.map, true, true);
1323 }
1324
1325 //Merge shim
1326 if (cfg.shim) {
1327 eachProp(cfg.shim, function (value, id) {
1328 //Normalize the structure
1329 if (isArray(value)) {
1330 value = {
1331 deps: value
1332 };
1333 }
1334 if (value.exports && !value.exports.__buildReady) {
1335 value.exports = context.makeShimExports(value.exports);
1336 }
1337 shim[id] = value;
1338 });
1339 config.shim = shim;
1340 }
1341
1342 //Adjust packages if necessary.
1343 if (cfg.packages) {
1344 each(cfg.packages, function (pkgObj) {
1345 var location;
1346
1347 pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
1348 location = pkgObj.location;
1349
1350 //Create a brand new object on pkgs, since currentPackages can
1351 //be passed in again, and config.pkgs is the internal transformed
1352 //state for all package configs.
1353 pkgs[pkgObj.name] = {
1354 name: pkgObj.name,
1355 location: location || pkgObj.name,
1356 //Remove leading dot in main, so main paths are normalized,
1357 //and remove any trailing .js, since different package
1358 //envs have different conventions: some use a module name,
1359 //some use a file name.
1360 main: (pkgObj.main || 'main')
1361 .replace(currDirRegExp, '')
1362 .replace(jsSuffixRegExp, '')
1363 };
1364 });
1365
1366 //Done with modifications, assing packages back to context config
1367 config.pkgs = pkgs;
1368 }
1369
1370 //If there are any "waiting to execute" modules in the registry,
1371 //update the maps for them, since their info, like URLs to load,
1372 //may have changed.
1373 eachProp(registry, function (mod, id) {
1374 mod.map = makeModuleMap(id);
1375 });
1376
1377 //If a deps array or a config callback is specified, then call
1378 //require with those args. This is useful when require is defined as a
1379 //config object before require.js is loaded.
1380 if (cfg.deps || cfg.callback) {
1381 context.require(cfg.deps || [], cfg.callback);
1382 }
1383 },
1384
1385 makeShimExports: function (exports) {
1386 var func;
1387 if (typeof exports === 'string') {
1388 func = function () {
1389 return getGlobal(exports);
1390 };
1391 //Save the exports for use in nodefine checking.
1392 func.exports = exports;
1393 return func;
1394 } else {
1395 return function () {
1396 return exports.apply(global, arguments);
1397 };
1398 }
1399 },
1400
1401 requireDefined: function (id, relMap) {
1402 return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
1403 },
1404
1405 requireSpecified: function (id, relMap) {
1406 id = makeModuleMap(id, relMap, false, true).id;
1407 return hasProp(defined, id) || hasProp(registry, id);
1408 },
1409
1410 require: function (deps, callback, errback, relMap) {
1411 var moduleName, id, map, requireMod, args;
1412 if (typeof deps === 'string') {
1413 if (isFunction(callback)) {
1414 //Invalid call
1415 return onError(makeError('requireargs', 'Invalid require call'), errback);
1416 }
1417
1418 //Synchronous access to one module. If require.get is
1419 //available (as in the Node adapter), prefer that.
1420 //In this case deps is the moduleName and callback is
1421 //the relMap
1422 if (req.get) {
1423 return req.get(context, deps, callback);
1424 }
1425
1426 //Just return the module wanted. In this scenario, the
1427 //second arg (if passed) is just the relMap.
1428 moduleName = deps;
1429 relMap = callback;
1430
1431 //Normalize module name, if it contains . or ..
1432 map = makeModuleMap(moduleName, relMap, false, true);
1433 id = map.id;
1434
1435 if (!hasProp(defined, id)) {
1436 return onError(makeError('notloaded', 'Module name "' +
1437 id +
1438 '" has not been loaded yet for context: ' +
1439 contextName));
1440 }
1441 return defined[id];
1442 }
1443
1444 //Callback require. Normalize args. if callback or errback is
1445 //not a function, it means it is a relMap. Test errback first.
1446 if (errback && !isFunction(errback)) {
1447 relMap = errback;
1448 errback = undefined;
1449 }
1450 if (callback && !isFunction(callback)) {
1451 relMap = callback;
1452 callback = undefined;
1453 }
1454
1455 //Any defined modules in the global queue, intake them now.
1456 takeGlobalQueue();
1457
1458 //Make sure any remaining defQueue items get properly processed.
1459 while (defQueue.length) {
1460 args = defQueue.shift();
1461 if (args[0] === null) {
1462 return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
1463 } else {
1464 //args are id, deps, factory. Should be normalized by the
1465 //define() function.
1466 callGetModule(args);
1467 }
1468 }
1469
1470 //Mark all the dependencies as needing to be loaded.
1471 requireMod = getModule(makeModuleMap(null, relMap));
1472
1473 requireMod.init(deps, callback, errback, {
1474 enabled: true
1475 });
1476
1477 checkLoaded();
1478
1479 return context.require;
1480 },
1481
1482 undef: function (id) {
1483 var map = makeModuleMap(id, null, true),
1484 mod = registry[id];
1485
1486 delete defined[id];
1487 delete urlFetched[map.url];
1488 delete undefEvents[id];
1489
1490 if (mod) {
1491 //Hold on to listeners in case the
1492 //module will be attempted to be reloaded
1493 //using a different config.
1494 if (mod.events.defined) {
1495 undefEvents[id] = mod.events;
1496 }
1497
1498 removeWaiting(id);
1499 }
1500 },
1501
1502 /**
1503 * Called to enable a module if it is still in the registry
1504 * awaiting enablement. parent module is passed in for context,
1505 * used by the optimizer.
1506 */
1507 enable: function (depMap, parent) {
1508 var mod = registry[depMap.id];
1509 if (mod) {
1510 getModule(depMap).enable();
1511 }
1512 },
1513
1514 /**
1515 * Internal method used by environment adapters to complete a load event.
1516 * A load event could be a script load or just a load pass from a synchronous
1517 * load call.
1518 * @param {String} moduleName the name of the module to potentially complete.
1519 */
1520 completeLoad: function (moduleName) {
1521 var shim = config.shim[moduleName] || {},
1522 shExports = shim.exports && shim.exports.exports,
1523 found, args, mod;
1524
1525 takeGlobalQueue();
1526
1527 while (defQueue.length) {
1528 args = defQueue.shift();
1529 if (args[0] === null) {
1530 args[0] = moduleName;
1531 //If already found an anonymous module and bound it
1532 //to this name, then this is some other anon module
1533 //waiting for its completeLoad to fire.
1534 if (found) {
1535 break;
1536 }
1537 found = true;
1538 } else if (args[0] === moduleName) {
1539 //Found matching define call for this script!
1540 found = true;
1541 }
1542
1543 callGetModule(args);
1544 }
1545
1546 //Do this after the cycle of callGetModule in case the result
1547 //of those calls/init calls changes the registry.
1548 mod = registry[moduleName];
1549
1550 if (!found &&
1551 !defined[moduleName] &&
1552 mod && !mod.inited) {
1553 if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
1554 if (hasPathFallback(moduleName)) {
1555 return;
1556 } else {
1557 return onError(makeError('nodefine',
1558 'No define call for ' + moduleName,
1559 null,
1560 [moduleName]));
1561 }
1562 } else {
1563 //A script that does not call define(), so just simulate
1564 //the call for it.
1565 callGetModule([moduleName, (shim.deps || []), shim.exports]);
1566 }
1567 }
1568
1569 checkLoaded();
1570 },
1571
1572 /**
1573 * Converts a module name + .extension into an URL path.
1574 * *Requires* the use of a module name. It does not support using
1575 * plain URLs like nameToUrl.
1576 */
1577 toUrl: function (moduleNamePlusExt, relModuleMap) {
1578 var index = moduleNamePlusExt.lastIndexOf('.'),
1579 ext = null;
1580
1581 if (index !== -1) {
1582 ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
1583 moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
1584 }
1585
1586 return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap);
1587 },
1588
1589 /**
1590 * Converts a module name to a file path. Supports cases where
1591 * moduleName may actually be just an URL.
1592 */
1593 nameToUrl: function (moduleName, ext, relModuleMap) {
1594 var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
1595 parentPath;
1596
1597 //Normalize module name if have a base relative module name to work from.
1598 moduleName = normalize(moduleName, relModuleMap && relModuleMap.id, true);
1599
1600 //If a colon is in the URL, it indicates a protocol is used and it is just
1601 //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
1602 //or ends with .js, then assume the user meant to use an url and not a module id.
1603 //The slash is important for protocol-less URLs as well as full paths.
1604 if (req.jsExtRegExp.test(moduleName)) {
1605 //Just a plain path, not module name lookup, so just return it.
1606 //Add extension if it is included. This is a bit wonky, only non-.js things pass
1607 //an extension, this method probably needs to be reworked.
1608 url = moduleName + (ext || '');
1609 } else {
1610 //A module that needs to be converted to a path.
1611 paths = config.paths;
1612 pkgs = config.pkgs;
1613
1614 syms = moduleName.split('/');
1615 //For each module name segment, see if there is a path
1616 //registered for it. Start with most specific name
1617 //and work up from it.
1618 for (i = syms.length; i > 0; i -= 1) {
1619 parentModule = syms.slice(0, i).join('/');
1620 pkg = pkgs[parentModule];
1621 parentPath = paths[parentModule];
1622 if (parentPath) {
1623 //If an array, it means there are a few choices,
1624 //Choose the one that is desired
1625 if (isArray(parentPath)) {
1626 parentPath = parentPath[0];
1627 }
1628 syms.splice(0, i, parentPath);
1629 break;
1630 } else if (pkg) {
1631 //If module name is just the package name, then looking
1632 //for the main module.
1633 if (moduleName === pkg.name) {
1634 pkgPath = pkg.location + '/' + pkg.main;
1635 } else {
1636 pkgPath = pkg.location;
1637 }
1638 syms.splice(0, i, pkgPath);
1639 break;
1640 }
1641 }
1642
1643 //Join the path parts together, then figure out if baseUrl is needed.
1644 url = syms.join('/') + (ext || '.js')+'?random='+Math.random();
1645 url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
1646 }
1647
1648 return config.urlArgs ? url +
1649 ((url.indexOf('?') === -1 ? '?' : '&') +
1650 config.urlArgs) : url;
1651 },
1652
1653 //Delegates to req.load. Broken out as a separate function to
1654 //allow overriding in the optimizer.
1655 load: function (id, url) {
1656 req.load(context, id, url);
1657 },
1658
1659 /**
1660 * Executes a module callack function. Broken out as a separate function
1661 * solely to allow the build system to sequence the files in the built
1662 * layer in the right sequence.
1663 *
1664 * @private
1665 */
1666 execCb: function (name, callback, args, exports) {
1667 return callback.apply(exports, args);
1668 },
1669
1670 /**
1671 * callback for script loads, used to check status of loading.
1672 *
1673 * @param {Event} evt the event from the browser for the script
1674 * that was loaded.
1675 */
1676 onScriptLoad: function (evt) {
1677 //Using currentTarget instead of target for Firefox 2.0's sake. Not
1678 //all old browsers will be supported, but this one was easy enough
1679 //to support and still makes sense.
1680 if (evt.type === 'load' ||
1681 (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
1682 //Reset interactive script so a script node is not held onto for
1683 //to long.
1684 interactiveScript = null;
1685
1686 //Pull out the name of the module and the context.
1687 var data = getScriptData(evt);
1688 context.completeLoad(data.id);
1689 }
1690 },
1691
1692 /**
1693 * Callback for script errors.
1694 */
1695 onScriptError: function (evt) {
1696 var data = getScriptData(evt);
1697 if (!hasPathFallback(data.id)) {
1698 return onError(makeError('scripterror', 'Script error', evt, [data.id]));
1699 }
1700 }
1701 });
1702 }
1703
1704 /**
1705 * Main entry point.
1706 *
1707 * If the only argument to require is a string, then the module that
1708 * is represented by that string is fetched for the appropriate context.
1709 *
1710 * If the first argument is an array, then it will be treated as an array
1711 * of dependency string names to fetch. An optional function callback can
1712 * be specified to execute when all of those dependencies are available.
1713 *
1714 * Make a local req variable to help Caja compliance (it assumes things
1715 * on a require that are not standardized), and to give a short
1716 * name for minification/local scope use.
1717 */
1718 req = requirejs = function (deps, callback, errback, optional) {
1719
1720 //Find the right context, use default
1721 var contextName = defContextName,
1722 context, config;
1723
1724 // Determine if have config object in the call.
1725 if (!isArray(deps) && typeof deps !== 'string') {
1726 // deps is a config object
1727 config = deps;
1728 if (isArray(callback)) {
1729 // Adjust args if there are dependencies
1730 deps = callback;
1731 callback = errback;
1732 errback = optional;
1733 } else {
1734 deps = [];
1735 }
1736 }
1737
1738 if (config && config.context) {
1739 contextName = config.context;
1740 }
1741
1742 context = contexts[contextName];
1743 if (!context) {
1744 context = contexts[contextName] = req.s.newContext(contextName);
1745 }
1746
1747 if (config) {
1748 context.configure(config);
1749 }
1750
1751 return context.require(deps, callback, errback);
1752 };
1753
1754 /**
1755 * Support require.config() to make it easier to cooperate with other
1756 * AMD loaders on globally agreed names.
1757 */
1758 req.config = function (config) {
1759 return req(config);
1760 };
1761
1762 /**
1763 * Export require as a global, but only if it does not already exist.
1764 */
1765 if (!require) {
1766 require = req;
1767 }
1768
1769 req.version = version;
1770
1771 //Used to filter out dependencies that are already paths.
1772 req.jsExtRegExp = /^\/|:|\?|\.js$/;
1773 req.isBrowser = isBrowser;
1774 s = req.s = {
1775 contexts: contexts,
1776 newContext: newContext
1777 };
1778
1779 //Create default context.
1780 req({});
1781
1782 //Exports some context-sensitive methods on global require, using
1783 //default context if no context specified.
1784 addRequireMethods(req);
1785
1786 if (isBrowser) {
1787 head = s.head = document.getElementsByTagName('head')[0];
1788 //If BASE tag is in play, using appendChild is a problem for IE6.
1789 //When that browser dies, this can be removed. Details in this jQuery bug:
1790 //http://dev.jquery.com/ticket/2709
1791 baseElement = document.getElementsByTagName('base')[0];
1792 if (baseElement) {
1793 head = s.head = baseElement.parentNode;
1794 }
1795 }
1796
1797 /**
1798 * Any errors that require explicitly generates will be passed to this
1799 * function. Intercept/override it if you want custom error handling.
1800 * @param {Error} err the error object.
1801 */
1802 req.onError = function (err) {
1803 throw err;
1804 };
1805
1806 /**
1807 * Does the request to load a module for the browser case.
1808 * Make this a separate function to allow other environments
1809 * to override it.
1810 *
1811 * @param {Object} context the require context to find state.
1812 * @param {String} moduleName the name of the module.
1813 * @param {Object} url the URL to the module.
1814 */
1815 req.load = function (context, moduleName, url) {
1816 var config = (context && context.config) || {},
1817 node;
1818 if (isBrowser) {
1819 //In the browser so use a script tag
1820 node = config.xhtml ?
1821 document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
1822 document.createElement('script');
1823 node.type = config.scriptType || 'text/javascript';
1824 node.charset = 'utf-8';
1825
1826 node.setAttribute('data-requirecontext', context.contextName);
1827 node.setAttribute('data-requiremodule', moduleName);
1828
1829 //Set up load listener. Test attachEvent first because IE9 has
1830 //a subtle issue in its addEventListener and script onload firings
1831 //that do not match the behavior of all other browsers with
1832 //addEventListener support, which fire the onload event for a
1833 //script right after the script execution. See:
1834 //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
1835 //UNFORTUNATELY Opera implements attachEvent but does not follow the script
1836 //script execution mode.
1837 if (node.attachEvent &&
1838 //Check if node.attachEvent is artificially added by custom script or
1839 //natively supported by browser
1840 //read https://github.com/jrburke/requirejs/issues/187
1841 //if we can NOT find [native code] then it must NOT natively supported.
1842 //in IE8, node.attachEvent does not have toString()
1843 //Note the test for "[native code" with no closing brace, see:
1844 //https://github.com/jrburke/requirejs/issues/273
1845 !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
1846 !isOpera) {
1847 //Probably IE. IE (at least 6-8) do not fire
1848 //script onload right after executing the script, so
1849 //we cannot tie the anonymous define call to a name.
1850 //However, IE reports the script as being in 'interactive'
1851 //readyState at the time of the define call.
1852 useInteractive = true;
1853
1854 node.attachEvent('onreadystatechange', context.onScriptLoad);
1855 //It would be great to add an error handler here to catch
1856 //404s in IE9+. However, onreadystatechange will fire before
1857 //the error handler, so that does not help. If addEvenListener
1858 //is used, then IE will fire error before load, but we cannot
1859 //use that pathway given the connect.microsoft.com issue
1860 //mentioned above about not doing the 'script execute,
1861 //then fire the script load event listener before execute
1862 //next script' that other browsers do.
1863 //Best hope: IE10 fixes the issues,
1864 //and then destroys all installs of IE 6-9.
1865 //node.attachEvent('onerror', context.onScriptError);
1866 } else {
1867 node.addEventListener('load', context.onScriptLoad, false);
1868 node.addEventListener('error', context.onScriptError, false);
1869 }
1870 node.src = url;
1871
1872 //For some cache cases in IE 6-8, the script executes before the end
1873 //of the appendChild execution, so to tie an anonymous define
1874 //call to the module name (which is stored on the node), hold on
1875 //to a reference to this node, but clear after the DOM insertion.
1876 currentlyAddingScript = node;
1877 if (baseElement) {
1878 head.insertBefore(node, baseElement);
1879 } else {
1880 head.appendChild(node);
1881 }
1882 currentlyAddingScript = null;
1883
1884 return node;
1885 } else if (isWebWorker) {
1886 //In a web worker, use importScripts. This is not a very
1887 //efficient use of importScripts, importScripts will block until
1888 //its script is downloaded and evaluated. However, if web workers
1889 //are in play, the expectation that a build has been done so that
1890 //only one script needs to be loaded anyway. This may need to be
1891 //reevaluated if other use cases become common.
1892 importScripts(url);
1893
1894 //Account for anonymous modules
1895 context.completeLoad(moduleName);
1896 }
1897 };
1898
1899 function getInteractiveScript() {
1900 if (interactiveScript && interactiveScript.readyState === 'interactive') {
1901 return interactiveScript;
1902 }
1903
1904 eachReverse(scripts(), function (script) {
1905 if (script.readyState === 'interactive') {
1906 return (interactiveScript = script);
1907 }
1908 });
1909 return interactiveScript;
1910 }
1911
1912 //Look for a data-main script attribute, which could also adjust the baseUrl.
1913 if (isBrowser) {
1914 //Figure out baseUrl. Get it from the script tag with require.js in it.
1915 eachReverse(scripts(), function (script) {
1916 //Set the 'head' where we can append children by
1917 //using the script's parent.
1918 if (!head) {
1919 head = script.parentNode;
1920 }
1921
1922 //Look for a data-main attribute to set main script for the page
1923 //to load. If it is there, the path to data main becomes the
1924 //baseUrl, if it is not already set.
1925 dataMain = script.getAttribute('data-main');
1926 if (dataMain) {
1927
1928 //Pull off the directory of data-main for use as the
1929 //baseUrl.
1930 src = dataMain.split('/');
1931 mainScript = src.pop();
1932 subPath = src.length ? src.join('/') + '/' : './';
1933
1934 //Set final baseUrl if there is not already an explicit one.
1935 if (!cfg.baseUrl) {
1936 cfg.baseUrl = subPath;
1937 }
1938
1939 //Strip off any trailing .js since dataMain is now
1940 //like a module name.
1941 dataMain = mainScript.replace(jsSuffixRegExp, '');
1942
1943 //Put the data-main script in the files to load.
1944 cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
1945
1946 return true;
1947 }
1948 });
1949 }
1950
1951 /**
1952 * The function that handles definitions of modules. Differs from
1953 * require() in that a string for the module should be the first argument,
1954 * and the function to execute after dependencies are loaded should
1955 * return a value to define the module corresponding to the first argument's
1956 * name.
1957 */
1958 define = function (name, deps, callback) {
1959 var node, context;
1960
1961 //Allow for anonymous functions
1962 if (typeof name !== 'string') {
1963 //Adjust args appropriately
1964 callback = deps;
1965 deps = name;
1966 name = null;
1967 }
1968
1969 //This module may not have dependencies
1970 if (!isArray(deps)) {
1971 callback = deps;
1972 deps = [];
1973 }
1974
1975 //If no name, and callback is a function, then figure out if it a
1976 //CommonJS thing with dependencies.
1977 if (!deps.length && isFunction(callback)) {
1978 //Remove comments from the callback string,
1979 //look for require calls, and pull them into the dependencies,
1980 //but only if there are function args.
1981 if (callback.length) {
1982 callback
1983 .toString()
1984 .replace(commentRegExp, '')
1985 .replace(cjsRequireRegExp, function (match, dep) {
1986 deps.push(dep);
1987 });
1988
1989 //May be a CommonJS thing even without require calls, but still
1990 //could use exports, and module. Avoid doing exports and module
1991 //work though if it just needs require.
1992 //REQUIRES the function to expect the CommonJS variables in the
1993 //order listed below.
1994 deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
1995 }
1996 }
1997
1998 //If in IE 6-8 and hit an anonymous define() call, do the interactive
1999 //work.
2000 if (useInteractive) {
2001 node = currentlyAddingScript || getInteractiveScript();
2002 if (node) {
2003 if (!name) {
2004 name = node.getAttribute('data-requiremodule');
2005 }
2006 context = contexts[node.getAttribute('data-requirecontext')];
2007 }
2008 }
2009
2010 //Always save off evaluating the def call until the script onload handler.
2011 //This allows multiple modules to be in a file without prematurely
2012 //tracing dependencies, and allows for anonymous module support,
2013 //where the module name is not known until the script onload event
2014 //occurs. If no context, use the global queue, and get it processed
2015 //in the onscript load callback.
2016 (context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
2017 };
2018
2019 define.amd = {
2020 jQuery: true
2021 };
2022
2023
2024 /**
2025 * Executes the text. Normally just uses eval, but can be modified
2026 * to use a better, environment-specific call. Only used for transpiling
2027 * loader plugins, not for plain JS modules.
2028 * @param {String} text the text to execute/evaluate.
2029 */
2030 req.exec = function (text) {
2031 /*jslint evil: true */
2032 return eval(text);
2033 };
2034
2035 //Set up with config info.
2036 req(cfg);
2037}(this));
2038/*
2039 * jQuery JavaScript Library
2040 * http://jquery.com/
2041 *
2042 * Copyright, John Resig
2043 * Dual licensed under the MIT or GPL Version 2 licenses.
2044 * http://jquery.org/license
2045 *
2046 * Includes Sizzle.js
2047 * http://sizzlejs.com/
2048 * Copyright, The Dojo Foundation
2049 * Released under the MIT, BSD, and GPL Licenses.
2050 *
2051 * Date: NULL
2052 */
2053(function( window, undefined ) {
2054
2055// Use the correct document accordingly with window argument (sandbox)
2056var document = window.document,
2057 navigator = window.navigator,
2058 location = window.location;
2059var jQuery = (function() {
2060
2061// Define a local copy of jQuery
2062var jQuery = function( selector, context ) {
2063 // The jQuery object is actually just the init constructor 'enhanced'
2064 return new jQuery.fn.init( selector, context, rootjQuery );
2065 },
2066
2067 // Map over jQuery in case of overwrite
2068 _jQuery = window.jQuery,
2069
2070 // Map over the $ in case of overwrite
2071 _$ = window.$,
2072
2073 // A central reference to the root jQuery(document)
2074 rootjQuery,
2075
2076 // A simple way to check for HTML strings or ID strings
2077 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2078 quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
2079
2080 // Check if a string has a non-whitespace character in it
2081 rnotwhite = /\S/,
2082
2083 // Used for trimming whitespace
2084 trimLeft = /^\s+/,
2085 trimRight = /\s+$/,
2086
2087 // Match a standalone tag
2088 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
2089
2090 // JSON RegExp
2091 rvalidchars = /^[\],:{}\s]*$/,
2092 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
2093 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
2094 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
2095
2096 // Useragent RegExp
2097 rwebkit = /(webkit)[ \/]([\w.]+)/,
2098 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
2099 rmsie = /(msie) ([\w.]+)/,
2100 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
2101
2102 // Matches dashed string for camelizing
2103 rdashAlpha = /-([a-z]|[0-9])/ig,
2104 rmsPrefix = /^-ms-/,
2105
2106 // Used by jQuery.camelCase as callback to replace()
2107 fcamelCase = function( all, letter ) {
2108 return ( letter + "" ).toUpperCase();
2109 },
2110
2111 // Keep a UserAgent string for use with jQuery.browser
2112 userAgent = navigator.userAgent,
2113
2114 // For matching the engine and version of the browser
2115 browserMatch,
2116
2117 // The deferred used on DOM ready
2118 readyList,
2119
2120 // The ready event handler
2121 DOMContentLoaded,
2122
2123 // Save a reference to some core methods
2124 toString = Object.prototype.toString,
2125 hasOwn = Object.prototype.hasOwnProperty,
2126 push = Array.prototype.push,
2127 slice = Array.prototype.slice,
2128 trim = String.prototype.trim,
2129 indexOf = Array.prototype.indexOf,
2130
2131 // [[Class]] -> type pairs
2132 class2type = {};
2133
2134jQuery.fn = jQuery.prototype = {
2135 constructor: jQuery,
2136 init: function( selector, context, rootjQuery ) {
2137 var match, elem, ret, doc;
2138
2139 // Handle $(""), $(null), or $(undefined)
2140 if ( !selector ) {
2141 return this;
2142 }
2143
2144 // Handle $(DOMElement)
2145 if ( selector.nodeType ) {
2146 this.context = this[0] = selector;
2147 this.length = 1;
2148 return this;
2149 }
2150
2151 // The body element only exists once, optimize finding it
2152 if ( selector === "body" && !context && document.body ) {
2153 this.context = document;
2154 this[0] = document.body;
2155 this.selector = selector;
2156 this.length = 1;
2157 return this;
2158 }
2159
2160 // Handle HTML strings
2161 if ( typeof selector === "string" ) {
2162 // Are we dealing with HTML string or an ID?
2163 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2164 // Assume that strings that start and end with <> are HTML and skip the regex check
2165 match = [ null, selector, null ];
2166
2167 } else {
2168 match = quickExpr.exec( selector );
2169 }
2170
2171 // Verify a match, and that no context was specified for #id
2172 if ( match && (match[1] || !context) ) {
2173
2174 // HANDLE: $(html) -> $(array)
2175 if ( match[1] ) {
2176 context = context instanceof jQuery ? context[0] : context;
2177 doc = ( context ? context.ownerDocument || context : document );
2178
2179 // If a single string is passed in and it's a single tag
2180 // just do a createElement and skip the rest
2181 ret = rsingleTag.exec( selector );
2182
2183 if ( ret ) {
2184 if ( jQuery.isPlainObject( context ) ) {
2185 selector = [ document.createElement( ret[1] ) ];
2186 jQuery.fn.attr.call( selector, context, true );
2187
2188 } else {
2189 selector = [ doc.createElement( ret[1] ) ];
2190 }
2191
2192 } else {
2193 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
2194 selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
2195 }
2196
2197 return jQuery.merge( this, selector );
2198
2199 // HANDLE: $("#id")
2200 } else {
2201 elem = document.getElementById( match[2] );
2202
2203 // Check parentNode to catch when Blackberry 4.6 returns
2204 // nodes that are no longer in the document #6963
2205 if ( elem && elem.parentNode ) {
2206 // Handle the case where IE and Opera return items
2207 // by name instead of ID
2208 if ( elem.id !== match[2] ) {
2209 return rootjQuery.find( selector );
2210 }
2211
2212 // Otherwise, we inject the element directly into the jQuery object
2213 this.length = 1;
2214 this[0] = elem;
2215 }
2216
2217 this.context = document;
2218 this.selector = selector;
2219 return this;
2220 }
2221
2222 // HANDLE: $(expr, $(...))
2223 } else if ( !context || context.jquery ) {
2224 return ( context || rootjQuery ).find( selector );
2225
2226 // HANDLE: $(expr, context)
2227 // (which is just equivalent to: $(context).find(expr)
2228 } else {
2229 return this.constructor( context ).find( selector );
2230 }
2231
2232 // HANDLE: $(function)
2233 // Shortcut for document ready
2234 } else if ( jQuery.isFunction( selector ) ) {
2235 return rootjQuery.ready( selector );
2236 }
2237
2238 if ( selector.selector !== undefined ) {
2239 this.selector = selector.selector;
2240 this.context = selector.context;
2241 }
2242
2243 return jQuery.makeArray( selector, this );
2244 },
2245
2246 // Start with an empty selector
2247 selector: "",
2248
2249 // The current version of jQuery being used
2250 jquery: "",
2251
2252 // The default length of a jQuery object is 0
2253 length: 0,
2254
2255 // The number of elements contained in the matched element set
2256 size: function() {
2257 return this.length;
2258 },
2259
2260 toArray: function() {
2261 return slice.call( this, 0 );
2262 },
2263
2264 // Get the Nth element in the matched element set OR
2265 // Get the whole matched element set as a clean array
2266 get: function( num ) {
2267 return num == null ?
2268
2269 // Return a 'clean' array
2270 this.toArray() :
2271
2272 // Return just the object
2273 ( num < 0 ? this[ this.length + num ] : this[ num ] );
2274 },
2275
2276 // Take an array of elements and push it onto the stack
2277 // (returning the new matched element set)
2278 pushStack: function( elems, name, selector ) {
2279 // Build a new jQuery matched element set
2280 var ret = this.constructor();
2281
2282 if ( jQuery.isArray( elems ) ) {
2283 push.apply( ret, elems );
2284
2285 } else {
2286 jQuery.merge( ret, elems );
2287 }
2288
2289 // Add the old object onto the stack (as a reference)
2290 ret.prevObject = this;
2291
2292 ret.context = this.context;
2293
2294 if ( name === "find" ) {
2295 ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
2296 } else if ( name ) {
2297 ret.selector = this.selector + "." + name + "(" + selector + ")";
2298 }
2299
2300 // Return the newly-formed element set
2301 return ret;
2302 },
2303
2304 // Execute a callback for every element in the matched set.
2305 // (You can seed the arguments with an array of args, but this is
2306 // only used internally.)
2307 each: function( callback, args ) {
2308 return jQuery.each( this, callback, args );
2309 },
2310
2311 ready: function( fn ) {
2312 // Attach the listeners
2313 jQuery.bindReady();
2314
2315 // Add the callback
2316 readyList.add( fn );
2317
2318 return this;
2319 },
2320
2321 eq: function( i ) {
2322 i = +i;
2323 return i === -1 ?
2324 this.slice( i ) :
2325 this.slice( i, i + 1 );
2326 },
2327
2328 first: function() {
2329 return this.eq( 0 );
2330 },
2331
2332 last: function() {
2333 return this.eq( -1 );
2334 },
2335
2336 slice: function() {
2337 return this.pushStack( slice.apply( this, arguments ),
2338 "slice", slice.call(arguments).join(",") );
2339 },
2340
2341 map: function( callback ) {
2342 return this.pushStack( jQuery.map(this, function( elem, i ) {
2343 return callback.call( elem, i, elem );
2344 }));
2345 },
2346
2347 end: function() {
2348 return this.prevObject || this.constructor(null);
2349 },
2350
2351 // For internal use only.
2352 // Behaves like an Array's method, not like a jQuery method.
2353 push: push,
2354 sort: [].sort,
2355 splice: [].splice
2356};
2357
2358// Give the init function the jQuery prototype for later instantiation
2359jQuery.fn.init.prototype = jQuery.fn;
2360
2361jQuery.extend = jQuery.fn.extend = function() {
2362 var options, name, src, copy, copyIsArray, clone,
2363 target = arguments[0] || {},
2364 i = 1,
2365 length = arguments.length,
2366 deep = false;
2367
2368 // Handle a deep copy situation
2369 if ( typeof target === "boolean" ) {
2370 deep = target;
2371 target = arguments[1] || {};
2372 // skip the boolean and the target
2373 i = 2;
2374 }
2375
2376 // Handle case when target is a string or something (possible in deep copy)
2377 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
2378 target = {};
2379 }
2380
2381 // extend jQuery itself if only one argument is passed
2382 if ( length === i ) {
2383 target = this;
2384 --i;
2385 }
2386
2387 for ( ; i < length; i++ ) {
2388 // Only deal with non-null/undefined values
2389 if ( (options = arguments[ i ]) != null ) {
2390 // Extend the base object
2391 for ( name in options ) {
2392 src = target[ name ];
2393 copy = options[ name ];
2394
2395 // Prevent never-ending loop
2396 if ( target === copy ) {
2397 continue;
2398 }
2399
2400 // Recurse if we're merging plain objects or arrays
2401 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
2402 if ( copyIsArray ) {
2403 copyIsArray = false;
2404 clone = src && jQuery.isArray(src) ? src : [];
2405
2406 } else {
2407 clone = src && jQuery.isPlainObject(src) ? src : {};
2408 }
2409
2410 // Never move original objects, clone them
2411 target[ name ] = jQuery.extend( deep, clone, copy );
2412
2413 // Don't bring in undefined values
2414 } else if ( copy !== undefined ) {
2415 target[ name ] = copy;
2416 }
2417 }
2418 }
2419 }
2420
2421 // Return the modified object
2422 return target;
2423};
2424
2425jQuery.extend({
2426 noConflict: function( deep ) {
2427 if ( window.$ === jQuery ) {
2428 window.$ = _$;
2429 }
2430
2431 if ( deep && window.jQuery === jQuery ) {
2432 window.jQuery = _jQuery;
2433 }
2434
2435 return jQuery;
2436 },
2437
2438 // Is the DOM ready to be used? Set to true once it occurs.
2439 isReady: false,
2440
2441 // A counter to track how many items to wait for before
2442 // the ready event fires. See #6781
2443 readyWait: 1,
2444
2445 // Hold (or release) the ready event
2446 holdReady: function( hold ) {
2447 if ( hold ) {
2448 jQuery.readyWait++;
2449 } else {
2450 jQuery.ready( true );
2451 }
2452 },
2453
2454 // Handle when the DOM is ready
2455 ready: function( wait ) {
2456 // Either a released hold or an DOMready/load event and not yet ready
2457 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
2458 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
2459 if ( !document.body ) {
2460 return setTimeout( jQuery.ready, 1 );
2461 }
2462
2463 // Remember that the DOM is ready
2464 jQuery.isReady = true;
2465
2466 // If a normal DOM Ready event fired, decrement, and wait if need be
2467 if ( wait !== true && --jQuery.readyWait > 0 ) {
2468 return;
2469 }
2470
2471 // If there are functions bound, to execute
2472 readyList.fireWith( document, [ jQuery ] );
2473
2474 // Trigger any bound ready events
2475 if ( jQuery.fn.trigger ) {
2476 jQuery( document ).trigger( "ready" ).off( "ready" );
2477 }
2478 }
2479 },
2480
2481 bindReady: function() {
2482 if ( readyList ) {
2483 return;
2484 }
2485
2486 readyList = jQuery.Callbacks( "once memory" );
2487
2488 // Catch cases where $(document).ready() is called after the
2489 // browser event has already occurred.
2490 if ( document.readyState === "complete" ) {
2491 // Handle it asynchronously to allow scripts the opportunity to delay ready
2492 return setTimeout( jQuery.ready, 1 );
2493 }
2494
2495 // Mozilla, Opera and webkit nightlies currently support this event
2496 if ( document.addEventListener ) {
2497 // Use the handy event callback
2498 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
2499
2500 // A fallback to window.onload, that will always work
2501 window.addEventListener( "load", jQuery.ready, false );
2502
2503 // If IE event model is used
2504 } else if ( document.attachEvent ) {
2505 // ensure firing before onload,
2506 // maybe late but safe also for iframes
2507 document.attachEvent( "onreadystatechange", DOMContentLoaded );
2508
2509 // A fallback to window.onload, that will always work
2510 window.attachEvent( "onload", jQuery.ready );
2511
2512 // If IE and not a frame
2513 // continually check to see if the document is ready
2514 var toplevel = false;
2515
2516 try {
2517 toplevel = window.frameElement == null;
2518 } catch(e) {}
2519
2520 if ( document.documentElement.doScroll && toplevel ) {
2521 doScrollCheck();
2522 }
2523 }
2524 },
2525
2526 // See test/unit/core.js for details concerning isFunction.
2527 // Since version 1.3, DOM methods and functions like alert
2528 // aren't supported. They return false on IE (#2968).
2529 isFunction: function( obj ) {
2530 return jQuery.type(obj) === "function";
2531 },
2532
2533 isArray: Array.isArray || function( obj ) {
2534 return jQuery.type(obj) === "array";
2535 },
2536
2537 isWindow: function( obj ) {
2538 return obj != null && obj == obj.window;
2539 },
2540
2541 isNumeric: function( obj ) {
2542 return !isNaN( parseFloat(obj) ) && isFinite( obj );
2543 },
2544
2545 type: function( obj ) {
2546 return obj == null ?
2547 String( obj ) :
2548 class2type[ toString.call(obj) ] || "object";
2549 },
2550
2551 isPlainObject: function( obj ) {
2552 // Must be an Object.
2553 // Because of IE, we also have to check the presence of the constructor property.
2554 // Make sure that DOM nodes and window objects don't pass through, as well
2555 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
2556 return false;
2557 }
2558
2559 try {
2560 // Not own constructor property must be Object
2561 if ( obj.constructor &&
2562 !hasOwn.call(obj, "constructor") &&
2563 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
2564 return false;
2565 }
2566 } catch ( e ) {
2567 // IE8,9 Will throw exceptions on certain host objects #9897
2568 return false;
2569 }
2570
2571 // Own properties are enumerated firstly, so to speed up,
2572 // if last one is own, then all properties are own.
2573
2574 var key;
2575 for ( key in obj ) {}
2576
2577 return key === undefined || hasOwn.call( obj, key );
2578 },
2579
2580 isEmptyObject: function( obj ) {
2581 for ( var name in obj ) {
2582 return false;
2583 }
2584 return true;
2585 },
2586
2587 error: function( msg ) {
2588 throw new Error( msg );
2589 },
2590
2591 parseJSON: function( data ) {
2592 if ( typeof data !== "string" || !data ) {
2593 return null;
2594 }
2595
2596 // Make sure leading/trailing whitespace is removed (IE can't handle it)
2597 data = jQuery.trim( data );
2598
2599 // Attempt to parse using the native JSON parser first
2600 if ( window.JSON && window.JSON.parse ) {
2601 return window.JSON.parse( data );
2602 }
2603
2604 // Make sure the incoming data is actual JSON
2605 // Logic borrowed from http://json.org/json2.js
2606 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
2607 .replace( rvalidtokens, "]" )
2608 .replace( rvalidbraces, "")) ) {
2609
2610 return ( new Function( "return " + data ) )();
2611
2612 }
2613 jQuery.error( "Invalid JSON: " + data );
2614 },
2615
2616 // Cross-browser xml parsing
2617 parseXML: function( data ) {
2618 if ( typeof data !== "string" || !data ) {
2619 return null;
2620 }
2621 var xml, tmp;
2622 try {
2623 if ( window.DOMParser ) { // Standard
2624 tmp = new DOMParser();
2625 xml = tmp.parseFromString( data , "text/xml" );
2626 } else { // IE
2627 xml = new ActiveXObject( "Microsoft.XMLDOM" );
2628 xml.async = "false";
2629 xml.loadXML( data );
2630 }
2631 } catch( e ) {
2632 xml = undefined;
2633 }
2634 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
2635 jQuery.error( "Invalid XML: " + data );
2636 }
2637 return xml;
2638 },
2639
2640 noop: function() {},
2641
2642 // Evaluates a script in a global context
2643 // Workarounds based on findings by Jim Driscoll
2644 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
2645 globalEval: function( data ) {
2646 if ( data && rnotwhite.test( data ) ) {
2647 // We use execScript on Internet Explorer
2648 // We use an anonymous function so that context is window
2649 // rather than jQuery in Firefox
2650 ( window.execScript || function( data ) {
2651 window[ "eval" ].call( window, data );
2652 } )( data );
2653 }
2654 },
2655
2656 // Convert dashed to camelCase; used by the css and data modules
2657 // Microsoft forgot to hump their vendor prefix (#9572)
2658 camelCase: function( string ) {
2659 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
2660 },
2661
2662 nodeName: function( elem, name ) {
2663 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
2664 },
2665
2666 // args is for internal usage only
2667 each: function( object, callback, args ) {
2668 var name, i = 0,
2669 length = object.length,
2670 isObj = length === undefined || jQuery.isFunction( object );
2671
2672 if ( args ) {
2673 if ( isObj ) {
2674 for ( name in object ) {
2675 if ( callback.apply( object[ name ], args ) === false ) {
2676 break;
2677 }
2678 }
2679 } else {
2680 for ( ; i < length; ) {
2681 if ( callback.apply( object[ i++ ], args ) === false ) {
2682 break;
2683 }
2684 }
2685 }
2686
2687 // A special, fast, case for the most common use of each
2688 } else {
2689 if ( isObj ) {
2690 for ( name in object ) {
2691 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
2692 break;
2693 }
2694 }
2695 } else {
2696 for ( ; i < length; ) {
2697 if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
2698 break;
2699 }
2700 }
2701 }
2702 }
2703
2704 return object;
2705 },
2706
2707 // Use native String.trim function wherever possible
2708 trim: trim ?
2709 function( text ) {
2710 return text == null ?
2711 "" :
2712 trim.call( text );
2713 } :
2714
2715 // Otherwise use our own trimming functionality
2716 function( text ) {
2717 return text == null ?
2718 "" :
2719 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
2720 },
2721
2722 // results is for internal usage only
2723 makeArray: function( array, results ) {
2724 var ret = results || [];
2725
2726 if ( array != null ) {
2727 // The window, strings (and functions) also have 'length'
2728 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
2729 var type = jQuery.type( array );
2730
2731 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
2732 push.call( ret, array );
2733 } else {
2734 jQuery.merge( ret, array );
2735 }
2736 }
2737
2738 return ret;
2739 },
2740
2741 inArray: function( elem, array, i ) {
2742 var len;
2743
2744 if ( array ) {
2745 if ( indexOf ) {
2746 return indexOf.call( array, elem, i );
2747 }
2748
2749 len = array.length;
2750 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
2751
2752 for ( ; i < len; i++ ) {
2753 // Skip accessing in sparse arrays
2754 if ( i in array && array[ i ] === elem ) {
2755 return i;
2756 }
2757 }
2758 }
2759
2760 return -1;
2761 },
2762
2763 merge: function( first, second ) {
2764 var i = first.length,
2765 j = 0;
2766
2767 if ( typeof second.length === "number" ) {
2768 for ( var l = second.length; j < l; j++ ) {
2769 first[ i++ ] = second[ j ];
2770 }
2771
2772 } else {
2773 while ( second[j] !== undefined ) {
2774 first[ i++ ] = second[ j++ ];
2775 }
2776 }
2777
2778 first.length = i;
2779
2780 return first;
2781 },
2782
2783 grep: function( elems, callback, inv ) {
2784 var ret = [], retVal;
2785 inv = !!inv;
2786
2787 // Go through the array, only saving the items
2788 // that pass the validator function
2789 for ( var i = 0, length = elems.length; i < length; i++ ) {
2790 retVal = !!callback( elems[ i ], i );
2791 if ( inv !== retVal ) {
2792 ret.push( elems[ i ] );
2793 }
2794 }
2795
2796 return ret;
2797 },
2798
2799 // arg is for internal usage only
2800 map: function( elems, callback, arg ) {
2801 var value, key, ret = [],
2802 i = 0,
2803 length = elems.length,
2804 // jquery objects are treated as arrays
2805 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
2806
2807 // Go through the array, translating each of the items to their
2808 if ( isArray ) {
2809 for ( ; i < length; i++ ) {
2810 value = callback( elems[ i ], i, arg );
2811
2812 if ( value != null ) {
2813 ret[ ret.length ] = value;
2814 }
2815 }
2816
2817 // Go through every key on the object,
2818 } else {
2819 for ( key in elems ) {
2820 value = callback( elems[ key ], key, arg );
2821
2822 if ( value != null ) {
2823 ret[ ret.length ] = value;
2824 }
2825 }
2826 }
2827
2828 // Flatten any nested arrays
2829 return ret.concat.apply( [], ret );
2830 },
2831
2832 // A global GUID counter for objects
2833 guid: 1,
2834
2835 // Bind a function to a context, optionally partially applying any
2836 // arguments.
2837 proxy: function( fn, context ) {
2838 if ( typeof context === "string" ) {
2839 var tmp = fn[ context ];
2840 context = fn;
2841 fn = tmp;
2842 }
2843
2844 // Quick check to determine if target is callable, in the spec
2845 // this throws a TypeError, but we will just return undefined.
2846 if ( !jQuery.isFunction( fn ) ) {
2847 return undefined;
2848 }
2849
2850 // Simulated bind
2851 var args = slice.call( arguments, 2 ),
2852 proxy = function() {
2853 return fn.apply( context, args.concat( slice.call( arguments ) ) );
2854 };
2855
2856 // Set the guid of unique handler to the same of original handler, so it can be removed
2857 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
2858
2859 return proxy;
2860 },
2861
2862 // Mutifunctional method to get and set values to a collection
2863 // The value/s can optionally be executed if it's a function
2864 access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
2865 var exec,
2866 bulk = key == null,
2867 i = 0,
2868 length = elems.length;
2869
2870 // Sets many values
2871 if ( key && typeof key === "object" ) {
2872 for ( i in key ) {
2873 jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
2874 }
2875 chainable = 1;
2876
2877 // Sets one value
2878 } else if ( value !== undefined ) {
2879 // Optionally, function values get executed if exec is true
2880 exec = pass === undefined && jQuery.isFunction( value );
2881
2882 if ( bulk ) {
2883 // Bulk operations only iterate when executing function values
2884 if ( exec ) {
2885 exec = fn;
2886 fn = function( elem, key, value ) {
2887 return exec.call( jQuery( elem ), value );
2888 };
2889
2890 // Otherwise they run against the entire set
2891 } else {
2892 fn.call( elems, value );
2893 fn = null;
2894 }
2895 }
2896
2897 if ( fn ) {
2898 for (; i < length; i++ ) {
2899 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
2900 }
2901 }
2902
2903 chainable = 1;
2904 }
2905
2906 return chainable ?
2907 elems :
2908
2909 // Gets
2910 bulk ?
2911 fn.call( elems ) :
2912 length ? fn( elems[0], key ) : emptyGet;
2913 },
2914
2915 now: function() {
2916 return ( new Date() ).getTime();
2917 },
2918
2919 // Use of jQuery.browser is frowned upon.
2920 // More details: http://docs.jquery.com/Utilities/jQuery.browser
2921 uaMatch: function( ua ) {
2922 ua = ua.toLowerCase();
2923
2924 var match = rwebkit.exec( ua ) ||
2925 ropera.exec( ua ) ||
2926 rmsie.exec( ua ) ||
2927 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
2928 [];
2929
2930 return { browser: match[1] || "", version: match[2] || "0" };
2931 },
2932
2933 sub: function() {
2934 function jQuerySub( selector, context ) {
2935 return new jQuerySub.fn.init( selector, context );
2936 }
2937 jQuery.extend( true, jQuerySub, this );
2938 jQuerySub.superclass = this;
2939 jQuerySub.fn = jQuerySub.prototype = this();
2940 jQuerySub.fn.constructor = jQuerySub;
2941 jQuerySub.sub = this.sub;
2942 jQuerySub.fn.init = function init( selector, context ) {
2943 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
2944 context = jQuerySub( context );
2945 }
2946
2947 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
2948 };
2949 jQuerySub.fn.init.prototype = jQuerySub.fn;
2950 var rootjQuerySub = jQuerySub(document);
2951 return jQuerySub;
2952 },
2953
2954 browser: {}
2955});
2956
2957// Populate the class2type map
2958jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
2959 class2type[ "[object " + name + "]" ] = name.toLowerCase();
2960});
2961
2962browserMatch = jQuery.uaMatch( userAgent );
2963if ( browserMatch.browser ) {
2964 jQuery.browser[ browserMatch.browser ] = true;
2965 jQuery.browser.version = browserMatch.version;
2966}
2967
2968// Deprecated, use jQuery.browser.webkit instead
2969if ( jQuery.browser.webkit ) {
2970 jQuery.browser.safari = true;
2971}
2972
2973// IE doesn't match non-breaking spaces with \s
2974if ( rnotwhite.test( "\xA0" ) ) {
2975 trimLeft = /^[\s\xA0]+/;
2976 trimRight = /[\s\xA0]+$/;
2977}
2978
2979// All jQuery objects should point back to these
2980rootjQuery = jQuery(document);
2981
2982// Cleanup functions for the document ready method
2983if ( document.addEventListener ) {
2984 DOMContentLoaded = function() {
2985 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
2986 jQuery.ready();
2987 };
2988
2989} else if ( document.attachEvent ) {
2990 DOMContentLoaded = function() {
2991 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
2992 if ( document.readyState === "complete" ) {
2993 document.detachEvent( "onreadystatechange", DOMContentLoaded );
2994 jQuery.ready();
2995 }
2996 };
2997}
2998
2999// The DOM ready check for Internet Explorer
3000function doScrollCheck() {
3001 if ( jQuery.isReady ) {
3002 return;
3003 }
3004
3005 try {
3006 // If IE is used, use the trick by Diego Perini
3007 // http://javascript.nwbox.com/IEContentLoaded/
3008 document.documentElement.doScroll("left");
3009 } catch(e) {
3010 setTimeout( doScrollCheck, 1 );
3011 return;
3012 }
3013
3014 // and execute any waiting functions
3015 jQuery.ready();
3016}
3017
3018return jQuery;
3019
3020})();
3021
3022
3023// String to Object flags format cache
3024var flagsCache = {};
3025
3026// Convert String-formatted flags into Object-formatted ones and store in cache
3027function createFlags( flags ) {
3028 var object = flagsCache[ flags ] = {},
3029 i, length;
3030 flags = flags.split( /\s+/ );
3031 for ( i = 0, length = flags.length; i < length; i++ ) {
3032 object[ flags[i] ] = true;
3033 }
3034 return object;
3035}
3036
3037/*
3038 * Create a callback list using the following parameters:
3039 *
3040 * flags: an optional list of space-separated flags that will change how
3041 * the callback list behaves
3042 *
3043 * By default a callback list will act like an event callback list and can be
3044 * "fired" multiple times.
3045 *
3046 * Possible flags:
3047 *
3048 * once: will ensure the callback list can only be fired once (like a Deferred)
3049 *
3050 * memory: will keep track of previous values and will call any callback added
3051 * after the list has been fired right away with the latest "memorized"
3052 * values (like a Deferred)
3053 *
3054 * unique: will ensure a callback can only be added once (no duplicate in the list)
3055 *
3056 * stopOnFalse: interrupt callings when a callback returns false
3057 *
3058 */
3059jQuery.Callbacks = function( flags ) {
3060
3061 // Convert flags from String-formatted to Object-formatted
3062 // (we check in cache first)
3063 flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
3064
3065 var // Actual callback list
3066 list = [],
3067 // Stack of fire calls for repeatable lists
3068 stack = [],
3069 // Last fire value (for non-forgettable lists)
3070 memory,
3071 // Flag to know if list was already fired
3072 fired,
3073 // Flag to know if list is currently firing
3074 firing,
3075 // First callback to fire (used internally by add and fireWith)
3076 firingStart,
3077 // End of the loop when firing
3078 firingLength,
3079 // Index of currently firing callback (modified by remove if needed)
3080 firingIndex,
3081 // Add one or several callbacks to the list
3082 add = function( args ) {
3083 var i,
3084 length,
3085 elem,
3086 type,
3087 actual;
3088 for ( i = 0, length = args.length; i < length; i++ ) {
3089 elem = args[ i ];
3090 type = jQuery.type( elem );
3091 if ( type === "array" ) {
3092 // Inspect recursively
3093 add( elem );
3094 } else if ( type === "function" ) {
3095 // Add if not in unique mode and callback is not in
3096 if ( !flags.unique || !self.has( elem ) ) {
3097 list.push( elem );
3098 }
3099 }
3100 }
3101 },
3102 // Fire callbacks
3103 fire = function( context, args ) {
3104 args = args || [];
3105 memory = !flags.memory || [ context, args ];
3106 fired = true;
3107 firing = true;
3108 firingIndex = firingStart || 0;
3109 firingStart = 0;
3110 firingLength = list.length;
3111 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
3112 if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
3113 memory = true; // Mark as halted
3114 break;
3115 }
3116 }
3117 firing = false;
3118 if ( list ) {
3119 if ( !flags.once ) {
3120 if ( stack && stack.length ) {
3121 memory = stack.shift();
3122 self.fireWith( memory[ 0 ], memory[ 1 ] );
3123 }
3124 } else if ( memory === true ) {
3125 self.disable();
3126 } else {
3127 list = [];
3128 }
3129 }
3130 },
3131 // Actual Callbacks object
3132 self = {
3133 // Add a callback or a collection of callbacks to the list
3134 add: function() {
3135 if ( list ) {
3136 var length = list.length;
3137 add( arguments );
3138 // Do we need to add the callbacks to the
3139 // current firing batch?
3140 if ( firing ) {
3141 firingLength = list.length;
3142 // With memory, if we're not firing then
3143 // we should call right away, unless previous
3144 // firing was halted (stopOnFalse)
3145 } else if ( memory && memory !== true ) {
3146 firingStart = length;
3147 fire( memory[ 0 ], memory[ 1 ] );
3148 }
3149 }
3150 return this;
3151 },
3152 // Remove a callback from the list
3153 remove: function() {
3154 if ( list ) {
3155 var args = arguments,
3156 argIndex = 0,
3157 argLength = args.length;
3158 for ( ; argIndex < argLength ; argIndex++ ) {
3159 for ( var i = 0; i < list.length; i++ ) {
3160 if ( args[ argIndex ] === list[ i ] ) {
3161 // Handle firingIndex and firingLength
3162 if ( firing ) {
3163 if ( i <= firingLength ) {
3164 firingLength--;
3165 if ( i <= firingIndex ) {
3166 firingIndex--;
3167 }
3168 }
3169 }
3170 // Remove the element
3171 list.splice( i--, 1 );
3172 // If we have some unicity property then
3173 // we only need to do this once
3174 if ( flags.unique ) {
3175 break;
3176 }
3177 }
3178 }
3179 }
3180 }
3181 return this;
3182 },
3183 // Control if a given callback is in the list
3184 has: function( fn ) {
3185 if ( list ) {
3186 var i = 0,
3187 length = list.length;
3188 for ( ; i < length; i++ ) {
3189 if ( fn === list[ i ] ) {
3190 return true;
3191 }
3192 }
3193 }
3194 return false;
3195 },
3196 // Remove all callbacks from the list
3197 empty: function() {
3198 list = [];
3199 return this;
3200 },
3201 // Have the list do nothing anymore
3202 disable: function() {
3203 list = stack = memory = undefined;
3204 return this;
3205 },
3206 // Is it disabled?
3207 disabled: function() {
3208 return !list;
3209 },
3210 // Lock the list in its current state
3211 lock: function() {
3212 stack = undefined;
3213 if ( !memory || memory === true ) {
3214 self.disable();
3215 }
3216 return this;
3217 },
3218 // Is it locked?
3219 locked: function() {
3220 return !stack;
3221 },
3222 // Call all callbacks with the given context and arguments
3223 fireWith: function( context, args ) {
3224 if ( stack ) {
3225 if ( firing ) {
3226 if ( !flags.once ) {
3227 stack.push( [ context, args ] );
3228 }
3229 } else if ( !( flags.once && memory ) ) {
3230 fire( context, args );
3231 }
3232 }
3233 return this;
3234 },
3235 // Call all the callbacks with the given arguments
3236 fire: function() {
3237 self.fireWith( this, arguments );
3238 return this;
3239 },
3240 // To know if the callbacks have already been called at least once
3241 fired: function() {
3242 return !!fired;
3243 }
3244 };
3245
3246 return self;
3247};
3248
3249
3250
3251
3252var // Static reference to slice
3253 sliceDeferred = [].slice;
3254
3255jQuery.extend({
3256
3257 Deferred: function( func ) {
3258 var doneList = jQuery.Callbacks( "once memory" ),
3259 failList = jQuery.Callbacks( "once memory" ),
3260 progressList = jQuery.Callbacks( "memory" ),
3261 state = "pending",
3262 lists = {
3263 resolve: doneList,
3264 reject: failList,
3265 notify: progressList
3266 },
3267 promise = {
3268 done: doneList.add,
3269 fail: failList.add,
3270 progress: progressList.add,
3271
3272 state: function() {
3273 return state;
3274 },
3275
3276 // Deprecated
3277 isResolved: doneList.fired,
3278 isRejected: failList.fired,
3279
3280 then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
3281 deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
3282 return this;
3283 },
3284 always: function() {
3285 deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
3286 return this;
3287 },
3288 pipe: function( fnDone, fnFail, fnProgress ) {
3289 return jQuery.Deferred(function( newDefer ) {
3290 jQuery.each( {
3291 done: [ fnDone, "resolve" ],
3292 fail: [ fnFail, "reject" ],
3293 progress: [ fnProgress, "notify" ]
3294 }, function( handler, data ) {
3295 var fn = data[ 0 ],
3296 action = data[ 1 ],
3297 returned;
3298 if ( jQuery.isFunction( fn ) ) {
3299 deferred[ handler ](function() {
3300 returned = fn.apply( this, arguments );
3301 if ( returned && jQuery.isFunction( returned.promise ) ) {
3302 returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
3303 } else {
3304 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
3305 }
3306 });
3307 } else {
3308 deferred[ handler ]( newDefer[ action ] );
3309 }
3310 });
3311 }).promise();
3312 },
3313 // Get a promise for this deferred
3314 // If obj is provided, the promise aspect is added to the object
3315 promise: function( obj ) {
3316 if ( obj == null ) {
3317 obj = promise;
3318 } else {
3319 for ( var key in promise ) {
3320 obj[ key ] = promise[ key ];
3321 }
3322 }
3323 return obj;
3324 }
3325 },
3326 deferred = promise.promise({}),
3327 key;
3328
3329 for ( key in lists ) {
3330 deferred[ key ] = lists[ key ].fire;
3331 deferred[ key + "With" ] = lists[ key ].fireWith;
3332 }
3333
3334 // Handle state
3335 deferred.done( function() {
3336 state = "resolved";
3337 }, failList.disable, progressList.lock ).fail( function() {
3338 state = "rejected";
3339 }, doneList.disable, progressList.lock );
3340
3341 // Call given func if any
3342 if ( func ) {
3343 func.call( deferred, deferred );
3344 }
3345
3346 // All done!
3347 return deferred;
3348 },
3349
3350 // Deferred helper
3351 when: function( firstParam ) {
3352 var args = sliceDeferred.call( arguments, 0 ),
3353 i = 0,
3354 length = args.length,
3355 pValues = new Array( length ),
3356 count = length,
3357 pCount = length,
3358 deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
3359 firstParam :
3360 jQuery.Deferred(),
3361 promise = deferred.promise();
3362 function resolveFunc( i ) {
3363 return function( value ) {
3364 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
3365 if ( !( --count ) ) {
3366 deferred.resolveWith( deferred, args );
3367 }
3368 };
3369 }
3370 function progressFunc( i ) {
3371 return function( value ) {
3372 pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
3373 deferred.notifyWith( promise, pValues );
3374 };
3375 }
3376 if ( length > 1 ) {
3377 for ( ; i < length; i++ ) {
3378 if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
3379 args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
3380 } else {
3381 --count;
3382 }
3383 }
3384 if ( !count ) {
3385 deferred.resolveWith( deferred, args );
3386 }
3387 } else if ( deferred !== firstParam ) {
3388 deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
3389 }
3390 return promise;
3391 }
3392});
3393
3394
3395
3396
3397jQuery.support = (function() {
3398
3399 var support,
3400 all,
3401 a,
3402 select,
3403 opt,
3404 input,
3405 fragment,
3406 tds,
3407 events,
3408 eventName,
3409 i,
3410 isSupported,
3411 div = document.createElement( "div" ),
3412 documentElement = document.documentElement;
3413
3414 // Preliminary tests
3415 div.setAttribute("className", "t");
3416 div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
3417
3418 all = div.getElementsByTagName( "*" );
3419 a = div.getElementsByTagName( "a" )[ 0 ];
3420
3421 // Can't get basic test support
3422 if ( !all || !all.length || !a ) {
3423 return {};
3424 }
3425
3426 // First batch of supports tests
3427 select = document.createElement( "select" );
3428 opt = select.appendChild( document.createElement("option") );
3429 input = div.getElementsByTagName( "input" )[ 0 ];
3430
3431 support = {
3432 // IE strips leading whitespace when .innerHTML is used
3433 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
3434
3435 // Make sure that tbody elements aren't automatically inserted
3436 // IE will insert them into empty tables
3437 tbody: !div.getElementsByTagName("tbody").length,
3438
3439 // Make sure that link elements get serialized correctly by innerHTML
3440 // This requires a wrapper element in IE
3441 htmlSerialize: !!div.getElementsByTagName("link").length,
3442
3443 // Get the style information from getAttribute
3444 // (IE uses .cssText instead)
3445 style: /top/.test( a.getAttribute("style") ),
3446
3447 // Make sure that URLs aren't manipulated
3448 // (IE normalizes it by default)
3449 hrefNormalized: ( a.getAttribute("href") === "/a" ),
3450
3451 // Make sure that element opacity exists
3452 // (IE uses filter instead)
3453 // Use a regex to work around a WebKit issue. See #5145
3454 opacity: /^0.55/.test( a.style.opacity ),
3455
3456 // Verify style float existence
3457 // (IE uses styleFloat instead of cssFloat)
3458 cssFloat: !!a.style.cssFloat,
3459
3460 // Make sure that if no value is specified for a checkbox
3461 // that it defaults to "on".
3462 // (WebKit defaults to "" instead)
3463 checkOn: ( input.value === "on" ),
3464
3465 // Make sure that a selected-by-default option has a working selected property.
3466 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
3467 optSelected: opt.selected,
3468
3469 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
3470 getSetAttribute: div.className !== "t",
3471
3472 // Tests for enctype support on a form(#6743)
3473 enctype: !!document.createElement("form").enctype,
3474
3475 // Makes sure cloning an html5 element does not cause problems
3476 // Where outerHTML is undefined, this still works
3477 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
3478
3479 // Will be defined later
3480 submitBubbles: true,
3481 changeBubbles: true,
3482 focusinBubbles: false,
3483 deleteExpando: true,
3484 noCloneEvent: true,
3485 inlineBlockNeedsLayout: false,
3486 shrinkWrapBlocks: false,
3487 reliableMarginRight: true,
3488 pixelMargin: true
3489 };
3490
3491 // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead
3492 jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat");
3493
3494 // Make sure checked status is properly cloned
3495 input.checked = true;
3496 support.noCloneChecked = input.cloneNode( true ).checked;
3497
3498 // Make sure that the options inside disabled selects aren't marked as disabled
3499 // (WebKit marks them as disabled)
3500 select.disabled = true;
3501 support.optDisabled = !opt.disabled;
3502
3503 // Test to see if it's possible to delete an expando from an element
3504 // Fails in Internet Explorer
3505 try {
3506 delete div.test;
3507 } catch( e ) {
3508 support.deleteExpando = false;
3509 }
3510
3511 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
3512 div.attachEvent( "onclick", function() {
3513 // Cloning a node shouldn't copy over any
3514 // bound event handlers (IE does this)
3515 support.noCloneEvent = false;
3516 });
3517 div.cloneNode( true ).fireEvent( "onclick" );
3518 }
3519
3520 // Check if a radio maintains its value
3521 // after being appended to the DOM
3522 input = document.createElement("input");
3523 input.value = "t";
3524 input.setAttribute("type", "radio");
3525 support.radioValue = input.value === "t";
3526
3527 input.setAttribute("checked", "checked");
3528
3529 // #11217 - WebKit loses check when the name is after the checked attribute
3530 input.setAttribute( "name", "t" );
3531
3532 div.appendChild( input );
3533 fragment = document.createDocumentFragment();
3534 fragment.appendChild( div.lastChild );
3535
3536 // WebKit doesn't clone checked state correctly in fragments
3537 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
3538
3539 // Check if a disconnected checkbox will retain its checked
3540 // value of true after appended to the DOM (IE6/7)
3541 support.appendChecked = input.checked;
3542
3543 fragment.removeChild( input );
3544 fragment.appendChild( div );
3545
3546 // Technique from Juriy Zaytsev
3547 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
3548 // We only care about the case where non-standard event systems
3549 // are used, namely in IE. Short-circuiting here helps us to
3550 // avoid an eval call (in setAttribute) which can cause CSP
3551 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
3552 if ( div.attachEvent ) {
3553 for ( i in {
3554 submit: 1,
3555 change: 1,
3556 focusin: 1
3557 }) {
3558 eventName = "on" + i;
3559 isSupported = ( eventName in div );
3560 if ( !isSupported ) {
3561 div.setAttribute( eventName, "return;" );
3562 isSupported = ( typeof div[ eventName ] === "function" );
3563 }
3564 support[ i + "Bubbles" ] = isSupported;
3565 }
3566 }
3567
3568 fragment.removeChild( div );
3569
3570 // Null elements to avoid leaks in IE
3571 fragment = select = opt = div = input = null;
3572
3573 // Run tests that need a body at doc ready
3574 jQuery(function() {
3575 var container, outer, inner, table, td, offsetSupport,
3576 marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
3577 paddingMarginBorderVisibility, paddingMarginBorder,
3578 body = document.getElementsByTagName("body")[0];
3579
3580 if ( !body ) {
3581 // Return for frameset docs that don't have a body
3582 return;
3583 }
3584
3585 conMarginTop = 1;
3586 paddingMarginBorder = "padding:0;margin:0;border:";
3587 positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
3588 paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
3589 style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
3590 html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
3591 "<table " + style + "' cellpadding='0' cellspacing='0'>" +
3592 "<tr><td></td></tr></table>";
3593
3594 container = document.createElement("div");
3595 container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
3596 body.insertBefore( container, body.firstChild );
3597
3598 // Construct the test element
3599 div = document.createElement("div");
3600 container.appendChild( div );
3601
3602 // Check if table cells still have offsetWidth/Height when they are set
3603 // to display:none and there are still other visible table cells in a
3604 // table row; if so, offsetWidth/Height are not reliable for use when
3605 // determining if an element has been hidden directly using
3606 // display:none (it is still safe to use offsets if a parent element is
3607 // hidden; don safety goggles and see bug #4512 for more information).
3608 // (only IE 8 fails this test)
3609 div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";
3610 tds = div.getElementsByTagName( "td" );
3611 isSupported = ( tds[ 0 ].offsetHeight === 0 );
3612
3613 tds[ 0 ].style.display = "";
3614 tds[ 1 ].style.display = "none";
3615
3616 // Check if empty table cells still have offsetWidth/Height
3617 // (IE <= 8 fail this test)
3618 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
3619
3620 // Check if div with explicit width and no margin-right incorrectly
3621 // gets computed margin-right based on width of container. For more
3622 // info see bug #3333
3623 // Fails in WebKit before Feb 2011 nightlies
3624 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
3625 if ( window.getComputedStyle ) {
3626 div.innerHTML = "";
3627 marginDiv = document.createElement( "div" );
3628 marginDiv.style.width = "0";
3629 marginDiv.style.marginRight = "0";
3630 div.style.width = "2px";
3631 div.appendChild( marginDiv );
3632 support.reliableMarginRight =
3633 ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
3634 }
3635
3636 if ( typeof div.style.zoom !== "undefined" ) {
3637 // Check if natively block-level elements act like inline-block
3638 // elements when setting their display to 'inline' and giving
3639 // them layout
3640 // (IE < 8 does this)
3641 div.innerHTML = "";
3642 div.style.width = div.style.padding = "1px";
3643 div.style.border = 0;
3644 div.style.overflow = "hidden";
3645 div.style.display = "inline";
3646 div.style.zoom = 1;
3647 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
3648
3649 // Check if elements with layout shrink-wrap their children
3650 // (IE 6 does this)
3651 div.style.display = "block";
3652 div.style.overflow = "visible";
3653 div.innerHTML = "<div style='width:5px;'></div>";
3654 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
3655 }
3656
3657 div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
3658 div.innerHTML = html;
3659
3660 outer = div.firstChild;
3661 inner = outer.firstChild;
3662 td = outer.nextSibling.firstChild.firstChild;
3663
3664 offsetSupport = {
3665 doesNotAddBorder: ( inner.offsetTop !== 5 ),
3666 doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
3667 };
3668
3669 inner.style.position = "fixed";
3670 inner.style.top = "20px";
3671
3672 // safari subtracts parent border width here which is 5px
3673 offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
3674 inner.style.position = inner.style.top = "";
3675
3676 outer.style.overflow = "hidden";
3677 outer.style.position = "relative";
3678
3679 offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
3680 offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
3681
3682 if ( window.getComputedStyle ) {
3683 div.style.marginTop = "1%";
3684 support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
3685 }
3686
3687 if ( typeof container.style.zoom !== "undefined" ) {
3688 container.style.zoom = 1;
3689 }
3690
3691 body.removeChild( container );
3692 marginDiv = div = container = null;
3693
3694 jQuery.extend( support, offsetSupport );
3695 });
3696
3697 return support;
3698})();
3699
3700
3701
3702
3703var rbrace = /^(?:\{.*\}|\[.*\])$/,
3704 rmultiDash = /([A-Z])/g;
3705
3706jQuery.extend({
3707 cache: {},
3708
3709 // Please use with caution
3710 uuid: 0,
3711
3712 // Unique for each copy of jQuery on the page
3713 // Non-digits removed to match rinlinejQuery
3714 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
3715
3716 // The following elements throw uncatchable exceptions if you
3717 // attempt to add expando properties to them.
3718 noData: {
3719 "embed": true,
3720 // Ban all objects except for Flash (which handle expandos)
3721 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
3722 "applet": true
3723 },
3724
3725 hasData: function( elem ) {
3726 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
3727 return !!elem && !isEmptyDataObject( elem );
3728 },
3729
3730 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
3731 if ( !jQuery.acceptData( elem ) ) {
3732 return;
3733 }
3734
3735 var privateCache, thisCache, ret,
3736 internalKey = jQuery.expando,
3737 getByName = typeof name === "string",
3738
3739 // We have to handle DOM nodes and JS objects differently because IE6-7
3740 // can't GC object references properly across the DOM-JS boundary
3741 isNode = elem.nodeType,
3742
3743 // Only DOM nodes need the global jQuery cache; JS object data is
3744 // attached directly to the object so GC can occur automatically
3745 cache = isNode ? jQuery.cache : elem,
3746
3747 // Only defining an ID for JS objects if its cache already exists allows
3748 // the code to shortcut on the same path as a DOM node with no cache
3749 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
3750 isEvents = name === "events";
3751
3752 // Avoid doing any more work than we need to when trying to get data on an
3753 // object that has no data at all
3754 if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
3755 return;
3756 }
3757
3758 if ( !id ) {
3759 // Only DOM nodes need a new unique ID for each element since their data
3760 // ends up in the global cache
3761 if ( isNode ) {
3762 elem[ internalKey ] = id = ++jQuery.uuid;
3763 } else {
3764 id = internalKey;
3765 }
3766 }
3767
3768 if ( !cache[ id ] ) {
3769 cache[ id ] = {};
3770
3771 // Avoids exposing jQuery metadata on plain JS objects when the object
3772 // is serialized using JSON.stringify
3773 if ( !isNode ) {
3774 cache[ id ].toJSON = jQuery.noop;
3775 }
3776 }
3777
3778 // An object can be passed to jQuery.data instead of a key/value pair; this gets
3779 // shallow copied over onto the existing cache
3780 if ( typeof name === "object" || typeof name === "function" ) {
3781 if ( pvt ) {
3782 cache[ id ] = jQuery.extend( cache[ id ], name );
3783 } else {
3784 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
3785 }
3786 }
3787
3788 privateCache = thisCache = cache[ id ];
3789
3790 // jQuery data() is stored in a separate object inside the object's internal data
3791 // cache in order to avoid key collisions between internal data and user-defined
3792 // data.
3793 if ( !pvt ) {
3794 if ( !thisCache.data ) {
3795 thisCache.data = {};
3796 }
3797
3798 thisCache = thisCache.data;
3799 }
3800
3801 if ( data !== undefined ) {
3802 thisCache[ jQuery.camelCase( name ) ] = data;
3803 }
3804
3805 // Users should not attempt to inspect the internal events object using jQuery.data,
3806 // it is undocumented and subject to change. But does anyone listen? No.
3807 if ( isEvents && !thisCache[ name ] ) {
3808 return privateCache.events;
3809 }
3810
3811 // Check for both converted-to-camel and non-converted data property names
3812 // If a data property was specified
3813 if ( getByName ) {
3814
3815 // First Try to find as-is property data
3816 ret = thisCache[ name ];
3817
3818 // Test for null|undefined property data
3819 if ( ret == null ) {
3820
3821 // Try to find the camelCased property
3822 ret = thisCache[ jQuery.camelCase( name ) ];
3823 }
3824 } else {
3825 ret = thisCache;
3826 }
3827
3828 return ret;
3829 },
3830
3831 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
3832 if ( !jQuery.acceptData( elem ) ) {
3833 return;
3834 }
3835
3836 var thisCache, i, l,
3837
3838 // Reference to internal data cache key
3839 internalKey = jQuery.expando,
3840
3841 isNode = elem.nodeType,
3842
3843 // See jQuery.data for more information
3844 cache = isNode ? jQuery.cache : elem,
3845
3846 // See jQuery.data for more information
3847 id = isNode ? elem[ internalKey ] : internalKey;
3848
3849 // If there is already no cache entry for this object, there is no
3850 // purpose in continuing
3851 if ( !cache[ id ] ) {
3852 return;
3853 }
3854
3855 if ( name ) {
3856
3857 thisCache = pvt ? cache[ id ] : cache[ id ].data;
3858
3859 if ( thisCache ) {
3860
3861 // Support array or space separated string names for data keys
3862 if ( !jQuery.isArray( name ) ) {
3863
3864 // try the string as a key before any manipulation
3865 if ( name in thisCache ) {
3866 name = [ name ];
3867 } else {
3868
3869 // split the camel cased version by spaces unless a key with the spaces exists
3870 name = jQuery.camelCase( name );
3871 if ( name in thisCache ) {
3872 name = [ name ];
3873 } else {
3874 name = name.split( " " );
3875 }
3876 }
3877 }
3878
3879 for ( i = 0, l = name.length; i < l; i++ ) {
3880 delete thisCache[ name[i] ];
3881 }
3882
3883 // If there is no data left in the cache, we want to continue
3884 // and let the cache object itself get destroyed
3885 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
3886 return;
3887 }
3888 }
3889 }
3890
3891 // See jQuery.data for more information
3892 if ( !pvt ) {
3893 delete cache[ id ].data;
3894
3895 // Don't destroy the parent cache unless the internal data object
3896 // had been the only thing left in it
3897 if ( !isEmptyDataObject(cache[ id ]) ) {
3898 return;
3899 }
3900 }
3901
3902 // Browsers that fail expando deletion also refuse to delete expandos on
3903 // the window, but it will allow it on all other JS objects; other browsers
3904 // don't care
3905 // Ensure that `cache` is not a window object #10080
3906 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
3907 delete cache[ id ];
3908 } else {
3909 cache[ id ] = null;
3910 }
3911
3912 // We destroyed the cache and need to eliminate the expando on the node to avoid
3913 // false lookups in the cache for entries that no longer exist
3914 if ( isNode ) {
3915 // IE does not allow us to delete expando properties from nodes,
3916 // nor does it have a removeAttribute function on Document nodes;
3917 // we must handle all of these cases
3918 if ( jQuery.support.deleteExpando ) {
3919 delete elem[ internalKey ];
3920 } else if ( elem.removeAttribute ) {
3921 elem.removeAttribute( internalKey );
3922 } else {
3923 elem[ internalKey ] = null;
3924 }
3925 }
3926 },
3927
3928 // For internal use only.
3929 _data: function( elem, name, data ) {
3930 return jQuery.data( elem, name, data, true );
3931 },
3932
3933 // A method for determining if a DOM node can handle the data expando
3934 acceptData: function( elem ) {
3935 if ( elem.nodeName ) {
3936 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
3937
3938 if ( match ) {
3939 return !(match === true || elem.getAttribute("classid") !== match);
3940 }
3941 }
3942
3943 return true;
3944 }
3945});
3946
3947jQuery.fn.extend({
3948 data: function( key, value ) {
3949 var parts, part, attr, name, l,
3950 elem = this[0],
3951 i = 0,
3952 data = null;
3953
3954 // Gets all values
3955 if ( key === undefined ) {
3956 if ( this.length ) {
3957 data = jQuery.data( elem );
3958
3959 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
3960 attr = elem.attributes;
3961 for ( l = attr.length; i < l; i++ ) {
3962 name = attr[i].name;
3963
3964 if ( name.indexOf( "data-" ) === 0 ) {
3965 name = jQuery.camelCase( name.substring(5) );
3966
3967 dataAttr( elem, name, data[ name ] );
3968 }
3969 }
3970 jQuery._data( elem, "parsedAttrs", true );
3971 }
3972 }
3973
3974 return data;
3975 }
3976
3977 // Sets multiple values
3978 if ( typeof key === "object" ) {
3979 return this.each(function() {
3980 jQuery.data( this, key );
3981 });
3982 }
3983
3984 parts = key.split( ".", 2 );
3985 parts[1] = parts[1] ? "." + parts[1] : "";
3986 part = parts[1] + "!";
3987
3988 return jQuery.access( this, function( value ) {
3989
3990 if ( value === undefined ) {
3991 data = this.triggerHandler( "getData" + part, [ parts[0] ] );
3992
3993 // Try to fetch any internally stored data first
3994 if ( data === undefined && elem ) {
3995 data = jQuery.data( elem, key );
3996 data = dataAttr( elem, key, data );
3997 }
3998
3999 return data === undefined && parts[1] ?
4000 this.data( parts[0] ) :
4001 data;
4002 }
4003
4004 parts[1] = value;
4005 this.each(function() {
4006 var self = jQuery( this );
4007
4008 self.triggerHandler( "setData" + part, parts );
4009 jQuery.data( this, key, value );
4010 self.triggerHandler( "changeData" + part, parts );
4011 });
4012 }, null, value, arguments.length > 1, null, false );
4013 },
4014
4015 removeData: function( key ) {
4016 return this.each(function() {
4017 jQuery.removeData( this, key );
4018 });
4019 }
4020});
4021
4022function dataAttr( elem, key, data ) {
4023 // If nothing was found internally, try to fetch any
4024 // data from the HTML5 data-* attribute
4025 if ( data === undefined && elem.nodeType === 1 ) {
4026
4027 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
4028
4029 data = elem.getAttribute( name );
4030
4031 if ( typeof data === "string" ) {
4032 try {
4033 data = data === "true" ? true :
4034 data === "false" ? false :
4035 data === "null" ? null :
4036 jQuery.isNumeric( data ) ? +data :
4037 rbrace.test( data ) ? jQuery.parseJSON( data ) :
4038 data;
4039 } catch( e ) {}
4040
4041 // Make sure we set the data so it isn't changed later
4042 jQuery.data( elem, key, data );
4043
4044 } else {
4045 data = undefined;
4046 }
4047 }
4048
4049 return data;
4050}
4051
4052// checks a cache object for emptiness
4053function isEmptyDataObject( obj ) {
4054 for ( var name in obj ) {
4055
4056 // if the public data object is empty, the private is still empty
4057 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
4058 continue;
4059 }
4060 if ( name !== "toJSON" ) {
4061 return false;
4062 }
4063 }
4064
4065 return true;
4066}
4067
4068
4069
4070
4071function handleQueueMarkDefer( elem, type, src ) {
4072 var deferDataKey = type + "defer",
4073 queueDataKey = type + "queue",
4074 markDataKey = type + "mark",
4075 defer = jQuery._data( elem, deferDataKey );
4076 if ( defer &&
4077 ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
4078 ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
4079 // Give room for hard-coded callbacks to fire first
4080 // and eventually mark/queue something else on the element
4081 setTimeout( function() {
4082 if ( !jQuery._data( elem, queueDataKey ) &&
4083 !jQuery._data( elem, markDataKey ) ) {
4084 jQuery.removeData( elem, deferDataKey, true );
4085 defer.fire();
4086 }
4087 }, 0 );
4088 }
4089}
4090
4091jQuery.extend({
4092
4093 _mark: function( elem, type ) {
4094 if ( elem ) {
4095 type = ( type || "fx" ) + "mark";
4096 jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
4097 }
4098 },
4099
4100 _unmark: function( force, elem, type ) {
4101 if ( force !== true ) {
4102 type = elem;
4103 elem = force;
4104 force = false;
4105 }
4106 if ( elem ) {
4107 type = type || "fx";
4108 var key = type + "mark",
4109 count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
4110 if ( count ) {
4111 jQuery._data( elem, key, count );
4112 } else {
4113 jQuery.removeData( elem, key, true );
4114 handleQueueMarkDefer( elem, type, "mark" );
4115 }
4116 }
4117 },
4118
4119 queue: function( elem, type, data ) {
4120 var q;
4121 if ( elem ) {
4122 type = ( type || "fx" ) + "queue";
4123 q = jQuery._data( elem, type );
4124
4125 // Speed up dequeue by getting out quickly if this is just a lookup
4126 if ( data ) {
4127 if ( !q || jQuery.isArray(data) ) {
4128 q = jQuery._data( elem, type, jQuery.makeArray(data) );
4129 } else {
4130 q.push( data );
4131 }
4132 }
4133 return q || [];
4134 }
4135 },
4136
4137 dequeue: function( elem, type ) {
4138 type = type || "fx";
4139
4140 var queue = jQuery.queue( elem, type ),
4141 fn = queue.shift(),
4142 hooks = {};
4143
4144 // If the fx queue is dequeued, always remove the progress sentinel
4145 if ( fn === "inprogress" ) {
4146 fn = queue.shift();
4147 }
4148
4149 if ( fn ) {
4150 // Add a progress sentinel to prevent the fx queue from being
4151 // automatically dequeued
4152 if ( type === "fx" ) {
4153 queue.unshift( "inprogress" );
4154 }
4155
4156 jQuery._data( elem, type + ".run", hooks );
4157 fn.call( elem, function() {
4158 jQuery.dequeue( elem, type );
4159 }, hooks );
4160 }
4161
4162 if ( !queue.length ) {
4163 jQuery.removeData( elem, type + "queue " + type + ".run", true );
4164 handleQueueMarkDefer( elem, type, "queue" );
4165 }
4166 }
4167});
4168
4169jQuery.fn.extend({
4170 queue: function( type, data ) {
4171 var setter = 2;
4172
4173 if ( typeof type !== "string" ) {
4174 data = type;
4175 type = "fx";
4176 setter--;
4177 }
4178
4179 if ( arguments.length < setter ) {
4180 return jQuery.queue( this[0], type );
4181 }
4182
4183 return data === undefined ?
4184 this :
4185 this.each(function() {
4186 var queue = jQuery.queue( this, type, data );
4187
4188 if ( type === "fx" && queue[0] !== "inprogress" ) {
4189 jQuery.dequeue( this, type );
4190 }
4191 });
4192 },
4193 dequeue: function( type ) {
4194 return this.each(function() {
4195 jQuery.dequeue( this, type );
4196 });
4197 },
4198 // Based off of the plugin by Clint Helfers, with permission.
4199 // http://blindsignals.com/index.php/2009/07/jquery-delay/
4200 delay: function( time, type ) {
4201 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
4202 type = type || "fx";
4203
4204 return this.queue( type, function( next, hooks ) {
4205 var timeout = setTimeout( next, time );
4206 hooks.stop = function() {
4207 clearTimeout( timeout );
4208 };
4209 });
4210 },
4211 clearQueue: function( type ) {
4212 return this.queue( type || "fx", [] );
4213 },
4214 // Get a promise resolved when queues of a certain type
4215 // are emptied (fx is the type by default)
4216 promise: function( type, object ) {
4217 if ( typeof type !== "string" ) {
4218 object = type;
4219 type = undefined;
4220 }
4221 type = type || "fx";
4222 var defer = jQuery.Deferred(),
4223 elements = this,
4224 i = elements.length,
4225 count = 1,
4226 deferDataKey = type + "defer",
4227 queueDataKey = type + "queue",
4228 markDataKey = type + "mark",
4229 tmp;
4230 function resolve() {
4231 if ( !( --count ) ) {
4232 defer.resolveWith( elements, [ elements ] );
4233 }
4234 }
4235 while( i-- ) {
4236 if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
4237 ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
4238 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
4239 jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
4240 count++;
4241 tmp.add( resolve );
4242 }
4243 }
4244 resolve();
4245 return defer.promise( object );
4246 }
4247});
4248
4249
4250
4251
4252var rclass = /[\n\t\r]/g,
4253 rspace = /\s+/,
4254 rreturn = /\r/g,
4255 rtype = /^(?:button|input)$/i,
4256 rfocusable = /^(?:button|input|object|select|textarea)$/i,
4257 rclickable = /^a(?:rea)?$/i,
4258 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
4259 getSetAttribute = jQuery.support.getSetAttribute,
4260 nodeHook, boolHook, fixSpecified;
4261
4262jQuery.fn.extend({
4263 attr: function( name, value ) {
4264 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
4265 },
4266
4267 removeAttr: function( name ) {
4268 return this.each(function() {
4269 jQuery.removeAttr( this, name );
4270 });
4271 },
4272
4273 prop: function( name, value ) {
4274 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
4275 },
4276
4277 removeProp: function( name ) {
4278 name = jQuery.propFix[ name ] || name;
4279 return this.each(function() {
4280 // try/catch handles cases where IE balks (such as removing a property on window)
4281 try {
4282 this[ name ] = undefined;
4283 delete this[ name ];
4284 } catch( e ) {}
4285 });
4286 },
4287
4288 addClass: function( value ) {
4289 var classNames, i, l, elem,
4290 setClass, c, cl;
4291
4292 if ( jQuery.isFunction( value ) ) {
4293 return this.each(function( j ) {
4294 jQuery( this ).addClass( value.call(this, j, this.className) );
4295 });
4296 }
4297
4298 if ( value && typeof value === "string" ) {
4299 classNames = value.split( rspace );
4300
4301 for ( i = 0, l = this.length; i < l; i++ ) {
4302 elem = this[ i ];
4303
4304 if ( elem.nodeType === 1 ) {
4305 if ( !elem.className && classNames.length === 1 ) {
4306 elem.className = value;
4307
4308 } else {
4309 setClass = " " + elem.className + " ";
4310
4311 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
4312 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
4313 setClass += classNames[ c ] + " ";
4314 }
4315 }
4316 elem.className = jQuery.trim( setClass );
4317 }
4318 }
4319 }
4320 }
4321
4322 return this;
4323 },
4324
4325 removeClass: function( value ) {
4326 var classNames, i, l, elem, className, c, cl;
4327
4328 if ( jQuery.isFunction( value ) ) {
4329 return this.each(function( j ) {
4330 jQuery( this ).removeClass( value.call(this, j, this.className) );
4331 });
4332 }
4333
4334 if ( (value && typeof value === "string") || value === undefined ) {
4335 classNames = ( value || "" ).split( rspace );
4336
4337 for ( i = 0, l = this.length; i < l; i++ ) {
4338 elem = this[ i ];
4339
4340 if ( elem.nodeType === 1 && elem.className ) {
4341 if ( value ) {
4342 className = (" " + elem.className + " ").replace( rclass, " " );
4343 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
4344 className = className.replace(" " + classNames[ c ] + " ", " ");
4345 }
4346 elem.className = jQuery.trim( className );
4347
4348 } else {
4349 elem.className = "";
4350 }
4351 }
4352 }
4353 }
4354
4355 return this;
4356 },
4357
4358 toggleClass: function( value, stateVal ) {
4359 var type = typeof value,
4360 isBool = typeof stateVal === "boolean";
4361
4362 if ( jQuery.isFunction( value ) ) {
4363 return this.each(function( i ) {
4364 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
4365 });
4366 }
4367
4368 return this.each(function() {
4369 if ( type === "string" ) {
4370 // toggle individual class names
4371 var className,
4372 i = 0,
4373 self = jQuery( this ),
4374 state = stateVal,
4375 classNames = value.split( rspace );
4376
4377 while ( (className = classNames[ i++ ]) ) {
4378 // check each className given, space seperated list
4379 state = isBool ? state : !self.hasClass( className );
4380 self[ state ? "addClass" : "removeClass" ]( className );
4381 }
4382
4383 } else if ( type === "undefined" || type === "boolean" ) {
4384 if ( this.className ) {
4385 // store className if set
4386 jQuery._data( this, "__className__", this.className );
4387 }
4388
4389 // toggle whole className
4390 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
4391 }
4392 });
4393 },
4394
4395 hasClass: function( selector ) {
4396 var className = " " + selector + " ",
4397 i = 0,
4398 l = this.length;
4399 for ( ; i < l; i++ ) {
4400 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
4401 return true;
4402 }
4403 }
4404
4405 return false;
4406 },
4407
4408 val: function( value ) {
4409 var hooks, ret, isFunction,
4410 elem = this[0];
4411
4412 if ( !arguments.length ) {
4413 if ( elem ) {
4414 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
4415
4416 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
4417 return ret;
4418 }
4419
4420 ret = elem.value;
4421
4422 return typeof ret === "string" ?
4423 // handle most common string cases
4424 ret.replace(rreturn, "") :
4425 // handle cases where value is null/undef or number
4426 ret == null ? "" : ret;
4427 }
4428
4429 return;
4430 }
4431
4432 isFunction = jQuery.isFunction( value );
4433
4434 return this.each(function( i ) {
4435 var self = jQuery(this), val;
4436
4437 if ( this.nodeType !== 1 ) {
4438 return;
4439 }
4440
4441 if ( isFunction ) {
4442 val = value.call( this, i, self.val() );
4443 } else {
4444 val = value;
4445 }
4446
4447 // Treat null/undefined as ""; convert numbers to string
4448 if ( val == null ) {
4449 val = "";
4450 } else if ( typeof val === "number" ) {
4451 val += "";
4452 } else if ( jQuery.isArray( val ) ) {
4453 val = jQuery.map(val, function ( value ) {
4454 return value == null ? "" : value + "";
4455 });
4456 }
4457
4458 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
4459
4460 // If set returns undefined, fall back to normal setting
4461 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
4462 this.value = val;
4463 }
4464 });
4465 }
4466});
4467
4468jQuery.extend({
4469 valHooks: {
4470 option: {
4471 get: function( elem ) {
4472 // attributes.value is undefined in Blackberry 4.7 but
4473 // uses .value. See #6932
4474 var val = elem.attributes.value;
4475 return !val || val.specified ? elem.value : elem.text;
4476 }
4477 },
4478 select: {
4479 get: function( elem ) {
4480 var value, i, max, option,
4481 index = elem.selectedIndex,
4482 values = [],
4483 options = elem.options,
4484 one = elem.type === "select-one";
4485
4486 // Nothing was selected
4487 if ( index < 0 ) {
4488 return null;
4489 }
4490
4491 // Loop through all the selected options
4492 i = one ? index : 0;
4493 max = one ? index + 1 : options.length;
4494 for ( ; i < max; i++ ) {
4495 option = options[ i ];
4496
4497 // Don't return options that are disabled or in a disabled optgroup
4498 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
4499 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
4500
4501 // Get the specific value for the option
4502 value = jQuery( option ).val();
4503
4504 // We don't need an array for one selects
4505 if ( one ) {
4506 return value;
4507 }
4508
4509 // Multi-Selects return an array
4510 values.push( value );
4511 }
4512 }
4513
4514 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
4515 if ( one && !values.length && options.length ) {
4516 return jQuery( options[ index ] ).val();
4517 }
4518
4519 return values;
4520 },
4521
4522 set: function( elem, value ) {
4523 var values = jQuery.makeArray( value );
4524
4525 jQuery(elem).find("option").each(function() {
4526 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
4527 });
4528
4529 if ( !values.length ) {
4530 elem.selectedIndex = -1;
4531 }
4532 return values;
4533 }
4534 }
4535 },
4536
4537 attrFn: {
4538 val: true,
4539 css: true,
4540 html: true,
4541 text: true,
4542 data: true,
4543 width: true,
4544 height: true,
4545 offset: true
4546 },
4547
4548 attr: function( elem, name, value, pass ) {
4549 var ret, hooks, notxml,
4550 nType = elem.nodeType;
4551
4552 // don't get/set attributes on text, comment and attribute nodes
4553 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
4554 return;
4555 }
4556
4557 if ( pass && name in jQuery.attrFn ) {
4558 return jQuery( elem )[ name ]( value );
4559 }
4560
4561 // Fallback to prop when attributes are not supported
4562 if ( typeof elem.getAttribute === "undefined" ) {
4563 return jQuery.prop( elem, name, value );
4564 }
4565
4566 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
4567
4568 // All attributes are lowercase
4569 // Grab necessary hook if one is defined
4570 if ( notxml ) {
4571 name = name.toLowerCase();
4572 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
4573 }
4574
4575 if ( value !== undefined ) {
4576
4577 if ( value === null ) {
4578 jQuery.removeAttr( elem, name );
4579 return;
4580
4581 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
4582 return ret;
4583
4584 } else {
4585 elem.setAttribute( name, "" + value );
4586 return value;
4587 }
4588
4589 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
4590 return ret;
4591
4592 } else {
4593
4594 ret = elem.getAttribute( name );
4595
4596 // Non-existent attributes return null, we normalize to undefined
4597 return ret === null ?
4598 undefined :
4599 ret;
4600 }
4601 },
4602
4603 removeAttr: function( elem, value ) {
4604 var propName, attrNames, name, l, isBool,
4605 i = 0;
4606
4607 if ( value && elem.nodeType === 1 ) {
4608 attrNames = value.toLowerCase().split( rspace );
4609 l = attrNames.length;
4610
4611 for ( ; i < l; i++ ) {
4612 name = attrNames[ i ];
4613
4614 if ( name ) {
4615 propName = jQuery.propFix[ name ] || name;
4616 isBool = rboolean.test( name );
4617
4618 // See #9699 for explanation of this approach (setting first, then removal)
4619 // Do not do this for boolean attributes (see #10870)
4620 if ( !isBool ) {
4621 jQuery.attr( elem, name, "" );
4622 }
4623 elem.removeAttribute( getSetAttribute ? name : propName );
4624
4625 // Set corresponding property to false for boolean attributes
4626 if ( isBool && propName in elem ) {
4627 elem[ propName ] = false;
4628 }
4629 }
4630 }
4631 }
4632 },
4633
4634 attrHooks: {
4635 type: {
4636 set: function( elem, value ) {
4637 // We can't allow the type property to be changed (since it causes problems in IE)
4638 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
4639 jQuery.error( "type property can't be changed" );
4640 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
4641 // Setting the type on a radio button after the value resets the value in IE6-9
4642 // Reset value to it's default in case type is set after value
4643 // This is for element creation
4644 var val = elem.value;
4645 elem.setAttribute( "type", value );
4646 if ( val ) {
4647 elem.value = val;
4648 }
4649 return value;
4650 }
4651 }
4652 },
4653 // Use the value property for back compat
4654 // Use the nodeHook for button elements in IE6/7 (#1954)
4655 value: {
4656 get: function( elem, name ) {
4657 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
4658 return nodeHook.get( elem, name );
4659 }
4660 return name in elem ?
4661 elem.value :
4662 null;
4663 },
4664 set: function( elem, value, name ) {
4665 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
4666 return nodeHook.set( elem, value, name );
4667 }
4668 // Does not return so that setAttribute is also used
4669 elem.value = value;
4670 }
4671 }
4672 },
4673
4674 propFix: {
4675 tabindex: "tabIndex",
4676 readonly: "readOnly",
4677 "for": "htmlFor",
4678 "class": "className",
4679 maxlength: "maxLength",
4680 cellspacing: "cellSpacing",
4681 cellpadding: "cellPadding",
4682 rowspan: "rowSpan",
4683 colspan: "colSpan",
4684 usemap: "useMap",
4685 frameborder: "frameBorder",
4686 contenteditable: "contentEditable"
4687 },
4688
4689 prop: function( elem, name, value ) {
4690 var ret, hooks, notxml,
4691 nType = elem.nodeType;
4692
4693 // don't get/set properties on text, comment and attribute nodes
4694 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
4695 return;
4696 }
4697
4698 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
4699
4700 if ( notxml ) {
4701 // Fix name and attach hooks
4702 name = jQuery.propFix[ name ] || name;
4703 hooks = jQuery.propHooks[ name ];
4704 }
4705
4706 if ( value !== undefined ) {
4707 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
4708 return ret;
4709
4710 } else {
4711 return ( elem[ name ] = value );
4712 }
4713
4714 } else {
4715 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
4716 return ret;
4717
4718 } else {
4719 return elem[ name ];
4720 }
4721 }
4722 },
4723
4724 propHooks: {
4725 tabIndex: {
4726 get: function( elem ) {
4727 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
4728 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
4729 var attributeNode = elem.getAttributeNode("tabindex");
4730
4731 return attributeNode && attributeNode.specified ?
4732 parseInt( attributeNode.value, 10 ) :
4733 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
4734 0 :
4735 undefined;
4736 }
4737 }
4738 }
4739});
4740
4741// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
4742jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
4743
4744// Hook for boolean attributes
4745boolHook = {
4746 get: function( elem, name ) {
4747 // Align boolean attributes with corresponding properties
4748 // Fall back to attribute presence where some booleans are not supported
4749 var attrNode,
4750 property = jQuery.prop( elem, name );
4751 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
4752 name.toLowerCase() :
4753 undefined;
4754 },
4755 set: function( elem, value, name ) {
4756 var propName;
4757 if ( value === false ) {
4758 // Remove boolean attributes when set to false
4759 jQuery.removeAttr( elem, name );
4760 } else {
4761 // value is true since we know at this point it's type boolean and not false
4762 // Set boolean attributes to the same name and set the DOM property
4763 propName = jQuery.propFix[ name ] || name;
4764 if ( propName in elem ) {
4765 // Only set the IDL specifically if it already exists on the element
4766 elem[ propName ] = true;
4767 }
4768
4769 elem.setAttribute( name, name.toLowerCase() );
4770 }
4771 return name;
4772 }
4773};
4774
4775// IE6/7 do not support getting/setting some attributes with get/setAttribute
4776if ( !getSetAttribute ) {
4777
4778 fixSpecified = {
4779 name: true,
4780 id: true,
4781 coords: true
4782 };
4783
4784 // Use this for any attribute in IE6/7
4785 // This fixes almost every IE6/7 issue
4786 nodeHook = jQuery.valHooks.button = {
4787 get: function( elem, name ) {
4788 var ret;
4789 ret = elem.getAttributeNode( name );
4790 return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
4791 ret.nodeValue :
4792 undefined;
4793 },
4794 set: function( elem, value, name ) {
4795 // Set the existing or create a new attribute node
4796 var ret = elem.getAttributeNode( name );
4797 if ( !ret ) {
4798 ret = document.createAttribute( name );
4799 elem.setAttributeNode( ret );
4800 }
4801 return ( ret.nodeValue = value + "" );
4802 }
4803 };
4804
4805 // Apply the nodeHook to tabindex
4806 jQuery.attrHooks.tabindex.set = nodeHook.set;
4807
4808 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
4809 // This is for removals
4810 jQuery.each([ "width", "height" ], function( i, name ) {
4811 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
4812 set: function( elem, value ) {
4813 if ( value === "" ) {
4814 elem.setAttribute( name, "auto" );
4815 return value;
4816 }
4817 }
4818 });
4819 });
4820
4821 // Set contenteditable to false on removals(#10429)
4822 // Setting to empty string throws an error as an invalid value
4823 jQuery.attrHooks.contenteditable = {
4824 get: nodeHook.get,
4825 set: function( elem, value, name ) {
4826 if ( value === "" ) {
4827 value = "false";
4828 }
4829 nodeHook.set( elem, value, name );
4830 }
4831 };
4832}
4833
4834
4835// Some attributes require a special call on IE
4836if ( !jQuery.support.hrefNormalized ) {
4837 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
4838 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
4839 get: function( elem ) {
4840 var ret = elem.getAttribute( name, 2 );
4841 return ret === null ? undefined : ret;
4842 }
4843 });
4844 });
4845}
4846
4847if ( !jQuery.support.style ) {
4848 jQuery.attrHooks.style = {
4849 get: function( elem ) {
4850 // Return undefined in the case of empty string
4851 // Normalize to lowercase since IE uppercases css property names
4852 return elem.style.cssText.toLowerCase() || undefined;
4853 },
4854 set: function( elem, value ) {
4855 return ( elem.style.cssText = "" + value );
4856 }
4857 };
4858}
4859
4860// Safari mis-reports the default selected property of an option
4861// Accessing the parent's selectedIndex property fixes it
4862if ( !jQuery.support.optSelected ) {
4863 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
4864 get: function( elem ) {
4865 var parent = elem.parentNode;
4866
4867 if ( parent ) {
4868 parent.selectedIndex;
4869
4870 // Make sure that it also works with optgroups, see #5701
4871 if ( parent.parentNode ) {
4872 parent.parentNode.selectedIndex;
4873 }
4874 }
4875 return null;
4876 }
4877 });
4878}
4879
4880// IE6/7 call enctype encoding
4881if ( !jQuery.support.enctype ) {
4882 jQuery.propFix.enctype = "encoding";
4883}
4884
4885// Radios and checkboxes getter/setter
4886if ( !jQuery.support.checkOn ) {
4887 jQuery.each([ "radio", "checkbox" ], function() {
4888 jQuery.valHooks[ this ] = {
4889 get: function( elem ) {
4890 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
4891 return elem.getAttribute("value") === null ? "on" : elem.value;
4892 }
4893 };
4894 });
4895}
4896jQuery.each([ "radio", "checkbox" ], function() {
4897 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
4898 set: function( elem, value ) {
4899 if ( jQuery.isArray( value ) ) {
4900 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
4901 }
4902 }
4903 });
4904});
4905
4906
4907
4908
4909var rformElems = /^(?:textarea|input|select)$/i,
4910 rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
4911 rhoverHack = /(?:^|\s)hover(\.\S+)?\b/,
4912 rkeyEvent = /^key/,
4913 rmouseEvent = /^(?:mouse|contextmenu)|click/,
4914 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4915 rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
4916 quickParse = function( selector ) {
4917 var quick = rquickIs.exec( selector );
4918 if ( quick ) {
4919 // 0 1 2 3
4920 // [ _, tag, id, class ]
4921 quick[1] = ( quick[1] || "" ).toLowerCase();
4922 quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
4923 }
4924 return quick;
4925 },
4926 quickIs = function( elem, m ) {
4927 var attrs = elem.attributes || {};
4928 return (
4929 (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
4930 (!m[2] || (attrs.id || {}).value === m[2]) &&
4931 (!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
4932 );
4933 },
4934 hoverHack = function( events ) {
4935 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
4936 };
4937
4938/*
4939 * Helper functions for managing events -- not part of the public interface.
4940 * Props to Dean Edwards' addEvent library for many of the ideas.
4941 */
4942jQuery.event = {
4943
4944 add: function( elem, types, handler, data, selector ) {
4945
4946 var elemData, eventHandle, events,
4947 t, tns, type, namespaces, handleObj,
4948 handleObjIn, quick, handlers, special;
4949
4950 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
4951 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
4952 return;
4953 }
4954
4955 // Caller can pass in an object of custom data in lieu of the handler
4956 if ( handler.handler ) {
4957 handleObjIn = handler;
4958 handler = handleObjIn.handler;
4959 selector = handleObjIn.selector;
4960 }
4961
4962 // Make sure that the handler has a unique ID, used to find/remove it later
4963 if ( !handler.guid ) {
4964 handler.guid = jQuery.guid++;
4965 }
4966
4967 // Init the element's event structure and main handler, if this is the first
4968 events = elemData.events;
4969 if ( !events ) {
4970 elemData.events = events = {};
4971 }
4972 eventHandle = elemData.handle;
4973 if ( !eventHandle ) {
4974 elemData.handle = eventHandle = function( e ) {
4975 // Discard the second event of a jQuery.event.trigger() and
4976 // when an event is called after a page has unloaded
4977 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
4978 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
4979 undefined;
4980 };
4981 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
4982 eventHandle.elem = elem;
4983 }
4984
4985 // Handle multiple events separated by a space
4986 // jQuery(...).bind("mouseover mouseout", fn);
4987 types = jQuery.trim( hoverHack(types) ).split( " " );
4988 for ( t = 0; t < types.length; t++ ) {
4989
4990 tns = rtypenamespace.exec( types[t] ) || [];
4991 type = tns[1];
4992 namespaces = ( tns[2] || "" ).split( "." ).sort();
4993
4994 // If event changes its type, use the special event handlers for the changed type
4995 special = jQuery.event.special[ type ] || {};
4996
4997 // If selector defined, determine special event api type, otherwise given type
4998 type = ( selector ? special.delegateType : special.bindType ) || type;
4999
5000 // Update special based on newly reset type
5001 special = jQuery.event.special[ type ] || {};
5002
5003 // handleObj is passed to all event handlers
5004 handleObj = jQuery.extend({
5005 type: type,
5006 origType: tns[1],
5007 data: data,
5008 handler: handler,
5009 guid: handler.guid,
5010 selector: selector,
5011 quick: selector && quickParse( selector ),
5012 namespace: namespaces.join(".")
5013 }, handleObjIn );
5014
5015 // Init the event handler queue if we're the first
5016 handlers = events[ type ];
5017 if ( !handlers ) {
5018 handlers = events[ type ] = [];
5019 handlers.delegateCount = 0;
5020
5021 // Only use addEventListener/attachEvent if the special events handler returns false
5022 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
5023 // Bind the global event handler to the element
5024 if ( elem.addEventListener ) {
5025 elem.addEventListener( type, eventHandle, false );
5026
5027 } else if ( elem.attachEvent ) {
5028 elem.attachEvent( "on" + type, eventHandle );
5029 }
5030 }
5031 }
5032
5033 if ( special.add ) {
5034 special.add.call( elem, handleObj );
5035
5036 if ( !handleObj.handler.guid ) {
5037 handleObj.handler.guid = handler.guid;
5038 }
5039 }
5040
5041 // Add to the element's handler list, delegates in front
5042 if ( selector ) {
5043 handlers.splice( handlers.delegateCount++, 0, handleObj );
5044 } else {
5045 handlers.push( handleObj );
5046 }
5047
5048 // Keep track of which events have ever been used, for event optimization
5049 jQuery.event.global[ type ] = true;
5050 }
5051
5052 // Nullify elem to prevent memory leaks in IE
5053 elem = null;
5054 },
5055
5056 global: {},
5057
5058 // Detach an event or set of events from an element
5059 remove: function( elem, types, handler, selector, mappedTypes ) {
5060
5061 var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
5062 t, tns, type, origType, namespaces, origCount,
5063 j, events, special, handle, eventType, handleObj;
5064
5065 if ( !elemData || !(events = elemData.events) ) {
5066 return;
5067 }
5068
5069 // Once for each type.namespace in types; type may be omitted
5070 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
5071 for ( t = 0; t < types.length; t++ ) {
5072 tns = rtypenamespace.exec( types[t] ) || [];
5073 type = origType = tns[1];
5074 namespaces = tns[2];
5075
5076 // Unbind all events (on this namespace, if provided) for the element
5077 if ( !type ) {
5078 for ( type in events ) {
5079 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
5080 }
5081 continue;
5082 }
5083
5084 special = jQuery.event.special[ type ] || {};
5085 type = ( selector? special.delegateType : special.bindType ) || type;
5086 eventType = events[ type ] || [];
5087 origCount = eventType.length;
5088 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
5089
5090 // Remove matching events
5091 for ( j = 0; j < eventType.length; j++ ) {
5092 handleObj = eventType[ j ];
5093
5094 if ( ( mappedTypes || origType === handleObj.origType ) &&
5095 ( !handler || handler.guid === handleObj.guid ) &&
5096 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
5097 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
5098 eventType.splice( j--, 1 );
5099
5100 if ( handleObj.selector ) {
5101 eventType.delegateCount--;
5102 }
5103 if ( special.remove ) {
5104 special.remove.call( elem, handleObj );
5105 }
5106 }
5107 }
5108
5109 // Remove generic event handler if we removed something and no more handlers exist
5110 // (avoids potential for endless recursion during removal of special event handlers)
5111 if ( eventType.length === 0 && origCount !== eventType.length ) {
5112 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
5113 jQuery.removeEvent( elem, type, elemData.handle );
5114 }
5115
5116 delete events[ type ];
5117 }
5118 }
5119
5120 // Remove the expando if it's no longer used
5121 if ( jQuery.isEmptyObject( events ) ) {
5122 handle = elemData.handle;
5123 if ( handle ) {
5124 handle.elem = null;
5125 }
5126
5127 // removeData also checks for emptiness and clears the expando if empty
5128 // so use it instead of delete
5129 jQuery.removeData( elem, [ "events", "handle" ], true );
5130 }
5131 },
5132
5133 // Events that are safe to short-circuit if no handlers are attached.
5134 // Native DOM events should not be added, they may have inline handlers.
5135 customEvent: {
5136 "getData": true,
5137 "setData": true,
5138 "changeData": true
5139 },
5140
5141 trigger: function( event, data, elem, onlyHandlers ) {
5142 // Don't do events on text and comment nodes
5143 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
5144 return;
5145 }
5146
5147 // Event object or event type
5148 var type = event.type || event,
5149 namespaces = [],
5150 cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
5151
5152 // focus/blur morphs to focusin/out; ensure we're not firing them right now
5153 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
5154 return;
5155 }
5156
5157 if ( type.indexOf( "!" ) >= 0 ) {
5158 // Exclusive events trigger only for the exact event (no namespaces)
5159 type = type.slice(0, -1);
5160 exclusive = true;
5161 }
5162
5163 if ( type.indexOf( "." ) >= 0 ) {
5164 // Namespaced trigger; create a regexp to match event type in handle()
5165 namespaces = type.split(".");
5166 type = namespaces.shift();
5167 namespaces.sort();
5168 }
5169
5170 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
5171 // No jQuery handlers for this event type, and it can't have inline handlers
5172 return;
5173 }
5174
5175 // Caller can pass in an Event, Object, or just an event type string
5176 event = typeof event === "object" ?
5177 // jQuery.Event object
5178 event[ jQuery.expando ] ? event :
5179 // Object literal
5180 new jQuery.Event( type, event ) :
5181 // Just the event type (string)
5182 new jQuery.Event( type );
5183
5184 event.type = type;
5185 event.isTrigger = true;
5186 event.exclusive = exclusive;
5187 event.namespace = namespaces.join( "." );
5188 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
5189 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
5190
5191 // Handle a global trigger
5192 if ( !elem ) {
5193
5194 // TODO: Stop taunting the data cache; remove global events and always attach to document
5195 cache = jQuery.cache;
5196 for ( i in cache ) {
5197 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
5198 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
5199 }
5200 }
5201 return;
5202 }
5203
5204 // Clean up the event in case it is being reused
5205 event.result = undefined;
5206 if ( !event.target ) {
5207 event.target = elem;
5208 }
5209
5210 // Clone any incoming data and prepend the event, creating the handler arg list
5211 data = data != null ? jQuery.makeArray( data ) : [];
5212 data.unshift( event );
5213
5214 // Allow special events to draw outside the lines
5215 special = jQuery.event.special[ type ] || {};
5216 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
5217 return;
5218 }
5219
5220 // Determine event propagation path in advance, per W3C events spec (#9951)
5221 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
5222 eventPath = [[ elem, special.bindType || type ]];
5223 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
5224
5225 bubbleType = special.delegateType || type;
5226 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
5227 old = null;
5228 for ( ; cur; cur = cur.parentNode ) {
5229 eventPath.push([ cur, bubbleType ]);
5230 old = cur;
5231 }
5232
5233 // Only add window if we got to document (e.g., not plain obj or detached DOM)
5234 if ( old && old === elem.ownerDocument ) {
5235 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
5236 }
5237 }
5238
5239 // Fire handlers on the event path
5240 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
5241
5242 cur = eventPath[i][0];
5243 event.type = eventPath[i][1];
5244
5245 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
5246 if ( handle ) {
5247 handle.apply( cur, data );
5248 }
5249 // Note that this is a bare JS function and not a jQuery handler
5250 handle = ontype && cur[ ontype ];
5251 if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
5252 event.preventDefault();
5253 }
5254 }
5255 event.type = type;
5256
5257 // If nobody prevented the default action, do it now
5258 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
5259
5260 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
5261 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
5262
5263 // Call a native DOM method on the target with the same name name as the event.
5264 // Can't use an .isFunction() check here because IE6/7 fails that test.
5265 // Don't do default actions on window, that's where global variables be (#6170)
5266 // IE<9 dies on focus/blur to hidden element (#1486)
5267 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
5268
5269 // Don't re-trigger an onFOO event when we call its FOO() method
5270 old = elem[ ontype ];
5271
5272 if ( old ) {
5273 elem[ ontype ] = null;
5274 }
5275
5276 // Prevent re-triggering of the same event, since we already bubbled it above
5277 jQuery.event.triggered = type;
5278 elem[ type ]();
5279 jQuery.event.triggered = undefined;
5280
5281 if ( old ) {
5282 elem[ ontype ] = old;
5283 }
5284 }
5285 }
5286 }
5287
5288 return event.result;
5289 },
5290
5291 dispatch: function( event ) {
5292
5293 // Make a writable jQuery.Event from the native event object
5294 event = jQuery.event.fix( event || window.event );
5295
5296 var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
5297 delegateCount = handlers.delegateCount,
5298 args = [].slice.call( arguments, 0 ),
5299 run_all = !event.exclusive && !event.namespace,
5300 special = jQuery.event.special[ event.type ] || {},
5301 handlerQueue = [],
5302 i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
5303
5304 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5305 args[0] = event;
5306 event.delegateTarget = this;
5307
5308 // Call the preDispatch hook for the mapped type, and let it bail if desired
5309 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5310 return;
5311 }
5312
5313 // Determine handlers that should run if there are delegated events
5314 // Avoid non-left-click bubbling in Firefox (#3861)
5315 if ( delegateCount && !(event.button && event.type === "click") ) {
5316
5317 // Pregenerate a single jQuery object for reuse with .is()
5318 jqcur = jQuery(this);
5319 jqcur.context = this.ownerDocument || this;
5320
5321 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
5322
5323 // Don't process events on disabled elements (#6911, #8165)
5324 if ( cur.disabled !== true ) {
5325 selMatch = {};
5326 matches = [];
5327 jqcur[0] = cur;
5328 for ( i = 0; i < delegateCount; i++ ) {
5329 handleObj = handlers[ i ];
5330 sel = handleObj.selector;
5331
5332 if ( selMatch[ sel ] === undefined ) {
5333 selMatch[ sel ] = (
5334 handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
5335 );
5336 }
5337 if ( selMatch[ sel ] ) {
5338 matches.push( handleObj );
5339 }
5340 }
5341 if ( matches.length ) {
5342 handlerQueue.push({ elem: cur, matches: matches });
5343 }
5344 }
5345 }
5346 }
5347
5348 // Add the remaining (directly-bound) handlers
5349 if ( handlers.length > delegateCount ) {
5350 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
5351 }
5352
5353 // Run delegates first; they may want to stop propagation beneath us
5354 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
5355 matched = handlerQueue[ i ];
5356 event.currentTarget = matched.elem;
5357
5358 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
5359 handleObj = matched.matches[ j ];
5360
5361 // Triggered event must either 1) be non-exclusive and have no namespace, or
5362 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
5363 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
5364
5365 event.data = handleObj.data;
5366 event.handleObj = handleObj;
5367
5368 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
5369 .apply( matched.elem, args );
5370
5371 if ( ret !== undefined ) {
5372 event.result = ret;
5373 if ( ret === false ) {
5374 event.preventDefault();
5375 event.stopPropagation();
5376 }
5377 }
5378 }
5379 }
5380 }
5381
5382 // Call the postDispatch hook for the mapped type
5383 if ( special.postDispatch ) {
5384 special.postDispatch.call( this, event );
5385 }
5386
5387 return event.result;
5388 },
5389
5390 // Includes some event props shared by KeyEvent and MouseEvent
5391 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
5392 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
5393
5394 fixHooks: {},
5395
5396 keyHooks: {
5397 props: "char charCode key keyCode".split(" "),
5398 filter: function( event, original ) {
5399
5400 // Add which for key events
5401 if ( event.which == null ) {
5402 event.which = original.charCode != null ? original.charCode : original.keyCode;
5403 }
5404
5405 return event;
5406 }
5407 },
5408
5409 mouseHooks: {
5410 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
5411 filter: function( event, original ) {
5412 var eventDoc, doc, body,
5413 button = original.button,
5414 fromElement = original.fromElement;
5415
5416 // Calculate pageX/Y if missing and clientX/Y available
5417 if ( event.pageX == null && original.clientX != null ) {
5418 eventDoc = event.target.ownerDocument || document;
5419 doc = eventDoc.documentElement;
5420 body = eventDoc.body;
5421
5422 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
5423 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
5424 }
5425
5426 // Add relatedTarget, if necessary
5427 if ( !event.relatedTarget && fromElement ) {
5428 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
5429 }
5430
5431 // Add which for click: 1 === left; 2 === middle; 3 === right
5432 // Note: button is not normalized, so don't use it
5433 if ( !event.which && button !== undefined ) {
5434 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
5435 }
5436
5437 return event;
5438 }
5439 },
5440
5441 fix: function( event ) {
5442 if ( event[ jQuery.expando ] ) {
5443 return event;
5444 }
5445
5446 // Create a writable copy of the event object and normalize some properties
5447 var i, prop,
5448 originalEvent = event,
5449 fixHook = jQuery.event.fixHooks[ event.type ] || {},
5450 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
5451
5452 event = jQuery.Event( originalEvent );
5453
5454 for ( i = copy.length; i; ) {
5455 prop = copy[ --i ];
5456 event[ prop ] = originalEvent[ prop ];
5457 }
5458
5459 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
5460 if ( !event.target ) {
5461 event.target = originalEvent.srcElement || document;
5462 }
5463
5464 // Target should not be a text node (#504, Safari)
5465 if ( event.target.nodeType === 3 ) {
5466 event.target = event.target.parentNode;
5467 }
5468
5469 // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
5470 if ( event.metaKey === undefined ) {
5471 event.metaKey = event.ctrlKey;
5472 }
5473
5474 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
5475 },
5476
5477 special: {
5478 ready: {
5479 // Make sure the ready event is setup
5480 setup: jQuery.bindReady
5481 },
5482
5483 load: {
5484 // Prevent triggered image.load events from bubbling to window.load
5485 noBubble: true
5486 },
5487
5488 focus: {
5489 delegateType: "focusin"
5490 },
5491 blur: {
5492 delegateType: "focusout"
5493 },
5494
5495 beforeunload: {
5496 setup: function( data, namespaces, eventHandle ) {
5497 // We only want to do this special case on windows
5498 if ( jQuery.isWindow( this ) ) {
5499 this.onbeforeunload = eventHandle;
5500 }
5501 },
5502
5503 teardown: function( namespaces, eventHandle ) {
5504 if ( this.onbeforeunload === eventHandle ) {
5505 this.onbeforeunload = null;
5506 }
5507 }
5508 }
5509 },
5510
5511 simulate: function( type, elem, event, bubble ) {
5512 // Piggyback on a donor event to simulate a different one.
5513 // Fake originalEvent to avoid donor's stopPropagation, but if the
5514 // simulated event prevents default then we do the same on the donor.
5515 var e = jQuery.extend(
5516 new jQuery.Event(),
5517 event,
5518 { type: type,
5519 isSimulated: true,
5520 originalEvent: {}
5521 }
5522 );
5523 if ( bubble ) {
5524 jQuery.event.trigger( e, null, elem );
5525 } else {
5526 jQuery.event.dispatch.call( elem, e );
5527 }
5528 if ( e.isDefaultPrevented() ) {
5529 event.preventDefault();
5530 }
5531 }
5532};
5533
5534// Some plugins are using, but it's undocumented/deprecated and will be removed.
5535// The 1.7 special event interface should provide all the hooks needed now.
5536jQuery.event.handle = jQuery.event.dispatch;
5537
5538jQuery.removeEvent = document.removeEventListener ?
5539 function( elem, type, handle ) {
5540 if ( elem.removeEventListener ) {
5541 elem.removeEventListener( type, handle, false );
5542 }
5543 } :
5544 function( elem, type, handle ) {
5545 if ( elem.detachEvent ) {
5546 elem.detachEvent( "on" + type, handle );
5547 }
5548 };
5549
5550jQuery.Event = function( src, props ) {
5551 // Allow instantiation without the 'new' keyword
5552 if ( !(this instanceof jQuery.Event) ) {
5553 return new jQuery.Event( src, props );
5554 }
5555
5556 // Event object
5557 if ( src && src.type ) {
5558 this.originalEvent = src;
5559 this.type = src.type;
5560
5561 // Events bubbling up the document may have been marked as prevented
5562 // by a handler lower down the tree; reflect the correct value.
5563 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
5564 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
5565
5566 // Event type
5567 } else {
5568 this.type = src;
5569 }
5570
5571 // Put explicitly provided properties onto the event object
5572 if ( props ) {
5573 jQuery.extend( this, props );
5574 }
5575
5576 // Create a timestamp if incoming event doesn't have one
5577 this.timeStamp = src && src.timeStamp || jQuery.now();
5578
5579 // Mark it as fixed
5580 this[ jQuery.expando ] = true;
5581};
5582
5583function returnFalse() {
5584 return false;
5585}
5586function returnTrue() {
5587 return true;
5588}
5589
5590// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5591// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5592jQuery.Event.prototype = {
5593 preventDefault: function() {
5594 this.isDefaultPrevented = returnTrue;
5595
5596 var e = this.originalEvent;
5597 if ( !e ) {
5598 return;
5599 }
5600
5601 // if preventDefault exists run it on the original event
5602 if ( e.preventDefault ) {
5603 e.preventDefault();
5604
5605 // otherwise set the returnValue property of the original event to false (IE)
5606 } else {
5607 e.returnValue = false;
5608 }
5609 },
5610 stopPropagation: function() {
5611 this.isPropagationStopped = returnTrue;
5612
5613 var e = this.originalEvent;
5614 if ( !e ) {
5615 return;
5616 }
5617 // if stopPropagation exists run it on the original event
5618 if ( e.stopPropagation ) {
5619 e.stopPropagation();
5620 }
5621 // otherwise set the cancelBubble property of the original event to true (IE)
5622 e.cancelBubble = true;
5623 },
5624 stopImmediatePropagation: function() {
5625 this.isImmediatePropagationStopped = returnTrue;
5626 this.stopPropagation();
5627 },
5628 isDefaultPrevented: returnFalse,
5629 isPropagationStopped: returnFalse,
5630 isImmediatePropagationStopped: returnFalse
5631};
5632
5633// Create mouseenter/leave events using mouseover/out and event-time checks
5634jQuery.each({
5635 mouseenter: "mouseover",
5636 mouseleave: "mouseout"
5637}, function( orig, fix ) {
5638 jQuery.event.special[ orig ] = {
5639 delegateType: fix,
5640 bindType: fix,
5641
5642 handle: function( event ) {
5643 var target = this,
5644 related = event.relatedTarget,
5645 handleObj = event.handleObj,
5646 selector = handleObj.selector,
5647 ret;
5648
5649 // For mousenter/leave call the handler if related is outside the target.
5650 // NB: No relatedTarget if the mouse left/entered the browser window
5651 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
5652 event.type = handleObj.origType;
5653 ret = handleObj.handler.apply( this, arguments );
5654 event.type = fix;
5655 }
5656 return ret;
5657 }
5658 };
5659});
5660
5661// IE submit delegation
5662if ( !jQuery.support.submitBubbles ) {
5663
5664 jQuery.event.special.submit = {
5665 setup: function() {
5666 // Only need this for delegated form submit events
5667 if ( jQuery.nodeName( this, "form" ) ) {
5668 return false;
5669 }
5670
5671 // Lazy-add a submit handler when a descendant form may potentially be submitted
5672 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
5673 // Node name check avoids a VML-related crash in IE (#9807)
5674 var elem = e.target,
5675 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
5676 if ( form && !form._submit_attached ) {
5677 jQuery.event.add( form, "submit._submit", function( event ) {
5678 event._submit_bubble = true;
5679 });
5680 form._submit_attached = true;
5681 }
5682 });
5683 // return undefined since we don't need an event listener
5684 },
5685
5686 postDispatch: function( event ) {
5687 // If form was submitted by the user, bubble the event up the tree
5688 if ( event._submit_bubble ) {
5689 delete event._submit_bubble;
5690 if ( this.parentNode && !event.isTrigger ) {
5691 jQuery.event.simulate( "submit", this.parentNode, event, true );
5692 }
5693 }
5694 },
5695
5696 teardown: function() {
5697 // Only need this for delegated form submit events
5698 if ( jQuery.nodeName( this, "form" ) ) {
5699 return false;
5700 }
5701
5702 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
5703 jQuery.event.remove( this, "._submit" );
5704 }
5705 };
5706}
5707
5708// IE change delegation and checkbox/radio fix
5709if ( !jQuery.support.changeBubbles ) {
5710
5711 jQuery.event.special.change = {
5712
5713 setup: function() {
5714
5715 if ( rformElems.test( this.nodeName ) ) {
5716 // IE doesn't fire change on a check/radio until blur; trigger it on click
5717 // after a propertychange. Eat the blur-change in special.change.handle.
5718 // This still fires onchange a second time for check/radio after blur.
5719 if ( this.type === "checkbox" || this.type === "radio" ) {
5720 jQuery.event.add( this, "propertychange._change", function( event ) {
5721 if ( event.originalEvent.propertyName === "checked" ) {
5722 this._just_changed = true;
5723 }
5724 });
5725 jQuery.event.add( this, "click._change", function( event ) {
5726 if ( this._just_changed && !event.isTrigger ) {
5727 this._just_changed = false;
5728 jQuery.event.simulate( "change", this, event, true );
5729 }
5730 });
5731 }
5732 return false;
5733 }
5734 // Delegated event; lazy-add a change handler on descendant inputs
5735 jQuery.event.add( this, "beforeactivate._change", function( e ) {
5736 var elem = e.target;
5737
5738 if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
5739 jQuery.event.add( elem, "change._change", function( event ) {
5740 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
5741 jQuery.event.simulate( "change", this.parentNode, event, true );
5742 }
5743 });
5744 elem._change_attached = true;
5745 }
5746 });
5747 },
5748
5749 handle: function( event ) {
5750 var elem = event.target;
5751
5752 // Swallow native change events from checkbox/radio, we already triggered them above
5753 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
5754 return event.handleObj.handler.apply( this, arguments );
5755 }
5756 },
5757
5758 teardown: function() {
5759 jQuery.event.remove( this, "._change" );
5760
5761 return rformElems.test( this.nodeName );
5762 }
5763 };
5764}
5765
5766// Create "bubbling" focus and blur events
5767if ( !jQuery.support.focusinBubbles ) {
5768 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
5769
5770 // Attach a single capturing handler while someone wants focusin/focusout
5771 var attaches = 0,
5772 handler = function( event ) {
5773 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
5774 };
5775
5776 jQuery.event.special[ fix ] = {
5777 setup: function() {
5778 if ( attaches++ === 0 ) {
5779 document.addEventListener( orig, handler, true );
5780 }
5781 },
5782 teardown: function() {
5783 if ( --attaches === 0 ) {
5784 document.removeEventListener( orig, handler, true );
5785 }
5786 }
5787 };
5788 });
5789}
5790
5791jQuery.fn.extend({
5792
5793 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
5794 var origFn, type;
5795
5796 // Types can be a map of types/handlers
5797 if ( typeof types === "object" ) {
5798 // ( types-Object, selector, data )
5799 if ( typeof selector !== "string" ) { // && selector != null
5800 // ( types-Object, data )
5801 data = data || selector;
5802 selector = undefined;
5803 }
5804 for ( type in types ) {
5805 this.on( type, selector, data, types[ type ], one );
5806 }
5807 return this;
5808 }
5809
5810 if ( data == null && fn == null ) {
5811 // ( types, fn )
5812 fn = selector;
5813 data = selector = undefined;
5814 } else if ( fn == null ) {
5815 if ( typeof selector === "string" ) {
5816 // ( types, selector, fn )
5817 fn = data;
5818 data = undefined;
5819 } else {
5820 // ( types, data, fn )
5821 fn = data;
5822 data = selector;
5823 selector = undefined;
5824 }
5825 }
5826 if ( fn === false ) {
5827 fn = returnFalse;
5828 } else if ( !fn ) {
5829 return this;
5830 }
5831
5832 if ( one === 1 ) {
5833 origFn = fn;
5834 fn = function( event ) {
5835 // Can use an empty set, since event contains the info
5836 jQuery().off( event );
5837 return origFn.apply( this, arguments );
5838 };
5839 // Use same guid so caller can remove using origFn
5840 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
5841 }
5842 return this.each( function() {
5843 jQuery.event.add( this, types, fn, data, selector );
5844 });
5845 },
5846 one: function( types, selector, data, fn ) {
5847 return this.on( types, selector, data, fn, 1 );
5848 },
5849 off: function( types, selector, fn ) {
5850 if ( types && types.preventDefault && types.handleObj ) {
5851 // ( event ) dispatched jQuery.Event
5852 var handleObj = types.handleObj;
5853 jQuery( types.delegateTarget ).off(
5854 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
5855 handleObj.selector,
5856 handleObj.handler
5857 );
5858 return this;
5859 }
5860 if ( typeof types === "object" ) {
5861 // ( types-object [, selector] )
5862 for ( var type in types ) {
5863 this.off( type, selector, types[ type ] );
5864 }
5865 return this;
5866 }
5867 if ( selector === false || typeof selector === "function" ) {
5868 // ( types [, fn] )
5869 fn = selector;
5870 selector = undefined;
5871 }
5872 if ( fn === false ) {
5873 fn = returnFalse;
5874 }
5875 return this.each(function() {
5876 jQuery.event.remove( this, types, fn, selector );
5877 });
5878 },
5879
5880 bind: function( types, data, fn ) {
5881 return this.on( types, null, data, fn );
5882 },
5883 unbind: function( types, fn ) {
5884 return this.off( types, null, fn );
5885 },
5886
5887 live: function( types, data, fn ) {
5888 jQuery( this.context ).on( types, this.selector, data, fn );
5889 return this;
5890 },
5891 die: function( types, fn ) {
5892 jQuery( this.context ).off( types, this.selector || "**", fn );
5893 return this;
5894 },
5895
5896 delegate: function( selector, types, data, fn ) {
5897 return this.on( types, selector, data, fn );
5898 },
5899 undelegate: function( selector, types, fn ) {
5900 // ( namespace ) or ( selector, types [, fn] )
5901 return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
5902 },
5903
5904 trigger: function( type, data ) {
5905 return this.each(function() {
5906 jQuery.event.trigger( type, data, this );
5907 });
5908 },
5909 triggerHandler: function( type, data ) {
5910 if ( this[0] ) {
5911 return jQuery.event.trigger( type, data, this[0], true );
5912 }
5913 },
5914
5915 toggle: function( fn ) {
5916 // Save reference to arguments for access in closure
5917 var args = arguments,
5918 guid = fn.guid || jQuery.guid++,
5919 i = 0,
5920 toggler = function( event ) {
5921 // Figure out which function to execute
5922 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
5923 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
5924
5925 // Make sure that clicks stop
5926 event.preventDefault();
5927
5928 // and execute the function
5929 return args[ lastToggle ].apply( this, arguments ) || false;
5930 };
5931
5932 // link all the functions, so any of them can unbind this click handler
5933 toggler.guid = guid;
5934 while ( i < args.length ) {
5935 args[ i++ ].guid = guid;
5936 }
5937
5938 return this.click( toggler );
5939 },
5940
5941 hover: function( fnOver, fnOut ) {
5942 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
5943 }
5944});
5945
5946jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
5947 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
5948 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
5949
5950 // Handle event binding
5951 jQuery.fn[ name ] = function( data, fn ) {
5952 if ( fn == null ) {
5953 fn = data;
5954 data = null;
5955 }
5956
5957 return arguments.length > 0 ?
5958 this.on( name, null, data, fn ) :
5959 this.trigger( name );
5960 };
5961
5962 if ( jQuery.attrFn ) {
5963 jQuery.attrFn[ name ] = true;
5964 }
5965
5966 if ( rkeyEvent.test( name ) ) {
5967 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
5968 }
5969
5970 if ( rmouseEvent.test( name ) ) {
5971 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
5972 }
5973});
5974
5975
5976
5977/*
5978 * Sizzle CSS Selector Engine
5979 * Copyright 2011, The Dojo Foundation
5980 * Released under the MIT, BSD, and GPL Licenses.
5981 * More information: http://sizzlejs.com/
5982 */
5983(function(){
5984
5985var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
5986 expando = "sizcache" + (Math.random() + '').replace('.', ''),
5987 done = 0,
5988 toString = Object.prototype.toString,
5989 hasDuplicate = false,
5990 baseHasDuplicate = true,
5991 rBackslash = /\\/g,
5992 rReturn = /\r\n/g,
5993 rNonWord = /\W/;
5994
5995// Here we check if the JavaScript engine is using some sort of
5996// optimization where it does not always call our comparision
5997// function. If that is the case, discard the hasDuplicate value.
5998// Thus far that includes Google Chrome.
5999[0, 0].sort(function() {
6000 baseHasDuplicate = false;
6001 return 0;
6002});
6003
6004var Sizzle = function( selector, context, results, seed ) {
6005 results = results || [];
6006 context = context || document;
6007
6008 var origContext = context;
6009
6010 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
6011 return [];
6012 }
6013
6014 if ( !selector || typeof selector !== "string" ) {
6015 return results;
6016 }
6017
6018 var m, set, checkSet, extra, ret, cur, pop, i,
6019 prune = true,
6020 contextXML = Sizzle.isXML( context ),
6021 parts = [],
6022 soFar = selector;
6023
6024 // Reset the position of the chunker regexp (start from head)
6025 do {
6026 chunker.exec( "" );
6027 m = chunker.exec( soFar );
6028
6029 if ( m ) {
6030 soFar = m[3];
6031
6032 parts.push( m[1] );
6033
6034 if ( m[2] ) {
6035 extra = m[3];
6036 break;
6037 }
6038 }
6039 } while ( m );
6040
6041 if ( parts.length > 1 && origPOS.exec( selector ) ) {
6042
6043 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
6044 set = posProcess( parts[0] + parts[1], context, seed );
6045
6046 } else {
6047 set = Expr.relative[ parts[0] ] ?
6048 [ context ] :
6049 Sizzle( parts.shift(), context );
6050
6051 while ( parts.length ) {
6052 selector = parts.shift();
6053
6054 if ( Expr.relative[ selector ] ) {
6055 selector += parts.shift();
6056 }
6057
6058 set = posProcess( selector, set, seed );
6059 }
6060 }
6061
6062 } else {
6063 // Take a shortcut and set the context if the root selector is an ID
6064 // (but not if it'll be faster if the inner selector is an ID)
6065 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
6066 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
6067
6068 ret = Sizzle.find( parts.shift(), context, contextXML );
6069 context = ret.expr ?
6070 Sizzle.filter( ret.expr, ret.set )[0] :
6071 ret.set[0];
6072 }
6073
6074 if ( context ) {
6075 ret = seed ?
6076 { expr: parts.pop(), set: makeArray(seed) } :
6077 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
6078
6079 set = ret.expr ?
6080 Sizzle.filter( ret.expr, ret.set ) :
6081 ret.set;
6082
6083 if ( parts.length > 0 ) {
6084 checkSet = makeArray( set );
6085
6086 } else {
6087 prune = false;
6088 }
6089
6090 while ( parts.length ) {
6091 cur = parts.pop();
6092 pop = cur;
6093
6094 if ( !Expr.relative[ cur ] ) {
6095 cur = "";
6096 } else {
6097 pop = parts.pop();
6098 }
6099
6100 if ( pop == null ) {
6101 pop = context;
6102 }
6103
6104 Expr.relative[ cur ]( checkSet, pop, contextXML );
6105 }
6106
6107 } else {
6108 checkSet = parts = [];
6109 }
6110 }
6111
6112 if ( !checkSet ) {
6113 checkSet = set;
6114 }
6115
6116 if ( !checkSet ) {
6117 Sizzle.error( cur || selector );
6118 }
6119
6120 if ( toString.call(checkSet) === "[object Array]" ) {
6121 if ( !prune ) {
6122 results.push.apply( results, checkSet );
6123
6124 } else if ( context && context.nodeType === 1 ) {
6125 for ( i = 0; checkSet[i] != null; i++ ) {
6126 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
6127 results.push( set[i] );
6128 }
6129 }
6130
6131 } else {
6132 for ( i = 0; checkSet[i] != null; i++ ) {
6133 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
6134 results.push( set[i] );
6135 }
6136 }
6137 }
6138
6139 } else {
6140 makeArray( checkSet, results );
6141 }
6142
6143 if ( extra ) {
6144 Sizzle( extra, origContext, results, seed );
6145 Sizzle.uniqueSort( results );
6146 }
6147
6148 return results;
6149};
6150
6151Sizzle.uniqueSort = function( results ) {
6152 if ( sortOrder ) {
6153 hasDuplicate = baseHasDuplicate;
6154 results.sort( sortOrder );
6155
6156 if ( hasDuplicate ) {
6157 for ( var i = 1; i < results.length; i++ ) {
6158 if ( results[i] === results[ i - 1 ] ) {
6159 results.splice( i--, 1 );
6160 }
6161 }
6162 }
6163 }
6164
6165 return results;
6166};
6167
6168Sizzle.matches = function( expr, set ) {
6169 return Sizzle( expr, null, null, set );
6170};
6171
6172Sizzle.matchesSelector = function( node, expr ) {
6173 return Sizzle( expr, null, null, [node] ).length > 0;
6174};
6175
6176Sizzle.find = function( expr, context, isXML ) {
6177 var set, i, len, match, type, left;
6178
6179 if ( !expr ) {
6180 return [];
6181 }
6182
6183 for ( i = 0, len = Expr.order.length; i < len; i++ ) {
6184 type = Expr.order[i];
6185
6186 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
6187 left = match[1];
6188 match.splice( 1, 1 );
6189
6190 if ( left.substr( left.length - 1 ) !== "\\" ) {
6191 match[1] = (match[1] || "").replace( rBackslash, "" );
6192 set = Expr.find[ type ]( match, context, isXML );
6193
6194 if ( set != null ) {
6195 expr = expr.replace( Expr.match[ type ], "" );
6196 break;
6197 }
6198 }
6199 }
6200 }
6201
6202 if ( !set ) {
6203 set = typeof context.getElementsByTagName !== "undefined" ?
6204 context.getElementsByTagName( "*" ) :
6205 [];
6206 }
6207
6208 return { set: set, expr: expr };
6209};
6210
6211Sizzle.filter = function( expr, set, inplace, not ) {
6212 var match, anyFound,
6213 type, found, item, filter, left,
6214 i, pass,
6215 old = expr,
6216 result = [],
6217 curLoop = set,
6218 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
6219
6220 while ( expr && set.length ) {
6221 for ( type in Expr.filter ) {
6222 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
6223 filter = Expr.filter[ type ];
6224 left = match[1];
6225
6226 anyFound = false;
6227
6228 match.splice(1,1);
6229
6230 if ( left.substr( left.length - 1 ) === "\\" ) {
6231 continue;
6232 }
6233
6234 if ( curLoop === result ) {
6235 result = [];
6236 }
6237
6238 if ( Expr.preFilter[ type ] ) {
6239 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
6240
6241 if ( !match ) {
6242 anyFound = found = true;
6243
6244 } else if ( match === true ) {
6245 continue;
6246 }
6247 }
6248
6249 if ( match ) {
6250 for ( i = 0; (item = curLoop[i]) != null; i++ ) {
6251 if ( item ) {
6252 found = filter( item, match, i, curLoop );
6253 pass = not ^ found;
6254
6255 if ( inplace && found != null ) {
6256 if ( pass ) {
6257 anyFound = true;
6258
6259 } else {
6260 curLoop[i] = false;
6261 }
6262
6263 } else if ( pass ) {
6264 result.push( item );
6265 anyFound = true;
6266 }
6267 }
6268 }
6269 }
6270
6271 if ( found !== undefined ) {
6272 if ( !inplace ) {
6273 curLoop = result;
6274 }
6275
6276 expr = expr.replace( Expr.match[ type ], "" );
6277
6278 if ( !anyFound ) {
6279 return [];
6280 }
6281
6282 break;
6283 }
6284 }
6285 }
6286
6287 // Improper expression
6288 if ( expr === old ) {
6289 if ( anyFound == null ) {
6290 Sizzle.error( expr );
6291
6292 } else {
6293 break;
6294 }
6295 }
6296
6297 old = expr;
6298 }
6299
6300 return curLoop;
6301};
6302
6303Sizzle.error = function( msg ) {
6304 throw new Error( "Syntax error, unrecognized expression: " + msg );
6305};
6306
6307/**
6308 * Utility function for retreiving the text value of an array of DOM nodes
6309 * @param {Array|Element} elem
6310 */
6311var getText = Sizzle.getText = function( elem ) {
6312 var i, node,
6313 nodeType = elem.nodeType,
6314 ret = "";
6315
6316 if ( nodeType ) {
6317 if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
6318 // Use textContent || innerText for elements
6319 if ( typeof elem.textContent === 'string' ) {
6320 return elem.textContent;
6321 } else if ( typeof elem.innerText === 'string' ) {
6322 // Replace IE's carriage returns
6323 return elem.innerText.replace( rReturn, '' );
6324 } else {
6325 // Traverse it's children
6326 for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
6327 ret += getText( elem );
6328 }
6329 }
6330 } else if ( nodeType === 3 || nodeType === 4 ) {
6331 return elem.nodeValue;
6332 }
6333 } else {
6334
6335 // If no nodeType, this is expected to be an array
6336 for ( i = 0; (node = elem[i]); i++ ) {
6337 // Do not traverse comment nodes
6338 if ( node.nodeType !== 8 ) {
6339 ret += getText( node );
6340 }
6341 }
6342 }
6343 return ret;
6344};
6345
6346var Expr = Sizzle.selectors = {
6347 order: [ "ID", "NAME", "TAG" ],
6348
6349 match: {
6350 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
6351 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
6352 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
6353 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
6354 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
6355 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
6356 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
6357 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
6358 },
6359
6360 leftMatch: {},
6361
6362 attrMap: {
6363 "class": "className",
6364 "for": "htmlFor"
6365 },
6366
6367 attrHandle: {
6368 href: function( elem ) {
6369 return elem.getAttribute( "href" );
6370 },
6371 type: function( elem ) {
6372 return elem.getAttribute( "type" );
6373 }
6374 },
6375
6376 relative: {
6377 "+": function(checkSet, part){
6378 var isPartStr = typeof part === "string",
6379 isTag = isPartStr && !rNonWord.test( part ),
6380 isPartStrNotTag = isPartStr && !isTag;
6381
6382 if ( isTag ) {
6383 part = part.toLowerCase();
6384 }
6385
6386 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
6387 if ( (elem = checkSet[i]) ) {
6388 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
6389
6390 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
6391 elem || false :
6392 elem === part;
6393 }
6394 }
6395
6396 if ( isPartStrNotTag ) {
6397 Sizzle.filter( part, checkSet, true );
6398 }
6399 },
6400
6401 ">": function( checkSet, part ) {
6402 var elem,
6403 isPartStr = typeof part === "string",
6404 i = 0,
6405 l = checkSet.length;
6406
6407 if ( isPartStr && !rNonWord.test( part ) ) {
6408 part = part.toLowerCase();
6409
6410 for ( ; i < l; i++ ) {
6411 elem = checkSet[i];
6412
6413 if ( elem ) {
6414 var parent = elem.parentNode;
6415 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
6416 }
6417 }
6418
6419 } else {
6420 for ( ; i < l; i++ ) {
6421 elem = checkSet[i];
6422
6423 if ( elem ) {
6424 checkSet[i] = isPartStr ?
6425 elem.parentNode :
6426 elem.parentNode === part;
6427 }
6428 }
6429
6430 if ( isPartStr ) {
6431 Sizzle.filter( part, checkSet, true );
6432 }
6433 }
6434 },
6435
6436 "": function(checkSet, part, isXML){
6437 var nodeCheck,
6438 doneName = done++,
6439 checkFn = dirCheck;
6440
6441 if ( typeof part === "string" && !rNonWord.test( part ) ) {
6442 part = part.toLowerCase();
6443 nodeCheck = part;
6444 checkFn = dirNodeCheck;
6445 }
6446
6447 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
6448 },
6449
6450 "~": function( checkSet, part, isXML ) {
6451 var nodeCheck,
6452 doneName = done++,
6453 checkFn = dirCheck;
6454
6455 if ( typeof part === "string" && !rNonWord.test( part ) ) {
6456 part = part.toLowerCase();
6457 nodeCheck = part;
6458 checkFn = dirNodeCheck;
6459 }
6460
6461 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
6462 }
6463 },
6464
6465 find: {
6466 ID: function( match, context, isXML ) {
6467 if ( typeof context.getElementById !== "undefined" && !isXML ) {
6468 var m = context.getElementById(match[1]);
6469 // Check parentNode to catch when Blackberry 4.6 returns
6470 // nodes that are no longer in the document #6963
6471 return m && m.parentNode ? [m] : [];
6472 }
6473 },
6474
6475 NAME: function( match, context ) {
6476 if ( typeof context.getElementsByName !== "undefined" ) {
6477 var ret = [],
6478 results = context.getElementsByName( match[1] );
6479
6480 for ( var i = 0, l = results.length; i < l; i++ ) {
6481 if ( results[i].getAttribute("name") === match[1] ) {
6482 ret.push( results[i] );
6483 }
6484 }
6485
6486 return ret.length === 0 ? null : ret;
6487 }
6488 },
6489
6490 TAG: function( match, context ) {
6491 if ( typeof context.getElementsByTagName !== "undefined" ) {
6492 return context.getElementsByTagName( match[1] );
6493 }
6494 }
6495 },
6496 preFilter: {
6497 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
6498 match = " " + match[1].replace( rBackslash, "" ) + " ";
6499
6500 if ( isXML ) {
6501 return match;
6502 }
6503
6504 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
6505 if ( elem ) {
6506 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
6507 if ( !inplace ) {
6508 result.push( elem );
6509 }
6510
6511 } else if ( inplace ) {
6512 curLoop[i] = false;
6513 }
6514 }
6515 }
6516
6517 return false;
6518 },
6519
6520 ID: function( match ) {
6521 return match[1].replace( rBackslash, "" );
6522 },
6523
6524 TAG: function( match, curLoop ) {
6525 return match[1].replace( rBackslash, "" ).toLowerCase();
6526 },
6527
6528 CHILD: function( match ) {
6529 if ( match[1] === "nth" ) {
6530 if ( !match[2] ) {
6531 Sizzle.error( match[0] );
6532 }
6533
6534 match[2] = match[2].replace(/^\+|\s*/g, '');
6535
6536 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
6537 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
6538 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
6539 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
6540
6541 // calculate the numbers (first)n+(last) including if they are negative
6542 match[2] = (test[1] + (test[2] || 1)) - 0;
6543 match[3] = test[3] - 0;
6544 }
6545 else if ( match[2] ) {
6546 Sizzle.error( match[0] );
6547 }
6548
6549 // TODO: Move to normal caching system
6550 match[0] = done++;
6551
6552 return match;
6553 },
6554
6555 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
6556 var name = match[1] = match[1].replace( rBackslash, "" );
6557
6558 if ( !isXML && Expr.attrMap[name] ) {
6559 match[1] = Expr.attrMap[name];
6560 }
6561
6562 // Handle if an un-quoted value was used
6563 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
6564
6565 if ( match[2] === "~=" ) {
6566 match[4] = " " + match[4] + " ";
6567 }
6568
6569 return match;
6570 },
6571
6572 PSEUDO: function( match, curLoop, inplace, result, not ) {
6573 if ( match[1] === "not" ) {
6574 // If we're dealing with a complex expression, or a simple one
6575 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
6576 match[3] = Sizzle(match[3], null, null, curLoop);
6577
6578 } else {
6579 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
6580
6581 if ( !inplace ) {
6582 result.push.apply( result, ret );
6583 }
6584
6585 return false;
6586 }
6587
6588 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
6589 return true;
6590 }
6591
6592 return match;
6593 },
6594
6595 POS: function( match ) {
6596 match.unshift( true );
6597
6598 return match;
6599 }
6600 },
6601
6602 filters: {
6603 enabled: function( elem ) {
6604 return elem.disabled === false && elem.type !== "hidden";
6605 },
6606
6607 disabled: function( elem ) {
6608 return elem.disabled === true;
6609 },
6610
6611 checked: function( elem ) {
6612 return elem.checked === true;
6613 },
6614
6615 selected: function( elem ) {
6616 // Accessing this property makes selected-by-default
6617 // options in Safari work properly
6618 if ( elem.parentNode ) {
6619 elem.parentNode.selectedIndex;
6620 }
6621
6622 return elem.selected === true;
6623 },
6624
6625 parent: function( elem ) {
6626 return !!elem.firstChild;
6627 },
6628
6629 empty: function( elem ) {
6630 return !elem.firstChild;
6631 },
6632
6633 has: function( elem, i, match ) {
6634 return !!Sizzle( match[3], elem ).length;
6635 },
6636
6637 header: function( elem ) {
6638 return (/h\d/i).test( elem.nodeName );
6639 },
6640
6641 text: function( elem ) {
6642 var attr = elem.getAttribute( "type" ), type = elem.type;
6643 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
6644 // use getAttribute instead to test this case
6645 return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
6646 },
6647
6648 radio: function( elem ) {
6649 return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
6650 },
6651
6652 checkbox: function( elem ) {
6653 return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
6654 },
6655
6656 file: function( elem ) {
6657 return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
6658 },
6659
6660 password: function( elem ) {
6661 return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
6662 },
6663
6664 submit: function( elem ) {
6665 var name = elem.nodeName.toLowerCase();
6666 return (name === "input" || name === "button") && "submit" === elem.type;
6667 },
6668
6669 image: function( elem ) {
6670 return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
6671 },
6672
6673 reset: function( elem ) {
6674 var name = elem.nodeName.toLowerCase();
6675 return (name === "input" || name === "button") && "reset" === elem.type;
6676 },
6677
6678 button: function( elem ) {
6679 var name = elem.nodeName.toLowerCase();
6680 return name === "input" && "button" === elem.type || name === "button";
6681 },
6682
6683 input: function( elem ) {
6684 return (/input|select|textarea|button/i).test( elem.nodeName );
6685 },
6686
6687 focus: function( elem ) {
6688 return elem === elem.ownerDocument.activeElement;
6689 }
6690 },
6691 setFilters: {
6692 first: function( elem, i ) {
6693 return i === 0;
6694 },
6695
6696 last: function( elem, i, match, array ) {
6697 return i === array.length - 1;
6698 },
6699
6700 even: function( elem, i ) {
6701 return i % 2 === 0;
6702 },
6703
6704 odd: function( elem, i ) {
6705 return i % 2 === 1;
6706 },
6707
6708 lt: function( elem, i, match ) {
6709 return i < match[3] - 0;
6710 },
6711
6712 gt: function( elem, i, match ) {
6713 return i > match[3] - 0;
6714 },
6715
6716 nth: function( elem, i, match ) {
6717 return match[3] - 0 === i;
6718 },
6719
6720 eq: function( elem, i, match ) {
6721 return match[3] - 0 === i;
6722 }
6723 },
6724 filter: {
6725 PSEUDO: function( elem, match, i, array ) {
6726 var name = match[1],
6727 filter = Expr.filters[ name ];
6728
6729 if ( filter ) {
6730 return filter( elem, i, match, array );
6731
6732 } else if ( name === "contains" ) {
6733 return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
6734
6735 } else if ( name === "not" ) {
6736 var not = match[3];
6737
6738 for ( var j = 0, l = not.length; j < l; j++ ) {
6739 if ( not[j] === elem ) {
6740 return false;
6741 }
6742 }
6743
6744 return true;
6745
6746 } else {
6747 Sizzle.error( name );
6748 }
6749 },
6750
6751 CHILD: function( elem, match ) {
6752 var first, last,
6753 doneName, parent, cache,
6754 count, diff,
6755 type = match[1],
6756 node = elem;
6757
6758 switch ( type ) {
6759 case "only":
6760 case "first":
6761 while ( (node = node.previousSibling) ) {
6762 if ( node.nodeType === 1 ) {
6763 return false;
6764 }
6765 }
6766
6767 if ( type === "first" ) {
6768 return true;
6769 }
6770
6771 node = elem;
6772
6773 /* falls through */
6774 case "last":
6775 while ( (node = node.nextSibling) ) {
6776 if ( node.nodeType === 1 ) {
6777 return false;
6778 }
6779 }
6780
6781 return true;
6782
6783 case "nth":
6784 first = match[2];
6785 last = match[3];
6786
6787 if ( first === 1 && last === 0 ) {
6788 return true;
6789 }
6790
6791 doneName = match[0];
6792 parent = elem.parentNode;
6793
6794 if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
6795 count = 0;
6796
6797 for ( node = parent.firstChild; node; node = node.nextSibling ) {
6798 if ( node.nodeType === 1 ) {
6799 node.nodeIndex = ++count;
6800 }
6801 }
6802
6803 parent[ expando ] = doneName;
6804 }
6805
6806 diff = elem.nodeIndex - last;
6807
6808 if ( first === 0 ) {
6809 return diff === 0;
6810
6811 } else {
6812 return ( diff % first === 0 && diff / first >= 0 );
6813 }
6814 }
6815 },
6816
6817 ID: function( elem, match ) {
6818 return elem.nodeType === 1 && elem.getAttribute("id") === match;
6819 },
6820
6821 TAG: function( elem, match ) {
6822 return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
6823 },
6824
6825 CLASS: function( elem, match ) {
6826 return (" " + (elem.className || elem.getAttribute("class")) + " ")
6827 .indexOf( match ) > -1;
6828 },
6829
6830 ATTR: function( elem, match ) {
6831 var name = match[1],
6832 result = Sizzle.attr ?
6833 Sizzle.attr( elem, name ) :
6834 Expr.attrHandle[ name ] ?
6835 Expr.attrHandle[ name ]( elem ) :
6836 elem[ name ] != null ?
6837 elem[ name ] :
6838 elem.getAttribute( name ),
6839 value = result + "",
6840 type = match[2],
6841 check = match[4];
6842
6843 return result == null ?
6844 type === "!=" :
6845 !type && Sizzle.attr ?
6846 result != null :
6847 type === "=" ?
6848 value === check :
6849 type === "*=" ?
6850 value.indexOf(check) >= 0 :
6851 type === "~=" ?
6852 (" " + value + " ").indexOf(check) >= 0 :
6853 !check ?
6854 value && result !== false :
6855 type === "!=" ?
6856 value !== check :
6857 type === "^=" ?
6858 value.indexOf(check) === 0 :
6859 type === "$=" ?
6860 value.substr(value.length - check.length) === check :
6861 type === "|=" ?
6862 value === check || value.substr(0, check.length + 1) === check + "-" :
6863 false;
6864 },
6865
6866 POS: function( elem, match, i, array ) {
6867 var name = match[2],
6868 filter = Expr.setFilters[ name ];
6869
6870 if ( filter ) {
6871 return filter( elem, i, match, array );
6872 }
6873 }
6874 }
6875};
6876
6877var origPOS = Expr.match.POS,
6878 fescape = function(all, num){
6879 return "\\" + (num - 0 + 1);
6880 };
6881
6882for ( var type in Expr.match ) {
6883 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
6884 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
6885}
6886// Expose origPOS
6887// "global" as in regardless of relation to brackets/parens
6888Expr.match.globalPOS = origPOS;
6889
6890var makeArray = function( array, results ) {
6891 array = Array.prototype.slice.call( array, 0 );
6892
6893 if ( results ) {
6894 results.push.apply( results, array );
6895 return results;
6896 }
6897
6898 return array;
6899};
6900
6901// Perform a simple check to determine if the browser is capable of
6902// converting a NodeList to an array using builtin methods.
6903// Also verifies that the returned array holds DOM nodes
6904// (which is not the case in the Blackberry browser)
6905try {
6906 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
6907
6908// Provide a fallback method if it does not work
6909} catch( e ) {
6910 makeArray = function( array, results ) {
6911 var i = 0,
6912 ret = results || [];
6913
6914 if ( toString.call(array) === "[object Array]" ) {
6915 Array.prototype.push.apply( ret, array );
6916
6917 } else {
6918 if ( typeof array.length === "number" ) {
6919 for ( var l = array.length; i < l; i++ ) {
6920 ret.push( array[i] );
6921 }
6922
6923 } else {
6924 for ( ; array[i]; i++ ) {
6925 ret.push( array[i] );
6926 }
6927 }
6928 }
6929
6930 return ret;
6931 };
6932}
6933
6934var sortOrder, siblingCheck;
6935
6936if ( document.documentElement.compareDocumentPosition ) {
6937 sortOrder = function( a, b ) {
6938 if ( a === b ) {
6939 hasDuplicate = true;
6940 return 0;
6941 }
6942
6943 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
6944 return a.compareDocumentPosition ? -1 : 1;
6945 }
6946
6947 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
6948 };
6949
6950} else {
6951 sortOrder = function( a, b ) {
6952 // The nodes are identical, we can exit early
6953 if ( a === b ) {
6954 hasDuplicate = true;
6955 return 0;
6956
6957 // Fallback to using sourceIndex (in IE) if it's available on both nodes
6958 } else if ( a.sourceIndex && b.sourceIndex ) {
6959 return a.sourceIndex - b.sourceIndex;
6960 }
6961
6962 var al, bl,
6963 ap = [],
6964 bp = [],
6965 aup = a.parentNode,
6966 bup = b.parentNode,
6967 cur = aup;
6968
6969 // If the nodes are siblings (or identical) we can do a quick check
6970 if ( aup === bup ) {
6971 return siblingCheck( a, b );
6972
6973 // If no parents were found then the nodes are disconnected
6974 } else if ( !aup ) {
6975 return -1;
6976
6977 } else if ( !bup ) {
6978 return 1;
6979 }
6980
6981 // Otherwise they're somewhere else in the tree so we need
6982 // to build up a full list of the parentNodes for comparison
6983 while ( cur ) {
6984 ap.unshift( cur );
6985 cur = cur.parentNode;
6986 }
6987
6988 cur = bup;
6989
6990 while ( cur ) {
6991 bp.unshift( cur );
6992 cur = cur.parentNode;
6993 }
6994
6995 al = ap.length;
6996 bl = bp.length;
6997
6998 // Start walking down the tree looking for a discrepancy
6999 for ( var i = 0; i < al && i < bl; i++ ) {
7000 if ( ap[i] !== bp[i] ) {
7001 return siblingCheck( ap[i], bp[i] );
7002 }
7003 }
7004
7005 // We ended someplace up the tree so do a sibling check
7006 return i === al ?
7007 siblingCheck( a, bp[i], -1 ) :
7008 siblingCheck( ap[i], b, 1 );
7009 };
7010
7011 siblingCheck = function( a, b, ret ) {
7012 if ( a === b ) {
7013 return ret;
7014 }
7015
7016 var cur = a.nextSibling;
7017
7018 while ( cur ) {
7019 if ( cur === b ) {
7020 return -1;
7021 }
7022
7023 cur = cur.nextSibling;
7024 }
7025
7026 return 1;
7027 };
7028}
7029
7030// Check to see if the browser returns elements by name when
7031// querying by getElementById (and provide a workaround)
7032(function(){
7033 // We're going to inject a fake input element with a specified name
7034 var form = document.createElement("div"),
7035 id = "script" + (new Date()).getTime(),
7036 root = document.documentElement;
7037
7038 form.innerHTML = "<a name='" + id + "'/>";
7039
7040 // Inject it into the root element, check its status, and remove it quickly
7041 root.insertBefore( form, root.firstChild );
7042
7043 // The workaround has to do additional checks after a getElementById
7044 // Which slows things down for other browsers (hence the branching)
7045 if ( document.getElementById( id ) ) {
7046 Expr.find.ID = function( match, context, isXML ) {
7047 if ( typeof context.getElementById !== "undefined" && !isXML ) {
7048 var m = context.getElementById(match[1]);
7049
7050 return m ?
7051 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
7052 [m] :
7053 undefined :
7054 [];
7055 }
7056 };
7057
7058 Expr.filter.ID = function( elem, match ) {
7059 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
7060
7061 return elem.nodeType === 1 && node && node.nodeValue === match;
7062 };
7063 }
7064
7065 root.removeChild( form );
7066
7067 // release memory in IE
7068 root = form = null;
7069})();
7070
7071(function(){
7072 // Check to see if the browser returns only elements
7073 // when doing getElementsByTagName("*")
7074
7075 // Create a fake element
7076 var div = document.createElement("div");
7077 div.appendChild( document.createComment("") );
7078
7079 // Make sure no comments are found
7080 if ( div.getElementsByTagName("*").length > 0 ) {
7081 Expr.find.TAG = function( match, context ) {
7082 var results = context.getElementsByTagName( match[1] );
7083
7084 // Filter out possible comments
7085 if ( match[1] === "*" ) {
7086 var tmp = [];
7087
7088 for ( var i = 0; results[i]; i++ ) {
7089 if ( results[i].nodeType === 1 ) {
7090 tmp.push( results[i] );
7091 }
7092 }
7093
7094 results = tmp;
7095 }
7096
7097 return results;
7098 };
7099 }
7100
7101 // Check to see if an attribute returns normalized href attributes
7102 div.innerHTML = "<a href='#'></a>";
7103
7104 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
7105 div.firstChild.getAttribute("href") !== "#" ) {
7106
7107 Expr.attrHandle.href = function( elem ) {
7108 return elem.getAttribute( "href", 2 );
7109 };
7110 }
7111
7112 // release memory in IE
7113 div = null;
7114})();
7115
7116if ( document.querySelectorAll ) {
7117 (function(){
7118 var oldSizzle = Sizzle,
7119 div = document.createElement("div"),
7120 id = "__sizzle__";
7121
7122 div.innerHTML = "<p class='TEST'></p>";
7123
7124 // Safari can't handle uppercase or unicode characters when
7125 // in quirks mode.
7126 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
7127 return;
7128 }
7129
7130 Sizzle = function( query, context, extra, seed ) {
7131 context = context || document;
7132
7133 // Only use querySelectorAll on non-XML documents
7134 // (ID selectors don't work in non-HTML documents)
7135 if ( !seed && !Sizzle.isXML(context) ) {
7136 // See if we find a selector to speed up
7137 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
7138
7139 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
7140 // Speed-up: Sizzle("TAG")
7141 if ( match[1] ) {
7142 return makeArray( context.getElementsByTagName( query ), extra );
7143
7144 // Speed-up: Sizzle(".CLASS")
7145 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
7146 return makeArray( context.getElementsByClassName( match[2] ), extra );
7147 }
7148 }
7149
7150 if ( context.nodeType === 9 ) {
7151 // Speed-up: Sizzle("body")
7152 // The body element only exists once, optimize finding it
7153 if ( query === "body" && context.body ) {
7154 return makeArray( [ context.body ], extra );
7155
7156 // Speed-up: Sizzle("#ID")
7157 } else if ( match && match[3] ) {
7158 var elem = context.getElementById( match[3] );
7159
7160 // Check parentNode to catch when Blackberry 4.6 returns
7161 // nodes that are no longer in the document #6963
7162 if ( elem && elem.parentNode ) {
7163 // Handle the case where IE and Opera return items
7164 // by name instead of ID
7165 if ( elem.id === match[3] ) {
7166 return makeArray( [ elem ], extra );
7167 }
7168
7169 } else {
7170 return makeArray( [], extra );
7171 }
7172 }
7173
7174 try {
7175 return makeArray( context.querySelectorAll(query), extra );
7176 } catch(qsaError) {}
7177
7178 // qSA works strangely on Element-rooted queries
7179 // We can work around this by specifying an extra ID on the root
7180 // and working up from there (Thanks to Andrew Dupont for the technique)
7181 // IE 8 doesn't work on object elements
7182 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
7183 var oldContext = context,
7184 old = context.getAttribute( "id" ),
7185 nid = old || id,
7186 hasParent = context.parentNode,
7187 relativeHierarchySelector = /^\s*[+~]/.test( query );
7188
7189 if ( !old ) {
7190 context.setAttribute( "id", nid );
7191 } else {
7192 nid = nid.replace( /'/g, "\\$&" );
7193 }
7194 if ( relativeHierarchySelector && hasParent ) {
7195 context = context.parentNode;
7196 }
7197
7198 try {
7199 if ( !relativeHierarchySelector || hasParent ) {
7200 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
7201 }
7202
7203 } catch(pseudoError) {
7204 } finally {
7205 if ( !old ) {
7206 oldContext.removeAttribute( "id" );
7207 }
7208 }
7209 }
7210 }
7211
7212 return oldSizzle(query, context, extra, seed);
7213 };
7214
7215 for ( var prop in oldSizzle ) {
7216 Sizzle[ prop ] = oldSizzle[ prop ];
7217 }
7218
7219 // release memory in IE
7220 div = null;
7221 })();
7222}
7223
7224(function(){
7225 var html = document.documentElement,
7226 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
7227
7228 if ( matches ) {
7229 // Check to see if it's possible to do matchesSelector
7230 // on a disconnected node (IE 9 fails this)
7231 var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
7232 pseudoWorks = false;
7233
7234 try {
7235 // This should fail with an exception
7236 // Gecko does not error, returns false instead
7237 matches.call( document.documentElement, "[test!='']:sizzle" );
7238
7239 } catch( pseudoError ) {
7240 pseudoWorks = true;
7241 }
7242
7243 Sizzle.matchesSelector = function( node, expr ) {
7244 // Make sure that attribute selectors are quoted
7245 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
7246
7247 if ( !Sizzle.isXML( node ) ) {
7248 try {
7249 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
7250 var ret = matches.call( node, expr );
7251
7252 // IE 9's matchesSelector returns false on disconnected nodes
7253 if ( ret || !disconnectedMatch ||
7254 // As well, disconnected nodes are said to be in a document
7255 // fragment in IE 9, so check for that
7256 node.document && node.document.nodeType !== 11 ) {
7257 return ret;
7258 }
7259 }
7260 } catch(e) {}
7261 }
7262
7263 return Sizzle(expr, null, null, [node]).length > 0;
7264 };
7265 }
7266})();
7267
7268(function(){
7269 var div = document.createElement("div");
7270
7271 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
7272
7273 // Opera can't find a second classname (in 9.6)
7274 // Also, make sure that getElementsByClassName actually exists
7275 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
7276 return;
7277 }
7278
7279 // Safari caches class attributes, doesn't catch changes (in 3.2)
7280 div.lastChild.className = "e";
7281
7282 if ( div.getElementsByClassName("e").length === 1 ) {
7283 return;
7284 }
7285
7286 Expr.order.splice(1, 0, "CLASS");
7287 Expr.find.CLASS = function( match, context, isXML ) {
7288 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
7289 return context.getElementsByClassName(match[1]);
7290 }
7291 };
7292
7293 // release memory in IE
7294 div = null;
7295})();
7296
7297function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
7298 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
7299 var elem = checkSet[i];
7300
7301 if ( elem ) {
7302 var match = false;
7303
7304 elem = elem[dir];
7305
7306 while ( elem ) {
7307 if ( elem[ expando ] === doneName ) {
7308 match = checkSet[elem.sizset];
7309 break;
7310 }
7311
7312 if ( elem.nodeType === 1 && !isXML ){
7313 elem[ expando ] = doneName;
7314 elem.sizset = i;
7315 }
7316
7317 if ( elem.nodeName.toLowerCase() === cur ) {
7318 match = elem;
7319 break;
7320 }
7321
7322 elem = elem[dir];
7323 }
7324
7325 checkSet[i] = match;
7326 }
7327 }
7328}
7329
7330function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
7331 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
7332 var elem = checkSet[i];
7333
7334 if ( elem ) {
7335 var match = false;
7336
7337 elem = elem[dir];
7338
7339 while ( elem ) {
7340 if ( elem[ expando ] === doneName ) {
7341 match = checkSet[elem.sizset];
7342 break;
7343 }
7344
7345 if ( elem.nodeType === 1 ) {
7346 if ( !isXML ) {
7347 elem[ expando ] = doneName;
7348 elem.sizset = i;
7349 }
7350
7351 if ( typeof cur !== "string" ) {
7352 if ( elem === cur ) {
7353 match = true;
7354 break;
7355 }
7356
7357 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
7358 match = elem;
7359 break;
7360 }
7361 }
7362
7363 elem = elem[dir];
7364 }
7365
7366 checkSet[i] = match;
7367 }
7368 }
7369}
7370
7371if ( document.documentElement.contains ) {
7372 Sizzle.contains = function( a, b ) {
7373 return a !== b && (a.contains ? a.contains(b) : true);
7374 };
7375
7376} else if ( document.documentElement.compareDocumentPosition ) {
7377 Sizzle.contains = function( a, b ) {
7378 return !!(a.compareDocumentPosition(b) & 16);
7379 };
7380
7381} else {
7382 Sizzle.contains = function() {
7383 return false;
7384 };
7385}
7386
7387Sizzle.isXML = function( elem ) {
7388 // documentElement is verified for cases where it doesn't yet exist
7389 // (such as loading iframes in IE - #4833)
7390 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
7391
7392 return documentElement ? documentElement.nodeName !== "HTML" : false;
7393};
7394
7395var posProcess = function( selector, context, seed ) {
7396 var match,
7397 tmpSet = [],
7398 later = "",
7399 root = context.nodeType ? [context] : context;
7400
7401 // Position selectors must be done after the filter
7402 // And so must :not(positional) so we move all PSEUDOs to the end
7403 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
7404 later += match[0];
7405 selector = selector.replace( Expr.match.PSEUDO, "" );
7406 }
7407
7408 selector = Expr.relative[selector] ? selector + "*" : selector;
7409
7410 for ( var i = 0, l = root.length; i < l; i++ ) {
7411 Sizzle( selector, root[i], tmpSet, seed );
7412 }
7413
7414 return Sizzle.filter( later, tmpSet );
7415};
7416
7417// EXPOSE
7418// Override sizzle attribute retrieval
7419Sizzle.attr = jQuery.attr;
7420Sizzle.selectors.attrMap = {};
7421jQuery.find = Sizzle;
7422jQuery.expr = Sizzle.selectors;
7423jQuery.expr[":"] = jQuery.expr.filters;
7424jQuery.unique = Sizzle.uniqueSort;
7425jQuery.text = Sizzle.getText;
7426jQuery.isXMLDoc = Sizzle.isXML;
7427jQuery.contains = Sizzle.contains;
7428
7429
7430})();
7431
7432
7433var runtil = /Until$/,
7434 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
7435 // Note: This RegExp should be improved, or likely pulled from Sizzle
7436 rmultiselector = /,/,
7437 isSimple = /^.[^:#\[\.,]*$/,
7438 slice = Array.prototype.slice,
7439 POS = jQuery.expr.match.globalPOS,
7440 // methods guaranteed to produce a unique set when starting from a unique set
7441 guaranteedUnique = {
7442 children: true,
7443 contents: true,
7444 next: true,
7445 prev: true
7446 };
7447
7448jQuery.fn.extend({
7449 find: function( selector ) {
7450 var self = this,
7451 i, l;
7452
7453 if ( typeof selector !== "string" ) {
7454 return jQuery( selector ).filter(function() {
7455 for ( i = 0, l = self.length; i < l; i++ ) {
7456 if ( jQuery.contains( self[ i ], this ) ) {
7457 return true;
7458 }
7459 }
7460 });
7461 }
7462
7463 var ret = this.pushStack( "", "find", selector ),
7464 length, n, r;
7465
7466 for ( i = 0, l = this.length; i < l; i++ ) {
7467 length = ret.length;
7468 jQuery.find( selector, this[i], ret );
7469
7470 if ( i > 0 ) {
7471 // Make sure that the results are unique
7472 for ( n = length; n < ret.length; n++ ) {
7473 for ( r = 0; r < length; r++ ) {
7474 if ( ret[r] === ret[n] ) {
7475 ret.splice(n--, 1);
7476 break;
7477 }
7478 }
7479 }
7480 }
7481 }
7482
7483 return ret;
7484 },
7485
7486 has: function( target ) {
7487 var targets = jQuery( target );
7488 return this.filter(function() {
7489 for ( var i = 0, l = targets.length; i < l; i++ ) {
7490 if ( jQuery.contains( this, targets[i] ) ) {
7491 return true;
7492 }
7493 }
7494 });
7495 },
7496
7497 not: function( selector ) {
7498 return this.pushStack( winnow(this, selector, false), "not", selector);
7499 },
7500
7501 filter: function( selector ) {
7502 return this.pushStack( winnow(this, selector, true), "filter", selector );
7503 },
7504
7505 is: function( selector ) {
7506 return !!selector && (
7507 typeof selector === "string" ?
7508 // If this is a positional selector, check membership in the returned set
7509 // so $("p:first").is("p:last") won't return true for a doc with two "p".
7510 POS.test( selector ) ?
7511 jQuery( selector, this.context ).index( this[0] ) >= 0 :
7512 jQuery.filter( selector, this ).length > 0 :
7513 this.filter( selector ).length > 0 );
7514 },
7515
7516 closest: function( selectors, context ) {
7517 var ret = [], i, l, cur = this[0];
7518
7519 // Array (deprecated as of jQuery 1.7)
7520 if ( jQuery.isArray( selectors ) ) {
7521 var level = 1;
7522
7523 while ( cur && cur.ownerDocument && cur !== context ) {
7524 for ( i = 0; i < selectors.length; i++ ) {
7525
7526 if ( jQuery( cur ).is( selectors[ i ] ) ) {
7527 ret.push({ selector: selectors[ i ], elem: cur, level: level });
7528 }
7529 }
7530
7531 cur = cur.parentNode;
7532 level++;
7533 }
7534
7535 return ret;
7536 }
7537
7538 // String
7539 var pos = POS.test( selectors ) || typeof selectors !== "string" ?
7540 jQuery( selectors, context || this.context ) :
7541 0;
7542
7543 for ( i = 0, l = this.length; i < l; i++ ) {
7544 cur = this[i];
7545
7546 while ( cur ) {
7547 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
7548 ret.push( cur );
7549 break;
7550
7551 } else {
7552 cur = cur.parentNode;
7553 if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
7554 break;
7555 }
7556 }
7557 }
7558 }
7559
7560 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
7561
7562 return this.pushStack( ret, "closest", selectors );
7563 },
7564
7565 // Determine the position of an element within
7566 // the matched set of elements
7567 index: function( elem ) {
7568
7569 // No argument, return index in parent
7570 if ( !elem ) {
7571 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
7572 }
7573
7574 // index in selector
7575 if ( typeof elem === "string" ) {
7576 return jQuery.inArray( this[0], jQuery( elem ) );
7577 }
7578
7579 // Locate the position of the desired element
7580 return jQuery.inArray(
7581 // If it receives a jQuery object, the first element is used
7582 elem.jquery ? elem[0] : elem, this );
7583 },
7584
7585 add: function( selector, context ) {
7586 var set = typeof selector === "string" ?
7587 jQuery( selector, context ) :
7588 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
7589 all = jQuery.merge( this.get(), set );
7590
7591 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
7592 all :
7593 jQuery.unique( all ) );
7594 },
7595
7596 andSelf: function() {
7597 return this.add( this.prevObject );
7598 }
7599});
7600
7601// A painfully simple check to see if an element is disconnected
7602// from a document (should be improved, where feasible).
7603function isDisconnected( node ) {
7604 return !node || !node.parentNode || node.parentNode.nodeType === 11;
7605}
7606
7607jQuery.each({
7608 parent: function( elem ) {
7609 var parent = elem.parentNode;
7610 return parent && parent.nodeType !== 11 ? parent : null;
7611 },
7612 parents: function( elem ) {
7613 return jQuery.dir( elem, "parentNode" );
7614 },
7615 parentsUntil: function( elem, i, until ) {
7616 return jQuery.dir( elem, "parentNode", until );
7617 },
7618 next: function( elem ) {
7619 return jQuery.nth( elem, 2, "nextSibling" );
7620 },
7621 prev: function( elem ) {
7622 return jQuery.nth( elem, 2, "previousSibling" );
7623 },
7624 nextAll: function( elem ) {
7625 return jQuery.dir( elem, "nextSibling" );
7626 },
7627 prevAll: function( elem ) {
7628 return jQuery.dir( elem, "previousSibling" );
7629 },
7630 nextUntil: function( elem, i, until ) {
7631 return jQuery.dir( elem, "nextSibling", until );
7632 },
7633 prevUntil: function( elem, i, until ) {
7634 return jQuery.dir( elem, "previousSibling", until );
7635 },
7636 siblings: function( elem ) {
7637 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
7638 },
7639 children: function( elem ) {
7640 return jQuery.sibling( elem.firstChild );
7641 },
7642 contents: function( elem ) {
7643 return jQuery.nodeName( elem, "iframe" ) ?
7644 elem.contentDocument || elem.contentWindow.document :
7645 jQuery.makeArray( elem.childNodes );
7646 }
7647}, function( name, fn ) {
7648 jQuery.fn[ name ] = function( until, selector ) {
7649 var ret = jQuery.map( this, fn, until );
7650
7651 if ( !runtil.test( name ) ) {
7652 selector = until;
7653 }
7654
7655 if ( selector && typeof selector === "string" ) {
7656 ret = jQuery.filter( selector, ret );
7657 }
7658
7659 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
7660
7661 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
7662 ret = ret.reverse();
7663 }
7664
7665 return this.pushStack( ret, name, slice.call( arguments ).join(",") );
7666 };
7667});
7668
7669jQuery.extend({
7670 filter: function( expr, elems, not ) {
7671 if ( not ) {
7672 expr = ":not(" + expr + ")";
7673 }
7674
7675 return elems.length === 1 ?
7676 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
7677 jQuery.find.matches(expr, elems);
7678 },
7679
7680 dir: function( elem, dir, until ) {
7681 var matched = [],
7682 cur = elem[ dir ];
7683
7684 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
7685 if ( cur.nodeType === 1 ) {
7686 matched.push( cur );
7687 }
7688 cur = cur[dir];
7689 }
7690 return matched;
7691 },
7692
7693 nth: function( cur, result, dir, elem ) {
7694 result = result || 1;
7695 var num = 0;
7696
7697 for ( ; cur; cur = cur[dir] ) {
7698 if ( cur.nodeType === 1 && ++num === result ) {
7699 break;
7700 }
7701 }
7702
7703 return cur;
7704 },
7705
7706 sibling: function( n, elem ) {
7707 var r = [];
7708
7709 for ( ; n; n = n.nextSibling ) {
7710 if ( n.nodeType === 1 && n !== elem ) {
7711 r.push( n );
7712 }
7713 }
7714
7715 return r;
7716 }
7717});
7718
7719// Implement the identical functionality for filter and not
7720function winnow( elements, qualifier, keep ) {
7721
7722 // Can't pass null or undefined to indexOf in Firefox 4
7723 // Set to 0 to skip string check
7724 qualifier = qualifier || 0;
7725
7726 if ( jQuery.isFunction( qualifier ) ) {
7727 return jQuery.grep(elements, function( elem, i ) {
7728 var retVal = !!qualifier.call( elem, i, elem );
7729 return retVal === keep;
7730 });
7731
7732 } else if ( qualifier.nodeType ) {
7733 return jQuery.grep(elements, function( elem, i ) {
7734 return ( elem === qualifier ) === keep;
7735 });
7736
7737 } else if ( typeof qualifier === "string" ) {
7738 var filtered = jQuery.grep(elements, function( elem ) {
7739 return elem.nodeType === 1;
7740 });
7741
7742 if ( isSimple.test( qualifier ) ) {
7743 return jQuery.filter(qualifier, filtered, !keep);
7744 } else {
7745 qualifier = jQuery.filter( qualifier, filtered );
7746 }
7747 }
7748
7749 return jQuery.grep(elements, function( elem, i ) {
7750 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
7751 });
7752}
7753
7754
7755
7756
7757function createSafeFragment( document ) {
7758 var list = nodeNames.split( "|" ),
7759 safeFrag = document.createDocumentFragment();
7760
7761 if ( safeFrag.createElement ) {
7762 while ( list.length ) {
7763 safeFrag.createElement(
7764 list.pop()
7765 );
7766 }
7767 }
7768 return safeFrag;
7769}
7770
7771var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
7772 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
7773 rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
7774 rleadingWhitespace = /^\s+/,
7775 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
7776 rtagName = /<([\w:]+)/,
7777 rtbody = /<tbody/i,
7778 rhtml = /<|&#?\w+;/,
7779 rnoInnerhtml = /<(?:script|style)/i,
7780 rnocache = /<(?:script|object|embed|option|style)/i,
7781 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
7782 // checked="checked" or checked
7783 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
7784 rscriptType = /\/(java|ecma)script/i,
7785 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
7786 wrapMap = {
7787 option: [ 1, "<select multiple='multiple'>", "</select>" ],
7788 legend: [ 1, "<fieldset>", "</fieldset>" ],
7789 thead: [ 1, "<table>", "</table>" ],
7790 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
7791 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
7792 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
7793 area: [ 1, "<map>", "</map>" ],
7794 _default: [ 0, "", "" ]
7795 },
7796 safeFragment = createSafeFragment( document );
7797
7798wrapMap.optgroup = wrapMap.option;
7799wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
7800wrapMap.th = wrapMap.td;
7801
7802// IE can't serialize <link> and <script> tags normally
7803if ( !jQuery.support.htmlSerialize ) {
7804 wrapMap._default = [ 1, "div<div>", "</div>" ];
7805}
7806
7807jQuery.fn.extend({
7808 text: function( value ) {
7809 return jQuery.access( this, function( value ) {
7810 return value === undefined ?
7811 jQuery.text( this ) :
7812 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
7813 }, null, value, arguments.length );
7814 },
7815
7816 wrapAll: function( html ) {
7817 if ( jQuery.isFunction( html ) ) {
7818 return this.each(function(i) {
7819 jQuery(this).wrapAll( html.call(this, i) );
7820 });
7821 }
7822
7823 if ( this[0] ) {
7824 // The elements to wrap the target around
7825 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
7826
7827 if ( this[0].parentNode ) {
7828 wrap.insertBefore( this[0] );
7829 }
7830
7831 wrap.map(function() {
7832 var elem = this;
7833
7834 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
7835 elem = elem.firstChild;
7836 }
7837
7838 return elem;
7839 }).append( this );
7840 }
7841
7842 return this;
7843 },
7844
7845 wrapInner: function( html ) {
7846 if ( jQuery.isFunction( html ) ) {
7847 return this.each(function(i) {
7848 jQuery(this).wrapInner( html.call(this, i) );
7849 });
7850 }
7851
7852 return this.each(function() {
7853 var self = jQuery( this ),
7854 contents = self.contents();
7855
7856 if ( contents.length ) {
7857 contents.wrapAll( html );
7858
7859 } else {
7860 self.append( html );
7861 }
7862 });
7863 },
7864
7865 wrap: function( html ) {
7866 var isFunction = jQuery.isFunction( html );
7867
7868 return this.each(function(i) {
7869 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
7870 });
7871 },
7872
7873 unwrap: function() {
7874 return this.parent().each(function() {
7875 if ( !jQuery.nodeName( this, "body" ) ) {
7876 jQuery( this ).replaceWith( this.childNodes );
7877 }
7878 }).end();
7879 },
7880
7881 append: function() {
7882 return this.domManip(arguments, true, function( elem ) {
7883 if ( this.nodeType === 1 ) {
7884 this.appendChild( elem );
7885 }
7886 });
7887 },
7888
7889 prepend: function() {
7890 return this.domManip(arguments, true, function( elem ) {
7891 if ( this.nodeType === 1 ) {
7892 this.insertBefore( elem, this.firstChild );
7893 }
7894 });
7895 },
7896
7897 before: function() {
7898 if ( this[0] && this[0].parentNode ) {
7899 return this.domManip(arguments, false, function( elem ) {
7900 this.parentNode.insertBefore( elem, this );
7901 });
7902 } else if ( arguments.length ) {
7903 var set = jQuery.clean( arguments );
7904 set.push.apply( set, this.toArray() );
7905 return this.pushStack( set, "before", arguments );
7906 }
7907 },
7908
7909 after: function() {
7910 if ( this[0] && this[0].parentNode ) {
7911 return this.domManip(arguments, false, function( elem ) {
7912 this.parentNode.insertBefore( elem, this.nextSibling );
7913 });
7914 } else if ( arguments.length ) {
7915 var set = this.pushStack( this, "after", arguments );
7916 set.push.apply( set, jQuery.clean(arguments) );
7917 return set;
7918 }
7919 },
7920
7921 // keepData is for internal use only--do not document
7922 remove: function( selector, keepData ) {
7923 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
7924 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
7925 if ( !keepData && elem.nodeType === 1 ) {
7926 jQuery.cleanData( elem.getElementsByTagName("*") );
7927 jQuery.cleanData( [ elem ] );
7928 }
7929
7930 if ( elem.parentNode ) {
7931 elem.parentNode.removeChild( elem );
7932 }
7933 }
7934 }
7935
7936 return this;
7937 },
7938
7939 empty: function() {
7940 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
7941 // Remove element nodes and prevent memory leaks
7942 if ( elem.nodeType === 1 ) {
7943 jQuery.cleanData( elem.getElementsByTagName("*") );
7944 }
7945
7946 // Remove any remaining nodes
7947 while ( elem.firstChild ) {
7948 elem.removeChild( elem.firstChild );
7949 }
7950 }
7951
7952 return this;
7953 },
7954
7955 clone: function( dataAndEvents, deepDataAndEvents ) {
7956 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
7957 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
7958
7959 return this.map( function () {
7960 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
7961 });
7962 },
7963
7964 html: function( value ) {
7965 return jQuery.access( this, function( value ) {
7966 var elem = this[0] || {},
7967 i = 0,
7968 l = this.length;
7969
7970 if ( value === undefined ) {
7971 return elem.nodeType === 1 ?
7972 elem.innerHTML.replace( rinlinejQuery, "" ) :
7973 null;
7974 }
7975
7976
7977 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
7978 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
7979 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
7980
7981 value = value.replace( rxhtmlTag, "<$1></$2>" );
7982
7983 try {
7984 for (; i < l; i++ ) {
7985 // Remove element nodes and prevent memory leaks
7986 elem = this[i] || {};
7987 if ( elem.nodeType === 1 ) {
7988 jQuery.cleanData( elem.getElementsByTagName( "*" ) );
7989 elem.innerHTML = value;
7990 }
7991 }
7992
7993 elem = 0;
7994
7995 // If using innerHTML throws an exception, use the fallback method
7996 } catch(e) {}
7997 }
7998
7999 if ( elem ) {
8000 this.empty().append( value );
8001 }
8002 }, null, value, arguments.length );
8003 },
8004
8005 replaceWith: function( value ) {
8006 if ( this[0] && this[0].parentNode ) {
8007 // Make sure that the elements are removed from the DOM before they are inserted
8008 // this can help fix replacing a parent with child elements
8009 if ( jQuery.isFunction( value ) ) {
8010 return this.each(function(i) {
8011 var self = jQuery(this), old = self.html();
8012 self.replaceWith( value.call( this, i, old ) );
8013 });
8014 }
8015
8016 if ( typeof value !== "string" ) {
8017 value = jQuery( value ).detach();
8018 }
8019
8020 return this.each(function() {
8021 var next = this.nextSibling,
8022 parent = this.parentNode;
8023
8024 jQuery( this ).remove();
8025
8026 if ( next ) {
8027 jQuery(next).before( value );
8028 } else {
8029 jQuery(parent).append( value );
8030 }
8031 });
8032 } else {
8033 return this.length ?
8034 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
8035 this;
8036 }
8037 },
8038
8039 detach: function( selector ) {
8040 return this.remove( selector, true );
8041 },
8042
8043 domManip: function( args, table, callback ) {
8044 var results, first, fragment, parent,
8045 value = args[0],
8046 scripts = [];
8047
8048 // We can't cloneNode fragments that contain checked, in WebKit
8049 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
8050 return this.each(function() {
8051 jQuery(this).domManip( args, table, callback, true );
8052 });
8053 }
8054
8055 if ( jQuery.isFunction(value) ) {
8056 return this.each(function(i) {
8057 var self = jQuery(this);
8058 args[0] = value.call(this, i, table ? self.html() : undefined);
8059 self.domManip( args, table, callback );
8060 });
8061 }
8062
8063 if ( this[0] ) {
8064 parent = value && value.parentNode;
8065
8066 // If we're in a fragment, just use that instead of building a new one
8067 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
8068 results = { fragment: parent };
8069
8070 } else {
8071 results = jQuery.buildFragment( args, this, scripts );
8072 }
8073
8074 fragment = results.fragment;
8075
8076 if ( fragment.childNodes.length === 1 ) {
8077 first = fragment = fragment.firstChild;
8078 } else {
8079 first = fragment.firstChild;
8080 }
8081
8082 if ( first ) {
8083 table = table && jQuery.nodeName( first, "tr" );
8084
8085 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
8086 callback.call(
8087 table ?
8088 root(this[i], first) :
8089 this[i],
8090 // Make sure that we do not leak memory by inadvertently discarding
8091 // the original fragment (which might have attached data) instead of
8092 // using it; in addition, use the original fragment object for the last
8093 // item instead of first because it can end up being emptied incorrectly
8094 // in certain situations (Bug #8070).
8095 // Fragments from the fragment cache must always be cloned and never used
8096 // in place.
8097 results.cacheable || ( l > 1 && i < lastIndex ) ?
8098 jQuery.clone( fragment, true, true ) :
8099 fragment
8100 );
8101 }
8102 }
8103
8104 if ( scripts.length ) {
8105 jQuery.each( scripts, function( i, elem ) {
8106 if ( elem.src ) {
8107 jQuery.ajax({
8108 type: "GET",
8109 global: false,
8110 url: elem.src,
8111 async: false,
8112 dataType: "script"
8113 });
8114 } else {
8115 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
8116 }
8117
8118 if ( elem.parentNode ) {
8119 elem.parentNode.removeChild( elem );
8120 }
8121 });
8122 }
8123 }
8124
8125 return this;
8126 }
8127});
8128
8129function root( elem, cur ) {
8130 return jQuery.nodeName(elem, "table") ?
8131 (elem.getElementsByTagName("tbody")[0] ||
8132 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
8133 elem;
8134}
8135
8136function cloneCopyEvent( src, dest ) {
8137
8138 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
8139 return;
8140 }
8141
8142 var type, i, l,
8143 oldData = jQuery._data( src ),
8144 curData = jQuery._data( dest, oldData ),
8145 events = oldData.events;
8146
8147 if ( events ) {
8148 delete curData.handle;
8149 curData.events = {};
8150
8151 for ( type in events ) {
8152 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
8153 jQuery.event.add( dest, type, events[ type ][ i ] );
8154 }
8155 }
8156 }
8157
8158 // make the cloned public data object a copy from the original
8159 if ( curData.data ) {
8160 curData.data = jQuery.extend( {}, curData.data );
8161 }
8162}
8163
8164function cloneFixAttributes( src, dest ) {
8165 var nodeName;
8166
8167 // We do not need to do anything for non-Elements
8168 if ( dest.nodeType !== 1 ) {
8169 return;
8170 }
8171
8172 // clearAttributes removes the attributes, which we don't want,
8173 // but also removes the attachEvent events, which we *do* want
8174 if ( dest.clearAttributes ) {
8175 dest.clearAttributes();
8176 }
8177
8178 // mergeAttributes, in contrast, only merges back on the
8179 // original attributes, not the events
8180 if ( dest.mergeAttributes ) {
8181 dest.mergeAttributes( src );
8182 }
8183
8184 nodeName = dest.nodeName.toLowerCase();
8185
8186 // IE6-8 fail to clone children inside object elements that use
8187 // the proprietary classid attribute value (rather than the type
8188 // attribute) to identify the type of content to display
8189 if ( nodeName === "object" ) {
8190 dest.outerHTML = src.outerHTML;
8191
8192 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
8193 // IE6-8 fails to persist the checked state of a cloned checkbox
8194 // or radio button. Worse, IE6-7 fail to give the cloned element
8195 // a checked appearance if the defaultChecked value isn't also set
8196 if ( src.checked ) {
8197 dest.defaultChecked = dest.checked = src.checked;
8198 }
8199
8200 // IE6-7 get confused and end up setting the value of a cloned
8201 // checkbox/radio button to an empty string instead of "on"
8202 if ( dest.value !== src.value ) {
8203 dest.value = src.value;
8204 }
8205
8206 // IE6-8 fails to return the selected option to the default selected
8207 // state when cloning options
8208 } else if ( nodeName === "option" ) {
8209 dest.selected = src.defaultSelected;
8210
8211 // IE6-8 fails to set the defaultValue to the correct value when
8212 // cloning other types of input fields
8213 } else if ( nodeName === "input" || nodeName === "textarea" ) {
8214 dest.defaultValue = src.defaultValue;
8215
8216 // IE blanks contents when cloning scripts
8217 } else if ( nodeName === "script" && dest.text !== src.text ) {
8218 dest.text = src.text;
8219 }
8220
8221 // Event data gets referenced instead of copied if the expando
8222 // gets copied too
8223 dest.removeAttribute( jQuery.expando );
8224
8225 // Clear flags for bubbling special change/submit events, they must
8226 // be reattached when the newly cloned events are first activated
8227 dest.removeAttribute( "_submit_attached" );
8228 dest.removeAttribute( "_change_attached" );
8229}
8230
8231jQuery.buildFragment = function( args, nodes, scripts ) {
8232 var fragment, cacheable, cacheresults, doc,
8233 first = args[ 0 ];
8234
8235 // nodes may contain either an explicit document object,
8236 // a jQuery collection or context object.
8237 // If nodes[0] contains a valid object to assign to doc
8238 if ( nodes && nodes[0] ) {
8239 doc = nodes[0].ownerDocument || nodes[0];
8240 }
8241
8242 // Ensure that an attr object doesn't incorrectly stand in as a document object
8243 // Chrome and Firefox seem to allow this to occur and will throw exception
8244 // Fixes #8950
8245 if ( !doc.createDocumentFragment ) {
8246 doc = document;
8247 }
8248
8249 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
8250 // Cloning options loses the selected state, so don't cache them
8251 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
8252 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
8253 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
8254 if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
8255 first.charAt(0) === "<" && !rnocache.test( first ) &&
8256 (jQuery.support.checkClone || !rchecked.test( first )) &&
8257 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
8258
8259 cacheable = true;
8260
8261 cacheresults = jQuery.fragments[ first ];
8262 if ( cacheresults && cacheresults !== 1 ) {
8263 fragment = cacheresults;
8264 }
8265 }
8266
8267 if ( !fragment ) {
8268 fragment = doc.createDocumentFragment();
8269 jQuery.clean( args, doc, fragment, scripts );
8270 }
8271
8272 if ( cacheable ) {
8273 jQuery.fragments[ first ] = cacheresults ? fragment : 1;
8274 }
8275
8276 return { fragment: fragment, cacheable: cacheable };
8277};
8278
8279jQuery.fragments = {};
8280
8281jQuery.each({
8282 appendTo: "append",
8283 prependTo: "prepend",
8284 insertBefore: "before",
8285 insertAfter: "after",
8286 replaceAll: "replaceWith"
8287}, function( name, original ) {
8288 jQuery.fn[ name ] = function( selector ) {
8289 var ret = [],
8290 insert = jQuery( selector ),
8291 parent = this.length === 1 && this[0].parentNode;
8292
8293 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
8294 insert[ original ]( this[0] );
8295 return this;
8296
8297 } else {
8298 for ( var i = 0, l = insert.length; i < l; i++ ) {
8299 var elems = ( i > 0 ? this.clone(true) : this ).get();
8300 jQuery( insert[i] )[ original ]( elems );
8301 ret = ret.concat( elems );
8302 }
8303
8304 return this.pushStack( ret, name, insert.selector );
8305 }
8306 };
8307});
8308
8309function getAll( elem ) {
8310 if ( typeof elem.getElementsByTagName !== "undefined" ) {
8311 return elem.getElementsByTagName( "*" );
8312
8313 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
8314 return elem.querySelectorAll( "*" );
8315
8316 } else {
8317 return [];
8318 }
8319}
8320
8321// Used in clean, fixes the defaultChecked property
8322function fixDefaultChecked( elem ) {
8323 if ( elem.type === "checkbox" || elem.type === "radio" ) {
8324 elem.defaultChecked = elem.checked;
8325 }
8326}
8327// Finds all inputs and passes them to fixDefaultChecked
8328function findInputs( elem ) {
8329 var nodeName = ( elem.nodeName || "" ).toLowerCase();
8330 if ( nodeName === "input" ) {
8331 fixDefaultChecked( elem );
8332 // Skip scripts, get other children
8333 } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
8334 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
8335 }
8336}
8337
8338// Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
8339function shimCloneNode( elem ) {
8340 var div = document.createElement( "div" );
8341 safeFragment.appendChild( div );
8342
8343 div.innerHTML = elem.outerHTML;
8344 return div.firstChild;
8345}
8346
8347jQuery.extend({
8348 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
8349 var srcElements,
8350 destElements,
8351 i,
8352 // IE<=8 does not properly clone detached, unknown element nodes
8353 clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ?
8354 elem.cloneNode( true ) :
8355 shimCloneNode( elem );
8356
8357 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
8358 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
8359 // IE copies events bound via attachEvent when using cloneNode.
8360 // Calling detachEvent on the clone will also remove the events
8361 // from the original. In order to get around this, we use some
8362 // proprietary methods to clear the events. Thanks to MooTools
8363 // guys for this hotness.
8364
8365 cloneFixAttributes( elem, clone );
8366
8367 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
8368 srcElements = getAll( elem );
8369 destElements = getAll( clone );
8370
8371 // Weird iteration because IE will replace the length property
8372 // with an element if you are cloning the body and one of the
8373 // elements on the page has a name or id of "length"
8374 for ( i = 0; srcElements[i]; ++i ) {
8375 // Ensure that the destination node is not null; Fixes #9587
8376 if ( destElements[i] ) {
8377 cloneFixAttributes( srcElements[i], destElements[i] );
8378 }
8379 }
8380 }
8381
8382 // Copy the events from the original to the clone
8383 if ( dataAndEvents ) {
8384 cloneCopyEvent( elem, clone );
8385
8386 if ( deepDataAndEvents ) {
8387 srcElements = getAll( elem );
8388 destElements = getAll( clone );
8389
8390 for ( i = 0; srcElements[i]; ++i ) {
8391 cloneCopyEvent( srcElements[i], destElements[i] );
8392 }
8393 }
8394 }
8395
8396 srcElements = destElements = null;
8397
8398 // Return the cloned set
8399 return clone;
8400 },
8401
8402 clean: function( elems, context, fragment, scripts ) {
8403 var checkScriptType, script, j,
8404 ret = [];
8405
8406 context = context || document;
8407
8408 // !context.createElement fails in IE with an error but returns typeof 'object'
8409 if ( typeof context.createElement === "undefined" ) {
8410 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
8411 }
8412
8413 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
8414 if ( typeof elem === "number" ) {
8415 elem += "";
8416 }
8417
8418 if ( !elem ) {
8419 continue;
8420 }
8421
8422 // Convert html string into DOM nodes
8423 if ( typeof elem === "string" ) {
8424 if ( !rhtml.test( elem ) ) {
8425 elem = context.createTextNode( elem );
8426 } else {
8427 // Fix "XHTML"-style tags in all browsers
8428 elem = elem.replace(rxhtmlTag, "<$1></$2>");
8429
8430 // Trim whitespace, otherwise indexOf won't work as expected
8431 var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
8432 wrap = wrapMap[ tag ] || wrapMap._default,
8433 depth = wrap[0],
8434 div = context.createElement("div"),
8435 safeChildNodes = safeFragment.childNodes,
8436 remove;
8437
8438 // Append wrapper element to unknown element safe doc fragment
8439 if ( context === document ) {
8440 // Use the fragment we've already created for this document
8441 safeFragment.appendChild( div );
8442 } else {
8443 // Use a fragment created with the owner document
8444 createSafeFragment( context ).appendChild( div );
8445 }
8446
8447 // Go to html and back, then peel off extra wrappers
8448 div.innerHTML = wrap[1] + elem + wrap[2];
8449
8450 // Move to the right depth
8451 while ( depth-- ) {
8452 div = div.lastChild;
8453 }
8454
8455 // Remove IE's autoinserted <tbody> from table fragments
8456 if ( !jQuery.support.tbody ) {
8457
8458 // String was a <table>, *may* have spurious <tbody>
8459 var hasBody = rtbody.test(elem),
8460 tbody = tag === "table" && !hasBody ?
8461 div.firstChild && div.firstChild.childNodes :
8462
8463 // String was a bare <thead> or <tfoot>
8464 wrap[1] === "<table>" && !hasBody ?
8465 div.childNodes :
8466 [];
8467
8468 for ( j = tbody.length - 1; j >= 0 ; --j ) {
8469 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
8470 tbody[ j ].parentNode.removeChild( tbody[ j ] );
8471 }
8472 }
8473 }
8474
8475 // IE completely kills leading whitespace when innerHTML is used
8476 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
8477 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
8478 }
8479
8480 elem = div.childNodes;
8481
8482 // Clear elements from DocumentFragment (safeFragment or otherwise)
8483 // to avoid hoarding elements. Fixes #11356
8484 if ( div ) {
8485 div.parentNode.removeChild( div );
8486
8487 // Guard against -1 index exceptions in FF3.6
8488 if ( safeChildNodes.length > 0 ) {
8489 remove = safeChildNodes[ safeChildNodes.length - 1 ];
8490
8491 if ( remove && remove.parentNode ) {
8492 remove.parentNode.removeChild( remove );
8493 }
8494 }
8495 }
8496 }
8497 }
8498
8499 // Resets defaultChecked for any radios and checkboxes
8500 // about to be appended to the DOM in IE 6/7 (#8060)
8501 var len;
8502 if ( !jQuery.support.appendChecked ) {
8503 if ( elem[0] && typeof (len = elem.length) === "number" ) {
8504 for ( j = 0; j < len; j++ ) {
8505 findInputs( elem[j] );
8506 }
8507 } else {
8508 findInputs( elem );
8509 }
8510 }
8511
8512 if ( elem.nodeType ) {
8513 ret.push( elem );
8514 } else {
8515 ret = jQuery.merge( ret, elem );
8516 }
8517 }
8518
8519 if ( fragment ) {
8520 checkScriptType = function( elem ) {
8521 return !elem.type || rscriptType.test( elem.type );
8522 };
8523 for ( i = 0; ret[i]; i++ ) {
8524 script = ret[i];
8525 if ( scripts && jQuery.nodeName( script, "script" ) && (!script.type || rscriptType.test( script.type )) ) {
8526 scripts.push( script.parentNode ? script.parentNode.removeChild( script ) : script );
8527
8528 } else {
8529 if ( script.nodeType === 1 ) {
8530 var jsTags = jQuery.grep( script.getElementsByTagName( "script" ), checkScriptType );
8531
8532 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
8533 }
8534 fragment.appendChild( script );
8535 }
8536 }
8537 }
8538
8539 return ret;
8540 },
8541
8542 cleanData: function( elems ) {
8543 var data, id,
8544 cache = jQuery.cache,
8545 special = jQuery.event.special,
8546 deleteExpando = jQuery.support.deleteExpando;
8547
8548 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
8549 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
8550 continue;
8551 }
8552
8553 id = elem[ jQuery.expando ];
8554
8555 if ( id ) {
8556 data = cache[ id ];
8557
8558 if ( data && data.events ) {
8559 for ( var type in data.events ) {
8560 if ( special[ type ] ) {
8561 jQuery.event.remove( elem, type );
8562
8563 // This is a shortcut to avoid jQuery.event.remove's overhead
8564 } else {
8565 jQuery.removeEvent( elem, type, data.handle );
8566 }
8567 }
8568
8569 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
8570 if ( data.handle ) {
8571 data.handle.elem = null;
8572 }
8573 }
8574
8575 if ( deleteExpando ) {
8576 delete elem[ jQuery.expando ];
8577
8578 } else if ( elem.removeAttribute ) {
8579 elem.removeAttribute( jQuery.expando );
8580 }
8581
8582 delete cache[ id ];
8583 }
8584 }
8585 }
8586});
8587
8588
8589
8590
8591var ralpha = /alpha\([^)]*\)/i,
8592 ropacity = /opacity=([^)]*)/,
8593 // fixed for IE9, see #8346
8594 rupper = /([A-Z]|^ms)/g,
8595 rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
8596 rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
8597 rrelNum = /^([\-+])=([\-+.\de]+)/,
8598 rmargin = /^margin/,
8599
8600 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
8601
8602 // order is important!
8603 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
8604
8605 curCSS,
8606
8607 getComputedStyle,
8608 currentStyle;
8609
8610jQuery.fn.css = function( name, value ) {
8611 return jQuery.access( this, function( elem, name, value ) {
8612 return value !== undefined ?
8613 jQuery.style( elem, name, value ) :
8614 jQuery.css( elem, name );
8615 }, name, value, arguments.length > 1 );
8616};
8617
8618jQuery.extend({
8619 // Add in style property hooks for overriding the default
8620 // behavior of getting and setting a style property
8621 cssHooks: {
8622 opacity: {
8623 get: function( elem, computed ) {
8624 if ( computed ) {
8625 // We should always get a number back from opacity
8626 var ret = curCSS( elem, "opacity" );
8627 return ret === "" ? "1" : ret;
8628
8629 } else {
8630 return elem.style.opacity;
8631 }
8632 }
8633 }
8634 },
8635
8636 // Exclude the following css properties to add px
8637 cssNumber: {
8638 "fillOpacity": true,
8639 "fontWeight": true,
8640 "lineHeight": true,
8641 "opacity": true,
8642 "orphans": true,
8643 "widows": true,
8644 "zIndex": true,
8645 "zoom": true
8646 },
8647
8648 // Add in properties whose names you wish to fix before
8649 // setting or getting the value
8650 cssProps: {
8651 // normalize float css property
8652 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
8653 },
8654
8655 // Get and set the style property on a DOM Node
8656 style: function( elem, name, value, extra ) {
8657 // Don't set styles on text and comment nodes
8658 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
8659 return;
8660 }
8661
8662 // Make sure that we're working with the right name
8663 var ret, type, origName = jQuery.camelCase( name ),
8664 style = elem.style, hooks = jQuery.cssHooks[ origName ];
8665
8666 name = jQuery.cssProps[ origName ] || origName;
8667
8668 // Check if we're setting a value
8669 if ( value !== undefined ) {
8670 type = typeof value;
8671
8672 // convert relative number strings (+= or -=) to relative numbers. #7345
8673 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
8674 value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
8675 // Fixes bug #9237
8676 type = "number";
8677 }
8678
8679 // Make sure that NaN and null values aren't set. See: #7116
8680 if ( value == null || type === "number" && isNaN( value ) ) {
8681 return;
8682 }
8683
8684 // If a number was passed in, add 'px' to the (except for certain CSS properties)
8685 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
8686 value += "px";
8687 }
8688
8689 // If a hook was provided, use that value, otherwise just set the specified value
8690 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
8691 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
8692 // Fixes bug #5509
8693 try {
8694 style[ name ] = value;
8695 } catch(e) {}
8696 }
8697
8698 } else {
8699 // If a hook was provided get the non-computed value from there
8700 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
8701 return ret;
8702 }
8703
8704 // Otherwise just get the value from the style object
8705 return style[ name ];
8706 }
8707 },
8708
8709 css: function( elem, name, extra ) {
8710 var ret, hooks;
8711
8712 // Make sure that we're working with the right name
8713 name = jQuery.camelCase( name );
8714 hooks = jQuery.cssHooks[ name ];
8715 name = jQuery.cssProps[ name ] || name;
8716
8717 // cssFloat needs a special treatment
8718 if ( name === "cssFloat" ) {
8719 name = "float";
8720 }
8721
8722 // If a hook was provided get the computed value from there
8723 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
8724 return ret;
8725
8726 // Otherwise, if a way to get the computed value exists, use that
8727 } else if ( curCSS ) {
8728 return curCSS( elem, name );
8729 }
8730 },
8731
8732 // A method for quickly swapping in/out CSS properties to get correct calculations
8733 swap: function( elem, options, callback ) {
8734 var old = {},
8735 ret, name;
8736
8737 // Remember the old values, and insert the new ones
8738 for ( name in options ) {
8739 old[ name ] = elem.style[ name ];
8740 elem.style[ name ] = options[ name ];
8741 }
8742
8743 ret = callback.call( elem );
8744
8745 // Revert the old values
8746 for ( name in options ) {
8747 elem.style[ name ] = old[ name ];
8748 }
8749
8750 return ret;
8751 }
8752});
8753
8754// DEPRECATED in 1.3, Use jQuery.css() instead
8755jQuery.curCSS = jQuery.css;
8756
8757if ( document.defaultView && document.defaultView.getComputedStyle ) {
8758 getComputedStyle = function( elem, name ) {
8759 var ret, defaultView, computedStyle, width,
8760 style = elem.style;
8761
8762 name = name.replace( rupper, "-$1" ).toLowerCase();
8763
8764 if ( (defaultView = elem.ownerDocument.defaultView) &&
8765 (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
8766
8767 ret = computedStyle.getPropertyValue( name );
8768 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
8769 ret = jQuery.style( elem, name );
8770 }
8771 }
8772
8773 // A tribute to the "awesome hack by Dean Edwards"
8774 // WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
8775 // which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
8776 if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) {
8777 width = style.width;
8778 style.width = ret;
8779 ret = computedStyle.width;
8780 style.width = width;
8781 }
8782
8783 return ret;
8784 };
8785}
8786
8787if ( document.documentElement.currentStyle ) {
8788 currentStyle = function( elem, name ) {
8789 var left, rsLeft, uncomputed,
8790 ret = elem.currentStyle && elem.currentStyle[ name ],
8791 style = elem.style;
8792
8793 // Avoid setting ret to empty string here
8794 // so we don't default to auto
8795 if ( ret == null && style && (uncomputed = style[ name ]) ) {
8796 ret = uncomputed;
8797 }
8798
8799 // From the awesome hack by Dean Edwards
8800 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
8801
8802 // If we're not dealing with a regular pixel number
8803 // but a number that has a weird ending, we need to convert it to pixels
8804 if ( rnumnonpx.test( ret ) ) {
8805
8806 // Remember the original values
8807 left = style.left;
8808 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
8809
8810 // Put in the new values to get a computed value out
8811 if ( rsLeft ) {
8812 elem.runtimeStyle.left = elem.currentStyle.left;
8813 }
8814 style.left = name === "fontSize" ? "1em" : ret;
8815 ret = style.pixelLeft + "px";
8816
8817 // Revert the changed values
8818 style.left = left;
8819 if ( rsLeft ) {
8820 elem.runtimeStyle.left = rsLeft;
8821 }
8822 }
8823
8824 return ret === "" ? "auto" : ret;
8825 };
8826}
8827
8828curCSS = getComputedStyle || currentStyle;
8829
8830function getWidthOrHeight( elem, name, extra ) {
8831
8832 // Start with offset property
8833 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
8834 i = name === "width" ? 1 : 0,
8835 len = 4;
8836
8837 if ( val > 0 ) {
8838 if ( extra !== "border" ) {
8839 for ( ; i < len; i += 2 ) {
8840 if ( !extra ) {
8841 val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
8842 }
8843 if ( extra === "margin" ) {
8844 val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
8845 } else {
8846 val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
8847 }
8848 }
8849 }
8850
8851 return val + "px";
8852 }
8853
8854 // Fall back to computed then uncomputed css if necessary
8855 val = curCSS( elem, name );
8856 if ( val < 0 || val == null ) {
8857 val = elem.style[ name ];
8858 }
8859
8860 // Computed unit is not pixels. Stop here and return.
8861 if ( rnumnonpx.test(val) ) {
8862 return val;
8863 }
8864
8865 // Normalize "", auto, and prepare for extra
8866 val = parseFloat( val ) || 0;
8867
8868 // Add padding, border, margin
8869 if ( extra ) {
8870 for ( ; i < len; i += 2 ) {
8871 val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
8872 if ( extra !== "padding" ) {
8873 val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
8874 }
8875 if ( extra === "margin" ) {
8876 val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
8877 }
8878 }
8879 }
8880
8881 return val + "px";
8882}
8883
8884jQuery.each([ "height", "width" ], function( i, name ) {
8885 jQuery.cssHooks[ name ] = {
8886 get: function( elem, computed, extra ) {
8887 if ( computed ) {
8888 if ( elem.offsetWidth !== 0 ) {
8889 return getWidthOrHeight( elem, name, extra );
8890 } else {
8891 return jQuery.swap( elem, cssShow, function() {
8892 return getWidthOrHeight( elem, name, extra );
8893 });
8894 }
8895 }
8896 },
8897
8898 set: function( elem, value ) {
8899 return rnum.test( value ) ?
8900 value + "px" :
8901 value;
8902 }
8903 };
8904});
8905
8906if ( !jQuery.support.opacity ) {
8907 jQuery.cssHooks.opacity = {
8908 get: function( elem, computed ) {
8909 // IE uses filters for opacity
8910 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
8911 ( parseFloat( RegExp.$1 ) / 100 ) + "" :
8912 computed ? "1" : "";
8913 },
8914
8915 set: function( elem, value ) {
8916 var style = elem.style,
8917 currentStyle = elem.currentStyle,
8918 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
8919 filter = currentStyle && currentStyle.filter || style.filter || "";
8920
8921 // IE has trouble with opacity if it does not have layout
8922 // Force it by setting the zoom level
8923 style.zoom = 1;
8924
8925 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
8926 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
8927
8928 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
8929 // if "filter:" is present at all, clearType is disabled, we want to avoid this
8930 // style.removeAttribute is IE Only, but so apparently is this code path...
8931 style.removeAttribute( "filter" );
8932
8933 // if there there is no filter style applied in a css rule, we are done
8934 if ( currentStyle && !currentStyle.filter ) {
8935 return;
8936 }
8937 }
8938
8939 // otherwise, set new filter values
8940 style.filter = ralpha.test( filter ) ?
8941 filter.replace( ralpha, opacity ) :
8942 filter + " " + opacity;
8943 }
8944 };
8945}
8946
8947jQuery(function() {
8948 // This hook cannot be added until DOM ready because the support test
8949 // for it is not run until after DOM ready
8950 if ( !jQuery.support.reliableMarginRight ) {
8951 jQuery.cssHooks.marginRight = {
8952 get: function( elem, computed ) {
8953 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
8954 // Work around by temporarily setting element display to inline-block
8955 return jQuery.swap( elem, { "display": "inline-block" }, function() {
8956 if ( computed ) {
8957 return curCSS( elem, "margin-right" );
8958 } else {
8959 return elem.style.marginRight;
8960 }
8961 });
8962 }
8963 };
8964 }
8965});
8966
8967if ( jQuery.expr && jQuery.expr.filters ) {
8968 jQuery.expr.filters.hidden = function( elem ) {
8969 var width = elem.offsetWidth,
8970 height = elem.offsetHeight;
8971
8972 return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
8973 };
8974
8975 jQuery.expr.filters.visible = function( elem ) {
8976 return !jQuery.expr.filters.hidden( elem );
8977 };
8978}
8979
8980// These hooks are used by animate to expand properties
8981jQuery.each({
8982 margin: "",
8983 padding: "",
8984 border: "Width"
8985}, function( prefix, suffix ) {
8986
8987 jQuery.cssHooks[ prefix + suffix ] = {
8988 expand: function( value ) {
8989 var i,
8990
8991 // assumes a single number if not a string
8992 parts = typeof value === "string" ? value.split(" ") : [ value ],
8993 expanded = {};
8994
8995 for ( i = 0; i < 4; i++ ) {
8996 expanded[ prefix + cssExpand[ i ] + suffix ] =
8997 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
8998 }
8999
9000 return expanded;
9001 }
9002 };
9003});
9004
9005
9006
9007
9008var r20 = /%20/g,
9009 rbracket = /\[\]$/,
9010 rCRLF = /\r?\n/g,
9011 rhash = /#.*$/,
9012 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
9013 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
9014 // #7653, #8125, #8152: local protocol detection
9015 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
9016 rnoContent = /^(?:GET|HEAD)$/,
9017 rprotocol = /^\/\//,
9018 rquery = /\?/,
9019 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
9020 rselectTextarea = /^(?:select|textarea)/i,
9021 rspacesAjax = /\s+/,
9022 rts = /([?&])_=[^&]*/,
9023 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
9024
9025 // Keep a copy of the old load method
9026 _load = jQuery.fn.load,
9027
9028 /* Prefilters
9029 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
9030 * 2) These are called:
9031 * - BEFORE asking for a transport
9032 * - AFTER param serialization (s.data is a string if s.processData is true)
9033 * 3) key is the dataType
9034 * 4) the catchall symbol "*" can be used
9035 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
9036 */
9037 prefilters = {},
9038
9039 /* Transports bindings
9040 * 1) key is the dataType
9041 * 2) the catchall symbol "*" can be used
9042 * 3) selection will start with transport dataType and THEN go to "*" if needed
9043 */
9044 transports = {},
9045
9046 // Document location
9047 ajaxLocation,
9048
9049 // Document location segments
9050 ajaxLocParts,
9051
9052 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
9053 allTypes = ["*/"] + ["*"];
9054
9055// #8138, IE may throw an exception when accessing
9056// a field from window.location if document.domain has been set
9057try {
9058 ajaxLocation = location.href;
9059} catch( e ) {
9060 // Use the href attribute of an A element
9061 // since IE will modify it given document.location
9062 ajaxLocation = document.createElement( "a" );
9063 ajaxLocation.href = "";
9064 ajaxLocation = ajaxLocation.href;
9065}
9066
9067// Segment location into parts
9068ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
9069
9070// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
9071function addToPrefiltersOrTransports( structure ) {
9072
9073 // dataTypeExpression is optional and defaults to "*"
9074 return function( dataTypeExpression, func ) {
9075
9076 if ( typeof dataTypeExpression !== "string" ) {
9077 func = dataTypeExpression;
9078 dataTypeExpression = "*";
9079 }
9080
9081 if ( jQuery.isFunction( func ) ) {
9082 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
9083 i = 0,
9084 length = dataTypes.length,
9085 dataType,
9086 list,
9087 placeBefore;
9088
9089 // For each dataType in the dataTypeExpression
9090 for ( ; i < length; i++ ) {
9091 dataType = dataTypes[ i ];
9092 // We control if we're asked to add before
9093 // any existing element
9094 placeBefore = /^\+/.test( dataType );
9095 if ( placeBefore ) {
9096 dataType = dataType.substr( 1 ) || "*";
9097 }
9098 list = structure[ dataType ] = structure[ dataType ] || [];
9099 // then we add to the structure accordingly
9100 list[ placeBefore ? "unshift" : "push" ]( func );
9101 }
9102 }
9103 };
9104}
9105
9106// Base inspection function for prefilters and transports
9107function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
9108 dataType /* internal */, inspected /* internal */ ) {
9109
9110 dataType = dataType || options.dataTypes[ 0 ];
9111 inspected = inspected || {};
9112
9113 inspected[ dataType ] = true;
9114
9115 var list = structure[ dataType ],
9116 i = 0,
9117 length = list ? list.length : 0,
9118 executeOnly = ( structure === prefilters ),
9119 selection;
9120
9121 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
9122 selection = list[ i ]( options, originalOptions, jqXHR );
9123 // If we got redirected to another dataType
9124 // we try there if executing only and not done already
9125 if ( typeof selection === "string" ) {
9126 if ( !executeOnly || inspected[ selection ] ) {
9127 selection = undefined;
9128 } else {
9129 options.dataTypes.unshift( selection );
9130 selection = inspectPrefiltersOrTransports(
9131 structure, options, originalOptions, jqXHR, selection, inspected );
9132 }
9133 }
9134 }
9135 // If we're only executing or nothing was selected
9136 // we try the catchall dataType if not done already
9137 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
9138 selection = inspectPrefiltersOrTransports(
9139 structure, options, originalOptions, jqXHR, "*", inspected );
9140 }
9141 // unnecessary when only executing (prefilters)
9142 // but it'll be ignored by the caller in that case
9143 return selection;
9144}
9145
9146// A special extend for ajax options
9147// that takes "flat" options (not to be deep extended)
9148// Fixes #9887
9149function ajaxExtend( target, src ) {
9150 var key, deep,
9151 flatOptions = jQuery.ajaxSettings.flatOptions || {};
9152 for ( key in src ) {
9153 if ( src[ key ] !== undefined ) {
9154 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
9155 }
9156 }
9157 if ( deep ) {
9158 jQuery.extend( true, target, deep );
9159 }
9160}
9161
9162jQuery.fn.extend({
9163 load: function( url, params, callback ) {
9164 if ( typeof url !== "string" && _load ) {
9165 return _load.apply( this, arguments );
9166
9167 // Don't do a request if no elements are being requested
9168 } else if ( !this.length ) {
9169 return this;
9170 }
9171
9172 var off = url.indexOf( " " );
9173 if ( off >= 0 ) {
9174 var selector = url.slice( off, url.length );
9175 url = url.slice( 0, off );
9176 }
9177
9178 // Default to a GET request
9179 var type = "GET";
9180
9181 // If the second parameter was provided
9182 if ( params ) {
9183 // If it's a function
9184 if ( jQuery.isFunction( params ) ) {
9185 // We assume that it's the callback
9186 callback = params;
9187 params = undefined;
9188
9189 // Otherwise, build a param string
9190 } else if ( typeof params === "object" ) {
9191 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
9192 type = "POST";
9193 }
9194 }
9195
9196 var self = this;
9197
9198 // Request the remote document
9199 jQuery.ajax({
9200 url: url,
9201 type: type,
9202 dataType: "html",
9203 data: params,
9204 // Complete callback (responseText is used internally)
9205 complete: function( jqXHR, status, responseText ) {
9206 // Store the response as specified by the jqXHR object
9207 responseText = jqXHR.responseText;
9208 // If successful, inject the HTML into all the matched elements
9209 if ( jqXHR.isResolved() ) {
9210 // #4825: Get the actual response in case
9211 // a dataFilter is present in ajaxSettings
9212 jqXHR.done(function( r ) {
9213 responseText = r;
9214 });
9215 // See if a selector was specified
9216 self.html( selector ?
9217 // Create a dummy div to hold the results
9218 jQuery("<div>")
9219 // inject the contents of the document in, removing the scripts
9220 // to avoid any 'Permission Denied' errors in IE
9221 .append(responseText.replace(rscript, ""))
9222
9223 // Locate the specified elements
9224 .find(selector) :
9225
9226 // If not, just inject the full result
9227 responseText );
9228 }
9229
9230 if ( callback ) {
9231 self.each( callback, [ responseText, status, jqXHR ] );
9232 }
9233 }
9234 });
9235
9236 return this;
9237 },
9238
9239 serialize: function() {
9240 return jQuery.param( this.serializeArray() );
9241 },
9242
9243 serializeArray: function() {
9244 return this.map(function(){
9245 return this.elements ? jQuery.makeArray( this.elements ) : this;
9246 })
9247 .filter(function(){
9248 return this.name && !this.disabled &&
9249 ( this.checked || rselectTextarea.test( this.nodeName ) ||
9250 rinput.test( this.type ) );
9251 })
9252 .map(function( i, elem ){
9253 var val = jQuery( this ).val();
9254
9255 return val == null ?
9256 null :
9257 jQuery.isArray( val ) ?
9258 jQuery.map( val, function( val, i ){
9259 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9260 }) :
9261 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9262 }).get();
9263 }
9264});
9265
9266// Attach a bunch of functions for handling common AJAX events
9267jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
9268 jQuery.fn[ o ] = function( f ){
9269 return this.on( o, f );
9270 };
9271});
9272
9273jQuery.each( [ "get", "post" ], function( i, method ) {
9274 jQuery[ method ] = function( url, data, callback, type ) {
9275 // shift arguments if data argument was omitted
9276 if ( jQuery.isFunction( data ) ) {
9277 type = type || callback;
9278 callback = data;
9279 data = undefined;
9280 }
9281
9282 return jQuery.ajax({
9283 type: method,
9284 url: url,
9285 data: data,
9286 success: callback,
9287 dataType: type
9288 });
9289 };
9290});
9291
9292jQuery.extend({
9293
9294 getScript: function( url, callback ) {
9295 return jQuery.get( url, undefined, callback, "script" );
9296 },
9297
9298 getJSON: function( url, data, callback ) {
9299 return jQuery.get( url, data, callback, "json" );
9300 },
9301
9302 // Creates a full fledged settings object into target
9303 // with both ajaxSettings and settings fields.
9304 // If target is omitted, writes into ajaxSettings.
9305 ajaxSetup: function( target, settings ) {
9306 if ( settings ) {
9307 // Building a settings object
9308 ajaxExtend( target, jQuery.ajaxSettings );
9309 } else {
9310 // Extending ajaxSettings
9311 settings = target;
9312 target = jQuery.ajaxSettings;
9313 }
9314 ajaxExtend( target, settings );
9315 return target;
9316 },
9317
9318 ajaxSettings: {
9319 url: ajaxLocation,
9320 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
9321 global: true,
9322 type: "GET",
9323 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
9324 processData: true,
9325 async: true,
9326 /*
9327 timeout: 0,
9328 data: null,
9329 dataType: null,
9330 username: null,
9331 password: null,
9332 cache: null,
9333 traditional: false,
9334 headers: {},
9335 */
9336
9337 accepts: {
9338 xml: "application/xml, text/xml",
9339 html: "text/html",
9340 text: "text/plain",
9341 json: "application/json, text/javascript",
9342 "*": allTypes
9343 },
9344
9345 contents: {
9346 xml: /xml/,
9347 html: /html/,
9348 json: /json/
9349 },
9350
9351 responseFields: {
9352 xml: "responseXML",
9353 text: "responseText"
9354 },
9355
9356 // List of data converters
9357 // 1) key format is "source_type destination_type" (a single space in-between)
9358 // 2) the catchall symbol "*" can be used for source_type
9359 converters: {
9360
9361 // Convert anything to text
9362 "* text": window.String,
9363
9364 // Text to html (true = no transformation)
9365 "text html": true,
9366
9367 // Evaluate text as a json expression
9368 "text json": jQuery.parseJSON,
9369
9370 // Parse text as xml
9371 "text xml": jQuery.parseXML
9372 },
9373
9374 // For options that shouldn't be deep extended:
9375 // you can add your own custom options here if
9376 // and when you create one that shouldn't be
9377 // deep extended (see ajaxExtend)
9378 flatOptions: {
9379 context: true,
9380 url: true
9381 }
9382 },
9383
9384 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
9385 ajaxTransport: addToPrefiltersOrTransports( transports ),
9386
9387 // Main method
9388 ajax: function( url, options ) {
9389
9390 // If url is an object, simulate pre-1.5 signature
9391 if ( typeof url === "object" ) {
9392 options = url;
9393 url = undefined;
9394 }
9395
9396 // Force options to be an object
9397 options = options || {};
9398
9399 var // Create the final options object
9400 s = jQuery.ajaxSetup( {}, options ),
9401 // Callbacks context
9402 callbackContext = s.context || s,
9403 // Context for global events
9404 // It's the callbackContext if one was provided in the options
9405 // and if it's a DOM node or a jQuery collection
9406 globalEventContext = callbackContext !== s &&
9407 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
9408 jQuery( callbackContext ) : jQuery.event,
9409 // Deferreds
9410 deferred = jQuery.Deferred(),
9411 completeDeferred = jQuery.Callbacks( "once memory" ),
9412 // Status-dependent callbacks
9413 statusCode = s.statusCode || {},
9414 // ifModified key
9415 ifModifiedKey,
9416 // Headers (they are sent all at once)
9417 requestHeaders = {},
9418 requestHeadersNames = {},
9419 // Response headers
9420 responseHeadersString,
9421 responseHeaders,
9422 // transport
9423 transport,
9424 // timeout handle
9425 timeoutTimer,
9426 // Cross-domain detection vars
9427 parts,
9428 // The jqXHR state
9429 state = 0,
9430 // To know if global events are to be dispatched
9431 fireGlobals,
9432 // Loop variable
9433 i,
9434 // Fake xhr
9435 jqXHR = {
9436
9437 readyState: 0,
9438
9439 // Caches the header
9440 setRequestHeader: function( name, value ) {
9441 if ( !state ) {
9442 var lname = name.toLowerCase();
9443 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
9444 requestHeaders[ name ] = value;
9445 }
9446 return this;
9447 },
9448
9449 // Raw string
9450 getAllResponseHeaders: function() {
9451 return state === 2 ? responseHeadersString : null;
9452 },
9453
9454 // Builds headers hashtable if needed
9455 getResponseHeader: function( key ) {
9456 var match;
9457 if ( state === 2 ) {
9458 if ( !responseHeaders ) {
9459 responseHeaders = {};
9460 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
9461 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
9462 }
9463 }
9464 match = responseHeaders[ key.toLowerCase() ];
9465 }
9466 return match === undefined ? null : match;
9467 },
9468
9469 // Overrides response content-type header
9470 overrideMimeType: function( type ) {
9471 if ( !state ) {
9472 s.mimeType = type;
9473 }
9474 return this;
9475 },
9476
9477 // Cancel the request
9478 abort: function( statusText ) {
9479 statusText = statusText || "abort";
9480 if ( transport ) {
9481 transport.abort( statusText );
9482 }
9483 done( 0, statusText );
9484 return this;
9485 }
9486 };
9487
9488 // Callback for when everything is done
9489 // It is defined here because jslint complains if it is declared
9490 // at the end of the function (which would be more logical and readable)
9491 function done( status, nativeStatusText, responses, headers ) {
9492
9493 // Called once
9494 if ( state === 2 ) {
9495 return;
9496 }
9497
9498 // State is "done" now
9499 state = 2;
9500
9501 // Clear timeout if it exists
9502 if ( timeoutTimer ) {
9503 clearTimeout( timeoutTimer );
9504 }
9505
9506 // Dereference transport for early garbage collection
9507 // (no matter how long the jqXHR object will be used)
9508 transport = undefined;
9509
9510 // Cache response headers
9511 responseHeadersString = headers || "";
9512
9513 // Set readyState
9514 jqXHR.readyState = status > 0 ? 4 : 0;
9515
9516 var isSuccess,
9517 success,
9518 error,
9519 statusText = nativeStatusText,
9520 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
9521 lastModified,
9522 etag;
9523
9524 // If successful, handle type chaining
9525 if ( status >= 200 && status < 300 || status === 304 ) {
9526
9527 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9528 if ( s.ifModified ) {
9529
9530 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
9531 jQuery.lastModified[ ifModifiedKey ] = lastModified;
9532 }
9533 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
9534 jQuery.etag[ ifModifiedKey ] = etag;
9535 }
9536 }
9537
9538 // If not modified
9539 if ( status === 304 ) {
9540
9541 statusText = "notmodified";
9542 isSuccess = true;
9543
9544 // If we have data
9545 } else {
9546
9547 try {
9548 success = ajaxConvert( s, response );
9549 statusText = "success";
9550 isSuccess = true;
9551 } catch(e) {
9552 // We have a parsererror
9553 statusText = "parsererror";
9554 error = e;
9555 }
9556 }
9557 } else {
9558 // We extract error from statusText
9559 // then normalize statusText and status for non-aborts
9560 error = statusText;
9561 if ( !statusText || status ) {
9562 statusText = "error";
9563 if ( status < 0 ) {
9564 status = 0;
9565 }
9566 }
9567 }
9568
9569 // Set data for the fake xhr object
9570 jqXHR.status = status;
9571 jqXHR.statusText = "" + ( nativeStatusText || statusText );
9572
9573 // Success/Error
9574 if ( isSuccess ) {
9575 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9576 } else {
9577 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9578 }
9579
9580 // Status-dependent callbacks
9581 jqXHR.statusCode( statusCode );
9582 statusCode = undefined;
9583
9584 if ( fireGlobals ) {
9585 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
9586 [ jqXHR, s, isSuccess ? success : error ] );
9587 }
9588
9589 // Complete
9590 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9591
9592 if ( fireGlobals ) {
9593 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9594 // Handle the global AJAX counter
9595 if ( !( --jQuery.active ) ) {
9596 jQuery.event.trigger( "ajaxStop" );
9597 }
9598 }
9599 }
9600
9601 // Attach deferreds
9602 deferred.promise( jqXHR );
9603 jqXHR.success = jqXHR.done;
9604 jqXHR.error = jqXHR.fail;
9605 jqXHR.complete = completeDeferred.add;
9606
9607 // Status-dependent callbacks
9608 jqXHR.statusCode = function( map ) {
9609 if ( map ) {
9610 var tmp;
9611 if ( state < 2 ) {
9612 for ( tmp in map ) {
9613 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
9614 }
9615 } else {
9616 tmp = map[ jqXHR.status ];
9617 jqXHR.then( tmp, tmp );
9618 }
9619 }
9620 return this;
9621 };
9622
9623 // Remove hash character (#7531: and string promotion)
9624 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
9625 // We also use the url parameter if available
9626 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
9627
9628 // Extract dataTypes list
9629 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
9630
9631 // Determine if a cross-domain request is in order
9632 if ( s.crossDomain == null ) {
9633 parts = rurl.exec( s.url.toLowerCase() );
9634 s.crossDomain = !!( parts &&
9635 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
9636 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
9637 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
9638 );
9639 }
9640
9641 // Convert data if not already a string
9642 if ( s.data && s.processData && typeof s.data !== "string" ) {
9643 s.data = jQuery.param( s.data, s.traditional );
9644 }
9645
9646 // Apply prefilters
9647 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9648
9649 // If request was aborted inside a prefilter, stop there
9650 if ( state === 2 ) {
9651 return false;
9652 }
9653
9654 // We can fire global events as of now if asked to
9655 fireGlobals = s.global;
9656
9657 // Uppercase the type
9658 s.type = s.type.toUpperCase();
9659
9660 // Determine if request has content
9661 s.hasContent = !rnoContent.test( s.type );
9662
9663 // Watch for a new set of requests
9664 if ( fireGlobals && jQuery.active++ === 0 ) {
9665 jQuery.event.trigger( "ajaxStart" );
9666 }
9667
9668 // More options handling for requests with no content
9669 if ( !s.hasContent ) {
9670
9671 // If data is available, append data to url
9672 if ( s.data ) {
9673 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
9674 // #9682: remove data so that it's not used in an eventual retry
9675 delete s.data;
9676 }
9677
9678 // Get ifModifiedKey before adding the anti-cache parameter
9679 ifModifiedKey = s.url;
9680
9681 // Add anti-cache in url if needed
9682 if ( s.cache === false ) {
9683
9684 var ts = jQuery.now(),
9685 // try replacing _= if it is there
9686 ret = s.url.replace( rts, "$1_=" + ts );
9687
9688 // if nothing was replaced, add timestamp to the end
9689 s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
9690 }
9691 }
9692
9693 // Set the correct header, if data is being sent
9694 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9695 jqXHR.setRequestHeader( "Content-Type", s.contentType );
9696 }
9697
9698 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9699 if ( s.ifModified ) {
9700 ifModifiedKey = ifModifiedKey || s.url;
9701 if ( jQuery.lastModified[ ifModifiedKey ] ) {
9702 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
9703 }
9704 if ( jQuery.etag[ ifModifiedKey ] ) {
9705 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
9706 }
9707 }
9708
9709 // Set the Accepts header for the server, depending on the dataType
9710 jqXHR.setRequestHeader(
9711 "Accept",
9712 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
9713 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9714 s.accepts[ "*" ]
9715 );
9716
9717 // Check for headers option
9718 for ( i in s.headers ) {
9719 jqXHR.setRequestHeader( i, s.headers[ i ] );
9720 }
9721
9722 // Allow custom headers/mimetypes and early abort
9723 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
9724 // Abort if not done already
9725 jqXHR.abort();
9726 return false;
9727
9728 }
9729
9730 // Install callbacks on deferreds
9731 for ( i in { success: 1, error: 1, complete: 1 } ) {
9732 jqXHR[ i ]( s[ i ] );
9733 }
9734
9735 // Get transport
9736 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9737
9738 // If no transport, we auto-abort
9739 if ( !transport ) {
9740 done( -1, "No Transport" );
9741 } else {
9742 jqXHR.readyState = 1;
9743 // Send global event
9744 if ( fireGlobals ) {
9745 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9746 }
9747 // Timeout
9748 if ( s.async && s.timeout > 0 ) {
9749 timeoutTimer = setTimeout( function(){
9750 jqXHR.abort( "timeout" );
9751 }, s.timeout );
9752 }
9753
9754 try {
9755 state = 1;
9756 transport.send( requestHeaders, done );
9757 } catch (e) {
9758 // Propagate exception as error if not done
9759 if ( state < 2 ) {
9760 done( -1, e );
9761 // Simply rethrow otherwise
9762 } else {
9763 throw e;
9764 }
9765 }
9766 }
9767
9768 return jqXHR;
9769 },
9770
9771 // Serialize an array of form elements or a set of
9772 // key/values into a query string
9773 param: function( a, traditional ) {
9774 var s = [],
9775 add = function( key, value ) {
9776 // If value is a function, invoke it and return its value
9777 value = jQuery.isFunction( value ) ? value() : value;
9778 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
9779 };
9780
9781 // Set traditional to true for jQuery <= 1.3.2 behavior.
9782 if ( traditional === undefined ) {
9783 traditional = jQuery.ajaxSettings.traditional;
9784 }
9785
9786 // If an array was passed in, assume that it is an array of form elements.
9787 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
9788 // Serialize the form elements
9789 jQuery.each( a, function() {
9790 add( this.name, this.value );
9791 });
9792
9793 } else {
9794 // If traditional, encode the "old" way (the way 1.3.2 or older
9795 // did it), otherwise encode params recursively.
9796 for ( var prefix in a ) {
9797 buildParams( prefix, a[ prefix ], traditional, add );
9798 }
9799 }
9800
9801 // Return the resulting serialization
9802 return s.join( "&" ).replace( r20, "+" );
9803 }
9804});
9805
9806function buildParams( prefix, obj, traditional, add ) {
9807 if ( jQuery.isArray( obj ) ) {
9808 // Serialize array item.
9809 jQuery.each( obj, function( i, v ) {
9810 if ( traditional || rbracket.test( prefix ) ) {
9811 // Treat each array item as a scalar.
9812 add( prefix, v );
9813
9814 } else {
9815 // If array item is non-scalar (array or object), encode its
9816 // numeric index to resolve deserialization ambiguity issues.
9817 // Note that rack (as of 1.0.0) can't currently deserialize
9818 // nested arrays properly, and attempting to do so may cause
9819 // a server error. Possible fixes are to modify rack's
9820 // deserialization algorithm or to provide an option or flag
9821 // to force array serialization to be shallow.
9822 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
9823 }
9824 });
9825
9826 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
9827 // Serialize object item.
9828 for ( var name in obj ) {
9829 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
9830 }
9831
9832 } else {
9833 // Serialize scalar item.
9834 add( prefix, obj );
9835 }
9836}
9837
9838// This is still on the jQuery object... for now
9839// Want to move this to jQuery.ajax some day
9840jQuery.extend({
9841
9842 // Counter for holding the number of active queries
9843 active: 0,
9844
9845 // Last-Modified header cache for next request
9846 lastModified: {},
9847 etag: {}
9848
9849});
9850
9851/* Handles responses to an ajax request:
9852 * - sets all responseXXX fields accordingly
9853 * - finds the right dataType (mediates between content-type and expected dataType)
9854 * - returns the corresponding response
9855 */
9856function ajaxHandleResponses( s, jqXHR, responses ) {
9857
9858 var contents = s.contents,
9859 dataTypes = s.dataTypes,
9860 responseFields = s.responseFields,
9861 ct,
9862 type,
9863 finalDataType,
9864 firstDataType;
9865
9866 // Fill responseXXX fields
9867 for ( type in responseFields ) {
9868 if ( type in responses ) {
9869 jqXHR[ responseFields[type] ] = responses[ type ];
9870 }
9871 }
9872
9873 // Remove auto dataType and get content-type in the process
9874 while( dataTypes[ 0 ] === "*" ) {
9875 dataTypes.shift();
9876 if ( ct === undefined ) {
9877 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
9878 }
9879 }
9880
9881 // Check if we're dealing with a known content-type
9882 if ( ct ) {
9883 for ( type in contents ) {
9884 if ( contents[ type ] && contents[ type ].test( ct ) ) {
9885 dataTypes.unshift( type );
9886 break;
9887 }
9888 }
9889 }
9890
9891 // Check to see if we have a response for the expected dataType
9892 if ( dataTypes[ 0 ] in responses ) {
9893 finalDataType = dataTypes[ 0 ];
9894 } else {
9895 // Try convertible dataTypes
9896 for ( type in responses ) {
9897 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
9898 finalDataType = type;
9899 break;
9900 }
9901 if ( !firstDataType ) {
9902 firstDataType = type;
9903 }
9904 }
9905 // Or just use first one
9906 finalDataType = finalDataType || firstDataType;
9907 }
9908
9909 // If we found a dataType
9910 // We add the dataType to the list if needed
9911 // and return the corresponding response
9912 if ( finalDataType ) {
9913 if ( finalDataType !== dataTypes[ 0 ] ) {
9914 dataTypes.unshift( finalDataType );
9915 }
9916 return responses[ finalDataType ];
9917 }
9918}
9919
9920// Chain conversions given the request and the original response
9921function ajaxConvert( s, response ) {
9922
9923 // Apply the dataFilter if provided
9924 if ( s.dataFilter ) {
9925 response = s.dataFilter( response, s.dataType );
9926 }
9927
9928 var dataTypes = s.dataTypes,
9929 converters = {},
9930 i,
9931 key,
9932 length = dataTypes.length,
9933 tmp,
9934 // Current and previous dataTypes
9935 current = dataTypes[ 0 ],
9936 prev,
9937 // Conversion expression
9938 conversion,
9939 // Conversion function
9940 conv,
9941 // Conversion functions (transitive conversion)
9942 conv1,
9943 conv2;
9944
9945 // For each dataType in the chain
9946 for ( i = 1; i < length; i++ ) {
9947
9948 // Create converters map
9949 // with lowercased keys
9950 if ( i === 1 ) {
9951 for ( key in s.converters ) {
9952 if ( typeof key === "string" ) {
9953 converters[ key.toLowerCase() ] = s.converters[ key ];
9954 }
9955 }
9956 }
9957
9958 // Get the dataTypes
9959 prev = current;
9960 current = dataTypes[ i ];
9961
9962 // If current is auto dataType, update it to prev
9963 if ( current === "*" ) {
9964 current = prev;
9965 // If no auto and dataTypes are actually different
9966 } else if ( prev !== "*" && prev !== current ) {
9967
9968 // Get the converter
9969 conversion = prev + " " + current;
9970 conv = converters[ conversion ] || converters[ "* " + current ];
9971
9972 // If there is no direct converter, search transitively
9973 if ( !conv ) {
9974 conv2 = undefined;
9975 for ( conv1 in converters ) {
9976 tmp = conv1.split( " " );
9977 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
9978 conv2 = converters[ tmp[1] + " " + current ];
9979 if ( conv2 ) {
9980 conv1 = converters[ conv1 ];
9981 if ( conv1 === true ) {
9982 conv = conv2;
9983 } else if ( conv2 === true ) {
9984 conv = conv1;
9985 }
9986 break;
9987 }
9988 }
9989 }
9990 }
9991 // If we found no converter, dispatch an error
9992 if ( !( conv || conv2 ) ) {
9993 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
9994 }
9995 // If found converter is not an equivalence
9996 if ( conv !== true ) {
9997 // Convert with 1 or 2 converters accordingly
9998 response = conv ? conv( response ) : conv2( conv1(response) );
9999 }
10000 }
10001 }
10002 return response;
10003}
10004
10005
10006
10007
10008var jsc = jQuery.now(),
10009 jsre = /(\=)\?(&|$)|\?\?/i;
10010
10011// Default jsonp settings
10012jQuery.ajaxSetup({
10013 jsonp: "callback",
10014 jsonpCallback: function() {
10015 return jQuery.expando + "_" + ( jsc++ );
10016 }
10017});
10018
10019// Detect, normalize options and install callbacks for jsonp requests
10020jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
10021
10022 var inspectData = ( typeof s.data === "string" ) && /^application\/x\-www\-form\-urlencoded/.test( s.contentType );
10023
10024 if ( s.dataTypes[ 0 ] === "jsonp" ||
10025 s.jsonp !== false && ( jsre.test( s.url ) ||
10026 inspectData && jsre.test( s.data ) ) ) {
10027
10028 var responseContainer,
10029 jsonpCallback = s.jsonpCallback =
10030 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
10031 previous = window[ jsonpCallback ],
10032 url = s.url,
10033 data = s.data,
10034 replace = "$1" + jsonpCallback + "$2";
10035
10036 if ( s.jsonp !== false ) {
10037 url = url.replace( jsre, replace );
10038 if ( s.url === url ) {
10039 if ( inspectData ) {
10040 data = data.replace( jsre, replace );
10041 }
10042 if ( s.data === data ) {
10043 // Add callback manually
10044 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
10045 }
10046 }
10047 }
10048
10049 s.url = url;
10050 s.data = data;
10051
10052 // Install callback
10053 window[ jsonpCallback ] = function( response ) {
10054 responseContainer = [ response ];
10055 };
10056
10057 // Clean-up function
10058 jqXHR.always(function() {
10059 // Set callback back to previous value
10060 window[ jsonpCallback ] = previous;
10061 // Call if it was a function and we have a response
10062 if ( responseContainer && jQuery.isFunction( previous ) ) {
10063 window[ jsonpCallback ]( responseContainer[ 0 ] );
10064 }
10065 });
10066
10067 // Use data converter to retrieve json after script execution
10068 s.converters["script json"] = function() {
10069 if ( !responseContainer ) {
10070 jQuery.error( jsonpCallback + " was not called" );
10071 }
10072 return responseContainer[ 0 ];
10073 };
10074
10075 // force json dataType
10076 s.dataTypes[ 0 ] = "json";
10077
10078 // Delegate to script
10079 return "script";
10080 }
10081});
10082
10083
10084
10085
10086// Install script dataType
10087jQuery.ajaxSetup({
10088 accepts: {
10089 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
10090 },
10091 contents: {
10092 script: /javascript|ecmascript/
10093 },
10094 converters: {
10095 "text script": function( text ) {
10096 jQuery.globalEval( text );
10097 return text;
10098 }
10099 }
10100});
10101
10102// Handle cache's special case and global
10103jQuery.ajaxPrefilter( "script", function( s ) {
10104 if ( s.cache === undefined ) {
10105 s.cache = false;
10106 }
10107 if ( s.crossDomain ) {
10108 s.type = "GET";
10109 s.global = false;
10110 }
10111});
10112
10113// Bind script tag hack transport
10114jQuery.ajaxTransport( "script", function(s) {
10115
10116 // This transport only deals with cross domain requests
10117 if ( s.crossDomain ) {
10118
10119 var script,
10120 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
10121
10122 return {
10123
10124 send: function( _, callback ) {
10125
10126 script = document.createElement( "script" );
10127
10128 script.async = "async";
10129
10130 if ( s.scriptCharset ) {
10131 script.charset = s.scriptCharset;
10132 }
10133
10134 script.src = s.url;
10135
10136 // Attach handlers for all browsers
10137 script.onload = script.onreadystatechange = function( _, isAbort ) {
10138
10139 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
10140
10141 // Handle memory leak in IE
10142 script.onload = script.onreadystatechange = null;
10143
10144 // Remove the script
10145 if ( head && script.parentNode ) {
10146 head.removeChild( script );
10147 }
10148
10149 // Dereference the script
10150 script = undefined;
10151
10152 // Callback if not abort
10153 if ( !isAbort ) {
10154 callback( 200, "success" );
10155 }
10156 }
10157 };
10158 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
10159 // This arises when a base node is used (#2709 and #4378).
10160 head.insertBefore( script, head.firstChild );
10161 },
10162
10163 abort: function() {
10164 if ( script ) {
10165 script.onload( 0, 1 );
10166 }
10167 }
10168 };
10169 }
10170});
10171
10172
10173
10174
10175var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
10176 xhrOnUnloadAbort = window.ActiveXObject ? function() {
10177 // Abort all pending requests
10178 for ( var key in xhrCallbacks ) {
10179 xhrCallbacks[ key ]( 0, 1 );
10180 }
10181 } : false,
10182 xhrId = 0,
10183 xhrCallbacks;
10184
10185// Functions to create xhrs
10186function createStandardXHR() {
10187 try {
10188 return new window.XMLHttpRequest();
10189 } catch( e ) {}
10190}
10191
10192function createActiveXHR() {
10193 try {
10194 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
10195 } catch( e ) {}
10196}
10197
10198// Create the request object
10199// (This is still attached to ajaxSettings for backward compatibility)
10200jQuery.ajaxSettings.xhr = window.ActiveXObject ?
10201 /* Microsoft failed to properly
10202 * implement the XMLHttpRequest in IE7 (can't request local files),
10203 * so we use the ActiveXObject when it is available
10204 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
10205 * we need a fallback.
10206 */
10207 function() {
10208 return !this.isLocal && createStandardXHR() || createActiveXHR();
10209 } :
10210 // For all other browsers, use the standard XMLHttpRequest object
10211 createStandardXHR;
10212
10213// Determine support properties
10214(function( xhr ) {
10215 jQuery.extend( jQuery.support, {
10216 ajax: !!xhr,
10217 cors: !!xhr && ( "withCredentials" in xhr )
10218 });
10219})( jQuery.ajaxSettings.xhr() );
10220
10221// Create transport if the browser can provide an xhr
10222if ( jQuery.support.ajax ) {
10223
10224 jQuery.ajaxTransport(function( s ) {
10225 // Cross domain only allowed if supported through XMLHttpRequest
10226 if ( !s.crossDomain || jQuery.support.cors ) {
10227
10228 var callback;
10229
10230 return {
10231 send: function( headers, complete ) {
10232
10233 // Get a new xhr
10234 var xhr = s.xhr(),
10235 handle,
10236 i;
10237
10238 // Open the socket
10239 // Passing null username, generates a login popup on Opera (#2865)
10240 if ( s.username ) {
10241 xhr.open( s.type, s.url, s.async, s.username, s.password );
10242 } else {
10243 xhr.open( s.type, s.url, s.async );
10244 }
10245
10246 // Apply custom fields if provided
10247 if ( s.xhrFields ) {
10248 for ( i in s.xhrFields ) {
10249 xhr[ i ] = s.xhrFields[ i ];
10250 }
10251 }
10252
10253 // Override mime type if needed
10254 if ( s.mimeType && xhr.overrideMimeType ) {
10255 xhr.overrideMimeType( s.mimeType );
10256 }
10257
10258 // X-Requested-With header
10259 // For cross-domain requests, seeing as conditions for a preflight are
10260 // akin to a jigsaw puzzle, we simply never set it to be sure.
10261 // (it can always be set on a per-request basis or even using ajaxSetup)
10262 // For same-domain requests, won't change header if already provided.
10263 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
10264 headers[ "X-Requested-With" ] = "XMLHttpRequest";
10265 }
10266
10267 // Need an extra try/catch for cross domain requests in Firefox 3
10268 try {
10269 for ( i in headers ) {
10270 xhr.setRequestHeader( i, headers[ i ] );
10271 }
10272 } catch( _ ) {}
10273
10274 // Do send the request
10275 // This may raise an exception which is actually
10276 // handled in jQuery.ajax (so no try/catch here)
10277 xhr.send( ( s.hasContent && s.data ) || null );
10278
10279 // Listener
10280 callback = function( _, isAbort ) {
10281
10282 var status,
10283 statusText,
10284 responseHeaders,
10285 responses,
10286 xml;
10287
10288 // Firefox throws exceptions when accessing properties
10289 // of an xhr when a network error occured
10290 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
10291 try {
10292
10293 // Was never called and is aborted or complete
10294 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
10295
10296 // Only called once
10297 callback = undefined;
10298
10299 // Do not keep as active anymore
10300 if ( handle ) {
10301 xhr.onreadystatechange = jQuery.noop;
10302 if ( xhrOnUnloadAbort ) {
10303 delete xhrCallbacks[ handle ];
10304 }
10305 }
10306
10307 // If it's an abort
10308 if ( isAbort ) {
10309 // Abort it manually if needed
10310 if ( xhr.readyState !== 4 ) {
10311 xhr.abort();
10312 }
10313 } else {
10314 status = xhr.status;
10315 responseHeaders = xhr.getAllResponseHeaders();
10316 responses = {};
10317 xml = xhr.responseXML;
10318
10319 // Construct response list
10320 if ( xml && xml.documentElement /* #4958 */ ) {
10321 responses.xml = xml;
10322 }
10323
10324 // When requesting binary data, IE6-9 will throw an exception
10325 // on any attempt to access responseText (#11426)
10326 try {
10327 responses.text = xhr.responseText;
10328 } catch( _ ) {
10329 }
10330
10331 // Firefox throws an exception when accessing
10332 // statusText for faulty cross-domain requests
10333 try {
10334 statusText = xhr.statusText;
10335 } catch( e ) {
10336 // We normalize with Webkit giving an empty statusText
10337 statusText = "";
10338 }
10339
10340 // Filter status for non standard behaviors
10341
10342 // If the request is local and we have data: assume a success
10343 // (success with no data won't get notified, that's the best we
10344 // can do given current implementations)
10345 if ( !status && s.isLocal && !s.crossDomain ) {
10346 status = responses.text ? 200 : 404;
10347 // IE - #1450: sometimes returns 1223 when it should be 204
10348 } else if ( status === 1223 ) {
10349 status = 204;
10350 }
10351 }
10352 }
10353 } catch( firefoxAccessException ) {
10354 if ( !isAbort ) {
10355 complete( -1, firefoxAccessException );
10356 }
10357 }
10358
10359 // Call complete if needed
10360 if ( responses ) {
10361 complete( status, statusText, responses, responseHeaders );
10362 }
10363 };
10364
10365 // if we're in sync mode or it's in cache
10366 // and has been retrieved directly (IE6 & IE7)
10367 // we need to manually fire the callback
10368 if ( !s.async || xhr.readyState === 4 ) {
10369 callback();
10370 } else {
10371 handle = ++xhrId;
10372 if ( xhrOnUnloadAbort ) {
10373 // Create the active xhrs callbacks list if needed
10374 // and attach the unload handler
10375 if ( !xhrCallbacks ) {
10376 xhrCallbacks = {};
10377 jQuery( window ).unload( xhrOnUnloadAbort );
10378 }
10379 // Add to list of active xhrs callbacks
10380 xhrCallbacks[ handle ] = callback;
10381 }
10382 xhr.onreadystatechange = callback;
10383 }
10384 },
10385
10386 abort: function() {
10387 if ( callback ) {
10388 callback(0,1);
10389 }
10390 }
10391 };
10392 }
10393 });
10394}
10395
10396
10397
10398
10399var elemdisplay = {},
10400 iframe, iframeDoc,
10401 rfxtypes = /^(?:toggle|show|hide)$/,
10402 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
10403 timerId,
10404 fxAttrs = [
10405 // height animations
10406 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
10407 // width animations
10408 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
10409 // opacity animations
10410 [ "opacity" ]
10411 ],
10412 fxNow;
10413
10414jQuery.fn.extend({
10415 show: function( speed, easing, callback ) {
10416 var elem, display;
10417
10418 if ( speed || speed === 0 ) {
10419 return this.animate( genFx("show", 3), speed, easing, callback );
10420
10421 } else {
10422 for ( var i = 0, j = this.length; i < j; i++ ) {
10423 elem = this[ i ];
10424
10425 if ( elem.style ) {
10426 display = elem.style.display;
10427
10428 // Reset the inline display of this element to learn if it is
10429 // being hidden by cascaded rules or not
10430 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
10431 display = elem.style.display = "";
10432 }
10433
10434 // Set elements which have been overridden with display: none
10435 // in a stylesheet to whatever the default browser style is
10436 // for such an element
10437 if ( (display === "" && jQuery.css(elem, "display") === "none") ||
10438 !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
10439 jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
10440 }
10441 }
10442 }
10443
10444 // Set the display of most of the elements in a second loop
10445 // to avoid the constant reflow
10446 for ( i = 0; i < j; i++ ) {
10447 elem = this[ i ];
10448
10449 if ( elem.style ) {
10450 display = elem.style.display;
10451
10452 if ( display === "" || display === "none" ) {
10453 elem.style.display = jQuery._data( elem, "olddisplay" ) || "";
10454 }
10455 }
10456 }
10457
10458 return this;
10459 }
10460 },
10461
10462 hide: function( speed, easing, callback ) {
10463 if ( speed || speed === 0 ) {
10464 return this.animate( genFx("hide", 3), speed, easing, callback);
10465
10466 } else {
10467 var elem, display,
10468 i = 0,
10469 j = this.length;
10470
10471 for ( ; i < j; i++ ) {
10472 elem = this[i];
10473 if ( elem.style ) {
10474 display = jQuery.css( elem, "display" );
10475
10476 if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
10477 jQuery._data( elem, "olddisplay", display );
10478 }
10479 }
10480 }
10481
10482 // Set the display of the elements in a second loop
10483 // to avoid the constant reflow
10484 for ( i = 0; i < j; i++ ) {
10485 if ( this[i].style ) {
10486 this[i].style.display = "none";
10487 }
10488 }
10489
10490 return this;
10491 }
10492 },
10493
10494 // Save the old toggle function
10495 _toggle: jQuery.fn.toggle,
10496
10497 toggle: function( fn, fn2, callback ) {
10498 var bool = typeof fn === "boolean";
10499
10500 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
10501 this._toggle.apply( this, arguments );
10502
10503 } else if ( fn == null || bool ) {
10504 this.each(function() {
10505 var state = bool ? fn : jQuery(this).is(":hidden");
10506 jQuery(this)[ state ? "show" : "hide" ]();
10507 });
10508
10509 } else {
10510 this.animate(genFx("toggle", 3), fn, fn2, callback);
10511 }
10512
10513 return this;
10514 },
10515
10516 fadeTo: function( speed, to, easing, callback ) {
10517 return this.filter(":hidden").css("opacity", 0).show().end()
10518 .animate({opacity: to}, speed, easing, callback);
10519 },
10520
10521 animate: function( prop, speed, easing, callback ) {
10522 var optall = jQuery.speed( speed, easing, callback );
10523
10524 if ( jQuery.isEmptyObject( prop ) ) {
10525 return this.each( optall.complete, [ false ] );
10526 }
10527
10528 // Do not change referenced properties as per-property easing will be lost
10529 prop = jQuery.extend( {}, prop );
10530
10531 function doAnimation() {
10532 // XXX 'this' does not always have a nodeName when running the
10533 // test suite
10534
10535 if ( optall.queue === false ) {
10536 jQuery._mark( this );
10537 }
10538
10539 var opt = jQuery.extend( {}, optall ),
10540 isElement = this.nodeType === 1,
10541 hidden = isElement && jQuery(this).is(":hidden"),
10542 name, val, p, e, hooks, replace,
10543 parts, start, end, unit,
10544 method;
10545
10546 // will store per property easing and be used to determine when an animation is complete
10547 opt.animatedProperties = {};
10548
10549 // first pass over propertys to expand / normalize
10550 for ( p in prop ) {
10551 name = jQuery.camelCase( p );
10552 if ( p !== name ) {
10553 prop[ name ] = prop[ p ];
10554 delete prop[ p ];
10555 }
10556
10557 if ( ( hooks = jQuery.cssHooks[ name ] ) && "expand" in hooks ) {
10558 replace = hooks.expand( prop[ name ] );
10559 delete prop[ name ];
10560
10561 // not quite $.extend, this wont overwrite keys already present.
10562 // also - reusing 'p' from above because we have the correct "name"
10563 for ( p in replace ) {
10564 if ( ! ( p in prop ) ) {
10565 prop[ p ] = replace[ p ];
10566 }
10567 }
10568 }
10569 }
10570
10571 for ( name in prop ) {
10572 val = prop[ name ];
10573 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
10574 if ( jQuery.isArray( val ) ) {
10575 opt.animatedProperties[ name ] = val[ 1 ];
10576 val = prop[ name ] = val[ 0 ];
10577 } else {
10578 opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
10579 }
10580
10581 if ( val === "hide" && hidden || val === "show" && !hidden ) {
10582 return opt.complete.call( this );
10583 }
10584
10585 if ( isElement && ( name === "height" || name === "width" ) ) {
10586 // Make sure that nothing sneaks out
10587 // Record all 3 overflow attributes because IE does not
10588 // change the overflow attribute when overflowX and
10589 // overflowY are set to the same value
10590 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
10591
10592 // Set display property to inline-block for height/width
10593 // animations on inline elements that are having width/height animated
10594 if ( jQuery.css( this, "display" ) === "inline" &&
10595 jQuery.css( this, "float" ) === "none" ) {
10596
10597 // inline-level elements accept inline-block;
10598 // block-level elements need to be inline with layout
10599 if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
10600 this.style.display = "inline-block";
10601
10602 } else {
10603 this.style.zoom = 1;
10604 }
10605 }
10606 }
10607 }
10608
10609 if ( opt.overflow != null ) {
10610 this.style.overflow = "hidden";
10611 }
10612
10613 for ( p in prop ) {
10614 e = new jQuery.fx( this, opt, p );
10615 val = prop[ p ];
10616
10617 if ( rfxtypes.test( val ) ) {
10618
10619 // Tracks whether to show or hide based on private
10620 // data attached to the element
10621 method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );
10622 if ( method ) {
10623 jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
10624 e[ method ]();
10625 } else {
10626 e[ val ]();
10627 }
10628
10629 } else {
10630 parts = rfxnum.exec( val );
10631 start = e.cur();
10632
10633 if ( parts ) {
10634 end = parseFloat( parts[2] );
10635 unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
10636
10637 // We need to compute starting value
10638 if ( unit !== "px" ) {
10639 jQuery.style( this, p, (end || 1) + unit);
10640 start = ( (end || 1) / e.cur() ) * start;
10641 jQuery.style( this, p, start + unit);
10642 }
10643
10644 // If a +=/-= token was provided, we're doing a relative animation
10645 if ( parts[1] ) {
10646 end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
10647 }
10648
10649 e.custom( start, end, unit );
10650
10651 } else {
10652 e.custom( start, val, "" );
10653 }
10654 }
10655 }
10656
10657 // For JS strict compliance
10658 return true;
10659 }
10660
10661 return optall.queue === false ?
10662 this.each( doAnimation ) :
10663 this.queue( optall.queue, doAnimation );
10664 },
10665
10666 stop: function( type, clearQueue, gotoEnd ) {
10667 if ( typeof type !== "string" ) {
10668 gotoEnd = clearQueue;
10669 clearQueue = type;
10670 type = undefined;
10671 }
10672 if ( clearQueue && type !== false ) {
10673 this.queue( type || "fx", [] );
10674 }
10675
10676 return this.each(function() {
10677 var index,
10678 hadTimers = false,
10679 timers = jQuery.timers,
10680 data = jQuery._data( this );
10681
10682 // clear marker counters if we know they won't be
10683 if ( !gotoEnd ) {
10684 jQuery._unmark( true, this );
10685 }
10686
10687 function stopQueue( elem, data, index ) {
10688 var hooks = data[ index ];
10689 jQuery.removeData( elem, index, true );
10690 hooks.stop( gotoEnd );
10691 }
10692
10693 if ( type == null ) {
10694 for ( index in data ) {
10695 if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {
10696 stopQueue( this, data, index );
10697 }
10698 }
10699 } else if ( data[ index = type + ".run" ] && data[ index ].stop ){
10700 stopQueue( this, data, index );
10701 }
10702
10703 for ( index = timers.length; index--; ) {
10704 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
10705 if ( gotoEnd ) {
10706
10707 // force the next step to be the last
10708 timers[ index ]( true );
10709 } else {
10710 timers[ index ].saveState();
10711 }
10712 hadTimers = true;
10713 timers.splice( index, 1 );
10714 }
10715 }
10716
10717 // start the next in the queue if the last step wasn't forced
10718 // timers currently will call their complete callbacks, which will dequeue
10719 // but only if they were gotoEnd
10720 if ( !( gotoEnd && hadTimers ) ) {
10721 jQuery.dequeue( this, type );
10722 }
10723 });
10724 }
10725
10726});
10727
10728// Animations created synchronously will run synchronously
10729function createFxNow() {
10730 setTimeout( clearFxNow, 0 );
10731 return ( fxNow = jQuery.now() );
10732}
10733
10734function clearFxNow() {
10735 fxNow = undefined;
10736}
10737
10738// Generate parameters to create a standard animation
10739function genFx( type, num ) {
10740 var obj = {};
10741
10742 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
10743 obj[ this ] = type;
10744 });
10745
10746 return obj;
10747}
10748
10749// Generate shortcuts for custom animations
10750jQuery.each({
10751 slideDown: genFx( "show", 1 ),
10752 slideUp: genFx( "hide", 1 ),
10753 slideToggle: genFx( "toggle", 1 ),
10754 fadeIn: { opacity: "show" },
10755 fadeOut: { opacity: "hide" },
10756 fadeToggle: { opacity: "toggle" }
10757}, function( name, props ) {
10758 jQuery.fn[ name ] = function( speed, easing, callback ) {
10759 return this.animate( props, speed, easing, callback );
10760 };
10761});
10762
10763jQuery.extend({
10764 speed: function( speed, easing, fn ) {
10765 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
10766 complete: fn || !fn && easing ||
10767 jQuery.isFunction( speed ) && speed,
10768 duration: speed,
10769 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
10770 };
10771
10772 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
10773 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
10774
10775 // normalize opt.queue - true/undefined/null -> "fx"
10776 if ( opt.queue == null || opt.queue === true ) {
10777 opt.queue = "fx";
10778 }
10779
10780 // Queueing
10781 opt.old = opt.complete;
10782
10783 opt.complete = function( noUnmark ) {
10784 if ( jQuery.isFunction( opt.old ) ) {
10785 opt.old.call( this );
10786 }
10787
10788 if ( opt.queue ) {
10789 jQuery.dequeue( this, opt.queue );
10790 } else if ( noUnmark !== false ) {
10791 jQuery._unmark( this );
10792 }
10793 };
10794
10795 return opt;
10796 },
10797
10798 easing: {
10799 linear: function( p ) {
10800 return p;
10801 },
10802 swing: function( p ) {
10803 return ( -Math.cos( p*Math.PI ) / 2 ) + 0.5;
10804 }
10805 },
10806
10807 timers: [],
10808
10809 fx: function( elem, options, prop ) {
10810 this.options = options;
10811 this.elem = elem;
10812 this.prop = prop;
10813
10814 options.orig = options.orig || {};
10815 }
10816
10817});
10818
10819jQuery.fx.prototype = {
10820 // Simple function for setting a style value
10821 update: function() {
10822 if ( this.options.step ) {
10823 this.options.step.call( this.elem, this.now, this );
10824 }
10825
10826 ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );
10827 },
10828
10829 // Get the current size
10830 cur: function() {
10831 if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
10832 return this.elem[ this.prop ];
10833 }
10834
10835 var parsed,
10836 r = jQuery.css( this.elem, this.prop );
10837 // Empty strings, null, undefined and "auto" are converted to 0,
10838 // complex values such as "rotate(1rad)" are returned as is,
10839 // simple values such as "10px" are parsed to Float.
10840 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
10841 },
10842
10843 // Start an animation from one number to another
10844 custom: function( from, to, unit ) {
10845 var self = this,
10846 fx = jQuery.fx;
10847
10848 this.startTime = fxNow || createFxNow();
10849 this.end = to;
10850 this.now = this.start = from;
10851 this.pos = this.state = 0;
10852 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
10853
10854 function t( gotoEnd ) {
10855 return self.step( gotoEnd );
10856 }
10857
10858 t.queue = this.options.queue;
10859 t.elem = this.elem;
10860 t.saveState = function() {
10861 if ( jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
10862 if ( self.options.hide ) {
10863 jQuery._data( self.elem, "fxshow" + self.prop, self.start );
10864 } else if ( self.options.show ) {
10865 jQuery._data( self.elem, "fxshow" + self.prop, self.end );
10866 }
10867 }
10868 };
10869
10870 if ( t() && jQuery.timers.push(t) && !timerId ) {
10871 timerId = setInterval( fx.tick, fx.interval );
10872 }
10873 },
10874
10875 // Simple 'show' function
10876 show: function() {
10877 var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
10878
10879 // Remember where we started, so that we can go back to it later
10880 this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
10881 this.options.show = true;
10882
10883 // Begin the animation
10884 // Make sure that we start at a small width/height to avoid any flash of content
10885 if ( dataShow !== undefined ) {
10886 // This show is picking up where a previous hide or show left off
10887 this.custom( this.cur(), dataShow );
10888 } else {
10889 this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
10890 }
10891
10892 // Start by showing the element
10893 jQuery( this.elem ).show();
10894 },
10895
10896 // Simple 'hide' function
10897 hide: function() {
10898 // Remember where we started, so that we can go back to it later
10899 this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
10900 this.options.hide = true;
10901
10902 // Begin the animation
10903 this.custom( this.cur(), 0 );
10904 },
10905
10906 // Each step of an animation
10907 step: function( gotoEnd ) {
10908 var p, n, complete,
10909 t = fxNow || createFxNow(),
10910 done = true,
10911 elem = this.elem,
10912 options = this.options;
10913
10914 if ( gotoEnd || t >= options.duration + this.startTime ) {
10915 this.now = this.end;
10916 this.pos = this.state = 1;
10917 this.update();
10918
10919 options.animatedProperties[ this.prop ] = true;
10920
10921 for ( p in options.animatedProperties ) {
10922 if ( options.animatedProperties[ p ] !== true ) {
10923 done = false;
10924 }
10925 }
10926
10927 if ( done ) {
10928 // Reset the overflow
10929 if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
10930
10931 jQuery.each( [ "", "X", "Y" ], function( index, value ) {
10932 elem.style[ "overflow" + value ] = options.overflow[ index ];
10933 });
10934 }
10935
10936 // Hide the element if the "hide" operation was done
10937 if ( options.hide ) {
10938 jQuery( elem ).hide();
10939 }
10940
10941 // Reset the properties, if the item has been hidden or shown
10942 if ( options.hide || options.show ) {
10943 for ( p in options.animatedProperties ) {
10944 jQuery.style( elem, p, options.orig[ p ] );
10945 jQuery.removeData( elem, "fxshow" + p, true );
10946 // Toggle data is no longer needed
10947 jQuery.removeData( elem, "toggle" + p, true );
10948 }
10949 }
10950
10951 // Execute the complete function
10952 // in the event that the complete function throws an exception
10953 // we must ensure it won't be called twice. #5684
10954
10955 complete = options.complete;
10956 if ( complete ) {
10957
10958 options.complete = false;
10959 complete.call( elem );
10960 }
10961 }
10962
10963 return false;
10964
10965 } else {
10966 // classical easing cannot be used with an Infinity duration
10967 if ( options.duration == Infinity ) {
10968 this.now = t;
10969 } else {
10970 n = t - this.startTime;
10971 this.state = n / options.duration;
10972
10973 // Perform the easing function, defaults to swing
10974 this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
10975 this.now = this.start + ( (this.end - this.start) * this.pos );
10976 }
10977 // Perform the next step of the animation
10978 this.update();
10979 }
10980
10981 return true;
10982 }
10983};
10984
10985jQuery.extend( jQuery.fx, {
10986 tick: function() {
10987 var timer,
10988 timers = jQuery.timers,
10989 i = 0;
10990
10991 for ( ; i < timers.length; i++ ) {
10992 timer = timers[ i ];
10993 // Checks the timer has not already been removed
10994 if ( !timer() && timers[ i ] === timer ) {
10995 timers.splice( i--, 1 );
10996 }
10997 }
10998
10999 if ( !timers.length ) {
11000 jQuery.fx.stop();
11001 }
11002 },
11003
11004 interval: 13,
11005
11006 stop: function() {
11007 clearInterval( timerId );
11008 timerId = null;
11009 },
11010
11011 speeds: {
11012 slow: 600,
11013 fast: 200,
11014 // Default speed
11015 _default: 400
11016 },
11017
11018 step: {
11019 opacity: function( fx ) {
11020 jQuery.style( fx.elem, "opacity", fx.now );
11021 },
11022
11023 _default: function( fx ) {
11024 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
11025 fx.elem.style[ fx.prop ] = fx.now + fx.unit;
11026 } else {
11027 fx.elem[ fx.prop ] = fx.now;
11028 }
11029 }
11030 }
11031});
11032
11033// Ensure props that can't be negative don't go there on undershoot easing
11034jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
11035 // exclude marginTop, marginLeft, marginBottom and marginRight from this list
11036 if ( prop.indexOf( "margin" ) ) {
11037 jQuery.fx.step[ prop ] = function( fx ) {
11038 jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
11039 };
11040 }
11041});
11042
11043if ( jQuery.expr && jQuery.expr.filters ) {
11044 jQuery.expr.filters.animated = function( elem ) {
11045 return jQuery.grep(jQuery.timers, function( fn ) {
11046 return elem === fn.elem;
11047 }).length;
11048 };
11049}
11050
11051// Try to restore the default display value of an element
11052function defaultDisplay( nodeName ) {
11053
11054 if ( !elemdisplay[ nodeName ] ) {
11055
11056 var body = document.body,
11057 elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
11058 display = elem.css( "display" );
11059 elem.remove();
11060
11061 // If the simple way fails,
11062 // get element's real default display by attaching it to a temp iframe
11063 if ( display === "none" || display === "" ) {
11064 // No iframe to use yet, so create it
11065 if ( !iframe ) {
11066 iframe = document.createElement( "iframe" );
11067 iframe.frameBorder = iframe.width = iframe.height = 0;
11068 }
11069
11070 body.appendChild( iframe );
11071
11072 // Create a cacheable copy of the iframe document on first call.
11073 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
11074 // document to it; WebKit & Firefox won't allow reusing the iframe document.
11075 if ( !iframeDoc || !iframe.createElement ) {
11076 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
11077 iframeDoc.write( ( jQuery.support.boxModel ? "<!doctype html>" : "" ) + "<html><body>" );
11078 iframeDoc.close();
11079 }
11080
11081 elem = iframeDoc.createElement( nodeName );
11082
11083 iframeDoc.body.appendChild( elem );
11084
11085 display = jQuery.css( elem, "display" );
11086 body.removeChild( iframe );
11087 }
11088
11089 // Store the correct default display
11090 elemdisplay[ nodeName ] = display;
11091 }
11092
11093 return elemdisplay[ nodeName ];
11094}
11095
11096
11097
11098
11099var getOffset,
11100 rtable = /^t(?:able|d|h)$/i,
11101 rroot = /^(?:body|html)$/i;
11102
11103if ( "getBoundingClientRect" in document.documentElement ) {
11104 getOffset = function( elem, doc, docElem, box ) {
11105 try {
11106 box = elem.getBoundingClientRect();
11107 } catch(e) {}
11108
11109 // Make sure we're not dealing with a disconnected DOM node
11110 if ( !box || !jQuery.contains( docElem, elem ) ) {
11111 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
11112 }
11113
11114 var body = doc.body,
11115 win = getWindow( doc ),
11116 clientTop = docElem.clientTop || body.clientTop || 0,
11117 clientLeft = docElem.clientLeft || body.clientLeft || 0,
11118 scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
11119 scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
11120 top = box.top + scrollTop - clientTop,
11121 left = box.left + scrollLeft - clientLeft;
11122
11123 return { top: top, left: left };
11124 };
11125
11126} else {
11127 getOffset = function( elem, doc, docElem ) {
11128 var computedStyle,
11129 offsetParent = elem.offsetParent,
11130 prevOffsetParent = elem,
11131 body = doc.body,
11132 defaultView = doc.defaultView,
11133 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
11134 top = elem.offsetTop,
11135 left = elem.offsetLeft;
11136
11137 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
11138 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
11139 break;
11140 }
11141
11142 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
11143 top -= elem.scrollTop;
11144 left -= elem.scrollLeft;
11145
11146 if ( elem === offsetParent ) {
11147 top += elem.offsetTop;
11148 left += elem.offsetLeft;
11149
11150 if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
11151 top += parseFloat( computedStyle.borderTopWidth ) || 0;
11152 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
11153 }
11154
11155 prevOffsetParent = offsetParent;
11156 offsetParent = elem.offsetParent;
11157 }
11158
11159 if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
11160 top += parseFloat( computedStyle.borderTopWidth ) || 0;
11161 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
11162 }
11163
11164 prevComputedStyle = computedStyle;
11165 }
11166
11167 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
11168 top += body.offsetTop;
11169 left += body.offsetLeft;
11170 }
11171
11172 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
11173 top += Math.max( docElem.scrollTop, body.scrollTop );
11174 left += Math.max( docElem.scrollLeft, body.scrollLeft );
11175 }
11176
11177 return { top: top, left: left };
11178 };
11179}
11180
11181jQuery.fn.offset = function( options ) {
11182 if ( arguments.length ) {
11183 return options === undefined ?
11184 this :
11185 this.each(function( i ) {
11186 jQuery.offset.setOffset( this, options, i );
11187 });
11188 }
11189
11190 var elem = this[0],
11191 doc = elem && elem.ownerDocument;
11192
11193 if ( !doc ) {
11194 return null;
11195 }
11196
11197 if ( elem === doc.body ) {
11198 return jQuery.offset.bodyOffset( elem );
11199 }
11200
11201 return getOffset( elem, doc, doc.documentElement );
11202};
11203
11204jQuery.offset = {
11205
11206 bodyOffset: function( body ) {
11207 var top = body.offsetTop,
11208 left = body.offsetLeft;
11209
11210 if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
11211 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
11212 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
11213 }
11214
11215 return { top: top, left: left };
11216 },
11217
11218 setOffset: function( elem, options, i ) {
11219 var position = jQuery.css( elem, "position" );
11220
11221 // set position first, in-case top/left are set even on static elem
11222 if ( position === "static" ) {
11223 elem.style.position = "relative";
11224 }
11225
11226 var curElem = jQuery( elem ),
11227 curOffset = curElem.offset(),
11228 curCSSTop = jQuery.css( elem, "top" ),
11229 curCSSLeft = jQuery.css( elem, "left" ),
11230 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
11231 props = {}, curPosition = {}, curTop, curLeft;
11232
11233 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
11234 if ( calculatePosition ) {
11235 curPosition = curElem.position();
11236 curTop = curPosition.top;
11237 curLeft = curPosition.left;
11238 } else {
11239 curTop = parseFloat( curCSSTop ) || 0;
11240 curLeft = parseFloat( curCSSLeft ) || 0;
11241 }
11242
11243 if ( jQuery.isFunction( options ) ) {
11244 options = options.call( elem, i, curOffset );
11245 }
11246
11247 if ( options.top != null ) {
11248 props.top = ( options.top - curOffset.top ) + curTop;
11249 }
11250 if ( options.left != null ) {
11251 props.left = ( options.left - curOffset.left ) + curLeft;
11252 }
11253
11254 if ( "using" in options ) {
11255 options.using.call( elem, props );
11256 } else {
11257 curElem.css( props );
11258 }
11259 }
11260};
11261
11262
11263jQuery.fn.extend({
11264
11265 position: function() {
11266 if ( !this[0] ) {
11267 return null;
11268 }
11269
11270 var elem = this[0],
11271
11272 // Get *real* offsetParent
11273 offsetParent = this.offsetParent(),
11274
11275 // Get correct offsets
11276 offset = this.offset(),
11277 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
11278
11279 // Subtract element margins
11280 // note: when an element has margin: auto the offsetLeft and marginLeft
11281 // are the same in Safari causing offset.left to incorrectly be 0
11282 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
11283 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
11284
11285 // Add offsetParent borders
11286 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
11287 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
11288
11289 // Subtract the two offsets
11290 return {
11291 top: offset.top - parentOffset.top,
11292 left: offset.left - parentOffset.left
11293 };
11294 },
11295
11296 offsetParent: function() {
11297 return this.map(function() {
11298 var offsetParent = this.offsetParent || document.body;
11299 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
11300 offsetParent = offsetParent.offsetParent;
11301 }
11302 return offsetParent;
11303 });
11304 }
11305});
11306
11307
11308// Create scrollLeft and scrollTop methods
11309jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
11310 var top = /Y/.test( prop );
11311
11312 jQuery.fn[ method ] = function( val ) {
11313 return jQuery.access( this, function( elem, method, val ) {
11314 var win = getWindow( elem );
11315
11316 if ( val === undefined ) {
11317 return win ? (prop in win) ? win[ prop ] :
11318 jQuery.support.boxModel && win.document.documentElement[ method ] ||
11319 win.document.body[ method ] :
11320 elem[ method ];
11321 }
11322
11323 if ( win ) {
11324 win.scrollTo(
11325 !top ? val : jQuery( win ).scrollLeft(),
11326 top ? val : jQuery( win ).scrollTop()
11327 );
11328
11329 } else {
11330 elem[ method ] = val;
11331 }
11332 }, method, val, arguments.length, null );
11333 };
11334});
11335
11336function getWindow( elem ) {
11337 return jQuery.isWindow( elem ) ?
11338 elem :
11339 elem.nodeType === 9 ?
11340 elem.defaultView || elem.parentWindow :
11341 false;
11342}
11343
11344
11345
11346
11347// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
11348jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
11349 var clientProp = "client" + name,
11350 scrollProp = "scroll" + name,
11351 offsetProp = "offset" + name;
11352
11353 // innerHeight and innerWidth
11354 jQuery.fn[ "inner" + name ] = function() {
11355 var elem = this[0];
11356 return elem ?
11357 elem.style ?
11358 parseFloat( jQuery.css( elem, type, "padding" ) ) :
11359 this[ type ]() :
11360 null;
11361 };
11362
11363 // outerHeight and outerWidth
11364 jQuery.fn[ "outer" + name ] = function( margin ) {
11365 var elem = this[0];
11366 return elem ?
11367 elem.style ?
11368 parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
11369 this[ type ]() :
11370 null;
11371 };
11372
11373 jQuery.fn[ type ] = function( value ) {
11374 return jQuery.access( this, function( elem, type, value ) {
11375 var doc, docElemProp, orig, ret;
11376
11377 if ( jQuery.isWindow( elem ) ) {
11378 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
11379 doc = elem.document;
11380 docElemProp = doc.documentElement[ clientProp ];
11381 return jQuery.support.boxModel && docElemProp ||
11382 doc.body && doc.body[ clientProp ] || docElemProp;
11383 }
11384
11385 // Get document width or height
11386 if ( elem.nodeType === 9 ) {
11387 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
11388 doc = elem.documentElement;
11389
11390 // when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height]
11391 // so we can't use max, as it'll choose the incorrect offset[Width/Height]
11392 // instead we use the correct client[Width/Height]
11393 // support:IE6
11394 if ( doc[ clientProp ] >= doc[ scrollProp ] ) {
11395 return doc[ clientProp ];
11396 }
11397
11398 return Math.max(
11399 elem.body[ scrollProp ], doc[ scrollProp ],
11400 elem.body[ offsetProp ], doc[ offsetProp ]
11401 );
11402 }
11403
11404 // Get width or height on the element
11405 if ( value === undefined ) {
11406 orig = jQuery.css( elem, type );
11407 ret = parseFloat( orig );
11408 return jQuery.isNumeric( ret ) ? ret : orig;
11409 }
11410
11411 // Set the width or height on the element
11412 jQuery( elem ).css( type, value );
11413 }, type, value, arguments.length, null );
11414 };
11415});
11416
11417
11418
11419
11420// Expose jQuery to the global object
11421window.jQuery = window.$ = jQuery;
11422
11423// Expose jQuery as an AMD module, but only for AMD loaders that
11424// understand the issues with loading multiple versions of jQuery
11425// in a page that all might call define(). The loader will indicate
11426// they have special allowances for multiple jQuery versions by
11427// specifying define.amd.jQuery = true. Register as a named module,
11428// since jQuery can be concatenated with other files that may use define,
11429// but not use a proper concatenation script that understands anonymous
11430// AMD modules. A named AMD is safest and most robust way to register.
11431// Lowercase jquery is used because AMD module names are derived from
11432// file names, and jQuery is normally delivered in a lowercase file name.
11433// Do this after creating the global so that if an AMD module wants to call
11434// noConflict to hide this version of jQuery, it will work.
11435if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
11436 define( "jquery", [], function () { return jQuery; } );
11437}
11438
11439
11440
11441})( window );