diff options
author | joeycastillo <joeycastillo@users.noreply.github.com> | 2022-02-05 18:37:05 +0000 |
---|---|---|
committer | joeycastillo <joeycastillo@users.noreply.github.com> | 2022-02-05 18:37:05 +0000 |
commit | 595c3cb881c14a28d37a8a9a3e4aadc79285a673 (patch) | |
tree | dee69ea8a38ab86fce7496f39c402244c75b7878 /search/search.js | |
parent | 12daf390078506a2a48c331752a5c69894aa01ec (diff) | |
download | Sensor-Watch-595c3cb881c14a28d37a8a9a3e4aadc79285a673.tar.gz Sensor-Watch-595c3cb881c14a28d37a8a9a3e4aadc79285a673.tar.bz2 Sensor-Watch-595c3cb881c14a28d37a8a9a3e4aadc79285a673.zip |
deploy: c74cacd34f68f2897fbd63e2ba90831f87cbad49
Diffstat (limited to 'search/search.js')
-rw-r--r-- | search/search.js | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/search/search.js b/search/search.js index fb226f73..ac8055d1 100644 --- a/search/search.js +++ b/search/search.js @@ -80,7 +80,7 @@ function getYPos(item) storing this instance. Is needed to be able to set timeouts. resultPath - path to use for external files */ -function SearchBox(name, resultsPath, inFrame, label, extension) +function SearchBox(name, resultsPath, label, extension) { if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); } if (!extension || extension == "") { extension = ".html"; } @@ -96,7 +96,6 @@ function SearchBox(name, resultsPath, inFrame, label, extension) this.hideTimeout = 0; this.searchIndex = 0; this.searchActive = false; - this.insideFrame = inFrame; this.searchLabel = label; this.extension = extension; @@ -136,30 +135,14 @@ function SearchBox(name, resultsPath, inFrame, label, extension) var searchSelectWindow = this.DOMSearchSelectWindow(); var searchField = this.DOMSearchSelect(); - if (this.insideFrame) - { - var left = getXPos(searchField); - var top = getYPos(searchField); - left += searchField.offsetWidth + 6; - top += searchField.offsetHeight; - - // show search selection popup - searchSelectWindow.style.display='block'; - left -= searchSelectWindow.offsetWidth; - searchSelectWindow.style.left = left + 'px'; - searchSelectWindow.style.top = top + 'px'; - } - else - { - var left = getXPos(searchField); - var top = getYPos(searchField); - top += searchField.offsetHeight; - - // show search selection popup - searchSelectWindow.style.display='block'; - searchSelectWindow.style.left = left + 'px'; - searchSelectWindow.style.top = top + 'px'; - } + var left = getXPos(searchField); + var top = getYPos(searchField); + top += searchField.offsetHeight; + + // show search selection popup + searchSelectWindow.style.display='block'; + searchSelectWindow.style.left = left + 'px'; + searchSelectWindow.style.top = top + 'px'; // stop selection hide timer if (this.hideTimeout) @@ -367,25 +350,18 @@ function SearchBox(name, resultsPath, inFrame, label, extension) { var domSearchBox = this.DOMSearchBox(); this.DOMSearchClose().style.display = 'inline-block'; - if (this.insideFrame) - { - var domPopupSearchResults = this.DOMPopupSearchResults(); - domPopupSearchResultsWindow.style.position = 'relative'; - domPopupSearchResultsWindow.style.display = 'block'; - var width = document.body.clientWidth - 8; // the -8 is for IE :-( - domPopupSearchResultsWindow.style.width = width + 'px'; - domPopupSearchResults.style.width = width + 'px'; - } - else - { - var domPopupSearchResults = this.DOMPopupSearchResults(); - var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; - var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; - domPopupSearchResultsWindow.style.display = 'block'; - left -= domPopupSearchResults.offsetWidth; - domPopupSearchResultsWindow.style.top = top + 'px'; - domPopupSearchResultsWindow.style.left = left + 'px'; - } + var domPopupSearchResults = this.DOMPopupSearchResults(); + var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; + var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; + domPopupSearchResultsWindow.style.display = 'block'; + left -= domPopupSearchResults.offsetWidth; + var maxWidth = document.body.clientWidth; + var width = 400; + if (left<10) left=10; + if (width+left+8>maxWidth) width=maxWidth-left-8; + domPopupSearchResultsWindow.style.top = top + 'px'; + domPopupSearchResultsWindow.style.left = left + 'px'; + domPopupSearchResultsWindow.style.width = width + 'px'; } this.lastSearchValue = searchValue; @@ -764,6 +740,7 @@ function createResults() if (searchData[e][1].length==2) // single result { srLink.setAttribute('href',searchData[e][1][1][0]); + srLink.setAttribute('onclick','parent.searchBox.CloseResultsWindow()'); if (searchData[e][1][1][1]) { srLink.setAttribute('target','_parent'); @@ -785,6 +762,7 @@ function createResults() setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')'); setClassAttr(srChild,'SRScope'); srChild.setAttribute('href',searchData[e][1][c+1][0]); + srChild.setAttribute('onclick','parent.searchBox.CloseResultsWindow()'); if (searchData[e][1][c+1][1]) { srChild.setAttribute('target','_parent'); |