Skip to content

Commit

Permalink
Fixing documentcloud#27: Broken filter matches when typing a colon. F…
Browse files Browse the repository at this point in the history
…allout from turning VS into an instance-based script. Needed correct options callback.
  • Loading branch information
samuelclay committed Nov 24, 2011
1 parent ad86cce commit c2ab97d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
Binary file modified build-min/dependencies.js.gz
Binary file not shown.
8 changes: 4 additions & 4 deletions build-min/visualsearch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build-min/visualsearch.js.gz
Binary file not shown.
Binary file modified build-min/visualsearch_templates.js.gz
Binary file not shown.
7 changes: 6 additions & 1 deletion build/visualsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,12 @@ VS.ui.SearchInput = Backbone.View.extend({
} else if (VS.app.hotkeys.colon(e)) {
this.box.trigger('resize.autogrow', e);
var query = this.box.val();
var prefixes = this.options.callbacks.facetMatches() || [];
var prefixes = [];
if (this.app.options.callbacks.facetMatches) {
this.app.options.callbacks.facetMatches(function(p) {
prefixes = p;
});
}
var labels = _.map(prefixes, function(prefix) {
if (prefix.label) return prefix.label;
else return prefix;
Expand Down
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ <h2 id="demo">Demo <span class="demo-hint"><i>Try searching for: <b>account</b>,

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var visualSearch = VS.init({
window.visualSearch = VS.init({
container : $('#search_box_container'),
query : 'country: "South Africa" account: 5-samuel title: "Pentagon Papers"',
// query : '',
Expand Down
7 changes: 6 additions & 1 deletion lib/js/views/search_input.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,12 @@ VS.ui.SearchInput = Backbone.View.extend({
} else if (VS.app.hotkeys.colon(e)) {
this.box.trigger('resize.autogrow', e);
var query = this.box.val();
var prefixes = this.options.callbacks.facetMatches() || [];
var prefixes = [];
if (this.app.options.callbacks.facetMatches) {
this.app.options.callbacks.facetMatches(function(p) {
prefixes = p;
});
}
var labels = _.map(prefixes, function(prefix) {
if (prefix.label) return prefix.label;
else return prefix;
Expand Down

0 comments on commit c2ab97d

Please sign in to comment.