Skip to content

Commit 6698777

Browse files
committed
Use full page for search results
1 parent df63da0 commit 6698777

File tree

3 files changed

+65
-19
lines changed

3 files changed

+65
-19
lines changed

css/ddox.css

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,36 @@ a.inherited:after { content: url(../images/ddox/inherited.png); padding-left: 3p
5353

5454
#symbolSearch { width: 112pt; }
5555

56+
#symbolSearchResultsContainer {
57+
width: 80%;
58+
margin: 0 auto;
59+
padding: 0.3em;
60+
display: none;
61+
}
62+
5663
#symbolSearchResults {
57-
background: #F5F5F5;
58-
border: 1px solid #CCC;
5964
font-size: small;
6065
list-style: none;
61-
margin: 0;
6266
margin-top: 5px;
63-
padding: 0.3em;
64-
position: absolute;
65-
right: -1px;
66-
top: 100%;
67-
width: 100%;
68-
z-index: 1000;
67+
-moz-column-gap: 20px;
68+
-webkit-column-gap: 20px;
69+
column-gap: 20px;
70+
-moz-column-width: 17.5em;
71+
-webkit-column-width: 17.5em;
72+
column-width: 17.5em;
73+
list-style-type: none;
74+
font-size: 1.2em;
75+
}
76+
77+
#symbolSearchCloseButton {
78+
float: right;
79+
font-size: 1.5em;
6980
}
7081

7182
#symbolSearchResults li {
7283
background-repeat: no-repeat;
7384
background-position: left center;
74-
padding-left: 18px;
85+
padding: 15px;
7586
}
7687

7788
#top #symbolSearchResults li a {

dpl-docs/views/layout.dt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ html(lang='en-US')
136136
button(type='submit')
137137
i.fa.fa-search
138138
span go
139-
include ddox.inc.symbol-search.results
140139

140+
#symbolSearchResultsContainer
141+
include ddox.inc.symbol-search.results
141142
.container
142143
.subnav-helper
143144
.subnav

js/ddox.js

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
function getParameterByName(name, url) {
2+
if (!url) url = window.location.href;
3+
name = name.replace(/[\[\]]/g, "\\$&");
4+
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
5+
results = regex.exec(url);
6+
if (!results) return '';
7+
if (!results[2]) return '';
8+
return decodeURIComponent(results[2].replace(/\+/g, " "));
9+
}
10+
111
function setupDdox()
212
{
313
$(".tree-view").children(".package").click(toggleTree);
@@ -6,6 +16,12 @@ function setupDdox()
616

717
updateSearchBox();
818
$('#sitesearch').change(updateSearchBox);
19+
20+
var searchParam = getParameterByName("q");
21+
if (searchParam.length > 0) {
22+
$("#symbolSearch").val(searchParam)
23+
performSymbolSearch(40);
24+
}
925
}
1026

1127
function updateSearchBox()
@@ -30,17 +46,24 @@ function toggleTree()
3046
var searchCounter = 0;
3147
var lastSearchString = "";
3248

49+
var closeButton = undefined;
50+
3351
function performSymbolSearch(maxlen)
3452
{
3553
if (maxlen === 'undefined') maxlen = 26;
3654

3755
var searchstring = $("#symbolSearch").val().toLowerCase();
3856

57+
if (searchstring.length === 0) {
58+
$('.container').show();
59+
return;
60+
}
61+
3962
if (searchstring == lastSearchString) return;
4063
lastSearchString = searchstring;
4164

4265
var scnt = ++searchCounter;
43-
$('#symbolSearchResults').hide();
66+
$('#symbolSearchResultsContainer').hide();
4467
$('#symbolSearchResults').empty();
4568

4669
var terms = $.trim(searchstring).split(/\s+/);
@@ -97,6 +120,15 @@ function performSymbolSearch(maxlen)
97120

98121
results.sort(compare);
99122

123+
if (closeButton === undefined) {
124+
closeButton = $("<div id='symbolSearchCloseButton'><i class='fa fa-times big-icon'></i></div>");
125+
closeButton.on("click", function() {
126+
$('#symbolSearchResultsContainer').hide();
127+
$('.container').show();
128+
});
129+
$('#symbolSearchResultsContainer').prepend(closeButton);
130+
}
131+
100132
for (i = 0; i < results.length && i < 100; i++) {
101133
var sym = results[i];
102134

@@ -127,14 +159,16 @@ function performSymbolSearch(maxlen)
127159
}
128160

129161
$('#symbolSearchResults').show();
162+
$('#symbolSearchResultsContainer').show();
163+
$('.container').hide();
130164
}
131165

132166
$(function(){
133-
$("#search-box form").on("submit", function(e) {
134-
var searchResults = $('#symbolSearchResults').children();
135-
if (searchResults.length > 0) {
136-
window.location = searchResults.first().find("a").attr("href");
137-
e.preventDefault();
138-
}
139-
});
167+
$("#search-box form").on("submit", function(e) {
168+
var searchResults = $('#symbolSearchResults').children();
169+
if (searchResults.length > 0) {
170+
window.location = searchResults.first().find("a").attr("href");
171+
e.preventDefault();
172+
}
173+
});
140174
});

0 commit comments

Comments
 (0)