|
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 */ |
| 1 | +/*! Picturefill - v3.0.0-rc1 - 2015-08-21 |
| 2 | + * http://scottjehl.github.io/picturefill |
| 3 | + * Copyright (c) 2015 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT |
| 4 | + */ |
| 5 | +/*! Gecko-Picture - v1.0 |
| 6 | + * https://github.com/scottjehl/picturefill/tree/3.0/src/plugins/gecko-picture |
| 7 | + * Firefox's early picture implementation (prior to FF41) is static and does |
| 8 | + * not react to viewport changes. This tiny module fixes this. |
| 9 | + */ |
4 | 10 | (function(window) {
|
5 | 11 | /*jshint eqnull:true */
|
6 | 12 | var ua = navigator.userAgent;
|
|
65 | 71 | }
|
66 | 72 | })(window);
|
67 | 73 |
|
68 |
| -/*! Picturefill - Responsive Images that work today. |
69 |
| - * Author: Scott Jehl, Filament Group, 2012 ( new proposal implemented by Shawn Jansepar ) |
| 74 | +/*! Picturefill - v3.0.0-beta |
| 75 | + * http://scottjehl.github.io/picturefill |
| 76 | + * Copyright (c) 2015 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; |
70 | 77 | * License: MIT
|
71 |
| - * Spec: http://picture.responsiveimages.org/ |
72 | 78 | */
|
| 79 | + |
73 | 80 | (function( window, document, undefined ) {
|
74 |
| - /* global parseSizes */ |
75 | 81 | // Enable strict mode
|
76 | 82 | "use strict";
|
77 | 83 |
|
|
192 | 198 | return string;
|
193 | 199 | };
|
194 | 200 |
|
195 |
| - var buidlStr = memoize(function(css) { |
| 201 | + var buildStr = memoize(function(css) { |
196 | 202 |
|
197 | 203 | return "return " + replace((css || "").toLowerCase(),
|
198 | 204 | // interpret `and`
|
|
226 | 232 | } else {
|
227 | 233 | /*jshint evil:true */
|
228 | 234 | try{
|
229 |
| - cssCache[css] = new Function("e", buidlStr(css))(units); |
| 235 | + cssCache[css] = new Function("e", buildStr(css))(units); |
230 | 236 | } catch(e) {}
|
231 | 237 | /*jshint evil:false */
|
232 | 238 | }
|
|
740 | 746 | } // (Close of big while loop.)
|
741 | 747 | }
|
742 | 748 |
|
743 |
| - /* jshint ignore:start */ |
744 |
| - // jscs:disable |
745 |
| - |
746 | 749 | /*
|
747 | 750 | * Sizes Parser
|
748 | 751 | *
|
|
825 | 828 |
|
826 | 829 | // (Loop forwards from the beginning of the string.)
|
827 | 830 | while (true) {
|
828 |
| - chrctr = str[pos]; |
| 831 | + chrctr = str.charAt(pos); |
829 | 832 |
|
830 |
| - if (chrctr === undefined) { // ( End of string reached.) |
| 833 | + if (chrctr === "") { // ( End of string reached.) |
831 | 834 | pushComponent();
|
832 | 835 | pushComponentArray();
|
833 | 836 | return listArray;
|
|
845 | 848 | // (If previous character in loop was also a space, or if
|
846 | 849 | // at the beginning of the string, do not add space char to
|
847 | 850 | // component.)
|
848 |
| - if ((str[pos - 1] && isSpace(str[pos - 1])) || (!component)) { |
| 851 | + if ( (str.charAt(pos - 1) && isSpace( str.charAt(pos - 1) ) ) || !component ) { |
849 | 852 | pos += 1;
|
850 | 853 | continue;
|
851 | 854 | } else if (parenDepth === 0) {
|
|
861 | 864 | } else if (chrctr === ")") {
|
862 | 865 | parenDepth -= 1;
|
863 | 866 | } else if (chrctr === ",") {
|
864 |
| - pushComponent() |
| 867 | + pushComponent(); |
865 | 868 | pushComponentArray();
|
866 | 869 | pos += 1;
|
867 | 870 | continue;
|
868 |
| - } else if ((chrctr === "/") && (str[pos + 1] === "*")) { |
| 871 | + } else if ( (chrctr === "/") && (str.charAt(pos + 1) === "*") ) { |
869 | 872 | inComment = true;
|
870 | 873 | pos += 2;
|
871 | 874 | continue;
|
|
949 | 952 | // size value, return 100vw.
|
950 | 953 | return "100vw";
|
951 | 954 | }
|
952 |
| - // jscs: enable |
953 |
| - /* jshint ignore:end */ |
954 | 955 |
|
955 | 956 | // namespace
|
956 | 957 | pf.ns = ("pf" + new Date().getTime()).substr(0, 9);
|
957 | 958 |
|
958 | 959 | // srcset support test
|
959 | 960 | pf.supSrcset = "srcset" in image;
|
960 | 961 | pf.supSizes = "sizes" in image;
|
| 962 | + pf.supPicture = !!window.HTMLPictureElement; |
| 963 | + |
| 964 | + if (pf.supSrcset && pf.supPicture && !pf.supSizes) { |
| 965 | + (function(image2) { |
| 966 | + image.srcset = "data:,a"; |
| 967 | + image2.src = "data:,a"; |
| 968 | + pf.supSrcset = image.complete === image2.complete; |
| 969 | + pf.supPicture = pf.supSrcset && pf.supPicture; |
| 970 | + })(document.createElement("img")); |
| 971 | + } |
961 | 972 |
|
962 | 973 | // using pf.qsa instead of dom traversing does scale much better,
|
963 | 974 | // especially on sites mixing responsive and non-responsive images
|
|
1391 | 1402 | };
|
1392 | 1403 |
|
1393 | 1404 | // If picture is supported, well, that's awesome.
|
1394 |
| - if ( window.HTMLPictureElement ) { |
| 1405 | + if ( pf.supPicture ) { |
1395 | 1406 | picturefill = noop;
|
1396 | 1407 | pf.fillImg = noop;
|
1397 | 1408 | } else {
|
|
1451 | 1462 |
|
1452 | 1463 | on( window, "resize", debounce(onResize, 99 ) );
|
1453 | 1464 | on( document, "readystatechange", run );
|
1454 |
| - |
1455 |
| - types[ "image/webp" ] = detectTypeSupport("image/webp", "data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA==" ); |
1456 | 1465 | })();
|
1457 | 1466 | }
|
1458 | 1467 |
|
|
1495 | 1504 | define( "picturefill", function() { return picturefill; } );
|
1496 | 1505 | }
|
1497 | 1506 |
|
| 1507 | + // IE8 evals this sync, so it must be the last thing we do |
| 1508 | + if ( !pf.supPicture ) { |
| 1509 | + types[ "image/webp" ] = detectTypeSupport("image/webp", "data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA==" ); |
| 1510 | + } |
| 1511 | + |
1498 | 1512 | } )( window, document );
|
0 commit comments