Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
Changes to mod log matrix
Browse files Browse the repository at this point in the history
- Shadow banned and deleted users are unchecked by default in the mod
filter.
- Auto-refreshing only applies to mod filtering when there are fewer
than 20 mods on the list, for performance reasons.
- Added "show header labels" option.
  • Loading branch information
LowSociety committed Feb 4, 2014
1 parent 4e98a8b commit 1d170ce
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
29 changes: 26 additions & 3 deletions modmatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ var modLogMatrix = {

// Moderator filter
var modFilterRow = $("<tr><td>moderators:</td></tr>");
var modFilterCell = $("<div></div>").wrap("<td></td>").hide();
var modFilterCell = $("<div></div>").wrap("<td></td>").hide().attr("id", "modfilter");
modFilterCell.append('<div><input type="checkbox" value="" id="modmatrixmodfilter-all" checked="checked" /><label for="modmatrixmodfilter-all">All</label></div>');
for(var moderator in this.subredditModerators) {
modFilterCell.append('<div style="padding-left: 10px;"><input class=\"mod-filter\" type="checkbox" value="' + moderator + '" id="modmatrixmodfilter-' + moderator + '" checked="checked" /><label for="modmatrixmodfilter-' + moderator + '">' + moderator + '</label></div>');
modFilterCell.append('<div style="padding-left: 10px;"><input class=\"mod-filter\" type="checkbox" value="' + moderator + '" id="modmatrixmodfilter-' + moderator + '" /><label for="modmatrixmodfilter-' + moderator + '">' + moderator + '</label></div>');
}
modMatrixSettings.find("table").append(modFilterRow);
var addButton = $("<a></a>").text("show moderator filter").insertBefore(modFilterCell);
Expand All @@ -186,6 +186,24 @@ var modLogMatrix = {
modFilterCell.find(".mod-filter").change(function() { if($("#mod-matrix-settings .mod-filter:not(:checked)").length > 0) { $("#modmatrixmodfilter-all").removeAttr("checked"); } else { $("#modmatrixmodfilter-all").prop("checked", "checked"); }});
addButton.click(function() { if(modFilterCell.is(":hidden")) { modFilterCell.show(); $(this).text("hide moderator filter"); } else { modFilterCell.hide(); $(this).text("show moderator filter"); }});

// Unless we're on /r/mod, we want to check the mod filters for _active_ mods. These do not include shadow banned and deleted users
if(this.subredditName != "mod") {
var subredditNames = this.subredditName.split("+");
var self = this;
for(var i = 0; i < subredditNames.length; i++) {
$.getJSON("/r/" + subredditNames[i] + "/about/moderators.json", function(moderatorData) {
for(var j = 0; j < moderatorData.data.children.length; j++) {
$("#modmatrixmodfilter-" + moderatorData.data.children[j].name).prop("checked", "checked");
}
if($("#mod-matrix-settings .mod-filter:not(:checked)").length > 0) {
$("#modmatrixmodfilter-all").removeAttr("checked");
} else {
$("#modmatrixmodfilter-all").prop("checked", "checked");
}
});
}
}

// Action filter
var actionFilterRow = $("<tr><td>actions:</td></tr>");
var actionFilterCell = $("<div></div>").wrap("<td></td>").hide();
Expand All @@ -206,10 +224,15 @@ var modLogMatrix = {
actionFilterCell.find(".action-filter").change(function() { if($("#mod-matrix-settings .action-filter:not(:checked)").length > 0) { $("#modmatrixactionfilter-all").removeAttr("checked"); } else { $("#modmatrixactionfilter-all").prop("checked", "checked"); }});
addButton.click(function() { if(actionFilterCell.is(":hidden")) { actionFilterCell.show(); $(this).text("hide action filter"); } else { actionFilterCell.hide(); $(this).text("show action filter"); }});

modMatrixSettings.find(".action-filter, .mod-filter").change(function() {
// Automatic refresh the table when action filter is changed. Same thing with mod filter, as long as there are fewer than 20 mods
modMatrixSettings.find(".action-filter" + (modMatrixSettings.find(".mod-filter").length < 20? ", .mod-filter" : "")).change(function() {
modLogMatrix.refreshTable();
});

// Show labels
modMatrixSettings.find("table").append('<tr><td><label for="showlabels">show header labels:</label></td><td><input id="showlabels" type="checkbox" /></td></tr>');
$("#showlabels").change(function() { $("#mod-matrix").toggleClass("labels",this.checked); });

// Show percentages
modMatrixSettings.find("table").append('<tr><td><label for="showpercentages">show percentages:</label></td><td><input id="showpercentages" type="checkbox" checked="checked" /></td></tr>');
$("#showpercentages").change(function() { $("#mod-matrix .action-percentage").toggle(this.checked); $("#highlightpercentages").parent().parent().toggle(this.checked); });
Expand Down
10 changes: 8 additions & 2 deletions toolbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -972,15 +972,15 @@ background-color: #CEE3F8;
background: #F5F5F5;
}

/* Mod Log Matrix */
/* mod log matrix */
#mod-matrix-wrapper a { cursor: pointer; }

#mod-matrix thead th, #mod-matrix tfoot td, #mod-matrix tbody td.action-total, #mod-matrix tbody td.action-percentage { font-weight: bold; }
#mod-matrix tr{ border-bottom: 1px solid #eee; }
#mod-matrix tfoot tr { border-top: 1px solid #eee; }
#mod-matrix td, #mod-matrix th { padding: 5px; border-right: 1px solid #eee; text-align: center; font-size: x-small; }
#mod-matrix td:first-child, #mod-matrix th:first-child { text-align: left; }
#mod-matrix a.modactions { margin-right: 0px; }
#mod-matrix a.modactions { margin-right: 0px; display: inline-block; float: none; }
#mod-matrix tbody tr:nth-of-type(even) { background: #fafafa; }
#mod-matrix tr:hover, #mod-matrix td.hover { background: #ffc!important; }
#mod-matrix thead th { position: relative; cursor:s-resize; }
Expand All @@ -999,3 +999,9 @@ background: #F5F5F5;
#mod-matrix-statistics { margin-top: 1em; }
#mod-matrix-statistics { border-top: 1px dotted #000; padding: 7px; }
#mod-matrix-statistics strong { font-weight: bold; }

/* show header labels (thanks to /u/ashishtiwari) */
#mod-matrix.labels th { vertical-align: text-bottom; text-align: center; text-overflow: ellipsis; overflow: hidden; padding-top: 150px; }
#mod-matrix.labels a.modactions { vertical-align: bottom; width: 16px!important; height: 16px!important; }
#mod-matrix.labels a.modactions:before { content: attr(title); position: relative; bottom: 20px; display: block; font-size: 11px; white-space: nowrap; font-weight: normal; color: #000; -webkit-transform: rotate(-90.0deg); transform: rotate(-90.0deg); }

0 comments on commit 1d170ce

Please sign in to comment.