aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-12-10 21:24:00 +0300
committerGravatar Vitaly Takmazov2020-12-10 21:24:00 +0300
commit82cd876419bb2604fd20aa97299e9c9d961669c0 (patch)
tree5283bb3d72f5148050c2b545d8f5347448dabc35 /src
parent0121e2dd9093007315382aa505e563675a8d5112 (diff)
scripts: drop outdated header scrolling code
Diffstat (limited to 'src')
-rw-r--r--src/main/assets/scripts.js84
1 files changed, 11 insertions, 73 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js
index ef02dca8..de4669b6 100644
--- a/src/main/assets/scripts.js
+++ b/src/main/assets/scripts.js
@@ -142,7 +142,7 @@ function initES() {
pageTitle = document.title;
}
};
- es.addEventListener('msg', msg => {
+ es.addEventListener('msg', msg => {
try {
var jsonMsg = JSON.parse(msg.data);
console.log('data: ' + msg.data);
@@ -521,9 +521,9 @@ function likeMessage(e, mid) {
if (confirm(i18n('message.likeThisMessage?'))) {
fetch('/api/like?mid=' + mid
+ '&hash=' + document.getElementById('body').getAttribute('data-hash'), {
- method: 'POST',
- credentials: 'omit'
- })
+ method: 'POST',
+ credentials: 'omit'
+ })
.then(handleErrors)
.then(function(response) {
if (response.ok) {
@@ -540,9 +540,9 @@ function likeMessage(e, mid) {
function subscribeMessage(e, mid) {
fetch('/api/subscribe?mid=' + mid
+ '&hash=' + document.getElementById('body').getAttribute('data-hash'), {
- method: 'POST',
- credentials: 'omit'
- })
+ method: 'POST',
+ credentials: 'omit'
+ })
.then(handleErrors)
.then(function(response) {
if (response.ok) {
@@ -563,8 +563,8 @@ function setPopular(e, mid, popular) {
fetch('/api/messages/set_popular?mid=' + mid
+ '&popular=' + popular
+ '&hash=' + document.getElementById('body').getAttribute('data-hash'), {
- credentials: 'same-origin'
- })
+ credentials: 'same-origin'
+ })
.then(handleErrors)
.then(function() {
e.closest('article').append(resultMessage('OK!'));
@@ -575,8 +575,8 @@ function setPopular(e, mid, popular) {
function setPrivacy(e, mid) {
fetch('/api/messages/set_privacy?mid=' + mid
+ '&hash=' + document.getElementById('body').getAttribute('data-hash'), {
- credentials: 'same-origin'
- })
+ credentials: 'same-origin'
+ })
.then(handleErrors)
.then(function() {
e.closest('article').append(resultMessage('OK!'));
@@ -876,66 +876,4 @@ ready(function() {
initES();
embedAll();
- var elSelector = 'header',
- elClassHidden = 'header--hidden',
- elClassBackground = 'header--background',
- throttleTimeout = 500,
- element = document.querySelector(elSelector);
-
- if (element) {
-
- var dHeight = 0,
- wHeight = 0,
- wScrollCurrent = 0,
- wScrollBefore = 0,
- wScrollDiff = 0,
-
- throttle = function(delay, fn) {
- var last, deferTimer;
- return function() {
- var context = this, args = arguments, now = +new Date;
- if (last && now < last + delay) {
- clearTimeout(deferTimer);
- deferTimer = setTimeout(
- function() {
- last = now;
- fn.apply(context, args);
- },
- delay);
- } else {
- last = now;
- fn.apply(context, args);
- }
- };
- };
-
- window.addEventListener('scroll', throttle(throttleTimeout, function() {
- dHeight = document.body.offsetHeight;
- wHeight = window.innerHeight;
- wScrollCurrent = window.pageYOffset;
- wScrollDiff = wScrollBefore - wScrollCurrent;
-
- if (wScrollCurrent <= 0) {
- // scrolled to the very top; element sticks to the top
- element.classList.remove(elClassHidden);
- element.classList.remove(elClassBackground);
- } else if (wScrollDiff > 0 && element.classList.contains(elClassHidden)) {
- // scrolled up; element slides in
- element.classList.remove(elClassHidden);
- element.classList.add(elClassBackground);
- } else if (wScrollDiff < 0) {
- // scrolled down
- if (wScrollCurrent + wHeight >= dHeight && element.classList.contains(elClassHidden)) {
- // scrolled to the very bottom; element slides in
- element.classList.remove(elClassHidden);
- element.classList.add(elClassBackground);
- } else {
- // scrolled down; element slides out
- element.classList.add(elClassHidden);
- }
- }
-
- wScrollBefore = wScrollCurrent;
- }));
- }
});