[web-php] master: Drop Modernizr (#653)
| From: | Kamil Tekiela via GitHub | Date: | Wed, 13 Jul 2022 14:45:24 +0000 |
| Subject: | [web-php] master: Drop Modernizr (#653) | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-30387@lists.php.net to get a copy of this message | ||
Author: Kamil Tekiela (kamil-tekiela)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2022-07-13T15:38:53+01:00
Commit: https://github.com/php/web-php/commit/33a94e54bbccb71faccd58958e6f0119040d40c0
Raw diff: https://github.com/php/web-php/commit/33a94e54bbccb71faccd58958e6f0119040d40c0.diff
Drop Modernizr (#653)
We only used it to check for data: URI support, but that's universally supported now https://caniuse.com/datauri
Changed paths:
D js/ext/modernizr.js
M include/footer.inc
M js/common.js
Diff:
diff --git a/include/footer.inc b/include/footer.inc
index 6161365b13..691cd39c72 100644
--- a/include/footer.inc
+++ b/include/footer.inc
@@ -87,7 +87,7 @@
<!-- External and third party libraries. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
integrity="sha384-aBL3Lzi6c9LNDGvpHkZrrm3ZVsIwohDD7CDozL0pk8FwCrfmV7H9w8j3L7ikEv6h"
crossorigin="anonymous"></script>
<?php
- $jsfiles = array("ext/modernizr.js", "ext/hogan-2.0.0.min.js",
"ext/typeahead.min.js", "ext/mousetrap.min.js", "search.js",
"common.js");
+ $jsfiles = array("ext/hogan-2.0.0.min.js", "ext/typeahead.min.js",
"ext/mousetrap.min.js", "search.js", "common.js");
foreach ($jsfiles as $filename) {
$path = dirname(__DIR__).'/js/'.$filename;
echo '<script src="/cached.php?t=' . @filemtime($path) ..
'&f=/js/' . $filename . '"></script>'."\n";
diff --git a/js/common.js b/js/common.js
index 6dbcaa146e..ec6263e8e0 100644
--- a/js/common..js
+++ b/js/common.js
@@ -345,75 +345,62 @@ $(document).ready(function() {
$this.append("<a class='genanchor' href='#" +
$this.attr('id') + "'> ¶</a>");
});
- /* Don't load elephpants on browsers that don't support data: URIs.
- * Unfortunately, the Modernizr test is asynchronous, so we have to spin
- * until it actually gives us a yes or a no. */
- var initElephpants = function () {
- if (typeof Modernizr.datauri !== "undefined") {
- var $elephpants = $(".elephpants");
-
- if (Modernizr.datauri) {
- var $elephpantsImages = $elephpants.find('.images');
- // load the elephpant images if elephpants div is in the dom.
- $elephpantsImages.first().each(function (idx, node) {
-
- // function to fetch and insert images..
- var fetchImages = function() {
-
- // determine how many elephpants are required to fill the
- // viewport and subtract for any images we already have.
- var count = Math.ceil($(document).width() / 75)
- - $elephpantsImages.find("img").length;
-
- // early exit if we don't need any images.
- if (count < 1) {
- return;
- }
+ (function () {
+ var $elephpants = $(".elephpants");
- // do the fetch.
- $.ajax({
- url: '/images/elephpants.php?count=' + count,
- dataType: 'json',
- success: function(data) {
- var photo, image;
- for (photo in data) {
- photo = data[photo];
- link = $('<a>');
- link.attr('href', photo.url);
- link.attr('title', photo.title);
- image = $('<img>');
- image.attr('src',
'data:image/jpeg;base64,' + photo.data);
- $(node).append(link.append(image));
- }
- },
- error: function() {
- $elephpants.hide();
- }
- });
+ var $elephpantsImages = $elephpants.find('.images');
+ // load the elephpant images if elephpants div is in the dom.
+ $elephpantsImages.first()..each(function (idx, node) {
- }
+ // function to fetch and insert images.
+ var fetchImages = function() {
- // begin by fetching the images we need now.
- fetchImages();
+ // determine how many elephpants are required to fill the
+ // viewport and subtract for any images we already have.
+ var count = Math.ceil($(document).width() / 75)
+ - $elephpantsImages.find("img").length;
+
+ // early exit if we don't need any images.
+ if (count < 1) {
+ return;
+ }
- // fetch more if viewport gets larger.
- var deferred = null;
- $(window).resize(function() {
- window.clearTimeout(deferred);
- deferred = window.setTimeout(function(){
- fetchImages();
- }, 250);
- });
+ // do the fetch.
+ $.ajax({
+ url: '/images/elephpants.php?count=' + count,
+ dataType: 'json',
+ success: function(data) {
+ var photo, image;
+ for (photo in data) {
+ photo = data[photo];
+ link = $('<a>');
+ link.attr('href', photo.url);
+ link.attr('title', photo.title);
+ image = $('<img>');
+ image.attr('src', 'data:image/jpeg;base64,' +
photo.data);
+ $(node).append(link.append(image));
+ }
+ },
+ error: function() {
+ $elephpants.hide();
+ }
});
- } else {
- $elephpants.hide();
+
}
- } else {
- // Modernizr is still testing; check again in 100 ms.
- window.setTimeout(initElephpants, 100);
- }
- };
- initElephpants();
+
+ // begin by fetching the images we need now.
+ fetchImages();
+
+ // fetch more if viewport gets larger.
+ var deferred = null;
+ $(window).resize(function() {
+ window.clearTimeout(deferred);
+ deferred = window.setTimeout(function(){
+ fetchImages();
+ }, 250);
+ });
+ });
+ })();
// We have <p> tags generated with nothing in them and it requires a PHD change,
meanwhile this fixes it.
$refsect1.find('p').each(function() {
diff --git a/js/ext/modernizr.js b/js/ext/modernizr.js
deleted file mode 100644
index cdfd0cd33c..0000000000
--- a/js/ext/modernizr.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Modernizr 2.7.1 (Custom Build) | MIT & BSD
- * Build: http://modernizr.com/download/#-flexbox-flexboxlegacy-cssclasses-testprop-testallprops-domprefixes-url_data_uri
- */
-;window.Modernizr=function(a,b,c){function x(a){j.cssText=a}function y(a,b){return
x(prefixes..join(a+";")+(b||""))}function z(a,b){return typeof a===b}function
A(a,b){return!!~(""+a).indexOf(b)}function B(a,b){for(var d in a){var
e=a[d];if(!A(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function
C(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return
d===!1?a[e]:z(f,"function")?f.bind(d||b):f}return!1}function D(a,b,c){var
d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+n.join(d+" ")+d).split("
");return z(b,"string")||z(b,"undefined")?B(e,b):(e=(a+"
"+o.join(d+" ")+d).split(" "),C(e,b,c))}var
d="2.7.1",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m="Webkit
Moz O ms",n=m.split(" "),o=m.toLowerCase().split("
"),p={},q={},r={},s=[],t=s.slice,u,v={}.hasOwnProperty,w;!z(v,"undefined")&&!z(v.call,"undefined")?w=function(a,b){return
v.call(a,b)}:w=function(a,b){return b in
a&&z(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var
c=this;if(typeof c!="function")throw new TypeError;var
d=t.call(arguments,1),e=function(){if(this instanceof e){var
a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(t.call(arguments)));return
Object(g)===g?g:f}return c.apply(b,d.concat(t.call(arguments)))};return
e}),p.flexbox=function(){return D("flexWrap")},p.flexboxlegacy=function(){return
D("boxDirection")};for(var E in
p)w(p,E)&&(u=E.toLowerCase(),e[u]=p[E](),s.push((e[u]?"":"no-")+u));return
e.addTest=function(a,b){if(typeof a=="object")for(var d in
a)w(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof
b=="function"?b():b,typeof
f!="undefined"&&f&&(g.className+="
"+(b?"":"no-")+a),e[a]=b}return
e},x(""),i=k=null,e._version=d,e._domPrefixes=o,e._cssomPrefixes=n,e.testProp=function(a){return
B([a])},e.testAllProps=D,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?"
js "+s.join(" "):""),e}(this,this.document),function(){var a=new
Image;a.onerror=function(){Modernizr.addTest("datauri",function(){return!1})},a.onload=function(){Modernizr.addTest("datauri",function(){return
a.width==1&&a.height==1})},a.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="}();
\ No newline at end of file