3 var globalSearchBarFormChunk = null;
5 function SearchBarFormChunk() {
7 globalSearchBarFormChunk = this;
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");
19 SearchBarFormChunk.prototype.resetPage = function() {
23 this.search_button.onclick = mrSearchSubmitForm;
24 this.search_query.onkeydown = mrSearchSubmitOnEnter;
25 this.search_type.onkeydown = mrSearchSubmitOnEnter;
28 if(paramObj.__mr_search_query)
29 this.search_query.value = paramObj.__mr_search_query;
31 if(paramObj.__mr_search_type)
32 this.search_type.value = paramObj.__mr_search_type;
34 try{ this.search_query.focus(); } catch(E) {}
42 SearchBarFormChunk.prototype.resetRange = function() {
44 this.searchRange = getById("search_range_select");
45 var orgunit = globalSelectedLocation;
47 orgunit = globalLocation;
49 if(this.searchRange) {
50 for( var index in globalOrgTypes ) {
51 var otype = globalOrgTypes[index];
53 if( otype.depth() > orgunit.ou_type() )
56 var select = new Option(otype.name(), otype.depth());
58 debug("org depth " + otype.name() + " : " + otype.depth() );
59 if( otype.depth() == globalSearchDepth ) {
60 debug("Building range selector with depth "
61 + globalSearchDepth + " and name " + otype.name() );
62 select.selected = true;
65 this.searchRange.options[index] = select;
72 function mrSearchSubmitForm() {
73 var search_query = getById("mr_search_query").value;
74 var search_type = getById("mr_search_type").value;
77 var depth = globalSearchDepth;
78 var location = globalSelectedLocation;
80 location = globalLocation.id();
82 location = location.id();
85 "target", "mr_result",
86 "mr_search_type", search_type,
87 "mr_search_query", search_query,
88 "mr_search_location", location,
89 "mr_search_depth", depth,
95 /* forces the submission of the search */
96 function mrSearchSubmitOnEnter(evt) {
97 evt = (evt) ? evt : ((window.event) ? event : null); /* for mozilla and IE */
98 var obj = globalSearchBarFormChunk;
99 var code = grabCharCode(evt);
100 if(code==13||code==3) {
101 mrSearchSubmitForm();