compass/doc-src/content/search.haml
2010-05-08 15:23:07 -07:00

33 lines
994 B
Plaintext

---
title: Search | Compass Documentation
crumb: Search
body_id: search
---
- content_for(:javascripts) do
%script(type="text/javascript" src="/docs/javascripts/search-data.js")
%script(type="text/javascript" src="/docs/javascripts/jquery.url.packed.js")
:javascript
$(function(){
if ($.url.param("q")) {
$('input#q').attr('value', $.url.param("q"));
search($.url.param("q"), displayResults);
}
$('input#q').keyup(function(){
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>");
}
}
%input#q{:type => "text", :placeholder=>"Search"}
%ol#results
%li.none Please enter a search term.