Skip to content

Commit

Permalink
Merge pull request dirkfabisch#14 from MarkBorcherding/javascript_opt…
Browse files Browse the repository at this point in the history
…imizations

Javascript optimizations
  • Loading branch information
dirkfabisch committed Nov 20, 2014
2 parents 064aa16 + 85b2edb commit 227283e
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 105 deletions.
5 changes: 0 additions & 5 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@

<link rel="stylesheet" type="text/css" media="screen" href="{{ "/css/main.css" | prepend: site.baseurl }}" />
<link rel="stylesheet" type="text/css" media="print" href="{{ "/css/print.css" | prepend: site.baseurl }}" />
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>

<script type="text/javascript" src="{{ "/assets/js/jquery.fitvids.js" | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ "/assets/js/index.js" | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ "/assets/js/readingTime.min.js" | prepend: site.baseurl }}"></script>
</head>
39 changes: 39 additions & 0 deletions _includes/javascripts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="{{ "/assets/js/jquery.fitvids.js" | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ "/assets/js/index.js" | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ "/assets/js/readingTime.min.js" | prepend: site.baseurl }}"></script>
<script>
(function ($) {
"use strict";
$(document).ready(function(){

var $window = $(window),
$image = $('.post-image-image, .teaserimage-image');
$window.on('scroll', function() {
var top = $window.scrollTop();

if (top < 0 || top > 1500) { return; }
$image
.css('transform', 'translate3d(0px, '+top/3+'px, 0px)')
.css('opacity', 1-Math.max(top/700, 0));
});
$window.trigger('scroll');

var height = $('.article-image').height();
$('.post-content').css('padding-top', height + 'px');

$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({ scrollTop: target.offset().top }, 500);
return false;
}
}
});
});
}(jQuery));
</script>

1 change: 1 addition & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<!-- content end -->

{% include footer.html %}
{% include javascripts.html %}

</body>

Expand Down
41 changes: 1 addition & 40 deletions _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,6 @@ <h4 class="author-name" itemprop="author" itemscope itemtype="http://schema.org/
</div>
</div>
</div>
<script>
(function ($) {
"use strict";

$(document).ready(function(){

var $window = $(window),
$image = $('.post-image-image');
$window.on('scroll', function() {
var top = $window.scrollTop();

if (top < 0 || top > 1500) { return; }
$image
.css('transform', 'translate3d(0px, '+top/3+'px, 0px)')
.css('opacity', 1-Math.max(top/700, 0));
});
$window.trigger('scroll');

var height = $('.article-image').height();
$('.post-content').css('padding-top', height + 'px');

$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 500);
return false;
}
}
});
});

});

}(jQuery));
</script>
{% else %}
<div class="noarticleimage">
<div class="post-meta">
Expand Down Expand Up @@ -94,5 +54,6 @@ <h2 class="blog-description">{{ site.description }}</h2>
<a href="/" class="btn">Back to Overview</a>
</div>
</div>
{% include javascripts.html %}
</body>
</html>
39 changes: 1 addition & 38 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,6 @@ <h4 class="author-name" itemprop="author" itemscope itemtype="http://schema.org/
</div>
</div>
</div>
<script>
(function ($) {
"use strict";
$(document).ready(function(){
var $window = $(window),
$image = $('.post-image-image');
$window.on('scroll', function() {
var top = $window.scrollTop();

if (top < 0 || top > 1500) { return; }
$image
.css('transform', 'translate3d(0px, '+top/3+'px, 0px)')
.css('opacity', 1-Math.max(top/700, 0));
});
$window.trigger('scroll');

var height = $('.article-image').height();
$('.post-content').css('padding-top', height + 'px');

$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 500);
return false;
}
}
});
});

});

}(jQuery));
</script>
{% else %}
<div class="noarticleimage">
<div class="post-meta">
Expand Down Expand Up @@ -135,5 +97,6 @@ <h2 class="blog-description">{{ site.description }}</h2>
<a href="/" class="btn">Back to Overview</a>
</div>
</div>
{% include javascripts.html %}
</body>
</html>
Empty file modified assets/js/index.js
100755 → 100644
Empty file.
Empty file modified assets/js/jquery.fitvids.js
100755 → 100644
Empty file.
Empty file modified assets/js/min/highlight.pack-ck.js
100755 → 100644
Empty file.
Empty file modified assets/js/min/index-ck.js
100755 → 100644
Empty file.
Empty file modified assets/js/min/jquery.fitvids-ck.js
100755 → 100644
Empty file.
Empty file modified assets/js/min/jquery.ghostHunter.min-ck.js
100755 → 100644
Empty file.
Empty file modified assets/js/min/readingTime.min-ck.js
100755 → 100644
Empty file.
Empty file modified assets/js/readingTime.min.js
100755 → 100644
Empty file.
Empty file modified css/main.sass
100755 → 100644
Empty file.
Empty file modified css/normalize.css
100755 → 100644
Empty file.
Empty file modified css/print.css
100755 → 100644
Empty file.
22 changes: 0 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,6 @@ <h2 class="blog-description">{{ site.description }}</h2>
</div>
</header>

<script>
(function ($) {
"use strict";

$(document).ready(function(){

var $window = $(window),
$image = $('.teaserimage-image');
$window.on('scroll', function() {
var top = $window.scrollTop();

if (top < 0 || top > 1500) { return; }
$image
.css('transform', 'translate3d(0px, '+top/3+'px, 0px)')
.css('opacity', 1-Math.max(top/700, 0));
});
$window.trigger('scroll');

});

}(jQuery));
</script>

<main class="content" role="main">

Expand Down

0 comments on commit 227283e

Please sign in to comment.