Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
26 changes: 14 additions & 12 deletions extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ class EnhancedNavigationExtension extends Minz_Extension {
public function init(): void {
$this->registerTranslates();

if (version_compare(FRESHRSS_VERSION, '1.28') >= 0) {
$this->registerHook(Minz_HookType::NavEntries, [$this, 'generateEnhancedNavigation']);
} else {
$this->registerHook('nav_entries', [$this, 'generateEnhancedNavigation']);
}
// Use string hook name for compatibility with all versions
$this->registerHook('nav_entries', [$this, 'generateEnhancedNavigation']);

Minz_View::appendStyle($this->getFileUrl('navigation.css', 'css'));
Minz_View::appendScript($this->getFileUrl('navigation.js', 'js'));
Expand Down Expand Up @@ -53,15 +50,20 @@ private function computeButtonWidth(): int {
}

public function generateEnhancedNavigation(): string {
return <<<NAV
<nav id="nav_entries_enhanced">
$html = <<<NAV
<nav id="nav_entries_enhanced" style="background-color: #ff000020; border-top: 2px solid red;">
{$this->generatePreviousEntryButton()}
{$this->generateSeeOnWebsiteButton()}
{$this->generateUpButton()}
{$this->generateFavoriteButton()}
{$this->generateNextEntryButton()}
</nav>
NAV;

// Debug: log to FreshRSS error log
error_log("EnhancedNavigation: Generated HTML: " . $html);

return $html;
}

private function generateButton(string $class, string $title, string $icon): string {
Expand Down Expand Up @@ -112,22 +114,22 @@ private function generateNextEntryButton(): string {
}

public function showPreviousEntryButton(): bool {
return $this->getUserConfigurationValue('show_previous_entry_button');
return (bool) ($this->getUserConfigurationValue('show_previous_entry_button') ?? true);
}

public function showSeeOnWebSiteButton(): bool {
return $this->getUserConfigurationValue('show_see_on_website_button');
return (bool) ($this->getUserConfigurationValue('show_see_on_website_button') ?? true);
}

public function showUpButton(): bool {
return $this->getUserConfigurationValue('show_up_button');
return (bool) ($this->getUserConfigurationValue('show_up_button') ?? true);
}

public function showFavoriteButton(): bool {
return $this->getUserConfigurationValue('show_favorite_button');
return (bool) ($this->getUserConfigurationValue('show_favorite_button') ?? true);
}

public function showNextEntryButton(): bool {
return $this->getUserConfigurationValue('show_next_entry_button');
return (bool) ($this->getUserConfigurationValue('show_next_entry_button') ?? true);
}
}
22 changes: 20 additions & 2 deletions static/navigation.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nav_entries {
display: none;
#nav_entries, /* Hide original desktop navigation */
#nav_entries_mobile /* Hide original mobile navigation if it exists */ {
display: none !important;
}

#nav_entries_enhanced {
Expand Down Expand Up @@ -39,4 +40,21 @@
#nav_entries_enhanced {
width: 100%;
}

#nav_entries_enhanced button {
font-size: 0.9rem;
padding: 0 0.3rem;
min-width: 0; /* Allow buttons to shrink */
overflow: hidden; /* Prevent content overflow */
white-space: nowrap; /* Prevent text wrapping */
}

/* Ensure buttons take equal space and don't disappear */
#nav_entries_enhanced {
table-layout: fixed;
}

#nav_entries_enhanced button {
width: 1%; /* Distribute space equally */
}
}
85 changes: 55 additions & 30 deletions static/navigation.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,61 @@
function init_nav_entries_enhanced() {
console.log('EnhancedNavigation: Initializing...');
const nav_entries = document.getElementById('nav_entries_enhanced');
if (!nav_entries) {
console.log('EnhancedNavigation: nav_entries_enhanced element not found');
} else {
console.log('EnhancedNavigation: nav_entries_enhanced element found');
}
if (nav_entries) {
nav_entries.querySelector('.previous_entry').onclick = function (e) {
prev_entry(false);
return false;
};
nav_entries.querySelector('.next_entry').onclick = function (e) {
next_entry(false);
return false;
};
nav_entries.querySelector('.up').onclick = function (e) {
const active_item = (document.querySelector('.flux.current') || document.querySelector('.flux'));
const windowTop = document.scrollingElement.scrollTop;
const item_top = active_item.offsetParent.offsetTop + active_item.offsetTop;
const nav_menu = document.querySelector('.nav_menu');
let nav_menu_height = 0;
if (getComputedStyle(nav_menu).position === 'fixed' || getComputedStyle(nav_menu).position === 'sticky') {
nav_menu_height = nav_menu.offsetHeight;
}
document.scrollingElement.scrollTop = windowTop > item_top ? item_top - nav_menu_height : 0 - nav_menu_height;
return false;
};
nav_entries.querySelector('.favorite').onclick = function (e) {
const active_item = (document.querySelector('.flux.current') || document.querySelector('.flux'));
mark_favorite(active_item);
return false;
};
nav_entries.querySelector('.link').onclick = function (e) {
const active_item = (document.querySelector('.flux.current') || document.querySelector('.flux'));
window.open(active_item.dataset.link, '_blank');
return false;
};
const previousBtn = nav_entries.querySelector('.previous_entry');
if (previousBtn) {
previousBtn.onclick = function (e) {
prev_entry(false);
return false;
};
}

const nextBtn = nav_entries.querySelector('.next_entry');
if (nextBtn) {
nextBtn.onclick = function (e) {
next_entry(false);
return false;
};
}

const upBtn = nav_entries.querySelector('.up');
if (upBtn) {
upBtn.onclick = function (e) {
const active_item = (document.querySelector('.flux.current') || document.querySelector('.flux'));
const windowTop = document.scrollingElement.scrollTop;
const item_top = active_item.offsetParent.offsetTop + active_item.offsetTop;
const nav_menu = document.querySelector('.nav_menu');
let nav_menu_height = 0;
if (getComputedStyle(nav_menu).position === 'fixed' || getComputedStyle(nav_menu).position === 'sticky') {
nav_menu_height = nav_menu.offsetHeight;
}
document.scrollingElement.scrollTop = windowTop > item_top ? item_top - nav_menu_height : 0 - nav_menu_height;
return false;
};
}

const favoriteBtn = nav_entries.querySelector('.favorite');
if (favoriteBtn) {
favoriteBtn.onclick = function (e) {
const active_item = (document.querySelector('.flux.current') || document.querySelector('.flux'));
mark_favorite(active_item);
return false;
};
}

const linkBtn = nav_entries.querySelector('.link');
if (linkBtn) {
linkBtn.onclick = function (e) {
const active_item = (document.querySelector('.flux.current') || document.querySelector('.flux'));
window.open(active_item.dataset.link, '_blank');
return false;
};
}
}
}

Expand Down