-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-filter the 'Available' plugin manager tab, allow multiple terms #4580
Changes from all commits
b9e4d4c
42cfea9
03d2937
142a786
a73f86c
104e745
dd0c8d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,30 +9,42 @@ function checkPluginsWithoutWarnings() { | |
} | ||
|
||
Behaviour.specify("#filter-box", '_table', 0, function(e) { | ||
function applyFilter() { | ||
var filter = e.value.toLowerCase(); | ||
["TR.plugin","TR.plugin-category"].each(function(clz) { | ||
var encountered = {}; | ||
var items = document.getElementsBySelector(clz); | ||
for (var i=0; i<items.length; i++) { | ||
var visible = (filter=="" || items[i].innerHTML.toLowerCase().indexOf(filter)>=0); | ||
var name = items[i].cells && items[i].cells.length > 1 | ||
? items[i].cells[1].getAttribute('data-id') | ||
: items[i].getAttribute("name"); | ||
if (visible && name != null) { | ||
if (encountered[name]) { | ||
visible = false; | ||
} | ||
encountered[name] = true; | ||
function applyFilter() { | ||
var filter = e.value.toLowerCase().trim(); | ||
var filterParts = filter.split(/ +/).filter (word => word.length > 0); | ||
var items = document.getElementsBySelector("TR.plugin"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unchanged from before, just threw out the other, obsolete selector There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like I didn't read the diff properly then 👍 |
||
var anyVisible = false; | ||
for (var i=0; i<items.length; i++) { | ||
if ((filterParts.length < 1 || filter.length < 2) && items[i].hasClassName("hidden-by-default")) { | ||
items[i].addClassName("hidden"); | ||
continue; | ||
} | ||
var makeVisible = true; | ||
|
||
var content = items[i].innerHTML.toLowerCase(); | ||
for (var j = 0; j < filterParts.length; j++) { | ||
var part = filterParts[j]; | ||
if (content.indexOf(part) < 0) { | ||
makeVisible = false; | ||
break; | ||
} | ||
items[i].style.display = (visible ? "" : "none"); | ||
} | ||
}); | ||
if (makeVisible) { | ||
items[i].removeClassName("hidden"); | ||
anyVisible = true; | ||
} else { | ||
items[i].addClassName("hidden"); | ||
} | ||
} | ||
var instructions = document.getElementById("hidden-by-default-instructions") | ||
if (instructions) { | ||
instructions.style.display = anyVisible ? 'none' : ''; | ||
} | ||
|
||
layoutUpdateCallback.call(); | ||
} | ||
layoutUpdateCallback.call(); | ||
} | ||
|
||
e.onkeyup = applyFilter; | ||
e.onkeyup = applyFilter; | ||
}); | ||
|
||
/** | ||
|
@@ -407,3 +419,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) { | |
setEnableWidgetStates(); | ||
}); | ||
}()); | ||
|
||
Element.observe(window, "load", function() { | ||
document.getElementById('filter-box').focus(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encountered
andTR.plugin-category
have been obsolete since #4534.