1 var searchBarExpanded = false;
\r
2 /* our search selector boxes */
\r
4 var isFrontPage = false;
\r
5 G.evt.common.init.push(searchBarInit);
\r
7 /* if set by the org selector, this will be the location used the
\r
8 next time the search is submitted */
\r
9 var newSearchLocation;
\r
10 var newSearchDepth = null;
\r
13 function searchBarInit() {
\r
15 _ts = G.ui.searchbar.type_selector;
\r
16 _fs = G.ui.searchbar.form_selector;
\r
18 try{G.ui.searchbar.text.focus();}catch(e){}
\r
19 G.ui.searchbar.text.onkeydown = function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } };
\r
20 _ts.onkeydown = function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } };
\r
21 _fs.onkeydown = function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } };
\r
23 G.ui.searchbar.submit.onclick = searchBarSubmit;
\r
25 /* set up the selector objects, etc */
\r
26 G.ui.searchbar.text.value = (getTerm() != null) ? getTerm() : "";
\r
27 G.ui.searchbar.facets.value = (getFacet() != null) ? getFacet() : "";
\r
28 setSelector(_ts, getStype());
\r
29 setSelector(_fs, getForm());
\r
34 var searches = JSON2js(getSearches());
\r
35 setSelector(_fs, searches[1].term);
\r
36 if(!G.ui.searchbar.text.value) G.ui.searchbar.text.value = searches[0].term;
\r
39 if(!isFrontPage && (findCurrentPage() != MYOPAC)) {
\r
40 attachEvt('common','depthChanged', searchBarSubmit);
\r
43 if( (limit = $('opac.result.limit2avail')) ) {
\r
44 if(getAvail()) limit.checked = true;
\r
45 if(getSort() && getSortDir())
\r
46 setSelector($('opac.result.sort'), getSort()+'.'+getSortDir());
\r
49 if( (limit2 = $('opac.result.limit2avail2')) ) if(getAvail()) limit2.checked = true;
\r
52 function searchBarSubmit(isFilterSort) {
\r
53 var text = G.ui.searchbar.text.value;
\r
54 var facet_text = isFrontPage ? '' : G.ui.searchbar.facets.value;
\r
55 clearSearchParams();
\r
56 if(!text || text == "" || text == "Search Keyword") return;
\r
57 //var d = (newSearchDepth != null) ? newSearchDepth : depthSelGetDepth();
\r
62 if(SHOW_MR_DEFAULT || (isFilterSort && findCurrentPage() == MRESULT)) {
\r
63 args.page = MRESULT;
\r
65 args.page = RRESULT;
\r
66 args[PARAM_RTYPE] = _ts.options[_ts.selectedIndex].value;
\r
69 // The following commented-out code does not do what it is apparently
\r
70 // intended to do and has no effect on search other than causing load
\r
72 args[PARAM_STYPE] = _ts.options[_ts.selectedIndex].value;
\r
73 args[PARAM_LOCATION] = depthSelGetNewLoc();
\r
74 args[PARAM_DEPTH] = d;
\r
76 var val = _fs.options[_fs.selectedIndex].value;
\r
78 args[PARAM_SEARCHES] = '[{"term":"'+text+'","restrict":[{"tag":"245","subfield":"a"}]},{"term":"'+val+'","restrict":[{"tag":"998","subfield":"d"}]}]';
\r
79 args[PARAM_ADVTYPE] = ADVTYPE_MARC;
\r
80 args[PARAM_TERM] = "";
\r
81 args[PARAM_FORM] = 'all';
\r
82 args[PARAM_RTYPE] = RTYPE_MARC;
\r
84 args[PARAM_TERM] = text;
\r
85 args[PARAM_FACET]= facet_text;
\r
89 args[PARAM_STYPE] = _ts.options[_ts.selectedIndex].value;
\r
90 args[PARAM_TERM] = text;
\r
91 args[PARAM_FACET] = facet_text;
\r
92 args[PARAM_LOCATION] = depthSelGetNewLoc();
\r
93 args[PARAM_DEPTH] = d;
\r
94 args[PARAM_FORM] = _fs.options[_fs.selectedIndex].value;
\r
96 if($('opac.result.limit2avail') && !arguments[1]) {
\r
97 args[PARAM_AVAIL] = ($('opac.result.limit2avail').checked) ? 1 : '';
\r
98 if( (val = getSelectorVal($('opac.result.sort'))) ) {
\r
99 args[PARAM_SORT] = val.split('.')[0];
\r
100 args[PARAM_SORT_DIR] = val.split('.')[1];
\r
102 } else if(arguments[1]) {
\r
103 args[PARAM_AVAIL] = (arguments[1].checked) ? 1 : '';
\r
104 if( (val = getSelectorVal($('opac.result.sort'))) ) {
\r
105 args[PARAM_SORT] = val.split('.')[0];
\r
106 args[PARAM_SORT_DIR] = val.split('.')[1];
\r
110 goTo(buildOPACLink(args));
\r