Skip to content

Commit 6df75e0

Browse files
committed
Merge #554: Simplify javascript
e2acad0 Removing JS for magnific-popup configuration (Karel Bilek) d0a72b1 Modernizr-like no-js -> js <html> class replace (Karel Bilek) 4a545c8 Simplify javascript (Karel Bilek) Pull request description: * Deletes unused js modules: * magnific-popup (tool for better image galleries) is not used at all * modernizr is not used at all (it creates window.Modernizr js object which is never used anywhere else) * Deletes obsolete js modules: * respond and html5shiv are used only in IE9, which had last version in 2011. We can reasonably assume those will not be very frequent, and the website should work there as-is anyway. * Puts javascripts to a single file * instead of using pre-built minified file, jekyll puts the files together through `{% include %}` * Uses "local" javascript instead of hardlink to bitcoincore * This allows easier future experimentation I wanted to also delete fitvids, but it is used on one page - https://bitcoincore.org/en/2016/01/13/development-visualisation-2015/ . So it is probably better to keep using it. This PR also removes minification as a by-product of using jekyll for putting js together. I think the performance difference is negligible, since jquery is already minified. Related: #552 , #526 Tree-SHA512: 6fe9a2b65156cd800993e711fe552d6ecf1a6305e9862cdfbd9ddbe142b0c334b30e16558c669d2d0d636a30e60a5bd5e1c970da3588a2bb10f9bc0fb2ac71d1
2 parents 520d745 + e2acad0 commit 6df75e0

File tree

11 files changed

+21
-2105
lines changed

11 files changed

+21
-2105
lines changed

_includes/_head.html

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@
3232
<link rel="stylesheet" href="/assets/css/main.css">
3333
<meta http-equiv="cleartype" content="on">
3434

35-
<!-- HTML5 Shiv and Media Query Support -->
36-
<!--[if lt IE 9]>
37-
<script src="/assets/js/vendor/html5shiv.min.js"></script>
38-
<script src="/assets/js/vendor/respond.min.js"></script>
39-
<![endif]-->
40-
41-
<!-- Modernizr -->
42-
<!--[if lt IE 9 ]>
43-
<script src="/assets/js/vendor/modernizr-2.7.1.custom.min.js"></script>
44-
<![endif]-->
45-
4635
<!-- Icons -->
4736
<link rel="shortcut icon" href="/assets/images/favicon.ico"><!-- 16x16 -->
4837
<link rel="shortcut icon" href="/assets/images/favicon.png"><!-- 32x32 -->

_includes/_scripts.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
<!-- Modernizr -->
2-
<!--[if gt IE 8]><!-->
3-
<script src="/assets/js/vendor/modernizr-2.7.1.custom.min.js"></script>
4-
<!--<![endif]-->
51
</body>
62

7-
<script src="/assets/js/vendor/jquery-1.9.1.min.js"></script>'
8-
<script src="{{ site.url }}/assets/js/scripts.min.js"></script>
3+
<script src="/assets/js/scripts.js"></script>
94
{% if site.owner.google.analytics %}
105
<script>
116
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
File renamed without changes.

assets/js/_main.js renamed to _includes/js/main.js

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
/*! Responsive Menu */
22
// http://tympanus.net/codrops/2013/05/08/responsive-retina-ready-menu/
33
// The function to change the class
4+
5+
// change root element class from no-js to js
6+
// copied from https://github.com/Modernizr/Modernizr/blob/5eea7e2a213edc9e83a47b6414d0250468d83471/src/setClasses.js
7+
function addJs() {
8+
var docElement = document.documentElement;
9+
var className = docElement.className;
10+
11+
var reJS = new RegExp('(^|\\s)no-js(\\s|$)');
12+
className = className.replace(reJS, '$1js$2');
13+
docElement.className = className;
14+
}
15+
16+
addJs();
17+
418
var changeClass = function (r,className1,className2) {
519
var regex = new RegExp("(?:^|\\s+)" + className1 + "(?:\\s+|$)");
620
if( regex.test(r.className) ) {
@@ -42,26 +56,3 @@ $(function() {
4256
$("#drawer").toggleClass("js-hidden");
4357
});
4458
});
45-
46-
// Add lightbox class to all image links
47-
$("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.JPG'],a[href$='.png'],a[href$='.gif']").addClass("image-popup");
48-
49-
// Magnific-Popup options
50-
$(document).ready(function() {
51-
$('.image-popup').magnificPopup({
52-
type: 'image',
53-
tLoading: 'Loading image #%curr%...',
54-
gallery: {
55-
enabled: true,
56-
navigateByImgClick: true,
57-
preload: [0,1] // Will preload 0 - before current, and 1 after the current image
58-
},
59-
image: {
60-
tError: '<a href="%url%">Image #%curr%</a> could not be loaded.',
61-
},
62-
removalDelay: 300, // Delay in milliseconds before popup is removed
63-
// Class that is added to body when popup is open.
64-
// make it unique to apply your CSS animations just to this exact popup
65-
mainClass: 'mfp-fade'
66-
});
67-
});

0 commit comments

Comments
 (0)