Skip to content

Commit

Permalink
Revisit the header/news area moving things around a bit according to e…
Browse files Browse the repository at this point in the history
…lkarte#710

Signed-off-by: emanuele <emanuele45@gmail.com>
  • Loading branch information
emanuele45 committed Nov 12, 2013
1 parent a4453c6 commit 60b00b0
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 81 deletions.
20 changes: 7 additions & 13 deletions sources/Subs.php
Expand Up @@ -2719,7 +2719,7 @@ function determineTopicClass(&$topic_context)
*/
function setupThemeContext($forceload = false)
{
global $modSettings, $user_info, $scripturl, $context, $settings, $options, $txt, $maintenance;
global $modSettings, $user_info, $scripturl, $context, $settings, $options, $txt;
global $user_settings;

static $loaded = false;
Expand All @@ -2731,7 +2731,6 @@ function setupThemeContext($forceload = false)

$loaded = true;

$context['in_maintenance'] = !empty($maintenance);
$context['current_time'] = standardTime(time(), false);
$context['current_action'] = isset($_GET['action']) ? $_GET['action'] : '';
$context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest'];
Expand Down Expand Up @@ -3573,13 +3572,6 @@ function setupMenuContext()
// The main menu
$menu->addBulk(
array(
// The old "logout" is meh. Not a real word. "Log out" is better.
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
),

'home' => array(
'title' => $txt['community'],
'href' => $scripturl,
Expand Down Expand Up @@ -3801,6 +3793,12 @@ function setupMenuContext()
'href' => $scripturl . '?action=profile;area=theme',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_extra_any')),
),
// The old "logout" is meh. Not a real word. "Log out" is better.
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'],
'show' => !$user_info['is_guest'],
),
)
);

Expand Down Expand Up @@ -3870,10 +3868,6 @@ function setupMenuContext()
$context['menu_buttons'] = $menu_buttons;
$allMenus->destroy('Main_Menu');

// Logging out requires the session id in the url.
if (isset($context['menu_buttons']['logout']))
$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);

