Browse Source

added link to blogpost to blog headline, also some cleaning, we cant have more than 4 navigation points

master
Timm Szigat 6 years ago
parent
commit
cef7b0df10
4 changed files with 109 additions and 57 deletions
  1. +2
    -6
      _includes/header.html
  2. +13
    -4
      blog.html
  3. +10
    -2
      index.html
  4. +84
    -45
      js/elevator.js

+ 2
- 6
_includes/header.html View File

@ -23,10 +23,6 @@
<li><a href="#contact">Kontakt</a></li>
<li class="divider-vertical"></li>
<li><a href="https://wiki.chaospott.de">Wiki</a></li>
<li class="divider-vertical"></li>
<li><a href="https://wiki.chaospott.de/Anfahrt">Anfahrt</a></li>
<li class="divider-vertical"></li>
<li><a href="/status.html">Raumstatus</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<script>
@ -42,12 +38,12 @@
</script>
<li id="status_open">
<a href="/status.html" style="color:#5CB85C !important;">
<i class="fa fa-unlock"></i> Raum offen
<i class="fa fa-unlock"></i> Raumstatus
</a>
</li>
<li id="status_closed">
<a href="/status.html">
<i class="fa fa-lock"></i> Raum geschlossen
<i class="fa fa-lock"></i> Raumstatus
</a>
</li>
</ul>


+ 13
- 4
blog.html View File

@ -11,18 +11,27 @@ layout: default
<div class="col-md-12 post">
<header class="post-header">
<h1 class="post-title">{{ post.title }}</h1>
<p class="post-meta">{{ post.date | date: "%b %-d, %Y" }}{% if post.author %} • {{ post.author }}{% endif %}{% if post.meta %} • {{ post.meta }}{% endif %}</p>
<h2 class="post-title">
<a href="{{ post.url | prepend: site.baseurl }}">
{{ post.title }}
</a>
</h2>
<p class="post-meta">
{{ post.date | date: "%b %-d, %Y" }}{% if post.author %} • {{ post.author }}{% endif %}{% if post.meta %} • {{ post.meta }}{% endif %}
</p>
</header>
<article class="post-content">
{{post.content}}
{% assign wordcount = post.content | number_of_words %}
{% if wordcount > 200 %}
<p><a class="btn btn-default" href="{{ post.url | prepend: site.baseurl }}" role="button">&gt; Weiterlesen</a></p>
<p>
<a class="btn btn-default" href="{{ post.url | prepend: site.baseurl }}" role="button">
&gt; Weiterlesen
</a>
</p>
{% endif %}
</article>
</div>
</div>
</div>


+ 10
- 2
index.html View File

@ -6,13 +6,21 @@ layout: default
<div class="row">
{% for post in site.posts limit:4 %}
<div class="col-md-3">
<h2>{{ post.title }}</h2>
<h2>
<a href="{{ post.url | prepend: site.baseurl }}">
{{ post.title }}
</a>
</h2>
<p>
{{ post.content | truncatewords:20 }}
</p>
{% assign wordcount = post.content | number_of_words %}
{% if wordcount > 20 %}
<p><a class="btn btn-default" href="{{ post.url | prepend: site.baseurl }}" role="button">&gt; Weiterlesen</a></p>
<p>
<a class="btn btn-default" href="{{ post.url | prepend: site.baseurl }}" role="button">
&gt; Weiterlesen
</a>
</p>
{% endif %}
</div>
{% endfor %}


+ 84
- 45
js/elevator.js View File

