mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-14 07:18:52 +00:00
Merge pull request #3668 from callumacrae/js-linting
[ticket/13898] js coding standards
This commit is contained in:
commit
189d94e897
6 changed files with 218 additions and 96 deletions
78
.jscsrc
Normal file
78
.jscsrc
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
|
||||||
|
{
|
||||||
|
"excludeFiles": ["node_modules/**", "**/build/**"],
|
||||||
|
"requireCurlyBraces": [
|
||||||
|
"if", "else", "for", "while", "do", "try", "catch"
|
||||||
|
],
|
||||||
|
"requireSpaceBeforeKeywords": [
|
||||||
|
"else", "while", "catch"
|
||||||
|
],
|
||||||
|
"requireSpaceAfterKeywords": [
|
||||||
|
"do", "for", "if", "else", "switch", "case", "try", "catch", "while", "return", "typeof"
|
||||||
|
],
|
||||||
|
"requireSpaceBeforeBlockStatements": true,
|
||||||
|
"requireParenthesesAroundIIFE": true,
|
||||||
|
"requireSpacesInConditionalExpression": {
|
||||||
|
"afterTest": true,
|
||||||
|
"beforeConsequent": true,
|
||||||
|
"afterConsequent": true,
|
||||||
|
"beforeAlternate": true
|
||||||
|
},
|
||||||
|
"requireSpacesInAnonymousFunctionExpression": {
|
||||||
|
"beforeOpeningCurlyBrace": true
|
||||||
|
},
|
||||||
|
"disallowSpacesInNamedFunctionExpression": {
|
||||||
|
"beforeOpeningRoundBrace": true
|
||||||
|
},
|
||||||
|
"requireSpacesInFunction": {
|
||||||
|
"beforeOpeningCurlyBrace": true
|
||||||
|
},
|
||||||
|
"disallowSpacesInCallExpression": true,
|
||||||
|
"requireBlocksOnNewline": true,
|
||||||
|
"requirePaddingNewlinesBeforeKeywords": ["case"],
|
||||||
|
"disallowEmptyBlocks": true,
|
||||||
|
"disallowSpacesInsideArrayBrackets": "nested",
|
||||||
|
"disallowSpacesInsideParentheses": true,
|
||||||
|
"requireSpacesInsideObjectBrackets": "all",
|
||||||
|
"disallowQuotedKeysInObjects": "allButReserved",
|
||||||
|
"disallowSpaceAfterObjectKeys": true,
|
||||||
|
"requireSpaceBeforeObjectValues": true,
|
||||||
|
"requireCommaBeforeLineBreak": true,
|
||||||
|
"requireOperatorBeforeLineBreak": [
|
||||||
|
"?", "=", "+", "-", "/", "*", "===", "!==", ">", ">=", "<", "<="
|
||||||
|
],
|
||||||
|
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
|
||||||
|
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
|
||||||
|
"requireSpaceBeforeBinaryOperators": [
|
||||||
|
"=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">="
|
||||||
|
],
|
||||||
|
"requireSpaceAfterBinaryOperators": [
|
||||||
|
"=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">="
|
||||||
|
],
|
||||||
|
"disallowKeywords": ["with"],
|
||||||
|
"disallowMultipleLineStrings": true,
|
||||||
|
"disallowMixedSpacesAndTabs": "smart",
|
||||||
|
"disallowTrailingWhitespace": true,
|
||||||
|
"disallowTrailingComma": true,
|
||||||
|
"disallowKeywordsOnNewLine": ["else"],
|
||||||
|
"requireLineFeedAtFileEnd": true,
|
||||||
|
"maximumLineLength": {
|
||||||
|
"value": 120,
|
||||||
|
"tabSize": 4,
|
||||||
|
"allowUrlComments": true,
|
||||||
|
"allowRegex": true
|
||||||
|
},
|
||||||
|
"requireCapitalizedConstructors": true,
|
||||||
|
"requireDotNotation": true,
|
||||||
|
"disallowYodaConditions": true,
|
||||||
|
"requireSpaceAfterLineComment": {
|
||||||
|
"allExcept": ["#", "="]
|
||||||
|
},
|
||||||
|
"disallowNewlineBeforeBlockStatements": true,
|
||||||
|
"validateQuoteMarks": {
|
||||||
|
"mark": "'",
|
||||||
|
"escape": true
|
||||||
|
},
|
||||||
|
"validateParameterSeparator": ", ",
|
||||||
|
"safeContextKeyword": ["that"]
|
||||||
|
}
|
24
.jshintrc
Normal file
24
.jshintrc
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
{
|
||||||
|
"bitwise": true,
|
||||||
|
"curly": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"es3": true,
|
||||||
|
"forin": false,
|
||||||
|
"freeze": true,
|
||||||
|
"newcap": true,
|
||||||
|
"noarg": true,
|
||||||
|
"noempty": true,
|
||||||
|
"nonbsp": true,
|
||||||
|
"undef": true,
|
||||||
|
"unused": true,
|
||||||
|
"strict": true,
|
||||||
|
|
||||||
|
"browser": true,
|
||||||
|
"devel": true,
|
||||||
|
"jquery": true,
|
||||||
|
|
||||||
|
"globals": {
|
||||||
|
"JSON": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -264,11 +264,9 @@ phpbb.ajaxify = function(options) {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
if (typeof responseText === 'string' && responseText.length > 0) {
|
if (typeof responseText === 'string' && responseText.length > 0) {
|
||||||
errorText = responseText;
|
errorText = responseText;
|
||||||
}
|
} else if (typeof errorThrown === 'string' && errorThrown.length > 0) {
|
||||||
else if (typeof errorThrown === 'string' && errorThrown.length > 0) {
|
|
||||||
errorText = errorThrown;
|
errorText = errorThrown;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
errorText = $dark.attr('data-ajax-error-text-' + textStatus);
|
errorText = $dark.attr('data-ajax-error-text-' + textStatus);
|
||||||
if (typeof errorText !== 'string' || !errorText.length) {
|
if (typeof errorText !== 'string' || !errorText.length) {
|
||||||
errorText = $dark.attr('data-ajax-error-text');
|
errorText = $dark.attr('data-ajax-error-text');
|
||||||
|
@ -450,7 +448,7 @@ phpbb.search.cache.get = function(id) {
|
||||||
*/
|
*/
|
||||||
phpbb.search.cache.set = function(id, key, value) {
|
phpbb.search.cache.set = function(id, key, value) {
|
||||||
if (!this.data[id]) {
|
if (!this.data[id]) {
|
||||||
this.data[id] = {results: []};
|
this.data[id] = { results: [] };
|
||||||
}
|
}
|
||||||
this.data[id][key] = value;
|
this.data[id][key] = value;
|
||||||
};
|
};
|
||||||
|
@ -525,7 +523,8 @@ phpbb.search.setValue = function($input, value, multiline) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the onclick event to set the value on the input|textarea to the selected search result.
|
* Sets the onclick event to set the value on the input|textarea to the
|
||||||
|
* selected search result.
|
||||||
*
|
*
|
||||||
* @param {jQuery} $input Search input|textarea.
|
* @param {jQuery} $input Search input|textarea.
|
||||||
* @param {object} value Result object.
|
* @param {object} value Result object.
|
||||||
|
@ -554,7 +553,7 @@ phpbb.search.setValueOnClick = function($input, value, $row, $container) {
|
||||||
phpbb.search.filter = function(data, event, sendRequest) {
|
phpbb.search.filter = function(data, event, sendRequest) {
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'),
|
dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'),
|
||||||
minLength = parseInt($this.attr('data-min-length')),
|
minLength = parseInt($this.attr('data-min-length'), 10),
|
||||||
searchID = $this.attr('data-results'),
|
searchID = $this.attr('data-results'),
|
||||||
keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')),
|
keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')),
|
||||||
cache = phpbb.search.cache.get(searchID),
|
cache = phpbb.search.cache.get(searchID),
|
||||||
|
@ -576,7 +575,10 @@ phpbb.search.filter = function(data, event, sendRequest) {
|
||||||
} else {
|
} else {
|
||||||
// Do we already have results for this?
|
// Do we already have results for this?
|
||||||
if (cache.results[keyword]) {
|
if (cache.results[keyword]) {
|
||||||
var response = {keyword: keyword, results: cache.results[keyword]};
|
var response = {
|
||||||
|
keyword: keyword,
|
||||||
|
results: cache.results[keyword]
|
||||||
|
};
|
||||||
phpbb.search.handleResponse(response, $this, true);
|
phpbb.search.handleResponse(response, $this, true);
|
||||||
proceed = false;
|
proceed = false;
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1008,9 @@ phpbb.resizeTextArea = function($items, options) {
|
||||||
function resetAutoResize(item) {
|
function resetAutoResize(item) {
|
||||||
var $item = $(item);
|
var $item = $(item);
|
||||||
if ($item.hasClass('auto-resized')) {
|
if ($item.hasClass('auto-resized')) {
|
||||||
$(item).css({height: '', resize: ''}).removeClass('auto-resized');
|
$(item)
|
||||||
|
.css({ height: '', resize: '' })
|
||||||
|
.removeClass('auto-resized');
|
||||||
configuration.resetCallback.call(item, $item);
|
configuration.resetCallback.call(item, $item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1014,7 +1018,9 @@ phpbb.resizeTextArea = function($items, options) {
|
||||||
function autoResize(item) {
|
function autoResize(item) {
|
||||||
function setHeight(height) {
|
function setHeight(height) {
|
||||||
height += parseInt($item.css('height'), 10) - $item.height();
|
height += parseInt($item.css('height'), 10) - $item.height();
|
||||||
$item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized');
|
$item
|
||||||
|
.css({ height: height + 'px', resize: 'none' })
|
||||||
|
.addClass('auto-resized');
|
||||||
configuration.resizeCallback.call(item, $item);
|
configuration.resizeCallback.call(item, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1039,8 +1045,7 @@ phpbb.resizeTextArea = function($items, options) {
|
||||||
|
|
||||||
if (height > maxHeight) {
|
if (height > maxHeight) {
|
||||||
setHeight(maxHeight);
|
setHeight(maxHeight);
|
||||||
}
|
} else if (scrollHeight > (height + 5)) {
|
||||||
else if (scrollHeight > (height + 5)) {
|
|
||||||
setHeight(Math.min(maxHeight, scrollHeight));
|
setHeight(Math.min(maxHeight, scrollHeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1157,7 +1162,7 @@ phpbb.applyCodeEditor = function(textarea) {
|
||||||
var tagLength = startTags[i].length;
|
var tagLength = startTags[i].length;
|
||||||
|
|
||||||
value = value.substring(index + tagLength);
|
value = value.substring(index + tagLength);
|
||||||
if (startTags[i].lastIndexOf(startTagsEnd) != tagLength) {
|
if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) {
|
||||||
index = value.indexOf(startTagsEnd);
|
index = value.indexOf(startTagsEnd);
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
@ -1333,12 +1338,15 @@ phpbb.toggleDropdown = function() {
|
||||||
fullFreeSpace = freeSpace + parent.outerWidth();
|
fullFreeSpace = freeSpace + parent.outerWidth();
|
||||||
|
|
||||||
options.dropdown.find('.dropdown-contents').each(function() {
|
options.dropdown.find('.dropdown-contents').each(function() {
|
||||||
contentWidth = parseInt($(this).outerWidth());
|
contentWidth = parseInt($(this).outerWidth(), 10);
|
||||||
$(this).css({marginLeft: 0, left: 0});
|
$(this).css({ marginLeft: 0, left: 0 });
|
||||||
});
|
});
|
||||||
|
|
||||||
var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px';
|
var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px';
|
||||||
options.dropdown.css({'width': maxOffset, 'margin-left': '-' + maxOffset});
|
options.dropdown.css({
|
||||||
|
width: maxOffset,
|
||||||
|
marginLeft: -maxOffset
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options.dropdown.css('margin-right', '-' + (windowWidth + freeSpace) + 'px');
|
options.dropdown.css('margin-right', '-' + (windowWidth + freeSpace) + 'px');
|
||||||
|
@ -1405,9 +1413,7 @@ phpbb.registerDropdown = function(toggle, dropdown, options) {
|
||||||
* @param {int} height Palette cell height.
|
* @param {int} height Palette cell height.
|
||||||
*/
|
*/
|
||||||
phpbb.colorPalette = function(dir, width, height) {
|
phpbb.colorPalette = function(dir, width, height) {
|
||||||
var r = 0,
|
var r, g, b,
|
||||||
g = 0,
|
|
||||||
b = 0,
|
|
||||||
numberList = new Array(6),
|
numberList = new Array(6),
|
||||||
color = '',
|
color = '',
|
||||||
html = '';
|
html = '';
|
||||||
|
@ -1418,32 +1424,33 @@ phpbb.colorPalette = function(dir, width, height) {
|
||||||
numberList[3] = 'BF';
|
numberList[3] = 'BF';
|
||||||
numberList[4] = 'FF';
|
numberList[4] = 'FF';
|
||||||
|
|
||||||
var tableClass = (dir == 'h') ? 'horizontal-palette' : 'vertical-palette';
|
var tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette';
|
||||||
html += '<table class="not-responsive colour-palette ' + tableClass + '" style="width: auto;">';
|
html += '<table class="not-responsive colour-palette ' + tableClass + '" style="width: auto;">';
|
||||||
|
|
||||||
for (r = 0; r < 5; r++) {
|
for (r = 0; r < 5; r++) {
|
||||||
if (dir == 'h') {
|
if (dir === 'h') {
|
||||||
html += '<tr>';
|
html += '<tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (g = 0; g < 5; g++) {
|
for (g = 0; g < 5; g++) {
|
||||||
if (dir == 'v') {
|
if (dir === 'v') {
|
||||||
html += '<tr>';
|
html += '<tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (b = 0; b < 5; b++) {
|
for (b = 0; b < 5; b++) {
|
||||||
color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
|
color = '' + numberList[r] + numberList[g] + numberList[b];
|
||||||
html += '<td style="background-color: #' + color + '; width: ' + width + 'px; height: ' + height + 'px;">';
|
html += '<td style="background-color: #' + color + '; width: ' + width + 'px; height: ' +
|
||||||
html += '<a href="#" data-color="' + color + '" style="display: block; width: ' + width + 'px; height: ' + height + 'px; " alt="#' + color + '" title="#' + color + '"></a>';
|
height + 'px;"><a href="#" data-color="' + color + '" style="display: block; width: ' +
|
||||||
|
width + 'px; height: ' + height + 'px; " alt="#' + color + '" title="#' + color + '"></a>';
|
||||||
html += '</td>';
|
html += '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir == 'v') {
|
if (dir === 'v') {
|
||||||
html += '</tr>';
|
html += '</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir == 'h') {
|
if (dir === 'h') {
|
||||||
html += '</tr>';
|
html += '</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ phpbb.plupload.insertRow = function(file) {
|
||||||
row.find('.file-name').html(plupload.xmlEncode(file.name));
|
row.find('.file-name').html(plupload.xmlEncode(file.name));
|
||||||
row.find('.file-size').html(plupload.formatSize(file.size));
|
row.find('.file-size').html(plupload.formatSize(file.size));
|
||||||
|
|
||||||
if (phpbb.plupload.order == 'desc') {
|
if (phpbb.plupload.order === 'desc') {
|
||||||
$('#file-list').prepend(row);
|
$('#file-list').prepend(row);
|
||||||
} else {
|
} else {
|
||||||
$('#file-list').append(row);
|
$('#file-list').append(row);
|
||||||
|
@ -209,7 +209,7 @@ phpbb.plupload.updateHiddenData = function(row, attach, index) {
|
||||||
|
|
||||||
var input = $('<input />')
|
var input = $('<input />')
|
||||||
.attr('type', 'hidden')
|
.attr('type', 'hidden')
|
||||||
.attr('name', 'attachment_data[' + index + '][' + key +']')
|
.attr('name', 'attachment_data[' + index + '][' + key + ']')
|
||||||
.attr('value', attach[key]);
|
.attr('value', attach[key]);
|
||||||
$('textarea', row).after(input);
|
$('textarea', row).after(input);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ phpbb.plupload.deleteFile = function(row, attachId) {
|
||||||
|
|
||||||
// trigger_error() was called which likely means a permission error was encountered.
|
// trigger_error() was called which likely means a permission error was encountered.
|
||||||
if (typeof response.title !== 'undefined') {
|
if (typeof response.title !== 'undefined') {
|
||||||
phpbb.plupload.uploader.trigger('Error', {message: response.message});
|
phpbb.plupload.uploader.trigger('Error', { message: response.message });
|
||||||
// We will have to assume that the deletion failed. So leave the file status as uploaded.
|
// We will have to assume that the deletion failed. So leave the file status as uploaded.
|
||||||
row.find('.file-status').toggleClass('file-uploaded');
|
row.find('.file-status').toggleClass('file-uploaded');
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ phpbb.plupload.deleteFile = function(row, attachId) {
|
||||||
$.ajax(phpbb.plupload.config.url, {
|
$.ajax(phpbb.plupload.config.url, {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: $.extend(fields, phpbb.plupload.getSerializedData()),
|
data: $.extend(fields, phpbb.plupload.getSerializedData()),
|
||||||
headers: {'X-PHPBB-USING-PLUPLOAD': '1', 'X-Requested-With': 'XMLHttpRequest'}
|
headers: { 'X-PHPBB-USING-PLUPLOAD': '1', 'X-Requested-With': 'XMLHttpRequest' }
|
||||||
})
|
})
|
||||||
.always(always)
|
.always(always)
|
||||||
.done(done);
|
.done(done);
|
||||||
|
@ -297,10 +297,10 @@ phpbb.plupload.hideEmptyList = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the indices used in inline attachment bbcodes. This ensures that the bbcodes
|
* Update the indices used in inline attachment bbcodes. This ensures that the
|
||||||
* correspond to the correct file after a file is added or removed. This should be called
|
* bbcodes correspond to the correct file after a file is added or removed.
|
||||||
* before the phpbb.plupload,data and phpbb.plupload.ids arrays are updated, otherwise it will
|
* This should be called before the phpbb.plupload,data and phpbb.plupload.ids
|
||||||
* not work correctly.
|
* arrays are updated, otherwise it will not work correctly.
|
||||||
*
|
*
|
||||||
* @param {string} action The action that occurred -- either "addition" or "removal"
|
* @param {string} action The action that occurred -- either "addition" or "removal"
|
||||||
* @param {int} index The index of the attachment from phpbb.plupload.ids that was affected.
|
* @param {int} index The index of the attachment from phpbb.plupload.ids that was affected.
|
||||||
|
@ -323,7 +323,7 @@ phpbb.plupload.updateBbcode = function(action, index) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
var newIndex = i + ((removal) ? -1 : 1);
|
var newIndex = i + ((removal) ? -1 : 1);
|
||||||
return '[attachment=' + newIndex +']' + fileName + '[/attachment]';
|
return '[attachment=' + newIndex + ']' + fileName + '[/attachment]';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,10 +380,10 @@ phpbb.plupload.handleMaxFilesReached = function() {
|
||||||
phpbb.plupload.markQueuedFailed(phpbb.plupload.lang.TOO_MANY_ATTACHMENTS);
|
phpbb.plupload.markQueuedFailed(phpbb.plupload.lang.TOO_MANY_ATTACHMENTS);
|
||||||
// Disable the uploader.
|
// Disable the uploader.
|
||||||
phpbb.plupload.disableUploader();
|
phpbb.plupload.disableUploader();
|
||||||
phpbb.plupload.uploader.trigger('Error', {message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS});
|
phpbb.plupload.uploader.trigger('Error', { message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(phpbb.plupload.maxFiles > phpbb.plupload.ids.length) {
|
} else if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) {
|
||||||
// Enable the uploader if the user is under the limit
|
// Enable the uploader if the user is under the limit
|
||||||
phpbb.plupload.enableUploader();
|
phpbb.plupload.enableUploader();
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb.plupload.updateMultipartParams({'real_filename': file.name});
|
phpbb.plupload.updateMultipartParams({ real_filename: file.name });
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -538,7 +538,7 @@ phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) {
|
||||||
|
|
||||||
// If trigger_error() was called, then a permission error likely occurred.
|
// If trigger_error() was called, then a permission error likely occurred.
|
||||||
if (typeof json.title !== 'undefined') {
|
if (typeof json.title !== 'undefined') {
|
||||||
json.error = {message: json.message};
|
json.error = { message: json.message };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json.error) {
|
if (json.error) {
|
||||||
|
@ -619,7 +619,7 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) {
|
||||||
// If trigger_error() was called, then a permission error likely occurred.
|
// If trigger_error() was called, then a permission error likely occurred.
|
||||||
if (typeof json.title !== 'undefined') {
|
if (typeof json.title !== 'undefined') {
|
||||||
error = json.message;
|
error = json.message;
|
||||||
up.trigger('Error', {message: error});
|
up.trigger('Error', { message: error });
|
||||||
|
|
||||||
// The rest of the queue will fail.
|
// The rest of the queue will fail.
|
||||||
phpbb.plupload.markQueuedFailed(error);
|
phpbb.plupload.markQueuedFailed(error);
|
||||||
|
|
|
@ -9,9 +9,9 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) {
|
||||||
var readTitle = res.NO_UNREAD_POSTS;
|
var readTitle = res.NO_UNREAD_POSTS;
|
||||||
var unreadTitle = res.UNREAD_POSTS;
|
var unreadTitle = res.UNREAD_POSTS;
|
||||||
var iconsArray = {
|
var iconsArray = {
|
||||||
'forum_unread': 'forum_read',
|
forum_unread: 'forum_read',
|
||||||
'forum_unread_subforum': 'forum_read_subforum',
|
forum_unread_subforum: 'forum_read_subforum',
|
||||||
'forum_unread_locked': 'forum_read_locked'
|
forum_unread_locked: 'forum_read_locked'
|
||||||
};
|
};
|
||||||
|
|
||||||
$('li.row').find('dl[class*="forum_unread"]').each(function() {
|
$('li.row').find('dl[class*="forum_unread"]').each(function() {
|
||||||
|
@ -49,10 +49,10 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) {
|
||||||
var readTitle = res.NO_UNREAD_POSTS;
|
var readTitle = res.NO_UNREAD_POSTS;
|
||||||
var unreadTitle = res.UNREAD_POSTS;
|
var unreadTitle = res.UNREAD_POSTS;
|
||||||
var iconsArray = {
|
var iconsArray = {
|
||||||
'global_unread': 'global_read',
|
global_unread: 'global_read',
|
||||||
'announce_unread': 'announce_read',
|
announce_unread: 'announce_read',
|
||||||
'sticky_unread': 'sticky_read',
|
sticky_unread: 'sticky_read',
|
||||||
'topic_unread': 'topic_read'
|
topic_unread: 'topic_read'
|
||||||
};
|
};
|
||||||
var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
|
var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
|
||||||
var unreadClassSelectors;
|
var unreadClassSelectors;
|
||||||
|
@ -252,7 +252,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
|
||||||
var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
|
var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
bar.animate({width: percentRel + '%'}, 500)
|
bar.animate({ width: percentRel + '%' }, 500)
|
||||||
.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
|
.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
|
||||||
.addClass(newBarClass)
|
.addClass(newBarClass)
|
||||||
.html(res.vote_counts[optionId]);
|
.html(res.vote_counts[optionId]);
|
||||||
|
@ -287,10 +287,10 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
|
||||||
var panelHeight = panel.height();
|
var panelHeight = panel.height();
|
||||||
var innerHeight = panel.find('.inner').outerHeight();
|
var innerHeight = panel.find('.inner').outerHeight();
|
||||||
|
|
||||||
if (panelHeight != innerHeight) {
|
if (panelHeight !== innerHeight) {
|
||||||
panel.css({'min-height': '', 'height': panelHeight})
|
panel.css({ minHeight: '', height: panelHeight })
|
||||||
.animate({height: innerHeight}, time, function () {
|
.animate({ height: innerHeight }, time, function () {
|
||||||
panel.css({'min-height': innerHeight, 'height': ''});
|
panel.css({ minHeight: innerHeight, height: '' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -377,7 +377,8 @@ $('#member_search').click(function () {
|
||||||
* Automatically resize textarea
|
* Automatically resize textarea
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(function() {
|
||||||
phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250});
|
var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)');
|
||||||
|
phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 });
|
||||||
phpbb.resizeTextArea($('textarea', '#message-box'));
|
phpbb.resizeTextArea($('textarea', '#message-box'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global phpbb */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phpBB3 forum functions
|
* phpBB3 forum functions
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +39,7 @@ function pageJump(item) {
|
||||||
baseUrl = item.attr('data-base-url'),
|
baseUrl = item.attr('data-base-url'),
|
||||||
startName = item.attr('data-start-name');
|
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) {
|
if (baseUrl.indexOf('?') === -1) {
|
||||||
document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage);
|
document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage);
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,7 +126,7 @@ function activateSubPanel(p, panels) {
|
||||||
|
|
||||||
var i, showPanel;
|
var i, showPanel;
|
||||||
|
|
||||||
if (typeof(p) === 'string') {
|
if (typeof p === 'string') {
|
||||||
showPanel = p;
|
showPanel = p;
|
||||||
}
|
}
|
||||||
$('input[name="show_panel"]').val(showPanel);
|
$('input[name="show_panel"]').val(showPanel);
|
||||||
|
@ -277,8 +279,7 @@ jQuery(function($) {
|
||||||
/**
|
/**
|
||||||
* Functions for user search popup
|
* Functions for user search popup
|
||||||
*/
|
*/
|
||||||
function insertUser(formId, value)
|
function insertUser(formId, value) {
|
||||||
{
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var $form = jQuery(formId),
|
var $form = jQuery(formId),
|
||||||
|
@ -286,7 +287,7 @@ function insertUser(formId, value)
|
||||||
fieldName = $form.attr('data-field-name'),
|
fieldName = $form.attr('data-field-name'),
|
||||||
item = opener.document.forms[formName][fieldName];
|
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;
|
value = item.value + '\n' + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +320,7 @@ function parseDocument($container) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var test = document.createElement('div'),
|
var test = document.createElement('div'),
|
||||||
oldBrowser = (typeof test.style.borderRadius == 'undefined'),
|
oldBrowser = (typeof test.style.borderRadius === 'undefined'),
|
||||||
$body = $('body');
|
$body = $('body');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -359,7 +360,10 @@ function parseDocument($container) {
|
||||||
*/
|
*/
|
||||||
if (oldBrowser) {
|
if (oldBrowser) {
|
||||||
// Fix .linklist.bulletin lists
|
// 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;
|
width;
|
||||||
|
|
||||||
// Test max-width set in code for .navlinks above
|
// Test max-width set in code for .navlinks above
|
||||||
width = parseInt($this.css('max-width'));
|
width = parseInt($this.css('max-width'), 10);
|
||||||
if (!width) {
|
if (!width) {
|
||||||
width = $body.width();
|
width = $body.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
maxHeight = parseInt($this.css('line-height'));
|
maxHeight = parseInt($this.css('line-height'), 10);
|
||||||
$links.each(function() {
|
$links.each(function() {
|
||||||
if ($(this).height() > 0) {
|
if ($(this).height() > 0) {
|
||||||
maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
|
maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
|
||||||
|
@ -452,8 +456,8 @@ function parseDocument($container) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < classesLength; i ++) {
|
for (var i = 0; i < classesLength; i++) {
|
||||||
for (var j = length - 1; j >= 0; j --) {
|
for (var j = length - 1; j >= 0; j--) {
|
||||||
$links.eq(j).addClass('wrapped ' + classes[i]);
|
$links.eq(j).addClass('wrapped ' + classes[i]);
|
||||||
if ($this.height() <= maxHeight) {
|
if ($this.height() <= maxHeight) {
|
||||||
return;
|
return;
|
||||||
|
@ -470,7 +474,9 @@ function parseDocument($container) {
|
||||||
/**
|
/**
|
||||||
* Responsive link lists
|
* 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),
|
var $this = $(this),
|
||||||
filterSkip = '.breadcrumbs, [data-skip-responsive]',
|
filterSkip = '.breadcrumbs, [data-skip-responsive]',
|
||||||
filterLast = '.edit-icon, .quote-icon, [data-last-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
|
$linksNotSkip = $linksAll.not(filterSkip), // All items that can potentially be hidden
|
||||||
$linksFirst = $linksNotSkip.not(filterLast), // The items that will be hidden first
|
$linksFirst = $linksNotSkip.not(filterLast), // The items that will be hidden first
|
||||||
$linksLast = $linksNotSkip.filter(filterLast), // The items that will be hidden last
|
$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"> </a><div class="dropdown hidden"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>',
|
html = '<li class="responsive-menu hidden"><a href="javascript:void(0);" class="responsive-menu-link"> </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.
|
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(),
|
$children = column.children(),
|
||||||
html = column.html();
|
html = column.html();
|
||||||
|
|
||||||
if ($children.length == 1 && $children.text() == column.text()) {
|
if ($children.length === 1 && $children.text() === column.text()) {
|
||||||
html = $children.html();
|
html = $children.html();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,8 +723,7 @@ function parseDocument($container) {
|
||||||
if (!$block.length) {
|
if (!$block.length) {
|
||||||
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
||||||
$block = $this.find('dt .responsive-show:last-child');
|
$block = $this.find('dt .responsive-show:last-child');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
first = ($.trim($block.text()).length === 0);
|
first = ($.trim($block.text()).length === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +733,7 @@ function parseDocument($container) {
|
||||||
children = column.children(),
|
children = column.children(),
|
||||||
html = column.html();
|
html = column.html();
|
||||||
|
|
||||||
if (children.length == 1 && children.text() == column.text()) {
|
if (children.length === 1 && children.text() === column.text()) {
|
||||||
html = children.html();
|
html = children.html();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +762,7 @@ function parseDocument($container) {
|
||||||
// Find each header
|
// Find each header
|
||||||
$th.each(function(column) {
|
$th.each(function(column) {
|
||||||
var cell = $(this),
|
var cell = $(this),
|
||||||
colspan = parseInt(cell.attr('colspan')),
|
colspan = parseInt(cell.attr('colspan'), 10),
|
||||||
dfn = cell.attr('data-dfn'),
|
dfn = cell.attr('data-dfn'),
|
||||||
text = dfn ? dfn : cell.text();
|
text = dfn ? dfn : cell.text();
|
||||||
|
|
||||||
|
@ -788,14 +793,14 @@ function parseDocument($container) {
|
||||||
cells = row.children('td'),
|
cells = row.children('td'),
|
||||||
column = 0;
|
column = 0;
|
||||||
|
|
||||||
if (cells.length == 1) {
|
if (cells.length === 1) {
|
||||||
row.addClass('big-column');
|
row.addClass('big-column');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cells.each(function() {
|
cells.each(function() {
|
||||||
var cell = $(this),
|
var cell = $(this),
|
||||||
colspan = parseInt(cell.attr('colspan')),
|
colspan = parseInt(cell.attr('colspan'), 10),
|
||||||
text = $.trim(cell.text());
|
text = $.trim(cell.text());
|
||||||
|
|
||||||
if (headersLength <= column) {
|
if (headersLength <= column) {
|
||||||
|
@ -871,19 +876,26 @@ function parseDocument($container) {
|
||||||
total = $availableTabs.length,
|
total = $availableTabs.length,
|
||||||
i, $tab;
|
i, $tab;
|
||||||
|
|
||||||
for (i = total - 1; i >= 0; i --) {
|
for (i = total - 1; i >= 0; i--) {
|
||||||
$tab = $availableTabs.eq(i);
|
$tab = $availableTabs.eq(i);
|
||||||
$menu.prepend($tab.clone(true).removeClass('tab'));
|
$menu.prepend($tab.clone(true).removeClass('tab'));
|
||||||
$tab.hide();
|
$tab.hide();
|
||||||
if ($this.height() <= maxHeight) {
|
if ($this.height() <= maxHeight) {
|
||||||
$menu.find('a').click(function() { check(true); });
|
$menu.find('a').click(function() {
|
||||||
|
check(true);
|
||||||
|
});
|
||||||
return;
|
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);
|
check(true);
|
||||||
$(window).resize(check);
|
$(window).resize(check);
|
||||||
|
|
Loading…
Add table
Reference in a new issue