// Figure out which action we are doing so we can set the active tab.
// Default to home.
$current_action = 'home';
Expand Down
58 changes: 49 additions & 9 deletions themes/default/css/index.css
Expand Up @@ -846,8 +846,33 @@ div.bbc_footnotes {
margin: 0;
padding: 14px 8px 0 8px;
line-height: 1.3em;
min-width:38%;
position: relative;
min-height: 40px;
/* @todo - See me grumblez in Issue #552. ;) */
}
#top_section_notice .toggle_login {
position:absolute;
left: 0;
padding-top: 2px;
display: inline;
cursor: pointer;
}
#top_section_notice form {
white-space: nowrap;
width: 100%;
}
#top_section_notice .button_submit {
position: absolute;
right: 0;
}
#password_login, #openid_login {
display: inline-block;
margin-left: 50px;
}
#password_login input, #password_login select {
margin-left: -5px;
}
#search_form {
padding: 12px 0 4px 8px;
float: left;
Expand Down Expand Up @@ -892,9 +917,7 @@ div.bbc_footnotes {
}
/* The user info, news, etc.*/
#news {
display: table-cell;
vertical-align: top;
width: 90%;
}
#upper_section>.user {
display: table-cell;
Expand All @@ -903,7 +926,9 @@ div.bbc_footnotes {
font-size: 0.857em;
}
.greeting {
float: right;
font-weight: bold;
padding-top: 10px;
}
/* The login form. */
#guest_form {
Expand All @@ -914,16 +939,18 @@ div.bbc_footnotes {
margin: 0 4px 8px 0;
}
/* User information. @todo - Simplify. */
#upper_section .avatar {
float: left;
margin: 0 5px 5px 0;
#top_section_notice a.avatar {
float: right;
vertical-align: middle;
padding-right: 5px;
}
/* No more huge avatars up top. YAY! */
#upper_section .avatar img, .notifavatar .avatar {
#top_section_notice .avatar img, .notifavatar .avatar {
width: auto;
height: auto;
max-width: 60px;
max-height: 60px;
max-width: 36px;
max-height: 36px;
border-radius: 2px;
}
.modtask {
margin: 1em 0 0 0;
Expand Down Expand Up @@ -1002,7 +1029,7 @@ div.bbc_footnotes {
.listlevel1:hover {
z-index: 5;
}
.listlevel1#collapse_button, .listlevel1#button_logout {
.listlevel1#collapse_button, .listlevel1#button_profile {
float: right;
}
/* Level 1 Menu bar: link or button. */
Expand Down Expand Up @@ -1030,6 +1057,10 @@ div.bbc_footnotes {
.listlevel1:hover .menulevel2, .listlevel1.sfhover .menulevel2 {
left: 0;
}
.listlevel1#button_profile:hover .menulevel2, .listlevel1#button_profile.sfhover .menulevel2 {
left: auto;
right: 0px;
}
/* Hiding Level 3 drop menu off hover. */
.listlevel1:hover .menulevel3, .listlevel1.sfhover .menulevel3 {
left: -9999px;
Expand Down Expand Up @@ -4135,6 +4166,9 @@ a.help .icon {
.board_stats, .topic_stats {
display: none;
}
#password_login select {
display: none;
}
}
/* This one does 800 screens at default font size. */
@media screen and (min-width: 30em) and (max-width: 50em) {
Expand Down Expand Up @@ -4191,6 +4225,12 @@ a.help .icon {
display: block;
}
/* End playing silly buggers. */
#top_section_notice {
min-width: 250px;
}
#password_login select {
display: none;
}
}
/* This one does 480 screens at default font size. */
@media screen and (max-width: 30em) {
Expand Down
2 changes: 1 addition & 1 deletion themes/default/css/index_light.css
Expand Up @@ -206,7 +206,7 @@ sup.bbc_footnotes, sup.bbc_footnotes a {
}
/* News section. */
#news {
padding: 0 0 1em 1em;
padding: 0 1em 1em 1em;
font-size: 0.929em;
}
#news>h2 {
Expand Down
108 changes: 51 additions & 57 deletions themes/default/index.template.php
Expand Up @@ -205,29 +205,66 @@ function template_body_above()
// Skip nav link.
echo '
<div id="top_section">
<div class="wrapper">
<p id="top_section_notice">';
<div class="wrapper">';

// If the user is logged in, display the time, or a maintenance warning for admins.
// @todo - TBH I always intended the time/date to be more or less a place holder for more important things.
// The maintenance mode warning for admins is an obvious one, but this could also be used for moderation notifications.
// I also assumed this would be an obvious place for sites to put a string of icons to link to their FB, Twitter, etc.
// This could still be done via conditional, so that administration and moderation notices were still active when applicable.
if ($context['user']['is_logged'])

echo '
<div id="top_section_notice" class="user">';

// Show log in form to guests.
if (!empty($context['show_login_bar']))
{
// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="UTF-8" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>', !empty($modSettings['enableOpenID']) ? '
<img style="display: none" class="toggle_login" src="' . $settings['images_url'] . '/login.png" alt="' . $txt['toggle_password'] . '" title="' . $txt['toggle_openid'] . '" />' : '', '
<div id="password_login">
<input type="text" name="user" size="10" class="input_text" placeholder="', $txt['username'], '" />
<input type="password" name="passwrd" size="10" class="input_password" placeholder="', $txt['password'], '" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
</div>';

if (!empty($modSettings['enableOpenID']))
{
echo '
<span class="notice">', $txt['maintain_mode_on'], '</span>';
else
echo $context['current_time'];
}
// Otherwise they're a guest. Ask them to either register or login.
else
echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $scripturl . '?action=login');
<div id="openid_login">
<input type="text" name="openid_identifier" size="25" class="input_text openid_login" placeholder="', $txt['openid'], '" />
</div>
<script>
var toggle_openid = ', JavaScriptEscape($txt['toggle_openid']), ';
var toggle_password = ', JavaScriptEscape($txt['toggle_password']), ';
</script>';
}

