brooklyn-docs/website/learnmore/catalog/index.html [78:135]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - var $element = $(element), $tab = $element.parent(), kind = $tab.attr("id"), collection = items[kind]; if (!collection) { console.warn("Unable to determine type for input", element); return; } // Number.MAX_VALUE configures Bloodhound to return all matches. var bloodhound = new Bloodhound({ name: kind, local: collection, limit: Number.MAX_VALUE, datumTokenizer: function (d) { return Bloodhound.tokenizers.nonword(d.type); }, queryTokenizer: Bloodhound.tokenizers.nonword }); bloodhound.initialize(); // Filter items as input changes var allAnchors = $tab.find("a").map(function (index, a) { return $(a); }); var hideAnchorsNotMatchingQuery = function () { var query = $element.val(); query = query.trim(); if (!query) { $tab.find("a").removeClass("hide"); } else { var matchedTypes = {}; bloodhound.get(query, function (suggestions) { _.each(suggestions, function (s) { // approximate a set! matchedTypes[s.type] = true; }); }); _.each(allAnchors, function (a) { if (_.has(matchedTypes, a.data("type"))) { a.removeClass("hide"); } else { a.addClass("hide"); } }); } }; $element.on("input", hideAnchorsNotMatchingQuery); // In case page is loaded with text in input, e.g. from back button. hideAnchorsNotMatchingQuery(); $element.on("keydown", function (e) { if (e.keyCode == ESCAPE_KEY) { $element.val(""); hideAnchorsNotMatchingQuery(); } }); }; $(document).ready(function () { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - brooklyn-server/server-cli/src/main/resources/brooklyn/item-lister/statics/brooklyn-object-list.html [78:135]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - var $element = $(element), $tab = $element.parent(), kind = $tab.attr("id"), collection = items[kind]; if (!collection) { console.warn("Unable to determine type for input", element); return; } // Number.MAX_VALUE configures Bloodhound to return all matches. var bloodhound = new Bloodhound({ name: kind, local: collection, limit: Number.MAX_VALUE, datumTokenizer: function (d) { return Bloodhound.tokenizers.nonword(d.type); }, queryTokenizer: Bloodhound.tokenizers.nonword }); bloodhound.initialize(); // Filter items as input changes var allAnchors = $tab.find("a").map(function (index, a) { return $(a); }); var hideAnchorsNotMatchingQuery = function () { var query = $element.val(); query = query.trim(); if (!query) { $tab.find("a").removeClass("hide"); } else { var matchedTypes = {}; bloodhound.get(query, function (suggestions) { _.each(suggestions, function (s) { // approximate a set! matchedTypes[s.type] = true; }); }); _.each(allAnchors, function (a) { if (_.has(matchedTypes, a.data("type"))) { a.removeClass("hide"); } else { a.addClass("hide"); } }); } }; $element.on("input", hideAnchorsNotMatchingQuery); // In case page is loaded with text in input, e.g. from back button. hideAnchorsNotMatchingQuery(); $element.on("keydown", function (e) { if (e.keyCode == ESCAPE_KEY) { $element.val(""); hideAnchorsNotMatchingQuery(); } }); }; $(document).ready(function () { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -