Organize scripts under subdirectories
This commit is contained in:
11
assets/js/scripts/arrow-fade.js
Executable file
11
assets/js/scripts/arrow-fade.js
Executable file
@@ -0,0 +1,11 @@
|
||||
$(document).ready(function(){
|
||||
$(window).scroll(function(){
|
||||
if($(this).scrollTop() >
|
||||
//$(window).height()*0.3){
|
||||
100) {
|
||||
$(".mind-global-header_arrow-down").css({"opacity" : "0"});
|
||||
} else {
|
||||
$(".mind-global-header_arrow-down").css({"opacity" : "0.4"});
|
||||
}
|
||||
});
|
||||
});
|
||||
39
assets/js/scripts/get-headers-list.js
Normal file
39
assets/js/scripts/get-headers-list.js
Normal file
@@ -0,0 +1,39 @@
|
||||
let headers;
|
||||
let sidebarLinks;
|
||||
|
||||
$(document).ready(function () {
|
||||
headers = $(".mind-post_content h2, .mind-post_content h3").toArray();
|
||||
const sidebar = $("#mind-post_sidebar-left");
|
||||
|
||||
for (let i = 0; i < headers.length; i++) {
|
||||
const currentHeader = headers[i];
|
||||
const headerText = $(currentHeader).text();
|
||||
const headerId = $(currentHeader).attr("id");
|
||||
const headerType = $(currentHeader).prop("nodeName").toLowerCase();
|
||||
|
||||
// <h2> <a href="header-linke"> Header Name </a> </h2>
|
||||
const newLine = "<" + headerType + "> <a href=\"#" + headerId + "\">" + headerText + "</a> </" + headerType + ">";
|
||||
sidebar.append(newLine);
|
||||
}
|
||||
|
||||
sidebarLinks = $("#mind-post_sidebar-left a").toArray();
|
||||
});
|
||||
$(function () {
|
||||
$(window).scroll(function () {
|
||||
let bottomScroll = $(window).scrollTop() + ($(window).height() / 2);
|
||||
let found = false;
|
||||
|
||||
for (let i = headers.length - 1; i >= 0; i--) {
|
||||
const currentHeader = headers[i];
|
||||
const currentSidebarLink = sidebarLinks[i];
|
||||
$(currentSidebarLink).removeClass("current");
|
||||
|
||||
const headerVPPosition = $(currentHeader).offset().top;
|
||||
|
||||
if (!found && bottomScroll > headerVPPosition) {
|
||||
$(currentSidebarLink).addClass("current");
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
38
assets/js/scripts/policy-popup.js
Executable file
38
assets/js/scripts/policy-popup.js
Executable file
@@ -0,0 +1,38 @@
|
||||
function openPolicyPopup() {
|
||||
if(getCookie("consentGiven") === "true") return;
|
||||
|
||||
$("#mind-policy-popup").fadeIn(300); // Enable the div
|
||||
}
|
||||
|
||||
function agreePolicyPopup() {
|
||||
const _paq = window._paq || [];
|
||||
_paq.push(['rememberConsentGiven', 43800]);
|
||||
$("#mind-policy-popup").fadeOut(300); // Disable the div
|
||||
setCookie("consentGiven", "true", 1825) // todo: check if already present? also, firefox was throwing a warning...
|
||||
}
|
||||
|
||||
function getCookie(cname) {
|
||||
const name = cname + "=";
|
||||
const decodedCookie = decodeURIComponent(document.cookie);
|
||||
const ca = decodedCookie.split(';');
|
||||
for(let i = 0; i <ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) === 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function setCookie(name, value, days) {
|
||||
let expires = "";
|
||||
if (days) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + (days*24*60*60*1000));
|
||||
expires = "; expires=" + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/;SameSite=Lax";
|
||||
}
|
||||
48
assets/js/scripts/scroll-navbar-color.js
Executable file
48
assets/js/scripts/scroll-navbar-color.js
Executable file
@@ -0,0 +1,48 @@
|
||||
var scroll_pos = 0;
|
||||
var transparent = true;
|
||||
var offset = 100;
|
||||
|
||||
function makeTransparent()
|
||||
{
|
||||
$("#mind-global-navbar_primary").removeClass('mind-global-navbar_primary-colored').addClass('mind-global-navbar_primary-transparent');
|
||||
transparent = true;
|
||||
}
|
||||
|
||||
function makeOpaque()
|
||||
{
|
||||
$("#mind-global-navbar_primary").removeClass('mind-global-navbar_primary-transparent').addClass('mind-global-navbar_primary-colored');
|
||||
transparent = false;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#mind-global-navbar_primary").addClass('mind-global-navbar_primary-allowmoving');
|
||||
scroll_pos = $(this).scrollTop();
|
||||
|
||||
if(scroll_pos > offset)
|
||||
{
|
||||
makeOpaque();
|
||||
}
|
||||
else
|
||||
{
|
||||
makeTransparent();
|
||||
}
|
||||
|
||||
$(document).scroll(function() {
|
||||
scroll_pos = $(this).scrollTop();
|
||||
if(transparent)
|
||||
{
|
||||
if(scroll_pos > offset)
|
||||
{
|
||||
makeOpaque();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(scroll_pos <= offset)
|
||||
{
|
||||
makeTransparent();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user