xf.li | e31de8b | 2023-12-26 23:38:58 -0800 | [diff] [blame^] | 1 | /** 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 |
|
| 9 | var 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 | * Includes Sizzle.js
|
| 2043 | * http://sizzlejs.com/
|
| 2044 | *
|
| 2045 | * Copyright jQuery Foundation, Inc. and other contributors
|
| 2046 | * Released under the MIT license
|
| 2047 | * http://jquery.org/license
|
| 2048 | *
|
| 2049 | * Date: NULL
|
| 2050 | */
|
| 2051 | (function( window, undefined ) {
|
| 2052 |
|
| 2053 | // Can't do this because several apps including ASP.NET trace
|
| 2054 | // the stack via arguments.caller.callee and Firefox dies if
|
| 2055 | // you try to trace through "use strict" call chains. (#13335)
|
| 2056 | // Support: Firefox 18+
|
| 2057 | //"use strict";
|
| 2058 | var
|
| 2059 | // The deferred used on DOM ready
|
| 2060 | readyList,
|
| 2061 |
|
| 2062 | // A central reference to the root jQuery(document)
|
| 2063 | rootjQuery,
|
| 2064 |
|
| 2065 | // Support: IE<10
|
| 2066 | // For `typeof xmlNode.method` instead of `xmlNode.method !== undefined`
|
| 2067 | core_strundefined = typeof undefined,
|
| 2068 |
|
| 2069 | // Use the correct document accordingly with window argument (sandbox)
|
| 2070 | location = window.location,
|
| 2071 | document = window.document,
|
| 2072 | docElem = document.documentElement,
|
| 2073 |
|
| 2074 | // Map over jQuery in case of overwrite
|
| 2075 | _jQuery = window.jQuery,
|
| 2076 |
|
| 2077 | // Map over the $ in case of overwrite
|
| 2078 | _$ = window.$,
|
| 2079 |
|
| 2080 | // [[Class]] -> type pairs
|
| 2081 | class2type = {},
|
| 2082 |
|
| 2083 | // List of deleted data cache ids, so we can reuse them
|
| 2084 | core_deletedIds = [],
|
| 2085 |
|
| 2086 | core_version = "0.0.0",
|
| 2087 |
|
| 2088 | // Save a reference to some core methods
|
| 2089 | core_concat = core_deletedIds.concat,
|
| 2090 | core_push = core_deletedIds.push,
|
| 2091 | core_slice = core_deletedIds.slice,
|
| 2092 | core_indexOf = core_deletedIds.indexOf,
|
| 2093 | core_toString = class2type.toString,
|
| 2094 | core_hasOwn = class2type.hasOwnProperty,
|
| 2095 | core_trim = core_version.trim,
|
| 2096 |
|
| 2097 | // Define a local copy of jQuery
|
| 2098 | jQuery = function( selector, context ) {
|
| 2099 | // The jQuery object is actually just the init constructor 'enhanced'
|
| 2100 | return new jQuery.fn.init( selector, context, rootjQuery );
|
| 2101 | },
|
| 2102 |
|
| 2103 | // Used for matching numbers
|
| 2104 | core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
|
| 2105 |
|
| 2106 | // Used for splitting on whitespace
|
| 2107 | core_rnotwhite = /\S+/g,
|
| 2108 |
|
| 2109 | // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
|
| 2110 | rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
| 2111 |
|
| 2112 | // A simple way to check for HTML strings
|
| 2113 | // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
|
| 2114 | // Strict HTML recognition (#11290: must start with <)
|
| 2115 | rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
|
| 2116 |
|
| 2117 | // Match a standalone tag
|
| 2118 | rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
|
| 2119 |
|
| 2120 | // JSON RegExp
|
| 2121 | rvalidchars = /^[\],:{}\s]*$/,
|
| 2122 | rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
|
| 2123 | rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
|
| 2124 | rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
|
| 2125 |
|
| 2126 | // Matches dashed string for camelizing
|
| 2127 | rmsPrefix = /^-ms-/,
|
| 2128 | rdashAlpha = /-([\da-z])/gi,
|
| 2129 |
|
| 2130 | // Used by jQuery.camelCase as callback to replace()
|
| 2131 | fcamelCase = function( all, letter ) {
|
| 2132 | return letter.toUpperCase();
|
| 2133 | },
|
| 2134 |
|
| 2135 | // The ready event handler
|
| 2136 | completed = function( event ) {
|
| 2137 |
|
| 2138 | // readyState === "complete" is good enough for us to call the dom ready in oldIE
|
| 2139 | if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
|
| 2140 | detach();
|
| 2141 | jQuery.ready();
|
| 2142 | }
|
| 2143 | },
|
| 2144 | // Clean-up method for dom ready events
|
| 2145 | detach = function() {
|
| 2146 | if ( document.addEventListener ) {
|
| 2147 | document.removeEventListener( "DOMContentLoaded", completed, false );
|
| 2148 | window.removeEventListener( "load", completed, false );
|
| 2149 |
|
| 2150 | } else {
|
| 2151 | document.detachEvent( "onreadystatechange", completed );
|
| 2152 | window.detachEvent( "onload", completed );
|
| 2153 | }
|
| 2154 | };
|
| 2155 |
|
| 2156 | jQuery.fn = jQuery.prototype = {
|
| 2157 | // The current version of jQuery being used
|
| 2158 | jquery: core_version,
|
| 2159 |
|
| 2160 | constructor: jQuery,
|
| 2161 | init: function( selector, context, rootjQuery ) {
|
| 2162 | var match, elem;
|
| 2163 |
|
| 2164 | // HANDLE: $(""), $(null), $(undefined), $(false)
|
| 2165 | if ( !selector ) {
|
| 2166 | return this;
|
| 2167 | }
|
| 2168 |
|
| 2169 | // Handle HTML strings
|
| 2170 | if ( typeof selector === "string" ) {
|
| 2171 | if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
|
| 2172 | // Assume that strings that start and end with <> are HTML and skip the regex check
|
| 2173 | match = [ null, selector, null ];
|
| 2174 |
|
| 2175 | } else {
|
| 2176 | match = rquickExpr.exec( selector );
|
| 2177 | }
|
| 2178 |
|
| 2179 | // Match html or make sure no context is specified for #id
|
| 2180 | if ( match && (match[1] || !context) ) {
|
| 2181 |
|
| 2182 | // HANDLE: $(html) -> $(array)
|
| 2183 | if ( match[1] ) {
|
| 2184 | context = context instanceof jQuery ? context[0] : context;
|
| 2185 |
|
| 2186 | // scripts is true for back-compat
|
| 2187 | jQuery.merge( this, jQuery.parseHTML(
|
| 2188 | match[1],
|
| 2189 | context && context.nodeType ? context.ownerDocument || context : document,
|
| 2190 | true
|
| 2191 | ) );
|
| 2192 |
|
| 2193 | // HANDLE: $(html, props)
|
| 2194 | if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
|
| 2195 | for ( match in context ) {
|
| 2196 | // Properties of context are called as methods if possible
|
| 2197 | if ( jQuery.isFunction( this[ match ] ) ) {
|
| 2198 | this[ match ]( context[ match ] );
|
| 2199 |
|
| 2200 | // ...and otherwise set as attributes
|
| 2201 | } else {
|
| 2202 | this.attr( match, context[ match ] );
|
| 2203 | }
|
| 2204 | }
|
| 2205 | }
|
| 2206 |
|
| 2207 | return this;
|
| 2208 |
|
| 2209 | // HANDLE: $(#id)
|
| 2210 | } else {
|
| 2211 | elem = document.getElementById( match[2] );
|
| 2212 |
|
| 2213 | // Check parentNode to catch when Blackberry 4.6 returns
|
| 2214 | // nodes that are no longer in the document #6963
|
| 2215 | if ( elem && elem.parentNode ) {
|
| 2216 | // Handle the case where IE and Opera return items
|
| 2217 | // by name instead of ID
|
| 2218 | if ( elem.id !== match[2] ) {
|
| 2219 | return rootjQuery.find( selector );
|
| 2220 | }
|
| 2221 |
|
| 2222 | // Otherwise, we inject the element directly into the jQuery object
|
| 2223 | this.length = 1;
|
| 2224 | this[0] = elem;
|
| 2225 | }
|
| 2226 |
|
| 2227 | this.context = document;
|
| 2228 | this.selector = selector;
|
| 2229 | return this;
|
| 2230 | }
|
| 2231 |
|
| 2232 | // HANDLE: $(expr, $(...))
|
| 2233 | } else if ( !context || context.jquery ) {
|
| 2234 | return ( context || rootjQuery ).find( selector );
|
| 2235 |
|
| 2236 | // HANDLE: $(expr, context)
|
| 2237 | // (which is just equivalent to: $(context).find(expr)
|
| 2238 | } else {
|
| 2239 | return this.constructor( context ).find( selector );
|
| 2240 | }
|
| 2241 |
|
| 2242 | // HANDLE: $(DOMElement)
|
| 2243 | } else if ( selector.nodeType ) {
|
| 2244 | this.context = this[0] = selector;
|
| 2245 | this.length = 1;
|
| 2246 | return this;
|
| 2247 |
|
| 2248 | // HANDLE: $(function)
|
| 2249 | // Shortcut for document ready
|
| 2250 | } else if ( jQuery.isFunction( selector ) ) {
|
| 2251 | return rootjQuery.ready( selector );
|
| 2252 | }
|
| 2253 |
|
| 2254 | if ( selector.selector !== undefined ) {
|
| 2255 | this.selector = selector.selector;
|
| 2256 | this.context = selector.context;
|
| 2257 | }
|
| 2258 |
|
| 2259 | return jQuery.makeArray( selector, this );
|
| 2260 | },
|
| 2261 |
|
| 2262 | // Start with an empty selector
|
| 2263 | selector: "",
|
| 2264 |
|
| 2265 | // The default length of a jQuery object is 0
|
| 2266 | length: 0,
|
| 2267 |
|
| 2268 | toArray: function() {
|
| 2269 | return core_slice.call( this );
|
| 2270 | },
|
| 2271 |
|
| 2272 | // Get the Nth element in the matched element set OR
|
| 2273 | // Get the whole matched element set as a clean array
|
| 2274 | get: function( num ) {
|
| 2275 | return num == null ?
|
| 2276 |
|
| 2277 | // Return a 'clean' array
|
| 2278 | this.toArray() :
|
| 2279 |
|
| 2280 | // Return just the object
|
| 2281 | ( num < 0 ? this[ this.length + num ] : this[ num ] );
|
| 2282 | },
|
| 2283 |
|
| 2284 | // Take an array of elements and push it onto the stack
|
| 2285 | // (returning the new matched element set)
|
| 2286 | pushStack: function( elems ) {
|
| 2287 |
|
| 2288 | // Build a new jQuery matched element set
|
| 2289 | var ret = jQuery.merge( this.constructor(), elems );
|
| 2290 |
|
| 2291 | // Add the old object onto the stack (as a reference)
|
| 2292 | ret.prevObject = this;
|
| 2293 | ret.context = this.context;
|
| 2294 |
|
| 2295 | // Return the newly-formed element set
|
| 2296 | return ret;
|
| 2297 | },
|
| 2298 |
|
| 2299 | // Execute a callback for every element in the matched set.
|
| 2300 | // (You can seed the arguments with an array of args, but this is
|
| 2301 | // only used internally.)
|
| 2302 | each: function( callback, args ) {
|
| 2303 | return jQuery.each( this, callback, args );
|
| 2304 | },
|
| 2305 |
|
| 2306 | ready: function( fn ) {
|
| 2307 | // Add the callback
|
| 2308 | jQuery.ready.promise().done( fn );
|
| 2309 |
|
| 2310 | return this;
|
| 2311 | },
|
| 2312 |
|
| 2313 | slice: function() {
|
| 2314 | return this.pushStack( core_slice.apply( this, arguments ) );
|
| 2315 | },
|
| 2316 |
|
| 2317 | first: function() {
|
| 2318 | return this.eq( 0 );
|
| 2319 | },
|
| 2320 |
|
| 2321 | last: function() {
|
| 2322 | return this.eq( -1 );
|
| 2323 | },
|
| 2324 |
|
| 2325 | eq: function( i ) {
|
| 2326 | var len = this.length,
|
| 2327 | j = +i + ( i < 0 ? len : 0 );
|
| 2328 | return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
|
| 2329 | },
|
| 2330 |
|
| 2331 | map: function( callback ) {
|
| 2332 | return this.pushStack( jQuery.map(this, function( elem, i ) {
|
| 2333 | return callback.call( elem, i, elem );
|
| 2334 | }));
|
| 2335 | },
|
| 2336 |
|
| 2337 | end: function() {
|
| 2338 | return this.prevObject || this.constructor(null);
|
| 2339 | },
|
| 2340 |
|
| 2341 | // For internal use only.
|
| 2342 | // Behaves like an Array's method, not like a jQuery method.
|
| 2343 | push: core_push,
|
| 2344 | sort: [].sort,
|
| 2345 | splice: [].splice
|
| 2346 | };
|
| 2347 |
|
| 2348 | // Give the init function the jQuery prototype for later instantiation
|
| 2349 | jQuery.fn.init.prototype = jQuery.fn;
|
| 2350 |
|
| 2351 | jQuery.extend = jQuery.fn.extend = function() {
|
| 2352 | var src, copyIsArray, copy, name, options, clone,
|
| 2353 | target = arguments[0] || {},
|
| 2354 | i = 1,
|
| 2355 | length = arguments.length,
|
| 2356 | deep = false;
|
| 2357 |
|
| 2358 | // Handle a deep copy situation
|
| 2359 | if ( typeof target === "boolean" ) {
|
| 2360 | deep = target;
|
| 2361 | target = arguments[1] || {};
|
| 2362 | // skip the boolean and the target
|
| 2363 | i = 2;
|
| 2364 | }
|
| 2365 |
|
| 2366 | // Handle case when target is a string or something (possible in deep copy)
|
| 2367 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
| 2368 | target = {};
|
| 2369 | }
|
| 2370 |
|
| 2371 | // extend jQuery itself if only one argument is passed
|
| 2372 | if ( length === i ) {
|
| 2373 | target = this;
|
| 2374 | --i;
|
| 2375 | }
|
| 2376 |
|
| 2377 | for ( ; i < length; i++ ) {
|
| 2378 | // Only deal with non-null/undefined values
|
| 2379 | if ( (options = arguments[ i ]) != null ) {
|
| 2380 | // Extend the base object
|
| 2381 | for ( name in options ) {
|
| 2382 | src = target[ name ];
|
| 2383 | copy = options[ name ];
|
| 2384 |
|
| 2385 | // Prevent never-ending loop
|
| 2386 | if ( target === copy ) {
|
| 2387 | continue;
|
| 2388 | }
|
| 2389 |
|
| 2390 | // Recurse if we're merging plain objects or arrays
|
| 2391 | if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
| 2392 | if ( copyIsArray ) {
|
| 2393 | copyIsArray = false;
|
| 2394 | clone = src && jQuery.isArray(src) ? src : [];
|
| 2395 |
|
| 2396 | } else {
|
| 2397 | clone = src && jQuery.isPlainObject(src) ? src : {};
|
| 2398 | }
|
| 2399 |
|
| 2400 | // Never move original objects, clone them
|
| 2401 | target[ name ] = jQuery.extend( deep, clone, copy );
|
| 2402 |
|
| 2403 | // Don't bring in undefined values
|
| 2404 | } else if ( copy !== undefined ) {
|
| 2405 | target[ name ] = copy;
|
| 2406 | }
|
| 2407 | }
|
| 2408 | }
|
| 2409 | }
|
| 2410 |
|
| 2411 | // Return the modified object
|
| 2412 | return target;
|
| 2413 | };
|
| 2414 |
|
| 2415 | jQuery.extend({
|
| 2416 | // Unique for each copy of jQuery on the page
|
| 2417 | // Non-digits removed to match rinlinejQuery
|
| 2418 | expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
|
| 2419 |
|
| 2420 | noConflict: function( deep ) {
|
| 2421 | if ( window.$ === jQuery ) {
|
| 2422 | window.$ = _$;
|
| 2423 | }
|
| 2424 |
|
| 2425 | if ( deep && window.jQuery === jQuery ) {
|
| 2426 | window.jQuery = _jQuery;
|
| 2427 | }
|
| 2428 |
|
| 2429 | return jQuery;
|
| 2430 | },
|
| 2431 |
|
| 2432 | // Is the DOM ready to be used? Set to true once it occurs.
|
| 2433 | isReady: false,
|
| 2434 |
|
| 2435 | // A counter to track how many items to wait for before
|
| 2436 | // the ready event fires. See #6781
|
| 2437 | readyWait: 1,
|
| 2438 |
|
| 2439 | // Hold (or release) the ready event
|
| 2440 | holdReady: function( hold ) {
|
| 2441 | if ( hold ) {
|
| 2442 | jQuery.readyWait++;
|
| 2443 | } else {
|
| 2444 | jQuery.ready( true );
|
| 2445 | }
|
| 2446 | },
|
| 2447 |
|
| 2448 | // Handle when the DOM is ready
|
| 2449 | ready: function( wait ) {
|
| 2450 |
|
| 2451 | // Abort if there are pending holds or we're already ready
|
| 2452 | if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
|
| 2453 | return;
|
| 2454 | }
|
| 2455 |
|
| 2456 | // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
| 2457 | if ( !document.body ) {
|
| 2458 | return setTimeout( jQuery.ready );
|
| 2459 | }
|
| 2460 |
|
| 2461 | // Remember that the DOM is ready
|
| 2462 | jQuery.isReady = true;
|
| 2463 |
|
| 2464 | // If a normal DOM Ready event fired, decrement, and wait if need be
|
| 2465 | if ( wait !== true && --jQuery.readyWait > 0 ) {
|
| 2466 | return;
|
| 2467 | }
|
| 2468 |
|
| 2469 | // If there are functions bound, to execute
|
| 2470 | readyList.resolveWith( document, [ jQuery ] );
|
| 2471 |
|
| 2472 | // Trigger any bound ready events
|
| 2473 | if ( jQuery.fn.trigger ) {
|
| 2474 | jQuery( document ).trigger("ready").off("ready");
|
| 2475 | }
|
| 2476 | },
|
| 2477 |
|
| 2478 | // See test/unit/core.js for details concerning isFunction.
|
| 2479 | // Since version 1.3, DOM methods and functions like alert
|
| 2480 | // aren't supported. They return false on IE (#2968).
|
| 2481 | isFunction: function( obj ) {
|
| 2482 | return jQuery.type(obj) === "function";
|
| 2483 | },
|
| 2484 |
|
| 2485 | isArray: Array.isArray || function( obj ) {
|
| 2486 | return jQuery.type(obj) === "array";
|
| 2487 | },
|
| 2488 |
|
| 2489 | isWindow: function( obj ) {
|
| 2490 | /* jshint eqeqeq: false */
|
| 2491 | return obj != null && obj == obj.window;
|
| 2492 | },
|
| 2493 |
|
| 2494 | isNumeric: function( obj ) {
|
| 2495 | return !isNaN( parseFloat(obj) ) && isFinite( obj );
|
| 2496 | },
|
| 2497 |
|
| 2498 | type: function( obj ) {
|
| 2499 | if ( obj == null ) {
|
| 2500 | return String( obj );
|
| 2501 | }
|
| 2502 | return typeof obj === "object" || typeof obj === "function" ?
|
| 2503 | class2type[ core_toString.call(obj) ] || "object" :
|
| 2504 | typeof obj;
|
| 2505 | },
|
| 2506 |
|
| 2507 | isPlainObject: function( obj ) {
|
| 2508 | var key;
|
| 2509 |
|
| 2510 | // Must be an Object.
|
| 2511 | // Because of IE, we also have to check the presence of the constructor property.
|
| 2512 | // Make sure that DOM nodes and window objects don't pass through, as well
|
| 2513 | if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
| 2514 | return false;
|
| 2515 | }
|
| 2516 |
|
| 2517 | try {
|
| 2518 | // Not own constructor property must be Object
|
| 2519 | if ( obj.constructor &&
|
| 2520 | !core_hasOwn.call(obj, "constructor") &&
|
| 2521 | !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
|
| 2522 | return false;
|
| 2523 | }
|
| 2524 | } catch ( e ) {
|
| 2525 | // IE8,9 Will throw exceptions on certain host objects #9897
|
| 2526 | return false;
|
| 2527 | }
|
| 2528 |
|
| 2529 | // Support: IE<9
|
| 2530 | // Handle iteration over inherited properties before own properties.
|
| 2531 | if ( jQuery.support.ownLast ) {
|
| 2532 | for ( key in obj ) {
|
| 2533 | return core_hasOwn.call( obj, key );
|
| 2534 | }
|
| 2535 | }
|
| 2536 |
|
| 2537 | // Own properties are enumerated firstly, so to speed up,
|
| 2538 | // if last one is own, then all properties are own.
|
| 2539 | for ( key in obj ) {}
|
| 2540 |
|
| 2541 | return key === undefined || core_hasOwn.call( obj, key );
|
| 2542 | },
|
| 2543 |
|
| 2544 | isEmptyObject: function( obj ) {
|
| 2545 | var name;
|
| 2546 | for ( name in obj ) {
|
| 2547 | return false;
|
| 2548 | }
|
| 2549 | return true;
|
| 2550 | },
|
| 2551 |
|
| 2552 | error: function( msg ) {
|
| 2553 | throw new Error( msg );
|
| 2554 | },
|
| 2555 |
|
| 2556 | // data: string of html
|
| 2557 | // context (optional): If specified, the fragment will be created in this context, defaults to document
|
| 2558 | // keepScripts (optional): If true, will include scripts passed in the html string
|
| 2559 | parseHTML: function( data, context, keepScripts ) {
|
| 2560 | if ( !data || typeof data !== "string" ) {
|
| 2561 | return null;
|
| 2562 | }
|
| 2563 | if ( typeof context === "boolean" ) {
|
| 2564 | keepScripts = context;
|
| 2565 | context = false;
|
| 2566 | }
|
| 2567 | context = context || document;
|
| 2568 |
|
| 2569 | var parsed = rsingleTag.exec( data ),
|
| 2570 | scripts = !keepScripts && [];
|
| 2571 |
|
| 2572 | // Single tag
|
| 2573 | if ( parsed ) {
|
| 2574 | return [ context.createElement( parsed[1] ) ];
|
| 2575 | }
|
| 2576 |
|
| 2577 | parsed = jQuery.buildFragment( [ data ], context, scripts );
|
| 2578 | if ( scripts ) {
|
| 2579 | jQuery( scripts ).remove();
|
| 2580 | }
|
| 2581 | return jQuery.merge( [], parsed.childNodes );
|
| 2582 | },
|
| 2583 |
|
| 2584 | parseJSON: function( data ) {
|
| 2585 | // Attempt to parse using the native JSON parser first
|
| 2586 | if ( window.JSON && window.JSON.parse ) {
|
| 2587 | return window.JSON.parse( data );
|
| 2588 | }
|
| 2589 |
|
| 2590 | if ( data === null ) {
|
| 2591 | return data;
|
| 2592 | }
|
| 2593 |
|
| 2594 | if ( typeof data === "string" ) {
|
| 2595 |
|
| 2596 | // Make sure leading/trailing whitespace is removed (IE can't handle it)
|
| 2597 | data = jQuery.trim( data );
|
| 2598 |
|
| 2599 | if ( data ) {
|
| 2600 | // Make sure the incoming data is actual JSON
|
| 2601 | // Logic borrowed from http://json.org/json2.js
|
| 2602 | if ( rvalidchars.test( data.replace( rvalidescape, "@" )
|
| 2603 | .replace( rvalidtokens, "]" )
|
| 2604 | .replace( rvalidbraces, "")) ) {
|
| 2605 |
|
| 2606 | return ( new Function( "return " + data ) )();
|
| 2607 | }
|
| 2608 | }
|
| 2609 | }
|
| 2610 |
|
| 2611 | jQuery.error( "Invalid JSON: " + data );
|
| 2612 | },
|
| 2613 |
|
| 2614 | // Cross-browser xml parsing
|
| 2615 | parseXML: function( data ) {
|
| 2616 | var xml, tmp;
|
| 2617 | if ( !data || typeof data !== "string" ) {
|
| 2618 | return null;
|
| 2619 | }
|
| 2620 | try {
|
| 2621 | if ( window.DOMParser ) { // Standard
|
| 2622 | tmp = new DOMParser();
|
| 2623 | xml = tmp.parseFromString( data , "text/xml" );
|
| 2624 | } else { // IE
|
| 2625 | xml = new ActiveXObject( "Microsoft.XMLDOM" );
|
| 2626 | xml.async = "false";
|
| 2627 | xml.loadXML( data );
|
| 2628 | }
|
| 2629 | } catch( e ) {
|
| 2630 | xml = undefined;
|
| 2631 | }
|
| 2632 | if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
|
| 2633 | jQuery.error( "Invalid XML: " + data );
|
| 2634 | }
|
| 2635 | return xml;
|
| 2636 | },
|
| 2637 |
|
| 2638 | noop: function() {},
|
| 2639 |
|
| 2640 | // Evaluates a script in a global context
|
| 2641 | // Workarounds based on findings by Jim Driscoll
|
| 2642 | // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
|
| 2643 | globalEval: function( data ) {
|
| 2644 | if ( data && jQuery.trim( data ) ) {
|
| 2645 | // We use execScript on Internet Explorer
|
| 2646 | // We use an anonymous function so that context is window
|
| 2647 | // rather than jQuery in Firefox
|
| 2648 | ( window.execScript || function( data ) {
|
| 2649 | window[ "eval" ].call( window, data );
|
| 2650 | } )( data );
|
| 2651 | }
|
| 2652 | },
|
| 2653 |
|
| 2654 | // Convert dashed to camelCase; used by the css and data modules
|
| 2655 | // Microsoft forgot to hump their vendor prefix (#9572)
|
| 2656 | camelCase: function( string ) {
|
| 2657 | return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
|
| 2658 | },
|
| 2659 |
|
| 2660 | nodeName: function( elem, name ) {
|
| 2661 | return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
| 2662 | },
|
| 2663 |
|
| 2664 | // args is for internal usage only
|
| 2665 | each: function( obj, callback, args ) {
|
| 2666 | var value,
|
| 2667 | i = 0,
|
| 2668 | length = obj.length,
|
| 2669 | isArray = isArraylike( obj );
|
| 2670 |
|
| 2671 | if ( args ) {
|
| 2672 | if ( isArray ) {
|
| 2673 | for ( ; i < length; i++ ) {
|
| 2674 | value = callback.apply( obj[ i ], args );
|
| 2675 |
|
| 2676 | if ( value === false ) {
|
| 2677 | break;
|
| 2678 | }
|
| 2679 | }
|
| 2680 | } else {
|
| 2681 | for ( i in obj ) {
|
| 2682 | value = callback.apply( obj[ i ], args );
|
| 2683 |
|
| 2684 | if ( value === false ) {
|
| 2685 | break;
|
| 2686 | }
|
| 2687 | }
|
| 2688 | }
|
| 2689 |
|
| 2690 | // A special, fast, case for the most common use of each
|
| 2691 | } else {
|
| 2692 | if ( isArray ) {
|
| 2693 | for ( ; i < length; i++ ) {
|
| 2694 | value = callback.call( obj[ i ], i, obj[ i ] );
|
| 2695 |
|
| 2696 | if ( value === false ) {
|
| 2697 | break;
|
| 2698 | }
|
| 2699 | }
|
| 2700 | } else {
|
| 2701 | for ( i in obj ) {
|
| 2702 | value = callback.call( obj[ i ], i, obj[ i ] );
|
| 2703 |
|
| 2704 | if ( value === false ) {
|
| 2705 | break;
|
| 2706 | }
|
| 2707 | }
|
| 2708 | }
|
| 2709 | }
|
| 2710 |
|
| 2711 | return obj;
|
| 2712 | },
|
| 2713 |
|
| 2714 | // Use native String.trim function wherever possible
|
| 2715 | trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
|
| 2716 | function( text ) {
|
| 2717 | return text == null ?
|
| 2718 | "" :
|
| 2719 | core_trim.call( text );
|
| 2720 | } :
|
| 2721 |
|
| 2722 | // Otherwise use our own trimming functionality
|
| 2723 | function( text ) {
|
| 2724 | return text == null ?
|
| 2725 | "" :
|
| 2726 | ( text + "" ).replace( rtrim, "" );
|
| 2727 | },
|
| 2728 |
|
| 2729 | // results is for internal usage only
|
| 2730 | makeArray: function( arr, results ) {
|
| 2731 | var ret = results || [];
|
| 2732 |
|
| 2733 | if ( arr != null ) {
|
| 2734 | if ( isArraylike( Object(arr) ) ) {
|
| 2735 | jQuery.merge( ret,
|
| 2736 | typeof arr === "string" ?
|
| 2737 | [ arr ] : arr
|
| 2738 | );
|
| 2739 | } else {
|
| 2740 | core_push.call( ret, arr );
|
| 2741 | }
|
| 2742 | }
|
| 2743 |
|
| 2744 | return ret;
|
| 2745 | },
|
| 2746 |
|
| 2747 | inArray: function( elem, arr, i ) {
|
| 2748 | var len;
|
| 2749 |
|
| 2750 | if ( arr ) {
|
| 2751 | if ( core_indexOf ) {
|
| 2752 | return core_indexOf.call( arr, elem, i );
|
| 2753 | }
|
| 2754 |
|
| 2755 | len = arr.length;
|
| 2756 | i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
|
| 2757 |
|
| 2758 | for ( ; i < len; i++ ) {
|
| 2759 | // Skip accessing in sparse arrays
|
| 2760 | if ( i in arr && arr[ i ] === elem ) {
|
| 2761 | return i;
|
| 2762 | }
|
| 2763 | }
|
| 2764 | }
|
| 2765 |
|
| 2766 | return -1;
|
| 2767 | },
|
| 2768 |
|
| 2769 | merge: function( first, second ) {
|
| 2770 | var l = second.length,
|
| 2771 | i = first.length,
|
| 2772 | j = 0;
|
| 2773 |
|
| 2774 | if ( typeof l === "number" ) {
|
| 2775 | for ( ; j < l; j++ ) {
|
| 2776 | first[ i++ ] = second[ j ];
|
| 2777 | }
|
| 2778 | } else {
|
| 2779 | while ( second[j] !== undefined ) {
|
| 2780 | first[ i++ ] = second[ j++ ];
|
| 2781 | }
|
| 2782 | }
|
| 2783 |
|
| 2784 | first.length = i;
|
| 2785 |
|
| 2786 | return first;
|
| 2787 | },
|
| 2788 |
|
| 2789 | grep: function( elems, callback, inv ) {
|
| 2790 | var retVal,
|
| 2791 | ret = [],
|
| 2792 | i = 0,
|
| 2793 | length = elems.length;
|
| 2794 | inv = !!inv;
|
| 2795 |
|
| 2796 | // Go through the array, only saving the items
|
| 2797 | // that pass the validator function
|
| 2798 | for ( ; i < length; i++ ) {
|
| 2799 | retVal = !!callback( elems[ i ], i );
|
| 2800 | if ( inv !== retVal ) {
|
| 2801 | ret.push( elems[ i ] );
|
| 2802 | }
|
| 2803 | }
|
| 2804 |
|
| 2805 | return ret;
|
| 2806 | },
|
| 2807 |
|
| 2808 | // arg is for internal usage only
|
| 2809 | map: function( elems, callback, arg ) {
|
| 2810 | var value,
|
| 2811 | i = 0,
|
| 2812 | length = elems.length,
|
| 2813 | isArray = isArraylike( elems ),
|
| 2814 | ret = [];
|
| 2815 |
|
| 2816 | // Go through the array, translating each of the items to their
|
| 2817 | if ( isArray ) {
|
| 2818 | for ( ; i < length; i++ ) {
|
| 2819 | value = callback( elems[ i ], i, arg );
|
| 2820 |
|
| 2821 | if ( value != null ) {
|
| 2822 | ret[ ret.length ] = value;
|
| 2823 | }
|
| 2824 | }
|
| 2825 |
|
| 2826 | // Go through every key on the object,
|
| 2827 | } else {
|
| 2828 | for ( i in elems ) {
|
| 2829 | value = callback( elems[ i ], i, arg );
|
| 2830 |
|
| 2831 | if ( value != null ) {
|
| 2832 | ret[ ret.length ] = value;
|
| 2833 | }
|
| 2834 | }
|
| 2835 | }
|
| 2836 |
|
| 2837 | // Flatten any nested arrays
|
| 2838 | return core_concat.apply( [], ret );
|
| 2839 | },
|
| 2840 |
|
| 2841 | // A global GUID counter for objects
|
| 2842 | guid: 1,
|
| 2843 |
|
| 2844 | // Bind a function to a context, optionally partially applying any
|
| 2845 | // arguments.
|
| 2846 | proxy: function( fn, context ) {
|
| 2847 | var args, proxy, tmp;
|
| 2848 |
|
| 2849 | if ( typeof context === "string" ) {
|
| 2850 | tmp = fn[ context ];
|
| 2851 | context = fn;
|
| 2852 | fn = tmp;
|
| 2853 | }
|
| 2854 |
|
| 2855 | // Quick check to determine if target is callable, in the spec
|
| 2856 | // this throws a TypeError, but we will just return undefined.
|
| 2857 | if ( !jQuery.isFunction( fn ) ) {
|
| 2858 | return undefined;
|
| 2859 | }
|
| 2860 |
|
| 2861 | // Simulated bind
|
| 2862 | args = core_slice.call( arguments, 2 );
|
| 2863 | proxy = function() {
|
| 2864 | return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
|
| 2865 | };
|
| 2866 |
|
| 2867 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
| 2868 | proxy.guid = fn.guid = fn.guid || jQuery.guid++;
|
| 2869 |
|
| 2870 | return proxy;
|
| 2871 | },
|
| 2872 |
|
| 2873 | // Multifunctional method to get and set values of a collection
|
| 2874 | // The value/s can optionally be executed if it's a function
|
| 2875 | access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
|
| 2876 | var i = 0,
|
| 2877 | length = elems.length,
|
| 2878 | bulk = key == null;
|
| 2879 |
|
| 2880 | // Sets many values
|
| 2881 | if ( jQuery.type( key ) === "object" ) {
|
| 2882 | chainable = true;
|
| 2883 | for ( i in key ) {
|
| 2884 | jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
|
| 2885 | }
|
| 2886 |
|
| 2887 | // Sets one value
|
| 2888 | } else if ( value !== undefined ) {
|
| 2889 | chainable = true;
|
| 2890 |
|
| 2891 | if ( !jQuery.isFunction( value ) ) {
|
| 2892 | raw = true;
|
| 2893 | }
|
| 2894 |
|
| 2895 | if ( bulk ) {
|
| 2896 | // Bulk operations run against the entire set
|
| 2897 | if ( raw ) {
|
| 2898 | fn.call( elems, value );
|
| 2899 | fn = null;
|
| 2900 |
|
| 2901 | // ...except when executing function values
|
| 2902 | } else {
|
| 2903 | bulk = fn;
|
| 2904 | fn = function( elem, key, value ) {
|
| 2905 | return bulk.call( jQuery( elem ), value );
|
| 2906 | };
|
| 2907 | }
|
| 2908 | }
|
| 2909 |
|
| 2910 | if ( fn ) {
|
| 2911 | for ( ; i < length; i++ ) {
|
| 2912 | fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
|
| 2913 | }
|
| 2914 | }
|
| 2915 | }
|
| 2916 |
|
| 2917 | return chainable ?
|
| 2918 | elems :
|
| 2919 |
|
| 2920 | // Gets
|
| 2921 | bulk ?
|
| 2922 | fn.call( elems ) :
|
| 2923 | length ? fn( elems[0], key ) : emptyGet;
|
| 2924 | },
|
| 2925 |
|
| 2926 | now: function() {
|
| 2927 | return ( new Date() ).getTime();
|
| 2928 | },
|
| 2929 |
|
| 2930 | // A method for quickly swapping in/out CSS properties to get correct calculations.
|
| 2931 | // Note: this method belongs to the css module but it's needed here for the support module.
|
| 2932 | // If support gets modularized, this method should be moved back to the css module.
|
| 2933 | swap: function( elem, options, callback, args ) {
|
| 2934 | var ret, name,
|
| 2935 | old = {};
|
| 2936 |
|
| 2937 | // Remember the old values, and insert the new ones
|
| 2938 | for ( name in options ) {
|
| 2939 | old[ name ] = elem.style[ name ];
|
| 2940 | elem.style[ name ] = options[ name ];
|
| 2941 | }
|
| 2942 |
|
| 2943 | ret = callback.apply( elem, args || [] );
|
| 2944 |
|
| 2945 | // Revert the old values
|
| 2946 | for ( name in options ) {
|
| 2947 | elem.style[ name ] = old[ name ];
|
| 2948 | }
|
| 2949 |
|
| 2950 | return ret;
|
| 2951 | }
|
| 2952 | });
|
| 2953 |
|
| 2954 | jQuery.ready.promise = function( obj ) {
|
| 2955 | if ( !readyList ) {
|
| 2956 |
|
| 2957 | readyList = jQuery.Deferred();
|
| 2958 |
|
| 2959 | // Catch cases where $(document).ready() is called after the browser event has already occurred.
|
| 2960 | // we once tried to use readyState "interactive" here, but it caused issues like the one
|
| 2961 | // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
|
| 2962 | if ( document.readyState === "complete" ) {
|
| 2963 | // Handle it asynchronously to allow scripts the opportunity to delay ready
|
| 2964 | setTimeout( jQuery.ready );
|
| 2965 |
|
| 2966 | // Standards-based browsers support DOMContentLoaded
|
| 2967 | } else if ( document.addEventListener ) {
|
| 2968 | // Use the handy event callback
|
| 2969 | document.addEventListener( "DOMContentLoaded", completed, false );
|
| 2970 |
|
| 2971 | // A fallback to window.onload, that will always work
|
| 2972 | window.addEventListener( "load", completed, false );
|
| 2973 |
|
| 2974 | // If IE event model is used
|
| 2975 | } else {
|
| 2976 | // Ensure firing before onload, maybe late but safe also for iframes
|
| 2977 | document.attachEvent( "onreadystatechange", completed );
|
| 2978 |
|
| 2979 | // A fallback to window.onload, that will always work
|
| 2980 | window.attachEvent( "onload", completed );
|
| 2981 |
|
| 2982 | // If IE and not a frame
|
| 2983 | // continually check to see if the document is ready
|
| 2984 | var top = false;
|
| 2985 |
|
| 2986 | try {
|
| 2987 | top = window.frameElement == null && document.documentElement;
|
| 2988 | } catch(e) {}
|
| 2989 |
|
| 2990 | if ( top && top.doScroll ) {
|
| 2991 | (function doScrollCheck() {
|
| 2992 | if ( !jQuery.isReady ) {
|
| 2993 |
|
| 2994 | try {
|
| 2995 | // Use the trick by Diego Perini
|
| 2996 | // http://javascript.nwbox.com/IEContentLoaded/
|
| 2997 | top.doScroll("left");
|
| 2998 | } catch(e) {
|
| 2999 | return setTimeout( doScrollCheck, 50 );
|
| 3000 | }
|
| 3001 |
|
| 3002 | // detach all dom ready events
|
| 3003 | detach();
|
| 3004 |
|
| 3005 | // and execute any waiting functions
|
| 3006 | jQuery.ready();
|
| 3007 | }
|
| 3008 | })();
|
| 3009 | }
|
| 3010 | }
|
| 3011 | }
|
| 3012 | return readyList.promise( obj );
|
| 3013 | };
|
| 3014 |
|
| 3015 | // Populate the class2type map
|
| 3016 | jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
|
| 3017 | class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
| 3018 | });
|
| 3019 |
|
| 3020 | function isArraylike( obj ) {
|
| 3021 | var length = obj.length,
|
| 3022 | type = jQuery.type( obj );
|
| 3023 |
|
| 3024 | if ( jQuery.isWindow( obj ) ) {
|
| 3025 | return false;
|
| 3026 | }
|
| 3027 |
|
| 3028 | if ( obj.nodeType === 1 && length ) {
|
| 3029 | return true;
|
| 3030 | }
|
| 3031 |
|
| 3032 | return type === "array" || type !== "function" &&
|
| 3033 | ( length === 0 ||
|
| 3034 | typeof length === "number" && length > 0 && ( length - 1 ) in obj );
|
| 3035 | }
|
| 3036 |
|
| 3037 | // All jQuery objects should point back to these
|
| 3038 | rootjQuery = jQuery(document);
|
| 3039 | /*
|
| 3040 | * Sizzle CSS Selector Engine
|
| 3041 | * http://sizzlejs.com/
|
| 3042 | *
|
| 3043 | * Copyright jQuery Foundation, Inc. and other contributors
|
| 3044 | * Released under the MIT license
|
| 3045 | * http://jquery.org/license
|
| 3046 | *
|
| 3047 | * Date: NULL
|
| 3048 | */
|
| 3049 | (function( window, undefined ) {
|
| 3050 |
|
| 3051 | var i,
|
| 3052 | support,
|
| 3053 | cachedruns,
|
| 3054 | Expr,
|
| 3055 | getText,
|
| 3056 | isXML,
|
| 3057 | compile,
|
| 3058 | outermostContext,
|
| 3059 | sortInput,
|
| 3060 |
|
| 3061 | // Local document vars
|
| 3062 | setDocument,
|
| 3063 | document,
|
| 3064 | docElem,
|
| 3065 | documentIsHTML,
|
| 3066 | rbuggyQSA,
|
| 3067 | rbuggyMatches,
|
| 3068 | matches,
|
| 3069 | contains,
|
| 3070 |
|
| 3071 | // Instance-specific data
|
| 3072 | expando = "sizzle" + -(new Date()),
|
| 3073 | preferredDoc = window.document,
|
| 3074 | dirruns = 0,
|
| 3075 | done = 0,
|
| 3076 | classCache = createCache(),
|
| 3077 | tokenCache = createCache(),
|
| 3078 | compilerCache = createCache(),
|
| 3079 | hasDuplicate = false,
|
| 3080 | sortOrder = function( a, b ) {
|
| 3081 | if ( a === b ) {
|
| 3082 | hasDuplicate = true;
|
| 3083 | return 0;
|
| 3084 | }
|
| 3085 | return 0;
|
| 3086 | },
|
| 3087 |
|
| 3088 | // General-purpose constants
|
| 3089 | strundefined = typeof undefined,
|
| 3090 | MAX_NEGATIVE = 1 << 31,
|
| 3091 |
|
| 3092 | // Instance methods
|
| 3093 | hasOwn = ({}).hasOwnProperty,
|
| 3094 | arr = [],
|
| 3095 | pop = arr.pop,
|
| 3096 | push_native = arr.push,
|
| 3097 | push = arr.push,
|
| 3098 | slice = arr.slice,
|
| 3099 | // Use a stripped-down indexOf if we can't use a native one
|
| 3100 | indexOf = arr.indexOf || function( elem ) {
|
| 3101 | var i = 0,
|
| 3102 | len = this.length;
|
| 3103 | for ( ; i < len; i++ ) {
|
| 3104 | if ( this[i] === elem ) {
|
| 3105 | return i;
|
| 3106 | }
|
| 3107 | }
|
| 3108 | return -1;
|
| 3109 | },
|
| 3110 |
|
| 3111 | booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
|
| 3112 |
|
| 3113 | // Regular expressions
|
| 3114 |
|
| 3115 | // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
|
| 3116 | whitespace = "[\\x20\\t\\r\\n\\f]",
|
| 3117 | // http://www.w3.org/TR/css3-syntax/#characters
|
| 3118 | characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
|
| 3119 |
|
| 3120 | // Loosely modeled on CSS identifier characters
|
| 3121 | // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
|
| 3122 | // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
|
| 3123 | identifier = characterEncoding.replace( "w", "w#" ),
|
| 3124 |
|
| 3125 | // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
|
| 3126 | attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
|
| 3127 | "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
|
| 3128 |
|
| 3129 | // Prefer arguments quoted,
|
| 3130 | // then not containing pseudos/brackets,
|
| 3131 | // then attribute selectors/non-parenthetical expressions,
|
| 3132 | // then anything else
|
| 3133 | // These preferences are here to reduce the number of selectors
|
| 3134 | // needing tokenize in the PSEUDO preFilter
|
| 3135 | pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
|
| 3136 |
|
| 3137 | // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
|
| 3138 | rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
|
| 3139 |
|
| 3140 | rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
|
| 3141 | rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
|
| 3142 |
|
| 3143 | rsibling = new RegExp( whitespace + "*[+~]" ),
|
| 3144 | rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ),
|
| 3145 |
|
| 3146 | rpseudo = new RegExp( pseudos ),
|
| 3147 | ridentifier = new RegExp( "^" + identifier + "$" ),
|
| 3148 |
|
| 3149 | matchExpr = {
|
| 3150 | "ID": new RegExp( "^#(" + characterEncoding + ")" ),
|
| 3151 | "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
|
| 3152 | "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
|
| 3153 | "ATTR": new RegExp( "^" + attributes ),
|
| 3154 | "PSEUDO": new RegExp( "^" + pseudos ),
|
| 3155 | "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
|
| 3156 | "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
|
| 3157 | "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
|
| 3158 | "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
|
| 3159 | // For use in libraries implementing .is()
|
| 3160 | // We use this for POS matching in `select`
|
| 3161 | "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
|
| 3162 | whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
|
| 3163 | },
|
| 3164 |
|
| 3165 | rnative = /^[^{]+\{\s*\[native \w/,
|
| 3166 |
|
| 3167 | // Easily-parseable/retrievable ID or TAG or CLASS selectors
|
| 3168 | rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
|
| 3169 |
|
| 3170 | rinputs = /^(?:input|select|textarea|button)$/i,
|
| 3171 | rheader = /^h\d$/i,
|
| 3172 |
|
| 3173 | rescape = /'|\\/g,
|
| 3174 |
|
| 3175 | // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
|
| 3176 | runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
|
| 3177 | funescape = function( _, escaped, escapedWhitespace ) {
|
| 3178 | var high = "0x" + escaped - 0x10000;
|
| 3179 | // NaN means non-codepoint
|
| 3180 | // Support: Firefox
|
| 3181 | // Workaround erroneous numeric interpretation of +"0x"
|
| 3182 | return high !== high || escapedWhitespace ?
|
| 3183 | escaped :
|
| 3184 | // BMP codepoint
|
| 3185 | high < 0 ?
|
| 3186 | String.fromCharCode( high + 0x10000 ) :
|
| 3187 | // Supplemental Plane codepoint (surrogate pair)
|
| 3188 | String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
|
| 3189 | };
|
| 3190 |
|
| 3191 | // Optimize for push.apply( _, NodeList )
|
| 3192 | try {
|
| 3193 | push.apply(
|
| 3194 | (arr = slice.call( preferredDoc.childNodes )),
|
| 3195 | preferredDoc.childNodes
|
| 3196 | );
|
| 3197 | // Support: Android<4.0
|
| 3198 | // Detect silently failing push.apply
|
| 3199 | arr[ preferredDoc.childNodes.length ].nodeType;
|
| 3200 | } catch ( e ) {
|
| 3201 | push = { apply: arr.length ?
|
| 3202 |
|
| 3203 | // Leverage slice if possible
|
| 3204 | function( target, els ) {
|
| 3205 | push_native.apply( target, slice.call(els) );
|
| 3206 | } :
|
| 3207 |
|
| 3208 | // Support: IE<9
|
| 3209 | // Otherwise append directly
|
| 3210 | function( target, els ) {
|
| 3211 | var j = target.length,
|
| 3212 | i = 0;
|
| 3213 | // Can't trust NodeList.length
|
| 3214 | while ( (target[j++] = els[i++]) ) {}
|
| 3215 | target.length = j - 1;
|
| 3216 | }
|
| 3217 | };
|
| 3218 | }
|
| 3219 |
|
| 3220 | function Sizzle( selector, context, results, seed ) {
|
| 3221 | var match, elem, m, nodeType,
|
| 3222 | // QSA vars
|
| 3223 | i, groups, old, nid, newContext, newSelector;
|
| 3224 |
|
| 3225 | if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
|
| 3226 | setDocument( context );
|
| 3227 | }
|
| 3228 |
|
| 3229 | context = context || document;
|
| 3230 | results = results || [];
|
| 3231 |
|
| 3232 | if ( !selector || typeof selector !== "string" ) {
|
| 3233 | return results;
|
| 3234 | }
|
| 3235 |
|
| 3236 | if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
|
| 3237 | return [];
|
| 3238 | }
|
| 3239 |
|
| 3240 | if ( documentIsHTML && !seed ) {
|
| 3241 |
|
| 3242 | // Shortcuts
|
| 3243 | if ( (match = rquickExpr.exec( selector )) ) {
|
| 3244 | // Speed-up: Sizzle("#ID")
|
| 3245 | if ( (m = match[1]) ) {
|
| 3246 | if ( nodeType === 9 ) {
|
| 3247 | elem = context.getElementById( m );
|
| 3248 | // Check parentNode to catch when Blackberry 4.6 returns
|
| 3249 | // nodes that are no longer in the document #6963
|
| 3250 | if ( elem && elem.parentNode ) {
|
| 3251 | // Handle the case where IE, Opera, and Webkit return items
|
| 3252 | // by name instead of ID
|
| 3253 | if ( elem.id === m ) {
|
| 3254 | results.push( elem );
|
| 3255 | return results;
|
| 3256 | }
|
| 3257 | } else {
|
| 3258 | return results;
|
| 3259 | }
|
| 3260 | } else {
|
| 3261 | // Context is not a document
|
| 3262 | if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
|
| 3263 | contains( context, elem ) && elem.id === m ) {
|
| 3264 | results.push( elem );
|
| 3265 | return results;
|
| 3266 | }
|
| 3267 | }
|
| 3268 |
|
| 3269 | // Speed-up: Sizzle("TAG")
|
| 3270 | } else if ( match[2] ) {
|
| 3271 | push.apply( results, context.getElementsByTagName( selector ) );
|
| 3272 | return results;
|
| 3273 |
|
| 3274 | // Speed-up: Sizzle(".CLASS")
|
| 3275 | } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
|
| 3276 | push.apply( results, context.getElementsByClassName( m ) );
|
| 3277 | return results;
|
| 3278 | }
|
| 3279 | }
|
| 3280 |
|
| 3281 | // QSA path
|
| 3282 | if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
|
| 3283 | nid = old = expando;
|
| 3284 | newContext = context;
|
| 3285 | newSelector = nodeType === 9 && selector;
|
| 3286 |
|
| 3287 | // qSA works strangely on Element-rooted queries
|
| 3288 | // We can work around this by specifying an extra ID on the root
|
| 3289 | // and working up from there (Thanks to Andrew Dupont for the technique)
|
| 3290 | // IE 8 doesn't work on object elements
|
| 3291 | if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
|
| 3292 | groups = tokenize( selector );
|
| 3293 |
|
| 3294 | if ( (old = context.getAttribute("id")) ) {
|
| 3295 | nid = old.replace( rescape, "\\$&" );
|
| 3296 | } else {
|
| 3297 | context.setAttribute( "id", nid );
|
| 3298 | }
|
| 3299 | nid = "[id='" + nid + "'] ";
|
| 3300 |
|
| 3301 | i = groups.length;
|
| 3302 | while ( i-- ) {
|
| 3303 | groups[i] = nid + toSelector( groups[i] );
|
| 3304 | }
|
| 3305 | newContext = rsibling.test( selector ) && context.parentNode || context;
|
| 3306 | newSelector = groups.join(",");
|
| 3307 | }
|
| 3308 |
|
| 3309 | if ( newSelector ) {
|
| 3310 | try {
|
| 3311 | push.apply( results,
|
| 3312 | newContext.querySelectorAll( newSelector )
|
| 3313 | );
|
| 3314 | return results;
|
| 3315 | } catch(qsaError) {
|
| 3316 | } finally {
|
| 3317 | if ( !old ) {
|
| 3318 | context.removeAttribute("id");
|
| 3319 | }
|
| 3320 | }
|
| 3321 | }
|
| 3322 | }
|
| 3323 | }
|
| 3324 |
|
| 3325 | // All others
|
| 3326 | return select( selector.replace( rtrim, "$1" ), context, results, seed );
|
| 3327 | }
|
| 3328 |
|
| 3329 | /**
|
| 3330 | * Create key-value caches of limited size
|
| 3331 | * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
|
| 3332 | * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
|
| 3333 | * deleting the oldest entry
|
| 3334 | */
|
| 3335 | function createCache() {
|
| 3336 | var keys = [];
|
| 3337 |
|
| 3338 | function cache( key, value ) {
|
| 3339 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
|
| 3340 | if ( keys.push( key += " " ) > Expr.cacheLength ) {
|
| 3341 | // Only keep the most recent entries
|
| 3342 | delete cache[ keys.shift() ];
|
| 3343 | }
|
| 3344 | return (cache[ key ] = value);
|
| 3345 | }
|
| 3346 | return cache;
|
| 3347 | }
|
| 3348 |
|
| 3349 | /**
|
| 3350 | * Mark a function for special use by Sizzle
|
| 3351 | * @param {Function} fn The function to mark
|
| 3352 | */
|
| 3353 | function markFunction( fn ) {
|
| 3354 | fn[ expando ] = true;
|
| 3355 | return fn;
|
| 3356 | }
|
| 3357 |
|
| 3358 | /**
|
| 3359 | * Support testing using an element
|
| 3360 | * @param {Function} fn Passed the created div and expects a boolean result
|
| 3361 | */
|
| 3362 | function assert( fn ) {
|
| 3363 | var div = document.createElement("div");
|
| 3364 |
|
| 3365 | try {
|
| 3366 | return !!fn( div );
|
| 3367 | } catch (e) {
|
| 3368 | return false;
|
| 3369 | } finally {
|
| 3370 | // Remove from its parent by default
|
| 3371 | if ( div.parentNode ) {
|
| 3372 | div.parentNode.removeChild( div );
|
| 3373 | }
|
| 3374 | // release memory in IE
|
| 3375 | div = null;
|
| 3376 | }
|
| 3377 | }
|
| 3378 |
|
| 3379 | /**
|
| 3380 | * Adds the same handler for all of the specified attrs
|
| 3381 | * @param {String} attrs Pipe-separated list of attributes
|
| 3382 | * @param {Function} handler The method that will be applied
|
| 3383 | */
|
| 3384 | function addHandle( attrs, handler ) {
|
| 3385 | var arr = attrs.split("|"),
|
| 3386 | i = attrs.length;
|
| 3387 |
|
| 3388 | while ( i-- ) {
|
| 3389 | Expr.attrHandle[ arr[i] ] = handler;
|
| 3390 | }
|
| 3391 | }
|
| 3392 |
|
| 3393 | /**
|
| 3394 | * Checks document order of two siblings
|
| 3395 | * @param {Element} a
|
| 3396 | * @param {Element} b
|
| 3397 | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
|
| 3398 | */
|
| 3399 | function siblingCheck( a, b ) {
|
| 3400 | var cur = b && a,
|
| 3401 | diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
|
| 3402 | ( ~b.sourceIndex || MAX_NEGATIVE ) -
|
| 3403 | ( ~a.sourceIndex || MAX_NEGATIVE );
|
| 3404 |
|
| 3405 | // Use IE sourceIndex if available on both nodes
|
| 3406 | if ( diff ) {
|
| 3407 | return diff;
|
| 3408 | }
|
| 3409 |
|
| 3410 | // Check if b follows a
|
| 3411 | if ( cur ) {
|
| 3412 | while ( (cur = cur.nextSibling) ) {
|
| 3413 | if ( cur === b ) {
|
| 3414 | return -1;
|
| 3415 | }
|
| 3416 | }
|
| 3417 | }
|
| 3418 |
|
| 3419 | return a ? 1 : -1;
|
| 3420 | }
|
| 3421 |
|
| 3422 | /**
|
| 3423 | * Returns a function to use in pseudos for input types
|
| 3424 | * @param {String} type
|
| 3425 | */
|
| 3426 | function createInputPseudo( type ) {
|
| 3427 | return function( elem ) {
|
| 3428 | var name = elem.nodeName.toLowerCase();
|
| 3429 | return name === "input" && elem.type === type;
|
| 3430 | };
|
| 3431 | }
|
| 3432 |
|
| 3433 | /**
|
| 3434 | * Returns a function to use in pseudos for buttons
|
| 3435 | * @param {String} type
|
| 3436 | */
|
| 3437 | function createButtonPseudo( type ) {
|
| 3438 | return function( elem ) {
|
| 3439 | var name = elem.nodeName.toLowerCase();
|
| 3440 | return (name === "input" || name === "button") && elem.type === type;
|
| 3441 | };
|
| 3442 | }
|
| 3443 |
|
| 3444 | /**
|
| 3445 | * Returns a function to use in pseudos for positionals
|
| 3446 | * @param {Function} fn
|
| 3447 | */
|
| 3448 | function createPositionalPseudo( fn ) {
|
| 3449 | return markFunction(function( argument ) {
|
| 3450 | argument = +argument;
|
| 3451 | return markFunction(function( seed, matches ) {
|
| 3452 | var j,
|
| 3453 | matchIndexes = fn( [], seed.length, argument ),
|
| 3454 | i = matchIndexes.length;
|
| 3455 |
|
| 3456 | // Match elements found at the specified indexes
|
| 3457 | while ( i-- ) {
|
| 3458 | if ( seed[ (j = matchIndexes[i]) ] ) {
|
| 3459 | seed[j] = !(matches[j] = seed[j]);
|
| 3460 | }
|
| 3461 | }
|
| 3462 | });
|
| 3463 | });
|
| 3464 | }
|
| 3465 |
|
| 3466 | /**
|
| 3467 | * Detect xml
|
| 3468 | * @param {Element|Object} elem An element or a document
|
| 3469 | */
|
| 3470 | isXML = Sizzle.isXML = function( elem ) {
|
| 3471 | // documentElement is verified for cases where it doesn't yet exist
|
| 3472 | // (such as loading iframes in IE - #4833)
|
| 3473 | var documentElement = elem && (elem.ownerDocument || elem).documentElement;
|
| 3474 | return documentElement ? documentElement.nodeName !== "HTML" : false;
|
| 3475 | };
|
| 3476 |
|
| 3477 | // Expose support vars for convenience
|
| 3478 | support = Sizzle.support = {};
|
| 3479 |
|
| 3480 | /**
|
| 3481 | * Sets document-related variables once based on the current document
|
| 3482 | * @param {Element|Object} [doc] An element or document object to use to set the document
|
| 3483 | * @returns {Object} Returns the current document
|
| 3484 | */
|
| 3485 | setDocument = Sizzle.setDocument = function( node ) {
|
| 3486 | var doc = node ? node.ownerDocument || node : preferredDoc,
|
| 3487 | parent = doc.defaultView;
|
| 3488 |
|
| 3489 | // If no document and documentElement is available, return
|
| 3490 | if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
|
| 3491 | return document;
|
| 3492 | }
|
| 3493 |
|
| 3494 | // Set our document
|
| 3495 | document = doc;
|
| 3496 | docElem = doc.documentElement;
|
| 3497 |
|
| 3498 | // Support tests
|
| 3499 | documentIsHTML = !isXML( doc );
|
| 3500 |
|
| 3501 | // Support: IE>8
|
| 3502 | // If iframe document is assigned to "document" variable and if iframe has been reloaded,
|
| 3503 | // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
|
| 3504 | // IE6-8 do not support the defaultView property so parent will be undefined
|
| 3505 | if ( parent && parent.attachEvent && parent !== parent.top ) {
|
| 3506 | parent.attachEvent( "onbeforeunload", function() {
|
| 3507 | setDocument();
|
| 3508 | });
|
| 3509 | }
|
| 3510 |
|
| 3511 | /* Attributes
|
| 3512 | ---------------------------------------------------------------------- */
|
| 3513 |
|
| 3514 | // Support: IE<8
|
| 3515 | // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
|
| 3516 | support.attributes = assert(function( div ) {
|
| 3517 | div.className = "i";
|
| 3518 | return !div.getAttribute("className");
|
| 3519 | });
|
| 3520 |
|
| 3521 | /* getElement(s)By*
|
| 3522 | ---------------------------------------------------------------------- */
|
| 3523 |
|
| 3524 | // Check if getElementsByTagName("*") returns only elements
|
| 3525 | support.getElementsByTagName = assert(function( div ) {
|
| 3526 | div.appendChild( doc.createComment("") );
|
| 3527 | return !div.getElementsByTagName("*").length;
|
| 3528 | });
|
| 3529 |
|
| 3530 | // Check if getElementsByClassName can be trusted
|
| 3531 | support.getElementsByClassName = assert(function( div ) {
|
| 3532 | div.innerHTML = "<div class='a'></div><div class='a i'></div>";
|
| 3533 |
|
| 3534 | // Support: Safari<4
|
| 3535 | // Catch class over-caching
|
| 3536 | div.firstChild.className = "i";
|
| 3537 | // Support: Opera<10
|
| 3538 | // Catch gEBCN failure to find non-leading classes
|
| 3539 | return div.getElementsByClassName("i").length === 2;
|
| 3540 | });
|
| 3541 |
|
| 3542 | // Support: IE<10
|
| 3543 | // Check if getElementById returns elements by name
|
| 3544 | // The broken getElementById methods don't pick up programatically-set names,
|
| 3545 | // so use a roundabout getElementsByName test
|
| 3546 | support.getById = assert(function( div ) {
|
| 3547 | docElem.appendChild( div ).id = expando;
|
| 3548 | return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
|
| 3549 | });
|
| 3550 |
|
| 3551 | // ID find and filter
|
| 3552 | if ( support.getById ) {
|
| 3553 | Expr.find["ID"] = function( id, context ) {
|
| 3554 | if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
|
| 3555 | var m = context.getElementById( id );
|
| 3556 | // Check parentNode to catch when Blackberry 4.6 returns
|
| 3557 | // nodes that are no longer in the document #6963
|
| 3558 | return m && m.parentNode ? [m] : [];
|
| 3559 | }
|
| 3560 | };
|
| 3561 | Expr.filter["ID"] = function( id ) {
|
| 3562 | var attrId = id.replace( runescape, funescape );
|
| 3563 | return function( elem ) {
|
| 3564 | return elem.getAttribute("id") === attrId;
|
| 3565 | };
|
| 3566 | };
|
| 3567 | } else {
|
| 3568 | // Support: IE6/7
|
| 3569 | // getElementById is not reliable as a find shortcut
|
| 3570 | delete Expr.find["ID"];
|
| 3571 |
|
| 3572 | Expr.filter["ID"] = function( id ) {
|
| 3573 | var attrId = id.replace( runescape, funescape );
|
| 3574 | return function( elem ) {
|
| 3575 | var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
|
| 3576 | return node && node.value === attrId;
|
| 3577 | };
|
| 3578 | };
|
| 3579 | }
|
| 3580 |
|
| 3581 | // Tag
|
| 3582 | Expr.find["TAG"] = support.getElementsByTagName ?
|
| 3583 | function( tag, context ) {
|
| 3584 | if ( typeof context.getElementsByTagName !== strundefined ) {
|
| 3585 | return context.getElementsByTagName( tag );
|
| 3586 | }
|
| 3587 | } :
|
| 3588 | function( tag, context ) {
|
| 3589 | var elem,
|
| 3590 | tmp = [],
|
| 3591 | i = 0,
|
| 3592 | results = context.getElementsByTagName( tag );
|
| 3593 |
|
| 3594 | // Filter out possible comments
|
| 3595 | if ( tag === "*" ) {
|
| 3596 | while ( (elem = results[i++]) ) {
|
| 3597 | if ( elem.nodeType === 1 ) {
|
| 3598 | tmp.push( elem );
|
| 3599 | }
|
| 3600 | }
|
| 3601 |
|
| 3602 | return tmp;
|
| 3603 | }
|
| 3604 | return results;
|
| 3605 | };
|
| 3606 |
|
| 3607 | // Class
|
| 3608 | Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
|
| 3609 | if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
|
| 3610 | return context.getElementsByClassName( className );
|
| 3611 | }
|
| 3612 | };
|
| 3613 |
|
| 3614 | /* QSA/matchesSelector
|
| 3615 | ---------------------------------------------------------------------- */
|
| 3616 |
|
| 3617 | // QSA and matchesSelector support
|
| 3618 |
|
| 3619 | // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
|
| 3620 | rbuggyMatches = [];
|
| 3621 |
|
| 3622 | // qSa(:focus) reports false when true (Chrome 21)
|
| 3623 | // We allow this because of a bug in IE8/9 that throws an error
|
| 3624 | // whenever `document.activeElement` is accessed on an iframe
|
| 3625 | // So, we allow :focus to pass through QSA all the time to avoid the IE error
|
| 3626 | // See http://bugs.jquery.com/ticket/13378
|
| 3627 | rbuggyQSA = [];
|
| 3628 |
|
| 3629 | if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
|
| 3630 | // Build QSA regex
|
| 3631 | // Regex strategy adopted from Diego Perini
|
| 3632 | assert(function( div ) {
|
| 3633 | // Select is set to empty string on purpose
|
| 3634 | // This is to test IE's treatment of not explicitly
|
| 3635 | // setting a boolean content attribute,
|
| 3636 | // since its presence should be enough
|
| 3637 | // http://bugs.jquery.com/ticket/12359
|
| 3638 | div.innerHTML = "<select><option selected=''></option></select>";
|
| 3639 |
|
| 3640 | // Support: IE8
|
| 3641 | // Boolean attributes and "value" are not treated correctly
|
| 3642 | if ( !div.querySelectorAll("[selected]").length ) {
|
| 3643 | rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
|
| 3644 | }
|
| 3645 |
|
| 3646 | // Webkit/Opera - :checked should return selected option elements
|
| 3647 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
| 3648 | // IE8 throws error here and will not see later tests
|
| 3649 | if ( !div.querySelectorAll(":checked").length ) {
|
| 3650 | rbuggyQSA.push(":checked");
|
| 3651 | }
|
| 3652 | });
|
| 3653 |
|
| 3654 | assert(function( div ) {
|
| 3655 |
|
| 3656 | // Support: Opera 10-12/IE8
|
| 3657 | // ^= $= *= and empty values
|
| 3658 | // Should not select anything
|
| 3659 | // Support: Windows 8 Native Apps
|
| 3660 | // The type attribute is restricted during .innerHTML assignment
|
| 3661 | var input = doc.createElement("input");
|
| 3662 | input.setAttribute( "type", "hidden" );
|
| 3663 | div.appendChild( input ).setAttribute( "t", "" );
|
| 3664 |
|
| 3665 | if ( div.querySelectorAll("[t^='']").length ) {
|
| 3666 | rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
|
| 3667 | }
|
| 3668 |
|
| 3669 | // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
|
| 3670 | // IE8 throws error here and will not see later tests
|
| 3671 | if ( !div.querySelectorAll(":enabled").length ) {
|
| 3672 | rbuggyQSA.push( ":enabled", ":disabled" );
|
| 3673 | }
|
| 3674 |
|
| 3675 | // Opera 10-11 does not throw on post-comma invalid pseudos
|
| 3676 | div.querySelectorAll("*,:x");
|
| 3677 | rbuggyQSA.push(",.*:");
|
| 3678 | });
|
| 3679 | }
|
| 3680 |
|
| 3681 | if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
|
| 3682 | docElem.mozMatchesSelector ||
|
| 3683 | docElem.oMatchesSelector ||
|
| 3684 | docElem.msMatchesSelector) )) ) {
|
| 3685 |
|
| 3686 | assert(function( div ) {
|
| 3687 | // Check to see if it's possible to do matchesSelector
|
| 3688 | // on a disconnected node (IE 9)
|
| 3689 | support.disconnectedMatch = matches.call( div, "div" );
|
| 3690 |
|
| 3691 | // This should fail with an exception
|
| 3692 | // Gecko does not error, returns false instead
|
| 3693 | matches.call( div, "[s!='']:x" );
|
| 3694 | rbuggyMatches.push( "!=", pseudos );
|
| 3695 | });
|
| 3696 | }
|
| 3697 |
|
| 3698 | rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
|
| 3699 | rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
|
| 3700 |
|
| 3701 | /* Contains
|
| 3702 | ---------------------------------------------------------------------- */
|
| 3703 |
|
| 3704 | // Element contains another
|
| 3705 | // Purposefully does not implement inclusive descendent
|
| 3706 | // As in, an element does not contain itself
|
| 3707 | contains = rnative.test( docElem.contains ) || docElem.compareDocumentPosition ?
|
| 3708 | function( a, b ) {
|
| 3709 | var adown = a.nodeType === 9 ? a.documentElement : a,
|
| 3710 | bup = b && b.parentNode;
|
| 3711 | return a === bup || !!( bup && bup.nodeType === 1 && (
|
| 3712 | adown.contains ?
|
| 3713 | adown.contains( bup ) :
|
| 3714 | a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
|
| 3715 | ));
|
| 3716 | } :
|
| 3717 | function( a, b ) {
|
| 3718 | if ( b ) {
|
| 3719 | while ( (b = b.parentNode) ) {
|
| 3720 | if ( b === a ) {
|
| 3721 | return true;
|
| 3722 | }
|
| 3723 | }
|
| 3724 | }
|
| 3725 | return false;
|
| 3726 | };
|
| 3727 |
|
| 3728 | /* Sorting
|
| 3729 | ---------------------------------------------------------------------- */
|
| 3730 |
|
| 3731 | // Document order sorting
|
| 3732 | sortOrder = docElem.compareDocumentPosition ?
|
| 3733 | function( a, b ) {
|
| 3734 |
|
| 3735 | // Flag for duplicate removal
|
| 3736 | if ( a === b ) {
|
| 3737 | hasDuplicate = true;
|
| 3738 | return 0;
|
| 3739 | }
|
| 3740 |
|
| 3741 | var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
|
| 3742 |
|
| 3743 | if ( compare ) {
|
| 3744 | // Disconnected nodes
|
| 3745 | if ( compare & 1 ||
|
| 3746 | (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
|
| 3747 |
|
| 3748 | // Choose the first element that is related to our preferred document
|
| 3749 | if ( a === doc || contains(preferredDoc, a) ) {
|
| 3750 | return -1;
|
| 3751 | }
|
| 3752 | if ( b === doc || contains(preferredDoc, b) ) {
|
| 3753 | return 1;
|
| 3754 | }
|
| 3755 |
|
| 3756 | // Maintain original order
|
| 3757 | return sortInput ?
|
| 3758 | ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
|
| 3759 | 0;
|
| 3760 | }
|
| 3761 |
|
| 3762 | return compare & 4 ? -1 : 1;
|
| 3763 | }
|
| 3764 |
|
| 3765 | // Not directly comparable, sort on existence of method
|
| 3766 | return a.compareDocumentPosition ? -1 : 1;
|
| 3767 | } :
|
| 3768 | function( a, b ) {
|
| 3769 | var cur,
|
| 3770 | i = 0,
|
| 3771 | aup = a.parentNode,
|
| 3772 | bup = b.parentNode,
|
| 3773 | ap = [ a ],
|
| 3774 | bp = [ b ];
|
| 3775 |
|
| 3776 | // Exit early if the nodes are identical
|
| 3777 | if ( a === b ) {
|
| 3778 | hasDuplicate = true;
|
| 3779 | return 0;
|
| 3780 |
|
| 3781 | // Parentless nodes are either documents or disconnected
|
| 3782 | } else if ( !aup || !bup ) {
|
| 3783 | return a === doc ? -1 :
|
| 3784 | b === doc ? 1 :
|
| 3785 | aup ? -1 :
|
| 3786 | bup ? 1 :
|
| 3787 | sortInput ?
|
| 3788 | ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
|
| 3789 | 0;
|
| 3790 |
|
| 3791 | // If the nodes are siblings, we can do a quick check
|
| 3792 | } else if ( aup === bup ) {
|
| 3793 | return siblingCheck( a, b );
|
| 3794 | }
|
| 3795 |
|
| 3796 | // Otherwise we need full lists of their ancestors for comparison
|
| 3797 | cur = a;
|
| 3798 | while ( (cur = cur.parentNode) ) {
|
| 3799 | ap.unshift( cur );
|
| 3800 | }
|
| 3801 | cur = b;
|
| 3802 | while ( (cur = cur.parentNode) ) {
|
| 3803 | bp.unshift( cur );
|
| 3804 | }
|
| 3805 |
|
| 3806 | // Walk down the tree looking for a discrepancy
|
| 3807 | while ( ap[i] === bp[i] ) {
|
| 3808 | i++;
|
| 3809 | }
|
| 3810 |
|
| 3811 | return i ?
|
| 3812 | // Do a sibling check if the nodes have a common ancestor
|
| 3813 | siblingCheck( ap[i], bp[i] ) :
|
| 3814 |
|
| 3815 | // Otherwise nodes in our document sort first
|
| 3816 | ap[i] === preferredDoc ? -1 :
|
| 3817 | bp[i] === preferredDoc ? 1 :
|
| 3818 | 0;
|
| 3819 | };
|
| 3820 |
|
| 3821 | return doc;
|
| 3822 | };
|
| 3823 |
|
| 3824 | Sizzle.matches = function( expr, elements ) {
|
| 3825 | return Sizzle( expr, null, null, elements );
|
| 3826 | };
|
| 3827 |
|
| 3828 | Sizzle.matchesSelector = function( elem, expr ) {
|
| 3829 | // Set document vars if needed
|
| 3830 | if ( ( elem.ownerDocument || elem ) !== document ) {
|
| 3831 | setDocument( elem );
|
| 3832 | }
|
| 3833 |
|
| 3834 | // Make sure that attribute selectors are quoted
|
| 3835 | expr = expr.replace( rattributeQuotes, "='$1']" );
|
| 3836 |
|
| 3837 | if ( support.matchesSelector && documentIsHTML &&
|
| 3838 | ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
|
| 3839 | ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
|
| 3840 |
|
| 3841 | try {
|
| 3842 | var ret = matches.call( elem, expr );
|
| 3843 |
|
| 3844 | // IE 9's matchesSelector returns false on disconnected nodes
|
| 3845 | if ( ret || support.disconnectedMatch ||
|
| 3846 | // As well, disconnected nodes are said to be in a document
|
| 3847 | // fragment in IE 9
|
| 3848 | elem.document && elem.document.nodeType !== 11 ) {
|
| 3849 | return ret;
|
| 3850 | }
|
| 3851 | } catch(e) {}
|
| 3852 | }
|
| 3853 |
|
| 3854 | return Sizzle( expr, document, null, [elem] ).length > 0;
|
| 3855 | };
|
| 3856 |
|
| 3857 | Sizzle.contains = function( context, elem ) {
|
| 3858 | // Set document vars if needed
|
| 3859 | if ( ( context.ownerDocument || context ) !== document ) {
|
| 3860 | setDocument( context );
|
| 3861 | }
|
| 3862 | return contains( context, elem );
|
| 3863 | };
|
| 3864 |
|
| 3865 | Sizzle.attr = function( elem, name ) {
|
| 3866 | // Set document vars if needed
|
| 3867 | if ( ( elem.ownerDocument || elem ) !== document ) {
|
| 3868 | setDocument( elem );
|
| 3869 | }
|
| 3870 |
|
| 3871 | var fn = Expr.attrHandle[ name.toLowerCase() ],
|
| 3872 | // Don't get fooled by Object.prototype properties (jQuery #13807)
|
| 3873 | val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
|
| 3874 | fn( elem, name, !documentIsHTML ) :
|
| 3875 | undefined;
|
| 3876 |
|
| 3877 | return val === undefined ?
|
| 3878 | support.attributes || !documentIsHTML ?
|
| 3879 | elem.getAttribute( name ) :
|
| 3880 | (val = elem.getAttributeNode(name)) && val.specified ?
|
| 3881 | val.value :
|
| 3882 | null :
|
| 3883 | val;
|
| 3884 | };
|
| 3885 |
|
| 3886 | Sizzle.error = function( msg ) {
|
| 3887 | throw new Error( "Syntax error, unrecognized expression: " + msg );
|
| 3888 | };
|
| 3889 |
|
| 3890 | /**
|
| 3891 | * Document sorting and removing duplicates
|
| 3892 | * @param {ArrayLike} results
|
| 3893 | */
|
| 3894 | Sizzle.uniqueSort = function( results ) {
|
| 3895 | var elem,
|
| 3896 | duplicates = [],
|
| 3897 | j = 0,
|
| 3898 | i = 0;
|
| 3899 |
|
| 3900 | // Unless we *know* we can detect duplicates, assume their presence
|
| 3901 | hasDuplicate = !support.detectDuplicates;
|
| 3902 | sortInput = !support.sortStable && results.slice( 0 );
|
| 3903 | results.sort( sortOrder );
|
| 3904 |
|
| 3905 | if ( hasDuplicate ) {
|
| 3906 | while ( (elem = results[i++]) ) {
|
| 3907 | if ( elem === results[ i ] ) {
|
| 3908 | j = duplicates.push( i );
|
| 3909 | }
|
| 3910 | }
|
| 3911 | while ( j-- ) {
|
| 3912 | results.splice( duplicates[ j ], 1 );
|
| 3913 | }
|
| 3914 | }
|
| 3915 |
|
| 3916 | return results;
|
| 3917 | };
|
| 3918 |
|
| 3919 | /**
|
| 3920 | * Utility function for retrieving the text value of an array of DOM nodes
|
| 3921 | * @param {Array|Element} elem
|
| 3922 | */
|
| 3923 | getText = Sizzle.getText = function( elem ) {
|
| 3924 | var node,
|
| 3925 | ret = "",
|
| 3926 | i = 0,
|
| 3927 | nodeType = elem.nodeType;
|
| 3928 |
|
| 3929 | if ( !nodeType ) {
|
| 3930 | // If no nodeType, this is expected to be an array
|
| 3931 | for ( ; (node = elem[i]); i++ ) {
|
| 3932 | // Do not traverse comment nodes
|
| 3933 | ret += getText( node );
|
| 3934 | }
|
| 3935 | } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
|
| 3936 | // Use textContent for elements
|
| 3937 | // innerText usage removed for consistency of new lines (see #11153)
|
| 3938 | if ( typeof elem.textContent === "string" ) {
|
| 3939 | return elem.textContent;
|
| 3940 | } else {
|
| 3941 | // Traverse its children
|
| 3942 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
| 3943 | ret += getText( elem );
|
| 3944 | }
|
| 3945 | }
|
| 3946 | } else if ( nodeType === 3 || nodeType === 4 ) {
|
| 3947 | return elem.nodeValue;
|
| 3948 | }
|
| 3949 | // Do not include comment or processing instruction nodes
|
| 3950 |
|
| 3951 | return ret;
|
| 3952 | };
|
| 3953 |
|
| 3954 | Expr = Sizzle.selectors = {
|
| 3955 |
|
| 3956 | // Can be adjusted by the user
|
| 3957 | cacheLength: 50,
|
| 3958 |
|
| 3959 | createPseudo: markFunction,
|
| 3960 |
|
| 3961 | match: matchExpr,
|
| 3962 |
|
| 3963 | attrHandle: {},
|
| 3964 |
|
| 3965 | find: {},
|
| 3966 |
|
| 3967 | relative: {
|
| 3968 | ">": { dir: "parentNode", first: true },
|
| 3969 | " ": { dir: "parentNode" },
|
| 3970 | "+": { dir: "previousSibling", first: true },
|
| 3971 | "~": { dir: "previousSibling" }
|
| 3972 | },
|
| 3973 |
|
| 3974 | preFilter: {
|
| 3975 | "ATTR": function( match ) {
|
| 3976 | match[1] = match[1].replace( runescape, funescape );
|
| 3977 |
|
| 3978 | // Move the given value to match[3] whether quoted or unquoted
|
| 3979 | match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
|
| 3980 |
|
| 3981 | if ( match[2] === "~=" ) {
|
| 3982 | match[3] = " " + match[3] + " ";
|
| 3983 | }
|
| 3984 |
|
| 3985 | return match.slice( 0, 4 );
|
| 3986 | },
|
| 3987 |
|
| 3988 | "CHILD": function( match ) {
|
| 3989 | /* matches from matchExpr["CHILD"]
|
| 3990 | 1 type (only|nth|...)
|
| 3991 | 2 what (child|of-type)
|
| 3992 | 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
|
| 3993 | 4 xn-component of xn+y argument ([+-]?\d*n|)
|
| 3994 | 5 sign of xn-component
|
| 3995 | 6 x of xn-component
|
| 3996 | 7 sign of y-component
|
| 3997 | 8 y of y-component
|
| 3998 | */
|
| 3999 | match[1] = match[1].toLowerCase();
|
| 4000 |
|
| 4001 | if ( match[1].slice( 0, 3 ) === "nth" ) {
|
| 4002 | // nth-* requires argument
|
| 4003 | if ( !match[3] ) {
|
| 4004 | Sizzle.error( match[0] );
|
| 4005 | }
|
| 4006 |
|
| 4007 | // numeric x and y parameters for Expr.filter.CHILD
|
| 4008 | // remember that false/true cast respectively to 0/1
|
| 4009 | match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
|
| 4010 | match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
|
| 4011 |
|
| 4012 | // other types prohibit arguments
|
| 4013 | } else if ( match[3] ) {
|
| 4014 | Sizzle.error( match[0] );
|
| 4015 | }
|
| 4016 |
|
| 4017 | return match;
|
| 4018 | },
|
| 4019 |
|
| 4020 | "PSEUDO": function( match ) {
|
| 4021 | var excess,
|
| 4022 | unquoted = !match[5] && match[2];
|
| 4023 |
|
| 4024 | if ( matchExpr["CHILD"].test( match[0] ) ) {
|
| 4025 | return null;
|
| 4026 | }
|
| 4027 |
|
| 4028 | // Accept quoted arguments as-is
|
| 4029 | if ( match[3] && match[4] !== undefined ) {
|
| 4030 | match[2] = match[4];
|
| 4031 |
|
| 4032 | // Strip excess characters from unquoted arguments
|
| 4033 | } else if ( unquoted && rpseudo.test( unquoted ) &&
|
| 4034 | // Get excess from tokenize (recursively)
|
| 4035 | (excess = tokenize( unquoted, true )) &&
|
| 4036 | // advance to the next closing parenthesis
|
| 4037 | (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
|
| 4038 |
|
| 4039 | // excess is a negative index
|
| 4040 | match[0] = match[0].slice( 0, excess );
|
| 4041 | match[2] = unquoted.slice( 0, excess );
|
| 4042 | }
|
| 4043 |
|
| 4044 | // Return only captures needed by the pseudo filter method (type and argument)
|
| 4045 | return match.slice( 0, 3 );
|
| 4046 | }
|
| 4047 | },
|
| 4048 |
|
| 4049 | filter: {
|
| 4050 |
|
| 4051 | "TAG": function( nodeNameSelector ) {
|
| 4052 | var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
|
| 4053 | return nodeNameSelector === "*" ?
|
| 4054 | function() { return true; } :
|
| 4055 | function( elem ) {
|
| 4056 | return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
|
| 4057 | };
|
| 4058 | },
|
| 4059 |
|
| 4060 | "CLASS": function( className ) {
|
| 4061 | var pattern = classCache[ className + " " ];
|
| 4062 |
|
| 4063 | return pattern ||
|
| 4064 | (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
|
| 4065 | classCache( className, function( elem ) {
|
| 4066 | return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
|
| 4067 | });
|
| 4068 | },
|
| 4069 |
|
| 4070 | "ATTR": function( name, operator, check ) {
|
| 4071 | return function( elem ) {
|
| 4072 | var result = Sizzle.attr( elem, name );
|
| 4073 |
|
| 4074 | if ( result == null ) {
|
| 4075 | return operator === "!=";
|
| 4076 | }
|
| 4077 | if ( !operator ) {
|
| 4078 | return true;
|
| 4079 | }
|
| 4080 |
|
| 4081 | result += "";
|
| 4082 |
|
| 4083 | return operator === "=" ? result === check :
|
| 4084 | operator === "!=" ? result !== check :
|
| 4085 | operator === "^=" ? check && result.indexOf( check ) === 0 :
|
| 4086 | operator === "*=" ? check && result.indexOf( check ) > -1 :
|
| 4087 | operator === "$=" ? check && result.slice( -check.length ) === check :
|
| 4088 | operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
|
| 4089 | operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
|
| 4090 | false;
|
| 4091 | };
|
| 4092 | },
|
| 4093 |
|
| 4094 | "CHILD": function( type, what, argument, first, last ) {
|
| 4095 | var simple = type.slice( 0, 3 ) !== "nth",
|
| 4096 | forward = type.slice( -4 ) !== "last",
|
| 4097 | ofType = what === "of-type";
|
| 4098 |
|
| 4099 | return first === 1 && last === 0 ?
|
| 4100 |
|
| 4101 | // Shortcut for :nth-*(n)
|
| 4102 | function( elem ) {
|
| 4103 | return !!elem.parentNode;
|
| 4104 | } :
|
| 4105 |
|
| 4106 | function( elem, context, xml ) {
|
| 4107 | var cache, outerCache, node, diff, nodeIndex, start,
|
| 4108 | dir = simple !== forward ? "nextSibling" : "previousSibling",
|
| 4109 | parent = elem.parentNode,
|
| 4110 | name = ofType && elem.nodeName.toLowerCase(),
|
| 4111 | useCache = !xml && !ofType;
|
| 4112 |
|
| 4113 | if ( parent ) {
|
| 4114 |
|
| 4115 | // :(first|last|only)-(child|of-type)
|
| 4116 | if ( simple ) {
|
| 4117 | while ( dir ) {
|
| 4118 | node = elem;
|
| 4119 | while ( (node = node[ dir ]) ) {
|
| 4120 | if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
|
| 4121 | return false;
|
| 4122 | }
|
| 4123 | }
|
| 4124 | // Reverse direction for :only-* (if we haven't yet done so)
|
| 4125 | start = dir = type === "only" && !start && "nextSibling";
|
| 4126 | }
|
| 4127 | return true;
|
| 4128 | }
|
| 4129 |
|
| 4130 | start = [ forward ? parent.firstChild : parent.lastChild ];
|
| 4131 |
|
| 4132 | // non-xml :nth-child(...) stores cache data on `parent`
|
| 4133 | if ( forward && useCache ) {
|
| 4134 | // Seek `elem` from a previously-cached index
|
| 4135 | outerCache = parent[ expando ] || (parent[ expando ] = {});
|
| 4136 | cache = outerCache[ type ] || [];
|
| 4137 | nodeIndex = cache[0] === dirruns && cache[1];
|
| 4138 | diff = cache[0] === dirruns && cache[2];
|
| 4139 | node = nodeIndex && parent.childNodes[ nodeIndex ];
|
| 4140 |
|
| 4141 | while ( (node = ++nodeIndex && node && node[ dir ] ||
|
| 4142 |
|
| 4143 | // Fallback to seeking `elem` from the start
|
| 4144 | (diff = nodeIndex = 0) || start.pop()) ) {
|
| 4145 |
|
| 4146 | // When found, cache indexes on `parent` and break
|
| 4147 | if ( node.nodeType === 1 && ++diff && node === elem ) {
|
| 4148 | outerCache[ type ] = [ dirruns, nodeIndex, diff ];
|
| 4149 | break;
|
| 4150 | }
|
| 4151 | }
|
| 4152 |
|
| 4153 | // Use previously-cached element index if available
|
| 4154 | } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
|
| 4155 | diff = cache[1];
|
| 4156 |
|
| 4157 | // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
|
| 4158 | } else {
|
| 4159 | // Use the same loop as above to seek `elem` from the start
|
| 4160 | while ( (node = ++nodeIndex && node && node[ dir ] ||
|
| 4161 | (diff = nodeIndex = 0) || start.pop()) ) {
|
| 4162 |
|
| 4163 | if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
|
| 4164 | // Cache the index of each encountered element
|
| 4165 | if ( useCache ) {
|
| 4166 | (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
|
| 4167 | }
|
| 4168 |
|
| 4169 | if ( node === elem ) {
|
| 4170 | break;
|
| 4171 | }
|
| 4172 | }
|
| 4173 | }
|
| 4174 | }
|
| 4175 |
|
| 4176 | // Incorporate the offset, then check against cycle size
|
| 4177 | diff -= last;
|
| 4178 | return diff === first || ( diff % first === 0 && diff / first >= 0 );
|
| 4179 | }
|
| 4180 | };
|
| 4181 | },
|
| 4182 |
|
| 4183 | "PSEUDO": function( pseudo, argument ) {
|
| 4184 | // pseudo-class names are case-insensitive
|
| 4185 | // http://www.w3.org/TR/selectors/#pseudo-classes
|
| 4186 | // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
|
| 4187 | // Remember that setFilters inherits from pseudos
|
| 4188 | var args,
|
| 4189 | fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
|
| 4190 | Sizzle.error( "unsupported pseudo: " + pseudo );
|
| 4191 |
|
| 4192 | // The user may use createPseudo to indicate that
|
| 4193 | // arguments are needed to create the filter function
|
| 4194 | // just as Sizzle does
|
| 4195 | if ( fn[ expando ] ) {
|
| 4196 | return fn( argument );
|
| 4197 | }
|
| 4198 |
|
| 4199 | // But maintain support for old signatures
|
| 4200 | if ( fn.length > 1 ) {
|
| 4201 | args = [ pseudo, pseudo, "", argument ];
|
| 4202 | return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
|
| 4203 | markFunction(function( seed, matches ) {
|
| 4204 | var idx,
|
| 4205 | matched = fn( seed, argument ),
|
| 4206 | i = matched.length;
|
| 4207 | while ( i-- ) {
|
| 4208 | idx = indexOf.call( seed, matched[i] );
|
| 4209 | seed[ idx ] = !( matches[ idx ] = matched[i] );
|
| 4210 | }
|
| 4211 | }) :
|
| 4212 | function( elem ) {
|
| 4213 | return fn( elem, 0, args );
|
| 4214 | };
|
| 4215 | }
|
| 4216 |
|
| 4217 | return fn;
|
| 4218 | }
|
| 4219 | },
|
| 4220 |
|
| 4221 | pseudos: {
|
| 4222 | // Potentially complex pseudos
|
| 4223 | "not": markFunction(function( selector ) {
|
| 4224 | // Trim the selector passed to compile
|
| 4225 | // to avoid treating leading and trailing
|
| 4226 | // spaces as combinators
|
| 4227 | var input = [],
|
| 4228 | results = [],
|
| 4229 | matcher = compile( selector.replace( rtrim, "$1" ) );
|
| 4230 |
|
| 4231 | return matcher[ expando ] ?
|
| 4232 | markFunction(function( seed, matches, context, xml ) {
|
| 4233 | var elem,
|
| 4234 | unmatched = matcher( seed, null, xml, [] ),
|
| 4235 | i = seed.length;
|
| 4236 |
|
| 4237 | // Match elements unmatched by `matcher`
|
| 4238 | while ( i-- ) {
|
| 4239 | if ( (elem = unmatched[i]) ) {
|
| 4240 | seed[i] = !(matches[i] = elem);
|
| 4241 | }
|
| 4242 | }
|
| 4243 | }) :
|
| 4244 | function( elem, context, xml ) {
|
| 4245 | input[0] = elem;
|
| 4246 | matcher( input, null, xml, results );
|
| 4247 | return !results.pop();
|
| 4248 | };
|
| 4249 | }),
|
| 4250 |
|
| 4251 | "has": markFunction(function( selector ) {
|
| 4252 | return function( elem ) {
|
| 4253 | return Sizzle( selector, elem ).length > 0;
|
| 4254 | };
|
| 4255 | }),
|
| 4256 |
|
| 4257 | "contains": markFunction(function( text ) {
|
| 4258 | return function( elem ) {
|
| 4259 | return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
|
| 4260 | };
|
| 4261 | }),
|
| 4262 |
|
| 4263 | // "Whether an element is represented by a :lang() selector
|
| 4264 | // is based solely on the element's language value
|
| 4265 | // being equal to the identifier C,
|
| 4266 | // or beginning with the identifier C immediately followed by "-".
|
| 4267 | // The matching of C against the element's language value is performed case-insensitively.
|
| 4268 | // The identifier C does not have to be a valid language name."
|
| 4269 | // http://www.w3.org/TR/selectors/#lang-pseudo
|
| 4270 | "lang": markFunction( function( lang ) {
|
| 4271 | // lang value must be a valid identifier
|
| 4272 | if ( !ridentifier.test(lang || "") ) {
|
| 4273 | Sizzle.error( "unsupported lang: " + lang );
|
| 4274 | }
|
| 4275 | lang = lang.replace( runescape, funescape ).toLowerCase();
|
| 4276 | return function( elem ) {
|
| 4277 | var elemLang;
|
| 4278 | do {
|
| 4279 | if ( (elemLang = documentIsHTML ?
|
| 4280 | elem.lang :
|
| 4281 | elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
|
| 4282 |
|
| 4283 | elemLang = elemLang.toLowerCase();
|
| 4284 | return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
|
| 4285 | }
|
| 4286 | } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
|
| 4287 | return false;
|
| 4288 | };
|
| 4289 | }),
|
| 4290 |
|
| 4291 | // Miscellaneous
|
| 4292 | "target": function( elem ) {
|
| 4293 | var hash = window.location && window.location.hash;
|
| 4294 | return hash && hash.slice( 1 ) === elem.id;
|
| 4295 | },
|
| 4296 |
|
| 4297 | "root": function( elem ) {
|
| 4298 | return elem === docElem;
|
| 4299 | },
|
| 4300 |
|
| 4301 | "focus": function( elem ) {
|
| 4302 | return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
|
| 4303 | },
|
| 4304 |
|
| 4305 | // Boolean properties
|
| 4306 | "enabled": function( elem ) {
|
| 4307 | return elem.disabled === false;
|
| 4308 | },
|
| 4309 |
|
| 4310 | "disabled": function( elem ) {
|
| 4311 | return elem.disabled === true;
|
| 4312 | },
|
| 4313 |
|
| 4314 | "checked": function( elem ) {
|
| 4315 | // In CSS3, :checked should return both checked and selected elements
|
| 4316 | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
| 4317 | var nodeName = elem.nodeName.toLowerCase();
|
| 4318 | return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
|
| 4319 | },
|
| 4320 |
|
| 4321 | "selected": function( elem ) {
|
| 4322 | // Accessing this property makes selected-by-default
|
| 4323 | // options in Safari work properly
|
| 4324 | if ( elem.parentNode ) {
|
| 4325 | elem.parentNode.selectedIndex;
|
| 4326 | }
|
| 4327 |
|
| 4328 | return elem.selected === true;
|
| 4329 | },
|
| 4330 |
|
| 4331 | // Contents
|
| 4332 | "empty": function( elem ) {
|
| 4333 | // http://www.w3.org/TR/selectors/#empty-pseudo
|
| 4334 | // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
|
| 4335 | // not comment, processing instructions, or others
|
| 4336 | // Thanks to Diego Perini for the nodeName shortcut
|
| 4337 | // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
|
| 4338 | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
| 4339 | if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
|
| 4340 | return false;
|
| 4341 | }
|
| 4342 | }
|
| 4343 | return true;
|
| 4344 | },
|
| 4345 |
|
| 4346 | "parent": function( elem ) {
|
| 4347 | return !Expr.pseudos["empty"]( elem );
|
| 4348 | },
|
| 4349 |
|
| 4350 | // Element/input types
|
| 4351 | "header": function( elem ) {
|
| 4352 | return rheader.test( elem.nodeName );
|
| 4353 | },
|
| 4354 |
|
| 4355 | "input": function( elem ) {
|
| 4356 | return rinputs.test( elem.nodeName );
|
| 4357 | },
|
| 4358 |
|
| 4359 | "button": function( elem ) {
|
| 4360 | var name = elem.nodeName.toLowerCase();
|
| 4361 | return name === "input" && elem.type === "button" || name === "button";
|
| 4362 | },
|
| 4363 |
|
| 4364 | "text": function( elem ) {
|
| 4365 | var attr;
|
| 4366 | // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
|
| 4367 | // use getAttribute instead to test this case
|
| 4368 | return elem.nodeName.toLowerCase() === "input" &&
|
| 4369 | elem.type === "text" &&
|
| 4370 | ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
|
| 4371 | },
|
| 4372 |
|
| 4373 | // Position-in-collection
|
| 4374 | "first": createPositionalPseudo(function() {
|
| 4375 | return [ 0 ];
|
| 4376 | }),
|
| 4377 |
|
| 4378 | "last": createPositionalPseudo(function( matchIndexes, length ) {
|
| 4379 | return [ length - 1 ];
|
| 4380 | }),
|
| 4381 |
|
| 4382 | "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
| 4383 | return [ argument < 0 ? argument + length : argument ];
|
| 4384 | }),
|
| 4385 |
|
| 4386 | "even": createPositionalPseudo(function( matchIndexes, length ) {
|
| 4387 | var i = 0;
|
| 4388 | for ( ; i < length; i += 2 ) {
|
| 4389 | matchIndexes.push( i );
|
| 4390 | }
|
| 4391 | return matchIndexes;
|
| 4392 | }),
|
| 4393 |
|
| 4394 | "odd": createPositionalPseudo(function( matchIndexes, length ) {
|
| 4395 | var i = 1;
|
| 4396 | for ( ; i < length; i += 2 ) {
|
| 4397 | matchIndexes.push( i );
|
| 4398 | }
|
| 4399 | return matchIndexes;
|
| 4400 | }),
|
| 4401 |
|
| 4402 | "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
| 4403 | var i = argument < 0 ? argument + length : argument;
|
| 4404 | for ( ; --i >= 0; ) {
|
| 4405 | matchIndexes.push( i );
|
| 4406 | }
|
| 4407 | return matchIndexes;
|
| 4408 | }),
|
| 4409 |
|
| 4410 | "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
| 4411 | var i = argument < 0 ? argument + length : argument;
|
| 4412 | for ( ; ++i < length; ) {
|
| 4413 | matchIndexes.push( i );
|
| 4414 | }
|
| 4415 | return matchIndexes;
|
| 4416 | })
|
| 4417 | }
|
| 4418 | };
|
| 4419 |
|
| 4420 | Expr.pseudos["nth"] = Expr.pseudos["eq"];
|
| 4421 |
|
| 4422 | // Add button/input type pseudos
|
| 4423 | for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
|
| 4424 | Expr.pseudos[ i ] = createInputPseudo( i );
|
| 4425 | }
|
| 4426 | for ( i in { submit: true, reset: true } ) {
|
| 4427 | Expr.pseudos[ i ] = createButtonPseudo( i );
|
| 4428 | }
|
| 4429 |
|
| 4430 | // Easy API for creating new setFilters
|
| 4431 | function setFilters() {}
|
| 4432 | setFilters.prototype = Expr.filters = Expr.pseudos;
|
| 4433 | Expr.setFilters = new setFilters();
|
| 4434 |
|
| 4435 | function tokenize( selector, parseOnly ) {
|
| 4436 | var matched, match, tokens, type,
|
| 4437 | soFar, groups, preFilters,
|
| 4438 | cached = tokenCache[ selector + " " ];
|
| 4439 |
|
| 4440 | if ( cached ) {
|
| 4441 | return parseOnly ? 0 : cached.slice( 0 );
|
| 4442 | }
|
| 4443 |
|
| 4444 | soFar = selector;
|
| 4445 | groups = [];
|
| 4446 | preFilters = Expr.preFilter;
|
| 4447 |
|
| 4448 | while ( soFar ) {
|
| 4449 |
|
| 4450 | // Comma and first run
|
| 4451 | if ( !matched || (match = rcomma.exec( soFar )) ) {
|
| 4452 | if ( match ) {
|
| 4453 | // Don't consume trailing commas as valid
|
| 4454 | soFar = soFar.slice( match[0].length ) || soFar;
|
| 4455 | }
|
| 4456 | groups.push( tokens = [] );
|
| 4457 | }
|
| 4458 |
|
| 4459 | matched = false;
|
| 4460 |
|
| 4461 | // Combinators
|
| 4462 | if ( (match = rcombinators.exec( soFar )) ) {
|
| 4463 | matched = match.shift();
|
| 4464 | tokens.push({
|
| 4465 | value: matched,
|
| 4466 | // Cast descendant combinators to space
|
| 4467 | type: match[0].replace( rtrim, " " )
|
| 4468 | });
|
| 4469 | soFar = soFar.slice( matched.length );
|
| 4470 | }
|
| 4471 |
|
| 4472 | // Filters
|
| 4473 | for ( type in Expr.filter ) {
|
| 4474 | if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
|
| 4475 | (match = preFilters[ type ]( match ))) ) {
|
| 4476 | matched = match.shift();
|
| 4477 | tokens.push({
|
| 4478 | value: matched,
|
| 4479 | type: type,
|
| 4480 | matches: match
|
| 4481 | });
|
| 4482 | soFar = soFar.slice( matched.length );
|
| 4483 | }
|
| 4484 | }
|
| 4485 |
|
| 4486 | if ( !matched ) {
|
| 4487 | break;
|
| 4488 | }
|
| 4489 | }
|
| 4490 |
|
| 4491 | // Return the length of the invalid excess
|
| 4492 | // if we're just parsing
|
| 4493 | // Otherwise, throw an error or return tokens
|
| 4494 | return parseOnly ?
|
| 4495 | soFar.length :
|
| 4496 | soFar ?
|
| 4497 | Sizzle.error( selector ) :
|
| 4498 | // Cache the tokens
|
| 4499 | tokenCache( selector, groups ).slice( 0 );
|
| 4500 | }
|
| 4501 |
|
| 4502 | function toSelector( tokens ) {
|
| 4503 | var i = 0,
|
| 4504 | len = tokens.length,
|
| 4505 | selector = "";
|
| 4506 | for ( ; i < len; i++ ) {
|
| 4507 | selector += tokens[i].value;
|
| 4508 | }
|
| 4509 | return selector;
|
| 4510 | }
|
| 4511 |
|
| 4512 | function addCombinator( matcher, combinator, base ) {
|
| 4513 | var dir = combinator.dir,
|
| 4514 | checkNonElements = base && dir === "parentNode",
|
| 4515 | doneName = done++;
|
| 4516 |
|
| 4517 | return combinator.first ?
|
| 4518 | // Check against closest ancestor/preceding element
|
| 4519 | function( elem, context, xml ) {
|
| 4520 | while ( (elem = elem[ dir ]) ) {
|
| 4521 | if ( elem.nodeType === 1 || checkNonElements ) {
|
| 4522 | return matcher( elem, context, xml );
|
| 4523 | }
|
| 4524 | }
|
| 4525 | } :
|
| 4526 |
|
| 4527 | // Check against all ancestor/preceding elements
|
| 4528 | function( elem, context, xml ) {
|
| 4529 | var data, cache, outerCache,
|
| 4530 | dirkey = dirruns + " " + doneName;
|
| 4531 |
|
| 4532 | // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
|
| 4533 | if ( xml ) {
|
| 4534 | while ( (elem = elem[ dir ]) ) {
|
| 4535 | if ( elem.nodeType === 1 || checkNonElements ) {
|
| 4536 | if ( matcher( elem, context, xml ) ) {
|
| 4537 | return true;
|
| 4538 | }
|
| 4539 | }
|
| 4540 | }
|
| 4541 | } else {
|
| 4542 | while ( (elem = elem[ dir ]) ) {
|
| 4543 | if ( elem.nodeType === 1 || checkNonElements ) {
|
| 4544 | outerCache = elem[ expando ] || (elem[ expando ] = {});
|
| 4545 | if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
|
| 4546 | if ( (data = cache[1]) === true || data === cachedruns ) {
|
| 4547 | return data === true;
|
| 4548 | }
|
| 4549 | } else {
|
| 4550 | cache = outerCache[ dir ] = [ dirkey ];
|
| 4551 | cache[1] = matcher( elem, context, xml ) || cachedruns;
|
| 4552 | if ( cache[1] === true ) {
|
| 4553 | return true;
|
| 4554 | }
|
| 4555 | }
|
| 4556 | }
|
| 4557 | }
|
| 4558 | }
|
| 4559 | };
|
| 4560 | }
|
| 4561 |
|
| 4562 | function elementMatcher( matchers ) {
|
| 4563 | return matchers.length > 1 ?
|
| 4564 | function( elem, context, xml ) {
|
| 4565 | var i = matchers.length;
|
| 4566 | while ( i-- ) {
|
| 4567 | if ( !matchers[i]( elem, context, xml ) ) {
|
| 4568 | return false;
|
| 4569 | }
|
| 4570 | }
|
| 4571 | return true;
|
| 4572 | } :
|
| 4573 | matchers[0];
|
| 4574 | }
|
| 4575 |
|
| 4576 | function condense( unmatched, map, filter, context, xml ) {
|
| 4577 | var elem,
|
| 4578 | newUnmatched = [],
|
| 4579 | i = 0,
|
| 4580 | len = unmatched.length,
|
| 4581 | mapped = map != null;
|
| 4582 |
|
| 4583 | for ( ; i < len; i++ ) {
|
| 4584 | if ( (elem = unmatched[i]) ) {
|
| 4585 | if ( !filter || filter( elem, context, xml ) ) {
|
| 4586 | newUnmatched.push( elem );
|
| 4587 | if ( mapped ) {
|
| 4588 | map.push( i );
|
| 4589 | }
|
| 4590 | }
|
| 4591 | }
|
| 4592 | }
|
| 4593 |
|
| 4594 | return newUnmatched;
|
| 4595 | }
|
| 4596 |
|
| 4597 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
|
| 4598 | if ( postFilter && !postFilter[ expando ] ) {
|
| 4599 | postFilter = setMatcher( postFilter );
|
| 4600 | }
|
| 4601 | if ( postFinder && !postFinder[ expando ] ) {
|
| 4602 | postFinder = setMatcher( postFinder, postSelector );
|
| 4603 | }
|
| 4604 | return markFunction(function( seed, results, context, xml ) {
|
| 4605 | var temp, i, elem,
|
| 4606 | preMap = [],
|
| 4607 | postMap = [],
|
| 4608 | preexisting = results.length,
|
| 4609 |
|
| 4610 | // Get initial elements from seed or context
|
| 4611 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
|
| 4612 |
|
| 4613 | // Prefilter to get matcher input, preserving a map for seed-results synchronization
|
| 4614 | matcherIn = preFilter && ( seed || !selector ) ?
|
| 4615 | condense( elems, preMap, preFilter, context, xml ) :
|
| 4616 | elems,
|
| 4617 |
|
| 4618 | matcherOut = matcher ?
|
| 4619 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
|
| 4620 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
|
| 4621 |
|
| 4622 | // ...intermediate processing is necessary
|
| 4623 | [] :
|
| 4624 |
|
| 4625 | // ...otherwise use results directly
|
| 4626 | results :
|
| 4627 | matcherIn;
|
| 4628 |
|
| 4629 | // Find primary matches
|
| 4630 | if ( matcher ) {
|
| 4631 | matcher( matcherIn, matcherOut, context, xml );
|
| 4632 | }
|
| 4633 |
|
| 4634 | // Apply postFilter
|
| 4635 | if ( postFilter ) {
|
| 4636 | temp = condense( matcherOut, postMap );
|
| 4637 | postFilter( temp, [], context, xml );
|
| 4638 |
|
| 4639 | // Un-match failing elements by moving them back to matcherIn
|
| 4640 | i = temp.length;
|
| 4641 | while ( i-- ) {
|
| 4642 | if ( (elem = temp[i]) ) {
|
| 4643 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
|
| 4644 | }
|
| 4645 | }
|
| 4646 | }
|
| 4647 |
|
| 4648 | if ( seed ) {
|
| 4649 | if ( postFinder || preFilter ) {
|
| 4650 | if ( postFinder ) {
|
| 4651 | // Get the final matcherOut by condensing this intermediate into postFinder contexts
|
| 4652 | temp = [];
|
| 4653 | i = matcherOut.length;
|
| 4654 | while ( i-- ) {
|
| 4655 | if ( (elem = matcherOut[i]) ) {
|
| 4656 | // Restore matcherIn since elem is not yet a final match
|
| 4657 | temp.push( (matcherIn[i] = elem) );
|
| 4658 | }
|
| 4659 | }
|
| 4660 | postFinder( null, (matcherOut = []), temp, xml );
|
| 4661 | }
|
| 4662 |
|
| 4663 | // Move matched elements from seed to results to keep them synchronized
|
| 4664 | i = matcherOut.length;
|
| 4665 | while ( i-- ) {
|
| 4666 | if ( (elem = matcherOut[i]) &&
|
| 4667 | (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
|
| 4668 |
|
| 4669 | seed[temp] = !(results[temp] = elem);
|
| 4670 | }
|
| 4671 | }
|
| 4672 | }
|
| 4673 |
|
| 4674 | // Add elements to results, through postFinder if defined
|
| 4675 | } else {
|
| 4676 | matcherOut = condense(
|
| 4677 | matcherOut === results ?
|
| 4678 | matcherOut.splice( preexisting, matcherOut.length ) :
|
| 4679 | matcherOut
|
| 4680 | );
|
| 4681 | if ( postFinder ) {
|
| 4682 | postFinder( null, results, matcherOut, xml );
|
| 4683 | } else {
|
| 4684 | push.apply( results, matcherOut );
|
| 4685 | }
|
| 4686 | }
|
| 4687 | });
|
| 4688 | }
|
| 4689 |
|
| 4690 | function matcherFromTokens( tokens ) {
|
| 4691 | var checkContext, matcher, j,
|
| 4692 | len = tokens.length,
|
| 4693 | leadingRelative = Expr.relative[ tokens[0].type ],
|
| 4694 | implicitRelative = leadingRelative || Expr.relative[" "],
|
| 4695 | i = leadingRelative ? 1 : 0,
|
| 4696 |
|
| 4697 | // The foundational matcher ensures that elements are reachable from top-level context(s)
|
| 4698 | matchContext = addCombinator( function( elem ) {
|
| 4699 | return elem === checkContext;
|
| 4700 | }, implicitRelative, true ),
|
| 4701 | matchAnyContext = addCombinator( function( elem ) {
|
| 4702 | return indexOf.call( checkContext, elem ) > -1;
|
| 4703 | }, implicitRelative, true ),
|
| 4704 | matchers = [ function( elem, context, xml ) {
|
| 4705 | return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
|
| 4706 | (checkContext = context).nodeType ?
|
| 4707 | matchContext( elem, context, xml ) :
|
| 4708 | matchAnyContext( elem, context, xml ) );
|
| 4709 | } ];
|
| 4710 |
|
| 4711 | for ( ; i < len; i++ ) {
|
| 4712 | if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
|
| 4713 | matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
|
| 4714 | } else {
|
| 4715 | matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
|
| 4716 |
|
| 4717 | // Return special upon seeing a positional matcher
|
| 4718 | if ( matcher[ expando ] ) {
|
| 4719 | // Find the next relative operator (if any) for proper handling
|
| 4720 | j = ++i;
|
| 4721 | for ( ; j < len; j++ ) {
|
| 4722 | if ( Expr.relative[ tokens[j].type ] ) {
|
| 4723 | break;
|
| 4724 | }
|
| 4725 | }
|
| 4726 | return setMatcher(
|
| 4727 | i > 1 && elementMatcher( matchers ),
|
| 4728 | i > 1 && toSelector(
|
| 4729 | // If the preceding token was a descendant combinator, insert an implicit any-element `*`
|
| 4730 | tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
|
| 4731 | ).replace( rtrim, "$1" ),
|
| 4732 | matcher,
|
| 4733 | i < j && matcherFromTokens( tokens.slice( i, j ) ),
|
| 4734 | j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
|
| 4735 | j < len && toSelector( tokens )
|
| 4736 | );
|
| 4737 | }
|
| 4738 | matchers.push( matcher );
|
| 4739 | }
|
| 4740 | }
|
| 4741 |
|
| 4742 | return elementMatcher( matchers );
|
| 4743 | }
|
| 4744 |
|
| 4745 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
|
| 4746 | // A counter to specify which element is currently being matched
|
| 4747 | var matcherCachedRuns = 0,
|
| 4748 | bySet = setMatchers.length > 0,
|
| 4749 | byElement = elementMatchers.length > 0,
|
| 4750 | superMatcher = function( seed, context, xml, results, expandContext ) {
|
| 4751 | var elem, j, matcher,
|
| 4752 | setMatched = [],
|
| 4753 | matchedCount = 0,
|
| 4754 | i = "0",
|
| 4755 | unmatched = seed && [],
|
| 4756 | outermost = expandContext != null,
|
| 4757 | contextBackup = outermostContext,
|
| 4758 | // We must always have either seed elements or context
|
| 4759 | elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
|
| 4760 | // Use integer dirruns iff this is the outermost matcher
|
| 4761 | dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
|
| 4762 |
|
| 4763 | if ( outermost ) {
|
| 4764 | outermostContext = context !== document && context;
|
| 4765 | cachedruns = matcherCachedRuns;
|
| 4766 | }
|
| 4767 |
|
| 4768 | // Add elements passing elementMatchers directly to results
|
| 4769 | // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
|
| 4770 | for ( ; (elem = elems[i]) != null; i++ ) {
|
| 4771 | if ( byElement && elem ) {
|
| 4772 | j = 0;
|
| 4773 | while ( (matcher = elementMatchers[j++]) ) {
|
| 4774 | if ( matcher( elem, context, xml ) ) {
|
| 4775 | results.push( elem );
|
| 4776 | break;
|
| 4777 | }
|
| 4778 | }
|
| 4779 | if ( outermost ) {
|
| 4780 | dirruns = dirrunsUnique;
|
| 4781 | cachedruns = ++matcherCachedRuns;
|
| 4782 | }
|
| 4783 | }
|
| 4784 |
|
| 4785 | // Track unmatched elements for set filters
|
| 4786 | if ( bySet ) {
|
| 4787 | // They will have gone through all possible matchers
|
| 4788 | if ( (elem = !matcher && elem) ) {
|
| 4789 | matchedCount--;
|
| 4790 | }
|
| 4791 |
|
| 4792 | // Lengthen the array for every element, matched or not
|
| 4793 | if ( seed ) {
|
| 4794 | unmatched.push( elem );
|
| 4795 | }
|
| 4796 | }
|
| 4797 | }
|
| 4798 |
|
| 4799 | // Apply set filters to unmatched elements
|
| 4800 | matchedCount += i;
|
| 4801 | if ( bySet && i !== matchedCount ) {
|
| 4802 | j = 0;
|
| 4803 | while ( (matcher = setMatchers[j++]) ) {
|
| 4804 | matcher( unmatched, setMatched, context, xml );
|
| 4805 | }
|
| 4806 |
|
| 4807 | if ( seed ) {
|
| 4808 | // Reintegrate element matches to eliminate the need for sorting
|
| 4809 | if ( matchedCount > 0 ) {
|
| 4810 | while ( i-- ) {
|
| 4811 | if ( !(unmatched[i] || setMatched[i]) ) {
|
| 4812 | setMatched[i] = pop.call( results );
|
| 4813 | }
|
| 4814 | }
|
| 4815 | }
|
| 4816 |
|
| 4817 | // Discard index placeholder values to get only actual matches
|
| 4818 | setMatched = condense( setMatched );
|
| 4819 | }
|
| 4820 |
|
| 4821 | // Add matches to results
|
| 4822 | push.apply( results, setMatched );
|
| 4823 |
|
| 4824 | // Seedless set matches succeeding multiple successful matchers stipulate sorting
|
| 4825 | if ( outermost && !seed && setMatched.length > 0 &&
|
| 4826 | ( matchedCount + setMatchers.length ) > 1 ) {
|
| 4827 |
|
| 4828 | Sizzle.uniqueSort( results );
|
| 4829 | }
|
| 4830 | }
|
| 4831 |
|
| 4832 | // Override manipulation of globals by nested matchers
|
| 4833 | if ( outermost ) {
|
| 4834 | dirruns = dirrunsUnique;
|
| 4835 | outermostContext = contextBackup;
|
| 4836 | }
|
| 4837 |
|
| 4838 | return unmatched;
|
| 4839 | };
|
| 4840 |
|
| 4841 | return bySet ?
|
| 4842 | markFunction( superMatcher ) :
|
| 4843 | superMatcher;
|
| 4844 | }
|
| 4845 |
|
| 4846 | compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
|
| 4847 | var i,
|
| 4848 | setMatchers = [],
|
| 4849 | elementMatchers = [],
|
| 4850 | cached = compilerCache[ selector + " " ];
|
| 4851 |
|
| 4852 | if ( !cached ) {
|
| 4853 | // Generate a function of recursive functions that can be used to check each element
|
| 4854 | if ( !group ) {
|
| 4855 | group = tokenize( selector );
|
| 4856 | }
|
| 4857 | i = group.length;
|
| 4858 | while ( i-- ) {
|
| 4859 | cached = matcherFromTokens( group[i] );
|
| 4860 | if ( cached[ expando ] ) {
|
| 4861 | setMatchers.push( cached );
|
| 4862 | } else {
|
| 4863 | elementMatchers.push( cached );
|
| 4864 | }
|
| 4865 | }
|
| 4866 |
|
| 4867 | // Cache the compiled function
|
| 4868 | cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
|
| 4869 | }
|
| 4870 | return cached;
|
| 4871 | };
|
| 4872 |
|
| 4873 | function multipleContexts( selector, contexts, results ) {
|
| 4874 | var i = 0,
|
| 4875 | len = contexts.length;
|
| 4876 | for ( ; i < len; i++ ) {
|
| 4877 | Sizzle( selector, contexts[i], results );
|
| 4878 | }
|
| 4879 | return results;
|
| 4880 | }
|
| 4881 |
|
| 4882 | function select( selector, context, results, seed ) {
|
| 4883 | var i, tokens, token, type, find,
|
| 4884 | match = tokenize( selector );
|
| 4885 |
|
| 4886 | if ( !seed ) {
|
| 4887 | // Try to minimize operations if there is only one group
|
| 4888 | if ( match.length === 1 ) {
|
| 4889 |
|
| 4890 | // Take a shortcut and set the context if the root selector is an ID
|
| 4891 | tokens = match[0] = match[0].slice( 0 );
|
| 4892 | if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
|
| 4893 | support.getById && context.nodeType === 9 && documentIsHTML &&
|
| 4894 | Expr.relative[ tokens[1].type ] ) {
|
| 4895 |
|
| 4896 | context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
|
| 4897 | if ( !context ) {
|
| 4898 | return results;
|
| 4899 | }
|
| 4900 | selector = selector.slice( tokens.shift().value.length );
|
| 4901 | }
|
| 4902 |
|
| 4903 | // Fetch a seed set for right-to-left matching
|
| 4904 | i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
|
| 4905 | while ( i-- ) {
|
| 4906 | token = tokens[i];
|
| 4907 |
|
| 4908 | // Abort if we hit a combinator
|
| 4909 | if ( Expr.relative[ (type = token.type) ] ) {
|
| 4910 | break;
|
| 4911 | }
|
| 4912 | if ( (find = Expr.find[ type ]) ) {
|
| 4913 | // Search, expanding context for leading sibling combinators
|
| 4914 | if ( (seed = find(
|
| 4915 | token.matches[0].replace( runescape, funescape ),
|
| 4916 | rsibling.test( tokens[0].type ) && context.parentNode || context
|
| 4917 | )) ) {
|
| 4918 |
|
| 4919 | // If seed is empty or no tokens remain, we can return early
|
| 4920 | tokens.splice( i, 1 );
|
| 4921 | selector = seed.length && toSelector( tokens );
|
| 4922 | if ( !selector ) {
|
| 4923 | push.apply( results, seed );
|
| 4924 | return results;
|
| 4925 | }
|
| 4926 |
|
| 4927 | break;
|
| 4928 | }
|
| 4929 | }
|
| 4930 | }
|
| 4931 | }
|
| 4932 | }
|
| 4933 |
|
| 4934 | // Compile and execute a filtering function
|
| 4935 | // Provide `match` to avoid retokenization if we modified the selector above
|
| 4936 | compile( selector, match )(
|
| 4937 | seed,
|
| 4938 | context,
|
| 4939 | !documentIsHTML,
|
| 4940 | results,
|
| 4941 | rsibling.test( selector )
|
| 4942 | );
|
| 4943 | return results;
|
| 4944 | }
|
| 4945 |
|
| 4946 | // One-time assignments
|
| 4947 |
|
| 4948 | // Sort stability
|
| 4949 | support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
|
| 4950 |
|
| 4951 | // Support: Chrome<14
|
| 4952 | // Always assume duplicates if they aren't passed to the comparison function
|
| 4953 | support.detectDuplicates = hasDuplicate;
|
| 4954 |
|
| 4955 | // Initialize against the default document
|
| 4956 | setDocument();
|
| 4957 |
|
| 4958 | // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
|
| 4959 | // Detached nodes confoundingly follow *each other*
|
| 4960 | support.sortDetached = assert(function( div1 ) {
|
| 4961 | // Should return 1, but returns 4 (following)
|
| 4962 | return div1.compareDocumentPosition( document.createElement("div") ) & 1;
|
| 4963 | });
|
| 4964 |
|
| 4965 | // Support: IE<8
|
| 4966 | // Prevent attribute/property "interpolation"
|
| 4967 | // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
| 4968 | if ( !assert(function( div ) {
|
| 4969 | div.innerHTML = "<a href='#'></a>";
|
| 4970 | return div.firstChild.getAttribute("href") === "#" ;
|
| 4971 | }) ) {
|
| 4972 | addHandle( "type|href|height|width", function( elem, name, isXML ) {
|
| 4973 | if ( !isXML ) {
|
| 4974 | return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
|
| 4975 | }
|
| 4976 | });
|
| 4977 | }
|
| 4978 |
|
| 4979 | // Support: IE<9
|
| 4980 | // Use defaultValue in place of getAttribute("value")
|
| 4981 | if ( !support.attributes || !assert(function( div ) {
|
| 4982 | div.innerHTML = "<input/>";
|
| 4983 | div.firstChild.setAttribute( "value", "" );
|
| 4984 | return div.firstChild.getAttribute( "value" ) === "";
|
| 4985 | }) ) {
|
| 4986 | addHandle( "value", function( elem, name, isXML ) {
|
| 4987 | if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
|
| 4988 | return elem.defaultValue;
|
| 4989 | }
|
| 4990 | });
|
| 4991 | }
|
| 4992 |
|
| 4993 | // Support: IE<9
|
| 4994 | // Use getAttributeNode to fetch booleans when getAttribute lies
|
| 4995 | if ( !assert(function( div ) {
|
| 4996 | return div.getAttribute("disabled") == null;
|
| 4997 | }) ) {
|
| 4998 | addHandle( booleans, function( elem, name, isXML ) {
|
| 4999 | var val;
|
| 5000 | if ( !isXML ) {
|
| 5001 | return (val = elem.getAttributeNode( name )) && val.specified ?
|
| 5002 | val.value :
|
| 5003 | elem[ name ] === true ? name.toLowerCase() : null;
|
| 5004 | }
|
| 5005 | });
|
| 5006 | }
|
| 5007 |
|
| 5008 | jQuery.find = Sizzle;
|
| 5009 | jQuery.expr = Sizzle.selectors;
|
| 5010 | jQuery.expr[":"] = jQuery.expr.pseudos;
|
| 5011 | jQuery.unique = Sizzle.uniqueSort;
|
| 5012 | jQuery.text = Sizzle.getText;
|
| 5013 | jQuery.isXMLDoc = Sizzle.isXML;
|
| 5014 | jQuery.contains = Sizzle.contains;
|
| 5015 |
|
| 5016 |
|
| 5017 | })( window );
|
| 5018 | // String to Object options format cache
|
| 5019 | var optionsCache = {};
|
| 5020 |
|
| 5021 | // Convert String-formatted options into Object-formatted ones and store in cache
|
| 5022 | function createOptions( options ) {
|
| 5023 | var object = optionsCache[ options ] = {};
|
| 5024 | jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
|
| 5025 | object[ flag ] = true;
|
| 5026 | });
|
| 5027 | return object;
|
| 5028 | }
|
| 5029 |
|
| 5030 | /*
|
| 5031 | * Create a callback list using the following parameters:
|
| 5032 | *
|
| 5033 | * options: an optional list of space-separated options that will change how
|
| 5034 | * the callback list behaves or a more traditional option object
|
| 5035 | *
|
| 5036 | * By default a callback list will act like an event callback list and can be
|
| 5037 | * "fired" multiple times.
|
| 5038 | *
|
| 5039 | * Possible options:
|
| 5040 | *
|
| 5041 | * once: will ensure the callback list can only be fired once (like a Deferred)
|
| 5042 | *
|
| 5043 | * memory: will keep track of previous values and will call any callback added
|
| 5044 | * after the list has been fired right away with the latest "memorized"
|
| 5045 | * values (like a Deferred)
|
| 5046 | *
|
| 5047 | * unique: will ensure a callback can only be added once (no duplicate in the list)
|
| 5048 | *
|
| 5049 | * stopOnFalse: interrupt callings when a callback returns false
|
| 5050 | *
|
| 5051 | */
|
| 5052 | jQuery.Callbacks = function( options ) {
|
| 5053 |
|
| 5054 | // Convert options from String-formatted to Object-formatted if needed
|
| 5055 | // (we check in cache first)
|
| 5056 | options = typeof options === "string" ?
|
| 5057 | ( optionsCache[ options ] || createOptions( options ) ) :
|
| 5058 | jQuery.extend( {}, options );
|
| 5059 |
|
| 5060 | var // Flag to know if list is currently firing
|
| 5061 | firing,
|
| 5062 | // Last fire value (for non-forgettable lists)
|
| 5063 | memory,
|
| 5064 | // Flag to know if list was already fired
|
| 5065 | fired,
|
| 5066 | // End of the loop when firing
|
| 5067 | firingLength,
|
| 5068 | // Index of currently firing callback (modified by remove if needed)
|
| 5069 | firingIndex,
|
| 5070 | // First callback to fire (used internally by add and fireWith)
|
| 5071 | firingStart,
|
| 5072 | // Actual callback list
|
| 5073 | list = [],
|
| 5074 | // Stack of fire calls for repeatable lists
|
| 5075 | stack = !options.once && [],
|
| 5076 | // Fire callbacks
|
| 5077 | fire = function( data ) {
|
| 5078 | memory = options.memory && data;
|
| 5079 | fired = true;
|
| 5080 | firingIndex = firingStart || 0;
|
| 5081 | firingStart = 0;
|
| 5082 | firingLength = list.length;
|
| 5083 | firing = true;
|
| 5084 | for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
| 5085 | if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
|
| 5086 | memory = false; // To prevent further calls using add
|
| 5087 | break;
|
| 5088 | }
|
| 5089 | }
|
| 5090 | firing = false;
|
| 5091 | if ( list ) {
|
| 5092 | if ( stack ) {
|
| 5093 | if ( stack.length ) {
|
| 5094 | fire( stack.shift() );
|
| 5095 | }
|
| 5096 | } else if ( memory ) {
|
| 5097 | list = [];
|
| 5098 | } else {
|
| 5099 | self.disable();
|
| 5100 | }
|
| 5101 | }
|
| 5102 | },
|
| 5103 | // Actual Callbacks object
|
| 5104 | self = {
|
| 5105 | // Add a callback or a collection of callbacks to the list
|
| 5106 | add: function() {
|
| 5107 | if ( list ) {
|
| 5108 | // First, we save the current length
|
| 5109 | var start = list.length;
|
| 5110 | (function add( args ) {
|
| 5111 | jQuery.each( args, function( _, arg ) {
|
| 5112 | var type = jQuery.type( arg );
|
| 5113 | if ( type === "function" ) {
|
| 5114 | if ( !options.unique || !self.has( arg ) ) {
|
| 5115 | list.push( arg );
|
| 5116 | }
|
| 5117 | } else if ( arg && arg.length && type !== "string" ) {
|
| 5118 | // Inspect recursively
|
| 5119 | add( arg );
|
| 5120 | }
|
| 5121 | });
|
| 5122 | })( arguments );
|
| 5123 | // Do we need to add the callbacks to the
|
| 5124 | // current firing batch?
|
| 5125 | if ( firing ) {
|
| 5126 | firingLength = list.length;
|
| 5127 | // With memory, if we're not firing then
|
| 5128 | // we should call right away
|
| 5129 | } else if ( memory ) {
|
| 5130 | firingStart = start;
|
| 5131 | fire( memory );
|
| 5132 | }
|
| 5133 | }
|
| 5134 | return this;
|
| 5135 | },
|
| 5136 | // Remove a callback from the list
|
| 5137 | remove: function() {
|
| 5138 | if ( list ) {
|
| 5139 | jQuery.each( arguments, function( _, arg ) {
|
| 5140 | var index;
|
| 5141 | while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
|
| 5142 | list.splice( index, 1 );
|
| 5143 | // Handle firing indexes
|
| 5144 | if ( firing ) {
|
| 5145 | if ( index <= firingLength ) {
|
| 5146 | firingLength--;
|
| 5147 | }
|
| 5148 | if ( index <= firingIndex ) {
|
| 5149 | firingIndex--;
|
| 5150 | }
|
| 5151 | }
|
| 5152 | }
|
| 5153 | });
|
| 5154 | }
|
| 5155 | return this;
|
| 5156 | },
|
| 5157 | // Check if a given callback is in the list.
|
| 5158 | // If no argument is given, return whether or not list has callbacks attached.
|
| 5159 | has: function( fn ) {
|
| 5160 | return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
|
| 5161 | },
|
| 5162 | // Remove all callbacks from the list
|
| 5163 | empty: function() {
|
| 5164 | list = [];
|
| 5165 | firingLength = 0;
|
| 5166 | return this;
|
| 5167 | },
|
| 5168 | // Have the list do nothing anymore
|
| 5169 | disable: function() {
|
| 5170 | list = stack = memory = undefined;
|
| 5171 | return this;
|
| 5172 | },
|
| 5173 | // Is it disabled?
|
| 5174 | disabled: function() {
|
| 5175 | return !list;
|
| 5176 | },
|
| 5177 | // Lock the list in its current state
|
| 5178 | lock: function() {
|
| 5179 | stack = undefined;
|
| 5180 | if ( !memory ) {
|
| 5181 | self.disable();
|
| 5182 | }
|
| 5183 | return this;
|
| 5184 | },
|
| 5185 | // Is it locked?
|
| 5186 | locked: function() {
|
| 5187 | return !stack;
|
| 5188 | },
|
| 5189 | // Call all callbacks with the given context and arguments
|
| 5190 | fireWith: function( context, args ) {
|
| 5191 | if ( list && ( !fired || stack ) ) {
|
| 5192 | args = args || [];
|
| 5193 | args = [ context, args.slice ? args.slice() : args ];
|
| 5194 | if ( firing ) {
|
| 5195 | stack.push( args );
|
| 5196 | } else {
|
| 5197 | fire( args );
|
| 5198 | }
|
| 5199 | }
|
| 5200 | return this;
|
| 5201 | },
|
| 5202 | // Call all the callbacks with the given arguments
|
| 5203 | fire: function() {
|
| 5204 | self.fireWith( this, arguments );
|
| 5205 | return this;
|
| 5206 | },
|
| 5207 | // To know if the callbacks have already been called at least once
|
| 5208 | fired: function() {
|
| 5209 | return !!fired;
|
| 5210 | }
|
| 5211 | };
|
| 5212 |
|
| 5213 | return self;
|
| 5214 | };
|
| 5215 | jQuery.extend({
|
| 5216 |
|
| 5217 | Deferred: function( func ) {
|
| 5218 | var tuples = [
|
| 5219 | // action, add listener, listener list, final state
|
| 5220 | [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
|
| 5221 | [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
|
| 5222 | [ "notify", "progress", jQuery.Callbacks("memory") ]
|
| 5223 | ],
|
| 5224 | state = "pending",
|
| 5225 | promise = {
|
| 5226 | state: function() {
|
| 5227 | return state;
|
| 5228 | },
|
| 5229 | always: function() {
|
| 5230 | deferred.done( arguments ).fail( arguments );
|
| 5231 | return this;
|
| 5232 | },
|
| 5233 | then: function( /* fnDone, fnFail, fnProgress */ ) {
|
| 5234 | var fns = arguments;
|
| 5235 | return jQuery.Deferred(function( newDefer ) {
|
| 5236 | jQuery.each( tuples, function( i, tuple ) {
|
| 5237 | var action = tuple[ 0 ],
|
| 5238 | fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
| 5239 | // deferred[ done | fail | progress ] for forwarding actions to newDefer
|
| 5240 | deferred[ tuple[1] ](function() {
|
| 5241 | var returned = fn && fn.apply( this, arguments );
|
| 5242 | if ( returned && jQuery.isFunction( returned.promise ) ) {
|
| 5243 | returned.promise()
|
| 5244 | .done( newDefer.resolve )
|
| 5245 | .fail( newDefer.reject )
|
| 5246 | .progress( newDefer.notify );
|
| 5247 | } else {
|
| 5248 | newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
|
| 5249 | }
|
| 5250 | });
|
| 5251 | });
|
| 5252 | fns = null;
|
| 5253 | }).promise();
|
| 5254 | },
|
| 5255 | // Get a promise for this deferred
|
| 5256 | // If obj is provided, the promise aspect is added to the object
|
| 5257 | promise: function( obj ) {
|
| 5258 | return obj != null ? jQuery.extend( obj, promise ) : promise;
|
| 5259 | }
|
| 5260 | },
|
| 5261 | deferred = {};
|
| 5262 |
|
| 5263 | // Keep pipe for back-compat
|
| 5264 | promise.pipe = promise.then;
|
| 5265 |
|
| 5266 | // Add list-specific methods
|
| 5267 | jQuery.each( tuples, function( i, tuple ) {
|
| 5268 | var list = tuple[ 2 ],
|
| 5269 | stateString = tuple[ 3 ];
|
| 5270 |
|
| 5271 | // promise[ done | fail | progress ] = list.add
|
| 5272 | promise[ tuple[1] ] = list.add;
|
| 5273 |
|
| 5274 | // Handle state
|
| 5275 | if ( stateString ) {
|
| 5276 | list.add(function() {
|
| 5277 | // state = [ resolved | rejected ]
|
| 5278 | state = stateString;
|
| 5279 |
|
| 5280 | // [ reject_list | resolve_list ].disable; progress_list.lock
|
| 5281 | }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
|
| 5282 | }
|
| 5283 |
|
| 5284 | // deferred[ resolve | reject | notify ]
|
| 5285 | deferred[ tuple[0] ] = function() {
|
| 5286 | deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
|
| 5287 | return this;
|
| 5288 | };
|
| 5289 | deferred[ tuple[0] + "With" ] = list.fireWith;
|
| 5290 | });
|
| 5291 |
|
| 5292 | // Make the deferred a promise
|
| 5293 | promise.promise( deferred );
|
| 5294 |
|
| 5295 | // Call given func if any
|
| 5296 | if ( func ) {
|
| 5297 | func.call( deferred, deferred );
|
| 5298 | }
|
| 5299 |
|
| 5300 | // All done!
|
| 5301 | return deferred;
|
| 5302 | },
|
| 5303 |
|
| 5304 | // Deferred helper
|
| 5305 | when: function( subordinate /* , ..., subordinateN */ ) {
|
| 5306 | var i = 0,
|
| 5307 | resolveValues = core_slice.call( arguments ),
|
| 5308 | length = resolveValues.length,
|
| 5309 |
|
| 5310 | // the count of uncompleted subordinates
|
| 5311 | remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
|
| 5312 |
|
| 5313 | // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
|
| 5314 | deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
|
| 5315 |
|
| 5316 | // Update function for both resolve and progress values
|
| 5317 | updateFunc = function( i, contexts, values ) {
|
| 5318 | return function( value ) {
|
| 5319 | contexts[ i ] = this;
|
| 5320 | values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
|
| 5321 | if( values === progressValues ) {
|
| 5322 | deferred.notifyWith( contexts, values );
|
| 5323 | } else if ( !( --remaining ) ) {
|
| 5324 | deferred.resolveWith( contexts, values );
|
| 5325 | }
|
| 5326 | };
|
| 5327 | },
|
| 5328 |
|
| 5329 | progressValues, progressContexts, resolveContexts;
|
| 5330 |
|
| 5331 | // add listeners to Deferred subordinates; treat others as resolved
|
| 5332 | if ( length > 1 ) {
|
| 5333 | progressValues = new Array( length );
|
| 5334 | progressContexts = new Array( length );
|
| 5335 | resolveContexts = new Array( length );
|
| 5336 | for ( ; i < length; i++ ) {
|
| 5337 | if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
|
| 5338 | resolveValues[ i ].promise()
|
| 5339 | .done( updateFunc( i, resolveContexts, resolveValues ) )
|
| 5340 | .fail( deferred.reject )
|
| 5341 | .progress( updateFunc( i, progressContexts, progressValues ) );
|
| 5342 | } else {
|
| 5343 | --remaining;
|
| 5344 | }
|
| 5345 | }
|
| 5346 | }
|
| 5347 |
|
| 5348 | // if we're not waiting on anything, resolve the master
|
| 5349 | if ( !remaining ) {
|
| 5350 | deferred.resolveWith( resolveContexts, resolveValues );
|
| 5351 | }
|
| 5352 |
|
| 5353 | return deferred.promise();
|
| 5354 | }
|
| 5355 | });
|
| 5356 | jQuery.support = (function( support ) {
|
| 5357 |
|
| 5358 | var all, a, input, select, fragment, opt, eventName, isSupported, i,
|
| 5359 | div = document.createElement("div");
|
| 5360 |
|
| 5361 | // Setup
|
| 5362 | div.setAttribute( "className", "t" );
|
| 5363 | div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
|
| 5364 |
|
| 5365 | // Finish early in limited (non-browser) environments
|
| 5366 | all = div.getElementsByTagName("*") || [];
|
| 5367 | a = div.getElementsByTagName("a")[ 0 ];
|
| 5368 | if ( !a || !a.style || !all.length ) {
|
| 5369 | return support;
|
| 5370 | }
|
| 5371 |
|
| 5372 | // First batch of tests
|
| 5373 | select = document.createElement("select");
|
| 5374 | opt = select.appendChild( document.createElement("option") );
|
| 5375 | input = div.getElementsByTagName("input")[ 0 ];
|
| 5376 |
|
| 5377 | a.style.cssText = "top:1px;float:left;opacity:.5";
|
| 5378 |
|
| 5379 | // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
| 5380 | support.getSetAttribute = div.className !== "t";
|
| 5381 |
|
| 5382 | // IE strips leading whitespace when .innerHTML is used
|
| 5383 | support.leadingWhitespace = div.firstChild.nodeType === 3;
|
| 5384 |
|
| 5385 | // Make sure that tbody elements aren't automatically inserted
|
| 5386 | // IE will insert them into empty tables
|
| 5387 | support.tbody = !div.getElementsByTagName("tbody").length;
|
| 5388 |
|
| 5389 | // Make sure that link elements get serialized correctly by innerHTML
|
| 5390 | // This requires a wrapper element in IE
|
| 5391 | support.htmlSerialize = !!div.getElementsByTagName("link").length;
|
| 5392 |
|
| 5393 | // Get the style information from getAttribute
|
| 5394 | // (IE uses .cssText instead)
|
| 5395 | support.style = /top/.test( a.getAttribute("style") );
|
| 5396 |
|
| 5397 | // Make sure that URLs aren't manipulated
|
| 5398 | // (IE normalizes it by default)
|
| 5399 | support.hrefNormalized = a.getAttribute("href") === "/a";
|
| 5400 |
|
| 5401 | // Make sure that element opacity exists
|
| 5402 | // (IE uses filter instead)
|
| 5403 | // Use a regex to work around a WebKit issue. See #5145
|
| 5404 | support.opacity = /^0.5/.test( a.style.opacity );
|
| 5405 |
|
| 5406 | // Verify style float existence
|
| 5407 | // (IE uses styleFloat instead of cssFloat)
|
| 5408 | support.cssFloat = !!a.style.cssFloat;
|
| 5409 |
|
| 5410 | // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
|
| 5411 | support.checkOn = !!input.value;
|
| 5412 |
|
| 5413 | // Make sure that a selected-by-default option has a working selected property.
|
| 5414 | // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
|
| 5415 | support.optSelected = opt.selected;
|
| 5416 |
|
| 5417 | // Tests for enctype support on a form (#6743)
|
| 5418 | support.enctype = !!document.createElement("form").enctype;
|
| 5419 |
|
| 5420 | // Makes sure cloning an html5 element does not cause problems
|
| 5421 | // Where outerHTML is undefined, this still works
|
| 5422 | support.html5Clone = document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>";
|
| 5423 |
|
| 5424 | // Will be defined later
|
| 5425 | support.inlineBlockNeedsLayout = false;
|
| 5426 | support.shrinkWrapBlocks = false;
|
| 5427 | support.pixelPosition = false;
|
| 5428 | support.deleteExpando = true;
|
| 5429 | support.noCloneEvent = true;
|
| 5430 | support.reliableMarginRight = true;
|
| 5431 | support.boxSizingReliable = true;
|
| 5432 |
|
| 5433 | // Make sure checked status is properly cloned
|
| 5434 | input.checked = true;
|
| 5435 | support.noCloneChecked = input.cloneNode( true ).checked;
|
| 5436 |
|
| 5437 | // Make sure that the options inside disabled selects aren't marked as disabled
|
| 5438 | // (WebKit marks them as disabled)
|
| 5439 | select.disabled = true;
|
| 5440 | support.optDisabled = !opt.disabled;
|
| 5441 |
|
| 5442 | // Support: IE<9
|
| 5443 | try {
|
| 5444 | delete div.test;
|
| 5445 | } catch( e ) {
|
| 5446 | support.deleteExpando = false;
|
| 5447 | }
|
| 5448 |
|
| 5449 | // Check if we can trust getAttribute("value")
|
| 5450 | input = document.createElement("input");
|
| 5451 | input.setAttribute( "value", "" );
|
| 5452 | support.input = input.getAttribute( "value" ) === "";
|
| 5453 |
|
| 5454 | // Check if an input maintains its value after becoming a radio
|
| 5455 | input.value = "t";
|
| 5456 | input.setAttribute( "type", "radio" );
|
| 5457 | support.radioValue = input.value === "t";
|
| 5458 |
|
| 5459 | // #11217 - WebKit loses check when the name is after the checked attribute
|
| 5460 | input.setAttribute( "checked", "t" );
|
| 5461 | input.setAttribute( "name", "t" );
|
| 5462 |
|
| 5463 | fragment = document.createDocumentFragment();
|
| 5464 | fragment.appendChild( input );
|
| 5465 |
|
| 5466 | // Check if a disconnected checkbox will retain its checked
|
| 5467 | // value of true after appended to the DOM (IE6/7)
|
| 5468 | support.appendChecked = input.checked;
|
| 5469 |
|
| 5470 | // WebKit doesn't clone checked state correctly in fragments
|
| 5471 | support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
|
| 5472 |
|
| 5473 | // Support: IE<9
|
| 5474 | // Opera does not clone events (and typeof div.attachEvent === undefined).
|
| 5475 | // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
|
| 5476 | if ( div.attachEvent ) {
|
| 5477 | div.attachEvent( "onclick", function() {
|
| 5478 | support.noCloneEvent = false;
|
| 5479 | });
|
| 5480 |
|
| 5481 | div.cloneNode( true ).click();
|
| 5482 | }
|
| 5483 |
|
| 5484 | // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
|
| 5485 | // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
|
| 5486 | for ( i in { submit: true, change: true, focusin: true }) {
|
| 5487 | div.setAttribute( eventName = "on" + i, "t" );
|
| 5488 |
|
| 5489 | support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
|
| 5490 | }
|
| 5491 |
|
| 5492 | div.style.backgroundClip = "content-box";
|
| 5493 | div.cloneNode( true ).style.backgroundClip = "";
|
| 5494 | support.clearCloneStyle = div.style.backgroundClip === "content-box";
|
| 5495 |
|
| 5496 | // Support: IE<9
|
| 5497 | // Iteration over object's inherited properties before its own.
|
| 5498 | for ( i in jQuery( support ) ) {
|
| 5499 | break;
|
| 5500 | }
|
| 5501 | support.ownLast = i !== "0";
|
| 5502 |
|
| 5503 | // Run tests that need a body at doc ready
|
| 5504 | jQuery(function() {
|
| 5505 | var container, marginDiv, tds,
|
| 5506 | divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
|
| 5507 | body = document.getElementsByTagName("body")[0];
|
| 5508 |
|
| 5509 | if ( !body ) {
|
| 5510 | // Return for frameset docs that don't have a body
|
| 5511 | return;
|
| 5512 | }
|
| 5513 |
|
| 5514 | container = document.createElement("div");
|
| 5515 | container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
|
| 5516 |
|
| 5517 | body.appendChild( container ).appendChild( div );
|
| 5518 |
|
| 5519 | // Support: IE8
|
| 5520 | // Check if table cells still have offsetWidth/Height when they are set
|
| 5521 | // to display:none and there are still other visible table cells in a
|
| 5522 | // table row; if so, offsetWidth/Height are not reliable for use when
|
| 5523 | // determining if an element has been hidden directly using
|
| 5524 | // display:none (it is still safe to use offsets if a parent element is
|
| 5525 | // hidden; don safety goggles and see bug #4512 for more information).
|
| 5526 | div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
|
| 5527 | tds = div.getElementsByTagName("td");
|
| 5528 | tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
|
| 5529 | isSupported = ( tds[ 0 ].offsetHeight === 0 );
|
| 5530 |
|
| 5531 | tds[ 0 ].style.display = "";
|
| 5532 | tds[ 1 ].style.display = "none";
|
| 5533 |
|
| 5534 | // Support: IE8
|
| 5535 | // Check if empty table cells still have offsetWidth/Height
|
| 5536 | support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
|
| 5537 |
|
| 5538 | // Check box-sizing and margin behavior.
|
| 5539 | div.innerHTML = "";
|
| 5540 | div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
|
| 5541 |
|
| 5542 | // Workaround failing boxSizing test due to offsetWidth returning wrong value
|
| 5543 | // with some non-1 values of body zoom, ticket #13543
|
| 5544 | jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
|
| 5545 | support.boxSizing = div.offsetWidth === 4;
|
| 5546 | });
|
| 5547 |
|
| 5548 | // Use window.getComputedStyle because jsdom on node.js will break without it.
|
| 5549 | if ( window.getComputedStyle ) {
|
| 5550 | support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
|
| 5551 | support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
|
| 5552 |
|
| 5553 | // Check if div with explicit width and no margin-right incorrectly
|
| 5554 | // gets computed margin-right based on width of container. (#3333)
|
| 5555 | // Fails in WebKit before Feb 2011 nightlies
|
| 5556 | // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
| 5557 | marginDiv = div.appendChild( document.createElement("div") );
|
| 5558 | marginDiv.style.cssText = div.style.cssText = divReset;
|
| 5559 | marginDiv.style.marginRight = marginDiv.style.width = "0";
|
| 5560 | div.style.width = "1px";
|
| 5561 |
|
| 5562 | support.reliableMarginRight =
|
| 5563 | !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
|
| 5564 | }
|
| 5565 |
|
| 5566 | if ( typeof div.style.zoom !== core_strundefined ) {
|
| 5567 | // Support: IE<8
|
| 5568 | // Check if natively block-level elements act like inline-block
|
| 5569 | // elements when setting their display to 'inline' and giving
|
| 5570 | // them layout
|
| 5571 | div.innerHTML = "";
|
| 5572 | div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
|
| 5573 | support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
|
| 5574 |
|
| 5575 | // Support: IE6
|
| 5576 | // Check if elements with layout shrink-wrap their children
|
| 5577 | div.style.display = "block";
|
| 5578 | div.innerHTML = "<div></div>";
|
| 5579 | div.firstChild.style.width = "5px";
|
| 5580 | support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
|
| 5581 |
|
| 5582 | if ( support.inlineBlockNeedsLayout ) {
|
| 5583 | // Prevent IE 6 from affecting layout for positioned elements #11048
|
| 5584 | // Prevent IE from shrinking the body in IE 7 mode #12869
|
| 5585 | // Support: IE<8
|
| 5586 | body.style.zoom = 1;
|
| 5587 | }
|
| 5588 | }
|
| 5589 |
|
| 5590 | body.removeChild( container );
|
| 5591 |
|
| 5592 | // Null elements to avoid leaks in IE
|
| 5593 | container = div = tds = marginDiv = null;
|
| 5594 | });
|
| 5595 |
|
| 5596 | // Null elements to avoid leaks in IE
|
| 5597 | all = select = fragment = opt = a = input = null;
|
| 5598 |
|
| 5599 | return support;
|
| 5600 | })({});
|
| 5601 |
|
| 5602 | var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
|
| 5603 | rmultiDash = /([A-Z])/g;
|
| 5604 |
|
| 5605 | function internalData( elem, name, data, pvt /* Internal Use Only */ ){
|
| 5606 | if ( !jQuery.acceptData( elem ) ) {
|
| 5607 | return;
|
| 5608 | }
|
| 5609 |
|
| 5610 | var ret, thisCache,
|
| 5611 | internalKey = jQuery.expando,
|
| 5612 |
|
| 5613 | // We have to handle DOM nodes and JS objects differently because IE6-7
|
| 5614 | // can't GC object references properly across the DOM-JS boundary
|
| 5615 | isNode = elem.nodeType,
|
| 5616 |
|
| 5617 | // Only DOM nodes need the global jQuery cache; JS object data is
|
| 5618 | // attached directly to the object so GC can occur automatically
|
| 5619 | cache = isNode ? jQuery.cache : elem,
|
| 5620 |
|
| 5621 | // Only defining an ID for JS objects if its cache already exists allows
|
| 5622 | // the code to shortcut on the same path as a DOM node with no cache
|
| 5623 | id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
|
| 5624 |
|
| 5625 | // Avoid doing any more work than we need to when trying to get data on an
|
| 5626 | // object that has no data at all
|
| 5627 | if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
|
| 5628 | return;
|
| 5629 | }
|
| 5630 |
|
| 5631 | if ( !id ) {
|
| 5632 | // Only DOM nodes need a new unique ID for each element since their data
|
| 5633 | // ends up in the global cache
|
| 5634 | if ( isNode ) {
|
| 5635 | id = elem[ internalKey ] = core_deletedIds.pop() || jQuery.guid++;
|
| 5636 | } else {
|
| 5637 | id = internalKey;
|
| 5638 | }
|
| 5639 | }
|
| 5640 |
|
| 5641 | if ( !cache[ id ] ) {
|
| 5642 | // Avoid exposing jQuery metadata on plain JS objects when the object
|
| 5643 | // is serialized using JSON.stringify
|
| 5644 | cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
|
| 5645 | }
|
| 5646 |
|
| 5647 | // An object can be passed to jQuery.data instead of a key/value pair; this gets
|
| 5648 | // shallow copied over onto the existing cache
|
| 5649 | if ( typeof name === "object" || typeof name === "function" ) {
|
| 5650 | if ( pvt ) {
|
| 5651 | cache[ id ] = jQuery.extend( cache[ id ], name );
|
| 5652 | } else {
|
| 5653 | cache[ id ].data = jQuery.extend( cache[ id ].data, name );
|
| 5654 | }
|
| 5655 | }
|
| 5656 |
|
| 5657 | thisCache = cache[ id ];
|
| 5658 |
|
| 5659 | // jQuery data() is stored in a separate object inside the object's internal data
|
| 5660 | // cache in order to avoid key collisions between internal data and user-defined
|
| 5661 | // data.
|
| 5662 | if ( !pvt ) {
|
| 5663 | if ( !thisCache.data ) {
|
| 5664 | thisCache.data = {};
|
| 5665 | }
|
| 5666 |
|
| 5667 | thisCache = thisCache.data;
|
| 5668 | }
|
| 5669 |
|
| 5670 | if ( data !== undefined ) {
|
| 5671 | thisCache[ jQuery.camelCase( name ) ] = data;
|
| 5672 | }
|
| 5673 |
|
| 5674 | // Check for both converted-to-camel and non-converted data property names
|
| 5675 | // If a data property was specified
|
| 5676 | if ( typeof name === "string" ) {
|
| 5677 |
|
| 5678 | // First Try to find as-is property data
|
| 5679 | ret = thisCache[ name ];
|
| 5680 |
|
| 5681 | // Test for null|undefined property data
|
| 5682 | if ( ret == null ) {
|
| 5683 |
|
| 5684 | // Try to find the camelCased property
|
| 5685 | ret = thisCache[ jQuery.camelCase( name ) ];
|
| 5686 | }
|
| 5687 | } else {
|
| 5688 | ret = thisCache;
|
| 5689 | }
|
| 5690 |
|
| 5691 | return ret;
|
| 5692 | }
|
| 5693 |
|
| 5694 | function internalRemoveData( elem, name, pvt ) {
|
| 5695 | if ( !jQuery.acceptData( elem ) ) {
|
| 5696 | return;
|
| 5697 | }
|
| 5698 |
|
| 5699 | var thisCache, i,
|
| 5700 | isNode = elem.nodeType,
|
| 5701 |
|
| 5702 | // See jQuery.data for more information
|
| 5703 | cache = isNode ? jQuery.cache : elem,
|
| 5704 | id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
|
| 5705 |
|
| 5706 | // If there is already no cache entry for this object, there is no
|
| 5707 | // purpose in continuing
|
| 5708 | if ( !cache[ id ] ) {
|
| 5709 | return;
|
| 5710 | }
|
| 5711 |
|
| 5712 | if ( name ) {
|
| 5713 |
|
| 5714 | thisCache = pvt ? cache[ id ] : cache[ id ].data;
|
| 5715 |
|
| 5716 | if ( thisCache ) {
|
| 5717 |
|
| 5718 | // Support array or space separated string names for data keys
|
| 5719 | if ( !jQuery.isArray( name ) ) {
|
| 5720 |
|
| 5721 | // try the string as a key before any manipulation
|
| 5722 | if ( name in thisCache ) {
|
| 5723 | name = [ name ];
|
| 5724 | } else {
|
| 5725 |
|
| 5726 | // split the camel cased version by spaces unless a key with the spaces exists
|
| 5727 | name = jQuery.camelCase( name );
|
| 5728 | if ( name in thisCache ) {
|
| 5729 | name = [ name ];
|
| 5730 | } else {
|
| 5731 | name = name.split(" ");
|
| 5732 | }
|
| 5733 | }
|
| 5734 | } else {
|
| 5735 | // If "name" is an array of keys...
|
| 5736 | // When data is initially created, via ("key", "val") signature,
|
| 5737 | // keys will be converted to camelCase.
|
| 5738 | // Since there is no way to tell _how_ a key was added, remove
|
| 5739 | // both plain key and camelCase key. #12786
|
| 5740 | // This will only penalize the array argument path.
|
| 5741 | name = name.concat( jQuery.map( name, jQuery.camelCase ) );
|
| 5742 | }
|
| 5743 |
|
| 5744 | i = name.length;
|
| 5745 | while ( i-- ) {
|
| 5746 | delete thisCache[ name[i] ];
|
| 5747 | }
|
| 5748 |
|
| 5749 | // If there is no data left in the cache, we want to continue
|
| 5750 | // and let the cache object itself get destroyed
|
| 5751 | if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
|
| 5752 | return;
|
| 5753 | }
|
| 5754 | }
|
| 5755 | }
|
| 5756 |
|
| 5757 | // See jQuery.data for more information
|
| 5758 | if ( !pvt ) {
|
| 5759 | delete cache[ id ].data;
|
| 5760 |
|
| 5761 | // Don't destroy the parent cache unless the internal data object
|
| 5762 | // had been the only thing left in it
|
| 5763 | if ( !isEmptyDataObject( cache[ id ] ) ) {
|
| 5764 | return;
|
| 5765 | }
|
| 5766 | }
|
| 5767 |
|
| 5768 | // Destroy the cache
|
| 5769 | if ( isNode ) {
|
| 5770 | jQuery.cleanData( [ elem ], true );
|
| 5771 |
|
| 5772 | // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
|
| 5773 | /* jshint eqeqeq: false */
|
| 5774 | } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
|
| 5775 | /* jshint eqeqeq: true */
|
| 5776 | delete cache[ id ];
|
| 5777 |
|
| 5778 | // When all else fails, null
|
| 5779 | } else {
|
| 5780 | cache[ id ] = null;
|
| 5781 | }
|
| 5782 | }
|
| 5783 |
|
| 5784 | jQuery.extend({
|
| 5785 | cache: {},
|
| 5786 |
|
| 5787 | // The following elements throw uncatchable exceptions if you
|
| 5788 | // attempt to add expando properties to them.
|
| 5789 | noData: {
|
| 5790 | "applet": true,
|
| 5791 | "embed": true,
|
| 5792 | // Ban all objects except for Flash (which handle expandos)
|
| 5793 | "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
| 5794 | },
|
| 5795 |
|
| 5796 | hasData: function( elem ) {
|
| 5797 | elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
|
| 5798 | return !!elem && !isEmptyDataObject( elem );
|
| 5799 | },
|
| 5800 |
|
| 5801 | data: function( elem, name, data ) {
|
| 5802 | return internalData( elem, name, data );
|
| 5803 | },
|
| 5804 |
|
| 5805 | removeData: function( elem, name ) {
|
| 5806 | return internalRemoveData( elem, name );
|
| 5807 | },
|
| 5808 |
|
| 5809 | // For internal use only.
|
| 5810 | _data: function( elem, name, data ) {
|
| 5811 | return internalData( elem, name, data, true );
|
| 5812 | },
|
| 5813 |
|
| 5814 | _removeData: function( elem, name ) {
|
| 5815 | return internalRemoveData( elem, name, true );
|
| 5816 | },
|
| 5817 |
|
| 5818 | // A method for determining if a DOM node can handle the data expando
|
| 5819 | acceptData: function( elem ) {
|
| 5820 | // Do not set data on non-element because it will not be cleared (#8335).
|
| 5821 | if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
|
| 5822 | return false;
|
| 5823 | }
|
| 5824 |
|
| 5825 | var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
|
| 5826 |
|
| 5827 | // nodes accept data unless otherwise specified; rejection can be conditional
|
| 5828 | return !noData || noData !== true && elem.getAttribute("classid") === noData;
|
| 5829 | }
|
| 5830 | });
|
| 5831 |
|
| 5832 | jQuery.fn.extend({
|
| 5833 | data: function( key, value ) {
|
| 5834 | var attrs, name,
|
| 5835 | data = null,
|
| 5836 | i = 0,
|
| 5837 | elem = this[0];
|
| 5838 |
|
| 5839 | // Special expections of .data basically thwart jQuery.access,
|
| 5840 | // so implement the relevant behavior ourselves
|
| 5841 |
|
| 5842 | // Gets all values
|
| 5843 | if ( key === undefined ) {
|
| 5844 | if ( this.length ) {
|
| 5845 | data = jQuery.data( elem );
|
| 5846 |
|
| 5847 | if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
|
| 5848 | attrs = elem.attributes;
|
| 5849 | for ( ; i < attrs.length; i++ ) {
|
| 5850 | name = attrs[i].name;
|
| 5851 |
|
| 5852 | if ( name.indexOf("data-") === 0 ) {
|
| 5853 | name = jQuery.camelCase( name.slice(5) );
|
| 5854 |
|
| 5855 | dataAttr( elem, name, data[ name ] );
|
| 5856 | }
|
| 5857 | }
|
| 5858 | jQuery._data( elem, "parsedAttrs", true );
|
| 5859 | }
|
| 5860 | }
|
| 5861 |
|
| 5862 | return data;
|
| 5863 | }
|
| 5864 |
|
| 5865 | // Sets multiple values
|
| 5866 | if ( typeof key === "object" ) {
|
| 5867 | return this.each(function() {
|
| 5868 | jQuery.data( this, key );
|
| 5869 | });
|
| 5870 | }
|
| 5871 |
|
| 5872 | return arguments.length > 1 ?
|
| 5873 |
|
| 5874 | // Sets one value
|
| 5875 | this.each(function() {
|
| 5876 | jQuery.data( this, key, value );
|
| 5877 | }) :
|
| 5878 |
|
| 5879 | // Gets one value
|
| 5880 | // Try to fetch any internally stored data first
|
| 5881 | elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
|
| 5882 | },
|
| 5883 |
|
| 5884 | removeData: function( key ) {
|
| 5885 | return this.each(function() {
|
| 5886 | jQuery.removeData( this, key );
|
| 5887 | });
|
| 5888 | }
|
| 5889 | });
|
| 5890 |
|
| 5891 | function dataAttr( elem, key, data ) {
|
| 5892 | // If nothing was found internally, try to fetch any
|
| 5893 | // data from the HTML5 data-* attribute
|
| 5894 | if ( data === undefined && elem.nodeType === 1 ) {
|
| 5895 |
|
| 5896 | var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
|
| 5897 |
|
| 5898 | data = elem.getAttribute( name );
|
| 5899 |
|
| 5900 | if ( typeof data === "string" ) {
|
| 5901 | try {
|
| 5902 | data = data === "true" ? true :
|
| 5903 | data === "false" ? false :
|
| 5904 | data === "null" ? null :
|
| 5905 | // Only convert to a number if it doesn't change the string
|
| 5906 | +data + "" === data ? +data :
|
| 5907 | rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
| 5908 | data;
|
| 5909 | } catch( e ) {}
|
| 5910 |
|
| 5911 | // Make sure we set the data so it isn't changed later
|
| 5912 | jQuery.data( elem, key, data );
|
| 5913 |
|
| 5914 | } else {
|
| 5915 | data = undefined;
|
| 5916 | }
|
| 5917 | }
|
| 5918 |
|
| 5919 | return data;
|
| 5920 | }
|
| 5921 |
|
| 5922 | // checks a cache object for emptiness
|
| 5923 | function isEmptyDataObject( obj ) {
|
| 5924 | var name;
|
| 5925 | for ( name in obj ) {
|
| 5926 |
|
| 5927 | // if the public data object is empty, the private is still empty
|
| 5928 | if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
|
| 5929 | continue;
|
| 5930 | }
|
| 5931 | if ( name !== "toJSON" ) {
|
| 5932 | return false;
|
| 5933 | }
|
| 5934 | }
|
| 5935 |
|
| 5936 | return true;
|
| 5937 | }
|
| 5938 | jQuery.extend({
|
| 5939 | queue: function( elem, type, data ) {
|
| 5940 | var queue;
|
| 5941 |
|
| 5942 | if ( elem ) {
|
| 5943 | type = ( type || "fx" ) + "queue";
|
| 5944 | queue = jQuery._data( elem, type );
|
| 5945 |
|
| 5946 | // Speed up dequeue by getting out quickly if this is just a lookup
|
| 5947 | if ( data ) {
|
| 5948 | if ( !queue || jQuery.isArray(data) ) {
|
| 5949 | queue = jQuery._data( elem, type, jQuery.makeArray(data) );
|
| 5950 | } else {
|
| 5951 | queue.push( data );
|
| 5952 | }
|
| 5953 | }
|
| 5954 | return queue || [];
|
| 5955 | }
|
| 5956 | },
|
| 5957 |
|
| 5958 | dequeue: function( elem, type ) {
|
| 5959 | type = type || "fx";
|
| 5960 |
|
| 5961 | var queue = jQuery.queue( elem, type ),
|
| 5962 | startLength = queue.length,
|
| 5963 | fn = queue.shift(),
|
| 5964 | hooks = jQuery._queueHooks( elem, type ),
|
| 5965 | next = function() {
|
| 5966 | jQuery.dequeue( elem, type );
|
| 5967 | };
|
| 5968 |
|
| 5969 | // If the fx queue is dequeued, always remove the progress sentinel
|
| 5970 | if ( fn === "inprogress" ) {
|
| 5971 | fn = queue.shift();
|
| 5972 | startLength--;
|
| 5973 | }
|
| 5974 |
|
| 5975 | if ( fn ) {
|
| 5976 |
|
| 5977 | // Add a progress sentinel to prevent the fx queue from being
|
| 5978 | // automatically dequeued
|
| 5979 | if ( type === "fx" ) {
|
| 5980 | queue.unshift( "inprogress" );
|
| 5981 | }
|
| 5982 |
|
| 5983 | // clear up the last queue stop function
|
| 5984 | delete hooks.stop;
|
| 5985 | fn.call( elem, next, hooks );
|
| 5986 | }
|
| 5987 |
|
| 5988 | if ( !startLength && hooks ) {
|
| 5989 | hooks.empty.fire();
|
| 5990 | }
|
| 5991 | },
|
| 5992 |
|
| 5993 | // not intended for public consumption - generates a queueHooks object, or returns the current one
|
| 5994 | _queueHooks: function( elem, type ) {
|
| 5995 | var key = type + "queueHooks";
|
| 5996 | return jQuery._data( elem, key ) || jQuery._data( elem, key, {
|
| 5997 | empty: jQuery.Callbacks("once memory").add(function() {
|
| 5998 | jQuery._removeData( elem, type + "queue" );
|
| 5999 | jQuery._removeData( elem, key );
|
| 6000 | })
|
| 6001 | });
|
| 6002 | }
|
| 6003 | });
|
| 6004 |
|
| 6005 | jQuery.fn.extend({
|
| 6006 | queue: function( type, data ) {
|
| 6007 | var setter = 2;
|
| 6008 |
|
| 6009 | if ( typeof type !== "string" ) {
|
| 6010 | data = type;
|
| 6011 | type = "fx";
|
| 6012 | setter--;
|
| 6013 | }
|
| 6014 |
|
| 6015 | if ( arguments.length < setter ) {
|
| 6016 | return jQuery.queue( this[0], type );
|
| 6017 | }
|
| 6018 |
|
| 6019 | return data === undefined ?
|
| 6020 | this :
|
| 6021 | this.each(function() {
|
| 6022 | var queue = jQuery.queue( this, type, data );
|
| 6023 |
|
| 6024 | // ensure a hooks for this queue
|
| 6025 | jQuery._queueHooks( this, type );
|
| 6026 |
|
| 6027 | if ( type === "fx" && queue[0] !== "inprogress" ) {
|
| 6028 | jQuery.dequeue( this, type );
|
| 6029 | }
|
| 6030 | });
|
| 6031 | },
|
| 6032 | dequeue: function( type ) {
|
| 6033 | return this.each(function() {
|
| 6034 | jQuery.dequeue( this, type );
|
| 6035 | });
|
| 6036 | },
|
| 6037 | // Based off of the plugin by Clint Helfers, with permission.
|
| 6038 | // http://blindsignals.com/index.php/2009/07/jquery-delay/
|
| 6039 | delay: function( time, type ) {
|
| 6040 | time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
|
| 6041 | type = type || "fx";
|
| 6042 |
|
| 6043 | return this.queue( type, function( next, hooks ) {
|
| 6044 | var timeout = setTimeout( next, time );
|
| 6045 | hooks.stop = function() {
|
| 6046 | clearTimeout( timeout );
|
| 6047 | };
|
| 6048 | });
|
| 6049 | },
|
| 6050 | clearQueue: function( type ) {
|
| 6051 | return this.queue( type || "fx", [] );
|
| 6052 | },
|
| 6053 | // Get a promise resolved when queues of a certain type
|
| 6054 | // are emptied (fx is the type by default)
|
| 6055 | promise: function( type, obj ) {
|
| 6056 | var tmp,
|
| 6057 | count = 1,
|
| 6058 | defer = jQuery.Deferred(),
|
| 6059 | elements = this,
|
| 6060 | i = this.length,
|
| 6061 | resolve = function() {
|
| 6062 | if ( !( --count ) ) {
|
| 6063 | defer.resolveWith( elements, [ elements ] );
|
| 6064 | }
|
| 6065 | };
|
| 6066 |
|
| 6067 | if ( typeof type !== "string" ) {
|
| 6068 | obj = type;
|
| 6069 | type = undefined;
|
| 6070 | }
|
| 6071 | type = type || "fx";
|
| 6072 |
|
| 6073 | while( i-- ) {
|
| 6074 | tmp = jQuery._data( elements[ i ], type + "queueHooks" );
|
| 6075 | if ( tmp && tmp.empty ) {
|
| 6076 | count++;
|
| 6077 | tmp.empty.add( resolve );
|
| 6078 | }
|
| 6079 | }
|
| 6080 | resolve();
|
| 6081 | return defer.promise( obj );
|
| 6082 | }
|
| 6083 | });
|
| 6084 | var nodeHook, boolHook,
|
| 6085 | rclass = /[\t\r\n\f]/g,
|
| 6086 | rreturn = /\r/g,
|
| 6087 | rfocusable = /^(?:input|select|textarea|button|object)$/i,
|
| 6088 | rclickable = /^(?:a|area)$/i,
|
| 6089 | ruseDefault = /^(?:checked|selected)$/i,
|
| 6090 | getSetAttribute = jQuery.support.getSetAttribute,
|
| 6091 | getSetInput = jQuery.support.input;
|
| 6092 |
|
| 6093 | jQuery.fn.extend({
|
| 6094 | attr: function( name, value ) {
|
| 6095 | return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
|
| 6096 | },
|
| 6097 |
|
| 6098 | removeAttr: function( name ) {
|
| 6099 | return this.each(function() {
|
| 6100 | jQuery.removeAttr( this, name );
|
| 6101 | });
|
| 6102 | },
|
| 6103 |
|
| 6104 | prop: function( name, value ) {
|
| 6105 | return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
|
| 6106 | },
|
| 6107 |
|
| 6108 | removeProp: function( name ) {
|
| 6109 | name = jQuery.propFix[ name ] || name;
|
| 6110 | return this.each(function() {
|
| 6111 | // try/catch handles cases where IE balks (such as removing a property on window)
|
| 6112 | try {
|
| 6113 | this[ name ] = undefined;
|
| 6114 | delete this[ name ];
|
| 6115 | } catch( e ) {}
|
| 6116 | });
|
| 6117 | },
|
| 6118 |
|
| 6119 | addClass: function( value ) {
|
| 6120 | var classes, elem, cur, clazz, j,
|
| 6121 | i = 0,
|
| 6122 | len = this.length,
|
| 6123 | proceed = typeof value === "string" && value;
|
| 6124 |
|
| 6125 | if ( jQuery.isFunction( value ) ) {
|
| 6126 | return this.each(function( j ) {
|
| 6127 | jQuery( this ).addClass( value.call( this, j, this.className ) );
|
| 6128 | });
|
| 6129 | }
|
| 6130 |
|
| 6131 | if ( proceed ) {
|
| 6132 | // The disjunction here is for better compressibility (see removeClass)
|
| 6133 | classes = ( value || "" ).match( core_rnotwhite ) || [];
|
| 6134 |
|
| 6135 | for ( ; i < len; i++ ) {
|
| 6136 | elem = this[ i ];
|
| 6137 | cur = elem.nodeType === 1 && ( elem.className ?
|
| 6138 | ( " " + elem.className + " " ).replace( rclass, " " ) :
|
| 6139 | " "
|
| 6140 | );
|
| 6141 |
|
| 6142 | if ( cur ) {
|
| 6143 | j = 0;
|
| 6144 | while ( (clazz = classes[j++]) ) {
|
| 6145 | if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
|
| 6146 | cur += clazz + " ";
|
| 6147 | }
|
| 6148 | }
|
| 6149 | elem.className = jQuery.trim( cur );
|
| 6150 |
|
| 6151 | }
|
| 6152 | }
|
| 6153 | }
|
| 6154 |
|
| 6155 | return this;
|
| 6156 | },
|
| 6157 |
|
| 6158 | removeClass: function( value ) {
|
| 6159 | var classes, elem, cur, clazz, j,
|
| 6160 | i = 0,
|
| 6161 | len = this.length,
|
| 6162 | proceed = arguments.length === 0 || typeof value === "string" && value;
|
| 6163 |
|
| 6164 | if ( jQuery.isFunction( value ) ) {
|
| 6165 | return this.each(function( j ) {
|
| 6166 | jQuery( this ).removeClass( value.call( this, j, this.className ) );
|
| 6167 | });
|
| 6168 | }
|
| 6169 | if ( proceed ) {
|
| 6170 | classes = ( value || "" ).match( core_rnotwhite ) || [];
|
| 6171 |
|
| 6172 | for ( ; i < len; i++ ) {
|
| 6173 | elem = this[ i ];
|
| 6174 | // This expression is here for better compressibility (see addClass)
|
| 6175 | cur = elem.nodeType === 1 && ( elem.className ?
|
| 6176 | ( " " + elem.className + " " ).replace( rclass, " " ) :
|
| 6177 | ""
|
| 6178 | );
|
| 6179 |
|
| 6180 | if ( cur ) {
|
| 6181 | j = 0;
|
| 6182 | while ( (clazz = classes[j++]) ) {
|
| 6183 | // Remove *all* instances
|
| 6184 | while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
|
| 6185 | cur = cur.replace( " " + clazz + " ", " " );
|
| 6186 | }
|
| 6187 | }
|
| 6188 | elem.className = value ? jQuery.trim( cur ) : "";
|
| 6189 | }
|
| 6190 | }
|
| 6191 | }
|
| 6192 |
|
| 6193 | return this;
|
| 6194 | },
|
| 6195 |
|
| 6196 | toggleClass: function( value, stateVal ) {
|
| 6197 | var type = typeof value;
|
| 6198 |
|
| 6199 | if ( typeof stateVal === "boolean" && type === "string" ) {
|
| 6200 | return stateVal ? this.addClass( value ) : this.removeClass( value );
|
| 6201 | }
|
| 6202 |
|
| 6203 | if ( jQuery.isFunction( value ) ) {
|
| 6204 | return this.each(function( i ) {
|
| 6205 | jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
| 6206 | });
|
| 6207 | }
|
| 6208 |
|
| 6209 | return this.each(function() {
|
| 6210 | if ( type === "string" ) {
|
| 6211 | // toggle individual class names
|
| 6212 | var className,
|
| 6213 | i = 0,
|
| 6214 | self = jQuery( this ),
|
| 6215 | classNames = value.match( core_rnotwhite ) || [];
|
| 6216 |
|
| 6217 | while ( (className = classNames[ i++ ]) ) {
|
| 6218 | // check each className given, space separated list
|
| 6219 | if ( self.hasClass( className ) ) {
|
| 6220 | self.removeClass( className );
|
| 6221 | } else {
|
| 6222 | self.addClass( className );
|
| 6223 | }
|
| 6224 | }
|
| 6225 |
|
| 6226 | // Toggle whole class name
|
| 6227 | } else if ( type === core_strundefined || type === "boolean" ) {
|
| 6228 | if ( this.className ) {
|
| 6229 | // store className if set
|
| 6230 | jQuery._data( this, "__className__", this.className );
|
| 6231 | }
|
| 6232 |
|
| 6233 | // If the element has a class name or if we're passed "false",
|
| 6234 | // then remove the whole classname (if there was one, the above saved it).
|
| 6235 | // Otherwise bring back whatever was previously saved (if anything),
|
| 6236 | // falling back to the empty string if nothing was stored.
|
| 6237 | this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
|
| 6238 | }
|
| 6239 | });
|
| 6240 | },
|
| 6241 |
|
| 6242 | hasClass: function( selector ) {
|
| 6243 | var className = " " + selector + " ",
|
| 6244 | i = 0,
|
| 6245 | l = this.length;
|
| 6246 | for ( ; i < l; i++ ) {
|
| 6247 | if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
|
| 6248 | return true;
|
| 6249 | }
|
| 6250 | }
|
| 6251 |
|
| 6252 | return false;
|
| 6253 | },
|
| 6254 |
|
| 6255 | val: function( value ) {
|
| 6256 | var ret, hooks, isFunction,
|
| 6257 | elem = this[0];
|
| 6258 |
|
| 6259 | if ( !arguments.length ) {
|
| 6260 | if ( elem ) {
|
| 6261 | hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
|
| 6262 |
|
| 6263 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
| 6264 | return ret;
|
| 6265 | }
|
| 6266 |
|
| 6267 | ret = elem.value;
|
| 6268 |
|
| 6269 | return typeof ret === "string" ?
|
| 6270 | // handle most common string cases
|
| 6271 | ret.replace(rreturn, "") :
|
| 6272 | // handle cases where value is null/undef or number
|
| 6273 | ret == null ? "" : ret;
|
| 6274 | }
|
| 6275 |
|
| 6276 | return;
|
| 6277 | }
|
| 6278 |
|
| 6279 | isFunction = jQuery.isFunction( value );
|
| 6280 |
|
| 6281 | return this.each(function( i ) {
|
| 6282 | var val;
|
| 6283 |
|
| 6284 | if ( this.nodeType !== 1 ) {
|
| 6285 | return;
|
| 6286 | }
|
| 6287 |
|
| 6288 | if ( isFunction ) {
|
| 6289 | val = value.call( this, i, jQuery( this ).val() );
|
| 6290 | } else {
|
| 6291 | val = value;
|
| 6292 | }
|
| 6293 |
|
| 6294 | // Treat null/undefined as ""; convert numbers to string
|
| 6295 | if ( val == null ) {
|
| 6296 | val = "";
|
| 6297 | } else if ( typeof val === "number" ) {
|
| 6298 | val += "";
|
| 6299 | } else if ( jQuery.isArray( val ) ) {
|
| 6300 | val = jQuery.map(val, function ( value ) {
|
| 6301 | return value == null ? "" : value + "";
|
| 6302 | });
|
| 6303 | }
|
| 6304 |
|
| 6305 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
|
| 6306 |
|
| 6307 | // If set returns undefined, fall back to normal setting
|
| 6308 | if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
|
| 6309 | this.value = val;
|
| 6310 | }
|
| 6311 | });
|
| 6312 | }
|
| 6313 | });
|
| 6314 |
|
| 6315 | jQuery.extend({
|
| 6316 | valHooks: {
|
| 6317 | option: {
|
| 6318 | get: function( elem ) {
|
| 6319 | // Use proper attribute retrieval(#6932, #12072)
|
| 6320 | var val = jQuery.find.attr( elem, "value" );
|
| 6321 | return val != null ?
|
| 6322 | val :
|
| 6323 | elem.text;
|
| 6324 | }
|
| 6325 | },
|
| 6326 | select: {
|
| 6327 | get: function( elem ) {
|
| 6328 | var value, option,
|
| 6329 | options = elem.options,
|
| 6330 | index = elem.selectedIndex,
|
| 6331 | one = elem.type === "select-one" || index < 0,
|
| 6332 | values = one ? null : [],
|
| 6333 | max = one ? index + 1 : options.length,
|
| 6334 | i = index < 0 ?
|
| 6335 | max :
|
| 6336 | one ? index : 0;
|
| 6337 |
|
| 6338 | // Loop through all the selected options
|
| 6339 | for ( ; i < max; i++ ) {
|
| 6340 | option = options[ i ];
|
| 6341 |
|
| 6342 | // oldIE doesn't update selected after form reset (#2551)
|
| 6343 | if ( ( option.selected || i === index ) &&
|
| 6344 | // Don't return options that are disabled or in a disabled optgroup
|
| 6345 | ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
|
| 6346 | ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
| 6347 |
|
| 6348 | // Get the specific value for the option
|
| 6349 | value = jQuery( option ).val();
|
| 6350 |
|
| 6351 | // We don't need an array for one selects
|
| 6352 | if ( one ) {
|
| 6353 | return value;
|
| 6354 | }
|
| 6355 |
|
| 6356 | // Multi-Selects return an array
|
| 6357 | values.push( value );
|
| 6358 | }
|
| 6359 | }
|
| 6360 |
|
| 6361 | return values;
|
| 6362 | },
|
| 6363 |
|
| 6364 | set: function( elem, value ) {
|
| 6365 | var optionSet, option,
|
| 6366 | options = elem.options,
|
| 6367 | values = jQuery.makeArray( value ),
|
| 6368 | i = options.length;
|
| 6369 |
|
| 6370 | while ( i-- ) {
|
| 6371 | option = options[ i ];
|
| 6372 | if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
|
| 6373 | optionSet = true;
|
| 6374 | }
|
| 6375 | }
|
| 6376 |
|
| 6377 | // force browsers to behave consistently when non-matching value is set
|
| 6378 | if ( !optionSet ) {
|
| 6379 | elem.selectedIndex = -1;
|
| 6380 | }
|
| 6381 | return values;
|
| 6382 | }
|
| 6383 | }
|
| 6384 | },
|
| 6385 |
|
| 6386 | attr: function( elem, name, value ) {
|
| 6387 | var hooks, ret,
|
| 6388 | nType = elem.nodeType;
|
| 6389 |
|
| 6390 | // don't get/set attributes on text, comment and attribute nodes
|
| 6391 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
| 6392 | return;
|
| 6393 | }
|
| 6394 |
|
| 6395 | // Fallback to prop when attributes are not supported
|
| 6396 | if ( typeof elem.getAttribute === core_strundefined ) {
|
| 6397 | return jQuery.prop( elem, name, value );
|
| 6398 | }
|
| 6399 |
|
| 6400 | // All attributes are lowercase
|
| 6401 | // Grab necessary hook if one is defined
|
| 6402 | if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
|
| 6403 | name = name.toLowerCase();
|
| 6404 | hooks = jQuery.attrHooks[ name ] ||
|
| 6405 | ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
|
| 6406 | }
|
| 6407 |
|
| 6408 | if ( value !== undefined ) {
|
| 6409 |
|
| 6410 | if ( value === null ) {
|
| 6411 | jQuery.removeAttr( elem, name );
|
| 6412 |
|
| 6413 | } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
| 6414 | return ret;
|
| 6415 |
|
| 6416 | } else {
|
| 6417 | elem.setAttribute( name, value + "" );
|
| 6418 | return value;
|
| 6419 | }
|
| 6420 |
|
| 6421 | } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
|
| 6422 | return ret;
|
| 6423 |
|
| 6424 | } else {
|
| 6425 | ret = jQuery.find.attr( elem, name );
|
| 6426 |
|
| 6427 | // Non-existent attributes return null, we normalize to undefined
|
| 6428 | return ret == null ?
|
| 6429 | undefined :
|
| 6430 | ret;
|
| 6431 | }
|
| 6432 | },
|
| 6433 |
|
| 6434 | removeAttr: function( elem, value ) {
|
| 6435 | var name, propName,
|
| 6436 | i = 0,
|
| 6437 | attrNames = value && value.match( core_rnotwhite );
|
| 6438 |
|
| 6439 | if ( attrNames && elem.nodeType === 1 ) {
|
| 6440 | while ( (name = attrNames[i++]) ) {
|
| 6441 | propName = jQuery.propFix[ name ] || name;
|
| 6442 |
|
| 6443 | // Boolean attributes get special treatment (#10870)
|
| 6444 | if ( jQuery.expr.match.bool.test( name ) ) {
|
| 6445 | // Set corresponding property to false
|
| 6446 | if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
| 6447 | elem[ propName ] = false;
|
| 6448 | // Support: IE<9
|
| 6449 | // Also clear defaultChecked/defaultSelected (if appropriate)
|
| 6450 | } else {
|
| 6451 | elem[ jQuery.camelCase( "default-" + name ) ] =
|
| 6452 | elem[ propName ] = false;
|
| 6453 | }
|
| 6454 |
|
| 6455 | // See #9699 for explanation of this approach (setting first, then removal)
|
| 6456 | } else {
|
| 6457 | jQuery.attr( elem, name, "" );
|
| 6458 | }
|
| 6459 |
|
| 6460 | elem.removeAttribute( getSetAttribute ? name : propName );
|
| 6461 | }
|
| 6462 | }
|
| 6463 | },
|
| 6464 |
|
| 6465 | attrHooks: {
|
| 6466 | type: {
|
| 6467 | set: function( elem, value ) {
|
| 6468 | if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
|
| 6469 | // Setting the type on a radio button after the value resets the value in IE6-9
|
| 6470 | // Reset value to default in case type is set after value during creation
|
| 6471 | var val = elem.value;
|
| 6472 | elem.setAttribute( "type", value );
|
| 6473 | if ( val ) {
|
| 6474 | elem.value = val;
|
| 6475 | }
|
| 6476 | return value;
|
| 6477 | }
|
| 6478 | }
|
| 6479 | }
|
| 6480 | },
|
| 6481 |
|
| 6482 | propFix: {
|
| 6483 | "for": "htmlFor",
|
| 6484 | "class": "className"
|
| 6485 | },
|
| 6486 |
|
| 6487 | prop: function( elem, name, value ) {
|
| 6488 | var ret, hooks, notxml,
|
| 6489 | nType = elem.nodeType;
|
| 6490 |
|
| 6491 | // don't get/set properties on text, comment and attribute nodes
|
| 6492 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
| 6493 | return;
|
| 6494 | }
|
| 6495 |
|
| 6496 | notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
| 6497 |
|
| 6498 | if ( notxml ) {
|
| 6499 | // Fix name and attach hooks
|
| 6500 | name = jQuery.propFix[ name ] || name;
|
| 6501 | hooks = jQuery.propHooks[ name ];
|
| 6502 | }
|
| 6503 |
|
| 6504 | if ( value !== undefined ) {
|
| 6505 | return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
|
| 6506 | ret :
|
| 6507 | ( elem[ name ] = value );
|
| 6508 |
|
| 6509 | } else {
|
| 6510 | return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
|
| 6511 | ret :
|
| 6512 | elem[ name ];
|
| 6513 | }
|
| 6514 | },
|
| 6515 |
|
| 6516 | propHooks: {
|
| 6517 | tabIndex: {
|
| 6518 | get: function( elem ) {
|
| 6519 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
| 6520 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
| 6521 | // Use proper attribute retrieval(#12072)
|
| 6522 | var tabindex = jQuery.find.attr( elem, "tabindex" );
|
| 6523 |
|
| 6524 | return tabindex ?
|
| 6525 | parseInt( tabindex, 10 ) :
|
| 6526 | rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
|
| 6527 | 0 :
|
| 6528 | -1;
|
| 6529 | }
|
| 6530 | }
|
| 6531 | }
|
| 6532 | });
|
| 6533 |
|
| 6534 | // Hooks for boolean attributes
|
| 6535 | boolHook = {
|
| 6536 | set: function( elem, value, name ) {
|
| 6537 | if ( value === false ) {
|
| 6538 | // Remove boolean attributes when set to false
|
| 6539 | jQuery.removeAttr( elem, name );
|
| 6540 | } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
| 6541 | // IE<8 needs the *property* name
|
| 6542 | elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
|
| 6543 |
|
| 6544 | // Use defaultChecked and defaultSelected for oldIE
|
| 6545 | } else {
|
| 6546 | elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
|
| 6547 | }
|
| 6548 |
|
| 6549 | return name;
|
| 6550 | }
|
| 6551 | };
|
| 6552 | jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
|
| 6553 | var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr;
|
| 6554 |
|
| 6555 | jQuery.expr.attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
|
| 6556 | function( elem, name, isXML ) {
|
| 6557 | var fn = jQuery.expr.attrHandle[ name ],
|
| 6558 | ret = isXML ?
|
| 6559 | undefined :
|
| 6560 | /* jshint eqeqeq: false */
|
| 6561 | (jQuery.expr.attrHandle[ name ] = undefined) !=
|
| 6562 | getter( elem, name, isXML ) ?
|
| 6563 |
|
| 6564 | name.toLowerCase() :
|
| 6565 | null;
|
| 6566 | jQuery.expr.attrHandle[ name ] = fn;
|
| 6567 | return ret;
|
| 6568 | } :
|
| 6569 | function( elem, name, isXML ) {
|
| 6570 | return isXML ?
|
| 6571 | undefined :
|
| 6572 | elem[ jQuery.camelCase( "default-" + name ) ] ?
|
| 6573 | name.toLowerCase() :
|
| 6574 | null;
|
| 6575 | };
|
| 6576 | });
|
| 6577 |
|
| 6578 | // fix oldIE attroperties
|
| 6579 | if ( !getSetInput || !getSetAttribute ) {
|
| 6580 | jQuery.attrHooks.value = {
|
| 6581 | set: function( elem, value, name ) {
|
| 6582 | if ( jQuery.nodeName( elem, "input" ) ) {
|
| 6583 | // Does not return so that setAttribute is also used
|
| 6584 | elem.defaultValue = value;
|
| 6585 | } else {
|
| 6586 | // Use nodeHook if defined (#1954); otherwise setAttribute is fine
|
| 6587 | return nodeHook && nodeHook.set( elem, value, name );
|
| 6588 | }
|
| 6589 | }
|
| 6590 | };
|
| 6591 | }
|
| 6592 |
|
| 6593 | // IE6/7 do not support getting/setting some attributes with get/setAttribute
|
| 6594 | if ( !getSetAttribute ) {
|
| 6595 |
|
| 6596 | // Use this for any attribute in IE6/7
|
| 6597 | // This fixes almost every IE6/7 issue
|
| 6598 | nodeHook = {
|
| 6599 | set: function( elem, value, name ) {
|
| 6600 | // Set the existing or create a new attribute node
|
| 6601 | var ret = elem.getAttributeNode( name );
|
| 6602 | if ( !ret ) {
|
| 6603 | elem.setAttributeNode(
|
| 6604 | (ret = elem.ownerDocument.createAttribute( name ))
|
| 6605 | );
|
| 6606 | }
|
| 6607 |
|
| 6608 | ret.value = value += "";
|
| 6609 |
|
| 6610 | // Break association with cloned elements by also using setAttribute (#9646)
|
| 6611 | return name === "value" || value === elem.getAttribute( name ) ?
|
| 6612 | value :
|
| 6613 | undefined;
|
| 6614 | }
|
| 6615 | };
|
| 6616 | jQuery.expr.attrHandle.id = jQuery.expr.attrHandle.name = jQuery.expr.attrHandle.coords =
|
| 6617 | // Some attributes are constructed with empty-string values when not defined
|
| 6618 | function( elem, name, isXML ) {
|
| 6619 | var ret;
|
| 6620 | return isXML ?
|
| 6621 | undefined :
|
| 6622 | (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
|
| 6623 | ret.value :
|
| 6624 | null;
|
| 6625 | };
|
| 6626 | jQuery.valHooks.button = {
|
| 6627 | get: function( elem, name ) {
|
| 6628 | var ret = elem.getAttributeNode( name );
|
| 6629 | return ret && ret.specified ?
|
| 6630 | ret.value :
|
| 6631 | undefined;
|
| 6632 | },
|
| 6633 | set: nodeHook.set
|
| 6634 | };
|
| 6635 |
|
| 6636 | // Set contenteditable to false on removals(#10429)
|
| 6637 | // Setting to empty string throws an error as an invalid value
|
| 6638 | jQuery.attrHooks.contenteditable = {
|
| 6639 | set: function( elem, value, name ) {
|
| 6640 | nodeHook.set( elem, value === "" ? false : value, name );
|
| 6641 | }
|
| 6642 | };
|
| 6643 |
|
| 6644 | // Set width and height to auto instead of 0 on empty string( Bug #8150 )
|
| 6645 | // This is for removals
|
| 6646 | jQuery.each([ "width", "height" ], function( i, name ) {
|
| 6647 | jQuery.attrHooks[ name ] = {
|
| 6648 | set: function( elem, value ) {
|
| 6649 | if ( value === "" ) {
|
| 6650 | elem.setAttribute( name, "auto" );
|
| 6651 | return value;
|
| 6652 | }
|
| 6653 | }
|
| 6654 | };
|
| 6655 | });
|
| 6656 | }
|
| 6657 |
|
| 6658 |
|
| 6659 | // Some attributes require a special call on IE
|
| 6660 | // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
| 6661 | if ( !jQuery.support.hrefNormalized ) {
|
| 6662 | // href/src property should get the full normalized URL (#10299/#12915)
|
| 6663 | jQuery.each([ "href", "src" ], function( i, name ) {
|
| 6664 | jQuery.propHooks[ name ] = {
|
| 6665 | get: function( elem ) {
|
| 6666 | return elem.getAttribute( name, 4 );
|
| 6667 | }
|
| 6668 | };
|
| 6669 | });
|
| 6670 | }
|
| 6671 |
|
| 6672 | if ( !jQuery.support.style ) {
|
| 6673 | jQuery.attrHooks.style = {
|
| 6674 | get: function( elem ) {
|
| 6675 | // Return undefined in the case of empty string
|
| 6676 | // Note: IE uppercases css property names, but if we were to .toLowerCase()
|
| 6677 | // .cssText, that would destroy case senstitivity in URL's, like in "background"
|
| 6678 | return elem.style.cssText || undefined;
|
| 6679 | },
|
| 6680 | set: function( elem, value ) {
|
| 6681 | return ( elem.style.cssText = value + "" );
|
| 6682 | }
|
| 6683 | };
|
| 6684 | }
|
| 6685 |
|
| 6686 | // Safari mis-reports the default selected property of an option
|
| 6687 | // Accessing the parent's selectedIndex property fixes it
|
| 6688 | if ( !jQuery.support.optSelected ) {
|
| 6689 | jQuery.propHooks.selected = {
|
| 6690 | get: function( elem ) {
|
| 6691 | var parent = elem.parentNode;
|
| 6692 |
|
| 6693 | if ( parent ) {
|
| 6694 | parent.selectedIndex;
|
| 6695 |
|
| 6696 | // Make sure that it also works with optgroups, see #5701
|
| 6697 | if ( parent.parentNode ) {
|
| 6698 | parent.parentNode.selectedIndex;
|
| 6699 | }
|
| 6700 | }
|
| 6701 | return null;
|
| 6702 | }
|
| 6703 | };
|
| 6704 | }
|
| 6705 |
|
| 6706 | jQuery.each([
|
| 6707 | "tabIndex",
|
| 6708 | "readOnly",
|
| 6709 | "maxLength",
|
| 6710 | "cellSpacing",
|
| 6711 | "cellPadding",
|
| 6712 | "rowSpan",
|
| 6713 | "colSpan",
|
| 6714 | "useMap",
|
| 6715 | "frameBorder",
|
| 6716 | "contentEditable"
|
| 6717 | ], function() {
|
| 6718 | jQuery.propFix[ this.toLowerCase() ] = this;
|
| 6719 | });
|
| 6720 |
|
| 6721 | // IE6/7 call enctype encoding
|
| 6722 | if ( !jQuery.support.enctype ) {
|
| 6723 | jQuery.propFix.enctype = "encoding";
|
| 6724 | }
|
| 6725 |
|
| 6726 | // Radios and checkboxes getter/setter
|
| 6727 | jQuery.each([ "radio", "checkbox" ], function() {
|
| 6728 | jQuery.valHooks[ this ] = {
|
| 6729 | set: function( elem, value ) {
|
| 6730 | if ( jQuery.isArray( value ) ) {
|
| 6731 | return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
|
| 6732 | }
|
| 6733 | }
|
| 6734 | };
|
| 6735 | if ( !jQuery.support.checkOn ) {
|
| 6736 | jQuery.valHooks[ this ].get = function( elem ) {
|
| 6737 | // Support: Webkit
|
| 6738 | // "" is returned instead of "on" if a value isn't specified
|
| 6739 | return elem.getAttribute("value") === null ? "on" : elem.value;
|
| 6740 | };
|
| 6741 | }
|
| 6742 | });
|
| 6743 | var rformElems = /^(?:input|select|textarea)$/i,
|
| 6744 | rkeyEvent = /^key/,
|
| 6745 | rmouseEvent = /^(?:mouse|contextmenu)|click/,
|
| 6746 | rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
|
| 6747 | rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
|
| 6748 |
|
| 6749 | function returnTrue() {
|
| 6750 | return true;
|
| 6751 | }
|
| 6752 |
|
| 6753 | function returnFalse() {
|
| 6754 | return false;
|
| 6755 | }
|
| 6756 |
|
| 6757 | function safeActiveElement() {
|
| 6758 | try {
|
| 6759 | return document.activeElement;
|
| 6760 | } catch ( err ) { }
|
| 6761 | }
|
| 6762 |
|
| 6763 | /*
|
| 6764 | * Helper functions for managing events -- not part of the public interface.
|
| 6765 | * Props to Dean Edwards' addEvent library for many of the ideas.
|
| 6766 | */
|
| 6767 | jQuery.event = {
|
| 6768 |
|
| 6769 | global: {},
|
| 6770 |
|
| 6771 | add: function( elem, types, handler, data, selector ) {
|
| 6772 | var tmp, events, t, handleObjIn,
|
| 6773 | special, eventHandle, handleObj,
|
| 6774 | handlers, type, namespaces, origType,
|
| 6775 | elemData = jQuery._data( elem );
|
| 6776 |
|
| 6777 | // Don't attach events to noData or text/comment nodes (but allow plain objects)
|
| 6778 | if ( !elemData ) {
|
| 6779 | return;
|
| 6780 | }
|
| 6781 |
|
| 6782 | // Caller can pass in an object of custom data in lieu of the handler
|
| 6783 | if ( handler.handler ) {
|
| 6784 | handleObjIn = handler;
|
| 6785 | handler = handleObjIn.handler;
|
| 6786 | selector = handleObjIn.selector;
|
| 6787 | }
|
| 6788 |
|
| 6789 | // Make sure that the handler has a unique ID, used to find/remove it later
|
| 6790 | if ( !handler.guid ) {
|
| 6791 | handler.guid = jQuery.guid++;
|
| 6792 | }
|
| 6793 |
|
| 6794 | // Init the element's event structure and main handler, if this is the first
|
| 6795 | if ( !(events = elemData.events) ) {
|
| 6796 | events = elemData.events = {};
|
| 6797 | }
|
| 6798 | if ( !(eventHandle = elemData.handle) ) {
|
| 6799 | eventHandle = elemData.handle = function( e ) {
|
| 6800 | // Discard the second event of a jQuery.event.trigger() and
|
| 6801 | // when an event is called after a page has unloaded
|
| 6802 | return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
|
| 6803 | jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
|
| 6804 | undefined;
|
| 6805 | };
|
| 6806 | // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
|
| 6807 | eventHandle.elem = elem;
|
| 6808 | }
|
| 6809 |
|
| 6810 | // Handle multiple events separated by a space
|
| 6811 | types = ( types || "" ).match( core_rnotwhite ) || [""];
|
| 6812 | t = types.length;
|
| 6813 | while ( t-- ) {
|
| 6814 | tmp = rtypenamespace.exec( types[t] ) || [];
|
| 6815 | type = origType = tmp[1];
|
| 6816 | namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
| 6817 |
|
| 6818 | // There *must* be a type, no attaching namespace-only handlers
|
| 6819 | if ( !type ) {
|
| 6820 | continue;
|
| 6821 | }
|
| 6822 |
|
| 6823 | // If event changes its type, use the special event handlers for the changed type
|
| 6824 | special = jQuery.event.special[ type ] || {};
|
| 6825 |
|
| 6826 | // If selector defined, determine special event api type, otherwise given type
|
| 6827 | type = ( selector ? special.delegateType : special.bindType ) || type;
|
| 6828 |
|
| 6829 | // Update special based on newly reset type
|
| 6830 | special = jQuery.event.special[ type ] || {};
|
| 6831 |
|
| 6832 | // handleObj is passed to all event handlers
|
| 6833 | handleObj = jQuery.extend({
|
| 6834 | type: type,
|
| 6835 | origType: origType,
|
| 6836 | data: data,
|
| 6837 | handler: handler,
|
| 6838 | guid: handler.guid,
|
| 6839 | selector: selector,
|
| 6840 | needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
|
| 6841 | namespace: namespaces.join(".")
|
| 6842 | }, handleObjIn );
|
| 6843 |
|
| 6844 | // Init the event handler queue if we're the first
|
| 6845 | if ( !(handlers = events[ type ]) ) {
|
| 6846 | handlers = events[ type ] = [];
|
| 6847 | handlers.delegateCount = 0;
|
| 6848 |
|
| 6849 | // Only use addEventListener/attachEvent if the special events handler returns false
|
| 6850 | if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
| 6851 | // Bind the global event handler to the element
|
| 6852 | if ( elem.addEventListener ) {
|
| 6853 | elem.addEventListener( type, eventHandle, false );
|
| 6854 |
|
| 6855 | } else if ( elem.attachEvent ) {
|
| 6856 | elem.attachEvent( "on" + type, eventHandle );
|
| 6857 | }
|
| 6858 | }
|
| 6859 | }
|
| 6860 |
|
| 6861 | if ( special.add ) {
|
| 6862 | special.add.call( elem, handleObj );
|
| 6863 |
|
| 6864 | if ( !handleObj.handler.guid ) {
|
| 6865 | handleObj.handler.guid = handler.guid;
|
| 6866 | }
|
| 6867 | }
|
| 6868 |
|
| 6869 | // Add to the element's handler list, delegates in front
|
| 6870 | if ( selector ) {
|
| 6871 | handlers.splice( handlers.delegateCount++, 0, handleObj );
|
| 6872 | } else {
|
| 6873 | handlers.push( handleObj );
|
| 6874 | }
|
| 6875 |
|
| 6876 | // Keep track of which events have ever been used, for event optimization
|
| 6877 | jQuery.event.global[ type ] = true;
|
| 6878 | }
|
| 6879 |
|
| 6880 | // Nullify elem to prevent memory leaks in IE
|
| 6881 | elem = null;
|
| 6882 | },
|
| 6883 |
|
| 6884 | // Detach an event or set of events from an element
|
| 6885 | remove: function( elem, types, handler, selector, mappedTypes ) {
|
| 6886 | var j, handleObj, tmp,
|
| 6887 | origCount, t, events,
|
| 6888 | special, handlers, type,
|
| 6889 | namespaces, origType,
|
| 6890 | elemData = jQuery.hasData( elem ) && jQuery._data( elem );
|
| 6891 |
|
| 6892 | if ( !elemData || !(events = elemData.events) ) {
|
| 6893 | return;
|
| 6894 | }
|
| 6895 |
|
| 6896 | // Once for each type.namespace in types; type may be omitted
|
| 6897 | types = ( types || "" ).match( core_rnotwhite ) || [""];
|
| 6898 | t = types.length;
|
| 6899 | while ( t-- ) {
|
| 6900 | tmp = rtypenamespace.exec( types[t] ) || [];
|
| 6901 | type = origType = tmp[1];
|
| 6902 | namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
| 6903 |
|
| 6904 | // Unbind all events (on this namespace, if provided) for the element
|
| 6905 | if ( !type ) {
|
| 6906 | for ( type in events ) {
|
| 6907 | jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
|
| 6908 | }
|
| 6909 | continue;
|
| 6910 | }
|
| 6911 |
|
| 6912 | special = jQuery.event.special[ type ] || {};
|
| 6913 | type = ( selector ? special.delegateType : special.bindType ) || type;
|
| 6914 | handlers = events[ type ] || [];
|
| 6915 | tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
|
| 6916 |
|
| 6917 | // Remove matching events
|
| 6918 | origCount = j = handlers.length;
|
| 6919 | while ( j-- ) {
|
| 6920 | handleObj = handlers[ j ];
|
| 6921 |
|
| 6922 | if ( ( mappedTypes || origType === handleObj.origType ) &&
|
| 6923 | ( !handler || handler.guid === handleObj.guid ) &&
|
| 6924 | ( !tmp || tmp.test( handleObj.namespace ) ) &&
|
| 6925 | ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
| 6926 | handlers.splice( j, 1 );
|
| 6927 |
|
| 6928 | if ( handleObj.selector ) {
|
| 6929 | handlers.delegateCount--;
|
| 6930 | }
|
| 6931 | if ( special.remove ) {
|
| 6932 | special.remove.call( elem, handleObj );
|
| 6933 | }
|
| 6934 | }
|
| 6935 | }
|
| 6936 |
|
| 6937 | // Remove generic event handler if we removed something and no more handlers exist
|
| 6938 | // (avoids potential for endless recursion during removal of special event handlers)
|
| 6939 | if ( origCount && !handlers.length ) {
|
| 6940 | if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
| 6941 | jQuery.removeEvent( elem, type, elemData.handle );
|
| 6942 | }
|
| 6943 |
|
| 6944 | delete events[ type ];
|
| 6945 | }
|
| 6946 | }
|
| 6947 |
|
| 6948 | // Remove the expando if it's no longer used
|
| 6949 | if ( jQuery.isEmptyObject( events ) ) {
|
| 6950 | delete elemData.handle;
|
| 6951 |
|
| 6952 | // removeData also checks for emptiness and clears the expando if empty
|
| 6953 | // so use it instead of delete
|
| 6954 | jQuery._removeData( elem, "events" );
|
| 6955 | }
|
| 6956 | },
|
| 6957 |
|
| 6958 | trigger: function( event, data, elem, onlyHandlers ) {
|
| 6959 | var handle, ontype, cur,
|
| 6960 | bubbleType, special, tmp, i,
|
| 6961 | eventPath = [ elem || document ],
|
| 6962 | type = core_hasOwn.call( event, "type" ) ? event.type : event,
|
| 6963 | namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
|
| 6964 |
|
| 6965 | cur = tmp = elem = elem || document;
|
| 6966 |
|
| 6967 | // Don't do events on text and comment nodes
|
| 6968 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
| 6969 | return;
|
| 6970 | }
|
| 6971 |
|
| 6972 | // focus/blur morphs to focusin/out; ensure we're not firing them right now
|
| 6973 | if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
|
| 6974 | return;
|
| 6975 | }
|
| 6976 |
|
| 6977 | if ( type.indexOf(".") >= 0 ) {
|
| 6978 | // Namespaced trigger; create a regexp to match event type in handle()
|
| 6979 | namespaces = type.split(".");
|
| 6980 | type = namespaces.shift();
|
| 6981 | namespaces.sort();
|
| 6982 | }
|
| 6983 | ontype = type.indexOf(":") < 0 && "on" + type;
|
| 6984 |
|
| 6985 | // Caller can pass in a jQuery.Event object, Object, or just an event type string
|
| 6986 | event = event[ jQuery.expando ] ?
|
| 6987 | event :
|
| 6988 | new jQuery.Event( type, typeof event === "object" && event );
|
| 6989 |
|
| 6990 | // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
|
| 6991 | event.isTrigger = onlyHandlers ? 2 : 3;
|
| 6992 | event.namespace = namespaces.join(".");
|
| 6993 | event.namespace_re = event.namespace ?
|
| 6994 | new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
| 6995 | null;
|
| 6996 |
|
| 6997 | // Clean up the event in case it is being reused
|
| 6998 | event.result = undefined;
|
| 6999 | if ( !event.target ) {
|
| 7000 | event.target = elem;
|
| 7001 | }
|
| 7002 |
|
| 7003 | // Clone any incoming data and prepend the event, creating the handler arg list
|
| 7004 | data = data == null ?
|
| 7005 | [ event ] :
|
| 7006 | jQuery.makeArray( data, [ event ] );
|
| 7007 |
|
| 7008 | // Allow special events to draw outside the lines
|
| 7009 | special = jQuery.event.special[ type ] || {};
|
| 7010 | if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
|
| 7011 | return;
|
| 7012 | }
|
| 7013 |
|
| 7014 | // Determine event propagation path in advance, per W3C events spec (#9951)
|
| 7015 | // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
|
| 7016 | if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
|
| 7017 |
|
| 7018 | bubbleType = special.delegateType || type;
|
| 7019 | if ( !rfocusMorph.test( bubbleType + type ) ) {
|
| 7020 | cur = cur.parentNode;
|
| 7021 | }
|
| 7022 | for ( ; cur; cur = cur.parentNode ) {
|
| 7023 | eventPath.push( cur );
|
| 7024 | tmp = cur;
|
| 7025 | }
|
| 7026 |
|
| 7027 | // Only add window if we got to document (e.g., not plain obj or detached DOM)
|
| 7028 | if ( tmp === (elem.ownerDocument || document) ) {
|
| 7029 | eventPath.push( tmp.defaultView || tmp.parentWindow || window );
|
| 7030 | }
|
| 7031 | }
|
| 7032 |
|
| 7033 | // Fire handlers on the event path
|
| 7034 | i = 0;
|
| 7035 | while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
|
| 7036 |
|
| 7037 | event.type = i > 1 ?
|
| 7038 | bubbleType :
|
| 7039 | special.bindType || type;
|
| 7040 |
|
| 7041 | // jQuery handler
|
| 7042 | handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
|
| 7043 | if ( handle ) {
|
| 7044 | handle.apply( cur, data );
|
| 7045 | }
|
| 7046 |
|
| 7047 | // Native handler
|
| 7048 | handle = ontype && cur[ ontype ];
|
| 7049 | if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
|
| 7050 | event.preventDefault();
|
| 7051 | }
|
| 7052 | }
|
| 7053 | event.type = type;
|
| 7054 |
|
| 7055 | // If nobody prevented the default action, do it now
|
| 7056 | if ( !onlyHandlers && !event.isDefaultPrevented() ) {
|
| 7057 |
|
| 7058 | if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
|
| 7059 | jQuery.acceptData( elem ) ) {
|
| 7060 |
|
| 7061 | // Call a native DOM method on the target with the same name name as the event.
|
| 7062 | // Can't use an .isFunction() check here because IE6/7 fails that test.
|
| 7063 | // Don't do default actions on window, that's where global variables be (#6170)
|
| 7064 | if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
|
| 7065 |
|
| 7066 | // Don't re-trigger an onFOO event when we call its FOO() method
|
| 7067 | tmp = elem[ ontype ];
|
| 7068 |
|
| 7069 | if ( tmp ) {
|
| 7070 | elem[ ontype ] = null;
|
| 7071 | }
|
| 7072 |
|
| 7073 | // Prevent re-triggering of the same event, since we already bubbled it above
|
| 7074 | jQuery.event.triggered = type;
|
| 7075 | try {
|
| 7076 | elem[ type ]();
|
| 7077 | } catch ( e ) {
|
| 7078 | // IE<9 dies on focus/blur to hidden element (#1486,#12518)
|
| 7079 | // only reproducible on winXP IE8 native, not IE9 in IE8 mode
|
| 7080 | }
|
| 7081 | jQuery.event.triggered = undefined;
|
| 7082 |
|
| 7083 | if ( tmp ) {
|
| 7084 | elem[ ontype ] = tmp;
|
| 7085 | }
|
| 7086 | }
|
| 7087 | }
|
| 7088 | }
|
| 7089 |
|
| 7090 | return event.result;
|
| 7091 | },
|
| 7092 |
|
| 7093 | dispatch: function( event ) {
|
| 7094 |
|
| 7095 | // Make a writable jQuery.Event from the native event object
|
| 7096 | event = jQuery.event.fix( event );
|
| 7097 |
|
| 7098 | var i, ret, handleObj, matched, j,
|
| 7099 | handlerQueue = [],
|
| 7100 | args = core_slice.call( arguments ),
|
| 7101 | handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
|
| 7102 | special = jQuery.event.special[ event.type ] || {};
|
| 7103 |
|
| 7104 | // Use the fix-ed jQuery.Event rather than the (read-only) native event
|
| 7105 | args[0] = event;
|
| 7106 | event.delegateTarget = this;
|
| 7107 |
|
| 7108 | // Call the preDispatch hook for the mapped type, and let it bail if desired
|
| 7109 | if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
|
| 7110 | return;
|
| 7111 | }
|
| 7112 |
|
| 7113 | // Determine handlers
|
| 7114 | handlerQueue = jQuery.event.handlers.call( this, event, handlers );
|
| 7115 |
|
| 7116 | // Run delegates first; they may want to stop propagation beneath us
|
| 7117 | i = 0;
|
| 7118 | while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
|
| 7119 | event.currentTarget = matched.elem;
|
| 7120 |
|
| 7121 | j = 0;
|
| 7122 | while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
|
| 7123 |
|
| 7124 | // Triggered event must either 1) have no namespace, or
|
| 7125 | // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
|
| 7126 | if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
|
| 7127 |
|
| 7128 | event.handleObj = handleObj;
|
| 7129 | event.data = handleObj.data;
|
| 7130 |
|
| 7131 | ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
| 7132 | .apply( matched.elem, args );
|
| 7133 |
|
| 7134 | if ( ret !== undefined ) {
|
| 7135 | if ( (event.result = ret) === false ) {
|
| 7136 | event.preventDefault();
|
| 7137 | event.stopPropagation();
|
| 7138 | }
|
| 7139 | }
|
| 7140 | }
|
| 7141 | }
|
| 7142 | }
|
| 7143 |
|
| 7144 | // Call the postDispatch hook for the mapped type
|
| 7145 | if ( special.postDispatch ) {
|
| 7146 | special.postDispatch.call( this, event );
|
| 7147 | }
|
| 7148 |
|
| 7149 | return event.result;
|
| 7150 | },
|
| 7151 |
|
| 7152 | handlers: function( event, handlers ) {
|
| 7153 | var sel, handleObj, matches, i,
|
| 7154 | handlerQueue = [],
|
| 7155 | delegateCount = handlers.delegateCount,
|
| 7156 | cur = event.target;
|
| 7157 |
|
| 7158 | // Find delegate handlers
|
| 7159 | // Black-hole SVG <use> instance trees (#13180)
|
| 7160 | // Avoid non-left-click bubbling in Firefox (#3861)
|
| 7161 | if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
|
| 7162 |
|
| 7163 | /* jshint eqeqeq: false */
|
| 7164 | for ( ; cur != this; cur = cur.parentNode || this ) {
|
| 7165 | /* jshint eqeqeq: true */
|
| 7166 |
|
| 7167 | // Don't check non-elements (#13208)
|
| 7168 | // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
|
| 7169 | if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
|
| 7170 | matches = [];
|
| 7171 | for ( i = 0; i < delegateCount; i++ ) {
|
| 7172 | handleObj = handlers[ i ];
|
| 7173 |
|
| 7174 | // Don't conflict with Object.prototype properties (#13203)
|
| 7175 | sel = handleObj.selector + " ";
|
| 7176 |
|
| 7177 | if ( matches[ sel ] === undefined ) {
|
| 7178 | matches[ sel ] = handleObj.needsContext ?
|
| 7179 | jQuery( sel, this ).index( cur ) >= 0 :
|
| 7180 | jQuery.find( sel, this, null, [ cur ] ).length;
|
| 7181 | }
|
| 7182 | if ( matches[ sel ] ) {
|
| 7183 | matches.push( handleObj );
|
| 7184 | }
|
| 7185 | }
|
| 7186 | if ( matches.length ) {
|
| 7187 | handlerQueue.push({ elem: cur, handlers: matches });
|
| 7188 | }
|
| 7189 | }
|
| 7190 | }
|
| 7191 | }
|
| 7192 |
|
| 7193 | // Add the remaining (directly-bound) handlers
|
| 7194 | if ( delegateCount < handlers.length ) {
|
| 7195 | handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
|
| 7196 | }
|
| 7197 |
|
| 7198 | return handlerQueue;
|
| 7199 | },
|
| 7200 |
|
| 7201 | fix: function( event ) {
|
| 7202 | if ( event[ jQuery.expando ] ) {
|
| 7203 | return event;
|
| 7204 | }
|
| 7205 |
|
| 7206 | // Create a writable copy of the event object and normalize some properties
|
| 7207 | var i, prop, copy,
|
| 7208 | type = event.type,
|
| 7209 | originalEvent = event,
|
| 7210 | fixHook = this.fixHooks[ type ];
|
| 7211 |
|
| 7212 | if ( !fixHook ) {
|
| 7213 | this.fixHooks[ type ] = fixHook =
|
| 7214 | rmouseEvent.test( type ) ? this.mouseHooks :
|
| 7215 | rkeyEvent.test( type ) ? this.keyHooks :
|
| 7216 | {};
|
| 7217 | }
|
| 7218 | copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
|
| 7219 |
|
| 7220 | event = new jQuery.Event( originalEvent );
|
| 7221 |
|
| 7222 | i = copy.length;
|
| 7223 | while ( i-- ) {
|
| 7224 | prop = copy[ i ];
|
| 7225 | event[ prop ] = originalEvent[ prop ];
|
| 7226 | }
|
| 7227 |
|
| 7228 | // Support: IE<9
|
| 7229 | // Fix target property (#1925)
|
| 7230 | if ( !event.target ) {
|
| 7231 | event.target = originalEvent.srcElement || document;
|
| 7232 | }
|
| 7233 |
|
| 7234 | // Support: Chrome 23+, Safari?
|
| 7235 | // Target should not be a text node (#504, #13143)
|
| 7236 | if ( event.target.nodeType === 3 ) {
|
| 7237 | event.target = event.target.parentNode;
|
| 7238 | }
|
| 7239 |
|
| 7240 | // Support: IE<9
|
| 7241 | // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
|
| 7242 | event.metaKey = !!event.metaKey;
|
| 7243 |
|
| 7244 | return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
|
| 7245 | },
|
| 7246 |
|
| 7247 | // Includes some event props shared by KeyEvent and MouseEvent
|
| 7248 | props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
|
| 7249 |
|
| 7250 | fixHooks: {},
|
| 7251 |
|
| 7252 | keyHooks: {
|
| 7253 | props: "char charCode key keyCode".split(" "),
|
| 7254 | filter: function( event, original ) {
|
| 7255 |
|
| 7256 | // Add which for key events
|
| 7257 | if ( event.which == null ) {
|
| 7258 | event.which = original.charCode != null ? original.charCode : original.keyCode;
|
| 7259 | }
|
| 7260 |
|
| 7261 | return event;
|
| 7262 | }
|
| 7263 | },
|
| 7264 |
|
| 7265 | mouseHooks: {
|
| 7266 | props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
|
| 7267 | filter: function( event, original ) {
|
| 7268 | var body, eventDoc, doc,
|
| 7269 | button = original.button,
|
| 7270 | fromElement = original.fromElement;
|
| 7271 |
|
| 7272 | // Calculate pageX/Y if missing and clientX/Y available
|
| 7273 | if ( event.pageX == null && original.clientX != null ) {
|
| 7274 | eventDoc = event.target.ownerDocument || document;
|
| 7275 | doc = eventDoc.documentElement;
|
| 7276 | body = eventDoc.body;
|
| 7277 |
|
| 7278 | event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
|
| 7279 | event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
|
| 7280 | }
|
| 7281 |
|
| 7282 | // Add relatedTarget, if necessary
|
| 7283 | if ( !event.relatedTarget && fromElement ) {
|
| 7284 | event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
|
| 7285 | }
|
| 7286 |
|
| 7287 | // Add which for click: 1 === left; 2 === middle; 3 === right
|
| 7288 | // Note: button is not normalized, so don't use it
|
| 7289 | if ( !event.which && button !== undefined ) {
|
| 7290 | event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
|
| 7291 | }
|
| 7292 |
|
| 7293 | return event;
|
| 7294 | }
|
| 7295 | },
|
| 7296 |
|
| 7297 | special: {
|
| 7298 | load: {
|
| 7299 | // Prevent triggered image.load events from bubbling to window.load
|
| 7300 | noBubble: true
|
| 7301 | },
|
| 7302 | focus: {
|
| 7303 | // Fire native event if possible so blur/focus sequence is correct
|
| 7304 | trigger: function() {
|
| 7305 | if ( this !== safeActiveElement() && this.focus ) {
|
| 7306 | try {
|
| 7307 | this.focus();
|
| 7308 | return false;
|
| 7309 | } catch ( e ) {
|
| 7310 | // Support: IE<9
|
| 7311 | // If we error on focus to hidden element (#1486, #12518),
|
| 7312 | // let .trigger() run the handlers
|
| 7313 | }
|
| 7314 | }
|
| 7315 | },
|
| 7316 | delegateType: "focusin"
|
| 7317 | },
|
| 7318 | blur: {
|
| 7319 | trigger: function() {
|
| 7320 | if ( this === safeActiveElement() && this.blur ) {
|
| 7321 | this.blur();
|
| 7322 | return false;
|
| 7323 | }
|
| 7324 | },
|
| 7325 | delegateType: "focusout"
|
| 7326 | },
|
| 7327 | click: {
|
| 7328 | // For checkbox, fire native event so checked state will be right
|
| 7329 | trigger: function() {
|
| 7330 | if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
|
| 7331 | this.click();
|
| 7332 | return false;
|
| 7333 | }
|
| 7334 | },
|
| 7335 |
|
| 7336 | // For cross-browser consistency, don't fire native .click() on links
|
| 7337 | _default: function( event ) {
|
| 7338 | return jQuery.nodeName( event.target, "a" );
|
| 7339 | }
|
| 7340 | },
|
| 7341 |
|
| 7342 | beforeunload: {
|
| 7343 | postDispatch: function( event ) {
|
| 7344 |
|
| 7345 | // Even when returnValue equals to undefined Firefox will still show alert
|
| 7346 | if ( event.result !== undefined ) {
|
| 7347 | event.originalEvent.returnValue = event.result;
|
| 7348 | }
|
| 7349 | }
|
| 7350 | }
|
| 7351 | },
|
| 7352 |
|
| 7353 | simulate: function( type, elem, event, bubble ) {
|
| 7354 | // Piggyback on a donor event to simulate a different one.
|
| 7355 | // Fake originalEvent to avoid donor's stopPropagation, but if the
|
| 7356 | // simulated event prevents default then we do the same on the donor.
|
| 7357 | var e = jQuery.extend(
|
| 7358 | new jQuery.Event(),
|
| 7359 | event,
|
| 7360 | {
|
| 7361 | type: type,
|
| 7362 | isSimulated: true,
|
| 7363 | originalEvent: {}
|
| 7364 | }
|
| 7365 | );
|
| 7366 | if ( bubble ) {
|
| 7367 | jQuery.event.trigger( e, null, elem );
|
| 7368 | } else {
|
| 7369 | jQuery.event.dispatch.call( elem, e );
|
| 7370 | }
|
| 7371 | if ( e.isDefaultPrevented() ) {
|
| 7372 | event.preventDefault();
|
| 7373 | }
|
| 7374 | }
|
| 7375 | };
|
| 7376 |
|
| 7377 | jQuery.removeEvent = document.removeEventListener ?
|
| 7378 | function( elem, type, handle ) {
|
| 7379 | if ( elem.removeEventListener ) {
|
| 7380 | elem.removeEventListener( type, handle, false );
|
| 7381 | }
|
| 7382 | } :
|
| 7383 | function( elem, type, handle ) {
|
| 7384 | var name = "on" + type;
|
| 7385 |
|
| 7386 | if ( elem.detachEvent ) {
|
| 7387 |
|
| 7388 | // #8545, #7054, preventing memory leaks for custom events in IE6-8
|
| 7389 | // detachEvent needed property on element, by name of that event, to properly expose it to GC
|
| 7390 | if ( typeof elem[ name ] === core_strundefined ) {
|
| 7391 | elem[ name ] = null;
|
| 7392 | }
|
| 7393 |
|
| 7394 | elem.detachEvent( name, handle );
|
| 7395 | }
|
| 7396 | };
|
| 7397 |
|
| 7398 | jQuery.Event = function( src, props ) {
|
| 7399 | // Allow instantiation without the 'new' keyword
|
| 7400 | if ( !(this instanceof jQuery.Event) ) {
|
| 7401 | return new jQuery.Event( src, props );
|
| 7402 | }
|
| 7403 |
|
| 7404 | // Event object
|
| 7405 | if ( src && src.type ) {
|
| 7406 | this.originalEvent = src;
|
| 7407 | this.type = src.type;
|
| 7408 |
|
| 7409 | // Events bubbling up the document may have been marked as prevented
|
| 7410 | // by a handler lower down the tree; reflect the correct value.
|
| 7411 | this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
|
| 7412 | src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
|
| 7413 |
|
| 7414 | // Event type
|
| 7415 | } else {
|
| 7416 | this.type = src;
|
| 7417 | }
|
| 7418 |
|
| 7419 | // Put explicitly provided properties onto the event object
|
| 7420 | if ( props ) {
|
| 7421 | jQuery.extend( this, props );
|
| 7422 | }
|
| 7423 |
|
| 7424 | // Create a timestamp if incoming event doesn't have one
|
| 7425 | this.timeStamp = src && src.timeStamp || jQuery.now();
|
| 7426 |
|
| 7427 | // Mark it as fixed
|
| 7428 | this[ jQuery.expando ] = true;
|
| 7429 | };
|
| 7430 |
|
| 7431 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
| 7432 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
| 7433 | jQuery.Event.prototype = {
|
| 7434 | isDefaultPrevented: returnFalse,
|
| 7435 | isPropagationStopped: returnFalse,
|
| 7436 | isImmediatePropagationStopped: returnFalse,
|
| 7437 |
|
| 7438 | preventDefault: function() {
|
| 7439 | var e = this.originalEvent;
|
| 7440 |
|
| 7441 | this.isDefaultPrevented = returnTrue;
|
| 7442 | if ( !e ) {
|
| 7443 | return;
|
| 7444 | }
|
| 7445 |
|
| 7446 | // If preventDefault exists, run it on the original event
|
| 7447 | if ( e.preventDefault ) {
|
| 7448 | e.preventDefault();
|
| 7449 |
|
| 7450 | // Support: IE
|
| 7451 | // Otherwise set the returnValue property of the original event to false
|
| 7452 | } else {
|
| 7453 | e.returnValue = false;
|
| 7454 | }
|
| 7455 | },
|
| 7456 | stopPropagation: function() {
|
| 7457 | var e = this.originalEvent;
|
| 7458 |
|
| 7459 | this.isPropagationStopped = returnTrue;
|
| 7460 | if ( !e ) {
|
| 7461 | return;
|
| 7462 | }
|
| 7463 | // If stopPropagation exists, run it on the original event
|
| 7464 | if ( e.stopPropagation ) {
|
| 7465 | e.stopPropagation();
|
| 7466 | }
|
| 7467 |
|
| 7468 | // Support: IE
|
| 7469 | // Set the cancelBubble property of the original event to true
|
| 7470 | e.cancelBubble = true;
|
| 7471 | },
|
| 7472 | stopImmediatePropagation: function() {
|
| 7473 | this.isImmediatePropagationStopped = returnTrue;
|
| 7474 | this.stopPropagation();
|
| 7475 | }
|
| 7476 | };
|
| 7477 |
|
| 7478 | // Create mouseenter/leave events using mouseover/out and event-time checks
|
| 7479 | jQuery.each({
|
| 7480 | mouseenter: "mouseover",
|
| 7481 | mouseleave: "mouseout"
|
| 7482 | }, function( orig, fix ) {
|
| 7483 | jQuery.event.special[ orig ] = {
|
| 7484 | delegateType: fix,
|
| 7485 | bindType: fix,
|
| 7486 |
|
| 7487 | handle: function( event ) {
|
| 7488 | var ret,
|
| 7489 | target = this,
|
| 7490 | related = event.relatedTarget,
|
| 7491 | handleObj = event.handleObj;
|
| 7492 |
|
| 7493 | // For mousenter/leave call the handler if related is outside the target.
|
| 7494 | // NB: No relatedTarget if the mouse left/entered the browser window
|
| 7495 | if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
|
| 7496 | event.type = handleObj.origType;
|
| 7497 | ret = handleObj.handler.apply( this, arguments );
|
| 7498 | event.type = fix;
|
| 7499 | }
|
| 7500 | return ret;
|
| 7501 | }
|
| 7502 | };
|
| 7503 | });
|
| 7504 |
|
| 7505 | // IE submit delegation
|
| 7506 | if ( !jQuery.support.submitBubbles ) {
|
| 7507 |
|
| 7508 | jQuery.event.special.submit = {
|
| 7509 | setup: function() {
|
| 7510 | // Only need this for delegated form submit events
|
| 7511 | if ( jQuery.nodeName( this, "form" ) ) {
|
| 7512 | return false;
|
| 7513 | }
|
| 7514 |
|
| 7515 | // Lazy-add a submit handler when a descendant form may potentially be submitted
|
| 7516 | jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
|
| 7517 | // Node name check avoids a VML-related crash in IE (#9807)
|
| 7518 | var elem = e.target,
|
| 7519 | form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
|
| 7520 | if ( form && !jQuery._data( form, "submitBubbles" ) ) {
|
| 7521 | jQuery.event.add( form, "submit._submit", function( event ) {
|
| 7522 | event._submit_bubble = true;
|
| 7523 | });
|
| 7524 | jQuery._data( form, "submitBubbles", true );
|
| 7525 | }
|
| 7526 | });
|
| 7527 | // return undefined since we don't need an event listener
|
| 7528 | },
|
| 7529 |
|
| 7530 | postDispatch: function( event ) {
|
| 7531 | // If form was submitted by the user, bubble the event up the tree
|
| 7532 | if ( event._submit_bubble ) {
|
| 7533 | delete event._submit_bubble;
|
| 7534 | if ( this.parentNode && !event.isTrigger ) {
|
| 7535 | jQuery.event.simulate( "submit", this.parentNode, event, true );
|
| 7536 | }
|
| 7537 | }
|
| 7538 | },
|
| 7539 |
|
| 7540 | teardown: function() {
|
| 7541 | // Only need this for delegated form submit events
|
| 7542 | if ( jQuery.nodeName( this, "form" ) ) {
|
| 7543 | return false;
|
| 7544 | }
|
| 7545 |
|
| 7546 | // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
|
| 7547 | jQuery.event.remove( this, "._submit" );
|
| 7548 | }
|
| 7549 | };
|
| 7550 | }
|
| 7551 |
|
| 7552 | // IE change delegation and checkbox/radio fix
|
| 7553 | if ( !jQuery.support.changeBubbles ) {
|
| 7554 |
|
| 7555 | jQuery.event.special.change = {
|
| 7556 |
|
| 7557 | setup: function() {
|
| 7558 |
|
| 7559 | if ( rformElems.test( this.nodeName ) ) {
|
| 7560 | // IE doesn't fire change on a check/radio until blur; trigger it on click
|
| 7561 | // after a propertychange. Eat the blur-change in special.change.handle.
|
| 7562 | // This still fires onchange a second time for check/radio after blur.
|
| 7563 | if ( this.type === "checkbox" || this.type === "radio" ) {
|
| 7564 | jQuery.event.add( this, "propertychange._change", function( event ) {
|
| 7565 | if ( event.originalEvent.propertyName === "checked" ) {
|
| 7566 | this._just_changed = true;
|
| 7567 | }
|
| 7568 | });
|
| 7569 | jQuery.event.add( this, "click._change", function( event ) {
|
| 7570 | if ( this._just_changed && !event.isTrigger ) {
|
| 7571 | this._just_changed = false;
|
| 7572 | }
|
| 7573 | // Allow triggered, simulated change events (#11500)
|
| 7574 | jQuery.event.simulate( "change", this, event, true );
|
| 7575 | });
|
| 7576 | }
|
| 7577 | return false;
|
| 7578 | }
|
| 7579 | // Delegated event; lazy-add a change handler on descendant inputs
|
| 7580 | jQuery.event.add( this, "beforeactivate._change", function( e ) {
|
| 7581 | var elem = e.target;
|
| 7582 |
|
| 7583 | if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
|
| 7584 | jQuery.event.add( elem, "change._change", function( event ) {
|
| 7585 | if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
|
| 7586 | jQuery.event.simulate( "change", this.parentNode, event, true );
|
| 7587 | }
|
| 7588 | });
|
| 7589 | jQuery._data( elem, "changeBubbles", true );
|
| 7590 | }
|
| 7591 | });
|
| 7592 | },
|
| 7593 |
|
| 7594 | handle: function( event ) {
|
| 7595 | var elem = event.target;
|
| 7596 |
|
| 7597 | // Swallow native change events from checkbox/radio, we already triggered them above
|
| 7598 | if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
|
| 7599 | return event.handleObj.handler.apply( this, arguments );
|
| 7600 | }
|
| 7601 | },
|
| 7602 |
|
| 7603 | teardown: function() {
|
| 7604 | jQuery.event.remove( this, "._change" );
|
| 7605 |
|
| 7606 | return !rformElems.test( this.nodeName );
|
| 7607 | }
|
| 7608 | };
|
| 7609 | }
|
| 7610 |
|
| 7611 | // Create "bubbling" focus and blur events
|
| 7612 | if ( !jQuery.support.focusinBubbles ) {
|
| 7613 | jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
| 7614 |
|
| 7615 | // Attach a single capturing handler while someone wants focusin/focusout
|
| 7616 | var attaches = 0,
|
| 7617 | handler = function( event ) {
|
| 7618 | jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
|
| 7619 | };
|
| 7620 |
|
| 7621 | jQuery.event.special[ fix ] = {
|
| 7622 | setup: function() {
|
| 7623 | if ( attaches++ === 0 ) {
|
| 7624 | document.addEventListener( orig, handler, true );
|
| 7625 | }
|
| 7626 | },
|
| 7627 | teardown: function() {
|
| 7628 | if ( --attaches === 0 ) {
|
| 7629 | document.removeEventListener( orig, handler, true );
|
| 7630 | }
|
| 7631 | }
|
| 7632 | };
|
| 7633 | });
|
| 7634 | }
|
| 7635 |
|
| 7636 | jQuery.fn.extend({
|
| 7637 |
|
| 7638 | on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
|
| 7639 | var type, origFn;
|
| 7640 |
|
| 7641 | // Types can be a map of types/handlers
|
| 7642 | if ( typeof types === "object" ) {
|
| 7643 | // ( types-Object, selector, data )
|
| 7644 | if ( typeof selector !== "string" ) {
|
| 7645 | // ( types-Object, data )
|
| 7646 | data = data || selector;
|
| 7647 | selector = undefined;
|
| 7648 | }
|
| 7649 | for ( type in types ) {
|
| 7650 | this.on( type, selector, data, types[ type ], one );
|
| 7651 | }
|
| 7652 | return this;
|
| 7653 | }
|
| 7654 |
|
| 7655 | if ( data == null && fn == null ) {
|
| 7656 | // ( types, fn )
|
| 7657 | fn = selector;
|
| 7658 | data = selector = undefined;
|
| 7659 | } else if ( fn == null ) {
|
| 7660 | if ( typeof selector === "string" ) {
|
| 7661 | // ( types, selector, fn )
|
| 7662 | fn = data;
|
| 7663 | data = undefined;
|
| 7664 | } else {
|
| 7665 | // ( types, data, fn )
|
| 7666 | fn = data;
|
| 7667 | data = selector;
|
| 7668 | selector = undefined;
|
| 7669 | }
|
| 7670 | }
|
| 7671 | if ( fn === false ) {
|
| 7672 | fn = returnFalse;
|
| 7673 | } else if ( !fn ) {
|
| 7674 | return this;
|
| 7675 | }
|
| 7676 |
|
| 7677 | if ( one === 1 ) {
|
| 7678 | origFn = fn;
|
| 7679 | fn = function( event ) {
|
| 7680 | // Can use an empty set, since event contains the info
|
| 7681 | jQuery().off( event );
|
| 7682 | return origFn.apply( this, arguments );
|
| 7683 | };
|
| 7684 | // Use same guid so caller can remove using origFn
|
| 7685 | fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
|
| 7686 | }
|
| 7687 | return this.each( function() {
|
| 7688 | jQuery.event.add( this, types, fn, data, selector );
|
| 7689 | });
|
| 7690 | },
|
| 7691 | one: function( types, selector, data, fn ) {
|
| 7692 | return this.on( types, selector, data, fn, 1 );
|
| 7693 | },
|
| 7694 | off: function( types, selector, fn ) {
|
| 7695 | var handleObj, type;
|
| 7696 | if ( types && types.preventDefault && types.handleObj ) {
|
| 7697 | // ( event ) dispatched jQuery.Event
|
| 7698 | handleObj = types.handleObj;
|
| 7699 | jQuery( types.delegateTarget ).off(
|
| 7700 | handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
|
| 7701 | handleObj.selector,
|
| 7702 | handleObj.handler
|
| 7703 | );
|
| 7704 | return this;
|
| 7705 | }
|
| 7706 | if ( typeof types === "object" ) {
|
| 7707 | // ( types-object [, selector] )
|
| 7708 | for ( type in types ) {
|
| 7709 | this.off( type, selector, types[ type ] );
|
| 7710 | }
|
| 7711 | return this;
|
| 7712 | }
|
| 7713 | if ( selector === false || typeof selector === "function" ) {
|
| 7714 | // ( types [, fn] )
|
| 7715 | fn = selector;
|
| 7716 | selector = undefined;
|
| 7717 | }
|
| 7718 | if ( fn === false ) {
|
| 7719 | fn = returnFalse;
|
| 7720 | }
|
| 7721 | return this.each(function() {
|
| 7722 | jQuery.event.remove( this, types, fn, selector );
|
| 7723 | });
|
| 7724 | },
|
| 7725 |
|
| 7726 | trigger: function( type, data ) {
|
| 7727 | return this.each(function() {
|
| 7728 | jQuery.event.trigger( type, data, this );
|
| 7729 | });
|
| 7730 | },
|
| 7731 | triggerHandler: function( type, data ) {
|
| 7732 | var elem = this[0];
|
| 7733 | if ( elem ) {
|
| 7734 | return jQuery.event.trigger( type, data, elem, true );
|
| 7735 | }
|
| 7736 | }
|
| 7737 | });
|
| 7738 | var isSimple = /^.[^:#\[\.,]*$/,
|
| 7739 | rparentsprev = /^(?:parents|prev(?:Until|All))/,
|
| 7740 | rneedsContext = jQuery.expr.match.needsContext,
|
| 7741 | // methods guaranteed to produce a unique set when starting from a unique set
|
| 7742 | guaranteedUnique = {
|
| 7743 | children: true,
|
| 7744 | contents: true,
|
| 7745 | next: true,
|
| 7746 | prev: true
|
| 7747 | };
|
| 7748 |
|
| 7749 | jQuery.fn.extend({
|
| 7750 | find: function( selector ) {
|
| 7751 | var i,
|
| 7752 | ret = [],
|
| 7753 | self = this,
|
| 7754 | len = self.length;
|
| 7755 |
|
| 7756 | if ( typeof selector !== "string" ) {
|
| 7757 | return this.pushStack( jQuery( selector ).filter(function() {
|
| 7758 | for ( i = 0; i < len; i++ ) {
|
| 7759 | if ( jQuery.contains( self[ i ], this ) ) {
|
| 7760 | return true;
|
| 7761 | }
|
| 7762 | }
|
| 7763 | }) );
|
| 7764 | }
|
| 7765 |
|
| 7766 | for ( i = 0; i < len; i++ ) {
|
| 7767 | jQuery.find( selector, self[ i ], ret );
|
| 7768 | }
|
| 7769 |
|
| 7770 | // Needed because $( selector, context ) becomes $( context ).find( selector )
|
| 7771 | ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
|
| 7772 | ret.selector = this.selector ? this.selector + " " + selector : selector;
|
| 7773 | return ret;
|
| 7774 | },
|
| 7775 |
|
| 7776 | has: function( target ) {
|
| 7777 | var i,
|
| 7778 | targets = jQuery( target, this ),
|
| 7779 | len = targets.length;
|
| 7780 |
|
| 7781 | return this.filter(function() {
|
| 7782 | for ( i = 0; i < len; i++ ) {
|
| 7783 | if ( jQuery.contains( this, targets[i] ) ) {
|
| 7784 | return true;
|
| 7785 | }
|
| 7786 | }
|
| 7787 | });
|
| 7788 | },
|
| 7789 |
|
| 7790 | not: function( selector ) {
|
| 7791 | return this.pushStack( winnow(this, selector || [], true) );
|
| 7792 | },
|
| 7793 |
|
| 7794 | filter: function( selector ) {
|
| 7795 | return this.pushStack( winnow(this, selector || [], false) );
|
| 7796 | },
|
| 7797 |
|
| 7798 | is: function( selector ) {
|
| 7799 | return !!winnow(
|
| 7800 | this,
|
| 7801 |
|
| 7802 | // If this is a positional/relative selector, check membership in the returned set
|
| 7803 | // so $("p:first").is("p:last") won't return true for a doc with two "p".
|
| 7804 | typeof selector === "string" && rneedsContext.test( selector ) ?
|
| 7805 | jQuery( selector ) :
|
| 7806 | selector || [],
|
| 7807 | false
|
| 7808 | ).length;
|
| 7809 | },
|
| 7810 |
|
| 7811 | closest: function( selectors, context ) {
|
| 7812 | var cur,
|
| 7813 | i = 0,
|
| 7814 | l = this.length,
|
| 7815 | ret = [],
|
| 7816 | pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
|
| 7817 | jQuery( selectors, context || this.context ) :
|
| 7818 | 0;
|
| 7819 |
|
| 7820 | for ( ; i < l; i++ ) {
|
| 7821 | for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
|
| 7822 | // Always skip document fragments
|
| 7823 | if ( cur.nodeType < 11 && (pos ?
|
| 7824 | pos.index(cur) > -1 :
|
| 7825 |
|
| 7826 | // Don't pass non-elements to Sizzle
|
| 7827 | cur.nodeType === 1 &&
|
| 7828 | jQuery.find.matchesSelector(cur, selectors)) ) {
|
| 7829 |
|
| 7830 | cur = ret.push( cur );
|
| 7831 | break;
|
| 7832 | }
|
| 7833 | }
|
| 7834 | }
|
| 7835 |
|
| 7836 | return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret );
|
| 7837 | },
|
| 7838 |
|
| 7839 | // Determine the position of an element within
|
| 7840 | // the matched set of elements
|
| 7841 | index: function( elem ) {
|
| 7842 |
|
| 7843 | // No argument, return index in parent
|
| 7844 | if ( !elem ) {
|
| 7845 | return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
|
| 7846 | }
|
| 7847 |
|
| 7848 | // index in selector
|
| 7849 | if ( typeof elem === "string" ) {
|
| 7850 | return jQuery.inArray( this[0], jQuery( elem ) );
|
| 7851 | }
|
| 7852 |
|
| 7853 | // Locate the position of the desired element
|
| 7854 | return jQuery.inArray(
|
| 7855 | // If it receives a jQuery object, the first element is used
|
| 7856 | elem.jquery ? elem[0] : elem, this );
|
| 7857 | },
|
| 7858 |
|
| 7859 | add: function( selector, context ) {
|
| 7860 | var set = typeof selector === "string" ?
|
| 7861 | jQuery( selector, context ) :
|
| 7862 | jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
|
| 7863 | all = jQuery.merge( this.get(), set );
|
| 7864 |
|
| 7865 | return this.pushStack( jQuery.unique(all) );
|
| 7866 | },
|
| 7867 |
|
| 7868 | addBack: function( selector ) {
|
| 7869 | return this.add( selector == null ?
|
| 7870 | this.prevObject : this.prevObject.filter(selector)
|
| 7871 | );
|
| 7872 | }
|
| 7873 | });
|
| 7874 |
|
| 7875 | function sibling( cur, dir ) {
|
| 7876 | do {
|
| 7877 | cur = cur[ dir ];
|
| 7878 | } while ( cur && cur.nodeType !== 1 );
|
| 7879 |
|
| 7880 | return cur;
|
| 7881 | }
|
| 7882 |
|
| 7883 | jQuery.each({
|
| 7884 | parent: function( elem ) {
|
| 7885 | var parent = elem.parentNode;
|
| 7886 | return parent && parent.nodeType !== 11 ? parent : null;
|
| 7887 | },
|
| 7888 | parents: function( elem ) {
|
| 7889 | return jQuery.dir( elem, "parentNode" );
|
| 7890 | },
|
| 7891 | parentsUntil: function( elem, i, until ) {
|
| 7892 | return jQuery.dir( elem, "parentNode", until );
|
| 7893 | },
|
| 7894 | next: function( elem ) {
|
| 7895 | return sibling( elem, "nextSibling" );
|
| 7896 | },
|
| 7897 | prev: function( elem ) {
|
| 7898 | return sibling( elem, "previousSibling" );
|
| 7899 | },
|
| 7900 | nextAll: function( elem ) {
|
| 7901 | return jQuery.dir( elem, "nextSibling" );
|
| 7902 | },
|
| 7903 | prevAll: function( elem ) {
|
| 7904 | return jQuery.dir( elem, "previousSibling" );
|
| 7905 | },
|
| 7906 | nextUntil: function( elem, i, until ) {
|
| 7907 | return jQuery.dir( elem, "nextSibling", until );
|
| 7908 | },
|
| 7909 | prevUntil: function( elem, i, until ) {
|
| 7910 | return jQuery.dir( elem, "previousSibling", until );
|
| 7911 | },
|
| 7912 | siblings: function( elem ) {
|
| 7913 | return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
|
| 7914 | },
|
| 7915 | children: function( elem ) {
|
| 7916 | return jQuery.sibling( elem.firstChild );
|
| 7917 | },
|
| 7918 | contents: function( elem ) {
|
| 7919 | return jQuery.nodeName( elem, "iframe" ) ?
|
| 7920 | elem.contentDocument || elem.contentWindow.document :
|
| 7921 | jQuery.merge( [], elem.childNodes );
|
| 7922 | }
|
| 7923 | }, function( name, fn ) {
|
| 7924 | jQuery.fn[ name ] = function( until, selector ) {
|
| 7925 | var ret = jQuery.map( this, fn, until );
|
| 7926 |
|
| 7927 | if ( name.slice( -5 ) !== "Until" ) {
|
| 7928 | selector = until;
|
| 7929 | }
|
| 7930 |
|
| 7931 | if ( selector && typeof selector === "string" ) {
|
| 7932 | ret = jQuery.filter( selector, ret );
|
| 7933 | }
|
| 7934 |
|
| 7935 | if ( this.length > 1 ) {
|
| 7936 | // Remove duplicates
|
| 7937 | if ( !guaranteedUnique[ name ] ) {
|
| 7938 | ret = jQuery.unique( ret );
|
| 7939 | }
|
| 7940 |
|
| 7941 | // Reverse order for parents* and prev-derivatives
|
| 7942 | if ( rparentsprev.test( name ) ) {
|
| 7943 | ret = ret.reverse();
|
| 7944 | }
|
| 7945 | }
|
| 7946 |
|
| 7947 | return this.pushStack( ret );
|
| 7948 | };
|
| 7949 | });
|
| 7950 |
|
| 7951 | jQuery.extend({
|
| 7952 | filter: function( expr, elems, not ) {
|
| 7953 | var elem = elems[ 0 ];
|
| 7954 |
|
| 7955 | if ( not ) {
|
| 7956 | expr = ":not(" + expr + ")";
|
| 7957 | }
|
| 7958 |
|
| 7959 | return elems.length === 1 && elem.nodeType === 1 ?
|
| 7960 | jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
|
| 7961 | jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
|
| 7962 | return elem.nodeType === 1;
|
| 7963 | }));
|
| 7964 | },
|
| 7965 |
|
| 7966 | dir: function( elem, dir, until ) {
|
| 7967 | var matched = [],
|
| 7968 | cur = elem[ dir ];
|
| 7969 |
|
| 7970 | while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
|
| 7971 | if ( cur.nodeType === 1 ) {
|
| 7972 | matched.push( cur );
|
| 7973 | }
|
| 7974 | cur = cur[dir];
|
| 7975 | }
|
| 7976 | return matched;
|
| 7977 | },
|
| 7978 |
|
| 7979 | sibling: function( n, elem ) {
|
| 7980 | var r = [];
|
| 7981 |
|
| 7982 | for ( ; n; n = n.nextSibling ) {
|
| 7983 | if ( n.nodeType === 1 && n !== elem ) {
|
| 7984 | r.push( n );
|
| 7985 | }
|
| 7986 | }
|
| 7987 |
|
| 7988 | return r;
|
| 7989 | }
|
| 7990 | });
|
| 7991 |
|
| 7992 | // Implement the identical functionality for filter and not
|
| 7993 | function winnow( elements, qualifier, not ) {
|
| 7994 | if ( jQuery.isFunction( qualifier ) ) {
|
| 7995 | return jQuery.grep( elements, function( elem, i ) {
|
| 7996 | /* jshint -W018 */
|
| 7997 | return !!qualifier.call( elem, i, elem ) !== not;
|
| 7998 | });
|
| 7999 |
|
| 8000 | }
|
| 8001 |
|
| 8002 | if ( qualifier.nodeType ) {
|
| 8003 | return jQuery.grep( elements, function( elem ) {
|
| 8004 | return ( elem === qualifier ) !== not;
|
| 8005 | });
|
| 8006 |
|
| 8007 | }
|
| 8008 |
|
| 8009 | if ( typeof qualifier === "string" ) {
|
| 8010 | if ( isSimple.test( qualifier ) ) {
|
| 8011 | return jQuery.filter( qualifier, elements, not );
|
| 8012 | }
|
| 8013 |
|
| 8014 | qualifier = jQuery.filter( qualifier, elements );
|
| 8015 | }
|
| 8016 |
|
| 8017 | return jQuery.grep( elements, function( elem ) {
|
| 8018 | return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
|
| 8019 | });
|
| 8020 | }
|
| 8021 | function createSafeFragment( document ) {
|
| 8022 | var list = nodeNames.split( "|" ),
|
| 8023 | safeFrag = document.createDocumentFragment();
|
| 8024 |
|
| 8025 | if ( safeFrag.createElement ) {
|
| 8026 | while ( list.length ) {
|
| 8027 | safeFrag.createElement(
|
| 8028 | list.pop()
|
| 8029 | );
|
| 8030 | }
|
| 8031 | }
|
| 8032 | return safeFrag;
|
| 8033 | }
|
| 8034 |
|
| 8035 | var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
|
| 8036 | "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
|
| 8037 | rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
|
| 8038 | rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
|
| 8039 | rleadingWhitespace = /^\s+/,
|
| 8040 | rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
| 8041 | rtagName = /<([\w:]+)/,
|
| 8042 | rtbody = /<tbody/i,
|
| 8043 | rhtml = /<|&#?\w+;/,
|
| 8044 | rnoInnerhtml = /<(?:script|style|link)/i,
|
| 8045 | manipulation_rcheckableType = /^(?:checkbox|radio)$/i,
|
| 8046 | // checked="checked" or checked
|
| 8047 | rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
| 8048 | rscriptType = /^$|\/(?:java|ecma)script/i,
|
| 8049 | rscriptTypeMasked = /^true\/(.*)/,
|
| 8050 | rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
|
| 8051 |
|
| 8052 | // We have to close these tags to support XHTML (#13200)
|
| 8053 | wrapMap = {
|
| 8054 | option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
| 8055 | legend: [ 1, "<fieldset>", "</fieldset>" ],
|
| 8056 | area: [ 1, "<map>", "</map>" ],
|
| 8057 | param: [ 1, "<object>", "</object>" ],
|
| 8058 | thead: [ 1, "<table>", "</table>" ],
|
| 8059 | tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
| 8060 | col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
| 8061 | td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
| 8062 |
|
| 8063 | // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
|
| 8064 | // unless wrapped in a div with non-breaking characters in front of it.
|
| 8065 | _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
|
| 8066 | },
|
| 8067 | safeFragment = createSafeFragment( document ),
|
| 8068 | fragmentDiv = safeFragment.appendChild( document.createElement("div") );
|
| 8069 |
|
| 8070 | wrapMap.optgroup = wrapMap.option;
|
| 8071 | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
| 8072 | wrapMap.th = wrapMap.td;
|
| 8073 |
|
| 8074 | jQuery.fn.extend({
|
| 8075 | text: function( value ) {
|
| 8076 | return jQuery.access( this, function( value ) {
|
| 8077 | return value === undefined ?
|
| 8078 | jQuery.text( this ) :
|
| 8079 | this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
|
| 8080 | }, null, value, arguments.length );
|
| 8081 | },
|
| 8082 |
|
| 8083 | append: function() {
|
| 8084 | return this.domManip( arguments, function( elem ) {
|
| 8085 | if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
| 8086 | var target = manipulationTarget( this, elem );
|
| 8087 | target.appendChild( elem );
|
| 8088 | }
|
| 8089 | });
|
| 8090 | },
|
| 8091 |
|
| 8092 | prepend: function() {
|
| 8093 | return this.domManip( arguments, function( elem ) {
|
| 8094 | if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
| 8095 | var target = manipulationTarget( this, elem );
|
| 8096 | target.insertBefore( elem, target.firstChild );
|
| 8097 | }
|
| 8098 | });
|
| 8099 | },
|
| 8100 |
|
| 8101 | before: function() {
|
| 8102 | return this.domManip( arguments, function( elem ) {
|
| 8103 | if ( this.parentNode ) {
|
| 8104 | this.parentNode.insertBefore( elem, this );
|
| 8105 | }
|
| 8106 | });
|
| 8107 | },
|
| 8108 |
|
| 8109 | after: function() {
|
| 8110 | return this.domManip( arguments, function( elem ) {
|
| 8111 | if ( this.parentNode ) {
|
| 8112 | this.parentNode.insertBefore( elem, this.nextSibling );
|
| 8113 | }
|
| 8114 | });
|
| 8115 | },
|
| 8116 |
|
| 8117 | // keepData is for internal use only--do not document
|
| 8118 | remove: function( selector, keepData ) {
|
| 8119 | var elem,
|
| 8120 | elems = selector ? jQuery.filter( selector, this ) : this,
|
| 8121 | i = 0;
|
| 8122 |
|
| 8123 | for ( ; (elem = elems[i]) != null; i++ ) {
|
| 8124 |
|
| 8125 | if ( !keepData && elem.nodeType === 1 ) {
|
| 8126 | jQuery.cleanData( getAll( elem ) );
|
| 8127 | }
|
| 8128 |
|
| 8129 | if ( elem.parentNode ) {
|
| 8130 | if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
| 8131 | setGlobalEval( getAll( elem, "script" ) );
|
| 8132 | }
|
| 8133 | elem.parentNode.removeChild( elem );
|
| 8134 | }
|
| 8135 | }
|
| 8136 |
|
| 8137 | return this;
|
| 8138 | },
|
| 8139 |
|
| 8140 | empty: function() {
|
| 8141 | var elem,
|
| 8142 | i = 0;
|
| 8143 |
|
| 8144 | for ( ; (elem = this[i]) != null; i++ ) {
|
| 8145 | // Remove element nodes and prevent memory leaks
|
| 8146 | if ( elem.nodeType === 1 ) {
|
| 8147 | jQuery.cleanData( getAll( elem, false ) );
|
| 8148 | }
|
| 8149 |
|
| 8150 | // Remove any remaining nodes
|
| 8151 | while ( elem.firstChild ) {
|
| 8152 | elem.removeChild( elem.firstChild );
|
| 8153 | }
|
| 8154 |
|
| 8155 | // If this is a select, ensure that it displays empty (#12336)
|
| 8156 | // Support: IE<9
|
| 8157 | if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
|
| 8158 | elem.options.length = 0;
|
| 8159 | }
|
| 8160 | }
|
| 8161 |
|
| 8162 | return this;
|
| 8163 | },
|
| 8164 |
|
| 8165 | clone: function( dataAndEvents, deepDataAndEvents ) {
|
| 8166 | dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
| 8167 | deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
| 8168 |
|
| 8169 | return this.map( function () {
|
| 8170 | return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
| 8171 | });
|
| 8172 | },
|
| 8173 |
|
| 8174 | html: function( value ) {
|
| 8175 | return jQuery.access( this, function( value ) {
|
| 8176 | var elem = this[0] || {},
|
| 8177 | i = 0,
|
| 8178 | l = this.length;
|
| 8179 |
|
| 8180 | if ( value === undefined ) {
|
| 8181 | return elem.nodeType === 1 ?
|
| 8182 | elem.innerHTML.replace( rinlinejQuery, "" ) :
|
| 8183 | undefined;
|
| 8184 | }
|
| 8185 |
|
| 8186 | // See if we can take a shortcut and just use innerHTML
|
| 8187 | if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
| 8188 | ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
|
| 8189 | ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
|
| 8190 | !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
|
| 8191 |
|
| 8192 | value = value.replace( rxhtmlTag, "<$1></$2>" );
|
| 8193 |
|
| 8194 | try {
|
| 8195 | for (; i < l; i++ ) {
|
| 8196 | // Remove element nodes and prevent memory leaks
|
| 8197 | elem = this[i] || {};
|
| 8198 | if ( elem.nodeType === 1 ) {
|
| 8199 | jQuery.cleanData( getAll( elem, false ) );
|
| 8200 | elem.innerHTML = value;
|
| 8201 | }
|
| 8202 | }
|
| 8203 |
|
| 8204 | elem = 0;
|
| 8205 |
|
| 8206 | // If using innerHTML throws an exception, use the fallback method
|
| 8207 | } catch(e) {}
|
| 8208 | }
|
| 8209 |
|
| 8210 | if ( elem ) {
|
| 8211 | this.empty().append( value );
|
| 8212 | }
|
| 8213 | }, null, value, arguments.length );
|
| 8214 | },
|
| 8215 |
|
| 8216 | replaceWith: function() {
|
| 8217 | var
|
| 8218 | // Snapshot the DOM in case .domManip sweeps something relevant into its fragment
|
| 8219 | args = jQuery.map( this, function( elem ) {
|
| 8220 | return [ elem.nextSibling, elem.parentNode ];
|
| 8221 | }),
|
| 8222 | i = 0;
|
| 8223 |
|
| 8224 | // Make the changes, replacing each context element with the new content
|
| 8225 | this.domManip( arguments, function( elem ) {
|
| 8226 | var next = args[ i++ ],
|
| 8227 | parent = args[ i++ ];
|
| 8228 |
|
| 8229 | if ( parent ) {
|
| 8230 | // Don't use the snapshot next if it has moved (#13810)
|
| 8231 | if ( next && next.parentNode !== parent ) {
|
| 8232 | next = this.nextSibling;
|
| 8233 | }
|
| 8234 | jQuery( this ).remove();
|
| 8235 | parent.insertBefore( elem, next );
|
| 8236 | }
|
| 8237 | // Allow new content to include elements from the context set
|
| 8238 | }, true );
|
| 8239 |
|
| 8240 | // Force removal if there was no new content (e.g., from empty arguments)
|
| 8241 | return i ? this : this.remove();
|
| 8242 | },
|
| 8243 |
|
| 8244 | detach: function( selector ) {
|
| 8245 | return this.remove( selector, true );
|
| 8246 | },
|
| 8247 |
|
| 8248 | domManip: function( args, callback, allowIntersection ) {
|
| 8249 |
|
| 8250 | // Flatten any nested arrays
|
| 8251 | args = core_concat.apply( [], args );
|
| 8252 |
|
| 8253 | var first, node, hasScripts,
|
| 8254 | scripts, doc, fragment,
|
| 8255 | i = 0,
|
| 8256 | l = this.length,
|
| 8257 | set = this,
|
| 8258 | iNoClone = l - 1,
|
| 8259 | value = args[0],
|
| 8260 | isFunction = jQuery.isFunction( value );
|
| 8261 |
|
| 8262 | // We can't cloneNode fragments that contain checked, in WebKit
|
| 8263 | if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
|
| 8264 | return this.each(function( index ) {
|
| 8265 | var self = set.eq( index );
|
| 8266 | if ( isFunction ) {
|
| 8267 | args[0] = value.call( this, index, self.html() );
|
| 8268 | }
|
| 8269 | self.domManip( args, callback, allowIntersection );
|
| 8270 | });
|
| 8271 | }
|
| 8272 |
|
| 8273 | if ( l ) {
|
| 8274 | fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );
|
| 8275 | first = fragment.firstChild;
|
| 8276 |
|
| 8277 | if ( fragment.childNodes.length === 1 ) {
|
| 8278 | fragment = first;
|
| 8279 | }
|
| 8280 |
|
| 8281 | if ( first ) {
|
| 8282 | scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
| 8283 | hasScripts = scripts.length;
|
| 8284 |
|
| 8285 | // Use the original fragment for the last item instead of the first because it can end up
|
| 8286 | // being emptied incorrectly in certain situations (#8070).
|
| 8287 | for ( ; i < l; i++ ) {
|
| 8288 | node = fragment;
|
| 8289 |
|
| 8290 | if ( i !== iNoClone ) {
|
| 8291 | node = jQuery.clone( node, true, true );
|
| 8292 |
|
| 8293 | // Keep references to cloned scripts for later restoration
|
| 8294 | if ( hasScripts ) {
|
| 8295 | jQuery.merge( scripts, getAll( node, "script" ) );
|
| 8296 | }
|
| 8297 | }
|
| 8298 |
|
| 8299 | callback.call( this[i], node, i );
|
| 8300 | }
|
| 8301 |
|
| 8302 | if ( hasScripts ) {
|
| 8303 | doc = scripts[ scripts.length - 1 ].ownerDocument;
|
| 8304 |
|
| 8305 | // Reenable scripts
|
| 8306 | jQuery.map( scripts, restoreScript );
|
| 8307 |
|
| 8308 | // Evaluate executable scripts on first document insertion
|
| 8309 | for ( i = 0; i < hasScripts; i++ ) {
|
| 8310 | node = scripts[ i ];
|
| 8311 | if ( rscriptType.test( node.type || "" ) &&
|
| 8312 | !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
| 8313 |
|
| 8314 | if ( node.src ) {
|
| 8315 | // Hope ajax is available...
|
| 8316 | jQuery._evalUrl( node.src );
|
| 8317 | } else {
|
| 8318 | jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
|
| 8319 | }
|
| 8320 | }
|
| 8321 | }
|
| 8322 | }
|
| 8323 |
|
| 8324 | // Fix #11809: Avoid leaking memory
|
| 8325 | fragment = first = null;
|
| 8326 | }
|
| 8327 | }
|
| 8328 |
|
| 8329 | return this;
|
| 8330 | }
|
| 8331 | });
|
| 8332 |
|
| 8333 | // Support: IE<8
|
| 8334 | // Manipulating tables requires a tbody
|
| 8335 | function manipulationTarget( elem, content ) {
|
| 8336 | return jQuery.nodeName( elem, "table" ) &&
|
| 8337 | jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ?
|
| 8338 |
|
| 8339 | elem.getElementsByTagName("tbody")[0] ||
|
| 8340 | elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
|
| 8341 | elem;
|
| 8342 | }
|
| 8343 |
|
| 8344 | // Replace/restore the type attribute of script elements for safe DOM manipulation
|
| 8345 | function disableScript( elem ) {
|
| 8346 | elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
|
| 8347 | return elem;
|
| 8348 | }
|
| 8349 | function restoreScript( elem ) {
|
| 8350 | var match = rscriptTypeMasked.exec( elem.type );
|
| 8351 | if ( match ) {
|
| 8352 | elem.type = match[1];
|
| 8353 | } else {
|
| 8354 | elem.removeAttribute("type");
|
| 8355 | }
|
| 8356 | return elem;
|
| 8357 | }
|
| 8358 |
|
| 8359 | // Mark scripts as having already been evaluated
|
| 8360 | function setGlobalEval( elems, refElements ) {
|
| 8361 | var elem,
|
| 8362 | i = 0;
|
| 8363 | for ( ; (elem = elems[i]) != null; i++ ) {
|
| 8364 | jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
|
| 8365 | }
|
| 8366 | }
|
| 8367 |
|
| 8368 | function cloneCopyEvent( src, dest ) {
|
| 8369 |
|
| 8370 | if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
| 8371 | return;
|
| 8372 | }
|
| 8373 |
|
| 8374 | var type, i, l,
|
| 8375 | oldData = jQuery._data( src ),
|
| 8376 | curData = jQuery._data( dest, oldData ),
|
| 8377 | events = oldData.events;
|
| 8378 |
|
| 8379 | if ( events ) {
|
| 8380 | delete curData.handle;
|
| 8381 | curData.events = {};
|
| 8382 |
|
| 8383 | for ( type in events ) {
|
| 8384 | for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
| 8385 | jQuery.event.add( dest, type, events[ type ][ i ] );
|
| 8386 | }
|
| 8387 | }
|
| 8388 | }
|
| 8389 |
|
| 8390 | // make the cloned public data object a copy from the original
|
| 8391 | if ( curData.data ) {
|
| 8392 | curData.data = jQuery.extend( {}, curData.data );
|
| 8393 | }
|
| 8394 | }
|
| 8395 |
|
| 8396 | function fixCloneNodeIssues( src, dest ) {
|
| 8397 | var nodeName, e, data;
|
| 8398 |
|
| 8399 | // We do not need to do anything for non-Elements
|
| 8400 | if ( dest.nodeType !== 1 ) {
|
| 8401 | return;
|
| 8402 | }
|
| 8403 |
|
| 8404 | nodeName = dest.nodeName.toLowerCase();
|
| 8405 |
|
| 8406 | // IE6-8 copies events bound via attachEvent when using cloneNode.
|
| 8407 | if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
|
| 8408 | data = jQuery._data( dest );
|
| 8409 |
|
| 8410 | for ( e in data.events ) {
|
| 8411 | jQuery.removeEvent( dest, e, data.handle );
|
| 8412 | }
|
| 8413 |
|
| 8414 | // Event data gets referenced instead of copied if the expando gets copied too
|
| 8415 | dest.removeAttribute( jQuery.expando );
|
| 8416 | }
|
| 8417 |
|
| 8418 | // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
|
| 8419 | if ( nodeName === "script" && dest.text !== src.text ) {
|
| 8420 | disableScript( dest ).text = src.text;
|
| 8421 | restoreScript( dest );
|
| 8422 |
|
| 8423 | // IE6-10 improperly clones children of object elements using classid.
|
| 8424 | // IE10 throws NoModificationAllowedError if parent is null, #12132.
|
| 8425 | } else if ( nodeName === "object" ) {
|
| 8426 | if ( dest.parentNode ) {
|
| 8427 | dest.outerHTML = src.outerHTML;
|
| 8428 | }
|
| 8429 |
|
| 8430 | // This path appears unavoidable for IE9. When cloning an object
|
| 8431 | // element in IE9, the outerHTML strategy above is not sufficient.
|
| 8432 | // If the src has innerHTML and the destination does not,
|
| 8433 | // copy the src.innerHTML into the dest.innerHTML. #10324
|
| 8434 | if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
|
| 8435 | dest.innerHTML = src.innerHTML;
|
| 8436 | }
|
| 8437 |
|
| 8438 | } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
|
| 8439 | // IE6-8 fails to persist the checked state of a cloned checkbox
|
| 8440 | // or radio button. Worse, IE6-7 fail to give the cloned element
|
| 8441 | // a checked appearance if the defaultChecked value isn't also set
|
| 8442 |
|
| 8443 | dest.defaultChecked = dest.checked = src.checked;
|
| 8444 |
|
| 8445 | // IE6-7 get confused and end up setting the value of a cloned
|
| 8446 | // checkbox/radio button to an empty string instead of "on"
|
| 8447 | if ( dest.value !== src.value ) {
|
| 8448 | dest.value = src.value;
|
| 8449 | }
|
| 8450 |
|
| 8451 | // IE6-8 fails to return the selected option to the default selected
|
| 8452 | // state when cloning options
|
| 8453 | } else if ( nodeName === "option" ) {
|
| 8454 | dest.defaultSelected = dest.selected = src.defaultSelected;
|
| 8455 |
|
| 8456 | // IE6-8 fails to set the defaultValue to the correct value when
|
| 8457 | // cloning other types of input fields
|
| 8458 | } else if ( nodeName === "input" || nodeName === "textarea" ) {
|
| 8459 | dest.defaultValue = src.defaultValue;
|
| 8460 | }
|
| 8461 | }
|
| 8462 |
|
| 8463 | jQuery.each({
|
| 8464 | appendTo: "append",
|
| 8465 | prependTo: "prepend",
|
| 8466 | insertBefore: "before",
|
| 8467 | insertAfter: "after",
|
| 8468 | replaceAll: "replaceWith"
|
| 8469 | }, function( name, original ) {
|
| 8470 | jQuery.fn[ name ] = function( selector ) {
|
| 8471 | var elems,
|
| 8472 | i = 0,
|
| 8473 | ret = [],
|
| 8474 | insert = jQuery( selector ),
|
| 8475 | last = insert.length - 1;
|
| 8476 |
|
| 8477 | for ( ; i <= last; i++ ) {
|
| 8478 | elems = i === last ? this : this.clone(true);
|
| 8479 | jQuery( insert[i] )[ original ]( elems );
|
| 8480 |
|
| 8481 | // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
|
| 8482 | core_push.apply( ret, elems.get() );
|
| 8483 | }
|
| 8484 |
|
| 8485 | return this.pushStack( ret );
|
| 8486 | };
|
| 8487 | });
|
| 8488 |
|
| 8489 | function getAll( context, tag ) {
|
| 8490 | var elems, elem,
|
| 8491 | i = 0,
|
| 8492 | found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) :
|
| 8493 | typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) :
|
| 8494 | undefined;
|
| 8495 |
|
| 8496 | if ( !found ) {
|
| 8497 | for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
|
| 8498 | if ( !tag || jQuery.nodeName( elem, tag ) ) {
|
| 8499 | found.push( elem );
|
| 8500 | } else {
|
| 8501 | jQuery.merge( found, getAll( elem, tag ) );
|
| 8502 | }
|
| 8503 | }
|
| 8504 | }
|
| 8505 |
|
| 8506 | return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
| 8507 | jQuery.merge( [ context ], found ) :
|
| 8508 | found;
|
| 8509 | }
|
| 8510 |
|
| 8511 | // Used in buildFragment, fixes the defaultChecked property
|
| 8512 | function fixDefaultChecked( elem ) {
|
| 8513 | if ( manipulation_rcheckableType.test( elem.type ) ) {
|
| 8514 | elem.defaultChecked = elem.checked;
|
| 8515 | }
|
| 8516 | }
|
| 8517 |
|
| 8518 | jQuery.extend({
|
| 8519 | clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
| 8520 | var destElements, node, clone, i, srcElements,
|
| 8521 | inPage = jQuery.contains( elem.ownerDocument, elem );
|
| 8522 |
|
| 8523 | if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
|
| 8524 | clone = elem.cloneNode( true );
|
| 8525 |
|
| 8526 | // IE<=8 does not properly clone detached, unknown element nodes
|
| 8527 | } else {
|
| 8528 | fragmentDiv.innerHTML = elem.outerHTML;
|
| 8529 | fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
|
| 8530 | }
|
| 8531 |
|
| 8532 | if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
|
| 8533 | (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
| 8534 |
|
| 8535 | // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
| 8536 | destElements = getAll( clone );
|
| 8537 | srcElements = getAll( elem );
|
| 8538 |
|
| 8539 | // Fix all IE cloning issues
|
| 8540 | for ( i = 0; (node = srcElements[i]) != null; ++i ) {
|
| 8541 | // Ensure that the destination node is not null; Fixes #9587
|
| 8542 | if ( destElements[i] ) {
|
| 8543 | fixCloneNodeIssues( node, destElements[i] );
|
| 8544 | }
|
| 8545 | }
|
| 8546 | }
|
| 8547 |
|
| 8548 | // Copy the events from the original to the clone
|
| 8549 | if ( dataAndEvents ) {
|
| 8550 | if ( deepDataAndEvents ) {
|
| 8551 | srcElements = srcElements || getAll( elem );
|
| 8552 | destElements = destElements || getAll( clone );
|
| 8553 |
|
| 8554 | for ( i = 0; (node = srcElements[i]) != null; i++ ) {
|
| 8555 | cloneCopyEvent( node, destElements[i] );
|
| 8556 | }
|
| 8557 | } else {
|
| 8558 | cloneCopyEvent( elem, clone );
|
| 8559 | }
|
| 8560 | }
|
| 8561 |
|
| 8562 | // Preserve script evaluation history
|
| 8563 | destElements = getAll( clone, "script" );
|
| 8564 | if ( destElements.length > 0 ) {
|
| 8565 | setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
| 8566 | }
|
| 8567 |
|
| 8568 | destElements = srcElements = node = null;
|
| 8569 |
|
| 8570 | // Return the cloned set
|
| 8571 | return clone;
|
| 8572 | },
|
| 8573 |
|
| 8574 | buildFragment: function( elems, context, scripts, selection ) {
|
| 8575 | var j, elem, contains,
|
| 8576 | tmp, tag, tbody, wrap,
|
| 8577 | l = elems.length,
|
| 8578 |
|
| 8579 | // Ensure a safe fragment
|
| 8580 | safe = createSafeFragment( context ),
|
| 8581 |
|
| 8582 | nodes = [],
|
| 8583 | i = 0;
|
| 8584 |
|
| 8585 | for ( ; i < l; i++ ) {
|
| 8586 | elem = elems[ i ];
|
| 8587 |
|
| 8588 | if ( elem || elem === 0 ) {
|
| 8589 |
|
| 8590 | // Add nodes directly
|
| 8591 | if ( jQuery.type( elem ) === "object" ) {
|
| 8592 | jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
| 8593 |
|
| 8594 | // Convert non-html into a text node
|
| 8595 | } else if ( !rhtml.test( elem ) ) {
|
| 8596 | nodes.push( context.createTextNode( elem ) );
|
| 8597 |
|
| 8598 | // Convert html into DOM nodes
|
| 8599 | } else {
|
| 8600 | tmp = tmp || safe.appendChild( context.createElement("div") );
|
| 8601 |
|
| 8602 | // Deserialize a standard representation
|
| 8603 | tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
| 8604 | wrap = wrapMap[ tag ] || wrapMap._default;
|
| 8605 |
|
| 8606 | tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
|
| 8607 |
|
| 8608 | // Descend through wrappers to the right content
|
| 8609 | j = wrap[0];
|
| 8610 | while ( j-- ) {
|
| 8611 | tmp = tmp.lastChild;
|
| 8612 | }
|
| 8613 |
|
| 8614 | // Manually add leading whitespace removed by IE
|
| 8615 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
| 8616 | nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
|
| 8617 | }
|
| 8618 |
|
| 8619 | // Remove IE's autoinserted <tbody> from table fragments
|
| 8620 | if ( !jQuery.support.tbody ) {
|
| 8621 |
|
| 8622 | // String was a <table>, *may* have spurious <tbody>
|
| 8623 | elem = tag === "table" && !rtbody.test( elem ) ?
|
| 8624 | tmp.firstChild :
|
| 8625 |
|
| 8626 | // String was a bare <thead> or <tfoot>
|
| 8627 | wrap[1] === "<table>" && !rtbody.test( elem ) ?
|
| 8628 | tmp :
|
| 8629 | 0;
|
| 8630 |
|
| 8631 | j = elem && elem.childNodes.length;
|
| 8632 | while ( j-- ) {
|
| 8633 | if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
|
| 8634 | elem.removeChild( tbody );
|
| 8635 | }
|
| 8636 | }
|
| 8637 | }
|
| 8638 |
|
| 8639 | jQuery.merge( nodes, tmp.childNodes );
|
| 8640 |
|
| 8641 | // Fix #12392 for WebKit and IE > 9
|
| 8642 | tmp.textContent = "";
|
| 8643 |
|
| 8644 | // Fix #12392 for oldIE
|
| 8645 | while ( tmp.firstChild ) {
|
| 8646 | tmp.removeChild( tmp.firstChild );
|
| 8647 | }
|
| 8648 |
|
| 8649 | // Remember the top-level container for proper cleanup
|
| 8650 | tmp = safe.lastChild;
|
| 8651 | }
|
| 8652 | }
|
| 8653 | }
|
| 8654 |
|
| 8655 | // Fix #11356: Clear elements from fragment
|
| 8656 | if ( tmp ) {
|
| 8657 | safe.removeChild( tmp );
|
| 8658 | }
|
| 8659 |
|
| 8660 | // Reset defaultChecked for any radios and checkboxes
|
| 8661 | // about to be appended to the DOM in IE 6/7 (#8060)
|
| 8662 | if ( !jQuery.support.appendChecked ) {
|
| 8663 | jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
|
| 8664 | }
|
| 8665 |
|
| 8666 | i = 0;
|
| 8667 | while ( (elem = nodes[ i++ ]) ) {
|
| 8668 |
|
| 8669 | // #4087 - If origin and destination elements are the same, and this is
|
| 8670 | // that element, do not do anything
|
| 8671 | if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
|
| 8672 | continue;
|
| 8673 | }
|
| 8674 |
|
| 8675 | contains = jQuery.contains( elem.ownerDocument, elem );
|
| 8676 |
|
| 8677 | // Append to fragment
|
| 8678 | tmp = getAll( safe.appendChild( elem ), "script" );
|
| 8679 |
|
| 8680 | // Preserve script evaluation history
|
| 8681 | if ( contains ) {
|
| 8682 | setGlobalEval( tmp );
|
| 8683 | }
|
| 8684 |
|
| 8685 | // Capture executables
|
| 8686 | if ( scripts ) {
|
| 8687 | j = 0;
|
| 8688 | while ( (elem = tmp[ j++ ]) ) {
|
| 8689 | if ( rscriptType.test( elem.type || "" ) ) {
|
| 8690 | scripts.push( elem );
|
| 8691 | }
|
| 8692 | }
|
| 8693 | }
|
| 8694 | }
|
| 8695 |
|
| 8696 | tmp = null;
|
| 8697 |
|
| 8698 | return safe;
|
| 8699 | },
|
| 8700 |
|
| 8701 | cleanData: function( elems, /* internal */ acceptData ) {
|
| 8702 | var elem, type, id, data,
|
| 8703 | i = 0,
|
| 8704 | internalKey = jQuery.expando,
|
| 8705 | cache = jQuery.cache,
|
| 8706 | deleteExpando = jQuery.support.deleteExpando,
|
| 8707 | special = jQuery.event.special;
|
| 8708 |
|
| 8709 | for ( ; (elem = elems[i]) != null; i++ ) {
|
| 8710 |
|
| 8711 | if ( acceptData || jQuery.acceptData( elem ) ) {
|
| 8712 |
|
| 8713 | id = elem[ internalKey ];
|
| 8714 | data = id && cache[ id ];
|
| 8715 |
|
| 8716 | if ( data ) {
|
| 8717 | if ( data.events ) {
|
| 8718 | for ( type in data.events ) {
|
| 8719 | if ( special[ type ] ) {
|
| 8720 | jQuery.event.remove( elem, type );
|
| 8721 |
|
| 8722 | // This is a shortcut to avoid jQuery.event.remove's overhead
|
| 8723 | } else {
|
| 8724 | jQuery.removeEvent( elem, type, data.handle );
|
| 8725 | }
|
| 8726 | }
|
| 8727 | }
|
| 8728 |
|
| 8729 | // Remove cache only if it was not already removed by jQuery.event.remove
|
| 8730 | if ( cache[ id ] ) {
|
| 8731 |
|
| 8732 | delete cache[ id ];
|
| 8733 |
|
| 8734 | // IE does not allow us to delete expando properties from nodes,
|
| 8735 | // nor does it have a removeAttribute function on Document nodes;
|
| 8736 | // we must handle all of these cases
|
| 8737 | if ( deleteExpando ) {
|
| 8738 | delete elem[ internalKey ];
|
| 8739 |
|
| 8740 | } else if ( typeof elem.removeAttribute !== core_strundefined ) {
|
| 8741 | elem.removeAttribute( internalKey );
|
| 8742 |
|
| 8743 | } else {
|
| 8744 | elem[ internalKey ] = null;
|
| 8745 | }
|
| 8746 |
|
| 8747 | core_deletedIds.push( id );
|
| 8748 | }
|
| 8749 | }
|
| 8750 | }
|
| 8751 | }
|
| 8752 | },
|
| 8753 |
|
| 8754 | _evalUrl: function( url ) {
|
| 8755 | return jQuery.ajax({
|
| 8756 | url: url,
|
| 8757 | type: "GET",
|
| 8758 | dataType: "script",
|
| 8759 | async: false,
|
| 8760 | global: false,
|
| 8761 | "throws": true
|
| 8762 | });
|
| 8763 | }
|
| 8764 | });
|
| 8765 | jQuery.fn.extend({
|
| 8766 | wrapAll: function( html ) {
|
| 8767 | if ( jQuery.isFunction( html ) ) {
|
| 8768 | return this.each(function(i) {
|
| 8769 | jQuery(this).wrapAll( html.call(this, i) );
|
| 8770 | });
|
| 8771 | }
|
| 8772 |
|
| 8773 | if ( this[0] ) {
|
| 8774 | // The elements to wrap the target around
|
| 8775 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
|
| 8776 |
|
| 8777 | if ( this[0].parentNode ) {
|
| 8778 | wrap.insertBefore( this[0] );
|
| 8779 | }
|
| 8780 |
|
| 8781 | wrap.map(function() {
|
| 8782 | var elem = this;
|
| 8783 |
|
| 8784 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
|
| 8785 | elem = elem.firstChild;
|
| 8786 | }
|
| 8787 |
|
| 8788 | return elem;
|
| 8789 | }).append( this );
|
| 8790 | }
|
| 8791 |
|
| 8792 | return this;
|
| 8793 | },
|
| 8794 |
|
| 8795 | wrapInner: function( html ) {
|
| 8796 | if ( jQuery.isFunction( html ) ) {
|
| 8797 | return this.each(function(i) {
|
| 8798 | jQuery(this).wrapInner( html.call(this, i) );
|
| 8799 | });
|
| 8800 | }
|
| 8801 |
|
| 8802 | return this.each(function() {
|
| 8803 | var self = jQuery( this ),
|
| 8804 | contents = self.contents();
|
| 8805 |
|
| 8806 | if ( contents.length ) {
|
| 8807 | contents.wrapAll( html );
|
| 8808 |
|
| 8809 | } else {
|
| 8810 | self.append( html );
|
| 8811 | }
|
| 8812 | });
|
| 8813 | },
|
| 8814 |
|
| 8815 | wrap: function( html ) {
|
| 8816 | var isFunction = jQuery.isFunction( html );
|
| 8817 |
|
| 8818 | return this.each(function(i) {
|
| 8819 | jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
|
| 8820 | });
|
| 8821 | },
|
| 8822 |
|
| 8823 | unwrap: function() {
|
| 8824 | return this.parent().each(function() {
|
| 8825 | if ( !jQuery.nodeName( this, "body" ) ) {
|
| 8826 | jQuery( this ).replaceWith( this.childNodes );
|
| 8827 | }
|
| 8828 | }).end();
|
| 8829 | }
|
| 8830 | });
|
| 8831 | var iframe, getStyles, curCSS,
|
| 8832 | ralpha = /alpha\([^)]*\)/i,
|
| 8833 | ropacity = /opacity\s*=\s*([^)]*)/,
|
| 8834 | rposition = /^(top|right|bottom|left)$/,
|
| 8835 | // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
|
| 8836 | // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
| 8837 | rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
| 8838 | rmargin = /^margin/,
|
| 8839 | rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
|
| 8840 | rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
|
| 8841 | rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
|
| 8842 | elemdisplay = { BODY: "block" },
|
| 8843 |
|
| 8844 | cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
| 8845 | cssNormalTransform = {
|
| 8846 | letterSpacing: 0,
|
| 8847 | fontWeight: 400
|
| 8848 | },
|
| 8849 |
|
| 8850 | cssExpand = [ "Top", "Right", "Bottom", "Left" ],
|
| 8851 | cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
|
| 8852 |
|
| 8853 | // return a css property mapped to a potentially vendor prefixed property
|
| 8854 | function vendorPropName( style, name ) {
|
| 8855 |
|
| 8856 | // shortcut for names that are not vendor prefixed
|
| 8857 | if ( name in style ) {
|
| 8858 | return name;
|
| 8859 | }
|
| 8860 |
|
| 8861 | // check for vendor prefixed names
|
| 8862 | var capName = name.charAt(0).toUpperCase() + name.slice(1),
|
| 8863 | origName = name,
|
| 8864 | i = cssPrefixes.length;
|
| 8865 |
|
| 8866 | while ( i-- ) {
|
| 8867 | name = cssPrefixes[ i ] + capName;
|
| 8868 | if ( name in style ) {
|
| 8869 | return name;
|
| 8870 | }
|
| 8871 | }
|
| 8872 |
|
| 8873 | return origName;
|
| 8874 | }
|
| 8875 |
|
| 8876 | function isHidden( elem, el ) {
|
| 8877 | // isHidden might be called from jQuery#filter function;
|
| 8878 | // in that case, element will be second argument
|
| 8879 | elem = el || elem;
|
| 8880 | return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
| 8881 | }
|
| 8882 |
|
| 8883 | function showHide( elements, show ) {
|
| 8884 | var display, elem, hidden,
|
| 8885 | values = [],
|
| 8886 | index = 0,
|
| 8887 | length = elements.length;
|
| 8888 |
|
| 8889 | for ( ; index < length; index++ ) {
|
| 8890 | elem = elements[ index ];
|
| 8891 | if ( !elem.style ) {
|
| 8892 | continue;
|
| 8893 | }
|
| 8894 |
|
| 8895 | values[ index ] = jQuery._data( elem, "olddisplay" );
|
| 8896 | display = elem.style.display;
|
| 8897 | if ( show ) {
|
| 8898 | // Reset the inline display of this element to learn if it is
|
| 8899 | // being hidden by cascaded rules or not
|
| 8900 | if ( !values[ index ] && display === "none" ) {
|
| 8901 | elem.style.display = "";
|
| 8902 | }
|
| 8903 |
|
| 8904 | // Set elements which have been overridden with display: none
|
| 8905 | // in a stylesheet to whatever the default browser style is
|
| 8906 | // for such an element
|
| 8907 | if ( elem.style.display === "" && isHidden( elem ) ) {
|
| 8908 | values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
|
| 8909 | }
|
| 8910 | } else {
|
| 8911 |
|
| 8912 | if ( !values[ index ] ) {
|
| 8913 | hidden = isHidden( elem );
|
| 8914 |
|
| 8915 | if ( display && display !== "none" || !hidden ) {
|
| 8916 | jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
|
| 8917 | }
|
| 8918 | }
|
| 8919 | }
|
| 8920 | }
|
| 8921 |
|
| 8922 | // Set the display of most of the elements in a second loop
|
| 8923 | // to avoid the constant reflow
|
| 8924 | for ( index = 0; index < length; index++ ) {
|
| 8925 | elem = elements[ index ];
|
| 8926 | if ( !elem.style ) {
|
| 8927 | continue;
|
| 8928 | }
|
| 8929 | if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
|
| 8930 | elem.style.display = show ? values[ index ] || "" : "none";
|
| 8931 | }
|
| 8932 | }
|
| 8933 |
|
| 8934 | return elements;
|
| 8935 | }
|
| 8936 |
|
| 8937 | jQuery.fn.extend({
|
| 8938 | css: function( name, value ) {
|
| 8939 | return jQuery.access( this, function( elem, name, value ) {
|
| 8940 | var len, styles,
|
| 8941 | map = {},
|
| 8942 | i = 0;
|
| 8943 |
|
| 8944 | if ( jQuery.isArray( name ) ) {
|
| 8945 | styles = getStyles( elem );
|
| 8946 | len = name.length;
|
| 8947 |
|
| 8948 | for ( ; i < len; i++ ) {
|
| 8949 | map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
|
| 8950 | }
|
| 8951 |
|
| 8952 | return map;
|
| 8953 | }
|
| 8954 |
|
| 8955 | return value !== undefined ?
|
| 8956 | jQuery.style( elem, name, value ) :
|
| 8957 | jQuery.css( elem, name );
|
| 8958 | }, name, value, arguments.length > 1 );
|
| 8959 | },
|
| 8960 | show: function() {
|
| 8961 | return showHide( this, true );
|
| 8962 | },
|
| 8963 | hide: function() {
|
| 8964 | return showHide( this );
|
| 8965 | },
|
| 8966 | toggle: function( state ) {
|
| 8967 | if ( typeof state === "boolean" ) {
|
| 8968 | return state ? this.show() : this.hide();
|
| 8969 | }
|
| 8970 |
|
| 8971 | return this.each(function() {
|
| 8972 | if ( isHidden( this ) ) {
|
| 8973 | jQuery( this ).show();
|
| 8974 | } else {
|
| 8975 | jQuery( this ).hide();
|
| 8976 | }
|
| 8977 | });
|
| 8978 | }
|
| 8979 | });
|
| 8980 |
|
| 8981 | jQuery.extend({
|
| 8982 | // Add in style property hooks for overriding the default
|
| 8983 | // behavior of getting and setting a style property
|
| 8984 | cssHooks: {
|
| 8985 | opacity: {
|
| 8986 | get: function( elem, computed ) {
|
| 8987 | if ( computed ) {
|
| 8988 | // We should always get a number back from opacity
|
| 8989 | var ret = curCSS( elem, "opacity" );
|
| 8990 | return ret === "" ? "1" : ret;
|
| 8991 | }
|
| 8992 | }
|
| 8993 | }
|
| 8994 | },
|
| 8995 |
|
| 8996 | // Don't automatically add "px" to these possibly-unitless properties
|
| 8997 | cssNumber: {
|
| 8998 | "columnCount": true,
|
| 8999 | "fillOpacity": true,
|
| 9000 | "fontWeight": true,
|
| 9001 | "lineHeight": true,
|
| 9002 | "opacity": true,
|
| 9003 | "order": true,
|
| 9004 | "orphans": true,
|
| 9005 | "widows": true,
|
| 9006 | "zIndex": true,
|
| 9007 | "zoom": true
|
| 9008 | },
|
| 9009 |
|
| 9010 | // Add in properties whose names you wish to fix before
|
| 9011 | // setting or getting the value
|
| 9012 | cssProps: {
|
| 9013 | // normalize float css property
|
| 9014 | "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
|
| 9015 | },
|
| 9016 |
|
| 9017 | // Get and set the style property on a DOM Node
|
| 9018 | style: function( elem, name, value, extra ) {
|
| 9019 | // Don't set styles on text and comment nodes
|
| 9020 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
| 9021 | return;
|
| 9022 | }
|
| 9023 |
|
| 9024 | // Make sure that we're working with the right name
|
| 9025 | var ret, type, hooks,
|
| 9026 | origName = jQuery.camelCase( name ),
|
| 9027 | style = elem.style;
|
| 9028 |
|
| 9029 | name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
|
| 9030 |
|
| 9031 | // gets hook for the prefixed version
|
| 9032 | // followed by the unprefixed version
|
| 9033 | hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
| 9034 |
|
| 9035 | // Check if we're setting a value
|
| 9036 | if ( value !== undefined ) {
|
| 9037 | type = typeof value;
|
| 9038 |
|
| 9039 | // convert relative number strings (+= or -=) to relative numbers. #7345
|
| 9040 | if ( type === "string" && (ret = rrelNum.exec( value )) ) {
|
| 9041 | value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
|
| 9042 | // Fixes bug #9237
|
| 9043 | type = "number";
|
| 9044 | }
|
| 9045 |
|
| 9046 | // Make sure that NaN and null values aren't set. See: #7116
|
| 9047 | if ( value == null || type === "number" && isNaN( value ) ) {
|
| 9048 | return;
|
| 9049 | }
|
| 9050 |
|
| 9051 | // If a number was passed in, add 'px' to the (except for certain CSS properties)
|
| 9052 | if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
|
| 9053 | value += "px";
|
| 9054 | }
|
| 9055 |
|
| 9056 | // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
|
| 9057 | // but it would mean to define eight (for every problematic property) identical functions
|
| 9058 | if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
|
| 9059 | style[ name ] = "inherit";
|
| 9060 | }
|
| 9061 |
|
| 9062 | // If a hook was provided, use that value, otherwise just set the specified value
|
| 9063 | if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
|
| 9064 |
|
| 9065 | // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
|
| 9066 | // Fixes bug #5509
|
| 9067 | try {
|
| 9068 | style[ name ] = value;
|
| 9069 | } catch(e) {}
|
| 9070 | }
|
| 9071 |
|
| 9072 | } else {
|
| 9073 | // If a hook was provided get the non-computed value from there
|
| 9074 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
|
| 9075 | return ret;
|
| 9076 | }
|
| 9077 |
|
| 9078 | // Otherwise just get the value from the style object
|
| 9079 | return style[ name ];
|
| 9080 | }
|
| 9081 | },
|
| 9082 |
|
| 9083 | css: function( elem, name, extra, styles ) {
|
| 9084 | var num, val, hooks,
|
| 9085 | origName = jQuery.camelCase( name );
|
| 9086 |
|
| 9087 | // Make sure that we're working with the right name
|
| 9088 | name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
|
| 9089 |
|
| 9090 | // gets hook for the prefixed version
|
| 9091 | // followed by the unprefixed version
|
| 9092 | hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
| 9093 |
|
| 9094 | // If a hook was provided get the computed value from there
|
| 9095 | if ( hooks && "get" in hooks ) {
|
| 9096 | val = hooks.get( elem, true, extra );
|
| 9097 | }
|
| 9098 |
|
| 9099 | // Otherwise, if a way to get the computed value exists, use that
|
| 9100 | if ( val === undefined ) {
|
| 9101 | val = curCSS( elem, name, styles );
|
| 9102 | }
|
| 9103 |
|
| 9104 | //convert "normal" to computed value
|
| 9105 | if ( val === "normal" && name in cssNormalTransform ) {
|
| 9106 | val = cssNormalTransform[ name ];
|
| 9107 | }
|
| 9108 |
|
| 9109 | // Return, converting to number if forced or a qualifier was provided and val looks numeric
|
| 9110 | if ( extra === "" || extra ) {
|
| 9111 | num = parseFloat( val );
|
| 9112 | return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
|
| 9113 | }
|
| 9114 | return val;
|
| 9115 | }
|
| 9116 | });
|
| 9117 |
|
| 9118 | // NOTE: we've included the "window" in window.getComputedStyle
|
| 9119 | // because jsdom on node.js will break without it.
|
| 9120 | if ( window.getComputedStyle ) {
|
| 9121 | getStyles = function( elem ) {
|
| 9122 | return window.getComputedStyle( elem, null );
|
| 9123 | };
|
| 9124 |
|
| 9125 | curCSS = function( elem, name, _computed ) {
|
| 9126 | var width, minWidth, maxWidth,
|
| 9127 | computed = _computed || getStyles( elem ),
|
| 9128 |
|
| 9129 | // getPropertyValue is only needed for .css('filter') in IE9, see #12537
|
| 9130 | ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
|
| 9131 | style = elem.style;
|
| 9132 |
|
| 9133 | if ( computed ) {
|
| 9134 |
|
| 9135 | if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
|
| 9136 | ret = jQuery.style( elem, name );
|
| 9137 | }
|
| 9138 |
|
| 9139 | // A tribute to the "awesome hack by Dean Edwards"
|
| 9140 | // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
|
| 9141 | // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
|
| 9142 | // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
| 9143 | if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
| 9144 |
|
| 9145 | // Remember the original values
|
| 9146 | width = style.width;
|
| 9147 | minWidth = style.minWidth;
|
| 9148 | maxWidth = style.maxWidth;
|
| 9149 |
|
| 9150 | // Put in the new values to get a computed value out
|
| 9151 | style.minWidth = style.maxWidth = style.width = ret;
|
| 9152 | ret = computed.width;
|
| 9153 |
|
| 9154 | // Revert the changed values
|
| 9155 | style.width = width;
|
| 9156 | style.minWidth = minWidth;
|
| 9157 | style.maxWidth = maxWidth;
|
| 9158 | }
|
| 9159 | }
|
| 9160 |
|
| 9161 | return ret;
|
| 9162 | };
|
| 9163 | } else if ( document.documentElement.currentStyle ) {
|
| 9164 | getStyles = function( elem ) {
|
| 9165 | return elem.currentStyle;
|
| 9166 | };
|
| 9167 |
|
| 9168 | curCSS = function( elem, name, _computed ) {
|
| 9169 | var left, rs, rsLeft,
|
| 9170 | computed = _computed || getStyles( elem ),
|
| 9171 | ret = computed ? computed[ name ] : undefined,
|
| 9172 | style = elem.style;
|
| 9173 |
|
| 9174 | // Avoid setting ret to empty string here
|
| 9175 | // so we don't default to auto
|
| 9176 | if ( ret == null && style && style[ name ] ) {
|
| 9177 | ret = style[ name ];
|
| 9178 | }
|
| 9179 |
|
| 9180 | // From the awesome hack by Dean Edwards
|
| 9181 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
| 9182 |
|
| 9183 | // If we're not dealing with a regular pixel number
|
| 9184 | // but a number that has a weird ending, we need to convert it to pixels
|
| 9185 | // but not position css attributes, as those are proportional to the parent element instead
|
| 9186 | // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
|
| 9187 | if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
|
| 9188 |
|
| 9189 | // Remember the original values
|
| 9190 | left = style.left;
|
| 9191 | rs = elem.runtimeStyle;
|
| 9192 | rsLeft = rs && rs.left;
|
| 9193 |
|
| 9194 | // Put in the new values to get a computed value out
|
| 9195 | if ( rsLeft ) {
|
| 9196 | rs.left = elem.currentStyle.left;
|
| 9197 | }
|
| 9198 | style.left = name === "fontSize" ? "1em" : ret;
|
| 9199 | ret = style.pixelLeft + "px";
|
| 9200 |
|
| 9201 | // Revert the changed values
|
| 9202 | style.left = left;
|
| 9203 | if ( rsLeft ) {
|
| 9204 | rs.left = rsLeft;
|
| 9205 | }
|
| 9206 | }
|
| 9207 |
|
| 9208 | return ret === "" ? "auto" : ret;
|
| 9209 | };
|
| 9210 | }
|
| 9211 |
|
| 9212 | function setPositiveNumber( elem, value, subtract ) {
|
| 9213 | var matches = rnumsplit.exec( value );
|
| 9214 | return matches ?
|
| 9215 | // Guard against undefined "subtract", e.g., when used as in cssHooks
|
| 9216 | Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
|
| 9217 | value;
|
| 9218 | }
|
| 9219 |
|
| 9220 | function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
|
| 9221 | var i = extra === ( isBorderBox ? "border" : "content" ) ?
|
| 9222 | // If we already have the right measurement, avoid augmentation
|
| 9223 | 4 :
|
| 9224 | // Otherwise initialize for horizontal or vertical properties
|
| 9225 | name === "width" ? 1 : 0,
|
| 9226 |
|
| 9227 | val = 0;
|
| 9228 |
|
| 9229 | for ( ; i < 4; i += 2 ) {
|
| 9230 | // both box models exclude margin, so add it if we want it
|
| 9231 | if ( extra === "margin" ) {
|
| 9232 | val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
|
| 9233 | }
|
| 9234 |
|
| 9235 | if ( isBorderBox ) {
|
| 9236 | // border-box includes padding, so remove it if we want content
|
| 9237 | if ( extra === "content" ) {
|
| 9238 | val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
| 9239 | }
|
| 9240 |
|
| 9241 | // at this point, extra isn't border nor margin, so remove border
|
| 9242 | if ( extra !== "margin" ) {
|
| 9243 | val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
| 9244 | }
|
| 9245 | } else {
|
| 9246 | // at this point, extra isn't content, so add padding
|
| 9247 | val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
| 9248 |
|
| 9249 | // at this point, extra isn't content nor padding, so add border
|
| 9250 | if ( extra !== "padding" ) {
|
| 9251 | val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
| 9252 | }
|
| 9253 | }
|
| 9254 | }
|
| 9255 |
|
| 9256 | return val;
|
| 9257 | }
|
| 9258 |
|
| 9259 | function getWidthOrHeight( elem, name, extra ) {
|
| 9260 |
|
| 9261 | // Start with offset property, which is equivalent to the border-box value
|
| 9262 | var valueIsBorderBox = true,
|
| 9263 | val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
| 9264 | styles = getStyles( elem ),
|
| 9265 | isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
| 9266 |
|
| 9267 | // some non-html elements return undefined for offsetWidth, so check for null/undefined
|
| 9268 | // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
|
| 9269 | // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
|
| 9270 | if ( val <= 0 || val == null ) {
|
| 9271 | // Fall back to computed then uncomputed css if necessary
|
| 9272 | val = curCSS( elem, name, styles );
|
| 9273 | if ( val < 0 || val == null ) {
|
| 9274 | val = elem.style[ name ];
|
| 9275 | }
|
| 9276 |
|
| 9277 | // Computed unit is not pixels. Stop here and return.
|
| 9278 | if ( rnumnonpx.test(val) ) {
|
| 9279 | return val;
|
| 9280 | }
|
| 9281 |
|
| 9282 | // we need the check for style in case a browser which returns unreliable values
|
| 9283 | // for getComputedStyle silently falls back to the reliable elem.style
|
| 9284 | valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
|
| 9285 |
|
| 9286 | // Normalize "", auto, and prepare for extra
|
| 9287 | val = parseFloat( val ) || 0;
|
| 9288 | }
|
| 9289 |
|
| 9290 | // use the active box-sizing model to add/subtract irrelevant styles
|
| 9291 | return ( val +
|
| 9292 | augmentWidthOrHeight(
|
| 9293 | elem,
|
| 9294 | name,
|
| 9295 | extra || ( isBorderBox ? "border" : "content" ),
|
| 9296 | valueIsBorderBox,
|
| 9297 | styles
|
| 9298 | )
|
| 9299 | ) + "px";
|
| 9300 | }
|
| 9301 |
|
| 9302 | // Try to determine the default display value of an element
|
| 9303 | function css_defaultDisplay( nodeName ) {
|
| 9304 | var doc = document,
|
| 9305 | display = elemdisplay[ nodeName ];
|
| 9306 |
|
| 9307 | if ( !display ) {
|
| 9308 | display = actualDisplay( nodeName, doc );
|
| 9309 |
|
| 9310 | // If the simple way fails, read from inside an iframe
|
| 9311 | if ( display === "none" || !display ) {
|
| 9312 | // Use the already-created iframe if possible
|
| 9313 | iframe = ( iframe ||
|
| 9314 | jQuery("<iframe frameborder='0' width='0' height='0'/>")
|
| 9315 | .css( "cssText", "display:block !important" )
|
| 9316 | ).appendTo( doc.documentElement );
|
| 9317 |
|
| 9318 | // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
|
| 9319 | doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
|
| 9320 | doc.write("<!doctype html><html><body>");
|
| 9321 | doc.close();
|
| 9322 |
|
| 9323 | display = actualDisplay( nodeName, doc );
|
| 9324 | iframe.detach();
|
| 9325 | }
|
| 9326 |
|
| 9327 | // Store the correct default display
|
| 9328 | elemdisplay[ nodeName ] = display;
|
| 9329 | }
|
| 9330 |
|
| 9331 | return display;
|
| 9332 | }
|
| 9333 |
|
| 9334 | // Called ONLY from within css_defaultDisplay
|
| 9335 | function actualDisplay( name, doc ) {
|
| 9336 | var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
| 9337 | display = jQuery.css( elem[0], "display" );
|
| 9338 | elem.remove();
|
| 9339 | return display;
|
| 9340 | }
|
| 9341 |
|
| 9342 | jQuery.each([ "height", "width" ], function( i, name ) {
|
| 9343 | jQuery.cssHooks[ name ] = {
|
| 9344 | get: function( elem, computed, extra ) {
|
| 9345 | if ( computed ) {
|
| 9346 | // certain elements can have dimension info if we invisibly show them
|
| 9347 | // however, it must have a current display style that would benefit from this
|
| 9348 | return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
|
| 9349 | jQuery.swap( elem, cssShow, function() {
|
| 9350 | return getWidthOrHeight( elem, name, extra );
|
| 9351 | }) :
|
| 9352 | getWidthOrHeight( elem, name, extra );
|
| 9353 | }
|
| 9354 | },
|
| 9355 |
|
| 9356 | set: function( elem, value, extra ) {
|
| 9357 | var styles = extra && getStyles( elem );
|
| 9358 | return setPositiveNumber( elem, value, extra ?
|
| 9359 | augmentWidthOrHeight(
|
| 9360 | elem,
|
| 9361 | name,
|
| 9362 | extra,
|
| 9363 | jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
| 9364 | styles
|
| 9365 | ) : 0
|
| 9366 | );
|
| 9367 | }
|
| 9368 | };
|
| 9369 | });
|
| 9370 |
|
| 9371 | if ( !jQuery.support.opacity ) {
|
| 9372 | jQuery.cssHooks.opacity = {
|
| 9373 | get: function( elem, computed ) {
|
| 9374 | // IE uses filters for opacity
|
| 9375 | return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
|
| 9376 | ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
|
| 9377 | computed ? "1" : "";
|
| 9378 | },
|
| 9379 |
|
| 9380 | set: function( elem, value ) {
|
| 9381 | var style = elem.style,
|
| 9382 | currentStyle = elem.currentStyle,
|
| 9383 | opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
|
| 9384 | filter = currentStyle && currentStyle.filter || style.filter || "";
|
| 9385 |
|
| 9386 | // IE has trouble with opacity if it does not have layout
|
| 9387 | // Force it by setting the zoom level
|
| 9388 | style.zoom = 1;
|
| 9389 |
|
| 9390 | // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
|
| 9391 | // if value === "", then remove inline opacity #12685
|
| 9392 | if ( ( value >= 1 || value === "" ) &&
|
| 9393 | jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
|
| 9394 | style.removeAttribute ) {
|
| 9395 |
|
| 9396 | // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
|
| 9397 | // if "filter:" is present at all, clearType is disabled, we want to avoid this
|
| 9398 | // style.removeAttribute is IE Only, but so apparently is this code path...
|
| 9399 | style.removeAttribute( "filter" );
|
| 9400 |
|
| 9401 | // if there is no filter style applied in a css rule or unset inline opacity, we are done
|
| 9402 | if ( value === "" || currentStyle && !currentStyle.filter ) {
|
| 9403 | return;
|
| 9404 | }
|
| 9405 | }
|
| 9406 |
|
| 9407 | // otherwise, set new filter values
|
| 9408 | style.filter = ralpha.test( filter ) ?
|
| 9409 | filter.replace( ralpha, opacity ) :
|
| 9410 | filter + " " + opacity;
|
| 9411 | }
|
| 9412 | };
|
| 9413 | }
|
| 9414 |
|
| 9415 | // These hooks cannot be added until DOM ready because the support test
|
| 9416 | // for it is not run until after DOM ready
|
| 9417 | jQuery(function() {
|
| 9418 | if ( !jQuery.support.reliableMarginRight ) {
|
| 9419 | jQuery.cssHooks.marginRight = {
|
| 9420 | get: function( elem, computed ) {
|
| 9421 | if ( computed ) {
|
| 9422 | // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
| 9423 | // Work around by temporarily setting element display to inline-block
|
| 9424 | return jQuery.swap( elem, { "display": "inline-block" },
|
| 9425 | curCSS, [ elem, "marginRight" ] );
|
| 9426 | }
|
| 9427 | }
|
| 9428 | };
|
| 9429 | }
|
| 9430 |
|
| 9431 | // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
|
| 9432 | // getComputedStyle returns percent when specified for top/left/bottom/right
|
| 9433 | // rather than make the css module depend on the offset module, we just check for it here
|
| 9434 | if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
|
| 9435 | jQuery.each( [ "top", "left" ], function( i, prop ) {
|
| 9436 | jQuery.cssHooks[ prop ] = {
|
| 9437 | get: function( elem, computed ) {
|
| 9438 | if ( computed ) {
|
| 9439 | computed = curCSS( elem, prop );
|
| 9440 | // if curCSS returns percentage, fallback to offset
|
| 9441 | return rnumnonpx.test( computed ) ?
|
| 9442 | jQuery( elem ).position()[ prop ] + "px" :
|
| 9443 | computed;
|
| 9444 | }
|
| 9445 | }
|
| 9446 | };
|
| 9447 | });
|
| 9448 | }
|
| 9449 |
|
| 9450 | });
|
| 9451 |
|
| 9452 | if ( jQuery.expr && jQuery.expr.filters ) {
|
| 9453 | jQuery.expr.filters.hidden = function( elem ) {
|
| 9454 | // Support: Opera <= 12.12
|
| 9455 | // Opera reports offsetWidths and offsetHeights less than zero on some elements
|
| 9456 | return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
|
| 9457 | (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
|
| 9458 | };
|
| 9459 |
|
| 9460 | jQuery.expr.filters.visible = function( elem ) {
|
| 9461 | return !jQuery.expr.filters.hidden( elem );
|
| 9462 | };
|
| 9463 | }
|
| 9464 |
|
| 9465 | // These hooks are used by animate to expand properties
|
| 9466 | jQuery.each({
|
| 9467 | margin: "",
|
| 9468 | padding: "",
|
| 9469 | border: "Width"
|
| 9470 | }, function( prefix, suffix ) {
|
| 9471 | jQuery.cssHooks[ prefix + suffix ] = {
|
| 9472 | expand: function( value ) {
|
| 9473 | var i = 0,
|
| 9474 | expanded = {},
|
| 9475 |
|
| 9476 | // assumes a single number if not a string
|
| 9477 | parts = typeof value === "string" ? value.split(" ") : [ value ];
|
| 9478 |
|
| 9479 | for ( ; i < 4; i++ ) {
|
| 9480 | expanded[ prefix + cssExpand[ i ] + suffix ] =
|
| 9481 | parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
|
| 9482 | }
|
| 9483 |
|
| 9484 | return expanded;
|
| 9485 | }
|
| 9486 | };
|
| 9487 |
|
| 9488 | if ( !rmargin.test( prefix ) ) {
|
| 9489 | jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
| 9490 | }
|
| 9491 | });
|
| 9492 | var r20 = /%20/g,
|
| 9493 | rbracket = /\[\]$/,
|
| 9494 | rCRLF = /\r?\n/g,
|
| 9495 | rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
|
| 9496 | rsubmittable = /^(?:input|select|textarea|keygen)/i;
|
| 9497 |
|
| 9498 | jQuery.fn.extend({
|
| 9499 | serialize: function() {
|
| 9500 | return jQuery.param( this.serializeArray() );
|
| 9501 | },
|
| 9502 | serializeArray: function() {
|
| 9503 | return this.map(function(){
|
| 9504 | // Can add propHook for "elements" to filter or add form elements
|
| 9505 | var elements = jQuery.prop( this, "elements" );
|
| 9506 | return elements ? jQuery.makeArray( elements ) : this;
|
| 9507 | })
|
| 9508 | .filter(function(){
|
| 9509 | var type = this.type;
|
| 9510 | // Use .is(":disabled") so that fieldset[disabled] works
|
| 9511 | return this.name && !jQuery( this ).is( ":disabled" ) &&
|
| 9512 | rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
| 9513 | ( this.checked || !manipulation_rcheckableType.test( type ) );
|
| 9514 | })
|
| 9515 | .map(function( i, elem ){
|
| 9516 | var val = jQuery( this ).val();
|
| 9517 |
|
| 9518 | return val == null ?
|
| 9519 | null :
|
| 9520 | jQuery.isArray( val ) ?
|
| 9521 | jQuery.map( val, function( val ){
|
| 9522 | return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
| 9523 | }) :
|
| 9524 | { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
| 9525 | }).get();
|
| 9526 | }
|
| 9527 | });
|
| 9528 |
|
| 9529 | //Serialize an array of form elements or a set of
|
| 9530 | //key/values into a query string
|
| 9531 | jQuery.param = function( a, traditional ) {
|
| 9532 | var prefix,
|
| 9533 | s = [],
|
| 9534 | add = function( key, value ) {
|
| 9535 | // If value is a function, invoke it and return its value
|
| 9536 | value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
|
| 9537 | s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
|
| 9538 | };
|
| 9539 |
|
| 9540 | // Set traditional to true for jQuery <= 1.3.2 behavior.
|
| 9541 | if ( traditional === undefined ) {
|
| 9542 | traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
|
| 9543 | }
|
| 9544 |
|
| 9545 | // If an array was passed in, assume that it is an array of form elements.
|
| 9546 | if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
|
| 9547 | // Serialize the form elements
|
| 9548 | jQuery.each( a, function() {
|
| 9549 | add( this.name, this.value );
|
| 9550 | });
|
| 9551 |
|
| 9552 | } else {
|
| 9553 | // If traditional, encode the "old" way (the way 1.3.2 or older
|
| 9554 | // did it), otherwise encode params recursively.
|
| 9555 | for ( prefix in a ) {
|
| 9556 | buildParams( prefix, a[ prefix ], traditional, add );
|
| 9557 | }
|
| 9558 | }
|
| 9559 |
|
| 9560 | // Return the resulting serialization
|
| 9561 | return s.join( "&" ).replace( r20, "+" );
|
| 9562 | };
|
| 9563 |
|
| 9564 | function buildParams( prefix, obj, traditional, add ) {
|
| 9565 | var name;
|
| 9566 |
|
| 9567 | if ( jQuery.isArray( obj ) ) {
|
| 9568 | // Serialize array item.
|
| 9569 | jQuery.each( obj, function( i, v ) {
|
| 9570 | if ( traditional || rbracket.test( prefix ) ) {
|
| 9571 | // Treat each array item as a scalar.
|
| 9572 | add( prefix, v );
|
| 9573 |
|
| 9574 | } else {
|
| 9575 | // Item is non-scalar (array or object), encode its numeric index.
|
| 9576 | buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
|
| 9577 | }
|
| 9578 | });
|
| 9579 |
|
| 9580 | } else if ( !traditional && jQuery.type( obj ) === "object" ) {
|
| 9581 | // Serialize object item.
|
| 9582 | for ( name in obj ) {
|
| 9583 | buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
| 9584 | }
|
| 9585 |
|
| 9586 | } else {
|
| 9587 | // Serialize scalar item.
|
| 9588 | add( prefix, obj );
|
| 9589 | }
|
| 9590 | }
|
| 9591 | jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
| 9592 | "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
| 9593 | "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
|
| 9594 |
|
| 9595 | // Handle event binding
|
| 9596 | jQuery.fn[ name ] = function( data, fn ) {
|
| 9597 | return arguments.length > 0 ?
|
| 9598 | this.on( name, null, data, fn ) :
|
| 9599 | this.trigger( name );
|
| 9600 | };
|
| 9601 | });
|
| 9602 |
|
| 9603 | jQuery.fn.extend({
|
| 9604 | hover: function( fnOver, fnOut ) {
|
| 9605 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
| 9606 | },
|
| 9607 |
|
| 9608 | bind: function( types, data, fn ) {
|
| 9609 | return this.on( types, null, data, fn );
|
| 9610 | },
|
| 9611 | unbind: function( types, fn ) {
|
| 9612 | return this.off( types, null, fn );
|
| 9613 | },
|
| 9614 |
|
| 9615 | delegate: function( selector, types, data, fn ) {
|
| 9616 | return this.on( types, selector, data, fn );
|
| 9617 | },
|
| 9618 | undelegate: function( selector, types, fn ) {
|
| 9619 | // ( namespace ) or ( selector, types [, fn] )
|
| 9620 | return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
|
| 9621 | }
|
| 9622 | });
|
| 9623 | var
|
| 9624 | // Document location
|
| 9625 | ajaxLocParts,
|
| 9626 | ajaxLocation,
|
| 9627 | ajax_nonce = jQuery.now(),
|
| 9628 |
|
| 9629 | ajax_rquery = /\?/,
|
| 9630 | rhash = /#.*$/,
|
| 9631 | rts = /([?&])_=[^&]*/,
|
| 9632 | rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
| 9633 | // #7653, #8125, #8152: local protocol detection
|
| 9634 | rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
|
| 9635 | rnoContent = /^(?:GET|HEAD)$/,
|
| 9636 | rprotocol = /^\/\//,
|
| 9637 | rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
|
| 9638 |
|
| 9639 | // Keep a copy of the old load method
|
| 9640 | _load = jQuery.fn.load,
|
| 9641 |
|
| 9642 | /* Prefilters
|
| 9643 | * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
| 9644 | * 2) These are called:
|
| 9645 | * - BEFORE asking for a transport
|
| 9646 | * - AFTER param serialization (s.data is a string if s.processData is true)
|
| 9647 | * 3) key is the dataType
|
| 9648 | * 4) the catchall symbol "*" can be used
|
| 9649 | * 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
| 9650 | */
|
| 9651 | prefilters = {},
|
| 9652 |
|
| 9653 | /* Transports bindings
|
| 9654 | * 1) key is the dataType
|
| 9655 | * 2) the catchall symbol "*" can be used
|
| 9656 | * 3) selection will start with transport dataType and THEN go to "*" if needed
|
| 9657 | */
|
| 9658 | transports = {},
|
| 9659 |
|
| 9660 | // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
|
| 9661 | allTypes = "*/".concat("*");
|
| 9662 |
|
| 9663 | // #8138, IE may throw an exception when accessing
|
| 9664 | // a field from window.location if document.domain has been set
|
| 9665 | try {
|
| 9666 | ajaxLocation = location.href;
|
| 9667 | } catch( e ) {
|
| 9668 | // Use the href attribute of an A element
|
| 9669 | // since IE will modify it given document.location
|
| 9670 | ajaxLocation = document.createElement( "a" );
|
| 9671 | ajaxLocation.href = "";
|
| 9672 | ajaxLocation = ajaxLocation.href;
|
| 9673 | }
|
| 9674 |
|
| 9675 | // Segment location into parts
|
| 9676 | ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
| 9677 |
|
| 9678 | // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
| 9679 | function addToPrefiltersOrTransports( structure ) {
|
| 9680 |
|
| 9681 | // dataTypeExpression is optional and defaults to "*"
|
| 9682 | return function( dataTypeExpression, func ) {
|
| 9683 |
|
| 9684 | if ( typeof dataTypeExpression !== "string" ) {
|
| 9685 | func = dataTypeExpression;
|
| 9686 | dataTypeExpression = "*";
|
| 9687 | }
|
| 9688 |
|
| 9689 | var dataType,
|
| 9690 | i = 0,
|
| 9691 | dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
|
| 9692 |
|
| 9693 | if ( jQuery.isFunction( func ) ) {
|
| 9694 | // For each dataType in the dataTypeExpression
|
| 9695 | while ( (dataType = dataTypes[i++]) ) {
|
| 9696 | // Prepend if requested
|
| 9697 | if ( dataType[0] === "+" ) {
|
| 9698 | dataType = dataType.slice( 1 ) || "*";
|
| 9699 | (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
|
| 9700 |
|
| 9701 | // Otherwise append
|
| 9702 | } else {
|
| 9703 | (structure[ dataType ] = structure[ dataType ] || []).push( func );
|
| 9704 | }
|
| 9705 | }
|
| 9706 | }
|
| 9707 | };
|
| 9708 | }
|
| 9709 |
|
| 9710 | // Base inspection function for prefilters and transports
|
| 9711 | function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
|
| 9712 |
|
| 9713 | var inspected = {},
|
| 9714 | seekingTransport = ( structure === transports );
|
| 9715 |
|
| 9716 | function inspect( dataType ) {
|
| 9717 | var selected;
|
| 9718 | inspected[ dataType ] = true;
|
| 9719 | jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
| 9720 | var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
| 9721 | if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
| 9722 | options.dataTypes.unshift( dataTypeOrTransport );
|
| 9723 | inspect( dataTypeOrTransport );
|
| 9724 | return false;
|
| 9725 | } else if ( seekingTransport ) {
|
| 9726 | return !( selected = dataTypeOrTransport );
|
| 9727 | }
|
| 9728 | });
|
| 9729 | return selected;
|
| 9730 | }
|
| 9731 |
|
| 9732 | return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
|
| 9733 | }
|
| 9734 |
|
| 9735 | // A special extend for ajax options
|
| 9736 | // that takes "flat" options (not to be deep extended)
|
| 9737 | // Fixes #9887
|
| 9738 | function ajaxExtend( target, src ) {
|
| 9739 | var deep, key,
|
| 9740 | flatOptions = jQuery.ajaxSettings.flatOptions || {};
|
| 9741 |
|
| 9742 | for ( key in src ) {
|
| 9743 | if ( src[ key ] !== undefined ) {
|
| 9744 | ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
|
| 9745 | }
|
| 9746 | }
|
| 9747 | if ( deep ) {
|
| 9748 | jQuery.extend( true, target, deep );
|
| 9749 | }
|
| 9750 |
|
| 9751 | return target;
|
| 9752 | }
|
| 9753 |
|
| 9754 | jQuery.fn.load = function( url, params, callback ) {
|
| 9755 | if ( typeof url !== "string" && _load ) {
|
| 9756 | return _load.apply( this, arguments );
|
| 9757 | }
|
| 9758 |
|
| 9759 | var selector, response, type,
|
| 9760 | self = this,
|
| 9761 | off = url.indexOf(" ");
|
| 9762 |
|
| 9763 | if ( off >= 0 ) {
|
| 9764 | selector = url.slice( off, url.length );
|
| 9765 | url = url.slice( 0, off );
|
| 9766 | }
|
| 9767 |
|
| 9768 | // If it's a function
|
| 9769 | if ( jQuery.isFunction( params ) ) {
|
| 9770 |
|
| 9771 | // We assume that it's the callback
|
| 9772 | callback = params;
|
| 9773 | params = undefined;
|
| 9774 |
|
| 9775 | // Otherwise, build a param string
|
| 9776 | } else if ( params && typeof params === "object" ) {
|
| 9777 | type = "POST";
|
| 9778 | }
|
| 9779 |
|
| 9780 | // If we have elements to modify, make the request
|
| 9781 | if ( self.length > 0 ) {
|
| 9782 | jQuery.ajax({
|
| 9783 | url: url,
|
| 9784 |
|
| 9785 | // if "type" variable is undefined, then "GET" method will be used
|
| 9786 | type: type,
|
| 9787 | dataType: "html",
|
| 9788 | data: params
|
| 9789 | }).done(function( responseText ) {
|
| 9790 |
|
| 9791 | // Save response for use in complete callback
|
| 9792 | response = arguments;
|
| 9793 |
|
| 9794 | self.html( selector ?
|
| 9795 |
|
| 9796 | // If a selector was specified, locate the right elements in a dummy div
|
| 9797 | // Exclude scripts to avoid IE 'Permission Denied' errors
|
| 9798 | jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
|
| 9799 |
|
| 9800 | // Otherwise use the full result
|
| 9801 | responseText );
|
| 9802 |
|
| 9803 | }).complete( callback && function( jqXHR, status ) {
|
| 9804 | self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
|
| 9805 | });
|
| 9806 | }
|
| 9807 |
|
| 9808 | return this;
|
| 9809 | };
|
| 9810 |
|
| 9811 | // Attach a bunch of functions for handling common AJAX events
|
| 9812 | jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
|
| 9813 | jQuery.fn[ type ] = function( fn ){
|
| 9814 | return this.on( type, fn );
|
| 9815 | };
|
| 9816 | });
|
| 9817 |
|
| 9818 | jQuery.extend({
|
| 9819 |
|
| 9820 | // Counter for holding the number of active queries
|
| 9821 | active: 0,
|
| 9822 |
|
| 9823 | // Last-Modified header cache for next request
|
| 9824 | lastModified: {},
|
| 9825 | etag: {},
|
| 9826 |
|
| 9827 | ajaxSettings: {
|
| 9828 | url: ajaxLocation,
|
| 9829 | type: "GET",
|
| 9830 | isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
|
| 9831 | global: true,
|
| 9832 | processData: true,
|
| 9833 | async: true,
|
| 9834 | contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
| 9835 | /*
|
| 9836 | timeout: 0,
|
| 9837 | data: null,
|
| 9838 | dataType: null,
|
| 9839 | username: null,
|
| 9840 | password: null,
|
| 9841 | cache: null,
|
| 9842 | throws: false,
|
| 9843 | traditional: false,
|
| 9844 | headers: {},
|
| 9845 | */
|
| 9846 |
|
| 9847 | accepts: {
|
| 9848 | "*": allTypes,
|
| 9849 | text: "text/plain",
|
| 9850 | html: "text/html",
|
| 9851 | xml: "application/xml, text/xml",
|
| 9852 | json: "application/json, text/javascript"
|
| 9853 | },
|
| 9854 |
|
| 9855 | contents: {
|
| 9856 | xml: /xml/,
|
| 9857 | html: /html/,
|
| 9858 | json: /json/
|
| 9859 | },
|
| 9860 |
|
| 9861 | responseFields: {
|
| 9862 | xml: "responseXML",
|
| 9863 | text: "responseText",
|
| 9864 | json: "responseJSON"
|
| 9865 | },
|
| 9866 |
|
| 9867 | // Data converters
|
| 9868 | // Keys separate source (or catchall "*") and destination types with a single space
|
| 9869 | converters: {
|
| 9870 |
|
| 9871 | // Convert anything to text
|
| 9872 | "* text": String,
|
| 9873 |
|
| 9874 | // Text to html (true = no transformation)
|
| 9875 | "text html": true,
|
| 9876 |
|
| 9877 | // Evaluate text as a json expression
|
| 9878 | "text json": jQuery.parseJSON,
|
| 9879 |
|
| 9880 | // Parse text as xml
|
| 9881 | "text xml": jQuery.parseXML
|
| 9882 | },
|
| 9883 |
|
| 9884 | // For options that shouldn't be deep extended:
|
| 9885 | // you can add your own custom options here if
|
| 9886 | // and when you create one that shouldn't be
|
| 9887 | // deep extended (see ajaxExtend)
|
| 9888 | flatOptions: {
|
| 9889 | url: true,
|
| 9890 | context: true
|
| 9891 | }
|
| 9892 | },
|
| 9893 |
|
| 9894 | // Creates a full fledged settings object into target
|
| 9895 | // with both ajaxSettings and settings fields.
|
| 9896 | // If target is omitted, writes into ajaxSettings.
|
| 9897 | ajaxSetup: function( target, settings ) {
|
| 9898 | return settings ?
|
| 9899 |
|
| 9900 | // Building a settings object
|
| 9901 | ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
|
| 9902 |
|
| 9903 | // Extending ajaxSettings
|
| 9904 | ajaxExtend( jQuery.ajaxSettings, target );
|
| 9905 | },
|
| 9906 |
|
| 9907 | ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
|
| 9908 | ajaxTransport: addToPrefiltersOrTransports( transports ),
|
| 9909 |
|
| 9910 | // Main method
|
| 9911 | ajax: function( url, options ) {
|
| 9912 |
|
| 9913 | // If url is an object, simulate pre-1.5 signature
|
| 9914 | if ( typeof url === "object" ) {
|
| 9915 | options = url;
|
| 9916 | url = undefined;
|
| 9917 | }
|
| 9918 |
|
| 9919 | // Force options to be an object
|
| 9920 | options = options || {};
|
| 9921 |
|
| 9922 | var // Cross-domain detection vars
|
| 9923 | parts,
|
| 9924 | // Loop variable
|
| 9925 | i,
|
| 9926 | // URL without anti-cache param
|
| 9927 | cacheURL,
|
| 9928 | // Response headers as string
|
| 9929 | responseHeadersString,
|
| 9930 | // timeout handle
|
| 9931 | timeoutTimer,
|
| 9932 |
|
| 9933 | // To know if global events are to be dispatched
|
| 9934 | fireGlobals,
|
| 9935 |
|
| 9936 | transport,
|
| 9937 | // Response headers
|
| 9938 | responseHeaders,
|
| 9939 | // Create the final options object
|
| 9940 | s = jQuery.ajaxSetup( {}, options ),
|
| 9941 | // Callbacks context
|
| 9942 | callbackContext = s.context || s,
|
| 9943 | // Context for global events is callbackContext if it is a DOM node or jQuery collection
|
| 9944 | globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
|
| 9945 | jQuery( callbackContext ) :
|
| 9946 | jQuery.event,
|
| 9947 | // Deferreds
|
| 9948 | deferred = jQuery.Deferred(),
|
| 9949 | completeDeferred = jQuery.Callbacks("once memory"),
|
| 9950 | // Status-dependent callbacks
|
| 9951 | statusCode = s.statusCode || {},
|
| 9952 | // Headers (they are sent all at once)
|
| 9953 | requestHeaders = {},
|
| 9954 | requestHeadersNames = {},
|
| 9955 | // The jqXHR state
|
| 9956 | state = 0,
|
| 9957 | // Default abort message
|
| 9958 | strAbort = "canceled",
|
| 9959 | // Fake xhr
|
| 9960 | jqXHR = {
|
| 9961 | readyState: 0,
|
| 9962 |
|
| 9963 | // Builds headers hashtable if needed
|
| 9964 | getResponseHeader: function( key ) {
|
| 9965 | var match;
|
| 9966 | if ( state === 2 ) {
|
| 9967 | if ( !responseHeaders ) {
|
| 9968 | responseHeaders = {};
|
| 9969 | while ( (match = rheaders.exec( responseHeadersString )) ) {
|
| 9970 | responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
|
| 9971 | }
|
| 9972 | }
|
| 9973 | match = responseHeaders[ key.toLowerCase() ];
|
| 9974 | }
|
| 9975 | return match == null ? null : match;
|
| 9976 | },
|
| 9977 |
|
| 9978 | // Raw string
|
| 9979 | getAllResponseHeaders: function() {
|
| 9980 | return state === 2 ? responseHeadersString : null;
|
| 9981 | },
|
| 9982 |
|
| 9983 | // Caches the header
|
| 9984 | setRequestHeader: function( name, value ) {
|
| 9985 | var lname = name.toLowerCase();
|
| 9986 | if ( !state ) {
|
| 9987 | name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
| 9988 | requestHeaders[ name ] = value;
|
| 9989 | }
|
| 9990 | return this;
|
| 9991 | },
|
| 9992 |
|
| 9993 | // Overrides response content-type header
|
| 9994 | overrideMimeType: function( type ) {
|
| 9995 | if ( !state ) {
|
| 9996 | s.mimeType = type;
|
| 9997 | }
|
| 9998 | return this;
|
| 9999 | },
|
| 10000 |
|
| 10001 | // Status-dependent callbacks
|
| 10002 | statusCode: function( map ) {
|
| 10003 | var code;
|
| 10004 | if ( map ) {
|
| 10005 | if ( state < 2 ) {
|
| 10006 | for ( code in map ) {
|
| 10007 | // Lazy-add the new callback in a way that preserves old ones
|
| 10008 | statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
|
| 10009 | }
|
| 10010 | } else {
|
| 10011 | // Execute the appropriate callbacks
|
| 10012 | jqXHR.always( map[ jqXHR.status ] );
|
| 10013 | }
|
| 10014 | }
|
| 10015 | return this;
|
| 10016 | },
|
| 10017 |
|
| 10018 | // Cancel the request
|
| 10019 | abort: function( statusText ) {
|
| 10020 | var finalText = statusText || strAbort;
|
| 10021 | if ( transport ) {
|
| 10022 | transport.abort( finalText );
|
| 10023 | }
|
| 10024 | done( 0, finalText );
|
| 10025 | return this;
|
| 10026 | }
|
| 10027 | };
|
| 10028 |
|
| 10029 | // Attach deferreds
|
| 10030 | deferred.promise( jqXHR ).complete = completeDeferred.add;
|
| 10031 | jqXHR.success = jqXHR.done;
|
| 10032 | jqXHR.error = jqXHR.fail;
|
| 10033 |
|
| 10034 | // Remove hash character (#7531: and string promotion)
|
| 10035 | // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
|
| 10036 | // Handle falsy url in the settings object (#10093: consistency with old signature)
|
| 10037 | // We also use the url parameter if available
|
| 10038 | s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
| 10039 |
|
| 10040 | // Alias method option to type as per ticket #12004
|
| 10041 | s.type = options.method || options.type || s.method || s.type;
|
| 10042 |
|
| 10043 | // Extract dataTypes list
|
| 10044 | s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
|
| 10045 |
|
| 10046 | // A cross-domain request is in order when we have a protocol:host:port mismatch
|
| 10047 | if ( s.crossDomain == null ) {
|
| 10048 | parts = rurl.exec( s.url.toLowerCase() );
|
| 10049 | s.crossDomain = !!( parts &&
|
| 10050 | ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
|
| 10051 | ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
|
| 10052 | ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
|
| 10053 | );
|
| 10054 | }
|
| 10055 |
|
| 10056 | // Convert data if not already a string
|
| 10057 | if ( s.data && s.processData && typeof s.data !== "string" ) {
|
| 10058 | s.data = jQuery.param( s.data, s.traditional );
|
| 10059 | }
|
| 10060 |
|
| 10061 | // Apply prefilters
|
| 10062 | inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
|
| 10063 |
|
| 10064 | // If request was aborted inside a prefilter, stop there
|
| 10065 | if ( state === 2 ) {
|
| 10066 | return jqXHR;
|
| 10067 | }
|
| 10068 |
|
| 10069 | // We can fire global events as of now if asked to
|
| 10070 | fireGlobals = s.global;
|
| 10071 |
|
| 10072 | // Watch for a new set of requests
|
| 10073 | if ( fireGlobals && jQuery.active++ === 0 ) {
|
| 10074 | jQuery.event.trigger("ajaxStart");
|
| 10075 | }
|
| 10076 |
|
| 10077 | // Uppercase the type
|
| 10078 | s.type = s.type.toUpperCase();
|
| 10079 |
|
| 10080 | // Determine if request has content
|
| 10081 | s.hasContent = !rnoContent.test( s.type );
|
| 10082 |
|
| 10083 | // Save the URL in case we're toying with the If-Modified-Since
|
| 10084 | // and/or If-None-Match header later on
|
| 10085 | cacheURL = s.url;
|
| 10086 |
|
| 10087 | // More options handling for requests with no content
|
| 10088 | if ( !s.hasContent ) {
|
| 10089 |
|
| 10090 | // If data is available, append data to url
|
| 10091 | if ( s.data ) {
|
| 10092 | cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
|
| 10093 | // #9682: remove data so that it's not used in an eventual retry
|
| 10094 | delete s.data;
|
| 10095 | }
|
| 10096 |
|
| 10097 | // Add anti-cache in url if needed
|
| 10098 | if ( s.cache === false ) {
|
| 10099 | s.url = rts.test( cacheURL ) ?
|
| 10100 |
|
| 10101 | // If there is already a '_' parameter, set its value
|
| 10102 | cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
|
| 10103 |
|
| 10104 | // Otherwise add one to the end
|
| 10105 | cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
|
| 10106 | }
|
| 10107 | }
|
| 10108 |
|
| 10109 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
| 10110 | if ( s.ifModified ) {
|
| 10111 | if ( jQuery.lastModified[ cacheURL ] ) {
|
| 10112 | jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
|
| 10113 | }
|
| 10114 | if ( jQuery.etag[ cacheURL ] ) {
|
| 10115 | jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
|
| 10116 | }
|
| 10117 | }
|
| 10118 |
|
| 10119 | // Set the correct header, if data is being sent
|
| 10120 | if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
| 10121 | jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
| 10122 | }
|
| 10123 |
|
| 10124 | // Set the Accepts header for the server, depending on the dataType
|
| 10125 | jqXHR.setRequestHeader(
|
| 10126 | "Accept",
|
| 10127 | s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
| 10128 | s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
| 10129 | s.accepts[ "*" ]
|
| 10130 | );
|
| 10131 |
|
| 10132 | // Check for headers option
|
| 10133 | for ( i in s.headers ) {
|
| 10134 | jqXHR.setRequestHeader( i, s.headers[ i ] );
|
| 10135 | }
|
| 10136 |
|
| 10137 | // Allow custom headers/mimetypes and early abort
|
| 10138 | if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
| 10139 | // Abort if not done already and return
|
| 10140 | return jqXHR.abort();
|
| 10141 | }
|
| 10142 |
|
| 10143 | // aborting is no longer a cancellation
|
| 10144 | strAbort = "abort";
|
| 10145 |
|
| 10146 | // Install callbacks on deferreds
|
| 10147 | for ( i in { success: 1, error: 1, complete: 1 } ) {
|
| 10148 | jqXHR[ i ]( s[ i ] );
|
| 10149 | }
|
| 10150 |
|
| 10151 | // Get transport
|
| 10152 | transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
|
| 10153 |
|
| 10154 | // If no transport, we auto-abort
|
| 10155 | if ( !transport ) {
|
| 10156 | done( -1, "No Transport" );
|
| 10157 | } else {
|
| 10158 | jqXHR.readyState = 1;
|
| 10159 |
|
| 10160 | // Send global event
|
| 10161 | if ( fireGlobals ) {
|
| 10162 | globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
|
| 10163 | }
|
| 10164 | // Timeout
|
| 10165 | if ( s.async && s.timeout > 0 ) {
|
| 10166 | timeoutTimer = setTimeout(function() {
|
| 10167 | jqXHR.abort("timeout");
|
| 10168 | }, s.timeout );
|
| 10169 | }
|
| 10170 |
|
| 10171 | try {
|
| 10172 | state = 1;
|
| 10173 | transport.send( requestHeaders, done );
|
| 10174 | } catch ( e ) {
|
| 10175 | // Propagate exception as error if not done
|
| 10176 | if ( state < 2 ) {
|
| 10177 | done( -1, e );
|
| 10178 | // Simply rethrow otherwise
|
| 10179 | } else {
|
| 10180 | throw e;
|
| 10181 | }
|
| 10182 | }
|
| 10183 | }
|
| 10184 |
|
| 10185 | // Callback for when everything is done
|
| 10186 | function done( status, nativeStatusText, responses, headers ) {
|
| 10187 | var isSuccess, success, error, response, modified,
|
| 10188 | statusText = nativeStatusText;
|
| 10189 |
|
| 10190 | // Called once
|
| 10191 | if ( state === 2 ) {
|
| 10192 | return;
|
| 10193 | }
|
| 10194 |
|
| 10195 | // State is "done" now
|
| 10196 | state = 2;
|
| 10197 |
|
| 10198 | // Clear timeout if it exists
|
| 10199 | if ( timeoutTimer ) {
|
| 10200 | clearTimeout( timeoutTimer );
|
| 10201 | }
|
| 10202 |
|
| 10203 | // Dereference transport for early garbage collection
|
| 10204 | // (no matter how long the jqXHR object will be used)
|
| 10205 | transport = undefined;
|
| 10206 |
|
| 10207 | // Cache response headers
|
| 10208 | responseHeadersString = headers || "";
|
| 10209 |
|
| 10210 | // Set readyState
|
| 10211 | jqXHR.readyState = status > 0 ? 4 : 0;
|
| 10212 |
|
| 10213 | // Determine if successful
|
| 10214 | isSuccess = status >= 200 && status < 300 || status === 304;
|
| 10215 |
|
| 10216 | // Get response data
|
| 10217 | if ( responses ) {
|
| 10218 | response = ajaxHandleResponses( s, jqXHR, responses );
|
| 10219 | }
|
| 10220 |
|
| 10221 | // Convert no matter what (that way responseXXX fields are always set)
|
| 10222 | response = ajaxConvert( s, response, jqXHR, isSuccess );
|
| 10223 |
|
| 10224 | // If successful, handle type chaining
|
| 10225 | if ( isSuccess ) {
|
| 10226 |
|
| 10227 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
| 10228 | if ( s.ifModified ) {
|
| 10229 | modified = jqXHR.getResponseHeader("Last-Modified");
|
| 10230 | if ( modified ) {
|
| 10231 | jQuery.lastModified[ cacheURL ] = modified;
|
| 10232 | }
|
| 10233 | modified = jqXHR.getResponseHeader("etag");
|
| 10234 | if ( modified ) {
|
| 10235 | jQuery.etag[ cacheURL ] = modified;
|
| 10236 | }
|
| 10237 | }
|
| 10238 |
|
| 10239 | // if no content
|
| 10240 | if ( status === 204 || s.type === "HEAD" ) {
|
| 10241 | statusText = "nocontent";
|
| 10242 |
|
| 10243 | // if not modified
|
| 10244 | } else if ( status === 304 ) {
|
| 10245 | statusText = "notmodified";
|
| 10246 |
|
| 10247 | // If we have data, let's convert it
|
| 10248 | } else {
|
| 10249 | statusText = response.state;
|
| 10250 | success = response.data;
|
| 10251 | error = response.error;
|
| 10252 | isSuccess = !error;
|
| 10253 | }
|
| 10254 | } else {
|
| 10255 | // We extract error from statusText
|
| 10256 | // then normalize statusText and status for non-aborts
|
| 10257 | error = statusText;
|
| 10258 | if ( status || !statusText ) {
|
| 10259 | statusText = "error";
|
| 10260 | if ( status < 0 ) {
|
| 10261 | status = 0;
|
| 10262 | }
|
| 10263 | }
|
| 10264 | }
|
| 10265 |
|
| 10266 | // Set data for the fake xhr object
|
| 10267 | jqXHR.status = status;
|
| 10268 | jqXHR.statusText = ( nativeStatusText || statusText ) + "";
|
| 10269 |
|
| 10270 | // Success/Error
|
| 10271 | if ( isSuccess ) {
|
| 10272 | deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
|
| 10273 | } else {
|
| 10274 | deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
|
| 10275 | }
|
| 10276 |
|
| 10277 | // Status-dependent callbacks
|
| 10278 | jqXHR.statusCode( statusCode );
|
| 10279 | statusCode = undefined;
|
| 10280 |
|
| 10281 | if ( fireGlobals ) {
|
| 10282 | globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
|
| 10283 | [ jqXHR, s, isSuccess ? success : error ] );
|
| 10284 | }
|
| 10285 |
|
| 10286 | // Complete
|
| 10287 | completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
|
| 10288 |
|
| 10289 | if ( fireGlobals ) {
|
| 10290 | globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
| 10291 | // Handle the global AJAX counter
|
| 10292 | if ( !( --jQuery.active ) ) {
|
| 10293 | jQuery.event.trigger("ajaxStop");
|
| 10294 | }
|
| 10295 | }
|
| 10296 | }
|
| 10297 |
|
| 10298 | return jqXHR;
|
| 10299 | },
|
| 10300 |
|
| 10301 | getJSON: function( url, data, callback ) {
|
| 10302 | return jQuery.get( url, data, callback, "json" );
|
| 10303 | },
|
| 10304 |
|
| 10305 | getScript: function( url, callback ) {
|
| 10306 | return jQuery.get( url, undefined, callback, "script" );
|
| 10307 | }
|
| 10308 | });
|
| 10309 |
|
| 10310 | jQuery.each( [ "get", "post" ], function( i, method ) {
|
| 10311 | jQuery[ method ] = function( url, data, callback, type ) {
|
| 10312 | // shift arguments if data argument was omitted
|
| 10313 | if ( jQuery.isFunction( data ) ) {
|
| 10314 | type = type || callback;
|
| 10315 | callback = data;
|
| 10316 | data = undefined;
|
| 10317 | }
|
| 10318 |
|
| 10319 | return jQuery.ajax({
|
| 10320 | url: url,
|
| 10321 | type: method,
|
| 10322 | dataType: type,
|
| 10323 | data: data,
|
| 10324 | success: callback
|
| 10325 | });
|
| 10326 | };
|
| 10327 | });
|
| 10328 |
|
| 10329 | /* Handles responses to an ajax request:
|
| 10330 | * - finds the right dataType (mediates between content-type and expected dataType)
|
| 10331 | * - returns the corresponding response
|
| 10332 | */
|
| 10333 | function ajaxHandleResponses( s, jqXHR, responses ) {
|
| 10334 | var firstDataType, ct, finalDataType, type,
|
| 10335 | contents = s.contents,
|
| 10336 | dataTypes = s.dataTypes;
|
| 10337 |
|
| 10338 | // Remove auto dataType and get content-type in the process
|
| 10339 | while( dataTypes[ 0 ] === "*" ) {
|
| 10340 | dataTypes.shift();
|
| 10341 | if ( ct === undefined ) {
|
| 10342 | ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
|
| 10343 | }
|
| 10344 | }
|
| 10345 |
|
| 10346 | // Check if we're dealing with a known content-type
|
| 10347 | if ( ct ) {
|
| 10348 | for ( type in contents ) {
|
| 10349 | if ( contents[ type ] && contents[ type ].test( ct ) ) {
|
| 10350 | dataTypes.unshift( type );
|
| 10351 | break;
|
| 10352 | }
|
| 10353 | }
|
| 10354 | }
|
| 10355 |
|
| 10356 | // Check to see if we have a response for the expected dataType
|
| 10357 | if ( dataTypes[ 0 ] in responses ) {
|
| 10358 | finalDataType = dataTypes[ 0 ];
|
| 10359 | } else {
|
| 10360 | // Try convertible dataTypes
|
| 10361 | for ( type in responses ) {
|
| 10362 | if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
|
| 10363 | finalDataType = type;
|
| 10364 | break;
|
| 10365 | }
|
| 10366 | if ( !firstDataType ) {
|
| 10367 | firstDataType = type;
|
| 10368 | }
|
| 10369 | }
|
| 10370 | // Or just use first one
|
| 10371 | finalDataType = finalDataType || firstDataType;
|
| 10372 | }
|
| 10373 |
|
| 10374 | // If we found a dataType
|
| 10375 | // We add the dataType to the list if needed
|
| 10376 | // and return the corresponding response
|
| 10377 | if ( finalDataType ) {
|
| 10378 | if ( finalDataType !== dataTypes[ 0 ] ) {
|
| 10379 | dataTypes.unshift( finalDataType );
|
| 10380 | }
|
| 10381 | return responses[ finalDataType ];
|
| 10382 | }
|
| 10383 | }
|
| 10384 |
|
| 10385 | /* Chain conversions given the request and the original response
|
| 10386 | * Also sets the responseXXX fields on the jqXHR instance
|
| 10387 | */
|
| 10388 | function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
| 10389 | var conv2, current, conv, tmp, prev,
|
| 10390 | converters = {},
|
| 10391 | // Work with a copy of dataTypes in case we need to modify it for conversion
|
| 10392 | dataTypes = s.dataTypes.slice();
|
| 10393 |
|
| 10394 | // Create converters map with lowercased keys
|
| 10395 | if ( dataTypes[ 1 ] ) {
|
| 10396 | for ( conv in s.converters ) {
|
| 10397 | converters[ conv.toLowerCase() ] = s.converters[ conv ];
|
| 10398 | }
|
| 10399 | }
|
| 10400 |
|
| 10401 | current = dataTypes.shift();
|
| 10402 |
|
| 10403 | // Convert to each sequential dataType
|
| 10404 | while ( current ) {
|
| 10405 |
|
| 10406 | if ( s.responseFields[ current ] ) {
|
| 10407 | jqXHR[ s.responseFields[ current ] ] = response;
|
| 10408 | }
|
| 10409 |
|
| 10410 | // Apply the dataFilter if provided
|
| 10411 | if ( !prev && isSuccess && s.dataFilter ) {
|
| 10412 | response = s.dataFilter( response, s.dataType );
|
| 10413 | }
|
| 10414 |
|
| 10415 | prev = current;
|
| 10416 | current = dataTypes.shift();
|
| 10417 |
|
| 10418 | if ( current ) {
|
| 10419 |
|
| 10420 | // There's only work to do if current dataType is non-auto
|
| 10421 | if ( current === "*" ) {
|
| 10422 |
|
| 10423 | current = prev;
|
| 10424 |
|
| 10425 | // Convert response if prev dataType is non-auto and differs from current
|
| 10426 | } else if ( prev !== "*" && prev !== current ) {
|
| 10427 |
|
| 10428 | // Seek a direct converter
|
| 10429 | conv = converters[ prev + " " + current ] || converters[ "* " + current ];
|
| 10430 |
|
| 10431 | // If none found, seek a pair
|
| 10432 | if ( !conv ) {
|
| 10433 | for ( conv2 in converters ) {
|
| 10434 |
|
| 10435 | // If conv2 outputs current
|
| 10436 | tmp = conv2.split( " " );
|
| 10437 | if ( tmp[ 1 ] === current ) {
|
| 10438 |
|
| 10439 | // If prev can be converted to accepted input
|
| 10440 | conv = converters[ prev + " " + tmp[ 0 ] ] ||
|
| 10441 | converters[ "* " + tmp[ 0 ] ];
|
| 10442 | if ( conv ) {
|
| 10443 | // Condense equivalence converters
|
| 10444 | if ( conv === true ) {
|
| 10445 | conv = converters[ conv2 ];
|
| 10446 |
|
| 10447 | // Otherwise, insert the intermediate dataType
|
| 10448 | } else if ( converters[ conv2 ] !== true ) {
|
| 10449 | current = tmp[ 0 ];
|
| 10450 | dataTypes.unshift( tmp[ 1 ] );
|
| 10451 | }
|
| 10452 | break;
|
| 10453 | }
|
| 10454 | }
|
| 10455 | }
|
| 10456 | }
|
| 10457 |
|
| 10458 | // Apply converter (if not an equivalence)
|
| 10459 | if ( conv !== true ) {
|
| 10460 |
|
| 10461 | // Unless errors are allowed to bubble, catch and return them
|
| 10462 | if ( conv && s[ "throws" ] ) {
|
| 10463 | response = conv( response );
|
| 10464 | } else {
|
| 10465 | try {
|
| 10466 | response = conv( response );
|
| 10467 | } catch ( e ) {
|
| 10468 | return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
|
| 10469 | }
|
| 10470 | }
|
| 10471 | }
|
| 10472 | }
|
| 10473 | }
|
| 10474 | }
|
| 10475 |
|
| 10476 | return { state: "success", data: response };
|
| 10477 | }
|
| 10478 | // Install script dataType
|
| 10479 | jQuery.ajaxSetup({
|
| 10480 | accepts: {
|
| 10481 | script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
| 10482 | },
|
| 10483 | contents: {
|
| 10484 | script: /(?:java|ecma)script/
|
| 10485 | },
|
| 10486 | converters: {
|
| 10487 | "text script": function( text ) {
|
| 10488 | jQuery.globalEval( text );
|
| 10489 | return text;
|
| 10490 | }
|
| 10491 | }
|
| 10492 | });
|
| 10493 |
|
| 10494 | // Handle cache's special case and global
|
| 10495 | jQuery.ajaxPrefilter( "script", function( s ) {
|
| 10496 | if ( s.cache === undefined ) {
|
| 10497 | s.cache = false;
|
| 10498 | }
|
| 10499 | if ( s.crossDomain ) {
|
| 10500 | s.type = "GET";
|
| 10501 | s.global = false;
|
| 10502 | }
|
| 10503 | });
|
| 10504 |
|
| 10505 | // Bind script tag hack transport
|
| 10506 | jQuery.ajaxTransport( "script", function(s) {
|
| 10507 |
|
| 10508 | // This transport only deals with cross domain requests
|
| 10509 | if ( s.crossDomain ) {
|
| 10510 |
|
| 10511 | var script,
|
| 10512 | head = document.head || jQuery("head")[0] || document.documentElement;
|
| 10513 |
|
| 10514 | return {
|
| 10515 |
|
| 10516 | send: function( _, callback ) {
|
| 10517 |
|
| 10518 | script = document.createElement("script");
|
| 10519 |
|
| 10520 | script.async = true;
|
| 10521 |
|
| 10522 | if ( s.scriptCharset ) {
|
| 10523 | script.charset = s.scriptCharset;
|
| 10524 | }
|
| 10525 |
|
| 10526 | script.src = s.url;
|
| 10527 |
|
| 10528 | // Attach handlers for all browsers
|
| 10529 | script.onload = script.onreadystatechange = function( _, isAbort ) {
|
| 10530 |
|
| 10531 | if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
| 10532 |
|
| 10533 | // Handle memory leak in IE
|
| 10534 | script.onload = script.onreadystatechange = null;
|
| 10535 |
|
| 10536 | // Remove the script
|
| 10537 | if ( script.parentNode ) {
|
| 10538 | script.parentNode.removeChild( script );
|
| 10539 | }
|
| 10540 |
|
| 10541 | // Dereference the script
|
| 10542 | script = null;
|
| 10543 |
|
| 10544 | // Callback if not abort
|
| 10545 | if ( !isAbort ) {
|
| 10546 | callback( 200, "success" );
|
| 10547 | }
|
| 10548 | }
|
| 10549 | };
|
| 10550 |
|
| 10551 | // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
|
| 10552 | // Use native DOM manipulation to avoid our domManip AJAX trickery
|
| 10553 | head.insertBefore( script, head.firstChild );
|
| 10554 | },
|
| 10555 |
|
| 10556 | abort: function() {
|
| 10557 | if ( script ) {
|
| 10558 | script.onload( undefined, true );
|
| 10559 | }
|
| 10560 | }
|
| 10561 | };
|
| 10562 | }
|
| 10563 | });
|
| 10564 | var oldCallbacks = [],
|
| 10565 | rjsonp = /(=)\?(?=&|$)|\?\?/;
|
| 10566 |
|
| 10567 | // Default jsonp settings
|
| 10568 | jQuery.ajaxSetup({
|
| 10569 | jsonp: "callback",
|
| 10570 | jsonpCallback: function() {
|
| 10571 | var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
|
| 10572 | this[ callback ] = true;
|
| 10573 | return callback;
|
| 10574 | }
|
| 10575 | });
|
| 10576 |
|
| 10577 | // Detect, normalize options and install callbacks for jsonp requests
|
| 10578 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
| 10579 |
|
| 10580 | var callbackName, overwritten, responseContainer,
|
| 10581 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
| 10582 | "url" :
|
| 10583 | typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
|
| 10584 | );
|
| 10585 |
|
| 10586 | // Handle iff the expected data type is "jsonp" or we have a parameter to set
|
| 10587 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
|
| 10588 |
|
| 10589 | // Get callback name, remembering preexisting value associated with it
|
| 10590 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
|
| 10591 | s.jsonpCallback() :
|
| 10592 | s.jsonpCallback;
|
| 10593 |
|
| 10594 | // Insert callback into url or form data
|
| 10595 | if ( jsonProp ) {
|
| 10596 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
|
| 10597 | } else if ( s.jsonp !== false ) {
|
| 10598 | s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
|
| 10599 | }
|
| 10600 |
|
| 10601 | // Use data converter to retrieve json after script execution
|
| 10602 | s.converters["script json"] = function() {
|
| 10603 | if ( !responseContainer ) {
|
| 10604 | jQuery.error( callbackName + " was not called" );
|
| 10605 | }
|
| 10606 | return responseContainer[ 0 ];
|
| 10607 | };
|
| 10608 |
|
| 10609 | // force json dataType
|
| 10610 | s.dataTypes[ 0 ] = "json";
|
| 10611 |
|
| 10612 | // Install callback
|
| 10613 | overwritten = window[ callbackName ];
|
| 10614 | window[ callbackName ] = function() {
|
| 10615 | responseContainer = arguments;
|
| 10616 | };
|
| 10617 |
|
| 10618 | // Clean-up function (fires after converters)
|
| 10619 | jqXHR.always(function() {
|
| 10620 | // Restore preexisting value
|
| 10621 | window[ callbackName ] = overwritten;
|
| 10622 |
|
| 10623 | // Save back as free
|
| 10624 | if ( s[ callbackName ] ) {
|
| 10625 | // make sure that re-using the options doesn't screw things around
|
| 10626 | s.jsonpCallback = originalSettings.jsonpCallback;
|
| 10627 |
|
| 10628 | // save the callback name for future use
|
| 10629 | oldCallbacks.push( callbackName );
|
| 10630 | }
|
| 10631 |
|
| 10632 | // Call if it was a function and we have a response
|
| 10633 | if ( responseContainer && jQuery.isFunction( overwritten ) ) {
|
| 10634 | overwritten( responseContainer[ 0 ] );
|
| 10635 | }
|
| 10636 |
|
| 10637 | responseContainer = overwritten = undefined;
|
| 10638 | });
|
| 10639 |
|
| 10640 | // Delegate to script
|
| 10641 | return "script";
|
| 10642 | }
|
| 10643 | });
|
| 10644 | var xhrCallbacks, xhrSupported,
|
| 10645 | xhrId = 0,
|
| 10646 | // #5280: Internet Explorer will keep connections alive if we don't abort on unload
|
| 10647 | xhrOnUnloadAbort = window.ActiveXObject && function() {
|
| 10648 | // Abort all pending requests
|
| 10649 | var key;
|
| 10650 | for ( key in xhrCallbacks ) {
|
| 10651 | xhrCallbacks[ key ]( undefined, true );
|
| 10652 | }
|
| 10653 | };
|
| 10654 |
|
| 10655 | // Functions to create xhrs
|
| 10656 | function createStandardXHR() {
|
| 10657 | try {
|
| 10658 | return new window.XMLHttpRequest();
|
| 10659 | } catch( e ) {}
|
| 10660 | }
|
| 10661 |
|
| 10662 | function createActiveXHR() {
|
| 10663 | try {
|
| 10664 | return new window.ActiveXObject("Microsoft.XMLHTTP");
|
| 10665 | } catch( e ) {}
|
| 10666 | }
|
| 10667 |
|
| 10668 | // Create the request object
|
| 10669 | // (This is still attached to ajaxSettings for backward compatibility)
|
| 10670 | jQuery.ajaxSettings.xhr = window.ActiveXObject ?
|
| 10671 | /* Microsoft failed to properly
|
| 10672 | * implement the XMLHttpRequest in IE7 (can't request local files),
|
| 10673 | * so we use the ActiveXObject when it is available
|
| 10674 | * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
|
| 10675 | * we need a fallback.
|
| 10676 | */
|
| 10677 | function() {
|
| 10678 | return !this.isLocal && createStandardXHR() || createActiveXHR();
|
| 10679 | } :
|
| 10680 | // For all other browsers, use the standard XMLHttpRequest object
|
| 10681 | createStandardXHR;
|
| 10682 |
|
| 10683 | // Determine support properties
|
| 10684 | xhrSupported = jQuery.ajaxSettings.xhr();
|
| 10685 | jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
|
| 10686 | xhrSupported = jQuery.support.ajax = !!xhrSupported;
|
| 10687 |
|
| 10688 | // Create transport if the browser can provide an xhr
|
| 10689 | if ( xhrSupported ) {
|
| 10690 |
|
| 10691 | jQuery.ajaxTransport(function( s ) {
|
| 10692 | // Cross domain only allowed if supported through XMLHttpRequest
|
| 10693 | if ( !s.crossDomain || jQuery.support.cors ) {
|
| 10694 |
|
| 10695 | var callback;
|
| 10696 |
|
| 10697 | return {
|
| 10698 | send: function( headers, complete ) {
|
| 10699 |
|
| 10700 | // Get a new xhr
|
| 10701 | var handle, i,
|
| 10702 | xhr = s.xhr();
|
| 10703 |
|
| 10704 | // Open the socket
|
| 10705 | // Passing null username, generates a login popup on Opera (#2865)
|
| 10706 | if ( s.username ) {
|
| 10707 | xhr.open( s.type, s.url, s.async, s.username, s.password );
|
| 10708 | } else {
|
| 10709 | xhr.open( s.type, s.url, s.async );
|
| 10710 | }
|
| 10711 |
|
| 10712 | // Apply custom fields if provided
|
| 10713 | if ( s.xhrFields ) {
|
| 10714 | for ( i in s.xhrFields ) {
|
| 10715 | xhr[ i ] = s.xhrFields[ i ];
|
| 10716 | }
|
| 10717 | }
|
| 10718 |
|
| 10719 | // Override mime type if needed
|
| 10720 | if ( s.mimeType && xhr.overrideMimeType ) {
|
| 10721 | xhr.overrideMimeType( s.mimeType );
|
| 10722 | }
|
| 10723 |
|
| 10724 | // X-Requested-With header
|
| 10725 | // For cross-domain requests, seeing as conditions for a preflight are
|
| 10726 | // akin to a jigsaw puzzle, we simply never set it to be sure.
|
| 10727 | // (it can always be set on a per-request basis or even using ajaxSetup)
|
| 10728 | // For same-domain requests, won't change header if already provided.
|
| 10729 | if ( !s.crossDomain && !headers["X-Requested-With"] ) {
|
| 10730 | headers["X-Requested-With"] = "XMLHttpRequest";
|
| 10731 | }
|
| 10732 |
|
| 10733 | // Need an extra try/catch for cross domain requests in Firefox 3
|
| 10734 | try {
|
| 10735 | for ( i in headers ) {
|
| 10736 | xhr.setRequestHeader( i, headers[ i ] );
|
| 10737 | }
|
| 10738 | } catch( err ) {}
|
| 10739 |
|
| 10740 | // Do send the request
|
| 10741 | // This may raise an exception which is actually
|
| 10742 | // handled in jQuery.ajax (so no try/catch here)
|
| 10743 | xhr.send( ( s.hasContent && s.data ) || null );
|
| 10744 |
|
| 10745 | // Listener
|
| 10746 | callback = function( _, isAbort ) {
|
| 10747 | var status, responseHeaders, statusText, responses;
|
| 10748 |
|
| 10749 | // Firefox throws exceptions when accessing properties
|
| 10750 | // of an xhr when a network error occurred
|
| 10751 | // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
|
| 10752 | try {
|
| 10753 |
|
| 10754 | // Was never called and is aborted or complete
|
| 10755 | if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
|
| 10756 |
|
| 10757 | // Only called once
|
| 10758 | callback = undefined;
|
| 10759 |
|
| 10760 | // Do not keep as active anymore
|
| 10761 | if ( handle ) {
|
| 10762 | xhr.onreadystatechange = jQuery.noop;
|
| 10763 | if ( xhrOnUnloadAbort ) {
|
| 10764 | delete xhrCallbacks[ handle ];
|
| 10765 | }
|
| 10766 | }
|
| 10767 |
|
| 10768 | // If it's an abort
|
| 10769 | if ( isAbort ) {
|
| 10770 | // Abort it manually if needed
|
| 10771 | if ( xhr.readyState !== 4 ) {
|
| 10772 | xhr.abort();
|
| 10773 | }
|
| 10774 | } else {
|
| 10775 | responses = {};
|
| 10776 | status = xhr.status;
|
| 10777 | responseHeaders = xhr.getAllResponseHeaders();
|
| 10778 |
|
| 10779 | // When requesting binary data, IE6-9 will throw an exception
|
| 10780 | // on any attempt to access responseText (#11426)
|
| 10781 | if ( typeof xhr.responseText === "string" ) {
|
| 10782 | responses.text = xhr.responseText;
|
| 10783 | }
|
| 10784 |
|
| 10785 | // Firefox throws an exception when accessing
|
| 10786 | // statusText for faulty cross-domain requests
|
| 10787 | try {
|
| 10788 | statusText = xhr.statusText;
|
| 10789 | } catch( e ) {
|
| 10790 | // We normalize with Webkit giving an empty statusText
|
| 10791 | statusText = "";
|
| 10792 | }
|
| 10793 |
|
| 10794 | // Filter status for non standard behaviors
|
| 10795 |
|
| 10796 | // If the request is local and we have data: assume a success
|
| 10797 | // (success with no data won't get notified, that's the best we
|
| 10798 | // can do given current implementations)
|
| 10799 | if ( !status && s.isLocal && !s.crossDomain ) {
|
| 10800 | status = responses.text ? 200 : 404;
|
| 10801 | // IE - #1450: sometimes returns 1223 when it should be 204
|
| 10802 | } else if ( status === 1223 ) {
|
| 10803 | status = 204;
|
| 10804 | }
|
| 10805 | }
|
| 10806 | }
|
| 10807 | } catch( firefoxAccessException ) {
|
| 10808 | if ( !isAbort ) {
|
| 10809 | complete( -1, firefoxAccessException );
|
| 10810 | }
|
| 10811 | }
|
| 10812 |
|
| 10813 | // Call complete if needed
|
| 10814 | if ( responses ) {
|
| 10815 | complete( status, statusText, responses, responseHeaders );
|
| 10816 | }
|
| 10817 | };
|
| 10818 |
|
| 10819 | if ( !s.async ) {
|
| 10820 | // if we're in sync mode we fire the callback
|
| 10821 | callback();
|
| 10822 | } else if ( xhr.readyState === 4 ) {
|
| 10823 | // (IE6 & IE7) if it's in cache and has been
|
| 10824 | // retrieved directly we need to fire the callback
|
| 10825 | setTimeout( callback );
|
| 10826 | } else {
|
| 10827 | handle = ++xhrId;
|
| 10828 | if ( xhrOnUnloadAbort ) {
|
| 10829 | // Create the active xhrs callbacks list if needed
|
| 10830 | // and attach the unload handler
|
| 10831 | if ( !xhrCallbacks ) {
|
| 10832 | xhrCallbacks = {};
|
| 10833 | jQuery( window ).unload( xhrOnUnloadAbort );
|
| 10834 | }
|
| 10835 | // Add to list of active xhrs callbacks
|
| 10836 | xhrCallbacks[ handle ] = callback;
|
| 10837 | }
|
| 10838 | xhr.onreadystatechange = callback;
|
| 10839 | }
|
| 10840 | },
|
| 10841 |
|
| 10842 | abort: function() {
|
| 10843 | if ( callback ) {
|
| 10844 | callback( undefined, true );
|
| 10845 | }
|
| 10846 | }
|
| 10847 | };
|
| 10848 | }
|
| 10849 | });
|
| 10850 | }
|
| 10851 | var fxNow, timerId,
|
| 10852 | rfxtypes = /^(?:toggle|show|hide)$/,
|
| 10853 | rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
|
| 10854 | rrun = /queueHooks$/,
|
| 10855 | animationPrefilters = [ defaultPrefilter ],
|
| 10856 | tweeners = {
|
| 10857 | "*": [function( prop, value ) {
|
| 10858 | var tween = this.createTween( prop, value ),
|
| 10859 | target = tween.cur(),
|
| 10860 | parts = rfxnum.exec( value ),
|
| 10861 | unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
|
| 10862 |
|
| 10863 | // Starting value computation is required for potential unit mismatches
|
| 10864 | start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
|
| 10865 | rfxnum.exec( jQuery.css( tween.elem, prop ) ),
|
| 10866 | scale = 1,
|
| 10867 | maxIterations = 20;
|
| 10868 |
|
| 10869 | if ( start && start[ 3 ] !== unit ) {
|
| 10870 | // Trust units reported by jQuery.css
|
| 10871 | unit = unit || start[ 3 ];
|
| 10872 |
|
| 10873 | // Make sure we update the tween properties later on
|
| 10874 | parts = parts || [];
|
| 10875 |
|
| 10876 | // Iteratively approximate from a nonzero starting point
|
| 10877 | start = +target || 1;
|
| 10878 |
|
| 10879 | do {
|
| 10880 | // If previous iteration zeroed out, double until we get *something*
|
| 10881 | // Use a string for doubling factor so we don't accidentally see scale as unchanged below
|
| 10882 | scale = scale || ".5";
|
| 10883 |
|
| 10884 | // Adjust and apply
|
| 10885 | start = start / scale;
|
| 10886 | jQuery.style( tween.elem, prop, start + unit );
|
| 10887 |
|
| 10888 | // Update scale, tolerating zero or NaN from tween.cur()
|
| 10889 | // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
|
| 10890 | } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
|
| 10891 | }
|
| 10892 |
|
| 10893 | // Update tween properties
|
| 10894 | if ( parts ) {
|
| 10895 | start = tween.start = +start || +target || 0;
|
| 10896 | tween.unit = unit;
|
| 10897 | // If a +=/-= token was provided, we're doing a relative animation
|
| 10898 | tween.end = parts[ 1 ] ?
|
| 10899 | start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
|
| 10900 | +parts[ 2 ];
|
| 10901 | }
|
| 10902 |
|
| 10903 | return tween;
|
| 10904 | }]
|
| 10905 | };
|
| 10906 |
|
| 10907 | // Animations created synchronously will run synchronously
|
| 10908 | function createFxNow() {
|
| 10909 | setTimeout(function() {
|
| 10910 | fxNow = undefined;
|
| 10911 | });
|
| 10912 | return ( fxNow = jQuery.now() );
|
| 10913 | }
|
| 10914 |
|
| 10915 | function createTween( value, prop, animation ) {
|
| 10916 | var tween,
|
| 10917 | collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
|
| 10918 | index = 0,
|
| 10919 | length = collection.length;
|
| 10920 | for ( ; index < length; index++ ) {
|
| 10921 | if ( (tween = collection[ index ].call( animation, prop, value )) ) {
|
| 10922 |
|
| 10923 | // we're done with this property
|
| 10924 | return tween;
|
| 10925 | }
|
| 10926 | }
|
| 10927 | }
|
| 10928 |
|
| 10929 | function Animation( elem, properties, options ) {
|
| 10930 | var result,
|
| 10931 | stopped,
|
| 10932 | index = 0,
|
| 10933 | length = animationPrefilters.length,
|
| 10934 | deferred = jQuery.Deferred().always( function() {
|
| 10935 | // don't match elem in the :animated selector
|
| 10936 | delete tick.elem;
|
| 10937 | }),
|
| 10938 | tick = function() {
|
| 10939 | if ( stopped ) {
|
| 10940 | return false;
|
| 10941 | }
|
| 10942 | var currentTime = fxNow || createFxNow(),
|
| 10943 | remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
| 10944 | // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
|
| 10945 | temp = remaining / animation.duration || 0,
|
| 10946 | percent = 1 - temp,
|
| 10947 | index = 0,
|
| 10948 | length = animation.tweens.length;
|
| 10949 |
|
| 10950 | for ( ; index < length ; index++ ) {
|
| 10951 | animation.tweens[ index ].run( percent );
|
| 10952 | }
|
| 10953 |
|
| 10954 | deferred.notifyWith( elem, [ animation, percent, remaining ]);
|
| 10955 |
|
| 10956 | if ( percent < 1 && length ) {
|
| 10957 | return remaining;
|
| 10958 | } else {
|
| 10959 | deferred.resolveWith( elem, [ animation ] );
|
| 10960 | return false;
|
| 10961 | }
|
| 10962 | },
|
| 10963 | animation = deferred.promise({
|
| 10964 | elem: elem,
|
| 10965 | props: jQuery.extend( {}, properties ),
|
| 10966 | opts: jQuery.extend( true, { specialEasing: {} }, options ),
|
| 10967 | originalProperties: properties,
|
| 10968 | originalOptions: options,
|
| 10969 | startTime: fxNow || createFxNow(),
|
| 10970 | duration: options.duration,
|
| 10971 | tweens: [],
|
| 10972 | createTween: function( prop, end ) {
|
| 10973 | var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
| 10974 | animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
| 10975 | animation.tweens.push( tween );
|
| 10976 | return tween;
|
| 10977 | },
|
| 10978 | stop: function( gotoEnd ) {
|
| 10979 | var index = 0,
|
| 10980 | // if we are going to the end, we want to run all the tweens
|
| 10981 | // otherwise we skip this part
|
| 10982 | length = gotoEnd ? animation.tweens.length : 0;
|
| 10983 | if ( stopped ) {
|
| 10984 | return this;
|
| 10985 | }
|
| 10986 | stopped = true;
|
| 10987 | for ( ; index < length ; index++ ) {
|
| 10988 | animation.tweens[ index ].run( 1 );
|
| 10989 | }
|
| 10990 |
|
| 10991 | // resolve when we played the last frame
|
| 10992 | // otherwise, reject
|
| 10993 | if ( gotoEnd ) {
|
| 10994 | deferred.resolveWith( elem, [ animation, gotoEnd ] );
|
| 10995 | } else {
|
| 10996 | deferred.rejectWith( elem, [ animation, gotoEnd ] );
|
| 10997 | }
|
| 10998 | return this;
|
| 10999 | }
|
| 11000 | }),
|
| 11001 | props = animation.props;
|
| 11002 |
|
| 11003 | propFilter( props, animation.opts.specialEasing );
|
| 11004 |
|
| 11005 | for ( ; index < length ; index++ ) {
|
| 11006 | result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
|
| 11007 | if ( result ) {
|
| 11008 | return result;
|
| 11009 | }
|
| 11010 | }
|
| 11011 |
|
| 11012 | jQuery.map( props, createTween, animation );
|
| 11013 |
|
| 11014 | if ( jQuery.isFunction( animation.opts.start ) ) {
|
| 11015 | animation.opts.start.call( elem, animation );
|
| 11016 | }
|
| 11017 |
|
| 11018 | jQuery.fx.timer(
|
| 11019 | jQuery.extend( tick, {
|
| 11020 | elem: elem,
|
| 11021 | anim: animation,
|
| 11022 | queue: animation.opts.queue
|
| 11023 | })
|
| 11024 | );
|
| 11025 |
|
| 11026 | // attach callbacks from options
|
| 11027 | return animation.progress( animation.opts.progress )
|
| 11028 | .done( animation.opts.done, animation.opts.complete )
|
| 11029 | .fail( animation.opts.fail )
|
| 11030 | .always( animation.opts.always );
|
| 11031 | }
|
| 11032 |
|
| 11033 | function propFilter( props, specialEasing ) {
|
| 11034 | var index, name, easing, value, hooks;
|
| 11035 |
|
| 11036 | // camelCase, specialEasing and expand cssHook pass
|
| 11037 | for ( index in props ) {
|
| 11038 | name = jQuery.camelCase( index );
|
| 11039 | easing = specialEasing[ name ];
|
| 11040 | value = props[ index ];
|
| 11041 | if ( jQuery.isArray( value ) ) {
|
| 11042 | easing = value[ 1 ];
|
| 11043 | value = props[ index ] = value[ 0 ];
|
| 11044 | }
|
| 11045 |
|
| 11046 | if ( index !== name ) {
|
| 11047 | props[ name ] = value;
|
| 11048 | delete props[ index ];
|
| 11049 | }
|
| 11050 |
|
| 11051 | hooks = jQuery.cssHooks[ name ];
|
| 11052 | if ( hooks && "expand" in hooks ) {
|
| 11053 | value = hooks.expand( value );
|
| 11054 | delete props[ name ];
|
| 11055 |
|
| 11056 | // not quite $.extend, this wont overwrite keys already present.
|
| 11057 | // also - reusing 'index' from above because we have the correct "name"
|
| 11058 | for ( index in value ) {
|
| 11059 | if ( !( index in props ) ) {
|
| 11060 | props[ index ] = value[ index ];
|
| 11061 | specialEasing[ index ] = easing;
|
| 11062 | }
|
| 11063 | }
|
| 11064 | } else {
|
| 11065 | specialEasing[ name ] = easing;
|
| 11066 | }
|
| 11067 | }
|
| 11068 | }
|
| 11069 |
|
| 11070 | jQuery.Animation = jQuery.extend( Animation, {
|
| 11071 |
|
| 11072 | tweener: function( props, callback ) {
|
| 11073 | if ( jQuery.isFunction( props ) ) {
|
| 11074 | callback = props;
|
| 11075 | props = [ "*" ];
|
| 11076 | } else {
|
| 11077 | props = props.split(" ");
|
| 11078 | }
|
| 11079 |
|
| 11080 | var prop,
|
| 11081 | index = 0,
|
| 11082 | length = props.length;
|
| 11083 |
|
| 11084 | for ( ; index < length ; index++ ) {
|
| 11085 | prop = props[ index ];
|
| 11086 | tweeners[ prop ] = tweeners[ prop ] || [];
|
| 11087 | tweeners[ prop ].unshift( callback );
|
| 11088 | }
|
| 11089 | },
|
| 11090 |
|
| 11091 | prefilter: function( callback, prepend ) {
|
| 11092 | if ( prepend ) {
|
| 11093 | animationPrefilters.unshift( callback );
|
| 11094 | } else {
|
| 11095 | animationPrefilters.push( callback );
|
| 11096 | }
|
| 11097 | }
|
| 11098 | });
|
| 11099 |
|
| 11100 | function defaultPrefilter( elem, props, opts ) {
|
| 11101 | /* jshint validthis: true */
|
| 11102 | var prop, value, toggle, tween, hooks, oldfire,
|
| 11103 | anim = this,
|
| 11104 | orig = {},
|
| 11105 | style = elem.style,
|
| 11106 | hidden = elem.nodeType && isHidden( elem ),
|
| 11107 | dataShow = jQuery._data( elem, "fxshow" );
|
| 11108 |
|
| 11109 | // handle queue: false promises
|
| 11110 | if ( !opts.queue ) {
|
| 11111 | hooks = jQuery._queueHooks( elem, "fx" );
|
| 11112 | if ( hooks.unqueued == null ) {
|
| 11113 | hooks.unqueued = 0;
|
| 11114 | oldfire = hooks.empty.fire;
|
| 11115 | hooks.empty.fire = function() {
|
| 11116 | if ( !hooks.unqueued ) {
|
| 11117 | oldfire();
|
| 11118 | }
|
| 11119 | };
|
| 11120 | }
|
| 11121 | hooks.unqueued++;
|
| 11122 |
|
| 11123 | anim.always(function() {
|
| 11124 | // doing this makes sure that the complete handler will be called
|
| 11125 | // before this completes
|
| 11126 | anim.always(function() {
|
| 11127 | hooks.unqueued--;
|
| 11128 | if ( !jQuery.queue( elem, "fx" ).length ) {
|
| 11129 | hooks.empty.fire();
|
| 11130 | }
|
| 11131 | });
|
| 11132 | });
|
| 11133 | }
|
| 11134 |
|
| 11135 | // height/width overflow pass
|
| 11136 | if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
|
| 11137 | // Make sure that nothing sneaks out
|
| 11138 | // Record all 3 overflow attributes because IE does not
|
| 11139 | // change the overflow attribute when overflowX and
|
| 11140 | // overflowY are set to the same value
|
| 11141 | opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
|
| 11142 |
|
| 11143 | // Set display property to inline-block for height/width
|
| 11144 | // animations on inline elements that are having width/height animated
|
| 11145 | if ( jQuery.css( elem, "display" ) === "inline" &&
|
| 11146 | jQuery.css( elem, "float" ) === "none" ) {
|
| 11147 |
|
| 11148 | // inline-level elements accept inline-block;
|
| 11149 | // block-level elements need to be inline with layout
|
| 11150 | if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
|
| 11151 | style.display = "inline-block";
|
| 11152 |
|
| 11153 | } else {
|
| 11154 | style.zoom = 1;
|
| 11155 | }
|
| 11156 | }
|
| 11157 | }
|
| 11158 |
|
| 11159 | if ( opts.overflow ) {
|
| 11160 | style.overflow = "hidden";
|
| 11161 | if ( !jQuery.support.shrinkWrapBlocks ) {
|
| 11162 | anim.always(function() {
|
| 11163 | style.overflow = opts.overflow[ 0 ];
|
| 11164 | style.overflowX = opts.overflow[ 1 ];
|
| 11165 | style.overflowY = opts.overflow[ 2 ];
|
| 11166 | });
|
| 11167 | }
|
| 11168 | }
|
| 11169 |
|
| 11170 |
|
| 11171 | // show/hide pass
|
| 11172 | for ( prop in props ) {
|
| 11173 | value = props[ prop ];
|
| 11174 | if ( rfxtypes.exec( value ) ) {
|
| 11175 | delete props[ prop ];
|
| 11176 | toggle = toggle || value === "toggle";
|
| 11177 | if ( value === ( hidden ? "hide" : "show" ) ) {
|
| 11178 | continue;
|
| 11179 | }
|
| 11180 | orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
|
| 11181 | }
|
| 11182 | }
|
| 11183 |
|
| 11184 | if ( !jQuery.isEmptyObject( orig ) ) {
|
| 11185 | if ( dataShow ) {
|
| 11186 | if ( "hidden" in dataShow ) {
|
| 11187 | hidden = dataShow.hidden;
|
| 11188 | }
|
| 11189 | } else {
|
| 11190 | dataShow = jQuery._data( elem, "fxshow", {} );
|
| 11191 | }
|
| 11192 |
|
| 11193 | // store state if its toggle - enables .stop().toggle() to "reverse"
|
| 11194 | if ( toggle ) {
|
| 11195 | dataShow.hidden = !hidden;
|
| 11196 | }
|
| 11197 | if ( hidden ) {
|
| 11198 | jQuery( elem ).show();
|
| 11199 | } else {
|
| 11200 | anim.done(function() {
|
| 11201 | jQuery( elem ).hide();
|
| 11202 | });
|
| 11203 | }
|
| 11204 | anim.done(function() {
|
| 11205 | var prop;
|
| 11206 | jQuery._removeData( elem, "fxshow" );
|
| 11207 | for ( prop in orig ) {
|
| 11208 | jQuery.style( elem, prop, orig[ prop ] );
|
| 11209 | }
|
| 11210 | });
|
| 11211 | for ( prop in orig ) {
|
| 11212 | tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
|
| 11213 |
|
| 11214 | if ( !( prop in dataShow ) ) {
|
| 11215 | dataShow[ prop ] = tween.start;
|
| 11216 | if ( hidden ) {
|
| 11217 | tween.end = tween.start;
|
| 11218 | tween.start = prop === "width" || prop === "height" ? 1 : 0;
|
| 11219 | }
|
| 11220 | }
|
| 11221 | }
|
| 11222 | }
|
| 11223 | }
|
| 11224 |
|
| 11225 | function Tween( elem, options, prop, end, easing ) {
|
| 11226 | return new Tween.prototype.init( elem, options, prop, end, easing );
|
| 11227 | }
|
| 11228 | jQuery.Tween = Tween;
|
| 11229 |
|
| 11230 | Tween.prototype = {
|
| 11231 | constructor: Tween,
|
| 11232 | init: function( elem, options, prop, end, easing, unit ) {
|
| 11233 | this.elem = elem;
|
| 11234 | this.prop = prop;
|
| 11235 | this.easing = easing || "swing";
|
| 11236 | this.options = options;
|
| 11237 | this.start = this.now = this.cur();
|
| 11238 | this.end = end;
|
| 11239 | this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
|
| 11240 | },
|
| 11241 | cur: function() {
|
| 11242 | var hooks = Tween.propHooks[ this.prop ];
|
| 11243 |
|
| 11244 | return hooks && hooks.get ?
|
| 11245 | hooks.get( this ) :
|
| 11246 | Tween.propHooks._default.get( this );
|
| 11247 | },
|
| 11248 | run: function( percent ) {
|
| 11249 | var eased,
|
| 11250 | hooks = Tween.propHooks[ this.prop ];
|
| 11251 |
|
| 11252 | if ( this.options.duration ) {
|
| 11253 | this.pos = eased = jQuery.easing[ this.easing ](
|
| 11254 | percent, this.options.duration * percent, 0, 1, this.options.duration
|
| 11255 | );
|
| 11256 | } else {
|
| 11257 | this.pos = eased = percent;
|
| 11258 | }
|
| 11259 | this.now = ( this.end - this.start ) * eased + this.start;
|
| 11260 |
|
| 11261 | if ( this.options.step ) {
|
| 11262 | this.options.step.call( this.elem, this.now, this );
|
| 11263 | }
|
| 11264 |
|
| 11265 | if ( hooks && hooks.set ) {
|
| 11266 | hooks.set( this );
|
| 11267 | } else {
|
| 11268 | Tween.propHooks._default.set( this );
|
| 11269 | }
|
| 11270 | return this;
|
| 11271 | }
|
| 11272 | };
|
| 11273 |
|
| 11274 | Tween.prototype.init.prototype = Tween.prototype;
|
| 11275 |
|
| 11276 | Tween.propHooks = {
|
| 11277 | _default: {
|
| 11278 | get: function( tween ) {
|
| 11279 | var result;
|
| 11280 |
|
| 11281 | if ( tween.elem[ tween.prop ] != null &&
|
| 11282 | (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
|
| 11283 | return tween.elem[ tween.prop ];
|
| 11284 | }
|
| 11285 |
|
| 11286 | // passing an empty string as a 3rd parameter to .css will automatically
|
| 11287 | // attempt a parseFloat and fallback to a string if the parse fails
|
| 11288 | // so, simple values such as "10px" are parsed to Float.
|
| 11289 | // complex values such as "rotate(1rad)" are returned as is.
|
| 11290 | result = jQuery.css( tween.elem, tween.prop, "" );
|
| 11291 | // Empty strings, null, undefined and "auto" are converted to 0.
|
| 11292 | return !result || result === "auto" ? 0 : result;
|
| 11293 | },
|
| 11294 | set: function( tween ) {
|
| 11295 | // use step hook for back compat - use cssHook if its there - use .style if its
|
| 11296 | // available and use plain properties where available
|
| 11297 | if ( jQuery.fx.step[ tween.prop ] ) {
|
| 11298 | jQuery.fx.step[ tween.prop ]( tween );
|
| 11299 | } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
|
| 11300 | jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
| 11301 | } else {
|
| 11302 | tween.elem[ tween.prop ] = tween.now;
|
| 11303 | }
|
| 11304 | }
|
| 11305 | }
|
| 11306 | };
|
| 11307 |
|
| 11308 | // Support: IE <=9
|
| 11309 | // Panic based approach to setting things on disconnected nodes
|
| 11310 |
|
| 11311 | Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
|
| 11312 | set: function( tween ) {
|
| 11313 | if ( tween.elem.nodeType && tween.elem.parentNode ) {
|
| 11314 | tween.elem[ tween.prop ] = tween.now;
|
| 11315 | }
|
| 11316 | }
|
| 11317 | };
|
| 11318 |
|
| 11319 | jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
|
| 11320 | var cssFn = jQuery.fn[ name ];
|
| 11321 | jQuery.fn[ name ] = function( speed, easing, callback ) {
|
| 11322 | return speed == null || typeof speed === "boolean" ?
|
| 11323 | cssFn.apply( this, arguments ) :
|
| 11324 | this.animate( genFx( name, true ), speed, easing, callback );
|
| 11325 | };
|
| 11326 | });
|
| 11327 |
|
| 11328 | jQuery.fn.extend({
|
| 11329 | fadeTo: function( speed, to, easing, callback ) {
|
| 11330 |
|
| 11331 | // show any hidden elements after setting opacity to 0
|
| 11332 | return this.filter( isHidden ).css( "opacity", 0 ).show()
|
| 11333 |
|
| 11334 | // animate to the value specified
|
| 11335 | .end().animate({ opacity: to }, speed, easing, callback );
|
| 11336 | },
|
| 11337 | animate: function( prop, speed, easing, callback ) {
|
| 11338 | var empty = jQuery.isEmptyObject( prop ),
|
| 11339 | optall = jQuery.speed( speed, easing, callback ),
|
| 11340 | doAnimation = function() {
|
| 11341 | // Operate on a copy of prop so per-property easing won't be lost
|
| 11342 | var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
| 11343 |
|
| 11344 | // Empty animations, or finishing resolves immediately
|
| 11345 | if ( empty || jQuery._data( this, "finish" ) ) {
|
| 11346 | anim.stop( true );
|
| 11347 | }
|
| 11348 | };
|
| 11349 | doAnimation.finish = doAnimation;
|
| 11350 |
|
| 11351 | return empty || optall.queue === false ?
|
| 11352 | this.each( doAnimation ) :
|
| 11353 | this.queue( optall.queue, doAnimation );
|
| 11354 | },
|
| 11355 | stop: function( type, clearQueue, gotoEnd ) {
|
| 11356 | var stopQueue = function( hooks ) {
|
| 11357 | var stop = hooks.stop;
|
| 11358 | delete hooks.stop;
|
| 11359 | stop( gotoEnd );
|
| 11360 | };
|
| 11361 |
|
| 11362 | if ( typeof type !== "string" ) {
|
| 11363 | gotoEnd = clearQueue;
|
| 11364 | clearQueue = type;
|
| 11365 | type = undefined;
|
| 11366 | }
|
| 11367 | if ( clearQueue && type !== false ) {
|
| 11368 | this.queue( type || "fx", [] );
|
| 11369 | }
|
| 11370 |
|
| 11371 | return this.each(function() {
|
| 11372 | var dequeue = true,
|
| 11373 | index = type != null && type + "queueHooks",
|
| 11374 | timers = jQuery.timers,
|
| 11375 | data = jQuery._data( this );
|
| 11376 |
|
| 11377 | if ( index ) {
|
| 11378 | if ( data[ index ] && data[ index ].stop ) {
|
| 11379 | stopQueue( data[ index ] );
|
| 11380 | }
|
| 11381 | } else {
|
| 11382 | for ( index in data ) {
|
| 11383 | if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
|
| 11384 | stopQueue( data[ index ] );
|
| 11385 | }
|
| 11386 | }
|
| 11387 | }
|
| 11388 |
|
| 11389 | for ( index = timers.length; index--; ) {
|
| 11390 | if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
|
| 11391 | timers[ index ].anim.stop( gotoEnd );
|
| 11392 | dequeue = false;
|
| 11393 | timers.splice( index, 1 );
|
| 11394 | }
|
| 11395 | }
|
| 11396 |
|
| 11397 | // start the next in the queue if the last step wasn't forced
|
| 11398 | // timers currently will call their complete callbacks, which will dequeue
|
| 11399 | // but only if they were gotoEnd
|
| 11400 | if ( dequeue || !gotoEnd ) {
|
| 11401 | jQuery.dequeue( this, type );
|
| 11402 | }
|
| 11403 | });
|
| 11404 | },
|
| 11405 | finish: function( type ) {
|
| 11406 | if ( type !== false ) {
|
| 11407 | type = type || "fx";
|
| 11408 | }
|
| 11409 | return this.each(function() {
|
| 11410 | var index,
|
| 11411 | data = jQuery._data( this ),
|
| 11412 | queue = data[ type + "queue" ],
|
| 11413 | hooks = data[ type + "queueHooks" ],
|
| 11414 | timers = jQuery.timers,
|
| 11415 | length = queue ? queue.length : 0;
|
| 11416 |
|
| 11417 | // enable finishing flag on private data
|
| 11418 | data.finish = true;
|
| 11419 |
|
| 11420 | // empty the queue first
|
| 11421 | jQuery.queue( this, type, [] );
|
| 11422 |
|
| 11423 | if ( hooks && hooks.stop ) {
|
| 11424 | hooks.stop.call( this, true );
|
| 11425 | }
|
| 11426 |
|
| 11427 | // look for any active animations, and finish them
|
| 11428 | for ( index = timers.length; index--; ) {
|
| 11429 | if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
|
| 11430 | timers[ index ].anim.stop( true );
|
| 11431 | timers.splice( index, 1 );
|
| 11432 | }
|
| 11433 | }
|
| 11434 |
|
| 11435 | // look for any animations in the old queue and finish them
|
| 11436 | for ( index = 0; index < length; index++ ) {
|
| 11437 | if ( queue[ index ] && queue[ index ].finish ) {
|
| 11438 | queue[ index ].finish.call( this );
|
| 11439 | }
|
| 11440 | }
|
| 11441 |
|
| 11442 | // turn off finishing flag
|
| 11443 | delete data.finish;
|
| 11444 | });
|
| 11445 | }
|
| 11446 | });
|
| 11447 |
|
| 11448 | // Generate parameters to create a standard animation
|
| 11449 | function genFx( type, includeWidth ) {
|
| 11450 | var which,
|
| 11451 | attrs = { height: type },
|
| 11452 | i = 0;
|
| 11453 |
|
| 11454 | // if we include width, step value is 1 to do all cssExpand values,
|
| 11455 | // if we don't include width, step value is 2 to skip over Left and Right
|
| 11456 | includeWidth = includeWidth? 1 : 0;
|
| 11457 | for( ; i < 4 ; i += 2 - includeWidth ) {
|
| 11458 | which = cssExpand[ i ];
|
| 11459 | attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
|
| 11460 | }
|
| 11461 |
|
| 11462 | if ( includeWidth ) {
|
| 11463 | attrs.opacity = attrs.width = type;
|
| 11464 | }
|
| 11465 |
|
| 11466 | return attrs;
|
| 11467 | }
|
| 11468 |
|
| 11469 | // Generate shortcuts for custom animations
|
| 11470 | jQuery.each({
|
| 11471 | slideDown: genFx("show"),
|
| 11472 | slideUp: genFx("hide"),
|
| 11473 | slideToggle: genFx("toggle"),
|
| 11474 | fadeIn: { opacity: "show" },
|
| 11475 | fadeOut: { opacity: "hide" },
|
| 11476 | fadeToggle: { opacity: "toggle" }
|
| 11477 | }, function( name, props ) {
|
| 11478 | jQuery.fn[ name ] = function( speed, easing, callback ) {
|
| 11479 | return this.animate( props, speed, easing, callback );
|
| 11480 | };
|
| 11481 | });
|
| 11482 |
|
| 11483 | jQuery.speed = function( speed, easing, fn ) {
|
| 11484 | var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
| 11485 | complete: fn || !fn && easing ||
|
| 11486 | jQuery.isFunction( speed ) && speed,
|
| 11487 | duration: speed,
|
| 11488 | easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
|
| 11489 | };
|
| 11490 |
|
| 11491 | opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
| 11492 | opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
|
| 11493 |
|
| 11494 | // normalize opt.queue - true/undefined/null -> "fx"
|
| 11495 | if ( opt.queue == null || opt.queue === true ) {
|
| 11496 | opt.queue = "fx";
|
| 11497 | }
|
| 11498 |
|
| 11499 | // Queueing
|
| 11500 | opt.old = opt.complete;
|
| 11501 |
|
| 11502 | opt.complete = function() {
|
| 11503 | if ( jQuery.isFunction( opt.old ) ) {
|
| 11504 | opt.old.call( this );
|
| 11505 | }
|
| 11506 |
|
| 11507 | if ( opt.queue ) {
|
| 11508 | jQuery.dequeue( this, opt.queue );
|
| 11509 | }
|
| 11510 | };
|
| 11511 |
|
| 11512 | return opt;
|
| 11513 | };
|
| 11514 |
|
| 11515 | jQuery.easing = {
|
| 11516 | linear: function( p ) {
|
| 11517 | return p;
|
| 11518 | },
|
| 11519 | swing: function( p ) {
|
| 11520 | return 0.5 - Math.cos( p*Math.PI ) / 2;
|
| 11521 | }
|
| 11522 | };
|
| 11523 |
|
| 11524 | jQuery.timers = [];
|
| 11525 | jQuery.fx = Tween.prototype.init;
|
| 11526 | jQuery.fx.tick = function() {
|
| 11527 | var timer,
|
| 11528 | timers = jQuery.timers,
|
| 11529 | i = 0;
|
| 11530 |
|
| 11531 | fxNow = jQuery.now();
|
| 11532 |
|
| 11533 | for ( ; i < timers.length; i++ ) {
|
| 11534 | timer = timers[ i ];
|
| 11535 | // Checks the timer has not already been removed
|
| 11536 | if ( !timer() && timers[ i ] === timer ) {
|
| 11537 | timers.splice( i--, 1 );
|
| 11538 | }
|
| 11539 | }
|
| 11540 |
|
| 11541 | if ( !timers.length ) {
|
| 11542 | jQuery.fx.stop();
|
| 11543 | }
|
| 11544 | fxNow = undefined;
|
| 11545 | };
|
| 11546 |
|
| 11547 | jQuery.fx.timer = function( timer ) {
|
| 11548 | if ( timer() && jQuery.timers.push( timer ) ) {
|
| 11549 | jQuery.fx.start();
|
| 11550 | }
|
| 11551 | };
|
| 11552 |
|
| 11553 | jQuery.fx.interval = 13;
|
| 11554 |
|
| 11555 | jQuery.fx.start = function() {
|
| 11556 | if ( !timerId ) {
|
| 11557 | timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
| 11558 | }
|
| 11559 | };
|
| 11560 |
|
| 11561 | jQuery.fx.stop = function() {
|
| 11562 | clearInterval( timerId );
|
| 11563 | timerId = null;
|
| 11564 | };
|
| 11565 |
|
| 11566 | jQuery.fx.speeds = {
|
| 11567 | slow: 600,
|
| 11568 | fast: 200,
|
| 11569 | // Default speed
|
| 11570 | _default: 400
|
| 11571 | };
|
| 11572 |
|
| 11573 | // Back Compat <1.8 extension point
|
| 11574 | jQuery.fx.step = {};
|
| 11575 |
|
| 11576 | if ( jQuery.expr && jQuery.expr.filters ) {
|
| 11577 | jQuery.expr.filters.animated = function( elem ) {
|
| 11578 | return jQuery.grep(jQuery.timers, function( fn ) {
|
| 11579 | return elem === fn.elem;
|
| 11580 | }).length;
|
| 11581 | };
|
| 11582 | }
|
| 11583 | jQuery.fn.offset = function( options ) {
|
| 11584 | if ( arguments.length ) {
|
| 11585 | return options === undefined ?
|
| 11586 | this :
|
| 11587 | this.each(function( i ) {
|
| 11588 | jQuery.offset.setOffset( this, options, i );
|
| 11589 | });
|
| 11590 | }
|
| 11591 |
|
| 11592 | var docElem, win,
|
| 11593 | box = { top: 0, left: 0 },
|
| 11594 | elem = this[ 0 ],
|
| 11595 | doc = elem && elem.ownerDocument;
|
| 11596 |
|
| 11597 | if ( !doc ) {
|
| 11598 | return;
|
| 11599 | }
|
| 11600 |
|
| 11601 | docElem = doc.documentElement;
|
| 11602 |
|
| 11603 | // Make sure it's not a disconnected DOM node
|
| 11604 | if ( !jQuery.contains( docElem, elem ) ) {
|
| 11605 | return box;
|
| 11606 | }
|
| 11607 |
|
| 11608 | // If we don't have gBCR, just use 0,0 rather than error
|
| 11609 | // BlackBerry 5, iOS 3 (original iPhone)
|
| 11610 | if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
|
| 11611 | box = elem.getBoundingClientRect();
|
| 11612 | }
|
| 11613 | win = getWindow( doc );
|
| 11614 | return {
|
| 11615 | top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
|
| 11616 | left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
|
| 11617 | };
|
| 11618 | };
|
| 11619 |
|
| 11620 | jQuery.offset = {
|
| 11621 |
|
| 11622 | setOffset: function( elem, options, i ) {
|
| 11623 | var position = jQuery.css( elem, "position" );
|
| 11624 |
|
| 11625 | // set position first, in-case top/left are set even on static elem
|
| 11626 | if ( position === "static" ) {
|
| 11627 | elem.style.position = "relative";
|
| 11628 | }
|
| 11629 |
|
| 11630 | var curElem = jQuery( elem ),
|
| 11631 | curOffset = curElem.offset(),
|
| 11632 | curCSSTop = jQuery.css( elem, "top" ),
|
| 11633 | curCSSLeft = jQuery.css( elem, "left" ),
|
| 11634 | calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
|
| 11635 | props = {}, curPosition = {}, curTop, curLeft;
|
| 11636 |
|
| 11637 | // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
|
| 11638 | if ( calculatePosition ) {
|
| 11639 | curPosition = curElem.position();
|
| 11640 | curTop = curPosition.top;
|
| 11641 | curLeft = curPosition.left;
|
| 11642 | } else {
|
| 11643 | curTop = parseFloat( curCSSTop ) || 0;
|
| 11644 | curLeft = parseFloat( curCSSLeft ) || 0;
|
| 11645 | }
|
| 11646 |
|
| 11647 | if ( jQuery.isFunction( options ) ) {
|
| 11648 | options = options.call( elem, i, curOffset );
|
| 11649 | }
|
| 11650 |
|
| 11651 | if ( options.top != null ) {
|
| 11652 | props.top = ( options.top - curOffset.top ) + curTop;
|
| 11653 | }
|
| 11654 | if ( options.left != null ) {
|
| 11655 | props.left = ( options.left - curOffset.left ) + curLeft;
|
| 11656 | }
|
| 11657 |
|
| 11658 | if ( "using" in options ) {
|
| 11659 | options.using.call( elem, props );
|
| 11660 | } else {
|
| 11661 | curElem.css( props );
|
| 11662 | }
|
| 11663 | }
|
| 11664 | };
|
| 11665 |
|
| 11666 |
|
| 11667 | jQuery.fn.extend({
|
| 11668 |
|
| 11669 | position: function() {
|
| 11670 | if ( !this[ 0 ] ) {
|
| 11671 | return;
|
| 11672 | }
|
| 11673 |
|
| 11674 | var offsetParent, offset,
|
| 11675 | parentOffset = { top: 0, left: 0 },
|
| 11676 | elem = this[ 0 ];
|
| 11677 |
|
| 11678 | // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
|
| 11679 | if ( jQuery.css( elem, "position" ) === "fixed" ) {
|
| 11680 | // we assume that getBoundingClientRect is available when computed position is fixed
|
| 11681 | offset = elem.getBoundingClientRect();
|
| 11682 | } else {
|
| 11683 | // Get *real* offsetParent
|
| 11684 | offsetParent = this.offsetParent();
|
| 11685 |
|
| 11686 | // Get correct offsets
|
| 11687 | offset = this.offset();
|
| 11688 | if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
|
| 11689 | parentOffset = offsetParent.offset();
|
| 11690 | }
|
| 11691 |
|
| 11692 | // Add offsetParent borders
|
| 11693 | parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
|
| 11694 | parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
|
| 11695 | }
|
| 11696 |
|
| 11697 | // Subtract parent offsets and element margins
|
| 11698 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
| 11699 | // are the same in Safari causing offset.left to incorrectly be 0
|
| 11700 | return {
|
| 11701 | top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
|
| 11702 | left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
|
| 11703 | };
|
| 11704 | },
|
| 11705 |
|
| 11706 | offsetParent: function() {
|
| 11707 | return this.map(function() {
|
| 11708 | var offsetParent = this.offsetParent || docElem;
|
| 11709 | while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
|
| 11710 | offsetParent = offsetParent.offsetParent;
|
| 11711 | }
|
| 11712 | return offsetParent || docElem;
|
| 11713 | });
|
| 11714 | }
|
| 11715 | });
|
| 11716 |
|
| 11717 |
|
| 11718 | // Create scrollLeft and scrollTop methods
|
| 11719 | jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
|
| 11720 | var top = /Y/.test( prop );
|
| 11721 |
|
| 11722 | jQuery.fn[ method ] = function( val ) {
|
| 11723 | return jQuery.access( this, function( elem, method, val ) {
|
| 11724 | var win = getWindow( elem );
|
| 11725 |
|
| 11726 | if ( val === undefined ) {
|
| 11727 | return win ? (prop in win) ? win[ prop ] :
|
| 11728 | win.document.documentElement[ method ] :
|
| 11729 | elem[ method ];
|
| 11730 | }
|
| 11731 |
|
| 11732 | if ( win ) {
|
| 11733 | win.scrollTo(
|
| 11734 | !top ? val : jQuery( win ).scrollLeft(),
|
| 11735 | top ? val : jQuery( win ).scrollTop()
|
| 11736 | );
|
| 11737 |
|
| 11738 | } else {
|
| 11739 | elem[ method ] = val;
|
| 11740 | }
|
| 11741 | }, method, val, arguments.length, null );
|
| 11742 | };
|
| 11743 | });
|
| 11744 |
|
| 11745 | function getWindow( elem ) {
|
| 11746 | return jQuery.isWindow( elem ) ?
|
| 11747 | elem :
|
| 11748 | elem.nodeType === 9 ?
|
| 11749 | elem.defaultView || elem.parentWindow :
|
| 11750 | false;
|
| 11751 | }
|
| 11752 | // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
| 11753 | jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
| 11754 | jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
|
| 11755 | // margin is only for outerHeight, outerWidth
|
| 11756 | jQuery.fn[ funcName ] = function( margin, value ) {
|
| 11757 | var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
| 11758 | extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
|
| 11759 |
|
| 11760 | return jQuery.access( this, function( elem, type, value ) {
|
| 11761 | var doc;
|
| 11762 |
|
| 11763 | if ( jQuery.isWindow( elem ) ) {
|
| 11764 | // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
|
| 11765 | // isn't a whole lot we can do. See pull request at this URL for discussion:
|
| 11766 | // https://github.com/jquery/jquery/pull/764
|
| 11767 | return elem.document.documentElement[ "client" + name ];
|
| 11768 | }
|
| 11769 |
|
| 11770 | // Get document width or height
|
| 11771 | if ( elem.nodeType === 9 ) {
|
| 11772 | doc = elem.documentElement;
|
| 11773 |
|
| 11774 | // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
|
| 11775 | // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
|
| 11776 | return Math.max(
|
| 11777 | elem.body[ "scroll" + name ], doc[ "scroll" + name ],
|
| 11778 | elem.body[ "offset" + name ], doc[ "offset" + name ],
|
| 11779 | doc[ "client" + name ]
|
| 11780 | );
|
| 11781 | }
|
| 11782 |
|
| 11783 | return value === undefined ?
|
| 11784 | // Get width or height on the element, requesting but not forcing parseFloat
|
| 11785 | jQuery.css( elem, type, extra ) :
|
| 11786 |
|
| 11787 | // Set width or height on the element
|
| 11788 | jQuery.style( elem, type, value, extra );
|
| 11789 | }, type, chainable ? margin : undefined, chainable, null );
|
| 11790 | };
|
| 11791 | });
|
| 11792 | });
|
| 11793 | // Limit scope pollution from any deprecated API
|
| 11794 | // (function() {
|
| 11795 |
|
| 11796 | // The number of elements contained in the matched element set
|
| 11797 | jQuery.fn.size = function() {
|
| 11798 | return this.length;
|
| 11799 | };
|
| 11800 |
|
| 11801 | jQuery.fn.andSelf = jQuery.fn.addBack;
|
| 11802 |
|
| 11803 | // })();
|
| 11804 | if ( typeof module === "object" && module && typeof module.exports === "object" ) {
|
| 11805 | // Expose jQuery as module.exports in loaders that implement the Node
|
| 11806 | // module pattern (including browserify). Do not create the global, since
|
| 11807 | // the user will be storing it themselves locally, and globals are frowned
|
| 11808 | // upon in the Node module world.
|
| 11809 | module.exports = jQuery;
|
| 11810 | } else {
|
| 11811 | // Otherwise expose jQuery to the global object as usual
|
| 11812 | window.jQuery = window.$ = jQuery;
|
| 11813 |
|
| 11814 | // Register as a named AMD module, since jQuery can be concatenated with other
|
| 11815 | // files that may use define, but not via a proper concatenation script that
|
| 11816 | // understands anonymous AMD modules. A named AMD is safest and most robust
|
| 11817 | // way to register. Lowercase jquery is used because AMD module names are
|
| 11818 | // derived from file names, and jQuery is normally delivered in a lowercase
|
| 11819 | // file name. Do this after creating the global so that if an AMD module wants
|
| 11820 | // to call noConflict to hide this version of jQuery, it will work.
|
| 11821 | if ( typeof define === "function" && define.amd ) {
|
| 11822 | define( "jquery", [], function () { return jQuery; } );
|
| 11823 | }
|
| 11824 | }
|
| 11825 |
|
| 11826 | })( window );
|
| 11827 | /*
|
| 11828 | * jQuery Migrate
|
| 11829 | * Copyright jQuery Foundation and other contributors
|
| 11830 | */
|
| 11831 | (function( jQuery, window, undefined ) {
|
| 11832 | // See http://bugs.jquery.com/ticket/13335
|
| 11833 | // "use strict";
|
| 11834 |
|
| 11835 |
|
| 11836 | jQuery.migrateVersion = "0.0.0";
|
| 11837 |
|
| 11838 |
|
| 11839 | var warnedAbout = {};
|
| 11840 |
|
| 11841 | // List of warnings already given; public read only
|
| 11842 | jQuery.migrateWarnings = [];
|
| 11843 |
|
| 11844 | // Set to true to prevent console output; migrateWarnings still maintained
|
| 11845 | jQuery.migrateMute = true;
|
| 11846 |
|
| 11847 | // Show a message on the console so devs know we're active
|
| 11848 | if ( window.console && window.console.log && !jQuery.migrateMute ) {
|
| 11849 | window.console.log( "JQMIGRATE: Migrate is installed" +
|
| 11850 | ( jQuery.migrateMute ? "" : " with logging active" ) +
|
| 11851 | ", version " + jQuery.migrateVersion );
|
| 11852 | }
|
| 11853 |
|
| 11854 | // Set to false to disable traces that appear with warnings
|
| 11855 | if ( jQuery.migrateTrace === undefined ) {
|
| 11856 | jQuery.migrateTrace = false;
|
| 11857 | }
|
| 11858 |
|
| 11859 | // Forget any warnings we've already given; public
|
| 11860 | jQuery.migrateReset = function() {
|
| 11861 | warnedAbout = {};
|
| 11862 | jQuery.migrateWarnings.length = 0;
|
| 11863 | };
|
| 11864 |
|
| 11865 | function migrateWarn( msg) {
|
| 11866 | var console = window.console;
|
| 11867 | if ( !warnedAbout[ msg ] ) {
|
| 11868 | warnedAbout[ msg ] = true;
|
| 11869 | jQuery.migrateWarnings.push( msg );
|
| 11870 | if ( console && console.warn && !jQuery.migrateMute ) {
|
| 11871 | console.warn( "JQMIGRATE: " + msg );
|
| 11872 | if ( jQuery.migrateTrace && console.trace ) {
|
| 11873 | console.trace();
|
| 11874 | }
|
| 11875 | }
|
| 11876 | }
|
| 11877 | }
|
| 11878 |
|
| 11879 | function migrateWarnProp( obj, prop, value, msg ) {
|
| 11880 | if ( Object.defineProperty ) {
|
| 11881 | // On ES5 browsers (non-oldIE), warn if the code tries to get prop;
|
| 11882 | // allow property to be overwritten in case some other plugin wants it
|
| 11883 | try {
|
| 11884 | Object.defineProperty( obj, prop, {
|
| 11885 | configurable: true,
|
| 11886 | enumerable: true,
|
| 11887 | get: function() {
|
| 11888 | migrateWarn( msg );
|
| 11889 | return value;
|
| 11890 | },
|
| 11891 | set: function( newValue ) {
|
| 11892 | migrateWarn( msg );
|
| 11893 | value = newValue;
|
| 11894 | }
|
| 11895 | });
|
| 11896 | return;
|
| 11897 | } catch( err ) {
|
| 11898 | // IE8 is a dope about Object.defineProperty, can't warn there
|
| 11899 | }
|
| 11900 | }
|
| 11901 |
|
| 11902 | // Non-ES5 (or broken) browser; just set the property
|
| 11903 | jQuery._definePropertyBroken = true;
|
| 11904 | obj[ prop ] = value;
|
| 11905 | }
|
| 11906 |
|
| 11907 | if ( document.compatMode === "BackCompat" ) {
|
| 11908 | // jQuery has never supported or tested Quirks Mode
|
| 11909 | migrateWarn( "jQuery is not compatible with Quirks Mode" );
|
| 11910 | }
|
| 11911 |
|
| 11912 |
|
| 11913 | var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
|
| 11914 | oldAttr = jQuery.attr,
|
| 11915 | valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
|
| 11916 | function() { return null; },
|
| 11917 | valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
|
| 11918 | function() { return undefined; },
|
| 11919 | rnoType = /^(?:input|button)$/i,
|
| 11920 | rnoAttrNodeType = /^[238]$/,
|
| 11921 | rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
|
| 11922 | ruseDefault = /^(?:checked|selected)$/i;
|
| 11923 |
|
| 11924 | // jQuery.attrFn
|
| 11925 | migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
|
| 11926 |
|
| 11927 | jQuery.attr = function( elem, name, value, pass ) {
|
| 11928 | var lowerName = name.toLowerCase(),
|
| 11929 | nType = elem && elem.nodeType;
|
| 11930 |
|
| 11931 | if ( pass ) {
|
| 11932 | // Since pass is used internally, we only warn for new jQuery
|
| 11933 | // versions where there isn't a pass arg in the formal params
|
| 11934 | if ( oldAttr.length < 4 ) {
|
| 11935 | migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
|
| 11936 | }
|
| 11937 | if ( elem && !rnoAttrNodeType.test( nType ) &&
|
| 11938 | (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
|
| 11939 | return jQuery( elem )[ name ]( value );
|
| 11940 | }
|
| 11941 | }
|
| 11942 |
|
| 11943 | // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
|
| 11944 | // for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
|
| 11945 | if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
|
| 11946 | migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
|
| 11947 | }
|
| 11948 |
|
| 11949 | // Restore boolHook for boolean property/attribute synchronization
|
| 11950 | if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
|
| 11951 | jQuery.attrHooks[ lowerName ] = {
|
| 11952 | get: function( elem, name ) {
|
| 11953 | // Align boolean attributes with corresponding properties
|
| 11954 | // Fall back to attribute presence where some booleans are not supported
|
| 11955 | var attrNode,
|
| 11956 | property = jQuery.prop( elem, name );
|
| 11957 | return property === true || typeof property !== "boolean" &&
|
| 11958 | ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
|
| 11959 |
|
| 11960 | name.toLowerCase() :
|
| 11961 | undefined;
|
| 11962 | },
|
| 11963 | set: function( elem, value, name ) {
|
| 11964 | var propName;
|
| 11965 | if ( value === false ) {
|
| 11966 | // Remove boolean attributes when set to false
|
| 11967 | jQuery.removeAttr( elem, name );
|
| 11968 | } else {
|
| 11969 | // value is true since we know at this point it's type boolean and not false
|
| 11970 | // Set boolean attributes to the same name and set the DOM property
|
| 11971 | propName = jQuery.propFix[ name ] || name;
|
| 11972 | if ( propName in elem ) {
|
| 11973 | // Only set the IDL specifically if it already exists on the element
|
| 11974 | elem[ propName ] = true;
|
| 11975 | }
|
| 11976 |
|
| 11977 | elem.setAttribute( name, name.toLowerCase() );
|
| 11978 | }
|
| 11979 | return name;
|
| 11980 | }
|
| 11981 | };
|
| 11982 |
|
| 11983 | // Warn only for attributes that can remain distinct from their properties post-1.9
|
| 11984 | if ( ruseDefault.test( lowerName ) ) {
|
| 11985 | migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" );
|
| 11986 | }
|
| 11987 | }
|
| 11988 |
|
| 11989 | return oldAttr.call( jQuery, elem, name, value );
|
| 11990 | };
|
| 11991 |
|
| 11992 | // attrHooks: value
|
| 11993 | jQuery.attrHooks.value = {
|
| 11994 | get: function( elem, name ) {
|
| 11995 | var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
| 11996 | if ( nodeName === "button" ) {
|
| 11997 | return valueAttrGet.apply( this, arguments );
|
| 11998 | }
|
| 11999 | if ( nodeName !== "input" && nodeName !== "option" ) {
|
| 12000 | migrateWarn("jQuery.fn.attr('value') no longer gets properties");
|
| 12001 | }
|
| 12002 | return name in elem ?
|
| 12003 | elem.value :
|
| 12004 | null;
|
| 12005 | },
|
| 12006 | set: function( elem, value ) {
|
| 12007 | var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
| 12008 | if ( nodeName === "button" ) {
|
| 12009 | return valueAttrSet.apply( this, arguments );
|
| 12010 | }
|
| 12011 | if ( nodeName !== "input" && nodeName !== "option" ) {
|
| 12012 | migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
|
| 12013 | }
|
| 12014 | // Does not return so that setAttribute is also used
|
| 12015 | elem.value = value;
|
| 12016 | }
|
| 12017 | };
|
| 12018 |
|
| 12019 |
|
| 12020 | var matched, browser,
|
| 12021 | oldInit = jQuery.fn.init,
|
| 12022 | oldFind = jQuery.find,
|
| 12023 | oldParseJSON = jQuery.parseJSON,
|
| 12024 | rspaceAngle = /^\s*</,
|
| 12025 | rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
|
| 12026 | rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
|
| 12027 | // Note: XSS check is done below after string is trimmed
|
| 12028 | rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
|
| 12029 |
|
| 12030 | // $(html) "looks like html" rule change
|
| 12031 | jQuery.fn.init = function( selector, context, rootjQuery ) {
|
| 12032 | var match, ret;
|
| 12033 |
|
| 12034 | if ( selector && typeof selector === "string" ) {
|
| 12035 | if ( !jQuery.isPlainObject( context ) &&
|
| 12036 | (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
|
| 12037 |
|
| 12038 | // This is an HTML string according to the "old" rules; is it still?
|
| 12039 | if ( !rspaceAngle.test( selector ) ) {
|
| 12040 | migrateWarn("$(html) HTML strings must start with '<' character");
|
| 12041 | }
|
| 12042 | if ( match[ 3 ] ) {
|
| 12043 | migrateWarn("$(html) HTML text after last tag is ignored");
|
| 12044 | }
|
| 12045 |
|
| 12046 | // Consistently reject any HTML-like string starting with a hash (gh-9521)
|
| 12047 | // Note that this may break jQuery 1.6.x code that otherwise would work.
|
| 12048 | if ( match[ 0 ].charAt( 0 ) === "#" ) {
|
| 12049 | migrateWarn("HTML string cannot start with a '#' character");
|
| 12050 | jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
|
| 12051 | }
|
| 12052 |
|
| 12053 | // Now process using loose rules; let pre-1.8 play too
|
| 12054 | // Is this a jQuery context? parseHTML expects a DOM element (#178)
|
| 12055 | if ( context && context.context && context.context.nodeType ) {
|
| 12056 | context = context.context;
|
| 12057 | }
|
| 12058 |
|
| 12059 | if ( jQuery.parseHTML ) {
|
| 12060 | return oldInit.call( this,
|
| 12061 | jQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||
|
| 12062 | context || document, true ), context, rootjQuery );
|
| 12063 | }
|
| 12064 | }
|
| 12065 | }
|
| 12066 |
|
| 12067 | ret = oldInit.apply( this, arguments );
|
| 12068 |
|
| 12069 | // Fill in selector and context properties so .live() works
|
| 12070 | if ( selector && selector.selector !== undefined ) {
|
| 12071 | // A jQuery object, copy its properties
|
| 12072 | ret.selector = selector.selector;
|
| 12073 | ret.context = selector.context;
|
| 12074 |
|
| 12075 | } else {
|
| 12076 | ret.selector = typeof selector === "string" ? selector : "";
|
| 12077 | if ( selector ) {
|
| 12078 | ret.context = selector.nodeType? selector : context || document;
|
| 12079 | }
|
| 12080 | }
|
| 12081 |
|
| 12082 | return ret;
|
| 12083 | };
|
| 12084 | jQuery.fn.init.prototype = jQuery.fn;
|
| 12085 |
|
| 12086 | jQuery.find = function( selector ) {
|
| 12087 | var args = Array.prototype.slice.call( arguments );
|
| 12088 |
|
| 12089 | // Support: PhantomJS 1.x
|
| 12090 | // String#match fails to match when used with a //g RegExp, only on some strings
|
| 12091 | if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
|
| 12092 |
|
| 12093 | // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
|
| 12094 | // First see if qS thinks it's a valid selector, if so avoid a false positive
|
| 12095 | try {
|
| 12096 | document.querySelector( selector );
|
| 12097 | } catch ( err1 ) {
|
| 12098 |
|
| 12099 | // Didn't *look* valid to qSA, warn and try quoting what we think is the value
|
| 12100 | selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
|
| 12101 | return "[" + attr + op + "\"" + value + "\"]";
|
| 12102 | } );
|
| 12103 |
|
| 12104 | // If the regexp *may* have created an invalid selector, don't update it
|
| 12105 | // Note that there may be false alarms if selector uses jQuery extensions
|
| 12106 | try {
|
| 12107 | document.querySelector( selector );
|
| 12108 | migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
|
| 12109 | args[ 0 ] = selector;
|
| 12110 | } catch ( err2 ) {
|
| 12111 | migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
|
| 12112 | }
|
| 12113 | }
|
| 12114 | }
|
| 12115 |
|
| 12116 | return oldFind.apply( this, args );
|
| 12117 | };
|
| 12118 |
|
| 12119 | // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
|
| 12120 | var findProp;
|
| 12121 | for ( findProp in oldFind ) {
|
| 12122 | if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
|
| 12123 | jQuery.find[ findProp ] = oldFind[ findProp ];
|
| 12124 | }
|
| 12125 | }
|
| 12126 |
|
| 12127 | // Let $.parseJSON(falsy_value) return null
|
| 12128 | jQuery.parseJSON = function( json ) {
|
| 12129 | if ( !json ) {
|
| 12130 | migrateWarn("jQuery.parseJSON requires a valid JSON string");
|
| 12131 | return null;
|
| 12132 | }
|
| 12133 | return oldParseJSON.apply( this, arguments );
|
| 12134 | };
|
| 12135 |
|
| 12136 | jQuery.uaMatch = function( ua ) {
|
| 12137 | ua = ua.toLowerCase();
|
| 12138 |
|
| 12139 | var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
|
| 12140 | /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
| 12141 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
| 12142 | /(msie) ([\w.]+)/.exec( ua ) ||
|
| 12143 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
| 12144 | [];
|
| 12145 |
|
| 12146 | return {
|
| 12147 | browser: match[ 1 ] || "",
|
| 12148 | version: match[ 2 ] || "0"
|
| 12149 | };
|
| 12150 | };
|
| 12151 |
|
| 12152 | // Don't clobber any existing jQuery.browser in case it's different
|
| 12153 | if ( !jQuery.browser ) {
|
| 12154 | matched = jQuery.uaMatch( navigator.userAgent );
|
| 12155 | browser = {};
|
| 12156 |
|
| 12157 | if ( matched.browser ) {
|
| 12158 | browser[ matched.browser ] = true;
|
| 12159 | browser.version = matched.version;
|
| 12160 | }
|
| 12161 |
|
| 12162 | // Chrome is Webkit, but Webkit is also Safari.
|
| 12163 | if ( browser.chrome ) {
|
| 12164 | browser.webkit = true;
|
| 12165 | } else if ( browser.webkit ) {
|
| 12166 | browser.safari = true;
|
| 12167 | }
|
| 12168 |
|
| 12169 | jQuery.browser = browser;
|
| 12170 | }
|
| 12171 |
|
| 12172 | // Warn if the code tries to get jQuery.browser
|
| 12173 | migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
|
| 12174 |
|
| 12175 | // jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
|
| 12176 | jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat");
|
| 12177 | migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" );
|
| 12178 | migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" );
|
| 12179 |
|
| 12180 | jQuery.sub = function() {
|
| 12181 | function jQuerySub( selector, context ) {
|
| 12182 | return new jQuerySub.fn.init( selector, context );
|
| 12183 | }
|
| 12184 | jQuery.extend( true, jQuerySub, this );
|
| 12185 | jQuerySub.superclass = this;
|
| 12186 | jQuerySub.fn = jQuerySub.prototype = this();
|
| 12187 | jQuerySub.fn.constructor = jQuerySub;
|
| 12188 | jQuerySub.sub = this.sub;
|
| 12189 | jQuerySub.fn.init = function init( selector, context ) {
|
| 12190 | var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );
|
| 12191 | return instance instanceof jQuerySub ?
|
| 12192 | instance :
|
| 12193 | jQuerySub( instance );
|
| 12194 | };
|
| 12195 | jQuerySub.fn.init.prototype = jQuerySub.fn;
|
| 12196 | var rootjQuerySub = jQuerySub(document);
|
| 12197 | migrateWarn( "jQuery.sub() is deprecated" );
|
| 12198 | return jQuerySub;
|
| 12199 | };
|
| 12200 |
|
| 12201 | // The number of elements contained in the matched element set
|
| 12202 | jQuery.fn.size = function() {
|
| 12203 | migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
|
| 12204 | return this.length;
|
| 12205 | };
|
| 12206 |
|
| 12207 |
|
| 12208 | var internalSwapCall = false;
|
| 12209 |
|
| 12210 | // If this version of jQuery has .swap(), don't false-alarm on internal uses
|
| 12211 | if ( jQuery.swap ) {
|
| 12212 | jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
|
| 12213 | var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
|
| 12214 |
|
| 12215 | if ( oldHook ) {
|
| 12216 | jQuery.cssHooks[ name ].get = function() {
|
| 12217 | var ret;
|
| 12218 |
|
| 12219 | internalSwapCall = true;
|
| 12220 | ret = oldHook.apply( this, arguments );
|
| 12221 | internalSwapCall = false;
|
| 12222 | return ret;
|
| 12223 | };
|
| 12224 | }
|
| 12225 | });
|
| 12226 | }
|
| 12227 |
|
| 12228 | jQuery.swap = function( elem, options, callback, args ) {
|
| 12229 | var ret, name,
|
| 12230 | old = {};
|
| 12231 |
|
| 12232 | if ( !internalSwapCall ) {
|
| 12233 | migrateWarn( "jQuery.swap() is undocumented and deprecated" );
|
| 12234 | }
|
| 12235 |
|
| 12236 | // Remember the old values, and insert the new ones
|
| 12237 | for ( name in options ) {
|
| 12238 | old[ name ] = elem.style[ name ];
|
| 12239 | elem.style[ name ] = options[ name ];
|
| 12240 | }
|
| 12241 |
|
| 12242 | ret = callback.apply( elem, args || [] );
|
| 12243 |
|
| 12244 | // Revert the old values
|
| 12245 | for ( name in options ) {
|
| 12246 | elem.style[ name ] = old[ name ];
|
| 12247 | }
|
| 12248 |
|
| 12249 | return ret;
|
| 12250 | };
|
| 12251 |
|
| 12252 |
|
| 12253 | // Ensure that $.ajax gets the new parseJSON defined in core.js
|
| 12254 | jQuery.ajaxSetup({
|
| 12255 | converters: {
|
| 12256 | "text json": jQuery.parseJSON
|
| 12257 | }
|
| 12258 | });
|
| 12259 |
|
| 12260 |
|
| 12261 | var oldFnData = jQuery.fn.data;
|
| 12262 |
|
| 12263 | jQuery.fn.data = function( name ) {
|
| 12264 | var ret, evt,
|
| 12265 | elem = this[0];
|
| 12266 |
|
| 12267 | // Handles 1.7 which has this behavior and 1.8 which doesn't
|
| 12268 | if ( elem && name === "events" && arguments.length === 1 ) {
|
| 12269 | ret = jQuery.data( elem, name );
|
| 12270 | evt = jQuery._data( elem, name );
|
| 12271 | if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
|
| 12272 | migrateWarn("Use of jQuery.fn.data('events') is deprecated");
|
| 12273 | return evt;
|
| 12274 | }
|
| 12275 | }
|
| 12276 | return oldFnData.apply( this, arguments );
|
| 12277 | };
|
| 12278 |
|
| 12279 |
|
| 12280 | var rscriptType = /\/(java|ecma)script/i;
|
| 12281 |
|
| 12282 | // Since jQuery.clean is used internally on older versions, we only shim if it's missing
|
| 12283 | if ( !jQuery.clean ) {
|
| 12284 | jQuery.clean = function( elems, context, fragment, scripts ) {
|
| 12285 | // Set context per 1.8 logic
|
| 12286 | context = context || document;
|
| 12287 | context = !context.nodeType && context[0] || context;
|
| 12288 | context = context.ownerDocument || context;
|
| 12289 |
|
| 12290 | migrateWarn("jQuery.clean() is deprecated");
|
| 12291 |
|
| 12292 | var i, elem, handleScript, jsTags,
|
| 12293 | ret = [];
|
| 12294 |
|
| 12295 | jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
|
| 12296 |
|
| 12297 | // Complex logic lifted directly from jQuery 1.8
|
| 12298 | if ( fragment ) {
|
| 12299 | // Special handling of each script element
|
| 12300 | handleScript = function( elem ) {
|
| 12301 | // Check if we consider it executable
|
| 12302 | if ( !elem.type || rscriptType.test( elem.type ) ) {
|
| 12303 | // Detach the script and store it in the scripts array (if provided) or the fragment
|
| 12304 | // Return truthy to indicate that it has been handled
|
| 12305 | return scripts ?
|
| 12306 | scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
|
| 12307 | fragment.appendChild( elem );
|
| 12308 | }
|
| 12309 | };
|
| 12310 |
|
| 12311 | for ( i = 0; (elem = ret[i]) != null; i++ ) {
|
| 12312 | // Check if we're done after handling an executable script
|
| 12313 | if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
|
| 12314 | // Append to fragment and handle embedded scripts
|
| 12315 | fragment.appendChild( elem );
|
| 12316 | if ( typeof elem.getElementsByTagName !== "undefined" ) {
|
| 12317 | // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
|
| 12318 | jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
|
| 12319 |
|
| 12320 | // Splice the scripts into ret after their former ancestor and advance our index beyond them
|
| 12321 | ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
| 12322 | i += jsTags.length;
|
| 12323 | }
|
| 12324 | }
|
| 12325 | }
|
| 12326 | }
|
| 12327 |
|
| 12328 | return ret;
|
| 12329 | };
|
| 12330 | }
|
| 12331 |
|
| 12332 | var eventAdd = jQuery.event.add,
|
| 12333 | eventRemove = jQuery.event.remove,
|
| 12334 | eventTrigger = jQuery.event.trigger,
|
| 12335 | oldToggle = jQuery.fn.toggle,
|
| 12336 | oldLive = jQuery.fn.live,
|
| 12337 | oldDie = jQuery.fn.die,
|
| 12338 | oldLoad = jQuery.fn.load,
|
| 12339 | ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
|
| 12340 | rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
|
| 12341 | rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
|
| 12342 | hoverHack = function( events ) {
|
| 12343 | if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
|
| 12344 | return events;
|
| 12345 | }
|
| 12346 | if ( rhoverHack.test( events ) ) {
|
| 12347 | migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
|
| 12348 | }
|
| 12349 | return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
|
| 12350 | };
|
| 12351 |
|
| 12352 | // Event props removed in 1.9, put them back if needed; no practical way to warn them
|
| 12353 | if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
|
| 12354 | jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
|
| 12355 | }
|
| 12356 |
|
| 12357 | // Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
|
| 12358 | if ( jQuery.event.dispatch ) {
|
| 12359 | migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
|
| 12360 | }
|
| 12361 |
|
| 12362 | // Support for 'hover' pseudo-event and ajax event warnings
|
| 12363 | jQuery.event.add = function( elem, types, handler, data, selector ){
|
| 12364 | if ( elem !== document && rajaxEvent.test( types ) ) {
|
| 12365 | migrateWarn( "AJAX events should be attached to document: " + types );
|
| 12366 | }
|
| 12367 | eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
|
| 12368 | };
|
| 12369 | jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
|
| 12370 | eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
|
| 12371 | };
|
| 12372 |
|
| 12373 | jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
|
| 12374 |
|
| 12375 | jQuery.fn[ name ] = function() {
|
| 12376 | var args = Array.prototype.slice.call( arguments, 0 );
|
| 12377 |
|
| 12378 | // If this is an ajax load() the first arg should be the string URL;
|
| 12379 | // technically this could also be the "Anything" arg of the event .load()
|
| 12380 | // which just goes to show why this dumb signature has been deprecated!
|
| 12381 | // jQuery custom builds that exclude the Ajax module justifiably die here.
|
| 12382 | if ( name === "load" && typeof args[ 0 ] === "string" ) {
|
| 12383 | return oldLoad.apply( this, args );
|
| 12384 | }
|
| 12385 |
|
| 12386 | migrateWarn( "jQuery.fn." + name + "() is deprecated" );
|
| 12387 |
|
| 12388 | args.splice( 0, 0, name );
|
| 12389 | if ( arguments.length ) {
|
| 12390 | return this.bind.apply( this, args );
|
| 12391 | }
|
| 12392 |
|
| 12393 | // Use .triggerHandler here because:
|
| 12394 | // - load and unload events don't need to bubble, only applied to window or image
|
| 12395 | // - error event should not bubble to window, although it does pre-1.7
|
| 12396 | // See http://bugs.jquery.com/ticket/11820
|
| 12397 | this.triggerHandler.apply( this, args );
|
| 12398 | return this;
|
| 12399 | };
|
| 12400 |
|
| 12401 | });
|
| 12402 |
|
| 12403 | jQuery.fn.toggle = function( fn, fn2 ) {
|
| 12404 |
|
| 12405 | // Don't mess with animation or css toggles
|
| 12406 | if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
|
| 12407 | return oldToggle.apply( this, arguments );
|
| 12408 | }
|
| 12409 | migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
|
| 12410 |
|
| 12411 | // Save reference to arguments for access in closure
|
| 12412 | var args = arguments,
|
| 12413 | guid = fn.guid || jQuery.guid++,
|
| 12414 | i = 0,
|
| 12415 | toggler = function( event ) {
|
| 12416 | // Figure out which function to execute
|
| 12417 | var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
| 12418 | jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
| 12419 |
|
| 12420 | // Make sure that clicks stop
|
| 12421 | event.preventDefault();
|
| 12422 |
|
| 12423 | // and execute the function
|
| 12424 | return args[ lastToggle ].apply( this, arguments ) || false;
|
| 12425 | };
|
| 12426 |
|
| 12427 | // link all the functions, so any of them can unbind this click handler
|
| 12428 | toggler.guid = guid;
|
| 12429 | while ( i < args.length ) {
|
| 12430 | args[ i++ ].guid = guid;
|
| 12431 | }
|
| 12432 |
|
| 12433 | return this.click( toggler );
|
| 12434 | };
|
| 12435 |
|
| 12436 | jQuery.fn.live = function( types, data, fn ) {
|
| 12437 | migrateWarn("jQuery.fn.live() is deprecated");
|
| 12438 | if ( oldLive ) {
|
| 12439 | return oldLive.apply( this, arguments );
|
| 12440 | }
|
| 12441 | jQuery( this.context ).on( types, this.selector, data, fn );
|
| 12442 | return this;
|
| 12443 | };
|
| 12444 |
|
| 12445 | jQuery.fn.die = function( types, fn ) {
|
| 12446 | migrateWarn("jQuery.fn.die() is deprecated");
|
| 12447 | if ( oldDie ) {
|
| 12448 | return oldDie.apply( this, arguments );
|
| 12449 | }
|
| 12450 | jQuery( this.context ).off( types, this.selector || "**", fn );
|
| 12451 | return this;
|
| 12452 | };
|
| 12453 |
|
| 12454 | // Turn global events into document-triggered events
|
| 12455 | jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
|
| 12456 | if ( !elem && !rajaxEvent.test( event ) ) {
|
| 12457 | migrateWarn( "Global events are undocumented and deprecated" );
|
| 12458 | }
|
| 12459 | return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
|
| 12460 | };
|
| 12461 | jQuery.each( ajaxEvents.split("|"),
|
| 12462 | function( _, name ) {
|
| 12463 | jQuery.event.special[ name ] = {
|
| 12464 | setup: function() {
|
| 12465 | var elem = this;
|
| 12466 |
|
| 12467 | // The document needs no shimming; must be !== for oldIE
|
| 12468 | if ( elem !== document ) {
|
| 12469 | jQuery.event.add( document, name + "." + jQuery.guid, function() {
|
| 12470 | jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );
|
| 12471 | });
|
| 12472 | jQuery._data( this, name, jQuery.guid++ );
|
| 12473 | }
|
| 12474 | return false;
|
| 12475 | },
|
| 12476 | teardown: function() {
|
| 12477 | if ( this !== document ) {
|
| 12478 | jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
|
| 12479 | }
|
| 12480 | return false;
|
| 12481 | }
|
| 12482 | };
|
| 12483 | }
|
| 12484 | );
|
| 12485 |
|
| 12486 | jQuery.event.special.ready = {
|
| 12487 | setup: function() {
|
| 12488 | if ( this === document ) {
|
| 12489 | migrateWarn( "'ready' event is deprecated" );
|
| 12490 | }
|
| 12491 | }
|
| 12492 | };
|
| 12493 |
|
| 12494 | var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
|
| 12495 | oldFnFind = jQuery.fn.find;
|
| 12496 |
|
| 12497 | jQuery.fn.andSelf = function() {
|
| 12498 | migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
|
| 12499 | return oldSelf.apply( this, arguments );
|
| 12500 | };
|
| 12501 |
|
| 12502 | jQuery.fn.find = function( selector ) {
|
| 12503 | var ret = oldFnFind.apply( this, arguments );
|
| 12504 | ret.context = this.context;
|
| 12505 | ret.selector = this.selector ? this.selector + " " + selector : selector;
|
| 12506 | return ret;
|
| 12507 | };
|
| 12508 |
|
| 12509 |
|
| 12510 | // jQuery 1.6 did not support Callbacks, do not warn there
|
| 12511 | if ( jQuery.Callbacks ) {
|
| 12512 |
|
| 12513 | var oldDeferred = jQuery.Deferred,
|
| 12514 | tuples = [
|
| 12515 | // action, add listener, callbacks, .then handlers, final state
|
| 12516 | [ "resolve", "done", jQuery.Callbacks("once memory"),
|
| 12517 | jQuery.Callbacks("once memory"), "resolved" ],
|
| 12518 | [ "reject", "fail", jQuery.Callbacks("once memory"),
|
| 12519 | jQuery.Callbacks("once memory"), "rejected" ],
|
| 12520 | [ "notify", "progress", jQuery.Callbacks("memory"),
|
| 12521 | jQuery.Callbacks("memory") ]
|
| 12522 | ];
|
| 12523 |
|
| 12524 | jQuery.Deferred = function( func ) {
|
| 12525 | var deferred = oldDeferred(),
|
| 12526 | promise = deferred.promise();
|
| 12527 |
|
| 12528 | deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
|
| 12529 | var fns = arguments;
|
| 12530 |
|
| 12531 | migrateWarn( "deferred.pipe() is deprecated" );
|
| 12532 |
|
| 12533 | return jQuery.Deferred(function( newDefer ) {
|
| 12534 | jQuery.each( tuples, function( i, tuple ) {
|
| 12535 | var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
| 12536 | // deferred.done(function() { bind to newDefer or newDefer.resolve })
|
| 12537 | // deferred.fail(function() { bind to newDefer or newDefer.reject })
|
| 12538 | // deferred.progress(function() { bind to newDefer or newDefer.notify })
|
| 12539 | deferred[ tuple[1] ](function() {
|
| 12540 | var returned = fn && fn.apply( this, arguments );
|
| 12541 | if ( returned && jQuery.isFunction( returned.promise ) ) {
|
| 12542 | returned.promise()
|
| 12543 | .done( newDefer.resolve )
|
| 12544 | .fail( newDefer.reject )
|
| 12545 | .progress( newDefer.notify );
|
| 12546 | } else {
|
| 12547 | newDefer[ tuple[ 0 ] + "With" ](
|
| 12548 | this === promise ? newDefer.promise() : this,
|
| 12549 | fn ? [ returned ] : arguments
|
| 12550 | );
|
| 12551 | }
|
| 12552 | });
|
| 12553 | });
|
| 12554 | fns = null;
|
| 12555 | }).promise();
|
| 12556 |
|
| 12557 | };
|
| 12558 |
|
| 12559 | deferred.isResolved = function() {
|
| 12560 | migrateWarn( "deferred.isResolved is deprecated" );
|
| 12561 | return deferred.state() === "resolved";
|
| 12562 | };
|
| 12563 |
|
| 12564 | deferred.isRejected = function() {
|
| 12565 | migrateWarn( "deferred.isRejected is deprecated" );
|
| 12566 | return deferred.state() === "rejected";
|
| 12567 | };
|
| 12568 |
|
| 12569 | if ( func ) {
|
| 12570 | func.call( deferred, deferred );
|
| 12571 | }
|
| 12572 |
|
| 12573 | return deferred;
|
| 12574 | };
|
| 12575 |
|
| 12576 | }
|
| 12577 |
|
| 12578 | })( jQuery, window ); |