home, tag archive improvements

This commit is contained in:
2019-06-24 02:37:58 +02:00
parent bbd581903b
commit 48e247e0f9
15 changed files with 768 additions and 280 deletions

View File

@@ -147,15 +147,18 @@
if (!isMobile) {
$(".search-box button").click(function (e) {
e.preventDefault()
// e.preventDefault()
var bar = $(this).next(".search-bar")
if (bar.hasClass("opensearch")) {
//if search is opened close:
bar.stop().animate({ width: "0" }, 400, function () {
bar.hide().removeClass("opensearch")
})
} else {
bar.show().stop().animate({ width: "20rem" }, 400, function () {
//if it's closed open:
bar.show().stop().animate({ width: "50vw" }, 400, function () {
bar.addClass("opensearch")
$(".search-input").focus()
})
}
@@ -203,8 +206,13 @@
//console.log($('.hbox:nth-child(' + j + ')').attr("id"), i, j)
$('.hbox:nth-child(' + j + ')').addClass("home-small home-thumbnail-small-" + articleWrapCounter)
//change order if there is a description
if ($(".archivedescription") && articleWrapCounter == 1 && j > 2 && j < 5) {
$('.hbox:nth-child(' + j + ')').css({ order: "99" })
if ($("body").is('.archive, .tag') && articleWrapCounter == 1) {
if (j == 3 || j == 4) {
$('.hbox:nth-child(' + j + ')').css({ order: j - 1 })
} else if (j == 5 || j == 6) {
$('.hbox:nth-child(' + j + ')').css({ order: j })
}
}
}
//wrap classes
@@ -247,12 +255,27 @@
return i
}
function random2() {
const choices = [
[1, 3],
[1, 5],
[1, 6],
[2, 4],
[2, 6],
[3, 4],
[3, 5],
[4, 6]
]
let nr = Math.floor(Math.random() * choices.length);
return choices[nr]
}
//jquery function, adds random class to 3 random cihldren
(function ($) {
$.fn.addRandomClasses = function () {
let rn = randomNumbers()
for (let i = 0; i < 3; i++) {
var j = rn[i] + 1
let rn = random2()
for (let i = 0; i < 2; i++) {
var j = rn[i]
this.children("article:nth-child(" + j + ")").addClass("random")
}
return this
@@ -576,9 +599,20 @@
//move subs to wrapper
$(bedoListItems).each(function () {
let itemId = $(this).attr("id")
$(".sub-wrapper").append('<div id="' + itemId + '"></div>')
$(this).children("a").clone().appendTo(".sub-wrapper #"+ itemId)
$(this).children("span").appendTo(".sub-wrapper #"+ itemId)
let tagClass = $(this).attr("class").split(" ")
let itemClass = findClassByStart(tagClass, 'tag')
// add wrapper div
$(".sub-wrapper").append('<div id="' + itemId + '" class="bedo-sub-wrapper ' + itemClass + '"></div>')
// add tag title
$(this).children("a").clone().appendTo(".sub-wrapper #" + itemId)
//add sub text
$(this).children("span").appendTo(".sub-wrapper #" + itemId)
//add circle
$(".sub-wrapper #" + itemId + " span").append('<div class="circle">')
})
//wrap each letter to spans
@@ -600,9 +634,15 @@
$(bedoWords).hover(function () {
$(bedoLetters).addClass("pause")
$(this).children("span").addClass("current")
let currTagClass = $(this).parent().attr("class").split(" ")
let tagClass = findClassByStart(currTagClass, "tag")
console.log(".bedo-sub-wrapper ." + tagClass)
$(".sub-wrapper>.opened").removeClass("opened")
$(".sub-wrapper>." + tagClass).addClass("opened")
}, function () {
$(bedoLetters).removeClass("pause")
$(this).children("span").removeClass("current")
$(".sub-wrapper>.opened").removeClass("opened")
})