@ -9,7 +9,7 @@
* Elevator.js
*********************************************/
var Elevator = (function() {
var Elevator = function(options) {
'use strict';
@ -22,33 +22,44 @@ var Elevator = (function() {
var customDuration = false;
var startTime = null;
var startPosition = null;
var endPosition = 0;
var elevating = false;
var mainAudio;
var endAudio;
var elevating = false;
var that = this;
/**
* Utils
*/
// Soft object augmentation
function extend( target, source ) {
for ( var key in source ) {
if ( !( key in target ) ) {
target[ key ] = source[ key ];
}
}
return target;
};
// Thanks Mr Penner - http://robertpenner.com/easing/
function easeInOutQuad( t, b, c, d ) {
t /= d/2;
if (t < 1) return c/2*t*t + b;
t /= d / 2;
if ( t < 1 ) return c / 2 * t * t + b;
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
return -c / 2 * ( t * ( t -2 ) - 1 ) + b;
}
function extendParameters(options, defaults){
for( var option in defaults ){
var t = options[option] === undefined && typeof option !== "function";
if(t){
options[option] = defaults[option];
}
}
return options;
}
function getVerticalOffset(element) {
var verticalOffset = 0;
while( element ){
verticalOffset += element.offsetTop || 0;
element = element.offsetParent;
}
return verticalOffset;
}
/**
* Main
@ -56,13 +67,13 @@ var Elevator = (function() {
// Time is passed through requestAnimationFrame, what a world!
function animateLoop( time ) {
if (!startTime) {
if ( !startTime ) {
startTime = time;
}
var timeSoFar = time - startTime;
var easedPosition = easeInOutQuad(timeSoFar, startPosition, -startPosition, duration);
var easedPosition = easeInOutQuad(timeSoFar, startPosition, endPosition - startPosition, duration);
window.scrollTo(0, easedPosition);
if( timeSoFar < duration ) {
@ -70,7 +81,7 @@ var Elevator = (function() {
} else {
animationFinished();
}
};
}
// ELEVATE!
// /
@ -85,7 +96,7 @@ var Elevator = (function() {
// C O O O D
// C__O__O__O__D
// [_____________]
function elevate() {
this.elevate = function() {
if( elevating ) {
return;
@ -93,7 +104,7 @@ var Elevator = (function() {
elevating = true;
startPosition = (document.documentElement.scrollTop || body.scrollTop);
// No custom duration set, so we travel at pixels per millisecond. (0.75px per ms)
if( !customDuration ) {
duration = (startPosition * 1.5);
@ -105,6 +116,10 @@ var Elevator = (function() {
if( mainAudio ) {
mainAudio.play();
}
};
function browserMeetsRequirements() {
return window.requestAnimationFrame && window.Audio && window.addEventListener;
}
function resetPositions() {
@ -114,7 +129,7 @@ var Elevator = (function() {
}
function animationFinished() {
resetPositions();
// Stop music!
@ -141,44 +156,68 @@ var Elevator = (function() {
mainAudio.currentTime = 0;
}
window.scrollTo(0, 0);
window.scrollTo(0, endPosition);
}
}
//@TODO: Does this need tap bindings too?
function bindElevateToElement( element ) {
element.addEventListener('click', elevate, false);
if( element.addEventListener ) {
element.addEventListener('click', that.elevate, false);
} else {
// Older browsers
element.attachEvent('onclick', function() {
document.documentElement.scrollTop = endPosition;
document.body.scrollTop = endPosition;
window.scroll(0, endPosition);
});
}
}
function main( options ) {
function init( _options ) {
// Bind to element click event, if need be.
body = document.body;
if( options.element ) {
bindElevateToElement( options.element );
var defaults = {
duration: undefined,
mainAudio: false,
endAudio: false,
preloadAudio: true,
loopAudio: true,
};
_options = extendParameters(_options, defaults);
if( _options.element ) {
bindElevateToElement( _options.element );
}
if( options.duration ) {
customDuration = true;
duration = options.duration;
// Take the stairs instead
if( !browserMeetsRequirements() ) {
return;
}
if( options.mainAudio ) {
mainAudio = new Audio( options.mainAudio );
mainAudio.setAttribute( 'preload', 'true' ); //@TODO: Option to not preload audio.
mainAudio.setAttribute( 'loop', 'true' );
if( _options.duration ) {
customDuration = true;
duration = _options.duration;
}
if( options.endAudio ) {
endAudio = new Audio( options.endAudio );
endAudio.setAttribute( 'preload', 'true' );
if( _options.targetElement ) {
endPosition = getVerticalOffset(_options.targetElement);
}
window.addEventListener('blur', onWindowBlur, false);
if( _options.mainAudio ) {
mainAudio = new Audio( _options.mainAudio );
mainAudio.setAttribute( 'preload', _options.preloadAudio );
mainAudio.setAttribute( 'loop', _options.loopAudio );
}
if( _options.endAudio ) {
endAudio = new Audio( _options.endAudio );
endAudio.setAttribute( 'preload', 'true' );
}
}
return extend(main, {
elevate: elevate
});
})();
init(options);
};

Loading…
Cancel
Save