This commit is contained in:
janraasch 2020-09-09 16:01:27 +00:00
parent e9ef4a7cfa
commit de11482928
6 changed files with 1688 additions and 1158 deletions

File diff suppressed because one or more lines are too long

View file

@ -2,121 +2,133 @@
* Main JS file for GhostScroll behaviours
*/
var $post = $('.post');
var $first = $('.post.first');
var $last = $('.post.last');
var $fnav = $('.fixed-nav');
var $postholder = $('.post-holder');
var $postafter = $('.post-after');
var $sitehead = $('#site-head');
var $post = $(".post");
var $first = $(".post.first");
var $last = $(".post.last");
var $fnav = $(".fixed-nav");
var $postholder = $(".post-holder");
var $postafter = $(".post-after");
var $sitehead = $("#site-head");
/* Globals jQuery, document */
(function ($) {
"use strict";
function srcTo (el) {
$('html, body').animate({
scrollTop: el.offset().top
}, 1000);
}
function srcToAnchorWithTitle (str) {
var $el = $('#' + str);
if ($el.length) {
srcTo($el);
}
}
$(document).ready(function(){
"use strict";
function srcTo(el) {
$("html, body").animate(
{
scrollTop: el.offset().top,
},
1000
);
}
function srcToAnchorWithTitle(str) {
var $el = $("#" + str);
if ($el.length) {
srcTo($el);
}
}
$(document).ready(function () {
$postholder.each(function (e) {
if (e % 2 != 0) $(this).addClass("odd");
});
$postholder.each(function (e) {
if(e % 2 != 0)
$(this).addClass("odd");
});
$postafter.each(function (e) {
var bg = $(this).parent().css("background-color");
$(this).css("border-top-color", bg);
$postafter.each(function (e) {
var bg = $(this).parent().css('background-color')
$(this).css('border-top-color', bg);
if (e % 2 == 0) {
$(this).addClass("even");
}
});
if (e % 2 == 0) {
$(this).addClass("even");
}
});
$("a.btn.site-menu").click(function (e) {
srcToAnchorWithTitle($(e.target).data("title-anchor"));
});
$("#header-arrow").click(function () {
srcTo($first);
});
$('a.btn.site-menu').click(function (e) {
srcToAnchorWithTitle($(e.target).data('title-anchor'));
});
$('#header-arrow').click(function () {
srcTo($first);
});
$(".post-title").each(function () {
var t = $(this).text();
var index = $(this).parents(".post-holder").index();
$fnav.append(
"<a class='fn-item' item_index='" + index + "'>" + t + "</a>"
);
$(".fn-item").click(function () {
var i = $(this).attr("item_index");
var s = $(".post[item_index='" + i + "']");
$('.post-title').each(function () {
var t = $(this).text();
var index = $(this).parents('.post-holder').index();
$fnav.append("<a class='fn-item' item_index='"+index+"'>"+t+"</a>")
$('.fn-item').click(function () {
var i = $(this).attr('item_index');
var s = $(".post[item_index='"+i+"']");
$("html, body").animate(
{
scrollTop: s.offset().top,
},
400
);
});
});
$('html, body').animate({
scrollTop: s.offset().top
}, 400);
$(".post.last").next(".post-after").hide();
if ($sitehead.length) {
$(window).scroll(function () {
var w = $(window).scrollTop();
var g = $sitehead.offset().top;
var h = $sitehead.offset().top + $sitehead.height() - 100;
});
});
if (w >= g && w <= h) {
$(".fixed-nav").fadeOut("fast");
} else if ($(window).width() > 500) {
$(".fixed-nav").fadeIn("fast");
}
$('.post.last').next('.post-after').hide();
if($sitehead.length) {
$(window).scroll( function () {
var w = $(window).scrollTop();
var g = $sitehead.offset().top;
var h = $sitehead.offset().top + $sitehead.height()-100;
$post.each(function () {
var f = $(this).offset().top;
var b = $(this).offset().top + $(this).height();
var t = $(this).parent(".post-holder").index();
var i = $(".fn-item[item_index='" + t + "']");
var a = $(this)
.parent(".post-holder")
.prev(".post-holder")
.find(".post-after");
if(w >= g && w<=h) {
$('.fixed-nav').fadeOut('fast');
} else if($(window).width()>500) {
$('.fixed-nav').fadeIn('fast');
}
$(this).attr("item_index", t);
$post.each(function () {
var f = $(this).offset().top;
var b = $(this).offset().top + $(this).height();
var t = $(this).parent('.post-holder').index();
var i = $(".fn-item[item_index='"+t+"']");
var a = $(this).parent('.post-holder').prev('.post-holder').find('.post-after');
if (w >= f && w <= b) {
i.addClass("active");
a.fadeOut("slow");
} else {
i.removeClass("active");
a.fadeIn("slow");
}
});
});
}
$(this).attr('item_index', t);
$("ul li").before(
'<span class="bult fa fa-asterisk icon-asterisk"></span>'
);
$("blockquote p").prepend('<span class="quo icon-quote-left"></span>');
$("blockquote p").append('<span class="quo icon-quote-right"></span>');
});
if(w >= f && w<=b) {
i.addClass('active');
a.fadeOut('slow');
} else {
i.removeClass('active');
a.fadeIn('slow');
}
});
});
}
$post.each(function () {
var postText = $(this).html();
var fa = [];
for (var i = 0; i < icons.length; i++) {
fa[i] = {};
fa[i].str = "@" + icons[i] + "@";
fa[i].icon = icons[i];
fa[i].int = postText.search(fa[i].str);
$('ul li').before('<span class="bult fa fa-asterisk icon-asterisk"></span>');
$('blockquote p').prepend('<span class="quo icon-quote-left"></span>');
$('blockquote p').append('<span class="quo icon-quote-right"></span>');
});
$post.each(function () {
var postText = $(this).html();
var fa = [];
for(var i=0; i < icons.length; i++) {
fa[i] = {};
fa[i].str = "@"+ icons[i]+ "@";
fa[i].icon = icons[i];
fa[i].int = postText.search(fa[i].str);
if(fa[i].int > -1 ) {
fa[i].count = postText.match(new RegExp(fa[i].str,"g")).length;
for(var j=0; j < fa[i].count; j++) {
$(this).html($(this).html().replace(fa[i].str, "<i class='fa "+fa[i].icon+"'></i>"))
}
}
}
});
}(jQuery));
if (fa[i].int > -1) {
fa[i].count = postText.match(new RegExp(fa[i].str, "g")).length;
for (var j = 0; j < fa[i].count; j++) {
$(this).html(
$(this)
.html()
.replace(fa[i].str, "<i class='fa " + fa[i].icon + "'></i>")
);
}
}
}
});
})(jQuery);