nodebb-theme-harmony
Advanced tools
Comparing version 1.0.0-beta.39 to 1.0.0-beta.40
@@ -9,3 +9,6 @@ { | ||
"settings.centerHeaderElements": "Center header elements", | ||
"settings.stickyToolbar": "Sticky toolbar" | ||
"settings.stickyToolbar": "Sticky toolbar", | ||
"settings.stickyToolbar.help": "The toolbar on topic and category pages will stick to the top of the page", | ||
"settings.autohideBottombar": "Auto hide bottom bar", | ||
"settings.autohideBottombar.help": "The bottom bar on mobile view will be hidden when the page is scrolled down" | ||
} |
@@ -15,2 +15,3 @@ 'use strict'; | ||
stickyToolbar: 'on', | ||
autohideBottombar: 'off', | ||
openSidebars: 'off', | ||
@@ -106,11 +107,14 @@ }; | ||
]); | ||
return { ...defaults, ...themeConfig, ...userConfig }; | ||
const config = { ...defaults, ...themeConfig, ...(_.pick(userConfig, Object.keys(defaults))) }; | ||
config.enableQuickReply = config.enableQuickReply === 'on'; | ||
config.centerHeaderElements = config.centerHeaderElements === 'on'; | ||
config.stickyToolbar = config.stickyToolbar === 'on'; | ||
config.autohideBottombar = config.autohideBottombar === 'on'; | ||
config.openSidebars = config.openSidebars === 'on'; | ||
return config; | ||
} | ||
library.getThemeConfig = async function (config) { | ||
const themeConfig = await loadThemeConfig(config.uid); | ||
config.enableQuickReply = themeConfig.enableQuickReply === 'on'; | ||
config.centerHeaderElements = themeConfig.centerHeaderElements === 'on'; | ||
config.stickyToolbar = themeConfig.stickyToolbar === 'on'; | ||
config.openSidebars = themeConfig.openSidebars === 'on'; | ||
config.theme = await loadThemeConfig(config.uid);; | ||
config.openDraftsOnPageLoad = false; | ||
@@ -141,3 +145,3 @@ return config; | ||
const { enableQuickReply } = await loadThemeConfig(hookData.req.uid); | ||
if (enableQuickReply === 'on') { | ||
if (enableQuickReply) { | ||
if (hookData.req.user) { | ||
@@ -144,0 +148,0 @@ const userData = await user.getUserData(hookData.req.uid); |
{ | ||
"name": "nodebb-theme-harmony", | ||
"version": "1.0.0-beta.39", | ||
"version": "1.0.0-beta.40", | ||
"nbbpm": { | ||
@@ -5,0 +5,0 @@ "compatibility": "^3.0.0" |
@@ -57,2 +57,47 @@ 'use strict'; | ||
}); | ||
const bottomBar = $('[component="bottombar"]'); | ||
$('body').on('shown.bs.dropdown', '.sticky-tools', function () { | ||
bottomBar.addClass('hidden'); | ||
}); | ||
$('body').on('hidden.bs.dropdown', '.sticky-tools', function () { | ||
bottomBar.removeClass('hidden'); | ||
}); | ||
let lastScrollTop = 0; | ||
const $window = $(window); | ||
function onWindowScroll() { | ||
const st = $window.scrollTop(); | ||
if (st !== lastScrollTop) { | ||
const diff = Math.abs(st - lastScrollTop); | ||
const scrolledDown = st > lastScrollTop; | ||
const scrolledUp = st < lastScrollTop; | ||
if (diff > 5) { | ||
bottomBar.css({ | ||
bottom: !scrolledUp && scrolledDown ? | ||
-bottomBar.find('.bottombar-nav').outerHeight(true) : | ||
0, | ||
}); | ||
lastScrollTop = st; | ||
} | ||
} | ||
} | ||
const delayedScroll = utils.throttle(onWindowScroll, 250); | ||
function enableAutohide() { | ||
if (config.theme.autohideBottombar) { | ||
lastScrollTop = $window.scrollTop(); | ||
$window.on('scroll', delayedScroll); | ||
} | ||
} | ||
hooks.on('action:posts.loading', function () { | ||
$window.off('scroll', delayedScroll); | ||
}); | ||
hooks.on('action:posts.loaded', enableAutohide); | ||
hooks.on('action:ajaxify.end', function () { | ||
$window.off('scroll', delayedScroll); | ||
enableAutohide(); | ||
}); | ||
enableAutohide(); | ||
}); | ||
@@ -59,0 +104,0 @@ } |
@@ -22,2 +22,3 @@ 'use strict'; | ||
}); | ||
config.theme = (await api.get('/api/config')).theme; | ||
alerts.success('[[success:settings-saved]]'); | ||
@@ -24,0 +25,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
272890
471