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