Optimalization: simplified tabs structure

This commit is contained in:
Marcin Kurczewski 2013-11-30 00:03:59 +01:00
parent e4b4c5d273
commit 5e58488f3e
10 changed files with 140 additions and 126 deletions

View file

@ -322,6 +322,38 @@ button:hover {
.tabs ul {
list-style-type: none;
margin: -4px 0 1em 0;
padding: 0;
border-bottom: 1px solid #ccc;
}
.tabs li {
display: inline-block;
}
.tabs li a {
display: inline-block;
padding: 0.5em 1em;
margin: 5px 0 -1px 0;
vertical-align: middle;
border: 1px none;
border-bottom: 1px solid #ccc;
color: silver;
}
.tabs li.selected a {
border: 1px solid #ccc;
border-bottom: none;
color: inherit;
background: white;
}
.tabs li a:focus {
color: firebrick;
}
.alert {
text-align: center;
padding: 10px;

View file

@ -34,7 +34,6 @@ class IndexController
throw new SimpleException('Invalid tab');
$this->context->path = TextHelper::absolutePath($this->config->help->paths[$tab]);
$this->context->stylesheets []= 'index-help.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->subTitle = 'help';
$this->context->tab = $tab;
}

View file

@ -69,7 +69,6 @@ class PostController
$this->context->viewName = 'post-list-wrapper';
$this->context->stylesheets []= 'post-small.css';
$this->context->stylesheets []= 'post-list.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->stylesheets []= 'paginator.css';
$this->context->scripts []= 'post-list.js';
if ($this->context->user->hasEnabledEndlessScrolling())
@ -189,7 +188,6 @@ class PostController
public function uploadAction()
{
$this->context->stylesheets []= 'upload.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->scripts []= 'upload.js';
$this->context->subTitle = 'upload';
PrivilegesHelper::confirmWithException(Privilege::UploadPost);

View file

@ -9,7 +9,6 @@ class TagController
public function listAction($filter = null)
{
$this->context->stylesheets []= 'tag-list.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->subTitle = 'tags';
$this->context->viewName = 'tag-list-wrapper';
@ -34,7 +33,6 @@ class TagController
public function mergeAction()
{
$this->context->stylesheets []= 'tag-list.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->subTitle = 'tags';
$this->context->viewName = 'tag-list-wrapper';
@ -78,7 +76,6 @@ class TagController
public function renameAction()
{
$this->context->stylesheets []= 'tag-list.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->subTitle = 'tags';
$this->context->viewName = 'tag-list-wrapper';
@ -113,7 +110,6 @@ class TagController
public function massTagRedirectAction()
{
$this->context->stylesheets []= 'tag-list.css';
$this->context->stylesheets []= 'tabs.css';
$this->context->subTitle = 'tags';
$this->context->viewName = 'tag-list-wrapper';

View file

@ -8,7 +8,6 @@ class UserController
$this->context->transport->user = $user;
$this->context->handleExceptions = true;
$this->context->viewName = 'user-view';
$this->context->stylesheets []= 'tabs.css';
$this->context->stylesheets []= 'user-view.css';
$this->context->subTitle = $user->name;
}

View file

@ -4,23 +4,21 @@ $firstTab = !empty($tabs) ? array_keys($tabs)[0] : null;
?>
<?php if (count($tabs) > 1): ?>
<div class="tabs">
<nav>
<ul>
<?php foreach ($tabs as $tab => $text): ?>
<?php if ($tab == $this->context->tab): ?>
<li class="selected <?php echo $tab ?>">
<?php else: ?>
<li class="<?php echo $tab ?>">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('index', 'help', $tab == $firstTab ? [] : ['tab' => $tab]) ?>">
<?php echo $text ?>
</a>
</li>
<?php endforeach ?>
</ul>
</nav>
</div>
<nav class="tabs">
<ul>
<?php foreach ($tabs as $tab => $text): ?>
<?php if ($tab == $this->context->tab): ?>
<li class="selected <?php echo $tab ?>">
<?php else: ?>
<li class="<?php echo $tab ?>">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('index', 'help', $tab == $firstTab ? [] : ['tab' => $tab]) ?>">
<?php echo $text ?>
</a>
</li>
<?php endforeach ?>
</ul>
</nav>
<?php endif ?>
<?php echo TextHelper::parseMarkdown(file_get_contents($this->context->path)) ?>

View file

@ -11,23 +11,21 @@ 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>
<nav class="tabs">
<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>
<?php $this->renderFile('post-list') ?>

View file

@ -10,23 +10,21 @@
<div id="inner-content">
<div id="upload-step1">
<div class="tabs">
<nav>
<ul>
<li class="selected file">
<a href="#">
Upload from file
</a>
</li>
<nav class="tabs">
<ul>
<li class="selected file">
<a href="#">
Upload from file
</a>
</li>
<li class="url">
<a href="#">
Upload from URL
</a>
</li>
</ul>
</nav>
</div>
<li class="url">
<a href="#">
Upload from URL
</a>
</li>
</ul>
</nav>
<div class="tab file">
<input type=file multiple style="display: none"/>

View file

@ -5,23 +5,21 @@
<?php if (PrivilegesHelper::confirm(Privilege::MassTag)) $tabs['mass-tag-redirect'] = 'Mass tag'; ?>
<?php if (count(array_diff($tabs, ['list'])) > 1): ?>
<div class="tabs">
<nav>
<ul>
<?php foreach ($tabs as $tab => $name): ?>
<?php if ($this->context->route->simpleActionName == $tab): ?>
<li class="selected <?php echo $tab ?>">
<?php else: ?>
<li class="<?php echo $tab ?>">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('tag', $tab) ?>">
<?php echo $name ?>
</a>
</li>
<?php endforeach ?>
</ul>
</nav>
</div>
<nav class="tabs">
<ul>
<?php foreach ($tabs as $tab => $name): ?>
<?php if ($this->context->route->simpleActionName == $tab): ?>
<li class="selected <?php echo $tab ?>">
<?php else: ?>
<li class="<?php echo $tab ?>">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('tag', $tab) ?>">
<?php echo $name ?>
</a>
</li>
<?php endforeach ?>
</ul>
</nav>
<?php endif ?>
<?php if ($this->context->route->simpleActionName == 'merge'): ?>

View file

@ -112,67 +112,65 @@
</div>
<div id="inner-content">
<div class="tabs">
<nav>
<ul>
<?php if ($this->context->transport->tab == 'favs'): ?>
<li class="selected favs">
<nav class="tabs">
<ul>
<?php if ($this->context->transport->tab == 'favs'): ?>
<li class="selected favs">
<?php else: ?>
<li class="favs">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->user->name, 'tab' => 'favs', 'page' => 1]) ?>">
Favs
</a>
</li>
<?php if ($this->context->transport->tab == 'uploads'): ?>
<li class="selected uploads">
<?php else: ?>
<li class="uploads">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->user->name, 'tab' => 'uploads', 'page' => 1]) ?>">
Uploads
</a>
</li>
<?php if (PrivilegesHelper::confirm(Privilege::ChangeUserSettings, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
<?php if ($this->context->transport->tab == 'settings'): ?>
<li class="selected settings">
<?php else: ?>
<li class="favs">
<li class="settings">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->user->name, 'tab' => 'favs', 'page' => 1]) ?>">
Favs
<a href="<?php echo \Chibi\UrlHelper::route('user', 'settings', ['name' => $this->context->transport->user->name]) ?>">
Browsing settings
</a>
</li>
<?php endif ?>
<?php if ($this->context->transport->tab == 'uploads'): ?>
<li class="selected uploads">
<?php if ($canModifyAnything): ?>
<?php if ($this->context->transport->tab == 'edit'): ?>
<li class="selected edit">
<?php else: ?>
<li class="uploads">
<li class="edit">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->user->name, 'tab' => 'uploads', 'page' => 1]) ?>">
Uploads
<a href="<?php echo \Chibi\UrlHelper::route('user', 'edit', ['name' => $this->context->transport->user->name]) ?>">
Account settings
</a>
</li>
<?php endif ?>
<?php if (PrivilegesHelper::confirm(Privilege::ChangeUserSettings, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
<?php if ($this->context->transport->tab == 'settings'): ?>
<li class="selected settings">
<?php else: ?>
<li class="settings">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'settings', ['name' => $this->context->transport->user->name]) ?>">
Browsing settings
</a>
</li>
<?php if (PrivilegesHelper::confirm(Privilege::DeleteUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
<?php if ($this->context->transport->tab == 'delete'): ?>
<li class="selected delete">
<?php else: ?>
<li class="delete">
<?php endif ?>
<?php if ($canModifyAnything): ?>
<?php if ($this->context->transport->tab == 'edit'): ?>
<li class="selected edit">
<?php else: ?>
<li class="edit">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'edit', ['name' => $this->context->transport->user->name]) ?>">
Account settings
</a>
</li>
<?php endif ?>
<?php if (PrivilegesHelper::confirm(Privilege::DeleteUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
<?php if ($this->context->transport->tab == 'delete'): ?>
<li class="selected delete">
<?php else: ?>
<li class="delete">
<?php endif ?>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'delete', ['name' => $this->context->transport->user->name]) ?>">
Delete account
</a>
</li>
<?php endif ?>
</ul>
</nav>
</div>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'delete', ['name' => $this->context->transport->user->name]) ?>">
Delete account
</a>
</li>
<?php endif ?>
</ul>
</nav>
<?php if (isset($this->context->transport->posts)): ?>
<?php $this->renderFile('post-list') ?>