%]" value="[% is_advanced ? ctx.naive_query_scrub(ctx.user_query) : CGI.param('query') | html %]"
[%- IF use_autosuggest.enabled == "t" %]
dojoType="openils.widget.AutoSuggest" type_selector="'qtype'"
- submitter="this.textbox.form.submit();"
+ submitter="this.textbox.form.submit();" min_search_length="1"
[%- IF use_autosuggest.value.search('opac_visible') %]
store_args='{"org_unit_getter": function() { return [% ctx.search_ou %]; }}'
[%- END # opac_visible -%]
are search_classes (required) */
"org_unit_getter": null, /* function that returns int (OU ID) */
+ "min_search_length": 1, /* Minimum number of characters in the search term before we suggest */
"limit": 10, /* number of suggestions at once */
"highlight_max": null, /* TS_HEADLINE()'s MaxWords option */
"highlight_min": null, /* TS_HEADLINE()'s MinWords option */
if (!term || term.length < 1 || term == "*") return null;
if (term.match(/[^\s*]$/)) term += " ";
term = term.replace(/\*$/, "");
+ term = term.replace(/\s+/g, " "); /* remove extra spaces */
+
+ /* test minimum length after normalization */
+ if (term.length < this.min_search_length) return null;
var params = [
"query=" + encodeURIComponent(term),
"hasDownArrow": false,
"autoComplete": false,
"searchDelay": 200,
+ "min_search_length": 1,
/* Don't forget to these two parameters when instantiating. */
"submitter": function() { console.log("No submitter connected"); },
if (typeof this.type_selector == "string")
this.type_selector = dojo.byId(this.type_selector);
- /* Save the instantiator from needing to specify same thing
- * twice, even though we need it and the store needs it too. */
+ /* Save the instantiator from needing to specify same things
+ * twice, even though we need them and the store needs them too. */
if (this.type_selector && !this.store_args.type_selector)
this.store_args.type_selector = this.type_selector;
+ if (this.min_search_length && !this.store_args.min_search_length) {
+ var val = parseInt(this.min_search_length);
+ if (!isNaN(val)) this.store_args.min_search_length = val;
+ }
+
this.store = new openils.AutoSuggestStore(this.store_args);
},