Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added lhn-backbutton #44753

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[commit]
gpgsign = true
[user]
email = [email protected]
name = Rasheed Mudasiru
signingkey = 30C8087C891F6D07
[gpg]
Taiwrash marked this conversation as resolved.
Show resolved Hide resolved
program = gpg
3 changes: 3 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ GEM
racc (~> 1.4)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
Taiwrash marked this conversation as resolved.
Show resolved Hide resolved
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
Expand Down Expand Up @@ -259,6 +261,7 @@ PLATFORMS
arm64-darwin-23
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux
Taiwrash marked this conversation as resolved.
Show resolved Hide resolved

DEPENDENCIES
github-pages
Expand Down
54 changes: 35 additions & 19 deletions docs/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,41 @@ function isInRange(num, min, max) {
* If a page is directly accessed (e.g., via deep link, bookmark, or opened in a new tab),the user will be navigated
* back to the relevant hub page of that article.
*/
let newPath;
Taiwrash marked this conversation as resolved.
Show resolved Hide resolved
function navigateBack() {
const currentHost = window.location.host;
const referrer = document.referrer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Taiwrash do you know why this code was removed?


if (referrer.includes(currentHost) && window.history.length > 1) {
window.history.back();
return;
}

// Path name is of the form /articles/[platform]/[hub]/[resource]
const path = window.location.pathname.split('/');
if (path[2] && path[3]) {
window.location.href = `/${path[2]}/hubs/${path[3]}`;
const currentPath = window.location.pathname;
const pathSegments = currentPath.split('/');

// Check if we're in an article page
if (pathSegments.length >= 5 && pathSegments[1] === 'articles') {
// Extract the product (new-expensify or expensify-classic) and the hub
const product = pathSegments[2];
const hub = pathSegments[3];

// Construct the path to the hub page
newPath = `/${product}/hubs/${hub}/`;
} else if (pathSegments.length > 4 && (pathSegments[2] === 'new-expensify' || pathSegments[2] === 'expensify-classic')) {
// This is the existing logic for other cases
newPath = `/${pathSegments[2]}/hubs/${pathSegments[3]}/`;
} else {
window.location.href = '/';
// If we're not in an article or a recognizable path, go to the home page
newPath = '/';
}

// Add a little delay to avoid showing the previous content in a fraction of a time
setTimeout(toggleHeaderMenu, 250);
if (newPath !== currentPath) {
window.location.href = newPath;

// Add a little delay to avoid showing the previous content in a fraction of a time
setTimeout(toggleHeaderMenu, 250);
}
}

// Add an event listener for the popstate event
Taiwrash marked this conversation as resolved.
Show resolved Hide resolved
window.addEventListener('popstate', (e)=>{
e.preventDefault()
navigateBack()
});

function injectFooterCopywrite() {
const footer = document.getElementById('footer-copywrite-date');
footer.innerHTML = `&copy;2008-${new Date().getFullYear()} Expensify, Inc.`;
Expand Down Expand Up @@ -272,11 +286,13 @@ window.addEventListener('DOMContentLoaded', () => {
});

document.getElementById('header-button').addEventListener('click', toggleHeaderMenu);

// Back button doesn't exist on all the pages

const backButton = document.getElementById('back-button');
if (backButton) {
backButton.addEventListener('click', navigateBack);
backButton.addEventListener('click', function(event) {
event.preventDefault();
navigateBack();
});
}

const articleContent = document.getElementById('article-content');
Expand Down Expand Up @@ -309,4 +325,4 @@ window.addEventListener('DOMContentLoaded', () => {
// Count property of y-axis to keep scroll position & reference it later for making the body fixed when sidebar opened
document.documentElement.style.setProperty('y-axis', `${window.scrollY}px`);
});
});
});
Taiwrash marked this conversation as resolved.
Show resolved Hide resolved
Taiwrash marked this conversation as resolved.
Show resolved Hide resolved
Loading