Header becomes less bloated in favor of tabs

This commit is contained in:
Marcin Kurczewski 2013-11-01 12:48:02 +01:00
parent be919603e3
commit b3f15dc049
5 changed files with 49 additions and 13 deletions

View file

@ -15,13 +15,17 @@
width: 100%;
}
form.aligned {
margin: 0 auto;
width: 24em;
text-align: left;
margin: 0 auto;
}
form.aligned label.left {
width: 7em;
}
form h1 {
text-align: center;
display: none;
}
li.mass-tag {
float: right;
}

View file

@ -63,7 +63,9 @@ class PostController
{
$this->context->stylesheets []= 'post-small.css';
$this->context->stylesheets []= 'post-list.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->stylesheets []= 'paginator.css';
$this->context->viewName = 'post-list-wrapper';
if ($this->context->user->hasEnabledEndlessScrolling())
$this->context->scripts []= 'paginator-endless.js';
if ($source == 'mass-tag')
@ -150,7 +152,6 @@ class PostController
public function favoritesAction($page = 1)
{
$this->listAction('favmin:1', $page);
$this->context->viewName = 'post-list';
}
@ -163,7 +164,6 @@ class PostController
public function randomAction($page = 1)
{
$this->listAction('order:random', $page);
$this->context->viewName = 'post-list';
}

View file

@ -48,6 +48,14 @@ class TextHelper
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)
{
$constantName = self::kebabCaseToCamelCase($constantName);

View file

@ -27,12 +27,6 @@
if (PrivilegesHelper::confirm(Privilege::ListPosts))
$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))
$nav []= ['Upload', \Chibi\UrlHelper::route('post', 'upload')];
@ -42,9 +36,6 @@
if (PrivilegesHelper::confirm(Privilege::ListTags))
$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))
$nav []= ['Users', \Chibi\UrlHelper::route('user', 'list')];

View 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') ?>