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
24 _fs.onchange = function(e) {
\r
25 var fs = G.ui.searchbar.form_selector;
\r
26 var val = fs.options[fs.selectedIndex].value;
\r
28 G.ui.searchbar.facets.value = val==''?'':"identifier|mattype["+val+"]";
\r
31 /* set up the selector objects, etc */
\r
32 var txtVal = (getTerm() != null) ? getTerm() : "";
\r
33 if(getStype()=="cn") txtVal = txtVal.replace(/identifier\|bibcn:/, "");
\r
35 G.ui.searchbar.text.value = txtVal;
\r
36 G.ui.searchbar.facets.value = (getFacet() != null) ? getFacet() : "";
\r
37 setSelector(_ts, getStype());
\r
38 setSelector(_fs, getForm());
\r
43 var searches = JSON2js(getSearches());
\r
44 setSelector(_fs, searches[1].term);
\r
45 if(!G.ui.searchbar.text.value) G.ui.searchbar.text.value = searches[0].term;
\r
48 if(!isFrontPage && (findCurrentPage() != MYOPAC)) {
\r
49 attachEvt('common','depthChanged', searchBarSubmit);
\r
52 if( (limit = $('opac.result.limit2avail')) ) {
\r
53 if(getAvail()) limit.checked = true;
\r
54 if(getSort() && getSortDir())
\r
55 setSelector($('opac.result.sort'), getSort()+'.'+getSortDir());
\r
58 if( (limit2 = $('opac.result.limit2avail2')) ) if(getAvail()) limit2.checked = true;
\r
61 function searchBarSubmit(isFilterSort) {
\r
62 var text = G.ui.searchbar.text.value;
\r
63 var facet_text = isFrontPage ? '' : G.ui.searchbar.facets.value;
\r
64 clearSearchParams();
\r
65 if(!text || text == "" || text == "Search Keyword") return;
\r
66 //var d = (newSearchDepth != null) ? newSearchDepth : depthSelGetDepth();
\r
71 if(SHOW_MR_DEFAULT || (isFilterSort && findCurrentPage() == MRESULT)) {
\r
72 args.page = MRESULT;
\r
74 args.page = RRESULT;
\r
75 args[PARAM_RTYPE] = _ts.options[_ts.selectedIndex].value;
\r
78 var tsVal = _ts.options[_ts.selectedIndex].value;
\r
80 args[PARAM_STYPE] = tsVal;
\r
81 args[PARAM_TERM] = tsVal=="cn"?"identifier|bibcn:"+text:text;
\r
82 args[PARAM_FACET] = facet_text;
\r
83 args[PARAM_LOCATION] = depthSelGetNewLoc();
\r
84 args[PARAM_DEPTH] = d;
\r
85 args[PARAM_FORM] = _fs.options[_fs.selectedIndex].value;
\r
86 //args[PARAM_SORT] = isFilterSort?'':'pubdate';
\r
87 //args[PARAM_SORT_DIR] = isFilterSort?'':'desc';
\r
89 if($('opac.result.limit2avail') && !arguments[1]) {
\r
90 args[PARAM_AVAIL] = ($('opac.result.limit2avail').checked) ? 1 : '';
\r
91 if( (val = getSelectorVal($('opac.result.sort'))) ) {
\r
92 args[PARAM_SORT] = val.split('.')[0];
\r
93 args[PARAM_SORT_DIR] = val.split('.')[1];
\r
95 } else if(arguments[1]) {
\r
96 args[PARAM_AVAIL] = (arguments[1].checked) ? 1 : '';
\r
97 if( (val = getSelectorVal($('opac.result.sort'))) ) {
\r
98 args[PARAM_SORT] = val.split('.')[0];
\r
99 args[PARAM_SORT_DIR] = val.split('.')[1];
\r
103 goTo(buildOPACLink(args));
\r