--- /dev/null
+if (!dojo._hasResource["openils.widget.AutoSuggest"]) {
+ dojo.provide("openils.widget.AutoSuggest");
+ dojo._hasResource["openils.widget.AutoSuggest"] = true;
+
+ dojo.require("dijit.form.ComboBox");
+ dojo.require("openils.AutoSuggestStore");
+
+ dojo.declare(
+ "openils.widget.AutoSuggest", [dijit.form.ComboBox], {
+
+ "labelAttr": "match",
+ "labelType": "html",
+ "searchAttr": "term",
+ "hasDownArrow": false,
+ "autoComplete": false,
+ "searchDelay": 200,
+
+ "postMixInProperties": function() {
+ this.inherited(arguments);
+
+ if (this.storeArgs)
+ this.store = new openils.AutoSuggestStore(this.storeArgs);
+ }
+ }
+ );
+}
var newSearchLocation;
var newSearchDepth = null;
-dojo.require("dijit.form.ComboBox");
-dojo.require("openils.AutoSuggestStore");
+dojo.require("openils.widget.AutoSuggest");
function updateSearchTypeSelector(id) {
/* Fail somewhat gracefully if a race condition, which I'm not /certain/
}
function autoSuggestInit() {
- var as_store = new openils.AutoSuggestStore(
+ var widg = new openils.widget.AutoSuggest(
{
- "type_selector": G.ui.searchbar.type_selector
- }
- );
-
- var widg = new dijit.form.ComboBox(
- {
- "store": as_store,
- "labelAttr": "match",
- "labelType": "html",
- "searchAttr": "term",
- "hasDownArrow": false,
- "autoComplete": false,
- "searchDelay": 200,
+ "storeArgs": {"type_selector": G.ui.searchbar.type_selector},
"onChange": function(value) {
if (typeof value.field == "number")
updateSearchTypeSelector(value.field);
if (event.charOrCode == dojo.keys.ENTER)
searchBarSubmit();
},
- "style": dojo.attr("search_box", "style")
+ "style": dojo.attr("search_box", "style"),
+ "value": ((getTerm() != null) ? getTerm() : "")
}, "search_box"
);
setSelector($('opac.result.sort'), getSort()+'.'+getSortDir());
}
- autoSuggestInit(); /* XXX TODO make this conditional. OU setting? */
+ autoSuggestInit(); /* XXX TODO make this conditional by global flag */
}
function searchBarSubmit(isFilterSort) {