]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/opac/SearchBarFormChunk.js
web batch update
[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         debug("Initing searchBarFormchunk");
13         this.search_query                       = getById("mr_search_query");
14         this.search_type                        = getById("mr_search_type");
15         this.search_button              = getById("mr_search_button");
16         this.searchRange                        = getById("search_range_select");
17 }
18
19 SearchBarFormChunk.prototype.resetPage = function() {
20
21         debug("pageReset on SearchBarFormChunk");
22         this.search_button.onclick              = mrSearchSubmitForm;
23         this.search_query.onkeydown     = mrSearchSubmitOnEnter;
24         this.search_type.onkeydown              = mrSearchSubmitOnEnter;
25
26         if(paramObj.__mr_search_query)
27                 this.search_query.value = paramObj.__mr_search_query;
28
29         if(paramObj.__mr_search_type)
30                 this.search_type.value = paramObj.__mr_search_type;
31
32         try{ this.search_query.focus(); } catch(E) {}
33
34         for( var index in globalOrgTypes ) {
35                 var otype = globalOrgTypes[index]
36                 var select =  new Option(otype.name(), otype.depth());
37
38                 if( otype.depth() == globalSearchDepth )
39                         select.selected = true;
40
41                 this.searchRange.options[index] = select;
42         }
43
44 }
45         
46         
47 function mrSearchSubmitForm() {
48         var search_query                = getById("mr_search_query").value;
49         var search_type         = getById("mr_search_type").value;
50
51         debug("Submitting MR search via form");
52
53         url_redirect( [ 
54                         "target",                               "mr_result",
55                         "mr_search_type",               search_type,
56                         "mr_search_query",      search_query,
57                         "page",                                 0
58                         ] );
59 }
60
61
62 /* forces the submission of the search */
63 function mrSearchSubmitOnEnter(evt) {
64         evt = (evt) ? evt : ((window.event) ? event : null); /* for mozilla and IE */
65         var obj = globalSearchBarFormChunk;
66         var code = grabCharCode(evt); 
67         if(code==13||code==3) { 
68                 mrSearchSubmitForm();
69         }
70 }
71
72
73