1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 17:27:16 +02:00

[ticket/11552] Responsive breadcrumbs

PHPBB3-11552
This commit is contained in:
Vjacheslav Trushkin
2013-10-17 21:07:41 +03:00
parent a189c38853
commit 744a91dc7b
4 changed files with 68 additions and 3 deletions

View File

@@ -441,5 +441,56 @@ function insert_single_user(formId, user)
// Fix .linkslist.bulletin lists
$('ul.linklist.bulletin li:first-child, ul.linklist.bulletin li.rightside:last-child').addClass('no-bulletin');
}
// Responsive breadcrumbs
$('.breadcrumbs').each(function() {
var $this = $(this),
$body = $('body'),
links = $this.find('a'),
length = links.length,
classes = ['wrapped-wide', 'wrapped-medium', 'wrapped-small'],
classesLength = classes.length,
maxHeight = 0,
lastWidth = false,
wrapped = false;
// Test height by setting nowrap
$this.css('white-space', 'nowrap');
maxHeight = $this.height() + 1;
$this.css('white-space', '');
// Funciton that checks breadcrumbs
function check() {
var height = $this.height(),
width = $body.width(),
link, i, j;
if (height <= maxHeight) {
if (!wrapped || lastWidth === false || lastWidth >= width) {
lastWidth = width;
return;
}
}
lastWidth = width;
if (wrapped) {
$this.find('a.wrapped').removeClass('wrapped ' + classes.join(' '));
wrapped = false;
if ($this.height() <= maxHeight) return;
}
wrapped = true;
for (i = 0; i < classesLength; i ++) {
for (j = length; j >= 0; j --) {
links.eq(j).addClass('wrapped ' + classes[i]);
if ($this.height() <= maxHeight) return;
}
}
}
// Run function and set event
check();
$(window).resize(check);
});
});
})(jQuery);