Commit 14686f69 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Hightlight matching words in search results.

parent 6e59a948
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -59,16 +59,23 @@ Ext.define("Docs.ClassRegistry", {
            var shift = r["private"] ? 4 : (r["removed"] ? 8 : 0);

            if (reFull.test(name)) {
                results[r.sort + shift].push(r);
                results[r.sort + shift].push(this.highlightMatch(r, reFull));
            }
            else if (reBeg.test(name)) {
                results[r.sort + shift + 12].push(r);
                results[r.sort + shift + 12].push(this.highlightMatch(r, reBeg));
            }
            else if (reMid.test(name)) {
                results[r.sort + shift + 24].push(r);
                results[r.sort + shift + 24].push(this.highlightMatch(r, reMid));
            }
        }

        return Ext.Array.flatten(results);
    },

    highlightMatch: function(r, regex) {
        r = Ext.apply({}, r);
        r.name = r.name.replace(regex, '<strong>$&</strong>');
        r.fullName = r.fullName.replace(regex, '<strong>$&</strong>');
        return r;
    }
});
+4 −1
Original line number Diff line number Diff line
@@ -86,7 +86,10 @@
    color: #605f5f;
    // Avoid wrapping titles of guides, videos, etc.
    .title, .class {
      white-space: pre; }
      white-space: pre;
      strong {
        background: rgba(0, 0, 0, 0.1);
        color: black; } }
    .title {
      font-weight: bold;
      overflow: hidden;