Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
perf(js/nav_active): Active nav status frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Jul 19, 2019
1 parent 10be2f8 commit c327d0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
13 changes: 13 additions & 0 deletions apps/public/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ jQuery(document).ready(function () {
}
});

// Active Nav `active` class by location.pathname
if ($('nav#nav').length) {
let pathname_split = window.location.pathname.split('/');
for (let i = pathname_split.length; i > 0; i--) {
let test_pathname = pathname_split.slice(0, i).join('/');
let test_nav_li = $(`nav#nav li > a[href="${test_pathname}"]`);
if (test_nav_li.length) {
test_nav_li.parent('li').addClass('active');
break;
}
}
}

// Captcha Img Re-flush
let captcha_img_another = $('.captcha_img');
captcha_img_another.on('click', function () {
Expand Down
24 changes: 12 additions & 12 deletions apps/views/layout/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@
<div class="container">
<div class="collapse navbar-collapse navbar-collapse-custom">
<ul class="nav navbar-nav nav-justified">
<li<?= $this->uri('/index', ' class="active"') ?>><a href="/"><?= __('nav_index') ?></a></li>
<li<?= $this->uri('/forums', ' class="active"'); ?>><a href="/forums"><?= __('nav_forums') ?></a></li> <!-- TODO -->
<li<?= $this->uri('/collections', ' class="active"'); ?>><a href="/collections"><?= __('nav_collections') ?></a></li> <!-- TODO -->
<li<?= $this->uri('/torrents', ' class="active"'); ?>><a href="/torrents"><?= __('nav_torrents') ?></a></li>
<li<?= $this->uri('/torrent/upload', ' class="active"'); ?>><a href="/torrent/upload"><?= __('nav_upload') ?></a></li>
<li<?= $this->uri('/torrents/request', ' class="active"'); ?>><a href="/torrents/request"><?= __('nav_requests') ?></a></li> <!-- TODO -->
<li<?= $this->uri('/subtitles', ' class="active"'); ?>><a href="/subtitles"><?= __('nav_subtitles') ?></a></li> <!-- TODO -->
<li<?= $this->uri('/site/rules', ' class="active"'); ?>><a href="/site/rules"><?= __('nav_rules') ?></a></li> <!-- TODO -->
<li<?= $this->uri('/site/staff', ' class="active"'); ?>><a href="/site/staff"><?= __('nav_staff') ?></a></li> <!-- TODO -->
<li><a href="/"><?= __('nav_index') ?></a></li>
<li><a href="/forums"><?= __('nav_forums') ?></a></li> <!-- TODO -->
<li><a href="/collections"><?= __('nav_collections') ?></a></li> <!-- TODO -->
<li><a href="/torrents"><?= __('nav_torrents') ?></a></li>
<li><a href="/torrent/upload"><?= __('nav_upload') ?></a></li>
<li><a href="/torrents/request"><?= __('nav_requests') ?></a></li> <!-- TODO -->
<li><a href="/subtitles"><?= __('nav_subtitles') ?></a></li> <!-- TODO -->
<li><a href="/site/rules"><?= __('nav_rules') ?></a></li> <!-- TODO -->
<li><a href="/site/staff"><?= __('nav_staff') ?></a></li> <!-- TODO -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?= __('nav_more') ?> <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu"><!-- FIXME class="active" in dropdown-munu -->
<li<?= $this->uri('/site/topten', ' class="active"'); ?>><a href="/site/topten"><?= __('nav_topten') ?></a></li> <!-- TODO -->
<li><a href="/site/topten"><?= __('nav_topten') ?></a></li> <!-- TODO -->
<li class="divider"></li>
<li<?= $this->uri('/site/stats', ' class="active"'); ?>><a href="/site/stats"><?= __('nav_stats') ?></a></li> <!-- TODO -->
<li<?= $this->uri('/site/log', ' class="active"'); ?>><a href="/site/log"><?= __('nav_log') ?></a></li> <!-- TODO -->
<li><a href="/site/stats"><?= __('nav_stats') ?></a></li> <!-- TODO -->
<li><a href="/site/log"><?= __('nav_log') ?></a></li> <!-- TODO -->
</ul>
</li>
</ul> <!-- END .navbar-nav -->
Expand Down

0 comments on commit c327d0e

Please sign in to comment.