diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 0ad5c1d6e7..ab0891e70c 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -624,8 +624,7 @@ phpbb.resizeTextArea = function(items, options) { function resetAutoResize(item) { var $item = $(item); - if ($item.hasClass('auto-resized')) - { + if ($item.hasClass('auto-resized')) { $(item).css({height: '', resize: ''}).removeClass('auto-resized'); configuration.resetCallback.call(item, $item); } @@ -635,14 +634,14 @@ phpbb.resizeTextArea = function(items, options) { { function setHeight(height) { + height += parseInt($item.css('height')) - $item.height(); $item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized'); configuration.resizeCallback.call(item, $item); } var windowHeight = $(window).height(); - if (windowHeight < configuration.minWindowHeight) - { + if (windowHeight < configuration.minWindowHeight) { resetAutoResize(item); return; } @@ -652,12 +651,14 @@ phpbb.resizeTextArea = function(items, options) { height = parseInt($item.height()), scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; - if (height > maxHeight) - { + if (height < 0) { + return; + } + + if (height > maxHeight) { setHeight(maxHeight); } - else if (scrollHeight > (height + 5)) - { + else if (scrollHeight > (height + 5)) { setHeight(Math.min(maxHeight, scrollHeight)); } } @@ -670,8 +671,7 @@ phpbb.resizeTextArea = function(items, options) { $(window).resize(function() { items.each(function() { - if ($(this).hasClass('auto-resized')) - { + if ($(this).hasClass('auto-resized')) { autoResize(this); } }); diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 800fadd972..a2758de9dc 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -414,6 +414,9 @@ function insert_single_user(formId, user) */ (function($) { $(document).ready(function() { + // Swap .nojs and .hasjs + $('#phpbb.nojs').toggleClass('nojs hasjs'); + // Focus forms $('form[data-focus]:first').each(function() { $('#' + this.getAttribute('data-focus')).focus(); @@ -435,8 +438,396 @@ function insert_single_user(formId, user) delete test; if (oldBrowser) { - // Fix .linkslist.bulletin lists + // Fix .linklist.bulletin lists $('ul.linklist.bulletin li:first-child, ul.linklist.bulletin li.rightside:last-child').addClass('no-bulletin'); + + // Do not run functions below for old browsers + return; } + + // Adjust topiclist lists with check boxes + $('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark'); + + // Resize navigation block to keep all links on same line + $('.navlinks').each(function() { + var $this = $(this), + left = $this.children().not('.rightside'), + right = $this.children('.rightside'); + + if (left.length !== 1 || !right.length) return; + + function resize() { + var width = 0, + diff = left.outerWidth(true) - left.width(); + + right.each(function() { + width += $(this).outerWidth(true); + }); + left.css('max-width', Math.floor($this.width() - width - diff) + 'px'); + } + + resize(); + $(window).resize(resize); + }); + + // Responsive breadcrumbs + $('.breadcrumbs:not(.skip-responsive, .linklist.leftside .breadcrumbs)').each(function() { + var $this = $(this), + $body = $('body'), + links = $this.find('.crumb'), + 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', ''); + + // Set tooltips + $this.find('a').each(function() { + var $link = $(this); + $link.attr('title', $link.text()); + }); + + // 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.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' ')); + wrapped = false; + if ($this.height() <= maxHeight) { + return; + } + } + + wrapped = true; + $this.addClass('wrapped'); + if ($this.height() <= maxHeight) { + return; + } + + for (i = 0; i < classesLength; i ++) { + for (j = length - 1; j >= 0; j --) { + links.eq(j).addClass('wrapped ' + classes[i]); + if ($this.height() <= maxHeight) { + return; + } + } + } + } + + // Run function and set event + check(); + $(window).resize(check); + }); + + // Responsive tables + $('table.table1').not('.not-responsive').each(function() { + var $this = $(this), + th = $this.find('thead > tr > th'), + columns = th.length, + headers = [], + totalHeaders = 0, + i, headersLength; + + // Find each header + th.each(function() { + var cell = $(this), + colspan = parseInt(cell.attr('colspan')), + dfn = cell.attr('data-dfn'), + text = dfn ? dfn : cell.text(); + + colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; + + for (i=0; i + $this.addClass('responsive'); + + if (totalHeaders < 2) { + $this.addClass('show-header'); + return; + } + + $this.find('tbody > tr').each(function() { + var row = $(this), + cells = row.children('td'), + column = 0; + + if (cells.length == 1) { + row.addClass('big-column'); + return; + } + + cells.each(function() { + var cell = $(this), + colspan = parseInt(cell.attr('colspan')), + text = cell.text().trim(); + + if (headersLength <= column) { + return; + } + + if (text.length && text !== '-') { + cell.prepend('' + headers[column] + ''); + } + else { + cell.addClass('empty'); + } + + colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; + column += colspan; + }); + }); + }); + + // Responsive link lists + $('.linklist:not(.navlinks, .skip-responsive), .postbody ul.profile-icons:not(.skip-responsive)').each(function() { + var $this = $(this), + $body = $('body'), + links = $this.children().not('.skip-responsive'), + html = '