vendor: 8,641 bytes, lines 1-308
1/*! Picturefill - v3.0.0-beta1 - 2015-07-24 2* http://scottjehl.github.io/picturefill 3* Copyright (c) 2015 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT */ 4(function(window) { 5 /*jshint eqnull:true */ 6 var ua = navigator.userAgent; 7 8 if ( window.HTMLPictureElement && ((/ecko/).test(ua) && ua.match(/rv\:(\d+)/) && RegExp.$1 < 41) ) { 9 addEventListener("resize", (function() { 10 var timer; 11 12 var dummySrc = document.createElement("source"); 13 14 var fixRespimg = function(img) { 15 var source, sizes; 16 var picture = img.parentNode; 17 18 if (picture.nodeName.toUpperCase() === "PICTURE") { 19 source = dummySrc.cloneNode(); 20 21 picture.insertBefore(source, picture.firstElementChild); 22 setTimeout(function() { 23 picture.removeChild(source); 24 }); 25 } else if (!img._pfLastSize || img.offsetWidth > img._pfLastSize) { 26 img._pfLastSize = img.offsetWidth; 27 sizes = img.sizes; 28 img.sizes += ",100vw"; 29 setTimeout(function() { 30 img.sizes = sizes; 31 }); 32 } 33 }; 34 35 var findPictureImgs = function() { 36 var i; 37 var imgs = document.querySelectorAll("picture > img, img[srcset][sizes]"); 38 for (i = 0; i < imgs.length; i++) { 39 fixRespimg(imgs[i]); 40 } 41 }; 42 var onResize = function() { 43 clearTimeout(timer); 44 timer = setTimeout(findPictureImgs, 99); 45 }; 46 var mq = window.matchMedia && matchMedia("(orientation: landscape)"); 47 var init = function() { 48 onResize(); 49 50 if (mq && mq.addListener) { 51 mq.addListener(onResize); 52 } 53 }; 54 55 dummySrc.srcset = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; 56 57 if (/^[c|i]|d$/.test(document.readyState || "")) { 58 init(); 59 } else { 60 document.addEventListener("DOMContentLoaded", init); 61 } 62 63 return onResize; 64 })()); 65 } 66})(window); 67 68/*! Picturefill - Responsive Images that work today. 69 * Author: Scott Jehl, Filament Group, 2012 ( new proposal implemented by Shawn Jansepar ) 70 * License: MIT 71 * Spec: http://picture.responsiveimages.org/ 72 */ 73(function( window, document, undefined ) { 74 /* global parseSizes */ 75 // Enable strict mode 76 "use strict"; 77 78 // HTML shim|v it for old IE (IE9 will still need the HTML video tag workaround) 79 document.createElement( "picture" ); 80 81 var warn, eminpx, alwaysCheckWDescriptor, evalId; 82 // local object for method references and testing exposure 83 var pf = {}; 84 var noop = function() {}; 85 var image = document.createElement( "img" ); 86 var getImgAttr = image.getAttribute; 87 var setImgAttr = image.setAttribute; 88 var removeImgAttr = image.removeAttribute; 89 var docElem = document.documentElement; 90 var types = {}; 91 var cfg = { 92 //resource selection: 93 algorithm: "" 94 }; 95 var srcAttr = "data-pfsrc"; 96 var srcsetAttr = srcAttr + "set"; 97 // ua sniffing is done for undetectable img loading features, 98 // to do some non crucial perf optimizations 99 var ua = navigator.userAgent; 100 var supportAbort = (/rident/).test(ua) || ((/ecko/).test(ua) && ua.match(/rv\:(\d+)/) && RegExp.$1 > 35 ); 101 var curSrcProp = "currentSrc"; 102 var regWDesc = /\s+\+?\d+(e\d+)?w/; 103 var regSize = /(\([^)]+\))?\s*(.+)/; 104 var setOptions = window.picturefillCFG; 105 /** 106 * Shortcut property for https://w3c.github.io/webappsec/specs/mixedcontent/#restricts-mixed-content ( for easy overriding in tests ) 107 */ 108 // baseStyle also used by getEmValue (i.e.: width: 1em is important) 109 var baseStyle = "position:absolute;left:0;visibility:hidden;display:block;padding:0;border:none;font-size:1em;width:1em;overflow:hidden;clip:rect(0px, 0px, 0px, 0px)"; 110 var fsCss = "font-size:100%!important;"; 111 var isVwDirty = true; 112 113 var cssCache = {}; 114 var sizeLengthCache = {}; 115 var DPR = window.devicePixelRatio; 116 var units = { 117 px: 1, 118 "in": 96 119 }; 120 var anchor = document.createElement( "a" ); 121 /** 122 * alreadyRun flag used for setOptions. is it true setOptions will reevaluate 123 * @type {boolean} 124 */ 125 var alreadyRun = false; 126 127 // Reusable, non-"g" Regexes 128 129 // (Don't use \s, to avoid matching non-breaking space.) 130 var regexLeadingSpaces = /^[ \t\n\r\u000c]+/, 131 regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/, 132 regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/, 133 regexTrailingCommas = /[,]+$/, 134 regexNonNegativeInteger = /^\d+$/, 135 136 // ( Positive or negative or unsigned integers or decimals, without or without exponents. 137 // Must include at least one digit. 138 // According to spec tests any decimal point must be followed by a digit. 139 // No leading plus sign is allowed.) 140 // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number 141 regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/; 142 143 var on = function(obj, evt, fn, capture) { 144 if ( obj.addEventListener ) { 145 obj.addEventListener(evt, fn, capture || false); 146 } else if ( obj.attachEvent ) { 147 obj.attachEvent( "on" + evt, fn); 148 } 149 }; 150 151 /** 152 * simple memoize function: 153 */ 154 155 var memoize = function(fn) { 156 var cache = {}; 157 return function(input) { 158 if ( !(input in cache) ) { 159 cache[ input ] = fn(input); 160 } 161 return cache[ input ]; 162 }; 163 }; 164 165 // UTILITY FUNCTIONS 166 167 // Manual is faster than RegEx 168 // http://jsperf.com/whitespace-character/5 169 function isSpace(c) { 170 return (c === "\u0020" || // space 171 c === "\u0009" || // horizontal tab 172 c === "\u000A" || // new line 173 c === "\u000C" || // form feed 174 c === "\u000D"); // carriage return 175 } 176 177 /** 178 * gets a mediaquery and returns a boolean or gets a css length and returns a number 179 * @param css mediaqueries or css length 180 * @returns {boolean|number} 181 * 182 * based on: https://gist.github.com/jonathantneal/db4f77009b155f083738 183 */ 184 var evalCSS = (function() { 185 186 var regLength = /^([\d\.]+)(em|vw|px)$/; 187 var replace = function() { 188 var args = arguments, index = 0, string = args[0]; 189 while (++index in args) { 190 string = string.replace(args[index], args[++index]); 191 } 192 return string; 193 }; 194 195 var buidlStr = memoize(function(css) { 196 197 return "return " + replace((css || "").toLowerCase(), 198 // interpret `and` 199 /\band\b/g, "&&", 200 201 // interpret `,` 202 /,/g, "||", 203 204 // interpret `min-` as >= 205 /min-([a-z-\s]+):/g, "e.$1>=", 206 207 // interpret `max-` as <= 208 /max-([a-z-\s]+):/g, "e.$1<=", 209 210 //calc value 211 /calc([^)]+)/g, "($1)", 212 213 // interpret css values 214 /(\d+[\.]*[\d]*)([a-z]+)/g, "($1 * e.$2)", 215 //make eval less evil 216 /^(?!(e.[a-z]|[0-9\.&=|><\+\-\*\(\)\/])).*/ig, "" 217 ) + ";"; 218 }); 219 220 return function(css, length) { 221 var parsedLength; 222 if (!(css in cssCache)) { 223 cssCache[css] = false; 224 if (length && (parsedLength = css.match( regLength ))) { 225 cssCache[css] = parsedLength[ 1 ] * units[parsedLength[ 2 ]]; 226 } else { 227 /*jshint evil:true */ 228 try{ 229 cssCache[css] = new Function("e", buidlStr(css))(units); 230 } catch(e) {} 231 /*jshint evil:false */ 232 } 233 } 234 return cssCache[css]; 235 }; 236 })(); 237 238 var setResolution = function( candidate, sizesattr ) { 239 if ( candidate.w ) { // h = means height: || descriptor.type === 'h' do not handle yet... 240 candidate.cWidth = pf.calcListLength( sizesattr || "100vw" ); 241 candidate.res = candidate.w / candidate.cWidth ; 242 } else { 243 candidate.res = candidate.d; 244 } 245 return candidate; 246 }; 247 248 /** 249 * 250 * @param opt 251 */ 252 var picturefill = function( opt ) { 253 var elements, i, plen; 254 255 var options = opt || {}; 256 257 if ( options.elements && options.elements.nodeType === 1 ) { 258 if ( options.elements.nodeName.toUpperCase() === "IMG" ) { 259 options.elements = [ options.elements ]; 260 } else { 261 options.context = options.elements; 262 options.elements = null; 263 } 264 } 265 266 elements = options.elements || pf.qsa( (options.context || document), ( options.reevaluate || options.reselect ) ? pf.sel : pf.selShort ); 267 268 if ( (plen = elements.length) ) { 269 270 pf.setupRun( options ); 271 alreadyRun = true; 272 273 // Loop through all elements 274 for ( i = 0; i < plen; i++ ) { 275 pf.fillImg(elements[ i ], options); 276 } 277 278 pf.teardownRun( options ); 279 } 280 }; 281 282 /** 283 * outputs a warning for the developer 284 * @param {message} 285 * @type {Function} 286 */ 287 warn = ( window.console && console.warn ) ? 288 function( message ) { 289 console.warn( message ); 290 } : 291 noop 292 ; 293 294 if ( !(curSrcProp in image) ) { 295 curSrcProp = "src"; 296 } 297 298 // Add support for standard mime types. 299 types[ "image/jpeg" ] = true; 300 types[ "image/gif" ] = true; 301 types[ "image/png" ] = true; 302 303 function detectTypeSupport( type, typeUri ) { 304 // based on Modernizr's lossless img-webp test 305 // note: asynchronous 306 var image = new window.Image(); 307 image.onerror = function() { 308 types[ type ] = false;
309 picturefill(); 310 }; 311 image.onload = function() { 312 types[ type ] = image.width === 1; 313 picturefill(); 314 }; 315 image.src = typeUri; 316 return "pending"; 317 } 318 319 // test svg support 320 types[ "image/svg+xml" ] = document.implementation.hasFeature( "http://wwwindo
vendor: 12,576 bytes, lines 320-743
320w.w3.org/TR/SVG11/feature#Image", "1.1" ); 321 322 /** 323 * updates the internal vW property with the current viewport width in px 324 */ 325 function updateMetrics() { 326 327 isVwDirty = false; 328 DPR = window.devicePixelRatio; 329 cssCache = {}; 330 sizeLengthCache = {}; 331 332 pf.DPR = DPR || 1; 333 334 units.width = Math.max(window.innerWidth || 0, docElem.clientWidth); 335 units.height = Math.max(window.innerHeight || 0, docElem.clientHeight); 336 337 units.vw = units.width / 100; 338 units.vh = units.height / 100; 339 340 evalId = [ units.height, units.width, DPR ].join("-"); 341 342 units.em = pf.getEmValue(); 343 units.rem = units.em; 344 } 345 346 function chooseLowRes( lowerValue, higherValue, dprValue, isCached ) { 347 var bonusFactor, tooMuch, bonus, meanDensity; 348 349 //experimental 350 if (cfg.algorithm === "saveData" ){ 351 if ( lowerValue > 2.7 ) { 352 meanDensity = dprValue + 1; 353 } else { 354 tooMuch = higherValue - dprValue; 355 bonusFactor = Math.pow(lowerValue - 0.6, 1.5); 356 357 bonus = tooMuch * bonusFactor; 358 359 if (isCached) { 360 bonus += 0.1 * bonusFactor; 361 } 362 363 meanDensity = lowerValue + bonus; 364 } 365 } else { 366 meanDensity = (dprValue > 1) ? 367 Math.sqrt(lowerValue * higherValue) : 368 lowerValue; 369 } 370 371 return meanDensity > dprValue; 372 } 373 374 function applyBestCandidate( img ) { 375 var srcSetCandidates; 376 var matchingSet = pf.getSet( img ); 377 var evaluated = false; 378 if ( matchingSet !== "pending" ) { 379 evaluated = evalId; 380 if ( matchingSet ) { 381 srcSetCandidates = pf.setRes( matchingSet ); 382 pf.applySetCandidate( srcSetCandidates, img ); 383 } 384 } 385 img[ pf.ns ].evaled = evaluated; 386 } 387 388 function ascendingSort( a, b ) { 389 return a.res - b.res; 390 } 391 392 function setSrcToCur( img, src, set ) { 393 var candidate; 394 if ( !set && src ) { 395 set = img[ pf.ns ].sets; 396 set = set && set[set.length - 1]; 397 } 398 399 candidate = getCandidateForSrc(src, set); 400 401 if ( candidate ) { 402 src = pf.makeUrl(src); 403 img[ pf.ns ].curSrc = src; 404 img[ pf.ns ].curCan = candidate; 405 406 if ( !candidate.res ) { 407 setResolution( candidate, candidate.set.sizes ); 408 } 409 } 410 return candidate; 411 } 412 413 function getCandidateForSrc( src, set ) { 414 var i, candidate, candidates; 415 if ( src && set ) { 416 candidates = pf.parseSet( set ); 417 src = pf.makeUrl(src); 418 for ( i = 0; i < candidates.length; i++ ) { 419 if ( src === pf.makeUrl(candidates[ i ].url) ) { 420 candidate = candidates[ i ]; 421 break; 422 } 423 } 424 } 425 return candidate; 426 } 427 428 function getAllSourceElements( picture, candidates ) { 429 var i, len, source, srcset; 430 431 // SPEC mismatch intended for size and perf: 432 // actually only source elements preceding the img should be used 433 // also note: don't use qsa here, because IE8 sometimes doesn't like source as the key part in a selector 434 var sources = picture.getElementsByTagName( "source" ); 435 436 for ( i = 0, len = sources.length; i < len; i++ ) { 437 source = sources[ i ]; 438 source[ pf.ns ] = true; 439 srcset = source.getAttribute( "srcset" ); 440 441 // if source does not have a srcset attribute, skip 442 if ( srcset ) { 443 candidates.push( { 444 srcset: srcset, 445 media: source.getAttribute( "media" ), 446 type: source.getAttribute( "type" ), 447 sizes: source.getAttribute( "sizes" ) 448 } ); 449 } 450 } 451 } 452 453 /** 454 * Srcset Parser 455 * By Alex Bell | MIT License 456 * 457 * @returns Array [{url: _, d: _, w: _, h:_, set:_(????)}, ...] 458 * 459 * Based super duper closely on the reference algorithm at: 460 * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute 461 */ 462 463 // 1. Let input be the value passed to this algorithm. 464 // (TO-DO : Explain what "set" argument is here. Maybe choose a more 465 // descriptive & more searchable name. Since passing the "set" in really has 466 // nothing to do with parsing proper, I would prefer this assignment eventually 467 // go in an external fn.) 468 function parseSrcset(input, set) { 469 470 function collectCharacters(regEx) { 471 var chars, 472 match = regEx.exec(input.substring(pos)); 473 if (match) { 474 chars = match[ 0 ]; 475 pos += chars.length; 476 return chars; 477 } 478 } 479 480 var inputLength = input.length, 481 url, 482 descriptors, 483 currentDescriptor, 484 state, 485 c, 486 487 // 2. Let position be a pointer into input, initially pointing at the start 488 // of the string. 489 pos = 0, 490 491 // 3. Let candidates be an initially empty source set. 492 candidates = []; 493 494 /** 495 * Adds descriptor properties to a candidate, pushes to the candidates array 496 * @return undefined 497 */ 498 // (Declared outside of the while loop so that it's only created once. 499 // (This fn is defined before it is used, in order to pass JSHINT. 500 // Unfortunately this breaks the sequencing of the spec comments. :/ ) 501 function parseDescriptors() { 502 503 // 9. Descriptor parser: Let error be no. 504 var pError = false, 505 506 // 10. Let width be absent. 507 // 11. Let density be absent. 508 // 12. Let future-compat-h be absent. (We're implementing it now as h) 509 w, d, h, i, 510 candidate = {}, 511 desc, lastChar, value, intVal, floatVal; 512 513 // 13. For each descriptor in descriptors, run the appropriate set of steps 514 // from the following list: 515 for (i = 0 ; i < descriptors.length; i++) { 516 desc = descriptors[ i ]; 517 518 lastChar = desc[ desc.length - 1 ]; 519 value = desc.substring(0, desc.length - 1); 520 intVal = parseInt(value, 10); 521 floatVal = parseFloat(value); 522 523 // If the descriptor consists of a valid non-negative integer followed by 524 // a U+0077 LATIN SMALL LETTER W character 525 if (regexNonNegativeInteger.test(value) && (lastChar === "w")) { 526 527 // If width and density are not both absent, then let error be yes. 528 if (w || d) {pError = true;} 529 530 // Apply the rules for parsing non-negative integers to the descriptor. 531 // If the result is zero, let error be yes. 532 // Otherwise, let width be the result. 533 if (intVal === 0) {pError = true;} else {w = intVal;} 534 535 // If the descriptor consists of a valid floating-point number followed by 536 // a U+0078 LATIN SMALL LETTER X character 537 } else if (regexFloatingPoint.test(value) && (lastChar === "x")) { 538 539 // If width, density and future-compat-h are not all absent, then let error 540 // be yes. 541 if (w || d || h) {pError = true;} 542 543 // Apply the rules for parsing floating-point number values to the descriptor. 544 // If the result is less than zero, let error be yes. Otherwise, let density 545 // be the result. 546 if (floatVal < 0) {pError = true;} else {d = floatVal;} 547 548 // If the descriptor consists of a valid non-negative integer followed by 549 // a U+0068 LATIN SMALL LETTER H character 550 } else if (regexNonNegativeInteger.test(value) && (lastChar === "h")) { 551 552 // If height and density are not both absent, then let error be yes. 553 if (h || d) {pError = true;} 554 555 // Apply the rules for parsing non-negative integers to the descriptor. 556 // If the result is zero, let error be yes. Otherwise, let future-compat-h 557 // be the result. 558 if (intVal === 0) {pError = true;} else {h = intVal;} 559 560 // Anything else, Let error be yes. 561 } else {pError = true;} 562 } // (close step 13 for loop) 563 564 // 15. If error is still no, then append a new image source to candidates whose 565 // URL is url, associated with a width width if not absent and a pixel 566 // density density if not absent. Otherwise, there is a parse error. 567 if (!pError) { 568 candidate.url = url; 569 570 if (w) { candidate.w = w;} 571 if (d) { candidate.d = d;} 572 if (h) { candidate.h = h;} 573 if (!h && !d && !w) {candidate.d = 1;} 574 if (candidate.d === 1) {set.has1x = true;} 575 candidate.set = set; 576 577 candidates.push(candidate); 578 } 579 } // (close parseDescriptors fn) 580 581 /** 582 * Tokenizes descriptor properties prior to parsing 583 * Returns undefined. 584 * (Again, this fn is defined before it is used, in order to pass JSHINT. 585 * Unfortunately this breaks the logical sequencing of the spec comments. :/ ) 586 */ 587 function tokenize() { 588 589 // 8.1. Descriptor tokeniser: Skip whitespace 590 collectCharacters(regexLeadingSpaces); 591 592 // 8.2. Let current descriptor be the empty string. 593 currentDescriptor = ""; 594 595 // 8.3. Let state be in descriptor. 596 state = "in descriptor"; 597 598 while (true) { 599 600 // 8.4. Let c be the character at position. 601 c = input.charAt(pos); 602 603 // Do the following depending on the value of state. 604 // For the purpose of this step, "EOF" is a special character representing 605 // that position is past the end of input. 606 607 // In descriptor 608 if (state === "in descriptor") { 609 // Do the following, depending on the value of c: 610 611 // Space character 612 // If current descriptor is not empty, append current descriptor to 613 // descriptors and let current descriptor be the empty string. 614 // Set state to after descriptor. 615 if (isSpace(c)) { 616 if (currentDescriptor) { 617 descriptors.push(currentDescriptor); 618 currentDescriptor = ""; 619 state = "after descriptor"; 620 } 621 622 // U+002C COMMA (,) 623 // Advance position to the next character in input. If current descriptor 624 // is not empty, append current descriptor to descriptors. Jump to the step 625 // labeled descriptor parser. 626 } else if (c === ",") { 627 pos += 1; 628 if (currentDescriptor) { 629 descriptors.push(currentDescriptor); 630 } 631 parseDescriptors(); 632 return; 633 634 // U+0028 LEFT PARENTHESIS (() 635 // Append c to current descriptor. Set state to in parens. 636 } else if (c === "\u0028") { 637 currentDescriptor = currentDescriptor + c; 638 state = "in parens"; 639 640 // EOF 641 // If current descriptor is not empty, append current descriptor to 642 // descriptors. Jump to the step labeled descriptor parser. 643 } else if (c === "") { 644 if (currentDescriptor) { 645 descriptors.push(currentDescriptor); 646 } 647 parseDescriptors(); 648 return; 649 650 // Anything else 651 // Append c to current descriptor. 652 } else { 653 currentDescriptor = currentDescriptor + c; 654 } 655 // (end "in descriptor" 656 657 // In parens 658 } else if (state === "in parens") { 659 660 // U+0029 RIGHT PARENTHESIS ()) 661 // Append c to current descriptor. Set state to in descriptor. 662 if (c === ")") { 663 currentDescriptor = currentDescriptor + c; 664 state = "in descriptor"; 665 666 // EOF 667 // Append current descriptor to descriptors. Jump to the step labeled 668 // descriptor parser. 669 } else if (c === "") { 670 descriptors.push(currentDescriptor); 671 parseDescriptors(); 672 return; 673 674 // Anything else 675 // Append c to current descriptor. 676 } else { 677 currentDescriptor = currentDescriptor + c; 678 } 679 680 // After descriptor 681 } else if (state === "after descriptor") { 682 683 // Do the following, depending on the value of c: 684 // Space character: Stay in this state. 685 if (isSpace(c)) { 686 687 // EOF: Jump to the step labeled descriptor parser. 688 } else if (c === "") { 689 parseDescriptors(); 690 return; 691 692 // Anything else 693 // Set state to in descriptor. Set position to the previous character in input. 694 } else { 695 state = "in descriptor"; 696 pos -= 1; 697 698 } 699 } 700 701 // Advance position to the next character in input. 702 pos += 1; 703 704 // Repeat this step. 705 } // (close while true loop) 706 } 707 708 // 4. Splitting loop: Collect a sequence of characters that are space 709 // characters or U+002C COMMA characters. If any U+002C COMMA characters 710 // were collected, that is a parse error. 711 while (true) { 712 collectCharacters(regexLeadingCommasOrSpaces); 713 714 // 5. If position is past the end of input, return candidates and abort these steps. 715 if (pos >= inputLength) { 716 return candidates; // (we're done, this is the sole return path) 717 } 718 719 // 6. Collect a sequence of characters that are not space characters, 720 // and let that be url. 721 url = collectCharacters(regexLeadingNotSpaces); 722 723 // 7. Let descriptors be a new empty list. 724 descriptors = []; 725 726 // 8. If url ends with a U+002C COMMA character (,), follow these substeps: 727 // (1). Remove all trailing U+002C COMMA characters from url. If this removed 728 // more than one character, that is a parse error. 729 if (url.slice(-1) === ",") { 730 url = url.replace(regexTrailingCommas, ""); 731 // (Jump ahead to step 9 to skip tokenization and just push the candidate). 732 parseDescriptors(); 733 734 // Otherwise, follow these substeps: 735 } else { 736 tokenize(); 737 } // (close else of step 8) 738 739 // 16. Return to the step labeled splitting loop. 740 } // (Close of big while loop.) 741 } 742 743 /*
743 jshint ignore:start */ 744 // jscs:disable 745 746 /* 747 * Sizes Parser 748 * 749 * By Alex Bell | MIT License 750 * 751 * Non-strict but accurate and lightweight JS Parser for the string value <img sizes="here"> 752 * 753 * Reference algorithm at: 754 * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-sizes-attribute 755 * 756 * Most comments are copied in directly from the spec 757 * (except for comments in parens). 758 * 759 * Grammar is: 760 * <source-size-list> = <source-size># [ , <source-size-value> ]? | <source-size-value> 761 * <source-size> = <media-condition> <source-size-value> 762 * <source-size-value> = <length> 763 * http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-sizes 764 * 765 * E.g. "(max-width: 30em) 100vw, (max-width: 50em) 70vw, 100vw"
766 * or "(min-width: 30em), calc(30vw - 15px)" or just "30vw" 767 * 768 * Returns the first valid <css-length> with a media condition that evaluates to true, 769 * or "100vw" if all valid media conditions evaluate to false. 770 * 771 */ 772 773 function parseSizes(strValue) { 774 775 // (Percentage CSS lengths are not allowed in this case, to avoid confusion: 776 // https://html.spec.whatwg.org/multipage/embedded-content.html#valid-source-size-list 777 // CSS allows a single optional plus or minus sign: 778 // http://www.w3.org/TR/CSS2/syndata.html#numbers 779 // CSS is ASCII case-insensitive: 780 // http://www.w3.org/TR/CSS2/syndata.html#characters ) 781 // Spec allows exponential notation for <number> type: 782 // http://dev.w3.org/csswg/css-values/#numbers 783 var regexCssLengthWithUnits = /^(?:[+-]?[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?:ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmin|vmax|vw)$/i; 784 785 // (This is a quick and lenient test. Because of optional unlimited-depth internal 786 // grouping parens and strict spacing rules, this could get very complicated.) 787 var regexCssCalc = /^calc\((?:[0-9a-z \.\+\-\*\/\(\)]+)\)$/i; 788 789 var i; 790 var unparsedSizesList; 791 var unparsedSizesListLength; 792 var unparsedSize; 793 var lastComponentValue; 794 var size; 795 796 // UTILITY FUNCTIONS 797 798 // (Toy CSS parser. The goals here are: 799 // 1) expansive test coverage without the weight of a full CSS parser. 800 // 2) Avoiding regex wherever convenient. 801 // Quick tests: http://jsfiddle.net/gtntL4gr/3/ 802 // Returns an array of arrays.) 803 function parseComponentValues(str) { 804 var chrctr; 805 var component = ""; 806 var componentArray = []; 807 var listArray = []; 808 var parenDepth = 0; 809 var pos = 0; 810 var inComment = false; 811 812 function pushComponent() { 813 if (component) { 814 componentArray.push(component); 815 component = ""; 816 } 817 } 818 819 function pushComponentArray() { 820 if (componentArray[0]) { 821 listArray.push(componentArray); 822 componentArray = []; 823 } 824 } 825 826 // (Loop forwards from the beginning of the string.) 827 while (true) { 828 chrctr = str[pos]; 829 830 if (chrctr === undefined) { // ( End of string reached.) 831 pushComponent(); 832 pushComponentArray(); 833 return listArray; 834 } else if (inComment) { 835 if ((chrctr === "*") && (str[pos + 1] === "/")) { // (At end of a comment.) 836 inComment = false; 837 pos += 2; 838 pushComponent(); 839 continue; 840 } else { 841 pos += 1; // (Skip all characters inside comments.) 842 continue; 843 } 844 } else if (isSpace(chrctr)) { 845 // (If previous character in loop was also a space, or if 846 // at the beginning of the string, do not add space char to 847 // component.) 848 if ((str[pos - 1] && isSpace(str[pos - 1])) || (!component)) { 849 pos += 1; 850 continue; 851 } else if (parenDepth === 0) { 852 pushComponent(); 853 pos +=1; 854 continue; 855 } else { 856 // (Replace any space character with a plain space for legibility.) 857 chrctr = " "; 858 } 859 } else if (chrctr === "(") { 860 parenDepth += 1; 861 } else if (chrctr === ")") { 862 parenDepth -= 1; 863 } else if (chrctr === ",") { 864 pushComponent() 865 pushComponentArray(); 866 pos += 1; 867 continue; 868 } else if ((chrctr === "/") && (str[pos + 1] === "*")) { 869 inComment = true; 870 pos += 2; 871 continue; 872 } 873 874 component = component + chrctr; 875 pos += 1; 876 } 877 } 878 879 function isValidNonNegativeSourceSizeValue(s) { 880 if (regexCssLengthWithUnits.test(s) && (parseFloat(s) >= 0)) {return true;} 881 if (regexCssCalc.test(s)) {return true;} 882 // ( http://www.w3.org/TR/CSS2/syndata.html#numbers says: 883 // "-0 is equivalent to 0 and is not a negative number." which means that 884 // unitless zero and unitless negative zero must be accepted as special cases.) 885 if ((s === "0") || (s === "-0") || (s === "+0")) {return true;} 886 return false; 887 } 888 889 // When asked to parse a sizes attribute from an element, parse a 890 // comma-separated list of component values from the value of the element's 891 // sizes attribute (or the empty string, if the attribute is absent), and let 892 // unparsed sizes list be the result. 893 // http://dev.w3.org/csswg/css-syntax/#parse-comma-separated-list-of-component-values 894 895 unparsedSizesList = parseComponentValues(strValue); 896 unparsedSizesListLength = unparsedSizesList.length; 897 898 // For each unparsed size in unparsed sizes list: 899 for (i = 0; i < unparsedSizesListLength; i++) { 900 unparsedSize = unparsedSizesList[i]; 901
902 // 1. Remove all consecutive <whitespace-token>s from the end of unparsed size. 903 // ( parseComponentValues() already omits spaces outside of parens. ) 904 905 // If unparsed size is now empty, that is a parse error; continue to the next 906 // iteration of this algorithm. 907 // ( parseComponentValues() won't push an empty array. ) 908 909 // 2. If the last component value in unparsed size is a valid non-negative 910 // <source-size-value>, let size be its value and remove the component value 911 // from unparsed size. Any CSS function other than the calc() function is 912 // invalid. Otherwise, there is a parse error; continue to the next iteration 913 // of this algorithm. 914 // http://dev.w3.org/csswg/css-syntax/#parse-component-value 915 lastComponentValue = unparsedSize[unparsedSize.length - 1]; 916 917 if (isValidNonNegativeSourceSizeValue(lastComponentValue)) { 918 size = lastComponentValue; 919 unparsedSize.pop(); 920 } else { 921 continue; 922 } 923 924 // 3. Remove all consecutive <whitespace-token>s from the end of unparsed 925 // size. If unparsed size is now empty, return size and exit this algorithm. 926 // If this was not the last item in unparsed sizes list, that is a parse error. 927 if (unparsedSize.length === 0) { 928 return size; 929 } 930 931 // 4. Parse the remaining component values in unparsed size as a 932 // <media-condition>. If it does not parse correctly, or it does parse 933 // correctly but the <media-condition> evaluates to false, continue to the 934 // next iteration of this algorithm. 935 // (Parsing all possible compound media conditions in JS is heavy, complicated, 936 // and the payoff is unclear. Is there ever an situation where the 937 // media condition parses incorrectly but still somehow evaluates to true? 938 // Can we just rely on the browser/polyfill to do it?) 939 unparsedSize = unparsedSize.join(" "); 940 if (!(pf.matchesMedia( unparsedSize ) ) ) { 941 continue; 942 } 943 944 // 5. Return size and exit this algorithm. 945 return size; 946 } 947 948 // If the above algorithm exhausts unparsed sizes list without returning a 949 // size value, return 100vw. 950 return "100vw"; 951 } 952 // jscs: enable 953 /* jshint ignore:end */ 954 955 // namespace 956 pf.ns = ("pf" + new Date().getTime()).substr(0, 9); 957 958 // srcset support test 959 pf.supSrcset = "srcset" in image; 960 pf.supSizes = "sizes" in image; 961 962 // using pf.qsa instead of dom traversing does scale much better, 963 // especially on sites mixing responsive and non-responsive images 964 pf.selShort = "picture>img,img[srcset]"; 965 pf.sel = pf.selShort; 966 pf.cfg = cfg; 967 968 if ( pf.supSrcset ) { 969 pf.sel += ",img[" + srcsetAttr + "]"; 970 } 971 972 /** 973 * Shortcut property for `devicePixelRatio` ( for easy overriding in tests ) 974 */ 975 pf.DPR = (DPR || 1 ); 976 pf.u = units; 977 978 // container of supported mime types that one might need to qualify before using 979 pf.types = types; 980 981 alwaysCheckWDescriptor = pf.supSrcset && !pf.supSizes; 982 983 pf.setSize = noop; 984 985 /** 986 * Gets a string and returns the absolute URL 987 * @param src 988 * @returns {String} absolute URL 989 */ 990 991 pf.makeUrl = memoize(function(src) { 992 anchor.href = src; 993 return anchor.href; 994 }); 995 996 /** 997 * Gets a DOM element or document and a selctor and returns the found matches 998 * Can be extended with jQuery/Sizzle for IE7 support 999 * @param context 1000 * @param sel 1001 * @returns {NodeList} 1002 */ 1003 pf.qsa = function(context, sel) { 1004 return context.querySelectorAll(sel); 1005 }; 1006 1007 /** 1008 * Shortcut method for matchMedia ( for easy overriding in tests ) 1009 * wether native or pf.mMQ is used will be decided lazy on first call 1010 * @returns {boolean} 1011 */ 1012 pf.matchesMedia = function() { 1013 if ( window.matchMedia && (matchMedia( "(min-width: 0.1em)" ) || {}).matches ) { 1014 pf.matchesMedia = function( media ) { 1015 return !media || ( matchMedia( media ).matches ); 1016 }; 1017 } else { 1018 pf.matchesMedia = pf.mMQ; 1019 } 1020 1021 return pf.matchesMedia.apply( this, arguments ); 1022 }; 1023 1024 /** 1025 * A simplified matchMedia implementation for IE8 and IE9 1026 * handles only min-width/max-width with px or em values 1027 * @param media 1028 * @returns {boolean} 1029 */ 1030 pf.mMQ = function( media ) { 1031 return media ? evalCSS(media) : true; 1032 }; 1033 1034 /** 1035 * Returns the calculated length in css pixel from the given sourceSizeValue 1036 * http://dev.w3.org/csswg/css-values-3/#length-value 1037 * intended Spec mismatches: 1038 * * Does not check for invalid use of CSS functions 1039 * * Does handle a computed length of 0 the same as a negative and therefore invalid value 1040 * @param sourceSizeValue 1041 * @returns {Number} 1042 */ 1043 pf.calcLength = function( sourceSizeValue ) { 1044 1045 var value = evalCSS(sourceSizeValue, true) || false; 1046 if (value < 0) { 1047 value = false;
vendor: 11,896 bytes, lines 1048-1498
1048 } 1049 1050 return value; 1051 }; 1052 1053 /** 1054 * Takes a type string and checks if its supported 1055 */ 1056 1057 pf.supportsType = function( type ) { 1058 return ( type ) ? types[ type ] : true; 1059 }; 1060 1061 /** 1062 * Parses a sourceSize into mediaCondition (media) and sourceSizeValue (length) 1063 * @param sourceSizeStr 1064 * @returns {*} 1065 */ 1066 pf.parseSize = memoize(function( sourceSizeStr ) { 1067 var match = ( sourceSizeStr || "" ).match(regSize); 1068 return { 1069 media: match && match[1], 1070 length: match && match[2] 1071 }; 1072 }); 1073 1074 pf.parseSet = function( set ) { 1075 if ( !set.cands ) { 1076 set.cands = parseSrcset(set.srcset, set); 1077 } 1078 return set.cands; 1079 }; 1080 1081 /** 1082 * returns 1em in css px for html/body default size 1083 * function taken from respondjs 1084 * @returns {*|number} 1085 */ 1086 pf.getEmValue = function() { 1087 var body; 1088 if ( !eminpx && (body = document.body) ) { 1089 var div = document.createElement( "div" ), 1090 originalHTMLCSS = docElem.style.cssText, 1091 originalBodyCSS = body.style.cssText; 1092 1093 div.style.cssText = baseStyle; 1094 1095 // 1em in a media query is the value of the default font size of the browser 1096 // reset docElem and body to ensure the correct value is returned 1097 docElem.style.cssText = fsCss; 1098 body.style.cssText = fsCss; 1099 1100 body.appendChild( div ); 1101 eminpx = div.offsetWidth; 1102 body.removeChild( div ); 1103 1104 //also update eminpx before returning 1105 eminpx = parseFloat( eminpx, 10 ); 1106 1107 // restore the original values 1108 docElem.style.cssText = originalHTMLCSS; 1109 body.style.cssText = originalBodyCSS; 1110 1111 } 1112 return eminpx || 16; 1113 }; 1114 1115 /** 1116 * Takes a string of sizes and returns the width in pixels as a number 1117 */ 1118 pf.calcListLength = function( sourceSizeListStr ) { 1119 // Split up source size list, ie ( max-width: 30em ) 100%, ( max-width: 50em ) 50%, 33% 1120 // 1121 // or (min-width:30em) calc(30% - 15px) 1122 if ( !(sourceSizeListStr in sizeLengthCache) || cfg.uT ) { 1123 var winningLength = pf.calcLength( parseSizes( sourceSizeListStr ) ); 1124 1125 sizeLengthCache[ sourceSizeListStr ] = !winningLength ? units.width : winningLength; 1126 } 1127 1128 return sizeLengthCache[ sourceSizeListStr ]; 1129 }; 1130 1131 /** 1132 * Takes a candidate object with a srcset property in the form of url/ 1133 * ex. "images/pic-medium.png 1x, images/pic-medium-2x.png 2x" or 1134 * "images/pic-medium.png 400w, images/pic-medium-2x.png 800w" or 1135 * "images/pic-small.png" 1136 * Get an array of image candidates in the form of 1137 * {url: "/foo/bar.png", resolution: 1} 1138 * where resolution is http://dev.w3.org/csswg/css-values-3/#resolution-value 1139 * If sizes is specified, res is calculated 1140 */ 1141 pf.setRes = function( set ) { 1142 var candidates; 1143 if ( set ) { 1144 1145 candidates = pf.parseSet( set ); 1146 1147 for ( var i = 0, len = candidates.length; i < len; i++ ) { 1148 setResolution( candidates[ i ], set.sizes ); 1149 } 1150 } 1151 return candidates; 1152 }; 1153 1154 pf.setRes.res = setResolution; 1155 1156 pf.applySetCandidate = function( candidates, img ) { 1157 if ( !candidates.length ) {return;} 1158 var candidate, 1159 i, 1160 j, 1161 length, 1162 bestCandidate, 1163 curSrc, 1164 curCan, 1165 isSameSet, 1166 candidateSrc, 1167 abortCurSrc; 1168 1169 var imageData = img[ pf.ns ]; 1170 var dpr = pf.DPR; 1171 1172 curSrc = imageData.curSrc || img[curSrcProp]; 1173 1174 curCan = imageData.curCan || setSrcToCur(img, curSrc, candidates[0].set); 1175 1176 // if we have a current source, we might either become lazy or give this source some advantage 1177 if ( curCan && curCan.set === candidates[ 0 ].set ) { 1178 1179 // if browser can abort image request and the image has a higher pixel density than needed 1180 // and this image isn't downloaded yet, we skip next part and try to save bandwidth 1181 abortCurSrc = (supportAbort && !img.complete && curCan.res - 0.1 > dpr); 1182 1183 if ( !abortCurSrc ) { 1184 curCan.cached = true; 1185 1186 // if current candidate is "best", "better" or "okay", 1187 // set it to bestCandidate 1188 if ( curCan && isSameSet && curCan.res >= dpr ) { 1189 bestCandidate = curCan; 1190 } 1191 } 1192 } 1193 1194 if ( !bestCandidate ) { 1195 1196 candidates.sort( ascendingSort ); 1197 1198 length = candidates.length; 1199 bestCandidate = candidates[ length - 1 ]; 1200 1201 for ( i = 0; i < length; i++ ) { 1202 candidate = candidates[ i ]; 1203 if ( candidate.res >= dpr ) { 1204 j = i - 1; 1205 1206 // we have found the perfect candidate, 1207 // but let's improve this a little bit with some assumptions ;-) 1208 if (candidates[ j ] && 1209 (abortCurSrc || curSrc !== pf.makeUrl( candidate.url )) && 1210 chooseLowRes(candidates[ j ].res, candidate.res, dpr, candidates[ j ].cached)) { 1211 1212 bestCandidate = candidates[ j ]; 1213 1214 } else { 1215 bestCandidate = candidate; 1216 } 1217 break; 1218 } 1219 } 1220 } 1221 1222 if ( bestCandidate ) { 1223 1224 candidateSrc = pf.makeUrl( bestCandidate.url ); 1225 1226 imageData.curSrc = candidateSrc; 1227 imageData.curCan = bestCandidate; 1228 1229 if ( candidateSrc !== curSrc ) { 1230 pf.setSrc( img, bestCandidate ); 1231 } 1232 pf.setSize( img ); 1233 } 1234 }; 1235 1236 pf.setSrc = function( img, bestCandidate ) { 1237 var origWidth; 1238 img.src = bestCandidate.url; 1239 1240 // although this is a specific Safari issue, we don't want to take too much different code paths 1241 if ( bestCandidate.set.type === "image/svg+xml" ) { 1242 origWidth = img.style.width; 1243 img.style.width = (img.offsetWidth + 1) + "px"; 1244 1245 // next line only should trigger a repaint 1246 // if... is only done to trick dead code removal 1247 if ( img.offsetWidth + 1 ) { 1248 img.style.width = origWidth; 1249 } 1250 } 1251 }; 1252 1253 pf.getSet = function( img ) { 1254 var i, set, supportsType; 1255 var match = false; 1256 var sets = img [ pf.ns ].sets; 1257 1258 for ( i = 0; i < sets.length && !match; i++ ) { 1259 set = sets[i]; 1260 1261 if ( !set.srcset || !pf.matchesMedia( set.media ) || !(supportsType = pf.supportsType( set.type )) ) { 1262 continue; 1263 } 1264 1265 if ( supportsType === "pending" ) { 1266 set = supportsType; 1267 } 1268 1269 match = set; 1270 break; 1271 } 1272 1273 return match; 1274 }; 1275 1276 pf.parseSets = function( element, parent, options ) { 1277 var srcsetAttribute, imageSet, isWDescripor, srcsetParsed; 1278 1279 var hasPicture = parent && parent.nodeName.toUpperCase() === "PICTURE"; 1280 var imageData = element[ pf.ns ]; 1281 1282 if ( imageData.src === undefined || options.src ) { 1283 imageData.src = getImgAttr.call( element, "src" ); 1284 if ( imageData.src ) { 1285 setImgAttr.call( element, srcAttr, imageData.src ); 1286 } else { 1287 removeImgAttr.call( element, srcAttr ); 1288 } 1289 } 1290 1291 if ( imageData.srcset === undefined || options.srcset || !pf.supSrcset || element.srcset ) { 1292 srcsetAttribute = getImgAttr.call( element, "srcset" ); 1293 imageData.srcset = srcsetAttribute; 1294 srcsetParsed = true; 1295 } 1296 1297 imageData.sets = []; 1298 1299 if ( hasPicture ) { 1300 imageData.pic = true; 1301 getAllSourceElements( parent, imageData.sets ); 1302 } 1303 1304 if ( imageData.srcset ) { 1305 imageSet = { 1306 srcset: imageData.srcset, 1307 sizes: getImgAttr.call( element, "sizes" ) 1308 }; 1309 1310 imageData.sets.push( imageSet ); 1311 1312 isWDescripor = (alwaysCheckWDescriptor || imageData.src) && regWDesc.test(imageData.srcset || ""); 1313 1314 // add normal src as candidate, if source has no w descriptor 1315 if ( !isWDescripor && imageData.src && !getCandidateForSrc(imageData.src, imageSet) && !imageSet.has1x ) { 1316 imageSet.srcset += ", " + imageData.src; 1317 imageSet.cands.push({ 1318 url: imageData.src, 1319 d: 1, 1320 set: imageSet 1321 }); 1322 } 1323 1324 } else if ( imageData.src ) { 1325 imageData.sets.push( { 1326 srcset: imageData.src, 1327 sizes: null 1328 } ); 1329 } 1330 1331 imageData.curCan = null; 1332 imageData.curSrc = undefined; 1333 1334 // if img has picture or the srcset was removed or has a srcset and does not support srcset at all 1335 // or has a w descriptor (and does not support sizes) set support to false to evaluate 1336 imageData.supported = !( hasPicture || ( imageSet && !pf.supSrcset ) || isWDescripor ); 1337 1338 if ( srcsetParsed && pf.supSrcset && !imageData.supported ) { 1339 if ( srcsetAttribute ) { 1340 setImgAttr.call( element, srcsetAttr, srcsetAttribute ); 1341 element.srcset = ""; 1342 } else { 1343 removeImgAttr.call( element, srcsetAttr ); 1344 } 1345 } 1346 1347 if (imageData.supported && !imageData.srcset && ((!imageData.src && element.src) || element.src !== pf.makeUrl(imageData.src))) { 1348 if (imageData.src === null) { 1349 element.removeAttribute("src"); 1350 } else { 1351 element.src = imageData.src; 1352 } 1353 } 1354 1355 imageData.parsed = true; 1356 }; 1357 1358 pf.fillImg = function(element, options) { 1359 var imageData; 1360 var extreme = options.reselect || options.reevaluate; 1361 1362 // expando for caching data on the img 1363 if ( !element[ pf.ns ] ) { 1364 element[ pf.ns ] = {}; 1365 } 1366 1367 imageData = element[ pf.ns ]; 1368 1369 // if the element has already been evaluated, skip it 1370 // unless `options.reevaluate` is set to true ( this, for example, 1371 // is set to true when running `picturefill` on `resize` ). 1372 if ( !extreme && imageData.evaled === evalId ) { 1373 return; 1374 } 1375 1376 if ( !imageData.parsed || options.reevaluate ) { 1377 pf.parseSets( element, element.parentNode, options ); 1378 } 1379 1380 if ( !imageData.supported ) { 1381 applyBestCandidate( element ); 1382 } else { 1383 imageData.evaled = evalId; 1384 } 1385 }; 1386 1387 pf.setupRun = function() { 1388 if ( !alreadyRun || isVwDirty || (DPR !== window.devicePixelRatio) ) { 1389 updateMetrics(); 1390 } 1391 }; 1392 1393 // If picture is supported, well, that's awesome. 1394 if ( window.HTMLPictureElement ) { 1395 picturefill = noop; 1396 pf.fillImg = noop; 1397 } else { 1398 1399 // Set up picture polyfill by polling the document 1400 (function() { 1401 var isDomReady; 1402 var regReady = window.attachEvent ? /d$|^c/ : /d$|^c|^i/; 1403 1404 var run = function() { 1405 var readyState = document.readyState || ""; 1406 1407 timerId = setTimeout(run, readyState === "loading" ? 200 : 999); 1408 if ( document.body ) { 1409 pf.fillImgs(); 1410 isDomReady = isDomReady || regReady.test(readyState); 1411 if ( isDomReady ) { 1412 clearTimeout( timerId ); 1413 } 1414 1415 } 1416 }; 1417 1418 var timerId = setTimeout(run, document.body ? 9 : 99); 1419 1420 // Also attach picturefill on resize and readystatechange 1421 // http://modernjavascript.blogspot.com/2013/08/building-better-debounce.html 1422 var debounce = function(func, wait) { 1423 var timeout, timestamp; 1424 var later = function() { 1425 var last = (new Date()) - timestamp; 1426 1427 if (last < wait) { 1428 timeout = setTimeout(later, wait - last); 1429 } else { 1430 timeout = null; 1431 func(); 1432 } 1433 }; 1434 1435 return function() { 1436 timestamp = new Date(); 1437 1438 if (!timeout) { 1439 timeout = setTimeout(later, wait); 1440 } 1441 }; 1442 }; 1443 var lastClientWidth = docElem.clientHeight; 1444 var onResize = function() { 1445 isVwDirty = Math.max(window.innerWidth || 0, docElem.clientWidth) !== units.width || docElem.clientHeight !== lastClientWidth; 1446 lastClientWidth = docElem.clientHeight; 1447 if ( isVwDirty ) { 1448 pf.fillImgs(); 1449 } 1450 }; 1451 1452 on( window, "resize", debounce(onResize, 99 ) ); 1453 on( document, "readystatechange", run ); 1454 1455 types[ "image/webp" ] = detectTypeSupport("image/webp", "data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA==" ); 1456 })(); 1457 } 1458 1459 pf.picturefill = picturefill; 1460 //use this internally for easy monkey patching/performance testing 1461 pf.fillImgs = picturefill; 1462 pf.teardownRun = noop; 1463 1464 /* expose methods for testing */ 1465 picturefill._ = pf; 1466 1467 window.picturefillCFG = { 1468 pf: pf, 1469 push: function(args) { 1470 var name = args.shift(); 1471 if (typeof pf[name] === "function") { 1472 pf[name].apply(pf, args); 1473 } else { 1474 cfg[name] = args[0]; 1475 if (alreadyRun) { 1476 pf.fillImgs( { reselect: true } ); 1477 } 1478 } 1479 } 1480 }; 1481 1482 while (setOptions && setOptions.length) { 1483 window.picturefillCFG.push(setOptions.shift()); 1484 } 1485 1486 /* expose picturefill */ 1487 window.picturefill = picturefill; 1488 1489 /* expose picturefill */ 1490 if ( typeof module === "object" && typeof module.exports === "object" ) { 1491 // CommonJS, just export 1492 module.exports = picturefill; 1493 } else if ( typeof define === "function" && define.amd ) { 1494 // AMD support 1495 define( "picturefill", function() { return picturefill; } ); 1496 } 1497 1498} )( window, document );
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.