1 /*---------------- Search Box */
16 background-color: white;
26 background:url('search_l.png') no-repeat;
27 background-position:right;
37 .left #MSearchSelect {
41 .right #MSearchSelect {
49 background:url('search_m.png') repeat-x;
56 font: 9pt Arial, Verdana, sans-serif;
59 #FSearchBox #MSearchField {
70 background:url('search_r.png') no-repeat;
71 background-position:left;
80 margin: 0px 4px 0px 0px;
89 .right #MSearchClose {
93 .MSearchBoxActive #MSearchField {
97 /*---------------- Search filter selection */
99 #MSearchSelectWindow {
103 border: 1px solid #90A5CE;
104 background-color: #F9FAFC;
108 -moz-border-radius: 4px;
109 -webkit-border-top-left-radius: 4px;
110 -webkit-border-top-right-radius: 4px;
111 -webkit-border-bottom-left-radius: 4px;
112 -webkit-border-bottom-right-radius: 4px;
113 -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
117 font: 8pt Arial, Verdana, sans-serif;
125 font-family: monospace;
127 text-decoration: none;
134 text-decoration: none;
140 a.SelectItem:active {
143 text-decoration: none;
148 background-color: #3D578C;
150 text-decoration: none;
155 /*---------------- Search results window */
157 iframe#MSearchResults {
162 #MSearchResultsWindow {
166 border: 1px solid #000;
167 background-color: #EEF1F7;
170 /* ----------------------------------- */
175 padding-bottom: 15px;
193 padding-left: 3ex; padding-bottom: .5em
196 .SRPage .SRChildren {
203 font-family: Arial, Verdana, sans-serif;
204 text-decoration: none;
211 font-family: Arial, Verdana, sans-serif;
212 text-decoration: none;
216 a.SRSymbol:focus, a.SRSymbol:active,
217 a.SRScope:focus, a.SRScope:active {
218 text-decoration: underline;
240 /*---------------- External search page results */
243 background-color: #F0F3F8;
248 padding: 5px 5px 3px 5px;
249 background-image: url("../tab_a.png");
250 background-repeat: repeat-x;
251 text-shadow: 0 1px 1px #000000;
257 text-decoration: none;
272 function convertToId(search)
275 for (i=0;i<search.length;i++)
277 var c = search.charAt(i);
278 var cn = c.charCodeAt(0);
279 if (c.match(/[a-z0-9\u0080-\uFFFF]/))
285 result+="_0"+cn.toString(16);
289 result+="_"+cn.toString(16);
295 function getXPos(item)
298 if (item.offsetWidth)
300 while (item && item!=document.body)
302 x += item.offsetLeft;
303 item = item.offsetParent;
309 function getYPos(item)
312 if (item.offsetWidth)
314 while (item && item!=document.body)
317 item = item.offsetParent;
323 /* A class handling everything associated with the search panel.
326 name - The name of the global variable that will be
327 storing this instance. Is needed to be able to set timeouts.
328 resultPath - path to use for external files
330 function SearchBox(name, resultsPath, inFrame, label)
332 if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); }
334 // ---------- Instance variables
336 this.resultsPath = resultsPath;
338 this.keyTimeoutLength = 500;
339 this.closeSelectionTimeout = 300;
340 this.lastSearchValue = "";
341 this.lastResultsPage = "";
342 this.hideTimeout = 0;
343 this.searchIndex = 0;
344 this.searchActive = false;
345 this.insideFrame = inFrame;
346 this.searchLabel = label;
348 // ----------- DOM Elements
350 this.DOMSearchField = function()
351 { return document.getElementById("MSearchField"); }
353 this.DOMSearchSelect = function()
354 { return document.getElementById("MSearchSelect"); }
356 this.DOMSearchSelectWindow = function()
357 { return document.getElementById("MSearchSelectWindow"); }
359 this.DOMPopupSearchResults = function()
360 { return document.getElementById("MSearchResults"); }
362 this.DOMPopupSearchResultsWindow = function()
363 { return document.getElementById("MSearchResultsWindow"); }
365 this.DOMSearchClose = function()
366 { return document.getElementById("MSearchClose"); }
368 this.DOMSearchBox = function()
369 { return document.getElementById("MSearchBox"); }
371 // ------------ Event Handlers
373 // Called when focus is added or removed from the search field.
374 this.OnSearchFieldFocus = function(isActive)
376 this.Activate(isActive);
379 this.OnSearchSelectShow = function()
381 var searchSelectWindow = this.DOMSearchSelectWindow();
382 var searchField = this.DOMSearchSelect();
384 if (this.insideFrame)
386 var left = getXPos(searchField);
387 var top = getYPos(searchField);
388 left += searchField.offsetWidth + 6;
389 top += searchField.offsetHeight;
391 // show search selection popup
392 searchSelectWindow.style.display='block';
393 left -= searchSelectWindow.offsetWidth;
394 searchSelectWindow.style.left = left + 'px';
395 searchSelectWindow.style.top = top + 'px';
399 var left = getXPos(searchField);
400 var top = getYPos(searchField);
401 top += searchField.offsetHeight;
403 // show search selection popup
404 searchSelectWindow.style.display='block';
405 searchSelectWindow.style.left = left + 'px';
406 searchSelectWindow.style.top = top + 'px';
409 // stop selection hide timer
410 if (this.hideTimeout)
412 clearTimeout(this.hideTimeout);
415 return false; // to avoid "image drag" default event
418 this.OnSearchSelectHide = function()
420 this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()",
421 this.closeSelectionTimeout);
424 // Called when the content of the search field is changed.
425 this.OnSearchFieldChange = function(evt)
427 if (this.keyTimeout) // kill running timer
429 clearTimeout(this.keyTimeout);
433 var e = (evt) ? evt : window.event; // for IE
434 if (e.keyCode==40 || e.keyCode==13)
438 this.OnSearchSelectShow();
439 var win=this.DOMSearchSelectWindow();
440 for (i=0;i<win.childNodes.length;i++)
442 var child = win.childNodes[i]; // get span within a
443 if (child.className=='SelectItem')
451 else if (window.frames.MSearchResults.searchResults)
453 var elem = window.frames.MSearchResults.searchResults.NavNext(0);
454 if (elem) elem.focus();
457 else if (e.keyCode==27) // Escape out of the search field
459 this.DOMSearchField().blur();
460 this.DOMPopupSearchResultsWindow().style.display = 'none';
461 this.DOMSearchClose().style.display = 'none';
462 this.lastSearchValue = '';
463 this.Activate(false);
468 var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
470 if (searchValue != this.lastSearchValue) // search value has changed
472 if (searchValue != "") // non-empty search
474 // set timer for search update
475 this.keyTimeout = setTimeout(this.name + '.Search()',
476 this.keyTimeoutLength);
478 else // empty search field
480 this.DOMPopupSearchResultsWindow().style.display = 'none';
481 this.DOMSearchClose().style.display = 'none';
482 this.lastSearchValue = '';
487 this.SelectItemCount = function(id)
490 var win=this.DOMSearchSelectWindow();
491 for (i=0;i<win.childNodes.length;i++)
493 var child = win.childNodes[i]; // get span within a
494 if (child.className=='SelectItem')
502 this.SelectItemSet = function(id)
505 var win=this.DOMSearchSelectWindow();
506 for (i=0;i<win.childNodes.length;i++)
508 var child = win.childNodes[i]; // get span within a
509 if (child.className=='SelectItem')
511 var node = child.firstChild;
514 node.innerHTML='•';
518 node.innerHTML=' ';
525 // Called when an search filter selection is made.
526 // set item with index id as the active item
527 this.OnSelectItem = function(id)
529 this.searchIndex = id;
530 this.SelectItemSet(id);
531 var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
532 if (searchValue!="" && this.searchActive) // something was found -> do a search
538 this.OnSearchSelectKey = function(evt)
540 var e = (evt) ? evt : window.event; // for IE
541 if (e.keyCode==40 && this.searchIndex<this.SelectItemCount()) // Down
544 this.OnSelectItem(this.searchIndex);
546 else if (e.keyCode==38 && this.searchIndex>0) // Up
549 this.OnSelectItem(this.searchIndex);
551 else if (e.keyCode==13 || e.keyCode==27)
553 this.OnSelectItem(this.searchIndex);
554 this.CloseSelectionWindow();
555 this.DOMSearchField().focus();
562 // Closes the results window.
563 this.CloseResultsWindow = function()
565 this.DOMPopupSearchResultsWindow().style.display = 'none';
566 this.DOMSearchClose().style.display = 'none';
567 this.Activate(false);
570 this.CloseSelectionWindow = function()
572 this.DOMSearchSelectWindow().style.display = 'none';
575 // Performs a search.
576 this.Search = function()
580 // strip leading whitespace
581 var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
583 var code = searchValue.toLowerCase().charCodeAt(0);
584 var idxChar = searchValue.substr(0, 1).toLowerCase();
585 if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
587 idxChar = searchValue.substr(0, 2);
591 var resultsPageWithSearch;
594 var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
597 var hexCode=idx.toString(16);
598 resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html';
599 resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
600 hasResultsPage = true;
602 else // nothing available for this search term
604 resultsPage = this.resultsPath + '/nomatches.html';
605 resultsPageWithSearch = resultsPage;
606 hasResultsPage = false;
609 window.frames.MSearchResults.location = resultsPageWithSearch;
610 var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
612 if (domPopupSearchResultsWindow.style.display!='block')
614 var domSearchBox = this.DOMSearchBox();
615 this.DOMSearchClose().style.display = 'inline';
616 if (this.insideFrame)
618 var domPopupSearchResults = this.DOMPopupSearchResults();
619 domPopupSearchResultsWindow.style.position = 'relative';
620 domPopupSearchResultsWindow.style.display = 'block';
621 var width = document.body.clientWidth - 8; // the -8 is for IE :-(
622 domPopupSearchResultsWindow.style.width = width + 'px';
623 domPopupSearchResults.style.width = width + 'px';
627 var domPopupSearchResults = this.DOMPopupSearchResults();
628 var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth;
629 var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1;
630 domPopupSearchResultsWindow.style.display = 'block';
631 left -= domPopupSearchResults.offsetWidth;
632 domPopupSearchResultsWindow.style.top = top + 'px';
633 domPopupSearchResultsWindow.style.left = left + 'px';
637 this.lastSearchValue = searchValue;
638 this.lastResultsPage = resultsPage;
641 // -------- Activation Functions
643 // Activates or deactivates the search panel, resetting things to
644 // their default values if necessary.
645 this.Activate = function(isActive)
647 if (isActive || // open it
648 this.DOMPopupSearchResultsWindow().style.display == 'block'
651 this.DOMSearchBox().className = 'MSearchBoxActive';
653 var searchField = this.DOMSearchField();
655 if (searchField.value == this.searchLabel) // clear "Search" term upon entry
657 searchField.value = '';
658 this.searchActive = true;
661 else if (!isActive) // directly remove the panel
663 this.DOMSearchBox().className = 'MSearchBoxInactive';
664 this.DOMSearchField().value = this.searchLabel;
665 this.searchActive = false;
666 this.lastSearchValue = ''
667 this.lastResultsPage = '';
672 // -----------------------------------------------------------------------
674 // The class that handles everything on the search results page.
675 function SearchResults(name)
677 // The number of matches from the last run of <Search()>.
678 this.lastMatchCount = 0;
680 this.repeatOn = false;
682 // Toggles the visibility of the passed element ID.
683 this.FindChildElement = function(id)
685 var parentElement = document.getElementById(id);
686 var element = parentElement.firstChild;
688 while (element && element!=parentElement)
690 if (element.nodeName == 'DIV' && element.className == 'SRChildren')
695 if (element.nodeName == 'DIV' && element.hasChildNodes())
697 element = element.firstChild;
699 else if (element.nextSibling)
701 element = element.nextSibling;
707 element = element.parentNode;
709 while (element && element!=parentElement && !element.nextSibling);
711 if (element && element!=parentElement)
713 element = element.nextSibling;
719 this.Toggle = function(id)
721 var element = this.FindChildElement(id);
724 if (element.style.display == 'block')
726 element.style.display = 'none';
730 element.style.display = 'block';
735 // Searches for the passed string. If there is no parameter,
736 // it takes it from the URL query.
738 // Always returns true, since other documents may try to call it
739 // and that may or may not be possible.
740 this.Search = function(search)
742 if (!search) // get search word from URL
744 search = window.location.search;
745 search = search.substring(1); // Remove the leading '?'
746 search = unescape(search);
749 search = search.replace(/^ +/, ""); // strip leading spaces
750 search = search.replace(/ +$/, ""); // strip trailing spaces
751 search = search.toLowerCase();
752 search = convertToId(search);
754 var resultRows = document.getElementsByTagName("div");
758 while (i < resultRows.length)
760 var row = resultRows.item(i);
761 if (row.className == "SRResult")
763 var rowMatchName = row.id.toLowerCase();
764 rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
766 if (search.length<=rowMatchName.length &&
767 rowMatchName.substr(0, search.length)==search)
769 row.style.display = 'block';
774 row.style.display = 'none';
779 document.getElementById("Searching").style.display='none';
780 if (matches == 0) // no results
782 document.getElementById("NoMatches").style.display='block';
784 else // at least one result
786 document.getElementById("NoMatches").style.display='none';
788 this.lastMatchCount = matches;
792 // return the first item with index index or higher that is visible
793 this.NavNext = function(index)
798 var focusName = 'Item'+index;
799 focusItem = document.getElementById(focusName);
800 if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
804 else if (!focusItem) // last element
814 this.NavPrev = function(index)
819 var focusName = 'Item'+index;
820 focusItem = document.getElementById(focusName);
821 if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
825 else if (!focusItem) // last element
835 this.ProcessKeys = function(e)
837 if (e.type == "keydown")
839 this.repeatOn = false;
840 this.lastKey = e.keyCode;
842 else if (e.type == "keypress")
846 if (this.lastKey) this.repeatOn = true;
847 return false; // ignore first keypress after keydown
850 else if (e.type == "keyup")
853 this.repeatOn = false;
855 return this.lastKey!=0;
858 this.Nav = function(evt,itemIndex)
860 var e = (evt) ? evt : window.event; // for IE
861 if (e.keyCode==13) return true;
862 if (!this.ProcessKeys(e)) return false;
864 if (this.lastKey==38) // Up
866 var newIndex = itemIndex-1;
867 var focusItem = this.NavPrev(newIndex);
870 var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
871 if (child && child.style.display == 'block') // children visible
875 while (1) // search for last child
877 tmpElem = document.getElementById('Item'+newIndex+'_c'+n);
894 else // return focus to search field
896 parent.document.getElementById("MSearchField").focus();
899 else if (this.lastKey==40) // Down
901 var newIndex = itemIndex+1;
903 var item = document.getElementById('Item'+itemIndex);
904 var elem = this.FindChildElement(item.parentNode.parentNode.id);
905 if (elem && elem.style.display == 'block') // children visible
907 focusItem = document.getElementById('Item'+itemIndex+'_c0');
909 if (!focusItem) focusItem = this.NavNext(newIndex);
910 if (focusItem) focusItem.focus();
912 else if (this.lastKey==39) // Right
914 var item = document.getElementById('Item'+itemIndex);
915 var elem = this.FindChildElement(item.parentNode.parentNode.id);
916 if (elem) elem.style.display = 'block';
918 else if (this.lastKey==37) // Left
920 var item = document.getElementById('Item'+itemIndex);
921 var elem = this.FindChildElement(item.parentNode.parentNode.id);
922 if (elem) elem.style.display = 'none';
924 else if (this.lastKey==27) // Escape
926 parent.searchBox.CloseResultsWindow();
927 parent.document.getElementById("MSearchField").focus();
929 else if (this.lastKey==13) // Enter
936 this.NavChild = function(evt,itemIndex,childIndex)
938 var e = (evt) ? evt : window.event; // for IE
939 if (e.keyCode==13) return true;
940 if (!this.ProcessKeys(e)) return false;
942 if (this.lastKey==38) // Up
946 var newIndex = childIndex-1;
947 document.getElementById('Item'+itemIndex+'_c'+newIndex).focus();
949 else // already at first child, jump to parent
951 document.getElementById('Item'+itemIndex).focus();
954 else if (this.lastKey==40) // Down
956 var newIndex = childIndex+1;
957 var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex);
958 if (!elem) // last child, jump to parent next parent
960 elem = this.NavNext(itemIndex+1);
967 else if (this.lastKey==27) // Escape
969 parent.searchBox.CloseResultsWindow();
970 parent.document.getElementById("MSearchField").focus();
972 else if (this.lastKey==13) // Enter
980 function setKeyActions(elem,action)
982 elem.setAttribute('onkeydown',action);
983 elem.setAttribute('onkeypress',action);
984 elem.setAttribute('onkeyup',action);
987 function setClassAttr(elem,attr)
989 elem.setAttribute('class',attr);
990 elem.setAttribute('className',attr);
993 function createResults()
995 var results = document.getElementById("SRResults");
996 for (var e=0; e<searchData.length; e++)
998 var id = searchData[e][0];
999 var srResult = document.createElement('div');
1000 srResult.setAttribute('id','SR_'+id);
1001 setClassAttr(srResult,'SRResult');
1002 var srEntry = document.createElement('div');
1003 setClassAttr(srEntry,'SREntry');
1004 var srLink = document.createElement('a');
1005 srLink.setAttribute('id','Item'+e);
1006 setKeyActions(srLink,'return searchResults.Nav(event,'+e+')');
1007 setClassAttr(srLink,'SRSymbol');
1008 srLink.innerHTML = searchData[e][1][0];
1009 srEntry.appendChild(srLink);
1010 if (searchData[e][1].length==2) // single result
1012 srLink.setAttribute('href',searchData[e][1][1][0]);
1013 if (searchData[e][1][1][1])
1015 srLink.setAttribute('target','_parent');
1017 var srScope = document.createElement('span');
1018 setClassAttr(srScope,'SRScope');
1019 srScope.innerHTML = searchData[e][1][1][2];
1020 srEntry.appendChild(srScope);
1022 else // multiple results
1024 srLink.setAttribute('href','javascript:searchResults.Toggle("SR_'+id+'")');
1025 var srChildren = document.createElement('div');
1026 setClassAttr(srChildren,'SRChildren');
1027 for (var c=0; c<searchData[e][1].length-1; c++)
1029 var srChild = document.createElement('a');
1030 srChild.setAttribute('id','Item'+e+'_c'+c);
1031 setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')');
1032 setClassAttr(srChild,'SRScope');
1033 srChild.setAttribute('href',searchData[e][1][c+1][0]);
1034 if (searchData[e][1][c+1][1])
1036 srChild.setAttribute('target','_parent');
1038 srChild.innerHTML = searchData[e][1][c+1][2];
1039 srChildren.appendChild(srChild);
1041 srEntry.appendChild(srChildren);
1043 srResult.appendChild(srEntry);
1044 results.appendChild(srResult);
1048 function init_search()
1050 var results = document.getElementById("MSearchSelectWindow");
1051 for (var key in indexSectionLabels)
1053 var link = document.createElement('a');
1054 link.setAttribute('class','SelectItem');
1055 link.setAttribute('onclick','searchBox.OnSelectItem('+key+')');
1056 link.href='javascript:void(0)';
1057 link.innerHTML='<span class="SelectionMark"> </span>'+indexSectionLabels[key];
1058 results.appendChild(link);
1060 searchBox.OnSelectItem(0);