[ticket/10954] Fix coding guidelines infractions

PHPBB3-10954
This commit is contained in:
Marc Alexander 2012-12-15 21:12:52 +01:00
parent 16c021e986
commit 61ef870fd5

View file

@ -4,25 +4,22 @@
// This callback will mark all forum icons read // This callback will mark all forum icons read
phpbb.add_ajax_callback('mark_forums_read', function(res) { phpbb.add_ajax_callback('mark_forums_read', function(res) {
var read_title = res.NO_UNREAD_POSTS; var readTitle = res.NO_UNREAD_POSTS;
var unread_title = res.UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS;
$('li.row').find('dl.forum_unread, dl.forum_unread_subforum, dl.forum_unread_locked').each(function() { $('li.row').find('dl.forum_unread, dl.forum_unread_subforum, dl.forum_unread_locked').each(function() {
var current_object = $(this); var currentObject = $(this);
if (current_object.hasClass('forum_unread')) if (currentObject.hasClass('forum_unread')) {
{ currentObject.removeClass('forum_unread').addClass('forum_read');
current_object.removeClass('forum_unread').addClass('forum_read');
} }
else if (current_object.hasClass('forum_unread_subforum')) else if (currentObject.hasClass('forum_unread_subforum')) {
{ currentObject.removeClass('forum_unread_subforum').addClass('forum_read_subforum');
current_object.removeClass('forum_unread_subforum').addClass('forum_read_subforum');
} }
else else {
{ currentObject.removeClass('forum_unread_locked').addClass('forum_read_locked');
current_object.removeClass('forum_unread_locked').addClass('forum_read_locked');
} }
current_object.children('dt[title=' + unread_title + ']').attr('title', read_title); currentObject.children('dt[title=' + unreadTitle + ']').attr('title', readTitle);
}); });
// Update mark forums read links // Update mark forums read links
@ -38,45 +35,43 @@ phpbb.add_ajax_callback('mark_forums_read', function(res) {
// This callback will mark all topic icons read // This callback will mark all topic icons read
phpbb.add_ajax_callback('mark_topics_read', function(res) { phpbb.add_ajax_callback('mark_topics_read', function(res) {
var read_title = res.NO_UNREAD_POSTS; var readTitle = res.NO_UNREAD_POSTS;
var unread_title = res.UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS;
var icons_array = { 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 icons_state = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine']; var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
var unread_class_selectors = ''; var unreadClassSelectors = '';
var class_array = {}; var classArray = {};
$.each(icons_array, function(unread_class, read_class) { $.each(iconsArray, function(unreadClass, readClass) {
$.each(icons_state, function(key, value) { $.each(iconsState, function(key, value) {
// Only topics can be hot // Only topics can be hot
if ((value == '_hot' || value == '_hot_mine') && unread_class != 'topic_unread') if ((value == '_hot' || value == '_hot_mine') && unreadClass != 'topic_unread') {
{
return true; return true;
} }
var current_class = {}; var currentClass = {};
current_class[unread_class + value] = read_class + value; currentClass[unreadClass + value] = readClass + value;
$.extend(class_array, current_class); $.extend(classArray, currentClass);
unread_class_selectors += '.' + unread_class + value + ','; unreadClassSelectors += '.' + unreadClass + value + ',';
}); });
}); });
// Remove trailing comma // Remove trailing comma
unread_class_selectors = unread_class_selectors.substring(0, unread_class_selectors.length - 1); unreadClassSelectors = unreadClassSelectors.substring(0, unreadClassSelectors.length - 1);
$('li.row').find(unread_class_selectors).each(function() { $('li.row').find(unreadClassSelectors).each(function() {
var current_object = $(this); var currentObject = $(this);
$.each(class_array, function(unread_class, read_class) { $.each(classArray, function(unreadClass, readClass) {
if (current_object.hasClass(unread_class)) if (currentObject.hasClass(unreadClass)) {
{ currentObject.removeClass(unreadClass).addClass(readClass);
current_object.removeClass(unread_class).addClass(read_class);
} }
}); });
current_object.children('dt[title=' + unread_title + ']').attr('title', read_title); currentObject.children('dt[title=' + unreadTitle + ']').attr('title', readTitle);
}); });
// Remove link to first unread post // Remove link to first unread post