[ticket/11552] Compact mode for notifications and pm links

This will hide part of buttons for notifications and pm links
in header before switching to responsive mode

PHPBB3-11552
This commit is contained in:
Vjacheslav Trushkin 2013-10-18 22:32:46 +03:00
parent bd4dab8026
commit a23d4526fd
3 changed files with 39 additions and 2 deletions

View file

@ -553,6 +553,7 @@ function insert_single_user(formId, user)
toggleLink = toggle.find('a.responsive-menu-link'), toggleLink = toggle.find('a.responsive-menu-link'),
menu = toggle.find('ul.responsive-popup'), menu = toggle.find('ul.responsive-popup'),
lastWidth = false, lastWidth = false,
compact = false,
responsive = false, responsive = false,
copied = false; copied = false;
@ -562,6 +563,7 @@ function insert_single_user(formId, user)
return; return;
} }
// Reset responsive and compact layout
if (responsive) { if (responsive) {
responsive = false; responsive = false;
$this.removeClass('responsive'); $this.removeClass('responsive');
@ -569,16 +571,42 @@ function insert_single_user(formId, user)
toggle.css('display', 'none'); toggle.css('display', 'none');
} }
if (compact) {
compact = false;
$this.removeClass('compact');
}
// Find tallest element
var maxHeight = 0; var maxHeight = 0;
links.each(function() { links.each(function() {
maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
}); });
// Nothing to resize if block's height is not bigger than tallest element's height
if ($this.height() <= maxHeight) {
toggle.removeClass('visible');
menu.hide();
return;
}
// Enable compact layout, find tallest element, compare to height of whole block
compact = true;
$this.addClass('compact');
var compactMaxHeight = 0;
links.each(function() {
compactMaxHeight = Math.max(compactMaxHeight, $(this).outerHeight(true));
});
if ($this.height() <= maxHeight) { if ($this.height() <= maxHeight) {
toggle.removeClass('visible'); toggle.removeClass('visible');
menu.hide(); menu.hide();
return; return;
} }
// Compact layout did not resize block enough, switch to responsive layout
compact = false;
$this.removeClass('compact');
responsive = true; responsive = true;
if (!copied) { if (!copied) {

View file

@ -101,7 +101,7 @@
<ul class="linklist leftside bulletin"> <ul class="linklist leftside bulletin">
<!-- IF S_NOTIFICATIONS_DISPLAY --> <!-- IF S_NOTIFICATIONS_DISPLAY -->
<li class="icon-notification skip-responsive"> <li class="icon-notification skip-responsive">
<a href="{U_VIEW_ALL_NOTIFICATIONS}" id="notification_list_button">{L_NOTIFICATIONS} [<strong>{NOTIFICATIONS_COUNT}</strong>]</a> <a href="{U_VIEW_ALL_NOTIFICATIONS}" id="notification_list_button"><span>{L_NOTIFICATIONS} [</span><strong>{NOTIFICATIONS_COUNT}</strong><span>]</span></a>
<div id="notification_list" class="notification_list"> <div id="notification_list" class="notification_list">
<div class="pointer"><div class="pointer_inner"></div></div> <div class="pointer"><div class="pointer_inner"></div></div>
<div class="header"> <div class="header">
@ -140,7 +140,7 @@
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF S_DISPLAY_PM --> <!-- IF S_DISPLAY_PM -->
<li class="icon-pm"> <li class="icon-pm">
<a href="{U_PRIVATEMSGS}">{L_PRIVATE_MESSAGES} [<strong>{PRIVATE_MESSAGE_COUNT}</strong>]</a> <a href="{U_PRIVATEMSGS}"><span>{L_PRIVATE_MESSAGES} [</span><strong>{PRIVATE_MESSAGE_COUNT}</strong><span>]</span></a>
</li> </li>
<!-- ENDIF --> <!-- ENDIF -->
<li class="icon-ucp"> <li class="icon-ucp">

View file

@ -915,3 +915,12 @@ form > p.post-notice strong {
.notification_list p.notifications_time { .notification_list p.notifications_time {
font-size: 11px; font-size: 11px;
} }
.compact .icon-notification > a > span, .compact .icon-pm > a > span {
display: none;
}
.compact .icon-notification > a > strong, .compact .icon-pm > a > strong {
padding-left: 2px;
}