update multiple things
This commit is contained in:
134
js/scripts.js
134
js/scripts.js
@@ -13,8 +13,8 @@
|
||||
/* -------------------------------- geometry -------------------------------- */
|
||||
|
||||
// const vw = $(window).width()
|
||||
const wow = window.outerWidth
|
||||
const wiw = window.innerWidth
|
||||
// const wow = window.outerWidth
|
||||
// const wiw = window.innerWidth
|
||||
// const bw = $('body').width()
|
||||
|
||||
// const woh = window.outerHeight
|
||||
@@ -24,8 +24,6 @@
|
||||
// const dch = document.documentElement.clientHeight
|
||||
|
||||
|
||||
const desktophomemargin = $(".header-1")[0].getBoundingClientRect().width
|
||||
|
||||
const bottomScrollHeight = 0
|
||||
// height of scrollbar at bottom
|
||||
// const bottomScrollHeight = (_ => {
|
||||
@@ -55,19 +53,38 @@
|
||||
|
||||
|
||||
/* --------------------------- css values to vars --------------------------- */
|
||||
//isMobile
|
||||
const isMobile = (_ => {
|
||||
if (wow < 769 || wiw < 769) {
|
||||
//mobile settings
|
||||
$('.social-link, .events-link').addClass('hidden')
|
||||
return true
|
||||
|
||||
|
||||
function calcWidths() {
|
||||
let wow = window.outerWidth
|
||||
let wiw = window.innerWidth
|
||||
let mw = $(".header-1")[0].getBoundingClientRect().width
|
||||
return { wow: wow, wiw: wiw, desktophomemargin: mw }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true or false for mobile and tablet query
|
||||
* @param {string} device 'tablet' or 'mobile'
|
||||
*/
|
||||
function checkDevice(device) {
|
||||
let ww = calcWidths()
|
||||
|
||||
// let wow = window.outerWidth
|
||||
// let wiw = window.innerWidth
|
||||
|
||||
if ((ww.wow < 769 || ww.wiw < 769) && device == 'mobile') {
|
||||
//mobile settings
|
||||
return true
|
||||
} else if (768 < ww.wow && ww.wow < 1024 && 768 < ww.wiw && ww.wiw < 1024 && device == 'tablet') {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
var isMobile = checkDevice('mobile')
|
||||
var isTablet = checkDevice('tablet')
|
||||
|
||||
const isTablet = (!isMobile && (wow < 1024 && wiw < 1024)) ? true : false
|
||||
|
||||
/**
|
||||
* Checks if body has a class
|
||||
@@ -122,7 +139,7 @@
|
||||
if ($(".menubutton button").hasClass("rotated")) {
|
||||
$(".menubutton button").removeClass("rotated");
|
||||
} else {
|
||||
$(".menubutton button").addClass("rotated");
|
||||
$(".menubutton button").addClass("rotated").addClass("inverted");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,18 +151,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
function convertRemToPixels(rem) {
|
||||
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
/* --------------------- generic page load for onresize --------------------- */
|
||||
|
||||
function loadPage() {
|
||||
if (isMobile) {
|
||||
// hide social buttons
|
||||
$('.social-link, .events-link').addClass('hidden')
|
||||
// move search to menu
|
||||
$(".search-box>.search-bar").prependTo("#sidebar-wrapper")
|
||||
} else {
|
||||
$('.social-link, .events-link').removeClass('hidden')
|
||||
// move search to back
|
||||
$("#sidebar-wrapper>.search-bar").appendTo(".search-box")
|
||||
}
|
||||
}
|
||||
|
||||
loadPage()
|
||||
|
||||
/* ========================================================================== */
|
||||
/* SEARCH */
|
||||
/* ========================================================================== */
|
||||
|
||||
// on mobile add to sidebar:
|
||||
if (isMobile) {
|
||||
$(".search-bar").prependTo("#sidebar-wrapper")
|
||||
}
|
||||
// if (isMobile) {
|
||||
// $(".search-box>.search-bar").prependTo("#sidebar-wrapper")
|
||||
// }
|
||||
|
||||
//clicking on desktop
|
||||
if (!isMobile) {
|
||||
@@ -158,8 +188,9 @@
|
||||
bar.hide().removeClass("opensearch")
|
||||
})
|
||||
} else {
|
||||
let ww = calcWidths()
|
||||
//if it's closed open:
|
||||
bar.show().stop().animate({ width: wiw - (desktophomemargin * 2) }, 400, function () {
|
||||
bar.show().stop().animate({ width: ww.wiw - (ww.desktophomemargin * 2) }, 400, function () {
|
||||
bar.addClass("opensearch")
|
||||
$(".search-input").focus()
|
||||
})
|
||||
@@ -173,14 +204,26 @@
|
||||
/* MENU */
|
||||
/* ========================================================================== */
|
||||
|
||||
var menuWidth = wow
|
||||
|
||||
if (isTablet) {
|
||||
menuWidth = 350
|
||||
}
|
||||
if (!isMobile && !isTablet) {
|
||||
menuWidth = 500
|
||||
function mwCalc() {
|
||||
let ww = calcWidths()
|
||||
if (isMobile) {
|
||||
return ww.wow
|
||||
} else if (isTablet) {
|
||||
return 350
|
||||
} else {
|
||||
return 500
|
||||
}
|
||||
}
|
||||
var menuWidth = mwCalc()
|
||||
// var menuWidth = 100
|
||||
|
||||
// if (isTablet) {
|
||||
// menuWidth = 350
|
||||
// }
|
||||
// if (!isMobile && !isTablet) {
|
||||
// menuWidth = 500
|
||||
// }
|
||||
|
||||
$("#sidebar").simplerSidebar({
|
||||
|
||||
@@ -210,6 +253,7 @@
|
||||
callbacks: {
|
||||
animation: {
|
||||
both: showHideSocial,
|
||||
close: function () { $(".menubutton button").removeClass("inverted") },
|
||||
freezePage: false
|
||||
}
|
||||
}
|
||||
@@ -301,11 +345,7 @@
|
||||
|
||||
//fit title
|
||||
$("body:not(.no-result) .archivetitle h1").fitText(0.7)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}//isMasonryPage end
|
||||
}// !isMobile end
|
||||
|
||||
@@ -416,20 +456,22 @@
|
||||
|
||||
var offset = ($(nextelem).position().left)
|
||||
|
||||
let ww = calcWidths()
|
||||
|
||||
//if loadmore is the next, do not scroll, but load:
|
||||
if (nextelem.attr("class") == "misha_loadmore") {
|
||||
loadmore()
|
||||
return target
|
||||
} else if (isEsemeny) {
|
||||
offset = offset - (desktophomemargin)
|
||||
offset = offset - (ww.desktophomemargin)
|
||||
} else {
|
||||
//from the third wrap modify the offset
|
||||
var wNum = parseInt($(nextelem).attr("class").split(" ")[1].split("-")[1])
|
||||
console.log(wNum)
|
||||
if (wNum == 3) {
|
||||
offset = offset - (desktophomemargin / 2)
|
||||
offset = offset - (ww.desktophomemargin / 2)
|
||||
} else if (wNum > 3 || !isHome) {
|
||||
offset = offset - desktophomemargin
|
||||
offset = offset - ww.desktophomemargin
|
||||
}
|
||||
}
|
||||
console.log("scrolling to: " + nextelem.attr("class") + " - offset: " + offset)
|
||||
@@ -1092,6 +1134,32 @@
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* window resize event */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
$(window).resize(function () {
|
||||
let ww = calcWidths()
|
||||
|
||||
//check if mobile
|
||||
isMobile = checkDevice('mobile')
|
||||
isTablet = checkDevice('tablet')
|
||||
|
||||
// calc other vars
|
||||
menuWidth = mwCalc()
|
||||
|
||||
//run load script
|
||||
loadPage()
|
||||
|
||||
|
||||
//resize search
|
||||
if ($('.search-bar').hasClass("opensearch")) {
|
||||
$('.search-bar').css({ width: ww.wiw - (ww.desktophomemargin * 2) })
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------- END OF FILE ------------------------------ */
|
||||
|
||||
Reference in New Issue
Block a user