hubzilla 8
This commit is contained in:
@@ -2,7 +2,45 @@
|
||||
* ussrbasicpub theme specific JavaScript
|
||||
*/
|
||||
|
||||
let ussrbasicpub_dark_mode = localStorage.getItem('ussrbasicpub_dark_mode');
|
||||
let ussrbasicpub_theme_color = localStorage.getItem('ussrbasicpub_theme_color');
|
||||
|
||||
if (ussrbasicpub_dark_mode == 1) {
|
||||
$('html').attr('data-bs-theme', 'dark');
|
||||
}
|
||||
|
||||
if (ussrbasicpub_dark_mode == 0) {
|
||||
$('html').attr('data-bs-theme', 'light');
|
||||
}
|
||||
|
||||
if (ussrbasicpub_theme_color) {
|
||||
$('meta[name=theme-color]').attr('content', ussrbasicpub_theme_color);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// provide a fake progress bar for pwa standalone mode
|
||||
if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||
$(window).on('beforeunload', function(){
|
||||
if ($('.page-loader').length) {
|
||||
return;
|
||||
}
|
||||
$('<div class="bg-primary page-loader"></div>').prependTo('body');
|
||||
});
|
||||
}
|
||||
|
||||
if (ussrbasicpub_dark_mode == 1) {
|
||||
$('#theme-switch-icon').removeClass('fa-moon-o').addClass('fa-sun-o');
|
||||
$('[data-bs-theme="light"]').attr('data-bs-theme', 'dark');
|
||||
}
|
||||
if (ussrbasicpub_dark_mode == 0) {
|
||||
$('#theme-switch-icon').removeClass('fa-sun-o').addClass('fa-moon-o');
|
||||
$('[data-bs-theme="dark"]:not(nav)').attr('data-bs-theme', 'light');
|
||||
}
|
||||
|
||||
if (ussrbasicpub_theme_color != $('nav').css('background-color')) {
|
||||
$('meta[name=theme-color]').attr('content', $('nav').css('background-color'));
|
||||
localStorage.setItem('ussrbasicpub_theme_color', $('nav').css('background-color'));
|
||||
}
|
||||
|
||||
// CSS3 calc() fallback (for unsupported browsers)
|
||||
$('body').append('<div id="css3-calc" style="width: 10px; width: calc(10px + 10px); display: none;"></div>');
|
||||
@@ -17,29 +55,47 @@ $(document).ready(function() {
|
||||
}
|
||||
$('#css3-calc').remove(); // Remove the test element
|
||||
|
||||
if($(window).width() < 1200) {
|
||||
$("#right_aside_wrapper").children().detach().appendTo('#left_aside_wrapper');
|
||||
$('#notifications_wrapper').addClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
if (document.querySelector('#region_1')) {
|
||||
stickyScroll('.aside_spacer_left', '.aside_spacer_top_left', '.content', parseFloat(window.getComputedStyle(document.querySelector('#region_1')).getPropertyValue('padding-top')), 0);
|
||||
stickyScroll('.aside_spacer_left', '.aside_spacer_top_left', 'section', parseFloat(document.querySelector('main').getBoundingClientRect().top), 20);
|
||||
}
|
||||
|
||||
if (document.querySelector('#region_3')) {
|
||||
stickyScroll('.aside_spacer_right', '.aside_spacer_top_right', '.content', parseFloat(window.getComputedStyle(document.querySelector('#region_3')).getPropertyValue('padding-top')), 20);
|
||||
stickyScroll('.aside_spacer_right', '.aside_spacer_top_right', 'section', parseFloat(document.querySelector('main').getBoundingClientRect().top), 20);
|
||||
}
|
||||
|
||||
$('#expand-aside').on('click', function() {
|
||||
if($('main').hasClass('region_1-on')){
|
||||
toggleAside('left');
|
||||
}
|
||||
else {
|
||||
toggleAside('right');
|
||||
}
|
||||
});
|
||||
|
||||
$('.usermenu').click(function() {
|
||||
if($('#navbar-collapse-1, #navbar-collapse-2').hasClass('show')){
|
||||
$('#navbar-collapse-1, #navbar-collapse-2').removeClass('show');
|
||||
}
|
||||
});
|
||||
|
||||
$('#theme-switch').click(function() {
|
||||
if ($('html').attr('data-bs-theme') === 'dark') {
|
||||
if ($('nav').data('bs-theme') === 'dark') {
|
||||
$('[data-bs-theme="dark"]:not(nav)').attr('data-bs-theme', 'light');
|
||||
}
|
||||
else {
|
||||
$('[data-bs-theme="dark"]').attr('data-bs-theme', 'light');
|
||||
}
|
||||
localStorage.setItem('ussrbasicpub_dark_mode', 0);
|
||||
$('#theme-switch-icon').removeClass('fa-sun-o').addClass('fa-moon-o');
|
||||
}
|
||||
else {
|
||||
$('[data-bs-theme="light"]').attr('data-bs-theme', 'dark');
|
||||
localStorage.setItem('ussrbasicpub_dark_mode', 1);
|
||||
$('#theme-switch-icon').removeClass('fa-moon-o').addClass('fa-sun-o');
|
||||
}
|
||||
$('meta[name=theme-color]').attr('content', $('nav').css('background-color'));
|
||||
localStorage.setItem('ussrbasicpub_theme_color', $('nav').css('background-color'));
|
||||
});
|
||||
|
||||
|
||||
$('#menu-btn').click(function() {
|
||||
if($('#navbar-collapse-1').hasClass('show')){
|
||||
$('#navbar-collapse-1').removeClass('show');
|
||||
@@ -83,7 +139,7 @@ $(document).ready(function() {
|
||||
//just one finger touched
|
||||
touch_start = e.touches.item(0).clientX;
|
||||
if (touch_start < touch_max) {
|
||||
$('html, body').css('overflow-y', 'hidden');
|
||||
$('body').css('overflow-y', 'hidden');
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -93,7 +149,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
window.addEventListener('touchend', function(e) {
|
||||
$('html, body').css('overflow-y', '');
|
||||
$('body').css('overflow-y', '');
|
||||
|
||||
let touch_offset = 30; //at least 30px are a swipe
|
||||
if (touch_start) {
|
||||
@@ -103,20 +159,15 @@ $(document).ready(function() {
|
||||
if (touch_end > (touch_start + touch_offset)) {
|
||||
//a left -> right swipe
|
||||
if (touch_start < touch_max) {
|
||||
toggleAside('right');
|
||||
toggleAside();
|
||||
}
|
||||
}
|
||||
if (touch_end < (touch_start - touch_offset)) {
|
||||
//a right -> left swipe
|
||||
//toggleAside('left');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('hz:hqControlsClickAction', function(e) {
|
||||
toggleAside('left');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function setStyle(element, cssProperty) {
|
||||
@@ -164,12 +215,12 @@ function stickyScroll(sticky, stickyTop, container, topOffset, bottomOffset) {
|
||||
setStyle(sticky, { position: 'sticky', top: Math.round(diff) - bottomOffset + 'px', bottom: '' });
|
||||
} else {
|
||||
// upscroll code
|
||||
h = sticky.getBoundingClientRect().top - content.getBoundingClientRect().top - topOffset;
|
||||
h = sticky.getBoundingClientRect().top - content.getBoundingClientRect().top;
|
||||
if(Math.round(stickyTop.getBoundingClientRect().height) === lasth) {
|
||||
setStyle(stickyTop, { height: Math.round(h) + 'px' });
|
||||
}
|
||||
lasth = Math.round(h);
|
||||
setStyle(sticky, { position: 'sticky', top: '', bottom: Math.round(diff - topOffset) + 'px' });
|
||||
setStyle(sticky, { position: 'sticky', top: '', bottom: Math.round(diff) - topOffset + 'px' });
|
||||
}
|
||||
lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
|
||||
}
|
||||
@@ -190,18 +241,4 @@ function makeFullScreen(full) {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleAside(swipe) {
|
||||
|
||||
if ($('main').hasClass('region_1-on') && swipe === 'left') {
|
||||
$('#expand-aside-icon').addClass('fa-arrow-circle-right').removeClass('fa-arrow-circle-left');
|
||||
$('html, body').css({ 'position': '', left: '' });
|
||||
$('main').removeClass('region_1-on');
|
||||
$('#overlay').remove();
|
||||
}
|
||||
if (!$('main').hasClass('region_1-on') && swipe === 'right') {
|
||||
$('#expand-aside-icon').removeClass('fa-arrow-circle-right').addClass('fa-arrow-circle-left');
|
||||
$('html, body').css({ 'position': 'sticky', 'left': '0px'});
|
||||
$('main').addClass('region_1-on');
|
||||
$('<div id="overlay"></div>').appendTo('body').one('click', function() { toggleAside('left'); });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user