Skip to content

Commit dd8c3f8

Browse files
kswedbergrdworth
authored andcommitted
API sites: Add list filtering from search field.
(cherry picked from commit cbb1689) Conflicts: themes/jquery/js/plugins.js themes/jquery/js/scripts.js
1 parent c7ee4e7 commit dd8c3f8

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

themes/jquery/js/plugins.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,3 +1008,43 @@ window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=
10081008
itemWidth:0,itemMargin:0,minItems:0,maxItems:0,move:0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};d.fn.flexslider=function(i){void 0===i&&(i={});if("object"===typeof i)return this.each(function(){var a=d(this),c=a.find(i.selector?i.selector:".slides > li");1===c.length?(c.fadeIn(400),i.start&&i.start(a)):void 0===a.data("flexslider")&&new d.flexslider(this,i)});var k=d(this).data("flexslider");switch(i){case "play":k.play();break;
10091009
case "pause":k.pause();break;case "next":k.flexAnimate(k.getTarget("next"),!0);break;case "prev":case "previous":k.flexAnimate(k.getTarget("prev"),!0);break;default:"number"===typeof i&&k.flexAnimate(i,!0)}}})(jQuery);
10101010

1011+
1012+
1013+
/*
1014+
* LIVE UPDATE
1015+
* for filtering lists of methods from the search field on api sites
1016+
*/
1017+
(function($) {
1018+
1019+
$.fn.liveUpdate = function(list) {
1020+
list = $(list);
1021+
1022+
var filter = function() {
1023+
var term = $.trim( $(this).val().toLowerCase() ), scores = [];
1024+
1025+
if ( !term ) {
1026+
rows.show().addClass("keynav withoutfocus");
1027+
} else {
1028+
rows.hide().removeClass("keynav withfocus withoutfocus");
1029+
1030+
cache.each(function(i){
1031+
if ( this.indexOf( term ) > -1 ) {
1032+
$(rows[i]).show().addClass("keynav withoutfocus");
1033+
}
1034+
});
1035+
}
1036+
};
1037+
1038+
if ( list.length ) {
1039+
var rows = list.children(),
1040+
cache = rows.map(function(){
1041+
return $(this).text().toLowerCase();
1042+
});
1043+
1044+
this
1045+
.keyup(filter).keyup();
1046+
}
1047+
1048+
return this;
1049+
};
1050+
})(jQuery);

themes/jquery/js/scripts.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$(function() {
2+
3+
// Filter lists on api sites if on home, category, or search results pages
4+
if ( location.hostname.indexOf("api.") > -1 &&
5+
/\b(?:home|category|search-results)\b/.test( document.body.className ) ) {
6+
7+
$("form.searchform").find( "input[type=text]" ).liveUpdate( "#body .inner" );
8+
9+
}
10+
});

0 commit comments

Comments
 (0)