[ticket/13898] Fixed all the forum_fn.js violations I understood

PHPBB3-13898
This commit is contained in:
Callum Macrae 2015-05-30 15:03:56 +02:00
parent a39a421acb
commit 27a70f573f

View file

@ -1,3 +1,5 @@
/* global phpbb */
/**
* phpBB3 forum functions
*/
@ -37,7 +39,7 @@ function pageJump(item) {
baseUrl = item.attr('data-base-url'),
startName = item.attr('data-start-name');
if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) {
if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) {
if (baseUrl.indexOf('?') === -1) {
document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage);
} else {
@ -124,7 +126,7 @@ function activateSubPanel(p, panels) {
var i, showPanel;
if (typeof(p) === 'string') {
if (typeof p === 'string') {
showPanel = p;
}
$('input[name="show_panel"]').val(showPanel);
@ -277,8 +279,7 @@ jQuery(function($) {
/**
* Functions for user search popup
*/
function insertUser(formId, value)
{
function insertUser(formId, value) {
'use strict';
var $form = jQuery(formId),
@ -286,7 +287,7 @@ function insertUser(formId, value)
fieldName = $form.attr('data-field-name'),
item = opener.document.forms[formName][fieldName];
if (item.value.length && item.type == 'textarea') {
if (item.value.length && item.type === 'textarea') {
value = item.value + '\n' + value;
}
@ -319,7 +320,7 @@ function parseDocument($container) {
'use strict';
var test = document.createElement('div'),
oldBrowser = (typeof test.style.borderRadius == 'undefined'),
oldBrowser = (typeof test.style.borderRadius === 'undefined'),
$body = $('body');
/**
@ -359,7 +360,10 @@ function parseDocument($container) {
*/
if (oldBrowser) {
// Fix .linklist.bulletin lists
$container.find('ul.linklist.bulletin > li:first-child, ul.linklist.bulletin > li.rightside:last-child').addClass('no-bulletin');
$container
.find('ul.linklist.bulletin > li')
.filter(':first-child, .rightside:last-child')
.addClass('no-bulletin');
}
/**
@ -420,12 +424,12 @@ function parseDocument($container) {
width;
// Test max-width set in code for .navlinks above
width = parseInt($this.css('max-width'));
width = parseInt($this.css('max-width'), 10);
if (!width) {
width = $body.width();
}
maxHeight = parseInt($this.css('line-height'));
maxHeight = parseInt($this.css('line-height'), 10);
$links.each(function() {
if ($(this).height() > 0) {
maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
@ -470,7 +474,9 @@ function parseDocument($container) {
/**
* Responsive link lists
*/
$container.find('.linklist:not(.navlinks, [data-skip-responsive]), .postbody .post-buttons:not([data-skip-responsive])').each(function() {
var selector = '.linklist:not(.navlinks, [data-skip-responsive]),' +
'.postbody .post-buttons:not([data-skip-responsive])';
$container.find(selector).each(function() {
var $this = $(this),
filterSkip = '.breadcrumbs, [data-skip-responsive]',
filterLast = '.edit-icon, .quote-icon, [data-last-responsive]',
@ -478,7 +484,7 @@ function parseDocument($container) {
$linksNotSkip = $linksAll.not(filterSkip), // All items that can potentially be hidden
$linksFirst = $linksNotSkip.not(filterLast), // The items that will be hidden first
$linksLast = $linksNotSkip.filter(filterLast), // The items that will be hidden last
persistent = $this.attr('id') == 'nav-main', // Does this list already have a menu (such as quick-links)?
persistent = $this.attr('id') === 'nav-main', // Does this list already have a menu (such as quick-links)?
html = '<li class="responsive-menu hidden"><a href="javascript:void(0);" class="responsive-menu-link">&nbsp;</a><div class="dropdown hidden"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>',
slack = 3; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occured.
@ -675,7 +681,7 @@ function parseDocument($container) {
$children = column.children(),
html = column.html();
if ($children.length == 1 && $children.text() == column.text()) {
if ($children.length === 1 && $children.text() === column.text()) {
html = $children.html();
}
@ -717,8 +723,7 @@ function parseDocument($container) {
if (!$block.length) {
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
$block = $this.find('dt .responsive-show:last-child');
}
else {
} else {
first = ($.trim($block.text()).length === 0);
}
@ -728,7 +733,7 @@ function parseDocument($container) {
children = column.children(),
html = column.html();
if (children.length == 1 && children.text() == column.text()) {
if (children.length === 1 && children.text() === column.text()) {
html = children.html();
}
@ -757,7 +762,7 @@ function parseDocument($container) {
// Find each header
$th.each(function(column) {
var cell = $(this),
colspan = parseInt(cell.attr('colspan')),
colspan = parseInt(cell.attr('colspan'), 10),
dfn = cell.attr('data-dfn'),
text = dfn ? dfn : cell.text();
@ -788,14 +793,14 @@ function parseDocument($container) {
cells = row.children('td'),
column = 0;
if (cells.length == 1) {
if (cells.length === 1) {
row.addClass('big-column');
return;
}
cells.each(function() {
var cell = $(this),
colspan = parseInt(cell.attr('colspan')),
colspan = parseInt(cell.attr('colspan'), 10),
text = $.trim(cell.text());
if (headersLength <= column) {
@ -876,14 +881,21 @@ function parseDocument($container) {
$menu.prepend($tab.clone(true).removeClass('tab'));
$tab.hide();
if ($this.height() <= maxHeight) {
$menu.find('a').click(function() { check(true); });
$menu.find('a').click(function() {
check(true);
});
return;
}
}
$menu.find('a').click(function() { check(true); });
$menu.find('a').click(function() {
check(true);
});
}
phpbb.registerDropdown($item.find('a.responsive-tab-link'), $item.find('.dropdown'), {visibleClass: 'activetab'});
var $tabLink = $item.find('a.responsive-tab-link');
phpbb.registerDropdown($tabLink, $item.find('.dropdown'), {
visibleClass: 'activetab'
});
check(true);
$(window).resize(check);