1(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 2var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; 3 4;(function (exports) { 5 'use strict'; 6 7 var Arr = (typeof Uint8Array !== 'undefined') 8 ? Uint8Array 9 : Array 10 11 var PLUS = '+'.charCodeAt(0) 12 var SLASH = '/'.charCodeAt(0) 13 var NUMBER = '0'.charCodeAt(0) 14 var LOWER = 'a'.charCodeAt(0) 15 var UPPER = 'A'.charCodeAt(0) 16 var PLUS_URL_SAFE = '-'.charCodeAt(0) 17 var SLASH_URL_SAFE = '_'.charCodeAt(0) 18 19 function decode (elt) { 20 var code = elt.charCodeAt(0) 21 if (code === PLUS || 22 code === PLUS_URL_SAFE) 23 return 62 // '+' 24 if (code === SLASH || 25 code === SLASH_URL_SAFE) 26 return 63 // '/' 27 if (code < NUMBER) 28 return -1 //no match 29 if (code < NUMBER + 10) 30 return code - NUMBER + 26 + 26 31 if (code < UPPER + 26) 32 return code - UPPER 33 if (code < LOWER + 26) 34 return code - LOWER + 26 35 } 36 37 function b64ToByteArray (b64) { 38 var i, j, l, tmp, placeHolders, arr 39 40 if (b64.length % 4 > 0) { 41 throw new Error('Invalid string. Length must be a multiple of 4') 42 } 43 44 // the number of equal signs (place holders) 45 // if there are two placeholders, than the two characters before it 46 // represent one byte 47 // if there is only one, then the three characters before it represent 2 bytes 48 // this is just a cheap hack to not do indexOf twice 49 var len = b64.length 50 placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 51 52 // base64 is 4/3 + up to two characters of the original data 53 arr = new Arr(b64.length * 3 / 4 - placeHolders) 54 55 // if there are placeholders, only get up to the last complete 4 chars 56 l = placeHolders > 0 ? b64.length - 4 : b64.length 57 58 var L = 0 59 60 function push (v) { 61 arr[L++] = v 62 } 63 64 for (i = 0, j = 0; i < l; i += 4, j += 3) { 65 tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) 66 push((tmp & 0xFF0000) >> 16) 67 push((tmp & 0xFF00) >> 8) 68 push(tmp & 0xFF) 69 } 70 71 if (placeHolders === 2) { 72 tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) 73 push(tmp & 0xFF) 74 } else if (placeHolders === 1) { 75 tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) 76 push((tmp >> 8) & 0xFF) 77 push(tmp & 0xFF) 78 } 79 80 return arr 81 } 82 83 function uint8ToBase64 (uint8) { 84 var i, 85 extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes 86 output = "", 87 temp, length 88 89 function encode (num) { 90 return lookup.charAt(num) 91 } 92 93 function tripletToBase64 (num) { 94 return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) 95 } 96 97 // go through the array every three bytes, we'll deal with trailing stuff later 98 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { 99 temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) 100 output += tripletToBase64(temp) 101 } 102 103 // pad the end with zeros, but make sure to not forget the extra bytes 104 switch (extraBytes) { 105 case 1: 106 temp = uint8[uint8.length - 1] 107 output += encode(temp >> 2) 108 output += encode((temp << 4) & 0x3F) 109 output += '==' 110 break 111 case 2: 112 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) 113 output += encode(temp >> 10) 114 output += encode((temp >> 4) & 0x3F) 115 output += encode((temp << 2) & 0x3F) 116 output += '=' 117 break 118 } 119 120 return output 121 } 122 123 exports.toByteArray = b64ToByteArray 124 exports.fromByteArray = uint8ToBase64 125}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) 126 127},{}],2:[function(require,module,exports){ 128(function (global){ 129/*! http://mths.be/punycode v1.2.4 by @mathias */ 130;(function(root) { 131 132 /** Detect free variables */ 133 var freeExports = typeof exports == 'object' && exports; 134 var freeModule = typeof module == 'object' && module && 135 module.exports == freeExports && module; 136 var freeGlobal = typeof global == 'object' && global; 137 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { 138 root = freeGlobal; 139 } 140 141 /** 142 * The `punycode` object. 143 * @name punycode 144 * @type Object 145 */ 146 var punycode, 147 148 /** Highest positive signed 32-bit float value */ 149 maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 150 151 /** Bootstring parameters */ 152 base = 36, 153 tMin = 1, 154 tMax = 26, 155 skew = 38, 156 damp = 700, 157 initialBias = 72, 158 initialN = 128, // 0x80 159 delimiter = '-', // '\x2D' 160 161 /** Regular expressions */ 162 regexPunycode = /^xn--/, 163 regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars 164 regexSeparators = /\x2E|\u3002|\uFF0E|\uFF61/g, // RFC 3490 separators 165 166 /** Error messages */ 167 errors = { 168 'overflow': 'Overflow: input needs wider integers to process', 169 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', 170 'invalid-input': 'Invalid input' 171 }, 172 173 /** Convenience shortcuts */ 174 baseMinusTMin = base - tMin, 175 floor = Math.floor, 176 stringFromCharCode = String.fromCharCode, 177 178 /** Temporary variable */ 179 key; 180 181 /*--------------------------------------------------------------------------*/ 182 183 /** 184 * A generic error utility function. 185 * @private 186 * @param {String} type The error type. 187 * @returns {Error} Throws a `RangeError` with the applicable error message. 188 */ 189 function error(type) { 190 throw RangeError(errors[type]); 191 } 192 193 /** 194 * A generic `Array#map` utility function. 195 * @private 196 * @param {Array} array The array to iterate over. 197 * @param {Function} callback The function that gets called for every array 198 * item. 199 * @returns {Array} A new array of values returned by the callback function. 200 */ 201 function map(array, fn) { 202 var length = array.length; 203 while (length--) { 204 array[length] = fn(array[length]); 205 } 206 return array; 207 } 208 209 /** 210 * A simple `Array#map`-like wrapper to work with domain name strings. 211 * @private 212 * @param {String} domain The domain name. 213 * @param {Function} callback The function that gets called for every 214 * character. 215 * @returns {Array} A new string of characters returned by the callback 216 * function. 217 */ 218 function mapDomain(string, fn) { 219 return map(string.split(regexSeparators), fn).join('.'); 220 } 221 222 /** 223 * Creates an array containing the numeric code points of each Unicode 224 * character in the string. While JavaScript uses UCS-2 internally, 225 * this function will convert a pair of surrogate halves (each of which 226 * UCS-2 exposes as separate characters) into a single code point, 227 * matching UTF-16. 228 * @see `punycode.ucs2.encode` 229 * @see <http://mathiasbynens.be/notes/javascript-encoding> 230 * @memberOf punycode.ucs2 231 * @name decode 232 * @param {String} string The Unicode input string (UCS-2). 233 * @returns {Array} The new array of code points. 234 */ 235 function ucs2decode(string) { 236 var output = [], 237 counter = 0, 238 length = string.length, 239 value, 240 extra; 241 while (counter < length) { 242 value = string.charCodeAt(counter++); 243 if (value >= 0xD800 && value <= 0xDBFF && counter < length) { 244 // high surrogate, and there is a next character 245 extra = string.charCodeAt(counter++); 246 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
vendor: 9,396 bytes, lines 247-591
247 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); 248 } else { 249 // unmatched surrogate; only append this code unit, in case the next 250 // code unit is the high surrogate of a surrogate pair 251 output.push(value); 252 counter--; 253 } 254 } else { 255 output.push(value); 256 } 257 } 258 return output; 259 } 260 261 /** 262 * Creates a string based on an array of numeric code points. 263 * @see `punycode.ucs2.decode` 264 * @memberOf punycode.ucs2 265 * @name encode 266 * @param {Array} codePoints The array of numeric code points. 267 * @returns {String} The new Unicode string (UCS-2). 268 */ 269 function ucs2encode(array) { 270 return map(array, function(value) { 271 var output = ''; 272 if (value > 0xFFFF) { 273 value -= 0x10000; 274 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); 275 value = 0xDC00 | value & 0x3FF; 276 } 277 output += stringFromCharCode(value); 278 return output; 279 }).join(''); 280 } 281 282 /** 283 * Converts a basic code point into a digit/integer. 284 * @see `digitToBasic()` 285 * @private 286 * @param {Number} codePoint The basic numeric code point value. 287 * @returns {Number} The numeric value of a basic code point (for use in 288 * representing integers) in the range `0` to `base - 1`, or `base` if 289 * the code point does not represent a value. 290 */ 291 function basicToDigit(codePoint) { 292 if (codePoint - 48 < 10) { 293 return codePoint - 22; 294 } 295 if (codePoint - 65 < 26) { 296 return codePoint - 65; 297 } 298 if (codePoint - 97 < 26) { 299 return codePoint - 97; 300 } 301 return base; 302 } 303 304 /** 305 * Converts a digit/integer into a basic code point. 306 * @see `basicToDigit()` 307 * @private 308 * @param {Number} digit The numeric value of a basic code point. 309 * @returns {Number} The basic code point whose value (when used for 310 * representing integers) is `digit`, which needs to be in the range 311 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is 312 * used; else, the lowercase form is used. The behavior is undefined 313 * if `flag` is non-zero and `digit` has no uppercase form. 314 */ 315 function digitToBasic(digit, flag) { 316 // 0..25 map to ASCII a..z or A..Z 317 // 26..35 map to ASCII 0..9 318 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); 319 } 320 321 /** 322 * Bias adaptation function as per section 3.4 of RFC 3492. 323 * http://tools.ietf.org/html/rfc3492#section-3.4 324 * @private 325 */ 326 function adapt(delta, numPoints, firstTime) { 327 var k = 0; 328 delta = firstTime ? floor(delta / damp) : delta >> 1; 329 delta += floor(delta / numPoints); 330 for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { 331 delta = floor(delta / baseMinusTMin); 332 } 333 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); 334 } 335 336 /** 337 * Converts a Punycode string of ASCII-only symbols to a string of Unicode 338 * symbols. 339 * @memberOf punycode 340 * @param {String} input The Punycode string of ASCII-only symbols. 341 * @returns {String} The resulting string of Unicode symbols. 342 */ 343 function decode(input) { 344 // Don't use UCS-2 345 var output = [], 346 inputLength = input.length, 347 out, 348 i = 0, 349 n = initialN, 350 bias = initialBias, 351 basic, 352 j, 353 index, 354 oldi, 355 w, 356 k, 357 digit, 358 t, 359 /** Cached calculation results */ 360 baseMinusT; 361 362 // Handle the basic code points: let `basic` be the number of input code 363 // points before the last delimiter, or `0` if there is none, then copy 364 // the first basic code points to the output. 365 366 basic = input.lastIndexOf(delimiter); 367 if (basic < 0) { 368 basic = 0; 369 } 370 371 for (j = 0; j < basic; ++j) { 372 // if it's not a basic code point 373 if (input.charCodeAt(j) >= 0x80) { 374 error('not-basic'); 375 } 376 output.push(input.charCodeAt(j)); 377 } 378 379 // Main decoding loop: start just after the last delimiter if any basic code 380 // points were copied; start at the beginning otherwise. 381 382 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { 383 384 // `index` is the index of the next character to be consumed. 385 // Decode a generalized variable-length integer into `delta`, 386 // which gets added to `i`. The overflow checking is easier 387 // if we increase `i` as we go, then subtract off its starting 388 // value at the end to obtain `delta`. 389 for (oldi = i, w = 1, k = base; /* no condition */; k += base) { 390 391 if (index >= inputLength) { 392 error('invalid-input'); 393 } 394 395 digit = basicToDigit(input.charCodeAt(index++)); 396 397 if (digit >= base || digit > floor((maxInt - i) / w)) { 398 error('overflow'); 399 } 400 401 i += digit * w; 402 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); 403 404 if (digit < t) { 405 break; 406 } 407 408 baseMinusT = base - t; 409 if (w > floor(maxInt / baseMinusT)) { 410 error('overflow'); 411 } 412 413 w *= baseMinusT; 414 415 } 416 417 out = output.length + 1; 418 bias = adapt(i - oldi, out, oldi == 0); 419 420 // `i` was supposed to wrap around from `out` to `0`, 421 // incrementing `n` each time, so we'll fix that now: 422 if (floor(i / out) > maxInt - n) { 423 error('overflow'); 424 } 425 426 n += floor(i / out); 427 i %= out; 428 429 // Insert `n` at position `i` of the output 430 output.splice(i++, 0, n); 431 432 } 433 434 return ucs2encode(output); 435 } 436 437 /** 438 * Converts a string of Unicode symbols to a Punycode string of ASCII-only 439 * symbols. 440 * @memberOf punycode 441 * @param {String} input The string of Unicode symbols. 442 * @returns {String} The resulting Punycode string of ASCII-only symbols. 443 */ 444 function encode(input) { 445 var n, 446 delta, 447 handledCPCount, 448 basicLength, 449 bias, 450 j, 451 m, 452 q, 453 k, 454 t, 455 currentValue, 456 output = [], 457 /** `inputLength` will hold the number of code points in `input`. */ 458 inputLength, 459 /** Cached calculation results */ 460 handledCPCountPlusOne, 461 baseMinusT, 462 qMinusT; 463 464 // Convert the input in UCS-2 to Unicode 465 input = ucs2decode(input); 466 467 // Cache the length 468 inputLength = input.length; 469 470 // Initialize the state 471 n = initialN; 472 delta = 0; 473 bias = initialBias; 474 475 // Handle the basic code points 476 for (j = 0; j < inputLength; ++j) { 477 currentValue = input[j]; 478 if (currentValue < 0x80) { 479 output.push(stringFromCharCode(currentValue)); 480 } 481 } 482 483 handledCPCount = basicLength = output.length; 484 485 // `handledCPCount` is the number of code points that have been handled; 486 // `basicLength` is the number of basic code points. 487 488 // Finish the basic string - if it is not empty - with a delimiter 489 if (basicLength) { 490 output.push(delimiter); 491 } 492 493 // Main encoding loop: 494 while (handledCPCount < inputLength) { 495 496 // All non-basic code points < n have been handled already. Find the next 497 // larger one: 498 for (m = maxInt, j = 0; j < inputLength; ++j) { 499 currentValue = input[j]; 500 if (currentValue >= n && currentValue < m) { 501 m = currentValue; 502 } 503 } 504 505 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, 506 // but guard against overflow 507 handledCPCountPlusOne = handledCPCount + 1; 508 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { 509 error('overflow'); 510 } 511 512 delta += (m - n) * handledCPCountPlusOne; 513 n = m; 514 515 for (j = 0; j < inputLength; ++j) { 516 currentValue = input[j]; 517 518 if (currentValue < n && ++delta > maxInt) { 519 error('overflow'); 520 } 521 522 if (currentValue == n) { 523 // Represent delta as a generalized variable-length integer 524 for (q = delta, k = base; /* no condition */; k += base) { 525 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); 526 if (q < t) { 527 break; 528 } 529 qMinusT = q - t; 530 baseMinusT = base - t; 531 output.push( 532 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) 533 ); 534 q = floor(qMinusT / baseMinusT); 535 } 536 537 output.push(stringFromCharCode(digitToBasic(q, 0))); 538 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); 539 delta = 0; 540 ++handledCPCount; 541 } 542 } 543 544 ++delta; 545 ++n; 546 547 } 548 return output.join(''); 549 } 550 551 /** 552 * Converts a Punycode string representing a domain name to Unicode. Only the 553 * Punycoded parts of the domain name will be converted, i.e. it doesn't 554 * matter if you call it on a string that has already been converted to 555 * Unicode. 556 * @memberOf punycode 557 * @param {String} domain The Punycode domain name to convert to Unicode. 558 * @returns {String} The Unicode representation of the given Punycode 559 * string. 560 */ 561 function toUnicode(domain) { 562 return mapDomain(domain, function(string) { 563 return regexPunycode.test(string) 564 ? decode(string.slice(4).toLowerCase()) 565 : string; 566 }); 567 } 568 569 /** 570 * Converts a Unicode string representing a domain name to Punycode. Only the 571 * non-ASCII parts of the domain name will be converted, i.e. it doesn't 572 * matter if you call it with a domain that's already in ASCII. 573 * @memberOf punycode 574 * @param {String} domain The domain name to convert, as a Unicode string. 575 * @returns {String} The Punycode representation of the given domain name. 576 */ 577 function toASCII(domain) { 578 return mapDomain(domain, function(string) { 579 return regexNonASCII.test(string) 580 ? 'xn--' + encode(string) 581 : string; 582 }); 583 } 584 585 /*--------------------------------------------------------------------------*/ 586 587 /** Define the public API */ 588 punycode = { 589 /** 590 * A string representing the current Punycode.js version number. 591 * @memberOf punycode
592 * @type String 593 */ 594 'version': '1.2.4', 595 /** 596 * An object of methods to convert from JavaScript's internal character 597 * representation (UCS-2) to Unicode code points, and back. 598 * @see <http://mathiasbynens.be/notes/javascript-encoding> 599 * @memberOf punycode 600 * @type Object 601 */ 602 'ucs2': { 603 'decode': ucs2decode, 604 'encode': ucs2encode 605 }, 606 'decode': decode, 607 'encode': encode, 608 'toASCII': toASCII, 609 'toUnicode': toUnicode 610 }; 611 612 /** Expose `punycode` */ 613 // Some AMD build optimizers, like r.js, check for specific condition patterns 614 // like the following: 615 if ( 616 typeof define == 'function' && 617 typeof define.amd == 'object' && 618 define.amd 619 ) { 620 define('punycode', function() { 621 return punycode; 622 }); 623 } else if (freeExports && !freeExports.nodeType) { 624 if (freeModule) { // in Node.js or RingoJS v0.8.0+ 625 freeModule.exports = punycode; 626 } else { // in Narwhal or RingoJS v0.7.0- 627 for (key in punycode) { 628 punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); 629 } 630 } 631 } else { // in Rhino or a web browser 632 root.punycode = punycode; 633 } 634 635}(this)); 636 637}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 638},{}],3:[function(require,module,exports){ 639(function (global){ 640/*! 641 * The buffer module from node.js, for the browser. 642 * 643 * @author Feross Aboukhadijeh <[email protected]> <http://feross.org> 644 * @license MIT 645 */ 646/* eslint-disable no-proto */ 647 648'use strict' 649 650var base64 = require('base64-js') 651var ieee754 = require('ieee754') 652var isArray = require('isarray') 653 654exports.Buffer = Buffer 655exports.SlowBuffer = SlowBuffer 656exports.INSPECT_MAX_BYTES = 50 657Buffer.poolSize = 8192 // not used by this implementation 658 659var rootParent = {} 660 661/** 662 * If `Buffer.TYPED_ARRAY_SUPPORT`: 663 * === true Use Uint8Array implementation (fastest) 664 * === false Use Object implementation (most compatible, even IE6) 665 * 666 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 667 * Opera 11.6+, iOS 4.2+. 668 * 669 * Due to various browser bugs, sometimes the Object implementation will be used even 670 * when the browser supports typed arrays. 671 *
672 * Note: 673 * 674 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, 675 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. 676 * 677 * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property 678 * on objects. 679 * 680 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. 681 * 682 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of 683 * incorrect length in some situations. 684 685 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they 686 * get the Object implementation, which is slower but behaves correctly. 687 */ 688Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined 689 ? global.TYPED_ARRAY_SUPPORT 690 : typedArraySupport() 691 692function typedArraySupport () { 693 function Bar () {} 694 try { 695 var arr = new Uint8Array(1) 696 arr.foo = function () { return 42 } 697 arr.constructor = Bar 698 return arr.foo() === 42 && // typed array instances can be augmented 699 arr.constructor === Bar && // constructor can be set 700 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` 701 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` 702 } catch (e) { 703 return false 704 } 705} 706 707function kMaxLength () { 708 return Buffer.TYPED_ARRAY_SUPPORT 709 ? 0x7fffffff 710 : 0x3fffffff 711} 712 713/** 714 * Class: Buffer 715 * ============= 716 * 717 * The Buffer constructor returns instances of `Uint8Array` that are augmented 718 * with function properties for all the node `Buffer` API functions. We use 719 * `Uint8Array` so that square bracket notation works as expected -- it returns 720 * a single octet. 721 * 722 * By augmenting the instances, we can avoid modifying the `Uint8Array` 723 * prototype. 724 */ 725function Buffer (arg) { 726 if (!(this instanceof Buffer)) { 727 // Avoid going through an ArgumentsAdaptorTrampoline in the common case. 728 if (arguments.length > 1) return new Buffer(arg, arguments[1]) 729 return new Buffer(arg) 730 } 731 732 if (!Buffer.TYPED_ARRAY_SUPPORT) { 733 this.length = 0 734 this.parent = undefined 735 } 736 737 // Common case. 738 if (typeof arg === 'number') { 739 return fromNumber(this, arg) 740 } 741 742 // Slightly less common case. 743 if (typeof arg === 'string') { 744 return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') 745 } 746 747 // Unusual. 748 return fromObject(this, arg) 749} 750 751function fromNumber (that, length) { 752 that = allocate(that, length < 0 ? 0 : checked(length) | 0) 753 if (!Buffer.TYPED_ARRAY_SUPPORT) { 754 for (var i = 0; i < length; i++) { 755 that[i] = 0 756 } 757 } 758 return that 759} 760 761function fromString (that, string, encoding) { 762 if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' 763 764 // Assumption: byteLength() return value is always < kMaxLength. 765 var length = byteLength(string, encoding) | 0 766 that = allocate(that, length) 767 768 that.write(string, encoding) 769 return that 770} 771 772function fromObject (that, object) { 773 if (Buffer.isBuffer(object)) return fromBuffer(that, object) 774 775 if (isArray(object)) return fromArray(that, object) 776 777 if (object == null) { 778 throw new TypeError('must start with number, buffer, array or string') 779 } 780 781 if (typeof ArrayBuffer !== 'undefined') { 782 if (object.buffer instanceof ArrayBuffer) { 783 return fromTypedArray(that, object) 784 } 785 if (object instanceof ArrayBuffer) { 786 return fromArrayBuffer(that, object) 787 } 788 } 789 790 if (object.length) return fromArrayLike(that, object) 791 792 return fromJsonObject(that, object) 793} 794 795function fromBuffer (that, buffer) { 796 var length = checked(buffer.length) | 0 797 that = allocate(that, length) 798 buffer.copy(that, 0, 0, length) 799 return that 800} 801 802function fromArray (that, array) { 803 var length = checked(array.length) | 0 804 that = allocate(that, length) 805 for (var i = 0; i < length; i += 1) { 806 that[i] = array[i] & 255 807 } 808 return that 809} 810 811// Duplicate of fromArray() to keep fromArray() monomorphic. 812function fromTypedArray (that, array) { 813 var length = checked(array.length) | 0 814 that = allocate(that, length) 815 // Truncating the elements is probably not what people expect from typed 816 // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior 817 // of the old Buffer constructor. 818 for (var i = 0; i < length; i += 1) { 819 that[i] = array[i] & 255 820 } 821 return that 822} 823 824function fromArrayBuffer (that, array) { 825 if (Buffer.TYPED_ARRAY_SUPPORT) { 826 // Return an augmented `Uint8Array` instance, for best performance 827 array.byteLength
828 that = Buffer._augment(new Uint8Array(array)) 829 } else { 830 // Fallback: Return an object instance of the Buffer class 831 that = fromTypedArray(that, new Uint8Array(array)) 832 } 833 return that 834} 835 836function fromArrayLike (that, array) { 837 var length = checked(array.length) | 0 838 that = allocate(that, length) 839 for (var i = 0; i < length; i += 1) { 840 that[i] = array[i] & 255 841 } 842 return that 843} 844 845// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. 846// Returns a zero-length buffer for inputs that don't conform to the spec. 847function fromJsonObject (that, object) { 848 var array 849 var length = 0 850 851 if (object.type === 'Buffer' && isArray(object.data)) { 852 array = object.data 853 length = checked(array.length) | 0 854 } 855 that = allocate(that, length) 856 857 for (var i = 0; i < length; i += 1) { 858 that[i] = array[i] & 255 859 } 860 return that 861} 862 863if (Buffer.TYPED_ARRAY_SUPPORT) { 864 Buffer.prototype.__proto__ = Uint8Array.prototype 865 Buffer.__proto__ = Uint8Array 866} else { 867 // pre-set for values that may exist in the future 868 Buffer.prototype.length = undefined 869 Buffer.prototype.parent = undefined 870} 871 872function allocate (that, length) { 873 if (Buffer.TYPED_ARRAY_SUPPORT) { 874 // Return an augmented `Uint8Array` instance, for best performance 875 that = Buffer._augment(new Uint8Array(length)) 876 that.__proto__ = Buffer.prototype 877 } else { 878 // Fallback: Return an object instance of the Buffer class 879 that.length = length 880 that._isBuffer = true 881 } 882 883 var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 884 if (fromPool) that.parent = rootParent 885 886 return that 887} 888 889function checked (length) { 890 // Note: cannot use `length < kMaxLength` here because that fails when 891 // length is NaN (which is otherwise coerced to zero.) 892 if (length >= kMaxLength()) { 893 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 894 'size: 0x' + kMaxLength().toString(16) + ' bytes') 895 } 896 return length | 0 897} 898 899function SlowBuffer (subject, encoding) { 900 if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) 901 902 var buf = new Buffer(subject, encoding) 903 delete buf.parent 904 return buf 905} 906 907Buffer.isBuffer = function isBuffer (b) { 908 return !!(b != null && b._isBuffer) 909} 910 911Buffer.compare = function compare (a, b) { 912 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { 913 throw new TypeError('Arguments must be Buffers') 914 } 915 916 if (a === b) return 0 917 918 var x = a.length 919 var y = b.length 920 921 var i = 0 922 var len = Math.min(x, y) 923 while (i < len) { 924 if (a[i] !== b[i]) break 925 926 ++i 927 } 928 929 if (i !== len) { 930 x = a[i] 931 y = b[i] 932 } 933 934 if (x < y) return -1 935 if (y < x) return 1 936 return 0 937} 938 939Buffer.isEncoding = function isEncoding (encoding) { 940 switch (String(encoding).toLowerCase()) { 941 case 'hex': 942 case 'utf8': 943 case 'utf-8': 944 case 'ascii': 945 case 'binary': 946 case 'base64': 947 case 'raw': 948 case 'ucs2': 949 case 'ucs-2': 950 case 'utf16le': 951 case 'utf-16le': 952 return true 953 default: 954 return false 955 } 956} 957 958Buffer.concat = function concat (list, length) { 959 if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') 960 961 if (list.length === 0) { 962 return new Buffer(0) 963 } 964 965 var i 966 if (length === undefined) { 967 length = 0 968 for (i = 0; i < list.length; i++) { 969 length += list[i].length 970 } 971 } 972 973 var buf = new Buffer(length) 974 var pos = 0 975 for (i = 0; i < list.length; i++) { 976 var item = list[i] 977 item.copy(buf, pos) 978 pos += item.length 979 } 980 return buf 981} 982 983function byteLength (string, encoding) { 984 if (typeof string !== 'string') string = '' + string 985 986 var len = string.length 987 if (len === 0) return 0 988 989 // Use a for loop to avoid recursion 990 var loweredCase = false 991 for (;;) { 992 switch (encoding) { 993 case 'ascii': 994 case 'binary': 995 // Deprecated 996 case 'raw': 997 case 'raws': 998 return len 999 case 'utf8': 1000 case 'utf-8': 1001 return utf8ToBytes(string).length 1002 case 'ucs2': 1003 case 'ucs-2': 1004 case 'utf16le': 1005 case 'utf-16le': 1006 return len * 2 1007 case 'hex': 1008 return len >>> 1 1009 case 'base64': 1010 return base64ToBytes(string).length 1011 default: 1012 if (loweredCase) return utf8ToBytes(string).length // assume utf8 1013 encoding = ('' + encoding).toLowerCase() 1014 loweredCase = true 1015 } 1016 } 1017} 1018Buffer.byteLength = byteLength 1019 1020function slowToString (encoding, start, end) { 1021 var loweredCase = false 1022 1023 start = start | 0 1024 end = end === undefined || end === Infinity ? this.length : end | 0 1025 1026 if (!encoding) encoding = 'utf8' 1027 if (start < 0) start = 0 1028 if (end > this.length) end = this.length 1029 if (end <= start) return '' 1030 1031 while (true) { 1032 switch (encoding) { 1033 case 'hex': 1034 return hexSlice(this, start, end) 1035 1036 case 'utf8': 1037 case 'utf-8': 1038 return utf8Slice(this, start, end) 1039 1040 case 'ascii': 1041 return asciiSlice(this, start, end) 1042 1043 case 'binary': 1044 return binarySlice(this, start, end) 1045 1046 case 'base64': 1047 return base64Slice(this, start, end) 1048 1049 case 'ucs2': 1050 case 'ucs-2': 1051 case 'utf16le': 1052 case 'utf-16le': 1053 return utf16leSlice(this, start, end) 1054 1055 default: 1056 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 1057 encoding = (encoding + '').toLowerCase() 1058 loweredCase = true 1059 } 1060 } 1061} 1062 1063Buffer.prototype.toString = function toString () { 1064 var length = this.length | 0 1065 if (length === 0) return '' 1066 if (arguments.length === 0) return utf8Slice(this, 0, length) 1067 return slowToString.apply(this, arguments) 1068} 1069 1070Buffer.prototype.equals = function equals (b) { 1071 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') 1072 if (this === b) return true 1073 return Buffer.compare(this, b) === 0 1074} 1075 1076Buffer.prototype.inspect = function inspect () { 1077 var str = ''
1078 var max = exports.INSPECT_MAX_BYTES 1079 if (this.length > 0) { 1080 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') 1081 if (this.length > max) str += ' ... ' 1082 } 1083 return '<Buffer ' + str + '>' 1084} 1085 1086Buffer.prototype.compare = function compare (b) { 1087 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') 1088 if (this === b) return 0 1089 return Buffer.compare(this, b) 1090} 1091 1092Buffer.prototype.indexOf = function indexOf (val, byteOffset) { 1093 if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff 1094 else if (byteOffset < -0x80000000) byteOffset = -0x80000000 1095 byteOffset >>= 0 1096 1097 if (this.length === 0) return -1 1098 if (byteOffset >= this.length) return -1 1099 1100 // Negative offsets start from the end of the buffer 1101 if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) 1102 1103 if (typeof val === 'string') { 1104 if (val.length === 0) return -1 // special case: looking for empty string always fails 1105 return String.prototype.indexOf.call(this, val, byteOffset) 1106 } 1107 if (Buffer.isBuffer(val)) { 1108 return arrayIndexOf(this, val, byteOffset) 1109 } 1110 if (typeof val === 'number') { 1111 if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { 1112 return Uint8Array.prototype.indexOf.call(this, val, byteOffset) 1113 } 1114 return arrayIndexOf(this, [ val ], byteOffset) 1115 } 1116 1117 function arrayIndexOf (arr, val, byteOffset) { 1118 var foundIndex = -1 1119 for (var i = 0; byteOffset + i < arr.length; i++) { 1120 if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { 1121 if (foundIndex === -1) foundIndex = i 1122 if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex 1123 } else { 1124 foundIndex = -1 1125 } 1126 } 1127 return -1 1128 } 1129 1130 throw new TypeError('val must be string, number or Buffer') 1131} 1132 1133// `get` is deprecated 1134Buffer.prototype.get = function get (offset) { 1135 console.log('.get() is deprecated. Access using array indexes instead.') 1136 return this.readUInt8(offset) 1137} 1138 1139// `set` is deprecated 1140Buffer.prototype.set = function set (v, offset) { 1141 console.log('.set() is deprecated. Access using array indexes instead.') 1142 return this.writeUInt8(v, offset) 1143} 1144 1145function hexWrite (buf, string, offset, length) { 1146 offset = Number(offset) || 0 1147 var remaining = buf.length - offset 1148 if (!length) { 1149 length = remaining 1150 } else { 1151 length = Number(length) 1152 if (length > remaining) { 1153 length = remaining 1154 } 1155 } 1156 1157 // must be an even number of digits 1158 var strLen = string.length 1159 if (strLen % 2 !== 0) throw new Error('Invalid hex string') 1160 1161 if (length > strLen / 2) { 1162 length = strLen / 2 1163 } 1164 for (var i = 0; i < length; i++) { 1165 var parsed = parseInt(string.substr(i * 2, 2), 16) 1166 if (isNaN(parsed)) throw new Error('Invalid hex string') 1167 buf[offset + i] = parsed 1168 } 1169 return i 1170} 1171 1172function utf8Write (buf, string, offset, length) { 1173 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) 1174} 1175 1176function asciiWrite (buf, string, offset, length) { 1177 return blitBuffer(asciiToBytes(string), buf, offset, length) 1178} 1179 1180function binaryWrite (buf, string, offset, length) { 1181 return asciiWrite(buf, string, offset, length) 1182} 1183 1184function base64Write (buf, string, offset, length) { 1185 return blitBuffer(base64ToBytes(string), buf, offset, length) 1186} 1187 1188function ucs2Write (buf, string, offset, length) { 1189 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) 1190} 1191 1192Buffer.prototype.write = function write (string, offset, length, encoding) { 1193 // Buffer#write(string) 1194 if (offset === undefined) { 1195 encoding = 'utf8' 1196 length = this.length 1197 offset = 0 1198 // Buffer#write(string, encoding) 1199 } else if (length === undefined && typeof offset === 'string') { 1200 encoding = offset 1201 length = this.length 1202 offset = 0 1203 // Buffer#write(string, offset[, length][, encoding]) 1204 } else if (isFinite(offset)) { 1205 offset = offset | 0 1206 if (isFinite(length)) { 1207 length = length | 0 1208 if (encoding === undefined) encoding = 'utf8' 1209 } else { 1210 encoding = length 1211 length = undefined 1212 } 1213 // legacy write(string, encoding, offset, length) - remove in v0.13 1214 } else { 1215 var swap = encoding 1216 encoding = offset 1217 offset = length | 0 1218 length = swap 1219 } 1220 1221 var remaining = this.length - offset 1222 if (length === undefined || length > remaining) length = remaining 1223 1224 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { 1225 throw new RangeError('attempt to write outside buffer bounds') 1226 } 1227 1228 if (!encoding) encoding = 'utf8' 1229 1230 var loweredCase = false 1231 for (;;) { 1232 switch (encoding) { 1233 case 'hex': 1234 return hexWrite(this, string, offset, length) 1235 1236 case 'utf8': 1237 case 'utf-8': 1238 return utf8Write(this, string, offset, length) 1239 1240 case 'ascii': 1241 return asciiWrite(this, string, offset, length) 1242 1243 case 'binary': 1244 return binaryWrite(this, string, offset, length) 1245 1246 case 'base64': 1247 // Warning: maxLength not taken into account in base64Write 1248 return base64Write(this, string, offset, length) 1249 1250 case 'ucs2': 1251 case 'ucs-2': 1252 case 'utf16le': 1253 case 'utf-16le': 1254 return ucs2Write(this, string, offset, length) 1255 1256 default: 1257 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 1258 encoding = ('' + encoding).toLowerCase() 1259 loweredCase = true 1260 } 1261 } 1262} 1263 1264Buffer.prototype.toJSON = function toJSON () { 1265 return { 1266 type: 'Buffer', 1267 data: Array.prototype.slice.call(this._arr || this, 0) 1268 } 1269} 1270 1271function base64Slice (buf, start, end) { 1272 if (start === 0 && end === buf.length) { 1273 return base64.fromByteArray(buf) 1274 } else { 1275 return base64.fromByteArray(buf.slice(start, end)) 1276 } 1277} 1278 1279function utf8Slice (buf, start, end) { 1280 end = Math.min(buf.length, end) 1281 var res = [] 1282 1283 var i = start 1284 while (i < end) { 1285 var firstByte = buf[i] 1286 var codePoint = null 1287 var bytesPerSequence = (firstByte > 0xEF) ? 4 1288 : (firstByte > 0xDF) ? 3 1289 : (firstByte > 0xBF) ? 2 1290 : 1 1291 1292 if (i + bytesPerSequence <= end) { 1293 var secondByte, thirdByte, fourthByte, tempCodePoint 1294 1295 switch (bytesPerSequence) { 1296 case 1: 1297 if (firstByte < 0x80) { 1298 codePoint = firstByte 1299 } 1300 break 1301 case 2: 1302 secondByte = buf[i + 1] 1303 if ((secondByte & 0xC0) === 0x80) { 1304 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) 1305 if (tempCodePoint > 0x7F) { 1306 codePoint = tempCodePoint 1307 } 1308 } 1309 break 1310 case 3: 1311 secondByte = buf[i + 1] 1312 thirdByte = buf[i + 2] 1313 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 1314 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) 1315 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 1316 codePoint = tempCodePoint 1317 } 1318 } 1319 break 1320 case 4: 1321 secondByte = buf[i + 1] 1322 thirdByte = buf[i + 2] 1323 fourthByte = buf[i + 3] 1324 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 1325 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) 1326 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 1327 codePoint = tempCodePoint 1328 } 1329 } 1330 } 1331 } 1332 1333 if (codePoint === null) { 1334 // we did not generate a valid codePoint so insert a 1335 // replacement char (U+FFFD) and advance only 1 byte 1336 codePoint = 0xFFFD 1337 bytesPerSequence = 1 1338 } else if (codePoint > 0xFFFF) { 1339 // encode to utf16 (surrogate pair dance) 1340 codePoint -= 0x10000 1341 res.push(codePoint >>>
vendor: 2,464 bytes, lines 1341-1456
1341 10 & 0x3FF | 0xD800) 1342 codePoint = 0xDC00 | codePoint & 0x3FF 1343 } 1344 1345 res.push(codePoint) 1346 i += bytesPerSequence 1347 } 1348 1349 return decodeCodePointsArray(res) 1350} 1351 1352// Based on http://stackoverflow.com/a/22747272/680742, the browser with 1353// the lowest limit is Chrome, with 0x10000 args. 1354// We go 1 magnitude less, for safety 1355var MAX_ARGUMENTS_LENGTH = 0x1000 1356 1357function decodeCodePointsArray (codePoints) { 1358 var len = codePoints.length 1359 if (len <= MAX_ARGUMENTS_LENGTH) { 1360 return String.fromCharCode.apply(String, codePoints) // avoid extra slice() 1361 } 1362 1363 // Decode in chunks to avoid "call stack size exceeded". 1364 var res = '' 1365 var i = 0 1366 while (i < len) { 1367 res += String.fromCharCode.apply( 1368 String, 1369 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) 1370 ) 1371 } 1372 return res 1373} 1374 1375function asciiSlice (buf, start, end) { 1376 var ret = '' 1377 end = Math.min(buf.length, end) 1378 1379 for (var i = start; i < end; i++) { 1380 ret += String.fromCharCode(buf[i] & 0x7F) 1381 } 1382 return ret 1383} 1384 1385function binarySlice (buf, start, end) { 1386 var ret = '' 1387 end = Math.min(buf.length, end) 1388 1389 for (var i = start; i < end; i++) { 1390 ret += String.fromCharCode(buf[i]) 1391 } 1392 return ret 1393} 1394 1395function hexSlice (buf, start, end) { 1396 var len = buf.length 1397 1398 if (!start || start < 0) start = 0 1399 if (!end || end < 0 || end > len) end = len 1400 1401 var out = '' 1402 for (var i = start; i < end; i++) { 1403 out += toHex(buf[i]) 1404 } 1405 return out 1406} 1407 1408function utf16leSlice (buf, start, end) { 1409 var bytes = buf.slice(start, end) 1410 var res = '' 1411 for (var i = 0; i < bytes.length; i += 2) { 1412 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) 1413 } 1414 return res 1415} 1416 1417Buffer.prototype.slice = function slice (start, end) { 1418 var len = this.length 1419 start = ~~start 1420 end = end === undefined ? len : ~~end 1421 1422 if (start < 0) { 1423 start += len 1424 if (start < 0) start = 0 1425 } else if (start > len) { 1426 start = len 1427 } 1428 1429 if (end < 0) { 1430 end += len 1431 if (end < 0) end = 0 1432 } else if (end > len) { 1433 end = len 1434 } 1435 1436 if (end < start) end = start 1437 1438 var newBuf 1439 if (Buffer.TYPED_ARRAY_SUPPORT) { 1440 newBuf = Buffer._augment(this.subarray(start, end)) 1441 } else { 1442 var sliceLen = end - start 1443 newBuf = new Buffer(sliceLen, undefined) 1444 for (var i = 0; i < sliceLen; i++) { 1445 newBuf[i] = this[i + start] 1446 } 1447 } 1448 1449 if (newBuf.length) newBuf.parent = this.parent || this 1450 1451 return newBuf 1452} 1453 1454/* 1455 * Need to make sure that buffer isn't trying to write out of bounds. 1456 */
vendor: 9,737 bytes, lines 1457-1785
1457function checkOffset (offset, ext, length) { 1458 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') 1459 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') 1460} 1461 1462Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { 1463 offset = offset | 0 1464 byteLength = byteLength | 0 1465 if (!noAssert) checkOffset(offset, byteLength, this.length) 1466 1467 var val = this[offset] 1468 var mul = 1 1469 var i = 0 1470 while (++i < byteLength && (mul *= 0x100)) { 1471 val += this[offset + i] * mul 1472 } 1473 1474 return val 1475} 1476 1477Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { 1478 offset = offset | 0 1479 byteLength = byteLength | 0 1480 if (!noAssert) { 1481 checkOffset(offset, byteLength, this.length) 1482 } 1483 1484 var val = this[offset + --byteLength] 1485 var mul = 1 1486 while (byteLength > 0 && (mul *= 0x100)) { 1487 val += this[offset + --byteLength] * mul 1488 } 1489 1490 return val 1491} 1492 1493Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { 1494 if (!noAssert) checkOffset(offset, 1, this.length) 1495 return this[offset] 1496} 1497 1498Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { 1499 if (!noAssert) checkOffset(offset, 2, this.length) 1500 return this[offset] | (this[offset + 1] << 8) 1501} 1502 1503Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { 1504 if (!noAssert) checkOffset(offset, 2, this.length) 1505 return (this[offset] << 8) | this[offset + 1] 1506} 1507 1508Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { 1509 if (!noAssert) checkOffset(offset, 4, this.length) 1510 1511 return ((this[offset]) | 1512 (this[offset + 1] << 8) | 1513 (this[offset + 2] << 16)) + 1514 (this[offset + 3] * 0x1000000) 1515} 1516 1517Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { 1518 if (!noAssert) checkOffset(offset, 4, this.length) 1519 1520 return (this[offset] * 0x1000000) + 1521 ((this[offset + 1] << 16) | 1522 (this[offset + 2] << 8) | 1523 this[offset + 3]) 1524} 1525 1526Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { 1527 offset = offset | 0 1528 byteLength = byteLength | 0 1529 if (!noAssert) checkOffset(offset, byteLength, this.length) 1530 1531 var val = this[offset] 1532 var mul = 1 1533 var i = 0 1534 while (++i < byteLength && (mul *= 0x100)) { 1535 val += this[offset + i] * mul 1536 } 1537 mul *= 0x80 1538 1539 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 1540 1541 return val 1542} 1543 1544Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { 1545 offset = offset | 0 1546 byteLength = byteLength | 0 1547 if (!noAssert) checkOffset(offset, byteLength, this.length) 1548 1549 var i = byteLength 1550 var mul = 1 1551 var val = this[offset + --i] 1552 while (i > 0 && (mul *= 0x100)) { 1553 val += this[offset + --i] * mul 1554 } 1555 mul *= 0x80 1556 1557 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 1558 1559 return val 1560} 1561 1562Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { 1563 if (!noAssert) checkOffset(offset, 1, this.length) 1564 if (!(this[offset] & 0x80)) return (this[offset]) 1565 return ((0xff - this[offset] + 1) * -1) 1566} 1567 1568Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { 1569 if (!noAssert) checkOffset(offset, 2, this.length) 1570 var val = this[offset] | (this[offset + 1] << 8) 1571 return (val & 0x8000) ? val | 0xFFFF0000 : val 1572} 1573 1574Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { 1575 if (!noAssert) checkOffset(offset, 2, this.length) 1576 var val = this[offset + 1] | (this[offset] << 8) 1577 return (val & 0x8000) ? val | 0xFFFF0000 : val 1578} 1579 1580Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { 1581 if (!noAssert) checkOffset(offset, 4, this.length) 1582 1583 return (this[offset]) | 1584 (this[offset + 1] << 8) | 1585 (this[offset + 2] << 16) | 1586 (this[offset + 3] << 24) 1587} 1588 1589Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { 1590 if (!noAssert) checkOffset(offset, 4, this.length) 1591 1592 return (this[offset] << 24) | 1593 (this[offset + 1] << 16) | 1594 (this[offset + 2] << 8) | 1595 (this[offset + 3]) 1596} 1597 1598Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { 1599 if (!noAssert) checkOffset(offset, 4, this.length) 1600 return ieee754.read(this, offset, true, 23, 4) 1601} 1602 1603Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { 1604 if (!noAssert) checkOffset(offset, 4, this.length) 1605 return ieee754.read(this, offset, false, 23, 4) 1606} 1607 1608Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { 1609 if (!noAssert) checkOffset(offset, 8, this.length) 1610 return ieee754.read(this, offset, true, 52, 8) 1611} 1612 1613Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { 1614 if (!noAssert) checkOffset(offset, 8, this.length) 1615 return ieee754.read(this, offset, false, 52, 8) 1616} 1617 1618function checkInt (buf, value, offset, ext, max, min) { 1619 if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') 1620 if (value > max || value < min) throw new RangeError('value is out of bounds') 1621 if (offset + ext > buf.length) throw new RangeError('index out of range') 1622} 1623 1624Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { 1625 value = +value 1626 offset = offset | 0 1627 byteLength = byteLength | 0 1628 if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) 1629 1630 var mul = 1 1631 var i = 0 1632 this[offset] = value & 0xFF 1633 while (++i < byteLength && (mul *= 0x100)) { 1634 this[offset + i] = (value / mul) & 0xFF 1635 } 1636 1637 return offset + byteLength 1638} 1639 1640Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { 1641 value = +value 1642 offset = offset | 0 1643 byteLength = byteLength | 0 1644 if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) 1645 1646 var i = byteLength - 1 1647 var mul = 1 1648 this[offset + i] = value & 0xFF 1649 while (--i >= 0 && (mul *= 0x100)) { 1650 this[offset + i] = (value / mul) & 0xFF 1651 } 1652 1653 return offset + byteLength 1654} 1655 1656Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { 1657 value = +value 1658 offset = offset | 0 1659 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) 1660 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 1661 this[offset] = (value & 0xff) 1662 return offset + 1 1663} 1664 1665function objectWriteUInt16 (buf, value, offset, littleEndian) { 1666 if (value < 0) value = 0xffff + value + 1 1667 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { 1668 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> 1669 (littleEndian ? i : 1 - i) * 8 1670 } 1671} 1672 1673Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { 1674 value = +value 1675 offset = offset | 0 1676 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 1677 if (Buffer.TYPED_ARRAY_SUPPORT) { 1678 this[offset] = (value & 0xff) 1679 this[offset + 1] = (value >>> 8) 1680 } else { 1681 objectWriteUInt16(this, value, offset, true) 1682 } 1683 return offset + 2 1684} 1685 1686Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { 1687 value = +value 1688 offset = offset | 0 1689 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 1690 if (Buffer.TYPED_ARRAY_SUPPORT) { 1691 this[offset] = (value >>> 8) 1692 this[offset + 1] = (value & 0xff) 1693 } else { 1694 objectWriteUInt16(this, value, offset, false) 1695 } 1696 return offset + 2 1697} 1698 1699function objectWriteUInt32 (buf, value, offset, littleEndian) { 1700 if (value < 0) value = 0xffffffff + value + 1 1701 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { 1702 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff 1703 } 1704} 1705 1706Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { 1707 value = +value 1708 offset = offset | 0 1709 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 1710 if (Buffer.TYPED_ARRAY_SUPPORT) { 1711 this[offset + 3] = (value >>> 24) 1712 this[offset + 2] = (value >>> 16) 1713 this[offset + 1] = (value >>> 8) 1714 this[offset] = (value & 0xff) 1715 } else { 1716 objectWriteUInt32(this, value, offset, true) 1717 } 1718 return offset + 4 1719} 1720 1721Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { 1722 value = +value 1723 offset = offset | 0 1724 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 1725 if (Buffer.TYPED_ARRAY_SUPPORT) { 1726 this[offset] = (value >>> 24) 1727 this[offset + 1] = (value >>> 16) 1728 this[offset + 2] = (value >>> 8) 1729 this[offset + 3] = (value & 0xff) 1730 } else { 1731 objectWriteUInt32(this, value, offset, false) 1732 } 1733 return offset + 4 1734} 1735 1736Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { 1737 value = +value 1738 offset = offset | 0 1739 if (!noAssert) { 1740 var limit = Math.pow(2, 8 * byteLength - 1) 1741 1742 checkInt(this, value, offset, byteLength, limit - 1, -limit) 1743 } 1744 1745 var i = 0 1746 var mul = 1 1747 var sub = value < 0 ? 1 : 0 1748 this[offset] = value & 0xFF 1749 while (++i < byteLength && (mul *= 0x100)) { 1750 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 1751 } 1752 1753 return offset + byteLength 1754} 1755 1756Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { 1757 value = +value 1758 offset = offset | 0 1759 if (!noAssert) { 1760 var limit = Math.pow(2, 8 * byteLength - 1) 1761 1762 checkInt(this, value, offset, byteLength, limit - 1, -limit) 1763 } 1764 1765 var i = byteLength - 1 1766 var mul = 1 1767 var sub = value < 0 ? 1 : 0 1768 this[offset + i] = value & 0xFF 1769 while (--i >= 0 && (mul *= 0x100)) { 1770 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 1771 } 1772 1773 return offset + byteLength 1774} 1775 1776Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { 1777 value = +value 1778 offset = offset | 0 1779 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) 1780 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 1781 if (value < 0) value = 0xff + value + 1 1782 this[offset] = (value & 0xff) 1783 return offset + 1 1784} 1785
vendor: 4,133 bytes, lines 1786-1909
1786Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { 1787 value = +value 1788 offset = offset | 0 1789 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 1790 if (Buffer.TYPED_ARRAY_SUPPORT) { 1791 this[offset] = (value & 0xff) 1792 this[offset + 1] = (value >>> 8) 1793 } else { 1794 objectWriteUInt16(this, value, offset, true) 1795 } 1796 return offset + 2 1797} 1798 1799Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { 1800 value = +value 1801 offset = offset | 0 1802 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 1803 if (Buffer.TYPED_ARRAY_SUPPORT) { 1804 this[offset] = (value >>> 8) 1805 this[offset + 1] = (value & 0xff) 1806 } else { 1807 objectWriteUInt16(this, value, offset, false) 1808 } 1809 return offset + 2 1810} 1811 1812Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { 1813 value = +value 1814 offset = offset | 0 1815 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 1816 if (Buffer.TYPED_ARRAY_SUPPORT) { 1817 this[offset] = (value & 0xff) 1818 this[offset + 1] = (value >>> 8) 1819 this[offset + 2] = (value >>> 16) 1820 this[offset + 3] = (value >>> 24) 1821 } else { 1822 objectWriteUInt32(this, value, offset, true) 1823 } 1824 return offset + 4 1825} 1826 1827Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { 1828 value = +value 1829 offset = offset | 0 1830 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 1831 if (value < 0) value = 0xffffffff + value + 1 1832 if (Buffer.TYPED_ARRAY_SUPPORT) { 1833 this[offset] = (value >>> 24) 1834 this[offset + 1] = (value >>> 16) 1835 this[offset + 2] = (value >>> 8) 1836 this[offset + 3] = (value & 0xff) 1837 } else { 1838 objectWriteUInt32(this, value, offset, false) 1839 } 1840 return offset + 4 1841} 1842 1843function checkIEEE754 (buf, value, offset, ext, max, min) { 1844 if (value > max || value < min) throw new RangeError('value is out of bounds') 1845 if (offset + ext > buf.length) throw new RangeError('index out of range') 1846 if (offset < 0) throw new RangeError('index out of range') 1847} 1848 1849function writeFloat (buf, value, offset, littleEndian, noAssert) { 1850 if (!noAssert) { 1851 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) 1852 } 1853 ieee754.write(buf, value, offset, littleEndian, 23, 4) 1854 return offset + 4 1855} 1856 1857Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { 1858 return writeFloat(this, value, offset, true, noAssert) 1859} 1860 1861Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { 1862 return writeFloat(this, value, offset, false, noAssert) 1863} 1864 1865function writeDouble (buf, value, offset, littleEndian, noAssert) { 1866 if (!noAssert) { 1867 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) 1868 } 1869 ieee754.write(buf, value, offset, littleEndian, 52, 8) 1870 return offset + 8 1871} 1872 1873Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { 1874 return writeDouble(this, value, offset, true, noAssert) 1875} 1876 1877Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { 1878 return writeDouble(this, value, offset, false, noAssert) 1879} 1880 1881// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 1882Buffer.prototype.copy = function copy (target, targetStart, start, end) { 1883 if (!start) start = 0 1884 if (!end && end !== 0) end = this.length 1885 if (targetStart >= target.length) targetStart = target.length 1886 if (!targetStart) targetStart = 0 1887 if (end > 0 && end < start) end = start 1888 1889 // Copy 0 bytes; we're done 1890 if (end === start) return 0 1891 if (target.length === 0 || this.length === 0) return 0 1892 1893 // Fatal error conditions 1894 if (targetStart < 0) { 1895 throw new RangeError('targetStart out of bounds') 1896 } 1897 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') 1898 if (end < 0) throw new RangeError('sourceEnd out of bounds') 1899 1900 // Are we oob? 1901 if (end > this.length) end = this.length 1902 if (target.length - targetStart < end - start) { 1903 end = target.length - targetStart + start 1904 } 1905 1906 var len = end - start 1907 var i 1908 1909 if (this === target && start < targetStart && targetStart < end) {
1910 // descending copy from end 1911 for (i = len - 1; i >= 0; i--) { 1912 target[i + targetStart] = this[i + start] 1913 } 1914 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { 1915 // ascending copy from start 1916 for (i = 0; i < len; i++) { 1917 target[i + targetStart] = this[i + start] 1918 } 1919 } else { 1920 target._set(this.subarray(start, start + len), targetStart) 1921 } 1922 1923 return len 1924} 1925 1926// fill(value, start=0, end=buffer.length) 1927Buffer.prototype.fill = function fill (value, start, end) { 1928 if (!value) value = 0 1929 if (!start) start = 0 1930 if (!end) end = this.length 1931 1932 if (end < start) throw new RangeError('end < start') 1933 1934 // Fill 0 bytes; we're done 1935 if (end === start) return 1936 if (this.length === 0) return 1937 1938 if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') 1939 if (end < 0 || end > this.length) throw new RangeError('end out of bounds') 1940 1941 var i 1942 if (typeof value === 'number') { 1943 for (i = start; i < end; i++) { 1944 this[i] = value 1945 } 1946 } else { 1947 var bytes = utf8ToBytes(value.toString()) 1948 var len = bytes.length 1949 for (i = start; i < end; i++) { 1950 this[i] = bytes[i % len] 1951 } 1952 } 1953 1954 return this 1955} 1956 1957/** 1958 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. 1959 * Added in Node 0.12. Only available in browsers that support ArrayBuffer. 1960 */ 1961Buffer.prototype.toArrayBuffer = function toArrayBuffer () { 1962 if (typeof Uint8Array !== 'undefined') { 1963 if (Buffer.TYPED_ARRAY_SUPPORT) { 1964 return (new Buffer(this)).buffer 1965 } else { 1966 var buf = new Uint8Array(this.length) 1967 for (var i = 0, len = buf.length; i < len; i += 1) { 1968 buf[i] = this[i] 1969 } 1970 return buf.buffer 1971 } 1972 } else { 1973 throw new TypeError('Buffer.toArrayBuffer not supported in this browser') 1974 } 1975} 1976 1977// HELPER FUNCTIONS 1978// ================ 1979 1980var BP = Buffer.prototype 1981 1982/** 1983 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods 1984 */ 1985Buffer._augment = function _augment (arr) { 1986 arr.constructor = Buffer 1987 arr._isBuffer = true 1988 1989 // save reference to original Uint8Array set method before overwriting 1990 arr._set = arr.set 1991 1992 // deprecated 1993 arr.get = BP.get 1994 arr.set = BP.set 1995 1996 arr.write = BP.write 1997 arr.toString = BP.toString 1998 arr.toLocaleString = BP.toString 1999 arr.toJSON = BP.toJSON 2000 arr.equals = BP.equals 2001 arr.compare = BP.compare 2002 arr.indexOf = BP.indexOf 2003 arr.copy = BP.copy 2004 arr.slice = BP.slice 2005 arr.readUIntLE = BP.readUIntLE 2006 arr.readUIntBE = BP.readUIntBE 2007 arr.readUInt8 = BP.readUInt8 2008 arr.readUInt16LE = BP.readUInt16LE 2009 arr.readUInt16BE = BP.readUInt16BE 2010 arr.readUInt32LE = BP.readUInt32LE 2011 arr.readUInt32BE = BP.readUInt32BE 2012 arr.readIntLE = BP.readIntLE 2013 arr.readIntBE = BP.readIntBE 2014 arr.readInt8 = BP.readInt8 2015 arr.readInt16LE = BP.readInt16LE 2016 arr.readInt16BE = BP.readInt16BE 2017 arr.readInt32LE = BP.readInt32LE 2018 arr.readInt32BE = BP.readInt32BE 2019 arr.readFloatLE = BP.readFloatLE 2020 arr.readFloatBE = BP.readFloatBE 2021 arr.readDoubleLE = BP.readDoubleLE 2022 arr.readDoubleBE = BP.readDoubleBE 2023 arr.writeUInt8 = BP.writeUInt8 2024 arr.writeUIntLE = BP.writeUIntLE 2025 arr.writeUIntBE = BP.writeUIntBE 2026 arr.writeUInt16LE = BP.writeUInt16LE 2027 arr.writeUInt16BE = BP.writeUInt16BE 2028 arr.writeUInt32LE = BP.writeUInt32LE 2029 arr.writeUInt32BE = BP.writeUInt32BE 2030 arr.writeIntLE = BP.writeIntLE 2031 arr.writeIntBE = BP.writeIntBE 2032 arr.writeInt8 = BP.writeInt8 2033 arr.writeInt16LE = BP.writeInt16LE 2034 arr.writeInt16BE = BP.writeInt16BE 2035 arr.writeInt32LE = BP.writeInt32LE 2036 arr.writeInt32BE = BP.writeInt32BE 2037 arr.writeFloatLE = BP.writeFloatLE 2038 arr.writeFloatBE = BP.writeFloatBE 2039 arr.writeDoubleLE = BP.writeDoubleLE 2040 arr.writeDoubleBE = BP.writeDoubleBE 2041 arr.fill = BP.fill 2042 arr.inspect = BP.inspect 2043 arr.toArrayBuffer = BP.toArrayBuffer 2044 2045 return arr 2046} 2047 2048var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g 2049 2050function base64clean (str) { 2051 // Node strips out invalid characters like \n and \t from the string, base64-js does not 2052 str = stringtrim(str).replace(INVALID_BASE64_RE, '') 2053 // Node converts strings with length < 2 to '' 2054 if (str.length < 2) return '' 2055 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 2056 while (str.length % 4 !== 0) { 2057 str = str + '=' 2058 } 2059 return str 2060} 2061 2062function stringtrim (str) { 2063 if (str.trim) return str.trim() 2064 return str.replace(/^\s+|\s+$/g, '') 2065} 2066 2067function toHex (n) { 2068 if (n < 16) return '0' + n.toString(16) 2069 return n.toString(16) 2070} 2071 2072function utf8ToBytes (string, units) { 2073 units = units || Infinity 2074 var codePoint 2075 var length = string.length 2076 var leadSurrogate = null 2077 var bytes = [] 2078 2079 for (var i = 0; i < length; i++) { 2080 codePoint = string.charCodeAt(i) 2081 2082 // is surrogate component 2083 if (codePoint > 0xD7FF && codePoint < 0xE000) { 2084 // last char was a lead 2085 if (!leadSurrogate) { 2086 // no lead yet 2087 if (codePoint > 0xDBFF) { 2088 // unexpected trail 2089 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 2090 continue 2091 } else if (i + 1 === length) { 2092 // unpaired lead 2093 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 2094 continue 2095 } 2096 2097 // valid lead 2098 leadSurrogate = codePoint 2099 2100 continue 2101 } 2102 2103 // 2 leads in a row 2104 if (codePoint < 0xDC00) { 2105 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 2106 leadSurrogate = codePoint 2107 continue 2108 } 2109 2110 // valid surrogate pair 2111 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 2112 } else if (leadSurrogate) { 2113 // valid bmp char, but last char was a lead 2114 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 2115 } 2116 2117 leadSurrogate = null 2118 2119 // encode utf8 2120 if (codePoint < 0x80) { 2121 if ((units -= 1) < 0) break 2122 bytes.push(codePoint) 2123 } else if (codePoint < 0x800) { 2124 if ((units -= 2) < 0) break 2125 bytes.push( 2126 codePoint >> 0x6 | 0xC0,
2127 codePoint & 0x3F | 0x80 2128 ) 2129 } else if (codePoint < 0x10000) { 2130 if ((units -= 3) < 0) break 2131 bytes.push( 2132 codePoint >> 0xC | 0xE0, 2133 codePoint >> 0x6 & 0x3F | 0x80, 2134 codePoint & 0x3F | 0x80 2135 ) 2136 } else if (codePoint < 0x110000) { 2137 if ((units -= 4) < 0) break 2138 bytes.push( 2139 codePoint >> 0x12 | 0xF0, 2140 codePoint >> 0xC & 0x3F | 0x80, 2141 codePoint >> 0x6 & 0x3F | 0x80, 2142 codePoint & 0x3F | 0x80 2143 ) 2144 } else { 2145 throw new Error('Invalid code point') 2146 } 2147 } 2148 2149 return bytes 2150} 2151 2152function asciiToBytes (str) { 2153 var byteArray = [] 2154 for (var i = 0; i < str.length; i++) { 2155 // Node's code seems to be doing this and not & 0x7F.. 2156 byteArray.push(str.charCodeAt(i) & 0xFF) 2157 } 2158 return byteArray 2159} 2160 2161function utf16leToBytes (str, units) { 2162 var c, hi, lo 2163 var byteArray = [] 2164 for (var i = 0; i < str.length; i++) { 2165 if ((units -= 2) < 0) break 2166 2167 c = str.charCodeAt(i) 2168 hi = c >> 8 2169 lo = c % 256 2170 byteArray.push(lo) 2171 byteArray.push(hi) 2172 } 2173 2174 return byteArray 2175} 2176 2177function base64ToBytes (str) { 2178 return base64.toByteArray(base64clean(str)) 2179} 2180 2181function blitBuffer (src, dst, offset, length) { 2182 for (var i = 0; i < length; i++) { 2183 if ((i + offset >= dst.length) || (i >= src.length)) break 2184 dst[i + offset] = src[i] 2185 } 2186 return i 2187} 2188 2189}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2190},{"base64-js":1,"ieee754":7,"isarray":4}],4:[function(require,module,exports){ 2191var toString = {}.toString; 2192 2193module.exports = Array.isArray || function (arr) { 2194 return toString.call(arr) == '[object Array]'; 2195}; 2196 2197},{}],5:[function(require,module,exports){ 2198 2199/// Serialize the a name value pair into a cookie string suitable for 2200/// http headers. An optional options object specified cookie parameters 2201/// 2202/// serialize('foo', 'bar', { httpOnly: true }) 2203/// => "foo=bar; httpOnly" 2204/// 2205/// @param {String} name 2206/// @param {String} val 2207/// @param {Object} options 2208/// @return {String} 2209var serialize = function(name, val, opt){ 2210 opt = opt || {}; 2211 var enc = opt.encode || encode; 2212 var pairs = [name + '=' + enc(val)]; 2213 2214 if (opt.maxAge) pairs.push('Max-Age=' + opt.maxAge); 2215 if (opt.domain) pairs.push('Domain=' + opt.domain); 2216 if (opt.path) pairs.push('Path=' + opt.path); 2217 if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString()); 2218 if (opt.httpOnly) pairs.push('HttpOnly'); 2219 if (opt.secure) pairs.push('Secure'); 2220 2221 return pairs.join('; '); 2222}; 2223 2224var regexTrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; 2225var trim = function (str){ 2226 if(str.trim){ 2227 return str.trim(); 2228 } 2229 return str.replace(regexTrim, ""); 2230} 2231 2232/// Parse the given cookie header string into an object 2233/// The object has the various cookies as keys(names) => values 2234/// @param {String} str 2235/// @return {Object} 2236var parse = function(str, opt) { 2237 opt = opt || {}; 2238 var obj = {} 2239 var pairs = str.split(/[;,] */); 2240 var dec = opt.decode || decode; 2241 2242 var len = pairs.length; 2243 for(var i = 0; i < len ; i++){ 2244 var pair = pairs[i]; 2245 var eq_idx = pair.indexOf('=') 2246 2247 // skip things that don't look like key=value 2248 if (eq_idx < 0) { 2249 continue; 2250 } 2251 2252 var key = trim(pair.substr(0, eq_idx)); 2253 var val = trim(pair.substr(++eq_idx, pair.length)); 2254 2255 // quoted values 2256 if ('"' == val[0]) { 2257 val = val.slice(1, -1); 2258 } 2259 2260 // only assign once 2261 if (undefined == obj[key]) { 2262 try { 2263 obj[key] = dec(val); 2264 } catch (e) { 2265 obj[key] = val; 2266 } 2267 } 2268 }; 2269 2270 return obj; 2271}; 2272 2273var encode = encodeURIComponent; 2274var decode = decodeURIComponent; 2275 2276module.exports.serialize = serialize; 2277module.exports.parse = parse; 2278 2279},{}],6:[function(require,module,exports){ 2280// Copyright Joyent, Inc. and other Node contributors. 2281// 2282// Permission is hereby granted, free of charge, to any person obtaining a 2283// copy of this software and associated documentation files (the 2284// "Software"), to deal in the Software without restriction, including 2285// without limitation the rights to use, copy, modify, merge, publish, 2286// distribute, sublicense, and/or sell copies of the Software, and to permit 2287// persons to whom the Software is furnished to do so, subject to the 2288// following conditions: 2289// 2290// The above copyright notice and this permission notice shall be included 2291// in all copies or substantial portions of the Software. 2292// 2293// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 2294// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2295// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 2296// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 2297// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 2298// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 2299// USE OR OTHER DEALINGS IN THE SOFTWARE. 2300 2301function EventEmitter() { 2302 this._events = this._events || {}; 2303 this._maxListeners = this._maxListeners || undefined; 2304} 2305module.exports = EventEmitter; 2306 2307// Backwards-compat with node 0.10.x 2308EventEmitter.EventEmitter = EventEmitter; 2309 2310EventEmitter.prototype._events = undefined; 2311EventEmitter.prototype._maxListeners = undefined; 2312 2313// By default EventEmitters will print a warning if more than 10 listeners are 2314// added to it. This is a useful default which helps finding memory leaks. 2315EventEmitter.defaultMaxListeners = 10; 2316 2317// Obviously not all Emitters should be limited to 10. This function allows 2318// that to be increased. Set to zero for unlimited. 2319EventEmitter.prototype.setMaxListeners = function(n) { 2320 if (!isNumber(n) || n < 0 || isNaN(n)) 2321 throw TypeError('n must be a positive number'); 2322 this._maxListeners = n; 2323 return this; 2324}; 2325 2326EventEmitter.prototype.emit = function(type) { 2327 var er, handler, len, args, i, listeners; 2328 2329 if (!this._events) 2330 this._events = {}; 2331 2332 // If there is no 'error' event listener then throw. 2333 if (type === 'error') { 2334 if (!this._events.error || 2335 (isObject(this._events.error) && !this._events.error.length)) { 2336 er = arguments[1]; 2337 if (er instanceof Error) { 2338 throw er; // Unhandled 'error' event 2339 } 2340 throw TypeError('Uncaught, unspecified "error" event.'); 2341 } 2342 } 2343 2344 handler = this._events[type]; 2345 2346 if (isUndefined(handler)) 2347 return false;
vendor: 5,733 bytes, lines 2348-2582
2348 2349 if (isFunction(handler)) { 2350 switch (arguments.length) { 2351 // fast cases 2352 case 1: 2353 handler.call(this); 2354 break; 2355 case 2: 2356 handler.call(this, arguments[1]); 2357 break; 2358 case 3: 2359 handler.call(this, arguments[1], arguments[2]); 2360 break; 2361 // slower 2362 default: 2363 len = arguments.length; 2364 args = new Array(len - 1); 2365 for (i = 1; i < len; i++) 2366 args[i - 1] = arguments[i]; 2367 handler.apply(this, args); 2368 } 2369 } else if (isObject(handler)) { 2370 len = arguments.length; 2371 args = new Array(len - 1); 2372 for (i = 1; i < len; i++) 2373 args[i - 1] = arguments[i]; 2374 2375 listeners = handler.slice(); 2376 len = listeners.length; 2377 for (i = 0; i < len; i++) 2378 listeners[i].apply(this, args); 2379 } 2380 2381 return true; 2382}; 2383 2384EventEmitter.prototype.addListener = function(type, listener) { 2385 var m; 2386 2387 if (!isFunction(listener)) 2388 throw TypeError('listener must be a function'); 2389 2390 if (!this._events) 2391 this._events = {}; 2392 2393 // To avoid recursion in the case that type === "newListener"! Before 2394 // adding it to the listeners, first emit "newListener". 2395 if (this._events.newListener) 2396 this.emit('newListener', type, 2397 isFunction(listener.listener) ? 2398 listener.listener : listener); 2399 2400 if (!this._events[type]) 2401 // Optimize the case of one listener. Don't need the extra array object. 2402 this._events[type] = listener; 2403 else if (isObject(this._events[type])) 2404 // If we've already got an array, just append. 2405 this._events[type].push(listener); 2406 else 2407 // Adding the second element, need to change to array. 2408 this._events[type] = [this._events[type], listener]; 2409 2410 // Check for listener leak 2411 if (isObject(this._events[type]) && !this._events[type].warned) { 2412 var m; 2413 if (!isUndefined(this._maxListeners)) { 2414 m = this._maxListeners; 2415 } else { 2416 m = EventEmitter.defaultMaxListeners; 2417 } 2418 2419 if (m && m > 0 && this._events[type].length > m) { 2420 this._events[type].warned = true; 2421 console.error('(node) warning: possible EventEmitter memory ' + 2422 'leak detected. %d listeners added. ' + 2423 'Use emitter.setMaxListeners() to increase limit.', 2424 this._events[type].length); 2425 if (typeof console.trace === 'function') { 2426 // not supported in IE 10 2427 console.trace(); 2428 } 2429 } 2430 } 2431 2432 return this; 2433}; 2434 2435EventEmitter.prototype.on = EventEmitter.prototype.addListener; 2436 2437EventEmitter.prototype.once = function(type, listener) { 2438 if (!isFunction(listener)) 2439 throw TypeError('listener must be a function'); 2440 2441 var fired = false; 2442 2443 function g() { 2444 this.removeListener(type, g); 2445 2446 if (!fired) { 2447 fired = true; 2448 listener.apply(this, arguments); 2449 } 2450 } 2451 2452 g.listener = listener; 2453 this.on(type, g); 2454 2455 return this; 2456}; 2457 2458// emits a 'removeListener' event iff the listener was removed 2459EventEmitter.prototype.removeListener = function(type, listener) { 2460 var list, position, length, i; 2461 2462 if (!isFunction(listener)) 2463 throw TypeError('listener must be a function'); 2464 2465 if (!this._events || !this._events[type]) 2466 return this; 2467 2468 list = this._events[type]; 2469 length = list.length; 2470 position = -1; 2471 2472 if (list === listener || 2473 (isFunction(list.listener) && list.listener === listener)) { 2474 delete this._events[type]; 2475 if (this._events.removeListener) 2476 this.emit('removeListener', type, listener); 2477 2478 } else if (isObject(list)) { 2479 for (i = length; i-- > 0;) { 2480 if (list[i] === listener || 2481 (list[i].listener && list[i].listener === listener)) { 2482 position = i; 2483 break; 2484 } 2485 } 2486 2487 if (position < 0) 2488 return this; 2489 2490 if (list.length === 1) { 2491 list.length = 0; 2492 delete this._events[type]; 2493 } else { 2494 list.splice(position, 1); 2495 } 2496 2497 if (this._events.removeListener) 2498 this.emit('removeListener', type, listener); 2499 } 2500 2501 return this; 2502}; 2503 2504EventEmitter.prototype.removeAllListeners = function(type) { 2505 var key, listeners; 2506 2507 if (!this._events) 2508 return this; 2509 2510 // not listening for removeListener, no need to emit 2511 if (!this._events.removeListener) { 2512 if (arguments.length === 0) 2513 this._events = {}; 2514 else if (this._events[type]) 2515 delete this._events[type]; 2516 return this; 2517 } 2518 2519 // emit removeListener for all listeners on all events 2520 if (arguments.length === 0) { 2521 for (key in this._events) { 2522 if (key === 'removeListener') continue; 2523 this.removeAllListeners(key); 2524 } 2525 this.removeAllListeners('removeListener'); 2526 this._events = {}; 2527 return this; 2528 } 2529 2530 listeners = this._events[type]; 2531 2532 if (isFunction(listeners)) { 2533 this.removeListener(type, listeners); 2534 } else { 2535 // LIFO order 2536 while (listeners.length) 2537 this.removeListener(type, listeners[listeners.length - 1]); 2538 } 2539 delete this._events[type]; 2540 2541 return this; 2542}; 2543 2544EventEmitter.prototype.listeners = function(type) { 2545 var ret; 2546 if (!this._events || !this._events[type]) 2547 ret = []; 2548 else if (isFunction(this._events[type])) 2549 ret = [this._events[type]]; 2550 else 2551 ret = this._events[type].slice(); 2552 return ret; 2553}; 2554 2555EventEmitter.listenerCount = function(emitter, type) { 2556 var ret; 2557 if (!emitter._events || !emitter._events[type]) 2558 ret = 0; 2559 else if (isFunction(emitter._events[type])) 2560 ret = 1; 2561 else 2562 ret = emitter._events[type].length; 2563 return ret; 2564}; 2565 2566function isFunction(arg) { 2567 return typeof arg === 'function'; 2568} 2569 2570function isNumber(arg) { 2571 return typeof arg === 'number'; 2572} 2573 2574function isObject(arg) { 2575 return typeof arg === 'object' && arg !== null; 2576} 2577 2578function isUndefined(arg) { 2579 return arg === void 0; 2580} 2581 2582},{}],7:[function(require,module,exports){
vendor: 3,098 bytes, lines 2583-2701
2583exports.read = function (buffer, offset, isLE, mLen, nBytes) { 2584 var e, m 2585 var eLen = (nBytes * 8) - mLen - 1 2586 var eMax = (1 << eLen) - 1 2587 var eBias = eMax >> 1 2588 var nBits = -7 2589 var i = isLE ? (nBytes - 1) : 0 2590 var d = isLE ? -1 : 1 2591 var s = buffer[offset + i] 2592 2593 i += d 2594 2595 e = s & ((1 << (-nBits)) - 1) 2596 s >>= (-nBits) 2597 nBits += eLen 2598 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} 2599 2600 m = e & ((1 << (-nBits)) - 1) 2601 e >>= (-nBits) 2602 nBits += mLen 2603 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} 2604 2605 if (e === 0) { 2606 e = 1 - eBias 2607 } else if (e === eMax) { 2608 return m ? NaN : ((s ? -1 : 1) * Infinity) 2609 } else { 2610 m = m + Math.pow(2, mLen) 2611 e = e - eBias 2612 } 2613 return (s ? -1 : 1) * m * Math.pow(2, e - mLen) 2614} 2615 2616exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { 2617 var e, m, c 2618 var eLen = (nBytes * 8) - mLen - 1 2619 var eMax = (1 << eLen) - 1 2620 var eBias = eMax >> 1 2621 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) 2622 var i = isLE ? 0 : (nBytes - 1) 2623 var d = isLE ? 1 : -1 2624 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 2625 2626 value = Math.abs(value) 2627 2628 if (isNaN(value) || value === Infinity) { 2629 m = isNaN(value) ? 1 : 0 2630 e = eMax 2631 } else { 2632 e = Math.floor(Math.log(value) / Math.LN2) 2633 if (value * (c = Math.pow(2, -e)) < 1) { 2634 e-- 2635 c *= 2 2636 } 2637 if (e + eBias >= 1) { 2638 value += rt / c 2639 } else { 2640 value += rt * Math.pow(2, 1 - eBias) 2641 } 2642 if (value * c >= 2) { 2643 e++ 2644 c /= 2 2645 } 2646 2647 if (e + eBias >= eMax) { 2648 m = 0 2649 e = eMax 2650 } else if (e + eBias >= 1) { 2651 m = ((value * c) - 1) * Math.pow(2, mLen) 2652 e = e + eBias 2653 } else { 2654 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) 2655 e = 0 2656 } 2657 } 2658 2659 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} 2660 2661 e = (e << mLen) | m 2662 eLen += mLen 2663 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} 2664 2665 buffer[offset + i - d] |= s * 128 2666} 2667 2668},{}],8:[function(require,module,exports){ 2669if (typeof Object.create === 'function') { 2670 // implementation from standard node.js 'util' module 2671 module.exports = function inherits(ctor, superCtor) { 2672 if (superCtor) { 2673 ctor.super_ = superCtor 2674 ctor.prototype = Object.create(superCtor.prototype, { 2675 constructor: { 2676 value: ctor, 2677 enumerable: false, 2678 writable: true, 2679 configurable: true 2680 } 2681 }) 2682 } 2683 }; 2684} else { 2685 // old school shim for old browsers 2686 module.exports = function inherits(ctor, superCtor) { 2687 if (superCtor) { 2688 ctor.super_ = superCtor 2689 var TempCtor = function () {} 2690 TempCtor.prototype = superCtor.prototype 2691 ctor.prototype = new TempCtor() 2692 ctor.prototype.constructor = ctor 2693 } 2694 } 2695} 2696 2697},{}],9:[function(require,module,exports){ 2698module.exports = require("./jquery.build.js"); 2699},{"./jquery.build.js":10}],10:[function(require,module,exports){ 2700/** 2701 * The JQuery.node plugin. A DOM builder in the spirit of the Scriptaculous
2702 * Builder.Node. 2703 * 2704 * Copyright (c) 2011 Ian Taylor 2705 * 2706 * Permission is hereby granted, free of charge, to any person obtaining a copy 2707 * of this software and associated documentation files (the "Software"), to deal 2708 * in the Software without restriction, including without limitation the rights 2709 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 2710 * copies of the Software, and to permit persons to whom the Software is 2711 * furnished to do so, subject to the following conditions: 2712 * 2713 * The above copyright notice and this permission notice shall be included in 2714 * all copies or substantial portions of the Software. 2715 * 2716 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2717 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2718 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2719 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2720 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2721 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2722 * SOFTWARE. 2723 */ 2724(function (){ 2725 var ctor = function ($, document){ 2726 /** Capability detection **/ 2727 2728 // IE Pre 9 has a weird bug with buttons and input tags that 2729 // causes it to throw exceptions when trying to set type 2730 // After the element has been created. 2731 var hasNormalInputButtonCreate = true; 2732 try{ 2733 var btn = document.createElement("button"); 2734 btn.type = "button"; 2735 } 2736 catch (e){ 2737 hasNormalInputButtonCreate = false; 2738 } 2739 //IE < 9 can't create stylesheets like normal elements, it has to use 2740 //a funky cssText property on its proprietary styleSheet object. 2741 var tempStyle = document.createElement("style"); 2742 tempStyle.type = "text/css"; 2743 var funkyStylesheetCreate = tempStyle.styleSheet && ('cssText' in tempStyle.styleSheet); 2744 2745 2746 //Many versions of IE will eat spaces off the front and back of text nodes 2747 var spaceTestElem = document.createElement("div"); 2748 spaceTestElem.innerHTML = " s "; 2749 var spaceTestValue = spaceTestElem.childNodes[0].nodeValue; 2750 var requiresLeadingSpace = spaceTestValue.indexOf(" ") != 0; 2751 var requiresTrailingSpace = spaceTestValue.lastIndexOf(" ") != 2; 2752 /** End Capability detection */ 2753 2754 /** Support functions */ 2755 2756 //Regex Caching 2757 var regexApos = /'/g; 2758 var regexLt = /</g; 2759 var regexGt = />/g; 2760 // These selector expressions were ripped from the Sizzle code. 2761 var elemExpr = /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/; 2762 var idExpr = /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/; 2763 var classExpr = /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/g; 2764 var attrExpr = /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/g; 2765 var attrPart = /[\[\]]/g; 2766 2767 2768 /** 2769 * Creates a shallow clone of an array. 2770 */ 2771 var arrayClone = function (arr){ 2772 var a = []; 2773 $.each(arr, function (i, o){a.push(o);}); 2774 return a; 2775 }; 2776 2777 var addHtmlTextToFrag = function (f, text){ 2778 2779 }; 2780 var addPlainTextToFrag = function (f, text){ 2781 if(requiresLeadingSpace && text.charAt(0) === " "){ 2782 f.appendChild(document.createTextNode(" ")); 2783 } 2784 f.appendChild(document.createTextNode(text)); 2785 if(requiresTrailingSpace && text.charAt(text.length -1) === " "){ 2786 f.appendChild(document.createTextNode(" ")); 2787 } 2788 }; 2789 2790 2791 var addFx = function (f, item){ 2792 if(!item){ 2793 return; 2794 } 2795 if (item.jquery){ 2796 f.appendChild(item.get(0)); 2797 } 2798 else if (item.nodeType == 1 || item.nodeType == 3 || item.nodeType == 11){ 2799 /* Element, Text, and DocumentFragment nodes get appended */ 2800 f.appendChild(item); 2801 } 2802 else if ($.isArray(item)){ 2803 var i = 0; 2804 var l = item.length; 2805 for(i = 0; i < l; i++){ 2806 addFx(f, item[i]); 2807 } 2808 } 2809 else{ 2810 addPlainTextToFrag(f, item.toString()); 2811 } 2812 }; 2813 /** 2814 * @function Allows you to create a new DocumentFragment node by passing in
2815 * jQuery objects, Dom Nodes, or text strings, either inside of an 2816 * array or as a single item. 2817 * 2818 * See: http://ejohn.org/blog/dom-documentfragments/ for more on why to use 2819 * documentfragments. 2820 */ 2821 var docFrag = function (children){ 2822 var f = document.createDocumentFragment(); 2823 if (children){ 2824 if ($.isArray(children)) { 2825 var i =0; 2826 var l = children.length; 2827 for(i = 0; i < l; i++){ 2828 addFx(f, children[i]); 2829 } 2830 } 2831 else { 2832 addFx(f,children); 2833 } 2834 } 2835 return f; 2836 }; 2837 2838 /** 2839 * @function This function converts a HTML string to a DocumentFragment. 2840 * It uses Element.innerHTML to do the parsing, so it's as fast as possible. 2841 * 2842 * Basically, if you want HTML to pass through $.build without it being HTMLEncoded, 2843 * you must wrap the text with a call to this function. 2844 * 2845 * 2846 * @example: 2847 * $.build("div", [ 2848 * $.build.html("This is a <em>HTML</em> string!"), 2849 * "This is a <em>Plain Text</em> string! 2850 * ]); 2851 * result: 2852 * <div> 2853 * This is a <em>HTML</em> string! 2854 * This is a <em>Plain Text</em> string! 2855 * </div> 2856 */ 2857 var html = function (text){ 2858 var f = document.createDocumentFragment(); 2859 if(text){ 2860 //Browsers/DOM impls supporting DocumentFragment.innerHTML get a fast track. 2861 if(typeof f.innerHTML != "undefined"){ 2862 f.innerHTML = text; 2863 }else{ 2864 var tempElem = document.createElement("div"); 2865 tempElem.innerHTML = text.replace(regexApos, "'"); 2866 if(requiresLeadingSpace && text.indexOf(" ") == 0){ 2867 f.appendChild(document.createTextNode(" ")); 2868 } 2869 while(tempElem.hasChildNodes()){ 2870 //appending to a new parent removes the item from the old parent, 2871 //thus this operation is safe and fast. 2872 f.appendChild(tempElem.firstChild); 2873 } 2874 if(requiresTrailingSpace && text.lastIndexOf(" ") == (text.length -1)){ 2875 f.appendChild(document.createTextNode(" ")); 2876 } 2877 } 2878 } 2879 return f; 2880 }; 2881 2882 /* End support functions */ 2883 2884 $.build = function (selector, attributes, children){ 2885 if(arguments.length == 2 && attributes!=null && 2886 (typeof attributes == "string" || $.isArray(attributes) || attributes.nodeType || attributes.jquery)){ 2887 children = attributes; 2888 attributes = null; 2889 } 2890 selector = selector || ""; 2891 2892 var elemTag; 2893 elemTag = selector.match(elemExpr); 2894 if(elemTag){ 2895 elemTag = elemTag[0]; 2896 } 2897 var id = null; 2898 if(selector.indexOf("#") != -1){ 2899 var id = selector.match(idExpr); 2900 if (id){ 2901 id = id[1]; 2902 } 2903 else{ 2904 id = null; 2905 } 2906 } 2907 var className; 2908 if(selector.indexOf(".") != -1){ 2909 className = selector.match(classExpr); 2910 } 2911 var attrs; 2912 if(selector.indexOf("[") != -1){ 2913 attrs = selector.match(attrExpr); 2914 } 2915 elemTag = elemTag || "div"; 2916 if (attrs){ 2917 attributes = attributes || {}; 2918 $.each(attrs, function (i, attr){ 2919 var parts = attr.replace(attrPart, "").split("="); 2920 if (parts && parts.length ==2){ 2921 attributes[parts[0]] = parts[1]; 2922 } 2923 }); 2924 } 2925 attributes = attributes || {}; 2926 var elem; 2927 if(!hasNormalInputButtonCreate && (elemTag === "input" || elemTag ==="button")){ 2928 // In IE versions before IE 9, an input or button type can only be set 2929 // once, at creation. If you try to set it 2930 // after the fact, you get exceptions 2931 var type = attributes.type ? "type=\""+attributes.type+"\"" : ""; 2932 // Name has to be set at creation time for radio buttons only, but 2933 // doesn't hurt for any other input/buttons. 2934 var name = attributes.name ? "name=\""+attributes.name+"\"" : ""; 2935 elem = document.createElement("<"+elemTag+" " +type+" " +name+">"); 2936 2937 delete attributes["type"]; 2938 delete attributes["name"]; 2939 } 2940 else{ 2941 elem = document.createElement(elemTag); 2942 } 2943 2944 var jqElem = $(elem); 2945 2946 // Set the attributes using jQuery. 2947 if(attributes){ 2948 jqElem.attr(attributes); 2949 } 2950 if(id){ 2951 elem.id = id; 2952 } 2953 2954 2955 if(elemTag === "img"){ 2956 // IE 8 bug with image elements in IE 8 standards mode. 2957 // IE 8 will automatically add in width and height attributes to 'help' 2958 // you if it has the image already in its cache. 2959 // in doing so, it craps up it's own rendering if there is a max-height 2960 // or max-width style applied. 2961 // we will remove any unrequested height and width attributes here. 2962 if(!attributes.width){ 2963 jqElem.removeAttr("width"); 2964 } 2965 if(!attributes.height){ 2966 jqElem.removeAttr("height"); 2967 } 2968 } 2969 if (className){ 2970 var cls =""; 2971 $.each(className, function (i, str) { cls+= str.replace(".", "") + " ";}); 2972 elem.className = $.trim(elem.className + " " + cls); 2973 } 2974 2975 if(funkyStylesheetCreate && elemTag == "style" && typeof children === "string"){ 2976 //IE < 9 has a weird implementation of stylesheets, 2977 //You can't just append a normal text node of styles to a style element, 2978 //You have to first give the stylesheet a type of "text/css", then add the string 2979 //as the cssText property. 2980 if(!jqElem.attr("type")){ 2981 jqElem.attr("type", "text/css"); 2982 } 2983 elem.styleSheet.cssText = children; 2984 }else if (children){ 2985 if(children.nodeType == 11) 2986 // Already a document fragment. 2987 elem.appendChild(children); 2988 else 2989 elem.appendChild(docFrag(children)); 2990 } 2991 return jqElem; 2992 }; 2993 2994 //expose docFrag and html children of $.build 2995 $.build.docFrag = docFrag; 2996 $.build.html = html; 2997 return $.build; 2998 }; 2999 3000 if(typeof module !== "undefined" && module.exports){ 3001 module.exports = ctor; 3002 } 3003 if(typeof window !== "undefined" && window.jQuery && window.document) { 3004 ctor(window.jQuery, window.document); 3005 } 3006} 3007)(); 3008 3009 3010},{}],11:[function(require,module,exports){ 3011// Copyright Joyent, Inc. and other Node contributors. 3012// 3013// Permission is hereby granted, free of charge, to any person obtaining a 3014// copy of this software and associated documentation files (the 3015// "Software"), to deal in the Software without restriction, including 3016// without limitation the rights to use, copy, modify, merge, publish, 3017// distribute, sublicense, and/or sell copies of the Software, and to permit 3018// persons to whom the Software is furnished to do so, subject to the 3019// following conditions: 3020// 3021// The above copyright notice and this permission notice shall be included 3022// in all copies or substantial portions of the Software. 3023// 3024// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 3025// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3026// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 3027// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 3028// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 3029// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 3030// USE OR OTHER DEALINGS IN THE SOFTWARE. 3031 3032'use strict'; 3033 3034// If obj.hasOwnProperty has been overridden, then calling 3035// obj.hasOwnProperty(prop) will break. 3036// See: https://github.com/joyent/node/issues/1707 3037function hasOwnProperty(obj, prop) { 3038 return Object.prototype.hasOwnProperty.call(obj, prop); 3039} 3040 3041module.exports = function(qs, sep, eq, options) { 3042 sep = sep || '&'; 3043 eq = eq || '='; 3044 var obj = {}; 3045 3046 if (typeof qs !== 'string' || qs.length === 0) { 3047 return obj; 3048 } 3049 3050 var regexp = /\+/g; 3051 qs = qs.split(sep); 3052 3053 var maxKeys = 1000; 3054 if (options && typeof options.maxKeys === 'number') { 3055 maxKeys = options.maxKeys; 3056 } 3057 3058 var len = qs.length; 3059 // maxKeys <= 0 means that we should not limit keys count 3060 if (maxKeys > 0 && len > maxKeys) { 3061 len = maxKeys; 3062 } 3063 3064 for (var i = 0; i < len; ++i) { 3065 var x = qs[i].replace(regexp, '%20'), 3066 idx = x.indexOf(eq), 3067 kstr, vstr, k, v; 3068 3069 if (idx >= 0) { 3070 kstr = x.substr(0, idx); 3071 vstr = x.substr(idx + 1); 3072 } else { 3073 kstr = x; 3074 vstr = ''; 3075 } 3076 3077 k = decodeURIComponent(kstr); 3078 v = decodeURIComponent(vstr); 3079 3080 if (!hasOwnProperty(obj, k)) { 3081 obj[k] = v; 3082 } else if (isArray(obj[k])) { 3083 obj[k].push(v); 3084 } else { 3085 obj[k] = [obj[k], v]; 3086 } 3087 } 3088 3089 return obj; 3090}; 3091 3092var isArray = Array.isArray || function (xs) { 3093 return Object.prototype.toString.call(xs) === '[object Array]'; 3094}; 3095 3096},{}],12:[function(require,module,exports){ 3097// Copyright Joyent, Inc. and other Node contributors. 3098// 3099// Permission is hereby granted, free of charge, to any person obtaining a 3100// copy of this software and associated documentation files (the 3101// "Software"), to deal in the Software without restriction, including 3102// without limitation the rights to use, copy, modify, merge, publish, 3103// distribute, sublicense, and/or sell copies of the Software, and to permit 3104// persons to whom the Software is furnished to do so, subject to the 3105// following conditions: 3106// 3107// The above copyright notice and this permission notice shall be included 3108// in all copies or substantial portions of the Software. 3109// 3110// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 3111// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3112// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 3113// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 3114// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 3115// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 3116// USE OR OTHER DEALINGS IN THE SOFTWARE. 3117 3118'use strict'; 3119 3120var stringifyPrimitive = function(v) { 3121 switch (typeof v) { 3122 case 'string': 3123 return v; 3124 3125 case 'boolean': 3126 return v ? 'true' : 'false'; 3127 3128 case 'number': 3129 return isFinite(v) ? v : ''; 3130 3131 default: 3132 return ''; 3133 } 3134}; 3135 3136module.exports = function(obj, sep, eq, name) { 3137 sep = sep || '&'; 3138 eq = eq || '='; 3139 if (obj === null) { 3140 obj = undefined; 3141 } 3142 3143 if (typeof obj === 'object') { 3144 return map(objectKeys(obj), function(k) { 3145 var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; 3146 if (isArray(obj[k])) { 3147 return map(obj[k], function(v) { 3148 return ks + encodeURIComponent(stringifyPrimitive(v)); 3149 }).join(sep); 3150 } else { 3151 return ks + encodeURIComponent(stringifyPrimitive(obj[k])); 3152 } 3153 }).join(sep); 3154 3155 } 3156 3157 if (!name) return ''; 3158 return encodeURIComponent(stringifyPrimitive(name)) + eq + 3159 encodeURIComponent(stringifyPrimitive(obj)); 3160}; 3161 3162var isArray = Array.isArray || function (xs) { 3163 return Object.prototype.toString.call(xs) === '[object Array]'; 3164}; 3165 3166function map (xs, f) { 3167 if (xs.map) return xs.map(f); 3168 var res = []; 3169 for (var i = 0; i < xs.length; i++) { 3170 res.push(f(xs[i], i)); 3171 } 3172 return res; 3173} 3174 3175var objectKeys = Object.keys || function (obj) { 3176 var res = []; 3177 for (var key in obj) { 3178 if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); 3179 } 3180 return res; 3181}; 3182 3183},{}],13:[function(require,module,exports){ 3184'use strict'; 3185 3186exports.decode = exports.parse = require('./decode'); 3187exports.encode = exports.stringify = require('./encode'); 3188 3189},{"./decode":11,"./encode":12}],14:[function(require,module,exports){ 3190/* eslint-disable node/no-deprecated-api */ 3191var buffer = require('buffer') 3192var Buffer = buffer.Buffer 3193 3194// alternative to using Object.keys for old browsers 3195function copyProps (src, dst) { 3196 for (var key in src) { 3197 dst[key] = src[key] 3198 } 3199} 3200if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { 3201 module.exports = buffer 3202} else { 3203 // Copy properties from require('buffer')
vendor: 23,187 bytes, lines 3204-4125
3204 copyProps(buffer, exports) 3205 exports.Buffer = SafeBuffer 3206} 3207 3208function SafeBuffer (arg, encodingOrOffset, length) { 3209 return Buffer(arg, encodingOrOffset, length) 3210} 3211 3212// Copy static methods from Buffer 3213copyProps(Buffer, SafeBuffer) 3214 3215SafeBuffer.from = function (arg, encodingOrOffset, length) { 3216 if (typeof arg === 'number') { 3217 throw new TypeError('Argument must not be a number') 3218 } 3219 return Buffer(arg, encodingOrOffset, length) 3220} 3221 3222SafeBuffer.alloc = function (size, fill, encoding) { 3223 if (typeof size !== 'number') { 3224 throw new TypeError('Argument must be a number') 3225 } 3226 var buf = Buffer(size) 3227 if (fill !== undefined) { 3228 if (typeof encoding === 'string') { 3229 buf.fill(fill, encoding) 3230 } else { 3231 buf.fill(fill) 3232 } 3233 } else { 3234 buf.fill(0) 3235 } 3236 return buf 3237} 3238 3239SafeBuffer.allocUnsafe = function (size) { 3240 if (typeof size !== 'number') { 3241 throw new TypeError('Argument must be a number') 3242 } 3243 return Buffer(size) 3244} 3245 3246SafeBuffer.allocUnsafeSlow = function (size) { 3247 if (typeof size !== 'number') { 3248 throw new TypeError('Argument must be a number') 3249 } 3250 return buffer.SlowBuffer(size) 3251} 3252 3253},{"buffer":3}],15:[function(require,module,exports){ 3254var Buffer = require('safe-buffer').Buffer 3255 3256// prototype class for hash functions 3257function Hash (blockSize, finalSize) { 3258 this._block = Buffer.alloc(blockSize) 3259 this._finalSize = finalSize 3260 this._blockSize = blockSize 3261 this._len = 0 3262} 3263 3264Hash.prototype.update = function (data, enc) { 3265 if (typeof data === 'string') { 3266 enc = enc || 'utf8' 3267 data = Buffer.from(data, enc) 3268 } 3269 3270 var block = this._block 3271 var blockSize = this._blockSize 3272 var length = data.length 3273 var accum = this._len 3274 3275 for (var offset = 0; offset < length;) { 3276 var assigned = accum % blockSize 3277 var remainder = Math.min(length - offset, blockSize - assigned) 3278 3279 for (var i = 0; i < remainder; i++) { 3280 block[assigned + i] = data[offset + i] 3281 } 3282 3283 accum += remainder 3284 offset += remainder 3285 3286 if ((accum % blockSize) === 0) { 3287 this._update(block) 3288 } 3289 } 3290 3291 this._len += length 3292 return this 3293} 3294 3295Hash.prototype.digest = function (enc) { 3296 var rem = this._len % this._blockSize 3297 3298 this._block[rem] = 0x80 3299 3300 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest 3301 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize 3302 this._block.fill(0, rem + 1) 3303 3304 if (rem >= this._finalSize) { 3305 this._update(this._block) 3306 this._block.fill(0) 3307 } 3308 3309 var bits = this._len * 8 3310 3311 // uint32 3312 if (bits <= 0xffffffff) { 3313 this._block.writeUInt32BE(bits, this._blockSize - 4) 3314 3315 // uint64 3316 } else { 3317 var lowBits = (bits & 0xffffffff) >>> 0 3318 var highBits = (bits - lowBits) / 0x100000000 3319 3320 this._block.writeUInt32BE(highBits, this._blockSize - 8) 3321 this._block.writeUInt32BE(lowBits, this._blockSize - 4) 3322 } 3323 3324 this._update(this._block) 3325 var hash = this._hash() 3326 3327 return enc ? hash.toString(enc) : hash 3328} 3329 3330Hash.prototype._update = function () { 3331 throw new Error('_update must be implemented by subclass') 3332} 3333 3334module.exports = Hash 3335 3336},{"safe-buffer":14}],16:[function(require,module,exports){ 3337var exports = module.exports = function SHA (algorithm) { 3338 algorithm = algorithm.toLowerCase() 3339 3340 var Algorithm = exports[algorithm] 3341 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') 3342 3343 return new Algorithm() 3344} 3345 3346exports.sha = require('./sha') 3347exports.sha1 = require('./sha1') 3348exports.sha224 = require('./sha224') 3349exports.sha256 = require('./sha256') 3350exports.sha384 = require('./sha384') 3351exports.sha512 = require('./sha512') 3352 3353},{"./sha":17,"./sha1":18,"./sha224":19,"./sha256":20,"./sha384":21,"./sha512":22}],17:[function(require,module,exports){ 3354/* 3355 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined 3356 * in FIPS PUB 180-1 3357 * This source code is derived from sha1.js of the same repository. 3358 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left 3359 * operation was added. 3360 */ 3361 3362var inherits = require('inherits') 3363var Hash = require('./hash') 3364var Buffer = require('safe-buffer').Buffer 3365 3366var K = [ 3367 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 3368] 3369 3370var W = new Array(80) 3371 3372function Sha () { 3373 this.init() 3374 this._w = W 3375 3376 Hash.call(this, 64, 56) 3377} 3378 3379inherits(Sha, Hash) 3380 3381Sha.prototype.init = function () { 3382 this._a = 0x67452301 3383 this._b = 0xefcdab89 3384 this._c = 0x98badcfe 3385 this._d = 0x10325476 3386 this._e = 0xc3d2e1f0 3387 3388 return this 3389} 3390 3391function rotl5 (num) { 3392 return (num << 5) | (num >>> 27) 3393} 3394 3395function rotl30 (num) { 3396 return (num << 30) | (num >>> 2) 3397} 3398 3399function ft (s, b, c, d) { 3400 if (s === 0) return (b & c) | ((~b) & d) 3401 if (s === 2) return (b & c) | (b & d) | (c & d) 3402 return b ^ c ^ d 3403} 3404 3405Sha.prototype._update = function (M) { 3406 var W = this._w 3407 3408 var a = this._a | 0 3409 var b = this._b | 0 3410 var c = this._c | 0 3411 var d = this._d | 0 3412 var e = this._e | 0 3413 3414 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) 3415 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16] 3416 3417 for (var j = 0; j < 80; ++j) { 3418 var s = ~~(j / 20) 3419 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 3420 3421 e = d 3422 d = c 3423 c = rotl30(b) 3424 b = a 3425 a = t 3426 } 3427 3428 this._a = (a + this._a) | 0 3429 this._b = (b + this._b) | 0 3430 this._c = (c + this._c) | 0 3431 this._d = (d + this._d) | 0 3432 this._e = (e + this._e) | 0 3433} 3434 3435Sha.prototype._hash = function () { 3436 var H = Buffer.allocUnsafe(20) 3437 3438 H.writeInt32BE(this._a | 0, 0) 3439 H.writeInt32BE(this._b | 0, 4) 3440 H.writeInt32BE(this._c | 0, 8) 3441 H.writeInt32BE(this._d | 0, 12) 3442 H.writeInt32BE(this._e | 0, 16) 3443 3444 return H 3445} 3446 3447module.exports = Sha 3448 3449},{"./hash":15,"inherits":8,"safe-buffer":14}],18:[function(require,module,exports){ 3450/* 3451 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined 3452 * in FIPS PUB 180-1 3453 * Version 2.1a Copyright Paul Johnston 2000 - 2002. 3454 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet 3455 * Distributed under the BSD License 3456 * See http://pajhome.org.uk/crypt/md5 for details. 3457 */ 3458 3459var inherits = require('inherits') 3460var Hash = require('./hash') 3461var Buffer = require('safe-buffer').Buffer 3462 3463var K = [ 3464 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 3465] 3466 3467var W = new Array(80) 3468 3469function Sha1 () { 3470 this.init() 3471 this._w = W 3472 3473 Hash.call(this, 64, 56) 3474} 3475 3476inherits(Sha1, Hash) 3477 3478Sha1.prototype.init = function () { 3479 this._a = 0x67452301 3480 this._b = 0xefcdab89 3481 this._c = 0x98badcfe 3482 this._d = 0x10325476 3483 this._e = 0xc3d2e1f0 3484 3485 return this 3486} 3487 3488function rotl1 (num) { 3489 return (num << 1) | (num >>> 31) 3490} 3491 3492function rotl5 (num) { 3493 return (num << 5) | (num >>> 27) 3494} 3495 3496function rotl30 (num) { 3497 return (num << 30) | (num >>> 2) 3498} 3499 3500function ft (s, b, c, d) { 3501 if (s === 0) return (b & c) | ((~b) & d) 3502 if (s === 2) return (b & c) | (b & d) | (c & d) 3503 return b ^ c ^ d 3504} 3505 3506Sha1.prototype._update = function (M) { 3507 var W = this._w 3508 3509 var a = this._a | 0 3510 var b = this._b | 0 3511 var c = this._c | 0 3512 var d = this._d | 0 3513 var e = this._e | 0 3514 3515 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) 3516 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) 3517 3518 for (var j = 0; j < 80; ++j) { 3519 var s = ~~(j / 20) 3520 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 3521 3522 e = d 3523 d = c 3524 c = rotl30(b) 3525 b = a 3526 a = t 3527 } 3528 3529 this._a = (a + this._a) | 0 3530 this._b = (b + this._b) | 0 3531 this._c = (c + this._c) | 0 3532 this._d = (d + this._d) | 0 3533 this._e = (e + this._e) | 0 3534} 3535 3536Sha1.prototype._hash = function () { 3537 var H = Buffer.allocUnsafe(20) 3538 3539 H.writeInt32BE(this._a | 0, 0) 3540 H.writeInt32BE(this._b | 0, 4) 3541 H.writeInt32BE(this._c | 0, 8) 3542 H.writeInt32BE(this._d | 0, 12) 3543 H.writeInt32BE(this._e | 0, 16) 3544 3545 return H 3546} 3547 3548module.exports = Sha1 3549 3550},{"./hash":15,"inherits":8,"safe-buffer":14}],19:[function(require,module,exports){ 3551/** 3552 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined 3553 * in FIPS 180-2 3554 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. 3555 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet 3556 * 3557 */ 3558 3559var inherits = require('inherits') 3560var Sha256 = require('./sha256') 3561var Hash = require('./hash') 3562var Buffer = require('safe-buffer').Buffer 3563 3564var W = new Array(64) 3565 3566function Sha224 () { 3567 this.init() 3568 3569 this._w = W // new Array(64) 3570 3571 Hash.call(this, 64, 56) 3572} 3573 3574inherits(Sha224, Sha256) 3575 3576Sha224.prototype.init = function () { 3577 this._a = 0xc1059ed8 3578 this._b = 0x367cd507 3579 this._c = 0x3070dd17 3580 this._d = 0xf70e5939 3581 this._e = 0xffc00b31 3582 this._f = 0x68581511 3583 this._g = 0x64f98fa7 3584 this._h = 0xbefa4fa4 3585 3586 return this 3587} 3588 3589Sha224.prototype._hash = function () { 3590 var H = Buffer.allocUnsafe(28) 3591 3592 H.writeInt32BE(this._a, 0) 3593 H.writeInt32BE(this._b, 4) 3594 H.writeInt32BE(this._c, 8) 3595 H.writeInt32BE(this._d, 12) 3596 H.writeInt32BE(this._e, 16) 3597 H.writeInt32BE(this._f, 20) 3598 H.writeInt32BE(this._g, 24) 3599 3600 return H 3601} 3602 3603module.exports = Sha224 3604 3605},{"./hash":15,"./sha256":20,"inherits":8,"safe-buffer":14}],20:[function(require,module,exports){ 3606/** 3607 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined 3608 * in FIPS 180-2 3609 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. 3610 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet 3611 * 3612 */ 3613 3614var inherits = require('inherits') 3615var Hash = require('./hash') 3616var Buffer = require('safe-buffer').Buffer 3617 3618var K = [ 3619 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 3620 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 3621 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 3622 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 3623 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, 3624 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 3625 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 3626 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, 3627 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 3628 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 3629 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 3630 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 3631 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 3632 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 3633 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 3634 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 3635] 3636 3637var W = new Array(64) 3638 3639function Sha256 () { 3640 this.init() 3641 3642 this._w = W // new Array(64) 3643 3644 Hash.call(this, 64, 56) 3645} 3646 3647inherits(Sha256, Hash) 3648 3649Sha256.prototype.init = function () { 3650 this._a = 0x6a09e667 3651 this._b = 0xbb67ae85 3652 this._c = 0x3c6ef372 3653 this._d = 0xa54ff53a 3654 this._e = 0x510e527f 3655 this._f = 0x9b05688c 3656 this._g = 0x1f83d9ab 3657 this._h = 0x5be0cd19 3658 3659 return this 3660} 3661 3662function ch (x, y, z) { 3663 return z ^ (x & (y ^ z)) 3664} 3665 3666function maj (x, y, z) { 3667 return (x & y) | (z & (x | y)) 3668} 3669 3670function sigma0 (x) { 3671 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) 3672} 3673 3674function sigma1 (x) { 3675 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) 3676} 3677 3678function gamma0 (x) { 3679 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) 3680} 3681 3682function gamma1 (x) { 3683 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) 3684} 3685 3686Sha256.prototype._update = function (M) { 3687 var W = this._w 3688 3689 var a = this._a | 0 3690 var b = this._b | 0 3691 var c = this._c | 0 3692 var d = this._d | 0 3693 var e = this._e | 0 3694 var f = this._f | 0 3695 var g = this._g | 0 3696 var h = this._h | 0 3697 3698 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) 3699 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0 3700 3701 for (var j = 0; j < 64; ++j) { 3702 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0 3703 var T2 = (sigma0(a) + maj(a, b, c)) | 0 3704 3705 h = g 3706 g = f 3707 f = e 3708 e = (d + T1) | 0 3709 d = c 3710 c = b 3711 b = a 3712 a = (T1 + T2) | 0 3713 } 3714 3715 this._a = (a + this._a) | 0 3716 this._b = (b + this._b) | 0 3717 this._c = (c + this._c) | 0 3718 this._d = (d + this._d) | 0 3719 this._e = (e + this._e) | 0 3720 this._f = (f + this._f) | 0 3721 this._g = (g + this._g) | 0 3722 this._h = (h + this._h) | 0 3723} 3724 3725Sha256.prototype._hash = function () { 3726 var H = Buffer.allocUnsafe(32) 3727 3728 H.writeInt32BE(this._a, 0) 3729 H.writeInt32BE(this._b, 4) 3730 H.writeInt32BE(this._c, 8) 3731 H.writeInt32BE(this._d, 12) 3732 H.writeInt32BE(this._e, 16) 3733 H.writeInt32BE(this._f, 20) 3734 H.writeInt32BE(this._g, 24) 3735 H.writeInt32BE(this._h, 28) 3736 3737 return H 3738} 3739 3740module.exports = Sha256 3741 3742},{"./hash":15,"inherits":8,"safe-buffer":14}],21:[function(require,module,exports){ 3743var inherits = require('inherits') 3744var SHA512 = require('./sha512') 3745var Hash = require('./hash') 3746var Buffer = require('safe-buffer').Buffer 3747 3748var W = new Array(160) 3749 3750function Sha384 () { 3751 this.init() 3752 this._w = W 3753 3754 Hash.call(this, 128, 112) 3755} 3756 3757inherits(Sha384, SHA512) 3758 3759Sha384.prototype.init = function () { 3760 this._ah = 0xcbbb9d5d 3761 this._bh = 0x629a292a 3762 this._ch = 0x9159015a 3763 this._dh = 0x152fecd8 3764 this._eh = 0x67332667 3765 this._fh = 0x8eb44a87 3766 this._gh = 0xdb0c2e0d 3767 this._hh = 0x47b5481d 3768 3769 this._al = 0xc1059ed8 3770 this._bl = 0x367cd507 3771 this._cl = 0x3070dd17 3772 this._dl = 0xf70e5939 3773 this._el = 0xffc00b31 3774 this._fl = 0x68581511 3775 this._gl = 0x64f98fa7 3776 this._hl = 0xbefa4fa4 3777 3778 return this 3779} 3780 3781Sha384.prototype._hash = function () { 3782 var H = Buffer.allocUnsafe(48) 3783 3784 function writeInt64BE (h, l, offset) { 3785 H.writeInt32BE(h, offset) 3786 H.writeInt32BE(l, offset + 4) 3787 } 3788 3789 writeInt64BE(this._ah, this._al, 0) 3790 writeInt64BE(this._bh, this._bl, 8) 3791 writeInt64BE(this._ch, this._cl, 16) 3792 writeInt64BE(this._dh, this._dl, 24) 3793 writeInt64BE(this._eh, this._el, 32) 3794 writeInt64BE(this._fh, this._fl, 40) 3795 3796 return H 3797} 3798 3799module.exports = Sha384 3800 3801},{"./hash":15,"./sha512":22,"inherits":8,"safe-buffer":14}],22:[function(require,module,exports){ 3802var inherits = require('inherits') 3803var Hash = require('./hash') 3804var Buffer = require('safe-buffer').Buffer 3805 3806var K = [ 3807 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 3808 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 3809 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 3810 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 3811 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 3812 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, 3813 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 3814 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, 3815 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 3816 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 3817 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 3818 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, 3819 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 3820 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, 3821 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 3822 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, 3823 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 3824 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, 3825 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 3826 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, 3827 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 3828 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 3829 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 3830 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, 3831 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 3832 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, 3833 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 3834 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 3835 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 3836 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, 3837 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 3838 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, 3839 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 3840 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, 3841 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 3842 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, 3843 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 3844 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, 3845 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 3846 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 3847] 3848 3849var W = new Array(160) 3850 3851function Sha512 () { 3852 this.init() 3853 this._w = W 3854 3855 Hash.call(this, 128, 112) 3856} 3857 3858inherits(Sha512, Hash) 3859 3860Sha512.prototype.init = function () { 3861 this._ah = 0x6a09e667 3862 this._bh = 0xbb67ae85 3863 this._ch = 0x3c6ef372 3864 this._dh = 0xa54ff53a 3865 this._eh = 0x510e527f 3866 this._fh = 0x9b05688c 3867 this._gh = 0x1f83d9ab 3868 this._hh = 0x5be0cd19 3869 3870 this._al = 0xf3bcc908 3871 this._bl = 0x84caa73b 3872 this._cl = 0xfe94f82b 3873 this._dl = 0x5f1d36f1 3874 this._el = 0xade682d1 3875 this._fl = 0x2b3e6c1f 3876 this._gl = 0xfb41bd6b 3877 this._hl = 0x137e2179 3878 3879 return this 3880} 3881 3882function Ch (x, y, z) { 3883 return z ^ (x & (y ^ z)) 3884} 3885 3886function maj (x, y, z) { 3887 return (x & y) | (z & (x | y)) 3888} 3889 3890function sigma0 (x, xl) { 3891 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) 3892} 3893 3894function sigma1 (x, xl) { 3895 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) 3896} 3897 3898function Gamma0 (x, xl) { 3899 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) 3900} 3901 3902function Gamma0l (x, xl) { 3903 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) 3904} 3905 3906function Gamma1 (x, xl) { 3907 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) 3908} 3909 3910function Gamma1l (x, xl) { 3911 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) 3912} 3913 3914function getCarry (a, b) { 3915 return (a >>> 0) < (b >>> 0) ? 1 : 0 3916} 3917 3918Sha512.prototype._update = function (M) { 3919 var W = this._w 3920 3921 var ah = this._ah | 0 3922 var bh = this._bh | 0 3923 var ch = this._ch | 0 3924 var dh = this._dh | 0 3925 var eh = this._eh | 0 3926 var fh = this._fh | 0 3927 var gh = this._gh | 0 3928 var hh = this._hh | 0 3929 3930 var al = this._al | 0 3931 var bl = this._bl | 0 3932 var cl = this._cl | 0 3933 var dl = this._dl | 0 3934 var el = this._el | 0 3935 var fl = this._fl | 0 3936 var gl = this._gl | 0 3937 var hl = this._hl | 0 3938 3939 for (var i = 0; i < 32; i += 2) { 3940 W[i] = M.readInt32BE(i * 4) 3941 W[i + 1] = M.readInt32BE(i * 4 + 4) 3942 } 3943 for (; i < 160; i += 2) { 3944 var xh = W[i - 15 * 2] 3945 var xl = W[i - 15 * 2 + 1] 3946 var gamma0 = Gamma0(xh, xl) 3947 var gamma0l = Gamma0l(xl, xh) 3948 3949 xh = W[i - 2 * 2] 3950 xl = W[i - 2 * 2 + 1] 3951 var gamma1 = Gamma1(xh, xl) 3952 var gamma1l = Gamma1l(xl, xh) 3953 3954 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] 3955 var Wi7h = W[i - 7 * 2] 3956 var Wi7l = W[i - 7 * 2 + 1] 3957 3958 var Wi16h = W[i - 16 * 2] 3959 var Wi16l = W[i - 16 * 2 + 1] 3960 3961 var Wil = (gamma0l + Wi7l) | 0 3962 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 3963 Wil = (Wil + gamma1l) | 0 3964 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 3965 Wil = (Wil + Wi16l) | 0 3966 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 3967 3968 W[i] = Wih 3969 W[i + 1] = Wil 3970 } 3971 3972 for (var j = 0; j < 160; j += 2) { 3973 Wih = W[j] 3974 Wil = W[j + 1] 3975 3976 var majh = maj(ah, bh, ch) 3977 var majl = maj(al, bl, cl) 3978 3979 var sigma0h = sigma0(ah, al) 3980 var sigma0l = sigma0(al, ah) 3981 var sigma1h = sigma1(eh, el) 3982 var sigma1l = sigma1(el, eh) 3983 3984 // t1 = h + sigma1 + ch + K[j] + W[j] 3985 var Kih = K[j] 3986 var Kil = K[j + 1] 3987 3988 var chh = Ch(eh, fh, gh) 3989 var chl = Ch(el, fl, gl) 3990 3991 var t1l = (hl + sigma1l) | 0 3992 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0 3993 t1l = (t1l + chl) | 0 3994 t1h = (t1h + chh + getCarry(t1l, chl)) | 0 3995 t1l = (t1l + Kil) | 0 3996 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 3997 t1l = (t1l + Wil) | 0 3998 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 3999 4000 // t2 = sigma0 + maj 4001 var t2l = (sigma0l + majl) | 0 4002 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0 4003 4004 hh = gh 4005 hl = gl 4006 gh = fh 4007 gl = fl 4008 fh = eh 4009 fl = el 4010 el = (dl + t1l) | 0 4011 eh = (dh + t1h + getCarry(el, dl)) | 0 4012 dh = ch 4013 dl = cl 4014 ch = bh 4015 cl = bl 4016 bh = ah 4017 bl = al 4018 al = (t1l + t2l) | 0 4019 ah = (t1h + t2h + getCarry(al, t1l)) | 0 4020 } 4021 4022 this._al = (this._al + al) | 0 4023 this._bl = (this._bl + bl) | 0 4024 this._cl = (this._cl + cl) | 0 4025 this._dl = (this._dl + dl) | 0 4026 this._el = (this._el + el) | 0 4027 this._fl = (this._fl + fl) | 0 4028 this._gl = (this._gl + gl) | 0 4029 this._hl = (this._hl + hl) | 0 4030 4031 this._ah = (this._ah + ah + getCarry(this._al, al)) | 0 4032 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0 4033 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0 4034 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0 4035 this._eh = (this._eh + eh + getCarry(this._el, el)) | 0 4036 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0 4037 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0 4038 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0 4039} 4040 4041Sha512.prototype._hash = function () { 4042 var H = Buffer.allocUnsafe(64) 4043 4044 function writeInt64BE (h, l, offset) { 4045 H.writeInt32BE(h, offset) 4046 H.writeInt32BE(l, offset + 4) 4047 } 4048 4049 writeInt64BE(this._ah, this._al, 0) 4050 writeInt64BE(this._bh, this._bl, 8) 4051 writeInt64BE(this._ch, this._cl, 16) 4052 writeInt64BE(this._dh, this._dl, 24) 4053 writeInt64BE(this._eh, this._el, 32) 4054 writeInt64BE(this._fh, this._fl, 40) 4055 writeInt64BE(this._gh, this._gl, 48) 4056 writeInt64BE(this._hh, this._hl, 56) 4057 4058 return H 4059} 4060 4061module.exports = Sha512 4062 4063},{"./hash":15,"inherits":8,"safe-buffer":14}],23:[function(require,module,exports){ 4064// Copyright Joyent, Inc. and other Node contributors. 4065// 4066// Permission is hereby granted, free of charge, to any person obtaining a 4067// copy of this software and associated documentation files (the 4068// "Software"), to deal in the Software without restriction, including 4069// without limitation the rights to use, copy, modify, merge, publish, 4070// distribute, sublicense, and/or sell copies of the Software, and to permit 4071// persons to whom the Software is furnished to do so, subject to the 4072// following conditions: 4073// 4074// The above copyright notice and this permission notice shall be included 4075// in all copies or substantial portions of the Software. 4076// 4077// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 4078// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 4079// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 4080// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 4081// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 4082// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 4083// USE OR OTHER DEALINGS IN THE SOFTWARE. 4084 4085var punycode = require('punycode'); 4086 4087exports.parse = urlParse; 4088exports.resolve = urlResolve; 4089exports.resolveObject = urlResolveObject; 4090exports.format = urlFormat; 4091 4092exports.Url = Url; 4093 4094function Url() { 4095 this.protocol = null; 4096 this.slashes = null; 4097 this.auth = null; 4098 this.host = null; 4099 this.port = null; 4100 this.hostname = null; 4101 this.hash = null; 4102 this.search = null; 4103 this.query = null; 4104 this.pathname = null; 4105 this.path = null; 4106 this.href = null; 4107} 4108 4109// Reference: RFC 3986, RFC 1808, RFC 2396 4110 4111// define these here so at least they only have to be 4112// compiled once on the first module load. 4113var protocolPattern = /^([a-z0-9.+-]+:)/i, 4114 portPattern = /:[0-9]*$/, 4115 4116 // RFC 2396: characters reserved for delimiting URLs. 4117 // We actually just auto-escape these. 4118 delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], 4119 4120 // RFC 2396: characters not allowed for various reasons. 4121 unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), 4122 4123 // Allowed by RFCs, but cause of XSS attacks. Always escape these. 4124 autoEscape = ['\''].concat(unwise), 4125 // Characters that are never ever allowed in a hostname.
vendor: 15,367 bytes, lines 4126-4612
4126 // Note that any invalid chars are also handled, but these 4127 // are the ones that are *expected* to be seen, so we fast-path 4128 // them. 4129 nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), 4130 hostEndingChars = ['/', '?', '#'], 4131 hostnameMaxLen = 255, 4132 hostnamePartPattern = /^[a-z0-9A-Z_-]{0,63}$/, 4133 hostnamePartStart = /^([a-z0-9A-Z_-]{0,63})(.*)$/, 4134 // protocols that can allow "unsafe" and "unwise" chars. 4135 unsafeProtocol = { 4136 'javascript': true, 4137 'javascript:': true 4138 }, 4139 // protocols that never have a hostname. 4140 hostlessProtocol = { 4141 'javascript': true, 4142 'javascript:': true 4143 }, 4144 // protocols that always contain a // bit. 4145 slashedProtocol = { 4146 'http': true, 4147 'https': true, 4148 'ftp': true, 4149 'gopher': true, 4150 'file': true, 4151 'http:': true, 4152 'https:': true, 4153 'ftp:': true, 4154 'gopher:': true, 4155 'file:': true 4156 }, 4157 querystring = require('querystring'); 4158 4159function urlParse(url, parseQueryString, slashesDenoteHost) { 4160 if (url && isObject(url) && url instanceof Url) return url; 4161 4162 var u = new Url; 4163 u.parse(url, parseQueryString, slashesDenoteHost); 4164 return u; 4165} 4166 4167Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { 4168 if (!isString(url)) { 4169 throw new TypeError("Parameter 'url' must be a string, not " + typeof url); 4170 } 4171 4172 var rest = url; 4173 4174 // trim before proceeding. 4175 // This is to support parse stuff like " http://foo.com \n" 4176 rest = rest.trim(); 4177 4178 var proto = protocolPattern.exec(rest); 4179 if (proto) { 4180 proto = proto[0]; 4181 var lowerProto = proto.toLowerCase(); 4182 this.protocol = lowerProto; 4183 rest = rest.substr(proto.length); 4184 } 4185 4186 // figure out if it's got a host 4187 // user@server is *always* interpreted as a hostname, and url 4188 // resolution will treat //foo/bar as host=foo,path=bar because that's 4189 // how the browser resolves relative URLs. 4190 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { 4191 var slashes = rest.substr(0, 2) === '//'; 4192 if (slashes && !(proto && hostlessProtocol[proto])) { 4193 rest = rest.substr(2); 4194 this.slashes = true; 4195 } 4196 } 4197 4198 if (!hostlessProtocol[proto] && 4199 (slashes || (proto && !slashedProtocol[proto]))) { 4200 4201 // there's a hostname. 4202 // the first instance of /, ?, ;, or # ends the host. 4203 // 4204 // If there is an @ in the hostname, then non-host chars *are* allowed 4205 // to the left of the last @ sign, unless some host-ending character 4206 // comes *before* the @-sign. 4207 // URLs are obnoxious. 4208 // 4209 // ex: 4210 // http://a@b@c/ => user:a@b host:c 4211 // http://a@b?@c => user:a host:c path:/?@c 4212 4213 // v0.12 TODO(isaacs): This is not quite how Chrome does things. 4214 // Review our test case against browsers more comprehensively. 4215 4216 // find the first instance of any hostEndingChars 4217 var hostEnd = -1; 4218 for (var i = 0; i < hostEndingChars.length; i++) { 4219 var hec = rest.indexOf(hostEndingChars[i]); 4220 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) 4221 hostEnd = hec; 4222 } 4223 4224 // at this point, either we have an explicit point where the 4225 // auth portion cannot go past, or the last @ char is the decider. 4226 var auth, atSign; 4227 if (hostEnd === -1) { 4228 // atSign can be anywhere. 4229 atSign = rest.lastIndexOf('@'); 4230 } else { 4231 // atSign must be in auth portion. 4232 // http://a@b/c@d => host:b auth:a path:/c@d 4233 atSign = rest.lastIndexOf('@', hostEnd); 4234 } 4235 4236 // Now we have a portion which is definitely the auth. 4237 // Pull that off. 4238 if (atSign !== -1) { 4239 auth = rest.slice(0, atSign); 4240 rest = rest.slice(atSign + 1); 4241 this.auth = decodeURIComponent(auth); 4242 } 4243 4244 // the host is the remaining to the left of the first non-host char 4245 hostEnd = -1; 4246 for (var i = 0; i < nonHostChars.length; i++) { 4247 var hec = rest.indexOf(nonHostChars[i]); 4248 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) 4249 hostEnd = hec; 4250 } 4251 // if we still have not hit it, then the entire thing is a host. 4252 if (hostEnd === -1) 4253 hostEnd = rest.length; 4254 4255 this.host = rest.slice(0, hostEnd); 4256 rest = rest.slice(hostEnd); 4257 4258 // pull out port. 4259 this.parseHost(); 4260 4261 // we've indicated that there is a hostname, 4262 // so even if it's empty, it has to be present. 4263 this.hostname = this.hostname || ''; 4264 4265 // if hostname begins with [ and ends with ] 4266 // assume that it's an IPv6 address. 4267 var ipv6Hostname = this.hostname[0] === '[' && 4268 this.hostname[this.hostname.length - 1] === ']'; 4269 4270 // validate a little. 4271 if (!ipv6Hostname) { 4272 var hostparts = this.hostname.split(/\./); 4273 for (var i = 0, l = hostparts.length; i < l; i++) { 4274 var part = hostparts[i]; 4275 if (!part) continue; 4276 if (!part.match(hostnamePartPattern)) { 4277 var newpart = ''; 4278 for (var j = 0, k = part.length; j < k; j++) { 4279 if (part.charCodeAt(j) > 127) { 4280 // we replace non-ASCII char with a temporary placeholder 4281 // we need this to make sure size of hostname is not 4282 // broken by replacing non-ASCII by nothing 4283 newpart += 'x'; 4284 } else { 4285 newpart += part[j]; 4286 } 4287 } 4288 // we test again with ASCII char only 4289 if (!newpart.match(hostnamePartPattern)) { 4290 var validParts = hostparts.slice(0, i); 4291 var notHost = hostparts.slice(i + 1); 4292 var bit = part.match(hostnamePartStart); 4293 if (bit) { 4294 validParts.push(bit[1]); 4295 notHost.unshift(bit[2]); 4296 } 4297 if (notHost.length) { 4298 rest = '/' + notHost.join('.') + rest; 4299 } 4300 this.hostname = validParts.join('.'); 4301 break; 4302 } 4303 } 4304 } 4305 } 4306 4307 if (this.hostname.length > hostnameMaxLen) { 4308 this.hostname = ''; 4309 } else { 4310 // hostnames are always lower case. 4311 this.hostname = this.hostname.toLowerCase(); 4312 } 4313 4314 if (!ipv6Hostname) { 4315 // IDNA Support: Returns a puny coded representation of "domain". 4316 // It only converts the part of the domain name that 4317 // has non ASCII characters. I.e. it dosent matter if 4318 // you call it with a domain that already is in ASCII. 4319 var domainArray = this.hostname.split('.'); 4320 var newOut = []; 4321 for (var i = 0; i < domainArray.length; ++i) { 4322 var s = domainArray[i]; 4323 newOut.push(s.match(/[^A-Za-z0-9_-]/) ? 4324 'xn--' + punycode.encode(s) : s); 4325 } 4326 this.hostname = newOut.join('.'); 4327 } 4328 4329 var p = this.port ? ':' + this.port : ''; 4330 var h = this.hostname || ''; 4331 this.host = h + p; 4332 this.href += this.host; 4333 4334 // strip [ and ] from the hostname 4335 // the host field still retains them, though 4336 if (ipv6Hostname) { 4337 this.hostname = this.hostname.substr(1, this.hostname.length - 2); 4338 if (rest[0] !== '/') { 4339 rest = '/' + rest; 4340 } 4341 } 4342 } 4343 4344 // now rest is set to the post-host stuff. 4345 // chop off any delim chars. 4346 if (!unsafeProtocol[lowerProto]) { 4347 4348 // First, make 100% sure that any "autoEscape" chars get 4349 // escaped, even if encodeURIComponent doesn't think they 4350 // need to be. 4351 for (var i = 0, l = autoEscape.length; i < l; i++) { 4352 var ae = autoEscape[i]; 4353 var esc = encodeURIComponent(ae); 4354 if (esc === ae) { 4355 esc = escape(ae); 4356 } 4357 rest = rest.split(ae).join(esc); 4358 } 4359 } 4360 4361 4362 // chop off from the tail first. 4363 var hash = rest.indexOf('#'); 4364 if (hash !== -1) { 4365 // got a fragment string. 4366 this.hash = rest.substr(hash); 4367 rest = rest.slice(0, hash); 4368 } 4369 var qm = rest.indexOf('?'); 4370 if (qm !== -1) { 4371 this.search = rest.substr(qm); 4372 this.query = rest.substr(qm + 1); 4373 if (parseQueryString) { 4374 this.query = querystring.parse(this.query); 4375 } 4376 rest = rest.slice(0, qm); 4377 } else if (parseQueryString) { 4378 // no query string, but parseQueryString still requested 4379 this.search = ''; 4380 this.query = {}; 4381 } 4382 if (rest) this.pathname = rest; 4383 if (slashedProtocol[lowerProto] && 4384 this.hostname && !this.pathname) { 4385 this.pathname = '/'; 4386 } 4387 4388 //to support http.request 4389 if (this.pathname || this.search) { 4390 var p = this.pathname || ''; 4391 var s = this.search || ''; 4392 this.path = p + s; 4393 } 4394 4395 // finally, reconstruct the href based on what has been validated. 4396 this.href = this.format(); 4397 return this; 4398}; 4399 4400// format a parsed object into a url string 4401function urlFormat(obj) { 4402 // ensure it's an object, and not a string url. 4403 // If it's an obj, this is a no-op. 4404 // this way, you can call url_format() on strings 4405 // to clean up potentially wonky urls. 4406 if (isString(obj)) obj = urlParse(obj); 4407 if (!(obj instanceof Url)) return Url.prototype.format.call(obj); 4408 return obj.format(); 4409} 4410 4411Url.prototype.format = function() { 4412 var auth = this.auth || ''; 4413 if (auth) { 4414 auth = encodeURIComponent(auth); 4415 auth = auth.replace(/%3A/i, ':'); 4416 auth += '@'; 4417 } 4418 4419 var protocol = this.protocol || '', 4420 pathname = this.pathname || '', 4421 hash = this.hash || '', 4422 host = false, 4423 query = ''; 4424 4425 if (this.host) { 4426 host = auth + this.host; 4427 } else if (this.hostname) { 4428 host = auth + (this.hostname.indexOf(':') === -1 ? 4429 this.hostname : 4430 '[' + this.hostname + ']'); 4431 if (this.port) { 4432 host += ':' + this.port; 4433 } 4434 } 4435 4436 if (this.query && 4437 isObject(this.query) && 4438 Object.keys(this.query).length) { 4439 query = querystring.stringify(this.query); 4440 } 4441 4442 var search = this.search || (query && ('?' + query)) || ''; 4443 4444 if (protocol && protocol.substr(-1) !== ':') protocol += ':'; 4445 4446 // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. 4447 // unless they had them to begin with. 4448 if (this.slashes || 4449 (!protocol || slashedProtocol[protocol]) && host !== false) { 4450 host = '//' + (host || ''); 4451 if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; 4452 } else if (!host) { 4453 host = ''; 4454 } 4455 4456 if (hash && hash.charAt(0) !== '#') hash = '#' + hash; 4457 if (search && search.charAt(0) !== '?') search = '?' + search; 4458 4459 pathname = pathname.replace(/[?#]/g, function(match) { 4460 return encodeURIComponent(match); 4461 }); 4462 search = search.replace('#', '%23'); 4463 4464 return protocol + host + pathname + search + hash; 4465}; 4466 4467function urlResolve(source, relative) { 4468 return urlParse(source, false, true).resolve(relative); 4469} 4470 4471Url.prototype.resolve = function(relative) { 4472 return this.resolveObject(urlParse(relative, false, true)).format(); 4473}; 4474 4475function urlResolveObject(source, relative) { 4476 if (!source) return relative; 4477 return urlParse(source, false, true).resolveObject(relative); 4478} 4479 4480Url.prototype.resolveObject = function(relative) { 4481 if (isString(relative)) { 4482 var rel = new Url(); 4483 rel.parse(relative, false, true); 4484 relative = rel; 4485 } 4486 4487 var result = new Url(); 4488 Object.keys(this).forEach(function(k) { 4489 result[k] = this[k]; 4490 }, this); 4491 4492 // hash is always overridden, no matter what. 4493 // even href="" will remove it. 4494 result.hash = relative.hash; 4495 4496 // if the relative url is empty, then there's nothing left to do here. 4497 if (relative.href === '') { 4498 result.href = result.format(); 4499 return result; 4500 } 4501 4502 // hrefs like //foo/bar always cut to the protocol. 4503 if (relative.slashes && !relative.protocol) { 4504 // take everything except the protocol from relative 4505 Object.keys(relative).forEach(function(k) { 4506 if (k !== 'protocol') 4507 result[k] = relative[k]; 4508 }); 4509 4510 //urlParse appends trailing / to urls like http://www.example.com 4511 if (slashedProtocol[result.protocol] && 4512 result.hostname && !result.pathname) { 4513 result.path = result.pathname = '/'; 4514 } 4515 4516 result.href = result.format(); 4517 return result; 4518 } 4519 4520 if (relative.protocol && relative.protocol !== result.protocol) { 4521 // if it's a known url protocol, then changing 4522 // the protocol does weird things 4523 // first, if it's not file:, then we MUST have a host, 4524 // and if there was a path 4525 // to begin with, then we MUST have a path. 4526 // if it is file:, then the host is dropped, 4527 // because that's known to be hostless. 4528 // anything else is assumed to be absolute. 4529 if (!slashedProtocol[relative.protocol]) { 4530 Object.keys(relative).forEach(function(k) { 4531 result[k] = relative[k]; 4532 }); 4533 result.href = result.format(); 4534 return result; 4535 } 4536 4537 result.protocol = relative.protocol; 4538 if (!relative.host && !hostlessProtocol[relative.protocol]) { 4539 var relPath = (relative.pathname || '').split('/'); 4540 while (relPath.length && !(relative.host = relPath.shift())); 4541 if (!relative.host) relative.host = ''; 4542 if (!relative.hostname) relative.hostname = ''; 4543 if (relPath[0] !== '') relPath.unshift(''); 4544 if (relPath.length < 2) relPath.unshift(''); 4545 result.pathname = relPath.join('/'); 4546 } else { 4547 result.pathname = relative.pathname; 4548 } 4549 result.search = relative.search; 4550 result.query = relative.query; 4551 result.host = relative.host || ''; 4552 result.auth = relative.auth; 4553 result.hostname = relative.hostname || relative.host; 4554 result.port = relative.port; 4555 // to support http.request 4556 if (result.pathname || result.search) { 4557 var p = result.pathname || ''; 4558 var s = result.search || ''; 4559 result.path = p + s; 4560 } 4561 result.slashes = result.slashes || relative.slashes; 4562 result.href = result.format(); 4563 return result; 4564 } 4565 4566 var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), 4567 isRelAbs = ( 4568 relative.host || 4569 relative.pathname && relative.pathname.charAt(0) === '/' 4570 ), 4571 mustEndAbs = (isRelAbs || isSourceAbs || 4572 (result.host && relative.pathname)), 4573 removeAllDots = mustEndAbs, 4574 srcPath = result.pathname && result.pathname.split('/') || [], 4575 relPath = relative.pathname && relative.pathname.split('/') || [], 4576 psychotic = result.protocol && !slashedProtocol[result.protocol]; 4577 4578 // if the url is a non-slashed url, then relative 4579 // links like ../.. should be able 4580 // to crawl up to the hostname, as well. This is strange. 4581 // result.protocol has already been set by now. 4582 // Later on, put the first path part into the host field. 4583 if (psychotic) { 4584 result.hostname = ''; 4585 result.port = null; 4586 if (result.host) { 4587 if (srcPath[0] === '') srcPath[0] = result.host; 4588 else srcPath.unshift(result.host); 4589 } 4590 result.host = ''; 4591 if (relative.protocol) { 4592 relative.hostname = null; 4593 relative.port = null; 4594 if (relative.host) { 4595 if (relPath[0] === '') relPath[0] = relative.host; 4596 else relPath.unshift(relative.host); 4597 } 4598 relative.host = null; 4599 } 4600 mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); 4601 } 4602 4603 if (isRelAbs) { 4604 // it's absolute. 4605 result.host = (relative.host || relative.host === '') ? 4606 relative.host : result.host; 4607 result.hostname = (relative.hostname || relative.hostname === '') ? 4608 relative.hostname : result.hostname; 4609 result.search = relative.search; 4610 result.query = relative.query; 4611 srcPath = relPath; 4612 // fall through to the dot-handling below.
4613 } else if (relPath.length) { 4614 // it's relative 4615 // throw away the existing file, and take the new path instead. 4616 if (!srcPath) srcPath = []; 4617 srcPath.pop(); 4618 srcPath = srcPath.concat(relPath); 4619 result.search = relative.search; 4620 result.query = relative.query; 4621 } else if (!isNullOrUndefined(relative.search)) { 4622 // just pull out the search. 4623 // like href='?foo'. 4624 // Put this after the other two cases because it simplifies the booleans 4625 if (psychotic) { 4626 result.hostname = result.host = srcPath.shift(); 4627 //occationaly the auth can get stuck only in host 4628 //this especialy happens in cases like 4629 //url.resolveObject('mailto:local1@domain1', 'local2@domain2') 4630 var authInHost = result.host && result.host.indexOf('@') > 0 ? 4631 result.host.split('@') : false; 4632 if (authInHost) { 4633 result.auth = authInHost.shift(); 4634 result.host = result.hostname = authInHost.shift(); 4635 } 4636 } 4637 result.search = relative.search; 4638 result.query = relative.query; 4639 //to support http.request 4640 if (!isNull(result.pathname) || !isNull(result.search)) { 4641 result.path = (result.pathname ? result.pathname : '') + 4642 (result.search ? result.search : ''); 4643 } 4644 result.href = result.format(); 4645 return result; 4646 } 4647 4648 if (!srcPath.length) { 4649 // no path at all. easy. 4650 // we've already handled the other stuff above. 4651 result.pathname = null; 4652 //to support http.request 4653 if (result.search) { 4654 result.path = '/' + result.search; 4655 } else { 4656 result.path = null; 4657 } 4658 result.href = result.format(); 4659 return result; 4660 } 4661 4662 // if a url ENDs in . or .., then it must get a trailing slash. 4663 // however, if it ends in anything else non-slashy, 4664 // then it must NOT get a trailing slash. 4665 var last = srcPath.slice(-1)[0]; 4666 var hasTrailingSlash = ( 4667 (result.host || relative.host) && (last === '.' || last === '..') || 4668 last === ''); 4669 4670 // strip single dots, resolve double dots to parent dir 4671 // if the path tries to go above the root, `up` ends up > 0 4672 var up = 0; 4673 for (var i = srcPath.length; i >= 0; i--) { 4674 last = srcPath[i]; 4675 if (last == '.') { 4676 srcPath.splice(i, 1); 4677 } else if (last === '..') { 4678 srcPath.splice(i, 1); 4679 up++; 4680 } else if (up) { 4681 srcPath.splice(i, 1); 4682 up--; 4683 } 4684 } 4685 4686 // if the path is allowed to go above the root, restore leading ..s 4687 if (!mustEndAbs && !removeAllDots) { 4688 for (; up--; up) { 4689 srcPath.unshift('..'); 4690 } 4691 } 4692 4693 if (mustEndAbs && srcPath[0] !== '' && 4694 (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { 4695 srcPath.unshift(''); 4696 } 4697 4698 if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { 4699 srcPath.push(''); 4700 } 4701 4702 var isAbsolute = srcPath[0] === '' || 4703 (srcPath[0] && srcPath[0].charAt(0) === '/'); 4704 4705 // put the host back 4706 if (psychotic) { 4707 result.hostname = result.host = isAbsolute ? '' : 4708 srcPath.length ? srcPath.shift() : ''; 4709 //occationaly the auth can get stuck only in host 4710 //this especialy happens in cases like 4711 //url.resolveObject('mailto:local1@domain1', 'local2@domain2') 4712 var authInHost = result.host && result.host.indexOf('@') > 0 ? 4713 result.host.split('@') : false; 4714 if (authInHost) { 4715 result.auth = authInHost.shift(); 4716 result.host = result.hostname = authInHost.shift(); 4717 } 4718 } 4719 4720 mustEndAbs = mustEndAbs || (result.host && srcPath.length); 4721 4722 if (mustEndAbs && !isAbsolute) { 4723 srcPath.unshift(''); 4724 } 4725 4726 if (!srcPath.length) { 4727 result.pathname = null; 4728 result.path = null; 4729 } else { 4730 result.pathname = srcPath.join('/'); 4731 } 4732 4733 //to support request.http 4734 if (!isNull(result.pathname) || !isNull(result.search)) { 4735 result.path = (result.pathname ? result.pathname : '') + 4736 (result.search ? result.search : ''); 4737 } 4738 result.auth = relative.auth || result.auth; 4739 result.slashes = result.slashes || relative.slashes; 4740 result.href = result.format(); 4741 return result; 4742}; 4743 4744Url.prototype.parseHost = function() { 4745 var host = this.host; 4746 var port = portPattern.exec(host); 4747 if (port) { 4748 port = port[0]; 4749 if (port !== ':') { 4750 this.port = port.substr(1); 4751 } 4752 host = host.substr(0, host.length - port.length); 4753 } 4754 if (host) this.hostname = host; 4755}; 4756 4757function isString(arg) { 4758 return typeof arg === "string"; 4759} 4760 4761function isObject(arg) { 4762 return typeof arg === 'object' && arg !== null; 4763} 4764 4765function isNull(arg) { 4766 return arg === null; 4767} 4768function isNullOrUndefined(arg) { 4769 return arg == null; 4770} 4771 4772},{"punycode":2,"querystring":13}],24:[function(require,module,exports){ 4773var $ = require("./jquery.js"); 4774var comparators = require("./comparators.js"); 4775var fh = require("./fields/fieldhelpers.js"); 4776//Deals with visiblity rules, dependency management 4777 4778module.exports = { 4779 getChangeMap:getChangeMap, 4780 fieldChangeChecker:fieldChangeChecker, 4781 applyPicklistAlterations:applyPicklistAlterations 4782} 4783 4784function getChangeMap(fields, formDescriptor){ 4785 var changeMap ={}; 4786 $.each(fields, function(i, field){ 4787 if(field.Datatype == "hidden" || field.Datatype == "profiling"){ 4788 //Don't evaluate visibility rules on hidden or profiling fields. 4789 return; 4790 } 4791 var vr = field.VisibilityRule; 4792 if(vr){ 4793 //Every field in a fieldset is dependent on the fieldset. 4794 if(field.Datatype == "fieldset"){ 4795 if(Object.keys(formDescriptor.fieldsetRows).length > 0) { 4796 var childFields = fh.flatten(formDescriptor.fieldsetRows[""+field.Id]); 4797 var deps = changeMap[field.Name]; 4798 if(!deps){ 4799 deps = []; 4800 } 4801 deps = deps.concat($.map(childFields, function (f){return f.Name;})); 4802 changeMap[field.Name] = deps; 4803 } 4804 } 4805 //New format has more than one rule. 4806 var rules = vr.rules || [vr]; 4807 $.each(rules, function (i, rule){ 4808 if(typeof rule === "string"){ 4809 return; 4810 } 4811 var dependents = changeMap[rule.subjectField]; 4812 if(!dependents){ 4813 dependents = []; 4814 } 4815 if($.inArray(field.Name, dependents) === -1){ 4816 dependents.push(field.Name); 4817 }
4818 changeMap[rule.subjectField] = dependents; 4819 }); 4820 } 4821 }); 4822 return changeMap; 4823} 4824 4825function firstItem (arr, test){ 4826 var len = arr.length; 4827 for(var i =0; i < len; i++){ 4828 var item = arr[i]; 4829 if(test(item)){ 4830 return item; 4831 } 4832 } 4833 return undefined; 4834} 4835 4836function applyPicklistAlterations (field, rule){ 4837 if(rule && (field.PicklistValues || rule.picklistKeys || rule.altLabel)){ 4838 //make a deep copy of the field 4839 field = $.extend(true, {}, field); 4840 4841 if (field.PicklistValues){ 4842 if (rule.picklistFilterValues){ 4843 // The filter is a list of label/value objects, need to compare both fields 4844 4845 // Build map from values to list of labels to avoid nested loop search 4846 var filterKeysToValues = {}; 4847 $.each(rule.picklistFilterValues, function (i, val){ 4848 if (!filterKeysToValues.hasOwnProperty(val.value)){ 4849 filterKeysToValues[val.value] = []; 4850 } 4851 filterKeysToValues[val.value].push(val.label); 4852 }); 4853 4854 field.PicklistValues = $.map(field.PicklistValues, function (val){ 4855 if (filterKeysToValues.hasOwnProperty(val.value) && $.inArray(val.label, filterKeysToValues[val.value]) != -1){ 4856 return val; 4857 } 4858 }); 4859 } 4860 else if (rule.picklistKeys){ 4861 // Pre-February2014, the picklistKeys property was used to filter 4862 // the values for the picklist, was replaced by picklistFilterValues to avoid problems 4863 // with to values having the same keys (see above) 4864 4865 //Filter the picklist values by the keys 4866 field.PicklistValues = $.map(field.PicklistValues, function (val){ 4867 if($.inArray(val.value, rule.picklistKeys) != -1){ 4868 return val; 4869 } 4870 }); 4871 } 4872 } 4873 4874 //Set the new label 4875 if(rule.altLabel){ 4876 field.InputLabel = rule.altLabel; 4877 } 4878 } 4879 return field; 4880} 4881 4882function fieldChangeChecker (vr, vals){ 4883 if(!vr){ 4884 return {show:true}; 4885 } 4886 var show = vr.defaultVisibility == "show"; 4887 4888 var rules = vr.rules || [vr]; 4889 4890 var results = $.map(rules, function (rule){ 4891 if(typeof rule === "string"){ 4892 return; 4893 } 4894 var val = vals[rule.subjectField]; 4895 if(!$.isArray(val)){ 4896 val = val ? [val] : [] 4897 } 4898 var comparator = comparators[rule.operator]; 4899 var ok = comparator(val, rule.values); 4900 4901 if(ok){ 4902 return rule; 4903 } 4904 return null; 4905 }); 4906 4907 var activeRule = firstItem(results, function (item){ 4908 return item !== null; 4909 }) 4910 if(show){ 4911 //If something is default "show" 4912 //Then it is shown when ALL of the value tests provided fail 4913 return {show:!activeRule, rule:activeRule}; 4914 }else{ 4915 //If something is default "hide", then it is shown when ANY of the 4916 //tests pass 4917 return {show:!!activeRule, rule:activeRule}; 4918 } 4919} 4920 4921},{"./comparators.js":26,"./fields/fieldhelpers.js":30,"./jquery.js":45}],25:[function(require,module,exports){ 4922 4923 4924module.exports = { 4925 parseColor:parseColor, 4926 compareColor:compareColor 4927} 4928/** 4929 Parses a color string into an array [r,g,b,a]; 4930 supports the following formats: 4931 #fff 4932 #ffffff 4933 rgba(255,255,255,0) 4934 rgb(255,255,255) 4935 returns null if the string wasn't a valid color. 4936*/ 4937function parseColor (color){ 4938 var match; 4939 var p = parseInt; 4940 color = (color || '').replace(/\s\s*/g,''); 4941 /* jshint -W084 */ 4942 // #000000 format 4943 if (match = /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(color)){ 4944 return [p(match[1], 16), p(match[2], 16), p(match[3], 16), 1]; 4945 } 4946 // #000 format 4947 else if (match = /^#([\da-f])([\da-f])([\da-f])/i.exec(color)){ 4948 return [p(match[1], 16) * 17, p(match[2], 16) * 17, p(match[3], 16) * 17, 1]; 4949 } 4950 //rgba(0,0,0,0) format 4951 else if (match = /^rgba\(([\d]+),([\d]+),([\d]+),([\d]+|[\d]*.[\d]+)\)/i.exec(color)){ 4952 return [+match[1], +match[2], +match[3], +match[4]]; 4953 } 4954 // rgb(0,0,0) format 4955 else if (match = /^rgb\(([\d]+),([\d]+),([\d]+)\)/i.exec(color)){ 4956 return [+match[1], +match[2], +match[3], 1]; 4957 } 4958 /* jshint +W084 */ 4959 return null; 4960} 4961 4962/** 4963 Compares two colors strings by value 4964 returns true if they're both valid colors and match, false otherwise. 4965*/ 4966function compareColor (color1, color2){ 4967 var c1 = parseColor(color1); 4968 var c2 = parseColor(color2); 4969 if(!c1 || !c2){ 4970 return false;
4971 } 4972 for(var i = 0; i < 4; i++){ 4973 if(c1[i] !== c2[i]){ 4974 return false; 4975 } 4976 } 4977 return true; 4978} 4979},{}],26:[function(require,module,exports){ 4980var intersect = function (x, y, fn){ 4981 var ret = []; 4982 for (var i = 0; i < x.length; i++) { 4983 for (var z = 0; z < y.length; z++) { 4984 if (fn(x[i],y[z])) { 4985 ret.push(x[i]); 4986 break; 4987 } 4988 } 4989 } 4990 return ret; 4991} 4992 4993 4994var comparators = { 4995 //tests if any elements from array are equal to any elements in array b 4996 equal: function (a, b){ 4997 var fn = function(x,y){ 4998 return x === y; 4999 }; 5000 return intersect(a, b, fn).length > 0; 5001 }, 5002 //returns true if all values in array a are not in array b 5003 notEqual: function (a, b){ 5004 var fn = function(x,y){ 5005 return x === y; 5006 }; 5007 return intersect(a, b, fn).length === 0; 5008 }, 5009 //returns true if there is no value 5010 empty: function(a,b){ 5011 return a.length === 0; 5012 }, 5013 //returns true if there is a value 5014 notEmpty: function(a,b){ 5015 return a.length > 0; 5016 }, 5017 //returns true if there is a value 5018 any: function(a,b){ 5019 return a.length > 0; 5020 }, 5021 //returns true if any value begins with any supplied value 5022 startsWith: function(a,b){ 5023 var fn = function(x,y){ 5024 return x.indexOf(y) === 0; 5025 }; 5026 return intersect(a, b, fn).length > 0; 5027 }, 5028 //returns true if no value begins with any supplied value 5029 notStartsWith: function(a,b){ 5030 var fn = function(x,y){ 5031 return x.indexOf(y) === 0; 5032 }; 5033 return intersect(a, b, fn).length === 0; 5034 }, 5035 //returns true if any value begins with any supplied value 5036 endsWith: function(a,b){ 5037 var fn = function(x,y){ 5038 return x.slice(-y.length) === y; 5039 }; 5040 return intersect(a, b, fn).length > 0; 5041 }, 5042 //returns true if no value begins with any supplied value 5043 notEndsWith: function(a,b){ 5044 var fn = function(x,y){ 5045 return x.slice(-y.length) === y; 5046 }; 5047 return intersect(a, b, fn).length === 0; 5048 }, 5049 //returns true if any value contains any supplied value 5050 contains: function(a,b){ 5051 var fn = function(x,y){ 5052 return x.match(new RegExp(y, 'g')); 5053 }; 5054 return intersect(a, b, fn).length > 0; 5055 }, 5056 //returns true if no value contains any supplied value 5057 notContains: function(a,b){ 5058 var fn = function(x,y){ 5059 return x.match(new RegExp(y, 'g')); 5060 }; 5061 return intersect(a, b, fn).length === 0; 5062 }, 5063 //returns true if value is greater or equal to supplied value 5064 atLeast: function(a,b){ 5065 return a[0] >= b[0]; 5066 }, 5067 //returns true if value is less than or equal to supplied value 5068 atMost: function(a,b){ 5069 return a[0] <= b[0]; 5070 }, 5071 //returns true if number is greater than supplied value 5072 greaterThan: function(a,b){ 5073 return a[0] > b[0]; 5074 }, 5075 //returns true if number is less than supplied value 5076 lessThan: function(a,b){ 5077 return a[0] < b[0]; 5078 }, 5079 //returns true if number is between two given values 5080 between: function(a,b){ 5081 return a[0] > b[0] && a[0] < b[1]; 5082 }, 5083 //returns true if number is not between two given values 5084 notBetween: function(a,b){ 5085 return a[0] < b[0] || a[0] > b[1]; 5086 }, 5087 //returns true if value is between two supplied dates 5088 inTimeFrame: function(formVals,compVals){ 5089 return (new Date(formVals[0])) > (new Date(compVals[0])) && (new Date(formVals[0])) < (new Date(compVals[1])); 5090 }, 5091 //returns true if value is not between two supplied dates 5092 notInTimeFrame: function(formVals,compVals){ 5093 return (new Date(formVals[0]) < new Date(compVals[0]) || new Date(formVals[0]) > new Date(compVals[1])); 5094 }, 5095 //returns true if value is before now 5096 inPast: function(formVals,compVals){ 5097 return (new Date(formVals[0])) < (new Date()); 5098 }, 5099 //returns true if value is now or in the future 5100 notInPast: function(formVals,compVals){ 5101 return (new Date(formVals[0])) >= (new Date()); 5102 }, 5103 //returns true if value is before given date 5104 before: function(formVals,compVals){ 5105 return (new Date(formVals[0])) < (new Date(compVals[0])); 5106 }, 5107 //returns true if value is after given date 5108 after: function(formVals,compVals){ 5109 return (new Date(formVals[0])) > (new Date(compVals[0])); 5110 }, 5111 //returns true if value is equal to or before the given date 5112 onOrBefore: function (formVals, compVals){ 5113 return (new Date(formVals[0])) <= (new Date(compVals[0])); 5114 }, 5115 //returns true if value is equal to or after the given date 5116 onOrAfter: function(formVals,compVals){ 5117 return (new Date(formVals[0])) >= (new Date(compVals[0])); 5118 } 5119}; 5120module.exports = comparators; 5121 5122},{}],27:[function(require,module,exports){ 5123var cookie = require("cookie"); 5124 5125/* 5126* Unsets a cookie on all sub domains. 5127* @param cookieName the name of the cookie to remove 5128* @param hostname the name of the host to remove cookies from, or location.hostname if unset 5129* @returns an array of all the domains that were unset. 5130*/ 5131 5132function removeCookieAllDomains (cookieName, hostname){ 5133 hostname = hostname || location.hostname; 5134 var d = new Date(); 5135 d.setFullYear(d.getFullYear() -1); 5136 //Unset on current domain. 5137 var removedDomains = []; 5138 document.cookie = cookie.serialize(cookieName, "", {expires:d, path:"/"}); 5139 removedDomains.push(""); 5140 //Unset on each sub domain... 5141 //So if the current domain is www.foo.bar.baz.com 5142 //We'd unset .www.foo.bar.baz.com, then .foo.bar.baz.com, then .bar.baz.com, then .baz.com; 5143 var hostParts = hostname.split("."); 5144 while(hostParts.length > 1 ){ 5145 var domain = "." + hostParts.join("."); 5146 document.cookie = cookie.serialize(cookieName, "", {expires:d, path:"/", domain:domain}); 5147 removedDomains.push(domain); 5148 hostParts.shift(); 5149 } 5150 return removedDomains; 5151} 5152module.exports.removeCookieAllDomains = removeCookieAllDomains; 5153},{"cookie":5}],28:[function(require,module,exports){ 5154var $ = require("../jquery.js"); 5155var $b = $.build; 5156var fh = require("./fieldHelpers.js"); 5157 5158var currency = {}; 5159module.exports = currency; 5160currency.fieldType = "currency"; 5161 5162var currencyPattern = /[0-9]+/g; 5163 5164var validateCurrency = function (v){ 5165 if(!v){ 5166 return true; 5167 } 5168 return v.match(currencyPattern); 5169} 5170 5171currency.newField = function (field, formData){ 5172 var e = fh.renderInput("text", field, formData); 5173 return { 5174 name:field.Name, 5175 elem:fh.formatStandardField(e, field, formData), 5176 val:$.proxy(e.val, e),
5177 required:field.IsRequired, 5178 validator:validateCurrency, 5179 validatorElem:e, 5180 onChange:function (fn){ 5181 e.on("change", fn); 5182 } 5183 } 5184} 5185 5186},{"../jquery.js":45,"./fieldHelpers.js":29}],29:[function(require,module,exports){ 5187var $ = require("../jquery.js"); 5188var $b = $.build; 5189 5190 5191 5192var fieldHelpers = {}; 5193 5194fieldHelpers.splitSemis = function (str){ 5195 str = "" + str; 5196 return str.split(/\s?;\s?/); 5197}; 5198 5199fieldHelpers.cap = function (s){ 5200 return s.charAt(0).toUpperCase() + s.slice(1); 5201}; 5202 5203fieldHelpers.first = function (){ 5204 for (var i = 0; i < arguments.length; i++){ 5205 var v = arguments[i]; 5206 if(v !== null && v!== undefined){ 5207 return v; 5208 } 5209 } 5210 return null; 5211}; 5212 5213fieldHelpers.getLabelId = function (name, id){ 5214 if(id !== undefined && name != id) { 5215 return "Lbl" + name + " " + "Lbl" + id; 5216 } 5217 return "Lbl" + name; 5218} 5219 5220fieldHelpers.getInstructionId = function (name) { 5221 if(name !== undefined) { 5222 return "Instruct" + name; 5223 } 5224} 5225 5226fieldHelpers.getValidationMsgId = function (name) { 5227 if(name !== undefined) { 5228 return "ValidMsg" + name; 5229 } 5230} 5231 5232fieldHelpers.getMaxLengthId = function (name) { 5233 if(name !== undefined) { 5234 return "MaxLen" + name; 5235 } 5236}; 5237 5238/** 5239 * Appends an ID to a space-separated ARIA attribute (aria-describedby or aria-labelledby). 5240 * Avoids duplicates. Works for any field element. 5241 */ 5242fieldHelpers.appendIdToAria = function (elem, attrName, id) { 5243 if (!elem || !id) return; 5244 var current = (elem.attr(attrName) || "").trim(); 5245 var ids = current ? current.split(" ").filter(Boolean) : []; 5246 if (ids.indexOf(id) === -1) ids.push(id); 5247 elem.attr(attrName, ids.join(" ")); 5248}; 5249 5250/** 5251 * Setup max-length counter when maxlength attribute is present (WCAG on only). 5252 * Adds counter span, wires aria, and updates counter on input, keyup, paste events. 5253 * When WCAG on: if aria-labelledby present, append to it; otherwise aria-describedby. 5254 */ 5255fieldHelpers.setupMaxLength = function (fieldElem, field, formData) { 5256 var isWcagCompliant = formData && formData.ProcessOptions && formData.ProcessOptions.isWcagCompliant; 5257 if (!isWcagCompliant) return null; 5258 var maxlen = fieldElem.attr("maxlength"); 5259 if (!maxlen) return null; 5260 var characterLimit = parseInt(maxlen, 10); 5261 var maxLenId = fieldHelpers.getMaxLengthId(field.Name); 5262 var limitReachedMsg = (formData && formData.maxLengthLimitReachedMsg) || "Maximum character limit reached"; 5263 var remainingMsg = (formData && formData.maxLengthRemainingMsg) || "characters remaining"; 5264 var maxLenSpan = $b("span.mktoMaxLength", {"id": maxLenId, "aria-live": "polite"}, "0 " + remainingMsg); 5265 var currentLabelledBy = (fieldElem.attr("aria-labelledby") || "").trim(); 5266 var ariaAttr = currentLabelledBy ? "aria-labelledby" : "aria-describedby"; 5267 fieldHelpers.appendIdToAria(fieldElem, ariaAttr, maxLenId); 5268 var updateCounter = function () { 5269 var len = (fieldElem.val() || "").length; 5270 var remaining = characterLimit - len; 5271 maxLenSpan.text(remaining <= 0 ? limitReachedMsg : remaining + " " + remainingMsg); 5272 }; 5273 fieldElem.on("input keyup paste", updateCounter); 5274 updateCounter(); 5275 return maxLenSpan; 5276}; 5277 5278fieldHelpers.formatStandardField = function(fieldElem, field, formData){ 5279 var first = fieldHelpers.first; 5280 var fieldWrap; 5281 var maxLenSpan = fieldHelpers.setupMaxLength(fieldElem, field, formData); 5282 var elems = $b.docFrag([ 5283 $b(".mktoOffset").css({width:first(field.OffsetWidth, formData.OffsetWidth, 0)}), 5284 fieldWrap = $b(".mktoFieldWrap",[ 5285 $b("label.mktoLabel.mktoHasWidth", {"for":field.Name, "id":fieldHelpers.getLabelId(field.Name)}, [ 5286 $b(".mktoAsterix", "*"), 5287 $b.html(field.InputLabel) 5288 ]).css({ 5289 width: first(field.LabelWidth, formData.LabelWidth, 0) 5290 }), 5291 $b(".mktoGutter.mktoHasWidth").css({width:first(field.GutterWidth,formData.GutterWidth,0)}), 5292 fieldElem.addClass("mktoHasWidth").css({width:first(field.FieldWidth, formData.FieldWidth, 0 )}), 5293 $b("span.mktoInstruction", {"id":fieldHelpers.getInstructionId(field.Name), "tabindex":"-1"}, 5294 field.Description), 5295 $b(".mktoClear") 5296 ] 5297 ), 5298 $b(".mktoClear") 5299 ]); 5300 if (maxLenSpan) { 5301 fieldWrap.find(".mktoClear").before(maxLenSpan); 5302 } 5303 if(field.IsRequired){ 5304 fieldWrap.addClass("mktoRequiredField"); 5305 } 5306 return elems; 5307} 5308fieldHelpers.renderInput = function (type, field, formData){ 5309 var isWcagCompliant = formData && formData.ProcessOptions && formData.ProcessOptions.isWcagCompliant; 5310 var attrs = { 5311 id:field.Name, 5312 name:field.Name, 5313 placeholder:field.PlaceholderText, 5314 title:field.Description, 5315 maxlength:field.Maxlength || 2000 5316 }; 5317 if (isWcagCompliant) { 5318 if (field.Description) { 5319 attrs["aria-describedby"] = fieldHelpers.getInstructionId(field.Name); 5320 } 5321 } else { 5322 attrs["aria-labelledby"] = [fieldHelpers.getLabelId(field.Name), fieldHelpers.getInstructionId(field.Name)].join(" "); 5323 } 5324 var e = $b("input[type="+type+"].mktoField.mkto"+fieldHelpers.cap(type)+"Field", attrs); 5325 return e; 5326} 5327fieldHelpers.isSet = function (v){ 5328 return v !== null && v !== undefined; 5329} 5330fieldHelpers.flatten = function (arr, accum){ 5331 accum = accum || []; 5332 $.each(arr, function (i, v){ 5333 if($.isArray(v)){ 5334 fieldHelpers.flatten(v, accum); 5335 }else{ 5336 accum.push(v); 5337 } 5338 }); 5339 return accum; 5340} 5341fieldHelpers.vals = function (obj){ 5342 return $.map(obj, function (val){return val;}); 5343} 5344 5345fieldHelpers.getFlattenedFields = function (formData){ 5346 var fields = []; 5347 5348 fields = fieldHelpers.flatten(formData.rows); 5349 5350 if(formData.fieldsetRows){ 5351 fields = fields.concat(fieldHelpers.flatten(fieldHelpers.vals(formData.fieldsetRows))
5351); 5352 } 5353 return fields; 5354}; 5355/** 5356* returns an object with a key with value = true for each Datatype in a list of fields 5357* eg: {textarea:true, range:true, date:true} 5358* see: getFlatenenedFields() for how to get a list of fields to pass to this. 5359*/ 5360fieldHelpers.getFieldTypes = function (fields){ 5361 var fieldTypes = {}; 5362 for(var i = 0; i < fields.length; i++){ 5363 fieldTypes[fields[i].Datatype] = true; 5364 } 5365 return fieldTypes; 5366}; 5367/** 5368* returns true if any field in fields list has a set property named propertyName 5369* see: getFlatenenedFields() for how to get a list of fields to pass to this. 5370*/ 5371fieldHelpers.anyFieldHasProperty = function (fields, propertyName){ 5372 for(var i =0; i < fields.length ; i++){ 5373 if(fields[i][propertyName]){ 5374 return true; 5375 } 5376 } 5377 return false; 5378}; 5379 5380fieldHelpers.getFieldsByName = function(fields){ 5381 var fieldsByName = {}; 5382 $.each(fields, function (i, v){ 5383 fieldsByName[v.Name] = v; 5384 }); 5385 return fieldsByName; 5386}; 5387 5388 5389module.exports = fieldHelpers; 5390},{"../jquery.js":45}],30:[function(require,module,exports){ 5391arguments[4][29][0].apply(exports,arguments) 5392},{"../jquery.js":45,"dup":29}],31:[function(require,module,exports){ 5393var $ = require("../jquery.js"); 5394var $b = $.build; 5395var fh = require("./fieldHelpers.js"); 5396 5397var checkbox = {}; 5398module.exports = checkbox; 5399checkbox.fieldType = "checkbox"; 5400 5401var singletonValuePairs = { 5402 "true":"false", 5403 "1":"0", 5404 "Yes":"No", 5405 "yes":"no" 5406} 5407var makeValFn = function (e, singletonValue){ 5408 5409 return function(val){ 5410 var inputs = e.find("input"); 5411 if(arguments.length === 0){ 5412 if(singletonValue){ 5413 //special case for singleton checkbox being used as a true/false. 5414 //These support the forms v1 syntaxes. 1/0 true/false, yes/no 5415 if(inputs.is(":checked")){ 5416 return singletonValue; 5417 }else{ 5418 return singletonValuePairs[singletonValue]; 5419 } 5420 } 5421 inputs = e.find("input:checked"); 5422 5423 var vals = []; 5424 inputs.each(function (){ 5425 vals.push($(this).val()); 5426 }) 5427 if(!vals.length){ 5428 return undefined; 5429 } 5430 if(vals.length == 1){ 5431 return vals[0] 5432 } 5433 return vals; 5434 }else{ 5435 if(singletonValue && typeof val === "boolean"){ 5436 //On a singleton, we accept booleans true/false always. 5437 e.find("input").prop("checked", val); 5438 return; 5439 } 5440 if(singletonValue && val === null){ 5441 //Null on a checkbox is a no-op. 5442 return; 5443 } 5444 if(val && !$.isArray(val)){ 5445 val = "" + val; 5446 val = fh.splitSemis("" + val); 5447 } 5448 e.find("input").prop("checked", false); 5449 if(val){ 5450 $.each(val, function (i, v){ 5451 e.find("input[value='"+v+"']").prop("checked", true); 5452 }) 5453 } 5454 } 5455 } 5456} 5457checkbox.newField = function (field, formData){ 5458 var isWcagCompliant = formData && formData.ProcessOptions && formData.ProcessOptions.isWcagCompliant; 5459 var plVals = field.PicklistValues || []; 5460 var e = $b(".mktoLogicalField.mktoCheckboxList", {title:field.Description}, [ 5461 $.map(plVals, function (val, i){ 5462 var id = "mktoCheckbox_" + (field.Id || field.Name) + "_" +i; 5463 var labelText = val.label || val.name; 5464 5465 //for single value checkboxes, they can use the field name as the id. 5466 //if there is more than one checkbox, we use instead a unique identifier. 5467 if(plVals.length == 1 && !labelText){ 5468 id = field.Name; 5469 } 5470 var inputAttrs = { 5471 name:field.Name, 5472 id:id, 5473 type:"checkbox", 5474 value:val.value, 5475 "aria-required":field.IsRequired 5476 }; 5477 if (isWcagCompliant && plVals.length === 1) { 5478 if (field.Description) { 5479 inputAttrs["aria-describedby"] = fh.getInstructionId(field.Name); 5480 } 5481 } else { 5482 inputAttrs["aria-labelledby"] = [fh.getLabelId(field.Name, id), fh.getInstructionId(field.Name)].join(" "); 5483 } 5484 var elements = [ 5485 $b("input.mktoField", inputAttrs) 5486 ]; 5487 if (labelText || !isWcagCompliant) { 5488 elements.push($b("label", {"for": id, "id": fh.getLabelId(id)}, [ 5489 $b.html(labelText) 5490 ])); 5491 } 5492 return $b.docFrag(elements); 5493 }) 5494 ]); 5495 if(field.IsLabelToLeft){ 5496 e.addClass("mktoLabelToLeft"); 5497 } 5498 var singletonValue = ""; 5499 if(plVals.length === 1){ 5500 if($.inArray(plVals[0].value, Object.keys(singletonValuePairs)) !== -1){ 5501 singletonValue = plVals[0].value; 5502 } 5503 } 5504 return { 5505 name:field.Name, 5506 elem:fh.formatStandardField(e, field, formData), 5507 val:makeValFn(e, singletonValue), 5508 required:field.IsRequired, 5509 requiredValFn:function (v){ 5510 v = $.trim(v); 5511 if(v && singletonValue){ 5512 return v !== singletonValuePairs[singletonValue]; 5513 } 5514 return !!v; 5515 }, 5516 validatorElem:e, 5517 validatorFocusElem:e.find("input:eq(0)"), 5518 onChange:function (fn){
5519 e.on("change", fn); 5520 } 5521 } 5522} 5523},{"../jquery.js":45,"./fieldHelpers.js":29}],32:[function(require,module,exports){ 5524var $ = require("../jquery.js"); 5525var $b = $.build; 5526var fh = require("./fieldHelpers.js"); 5527 5528var date = {}; 5529module.exports = date; 5530date.fieldType = "date"; 5531 5532var checkDate = function (e){ 5533 var elem = e.get(0); 5534 if(elem.validity && !elem.validity.valid){ 5535 //Some browsers support html5 date but give back invalid values as "". 5536 return false; 5537 } 5538 return true; 5539} 5540 5541date.newField = function (field, formData){ 5542 var e = fh.renderInput("date", field, formData); 5543 var locale = "en_US"; 5544 if(formData.ProcessOptions && formData.ProcessOptions.locale){ 5545 locale = formData.ProcessOptions.locale; 5546 } 5547 e.data("mktoLocale", locale); 5548 return { 5549 name:field.Name, 5550 elem:fh.formatStandardField(e, field, formData), 5551 val:$.proxy(e.val, e), 5552 validator:function (){ 5553 return checkDate(e); 5554 }, 5555 required:field.IsRequired, 5556 validatorElem:e, 5557 onChange:function (fn){ 5558 e.on("change", fn); 5559 } 5560 } 5561}; 5562},{"../jquery.js":45,"./fieldHelpers.js":29}],33:[function(require,module,exports){ 5563var $ = require("../jquery.js"); 5564var $b = $.build; 5565var fh = require("./fieldHelpers.js"); 5566//pattern from http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address 5567var emailPattern = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ 5568 5569var email = {}; 5570module.exports = email; 5571email.fieldType = "email"; 5572var checkEmail = function (e){ 5573 var val = e.val() || ""; 5574 if(!val){ 5575 return true; 5576 } 5577 return val.match(emailPattern); 5578} 5579 5580email.newField = function (field, formData){ 5581 var e = fh.renderInput("email", field, formData); 5582 5583 return { 5584 name:field.Name, 5585 elem:fh.formatStandardField(e, field, formData), 5586 val:$.proxy(e.val, e), 5587 required:field.IsRequired, 5588 validator:function (){ 5589 return checkEmail(e); 5590 }, 5591 validatorElem:e, 5592 onChange:function (fn){
5593 e.on("change", fn); 5594 } 5595 } 5596} 5597},{"../jquery.js":45,"./fieldHelpers.js":29}],34:[function(require,module,exports){ 5598var $ = require("../jquery.js"); 5599var $b = $.build; 5600var fh = require("./fieldHelpers.js"); 5601 5602 5603var $ = require("../jquery.js"); 5604var $b = $.build; 5605var fh = require("./fieldHelpers.js"); 5606 5607var number = {}; 5608module.exports = number; 5609number.fieldType = "number"; 5610 5611function coerceNumberOrBlank(num){ 5612 //any falsey value except 0 turns to empty string. Yes, -0 is different than 0 in JS. 5613 if(!num && num !== 0){ 5614 return ''; 5615 } 5616 return ''+num; 5617} 5618 5619function checkValid(e, min, max){ 5620 var elem = e.get(0); 5621 if(elem.validity){ 5622 // badInput: browser accepted input it cannot convert (e.g. "abc" in a number field). 5623 // Some browsers (Safari) sanitise element.value to "" but leave validity.valid=true, 5624 // so we check badInput explicitly rather than relying on valid alone. 5625 if(!elem.validity.valid || elem.validity.badInput){ return false; } 5626 } 5627 var v = e.val(); 5628 if(!v){ 5629 return true; 5630 } 5631 return checkNumber(v, min, max); 5632} 5633 5634function checkNumber(v, min, max){ 5635 if(v === "" || v === null){ 5636 return true; 5637 } 5638 v = parseFloat(v, 10); 5639 if(isNaN(v)){ 5640 return false; 5641 } 5642 5643 if(fh.isSet(min) && v < min){ 5644 return false; 5645 } 5646 if(fh.isSet(max) && v > max){ 5647 return false; 5648 } 5649 return true; 5650} 5651 5652function makeValFn(e, min, max){ 5653 return function (v){ 5654 if(arguments.length === 0){ 5655 var val = e.val(); 5656 if(fh.isSet(val)){ 5657 var result = parseFloat(val); 5658 if(isNaN(result)){ 5659 return ""; 5660 } 5661 return result; 5662 } 5663 return null; 5664 }else{ 5665 e.val(v); 5666 } 5667 } 5668} 5669 5670number.newField = function(field, formData){ 5671 var e = fh.renderInput("number", field, formData); 5672 // WebKit (Safari) sanitises element.value to "" for bad input but sets no validity flags. 5673 // Track bad input state via the input event: an event that fires with value="" when the 5674 // field previously also had value="" means bad chars were typed (not a clear from valid). 5675 var lastKnownValue = ''; 5676 var hasBadInput = false; 5677 e.on('input', function(){ 5678 var elem = e.get(0); 5679 if(elem.validity){ 5680 if(!elem.validity.valid || elem.validity.badInput){ 5681 hasBadInput = true; 5682 lastKnownValue = ''; 5683 return; 5684 } 5685 } 5686 var v = elem.value; 5687 if(v !== ''){ 5688 lastKnownValue = v; 5689 hasBadInput = false; 5690 } else if(lastKnownValue !== ''){ 5691 lastKnownValue = ''; 5692 hasBadInput = false; // transitioned from valid value to empty: user cleared it 5693 } else { 5694 hasBadInput = true; // empty→empty input event: WebKit bad input 5695 } 5696 }); 5697 5698 e.attr({ 5699 min:coerceNumberOrBlank(field.MinimumNumber), 5700 max:coerceNumberOrBlank(field.MaximumNumber), 5701 step:coerceNumberOrBlank(field.StepNumber) 5702 }); 5703 5704 return { 5705 name:field.Name, 5706 val:makeValFn(e, field.MinimumNumber, field.MaximumNumber), 5707 elem:fh.formatStandardField(e, field, formData), 5708 required:field.IsRequired, 5709 validator:function (){ 5710 if(hasBadInput){ return false; } 5711 return checkValid(e, field.MinimumNumber, field.MaximumNumber); 5712 }, 5713 validatorElem:e, 5714 onChange:function (fn){
5715 e.on("change", fn); 5716 } 5717 } 5718} 5719 5720},{"../jquery.js":45,"./fieldHelpers.js":29}],35:[function(require,module,exports){ 5721var $ = require("../jquery.js"); 5722var $b = $.build; 5723var fh = require("./fieldHelpers.js"); 5724 5725var radio = {}; 5726module.exports = radio; 5727radio.fieldType = "radio"; 5728 5729var makeValFn = function (e){ 5730 return function (val){ 5731 if(arguments.length === 0){ 5732 var value = e.find("input:checked").val(); 5733 return value; 5734 }else{ 5735 e.find("input").prop('checked', false); 5736 if(val !== ""){ 5737 e.find("input[value='"+val+"']").prop('checked', true) 5738 }else{ 5739 e.find("input").each(function (i, input){ 5740 input = $(input); 5741 if(input.val() === ""){ 5742 input.prop("checked", true); 5743 } 5744 }) 5745 } 5746 5747 } 5748 } 5749} 5750 5751radio.newField = function (field, formData){ 5752 var isWcagCompliant = formData && formData.ProcessOptions && formData.ProcessOptions.isWcagCompliant; 5753 var containerAttrs = { title: field.Description }; 5754 if (isWcagCompliant) { 5755 containerAttrs.role = "radiogroup"; 5756 containerAttrs["aria-labelledby"] = fh.getLabelId(field.Name); 5757 } 5758 var e = $b(".mktoRadioList", containerAttrs, [ 5759 $.map(field.PicklistValues || [], function (val, i){ 5760 var id = "mktoRadio_" + field.Id + "_" +i; 5761 if(!i){ 5762 firstVal = val.value; 5763 } 5764 var inputAttrs = { 5765 name: field.Name, 5766 id: id, 5767 value: val.value, 5768 "aria-required": field.IsRequired, 5769 "aria-labelledby": [fh.getLabelId(field.Name), fh.getLabelId(id), fh.getInstructionId(field.Name)].join(" ") 5770 }; 5771 if (isWcagCompliant) { 5772 inputAttrs["aria-labelledby"] = [fh.getLabelId(id), fh.getInstructionId(field.Name)].join(" "); 5773 } 5774 return $b.docFrag([ 5775 $b("input[type=radio].mktoField", inputAttrs), 5776 $b("label", {"for":id, "id":fh.getLabelId(id)}, [ 5777 $b.html(val.label || val.name) 5778 ]) 5779 ]) 5780 }) 5781 ]); 5782 if(field.IsLabelToLeft){ 5783 e.addClass("mktoLabelToLeft"); 5784 } 5785 var valFn = makeValFn(e); 5786 return { 5787 name:field.Name, 5788 elem:fh.formatStandardField(e, field, formData), 5789 val:valFn, 5790 required:field.IsRequired, 5791 validatorElem:e, 5792 validatorFocusElem:e.find("input:eq(0)"), 5793 onChange:function (fn){
5794 e.on("change", fn); 5795 } 5796 } 5797} 5798 5799},{"../jquery.js":45,"./fieldHelpers.js":29}],36:[function(require,module,exports){ 5800var $ = require("../jquery.js"); 5801var $b = $.build; 5802var fh = require("./fieldHelpers.js"); 5803var Modernizr = require("../modernizr.js"); 5804 5805var range = {}; 5806module.exports = range; 5807range.fieldType = "range"; 5808 5809var checkValid = function (e, min, max){ 5810 var elem = e.get(0); 5811 if(elem.validity && !elem.validity.valid){ 5812 //Some browsers support html5 but don't support min/max on numbers. 5813 //For those browsers, we can't trust valid and have to do the rest ourselves. 5814 return false; 5815 } 5816 var v = e.val(); 5817 if(!v){ 5818 return true; 5819 } 5820 return checkNumber(v, min, max); 5821} 5822 5823var checkNumber = function (v, min, max){ 5824 v = parseFloat(v, 10); 5825 if(isNaN(v)){ 5826 return false; 5827 } 5828 if(fh.isSet(min) && v < min){ 5829 return false; 5830 } 5831 if(fh.isSet(max) && v > max){ 5832 return false; 5833 } 5834 return true; 5835} 5836 5837var makeValFn = function (e, min, max){ 5838 return function (v){ 5839 if(arguments.length === 0){ 5840 var val = e.val(); 5841 if(fh.isSet(val)){ 5842 var result = parseFloat(val, 10); 5843 if(isNaN(result)){ 5844 return null; 5845 } 5846 return result; 5847 } 5848 return null; 5849 }else{ 5850 if(v === null || v === undefined || v === ""){ 5851 return; //it's not possible to unset a range. 5852 } 5853 if(checkNumber(v, min, max)){ 5854 e.val(parseFloat(v, 10)); 5855 e.trigger("change") 5856 } 5857 } 5858 } 5859} 5860 5861range.newField = function (field, formData){ 5862 5863 var e, valueText, rangeValue, arrowWrap; 5864 5865 var min = field.MinimumNumber || 0; 5866 var max = field.MaximumNumber || 100; 5867 var wrap = $b(".mktoLogicalField.mktoRangeField", [ 5868 rangeValue = $b(".mktoRangeValue", [ 5869 arrowWrap = $b(".mktoRangeValueArrowWrap", $b(".mktoRangeValueArrow")), 5870 valueText = $b(".mktoRangeValueText", "" + field.MinimumNumber || 0 ) 5871 ]), 5872 e = $b("input[type=range].mktoField", { 5873 id:field.Name, 5874 name:field.Name, 5875 min:min, 5876 max:max, 5877 step:field.StepNumber || 1, 5878 title:field.Description, 5879 "aria-labelledby":[fh.getLabelId(field.Name), fh.getInstructionId(field.Name)].join(" ") 5880 }).addClass("mktoHasWidth").css({width:fh.first(field.FieldWidth, formData.FieldWidth, 0 )}) 5881 ]).hover(function (){ 5882 wrap.addClass("mktoHover"); 5883 updateValueText(); 5884 },function (){ 5885 wrap.removeClass("mktoHover"); 5886 }); 5887 if(!Modernizr.csstransforms){ 5888 arrowWrap.addClass("mktoArrowImage"); 5889 } 5890 5891 var updateValueText = function (){ 5892 var val = e.val() || 0; 5893 valueText.html(""+val); 5894 var dragSliderSize = 12; 5895 var noCubicEase = e.data("mktoNoCubicEase"); 5896 var pxAboveSlider = e.data("mktoPxAboveSlider") || 0; 5897 var pctVal = (val - min)/ (max - min); 5898 var tgtX = e.width() * pctVal; 5899 5900 //this fudging with the tgtX is because the meaning of a range slider's draghandle changes as it slides. 5901 // -----------[x]----------- here the center of the draghandle is indicating the value of 50 out of 100 5902 // [x]---------------------- here the left side of the draghandle is indicating the value of 0 out 100 5903 // -----------------------[x] here the right side of the draghandle is indicating the value of 100 out of 1000 5904 //However, we want our popup to always point at the center of the slider. 5905 //Different browsers implement their sliders differently, so best case is getting close without probably 5906 //actually ever being exacty right in any browser. A cubic easing seems to do the job well. 5907 var fudge = 0; 5908 if(!noCubicEase){ 5909 if(pctVal < 0.5){ 5910 fudge = Math.pow((1-pctVal), 3) * (dragSliderSize/2); 5911 } 5912 if(pctVal > 0.5){ 5913 fudge = -1 * Math.pow(pctVal, 3) * (dragSliderSize/2); 5914 } 5915 tgtX += Math.floor(fudge); 5916 } 5917 5918 var rangeOffset = tgtX - (rangeValue.outerWidth() / 2); 5919 var arrowOffset = (valueText.outerWidth() / 2) - (arrowWrap.outerWidth()/ 2 ); 5920 //console.log({ val:e.val(), min:min, max:max, pctVal:pctVal, tgtX:tgtX, width:e.width(), rangeOffset:rangeOffset, rangeWidth:rangeValue.width(), rangeOuterWidth:rangeValue.outerWidth(), valueTextWidth: valueText.outerWidth()} ); 5921 rangeValue.css("margin-left", rangeOffset); 5922 rangeValue.css("margin-top", -1 * (arrowWrap.outerHeight() + valueText.outerHeight() + pxAboveSlider)); 5923 arrowWrap.css("margin-left", arrowOffset); 5924 }
5925 e.on('change', updateValueText); 5926 e.on('input', updateValueText); 5927 e.data("mktoRangeUpdate", updateValueText); 5928 //TODO: should probably be on mktoFormRender event instead. 5929 $("body").on("mktoRender", updateValueText); 5930 return { 5931 name:field.Name, 5932 val:makeValFn(e, field.MinimumNumber, field.MaximumNumber), 5933 elem:fh.formatStandardField(wrap, field, formData), 5934 required:field.IsRequired, 5935 validator:function (){ 5936 return checkValid(e, min, max); 5937 }, 5938 validatorElem:e, 5939 onChange:function (fn){ 5940 e.on("change", fn); 5941 } 5942 } 5943} 5944 5945},{"../jquery.js":45,"../modernizr.js":48,"./fieldHelpers.js":29}],37:[function(require,module,exports){ 5946var $ = require("../jquery.js"); 5947var $b = $.build; 5948var fh = require("./fieldHelpers.js"); 5949 5950var phonePattern = /^([0-9()+. \t-])+(\s?(x|ext|extension)\s?([0-9()])+)?$/ 5951 5952var tel = {}; 5953module.exports = tel; 5954tel.fieldType = "phone"; 5955var checkPhone = function (e){ 5956 var val = e.val() || ""; 5957 if(!val){ 5958 return true; 5959 } 5960 return val.match(phonePattern); 5961} 5962 5963tel.newField = function (field, formData){ 5964 var e = fh.renderInput("tel", field, formData); 5965 return { 5966 name:field.Name, 5967 elem:fh.formatStandardField(e, field, formData), 5968 val:$.proxy(e.val, e), 5969 required:field.IsRequired, 5970 validator:function (){ 5971 return checkPhone(e); 5972 }, 5973 validatorElem:e, 5974 onChange:function (fn){
5975 e.on("change", fn); 5976 } 5977 } 5978} 5979},{"../jquery.js":45,"./fieldHelpers.js":29}],38:[function(require,module,exports){ 5980var $ = require("../jquery.js"); 5981var $b = $.build; 5982var fh = require("./fieldHelpers.js"); 5983 5984var text = {}; 5985module.exports = text; 5986text.fieldType = "string"; 5987 5988text.newField = function (field, formData){ 5989 var maxlen = field.Maxlength || 255; 5990 var e = fh.renderInput("text", field, formData); 5991 if(field.FieldMask){ 5992 e.addClass("mktoInputMask").data("mktoInputMask", field.FieldMask); 5993 } 5994 5995 return { 5996 name:field.Name, 5997 elem:fh.formatStandardField(e, field, formData), 5998 val:function (v){ 5999 if(arguments.length === 0){ 6000 return e.val(); 6001 }else{ 6002 if(v && v.length > maxlen ){ 6003 v = v.substring(0, maxlen); 6004 } 6005 return e.val(v); 6006 } 6007 }, 6008 required:field.IsRequired, 6009 validatorElem:e, 6010 onChange:function (fn){ 6011 e.on("change", fn); 6012 } 6013 } 6014} 6015 6016},{"../jquery.js":45,"./fieldHelpers.js":29}],39:[function(require,module,exports){ 6017var $ = require("../jquery.js"); 6018var $b = $.build; 6019var fh = require("./fieldHelpers.js"); 6020 6021var url = {}; 6022module.exports = url; 6023url.fieldType = "url"; 6024var urlCharactersPattern = /^[a-zA-z0-9\.\-_~:/\?#\[\]@!$&\'\(\)\*\+,;=%]*$/ 6025 6026var validateUrl = function (v){ 6027 if(!v){ 6028 return true; 6029 } 6030 var protocolEndIdx = v.indexOf("://"); 6031 if(protocolEndIdx < 1){ 6032 return false; 6033 } 6034 return v.match(urlCharactersPattern); 6035} 6036 6037url.newField = function (field, formData){ 6038 var e = fh.renderInput("url", field, formData); 6039 6040 return { 6041 name:field.Name, 6042 elem:fh.formatStandardField(e, field, formData), 6043 val:$.proxy(e.val, e), 6044 required:field.IsRequired, 6045 validatorElem:e, 6046 validator:validateUrl, 6047 onChange:function (fn){
6048 e.on("change", fn); 6049 } 6050 } 6051} 6052 6053},{"../jquery.js":45,"./fieldHelpers.js":29}],40:[function(require,module,exports){ 6054var $ = require("../jquery.js"); 6055var $b = $.build; 6056var fh = require("./fieldHelpers.js"); 6057 6058var makeValFn = function (e, isMultiselect){ 6059 return function(val){ 6060 if(arguments.length === 0){ 6061 return e.val(); 6062 }else{ 6063 if(isMultiselect && val && !$.isArray(val)){ 6064 val = fh.splitSemis(val); 6065 } 6066 return e.val(val); 6067 } 6068 } 6069}; 6070 6071var select = {}; 6072module.exports = select; 6073select.fieldType = "picklist"; 6074select.newField = function (field, formData){ 6075 var e = 6076 $b("select.mktoField", {id:field.Name, name:field.Name, title:field.Description, 6077 "aria-labelledby":[fh.getLabelId(field.Name), fh.getInstructionId(field.Name)].join(" ")}, [ 6078 $.map(field.PicklistValues || [], function (val, i){ 6079 if(!val.isDefault || val.selected){ 6080 return $b("option", {value:val.value}, val.label || val.name); 6081 } 6082 }) 6083 ]); 6084 if(field.IsMultiselect){ 6085 e.attr("multiple", "multiple"); 6086 e.attr("size", field.VisibleRows || 5); 6087 } 6088 6089 return { 6090 name:field.Name, 6091 elem:fh.formatStandardField(e, field, formData), 6092 val:makeValFn(e, field.IsMultiselect), 6093 required:field.IsRequired, 6094 validatorElem:e, 6095 onChange:function (fn){
6096 e.on("change", fn); 6097 } 6098 } 6099} 6100},{"../jquery.js":45,"./fieldHelpers.js":29}],41:[function(require,module,exports){ 6101var $ = require("../jquery.js"); 6102var $b = $.build; 6103var fh = require("./fieldHelpers.js"); 6104 6105var textarea = {}; 6106module.exports = textarea; 6107textarea.fieldType = "textarea"; 6108 6109textarea.newField = function (field, formData){ 6110 var maxlen = field.Maxlength || 2000; 6111 var isWcagCompliant = formData && formData.ProcessOptions && formData.ProcessOptions.isWcagCompliant; 6112 var attrs = { 6113 id: field.Name, 6114 name: field.Name, 6115 placeholder: field.PlaceholderText, 6116 rows: Math.max(2, field.VisibleRows || 2), 6117 title: field.Description 6118 }; 6119 if (isWcagCompliant) { 6120 if (field.Description) { 6121 attrs["aria-describedby"] = fh.getInstructionId(field.Name); 6122 } 6123 } else { 6124 attrs["aria-labelledby"] = [fh.getLabelId(field.Name), fh.getInstructionId(field.Name)].join(" "); 6125 } 6126 var e = $b("textarea.mktoField", attrs); 6127 try{ 6128 e.attr("maxlength", maxlen); 6129 }catch(ex){ 6130 // broken IE compatibility mode attributes http://bugs.jquery.com/ticket/12577 6131 e.get(0).setAttribute("maxlength", "" + maxlen); 6132 } 6133 6134 return { 6135 name:field.Name, 6136 elem:fh.formatStandardField(e, field, formData), 6137 val:function (v){ 6138 if(arguments.length === 0){ 6139 return e.val(); 6140 }else{ 6141 if(v && v.length > maxlen ){ 6142 v = v.substring(0, maxlen); 6143 } 6144 return e.val(v); 6145 } 6146 }, 6147 required:field.IsRequired, 6148 validatorElem:e, 6149 onChange:function (fn){
6150 e.on("change", fn); 6151 } 6152 } 6153} 6154},{"../jquery.js":45,"./fieldHelpers.js":29}],42:[function(require,module,exports){ 6155var $ = require("./jquery.js"); 6156var $b = $.build; 6157var Validation = require("./validation.js"); 6158var measure = require("./measure.js"); 6159var fh = require("./fields/fieldhelpers.js"); 6160var cap = fh.cap; 6161var isSet = fh.isSet; 6162var first = fh.first; 6163var querystring = require("querystring"); 6164var url = require("url"); 6165var cookie = require("cookie"); 6166var cookieHelper = require("./cookiehelper.js"); 6167var tokenTemplate = require("./tokenTemplate.js"); 6168var changeManager = require("./changeManager.js"); 6169var urlHelper = require("./urlhelper.js"); 6170var prefillCoercer = require("./prefillcoercer.js"); 6171var iframeProxy = require("./iframeproxy.js"); 6172var log = require('./safelog.js'); 6173var shajs = require('sha.js'); 6174 6175var fieldTypes = [ 6176 require("./fields/inputRadio.js"), 6177 require("./fields/inputDate.js"), 6178 require("./fields/inputEmail.js"), 6179 require("./fields/inputCheckbox.js"), 6180 require("./fields/select.js"), 6181 require("./fields/inputRange.js"), 6182 require("./fields/inputText.js"), 6183 require("./fields/inputUrl.js"), 6184 require("./fields/inputTel.js"), 6185 require("./fields/inputNumber.js"), 6186 require("./fields/textarea.js"), 6187 require("./fields/currency.js") 6188]; 6189 6190var fieldTypeMap = {}; 6191$.each(fieldTypes, function (i, type){ 6192 fieldTypeMap[type.fieldType] = type; 6193}); 6194//Add int and double as aliases for number 6195fieldTypeMap["int"] = fieldTypeMap.number; 6196fieldTypeMap["double"] = fieldTypeMap.number; 6197fieldTypeMap.single_checkbox = fieldTypeMap.checkbox; 6198 6199 6200 6201var comparators = require("./comparators.js"); 6202 6203//Browser detection... All conditional JS code should NOT use these, 6204//and should instead use Modernizr to detect support for individual features. 6205//However, for ease of use when styling we will add .ie6 .ie7 and .ie8 classes into 6206//the dom to minizimze stylesheet hacks for these three historic bad-boys. 6207var oldIeMatch =navigator.userAgent.match(/msie ([6789])/i); 6208var oldIe = oldIeMatch? "ie"+oldIeMatch[1] : ""; 6209 6210// Cache location.href value, to be used later for _mktoReferrer 6211var originalLocationHref = location.href; 6212function getNonce() { 6213 return document && document.currentScript && document.currentScript.nonce; 6214} 6215var nonceValue = getNonce(); 6216var Form = function (formData, modernizr, opts){ 6217 var pub = {}; 6218 var priv = {}; 6219 priv.hiddenFields = { 6220 formid:formData.Id 6221 }; 6222 priv.onSuccess = []; 6223 priv.onSubmit = []; 6224 priv.onValidate = []; 6225 priv.values = {}; 6226 priv.fieldsByName = fh.getFieldsByName(fh.getFlattenedFields(formData)); 6227 priv.changeMap = changeManager.getChangeMap(priv.fieldsByName, formData); 6228 priv.fieldElemsByName = {}; 6229 priv.latestFieldsByName = {}; 6230 priv.canSubmit = formData.Status != "draft" && !formData.isPreview; 6231 6232 var updateDependentFields = function (subjectField){ 6233 var dependentFields = priv.changeMap[subjectField] || []; 6234 var fireRender = false;
6235 var renderCtx = { 6236 defaultValuesToSet:{}, 6237 fieldsToCheck:[] 6238 } 6239 $.each(dependentFields, function (i, fieldName){ 6240 var currentElem = priv.fieldElemsByName[fieldName]; 6241 if(!currentElem || !currentElem[0] || !$.contains(priv.formElem[0], currentElem[0])){ 6242 //element is in a nested fieldset, or progressive profiling block and fieldset is hidden, so currentElem is not in the DOM tree. 6243 //We can just bail out here, this field will be processed when the fieldset is re-shown. 6244 return; 6245 } 6246 var currentlyShown = !currentElem.hasClass("mktoPlaceholder"); 6247 var currentField = priv.fieldsByName[fieldName]; 6248 6249 var fieldChangeInfo = changeManager.fieldChangeChecker(currentField.VisibilityRule, pub.getValues()); 6250 var shouldBeShown = fieldChangeInfo.show; 6251 6252 var updateField = function (field, currentElem){ 6253 var e = renderField(field, renderCtx); 6254 var colObj = wrapColField(e); 6255 var newElem = colObj.elem; 6256 newElem.hide(); 6257 currentElem.replaceWith(newElem); 6258 if(isSmallViewport()){ 6259 removeFixedWidthContents(newElem); 6260 } 6261 // LM-100596: Visibility Rule always check Picklist value against full value list 6262 // Keep latest field information (picklist values) in storage 6263 priv.latestFieldsByName[fieldName] = field; 6264 return newElem; 6265 }; 6266 6267 var hideField = function (field, currentElem){ 6268 var newElem = $b(".mktoPlaceholder.mktoPlaceholder"+field.Name); 6269 currentElem.replaceWith(newElem); 6270 return newElem; 6271 }; 6272 6273 //If the field is aready shown and set to show... 6274 // 1. if it is a picklist, filter its picklist values based on the rule. 6275 //If the field is already shown and set to hide... 6276 // 1. hide the field 6277 //If the field is hidden and set to show... 6278 // 1. filter its picklist values based on the rule. 6279 // 2. show the field 6280 //If the field is hidden and set to hide 6281 // 1. do nothing. 6282 6283 var f, newElem; 6284 if(currentlyShown && shouldBeShown){ 6285 f = changeManager.applyPicklistAlterations(currentField, fieldChangeInfo.rule); 6286 // LM-100596: Visibility Rule always check Picklist value against full value list 6287 // Only update the field if the rule changes the field object for real 6288 // Comparison in JSON string, against most recently updated field information 6289 if(JSON.stringify(f) !== JSON.stringify(priv.latestFieldsByName[fieldName])) { 6290 newElem = updateField(f, currentElem); 6291 newElem.show(); //no need to fade in, just show updated field. 6292 fireRender = true; 6293 } 6294 } 6295 if(currentlyShown && !shouldBeShown){ 6296 newElem = hideField(currentField, currentElem); 6297 priv.fieldElemsByName[fieldName] = newElem; 6298 renderCtx.fieldsToCheck.push(currentField); 6299 } 6300 if(!currentlyShown && shouldBeShown){ 6301 f = changeManager.applyPicklistAlterations(currentField, fieldChangeInfo.rule); 6302 newElem = updateField(f, currentElem); 6303 newElem.show(); 6304 renderCtx.fieldsToCheck.push(currentField); 6305 fireRender = true; 6306 } 6307 if(newElem){ 6308 priv.fieldElemsByName[fieldName] = newElem; 6309 } 6310 6311 if(currentField.Datatype == 'fieldset'){ 6312 //if the fieldset was the subject of a show hide, we need to evaluate all its children 6313 updateDependentFields(currentField.Name); 6314 } 6315 if(fireRender && newElem && priv.validation){ 6316 priv.validation.initScoped(newElem); 6317 } 6318 }); 6319 pub.setValues(renderCtx.defaultValuesToSet); 6320 $.each(renderCtx.fieldsToCheck, function (i, field){ 6321 updateDependentFields(field.Name) 6322 }); 6323 6324 if(fireRender && $("body").data("mktoRendered")){ 6325 //Fire this only it's happening after the initial render. 6326 $("body").trigger("mktoRender", pub); 6327 } 6328 } 6329 6330 var renderField = function (field, renderCtx){ 6331 var defaultValue = priv.values[field.Name] || field.DefaultValue || field.InputInitialValue; 6332 6333 if(fieldTypeMap[field.Datatype]){ 6334 var fieldData = fieldTypeMap[field.Datatype].newField(field, formData); 6335 fieldData.validationMessage = fieldData.validationMessage || field.ValidationMessage; 6336 fieldData.requiredMessage = fieldData.requiredMessage || field.RequiredMessage; 6337 if(fieldData.required){ 6338 if(!fieldData.validatorElem){ 6339 throw new Error("Required fields must have a validatorElem"); 6340 } 6341 fieldData.validatorElem.addClass("mktoRequired"); 6342 if(field.Datatype != 'single_checkbox' && field.Datatype != 'checkbox' && field.Datatype != 'radio'){ 6343 fieldData.validatorElem.attr("aria-required", "true"); 6344 } 6345 } 6346 if(priv.changeMap[field.Name]){ 6347 fieldData.onChange(function (e){ 6348 updateDependentFields(field.Name); 6349 }) 6350 } 6351 if(isSet(defaultValue)){ 6352 //Defer setting default values until form has all fields rendered, so that
6353 //dependendent fields for conditional display will be set. 6354 renderCtx.defaultValuesToSet[field.Name] = defaultValue; 6355 } 6356 var descriptor = $b(".mktoFieldDescriptor", fieldData.elem); 6357 descriptor.data("mktoFieldDescriptor", fieldData); 6358 return descriptor; 6359 }else if (field.Datatype == "htmltext" || field.Datatype == "richtext"){ 6360 return $b.docFrag([ 6361 $b(".mktoOffset.mktoHasWidth").css({width:first(field.OffsetWidth, formData.OffsetWidth, 0)}), 6362 $b(".mktoFieldWrap",[ 6363 $b(".mktoHtmlText.mktoHasWidth", [$b.html(field.Htmltext || field.InputLabel)]) 6364 .css({ 6365 width: first(field.LabelWidth, formData.LabelWidth, 0) 6366 }), 6367 $b(".mktoClear") 6368 ]), 6369 $b(".mktoClear") 6370 ]); 6371 }else if (field.Datatype == "hidden"){ 6372 var ch = field.InputSourceChannel; 6373 var sel = field.InputSourceSelector; 6374 var name = field.Name; 6375 var value = ""; 6376 if(ch == "url" && sel){ 6377 var qsObj = querystring.parse(location.search.replace("?", "")); 6378 value = qsObj[sel] || "" 6379 }else if (ch == "cookie" && sel){ 6380 var cook = cookie.parse(document.cookie); 6381 value = cook[sel]; 6382 }else if (ch == "referrer" && sel){ 6383 var urlObj = url.parse(document.referrer, true); 6384 value = urlObj.query[sel]; 6385 } 6386 if(!value && defaultValue){ 6387 value = defaultValue; 6388 } 6389 renderCtx.defaultValuesToSet[name] = value; 6390 return makeHiddenField(value, name); 6391 } 6392 else if (field.Datatype == "fieldset"){ 6393 var fieldsetRows = formData.fieldsetRows[field.Id.toString()] || []; 6394 if(!fieldsetRows.length){ 6395 return null; 6396 } 6397 var fieldElem = $b("fieldset",[ 6398 $b("legend", $b.html(field.InputLabel)), 6399 $.map(fieldsetRows, function (row, i){ 6400 return renderRow(row, i, renderCtx); 6401 }) 6402 ]); 6403 if(fieldsetRows.length && fieldsetRows[0].length){ 6404 fieldElem.css({"padding-right":first(fieldsetRows[0][0].OffsetWidth,formData.OffsetWidth,0)}) 6405 } 6406 return fieldElem; 6407 } 6408 else if(field.Datatype=="profiling"){ 6409 return; 6410 }else { 6411 log("invalid data type: "+ field.Datatype); 6412 } 6413 } 6414 6415 var renderProfiling = function (field, renderCtx){ 6416 //see if we have values for any of the fieldset rows. 6417 //Evict all fields that don't have a value set. 6418 //Evict all fieldset rows that have no fields, up until you hit the profiling Field Number 6419 //then render the resulting data as normal rows. 6420 6421 var po = formData.ProcessOptions; 6422 var profilingNum = 0; 6423 if(po && po.profiling && po.profiling.numberOfProfilingFields){ 6424 profilingNum = po.profiling.numberOfProfilingFields; 6425 } 6426 var maxFields = field.ProfilingFieldNumber || profilingNum; 6427 var fieldsetRows = formData.fieldsetRows[field.Id.toString()] || []; 6428 var cleanfieldsetRows = []; 6429 var fieldCount = 0; 6430 $.each(fieldsetRows, function (i, row){ 6431 var cleanFields = []; 6432 var filledFields = []; 6433 if(formData.filledFields){ 6434 filledFields = formData.filledFields; 6435 } 6436 $.each(row, function (j, f){ 6437 if(!isSet(priv.values[f.Name]) && $.inArray(f.Name, filledFields) == -1 && fieldCount < maxFields){ 6438 cleanFields.push(f); 6439 fieldCount++; 6440 } 6441 }); 6442 if(cleanFields.length > 0){ 6443 cleanfieldsetRows.push(cleanFields); 6444 } 6445 }); 6446 return $b.docFrag($.map(cleanfieldsetRows, function (row, i){ 6447 return renderRow(row, i, renderCtx) 6448 })); 6449 } 6450 6451 var wrapColField = function (fieldElem){ 6452 var fieldWidth = 0; 6453 var colElem; 6454 if(fieldElem.nodeType == 11){ 6455 colElem = $b(".mktoFormCol", fieldElem); 6456 }else{ 6457 colElem = fieldElem.addClass("mktoFormCol"); 6458 } 6459 fieldWidth += measure.measure(colElem).w; 6460 colElem.css("margin-bottom", formData.LineMargin || 0); 6461 return {elem:colElem, width:fieldWidth} 6462 } 6463 6464 var renderRow = function (row,i,renderCtx){ 6465 var rowWidth = 0; 6466 //special case for profiling 6467 //it is always the only field in its row 6468 //and will end up rendering child rows, but without any wrappers. 6469 if(row.length == 1 && row[0].Datatype == "profiling"){ 6470 return renderProfiling(row[0], renderCtx); 6471 } 6472 var childRows = $.map(row, function (field, j){ 6473 var fieldElem = renderField(field, renderCtx); 6474 if(!fieldElem){ 6475 return null; 6476 } 6477 var colObj = wrapColField(fieldElem); 6478 rowWidth += colObj.width; 6479 6480 if(field.VisibilityRule && field.Datatype != "hidden"){ 6481 renderCtx.fieldsToCheck.push(field); 6482 } 6483 6484 priv.fieldElemsByName[field.Name] = colObj.elem; 6485 return colObj.elem; 6486 }); 6487 if(childRows.length === 0){ 6488 return null; 6489 } 6490 6491 var rowElem = $b(".mktoFormRow", [ 6492 childRows, 6493 $b(".mktoClear") 6494 ]); 6495 if(rowWidth > priv.formWidth){ 6496 priv.formWidth = rowWidth; 6497 } 6498 return rowElem; 6499 }; 6500 6501 var makeHiddenField = function (value, key){ 6502 var e = $b("input.mktoField.mktoFieldDescriptor", {type:"hidden", name:key}); 6503 var fieldData = { 6504 name:key, 6505 val:$.proxy(e.val, e),
6506 onChange:function (fn){ 6507 e.on("change", fn); 6508 } 6509 }; 6510 if(priv.changeMap[key]){ 6511 fieldData.onChange(function (e){ 6512 updateDependentFields(field.Name); 6513 }) 6514 } 6515 e.data("mktoFieldDescriptor", fieldData); 6516 return e; 6517 } 6518 6519 var addHiddenFields = function (formElem, obj){ 6520 var hiddensToAdd = {}; 6521 var ifNotExistFn = function (name, value){ 6522 hiddensToAdd[name] = value; 6523 } 6524 pub.setValues(obj, ifNotExistFn); 6525 6526 var hiddens = $.map(hiddensToAdd, makeHiddenField); 6527 6528 formElem.append($b.docFrag(hiddens)); 6529 pub.setValues(obj); 6530 }; 6531 6532 var isSmallViewport = function (){ 6533 if(window.matchMedia && $("body.mktoMobileShow").length){ 6534 return window.matchMedia("only screen and (max-width:480px), only screen and (max-device-width:480px), only screen and (max-device-height:480px)").matches; 6535 } 6536 return $(window).width() <= 480 6537 } 6538 6539 var removeFixedWidthContents = function (elem){ 6540 var elems = elem.find(".mktoHasWidth").addBack(); 6541 elems.each(function (){ 6542 var e = $(this); 6543 e.data("mktoFixedWidth", e.css("width")); 6544 e.css("width", ""); 6545 }); 6546 }; 6547 6548 var onResize = function (){ 6549 if(!priv.formElem){ 6550 return; 6551 } 6552 var winW = $(window).width(); 6553 if(!priv.hasRemovedWidths){ 6554 if(isSmallViewport()){ 6555 removeFixedWidthContents(priv.formElem); 6556 priv.hasRemovedWidths = true; 6557 } 6558 }else{ 6559 if(!isSmallViewport()){ 6560 priv.formElem.find(".mktoHasWidth").addBack().each(function (){ 6561 var e = $(this); 6562 e.css("width", e.data("mktoFixedWidth")); 6563 }) 6564 priv.hasRemovedWidths = false; 6565 } 6566 } 6567 }; 6568 6569 var buildButtonElem = function (formElem){ 6570 var buttonStyle = formData.ButtonStyle || {className:""} 6571 var buttonText = formData.ButtonText || formData.SubmitLabel || "Submit"; 6572 var buttonLocation = formData.ButtonLocation || ""; 6573 var blInt = parseInt(buttonLocation, 10) || 0; 6574 var btn = $b("span.mktoButtonWrap", [ 6575 $b("button.mktoButton", {type:"submit"}, [ 6576 buttonText 6577 ]) 6578 ]).addClass(buttonStyle.className).css({"margin-left":blInt+"px"}); 6579 return btn; 6580 }; 6581 6582 var renderSocialSignOn = function(){ 6583 var po = formData.ProcessOptions; 6584 if(!po || !po.socialSignOn || !po.socialSignOn.isEnabled || !po.socialSignOn.enabledNetworks.length){ 6585 return ""; 6586 } 6587 var id = po.socialSignOn.cfId +"_SocialSignOn"; 6588 var elem = $b(".cf_widgetLoader.cf_w_"+ id); 6589 if(window.cf_scripts && window.CF){ 6590 setTimeout(function (){ 6591 CF.widget.restart(id); 6592 }, 10); 6593 return elem; 6594 } 6595 var scriptFormData = $b("script", {src:formData.loaderJsUrl, type:"text/javascript"}); 6596 if (nonceValue !== null) { 6597 scriptFormData.attr("nonce", nonceValue); 6598 } 6599 6600 return $b.docFrag([ 6601 scriptFormData, 6602 elem 6603 ]); 6604 }; 6605 6606 var addFormClasses = function (formElem){ 6607 formElem.addClass("mktoForm mktoHasWidth mktoLayout"+ cap(formData.Layout || "left") + (modernizr.csschecked ? "" : " mktoNoCheckedSupport")); 6608 if(oldIe){ 6609 formElem.addClass(oldIe); 6610 } 6611 } 6612 6613 var onSuccess = function (values, followup){ 6614 var ok = true; 6615 $.each(priv.onSuccess, function (i, successFn){ 6616 if(successFn(values, followup) === false){ 6617 ok = false; 6618 } 6619 }); 6620 return ok; 6621 }; 6622 6623 6624 var getSyndId = function (cook){ 6625 var cd = cook.__cdrop; 6626 var parts; 6627 if(cd){ 6628 parts = cd.split("."); 6629 if(parts.length == 3){ 6630 return parts[2]; 6631 } 6632 } 6633 return null; 6634 }; 6635 6636 //The form submission code expects array objects to have "[]" in their parameter name. 6637 //So with the object {foo:["bar", "baz"]} instead of the natural form encoding 6638 //foo=bar&foo=baz 6639 //it expects 6640 //foo[]=bar&foo[]=baz 6641 var funkifyArrayParams = function (obj){ 6642 var newObj = {}; 6643 $.each(obj, function (k, v){ 6644 if($.isArray(v) && v.length > 1){ 6645 newObj[k+"[]"] = v; 6646 }else{ 6647 newObj[k] = v; 6648 } 6649 }); 6650 return newObj; 6651 } 6652 6653 var isFBTab = function (){ 6654 var l = location; 6655 return l.hostname.indexOf(opts.fbTabDomain) != -1 && l.search.indexOf("fbTab=1") != -1 6656 } 6657 6658 6659 var findCorrectFollowUpUrl = function (data){ 6660 var fbTab = isFBTab(); 6661 6662 var u = ""; 6663 if(data){ 6664 // Newer forms have the ID for the followup page defined as a hidden field, ignore the followup URL in the formData 6665 // Otherwise, "followupLpId" value can be undefined/null, or -1 in case external URL (formData.FomrFOllowup) is used. 6666 var isNewStyleFollowup = (pub.getValues().followupLpId > 0); 6667 if(!isNewStyleFollowup && typeof formData.FormFollowup == "string"){ 6668 u = formData.FormFollowup; 6669 if(fbTab && u.indexOf("https://") !== 0){ 6670 //If you're on a FB tab and you've specified a landing page defined url and you didn't use https, 6671 //then we're assuming that you're using a landing page follow up page url. 6672 u = urlHelper.remapLandingPageUrl(u, location.href); 6673 u = urlHelper.addQueryParams(u, {fbTab:"1"}); 6674 } 6675 }else{ 6676 if(data.followUpUrl && typeof data.followUpUrl == "string"){ 6677 u = data.followUpUrl; 6678 }else if(data.followUpUrl && data.followUpUrl.url){ 6679 if(fbTab && data.followUpUrl.isLandingPage){ 6680 u = urlHelper.remapLandingPageUrl(data.followUpUrl.url, location.href); 6681 u = urlHelper.addQueryParams(u, {fbTab:"1"}); 6682 }else{ 6683 u = data.followUpUrl.url; 6684 } 6685 } 6686 } 6687 } 6688 6689 u = u || location.href; 6690 if (data.aliId){ 6691 u = urlHelper.addQueryParams(u, {aliId:data.aliId}); 6692 } 6693 return u; 6694 } 6695
6696 var doAjaxSubmit = function (){ 6697 var values = pub.getValues(); 6698 if(window.Munchkin){ 6699 try{ 6700 window.Munchkin.createTrackingCookie(true); 6701 }catch(e){ 6702 //For IE 7 6703 } 6704 } 6705 var currPageQS = url.parse(originalLocationHref, true).query; 6706 6707 var cook = cookie.parse(document.cookie); 6708 var hostname = url.parse(formData.action).hostname; 6709 var submitUrl = (hostname ? "//" + hostname : '') + opts.formSubmitPath; 6710 var l = window.location; 6711 if(isFBTab()){ 6712 //FB tabs use local urls to submit. 6713 submitUrl = opts.formSubmitPath; 6714 hostname = location.hostname; 6715 } 6716 var dataType = "json"; 6717 var type = "POST"; 6718 if(values._mkt_trk === undefined){ 6719 values._mkt_trk = cook._mkto_trk; 6720 } 6721 values.formVid = formData.Vid; 6722 if(currPageQS.mkt_tok && values.mkt_tok === undefined){ 6723 values.mkt_tok= currPageQS.mkt_tok; 6724 } 6725 var syndId = getSyndId(cook); 6726 if(syndId){ 6727 values.MarketoSocialSyndicationId = syndId; 6728 } 6729 values._mktoReferrer = originalLocationHref; 6730 6731 var checksum = [], fields = []; 6732 var createChecksumField = function(formData) { 6733 var fieldCounter = 0; 6734 $.each(formData, function(i, field){ 6735 if(fieldCounter >= 20) { 6736 return; 6737 } 6738 checksum.push(field); 6739 fields.push(i); 6740 fieldCounter++; 6741 }); 6742 }; 6743 createChecksumField(values); 6744 values.checksumFields = fields.join(','); 6745 values.checksum = shajs('sha256').update(checksum.join("|")).digest('hex'); 6746 if (priv.captchaToken) { 6747 values.captchaToken = priv.captchaToken; 6748 } 6749 var valueString = querystring.stringify(funkifyArrayParams(values)); 6750 6751 var formFollowupRedirection = function (data){ 6752 var u = findCorrectFollowUpUrl(data); 6753 if (false === onSuccess(values, u)) { 6754 return; 6755 } 6756 cookieHelper.removeCookieAllDomains("_mkto_purl"); 6757 location.href = u; 6758 } 6759 6760 var success = function (data){ 6761 if(data.error){ 6762 onError(data); 6763 }else if(data.formId){ 6764 if (data.followupStreamValue && window.AdobeDX && window.AdobeDX.conversationalForms) { 6765 var formSubmittedData = pub.getValues(); 6766 var conversationalAdobeDxObject = { 6767 id: data.followupStreamValue, 6768 type: data.deliveryType || 'popup', 6769 content: { form: {} } 6770 }; 6771 if (formSubmittedData && formSubmittedData.Email) { 6772 conversationalAdobeDxObject.content.form.emailAddress = formSubmittedData.Email; 6773 } 6774 if (data && data.conversationalFieldAttributes) { 6775 $.each(data.conversationalFieldAttributes, function (formKey, formValue){ 6776 conversationalAdobeDxObject.content.form[formKey] = formValue; 6777 }); 6778 } 6779 var adobeDX = window.AdobeDX.conversationalForms(conversationalAdobeDxObject); 6780 if ( 6781 adobeDX.registerCallback && 6782 adobeDX.Enum && 6783 adobeDX.Enum.Events && 6784 adobeDX.Enum.Events.CONVERSATION_CLOSED && 6785 adobeDX.Enum.CallbackType && 6786 adobeDX.Enum.CallbackType.EVENT_LISTENER 6787 ) { 6788 var addListener = window.AdobeDX.addListener; 6789 if (addListener) { 6790 addListener( 6791 adobeDX.Enum.Events.CONVERSATION_CLOSED, 6792 function(event) { 6793 formFollowupRedirection(data); 6794 } 6795 ); 6796 } 6797 } 6798 } else { 6799 formFollowupRedirection(data); 6800 } 6801 } 6802 } 6803 function decode_utf8(s) { 6804 return decodeURIComponent(escape(s)); 6805 } 6806 var encodeHtmlEntity = function(str) { 6807 var val = []; 6808 for (var i=str.length-1;i>=0;i--) { 6809 val.unshift(['&#', str[i].charCodeAt(), ';'].join('')); 6810 } 6811 return val.join(''); 6812 }; 6813 var onError = function (err){ 6814 var invalidMsg = formData.formSubmitFailedMsg || 'Submission failed, please try again later.'; 6815 if (err.errorType === 'invalid') { 6816 if (err.invalidInputMsg) { 6817 err.invalidInputMsg = decode_utf8(err.invalidInputMsg); 6818 } 6819 invalidMsg = err.invalidInputMsg || formData.invalidInputMsg || 'Invalid input'; 6820 } 6821 var showedFieldError = false;
6822 if (err && err.errorFields && err.errorFields.length) { 6823 var fieldName = err.errorFields[0]; 6824 if (fieldName) { 6825 var fieldElem = priv.fieldElemsByName[fieldName]; 6826 if (fieldElem) { 6827 var fieldData = fieldElem.data("mktoFieldDescriptor"); 6828 if(fieldData && fieldData.validatorElem){ 6829 priv.validation.showError(fieldData.validatorElem, encodeHtmlEntity(invalidMsg)); 6830 showedFieldError = true; 6831 } 6832 } 6833 } 6834 } 6835 6836 if(priv.submitButton){ 6837 var btn = priv.submitButton.find("button"); 6838 btn.removeAttr('disabled'); 6839 btn.html(formData.ButtonText || formData.SubmitLabel || "Submit"); 6840 if (!showedFieldError) { 6841 priv.validation.showError(btn, invalidMsg); 6842 } 6843 } 6844 } 6845 6846 var ajaxParams = { 6847 type:type, data:valueString, dataType:dataType, 6848 url:submitUrl, success:success, error:onError 6849 }; 6850 6851 function errorWrap(resp, code, msg) { 6852 var err; 6853 if (resp && resp.responseJSON) { 6854 err = resp.responseJSON; 6855 } else if (resp && resp.responseText) { 6856 try { 6857 err = JSON.parse(resp.responseText); 6858 } catch (e) { 6859 err = msg; 6860 } 6861 } else { 6862 err = msg; 6863 } 6864 onError(err); 6865 } 6866 6867 if(hostname && hostname != location.hostname){ 6868 if(!modernizr.postmessage || !modernizr.json){ 6869 ajaxParams.dataType = "jsonp"; 6870 ajaxParams.submitUrl+="?callback=?"; 6871 ajaxParams.type = "GET"; 6872 ajaxParams.error = errorWrap; 6873 $.ajax(ajaxParams); 6874 } 6875 else{ 6876 iframeProxy.send(ajaxParams); 6877 } 6878 }else{ 6879 ajaxParams.error = errorWrap; 6880 $.ajax(ajaxParams); 6881 } 6882 }; 6883 6884 var disableSubmitButton = function(disable) { 6885 if (priv.submitButton) { 6886 var btn = priv.submitButton.find("button"); 6887 if(btn) { 6888 if (!disable) { 6889 btn.removeAttr('disabled'); 6890 } else { 6891 btn.attr('disabled', 'disabled'); 6892 if (formData.ButtonSubmissionText) { 6893 btn.html(formData.ButtonSubmissionText); 6894 } 6895 } 6896 } 6897 } 6898 }; 6899 6900 var onSubmit = function (e){ 6901 var submitFn = function(valid) { 6902 //disable submit button elem. 6903 disableSubmitButton(true); 6904 doAjaxSubmit(); 6905 return false; 6906 }; 6907 6908 var valid = pub.validate(); 6909 if (priv.canSubmit && valid && priv.onSubmit){ 6910 $.each(priv.onSubmit, function (i, fn){ 6911 fn(pub); 6912 }); 6913 } 6914 e.preventDefault(); 6915 if (!priv.canSubmit || !valid){ 6916 e.stopPropagation(); 6917 return false; 6918 } 6919 else if (formData.EnableCaptcha && formData.Captcha && 6920 formData.Captcha.provider !== "disabled" && 6921 (!priv.captchaToken || priv.captchaToken === "")) { 6922 if (formData.Captcha.provider == 'reCaptcha') { 6923 disableSubmitButton(true); 6924 try { 6925 grecaptcha.ready(function () { 6926 try { 6927 e.stopPropagation(); 6928 grecaptcha.execute(formData.Captcha.siteKey, {action: 'submit'}).then(function (token) { 6929 return submitFn(true); 6930 }); 6931 } 6932 catch (error) { 6933 console.error(error); 6934 disableSubmitButton(false); 6935 } 6936 }); 6937 } 6938 catch (error) { 6939 console.error(error); 6940 disableSubmitButton(false); 6941 } 6942 } 6943 // This will uncommented when hCaptcha is available to configure 6944 // else if(formData.Captcha.provider == 'hCaptcha') { 6945 // if(formData.Captcha.invisible) { 6946 // hcaptcha.execute(); 6947 // valid = true; 6948 // validateAndSubmit(); 6949 // } 6950 // else { 6951 // pub.showErrorMessage("Please complete the hCaptcha prior to submitting this form", priv.submitButton.find("button")); 6952 // } 6953 // } 6954 //} 6955 e.stopPropagation(); 6956 } 6957 else { 6958 return submitFn(true); 6959 } 6960 return false; 6961 }; 6962 6963 var renderTemplateButton = function (attrs){ 6964 var buttonStyle = formData.ButtonStyle || {className:""}; 6965 var btn = $b("span.mktoButtonWrap", [ 6966 $b("button.mktoButton", {type:"submit"}, [ 6967 attrs["default"] || "" 6968 ]) 6969 ]).addClass(buttonStyle.className) 6970 btn.click(function (e){ 6971 onSubmit(e); 6972 e.preventDefault(); 6973 }); 6974 return btn; 6975 }; 6976 6977 var renderNotYouButton = function (attrs){ 6978 return $b("a.mktoNotYou", [attrs["default"] || "Not You?"]).click( 6979 function (){ 6980 //unset _mkto_trk cookie, remove mkt_tok and aliId params, reload page. 6981 cookieHelper.removeCookieAllDomains("_mkto_trk"); 6982 location.href = urlHelper.removeQueryParams(location.href, ["mkt_tok", "aliId"]); 6983 }); 6984 }; 6985 6986 var renderTokenizedTemplate = function (){ 6987 var templ = formData.ProcessOptions.knownLead.template; 6988 //The token parsing code in MLM eats its own tokens. To get around this, we alter the token format 6989 //The real format is {{tag}}, but we change it to {[(tag)]} 6990 templ = templ.replace(/\{\[\((.*?)\)\]\}/g, "{{$1}}"); 6991 var swaps = {}; 6992 var count = 0; 6993 var swapForHtmlPlaceholder = function (fn){ 6994 return function (){ 6995 var result = fn.apply(null, arguments); 6996 if(result.jquery || result.nodeType){ 6997 var id = "__tempSwap"+count; 6998 count++; 6999 swaps[id] = result; 7000 return "<span id='"+id+"'></span>"; 7001 } 7002 return result; 7003 } 7004 } 7005 7006 var htmlSafe = function(leadData){ 7007 $.each(leadData, function (k, v){ 7008 leadData[k] = $('<div />').text(leadData[k]).html(); 7009 }); 7010 return leadData; 7011 } 7012 7013 var model = { 7014 lead:htmlSafe(formData.knownLead), 7015 form:{ 7016 Button:swapForHtmlPlaceholder(renderTemplateButton), 7017 NotYou:swapForHtmlPlaceholder(renderNotYouButton) 7018 } 7019 }; 7020 var template = $b("div.mktoTemplateBox", $b.html(tokenTemplate(templ, model))); 7021 $.each(swaps, function (k, v){ 7022 template.find("#"+k).replaceWith(v); 7023 }); 7024 return template; 7025 } 7026 7027 var rerender = function(){ 7028 if(priv.formElem){ 7029 priv.formElem.empty(); 7030 } 7031 pub.render(priv.formElem); 7032 } 7033 7034 pub.render = function (formElem){ 7035 priv.id = formData.Vid || formData.Id || 1; 7036 if(!formElem){ 7037 formElem = $("form#mktoForm_"+ (formData.Vid || formData.Id)); 7038 } 7039 if(!formElem.length){ 7040 formElem = $b("form#mktoForm_"+(formData.Vid || formData.Id)); 7041 } 7042 priv.formElem = formElem; 7043 7044 //Firefox and Webkit don't agree on how to style form validation messages 7045 //And IE < 9 don't support them at all. Sadly, it's easier to just turn 7046 //off HTML5 form validation and do it all manually with JS. Maybe in another 7047 //year, that won't be the case any more. 7048 formElem.attr({ 7049 "novalidate":"novalidate" 7050 }); 7051 formElem.css({ 7052 "font-family":formData.FontFamily || "", 7053 "font-size":formData.FontSize || "", 7054 "color":formData.FontColor || "" 7055 }); 7056 //Set up all the styles before initing the measuring element that we'll use to capture column widths. 7057 addFormClasses(formElem); 7058 measure.init(priv.formElem); 7059 7060 priv.formWidth = 0; 7061 var renderCtx = { 7062 defaultValuesToSet: {}, 7063 fieldsToCheck: [] 7064 } 7065 var rowElems = $.map(formData.rows, function (row, i){ 7066 return renderRow(row, i, renderCtx); 7067 }); 7068 7069 // Social sign-on disabled - return empty string instead of rendering 7070 var socialSignOn = ""; 7071 7072 $.each(renderCtx.fieldsToCheck, function (i, field){ 7073 if(!changeManager.fieldChangeChecker(field.VisibilityRule, renderCtx.defaultValuesToSet).show){ 7074 var plh = $b(".mktoPlaceholder.mktoPlaceholder"+field.Name); 7075 var elem = priv.fieldElemsByName[field.Name]; 7076 if(elem){ 7077 elem.replaceWith(plh); 7078 priv.fieldElemsByName[field.Name] = plh; 7079 } 7080 } 7081 }); 7082 7083 7084 var buttonCss = ""; 7085 var bs = formData.ButtonStyle; 7086 if(bs){ 7087 if(bs.css){ 7088 buttonCss += bs.css 7089 } 7090 if(bs.buttonColor){ 7091 //This background color support is lame. It should really come prebaked in the ButtonStyle.css 7092 buttonCss += "\n.mktoForm .mktoButtonWrap."+bs.className+" button.mktoButton {background:"+bs.buttonColor + ";}\n"; 7093 } 7094 } 7095 var styleButtonCss = $b("style", {type:"text/css"}, buttonCss); 7096 if (nonceValue !== null) { 7097 styleButtonCss.attr("nonce", nonceValue); 7098 } 7099 formElem.append(styleButtonCss); 7100 if (formData.knownLead && formData.ProcessOptions && formData.ProcessOptions.knownLead && formData.ProcessOptions.knownLead.type == "custom"){ 7101 formElem.append(renderTokenizedTemplate()); 7102 var elmsKnown = []; 7103 if (formData.EnableCaptcha && formData.Captcha && formData.Captcha.provider !== "disabled") { 7104 var captchaHTML1 = addCaptchaScript(formElem, formData); 7105 if(captchaHTML1) { 7106 captchaHTML1.forEach(function(item) { 7107 elmsKnown.push(item); 7108 }); 7109 } 7110 } 7111 formElem.append($b.docFrag(elmsKnown)); 7112 } else { 7113 var elms = [ 7114 socialSignOn, 7115 rowElems 7116 ]; 7117 var submitBtn = $b(".mktoButtonRow", [ 7118 priv.submitButton = buildButtonElem(formElem) 7119 ]); 7120 if (formData.EnableCaptcha && formData.Captcha && formData.Captcha.provider !== "disabled") { 7121 var captchaHTML = addCaptchaScript(formElem, formData, submitBtn); 7122 if(captchaHTML) { 7123 captchaHTML.forEach(function(item) { 7124 elms.push(item); 7125 }); 7126 } 7127 } 7128 elms.push(submitBtn); 7129 7130 //Add Dynamic Chat js in case of embbeded form 7131 if (formData.dcJsUrl) { 7132 var elem2 = $b("div"); 7133 var scriptTagDCJS = null; 7134 if (nonceValue !== null) { 7135 scriptTagDCJS = '<script nonce="'+nonceValue+ '" type="text/javascript" src="' + formData.dcJsUrl + '"></script>'; 7136 } else { 7137 scriptTagDCJS = '<script type="text/javascript" src="' + formData.dcJsUrl + '"></script>'; 7138 }
7139 elem2.append(scriptTagDCJS); 7140 elms.push(elem2); 7141 } 7142 formElem.append($b.docFrag(elms)); 7143 if (formData.removeDuplicateLabelId) { 7144 var Checkboxlabel = formElem.find('input[type="checkbox"]').next('label'); 7145 for (i = 0; i < Checkboxlabel.length; i++) { 7146 if (Checkboxlabel[i].innerText ==="") { 7147 Checkboxlabel[i].removeAttribute("id"); 7148 } 7149 } 7150 var Radiolabel = formElem.find('input[type="radio"]').next('label'); 7151 for (i = 0; i < Radiolabel.length; i++) { 7152 if (Radiolabel[i].innerText ==="") { 7153 Radiolabel[i].removeAttribute("id"); 7154 } 7155 } 7156 } 7157 } 7158 7159 addHiddenFields(formElem, priv.hiddenFields); 7160 7161 pub.setValues(renderCtx.defaultValuesToSet); 7162 7163 formElem.css({ 7164 "width": Math.max(priv.submitButton ? priv.submitButton.outerWidth(): 0, priv.formWidth + 1) //TODO: Figure out why things wrap wrong without adding 1 extra px. 7165 }); 7166 7167 formElem.on("submit", onSubmit); 7168 7169 priv.validation = Validation(formElem, formData); 7170 priv.validation.init(); 7171 setTimeout(function (){ 7172 $("body").trigger("mktoRender", pub).data("mktoRendered", true); 7173 },0); 7174 7175 $(window).on("resize", onResize); 7176 onResize(); 7177 7178 if(oldIe == "ie7"){ 7179 fixIEZIndex(formElem); 7180 } 7181 7182 return formElem; 7183 }; 7184 7185 addCaptchaScript = function(formElem, formData) { 7186 var cSettings = { 7187 'id': 'captcha', 7188 'class': '', 7189 'data-callback': 'captchaCallback', 7190 'data-expired-callback': 'captchaExpired', 7191 'data-sitekey': '' 7192 }; 7193 var providers = { 7194 'hCaptcha' : { 7195 cls: 'h-captcha', 7196 scriptSrc: "https://js.hcaptcha.com/1/api.js?onload=captchaCallback" 7197 }, 7198 'reCaptcha' :{ 7199 cls: 'g-recaptcha', 7200 scriptSrc: "https://www.google.com/recaptcha/api.js?onload=captchaCallback" 7201 } 7202 } 7203 var ec = formData.EnableCaptcha && formData.Captcha && formData.Captcha.provider !== "disabled"; 7204 if (!ec){ 7205 return ""; 7206 } 7207 var onCaptchaSuccess = function(response) { 7208 var items = document.getElementsByClassName("grecaptcha-badge"); 7209 if (items.length > 0) { 7210 for (var i = 0; i < items.length; i++) { 7211 items[i].style.visibility = 'hidden'; 7212 } 7213 } 7214 if (response) { 7215 var form = this.MktoForms2.getForm(formId); 7216 if (form) { 7217 form.setCaptchaValue(response); 7218 } 7219 } 7220 } 7221 7222 cSettings['data-sitekey'] = formData.Captcha.sitekey; 7223 cSettings['class'] = providers[formData.Captcha.provider].cls; 7224 var captchaScript = $b("script", { 7225 src: providers[formData.Captcha.provider].scriptSrc, 7226 type: "text/javascript", 7227 async: true, 7228 defer: true 7229 }); 7230 if (nonceValue !== null) { 7231 captchaScript.attr('nonce', nonceValue); 7232 } 7233 var elem2 = $b("div"); 7234 var callBackScript = null 7235 if (nonceValue !== null) { 7236 callBackScript = '<script nonce="'+nonceValue+ '" type="text/javascript">'; 7237 } else { 7238 callBackScript = '<script type="text/javascript">'; 7239 } 7240 callBackScript += 'var formId = ' + formData.Vid + ';'; 7241 callBackScript += 'var captchaCallback = ' + onCaptchaSuccess + ';'; 7242 callBackScript += '</script>'; 7243 elem2.append(callBackScript); 7244 7245 if (formData.Captcha.provider == 'reCaptcha') { 7246 cSettings['data-size'] = 'invisible'; 7247 } 7248 7249 var disclaimer = ''; 7250 if (formData.Captcha.provider == 'reCaptcha') { 7251 disclaimer = $b("div.mktoCaptchaDisclaimer"); 7252 if (formData.hideRecaptchaDisclaimer) { 7253 disclaimer.append("This site is protected by reCAPTCHA."); 7254 } else { 7255 disclaimer.append("This site is protected by reCAPTCHA and the Google\n" + 7256 " <a href=\"https://policies.google.com/privacy\" target=\"_blank\">Privacy Policy</a> and" + 7257 " <a href=\"https://policies.google.com/terms\" target=\"_blank\">Terms of Service</a> apply."); 7258 } 7259 } 7260 7261 var captchaDiv = $b("<div>", cSettings); 7262 return [ 7263 captchaScript, elem2, captchaDiv, disclaimer 7264 ]; 7265 } 7266 //Todo: move this to a polyfill that is dynamically loaded for only the chumps who use IE7 7267 //or IE in "compatibility mode". 7268 var fixIEZIndex = function(formElem){ 7269 var fields = formElem.find(".mktoFormRow, .mktoFormCol"); 7270 var count = fields.length; 7271 fields.each(function (){ 7272 $(this).css("z-index", count--); 7273 }); 7274 formElem.css("z-index", fields.length + 1); 7275 }; 7276 7277 pub.getId = function (){ 7278 return priv.id; 7279 }; 7280 7281 pub.getFormElem = function (){ 7282 return priv.formElem; 7283 }; 7284 //less verbose; 7285 pub.getElem = pub.getFormElem(); 7286 7287 pub.validate = function (){ 7288 var ok = priv.validation.check(); 7289 $.each(priv.onValidate, function (i, fn){ 7290 fn(ok); 7291 }); 7292 return ok; 7293 }; 7294 7295 pub.onValidate = function (callback){ 7296 if(!callback){ 7297 priv.onValidate = []; 7298 }else{ 7299 priv.onValidate.push(callback); 7300 } 7301 return pub; 7302 }; 7303 7304 pub.offValidate = function (callback){ 7305 priv.onValidate = priv.onValidate.filter(function (v){ 7306 return v !== callback; 7307 }); 7308 return pub; 7309 } 7310 7311 pub.submit = function (oneTimeSuccessCallback){ 7312 if(oneTimeSuccessCallback && typeof oneTimeSuccessCallback === 'function'){ 7313 var cb = function (){ 7314 pub.offSuccess(cb); 7315 oneTimeSuccessCallback.apply(null, arguments); 7316 } 7317 priv.onSuccess.push(cb); 7318 } 7319 priv.formElem.trigger("submit"); 7320 return pub; 7321 }; 7322 7323 pub.onSubmit = function (callback){ 7324 if(!callback){ 7325 priv.onSubmit = []; 7326 }else{ 7327 priv.onSubmit.push(callback); 7328 } 7329 return pub; 7330 }; 7331 7332 pub.offSubmit = function (callback){ 7333 priv.onSubmit = priv.onSubmit.filter(function (v){ 7334 return v !== callback; 7335 }); 7336 return pub; 7337 }; 7338 7339 pub.onSuccess = function (callback){ 7340 if(!callback){ 7341 priv.onSuccess = []; 7342 }else{ 7343 priv.onSuccess.push(callback); 7344 } 7345 return pub; 7346 }; 7347 7348 pub.offSuccess = function (callback){ 7349 priv.onSuccess = priv.onSuccess.filter(function (v){ 7350 return v !== callback; 7351 }); 7352 return pub; 7353 }; 7354 7355 pub.submitable = function (canSubmit){ 7356 if(!arguments.length){ 7357 return priv.canSubmit; 7358 } 7359 else{ 7360 priv.canSubmit = canSubmit; 7361 return pub; 7362 } 7363 }; 7364 //Fix spelling 7365 pub.submittable = pub.submitable; 7366 7367 pub.allFieldsFilled = function (){ 7368 var vals = pub.getValues(); 7369 var ok = true; 7370 $.each(vals, function (i, val){ 7371 if($.isArray(val) && val.length === 0){ 7372 ok = false;
7373 }else if(val === undefined || val === null || val === ""){ 7374 ok = false; 7375 } 7376 }); 7377 return ok; 7378 }; 7379 7380 var getFieldNameValFnMap = function (){ 7381 var nameMap = {}; 7382 priv.formElem.find(".mktoFieldDescriptor").each(function (i, elem){ 7383 var e = $(elem); 7384 var f = e.data("mktoFieldDescriptor"); 7385 nameMap[f.name] = f.val; 7386 }) 7387 return nameMap; 7388 }; 7389 7390 pub.setValuesCoerced = function (prefillObj){ 7391 var coerced = prefillCoercer.coerceTypes(prefillObj, formData); 7392 pub.setValues(coerced); 7393 } 7394 7395 pub.setValues = function (obj, ifNotExistFn){ 7396 if(!priv.formElem){ 7397 priv.values = obj; 7398 }else{ 7399 var dependencies = []; 7400 var nameMap = getFieldNameValFnMap(); 7401 $.each(obj, function (name, value){ 7402 if(nameMap[name]){ 7403 nameMap[name](value); 7404 }else if(ifNotExistFn){ 7405 ifNotExistFn(name, value); 7406 } 7407 if(priv.changeMap[name]){ 7408 dependencies.push(name); 7409 } 7410 }); 7411 $.each(dependencies, function (i, fieldName){ 7412 updateDependentFields(fieldName); 7413 var nameMap = getFieldNameValFnMap(); 7414 $.each(priv.changeMap[fieldName], function(i, child){ 7415 if(nameMap[child] && obj[child] !== undefined){ 7416 nameMap[child](obj[child]); 7417 } 7418 }) 7419 }) 7420 } 7421 return pub; 7422 }; 7423 7424 pub.setCaptchaValue = function(resp) { 7425 if (priv) { 7426 priv.captchaToken = resp; 7427 //enable submit button 7428 if (priv.submitButton) { 7429 var btn = priv.submitButton.find("button"); 7430 btn.removeAttr('disabled'); 7431 } 7432 } 7433 }; 7434 7435 pub.setCaptchaExpired = function() { 7436 if (priv) { 7437 priv.captchaToken = ''; 7438 // re-disable button 7439 if (priv.submitButton) { 7440 var btn = priv.submitButton.find("button"); 7441 btn.attr('disabled', 'disabled'); 7442 } 7443 } 7444 }; 7445 7446 pub.addHiddenFields = function (obj){ 7447 if(!priv.formElem){ 7448 $.extend(priv.hiddenFields, obj); 7449 }else{ 7450 addHiddenFields(priv.formElem, obj); 7451 } 7452 }; 7453 7454 pub.getValues = function (){ 7455 if(!priv.formElem){ 7456 return priv.values; 7457 }else{ 7458 var vals = {}; 7459 var nameMap = getFieldNameValFnMap(); 7460 $.each(nameMap, function (name, val){ 7461 var value = val(); 7462 vals[name] = value; 7463 }); 7464 return vals; 7465 } 7466 }; 7467 7468 pub.vals = function (){ 7469 if(arguments.length === 0){ 7470 return pub.getValues(); 7471 } 7472 return pub.setValues.apply(null, arguments); 7473 }; 7474 7475 pub.showErrorMessage = function (msg, elem){ 7476 if(priv.validation){ 7477 if(!elem){ 7478 elem = priv.submitButton; 7479 } 7480 priv.validation.showError(elem, msg); 7481 } 7482 return pub; 7483 }; 7484 7485 pub.setErrorMessages = function (obj){ 7486 $.each(obj, function (fieldName, message){ 7487 priv.fieldsByName[fieldName].ValidationMessage = message; 7488 if(priv.formElem){ 7489 var elem = priv.fieldElemsByName[fieldName]; 7490 if(elem){ 7491 var data = elem.data("mktoFieldDescriptor"); 7492 if(data){ 7493 data.validationMessage = message; 7494 elem.data("mktoFieldDescriptor", data); 7495 } 7496 } 7497 } 7498 }); 7499 } 7500 7501 return pub; 7502} 7503 7504module.exports = Form; 7505 7506},{"./changeManager.js":24,"./comparators.js":26,"./cookiehelper.js":27,"./fields/currency.js":28,"./fields/fieldhelpers.js":30,"./fields/inputCheckbox.js":31,"./fields/inputDate.js":32,"./fields/inputEmail.js":33,"./fields/inputNumber.js":34,"./fields/inputRadio.js":35,"./fields/inputRange.js":36,"./fields/inputTel.js":37,"./fields/inputText.js":38,"./fields/inputUrl.js":39,"./fields/select.js":40,"./fields/textarea.js":41,"./iframeproxy.js":44,"./jquery.js":45,"./measure.js":46,"./prefillcoercer.js":49,"./safelog.js":50,"./tokenTemplate.js":52,"./urlhelper.js":53,"./validation.js":54,"cookie":5,"querystring":13,"sha.js":16,"url":23}],43:[function(require,module,exports){ 7507if(typeof window !== 'undefined' && window.MktoForms2){ 7508 //This prevents re-executing the script if the customer has inserted the script block twice; 7509 module.exports = window.MktoForms2; 7510 return; 7511} 7512var $ = require("./jquery.js"); 7513// LM-113876: avoid conflicting with global jquery 7514$.noConflict(); 7515var $b = require("jquery.build")($, document); 7516var Form = require("./form.js"); 7517require("./shimsham.js"); 7518var forms2 ={}; 7519forms2.$ = $; 7520forms2.$b = $b; 7521forms2.Modernizr = require("./modernizr.js"); 7522var modernizr = forms2.Modernizr; 7523var qs = require("querystring"); 7524var fh = require("./fields/fieldhelpers.js"); 7525var cookie = require("cookie"); 7526var events = require("events"); 7527var emitter = new events.EventEmitter(); 7528var urlApi = require("url"); 7529var iframeProxy = require("./iframeproxy.js"); 7530var color = require("./color.js"); 7531var log = require("./safelog.js"); 7532var getLatestForm = true; 7533 7534var opts = { 7535 rootUrl:"", 7536 baseUrl:"/js/forms2/", 7537 skipPolyfills:false, 7538 formSubmitPath:"/index.php/leadCapture/save2", 7539 formXDPath:"/index.php/form/XDFrame", 7540 fbTabDomain:"marketo.com" 7541} 7542var forms = []; 7543function getNonce() { 7544 return document && document.currentScript && document.currentScript.nonce; 7545} 7546var nonceValue = getNonce(); 7547forms2.setOptions = function (_opts){ 7548 $.extend(opts, _opts); 7549}; 7550 7551/* 7552 * We test to see if both the theme style and base style have been loaded 7553 * We do this by checking to see if the border color and color on an 7554 * element with id=mktoStyleLoaded are equal to #123456. 7555 */ 7556 7557var waitForCssLoad = function (callback){ 7558 var tester = $b("#mktoStyleLoaded").css({ 7559 "display":"none", 7560 "border-top-color":"#123456" 7561 }).appendTo($("body")); 7562 var loadCount = 0; 7563 var timeout = 1500; 7564 var interval = 25; 7565 7566 var checkLoad = function (){ 7567 var fgColor = tester.css("color"); 7568 var bgColor = tester.css("background-color"); 7569 var borderColor = tester.css("border-top-color"); 7570 if(loadCount > timeout /interval){ 7571 log('Timeout loading CSS. #mktoStyleLoaded missing color #123456 for one of color, background-color, or border-top-color.', fgColor, bgColor, borderColor); 7572 callback(); 7573 }else if (color.compareColor(borderColor, bgColor) && color.compareColor(borderColor, fgColor)){ 7574 defer(callback); 7575 }else{ 7576 loadCount++; 7577 setTimeout(checkLoad, interval); 7578 } 7579 } 7580 checkLoad(); 7581} 7582 7583var addStyle = function (id, url){ 7584 if(url.indexOf("//") === 0){ 7585 url = location.protocol + url; 7586 } 7587 var l = $b("link", {id:id, rel:"stylesheet", type:"text/css", href:url}); 7588 if (nonceValue !== null) { 7589 l.attr("nonce", nonceValue); 7590 } 7591 $("head").append(l); 7592 //Appending to the head doesn't work in good old IE.
7593 if(document.createStyleSheet){ 7594 document.createStyleSheet(url); 7595 } 7596} 7597 7598//Generic error handler... logs to console and calls an optional callback. 7599var handleError = function (msg, callback){ 7600 if(window.console){ 7601 console.log("Error loading form:", msg); 7602 } 7603 if(callback){ 7604 callback(null); 7605 } 7606}; 7607 7608//Tells you if an url is relative or not. 7609//so "/foo/bar/foo.bar" is relative 7610//but //host.name/foo.bar is not. 7611var isRelativeUrl = function (url){ 7612 return url.indexOf("/") === 0 && url.indexOf("//") !== 0; 7613} 7614 7615var ajaxRequest = function(url, success){ 7616 //We used to use CORS for cross domain requests 7617 //but ran into issues where dumb corporate firewalls 7618 //would strip the Access-control-allow-origin headers. 7619 //Now we just force JSONP when a request is cross domain. 7620 var dataType = "json" 7621 if(!isRelativeUrl(url)){ 7622 dataType = "jsonp"; 7623 url+="&callback=?"; 7624 } 7625 if (nonceValue !== null) { 7626 $.ajax({ 7627 dataType: dataType, 7628 url: url, 7629 success: success, 7630 scriptAttrs: { nonce: nonceValue}, 7631 error: function (a, b, c) { 7632 handleError(c, success); 7633 } 7634 }); 7635 } else { 7636 $.ajax({ 7637 dataType: dataType, 7638 url: url, 7639 success: success, 7640 error: function (a, b, c) { 7641 handleError(c, success); 7642 } 7643 }); 7644 } 7645} 7646 7647 7648forms2.loadForm = function (rootUrl,munchkinId,formId,callback){ 7649 forms2.setOptions({ 7650 rootUrl:rootUrl, 7651 baseUrl:rootUrl + "/js/forms2/" 7652 }); 7653 var success = function (data){ 7654 getLatestForm = false; 7655 data.action = (rootUrl.indexOf("http") === 0 ? rootUrl : location.protocol + rootUrl) + opts.formSubmitPath; 7656 forms2.newForm(data, function (form){ 7657 form.addHiddenFields({ 7658 "munchkinId":munchkinId 7659 }); 7660 form.render(); 7661 if(callback){ 7662 callback(form); 7663 } 7664 }); 7665 } 7666 var pageUrl = location.href.split("?")[0].split("#")[0]; 7667 if(pageUrl.length > 255){ 7668 pageUrl = pageUrl.substring(0, 255); 7669 } 7670 var url = rootUrl + "/index.php/form/getForm?munchkinId="+munchkinId+"&form="+formId+"&url="+encodeURIComponent(pageUrl); 7671 ajaxRequest(url, function (data){ 7672 if(data.error){ 7673 handleError(data, callback); 7674 }else{ 7675 success(data); 7676 } 7677 }); 7678 return forms2; 7679}; 7680 7681forms2.lightbox = function (form, opts){ 7682 var elem, modal; 7683 opts = opts || {}; 7684 if(form.getFormElem){ 7685 if(!form.getFormElem()){ 7686 form.render(); 7687 } 7688 elem =form.getFormElem(); 7689 form.onSuccess(opts.onSuccess || function (values, url){ 7690 modal.hide(); 7691 if(!url){ 7692 return false; 7693 } 7694 }); 7695 }else{ 7696 elem = form; 7697 } 7698 modal = require("./modal.js")(elem, opts); 7699 return modal; 7700}; 7701 7702var defer = function (fn){ 7703 setTimeout(fn, 0); 7704} 7705 7706/** 7707 * Checks to see if the lead is known. callback will be called either with lead info or null if unknown lead. 7708 */ 7709var getKnownLead = function (formId, munchkinId, filledFields, callback, lpId){ 7710 if(window.mktoPreFillFields && mktoPreFillFields.FirstName && mktoPreFillFields.LastName){ 7711 defer(function (){ 7712 callback(mktoPreFillFields); 7713 }); 7714 return; 7715 } 7716 var cooks = cookie.parse(document.cookie); 7717 var params = qs.parse(location.search.replace("?", "")); 7718 var url = opts.rootUrl + "/index.php/form/getKnownLead?"; 7719 if(cooks._mkto_trk || params.mkt_tok){ 7720 var knownLeadsQs = { 7721 form:formId, 7722 lpId:lpId, 7723 munchkinId:munchkinId, 7724 filledFields:filledFields 7725 }; 7726 if(cooks._mkto_trk){ 7727 knownLeadsQs._mkt_trk = cooks._mkto_trk; 7728 } 7729 if(params.mkt_tok){ 7730 knownLeadsQs.mkt_tok = params.mkt_tok; 7731 } 7732 url += qs.stringify(knownLeadsQs); 7733 7734 ajaxRequest(url, function (data){ 7735 if(data && data.error){ 7736 handleError(data, callback); 7737 }else{ 7738 if(window.mktoPreFillFields) { 7739 data = $.extend({}, window.mktoPrefillFields, data); 7740 } 7741 callback(data); 7742 } 7743 }); 7744 return; 7745 } 7746 defer(callback); 7747}; 7748 7749forms2.newForm = function (formData, callback){ 7750 //Load Form Data here 7751 if (getLatestForm && !formData.isPreview && !formData.isFormTheme) { 7752 forms2.getLatestFormDescriptor(formData, callback); 7753 } 7754 else {
7755 forms2.processForm(formData,callback); 7756 } 7757}; 7758 7759forms2.getLatestFormDescriptor = function(formData,callback) { 7760 var handleError = function(error) { 7761 console.log("Error loading form : ", error); 7762 } 7763 var success = function (response) { 7764 if(response.Captcha) { 7765 formData.Captcha = response.Captcha; 7766 } 7767 else { 7768 delete formData.Captcha; 7769 } 7770 if(response.hideRecaptchaDisclaimer !== undefined) { 7771 formData.hideRecaptchaDisclaimer = response.hideRecaptchaDisclaimer; 7772 } 7773 return forms2.processForm(formData,callback); 7774 } 7775 7776 var ajaxRequest = function(url,success) { 7777 $.ajax({ 7778 dataType: "json", 7779 url: url, 7780 success: success, 7781 error: function (a, b, c) { 7782 handleError(c, success); 7783 } 7784 }); 7785 } 7786 7787 var hostname = location.hostname; 7788 var munchkinId = formData.munchkinId; 7789 var formId = formData.Id; 7790 if (munchkinId && formId) { 7791 var url = hostname + "/index.php/form/getForm?munchkinId=" + munchkinId + "&form=" + formId; 7792 url = (url.indexOf("http") === 0 ? url : location.protocol + "//" + url); 7793 ajaxRequest(url, function (data) { 7794 if (data.error) { 7795 handleError(data, callback); 7796 } else { 7797 success(data); 7798 } 7799 }); 7800 } 7801} 7802 7803forms2.processForm = function(formData, callback) { 7804 if($("#mktoForms2BaseStyle").length === 0){ 7805 var href = opts.baseUrl + "css/forms2.css"; 7806 addStyle("mktoForms2BaseStyle", href); 7807 } 7808 if($("#mktoForms2ThemeStyle").length === 0 && formData.ThemeStyle && formData.ThemeStyle.href){ 7809 addStyle("mktoForms2ThemeStyle", opts.baseUrl + formData.ThemeStyle.href); 7810 }else{ 7811 var styleMktoLoaded = $b("style", "#mktoStyleLoaded {color:#123456;}"); 7812 if (nonceValue !== null) { 7813 styleMktoLoaded.attr('nonce', nonceValue); 7814 } 7815 $("head").append(styleMktoLoaded); 7816 } 7817 if(formData.FontUrl){ 7818 addStyle("mktoFontUrl", formData.FontUrl); 7819 } 7820 if(formData.ThemeStyleOverride){ 7821 $("head").append($b("style", formData.ThemeStyleOverride)); 7822 } 7823 if(!forms2._polyfillsLoaded){ 7824 loadPolyfills(formData); 7825 forms2._polyfillsLoaded = true; 7826 } 7827 var po = formData.ProcessOptions; 7828 var waitCount = 0; 7829 7830 var isFBTab = function (){ 7831 var l = location; 7832 return l.hostname.indexOf(opts.fbTabDomain) != -1 && l.search.indexOf("fbTab=1") != -1 7833 } 7834 7835 var isDesigner = function (){ 7836 return location.hostname.indexOf(".marketodesigner.com") != -1; 7837 } 7838 7839 var waitFn = function (){ 7840 waitCount--; 7841 if (waitCount <= 0){ 7842 var form = Form(formData, modernizr, opts); 7843 forms.push(form); 7844 if(callback){ 7845 callback(form); 7846 } 7847 defer(function (){ 7848 if(formData.action && !isFBTab() && !isDesigner()){ 7849 //init the iframe proxy, but only if we're going to use it. 7850 var submitHost = urlApi.parse(formData.action).hostname; 7851 if(submitHost && submitHost != location.hostname && modernizr.postmessage && modernizr.json){ 7852 iframeProxy.init('//' + submitHost + opts.formXDPath); 7853 } 7854 } 7855 }); 7856 defer(function (){ 7857 emitter.emit('mktoFormReady', form); 7858 }); 7859 } 7860 }; 7861 7862 //We have to fetch the known lead info if progressive profiling is enabled and 7863 //If we have a "custom" type knownLead, we'll end up rendering a template instead of a form. 7864 var hasProfiling = po && po.profiling && po.profiling.isEnabled; 7865 var isCustomKnowLeadTypeAndHasMunchkin = po && po.knownLead && po.knownLead.type == "custom" && formData.munchkinId; 7866 if(isCustomKnowLeadTypeAndHasMunchkin || hasProfiling){ 7867 waitCount++; 7868 getKnownLead(formData.Vid, formData.munchkinId, hasProfiling, function (knownLead){ 7869 if(knownLead) { 7870 formData.filledFields = knownLead.filledFields; 7871 if(knownLead.FirstName && knownLead.LastName){ 7872 formData.knownLead = knownLead; 7873 } 7874 } 7875 waitFn(); 7876 }
7876, formData.lpId); 7877 } 7878 7879 waitCount++; 7880 waitForCssLoad(waitFn); 7881}; 7882 7883forms2.getForm = function(formId){ 7884 for(var i=0; i < forms.length; i++){ 7885 if(""+forms[i].getId() == ""+formId){ 7886 return forms[i]; 7887 } 7888 } 7889}; 7890 7891forms2.getPageFields = function (){ 7892 var params = qs.parse(location.search.replace("?", "")); 7893 var referrerParams = qs.parse(document.referrer.split("?")[0]); 7894 return { 7895 cr:params.cr || "", 7896 kw:params.kw || "", 7897 q:referrerParams.q || "" 7898 } 7899}; 7900 7901forms2.allForms = function (){ 7902 return forms; 7903}; 7904 7905 7906var callAllForms = function (callback){ 7907 $.each(forms2.allForms(), function (i, form){ 7908 defer(function (){ 7909 callback(form); 7910 }); 7911 }); 7912}; 7913 7914/** Adds a callback that will be called exactly once for each form on the page that becomes "ready". 7915 * Readyness means that the form exists, has been initially rendered and had its initial callbacks called. 7916 * Generally, this will mean that a "ready" form is currently visible to the lead. 7917 * The callback is passed a single argument, a form object. 7918 * If there is already a form that is ready at the time this function is called, 7919 * the passed callback will be called immediately. 7920 */ 7921forms2.whenReady = function (callback){ 7922 emitter.on("mktoFormReady", callback); 7923 callAllForms(callback); 7924 return forms2; 7925}; 7926 7927/* 7928 * Adds a callback that will be called every time any form renders. 7929 * Forms are rendered when initially created, then again every time that 7930 * visibility rules alter the structure of the form. 7931 * The callback will be passed a single argument, the form object of the form 7932 * that was rendered. 7933 */ 7934forms2.onFormRender = function (callback){ 7935 $("body").on("mktoRender", function (evt, form){ 7936 callback(form); 7937 }); 7938 return forms2; 7939}; 7940 7941/** 7942 * Like onFormRender, this adds a callback that will be called every time a form is rendered. 7943 * Additionally, this will also call the callback immediately for all forms that have already been rendered. 7944 * The callback will be passed a single argument, the form object of the form 7945 * that was rendered. 7946 */ 7947forms2.whenRendered = function (callback){ 7948 forms2.onFormRender(callback); 7949 callAllForms(callback); 7950 return forms2; 7951}; 7952 7953var loadPolyfills = function (formData){ 7954 //Load polyfills for browsers that need them. 7955 defer(function (){ 7956 var fields = fh.getFlattenedFields(formData); 7957 var fieldTypes = fh.getFieldTypes(fields); 7958 7959 if(!opts.skipPolyfills){ 7960 var baseUrl = opts.baseUrl; 7961 var load = modernizr.load; 7962 load({ 7963 test: (modernizr.input.placeholder), 7964 nope:[baseUrl+"polyfills/placeholder/placeholder.js", baseUrl+"polyfills/placeholder/placeholder.css"] 7965 }); 7966 load({ 7967 test:fieldTypes.date && !modernizr.inputtypes.date, 7968 yep:[baseUrl+"polyfills/datepicker/datepicker.js", baseUrl+"polyfills/datepicker/datepicker.css" ] 7969 }); 7970 load({ 7971 test:fieldTypes.range && !modernizr.inputtypes.range, 7972 yep:[baseUrl+"polyfills/range/range.js", baseUrl+"polyfills/range/range.css"] 7973 }); 7974 load({ 7975 test:fieldTypes.textarea && !modernizr.textareamaxlength, 7976 yep:[baseUrl+"polyfills/maxlength/maxlength.js"] 7977 }); 7978 7979 var hasMask = fh.anyFieldHasProperty(fields, "FieldMask"); 7980 if(hasMask) { 7981 var isAndroid = /Android/i.test(navigator.userAgent); 7982 load({ 7983 test: isAndroid, 7984 yep: [baseUrl+"polyfills/inputmask/jquery.mask.min.js"], 7985 nope: [baseUrl+"polyfills/inputmask/inputmask.min.js"] 7986 }); 7987 } 7988 } 7989 }); 7990} 7991if(typeof window !== 'undefined'){ 7992 window.MktoForms2 = forms2; 7993} 7994module.exports = forms2; 7995},{"./color.js":25,"./fields/fieldhelpers.js":30,"./form.js":42,"./iframeproxy.js":44,"./jquery.js":45,"./modal.js":47,"./modernizr.js":48,"./safelog.js":50,"./shimsham.js":51,"cookie":5,"events":6,"jquery.build":9,"querystring":13,"url":23}],44:[function(require,module,exports){ 7996var $ = require("./jquery.js"); 7997var urlApi = require("url"); 7998var $b = $.build; 7999 8000var pub = {}; 8001 8002var iframe = null; 8003var iframeWindow = null; 8004var i = 0; 8005var ready = false; 8006var frameName = "mktoFormsXDIframe" + Math.random(); 8007var inflight = {} 8008var q = []; 8009var iframeUrl; 8010 8011 8012function normalizeUrl(url){ 8013 if(url.indexOf("//") === 0){ 8014 if(url.match(/^\/\/app-.*?\.marketo\.com/i)){ 8015 return 'https:' + url; 8016 } 8017 return location.protocol + url; 8018 }else if (url.indexOf("/") === 0){ 8019 return location.protocol + "//" + location.hostname + url; 8020 } 8021 return url; 8022} 8023 8024pub.init = function (_iframeUrl){ 8025 if(!iframe){ 8026 iframeUrl = normalizeUrl(_iframeUrl); 8027 $("body").append(iframe = 8028 $b("iframe#MktoForms2XDIframe", { 8029 name:frameName 8030 }).css({display:"none"}) 8031 ); 8032 iframe.get(0).src = iframeUrl; 8033 iframeWindow = window.frames[frameName]; 8034 // LM-70403: Forms2 throws "TypeError: iframeWindow is undefined error" on Firefox 8035 // It seems FireFox on this particular customer website couldn't extract frame window by name. 8036 // Fall-back solution to retrieve contentWindow of the iframe a different way. 8037 if (!iframeWindow) { 8038 iframeWindow = iframe.get(0).contentWindow; 8039 } 8040 $(window).on("message", onMessage); 8041 } 8042} 8043 8044function onMessage (e){ 8045 if(e.originalEvent && e.originalEvent.data) { 8046 // LM-122751: Forms2 iframeproxy may receive XSS message posted by other source 8047 // To process the message ONLY IF its origin (protocol://host:port) matches iframeurl exactly 8048 var parsedIframeUrl = urlApi.parse(iframeUrl), parsedOrigin = urlApi.parse(e.originalEvent.origin); 8049 if (parsedIframeUrl.protocol !== parsedOrigin.protocol || parsedIframeUrl.port !== parsedOrigin.port || parsedIframeUrl.hostname !== parsedOrigin.hostname) { 8050 return; 8051 } 8052 var d; 8053 try { 8054 d = $.parseJSON(e.originalEvent.data); 8055 }catch(ex){ 8056 return; 8057 } 8058 if(d.mktoReady){ 8059 onReady(); 8060 }else if(d.mktoResponse){ 8061 onResponse(d.mktoResponse) 8062 } 8063 } 8064} 8065 8066function onResponse(mktoResponse){ 8067 var requestId = mktoResponse["for"]; 8068 var request = inflight[requestId]; 8069 if(request){ 8070 if(mktoResponse.error){ 8071 request.error(mktoResponse.data); 8072 }else{ 8073 request.success(mktoResponse.data); 8074 } 8075 } 8076 delete inflight[requestId]; 8077} 8078 8079function onReady(){ 8080 ready = true; 8081 $.each(q, function (i, ajaxParams){ 8082 sendMessage(ajaxParams); 8083 }) 8084 q = []; 8085} 8086 8087function sendMessage(ajaxParams){ 8088 var id = "mktoFormMessage" + (i++); 8089 inflight[id] = { 8090 error:ajaxParams.error, 8091 success:ajaxParams.success 8092 } 8093 if(ajaxParams.complete){ 8094 throw new Error("complete parameter not supported"); 8095 } 8096 ajaxParams.error = null; 8097 ajaxParams.success = null; 8098 var urlParsed = urlApi.parse(iframeUrl); 8099 8100 iframeWindow.postMessage(JSON.stringify({ 8101 mktoRequest:{ 8102 ajaxParams:ajaxParams, 8103 id:id 8104 } 8105 }), urlParsed.protocol + "//"+ urlParsed.hostname); 8106} 8107 8108function enqueue(ajaxParams){ 8109 if(ready){ 8110 sendMessage(ajaxParams); 8111 }else{ 8112 q.push(ajaxParams); 8113 } 8114} 8115 8116pub.send = function (ajaxParams){ 8117 enqueue(ajaxParams); 8118} 8119 8120module.exports = pub; 8121 8122 8123},{"./jquery.js":45,"url":23}],45:[function(require,module,exports){ 8124/*! 8125 * jQuery JavaScript Library v3.7.1 8126 * https://jquery.com/ 8127 * 8128 * Copyright OpenJS Foundation and other contributors 8129 * Released under the MIT license 8130 * https://jquery.org/license 8131 * 8132 * Date: 2023-08-28T13:37Z 8133 */ 8134( function( global, factory ) { 8135 8136 "use strict"; 8137 8138 if ( typeof module === "object" && typeof module.exports === "object" ) { 8139 8140 // For CommonJS and CommonJS-like environments where a proper `window` 8141 // is present, execute the factory and get jQuery. 8142 // For environments that do not have a `window` with a `document` 8143 // (such as Node.js), expose a factory as module.exports. 8144 // This accentuates the need for the creation of a real `window`. 8145 // e.g. var jQuery = require("jquery")(window); 8146 // See ticket trac-14549 for more info. 8147 module.exports = global.document ? 8148 factory( global, true ) : 8149 function( w ) { 8150 if ( !w.document ) { 8151 throw new Error( "jQuery requires a window with a document" ); 8152 } 8153 return factory( w ); 8154 }; 8155 } else { 8156 factory( global ); 8157 } 8158 8159// Pass this if window is not defined yet 8160} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 8161 8162// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 8163// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode 8164// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), str
vendor: 46,773 bytes, lines 8164-9805
8164ict mode should be common 8165// enough that all such attempts are guarded in a try block. 8166 "use strict"; 8167 8168 var arr = []; 8169 8170 var getProto = Object.getPrototypeOf; 8171 8172 var slice = arr.slice; 8173 8174 var flat = arr.flat ? function( array ) { 8175 return arr.flat.call( array ); 8176 } : function( array ) { 8177 return arr.concat.apply( [], array ); 8178 }; 8179 8180 8181 var push = arr.push; 8182 8183 var indexOf = arr.indexOf; 8184 8185 var class2type = {}; 8186 8187 var toString = class2type.toString; 8188 8189 var hasOwn = class2type.hasOwnProperty; 8190 8191 var fnToString = hasOwn.toString; 8192 8193 var ObjectFunctionString = fnToString.call( Object ); 8194 8195 var support = {}; 8196 8197 var isFunction = function isFunction( obj ) { 8198 8199 // Support: Chrome <=57, Firefox <=52 8200 // In some browsers, typeof returns "function" for HTML <object> elements 8201 // (i.e., `typeof document.createElement( "object" ) === "function"`). 8202 // We don't want to classify *any* DOM node as a function. 8203 // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 8204 // Plus for old WebKit, typeof returns "function" for HTML collections 8205 // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) 8206 return typeof obj === "function" && typeof obj.nodeType !== "number" && 8207 typeof obj.item !== "function"; 8208 }; 8209 8210 8211 var isWindow = function isWindow( obj ) { 8212 return obj != null && obj === obj.window; 8213 }; 8214 8215 8216 var document = window.document; 8217 8218 8219 8220 var preservedScriptAttributes = { 8221 type: true, 8222 src: true, 8223 nonce: true, 8224 noModule: true 8225 }; 8226 8227 function DOMEval( code, node, doc ) { 8228 doc = doc || document; 8229 8230 var i, val, 8231 script = doc.createElement( "script" ); 8232 8233 script.text = code; 8234 if ( node ) { 8235 for ( i in preservedScriptAttributes ) { 8236 8237 // Support: Firefox 64+, Edge 18+ 8238 // Some browsers don't support the "nonce" property on scripts. 8239 // On the other hand, just using `getAttribute` is not enough as 8240 // the `nonce` attribute is reset to an empty string whenever it 8241 // becomes browsing-context connected. 8242 // See https://github.com/whatwg/html/issues/2369 8243 // See https://html.spec.whatwg.org/#nonce-attributes 8244 // The `node.getAttribute` check was added for the sake of 8245 // `jQuery.globalEval` so that it can fake a nonce-containing node 8246 // via an object. 8247 val = node[ i ] || node.getAttribute && node.getAttribute( i ); 8248 if ( val ) { 8249 script.setAttribute( i, val ); 8250 } 8251 } 8252 } 8253 doc.head.appendChild( script ).parentNode.removeChild( script ); 8254 } 8255 8256 8257 function toType( obj ) { 8258 if ( obj == null ) { 8259 return obj + ""; 8260 } 8261 8262 // Support: Android <=2.3 only (functionish RegExp) 8263 return typeof obj === "object" || typeof obj === "function" ? 8264 class2type[ toString.call( obj ) ] || "object" : 8265 typeof obj; 8266 } 8267 /* global Symbol */ 8268// Defining this global in .eslintrc.json would create a danger of using the global 8269// unguarded in another place, it seems safer to define global only for this module 8270 8271 8272 8273 var version = "3.7.1", 8274 8275 rhtmlSuffix = /HTML$/i, 8276 8277 // Define a local copy of jQuery 8278 jQuery = function( selector, context ) { 8279 8280 // The jQuery object is actually just the init constructor 'enhanced' 8281 // Need init if jQuery is called (just allow error to be thrown if not included) 8282 return new jQuery.fn.init( selector, context ); 8283 }; 8284 8285 jQuery.fn = jQuery.prototype = { 8286 8287 // The current version of jQuery being used 8288 jquery: version, 8289 8290 constructor: jQuery, 8291 8292 // The default length of a jQuery object is 0 8293 length: 0, 8294 8295 toArray: function() { 8296 return slice.call( this ); 8297 }, 8298 8299 // Get the Nth element in the matched element set OR 8300 // Get the whole matched element set as a clean array 8301 get: function( num ) { 8302 8303 // Return all the elements in a clean array 8304 if ( num == null ) { 8305 return slice.call( this ); 8306 } 8307 8308 // Return just the one element from the set 8309 return num < 0 ? this[ num + this.length ] : this[ num ]; 8310 }, 8311 8312 // Take an array of elements and push it onto the stack 8313 // (returning the new matched element set) 8314 pushStack: function( elems ) { 8315 8316 // Build a new jQuery matched element set 8317 var ret = jQuery.merge( this.constructor(), elems ); 8318 8319 // Add the old object onto the stack (as a reference) 8320 ret.prevObject = this; 8321 8322 // Return the newly-formed element set 8323 return ret; 8324 }, 8325 8326 // Execute a callback for every element in the matched set. 8327 each: function( callback ) { 8328 return jQuery.each( this, callback ); 8329 }, 8330 8331 map: function( callback ) { 8332 return this.pushStack( jQuery.map( this, function( elem, i ) { 8333 return callback.call( elem, i, elem ); 8334 } ) ); 8335 }, 8336 8337 slice: function() { 8338 return this.pushStack( slice.apply( this, arguments ) ); 8339 }, 8340 8341 first: function() { 8342 return this.eq( 0 ); 8343 }, 8344 8345 last: function() { 8346 return this.eq( -1 ); 8347 }, 8348 8349 even: function() { 8350 return this.pushStack( jQuery.grep( this, function( _elem, i ) { 8351 return ( i + 1 ) % 2; 8352 } ) ); 8353 }, 8354 8355 odd: function() { 8356 return this.pushStack( jQuery.grep( this, function( _elem, i ) { 8357 return i % 2; 8358 } ) ); 8359 }, 8360 8361 eq: function( i ) { 8362 var len = this.length, 8363 j = +i + ( i < 0 ? len : 0 ); 8364 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 8365 }, 8366 8367 end: function() { 8368 return this.prevObject || this.constructor(); 8369 }, 8370 8371 // For internal use only. 8372 // Behaves like an Array's method, not like a jQuery method. 8373 push: push, 8374 sort: arr.sort, 8375 splice: arr.splice 8376 }; 8377 8378 jQuery.extend = jQuery.fn.extend = function() { 8379 var options, name, src, copy, copyIsArray, clone, 8380 target = arguments[ 0 ] || {}, 8381 i = 1, 8382 length = arguments.length, 8383 deep = false; 8384 8385 // Handle a deep copy situation 8386 if ( typeof target === "boolean" ) { 8387 deep = target; 8388 8389 // Skip the boolean and the target 8390 target = arguments[ i ] || {}; 8391 i++; 8392 } 8393 8394 // Handle case when target is a string or something (possible in deep copy) 8395 if ( typeof target !== "object" && !isFunction( target ) ) { 8396 target = {}; 8397 } 8398 8399 // Extend jQuery itself if only one argument is passed 8400 if ( i === length ) { 8401 target = this; 8402 i--; 8403 } 8404 8405 for ( ; i < length; i++ ) { 8406 8407 // Only deal with non-null/undefined values 8408 if ( ( options = arguments[ i ] ) != null ) { 8409 8410 // Extend the base object 8411 for ( name in options ) { 8412 copy = options[ name ]; 8413 8414 // Prevent Object.prototype pollution 8415 // Prevent never-ending loop 8416 if ( name === "__proto__" || target === copy ) { 8417 continue; 8418 } 8419 8420 // Recurse if we're merging plain objects or arrays 8421 if ( deep && copy && ( jQuery.isPlainObject( copy ) || 8422 ( copyIsArray = Array.isArray( copy ) ) ) ) { 8423 src = target[ name ]; 8424 8425 // Ensure proper type for the source value 8426 if ( copyIsArray && !Array.isArray( src ) ) { 8427 clone = []; 8428 } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { 8429 clone = {}; 8430 } else { 8431 clone = src; 8432 } 8433 copyIsArray = false; 8434 8435 // Never move original objects, clone them 8436 target[ name ] = jQuery.extend( deep, clone, copy ); 8437 8438 // Don't bring in undefined values 8439 } else if ( copy !== undefined ) { 8440 target[ name ] = copy; 8441 } 8442 } 8443 } 8444 } 8445 8446 // Return the modified object 8447 return target; 8448 }; 8449 8450 jQuery.extend( { 8451 8452 // Unique for each copy of jQuery on the page 8453 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 8454 8455 // Assume jQuery is ready without the ready module 8456 isReady: true, 8457 8458 error: function( msg ) { 8459 throw new Error( msg ); 8460 }, 8461 8462 noop: function() {}, 8463 8464 isPlainObject: function( obj ) { 8465 var proto, Ctor; 8466 8467 // Detect obvious negatives 8468 // Use toString instead of jQuery.type to catch host objects 8469 if ( !obj || toString.call( obj ) !== "[object Object]" ) { 8470 return false; 8471 } 8472 8473 proto = getProto( obj ); 8474 8475 // Objects with no prototype (e.g., `Object.create( null )`) are plain 8476 if ( !proto ) { 8477 return true; 8478 } 8479 8480 // Objects with prototype are plain iff they were constructed by a global Object function 8481 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; 8482 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; 8483 }, 8484 8485 isEmptyObject: function( obj ) { 8486 var name; 8487 8488 for ( name in obj ) { 8489 return false; 8490 } 8491 return true; 8492 }, 8493 8494 // Evaluates a script in a provided context; falls back to the global one 8495 // if not specified. 8496 globalEval: function( code, options, doc ) { 8497 DOMEval( code, { nonce: options && options.nonce }, doc ); 8498 }, 8499 8500 each: function( obj, callback ) { 8501 var length, i = 0; 8502 8503 if ( isArrayLike( obj ) ) { 8504 length = obj.length; 8505 for ( ; i < length; i++ ) { 8506 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 8507 break; 8508 } 8509 } 8510 } else { 8511 for ( i in obj ) { 8512 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 8513 break; 8514 } 8515 } 8516 } 8517 8518 return obj; 8519 }, 8520 8521 8522 // Retrieve the text value of an array of DOM nodes 8523 text: function( elem ) { 8524 var node, 8525 ret = "", 8526 i = 0, 8527 nodeType = elem.nodeType; 8528 8529 if ( !nodeType ) { 8530 8531 // If no nodeType, this is expected to be an array 8532 while ( ( node = elem[ i++ ] ) ) { 8533 8534 // Do not traverse comment nodes 8535 ret += jQuery.text( node ); 8536 } 8537 } 8538 if ( nodeType === 1 || nodeType === 11 ) { 8539 return elem.textContent; 8540 } 8541 if ( nodeType === 9 ) { 8542 return elem.documentElement.textContent; 8543 } 8544 if ( nodeType === 3 || nodeType === 4 ) { 8545 return elem.nodeValue; 8546 } 8547 8548 // Do not include comment or processing instruction nodes 8549 8550 return ret; 8551 }, 8552 8553 // results is for internal usage only 8554 makeArray: function( arr, results ) { 8555 var ret = results || []; 8556 8557 if ( arr != null ) { 8558 if ( isArrayLike( Object( arr ) ) ) { 8559 jQuery.merge( ret, 8560 typeof arr === "string" ? 8561 [ arr ] : arr 8562 ); 8563 } else { 8564 push.call( ret, arr ); 8565 } 8566 } 8567 8568 return ret; 8569 }, 8570 8571 inArray: function( elem, arr, i ) { 8572 return arr == null ? -1 : indexOf.call( arr, elem, i ); 8573 }, 8574 8575 isXMLDoc: function( elem ) { 8576 var namespace = elem && elem.namespaceURI, 8577 docElem = elem && ( elem.ownerDocument || elem ).documentElement; 8578 8579 // Assume HTML when documentElement doesn't yet exist, such as inside 8580 // document fragments. 8581 return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" ); 8582 }, 8583 8584 // Support: Android <=4.0 only, PhantomJS 1 only 8585 // push.apply(_, arraylike) throws on ancient WebKit 8586 merge: function( first, second ) { 8587 var len = +second.length, 8588 j = 0, 8589 i = first.length; 8590 8591 for ( ; j < len; j++ ) { 8592 first[ i++ ] = second[ j ]; 8593 } 8594 8595 first.length = i; 8596 8597 return first; 8598 }, 8599 8600 grep: function( elems, callback, invert ) { 8601 var callbackInverse, 8602 matches = [], 8603 i = 0, 8604 length = elems.length, 8605 callbackExpect = !invert; 8606 8607 // Go through the array, only saving the items 8608 // that pass the validator function 8609 for ( ; i < length; i++ ) { 8610 callbackInverse = !callback( elems[ i ], i ); 8611 if ( callbackInverse !== callbackExpect ) { 8612 matches.push( elems[ i ] ); 8613 } 8614 } 8615 8616 return matches; 8617 }, 8618 8619 // arg is for internal usage only 8620 map: function( elems, callback, arg ) { 8621 var length, value, 8622 i = 0, 8623 ret = []; 8624 8625 // Go through the array, translating each of the items to their new values 8626 if ( isArrayLike( elems ) ) { 8627 length = elems.length; 8628 for ( ; i < length; i++ ) { 8629 value = callback( elems[ i ], i, arg ); 8630 8631 if ( value != null ) { 8632 ret.push( value ); 8633 } 8634 } 8635 8636 // Go through every key on the object, 8637 } else { 8638 for ( i in elems ) { 8639 value = callback( elems[ i ], i, arg ); 8640 8641 if ( value != null ) { 8642 ret.push( value ); 8643 } 8644 } 8645 } 8646 8647 // Flatten any nested arrays 8648 return flat( ret ); 8649 }, 8650 8651 // A global GUID counter for objects 8652 guid: 1, 8653 8654 // jQuery.support is not used in Core but other projects attach their 8655 // properties to it so it needs to exist. 8656 support: support 8657 } ); 8658 8659 if ( typeof Symbol === "function" ) { 8660 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; 8661 } 8662 8663// Populate the class2type map 8664 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 8665 function( _i, name ) { 8666 class2type[ "[object " + name + "]" ] = name.toLowerCase(); 8667 } ); 8668 8669 function isArrayLike( obj ) { 8670 8671 // Support: real iOS 8.2 only (not reproducible in simulator) 8672 // `in` check used to prevent JIT error (gh-2145) 8673 // hasOwn isn't used here due to false negatives 8674 // regarding Nodelist length in IE 8675 var length = !!obj && "length" in obj && obj.length, 8676 type = toType( obj ); 8677 8678 if ( isFunction( obj ) || isWindow( obj ) ) { 8679 return false; 8680 } 8681 8682 return type === "array" || length === 0 || 8683 typeof length === "number" && length > 0 && ( length - 1 ) in obj; 8684 } 8685 8686 8687 function nodeName( elem, name ) { 8688 8689 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 8690 8691 } 8692 var pop = arr.pop; 8693 8694 8695 var sort = arr.sort; 8696 8697 8698 var splice = arr.splice; 8699 8700 8701 var whitespace = "[\\x20\\t\\r\\n\\f]"; 8702 8703 8704 var rtrimCSS = new RegExp( 8705 "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", 8706 "g" 8707 ); 8708 8709 8710 8711 8712// Note: an element does not contain itself 8713 jQuery.contains = function( a, b ) { 8714 var bup = b && b.parentNode; 8715 8716 return a === bup || !!( bup && bup.nodeType === 1 && ( 8717 8718 // Support: IE 9 - 11+ 8719 // IE doesn't have `contains` on SVG. 8720 a.contains ? 8721 a.contains( bup ) : 8722 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 8723 ) ); 8724 }; 8725 8726 8727 8728 8729// CSS string/identifier serialization 8730// https://drafts.csswg.org/cssom/#common-serializing-idioms 8731 var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g; 8732 8733 function fcssescape( ch, asCodePoint ) { 8734 if ( asCodePoint ) { 8735 8736 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 8737 if ( ch === "\0" ) { 8738 return "\uFFFD"; 8739 } 8740 8741 // Control characters and (dependent upon position) numbers get escaped as code points 8742 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 8743 } 8744 8745 // Other potentially-special ASCII characters get backslash-escaped 8746 return "\\" + ch; 8747 } 8748 8749 jQuery.escapeSelector = function( sel ) { 8750 return ( sel + "" ).replace( rcssescape, fcssescape ); 8751 }; 8752 8753 8754 8755 8756 var preferredDoc = document, 8757 pushNative = push; 8758 8759 ( function() { 8760 8761 var i, 8762 Expr, 8763 outermostContext, 8764 sortInput, 8765 hasDuplicate, 8766 push = pushNative, 8767 8768 // Local document vars 8769 document, 8770 documentElement, 8771 documentIsHTML, 8772 rbuggyQSA, 8773 matches, 8774 8775 // Instance-specific data 8776 expando = jQuery.expando, 8777 dirruns = 0, 8778 done = 0, 8779 classCache = createCache(), 8780 tokenCache = createCache(), 8781 compilerCache = createCache(), 8782 nonnativeSelectorCache = createCache(), 8783 sortOrder = function( a, b ) { 8784 if ( a === b ) { 8785 hasDuplicate = true; 8786 } 8787 return 0; 8788 }, 8789 8790 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" + 8791 "loop|multiple|open|readonly|required|scoped", 8792 8793 // Regular expressions 8794 8795 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram 8796 identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + 8797 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", 8798 8799 // Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors 8800 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 8801 8802 // Operator (capture 2) 8803 "*([*^$|!~]?=)" + whitespace + 8804 8805 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" 8806 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + 8807 whitespace + "*\\]", 8808 8809 pseudos = ":(" + identifier + ")(?:\\((" + 8810 8811 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 8812 // 1. quoted (capture 3; capture 4 or capture 5) 8813 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 8814 8815 // 2. simple (capture 6) 8816 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 8817 8818 // 3. anything else (capture 2) 8819 ".*" + 8820 ")\\)|)", 8821 8822 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 8823 rwhitespace = new RegExp( whitespace + "+", "g" ), 8824 8825 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 8826 rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + 8827 whitespace + "*" ), 8828 rdescend = new RegExp( whitespace + "|>" ), 8829 8830 rpseudo = new RegExp( pseudos ), 8831 ridentifier = new RegExp( "^" + identifier + "$" ), 8832 8833 matchExpr = { 8834 ID: new RegExp( "^#(" + identifier + ")" ), 8835 CLASS: new RegExp( "^\\.(" + identifier + ")" ), 8836 TAG: new RegExp( "^(" + identifier + "|[*])" ), 8837 ATTR: new RegExp( "^" + attributes ), 8838 PSEUDO: new RegExp( "^" + pseudos ), 8839 CHILD: new RegExp( 8840 "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + 8841 whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + 8842 whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 8843 bool: new RegExp( "^(?:" + booleans + ")$", "i" ), 8844 8845 // For use in libraries implementing .is() 8846 // We use this for POS matching in `select` 8847 needsContext: new RegExp( "^" + whitespace + 8848 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + 8849 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 8850 }, 8851 8852 rinputs = /^(?:input|select|textarea|button)$/i, 8853 rheader = /^h\d$/i, 8854 8855 // Easily-parseable/retrievable ID or TAG or CLASS selectors 8856 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 8857 8858 rsibling = /[+~]/, 8859 8860 // CSS escapes 8861 // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters 8862 runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + 8863 "?|\\\\([^\\r\\n\\f])", "g" ), 8864 funescape = function( escape, nonHex ) { 8865 var high = "0x" + escape.slice( 1 ) - 0x10000; 8866 8867 if ( nonHex ) { 8868 8869 // Strip the backslash prefix from a non-hex escape sequence 8870 return nonHex; 8871 } 8872 8873 // Replace a hexadecimal escape sequence with the encoded Unicode code point 8874 // Support: IE <=11+ 8875 // For values outside the Basic Multilingual Plane (BMP), manually construct a 8876 // surrogate pair 8877 return high < 0 ? 8878 String.fromCharCode( high + 0x10000 ) : 8879 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 8880 }, 8881 8882 // Used for iframes; see `setDocument`. 8883 // Support: IE 9 - 11+, Edge 12 - 18+ 8884 // Removing the function wrapper causes a "Permission Denied" 8885 // error in IE/Edge. 8886 unloadHandler = function() { 8887 setDocument(); 8888 }, 8889 8890 inDisabledFieldset = addCombinator( 8891 function( elem ) { 8892 return elem.disabled === true && nodeName( elem, "fieldset" ); 8893 }, 8894 { dir: "parentNode", next: "legend" } 8895 ); 8896 8897// Support: IE <=9 only 8898// Accessing document.activeElement can throw unexpectedly 8899// https://bugs.jquery.com/ticket/13393 8900 function safeActiveElement() { 8901 try { 8902 return document.activeElement; 8903 } catch ( err ) { } 8904 } 8905 8906// Optimize for push.apply( _, NodeList ) 8907 try { 8908 push.apply( 8909 ( arr = slice.call( preferredDoc.childNodes ) ), 8910 preferredDoc.childNodes 8911 ); 8912 8913 // Support: Android <=4.0 8914 // Detect silently failing push.apply 8915 // eslint-disable-next-line no-unused-expressions 8916 arr[ preferredDoc.childNodes.length ].nodeType; 8917 } catch ( e ) { 8918 push = { 8919 apply: function( target, els ) { 8920 pushNative.apply( target, slice.call( els ) ); 8921 }, 8922 call: function( target ) { 8923 pushNative.apply( target, slice.call( arguments, 1 ) ); 8924 } 8925 }; 8926 } 8927 8928 function find( selector, context, results, seed ) { 8929 var m, i, elem, nid, match, groups, newSelector, 8930 newContext = context && context.ownerDocument, 8931 8932 // nodeType defaults to 9, since context defaults to document 8933 nodeType = context ? context.nodeType : 9; 8934 8935 results = results || []; 8936 8937 // Return early from calls with invalid selector or context 8938 if ( typeof selector !== "string" || !selector || 8939 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 8940 8941 return results; 8942 } 8943 8944 // Try to shortcut find operations (as opposed to filters) in HTML documents 8945 if ( !seed ) { 8946 setDocument( context ); 8947 context = context || document; 8948 8949 if ( documentIsHTML ) { 8950 8951 // If the selector is sufficiently simple, try using a "get*By*" DOM method 8952 // (excepting DocumentFragment context, where the methods don't exist) 8953 if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { 8954 8955 // ID selector 8956 if ( ( m = match[ 1 ] ) ) { 8957 8958 // Document context 8959 if ( nodeType === 9 ) { 8960 if ( ( elem = context.getElementById( m ) ) ) { 8961 8962 // Support: IE 9 only 8963 // getElementById can match elements by name instead of ID 8964 if ( elem.id === m ) { 8965 push.call( results, elem ); 8966 return results; 8967 } 8968 } else { 8969 return results; 8970 } 8971 8972 // Element context 8973 } else { 8974 8975 // Support: IE 9 only 8976 // getElementById can match elements by name instead of ID 8977 if ( newContext && ( elem = newContext.getElementById( m ) ) && 8978 find.contains( context, elem ) && 8979 elem.id === m ) { 8980 8981 push.call( results, elem ); 8982 return results; 8983 } 8984 } 8985 8986 // Type selector 8987 } else if ( match[ 2 ] ) { 8988 push.apply( results, context.getElementsByTagName( selector ) ); 8989 return results; 8990 8991 // Class selector 8992 } else if ( ( m = match[ 3 ] ) && context.getElementsByClassName ) { 8993 push.apply( results, context.getElementsByClassName( m ) ); 8994 return results; 8995 } 8996 } 8997 8998 // Take advantage of querySelectorAll 8999 if ( !nonnativeSelectorCache[ selector + " " ] && 9000 ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) ) { 9001 9002 newSelector = selector; 9003 newContext = context; 9004 9005 // qSA considers elements outside a scoping root when evaluating child or 9006 // descendant combinators, which is not what we want. 9007 // In such cases, we work around the behavior by prefixing every selector in the 9008 // list with an ID selector referencing the scope context. 9009 // The technique has to be used as well when a leading combinator is used 9010 // as such selectors are not recognized by querySelectorAll. 9011 // Thanks to Andrew Dupont for this technique. 9012 if ( nodeType === 1 && 9013 ( rdescend.test( selector ) || rleadingCombinator.test( selector ) ) ) { 9014 9015 // Expand context for sibling selectors 9016 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 9017 context; 9018 9019 // We can use :scope instead of the ID hack if the browser 9020 // supports it & if we're not changing the context. 9021 // Support: IE 11+, Edge 17 - 18+ 9022 // IE/Edge sometimes throw a "Permission denied" error when 9023 // strict-comparing two documents; shallow comparisons work. 9024 // eslint-disable-next-line eqeqeq 9025 if ( newContext != context || !support.scope ) { 9026 9027 // Capture the context ID, setting it first if necessary 9028 if ( ( nid = context.getAttribute( "id" ) ) ) { 9029 nid = jQuery.escapeSelector( nid ); 9030 } else { 9031 context.setAttribute( "id", ( nid = expando ) ); 9032 } 9033 } 9034 9035 // Prefix every selector in the list 9036 groups = tokenize( selector ); 9037 i = groups.length; 9038 while ( i-- ) { 9039 groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + 9040 toSelector( groups[ i ] ); 9041 } 9042 newSelector = groups.join( "," ); 9043 } 9044 9045 try { 9046 push.apply( results, 9047 newContext.querySelectorAll( newSelector ) 9048 ); 9049 return results; 9050 } catch ( qsaError ) { 9051 nonnativeSelectorCache( selector, true ); 9052 } finally { 9053 if ( nid === expando ) { 9054 context.removeAttribute( "id" ); 9055 } 9056 } 9057 } 9058 } 9059 } 9060 9061 // All others 9062 return select( selector.replace( rtrimCSS, "$1" ), context, results, seed ); 9063 } 9064 9065 /** 9066 * Create key-value caches of limited size 9067 * @returns {function(string, object)} Returns the Object data after storing it on itself with 9068 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 9069 * deleting the oldest entry 9070 */ 9071 function createCache() { 9072 var keys = []; 9073 9074 function cache( key, value ) { 9075 9076 // Use (key + " ") to avoid collision with native prototype properties 9077 // (see https://github.com/jquery/sizzle/issues/157) 9078 if ( keys.push( key + " " ) > Expr.cacheLength ) { 9079 9080 // Only keep the most recent entries 9081 delete cache[ keys.shift() ]; 9082 } 9083 return ( cache[ key + " " ] = value ); 9084 } 9085 return cache; 9086 } 9087 9088 /** 9089 * Mark a function for special use by jQuery selector module 9090 * @param {Function} fn The function to mark 9091 */ 9092 function markFunction( fn ) { 9093 fn[ expando ] = true; 9094 return fn; 9095 } 9096 9097 /** 9098 * Support testing using an element 9099 * @param {Function} fn Passed the created element and returns a boolean result 9100 */ 9101 function assert( fn ) { 9102 var el = document.createElement( "fieldset" ); 9103 9104 try { 9105 return !!fn( el ); 9106 } catch ( e ) { 9107 return false; 9108 } finally { 9109 9110 // Remove from its parent by default 9111 if ( el.parentNode ) { 9112 el.parentNode.removeChild( el ); 9113 } 9114 9115 // release memory in IE 9116 el = null; 9117 } 9118 } 9119 9120 /** 9121 * Returns a function to use in pseudos for input types 9122 * @param {String} type 9123 */ 9124 function createInputPseudo( type ) { 9125 return function( elem ) { 9126 return nodeName( elem, "input" ) && elem.type === type; 9127 }; 9128 } 9129 9130 /** 9131 * Returns a function to use in pseudos for buttons 9132 * @param {String} type 9133 */ 9134 function createButtonPseudo( type ) { 9135 return function( elem ) { 9136 return ( nodeName( elem, "input" ) || nodeName( elem, "button" ) ) && 9137 elem.type === type; 9138 }; 9139 } 9140 9141 /** 9142 * Returns a function to use in pseudos for :enabled/:disabled 9143 * @param {Boolean} disabled true for :disabled; false for :enabled 9144 */ 9145 function createDisabledPseudo( disabled ) { 9146 9147 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable 9148 return function( elem ) { 9149 9150 // Only certain elements can match :enabled or :disabled 9151 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled 9152 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled 9153 if ( "form" in elem ) { 9154 9155 // Check for inherited disabledness on relevant non-disabled elements: 9156 // * listed form-associated elements in a disabled fieldset 9157 // https://html.spec.whatwg.org/multipage/forms.html#category-listed 9158 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled 9159 // * option elements in a disabled optgroup 9160 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled 9161 // All such elements have a "form" property. 9162 if ( elem.parentNode && elem.disabled === false ) { 9163 9164 // Option elements defer to a parent optgroup if present 9165 if ( "label" in elem ) { 9166 if ( "label" in elem.parentNode ) { 9167 return elem.parentNode.disabled === disabled; 9168 } else { 9169 return elem.disabled === disabled; 9170 } 9171 } 9172 9173 // Support: IE 6 - 11+ 9174 // Use the isDisabled shortcut property to check for disabled fieldset ancestors 9175 return elem.isDisabled === disabled || 9176 9177 // Where there is no isDisabled, check manually 9178 elem.isDisabled !== !disabled && 9179 inDisabledFieldset( elem ) === disabled; 9180 } 9181 9182 return elem.disabled === disabled; 9183 9184 // Try to winnow out elements that can't be disabled before trusting the disabled property. 9185 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't 9186 // even exist on them, let alone have a boolean value. 9187 } else if ( "label" in elem ) { 9188 return elem.disabled === disabled; 9189 } 9190 9191 // Remaining elements are neither :enabled nor :disabled 9192 return false; 9193 }; 9194 } 9195 9196 /** 9197 * Returns a function to use in pseudos for positionals 9198 * @param {Function} fn 9199 */ 9200 function createPositionalPseudo( fn ) { 9201 return markFunction( function( argument ) { 9202 argument = +argument; 9203 return markFunction( function( seed, matches ) { 9204 var j, 9205 matchIndexes = fn( [], seed.length, argument ), 9206 i = matchIndexes.length; 9207 9208 // Match elements found at the specified indexes 9209 while ( i-- ) { 9210 if ( seed[ ( j = matchIndexes[ i ] ) ] ) { 9211 seed[ j ] = !( matches[ j ] = seed[ j ] ); 9212 } 9213 } 9214 } ); 9215 } ); 9216 } 9217 9218 /** 9219 * Checks a node for validity as a jQuery selector context 9220 * @param {Element|Object=} context 9221 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 9222 */ 9223 function testContext( context ) { 9224 return context && typeof context.getElementsByTagName !== "undefined" && context; 9225 } 9226 9227 /** 9228 * Sets document-related variables once based on the current document 9229 * @param {Element|Object} [node] An element or document object to use to set the document 9230 * @returns {Object} Returns the current document 9231 */ 9232 function setDocument( node ) { 9233 var subWindow, 9234 doc = node ? node.ownerDocument || node : preferredDoc; 9235 9236 // Return early if doc is invalid or already selected 9237 // Support: IE 11+, Edge 17 - 18+ 9238 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9239 // two documents; shallow comparisons work. 9240 // eslint-disable-next-line eqeqeq 9241 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { 9242 return document; 9243 } 9244 9245 // Update global variables 9246 document = doc; 9247 documentElement = document.documentElement; 9248 documentIsHTML = !jQuery.isXMLDoc( document ); 9249 9250 // Support: iOS 7 only, IE 9 - 11+ 9251 // Older browsers didn't support unprefixed `matches`. 9252 matches = documentElement.matches || 9253 documentElement.webkitMatchesSelector || 9254 documentElement.msMatchesSelector; 9255 9256 // Support: IE 9 - 11+, Edge 12 - 18+ 9257 // Accessing iframe documents after unload throws "permission denied" errors 9258 // (see trac-13936). 9259 // Limit the fix to IE & Edge Legacy; despite Edge 15+ implementing `matches`, 9260 // all IE 9+ and Edge Legacy versions implement `msMatchesSelector` as well. 9261 if ( documentElement.msMatchesSelector && 9262 9263 // Support: IE 11+, Edge 17 - 18+ 9264 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9265 // two documents; shallow comparisons work. 9266 // eslint-disable-next-line eqeqeq 9267 preferredDoc != document && 9268 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { 9269 9270 // Support: IE 9 - 11+, Edge 12 - 18+ 9271 subWindow.addEventListener( "unload", unloadHandler ); 9272 } 9273 9274 // Support: IE <10 9275 // Check if getElementById returns elements by name 9276 // The broken getElementById methods don't pick up programmatically-set names, 9277 // so use a roundabout getElementsByName test 9278 support.getById = assert( function( el ) { 9279 documentElement.appendChild( el ).id = jQuery.expando; 9280 return !document.getElementsByName || 9281 !document.getElementsByName( jQuery.expando ).length; 9282 } ); 9283 9284 // Support: IE 9 only 9285 // Check to see if it's possible to do matchesSelector 9286 // on a disconnected node. 9287 support.disconnectedMatch = assert( function( el ) { 9288 return matches.call( el, "*" ); 9289 } ); 9290 9291 // Support: IE 9 - 11+, Edge 12 - 18+ 9292 // IE/Edge don't support the :scope pseudo-class. 9293 support.scope = assert( function() { 9294 return document.querySelectorAll( ":scope" ); 9295 } ); 9296 9297 // Support: Chrome 105 - 111 only, Safari 15.4 - 16.3 only 9298 // Make sure the `:has()` argument is parsed unforgivingly. 9299 // We include `*` in the test to detect buggy implementations that are 9300 // _selectively_ forgiving (specifically when the list includes at least 9301 // one valid selector). 9302 // Note that we treat complete lack of support for `:has()` as if it were 9303 // spec-compliant support, which is fine because use of `:has()` in such 9304 // environments will fail in the qSA path and fall back to jQuery traversal 9305 // anyway. 9306 support.cssHas = assert( function() { 9307 try { 9308 document.querySelector( ":has(*,:jqfake)" ); 9309 return false; 9310 } catch ( e ) { 9311 return true; 9312 } 9313 } ); 9314 9315 // ID filter and find 9316 if ( support.getById ) { 9317 Expr.filter.ID = function( id ) { 9318 var attrId = id.replace( runescape, funescape ); 9319 return function( elem ) { 9320 return elem.getAttribute( "id" ) === attrId; 9321 }; 9322 }; 9323 Expr.find.ID = function( id, context ) { 9324 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 9325 var elem = context.getElementById( id ); 9326 return elem ? [ elem ] : []; 9327 } 9328 }; 9329 } else { 9330 Expr.filter.ID = function( id ) { 9331 var attrId = id.replace( runescape, funescape ); 9332 return function( elem ) { 9333 var node = typeof elem.getAttributeNode !== "undefined" && 9334 elem.getAttributeNode( "id" ); 9335 return node && node.value === attrId; 9336 }; 9337 }; 9338 9339 // Support: IE 6 - 7 only 9340 // getElementById is not reliable as a find shortcut 9341 Expr.find.ID = function( id, context ) { 9342 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 9343 var node, i, elems, 9344 elem = context.getElementById( id ); 9345 9346 if ( elem ) { 9347 9348 // Verify the id attribute 9349 node = elem.getAttributeNode( "id" ); 9350 if ( node && node.value === id ) { 9351 return [ elem ]; 9352 } 9353 9354 // Fall back on getElementsByName 9355 elems = context.getElementsByName( id ); 9356 i = 0; 9357 while ( ( elem = elems[ i++ ] ) ) { 9358 node = elem.getAttributeNode( "id" ); 9359 if ( node && node.value === id ) { 9360 return [ elem ]; 9361 } 9362 } 9363 } 9364 9365 return []; 9366 } 9367 }; 9368 } 9369 9370 // Tag 9371 Expr.find.TAG = function( tag, context ) { 9372 if ( typeof context.getElementsByTagName !== "undefined" ) { 9373 return context.getElementsByTagName( tag ); 9374 9375 // DocumentFragment nodes don't have gEBTN 9376 } else { 9377 return context.querySelectorAll( tag ); 9378 } 9379 }; 9380 9381 // Class 9382 Expr.find.CLASS = function( className, context ) { 9383 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 9384 return context.getElementsByClassName( className ); 9385 } 9386 }; 9387 9388 /* QSA/matchesSelector 9389 ---------------------------------------------------------------------- */ 9390 9391 // QSA and matchesSelector support 9392 9393 rbuggyQSA = []; 9394 9395 // Build QSA regex 9396 // Regex strategy adopted from Diego Perini 9397 assert( function( el ) { 9398 9399 var input; 9400 9401 documentElement.appendChild( el ).innerHTML = 9402 "<a id='" + expando + "' href='' disabled='disabled'></a>" + 9403 "<select id='" + expando + "-\r\\' disabled='disabled'>" + 9404 "<option selected=''></option></select>"; 9405 9406 // Support: iOS <=7 - 8 only 9407 // Boolean attributes and "value" are not treated correctly in some XML documents 9408 if ( !el.querySelectorAll( "[selected]" ).length ) { 9409 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 9410 } 9411 9412 // Support: iOS <=7 - 8 only 9413 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 9414 rbuggyQSA.push( "~=" ); 9415 } 9416 9417 // Support: iOS 8 only 9418 // https://bugs.webkit.org/show_bug.cgi?id=136851 9419 // In-page `selector#id sibling-combinator selector` fails 9420 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { 9421 rbuggyQSA.push( ".#.+[+~]" ); 9422 } 9423 9424 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+ 9425 // In some of the document kinds, these selectors wouldn't work natively. 9426 // This is probably OK but for backwards compatibility we want to maintain 9427 // handling them through jQuery traversal in jQuery 3.x. 9428 if ( !el.querySelectorAll( ":checked" ).length ) { 9429 rbuggyQSA.push( ":checked" ); 9430 } 9431 9432 // Support: Windows 8 Native Apps 9433 // The type and name attributes are restricted during .innerHTML assignment 9434 input = document.createElement( "input" ); 9435 input.setAttribute( "type", "hidden" ); 9436 el.appendChild( input ).setAttribute( "name", "D" ); 9437 9438 // Support: IE 9 - 11+ 9439 // IE's :disabled selector does not pick up the children of disabled fieldsets 9440 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+ 9441 // In some of the document kinds, these selectors wouldn't work natively. 9442 // This is probably OK but for backwards compatibility we want to maintain 9443 // handling them through jQuery traversal in jQuery 3.x. 9444 documentElement.appendChild( el ).disabled = true; 9445 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { 9446 rbuggyQSA.push( ":enabled", ":disabled" ); 9447 } 9448 9449 // Support: IE 11+, Edge 15 - 18+ 9450 // IE 11/Edge don't find elements on a `[name='']` query in some cases. 9451 // Adding a temporary attribute to the document before the selection works 9452 // around the issue. 9453 // Interestingly, IE 10 & older don't seem to have the issue. 9454 input = document.createElement( "input" ); 9455 input.setAttribute( "name", "" ); 9456 el.appendChild( input ); 9457 if ( !el.querySelectorAll( "[name='']" ).length ) { 9458 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + 9459 whitespace + "*(?:''|\"\")" ); 9460 } 9461 } ); 9462 9463 if ( !support.cssHas ) { 9464 9465 // Support: Chrome 105 - 110+, Safari 15.4 - 16.3+ 9466 // Our regular `try-catch` mechanism fails to detect natively-unsupported 9467 // pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`) 9468 // in browsers that parse the `:has()` argument as a forgiving selector list. 9469 // https://drafts.csswg.org/selectors/#relational now requires the argument 9470 // to be parsed unforgivingly, but browsers have not yet fully adjusted. 9471 rbuggyQSA.push( ":has" ); 9472 } 9473 9474 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); 9475 9476 /* Sorting 9477 ---------------------------------------------------------------------- */ 9478 9479 // Document order sorting 9480 sortOrder = function( a, b ) { 9481 9482 // Flag for duplicate removal 9483 if ( a === b ) { 9484 hasDuplicate = true; 9485 return 0; 9486 } 9487 9488 // Sort on method existence if only one input has compareDocumentPosition 9489 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 9490 if ( compare ) { 9491 return compare; 9492 } 9493 9494 // Calculate position if both inputs belong to the same document 9495 // Support: IE 11+, Edge 17 - 18+ 9496 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9497 // two documents; shallow comparisons work. 9498 // eslint-disable-next-line eqeqeq 9499 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? 9500 a.compareDocumentPosition( b ) : 9501 9502 // Otherwise we know they are disconnected 9503 1; 9504 9505 // Disconnected nodes 9506 if ( compare & 1 || 9507 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { 9508 9509 // Choose the first element that is related to our preferred document 9510 // Support: IE 11+, Edge 17 - 18+ 9511 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9512 // two documents; shallow comparisons work. 9513 // eslint-disable-next-line eqeqeq 9514 if ( a === document || a.ownerDocument == preferredDoc && 9515 find.contains( preferredDoc, a ) ) { 9516 return -1; 9517 } 9518 9519 // Support: IE 11+, Edge 17 - 18+ 9520 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9521 // two documents; shallow comparisons work. 9522 // eslint-disable-next-line eqeqeq 9523 if ( b === document || b.ownerDocument == preferredDoc && 9524 find.contains( preferredDoc, b ) ) { 9525 return 1; 9526 } 9527 9528 // Maintain original order 9529 return sortInput ? 9530 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : 9531 0; 9532 } 9533 9534 return compare & 4 ? -1 : 1; 9535 }; 9536 9537 return document; 9538 } 9539 9540 find.matches = function( expr, elements ) { 9541 return find( expr, null, null, elements ); 9542 }; 9543 9544 find.matchesSelector = function( elem, expr ) { 9545 setDocument( elem ); 9546 9547 if ( documentIsHTML && 9548 !nonnativeSelectorCache[ expr + " " ] && 9549 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 9550 9551 try { 9552 var ret = matches.call( elem, expr ); 9553 9554 // IE 9's matchesSelector returns false on disconnected nodes 9555 if ( ret || support.disconnectedMatch || 9556 9557 // As well, disconnected nodes are said to be in a document 9558 // fragment in IE 9 9559 elem.document && elem.document.nodeType !== 11 ) { 9560 return ret; 9561 } 9562 } catch ( e ) { 9563 nonnativeSelectorCache( expr, true ); 9564 } 9565 } 9566 9567 return find( expr, document, null, [ elem ] ).length > 0; 9568 }; 9569 9570 find.contains = function( context, elem ) { 9571 9572 // Set document vars if needed 9573 // Support: IE 11+, Edge 17 - 18+ 9574 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9575 // two documents; shallow comparisons work. 9576 // eslint-disable-next-line eqeqeq 9577 if ( ( context.ownerDocument || context ) != document ) { 9578 setDocument( context ); 9579 } 9580 return jQuery.contains( context, elem ); 9581 }; 9582 9583 9584 find.attr = function( elem, name ) { 9585 9586 // Set document vars if needed 9587 // Support: IE 11+, Edge 17 - 18+ 9588 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9589 // two documents; shallow comparisons work. 9590 // eslint-disable-next-line eqeqeq 9591 if ( ( elem.ownerDocument || elem ) != document ) { 9592 setDocument( elem ); 9593 } 9594 9595 var fn = Expr.attrHandle[ name.toLowerCase() ], 9596 9597 // Don't get fooled by Object.prototype properties (see trac-13807) 9598 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 9599 fn( elem, name, !documentIsHTML ) : 9600 undefined; 9601 9602 if ( val !== undefined ) { 9603 return val; 9604 } 9605 9606 return elem.getAttribute( name ); 9607 }; 9608 9609 find.error = function( msg ) { 9610 throw new Error( "Syntax error, unrecognized expression: " + msg ); 9611 }; 9612 9613 /** 9614 * Document sorting and removing duplicates 9615 * @param {ArrayLike} results 9616 */ 9617 jQuery.uniqueSort = function( results ) { 9618 var elem, 9619 duplicates = [], 9620 j = 0, 9621 i = 0; 9622 9623 // Unless we *know* we can detect duplicates, assume their presence 9624 // 9625 // Support: Android <=4.0+ 9626 // Testing for detecting duplicates is unpredictable so instead assume we can't 9627 // depend on duplicate detection in all browsers without a stable sort. 9628 hasDuplicate = !support.sortStable; 9629 sortInput = !support.sortStable && slice.call( results, 0 ); 9630 sort.call( results, sortOrder ); 9631 9632 if ( hasDuplicate ) { 9633 while ( ( elem = results[ i++ ] ) ) { 9634 if ( elem === results[ i ] ) { 9635 j = duplicates.push( i ); 9636 } 9637 } 9638 while ( j-- ) { 9639 splice.call( results, duplicates[ j ], 1 ); 9640 } 9641 } 9642 9643 // Clear input after sorting to release objects 9644 // See https://github.com/jquery/sizzle/pull/225 9645 sortInput = null; 9646 9647 return results; 9648 }; 9649 9650 jQuery.fn.uniqueSort = function() { 9651 return this.pushStack( jQuery.uniqueSort( slice.apply( this ) ) ); 9652 }; 9653 9654 Expr = jQuery.expr = { 9655 9656 // Can be adjusted by the user 9657 cacheLength: 50, 9658 9659 createPseudo: markFunction, 9660 9661 match: matchExpr, 9662 9663 attrHandle: {}, 9664 9665 find: {}, 9666 9667 relative: { 9668 ">": { dir: "parentNode", first: true }, 9669 " ": { dir: "parentNode" }, 9670 "+": { dir: "previousSibling", first: true }, 9671 "~": { dir: "previousSibling" } 9672 }, 9673 9674 preFilter: { 9675 ATTR: function( match ) { 9676 match[ 1 ] = match[ 1 ].replace( runescape, funescape ); 9677 9678 // Move the given value to match[3] whether quoted or unquoted 9679 match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" ) 9680 .replace( runescape, funescape ); 9681 9682 if ( match[ 2 ] === "~=" ) { 9683 match[ 3 ] = " " + match[ 3 ] + " "; 9684 } 9685 9686 return match.slice( 0, 4 ); 9687 }, 9688 9689 CHILD: function( match ) { 9690 9691 /* matches from matchExpr["CHILD"] 9692 1 type (only|nth|...) 9693 2 what (child|of-type) 9694 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 9695 4 xn-component of xn+y argument ([+-]?\d*n|) 9696 5 sign of xn-component 9697 6 x of xn-component 9698 7 sign of y-component 9699 8 y of y-component 9700 */ 9701 match[ 1 ] = match[ 1 ].toLowerCase(); 9702 9703 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { 9704 9705 // nth-* requires argument 9706 if ( !match[ 3 ] ) { 9707 find.error( match[ 0 ] ); 9708 } 9709 9710 // numeric x and y parameters for Expr.filter.CHILD 9711 // remember that false/true cast respectively to 0/1 9712 match[ 4 ] = +( match[ 4 ] ? 9713 match[ 5 ] + ( match[ 6 ] || 1 ) : 9714 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) 9715 ); 9716 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); 9717 9718 // other types prohibit arguments 9719 } else if ( match[ 3 ] ) { 9720 find.error( match[ 0 ] ); 9721 } 9722 9723 return match; 9724 }, 9725 9726 PSEUDO: function( match ) { 9727 var excess, 9728 unquoted = !match[ 6 ] && match[ 2 ]; 9729 9730 if ( matchExpr.CHILD.test( match[ 0 ] ) ) { 9731 return null; 9732 } 9733 9734 // Accept quoted arguments as-is 9735 if ( match[ 3 ] ) { 9736 match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; 9737 9738 // Strip excess characters from unquoted arguments 9739 } else if ( unquoted && rpseudo.test( unquoted ) && 9740 9741 // Get excess from tokenize (recursively) 9742 ( excess = tokenize( unquoted, true ) ) && 9743 9744 // advance to the next closing parenthesis 9745 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { 9746 9747 // excess is a negative index 9748 match[ 0 ] = match[ 0 ].slice( 0, excess ); 9749 match[ 2 ] = unquoted.slice( 0, excess ); 9750 } 9751 9752 // Return only captures needed by the pseudo filter method (type and argument) 9753 return match.slice( 0, 3 ); 9754 } 9755 }, 9756 9757 filter: { 9758 9759 TAG: function( nodeNameSelector ) { 9760 var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 9761 return nodeNameSelector === "*" ? 9762 function() { 9763 return true; 9764 } : 9765 function( elem ) { 9766 return nodeName( elem, expectedNodeName ); 9767 }; 9768 }, 9769 9770 CLASS: function( className ) { 9771 var pattern = classCache[ className + " " ]; 9772 9773 return pattern || 9774 ( pattern = new RegExp( "(^|" + whitespace + ")" + className + 9775 "(" + whitespace + "|$)" ) ) && 9776 classCache( className, function( elem ) { 9777 return pattern.test( 9778 typeof elem.className === "string" && elem.className || 9779 typeof elem.getAttribute !== "undefined" && 9780 elem.getAttribute( "class" ) || 9781 "" 9782 ); 9783 } ); 9784 }, 9785 9786 ATTR: function( name, operator, check ) { 9787 return function( elem ) { 9788 var result = find.attr( elem, name ); 9789 9790 if ( result == null ) { 9791 return operator === "!="; 9792 } 9793 if ( !operator ) { 9794 return true; 9795 } 9796 9797 result += ""; 9798 9799 if ( operator === "=" ) { 9800 return result === check; 9801 } 9802 if ( operator === "!=" ) { 9803 return result !== check; 9804 } 9805 if ( operator === "^=" ) {
vendor: 1,205 bytes, lines 9806-9844
9806 return check && result.indexOf( check ) === 0; 9807 } 9808 if ( operator === "*=" ) { 9809 return check && result.indexOf( check ) > -1; 9810 } 9811 if ( operator === "$=" ) { 9812 return check && result.slice( -check.length ) === check; 9813 } 9814 if ( operator === "~=" ) { 9815 return ( " " + result.replace( rwhitespace, " " ) + " " ) 9816 .indexOf( check ) > -1; 9817 } 9818 if ( operator === "|=" ) { 9819 return result === check || result.slice( 0, check.length + 1 ) === check + "-"; 9820 } 9821 9822 return false; 9823 }; 9824 }, 9825 9826 CHILD: function( type, what, _argument, first, last ) { 9827 var simple = type.slice( 0, 3 ) !== "nth", 9828 forward = type.slice( -4 ) !== "last", 9829 ofType = what === "of-type"; 9830 9831 return first === 1 && last === 0 ? 9832 9833 // Shortcut for :nth-*(n) 9834 function( elem ) { 9835 return !!elem.parentNode; 9836 } : 9837 9838 function( elem, _context, xml ) { 9839 var cache, outerCache, node, nodeIndex, start, 9840 dir = simple !== forward ? "nextSibling" : "previousSibling", 9841 parent = elem.parentNode, 9842 name = ofType && elem.nodeName.toLowerCase(), 9843 useCache = !xml && !ofType, 9844 diff = false;
vendor: 63,823 bytes, lines 9845-12164
9845 9846 if ( parent ) { 9847 9848 // :(first|last|only)-(child|of-type) 9849 if ( simple ) { 9850 while ( dir ) { 9851 node = elem; 9852 while ( ( node = node[ dir ] ) ) { 9853 if ( ofType ? 9854 nodeName( node, name ) : 9855 node.nodeType === 1 ) { 9856 9857 return false; 9858 } 9859 } 9860 9861 // Reverse direction for :only-* (if we haven't yet done so) 9862 start = dir = type === "only" && !start && "nextSibling"; 9863 } 9864 return true; 9865 } 9866 9867 start = [ forward ? parent.firstChild : parent.lastChild ]; 9868 9869 // non-xml :nth-child(...) stores cache data on `parent` 9870 if ( forward && useCache ) { 9871 9872 // Seek `elem` from a previously-cached index 9873 outerCache = parent[ expando ] || ( parent[ expando ] = {} ); 9874 cache = outerCache[ type ] || []; 9875 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 9876 diff = nodeIndex && cache[ 2 ]; 9877 node = nodeIndex && parent.childNodes[ nodeIndex ]; 9878 9879 while ( ( node = ++nodeIndex && node && node[ dir ] || 9880 9881 // Fallback to seeking `elem` from the start 9882 ( diff = nodeIndex = 0 ) || start.pop() ) ) { 9883 9884 // When found, cache indexes on `parent` and break 9885 if ( node.nodeType === 1 && ++diff && node === elem ) { 9886 outerCache[ type ] = [ dirruns, nodeIndex, diff ]; 9887 break; 9888 } 9889 } 9890 9891 } else { 9892 9893 // Use previously-cached element index if available 9894 if ( useCache ) { 9895 outerCache = elem[ expando ] || ( elem[ expando ] = {} ); 9896 cache = outerCache[ type ] || []; 9897 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 9898 diff = nodeIndex; 9899 } 9900 9901 // xml :nth-child(...) 9902 // or :nth-last-child(...) or :nth(-last)?-of-type(...) 9903 if ( diff === false ) { 9904 9905 // Use the same loop as above to seek `elem` from the start 9906 while ( ( node = ++nodeIndex && node && node[ dir ] || 9907 ( diff = nodeIndex = 0 ) || start.pop() ) ) { 9908 9909 if ( ( ofType ? 9910 nodeName( node, name ) : 9911 node.nodeType === 1 ) && 9912 ++diff ) { 9913 9914 // Cache the index of each encountered element 9915 if ( useCache ) { 9916 outerCache = node[ expando ] || 9917 ( node[ expando ] = {} ); 9918 outerCache[ type ] = [ dirruns, diff ]; 9919 } 9920 9921 if ( node === elem ) { 9922 break; 9923 } 9924 } 9925 } 9926 } 9927 } 9928 9929 // Incorporate the offset, then check against cycle size 9930 diff -= last; 9931 return diff === first || ( diff % first === 0 && diff / first >= 0 ); 9932 } 9933 }; 9934 }, 9935 9936 PSEUDO: function( pseudo, argument ) { 9937 9938 // pseudo-class names are case-insensitive 9939 // https://www.w3.org/TR/selectors/#pseudo-classes 9940 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 9941 // Remember that setFilters inherits from pseudos 9942 var args, 9943 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 9944 find.error( "unsupported pseudo: " + pseudo ); 9945 9946 // The user may use createPseudo to indicate that 9947 // arguments are needed to create the filter function 9948 // just as jQuery does 9949 if ( fn[ expando ] ) { 9950 return fn( argument ); 9951 } 9952 9953 // But maintain support for old signatures 9954 if ( fn.length > 1 ) { 9955 args = [ pseudo, pseudo, "", argument ]; 9956 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 9957 markFunction( function( seed, matches ) { 9958 var idx, 9959 matched = fn( seed, argument ), 9960 i = matched.length; 9961 while ( i-- ) { 9962 idx = indexOf.call( seed, matched[ i ] ); 9963 seed[ idx ] = !( matches[ idx ] = matched[ i ] ); 9964 } 9965 } ) : 9966 function( elem ) { 9967 return fn( elem, 0, args ); 9968 }; 9969 } 9970 9971 return fn; 9972 } 9973 }, 9974 9975 pseudos: { 9976 9977 // Potentially complex pseudos 9978 not: markFunction( function( selector ) { 9979 9980 // Trim the selector passed to compile 9981 // to avoid treating leading and trailing 9982 // spaces as combinators 9983 var input = [], 9984 results = [], 9985 matcher = compile( selector.replace( rtrimCSS, "$1" ) ); 9986 9987 return matcher[ expando ] ? 9988 markFunction( function( seed, matches, _context, xml ) { 9989 var elem, 9990 unmatched = matcher( seed, null, xml, [] ), 9991 i = seed.length; 9992 9993 // Match elements unmatched by `matcher` 9994 while ( i-- ) { 9995 if ( ( elem = unmatched[ i ] ) ) { 9996 seed[ i ] = !( matches[ i ] = elem ); 9997 } 9998 } 9999 } ) : 10000 function( elem, _context, xml ) { 10001 input[ 0 ] = elem; 10002 matcher( input, null, xml, results ); 10003 10004 // Don't keep the element 10005 // (see https://github.com/jquery/sizzle/issues/299) 10006 input[ 0 ] = null; 10007 return !results.pop(); 10008 }; 10009 } ), 10010 10011 has: markFunction( function( selector ) { 10012 return function( elem ) { 10013 return find( selector, elem ).length > 0; 10014 }; 10015 } ), 10016 10017 contains: markFunction( function( text ) { 10018 text = text.replace( runescape, funescape ); 10019 return function( elem ) { 10020 return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1; 10021 }; 10022 } ), 10023 10024 // "Whether an element is represented by a :lang() selector 10025 // is based solely on the element's language value 10026 // being equal to the identifier C, 10027 // or beginning with the identifier C immediately followed by "-". 10028 // The matching of C against the element's language value is performed case-insensitively. 10029 // The identifier C does not have to be a valid language name." 10030 // https://www.w3.org/TR/selectors/#lang-pseudo 10031 lang: markFunction( function( lang ) { 10032 10033 // lang value must be a valid identifier 10034 if ( !ridentifier.test( lang || "" ) ) { 10035 find.error( "unsupported lang: " + lang ); 10036 } 10037 lang = lang.replace( runescape, funescape ).toLowerCase(); 10038 return function( elem ) { 10039 var elemLang; 10040 do { 10041 if ( ( elemLang = documentIsHTML ? 10042 elem.lang : 10043 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { 10044 10045 elemLang = elemLang.toLowerCase(); 10046 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 10047 } 10048 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); 10049 return false; 10050 }; 10051 } ), 10052 10053 // Miscellaneous 10054 target: function( elem ) { 10055 var hash = window.location && window.location.hash; 10056 return hash && hash.slice( 1 ) === elem.id; 10057 }, 10058 10059 root: function( elem ) { 10060 return elem === documentElement; 10061 }, 10062 10063 focus: function( elem ) { 10064 return elem === safeActiveElement() && 10065 document.hasFocus() && 10066 !!( elem.type || elem.href || ~elem.tabIndex ); 10067 }, 10068 10069 // Boolean properties 10070 enabled: createDisabledPseudo( false ), 10071 disabled: createDisabledPseudo( true ), 10072 10073 checked: function( elem ) { 10074 10075 // In CSS3, :checked should return both checked and selected elements 10076 // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 10077 return ( nodeName( elem, "input" ) && !!elem.checked ) || 10078 ( nodeName( elem, "option" ) && !!elem.selected ); 10079 }, 10080 10081 selected: function( elem ) { 10082 10083 // Support: IE <=11+ 10084 // Accessing the selectedIndex property 10085 // forces the browser to treat the default option as 10086 // selected when in an optgroup. 10087 if ( elem.parentNode ) { 10088 // eslint-disable-next-line no-unused-expressions 10089 elem.parentNode.selectedIndex; 10090 } 10091 10092 return elem.selected === true; 10093 }, 10094 10095 // Contents 10096 empty: function( elem ) { 10097 10098 // https://www.w3.org/TR/selectors/#empty-pseudo 10099 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 10100 // but not by others (comment: 8; processing instruction: 7; etc.) 10101 // nodeType < 6 works because attributes (2) do not appear as children 10102 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 10103 if ( elem.nodeType < 6 ) { 10104 return false; 10105 } 10106 } 10107 return true; 10108 }, 10109 10110 parent: function( elem ) { 10111 return !Expr.pseudos.empty( elem ); 10112 }, 10113 10114 // Element/input types 10115 header: function( elem ) { 10116 return rheader.test( elem.nodeName ); 10117 }, 10118 10119 input: function( elem ) { 10120 return rinputs.test( elem.nodeName ); 10121 }, 10122 10123 button: function( elem ) { 10124 return nodeName( elem, "input" ) && elem.type === "button" || 10125 nodeName( elem, "button" ); 10126 }, 10127 10128 text: function( elem ) { 10129 var attr; 10130 return nodeName( elem, "input" ) && elem.type === "text" && 10131 10132 // Support: IE <10 only 10133 // New HTML5 attribute values (e.g., "search") appear 10134 // with elem.type === "text" 10135 ( ( attr = elem.getAttribute( "type" ) ) == null || 10136 attr.toLowerCase() === "text" ); 10137 }, 10138 10139 // Position-in-collection 10140 first: createPositionalPseudo( function() { 10141 return [ 0 ]; 10142 } ), 10143 10144 last: createPositionalPseudo( function( _matchIndexes, length ) { 10145 return [ length - 1 ]; 10146 } ), 10147 10148 eq: createPositionalPseudo( function( _matchIndexes, length, argument ) { 10149 return [ argument < 0 ? argument + length : argument ]; 10150 } ), 10151 10152 even: createPositionalPseudo( function( matchIndexes, length ) { 10153 var i = 0; 10154 for ( ; i < length; i += 2 ) { 10155 matchIndexes.push( i ); 10156 } 10157 return matchIndexes; 10158 } ), 10159 10160 odd: createPositionalPseudo( function( matchIndexes, length ) { 10161 var i = 1; 10162 for ( ; i < length; i += 2 ) { 10163 matchIndexes.push( i ); 10164 } 10165 return matchIndexes; 10166 } ), 10167 10168 lt: createPositionalPseudo( function( matchIndexes, length, argument ) { 10169 var i; 10170 10171 if ( argument < 0 ) { 10172 i = argument + length; 10173 } else if ( argument > length ) { 10174 i = length; 10175 } else { 10176 i = argument; 10177 } 10178 10179 for ( ; --i >= 0; ) { 10180 matchIndexes.push( i ); 10181 } 10182 return matchIndexes; 10183 } ), 10184 10185 gt: createPositionalPseudo( function( matchIndexes, length, argument ) { 10186 var i = argument < 0 ? argument + length : argument; 10187 for ( ; ++i < length; ) { 10188 matchIndexes.push( i ); 10189 } 10190 return matchIndexes; 10191 } ) 10192 } 10193 }; 10194 10195 Expr.pseudos.nth = Expr.pseudos.eq; 10196 10197// Add button/input type pseudos 10198 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 10199 Expr.pseudos[ i ] = createInputPseudo( i ); 10200 } 10201 for ( i in { submit: true, reset: true } ) { 10202 Expr.pseudos[ i ] = createButtonPseudo( i ); 10203 } 10204 10205// Easy API for creating new setFilters 10206 function setFilters() {} 10207 setFilters.prototype = Expr.filters = Expr.pseudos; 10208 Expr.setFilters = new setFilters(); 10209 10210 function tokenize( selector, parseOnly ) { 10211 var matched, match, tokens, type, 10212 soFar, groups, preFilters, 10213 cached = tokenCache[ selector + " " ]; 10214 10215 if ( cached ) { 10216 return parseOnly ? 0 : cached.slice( 0 ); 10217 } 10218 10219 soFar = selector; 10220 groups = []; 10221 preFilters = Expr.preFilter; 10222 10223 while ( soFar ) { 10224 10225 // Comma and first run 10226 if ( !matched || ( match = rcomma.exec( soFar ) ) ) { 10227 if ( match ) { 10228 10229 // Don't consume trailing commas as valid 10230 soFar = soFar.slice( match[ 0 ].length ) || soFar; 10231 } 10232 groups.push( ( tokens = [] ) ); 10233 } 10234 10235 matched = false; 10236 10237 // Combinators 10238 if ( ( match = rleadingCombinator.exec( soFar ) ) ) { 10239 matched = match.shift(); 10240 tokens.push( { 10241 value: matched, 10242 10243 // Cast descendant combinators to space 10244 type: match[ 0 ].replace( rtrimCSS, " " ) 10245 } ); 10246 soFar = soFar.slice( matched.length ); 10247 } 10248 10249 // Filters 10250 for ( type in Expr.filter ) { 10251 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || 10252 ( match = preFilters[ type ]( match ) ) ) ) { 10253 matched = match.shift(); 10254 tokens.push( { 10255 value: matched, 10256 type: type, 10257 matches: match 10258 } ); 10259 soFar = soFar.slice( matched.length ); 10260 } 10261 } 10262 10263 if ( !matched ) { 10264 break; 10265 } 10266 } 10267 10268 // Return the length of the invalid excess 10269 // if we're just parsing 10270 // Otherwise, throw an error or return tokens 10271 if ( parseOnly ) { 10272 return soFar.length; 10273 } 10274 10275 return soFar ? 10276 find.error( selector ) : 10277 10278 // Cache the tokens 10279 tokenCache( selector, groups ).slice( 0 ); 10280 } 10281 10282 function toSelector( tokens ) { 10283 var i = 0, 10284 len = tokens.length, 10285 selector = ""; 10286 for ( ; i < len; i++ ) { 10287 selector += tokens[ i ].value; 10288 } 10289 return selector; 10290 } 10291 10292 function addCombinator( matcher, combinator, base ) { 10293 var dir = combinator.dir, 10294 skip = combinator.next, 10295 key = skip || dir, 10296 checkNonElements = base && key === "parentNode", 10297 doneName = done++; 10298 10299 return combinator.first ? 10300 10301 // Check against closest ancestor/preceding element 10302 function( elem, context, xml ) { 10303 while ( ( elem = elem[ dir ] ) ) { 10304 if ( elem.nodeType === 1 || checkNonElements ) { 10305 return matcher( elem, context, xml ); 10306 } 10307 } 10308 return false; 10309 } : 10310 10311 // Check against all ancestor/preceding elements 10312 function( elem, context, xml ) { 10313 var oldCache, outerCache, 10314 newCache = [ dirruns, doneName ]; 10315 10316 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 10317 if ( xml ) { 10318 while ( ( elem = elem[ dir ] ) ) { 10319 if ( elem.nodeType === 1 || checkNonElements ) { 10320 if ( matcher( elem, context, xml ) ) { 10321 return true; 10322 } 10323 } 10324 } 10325 } else { 10326 while ( ( elem = elem[ dir ] ) ) { 10327 if ( elem.nodeType === 1 || checkNonElements ) { 10328 outerCache = elem[ expando ] || ( elem[ expando ] = {} ); 10329 10330 if ( skip && nodeName( elem, skip ) ) { 10331 elem = elem[ dir ] || elem; 10332 } else if ( ( oldCache = outerCache[ key ] ) && 10333 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 10334 10335 // Assign to newCache so results back-propagate to previous elements 10336 return ( newCache[ 2 ] = oldCache[ 2 ] ); 10337 } else { 10338 10339 // Reuse newcache so results back-propagate to previous elements 10340 outerCache[ key ] = newCache; 10341 10342 // A match means we're done; a fail means we have to keep checking 10343 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { 10344 return true; 10345 } 10346 } 10347 } 10348 } 10349 } 10350 return false; 10351 }; 10352 } 10353 10354 function elementMatcher( matchers ) { 10355 return matchers.length > 1 ? 10356 function( elem, context, xml ) { 10357 var i = matchers.length; 10358 while ( i-- ) { 10359 if ( !matchers[ i ]( elem, context, xml ) ) { 10360 return false; 10361 } 10362 } 10363 return true; 10364 } : 10365 matchers[ 0 ]; 10366 } 10367 10368 function multipleContexts( selector, contexts, results ) { 10369 var i = 0, 10370 len = contexts.length; 10371 for ( ; i < len; i++ ) { 10372 find( selector, contexts[ i ], results ); 10373 } 10374 return results; 10375 } 10376 10377 function condense( unmatched, map, filter, context, xml ) { 10378 var elem, 10379 newUnmatched = [], 10380 i = 0, 10381 len = unmatched.length, 10382 mapped = map != null; 10383 10384 for ( ; i < len; i++ ) { 10385 if ( ( elem = unmatched[ i ] ) ) { 10386 if ( !filter || filter( elem, context, xml ) ) { 10387 newUnmatched.push( elem ); 10388 if ( mapped ) { 10389 map.push( i ); 10390 } 10391 } 10392 } 10393 } 10394 10395 return newUnmatched; 10396 } 10397 10398 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 10399 if ( postFilter && !postFilter[ expando ] ) { 10400 postFilter = setMatcher( postFilter ); 10401 } 10402 if ( postFinder && !postFinder[ expando ] ) { 10403 postFinder = setMatcher( postFinder, postSelector ); 10404 } 10405 return markFunction( function( seed, results, context, xml ) { 10406 var temp, i, elem, matcherOut, 10407 preMap = [], 10408 postMap = [], 10409 preexisting = results.length, 10410 10411 // Get initial elements from seed or context 10412 elems = seed || 10413 multipleContexts( selector || "*", 10414 context.nodeType ? [ context ] : context, [] ), 10415 10416 // Prefilter to get matcher input, preserving a map for seed-results synchronization 10417 matcherIn = preFilter && ( seed || !selector ) ? 10418 condense( elems, preMap, preFilter, context, xml ) : 10419 elems; 10420 10421 if ( matcher ) { 10422 10423 // If we have a postFinder, or filtered seed, or non-seed postFilter 10424 // or preexisting results, 10425 matcherOut = postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 10426 10427 // ...intermediate processing is necessary 10428 [] : 10429 10430 // ...otherwise use results directly 10431 results; 10432 10433 // Find primary matches 10434 matcher( matcherIn, matcherOut, context, xml ); 10435 } else { 10436 matcherOut = matcherIn; 10437 } 10438 10439 // Apply postFilter 10440 if ( postFilter ) { 10441 temp = condense( matcherOut, postMap ); 10442 postFilter( temp, [], context, xml ); 10443 10444 // Un-match failing elements by moving them back to matcherIn 10445 i = temp.length; 10446 while ( i-- ) { 10447 if ( ( elem = temp[ i ] ) ) { 10448 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); 10449 } 10450 } 10451 } 10452 10453 if ( seed ) { 10454 if ( postFinder || preFilter ) { 10455 if ( postFinder ) { 10456 10457 // Get the final matcherOut by condensing this intermediate into postFinder contexts 10458 temp = []; 10459 i = matcherOut.length; 10460 while ( i-- ) { 10461 if ( ( elem = matcherOut[ i ] ) ) { 10462 10463 // Restore matcherIn since elem is not yet a final match 10464 temp.push( ( matcherIn[ i ] = elem ) ); 10465 } 10466 } 10467 postFinder( null, ( matcherOut = [] ), temp, xml ); 10468 } 10469 10470 // Move matched elements from seed to results to keep them synchronized 10471 i = matcherOut.length; 10472 while ( i-- ) { 10473 if ( ( elem = matcherOut[ i ] ) && 10474 ( temp = postFinder ? indexOf.call( seed, elem ) : preMap[ i ] ) > -1 ) { 10475 10476 seed[ temp ] = !( results[ temp ] = elem ); 10477 } 10478 } 10479 } 10480 10481 // Add elements to results, through postFinder if defined 10482 } else { 10483 matcherOut = condense( 10484 matcherOut === results ? 10485 matcherOut.splice( preexisting, matcherOut.length ) : 10486 matcherOut 10487 ); 10488 if ( postFinder ) { 10489 postFinder( null, results, matcherOut, xml ); 10490 } else { 10491 push.apply( results, matcherOut ); 10492 } 10493 } 10494 } ); 10495 } 10496 10497 function matcherFromTokens( tokens ) { 10498 var checkContext, matcher, j, 10499 len = tokens.length, 10500 leadingRelative = Expr.relative[ tokens[ 0 ].type ], 10501 implicitRelative = leadingRelative || Expr.relative[ " " ], 10502 i = leadingRelative ? 1 : 0, 10503 10504 // The foundational matcher ensures that elements are reachable from top-level context(s) 10505 matchContext = addCombinator( function( elem ) { 10506 return elem === checkContext; 10507 }, implicitRelative, true ), 10508 matchAnyContext = addCombinator( function( elem ) { 10509 return indexOf.call( checkContext, elem ) > -1; 10510 }, implicitRelative, true ), 10511 matchers = [ function( elem, context, xml ) { 10512 10513 // Support: IE 11+, Edge 17 - 18+ 10514 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 10515 // two documents; shallow comparisons work. 10516 // eslint-disable-next-line eqeqeq 10517 var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || ( 10518 ( checkContext = context ).nodeType ? 10519 matchContext( elem, context, xml ) : 10520 matchAnyContext( elem, context, xml ) ); 10521 10522 // Avoid hanging onto element 10523 // (see https://github.com/jquery/sizzle/issues/299) 10524 checkContext = null; 10525 return ret; 10526 } ]; 10527 10528 for ( ; i < len; i++ ) { 10529 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { 10530 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; 10531 } else { 10532 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); 10533 10534 // Return special upon seeing a positional matcher 10535 if ( matcher[ expando ] ) { 10536 10537 // Find the next relative operator (if any) for proper handling 10538 j = ++i; 10539 for ( ; j < len; j++ ) { 10540 if ( Expr.relative[ tokens[ j ].type ] ) { 10541 break; 10542 } 10543 } 10544 return setMatcher( 10545 i > 1 && elementMatcher( matchers ), 10546 i > 1 && toSelector( 10547 10548 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 10549 tokens.slice( 0, i - 1 ) 10550 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) 10551 ).replace( rtrimCSS, "$1" ), 10552 matcher, 10553 i < j && matcherFromTokens( tokens.slice( i, j ) ), 10554 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), 10555 j < len && toSelector( tokens ) 10556 ); 10557 } 10558 matchers.push( matcher ); 10559 } 10560 } 10561 10562 return elementMatcher( matchers ); 10563 } 10564 10565 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { 10566 var bySet = setMatchers.length > 0, 10567 byElement = elementMatchers.length > 0, 10568 superMatcher = function( seed, context, xml, results, outermost ) { 10569 var elem, j, matcher, 10570 matchedCount = 0, 10571 i = "0", 10572 unmatched = seed && [], 10573 setMatched = [], 10574 contextBackup = outermostContext, 10575 10576 // We must always have either seed elements or outermost context 10577 elems = seed || byElement && Expr.find.TAG( "*", outermost ), 10578 10579 // Use integer dirruns iff this is the outermost matcher 10580 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), 10581 len = elems.length; 10582 10583 if ( outermost ) { 10584 10585 // Support: IE 11+, Edge 17 - 18+ 10586 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 10587 // two documents; shallow comparisons work. 10588 // eslint-disable-next-line eqeqeq 10589 outermostContext = context == document || context || outermost; 10590 } 10591 10592 // Add elements passing elementMatchers directly to results 10593 // Support: iOS <=7 - 9 only 10594 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching 10595 // elements by id. (see trac-14142) 10596 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { 10597 if ( byElement && elem ) { 10598 j = 0; 10599 10600 // Support: IE 11+, Edge 17 - 18+ 10601 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 10602 // two documents; shallow comparisons work. 10603 // eslint-disable-next-line eqeqeq 10604 if ( !context && elem.ownerDocument != document ) { 10605 setDocument( elem ); 10606 xml = !documentIsHTML; 10607 } 10608 while ( ( matcher = elementMatchers[ j++ ] ) ) { 10609 if ( matcher( elem, context || document, xml ) ) { 10610 push.call( results, elem ); 10611 break; 10612 } 10613 } 10614 if ( outermost ) { 10615 dirruns = dirrunsUnique; 10616 } 10617 } 10618 10619 // Track unmatched elements for set filters 10620 if ( bySet ) { 10621 10622 // They will have gone through all possible matchers 10623 if ( ( elem = !matcher && elem ) ) { 10624 matchedCount--; 10625 } 10626 10627 // Lengthen the array for every element, matched or not 10628 if ( seed ) { 10629 unmatched.push( elem ); 10630 } 10631 } 10632 } 10633 10634 // `i` is now the count of elements visited above, and adding it to `matchedCount` 10635 // makes the latter nonnegative. 10636 matchedCount += i; 10637 10638 // Apply set filters to unmatched elements 10639 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 10640 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 10641 // no element matchers and no seed. 10642 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 10643 // case, which will result in a "00" `matchedCount` that differs from `i` but is also 10644 // numerically zero. 10645 if ( bySet && i !== matchedCount ) { 10646 j = 0; 10647 while ( ( matcher = setMatchers[ j++ ] ) ) { 10648 matcher( unmatched, setMatched, context, xml ); 10649 } 10650 10651 if ( seed ) { 10652 10653 // Reintegrate element matches to eliminate the need for sorting 10654 if ( matchedCount > 0 ) { 10655 while ( i-- ) { 10656 if ( !( unmatched[ i ] || setMatched[ i ] ) ) { 10657 setMatched[ i ] = pop.call( results ); 10658 } 10659 } 10660 } 10661 10662 // Discard index placeholder values to get only actual matches 10663 setMatched = condense( setMatched ); 10664 } 10665 10666 // Add matches to results 10667 push.apply( results, setMatched ); 10668 10669 // Seedless set matches succeeding multiple successful matchers stipulate sorting 10670 if ( outermost && !seed && setMatched.length > 0 && 10671 ( matchedCount + setMatchers.length ) > 1 ) { 10672 10673 jQuery.uniqueSort( results ); 10674 } 10675 } 10676 10677 // Override manipulation of globals by nested matchers 10678 if ( outermost ) { 10679 dirruns = dirrunsUnique; 10680 outermostContext = contextBackup; 10681 } 10682 10683 return unmatched; 10684 }; 10685 10686 return bySet ? 10687 markFunction( superMatcher ) : 10688 superMatcher; 10689 } 10690 10691 function compile( selector, match /* Internal Use Only */ ) { 10692 var i, 10693 setMatchers = [], 10694 elementMatchers = [], 10695 cached = compilerCache[ selector + " " ]; 10696 10697 if ( !cached ) { 10698 10699 // Generate a function of recursive functions that can be used to check each element 10700 if ( !match ) { 10701 match = tokenize( selector ); 10702 } 10703 i = match.length; 10704 while ( i-- ) { 10705 cached = matcherFromTokens( match[ i ] ); 10706 if ( cached[ expando ] ) { 10707 setMatchers.push( cached ); 10708 } else { 10709 elementMatchers.push( cached ); 10710 } 10711 } 10712 10713 // Cache the compiled function 10714 cached = compilerCache( selector, 10715 matcherFromGroupMatchers( elementMatchers, setMatchers ) ); 10716 10717 // Save selector and tokenization 10718 cached.selector = selector; 10719 } 10720 return cached; 10721 } 10722 10723 /** 10724 * A low-level selection function that works with jQuery's compiled 10725 * selector functions 10726 * @param {String|Function} selector A selector or a pre-compiled 10727 * selector function built with jQuery selector compile 10728 * @param {Element} context 10729 * @param {Array} [results] 10730 * @param {Array} [seed] A set of elements to match against 10731 */ 10732 function select( selector, context, results, seed ) { 10733 var i, tokens, token, type, find, 10734 compiled = typeof selector === "function" && selector, 10735 match = !seed && tokenize( ( selector = compiled.selector || selector ) ); 10736 10737 results = results || []; 10738 10739 // Try to minimize operations if there is only one selector in the list and no seed 10740 // (the latter of which guarantees us context) 10741 if ( match.length === 1 ) { 10742 10743 // Reduce context if the leading compound selector is an ID 10744 tokens = match[ 0 ] = match[ 0 ].slice( 0 ); 10745 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && 10746 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { 10747 10748 context = ( Expr.find.ID( 10749 token.matches[ 0 ].replace( runescape, funescape ), 10750 context 10751 ) || [] )[ 0 ]; 10752 if ( !context ) { 10753 return results; 10754 10755 // Precompiled matchers will still verify ancestry, so step up a level 10756 } else if ( compiled ) { 10757 context = context.parentNode; 10758 } 10759 10760 selector = selector.slice( tokens.shift().value.length ); 10761 } 10762 10763 // Fetch a seed set for right-to-left matching 10764 i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length; 10765 while ( i-- ) { 10766 token = tokens[ i ]; 10767 10768 // Abort if we hit a combinator 10769 if ( Expr.relative[ ( type = token.type ) ] ) { 10770 break; 10771 } 10772 if ( ( find = Expr.find[ type ] ) ) { 10773 10774 // Search, expanding context for leading sibling combinators 10775 if ( ( seed = find( 10776 token.matches[ 0 ].replace( runescape, funescape ), 10777 rsibling.test( tokens[ 0 ].type ) && 10778 testContext( context.parentNode ) || context 10779 ) ) ) { 10780 10781 // If seed is empty or no tokens remain, we can return early 10782 tokens.splice( i, 1 ); 10783 selector = seed.length && toSelector( tokens ); 10784 if ( !selector ) { 10785 push.apply( results, seed ); 10786 return results; 10787 } 10788 10789 break; 10790 } 10791 } 10792 } 10793 } 10794 10795 // Compile and execute a filtering function if one is not provided 10796 // Provide `match` to avoid retokenization if we modified the selector above 10797 ( compiled || compile( selector, match ) )( 10798 seed, 10799 context, 10800 !documentIsHTML, 10801 results, 10802 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 10803 ); 10804 return results; 10805 } 10806 10807// One-time assignments 10808 10809// Support: Android <=4.0 - 4.1+ 10810// Sort stability 10811 support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; 10812 10813// Initialize against the default document 10814 setDocument(); 10815 10816// Support: Android <=4.0 - 4.1+ 10817// Detached nodes confoundingly follow *each other* 10818 support.sortDetached = assert( function( el ) { 10819 10820 // Should return 1, but returns 4 (following) 10821 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; 10822 } ); 10823 10824 jQuery.find = find; 10825 10826// Deprecated 10827 jQuery.expr[ ":" ] = jQuery.expr.pseudos; 10828 jQuery.unique = jQuery.uniqueSort; 10829 10830// These have always been private, but they used to be documented as part of 10831// Sizzle so let's maintain them for now for backwards compatibility purposes. 10832 find.compile = compile; 10833 find.select = select; 10834 find.setDocument = setDocument; 10835 find.tokenize = tokenize; 10836 10837 find.escape = jQuery.escapeSelector; 10838 find.getText = jQuery.text; 10839 find.isXML = jQuery.isXMLDoc; 10840 find.selectors = jQuery.expr; 10841 find.support = jQuery.support; 10842 find.uniqueSort = jQuery.uniqueSort; 10843 10844 /* eslint-enable */ 10845 10846 } )(); 10847 10848 10849 var dir = function( elem, dir, until ) { 10850 var matched = [], 10851 truncate = until !== undefined; 10852 10853 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 10854 if ( elem.nodeType === 1 ) { 10855 if ( truncate && jQuery( elem ).is( until ) ) { 10856 break; 10857 } 10858 matched.push( elem ); 10859 } 10860 } 10861 return matched; 10862 }; 10863 10864 10865 var siblings = function( n, elem ) { 10866 var matched = []; 10867 10868 for ( ; n; n = n.nextSibling ) { 10869 if ( n.nodeType === 1 && n !== elem ) { 10870 matched.push( n ); 10871 } 10872 } 10873 10874 return matched; 10875 }; 10876 10877 10878 var rneedsContext = jQuery.expr.match.needsContext; 10879 10880 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); 10881 10882 10883 10884// Implement the identical functionality for filter and not 10885 function winnow( elements, qualifier, not ) { 10886 if ( isFunction( qualifier ) ) { 10887 return jQuery.grep( elements, function( elem, i ) { 10888 return !!qualifier.call( elem, i, elem ) !== not; 10889 } ); 10890 } 10891 10892 // Single element 10893 if ( qualifier.nodeType ) { 10894 return jQuery.grep( elements, function( elem ) { 10895 return ( elem === qualifier ) !== not; 10896 } ); 10897 } 10898 10899 // Arraylike of elements (jQuery, arguments, Array) 10900 if ( typeof qualifier !== "string" ) { 10901 return jQuery.grep( elements, function( elem ) { 10902 return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 10903 } ); 10904 } 10905 10906 // Filtered directly for both simple and complex selectors 10907 return jQuery.filter( qualifier, elements, not ); 10908 } 10909 10910 jQuery.filter = function( expr, elems, not ) { 10911 var elem = elems[ 0 ]; 10912 10913 if ( not ) { 10914 expr = ":not(" + expr + ")"; 10915 } 10916 10917 if ( elems.length === 1 && elem.nodeType === 1 ) { 10918 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; 10919 } 10920 10921 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 10922 return elem.nodeType === 1; 10923 } ) ); 10924 }; 10925 10926 jQuery.fn.extend( { 10927 find: function( selector ) { 10928 var i, ret, 10929 len = this.length, 10930 self = this; 10931 10932 if ( typeof selector !== "string" ) { 10933 return this.pushStack( jQuery( selector ).filter( function() { 10934 for ( i = 0; i < len; i++ ) { 10935 if ( jQuery.contains( self[ i ], this ) ) { 10936 return true; 10937 } 10938 } 10939 } ) ); 10940 } 10941 10942 ret = this.pushStack( [] ); 10943 10944 for ( i = 0; i < len; i++ ) { 10945 jQuery.find( selector, self[ i ], ret ); 10946 } 10947 10948 return len > 1 ? jQuery.uniqueSort( ret ) : ret; 10949 }, 10950 filter: function( selector ) { 10951 return this.pushStack( winnow( this, selector || [], false ) ); 10952 }, 10953 not: function( selector ) { 10954 return this.pushStack( winnow( this, selector || [], true ) ); 10955 }, 10956 is: function( selector ) { 10957 return !!winnow( 10958 this, 10959 10960 // If this is a positional/relative selector, check membership in the returned set 10961 // so $("p:first").is("p:last") won't return true for a doc with two "p". 10962 typeof selector === "string" && rneedsContext.test( selector ) ? 10963 jQuery( selector ) : 10964 selector || [], 10965 false 10966 ).length; 10967 } 10968 } ); 10969 10970 10971// Initialize a jQuery object 10972 10973 10974// A central reference to the root jQuery(document) 10975 var rootjQuery, 10976 10977 // A simple way to check for HTML strings 10978 // Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521) 10979 // Strict HTML recognition (trac-11290: must start with <) 10980 // Shortcut simple #id case for speed 10981 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, 10982 10983 init = jQuery.fn.init = function( selector, context, root ) { 10984 var match, elem; 10985 10986 // HANDLE: $(""), $(null), $(undefined), $(false) 10987 if ( !selector ) { 10988 return this; 10989 } 10990 10991 // Method init() accepts an alternate rootjQuery 10992 // so migrate can support jQuery.sub (gh-2101) 10993 root = root || rootjQuery; 10994 10995 // Handle HTML strings 10996 if ( typeof selector === "string" ) { 10997 if ( selector[ 0 ] === "<" && 10998 selector[ selector.length - 1 ] === ">" && 10999 selector.length >= 3 ) { 11000 11001 // Assume that strings that start and end with <> are HTML and skip the regex check 11002 match = [ null, selector, null ]; 11003 11004 } else { 11005 match = rquickExpr.exec( selector ); 11006 } 11007 11008 // Match html or make sure no context is specified for #id 11009 if ( match && ( match[ 1 ] || !context ) ) { 11010 11011 // HANDLE: $(html) -> $(array) 11012 if ( match[ 1 ] ) { 11013 context = context instanceof jQuery ? context[ 0 ] : context; 11014 11015 // Option to run scripts is true for back-compat 11016 // Intentionally let the error be thrown if parseHTML is not present 11017 jQuery.merge( this, jQuery.parseHTML( 11018 match[ 1 ], 11019 context && context.nodeType ? context.ownerDocument || context : document, 11020 true 11021 ) ); 11022 11023 // HANDLE: $(html, props) 11024 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 11025 for ( match in context ) { 11026 11027 // Properties of context are called as methods if possible 11028 if ( isFunction( this[ match ] ) ) { 11029 this[ match ]( context[ match ] ); 11030 11031 // ...and otherwise set as attributes 11032 } else { 11033 this.attr( match, context[ match ] ); 11034 } 11035 } 11036 } 11037 11038 return this; 11039 11040 // HANDLE: $(#id) 11041 } else { 11042 elem = document.getElementById( match[ 2 ] ); 11043 11044 if ( elem ) { 11045 11046 // Inject the element directly into the jQuery object 11047 this[ 0 ] = elem; 11048 this.length = 1; 11049 } 11050 return this; 11051 } 11052 11053 // HANDLE: $(expr, $(...)) 11054 } else if ( !context || context.jquery ) { 11055 return ( context || root ).find( selector ); 11056 11057 // HANDLE: $(expr, context) 11058 // (which is just equivalent to: $(context).find(expr) 11059 } else { 11060 return this.constructor( context ).find( selector ); 11061 } 11062 11063 // HANDLE: $(DOMElement) 11064 } else if ( selector.nodeType ) { 11065 this[ 0 ] = selector; 11066 this.length = 1; 11067 return this; 11068 11069 // HANDLE: $(function) 11070 // Shortcut for document ready 11071 } else if ( isFunction( selector ) ) { 11072 return root.ready !== undefined ? 11073 root.ready( selector ) : 11074 11075 // Execute immediately if ready is not present 11076 selector( jQuery ); 11077 } 11078 11079 return jQuery.makeArray( selector, this ); 11080 }; 11081 11082// Give the init function the jQuery prototype for later instantiation 11083 init.prototype = jQuery.fn; 11084 11085// Initialize central reference 11086 rootjQuery = jQuery( document ); 11087 11088 11089 var rparentsprev = /^(?:parents|prev(?:Until|All))/, 11090 11091 // Methods guaranteed to produce a unique set when starting from a unique set 11092 guaranteedUnique = { 11093 children: true, 11094 contents: true, 11095 next: true, 11096 prev: true 11097 }; 11098 11099 jQuery.fn.extend( { 11100 has: function( target ) { 11101 var targets = jQuery( target, this ), 11102 l = targets.length; 11103 11104 return this.filter( function() { 11105 var i = 0; 11106 for ( ; i < l; i++ ) { 11107 if ( jQuery.contains( this, targets[ i ] ) ) { 11108 return true; 11109 } 11110 } 11111 } ); 11112 }, 11113 11114 closest: function( selectors, context ) { 11115 var cur, 11116 i = 0, 11117 l = this.length, 11118 matched = [], 11119 targets = typeof selectors !== "string" && jQuery( selectors ); 11120 11121 // Positional selectors never match, since there's no _selection_ context 11122 if ( !rneedsContext.test( selectors ) ) { 11123 for ( ; i < l; i++ ) { 11124 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 11125 11126 // Always skip document fragments 11127 if ( cur.nodeType < 11 && ( targets ? 11128 targets.index( cur ) > -1 : 11129 11130 // Don't pass non-elements to jQuery#find 11131 cur.nodeType === 1 && 11132 jQuery.find.matchesSelector( cur, selectors ) ) ) { 11133 11134 matched.push( cur ); 11135 break; 11136 } 11137 } 11138 } 11139 } 11140 11141 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 11142 }, 11143 11144 // Determine the position of an element within the set 11145 index: function( elem ) { 11146 11147 // No argument, return index in parent 11148 if ( !elem ) { 11149 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 11150 } 11151 11152 // Index in selector 11153 if ( typeof elem === "string" ) { 11154 return indexOf.call( jQuery( elem ), this[ 0 ] ); 11155 } 11156 11157 // Locate the position of the desired element 11158 return indexOf.call( this, 11159 11160 // If it receives a jQuery object, the first element is used 11161 elem.jquery ? elem[ 0 ] : elem 11162 ); 11163 }, 11164 11165 add: function( selector, context ) { 11166 return this.pushStack( 11167 jQuery.uniqueSort( 11168 jQuery.merge( this.get(), jQuery( selector, context ) ) 11169 ) 11170 ); 11171 }, 11172 11173 addBack: function( selector ) { 11174 return this.add( selector == null ? 11175 this.prevObject : this.prevObject.filter( selector ) 11176 ); 11177 } 11178 } ); 11179 11180 function sibling( cur, dir ) { 11181 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 11182 return cur; 11183 } 11184 11185 jQuery.each( { 11186 parent: function( elem ) { 11187 var parent = elem.parentNode; 11188 return parent && parent.nodeType !== 11 ? parent : null; 11189 }, 11190 parents: function( elem ) { 11191 return dir( elem, "parentNode" ); 11192 }, 11193 parentsUntil: function( elem, _i, until ) { 11194 return dir( elem, "parentNode", until ); 11195 }, 11196 next: function( elem ) { 11197 return sibling( elem, "nextSibling" ); 11198 }, 11199 prev: function( elem ) { 11200 return sibling( elem, "previousSibling" ); 11201 }, 11202 nextAll: function( elem ) { 11203 return dir( elem, "nextSibling" ); 11204 }, 11205 prevAll: function( elem ) { 11206 return dir( elem, "previousSibling" ); 11207 }, 11208 nextUntil: function( elem, _i, until ) { 11209 return dir( elem, "nextSibling", until ); 11210 }, 11211 prevUntil: function( elem, _i, until ) { 11212 return dir( elem, "previousSibling", until ); 11213 }, 11214 siblings: function( elem ) { 11215 return siblings( ( elem.parentNode || {} ).firstChild, elem ); 11216 }, 11217 children: function( elem ) { 11218 return siblings( elem.firstChild ); 11219 }, 11220 contents: function( elem ) { 11221 if ( elem.contentDocument != null && 11222 11223 // Support: IE 11+ 11224 // <object> elements with no `data` attribute has an object 11225 // `contentDocument` with a `null` prototype. 11226 getProto( elem.contentDocument ) ) { 11227 11228 return elem.contentDocument; 11229 } 11230 11231 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only 11232 // Treat the template element as a regular one in browsers that 11233 // don't support it. 11234 if ( nodeName( elem, "template" ) ) { 11235 elem = elem.content || elem; 11236 } 11237 11238 return jQuery.merge( [], elem.childNodes ); 11239 } 11240 }, function( name, fn ) { 11241 jQuery.fn[ name ] = function( until, selector ) { 11242 var matched = jQuery.map( this, fn, until ); 11243 11244 if ( name.slice( -5 ) !== "Until" ) { 11245 selector = until; 11246 } 11247 11248 if ( selector && typeof selector === "string" ) { 11249 matched = jQuery.filter( selector, matched ); 11250 } 11251 11252 if ( this.length > 1 ) { 11253 11254 // Remove duplicates 11255 if ( !guaranteedUnique[ name ] ) { 11256 jQuery.uniqueSort( matched ); 11257 } 11258 11259 // Reverse order for parents* and prev-derivatives 11260 if ( rparentsprev.test( name ) ) { 11261 matched.reverse(); 11262 } 11263 } 11264 11265 return this.pushStack( matched ); 11266 }; 11267 } ); 11268 var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); 11269 11270 11271 11272// Convert String-formatted options into Object-formatted ones 11273 function createOptions( options ) { 11274 var object = {}; 11275 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { 11276 object[ flag ] = true; 11277 } ); 11278 return object; 11279 } 11280 11281 /* 11282 * Create a callback list using the following parameters: 11283 * 11284 * options: an optional list of space-separated options that will change how 11285 * the callback list behaves or a more traditional option object 11286 * 11287 * By default a callback list will act like an event callback list and can be 11288 * "fired" multiple times. 11289 * 11290 * Possible options: 11291 * 11292 * once: will ensure the callback list can only be fired once (like a Deferred) 11293 * 11294 * memory: will keep track of previous values and will call any callback added 11295 * after the list has been fired right away with the latest "memorized" 11296 * values (like a Deferred) 11297 * 11298 * unique: will ensure a callback can only be added once (no duplicate in the list) 11299 * 11300 * stopOnFalse: interrupt callings when a callback returns false 11301 * 11302 */ 11303 jQuery.Callbacks = function( options ) { 11304 11305 // Convert options from String-formatted to Object-formatted if needed 11306 // (we check in cache first) 11307 options = typeof options === "string" ? 11308 createOptions( options ) : 11309 jQuery.extend( {}, options ); 11310 11311 var // Flag to know if list is currently firing 11312 firing, 11313 11314 // Last fire value for non-forgettable lists 11315 memory, 11316 11317 // Flag to know if list was already fired 11318 fired, 11319 11320 // Flag to prevent firing 11321 locked, 11322 11323 // Actual callback list 11324 list = [], 11325 11326 // Queue of execution data for repeatable lists 11327 queue = [], 11328 11329 // Index of currently firing callback (modified by add/remove as needed) 11330 firingIndex = -1, 11331 11332 // Fire callbacks 11333 fire = function() { 11334 11335 // Enforce single-firing 11336 locked = locked || options.once; 11337 11338 // Execute callbacks for all pending executions, 11339 // respecting firingIndex overrides and runtime changes 11340 fired = firing = true; 11341 for ( ; queue.length; firingIndex = -1 ) { 11342 memory = queue.shift(); 11343 while ( ++firingIndex < list.length ) { 11344 11345 // Run callback and check for early termination 11346 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 11347 options.stopOnFalse ) { 11348 11349 // Jump to end and forget the data so .add doesn't re-fire 11350 firingIndex = list.length; 11351 memory = false; 11352 } 11353 } 11354 } 11355 11356 // Forget the data if we're done with it 11357 if ( !options.memory ) { 11358 memory = false; 11359 } 11360 11361 firing = false; 11362 11363 // Clean up if we're done firing for good 11364 if ( locked ) { 11365 11366 // Keep an empty list if we have data for future add calls 11367 if ( memory ) { 11368 list = []; 11369 11370 // Otherwise, this object is spent 11371 } else { 11372 list = ""; 11373 } 11374 } 11375 }, 11376 11377 // Actual Callbacks object 11378 self = { 11379 11380 // Add a callback or a collection of callbacks to the list 11381 add: function() { 11382 if ( list ) { 11383 11384 // If we have memory from a past run, we should fire after adding 11385 if ( memory && !firing ) { 11386 firingIndex = list.length - 1; 11387 queue.push( memory ); 11388 } 11389 11390 ( function add( args ) { 11391 jQuery.each( args, function( _, arg ) { 11392 if ( isFunction( arg ) ) { 11393 if ( !options.unique || !self.has( arg ) ) { 11394 list.push( arg ); 11395 } 11396 } else if ( arg && arg.length && toType( arg ) !== "string" ) { 11397 11398 // Inspect recursively 11399 add( arg ); 11400 } 11401 } ); 11402 } )( arguments ); 11403 11404 if ( memory && !firing ) { 11405 fire(); 11406 } 11407 } 11408 return this; 11409 }, 11410 11411 // Remove a callback from the list 11412 remove: function() { 11413 jQuery.each( arguments, function( _, arg ) { 11414 var index; 11415 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 11416 list.splice( index, 1 ); 11417 11418 // Handle firing indexes 11419 if ( index <= firingIndex ) { 11420 firingIndex--; 11421 } 11422 } 11423 } ); 11424 return this; 11425 }, 11426 11427 // Check if a given callback is in the list. 11428 // If no argument is given, return whether or not list has callbacks attached. 11429 has: function( fn ) { 11430 return fn ? 11431 jQuery.inArray( fn, list ) > -1 : 11432 list.length > 0; 11433 }, 11434 11435 // Remove all callbacks from the list 11436 empty: function() { 11437 if ( list ) { 11438 list = []; 11439 } 11440 return this; 11441 }, 11442 11443 // Disable .fire and .add 11444 // Abort any current/pending executions 11445 // Clear all callbacks and values 11446 disable: function() { 11447 locked = queue = []; 11448 list = memory = ""; 11449 return this; 11450 }, 11451 disabled: function() { 11452 return !list; 11453 }, 11454 11455 // Disable .fire 11456 // Also disable .add unless we have memory (since it would have no effect) 11457 // Abort any pending executions 11458 lock: function() { 11459 locked = queue = []; 11460 if ( !memory && !firing ) { 11461 list = memory = ""; 11462 } 11463 return this; 11464 }, 11465 locked: function() { 11466 return !!locked; 11467 }, 11468 11469 // Call all callbacks with the given context and arguments 11470 fireWith: function( context, args ) { 11471 if ( !locked ) { 11472 args = args || []; 11473 args = [ context, args.slice ? args.slice() : args ]; 11474 queue.push( args ); 11475 if ( !firing ) { 11476 fire(); 11477 } 11478 } 11479 return this; 11480 }, 11481 11482 // Call all the callbacks with the given arguments 11483 fire: function() { 11484 self.fireWith( this, arguments ); 11485 return this; 11486 }, 11487 11488 // To know if the callbacks have already been called at least once 11489 fired: function() { 11490 return !!fired; 11491 } 11492 }; 11493 11494 return self; 11495 }; 11496 11497 11498 function Identity( v ) { 11499 return v; 11500 } 11501 function Thrower( ex ) { 11502 throw ex; 11503 } 11504 11505 function adoptValue( value, resolve, reject, noValue ) { 11506 var method; 11507 11508 try { 11509 11510 // Check for promise aspect first to privilege synchronous behavior 11511 if ( value && isFunction( ( method = value.promise ) ) ) { 11512 method.call( value ).done( resolve ).fail( reject ); 11513 11514 // Other thenables 11515 } else if ( value && isFunction( ( method = value.then ) ) ) { 11516 method.call( value, resolve, reject ); 11517 11518 // Other non-thenables 11519 } else { 11520 11521 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: 11522 // * false: [ value ].slice( 0 ) => resolve( value ) 11523 // * true: [ value ].slice( 1 ) => resolve() 11524 resolve.apply( undefined, [ value ].slice( noValue ) ); 11525 } 11526 11527 // For Promises/A+, convert exceptions into rejections 11528 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in 11529 // Deferred#then to conditionally suppress rejection. 11530 } catch ( value ) { 11531 11532 // Support: Android 4.0 only 11533 // Strict mode functions invoked without .call/.apply get global-object context 11534 reject.apply( undefined, [ value ] ); 11535 } 11536 } 11537 11538 jQuery.extend( { 11539 11540 Deferred: function( func ) { 11541 var tuples = [ 11542 11543 // action, add listener, callbacks, 11544 // ... .then handlers, argument index, [final state] 11545 [ "notify", "progress", jQuery.Callbacks( "memory" ), 11546 jQuery.Callbacks( "memory" ), 2 ], 11547 [ "resolve", "done", jQuery.Callbacks( "once memory" ), 11548 jQuery.Callbacks( "once memory" ), 0, "resolved" ], 11549 [ "reject", "fail", jQuery.Callbacks( "once memory" ), 11550 jQuery.Callbacks( "once memory" ), 1, "rejected" ] 11551 ], 11552 state = "pending", 11553 promise = { 11554 state: function() { 11555 return state; 11556 }, 11557 always: function() { 11558 deferred.done( arguments ).fail( arguments ); 11559 return this; 11560 }, 11561 "catch": function( fn ) { 11562 return promise.then( null, fn ); 11563 }, 11564 11565 // Keep pipe for back-compat 11566 pipe: function( /* fnDone, fnFail, fnProgress */ ) { 11567 var fns = arguments; 11568 11569 return jQuery.Deferred( function( newDefer ) { 11570 jQuery.each( tuples, function( _i, tuple ) { 11571 11572 // Map tuples (progress, done, fail) to arguments (done, fail, progress) 11573 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; 11574 11575 // deferred.progress(function() { bind to newDefer or newDefer.notify }) 11576 // deferred.done(function() { bind to newDefer or newDefer.resolve }) 11577 // deferred.fail(function() { bind to newDefer or newDefer.reject }) 11578 deferred[ tuple[ 1 ] ]( function() { 11579 var returned = fn && fn.apply( this, arguments ); 11580 if ( returned && isFunction( returned.promise ) ) { 11581 returned.promise() 11582 .progress( newDefer.notify ) 11583 .done( newDefer.resolve ) 11584 .fail( newDefer.reject ); 11585 } else { 11586 newDefer[ tuple[ 0 ] + "With" ]( 11587 this, 11588 fn ? [ returned ] : arguments 11589 ); 11590 } 11591 } ); 11592 } ); 11593 fns = null; 11594 } ).promise(); 11595 }, 11596 then: function( onFulfilled, onRejected, onProgress ) { 11597 var maxDepth = 0; 11598 function resolve( depth, deferred, handler, special ) { 11599 return function() { 11600 var that = this, 11601 args = arguments, 11602 mightThrow = function() { 11603 var returned, then; 11604 11605 // Support: Promises/A+ section 2.3.3.3.3 11606 // https://promisesaplus.com/#point-59 11607 // Ignore double-resolution attempts 11608 if ( depth < maxDepth ) { 11609 return; 11610 } 11611 11612 returned = handler.apply( that, args ); 11613 11614 // Support: Promises/A+ section 2.3.1 11615 // https://promisesaplus.com/#point-48 11616 if ( returned === deferred.promise() ) { 11617 throw new TypeError( "Thenable self-resolution" ); 11618 } 11619 11620 // Support: Promises/A+ sections 2.3.3.1, 3.5 11621 // https://promisesaplus.com/#point-54 11622 // https://promisesaplus.com/#point-75 11623 // Retrieve `then` only once 11624 then = returned && 11625 11626 // Support: Promises/A+ section 2.3.4 11627 // https://promisesaplus.com/#point-64 11628 // Only check objects and functions for thenability 11629 ( typeof returned === "object" || 11630 typeof returned === "function" ) && 11631 returned.then; 11632 11633 // Handle a returned thenable 11634 if ( isFunction( then ) ) { 11635 11636 // Special processors (notify) just wait for resolution 11637 if ( special ) { 11638 then.call( 11639 returned, 11640 resolve( maxDepth, deferred, Identity, special ), 11641 resolve( maxDepth, deferred, Thrower, special ) 11642 ); 11643 11644 // Normal processors (resolve) also hook into progress 11645 } else { 11646 11647 // ...and disregard older resolution values 11648 maxDepth++; 11649 11650 then.call( 11651 returned, 11652 resolve( maxDepth, deferred, Identity, special ), 11653 resolve( maxDepth, deferred, Thrower, special ), 11654 resolve( maxDepth, deferred, Identity, 11655 deferred.notifyWith ) 11656 ); 11657 } 11658 11659 // Handle all other returned values 11660 } else { 11661 11662 // Only substitute handlers pass on context 11663 // and multiple values (non-spec behavior) 11664 if ( handler !== Identity ) { 11665 that = undefined; 11666 args = [ returned ]; 11667 } 11668 11669 // Process the value(s) 11670 // Default process is resolve 11671 ( special || deferred.resolveWith )( that, args ); 11672 } 11673 }, 11674 11675 // Only normal processors (resolve) catch and reject exceptions 11676 process = special ? 11677 mightThrow : 11678 function() { 11679 try { 11680 mightThrow(); 11681 } catch ( e ) { 11682 11683 if ( jQuery.Deferred.exceptionHook ) { 11684 jQuery.Deferred.exceptionHook( e, 11685 process.error ); 11686 } 11687 11688 // Support: Promises/A+ section 2.3.3.3.4.1 11689 // https://promisesaplus.com/#point-61 11690 // Ignore post-resolution exceptions 11691 if ( depth + 1 >= maxDepth ) { 11692 11693 // Only substitute handlers pass on context 11694 // and multiple values (non-spec behavior) 11695 if ( handler !== Thrower ) { 11696 that = undefined; 11697 args = [ e ]; 11698 } 11699 11700 deferred.rejectWith( that, args ); 11701 } 11702 } 11703 }; 11704 11705 // Support: Promises/A+ section 2.3.3.3.1 11706 // https://promisesaplus.com/#point-57 11707 // Re-resolve promises immediately to dodge false rejection from 11708 // subsequent errors 11709 if ( depth ) { 11710 process(); 11711 } else { 11712 11713 // Call an optional hook to record the error, in case of exception 11714 // since it's otherwise lost when execution goes async 11715 if ( jQuery.Deferred.getErrorHook ) { 11716 process.error = jQuery.Deferred.getErrorHook(); 11717 11718 // The deprecated alias of the above. While the name suggests 11719 // returning the stack, not an error instance, jQuery just passes 11720 // it directly to `console.warn` so both will work; an instance 11721 // just better cooperates with source maps. 11722 } else if ( jQuery.Deferred.getStackHook ) { 11723 process.error = jQuery.Deferred.getStackHook(); 11724 } 11725 window.setTimeout( process ); 11726 } 11727 }; 11728 } 11729 11730 return jQuery.Deferred( function( newDefer ) { 11731 11732 // progress_handlers.add( ... ) 11733 tuples[ 0 ][ 3 ].add( 11734 resolve( 11735 0, 11736 newDefer, 11737 isFunction( onProgress ) ? 11738 onProgress : 11739 Identity, 11740 newDefer.notifyWith 11741 ) 11742 ); 11743 11744 // fulfilled_handlers.add( ... ) 11745 tuples[ 1 ][ 3 ].add( 11746 resolve( 11747 0, 11748 newDefer, 11749 isFunction( onFulfilled ) ? 11750 onFulfilled : 11751 Identity 11752 ) 11753 ); 11754 11755 // rejected_handlers.add( ... ) 11756 tuples[ 2 ][ 3 ].add( 11757 resolve( 11758 0, 11759 newDefer, 11760 isFunction( onRejected ) ? 11761 onRejected : 11762 Thrower 11763 ) 11764 ); 11765 } ).promise(); 11766 }, 11767 11768 // Get a promise for this deferred 11769 // If obj is provided, the promise aspect is added to the object 11770 promise: function( obj ) { 11771 return obj != null ? jQuery.extend( obj, promise ) : promise; 11772 } 11773 }, 11774 deferred = {}; 11775 11776 // Add list-specific methods 11777 jQuery.each( tuples, function( i, tuple ) { 11778 var list = tuple[ 2 ], 11779 stateString = tuple[ 5 ]; 11780 11781 // promise.progress = list.add 11782 // promise.done = list.add 11783 // promise.fail = list.add 11784 promise[ tuple[ 1 ] ] = list.add; 11785 11786 // Handle state 11787 if ( stateString ) { 11788 list.add( 11789 function() { 11790 11791 // state = "resolved" (i.e., fulfilled) 11792 // state = "rejected" 11793 state = stateString; 11794 }, 11795 11796 // rejected_callbacks.disable 11797 // fulfilled_callbacks.disable 11798 tuples[ 3 - i ][ 2 ].disable, 11799 11800 // rejected_handlers.disable 11801 // fulfilled_handlers.disable 11802 tuples[ 3 - i ][ 3 ].disable, 11803 11804 // progress_callbacks.lock 11805 tuples[ 0 ][ 2 ].lock, 11806 11807 // progress_handlers.lock 11808 tuples[ 0 ][ 3 ].lock 11809 ); 11810 } 11811 11812 // progress_handlers.fire 11813 // fulfilled_handlers.fire 11814 // rejected_handlers.fire 11815 list.add( tuple[ 3 ].fire ); 11816 11817 // deferred.notify = function() { deferred.notifyWith(...) } 11818 // deferred.resolve = function() { deferred.resolveWith(...) } 11819 // deferred.reject = function() { deferred.rejectWith(...) } 11820 deferred[ tuple[ 0 ] ] = function() { 11821 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); 11822 return this; 11823 }; 11824 11825 // deferred.notifyWith = list.fireWith 11826 // deferred.resolveWith = list.fireWith 11827 // deferred.rejectWith = list.fireWith 11828 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 11829 } ); 11830 11831 // Make the deferred a promise 11832 promise.promise( deferred ); 11833 11834 // Call given func if any 11835 if ( func ) { 11836 func.call( deferred, deferred ); 11837 } 11838 11839 // All done! 11840 return deferred; 11841 }, 11842 11843 // Deferred helper 11844 when: function( singleValue ) { 11845 var 11846 11847 // count of uncompleted subordinates 11848 remaining = arguments.length, 11849 11850 // count of unprocessed arguments 11851 i = remaining, 11852 11853 // subordinate fulfillment data 11854 resolveContexts = Array( i ), 11855 resolveValues = slice.call( arguments ), 11856 11857 // the primary Deferred 11858 primary = jQuery.Deferred(), 11859 11860 // subordinate callback factory 11861 updateFunc = function( i ) { 11862 return function( value ) { 11863 resolveContexts[ i ] = this; 11864 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 11865 if ( !( --remaining ) ) { 11866 primary.resolveWith( resolveContexts, resolveValues ); 11867 } 11868 }; 11869 }; 11870 11871 // Single- and empty arguments are adopted like Promise.resolve 11872 if ( remaining <= 1 ) { 11873 adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject, 11874 !remaining ); 11875 11876 // Use .then() to unwrap secondary thenables (cf. gh-3000) 11877 if ( primary.state() === "pending" || 11878 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { 11879 11880 return primary.then(); 11881 } 11882 } 11883 11884 // Multiple arguments are aggregated like Promise.all array elements 11885 while ( i-- ) { 11886 adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject ); 11887 } 11888 11889 return primary.promise(); 11890 } 11891 } ); 11892 11893 11894// These usually indicate a programmer mistake during development, 11895// warn about them ASAP rather than swallowing them by default. 11896 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; 11897 11898// If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error 11899// captured before the async barrier to get the original error cause 11900// which may otherwise be hidden. 11901 jQuery.Deferred.exceptionHook = function( error, asyncError ) { 11902 11903 // Support: IE 8 - 9 only 11904 // Console exists when dev tools are open, which can happen at any time 11905 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { 11906 window.console.warn( "jQuery.Deferred exception: " + error.message, 11907 error.stack, asyncError ); 11908 } 11909 }; 11910 11911 11912 11913 11914 jQuery.readyException = function( error ) { 11915 window.setTimeout( function() { 11916 throw error; 11917 } ); 11918 }; 11919 11920 11921 11922 11923// The deferred used on DOM ready 11924 var readyList = jQuery.Deferred(); 11925 11926 jQuery.fn.ready = function( fn ) { 11927 11928 readyList 11929 .then( fn ) 11930 11931 // Wrap jQuery.readyException in a function so that the lookup 11932 // happens at the time of error handling instead of callback 11933 // registration. 11934 .catch( function( error ) { 11935 jQuery.readyException( error ); 11936 } ); 11937 11938 return this; 11939 }; 11940 11941 jQuery.extend( { 11942 11943 // Is the DOM ready to be used? Set to true once it occurs. 11944 isReady: false, 11945 11946 // A counter to track how many items to wait for before 11947 // the ready event fires. See trac-6781 11948 readyWait: 1, 11949 11950 // Handle when the DOM is ready 11951 ready: function( wait ) { 11952 11953 // Abort if there are pending holds or we're already ready 11954 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 11955 return; 11956 } 11957 11958 // Remember that the DOM is ready 11959 jQuery.isReady = true; 11960 11961 // If a normal DOM Ready event fired, decrement, and wait if need be 11962 if ( wait !== true && --jQuery.readyWait > 0 ) { 11963 return; 11964 } 11965 11966 // If there are functions bound, to execute 11967 readyList.resolveWith( document, [ jQuery ] ); 11968 } 11969 } ); 11970 11971 jQuery.ready.then = readyList.then; 11972 11973// The ready event handler and self cleanup method 11974 function completed() { 11975 document.removeEventListener( "DOMContentLoaded", completed ); 11976 window.removeEventListener( "load", completed ); 11977 jQuery.ready(); 11978 } 11979 11980// Catch cases where $(document).ready() is called 11981// after the browser event has already occurred. 11982// Support: IE <=9 - 10 only 11983// Older IE sometimes signals "interactive" too soon 11984 if ( document.readyState === "complete" || 11985 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 11986 11987 // Handle it asynchronously to allow scripts the opportunity to delay ready 11988 window.setTimeout( jQuery.ready ); 11989 11990 } else { 11991 11992 // Use the handy event callback 11993 document.addEventListener( "DOMContentLoaded", completed ); 11994 11995 // A fallback to window.onload, that will always work 11996 window.addEventListener( "load", completed ); 11997 } 11998 11999 12000 12001 12002// Multifunctional method to get and set values of a collection 12003// The value/s can optionally be executed if it's a function 12004 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 12005 var i = 0, 12006 len = elems.length, 12007 bulk = key == null; 12008 12009 // Sets many values 12010 if ( toType( key ) === "object" ) { 12011 chainable = true; 12012 for ( i in key ) { 12013 access( elems, fn, i, key[ i ], true, emptyGet, raw ); 12014 } 12015 12016 // Sets one value 12017 } else if ( value !== undefined ) { 12018 chainable = true; 12019 12020 if ( !isFunction( value ) ) { 12021 raw = true; 12022 } 12023 12024 if ( bulk ) { 12025 12026 // Bulk operations run against the entire set 12027 if ( raw ) { 12028 fn.call( elems, value ); 12029 fn = null; 12030 12031 // ...except when executing function values 12032 } else { 12033 bulk = fn; 12034 fn = function( elem, _key, value ) { 12035 return bulk.call( jQuery( elem ), value ); 12036 }; 12037 } 12038 } 12039 12040 if ( fn ) { 12041 for ( ; i < len; i++ ) { 12042 fn( 12043 elems[ i ], key, raw ? 12044 value : 12045 value.call( elems[ i ], i, fn( elems[ i ], key ) ) 12046 ); 12047 } 12048 } 12049 } 12050 12051 if ( chainable ) { 12052 return elems; 12053 } 12054 12055 // Gets 12056 if ( bulk ) { 12057 return fn.call( elems ); 12058 } 12059 12060 return len ? fn( elems[ 0 ], key ) : emptyGet; 12061 }; 12062 12063 12064// Matches dashed string for camelizing 12065 var rmsPrefix = /^-ms-/, 12066 rdashAlpha = /-([a-z])/g; 12067 12068// Used by camelCase as callback to replace() 12069 function fcamelCase( _all, letter ) { 12070 return letter.toUpperCase(); 12071 } 12072 12073// Convert dashed to camelCase; used by the css and data modules 12074// Support: IE <=9 - 11, Edge 12 - 15 12075// Microsoft forgot to hump their vendor prefix (trac-9572) 12076 function camelCase( string ) { 12077 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 12078 } 12079 var acceptData = function( owner ) { 12080 12081 // Accepts only: 12082 // - Node 12083 // - Node.ELEMENT_NODE 12084 // - Node.DOCUMENT_NODE 12085 // - Object 12086 // - Any 12087 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 12088 }; 12089 12090 12091 12092 12093 function Data() { 12094 this.expando = jQuery.expando + Data.uid++; 12095 } 12096 12097 Data.uid = 1; 12098 12099 Data.prototype = { 12100 12101 cache: function( owner ) { 12102 12103 // Check if the owner object already has a cache 12104 var value = owner[ this.expando ]; 12105 12106 // If not, create one 12107 if ( !value ) { 12108 value = {}; 12109 12110 // We can accept data for non-element nodes in modern browsers, 12111 // but we should not, see trac-8335. 12112 // Always return an empty object. 12113 if ( acceptData( owner ) ) { 12114 12115 // If it is a node unlikely to be stringify-ed or looped over 12116 // use plain assignment 12117 if ( owner.nodeType ) { 12118 owner[ this.expando ] = value; 12119 12120 // Otherwise secure it in a non-enumerable property 12121 // configurable must be true to allow the property to be 12122 // deleted when data is removed 12123 } else { 12124 Object.defineProperty( owner, this.expando, { 12125 value: value, 12126 configurable: true 12127 } ); 12128 } 12129 } 12130 } 12131 12132 return value; 12133 }, 12134 set: function( owner, data, value ) { 12135 var prop, 12136 cache = this.cache( owner ); 12137 12138 // Handle: [ owner, key, value ] args 12139 // Always use camelCase key (gh-2257) 12140 if ( typeof data === "string" ) { 12141 cache[ camelCase( data ) ] = value; 12142 12143 // Handle: [ owner, { properties } ] args 12144 } else { 12145 12146 // Copy the properties one-by-one to the cache object 12147 for ( prop in data ) { 12148 cache[ camelCase( prop ) ] = data[ prop ]; 12149 } 12150 } 12151 return cache; 12152 }, 12153 get: function( owner, key ) { 12154 return key === undefined ? 12155 this.cache( owner ) : 12156 12157 // Always use camelCase key (gh-2257) 12158 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; 12159 }, 12160 access: function( owner, key, value ) { 12161 12162 // In cases where either: 12163 // 12164 // 1. No key was specified
vendor: 4,717 bytes, lines 12165-12348
12165 // 2. A string key was specified, but no value provided 12166 // 12167 // Take the "read" path and allow the get method to determine 12168 // which value to return, respectively either: 12169 // 12170 // 1. The entire cache object 12171 // 2. The data stored at the key 12172 // 12173 if ( key === undefined || 12174 ( ( key && typeof key === "string" ) && value === undefined ) ) { 12175 12176 return this.get( owner, key ); 12177 } 12178 12179 // When the key is not a string, or both a key and value 12180 // are specified, set or extend (existing objects) with either: 12181 // 12182 // 1. An object of properties 12183 // 2. A key and value 12184 // 12185 this.set( owner, key, value ); 12186 12187 // Since the "set" path can have two possible entry points 12188 // return the expected data based on which path was taken[*] 12189 return value !== undefined ? value : key; 12190 }, 12191 remove: function( owner, key ) { 12192 var i, 12193 cache = owner[ this.expando ]; 12194 12195 if ( cache === undefined ) { 12196 return; 12197 } 12198 12199 if ( key !== undefined ) { 12200 12201 // Support array or space separated string of keys 12202 if ( Array.isArray( key ) ) { 12203 12204 // If key is an array of keys... 12205 // We always set camelCase keys, so remove that. 12206 key = key.map( camelCase ); 12207 } else { 12208 key = camelCase( key ); 12209 12210 // If a key with the spaces exists, use it. 12211 // Otherwise, create an array by matching non-whitespace 12212 key = key in cache ? 12213 [ key ] : 12214 ( key.match( rnothtmlwhite ) || [] ); 12215 } 12216 12217 i = key.length; 12218 12219 while ( i-- ) { 12220 delete cache[ key[ i ] ]; 12221 } 12222 } 12223 12224 // Remove the expando if there's no more data 12225 if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 12226 12227 // Support: Chrome <=35 - 45 12228 // Webkit & Blink performance suffers when deleting properties 12229 // from DOM nodes, so set to undefined instead 12230 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) 12231 if ( owner.nodeType ) { 12232 owner[ this.expando ] = undefined; 12233 } else { 12234 delete owner[ this.expando ]; 12235 } 12236 } 12237 }, 12238 hasData: function( owner ) { 12239 var cache = owner[ this.expando ]; 12240 return cache !== undefined && !jQuery.isEmptyObject( cache ); 12241 } 12242 }; 12243 var dataPriv = new Data(); 12244 12245 var dataUser = new Data(); 12246 12247 12248 12249// Implementation Summary 12250// 12251// 1. Enforce API surface and semantic compatibility with 1.9.x branch 12252// 2. Improve the module's maintainability by reducing the storage 12253// paths to a single mechanism. 12254// 3. Use the same single mechanism to support "private" and "user" data. 12255// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 12256// 5. Avoid exposing implementation details on user objects (eg. expando properties) 12257// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 12258 12259 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 12260 rmultiDash = /[A-Z]/g; 12261 12262 function getData( data ) { 12263 if ( data === "true" ) { 12264 return true; 12265 } 12266 12267 if ( data === "false" ) { 12268 return false; 12269 } 12270 12271 if ( data === "null" ) { 12272 return null; 12273 } 12274 12275 // Only convert to a number if it doesn't change the string 12276 if ( data === +data + "" ) { 12277 return +data; 12278 } 12279 12280 if ( rbrace.test( data ) ) { 12281 return JSON.parse( data ); 12282 } 12283 12284 return data; 12285 } 12286 12287 function dataAttr( elem, key, data ) { 12288 var name; 12289 12290 // If nothing was found internally, try to fetch any 12291 // data from the HTML5 data-* attribute 12292 if ( data === undefined && elem.nodeType === 1 ) { 12293 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 12294 data = elem.getAttribute( name ); 12295 12296 if ( typeof data === "string" ) { 12297 try { 12298 data = getData( data ); 12299 } catch ( e ) {} 12300 12301 // Make sure we set the data so it isn't changed later 12302 dataUser.set( elem, key, data ); 12303 } else { 12304 data = undefined; 12305 } 12306 } 12307 return data; 12308 } 12309 12310 jQuery.extend( { 12311 hasData: function( elem ) { 12312 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 12313 }, 12314 12315 data: function( elem, name, data ) { 12316 return dataUser.access( elem, name, data ); 12317 }, 12318 12319 removeData: function( elem, name ) { 12320 dataUser.remove( elem, name ); 12321 }, 12322 12323 // TODO: Now that all calls to _data and _removeData have been replaced 12324 // with direct calls to dataPriv methods, these can be deprecated. 12325 _data: function( elem, name, data ) { 12326 return dataPriv.access( elem, name, data ); 12327 }, 12328 12329 _removeData: function( elem, name ) { 12330 dataPriv.remove( elem, name ); 12331 } 12332 } ); 12333 12334 jQuery.fn.extend( { 12335 data: function( key, value ) { 12336 var i, name, data, 12337 elem = this[ 0 ], 12338 attrs = elem && elem.attributes; 12339 12340 // Gets all values 12341 if ( key === undefined ) { 12342 if ( this.length ) { 12343 data = dataUser.get( elem ); 12344 12345 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 12346 i = attrs.length; 12347 while ( i-- ) { 12348
vendor: 21,160 bytes, lines 12349-13157
12349 // Support: IE 11 only 12350 // The attrs elements can be null (trac-14894) 12351 if ( attrs[ i ] ) { 12352 name = attrs[ i ].name; 12353 if ( name.indexOf( "data-" ) === 0 ) { 12354 name = camelCase( name.slice( 5 ) ); 12355 dataAttr( elem, name, data[ name ] ); 12356 } 12357 } 12358 } 12359 dataPriv.set( elem, "hasDataAttrs", true ); 12360 } 12361 } 12362 12363 return data; 12364 } 12365 12366 // Sets multiple values 12367 if ( typeof key === "object" ) { 12368 return this.each( function() { 12369 dataUser.set( this, key ); 12370 } ); 12371 } 12372 12373 return access( this, function( value ) { 12374 var data; 12375 12376 // The calling jQuery object (element matches) is not empty 12377 // (and therefore has an element appears at this[ 0 ]) and the 12378 // `value` parameter was not undefined. An empty jQuery object 12379 // will result in `undefined` for elem = this[ 0 ] which will 12380 // throw an exception if an attempt to read a data cache is made. 12381 if ( elem && value === undefined ) { 12382 12383 // Attempt to get data from the cache 12384 // The key will always be camelCased in Data 12385 data = dataUser.get( elem, key ); 12386 if ( data !== undefined ) { 12387 return data; 12388 } 12389 12390 // Attempt to "discover" the data in 12391 // HTML5 custom data-* attrs 12392 data = dataAttr( elem, key ); 12393 if ( data !== undefined ) { 12394 return data; 12395 } 12396 12397 // We tried really hard, but the data doesn't exist. 12398 return; 12399 } 12400 12401 // Set the data... 12402 this.each( function() { 12403 12404 // We always store the camelCased key 12405 dataUser.set( this, key, value ); 12406 } ); 12407 }, null, value, arguments.length > 1, null, true ); 12408 }, 12409 12410 removeData: function( key ) { 12411 return this.each( function() { 12412 dataUser.remove( this, key ); 12413 } ); 12414 } 12415 } ); 12416 12417 12418 jQuery.extend( { 12419 queue: function( elem, type, data ) { 12420 var queue; 12421 12422 if ( elem ) { 12423 type = ( type || "fx" ) + "queue"; 12424 queue = dataPriv.get( elem, type ); 12425 12426 // Speed up dequeue by getting out quickly if this is just a lookup 12427 if ( data ) { 12428 if ( !queue || Array.isArray( data ) ) { 12429 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 12430 } else { 12431 queue.push( data ); 12432 } 12433 } 12434 return queue || []; 12435 } 12436 }, 12437 12438 dequeue: function( elem, type ) { 12439 type = type || "fx"; 12440 12441 var queue = jQuery.queue( elem, type ), 12442 startLength = queue.length, 12443 fn = queue.shift(), 12444 hooks = jQuery._queueHooks( elem, type ), 12445 next = function() { 12446 jQuery.dequeue( elem, type ); 12447 }; 12448 12449 // If the fx queue is dequeued, always remove the progress sentinel 12450 if ( fn === "inprogress" ) { 12451 fn = queue.shift(); 12452 startLength--; 12453 } 12454 12455 if ( fn ) { 12456 12457 // Add a progress sentinel to prevent the fx queue from being 12458 // automatically dequeued 12459 if ( type === "fx" ) { 12460 queue.unshift( "inprogress" ); 12461 } 12462 12463 // Clear up the last queue stop function 12464 delete hooks.stop; 12465 fn.call( elem, next, hooks ); 12466 } 12467 12468 if ( !startLength && hooks ) { 12469 hooks.empty.fire(); 12470 } 12471 }, 12472 12473 // Not public - generate a queueHooks object, or return the current one 12474 _queueHooks: function( elem, type ) { 12475 var key = type + "queueHooks"; 12476 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 12477 empty: jQuery.Callbacks( "once memory" ).add( function() { 12478 dataPriv.remove( elem, [ type + "queue", key ] ); 12479 } ) 12480 } ); 12481 } 12482 } ); 12483 12484 jQuery.fn.extend( { 12485 queue: function( type, data ) { 12486 var setter = 2; 12487 12488 if ( typeof type !== "string" ) { 12489 data = type; 12490 type = "fx"; 12491 setter--; 12492 } 12493 12494 if ( arguments.length < setter ) { 12495 return jQuery.queue( this[ 0 ], type ); 12496 } 12497 12498 return data === undefined ? 12499 this : 12500 this.each( function() { 12501 var queue = jQuery.queue( this, type, data ); 12502 12503 // Ensure a hooks for this queue 12504 jQuery._queueHooks( this, type ); 12505 12506 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 12507 jQuery.dequeue( this, type ); 12508 } 12509 } ); 12510 }, 12511 dequeue: function( type ) { 12512 return this.each( function() { 12513 jQuery.dequeue( this, type ); 12514 } ); 12515 }, 12516 clearQueue: function( type ) { 12517 return this.queue( type || "fx", [] ); 12518 }, 12519 12520 // Get a promise resolved when queues of a certain type 12521 // are emptied (fx is the type by default) 12522 promise: function( type, obj ) { 12523 var tmp, 12524 count = 1, 12525 defer = jQuery.Deferred(), 12526 elements = this, 12527 i = this.length, 12528 resolve = function() { 12529 if ( !( --count ) ) { 12530 defer.resolveWith( elements, [ elements ] ); 12531 } 12532 }; 12533 12534 if ( typeof type !== "string" ) { 12535 obj = type; 12536 type = undefined; 12537 } 12538 type = type || "fx"; 12539 12540 while ( i-- ) { 12541 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 12542 if ( tmp && tmp.empty ) { 12543 count++; 12544 tmp.empty.add( resolve ); 12545 } 12546 } 12547 resolve(); 12548 return defer.promise( obj ); 12549 } 12550 } ); 12551 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 12552 12553 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 12554 12555 12556 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 12557 12558 var documentElement = document.documentElement; 12559 12560 12561 12562 var isAttached = function( elem ) { 12563 return jQuery.contains( elem.ownerDocument, elem ); 12564 }, 12565 composed = { composed: true }; 12566 12567 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only 12568 // Check attachment across shadow DOM boundaries when possible (gh-3504) 12569 // Support: iOS 10.0-10.2 only 12570 // Early iOS 10 versions support `attachShadow` but not `getRootNode`, 12571 // leading to errors. We need to check for `getRootNode`. 12572 if ( documentElement.getRootNode ) { 12573 isAttached = function( elem ) { 12574 return jQuery.contains( elem.ownerDocument, elem ) || 12575 elem.getRootNode( composed ) === elem.ownerDocument; 12576 }; 12577 } 12578 var isHiddenWithinTree = function( elem, el ) { 12579 12580 // isHiddenWithinTree might be called from jQuery#filter function; 12581 // in that case, element will be second argument 12582 elem = el || elem; 12583 12584 // Inline style trumps all 12585 return elem.style.display === "none" || 12586 elem.style.display === "" && 12587 12588 // Otherwise, check computed style 12589 // Support: Firefox <=43 - 45 12590 // Disconnected elements can have computed display: none, so first confirm that elem is 12591 // in the document. 12592 isAttached( elem ) && 12593 12594 jQuery.css( elem, "display" ) === "none"; 12595 }; 12596 12597 12598 12599 function adjustCSS( elem, prop, valueParts, tween ) { 12600 var adjusted, scale, 12601 maxIterations = 20, 12602 currentValue = tween ? 12603 function() { 12604 return tween.cur(); 12605 } : 12606 function() { 12607 return jQuery.css( elem, prop, "" ); 12608 }, 12609 initial = currentValue(), 12610 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 12611 12612 // Starting value computation is required for potential unit mismatches 12613 initialInUnit = elem.nodeType && 12614 ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 12615 rcssNum.exec( jQuery.css( elem, prop ) ); 12616 12617 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 12618 12619 // Support: Firefox <=54 12620 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) 12621 initial = initial / 2; 12622 12623 // Trust units reported by jQuery.css 12624 unit = unit || initialInUnit[ 3 ]; 12625 12626 // Iteratively approximate from a nonzero starting point 12627 initialInUnit = +initial || 1; 12628 12629 while ( maxIterations-- ) { 12630 12631 // Evaluate and update our best guess (doubling guesses that zero out). 12632 // Finish if the scale equals or crosses 1 (making the old*new product non-positive). 12633 jQuery.style( elem, prop, initialInUnit + unit ); 12634 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { 12635 maxIterations = 0; 12636 } 12637 initialInUnit = initialInUnit / scale; 12638 12639 } 12640 12641 initialInUnit = initialInUnit * 2; 12642 jQuery.style( elem, prop, initialInUnit + unit ); 12643 12644 // Make sure we update the tween properties later on 12645 valueParts = valueParts || []; 12646 } 12647 12648 if ( valueParts ) { 12649 initialInUnit = +initialInUnit || +initial || 0; 12650 12651 // Apply relative offset (+=/-=) if specified 12652 adjusted = valueParts[ 1 ] ? 12653 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 12654 +valueParts[ 2 ]; 12655 if ( tween ) { 12656 tween.unit = unit; 12657 tween.start = initialInUnit; 12658 tween.end = adjusted; 12659 } 12660 } 12661 return adjusted; 12662 } 12663 12664 12665 var defaultDisplayMap = {}; 12666 12667 function getDefaultDisplay( elem ) { 12668 var temp, 12669 doc = elem.ownerDocument, 12670 nodeName = elem.nodeName, 12671 display = defaultDisplayMap[ nodeName ]; 12672 12673 if ( display ) { 12674 return display; 12675 } 12676 12677 temp = doc.body.appendChild( doc.createElement( nodeName ) ); 12678 display = jQuery.css( temp, "display" ); 12679 12680 temp.parentNode.removeChild( temp ); 12681 12682 if ( display === "none" ) { 12683 display = "block"; 12684 } 12685 defaultDisplayMap[ nodeName ] = display; 12686 12687 return display; 12688 } 12689 12690 function showHide( elements, show ) { 12691 var display, elem, 12692 values = [], 12693 index = 0, 12694 length = elements.length; 12695 12696 // Determine new display value for elements that need to change 12697 for ( ; index < length; index++ ) { 12698 elem = elements[ index ]; 12699 if ( !elem.style ) { 12700 continue; 12701 } 12702 12703 display = elem.style.display; 12704 if ( show ) { 12705 12706 // Since we force visibility upon cascade-hidden elements, an immediate (and slow) 12707 // check is required in this first loop unless we have a nonempty display value (either 12708 // inline or about-to-be-restored) 12709 if ( display === "none" ) { 12710 values[ index ] = dataPriv.get( elem, "display" ) || null; 12711 if ( !values[ index ] ) { 12712 elem.style.display = ""; 12713 } 12714 } 12715 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { 12716 values[ index ] = getDefaultDisplay( elem ); 12717 } 12718 } else { 12719 if ( display !== "none" ) { 12720 values[ index ] = "none"; 12721 12722 // Remember what we're overwriting 12723 dataPriv.set( elem, "display", display ); 12724 } 12725 } 12726 } 12727 12728 // Set the display of the elements in a second loop to avoid constant reflow 12729 for ( index = 0; index < length; index++ ) { 12730 if ( values[ index ] != null ) { 12731 elements[ index ].style.display = values[ index ]; 12732 } 12733 } 12734 12735 return elements; 12736 } 12737 12738 jQuery.fn.extend( { 12739 show: function() { 12740 return showHide( this, true ); 12741 }, 12742 hide: function() { 12743 return showHide( this ); 12744 }, 12745 toggle: function( state ) { 12746 if ( typeof state === "boolean" ) { 12747 return state ? this.show() : this.hide(); 12748 } 12749 12750 return this.each( function() { 12751 if ( isHiddenWithinTree( this ) ) { 12752 jQuery( this ).show(); 12753 } else { 12754 jQuery( this ).hide(); 12755 } 12756 } ); 12757 } 12758 } ); 12759 var rcheckableType = ( /^(?:checkbox|radio)$/i ); 12760 12761 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); 12762 12763 var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); 12764 12765 12766 12767 ( function() { 12768 var fragment = document.createDocumentFragment(), 12769 div = fragment.appendChild( document.createElement( "div" ) ), 12770 input = document.createElement( "input" ); 12771 12772 // Support: Android 4.0 - 4.3 only 12773 // Check state lost if the name is set (trac-11217) 12774 // Support: Windows Web Apps (WWA) 12775 // `name` and `type` must use .setAttribute for WWA (trac-14901) 12776 input.setAttribute( "type", "radio" ); 12777 input.setAttribute( "checked", "checked" ); 12778 input.setAttribute( "name", "t" ); 12779 12780 div.appendChild( input ); 12781 12782 // Support: Android <=4.1 only 12783 // Older WebKit doesn't clone checked state correctly in fragments 12784 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 12785 12786 // Support: IE <=11 only 12787 // Make sure textarea (and checkbox) defaultValue is properly cloned 12788 div.innerHTML = "<textarea>x</textarea>"; 12789 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 12790 12791 // Support: IE <=9 only 12792 // IE <=9 replaces <option> tags with their contents when inserted outside of 12793 // the select element. 12794 div.innerHTML = "<option></option>"; 12795 support.option = !!div.lastChild; 12796 } )(); 12797 12798 12799// We have to close these tags to support XHTML (trac-13200) 12800 var wrapMap = { 12801 12802 // XHTML parsers do not magically insert elements in the 12803 // same way that tag soup parsers do. So we cannot shorten 12804 // this by omitting <tbody> or other required elements. 12805 thead: [ 1, "<table>", "</table>" ], 12806 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], 12807 tr: [ 2, "<table><tbody>", "</tbody></table>" ], 12808 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 12809 12810 _default: [ 0, "", "" ] 12811 }; 12812 12813 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 12814 wrapMap.th = wrapMap.td; 12815 12816// Support: IE <=9 only 12817 if ( !support.option ) { 12818 wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ]; 12819 } 12820 12821 12822 function getAll( context, tag ) { 12823 12824 // Support: IE <=9 - 11 only 12825 // Use typeof to avoid zero-argument method invocation on host objects (trac-15151) 12826 var ret; 12827 12828 if ( typeof context.getElementsByTagName !== "undefined" ) { 12829 ret = context.getElementsByTagName( tag || "*" ); 12830 12831 } else if ( typeof context.querySelectorAll !== "undefined" ) { 12832 ret = context.querySelectorAll( tag || "*" ); 12833 12834 } else { 12835 ret = []; 12836 } 12837 12838 if ( tag === undefined || tag && nodeName( context, tag ) ) { 12839 return jQuery.merge( [ context ], ret ); 12840 } 12841 12842 return ret; 12843 } 12844 12845 12846// Mark scripts as having already been evaluated 12847 function setGlobalEval( elems, refElements ) { 12848 var i = 0, 12849 l = elems.length; 12850 12851 for ( ; i < l; i++ ) { 12852 dataPriv.set( 12853 elems[ i ], 12854 "globalEval", 12855 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 12856 ); 12857 } 12858 } 12859 12860 12861 var rhtml = /<|&#?\w+;/; 12862 12863 function buildFragment( elems, context, scripts, selection, ignored ) { 12864 var elem, tmp, tag, wrap, attached, j, 12865 fragment = context.createDocumentFragment(), 12866 nodes = [], 12867 i = 0, 12868 l = elems.length; 12869 12870 for ( ; i < l; i++ ) { 12871 elem = elems[ i ]; 12872 12873 if ( elem || elem === 0 ) { 12874 12875 // Add nodes directly 12876 if ( toType( elem ) === "object" ) { 12877 12878 // Support: Android <=4.0 only, PhantomJS 1 only 12879 // push.apply(_, arraylike) throws on ancient WebKit 12880 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 12881 12882 // Convert non-html into a text node 12883 } else if ( !rhtml.test( elem ) ) { 12884 nodes.push( context.createTextNode( elem ) ); 12885 12886 // Convert html into DOM nodes 12887 } else { 12888 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 12889 12890 // Deserialize a standard representation 12891 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 12892 wrap = wrapMap[ tag ] || wrapMap._default; 12893 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 12894 12895 // Descend through wrappers to the right content 12896 j = wrap[ 0 ]; 12897 while ( j-- ) { 12898 tmp = tmp.lastChild; 12899 } 12900 12901 // Support: Android <=4.0 only, PhantomJS 1 only 12902 // push.apply(_, arraylike) throws on ancient WebKit 12903 jQuery.merge( nodes, tmp.childNodes ); 12904 12905 // Remember the top-level container 12906 tmp = fragment.firstChild; 12907 12908 // Ensure the created nodes are orphaned (trac-12392) 12909 tmp.textContent = ""; 12910 } 12911 } 12912 } 12913 12914 // Remove wrapper from fragment 12915 fragment.textContent = ""; 12916 12917 i = 0; 12918 while ( ( elem = nodes[ i++ ] ) ) { 12919 12920 // Skip elements already in the context collection (trac-4087) 12921 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 12922 if ( ignored ) { 12923 ignored.push( elem ); 12924 } 12925 continue; 12926 } 12927 12928 attached = isAttached( elem ); 12929 12930 // Append to fragment 12931 tmp = getAll( fragment.appendChild( elem ), "script" ); 12932 12933 // Preserve script evaluation history 12934 if ( attached ) { 12935 setGlobalEval( tmp ); 12936 } 12937 12938 // Capture executables 12939 if ( scripts ) { 12940 j = 0; 12941 while ( ( elem = tmp[ j++ ] ) ) { 12942 if ( rscriptType.test( elem.type || "" ) ) { 12943 scripts.push( elem ); 12944 } 12945 } 12946 } 12947 } 12948 12949 return fragment; 12950 } 12951 12952 12953 var rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 12954 12955 function returnTrue() { 12956 return true; 12957 } 12958 12959 function returnFalse() { 12960 return false; 12961 } 12962 12963 function on( elem, types, selector, data, fn, one ) { 12964 var origFn, type; 12965 12966 // Types can be a map of types/handlers 12967 if ( typeof types === "object" ) { 12968 12969 // ( types-Object, selector, data ) 12970 if ( typeof selector !== "string" ) { 12971 12972 // ( types-Object, data ) 12973 data = data || selector; 12974 selector = undefined; 12975 } 12976 for ( type in types ) { 12977 on( elem, type, selector, data, types[ type ], one ); 12978 } 12979 return elem; 12980 } 12981 12982 if ( data == null && fn == null ) { 12983 12984 // ( types, fn ) 12985 fn = selector; 12986 data = selector = undefined; 12987 } else if ( fn == null ) { 12988 if ( typeof selector === "string" ) { 12989 12990 // ( types, selector, fn ) 12991 fn = data; 12992 data = undefined; 12993 } else { 12994 12995 // ( types, data, fn ) 12996 fn = data; 12997 data = selector; 12998 selector = undefined; 12999 } 13000 } 13001 if ( fn === false ) { 13002 fn = returnFalse; 13003 } else if ( !fn ) { 13004 return elem; 13005 } 13006 13007 if ( one === 1 ) { 13008 origFn = fn; 13009 fn = function( event ) { 13010 13011 // Can use an empty set, since event contains the info 13012 jQuery().off( event ); 13013 return origFn.apply( this, arguments ); 13014 }; 13015 13016 // Use same guid so caller can remove using origFn 13017 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 13018 } 13019 return elem.each( function() { 13020 jQuery.event.add( this, types, fn, data, selector ); 13021 } ); 13022 } 13023 13024 /* 13025 * Helper functions for managing events -- not part of the public interface. 13026 * Props to Dean Edwards' addEvent library for many of the ideas. 13027 */ 13028 jQuery.event = { 13029 13030 global: {}, 13031 13032 add: function( elem, types, handler, data, selector ) { 13033 13034 var handleObjIn, eventHandle, tmp, 13035 events, t, handleObj, 13036 special, handlers, type, namespaces, origType, 13037 elemData = dataPriv.get( elem ); 13038 13039 // Only attach events to objects that accept data 13040 if ( !acceptData( elem ) ) { 13041 return; 13042 } 13043 13044 // Caller can pass in an object of custom data in lieu of the handler 13045 if ( handler.handler ) { 13046 handleObjIn = handler; 13047 handler = handleObjIn.handler; 13048 selector = handleObjIn.selector; 13049 } 13050 13051 // Ensure that invalid selectors throw exceptions at attach time 13052 // Evaluate against documentElement in case elem is a non-element node (e.g., document) 13053 if ( selector ) { 13054 jQuery.find.matchesSelector( documentElement, selector ); 13055 } 13056 13057 // Make sure that the handler has a unique ID, used to find/remove it later 13058 if ( !handler.guid ) { 13059 handler.guid = jQuery.guid++; 13060 } 13061 13062 // Init the element's event structure and main handler, if this is the first 13063 if ( !( events = elemData.events ) ) { 13064 events = elemData.events = Object.create( null ); 13065 } 13066 if ( !( eventHandle = elemData.handle ) ) { 13067 eventHandle = elemData.handle = function( e ) { 13068 13069 // Discard the second event of a jQuery.event.trigger() and 13070 // when an event is called after a page has unloaded 13071 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? 13072 jQuery.event.dispatch.apply( elem, arguments ) : undefined; 13073 }; 13074 } 13075 13076 // Handle multiple events separated by a space 13077 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 13078 t = types.length; 13079 while ( t-- ) { 13080 tmp = rtypenamespace.exec( types[ t ] ) || []; 13081 type = origType = tmp[ 1 ]; 13082 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 13083 13084 // There *must* be a type, no attaching namespace-only handlers 13085 if ( !type ) { 13086 continue; 13087 } 13088 13089 // If event changes its type, use the special event handlers for the changed type 13090 special = jQuery.event.special[ type ] || {}; 13091 13092 // If selector defined, determine special event api type, otherwise given type 13093 type = ( selector ? special.delegateType : special.bindType ) || type; 13094 13095 // Update special based on newly reset type 13096 special = jQuery.event.special[ type ] || {}; 13097 13098 // handleObj is passed to all event handlers 13099 handleObj = jQuery.extend( { 13100 type: type, 13101 origType: origType, 13102 data: data, 13103 handler: handler, 13104 guid: handler.guid, 13105 selector: selector, 13106 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 13107 namespace: namespaces.join( "." ) 13108 }, handleObjIn ); 13109 13110 // Init the event handler queue if we're the first 13111 if ( !( handlers = events[ type ] ) ) { 13112 handlers = events[ type ] = []; 13113 handlers.delegateCount = 0; 13114 13115 // Only use addEventListener if the special events handler returns false 13116 if ( !special.setup || 13117 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 13118 13119 if ( elem.addEventListener ) { 13120 elem.addEventListener( type, eventHandle ); 13121 } 13122 } 13123 } 13124 13125 if ( special.add ) { 13126 special.add.call( elem, handleObj ); 13127 13128 if ( !handleObj.handler.guid ) { 13129 handleObj.handler.guid = handler.guid; 13130 } 13131 } 13132 13133 // Add to the element's handler list, delegates in front 13134 if ( selector ) { 13135 handlers.splice( handlers.delegateCount++, 0, handleObj ); 13136 } else { 13137 handlers.push( handleObj ); 13138 } 13139 13140 // Keep track of which events have ever been used, for event optimization 13141 jQuery.event.global[ type ] = true; 13142 } 13143 13144 }, 13145 13146 // Detach an event or set of events from an element 13147 remove: function( elem, types, handler, selector, mappedTypes ) { 13148 13149 var j, origCount, tmp, 13150 events, t, handleObj, 13151 special, handlers, type, namespaces, origType, 13152 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); 13153 13154 if ( !elemData || !( events = elemData.events ) ) { 13155 return; 13156 } 13157
vendor: 4,306 bytes, lines 13158-13296
13158 // Once for each type.namespace in types; type may be omitted 13159 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 13160 t = types.length; 13161 while ( t-- ) { 13162 tmp = rtypenamespace.exec( types[ t ] ) || []; 13163 type = origType = tmp[ 1 ]; 13164 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 13165 13166 // Unbind all events (on this namespace, if provided) for the element 13167 if ( !type ) { 13168 for ( type in events ) { 13169 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 13170 } 13171 continue; 13172 } 13173 13174 special = jQuery.event.special[ type ] || {}; 13175 type = ( selector ? special.delegateType : special.bindType ) || type; 13176 handlers = events[ type ] || []; 13177 tmp = tmp[ 2 ] && 13178 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 13179 13180 // Remove matching events 13181 origCount = j = handlers.length; 13182 while ( j-- ) { 13183 handleObj = handlers[ j ]; 13184 13185 if ( ( mappedTypes || origType === handleObj.origType ) && 13186 ( !handler || handler.guid === handleObj.guid ) && 13187 ( !tmp || tmp.test( handleObj.namespace ) ) && 13188 ( !selector || selector === handleObj.selector || 13189 selector === "**" && handleObj.selector ) ) { 13190 handlers.splice( j, 1 ); 13191 13192 if ( handleObj.selector ) { 13193 handlers.delegateCount--; 13194 } 13195 if ( special.remove ) { 13196 special.remove.call( elem, handleObj ); 13197 } 13198 } 13199 } 13200 13201 // Remove generic event handler if we removed something and no more handlers exist 13202 // (avoids potential for endless recursion during removal of special event handlers) 13203 if ( origCount && !handlers.length ) { 13204 if ( !special.teardown || 13205 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 13206 13207 jQuery.removeEvent( elem, type, elemData.handle ); 13208 } 13209 13210 delete events[ type ]; 13211 } 13212 } 13213 13214 // Remove data and the expando if it's no longer used 13215 if ( jQuery.isEmptyObject( events ) ) { 13216 dataPriv.remove( elem, "handle events" ); 13217 } 13218 }, 13219 13220 dispatch: function( nativeEvent ) { 13221 13222 var i, j, ret, matched, handleObj, handlerQueue, 13223 args = new Array( arguments.length ), 13224 13225 // Make a writable jQuery.Event from the native event object 13226 event = jQuery.event.fix( nativeEvent ), 13227 13228 handlers = ( 13229 dataPriv.get( this, "events" ) || Object.create( null ) 13230 )[ event.type ] || [], 13231 special = jQuery.event.special[ event.type ] || {}; 13232 13233 // Use the fix-ed jQuery.Event rather than the (read-only) native event 13234 args[ 0 ] = event; 13235 13236 for ( i = 1; i < arguments.length; i++ ) { 13237 args[ i ] = arguments[ i ]; 13238 } 13239 13240 event.delegateTarget = this; 13241 13242 // Call the preDispatch hook for the mapped type, and let it bail if desired 13243 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 13244 return; 13245 } 13246 13247 // Determine handlers 13248 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 13249 13250 // Run delegates first; they may want to stop propagation beneath us 13251 i = 0; 13252 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 13253 event.currentTarget = matched.elem; 13254 13255 j = 0; 13256 while ( ( handleObj = matched.handlers[ j++ ] ) && 13257 !event.isImmediatePropagationStopped() ) { 13258 13259 // If the event is namespaced, then each handler is only invoked if it is 13260 // specially universal or its namespaces are a superset of the event's. 13261 if ( !event.rnamespace || handleObj.namespace === false || 13262 event.rnamespace.test( handleObj.namespace ) ) { 13263 13264 event.handleObj = handleObj; 13265 event.data = handleObj.data; 13266 13267 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 13268 handleObj.handler ).apply( matched.elem, args ); 13269 13270 if ( ret !== undefined ) { 13271 if ( ( event.result = ret ) === false ) { 13272 event.preventDefault(); 13273 event.stopPropagation(); 13274 } 13275 } 13276 } 13277 } 13278 } 13279 13280 // Call the postDispatch hook for the mapped type 13281 if ( special.postDispatch ) { 13282 special.postDispatch.call( this, event ); 13283 } 13284 13285 return event.result; 13286 }, 13287 13288 handlers: function( event, handlers ) { 13289 var i, handleObj, sel, matchedHandlers, matchedSelectors, 13290 handlerQueue = [], 13291 delegateCount = handlers.delegateCount, 13292 cur = event.target; 13293 13294 // Find delegate handlers 13295 if ( delegateCount && 13296
vendor: 61,617 bytes, lines 13297-15401
13297 // Support: IE <=9 13298 // Black-hole SVG <use> instance trees (trac-13180) 13299 cur.nodeType && 13300 13301 // Support: Firefox <=42 13302 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) 13303 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click 13304 // Support: IE 11 only 13305 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) 13306 !( event.type === "click" && event.button >= 1 ) ) { 13307 13308 for ( ; cur !== this; cur = cur.parentNode || this ) { 13309 13310 // Don't check non-elements (trac-13208) 13311 // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764) 13312 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { 13313 matchedHandlers = []; 13314 matchedSelectors = {}; 13315 for ( i = 0; i < delegateCount; i++ ) { 13316 handleObj = handlers[ i ]; 13317 13318 // Don't conflict with Object.prototype properties (trac-13203) 13319 sel = handleObj.selector + " "; 13320 13321 if ( matchedSelectors[ sel ] === undefined ) { 13322 matchedSelectors[ sel ] = handleObj.needsContext ? 13323 jQuery( sel, this ).index( cur ) > -1 : 13324 jQuery.find( sel, this, null, [ cur ] ).length; 13325 } 13326 if ( matchedSelectors[ sel ] ) { 13327 matchedHandlers.push( handleObj ); 13328 } 13329 } 13330 if ( matchedHandlers.length ) { 13331 handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); 13332 } 13333 } 13334 } 13335 } 13336 13337 // Add the remaining (directly-bound) handlers 13338 cur = this; 13339 if ( delegateCount < handlers.length ) { 13340 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); 13341 } 13342 13343 return handlerQueue; 13344 }, 13345 13346 addProp: function( name, hook ) { 13347 Object.defineProperty( jQuery.Event.prototype, name, { 13348 enumerable: true, 13349 configurable: true, 13350 13351 get: isFunction( hook ) ? 13352 function() { 13353 if ( this.originalEvent ) { 13354 return hook( this.originalEvent ); 13355 } 13356 } : 13357 function() { 13358 if ( this.originalEvent ) { 13359 return this.originalEvent[ name ]; 13360 } 13361 }, 13362 13363 set: function( value ) { 13364 Object.defineProperty( this, name, { 13365 enumerable: true, 13366 configurable: true, 13367 writable: true, 13368 value: value 13369 } ); 13370 } 13371 } ); 13372 }, 13373 13374 fix: function( originalEvent ) { 13375 return originalEvent[ jQuery.expando ] ? 13376 originalEvent : 13377 new jQuery.Event( originalEvent ); 13378 }, 13379 13380 special: { 13381 load: { 13382 13383 // Prevent triggered image.load events from bubbling to window.load 13384 noBubble: true 13385 }, 13386 click: { 13387 13388 // Utilize native event to ensure correct state for checkable inputs 13389 setup: function( data ) { 13390 13391 // For mutual compressibility with _default, replace `this` access with a local var. 13392 // `|| data` is dead code meant only to preserve the variable through minification. 13393 var el = this || data; 13394 13395 // Claim the first handler 13396 if ( rcheckableType.test( el.type ) && 13397 el.click && nodeName( el, "input" ) ) { 13398 13399 // dataPriv.set( el, "click", ... ) 13400 leverageNative( el, "click", true ); 13401 } 13402 13403 // Return false to allow normal processing in the caller 13404 return false; 13405 }, 13406 trigger: function( data ) { 13407 13408 // For mutual compressibility with _default, replace `this` access with a local var. 13409 // `|| data` is dead code meant only to preserve the variable through minification. 13410 var el = this || data; 13411 13412 // Force setup before triggering a click 13413 if ( rcheckableType.test( el.type ) && 13414 el.click && nodeName( el, "input" ) ) { 13415 13416 leverageNative( el, "click" ); 13417 } 13418 13419 // Return non-false to allow normal event-path propagation 13420 return true; 13421 }, 13422 13423 // For cross-browser consistency, suppress native .click() on links 13424 // Also prevent it if we're currently inside a leveraged native-event stack 13425 _default: function( event ) { 13426 var target = event.target; 13427 return rcheckableType.test( target.type ) && 13428 target.click && nodeName( target, "input" ) && 13429 dataPriv.get( target, "click" ) || 13430 nodeName( target, "a" ); 13431 } 13432 }, 13433 13434 beforeunload: { 13435 postDispatch: function( event ) { 13436 13437 // Support: Firefox 20+ 13438 // Firefox doesn't alert if the returnValue field is not set. 13439 if ( event.result !== undefined && event.originalEvent ) { 13440 event.originalEvent.returnValue = event.result; 13441 } 13442 } 13443 } 13444 } 13445 }; 13446 13447// Ensure the presence of an event listener that handles manually-triggered 13448// synthetic events by interrupting progress until reinvoked in response to 13449// *native* events that it fires directly, ensuring that state changes have 13450// already occurred before other listeners are invoked. 13451 function leverageNative( el, type, isSetup ) { 13452 13453 // Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add 13454 if ( !isSetup ) { 13455 if ( dataPriv.get( el, type ) === undefined ) { 13456 jQuery.event.add( el, type, returnTrue ); 13457 } 13458 return; 13459 } 13460 13461 // Register the controller as a special universal handler for all event namespaces 13462 dataPriv.set( el, type, false ); 13463 jQuery.event.add( el, type, { 13464 namespace: false, 13465 handler: function( event ) { 13466 var result, 13467 saved = dataPriv.get( this, type ); 13468 13469 if ( ( event.isTrigger & 1 ) && this[ type ] ) { 13470 13471 // Interrupt processing of the outer synthetic .trigger()ed event 13472 if ( !saved ) { 13473 13474 // Store arguments for use when handling the inner native event 13475 // There will always be at least one argument (an event object), so this array 13476 // will not be confused with a leftover capture object. 13477 saved = slice.call( arguments ); 13478 dataPriv.set( this, type, saved ); 13479 13480 // Trigger the native event and capture its result 13481 this[ type ](); 13482 result = dataPriv.get( this, type ); 13483 dataPriv.set( this, type, false ); 13484 13485 if ( saved !== result ) { 13486 13487 // Cancel the outer synthetic event 13488 event.stopImmediatePropagation(); 13489 event.preventDefault(); 13490 13491 return result; 13492 } 13493 13494 // If this is an inner synthetic event for an event with a bubbling surrogate 13495 // (focus or blur), assume that the surrogate already propagated from triggering 13496 // the native event and prevent that from happening again here. 13497 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the 13498 // bubbling surrogate propagates *after* the non-bubbling base), but that seems 13499 // less bad than duplication. 13500 } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { 13501 event.stopPropagation(); 13502 } 13503 13504 // If this is a native event triggered above, everything is now in order 13505 // Fire an inner synthetic event with the original arguments 13506 } else if ( saved ) { 13507 13508 // ...and capture the result 13509 dataPriv.set( this, type, jQuery.event.trigger( 13510 saved[ 0 ], 13511 saved.slice( 1 ), 13512 this 13513 ) ); 13514 13515 // Abort handling of the native event by all jQuery handlers while allowing 13516 // native handlers on the same element to run. On target, this is achieved 13517 // by stopping immediate propagation just on the jQuery event. However, 13518 // the native event is re-wrapped by a jQuery one on each level of the 13519 // propagation so the only way to stop it for jQuery is to stop it for 13520 // everyone via native `stopPropagation()`. This is not a problem for 13521 // focus/blur which don't bubble, but it does also stop click on checkboxes 13522 // and radios. We accept this limitation. 13523 event.stopPropagation(); 13524 event.isImmediatePropagationStopped = returnTrue; 13525 } 13526 } 13527 } ); 13528 } 13529 13530 jQuery.removeEvent = function( elem, type, handle ) { 13531 13532 // This "if" is needed for plain objects 13533 if ( elem.removeEventListener ) { 13534 elem.removeEventListener( type, handle ); 13535 } 13536 }; 13537 13538 jQuery.Event = function( src, props ) { 13539 13540 // Allow instantiation without the 'new' keyword 13541 if ( !( this instanceof jQuery.Event ) ) { 13542 return new jQuery.Event( src, props ); 13543 } 13544 13545 // Event object 13546 if ( src && src.type ) { 13547 this.originalEvent = src; 13548 this.type = src.type; 13549 13550 // Events bubbling up the document may have been marked as prevented 13551 // by a handler lower down the tree; reflect the correct value. 13552 this.isDefaultPrevented = src.defaultPrevented || 13553 src.defaultPrevented === undefined && 13554 13555 // Support: Android <=2.3 only 13556 src.returnValue === false ? 13557 returnTrue : 13558 returnFalse; 13559 13560 // Create target properties 13561 // Support: Safari <=6 - 7 only 13562 // Target should not be a text node (trac-504, trac-13143) 13563 this.target = ( src.target && src.target.nodeType === 3 ) ? 13564 src.target.parentNode : 13565 src.target; 13566 13567 this.currentTarget = src.currentTarget; 13568 this.relatedTarget = src.relatedTarget; 13569 13570 // Event type 13571 } else { 13572 this.type = src; 13573 } 13574 13575 // Put explicitly provided properties onto the event object 13576 if ( props ) { 13577 jQuery.extend( this, props ); 13578 } 13579 13580 // Create a timestamp if incoming event doesn't have one 13581 this.timeStamp = src && src.timeStamp || Date.now(); 13582 13583 // Mark it as fixed 13584 this[ jQuery.expando ] = true; 13585 }; 13586 13587// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 13588// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 13589 jQuery.Event.prototype = { 13590 constructor: jQuery.Event, 13591 isDefaultPrevented: returnFalse, 13592 isPropagationStopped: returnFalse, 13593 isImmediatePropagationStopped: returnFalse, 13594 isSimulated: false, 13595 13596 preventDefault: function() { 13597 var e = this.originalEvent; 13598 13599 this.isDefaultPrevented = returnTrue; 13600 13601 if ( e && !this.isSimulated ) { 13602 e.preventDefault(); 13603 } 13604 }, 13605 stopPropagation: function() { 13606 var e = this.originalEvent; 13607 13608 this.isPropagationStopped = returnTrue; 13609 13610 if ( e && !this.isSimulated ) { 13611 e.stopPropagation(); 13612 } 13613 }, 13614 stopImmediatePropagation: function() { 13615 var e = this.originalEvent; 13616 13617 this.isImmediatePropagationStopped = returnTrue; 13618 13619 if ( e && !this.isSimulated ) { 13620 e.stopImmediatePropagation(); 13621 } 13622 13623 this.stopPropagation(); 13624 } 13625 }; 13626 13627// Includes all common event props including KeyEvent and MouseEvent specific props 13628 jQuery.each( { 13629 altKey: true, 13630 bubbles: true, 13631 cancelable: true, 13632 changedTouches: true, 13633 ctrlKey: true, 13634 detail: true, 13635 eventPhase: true, 13636 metaKey: true, 13637 pageX: true, 13638 pageY: true, 13639 shiftKey: true, 13640 view: true, 13641 "char": true, 13642 code: true, 13643 charCode: true, 13644 key: true, 13645 keyCode: true, 13646 button: true, 13647 buttons: true, 13648 clientX: true, 13649 clientY: true, 13650 offsetX: true, 13651 offsetY: true, 13652 pointerId: true, 13653 pointerType: true, 13654 screenX: true, 13655 screenY: true, 13656 targetTouches: true, 13657 toElement: true, 13658 touches: true, 13659 which: true 13660 }, jQuery.event.addProp ); 13661 13662 jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { 13663 13664 function focusMappedHandler( nativeEvent ) { 13665 if ( document.documentMode ) { 13666 13667 // Support: IE 11+ 13668 // Attach a single focusin/focusout handler on the document while someone wants 13669 // focus/blur. This is because the former are synchronous in IE while the latter 13670 // are async. In other browsers, all those handlers are invoked synchronously. 13671 13672 // `handle` from private data would already wrap the event, but we need 13673 // to change the `type` here. 13674 var handle = dataPriv.get( this, "handle" ), 13675 event = jQuery.event.fix( nativeEvent ); 13676 event.type = nativeEvent.type === "focusin" ? "focus" : "blur"; 13677 event.isSimulated = true; 13678 13679 // First, handle focusin/focusout 13680 handle( nativeEvent ); 13681 13682 // ...then, handle focus/blur 13683 // 13684 // focus/blur don't bubble while focusin/focusout do; simulate the former by only 13685 // invoking the handler at the lower level. 13686 if ( event.target === event.currentTarget ) { 13687 13688 // The setup part calls `leverageNative`, which, in turn, calls 13689 // `jQuery.event.add`, so event handle will already have been set 13690 // by this point. 13691 handle( event ); 13692 } 13693 } else { 13694 13695 // For non-IE browsers, attach a single capturing handler on the document 13696 // while someone wants focusin/focusout. 13697 jQuery.event.simulate( delegateType, nativeEvent.target, 13698 jQuery.event.fix( nativeEvent ) ); 13699 } 13700 } 13701 13702 jQuery.event.special[ type ] = { 13703 13704 // Utilize native event if possible so blur/focus sequence is correct 13705 setup: function() { 13706 13707 var attaches; 13708 13709 // Claim the first handler 13710 // dataPriv.set( this, "focus", ... ) 13711 // dataPriv.set( this, "blur", ... ) 13712 leverageNative( this, type, true ); 13713 13714 if ( document.documentMode ) { 13715 13716 // Support: IE 9 - 11+ 13717 // We use the same native handler for focusin & focus (and focusout & blur) 13718 // so we need to coordinate setup & teardown parts between those events. 13719 // Use `delegateType` as the key as `type` is already used by `leverageNative`. 13720 attaches = dataPriv.get( this, delegateType ); 13721 if ( !attaches ) { 13722 this.addEventListener( delegateType, focusMappedHandler ); 13723 } 13724 dataPriv.set( this, delegateType, ( attaches || 0 ) + 1 ); 13725 } else { 13726 13727 // Return false to allow normal processing in the caller 13728 return false; 13729 } 13730 }, 13731 trigger: function() { 13732 13733 // Force setup before trigger 13734 leverageNative( this, type ); 13735 13736 // Return non-false to allow normal event-path propagation 13737 return true; 13738 }, 13739 13740 teardown: function() { 13741 var attaches; 13742 13743 if ( document.documentMode ) { 13744 attaches = dataPriv.get( this, delegateType ) - 1; 13745 if ( !attaches ) { 13746 this.removeEventListener( delegateType, focusMappedHandler ); 13747 dataPriv.remove( this, delegateType ); 13748 } else { 13749 dataPriv.set( this, delegateType, attaches ); 13750 } 13751 } else { 13752 13753 // Return false to indicate standard teardown should be applied 13754 return false; 13755 } 13756 }, 13757 13758 // Suppress native focus or blur if we're currently inside 13759 // a leveraged native-event stack 13760 _default: function( event ) { 13761 return dataPriv.get( event.target, type ); 13762 }, 13763 13764 delegateType: delegateType 13765 }; 13766 13767 // Support: Firefox <=44 13768 // Firefox doesn't have focus(in | out) events 13769 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 13770 // 13771 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 13772 // focus(in | out) events fire after focus & blur events, 13773 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 13774 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 13775 // 13776 // Support: IE 9 - 11+ 13777 // To preserve relative focusin/focus & focusout/blur event order guaranteed on the 3.x branch, 13778 // attach a single handler for both events in IE. 13779 jQuery.event.special[ delegateType ] = { 13780 setup: function() { 13781 13782 // Handle: regular nodes (via `this.ownerDocument`), window 13783 // (via `this.document`) & document (via `this`). 13784 var doc = this.ownerDocument || this.document || this, 13785 dataHolder = document.documentMode ? this : doc, 13786 attaches = dataPriv.get( dataHolder, delegateType ); 13787 13788 // Support: IE 9 - 11+ 13789 // We use the same native handler for focusin & focus (and focusout & blur) 13790 // so we need to coordinate setup & teardown parts between those events. 13791 // Use `delegateType` as the key as `type` is already used by `leverageNative`. 13792 if ( !attaches ) { 13793 if ( document.documentMode ) { 13794 this.addEventListener( delegateType, focusMappedHandler ); 13795 } else { 13796 doc.addEventListener( type, focusMappedHandler, true ); 13797 } 13798 } 13799 dataPriv.set( dataHolder, delegateType, ( attaches || 0 ) + 1 ); 13800 }, 13801 teardown: function() { 13802 var doc = this.ownerDocument || this.document || this, 13803 dataHolder = document.documentMode ? this : doc, 13804 attaches = dataPriv.get( dataHolder, delegateType ) - 1; 13805 13806 if ( !attaches ) { 13807 if ( document.documentMode ) { 13808 this.removeEventListener( delegateType, focusMappedHandler ); 13809 } else { 13810 doc.removeEventListener( type, focusMappedHandler, true ); 13811 } 13812 dataPriv.remove( dataHolder, delegateType ); 13813 } else { 13814 dataPriv.set( dataHolder, delegateType, attaches ); 13815 } 13816 } 13817 }; 13818 } ); 13819 13820// Create mouseenter/leave events using mouseover/out and event-time checks 13821// so that event delegation works in jQuery. 13822// Do the same for pointerenter/pointerleave and pointerover/pointerout 13823// 13824// Support: Safari 7 only 13825// Safari sends mouseenter too often; see: 13826// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 13827// for the description of the bug (it existed in older Chrome versions as well). 13828 jQuery.each( { 13829 mouseenter: "mouseover", 13830 mouseleave: "mouseout", 13831 pointerenter: "pointerover", 13832 pointerleave: "pointerout" 13833 }, function( orig, fix ) { 13834 jQuery.event.special[ orig ] = { 13835 delegateType: fix, 13836 bindType: fix, 13837 13838 handle: function( event ) { 13839 var ret, 13840 target = this, 13841 related = event.relatedTarget, 13842 handleObj = event.handleObj; 13843 13844 // For mouseenter/leave call the handler if related is outside the target. 13845 // NB: No relatedTarget if the mouse left/entered the browser window 13846 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 13847 event.type = handleObj.origType; 13848 ret = handleObj.handler.apply( this, arguments ); 13849 event.type = fix; 13850 } 13851 return ret; 13852 } 13853 }; 13854 } ); 13855 13856 jQuery.fn.extend( { 13857 13858 on: function( types, selector, data, fn ) { 13859 return on( this, types, selector, data, fn ); 13860 }, 13861 one: function( types, selector, data, fn ) { 13862 return on( this, types, selector, data, fn, 1 ); 13863 }, 13864 off: function( types, selector, fn ) { 13865 var handleObj, type; 13866 if ( types && types.preventDefault && types.handleObj ) { 13867 13868 // ( event ) dispatched jQuery.Event 13869 handleObj = types.handleObj; 13870 jQuery( types.delegateTarget ).off( 13871 handleObj.namespace ? 13872 handleObj.origType + "." + handleObj.namespace : 13873 handleObj.origType, 13874 handleObj.selector, 13875 handleObj.handler 13876 ); 13877 return this; 13878 } 13879 if ( typeof types === "object" ) { 13880 13881 // ( types-object [, selector] ) 13882 for ( type in types ) { 13883 this.off( type, selector, types[ type ] ); 13884 } 13885 return this; 13886 } 13887 if ( selector === false || typeof selector === "function" ) { 13888 13889 // ( types [, fn] ) 13890 fn = selector; 13891 selector = undefined; 13892 } 13893 if ( fn === false ) { 13894 fn = returnFalse; 13895 } 13896 return this.each( function() { 13897 jQuery.event.remove( this, types, fn, selector ); 13898 } ); 13899 } 13900 } ); 13901 13902 13903 var 13904 13905 // Support: IE <=10 - 11, Edge 12 - 13 only 13906 // In IE/Edge using regex groups here causes severe slowdowns. 13907 // See https://connect.microsoft.com/IE/feedback/details/1736512/ 13908 rnoInnerhtml = /<script|<style|<link/i, 13909 13910 // checked="checked" or checked 13911 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 13912 13913 rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g; 13914 13915// Prefer a tbody over its parent table for containing new rows 13916 function manipulationTarget( elem, content ) { 13917 if ( nodeName( elem, "table" ) && 13918 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { 13919 13920 return jQuery( elem ).children( "tbody" )[ 0 ] || elem; 13921 } 13922 13923 return elem; 13924 } 13925 13926// Replace/restore the type attribute of script elements for safe DOM manipulation 13927 function disableScript( elem ) { 13928 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; 13929 return elem; 13930 } 13931 function restoreScript( elem ) { 13932 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { 13933 elem.type = elem.type.slice( 5 ); 13934 } else { 13935 elem.removeAttribute( "type" ); 13936 } 13937 13938 return elem; 13939 } 13940 13941 function cloneCopyEvent( src, dest ) { 13942 var i, l, type, pdataOld, udataOld, udataCur, events; 13943 13944 if ( dest.nodeType !== 1 ) { 13945 return; 13946 } 13947 13948 // 1. Copy private data: events, handlers, etc. 13949 if ( dataPriv.hasData( src ) ) { 13950 pdataOld = dataPriv.get( src ); 13951 events = pdataOld.events; 13952 13953 if ( events ) { 13954 dataPriv.remove( dest, "handle events" ); 13955 13956 for ( type in events ) { 13957 for ( i = 0, l = events[ type ].length; i < l; i++ ) { 13958 jQuery.event.add( dest, type, events[ type ][ i ] ); 13959 } 13960 } 13961 } 13962 } 13963 13964 // 2. Copy user data 13965 if ( dataUser.hasData( src ) ) { 13966 udataOld = dataUser.access( src ); 13967 udataCur = jQuery.extend( {}, udataOld ); 13968 13969 dataUser.set( dest, udataCur ); 13970 } 13971 } 13972 13973// Fix IE bugs, see support tests 13974 function fixInput( src, dest ) { 13975 var nodeName = dest.nodeName.toLowerCase(); 13976 13977 // Fails to persist the checked state of a cloned checkbox or radio button. 13978 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 13979 dest.checked = src.checked; 13980 13981 // Fails to return the selected option to the default selected state when cloning options 13982 } else if ( nodeName === "input" || nodeName === "textarea" ) { 13983 dest.defaultValue = src.defaultValue; 13984 } 13985 } 13986 13987 function domManip( collection, args, callback, ignored ) { 13988 13989 // Flatten any nested arrays 13990 args = flat( args ); 13991 13992 var fragment, first, scripts, hasScripts, node, doc, 13993 i = 0, 13994 l = collection.length, 13995 iNoClone = l - 1, 13996 value = args[ 0 ], 13997 valueIsFunction = isFunction( value ); 13998 13999 // We can't cloneNode fragments that contain checked, in WebKit 14000 if ( valueIsFunction || 14001 ( l > 1 && typeof value === "string" && 14002 !support.checkClone && rchecked.test( value ) ) ) { 14003 return collection.each( function( index ) { 14004 var self = collection.eq( index ); 14005 if ( valueIsFunction ) { 14006 args[ 0 ] = value.call( this, index, self.html() ); 14007 } 14008 domManip( self, args, callback, ignored ); 14009 } ); 14010 } 14011 14012 if ( l ) { 14013 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 14014 first = fragment.firstChild; 14015 14016 if ( fragment.childNodes.length === 1 ) { 14017 fragment = first; 14018 } 14019 14020 // Require either new content or an interest in ignored elements to invoke the callback 14021 if ( first || ignored ) { 14022 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 14023 hasScripts = scripts.length; 14024 14025 // Use the original fragment for the last item 14026 // instead of the first because it can end up 14027 // being emptied incorrectly in certain situations (trac-8070). 14028 for ( ; i < l; i++ ) { 14029 node = fragment; 14030 14031 if ( i !== iNoClone ) { 14032 node = jQuery.clone( node, true, true ); 14033 14034 // Keep references to cloned scripts for later restoration 14035 if ( hasScripts ) { 14036 14037 // Support: Android <=4.0 only, PhantomJS 1 only 14038 // push.apply(_, arraylike) throws on ancient WebKit 14039 jQuery.merge( scripts, getAll( node, "script" ) ); 14040 } 14041 } 14042 14043 callback.call( collection[ i ], node, i ); 14044 } 14045 14046 if ( hasScripts ) { 14047 doc = scripts[ scripts.length - 1 ].ownerDocument; 14048 14049 // Re-enable scripts 14050 jQuery.map( scripts, restoreScript ); 14051 14052 // Evaluate executable scripts on first document insertion 14053 for ( i = 0; i < hasScripts; i++ ) { 14054 node = scripts[ i ]; 14055 if ( rscriptType.test( node.type || "" ) && 14056 !dataPriv.access( node, "globalEval" ) && 14057 jQuery.contains( doc, node ) ) { 14058 14059 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { 14060 14061 // Optional AJAX dependency, but won't run scripts if not present 14062 if ( jQuery._evalUrl && !node.noModule ) { 14063 jQuery._evalUrl( node.src, { 14064 nonce: node.nonce || node.getAttribute( "nonce" ) 14065 }, doc ); 14066 } 14067 } else { 14068 14069 // Unwrap a CDATA section containing script contents. This shouldn't be 14070 // needed as in XML documents they're already not visible when 14071 // inspecting element contents and in HTML documents they have no 14072 // meaning but we're preserving that logic for backwards compatibility. 14073 // This will be removed completely in 4.0. See gh-4904. 14074 DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); 14075 } 14076 } 14077 } 14078 } 14079 } 14080 } 14081 14082 return collection; 14083 } 14084 14085 function remove( elem, selector, keepData ) { 14086 var node, 14087 nodes = selector ? jQuery.filter( selector, elem ) : elem, 14088 i = 0; 14089 14090 for ( ; ( node = nodes[ i ] ) != null; i++ ) { 14091 if ( !keepData && node.nodeType === 1 ) { 14092 jQuery.cleanData( getAll( node ) ); 14093 } 14094 14095 if ( node.parentNode ) { 14096 if ( keepData && isAttached( node ) ) { 14097 setGlobalEval( getAll( node, "script" ) ); 14098 } 14099 node.parentNode.removeChild( node ); 14100 } 14101 } 14102 14103 return elem; 14104 } 14105 14106 jQuery.extend( { 14107 htmlPrefilter: function( html ) { 14108 return html; 14109 }, 14110 14111 clone: function( elem, dataAndEvents, deepDataAndEvents ) { 14112 var i, l, srcElements, destElements, 14113 clone = elem.cloneNode( true ), 14114 inPage = isAttached( elem ); 14115 14116 // Fix IE cloning issues 14117 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && 14118 !jQuery.isXMLDoc( elem ) ) { 14119 14120 // We eschew jQuery#find here for performance reasons: 14121 // https://jsperf.com/getall-vs-sizzle/2 14122 destElements = getAll( clone ); 14123 srcElements = getAll( elem ); 14124 14125 for ( i = 0, l = srcElements.length; i < l; i++ ) { 14126 fixInput( srcElements[ i ], destElements[ i ] ); 14127 } 14128 } 14129 14130 // Copy the events from the original to the clone 14131 if ( dataAndEvents ) { 14132 if ( deepDataAndEvents ) { 14133 srcElements = srcElements || getAll( elem ); 14134 destElements = destElements || getAll( clone ); 14135 14136 for ( i = 0, l = srcElements.length; i < l; i++ ) { 14137 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); 14138 } 14139 } else { 14140 cloneCopyEvent( elem, clone ); 14141 } 14142 } 14143 14144 // Preserve script evaluation history 14145 destElements = getAll( clone, "script" ); 14146 if ( destElements.length > 0 ) { 14147 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 14148 } 14149 14150 // Return the cloned set 14151 return clone; 14152 }, 14153 14154 cleanData: function( elems ) { 14155 var data, elem, type, 14156 special = jQuery.event.special, 14157 i = 0; 14158 14159 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { 14160 if ( acceptData( elem ) ) { 14161 if ( ( data = elem[ dataPriv.expando ] ) ) { 14162 if ( data.events ) { 14163 for ( type in data.events ) { 14164 if ( special[ type ] ) { 14165 jQuery.event.remove( elem, type ); 14166 14167 // This is a shortcut to avoid jQuery.event.remove's overhead 14168 } else { 14169 jQuery.removeEvent( elem, type, data.handle ); 14170 } 14171 } 14172 } 14173 14174 // Support: Chrome <=35 - 45+ 14175 // Assign undefined instead of using delete, see Data#remove 14176 elem[ dataPriv.expando ] = undefined; 14177 } 14178 if ( elem[ dataUser.expando ] ) { 14179 14180 // Support: Chrome <=35 - 45+ 14181 // Assign undefined instead of using delete, see Data#remove 14182 elem[ dataUser.expando ] = undefined; 14183 } 14184 } 14185 } 14186 } 14187 } ); 14188 14189 jQuery.fn.extend( { 14190 detach: function( selector ) { 14191 return remove( this, selector, true ); 14192 }, 14193 14194 remove: function( selector ) { 14195 return remove( this, selector ); 14196 }, 14197 14198 text: function( value ) { 14199 return access( this, function( value ) { 14200 return value === undefined ? 14201 jQuery.text( this ) : 14202 this.empty().each( function() { 14203 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 14204 this.textContent = value; 14205 } 14206 } ); 14207 }, null, value, arguments.length ); 14208 }, 14209 14210 append: function() { 14211 return domManip( this, arguments, function( elem ) { 14212 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 14213 var target = manipulationTarget( this, elem ); 14214 target.appendChild( elem ); 14215 } 14216 } ); 14217 }, 14218 14219 prepend: function() { 14220 return domManip( this, arguments, function( elem ) { 14221 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 14222 var target = manipulationTarget( this, elem ); 14223 target.insertBefore( elem, target.firstChild ); 14224 } 14225 } ); 14226 }, 14227 14228 before: function() { 14229 return domManip( this, arguments, function( elem ) { 14230 if ( this.parentNode ) { 14231 this.parentNode.insertBefore( elem, this ); 14232 } 14233 } ); 14234 }, 14235 14236 after: function() { 14237 return domManip( this, arguments, function( elem ) { 14238 if ( this.parentNode ) { 14239 this.parentNode.insertBefore( elem, this.nextSibling ); 14240 } 14241 } ); 14242 }, 14243 14244 empty: function() { 14245 var elem, 14246 i = 0; 14247 14248 for ( ; ( elem = this[ i ] ) != null; i++ ) { 14249 if ( elem.nodeType === 1 ) { 14250 14251 // Prevent memory leaks 14252 jQuery.cleanData( getAll( elem, false ) ); 14253 14254 // Remove any remaining nodes 14255 elem.textContent = ""; 14256 } 14257 } 14258 14259 return this; 14260 }, 14261 14262 clone: function( dataAndEvents, deepDataAndEvents ) { 14263 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 14264 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 14265 14266 return this.map( function() { 14267 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 14268 } ); 14269 }, 14270 14271 html: function( value ) { 14272 return access( this, function( value ) { 14273 var elem = this[ 0 ] || {}, 14274 i = 0, 14275 l = this.length; 14276 14277 if ( value === undefined && elem.nodeType === 1 ) { 14278 return elem.innerHTML; 14279 } 14280 14281 // See if we can take a shortcut and just use innerHTML 14282 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 14283 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 14284 14285 value = jQuery.htmlPrefilter( value ); 14286 14287 try { 14288 for ( ; i < l; i++ ) { 14289 elem = this[ i ] || {}; 14290 14291 // Remove element nodes and prevent memory leaks 14292 if ( elem.nodeType === 1 ) { 14293 jQuery.cleanData( getAll( elem, false ) ); 14294 elem.innerHTML = value; 14295 } 14296 } 14297 14298 elem = 0; 14299 14300 // If using innerHTML throws an exception, use the fallback method 14301 } catch ( e ) {} 14302 } 14303 14304 if ( elem ) { 14305 this.empty().append( value ); 14306 } 14307 }, null, value, arguments.length ); 14308 }, 14309 14310 replaceWith: function() { 14311 var ignored = []; 14312 14313 // Make the changes, replacing each non-ignored context element with the new content 14314 return domManip( this, arguments, function( elem ) { 14315 var parent = this.parentNode; 14316 14317 if ( jQuery.inArray( this, ignored ) < 0 ) { 14318 jQuery.cleanData( getAll( this ) ); 14319 if ( parent ) { 14320 parent.replaceChild( elem, this ); 14321 } 14322 } 14323 14324 // Force callback invocation 14325 }, ignored ); 14326 } 14327 } ); 14328 14329 jQuery.each( { 14330 appendTo: "append", 14331 prependTo: "prepend", 14332 insertBefore: "before", 14333 insertAfter: "after", 14334 replaceAll: "replaceWith" 14335 }, function( name, original ) { 14336 jQuery.fn[ name ] = function( selector ) { 14337 var elems, 14338 ret = [], 14339 insert = jQuery( selector ), 14340 last = insert.length - 1, 14341 i = 0; 14342 14343 for ( ; i <= last; i++ ) { 14344 elems = i === last ? this : this.clone( true ); 14345 jQuery( insert[ i ] )[ original ]( elems ); 14346 14347 // Support: Android <=4.0 only, PhantomJS 1 only 14348 // .get() because push.apply(_, arraylike) throws on ancient WebKit 14349 push.apply( ret, elems.get() ); 14350 } 14351 14352 return this.pushStack( ret ); 14353 }; 14354 } ); 14355 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 14356 14357 var rcustomProp = /^--/; 14358 14359 14360 var getStyles = function( elem ) { 14361 14362 // Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150) 14363 // IE throws on elements created in popups 14364 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 14365 var view = elem.ownerDocument.defaultView; 14366 14367 if ( !view || !view.opener ) { 14368 view = window; 14369 } 14370 14371 return view.getComputedStyle( elem ); 14372 }; 14373 14374 var swap = function( elem, options, callback ) { 14375 var ret, name, 14376 old = {}; 14377 14378 // Remember the old values, and insert the new ones 14379 for ( name in options ) { 14380 old[ name ] = elem.style[ name ]; 14381 elem.style[ name ] = options[ name ]; 14382 } 14383 14384 ret = callback.call( elem ); 14385 14386 // Revert the old values 14387 for ( name in options ) { 14388 elem.style[ name ] = old[ name ]; 14389 } 14390 14391 return ret; 14392 }; 14393 14394 14395 var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); 14396 14397 14398 14399 ( function() { 14400 14401 // Executing both pixelPosition & boxSizingReliable tests require only one layout 14402 // so they're executed at the same time to save the second computation. 14403 function computeStyleTests() { 14404 14405 // This is a singleton, we need to execute it only once 14406 if ( !div ) { 14407 return; 14408 } 14409 14410 container.style.cssText = "position:absolute;left:-11111px;width:60px;" + 14411 "margin-top:1px;padding:0;border:0"; 14412 div.style.cssText = 14413 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + 14414 "margin:auto;border:1px;padding:1px;" + 14415 "width:60%;top:1%"; 14416 documentElement.appendChild( container ).appendChild( div ); 14417 14418 var divStyle = window.getComputedStyle( div ); 14419 pixelPositionVal = divStyle.top !== "1%"; 14420 14421 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 14422 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; 14423 14424 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 14425 // Some styles come back with percentage values, even though they shouldn't 14426 div.style.right = "60%"; 14427 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; 14428 14429 // Support: IE 9 - 11 only 14430 // Detect misreporting of content dimensions for box-sizing:border-box elements 14431 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; 14432 14433 // Support: IE 9 only 14434 // Detect overflow:scroll screwiness (gh-3699) 14435 // Support: Chrome <=64 14436 // Don't get tricked when zoom affects offsetWidth (gh-4029) 14437 div.style.position = "absolute"; 14438 scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; 14439 14440 documentElement.removeChild( container ); 14441 14442 // Nullify the div so it wouldn't be stored in the memory and 14443 // it will also be a sign that checks already performed 14444 div = null; 14445 } 14446 14447 function roundPixelMeasures( measure ) { 14448 return Math.round( parseFloat( measure ) ); 14449 } 14450 14451 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, 14452 reliableTrDimensionsVal, reliableMarginLeftVal, 14453 container = document.createElement( "div" ), 14454 div = document.createElement( "div" ); 14455 14456 // Finish early in limited (non-browser) environments 14457 if ( !div.style ) { 14458 return; 14459 } 14460 14461 // Support: IE <=9 - 11 only 14462 // Style of cloned element affects source element cloned (trac-8908) 14463 div.style.backgroundClip = "content-box"; 14464 div.cloneNode( true ).style.backgroundClip = ""; 14465 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 14466 14467 jQuery.extend( support, { 14468 boxSizingReliable: function() { 14469 computeStyleTests(); 14470 return boxSizingReliableVal; 14471 }, 14472 pixelBoxStyles: function() { 14473 computeStyleTests(); 14474 return pixelBoxStylesVal; 14475 }, 14476 pixelPosition: function() { 14477 computeStyleTests(); 14478 return pixelPositionVal; 14479 }, 14480 reliableMarginLeft: function() { 14481 computeStyleTests(); 14482 return reliableMarginLeftVal; 14483 }, 14484 scrollboxSize: function() { 14485 computeStyleTests(); 14486 return scrollboxSizeVal; 14487 }, 14488 14489 // Support: IE 9 - 11+, Edge 15 - 18+ 14490 // IE/Edge misreport `getComputedStyle` of table rows with width/height 14491 // set in CSS while `offset*` properties report correct values. 14492 // Behavior in IE 9 is more subtle than in newer versions & it passes 14493 // some versions of this test; make sure not to make it pass there! 14494 // 14495 // Support: Firefox 70+ 14496 // Only Firefox includes border widths 14497 // in computed dimensions. (gh-4529) 14498 reliableTrDimensions: function() { 14499 var table, tr, trChild, trStyle; 14500 if ( reliableTrDimensionsVal == null ) { 14501 table = document.createElement( "table" ); 14502 tr = document.createElement( "tr" ); 14503 trChild = document.createElement( "div" ); 14504 14505 table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; 14506 tr.style.cssText = "box-sizing:content-box;border:1px solid"; 14507 14508 // Support: Chrome 86+ 14509 // Height set through cssText does not get applied. 14510 // Computed height then comes back as 0. 14511 tr.style.height = "1px"; 14512 trChild.style.height = "9px"; 14513 14514 // Support: Android 8 Chrome 86+ 14515 // In our bodyBackground.html iframe, 14516 // display for all div elements is set to "inline", 14517 // which causes a problem only in Android 8 Chrome 86. 14518 // Ensuring the div is `display: block` 14519 // gets around this issue. 14520 trChild.style.display = "block"; 14521 14522 documentElement 14523 .appendChild( table ) 14524 .appendChild( tr ) 14525 .appendChild( trChild ); 14526 14527 trStyle = window.getComputedStyle( tr ); 14528 reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + 14529 parseInt( trStyle.borderTopWidth, 10 ) + 14530 parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; 14531 14532 documentElement.removeChild( table ); 14533 } 14534 return reliableTrDimensionsVal; 14535 } 14536 } ); 14537 } )(); 14538 14539 14540 function curCSS( elem, name, computed ) { 14541 var width, minWidth, maxWidth, ret, 14542 isCustomProp = rcustomProp.test( name ), 14543 14544 // Support: Firefox 51+ 14545 // Retrieving style before computed somehow 14546 // fixes an issue with getting wrong values 14547 // on detached elements 14548 style = elem.style; 14549 14550 computed = computed || getStyles( elem ); 14551 14552 // getPropertyValue is needed for: 14553 // .css('filter') (IE 9 only, trac-12537) 14554 // .css('--customProperty) (gh-3144) 14555 if ( computed ) { 14556 14557 // Support: IE <=9 - 11+ 14558 // IE only supports `"float"` in `getPropertyValue`; in computed styles 14559 // it's only available as `"cssFloat"`. We no longer modify properties 14560 // sent to `.css()` apart from camelCasing, so we need to check both. 14561 // Normally, this would create difference in behavior: if 14562 // `getPropertyValue` returns an empty string, the value returned 14563 // by `.css()` would be `undefined`. This is usually the case for 14564 // disconnected elements. However, in IE even disconnected elements 14565 // with no styles return `"none"` for `getPropertyValue( "float" )` 14566 ret = computed.getPropertyValue( name ) || computed[ name ]; 14567 14568 if ( isCustomProp && ret ) { 14569 14570 // Support: Firefox 105+, Chrome <=105+ 14571 // Spec requires trimming whitespace for custom properties (gh-4926). 14572 // Firefox only trims leading whitespace. Chrome just collapses 14573 // both leading & trailing whitespace to a single space. 14574 // 14575 // Fall back to `undefined` if empty string returned. 14576 // This collapses a missing definition with property defined 14577 // and set to an empty string but there's no standard API 14578 // allowing us to differentiate them without a performance penalty 14579 // and returning `undefined` aligns with older jQuery. 14580 // 14581 // rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED 14582 // as whitespace while CSS does not, but this is not a problem 14583 // because CSS preprocessing replaces them with U+000A LINE FEED 14584 // (which *is* CSS whitespace) 14585 // https://www.w3.org/TR/css-syntax-3/#input-preprocessing 14586 ret = ret.replace( rtrimCSS, "$1" ) || undefined; 14587 } 14588 14589 if ( ret === "" && !isAttached( elem ) ) { 14590 ret = jQuery.style( elem, name ); 14591 } 14592 14593 // A tribute to the "awesome hack by Dean Edwards" 14594 // Android Browser returns percentage for some values, 14595 // but width seems to be reliably pixels. 14596 // This is against the CSSOM draft spec: 14597 // https://drafts.csswg.org/cssom/#resolved-values 14598 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { 14599 14600 // Remember the original values 14601 width = style.width; 14602 minWidth = style.minWidth; 14603 maxWidth = style.maxWidth; 14604 14605 // Put in the new values to get a computed value out 14606 style.minWidth = style.maxWidth = style.width = ret; 14607 ret = computed.width; 14608 14609 // Revert the changed values 14610 style.width = width; 14611 style.minWidth = minWidth; 14612 style.maxWidth = maxWidth; 14613 } 14614 } 14615 14616 return ret !== undefined ? 14617 14618 // Support: IE <=9 - 11 only 14619 // IE returns zIndex value as an integer. 14620 ret + "" : 14621 ret; 14622 } 14623 14624 14625 function addGetHookIf( conditionFn, hookFn ) { 14626 14627 // Define the hook, we'll check on the first run if it's really needed. 14628 return { 14629 get: function() { 14630 if ( conditionFn() ) { 14631 14632 // Hook not needed (or it's not possible to use it due 14633 // to missing dependency), remove it. 14634 delete this.get; 14635 return; 14636 } 14637 14638 // Hook needed; redefine it so that the support test is not executed again. 14639 return ( this.get = hookFn ).apply( this, arguments ); 14640 } 14641 }; 14642 } 14643 14644 14645 var cssPrefixes = [ "Webkit", "Moz", "ms" ], 14646 emptyStyle = document.createElement( "div" ).style, 14647 vendorProps = {}; 14648 14649// Return a vendor-prefixed property or undefined 14650 function vendorPropName( name ) { 14651 14652 // Check for vendor prefixed names 14653 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 14654 i = cssPrefixes.length; 14655 14656 while ( i-- ) { 14657 name = cssPrefixes[ i ] + capName; 14658 if ( name in emptyStyle ) { 14659 return name; 14660 } 14661 } 14662 } 14663 14664// Return a potentially-mapped jQuery.cssProps or vendor prefixed property 14665 function finalPropName( name ) { 14666 var final = jQuery.cssProps[ name ] || vendorProps[ name ]; 14667 14668 if ( final ) { 14669 return final; 14670 } 14671 if ( name in emptyStyle ) { 14672 return name; 14673 } 14674 return vendorProps[ name ] = vendorPropName( name ) || name; 14675 } 14676 14677 14678 var 14679 14680 // Swappable if display is none or starts with table 14681 // except "table", "table-cell", or "table-caption" 14682 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display 14683 rdisplayswap = /^(none|table(?!-c[ea]).+)/, 14684 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 14685 cssNormalTransform = { 14686 letterSpacing: "0", 14687 fontWeight: "400" 14688 }; 14689 14690 function setPositiveNumber( _elem, value, subtract ) { 14691 14692 // Any relative (+/-) values have already been 14693 // normalized at this point 14694 var matches = rcssNum.exec( value ); 14695 return matches ? 14696 14697 // Guard against undefined "subtract", e.g., when used as in cssHooks 14698 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : 14699 value; 14700 } 14701 14702 function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { 14703 var i = dimension === "width" ? 1 : 0, 14704 extra = 0, 14705 delta = 0, 14706 marginDelta = 0; 14707 14708 // Adjustment may not be necessary 14709 if ( box === ( isBorderBox ? "border" : "content" ) ) { 14710 return 0; 14711 } 14712 14713 for ( ; i < 4; i += 2 ) { 14714 14715 // Both box models exclude margin 14716 // Count margin delta separately to only add it after scroll gutter adjustment. 14717 // This is needed to make negative margins work with `outerHeight( true )` (gh-3982). 14718 if ( box === "margin" ) { 14719 marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); 14720 } 14721 14722 // If we get here with a content-box, we're seeking "padding" or "border" or "margin" 14723 if ( !isBorderBox ) { 14724 14725 // Add padding 14726 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 14727 14728 // For "border" or "margin", add border 14729 if ( box !== "padding" ) { 14730 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 14731 14732 // But still keep track of it otherwise 14733 } else { 14734 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 14735 } 14736 14737 // If we get here with a border-box (content + padding + border), we're seeking "content" or 14738 // "padding" or "margin" 14739 } else { 14740 14741 // For "content", subtract padding 14742 if ( box === "content" ) { 14743 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 14744 } 14745 14746 // For "content" or "padding", subtract border 14747 if ( box !== "margin" ) { 14748 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 14749 } 14750 } 14751 } 14752 14753 // Account for positive content-box scroll gutter when requested by providing computedVal 14754 if ( !isBorderBox && computedVal >= 0 ) { 14755 14756 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border 14757 // Assuming integer scroll gutter, subtract the rest and round down 14758 delta += Math.max( 0, Math.ceil( 14759 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 14760 computedVal - 14761 delta - 14762 extra - 14763 0.5 14764 14765 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter 14766 // Use an explicit zero to avoid NaN (gh-3964) 14767 ) ) || 0; 14768 } 14769 14770 return delta + marginDelta; 14771 } 14772 14773 function getWidthOrHeight( elem, dimension, extra ) { 14774 14775 // Start with computed style 14776 var styles = getStyles( elem ), 14777 14778 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). 14779 // Fake content-box until we know it's needed to know the true value. 14780 boxSizingNeeded = !support.boxSizingReliable() || extra, 14781 isBorderBox = boxSizingNeeded && 14782 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 14783 valueIsBorderBox = isBorderBox, 14784 14785 val = curCSS( elem, dimension, styles ), 14786 offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); 14787 14788 // Support: Firefox <=54 14789 // Return a confounding non-pixel value or feign ignorance, as appropriate. 14790 if ( rnumnonpx.test( val ) ) { 14791 if ( !extra ) { 14792 return val; 14793 } 14794 val = "auto"; 14795 } 14796 14797 14798 // Support: IE 9 - 11 only 14799 // Use offsetWidth/offsetHeight for when box sizing is unreliable. 14800 // In those cases, the computed value can be trusted to be border-box. 14801 if ( ( !support.boxSizingReliable() && isBorderBox || 14802 14803 // Support: IE 10 - 11+, Edge 15 - 18+ 14804 // IE/Edge misreport `getComputedStyle` of table rows with width/height 14805 // set in CSS while `offset*` properties report correct values. 14806 // Interestingly, in some cases IE 9 doesn't suffer from this issue. 14807 !support.reliableTrDimensions() && nodeName( elem, "tr" ) || 14808 14809 // Fall back to offsetWidth/offsetHeight when value is "auto" 14810 // This happens for inline elements with no explicit setting (gh-3571) 14811 val === "auto" || 14812 14813 // Support: Android <=4.1 - 4.3 only 14814 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) 14815 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && 14816 14817 // Make sure the element is visible & connected 14818 elem.getClientRects().length ) { 14819 14820 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; 14821 14822 // Where available, offsetWidth/offsetHeight approximate border box dimensions. 14823 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the 14824 // retrieved value as a content box dimension. 14825 valueIsBorderBox = offsetProp in elem; 14826 if ( valueIsBorderBox ) { 14827 val = elem[ offsetProp ]; 14828 } 14829 } 14830 14831 // Normalize "" and auto 14832 val = parseFloat( val ) || 0; 14833 14834 // Adjust for the element's box model 14835 return ( val + 14836 boxModelAdjustment( 14837 elem, 14838 dimension, 14839 extra || ( isBorderBox ? "border" : "content" ), 14840 valueIsBorderBox, 14841 styles, 14842 14843 // Provide the current computed size to request scroll gutter calculation (gh-3589) 14844 val 14845 ) 14846 ) + "px"; 14847 } 14848 14849 jQuery.extend( { 14850 14851 // Add in style property hooks for overriding the default 14852 // behavior of getting and setting a style property 14853 cssHooks: { 14854 opacity: { 14855 get: function( elem, computed ) { 14856 if ( computed ) { 14857 14858 // We should always get a number back from opacity 14859 var ret = curCSS( elem, "opacity" ); 14860 return ret === "" ? "1" : ret; 14861 } 14862 } 14863 } 14864 }, 14865 14866 // Don't automatically add "px" to these possibly-unitless properties 14867 cssNumber: { 14868 animationIterationCount: true, 14869 aspectRatio: true, 14870 borderImageSlice: true, 14871 columnCount: true, 14872 flexGrow: true, 14873 flexShrink: true, 14874 fontWeight: true, 14875 gridArea: true, 14876 gridColumn: true, 14877 gridColumnEnd: true, 14878 gridColumnStart: true, 14879 gridRow: true, 14880 gridRowEnd: true, 14881 gridRowStart: true, 14882 lineHeight: true, 14883 opacity: true, 14884 order: true, 14885 orphans: true, 14886 scale: true, 14887 widows: true, 14888 zIndex: true, 14889 zoom: true, 14890 14891 // SVG-related 14892 fillOpacity: true, 14893 floodOpacity: true, 14894 stopOpacity: true, 14895 strokeMiterlimit: true, 14896 strokeOpacity: true 14897 }, 14898 14899 // Add in properties whose names you wish to fix before 14900 // setting or getting the value 14901 cssProps: {}, 14902 14903 // Get and set the style property on a DOM Node 14904 style: function( elem, name, value, extra ) { 14905 14906 // Don't set styles on text and comment nodes 14907 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 14908 return; 14909 } 14910 14911 // Make sure that we're working with the right name 14912 var ret, type, hooks, 14913 origName = camelCase( name ), 14914 isCustomProp = rcustomProp.test( name ), 14915 style = elem.style; 14916 14917 // Make sure that we're working with the right name. We don't 14918 // want to query the value if it is a CSS custom property 14919 // since they are user-defined. 14920 if ( !isCustomProp ) { 14921 name = finalPropName( origName ); 14922 } 14923 14924 // Gets hook for the prefixed version, then unprefixed version 14925 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 14926 14927 // Check if we're setting a value 14928 if ( value !== undefined ) { 14929 type = typeof value; 14930 14931 // Convert "+=" or "-=" to relative numbers (trac-7345) 14932 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 14933 value = adjustCSS( elem, name, ret ); 14934 14935 // Fixes bug trac-9237 14936 type = "number"; 14937 } 14938 14939 // Make sure that null and NaN values aren't set (trac-7116) 14940 if ( value == null || value !== value ) { 14941 return; 14942 } 14943 14944 // If a number was passed in, add the unit (except for certain CSS properties) 14945 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append 14946 // "px" to a few hardcoded values. 14947 if ( type === "number" && !isCustomProp ) { 14948 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 14949 } 14950 14951 // background-* props affect original clone's values 14952 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 14953 style[ name ] = "inherit"; 14954 } 14955 14956 // If a hook was provided, use that value, otherwise just set the specified value 14957 if ( !hooks || !( "set" in hooks ) || 14958 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 14959 14960 if ( isCustomProp ) { 14961 style.setProperty( name, value ); 14962 } else { 14963 style[ name ] = value; 14964 } 14965 } 14966 14967 } else { 14968 14969 // If a hook was provided get the non-computed value from there 14970 if ( hooks && "get" in hooks && 14971 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 14972 14973 return ret; 14974 } 14975 14976 // Otherwise just get the value from the style object 14977 return style[ name ]; 14978 } 14979 }, 14980 14981 css: function( elem, name, extra, styles ) { 14982 var val, num, hooks, 14983 origName = camelCase( name ), 14984 isCustomProp = rcustomProp.test( name ); 14985 14986 // Make sure that we're working with the right name. We don't 14987 // want to modify the value if it is a CSS custom property 14988 // since they are user-defined. 14989 if ( !isCustomProp ) { 14990 name = finalPropName( origName ); 14991 } 14992 14993 // Try prefixed name followed by the unprefixed name 14994 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 14995 14996 // If a hook was provided get the computed value from there 14997 if ( hooks && "get" in hooks ) { 14998 val = hooks.get( elem, true, extra ); 14999 } 15000 15001 // Otherwise, if a way to get the computed value exists, use that 15002 if ( val === undefined ) { 15003 val = curCSS( elem, name, styles ); 15004 } 15005 15006 // Convert "normal" to computed value 15007 if ( val === "normal" && name in cssNormalTransform ) { 15008 val = cssNormalTransform[ name ]; 15009 } 15010 15011 // Make numeric if forced or a qualifier was provided and val looks numeric 15012 if ( extra === "" || extra ) { 15013 num = parseFloat( val ); 15014 return extra === true || isFinite( num ) ? num || 0 : val; 15015 } 15016 15017 return val; 15018 } 15019 } ); 15020 15021 jQuery.each( [ "height", "width" ], function( _i, dimension ) { 15022 jQuery.cssHooks[ dimension ] = { 15023 get: function( elem, computed, extra ) { 15024 if ( computed ) { 15025 15026 // Certain elements can have dimension info if we invisibly show them 15027 // but it must have a current display style that would benefit 15028 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 15029 15030 // Support: Safari 8+ 15031 // Table columns in Safari have non-zero offsetWidth & zero 15032 // getBoundingClientRect().width unless display is changed. 15033 // Support: IE <=11 only 15034 // Running getBoundingClientRect on a disconnected node 15035 // in IE throws an error. 15036 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? 15037 swap( elem, cssShow, function() { 15038 return getWidthOrHeight( elem, dimension, extra ); 15039 } ) : 15040 getWidthOrHeight( elem, dimension, extra ); 15041 } 15042 }, 15043 15044 set: function( elem, value, extra ) { 15045 var matches, 15046 styles = getStyles( elem ), 15047 15048 // Only read styles.position if the test has a chance to fail 15049 // to avoid forcing a reflow. 15050 scrollboxSizeBuggy = !support.scrollboxSize() && 15051 styles.position === "absolute", 15052 15053 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) 15054 boxSizingNeeded = scrollboxSizeBuggy || extra, 15055 isBorderBox = boxSizingNeeded && 15056 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 15057 subtract = extra ? 15058 boxModelAdjustment( 15059 elem, 15060 dimension, 15061 extra, 15062 isBorderBox, 15063 styles 15064 ) : 15065 0; 15066 15067 // Account for unreliable border-box dimensions by comparing offset* to computed and 15068 // faking a content-box to get border and padding (gh-3699) 15069 if ( isBorderBox && scrollboxSizeBuggy ) { 15070 subtract -= Math.ceil( 15071 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 15072 parseFloat( styles[ dimension ] ) - 15073 boxModelAdjustment( elem, dimension, "border", false, styles ) - 15074 0.5 15075 ); 15076 } 15077 15078 // Convert to pixels if value adjustment is needed 15079 if ( subtract && ( matches = rcssNum.exec( value ) ) && 15080 ( matches[ 3 ] || "px" ) !== "px" ) { 15081 15082 elem.style[ dimension ] = value; 15083 value = jQuery.css( elem, dimension ); 15084 } 15085 15086 return setPositiveNumber( elem, value, subtract ); 15087 } 15088 }; 15089 } ); 15090 15091 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 15092 function( elem, computed ) { 15093 if ( computed ) { 15094 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || 15095 elem.getBoundingClientRect().left - 15096 swap( elem, { marginLeft: 0 }, function() { 15097 return elem.getBoundingClientRect().left; 15098 } ) 15099 ) + "px"; 15100 } 15101 } 15102 ); 15103 15104// These hooks are used by animate to expand properties 15105 jQuery.each( { 15106 margin: "", 15107 padding: "", 15108 border: "Width" 15109 }, function( prefix, suffix ) { 15110 jQuery.cssHooks[ prefix + suffix ] = { 15111 expand: function( value ) { 15112 var i = 0, 15113 expanded = {}, 15114 15115 // Assumes a single number if not a string 15116 parts = typeof value === "string" ? value.split( " " ) : [ value ]; 15117 15118 for ( ; i < 4; i++ ) { 15119 expanded[ prefix + cssExpand[ i ] + suffix ] = 15120 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 15121 } 15122 15123 return expanded; 15124 } 15125 }; 15126 15127 if ( prefix !== "margin" ) { 15128 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 15129 } 15130 } ); 15131 15132 jQuery.fn.extend( { 15133 css: function( name, value ) { 15134 return access( this, function( elem, name, value ) { 15135 var styles, len, 15136 map = {}, 15137 i = 0; 15138 15139 if ( Array.isArray( name ) ) { 15140 styles = getStyles( elem ); 15141 len = name.length; 15142 15143 for ( ; i < len; i++ ) { 15144 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 15145 } 15146 15147 return map; 15148 } 15149 15150 return value !== undefined ? 15151 jQuery.style( elem, name, value ) : 15152 jQuery.css( elem, name ); 15153 }, name, value, arguments.length > 1 ); 15154 } 15155 } ); 15156 15157 15158 function Tween( elem, options, prop, end, easing ) { 15159 return new Tween.prototype.init( elem, options, prop, end, easing ); 15160 } 15161 jQuery.Tween = Tween; 15162 15163 Tween.prototype = { 15164 constructor: Tween, 15165 init: function( elem, options, prop, end, easing, unit ) { 15166 this.elem = elem; 15167 this.prop = prop; 15168 this.easing = easing || jQuery.easing._default; 15169 this.options = options; 15170 this.start = this.now = this.cur(); 15171 this.end = end; 15172 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 15173 }, 15174 cur: function() { 15175 var hooks = Tween.propHooks[ this.prop ]; 15176 15177 return hooks && hooks.get ? 15178 hooks.get( this ) : 15179 Tween.propHooks._default.get( this ); 15180 }, 15181 run: function( percent ) { 15182 var eased, 15183 hooks = Tween.propHooks[ this.prop ]; 15184 15185 if ( this.options.duration ) { 15186 this.pos = eased = jQuery.easing[ this.easing ]( 15187 percent, this.options.duration * percent, 0, 1, this.options.duration 15188 ); 15189 } else { 15190 this.pos = eased = percent; 15191 } 15192 this.now = ( this.end - this.start ) * eased + this.start; 15193 15194 if ( this.options.step ) { 15195 this.options.step.call( this.elem, this.now, this ); 15196 } 15197 15198 if ( hooks && hooks.set ) { 15199 hooks.set( this ); 15200 } else { 15201 Tween.propHooks._default.set( this ); 15202 } 15203 return this; 15204 } 15205 }; 15206 15207 Tween.prototype.init.prototype = Tween.prototype; 15208 15209 Tween.propHooks = { 15210 _default: { 15211 get: function( tween ) { 15212 var result; 15213 15214 // Use a property on the element directly when it is not a DOM element, 15215 // or when there is no matching style property that exists. 15216 if ( tween.elem.nodeType !== 1 || 15217 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 15218 return tween.elem[ tween.prop ]; 15219 } 15220 15221 // Passing an empty string as a 3rd parameter to .css will automatically 15222 // attempt a parseFloat and fallback to a string if the parse fails. 15223 // Simple values such as "10px" are parsed to Float; 15224 // complex values such as "rotate(1rad)" are returned as-is. 15225 result = jQuery.css( tween.elem, tween.prop, "" ); 15226 15227 // Empty strings, null, undefined and "auto" are converted to 0. 15228 return !result || result === "auto" ? 0 : result; 15229 }, 15230 set: function( tween ) { 15231 15232 // Use step hook for back compat. 15233 // Use cssHook if its there. 15234 // Use .style if available and use plain properties where available. 15235 if ( jQuery.fx.step[ tween.prop ] ) { 15236 jQuery.fx.step[ tween.prop ]( tween ); 15237 } else if ( tween.elem.nodeType === 1 && ( 15238 jQuery.cssHooks[ tween.prop ] || 15239 tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { 15240 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 15241 } else { 15242 tween.elem[ tween.prop ] = tween.now; 15243 } 15244 } 15245 } 15246 }; 15247 15248// Support: IE <=9 only 15249// Panic based approach to setting things on disconnected nodes 15250 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 15251 set: function( tween ) { 15252 if ( tween.elem.nodeType && tween.elem.parentNode ) { 15253 tween.elem[ tween.prop ] = tween.now; 15254 } 15255 } 15256 }; 15257 15258 jQuery.easing = { 15259 linear: function( p ) { 15260 return p; 15261 }, 15262 swing: function( p ) { 15263 return 0.5 - Math.cos( p * Math.PI ) / 2; 15264 }, 15265 _default: "swing" 15266 }; 15267 15268 jQuery.fx = Tween.prototype.init; 15269 15270// Back compat <1.8 extension point 15271 jQuery.fx.step = {}; 15272 15273 15274 15275 15276 var 15277 fxNow, inProgress, 15278 rfxtypes = /^(?:toggle|show|hide)$/, 15279 rrun = /queueHooks$/; 15280 15281 function schedule() { 15282 if ( inProgress ) { 15283 if ( document.hidden === false && window.requestAnimationFrame ) { 15284 window.requestAnimationFrame( schedule ); 15285 } else { 15286 window.setTimeout( schedule, jQuery.fx.interval ); 15287 } 15288 15289 jQuery.fx.tick(); 15290 } 15291 } 15292 15293// Animations created synchronously will run synchronously 15294 function createFxNow() { 15295 window.setTimeout( function() { 15296 fxNow = undefined; 15297 } ); 15298 return ( fxNow = Date.now() ); 15299 } 15300 15301// Generate parameters to create a standard animation 15302 function genFx( type, includeWidth ) { 15303 var which, 15304 i = 0, 15305 attrs = { height: type }; 15306 15307 // If we include width, step value is 1 to do all cssExpand values, 15308 // otherwise step value is 2 to skip over Left and Right 15309 includeWidth = includeWidth ? 1 : 0; 15310 for ( ; i < 4; i += 2 - includeWidth ) { 15311 which = cssExpand[ i ]; 15312 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 15313 } 15314 15315 if ( includeWidth ) { 15316 attrs.opacity = attrs.width = type; 15317 } 15318 15319 return attrs; 15320 } 15321 15322 function createTween( value, prop, animation ) { 15323 var tween, 15324 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 15325 index = 0, 15326 length = collection.length; 15327 for ( ; index < length; index++ ) { 15328 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 15329 15330 // We're done with this property 15331 return tween; 15332 } 15333 } 15334 } 15335 15336 function defaultPrefilter( elem, props, opts ) { 15337 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, 15338 isBox = "width" in props || "height" in props, 15339 anim = this, 15340 orig = {}, 15341 style = elem.style, 15342 hidden = elem.nodeType && isHiddenWithinTree( elem ), 15343 dataShow = dataPriv.get( elem, "fxshow" ); 15344 15345 // Queue-skipping animations hijack the fx hooks 15346 if ( !opts.queue ) { 15347 hooks = jQuery._queueHooks( elem, "fx" ); 15348 if ( hooks.unqueued == null ) { 15349 hooks.unqueued = 0; 15350 oldfire = hooks.empty.fire; 15351 hooks.empty.fire = function() { 15352 if ( !hooks.unqueued ) { 15353 oldfire(); 15354 } 15355 }; 15356 } 15357 hooks.unqueued++; 15358 15359 anim.always( function() { 15360 15361 // Ensure the complete handler is called before this completes 15362 anim.always( function() { 15363 hooks.unqueued--; 15364 if ( !jQuery.queue( elem, "fx" ).length ) { 15365 hooks.empty.fire(); 15366 } 15367 } ); 15368 } ); 15369 } 15370 15371 // Detect show/hide animations 15372 for ( prop in props ) { 15373 value = props[ prop ]; 15374 if ( rfxtypes.test( value ) ) { 15375 delete props[ prop ]; 15376 toggle = toggle || value === "toggle"; 15377 if ( value === ( hidden ? "hide" : "show" ) ) { 15378 15379 // Pretend to be hidden if this is a "show" and 15380 // there is still data from a stopped show/hide 15381 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 15382 hidden = true; 15383 15384 // Ignore all other no-op show/hide data 15385 } else { 15386 continue; 15387 } 15388 } 15389 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 15390 } 15391 } 15392 15393 // Bail out if this is a no-op like .hide().hide() 15394 propTween = !jQuery.isEmptyObject( props ); 15395 if ( !propTween && jQuery.isEmptyObject( orig ) ) { 15396 return; 15397 } 15398 15399 // Restrict "overflow" and "display" styles during box animations 15400 if ( isBox && elem.nodeType === 1 ) { 15401
vendor: 4,218 bytes, lines 15402-15557
15402 // Support: IE <=9 - 11, Edge 12 - 15 15403 // Record all 3 overflow attributes because IE does not infer the shorthand 15404 // from identically-valued overflowX and overflowY and Edge just mirrors 15405 // the overflowX value there. 15406 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 15407 15408 // Identify a display type, preferring old show/hide data over the CSS cascade 15409 restoreDisplay = dataShow && dataShow.display; 15410 if ( restoreDisplay == null ) { 15411 restoreDisplay = dataPriv.get( elem, "display" ); 15412 } 15413 display = jQuery.css( elem, "display" ); 15414 if ( display === "none" ) { 15415 if ( restoreDisplay ) { 15416 display = restoreDisplay; 15417 } else { 15418 15419 // Get nonempty value(s) by temporarily forcing visibility 15420 showHide( [ elem ], true ); 15421 restoreDisplay = elem.style.display || restoreDisplay; 15422 display = jQuery.css( elem, "display" ); 15423 showHide( [ elem ] ); 15424 } 15425 } 15426 15427 // Animate inline elements as inline-block 15428 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { 15429 if ( jQuery.css( elem, "float" ) === "none" ) { 15430 15431 // Restore the original display value at the end of pure show/hide animations 15432 if ( !propTween ) { 15433 anim.done( function() { 15434 style.display = restoreDisplay; 15435 } ); 15436 if ( restoreDisplay == null ) { 15437 display = style.display; 15438 restoreDisplay = display === "none" ? "" : display; 15439 } 15440 } 15441 style.display = "inline-block"; 15442 } 15443 } 15444 } 15445 15446 if ( opts.overflow ) { 15447 style.overflow = "hidden"; 15448 anim.always( function() { 15449 style.overflow = opts.overflow[ 0 ]; 15450 style.overflowX = opts.overflow[ 1 ]; 15451 style.overflowY = opts.overflow[ 2 ]; 15452 } ); 15453 } 15454 15455 // Implement show/hide animations 15456 propTween = false; 15457 for ( prop in orig ) { 15458 15459 // General show/hide setup for this element animation 15460 if ( !propTween ) { 15461 if ( dataShow ) { 15462 if ( "hidden" in dataShow ) { 15463 hidden = dataShow.hidden; 15464 } 15465 } else { 15466 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); 15467 } 15468 15469 // Store hidden/visible for toggle so `.stop().toggle()` "reverses" 15470 if ( toggle ) { 15471 dataShow.hidden = !hidden; 15472 } 15473 15474 // Show elements before animating them 15475 if ( hidden ) { 15476 showHide( [ elem ], true ); 15477 } 15478 15479 /* eslint-disable no-loop-func */ 15480 15481 anim.done( function() { 15482 15483 /* eslint-enable no-loop-func */ 15484 15485 // The final step of a "hide" animation is actually hiding the element 15486 if ( !hidden ) { 15487 showHide( [ elem ] ); 15488 } 15489 dataPriv.remove( elem, "fxshow" ); 15490 for ( prop in orig ) { 15491 jQuery.style( elem, prop, orig[ prop ] ); 15492 } 15493 } ); 15494 } 15495 15496 // Per-property setup 15497 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 15498 if ( !( prop in dataShow ) ) { 15499 dataShow[ prop ] = propTween.start; 15500 if ( hidden ) { 15501 propTween.end = propTween.start; 15502 propTween.start = 0; 15503 } 15504 } 15505 } 15506 } 15507 15508 function propFilter( props, specialEasing ) { 15509 var index, name, easing, value, hooks; 15510 15511 // camelCase, specialEasing and expand cssHook pass 15512 for ( index in props ) { 15513 name = camelCase( index ); 15514 easing = specialEasing[ name ]; 15515 value = props[ index ]; 15516 if ( Array.isArray( value ) ) { 15517 easing = value[ 1 ]; 15518 value = props[ index ] = value[ 0 ]; 15519 } 15520 15521 if ( index !== name ) { 15522 props[ name ] = value; 15523 delete props[ index ]; 15524 } 15525 15526 hooks = jQuery.cssHooks[ name ]; 15527 if ( hooks && "expand" in hooks ) { 15528 value = hooks.expand( value ); 15529 delete props[ name ]; 15530 15531 // Not quite $.extend, this won't overwrite existing keys. 15532 // Reusing 'index' because we have the correct "name" 15533 for ( index in value ) { 15534 if ( !( index in props ) ) { 15535 props[ index ] = value[ index ]; 15536 specialEasing[ index ] = easing; 15537 } 15538 } 15539 } else { 15540 specialEasing[ name ] = easing; 15541 } 15542 } 15543 } 15544 15545 function Animation( elem, properties, options ) { 15546 var result, 15547 stopped, 15548 index = 0, 15549 length = Animation.prefilters.length, 15550 deferred = jQuery.Deferred().always( function() { 15551 15552 // Don't match elem in the :animated selector 15553 delete tick.elem; 15554 } ), 15555 tick = function() { 15556 if ( stopped ) { 15557 return false;
vendor: 39,506 bytes, lines 15558-17112
15558 } 15559 var currentTime = fxNow || createFxNow(), 15560 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 15561 15562 // Support: Android 2.3 only 15563 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497) 15564 temp = remaining / animation.duration || 0, 15565 percent = 1 - temp, 15566 index = 0, 15567 length = animation.tweens.length; 15568 15569 for ( ; index < length; index++ ) { 15570 animation.tweens[ index ].run( percent ); 15571 } 15572 15573 deferred.notifyWith( elem, [ animation, percent, remaining ] ); 15574 15575 // If there's more to do, yield 15576 if ( percent < 1 && length ) { 15577 return remaining; 15578 } 15579 15580 // If this was an empty animation, synthesize a final progress notification 15581 if ( !length ) { 15582 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 15583 } 15584 15585 // Resolve the animation and report its conclusion 15586 deferred.resolveWith( elem, [ animation ] ); 15587 return false; 15588 }, 15589 animation = deferred.promise( { 15590 elem: elem, 15591 props: jQuery.extend( {}, properties ), 15592 opts: jQuery.extend( true, { 15593 specialEasing: {}, 15594 easing: jQuery.easing._default 15595 }, options ), 15596 originalProperties: properties, 15597 originalOptions: options, 15598 startTime: fxNow || createFxNow(), 15599 duration: options.duration, 15600 tweens: [], 15601 createTween: function( prop, end ) { 15602 var tween = jQuery.Tween( elem, animation.opts, prop, end, 15603 animation.opts.specialEasing[ prop ] || animation.opts.easing ); 15604 animation.tweens.push( tween ); 15605 return tween; 15606 }, 15607 stop: function( gotoEnd ) { 15608 var index = 0, 15609 15610 // If we are going to the end, we want to run all the tweens 15611 // otherwise we skip this part 15612 length = gotoEnd ? animation.tweens.length : 0; 15613 if ( stopped ) { 15614 return this; 15615 } 15616 stopped = true; 15617 for ( ; index < length; index++ ) { 15618 animation.tweens[ index ].run( 1 ); 15619 } 15620 15621 // Resolve when we played the last frame; otherwise, reject 15622 if ( gotoEnd ) { 15623 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 15624 deferred.resolveWith( elem, [ animation, gotoEnd ] ); 15625 } else { 15626 deferred.rejectWith( elem, [ animation, gotoEnd ] ); 15627 } 15628 return this; 15629 } 15630 } ), 15631 props = animation.props; 15632 15633 propFilter( props, animation.opts.specialEasing ); 15634 15635 for ( ; index < length; index++ ) { 15636 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 15637 if ( result ) { 15638 if ( isFunction( result.stop ) ) { 15639 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 15640 result.stop.bind( result ); 15641 } 15642 return result; 15643 } 15644 } 15645 15646 jQuery.map( props, createTween, animation ); 15647 15648 if ( isFunction( animation.opts.start ) ) { 15649 animation.opts.start.call( elem, animation ); 15650 } 15651 15652 // Attach callbacks from options 15653 animation 15654 .progress( animation.opts.progress ) 15655 .done( animation.opts.done, animation.opts.complete ) 15656 .fail( animation.opts.fail ) 15657 .always( animation.opts.always ); 15658 15659 jQuery.fx.timer( 15660 jQuery.extend( tick, { 15661 elem: elem, 15662 anim: animation, 15663 queue: animation.opts.queue 15664 } ) 15665 ); 15666 15667 return animation; 15668 } 15669 15670 jQuery.Animation = jQuery.extend( Animation, { 15671 15672 tweeners: { 15673 "*": [ function( prop, value ) { 15674 var tween = this.createTween( prop, value ); 15675 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 15676 return tween; 15677 } ] 15678 }, 15679 15680 tweener: function( props, callback ) { 15681 if ( isFunction( props ) ) { 15682 callback = props; 15683 props = [ "*" ]; 15684 } else { 15685 props = props.match( rnothtmlwhite ); 15686 } 15687 15688 var prop, 15689 index = 0, 15690 length = props.length; 15691 15692 for ( ; index < length; index++ ) { 15693 prop = props[ index ]; 15694 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 15695 Animation.tweeners[ prop ].unshift( callback ); 15696 } 15697 }, 15698 15699 prefilters: [ defaultPrefilter ], 15700 15701 prefilter: function( callback, prepend ) { 15702 if ( prepend ) { 15703 Animation.prefilters.unshift( callback ); 15704 } else { 15705 Animation.prefilters.push( callback ); 15706 } 15707 } 15708 } ); 15709 15710 jQuery.speed = function( speed, easing, fn ) { 15711 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 15712 complete: fn || !fn && easing || 15713 isFunction( speed ) && speed, 15714 duration: speed, 15715 easing: fn && easing || easing && !isFunction( easing ) && easing 15716 }; 15717 15718 // Go to the end state if fx are off 15719 if ( jQuery.fx.off ) { 15720 opt.duration = 0; 15721 15722 } else { 15723 if ( typeof opt.duration !== "number" ) { 15724 if ( opt.duration in jQuery.fx.speeds ) { 15725 opt.duration = jQuery.fx.speeds[ opt.duration ]; 15726 15727 } else { 15728 opt.duration = jQuery.fx.speeds._default; 15729 } 15730 } 15731 } 15732 15733 // Normalize opt.queue - true/undefined/null -> "fx" 15734 if ( opt.queue == null || opt.queue === true ) { 15735 opt.queue = "fx"; 15736 } 15737 15738 // Queueing 15739 opt.old = opt.complete; 15740 15741 opt.complete = function() { 15742 if ( isFunction( opt.old ) ) { 15743 opt.old.call( this ); 15744 } 15745 15746 if ( opt.queue ) { 15747 jQuery.dequeue( this, opt.queue ); 15748 } 15749 }; 15750 15751 return opt; 15752 }; 15753 15754 jQuery.fn.extend( { 15755 fadeTo: function( speed, to, easing, callback ) { 15756 15757 // Show any hidden elements after setting opacity to 0 15758 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() 15759 15760 // Animate to the value specified 15761 .end().animate( { opacity: to }, speed, easing, callback ); 15762 }, 15763 animate: function( prop, speed, easing, callback ) { 15764 var empty = jQuery.isEmptyObject( prop ), 15765 optall = jQuery.speed( speed, easing, callback ), 15766 doAnimation = function() { 15767 15768 // Operate on a copy of prop so per-property easing won't be lost 15769 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 15770 15771 // Empty animations, or finishing resolves immediately 15772 if ( empty || dataPriv.get( this, "finish" ) ) { 15773 anim.stop( true ); 15774 } 15775 }; 15776 15777 doAnimation.finish = doAnimation; 15778 15779 return empty || optall.queue === false ? 15780 this.each( doAnimation ) : 15781 this.queue( optall.queue, doAnimation ); 15782 }, 15783 stop: function( type, clearQueue, gotoEnd ) { 15784 var stopQueue = function( hooks ) { 15785 var stop = hooks.stop; 15786 delete hooks.stop; 15787 stop( gotoEnd ); 15788 }; 15789 15790 if ( typeof type !== "string" ) { 15791 gotoEnd = clearQueue; 15792 clearQueue = type; 15793 type = undefined; 15794 } 15795 if ( clearQueue ) { 15796 this.queue( type || "fx", [] ); 15797 } 15798 15799 return this.each( function() { 15800 var dequeue = true, 15801 index = type != null && type + "queueHooks", 15802 timers = jQuery.timers, 15803 data = dataPriv.get( this ); 15804 15805 if ( index ) { 15806 if ( data[ index ] && data[ index ].stop ) { 15807 stopQueue( data[ index ] ); 15808 } 15809 } else { 15810 for ( index in data ) { 15811 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 15812 stopQueue( data[ index ] ); 15813 } 15814 } 15815 } 15816 15817 for ( index = timers.length; index--; ) { 15818 if ( timers[ index ].elem === this && 15819 ( type == null || timers[ index ].queue === type ) ) { 15820 15821 timers[ index ].anim.stop( gotoEnd ); 15822 dequeue = false; 15823 timers.splice( index, 1 ); 15824 } 15825 } 15826 15827 // Start the next in the queue if the last step wasn't forced. 15828 // Timers currently will call their complete callbacks, which 15829 // will dequeue but only if they were gotoEnd. 15830 if ( dequeue || !gotoEnd ) { 15831 jQuery.dequeue( this, type ); 15832 } 15833 } ); 15834 }, 15835 finish: function( type ) { 15836 if ( type !== false ) { 15837 type = type || "fx"; 15838 } 15839 return this.each( function() { 15840 var index, 15841 data = dataPriv.get( this ), 15842 queue = data[ type + "queue" ], 15843 hooks = data[ type + "queueHooks" ], 15844 timers = jQuery.timers, 15845 length = queue ? queue.length : 0; 15846 15847 // Enable finishing flag on private data 15848 data.finish = true; 15849 15850 // Empty the queue first 15851 jQuery.queue( this, type, [] ); 15852 15853 if ( hooks && hooks.stop ) { 15854 hooks.stop.call( this, true ); 15855 } 15856 15857 // Look for any active animations, and finish them 15858 for ( index = timers.length; index--; ) { 15859 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 15860 timers[ index ].anim.stop( true ); 15861 timers.splice( index, 1 ); 15862 } 15863 } 15864 15865 // Look for any animations in the old queue and finish them 15866 for ( index = 0; index < length; index++ ) { 15867 if ( queue[ index ] && queue[ index ].finish ) { 15868 queue[ index ].finish.call( this ); 15869 } 15870 } 15871 15872 // Turn off finishing flag 15873 delete data.finish; 15874 } ); 15875 } 15876 } ); 15877 15878 jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { 15879 var cssFn = jQuery.fn[ name ]; 15880 jQuery.fn[ name ] = function( speed, easing, callback ) { 15881 return speed == null || typeof speed === "boolean" ? 15882 cssFn.apply( this, arguments ) : 15883 this.animate( genFx( name, true ), speed, easing, callback ); 15884 }; 15885 } ); 15886 15887// Generate shortcuts for custom animations 15888 jQuery.each( { 15889 slideDown: genFx( "show" ), 15890 slideUp: genFx( "hide" ), 15891 slideToggle: genFx( "toggle" ), 15892 fadeIn: { opacity: "show" }, 15893 fadeOut: { opacity: "hide" }, 15894 fadeToggle: { opacity: "toggle" } 15895 }, function( name, props ) { 15896 jQuery.fn[ name ] = function( speed, easing, callback ) { 15897 return this.animate( props, speed, easing, callback ); 15898 }; 15899 } ); 15900 15901 jQuery.timers = []; 15902 jQuery.fx.tick = function() { 15903 var timer, 15904 i = 0, 15905 timers = jQuery.timers; 15906 15907 fxNow = Date.now(); 15908 15909 for ( ; i < timers.length; i++ ) { 15910 timer = timers[ i ]; 15911 15912 // Run the timer and safely remove it when done (allowing for external removal) 15913 if ( !timer() && timers[ i ] === timer ) { 15914 timers.splice( i--, 1 ); 15915 } 15916 } 15917 15918 if ( !timers.length ) { 15919 jQuery.fx.stop(); 15920 } 15921 fxNow = undefined; 15922 }; 15923 15924 jQuery.fx.timer = function( timer ) { 15925 jQuery.timers.push( timer ); 15926 jQuery.fx.start(); 15927 }; 15928 15929 jQuery.fx.interval = 13; 15930 jQuery.fx.start = function() { 15931 if ( inProgress ) { 15932 return; 15933 } 15934 15935 inProgress = true; 15936 schedule(); 15937 }; 15938 15939 jQuery.fx.stop = function() { 15940 inProgress = null; 15941 }; 15942 15943 jQuery.fx.speeds = { 15944 slow: 600, 15945 fast: 200, 15946 15947 // Default speed 15948 _default: 400 15949 }; 15950 15951 15952// Based off of the plugin by Clint Helfers, with permission. 15953 jQuery.fn.delay = function( time, type ) { 15954 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 15955 type = type || "fx"; 15956 15957 return this.queue( type, function( next, hooks ) { 15958 var timeout = window.setTimeout( next, time ); 15959 hooks.stop = function() { 15960 window.clearTimeout( timeout ); 15961 }; 15962 } ); 15963 }; 15964 15965 15966 ( function() { 15967 var input = document.createElement( "input" ), 15968 select = document.createElement( "select" ), 15969 opt = select.appendChild( document.createElement( "option" ) ); 15970 15971 input.type = "checkbox"; 15972 15973 // Support: Android <=4.3 only 15974 // Default value for a checkbox should be "on" 15975 support.checkOn = input.value !== ""; 15976 15977 // Support: IE <=11 only 15978 // Must access selectedIndex to make default options select 15979 support.optSelected = opt.selected; 15980 15981 // Support: IE <=11 only 15982 // An input loses its value after becoming a radio 15983 input = document.createElement( "input" ); 15984 input.value = "t"; 15985 input.type = "radio"; 15986 support.radioValue = input.value === "t"; 15987 } )(); 15988 15989 15990 var boolHook, 15991 attrHandle = jQuery.expr.attrHandle; 15992 15993 jQuery.fn.extend( { 15994 attr: function( name, value ) { 15995 return access( this, jQuery.attr, name, value, arguments.length > 1 ); 15996 }, 15997 15998 removeAttr: function( name ) { 15999 return this.each( function() { 16000 jQuery.removeAttr( this, name ); 16001 } ); 16002 } 16003 } ); 16004 16005 jQuery.extend( { 16006 attr: function( elem, name, value ) { 16007 var ret, hooks, 16008 nType = elem.nodeType; 16009 16010 // Don't get/set attributes on text, comment and attribute nodes 16011 if ( nType === 3 || nType === 8 || nType === 2 ) { 16012 return; 16013 } 16014 16015 // Fallback to prop when attributes are not supported 16016 if ( typeof elem.getAttribute === "undefined" ) { 16017 return jQuery.prop( elem, name, value ); 16018 } 16019 16020 // Attribute hooks are determined by the lowercase version 16021 // Grab necessary hook if one is defined 16022 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 16023 hooks = jQuery.attrHooks[ name.toLowerCase() ] || 16024 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 16025 } 16026 16027 if ( value !== undefined ) { 16028 if ( value === null ) { 16029 jQuery.removeAttr( elem, name ); 16030 return; 16031 } 16032 16033 if ( hooks && "set" in hooks && 16034 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 16035 return ret; 16036 } 16037 16038 elem.setAttribute( name, value + "" ); 16039 return value; 16040 } 16041 16042 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 16043 return ret; 16044 } 16045 16046 ret = jQuery.find.attr( elem, name ); 16047 16048 // Non-existent attributes return null, we normalize to undefined 16049 return ret == null ? undefined : ret; 16050 }, 16051 16052 attrHooks: { 16053 type: { 16054 set: function( elem, value ) { 16055 if ( !support.radioValue && value === "radio" && 16056 nodeName( elem, "input" ) ) { 16057 var val = elem.value; 16058 elem.setAttribute( "type", value ); 16059 if ( val ) { 16060 elem.value = val; 16061 } 16062 return value; 16063 } 16064 } 16065 } 16066 }, 16067 16068 removeAttr: function( elem, value ) { 16069 var name, 16070 i = 0, 16071 16072 // Attribute names can contain non-HTML whitespace characters 16073 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 16074 attrNames = value && value.match( rnothtmlwhite ); 16075 16076 if ( attrNames && elem.nodeType === 1 ) { 16077 while ( ( name = attrNames[ i++ ] ) ) { 16078 elem.removeAttribute( name ); 16079 } 16080 } 16081 } 16082 } ); 16083 16084// Hooks for boolean attributes 16085 boolHook = { 16086 set: function( elem, value, name ) { 16087 if ( value === false ) { 16088 16089 // Remove boolean attributes when set to false 16090 jQuery.removeAttr( elem, name ); 16091 } else { 16092 elem.setAttribute( name, name ); 16093 } 16094 return name; 16095 } 16096 }; 16097 16098 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { 16099 var getter = attrHandle[ name ] || jQuery.find.attr; 16100 16101 attrHandle[ name ] = function( elem, name, isXML ) { 16102 var ret, handle, 16103 lowercaseName = name.toLowerCase(); 16104 16105 if ( !isXML ) { 16106 16107 // Avoid an infinite loop by temporarily removing this function from the getter 16108 handle = attrHandle[ lowercaseName ]; 16109 attrHandle[ lowercaseName ] = ret; 16110 ret = getter( elem, name, isXML ) != null ? 16111 lowercaseName : 16112 null; 16113 attrHandle[ lowercaseName ] = handle; 16114 } 16115 return ret; 16116 }; 16117 } ); 16118 16119 16120 16121 16122 var rfocusable = /^(?:input|select|textarea|button)$/i, 16123 rclickable = /^(?:a|area)$/i; 16124 16125 jQuery.fn.extend( { 16126 prop: function( name, value ) { 16127 return access( this, jQuery.prop, name, value, arguments.length > 1 ); 16128 }, 16129 16130 removeProp: function( name ) { 16131 return this.each( function() { 16132 delete this[ jQuery.propFix[ name ] || name ]; 16133 } ); 16134 } 16135 } ); 16136 16137 jQuery.extend( { 16138 prop: function( elem, name, value ) { 16139 var ret, hooks, 16140 nType = elem.nodeType; 16141 16142 // Don't get/set properties on text, comment and attribute nodes 16143 if ( nType === 3 || nType === 8 || nType === 2 ) { 16144 return; 16145 } 16146 16147 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 16148 16149 // Fix name and attach hooks 16150 name = jQuery.propFix[ name ] || name; 16151 hooks = jQuery.propHooks[ name ]; 16152 } 16153 16154 if ( value !== undefined ) { 16155 if ( hooks && "set" in hooks && 16156 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 16157 return ret; 16158 } 16159 16160 return ( elem[ name ] = value ); 16161 } 16162 16163 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 16164 return ret; 16165 } 16166 16167 return elem[ name ]; 16168 }, 16169 16170 propHooks: { 16171 tabIndex: { 16172 get: function( elem ) { 16173 16174 // Support: IE <=9 - 11 only 16175 // elem.tabIndex doesn't always return the 16176 // correct value when it hasn't been explicitly set 16177 // Use proper attribute retrieval (trac-12072) 16178 var tabindex = jQuery.find.attr( elem, "tabindex" ); 16179 16180 if ( tabindex ) { 16181 return parseInt( tabindex, 10 ); 16182 } 16183 16184 if ( 16185 rfocusable.test( elem.nodeName ) || 16186 rclickable.test( elem.nodeName ) && 16187 elem.href 16188 ) { 16189 return 0; 16190 } 16191 16192 return -1; 16193 } 16194 } 16195 }, 16196 16197 propFix: { 16198 "for": "htmlFor", 16199 "class": "className" 16200 } 16201 } ); 16202 16203// Support: IE <=11 only 16204// Accessing the selectedIndex property 16205// forces the browser to respect setting selected 16206// on the option 16207// The getter ensures a default option is selected 16208// when in an optgroup 16209// eslint rule "no-unused-expressions" is disabled for this code 16210// since it considers such accessions noop 16211 if ( !support.optSelected ) { 16212 jQuery.propHooks.selected = { 16213 get: function( elem ) { 16214 16215 /* eslint no-unused-expressions: "off" */ 16216 16217 var parent = elem.parentNode; 16218 if ( parent && parent.parentNode ) { 16219 parent.parentNode.selectedIndex; 16220 } 16221 return null; 16222 }, 16223 set: function( elem ) { 16224 16225 /* eslint no-unused-expressions: "off" */ 16226 16227 var parent = elem.parentNode; 16228 if ( parent ) { 16229 parent.selectedIndex; 16230 16231 if ( parent.parentNode ) { 16232 parent.parentNode.selectedIndex; 16233 } 16234 } 16235 } 16236 }; 16237 } 16238 16239 jQuery.each( [ 16240 "tabIndex", 16241 "readOnly", 16242 "maxLength", 16243 "cellSpacing", 16244 "cellPadding", 16245 "rowSpan", 16246 "colSpan", 16247 "useMap", 16248 "frameBorder", 16249 "contentEditable" 16250 ], function() { 16251 jQuery.propFix[ this.toLowerCase() ] = this; 16252 } ); 16253 16254 16255 16256 16257 // Strip and collapse whitespace according to HTML spec 16258 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace 16259 function stripAndCollapse( value ) { 16260 var tokens = value.match( rnothtmlwhite ) || []; 16261 return tokens.join( " " ); 16262 } 16263 16264 16265 function getClass( elem ) { 16266 return elem.getAttribute && elem.getAttribute( "class" ) || ""; 16267 } 16268 16269 function classesToArray( value ) { 16270 if ( Array.isArray( value ) ) { 16271 return value; 16272 } 16273 if ( typeof value === "string" ) { 16274 return value.match( rnothtmlwhite ) || []; 16275 } 16276 return []; 16277 } 16278 16279 jQuery.fn.extend( { 16280 addClass: function( value ) { 16281 var classNames, cur, curValue, className, i, finalValue; 16282 16283 if ( isFunction( value ) ) { 16284 return this.each( function( j ) { 16285 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 16286 } ); 16287 } 16288 16289 classNames = classesToArray( value ); 16290 16291 if ( classNames.length ) { 16292 return this.each( function() { 16293 curValue = getClass( this ); 16294 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 16295 16296 if ( cur ) { 16297 for ( i = 0; i < classNames.length; i++ ) { 16298 className = classNames[ i ]; 16299 if ( cur.indexOf( " " + className + " " ) < 0 ) { 16300 cur += className + " "; 16301 } 16302 } 16303 16304 // Only assign if different to avoid unneeded rendering. 16305 finalValue = stripAndCollapse( cur ); 16306 if ( curValue !== finalValue ) { 16307 this.setAttribute( "class", finalValue ); 16308 } 16309 } 16310 } ); 16311 } 16312 16313 return this; 16314 }, 16315 16316 removeClass: function( value ) { 16317 var classNames, cur, curValue, className, i, finalValue; 16318 16319 if ( isFunction( value ) ) { 16320 return this.each( function( j ) { 16321 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 16322 } ); 16323 } 16324 16325 if ( !arguments.length ) { 16326 return this.attr( "class", "" ); 16327 } 16328 16329 classNames = classesToArray( value ); 16330 16331 if ( classNames.length ) { 16332 return this.each( function() { 16333 curValue = getClass( this ); 16334 16335 // This expression is here for better compressibility (see addClass) 16336 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 16337 16338 if ( cur ) { 16339 for ( i = 0; i < classNames.length; i++ ) { 16340 className = classNames[ i ]; 16341 16342 // Remove *all* instances 16343 while ( cur.indexOf( " " + className + " " ) > -1 ) { 16344 cur = cur.replace( " " + className + " ", " " ); 16345 } 16346 } 16347 16348 // Only assign if different to avoid unneeded rendering. 16349 finalValue = stripAndCollapse( cur ); 16350 if ( curValue !== finalValue ) { 16351 this.setAttribute( "class", finalValue ); 16352 } 16353 } 16354 } ); 16355 } 16356 16357 return this; 16358 }, 16359 16360 toggleClass: function( value, stateVal ) { 16361 var classNames, className, i, self, 16362 type = typeof value, 16363 isValidValue = type === "string" || Array.isArray( value ); 16364 16365 if ( isFunction( value ) ) { 16366 return this.each( function( i ) { 16367 jQuery( this ).toggleClass( 16368 value.call( this, i, getClass( this ), stateVal ), 16369 stateVal 16370 ); 16371 } ); 16372 } 16373 16374 if ( typeof stateVal === "boolean" && isValidValue ) { 16375 return stateVal ? this.addClass( value ) : this.removeClass( value ); 16376 } 16377 16378 classNames = classesToArray( value ); 16379 16380 return this.each( function() { 16381 if ( isValidValue ) { 16382 16383 // Toggle individual class names 16384 self = jQuery( this ); 16385 16386 for ( i = 0; i < classNames.length; i++ ) { 16387 className = classNames[ i ]; 16388 16389 // Check each className given, space separated list 16390 if ( self.hasClass( className ) ) { 16391 self.removeClass( className ); 16392 } else { 16393 self.addClass( className ); 16394 } 16395 } 16396 16397 // Toggle whole class name 16398 } else if ( value === undefined || type === "boolean" ) { 16399 className = getClass( this ); 16400 if ( className ) { 16401 16402 // Store className if set 16403 dataPriv.set( this, "__className__", className ); 16404 } 16405 16406 // If the element has a class name or if we're passed `false`, 16407 // then remove the whole classname (if there was one, the above saved it). 16408 // Otherwise bring back whatever was previously saved (if anything), 16409 // falling back to the empty string if nothing was stored. 16410 if ( this.setAttribute ) { 16411 this.setAttribute( "class", 16412 className || value === false ? 16413 "" : 16414 dataPriv.get( this, "__className__" ) || "" 16415 ); 16416 } 16417 } 16418 } ); 16419 }, 16420 16421 hasClass: function( selector ) { 16422 var className, elem, 16423 i = 0; 16424 16425 className = " " + selector + " "; 16426 while ( ( elem = this[ i++ ] ) ) { 16427 if ( elem.nodeType === 1 && 16428 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { 16429 return true; 16430 } 16431 } 16432 16433 return false; 16434 } 16435 } ); 16436 16437 16438 16439 16440 var rreturn = /\r/g; 16441 16442 jQuery.fn.extend( { 16443 val: function( value ) { 16444 var hooks, ret, valueIsFunction, 16445 elem = this[ 0 ]; 16446 16447 if ( !arguments.length ) { 16448 if ( elem ) { 16449 hooks = jQuery.valHooks[ elem.type ] || 16450 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 16451 16452 if ( hooks && 16453 "get" in hooks && 16454 ( ret = hooks.get( elem, "value" ) ) !== undefined 16455 ) { 16456 return ret; 16457 } 16458 16459 ret = elem.value; 16460 16461 // Handle most common string cases 16462 if ( typeof ret === "string" ) { 16463 return ret.replace( rreturn, "" ); 16464 } 16465 16466 // Handle cases where value is null/undef or number 16467 return ret == null ? "" : ret; 16468 } 16469 16470 return; 16471 } 16472 16473 valueIsFunction = isFunction( value ); 16474 16475 return this.each( function( i ) { 16476 var val; 16477 16478 if ( this.nodeType !== 1 ) { 16479 return; 16480 } 16481 16482 if ( valueIsFunction ) { 16483 val = value.call( this, i, jQuery( this ).val() ); 16484 } else { 16485 val = value; 16486 } 16487 16488 // Treat null/undefined as ""; convert numbers to string 16489 if ( val == null ) { 16490 val = ""; 16491 16492 } else if ( typeof val === "number" ) { 16493 val += ""; 16494 16495 } else if ( Array.isArray( val ) ) { 16496 val = jQuery.map( val, function( value ) { 16497 return value == null ? "" : value + ""; 16498 } ); 16499 } 16500 16501 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 16502 16503 // If set returns undefined, fall back to normal setting 16504 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 16505 this.value = val; 16506 } 16507 } ); 16508 } 16509 } ); 16510 16511 jQuery.extend( { 16512 valHooks: { 16513 option: { 16514 get: function( elem ) { 16515 16516 var val = jQuery.find.attr( elem, "value" ); 16517 return val != null ? 16518 val : 16519 16520 // Support: IE <=10 - 11 only 16521 // option.text throws exceptions (trac-14686, trac-14858) 16522 // Strip and collapse whitespace 16523 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 16524 stripAndCollapse( jQuery.text( elem ) ); 16525 } 16526 }, 16527 select: { 16528 get: function( elem ) { 16529 var value, option, i, 16530 options = elem.options, 16531 index = elem.selectedIndex, 16532 one = elem.type === "select-one", 16533 values = one ? null : [], 16534 max = one ? index + 1 : options.length; 16535 16536 if ( index < 0 ) { 16537 i = max; 16538 16539 } else { 16540 i = one ? index : 0; 16541 } 16542 16543 // Loop through all the selected options 16544 for ( ; i < max; i++ ) { 16545 option = options[ i ]; 16546 16547 // Support: IE <=9 only 16548 // IE8-9 doesn't update selected after form reset (trac-2551) 16549 if ( ( option.selected || i === index ) && 16550 16551 // Don't return options that are disabled or in a disabled optgroup 16552 !option.disabled && 16553 ( !option.parentNode.disabled || 16554 !nodeName( option.parentNode, "optgroup" ) ) ) { 16555 16556 // Get the specific value for the option 16557 value = jQuery( option ).val(); 16558 16559 // We don't need an array for one selects 16560 if ( one ) { 16561 return value; 16562 } 16563 16564 // Multi-Selects return an array 16565 values.push( value ); 16566 } 16567 } 16568 16569 return values; 16570 }, 16571 16572 set: function( elem, value ) { 16573 var optionSet, option, 16574 options = elem.options, 16575 values = jQuery.makeArray( value ), 16576 i = options.length; 16577 16578 while ( i-- ) { 16579 option = options[ i ]; 16580 16581 /* eslint-disable no-cond-assign */ 16582 16583 if ( option.selected = 16584 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 16585 ) { 16586 optionSet = true; 16587 } 16588 16589 /* eslint-enable no-cond-assign */ 16590 } 16591 16592 // Force browsers to behave consistently when non-matching value is set 16593 if ( !optionSet ) { 16594 elem.selectedIndex = -1; 16595 } 16596 return values; 16597 } 16598 } 16599 } 16600 } ); 16601 16602// Radios and checkboxes getter/setter 16603 jQuery.each( [ "radio", "checkbox" ], function() { 16604 jQuery.valHooks[ this ] = { 16605 set: function( elem, value ) { 16606 if ( Array.isArray( value ) ) { 16607 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 16608 } 16609 } 16610 }; 16611 if ( !support.checkOn ) { 16612 jQuery.valHooks[ this ].get = function( elem ) { 16613 return elem.getAttribute( "value" ) === null ? "on" : elem.value; 16614 }; 16615 } 16616 } ); 16617 16618 16619 16620 16621// Return jQuery for attributes-only inclusion 16622 var location = window.location; 16623 16624 var nonce = { guid: Date.now() }; 16625 16626 var rquery = ( /\?/ ); 16627 16628 16629 16630// Cross-browser xml parsing 16631 jQuery.parseXML = function( data ) { 16632 var xml, parserErrorElem; 16633 if ( !data || typeof data !== "string" ) { 16634 return null; 16635 } 16636 16637 // Support: IE 9 - 11 only 16638 // IE throws on parseFromString with invalid input. 16639 try { 16640 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 16641 } catch ( e ) {} 16642 16643 parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; 16644 if ( !xml || parserErrorElem ) { 16645 jQuery.error( "Invalid XML: " + ( 16646 parserErrorElem ? 16647 jQuery.map( parserErrorElem.childNodes, function( el ) { 16648 return el.textContent; 16649 } ).join( "\n" ) : 16650 data 16651 ) ); 16652 } 16653 return xml; 16654 }; 16655 16656 16657 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, 16658 stopPropagationCallback = function( e ) { 16659 e.stopPropagation(); 16660 }; 16661 16662 jQuery.extend( jQuery.event, { 16663 16664 trigger: function( event, data, elem, onlyHandlers ) { 16665 16666 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, 16667 eventPath = [ elem || document ], 16668 type = hasOwn.call( event, "type" ) ? event.type : event, 16669 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 16670 16671 cur = lastElement = tmp = elem = elem || document; 16672 16673 // Don't do events on text and comment nodes 16674 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 16675 return; 16676 } 16677 16678 // focus/blur morphs to focusin/out; ensure we're not firing them right now 16679 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 16680 return; 16681 } 16682 16683 if ( type.indexOf( "." ) > -1 ) { 16684 16685 // Namespaced trigger; create a regexp to match event type in handle() 16686 namespaces = type.split( "." ); 16687 type = namespaces.shift(); 16688 namespaces.sort(); 16689 } 16690 ontype = type.indexOf( ":" ) < 0 && "on" + type; 16691 16692 // Caller can pass in a jQuery.Event object, Object, or just an event type string 16693 event = event[ jQuery.expando ] ? 16694 event : 16695 new jQuery.Event( type, typeof event === "object" && event ); 16696 16697 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 16698 event.isTrigger = onlyHandlers ? 2 : 3; 16699 event.namespace = namespaces.join( "." ); 16700 event.rnamespace = event.namespace ? 16701 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 16702 null; 16703 16704 // Clean up the event in case it is being reused 16705 event.result = undefined; 16706 if ( !event.target ) { 16707 event.target = elem; 16708 } 16709 16710 // Clone any incoming data and prepend the event, creating the handler arg list 16711 data = data == null ? 16712 [ event ] : 16713 jQuery.makeArray( data, [ event ] ); 16714 16715 // Allow special events to draw outside the lines 16716 special = jQuery.event.special[ type ] || {}; 16717 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 16718 return; 16719 } 16720 16721 // Determine event propagation path in advance, per W3C events spec (trac-9951) 16722 // Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724) 16723 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { 16724 16725 bubbleType = special.delegateType || type; 16726 if ( !rfocusMorph.test( bubbleType + type ) ) { 16727 cur = cur.parentNode; 16728 } 16729 for ( ; cur; cur = cur.parentNode ) { 16730 eventPath.push( cur ); 16731 tmp = cur; 16732 } 16733 16734 // Only add window if we got to document (e.g., not plain obj or detached DOM) 16735 if ( tmp === ( elem.ownerDocument || document ) ) { 16736 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 16737 } 16738 } 16739 16740 // Fire handlers on the event path 16741 i = 0; 16742 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 16743 lastElement = cur; 16744 event.type = i > 1 ? 16745 bubbleType : 16746 special.bindType || type; 16747 16748 // jQuery handler 16749 handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] && 16750 dataPriv.get( cur, "handle" ); 16751 if ( handle ) { 16752 handle.apply( cur, data ); 16753 } 16754 16755 // Native handler 16756 handle = ontype && cur[ ontype ]; 16757 if ( handle && handle.apply && acceptData( cur ) ) { 16758 event.result = handle.apply( cur, data ); 16759 if ( event.result === false ) { 16760 event.preventDefault(); 16761 } 16762 } 16763 } 16764 event.type = type; 16765 16766 // If nobody prevented the default action, do it now 16767 if ( !onlyHandlers && !event.isDefaultPrevented() ) { 16768 16769 if ( ( !special._default || 16770 special._default.apply( eventPath.pop(), data ) === false ) && 16771 acceptData( elem ) ) { 16772 16773 // Call a native DOM method on the target with the same name as the event. 16774 // Don't do default actions on window, that's where global variables be (trac-6170) 16775 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { 16776 16777 // Don't re-trigger an onFOO event when we call its FOO() method 16778 tmp = elem[ ontype ]; 16779 16780 if ( tmp ) { 16781 elem[ ontype ] = null; 16782 } 16783 16784 // Prevent re-triggering of the same event, since we already bubbled it above 16785 jQuery.event.triggered = type; 16786 16787 if ( event.isPropagationStopped() ) { 16788 lastElement.addEventListener( type, stopPropagationCallback ); 16789 } 16790 16791 elem[ type ](); 16792 16793 if ( event.isPropagationStopped() ) { 16794 lastElement.removeEventListener( type, stopPropagationCallback ); 16795 } 16796 16797 jQuery.event.triggered = undefined; 16798 16799 if ( tmp ) { 16800 elem[ ontype ] = tmp; 16801 } 16802 } 16803 } 16804 } 16805 16806 return event.result; 16807 }, 16808 16809 // Piggyback on a donor event to simulate a different one 16810 // Used only for `focus(in | out)` events 16811 simulate: function( type, elem, event ) { 16812 var e = jQuery.extend( 16813 new jQuery.Event(), 16814 event, 16815 { 16816 type: type, 16817 isSimulated: true 16818 } 16819 ); 16820 16821 jQuery.event.trigger( e, null, elem ); 16822 } 16823 16824 } ); 16825 16826 jQuery.fn.extend( { 16827 16828 trigger: function( type, data ) { 16829 return this.each( function() { 16830 jQuery.event.trigger( type, data, this ); 16831 } ); 16832 }, 16833 triggerHandler: function( type, data ) { 16834 var elem = this[ 0 ]; 16835 if ( elem ) { 16836 return jQuery.event.trigger( type, data, elem, true ); 16837 } 16838 } 16839 } ); 16840 16841 16842 var 16843 rbracket = /\[\]$/, 16844 rCRLF = /\r?\n/g, 16845 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 16846 rsubmittable = /^(?:input|select|textarea|keygen)/i; 16847 16848 function buildParams( prefix, obj, traditional, add ) { 16849 var name; 16850 16851 if ( Array.isArray( obj ) ) { 16852 16853 // Serialize array item. 16854 jQuery.each( obj, function( i, v ) { 16855 if ( traditional || rbracket.test( prefix ) ) { 16856 16857 // Treat each array item as a scalar. 16858 add( prefix, v ); 16859 16860 } else { 16861 16862 // Item is non-scalar (array or object), encode its numeric index. 16863 buildParams( 16864 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 16865 v, 16866 traditional, 16867 add 16868 ); 16869 } 16870 } ); 16871 16872 } else if ( !traditional && toType( obj ) === "object" ) { 16873 16874 // Serialize object item. 16875 for ( name in obj ) { 16876 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 16877 } 16878 16879 } else { 16880 16881 // Serialize scalar item. 16882 add( prefix, obj ); 16883 } 16884 } 16885 16886// Serialize an array of form elements or a set of 16887// key/values into a query string 16888 jQuery.param = function( a, traditional ) { 16889 var prefix, 16890 s = [], 16891 add = function( key, valueOrFunction ) { 16892 16893 // If value is a function, invoke it and use its return value 16894 var value = isFunction( valueOrFunction ) ? 16895 valueOrFunction() : 16896 valueOrFunction; 16897 16898 s[ s.length ] = encodeURIComponent( key ) + "=" + 16899 encodeURIComponent( value == null ? "" : value ); 16900 }; 16901 16902 if ( a == null ) { 16903 return ""; 16904 } 16905 16906 // If an array was passed in, assume that it is an array of form elements. 16907 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 16908 16909 // Serialize the form elements 16910 jQuery.each( a, function() { 16911 add( this.name, this.value ); 16912 } ); 16913 16914 } else { 16915 16916 // If traditional, encode the "old" way (the way 1.3.2 or older 16917 // did it), otherwise encode params recursively. 16918 for ( prefix in a ) { 16919 buildParams( prefix, a[ prefix ], traditional, add ); 16920 } 16921 } 16922 16923 // Return the resulting serialization 16924 return s.join( "&" ); 16925 }; 16926 16927 jQuery.fn.extend( { 16928 serialize: function() { 16929 return jQuery.param( this.serializeArray() ); 16930 }, 16931 serializeArray: function() { 16932 return this.map( function() { 16933 16934 // Can add propHook for "elements" to filter or add form elements 16935 var elements = jQuery.prop( this, "elements" ); 16936 return elements ? jQuery.makeArray( elements ) : this; 16937 } ).filter( function() { 16938 var type = this.type; 16939 16940 // Use .is( ":disabled" ) so that fieldset[disabled] works 16941 return this.name && !jQuery( this ).is( ":disabled" ) && 16942 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 16943 ( this.checked || !rcheckableType.test( type ) ); 16944 } ).map( function( _i, elem ) { 16945 var val = jQuery( this ).val(); 16946 16947 if ( val == null ) { 16948 return null; 16949 } 16950 16951 if ( Array.isArray( val ) ) { 16952 return jQuery.map( val, function( val ) { 16953 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 16954 } ); 16955 } 16956 16957 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 16958 } ).get(); 16959 } 16960 } ); 16961 16962 16963 var 16964 r20 = /%20/g, 16965 rhash = /#.*$/, 16966 rantiCache = /([?&])_=[^&]*/, 16967 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, 16968 16969 // trac-7653, trac-8125, trac-8152: local protocol detection 16970 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 16971 rnoContent = /^(?:GET|HEAD)$/, 16972 rprotocol = /^\/\//, 16973 16974 /* Prefilters 16975 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 16976 * 2) These are called: 16977 * - BEFORE asking for a transport 16978 * - AFTER param serialization (s.data is a string if s.processData is true) 16979 * 3) key is the dataType 16980 * 4) the catchall symbol "*" can be used 16981 * 5) execution will start with transport dataType and THEN continue down to "*" if needed 16982 */ 16983 prefilters = {}, 16984 16985 /* Transports bindings 16986 * 1) key is the dataType 16987 * 2) the catchall symbol "*" can be used 16988 * 3) selection will start with transport dataType and THEN go to "*" if needed 16989 */ 16990 transports = {}, 16991 16992 // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression 16993 allTypes = "*/".concat( "*" ), 16994 16995 // Anchor tag for parsing the document origin 16996 originAnchor = document.createElement( "a" ); 16997 16998 originAnchor.href = location.href; 16999 17000// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 17001 function addToPrefiltersOrTransports( structure ) { 17002 17003 // dataTypeExpression is optional and defaults to "*" 17004 return function( dataTypeExpression, func ) { 17005 17006 if ( typeof dataTypeExpression !== "string" ) { 17007 func = dataTypeExpression; 17008 dataTypeExpression = "*"; 17009 } 17010 17011 var dataType, 17012 i = 0, 17013 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; 17014 17015 if ( isFunction( func ) ) { 17016 17017 // For each dataType in the dataTypeExpression 17018 while ( ( dataType = dataTypes[ i++ ] ) ) { 17019 17020 // Prepend if requested 17021 if ( dataType[ 0 ] === "+" ) { 17022 dataType = dataType.slice( 1 ) || "*"; 17023 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 17024 17025 // Otherwise append 17026 } else { 17027 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 17028 } 17029 } 17030 } 17031 }; 17032 } 17033 17034// Base inspection function for prefilters and transports 17035 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 17036 17037 var inspected = {}, 17038 seekingTransport = ( structure === transports ); 17039 17040 function inspect( dataType ) { 17041 var selected; 17042 inspected[ dataType ] = true; 17043 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 17044 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 17045 if ( typeof dataTypeOrTransport === "string" && 17046 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 17047 17048 options.dataTypes.unshift( dataTypeOrTransport ); 17049 inspect( dataTypeOrTransport ); 17050 return false; 17051 } else if ( seekingTransport ) { 17052 return !( selected = dataTypeOrTransport ); 17053 } 17054 } ); 17055 return selected; 17056 } 17057 17058 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 17059 } 17060 17061// A special extend for ajax options 17062// that takes "flat" options (not to be deep extended) 17063// Fixes trac-9887 17064 function ajaxExtend( target, src ) { 17065 var key, deep, 17066 flatOptions = jQuery.ajaxSettings.flatOptions || {}; 17067 17068 for ( key in src ) { 17069 if ( src[ key ] !== undefined ) { 17070 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 17071 } 17072 } 17073 if ( deep ) { 17074 jQuery.extend( true, target, deep ); 17075 } 17076 17077 return target; 17078 } 17079 17080 /* Handles responses to an ajax request: 17081 * - finds the right dataType (mediates between content-type and expected dataType) 17082 * - returns the corresponding response 17083 */ 17084 function ajaxHandleResponses( s, jqXHR, responses ) { 17085 17086 var ct, type, finalDataType, firstDataType, 17087 contents = s.contents, 17088 dataTypes = s.dataTypes; 17089 17090 // Remove auto dataType and get content-type in the process 17091 while ( dataTypes[ 0 ] === "*" ) { 17092 dataTypes.shift(); 17093 if ( ct === undefined ) { 17094 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 17095 } 17096 } 17097 17098 // Check if we're dealing with a known content-type 17099 if ( ct ) { 17100 for ( type in contents ) { 17101 if ( contents[ type ] && contents[ type ].test( ct ) ) { 17102 dataTypes.unshift( type ); 17103 break; 17104 } 17105 } 17106 } 17107 17108 // Check to see if we have a response for the expected dataType 17109 if ( dataTypes[ 0 ] in responses ) { 17110 finalDataType = dataTypes[ 0 ]; 17111 } else { 17112
vendor: 9,441 bytes, lines 17113-17488
17113 // Try convertible dataTypes 17114 for ( type in responses ) { 17115 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 17116 finalDataType = type; 17117 break; 17118 } 17119 if ( !firstDataType ) { 17120 firstDataType = type; 17121 } 17122 } 17123 17124 // Or just use first one 17125 finalDataType = finalDataType || firstDataType; 17126 } 17127 17128 // If we found a dataType 17129 // We add the dataType to the list if needed 17130 // and return the corresponding response 17131 if ( finalDataType ) { 17132 if ( finalDataType !== dataTypes[ 0 ] ) { 17133 dataTypes.unshift( finalDataType ); 17134 } 17135 return responses[ finalDataType ]; 17136 } 17137 } 17138 17139 /* Chain conversions given the request and the original response 17140 * Also sets the responseXXX fields on the jqXHR instance 17141 */ 17142 function ajaxConvert( s, response, jqXHR, isSuccess ) { 17143 var conv2, current, conv, tmp, prev, 17144 converters = {}, 17145 17146 // Work with a copy of dataTypes in case we need to modify it for conversion 17147 dataTypes = s.dataTypes.slice(); 17148 17149 // Create converters map with lowercased keys 17150 if ( dataTypes[ 1 ] ) { 17151 for ( conv in s.converters ) { 17152 converters[ conv.toLowerCase() ] = s.converters[ conv ]; 17153 } 17154 } 17155 17156 current = dataTypes.shift(); 17157 17158 // Convert to each sequential dataType 17159 while ( current ) { 17160 17161 if ( s.responseFields[ current ] ) { 17162 jqXHR[ s.responseFields[ current ] ] = response; 17163 } 17164 17165 // Apply the dataFilter if provided 17166 if ( !prev && isSuccess && s.dataFilter ) { 17167 response = s.dataFilter( response, s.dataType ); 17168 } 17169 17170 prev = current; 17171 current = dataTypes.shift(); 17172 17173 if ( current ) { 17174 17175 // There's only work to do if current dataType is non-auto 17176 if ( current === "*" ) { 17177 17178 current = prev; 17179 17180 // Convert response if prev dataType is non-auto and differs from current 17181 } else if ( prev !== "*" && prev !== current ) { 17182 17183 // Seek a direct converter 17184 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 17185 17186 // If none found, seek a pair 17187 if ( !conv ) { 17188 for ( conv2 in converters ) { 17189 17190 // If conv2 outputs current 17191 tmp = conv2.split( " " ); 17192 if ( tmp[ 1 ] === current ) { 17193 17194 // If prev can be converted to accepted input 17195 conv = converters[ prev + " " + tmp[ 0 ] ] || 17196 converters[ "* " + tmp[ 0 ] ]; 17197 if ( conv ) { 17198 17199 // Condense equivalence converters 17200 if ( conv === true ) { 17201 conv = converters[ conv2 ]; 17202 17203 // Otherwise, insert the intermediate dataType 17204 } else if ( converters[ conv2 ] !== true ) { 17205 current = tmp[ 0 ]; 17206 dataTypes.unshift( tmp[ 1 ] ); 17207 } 17208 break; 17209 } 17210 } 17211 } 17212 } 17213 17214 // Apply converter (if not an equivalence) 17215 if ( conv !== true ) { 17216 17217 // Unless errors are allowed to bubble, catch and return them 17218 if ( conv && s.throws ) { 17219 response = conv( response ); 17220 } else { 17221 try { 17222 response = conv( response ); 17223 } catch ( e ) { 17224 return { 17225 state: "parsererror", 17226 error: conv ? e : "No conversion from " + prev + " to " + current 17227 }; 17228 } 17229 } 17230 } 17231 } 17232 } 17233 } 17234 17235 return { state: "success", data: response }; 17236 } 17237 17238 jQuery.extend( { 17239 17240 // Counter for holding the number of active queries 17241 active: 0, 17242 17243 // Last-Modified header cache for next request 17244 lastModified: {}, 17245 etag: {}, 17246 17247 ajaxSettings: { 17248 url: location.href, 17249 type: "GET", 17250 isLocal: rlocalProtocol.test( location.protocol ), 17251 global: true, 17252 processData: true, 17253 async: true, 17254 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 17255 17256 /* 17257 timeout: 0, 17258 data: null, 17259 dataType: null, 17260 username: null, 17261 password: null, 17262 cache: null, 17263 throws: false, 17264 traditional: false, 17265 headers: {}, 17266 */ 17267 17268 accepts: { 17269 "*": allTypes, 17270 text: "text/plain", 17271 html: "text/html", 17272 xml: "application/xml, text/xml", 17273 json: "application/json, text/javascript" 17274 }, 17275 17276 contents: { 17277 xml: /\bxml\b/, 17278 html: /\bhtml/, 17279 json: /\bjson\b/ 17280 }, 17281 17282 responseFields: { 17283 xml: "responseXML", 17284 text: "responseText", 17285 json: "responseJSON" 17286 }, 17287 17288 // Data converters 17289 // Keys separate source (or catchall "*") and destination types with a single space 17290 converters: { 17291 17292 // Convert anything to text 17293 "* text": String, 17294 17295 // Text to html (true = no transformation) 17296 "text html": true, 17297 17298 // Evaluate text as a json expression 17299 "text json": JSON.parse, 17300 17301 // Parse text as xml 17302 "text xml": jQuery.parseXML 17303 }, 17304 17305 // For options that shouldn't be deep extended: 17306 // you can add your own custom options here if 17307 // and when you create one that shouldn't be 17308 // deep extended (see ajaxExtend) 17309 flatOptions: { 17310 url: true, 17311 context: true 17312 } 17313 }, 17314 17315 // Creates a full fledged settings object into target 17316 // with both ajaxSettings and settings fields. 17317 // If target is omitted, writes into ajaxSettings. 17318 ajaxSetup: function( target, settings ) { 17319 return settings ? 17320 17321 // Building a settings object 17322 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 17323 17324 // Extending ajaxSettings 17325 ajaxExtend( jQuery.ajaxSettings, target ); 17326 }, 17327 17328 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 17329 ajaxTransport: addToPrefiltersOrTransports( transports ), 17330 17331 // Main method 17332 ajax: function( url, options ) { 17333 17334 // If url is an object, simulate pre-1.5 signature 17335 if ( typeof url === "object" ) { 17336 options = url; 17337 url = undefined; 17338 } 17339 17340 // Force options to be an object 17341 options = options || {}; 17342 17343 var transport, 17344 17345 // URL without anti-cache param 17346 cacheURL, 17347 17348 // Response headers 17349 responseHeadersString, 17350 responseHeaders, 17351 17352 // timeout handle 17353 timeoutTimer, 17354 17355 // Url cleanup var 17356 urlAnchor, 17357 17358 // Request state (becomes false upon send and true upon completion) 17359 completed, 17360 17361 // To know if global events are to be dispatched 17362 fireGlobals, 17363 17364 // Loop variable 17365 i, 17366 17367 // uncached part of the url 17368 uncached, 17369 17370 // Create the final options object 17371 s = jQuery.ajaxSetup( {}, options ), 17372 17373 // Callbacks context 17374 callbackContext = s.context || s, 17375 17376 // Context for global events is callbackContext if it is a DOM node or jQuery collection 17377 globalEventContext = s.context && 17378 ( callbackContext.nodeType || callbackContext.jquery ) ? 17379 jQuery( callbackContext ) : 17380 jQuery.event, 17381 17382 // Deferreds 17383 deferred = jQuery.Deferred(), 17384 completeDeferred = jQuery.Callbacks( "once memory" ), 17385 17386 // Status-dependent callbacks 17387 statusCode = s.statusCode || {}, 17388 17389 // Headers (they are sent all at once) 17390 requestHeaders = {}, 17391 requestHeadersNames = {}, 17392 17393 // Default abort message 17394 strAbort = "canceled", 17395 17396 // Fake xhr 17397 jqXHR = { 17398 readyState: 0, 17399 17400 // Builds headers hashtable if needed 17401 getResponseHeader: function( key ) { 17402 var match; 17403 if ( completed ) { 17404 if ( !responseHeaders ) { 17405 responseHeaders = {}; 17406 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 17407 responseHeaders[ match[ 1 ].toLowerCase() + " " ] = 17408 ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) 17409 .concat( match[ 2 ] ); 17410 } 17411 } 17412 match = responseHeaders[ key.toLowerCase() + " " ]; 17413 } 17414 return match == null ? null : match.join( ", " ); 17415 }, 17416 17417 // Raw string 17418 getAllResponseHeaders: function() { 17419 return completed ? responseHeadersString : null; 17420 }, 17421 17422 // Caches the header 17423 setRequestHeader: function( name, value ) { 17424 if ( completed == null ) { 17425 name = requestHeadersNames[ name.toLowerCase() ] = 17426 requestHeadersNames[ name.toLowerCase() ] || name; 17427 requestHeaders[ name ] = value; 17428 } 17429 return this; 17430 }, 17431 17432 // Overrides response content-type header 17433 overrideMimeType: function( type ) { 17434 if ( completed == null ) { 17435 s.mimeType = type; 17436 } 17437 return this; 17438 }, 17439 17440 // Status-dependent callbacks 17441 statusCode: function( map ) { 17442 var code; 17443 if ( map ) { 17444 if ( completed ) { 17445 17446 // Execute the appropriate callbacks 17447 jqXHR.always( map[ jqXHR.status ] ); 17448 } else { 17449 17450 // Lazy-add the new callbacks in a way that preserves old ones 17451 for ( code in map ) { 17452 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 17453 } 17454 } 17455 } 17456 return this; 17457 }, 17458 17459 // Cancel the request 17460 abort: function( statusText ) { 17461 var finalText = statusText || strAbort; 17462 if ( transport ) { 17463 transport.abort( finalText ); 17464 } 17465 done( 0, finalText ); 17466 return this; 17467 } 17468 }; 17469 17470 // Attach deferreds 17471 deferred.promise( jqXHR ); 17472 17473 // Add protocol if not provided (prefilters might expect it) 17474 // Handle falsy url in the settings object (trac-10093: consistency with old signature) 17475 // We also use the url parameter if available 17476 s.url = ( ( url || s.url || location.href ) + "" ) 17477 .replace( rprotocol, location.protocol + "//" ); 17478 17479 // Alias method option to type as per ticket trac-12004 17480 s.type = options.method || options.type || s.method || s.type; 17481 17482 // Extract dataTypes list 17483 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; 17484 17485 // A cross-domain request is in order when the origin doesn't match the current origin. 17486 if ( s.crossDomain == null ) { 17487 urlAnchor = document.createElement( "a" ); 17488
vendor: 9,388 bytes, lines 17489-17820
17489 // Support: IE <=8 - 11, Edge 12 - 15 17490 // IE throws exception on accessing the href property if url is malformed, 17491 // e.g. http://example.com:80x/ 17492 try { 17493 urlAnchor.href = s.url; 17494 17495 // Support: IE <=8 - 11 only 17496 // Anchor's host property isn't correctly set when s.url is relative 17497 urlAnchor.href = urlAnchor.href; 17498 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== 17499 urlAnchor.protocol + "//" + urlAnchor.host; 17500 } catch ( e ) { 17501 17502 // If there is an error parsing the URL, assume it is crossDomain, 17503 // it can be rejected by the transport if it is invalid 17504 s.crossDomain = true; 17505 } 17506 } 17507 17508 // Convert data if not already a string 17509 if ( s.data && s.processData && typeof s.data !== "string" ) { 17510 s.data = jQuery.param( s.data, s.traditional ); 17511 } 17512 17513 // Apply prefilters 17514 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 17515 17516 // If request was aborted inside a prefilter, stop there 17517 if ( completed ) { 17518 return jqXHR; 17519 } 17520 17521 // We can fire global events as of now if asked to 17522 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118) 17523 fireGlobals = jQuery.event && s.global; 17524 17525 // Watch for a new set of requests 17526 if ( fireGlobals && jQuery.active++ === 0 ) { 17527 jQuery.event.trigger( "ajaxStart" ); 17528 } 17529 17530 // Uppercase the type 17531 s.type = s.type.toUpperCase(); 17532 17533 // Determine if request has content 17534 s.hasContent = !rnoContent.test( s.type ); 17535 17536 // Save the URL in case we're toying with the If-Modified-Since 17537 // and/or If-None-Match header later on 17538 // Remove hash to simplify url manipulation 17539 cacheURL = s.url.replace( rhash, "" ); 17540 17541 // More options handling for requests with no content 17542 if ( !s.hasContent ) { 17543 17544 // Remember the hash so we can put it back 17545 uncached = s.url.slice( cacheURL.length ); 17546 17547 // If data is available and should be processed, append data to url 17548 if ( s.data && ( s.processData || typeof s.data === "string" ) ) { 17549 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; 17550 17551 // trac-9682: remove data so that it's not used in an eventual retry 17552 delete s.data; 17553 } 17554 17555 // Add or update anti-cache param if needed 17556 if ( s.cache === false ) { 17557 cacheURL = cacheURL.replace( rantiCache, "$1" ); 17558 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + 17559 uncached; 17560 } 17561 17562 // Put hash and anti-cache on the URL that will be requested (gh-1732) 17563 s.url = cacheURL + uncached; 17564 17565 // Change '%20' to '+' if this is encoded form body content (gh-2658) 17566 } else if ( s.data && s.processData && 17567 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { 17568 s.data = s.data.replace( r20, "+" ); 17569 } 17570 17571 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 17572 if ( s.ifModified ) { 17573 if ( jQuery.lastModified[ cacheURL ] ) { 17574 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 17575 } 17576 if ( jQuery.etag[ cacheURL ] ) { 17577 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 17578 } 17579 } 17580 17581 // Set the correct header, if data is being sent 17582 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 17583 jqXHR.setRequestHeader( "Content-Type", s.contentType ); 17584 } 17585 17586 // Set the Accepts header for the server, depending on the dataType 17587 jqXHR.setRequestHeader( 17588 "Accept", 17589 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 17590 s.accepts[ s.dataTypes[ 0 ] ] + 17591 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 17592 s.accepts[ "*" ] 17593 ); 17594 17595 // Check for headers option 17596 for ( i in s.headers ) { 17597 jqXHR.setRequestHeader( i, s.headers[ i ] ); 17598 } 17599 17600 // Allow custom headers/mimetypes and early abort 17601 if ( s.beforeSend && 17602 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { 17603 17604 // Abort if not done already and return 17605 return jqXHR.abort(); 17606 } 17607 17608 // Aborting is no longer a cancellation 17609 strAbort = "abort"; 17610 17611 // Install callbacks on deferreds 17612 completeDeferred.add( s.complete ); 17613 jqXHR.done( s.success ); 17614 jqXHR.fail( s.error ); 17615 17616 // Get transport 17617 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 17618 17619 // If no transport, we auto-abort 17620 if ( !transport ) { 17621 done( -1, "No Transport" ); 17622 } else { 17623 jqXHR.readyState = 1; 17624 17625 // Send global event 17626 if ( fireGlobals ) { 17627 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 17628 } 17629 17630 // If request was aborted inside ajaxSend, stop there 17631 if ( completed ) { 17632 return jqXHR; 17633 } 17634 17635 // Timeout 17636 if ( s.async && s.timeout > 0 ) { 17637 timeoutTimer = window.setTimeout( function() { 17638 jqXHR.abort( "timeout" ); 17639 }, s.timeout ); 17640 } 17641 17642 try { 17643 completed = false; 17644 transport.send( requestHeaders, done ); 17645 } catch ( e ) { 17646 17647 // Rethrow post-completion exceptions 17648 if ( completed ) { 17649 throw e; 17650 } 17651 17652 // Propagate others as results 17653 done( -1, e ); 17654 } 17655 } 17656 17657 // Callback for when everything is done 17658 function done( status, nativeStatusText, responses, headers ) { 17659 var isSuccess, success, error, response, modified, 17660 statusText = nativeStatusText; 17661 17662 // Ignore repeat invocations 17663 if ( completed ) { 17664 return; 17665 } 17666 17667 completed = true; 17668 17669 // Clear timeout if it exists 17670 if ( timeoutTimer ) { 17671 window.clearTimeout( timeoutTimer ); 17672 } 17673 17674 // Dereference transport for early garbage collection 17675 // (no matter how long the jqXHR object will be used) 17676 transport = undefined; 17677 17678 // Cache response headers 17679 responseHeadersString = headers || ""; 17680 17681 // Set readyState 17682 jqXHR.readyState = status > 0 ? 4 : 0; 17683 17684 // Determine if successful 17685 isSuccess = status >= 200 && status < 300 || status === 304; 17686 17687 // Get response data 17688 if ( responses ) { 17689 response = ajaxHandleResponses( s, jqXHR, responses ); 17690 } 17691 17692 // Use a noop converter for missing script but not if jsonp 17693 if ( !isSuccess && 17694 jQuery.inArray( "script", s.dataTypes ) > -1 && 17695 jQuery.inArray( "json", s.dataTypes ) < 0 ) { 17696 s.converters[ "text script" ] = function() {}; 17697 } 17698 17699 // Convert no matter what (that way responseXXX fields are always set) 17700 response = ajaxConvert( s, response, jqXHR, isSuccess ); 17701 17702 // If successful, handle type chaining 17703 if ( isSuccess ) { 17704 17705 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 17706 if ( s.ifModified ) { 17707 modified = jqXHR.getResponseHeader( "Last-Modified" ); 17708 if ( modified ) { 17709 jQuery.lastModified[ cacheURL ] = modified; 17710 } 17711 modified = jqXHR.getResponseHeader( "etag" ); 17712 if ( modified ) { 17713 jQuery.etag[ cacheURL ] = modified; 17714 } 17715 } 17716 17717 // if no content 17718 if ( status === 204 || s.type === "HEAD" ) { 17719 statusText = "nocontent"; 17720 17721 // if not modified 17722 } else if ( status === 304 ) { 17723 statusText = "notmodified"; 17724 17725 // If we have data, let's convert it 17726 } else { 17727 statusText = response.state; 17728 success = response.data; 17729 error = response.error; 17730 isSuccess = !error; 17731 } 17732 } else { 17733 17734 // Extract error from statusText and normalize for non-aborts 17735 error = statusText; 17736 if ( status || !statusText ) { 17737 statusText = "error"; 17738 if ( status < 0 ) { 17739 status = 0; 17740 } 17741 } 17742 } 17743 17744 // Set data for the fake xhr object 17745 jqXHR.status = status; 17746 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 17747 17748 // Success/Error 17749 if ( isSuccess ) { 17750 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 17751 } else { 17752 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 17753 } 17754 17755 // Status-dependent callbacks 17756 jqXHR.statusCode( statusCode ); 17757 statusCode = undefined; 17758 17759 if ( fireGlobals ) { 17760 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 17761 [ jqXHR, s, isSuccess ? success : error ] ); 17762 } 17763 17764 // Complete 17765 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 17766 17767 if ( fireGlobals ) { 17768 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 17769 17770 // Handle the global AJAX counter 17771 if ( !( --jQuery.active ) ) { 17772 jQuery.event.trigger( "ajaxStop" ); 17773 } 17774 } 17775 } 17776 17777 return jqXHR; 17778 }, 17779 17780 getJSON: function( url, data, callback ) { 17781 return jQuery.get( url, data, callback, "json" ); 17782 }, 17783 17784 getScript: function( url, callback ) { 17785 return jQuery.get( url, undefined, callback, "script" ); 17786 } 17787 } ); 17788 17789 jQuery.each( [ "get", "post" ], function( _i, method ) { 17790 jQuery[ method ] = function( url, data, callback, type ) { 17791 17792 // Shift arguments if data argument was omitted 17793 if ( isFunction( data ) ) { 17794 type = type || callback; 17795 callback = data; 17796 data = undefined; 17797 } 17798 17799 // The url can be an options object (which then must have .url) 17800 return jQuery.ajax( jQuery.extend( { 17801 url: url, 17802 type: method, 17803 dataType: type, 17804 data: data, 17805 success: callback 17806 }, jQuery.isPlainObject( url ) && url ) ); 17807 }; 17808 } ); 17809 17810 jQuery.ajaxPrefilter( function( s ) { 17811 var i; 17812 for ( i in s.headers ) { 17813 if ( i.toLowerCase() === "content-type" ) { 17814 s.contentType = s.headers[ i ] || ""; 17815 } 17816 } 17817 } ); 17818 17819 17820 jQuery._evalUrl = function( url, options, doc ) {
vendor: 3,752 bytes, lines 17821-17977
17821 var ajaxJson = { 17822 url: url, 17823 17824 // Make this explicit, since user can override this through ajaxSetup (trac-11264) 17825 type: "GET", 17826 dataType: "script", 17827 cache: true, 17828 async: false, 17829 global: false, 17830 // Only evaluate the response if it is successful (gh-4126) 17831 // dataFilter is not invoked for failure responses, so using it instead 17832 // of the default converter is kludgy but it works. 17833 converters: { 17834 "text script": function() {} 17835 }, 17836 dataFilter: function( response ) { 17837 jQuery.globalEval( response, options, doc ); 17838 } 17839 }; 17840 if (options && options.nonce) { 17841 ajaxJson.scriptAttrs = {nonce: options.nonce}; 17842 } 17843 return jQuery.ajax( ajaxJson ); 17844 }; 17845 17846 17847 jQuery.fn.extend( { 17848 wrapAll: function( html ) { 17849 var wrap; 17850 17851 if ( this[ 0 ] ) { 17852 if ( isFunction( html ) ) { 17853 html = html.call( this[ 0 ] ); 17854 } 17855 17856 // The elements to wrap the target around 17857 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 17858 17859 if ( this[ 0 ].parentNode ) { 17860 wrap.insertBefore( this[ 0 ] ); 17861 } 17862 17863 wrap.map( function() { 17864 var elem = this; 17865 17866 while ( elem.firstElementChild ) { 17867 elem = elem.firstElementChild; 17868 } 17869 17870 return elem; 17871 } ).append( this ); 17872 } 17873 17874 return this; 17875 }, 17876 17877 wrapInner: function( html ) { 17878 if ( isFunction( html ) ) { 17879 return this.each( function( i ) { 17880 jQuery( this ).wrapInner( html.call( this, i ) ); 17881 } ); 17882 } 17883 17884 return this.each( function() { 17885 var self = jQuery( this ), 17886 contents = self.contents(); 17887 17888 if ( contents.length ) { 17889 contents.wrapAll( html ); 17890 17891 } else { 17892 self.append( html ); 17893 } 17894 } ); 17895 }, 17896 17897 wrap: function( html ) { 17898 var htmlIsFunction = isFunction( html ); 17899 17900 return this.each( function( i ) { 17901 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); 17902 } ); 17903 }, 17904 17905 unwrap: function( selector ) { 17906 this.parent( selector ).not( "body" ).each( function() { 17907 jQuery( this ).replaceWith( this.childNodes ); 17908 } ); 17909 return this; 17910 } 17911 } ); 17912 17913 17914 jQuery.expr.pseudos.hidden = function( elem ) { 17915 return !jQuery.expr.pseudos.visible( elem ); 17916 }; 17917 jQuery.expr.pseudos.visible = function( elem ) { 17918 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); 17919 }; 17920 17921 17922 17923 17924 jQuery.ajaxSettings.xhr = function() { 17925 try { 17926 return new window.XMLHttpRequest(); 17927 } catch ( e ) {} 17928 }; 17929 17930 var xhrSuccessStatus = { 17931 17932 // File protocol always yields status code 0, assume 200 17933 0: 200, 17934 17935 // Support: IE <=9 only 17936 // trac-1450: sometimes IE returns 1223 when it should be 204 17937 1223: 204 17938 }, 17939 xhrSupported = jQuery.ajaxSettings.xhr(); 17940 17941 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 17942 support.ajax = xhrSupported = !!xhrSupported; 17943 17944 jQuery.ajaxTransport( function( options ) { 17945 var callback, errorCallback; 17946 17947 // Cross domain only allowed if supported through XMLHttpRequest 17948 if ( support.cors || xhrSupported && !options.crossDomain ) { 17949 return { 17950 send: function( headers, complete ) { 17951 var i, 17952 xhr = options.xhr(); 17953 17954 xhr.open( 17955 options.type, 17956 options.url, 17957 options.async, 17958 options.username, 17959 options.password 17960 ); 17961 17962 // Apply custom fields if provided 17963 if ( options.xhrFields ) { 17964 for ( i in options.xhrFields ) { 17965 xhr[ i ] = options.xhrFields[ i ]; 17966 } 17967 } 17968 17969 // Override mime type if needed 17970 if ( options.mimeType && xhr.overrideMimeType ) { 17971 xhr.overrideMimeType( options.mimeType ); 17972 } 17973 17974 // X-Requested-With header 17975 // For cross-domain requests, seeing as conditions for a preflight are 17976 // akin to a jigsaw puzzle, we simply never set it to be sure. 17977 // (it can always be set on a per-request basis or even using ajaxSetup)
vendor: 22,606 bytes, lines 17978-18783
17978 // For same-domain requests, won't change header if already provided. 17979 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 17980 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 17981 } 17982 17983 // Set headers 17984 for ( i in headers ) { 17985 xhr.setRequestHeader( i, headers[ i ] ); 17986 } 17987 17988 // Callback 17989 callback = function( type ) { 17990 return function() { 17991 if ( callback ) { 17992 callback = errorCallback = xhr.onload = 17993 xhr.onerror = xhr.onabort = xhr.ontimeout = 17994 xhr.onreadystatechange = null; 17995 17996 if ( type === "abort" ) { 17997 xhr.abort(); 17998 } else if ( type === "error" ) { 17999 18000 // Support: IE <=9 only 18001 // On a manual native abort, IE9 throws 18002 // errors on any property access that is not readyState 18003 if ( typeof xhr.status !== "number" ) { 18004 complete( 0, "error" ); 18005 } else { 18006 complete( 18007 18008 // File: protocol always yields status 0; see trac-8605, trac-14207 18009 xhr.status, 18010 xhr.statusText 18011 ); 18012 } 18013 } else { 18014 complete( 18015 xhrSuccessStatus[ xhr.status ] || xhr.status, 18016 xhr.statusText, 18017 18018 // Support: IE <=9 only 18019 // IE9 has no XHR2 but throws on binary (trac-11426) 18020 // For XHR2 non-text, let the caller handle it (gh-2498) 18021 ( xhr.responseType || "text" ) !== "text" || 18022 typeof xhr.responseText !== "string" ? 18023 { binary: xhr.response } : 18024 { text: xhr.responseText }, 18025 xhr.getAllResponseHeaders() 18026 ); 18027 } 18028 } 18029 }; 18030 }; 18031 18032 // Listen to events 18033 xhr.onload = callback(); 18034 errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); 18035 18036 // Support: IE 9 only 18037 // Use onreadystatechange to replace onabort 18038 // to handle uncaught aborts 18039 if ( xhr.onabort !== undefined ) { 18040 xhr.onabort = errorCallback; 18041 } else { 18042 xhr.onreadystatechange = function() { 18043 18044 // Check readyState before timeout as it changes 18045 if ( xhr.readyState === 4 ) { 18046 18047 // Allow onerror to be called first, 18048 // but that will not handle a native abort 18049 // Also, save errorCallback to a variable 18050 // as xhr.onerror cannot be accessed 18051 window.setTimeout( function() { 18052 if ( callback ) { 18053 errorCallback(); 18054 } 18055 } ); 18056 } 18057 }; 18058 } 18059 18060 // Create the abort callback 18061 callback = callback( "abort" ); 18062 18063 try { 18064 18065 // Do send the request (this may raise an exception) 18066 xhr.send( options.hasContent && options.data || null ); 18067 } catch ( e ) { 18068 18069 // trac-14683: Only rethrow if this hasn't been notified as an error yet 18070 if ( callback ) { 18071 throw e; 18072 } 18073 } 18074 }, 18075 18076 abort: function() { 18077 if ( callback ) { 18078 callback(); 18079 } 18080 } 18081 }; 18082 } 18083 } ); 18084 18085 18086 18087 18088// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) 18089 jQuery.ajaxPrefilter( function( s ) { 18090 if ( s.crossDomain ) { 18091 s.contents.script = false; 18092 } 18093 } ); 18094 18095// Install script dataType 18096 jQuery.ajaxSetup( { 18097 accepts: { 18098 script: "text/javascript, application/javascript, " + 18099 "application/ecmascript, application/x-ecmascript" 18100 }, 18101 contents: { 18102 script: /\b(?:java|ecma)script\b/ 18103 }, 18104 converters: { 18105 "text script": function( text ) { 18106 jQuery.globalEval( text ); 18107 return text; 18108 } 18109 } 18110 } ); 18111 18112// Handle cache's special case and crossDomain 18113 jQuery.ajaxPrefilter( "script", function( s ) { 18114 if ( s.cache === undefined ) { 18115 s.cache = false; 18116 } 18117 if ( s.crossDomain ) { 18118 s.type = "GET"; 18119 } 18120 } ); 18121 18122// Bind script tag hack transport 18123 jQuery.ajaxTransport( "script", function( s ) { 18124 18125 // This transport only deals with cross domain or forced-by-attrs requests 18126 if ( s.crossDomain || s.scriptAttrs ) { 18127 var script, callback; 18128 return { 18129 send: function( _, complete ) { 18130 script = jQuery( "<script>" ) 18131 .attr( s.scriptAttrs || {} ) 18132 .prop( { charset: s.scriptCharset, src: s.url } ) 18133 .on( "load error", callback = function( evt ) { 18134 script.remove(); 18135 callback = null; 18136 if ( evt ) { 18137 complete( evt.type === "error" ? 404 : 200, evt.type ); 18138 } 18139 } ); 18140 18141 // Use native DOM manipulation to avoid our domManip AJAX trickery 18142 document.head.appendChild( script[ 0 ] ); 18143 }, 18144 abort: function() { 18145 if ( callback ) { 18146 callback(); 18147 } 18148 } 18149 }; 18150 } 18151 } ); 18152 18153 18154 18155 18156 var oldCallbacks = [], 18157 rjsonp = /(=)\?(?=&|$)|\?\?/; 18158 18159// Default jsonp settings 18160 jQuery.ajaxSetup( { 18161 jsonp: "callback", 18162 jsonpCallback: function() { 18163 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) ); 18164 this[ callback ] = true; 18165 return callback; 18166 } 18167 } ); 18168 18169// Detect, normalize options and install callbacks for jsonp requests 18170 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 18171 18172 var callbackName, overwritten, responseContainer, 18173 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 18174 "url" : 18175 typeof s.data === "string" && 18176 ( s.contentType || "" ) 18177 .indexOf( "application/x-www-form-urlencoded" ) === 0 && 18178 rjsonp.test( s.data ) && "data" 18179 ); 18180 18181 // Handle iff the expected data type is "jsonp" or we have a parameter to set 18182 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 18183 18184 // Get callback name, remembering preexisting value associated with it 18185 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? 18186 s.jsonpCallback() : 18187 s.jsonpCallback; 18188 18189 // Insert callback into url or form data 18190 if ( jsonProp ) { 18191 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 18192 } else if ( s.jsonp !== false ) { 18193 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 18194 } 18195 18196 // Use data converter to retrieve json after script execution 18197 s.converters[ "script json" ] = function() { 18198 if ( !responseContainer ) { 18199 jQuery.error( callbackName + " was not called" ); 18200 } 18201 return responseContainer[ 0 ]; 18202 }; 18203 18204 // Force json dataType 18205 s.dataTypes[ 0 ] = "json"; 18206 18207 // Install callback 18208 overwritten = window[ callbackName ]; 18209 window[ callbackName ] = function() { 18210 responseContainer = arguments; 18211 }; 18212 18213 // Clean-up function (fires after converters) 18214 jqXHR.always( function() { 18215 18216 // If previous value didn't exist - remove it 18217 if ( overwritten === undefined ) { 18218 jQuery( window ).removeProp( callbackName ); 18219 18220 // Otherwise restore preexisting value 18221 } else { 18222 window[ callbackName ] = overwritten; 18223 } 18224 18225 // Save back as free 18226 if ( s[ callbackName ] ) { 18227 18228 // Make sure that re-using the options doesn't screw things around 18229 s.jsonpCallback = originalSettings.jsonpCallback; 18230 18231 // Save the callback name for future use 18232 oldCallbacks.push( callbackName ); 18233 } 18234 18235 // Call if it was a function and we have a response 18236 if ( responseContainer && isFunction( overwritten ) ) { 18237 overwritten( responseContainer[ 0 ] ); 18238 } 18239 18240 responseContainer = overwritten = undefined; 18241 } ); 18242 18243 // Delegate to script 18244 return "script"; 18245 } 18246 } ); 18247 18248 18249 18250 18251// Support: Safari 8 only 18252// In Safari 8 documents created via document.implementation.createHTMLDocument 18253// collapse sibling forms: the second one becomes a child of the first one. 18254// Because of that, this security measure has to be disabled in Safari 8. 18255// https://bugs.webkit.org/show_bug.cgi?id=137337 18256 support.createHTMLDocument = ( function() { 18257 var body = document.implementation.createHTMLDocument( "" ).body; 18258 body.innerHTML = "<form></form><form></form>"; 18259 return body.childNodes.length === 2; 18260 } )(); 18261 18262 18263// Argument "data" should be string of html 18264// context (optional): If specified, the fragment will be created in this context, 18265// defaults to document 18266// keepScripts (optional): If true, will include scripts passed in the html string 18267 jQuery.parseHTML = function( data, context, keepScripts ) { 18268 if ( typeof data !== "string" ) { 18269 return []; 18270 } 18271 if ( typeof context === "boolean" ) { 18272 keepScripts = context; 18273 context = false; 18274 } 18275 18276 var base, parsed, scripts; 18277 18278 if ( !context ) { 18279 18280 // Stop scripts or inline event handlers from being executed immediately 18281 // by using document.implementation 18282 if ( support.createHTMLDocument ) { 18283 context = document.implementation.createHTMLDocument( "" ); 18284 18285 // Set the base href for the created document 18286 // so any parsed elements with URLs 18287 // are based on the document's URL (gh-2965) 18288 base = context.createElement( "base" ); 18289 base.href = document.location.href; 18290 context.head.appendChild( base ); 18291 } else { 18292 context = document; 18293 } 18294 } 18295 18296 parsed = rsingleTag.exec( data ); 18297 scripts = !keepScripts && []; 18298 18299 // Single tag 18300 if ( parsed ) { 18301 return [ context.createElement( parsed[ 1 ] ) ]; 18302 } 18303 18304 parsed = buildFragment( [ data ], context, scripts ); 18305 18306 if ( scripts && scripts.length ) { 18307 jQuery( scripts ).remove(); 18308 } 18309 18310 return jQuery.merge( [], parsed.childNodes ); 18311 }; 18312 18313 18314 /** 18315 * Load a url into a page 18316 */ 18317 jQuery.fn.load = function( url, params, callback ) { 18318 var selector, type, response, 18319 self = this, 18320 off = url.indexOf( " " ); 18321 18322 if ( off > -1 ) { 18323 selector = stripAndCollapse( url.slice( off ) ); 18324 url = url.slice( 0, off ); 18325 } 18326 18327 // If it's a function 18328 if ( isFunction( params ) ) { 18329 18330 // We assume that it's the callback 18331 callback = params; 18332 params = undefined; 18333 18334 // Otherwise, build a param string 18335 } else if ( params && typeof params === "object" ) { 18336 type = "POST"; 18337 } 18338 18339 // If we have elements to modify, make the request 18340 if ( self.length > 0 ) { 18341 jQuery.ajax( { 18342 url: url, 18343 18344 // If "type" variable is undefined, then "GET" method will be used. 18345 // Make value of this field explicit since 18346 // user can override it through ajaxSetup method 18347 type: type || "GET", 18348 dataType: "html", 18349 data: params 18350 } ).done( function( responseText ) { 18351 18352 // Save response for use in complete callback 18353 response = arguments; 18354 18355 self.html( selector ? 18356 18357 // If a selector was specified, locate the right elements in a dummy div 18358 // Exclude scripts to avoid IE 'Permission Denied' errors 18359 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 18360 18361 // Otherwise use the full result 18362 responseText ); 18363 18364 // If the request succeeds, this function gets "data", "status", "jqXHR" 18365 // but they are ignored because response was set above. 18366 // If it fails, this function gets "jqXHR", "status", "error" 18367 } ).always( callback && function( jqXHR, status ) { 18368 self.each( function() { 18369 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 18370 } ); 18371 } ); 18372 } 18373 18374 return this; 18375 }; 18376 18377 18378 18379 18380 jQuery.expr.pseudos.animated = function( elem ) { 18381 return jQuery.grep( jQuery.timers, function( fn ) { 18382 return elem === fn.elem; 18383 } ).length; 18384 }; 18385 18386 18387 18388 18389 jQuery.offset = { 18390 setOffset: function( elem, options, i ) { 18391 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 18392 position = jQuery.css( elem, "position" ), 18393 curElem = jQuery( elem ), 18394 props = {}; 18395 18396 // Set position first, in-case top/left are set even on static elem 18397 if ( position === "static" ) { 18398 elem.style.position = "relative"; 18399 } 18400 18401 curOffset = curElem.offset(); 18402 curCSSTop = jQuery.css( elem, "top" ); 18403 curCSSLeft = jQuery.css( elem, "left" ); 18404 calculatePosition = ( position === "absolute" || position === "fixed" ) && 18405 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; 18406 18407 // Need to be able to calculate position if either 18408 // top or left is auto and position is either absolute or fixed 18409 if ( calculatePosition ) { 18410 curPosition = curElem.position(); 18411 curTop = curPosition.top; 18412 curLeft = curPosition.left; 18413 18414 } else { 18415 curTop = parseFloat( curCSSTop ) || 0; 18416 curLeft = parseFloat( curCSSLeft ) || 0; 18417 } 18418 18419 if ( isFunction( options ) ) { 18420 18421 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 18422 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 18423 } 18424 18425 if ( options.top != null ) { 18426 props.top = ( options.top - curOffset.top ) + curTop; 18427 } 18428 if ( options.left != null ) { 18429 props.left = ( options.left - curOffset.left ) + curLeft; 18430 } 18431 18432 if ( "using" in options ) { 18433 options.using.call( elem, props ); 18434 18435 } else { 18436 curElem.css( props ); 18437 } 18438 } 18439 }; 18440 18441 jQuery.fn.extend( { 18442 18443 // offset() relates an element's border box to the document origin 18444 offset: function( options ) { 18445 18446 // Preserve chaining for setter 18447 if ( arguments.length ) { 18448 return options === undefined ? 18449 this : 18450 this.each( function( i ) { 18451 jQuery.offset.setOffset( this, options, i ); 18452 } ); 18453 } 18454 18455 var rect, win, 18456 elem = this[ 0 ]; 18457 18458 if ( !elem ) { 18459 return; 18460 } 18461 18462 // Return zeros for disconnected and hidden (display: none) elements (gh-2310) 18463 // Support: IE <=11 only 18464 // Running getBoundingClientRect on a 18465 // disconnected node in IE throws an error 18466 if ( !elem.getClientRects().length ) { 18467 return { top: 0, left: 0 }; 18468 } 18469 18470 // Get document-relative position by adding viewport scroll to viewport-relative gBCR 18471 rect = elem.getBoundingClientRect(); 18472 win = elem.ownerDocument.defaultView; 18473 return { 18474 top: rect.top + win.pageYOffset, 18475 left: rect.left + win.pageXOffset 18476 }; 18477 }, 18478 18479 // position() relates an element's margin box to its offset parent's padding box 18480 // This corresponds to the behavior of CSS absolute positioning 18481 position: function() { 18482 if ( !this[ 0 ] ) { 18483 return; 18484 } 18485 18486 var offsetParent, offset, doc, 18487 elem = this[ 0 ], 18488 parentOffset = { top: 0, left: 0 }; 18489 18490 // position:fixed elements are offset from the viewport, which itself always has zero offset 18491 if ( jQuery.css( elem, "position" ) === "fixed" ) { 18492 18493 // Assume position:fixed implies availability of getBoundingClientRect 18494 offset = elem.getBoundingClientRect(); 18495 18496 } else { 18497 offset = this.offset(); 18498 18499 // Account for the *real* offset parent, which can be the document or its root element 18500 // when a statically positioned element is identified 18501 doc = elem.ownerDocument; 18502 offsetParent = elem.offsetParent || doc.documentElement; 18503 while ( offsetParent && 18504 ( offsetParent === doc.body || offsetParent === doc.documentElement ) && 18505 jQuery.css( offsetParent, "position" ) === "static" ) { 18506 18507 offsetParent = offsetParent.parentNode; 18508 } 18509 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) { 18510 18511 // Incorporate borders into its offset, since they are outside its content origin 18512 parentOffset = jQuery( offsetParent ).offset(); 18513 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ); 18514 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ); 18515 } 18516 } 18517 18518 // Subtract parent offsets and element margins 18519 return { 18520 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 18521 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 18522 }; 18523 }, 18524 18525 // This method will return documentElement in the following cases: 18526 // 1) For the element inside the iframe without offsetParent, this method will return 18527 // documentElement of the parent window 18528 // 2) For the hidden or detached element 18529 // 3) For body or html element, i.e. in case of the html node - it will return itself 18530 // 18531 // but those exceptions were never presented as a real life use-cases 18532 // and might be considered as more preferable results. 18533 // 18534 // This logic, however, is not guaranteed and can change at any point in the future 18535 offsetParent: function() { 18536 return this.map( function() { 18537 var offsetParent = this.offsetParent; 18538 18539 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { 18540 offsetParent = offsetParent.offsetParent; 18541 } 18542 18543 return offsetParent || documentElement; 18544 } ); 18545 } 18546 } ); 18547 18548// Create scrollLeft and scrollTop methods 18549 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 18550 var top = "pageYOffset" === prop; 18551 18552 jQuery.fn[ method ] = function( val ) { 18553 return access( this, function( elem, method, val ) { 18554 18555 // Coalesce documents and windows 18556 var win; 18557 if ( isWindow( elem ) ) { 18558 win = elem; 18559 } else if ( elem.nodeType === 9 ) { 18560 win = elem.defaultView; 18561 } 18562 18563 if ( val === undefined ) { 18564 return win ? win[ prop ] : elem[ method ]; 18565 } 18566 18567 if ( win ) { 18568 win.scrollTo( 18569 !top ? val : win.pageXOffset, 18570 top ? val : win.pageYOffset 18571 ); 18572 18573 } else { 18574 elem[ method ] = val; 18575 } 18576 }, method, val, arguments.length ); 18577 }; 18578 } ); 18579 18580// Support: Safari <=7 - 9.1, Chrome <=37 - 49 18581// Add the top/left cssHooks using jQuery.fn.position 18582// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 18583// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347 18584// getComputedStyle returns percent when specified for top/left/bottom/right; 18585// rather than make the css module depend on the offset module, just check for it here 18586 jQuery.each( [ "top", "left" ], function( _i, prop ) { 18587 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 18588 function( elem, computed ) { 18589 if ( computed ) { 18590 computed = curCSS( elem, prop ); 18591 18592 // If curCSS returns percentage, fallback to offset 18593 return rnumnonpx.test( computed ) ? 18594 jQuery( elem ).position()[ prop ] + "px" : 18595 computed; 18596 } 18597 } 18598 ); 18599 } ); 18600 18601 18602// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 18603 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 18604 jQuery.each( { 18605 padding: "inner" + name, 18606 content: type, 18607 "": "outer" + name 18608 }, function( defaultExtra, funcName ) { 18609 18610 // Margin is only for outerHeight, outerWidth 18611 jQuery.fn[ funcName ] = function( margin, value ) { 18612 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 18613 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 18614 18615 return access( this, function( elem, type, value ) { 18616 var doc; 18617 18618 if ( isWindow( elem ) ) { 18619 18620 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) 18621 return funcName.indexOf( "outer" ) === 0 ? 18622 elem[ "inner" + name ] : 18623 elem.document.documentElement[ "client" + name ]; 18624 } 18625 18626 // Get document width or height 18627 if ( elem.nodeType === 9 ) { 18628 doc = elem.documentElement; 18629 18630 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 18631 // whichever is greatest 18632 return Math.max( 18633 elem.body[ "scroll" + name ], doc[ "scroll" + name ], 18634 elem.body[ "offset" + name ], doc[ "offset" + name ], 18635 doc[ "client" + name ] 18636 ); 18637 } 18638 18639 return value === undefined ? 18640 18641 // Get width or height on the element, requesting but not forcing parseFloat 18642 jQuery.css( elem, type, extra ) : 18643 18644 // Set width or height on the element 18645 jQuery.style( elem, type, value, extra ); 18646 }, type, chainable ? margin : undefined, chainable ); 18647 }; 18648 } ); 18649 } ); 18650 18651 18652 jQuery.each( [ 18653 "ajaxStart", 18654 "ajaxStop", 18655 "ajaxComplete", 18656 "ajaxError", 18657 "ajaxSuccess", 18658 "ajaxSend" 18659 ], function( _i, type ) { 18660 jQuery.fn[ type ] = function( fn ) { 18661 return this.on( type, fn ); 18662 }; 18663 } ); 18664 18665 18666 18667 18668 jQuery.fn.extend( { 18669 18670 bind: function( types, data, fn ) { 18671 return this.on( types, null, data, fn ); 18672 }, 18673 unbind: function( types, fn ) { 18674 return this.off( types, null, fn ); 18675 }, 18676 18677 delegate: function( selector, types, data, fn ) { 18678 return this.on( types, selector, data, fn ); 18679 }, 18680 undelegate: function( selector, types, fn ) { 18681 18682 // ( namespace ) or ( selector, types [, fn] ) 18683 return arguments.length === 1 ? 18684 this.off( selector, "**" ) : 18685 this.off( types, selector || "**", fn ); 18686 }, 18687 18688 hover: function( fnOver, fnOut ) { 18689 return this 18690 .on( "mouseenter", fnOver ) 18691 .on( "mouseleave", fnOut || fnOver ); 18692 } 18693 } ); 18694 18695 jQuery.each( 18696 ( "blur focus focusin focusout resize scroll click dblclick " + 18697 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 18698 "change select submit keydown keypress keyup contextmenu" ).split( " " ), 18699 function( _i, name ) { 18700 18701 // Handle event binding 18702 jQuery.fn[ name ] = function( data, fn ) { 18703 return arguments.length > 0 ? 18704 this.on( name, null, data, fn ) : 18705 this.trigger( name ); 18706 }; 18707 } 18708 ); 18709 18710 18711 18712 18713// Support: Android <=4.0 only 18714// Make sure we trim BOM and NBSP 18715// Require that the "whitespace run" starts from a non-whitespace 18716// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position. 18717 var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g; 18718 18719// Bind a function to a context, optionally partially applying any 18720// arguments. 18721// jQuery.proxy is deprecated to promote standards (specifically Function#bind) 18722// However, it is not slated for removal any time soon 18723 jQuery.proxy = function( fn, context ) { 18724 var tmp, args, proxy; 18725 18726 if ( typeof context === "string" ) { 18727 tmp = fn[ context ]; 18728 context = fn; 18729 fn = tmp; 18730 } 18731 18732 // Quick check to determine if target is callable, in the spec 18733 // this throws a TypeError, but we will just return undefined. 18734 if ( !isFunction( fn ) ) { 18735 return undefined; 18736 } 18737 18738 // Simulated bind 18739 args = slice.call( arguments, 2 ); 18740 proxy = function() { 18741 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 18742 }; 18743 18744 // Set the guid of unique handler to the same of original handler, so it can be removed 18745 proxy.guid = fn.guid = fn.guid || jQuery.guid++; 18746 18747 return proxy; 18748 }; 18749 18750 jQuery.holdReady = function( hold ) { 18751 if ( hold ) { 18752 jQuery.readyWait++; 18753 } else { 18754 jQuery.ready( true ); 18755 } 18756 }; 18757 jQuery.isArray = Array.isArray; 18758 jQuery.parseJSON = JSON.parse; 18759 jQuery.nodeName = nodeName; 18760 jQuery.isFunction = isFunction; 18761 jQuery.isWindow = isWindow; 18762 jQuery.camelCase = camelCase; 18763 jQuery.type = toType; 18764 18765 jQuery.now = Date.now; 18766 18767 jQuery.isNumeric = function( obj ) { 18768 18769 // As of jQuery 3.0, isNumeric is limited to 18770 // strings and numbers (primitives or objects) 18771 // that can be coerced to finite numbers (gh-2662) 18772 var type = jQuery.type( obj ); 18773 return ( type === "number" || type === "string" ) && 18774 18775 // parseFloat NaNs numeric-cast false positives ("") 18776 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 18777 // subtraction forces infinities to NaN 18778 !isNaN( obj - parseFloat( obj ) ); 18779 }; 18780 18781 jQuery.trim = function( text ) { 18782 return text == null ? 18783 "" :
18784 ( text + "" ).replace( rtrim, "$1" ); 18785 }; 18786 18787 18788 18789// Register as a named AMD module, since jQuery can be concatenated with other 18790// files that may use define, but not via a proper concatenation script that 18791// understands anonymous AMD modules. A named AMD is safest and most robust 18792// way to register. Lowercase jquery is used because AMD module names are 18793// derived from file names, and jQuery is normally delivered in a lowercase 18794// file name. Do this after creating the global so that if an AMD module wants 18795// to call noConflict to hide this version of jQuery, it will work. 18796 18797// Note that for maximum portability, libraries that are not jQuery should 18798// declare themselves as anonymous modules, and avoid setting a global if an 18799// AMD loader is present. jQuery is a special case. For more information, see 18800// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 18801 18802 if ( typeof define === "function" && define.amd ) { 18803 define( "jquery", [], function() { 18804 return jQuery; 18805 } ); 18806 } 18807 18808 18809 18810 18811 var 18812 18813 // Map over jQuery in case of overwrite 18814 _jQuery = window.jQuery, 18815 18816 // Map over the $ in case of overwrite 18817 _$ = window.$; 18818 18819 jQuery.noConflict = function( deep ) { 18820 if ( window.$ === jQuery ) { 18821 window.$ = _$; 18822 } 18823 18824 if ( deep && window.jQuery === jQuery ) { 18825 window.jQuery = _jQuery; 18826 } 18827 18828 return jQuery; 18829 }; 18830 18831// Expose jQuery and $ identifiers, even in AMD 18832// (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557) 18833// and CommonJS for browser emulators (trac-13566) 18834 if ( typeof noGlobal === "undefined" ) { 18835 window.jQuery = window.$ = jQuery; 18836 } 18837 18838 18839 18840 18841 return jQuery; 18842} ); 18843},{}],46:[function(require,module,exports){ 18844var tempElem; 18845var $ = require("./jquery.js"); 18846var $b = $.build; 18847 18848var that = {}; 18849 18850that.init = function (container){ 18851 tempElem = container.clone().empty().removeAttr("id").css({visibility:"hidden", position:"absolute", top:-500, left:-1000, width:$(window).width()}); 18852 $("body").append(tempElem); 18853 return that; 18854}; 18855 18856that.measure = function (elemToMeasure, selector){ 18857 if(!tempElem){
18858 throw new Error("Must call init before measure"); 18859 } 18860 //measures the real size of a previously unrendered element, by putting it in a 18861 //fake form in a hidden part of the dom then taking its outerWidth then removing it. 18862 var clone = elemToMeasure.clone(); 18863 //clone.show(); 18864 tempElem.append(clone); 18865 18866 var tgt = clone; 18867 var w = clone.outerWidth(); 18868 var h = clone.outerHeight(); 18869 clone.remove(); 18870 return {w:w, h:h}; 18871}; 18872 18873module.exports = that; 18874},{"./jquery.js":45}],47:[function(require,module,exports){ 18875var $ = require("./jquery.js"); 18876var $b = $.build; 18877var measure = require("./measure.js"); 18878 18879var create = function (elem, opts){ 18880 var that = {}; 18881 opts = $.extend({closeBtn:true}, opts); 18882 18883 var modalElem, maskElem, contentElem, mainElem, closeElem, winResizeEvt; 18884 18885 var makeElems = function (){ 18886 modalElem = $b(".mktoModal",[ 18887 maskElem = $b(".mktoModalMask"), 18888 contentElem = $b(".mktoModalContent", [ 18889 closeElem = $b(".mktoModalClose", [" X "]).click(that.modalCloseClicked), 18890 mainElem = $b(".mktoModalMain") 18891 ]) 18892 ]); 18893 return modalElem; 18894 }; 18895 that.modalCloseClicked = function (){ 18896 that.hide(); 18897 }; 18898 var positionContent = function (){ 18899 var h = contentElem.height(); 18900 var w = contentElem.width(); 18901 if(!h || !w){ 18902 setTimeout(positionContent, 25); 18903 return; 18904 } 18905 18906 var winW = $(window).width(); 18907 var winH = $(window).height(); 18908 var scrollTop = $(window).scrollTop(); 18909 var docHeight = $(document).height(); 18910 18911 var offsetW = Math.max(0, (winW/2) - (w/2)); 18912 var offsetH = Math.max(10, (winH/2) - (h/2)); 18913 contentElem.css({ 18914 top:(offsetH + scrollTop )+ "px", 18915 left:offsetW + "px" 18916 }); 18917 maskElem.css("height", docHeight); 18918 }; 18919 18920 that.show = function (){ 18921 var modalElem = makeElems(); 18922 var elemSize = measure.measure(elem); 18923 mainElem.css("width", elemSize.w); 18924 mainElem.append(elem); 18925 if(!opts.closeBtn){ 18926 closeElem.remove(); 18927 } 18928 maskElem.hide(); 18929 contentElem.hide(); 18930 positionContent(); 18931 $("body").append(modalElem); 18932 maskElem.fadeIn(); 18933 contentElem.fadeIn(); 18934 $(window).on("resize.mktoModal", positionContent); 18935 return that; 18936 }; 18937 18938 that.hide = function (){ 18939 maskElem.fadeOut(); 18940 contentElem.fadeOut(function (){ 18941 setTimeout(function (){ 18942 elem.detach(); 18943 modalElem.remove(); 18944 $(window).off("resize.mktoModal"); 18945 },10); 18946 }); 18947 return that; 18948 }; 18949 return that; 18950} 18951module.exports = create; 18952},{"./jquery.js":45,"./measure.js":46}],48:[function(require,module,exports){ 18953/* Modernizr 2.6.2 (Custom Build) | MIT & BSD 18954 * Build: http://modernizr.com/download/#-input-inputtypes-localstorage-postmessage-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-css_boxsizing-forms_validation-load 18955 * 18956 * Modified by itaylor to simplify form validation checking and to make it browerserifyable. 18957 */ 18958; 18959 18960 18961 18962var Modernizr = (function( window, document, undefined ) { 18963 18964 var version = '2.6.2', 18965 18966 Modernizr = {}, 18967 18968 18969 docElement = document.documentElement, 18970 18971 mod = 'modernizr', 18972 modElem = document.createElement(mod), 18973 mStyle = modElem.style, 18974 18975 inputElem = document.createElement('input') , 18976 18977 smile = ':)', 18978 18979 toString = {}.toString, 18980 18981 prefixes = ' -webkit- -moz- -o- -ms- '.split(' '), 18982 18983 18984 18985 omPrefixes = 'Webkit Moz O ms', 18986 18987 cssomPrefixes = omPrefixes.split(' '), 18988 18989 domPrefixes = omPrefixes.toLowerCase().split(' '), 18990 18991 18992 tests = {}, 18993 inputs = {}, 18994 attrs = {}, 18995 18996 classes = [], 18997 18998 slice = classes.slice, 18999 19000 featureName, 19001 19002 19003 injectElementWithStyles = function( rule, callback, nodes, testnames ) { 19004 19005 var style, ret, node, docOverflow, 19006 div = document.createElement('div'), 19007 body = document.body, 19008 fakeBody = body || document.createElement('body'); 19009 19010 if ( parseInt(nodes, 10) ) { 19011 while ( nodes-- ) { 19012 node = document.createElement('div'); 19013 node.id = testnames ? testnames[nodes] : mod + (nodes + 1); 19014 div.appendChild(node); 19015 } 19016 } 19017 19018 var nonceValue = document && document.currentScript && document.currentScript.nonce; 19019 if (nonceValue !== null) { 19020 style = ['­','<style nonce="'+nonceValue+ '" id="s', mod, '">', rule, '</style>'].join(''); 19021 } else { 19022 style = ['­','<style id="s', mod, '">', rule, '</style>'].join(''); 19023 } 19024 div.id = mod; 19025 (body ? div : fakeBody).innerHTML += style; 19026 fakeBody.appendChild(div); 19027 if ( !body ) { 19028 fakeBody.style.background = ''; 19029 fakeBody.style.overflow = 'hidden'; 19030 docOverflow = docElement.style.overflow; 19031 docElement.style.overflow = 'hidden'; 19032 docElement.appendChild(fakeBody); 19033 } 19034 19035 ret = callback(div, rule); 19036 if ( !body ) { 19037 fakeBody.parentNode.removeChild(fakeBody); 19038 docElement.style.overflow = docOverflow; 19039 } else { 19040 div.parentNode.removeChild(div); 19041 } 19042 19043 return !!ret; 19044 19045 }, 19046 19047 19048 19049 isEventSupported = (function() { 19050 19051 var TAGNAMES = { 19052 'select': 'input', 'change': 'input', 19053 'submit': 'form', 'reset': 'form', 19054 'error': 'img', 'load': 'img', 'abort': 'img' 19055 }; 19056 19057 function isEventSupported( eventName, element ) { 19058 19059 element = element || document.createElement(TAGNAMES[eventName] || 'div'); 19060 eventName = 'on' + eventName; 19061 19062 var isSupported = eventName in element; 19063 19064 if ( !isSupported ) { 19065 if ( !element.setAttribute ) { 19066 element = document.createElement('div'); 19067 } 19068 if ( element.setAttribute && element.removeAttribute ) { 19069 element.setAttribute(eventName, ''); 19070 isSupported = is(element[eventName], 'function'); 19071 19072 if ( !is(element[eventName], 'undefined') ) { 19073 element[eventName] = undefined; 19074 } 19075 element.removeAttribute(eventName); 19076 } 19077 } 19078 19079 element = null; 19080 return isSupported; 19081 } 19082 return isEventSupported; 19083 })(), 19084 19085 19086 _hasOwnProperty = ({}).hasOwnProperty, hasOwnProp; 19087 19088 if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) { 19089 hasOwnProp = function (object, property) { 19090 return _hasOwnProperty.call(object, property); 19091 }; 19092 } 19093 else { 19094 hasOwnProp = function (object, property) { 19095 return ((property in object) && is(object.constructor.prototype[property], 'undefined')); 19096 }; 19097 } 19098 19099 19100 if (!Function.prototype.bind) { 19101 Function.prototype.bind = function bind(that) { 19102 19103 var target = this; 19104 19105 if (typeof target != "function") { 19106 throw new TypeError(); 19107 } 19108 19109 var args = slice.call(arguments, 1), 19110 bound = function () { 19111 19112 if (this instanceof bound) { 19113 19114 var F = function(){}; 19115 F.prototype = target.prototype; 19116 var self = new F(); 19117 19118 var result = target.apply( 19119 self, 19120 args.concat(slice.call(arguments)) 19121 ); 19122 if (Object(result) === result) { 19123 return result; 19124 } 19125 return self; 19126 19127 } else { 19128 19129 return target.apply( 19130 that, 19131 args.concat(slice.call(arguments)) 19132 ); 19133 19134 } 19135 19136 }; 19137 19138 return bound; 19139 }; 19140 } 19141 19142 function setCss( str ) { 19143 mStyle.cssText = str; 19144 } 19145 19146 function setCssAll( str1, str2 ) { 19147 return setCss(prefixes.join(str1 + ';') + ( str2 || '' )); 19148 } 19149 19150 function is( obj, type ) { 19151 return typeof obj === type; 19152 } 19153 19154 function contains( str, substr ) {
vendor: 6,116 bytes, lines 19155-19345
19155 return !!~('' + str).indexOf(substr); 19156 } 19157 19158 function testProps( props, prefixed ) { 19159 for ( var i in props ) { 19160 var prop = props[i]; 19161 if ( !contains(prop, "-") && mStyle[prop] !== undefined ) { 19162 return prefixed == 'pfx' ? prop : true; 19163 } 19164 } 19165 return false; 19166 } 19167 19168 function testDOMProps( props, obj, elem ) { 19169 for ( var i in props ) { 19170 var item = obj[props[i]]; 19171 if ( item !== undefined) { 19172 19173 if (elem === false) return props[i]; 19174 19175 if (is(item, 'function')){ 19176 return item.bind(elem || obj); 19177 } 19178 19179 return item; 19180 } 19181 } 19182 return false; 19183 } 19184 19185 function testPropsAll( prop, prefixed, elem ) { 19186 19187 var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), 19188 props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' '); 19189 19190 if(is(prefixed, "string") || is(prefixed, "undefined")) { 19191 return testProps(props, prefixed); 19192 19193 } else { 19194 props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' '); 19195 return testDOMProps(props, prefixed, elem); 19196 } 19197 } tests['postmessage'] = function() { 19198 return !!window.postMessage; 19199 }; 19200 19201 19202 19203 tests['localstorage'] = function() { 19204 try { 19205 localStorage.setItem(mod, mod); 19206 localStorage.removeItem(mod); 19207 return true; 19208 } catch(e) { 19209 return false; 19210 } 19211 }; 19212 19213 19214 function webforms() { 19215 Modernizr['input'] = (function( props ) { 19216 for ( var i = 0, len = props.length; i < len; i++ ) { 19217 attrs[ props[i] ] = !!(props[i] in inputElem); 19218 } 19219 if (attrs.list){ 19220 attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement); 19221 } 19222 return attrs; 19223 })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' ')); 19224 Modernizr['inputtypes'] = (function(props) { 19225 19226 for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) { 19227 19228 inputElem.setAttribute('type', inputElemType = props[i]); 19229 bool = inputElem.type !== 'text'; 19230 19231 if ( bool ) { 19232 19233 inputElem.value = smile; 19234 inputElem.style.cssText = 'position:absolute;visibility:hidden;'; 19235 19236 if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) { 19237 19238 docElement.appendChild(inputElem); 19239 defaultView = document.defaultView; 19240 if (defaultView.getComputedStyle){ 19241 var cs = defaultView.getComputedStyle(inputElem, null); 19242 19243 bool = cs && cs.WebkitAppearance !== 'textfield' && (inputElem.offsetHeight !== 0); 19244 } 19245 19246 19247 19248 docElement.removeChild(inputElem); 19249 19250 } else if ( /^(search|tel)$/.test(inputElemType) ){ 19251 } else if ( /^(url|email)$/.test(inputElemType) ) { 19252 bool = inputElem.checkValidity && inputElem.checkValidity() === false; 19253 19254 } else { 19255 bool = inputElem.value != smile; 19256 } 19257 } 19258 19259 inputs[ props[i] ] = !!bool; 19260 } 19261 return inputs; 19262 })('search tel url email datetime date month week time datetime-local number range color'.split(' ')); 19263 } 19264 for ( var feature in tests ) { 19265 if ( hasOwnProp(tests, feature) ) { 19266 featureName = feature.toLowerCase(); 19267 Modernizr[featureName] = tests[feature](); 19268 19269 classes.push((Modernizr[featureName] ? '' : 'no-') + featureName); 19270 } 19271 } 19272 19273 Modernizr.input || webforms(); 19274 19275 19276 Modernizr.addTest = function ( feature, test ) { 19277 if ( typeof feature == 'object' ) { 19278 for ( var key in feature ) { 19279 if ( hasOwnProp( feature, key ) ) { 19280 Modernizr.addTest( key, feature[ key ] ); 19281 } 19282 } 19283 } else { 19284 19285 feature = feature.toLowerCase(); 19286 19287 if ( Modernizr[feature] !== undefined ) { 19288 return Modernizr; 19289 } 19290 19291 test = typeof test == 'function' ? test() : test; 19292 19293 if (typeof enableClasses !== "undefined" && enableClasses) { 19294 docElement.className += ' ' + (test ? '' : 'no-') + feature; 19295 } 19296 Modernizr[feature] = test; 19297 19298 } 19299 19300 return Modernizr; 19301 }; 19302 19303 19304 setCss(''); 19305 modElem = inputElem = null; 19306 19307 19308 Modernizr._version = version; 19309 19310 Modernizr._prefixes = prefixes; 19311 Modernizr._domPrefixes = domPrefixes; 19312 Modernizr._cssomPrefixes = cssomPrefixes; 19313 19314 19315 Modernizr.hasEvent = isEventSupported; 19316 19317 Modernizr.testProp = function(prop){ 19318 return testProps([prop]); 19319 }; 19320 19321 Modernizr.testAllProps = testPropsAll; 19322 19323 19324 Modernizr.testStyles = injectElementWithStyles; 19325 Modernizr.prefixed = function(prop, obj, elem){ 19326 if(!obj) { 19327 return testPropsAll(prop, 'pfx'); 19328 } else { 19329 return testPropsAll(prop, obj, elem); 19330 } 19331 }; 19332 19333 return Modernizr; 19334 19335})(window, window.document); 19336var yepnope = require("./yepnope.js"); 19337Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0));}; 19338 19339// developer.mozilla.org/en/CSS/box-sizing 19340// github.com/Modernizr/Modernizr/issues/248 19341 19342Modernizr.addTest("boxsizing",function(){ 19343 return Modernizr.testAllProps("boxSizing") && (document.documentMode === undefined || document.documentMode > 7); 19344}); 19345
19346Modernizr.addTest("borderradius", function (){ 19347 return Modernizr.testAllProps('borderRadius'); 19348}); 19349 19350Modernizr.addTest('formvalidation', function(){ 19351 var form = document.createElement('form'); 19352 return ('checkValidity' in form); 19353}); 19354 19355Modernizr.addTest('cors', function (){ 19356 return !!(window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()); 19357}); 19358 19359Modernizr.addTest('textareamaxlength', function (){ 19360 var ta = document.createElement('textarea'); 19361 return ('maxLength' in ta); 19362}); 19363 19364Modernizr.addTest('csstransforms', function() { 19365 return !!Modernizr.testAllProps('transform'); 19366}); 19367 19368Modernizr.addTest('csschecked', function(){ 19369 return Modernizr.testStyles('#modernizr input {width:100px} #modernizr input:checked {width:200px;display:block}', function(elem, rule){ 19370 var cb = document.createElement('input'); 19371 cb.setAttribute("type", "checkbox"); 19372 cb.setAttribute("checked", "checked"); 19373 elem.appendChild(cb); 19374 return cb.offsetWidth >= 200; 19375 }); 19376 }); 19377 19378Modernizr.addTest('json', function (){ 19379 return !! ((window.JSON && JSON.stringify && JSON.parse) && !(document.documentMode && document.documentMode < 9)) 19380}); 19381 19382module.exports = Modernizr; 19383 19384},{"./yepnope.js":55}],49:[function(require,module,exports){ 19385var fh = require("./fields/fieldHelpers.js"); 19386var $ = require("./jquery.js"); 19387 19388var inArr = function (arr, val){ 19389 return $.inArray(val, arr) != -1; 19390} 19391var truthish = ["true", "1", "yes", "Yes"]; 19392var falseish = ["false", "0", "no", "No"]; 19393var booleanish = truthish.concat(falseish); 19394 19395 19396//Looks for the real string value of a pick list value. 19397//So if the field has values "Yes"/"No" and you pass 1 as the candidate, it'd return "Yes". 19398//If it can't find a match, the stringified input is returned. 19399function findPicklistRealValue(field, candidate){ 19400 var orig = candidate; 19401 candidate = ("" + candidate); 19402 var arrToUse = inArr(truthish, candidate) ? truthish : falseish; 19403 19404 for(var i = 0; i < field.PicklistValues.length ; i++){ 19405 var realVal = field.PicklistValues[i].value || ""; 19406 if(inArr(arrToUse, realVal)){ 19407 return realVal; 19408 } 19409 } 19410 return "" + orig; //Not found, return string 19411} 19412 19413function hasTruthyAndFalsey(field){ 19414 var hasTruthy = false; 19415 var hasFalsey = false; 19416 19417 for(var i=0; i < field.PicklistValues.length ; i++ ){ 19418 var val = (field.PicklistValues[i].value || ""); 19419 if(inArr(truthish, val)){ 19420 hasTruthy = true; 19421 } 19422 if(inArr(falseish, val)){ 19423 hasFalsey = true; 19424 } 19425 } 19426 return hasTruthy && hasFalsey; 19427} 19428 19429function hasBlankValue(field){ 19430 for(var i=0; i < field.PicklistValues.length ; i++ ){ 19431 var val = field.PicklistValues[i].value; 19432 if(val === ""){ 19433 return true; 19434 } 19435 } 19436 return false; 19437} 19438 19439 19440//For a picklist to be boolean, it must have a truthy and a falsey value and must have 2 or 3 choices (blanks are allowed) 19441//but it cannot be a multi-select picklist. 19442function isPicklistBoolean(field){ 19443 if(!field.PicklistValues || field.IsMultiselect){ 19444 return false; 19445 } 19446 if(field.PicklistValues.length == 2){ 19447 return hasTruthyAndFalsey(field); 19448 } 19449 if(field.PicklistValues.length == 3){ 19450 return hasTruthyAndFalsey(field) && hasBlankValue(field); 19451 } 19452 return false; 19453} 19454 19455//A checkbox is a boolean if it has exactly one field, and that field is truthy 19456function isCheckboxBoolean(field){ 19457 if(!field.PicklistValues){ 19458 return false; 19459 } 19460 return field.PicklistValues.length == 1 && inArr(truthish, (field.PicklistValues[0].value || "")); 19461} 19462 19463//For a radio to be boolean, it must have a truthy and a falsey value and must have 2 choices 19464function isRadioBoolean(field){ 19465 if(!field.PicklistValues){ 19466 return false; 19467 } 19468 if(field.PicklistValues.length == 2){ 19469 return hasTruthyAndFalsey(field); 19470 } 19471 return false; 19472} 19473 19474function coercePicklist(field, value){ 19475 if(value === null || value === undefined){ 19476 return ""; 19477 } 19478 //A picklist is either a boolean yes/no, or a nullable boolean ""/yes/no, 19479 //a single string, or a comma separated string representing multiple values being selected. 19480 var isBool = isPicklistBoolean(field); 19481 if(value === "" && isBool && !hasBlankValue(field)){ 19482 value = false;
19483 } 19484 if(value !== "" && isBool){ 19485 value = findPicklistRealValue(field, value); 19486 } 19487 return "" + value; 19488} 19489 19490function coerceRadio(field, value){ 19491 if(value === null || value === undefined){ 19492 return ""; 19493 } 19494 //A radio without a blank field that is set to empty string "" should 19495 //check the falsey of the two values. 19496 var isBool = isRadioBoolean(field); 19497 if(value === "" && isBool){ 19498 value = false; 19499 } 19500 if(isBool){ 19501 value = findPicklistRealValue(field, value); 19502 } 19503 return "" + value; 19504} 19505 19506//Form prefill sets full iso date times like this... 19507//2001-01-01 15:00 19508//but we only accept the date part. 19509function coerceDate(field, value){ 19510 if(value === null || value === undefined){ 19511 return ""; 19512 } 19513 value = "" + value; 19514 return value.split(/\s|T/)[0]; 19515} 19516 19517function coerceCheckbox(field, value){ 19518 if(value === null || value === undefined){ 19519 return ""; 19520 } 19521 if(isCheckboxBoolean(field)){ 19522 value = findPicklistRealValue(field, value); 19523 } 19524 return "" + value; 19525} 19526 19527function coerceTypes(prefillData, formData){ 19528 var result = {}; 19529 var fieldsByName = fh.getFieldsByName(fh.getFlattenedFields(formData)); 19530 $.each(prefillData, function (key, value){ 19531 var field = fieldsByName[key]; 19532 //Don't set values for fields that don't exist in the form 19533 if(!field || value === null){ 19534 //mktoPrefilFields uses null to mean "Never Set", not "has a value and that value is null" 19535 //so any field with value === null should be removed from the list of fields to set and 19536 //remain with its current value; 19537 return; 19538 } 19539 var dt = field.Datatype; 19540 if(dt === "picklist"){ 19541 result[key] = coercePicklist(field, value); 19542 }else if(dt === "radio"){ 19543 result[key] = coerceRadio(field, value); 19544 }else if (dt === "checkbox" || dt === "single_checkbox"){ 19545 result[key] = coerceCheckbox(field, value); 19546 }else if (dt === "date"){ 19547 result[key] = coerceDate(field, value); 19548 }else{ 19549 value = "" + value; 19550 result[key] = value; 19551 } 19552 }); 19553 return result; 19554} 19555 19556module.exports.coerceTypes = coerceTypes; 19557 19558},{"./fields/fieldHelpers.js":29,"./jquery.js":45}],50:[function(require,module,exports){ 19559module.exports = safeLog; 19560 19561function safeLog(){ 19562 try{ 19563 if(typeof console !== 'undefined' && typeof console.log === 'function'){ 19564 try{ 19565 console.log.apply(console, arguments); 19566 }catch(ex){ 19567 console.log(Array.prototype.slice.call(arguments, 0)); 19568 } 19569 } 19570 }catch(ex){ 19571 //logging is not worth throwing an exception over 19572 } 19573} 19574},{}],51:[function(require,module,exports){ 19575//In a perfect world, Old IE wouldn't exist, or we wouldn't care about it. 19576//In a more perfect world, Browserify would be able to handle/guarantee old IE compatibility 19577//In an ok world, we'd be able to include a whole ES5-shim without bloating the download size or messing up customer's existing JS 19578//In the real world, we're stuck with only monkey patching the things that are blatantly broken. 19579 19580//This file contains selected ES5 monkey patches that are as minimal in size and scope as possible. 19581module.exports = {}; 19582var $ = require("./jquery.js"); 19583 19584// 19585// Function 19586// ======== 19587// 19588 19589// ES-5 15.3.4.5 19590// http://es5.github.com/#x15.3.4.5 19591 19592function Empty() {} 19593 19594if (!Function.prototype.bind) { 19595 Function.prototype.bind = function bind(that) { // .length is 1 19596 // 1. Let Target be the this value. 19597 var target = this; 19598 // 2. If IsCallable(Target) is false, throw a TypeError exception. 19599 if (typeof target != "function") { 19600 throw new TypeError("Function.prototype.bind called on incompatible " + target); 19601 } 19602 // 3. Let A be a new (possibly empty) internal list of all of the 19603 // argument values provided after thisArg (arg1, arg2 etc), in order. 19604 // XXX slicedArgs will stand in for "A" if used 19605 var args = _Array_slice_.call(arguments, 1); // for normal call 19606 // 4. Let F be a new native ECMAScript object. 19607 // 11. Set the [[Prototype]] internal property of F to the standard 19608 // built-in Function prototype object as specified in 15.3.3.1. 19609 // 12. Set the [[Call]] internal property of F as described
vendor: 5,459 bytes, lines 19609-19728
19609in 19610 // 15.3.4.5.1. 19611 // 13. Set the [[Construct]] internal property of F as described in 19612 // 15.3.4.5.2. 19613 // 14. Set the [[HasInstance]] internal property of F as described in 19614 // 15.3.4.5.3. 19615 var binder = function () { 19616 19617 if (this instanceof bound) { 19618 // 15.3.4.5.2 [[Construct]] 19619 // When the [[Construct]] internal method of a function object, 19620 // F that was created using the bind function is called with a 19621 // list of arguments ExtraArgs, the following steps are taken: 19622 // 1. Let target be the value of F's [[TargetFunction]] 19623 // internal property. 19624 // 2. If target has no [[Construct]] internal method, a 19625 // TypeError exception is thrown. 19626 // 3. Let boundArgs be the value of F's [[BoundArgs]] internal 19627 // property. 19628 // 4. Let args be a new list containing the same values as the 19629 // list boundArgs in the same order followed by the same 19630 // values as the list ExtraArgs in the same order. 19631 // 5. Return the result of calling the [[Construct]] internal 19632 // method of target providing args as the arguments. 19633 19634 var result = target.apply( 19635 this, 19636 args.concat(_Array_slice_.call(arguments)) 19637 ); 19638 if (Object(result) === result) { 19639 return result; 19640 } 19641 return this; 19642 19643 } else { 19644 // 15.3.4.5.1 [[Call]] 19645 // When the [[Call]] internal method of a function object, F, 19646 // which was created using the bind function is called with a 19647 // this value and a list of arguments ExtraArgs, the following 19648 // steps are taken: 19649 // 1. Let boundArgs be the value of F's [[BoundArgs]] internal 19650 // property. 19651 // 2. Let boundThis be the value of F's [[BoundThis]] internal 19652 // property. 19653 // 3. Let target be the value of F's [[TargetFunction]] internal 19654 // property. 19655 // 4. Let args be a new list containing the same values as the 19656 // list boundArgs in the same order followed by the same 19657 // values as the list ExtraArgs in the same order. 19658 // 5. Return the result of calling the [[Call]] internal method 19659 // of target providing boundThis as the this value and 19660 // providing args as the arguments. 19661 19662 // equiv: target.call(this, ...boundArgs, ...args) 19663 return target.apply( 19664 that, 19665 args.concat(_Array_slice_.call(arguments)) 19666 ); 19667 19668 } 19669 19670 }; 19671 19672 // 15. If the [[Class]] internal property of Target is "Function", then 19673 // a. Let L be the length property of Target minus the length of A. 19674 // b. Set the length own property of F to either 0 or L, whichever is 19675 // larger. 19676 // 16. Else set the length own property of F to 0. 19677 19678 var boundLength = Math.max(0, target.length - args.length); 19679 19680 // 17. Set the attributes of the length own property of F to the values 19681 // specified in 15.3.5.1. 19682 var boundArgs = []; 19683 for (var i = 0; i < boundLength; i++) { 19684 boundArgs.push("$" + i); 19685 } 19686 19687 // XXX Build a dynamic function with desired amount of arguments is the only 19688 // way to set the length property of a function. 19689 // In environments where Content Security Policies enabled (Chrome extensions, 19690 // for ex.) all use of eval or Function costructor throws an exception. 19691 // However in all of these environments Function.prototype.bind exists 19692 // and so this code will never be executed. 19693 /*jshint -W061 */ 19694 var bound = Function("binder", "return function(" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder); 19695 19696 if (target.prototype) { 19697 Empty.prototype = target.prototype; 19698 bound.prototype = new Empty(); 19699 // Clean up dangling references. 19700 Empty.prototype = null; 19701 } 19702 19703 // TODO 19704 // 18. Set the [[Extensible]] internal property of F to true. 19705 19706 // TODO 19707 // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). 19708 // 20. Call the [[DefineOwnProperty]] internal method of F with 19709 // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: 19710 // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and 19711 // false. 19712 // 21. Call the [[DefineOwnProperty]] internal method of F with 19713 // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, 19714 // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, 19715 // and false. 19716 19717 // TODO 19718 // NOTE Function objects created using Function.prototype.bind do not 19719 // have a prototype property or the [[Code]], [[FormalParameters]], and 19720 // [[Scope]] internal properties. 19721 // XXX can't delete prototype in pure-js. 19722 19723 // 22. Return F. 19724 return bound; 19725 }; 19726} 19727 19728// Shortcut to an often accessed properties, in order to avoid multiple
19729// dereference that costs universally. 19730// _Please note: Shortcuts are defined after `Function.prototype.bind` as we 19731// us it in defining shortcuts. 19732var call = Function.prototype.call; 19733var prototypeOfArray = Array.prototype; 19734var prototypeOfObject = Object.prototype; 19735var _Array_slice_ = prototypeOfArray.slice; 19736// Having a toString local variable name breaks in Opera so use _toString. 19737var _toString = call.bind(prototypeOfObject.toString); 19738var owns = call.bind(prototypeOfObject.hasOwnProperty); 19739 19740 19741// ES5 15.2.3.14 19742// http://es5.github.com/#x15.2.3.14 19743if (!Object.keys) { 19744 // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation 19745 var hasDontEnumBug = true, 19746 hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'), 19747 dontEnums = [ 19748 "toString", 19749 "toLocaleString", 19750 "valueOf", 19751 "hasOwnProperty", 19752 "isPrototypeOf", 19753 "propertyIsEnumerable", 19754 "constructor" 19755 ], 19756 dontEnumsLength = dontEnums.length; 19757 19758 for (var key in {"toString": null}) { 19759 hasDontEnumBug = false; 19760 } 19761 19762 /* jshint -W004 */ 19763 Object.keys = function keys(object) { 19764 var isFunction = _toString(object) === '[object Function]', 19765 isObject = object !== null && typeof object === 'object'; 19766 19767 if (!isObject && !isFunction) { 19768 throw new TypeError("Object.keys called on a non-object"); 19769 } 19770 19771 var keys = [], 19772 skipProto = hasProtoEnumBug && isFunction; 19773 for (var name in object) { 19774 if (!(skipProto && name === 'prototype') && owns(object, name)) { 19775 keys.push(name); 19776 } 19777 } 19778 19779 if (hasDontEnumBug) { 19780 var ctor = object.constructor, 19781 skipConstructor = ctor && ctor.prototype === object; 19782 for (var i = 0; i < dontEnumsLength; i++) { 19783 var dontEnum = dontEnums[i]; 19784 if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) { 19785 keys.push(dontEnum); 19786 } 19787 } 19788 } 19789 return keys; 19790 }; 19791} 19792 19793if(!String.prototype.trim){ 19794 String.prototype.trim = function (){ 19795 return $.trim(this); 19796 } 19797} 19798 19799if (!Array.prototype.map){ 19800 Array.prototype.map = function(fn){ 19801 return $.map(this, fn); 19802 } 19803} 19804 19805// ECMA-262, 3rd B.2.3 19806// Note an ECMAScript standart, although ECMAScript 3rd Edition has a 19807// non-normative section suggesting uniform semantics and it should be 19808// normalized across all browsers 19809// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE 19810if ("".substr && "0b".substr(-1) !== "b") { 19811 var string_substr = String.prototype.substr; 19812 /** 19813 * Get the substring of a string 19814 * @param {integer} start where to start the substring 19815 * @param {integer} length how many characters to return 19816 * @return {string} 19817 */ 19818 String.prototype.substr = function(start, length) { 19819 return string_substr.call( 19820 this, 19821 start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start, 19822 length 19823 ); 19824 } 19825} 19826},{"./jquery.js":45}],52:[function(require,module,exports){ 19827var $ = require("./jquery.js"); 19828/** 19829 Weird token template renderer. 19830 "Tokens" look like {{namespace.name:attribute=value&attribute2=some other value}}. 19831 Sometimes, a token is a simple substitution, sometimes it's a method call to pass a value. 19832 19833 so given a string template 19834 "here is a value tag: {{token.number1}} and here is a method call tag: {{something.special:key=value}}"" 19835 And mappings object: 19836 { 19837 token:{ 19838 number1:1 19839 }, 19840 something:{ 19841 special:function (attrs){ 19842 return "special " + attrs.key; 19843 } 19844 } 19845 } 19846 You'd get "here is a value tag: 1 and here is a method call tag: special value" 19847*/ 19848function tokenTemplate (template, mappings){ 19849 var tokens = template.match(/\{\{.*?\}\}/g); 19850 if(!tokens){ 19851 return template; 19852 } 19853 var swaps = {} 19854 $.each(tokens, function (i, token){ 19855 var tok = token.match(/\{\{\s?(\w*)\.(\w*)\s?:?\s?(.*?)\}\}/); 19856 if(tok){ 19857 var tokVal = tok[0]; 19858 var namespace = tok[1]; 19859 var name= tok[2]; 19860 var attribs = tok[3] || ""; 19861 if(!namespace || !name || !mappings[namespace] || !mappings[namespace][name]){ 19862 return; 19863 } 19864 var thing = mappings[namespace][name]; 19865 if(typeof thing == "function"){ 19866 attribParts = attribs.split("&"); 19867 var attribMap = {}; 19868 $.each(attribParts, function (i, attr){ 19869 var p = attr.split("="); 19870 if(p.length == 2){ 19871 attribMap[$.trim(decodeURIComponent(p[0]))] = $.trim(decodeURIComponent(p[1])); 19872 } 19873 }); 19874 swaps[tokVal] = thing(attribMap); 19875 }else{ 19876 swaps[tokVal] = thing.toString(); 19877 } 19878 } 19879 }); 19880 var result = template; 19881 $.each(swaps, function (k, v){ 19882 result = result.split(k).join(v); 19883 }); 19884 return result; 19885} 19886 19887module.exports = tokenTemplate; 19888},{"./jquery.js":45}],53:[function(require,module,exports){ 19889var url = require("url"); 19890var $ = require("./jquery.js"); 19891 19892function swapHostsProtocols(dest, source){ 19893 if(!dest || !source){ 19894 return dest; 19895 } 19896 dest = url.parse(dest); 19897 source = url.parse(source); 19898 dest.protocol = source.protocol; 19899 dest.host = source.host; 19900 return url.format(dest); 19901} 19902 19903//This function takes a url like: 19904//http://whatever.mycustomercname.com/foobar.html?blah=whatever as dest 19905//and a url like: 19906//https://pod-name.marketo.com/lp/mycustomername/fizbuzz.html as source 19907//and creates a new url that preserves the customer source protocol, hostname, and partial path, like: 19908//https://pod-name.markteo.com/lp/mycustomername/foobar.html?blah=whatever 19909 19910function remapLandingPageUrl(dest, source){ 19911 if(!dest || !source){ 19912 return dest; 19913 } 19914 dest = url.parse(dest); 19915 source = url.parse(source); 19916 dest.protocol = source.protocol; 19917 dest.host = source.host; 19918 destPathParts = dest.path.split("/"); 19919 sourcePathParts = source.path.split("/"); 19920 if(sourcePathParts[1] === "lp" && sourcePathParts.length >= 3 && destPathParts[1] !== "lp"){ 19921 dest.pathname = sourcePathParts.slice(0, 3).join("/").concat(dest.pathname); 19922 } 19923 return url.format(dest); 19924} 19925 19926function addQueryParams(u, params){ 19927 var urlObj = url.parse(u, true); 19928 $.extend(urlObj.query, params); 19929 urlObj.search = ""; 19930 u = url.format(urlObj); 19931 return u; 19932} 19933 19934function removeQueryParams(u, params){ 19935 if(!params){ 19936 return u; 19937 } 19938 if(!$.isArray(params)){ 19939 params = [""+params] 19940 } 19941 var urlObj = url.parse(u, true); 19942 $.each(params, function (i, param){ 19943 delete urlObj.query[param]; 19944 }); 19945 urlObj.search = ""; 19946 u = url.format(urlObj); 19947 return u; 19948} 19949 19950module.exports = { 19951 swapHostsProtocols:swapHostsProtocols, 19952 addQueryParams:addQueryParams, 19953 removeQueryParams:removeQueryParams, 19954 remapLandingPageUrl:remapLandingPageUrl 19955}; 19956},{"./jquery.js":45,"url":23}],54:[function(require,module,exports){ 19957var $ = require("./jquery.js"); 19958var $b = $.build; 19959var measure = require("./measure.js"); 19960var modernizr = require("./modernizr.js"); 19961var fh = require("./fields/fieldHelpers.js"); 19962 19963var Validation = function (formElem, formData){ 19964 var that = {}; 19965 var isAccessibilityImprovementsEnabled = formData && formData.ProcessOptions && formData.ProcessOptions.isAccessibilityImprovementsEnabled; 19966 that.currentErrorElem = null; 19967 that.currentErrorMsg = null; 19968 var selector = ".mktoFieldDescriptor"; 19969 19970 that.checkOne = function(elem){ 19971 var okRequired = true; 19972 var okValidator = true; 19973 var desc = elem.data("mktoFieldDescriptor"); 19974 var val = desc.val(); 19975 if(desc.required){ 19976 if(desc.requiredValFn){ 19977 okRequired = desc.requiredValFn(val); 19978 }else{ 19979 okRequired = !! $.trim(val); 19980 } 19981 } 19982 if(desc.validator){ 19983 okValidator = desc.validator(desc.val()); 19984 } 19985 if(okRequired && okValidator && desc.validatorElem){ 19986 desc.validatorElem.removeClass("mktoInvalid"); 19987 desc.validatorElem.addClass("mktoValid"); 19988 var currentDescribedBy = desc.validatorElem.attr("aria-describedby");
19989 var validMsgId = fh.getValidationMsgId(desc.name); 19990 if (currentDescribedBy && currentDescribedBy.indexOf(validMsgId) >= 0) { 19991 var removedErrorMsgId = currentDescribedBy.replace(validMsgId, '').trim(); 19992 if (removedErrorMsgId) { 19993 desc.validatorElem.attr("aria-describedby", removedErrorMsgId); 19994 } else { 19995 desc.validatorElem.removeAttr("aria-describedby"); 19996 } 19997 } 19998 desc.validatorElem.attr("aria-invalid", "false"); 19999 } 20000 else if(desc.validatorElem){ 20001 desc.validatorElem.removeClass("mktoValid"); 20002 desc.validatorElem.addClass("mktoInvalid"); 20003 } 20004 if(!okRequired){ 20005 return desc.requiredMessage || desc.validationMessage || "This field is required"; 20006 } 20007 if(!okValidator){ 20008 return desc.validationMessage || "Validation failed"; 20009 } 20010 return null; 20011 }; 20012 20013 that.checkOneAndHide = function (){ 20014 var e = $(this); 20015 var msg = that.checkOne(e); 20016 if(!msg && that.currentErrorMsg){ 20017 that.currentErrorMsg.fadeOut(); 20018 } 20019 } 20020 20021 that.checkOneAndShow = function (){ 20022 var e = $(this); 20023 if(e.data("mktoErrorShowBlocked")){ 20024 return that.checkOneAndHide.call(this); 20025 } 20026 var validatorElem = e.data("mktoFieldDescriptor").validatorElem; 20027 var msg = that.checkOne(e); 20028 if(msg){ 20029 if(that.currentErrorElem != e){ 20030 if(that.currentErrorMsg){ 20031 that.currentErrorMsg.fadeOut(); 20032 } 20033 that.showError(validatorElem, msg); 20034 } 20035 }else{ 20036 if(that.currentErrorMsg){ 20037 that.currentErrorMsg.fadeOut(); 20038 } 20039 } 20040 } 20041 20042 that.initScoped = function (scope){ 20043 var initFn = function (i, e){ 20044 e = $(e); 20045 e.data("mktoErrorShowBlocked", true); 20046 var unblock = function (){ 20047 e.data("mktoErrorShowBlocked", false); 20048 that.checkOneAndHide.call(this); 20049 } 20050 var filterDivTargets = function (next){ 20051 return function (e){ 20052 if(e.target.tagName.toLowerCase() != 'div'){ 20053 next.apply(this, arguments); 20054 } 20055 } 20056 } 20057 // LM-90069: Multi-select checkboxes, the "required" feature (check at least one) needs special treatment 20058 if (e.find(".mktoLogicalField.mktoCheckboxList").length > 0) { 20059 e.on("focusout", filterDivTargets(unblock)) 20060 .on("keyup", unblock) 20061 // LM-101548: Form required boolean checkbox fields ("This field is required") are not working. 20062 .on("click", that.checkOneAndHide); 20063 return; 20064 } 20065 e.on("focusin", filterDivTargets(that.checkOneAndShow)) 20066 .on("focusout", filterDivTargets(unblock)) 20067 .on("keyup", unblock) 20068 .on("click", that.checkOneAndHide); 20069 }; 20070 scope.find(selector).each(initFn); 20071 if(scope.is(selector)){ 20072 var e = scope.get(0); 20073 initFn.call(e, 0, e); 20074 } 20075 } 20076 20077 that.init = function (){ 20078 that.clear(); 20079 that.initScoped(formElem); 20080 } 20081 20082 that.showError = function (elem, errorMsg){ 20083 if(that.currentErrorMsg){ 20084 that.currentErrorMsg.remove(); 20085 } 20086 var arrowWrap; 20087 var elemName; 20088 if (typeof elem[0].name !== "undefined" || (elem[0].childNodes[0] && typeof elem[0].childNodes[0].name !== "undefined")) { 20089 elemName = typeof elem[0].name !== "undefined" ? elem[0].name : elem[0].childNodes[0].name; 20090 } 20091 var errorMsgId = fh.getValidationMsgId(elemName); 20092 20093 var errorMsgAttrs = {"id": errorMsgId, "tabindex": "-1"}; 20094 if (isAccessibilityImprovementsEnabled) { 20095 errorMsgAttrs["aria-live"] = "assertive"; 20096 errorMsgAttrs["aria-atomic"] = "true"; 20097 } else { 20098 errorMsgAttrs.role = "alert"; 20099 } 20100 var errorMsgElem = $b(".mktoErrorMsg", errorMsgAttrs, $b.html(errorMsg)); 20101 20102 var errorBox = $b(".mktoError", [ 20103 arrowWrap = $b(".mktoErrorArrowWrap",[$b(".mktoErrorArrow")]), 20104 errorMsgElem 20105 ]).hide(); 20106 20107 if(!modernizr.csstransforms){ 20108 arrowWrap.addClass("mktoArrowImage"); 20109 } 20110 20111 elem.after(errorBox); 20112 var current = (elem.attr("aria-describedby") || "").trim(); 20113 var ids = current ? current.split(" ") : []; 20114 if (ids.indexOf(errorMsgId) === -1) { 20115 ids.push(errorMsgId); 20116 elem.attr("aria-describedby", ids.join(" ")); 20117 } 20118 elem.attr("aria-invalid", "true"); 20119 20120 that.currentErrorElem = elem; 20121 that.currentErrorMsg = errorBox; 20122 var dims = measure.measure(errorBox); 20123 var right; 20124 var ow = elem.outerWidth(); 20125 if( ow < dims.w){ 20126 right = -1 * (dims.w - ow); 20127 }else{ 20128 right = (ow - dims.w) / 2; 20129 } 20130 errorBox.css({ 20131 right: right, 20132 bottom: -1 * dims.h 20133 }) 20134 errorBox.fadeIn(); 20135 }; 20136 20137 that.check = function (){ 20138 that.clear(); 20139 var firstError = null; 20140 formElem.find(selector).each(function (){ 20141 var e = $(this); 20142 e.data("mktoErrorShowBlocked", false); 20143 var errorMsg = that.checkOne(e); 20144 if(errorMsg && !firstError){ 20145 firstError = e; 20146 } 20147 }) 20148 if(firstError){ 20149 var desc = firstError.data("mktoFieldDescriptor"); 20150 var errorElem = desc.validatorFocusElem || desc.validatorElem; 20151 if(errorElem){ 20152 setTimeout(function (){ 20153 errorElem.focus(); 20154 // LM-101548: Form required boolean checkbox fields ("This field is required") are not working. 20155 // Only for checkboxs (single or multi), conduct 'checkOneAndShow' at submit time, instead of using 'focu
20155sin' 20156 if (firstError.find(".mktoLogicalField.mktoCheckboxList").length > 0) { 20157 that.checkOneAndShow.call(firstError); 20158 } 20159 }, 10); 20160 } 20161 return false; 20162 } 20163 return true; 20164 }; 20165 20166 that.clear = function (){ 20167 that.currentErrorElem = null; 20168 that.currentErrorMsg = null; 20169 formElem.find(".mktoInvalid").removeClass("mktoInvalid"); 20170 formElem.find(".mktoValid").removeClass("mktoValid"); 20171 formElem.find(".mktoError").remove(); 20172 }; 20173 return that; 20174} 20175 20176module.exports = Validation 20177},{"./fields/fieldHelpers.js":29,"./jquery.js":45,"./measure.js":46,"./modernizr.js":48}],55:[function(require,module,exports){ 20178// yepnope.js 20179// Version - 1.5.4pre 20180// 20181// by 20182// Alex Sexton - @SlexAxton - AlexSexton[at]gmail.com 20183// Ralph Holzmann - @ralphholzmann - ralphholzmann[at]gmail.com 20184// 20185// http://yepnopejs.com/ 20186// https://github.com/SlexAxton/yepnope.js/ 20187// 20188// Tri-license - WTFPL | MIT | BSD 20189// 20190// Please minify before use. 20191// Also available as Modernizr.load via the Modernizr Project 20192// 20193( function ( window, doc, undef ) { 20194 20195var docElement = doc.documentElement, 20196 sTimeout = window.setTimeout, 20197 firstScript = doc.getElementsByTagName( "script" )[ 0 ], 20198 toString = {}.toString, 20199 execStack = [], 20200 started = 0, 20201 noop = function () {}, 20202 // Before you get mad about browser sniffs, please read: 20203 // https://github.com/Modernizr/Modernizr/wiki/Undetectables 20204 // If you have a better solution, we are actively looking to solve the problem 20205 isGecko = ( "MozAppearance" in docElement.style ), 20206 isGeckoLTE18 = isGecko && !! doc.createRange().compareNode, 20207 insBeforeObj = isGeckoLTE18 ? docElement : firstScript.parentNode, 20208 // Thanks to @jdalton for showing us this opera detection (by way of @kangax) (and probably @miketaylr too, or whatever...) 20209 isOpera = window.opera && toString.call( window.opera ) == "[object Opera]", 20210 isIE = !! doc.attachEvent && !isOpera, 20211 // isOlderWebkit fix for #95 - https://github.com/SlexAxton/yepnope.js/issues/95 20212 isOlderWebkit = ( 'webkitAppearance' in docElement.style ) && !( 'async' in doc.createElement('script') ), 20213 strJsElem = isGecko ? "object" : (isIE || isOlderWebkit) ? "script" : "img", 20214 strCssElem = isIE ? "script" : (isOlderWebkit) ? "img" : strJsElem, 20215 isArray = Array.isArray || function ( obj ) { 20216 return toString.call( obj ) == "[object Array]"; 20217 }, 20218 isObject = function ( obj ) { 20219 return Object(obj) === obj; 20220 }, 20221 isString = function ( s ) { 20222 return typeof s == "string"; 20223 }, 20224 isFunction = function ( fn ) { 20225 return toString.call( fn ) == "[object Function]"; 20226 }, 20227 readFirstScript = function() { 20228 if (!firstScript || !firstScript.parentNode) { 20229 firstScript = doc.getElementsByTagName( "script" )[ 0 ]; 20230 } 20231 }, 20232 globalFilters = [], 20233 scriptCache = {}, 20234 prefixes = { 20235 // key value pair timeout options 20236 timeout : function( resourceObj, prefix_parts ) { 20237 if ( prefix_parts.length ) { 20238 resourceObj['timeout'] = prefix_parts[ 0 ]; 20239 } 20240 return resourceObj; 20241 } 20242 }, 20243 handler, 20244 yepnope; 20245 20246 /* Loader helper functions */ 20247 function isFileReady ( readyState ) { 20248 // Check to see if any of the ways a file can be ready are available as properties on the file's element 20249 return ( ! readyState || readyState == "loaded" || readyState == "complete" || readyState == "uninitialized" ); 20250 } 20251 20252 20253 // Takes a preloaded js obj (changes in different browsers) and injects it into the head 20254 // in the appropriate order 20255 function injectJs ( src, cb, attrs, timeout, /* internal use */ err, internal ) { 20256 20257 var script = doc.createElement( "script" ), 20258 done, i; 20259 20260 timeout = timeout || yepnope['errorTimeout']; 20261 20262 script.src = src; 20263 20264 // Add our extra attributes to the script element 20265 for ( i in attrs ) { 20266 script.setAttribute( i, attrs[ i ] ); 20267 } 20268 20269 cb = internal ? executeStack : ( cb || noop ); 20270 20271 // Bind to load events 20272 script.onreadystatechange = script.onload = function () { 20273 20274 if ( ! done && isFileReady( script.readyState ) ) { 20275 20276 // Set done to prevent this function from being called twice. 20277 done = 1; 20278 cb(); 20279 20280 // Handle memory leak in IE 20281 script.onload = script.onreadystatechange = null; 20282 } 20283 }; 20284 20285 // 404 Fallback 20286 setTimeout(function () { 20287 if ( ! done ) { 20288 done = 1; 20289 // Might as well pass in an error-state if we fire the 404 fallback 20290 cb(1); 20291 } 20292 }, timeout ); 20293 20294 // Inject script into to document 20295 // or immediately callback if we know there 20296 // was previously a timeout error 20297 readFirstScript(); 20298 err ? script.onload() : firstScript.parentNode.insertBefore( script, firstScript ); 20299 } 20300 20301 // Takes a preloaded css obj (changes in different browsers) and injects it into the head 20302 function injectCss ( href, cb, attrs, timeout, /* Internal use */ err, internal ) { 20303 20304 // Create stylesheet link 20305 var link = doc.createElement( "link" ), 20306 done, i; 20307 20308 timeout = timeout || yepnope['errorTimeout']; 20309 20310 cb = internal ? executeStack : ( cb || noop ); 20311 20312 // Add attributes 20313 link.href = href; 20314 link.rel = "stylesheet"; 20315 link.type = "text/css"; 20316 20317 // Add our extra attributes to the link element 20318 for ( i in attrs ) { 20319 link.setAttribute( i, attrs[ i ] ); 20320 } 20321 20322 if ( ! err ) { 20323 readFirstScript(); 20324 firstScript.parentNode.insertBefore( link, firstScript ); 20325 setTimeout(cb, 0); 20326 } 20327 } 20328 20329 function executeStack ( ) { 20330 // shift an element off of the stack 20331 var i = execStack.shift(); 20332 started = 1; 20333 20334 // if a is truthy and the first item in the stack has an src 20335 if ( i ) { 20336 // if it's a script, inject it into the head with no type attribute 20337 if ( i['t'] ) { 20338 // Inject after a timeout so FF has time to be a jerk about it and 20339 // not double load (ignore the cache) 20340 setTimeout( function () { 20341 (i['t'] == "c" ? yepnope['injectCss'] : yepnope['injectJs'])( i['s'], 0, i['a'], i['x'], i['e'], 1 ); 20342 }, 0 ); 20343 } 20344 // Otherwise, just call the function and potentially run the stack 20345 else { 20346 i(); 20347 executeStack(); 20348 } 20349 } 20350 else { 20351 // just reset out of recursive mode 20352 started = 0; 20353 } 20354 } 20355 20356 function preloadFile ( elem, url, type, splicePoint, dontExec, attrObj, timeout ) { 20357 20358 timeout = timeout || yepnope['errorTimeout']; 20359 20360 // Create appropriate element for browser and type 20361 var preloadElem = doc.createElement( elem ), 20362 done = 0, 20363 firstFlag = 0, 20364 stackObject = { 20365 "t": type, // type 20366 "s": url, // src 20367 //r: 0, // ready 20368 "e": dontExec,// set to true if we don't want to reinject 20369 "a": attrObj, 20370 "x": timeout 20371 }; 20372 20373 // The first time (common-case) 20374 if ( scriptCache[ url ] === 1 ) { 20375 firstFlag = 1; 20376 scriptCache[ url ] = []; 20377 } 20378
20379 function onload ( first ) { 20380 // If the script/css file is loaded 20381 if ( ! done && isFileReady( preloadElem.readyState ) ) { 20382 20383 // Set done to prevent this function from being called twice. 20384 stackObject['r'] = done = 1; 20385 20386 ! started && executeStack(); 20387 20388 if ( first ) { 20389 if ( elem != "img" ) { 20390 setTimeout(function(){ insBeforeObj.removeChild( preloadElem ) }, 50); 20391 } 20392 20393 for ( var i in scriptCache[ url ] ) { 20394 if ( scriptCache[ url ].hasOwnProperty( i ) ) { 20395 scriptCache[ url ][ i ].onload(); 20396 } 20397 } 20398 20399 // Handle memory leak in IE 20400 preloadElem.onload = preloadElem.onreadystatechange = null; 20401 } 20402 } 20403 } 20404 20405 20406 // Setting url to data for objects or src for img/scripts 20407 if ( elem == "object" ) { 20408 preloadElem.data = url; 20409 20410 // Setting the type attribute to stop Firefox complaining about the mimetype when running locally. 20411 // The type doesn't matter as long as it's real, thus text/css instead of text/javascript. 20412 preloadElem.setAttribute("type", "text/css"); 20413 } else { 20414 preloadElem.src = url; 20415 20416 // Setting bogus script type to allow the script to be cached 20417 preloadElem.type = elem; 20418 } 20419 20420 // Don't let it show up visually 20421 preloadElem.width = preloadElem.height = "0"; 20422 20423 // Attach handlers for all browsers 20424 preloadElem.onerror = preloadElem.onload = preloadElem.onreadystatechange = function(){ 20425 onload.call(this, firstFlag); 20426 }; 20427 // inject the element into the stack depending on if it's 20428 // in the middle of other scripts or not 20429 execStack.splice( splicePoint, 0, stackObject ); 20430 20431 // The only place these can't go is in the <head> element, since objects won't load in there 20432 // so we have two options - insert before the head element (which is hard to assume) - or 20433 // insertBefore technically takes null/undefined as a second param and it will insert the element into 20434 // the parent last. We try the head, and it automatically falls back to undefined. 20435 if ( elem != "img" ) { 20436 // If it's the first time, or we've already loaded it all the way through 20437 if ( firstFlag || scriptCache[ url ] === 2 ) { 20438 readFirstScript(); 20439 insBeforeObj.insertBefore( preloadElem, isGeckoLTE18 ? null : firstScript ); 20440 20441 // If something fails, and onerror doesn't fire, 20442 // continue after a timeout. 20443 setTimeout( onload, timeout ); 20444 } 20445 else { 20446 // instead of injecting, just hold on to it 20447 scriptCache[ url ].push( preloadElem ); 20448 } 20449 } 20450 } 20451 20452 function load ( resource, type, dontExec, attrObj, timeout ) { 20453 // If this method gets hit multiple times, we should flag 20454 // that the execution of other threads should halt. 20455 started = 0; 20456 20457 // We'll do 'j' for js and 'c' for css, yay for unreadable minification tactics 20458 type = type || "j"; 20459 if ( isString( resource ) ) { 20460 // if the resource passed in here is a string, preload the file 20461 preloadFile( type == "c" ? strCssElem : strJsElem, resource, type, this['i']++, dontExec, attrObj, timeout ); 20462 } else { 20463 // Otherwise it's a callback function and we can splice it into the stack to run 20464 execStack.splice( this['i']++, 0, resource ); 20465 execStack.length == 1 && executeStack(); 20466 } 20467 20468 // OMG is this jQueries? For chaining... 20469 return this; 20470 } 20471 20472 // return the yepnope object with a fresh loader attached 20473 function getYepnope () { 20474 var y = yepnope; 20475 y['loader'] = { 20476 "load": load, 20477 "i" : 0 20478 }; 20479 return y; 20480 } 20481 20482 /* End loader helper functions */ 20483 // Yepnope Function 20484 yepnope = function ( needs ) { 20485 20486 var i, 20487 need, 20488 // start the chain as a plain instance 20489 chain = yepnope.loader; 20490 20491 function satisfyPrefixes ( url ) { 20492 // split all prefixes out 20493 var parts = url.split( "!" ), 20494 gLen = globalFilters.length, 20495 origUrl = parts.pop(), 20496 pLen = parts.length, 20497 res = { 20498 "url" : origUrl, 20499 // keep this one static for callback variable consistency 20500 "origUrl" : origUrl, 20501 "prefixes" : parts 20502 }, 20503 mFunc, 20504 j, 20505 prefix_parts; 20506 20507 // loop through prefixes 20508 // if there are none, this automatically gets skipped 20509 for ( j = 0; j < pLen; j++ ) { 20510 prefix_parts = parts[ j ].split( '=' ); 20511 mFunc = prefixes[ prefix_parts.shift() ]; 20512 if ( mFunc ) { 20513 res = mFunc( res, prefix_parts ); 20514 } 20515 } 20516 20517 // Go through our global filters 20518 for ( j = 0; j < gLen; j++ ) { 20519 res = globalFilters[ j ]( res ); 20520 } 20521 20522 // return the final url 20523 return res; 20524 } 20525 20526 function getExtension ( url ) { 20527 //The extension is always the last characters before the ? and after a period. 20528 //The previous method was not accounting for the possibility of a period in the query string. 20529 var b = url.split('?')[0]; 20530 return b.substr(b.lastIndexOf('.')+1); 20531 } 20532 20533 function loadScriptOrStyle ( input, callback, chain, index, testResult ) { 20534 // run through our set of prefixes 20535 var resource = satisfyPrefixes( input ), 20536 autoCallback = resource['autoCallback'], 20537 extension = getExtension( resource['url'] ); 20538 20539 // if no object is returned or the url is empty/0 just exit the load 20540 if ( resource['bypass'] ) { 20541 return; 20542 } 20543 20544 // Determine callback, if any 20545 if ( callback ) { 20546 callback = isFunction( callback ) ? 20547 callback : 20548 callback[ input ] || 20549 callback[ index ] || 20550 callback[ ( input.split( "/" ).pop().split( "?" )[ 0 ] ) ]; 20551 } 20552 20553 // if someone is overriding all normal functionality 20554 if ( resource['instead'] ) { 20555 return resource['instead']( input, callback, chain, index, testResult ); 20556 } 20557 else { 20558 // Handle if we've already had this url and it's completed loaded already 20559 if ( scriptCache[ resource['url'] ] && resource['reexecute'] !== true) { 20560 // don't let this execute again 20561 resource['noexec'] = true; 20562 } 20563 else { 20564 scriptCache[ resource['url'] ] = 1; 20565 } 20566 20567 // Throw this into the queue 20568 input && chain.load( resource['url'], ( ( resource['forceCSS'] || ( ! resource['forceJS'] && "css" == getExtension( resource['url'] ) ) ) ) ? "c" : undef, resource['noexec'], resource['attrs'], resource['timeout'] ); 20569 20570 // If we have a callback, we'll start the chain over 20571 if ( isFunction( callback ) || isFunction( autoCallback ) ) { 20572 // Call getJS with our current stack of things 20573 chain['load']( function () { 20574 // Hijack yepnope and restart index counter 20575 getYepnope(); 20576 // Call our callbacks with this set of data 20577 callback && callback( resource['origUrl'], testResult, index ); 20578 autoCallback && autoCallback( resource['origUrl'], testResult, index ); 20579 20580 // Override this to just a boolean positive 20581 scriptCache[ resource['url'] ] = 2; 20582 } ); 20583 } 20584 } 20585 } 20586 20587 function loadFromTestObject ( testObject, chain ) { 20588 var testResult = !! testObject['test'], 20589 group = testResult ? testObject['yep'] : testObject['nope'], 20590 always = testObject['load'] || testObject['both'], 20591 callback = testObject['callback'] || noop, 20592 cbRef = callback, 20593 complete = testObject['complete'] || noop, 20594 needGroupSize, 20595 callbackKey; 20596 20597 // Reusable function for dealing with the different input types 20598 // NOTE:: relies on closures to keep 'chain' up to date, a bit confusing, but 20599 // much smaller than the functional equivalent in this case. 20600 function handleGroup ( needGroup, moreToCome ) {
20601 if ( '' !== needGroup && ! needGroup ) { 20602 // Call the complete callback when there's nothing to load. 20603 ! moreToCome && complete(); 20604 } 20605 // If it's a string 20606 else if ( isString( needGroup ) ) { 20607 // if it's a string, it's the last 20608 if ( !moreToCome ) { 20609 // Add in the complete callback to go at the end 20610 callback = function () { 20611 var args = [].slice.call( arguments ); 20612 cbRef.apply( this, args ); 20613 complete(); 20614 }; 20615 } 20616 // Just load the script of style 20617 loadScriptOrStyle( needGroup, callback, chain, 0, testResult ); 20618 } 20619 // See if we have an object. Doesn't matter if it's an array or a key/val hash 20620 // Note:: order cannot be guaranteed on an key value object with multiple elements 20621 // since the for-in does not preserve order. Arrays _should_ go in order though. 20622 else if ( isObject( needGroup ) ) { 20623 // I hate this, but idk another way for objects. 20624 needGroupSize = (function(){ 20625 var count = 0, i 20626 for (i in needGroup ) { 20627 if ( needGroup.hasOwnProperty( i ) ) { 20628 count++; 20629 } 20630 } 20631 return count; 20632 })(); 20633 20634 for ( callbackKey in needGroup ) { 20635 // Safari 2 does not have hasOwnProperty, but not worth the bytes for a shim 20636 // patch if needed. Kangax has a nice shim for it. Or just remove the check 20637 // and promise not to extend the object prototype. 20638 if ( needGroup.hasOwnProperty( callbackKey ) ) { 20639 // Find the last added resource, and append to it's callback. 20640 if ( ! moreToCome && ! ( --needGroupSize ) ) { 20641 // If this is an object full of callbacks 20642 if ( ! isFunction( callback ) ) { 20643 // Add in the complete callback to go at the end 20644 callback[ callbackKey ] = (function( innerCb ) { 20645 return function () { 20646 var args = [].slice.call( arguments ); 20647 innerCb && innerCb.apply( this, args ); 20648 complete(); 20649 }; 20650 })( cbRef[ callbackKey ] ); 20651 } 20652 // If this is just a single callback 20653 else { 20654 callback = function () { 20655 var args = [].slice.call( arguments ); 20656 cbRef.apply( this, args ); 20657 complete(); 20658 }; 20659 } 20660 } 20661 loadScriptOrStyle( needGroup[ callbackKey ], callback, chain, callbackKey, testResult ); 20662 } 20663 } 20664 } 20665 } 20666 20667 // figure out what this group should do 20668 handleGroup( group, !!always || !!testObject['complete']); 20669 20670 // Run our loader on the load/both group too 20671 // the always stuff always loads second. 20672 always && handleGroup( always ); 20673 20674 // If complete callback is used without loading anything 20675 !always && !!testObject['complete'] && handleGroup(''); 20676 20677 } 20678 20679 // Someone just decides to load a single script or css file as a string 20680 if ( isString( needs ) ) { 20681 loadScriptOrStyle( needs, 0, chain, 0 ); 20682 } 20683 // Normal case is likely an array of different types of loading options 20684 else if ( isArray( needs ) ) { 20685 // go through the list of needs 20686 for( i = 0; i < needs.length; i++ ) { 20687 need = needs[ i ]; 20688 20689 // if it's a string, just load it 20690 if ( isString( need ) ) { 20691 loadScriptOrStyle( need, 0, chain, 0 ); 20692 } 20693 // if it's an array, call our function recursively 20694 else if ( isArray( need ) ) { 20695 yepnope( need ); 20696 } 20697 // if it's an object, use our modernizr logic to win 20698 else if ( isObject( need ) ) { 20699 loadFromTestObject( need, chain ); 20700 } 20701 } 20702 } 20703 // Allow a single object to be passed in 20704 else if ( isObject( needs ) ) { 20705 loadFromTestObject( needs, chain ); 20706 } 20707 }; 20708 20709 // This publicly exposed function is for allowing 20710 // you to add functionality based on prefixes on the 20711 // string files you add. 'css!' is a builtin prefix 20712 //
20713 // The arguments are the prefix (not including the !) as a string 20714 // and 20715 // A callback function. This function is passed a resource object 20716 // that can be manipulated and then returned. (like middleware. har.) 20717 // 20718 // Examples of this can be seen in the officially supported ie prefix 20719 yepnope['addPrefix'] = function ( prefix, callback ) { 20720 prefixes[ prefix ] = callback; 20721 }; 20722 20723 // A filter is a global function that every resource 20724 // object that passes through yepnope will see. You can 20725 // of course conditionally choose to modify the resource objects 20726 // or just pass them along. The filter function takes the resource 20727 // object and is expected to return one. 20728 // 20729 // The best example of a filter is the 'autoprotocol' officially 20730 // supported filter 20731 yepnope['addFilter'] = function ( filter ) { 20732 globalFilters.push( filter ); 20733 }; 20734 20735 // Default error timeout to 10sec - modify to alter 20736 yepnope['errorTimeout'] = 1e4; 20737 20738 // Webreflection readystate hack 20739 // safe for jQuery 1.4+ ( i.e. don't use yepnope with jQuery 1.3.2 ) 20740 // if the readyState is null and we have a listener 20741 if ( doc.readyState == null && doc.addEventListener ) { 20742 // set the ready state to loading 20743 doc.readyState = "loading"; 20744 // call the listener 20745 doc.addEventListener( "DOMContentLoaded", handler = function () { 20746 // Remove the listener 20747 doc.removeEventListener( "DOMContentLoaded", handler, 0 ); 20748 // Set it to ready 20749 doc.readyState = "complete"; 20750 }, 0 ); 20751 } 20752 20753 // Attach loader & 20754 // Leak it 20755 20756 module.exports = getYepnope(); 20757 20758 // Exposing executeStack to better facilitate plugins 20759 module.exports['executeStack'] = executeStack; 20760 module.exports['injectJs'] = injectJs; 20761 module.exports['injectCss'] = injectCss; 20762 20763})( this, document ); 20764},{}]},{},[43]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.