Header becomes less bloated in favor of tabs
This commit is contained in:
parent
be919603e3
commit
b3f15dc049
5 changed files with 49 additions and 13 deletions
|
@ -15,13 +15,17 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
form.aligned {
|
form.aligned {
|
||||||
|
margin: 0 auto;
|
||||||
width: 24em;
|
width: 24em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin: 0 auto;
|
|
||||||
}
|
}
|
||||||
form.aligned label.left {
|
form.aligned label.left {
|
||||||
width: 7em;
|
width: 7em;
|
||||||
}
|
}
|
||||||
form h1 {
|
form h1 {
|
||||||
text-align: center;
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.mass-tag {
|
||||||
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,9 @@ class PostController
|
||||||
{
|
{
|
||||||
$this->context->stylesheets []= 'post-small.css';
|
$this->context->stylesheets []= 'post-small.css';
|
||||||
$this->context->stylesheets []= 'post-list.css';
|
$this->context->stylesheets []= 'post-list.css';
|
||||||
|
$this->context->stylesheets []= 'tabs.css';
|
||||||
$this->context->stylesheets []= 'paginator.css';
|
$this->context->stylesheets []= 'paginator.css';
|
||||||
|
$this->context->viewName = 'post-list-wrapper';
|
||||||
if ($this->context->user->hasEnabledEndlessScrolling())
|
if ($this->context->user->hasEnabledEndlessScrolling())
|
||||||
$this->context->scripts []= 'paginator-endless.js';
|
$this->context->scripts []= 'paginator-endless.js';
|
||||||
if ($source == 'mass-tag')
|
if ($source == 'mass-tag')
|
||||||
|
@ -150,7 +152,6 @@ class PostController
|
||||||
public function favoritesAction($page = 1)
|
public function favoritesAction($page = 1)
|
||||||
{
|
{
|
||||||
$this->listAction('favmin:1', $page);
|
$this->listAction('favmin:1', $page);
|
||||||
$this->context->viewName = 'post-list';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,7 +164,6 @@ class PostController
|
||||||
public function randomAction($page = 1)
|
public function randomAction($page = 1)
|
||||||
{
|
{
|
||||||
$this->listAction('order:random', $page);
|
$this->listAction('order:random', $page);
|
||||||
$this->context->viewName = 'post-list';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,14 @@ class TextHelper
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function humanCaseToKebabCase($string)
|
||||||
|
{
|
||||||
|
$string = trim($string);
|
||||||
|
$string = str_replace(' ', '-', $string);
|
||||||
|
$string = strtolower($string);
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
public static function resolveConstant($constantName, $className = null)
|
public static function resolveConstant($constantName, $className = null)
|
||||||
{
|
{
|
||||||
$constantName = self::kebabCaseToCamelCase($constantName);
|
$constantName = self::kebabCaseToCamelCase($constantName);
|
||||||
|
|
|
@ -27,12 +27,6 @@
|
||||||
if (PrivilegesHelper::confirm(Privilege::ListPosts))
|
if (PrivilegesHelper::confirm(Privilege::ListPosts))
|
||||||
$nav []= ['Browse', \Chibi\UrlHelper::route('post', 'list')];
|
$nav []= ['Browse', \Chibi\UrlHelper::route('post', 'list')];
|
||||||
|
|
||||||
if (PrivilegesHelper::confirm(Privilege::ListPosts))
|
|
||||||
$nav []= ['Random', \Chibi\UrlHelper::route('post', 'random')];
|
|
||||||
|
|
||||||
if (PrivilegesHelper::confirm(Privilege::ListPosts))
|
|
||||||
$nav []= ['Favorites', \Chibi\UrlHelper::route('post', 'favorites')];
|
|
||||||
|
|
||||||
if (PrivilegesHelper::confirm(Privilege::UploadPost))
|
if (PrivilegesHelper::confirm(Privilege::UploadPost))
|
||||||
$nav []= ['Upload', \Chibi\UrlHelper::route('post', 'upload')];
|
$nav []= ['Upload', \Chibi\UrlHelper::route('post', 'upload')];
|
||||||
|
|
||||||
|
@ -42,9 +36,6 @@
|
||||||
if (PrivilegesHelper::confirm(Privilege::ListTags))
|
if (PrivilegesHelper::confirm(Privilege::ListTags))
|
||||||
$nav []= ['Tags', \Chibi\UrlHelper::route('tag', 'list')];
|
$nav []= ['Tags', \Chibi\UrlHelper::route('tag', 'list')];
|
||||||
|
|
||||||
if (PrivilegesHelper::confirm(Privilege::MassTag))
|
|
||||||
$nav []= ['Mass tag', \Chibi\UrlHelper::route('post', 'list', ['query' => isset($this->context->transport->searchQuery) ? htmlspecialchars($this->context->transport->searchQuery) : '', 'source' => 'mass-tag'])];
|
|
||||||
|
|
||||||
if (PrivilegesHelper::confirm(Privilege::ListUsers))
|
if (PrivilegesHelper::confirm(Privilege::ListUsers))
|
||||||
$nav []= ['Users', \Chibi\UrlHelper::route('user', 'list')];
|
$nav []= ['Users', \Chibi\UrlHelper::route('user', 'list')];
|
||||||
|
|
||||||
|
|
33
src/Views/post-list-wrapper.phtml
Normal file
33
src/Views/post-list-wrapper.phtml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
$tabs = [];
|
||||||
|
if (PrivilegesHelper::confirm(Privilege::ListPosts)) $tabs []= ['All posts', \Chibi\UrlHelper::route('post', 'list')];
|
||||||
|
if (PrivilegesHelper::confirm(Privilege::ListPosts)) $tabs []= ['Random', \Chibi\UrlHelper::route('post', 'random')];
|
||||||
|
if (PrivilegesHelper::confirm(Privilege::ListPosts)) $tabs []= ['Favorites', \Chibi\UrlHelper::route('post', 'favorites')];
|
||||||
|
if (PrivilegesHelper::confirm(Privilege::MassTag)) $tabs []= ['Mass tag', \Chibi\UrlHelper::route('post', 'list', ['query' => isset($this->context->transport->searchQuery) ? htmlspecialchars($this->context->transport->searchQuery) : '', 'source' => 'mass-tag', 'page' => $this->context->transport->paginator->page])];
|
||||||
|
|
||||||
|
$activeTab = 0;
|
||||||
|
if ($this->context->route->simpleActionName == 'random') $activeTab = 1;
|
||||||
|
if ($this->context->route->simpleActionName == 'favorites') $activeTab = 2;
|
||||||
|
if ($this->context->source == 'mass-tag') $activeTab = 3;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="tabs">
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($tabs as $i => $tab): ?>
|
||||||
|
<?php list($name, $url) = $tab ?>
|
||||||
|
<?php if ($i == $activeTab): ?>
|
||||||
|
<li class="selected <?php echo TextHelper::humanCaseToKebabCase($name) ?>">
|
||||||
|
<?php else: ?>
|
||||||
|
<li class="<?php echo TextHelper::humanCaseToKebabCase($name) ?>">
|
||||||
|
<?php endif ?>
|
||||||
|
<a href="<?php echo $url ?>">
|
||||||
|
<?php echo $name ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php $this->renderFile('post-list') ?>
|
Loading…
Reference in a new issue