nodebb-theme-oxide
Advanced tools
Comparing version 5.0.41 to 5.0.42
@@ -38,7 +38,7 @@ "use strict"; | ||
if (data && data.queued) { | ||
components.get("topic/quickreply/text").val(""); | ||
autocomplete._active["oxide_qr"].hide(); | ||
app.alertSuccess(data.message); | ||
} | ||
components.get("topic/quickreply/text").val(""); | ||
autocomplete._active["oxide_qr"].hide(); | ||
}); | ||
@@ -45,0 +45,0 @@ }); |
@@ -6,3 +6,3 @@ /* globals ajaxify */ | ||
const isDefault = document.documentElement.dataset.initialDark ? true : false; | ||
const isDefault = document.documentElement.dataset.initialDark === "true"; | ||
if (isDefault) return; | ||
@@ -18,12 +18,12 @@ | ||
window.darkmode = !window.darkmode; | ||
isDarkmode = !isDarkmode; | ||
const btnState = window.darkmode ? "on" : "off"; | ||
const btnState = isDarkmode ? "on" : "off"; | ||
btn.className = btnState; | ||
_updateTheme(window.darkmode); | ||
_updateTheme(isDarkmode); | ||
}; | ||
window.darkmode = Boolean(localStorage.getItem("user:dark")); | ||
_updateTheme(window.darkmode); | ||
let isDarkmode = localStorage.getItem("user:dark") === "true"; | ||
_updateTheme(isDarkmode); | ||
@@ -34,3 +34,3 @@ $(window).on("action:ajaxify.end", () => { | ||
const btn = document.querySelector("#toggle-theme"); | ||
window.darkmode ? (btn.className = "on") : (btn.className = "off"); | ||
isDarkmode ? (btn.className = "on") : (btn.className = "off"); | ||
@@ -37,0 +37,0 @@ btn.addEventListener("click", (e) => _setTheme(e, btn), false); |
201
lib/oxide.js
@@ -17,3 +17,3 @@ "use strict"; | ||
const configureNavbarHiding = () => { | ||
let navbarEl = $(".navbar-fixed-top"); | ||
const navbarEl = $(".navbar-fixed-top"); | ||
@@ -25,6 +25,7 @@ navbarEl.autoHidingNavbar("destroy"); | ||
if (env === "xs" || env === "sm") | ||
if (env === "xs" || env === "sm") { | ||
navbarEl.autoHidingNavbar({ | ||
showOnBottom: false, | ||
}); | ||
} | ||
}; | ||
@@ -98,12 +99,9 @@ | ||
// this... | ||
function setupEditedByIcon() { | ||
function activateEditedTooltips() { | ||
const setupEditedByIcon = () => { | ||
const activateEditedTooltips = () => { | ||
$('[data-pid] [component="post/editor"]').each(function() { | ||
var el = $(this), | ||
icon; | ||
const el = $(this); | ||
let icon; | ||
if (!el.attr("data-editor")) { | ||
return; | ||
} | ||
if (!el.attr("data-editor")) return; | ||
@@ -114,2 +112,3 @@ icon = el | ||
.first(); | ||
icon | ||
@@ -120,7 +119,9 @@ .prop("title", el.text()) | ||
}); | ||
} | ||
}; | ||
$(window).on("action:posts.edited", function(ev, data) { | ||
var parent = $('[data-pid="' + data.post.pid + '"]'); | ||
var icon = parent.find(".edit-icon").filter(function(index, el) { | ||
const handlePostEdit = (ev, data) => { | ||
const parent = $(`[data-pid="${data.post.pid}"]`); | ||
const el = parent.find('[component="post/editor"]').first(); | ||
const icon = parent.find(".edit-icon").filter((index, el) => { | ||
return ( | ||
@@ -135,3 +136,3 @@ parseInt( | ||
}); | ||
var el = parent.find('[component="post/editor"]').first(); | ||
icon | ||
@@ -141,21 +142,17 @@ .prop("title", el.text()) | ||
.removeClass("hidden"); | ||
}); | ||
}; | ||
$(window).on("action:topic.loaded", activateEditedTooltips); | ||
$(window).on("action:posts.loaded", activateEditedTooltips); | ||
} | ||
$(window).on("action:posts.edited", handlePostEdit); | ||
}; | ||
// Not edited | ||
function setupMobileMenu() { | ||
if (!window.addEventListener) { | ||
return; | ||
} | ||
const setupMobileMenu = () => { | ||
if (!window.addEventListener) return null; | ||
require(["pulling", "storage"], function(Pulling, Storage) { | ||
// initialization | ||
require(["pulling", "storage"], (Pulling, Storage) => { | ||
let chatMenuVisible = !config.disableChat && app.user && parseInt(app.user.uid, 10); | ||
let swapped = !!Storage.getItem("oxide:menus:legacy-layout"); | ||
const margin = window.innerWidth; | ||
var chatMenuVisible = !config.disableChat && app.user && parseInt(app.user.uid, 10); | ||
var swapped = !!Storage.getItem("oxide:menus:legacy-layout"); | ||
var margin = window.innerWidth; | ||
if (swapped) { | ||
@@ -166,9 +163,7 @@ $("#mobile-menu").removeClass("pull-left"); | ||
if (document.documentElement.getAttribute("data-dir") === "rtl") { | ||
swapped = !swapped; | ||
} | ||
if (document.documentElement.dataset.dir === "rtl") swapped = !swapped; | ||
var navSlideout = Pulling.create({ | ||
panel: document.getElementById("panel"), | ||
menu: document.getElementById("menu"), | ||
let navSlideout = Pulling.create({ | ||
panel: document.querySelector("#panel"), | ||
menu: document.querySelector("#menu"), | ||
width: 256, | ||
@@ -178,9 +173,11 @@ margin: margin, | ||
}); | ||
$("#menu").removeClass("hidden"); | ||
var chatsSlideout; | ||
let chatsSlideout; | ||
if (chatMenuVisible) { | ||
chatsSlideout = Pulling.create({ | ||
panel: document.getElementById("panel"), | ||
menu: document.getElementById("chats-menu"), | ||
panel: document.querySelector("#panel"), | ||
menu: document.querySelector("#chats-menu"), | ||
width: 256, | ||
@@ -190,29 +187,30 @@ margin: margin, | ||
}); | ||
$("#chats-menu").removeClass("hidden"); | ||
} | ||
// all menus | ||
/** | ||
* All menus | ||
*/ | ||
function closeOnClick() { | ||
const closeOnClick = () => { | ||
navSlideout.close(); | ||
if (chatsSlideout) { | ||
chatsSlideout.close(); | ||
} | ||
} | ||
function onBeforeOpen() { | ||
document.documentElement.classList.add("slideout-open"); | ||
} | ||
if (chatsSlideout) chatsSlideout.close(); | ||
}; | ||
function onClose() { | ||
const onBeforeOpen = () => document.documentElement.classList.add("slideout-open"); | ||
const onClose = () => { | ||
document.documentElement.classList.remove("slideout-open"); | ||
$("#mobile-menu").blur(); | ||
document.documentElement.classList.remove("slideout-open"); | ||
$("#panel").off("click", closeOnClick); | ||
} | ||
}; | ||
$(window).on("resize action:ajaxify.start", function() { | ||
$(window).on("resize action:ajaxify.start", () => { | ||
navSlideout.close(); | ||
if (chatsSlideout) { | ||
chatsSlideout.close(); | ||
} | ||
if (chatsSlideout) chatsSlideout.close(); | ||
$(".account .cover").css("top", $('[component="navbar"]').height()); | ||
@@ -225,5 +223,3 @@ }); | ||
.on("beforeopen", onBeforeOpen) | ||
.on("opened", function() { | ||
$("#panel").one("click", closeOnClick); | ||
}); | ||
.on("opened", () => $("#panel").one("click", closeOnClick)); | ||
@@ -240,13 +236,12 @@ if (chatMenuVisible) { | ||
// left slideout navigation menu | ||
/** | ||
* Left slideout navigation menu | ||
*/ | ||
$("#mobile-menu").on("click", function() { | ||
navSlideout.enable().toggle(); | ||
}); | ||
$("#mobile-menu").on("click", () => navSlideout.enable().toggle()); | ||
function loadNotifications() { | ||
require(["notifications"], function(notifications) { | ||
notifications.loadNotifications($('#menu [data-section="notifications"] ul')); | ||
}); | ||
} | ||
const loadNotifications = () => { | ||
require(["notifications"], (notifications) => | ||
notifications.loadNotifications($('#menu [data-section="notifications"] ul'))); | ||
}; | ||
@@ -257,7 +252,7 @@ navSlideout.on("opened", loadNotifications); | ||
navSlideout | ||
.on("beforeopen", function() { | ||
.on("beforeopen", () => { | ||
chatsSlideout.close(); | ||
chatsSlideout.disable(); | ||
}) | ||
.on("closed", function() { | ||
.on("closed", () => { | ||
chatsSlideout.enable(); | ||
@@ -270,2 +265,3 @@ }); | ||
); | ||
$("#user-control-list") | ||
@@ -276,3 +272,3 @@ .children() | ||
socket.on("event:user_status_change", function(data) { | ||
socket.on("event:user_status_change", (data) => { | ||
if (parseInt(data.uid, 10) === app.user.uid) { | ||
@@ -284,9 +280,9 @@ app.updateUserStatus($('#menu [component="user/status"]'), data.status); | ||
// right slideout chats menu | ||
/** | ||
* Right slideout chats menu | ||
*/ | ||
function loadChats() { | ||
require(["chat"], function(chat) { | ||
chat.loadChatsDropdown($("#chats-menu .chat-list")); | ||
}); | ||
} | ||
const loadChats = () => { | ||
require(["chat"], (chat) => chat.loadChatsDropdown($("#chats-menu .chat-list"))); | ||
}; | ||
@@ -296,7 +292,7 @@ if (chatMenuVisible) { | ||
.removeClass("hidden") | ||
.on("click", function() { | ||
.on("click", () => { | ||
navSlideout.close(); | ||
chatsSlideout.enable().toggle(); | ||
}); | ||
$("#chats-menu").on("click", "li[data-roomid]", function() { | ||
$("#chats-menu").on("click", "li[data-roomid]", () => { | ||
chatsSlideout.close(); | ||
@@ -307,6 +303,6 @@ }); | ||
.on("opened", loadChats) | ||
.on("beforeopen", function() { | ||
.on("beforeopen", () => { | ||
navSlideout.close().disable(); | ||
}) | ||
.on("closed", function() { | ||
.on("closed", () => { | ||
navSlideout.enable(); | ||
@@ -316,13 +312,13 @@ }); | ||
// add a checkbox in the user settings page | ||
// so users can swap the sides the menus appear on | ||
/** | ||
* Add a checkbox in the user settings page | ||
* so users can swap the sides the menus appear on | ||
*/ | ||
function setupSetting() { | ||
const setupSetting = () => { | ||
if (ajaxify.data.template["account/settings"] && !document.getElementById("oxide:menus:legacy-layout")) { | ||
require(["translator"], function(translator) { | ||
translator.translate("[[oxide:mobile-menu-side]]", function(translated) { | ||
require(["translator"], (translator) => { | ||
translator.translate("[[oxide:mobile-menu-side]]", (translated) => { | ||
$( | ||
'<div class="well checkbox"><label><input type="checkbox" id="oxide:menus:legacy-layout"/><strong>' + | ||
translated + | ||
"</strong></label></div>" | ||
`<div class="well checkbox"><label><input type="checkbox" id="oxide:menus:legacy-layout"/><strong>${translated}</strong></label></div>"` | ||
) | ||
@@ -332,3 +328,3 @@ .appendTo("#content .account > .row > div:first-child") | ||
.prop("checked", Storage.getItem("oxide:menus:legacy-layout", "true")) | ||
.change(function(e) { | ||
.change((e) => { | ||
if (e.target.checked) { | ||
@@ -343,3 +339,3 @@ Storage.setItem("oxide:menus:legacy-layout", "true"); | ||
} | ||
} | ||
}; | ||
@@ -349,11 +345,10 @@ $(window).on("action:ajaxify.end", setupSetting); | ||
}); | ||
} | ||
}; | ||
// Not edited | ||
function setupHoverCards() { | ||
require(["components"], function(components) { | ||
const setupHoverCards = () => { | ||
require(["components"], (components) => { | ||
components.get("topic").on("click", '[component="user/picture"],[component="user/status"]', generateUserCard); | ||
}); | ||
$(window).on("action:posts.loading", function(ev, data) { | ||
$(window).on("action:posts.loading", (ev, data) => { | ||
for (var i = 0, ii = data.posts.length; i < ii; i++) { | ||
@@ -363,8 +358,8 @@ (ajaxify.data.topics || ajaxify.data.posts)[data.posts[i].index] = data.posts[i]; | ||
}); | ||
} | ||
}; | ||
function generateUserCard(ev) { | ||
var avatar = $(this), | ||
index = avatar.parents("[data-index]").attr("data-index"), | ||
data = ajaxify.data.topics || ajaxify.data.posts; | ||
let avatar = $(this); | ||
let index = avatar.parents("[data-index]").attr("data-index"); | ||
let data = ajaxify.data.topics || ajaxify.data.posts; | ||
@@ -380,8 +375,6 @@ for (var i = 0, ii = data.length; i < ii; i++) { | ||
if (parseInt(data.uid, 10) === 0) { | ||
return false; | ||
} | ||
if (parseInt(data.uid, 10) === 0) return false; | ||
socket.emit("user.isFollowing", { uid: data.uid }, function(err, isFollowing) { | ||
app.parseAndTranslate("modules/usercard", data, function(html) { | ||
socket.emit("user.isFollowing", { uid: data.uid }, (err, isFollowing) => { | ||
app.parseAndTranslate("modules/usercard", data, (html) => { | ||
var card = $(html); | ||
@@ -412,4 +405,5 @@ avatar.parents("a").after(card.hide()); | ||
const setupFavouriteButtonOnProfile = () => | ||
const setupFavouriteButtonOnProfile = () => { | ||
setupFavouriteMorph($('[component="account/cover"]'), ajaxify.data.uid, ajaxify.data.username); | ||
}; | ||
@@ -428,3 +422,2 @@ const setupCardRemoval = (card) => { | ||
// this... | ||
function setupFavouriteMorph(parent, uid, username) { | ||
@@ -431,0 +424,0 @@ parent.find(".btn-morph").click(function(ev) { |
@@ -94,21 +94,10 @@ "use strict"; | ||
const { | ||
hideSubCategories, | ||
hideCategoryLastPost, | ||
enableQuickReply, | ||
enableShowTid, | ||
enableCategoryIcon, | ||
enableShowUserAllGroupsInProfile, | ||
enableShowIpInUserProfile, | ||
enableDarkmodeIsDefault, | ||
} = settings; | ||
config.hideSubCategories = hideSubCategories === "on"; | ||
config.hideCategoryLastPost = hideCategoryLastPost === "on"; | ||
config.enableQuickReply = enableQuickReply === "on"; | ||
config.enableShowTid = enableShowTid === "on"; | ||
config.enableCategoryIcon = enableCategoryIcon === "on"; | ||
config.enableShowUserAllGroupsInProfile = enableShowUserAllGroupsInProfile === "on"; | ||
config.enableShowIpInUserProfile = enableShowIpInUserProfile === "on"; | ||
config.enableDarkmodeIsDefault = enableDarkmodeIsDefault === "on"; | ||
config.hideSubCategories = settings.hideSubCategories === "on"; | ||
config.hideCategoryLastPost = settings.hideCategoryLastPost === "on"; | ||
config.enableQuickReply = settings.enableQuickReply === "on"; | ||
config.enableShowTid = settings.enableShowTid === "on"; | ||
config.enableCategoryIcon = settings.enableCategoryIcon === "on"; | ||
config.enableShowUserAllGroupsInProfile = settings.enableShowUserAllGroupsInProfile === "on"; | ||
config.enableShowIpInUserProfile = settings.enableShowIpInUserProfile === "on"; | ||
config.enableDarkmodeIsDefault = settings.enableDarkmodeIsDefault === "on"; | ||
}); | ||
@@ -120,15 +109,5 @@ | ||
library.addUserToTopic = (data, callback) => { | ||
const { | ||
req: { user: reqUser = {} }, | ||
} = data; | ||
const { user: reqUser } = data.req; | ||
if (reqUser) { | ||
user.getUserData(reqUser.uid, (err, userdata) => { | ||
if (err) return callback(err); | ||
data.templateData.loggedInUser = userdata; | ||
callback(null, data); | ||
}); | ||
} else { | ||
if (!reqUser) { | ||
data.templateData.loggedInUser = { | ||
@@ -142,6 +121,14 @@ uid: 0, | ||
return callback(null, data); | ||
} | ||
user.getUserData(reqUser.uid, (err, userdata) => { | ||
if (err) return callback(err); | ||
data.templateData.loggedInUser = userdata; | ||
callback(null, data); | ||
} | ||
}); | ||
}; | ||
module.exports = library; |
{ | ||
"name": "nodebb-theme-oxide", | ||
"version": "5.0.42", | ||
"description": "A theme that is based on the GitHub design.", | ||
"version": "5.0.41", | ||
"homepage": "https://github.com/youhosi/nodebb-theme-oxide", | ||
"license": "MIT", | ||
"main": "theme.less", | ||
"contributors": [ | ||
{ | ||
"name": "Sebastian Sycz", | ||
"email": "sebastiansycz99@icloud.com", | ||
"url": "https://github.com/youhosi" | ||
} | ||
], | ||
"keywords": [ | ||
@@ -23,4 +13,5 @@ "nodebb", | ||
], | ||
"nbbpm": { | ||
"compatibility": "^1.13.1" | ||
"homepage": "https://github.com/youhosi/nodebb-theme-oxide", | ||
"bugs": { | ||
"url": "https://github.com/youhosi/nodebb-theme-oxide/issues" | ||
}, | ||
@@ -31,16 +22,11 @@ "repository": { | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/youhosi/nodebb-theme-oxide/issues" | ||
}, | ||
"dependencies": { | ||
"pulling": "^2.0.0", | ||
"striptags": "^3.1.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.6.0", | ||
"eslint-config-prettier": "^6.7.0", | ||
"husky": "^3.1.0", | ||
"lint-staged": "^9.4.3", | ||
"prettier": "^1.19.1" | ||
}, | ||
"license": "MIT", | ||
"contributors": [ | ||
{ | ||
"name": "Sebastian Sycz", | ||
"email": "sebastiansycz99@icloud.com", | ||
"url": "https://github.com/youhosi" | ||
} | ||
], | ||
"main": "theme.less", | ||
"husky": { | ||
@@ -57,3 +43,17 @@ "hooks": { | ||
] | ||
}, | ||
"dependencies": { | ||
"pulling": "^2.0.0", | ||
"striptags": "^3.1.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.6.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"husky": "^4.2.2", | ||
"lint-staged": "^10.0.7", | ||
"prettier": "^1.19.1" | ||
}, | ||
"nbbpm": { | ||
"compatibility": "^1.13.1" | ||
} | ||
} |
2509180
2927