]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/opac/SearchBarFormChunk.js
removing old opac images and css
[Evergreen.git] / Open-ILS / src / javascript / opac / SearchBarFormChunk.js
1 /*  */
2
3 var globalSearchBarFormChunk = null;
4
5 function SearchBarFormChunk() {
6         this.init();
7         globalSearchBarFormChunk = this;
8 }
9
10
11 SearchBarFormChunk.prototype.init = function() {
12
13         debug("Initing searchBarFormchunk");
14         this.search_query                       = getById("mr_search_query");
15         this.search_type                        = getById("mr_search_type");
16         this.search_button              = getById("mr_search_button");
17         this.setFormat();
18 }
19
20
21 SearchBarFormChunk.prototype.setFormat = function() {
22         var fsel                                                = getById("mr_search_format");
23         var format                                      = paramObj.__format;
24         for( var idx = 0; idx != fsel.options.length; idx++ ) {
25                 var obj = fsel.options[idx];
26                 if(obj && obj.value == format) {
27                         fsel.selectedIndex = idx;
28                         obj.selected = true;
29                 }
30         }
31
32 }
33
34 SearchBarFormChunk.prototype.resetPage = function() {
35
36         this.init();
37
38         this.search_button.onclick              = mrSearchSubmitForm;
39         this.search_query.onkeydown     = mrSearchSubmitOnEnter;
40         this.search_type.onkeydown              = mrSearchSubmitOnEnter;
41
42         var s = paramObj.__mr_search_query;
43         if(!s) s = lastSearchString;
44         var t = paramObj.__mr_search_type;
45         if(!t) t = lastSearchType;
46         if(s) this.search_query.value = s;
47         if(t) this.search_type.value = t;
48
49         try{ this.search_query.focus(); } catch(E) {}
50
51 }
52
53
54         
55 function mrSearchSubmitForm() {
56
57         var search_query                = getById("mr_search_query").value;
58         var search_type         = getById("mr_search_type").value;
59         var form                                        = getById("mr_search_format").value 
60
61         if(search_query == null || search_query == "")
62                 return false;
63
64         var depth = globalSearchDepth;
65         var location = globalSelectedLocation;
66         if(location == null) 
67                 location = globalLocation.id();
68         else
69                 location = location.id();
70
71         url_redirect( [ 
72                         "target",                                       "mr_result",
73                         "mr_search_type",                       search_type,
74                         "mr_search_query",              search_query,
75                         "mr_search_location",   location,
76                         "mr_search_depth",              depth,
77                         "format",                                       form,
78                         "page",                                         0
79                         ] );
80 }
81
82
83 /* forces the submission of the search */
84 function mrSearchSubmitOnEnter(evt) {
85         var win = getWindow();
86         evt = (evt) ? evt : ((win.event) ? globalAppFrame.event : null); /* for mozilla and IE */
87         var obj = globalSearchBarFormChunk;
88         var code = grabCharCode(evt); 
89         if(code==13 || code==3) { 
90                 mrSearchSubmitForm();
91                 return false;
92         }
93 }
94
95
96