2010-05-08 18:07:31 +00:00
|
|
|
---
|
|
|
|
title: Search | Compass Documentation
|
|
|
|
crumb: Search
|
|
|
|
body_id: search
|
|
|
|
---
|
|
|
|
- content_for(:javascripts) do
|
2010-11-22 01:11:43 +00:00
|
|
|
%script(type="text/javascript" src="/javascripts/search-data.js")
|
|
|
|
%script(type="text/javascript" src="/javascripts/jquery.url.packed.js")
|
2010-05-08 18:07:31 +00:00
|
|
|
:javascript
|
|
|
|
$(function(){
|
2010-05-08 22:23:07 +00:00
|
|
|
if ($.url.param("q")) {
|
2010-05-08 22:40:07 +00:00
|
|
|
var query = $.url.param("q").replace("+"," ");
|
|
|
|
$('input#q').attr('value', query);
|
|
|
|
search(query, displayResults);
|
2010-05-08 22:23:07 +00:00
|
|
|
}
|
|
|
|
$('input#q').keyup(function(){
|
2010-05-08 18:07:31 +00:00
|
|
|
search(this.value, displayResults);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
function displayResults(items) {
|
|
|
|
if (items.length > 0) {
|
|
|
|
var html = ""
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
html += '<li><a href="'+items[i].url+'">'+items[i].title+'</a></li>';
|
|
|
|
}
|
|
|
|
$('ol#results').html(html)
|
|
|
|
} else {
|
|
|
|
$('ol#results').html("<li class='none'>Nothing found.</li>");
|
|
|
|
}
|
|
|
|
}
|
2010-05-08 22:23:07 +00:00
|
|
|
%input#q{:type => "text", :placeholder=>"Search"}
|
2010-05-08 18:07:31 +00:00
|
|
|
|
|
|
|
%ol#results
|
|
|
|
%li.none Please enter a search term.
|