Skip to content

Commit 375f32f

Browse files
committed
Use full page for search results
1 parent 8a0296f commit 375f32f

File tree

3 files changed

+66
-19
lines changed

3 files changed

+66
-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
@@ -148,8 +148,9 @@ html(lang='en-US')
148148
button(type='submit')
149149
i.fa.fa-search
150150
span go
151-
include ddox.inc.symbol-search.results
152151

152+
#symbolSearchResultsContainer
153+
include ddox.inc.symbol-search.results
153154
.container
154155
.subnav-helper
155156
.subnav

js/ddox.js

Lines changed: 43 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,16 @@ function performSymbolSearch(maxlen)
97120

98121
results.sort(compare);
99122

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

@@ -127,14 +160,16 @@ function performSymbolSearch(maxlen)
127160
}
128161

129162
$('#symbolSearchResults').show();
163+
$('#symbolSearchResultsContainer').show();
164+
$('.container').hide();
130165
}
131166

132167
$(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-
});
168+
$("#search-box form").on("submit", function(e) {
169+
var searchResults = $('#symbolSearchResults').children();
170+
if (searchResults.length > 0) {
171+
window.location = searchResults.first().find("a").attr("href");
172+
e.preventDefault();
173+
}
174+
});
140175
});

0 commit comments

Comments
 (0)