echo '
<input type="submit" value="', $txt['login'], '" class="button_submit" />
<input type="hidden" name="hash_passwrd" value="" />
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
</form>';
}
// If the user is logged in, display stuff like their name, new messages, etc.
elseif ($context['user']['is_logged'])
{
echo '
<span class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></span>';
if (!empty($context['user']['avatar']))
echo '
<a href="', $scripturl, '?action=profile" class="avatar">', $context['user']['avatar']['image'], '</a>';
}
echo '
</p>';
</div>';

if ($context['allow_search'])
{
Expand Down Expand Up @@ -304,50 +341,7 @@ function template_body_above()
</div>
</div>
<div id="wrapper" class="wrapper">
<div id="upper_section"', empty($context['minmax_preferences']['upshrink']) ? '' : ' style="display: none;" aria-hidden="true"', '>
<div class="user">';

// Show log in form to guests.
if (!empty($context['show_login_bar']))
{
echo '
<script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form id="guest_form" action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="UTF-8" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>
<input type="text" name="user" size="10" class="input_text" placeholder="', $txt['username'], '" />
<input type="password" name="passwrd" size="10" class="input_password" placeholder="', $txt['password'], '" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
<input type="submit" value="', $txt['login'], '" class="button_submit" />
<div>', $txt['quick_login_dec'], '</div>';

if (!empty($modSettings['enableOpenID']))
echo '
<br /><input type="text" name="openid_identifier" size="25" class="input_text openid_login" placeholder="', $txt['openid'], '" />';

echo '
<input type="hidden" name="hash_passwrd" value="" />
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
</form>';
}

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
if (!empty($context['user']['avatar']))
echo '
<a href="', $scripturl, '?action=profile" class="avatar">', $context['user']['avatar']['image'], '</a>';
echo '
<span class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></span>';
}

echo '
</div>';
<div id="upper_section"', empty($context['minmax_preferences']['upshrink']) ? '' : ' style="display: none;" aria-hidden="true"', '>';

// Display either news fader and random news lines (not both). These now run most of the same mark up and CSS. Less complication = happier n00bz. :)
if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
Expand Down
3 changes: 3 additions & 0 deletions themes/default/languages/index.english.php
Expand Up @@ -847,6 +847,9 @@
$txt['spiders'] = 'Spiders';
$txt['openid'] = 'OpenID';

$txt['toggle_openid'] = 'Show OpenID';
$txt['toggle_password'] = 'Show Username/Password';

$txt['downloads'] = 'Downloads';
$txt['filesize'] = 'Filesize';
$txt['subscribe_webslice'] = 'Subscribe to Webslice';
Expand Down
20 changes: 19 additions & 1 deletion themes/default/scripts/theme.js
Expand Up @@ -63,9 +63,27 @@ $(document).ready(function() {
});

// Spoiler
$('.spoilerheader').click(function(){
$('.spoilerheader').click(function() {
$(this).next().children().slideToggle("fast");
});

$('#top_section_notice .toggle_login').css({display: ''}).click(function() {
if ($('#openid_login').is(':visible'))
{
$(this).attr('alt', toggle_openid).attr('title', toggle_openid);
$('#openid_login').animate({width: 'toggle'}, function() {
$('#password_login').animate({width: 'toggle'});
});
}
else
{
$(this).attr('alt', toggle_password).attr('title', toggle_password);
$('#password_login').animate({width: 'toggle'}, function() {
$('#openid_login').animate({width: 'toggle'});
});
}
});
$('#openid_login').hide();
});

// Toggles the element height and width styles of an image.
Expand Down

0 comments on commit 60b00b0

Please sign in to comment.