]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/javascript/lib/js/opac/search_bar.js
memory leak debugging, removed closures
[working/Evergreen.git] / Open-ILS / src / javascript / lib / js / opac / search_bar.js
1 var searchBarExpanded = false;
2 /* our search selector boxes */
3 var _ts, _fs, _ds;
4
5
6 /* if set by the org selector, this will be the location used the
7         next time the search is submitted */
8 var newSearchLocation; 
9
10 function searchBarInit() {
11
12         _ts = G.ui.searchbar.type_selector;
13         _ds = G.ui.searchbar.depth_selector;
14         _fs = G.ui.searchbar.form_selector;
15
16         G.ui.searchbar.text.focus();
17         G.ui.searchbar.text.onkeydown = 
18                 function(evt) {if(userPressedEnter(evt)) searchBarSubmit();};
19
20         G.ui.searchbar.submit.onclick = searchBarSubmit;
21         G.ui.searchbar.tag.onclick = searchBarToggle;
22
23         /* set up the selector objects, etc */
24         G.ui.searchbar.text.value = (getTerm() != null) ? getTerm() : "";
25         setSelector(_ts,        getStype());
26         setSelector(_ds,        getDepth());
27         setSelector(_fs,        getForm());
28         G.ui.searchbar.location_tag.onclick = _opacHandleLocationTagClick;
29 }
30
31 function _opacHandleLocationTagClick() {
32         orgTreeSelector.openTo(  
33                 (newSearchLocation != null) ? parseInt(newSearchLocation) : getLocation(), true );
34         swapCanvas(G.ui.common.org_container);
35 }
36
37 function updateLoc(location, depth) {
38         if( location != null )
39                 newSearchLocation = location;
40         if( depth != null ) 
41                 setSelector(G.ui.searchbar.depth_selector, depth);
42 }
43 function searchBarSubmit() {
44
45         var text = G.ui.searchbar.text.value;
46         if(!text || text == "") return;
47
48
49         var args = {};
50         args.page                               = MRESULT;
51         args[PARAM_OFFSET]      = 0;
52         args[PARAM_TERM]                = text;
53         args[PARAM_STYPE]               = _ts.options[_ts.selectedIndex].value;
54         args[PARAM_LOCATION] = newSearchLocation;
55         args[PARAM_DEPTH]               = parseInt(_ds.options[_ds.selectedIndex].value);
56         args[PARAM_FORM]                = _fs.options[_fs.selectedIndex].value;
57
58         goTo(buildOPACLink(args));
59 }
60
61
62 function searchBarToggle() {
63         if(searchBarExpanded) {
64                 hideMe(G.ui.searchbar.extra_row);
65                 hideMe(G.ui.searchbar.tag_on);
66                 unHideMe(G.ui.searchbar.tag_off);
67         } else {
68                 unHideMe(G.ui.searchbar.extra_row);
69                 hideMe(G.ui.searchbar.tag_off);
70                 unHideMe(G.ui.searchbar.tag_on);
71         }
72         searchBarExpanded = !searchBarExpanded;
73 }
74
75