website/themes/scroll/static/js/index.min.js

2 lines
1.9 KiB
JavaScript

var $post=$(".post"),$first=$(".post.first"),$last=$(".post.last"),$fnav=$(".fixed-nav"),$postholder=$(".post-holder"),$postafter=$(".post-after"),$sitehead=$("#site-head");(function(e){"use strict";function t(t){e("html, body").animate({scrollTop:t.offset().top},1e3)}e(document).ready(function(){$postholder.each(function(t){if(t%2!=0)e(this).addClass("oneOff")});$postafter.each(function(t){var n=e(this).parent().css("background-color");e(this).css("border-top-color",n);if(t%2==0)e(this).css("left","6%")});e(".btn.first").click(function(){t($first)});e(".btn.last").click(function(){t($last)});e("#header-arrow").click(function(){t($first)});e(".post-title").each(function(){var t=e(this).text(),n=e(this).parents(".post-holder").index();$fnav.append("<a class='fn-item' item_index='"+n+"'>"+t+"</a>");e(this).parents("article").attr("id",t.toLowerCase().split(" ").join("-"));e(".fn-item").click(function(){var t=e(this).attr("item_index"),n=e(".post[item_index='"+t+"']");e("html, body").animate({scrollTop:n.offset().top},400)})});e(".post.last").next(".post-after").hide();if($sitehead.length){e(window).scroll(function(){var t=e(window).scrollTop(),n=$sitehead.offset().top,r=$sitehead.offset().top+e(this).height()-100;if(t>=n&&t<=r){e(".fixed-nav").fadeOut("fast")}else{if(e(window).width()>500)e(".fixed-nav").fadeIn("fast")}$post.each(function(){var n=e(this).offset().top,r=e(this).offset().top+e(this).height(),i=e(this).parent(".post-holder").index(),s=e(".fn-item[item_index='"+i+"']"),o=e(this).parent(".post-holder").prev(".post-holder").find(".post-after");e(this).attr("item_index",i);if(t>=n&&t<=r){s.addClass("active");o.fadeOut("slow")}else{s.removeClass("active");o.fadeIn("slow")}})})}e("ul li").before('<span class="bult fa fa-asterisk icon-asterisk"></span>');e("blockquote p").prepend('<span class="quo icon-quote-left"></span>').append('<span class="quo icon-quote-right"></span>')})})(jQuery)